diff --git a/dist/iwmlib.3rdparty.js b/dist/iwmlib.3rdparty.js index 115827c..9a4879a 100644 --- a/dist/iwmlib.3rdparty.js +++ b/dist/iwmlib.3rdparty.js @@ -47998,1109 +47998,1109 @@ var PIXI = (function (exports) { PIXI.useDeprecated(); -var e;e||(e=eval("(function() { try { return Module || {} } catch(e) { return {} } })()"));var aa={},k;for(k in e)e.hasOwnProperty(k)&&(aa[k]=e[k]);var ba="object"===typeof window,ca="function"===typeof importScripts,da="object"===typeof process&&"function"===typeof require&&!ba&&!ca,ea=!ba&&!da&&!ca; -if(da){e.print||(e.print=function(a){process.stdout.write(a+"\n")});e.printErr||(e.printErr=function(a){process.stderr.write(a+"\n")});var fa=require("fs"),ga=require("path");e.read=function(a,b){a=ga.normalize(a);var c=fa.readFileSync(a);c||a==ga.resolve(a)||(a=path.join(__dirname,"..","src",a),c=fa.readFileSync(a));c&&!b&&(c=c.toString());return c};e.readBinary=function(a){a=e.read(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a};e.load=function(a){ha(read(a))};e.thisProgram||(e.thisProgram= -1 0) var gc = undefined");else if(ba||ca)e.read=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},"undefined"!=typeof arguments&&(e.arguments=arguments),"undefined"!== -typeof console?(e.print||(e.print=function(a){console.log(a)}),e.printErr||(e.printErr=function(a){console.log(a)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),"undefined"===typeof e.setWindowTitle&&(e.setWindowTitle=function(a){document.title=a});else throw"Unknown runtime environment. Where are we?";function ha(a){eval.call(null,a)}!e.load&&e.read&&(e.load=function(a){ha(e.read(a))});e.print||(e.print=function(){});e.printErr||(e.printErr=e.print);e.arguments||(e.arguments=[]); -e.thisProgram||(e.thisProgram="./this.program");e.print=e.print;e.W=e.printErr;e.preRun=[];e.postRun=[];for(k in aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]); -var n={rb:function(a){ka=a},fb:function(){return ka},ua:function(){return m},ba:function(a){m=a},Ka:function(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?n.J:"i"===a[0]?(a=parseInt(a.substr(1)),assert(0===a%8),a/8):0}},eb:function(a){return Math.max(n.Ka(a),n.J)},ud:16,Qd:function(a,b){"double"===b||"i64"===b?a&7&&(assert(4===(a&7)),a+=4):assert(0===(a&3));return a}, -Ed:function(a,b,c){return c||"i64"!=a&&"double"!=a?a?Math.min(b||(a?n.eb(a):0),n.J):Math.min(b,8):8},L:function(a,b,c){return c&&c.length?(c.splice||(c=Array.prototype.slice.call(c)),c.splice(0,0,b),e["dynCall_"+a].apply(null,c)):e["dynCall_"+a].call(null,b)},Z:[],Xa:function(a){for(var b=0;b=t&&!ma()?(r=b,0): -b},ja:function(a,b){return Math.ceil(a/(b?b:16))*(b?b:16)},Nd:function(a,b,c){return c?+(a>>>0)+4294967296*+(b>>>0):+(a>>>0)+4294967296*+(b|0)},Ua:8,J:4,vd:0};e.Runtime=n;n.addFunction=n.Xa;n.removeFunction=n.nb;var na=!1,oa,pa,ka;function assert(a,b){a||x("Assertion failed: "+b)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(c){}assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)");return b}var ra,sa; -(function(){function a(a){a=a.toString().match(d).slice(1);return{arguments:a[0],body:a[1],returnValue:a[2]}}var b={stackSave:function(){n.ua()},stackRestore:function(){n.ba()},arrayToC:function(a){var b=n.aa(a.length);ta(a,b);return b},stringToC:function(a){var b=0;null!==a&&void 0!==a&&0!==a&&(b=n.aa((a.length<<2)+1),ua(a,b));return b}},c={string:b.stringToC,array:b.arrayToC};sa=function(a,b,d,f,g){a=qa(a);var v=[],B=0;if(f)for(var G=0;G>0]=b;break;case "i8":y[a>>0]=b;break;case "i16":z[a>>1]=b;break;case "i32":C[a>>2]=b;break;case "i64":pa=[b>>>0,(oa=b,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)];C[a>>2]=pa[0];C[a+4>>2]=pa[1];break;case "float":Ba[a>>2]=b;break;case "double":Ca[a>>3]=b;break;default:x("invalid type for setValue: "+c)}}e.setValue=wa; -function Da(a,b){b=b||"i8";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":return y[a>>0];case "i8":return y[a>>0];case "i16":return z[a>>1];case "i32":return C[a>>2];case "i64":return C[a>>2];case "float":return Ba[a>>2];case "double":return Ca[a>>3];default:x("invalid type for setValue: "+b)}return null}e.getValue=Da;e.ALLOC_NORMAL=0;e.ALLOC_STACK=1;e.ALLOC_STATIC=2;e.ALLOC_DYNAMIC=3;e.ALLOC_NONE=4; -function D(a,b,c,d){var f,g;"number"===typeof a?(f=!0,g=a):(f=!1,g=a.length);var h="string"===typeof b?b:null;c=4==c?d:[Ea,n.aa,n.Ra,n.R][void 0===c?2:c](Math.max(g,h?1:b.length));if(f){d=c;assert(0==(c&3));for(a=c+(g&-4);d>2]=0;for(a=c+g;d>0]=0;return c}if("i8"===h)return a.subarray||a.slice?E.set(a,c):E.set(new Uint8Array(a),c),c;d=0;for(var l,w;d>0];c|=d;if(0==d&&!b)break;f++;if(b&&f==b)break}b||(b=f);d="";if(128>c){for(;0>0];if(!c)return b;b+=String.fromCharCode(c)}}; -e.stringToAscii=function(a,b){return Ia(a,b,!1)}; -function Ja(a,b){for(var c,d,f,g,h,l,w="";;){c=a[b++];if(!c)return w;c&128?(d=a[b++]&63,192==(c&224)?w+=String.fromCharCode((c&31)<<6|d):(f=a[b++]&63,224==(c&240)?c=(c&15)<<12|d<<6|f:(g=a[b++]&63,240==(c&248)?c=(c&7)<<18|d<<12|f<<6|g:(h=a[b++]&63,248==(c&252)?c=(c&3)<<24|d<<18|f<<12|g<<6|h:(l=a[b++]&63,c=(c&1)<<30|d<<24|f<<18|g<<12|h<<6|l))),65536>c?w+=String.fromCharCode(c):(c-=65536,w+=String.fromCharCode(55296|c>>10,56320|c&1023)))):w+=String.fromCharCode(c)}}e.UTF8ArrayToString=Ja; -e.UTF8ToString=function(a){return Ja(E,a)}; -function Ka(a,b,c,d){if(!(0=h&&(h=65536+((h&1023)<<10)|a.charCodeAt(++g)&1023);if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(2097151>=h){if(c+3>=d)break;b[c++]=240|h>>18}else{if(67108863>=h){if(c+4>=d)break;b[c++]=248|h>>24}else{if(c+5>=d)break;b[c++]=252|h>>30;b[c++]=128|h>>24&63}b[c++]=128|h>>18&63}b[c++]=128| -h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-f}e.stringToUTF8Array=Ka;e.stringToUTF8=function(a,b,c){return Ka(a,E,b,c)};function La(a){for(var b=0,c=0;c=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:2097151>=d?b+4:67108863>=d?b+5:b+6}return b}e.lengthBytesUTF8=La;e.UTF16ToString=function(a){for(var b=0,c="";;){var d=z[a+2*b>>1];if(0==d)return c;++b;c+=String.fromCharCode(d)}}; -e.stringToUTF16=function(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f>1]=a.charCodeAt(f),b+=2;z[b>>1]=0;return b-d};e.lengthBytesUTF16=function(a){return 2*a.length};e.UTF32ToString=function(a){for(var b=0,c="";;){var d=C[a+4*b>>2];if(0==d)return c;++b;65536<=d?(d=d-65536,c+=String.fromCharCode(55296|d>>10,56320|d&1023)):c+=String.fromCharCode(d)}}; -e.stringToUTF32=function(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f=g)var h=a.charCodeAt(++f),g=65536+((g&1023)<<10)|h&1023;C[b>>2]=g;b+=4;if(b+4>c)break}C[b>>2]=0;return b-d};e.lengthBytesUTF32=function(a){for(var b=0,c=0;c=d&&++c;b+=4}return b}; -function Ma(a){function b(c,d,f){d=d||Infinity;var g="",h=[],v;if("N"===a[l]){l++;"K"===a[l]&&l++;for(v=[];"E"!==a[l];)if("S"===a[l]){l++;var A=a.indexOf("_",l);v.push(u[a.substring(l,A)||0]||"?");l=A+1}else if("C"===a[l])v.push(v[v.length-1]),l+=2;else{var A=parseInt(a.substr(l)),U=A.toString().length;if(!A||!U){l--;break}var Ub=a.substr(l+U,A);v.push(Ub);u.push(Ub);l+=U+A}l++;v=v.join("::");d--;if(0===d)return c?[v]:v}else if(("K"===a[l]||q&&"L"===a[l])&&l++,A=parseInt(a.substr(l)))U=A.toString().length, -v=a.substr(l+U,A),l+=U+A;q=!1;"I"===a[l]?(l++,A=b(!0),U=b(!0,1,!0),g+=U[0]+" "+v+"<"+A.join(", ")+">"):g=v;a:for(;l=a)return!1;for(;t<=r;)if(t=a)return!1;try{if(ArrayBuffer.p)buffer=ArrayBuffer.p(buffer,t);else{var c=y;buffer=new ArrayBuffer(t)}}catch(d){return!1}if(!Xa(buffer))return!1;e.buffer=buffer;e.HEAP8=y=new Int8Array(buffer);e.HEAP16=z=new Int16Array(buffer);e.HEAP32=C=new Int32Array(buffer);e.HEAPU8=E=new Uint8Array(buffer);e.HEAPU16=Ra=new Uint16Array(buffer);e.HEAPU32=Sa= -new Uint32Array(buffer);e.HEAPF32=Ba=new Float32Array(buffer);e.HEAPF64=Ca=new Float64Array(buffer);ArrayBuffer.p||y.set(c);return!0}var Ya;try{Ya=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get),Ya(new ArrayBuffer(4))}catch(Za){Ya=function(a){return a.byteLength}}for(var $a=e.TOTAL_STACK||5242880,t=e.TOTAL_MEMORY||16777216,F=65536;FF?2*F:F+16777216;F=Math.max(F,16777216);F!==t&&(t=F); -assert("undefined"!==typeof Int32Array&&"undefined"!==typeof Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"JS engine does not provide full typed array support");var buffer;buffer=new ArrayBuffer(t);y=new Int8Array(buffer);z=new Int16Array(buffer);C=new Int32Array(buffer);E=new Uint8Array(buffer);Ra=new Uint16Array(buffer);Sa=new Uint32Array(buffer);Ba=new Float32Array(buffer);Ca=new Float64Array(buffer);C[0]=255;assert(255===E[0]&&0===E[3],"Typed arrays 2 must be run on a little-endian system"); -e.HEAP=void 0;e.buffer=buffer;e.HEAP8=y;e.HEAP16=z;e.HEAP32=C;e.HEAPU8=E;e.HEAPU16=Ra;e.HEAPU32=Sa;e.HEAPF32=Ba;e.HEAPF64=Ca;function ab(a){for(;0>0]=a[c],c+=1}e.writeStringToMemory=ua;function ta(a,b){for(var c=0;c>0]=a[c]}e.writeArrayToMemory=ta; -function Ia(a,b,c){for(var d=0;d>0]=a.charCodeAt(d);c||(y[b>>0]=0)}e.writeAsciiToMemory=Ia;Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(a,b){var c=a&65535,d=b&65535;return c*d+((a>>>16)*d+c*(b>>>16)<<16)|0});Math.Jd=Math.imul;Math.clz32||(Math.clz32=function(a){a=a>>>0;for(var b=0;32>b;b++)if(a&1<<31-b)return b;return 32});Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null; -function kb(){I++;e.monitorRunDependencies&&e.monitorRunDependencies(I)}e.addRunDependency=kb;function lb(){I--;e.monitorRunDependencies&&e.monitorRunDependencies(I);if(0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var a=jb;jb=null;a()}}e.removeRunDependency=lb;e.preloadedImages={};e.preloadedAudios={};Ta=8;la=Ta+5888;cb.push(); -D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105, -110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91, -115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67, -82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121, -109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112, -101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97, -98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115, -105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114, -32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32, -101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95, -96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117, -99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112, -116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101, -116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100, -100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116, -111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111, -99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112, -101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111, -117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115, -32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117, -112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101, -0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116, -32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100, -105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0, -0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0, -0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);assert(0==mb%8);e._i64Subtract=nb; -function ob(a){e.___errno_location&&(C[e.___errno_location()>>2]=a);return a} -var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104, -wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(a,b){H.push(function(){n.L("vi",a,[b])});pb.level=H.length}e._memset=qb;e._bitshift64Lshr=rb;e._bitshift64Shl=sb;function tb(){return!!tb.p}var ub=[],vb={};function wb(a,b){wb.p||(wb.p={});a in wb.p||(n.L("v",b),wb.p[a]=1)} -var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system", -24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed", -44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network", -65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted", -82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available", -100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle", -122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function zb(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=yb(a.split("/").filter(function(a){return!!a}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a} -function Ab(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function Bb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}function Cb(){var a=Array.prototype.slice.call(arguments,0);return zb(a.join("/"))}function K(a,b){return zb(a+"/"+b)} -function Db(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=yb(a.split("/").filter(function(a){return!!a}),!b).join("/");return(b?"/":"")+a||"."}var Eb=[];function Fb(a,b){Eb[a]={input:[],output:[],N:b};Gb(a,Hb)} -var Hb={open:function(a){var b=Eb[a.g.rdev];if(!b)throw new L(J.ha);a.tty=b;a.seekable=!1},close:function(a){a.tty.N.flush(a.tty)},flush:function(a){a.tty.N.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.N.La)throw new L(J.Aa);for(var f=0,g=0;ga.e.length&& -(a.e=M.cb(a),a.o=a.e.length);if(!a.e||a.e.subarray){var c=a.e?a.e.buffer.byteLength:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)|0),0!=c&&(b=Math.max(b,256)),c=a.e,a.e=new Uint8Array(b),0b)a.e.length=b;else for(;a.e.length< -b;)a.e.push(0);a.o=b}},k:{D:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;N(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.o:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.K=4096;b.blocks=Math.ceil(b.size/b.K);return b},u:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);void 0!== -b.size&&M.ob(a,b.size)},lookup:function(){throw Mb[J.F];},T:function(a,b,c,d){return M.createNode(a,b,c,d)},rename:function(a,b,c){if(N(a.mode)){var d;try{d=Nb(b,c)}catch(f){}if(d)for(var g in d.e)throw new L(J.za);}delete a.parent.e[a.name];a.name=c;b.e[c]=a;a.parent=b},unlink:function(a,b){delete a.e[b]},rmdir:function(a,b){var c=Nb(a,b),d;for(d in c.e)throw new L(J.za);delete a.e[b]},readdir:function(a){var b=[".",".."],c;for(c in a.e)a.e.hasOwnProperty(c)&&b.push(c);return b},symlink:function(a, -b,c){a=M.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new L(J.q);return a.link}},n:{read:function(a,b,c,d,f){var g=a.g.e;if(f>=a.g.o)return 0;a=Math.min(a.g.o-f,d);assert(0<=a);if(8b)throw new L(J.q);return b},Ba:function(a,b,c){M.Ga(a.g,b+c);a.g.o=Math.max(a.g.o,b+c)},Na:function(a,b,c,d,f,g,h){if(32768!==(a.g.mode&61440))throw new L(J.ha);c=a.g.e;if(h&2||c.buffer!==b&&c.buffer!==b.buffer){if(0< -f||f+d>1)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}return b.mode},B:function(a){for(var b=[];a.parent!==a;)b.push(a.name),a=a.parent;b.push(a.A.pa.root);b.reverse();return Cb.apply(null,b)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+", -4096:"rs",4098:"rs+"},$a:function(a){a&=-32769;if(a in P.Ha)return P.Ha[a];throw new L(J.q);},k:{D:function(a){a=P.B(a);var b;try{b=fs.lstatSync(a)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}P.$&&!b.K&&(b.K=4096);P.$&&!b.blocks&&(b.blocks=(b.size+b.K-1)/b.K|0);return{dev:b.dev,ino:b.ino,mode:b.mode,nlink:b.nlink,uid:b.uid,gid:b.gid,rdev:b.rdev,size:b.size,atime:b.atime,mtime:b.mtime,ctime:b.ctime,K:b.K,blocks:b.blocks}},u:function(a,b){var c=P.B(a);try{void 0!==b.mode&&(fs.chmodSync(c,b.mode), -a.mode=b.mode),void 0!==b.size&&fs.truncateSync(c,b.size)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},lookup:function(a,b){var c=K(P.B(a),b),c=P.Ja(c);return P.createNode(a,b,c)},T:function(a,b,c,d){a=P.createNode(a,b,c,d);b=P.B(a);try{N(a.mode)?fs.mkdirSync(b,a.mode):fs.writeFileSync(b,"",{mode:a.mode})}catch(f){if(!f.code)throw f;throw new L(J[f.code]);}return a},rename:function(a,b,c){a=P.B(a);b=K(P.B(b),c);try{fs.renameSync(a,b)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}}, -unlink:function(a,b){var c=K(P.B(a),b);try{fs.unlinkSync(c)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},rmdir:function(a,b){var c=K(P.B(a),b);try{fs.rmdirSync(c)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},readdir:function(a){a=P.B(a);try{return fs.readdirSync(a)}catch(b){if(!b.code)throw b;throw new L(J[b.code]);}},symlink:function(a,b,c){a=K(P.B(a),b);try{fs.symlinkSync(c,a)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},readlink:function(a){var b=P.B(a);try{return b= -fs.readlinkSync(b),b=Ob.relative(Ob.resolve(a.A.pa.root),b)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}}},n:{open:function(a){var b=P.B(a.g);try{32768===(a.g.mode&61440)&&(a.V=fs.openSync(b,P.$a(a.flags)))}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}},close:function(a){try{32768===(a.g.mode&61440)&&a.V&&fs.closeSync(a.V)}catch(b){if(!b.code)throw b;throw new L(J[b.code]);}},read:function(a,b,c,d,f){if(0===d)return 0;var g=new Buffer(d),h;try{h=fs.readSync(a.V,g,0,d,f)}catch(l){throw new L(J[l.code]); -}if(0b)throw new L(J.q);return b}}};D(1,"i32*",2);D(1,"i32*",2);D(1,"i32*",2);var Pb=null,Qb=[null],Rb=[],Sb=1,Q=null,Tb=!0,R={},L=null,Mb={}; -function S(a,b){a=Db("/",a);b=b||{};if(!a)return{path:"",g:null};var c={Ia:!0,ra:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8>>0)%Q.length}function Xb(a){var b=Wb(a.parent.id,a.name);a.M=Q[b];Q[b]=a}function Nb(a,b){var c;if(c=(c=Yb(a,"x"))?c:a.k.lookup?0:J.da)throw new L(c,a);for(c=Q[Wb(a.id,b)];c;c=c.M){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.k.lookup(a,b)} -function Lb(a,b,c,d){Zb||(Zb=function(a,b,c,d){a||(a=this);this.parent=a;this.A=a.A;this.U=null;this.id=Sb++;this.name=b;this.mode=c;this.k={};this.n={};this.rdev=d},Zb.prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192===(this.mode& -61440)}}}));a=new Zb(a,b,c,d);Xb(a);return a}function N(a){return 16384===(a&61440)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(a,b){if(Tb)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return J.da}else return J.da;return 0}function ac(a,b){try{return Nb(a,b),J.wa}catch(c){}return Yb(a,"wx")} -function bc(){var a;a=4096;for(var b=0;b<=a;b++)if(!Rb[b])return b;throw new L(J.Sa);}function cc(a){dc||(dc=function(){},dc.prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(a){this.g=a}},Ld:{get:function(){return 1!==(this.flags&2097155)}},Md:{get:function(){return 0!==(this.flags&2097155)}},Kd:{get:function(){return this.flags&1024}}}));var b=new dc,c;for(c in a)b[c]=a[c];a=b;b=bc();a.fd=b;return Rb[b]=a} -var Kb={open:function(a){a.n=Qb[a.g.rdev].n;a.n.open&&a.n.open(a)},G:function(){throw new L(J.ia);}};function Gb(a,b){Qb[a]={n:b}}function ec(a,b){var c="/"===b,d=!b,f;if(c&&Pb)throw new L(J.fa);if(!c&&!d){f=S(b,{Ia:!1});b=f.path;f=f.g;if(f.U)throw new L(J.fa);if(!N(f.mode))throw new L(J.ya);}var d={type:a,pa:{},Oa:b,lb:[]},g=a.A(d);g.A=d;d.root=g;c?Pb=g:f&&(f.U=d,f.A&&f.A.lb.push(d))} -function fc(a,b,c){var d=S(a,{parent:!0}).g;a=Bb(a);if(!a||"."===a||".."===a)throw new L(J.q);var f=ac(d,a);if(f)throw new L(f);if(!d.k.T)throw new L(J.I);return d.k.T(d,a,b,c)}function gc(a,b){b=(void 0!==b?b:438)&4095;b|=32768;return fc(a,b,0)}function V(a,b){b=(void 0!==b?b:511)&1023;b|=16384;return fc(a,b,0)}function hc(a,b,c){"undefined"===typeof c&&(c=b,b=438);return fc(a,b|8192,c)} -function ic(a,b){if(!Db(a))throw new L(J.F);var c=S(b,{parent:!0}).g;if(!c)throw new L(J.F);var d=Bb(b),f=ac(c,d);if(f)throw new L(f);if(!c.k.symlink)throw new L(J.I);return c.k.symlink(c,d,a)}function Vb(a){a=S(a).g;if(!a)throw new L(J.F);if(!a.k.readlink)throw new L(J.q);return Db(T(a.parent),a.k.readlink(a))}function jc(a,b){var c;"string"===typeof a?c=S(a,{la:!0}).g:c=a;if(!c.k.u)throw new L(J.I);c.k.u(c,{mode:b&4095|c.mode&-4096,timestamp:Date.now()})} -function kc(a,b){var c;if(""===a)throw new L(J.F);var d;if("string"===typeof b){if(d=$b[b],"undefined"===typeof d)throw Error("Unknown file open mode: "+b);}else d=b;b=d;c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;var f;if("object"===typeof a)f=a;else{a=zb(a);try{f=S(a,{la:!(b&131072)}).g}catch(g){}}d=!1;if(b&64)if(f){if(b&128)throw new L(J.wa);}else f=fc(a,c,0),d=!0;if(!f)throw new L(J.F);8192===(f.mode&61440)&&(b&=-513);if(b&65536&&!N(f.mode))throw new L(J.ya);if(!d&&(f?40960===(f.mode&61440)? -c=J.ga:N(f.mode)&&(0!==(b&2097155)||b&512)?c=J.P:(c=["r","w","rw"][b&3],b&512&&(c+="w"),c=Yb(f,c)):c=J.F,c))throw new L(c);if(b&512){c=f;var h;"string"===typeof c?h=S(c,{la:!0}).g:h=c;if(!h.k.u)throw new L(J.I);if(N(h.mode))throw new L(J.P);if(32768!==(h.mode&61440))throw new L(J.q);if(c=Yb(h,"w"))throw new L(c);h.k.u(h,{size:0,timestamp:Date.now()})}b&=-641;f=cc({g:f,path:T(f),flags:b,seekable:!0,position:0,n:f.n,tb:[],error:!1});f.n.open&&f.n.open(f);!e.logReadFiles||b&1||(lc||(lc={}),a in lc|| -(lc[a]=1,e.printErr("read file: "+a)));try{R.onOpenFile&&(h=0,1!==(b&2097155)&&(h|=1),0!==(b&2097155)&&(h|=2),R.onOpenFile(a,h))}catch(l){console.log("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+l.message)}return f}function mc(a){a.na&&(a.na=null);try{a.n.close&&a.n.close(a)}catch(b){throw b;}finally{Rb[a.fd]=null}}function nc(a,b,c){if(!a.seekable||!a.n.G)throw new L(J.ia);a.position=a.n.G(a,b,c);a.tb=[]} -function oc(a,b,c,d,f,g){if(0>d||0>f)throw new L(J.q);if(0===(a.flags&2097155))throw new L(J.ea);if(N(a.g.mode))throw new L(J.P);if(!a.n.write)throw new L(J.q);a.flags&1024&&nc(a,0,2);var h=!0;if("undefined"===typeof f)f=a.position,h=!1;else if(!a.seekable)throw new L(J.ia);b=a.n.write(a,b,c,d,f,g);h||(a.position+=b);try{if(a.path&&R.onWriteToFile)R.onWriteToFile(a.path)}catch(l){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+l.message)}return b} -function pc(){L||(L=function(a,b){this.g=b;this.qb=function(a){this.S=a;for(var b in J)if(J[b]===a){this.code=b;break}};this.qb(a);this.message=xb[a]},L.prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(a){Mb[a]=new L(a);Mb[a].stack=""}))}var qc;function rc(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}function sc(a,b,c,d){a=K("string"===typeof a?a:T(a),b);return gc(a,rc(c,d))} -function tc(a,b,c,d,f,g){a=b?K("string"===typeof a?a:T(a),b):a;d=rc(d,f);f=gc(a,d);if(c){if("string"===typeof c){a=Array(c.length);b=0;for(var h=c.length;b>2]}function xc(){var a;a=X();a=Rb[a];if(!a)throw new L(J.ea);return a}var yc={};e._i64Add=zc;function Ga(a){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var b=r;return 0==a||Ga.bb(a)?b:4294967295}var Ac=1;e._memcpy=Bc; -function Cc(a,b){Dc=a;Ec=b;if(!Fc)return 1;if(0==a)Y=function(){setTimeout(Gc,b)},Hc="timeout";else if(1==a)Y=function(){Ic(Gc)},Hc="rAF";else if(2==a){if(!window.setImmediate){var c=[];window.addEventListener("message",function(a){a.source===window&&"__emcc"===a.data&&(a.stopPropagation(),c.shift()())},!0);window.setImmediate=function(a){c.push(a);window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)};Hc="immediate"}return 0} -function Jc(a,b,c,d,f){e.noExitRuntime=!0;assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.");Fc=a;Kc=d;var g=Lc;Gc=function(){if(!na)if(0>h-6&63,h=h-6,c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[v];2==h?(c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(g&3)<<4],c+="=="):4==h&&(c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(g&15)<<2],c+="=");B.src="data:audio/x-"+b.substr(-3)+";base64,"+c;l(B)}};B.src=q;ad(function(){l(B)})}else return w()}});var c=e.canvas;c&&(c.sa=c.requestPointerLock||c.mozRequestPointerLock|| -c.webkitRequestPointerLock||c.msRequestPointerLock||function(){},c.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},c.Fa=c.Fa.bind(document),document.addEventListener("pointerlockchange",a,!1),document.addEventListener("mozpointerlockchange",a,!1),document.addEventListener("webkitpointerlockchange",a,!1),document.addEventListener("mspointerlockchange",a,!1),e.elementPointerLock&&c.addEventListener("click",function(a){!Tc&& -c.sa&&(c.sa(),a.preventDefault())},!1))}}function bd(a,b,c,d){if(b&&e.ka&&a==e.canvas)return e.ka;var f,g;if(b){g={antialias:!1,alpha:!1};if(d)for(var h in d)g[h]=d[h];if(g=GL.createContext(a,g))f=GL.getContext(g).td;a.style.backgroundColor="black"}else f=a.getContext("2d");if(!f)return null;c&&(b||assert("undefined"===typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=f,b&&GL.Od(g),e.Td=b,Uc.forEach(function(a){a()}),Vc());return f} -var cd=!1,dd=void 0,ed=void 0; -function fd(a,b,c){function d(){Sc=!1;var a=f.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===a?(f.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){}, -f.Da=f.Da.bind(document),dd&&f.sa(),Sc=!0,ed&&gd()):(a.parentNode.insertBefore(f,a),a.parentNode.removeChild(a),ed&&hd());if(e.onFullScreen)e.onFullScreen(Sc);id(f)}dd=a;ed=b;jd=c;"undefined"===typeof dd&&(dd=!0);"undefined"===typeof ed&&(ed=!1);"undefined"===typeof jd&&(jd=null);var f=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",d,!1),document.addEventListener("mozfullscreenchange",d,!1),document.addEventListener("webkitfullscreenchange",d,!1),document.addEventListener("MSFullscreenChange", -d,!1));var g=document.createElement("div");f.parentNode.insertBefore(g,f);g.appendChild(f);g.p=g.requestFullScreen||g.mozRequestFullScreen||g.msRequestFullscreen||(g.webkitRequestFullScreen?function(){g.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null);c?g.p({Ud:c}):g.p()}var kd=0;function ld(a){var b=Date.now();if(0===kd)kd=b+1E3/60;else for(;b+2>=kd;)kd+=1E3/60;b=Math.max(kd-b,0);setTimeout(a,b)} -function Ic(a){"undefined"===typeof window?ld(a):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(a))}function ad(a){e.noExitRuntime=!0;setTimeout(function(){na||a()},1E4)} -function $c(a){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[a.substr(a.lastIndexOf(".")+1)]}function md(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)} -function nd(a,b,c){md(a,function(c){assert(c,'Loading data file "'+a+'" failed (no arrayBuffer).');b(new Uint8Array(c));lb()},function(){if(c)c();else throw'Loading data file "'+a+'" failed.';});kb()}var od=[];function pd(){var a=e.canvas;od.forEach(function(b){b(a.width,a.height)})}function gd(){if("undefined"!=typeof SDL){var a=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=a|8388608}pd()} -function hd(){if("undefined"!=typeof SDL){var a=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=a&-8388609}pd()} -function id(a,b,c){b&&c?(a.ub=b,a.hb=c):(b=a.ub,c=a.hb);var d=b,f=c;e.forcedAspectRatio&&0this.length-1||0>a)){var b=a%this.chunkSize;return this.gb(a/this.chunkSize|0)[b]}};l.prototype.pb=function(a){this.gb=a};l.prototype.Ca=function(){var a=new XMLHttpRequest;a.open("HEAD",c,!1);a.send(null);if(!(200<=a.status&&300>a.status||304===a.status))throw Error("Couldn't load "+c+". Status: "+a.status);var b=Number(a.getResponseHeader("Content-length")),d,f=1048576;(d=a.getResponseHeader("Accept-Ranges"))&& -"bytes"===d||(f=b);var g=this;g.pb(function(a){var d=a*f,h=(a+1)*f-1,h=Math.min(h,b-1);if("undefined"===typeof g.Y[a]){var l=g.Y;if(d>h)throw Error("invalid range ("+d+", "+h+") or no bytes requested!");if(h>b-1)throw Error("only "+b+" bytes available! programmer error!");var q=new XMLHttpRequest;q.open("GET",c,!1);b!==f&&q.setRequestHeader("Range","bytes="+d+"-"+h);"undefined"!=typeof Uint8Array&&(q.responseType="arraybuffer");q.overrideMimeType&&q.overrideMimeType("text/plain; charset=x-user-defined"); -q.send(null);if(!(200<=q.status&&300>q.status||304===q.status))throw Error("Couldn't load "+c+". Status: "+q.status);d=void 0!==q.response?new Uint8Array(q.response||[]):hb(q.responseText||"",!0);l[a]=d}if("undefined"===typeof g.Y[a])throw Error("doXHR failed!");return g.Y[a]});this.Wa=b;this.Va=f;this.oa=!0};if("undefined"!==typeof XMLHttpRequest){if(!ca)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";g=new l;Object.defineProperty(g, -"length",{get:function(){this.oa||this.Ca();return this.Wa}});Object.defineProperty(g,"chunkSize",{get:function(){this.oa||this.Ca();return this.Va}});h=void 0}else h=c,g=void 0;var w=sc(a,b,d,f);g?w.e=g:h&&(w.e=null,w.url=h);Object.defineProperty(w,"usedBytes",{get:function(){return this.e.length}});var u={};Object.keys(w.n).forEach(function(a){var b=w.n[a];u[a]=function(){if(!uc(w))throw new L(J.H);return b.apply(null,arguments)}});u.read=function(a,b,c,d,f){if(!uc(w))throw new L(J.H);a=a.g.e;if(f>= -a.length)return 0;d=Math.min(a.length-f,d);assert(0<=d);if(a.slice)for(var g=0;g>2]=0;case 21520:return c.tty?-J.q:-J.Q;case 21531:f=X();if(!c.n.ib)throw new L(J.Q);return c.n.ib(c,d,f);default:x("bad ioctl syscall "+d)}}catch(g){return"undefined"!==typeof vc&&g instanceof L||x(g),-g.S}},___syscall6:function(a,b){wc=b;try{var c=xc();mc(c);return 0}catch(d){return"undefined"!==typeof vc&&d instanceof L||x(d),-d.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(a){tb.p--;ub.push(a);var b; -a:{if(a&&!vb[a])for(b in vb)if(vb[b].wd===a)break a;b=a}b&&vb[b].Sd++;return a},_emscripten_memcpy_big:function(a,b,c){E.set(E.subarray(b,b+c),a);return a},_sysconf:function(a){switch(a){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809; -case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32; -case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1E3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"===typeof navigator?navigator.hardwareConcurrency||1:1}ob(J.q);return-1}, -_pthread_getspecific:function(a){return yc[a]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(a){if(0==a)return J.q;C[a>>2]=Ac;yc[Ac]=0;Ac++;return 0},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(a,b){if(!(a in yc))return J.q;yc[a]=b;return 0},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(a){var b=Date.now()/1E3|0;a&&(C[a>>2]=b);return b},___syscall140:function(a,b){wc=b;try{var c= -xc(),d=X(),f=X(),g=X(),h=X();assert(0===d);nc(c,f,h);C[g>>2]=c.position;c.na&&0===f&&0===h&&(c.na=null);return 0}catch(l){return"undefined"!==typeof vc&&l instanceof L||x(l),-l.S}},___syscall146:function(a,b){wc=b;try{var c=xc(),d=X(),f;a:{for(var g=X(),h=0,l=0;l>2],C[d+(8*l+4)>>2],void 0);if(0>w){f=-1;break a}h+=w}f=h}return f}catch(u){return"undefined"!==typeof vc&&u instanceof L||x(u),-u.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};// EMSCRIPTEN_START_ASM - -var Z=(function(global,env,buffer) { -"use asm";var a=global.Int8Array;var b=global.Int16Array;var c=global.Int32Array;var d=global.Uint8Array;var e=global.Uint16Array;var f=global.Uint32Array;var g=global.Float32Array;var h=global.Float64Array;var i=new a(buffer);var j=new b(buffer);var k=new c(buffer);var l=new d(buffer);var m=new e(buffer);var n=new f(buffer);var o=new g(buffer);var p=new h(buffer);var q=global.byteLength;var r=env.STACKTOP|0;var s=env.STACK_MAX|0;var t=env.tempDoublePtr|0;var u=env.ABORT|0;var v=env.cttz_i8|0;var w=0;var x=0;var y=0;var z=0;var A=global.NaN,B=global.Infinity;var C=0,D=0,E=0,F=0,G=0.0,H=0,I=0,J=0,K=0.0;var L=0;var M=0;var N=0;var O=0;var P=0;var Q=0;var R=0;var S=0;var T=0;var U=0;var V=global.Math.floor;var W=global.Math.abs;var X=global.Math.sqrt;var Y=global.Math.pow;var Z=global.Math.cos;var _=global.Math.sin;var $=global.Math.tan;var aa=global.Math.acos;var ba=global.Math.asin;var ca=global.Math.atan;var da=global.Math.atan2;var ea=global.Math.exp;var fa=global.Math.log;var ga=global.Math.ceil;var ha=global.Math.imul;var ia=global.Math.min;var ja=global.Math.clz32;var ka=env.abort;var la=env.assert;var ma=env.invoke_iiii;var na=env.invoke_viiiii;var oa=env.invoke_vi;var pa=env.invoke_ii;var qa=env.invoke_viii;var ra=env.invoke_v;var sa=env.invoke_viiiiii;var ta=env.invoke_iiiiii;var ua=env.invoke_viiii;var va=env._pthread_cleanup_pop;var wa=env.___syscall54;var xa=env.___syscall6;var ya=env._emscripten_set_main_loop_timing;var za=env.__ZSt18uncaught_exceptionv;var Aa=env.___setErrNo;var Ba=env._sbrk;var Ca=env.___cxa_begin_catch;var Da=env._emscripten_memcpy_big;var Ea=env._sysconf;var Fa=env._pthread_getspecific;var Ga=env._pthread_self;var Ha=env._pthread_once;var Ia=env._pthread_key_create;var Ja=env.___unlock;var Ka=env._emscripten_set_main_loop;var La=env._pthread_setspecific;var Ma=env.___lock;var Na=env._abort;var Oa=env._pthread_cleanup_push;var Pa=env._time;var Qa=env.___syscall140;var Ra=env.___syscall146;var Sa=0.0;function Ta(newBuffer){if(q(newBuffer)&16777215||q(newBuffer)<=16777215||q(newBuffer)>2147483648)return false;i=new a(newBuffer);j=new b(newBuffer);k=new c(newBuffer);l=new d(newBuffer);m=new e(newBuffer);n=new f(newBuffer);o=new g(newBuffer);p=new h(newBuffer);buffer=newBuffer;return true} -// EMSCRIPTEN_START_FUNCS -function bb(a){a=a|0;var b=0;b=r;r=r+a|0;r=r+15&-16;return b|0}function cb(){return r|0}function db(a){a=a|0;r=a}function eb(a,b){a=a|0;b=b|0;r=a;s=b}function fb(a,b){a=a|0;b=b|0;if(!w){w=a;x=b}}function gb(a){a=a|0;i[t>>0]=i[a>>0];i[t+1>>0]=i[a+1>>0];i[t+2>>0]=i[a+2>>0];i[t+3>>0]=i[a+3>>0]}function hb(a){a=a|0;i[t>>0]=i[a>>0];i[t+1>>0]=i[a+1>>0];i[t+2>>0]=i[a+2>>0];i[t+3>>0]=i[a+3>>0];i[t+4>>0]=i[a+4>>0];i[t+5>>0]=i[a+5>>0];i[t+6>>0]=i[a+6>>0];i[t+7>>0]=i[a+7>>0]}function ib(a){a=a|0;L=a}function jb(){return L|0}function kb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+608|0;n=q+88|0;m=q+72|0;i=q+64|0;h=q+48|0;g=q+24|0;f=q;l=q+96|0;o=q+92|0;j=a+4|0;p=a+8|0;if((k[j>>2]|0)>>>0>(k[p>>2]|0)>>>0){k[f>>2]=1154;k[f+4>>2]=2120;k[f+8>>2]=1133;Ac(l,1100,f)|0;zc(l,q+16|0)|0}if((2147418112/(d>>>0)|0)>>>0<=b>>>0){k[g>>2]=1154;k[g+4>>2]=2121;k[g+8>>2]=1169;Ac(l,1100,g)|0;zc(l,q+40|0)|0}g=k[p>>2]|0;if(g>>>0>=b>>>0){p=1;r=q;return p|0}do if(c){if(b){f=b+-1|0;if(!(f&b)){f=11;break}else b=f}else b=-1;b=b>>>16|b;b=b>>>8|b;b=b>>>4|b;b=b>>>2|b;b=(b>>>1|b)+1|0;f=10}else f=10;while(0);if((f|0)==10)if(!b){b=0;f=12}else f=11;if((f|0)==11)if(b>>>0<=g>>>0)f=12;if((f|0)==12){k[h>>2]=1154;k[h+4>>2]=2130;k[h+8>>2]=1217;Ac(l,1100,h)|0;zc(l,i)|0}c=ha(b,d)|0;do if(!e){f=lb(k[a>>2]|0,c,o,1)|0;if(!f){p=0;r=q;return p|0}else{k[a>>2]=f;break}}else{g=mb(c,o)|0;if(!g){p=0;r=q;return p|0}Ya[e&0](g,k[a>>2]|0,k[j>>2]|0);f=k[a>>2]|0;do if(f)if(!(f&7)){$a[k[104>>2]&1](f,0,0,1,k[27]|0)|0;break}else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(l,1100,m)|0;zc(l,n)|0;break}while(0);k[a>>2]=g}while(0);f=k[o>>2]|0;if(f>>>0>c>>>0)b=(f>>>0)/(d>>>0)|0;k[p>>2]=b;p=1;r=q;return p|0}function lb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=r;r=r+592|0;i=j+48|0;f=j+24|0;e=j;h=j+72|0;g=j+68|0;if(a&7){k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1494;Ac(h,1100,e)|0;zc(h,j+16|0)|0;i=0;r=j;return i|0}if(b>>>0>2147418112){k[f>>2]=1154;k[f+4>>2]=2499;k[f+8>>2]=1387;Ac(h,1100,f)|0;zc(h,j+40|0)|0;i=0;r=j;return i|0}k[g>>2]=b;d=$a[k[104>>2]&1](a,b,g,d,k[27]|0)|0;if(c)k[c>>2]=k[g>>2];if(!(d&7)){i=d;r=j;return i|0}k[i>>2]=1154;k[i+4>>2]=2551;k[i+8>>2]=1440;Ac(h,1100,i)|0;zc(h,j+64|0)|0;i=d;r=j;return i|0}function mb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;i=r;r=r+592|0;g=i+48|0;h=i+24|0;c=i;f=i+72|0;e=i+68|0;d=a+3&-4;d=(d|0)!=0?d:4;if(d>>>0>2147418112){k[c>>2]=1154;k[c+4>>2]=2499;k[c+8>>2]=1387;Ac(f,1100,c)|0;zc(f,i+16|0)|0;h=0;r=i;return h|0}k[e>>2]=d;c=$a[k[104>>2]&1](0,d,e,1,k[27]|0)|0;a=k[e>>2]|0;if(b)k[b>>2]=a;if((c|0)==0|a>>>0>>0){k[h>>2]=1154;k[h+4>>2]=2499;k[h+8>>2]=1413;Ac(f,1100,h)|0;zc(f,i+40|0)|0;h=0;r=i;return h|0}if(!(c&7)){h=c;r=i;return h|0}k[g>>2]=1154;k[g+4>>2]=2526;k[g+8>>2]=1440;Ac(f,1100,g)|0;zc(f,i+64|0)|0;h=c;r=i;return h|0}function nb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;S=r;r=r+960|0;P=S+232|0;O=S+216|0;N=S+208|0;M=S+192|0;L=S+184|0;K=S+168|0;J=S+160|0;I=S+144|0;F=S+136|0;E=S+120|0;D=S+112|0;C=S+96|0;z=S+88|0;y=S+72|0;x=S+64|0;w=S+48|0;q=S+40|0;t=S+24|0;s=S+16|0;p=S;H=S+440|0;Q=S+376|0;R=S+304|0;v=S+236|0;if((b|0)==0|d>>>0>11){a=0;r=S;return a|0}k[a>>2]=b;e=R;f=e+68|0;do{k[e>>2]=0;e=e+4|0}while((e|0)<(f|0));f=0;do{e=i[c+f>>0]|0;if(e<<24>>24){G=R+((e&255)<<2)|0;k[G>>2]=(k[G>>2]|0)+1}f=f+1|0}while((f|0)!=(b|0));f=0;o=1;g=0;h=-1;n=0;while(1){e=k[R+(o<<2)>>2]|0;if(!e)k[a+28+(o+-1<<2)>>2]=0;else{G=o+-1|0;k[Q+(G<<2)>>2]=f;f=e+f|0;B=16-o|0;k[a+28+(G<<2)>>2]=(f+-1<>2]=n;k[v+(o<<2)>>2]=n;g=g>>>0>o>>>0?g:o;h=h>>>0>>0?h:o;n=e+n|0}o=o+1|0;if((o|0)==17){G=g;break}else f=f<<1}k[a+4>>2]=n;f=a+172|0;do if(n>>>0>(k[f>>2]|0)>>>0){k[f>>2]=n;if(n){e=n+-1|0;if(e&n)u=14}else{e=-1;u=14}if((u|0)==14){B=e>>>16|e;B=B>>>8|B;B=B>>>4|B;B=B>>>2|B;B=(B>>>1|B)+1|0;k[f>>2]=B>>>0>b>>>0?b:B}g=a+176|0;e=k[g>>2]|0;do if(e){B=k[e+-4>>2]|0;e=e+-8|0;if(!((B|0)!=0?(B|0)==(~k[e>>2]|0):0)){k[p>>2]=1154;k[p+4>>2]=644;k[p+8>>2]=1863;Ac(H,1100,p)|0;zc(H,s)|0}if(!(e&7)){$a[k[104>>2]&1](e,0,0,1,k[27]|0)|0;break}else{k[t>>2]=1154;k[t+4>>2]=2499;k[t+8>>2]=1516;Ac(H,1100,t)|0;zc(H,q)|0;break}}while(0);f=k[f>>2]|0;f=(f|0)!=0?f:1;e=mb((f<<1)+8|0,0)|0;if(!e){k[g>>2]=0;e=0;break}else{k[e+4>>2]=f;k[e>>2]=~f;k[g>>2]=e+8;u=25;break}}else u=25;while(0);a:do if((u|0)==25){B=a+24|0;i[B>>0]=h;i[a+25>>0]=G;f=a+176|0;g=0;do{A=i[c+g>>0]|0;e=A&255;if(A<<24>>24){if(!(k[R+(e<<2)>>2]|0)){k[w>>2]=1154;k[w+4>>2]=2273;k[w+8>>2]=1261;Ac(H,1100,w)|0;zc(H,x)|0}A=v+(e<<2)|0;e=k[A>>2]|0;k[A>>2]=e+1;if(e>>>0>=n>>>0){k[y>>2]=1154;k[y+4>>2]=2277;k[y+8>>2]=1274;Ac(H,1100,y)|0;zc(H,z)|0}j[(k[f>>2]|0)+(e<<1)>>1]=g}g=g+1|0}while((g|0)!=(b|0));e=i[B>>0]|0;z=(e&255)>>>0>>0?d:0;A=a+8|0;k[A>>2]=z;y=(z|0)!=0;if(y){x=1<>>0>(k[e>>2]|0)>>>0){k[e>>2]=x;g=a+168|0;e=k[g>>2]|0;do if(e){w=k[e+-4>>2]|0;e=e+-8|0;if(!((w|0)!=0?(w|0)==(~k[e>>2]|0):0)){k[C>>2]=1154;k[C+4>>2]=644;k[C+8>>2]=1863;Ac(H,1100,C)|0;zc(H,D)|0}if(!(e&7)){$a[k[104>>2]&1](e,0,0,1,k[27]|0)|0;break}else{k[E>>2]=1154;k[E+4>>2]=2499;k[E+8>>2]=1516;Ac(H,1100,E)|0;zc(H,F)|0;break}}while(0);e=x<<2;f=mb(e+8|0,0)|0;if(!f){k[g>>2]=0;e=0;break a}else{F=f+8|0;k[f+4>>2]=x;k[f>>2]=~x;k[g>>2]=F;f=F;break}}else{f=a+168|0;e=x<<2;g=f;f=k[f>>2]|0}while(0);ad(f|0,-1,e|0)|0;u=a+176|0;w=1;do{if(k[R+(w<<2)>>2]|0){b=z-w|0;v=1<>2]|0;if(f>>>0>=16){k[I>>2]=1154;k[I+4>>2]=1953;k[I+8>>2]=1737;Ac(H,1100,I)|0;zc(H,J)|0}e=k[a+28+(f<<2)>>2]|0;if(!e)t=-1;else t=(e+-1|0)>>>(16-w|0);if(h>>>0<=t>>>0){q=(k[a+96+(f<<2)>>2]|0)-h|0;s=w<<16;do{e=m[(k[u>>2]|0)+(q+h<<1)>>1]|0;if((l[c+e>>0]|0|0)!=(w|0)){k[K>>2]=1154;k[K+4>>2]=2319;k[K+8>>2]=1303;Ac(H,1100,K)|0;zc(H,L)|0}p=h<>>0>=x>>>0){k[M>>2]=1154;k[M+4>>2]=2325;k[M+8>>2]=1337;Ac(H,1100,M)|0;zc(H,N)|0}e=k[g>>2]|0;if((k[e+(n<<2)>>2]|0)!=-1){k[O>>2]=1154;k[O+4>>2]=2327;k[O+8>>2]=1360;Ac(H,1100,O)|0;zc(H,P)|0;e=k[g>>2]|0}k[e+(n<<2)>>2]=f;o=o+1|0}while(o>>>0>>0);h=h+1|0}while(h>>>0<=t>>>0)}}w=w+1|0}while(z>>>0>=w>>>0);e=i[B>>0]|0}f=a+96|0;k[f>>2]=(k[f>>2]|0)-(k[Q>>2]|0);f=a+100|0;k[f>>2]=(k[f>>2]|0)-(k[Q+4>>2]|0);f=a+104|0;k[f>>2]=(k[f>>2]|0)-(k[Q+8>>2]|0);f=a+108|0;k[f>>2]=(k[f>>2]|0)-(k[Q+12>>2]|0);f=a+112|0;k[f>>2]=(k[f>>2]|0)-(k[Q+16>>2]|0);f=a+116|0;k[f>>2]=(k[f>>2]|0)-(k[Q+20>>2]|0);f=a+120|0;k[f>>2]=(k[f>>2]|0)-(k[Q+24>>2]|0);f=a+124|0;k[f>>2]=(k[f>>2]|0)-(k[Q+28>>2]|0);f=a+128|0;k[f>>2]=(k[f>>2]|0)-(k[Q+32>>2]|0);f=a+132|0;k[f>>2]=(k[f>>2]|0)-(k[Q+36>>2]|0);f=a+136|0;k[f>>2]=(k[f>>2]|0)-(k[Q+40>>2]|0);f=a+140|0;k[f>>2]=(k[f>>2]|0)-(k[Q+44>>2]|0);f=a+144|0;k[f>>2]=(k[f>>2]|0)-(k[Q+48>>2]|0);f=a+148|0;k[f>>2]=(k[f>>2]|0)-(k[Q+52>>2]|0);f=a+152|0;k[f>>2]=(k[f>>2]|0)-(k[Q+56>>2]|0);f=a+156|0;k[f>>2]=(k[f>>2]|0)-(k[Q+60>>2]|0);f=a+16|0;k[f>>2]=0;g=a+20|0;k[g>>2]=e&255;b:do if(y){while(1){if(!d)break b;e=d+-1|0;if(!(k[R+(d<<2)>>2]|0))d=e;else break}k[f>>2]=k[a+28+(e<<2)>>2];e=z+1|0;k[g>>2]=e;if(e>>>0<=G>>>0){while(1){if(k[R+(e<<2)>>2]|0)break;e=e+1|0;if(e>>>0>G>>>0)break b}k[g>>2]=e}}while(0);k[a+92>>2]=-1;k[a+160>>2]=1048575;k[a+12>>2]=32-(k[A>>2]|0);e=1}while(0);a=e;r=S;return a|0}function ob(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;if(!a){e=Uc(b)|0;if(!c){c=e;return c|0}if(!e)f=0;else f=Xc(e)|0;k[c>>2]=f;c=e;return c|0}if(!b){Vc(a);if(!c){c=0;return c|0}k[c>>2]=0;c=0;return c|0}e=Wc(a,b)|0;f=(e|0)!=0;if(f|d^1)f=f?e:a;else{e=Wc(a,b)|0;f=(e|0)==0?a:e}if(!c){c=e;return c|0}b=Xc(f)|0;k[c>>2]=b;c=e;return c|0}function pb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!((a|0)!=0&b>>>0>73&(c|0)!=0)){c=0;return c|0}if((k[c>>2]|0)!=40|b>>>0<74){c=0;return c|0}if(((l[a>>0]|0)<<8|(l[a+1>>0]|0)|0)!=18552){c=0;return c|0}if(((l[a+2>>0]|0)<<8|(l[a+3>>0]|0))>>>0<74){c=0;return c|0}if(((l[a+7>>0]|0)<<16|(l[a+6>>0]|0)<<24|(l[a+8>>0]|0)<<8|(l[a+9>>0]|0))>>>0>b>>>0){c=0;return c|0}k[c+4>>2]=(l[a+12>>0]|0)<<8|(l[a+13>>0]|0);k[c+8>>2]=(l[a+14>>0]|0)<<8|(l[a+15>>0]|0);k[c+12>>2]=l[a+16>>0];k[c+16>>2]=l[a+17>>0];b=a+18|0;d=c+32|0;k[d>>2]=l[b>>0];k[d+4>>2]=0;b=i[b>>0]|0;k[c+20>>2]=b<<24>>24==0|b<<24>>24==9?8:16;k[c+24>>2]=(l[a+26>>0]|0)<<16|(l[a+25>>0]|0)<<24|(l[a+27>>0]|0)<<8|(l[a+28>>0]|0);k[c+28>>2]=(l[a+30>>0]|0)<<16|(l[a+29>>0]|0)<<24|(l[a+31>>0]|0)<<8|(l[a+32>>0]|0);c=1;return c|0}function qb(a){a=a|0;Ca(a|0)|0;Vb()}function rb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;f=r;r=r+544|0;e=f;d=f+24|0;b=k[a+20>>2]|0;if(b)sb(b);b=a+4|0;c=k[b>>2]|0;if(!c){e=a+16|0;i[e>>0]=0;r=f;return}if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1516;Ac(d,1100,e)|0;zc(d,f+16|0)|0}k[b>>2]=0;k[a+8>>2]=0;k[a+12>>2]=0;e=a+16|0;i[e>>0]=0;r=f;return}function sb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;o=r;r=r+640|0;n=o+112|0;m=o+96|0;l=o+88|0;j=o+72|0;i=o+64|0;h=o+48|0;d=o+40|0;f=o+24|0;e=o+16|0;c=o;g=o+120|0;if(!a){r=o;return}b=k[a+168>>2]|0;do if(b){p=k[b+-4>>2]|0;b=b+-8|0;if(!((p|0)!=0?(p|0)==(~k[b>>2]|0):0)){k[c>>2]=1154;k[c+4>>2]=644;k[c+8>>2]=1863;Ac(g,1100,c)|0;zc(g,e)|0}if(!(b&7)){$a[k[104>>2]&1](b,0,0,1,k[27]|0)|0;break}else{k[f>>2]=1154;k[f+4>>2]=2499;k[f+8>>2]=1516;Ac(g,1100,f)|0;zc(g,d)|0;break}}while(0);b=k[a+176>>2]|0;do if(b){p=k[b+-4>>2]|0;b=b+-8|0;if(!((p|0)!=0?(p|0)==(~k[b>>2]|0):0)){k[h>>2]=1154;k[h+4>>2]=644;k[h+8>>2]=1863;Ac(g,1100,h)|0;zc(g,i)|0}if(!(b&7)){$a[k[104>>2]&1](b,0,0,1,k[27]|0)|0;break}else{k[j>>2]=1154;k[j+4>>2]=2499;k[j+8>>2]=1516;Ac(g,1100,j)|0;zc(g,l)|0;break}}while(0);if(!(a&7)){$a[k[104>>2]&1](a,0,0,1,k[27]|0)|0;r=o;return}else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(g,1100,m)|0;zc(g,n)|0;r=o;return}}function tb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0;l=r;r=r+560|0;g=l+40|0;h=l+24|0;b=l;f=l+48|0;e=a+8|0;c=k[e>>2]|0;if((c+-1|0)>>>0>=8192){k[b>>2]=1154;k[b+4>>2]=2997;k[b+8>>2]=1541;Ac(f,1100,b)|0;zc(f,l+16|0)|0}k[a>>2]=c;d=a+20|0;b=k[d>>2]|0;if(!b){b=mb(180,0)|0;if(!b)b=0;else{j=b+164|0;k[j>>2]=0;k[j+4>>2]=0;k[j+8>>2]=0;k[j+12>>2]=0}k[d>>2]=b;j=b;i=k[a>>2]|0}else{j=b;i=c}if(!(k[e>>2]|0)){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(f,1100,h)|0;zc(f,g)|0;f=k[a>>2]|0}else f=i;e=k[a+4>>2]|0;if(f>>>0>16){c=f;b=0}else{a=0;j=nb(j,i,e,a)|0;r=l;return j|0}while(1){d=b+1|0;if(c>>>0>3){c=c>>>1;b=d}else{c=d;break}}a=b+2+((c|0)!=32&1<>>0>>0&1)|0;a=a>>>0<11?a&255:11;j=nb(j,i,e,a)|0;r=l;return j|0}function ub(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;N=r;r=r+800|0;I=N+256|0;H=N+240|0;G=N+232|0;F=N+216|0;E=N+208|0;D=N+192|0;C=N+184|0;B=N+168|0;A=N+160|0;z=N+144|0;y=N+136|0;x=N+120|0;w=N+112|0;v=N+96|0;u=N+88|0;t=N+72|0;o=N+64|0;n=N+48|0;h=N+40|0;j=N+24|0;f=N+16|0;e=N;L=N+288|0;M=N+264|0;J=vb(a,14)|0;if(!J){k[b>>2]=0;c=b+4|0;d=k[c>>2]|0;if(d){if(!(d&7))$a[k[104>>2]&1](d,0,0,1,k[27]|0)|0;else{k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1516;Ac(L,1100,e)|0;zc(L,f)|0}k[c>>2]=0;k[b+8>>2]=0;k[b+12>>2]=0}i[b+16>>0]=0;c=b+20|0;d=k[c>>2]|0;if(!d){b=1;r=N;return b|0}sb(d);k[c>>2]=0;b=1;r=N;return b|0}q=b+4|0;s=b+8|0;c=k[s>>2]|0;if((c|0)!=(J|0)){if(c>>>0<=J>>>0){do if((k[b+12>>2]|0)>>>0>>0){if(kb(q,J,(c+1|0)==(J|0),1,0)|0){c=k[s>>2]|0;break}i[b+16>>0]=1;b=0;r=N;return b|0}while(0);ad((k[q>>2]|0)+c|0,0,J-c|0)|0}k[s>>2]=J}ad(k[q>>2]|0,0,J|0)|0;p=a+20|0;c=k[p>>2]|0;if((c|0)<5){f=a+4|0;g=a+8|0;e=a+16|0;do{d=k[f>>2]|0;if((d|0)==(k[g>>2]|0))d=0;else{k[f>>2]=d+1;d=l[d>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[j>>2]=1154;k[j+4>>2]=3199;k[j+8>>2]=1650;Ac(L,1100,j)|0;zc(L,h)|0;c=k[p>>2]|0}d=d<<32-c|k[e>>2];k[e>>2]=d}while((c|0)<5)}else{d=a+16|0;e=d;d=k[d>>2]|0}m=d>>>27;k[e>>2]=d<<5;k[p>>2]=c+-5;if((m+-1|0)>>>0>20){b=0;r=N;return b|0}k[M+20>>2]=0;k[M>>2]=0;k[M+4>>2]=0;k[M+8>>2]=0;k[M+12>>2]=0;i[M+16>>0]=0;c=M+4|0;d=M+8|0;a:do if(kb(c,21,0,1,0)|0){h=k[d>>2]|0;j=k[c>>2]|0;ad(j+h|0,0,21-h|0)|0;k[d>>2]=21;if(m){e=a+4|0;f=a+8|0;g=a+16|0;h=0;do{c=k[p>>2]|0;if((c|0)<3)do{d=k[e>>2]|0;if((d|0)==(k[f>>2]|0))d=0;else{k[e>>2]=d+1;d=l[d>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[n>>2]=1154;k[n+4>>2]=3199;k[n+8>>2]=1650;Ac(L,1100,n)|0;zc(L,o)|0;c=k[p>>2]|0}d=d<<32-c|k[g>>2];k[g>>2]=d}while((c|0)<3);else d=k[g>>2]|0;k[g>>2]=d<<3;k[p>>2]=c+-3;i[j+(l[1611+h>>0]|0)>>0]=d>>>29;h=h+1|0}while((h|0)!=(m|0))}if(tb(M)|0){h=a+4|0;j=a+8|0;m=a+16|0;d=0;b:while(1){g=J-d|0;c=wb(a,M)|0;c:do if(c>>>0<17){if((k[s>>2]|0)>>>0<=d>>>0){k[t>>2]=1154;k[t+4>>2]=903;k[t+8>>2]=1781;Ac(L,1100,t)|0;zc(L,u)|0}i[(k[q>>2]|0)+d>>0]=c;c=d+1|0}else switch(c|0){case 17:{c=k[p>>2]|0;if((c|0)<3)do{e=k[h>>2]|0;if((e|0)==(k[j>>2]|0))e=0;else{k[h>>2]=e+1;e=l[e>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[v>>2]=1154;k[v+4>>2]=3199;k[v+8>>2]=1650;Ac(L,1100,v)|0;zc(L,w)|0;c=k[p>>2]|0}e=e<<32-c|k[m>>2];k[m>>2]=e}while((c|0)<3);else e=k[m>>2]|0;k[m>>2]=e<<3;k[p>>2]=c+-3;c=(e>>>29)+3|0;if(c>>>0>g>>>0){c=0;break a}c=c+d|0;break c}case 18:{c=k[p>>2]|0;if((c|0)<7)do{e=k[h>>2]|0;if((e|0)==(k[j>>2]|0))e=0;else{k[h>>2]=e+1;e=l[e>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[x>>2]=1154;k[x+4>>2]=3199;k[x+8>>2]=1650;Ac(L,1100,x)|0;zc(L,y)|0;c=k[p>>2]|0}e=e<<32-c|k[m>>2];k[m>>2]=e}while((c|0)<7);else e=k[m>>2]|0;k[m>>2]=e<<7;k[p>>2]=c+-7;c=(e>>>25)+11|0;if(c>>>0>g>>>0){c=0;break a}c=c+d|0;break c}default:{if((c+-19|0)>>>0>=2){K=90;break b}f=k[p>>2]|0;if((c|0)==19){if((f|0)<2){e=f;while(1){c=k[h>>2]|0;if((c|0)==(k[j>>2]|0))f=0;else{k[h>>2]=c+1;f=l[c>>0]|0}c=e+8|0;k[p>>2]=c;if((c|0)>=33){k[z>>2]=1154;k[z+4>>2]=3199;k[z+8>>2]=1650;Ac(L,1100,z)|0;zc(L,A)|0;c=k[p>>2]|0}e=f<<32-c|k[m>>2];k[m>>2]=e;if((c|0)<2)e=c;else break}}else{e=k[m>>2]|0;c=f}k[m>>2]=e<<2;k[p>>2]=c+-2;f=(e>>>30)+3|0}else{if((f|0)<6){e=f;while(1){c=k[h>>2]|0;if((c|0)==(k[j>>2]|0))f=0;else{k[h>>2]=c+1;f=l[c>>0]|0}c=e+8|0;k[p>>2]=c;if((c|0)>=33){k[B>>2]=1154;k[B+4>>2]=3199;k[B+8>>2]=1650;Ac(L,1100,B)|0;zc(L,C)|0;c=k[p>>2]|0}e=f<<32-c|k[m>>2];k[m>>2]=e;if((c|0)<6)e=c;else break}}else{e=k[m>>2]|0;c=f}k[m>>2]=e<<6;k[p>>2]=c+-6;f=(e>>>26)+7|0}if((d|0)==0|f>>>0>g>>>0){c=0;break a}c=d+-1|0;if((k[s>>2]|0)>>>0<=c>>>0){k[D>>2]=1154;k[D+4>>2]=903;k[D+8>>2]=1781;Ac(L,1100,D)|0;zc(L,E)|0}e=i[(k[q>>2]|0)+c>>0]|0;if(!(e<<24>>24)){c=0;break a}c=f+d|0;if(d>>>0>=c>>>0){c=d;break c}do{if((k[s>>2]|0)>>>0<=d>>>0){k[F>>2]=1154;k[F+4>>2]=903;k[F+8>>2]=1781;Ac(L,1100,F)|0;zc(L,G)|0}i[(k[q>>2]|0)+d>>0]=e;d=d+1|0}while((d|0)!=(c|0))}}while(0);if(J>>>0>c>>>0)d=c;else break}if((K|0)==90){k[H>>2]=1154;k[H+4>>2]=3140;k[H+8>>2]=1632;Ac(L,1100,H)|0;zc(L,I)|0;c=0;break}if((J|0)==(c|0))c=tb(b)|0;else c=0}else c=0}else{i[M+16>>0]=1;c=0}while(0);rb(M);b=c;r=N;return b|0}function vb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+544|0;h=m+16|0;g=m;f=m+24|0;if(!b){j=0;r=m;return j|0}if(b>>>0<=16){j=xb(a,b)|0;r=m;return j|0}i=xb(a,b+-16|0)|0;j=a+20|0;b=k[j>>2]|0;if((b|0)<16){d=a+4|0;e=a+8|0;c=a+16|0;do{a=k[d>>2]|0;if((a|0)==(k[e>>2]|0))a=0;else{k[d>>2]=a+1;a=l[a>>0]|0}b=b+8|0;k[j>>2]=b;if((b|0)>=33){k[g>>2]=1154;k[g+4>>2]=3199;k[g+8>>2]=1650;Ac(f,1100,g)|0;zc(f,h)|0;b=k[j>>2]|0}a=a<<32-b|k[c>>2];k[c>>2]=a}while((b|0)<16)}else{a=a+16|0;c=a;a=k[a>>2]|0}k[c>>2]=a<<16;k[j>>2]=b+-16;j=a>>>16|i<<16;r=m;return j|0}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0;x=r;r=r+608|0;t=x+88|0;s=x+72|0;p=x+64|0;o=x+48|0;n=x+40|0;q=x+24|0;j=x+16|0;i=x;v=x+96|0;u=k[b+20>>2]|0;w=a+20|0;h=k[w>>2]|0;do if((h|0)<24){g=a+4|0;d=k[g>>2]|0;e=k[a+8>>2]|0;c=d>>>0>>0;if((h|0)>=16){if(c){k[g>>2]=d+1;c=l[d>>0]|0}else c=0;k[w>>2]=h+8;g=a+16|0;f=c<<24-h|k[g>>2];k[g>>2]=f;break}if(c){f=(l[d>>0]|0)<<8;c=d+1|0}else{f=0;c=d}if(c>>>0>>0){d=l[c>>0]|0;c=c+1|0}else d=0;k[g>>2]=c;k[w>>2]=h+16;g=a+16|0;f=(d|f)<<16-h|k[g>>2];k[g>>2]=f}else{f=a+16|0;g=f;f=k[f>>2]|0}while(0);e=(f>>>16)+1|0;do if(e>>>0<=(k[u+16>>2]|0)>>>0){d=k[(k[u+168>>2]|0)+(f>>>(32-(k[u+8>>2]|0)|0)<<2)>>2]|0;if((d|0)==-1){k[i>>2]=1154;k[i+4>>2]=3244;k[i+8>>2]=1677;Ac(v,1100,i)|0;zc(v,j)|0}c=d&65535;d=d>>>16;if((k[b+8>>2]|0)>>>0<=c>>>0){k[q>>2]=1154;k[q+4>>2]=902;k[q+8>>2]=1781;Ac(v,1100,q)|0;zc(v,n)|0}if((l[(k[b+4>>2]|0)+c>>0]|0|0)!=(d|0)){k[o>>2]=1154;k[o+4>>2]=3248;k[o+8>>2]=1694;Ac(v,1100,o)|0;zc(v,p)|0}}else{d=k[u+20>>2]|0;while(1){c=d+-1|0;if(e>>>0>(k[u+28+(c<<2)>>2]|0)>>>0)d=d+1|0;else break}c=(f>>>(32-d|0))+(k[u+96+(c<<2)>>2]|0)|0;if(c>>>0<(k[b>>2]|0)>>>0){c=m[(k[u+176>>2]|0)+(c<<1)>>1]|0;break}k[s>>2]=1154;k[s+4>>2]=3266;k[s+8>>2]=1632;Ac(v,1100,s)|0;zc(v,t)|0;w=0;r=x;return w|0}while(0);k[g>>2]=k[g>>2]<>2]=(k[w>>2]|0)-d;w=c;r=x;return w|0}function xb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+560|0;h=m+40|0;i=m+24|0;c=m;g=m+48|0;if(b>>>0>=33){k[c>>2]=1154;k[c+4>>2]=3190;k[c+8>>2]=1634;Ac(g,1100,c)|0;zc(g,m+16|0)|0}j=a+20|0;c=k[j>>2]|0;if((c|0)>=(b|0)){f=a+16|0;g=f;f=k[f>>2]|0;h=c;i=32-b|0;i=f>>>i;f=f<>2]=f;b=h-b|0;k[j>>2]=b;r=m;return i|0}e=a+4|0;f=a+8|0;d=a+16|0;do{a=k[e>>2]|0;if((a|0)==(k[f>>2]|0))a=0;else{k[e>>2]=a+1;a=l[a>>0]|0}c=c+8|0;k[j>>2]=c;if((c|0)>=33){k[i>>2]=1154;k[i+4>>2]=3199;k[i+8>>2]=1650;Ac(g,1100,i)|0;zc(g,h)|0;c=k[j>>2]|0}a=a<<32-c|k[d>>2];k[d>>2]=a}while((c|0)<(b|0));i=32-b|0;i=a>>>i;h=a<>2]=h;b=c-b|0;k[j>>2]=b;r=m;return i|0}function yb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0;s=r;r=r+544|0;p=s+16|0;o=s;n=s+24|0;if((a|0)==0|b>>>0<62){q=0;r=s;return q|0}m=mb(300,0)|0;if(!m){q=0;r=s;return q|0}k[m>>2]=519686845;c=m+4|0;k[c>>2]=0;d=m+8|0;k[d>>2]=0;j=m+88|0;e=m+136|0;f=m+160|0;g=j;h=g+44|0;do{k[g>>2]=0;g=g+4|0}while((g|0)<(h|0));i[j+44>>0]=0;t=m+184|0;g=m+208|0;h=m+232|0;u=m+252|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;u=m+268|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;u=m+284|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;k[e>>2]=0;k[e+4>>2]=0;k[e+8>>2]=0;k[e+12>>2]=0;k[e+16>>2]=0;i[e+20>>0]=0;k[f>>2]=0;k[f+4>>2]=0;k[f+8>>2]=0;k[f+12>>2]=0;k[f+16>>2]=0;i[f+20>>0]=0;k[t>>2]=0;k[t+4>>2]=0;k[t+8>>2]=0;k[t+12>>2]=0;k[t+16>>2]=0;i[t+20>>0]=0;k[g>>2]=0;k[g+4>>2]=0;k[g+8>>2]=0;k[g+12>>2]=0;k[g+16>>2]=0;i[g+20>>0]=0;k[h>>2]=0;k[h+4>>2]=0;k[h+8>>2]=0;k[h+12>>2]=0;i[h+16>>0]=0;do if(((b>>>0>=74?((l[a>>0]|0)<<8|(l[a+1>>0]|0)|0)==18552:0)?((l[a+2>>0]|0)<<8|(l[a+3>>0]|0))>>>0>=74:0)?((l[a+7>>0]|0)<<16|(l[a+6>>0]|0)<<24|(l[a+8>>0]|0)<<8|(l[a+9>>0]|0))>>>0<=b>>>0:0){k[j>>2]=a;k[c>>2]=a;k[d>>2]=b;if(Hb(m)|0){c=k[j>>2]|0;if((l[c+39>>0]|0)<<8|(l[c+40>>0]|0)){if(!(Ib(m)|0))break;if(!(Jb(m)|0))break;c=k[j>>2]|0}if(!((l[c+55>>0]|0)<<8|(l[c+56>>0]|0))){u=m;r=s;return u|0}if(Kb(m)|0?Lb(m)|0:0){u=m;r=s;return u|0}}}else q=7;while(0);if((q|0)==7)k[j>>2]=0;Qb(m);if(!(m&7)){$a[k[104>>2]&1](m,0,0,1,k[27]|0)|0;u=0;r=s;return u|0}else{k[o>>2]=1154;k[o+4>>2]=2499;k[o+8>>2]=1516;Ac(n,1100,o)|0;zc(n,p)|0;u=0;r=s;return u|0}return 0}function zb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+544|0;j=m;i=m+24|0;f=k[a+88>>2]|0;h=(l[f+70+(e<<2)+1>>0]|0)<<16|(l[f+70+(e<<2)>>0]|0)<<24|(l[f+70+(e<<2)+2>>0]|0)<<8|(l[f+70+(e<<2)+3>>0]|0);g=e+1|0;if(g>>>0<(l[f+16>>0]|0)>>>0)f=(l[f+70+(g<<2)+1>>0]|0)<<16|(l[f+70+(g<<2)>>0]|0)<<24|(l[f+70+(g<<2)+2>>0]|0)<<8|(l[f+70+(g<<2)+3>>0]|0);else f=k[a+8>>2]|0;if(f>>>0>h>>>0){i=a+4|0;i=k[i>>2]|0;i=i+h|0;j=f-h|0;j=Ab(a,i,j,b,c,d,e)|0;r=m;return j|0}k[j>>2]=1154;k[j+4>>2]=3704;k[j+8>>2]=1792;Ac(i,1100,j)|0;zc(i,m+16|0)|0;i=a+4|0;i=k[i>>2]|0;i=i+h|0;j=f-h|0;j=Ab(a,i,j,b,c,d,e)|0;r=m;return j|0}function Ab(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,m=0,n=0;n=k[a+88>>2]|0;j=((l[n+12>>0]|0)<<8|(l[n+13>>0]|0))>>>g;m=((l[n+14>>0]|0)<<8|(l[n+15>>0]|0))>>>g;j=j>>>0>1?(j+3|0)>>>2:1;m=m>>>0>1?(m+3|0)>>>2:1;n=n+18|0;g=i[n>>0]|0;g=ha(g<<24>>24==0|g<<24>>24==9?8:16,j)|0;if(f)if((f&3|0)==0&g>>>0<=f>>>0)g=f;else{a=0;return a|0}if((ha(g,m)|0)>>>0>e>>>0){a=0;return a|0}f=(j+1|0)>>>1;h=(m+1|0)>>>1;if(!c){a=0;return a|0}k[a+92>>2]=b;k[a+96>>2]=b;k[a+104>>2]=c;k[a+100>>2]=b+c;k[a+108>>2]=0;k[a+112>>2]=0;switch(l[n>>0]|0|0){case 0:{Mb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 4:case 6:case 5:case 3:case 2:{Nb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 9:{Ob(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 8:case 7:{Pb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}default:{a=0;return a|0}}return 0}function Bb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+4>>2]|0}function Cb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+8>>2]|0}function Db(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+12>>2]|0}function Eb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+32>>2]|0}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=r;r=r+576|0;g=i+56|0;f=i+40|0;e=i+64|0;j=i;k[j>>2]=40;pb(a,b,j)|0;d=(((k[j+4>>2]|0)>>>c)+3|0)>>>2;b=(((k[j+8>>2]|0)>>>c)+3|0)>>>2;c=j+32|0;a=k[c+4>>2]|0;do switch(k[c>>2]|0){case 0:{if(!a)a=8;else h=13;break}case 1:{if(!a)h=12;else h=13;break}case 2:{if(!a)h=12;else h=13;break}case 3:{if(!a)h=12;else h=13;break}case 4:{if(!a)h=12;else h=13;break}case 5:{if(!a)h=12;else h=13;break}case 6:{if(!a)h=12;else h=13;break}case 7:{if(!a)h=12;else h=13;break}case 8:{if(!a)h=12;else h=13;break}case 9:{if(!a)a=8;else h=13;break}default:h=13}while(0);if((h|0)==12)a=16;else if((h|0)==13){k[f>>2]=1154;k[f+4>>2]=2663;k[f+8>>2]=1535;Ac(e,1100,f)|0;zc(e,g)|0;a=0}j=ha(ha(b,d)|0,a)|0;r=i;return j|0}function Gb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0;p=r;r=r+608|0;n=p+80|0;o=p+64|0;h=p+56|0;g=p+40|0;l=p+88|0;q=p;m=p+84|0;k[q>>2]=40;pb(a,b,q)|0;i=(((k[q+4>>2]|0)>>>e)+3|0)>>>2;q=q+32|0;f=k[q+4>>2]|0;do switch(k[q>>2]|0){case 0:{if(!f)f=8;else j=13;break}case 1:{if(!f)j=12;else j=13;break}case 2:{if(!f)j=12;else j=13;break}case 3:{if(!f)j=12;else j=13;break}case 4:{if(!f)j=12;else j=13;break}case 5:{if(!f)j=12;else j=13;break}case 6:{if(!f)j=12;else j=13;break}case 7:{if(!f)j=12;else j=13;break}case 8:{if(!f)j=12;else j=13;break}case 9:{if(!f)f=8;else j=13;break}default:j=13}while(0);if((j|0)==12)f=16;else if((j|0)==13){k[g>>2]=1154;k[g+4>>2]=2663;k[g+8>>2]=1535;Ac(l,1100,g)|0;zc(l,h)|0;f=0}h=ha(f,i)|0;g=yb(a,b)|0;k[m>>2]=c;f=(g|0)==0;if(!(e>>>0>15|(d>>>0<8|f))?(k[g>>2]|0)==519686845:0)zb(g,m,d,h,e)|0;if(f){r=p;return}if((k[g>>2]|0)!=519686845){r=p;return}Qb(g);if(!(g&7)){$a[k[104>>2]&1](g,0,0,1,k[27]|0)|0;r=p;return}else{k[o>>2]=1154;k[o+4>>2]=2499;k[o+8>>2]=1516;Ac(l,1100,o)|0;zc(l,n)|0;r=p;return}}function Hb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;g=a+92|0;d=k[a+4>>2]|0;f=a+88|0;e=k[f>>2]|0;b=(l[e+68>>0]|0)<<8|(l[e+67>>0]|0)<<16|(l[e+69>>0]|0);c=d+b|0;e=(l[e+65>>0]|0)<<8|(l[e+66>>0]|0);if(!e){a=0;return a|0}k[g>>2]=c;k[a+96>>2]=c;k[a+104>>2]=e;k[a+100>>2]=d+(e+b);k[a+108>>2]=0;k[a+112>>2]=0;if(!(ub(g,a+116|0)|0)){a=0;return a|0}b=k[f>>2]|0;do if(!((l[b+39>>0]|0)<<8|(l[b+40>>0]|0))){if(!((l[b+55>>0]|0)<<8|(l[b+56>>0]|0))){a=0;return a|0}}else{if(!(ub(g,a+140|0)|0)){a=0;return a|0}if(ub(g,a+188|0)|0){b=k[f>>2]|0;break}else{a=0;return a|0}}while(0);if((l[b+55>>0]|0)<<8|(l[b+56>>0]|0)){if(!(ub(g,a+164|0)|0)){a=0;return a|0}if(!(ub(g,a+212|0)|0)){a=0;return a|0}}a=1;return a|0}function Ib(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0;s=r;r=r+592|0;j=s+16|0;h=s;g=s+72|0;q=s+24|0;d=a+88|0;b=k[d>>2]|0;p=(l[b+39>>0]|0)<<8|(l[b+40>>0]|0);n=a+236|0;f=a+240|0;c=k[f>>2]|0;if((c|0)!=(p|0)){if(c>>>0<=p>>>0){do if((k[a+244>>2]|0)>>>0

>>0){if(kb(n,p,(c+1|0)==(p|0),4,0)|0){b=k[f>>2]|0;break}i[a+248>>0]=1;q=0;r=s;return q|0}else b=c;while(0);ad((k[n>>2]|0)+(b<<2)|0,0,p-b<<2|0)|0;b=k[d>>2]|0}k[f>>2]=p}m=a+92|0;c=k[a+4>>2]|0;d=(l[b+34>>0]|0)<<8|(l[b+33>>0]|0)<<16|(l[b+35>>0]|0);e=c+d|0;b=(l[b+37>>0]|0)<<8|(l[b+36>>0]|0)<<16|(l[b+38>>0]|0);if(!b){q=0;r=s;return q|0}k[m>>2]=e;k[a+96>>2]=e;k[a+104>>2]=b;k[a+100>>2]=c+(b+d);k[a+108>>2]=0;k[a+112>>2]=0;k[q+20>>2]=0;k[q>>2]=0;k[q+4>>2]=0;k[q+8>>2]=0;k[q+12>>2]=0;i[q+16>>0]=0;a=q+24|0;k[q+44>>2]=0;k[a>>2]=0;k[a+4>>2]=0;k[a+8>>2]=0;k[a+12>>2]=0;i[a+16>>0]=0;if(ub(m,q)|0?(o=q+24|0,ub(m,o)|0):0){if(!(k[f>>2]|0)){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(g,1100,h)|0;zc(g,j)|0}if(!p)b=1;else{d=0;e=0;f=0;b=0;g=0;a=0;h=0;c=k[n>>2]|0;while(1){d=(wb(m,q)|0)+d&31;e=(wb(m,o)|0)+e&63;f=(wb(m,q)|0)+f&31;b=(wb(m,q)|0)+b|0;g=(wb(m,o)|0)+g&63;a=(wb(m,q)|0)+a&31;k[c>>2]=e<<5|d<<11|f|b<<27|g<<21|a<<16;h=h+1|0;if((h|0)==(p|0)){b=1;break}else{b=b&31;c=c+4|0}}}}else b=0;rb(q+24|0);rb(q);q=b;r=s;return q|0}function Jb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;D=r;r=r+1024|0;h=D+16|0;g=D;f=D+504|0;C=D+480|0;A=D+284|0;B=D+88|0;z=D+24|0;e=k[a+88>>2]|0;y=(l[e+47>>0]|0)<<8|(l[e+48>>0]|0);x=a+92|0;b=k[a+4>>2]|0;c=(l[e+42>>0]|0)<<8|(l[e+41>>0]|0)<<16|(l[e+43>>0]|0);d=b+c|0;e=(l[e+45>>0]|0)<<8|(l[e+44>>0]|0)<<16|(l[e+46>>0]|0);if(!e){C=0;r=D;return C|0}k[x>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[C+20>>2]=0;k[C>>2]=0;k[C+4>>2]=0;k[C+8>>2]=0;k[C+12>>2]=0;i[C+16>>0]=0;if(ub(x,C)|0){c=0;d=-3;e=-3;while(1){k[A+(c<<2)>>2]=d;k[B+(c<<2)>>2]=e;b=(d|0)>2;c=c+1|0;if((c|0)==49)break;else{d=b?-3:d+1|0;e=(b&1)+e|0}}b=z;c=b+64|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(c|0));w=a+252|0;c=a+256|0;b=k[c>>2]|0;a:do if((b|0)==(y|0))j=13;else{if(b>>>0<=y>>>0){do if((k[a+260>>2]|0)>>>0>>0)if(kb(w,y,(b+1|0)==(y|0),4,0)|0){b=k[c>>2]|0;break}else{i[a+264>>0]=1;b=0;break a}while(0);ad((k[w>>2]|0)+(b<<2)|0,0,y-b<<2|0)|0}k[c>>2]=y;j=13}while(0);do if((j|0)==13){if(!y){k[g>>2]=1154;k[g+4>>2]=903;k[g+8>>2]=1781;Ac(f,1100,g)|0;zc(f,h)|0;b=1;break}d=z+4|0;e=z+8|0;a=z+12|0;f=z+16|0;g=z+20|0;h=z+24|0;j=z+28|0;m=z+32|0;n=z+36|0;o=z+40|0;p=z+44|0;q=z+48|0;s=z+52|0;t=z+56|0;u=z+60|0;v=0;c=k[w>>2]|0;while(1){b=0;do{E=wb(x,C)|0;w=b<<1;F=z+(w<<2)|0;k[F>>2]=(k[F>>2]|0)+(k[A+(E<<2)>>2]|0)&3;w=z+((w|1)<<2)|0;k[w>>2]=(k[w>>2]|0)+(k[B+(E<<2)>>2]|0)&3;b=b+1|0}while((b|0)!=8);k[c>>2]=(l[1725+(k[d>>2]|0)>>0]|0)<<2|(l[1725+(k[z>>2]|0)>>0]|0)|(l[1725+(k[e>>2]|0)>>0]|0)<<4|(l[1725+(k[a>>2]|0)>>0]|0)<<6|(l[1725+(k[f>>2]|0)>>0]|0)<<8|(l[1725+(k[g>>2]|0)>>0]|0)<<10|(l[1725+(k[h>>2]|0)>>0]|0)<<12|(l[1725+(k[j>>2]|0)>>0]|0)<<14|(l[1725+(k[m>>2]|0)>>0]|0)<<16|(l[1725+(k[n>>2]|0)>>0]|0)<<18|(l[1725+(k[o>>2]|0)>>0]|0)<<20|(l[1725+(k[p>>2]|0)>>0]|0)<<22|(l[1725+(k[q>>2]|0)>>0]|0)<<24|(l[1725+(k[s>>2]|0)>>0]|0)<<26|(l[1725+(k[t>>2]|0)>>0]|0)<<28|(l[1725+(k[u>>2]|0)>>0]|0)<<30;v=v+1|0;if((v|0)==(y|0)){b=1;break}else c=c+4|0}}while(0)}else b=0;rb(C);F=b;r=D;return F|0}function Kb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+560|0;m=q+16|0;h=q;g=q+48|0;p=q+24|0;e=k[a+88>>2]|0;o=(l[e+55>>0]|0)<<8|(l[e+56>>0]|0);n=a+92|0;b=k[a+4>>2]|0;c=(l[e+50>>0]|0)<<8|(l[e+49>>0]|0)<<16|(l[e+51>>0]|0);d=b+c|0;e=(l[e+53>>0]|0)<<8|(l[e+52>>0]|0)<<16|(l[e+54>>0]|0);if(!e){p=0;r=q;return p|0}k[n>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[p+20>>2]=0;k[p>>2]=0;k[p+4>>2]=0;k[p+8>>2]=0;k[p+12>>2]=0;i[p+16>>0]=0;a:do if(ub(n,p)|0){f=a+268|0;c=a+272|0;b=k[c>>2]|0;if((b|0)!=(o|0)){if(b>>>0<=o>>>0){do if((k[a+276>>2]|0)>>>0>>0)if(kb(f,o,(b+1|0)==(o|0),2,0)|0){b=k[c>>2]|0;break}else{i[a+280>>0]=1;b=0;break a}while(0);ad((k[f>>2]|0)+(b<<1)|0,0,o-b<<1|0)|0}k[c>>2]=o}if(!o){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(g,1100,h)|0;zc(g,m)|0;b=1;break}c=0;d=0;e=0;b=k[f>>2]|0;while(1){m=wb(n,p)|0;c=m+c&255;d=(wb(n,p)|0)+d&255;j[b>>1]=d<<8|c;e=e+1|0;if((e|0)==(o|0)){b=1;break}else b=b+2|0}}else b=0;while(0);rb(p);p=b;r=q;return p|0}function Lb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;E=r;r=r+2432|0;h=E+16|0;g=E;f=E+1912|0;D=E+1888|0;B=E+988|0;C=E+88|0;A=E+24|0;e=k[a+88>>2]|0;z=(l[e+63>>0]|0)<<8|(l[e+64>>0]|0);y=a+92|0;b=k[a+4>>2]|0;c=(l[e+58>>0]|0)<<8|(l[e+57>>0]|0)<<16|(l[e+59>>0]|0);d=b+c|0;e=(l[e+61>>0]|0)<<8|(l[e+60>>0]|0)<<16|(l[e+62>>0]|0);if(!e){D=0;r=E;return D|0}k[y>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[D+20>>2]=0;k[D>>2]=0;k[D+4>>2]=0;k[D+8>>2]=0;k[D+12>>2]=0;i[D+16>>0]=0;if(ub(y,D)|0){c=0;d=-7;e=-7;while(1){k[B+(c<<2)>>2]=d;k[C+(c<<2)>>2]=e;b=(d|0)>6;c=c+1|0;if((c|0)==225)break;else{d=b?-7:d+1|0;e=(b&1)+e|0}}b=A;c=b+64|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(c|0));x=a+284|0;c=z*3|0;d=a+288|0;b=k[d>>2]|0;a:do if((b|0)==(c|0))m=13;else{if(b>>>0<=c>>>0){do if((k[a+292>>2]|0)>>>0>>0)if(kb(x,c,(b+1|0)==(c|0),2,0)|0){b=k[d>>2]|0;break}else{i[a+296>>0]=1;b=0;break a}while(0);ad((k[x>>2]|0)+(b<<1)|0,0,c-b<<1|0)|0}k[d>>2]=c;m=13}while(0);do if((m|0)==13){if(!z){k[g>>2]=1154;k[g+4>>2]=903;k[g+8>>2]=1781;Ac(f,1100,g)|0;zc(f,h)|0;b=1;break}d=A+4|0;e=A+8|0;a=A+12|0;f=A+16|0;g=A+20|0;h=A+24|0;m=A+28|0;n=A+32|0;o=A+36|0;p=A+40|0;q=A+44|0;s=A+48|0;t=A+52|0;u=A+56|0;v=A+60|0;w=0;c=k[x>>2]|0;while(1){b=0;do{F=wb(y,D)|0;x=b<<1;G=A+(x<<2)|0;k[G>>2]=(k[G>>2]|0)+(k[B+(F<<2)>>2]|0)&7;x=A+((x|1)<<2)|0;k[x>>2]=(k[x>>2]|0)+(k[C+(F<<2)>>2]|0)&7;b=b+1|0}while((b|0)!=8);F=l[1729+(k[g>>2]|0)>>0]|0;j[c>>1]=(l[1729+(k[d>>2]|0)>>0]|0)<<3|(l[1729+(k[A>>2]|0)>>0]|0)|(l[1729+(k[e>>2]|0)>>0]|0)<<6|(l[1729+(k[a>>2]|0)>>0]|0)<<9|(l[1729+(k[f>>2]|0)>>0]|0)<<12|F<<15;G=l[1729+(k[p>>2]|0)>>0]|0;j[c+2>>1]=(l[1729+(k[h>>2]|0)>>0]|0)<<2|F>>>1|(l[1729+(k[m>>2]|0)>>0]|0)<<5|(l[1729+(k[n>>2]|0)>>0]|0)<<8|(l[1729+(k[o>>2]|0)>>0]|0)<<11|G<<14;j[c+4>>1]=(l[1729+(k[q>>2]|0)>>0]|0)<<1|G>>>2|(l[1729+(k[s>>2]|0)>>0]|0)<<4|(l[1729+(k[t>>2]|0)>>0]|0)<<7|(l[1729+(k[u>>2]|0)>>0]|0)<<10|(l[1729+(k[v>>2]|0)>>0]|0)<<13;w=w+1|0;if((w|0)==(z|0)){b=1;break}else c=c+6|0}}while(0)}else b=0;rb(D);G=b;r=E;return G|0}function Mb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0;pa=r;r=r+720|0;oa=pa+184|0;ma=pa+168|0;la=pa+160|0;ka=pa+144|0;ja=pa+136|0;ia=pa+120|0;ga=pa+112|0;ea=pa+96|0;da=pa+88|0;ca=pa+72|0;ba=pa+64|0;aa=pa+48|0;$=pa+40|0;na=pa+24|0;fa=pa+16|0;_=pa;Y=pa+208|0;Z=pa+192|0;R=a+240|0;S=k[R>>2]|0;V=a+256|0;W=k[V>>2]|0;c=i[(k[a+88>>2]|0)+17>>0]|0;X=d>>>2;if(!(c<<24>>24)){r=pa;return 1}T=(h|0)==0;U=h+-1|0;K=(f&1|0)!=0;L=d<<1;M=a+92|0;N=a+116|0;O=a+140|0;P=a+236|0;Q=g+-1|0;J=(e&1|0)!=0;I=a+188|0;D=a+252|0;E=X+1|0;F=X+2|0;G=X+3|0;H=Q<<4;B=c&255;c=0;f=0;e=1;C=0;do{if(!T){z=k[b+(C<<2)>>2]|0;A=0;while(1){w=A&1;j=(w|0)==0;v=(w<<5^32)+-16|0;w=(w<<1^2)+-1|0;y=j?g:-1;m=j?0:Q;a=(A|0)==(U|0);x=K&a;if((m|0)!=(y|0)){u=K&a^1;t=j?z:z+H|0;while(1){if((e|0)==1)e=wb(M,N)|0|512;s=e&7;e=e>>>3;j=l[1823+s>>0]|0;a=0;do{p=(wb(M,O)|0)+f|0;q=p-S|0;f=q>>31;f=f&p|q&~f;if((k[R>>2]|0)>>>0<=f>>>0){k[_>>2]=1154;k[_+4>>2]=903;k[_+8>>2]=1781;Ac(Y,1100,_)|0;zc(Y,fa)|0}k[Z+(a<<2)>>2]=k[(k[P>>2]|0)+(f<<2)>>2];a=a+1|0}while(a>>>0>>0);q=J&(m|0)==(Q|0);if(x|q){p=0;do{n=ha(p,d)|0;a=t+n|0;j=(p|0)==0|u;o=p<<1;ra=(wb(M,I)|0)+c|0;qa=ra-W|0;c=qa>>31;c=c&ra|qa&~c;do if(q){if(!j){qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;break}k[a>>2]=k[Z+((l[1831+(s<<2)+o>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(Y,1100,ka)|0;zc(Y,la)|0}k[t+(n+4)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c}else{if(!j){qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;break}k[a>>2]=k[Z+((l[1831+(s<<2)+o>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ia>>2]=1154;k[ia+4>>2]=903;k[ia+8>>2]=1781;Ac(Y,1100,ia)|0;zc(Y,ja)|0}k[t+(n+4)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;k[t+(n+8)>>2]=k[Z+((l[(o|1)+(1831+(s<<2))>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ma>>2]=1154;k[ma+4>>2]=903;k[ma+8>>2]=1781;Ac(Y,1100,ma)|0;zc(Y,oa)|0}k[t+(n+12)>>2]=k[(k[D>>2]|0)+(c<<2)>>2]}while(0);p=p+1|0}while((p|0)!=2)}else{k[t>>2]=k[Z+((l[1831+(s<<2)>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[na>>2]=1154;k[na+4>>2]=903;k[na+8>>2]=1781;Ac(Y,1100,na)|0;zc(Y,$)|0}k[t+4>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+8>>2]=k[Z+((l[1831+(s<<2)+1>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[aa>>2]=1154;k[aa+4>>2]=903;k[aa+8>>2]=1781;Ac(Y,1100,aa)|0;zc(Y,ba)|0}k[t+12>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+(X<<2)>>2]=k[Z+((l[1831+(s<<2)+2>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[ca>>2]=1154;k[ca+4>>2]=903;k[ca+8>>2]=1781;Ac(Y,1100,ca)|0;zc(Y,da)|0}k[t+(E<<2)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+(F<<2)>>2]=k[Z+((l[1831+(s<<2)+3>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[ea>>2]=1154;k[ea+4>>2]=903;k[ea+8>>2]=1781;Ac(Y,1100,ea)|0;zc(Y,ga)|0}k[t+(G<<2)>>2]=k[(k[D>>2]|0)+(c<<2)>>2]}m=m+w|0;if((m|0)==(y|0))break;else t=t+v|0}}A=A+1|0;if((A|0)==(h|0))break;else z=z+L|0}}C=C+1|0}while((C|0)!=(B|0));r=pa;return 1}function Nb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0;qa=r;r=r+640|0;na=qa+88|0;ma=qa+72|0;la=qa+64|0;ka=qa+48|0;ja=qa+40|0;pa=qa+24|0;oa=qa+16|0;ia=qa;ga=qa+128|0;ha=qa+112|0;fa=qa+96|0;S=a+240|0;T=k[S>>2]|0;W=a+256|0;ca=k[W>>2]|0;da=a+272|0;ea=k[da>>2]|0;c=k[a+88>>2]|0;U=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=qa;return 1}V=(h|0)==0;X=h+-1|0;Y=d<<1;Z=a+92|0;_=a+116|0;$=g+-1|0;aa=a+212|0;ba=a+188|0;R=(e&1|0)==0;Q=(f&1|0)==0;K=a+288|0;L=a+284|0;M=a+252|0;N=a+140|0;O=a+236|0;P=a+164|0;I=a+268|0;J=$<<5;G=c&255;c=0;e=0;f=0;a=0;j=1;H=0;do{if(!V){E=k[b+(H<<2)>>2]|0;F=0;while(1){C=F&1;n=(C|0)==0;B=(C<<6^64)+-32|0;C=(C<<1^2)+-1|0;D=n?g:-1;o=n?0:$;if((o|0)!=(D|0)){A=Q|(F|0)!=(X|0);z=n?E:E+J|0;while(1){if((j|0)==1)j=wb(Z,_)|0|512;y=j&7;j=j>>>3;p=l[1823+y>>0]|0;n=0;do{w=(wb(Z,P)|0)+e|0;x=w-ea|0;e=x>>31;e=e&w|x&~e;if((k[da>>2]|0)>>>0<=e>>>0){k[ia>>2]=1154;k[ia+4>>2]=903;k[ia+8>>2]=1781;Ac(ga,1100,ia)|0;zc(ga,oa)|0}k[fa+(n<<2)>>2]=m[(k[I>>2]|0)+(e<<1)>>1];n=n+1|0}while(n>>>0

>>0);n=0;do{w=(wb(Z,N)|0)+a|0;x=w-T|0;a=x>>31;a=a&w|x&~a;if((k[S>>2]|0)>>>0<=a>>>0){k[pa>>2]=1154;k[pa+4>>2]=903;k[pa+8>>2]=1781;Ac(ga,1100,pa)|0;zc(ga,ja)|0}k[ha+(n<<2)>>2]=k[(k[O>>2]|0)+(a<<2)>>2];n=n+1|0}while(n>>>0

>>0);x=R|(o|0)!=($|0);v=0;w=z;while(1){u=A|(v|0)==0;t=v<<1;q=0;s=w;while(1){p=(wb(Z,aa)|0)+c|0;n=p-U|0;c=n>>31;c=c&p|n&~c;n=(wb(Z,ba)|0)+f|0;p=n-ca|0;f=p>>31;f=f&n|p&~f;if((x|(q|0)==0)&u){n=l[q+t+(1831+(y<<2))>>0]|0;p=c*3|0;if((k[K>>2]|0)>>>0<=p>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(ga,1100,ka)|0;zc(ga,la)|0}ra=k[L>>2]|0;k[s>>2]=(m[ra+(p<<1)>>1]|0)<<16|k[fa+(n<<2)>>2];k[s+4>>2]=(m[ra+(p+2<<1)>>1]|0)<<16|(m[ra+(p+1<<1)>>1]|0);k[s+8>>2]=k[ha+(n<<2)>>2];if((k[W>>2]|0)>>>0<=f>>>0){k[ma>>2]=1154;k[ma+4>>2]=903;k[ma+8>>2]=1781;Ac(ga,1100,ma)|0;zc(ga,na)|0}k[s+12>>2]=k[(k[M>>2]|0)+(f<<2)>>2]}q=q+1|0;if((q|0)==2)break;else s=s+16|0}v=v+1|0;if((v|0)==2)break;else w=w+d|0}o=o+C|0;if((o|0)==(D|0))break;else z=z+B|0}}F=F+1|0;if((F|0)==(h|0))break;else E=E+Y|0}}H=H+1|0}while((H|0)!=(G|0));r=qa;return 1}function Ob(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;ca=r;r=r+608|0;$=ca+64|0;_=ca+48|0;Z=ca+40|0;ba=ca+24|0;aa=ca+16|0;Y=ca;X=ca+88|0;W=ca+72|0;M=a+272|0;N=k[M>>2]|0;c=k[a+88>>2]|0;O=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=ca;return 1}P=(h|0)==0;Q=h+-1|0;R=d<<1;S=a+92|0;T=a+116|0;U=g+-1|0;V=a+212|0;L=(f&1|0)==0;I=a+288|0;J=a+284|0;K=a+164|0;G=a+268|0;H=U<<4;F=c&255;E=(e&1|0)!=0;c=0;f=0;a=1;D=0;do{if(!P){B=k[b+(D<<2)>>2]|0;C=0;while(1){z=C&1;e=(z|0)==0;y=(z<<5^32)+-16|0;z=(z<<1^2)+-1|0;A=e?g:-1;j=e?0:U;if((j|0)!=(A|0)){x=L|(C|0)!=(Q|0);w=e?B:B+H|0;while(1){if((a|0)==1)a=wb(S,T)|0|512;v=a&7;a=a>>>3;n=l[1823+v>>0]|0;e=0;do{t=(wb(S,K)|0)+f|0;u=t-N|0;f=u>>31;f=f&t|u&~f;if((k[M>>2]|0)>>>0<=f>>>0){k[Y>>2]=1154;k[Y+4>>2]=903;k[Y+8>>2]=1781;Ac(X,1100,Y)|0;zc(X,aa)|0}k[W+(e<<2)>>2]=m[(k[G>>2]|0)+(f<<1)>>1];e=e+1|0}while(e>>>0>>0);u=(j|0)==(U|0)&E;s=0;t=w;while(1){q=x|(s|0)==0;p=s<<1;e=(wb(S,V)|0)+c|0;o=e-O|0;n=o>>31;n=n&e|o&~n;if(q){c=l[1831+(v<<2)+p>>0]|0;e=n*3|0;if((k[I>>2]|0)>>>0<=e>>>0){k[ba>>2]=1154;k[ba+4>>2]=903;k[ba+8>>2]=1781;Ac(X,1100,ba)|0;zc(X,Z)|0}o=k[J>>2]|0;k[t>>2]=(m[o+(e<<1)>>1]|0)<<16|k[W+(c<<2)>>2];k[t+4>>2]=(m[o+(e+2<<1)>>1]|0)<<16|(m[o+(e+1<<1)>>1]|0)}o=t+8|0;e=(wb(S,V)|0)+n|0;n=e-O|0;c=n>>31;c=c&e|n&~c;if(!(u|q^1)){e=l[(p|1)+(1831+(v<<2))>>0]|0;n=c*3|0;if((k[I>>2]|0)>>>0<=n>>>0){k[_>>2]=1154;k[_+4>>2]=903;k[_+8>>2]=1781;Ac(X,1100,_)|0;zc(X,$)|0}q=k[J>>2]|0;k[o>>2]=(m[q+(n<<1)>>1]|0)<<16|k[W+(e<<2)>>2];k[t+12>>2]=(m[q+(n+2<<1)>>1]|0)<<16|(m[q+(n+1<<1)>>1]|0)}s=s+1|0;if((s|0)==2)break;else t=t+d|0}j=j+z|0;if((j|0)==(A|0))break;else w=w+y|0}}C=C+1|0;if((C|0)==(h|0))break;else B=B+R|0}}D=D+1|0}while((D|0)!=(F|0));r=ca;return 1}function Pb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0;la=r;r=r+640|0;ia=la+88|0;ha=la+72|0;ga=la+64|0;fa=la+48|0;ea=la+40|0;ka=la+24|0;ja=la+16|0;da=la;ca=la+128|0;aa=la+112|0;ba=la+96|0;S=a+272|0;T=k[S>>2]|0;c=k[a+88>>2]|0;U=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=la;return 1}V=(h|0)==0;W=h+-1|0;X=d<<1;Y=a+92|0;Z=a+116|0;_=g+-1|0;$=a+212|0;R=(e&1|0)==0;Q=(f&1|0)==0;N=a+288|0;O=a+284|0;P=a+164|0;L=a+268|0;M=_<<5;J=c&255;c=0;e=0;f=0;a=0;j=1;K=0;do{if(!V){H=k[b+(K<<2)>>2]|0;I=0;while(1){F=I&1;n=(F|0)==0;E=(F<<6^64)+-32|0;F=(F<<1^2)+-1|0;G=n?g:-1;o=n?0:_;if((o|0)!=(G|0)){D=Q|(I|0)!=(W|0);C=n?H:H+M|0;while(1){if((j|0)==1)j=wb(Y,Z)|0|512;B=j&7;j=j>>>3;p=l[1823+B>>0]|0;n=0;do{z=(wb(Y,P)|0)+a|0;A=z-T|0;a=A>>31;a=a&z|A&~a;if((k[S>>2]|0)>>>0<=a>>>0){k[da>>2]=1154;k[da+4>>2]=903;k[da+8>>2]=1781;Ac(ca,1100,da)|0;zc(ca,ja)|0}k[aa+(n<<2)>>2]=m[(k[L>>2]|0)+(a<<1)>>1];n=n+1|0}while(n>>>0

>>0);n=0;do{z=(wb(Y,P)|0)+e|0;A=z-T|0;e=A>>31;e=e&z|A&~e;if((k[S>>2]|0)>>>0<=e>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(ca,1100,ka)|0;zc(ca,ea)|0}k[ba+(n<<2)>>2]=m[(k[L>>2]|0)+(e<<1)>>1];n=n+1|0}while(n>>>0

>>0);A=R|(o|0)!=(_|0);y=0;z=C;while(1){x=D|(y|0)==0;w=y<<1;u=0;v=z;while(1){t=(wb(Y,$)|0)+f|0;s=t-U|0;f=s>>31;f=f&t|s&~f;s=(wb(Y,$)|0)+c|0;t=s-U|0;c=t>>31;c=c&s|t&~c;if((A|(u|0)==0)&x){s=l[u+w+(1831+(B<<2))>>0]|0;t=f*3|0;n=k[N>>2]|0;if(n>>>0<=t>>>0){k[fa>>2]=1154;k[fa+4>>2]=903;k[fa+8>>2]=1781;Ac(ca,1100,fa)|0;zc(ca,ga)|0;n=k[N>>2]|0}p=k[O>>2]|0;q=c*3|0;if(n>>>0>q>>>0)n=p;else{k[ha>>2]=1154;k[ha+4>>2]=903;k[ha+8>>2]=1781;Ac(ca,1100,ha)|0;zc(ca,ia)|0;n=k[O>>2]|0}k[v>>2]=(m[p+(t<<1)>>1]|0)<<16|k[aa+(s<<2)>>2];k[v+4>>2]=(m[p+(t+2<<1)>>1]|0)<<16|(m[p+(t+1<<1)>>1]|0);k[v+8>>2]=(m[n+(q<<1)>>1]|0)<<16|k[ba+(s<<2)>>2];k[v+12>>2]=(m[n+(q+2<<1)>>1]|0)<<16|(m[n+(q+1<<1)>>1]|0)}u=u+1|0;if((u|0)==2)break;else v=v+16|0}y=y+1|0;if((y|0)==2)break;else z=z+d|0}o=o+F|0;if((o|0)==(G|0))break;else C=C+E|0}}I=I+1|0;if((I|0)==(h|0))break;else H=H+X|0}}K=K+1|0}while((K|0)!=(J|0));r=la;return 1}function Qb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,l=0,m=0,n=0,o=0;o=r;r=r+608|0;n=o+88|0;m=o+72|0;j=o+64|0;h=o+48|0;f=o+40|0;g=o+24|0;e=o+16|0;d=o;l=o+96|0;k[a>>2]=0;b=a+284|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[d>>2]=1154;k[d+4>>2]=2499;k[d+8>>2]=1516;Ac(l,1100,d)|0;zc(l,e)|0}k[b>>2]=0;k[a+288>>2]=0;k[a+292>>2]=0}i[a+296>>0]=0;b=a+268|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[g>>2]=1154;k[g+4>>2]=2499;k[g+8>>2]=1516;Ac(l,1100,g)|0;zc(l,f)|0}k[b>>2]=0;k[a+272>>2]=0;k[a+276>>2]=0}i[a+280>>0]=0;b=a+252|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[h>>2]=1154;k[h+4>>2]=2499;k[h+8>>2]=1516;Ac(l,1100,h)|0;zc(l,j)|0}k[b>>2]=0;k[a+256>>2]=0;k[a+260>>2]=0}i[a+264>>0]=0;b=a+236|0;c=k[b>>2]|0;if(!c){n=a+248|0;i[n>>0]=0;n=a+212|0;rb(n);n=a+188|0;rb(n);n=a+164|0;rb(n);n=a+140|0;rb(n);n=a+116|0;rb(n);r=o;return}if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(l,1100,m)|0;zc(l,n)|0}k[b>>2]=0;k[a+240>>2]=0;k[a+244>>2]=0;n=a+248|0;i[n>>0]=0;n=a+212|0;rb(n);n=a+188|0;rb(n);n=a+164|0;rb(n);n=a+140|0;rb(n);n=a+116|0;rb(n);r=o;return}function Rb(a,b){a=a|0;b=b|0;var c=0;c=r;r=r+16|0;k[c>>2]=b;b=k[63]|0;Bc(b,a,c)|0;xc(10,b)|0;Na()}function Sb(){var a=0,b=0;a=r;r=r+16|0;if(!(Ha(200,2)|0)){b=Fa(k[49]|0)|0;r=a;return b|0}else Rb(2090,a);return 0}function Tb(a){a=a|0;Vc(a);return}function Ub(a){a=a|0;var b=0;b=r;r=r+16|0;Za[a&3]();Rb(2139,b)}function Vb(){var a=0,b=0;a=Sb()|0;if(((a|0)!=0?(b=k[a>>2]|0,(b|0)!=0):0)?(a=b+48|0,(k[a>>2]&-256|0)==1126902528?(k[a+4>>2]|0)==1129074247:0):0)Ub(k[b+12>>2]|0);b=k[28]|0;k[28]=b+0;Ub(b)}function Wb(a){a=a|0;return}function Xb(a){a=a|0;return}function Yb(a){a=a|0;return}function Zb(a){a=a|0;return}function _b(a){a=a|0;Tb(a);return}function $b(a){a=a|0;Tb(a);return}function ac(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;g=r;r=r+64|0;f=g;if((a|0)!=(b|0))if((b|0)!=0?(e=ec(b,24,40,0)|0,(e|0)!=0):0){b=f;d=b+56|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(d|0));k[f>>2]=e;k[f+8>>2]=a;k[f+12>>2]=-1;k[f+48>>2]=1;ab[k[(k[e>>2]|0)+28>>2]&3](e,f,k[c>>2]|0,1);if((k[f+24>>2]|0)==1){k[c>>2]=k[f+16>>2];b=1}else b=0}else b=0;else b=1;r=g;return b|0}function bc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;a=b+16|0;e=k[a>>2]|0;do if(e){if((e|0)!=(c|0)){d=b+36|0;k[d>>2]=(k[d>>2]|0)+1;k[b+24>>2]=2;i[b+54>>0]=1;break}a=b+24|0;if((k[a>>2]|0)==2)k[a>>2]=d}else{k[a>>2]=c;k[b+24>>2]=d;k[b+36>>2]=1}while(0);return}function cc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((a|0)==(k[b+8>>2]|0))bc(0,b,c,d);return}function dc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((a|0)==(k[b+8>>2]|0))bc(0,b,c,d);else{a=k[a+8>>2]|0;ab[k[(k[a>>2]|0)+28>>2]&3](a,b,c,d)}return}function ec(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,l=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+64|0;p=q;o=k[a>>2]|0;n=a+(k[o+-8>>2]|0)|0;o=k[o+-4>>2]|0;k[p>>2]=c;k[p+4>>2]=a;k[p+8>>2]=b;k[p+12>>2]=d;d=p+16|0;a=p+20|0;b=p+24|0;e=p+28|0;f=p+32|0;g=p+40|0;h=(o|0)==(c|0);l=d;m=l+36|0;do{k[l>>2]=0;l=l+4|0}while((l|0)<(m|0));j[d+36>>1]=0;i[d+38>>0]=0;a:do if(h){k[p+48>>2]=1;_a[k[(k[c>>2]|0)+20>>2]&3](c,p,n,n,1,0);d=(k[b>>2]|0)==1?n:0}else{Va[k[(k[o>>2]|0)+24>>2]&3](o,p,n,1,0);switch(k[p+36>>2]|0){case 0:{d=(k[g>>2]|0)==1&(k[e>>2]|0)==1&(k[f>>2]|0)==1?k[a>>2]|0:0;break a}case 1:break;default:{d=0;break a}}if((k[b>>2]|0)!=1?!((k[g>>2]|0)==0&(k[e>>2]|0)==1&(k[f>>2]|0)==1):0){d=0;break}d=k[d>>2]|0}while(0);r=q;return d|0}function fc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;i[b+53>>0]=1;do if((k[b+4>>2]|0)==(d|0)){i[b+52>>0]=1;d=b+16|0;a=k[d>>2]|0;if(!a){k[d>>2]=c;k[b+24>>2]=e;k[b+36>>2]=1;if(!((e|0)==1?(k[b+48>>2]|0)==1:0))break;i[b+54>>0]=1;break}if((a|0)!=(c|0)){e=b+36|0;k[e>>2]=(k[e>>2]|0)+1;i[b+54>>0]=1;break}a=b+24|0;d=k[a>>2]|0;if((d|0)==2){k[a>>2]=e;d=e}if((d|0)==1?(k[b+48>>2]|0)==1:0)i[b+54>>0]=1}while(0);return}function gc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0;a:do if((a|0)==(k[b+8>>2]|0)){if((k[b+4>>2]|0)==(c|0)?(f=b+28|0,(k[f>>2]|0)!=1):0)k[f>>2]=d}else{if((a|0)!=(k[b>>2]|0)){h=k[a+8>>2]|0;Va[k[(k[h>>2]|0)+24>>2]&3](h,b,c,d,e);break}if((k[b+16>>2]|0)!=(c|0)?(g=b+20|0,(k[g>>2]|0)!=(c|0)):0){k[b+32>>2]=d;d=b+44|0;if((k[d>>2]|0)==4)break;f=b+52|0;i[f>>0]=0;j=b+53|0;i[j>>0]=0;a=k[a+8>>2]|0;_a[k[(k[a>>2]|0)+20>>2]&3](a,b,c,c,1,e);if(i[j>>0]|0){if(!(i[f>>0]|0)){f=1;h=13}}else{f=0;h=13}do if((h|0)==13){k[g>>2]=c;j=b+40|0;k[j>>2]=(k[j>>2]|0)+1;if((k[b+36>>2]|0)==1?(k[b+24>>2]|0)==2:0){i[b+54>>0]=1;if(f)break}else h=16;if((h|0)==16?f:0)break;k[d>>2]=4;break a}while(0);k[d>>2]=3;break}if((d|0)==1)k[b+32>>2]=1}while(0);return}function hc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;do if((a|0)==(k[b+8>>2]|0)){if((k[b+4>>2]|0)==(c|0)?(g=b+28|0,(k[g>>2]|0)!=1):0)k[g>>2]=d}else if((a|0)==(k[b>>2]|0)){if((k[b+16>>2]|0)!=(c|0)?(f=b+20|0,(k[f>>2]|0)!=(c|0)):0){k[b+32>>2]=d;k[f>>2]=c;e=b+40|0;k[e>>2]=(k[e>>2]|0)+1;if((k[b+36>>2]|0)==1?(k[b+24>>2]|0)==2:0)i[b+54>>0]=1;k[b+44>>2]=4;break}if((d|0)==1)k[b+32>>2]=1}while(0);return}function ic(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if((a|0)==(k[b+8>>2]|0))fc(0,b,c,d,e);else{a=k[a+8>>2]|0;_a[k[(k[a>>2]|0)+20>>2]&3](a,b,c,d,e,f)}return}function jc(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if((a|0)==(k[b+8>>2]|0))fc(0,b,c,d,e);return}function kc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=r;r=r+16|0;d=e;k[d>>2]=k[c>>2];a=Ua[k[(k[a>>2]|0)+16>>2]&7](a,b,d)|0;if(a)k[c>>2]=k[d>>2];r=e;return a&1|0}function lc(a){a=a|0;if(!a)a=0;else a=(ec(a,24,72,0)|0)!=0;return a&1|0}function mc(){var a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;e=r;r=r+48|0;g=e+32|0;c=e+24|0;h=e+16|0;f=e;e=e+36|0;a=Sb()|0;if((a|0)!=0?(d=k[a>>2]|0,(d|0)!=0):0){a=d+48|0;b=k[a>>2]|0;a=k[a+4>>2]|0;if(!((b&-256|0)==1126902528&(a|0)==1129074247)){k[c>>2]=k[51];Rb(2368,c)}if((b|0)==1126902529&(a|0)==1129074247)a=k[d+44>>2]|0;else a=d+80|0;k[e>>2]=a;d=k[d>>2]|0;a=k[d+4>>2]|0;if(Ua[k[(k[8>>2]|0)+16>>2]&7](8,d,e)|0){h=k[e>>2]|0;e=k[51]|0;h=Xa[k[(k[h>>2]|0)+8>>2]&1](h)|0;k[f>>2]=e;k[f+4>>2]=a;k[f+8>>2]=h;Rb(2282,f)}else{k[h>>2]=k[51];k[h+4>>2]=a;Rb(2327,h)}}Rb(2406,g)}function nc(){var a=0;a=r;r=r+16|0;if(!(Ia(196,6)|0)){r=a;return}else Rb(2179,a)}function oc(a){a=a|0;var b=0;b=r;r=r+16|0;Vc(a);if(!(La(k[49]|0,0)|0)){r=b;return}else Rb(2229,b)}function pc(a){a=a|0;var b=0,c=0;b=0;while(1){if((l[2427+b>>0]|0)==(a|0)){c=2;break}b=b+1|0;if((b|0)==87){b=87;a=2515;c=5;break}}if((c|0)==2)if(!b)a=2515;else{a=2515;c=5}if((c|0)==5)while(1){c=a;while(1){a=c+1|0;if(!(i[c>>0]|0))break;else c=a}b=b+-1|0;if(!b)break;else c=5}return a|0}function qc(){var a=0;if(!(k[52]|0))a=264;else{a=(Ga()|0)+60|0;a=k[a>>2]|0}return a|0}function rc(a){a=a|0;var b=0;if(a>>>0>4294963200){b=qc()|0;k[b>>2]=0-a;a=-1}return a|0}function sc(a,b){a=+a;b=b|0;var c=0,d=0,e=0;p[t>>3]=a;c=k[t>>2]|0;d=k[t+4>>2]|0;e=bd(c|0,d|0,52)|0;e=e&2047;switch(e|0){case 0:{if(a!=0.0){a=+sc(a*18446744073709552.0e3,b);c=(k[b>>2]|0)+-64|0}else c=0;k[b>>2]=c;break}case 2047:break;default:{k[b>>2]=e+-1022;k[t>>2]=c;k[t+4>>2]=d&-2146435073|1071644672;a=+p[t>>3]}}return +a}function tc(a,b){a=+a;b=b|0;return +(+sc(a,b))}function uc(a,b,c){a=a|0;b=b|0;c=c|0;do if(a){if(b>>>0<128){i[a>>0]=b;a=1;break}if(b>>>0<2048){i[a>>0]=b>>>6|192;i[a+1>>0]=b&63|128;a=2;break}if(b>>>0<55296|(b&-8192|0)==57344){i[a>>0]=b>>>12|224;i[a+1>>0]=b>>>6&63|128;i[a+2>>0]=b&63|128;a=3;break}if((b+-65536|0)>>>0<1048576){i[a>>0]=b>>>18|240;i[a+1>>0]=b>>>12&63|128;i[a+2>>0]=b>>>6&63|128;i[a+3>>0]=b&63|128;a=4;break}else{a=qc()|0;k[a>>2]=84;a=-1;break}}else a=1;while(0);return a|0}function vc(a,b){a=a|0;b=b|0;if(!a)a=0;else a=uc(a,b,0)|0;return a|0}function wc(a){a=a|0;var b=0,c=0;do if(a){if((k[a+76>>2]|0)<=-1){b=Nc(a)|0;break}c=(Ec(a)|0)==0;b=Nc(a)|0;if(!c)Fc(a)}else{if(!(k[65]|0))b=0;else b=wc(k[65]|0)|0;Ma(236);a=k[58]|0;if(a)do{if((k[a+76>>2]|0)>-1)c=Ec(a)|0;else c=0;if((k[a+20>>2]|0)>>>0>(k[a+28>>2]|0)>>>0)b=Nc(a)|0|b;if(c)Fc(a);a=k[a+56>>2]|0}while((a|0)!=0);Ja(236)}while(0);return b|0}function xc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;if((k[b+76>>2]|0)>=0?(Ec(b)|0)!=0:0){if((i[b+75>>0]|0)!=(a|0)?(d=b+20|0,e=k[d>>2]|0,e>>>0<(k[b+16>>2]|0)>>>0):0){k[d>>2]=e+1;i[e>>0]=a;c=a&255}else c=Gc(b,a)|0;Fc(b)}else g=3;do if((g|0)==3){if((i[b+75>>0]|0)!=(a|0)?(f=b+20|0,c=k[f>>2]|0,c>>>0<(k[b+16>>2]|0)>>>0):0){k[f>>2]=c+1;i[c>>0]=a;c=a&255;break}c=Gc(b,a)|0}while(0);return c|0}function yc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=c+16|0;e=k[d>>2]|0;if(!e)if(!(Lc(c)|0)){e=k[d>>2]|0;f=4}else d=0;else f=4;a:do if((f|0)==4){g=c+20|0;f=k[g>>2]|0;if((e-f|0)>>>0>>0){d=Ua[k[c+36>>2]&7](c,a,b)|0;break}b:do if((i[c+75>>0]|0)>-1){d=b;while(1){if(!d){e=f;d=0;break b}e=d+-1|0;if((i[a+e>>0]|0)==10)break;else d=e}if((Ua[k[c+36>>2]&7](c,a,d)|0)>>>0>>0)break a;b=b-d|0;a=a+d|0;e=k[g>>2]|0}else{e=f;d=0}while(0);ed(e|0,a|0,b|0)|0;k[g>>2]=(k[g>>2]|0)+b;d=d+b|0}while(0);return d|0}function zc(a,b){a=a|0;b=b|0;var c=0,d=0;c=r;r=r+16|0;d=c;k[d>>2]=b;b=Bc(k[64]|0,a,d)|0;r=c;return b|0}function Ac(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=r;r=r+16|0;e=d;k[e>>2]=c;c=Dc(a,b,e)|0;r=d;return c|0}function Bc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,s=0;s=r;r=r+224|0;n=s+120|0;q=s+80|0;p=s;o=s+136|0;d=q;e=d+40|0;do{k[d>>2]=0;d=d+4|0}while((d|0)<(e|0));k[n>>2]=k[c>>2];if((Oc(0,b,n,p,q)|0)<0)c=-1;else{if((k[a+76>>2]|0)>-1)l=Ec(a)|0;else l=0;c=k[a>>2]|0;m=c&32;if((i[a+74>>0]|0)<1)k[a>>2]=c&-33;c=a+48|0;if(!(k[c>>2]|0)){e=a+44|0;f=k[e>>2]|0;k[e>>2]=o;g=a+28|0;k[g>>2]=o;h=a+20|0;k[h>>2]=o;k[c>>2]=80;j=a+16|0;k[j>>2]=o+80;d=Oc(a,b,n,p,q)|0;if(f){Ua[k[a+36>>2]&7](a,0,0)|0;d=(k[h>>2]|0)==0?-1:d;k[e>>2]=f;k[c>>2]=0;k[j>>2]=0;k[g>>2]=0;k[h>>2]=0}}else d=Oc(a,b,n,p,q)|0;c=k[a>>2]|0;k[a>>2]=c|m;if(l)Fc(a);c=(c&32|0)==0?d:-1}r=s;return c|0}function Cc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,l=0,m=0;m=r;r=r+128|0;e=m+112|0;l=m;f=l;g=268;h=f+112|0;do{k[f>>2]=k[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(h|0));if((b+-1|0)>>>0>2147483646)if(!b){b=1;j=4}else{b=qc()|0;k[b>>2]=75;b=-1}else{e=a;j=4}if((j|0)==4){j=-2-e|0;j=b>>>0>j>>>0?j:b;k[l+48>>2]=j;a=l+20|0;k[a>>2]=e;k[l+44>>2]=e;b=e+j|0;e=l+16|0;k[e>>2]=b;k[l+28>>2]=b;b=Bc(l,c,d)|0;if(j){c=k[a>>2]|0;i[c+(((c|0)==(k[e>>2]|0))<<31>>31)>>0]=0}}r=m;return b|0}function Dc(a,b,c){a=a|0;b=b|0;c=c|0;return Cc(a,2147483647,b,c)|0}function Ec(a){a=a|0;return 0}function Fc(a){a=a|0;return}function Gc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0;j=r;r=r+16|0;h=j;g=b&255;i[h>>0]=g;d=a+16|0;e=k[d>>2]|0;if(!e)if(!(Lc(a)|0)){e=k[d>>2]|0;f=4}else c=-1;else f=4;do if((f|0)==4){d=a+20|0;f=k[d>>2]|0;if(f>>>0>>0?(c=b&255,(c|0)!=(i[a+75>>0]|0)):0){k[d>>2]=f+1;i[f>>0]=g;break}if((Ua[k[a+36>>2]&7](a,h,1)|0)==1)c=l[h>>0]|0;else c=-1}while(0);r=j;return c|0}function Hc(a){a=a|0;var b=0,c=0;b=r;r=r+16|0;c=b;k[c>>2]=k[a+60>>2];a=rc(xa(6,c|0)|0)|0;r=b;return a|0}function Ic(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;e=r;r=r+32|0;f=e;d=e+20|0;k[f>>2]=k[a+60>>2];k[f+4>>2]=0;k[f+8>>2]=b;k[f+12>>2]=d;k[f+16>>2]=c;if((rc(Qa(140,f|0)|0)|0)<0){k[d>>2]=-1;a=-1}else a=k[d>>2]|0;r=e;return a|0}function Jc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;p=r;r=r+48|0;m=p+16|0;l=p;d=p+32|0;n=a+28|0;e=k[n>>2]|0;k[d>>2]=e;o=a+20|0;e=(k[o>>2]|0)-e|0;k[d+4>>2]=e;k[d+8>>2]=b;k[d+12>>2]=c;i=a+60|0;j=a+44|0;b=2;e=e+c|0;while(1){if(!(k[52]|0)){k[m>>2]=k[i>>2];k[m+4>>2]=d;k[m+8>>2]=b;g=rc(Ra(146,m|0)|0)|0}else{Oa(7,a|0);k[l>>2]=k[i>>2];k[l+4>>2]=d;k[l+8>>2]=b;g=rc(Ra(146,l|0)|0)|0;va(0)}if((e|0)==(g|0)){e=6;break}if((g|0)<0){e=8;break}e=e-g|0;f=k[d+4>>2]|0;if(g>>>0<=f>>>0)if((b|0)==2){k[n>>2]=(k[n>>2]|0)+g;h=f;b=2}else h=f;else{h=k[j>>2]|0;k[n>>2]=h;k[o>>2]=h;h=k[d+12>>2]|0;g=g-f|0;d=d+8|0;b=b+-1|0}k[d>>2]=(k[d>>2]|0)+g;k[d+4>>2]=h-g}if((e|0)==6){m=k[j>>2]|0;k[a+16>>2]=m+(k[a+48>>2]|0);a=m;k[n>>2]=a;k[o>>2]=a}else if((e|0)==8){k[a+16>>2]=0;k[n>>2]=0;k[o>>2]=0;k[a>>2]=k[a>>2]|32;if((b|0)==2)c=0;else c=c-(k[d+4>>2]|0)|0}r=p;return c|0}function Kc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=r;r=r+80|0;d=e;k[a+36>>2]=3;if((k[a>>2]&64|0)==0?(k[d>>2]=k[a+60>>2],k[d+4>>2]=21505,k[d+8>>2]=e+12,(wa(54,d|0)|0)!=0):0)i[a+75>>0]=-1;d=Jc(a,b,c)|0;r=e;return d|0}function Lc(a){a=a|0;var b=0,c=0;b=a+74|0;c=i[b>>0]|0;i[b>>0]=c+255|c;b=k[a>>2]|0;if(!(b&8)){k[a+8>>2]=0;k[a+4>>2]=0;b=k[a+44>>2]|0;k[a+28>>2]=b;k[a+20>>2]=b;k[a+16>>2]=b+(k[a+48>>2]|0);b=0}else{k[a>>2]=b|32;b=-1}return b|0}function Mc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;f=b&255;d=(c|0)!=0;a:do if(d&(a&3|0)!=0){e=b&255;while(1){if((i[a>>0]|0)==e<<24>>24){g=6;break a}a=a+1|0;c=c+-1|0;d=(c|0)!=0;if(!(d&(a&3|0)!=0)){g=5;break}}}else g=5;while(0);if((g|0)==5)if(d)g=6;else c=0;b:do if((g|0)==6){e=b&255;if((i[a>>0]|0)!=e<<24>>24){d=ha(f,16843009)|0;c:do if(c>>>0>3)while(1){f=k[a>>2]^d;if((f&-2139062144^-2139062144)&f+-16843009)break;a=a+4|0;c=c+-4|0;if(c>>>0<=3){g=11;break c}}else g=11;while(0);if((g|0)==11)if(!c){c=0;break}while(1){if((i[a>>0]|0)==e<<24>>24)break b;a=a+1|0;c=c+-1|0;if(!c){c=0;break}}}}while(0);return ((c|0)!=0?a:0)|0}function Nc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;b=a+20|0;f=a+28|0;if((k[b>>2]|0)>>>0>(k[f>>2]|0)>>>0?(Ua[k[a+36>>2]&7](a,0,0)|0,(k[b>>2]|0)==0):0)b=-1;else{g=a+4|0;c=k[g>>2]|0;d=a+8|0;e=k[d>>2]|0;if(c>>>0>>0)Ua[k[a+40>>2]&7](a,c-e|0,1)|0;k[a+16>>2]=0;k[f>>2]=0;k[b>>2]=0;k[d>>2]=0;k[g>>2]=0;b=0}return b|0}function Oc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,m=0,n=0.0,o=0,q=0,s=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0;ga=r;r=r+624|0;ba=ga+24|0;da=ga+16|0;ca=ga+588|0;Y=ga+576|0;aa=ga;V=ga+536|0;fa=ga+8|0;ea=ga+528|0;M=(a|0)!=0;N=V+40|0;U=N;V=V+39|0;W=fa+4|0;X=Y+12|0;Y=Y+11|0;Z=ca;_=X;$=_-Z|0;O=-2-Z|0;P=_+2|0;Q=ba+288|0;R=ca+9|0;S=R;T=ca+8|0;f=0;w=b;g=0;b=0;a:while(1){do if((f|0)>-1)if((g|0)>(2147483647-f|0)){f=qc()|0;k[f>>2]=75;f=-1;break}else{f=g+f|0;break}while(0);g=i[w>>0]|0;if(!(g<<24>>24)){K=245;break}else h=w;b:while(1){switch(g<<24>>24){case 37:{g=h;K=9;break b}case 0:{g=h;break b}default:{}}J=h+1|0;g=i[J>>0]|0;h=J}c:do if((K|0)==9)while(1){K=0;if((i[g+1>>0]|0)!=37)break c;h=h+1|0;g=g+2|0;if((i[g>>0]|0)==37)K=9;else break}while(0);y=h-w|0;if(M?(k[a>>2]&32|0)==0:0)yc(w,y,a)|0;if((h|0)!=(w|0)){w=g;g=y;continue}o=g+1|0;h=i[o>>0]|0;m=(h<<24>>24)+-48|0;if(m>>>0<10){J=(i[g+2>>0]|0)==36;o=J?g+3|0:o;h=i[o>>0]|0;u=J?m:-1;b=J?1:b}else u=-1;g=h<<24>>24;d:do if((g&-32|0)==32){m=0;while(1){if(!(1<>24)+-32|m;o=o+1|0;h=i[o>>0]|0;g=h<<24>>24;if((g&-32|0)!=32){q=m;g=o;break}}}else{q=0;g=o}while(0);do if(h<<24>>24==42){m=g+1|0;h=(i[m>>0]|0)+-48|0;if(h>>>0<10?(i[g+2>>0]|0)==36:0){k[e+(h<<2)>>2]=10;b=1;g=g+3|0;h=k[d+((i[m>>0]|0)+-48<<3)>>2]|0}else{if(b){f=-1;break a}if(!M){x=q;g=m;b=0;J=0;break}b=(k[c>>2]|0)+(4-1)&~(4-1);h=k[b>>2]|0;k[c>>2]=b+4;b=0;g=m}if((h|0)<0){x=q|8192;J=0-h|0}else{x=q;J=h}}else{m=(h<<24>>24)+-48|0;if(m>>>0<10){h=0;do{h=(h*10|0)+m|0;g=g+1|0;m=(i[g>>0]|0)+-48|0}while(m>>>0<10);if((h|0)<0){f=-1;break a}else{x=q;J=h}}else{x=q;J=0}}while(0);e:do if((i[g>>0]|0)==46){m=g+1|0;h=i[m>>0]|0;if(h<<24>>24!=42){o=(h<<24>>24)+-48|0;if(o>>>0<10){g=m;h=0}else{g=m;o=0;break}while(1){h=(h*10|0)+o|0;g=g+1|0;o=(i[g>>0]|0)+-48|0;if(o>>>0>=10){o=h;break e}}}m=g+2|0;h=(i[m>>0]|0)+-48|0;if(h>>>0<10?(i[g+3>>0]|0)==36:0){k[e+(h<<2)>>2]=10;g=g+4|0;o=k[d+((i[m>>0]|0)+-48<<3)>>2]|0;break}if(b){f=-1;break a}if(M){g=(k[c>>2]|0)+(4-1)&~(4-1);o=k[g>>2]|0;k[c>>2]=g+4;g=m}else{g=m;o=0}}else o=-1;while(0);s=0;while(1){h=(i[g>>0]|0)+-65|0;if(h>>>0>57){f=-1;break a}m=g+1|0;h=i[5359+(s*58|0)+h>>0]|0;q=h&255;if((q+-1|0)>>>0<8){g=m;s=q}else{I=m;break}}if(!(h<<24>>24)){f=-1;break}m=(u|0)>-1;do if(h<<24>>24==19)if(m){f=-1;break a}else K=52;else{if(m){k[e+(u<<2)>>2]=q;G=d+(u<<3)|0;H=k[G+4>>2]|0;K=aa;k[K>>2]=k[G>>2];k[K+4>>2]=H;K=52;break}if(!M){f=0;break a}Rc(aa,q,c)}while(0);if((K|0)==52?(K=0,!M):0){w=I;g=y;continue}u=i[g>>0]|0;u=(s|0)!=0&(u&15|0)==3?u&-33:u;m=x&-65537;H=(x&8192|0)==0?x:m;f:do switch(u|0){case 110:switch(s|0){case 0:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 1:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 2:{w=k[aa>>2]|0;k[w>>2]=f;k[w+4>>2]=((f|0)<0)<<31>>31;w=I;g=y;continue a}case 3:{j[k[aa>>2]>>1]=f;w=I;g=y;continue a}case 4:{i[k[aa>>2]>>0]=f;w=I;g=y;continue a}case 6:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 7:{w=k[aa>>2]|0;k[w>>2]=f;k[w+4>>2]=((f|0)<0)<<31>>31;w=I;g=y;continue a}default:{w=I;g=y;continue a}}case 112:{s=H|8;o=o>>>0>8?o:8;u=120;K=64;break}case 88:case 120:{s=H;K=64;break}case 111:{m=aa;h=k[m>>2]|0;m=k[m+4>>2]|0;if((h|0)==0&(m|0)==0)g=N;else{g=N;do{g=g+-1|0;i[g>>0]=h&7|48;h=bd(h|0,m|0,3)|0;m=L}while(!((h|0)==0&(m|0)==0))}if(!(H&8)){h=H;s=0;q=5839;K=77}else{s=U-g+1|0;h=H;o=(o|0)<(s|0)?s:o;s=0;q=5839;K=77}break}case 105:case 100:{h=aa;g=k[h>>2]|0;h=k[h+4>>2]|0;if((h|0)<0){g=$c(0,0,g|0,h|0)|0;h=L;m=aa;k[m>>2]=g;k[m+4>>2]=h;m=1;q=5839;K=76;break f}if(!(H&2048)){q=H&1;m=q;q=(q|0)==0?5839:5841;K=76}else{m=1;q=5840;K=76}break}case 117:{h=aa;g=k[h>>2]|0;h=k[h+4>>2]|0;m=0;q=5839;K=76;break}case 99:{i[V>>0]=k[aa>>2];w=V;h=1;s=0;u=5839;g=N;break}case 109:{g=qc()|0;g=pc(k[g>>2]|0)|0;K=82;break}case 115:{g=k[aa>>2]|0;g=(g|0)!=0?g:5849;K=82;break}case 67:{k[fa>>2]=k[aa>>2];k[W>>2]=0;k[aa>>2]=fa;o=-1;K=86;break}case 83:{if(!o){Tc(a,32,J,0,H);g=0;K=98}else K=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{n=+p[aa>>3];k[da>>2]=0;p[t>>3]=n;if((k[t+4>>2]|0)>=0)if(!(H&2048)){G=H&1;F=G;G=(G|0)==0?5857:5862}else{F=1;G=5859}else{n=-n;F=1;G=5856}p[t>>3]=n;E=k[t+4>>2]&2146435072;do if(E>>>0<2146435072|(E|0)==2146435072&0<0){v=+tc(n,da)*2.0;h=v!=0.0;if(h)k[da>>2]=(k[da>>2]|0)+-1;C=u|32;if((C|0)==97){w=u&32;y=(w|0)==0?G:G+9|0;x=F|2;g=12-o|0;do if(!(o>>>0>11|(g|0)==0)){n=8.0;do{g=g+-1|0;n=n*16.0}while((g|0)!=0);if((i[y>>0]|0)==45){n=-(n+(-v-n));break}else{n=v+n-n;break}}else n=v;while(0);h=k[da>>2]|0;g=(h|0)<0?0-h|0:h;g=Sc(g,((g|0)<0)<<31>>31,X)|0;if((g|0)==(X|0)){i[Y>>0]=48;g=Y}i[g+-1>>0]=(h>>31&2)+43;s=g+-2|0;i[s>>0]=u+15;q=(o|0)<1;m=(H&8|0)==0;h=ca;while(1){G=~~n;g=h+1|0;i[h>>0]=l[5823+G>>0]|w;n=(n-+(G|0))*16.0;do if((g-Z|0)==1){if(m&(q&n==0.0))break;i[g>>0]=46;g=h+2|0}while(0);if(!(n!=0.0))break;else h=g}o=(o|0)!=0&(O+g|0)<(o|0)?P+o-s|0:$-s+g|0;m=o+x|0;Tc(a,32,J,m,H);if(!(k[a>>2]&32))yc(y,x,a)|0;Tc(a,48,J,m,H^65536);g=g-Z|0;if(!(k[a>>2]&32))yc(ca,g,a)|0;h=_-s|0;Tc(a,48,o-(g+h)|0,0,0);if(!(k[a>>2]&32))yc(s,h,a)|0;Tc(a,32,J,m,H^8192);g=(m|0)<(J|0)?J:m;break}g=(o|0)<0?6:o;if(h){h=(k[da>>2]|0)+-28|0;k[da>>2]=h;n=v*268435456.0}else{n=v;h=k[da>>2]|0}E=(h|0)<0?ba:Q;D=E;h=E;do{B=~~n>>>0;k[h>>2]=B;h=h+4|0;n=(n-+(B>>>0))*1.0e9}while(n!=0.0);m=h;h=k[da>>2]|0;if((h|0)>0){q=E;while(1){s=(h|0)>29?29:h;o=m+-4|0;do if(o>>>0>>0)o=q;else{h=0;do{B=cd(k[o>>2]|0,0,s|0)|0;B=dd(B|0,L|0,h|0,0)|0;h=L;A=md(B|0,h|0,1e9,0)|0;k[o>>2]=A;h=ld(B|0,h|0,1e9,0)|0;o=o+-4|0}while(o>>>0>=q>>>0);if(!h){o=q;break}o=q+-4|0;k[o>>2]=h}while(0);while(1){if(m>>>0<=o>>>0)break;h=m+-4|0;if(!(k[h>>2]|0))m=h;else break}h=(k[da>>2]|0)-s|0;k[da>>2]=h;if((h|0)>0)q=o;else break}}else o=E;if((h|0)<0){y=((g+25|0)/9|0)+1|0;z=(C|0)==102;w=o;while(1){x=0-h|0;x=(x|0)>9?9:x;do if(w>>>0>>0){h=(1<>>x;o=0;s=w;do{B=k[s>>2]|0;k[s>>2]=(B>>>x)+o;o=ha(B&h,q)|0;s=s+4|0}while(s>>>0>>0);h=(k[w>>2]|0)==0?w+4|0:w;if(!o){o=h;break}k[m>>2]=o;o=h;m=m+4|0}else o=(k[w>>2]|0)==0?w+4|0:w;while(0);h=z?E:o;m=(m-h>>2|0)>(y|0)?h+(y<<2)|0:m;h=(k[da>>2]|0)+x|0;k[da>>2]=h;if((h|0)>=0){w=o;break}else w=o}}else w=o;do if(w>>>0>>0){h=(D-w>>2)*9|0;q=k[w>>2]|0;if(q>>>0<10)break;else o=10;do{o=o*10|0;h=h+1|0}while(q>>>0>=o>>>0)}else h=0;while(0);A=(C|0)==103;B=(g|0)!=0;o=g-((C|0)!=102?h:0)+((B&A)<<31>>31)|0;if((o|0)<(((m-D>>2)*9|0)+-9|0)){s=o+9216|0;z=(s|0)/9|0;o=E+(z+-1023<<2)|0;s=((s|0)%9|0)+1|0;if((s|0)<9){q=10;do{q=q*10|0;s=s+1|0}while((s|0)!=9)}else q=10;x=k[o>>2]|0;y=(x>>>0)%(q>>>0)|0;if((y|0)==0?(E+(z+-1022<<2)|0)==(m|0):0)q=w;else K=163;do if((K|0)==163){K=0;v=(((x>>>0)/(q>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;s=(q|0)/2|0;do if(y>>>0>>0)n=.5;else{if((y|0)==(s|0)?(E+(z+-1022<<2)|0)==(m|0):0){n=1.0;break}n=1.5}while(0);do if(F){if((i[G>>0]|0)!=45)break;v=-v;n=-n}while(0);s=x-y|0;k[o>>2]=s;if(!(v+n!=v)){q=w;break}C=s+q|0;k[o>>2]=C;if(C>>>0>999999999){h=w;while(1){q=o+-4|0;k[o>>2]=0;if(q>>>0>>0){h=h+-4|0;k[h>>2]=0}C=(k[q>>2]|0)+1|0;k[q>>2]=C;if(C>>>0>999999999)o=q;else{w=h;o=q;break}}}h=(D-w>>2)*9|0;s=k[w>>2]|0;if(s>>>0<10){q=w;break}else q=10;do{q=q*10|0;h=h+1|0}while(s>>>0>=q>>>0);q=w}while(0);C=o+4|0;w=q;m=m>>>0>C>>>0?C:m}y=0-h|0;while(1){if(m>>>0<=w>>>0){z=0;C=m;break}o=m+-4|0;if(!(k[o>>2]|0))m=o;else{z=1;C=m;break}}do if(A){g=(B&1^1)+g|0;if((g|0)>(h|0)&(h|0)>-5){u=u+-1|0;g=g+-1-h|0}else{u=u+-2|0;g=g+-1|0}m=H&8;if(m)break;do if(z){m=k[C+-4>>2]|0;if(!m){o=9;break}if(!((m>>>0)%10|0)){q=10;o=0}else{o=0;break}do{q=q*10|0;o=o+1|0}while(((m>>>0)%(q>>>0)|0|0)==0)}else o=9;while(0);m=((C-D>>2)*9|0)+-9|0;if((u|32|0)==102){m=m-o|0;m=(m|0)<0?0:m;g=(g|0)<(m|0)?g:m;m=0;break}else{m=m+h-o|0;m=(m|0)<0?0:m;g=(g|0)<(m|0)?g:m;m=0;break}}else m=H&8;while(0);x=g|m;q=(x|0)!=0&1;s=(u|32|0)==102;if(s){h=(h|0)>0?h:0;u=0}else{o=(h|0)<0?y:h;o=Sc(o,((o|0)<0)<<31>>31,X)|0;if((_-o|0)<2)do{o=o+-1|0;i[o>>0]=48}while((_-o|0)<2);i[o+-1>>0]=(h>>31&2)+43;D=o+-2|0;i[D>>0]=u;h=_-D|0;u=D}y=F+1+g+q+h|0;Tc(a,32,J,y,H);if(!(k[a>>2]&32))yc(G,F,a)|0;Tc(a,48,J,y,H^65536);do if(s){o=w>>>0>E>>>0?E:w;h=o;do{m=Sc(k[h>>2]|0,0,R)|0;do if((h|0)==(o|0)){if((m|0)!=(R|0))break;i[T>>0]=48;m=T}else{if(m>>>0<=ca>>>0)break;do{m=m+-1|0;i[m>>0]=48}while(m>>>0>ca>>>0)}while(0);if(!(k[a>>2]&32))yc(m,S-m|0,a)|0;h=h+4|0}while(h>>>0<=E>>>0);do if(x){if(k[a>>2]&32)break;yc(5891,1,a)|0}while(0);if((g|0)>0&h>>>0>>0){m=h;while(1){h=Sc(k[m>>2]|0,0,R)|0;if(h>>>0>ca>>>0)do{h=h+-1|0;i[h>>0]=48}while(h>>>0>ca>>>0);if(!(k[a>>2]&32))yc(h,(g|0)>9?9:g,a)|0;m=m+4|0;h=g+-9|0;if(!((g|0)>9&m>>>0>>0)){g=h;break}else g=h}}Tc(a,48,g+9|0,9,0)}else{s=z?C:w+4|0;if((g|0)>-1){q=(m|0)==0;o=w;do{h=Sc(k[o>>2]|0,0,R)|0;if((h|0)==(R|0)){i[T>>0]=48;h=T}do if((o|0)==(w|0)){m=h+1|0;if(!(k[a>>2]&32))yc(h,1,a)|0;if(q&(g|0)<1){h=m;break}if(k[a>>2]&32){h=m;break}yc(5891,1,a)|0;h=m}else{if(h>>>0<=ca>>>0)break;do{h=h+-1|0;i[h>>0]=48}while(h>>>0>ca>>>0)}while(0);m=S-h|0;if(!(k[a>>2]&32))yc(h,(g|0)>(m|0)?m:g,a)|0;g=g-m|0;o=o+4|0}while(o>>>0>>0&(g|0)>-1)}Tc(a,48,g+18|0,18,0);if(k[a>>2]&32)break;yc(u,_-u|0,a)|0}while(0);Tc(a,32,J,y,H^8192);g=(y|0)<(J|0)?J:y}else{s=(u&32|0)!=0;q=n!=n|0.0!=0.0;h=q?0:F;o=h+3|0;Tc(a,32,J,o,m);g=k[a>>2]|0;if(!(g&32)){yc(G,h,a)|0;g=k[a>>2]|0}if(!(g&32))yc(q?(s?5883:5887):s?5875:5879,3,a)|0;Tc(a,32,J,o,H^8192);g=(o|0)<(J|0)?J:o}while(0);w=I;continue a}default:{m=H;h=o;s=0;u=5839;g=N}}while(0);g:do if((K|0)==64){m=aa;h=k[m>>2]|0;m=k[m+4>>2]|0;q=u&32;if(!((h|0)==0&(m|0)==0)){g=N;do{g=g+-1|0;i[g>>0]=l[5823+(h&15)>>0]|q;h=bd(h|0,m|0,4)|0;m=L}while(!((h|0)==0&(m|0)==0));K=aa;if((s&8|0)==0|(k[K>>2]|0)==0&(k[K+4>>2]|0)==0){h=s;s=0;q=5839;K=77}else{h=s;s=2;q=5839+(u>>4)|0;K=77}}else{g=N;h=s;s=0;q=5839;K=77}}else if((K|0)==76){g=Sc(g,h,N)|0;h=H;s=m;K=77}else if((K|0)==82){K=0;H=Mc(g,0,o)|0;G=(H|0)==0;w=g;h=G?o:H-g|0;s=0;u=5839;g=G?g+o|0:H}else if((K|0)==86){K=0;h=0;g=0;q=k[aa>>2]|0;while(1){m=k[q>>2]|0;if(!m)break;g=vc(ea,m)|0;if((g|0)<0|g>>>0>(o-h|0)>>>0)break;h=g+h|0;if(o>>>0>h>>>0)q=q+4|0;else break}if((g|0)<0){f=-1;break a}Tc(a,32,J,h,H);if(!h){g=0;K=98}else{m=0;o=k[aa>>2]|0;while(1){g=k[o>>2]|0;if(!g){g=h;K=98;break g}g=vc(ea,g)|0;m=g+m|0;if((m|0)>(h|0)){g=h;K=98;break g}if(!(k[a>>2]&32))yc(ea,g,a)|0;if(m>>>0>=h>>>0){g=h;K=98;break}else o=o+4|0}}}while(0);if((K|0)==98){K=0;Tc(a,32,J,g,H^8192);w=I;g=(J|0)>(g|0)?J:g;continue}if((K|0)==77){K=0;m=(o|0)>-1?h&-65537:h;h=aa;h=(k[h>>2]|0)!=0|(k[h+4>>2]|0)!=0;if((o|0)!=0|h){h=(h&1^1)+(U-g)|0;w=g;h=(o|0)>(h|0)?o:h;u=q;g=N}else{w=N;h=0;u=q;g=N}}q=g-w|0;h=(h|0)<(q|0)?q:h;o=s+h|0;g=(J|0)<(o|0)?o:J;Tc(a,32,g,o,m);if(!(k[a>>2]&32))yc(u,s,a)|0;Tc(a,48,g,o,m^65536);Tc(a,48,h,q,0);if(!(k[a>>2]&32))yc(w,q,a)|0;Tc(a,32,g,o,m^8192);w=I}h:do if((K|0)==245)if(!a)if(b){f=1;while(1){b=k[e+(f<<2)>>2]|0;if(!b)break;Rc(d+(f<<3)|0,b,c);f=f+1|0;if((f|0)>=10){f=1;break h}}if((f|0)<10)while(1){if(k[e+(f<<2)>>2]|0){f=-1;break h}f=f+1|0;if((f|0)>=10){f=1;break}}else f=1}else f=0;while(0);r=ga;return f|0}function Pc(a){a=a|0;if(!(k[a+68>>2]|0))Fc(a);return}function Qc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=a+20|0;e=k[d>>2]|0;a=(k[a+16>>2]|0)-e|0;a=a>>>0>c>>>0?c:a;ed(e|0,b|0,a|0)|0;k[d>>2]=(k[d>>2]|0)+a;return c|0}function Rc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;k[a>>2]=b;break a}case 10:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;d=a;k[d>>2]=b;k[d+4>>2]=((b|0)<0)<<31>>31;break a}case 11:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;d=a;k[d>>2]=b;k[d+4>>2]=0;break a}case 12:{d=(k[c>>2]|0)+(8-1)&~(8-1);b=d;e=k[b>>2]|0;b=k[b+4>>2]|0;k[c>>2]=d+8;d=a;k[d>>2]=e;k[d+4>>2]=b;break a}case 13:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;d=(d&65535)<<16>>16;e=a;k[e>>2]=d;k[e+4>>2]=((d|0)<0)<<31>>31;break a}case 14:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;e=a;k[e>>2]=d&65535;k[e+4>>2]=0;break a}case 15:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;d=(d&255)<<24>>24;e=a;k[e>>2]=d;k[e+4>>2]=((d|0)<0)<<31>>31;break a}case 16:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;e=a;k[e>>2]=d&255;k[e+4>>2]=0;break a}case 17:{e=(k[c>>2]|0)+(8-1)&~(8-1);f=+p[e>>3];k[c>>2]=e+8;p[a>>3]=f;break a}case 18:{e=(k[c>>2]|0)+(8-1)&~(8-1);f=+p[e>>3];k[c>>2]=e+8;p[a>>3]=f;break a}default:break a}while(0);while(0);return}function Sc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(b>>>0>0|(b|0)==0&a>>>0>4294967295)while(1){d=md(a|0,b|0,10,0)|0;c=c+-1|0;i[c>>0]=d|48;d=ld(a|0,b|0,10,0)|0;if(b>>>0>9|(b|0)==9&a>>>0>4294967295){a=d;b=L}else{a=d;break}}if(a)while(1){c=c+-1|0;i[c>>0]=(a>>>0)%10|0|48;if(a>>>0<10)break;else a=(a>>>0)/10|0}return c|0}function Tc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=r;r=r+256|0;g=h;do if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;ad(g|0,b|0,(e>>>0>256?256:e)|0)|0;b=k[a>>2]|0;f=(b&32|0)==0;if(e>>>0>255){d=c-d|0;do{if(f){yc(g,256,a)|0;b=k[a>>2]|0}e=e+-256|0;f=(b&32|0)==0}while(e>>>0>255);if(f)e=d&255;else break}else if(!f)break;yc(g,e,a)|0}while(0);r=h;return}function Uc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;do if(a>>>0<245){o=a>>>0<11?16:a+11&-8;a=o>>>3;h=k[151]|0;c=h>>>a;if(c&3){a=(c&1^1)+a|0;d=a<<1;c=644+(d<<2)|0;d=644+(d+2<<2)|0;e=k[d>>2]|0;f=e+8|0;g=k[f>>2]|0;do if((c|0)!=(g|0)){if(g>>>0<(k[155]|0)>>>0)Na();b=g+12|0;if((k[b>>2]|0)==(e|0)){k[b>>2]=c;k[d>>2]=g;break}else Na()}else k[151]=h&~(1<>2]=M|3;M=e+(M|4)|0;k[M>>2]=k[M>>2]|1;M=f;return M|0}g=k[153]|0;if(o>>>0>g>>>0){if(c){d=2<>>12&16;d=d>>>i;e=d>>>5&8;d=d>>>e;f=d>>>2&4;d=d>>>f;c=d>>>1&2;d=d>>>c;a=d>>>1&1;a=(e|i|f|c|a)+(d>>>a)|0;d=a<<1;c=644+(d<<2)|0;d=644+(d+2<<2)|0;f=k[d>>2]|0;i=f+8|0;e=k[i>>2]|0;do if((c|0)!=(e|0)){if(e>>>0<(k[155]|0)>>>0)Na();b=e+12|0;if((k[b>>2]|0)==(f|0)){k[b>>2]=c;k[d>>2]=e;j=k[153]|0;break}else Na()}else{k[151]=h&~(1<>2]=o|3;h=f+o|0;k[f+(o|4)>>2]=g|1;k[f+M>>2]=g;if(j){e=k[156]|0;c=j>>>3;b=c<<1;d=644+(b<<2)|0;a=k[151]|0;c=1<>2]|0;if(b>>>0<(k[155]|0)>>>0)Na();else{l=a;m=b}}else{k[151]=a|c;l=644+(b+2<<2)|0;m=d}k[l>>2]=e;k[m+12>>2]=e;k[e+8>>2]=m;k[e+12>>2]=d}k[153]=g;k[156]=h;M=i;return M|0}a=k[152]|0;if(a){c=(a&0-a)+-1|0;L=c>>>12&16;c=c>>>L;K=c>>>5&8;c=c>>>K;M=c>>>2&4;c=c>>>M;a=c>>>1&2;c=c>>>a;d=c>>>1&1;d=k[908+((K|L|M|a|d)+(c>>>d)<<2)>>2]|0;c=(k[d+4>>2]&-8)-o|0;a=d;while(1){b=k[a+16>>2]|0;if(!b){b=k[a+20>>2]|0;if(!b){i=c;break}}a=(k[b+4>>2]&-8)-o|0;M=a>>>0>>0;c=M?a:c;a=b;d=M?b:d}f=k[155]|0;if(d>>>0>>0)Na();h=d+o|0;if(d>>>0>=h>>>0)Na();g=k[d+24>>2]|0;c=k[d+12>>2]|0;do if((c|0)==(d|0)){a=d+20|0;b=k[a>>2]|0;if(!b){a=d+16|0;b=k[a>>2]|0;if(!b){n=0;break}}while(1){c=b+20|0;e=k[c>>2]|0;if(e){b=e;a=c;continue}c=b+16|0;e=k[c>>2]|0;if(!e)break;else{b=e;a=c}}if(a>>>0>>0)Na();else{k[a>>2]=0;n=b;break}}else{e=k[d+8>>2]|0;if(e>>>0>>0)Na();b=e+12|0;if((k[b>>2]|0)!=(d|0))Na();a=c+8|0;if((k[a>>2]|0)==(d|0)){k[b>>2]=c;k[a>>2]=e;n=c;break}else Na()}while(0);do if(g){b=k[d+28>>2]|0;a=908+(b<<2)|0;if((d|0)==(k[a>>2]|0)){k[a>>2]=n;if(!n){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(d|0))k[b>>2]=n;else k[g+20>>2]=n;if(!n)break}a=k[155]|0;if(n>>>0>>0)Na();k[n+24>>2]=g;b=k[d+16>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[n+16>>2]=b;k[b+24>>2]=n;break}while(0);b=k[d+20>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[n+20>>2]=b;k[b+24>>2]=n;break}}while(0);if(i>>>0<16){M=i+o|0;k[d+4>>2]=M|3;M=d+(M+4)|0;k[M>>2]=k[M>>2]|1}else{k[d+4>>2]=o|3;k[d+(o|4)>>2]=i|1;k[d+(i+o)>>2]=i;b=k[153]|0;if(b){f=k[156]|0;c=b>>>3;b=c<<1;e=644+(b<<2)|0;a=k[151]|0;c=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{p=b;q=a}}else{k[151]=a|c;p=644+(b+2<<2)|0;q=e}k[p>>2]=f;k[q+12>>2]=f;k[f+8>>2]=q;k[f+12>>2]=e}k[153]=i;k[156]=h}M=d+8|0;return M|0}else q=o}else q=o}else if(a>>>0<=4294967231){a=a+11|0;m=a&-8;l=k[152]|0;if(l){c=0-m|0;a=a>>>8;if(a)if(m>>>0>16777215)j=31;else{q=(a+1048320|0)>>>16&8;v=a<>>16&4;v=v<>>16&2;j=14-(p|q|j)+(v<>>15)|0;j=m>>>(j+7|0)&1|j<<1}else j=0;a=k[908+(j<<2)>>2]|0;a:do if(!a){e=0;a=0;v=86}else{g=c;e=0;h=m<<((j|0)==31?0:25-(j>>>1)|0);i=a;a=0;while(1){f=k[i+4>>2]&-8;c=f-m|0;if(c>>>0>>0)if((f|0)==(m|0)){f=i;a=i;v=90;break a}else a=i;else c=g;v=k[i+20>>2]|0;i=k[i+16+(h>>>31<<2)>>2]|0;e=(v|0)==0|(v|0)==(i|0)?e:v;if(!i){v=86;break}else{g=c;h=h<<1}}}while(0);if((v|0)==86){if((e|0)==0&(a|0)==0){a=2<>>12&16;a=a>>>n;l=a>>>5&8;a=a>>>l;p=a>>>2&4;a=a>>>p;q=a>>>1&2;a=a>>>q;e=a>>>1&1;e=k[908+((l|n|p|q|e)+(a>>>e)<<2)>>2]|0;a=0}if(!e){h=c;i=a}else{f=e;v=90}}if((v|0)==90)while(1){v=0;q=(k[f+4>>2]&-8)-m|0;e=q>>>0>>0;c=e?q:c;a=e?f:a;e=k[f+16>>2]|0;if(e){f=e;v=90;continue}f=k[f+20>>2]|0;if(!f){h=c;i=a;break}else v=90}if((i|0)!=0?h>>>0<((k[153]|0)-m|0)>>>0:0){e=k[155]|0;if(i>>>0>>0)Na();g=i+m|0;if(i>>>0>=g>>>0)Na();f=k[i+24>>2]|0;c=k[i+12>>2]|0;do if((c|0)==(i|0)){a=i+20|0;b=k[a>>2]|0;if(!b){a=i+16|0;b=k[a>>2]|0;if(!b){o=0;break}}while(1){c=b+20|0;d=k[c>>2]|0;if(d){b=d;a=c;continue}c=b+16|0;d=k[c>>2]|0;if(!d)break;else{b=d;a=c}}if(a>>>0>>0)Na();else{k[a>>2]=0;o=b;break}}else{d=k[i+8>>2]|0;if(d>>>0>>0)Na();b=d+12|0;if((k[b>>2]|0)!=(i|0))Na();a=c+8|0;if((k[a>>2]|0)==(i|0)){k[b>>2]=c;k[a>>2]=d;o=c;break}else Na()}while(0);do if(f){b=k[i+28>>2]|0;a=908+(b<<2)|0;if((i|0)==(k[a>>2]|0)){k[a>>2]=o;if(!o){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=f+16|0;if((k[b>>2]|0)==(i|0))k[b>>2]=o;else k[f+20>>2]=o;if(!o)break}a=k[155]|0;if(o>>>0>>0)Na();k[o+24>>2]=f;b=k[i+16>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[o+16>>2]=b;k[b+24>>2]=o;break}while(0);b=k[i+20>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[o+20>>2]=b;k[b+24>>2]=o;break}}while(0);b:do if(h>>>0>=16){k[i+4>>2]=m|3;k[i+(m|4)>>2]=h|1;k[i+(h+m)>>2]=h;b=h>>>3;if(h>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{s=b;t=a}}else{k[151]=c|b;s=644+(a+2<<2)|0;t=d}k[s>>2]=g;k[t+12>>2]=g;k[i+(m+8)>>2]=t;k[i+(m+12)>>2]=d;break}b=h>>>8;if(b)if(h>>>0>16777215)d=31;else{L=(b+1048320|0)>>>16&8;M=b<>>16&4;M=M<>>16&2;d=14-(K|L|d)+(M<>>15)|0;d=h>>>(d+7|0)&1|d<<1}else d=0;b=908+(d<<2)|0;k[i+(m+28)>>2]=d;k[i+(m+20)>>2]=0;k[i+(m+16)>>2]=0;a=k[152]|0;c=1<>2]=g;k[i+(m+24)>>2]=b;k[i+(m+12)>>2]=g;k[i+(m+8)>>2]=g;break}b=k[b>>2]|0;c:do if((k[b+4>>2]&-8|0)!=(h|0)){d=h<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(h|0)){y=c;break c}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=g;k[i+(m+24)>>2]=b;k[i+(m+12)>>2]=g;k[i+(m+8)>>2]=g;break b}}else y=b;while(0);b=y+8|0;a=k[b>>2]|0;M=k[155]|0;if(a>>>0>=M>>>0&y>>>0>=M>>>0){k[a+12>>2]=g;k[b>>2]=g;k[i+(m+8)>>2]=a;k[i+(m+12)>>2]=y;k[i+(m+24)>>2]=0;break}else Na()}else{M=h+m|0;k[i+4>>2]=M|3;M=i+(M+4)|0;k[M>>2]=k[M>>2]|1}while(0);M=i+8|0;return M|0}else q=m}else q=m}else q=-1;while(0);c=k[153]|0;if(c>>>0>=q>>>0){b=c-q|0;a=k[156]|0;if(b>>>0>15){k[156]=a+q;k[153]=b;k[a+(q+4)>>2]=b|1;k[a+c>>2]=b;k[a+4>>2]=q|3}else{k[153]=0;k[156]=0;k[a+4>>2]=c|3;M=a+(c+4)|0;k[M>>2]=k[M>>2]|1}M=a+8|0;return M|0}a=k[154]|0;if(a>>>0>q>>>0){L=a-q|0;k[154]=L;M=k[157]|0;k[157]=M+q;k[M+(q+4)>>2]=L|1;k[M+4>>2]=q|3;M=M+8|0;return M|0}do if(!(k[269]|0)){a=Ea(30)|0;if(!(a+-1&a)){k[271]=a;k[270]=a;k[272]=-1;k[273]=-1;k[274]=0;k[262]=0;y=(Pa(0)|0)&-16^1431655768;k[269]=y;break}else Na()}while(0);i=q+48|0;h=k[271]|0;j=q+47|0;g=h+j|0;h=0-h|0;l=g&h;if(l>>>0<=q>>>0){M=0;return M|0}a=k[261]|0;if((a|0)!=0?(t=k[259]|0,y=t+l|0,y>>>0<=t>>>0|y>>>0>a>>>0):0){M=0;return M|0}d:do if(!(k[262]&4)){a=k[157]|0;e:do if(a){e=1052;while(1){c=k[e>>2]|0;if(c>>>0<=a>>>0?(r=e+4|0,(c+(k[r>>2]|0)|0)>>>0>a>>>0):0){f=e;a=r;break}e=k[e+8>>2]|0;if(!e){v=174;break e}}c=g-(k[154]|0)&h;if(c>>>0<2147483647){e=Ba(c|0)|0;y=(e|0)==((k[f>>2]|0)+(k[a>>2]|0)|0);a=y?c:0;if(y){if((e|0)!=(-1|0)){w=e;p=a;v=194;break d}}else v=184}else a=0}else v=174;while(0);do if((v|0)==174){f=Ba(0)|0;if((f|0)!=(-1|0)){a=f;c=k[270]|0;e=c+-1|0;if(!(e&a))c=l;else c=l-a+(e+a&0-c)|0;a=k[259]|0;e=a+c|0;if(c>>>0>q>>>0&c>>>0<2147483647){y=k[261]|0;if((y|0)!=0?e>>>0<=a>>>0|e>>>0>y>>>0:0){a=0;break}e=Ba(c|0)|0;y=(e|0)==(f|0);a=y?c:0;if(y){w=f;p=a;v=194;break d}else v=184}else a=0}else a=0}while(0);f:do if((v|0)==184){f=0-c|0;do if(i>>>0>c>>>0&(c>>>0<2147483647&(e|0)!=(-1|0))?(u=k[271]|0,u=j-c+u&0-u,u>>>0<2147483647):0)if((Ba(u|0)|0)==(-1|0)){Ba(f|0)|0;break f}else{c=u+c|0;break}while(0);if((e|0)!=(-1|0)){w=e;p=c;v=194;break d}}while(0);k[262]=k[262]|4;v=191}else{a=0;v=191}while(0);if((((v|0)==191?l>>>0<2147483647:0)?(w=Ba(l|0)|0,x=Ba(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(z=x-w|0,A=z>>>0>(q+40|0)>>>0,A):0){p=A?z:a;v=194}if((v|0)==194){a=(k[259]|0)+p|0;k[259]=a;if(a>>>0>(k[260]|0)>>>0)k[260]=a;g=k[157]|0;g:do if(g){f=1052;do{a=k[f>>2]|0;c=f+4|0;e=k[c>>2]|0;if((w|0)==(a+e|0)){B=a;C=c;D=e;E=f;v=204;break}f=k[f+8>>2]|0}while((f|0)!=0);if(((v|0)==204?(k[E+12>>2]&8|0)==0:0)?g>>>0>>0&g>>>0>=B>>>0:0){k[C>>2]=D+p;M=(k[154]|0)+p|0;L=g+8|0;L=(L&7|0)==0?0:0-L&7;K=M-L|0;k[157]=g+L;k[154]=K;k[g+(L+4)>>2]=K|1;k[g+(M+4)>>2]=40;k[158]=k[273];break}a=k[155]|0;if(w>>>0>>0){k[155]=w;a=w}c=w+p|0;f=1052;while(1){if((k[f>>2]|0)==(c|0)){e=f;c=f;v=212;break}f=k[f+8>>2]|0;if(!f){c=1052;break}}if((v|0)==212)if(!(k[c+12>>2]&8)){k[e>>2]=w;n=c+4|0;k[n>>2]=(k[n>>2]|0)+p;n=w+8|0;n=(n&7|0)==0?0:0-n&7;j=w+(p+8)|0;j=(j&7|0)==0?0:0-j&7;b=w+(j+p)|0;m=n+q|0;o=w+m|0;l=b-(w+n)-q|0;k[w+(n+4)>>2]=q|3;h:do if((b|0)!=(g|0)){if((b|0)==(k[156]|0)){M=(k[153]|0)+l|0;k[153]=M;k[156]=o;k[w+(m+4)>>2]=M|1;k[w+(M+m)>>2]=M;break}h=p+4|0;c=k[w+(h+j)>>2]|0;if((c&3|0)==1){i=c&-8;f=c>>>3;i:do if(c>>>0>=256){g=k[w+((j|24)+p)>>2]|0;d=k[w+(p+12+j)>>2]|0;do if((d|0)==(b|0)){e=j|16;d=w+(h+e)|0;c=k[d>>2]|0;if(!c){d=w+(e+p)|0;c=k[d>>2]|0;if(!c){J=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;J=c;break}}else{e=k[w+((j|8)+p)>>2]|0;if(e>>>0>>0)Na();a=e+12|0;if((k[a>>2]|0)!=(b|0))Na();c=d+8|0;if((k[c>>2]|0)==(b|0)){k[a>>2]=d;k[c>>2]=e;J=d;break}else Na()}while(0);if(!g)break;a=k[w+(p+28+j)>>2]|0;c=908+(a<<2)|0;do if((b|0)!=(k[c>>2]|0)){if(g>>>0<(k[155]|0)>>>0)Na();a=g+16|0;if((k[a>>2]|0)==(b|0))k[a>>2]=J;else k[g+20>>2]=J;if(!J)break i}else{k[c>>2]=J;if(J)break;k[152]=k[152]&~(1<>>0>>0)Na();k[J+24>>2]=g;b=j|16;a=k[w+(b+p)>>2]|0;do if(a)if(a>>>0>>0)Na();else{k[J+16>>2]=a;k[a+24>>2]=J;break}while(0);b=k[w+(h+b)>>2]|0;if(!b)break;if(b>>>0<(k[155]|0)>>>0)Na();else{k[J+20>>2]=b;k[b+24>>2]=J;break}}else{d=k[w+((j|8)+p)>>2]|0;e=k[w+(p+12+j)>>2]|0;c=644+(f<<1<<2)|0;do if((d|0)!=(c|0)){if(d>>>0>>0)Na();if((k[d+12>>2]|0)==(b|0))break;Na()}while(0);if((e|0)==(d|0)){k[151]=k[151]&~(1<>>0>>0)Na();a=e+8|0;if((k[a>>2]|0)==(b|0)){F=a;break}Na()}while(0);k[d+12>>2]=e;k[F>>2]=d}while(0);b=w+((i|j)+p)|0;e=i+l|0}else e=l;b=b+4|0;k[b>>2]=k[b>>2]&-2;k[w+(m+4)>>2]=e|1;k[w+(e+m)>>2]=e;b=e>>>3;if(e>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0>=(k[155]|0)>>>0){K=b;L=a;break}Na()}while(0);k[K>>2]=o;k[L+12>>2]=o;k[w+(m+8)>>2]=L;k[w+(m+12)>>2]=d;break}b=e>>>8;do if(!b)d=0;else{if(e>>>0>16777215){d=31;break}K=(b+1048320|0)>>>16&8;L=b<>>16&4;L=L<>>16&2;d=14-(J|K|d)+(L<>>15)|0;d=e>>>(d+7|0)&1|d<<1}while(0);b=908+(d<<2)|0;k[w+(m+28)>>2]=d;k[w+(m+20)>>2]=0;k[w+(m+16)>>2]=0;a=k[152]|0;c=1<>2]=o;k[w+(m+24)>>2]=b;k[w+(m+12)>>2]=o;k[w+(m+8)>>2]=o;break}b=k[b>>2]|0;j:do if((k[b+4>>2]&-8|0)!=(e|0)){d=e<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(e|0)){M=c;break j}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=o;k[w+(m+24)>>2]=b;k[w+(m+12)>>2]=o;k[w+(m+8)>>2]=o;break h}}else M=b;while(0);b=M+8|0;a=k[b>>2]|0;L=k[155]|0;if(a>>>0>=L>>>0&M>>>0>=L>>>0){k[a+12>>2]=o;k[b>>2]=o;k[w+(m+8)>>2]=a;k[w+(m+12)>>2]=M;k[w+(m+24)>>2]=0;break}else Na()}else{M=(k[154]|0)+l|0;k[154]=M;k[157]=o;k[w+(m+4)>>2]=M|1}while(0);M=w+(n|8)|0;return M|0}else c=1052;while(1){a=k[c>>2]|0;if(a>>>0<=g>>>0?(b=k[c+4>>2]|0,d=a+b|0,d>>>0>g>>>0):0)break;c=k[c+8>>2]|0}e=a+(b+-39)|0;a=a+(b+-47+((e&7|0)==0?0:0-e&7))|0;e=g+16|0;a=a>>>0>>0?g:a;b=a+8|0;c=w+8|0;c=(c&7|0)==0?0:0-c&7;M=p+-40-c|0;k[157]=w+c;k[154]=M;k[w+(c+4)>>2]=M|1;k[w+(p+-36)>>2]=40;k[158]=k[273];c=a+4|0;k[c>>2]=27;k[b>>2]=k[263];k[b+4>>2]=k[264];k[b+8>>2]=k[265];k[b+12>>2]=k[266];k[263]=w;k[264]=p;k[266]=0;k[265]=b;b=a+28|0;k[b>>2]=7;if((a+32|0)>>>0>>0)do{M=b;b=b+4|0;k[b>>2]=7}while((M+8|0)>>>0>>0);if((a|0)!=(g|0)){f=a-g|0;k[c>>2]=k[c>>2]&-2;k[g+4>>2]=f|1;k[a>>2]=f;b=f>>>3;if(f>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{G=b;H=a}}else{k[151]=c|b;G=644+(a+2<<2)|0;H=d}k[G>>2]=g;k[H+12>>2]=g;k[g+8>>2]=H;k[g+12>>2]=d;break}b=f>>>8;if(b)if(f>>>0>16777215)d=31;else{L=(b+1048320|0)>>>16&8;M=b<>>16&4;M=M<>>16&2;d=14-(K|L|d)+(M<>>15)|0;d=f>>>(d+7|0)&1|d<<1}else d=0;c=908+(d<<2)|0;k[g+28>>2]=d;k[g+20>>2]=0;k[e>>2]=0;b=k[152]|0;a=1<>2]=g;k[g+24>>2]=c;k[g+12>>2]=g;k[g+8>>2]=g;break}b=k[c>>2]|0;k:do if((k[b+4>>2]&-8|0)!=(f|0)){d=f<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(f|0)){I=c;break k}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=g;k[g+24>>2]=b;k[g+12>>2]=g;k[g+8>>2]=g;break g}}else I=b;while(0);b=I+8|0;a=k[b>>2]|0;M=k[155]|0;if(a>>>0>=M>>>0&I>>>0>=M>>>0){k[a+12>>2]=g;k[b>>2]=g;k[g+8>>2]=a;k[g+12>>2]=I;k[g+24>>2]=0;break}else Na()}}else{M=k[155]|0;if((M|0)==0|w>>>0>>0)k[155]=w;k[263]=w;k[264]=p;k[266]=0;k[160]=k[269];k[159]=-1;b=0;do{M=b<<1;L=644+(M<<2)|0;k[644+(M+3<<2)>>2]=L;k[644+(M+2<<2)>>2]=L;b=b+1|0}while((b|0)!=32);M=w+8|0;M=(M&7|0)==0?0:0-M&7;L=p+-40-M|0;k[157]=w+M;k[154]=L;k[w+(M+4)>>2]=L|1;k[w+(p+-36)>>2]=40;k[158]=k[273]}while(0);b=k[154]|0;if(b>>>0>q>>>0){L=b-q|0;k[154]=L;M=k[157]|0;k[157]=M+q;k[M+(q+4)>>2]=L|1;k[M+4>>2]=q|3;M=M+8|0;return M|0}}M=qc()|0;k[M>>2]=12;M=0;return M|0}function Vc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;if(!a)return;b=a+-8|0;h=k[155]|0;if(b>>>0>>0)Na();c=k[a+-4>>2]|0;d=c&3;if((d|0)==1)Na();o=c&-8;q=a+(o+-8)|0;do if(!(c&1)){b=k[b>>2]|0;if(!d)return;i=-8-b|0;l=a+i|0;m=b+o|0;if(l>>>0>>0)Na();if((l|0)==(k[156]|0)){b=a+(o+-4)|0;c=k[b>>2]|0;if((c&3|0)!=3){u=l;f=m;break}k[153]=m;k[b>>2]=c&-2;k[a+(i+4)>>2]=m|1;k[q>>2]=m;return}e=b>>>3;if(b>>>0<256){d=k[a+(i+8)>>2]|0;c=k[a+(i+12)>>2]|0;b=644+(e<<1<<2)|0;if((d|0)!=(b|0)){if(d>>>0>>0)Na();if((k[d+12>>2]|0)!=(l|0))Na()}if((c|0)==(d|0)){k[151]=k[151]&~(1<>>0>>0)Na();b=c+8|0;if((k[b>>2]|0)==(l|0))g=b;else Na()}else g=c+8|0;k[d+12>>2]=c;k[g>>2]=d;u=l;f=m;break}g=k[a+(i+24)>>2]|0;d=k[a+(i+12)>>2]|0;do if((d|0)==(l|0)){c=a+(i+20)|0;b=k[c>>2]|0;if(!b){c=a+(i+16)|0;b=k[c>>2]|0;if(!b){j=0;break}}while(1){d=b+20|0;e=k[d>>2]|0;if(e){b=e;c=d;continue}d=b+16|0;e=k[d>>2]|0;if(!e)break;else{b=e;c=d}}if(c>>>0>>0)Na();else{k[c>>2]=0;j=b;break}}else{e=k[a+(i+8)>>2]|0;if(e>>>0>>0)Na();b=e+12|0;if((k[b>>2]|0)!=(l|0))Na();c=d+8|0;if((k[c>>2]|0)==(l|0)){k[b>>2]=d;k[c>>2]=e;j=d;break}else Na()}while(0);if(g){b=k[a+(i+28)>>2]|0;c=908+(b<<2)|0;if((l|0)==(k[c>>2]|0)){k[c>>2]=j;if(!j){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(l|0))k[b>>2]=j;else k[g+20>>2]=j;if(!j){u=l;f=m;break}}c=k[155]|0;if(j>>>0>>0)Na();k[j+24>>2]=g;b=k[a+(i+16)>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[j+16>>2]=b;k[b+24>>2]=j;break}while(0);b=k[a+(i+20)>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[j+20>>2]=b;k[b+24>>2]=j;u=l;f=m;break}else{u=l;f=m}}else{u=l;f=m}}else{u=b;f=o}while(0);if(u>>>0>=q>>>0)Na();b=a+(o+-4)|0;c=k[b>>2]|0;if(!(c&1))Na();if(!(c&2)){if((q|0)==(k[157]|0)){t=(k[154]|0)+f|0;k[154]=t;k[157]=u;k[u+4>>2]=t|1;if((u|0)!=(k[156]|0))return;k[156]=0;k[153]=0;return}if((q|0)==(k[156]|0)){t=(k[153]|0)+f|0;k[153]=t;k[156]=u;k[u+4>>2]=t|1;k[u+t>>2]=t;return}f=(c&-8)+f|0;e=c>>>3;do if(c>>>0>=256){g=k[a+(o+16)>>2]|0;b=k[a+(o|4)>>2]|0;do if((b|0)==(q|0)){c=a+(o+12)|0;b=k[c>>2]|0;if(!b){c=a+(o+8)|0;b=k[c>>2]|0;if(!b){p=0;break}}while(1){d=b+20|0;e=k[d>>2]|0;if(e){b=e;c=d;continue}d=b+16|0;e=k[d>>2]|0;if(!e)break;else{b=e;c=d}}if(c>>>0<(k[155]|0)>>>0)Na();else{k[c>>2]=0;p=b;break}}else{c=k[a+o>>2]|0;if(c>>>0<(k[155]|0)>>>0)Na();d=c+12|0;if((k[d>>2]|0)!=(q|0))Na();e=b+8|0;if((k[e>>2]|0)==(q|0)){k[d>>2]=b;k[e>>2]=c;p=b;break}else Na()}while(0);if(g){b=k[a+(o+20)>>2]|0;c=908+(b<<2)|0;if((q|0)==(k[c>>2]|0)){k[c>>2]=p;if(!p){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(q|0))k[b>>2]=p;else k[g+20>>2]=p;if(!p)break}c=k[155]|0;if(p>>>0>>0)Na();k[p+24>>2]=g;b=k[a+(o+8)>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[p+16>>2]=b;k[b+24>>2]=p;break}while(0);b=k[a+(o+12)>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[p+20>>2]=b;k[b+24>>2]=p;break}}}else{d=k[a+o>>2]|0;c=k[a+(o|4)>>2]|0;b=644+(e<<1<<2)|0;if((d|0)!=(b|0)){if(d>>>0<(k[155]|0)>>>0)Na();if((k[d+12>>2]|0)!=(q|0))Na()}if((c|0)==(d|0)){k[151]=k[151]&~(1<>>0<(k[155]|0)>>>0)Na();b=c+8|0;if((k[b>>2]|0)==(q|0))n=b;else Na()}else n=c+8|0;k[d+12>>2]=c;k[n>>2]=d}while(0);k[u+4>>2]=f|1;k[u+f>>2]=f;if((u|0)==(k[156]|0)){k[153]=f;return}}else{k[b>>2]=c&-2;k[u+4>>2]=f|1;k[u+f>>2]=f}b=f>>>3;if(f>>>0<256){c=b<<1;e=644+(c<<2)|0;d=k[151]|0;b=1<>2]|0;if(c>>>0<(k[155]|0)>>>0)Na();else{r=b;s=c}}else{k[151]=d|b;r=644+(c+2<<2)|0;s=e}k[r>>2]=u;k[s+12>>2]=u;k[u+8>>2]=s;k[u+12>>2]=e;return}b=f>>>8;if(b)if(f>>>0>16777215)e=31;else{r=(b+1048320|0)>>>16&8;s=b<>>16&4;s=s<>>16&2;e=14-(q|r|e)+(s<>>15)|0;e=f>>>(e+7|0)&1|e<<1}else e=0;b=908+(e<<2)|0;k[u+28>>2]=e;k[u+20>>2]=0;k[u+16>>2]=0;c=k[152]|0;d=1<>2]|0;b:do if((k[b+4>>2]&-8|0)!=(f|0)){e=f<<((e|0)==31?0:25-(e>>>1)|0);while(1){c=b+16+(e>>>31<<2)|0;d=k[c>>2]|0;if(!d)break;if((k[d+4>>2]&-8|0)==(f|0)){t=d;break b}else{e=e<<1;b=d}}if(c>>>0<(k[155]|0)>>>0)Na();else{k[c>>2]=u;k[u+24>>2]=b;k[u+12>>2]=u;k[u+8>>2]=u;break a}}else t=b;while(0);b=t+8|0;c=k[b>>2]|0;s=k[155]|0;if(c>>>0>=s>>>0&t>>>0>=s>>>0){k[c+12>>2]=u;k[b>>2]=u;k[u+8>>2]=c;k[u+12>>2]=t;k[u+24>>2]=0;break}else Na()}else{k[152]=c|d;k[b>>2]=u;k[u+24>>2]=b;k[u+12>>2]=u;k[u+8>>2]=u}while(0);u=(k[159]|0)+-1|0;k[159]=u;if(!u)b=1060;else return;while(1){b=k[b>>2]|0;if(!b)break;else b=b+8|0}k[159]=-1;return}function Wc(a,b){a=a|0;b=b|0;var c=0,d=0;if(!a){a=Uc(b)|0;return a|0}if(b>>>0>4294967231){a=qc()|0;k[a>>2]=12;a=0;return a|0}c=Yc(a+-8|0,b>>>0<11?16:b+11&-8)|0;if(c){a=c+8|0;return a|0}c=Uc(b)|0;if(!c){a=0;return a|0}d=k[a+-4>>2]|0;d=(d&-8)-((d&3|0)==0?8:4)|0;ed(c|0,a|0,(d>>>0>>0?d:b)|0)|0;Vc(a);a=c;return a|0}function Xc(a){a=a|0;var b=0;if(!a){b=0;return b|0}a=k[a+-4>>2]|0;b=a&3;if((b|0)==1){b=0;return b|0}b=(a&-8)-((b|0)==0?8:4)|0;return b|0}function Yc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;o=a+4|0;p=k[o>>2]|0;i=p&-8;l=a+i|0;h=k[155]|0;c=p&3;if(!((c|0)!=1&a>>>0>=h>>>0&a>>>0>>0))Na();d=a+(i|4)|0;e=k[d>>2]|0;if(!(e&1))Na();if(!c){if(b>>>0<256){a=0;return a|0}if(i>>>0>=(b+4|0)>>>0?(i-b|0)>>>0<=k[271]<<1>>>0:0)return a|0;a=0;return a|0}if(i>>>0>=b>>>0){c=i-b|0;if(c>>>0<=15)return a|0;k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=c|3;k[d>>2]=k[d>>2]|1;Zc(a+b|0,c);return a|0}if((l|0)==(k[157]|0)){c=(k[154]|0)+i|0;if(c>>>0<=b>>>0){a=0;return a|0}n=c-b|0;k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=n|1;k[157]=a+b;k[154]=n;return a|0}if((l|0)==(k[156]|0)){d=(k[153]|0)+i|0;if(d>>>0>>0){a=0;return a|0}c=d-b|0;if(c>>>0>15){k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=c|1;k[a+d>>2]=c;d=a+(d+4)|0;k[d>>2]=k[d>>2]&-2;d=a+b|0}else{k[o>>2]=p&1|d|2;d=a+(d+4)|0;k[d>>2]=k[d>>2]|1;d=0;c=0}k[153]=c;k[156]=d;return a|0}if(e&2){a=0;return a|0}m=(e&-8)+i|0;if(m>>>0>>0){a=0;return a|0}n=m-b|0;f=e>>>3;do if(e>>>0>=256){g=k[a+(i+24)>>2]|0;f=k[a+(i+12)>>2]|0;do if((f|0)==(l|0)){d=a+(i+20)|0;c=k[d>>2]|0;if(!c){d=a+(i+16)|0;c=k[d>>2]|0;if(!c){j=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;j=c;break}}else{e=k[a+(i+8)>>2]|0;if(e>>>0>>0)Na();c=e+12|0;if((k[c>>2]|0)!=(l|0))Na();d=f+8|0;if((k[d>>2]|0)==(l|0)){k[c>>2]=f;k[d>>2]=e;j=f;break}else Na()}while(0);if(g){c=k[a+(i+28)>>2]|0;d=908+(c<<2)|0;if((l|0)==(k[d>>2]|0)){k[d>>2]=j;if(!j){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=g+16|0;if((k[c>>2]|0)==(l|0))k[c>>2]=j;else k[g+20>>2]=j;if(!j)break}d=k[155]|0;if(j>>>0>>0)Na();k[j+24>>2]=g;c=k[a+(i+16)>>2]|0;do if(c)if(c>>>0>>0)Na();else{k[j+16>>2]=c;k[c+24>>2]=j;break}while(0);c=k[a+(i+20)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[j+20>>2]=c;k[c+24>>2]=j;break}}}else{e=k[a+(i+8)>>2]|0;d=k[a+(i+12)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(l|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(l|0))g=c;else Na()}else g=d+8|0;k[e+12>>2]=d;k[g>>2]=e}while(0);if(n>>>0<16){k[o>>2]=m|p&1|2;b=a+(m|4)|0;k[b>>2]=k[b>>2]|1;return a|0}else{k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=n|3;p=a+(m|4)|0;k[p>>2]=k[p>>2]|1;Zc(a+b|0,n);return a|0}return 0}function Zc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;q=a+b|0;c=k[a+4>>2]|0;do if(!(c&1)){j=k[a>>2]|0;if(!(c&3))return;n=a+(0-j)|0;m=j+b|0;i=k[155]|0;if(n>>>0>>0)Na();if((n|0)==(k[156]|0)){d=a+(b+4)|0;c=k[d>>2]|0;if((c&3|0)!=3){t=n;g=m;break}k[153]=m;k[d>>2]=c&-2;k[a+(4-j)>>2]=m|1;k[q>>2]=m;return}f=j>>>3;if(j>>>0<256){e=k[a+(8-j)>>2]|0;d=k[a+(12-j)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(n|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(n|0))h=c;else Na()}else h=d+8|0;k[e+12>>2]=d;k[h>>2]=e;t=n;g=m;break}h=k[a+(24-j)>>2]|0;e=k[a+(12-j)>>2]|0;do if((e|0)==(n|0)){e=16-j|0;d=a+(e+4)|0;c=k[d>>2]|0;if(!c){d=a+e|0;c=k[d>>2]|0;if(!c){l=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;l=c;break}}else{f=k[a+(8-j)>>2]|0;if(f>>>0>>0)Na();c=f+12|0;if((k[c>>2]|0)!=(n|0))Na();d=e+8|0;if((k[d>>2]|0)==(n|0)){k[c>>2]=e;k[d>>2]=f;l=e;break}else Na()}while(0);if(h){c=k[a+(28-j)>>2]|0;d=908+(c<<2)|0;if((n|0)==(k[d>>2]|0)){k[d>>2]=l;if(!l){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=h+16|0;if((k[c>>2]|0)==(n|0))k[c>>2]=l;else k[h+20>>2]=l;if(!l){t=n;g=m;break}}e=k[155]|0;if(l>>>0>>0)Na();k[l+24>>2]=h;c=16-j|0;d=k[a+c>>2]|0;do if(d)if(d>>>0>>0)Na();else{k[l+16>>2]=d;k[d+24>>2]=l;break}while(0);c=k[a+(c+4)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[l+20>>2]=c;k[c+24>>2]=l;t=n;g=m;break}else{t=n;g=m}}else{t=n;g=m}}else{t=a;g=b}while(0);i=k[155]|0;if(q>>>0>>0)Na();c=a+(b+4)|0;d=k[c>>2]|0;if(!(d&2)){if((q|0)==(k[157]|0)){s=(k[154]|0)+g|0;k[154]=s;k[157]=t;k[t+4>>2]=s|1;if((t|0)!=(k[156]|0))return;k[156]=0;k[153]=0;return}if((q|0)==(k[156]|0)){s=(k[153]|0)+g|0;k[153]=s;k[156]=t;k[t+4>>2]=s|1;k[t+s>>2]=s;return}g=(d&-8)+g|0;f=d>>>3;do if(d>>>0>=256){h=k[a+(b+24)>>2]|0;e=k[a+(b+12)>>2]|0;do if((e|0)==(q|0)){d=a+(b+20)|0;c=k[d>>2]|0;if(!c){d=a+(b+16)|0;c=k[d>>2]|0;if(!c){p=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;p=c;break}}else{f=k[a+(b+8)>>2]|0;if(f>>>0>>0)Na();c=f+12|0;if((k[c>>2]|0)!=(q|0))Na();d=e+8|0;if((k[d>>2]|0)==(q|0)){k[c>>2]=e;k[d>>2]=f;p=e;break}else Na()}while(0);if(h){c=k[a+(b+28)>>2]|0;d=908+(c<<2)|0;if((q|0)==(k[d>>2]|0)){k[d>>2]=p;if(!p){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=h+16|0;if((k[c>>2]|0)==(q|0))k[c>>2]=p;else k[h+20>>2]=p;if(!p)break}d=k[155]|0;if(p>>>0>>0)Na();k[p+24>>2]=h;c=k[a+(b+16)>>2]|0;do if(c)if(c>>>0>>0)Na();else{k[p+16>>2]=c;k[c+24>>2]=p;break}while(0);c=k[a+(b+20)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[p+20>>2]=c;k[c+24>>2]=p;break}}}else{e=k[a+(b+8)>>2]|0;d=k[a+(b+12)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(q|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(q|0))o=c;else Na()}else o=d+8|0;k[e+12>>2]=d;k[o>>2]=e}while(0);k[t+4>>2]=g|1;k[t+g>>2]=g;if((t|0)==(k[156]|0)){k[153]=g;return}}else{k[c>>2]=d&-2;k[t+4>>2]=g|1;k[t+g>>2]=g}c=g>>>3;if(g>>>0<256){d=c<<1;f=644+(d<<2)|0;e=k[151]|0;c=1<>2]|0;if(d>>>0<(k[155]|0)>>>0)Na();else{r=c;s=d}}else{k[151]=e|c;r=644+(d+2<<2)|0;s=f}k[r>>2]=t;k[s+12>>2]=t;k[t+8>>2]=s;k[t+12>>2]=f;return}c=g>>>8;if(c)if(g>>>0>16777215)f=31;else{r=(c+1048320|0)>>>16&8;s=c<>>16&4;s=s<>>16&2;f=14-(q|r|f)+(s<>>15)|0;f=g>>>(f+7|0)&1|f<<1}else f=0;c=908+(f<<2)|0;k[t+28>>2]=f;k[t+20>>2]=0;k[t+16>>2]=0;d=k[152]|0;e=1<>2]=t;k[t+24>>2]=c;k[t+12>>2]=t;k[t+8>>2]=t;return}c=k[c>>2]|0;a:do if((k[c+4>>2]&-8|0)!=(g|0)){f=g<<((f|0)==31?0:25-(f>>>1)|0);while(1){d=c+16+(f>>>31<<2)|0;e=k[d>>2]|0;if(!e)break;if((k[e+4>>2]&-8|0)==(g|0)){c=e;break a}else{f=f<<1;c=e}}if(d>>>0<(k[155]|0)>>>0)Na();k[d>>2]=t;k[t+24>>2]=c;k[t+12>>2]=t;k[t+8>>2]=t;return}while(0);d=c+8|0;e=k[d>>2]|0;s=k[155]|0;if(!(e>>>0>=s>>>0&c>>>0>=s>>>0))Na();k[e+12>>2]=t;k[d>>2]=t;k[t+8>>2]=e;k[t+12>>2]=c;k[t+24>>2]=0;return}function _c(){}function $c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (L=d,a-c>>>0|0)|0}function ad(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=a+c|0;if((c|0)>=20){b=b&255;f=a&3;g=b|b<<8|b<<16|b<<24;e=d&~3;if(f){f=a+4-f|0;while((a|0)<(f|0)){i[a>>0]=b;a=a+1|0}}while((a|0)<(e|0)){k[a>>2]=g;a=a+4|0}}while((a|0)<(d|0)){i[a>>0]=b;a=a+1|0}return a-c|0}function bd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b>>>c;return a>>>c|(b&(1<>>c-32|0}function cd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b<>>32-c;return a<>>0;return (L=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function ed(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((c|0)>=4096)return Da(a|0,b|0,c|0)|0;d=a|0;if((a&3)==(b&3)){while(a&3){if(!c)return d|0;i[a>>0]=i[b>>0]|0;a=a+1|0;b=b+1|0;c=c-1|0}while((c|0)>=4){k[a>>2]=k[b>>2];a=a+4|0;b=b+4|0;c=c-4|0}}while((c|0)>0){i[a>>0]=i[b>>0]|0;a=a+1|0;b=b+1|0;c=c-1|0}return d|0}function fd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b>>c;return a>>>c|(b&(1<>c-32|0}function gd(a){a=a|0;var b=0;b=i[v+(a&255)>>0]|0;if((b|0)<8)return b|0;b=i[v+(a>>8&255)>>0]|0;if((b|0)<8)return b+8|0;b=i[v+(a>>16&255)>>0]|0;if((b|0)<8)return b+16|0;return (i[v+(a>>>24)>>0]|0)+24|0}function hd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=ha(e,f)|0;d=a>>>16;a=(c>>>16)+(ha(e,d)|0)|0;e=b>>>16;b=ha(e,f)|0;return (L=(a>>>16)+(ha(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function id(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=$c(j^a,i^b,j,i)|0;g=L;a=f^j;b=e^i;return $c((nd(h,g,$c(f^c,e^d,f,e)|0,L,0)|0)^a,L^b,a,b)|0}function jd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=r;r=r+16|0;h=e|0;g=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;j=d>>31|((d|0)<0?-1:0)<<1;i=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;a=$c(g^a,f^b,g,f)|0;b=L;nd(a,b,$c(j^c,i^d,j,i)|0,L,h)|0;d=$c(k[h>>2]^g,k[h+4>>2]^f,g,f)|0;c=L;r=e;return (L=c,d)|0}function kd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=hd(e,f)|0;a=L;return (L=(ha(b,f)|0)+(ha(d,e)|0)+a|a&0,c|0|0)|0}function ld(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return nd(a,b,c,d,0)|0}function md(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=r;r=r+16|0;e=f|0;nd(a,b,c,d,e)|0;r=f;return (L=k[e+4>>2]|0,k[e>>2]|0)|0}function nd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;l=a;i=b;j=i;g=c;n=d;h=n;if(!j){f=(e|0)!=0;if(!h){if(f){k[e>>2]=(l>>>0)%(g>>>0);k[e+4>>2]=0}n=0;e=(l>>>0)/(g>>>0)>>>0;return (L=n,e)|0}else{if(!f){n=0;e=0;return (L=n,e)|0}k[e>>2]=a|0;k[e+4>>2]=b&0;n=0;e=0;return (L=n,e)|0}}f=(h|0)==0;do if(g){if(!f){f=(ja(h|0)|0)-(ja(j|0)|0)|0;if(f>>>0<=31){m=f+1|0;h=31-f|0;b=f-31>>31;g=m;a=l>>>(m>>>0)&b|j<>>(m>>>0)&b;f=0;h=l<>2]=a|0;k[e+4>>2]=i|b&0;n=0;e=0;return (L=n,e)|0}f=g-1|0;if(f&g){h=(ja(g|0)|0)+33-(ja(j|0)|0)|0;p=64-h|0;m=32-h|0;i=m>>31;o=h-32|0;b=o>>31;g=h;a=m-1>>31&j>>>(o>>>0)|(j<>>(h>>>0))&b;b=b&j>>>(h>>>0);f=l<>>(o>>>0))&i|l<>31;break}if(e){k[e>>2]=f&l;k[e+4>>2]=0}if((g|0)==1){o=i|b&0;p=a|0|0;return (L=o,p)|0}else{p=gd(g|0)|0;o=j>>>(p>>>0)|0;p=j<<32-p|l>>>(p>>>0)|0;return (L=o,p)|0}}else{if(f){if(e){k[e>>2]=(j>>>0)%(g>>>0);k[e+4>>2]=0}o=0;p=(j>>>0)/(g>>>0)>>>0;return (L=o,p)|0}if(!l){if(e){k[e>>2]=0;k[e+4>>2]=(j>>>0)%(h>>>0)}o=0;p=(j>>>0)/(h>>>0)>>>0;return (L=o,p)|0}f=h-1|0;if(!(f&h)){if(e){k[e>>2]=a|0;k[e+4>>2]=f&j|b&0}o=0;p=j>>>((gd(h|0)|0)>>>0);return (L=o,p)|0}f=(ja(h|0)|0)-(ja(j|0)|0)|0;if(f>>>0<=30){b=f+1|0;h=31-f|0;g=b;a=j<>>(b>>>0);b=j>>>(b>>>0);f=0;h=l<>2]=a|0;k[e+4>>2]=i|b&0;o=0;p=0;return (L=o,p)|0}while(0);if(!g){j=h;i=0;h=0}else{m=c|0|0;l=n|d&0;j=dd(m|0,l|0,-1,-1)|0;c=L;i=h;h=0;do{d=i;i=f>>>31|i<<1;f=h|f<<1;d=a<<1|d>>>31|0;n=a>>>31|b<<1|0;$c(j,c,d,n)|0;p=L;o=p>>31|((p|0)<0?-1:0)<<1;h=o&1;a=$c(d,n,o&m,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l)|0;b=L;g=g-1|0}while((g|0)!=0);j=i;i=0}g=0;if(e){k[e>>2]=a;k[e+4>>2]=b}o=(f|0)>>>31|(j|g)<<1|(g<<1|f>>>31)&0|i;p=(f<<1|0>>>31)&-2|h;return (L=o,p)|0}function od(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ua[a&7](b|0,c|0,d|0)|0}function pd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Va[a&3](b|0,c|0,d|0,e|0,f|0)}function qd(a,b){a=a|0;b=b|0;Wa[a&7](b|0)}function rd(a,b){a=a|0;b=b|0;return Xa[a&1](b|0)|0}function sd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ya[a&0](b|0,c|0,d|0)}function td(a){a=a|0;Za[a&3]()}function ud(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;_a[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function vd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return $a[a&1](b|0,c|0,d|0,e|0,f|0)|0}function wd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ab[a&3](b|0,c|0,d|0,e|0)}function xd(a,b,c){a=a|0;b=b|0;c=c|0;ka(0);return 0}function yd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ka(1)}function zd(a){a=a|0;ka(2)}function Ad(a){a=a|0;ka(3);return 0}function Bd(a,b,c){a=a|0;b=b|0;c=c|0;ka(4)}function Cd(){ka(5)}function Dd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ka(6)}function Ed(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ka(7);return 0}function Fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ka(8)} - -// EMSCRIPTEN_END_FUNCS -var Ua=[xd,ac,Qc,Jc,Ic,Kc,xd,xd];var Va=[yd,hc,gc,yd];var Wa=[zd,Xb,_b,Yb,Zb,$b,oc,Pc];var Xa=[Ad,Hc];var Ya=[Bd];var Za=[Cd,mc,nc,Cd];var _a=[Dd,jc,ic,Dd];var $a=[Ed,ob];var ab=[Fd,cc,dc,Fd];return{___cxa_can_catch:kc,_crn_get_levels:Db,_crn_get_uncompressed_size:Fb,_crn_decompress:Gb,_i64Add:dd,_crn_get_width:Bb,___cxa_is_pointer_type:lc,_i64Subtract:$c,_memset:ad,_malloc:Uc,_free:Vc,_memcpy:ed,_bitshift64Lshr:bd,_fflush:wc,_bitshift64Shl:cd,_crn_get_height:Cb,___errno_location:qc,_crn_get_dxt_format:Eb,runPostSets:_c,_emscripten_replace_memory:Ta,stackAlloc:bb,stackSave:cb,stackRestore:db,establishStackSpace:eb,setThrew:fb,setTempRet0:ib,getTempRet0:jb,dynCall_iiii:od,dynCall_viiiii:pd,dynCall_vi:qd,dynCall_ii:rd,dynCall_viii:sd,dynCall_v:td,dynCall_viiiiii:ud,dynCall_iiiiii:vd,dynCall_viiii:wd}}) - - -// EMSCRIPTEN_END_ASM -(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch;e._crn_get_levels=Z._crn_get_levels;e.runPostSets=Z.runPostSets;e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size;e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height;e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type; -var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush;e._crn_get_width=Z._crn_get_width;e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;e.dynCall_iiii=Z.dynCall_iiii;e.dynCall_viiiii=Z.dynCall_viiiii;e.dynCall_vi=Z.dynCall_vi; -e.dynCall_ii=Z.dynCall_ii;e.dynCall_viii=Z.dynCall_viii;e.dynCall_v=Z.dynCall_v;e.dynCall_viiiiii=Z.dynCall_viiiiii;e.dynCall_iiiiii=Z.dynCall_iiiiii;e.dynCall_viiii=Z.dynCall_viiii;n.aa=Z.stackAlloc;n.ua=Z.stackSave;n.ba=Z.stackRestore;n.Cd=Z.establishStackSpace;n.rb=Z.setTempRet0;n.fb=Z.getTempRet0;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}ia.prototype=Error();ia.prototype.constructor=ia; -var rd=null,jb=function sd(){e.calledRun||td();e.calledRun||(jb=sd)}; -e.callMain=e.zd=function(a){function b(){for(var a=0;3>a;a++)d.push(0)}assert(0==I,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(0==bb.length,"cannot call main when preRun functions remain to be called");a=a||[];Ha||(Ha=!0,ab(cb));var c=a.length+1,d=[D(hb(e.thisProgram),"i8",0)];b();for(var f=0;f 0) var gc = undefined");else if(ba||ca)e.read=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},"undefined"!=typeof arguments&&(e.arguments=arguments),"undefined"!== +typeof console?(e.print||(e.print=function(a){console.log(a)}),e.printErr||(e.printErr=function(a){console.log(a)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),"undefined"===typeof e.setWindowTitle&&(e.setWindowTitle=function(a){document.title=a});else throw"Unknown runtime environment. Where are we?";function ha(a){eval.call(null,a)}!e.load&&e.read&&(e.load=function(a){ha(e.read(a))});e.print||(e.print=function(){});e.printErr||(e.printErr=e.print);e.arguments||(e.arguments=[]); +e.thisProgram||(e.thisProgram="./this.program");e.print=e.print;e.W=e.printErr;e.preRun=[];e.postRun=[];for(k in aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]); +var n={rb:function(a){ka=a},fb:function(){return ka},ua:function(){return m},ba:function(a){m=a},Ka:function(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?n.J:"i"===a[0]?(a=parseInt(a.substr(1)),assert(0===a%8),a/8):0}},eb:function(a){return Math.max(n.Ka(a),n.J)},ud:16,Qd:function(a,b){"double"===b||"i64"===b?a&7&&(assert(4===(a&7)),a+=4):assert(0===(a&3));return a}, +Ed:function(a,b,c){return c||"i64"!=a&&"double"!=a?a?Math.min(b||(a?n.eb(a):0),n.J):Math.min(b,8):8},L:function(a,b,c){return c&&c.length?(c.splice||(c=Array.prototype.slice.call(c)),c.splice(0,0,b),e["dynCall_"+a].apply(null,c)):e["dynCall_"+a].call(null,b)},Z:[],Xa:function(a){for(var b=0;b=t&&!ma()?(r=b,0): +b},ja:function(a,b){return Math.ceil(a/(b?b:16))*(b?b:16)},Nd:function(a,b,c){return c?+(a>>>0)+4294967296*+(b>>>0):+(a>>>0)+4294967296*+(b|0)},Ua:8,J:4,vd:0};e.Runtime=n;n.addFunction=n.Xa;n.removeFunction=n.nb;var na=!1,oa,pa,ka;function assert(a,b){a||x("Assertion failed: "+b)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(c){}assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)");return b}var ra,sa; +(function(){function a(a){a=a.toString().match(d).slice(1);return{arguments:a[0],body:a[1],returnValue:a[2]}}var b={stackSave:function(){n.ua()},stackRestore:function(){n.ba()},arrayToC:function(a){var b=n.aa(a.length);ta(a,b);return b},stringToC:function(a){var b=0;null!==a&&void 0!==a&&0!==a&&(b=n.aa((a.length<<2)+1),ua(a,b));return b}},c={string:b.stringToC,array:b.arrayToC};sa=function(a,b,d,f,g){a=qa(a);var v=[],B=0;if(f)for(var G=0;G>0]=b;break;case "i8":y[a>>0]=b;break;case "i16":z[a>>1]=b;break;case "i32":C[a>>2]=b;break;case "i64":pa=[b>>>0,(oa=b,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)];C[a>>2]=pa[0];C[a+4>>2]=pa[1];break;case "float":Ba[a>>2]=b;break;case "double":Ca[a>>3]=b;break;default:x("invalid type for setValue: "+c)}}e.setValue=wa; +function Da(a,b){b=b||"i8";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":return y[a>>0];case "i8":return y[a>>0];case "i16":return z[a>>1];case "i32":return C[a>>2];case "i64":return C[a>>2];case "float":return Ba[a>>2];case "double":return Ca[a>>3];default:x("invalid type for setValue: "+b)}return null}e.getValue=Da;e.ALLOC_NORMAL=0;e.ALLOC_STACK=1;e.ALLOC_STATIC=2;e.ALLOC_DYNAMIC=3;e.ALLOC_NONE=4; +function D(a,b,c,d){var f,g;"number"===typeof a?(f=!0,g=a):(f=!1,g=a.length);var h="string"===typeof b?b:null;c=4==c?d:[Ea,n.aa,n.Ra,n.R][void 0===c?2:c](Math.max(g,h?1:b.length));if(f){d=c;assert(0==(c&3));for(a=c+(g&-4);d>2]=0;for(a=c+g;d>0]=0;return c}if("i8"===h)return a.subarray||a.slice?E.set(a,c):E.set(new Uint8Array(a),c),c;d=0;for(var l,w;d>0];c|=d;if(0==d&&!b)break;f++;if(b&&f==b)break}b||(b=f);d="";if(128>c){for(;0>0];if(!c)return b;b+=String.fromCharCode(c)}}; +e.stringToAscii=function(a,b){return Ia(a,b,!1)}; +function Ja(a,b){for(var c,d,f,g,h,l,w="";;){c=a[b++];if(!c)return w;c&128?(d=a[b++]&63,192==(c&224)?w+=String.fromCharCode((c&31)<<6|d):(f=a[b++]&63,224==(c&240)?c=(c&15)<<12|d<<6|f:(g=a[b++]&63,240==(c&248)?c=(c&7)<<18|d<<12|f<<6|g:(h=a[b++]&63,248==(c&252)?c=(c&3)<<24|d<<18|f<<12|g<<6|h:(l=a[b++]&63,c=(c&1)<<30|d<<24|f<<18|g<<12|h<<6|l))),65536>c?w+=String.fromCharCode(c):(c-=65536,w+=String.fromCharCode(55296|c>>10,56320|c&1023)))):w+=String.fromCharCode(c)}}e.UTF8ArrayToString=Ja; +e.UTF8ToString=function(a){return Ja(E,a)}; +function Ka(a,b,c,d){if(!(0=h&&(h=65536+((h&1023)<<10)|a.charCodeAt(++g)&1023);if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(2097151>=h){if(c+3>=d)break;b[c++]=240|h>>18}else{if(67108863>=h){if(c+4>=d)break;b[c++]=248|h>>24}else{if(c+5>=d)break;b[c++]=252|h>>30;b[c++]=128|h>>24&63}b[c++]=128|h>>18&63}b[c++]=128| +h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-f}e.stringToUTF8Array=Ka;e.stringToUTF8=function(a,b,c){return Ka(a,E,b,c)};function La(a){for(var b=0,c=0;c=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:2097151>=d?b+4:67108863>=d?b+5:b+6}return b}e.lengthBytesUTF8=La;e.UTF16ToString=function(a){for(var b=0,c="";;){var d=z[a+2*b>>1];if(0==d)return c;++b;c+=String.fromCharCode(d)}}; +e.stringToUTF16=function(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f>1]=a.charCodeAt(f),b+=2;z[b>>1]=0;return b-d};e.lengthBytesUTF16=function(a){return 2*a.length};e.UTF32ToString=function(a){for(var b=0,c="";;){var d=C[a+4*b>>2];if(0==d)return c;++b;65536<=d?(d=d-65536,c+=String.fromCharCode(55296|d>>10,56320|d&1023)):c+=String.fromCharCode(d)}}; +e.stringToUTF32=function(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f=g)var h=a.charCodeAt(++f),g=65536+((g&1023)<<10)|h&1023;C[b>>2]=g;b+=4;if(b+4>c)break}C[b>>2]=0;return b-d};e.lengthBytesUTF32=function(a){for(var b=0,c=0;c=d&&++c;b+=4}return b}; +function Ma(a){function b(c,d,f){d=d||Infinity;var g="",h=[],v;if("N"===a[l]){l++;"K"===a[l]&&l++;for(v=[];"E"!==a[l];)if("S"===a[l]){l++;var A=a.indexOf("_",l);v.push(u[a.substring(l,A)||0]||"?");l=A+1}else if("C"===a[l])v.push(v[v.length-1]),l+=2;else{var A=parseInt(a.substr(l)),U=A.toString().length;if(!A||!U){l--;break}var Ub=a.substr(l+U,A);v.push(Ub);u.push(Ub);l+=U+A}l++;v=v.join("::");d--;if(0===d)return c?[v]:v}else if(("K"===a[l]||q&&"L"===a[l])&&l++,A=parseInt(a.substr(l)))U=A.toString().length, +v=a.substr(l+U,A),l+=U+A;q=!1;"I"===a[l]?(l++,A=b(!0),U=b(!0,1,!0),g+=U[0]+" "+v+"<"+A.join(", ")+">"):g=v;a:for(;l=a)return!1;for(;t<=r;)if(t=a)return!1;try{if(ArrayBuffer.p)buffer=ArrayBuffer.p(buffer,t);else{var c=y;buffer=new ArrayBuffer(t)}}catch(d){return!1}if(!Xa(buffer))return!1;e.buffer=buffer;e.HEAP8=y=new Int8Array(buffer);e.HEAP16=z=new Int16Array(buffer);e.HEAP32=C=new Int32Array(buffer);e.HEAPU8=E=new Uint8Array(buffer);e.HEAPU16=Ra=new Uint16Array(buffer);e.HEAPU32=Sa= +new Uint32Array(buffer);e.HEAPF32=Ba=new Float32Array(buffer);e.HEAPF64=Ca=new Float64Array(buffer);ArrayBuffer.p||y.set(c);return!0}var Ya;try{Ya=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get),Ya(new ArrayBuffer(4))}catch(Za){Ya=function(a){return a.byteLength}}for(var $a=e.TOTAL_STACK||5242880,t=e.TOTAL_MEMORY||16777216,F=65536;FF?2*F:F+16777216;F=Math.max(F,16777216);F!==t&&(t=F); +assert("undefined"!==typeof Int32Array&&"undefined"!==typeof Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"JS engine does not provide full typed array support");var buffer;buffer=new ArrayBuffer(t);y=new Int8Array(buffer);z=new Int16Array(buffer);C=new Int32Array(buffer);E=new Uint8Array(buffer);Ra=new Uint16Array(buffer);Sa=new Uint32Array(buffer);Ba=new Float32Array(buffer);Ca=new Float64Array(buffer);C[0]=255;assert(255===E[0]&&0===E[3],"Typed arrays 2 must be run on a little-endian system"); +e.HEAP=void 0;e.buffer=buffer;e.HEAP8=y;e.HEAP16=z;e.HEAP32=C;e.HEAPU8=E;e.HEAPU16=Ra;e.HEAPU32=Sa;e.HEAPF32=Ba;e.HEAPF64=Ca;function ab(a){for(;0>0]=a[c],c+=1}e.writeStringToMemory=ua;function ta(a,b){for(var c=0;c>0]=a[c]}e.writeArrayToMemory=ta; +function Ia(a,b,c){for(var d=0;d>0]=a.charCodeAt(d);c||(y[b>>0]=0)}e.writeAsciiToMemory=Ia;Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(a,b){var c=a&65535,d=b&65535;return c*d+((a>>>16)*d+c*(b>>>16)<<16)|0});Math.Jd=Math.imul;Math.clz32||(Math.clz32=function(a){a=a>>>0;for(var b=0;32>b;b++)if(a&1<<31-b)return b;return 32});Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null; +function kb(){I++;e.monitorRunDependencies&&e.monitorRunDependencies(I)}e.addRunDependency=kb;function lb(){I--;e.monitorRunDependencies&&e.monitorRunDependencies(I);if(0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var a=jb;jb=null;a()}}e.removeRunDependency=lb;e.preloadedImages={};e.preloadedAudios={};Ta=8;la=Ta+5888;cb.push(); +D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105, +110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91, +115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67, +82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121, +109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112, +101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97, +98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115, +105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114, +32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32, +101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95, +96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117, +99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112, +116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101, +116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100, +100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116, +111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111, +99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112, +101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111, +117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115, +32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117, +112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101, +0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116, +32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100, +105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0, +0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0, +0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);assert(0==mb%8);e._i64Subtract=nb; +function ob(a){e.___errno_location&&(C[e.___errno_location()>>2]=a);return a} +var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104, +wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(a,b){H.push(function(){n.L("vi",a,[b])});pb.level=H.length}e._memset=qb;e._bitshift64Lshr=rb;e._bitshift64Shl=sb;function tb(){return!!tb.p}var ub=[],vb={};function wb(a,b){wb.p||(wb.p={});a in wb.p||(n.L("v",b),wb.p[a]=1)} +var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system", +24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed", +44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network", +65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted", +82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available", +100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle", +122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function zb(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=yb(a.split("/").filter(function(a){return!!a}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a} +function Ab(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function Bb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}function Cb(){var a=Array.prototype.slice.call(arguments,0);return zb(a.join("/"))}function K(a,b){return zb(a+"/"+b)} +function Db(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=yb(a.split("/").filter(function(a){return!!a}),!b).join("/");return(b?"/":"")+a||"."}var Eb=[];function Fb(a,b){Eb[a]={input:[],output:[],N:b};Gb(a,Hb)} +var Hb={open:function(a){var b=Eb[a.g.rdev];if(!b)throw new L(J.ha);a.tty=b;a.seekable=!1},close:function(a){a.tty.N.flush(a.tty)},flush:function(a){a.tty.N.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.N.La)throw new L(J.Aa);for(var f=0,g=0;ga.e.length&& +(a.e=M.cb(a),a.o=a.e.length);if(!a.e||a.e.subarray){var c=a.e?a.e.buffer.byteLength:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)|0),0!=c&&(b=Math.max(b,256)),c=a.e,a.e=new Uint8Array(b),0b)a.e.length=b;else for(;a.e.length< +b;)a.e.push(0);a.o=b}},k:{D:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;N(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.o:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.K=4096;b.blocks=Math.ceil(b.size/b.K);return b},u:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);void 0!== +b.size&&M.ob(a,b.size)},lookup:function(){throw Mb[J.F];},T:function(a,b,c,d){return M.createNode(a,b,c,d)},rename:function(a,b,c){if(N(a.mode)){var d;try{d=Nb(b,c)}catch(f){}if(d)for(var g in d.e)throw new L(J.za);}delete a.parent.e[a.name];a.name=c;b.e[c]=a;a.parent=b},unlink:function(a,b){delete a.e[b]},rmdir:function(a,b){var c=Nb(a,b),d;for(d in c.e)throw new L(J.za);delete a.e[b]},readdir:function(a){var b=[".",".."],c;for(c in a.e)a.e.hasOwnProperty(c)&&b.push(c);return b},symlink:function(a, +b,c){a=M.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new L(J.q);return a.link}},n:{read:function(a,b,c,d,f){var g=a.g.e;if(f>=a.g.o)return 0;a=Math.min(a.g.o-f,d);assert(0<=a);if(8b)throw new L(J.q);return b},Ba:function(a,b,c){M.Ga(a.g,b+c);a.g.o=Math.max(a.g.o,b+c)},Na:function(a,b,c,d,f,g,h){if(32768!==(a.g.mode&61440))throw new L(J.ha);c=a.g.e;if(h&2||c.buffer!==b&&c.buffer!==b.buffer){if(0< +f||f+d>1)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}return b.mode},B:function(a){for(var b=[];a.parent!==a;)b.push(a.name),a=a.parent;b.push(a.A.pa.root);b.reverse();return Cb.apply(null,b)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+", +4096:"rs",4098:"rs+"},$a:function(a){a&=-32769;if(a in P.Ha)return P.Ha[a];throw new L(J.q);},k:{D:function(a){a=P.B(a);var b;try{b=fs.lstatSync(a)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}P.$&&!b.K&&(b.K=4096);P.$&&!b.blocks&&(b.blocks=(b.size+b.K-1)/b.K|0);return{dev:b.dev,ino:b.ino,mode:b.mode,nlink:b.nlink,uid:b.uid,gid:b.gid,rdev:b.rdev,size:b.size,atime:b.atime,mtime:b.mtime,ctime:b.ctime,K:b.K,blocks:b.blocks}},u:function(a,b){var c=P.B(a);try{void 0!==b.mode&&(fs.chmodSync(c,b.mode), +a.mode=b.mode),void 0!==b.size&&fs.truncateSync(c,b.size)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},lookup:function(a,b){var c=K(P.B(a),b),c=P.Ja(c);return P.createNode(a,b,c)},T:function(a,b,c,d){a=P.createNode(a,b,c,d);b=P.B(a);try{N(a.mode)?fs.mkdirSync(b,a.mode):fs.writeFileSync(b,"",{mode:a.mode})}catch(f){if(!f.code)throw f;throw new L(J[f.code]);}return a},rename:function(a,b,c){a=P.B(a);b=K(P.B(b),c);try{fs.renameSync(a,b)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}}, +unlink:function(a,b){var c=K(P.B(a),b);try{fs.unlinkSync(c)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},rmdir:function(a,b){var c=K(P.B(a),b);try{fs.rmdirSync(c)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},readdir:function(a){a=P.B(a);try{return fs.readdirSync(a)}catch(b){if(!b.code)throw b;throw new L(J[b.code]);}},symlink:function(a,b,c){a=K(P.B(a),b);try{fs.symlinkSync(c,a)}catch(d){if(!d.code)throw d;throw new L(J[d.code]);}},readlink:function(a){var b=P.B(a);try{return b= +fs.readlinkSync(b),b=Ob.relative(Ob.resolve(a.A.pa.root),b)}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}}},n:{open:function(a){var b=P.B(a.g);try{32768===(a.g.mode&61440)&&(a.V=fs.openSync(b,P.$a(a.flags)))}catch(c){if(!c.code)throw c;throw new L(J[c.code]);}},close:function(a){try{32768===(a.g.mode&61440)&&a.V&&fs.closeSync(a.V)}catch(b){if(!b.code)throw b;throw new L(J[b.code]);}},read:function(a,b,c,d,f){if(0===d)return 0;var g=new Buffer(d),h;try{h=fs.readSync(a.V,g,0,d,f)}catch(l){throw new L(J[l.code]); +}if(0b)throw new L(J.q);return b}}};D(1,"i32*",2);D(1,"i32*",2);D(1,"i32*",2);var Pb=null,Qb=[null],Rb=[],Sb=1,Q=null,Tb=!0,R={},L=null,Mb={}; +function S(a,b){a=Db("/",a);b=b||{};if(!a)return{path:"",g:null};var c={Ia:!0,ra:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8>>0)%Q.length}function Xb(a){var b=Wb(a.parent.id,a.name);a.M=Q[b];Q[b]=a}function Nb(a,b){var c;if(c=(c=Yb(a,"x"))?c:a.k.lookup?0:J.da)throw new L(c,a);for(c=Q[Wb(a.id,b)];c;c=c.M){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.k.lookup(a,b)} +function Lb(a,b,c,d){Zb||(Zb=function(a,b,c,d){a||(a=this);this.parent=a;this.A=a.A;this.U=null;this.id=Sb++;this.name=b;this.mode=c;this.k={};this.n={};this.rdev=d},Zb.prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192===(this.mode& +61440)}}}));a=new Zb(a,b,c,d);Xb(a);return a}function N(a){return 16384===(a&61440)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(a,b){if(Tb)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return J.da}else return J.da;return 0}function ac(a,b){try{return Nb(a,b),J.wa}catch(c){}return Yb(a,"wx")} +function bc(){var a;a=4096;for(var b=0;b<=a;b++)if(!Rb[b])return b;throw new L(J.Sa);}function cc(a){dc||(dc=function(){},dc.prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(a){this.g=a}},Ld:{get:function(){return 1!==(this.flags&2097155)}},Md:{get:function(){return 0!==(this.flags&2097155)}},Kd:{get:function(){return this.flags&1024}}}));var b=new dc,c;for(c in a)b[c]=a[c];a=b;b=bc();a.fd=b;return Rb[b]=a} +var Kb={open:function(a){a.n=Qb[a.g.rdev].n;a.n.open&&a.n.open(a)},G:function(){throw new L(J.ia);}};function Gb(a,b){Qb[a]={n:b}}function ec(a,b){var c="/"===b,d=!b,f;if(c&&Pb)throw new L(J.fa);if(!c&&!d){f=S(b,{Ia:!1});b=f.path;f=f.g;if(f.U)throw new L(J.fa);if(!N(f.mode))throw new L(J.ya);}var d={type:a,pa:{},Oa:b,lb:[]},g=a.A(d);g.A=d;d.root=g;c?Pb=g:f&&(f.U=d,f.A&&f.A.lb.push(d))} +function fc(a,b,c){var d=S(a,{parent:!0}).g;a=Bb(a);if(!a||"."===a||".."===a)throw new L(J.q);var f=ac(d,a);if(f)throw new L(f);if(!d.k.T)throw new L(J.I);return d.k.T(d,a,b,c)}function gc(a,b){b=(void 0!==b?b:438)&4095;b|=32768;return fc(a,b,0)}function V(a,b){b=(void 0!==b?b:511)&1023;b|=16384;return fc(a,b,0)}function hc(a,b,c){"undefined"===typeof c&&(c=b,b=438);return fc(a,b|8192,c)} +function ic(a,b){if(!Db(a))throw new L(J.F);var c=S(b,{parent:!0}).g;if(!c)throw new L(J.F);var d=Bb(b),f=ac(c,d);if(f)throw new L(f);if(!c.k.symlink)throw new L(J.I);return c.k.symlink(c,d,a)}function Vb(a){a=S(a).g;if(!a)throw new L(J.F);if(!a.k.readlink)throw new L(J.q);return Db(T(a.parent),a.k.readlink(a))}function jc(a,b){var c;"string"===typeof a?c=S(a,{la:!0}).g:c=a;if(!c.k.u)throw new L(J.I);c.k.u(c,{mode:b&4095|c.mode&-4096,timestamp:Date.now()})} +function kc(a,b){var c;if(""===a)throw new L(J.F);var d;if("string"===typeof b){if(d=$b[b],"undefined"===typeof d)throw Error("Unknown file open mode: "+b);}else d=b;b=d;c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;var f;if("object"===typeof a)f=a;else{a=zb(a);try{f=S(a,{la:!(b&131072)}).g}catch(g){}}d=!1;if(b&64)if(f){if(b&128)throw new L(J.wa);}else f=fc(a,c,0),d=!0;if(!f)throw new L(J.F);8192===(f.mode&61440)&&(b&=-513);if(b&65536&&!N(f.mode))throw new L(J.ya);if(!d&&(f?40960===(f.mode&61440)? +c=J.ga:N(f.mode)&&(0!==(b&2097155)||b&512)?c=J.P:(c=["r","w","rw"][b&3],b&512&&(c+="w"),c=Yb(f,c)):c=J.F,c))throw new L(c);if(b&512){c=f;var h;"string"===typeof c?h=S(c,{la:!0}).g:h=c;if(!h.k.u)throw new L(J.I);if(N(h.mode))throw new L(J.P);if(32768!==(h.mode&61440))throw new L(J.q);if(c=Yb(h,"w"))throw new L(c);h.k.u(h,{size:0,timestamp:Date.now()})}b&=-641;f=cc({g:f,path:T(f),flags:b,seekable:!0,position:0,n:f.n,tb:[],error:!1});f.n.open&&f.n.open(f);!e.logReadFiles||b&1||(lc||(lc={}),a in lc|| +(lc[a]=1,e.printErr("read file: "+a)));try{R.onOpenFile&&(h=0,1!==(b&2097155)&&(h|=1),0!==(b&2097155)&&(h|=2),R.onOpenFile(a,h))}catch(l){console.log("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+l.message)}return f}function mc(a){a.na&&(a.na=null);try{a.n.close&&a.n.close(a)}catch(b){throw b;}finally{Rb[a.fd]=null}}function nc(a,b,c){if(!a.seekable||!a.n.G)throw new L(J.ia);a.position=a.n.G(a,b,c);a.tb=[]} +function oc(a,b,c,d,f,g){if(0>d||0>f)throw new L(J.q);if(0===(a.flags&2097155))throw new L(J.ea);if(N(a.g.mode))throw new L(J.P);if(!a.n.write)throw new L(J.q);a.flags&1024&&nc(a,0,2);var h=!0;if("undefined"===typeof f)f=a.position,h=!1;else if(!a.seekable)throw new L(J.ia);b=a.n.write(a,b,c,d,f,g);h||(a.position+=b);try{if(a.path&&R.onWriteToFile)R.onWriteToFile(a.path)}catch(l){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+l.message)}return b} +function pc(){L||(L=function(a,b){this.g=b;this.qb=function(a){this.S=a;for(var b in J)if(J[b]===a){this.code=b;break}};this.qb(a);this.message=xb[a]},L.prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(a){Mb[a]=new L(a);Mb[a].stack=""}))}var qc;function rc(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}function sc(a,b,c,d){a=K("string"===typeof a?a:T(a),b);return gc(a,rc(c,d))} +function tc(a,b,c,d,f,g){a=b?K("string"===typeof a?a:T(a),b):a;d=rc(d,f);f=gc(a,d);if(c){if("string"===typeof c){a=Array(c.length);b=0;for(var h=c.length;b>2]}function xc(){var a;a=X();a=Rb[a];if(!a)throw new L(J.ea);return a}var yc={};e._i64Add=zc;function Ga(a){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var b=r;return 0==a||Ga.bb(a)?b:4294967295}var Ac=1;e._memcpy=Bc; +function Cc(a,b){Dc=a;Ec=b;if(!Fc)return 1;if(0==a)Y=function(){setTimeout(Gc,b)},Hc="timeout";else if(1==a)Y=function(){Ic(Gc)},Hc="rAF";else if(2==a){if(!window.setImmediate){var c=[];window.addEventListener("message",function(a){a.source===window&&"__emcc"===a.data&&(a.stopPropagation(),c.shift()())},!0);window.setImmediate=function(a){c.push(a);window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)};Hc="immediate"}return 0} +function Jc(a,b,c,d,f){e.noExitRuntime=!0;assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.");Fc=a;Kc=d;var g=Lc;Gc=function(){if(!na)if(0>h-6&63,h=h-6,c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[v];2==h?(c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(g&3)<<4],c+="=="):4==h&&(c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(g&15)<<2],c+="=");B.src="data:audio/x-"+b.substr(-3)+";base64,"+c;l(B)}};B.src=q;ad(function(){l(B)})}else return w()}});var c=e.canvas;c&&(c.sa=c.requestPointerLock||c.mozRequestPointerLock|| +c.webkitRequestPointerLock||c.msRequestPointerLock||function(){},c.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},c.Fa=c.Fa.bind(document),document.addEventListener("pointerlockchange",a,!1),document.addEventListener("mozpointerlockchange",a,!1),document.addEventListener("webkitpointerlockchange",a,!1),document.addEventListener("mspointerlockchange",a,!1),e.elementPointerLock&&c.addEventListener("click",function(a){!Tc&& +c.sa&&(c.sa(),a.preventDefault())},!1))}}function bd(a,b,c,d){if(b&&e.ka&&a==e.canvas)return e.ka;var f,g;if(b){g={antialias:!1,alpha:!1};if(d)for(var h in d)g[h]=d[h];if(g=GL.createContext(a,g))f=GL.getContext(g).td;a.style.backgroundColor="black"}else f=a.getContext("2d");if(!f)return null;c&&(b||assert("undefined"===typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=f,b&&GL.Od(g),e.Td=b,Uc.forEach(function(a){a()}),Vc());return f} +var cd=!1,dd=void 0,ed=void 0; +function fd(a,b,c){function d(){Sc=!1;var a=f.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===a?(f.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){}, +f.Da=f.Da.bind(document),dd&&f.sa(),Sc=!0,ed&&gd()):(a.parentNode.insertBefore(f,a),a.parentNode.removeChild(a),ed&&hd());if(e.onFullScreen)e.onFullScreen(Sc);id(f)}dd=a;ed=b;jd=c;"undefined"===typeof dd&&(dd=!0);"undefined"===typeof ed&&(ed=!1);"undefined"===typeof jd&&(jd=null);var f=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",d,!1),document.addEventListener("mozfullscreenchange",d,!1),document.addEventListener("webkitfullscreenchange",d,!1),document.addEventListener("MSFullscreenChange", +d,!1));var g=document.createElement("div");f.parentNode.insertBefore(g,f);g.appendChild(f);g.p=g.requestFullScreen||g.mozRequestFullScreen||g.msRequestFullscreen||(g.webkitRequestFullScreen?function(){g.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null);c?g.p({Ud:c}):g.p()}var kd=0;function ld(a){var b=Date.now();if(0===kd)kd=b+1E3/60;else for(;b+2>=kd;)kd+=1E3/60;b=Math.max(kd-b,0);setTimeout(a,b)} +function Ic(a){"undefined"===typeof window?ld(a):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(a))}function ad(a){e.noExitRuntime=!0;setTimeout(function(){na||a()},1E4)} +function $c(a){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[a.substr(a.lastIndexOf(".")+1)]}function md(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)} +function nd(a,b,c){md(a,function(c){assert(c,'Loading data file "'+a+'" failed (no arrayBuffer).');b(new Uint8Array(c));lb()},function(){if(c)c();else throw'Loading data file "'+a+'" failed.';});kb()}var od=[];function pd(){var a=e.canvas;od.forEach(function(b){b(a.width,a.height)})}function gd(){if("undefined"!=typeof SDL){var a=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=a|8388608}pd()} +function hd(){if("undefined"!=typeof SDL){var a=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=a&-8388609}pd()} +function id(a,b,c){b&&c?(a.ub=b,a.hb=c):(b=a.ub,c=a.hb);var d=b,f=c;e.forcedAspectRatio&&0this.length-1||0>a)){var b=a%this.chunkSize;return this.gb(a/this.chunkSize|0)[b]}};l.prototype.pb=function(a){this.gb=a};l.prototype.Ca=function(){var a=new XMLHttpRequest;a.open("HEAD",c,!1);a.send(null);if(!(200<=a.status&&300>a.status||304===a.status))throw Error("Couldn't load "+c+". Status: "+a.status);var b=Number(a.getResponseHeader("Content-length")),d,f=1048576;(d=a.getResponseHeader("Accept-Ranges"))&& +"bytes"===d||(f=b);var g=this;g.pb(function(a){var d=a*f,h=(a+1)*f-1,h=Math.min(h,b-1);if("undefined"===typeof g.Y[a]){var l=g.Y;if(d>h)throw Error("invalid range ("+d+", "+h+") or no bytes requested!");if(h>b-1)throw Error("only "+b+" bytes available! programmer error!");var q=new XMLHttpRequest;q.open("GET",c,!1);b!==f&&q.setRequestHeader("Range","bytes="+d+"-"+h);"undefined"!=typeof Uint8Array&&(q.responseType="arraybuffer");q.overrideMimeType&&q.overrideMimeType("text/plain; charset=x-user-defined"); +q.send(null);if(!(200<=q.status&&300>q.status||304===q.status))throw Error("Couldn't load "+c+". Status: "+q.status);d=void 0!==q.response?new Uint8Array(q.response||[]):hb(q.responseText||"",!0);l[a]=d}if("undefined"===typeof g.Y[a])throw Error("doXHR failed!");return g.Y[a]});this.Wa=b;this.Va=f;this.oa=!0};if("undefined"!==typeof XMLHttpRequest){if(!ca)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";g=new l;Object.defineProperty(g, +"length",{get:function(){this.oa||this.Ca();return this.Wa}});Object.defineProperty(g,"chunkSize",{get:function(){this.oa||this.Ca();return this.Va}});h=void 0}else h=c,g=void 0;var w=sc(a,b,d,f);g?w.e=g:h&&(w.e=null,w.url=h);Object.defineProperty(w,"usedBytes",{get:function(){return this.e.length}});var u={};Object.keys(w.n).forEach(function(a){var b=w.n[a];u[a]=function(){if(!uc(w))throw new L(J.H);return b.apply(null,arguments)}});u.read=function(a,b,c,d,f){if(!uc(w))throw new L(J.H);a=a.g.e;if(f>= +a.length)return 0;d=Math.min(a.length-f,d);assert(0<=d);if(a.slice)for(var g=0;g>2]=0;case 21520:return c.tty?-J.q:-J.Q;case 21531:f=X();if(!c.n.ib)throw new L(J.Q);return c.n.ib(c,d,f);default:x("bad ioctl syscall "+d)}}catch(g){return"undefined"!==typeof vc&&g instanceof L||x(g),-g.S}},___syscall6:function(a,b){wc=b;try{var c=xc();mc(c);return 0}catch(d){return"undefined"!==typeof vc&&d instanceof L||x(d),-d.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(a){tb.p--;ub.push(a);var b; +a:{if(a&&!vb[a])for(b in vb)if(vb[b].wd===a)break a;b=a}b&&vb[b].Sd++;return a},_emscripten_memcpy_big:function(a,b,c){E.set(E.subarray(b,b+c),a);return a},_sysconf:function(a){switch(a){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809; +case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32; +case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1E3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"===typeof navigator?navigator.hardwareConcurrency||1:1}ob(J.q);return-1}, +_pthread_getspecific:function(a){return yc[a]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(a){if(0==a)return J.q;C[a>>2]=Ac;yc[Ac]=0;Ac++;return 0},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(a,b){if(!(a in yc))return J.q;yc[a]=b;return 0},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(a){var b=Date.now()/1E3|0;a&&(C[a>>2]=b);return b},___syscall140:function(a,b){wc=b;try{var c= +xc(),d=X(),f=X(),g=X(),h=X();assert(0===d);nc(c,f,h);C[g>>2]=c.position;c.na&&0===f&&0===h&&(c.na=null);return 0}catch(l){return"undefined"!==typeof vc&&l instanceof L||x(l),-l.S}},___syscall146:function(a,b){wc=b;try{var c=xc(),d=X(),f;a:{for(var g=X(),h=0,l=0;l>2],C[d+(8*l+4)>>2],void 0);if(0>w){f=-1;break a}h+=w}f=h}return f}catch(u){return"undefined"!==typeof vc&&u instanceof L||x(u),-u.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};// EMSCRIPTEN_START_ASM + +var Z=(function(global,env,buffer) { +"use asm";var a=global.Int8Array;var b=global.Int16Array;var c=global.Int32Array;var d=global.Uint8Array;var e=global.Uint16Array;var f=global.Uint32Array;var g=global.Float32Array;var h=global.Float64Array;var i=new a(buffer);var j=new b(buffer);var k=new c(buffer);var l=new d(buffer);var m=new e(buffer);var n=new f(buffer);var o=new g(buffer);var p=new h(buffer);var q=global.byteLength;var r=env.STACKTOP|0;var s=env.STACK_MAX|0;var t=env.tempDoublePtr|0;var u=env.ABORT|0;var v=env.cttz_i8|0;var w=0;var x=0;var y=0;var z=0;var A=global.NaN,B=global.Infinity;var C=0,D=0,E=0,F=0,G=0.0,H=0,I=0,J=0,K=0.0;var L=0;var M=0;var N=0;var O=0;var P=0;var Q=0;var R=0;var S=0;var T=0;var U=0;var V=global.Math.floor;var W=global.Math.abs;var X=global.Math.sqrt;var Y=global.Math.pow;var Z=global.Math.cos;var _=global.Math.sin;var $=global.Math.tan;var aa=global.Math.acos;var ba=global.Math.asin;var ca=global.Math.atan;var da=global.Math.atan2;var ea=global.Math.exp;var fa=global.Math.log;var ga=global.Math.ceil;var ha=global.Math.imul;var ia=global.Math.min;var ja=global.Math.clz32;var ka=env.abort;var la=env.assert;var ma=env.invoke_iiii;var na=env.invoke_viiiii;var oa=env.invoke_vi;var pa=env.invoke_ii;var qa=env.invoke_viii;var ra=env.invoke_v;var sa=env.invoke_viiiiii;var ta=env.invoke_iiiiii;var ua=env.invoke_viiii;var va=env._pthread_cleanup_pop;var wa=env.___syscall54;var xa=env.___syscall6;var ya=env._emscripten_set_main_loop_timing;var za=env.__ZSt18uncaught_exceptionv;var Aa=env.___setErrNo;var Ba=env._sbrk;var Ca=env.___cxa_begin_catch;var Da=env._emscripten_memcpy_big;var Ea=env._sysconf;var Fa=env._pthread_getspecific;var Ga=env._pthread_self;var Ha=env._pthread_once;var Ia=env._pthread_key_create;var Ja=env.___unlock;var Ka=env._emscripten_set_main_loop;var La=env._pthread_setspecific;var Ma=env.___lock;var Na=env._abort;var Oa=env._pthread_cleanup_push;var Pa=env._time;var Qa=env.___syscall140;var Ra=env.___syscall146;var Sa=0.0;function Ta(newBuffer){if(q(newBuffer)&16777215||q(newBuffer)<=16777215||q(newBuffer)>2147483648)return false;i=new a(newBuffer);j=new b(newBuffer);k=new c(newBuffer);l=new d(newBuffer);m=new e(newBuffer);n=new f(newBuffer);o=new g(newBuffer);p=new h(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function bb(a){a=a|0;var b=0;b=r;r=r+a|0;r=r+15&-16;return b|0}function cb(){return r|0}function db(a){a=a|0;r=a}function eb(a,b){a=a|0;b=b|0;r=a;s=b}function fb(a,b){a=a|0;b=b|0;if(!w){w=a;x=b}}function gb(a){a=a|0;i[t>>0]=i[a>>0];i[t+1>>0]=i[a+1>>0];i[t+2>>0]=i[a+2>>0];i[t+3>>0]=i[a+3>>0]}function hb(a){a=a|0;i[t>>0]=i[a>>0];i[t+1>>0]=i[a+1>>0];i[t+2>>0]=i[a+2>>0];i[t+3>>0]=i[a+3>>0];i[t+4>>0]=i[a+4>>0];i[t+5>>0]=i[a+5>>0];i[t+6>>0]=i[a+6>>0];i[t+7>>0]=i[a+7>>0]}function ib(a){a=a|0;L=a}function jb(){return L|0}function kb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+608|0;n=q+88|0;m=q+72|0;i=q+64|0;h=q+48|0;g=q+24|0;f=q;l=q+96|0;o=q+92|0;j=a+4|0;p=a+8|0;if((k[j>>2]|0)>>>0>(k[p>>2]|0)>>>0){k[f>>2]=1154;k[f+4>>2]=2120;k[f+8>>2]=1133;Ac(l,1100,f)|0;zc(l,q+16|0)|0}if((2147418112/(d>>>0)|0)>>>0<=b>>>0){k[g>>2]=1154;k[g+4>>2]=2121;k[g+8>>2]=1169;Ac(l,1100,g)|0;zc(l,q+40|0)|0}g=k[p>>2]|0;if(g>>>0>=b>>>0){p=1;r=q;return p|0}do if(c){if(b){f=b+-1|0;if(!(f&b)){f=11;break}else b=f}else b=-1;b=b>>>16|b;b=b>>>8|b;b=b>>>4|b;b=b>>>2|b;b=(b>>>1|b)+1|0;f=10}else f=10;while(0);if((f|0)==10)if(!b){b=0;f=12}else f=11;if((f|0)==11)if(b>>>0<=g>>>0)f=12;if((f|0)==12){k[h>>2]=1154;k[h+4>>2]=2130;k[h+8>>2]=1217;Ac(l,1100,h)|0;zc(l,i)|0}c=ha(b,d)|0;do if(!e){f=lb(k[a>>2]|0,c,o,1)|0;if(!f){p=0;r=q;return p|0}else{k[a>>2]=f;break}}else{g=mb(c,o)|0;if(!g){p=0;r=q;return p|0}Ya[e&0](g,k[a>>2]|0,k[j>>2]|0);f=k[a>>2]|0;do if(f)if(!(f&7)){$a[k[104>>2]&1](f,0,0,1,k[27]|0)|0;break}else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(l,1100,m)|0;zc(l,n)|0;break}while(0);k[a>>2]=g}while(0);f=k[o>>2]|0;if(f>>>0>c>>>0)b=(f>>>0)/(d>>>0)|0;k[p>>2]=b;p=1;r=q;return p|0}function lb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=r;r=r+592|0;i=j+48|0;f=j+24|0;e=j;h=j+72|0;g=j+68|0;if(a&7){k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1494;Ac(h,1100,e)|0;zc(h,j+16|0)|0;i=0;r=j;return i|0}if(b>>>0>2147418112){k[f>>2]=1154;k[f+4>>2]=2499;k[f+8>>2]=1387;Ac(h,1100,f)|0;zc(h,j+40|0)|0;i=0;r=j;return i|0}k[g>>2]=b;d=$a[k[104>>2]&1](a,b,g,d,k[27]|0)|0;if(c)k[c>>2]=k[g>>2];if(!(d&7)){i=d;r=j;return i|0}k[i>>2]=1154;k[i+4>>2]=2551;k[i+8>>2]=1440;Ac(h,1100,i)|0;zc(h,j+64|0)|0;i=d;r=j;return i|0}function mb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;i=r;r=r+592|0;g=i+48|0;h=i+24|0;c=i;f=i+72|0;e=i+68|0;d=a+3&-4;d=(d|0)!=0?d:4;if(d>>>0>2147418112){k[c>>2]=1154;k[c+4>>2]=2499;k[c+8>>2]=1387;Ac(f,1100,c)|0;zc(f,i+16|0)|0;h=0;r=i;return h|0}k[e>>2]=d;c=$a[k[104>>2]&1](0,d,e,1,k[27]|0)|0;a=k[e>>2]|0;if(b)k[b>>2]=a;if((c|0)==0|a>>>0>>0){k[h>>2]=1154;k[h+4>>2]=2499;k[h+8>>2]=1413;Ac(f,1100,h)|0;zc(f,i+40|0)|0;h=0;r=i;return h|0}if(!(c&7)){h=c;r=i;return h|0}k[g>>2]=1154;k[g+4>>2]=2526;k[g+8>>2]=1440;Ac(f,1100,g)|0;zc(f,i+64|0)|0;h=c;r=i;return h|0}function nb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;S=r;r=r+960|0;P=S+232|0;O=S+216|0;N=S+208|0;M=S+192|0;L=S+184|0;K=S+168|0;J=S+160|0;I=S+144|0;F=S+136|0;E=S+120|0;D=S+112|0;C=S+96|0;z=S+88|0;y=S+72|0;x=S+64|0;w=S+48|0;q=S+40|0;t=S+24|0;s=S+16|0;p=S;H=S+440|0;Q=S+376|0;R=S+304|0;v=S+236|0;if((b|0)==0|d>>>0>11){a=0;r=S;return a|0}k[a>>2]=b;e=R;f=e+68|0;do{k[e>>2]=0;e=e+4|0}while((e|0)<(f|0));f=0;do{e=i[c+f>>0]|0;if(e<<24>>24){G=R+((e&255)<<2)|0;k[G>>2]=(k[G>>2]|0)+1}f=f+1|0}while((f|0)!=(b|0));f=0;o=1;g=0;h=-1;n=0;while(1){e=k[R+(o<<2)>>2]|0;if(!e)k[a+28+(o+-1<<2)>>2]=0;else{G=o+-1|0;k[Q+(G<<2)>>2]=f;f=e+f|0;B=16-o|0;k[a+28+(G<<2)>>2]=(f+-1<>2]=n;k[v+(o<<2)>>2]=n;g=g>>>0>o>>>0?g:o;h=h>>>0>>0?h:o;n=e+n|0}o=o+1|0;if((o|0)==17){G=g;break}else f=f<<1}k[a+4>>2]=n;f=a+172|0;do if(n>>>0>(k[f>>2]|0)>>>0){k[f>>2]=n;if(n){e=n+-1|0;if(e&n)u=14}else{e=-1;u=14}if((u|0)==14){B=e>>>16|e;B=B>>>8|B;B=B>>>4|B;B=B>>>2|B;B=(B>>>1|B)+1|0;k[f>>2]=B>>>0>b>>>0?b:B}g=a+176|0;e=k[g>>2]|0;do if(e){B=k[e+-4>>2]|0;e=e+-8|0;if(!((B|0)!=0?(B|0)==(~k[e>>2]|0):0)){k[p>>2]=1154;k[p+4>>2]=644;k[p+8>>2]=1863;Ac(H,1100,p)|0;zc(H,s)|0}if(!(e&7)){$a[k[104>>2]&1](e,0,0,1,k[27]|0)|0;break}else{k[t>>2]=1154;k[t+4>>2]=2499;k[t+8>>2]=1516;Ac(H,1100,t)|0;zc(H,q)|0;break}}while(0);f=k[f>>2]|0;f=(f|0)!=0?f:1;e=mb((f<<1)+8|0,0)|0;if(!e){k[g>>2]=0;e=0;break}else{k[e+4>>2]=f;k[e>>2]=~f;k[g>>2]=e+8;u=25;break}}else u=25;while(0);a:do if((u|0)==25){B=a+24|0;i[B>>0]=h;i[a+25>>0]=G;f=a+176|0;g=0;do{A=i[c+g>>0]|0;e=A&255;if(A<<24>>24){if(!(k[R+(e<<2)>>2]|0)){k[w>>2]=1154;k[w+4>>2]=2273;k[w+8>>2]=1261;Ac(H,1100,w)|0;zc(H,x)|0}A=v+(e<<2)|0;e=k[A>>2]|0;k[A>>2]=e+1;if(e>>>0>=n>>>0){k[y>>2]=1154;k[y+4>>2]=2277;k[y+8>>2]=1274;Ac(H,1100,y)|0;zc(H,z)|0}j[(k[f>>2]|0)+(e<<1)>>1]=g}g=g+1|0}while((g|0)!=(b|0));e=i[B>>0]|0;z=(e&255)>>>0>>0?d:0;A=a+8|0;k[A>>2]=z;y=(z|0)!=0;if(y){x=1<>>0>(k[e>>2]|0)>>>0){k[e>>2]=x;g=a+168|0;e=k[g>>2]|0;do if(e){w=k[e+-4>>2]|0;e=e+-8|0;if(!((w|0)!=0?(w|0)==(~k[e>>2]|0):0)){k[C>>2]=1154;k[C+4>>2]=644;k[C+8>>2]=1863;Ac(H,1100,C)|0;zc(H,D)|0}if(!(e&7)){$a[k[104>>2]&1](e,0,0,1,k[27]|0)|0;break}else{k[E>>2]=1154;k[E+4>>2]=2499;k[E+8>>2]=1516;Ac(H,1100,E)|0;zc(H,F)|0;break}}while(0);e=x<<2;f=mb(e+8|0,0)|0;if(!f){k[g>>2]=0;e=0;break a}else{F=f+8|0;k[f+4>>2]=x;k[f>>2]=~x;k[g>>2]=F;f=F;break}}else{f=a+168|0;e=x<<2;g=f;f=k[f>>2]|0}while(0);ad(f|0,-1,e|0)|0;u=a+176|0;w=1;do{if(k[R+(w<<2)>>2]|0){b=z-w|0;v=1<>2]|0;if(f>>>0>=16){k[I>>2]=1154;k[I+4>>2]=1953;k[I+8>>2]=1737;Ac(H,1100,I)|0;zc(H,J)|0}e=k[a+28+(f<<2)>>2]|0;if(!e)t=-1;else t=(e+-1|0)>>>(16-w|0);if(h>>>0<=t>>>0){q=(k[a+96+(f<<2)>>2]|0)-h|0;s=w<<16;do{e=m[(k[u>>2]|0)+(q+h<<1)>>1]|0;if((l[c+e>>0]|0|0)!=(w|0)){k[K>>2]=1154;k[K+4>>2]=2319;k[K+8>>2]=1303;Ac(H,1100,K)|0;zc(H,L)|0}p=h<>>0>=x>>>0){k[M>>2]=1154;k[M+4>>2]=2325;k[M+8>>2]=1337;Ac(H,1100,M)|0;zc(H,N)|0}e=k[g>>2]|0;if((k[e+(n<<2)>>2]|0)!=-1){k[O>>2]=1154;k[O+4>>2]=2327;k[O+8>>2]=1360;Ac(H,1100,O)|0;zc(H,P)|0;e=k[g>>2]|0}k[e+(n<<2)>>2]=f;o=o+1|0}while(o>>>0>>0);h=h+1|0}while(h>>>0<=t>>>0)}}w=w+1|0}while(z>>>0>=w>>>0);e=i[B>>0]|0}f=a+96|0;k[f>>2]=(k[f>>2]|0)-(k[Q>>2]|0);f=a+100|0;k[f>>2]=(k[f>>2]|0)-(k[Q+4>>2]|0);f=a+104|0;k[f>>2]=(k[f>>2]|0)-(k[Q+8>>2]|0);f=a+108|0;k[f>>2]=(k[f>>2]|0)-(k[Q+12>>2]|0);f=a+112|0;k[f>>2]=(k[f>>2]|0)-(k[Q+16>>2]|0);f=a+116|0;k[f>>2]=(k[f>>2]|0)-(k[Q+20>>2]|0);f=a+120|0;k[f>>2]=(k[f>>2]|0)-(k[Q+24>>2]|0);f=a+124|0;k[f>>2]=(k[f>>2]|0)-(k[Q+28>>2]|0);f=a+128|0;k[f>>2]=(k[f>>2]|0)-(k[Q+32>>2]|0);f=a+132|0;k[f>>2]=(k[f>>2]|0)-(k[Q+36>>2]|0);f=a+136|0;k[f>>2]=(k[f>>2]|0)-(k[Q+40>>2]|0);f=a+140|0;k[f>>2]=(k[f>>2]|0)-(k[Q+44>>2]|0);f=a+144|0;k[f>>2]=(k[f>>2]|0)-(k[Q+48>>2]|0);f=a+148|0;k[f>>2]=(k[f>>2]|0)-(k[Q+52>>2]|0);f=a+152|0;k[f>>2]=(k[f>>2]|0)-(k[Q+56>>2]|0);f=a+156|0;k[f>>2]=(k[f>>2]|0)-(k[Q+60>>2]|0);f=a+16|0;k[f>>2]=0;g=a+20|0;k[g>>2]=e&255;b:do if(y){while(1){if(!d)break b;e=d+-1|0;if(!(k[R+(d<<2)>>2]|0))d=e;else break}k[f>>2]=k[a+28+(e<<2)>>2];e=z+1|0;k[g>>2]=e;if(e>>>0<=G>>>0){while(1){if(k[R+(e<<2)>>2]|0)break;e=e+1|0;if(e>>>0>G>>>0)break b}k[g>>2]=e}}while(0);k[a+92>>2]=-1;k[a+160>>2]=1048575;k[a+12>>2]=32-(k[A>>2]|0);e=1}while(0);a=e;r=S;return a|0}function ob(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;if(!a){e=Uc(b)|0;if(!c){c=e;return c|0}if(!e)f=0;else f=Xc(e)|0;k[c>>2]=f;c=e;return c|0}if(!b){Vc(a);if(!c){c=0;return c|0}k[c>>2]=0;c=0;return c|0}e=Wc(a,b)|0;f=(e|0)!=0;if(f|d^1)f=f?e:a;else{e=Wc(a,b)|0;f=(e|0)==0?a:e}if(!c){c=e;return c|0}b=Xc(f)|0;k[c>>2]=b;c=e;return c|0}function pb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!((a|0)!=0&b>>>0>73&(c|0)!=0)){c=0;return c|0}if((k[c>>2]|0)!=40|b>>>0<74){c=0;return c|0}if(((l[a>>0]|0)<<8|(l[a+1>>0]|0)|0)!=18552){c=0;return c|0}if(((l[a+2>>0]|0)<<8|(l[a+3>>0]|0))>>>0<74){c=0;return c|0}if(((l[a+7>>0]|0)<<16|(l[a+6>>0]|0)<<24|(l[a+8>>0]|0)<<8|(l[a+9>>0]|0))>>>0>b>>>0){c=0;return c|0}k[c+4>>2]=(l[a+12>>0]|0)<<8|(l[a+13>>0]|0);k[c+8>>2]=(l[a+14>>0]|0)<<8|(l[a+15>>0]|0);k[c+12>>2]=l[a+16>>0];k[c+16>>2]=l[a+17>>0];b=a+18|0;d=c+32|0;k[d>>2]=l[b>>0];k[d+4>>2]=0;b=i[b>>0]|0;k[c+20>>2]=b<<24>>24==0|b<<24>>24==9?8:16;k[c+24>>2]=(l[a+26>>0]|0)<<16|(l[a+25>>0]|0)<<24|(l[a+27>>0]|0)<<8|(l[a+28>>0]|0);k[c+28>>2]=(l[a+30>>0]|0)<<16|(l[a+29>>0]|0)<<24|(l[a+31>>0]|0)<<8|(l[a+32>>0]|0);c=1;return c|0}function qb(a){a=a|0;Ca(a|0)|0;Vb()}function rb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;f=r;r=r+544|0;e=f;d=f+24|0;b=k[a+20>>2]|0;if(b)sb(b);b=a+4|0;c=k[b>>2]|0;if(!c){e=a+16|0;i[e>>0]=0;r=f;return}if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1516;Ac(d,1100,e)|0;zc(d,f+16|0)|0}k[b>>2]=0;k[a+8>>2]=0;k[a+12>>2]=0;e=a+16|0;i[e>>0]=0;r=f;return}function sb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;o=r;r=r+640|0;n=o+112|0;m=o+96|0;l=o+88|0;j=o+72|0;i=o+64|0;h=o+48|0;d=o+40|0;f=o+24|0;e=o+16|0;c=o;g=o+120|0;if(!a){r=o;return}b=k[a+168>>2]|0;do if(b){p=k[b+-4>>2]|0;b=b+-8|0;if(!((p|0)!=0?(p|0)==(~k[b>>2]|0):0)){k[c>>2]=1154;k[c+4>>2]=644;k[c+8>>2]=1863;Ac(g,1100,c)|0;zc(g,e)|0}if(!(b&7)){$a[k[104>>2]&1](b,0,0,1,k[27]|0)|0;break}else{k[f>>2]=1154;k[f+4>>2]=2499;k[f+8>>2]=1516;Ac(g,1100,f)|0;zc(g,d)|0;break}}while(0);b=k[a+176>>2]|0;do if(b){p=k[b+-4>>2]|0;b=b+-8|0;if(!((p|0)!=0?(p|0)==(~k[b>>2]|0):0)){k[h>>2]=1154;k[h+4>>2]=644;k[h+8>>2]=1863;Ac(g,1100,h)|0;zc(g,i)|0}if(!(b&7)){$a[k[104>>2]&1](b,0,0,1,k[27]|0)|0;break}else{k[j>>2]=1154;k[j+4>>2]=2499;k[j+8>>2]=1516;Ac(g,1100,j)|0;zc(g,l)|0;break}}while(0);if(!(a&7)){$a[k[104>>2]&1](a,0,0,1,k[27]|0)|0;r=o;return}else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(g,1100,m)|0;zc(g,n)|0;r=o;return}}function tb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0;l=r;r=r+560|0;g=l+40|0;h=l+24|0;b=l;f=l+48|0;e=a+8|0;c=k[e>>2]|0;if((c+-1|0)>>>0>=8192){k[b>>2]=1154;k[b+4>>2]=2997;k[b+8>>2]=1541;Ac(f,1100,b)|0;zc(f,l+16|0)|0}k[a>>2]=c;d=a+20|0;b=k[d>>2]|0;if(!b){b=mb(180,0)|0;if(!b)b=0;else{j=b+164|0;k[j>>2]=0;k[j+4>>2]=0;k[j+8>>2]=0;k[j+12>>2]=0}k[d>>2]=b;j=b;i=k[a>>2]|0}else{j=b;i=c}if(!(k[e>>2]|0)){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(f,1100,h)|0;zc(f,g)|0;f=k[a>>2]|0}else f=i;e=k[a+4>>2]|0;if(f>>>0>16){c=f;b=0}else{a=0;j=nb(j,i,e,a)|0;r=l;return j|0}while(1){d=b+1|0;if(c>>>0>3){c=c>>>1;b=d}else{c=d;break}}a=b+2+((c|0)!=32&1<>>0>>0&1)|0;a=a>>>0<11?a&255:11;j=nb(j,i,e,a)|0;r=l;return j|0}function ub(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;N=r;r=r+800|0;I=N+256|0;H=N+240|0;G=N+232|0;F=N+216|0;E=N+208|0;D=N+192|0;C=N+184|0;B=N+168|0;A=N+160|0;z=N+144|0;y=N+136|0;x=N+120|0;w=N+112|0;v=N+96|0;u=N+88|0;t=N+72|0;o=N+64|0;n=N+48|0;h=N+40|0;j=N+24|0;f=N+16|0;e=N;L=N+288|0;M=N+264|0;J=vb(a,14)|0;if(!J){k[b>>2]=0;c=b+4|0;d=k[c>>2]|0;if(d){if(!(d&7))$a[k[104>>2]&1](d,0,0,1,k[27]|0)|0;else{k[e>>2]=1154;k[e+4>>2]=2499;k[e+8>>2]=1516;Ac(L,1100,e)|0;zc(L,f)|0}k[c>>2]=0;k[b+8>>2]=0;k[b+12>>2]=0}i[b+16>>0]=0;c=b+20|0;d=k[c>>2]|0;if(!d){b=1;r=N;return b|0}sb(d);k[c>>2]=0;b=1;r=N;return b|0}q=b+4|0;s=b+8|0;c=k[s>>2]|0;if((c|0)!=(J|0)){if(c>>>0<=J>>>0){do if((k[b+12>>2]|0)>>>0>>0){if(kb(q,J,(c+1|0)==(J|0),1,0)|0){c=k[s>>2]|0;break}i[b+16>>0]=1;b=0;r=N;return b|0}while(0);ad((k[q>>2]|0)+c|0,0,J-c|0)|0}k[s>>2]=J}ad(k[q>>2]|0,0,J|0)|0;p=a+20|0;c=k[p>>2]|0;if((c|0)<5){f=a+4|0;g=a+8|0;e=a+16|0;do{d=k[f>>2]|0;if((d|0)==(k[g>>2]|0))d=0;else{k[f>>2]=d+1;d=l[d>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[j>>2]=1154;k[j+4>>2]=3199;k[j+8>>2]=1650;Ac(L,1100,j)|0;zc(L,h)|0;c=k[p>>2]|0}d=d<<32-c|k[e>>2];k[e>>2]=d}while((c|0)<5)}else{d=a+16|0;e=d;d=k[d>>2]|0}m=d>>>27;k[e>>2]=d<<5;k[p>>2]=c+-5;if((m+-1|0)>>>0>20){b=0;r=N;return b|0}k[M+20>>2]=0;k[M>>2]=0;k[M+4>>2]=0;k[M+8>>2]=0;k[M+12>>2]=0;i[M+16>>0]=0;c=M+4|0;d=M+8|0;a:do if(kb(c,21,0,1,0)|0){h=k[d>>2]|0;j=k[c>>2]|0;ad(j+h|0,0,21-h|0)|0;k[d>>2]=21;if(m){e=a+4|0;f=a+8|0;g=a+16|0;h=0;do{c=k[p>>2]|0;if((c|0)<3)do{d=k[e>>2]|0;if((d|0)==(k[f>>2]|0))d=0;else{k[e>>2]=d+1;d=l[d>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[n>>2]=1154;k[n+4>>2]=3199;k[n+8>>2]=1650;Ac(L,1100,n)|0;zc(L,o)|0;c=k[p>>2]|0}d=d<<32-c|k[g>>2];k[g>>2]=d}while((c|0)<3);else d=k[g>>2]|0;k[g>>2]=d<<3;k[p>>2]=c+-3;i[j+(l[1611+h>>0]|0)>>0]=d>>>29;h=h+1|0}while((h|0)!=(m|0))}if(tb(M)|0){h=a+4|0;j=a+8|0;m=a+16|0;d=0;b:while(1){g=J-d|0;c=wb(a,M)|0;c:do if(c>>>0<17){if((k[s>>2]|0)>>>0<=d>>>0){k[t>>2]=1154;k[t+4>>2]=903;k[t+8>>2]=1781;Ac(L,1100,t)|0;zc(L,u)|0}i[(k[q>>2]|0)+d>>0]=c;c=d+1|0}else switch(c|0){case 17:{c=k[p>>2]|0;if((c|0)<3)do{e=k[h>>2]|0;if((e|0)==(k[j>>2]|0))e=0;else{k[h>>2]=e+1;e=l[e>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[v>>2]=1154;k[v+4>>2]=3199;k[v+8>>2]=1650;Ac(L,1100,v)|0;zc(L,w)|0;c=k[p>>2]|0}e=e<<32-c|k[m>>2];k[m>>2]=e}while((c|0)<3);else e=k[m>>2]|0;k[m>>2]=e<<3;k[p>>2]=c+-3;c=(e>>>29)+3|0;if(c>>>0>g>>>0){c=0;break a}c=c+d|0;break c}case 18:{c=k[p>>2]|0;if((c|0)<7)do{e=k[h>>2]|0;if((e|0)==(k[j>>2]|0))e=0;else{k[h>>2]=e+1;e=l[e>>0]|0}c=c+8|0;k[p>>2]=c;if((c|0)>=33){k[x>>2]=1154;k[x+4>>2]=3199;k[x+8>>2]=1650;Ac(L,1100,x)|0;zc(L,y)|0;c=k[p>>2]|0}e=e<<32-c|k[m>>2];k[m>>2]=e}while((c|0)<7);else e=k[m>>2]|0;k[m>>2]=e<<7;k[p>>2]=c+-7;c=(e>>>25)+11|0;if(c>>>0>g>>>0){c=0;break a}c=c+d|0;break c}default:{if((c+-19|0)>>>0>=2){K=90;break b}f=k[p>>2]|0;if((c|0)==19){if((f|0)<2){e=f;while(1){c=k[h>>2]|0;if((c|0)==(k[j>>2]|0))f=0;else{k[h>>2]=c+1;f=l[c>>0]|0}c=e+8|0;k[p>>2]=c;if((c|0)>=33){k[z>>2]=1154;k[z+4>>2]=3199;k[z+8>>2]=1650;Ac(L,1100,z)|0;zc(L,A)|0;c=k[p>>2]|0}e=f<<32-c|k[m>>2];k[m>>2]=e;if((c|0)<2)e=c;else break}}else{e=k[m>>2]|0;c=f}k[m>>2]=e<<2;k[p>>2]=c+-2;f=(e>>>30)+3|0}else{if((f|0)<6){e=f;while(1){c=k[h>>2]|0;if((c|0)==(k[j>>2]|0))f=0;else{k[h>>2]=c+1;f=l[c>>0]|0}c=e+8|0;k[p>>2]=c;if((c|0)>=33){k[B>>2]=1154;k[B+4>>2]=3199;k[B+8>>2]=1650;Ac(L,1100,B)|0;zc(L,C)|0;c=k[p>>2]|0}e=f<<32-c|k[m>>2];k[m>>2]=e;if((c|0)<6)e=c;else break}}else{e=k[m>>2]|0;c=f}k[m>>2]=e<<6;k[p>>2]=c+-6;f=(e>>>26)+7|0}if((d|0)==0|f>>>0>g>>>0){c=0;break a}c=d+-1|0;if((k[s>>2]|0)>>>0<=c>>>0){k[D>>2]=1154;k[D+4>>2]=903;k[D+8>>2]=1781;Ac(L,1100,D)|0;zc(L,E)|0}e=i[(k[q>>2]|0)+c>>0]|0;if(!(e<<24>>24)){c=0;break a}c=f+d|0;if(d>>>0>=c>>>0){c=d;break c}do{if((k[s>>2]|0)>>>0<=d>>>0){k[F>>2]=1154;k[F+4>>2]=903;k[F+8>>2]=1781;Ac(L,1100,F)|0;zc(L,G)|0}i[(k[q>>2]|0)+d>>0]=e;d=d+1|0}while((d|0)!=(c|0))}}while(0);if(J>>>0>c>>>0)d=c;else break}if((K|0)==90){k[H>>2]=1154;k[H+4>>2]=3140;k[H+8>>2]=1632;Ac(L,1100,H)|0;zc(L,I)|0;c=0;break}if((J|0)==(c|0))c=tb(b)|0;else c=0}else c=0}else{i[M+16>>0]=1;c=0}while(0);rb(M);b=c;r=N;return b|0}function vb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+544|0;h=m+16|0;g=m;f=m+24|0;if(!b){j=0;r=m;return j|0}if(b>>>0<=16){j=xb(a,b)|0;r=m;return j|0}i=xb(a,b+-16|0)|0;j=a+20|0;b=k[j>>2]|0;if((b|0)<16){d=a+4|0;e=a+8|0;c=a+16|0;do{a=k[d>>2]|0;if((a|0)==(k[e>>2]|0))a=0;else{k[d>>2]=a+1;a=l[a>>0]|0}b=b+8|0;k[j>>2]=b;if((b|0)>=33){k[g>>2]=1154;k[g+4>>2]=3199;k[g+8>>2]=1650;Ac(f,1100,g)|0;zc(f,h)|0;b=k[j>>2]|0}a=a<<32-b|k[c>>2];k[c>>2]=a}while((b|0)<16)}else{a=a+16|0;c=a;a=k[a>>2]|0}k[c>>2]=a<<16;k[j>>2]=b+-16;j=a>>>16|i<<16;r=m;return j|0}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0;x=r;r=r+608|0;t=x+88|0;s=x+72|0;p=x+64|0;o=x+48|0;n=x+40|0;q=x+24|0;j=x+16|0;i=x;v=x+96|0;u=k[b+20>>2]|0;w=a+20|0;h=k[w>>2]|0;do if((h|0)<24){g=a+4|0;d=k[g>>2]|0;e=k[a+8>>2]|0;c=d>>>0>>0;if((h|0)>=16){if(c){k[g>>2]=d+1;c=l[d>>0]|0}else c=0;k[w>>2]=h+8;g=a+16|0;f=c<<24-h|k[g>>2];k[g>>2]=f;break}if(c){f=(l[d>>0]|0)<<8;c=d+1|0}else{f=0;c=d}if(c>>>0>>0){d=l[c>>0]|0;c=c+1|0}else d=0;k[g>>2]=c;k[w>>2]=h+16;g=a+16|0;f=(d|f)<<16-h|k[g>>2];k[g>>2]=f}else{f=a+16|0;g=f;f=k[f>>2]|0}while(0);e=(f>>>16)+1|0;do if(e>>>0<=(k[u+16>>2]|0)>>>0){d=k[(k[u+168>>2]|0)+(f>>>(32-(k[u+8>>2]|0)|0)<<2)>>2]|0;if((d|0)==-1){k[i>>2]=1154;k[i+4>>2]=3244;k[i+8>>2]=1677;Ac(v,1100,i)|0;zc(v,j)|0}c=d&65535;d=d>>>16;if((k[b+8>>2]|0)>>>0<=c>>>0){k[q>>2]=1154;k[q+4>>2]=902;k[q+8>>2]=1781;Ac(v,1100,q)|0;zc(v,n)|0}if((l[(k[b+4>>2]|0)+c>>0]|0|0)!=(d|0)){k[o>>2]=1154;k[o+4>>2]=3248;k[o+8>>2]=1694;Ac(v,1100,o)|0;zc(v,p)|0}}else{d=k[u+20>>2]|0;while(1){c=d+-1|0;if(e>>>0>(k[u+28+(c<<2)>>2]|0)>>>0)d=d+1|0;else break}c=(f>>>(32-d|0))+(k[u+96+(c<<2)>>2]|0)|0;if(c>>>0<(k[b>>2]|0)>>>0){c=m[(k[u+176>>2]|0)+(c<<1)>>1]|0;break}k[s>>2]=1154;k[s+4>>2]=3266;k[s+8>>2]=1632;Ac(v,1100,s)|0;zc(v,t)|0;w=0;r=x;return w|0}while(0);k[g>>2]=k[g>>2]<>2]=(k[w>>2]|0)-d;w=c;r=x;return w|0}function xb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+560|0;h=m+40|0;i=m+24|0;c=m;g=m+48|0;if(b>>>0>=33){k[c>>2]=1154;k[c+4>>2]=3190;k[c+8>>2]=1634;Ac(g,1100,c)|0;zc(g,m+16|0)|0}j=a+20|0;c=k[j>>2]|0;if((c|0)>=(b|0)){f=a+16|0;g=f;f=k[f>>2]|0;h=c;i=32-b|0;i=f>>>i;f=f<>2]=f;b=h-b|0;k[j>>2]=b;r=m;return i|0}e=a+4|0;f=a+8|0;d=a+16|0;do{a=k[e>>2]|0;if((a|0)==(k[f>>2]|0))a=0;else{k[e>>2]=a+1;a=l[a>>0]|0}c=c+8|0;k[j>>2]=c;if((c|0)>=33){k[i>>2]=1154;k[i+4>>2]=3199;k[i+8>>2]=1650;Ac(g,1100,i)|0;zc(g,h)|0;c=k[j>>2]|0}a=a<<32-c|k[d>>2];k[d>>2]=a}while((c|0)<(b|0));i=32-b|0;i=a>>>i;h=a<>2]=h;b=c-b|0;k[j>>2]=b;r=m;return i|0}function yb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0;s=r;r=r+544|0;p=s+16|0;o=s;n=s+24|0;if((a|0)==0|b>>>0<62){q=0;r=s;return q|0}m=mb(300,0)|0;if(!m){q=0;r=s;return q|0}k[m>>2]=519686845;c=m+4|0;k[c>>2]=0;d=m+8|0;k[d>>2]=0;j=m+88|0;e=m+136|0;f=m+160|0;g=j;h=g+44|0;do{k[g>>2]=0;g=g+4|0}while((g|0)<(h|0));i[j+44>>0]=0;t=m+184|0;g=m+208|0;h=m+232|0;u=m+252|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;u=m+268|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;u=m+284|0;k[u>>2]=0;k[u+4>>2]=0;k[u+8>>2]=0;i[u+12>>0]=0;k[e>>2]=0;k[e+4>>2]=0;k[e+8>>2]=0;k[e+12>>2]=0;k[e+16>>2]=0;i[e+20>>0]=0;k[f>>2]=0;k[f+4>>2]=0;k[f+8>>2]=0;k[f+12>>2]=0;k[f+16>>2]=0;i[f+20>>0]=0;k[t>>2]=0;k[t+4>>2]=0;k[t+8>>2]=0;k[t+12>>2]=0;k[t+16>>2]=0;i[t+20>>0]=0;k[g>>2]=0;k[g+4>>2]=0;k[g+8>>2]=0;k[g+12>>2]=0;k[g+16>>2]=0;i[g+20>>0]=0;k[h>>2]=0;k[h+4>>2]=0;k[h+8>>2]=0;k[h+12>>2]=0;i[h+16>>0]=0;do if(((b>>>0>=74?((l[a>>0]|0)<<8|(l[a+1>>0]|0)|0)==18552:0)?((l[a+2>>0]|0)<<8|(l[a+3>>0]|0))>>>0>=74:0)?((l[a+7>>0]|0)<<16|(l[a+6>>0]|0)<<24|(l[a+8>>0]|0)<<8|(l[a+9>>0]|0))>>>0<=b>>>0:0){k[j>>2]=a;k[c>>2]=a;k[d>>2]=b;if(Hb(m)|0){c=k[j>>2]|0;if((l[c+39>>0]|0)<<8|(l[c+40>>0]|0)){if(!(Ib(m)|0))break;if(!(Jb(m)|0))break;c=k[j>>2]|0}if(!((l[c+55>>0]|0)<<8|(l[c+56>>0]|0))){u=m;r=s;return u|0}if(Kb(m)|0?Lb(m)|0:0){u=m;r=s;return u|0}}}else q=7;while(0);if((q|0)==7)k[j>>2]=0;Qb(m);if(!(m&7)){$a[k[104>>2]&1](m,0,0,1,k[27]|0)|0;u=0;r=s;return u|0}else{k[o>>2]=1154;k[o+4>>2]=2499;k[o+8>>2]=1516;Ac(n,1100,o)|0;zc(n,p)|0;u=0;r=s;return u|0}return 0}function zb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,m=0;m=r;r=r+544|0;j=m;i=m+24|0;f=k[a+88>>2]|0;h=(l[f+70+(e<<2)+1>>0]|0)<<16|(l[f+70+(e<<2)>>0]|0)<<24|(l[f+70+(e<<2)+2>>0]|0)<<8|(l[f+70+(e<<2)+3>>0]|0);g=e+1|0;if(g>>>0<(l[f+16>>0]|0)>>>0)f=(l[f+70+(g<<2)+1>>0]|0)<<16|(l[f+70+(g<<2)>>0]|0)<<24|(l[f+70+(g<<2)+2>>0]|0)<<8|(l[f+70+(g<<2)+3>>0]|0);else f=k[a+8>>2]|0;if(f>>>0>h>>>0){i=a+4|0;i=k[i>>2]|0;i=i+h|0;j=f-h|0;j=Ab(a,i,j,b,c,d,e)|0;r=m;return j|0}k[j>>2]=1154;k[j+4>>2]=3704;k[j+8>>2]=1792;Ac(i,1100,j)|0;zc(i,m+16|0)|0;i=a+4|0;i=k[i>>2]|0;i=i+h|0;j=f-h|0;j=Ab(a,i,j,b,c,d,e)|0;r=m;return j|0}function Ab(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,m=0,n=0;n=k[a+88>>2]|0;j=((l[n+12>>0]|0)<<8|(l[n+13>>0]|0))>>>g;m=((l[n+14>>0]|0)<<8|(l[n+15>>0]|0))>>>g;j=j>>>0>1?(j+3|0)>>>2:1;m=m>>>0>1?(m+3|0)>>>2:1;n=n+18|0;g=i[n>>0]|0;g=ha(g<<24>>24==0|g<<24>>24==9?8:16,j)|0;if(f)if((f&3|0)==0&g>>>0<=f>>>0)g=f;else{a=0;return a|0}if((ha(g,m)|0)>>>0>e>>>0){a=0;return a|0}f=(j+1|0)>>>1;h=(m+1|0)>>>1;if(!c){a=0;return a|0}k[a+92>>2]=b;k[a+96>>2]=b;k[a+104>>2]=c;k[a+100>>2]=b+c;k[a+108>>2]=0;k[a+112>>2]=0;switch(l[n>>0]|0|0){case 0:{Mb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 4:case 6:case 5:case 3:case 2:{Nb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 9:{Ob(a,d,e,g,j,m,f,h)|0;a=1;return a|0}case 8:case 7:{Pb(a,d,e,g,j,m,f,h)|0;a=1;return a|0}default:{a=0;return a|0}}return 0}function Bb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+4>>2]|0}function Cb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+8>>2]|0}function Db(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+12>>2]|0}function Eb(a,b){a=a|0;b=b|0;var c=0,d=0;d=r;r=r+48|0;c=d;k[c>>2]=40;pb(a,b,c)|0;r=d;return k[c+32>>2]|0}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=r;r=r+576|0;g=i+56|0;f=i+40|0;e=i+64|0;j=i;k[j>>2]=40;pb(a,b,j)|0;d=(((k[j+4>>2]|0)>>>c)+3|0)>>>2;b=(((k[j+8>>2]|0)>>>c)+3|0)>>>2;c=j+32|0;a=k[c+4>>2]|0;do switch(k[c>>2]|0){case 0:{if(!a)a=8;else h=13;break}case 1:{if(!a)h=12;else h=13;break}case 2:{if(!a)h=12;else h=13;break}case 3:{if(!a)h=12;else h=13;break}case 4:{if(!a)h=12;else h=13;break}case 5:{if(!a)h=12;else h=13;break}case 6:{if(!a)h=12;else h=13;break}case 7:{if(!a)h=12;else h=13;break}case 8:{if(!a)h=12;else h=13;break}case 9:{if(!a)a=8;else h=13;break}default:h=13}while(0);if((h|0)==12)a=16;else if((h|0)==13){k[f>>2]=1154;k[f+4>>2]=2663;k[f+8>>2]=1535;Ac(e,1100,f)|0;zc(e,g)|0;a=0}j=ha(ha(b,d)|0,a)|0;r=i;return j|0}function Gb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0;p=r;r=r+608|0;n=p+80|0;o=p+64|0;h=p+56|0;g=p+40|0;l=p+88|0;q=p;m=p+84|0;k[q>>2]=40;pb(a,b,q)|0;i=(((k[q+4>>2]|0)>>>e)+3|0)>>>2;q=q+32|0;f=k[q+4>>2]|0;do switch(k[q>>2]|0){case 0:{if(!f)f=8;else j=13;break}case 1:{if(!f)j=12;else j=13;break}case 2:{if(!f)j=12;else j=13;break}case 3:{if(!f)j=12;else j=13;break}case 4:{if(!f)j=12;else j=13;break}case 5:{if(!f)j=12;else j=13;break}case 6:{if(!f)j=12;else j=13;break}case 7:{if(!f)j=12;else j=13;break}case 8:{if(!f)j=12;else j=13;break}case 9:{if(!f)f=8;else j=13;break}default:j=13}while(0);if((j|0)==12)f=16;else if((j|0)==13){k[g>>2]=1154;k[g+4>>2]=2663;k[g+8>>2]=1535;Ac(l,1100,g)|0;zc(l,h)|0;f=0}h=ha(f,i)|0;g=yb(a,b)|0;k[m>>2]=c;f=(g|0)==0;if(!(e>>>0>15|(d>>>0<8|f))?(k[g>>2]|0)==519686845:0)zb(g,m,d,h,e)|0;if(f){r=p;return}if((k[g>>2]|0)!=519686845){r=p;return}Qb(g);if(!(g&7)){$a[k[104>>2]&1](g,0,0,1,k[27]|0)|0;r=p;return}else{k[o>>2]=1154;k[o+4>>2]=2499;k[o+8>>2]=1516;Ac(l,1100,o)|0;zc(l,n)|0;r=p;return}}function Hb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;g=a+92|0;d=k[a+4>>2]|0;f=a+88|0;e=k[f>>2]|0;b=(l[e+68>>0]|0)<<8|(l[e+67>>0]|0)<<16|(l[e+69>>0]|0);c=d+b|0;e=(l[e+65>>0]|0)<<8|(l[e+66>>0]|0);if(!e){a=0;return a|0}k[g>>2]=c;k[a+96>>2]=c;k[a+104>>2]=e;k[a+100>>2]=d+(e+b);k[a+108>>2]=0;k[a+112>>2]=0;if(!(ub(g,a+116|0)|0)){a=0;return a|0}b=k[f>>2]|0;do if(!((l[b+39>>0]|0)<<8|(l[b+40>>0]|0))){if(!((l[b+55>>0]|0)<<8|(l[b+56>>0]|0))){a=0;return a|0}}else{if(!(ub(g,a+140|0)|0)){a=0;return a|0}if(ub(g,a+188|0)|0){b=k[f>>2]|0;break}else{a=0;return a|0}}while(0);if((l[b+55>>0]|0)<<8|(l[b+56>>0]|0)){if(!(ub(g,a+164|0)|0)){a=0;return a|0}if(!(ub(g,a+212|0)|0)){a=0;return a|0}}a=1;return a|0}function Ib(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0;s=r;r=r+592|0;j=s+16|0;h=s;g=s+72|0;q=s+24|0;d=a+88|0;b=k[d>>2]|0;p=(l[b+39>>0]|0)<<8|(l[b+40>>0]|0);n=a+236|0;f=a+240|0;c=k[f>>2]|0;if((c|0)!=(p|0)){if(c>>>0<=p>>>0){do if((k[a+244>>2]|0)>>>0

>>0){if(kb(n,p,(c+1|0)==(p|0),4,0)|0){b=k[f>>2]|0;break}i[a+248>>0]=1;q=0;r=s;return q|0}else b=c;while(0);ad((k[n>>2]|0)+(b<<2)|0,0,p-b<<2|0)|0;b=k[d>>2]|0}k[f>>2]=p}m=a+92|0;c=k[a+4>>2]|0;d=(l[b+34>>0]|0)<<8|(l[b+33>>0]|0)<<16|(l[b+35>>0]|0);e=c+d|0;b=(l[b+37>>0]|0)<<8|(l[b+36>>0]|0)<<16|(l[b+38>>0]|0);if(!b){q=0;r=s;return q|0}k[m>>2]=e;k[a+96>>2]=e;k[a+104>>2]=b;k[a+100>>2]=c+(b+d);k[a+108>>2]=0;k[a+112>>2]=0;k[q+20>>2]=0;k[q>>2]=0;k[q+4>>2]=0;k[q+8>>2]=0;k[q+12>>2]=0;i[q+16>>0]=0;a=q+24|0;k[q+44>>2]=0;k[a>>2]=0;k[a+4>>2]=0;k[a+8>>2]=0;k[a+12>>2]=0;i[a+16>>0]=0;if(ub(m,q)|0?(o=q+24|0,ub(m,o)|0):0){if(!(k[f>>2]|0)){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(g,1100,h)|0;zc(g,j)|0}if(!p)b=1;else{d=0;e=0;f=0;b=0;g=0;a=0;h=0;c=k[n>>2]|0;while(1){d=(wb(m,q)|0)+d&31;e=(wb(m,o)|0)+e&63;f=(wb(m,q)|0)+f&31;b=(wb(m,q)|0)+b|0;g=(wb(m,o)|0)+g&63;a=(wb(m,q)|0)+a&31;k[c>>2]=e<<5|d<<11|f|b<<27|g<<21|a<<16;h=h+1|0;if((h|0)==(p|0)){b=1;break}else{b=b&31;c=c+4|0}}}}else b=0;rb(q+24|0);rb(q);q=b;r=s;return q|0}function Jb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;D=r;r=r+1024|0;h=D+16|0;g=D;f=D+504|0;C=D+480|0;A=D+284|0;B=D+88|0;z=D+24|0;e=k[a+88>>2]|0;y=(l[e+47>>0]|0)<<8|(l[e+48>>0]|0);x=a+92|0;b=k[a+4>>2]|0;c=(l[e+42>>0]|0)<<8|(l[e+41>>0]|0)<<16|(l[e+43>>0]|0);d=b+c|0;e=(l[e+45>>0]|0)<<8|(l[e+44>>0]|0)<<16|(l[e+46>>0]|0);if(!e){C=0;r=D;return C|0}k[x>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[C+20>>2]=0;k[C>>2]=0;k[C+4>>2]=0;k[C+8>>2]=0;k[C+12>>2]=0;i[C+16>>0]=0;if(ub(x,C)|0){c=0;d=-3;e=-3;while(1){k[A+(c<<2)>>2]=d;k[B+(c<<2)>>2]=e;b=(d|0)>2;c=c+1|0;if((c|0)==49)break;else{d=b?-3:d+1|0;e=(b&1)+e|0}}b=z;c=b+64|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(c|0));w=a+252|0;c=a+256|0;b=k[c>>2]|0;a:do if((b|0)==(y|0))j=13;else{if(b>>>0<=y>>>0){do if((k[a+260>>2]|0)>>>0>>0)if(kb(w,y,(b+1|0)==(y|0),4,0)|0){b=k[c>>2]|0;break}else{i[a+264>>0]=1;b=0;break a}while(0);ad((k[w>>2]|0)+(b<<2)|0,0,y-b<<2|0)|0}k[c>>2]=y;j=13}while(0);do if((j|0)==13){if(!y){k[g>>2]=1154;k[g+4>>2]=903;k[g+8>>2]=1781;Ac(f,1100,g)|0;zc(f,h)|0;b=1;break}d=z+4|0;e=z+8|0;a=z+12|0;f=z+16|0;g=z+20|0;h=z+24|0;j=z+28|0;m=z+32|0;n=z+36|0;o=z+40|0;p=z+44|0;q=z+48|0;s=z+52|0;t=z+56|0;u=z+60|0;v=0;c=k[w>>2]|0;while(1){b=0;do{E=wb(x,C)|0;w=b<<1;F=z+(w<<2)|0;k[F>>2]=(k[F>>2]|0)+(k[A+(E<<2)>>2]|0)&3;w=z+((w|1)<<2)|0;k[w>>2]=(k[w>>2]|0)+(k[B+(E<<2)>>2]|0)&3;b=b+1|0}while((b|0)!=8);k[c>>2]=(l[1725+(k[d>>2]|0)>>0]|0)<<2|(l[1725+(k[z>>2]|0)>>0]|0)|(l[1725+(k[e>>2]|0)>>0]|0)<<4|(l[1725+(k[a>>2]|0)>>0]|0)<<6|(l[1725+(k[f>>2]|0)>>0]|0)<<8|(l[1725+(k[g>>2]|0)>>0]|0)<<10|(l[1725+(k[h>>2]|0)>>0]|0)<<12|(l[1725+(k[j>>2]|0)>>0]|0)<<14|(l[1725+(k[m>>2]|0)>>0]|0)<<16|(l[1725+(k[n>>2]|0)>>0]|0)<<18|(l[1725+(k[o>>2]|0)>>0]|0)<<20|(l[1725+(k[p>>2]|0)>>0]|0)<<22|(l[1725+(k[q>>2]|0)>>0]|0)<<24|(l[1725+(k[s>>2]|0)>>0]|0)<<26|(l[1725+(k[t>>2]|0)>>0]|0)<<28|(l[1725+(k[u>>2]|0)>>0]|0)<<30;v=v+1|0;if((v|0)==(y|0)){b=1;break}else c=c+4|0}}while(0)}else b=0;rb(C);F=b;r=D;return F|0}function Kb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+560|0;m=q+16|0;h=q;g=q+48|0;p=q+24|0;e=k[a+88>>2]|0;o=(l[e+55>>0]|0)<<8|(l[e+56>>0]|0);n=a+92|0;b=k[a+4>>2]|0;c=(l[e+50>>0]|0)<<8|(l[e+49>>0]|0)<<16|(l[e+51>>0]|0);d=b+c|0;e=(l[e+53>>0]|0)<<8|(l[e+52>>0]|0)<<16|(l[e+54>>0]|0);if(!e){p=0;r=q;return p|0}k[n>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[p+20>>2]=0;k[p>>2]=0;k[p+4>>2]=0;k[p+8>>2]=0;k[p+12>>2]=0;i[p+16>>0]=0;a:do if(ub(n,p)|0){f=a+268|0;c=a+272|0;b=k[c>>2]|0;if((b|0)!=(o|0)){if(b>>>0<=o>>>0){do if((k[a+276>>2]|0)>>>0>>0)if(kb(f,o,(b+1|0)==(o|0),2,0)|0){b=k[c>>2]|0;break}else{i[a+280>>0]=1;b=0;break a}while(0);ad((k[f>>2]|0)+(b<<1)|0,0,o-b<<1|0)|0}k[c>>2]=o}if(!o){k[h>>2]=1154;k[h+4>>2]=903;k[h+8>>2]=1781;Ac(g,1100,h)|0;zc(g,m)|0;b=1;break}c=0;d=0;e=0;b=k[f>>2]|0;while(1){m=wb(n,p)|0;c=m+c&255;d=(wb(n,p)|0)+d&255;j[b>>1]=d<<8|c;e=e+1|0;if((e|0)==(o|0)){b=1;break}else b=b+2|0}}else b=0;while(0);rb(p);p=b;r=q;return p|0}function Lb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;E=r;r=r+2432|0;h=E+16|0;g=E;f=E+1912|0;D=E+1888|0;B=E+988|0;C=E+88|0;A=E+24|0;e=k[a+88>>2]|0;z=(l[e+63>>0]|0)<<8|(l[e+64>>0]|0);y=a+92|0;b=k[a+4>>2]|0;c=(l[e+58>>0]|0)<<8|(l[e+57>>0]|0)<<16|(l[e+59>>0]|0);d=b+c|0;e=(l[e+61>>0]|0)<<8|(l[e+60>>0]|0)<<16|(l[e+62>>0]|0);if(!e){D=0;r=E;return D|0}k[y>>2]=d;k[a+96>>2]=d;k[a+104>>2]=e;k[a+100>>2]=b+(e+c);k[a+108>>2]=0;k[a+112>>2]=0;k[D+20>>2]=0;k[D>>2]=0;k[D+4>>2]=0;k[D+8>>2]=0;k[D+12>>2]=0;i[D+16>>0]=0;if(ub(y,D)|0){c=0;d=-7;e=-7;while(1){k[B+(c<<2)>>2]=d;k[C+(c<<2)>>2]=e;b=(d|0)>6;c=c+1|0;if((c|0)==225)break;else{d=b?-7:d+1|0;e=(b&1)+e|0}}b=A;c=b+64|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(c|0));x=a+284|0;c=z*3|0;d=a+288|0;b=k[d>>2]|0;a:do if((b|0)==(c|0))m=13;else{if(b>>>0<=c>>>0){do if((k[a+292>>2]|0)>>>0>>0)if(kb(x,c,(b+1|0)==(c|0),2,0)|0){b=k[d>>2]|0;break}else{i[a+296>>0]=1;b=0;break a}while(0);ad((k[x>>2]|0)+(b<<1)|0,0,c-b<<1|0)|0}k[d>>2]=c;m=13}while(0);do if((m|0)==13){if(!z){k[g>>2]=1154;k[g+4>>2]=903;k[g+8>>2]=1781;Ac(f,1100,g)|0;zc(f,h)|0;b=1;break}d=A+4|0;e=A+8|0;a=A+12|0;f=A+16|0;g=A+20|0;h=A+24|0;m=A+28|0;n=A+32|0;o=A+36|0;p=A+40|0;q=A+44|0;s=A+48|0;t=A+52|0;u=A+56|0;v=A+60|0;w=0;c=k[x>>2]|0;while(1){b=0;do{F=wb(y,D)|0;x=b<<1;G=A+(x<<2)|0;k[G>>2]=(k[G>>2]|0)+(k[B+(F<<2)>>2]|0)&7;x=A+((x|1)<<2)|0;k[x>>2]=(k[x>>2]|0)+(k[C+(F<<2)>>2]|0)&7;b=b+1|0}while((b|0)!=8);F=l[1729+(k[g>>2]|0)>>0]|0;j[c>>1]=(l[1729+(k[d>>2]|0)>>0]|0)<<3|(l[1729+(k[A>>2]|0)>>0]|0)|(l[1729+(k[e>>2]|0)>>0]|0)<<6|(l[1729+(k[a>>2]|0)>>0]|0)<<9|(l[1729+(k[f>>2]|0)>>0]|0)<<12|F<<15;G=l[1729+(k[p>>2]|0)>>0]|0;j[c+2>>1]=(l[1729+(k[h>>2]|0)>>0]|0)<<2|F>>>1|(l[1729+(k[m>>2]|0)>>0]|0)<<5|(l[1729+(k[n>>2]|0)>>0]|0)<<8|(l[1729+(k[o>>2]|0)>>0]|0)<<11|G<<14;j[c+4>>1]=(l[1729+(k[q>>2]|0)>>0]|0)<<1|G>>>2|(l[1729+(k[s>>2]|0)>>0]|0)<<4|(l[1729+(k[t>>2]|0)>>0]|0)<<7|(l[1729+(k[u>>2]|0)>>0]|0)<<10|(l[1729+(k[v>>2]|0)>>0]|0)<<13;w=w+1|0;if((w|0)==(z|0)){b=1;break}else c=c+6|0}}while(0)}else b=0;rb(D);G=b;r=E;return G|0}function Mb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,m=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0;pa=r;r=r+720|0;oa=pa+184|0;ma=pa+168|0;la=pa+160|0;ka=pa+144|0;ja=pa+136|0;ia=pa+120|0;ga=pa+112|0;ea=pa+96|0;da=pa+88|0;ca=pa+72|0;ba=pa+64|0;aa=pa+48|0;$=pa+40|0;na=pa+24|0;fa=pa+16|0;_=pa;Y=pa+208|0;Z=pa+192|0;R=a+240|0;S=k[R>>2]|0;V=a+256|0;W=k[V>>2]|0;c=i[(k[a+88>>2]|0)+17>>0]|0;X=d>>>2;if(!(c<<24>>24)){r=pa;return 1}T=(h|0)==0;U=h+-1|0;K=(f&1|0)!=0;L=d<<1;M=a+92|0;N=a+116|0;O=a+140|0;P=a+236|0;Q=g+-1|0;J=(e&1|0)!=0;I=a+188|0;D=a+252|0;E=X+1|0;F=X+2|0;G=X+3|0;H=Q<<4;B=c&255;c=0;f=0;e=1;C=0;do{if(!T){z=k[b+(C<<2)>>2]|0;A=0;while(1){w=A&1;j=(w|0)==0;v=(w<<5^32)+-16|0;w=(w<<1^2)+-1|0;y=j?g:-1;m=j?0:Q;a=(A|0)==(U|0);x=K&a;if((m|0)!=(y|0)){u=K&a^1;t=j?z:z+H|0;while(1){if((e|0)==1)e=wb(M,N)|0|512;s=e&7;e=e>>>3;j=l[1823+s>>0]|0;a=0;do{p=(wb(M,O)|0)+f|0;q=p-S|0;f=q>>31;f=f&p|q&~f;if((k[R>>2]|0)>>>0<=f>>>0){k[_>>2]=1154;k[_+4>>2]=903;k[_+8>>2]=1781;Ac(Y,1100,_)|0;zc(Y,fa)|0}k[Z+(a<<2)>>2]=k[(k[P>>2]|0)+(f<<2)>>2];a=a+1|0}while(a>>>0>>0);q=J&(m|0)==(Q|0);if(x|q){p=0;do{n=ha(p,d)|0;a=t+n|0;j=(p|0)==0|u;o=p<<1;ra=(wb(M,I)|0)+c|0;qa=ra-W|0;c=qa>>31;c=c&ra|qa&~c;do if(q){if(!j){qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;break}k[a>>2]=k[Z+((l[1831+(s<<2)+o>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(Y,1100,ka)|0;zc(Y,la)|0}k[t+(n+4)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c}else{if(!j){qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;break}k[a>>2]=k[Z+((l[1831+(s<<2)+o>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ia>>2]=1154;k[ia+4>>2]=903;k[ia+8>>2]=1781;Ac(Y,1100,ia)|0;zc(Y,ja)|0}k[t+(n+4)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;k[t+(n+8)>>2]=k[Z+((l[(o|1)+(1831+(s<<2))>>0]|0)<<2)>>2];if((k[V>>2]|0)>>>0<=c>>>0){k[ma>>2]=1154;k[ma+4>>2]=903;k[ma+8>>2]=1781;Ac(Y,1100,ma)|0;zc(Y,oa)|0}k[t+(n+12)>>2]=k[(k[D>>2]|0)+(c<<2)>>2]}while(0);p=p+1|0}while((p|0)!=2)}else{k[t>>2]=k[Z+((l[1831+(s<<2)>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[na>>2]=1154;k[na+4>>2]=903;k[na+8>>2]=1781;Ac(Y,1100,na)|0;zc(Y,$)|0}k[t+4>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+8>>2]=k[Z+((l[1831+(s<<2)+1>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[aa>>2]=1154;k[aa+4>>2]=903;k[aa+8>>2]=1781;Ac(Y,1100,aa)|0;zc(Y,ba)|0}k[t+12>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+(X<<2)>>2]=k[Z+((l[1831+(s<<2)+2>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[ca>>2]=1154;k[ca+4>>2]=903;k[ca+8>>2]=1781;Ac(Y,1100,ca)|0;zc(Y,da)|0}k[t+(E<<2)>>2]=k[(k[D>>2]|0)+(c<<2)>>2];k[t+(F<<2)>>2]=k[Z+((l[1831+(s<<2)+3>>0]|0)<<2)>>2];qa=(wb(M,I)|0)+c|0;ra=qa-W|0;c=ra>>31;c=c&qa|ra&~c;if((k[V>>2]|0)>>>0<=c>>>0){k[ea>>2]=1154;k[ea+4>>2]=903;k[ea+8>>2]=1781;Ac(Y,1100,ea)|0;zc(Y,ga)|0}k[t+(G<<2)>>2]=k[(k[D>>2]|0)+(c<<2)>>2]}m=m+w|0;if((m|0)==(y|0))break;else t=t+v|0}}A=A+1|0;if((A|0)==(h|0))break;else z=z+L|0}}C=C+1|0}while((C|0)!=(B|0));r=pa;return 1}function Nb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0;qa=r;r=r+640|0;na=qa+88|0;ma=qa+72|0;la=qa+64|0;ka=qa+48|0;ja=qa+40|0;pa=qa+24|0;oa=qa+16|0;ia=qa;ga=qa+128|0;ha=qa+112|0;fa=qa+96|0;S=a+240|0;T=k[S>>2]|0;W=a+256|0;ca=k[W>>2]|0;da=a+272|0;ea=k[da>>2]|0;c=k[a+88>>2]|0;U=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=qa;return 1}V=(h|0)==0;X=h+-1|0;Y=d<<1;Z=a+92|0;_=a+116|0;$=g+-1|0;aa=a+212|0;ba=a+188|0;R=(e&1|0)==0;Q=(f&1|0)==0;K=a+288|0;L=a+284|0;M=a+252|0;N=a+140|0;O=a+236|0;P=a+164|0;I=a+268|0;J=$<<5;G=c&255;c=0;e=0;f=0;a=0;j=1;H=0;do{if(!V){E=k[b+(H<<2)>>2]|0;F=0;while(1){C=F&1;n=(C|0)==0;B=(C<<6^64)+-32|0;C=(C<<1^2)+-1|0;D=n?g:-1;o=n?0:$;if((o|0)!=(D|0)){A=Q|(F|0)!=(X|0);z=n?E:E+J|0;while(1){if((j|0)==1)j=wb(Z,_)|0|512;y=j&7;j=j>>>3;p=l[1823+y>>0]|0;n=0;do{w=(wb(Z,P)|0)+e|0;x=w-ea|0;e=x>>31;e=e&w|x&~e;if((k[da>>2]|0)>>>0<=e>>>0){k[ia>>2]=1154;k[ia+4>>2]=903;k[ia+8>>2]=1781;Ac(ga,1100,ia)|0;zc(ga,oa)|0}k[fa+(n<<2)>>2]=m[(k[I>>2]|0)+(e<<1)>>1];n=n+1|0}while(n>>>0

>>0);n=0;do{w=(wb(Z,N)|0)+a|0;x=w-T|0;a=x>>31;a=a&w|x&~a;if((k[S>>2]|0)>>>0<=a>>>0){k[pa>>2]=1154;k[pa+4>>2]=903;k[pa+8>>2]=1781;Ac(ga,1100,pa)|0;zc(ga,ja)|0}k[ha+(n<<2)>>2]=k[(k[O>>2]|0)+(a<<2)>>2];n=n+1|0}while(n>>>0

>>0);x=R|(o|0)!=($|0);v=0;w=z;while(1){u=A|(v|0)==0;t=v<<1;q=0;s=w;while(1){p=(wb(Z,aa)|0)+c|0;n=p-U|0;c=n>>31;c=c&p|n&~c;n=(wb(Z,ba)|0)+f|0;p=n-ca|0;f=p>>31;f=f&n|p&~f;if((x|(q|0)==0)&u){n=l[q+t+(1831+(y<<2))>>0]|0;p=c*3|0;if((k[K>>2]|0)>>>0<=p>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(ga,1100,ka)|0;zc(ga,la)|0}ra=k[L>>2]|0;k[s>>2]=(m[ra+(p<<1)>>1]|0)<<16|k[fa+(n<<2)>>2];k[s+4>>2]=(m[ra+(p+2<<1)>>1]|0)<<16|(m[ra+(p+1<<1)>>1]|0);k[s+8>>2]=k[ha+(n<<2)>>2];if((k[W>>2]|0)>>>0<=f>>>0){k[ma>>2]=1154;k[ma+4>>2]=903;k[ma+8>>2]=1781;Ac(ga,1100,ma)|0;zc(ga,na)|0}k[s+12>>2]=k[(k[M>>2]|0)+(f<<2)>>2]}q=q+1|0;if((q|0)==2)break;else s=s+16|0}v=v+1|0;if((v|0)==2)break;else w=w+d|0}o=o+C|0;if((o|0)==(D|0))break;else z=z+B|0}}F=F+1|0;if((F|0)==(h|0))break;else E=E+Y|0}}H=H+1|0}while((H|0)!=(G|0));r=qa;return 1}function Ob(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;ca=r;r=r+608|0;$=ca+64|0;_=ca+48|0;Z=ca+40|0;ba=ca+24|0;aa=ca+16|0;Y=ca;X=ca+88|0;W=ca+72|0;M=a+272|0;N=k[M>>2]|0;c=k[a+88>>2]|0;O=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=ca;return 1}P=(h|0)==0;Q=h+-1|0;R=d<<1;S=a+92|0;T=a+116|0;U=g+-1|0;V=a+212|0;L=(f&1|0)==0;I=a+288|0;J=a+284|0;K=a+164|0;G=a+268|0;H=U<<4;F=c&255;E=(e&1|0)!=0;c=0;f=0;a=1;D=0;do{if(!P){B=k[b+(D<<2)>>2]|0;C=0;while(1){z=C&1;e=(z|0)==0;y=(z<<5^32)+-16|0;z=(z<<1^2)+-1|0;A=e?g:-1;j=e?0:U;if((j|0)!=(A|0)){x=L|(C|0)!=(Q|0);w=e?B:B+H|0;while(1){if((a|0)==1)a=wb(S,T)|0|512;v=a&7;a=a>>>3;n=l[1823+v>>0]|0;e=0;do{t=(wb(S,K)|0)+f|0;u=t-N|0;f=u>>31;f=f&t|u&~f;if((k[M>>2]|0)>>>0<=f>>>0){k[Y>>2]=1154;k[Y+4>>2]=903;k[Y+8>>2]=1781;Ac(X,1100,Y)|0;zc(X,aa)|0}k[W+(e<<2)>>2]=m[(k[G>>2]|0)+(f<<1)>>1];e=e+1|0}while(e>>>0>>0);u=(j|0)==(U|0)&E;s=0;t=w;while(1){q=x|(s|0)==0;p=s<<1;e=(wb(S,V)|0)+c|0;o=e-O|0;n=o>>31;n=n&e|o&~n;if(q){c=l[1831+(v<<2)+p>>0]|0;e=n*3|0;if((k[I>>2]|0)>>>0<=e>>>0){k[ba>>2]=1154;k[ba+4>>2]=903;k[ba+8>>2]=1781;Ac(X,1100,ba)|0;zc(X,Z)|0}o=k[J>>2]|0;k[t>>2]=(m[o+(e<<1)>>1]|0)<<16|k[W+(c<<2)>>2];k[t+4>>2]=(m[o+(e+2<<1)>>1]|0)<<16|(m[o+(e+1<<1)>>1]|0)}o=t+8|0;e=(wb(S,V)|0)+n|0;n=e-O|0;c=n>>31;c=c&e|n&~c;if(!(u|q^1)){e=l[(p|1)+(1831+(v<<2))>>0]|0;n=c*3|0;if((k[I>>2]|0)>>>0<=n>>>0){k[_>>2]=1154;k[_+4>>2]=903;k[_+8>>2]=1781;Ac(X,1100,_)|0;zc(X,$)|0}q=k[J>>2]|0;k[o>>2]=(m[q+(n<<1)>>1]|0)<<16|k[W+(e<<2)>>2];k[t+12>>2]=(m[q+(n+2<<1)>>1]|0)<<16|(m[q+(n+1<<1)>>1]|0)}s=s+1|0;if((s|0)==2)break;else t=t+d|0}j=j+z|0;if((j|0)==(A|0))break;else w=w+y|0}}C=C+1|0;if((C|0)==(h|0))break;else B=B+R|0}}D=D+1|0}while((D|0)!=(F|0));r=ca;return 1}function Pb(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,n=0,o=0,p=0,q=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0;la=r;r=r+640|0;ia=la+88|0;ha=la+72|0;ga=la+64|0;fa=la+48|0;ea=la+40|0;ka=la+24|0;ja=la+16|0;da=la;ca=la+128|0;aa=la+112|0;ba=la+96|0;S=a+272|0;T=k[S>>2]|0;c=k[a+88>>2]|0;U=(l[c+63>>0]|0)<<8|(l[c+64>>0]|0);c=i[c+17>>0]|0;if(!(c<<24>>24)){r=la;return 1}V=(h|0)==0;W=h+-1|0;X=d<<1;Y=a+92|0;Z=a+116|0;_=g+-1|0;$=a+212|0;R=(e&1|0)==0;Q=(f&1|0)==0;N=a+288|0;O=a+284|0;P=a+164|0;L=a+268|0;M=_<<5;J=c&255;c=0;e=0;f=0;a=0;j=1;K=0;do{if(!V){H=k[b+(K<<2)>>2]|0;I=0;while(1){F=I&1;n=(F|0)==0;E=(F<<6^64)+-32|0;F=(F<<1^2)+-1|0;G=n?g:-1;o=n?0:_;if((o|0)!=(G|0)){D=Q|(I|0)!=(W|0);C=n?H:H+M|0;while(1){if((j|0)==1)j=wb(Y,Z)|0|512;B=j&7;j=j>>>3;p=l[1823+B>>0]|0;n=0;do{z=(wb(Y,P)|0)+a|0;A=z-T|0;a=A>>31;a=a&z|A&~a;if((k[S>>2]|0)>>>0<=a>>>0){k[da>>2]=1154;k[da+4>>2]=903;k[da+8>>2]=1781;Ac(ca,1100,da)|0;zc(ca,ja)|0}k[aa+(n<<2)>>2]=m[(k[L>>2]|0)+(a<<1)>>1];n=n+1|0}while(n>>>0

>>0);n=0;do{z=(wb(Y,P)|0)+e|0;A=z-T|0;e=A>>31;e=e&z|A&~e;if((k[S>>2]|0)>>>0<=e>>>0){k[ka>>2]=1154;k[ka+4>>2]=903;k[ka+8>>2]=1781;Ac(ca,1100,ka)|0;zc(ca,ea)|0}k[ba+(n<<2)>>2]=m[(k[L>>2]|0)+(e<<1)>>1];n=n+1|0}while(n>>>0

>>0);A=R|(o|0)!=(_|0);y=0;z=C;while(1){x=D|(y|0)==0;w=y<<1;u=0;v=z;while(1){t=(wb(Y,$)|0)+f|0;s=t-U|0;f=s>>31;f=f&t|s&~f;s=(wb(Y,$)|0)+c|0;t=s-U|0;c=t>>31;c=c&s|t&~c;if((A|(u|0)==0)&x){s=l[u+w+(1831+(B<<2))>>0]|0;t=f*3|0;n=k[N>>2]|0;if(n>>>0<=t>>>0){k[fa>>2]=1154;k[fa+4>>2]=903;k[fa+8>>2]=1781;Ac(ca,1100,fa)|0;zc(ca,ga)|0;n=k[N>>2]|0}p=k[O>>2]|0;q=c*3|0;if(n>>>0>q>>>0)n=p;else{k[ha>>2]=1154;k[ha+4>>2]=903;k[ha+8>>2]=1781;Ac(ca,1100,ha)|0;zc(ca,ia)|0;n=k[O>>2]|0}k[v>>2]=(m[p+(t<<1)>>1]|0)<<16|k[aa+(s<<2)>>2];k[v+4>>2]=(m[p+(t+2<<1)>>1]|0)<<16|(m[p+(t+1<<1)>>1]|0);k[v+8>>2]=(m[n+(q<<1)>>1]|0)<<16|k[ba+(s<<2)>>2];k[v+12>>2]=(m[n+(q+2<<1)>>1]|0)<<16|(m[n+(q+1<<1)>>1]|0)}u=u+1|0;if((u|0)==2)break;else v=v+16|0}y=y+1|0;if((y|0)==2)break;else z=z+d|0}o=o+F|0;if((o|0)==(G|0))break;else C=C+E|0}}I=I+1|0;if((I|0)==(h|0))break;else H=H+X|0}}K=K+1|0}while((K|0)!=(J|0));r=la;return 1}function Qb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,l=0,m=0,n=0,o=0;o=r;r=r+608|0;n=o+88|0;m=o+72|0;j=o+64|0;h=o+48|0;f=o+40|0;g=o+24|0;e=o+16|0;d=o;l=o+96|0;k[a>>2]=0;b=a+284|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[d>>2]=1154;k[d+4>>2]=2499;k[d+8>>2]=1516;Ac(l,1100,d)|0;zc(l,e)|0}k[b>>2]=0;k[a+288>>2]=0;k[a+292>>2]=0}i[a+296>>0]=0;b=a+268|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[g>>2]=1154;k[g+4>>2]=2499;k[g+8>>2]=1516;Ac(l,1100,g)|0;zc(l,f)|0}k[b>>2]=0;k[a+272>>2]=0;k[a+276>>2]=0}i[a+280>>0]=0;b=a+252|0;c=k[b>>2]|0;if(c){if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[h>>2]=1154;k[h+4>>2]=2499;k[h+8>>2]=1516;Ac(l,1100,h)|0;zc(l,j)|0}k[b>>2]=0;k[a+256>>2]=0;k[a+260>>2]=0}i[a+264>>0]=0;b=a+236|0;c=k[b>>2]|0;if(!c){n=a+248|0;i[n>>0]=0;n=a+212|0;rb(n);n=a+188|0;rb(n);n=a+164|0;rb(n);n=a+140|0;rb(n);n=a+116|0;rb(n);r=o;return}if(!(c&7))$a[k[104>>2]&1](c,0,0,1,k[27]|0)|0;else{k[m>>2]=1154;k[m+4>>2]=2499;k[m+8>>2]=1516;Ac(l,1100,m)|0;zc(l,n)|0}k[b>>2]=0;k[a+240>>2]=0;k[a+244>>2]=0;n=a+248|0;i[n>>0]=0;n=a+212|0;rb(n);n=a+188|0;rb(n);n=a+164|0;rb(n);n=a+140|0;rb(n);n=a+116|0;rb(n);r=o;return}function Rb(a,b){a=a|0;b=b|0;var c=0;c=r;r=r+16|0;k[c>>2]=b;b=k[63]|0;Bc(b,a,c)|0;xc(10,b)|0;Na()}function Sb(){var a=0,b=0;a=r;r=r+16|0;if(!(Ha(200,2)|0)){b=Fa(k[49]|0)|0;r=a;return b|0}else Rb(2090,a);return 0}function Tb(a){a=a|0;Vc(a);return}function Ub(a){a=a|0;var b=0;b=r;r=r+16|0;Za[a&3]();Rb(2139,b)}function Vb(){var a=0,b=0;a=Sb()|0;if(((a|0)!=0?(b=k[a>>2]|0,(b|0)!=0):0)?(a=b+48|0,(k[a>>2]&-256|0)==1126902528?(k[a+4>>2]|0)==1129074247:0):0)Ub(k[b+12>>2]|0);b=k[28]|0;k[28]=b+0;Ub(b)}function Wb(a){a=a|0;return}function Xb(a){a=a|0;return}function Yb(a){a=a|0;return}function Zb(a){a=a|0;return}function _b(a){a=a|0;Tb(a);return}function $b(a){a=a|0;Tb(a);return}function ac(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;g=r;r=r+64|0;f=g;if((a|0)!=(b|0))if((b|0)!=0?(e=ec(b,24,40,0)|0,(e|0)!=0):0){b=f;d=b+56|0;do{k[b>>2]=0;b=b+4|0}while((b|0)<(d|0));k[f>>2]=e;k[f+8>>2]=a;k[f+12>>2]=-1;k[f+48>>2]=1;ab[k[(k[e>>2]|0)+28>>2]&3](e,f,k[c>>2]|0,1);if((k[f+24>>2]|0)==1){k[c>>2]=k[f+16>>2];b=1}else b=0}else b=0;else b=1;r=g;return b|0}function bc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;a=b+16|0;e=k[a>>2]|0;do if(e){if((e|0)!=(c|0)){d=b+36|0;k[d>>2]=(k[d>>2]|0)+1;k[b+24>>2]=2;i[b+54>>0]=1;break}a=b+24|0;if((k[a>>2]|0)==2)k[a>>2]=d}else{k[a>>2]=c;k[b+24>>2]=d;k[b+36>>2]=1}while(0);return}function cc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((a|0)==(k[b+8>>2]|0))bc(0,b,c,d);return}function dc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((a|0)==(k[b+8>>2]|0))bc(0,b,c,d);else{a=k[a+8>>2]|0;ab[k[(k[a>>2]|0)+28>>2]&3](a,b,c,d)}return}function ec(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,l=0,m=0,n=0,o=0,p=0,q=0;q=r;r=r+64|0;p=q;o=k[a>>2]|0;n=a+(k[o+-8>>2]|0)|0;o=k[o+-4>>2]|0;k[p>>2]=c;k[p+4>>2]=a;k[p+8>>2]=b;k[p+12>>2]=d;d=p+16|0;a=p+20|0;b=p+24|0;e=p+28|0;f=p+32|0;g=p+40|0;h=(o|0)==(c|0);l=d;m=l+36|0;do{k[l>>2]=0;l=l+4|0}while((l|0)<(m|0));j[d+36>>1]=0;i[d+38>>0]=0;a:do if(h){k[p+48>>2]=1;_a[k[(k[c>>2]|0)+20>>2]&3](c,p,n,n,1,0);d=(k[b>>2]|0)==1?n:0}else{Va[k[(k[o>>2]|0)+24>>2]&3](o,p,n,1,0);switch(k[p+36>>2]|0){case 0:{d=(k[g>>2]|0)==1&(k[e>>2]|0)==1&(k[f>>2]|0)==1?k[a>>2]|0:0;break a}case 1:break;default:{d=0;break a}}if((k[b>>2]|0)!=1?!((k[g>>2]|0)==0&(k[e>>2]|0)==1&(k[f>>2]|0)==1):0){d=0;break}d=k[d>>2]|0}while(0);r=q;return d|0}function fc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;i[b+53>>0]=1;do if((k[b+4>>2]|0)==(d|0)){i[b+52>>0]=1;d=b+16|0;a=k[d>>2]|0;if(!a){k[d>>2]=c;k[b+24>>2]=e;k[b+36>>2]=1;if(!((e|0)==1?(k[b+48>>2]|0)==1:0))break;i[b+54>>0]=1;break}if((a|0)!=(c|0)){e=b+36|0;k[e>>2]=(k[e>>2]|0)+1;i[b+54>>0]=1;break}a=b+24|0;d=k[a>>2]|0;if((d|0)==2){k[a>>2]=e;d=e}if((d|0)==1?(k[b+48>>2]|0)==1:0)i[b+54>>0]=1}while(0);return}function gc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0;a:do if((a|0)==(k[b+8>>2]|0)){if((k[b+4>>2]|0)==(c|0)?(f=b+28|0,(k[f>>2]|0)!=1):0)k[f>>2]=d}else{if((a|0)!=(k[b>>2]|0)){h=k[a+8>>2]|0;Va[k[(k[h>>2]|0)+24>>2]&3](h,b,c,d,e);break}if((k[b+16>>2]|0)!=(c|0)?(g=b+20|0,(k[g>>2]|0)!=(c|0)):0){k[b+32>>2]=d;d=b+44|0;if((k[d>>2]|0)==4)break;f=b+52|0;i[f>>0]=0;j=b+53|0;i[j>>0]=0;a=k[a+8>>2]|0;_a[k[(k[a>>2]|0)+20>>2]&3](a,b,c,c,1,e);if(i[j>>0]|0){if(!(i[f>>0]|0)){f=1;h=13}}else{f=0;h=13}do if((h|0)==13){k[g>>2]=c;j=b+40|0;k[j>>2]=(k[j>>2]|0)+1;if((k[b+36>>2]|0)==1?(k[b+24>>2]|0)==2:0){i[b+54>>0]=1;if(f)break}else h=16;if((h|0)==16?f:0)break;k[d>>2]=4;break a}while(0);k[d>>2]=3;break}if((d|0)==1)k[b+32>>2]=1}while(0);return}function hc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;do if((a|0)==(k[b+8>>2]|0)){if((k[b+4>>2]|0)==(c|0)?(g=b+28|0,(k[g>>2]|0)!=1):0)k[g>>2]=d}else if((a|0)==(k[b>>2]|0)){if((k[b+16>>2]|0)!=(c|0)?(f=b+20|0,(k[f>>2]|0)!=(c|0)):0){k[b+32>>2]=d;k[f>>2]=c;e=b+40|0;k[e>>2]=(k[e>>2]|0)+1;if((k[b+36>>2]|0)==1?(k[b+24>>2]|0)==2:0)i[b+54>>0]=1;k[b+44>>2]=4;break}if((d|0)==1)k[b+32>>2]=1}while(0);return}function ic(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if((a|0)==(k[b+8>>2]|0))fc(0,b,c,d,e);else{a=k[a+8>>2]|0;_a[k[(k[a>>2]|0)+20>>2]&3](a,b,c,d,e,f)}return}function jc(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if((a|0)==(k[b+8>>2]|0))fc(0,b,c,d,e);return}function kc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=r;r=r+16|0;d=e;k[d>>2]=k[c>>2];a=Ua[k[(k[a>>2]|0)+16>>2]&7](a,b,d)|0;if(a)k[c>>2]=k[d>>2];r=e;return a&1|0}function lc(a){a=a|0;if(!a)a=0;else a=(ec(a,24,72,0)|0)!=0;return a&1|0}function mc(){var a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;e=r;r=r+48|0;g=e+32|0;c=e+24|0;h=e+16|0;f=e;e=e+36|0;a=Sb()|0;if((a|0)!=0?(d=k[a>>2]|0,(d|0)!=0):0){a=d+48|0;b=k[a>>2]|0;a=k[a+4>>2]|0;if(!((b&-256|0)==1126902528&(a|0)==1129074247)){k[c>>2]=k[51];Rb(2368,c)}if((b|0)==1126902529&(a|0)==1129074247)a=k[d+44>>2]|0;else a=d+80|0;k[e>>2]=a;d=k[d>>2]|0;a=k[d+4>>2]|0;if(Ua[k[(k[8>>2]|0)+16>>2]&7](8,d,e)|0){h=k[e>>2]|0;e=k[51]|0;h=Xa[k[(k[h>>2]|0)+8>>2]&1](h)|0;k[f>>2]=e;k[f+4>>2]=a;k[f+8>>2]=h;Rb(2282,f)}else{k[h>>2]=k[51];k[h+4>>2]=a;Rb(2327,h)}}Rb(2406,g)}function nc(){var a=0;a=r;r=r+16|0;if(!(Ia(196,6)|0)){r=a;return}else Rb(2179,a)}function oc(a){a=a|0;var b=0;b=r;r=r+16|0;Vc(a);if(!(La(k[49]|0,0)|0)){r=b;return}else Rb(2229,b)}function pc(a){a=a|0;var b=0,c=0;b=0;while(1){if((l[2427+b>>0]|0)==(a|0)){c=2;break}b=b+1|0;if((b|0)==87){b=87;a=2515;c=5;break}}if((c|0)==2)if(!b)a=2515;else{a=2515;c=5}if((c|0)==5)while(1){c=a;while(1){a=c+1|0;if(!(i[c>>0]|0))break;else c=a}b=b+-1|0;if(!b)break;else c=5}return a|0}function qc(){var a=0;if(!(k[52]|0))a=264;else{a=(Ga()|0)+60|0;a=k[a>>2]|0}return a|0}function rc(a){a=a|0;var b=0;if(a>>>0>4294963200){b=qc()|0;k[b>>2]=0-a;a=-1}return a|0}function sc(a,b){a=+a;b=b|0;var c=0,d=0,e=0;p[t>>3]=a;c=k[t>>2]|0;d=k[t+4>>2]|0;e=bd(c|0,d|0,52)|0;e=e&2047;switch(e|0){case 0:{if(a!=0.0){a=+sc(a*18446744073709552.0e3,b);c=(k[b>>2]|0)+-64|0}else c=0;k[b>>2]=c;break}case 2047:break;default:{k[b>>2]=e+-1022;k[t>>2]=c;k[t+4>>2]=d&-2146435073|1071644672;a=+p[t>>3]}}return +a}function tc(a,b){a=+a;b=b|0;return +(+sc(a,b))}function uc(a,b,c){a=a|0;b=b|0;c=c|0;do if(a){if(b>>>0<128){i[a>>0]=b;a=1;break}if(b>>>0<2048){i[a>>0]=b>>>6|192;i[a+1>>0]=b&63|128;a=2;break}if(b>>>0<55296|(b&-8192|0)==57344){i[a>>0]=b>>>12|224;i[a+1>>0]=b>>>6&63|128;i[a+2>>0]=b&63|128;a=3;break}if((b+-65536|0)>>>0<1048576){i[a>>0]=b>>>18|240;i[a+1>>0]=b>>>12&63|128;i[a+2>>0]=b>>>6&63|128;i[a+3>>0]=b&63|128;a=4;break}else{a=qc()|0;k[a>>2]=84;a=-1;break}}else a=1;while(0);return a|0}function vc(a,b){a=a|0;b=b|0;if(!a)a=0;else a=uc(a,b,0)|0;return a|0}function wc(a){a=a|0;var b=0,c=0;do if(a){if((k[a+76>>2]|0)<=-1){b=Nc(a)|0;break}c=(Ec(a)|0)==0;b=Nc(a)|0;if(!c)Fc(a)}else{if(!(k[65]|0))b=0;else b=wc(k[65]|0)|0;Ma(236);a=k[58]|0;if(a)do{if((k[a+76>>2]|0)>-1)c=Ec(a)|0;else c=0;if((k[a+20>>2]|0)>>>0>(k[a+28>>2]|0)>>>0)b=Nc(a)|0|b;if(c)Fc(a);a=k[a+56>>2]|0}while((a|0)!=0);Ja(236)}while(0);return b|0}function xc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;if((k[b+76>>2]|0)>=0?(Ec(b)|0)!=0:0){if((i[b+75>>0]|0)!=(a|0)?(d=b+20|0,e=k[d>>2]|0,e>>>0<(k[b+16>>2]|0)>>>0):0){k[d>>2]=e+1;i[e>>0]=a;c=a&255}else c=Gc(b,a)|0;Fc(b)}else g=3;do if((g|0)==3){if((i[b+75>>0]|0)!=(a|0)?(f=b+20|0,c=k[f>>2]|0,c>>>0<(k[b+16>>2]|0)>>>0):0){k[f>>2]=c+1;i[c>>0]=a;c=a&255;break}c=Gc(b,a)|0}while(0);return c|0}function yc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=c+16|0;e=k[d>>2]|0;if(!e)if(!(Lc(c)|0)){e=k[d>>2]|0;f=4}else d=0;else f=4;a:do if((f|0)==4){g=c+20|0;f=k[g>>2]|0;if((e-f|0)>>>0>>0){d=Ua[k[c+36>>2]&7](c,a,b)|0;break}b:do if((i[c+75>>0]|0)>-1){d=b;while(1){if(!d){e=f;d=0;break b}e=d+-1|0;if((i[a+e>>0]|0)==10)break;else d=e}if((Ua[k[c+36>>2]&7](c,a,d)|0)>>>0>>0)break a;b=b-d|0;a=a+d|0;e=k[g>>2]|0}else{e=f;d=0}while(0);ed(e|0,a|0,b|0)|0;k[g>>2]=(k[g>>2]|0)+b;d=d+b|0}while(0);return d|0}function zc(a,b){a=a|0;b=b|0;var c=0,d=0;c=r;r=r+16|0;d=c;k[d>>2]=b;b=Bc(k[64]|0,a,d)|0;r=c;return b|0}function Ac(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=r;r=r+16|0;e=d;k[e>>2]=c;c=Dc(a,b,e)|0;r=d;return c|0}function Bc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,s=0;s=r;r=r+224|0;n=s+120|0;q=s+80|0;p=s;o=s+136|0;d=q;e=d+40|0;do{k[d>>2]=0;d=d+4|0}while((d|0)<(e|0));k[n>>2]=k[c>>2];if((Oc(0,b,n,p,q)|0)<0)c=-1;else{if((k[a+76>>2]|0)>-1)l=Ec(a)|0;else l=0;c=k[a>>2]|0;m=c&32;if((i[a+74>>0]|0)<1)k[a>>2]=c&-33;c=a+48|0;if(!(k[c>>2]|0)){e=a+44|0;f=k[e>>2]|0;k[e>>2]=o;g=a+28|0;k[g>>2]=o;h=a+20|0;k[h>>2]=o;k[c>>2]=80;j=a+16|0;k[j>>2]=o+80;d=Oc(a,b,n,p,q)|0;if(f){Ua[k[a+36>>2]&7](a,0,0)|0;d=(k[h>>2]|0)==0?-1:d;k[e>>2]=f;k[c>>2]=0;k[j>>2]=0;k[g>>2]=0;k[h>>2]=0}}else d=Oc(a,b,n,p,q)|0;c=k[a>>2]|0;k[a>>2]=c|m;if(l)Fc(a);c=(c&32|0)==0?d:-1}r=s;return c|0}function Cc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,l=0,m=0;m=r;r=r+128|0;e=m+112|0;l=m;f=l;g=268;h=f+112|0;do{k[f>>2]=k[g>>2];f=f+4|0;g=g+4|0}while((f|0)<(h|0));if((b+-1|0)>>>0>2147483646)if(!b){b=1;j=4}else{b=qc()|0;k[b>>2]=75;b=-1}else{e=a;j=4}if((j|0)==4){j=-2-e|0;j=b>>>0>j>>>0?j:b;k[l+48>>2]=j;a=l+20|0;k[a>>2]=e;k[l+44>>2]=e;b=e+j|0;e=l+16|0;k[e>>2]=b;k[l+28>>2]=b;b=Bc(l,c,d)|0;if(j){c=k[a>>2]|0;i[c+(((c|0)==(k[e>>2]|0))<<31>>31)>>0]=0}}r=m;return b|0}function Dc(a,b,c){a=a|0;b=b|0;c=c|0;return Cc(a,2147483647,b,c)|0}function Ec(a){a=a|0;return 0}function Fc(a){a=a|0;return}function Gc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0;j=r;r=r+16|0;h=j;g=b&255;i[h>>0]=g;d=a+16|0;e=k[d>>2]|0;if(!e)if(!(Lc(a)|0)){e=k[d>>2]|0;f=4}else c=-1;else f=4;do if((f|0)==4){d=a+20|0;f=k[d>>2]|0;if(f>>>0>>0?(c=b&255,(c|0)!=(i[a+75>>0]|0)):0){k[d>>2]=f+1;i[f>>0]=g;break}if((Ua[k[a+36>>2]&7](a,h,1)|0)==1)c=l[h>>0]|0;else c=-1}while(0);r=j;return c|0}function Hc(a){a=a|0;var b=0,c=0;b=r;r=r+16|0;c=b;k[c>>2]=k[a+60>>2];a=rc(xa(6,c|0)|0)|0;r=b;return a|0}function Ic(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;e=r;r=r+32|0;f=e;d=e+20|0;k[f>>2]=k[a+60>>2];k[f+4>>2]=0;k[f+8>>2]=b;k[f+12>>2]=d;k[f+16>>2]=c;if((rc(Qa(140,f|0)|0)|0)<0){k[d>>2]=-1;a=-1}else a=k[d>>2]|0;r=e;return a|0}function Jc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;p=r;r=r+48|0;m=p+16|0;l=p;d=p+32|0;n=a+28|0;e=k[n>>2]|0;k[d>>2]=e;o=a+20|0;e=(k[o>>2]|0)-e|0;k[d+4>>2]=e;k[d+8>>2]=b;k[d+12>>2]=c;i=a+60|0;j=a+44|0;b=2;e=e+c|0;while(1){if(!(k[52]|0)){k[m>>2]=k[i>>2];k[m+4>>2]=d;k[m+8>>2]=b;g=rc(Ra(146,m|0)|0)|0}else{Oa(7,a|0);k[l>>2]=k[i>>2];k[l+4>>2]=d;k[l+8>>2]=b;g=rc(Ra(146,l|0)|0)|0;va(0)}if((e|0)==(g|0)){e=6;break}if((g|0)<0){e=8;break}e=e-g|0;f=k[d+4>>2]|0;if(g>>>0<=f>>>0)if((b|0)==2){k[n>>2]=(k[n>>2]|0)+g;h=f;b=2}else h=f;else{h=k[j>>2]|0;k[n>>2]=h;k[o>>2]=h;h=k[d+12>>2]|0;g=g-f|0;d=d+8|0;b=b+-1|0}k[d>>2]=(k[d>>2]|0)+g;k[d+4>>2]=h-g}if((e|0)==6){m=k[j>>2]|0;k[a+16>>2]=m+(k[a+48>>2]|0);a=m;k[n>>2]=a;k[o>>2]=a}else if((e|0)==8){k[a+16>>2]=0;k[n>>2]=0;k[o>>2]=0;k[a>>2]=k[a>>2]|32;if((b|0)==2)c=0;else c=c-(k[d+4>>2]|0)|0}r=p;return c|0}function Kc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=r;r=r+80|0;d=e;k[a+36>>2]=3;if((k[a>>2]&64|0)==0?(k[d>>2]=k[a+60>>2],k[d+4>>2]=21505,k[d+8>>2]=e+12,(wa(54,d|0)|0)!=0):0)i[a+75>>0]=-1;d=Jc(a,b,c)|0;r=e;return d|0}function Lc(a){a=a|0;var b=0,c=0;b=a+74|0;c=i[b>>0]|0;i[b>>0]=c+255|c;b=k[a>>2]|0;if(!(b&8)){k[a+8>>2]=0;k[a+4>>2]=0;b=k[a+44>>2]|0;k[a+28>>2]=b;k[a+20>>2]=b;k[a+16>>2]=b+(k[a+48>>2]|0);b=0}else{k[a>>2]=b|32;b=-1}return b|0}function Mc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;f=b&255;d=(c|0)!=0;a:do if(d&(a&3|0)!=0){e=b&255;while(1){if((i[a>>0]|0)==e<<24>>24){g=6;break a}a=a+1|0;c=c+-1|0;d=(c|0)!=0;if(!(d&(a&3|0)!=0)){g=5;break}}}else g=5;while(0);if((g|0)==5)if(d)g=6;else c=0;b:do if((g|0)==6){e=b&255;if((i[a>>0]|0)!=e<<24>>24){d=ha(f,16843009)|0;c:do if(c>>>0>3)while(1){f=k[a>>2]^d;if((f&-2139062144^-2139062144)&f+-16843009)break;a=a+4|0;c=c+-4|0;if(c>>>0<=3){g=11;break c}}else g=11;while(0);if((g|0)==11)if(!c){c=0;break}while(1){if((i[a>>0]|0)==e<<24>>24)break b;a=a+1|0;c=c+-1|0;if(!c){c=0;break}}}}while(0);return ((c|0)!=0?a:0)|0}function Nc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;b=a+20|0;f=a+28|0;if((k[b>>2]|0)>>>0>(k[f>>2]|0)>>>0?(Ua[k[a+36>>2]&7](a,0,0)|0,(k[b>>2]|0)==0):0)b=-1;else{g=a+4|0;c=k[g>>2]|0;d=a+8|0;e=k[d>>2]|0;if(c>>>0>>0)Ua[k[a+40>>2]&7](a,c-e|0,1)|0;k[a+16>>2]=0;k[f>>2]=0;k[b>>2]=0;k[d>>2]=0;k[g>>2]=0;b=0}return b|0}function Oc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,m=0,n=0.0,o=0,q=0,s=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0;ga=r;r=r+624|0;ba=ga+24|0;da=ga+16|0;ca=ga+588|0;Y=ga+576|0;aa=ga;V=ga+536|0;fa=ga+8|0;ea=ga+528|0;M=(a|0)!=0;N=V+40|0;U=N;V=V+39|0;W=fa+4|0;X=Y+12|0;Y=Y+11|0;Z=ca;_=X;$=_-Z|0;O=-2-Z|0;P=_+2|0;Q=ba+288|0;R=ca+9|0;S=R;T=ca+8|0;f=0;w=b;g=0;b=0;a:while(1){do if((f|0)>-1)if((g|0)>(2147483647-f|0)){f=qc()|0;k[f>>2]=75;f=-1;break}else{f=g+f|0;break}while(0);g=i[w>>0]|0;if(!(g<<24>>24)){K=245;break}else h=w;b:while(1){switch(g<<24>>24){case 37:{g=h;K=9;break b}case 0:{g=h;break b}default:{}}J=h+1|0;g=i[J>>0]|0;h=J}c:do if((K|0)==9)while(1){K=0;if((i[g+1>>0]|0)!=37)break c;h=h+1|0;g=g+2|0;if((i[g>>0]|0)==37)K=9;else break}while(0);y=h-w|0;if(M?(k[a>>2]&32|0)==0:0)yc(w,y,a)|0;if((h|0)!=(w|0)){w=g;g=y;continue}o=g+1|0;h=i[o>>0]|0;m=(h<<24>>24)+-48|0;if(m>>>0<10){J=(i[g+2>>0]|0)==36;o=J?g+3|0:o;h=i[o>>0]|0;u=J?m:-1;b=J?1:b}else u=-1;g=h<<24>>24;d:do if((g&-32|0)==32){m=0;while(1){if(!(1<>24)+-32|m;o=o+1|0;h=i[o>>0]|0;g=h<<24>>24;if((g&-32|0)!=32){q=m;g=o;break}}}else{q=0;g=o}while(0);do if(h<<24>>24==42){m=g+1|0;h=(i[m>>0]|0)+-48|0;if(h>>>0<10?(i[g+2>>0]|0)==36:0){k[e+(h<<2)>>2]=10;b=1;g=g+3|0;h=k[d+((i[m>>0]|0)+-48<<3)>>2]|0}else{if(b){f=-1;break a}if(!M){x=q;g=m;b=0;J=0;break}b=(k[c>>2]|0)+(4-1)&~(4-1);h=k[b>>2]|0;k[c>>2]=b+4;b=0;g=m}if((h|0)<0){x=q|8192;J=0-h|0}else{x=q;J=h}}else{m=(h<<24>>24)+-48|0;if(m>>>0<10){h=0;do{h=(h*10|0)+m|0;g=g+1|0;m=(i[g>>0]|0)+-48|0}while(m>>>0<10);if((h|0)<0){f=-1;break a}else{x=q;J=h}}else{x=q;J=0}}while(0);e:do if((i[g>>0]|0)==46){m=g+1|0;h=i[m>>0]|0;if(h<<24>>24!=42){o=(h<<24>>24)+-48|0;if(o>>>0<10){g=m;h=0}else{g=m;o=0;break}while(1){h=(h*10|0)+o|0;g=g+1|0;o=(i[g>>0]|0)+-48|0;if(o>>>0>=10){o=h;break e}}}m=g+2|0;h=(i[m>>0]|0)+-48|0;if(h>>>0<10?(i[g+3>>0]|0)==36:0){k[e+(h<<2)>>2]=10;g=g+4|0;o=k[d+((i[m>>0]|0)+-48<<3)>>2]|0;break}if(b){f=-1;break a}if(M){g=(k[c>>2]|0)+(4-1)&~(4-1);o=k[g>>2]|0;k[c>>2]=g+4;g=m}else{g=m;o=0}}else o=-1;while(0);s=0;while(1){h=(i[g>>0]|0)+-65|0;if(h>>>0>57){f=-1;break a}m=g+1|0;h=i[5359+(s*58|0)+h>>0]|0;q=h&255;if((q+-1|0)>>>0<8){g=m;s=q}else{I=m;break}}if(!(h<<24>>24)){f=-1;break}m=(u|0)>-1;do if(h<<24>>24==19)if(m){f=-1;break a}else K=52;else{if(m){k[e+(u<<2)>>2]=q;G=d+(u<<3)|0;H=k[G+4>>2]|0;K=aa;k[K>>2]=k[G>>2];k[K+4>>2]=H;K=52;break}if(!M){f=0;break a}Rc(aa,q,c)}while(0);if((K|0)==52?(K=0,!M):0){w=I;g=y;continue}u=i[g>>0]|0;u=(s|0)!=0&(u&15|0)==3?u&-33:u;m=x&-65537;H=(x&8192|0)==0?x:m;f:do switch(u|0){case 110:switch(s|0){case 0:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 1:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 2:{w=k[aa>>2]|0;k[w>>2]=f;k[w+4>>2]=((f|0)<0)<<31>>31;w=I;g=y;continue a}case 3:{j[k[aa>>2]>>1]=f;w=I;g=y;continue a}case 4:{i[k[aa>>2]>>0]=f;w=I;g=y;continue a}case 6:{k[k[aa>>2]>>2]=f;w=I;g=y;continue a}case 7:{w=k[aa>>2]|0;k[w>>2]=f;k[w+4>>2]=((f|0)<0)<<31>>31;w=I;g=y;continue a}default:{w=I;g=y;continue a}}case 112:{s=H|8;o=o>>>0>8?o:8;u=120;K=64;break}case 88:case 120:{s=H;K=64;break}case 111:{m=aa;h=k[m>>2]|0;m=k[m+4>>2]|0;if((h|0)==0&(m|0)==0)g=N;else{g=N;do{g=g+-1|0;i[g>>0]=h&7|48;h=bd(h|0,m|0,3)|0;m=L}while(!((h|0)==0&(m|0)==0))}if(!(H&8)){h=H;s=0;q=5839;K=77}else{s=U-g+1|0;h=H;o=(o|0)<(s|0)?s:o;s=0;q=5839;K=77}break}case 105:case 100:{h=aa;g=k[h>>2]|0;h=k[h+4>>2]|0;if((h|0)<0){g=$c(0,0,g|0,h|0)|0;h=L;m=aa;k[m>>2]=g;k[m+4>>2]=h;m=1;q=5839;K=76;break f}if(!(H&2048)){q=H&1;m=q;q=(q|0)==0?5839:5841;K=76}else{m=1;q=5840;K=76}break}case 117:{h=aa;g=k[h>>2]|0;h=k[h+4>>2]|0;m=0;q=5839;K=76;break}case 99:{i[V>>0]=k[aa>>2];w=V;h=1;s=0;u=5839;g=N;break}case 109:{g=qc()|0;g=pc(k[g>>2]|0)|0;K=82;break}case 115:{g=k[aa>>2]|0;g=(g|0)!=0?g:5849;K=82;break}case 67:{k[fa>>2]=k[aa>>2];k[W>>2]=0;k[aa>>2]=fa;o=-1;K=86;break}case 83:{if(!o){Tc(a,32,J,0,H);g=0;K=98}else K=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{n=+p[aa>>3];k[da>>2]=0;p[t>>3]=n;if((k[t+4>>2]|0)>=0)if(!(H&2048)){G=H&1;F=G;G=(G|0)==0?5857:5862}else{F=1;G=5859}else{n=-n;F=1;G=5856}p[t>>3]=n;E=k[t+4>>2]&2146435072;do if(E>>>0<2146435072|(E|0)==2146435072&0<0){v=+tc(n,da)*2.0;h=v!=0.0;if(h)k[da>>2]=(k[da>>2]|0)+-1;C=u|32;if((C|0)==97){w=u&32;y=(w|0)==0?G:G+9|0;x=F|2;g=12-o|0;do if(!(o>>>0>11|(g|0)==0)){n=8.0;do{g=g+-1|0;n=n*16.0}while((g|0)!=0);if((i[y>>0]|0)==45){n=-(n+(-v-n));break}else{n=v+n-n;break}}else n=v;while(0);h=k[da>>2]|0;g=(h|0)<0?0-h|0:h;g=Sc(g,((g|0)<0)<<31>>31,X)|0;if((g|0)==(X|0)){i[Y>>0]=48;g=Y}i[g+-1>>0]=(h>>31&2)+43;s=g+-2|0;i[s>>0]=u+15;q=(o|0)<1;m=(H&8|0)==0;h=ca;while(1){G=~~n;g=h+1|0;i[h>>0]=l[5823+G>>0]|w;n=(n-+(G|0))*16.0;do if((g-Z|0)==1){if(m&(q&n==0.0))break;i[g>>0]=46;g=h+2|0}while(0);if(!(n!=0.0))break;else h=g}o=(o|0)!=0&(O+g|0)<(o|0)?P+o-s|0:$-s+g|0;m=o+x|0;Tc(a,32,J,m,H);if(!(k[a>>2]&32))yc(y,x,a)|0;Tc(a,48,J,m,H^65536);g=g-Z|0;if(!(k[a>>2]&32))yc(ca,g,a)|0;h=_-s|0;Tc(a,48,o-(g+h)|0,0,0);if(!(k[a>>2]&32))yc(s,h,a)|0;Tc(a,32,J,m,H^8192);g=(m|0)<(J|0)?J:m;break}g=(o|0)<0?6:o;if(h){h=(k[da>>2]|0)+-28|0;k[da>>2]=h;n=v*268435456.0}else{n=v;h=k[da>>2]|0}E=(h|0)<0?ba:Q;D=E;h=E;do{B=~~n>>>0;k[h>>2]=B;h=h+4|0;n=(n-+(B>>>0))*1.0e9}while(n!=0.0);m=h;h=k[da>>2]|0;if((h|0)>0){q=E;while(1){s=(h|0)>29?29:h;o=m+-4|0;do if(o>>>0>>0)o=q;else{h=0;do{B=cd(k[o>>2]|0,0,s|0)|0;B=dd(B|0,L|0,h|0,0)|0;h=L;A=md(B|0,h|0,1e9,0)|0;k[o>>2]=A;h=ld(B|0,h|0,1e9,0)|0;o=o+-4|0}while(o>>>0>=q>>>0);if(!h){o=q;break}o=q+-4|0;k[o>>2]=h}while(0);while(1){if(m>>>0<=o>>>0)break;h=m+-4|0;if(!(k[h>>2]|0))m=h;else break}h=(k[da>>2]|0)-s|0;k[da>>2]=h;if((h|0)>0)q=o;else break}}else o=E;if((h|0)<0){y=((g+25|0)/9|0)+1|0;z=(C|0)==102;w=o;while(1){x=0-h|0;x=(x|0)>9?9:x;do if(w>>>0>>0){h=(1<>>x;o=0;s=w;do{B=k[s>>2]|0;k[s>>2]=(B>>>x)+o;o=ha(B&h,q)|0;s=s+4|0}while(s>>>0>>0);h=(k[w>>2]|0)==0?w+4|0:w;if(!o){o=h;break}k[m>>2]=o;o=h;m=m+4|0}else o=(k[w>>2]|0)==0?w+4|0:w;while(0);h=z?E:o;m=(m-h>>2|0)>(y|0)?h+(y<<2)|0:m;h=(k[da>>2]|0)+x|0;k[da>>2]=h;if((h|0)>=0){w=o;break}else w=o}}else w=o;do if(w>>>0>>0){h=(D-w>>2)*9|0;q=k[w>>2]|0;if(q>>>0<10)break;else o=10;do{o=o*10|0;h=h+1|0}while(q>>>0>=o>>>0)}else h=0;while(0);A=(C|0)==103;B=(g|0)!=0;o=g-((C|0)!=102?h:0)+((B&A)<<31>>31)|0;if((o|0)<(((m-D>>2)*9|0)+-9|0)){s=o+9216|0;z=(s|0)/9|0;o=E+(z+-1023<<2)|0;s=((s|0)%9|0)+1|0;if((s|0)<9){q=10;do{q=q*10|0;s=s+1|0}while((s|0)!=9)}else q=10;x=k[o>>2]|0;y=(x>>>0)%(q>>>0)|0;if((y|0)==0?(E+(z+-1022<<2)|0)==(m|0):0)q=w;else K=163;do if((K|0)==163){K=0;v=(((x>>>0)/(q>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;s=(q|0)/2|0;do if(y>>>0>>0)n=.5;else{if((y|0)==(s|0)?(E+(z+-1022<<2)|0)==(m|0):0){n=1.0;break}n=1.5}while(0);do if(F){if((i[G>>0]|0)!=45)break;v=-v;n=-n}while(0);s=x-y|0;k[o>>2]=s;if(!(v+n!=v)){q=w;break}C=s+q|0;k[o>>2]=C;if(C>>>0>999999999){h=w;while(1){q=o+-4|0;k[o>>2]=0;if(q>>>0>>0){h=h+-4|0;k[h>>2]=0}C=(k[q>>2]|0)+1|0;k[q>>2]=C;if(C>>>0>999999999)o=q;else{w=h;o=q;break}}}h=(D-w>>2)*9|0;s=k[w>>2]|0;if(s>>>0<10){q=w;break}else q=10;do{q=q*10|0;h=h+1|0}while(s>>>0>=q>>>0);q=w}while(0);C=o+4|0;w=q;m=m>>>0>C>>>0?C:m}y=0-h|0;while(1){if(m>>>0<=w>>>0){z=0;C=m;break}o=m+-4|0;if(!(k[o>>2]|0))m=o;else{z=1;C=m;break}}do if(A){g=(B&1^1)+g|0;if((g|0)>(h|0)&(h|0)>-5){u=u+-1|0;g=g+-1-h|0}else{u=u+-2|0;g=g+-1|0}m=H&8;if(m)break;do if(z){m=k[C+-4>>2]|0;if(!m){o=9;break}if(!((m>>>0)%10|0)){q=10;o=0}else{o=0;break}do{q=q*10|0;o=o+1|0}while(((m>>>0)%(q>>>0)|0|0)==0)}else o=9;while(0);m=((C-D>>2)*9|0)+-9|0;if((u|32|0)==102){m=m-o|0;m=(m|0)<0?0:m;g=(g|0)<(m|0)?g:m;m=0;break}else{m=m+h-o|0;m=(m|0)<0?0:m;g=(g|0)<(m|0)?g:m;m=0;break}}else m=H&8;while(0);x=g|m;q=(x|0)!=0&1;s=(u|32|0)==102;if(s){h=(h|0)>0?h:0;u=0}else{o=(h|0)<0?y:h;o=Sc(o,((o|0)<0)<<31>>31,X)|0;if((_-o|0)<2)do{o=o+-1|0;i[o>>0]=48}while((_-o|0)<2);i[o+-1>>0]=(h>>31&2)+43;D=o+-2|0;i[D>>0]=u;h=_-D|0;u=D}y=F+1+g+q+h|0;Tc(a,32,J,y,H);if(!(k[a>>2]&32))yc(G,F,a)|0;Tc(a,48,J,y,H^65536);do if(s){o=w>>>0>E>>>0?E:w;h=o;do{m=Sc(k[h>>2]|0,0,R)|0;do if((h|0)==(o|0)){if((m|0)!=(R|0))break;i[T>>0]=48;m=T}else{if(m>>>0<=ca>>>0)break;do{m=m+-1|0;i[m>>0]=48}while(m>>>0>ca>>>0)}while(0);if(!(k[a>>2]&32))yc(m,S-m|0,a)|0;h=h+4|0}while(h>>>0<=E>>>0);do if(x){if(k[a>>2]&32)break;yc(5891,1,a)|0}while(0);if((g|0)>0&h>>>0>>0){m=h;while(1){h=Sc(k[m>>2]|0,0,R)|0;if(h>>>0>ca>>>0)do{h=h+-1|0;i[h>>0]=48}while(h>>>0>ca>>>0);if(!(k[a>>2]&32))yc(h,(g|0)>9?9:g,a)|0;m=m+4|0;h=g+-9|0;if(!((g|0)>9&m>>>0>>0)){g=h;break}else g=h}}Tc(a,48,g+9|0,9,0)}else{s=z?C:w+4|0;if((g|0)>-1){q=(m|0)==0;o=w;do{h=Sc(k[o>>2]|0,0,R)|0;if((h|0)==(R|0)){i[T>>0]=48;h=T}do if((o|0)==(w|0)){m=h+1|0;if(!(k[a>>2]&32))yc(h,1,a)|0;if(q&(g|0)<1){h=m;break}if(k[a>>2]&32){h=m;break}yc(5891,1,a)|0;h=m}else{if(h>>>0<=ca>>>0)break;do{h=h+-1|0;i[h>>0]=48}while(h>>>0>ca>>>0)}while(0);m=S-h|0;if(!(k[a>>2]&32))yc(h,(g|0)>(m|0)?m:g,a)|0;g=g-m|0;o=o+4|0}while(o>>>0>>0&(g|0)>-1)}Tc(a,48,g+18|0,18,0);if(k[a>>2]&32)break;yc(u,_-u|0,a)|0}while(0);Tc(a,32,J,y,H^8192);g=(y|0)<(J|0)?J:y}else{s=(u&32|0)!=0;q=n!=n|0.0!=0.0;h=q?0:F;o=h+3|0;Tc(a,32,J,o,m);g=k[a>>2]|0;if(!(g&32)){yc(G,h,a)|0;g=k[a>>2]|0}if(!(g&32))yc(q?(s?5883:5887):s?5875:5879,3,a)|0;Tc(a,32,J,o,H^8192);g=(o|0)<(J|0)?J:o}while(0);w=I;continue a}default:{m=H;h=o;s=0;u=5839;g=N}}while(0);g:do if((K|0)==64){m=aa;h=k[m>>2]|0;m=k[m+4>>2]|0;q=u&32;if(!((h|0)==0&(m|0)==0)){g=N;do{g=g+-1|0;i[g>>0]=l[5823+(h&15)>>0]|q;h=bd(h|0,m|0,4)|0;m=L}while(!((h|0)==0&(m|0)==0));K=aa;if((s&8|0)==0|(k[K>>2]|0)==0&(k[K+4>>2]|0)==0){h=s;s=0;q=5839;K=77}else{h=s;s=2;q=5839+(u>>4)|0;K=77}}else{g=N;h=s;s=0;q=5839;K=77}}else if((K|0)==76){g=Sc(g,h,N)|0;h=H;s=m;K=77}else if((K|0)==82){K=0;H=Mc(g,0,o)|0;G=(H|0)==0;w=g;h=G?o:H-g|0;s=0;u=5839;g=G?g+o|0:H}else if((K|0)==86){K=0;h=0;g=0;q=k[aa>>2]|0;while(1){m=k[q>>2]|0;if(!m)break;g=vc(ea,m)|0;if((g|0)<0|g>>>0>(o-h|0)>>>0)break;h=g+h|0;if(o>>>0>h>>>0)q=q+4|0;else break}if((g|0)<0){f=-1;break a}Tc(a,32,J,h,H);if(!h){g=0;K=98}else{m=0;o=k[aa>>2]|0;while(1){g=k[o>>2]|0;if(!g){g=h;K=98;break g}g=vc(ea,g)|0;m=g+m|0;if((m|0)>(h|0)){g=h;K=98;break g}if(!(k[a>>2]&32))yc(ea,g,a)|0;if(m>>>0>=h>>>0){g=h;K=98;break}else o=o+4|0}}}while(0);if((K|0)==98){K=0;Tc(a,32,J,g,H^8192);w=I;g=(J|0)>(g|0)?J:g;continue}if((K|0)==77){K=0;m=(o|0)>-1?h&-65537:h;h=aa;h=(k[h>>2]|0)!=0|(k[h+4>>2]|0)!=0;if((o|0)!=0|h){h=(h&1^1)+(U-g)|0;w=g;h=(o|0)>(h|0)?o:h;u=q;g=N}else{w=N;h=0;u=q;g=N}}q=g-w|0;h=(h|0)<(q|0)?q:h;o=s+h|0;g=(J|0)<(o|0)?o:J;Tc(a,32,g,o,m);if(!(k[a>>2]&32))yc(u,s,a)|0;Tc(a,48,g,o,m^65536);Tc(a,48,h,q,0);if(!(k[a>>2]&32))yc(w,q,a)|0;Tc(a,32,g,o,m^8192);w=I}h:do if((K|0)==245)if(!a)if(b){f=1;while(1){b=k[e+(f<<2)>>2]|0;if(!b)break;Rc(d+(f<<3)|0,b,c);f=f+1|0;if((f|0)>=10){f=1;break h}}if((f|0)<10)while(1){if(k[e+(f<<2)>>2]|0){f=-1;break h}f=f+1|0;if((f|0)>=10){f=1;break}}else f=1}else f=0;while(0);r=ga;return f|0}function Pc(a){a=a|0;if(!(k[a+68>>2]|0))Fc(a);return}function Qc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=a+20|0;e=k[d>>2]|0;a=(k[a+16>>2]|0)-e|0;a=a>>>0>c>>>0?c:a;ed(e|0,b|0,a|0)|0;k[d>>2]=(k[d>>2]|0)+a;return c|0}function Rc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;k[a>>2]=b;break a}case 10:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;d=a;k[d>>2]=b;k[d+4>>2]=((b|0)<0)<<31>>31;break a}case 11:{d=(k[c>>2]|0)+(4-1)&~(4-1);b=k[d>>2]|0;k[c>>2]=d+4;d=a;k[d>>2]=b;k[d+4>>2]=0;break a}case 12:{d=(k[c>>2]|0)+(8-1)&~(8-1);b=d;e=k[b>>2]|0;b=k[b+4>>2]|0;k[c>>2]=d+8;d=a;k[d>>2]=e;k[d+4>>2]=b;break a}case 13:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;d=(d&65535)<<16>>16;e=a;k[e>>2]=d;k[e+4>>2]=((d|0)<0)<<31>>31;break a}case 14:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;e=a;k[e>>2]=d&65535;k[e+4>>2]=0;break a}case 15:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;d=(d&255)<<24>>24;e=a;k[e>>2]=d;k[e+4>>2]=((d|0)<0)<<31>>31;break a}case 16:{e=(k[c>>2]|0)+(4-1)&~(4-1);d=k[e>>2]|0;k[c>>2]=e+4;e=a;k[e>>2]=d&255;k[e+4>>2]=0;break a}case 17:{e=(k[c>>2]|0)+(8-1)&~(8-1);f=+p[e>>3];k[c>>2]=e+8;p[a>>3]=f;break a}case 18:{e=(k[c>>2]|0)+(8-1)&~(8-1);f=+p[e>>3];k[c>>2]=e+8;p[a>>3]=f;break a}default:break a}while(0);while(0);return}function Sc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(b>>>0>0|(b|0)==0&a>>>0>4294967295)while(1){d=md(a|0,b|0,10,0)|0;c=c+-1|0;i[c>>0]=d|48;d=ld(a|0,b|0,10,0)|0;if(b>>>0>9|(b|0)==9&a>>>0>4294967295){a=d;b=L}else{a=d;break}}if(a)while(1){c=c+-1|0;i[c>>0]=(a>>>0)%10|0|48;if(a>>>0<10)break;else a=(a>>>0)/10|0}return c|0}function Tc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=r;r=r+256|0;g=h;do if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;ad(g|0,b|0,(e>>>0>256?256:e)|0)|0;b=k[a>>2]|0;f=(b&32|0)==0;if(e>>>0>255){d=c-d|0;do{if(f){yc(g,256,a)|0;b=k[a>>2]|0}e=e+-256|0;f=(b&32|0)==0}while(e>>>0>255);if(f)e=d&255;else break}else if(!f)break;yc(g,e,a)|0}while(0);r=h;return}function Uc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;do if(a>>>0<245){o=a>>>0<11?16:a+11&-8;a=o>>>3;h=k[151]|0;c=h>>>a;if(c&3){a=(c&1^1)+a|0;d=a<<1;c=644+(d<<2)|0;d=644+(d+2<<2)|0;e=k[d>>2]|0;f=e+8|0;g=k[f>>2]|0;do if((c|0)!=(g|0)){if(g>>>0<(k[155]|0)>>>0)Na();b=g+12|0;if((k[b>>2]|0)==(e|0)){k[b>>2]=c;k[d>>2]=g;break}else Na()}else k[151]=h&~(1<>2]=M|3;M=e+(M|4)|0;k[M>>2]=k[M>>2]|1;M=f;return M|0}g=k[153]|0;if(o>>>0>g>>>0){if(c){d=2<>>12&16;d=d>>>i;e=d>>>5&8;d=d>>>e;f=d>>>2&4;d=d>>>f;c=d>>>1&2;d=d>>>c;a=d>>>1&1;a=(e|i|f|c|a)+(d>>>a)|0;d=a<<1;c=644+(d<<2)|0;d=644+(d+2<<2)|0;f=k[d>>2]|0;i=f+8|0;e=k[i>>2]|0;do if((c|0)!=(e|0)){if(e>>>0<(k[155]|0)>>>0)Na();b=e+12|0;if((k[b>>2]|0)==(f|0)){k[b>>2]=c;k[d>>2]=e;j=k[153]|0;break}else Na()}else{k[151]=h&~(1<>2]=o|3;h=f+o|0;k[f+(o|4)>>2]=g|1;k[f+M>>2]=g;if(j){e=k[156]|0;c=j>>>3;b=c<<1;d=644+(b<<2)|0;a=k[151]|0;c=1<>2]|0;if(b>>>0<(k[155]|0)>>>0)Na();else{l=a;m=b}}else{k[151]=a|c;l=644+(b+2<<2)|0;m=d}k[l>>2]=e;k[m+12>>2]=e;k[e+8>>2]=m;k[e+12>>2]=d}k[153]=g;k[156]=h;M=i;return M|0}a=k[152]|0;if(a){c=(a&0-a)+-1|0;L=c>>>12&16;c=c>>>L;K=c>>>5&8;c=c>>>K;M=c>>>2&4;c=c>>>M;a=c>>>1&2;c=c>>>a;d=c>>>1&1;d=k[908+((K|L|M|a|d)+(c>>>d)<<2)>>2]|0;c=(k[d+4>>2]&-8)-o|0;a=d;while(1){b=k[a+16>>2]|0;if(!b){b=k[a+20>>2]|0;if(!b){i=c;break}}a=(k[b+4>>2]&-8)-o|0;M=a>>>0>>0;c=M?a:c;a=b;d=M?b:d}f=k[155]|0;if(d>>>0>>0)Na();h=d+o|0;if(d>>>0>=h>>>0)Na();g=k[d+24>>2]|0;c=k[d+12>>2]|0;do if((c|0)==(d|0)){a=d+20|0;b=k[a>>2]|0;if(!b){a=d+16|0;b=k[a>>2]|0;if(!b){n=0;break}}while(1){c=b+20|0;e=k[c>>2]|0;if(e){b=e;a=c;continue}c=b+16|0;e=k[c>>2]|0;if(!e)break;else{b=e;a=c}}if(a>>>0>>0)Na();else{k[a>>2]=0;n=b;break}}else{e=k[d+8>>2]|0;if(e>>>0>>0)Na();b=e+12|0;if((k[b>>2]|0)!=(d|0))Na();a=c+8|0;if((k[a>>2]|0)==(d|0)){k[b>>2]=c;k[a>>2]=e;n=c;break}else Na()}while(0);do if(g){b=k[d+28>>2]|0;a=908+(b<<2)|0;if((d|0)==(k[a>>2]|0)){k[a>>2]=n;if(!n){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(d|0))k[b>>2]=n;else k[g+20>>2]=n;if(!n)break}a=k[155]|0;if(n>>>0>>0)Na();k[n+24>>2]=g;b=k[d+16>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[n+16>>2]=b;k[b+24>>2]=n;break}while(0);b=k[d+20>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[n+20>>2]=b;k[b+24>>2]=n;break}}while(0);if(i>>>0<16){M=i+o|0;k[d+4>>2]=M|3;M=d+(M+4)|0;k[M>>2]=k[M>>2]|1}else{k[d+4>>2]=o|3;k[d+(o|4)>>2]=i|1;k[d+(i+o)>>2]=i;b=k[153]|0;if(b){f=k[156]|0;c=b>>>3;b=c<<1;e=644+(b<<2)|0;a=k[151]|0;c=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{p=b;q=a}}else{k[151]=a|c;p=644+(b+2<<2)|0;q=e}k[p>>2]=f;k[q+12>>2]=f;k[f+8>>2]=q;k[f+12>>2]=e}k[153]=i;k[156]=h}M=d+8|0;return M|0}else q=o}else q=o}else if(a>>>0<=4294967231){a=a+11|0;m=a&-8;l=k[152]|0;if(l){c=0-m|0;a=a>>>8;if(a)if(m>>>0>16777215)j=31;else{q=(a+1048320|0)>>>16&8;v=a<>>16&4;v=v<>>16&2;j=14-(p|q|j)+(v<>>15)|0;j=m>>>(j+7|0)&1|j<<1}else j=0;a=k[908+(j<<2)>>2]|0;a:do if(!a){e=0;a=0;v=86}else{g=c;e=0;h=m<<((j|0)==31?0:25-(j>>>1)|0);i=a;a=0;while(1){f=k[i+4>>2]&-8;c=f-m|0;if(c>>>0>>0)if((f|0)==(m|0)){f=i;a=i;v=90;break a}else a=i;else c=g;v=k[i+20>>2]|0;i=k[i+16+(h>>>31<<2)>>2]|0;e=(v|0)==0|(v|0)==(i|0)?e:v;if(!i){v=86;break}else{g=c;h=h<<1}}}while(0);if((v|0)==86){if((e|0)==0&(a|0)==0){a=2<>>12&16;a=a>>>n;l=a>>>5&8;a=a>>>l;p=a>>>2&4;a=a>>>p;q=a>>>1&2;a=a>>>q;e=a>>>1&1;e=k[908+((l|n|p|q|e)+(a>>>e)<<2)>>2]|0;a=0}if(!e){h=c;i=a}else{f=e;v=90}}if((v|0)==90)while(1){v=0;q=(k[f+4>>2]&-8)-m|0;e=q>>>0>>0;c=e?q:c;a=e?f:a;e=k[f+16>>2]|0;if(e){f=e;v=90;continue}f=k[f+20>>2]|0;if(!f){h=c;i=a;break}else v=90}if((i|0)!=0?h>>>0<((k[153]|0)-m|0)>>>0:0){e=k[155]|0;if(i>>>0>>0)Na();g=i+m|0;if(i>>>0>=g>>>0)Na();f=k[i+24>>2]|0;c=k[i+12>>2]|0;do if((c|0)==(i|0)){a=i+20|0;b=k[a>>2]|0;if(!b){a=i+16|0;b=k[a>>2]|0;if(!b){o=0;break}}while(1){c=b+20|0;d=k[c>>2]|0;if(d){b=d;a=c;continue}c=b+16|0;d=k[c>>2]|0;if(!d)break;else{b=d;a=c}}if(a>>>0>>0)Na();else{k[a>>2]=0;o=b;break}}else{d=k[i+8>>2]|0;if(d>>>0>>0)Na();b=d+12|0;if((k[b>>2]|0)!=(i|0))Na();a=c+8|0;if((k[a>>2]|0)==(i|0)){k[b>>2]=c;k[a>>2]=d;o=c;break}else Na()}while(0);do if(f){b=k[i+28>>2]|0;a=908+(b<<2)|0;if((i|0)==(k[a>>2]|0)){k[a>>2]=o;if(!o){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=f+16|0;if((k[b>>2]|0)==(i|0))k[b>>2]=o;else k[f+20>>2]=o;if(!o)break}a=k[155]|0;if(o>>>0>>0)Na();k[o+24>>2]=f;b=k[i+16>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[o+16>>2]=b;k[b+24>>2]=o;break}while(0);b=k[i+20>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[o+20>>2]=b;k[b+24>>2]=o;break}}while(0);b:do if(h>>>0>=16){k[i+4>>2]=m|3;k[i+(m|4)>>2]=h|1;k[i+(h+m)>>2]=h;b=h>>>3;if(h>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{s=b;t=a}}else{k[151]=c|b;s=644+(a+2<<2)|0;t=d}k[s>>2]=g;k[t+12>>2]=g;k[i+(m+8)>>2]=t;k[i+(m+12)>>2]=d;break}b=h>>>8;if(b)if(h>>>0>16777215)d=31;else{L=(b+1048320|0)>>>16&8;M=b<>>16&4;M=M<>>16&2;d=14-(K|L|d)+(M<>>15)|0;d=h>>>(d+7|0)&1|d<<1}else d=0;b=908+(d<<2)|0;k[i+(m+28)>>2]=d;k[i+(m+20)>>2]=0;k[i+(m+16)>>2]=0;a=k[152]|0;c=1<>2]=g;k[i+(m+24)>>2]=b;k[i+(m+12)>>2]=g;k[i+(m+8)>>2]=g;break}b=k[b>>2]|0;c:do if((k[b+4>>2]&-8|0)!=(h|0)){d=h<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(h|0)){y=c;break c}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=g;k[i+(m+24)>>2]=b;k[i+(m+12)>>2]=g;k[i+(m+8)>>2]=g;break b}}else y=b;while(0);b=y+8|0;a=k[b>>2]|0;M=k[155]|0;if(a>>>0>=M>>>0&y>>>0>=M>>>0){k[a+12>>2]=g;k[b>>2]=g;k[i+(m+8)>>2]=a;k[i+(m+12)>>2]=y;k[i+(m+24)>>2]=0;break}else Na()}else{M=h+m|0;k[i+4>>2]=M|3;M=i+(M+4)|0;k[M>>2]=k[M>>2]|1}while(0);M=i+8|0;return M|0}else q=m}else q=m}else q=-1;while(0);c=k[153]|0;if(c>>>0>=q>>>0){b=c-q|0;a=k[156]|0;if(b>>>0>15){k[156]=a+q;k[153]=b;k[a+(q+4)>>2]=b|1;k[a+c>>2]=b;k[a+4>>2]=q|3}else{k[153]=0;k[156]=0;k[a+4>>2]=c|3;M=a+(c+4)|0;k[M>>2]=k[M>>2]|1}M=a+8|0;return M|0}a=k[154]|0;if(a>>>0>q>>>0){L=a-q|0;k[154]=L;M=k[157]|0;k[157]=M+q;k[M+(q+4)>>2]=L|1;k[M+4>>2]=q|3;M=M+8|0;return M|0}do if(!(k[269]|0)){a=Ea(30)|0;if(!(a+-1&a)){k[271]=a;k[270]=a;k[272]=-1;k[273]=-1;k[274]=0;k[262]=0;y=(Pa(0)|0)&-16^1431655768;k[269]=y;break}else Na()}while(0);i=q+48|0;h=k[271]|0;j=q+47|0;g=h+j|0;h=0-h|0;l=g&h;if(l>>>0<=q>>>0){M=0;return M|0}a=k[261]|0;if((a|0)!=0?(t=k[259]|0,y=t+l|0,y>>>0<=t>>>0|y>>>0>a>>>0):0){M=0;return M|0}d:do if(!(k[262]&4)){a=k[157]|0;e:do if(a){e=1052;while(1){c=k[e>>2]|0;if(c>>>0<=a>>>0?(r=e+4|0,(c+(k[r>>2]|0)|0)>>>0>a>>>0):0){f=e;a=r;break}e=k[e+8>>2]|0;if(!e){v=174;break e}}c=g-(k[154]|0)&h;if(c>>>0<2147483647){e=Ba(c|0)|0;y=(e|0)==((k[f>>2]|0)+(k[a>>2]|0)|0);a=y?c:0;if(y){if((e|0)!=(-1|0)){w=e;p=a;v=194;break d}}else v=184}else a=0}else v=174;while(0);do if((v|0)==174){f=Ba(0)|0;if((f|0)!=(-1|0)){a=f;c=k[270]|0;e=c+-1|0;if(!(e&a))c=l;else c=l-a+(e+a&0-c)|0;a=k[259]|0;e=a+c|0;if(c>>>0>q>>>0&c>>>0<2147483647){y=k[261]|0;if((y|0)!=0?e>>>0<=a>>>0|e>>>0>y>>>0:0){a=0;break}e=Ba(c|0)|0;y=(e|0)==(f|0);a=y?c:0;if(y){w=f;p=a;v=194;break d}else v=184}else a=0}else a=0}while(0);f:do if((v|0)==184){f=0-c|0;do if(i>>>0>c>>>0&(c>>>0<2147483647&(e|0)!=(-1|0))?(u=k[271]|0,u=j-c+u&0-u,u>>>0<2147483647):0)if((Ba(u|0)|0)==(-1|0)){Ba(f|0)|0;break f}else{c=u+c|0;break}while(0);if((e|0)!=(-1|0)){w=e;p=c;v=194;break d}}while(0);k[262]=k[262]|4;v=191}else{a=0;v=191}while(0);if((((v|0)==191?l>>>0<2147483647:0)?(w=Ba(l|0)|0,x=Ba(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(z=x-w|0,A=z>>>0>(q+40|0)>>>0,A):0){p=A?z:a;v=194}if((v|0)==194){a=(k[259]|0)+p|0;k[259]=a;if(a>>>0>(k[260]|0)>>>0)k[260]=a;g=k[157]|0;g:do if(g){f=1052;do{a=k[f>>2]|0;c=f+4|0;e=k[c>>2]|0;if((w|0)==(a+e|0)){B=a;C=c;D=e;E=f;v=204;break}f=k[f+8>>2]|0}while((f|0)!=0);if(((v|0)==204?(k[E+12>>2]&8|0)==0:0)?g>>>0>>0&g>>>0>=B>>>0:0){k[C>>2]=D+p;M=(k[154]|0)+p|0;L=g+8|0;L=(L&7|0)==0?0:0-L&7;K=M-L|0;k[157]=g+L;k[154]=K;k[g+(L+4)>>2]=K|1;k[g+(M+4)>>2]=40;k[158]=k[273];break}a=k[155]|0;if(w>>>0>>0){k[155]=w;a=w}c=w+p|0;f=1052;while(1){if((k[f>>2]|0)==(c|0)){e=f;c=f;v=212;break}f=k[f+8>>2]|0;if(!f){c=1052;break}}if((v|0)==212)if(!(k[c+12>>2]&8)){k[e>>2]=w;n=c+4|0;k[n>>2]=(k[n>>2]|0)+p;n=w+8|0;n=(n&7|0)==0?0:0-n&7;j=w+(p+8)|0;j=(j&7|0)==0?0:0-j&7;b=w+(j+p)|0;m=n+q|0;o=w+m|0;l=b-(w+n)-q|0;k[w+(n+4)>>2]=q|3;h:do if((b|0)!=(g|0)){if((b|0)==(k[156]|0)){M=(k[153]|0)+l|0;k[153]=M;k[156]=o;k[w+(m+4)>>2]=M|1;k[w+(M+m)>>2]=M;break}h=p+4|0;c=k[w+(h+j)>>2]|0;if((c&3|0)==1){i=c&-8;f=c>>>3;i:do if(c>>>0>=256){g=k[w+((j|24)+p)>>2]|0;d=k[w+(p+12+j)>>2]|0;do if((d|0)==(b|0)){e=j|16;d=w+(h+e)|0;c=k[d>>2]|0;if(!c){d=w+(e+p)|0;c=k[d>>2]|0;if(!c){J=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;J=c;break}}else{e=k[w+((j|8)+p)>>2]|0;if(e>>>0>>0)Na();a=e+12|0;if((k[a>>2]|0)!=(b|0))Na();c=d+8|0;if((k[c>>2]|0)==(b|0)){k[a>>2]=d;k[c>>2]=e;J=d;break}else Na()}while(0);if(!g)break;a=k[w+(p+28+j)>>2]|0;c=908+(a<<2)|0;do if((b|0)!=(k[c>>2]|0)){if(g>>>0<(k[155]|0)>>>0)Na();a=g+16|0;if((k[a>>2]|0)==(b|0))k[a>>2]=J;else k[g+20>>2]=J;if(!J)break i}else{k[c>>2]=J;if(J)break;k[152]=k[152]&~(1<>>0>>0)Na();k[J+24>>2]=g;b=j|16;a=k[w+(b+p)>>2]|0;do if(a)if(a>>>0>>0)Na();else{k[J+16>>2]=a;k[a+24>>2]=J;break}while(0);b=k[w+(h+b)>>2]|0;if(!b)break;if(b>>>0<(k[155]|0)>>>0)Na();else{k[J+20>>2]=b;k[b+24>>2]=J;break}}else{d=k[w+((j|8)+p)>>2]|0;e=k[w+(p+12+j)>>2]|0;c=644+(f<<1<<2)|0;do if((d|0)!=(c|0)){if(d>>>0>>0)Na();if((k[d+12>>2]|0)==(b|0))break;Na()}while(0);if((e|0)==(d|0)){k[151]=k[151]&~(1<>>0>>0)Na();a=e+8|0;if((k[a>>2]|0)==(b|0)){F=a;break}Na()}while(0);k[d+12>>2]=e;k[F>>2]=d}while(0);b=w+((i|j)+p)|0;e=i+l|0}else e=l;b=b+4|0;k[b>>2]=k[b>>2]&-2;k[w+(m+4)>>2]=e|1;k[w+(e+m)>>2]=e;b=e>>>3;if(e>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0>=(k[155]|0)>>>0){K=b;L=a;break}Na()}while(0);k[K>>2]=o;k[L+12>>2]=o;k[w+(m+8)>>2]=L;k[w+(m+12)>>2]=d;break}b=e>>>8;do if(!b)d=0;else{if(e>>>0>16777215){d=31;break}K=(b+1048320|0)>>>16&8;L=b<>>16&4;L=L<>>16&2;d=14-(J|K|d)+(L<>>15)|0;d=e>>>(d+7|0)&1|d<<1}while(0);b=908+(d<<2)|0;k[w+(m+28)>>2]=d;k[w+(m+20)>>2]=0;k[w+(m+16)>>2]=0;a=k[152]|0;c=1<>2]=o;k[w+(m+24)>>2]=b;k[w+(m+12)>>2]=o;k[w+(m+8)>>2]=o;break}b=k[b>>2]|0;j:do if((k[b+4>>2]&-8|0)!=(e|0)){d=e<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(e|0)){M=c;break j}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=o;k[w+(m+24)>>2]=b;k[w+(m+12)>>2]=o;k[w+(m+8)>>2]=o;break h}}else M=b;while(0);b=M+8|0;a=k[b>>2]|0;L=k[155]|0;if(a>>>0>=L>>>0&M>>>0>=L>>>0){k[a+12>>2]=o;k[b>>2]=o;k[w+(m+8)>>2]=a;k[w+(m+12)>>2]=M;k[w+(m+24)>>2]=0;break}else Na()}else{M=(k[154]|0)+l|0;k[154]=M;k[157]=o;k[w+(m+4)>>2]=M|1}while(0);M=w+(n|8)|0;return M|0}else c=1052;while(1){a=k[c>>2]|0;if(a>>>0<=g>>>0?(b=k[c+4>>2]|0,d=a+b|0,d>>>0>g>>>0):0)break;c=k[c+8>>2]|0}e=a+(b+-39)|0;a=a+(b+-47+((e&7|0)==0?0:0-e&7))|0;e=g+16|0;a=a>>>0>>0?g:a;b=a+8|0;c=w+8|0;c=(c&7|0)==0?0:0-c&7;M=p+-40-c|0;k[157]=w+c;k[154]=M;k[w+(c+4)>>2]=M|1;k[w+(p+-36)>>2]=40;k[158]=k[273];c=a+4|0;k[c>>2]=27;k[b>>2]=k[263];k[b+4>>2]=k[264];k[b+8>>2]=k[265];k[b+12>>2]=k[266];k[263]=w;k[264]=p;k[266]=0;k[265]=b;b=a+28|0;k[b>>2]=7;if((a+32|0)>>>0>>0)do{M=b;b=b+4|0;k[b>>2]=7}while((M+8|0)>>>0>>0);if((a|0)!=(g|0)){f=a-g|0;k[c>>2]=k[c>>2]&-2;k[g+4>>2]=f|1;k[a>>2]=f;b=f>>>3;if(f>>>0<256){a=b<<1;d=644+(a<<2)|0;c=k[151]|0;b=1<>2]|0;if(a>>>0<(k[155]|0)>>>0)Na();else{G=b;H=a}}else{k[151]=c|b;G=644+(a+2<<2)|0;H=d}k[G>>2]=g;k[H+12>>2]=g;k[g+8>>2]=H;k[g+12>>2]=d;break}b=f>>>8;if(b)if(f>>>0>16777215)d=31;else{L=(b+1048320|0)>>>16&8;M=b<>>16&4;M=M<>>16&2;d=14-(K|L|d)+(M<>>15)|0;d=f>>>(d+7|0)&1|d<<1}else d=0;c=908+(d<<2)|0;k[g+28>>2]=d;k[g+20>>2]=0;k[e>>2]=0;b=k[152]|0;a=1<>2]=g;k[g+24>>2]=c;k[g+12>>2]=g;k[g+8>>2]=g;break}b=k[c>>2]|0;k:do if((k[b+4>>2]&-8|0)!=(f|0)){d=f<<((d|0)==31?0:25-(d>>>1)|0);while(1){a=b+16+(d>>>31<<2)|0;c=k[a>>2]|0;if(!c)break;if((k[c+4>>2]&-8|0)==(f|0)){I=c;break k}else{d=d<<1;b=c}}if(a>>>0<(k[155]|0)>>>0)Na();else{k[a>>2]=g;k[g+24>>2]=b;k[g+12>>2]=g;k[g+8>>2]=g;break g}}else I=b;while(0);b=I+8|0;a=k[b>>2]|0;M=k[155]|0;if(a>>>0>=M>>>0&I>>>0>=M>>>0){k[a+12>>2]=g;k[b>>2]=g;k[g+8>>2]=a;k[g+12>>2]=I;k[g+24>>2]=0;break}else Na()}}else{M=k[155]|0;if((M|0)==0|w>>>0>>0)k[155]=w;k[263]=w;k[264]=p;k[266]=0;k[160]=k[269];k[159]=-1;b=0;do{M=b<<1;L=644+(M<<2)|0;k[644+(M+3<<2)>>2]=L;k[644+(M+2<<2)>>2]=L;b=b+1|0}while((b|0)!=32);M=w+8|0;M=(M&7|0)==0?0:0-M&7;L=p+-40-M|0;k[157]=w+M;k[154]=L;k[w+(M+4)>>2]=L|1;k[w+(p+-36)>>2]=40;k[158]=k[273]}while(0);b=k[154]|0;if(b>>>0>q>>>0){L=b-q|0;k[154]=L;M=k[157]|0;k[157]=M+q;k[M+(q+4)>>2]=L|1;k[M+4>>2]=q|3;M=M+8|0;return M|0}}M=qc()|0;k[M>>2]=12;M=0;return M|0}function Vc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;if(!a)return;b=a+-8|0;h=k[155]|0;if(b>>>0>>0)Na();c=k[a+-4>>2]|0;d=c&3;if((d|0)==1)Na();o=c&-8;q=a+(o+-8)|0;do if(!(c&1)){b=k[b>>2]|0;if(!d)return;i=-8-b|0;l=a+i|0;m=b+o|0;if(l>>>0>>0)Na();if((l|0)==(k[156]|0)){b=a+(o+-4)|0;c=k[b>>2]|0;if((c&3|0)!=3){u=l;f=m;break}k[153]=m;k[b>>2]=c&-2;k[a+(i+4)>>2]=m|1;k[q>>2]=m;return}e=b>>>3;if(b>>>0<256){d=k[a+(i+8)>>2]|0;c=k[a+(i+12)>>2]|0;b=644+(e<<1<<2)|0;if((d|0)!=(b|0)){if(d>>>0>>0)Na();if((k[d+12>>2]|0)!=(l|0))Na()}if((c|0)==(d|0)){k[151]=k[151]&~(1<>>0>>0)Na();b=c+8|0;if((k[b>>2]|0)==(l|0))g=b;else Na()}else g=c+8|0;k[d+12>>2]=c;k[g>>2]=d;u=l;f=m;break}g=k[a+(i+24)>>2]|0;d=k[a+(i+12)>>2]|0;do if((d|0)==(l|0)){c=a+(i+20)|0;b=k[c>>2]|0;if(!b){c=a+(i+16)|0;b=k[c>>2]|0;if(!b){j=0;break}}while(1){d=b+20|0;e=k[d>>2]|0;if(e){b=e;c=d;continue}d=b+16|0;e=k[d>>2]|0;if(!e)break;else{b=e;c=d}}if(c>>>0>>0)Na();else{k[c>>2]=0;j=b;break}}else{e=k[a+(i+8)>>2]|0;if(e>>>0>>0)Na();b=e+12|0;if((k[b>>2]|0)!=(l|0))Na();c=d+8|0;if((k[c>>2]|0)==(l|0)){k[b>>2]=d;k[c>>2]=e;j=d;break}else Na()}while(0);if(g){b=k[a+(i+28)>>2]|0;c=908+(b<<2)|0;if((l|0)==(k[c>>2]|0)){k[c>>2]=j;if(!j){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(l|0))k[b>>2]=j;else k[g+20>>2]=j;if(!j){u=l;f=m;break}}c=k[155]|0;if(j>>>0>>0)Na();k[j+24>>2]=g;b=k[a+(i+16)>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[j+16>>2]=b;k[b+24>>2]=j;break}while(0);b=k[a+(i+20)>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[j+20>>2]=b;k[b+24>>2]=j;u=l;f=m;break}else{u=l;f=m}}else{u=l;f=m}}else{u=b;f=o}while(0);if(u>>>0>=q>>>0)Na();b=a+(o+-4)|0;c=k[b>>2]|0;if(!(c&1))Na();if(!(c&2)){if((q|0)==(k[157]|0)){t=(k[154]|0)+f|0;k[154]=t;k[157]=u;k[u+4>>2]=t|1;if((u|0)!=(k[156]|0))return;k[156]=0;k[153]=0;return}if((q|0)==(k[156]|0)){t=(k[153]|0)+f|0;k[153]=t;k[156]=u;k[u+4>>2]=t|1;k[u+t>>2]=t;return}f=(c&-8)+f|0;e=c>>>3;do if(c>>>0>=256){g=k[a+(o+16)>>2]|0;b=k[a+(o|4)>>2]|0;do if((b|0)==(q|0)){c=a+(o+12)|0;b=k[c>>2]|0;if(!b){c=a+(o+8)|0;b=k[c>>2]|0;if(!b){p=0;break}}while(1){d=b+20|0;e=k[d>>2]|0;if(e){b=e;c=d;continue}d=b+16|0;e=k[d>>2]|0;if(!e)break;else{b=e;c=d}}if(c>>>0<(k[155]|0)>>>0)Na();else{k[c>>2]=0;p=b;break}}else{c=k[a+o>>2]|0;if(c>>>0<(k[155]|0)>>>0)Na();d=c+12|0;if((k[d>>2]|0)!=(q|0))Na();e=b+8|0;if((k[e>>2]|0)==(q|0)){k[d>>2]=b;k[e>>2]=c;p=b;break}else Na()}while(0);if(g){b=k[a+(o+20)>>2]|0;c=908+(b<<2)|0;if((q|0)==(k[c>>2]|0)){k[c>>2]=p;if(!p){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();b=g+16|0;if((k[b>>2]|0)==(q|0))k[b>>2]=p;else k[g+20>>2]=p;if(!p)break}c=k[155]|0;if(p>>>0>>0)Na();k[p+24>>2]=g;b=k[a+(o+8)>>2]|0;do if(b)if(b>>>0>>0)Na();else{k[p+16>>2]=b;k[b+24>>2]=p;break}while(0);b=k[a+(o+12)>>2]|0;if(b)if(b>>>0<(k[155]|0)>>>0)Na();else{k[p+20>>2]=b;k[b+24>>2]=p;break}}}else{d=k[a+o>>2]|0;c=k[a+(o|4)>>2]|0;b=644+(e<<1<<2)|0;if((d|0)!=(b|0)){if(d>>>0<(k[155]|0)>>>0)Na();if((k[d+12>>2]|0)!=(q|0))Na()}if((c|0)==(d|0)){k[151]=k[151]&~(1<>>0<(k[155]|0)>>>0)Na();b=c+8|0;if((k[b>>2]|0)==(q|0))n=b;else Na()}else n=c+8|0;k[d+12>>2]=c;k[n>>2]=d}while(0);k[u+4>>2]=f|1;k[u+f>>2]=f;if((u|0)==(k[156]|0)){k[153]=f;return}}else{k[b>>2]=c&-2;k[u+4>>2]=f|1;k[u+f>>2]=f}b=f>>>3;if(f>>>0<256){c=b<<1;e=644+(c<<2)|0;d=k[151]|0;b=1<>2]|0;if(c>>>0<(k[155]|0)>>>0)Na();else{r=b;s=c}}else{k[151]=d|b;r=644+(c+2<<2)|0;s=e}k[r>>2]=u;k[s+12>>2]=u;k[u+8>>2]=s;k[u+12>>2]=e;return}b=f>>>8;if(b)if(f>>>0>16777215)e=31;else{r=(b+1048320|0)>>>16&8;s=b<>>16&4;s=s<>>16&2;e=14-(q|r|e)+(s<>>15)|0;e=f>>>(e+7|0)&1|e<<1}else e=0;b=908+(e<<2)|0;k[u+28>>2]=e;k[u+20>>2]=0;k[u+16>>2]=0;c=k[152]|0;d=1<>2]|0;b:do if((k[b+4>>2]&-8|0)!=(f|0)){e=f<<((e|0)==31?0:25-(e>>>1)|0);while(1){c=b+16+(e>>>31<<2)|0;d=k[c>>2]|0;if(!d)break;if((k[d+4>>2]&-8|0)==(f|0)){t=d;break b}else{e=e<<1;b=d}}if(c>>>0<(k[155]|0)>>>0)Na();else{k[c>>2]=u;k[u+24>>2]=b;k[u+12>>2]=u;k[u+8>>2]=u;break a}}else t=b;while(0);b=t+8|0;c=k[b>>2]|0;s=k[155]|0;if(c>>>0>=s>>>0&t>>>0>=s>>>0){k[c+12>>2]=u;k[b>>2]=u;k[u+8>>2]=c;k[u+12>>2]=t;k[u+24>>2]=0;break}else Na()}else{k[152]=c|d;k[b>>2]=u;k[u+24>>2]=b;k[u+12>>2]=u;k[u+8>>2]=u}while(0);u=(k[159]|0)+-1|0;k[159]=u;if(!u)b=1060;else return;while(1){b=k[b>>2]|0;if(!b)break;else b=b+8|0}k[159]=-1;return}function Wc(a,b){a=a|0;b=b|0;var c=0,d=0;if(!a){a=Uc(b)|0;return a|0}if(b>>>0>4294967231){a=qc()|0;k[a>>2]=12;a=0;return a|0}c=Yc(a+-8|0,b>>>0<11?16:b+11&-8)|0;if(c){a=c+8|0;return a|0}c=Uc(b)|0;if(!c){a=0;return a|0}d=k[a+-4>>2]|0;d=(d&-8)-((d&3|0)==0?8:4)|0;ed(c|0,a|0,(d>>>0>>0?d:b)|0)|0;Vc(a);a=c;return a|0}function Xc(a){a=a|0;var b=0;if(!a){b=0;return b|0}a=k[a+-4>>2]|0;b=a&3;if((b|0)==1){b=0;return b|0}b=(a&-8)-((b|0)==0?8:4)|0;return b|0}function Yc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;o=a+4|0;p=k[o>>2]|0;i=p&-8;l=a+i|0;h=k[155]|0;c=p&3;if(!((c|0)!=1&a>>>0>=h>>>0&a>>>0>>0))Na();d=a+(i|4)|0;e=k[d>>2]|0;if(!(e&1))Na();if(!c){if(b>>>0<256){a=0;return a|0}if(i>>>0>=(b+4|0)>>>0?(i-b|0)>>>0<=k[271]<<1>>>0:0)return a|0;a=0;return a|0}if(i>>>0>=b>>>0){c=i-b|0;if(c>>>0<=15)return a|0;k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=c|3;k[d>>2]=k[d>>2]|1;Zc(a+b|0,c);return a|0}if((l|0)==(k[157]|0)){c=(k[154]|0)+i|0;if(c>>>0<=b>>>0){a=0;return a|0}n=c-b|0;k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=n|1;k[157]=a+b;k[154]=n;return a|0}if((l|0)==(k[156]|0)){d=(k[153]|0)+i|0;if(d>>>0>>0){a=0;return a|0}c=d-b|0;if(c>>>0>15){k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=c|1;k[a+d>>2]=c;d=a+(d+4)|0;k[d>>2]=k[d>>2]&-2;d=a+b|0}else{k[o>>2]=p&1|d|2;d=a+(d+4)|0;k[d>>2]=k[d>>2]|1;d=0;c=0}k[153]=c;k[156]=d;return a|0}if(e&2){a=0;return a|0}m=(e&-8)+i|0;if(m>>>0>>0){a=0;return a|0}n=m-b|0;f=e>>>3;do if(e>>>0>=256){g=k[a+(i+24)>>2]|0;f=k[a+(i+12)>>2]|0;do if((f|0)==(l|0)){d=a+(i+20)|0;c=k[d>>2]|0;if(!c){d=a+(i+16)|0;c=k[d>>2]|0;if(!c){j=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;j=c;break}}else{e=k[a+(i+8)>>2]|0;if(e>>>0>>0)Na();c=e+12|0;if((k[c>>2]|0)!=(l|0))Na();d=f+8|0;if((k[d>>2]|0)==(l|0)){k[c>>2]=f;k[d>>2]=e;j=f;break}else Na()}while(0);if(g){c=k[a+(i+28)>>2]|0;d=908+(c<<2)|0;if((l|0)==(k[d>>2]|0)){k[d>>2]=j;if(!j){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=g+16|0;if((k[c>>2]|0)==(l|0))k[c>>2]=j;else k[g+20>>2]=j;if(!j)break}d=k[155]|0;if(j>>>0>>0)Na();k[j+24>>2]=g;c=k[a+(i+16)>>2]|0;do if(c)if(c>>>0>>0)Na();else{k[j+16>>2]=c;k[c+24>>2]=j;break}while(0);c=k[a+(i+20)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[j+20>>2]=c;k[c+24>>2]=j;break}}}else{e=k[a+(i+8)>>2]|0;d=k[a+(i+12)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(l|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(l|0))g=c;else Na()}else g=d+8|0;k[e+12>>2]=d;k[g>>2]=e}while(0);if(n>>>0<16){k[o>>2]=m|p&1|2;b=a+(m|4)|0;k[b>>2]=k[b>>2]|1;return a|0}else{k[o>>2]=p&1|b|2;k[a+(b+4)>>2]=n|3;p=a+(m|4)|0;k[p>>2]=k[p>>2]|1;Zc(a+b|0,n);return a|0}return 0}function Zc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;q=a+b|0;c=k[a+4>>2]|0;do if(!(c&1)){j=k[a>>2]|0;if(!(c&3))return;n=a+(0-j)|0;m=j+b|0;i=k[155]|0;if(n>>>0>>0)Na();if((n|0)==(k[156]|0)){d=a+(b+4)|0;c=k[d>>2]|0;if((c&3|0)!=3){t=n;g=m;break}k[153]=m;k[d>>2]=c&-2;k[a+(4-j)>>2]=m|1;k[q>>2]=m;return}f=j>>>3;if(j>>>0<256){e=k[a+(8-j)>>2]|0;d=k[a+(12-j)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(n|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(n|0))h=c;else Na()}else h=d+8|0;k[e+12>>2]=d;k[h>>2]=e;t=n;g=m;break}h=k[a+(24-j)>>2]|0;e=k[a+(12-j)>>2]|0;do if((e|0)==(n|0)){e=16-j|0;d=a+(e+4)|0;c=k[d>>2]|0;if(!c){d=a+e|0;c=k[d>>2]|0;if(!c){l=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;l=c;break}}else{f=k[a+(8-j)>>2]|0;if(f>>>0>>0)Na();c=f+12|0;if((k[c>>2]|0)!=(n|0))Na();d=e+8|0;if((k[d>>2]|0)==(n|0)){k[c>>2]=e;k[d>>2]=f;l=e;break}else Na()}while(0);if(h){c=k[a+(28-j)>>2]|0;d=908+(c<<2)|0;if((n|0)==(k[d>>2]|0)){k[d>>2]=l;if(!l){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=h+16|0;if((k[c>>2]|0)==(n|0))k[c>>2]=l;else k[h+20>>2]=l;if(!l){t=n;g=m;break}}e=k[155]|0;if(l>>>0>>0)Na();k[l+24>>2]=h;c=16-j|0;d=k[a+c>>2]|0;do if(d)if(d>>>0>>0)Na();else{k[l+16>>2]=d;k[d+24>>2]=l;break}while(0);c=k[a+(c+4)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[l+20>>2]=c;k[c+24>>2]=l;t=n;g=m;break}else{t=n;g=m}}else{t=n;g=m}}else{t=a;g=b}while(0);i=k[155]|0;if(q>>>0>>0)Na();c=a+(b+4)|0;d=k[c>>2]|0;if(!(d&2)){if((q|0)==(k[157]|0)){s=(k[154]|0)+g|0;k[154]=s;k[157]=t;k[t+4>>2]=s|1;if((t|0)!=(k[156]|0))return;k[156]=0;k[153]=0;return}if((q|0)==(k[156]|0)){s=(k[153]|0)+g|0;k[153]=s;k[156]=t;k[t+4>>2]=s|1;k[t+s>>2]=s;return}g=(d&-8)+g|0;f=d>>>3;do if(d>>>0>=256){h=k[a+(b+24)>>2]|0;e=k[a+(b+12)>>2]|0;do if((e|0)==(q|0)){d=a+(b+20)|0;c=k[d>>2]|0;if(!c){d=a+(b+16)|0;c=k[d>>2]|0;if(!c){p=0;break}}while(1){e=c+20|0;f=k[e>>2]|0;if(f){c=f;d=e;continue}e=c+16|0;f=k[e>>2]|0;if(!f)break;else{c=f;d=e}}if(d>>>0>>0)Na();else{k[d>>2]=0;p=c;break}}else{f=k[a+(b+8)>>2]|0;if(f>>>0>>0)Na();c=f+12|0;if((k[c>>2]|0)!=(q|0))Na();d=e+8|0;if((k[d>>2]|0)==(q|0)){k[c>>2]=e;k[d>>2]=f;p=e;break}else Na()}while(0);if(h){c=k[a+(b+28)>>2]|0;d=908+(c<<2)|0;if((q|0)==(k[d>>2]|0)){k[d>>2]=p;if(!p){k[152]=k[152]&~(1<>>0<(k[155]|0)>>>0)Na();c=h+16|0;if((k[c>>2]|0)==(q|0))k[c>>2]=p;else k[h+20>>2]=p;if(!p)break}d=k[155]|0;if(p>>>0>>0)Na();k[p+24>>2]=h;c=k[a+(b+16)>>2]|0;do if(c)if(c>>>0>>0)Na();else{k[p+16>>2]=c;k[c+24>>2]=p;break}while(0);c=k[a+(b+20)>>2]|0;if(c)if(c>>>0<(k[155]|0)>>>0)Na();else{k[p+20>>2]=c;k[c+24>>2]=p;break}}}else{e=k[a+(b+8)>>2]|0;d=k[a+(b+12)>>2]|0;c=644+(f<<1<<2)|0;if((e|0)!=(c|0)){if(e>>>0>>0)Na();if((k[e+12>>2]|0)!=(q|0))Na()}if((d|0)==(e|0)){k[151]=k[151]&~(1<>>0>>0)Na();c=d+8|0;if((k[c>>2]|0)==(q|0))o=c;else Na()}else o=d+8|0;k[e+12>>2]=d;k[o>>2]=e}while(0);k[t+4>>2]=g|1;k[t+g>>2]=g;if((t|0)==(k[156]|0)){k[153]=g;return}}else{k[c>>2]=d&-2;k[t+4>>2]=g|1;k[t+g>>2]=g}c=g>>>3;if(g>>>0<256){d=c<<1;f=644+(d<<2)|0;e=k[151]|0;c=1<>2]|0;if(d>>>0<(k[155]|0)>>>0)Na();else{r=c;s=d}}else{k[151]=e|c;r=644+(d+2<<2)|0;s=f}k[r>>2]=t;k[s+12>>2]=t;k[t+8>>2]=s;k[t+12>>2]=f;return}c=g>>>8;if(c)if(g>>>0>16777215)f=31;else{r=(c+1048320|0)>>>16&8;s=c<>>16&4;s=s<>>16&2;f=14-(q|r|f)+(s<>>15)|0;f=g>>>(f+7|0)&1|f<<1}else f=0;c=908+(f<<2)|0;k[t+28>>2]=f;k[t+20>>2]=0;k[t+16>>2]=0;d=k[152]|0;e=1<>2]=t;k[t+24>>2]=c;k[t+12>>2]=t;k[t+8>>2]=t;return}c=k[c>>2]|0;a:do if((k[c+4>>2]&-8|0)!=(g|0)){f=g<<((f|0)==31?0:25-(f>>>1)|0);while(1){d=c+16+(f>>>31<<2)|0;e=k[d>>2]|0;if(!e)break;if((k[e+4>>2]&-8|0)==(g|0)){c=e;break a}else{f=f<<1;c=e}}if(d>>>0<(k[155]|0)>>>0)Na();k[d>>2]=t;k[t+24>>2]=c;k[t+12>>2]=t;k[t+8>>2]=t;return}while(0);d=c+8|0;e=k[d>>2]|0;s=k[155]|0;if(!(e>>>0>=s>>>0&c>>>0>=s>>>0))Na();k[e+12>>2]=t;k[d>>2]=t;k[t+8>>2]=e;k[t+12>>2]=c;k[t+24>>2]=0;return}function _c(){}function $c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (L=d,a-c>>>0|0)|0}function ad(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=a+c|0;if((c|0)>=20){b=b&255;f=a&3;g=b|b<<8|b<<16|b<<24;e=d&~3;if(f){f=a+4-f|0;while((a|0)<(f|0)){i[a>>0]=b;a=a+1|0}}while((a|0)<(e|0)){k[a>>2]=g;a=a+4|0}}while((a|0)<(d|0)){i[a>>0]=b;a=a+1|0}return a-c|0}function bd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b>>>c;return a>>>c|(b&(1<>>c-32|0}function cd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b<>>32-c;return a<>>0;return (L=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function ed(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((c|0)>=4096)return Da(a|0,b|0,c|0)|0;d=a|0;if((a&3)==(b&3)){while(a&3){if(!c)return d|0;i[a>>0]=i[b>>0]|0;a=a+1|0;b=b+1|0;c=c-1|0}while((c|0)>=4){k[a>>2]=k[b>>2];a=a+4|0;b=b+4|0;c=c-4|0}}while((c|0)>0){i[a>>0]=i[b>>0]|0;a=a+1|0;b=b+1|0;c=c-1|0}return d|0}function fd(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){L=b>>c;return a>>>c|(b&(1<>c-32|0}function gd(a){a=a|0;var b=0;b=i[v+(a&255)>>0]|0;if((b|0)<8)return b|0;b=i[v+(a>>8&255)>>0]|0;if((b|0)<8)return b+8|0;b=i[v+(a>>16&255)>>0]|0;if((b|0)<8)return b+16|0;return (i[v+(a>>>24)>>0]|0)+24|0}function hd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=ha(e,f)|0;d=a>>>16;a=(c>>>16)+(ha(e,d)|0)|0;e=b>>>16;b=ha(e,f)|0;return (L=(a>>>16)+(ha(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function id(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=$c(j^a,i^b,j,i)|0;g=L;a=f^j;b=e^i;return $c((nd(h,g,$c(f^c,e^d,f,e)|0,L,0)|0)^a,L^b,a,b)|0}function jd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=r;r=r+16|0;h=e|0;g=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;j=d>>31|((d|0)<0?-1:0)<<1;i=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;a=$c(g^a,f^b,g,f)|0;b=L;nd(a,b,$c(j^c,i^d,j,i)|0,L,h)|0;d=$c(k[h>>2]^g,k[h+4>>2]^f,g,f)|0;c=L;r=e;return (L=c,d)|0}function kd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=hd(e,f)|0;a=L;return (L=(ha(b,f)|0)+(ha(d,e)|0)+a|a&0,c|0|0)|0}function ld(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return nd(a,b,c,d,0)|0}function md(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=r;r=r+16|0;e=f|0;nd(a,b,c,d,e)|0;r=f;return (L=k[e+4>>2]|0,k[e>>2]|0)|0}function nd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;l=a;i=b;j=i;g=c;n=d;h=n;if(!j){f=(e|0)!=0;if(!h){if(f){k[e>>2]=(l>>>0)%(g>>>0);k[e+4>>2]=0}n=0;e=(l>>>0)/(g>>>0)>>>0;return (L=n,e)|0}else{if(!f){n=0;e=0;return (L=n,e)|0}k[e>>2]=a|0;k[e+4>>2]=b&0;n=0;e=0;return (L=n,e)|0}}f=(h|0)==0;do if(g){if(!f){f=(ja(h|0)|0)-(ja(j|0)|0)|0;if(f>>>0<=31){m=f+1|0;h=31-f|0;b=f-31>>31;g=m;a=l>>>(m>>>0)&b|j<>>(m>>>0)&b;f=0;h=l<>2]=a|0;k[e+4>>2]=i|b&0;n=0;e=0;return (L=n,e)|0}f=g-1|0;if(f&g){h=(ja(g|0)|0)+33-(ja(j|0)|0)|0;p=64-h|0;m=32-h|0;i=m>>31;o=h-32|0;b=o>>31;g=h;a=m-1>>31&j>>>(o>>>0)|(j<>>(h>>>0))&b;b=b&j>>>(h>>>0);f=l<>>(o>>>0))&i|l<>31;break}if(e){k[e>>2]=f&l;k[e+4>>2]=0}if((g|0)==1){o=i|b&0;p=a|0|0;return (L=o,p)|0}else{p=gd(g|0)|0;o=j>>>(p>>>0)|0;p=j<<32-p|l>>>(p>>>0)|0;return (L=o,p)|0}}else{if(f){if(e){k[e>>2]=(j>>>0)%(g>>>0);k[e+4>>2]=0}o=0;p=(j>>>0)/(g>>>0)>>>0;return (L=o,p)|0}if(!l){if(e){k[e>>2]=0;k[e+4>>2]=(j>>>0)%(h>>>0)}o=0;p=(j>>>0)/(h>>>0)>>>0;return (L=o,p)|0}f=h-1|0;if(!(f&h)){if(e){k[e>>2]=a|0;k[e+4>>2]=f&j|b&0}o=0;p=j>>>((gd(h|0)|0)>>>0);return (L=o,p)|0}f=(ja(h|0)|0)-(ja(j|0)|0)|0;if(f>>>0<=30){b=f+1|0;h=31-f|0;g=b;a=j<>>(b>>>0);b=j>>>(b>>>0);f=0;h=l<>2]=a|0;k[e+4>>2]=i|b&0;o=0;p=0;return (L=o,p)|0}while(0);if(!g){j=h;i=0;h=0}else{m=c|0|0;l=n|d&0;j=dd(m|0,l|0,-1,-1)|0;c=L;i=h;h=0;do{d=i;i=f>>>31|i<<1;f=h|f<<1;d=a<<1|d>>>31|0;n=a>>>31|b<<1|0;$c(j,c,d,n)|0;p=L;o=p>>31|((p|0)<0?-1:0)<<1;h=o&1;a=$c(d,n,o&m,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l)|0;b=L;g=g-1|0}while((g|0)!=0);j=i;i=0}g=0;if(e){k[e>>2]=a;k[e+4>>2]=b}o=(f|0)>>>31|(j|g)<<1|(g<<1|f>>>31)&0|i;p=(f<<1|0>>>31)&-2|h;return (L=o,p)|0}function od(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ua[a&7](b|0,c|0,d|0)|0}function pd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Va[a&3](b|0,c|0,d|0,e|0,f|0)}function qd(a,b){a=a|0;b=b|0;Wa[a&7](b|0)}function rd(a,b){a=a|0;b=b|0;return Xa[a&1](b|0)|0}function sd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ya[a&0](b|0,c|0,d|0)}function td(a){a=a|0;Za[a&3]()}function ud(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;_a[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function vd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return $a[a&1](b|0,c|0,d|0,e|0,f|0)|0}function wd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ab[a&3](b|0,c|0,d|0,e|0)}function xd(a,b,c){a=a|0;b=b|0;c=c|0;ka(0);return 0}function yd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ka(1)}function zd(a){a=a|0;ka(2)}function Ad(a){a=a|0;ka(3);return 0}function Bd(a,b,c){a=a|0;b=b|0;c=c|0;ka(4)}function Cd(){ka(5)}function Dd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ka(6)}function Ed(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ka(7);return 0}function Fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ka(8)} + +// EMSCRIPTEN_END_FUNCS +var Ua=[xd,ac,Qc,Jc,Ic,Kc,xd,xd];var Va=[yd,hc,gc,yd];var Wa=[zd,Xb,_b,Yb,Zb,$b,oc,Pc];var Xa=[Ad,Hc];var Ya=[Bd];var Za=[Cd,mc,nc,Cd];var _a=[Dd,jc,ic,Dd];var $a=[Ed,ob];var ab=[Fd,cc,dc,Fd];return{___cxa_can_catch:kc,_crn_get_levels:Db,_crn_get_uncompressed_size:Fb,_crn_decompress:Gb,_i64Add:dd,_crn_get_width:Bb,___cxa_is_pointer_type:lc,_i64Subtract:$c,_memset:ad,_malloc:Uc,_free:Vc,_memcpy:ed,_bitshift64Lshr:bd,_fflush:wc,_bitshift64Shl:cd,_crn_get_height:Cb,___errno_location:qc,_crn_get_dxt_format:Eb,runPostSets:_c,_emscripten_replace_memory:Ta,stackAlloc:bb,stackSave:cb,stackRestore:db,establishStackSpace:eb,setThrew:fb,setTempRet0:ib,getTempRet0:jb,dynCall_iiii:od,dynCall_viiiii:pd,dynCall_vi:qd,dynCall_ii:rd,dynCall_viii:sd,dynCall_v:td,dynCall_viiiiii:ud,dynCall_iiiiii:vd,dynCall_viiii:wd}}) + + +// EMSCRIPTEN_END_ASM +(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch;e._crn_get_levels=Z._crn_get_levels;e.runPostSets=Z.runPostSets;e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size;e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height;e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type; +var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush;e._crn_get_width=Z._crn_get_width;e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;e.dynCall_iiii=Z.dynCall_iiii;e.dynCall_viiiii=Z.dynCall_viiiii;e.dynCall_vi=Z.dynCall_vi; +e.dynCall_ii=Z.dynCall_ii;e.dynCall_viii=Z.dynCall_viii;e.dynCall_v=Z.dynCall_v;e.dynCall_viiiiii=Z.dynCall_viiiiii;e.dynCall_iiiiii=Z.dynCall_iiiiii;e.dynCall_viiii=Z.dynCall_viiii;n.aa=Z.stackAlloc;n.ua=Z.stackSave;n.ba=Z.stackRestore;n.Cd=Z.establishStackSpace;n.rb=Z.setTempRet0;n.fb=Z.getTempRet0;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}ia.prototype=Error();ia.prototype.constructor=ia; +var rd=null,jb=function sd(){e.calledRun||td();e.calledRun||(jb=sd)}; +e.callMain=e.zd=function(a){function b(){for(var a=0;3>a;a++)d.push(0)}assert(0==I,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(0==bb.length,"cannot call main when preRun functions remain to be called");a=a||[];Ha||(Ha=!0,ab(cb));var c=a.length+1,d=[D(hb(e.thisProgram),"i8",0)];b();for(var f=0;f> 1; - if (width < 1) { - width = 1; - } - height = height >> 1; - if (height < 1) { - height = 1; - } - offset += levelSize; - } - this._internalLoader.free(); - if (!this.preserveSource) - this.data = null; - return true; - }; - CompressedImage.prototype.style = function (renderer, baseTexture, glTexture) { - var gl = renderer.state.gl; - var levels = this.levels; - if (baseTexture.scaleMode === PIXI.SCALE_MODES.LINEAR) { - if (levels > 1) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); - } - else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - } - } - else { - if (levels > 1) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); - } - else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - } - } - return true; - }; - CompressedImage.prototype.loadFromArrayBuffer = function (arrayBuffer, crnLoad) { - var loaders = pixi_compressed_textures.Loaders; - if (!loaders || !loaders.length) { - throw "Registered compressed loaders is missing. Call `TextureSystem.initCompressed` before loading!"; - } - var selectedLoaderCtr = undefined; - for (var _i = 0, loaders_1 = loaders; _i < loaders_1.length; _i++) { - var loader = loaders_1[_i]; - if (!crnLoad) { - if (loader.test(arrayBuffer)) { - selectedLoaderCtr = loader; - break; - } - } - else { - if (loader.type === "CRN") { - selectedLoaderCtr = loader; - break; - } - } - } - if (selectedLoaderCtr) { - this._internalLoader = new selectedLoaderCtr(this); - return this._internalLoader.load(arrayBuffer); - } - else { - throw new Error("Compressed texture format is not recognized: " + this.src); - } - }; - return CompressedImage; - }(PIXI.resources.Resource)); - pixi_compressed_textures.CompressedImage = CompressedImage; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var AbstractInternalLoader = (function () { - function AbstractInternalLoader(_image) { - if (_image === void 0) { _image = new pixi_compressed_textures.CompressedImage("unknown"); } - this._image = _image; - this._format = 0; - _image._internalLoader = this; - } - AbstractInternalLoader.prototype.free = function () { }; - ; - AbstractInternalLoader.test = function (arrayBuffer) { - return false; - }; - AbstractInternalLoader.type = "ABSTRACT"; - return AbstractInternalLoader; - }()); - pixi_compressed_textures.AbstractInternalLoader = AbstractInternalLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var _a; - var ASTC_HEADER_LENGTH = 16; - var ASTC_HEADER_DIM_X = 4; - var ASTC_HEADER_DIM_Y = 5; - var ASTC_HEADER_WIDTH = 7; - var ASTC_HEADER_HEIGHT = 10; - var ASTC_MAGIC = 0x5CA1AB13; - var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0; - var COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1; - var COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2; - var COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3; - var COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4; - var COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5; - var COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6; - var COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7; - var COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8; - var COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9; - var COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA; - var COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB; - var COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC; - var COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD; - var COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0; - var COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1; - var COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2; - var COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3; - var COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4; - var COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5; - var COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6; - var COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7; - var COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8; - var COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9; - var COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA; - var COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB; - var COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC; - var COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD; - var ASTC_DIMS_TO_FORMAT = (_a = {}, - _a[4 * 4] = 0, - _a[5 * 4] = 1, - _a[5 * 5] = 2, - _a[6 * 5] = 3, - _a[6 * 6] = 4, - _a[8 * 5] = 5, - _a[8 * 6] = 6, - _a[8 * 8] = 7, - _a[10 * 5] = 8, - _a[10 * 6] = 9, - _a[10 * 8] = 10, - _a[10 * 10] = 11, - _a[12 * 10] = 12, - _a[12 * 12] = 13, - _a); - var ASTCLoader = (function (_super) { - __extends(ASTCLoader, _super); - function ASTCLoader(_image, useSRGB) { - if (useSRGB === void 0) { useSRGB = false; } - var _this = _super.call(this, _image) || this; - _this.useSRGB = useSRGB; - _this._blockSize = { x: 0, y: 0 }; - return _this; - } - ASTCLoader.prototype.load = function (buffer) { - if (!ASTCLoader.test(buffer)) { - throw "Invalid magic number in ASTC header"; - } - var header = new Uint8Array(buffer, 0, ASTC_HEADER_LENGTH); - var dim_x = header[ASTC_HEADER_DIM_X]; - var dim_y = header[ASTC_HEADER_DIM_Y]; - var width = (header[ASTC_HEADER_WIDTH]) + (header[ASTC_HEADER_WIDTH + 1] << 8) + (header[ASTC_HEADER_WIDTH + 2] << 16); - var height = (header[ASTC_HEADER_HEIGHT]) + (header[ASTC_HEADER_HEIGHT + 1] << 8) + (header[ASTC_HEADER_HEIGHT + 2] << 16); - var internalFormat = ASTC_DIMS_TO_FORMAT[dim_x * dim_y] + (this.useSRGB ? COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : COMPRESSED_RGBA_ASTC_4x4_KHR); - var astcData = new Uint8Array(buffer, ASTC_HEADER_LENGTH); - this._format = internalFormat; - this._blockSize.x = dim_x; - this._blockSize.y = dim_y; - var dest = this._image; - dest.init(dest.src, astcData, 'ASTC', width, height, 1, internalFormat); - return dest; - }; - ASTCLoader.test = function (buffer) { - var magic = new Int32Array(buffer, 0, 1); - return magic[0] === ASTC_MAGIC; - }; - ASTCLoader.prototype.levelBufferSize = function (width, height, mipLevel) { - if (mipLevel === void 0) { mipLevel = 0; } - var f_ = Math.floor; - var dim_x = this._blockSize.x; - var dim_y = this._blockSize.y; - return (f_((width + dim_x - 1) / dim_x) * f_((height + dim_y - 1) / dim_y)) << 4; - }; - ASTCLoader.type = "ASTC"; - return ASTCLoader; - }(pixi_compressed_textures.AbstractInternalLoader)); - pixi_compressed_textures.ASTCLoader = ASTCLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -function fourCCToInt32(value) { - return value.charCodeAt(0) + - (value.charCodeAt(1) << 8) + - (value.charCodeAt(2) << 16) + - (value.charCodeAt(3) << 24); -} -function int32ToFourCC(value) { - return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff); -} -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var _a; - var DDS_MAGIC = 0x20534444; - var DDSD_MIPMAPCOUNT = 0x20000; - var DDPF_FOURCC = 0x4; - var DDS_HEADER_LENGTH = 31; - var DDS_HEADER_MAGIC = 0; - var DDS_HEADER_SIZE = 1; - var DDS_HEADER_FLAGS = 2; - var DDS_HEADER_HEIGHT = 3; - var DDS_HEADER_WIDTH = 4; - var DDS_HEADER_MIPMAPCOUNT = 7; - var DDS_HEADER_PF_FLAGS = 20; - var DDS_HEADER_PF_FOURCC = 21; - var FOURCC_DXT1 = fourCCToInt32("DXT1"); - var FOURCC_DXT3 = fourCCToInt32("DXT3"); - var FOURCC_DXT5 = fourCCToInt32("DXT5"); - var FOURCC_ATC = fourCCToInt32("ATC "); - var FOURCC_ATCA = fourCCToInt32("ATCA"); - var FOURCC_ATCI = fourCCToInt32("ATCI"); - var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; - var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; - var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; - var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; - var COMPRESSED_RGB_ATC_WEBGL = 0x8C92; - var COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93; - var COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE; - var FOURCC_TO_FORMAT = (_a = {}, - _a[FOURCC_DXT1] = COMPRESSED_RGB_S3TC_DXT1_EXT, - _a[FOURCC_DXT3] = COMPRESSED_RGBA_S3TC_DXT3_EXT, - _a[FOURCC_DXT5] = COMPRESSED_RGBA_S3TC_DXT5_EXT, - _a[FOURCC_ATC] = COMPRESSED_RGB_ATC_WEBGL, - _a[FOURCC_ATCA] = COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, - _a[FOURCC_ATCI] = COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, - _a); - var DDSLoader = (function (_super) { - __extends(DDSLoader, _super); - function DDSLoader(_image) { - return _super.call(this, _image) || this; - } - DDSLoader.prototype.load = function (arrayBuffer) { - if (!DDSLoader.test(arrayBuffer)) { - throw "Invalid magic number in DDS header"; - } - var header = new Int32Array(arrayBuffer, 0, DDS_HEADER_LENGTH); - if (!(header[DDS_HEADER_PF_FLAGS] & DDPF_FOURCC)) - throw "Unsupported format, must contain a FourCC code"; - var fourCC = header[DDS_HEADER_PF_FOURCC]; - var internalFormat = FOURCC_TO_FORMAT[fourCC] || -1; - if (internalFormat < 0) { - throw "Unsupported FourCC code: " + int32ToFourCC(fourCC); - } - var levels = 1; - if (header[DDS_HEADER_FLAGS] & DDSD_MIPMAPCOUNT) { - levels = Math.max(1, header[DDS_HEADER_MIPMAPCOUNT]); - } - var width = header[DDS_HEADER_WIDTH]; - var height = header[DDS_HEADER_HEIGHT]; - var dataOffset = header[DDS_HEADER_SIZE] + 4; - var dxtData = new Uint8Array(arrayBuffer, dataOffset); - var dest = this._image; - this._format = internalFormat; - dest.init(dest.src, dxtData, 'DDS', width, height, levels, internalFormat); - return dest; - }; - DDSLoader.test = function (buffer) { - var magic = new Int32Array(buffer, 0, 1); - return magic[0] === DDS_MAGIC; - }; - DDSLoader.prototype.levelBufferSize = function (width, height, mipLevel) { - if (mipLevel === void 0) { mipLevel = 0; } - switch (this._format) { - case COMPRESSED_RGB_S3TC_DXT1_EXT: - case COMPRESSED_RGB_ATC_WEBGL: - return ((width + 3) >> 2) * ((height + 3) >> 2) * 8; - case COMPRESSED_RGBA_S3TC_DXT3_EXT: - case COMPRESSED_RGBA_S3TC_DXT5_EXT: - case COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: - case COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: - return ((width + 3) >> 2) * ((height + 3) >> 2) * 16; - default: - return 0; - } - }; - DDSLoader.type = "DDS"; - return DDSLoader; - }(pixi_compressed_textures.AbstractInternalLoader)); - pixi_compressed_textures.DDSLoader = DDSLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var _a; - var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; - var COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01; - var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; - var COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03; - var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; - var PVR_FORMAT_2BPP_RGB = 0; - var PVR_FORMAT_2BPP_RGBA = 1; - var PVR_FORMAT_4BPP_RGB = 2; - var PVR_FORMAT_4BPP_RGBA = 3; - var PVR_FORMAT_ETC1 = 6; - var PVR_FORMAT_DXT1 = 7; - var PVR_FORMAT_DXT3 = 9; - var PVR_FORMAT_DXT5 = 5; - var PVR_HEADER_LENGTH = 13; - var PVR_MAGIC = 0x03525650; - var PVR_HEADER_MAGIC = 0; - var PVR_HEADER_FORMAT = 2; - var PVR_HEADER_HEIGHT = 6; - var PVR_HEADER_WIDTH = 7; - var PVR_HEADER_MIPMAPCOUNT = 11; - var PVR_HEADER_METADATA = 12; - var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; - var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; - var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; - var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; - var PVR_TO_FORMAT = (_a = {}, - _a[PVR_FORMAT_2BPP_RGB] = COMPRESSED_RGB_PVRTC_2BPPV1_IMG, - _a[PVR_FORMAT_2BPP_RGBA] = COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, - _a[PVR_FORMAT_4BPP_RGB] = COMPRESSED_RGB_PVRTC_4BPPV1_IMG, - _a[PVR_FORMAT_4BPP_RGBA] = COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, - _a[PVR_FORMAT_ETC1] = COMPRESSED_RGB_ETC1_WEBGL, - _a[PVR_FORMAT_DXT1] = COMPRESSED_RGB_S3TC_DXT1_EXT, - _a[PVR_FORMAT_DXT3] = COMPRESSED_RGBA_S3TC_DXT3_EXT, - _a[PVR_FORMAT_DXT5] = COMPRESSED_RGBA_S3TC_DXT5_EXT, - _a); - var PVRTCLoader = (function (_super) { - __extends(PVRTCLoader, _super); - function PVRTCLoader(_image) { - return _super.call(this, _image) || this; - } - PVRTCLoader.prototype.load = function (arrayBuffer) { - if (!pixi_compressed_textures.DDSLoader.test(arrayBuffer)) { - throw "Invalid magic number in PVR header"; - } - var header = new Int32Array(arrayBuffer, 0, PVR_HEADER_LENGTH); - var format = header[PVR_HEADER_FORMAT]; - var internalFormat = PVR_TO_FORMAT[format] || -1; - var width = header[PVR_HEADER_WIDTH]; - var height = header[PVR_HEADER_HEIGHT]; - var levels = header[PVR_HEADER_MIPMAPCOUNT]; - var dataOffset = header[PVR_HEADER_METADATA] + 52; - var pvrtcData = new Uint8Array(arrayBuffer, dataOffset); - var dest = this._image; - this._format = internalFormat; - dest.init(dest.src, pvrtcData, 'PVR', width, height, levels, internalFormat); - return dest; - }; - PVRTCLoader.test = function (buffer) { - var magic = new Int32Array(buffer, 0, 1); - return magic[0] === PVR_MAGIC; - }; - PVRTCLoader.prototype.levelBufferSize = function (width, height, mipLevel) { - if (mipLevel === void 0) { mipLevel = 0; } - switch (this._format) { - case COMPRESSED_RGB_S3TC_DXT1_EXT: - case COMPRESSED_RGB_ETC1_WEBGL: - return ((width + 3) >> 2) * ((height + 3) >> 2) * 8; - case COMPRESSED_RGBA_S3TC_DXT3_EXT: - case COMPRESSED_RGBA_S3TC_DXT5_EXT: - return ((width + 3) >> 2) * ((height + 3) >> 2) * 16; - case COMPRESSED_RGB_PVRTC_4BPPV1_IMG: - case COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: - return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8); - case COMPRESSED_RGB_PVRTC_2BPPV1_IMG: - case COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: - return Math.floor((Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8); - default: - return 0; - } - }; - PVRTCLoader.type = "PVR"; - return PVRTCLoader; - }(pixi_compressed_textures.AbstractInternalLoader)); - pixi_compressed_textures.PVRTCLoader = PVRTCLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var _a, _b; - var BASIS_FORMAT = { - cTFETC1: 0, - cTFBC1: 2, - cTFBC3: 3, - cTFPVRTC1_4_RGB: 8, - cTFPVRTC1_4_RGBA: 9, - cTFASTC_4x4: 10, - cTFRGBA32: 11 - }; - var BASIS_HAS_ALPHA = (_a = {}, - _a[3] = true, - _a[9] = true, - _a[10] = true, - _a[11] = true, - _a); - var NON_COMPRESSED = -1; - var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; - var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; - var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; - var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; - var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; - var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; - var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; - var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0; - var BASIS_TO_FMT = (_b = {}, - _b[BASIS_FORMAT.cTFRGBA32] = NON_COMPRESSED, - _b[BASIS_FORMAT.cTFETC1] = COMPRESSED_RGB_ETC1_WEBGL, - _b[BASIS_FORMAT.cTFBC1] = COMPRESSED_RGB_S3TC_DXT1_EXT, - _b[BASIS_FORMAT.cTFBC3] = COMPRESSED_RGBA_S3TC_DXT5_EXT, - _b[BASIS_FORMAT.cTFPVRTC1_4_RGB] = COMPRESSED_RGB_PVRTC_4BPPV1_IMG, - _b[BASIS_FORMAT.cTFPVRTC1_4_RGBA] = COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, - _b[BASIS_FORMAT.cTFASTC_4x4] = COMPRESSED_RGBA_ASTC_4x4_KHR, - _b); - var FMT_TO_BASIS = Object.keys(BASIS_TO_FMT).reduce(function (acc, next) { - acc[BASIS_TO_FMT[+next]] = +next; - return acc; - }, {}); - var BASISLoader = (function (_super) { - __extends(BASISLoader, _super); - function BASISLoader(_image) { - var _this = _super.call(this, _image) || this; - _this.type = "BASIS"; - _this._file = undefined; - return _this; - } - BASISLoader.test = function (array) { - var header = new Uint32Array(array, 0, 1)[0]; - var decoder = !!BASISLoader.BASIS_BINDING; - var isValid = header === 0x134273 && decoder; - var isSupported = BASISLoader.RGB_FORMAT && BASISLoader.RGBA_FORMAT; - if (!isValid && isSupported) { - console.warn("[BASIS LOADER] Is Supported, but transcoder not binded or file is not BASIS file!"); - } - return (isSupported && isValid); - }; - BASISLoader.bindTranscoder = function (fileCtr, ext) { - if (!fileCtr || !ext) { - throw "Invalid state! undef fileCtr or ext invalid!"; - } - ; - var plain = Object.keys(ext) - .reduce(function (acc, key) { - var val = ext[key]; - if (!val) { - return acc; - } - ; - return Object.assign(acc, val.__proto__); - }, {}); - var latestOp = undefined; - var lastestAlpha = undefined; - for (var v in plain) { - var native = plain[v]; - if (FMT_TO_BASIS[native] !== undefined) { - var basis = FMT_TO_BASIS[native]; - if (BASIS_HAS_ALPHA[basis]) { - lastestAlpha = { - native: native, name: v, basis: basis - }; - } - else { - latestOp = { - native: native, name: v, basis: basis - }; - } - } - } - BASISLoader.RGB_FORMAT = latestOp || lastestAlpha; - BASISLoader.RGBA_FORMAT = lastestAlpha || latestOp; - BASISLoader.BASIS_BINDING = fileCtr; - console.log("[BASISLoader] Supported formats:", "\nRGB:" + BASISLoader.RGB_FORMAT.name + "\nRGBA:" + BASISLoader.RGBA_FORMAT.name); - pixi_compressed_textures.RegisterCompressedLoader(BASISLoader); - pixi_compressed_textures.RegisterCompressedExtensions('basis'); - }; - BASISLoader.prototype.load = function (buffer) { - if (!BASISLoader.test(buffer)) { - throw "BASIS Transcoder not binded or transcoding not supported =(!"; - } - this._loadAsync(buffer); - return this._image; - }; - BASISLoader.prototype._loadAsync = function (buffer) { - return __awaiter(this, void 0, void 0, function () { - var startTime, BasisFileCtr, basisFile, width, height, levels, hasAlpha, dest, target, dst, _a, name; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - startTime = performance.now(); - BasisFileCtr = BASISLoader.BASIS_BINDING; - basisFile = new BasisFileCtr(new Uint8Array(buffer)); - return [4, basisFile.getImageWidth(0, 0)]; - case 1: - width = _b.sent(); - return [4, basisFile.getImageHeight(0, 0)]; - case 2: - height = _b.sent(); - levels = 1; - return [4, basisFile.getHasAlpha()]; - case 3: - hasAlpha = _b.sent(); - dest = this._image; - return [4, basisFile.startTranscoding()]; - case 4: - if (!(_b.sent())) { - throw "Transcoding error!"; - } - target = hasAlpha ? BASISLoader.RGBA_FORMAT : BASISLoader.RGB_FORMAT; - console.log("Grats! BASIS will be transcoded to:", target); - _a = Uint8Array.bind; - return [4, basisFile.getImageTranscodedSizeInBytes(0, 0, target.basis)]; - case 5: - dst = new (_a.apply(Uint8Array, [void 0, _b.sent()]))(); - return [4, basisFile.transcodeImage(dst, 0, 0, target.basis, !!0, !!0)]; - case 6: - if (!(_b.sent())) { - throw "Transcoding error!"; - } - console.log("[BASISLoader] Totla transcoding time:", performance.now() - startTime); - this._format = target.native; - this._file = basisFile; - name = target.name.replace("COMPRESSED_", ""); - return [2, dest.init(dest.src, dst, 'BASIS|' + name, width, height, levels, target.native)]; - } - }); - }); - }; - BASISLoader.prototype.levelBufferSize = function (width, height, level) { - return this._file ? this._file.getImageTranscodedSizeInBytes(0, level, FMT_TO_BASIS[this._format]) : undefined; - }; - BASISLoader.BASIS_BINDING = undefined; - return BASISLoader; - }(pixi_compressed_textures.AbstractInternalLoader)); - pixi_compressed_textures.BASISLoader = BASISLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var CRN_Module = window.CRN_Module; - function arrayBufferCopy(src, dst, dstByteOffset, numBytes) { - var dst32Offset = dstByteOffset / 4; - var tail = (numBytes % 4); - var src32 = new Uint32Array(src.buffer, 0, (numBytes - tail) / 4); - var dst32 = new Uint32Array(dst.buffer); - for (var ii = 0; ii < src32.length; ii++) { - dst32[dst32Offset + ii] = src32[ii]; - } - for (var i = numBytes - tail; i < numBytes; i++) { - dst[dstByteOffset + i] = src[i]; - } - } - var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; - var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; - var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; - var DXT_FORMAT_MAP = [ - COMPRESSED_RGB_S3TC_DXT1_EXT, - COMPRESSED_RGBA_S3TC_DXT3_EXT, - COMPRESSED_RGBA_S3TC_DXT5_EXT - ]; - var CRNLoader = (function (_super) { - __extends(CRNLoader, _super); - function CRNLoader(_image) { - return _super.call(this, _image) || this; - } - CRNLoader.prototype.load = function (arrayBuffer) { - var srcSize = arrayBuffer.byteLength; - var bytes = new Uint8Array(arrayBuffer); - var src = CRN_Module._malloc(srcSize); - arrayBufferCopy(bytes, CRN_Module.HEAPU8, src, srcSize); - var width = CRN_Module._crn_get_width(src, srcSize); - var height = CRN_Module._crn_get_height(src, srcSize); - var levels = CRN_Module._crn_get_levels(src, srcSize); - var format = CRN_Module._crn_get_dxt_format(src, srcSize); - var dstSize = CRN_Module._crn_get_uncompressed_size(src, srcSize, 0); - var dst = CRN_Module._malloc(dstSize); - CRN_Module._crn_decompress(src, srcSize, dst, dstSize, 0); - var dxtData = new Uint8Array(CRN_Module.HEAPU8.buffer, dst, dstSize); - var internalFormat = DXT_FORMAT_MAP[format]; - var dest = this._image; - this._format = internalFormat; - this._caches = [src, dst]; - return dest.init(dest.src, dxtData, 'CRN', width, height, levels, internalFormat); - }; - CRNLoader.prototype.levelBufferSize = function (width, height, mipLevel) { - if (mipLevel === void 0) { mipLevel = 0; } - return pixi_compressed_textures.DDSLoader.prototype.levelBufferSize.call(this, width, height, mipLevel); - }; - CRNLoader.prototype.free = function () { - CRN_Module._free(this._caches[0]); - CRN_Module._free(this._caches[1]); - }; - CRNLoader.test = function (buffer) { - return !!CRN_Module; - }; - CRNLoader.type = "CRN"; - return CRNLoader; - }(pixi_compressed_textures.AbstractInternalLoader)); - pixi_compressed_textures.CRNLoader = CRNLoader; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - pixi_compressed_textures.Loaders = [ - pixi_compressed_textures.DDSLoader, - pixi_compressed_textures.PVRTCLoader, - pixi_compressed_textures.ASTCLoader, - pixi_compressed_textures.CRNLoader - ]; - PIXI.systems.TextureSystem.prototype.initCompressed = function () { - var gl = this.gl; - if (!this.compressedExtensions) { - this.compressedExtensions = { - dxt: gl.getExtension("WEBGL_compressed_texture_s3tc"), - pvrtc: (gl.getExtension("WEBGL_compressed_texture_pvrtc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")), - astc: gl.getExtension("WEBGL_compressed_texture_astc"), - atc: gl.getExtension("WEBGL_compressed_texture_atc"), - etc1: gl.getExtension("WEBGL_compressed_texture_etc1") - }; - this.compressedExtensions.crn = this.compressedExtensions.dxt; - } - }; - function RegisterCompressedLoader() { - var loaders = []; - for (var _i = 0; _i < arguments.length; _i++) { - loaders[_i] = arguments[_i]; - } - pixi_compressed_textures.Loaders = pixi_compressed_textures.Loaders || []; - for (var e in loaders) { - if (pixi_compressed_textures.Loaders.indexOf(loaders[e]) < 0) { - pixi_compressed_textures.Loaders.push(loaders[e]); - } - } - } - pixi_compressed_textures.RegisterCompressedLoader = RegisterCompressedLoader; - function detectExtensions(renderer, resolution) { - var extensions = []; - if (renderer instanceof PIXI.Renderer) { - renderer.texture.initCompressed(); - var data = renderer.texture.compressedExtensions; - if (data.dxt) - extensions.push('.dds'); - if (data.pvrtc) - extensions.push('.pvr'); - if (data.atc) - extensions.push('.atc'); - if (data.astc) - extensions.push('.astc'); - if (data.etc1) - extensions.push('.etc1'); - } - resolution = resolution || renderer.resolution; - var res = "@" + resolution + "x"; - var ext = extensions.slice(0); - while (ext.length > 0) { - extensions.push(res + ext.pop()); - } - extensions.push(res + ".png"); - extensions.push(res + ".jpg"); - extensions.push(res + ".json"); - extensions.push(res + ".atlas"); - return extensions; - } - pixi_compressed_textures.detectExtensions = detectExtensions; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var Resource = PIXI.LoaderResource; - pixi_compressed_textures.TEXTURE_EXTENSIONS = []; - function RegisterCompressedExtensions() { - var exts = []; - for (var _i = 0; _i < arguments.length; _i++) { - exts[_i] = arguments[_i]; - } - for (var e in exts) { - if (pixi_compressed_textures.TEXTURE_EXTENSIONS.indexOf(exts[e]) < 0) { - pixi_compressed_textures.TEXTURE_EXTENSIONS.push(exts[e]); - Resource.setExtensionXhrType(exts[e], Resource.XHR_RESPONSE_TYPE.BUFFER); - } - } - } - pixi_compressed_textures.RegisterCompressedExtensions = RegisterCompressedExtensions; - var ImageParser = (function () { - function ImageParser() { - } - ImageParser.use = function (resource, next) { - var url = resource.url; - var idx = url.lastIndexOf('.'); - var amper = url.lastIndexOf('?'); - var ext = url.substring(idx + 1, amper > 0 ? amper : url.length); - if (pixi_compressed_textures.TEXTURE_EXTENSIONS.indexOf(ext) < 0) { - next(); - return; - } - if (!resource.data) { - throw new Error("compressedImageParser middleware for PixiJS v5 must be specified in loader.use()" + - " and must have resource.data when completed"); - } - if (resource.compressedImage) { - next(); - return; - } - resource.compressedImage = new pixi_compressed_textures.CompressedImage(resource.url); - resource.compressedImage.loadFromArrayBuffer(resource.data, ext === 'crn'); - resource.isCompressedImage = true; - resource.texture = fromResource(resource.compressedImage, resource.url, resource.name); - next(); - }; - return ImageParser; - }()); - pixi_compressed_textures.ImageParser = ImageParser; - function fromResource(resource, imageUrl, name) { - var baseTexture = new PIXI.BaseTexture(resource, { - scaleMode: PIXI.settings.SCALE_MODE, - resolution: PIXI.utils.getResolutionOfUrl(imageUrl), - }); - var texture = new PIXI.Texture(baseTexture); - if (!name) { - name = imageUrl; - } - PIXI.BaseTexture.addToCache(texture.baseTexture, name); - PIXI.Texture.addToCache(texture, name); - if (name !== imageUrl) { - PIXI.BaseTexture.addToCache(texture.baseTexture, imageUrl); - PIXI.Texture.addToCache(texture, imageUrl); - } - return texture; - } - RegisterCompressedExtensions('dds', 'crn', 'pvr', 'etc1', 'astc'); - PIXI.Loader.registerPlugin(ImageParser); -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - function extensionChooser(supportedExtensions) { - if (supportedExtensions === void 0) { supportedExtensions = []; } - return function (resource, next) { - var ext = resource.metadata.choice; - if (!ext) { - return next(); - } - var url = resource.url; - var k = 0; - if (!resource._defaultUrlChoice) { - resource._defaultUrlChoice = url; - k = url.lastIndexOf("."); - if (k >= 0) { - resource._baseUrl = url.substring(0, k); - if (k >= 4 && url.substring(k - 3, 3) === '@1x') { - resource._baseUrl = url.substring(0, k); - } - } - else { - return next(); - } - } - for (var i = ext.length - 1; i >= 0; i--) { - url = resource._baseUrl + ext[i]; - var isSupported = false; - for (var j = 0; j < supportedExtensions.length; j++) { - if (ext[i] === supportedExtensions[j]) { - resource.url = url; - var pureExt = ext[i]; - if (pureExt.indexOf('@') > -1) { - pureExt = pureExt.replace(/@[0-9.]*x/, ""); - } - k = pureExt.indexOf('.'); - if (k >= 0) { - pureExt = pureExt.substring(k + 1); - } - resource.extension = pureExt; - resource.loadType = resource._determineLoadType(); - next(); - return; - } - } - } - next(); - }; - } - pixi_compressed_textures.extensionChooser = extensionChooser; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - var ExtensionFixer = (function () { - function ExtensionFixer() { - } - ExtensionFixer.use = function (resource, next) { - if (resource.texture && resource._defaultUrlChoice && resource._defaultUrl !== resource.url) { - var texture = resource.texture; - var baseTexture = texture.baseTexture; - var oldUrl = resource.url; - var newUrl = resource._defaultUrlChoice; - var ind = baseTexture.textureCacheIds.indexOf(oldUrl); - if (ind >= 0) { - baseTexture.textureCacheIds[ind] = newUrl; - delete PIXI.utils.BaseTextureCache[resource.url]; - PIXI.utils.BaseTextureCache[newUrl] = baseTexture; - } - ind = texture.textureCacheIds.indexOf(oldUrl); - if (ind >= 0) { - texture.textureCacheIds[ind] = newUrl; - delete PIXI.utils.TextureCache[resource.url]; - PIXI.utils.TextureCache[newUrl] = baseTexture; - } - } - next(); - }; - return ExtensionFixer; - }()); - pixi_compressed_textures.ExtensionFixer = ExtensionFixer; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); -var pixi_compressed_textures; -(function (pixi_compressed_textures) { - PIXI.compressedTextures = pixi_compressed_textures; -})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + function loadFromArrayBuffer(arrayBuffer, src, crnLoad) { + return new CompressedImage(src).loadFromArrayBuffer(arrayBuffer, crnLoad); + } + pixi_compressed_textures.loadFromArrayBuffer = loadFromArrayBuffer; + var CompressedImage = (function (_super) { + __extends(CompressedImage, _super); + function CompressedImage(src, data, type, width, height, levels, internalFormat) { + var _this = _super.call(this) || this; + _this.complete = false; + _this.isCompressedImage = true; + _this.preserveSource = true; + _this.onload = null; + _this.baseTexture = null; + _this.init(src, data, type, width, height, levels, internalFormat); + return _this; + } + CompressedImage.prototype.init = function (src, data, type, width, height, levels, internalFormat) { + if (width === void 0) { width = -1; } + if (height === void 0) { height = -1; } + this.src = src; + this.resize(width, height); + this._width = width; + this._height = height; + this.data = data; + this.type = type; + this.levels = levels; + this.internalFormat = internalFormat; + var oldComplete = this.complete; + this.complete = !!data; + if (!oldComplete && this.complete && this.onload) { + this.onload({ target: this }); + } + this.update(); + return this; + }; + CompressedImage.prototype.dispose = function () { + this.data = null; + }; + CompressedImage.prototype.bind = function (baseTexture) { + baseTexture.premultiplyAlpha = false; + _super.prototype.bind.call(this, baseTexture); + }; + CompressedImage.prototype.upload = function (renderer, baseTexture, glTexture) { + var gl = renderer.state.gl; + glTexture.compressed = false; + renderer.texture.initCompressed(); + if (this.data === null) { + throw "Trying to create a second (or more) webgl texture from the same CompressedImage : " + this.src; + } + var levels = this.levels; + var width = this.width; + var height = this.height; + var offset = 0; + for (var i = 0; i < levels; ++i) { + var levelSize = this._internalLoader.levelBufferSize(width, height, i); + var dxtLevel = new Uint8Array(this.data.buffer, this.data.byteOffset + offset, levelSize); + gl.compressedTexImage2D(gl.TEXTURE_2D, i, this.internalFormat, width, height, 0, dxtLevel); + width = width >> 1; + if (width < 1) { + width = 1; + } + height = height >> 1; + if (height < 1) { + height = 1; + } + offset += levelSize; + } + this._internalLoader.free(); + if (!this.preserveSource) + this.data = null; + return true; + }; + CompressedImage.prototype.style = function (renderer, baseTexture, glTexture) { + var gl = renderer.state.gl; + var levels = this.levels; + if (baseTexture.scaleMode === PIXI.SCALE_MODES.LINEAR) { + if (levels > 1) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); + } + else { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + } + } + else { + if (levels > 1) { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); + } + else { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + } + } + return true; + }; + CompressedImage.prototype.loadFromArrayBuffer = function (arrayBuffer, crnLoad) { + var loaders = pixi_compressed_textures.Loaders; + if (!loaders || !loaders.length) { + throw "Registered compressed loaders is missing. Call `TextureSystem.initCompressed` before loading!"; + } + var selectedLoaderCtr = undefined; + for (var _i = 0, loaders_1 = loaders; _i < loaders_1.length; _i++) { + var loader = loaders_1[_i]; + if (!crnLoad) { + if (loader.test(arrayBuffer)) { + selectedLoaderCtr = loader; + break; + } + } + else { + if (loader.type === "CRN") { + selectedLoaderCtr = loader; + break; + } + } + } + if (selectedLoaderCtr) { + this._internalLoader = new selectedLoaderCtr(this); + return this._internalLoader.load(arrayBuffer); + } + else { + throw new Error("Compressed texture format is not recognized: " + this.src); + } + }; + return CompressedImage; + }(PIXI.resources.Resource)); + pixi_compressed_textures.CompressedImage = CompressedImage; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var AbstractInternalLoader = (function () { + function AbstractInternalLoader(_image) { + if (_image === void 0) { _image = new pixi_compressed_textures.CompressedImage("unknown"); } + this._image = _image; + this._format = 0; + _image._internalLoader = this; + } + AbstractInternalLoader.prototype.free = function () { }; + ; + AbstractInternalLoader.test = function (arrayBuffer) { + return false; + }; + AbstractInternalLoader.type = "ABSTRACT"; + return AbstractInternalLoader; + }()); + pixi_compressed_textures.AbstractInternalLoader = AbstractInternalLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var _a; + var ASTC_HEADER_LENGTH = 16; + var ASTC_HEADER_DIM_X = 4; + var ASTC_HEADER_DIM_Y = 5; + var ASTC_HEADER_WIDTH = 7; + var ASTC_HEADER_HEIGHT = 10; + var ASTC_MAGIC = 0x5CA1AB13; + var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0; + var COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1; + var COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2; + var COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3; + var COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4; + var COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5; + var COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6; + var COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7; + var COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8; + var COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9; + var COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA; + var COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB; + var COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC; + var COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD; + var COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0; + var COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1; + var COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2; + var COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3; + var COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4; + var COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5; + var COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6; + var COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7; + var COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8; + var COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9; + var COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA; + var COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB; + var COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC; + var COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD; + var ASTC_DIMS_TO_FORMAT = (_a = {}, + _a[4 * 4] = 0, + _a[5 * 4] = 1, + _a[5 * 5] = 2, + _a[6 * 5] = 3, + _a[6 * 6] = 4, + _a[8 * 5] = 5, + _a[8 * 6] = 6, + _a[8 * 8] = 7, + _a[10 * 5] = 8, + _a[10 * 6] = 9, + _a[10 * 8] = 10, + _a[10 * 10] = 11, + _a[12 * 10] = 12, + _a[12 * 12] = 13, + _a); + var ASTCLoader = (function (_super) { + __extends(ASTCLoader, _super); + function ASTCLoader(_image, useSRGB) { + if (useSRGB === void 0) { useSRGB = false; } + var _this = _super.call(this, _image) || this; + _this.useSRGB = useSRGB; + _this._blockSize = { x: 0, y: 0 }; + return _this; + } + ASTCLoader.prototype.load = function (buffer) { + if (!ASTCLoader.test(buffer)) { + throw "Invalid magic number in ASTC header"; + } + var header = new Uint8Array(buffer, 0, ASTC_HEADER_LENGTH); + var dim_x = header[ASTC_HEADER_DIM_X]; + var dim_y = header[ASTC_HEADER_DIM_Y]; + var width = (header[ASTC_HEADER_WIDTH]) + (header[ASTC_HEADER_WIDTH + 1] << 8) + (header[ASTC_HEADER_WIDTH + 2] << 16); + var height = (header[ASTC_HEADER_HEIGHT]) + (header[ASTC_HEADER_HEIGHT + 1] << 8) + (header[ASTC_HEADER_HEIGHT + 2] << 16); + var internalFormat = ASTC_DIMS_TO_FORMAT[dim_x * dim_y] + (this.useSRGB ? COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : COMPRESSED_RGBA_ASTC_4x4_KHR); + var astcData = new Uint8Array(buffer, ASTC_HEADER_LENGTH); + this._format = internalFormat; + this._blockSize.x = dim_x; + this._blockSize.y = dim_y; + var dest = this._image; + dest.init(dest.src, astcData, 'ASTC', width, height, 1, internalFormat); + return dest; + }; + ASTCLoader.test = function (buffer) { + var magic = new Int32Array(buffer, 0, 1); + return magic[0] === ASTC_MAGIC; + }; + ASTCLoader.prototype.levelBufferSize = function (width, height, mipLevel) { + if (mipLevel === void 0) { mipLevel = 0; } + var f_ = Math.floor; + var dim_x = this._blockSize.x; + var dim_y = this._blockSize.y; + return (f_((width + dim_x - 1) / dim_x) * f_((height + dim_y - 1) / dim_y)) << 4; + }; + ASTCLoader.type = "ASTC"; + return ASTCLoader; + }(pixi_compressed_textures.AbstractInternalLoader)); + pixi_compressed_textures.ASTCLoader = ASTCLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +function fourCCToInt32(value) { + return value.charCodeAt(0) + + (value.charCodeAt(1) << 8) + + (value.charCodeAt(2) << 16) + + (value.charCodeAt(3) << 24); +} +function int32ToFourCC(value) { + return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff); +} +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var _a; + var DDS_MAGIC = 0x20534444; + var DDSD_MIPMAPCOUNT = 0x20000; + var DDPF_FOURCC = 0x4; + var DDS_HEADER_LENGTH = 31; + var DDS_HEADER_MAGIC = 0; + var DDS_HEADER_SIZE = 1; + var DDS_HEADER_FLAGS = 2; + var DDS_HEADER_HEIGHT = 3; + var DDS_HEADER_WIDTH = 4; + var DDS_HEADER_MIPMAPCOUNT = 7; + var DDS_HEADER_PF_FLAGS = 20; + var DDS_HEADER_PF_FOURCC = 21; + var FOURCC_DXT1 = fourCCToInt32("DXT1"); + var FOURCC_DXT3 = fourCCToInt32("DXT3"); + var FOURCC_DXT5 = fourCCToInt32("DXT5"); + var FOURCC_ATC = fourCCToInt32("ATC "); + var FOURCC_ATCA = fourCCToInt32("ATCA"); + var FOURCC_ATCI = fourCCToInt32("ATCI"); + var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; + var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; + var COMPRESSED_RGB_ATC_WEBGL = 0x8C92; + var COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93; + var COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE; + var FOURCC_TO_FORMAT = (_a = {}, + _a[FOURCC_DXT1] = COMPRESSED_RGB_S3TC_DXT1_EXT, + _a[FOURCC_DXT3] = COMPRESSED_RGBA_S3TC_DXT3_EXT, + _a[FOURCC_DXT5] = COMPRESSED_RGBA_S3TC_DXT5_EXT, + _a[FOURCC_ATC] = COMPRESSED_RGB_ATC_WEBGL, + _a[FOURCC_ATCA] = COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, + _a[FOURCC_ATCI] = COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, + _a); + var DDSLoader = (function (_super) { + __extends(DDSLoader, _super); + function DDSLoader(_image) { + return _super.call(this, _image) || this; + } + DDSLoader.prototype.load = function (arrayBuffer) { + if (!DDSLoader.test(arrayBuffer)) { + throw "Invalid magic number in DDS header"; + } + var header = new Int32Array(arrayBuffer, 0, DDS_HEADER_LENGTH); + if (!(header[DDS_HEADER_PF_FLAGS] & DDPF_FOURCC)) + throw "Unsupported format, must contain a FourCC code"; + var fourCC = header[DDS_HEADER_PF_FOURCC]; + var internalFormat = FOURCC_TO_FORMAT[fourCC] || -1; + if (internalFormat < 0) { + throw "Unsupported FourCC code: " + int32ToFourCC(fourCC); + } + var levels = 1; + if (header[DDS_HEADER_FLAGS] & DDSD_MIPMAPCOUNT) { + levels = Math.max(1, header[DDS_HEADER_MIPMAPCOUNT]); + } + var width = header[DDS_HEADER_WIDTH]; + var height = header[DDS_HEADER_HEIGHT]; + var dataOffset = header[DDS_HEADER_SIZE] + 4; + var dxtData = new Uint8Array(arrayBuffer, dataOffset); + var dest = this._image; + this._format = internalFormat; + dest.init(dest.src, dxtData, 'DDS', width, height, levels, internalFormat); + return dest; + }; + DDSLoader.test = function (buffer) { + var magic = new Int32Array(buffer, 0, 1); + return magic[0] === DDS_MAGIC; + }; + DDSLoader.prototype.levelBufferSize = function (width, height, mipLevel) { + if (mipLevel === void 0) { mipLevel = 0; } + switch (this._format) { + case COMPRESSED_RGB_S3TC_DXT1_EXT: + case COMPRESSED_RGB_ATC_WEBGL: + return ((width + 3) >> 2) * ((height + 3) >> 2) * 8; + case COMPRESSED_RGBA_S3TC_DXT3_EXT: + case COMPRESSED_RGBA_S3TC_DXT5_EXT: + case COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: + case COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: + return ((width + 3) >> 2) * ((height + 3) >> 2) * 16; + default: + return 0; + } + }; + DDSLoader.type = "DDS"; + return DDSLoader; + }(pixi_compressed_textures.AbstractInternalLoader)); + pixi_compressed_textures.DDSLoader = DDSLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var _a; + var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; + var COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01; + var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; + var COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03; + var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; + var PVR_FORMAT_2BPP_RGB = 0; + var PVR_FORMAT_2BPP_RGBA = 1; + var PVR_FORMAT_4BPP_RGB = 2; + var PVR_FORMAT_4BPP_RGBA = 3; + var PVR_FORMAT_ETC1 = 6; + var PVR_FORMAT_DXT1 = 7; + var PVR_FORMAT_DXT3 = 9; + var PVR_FORMAT_DXT5 = 5; + var PVR_HEADER_LENGTH = 13; + var PVR_MAGIC = 0x03525650; + var PVR_HEADER_MAGIC = 0; + var PVR_HEADER_FORMAT = 2; + var PVR_HEADER_HEIGHT = 6; + var PVR_HEADER_WIDTH = 7; + var PVR_HEADER_MIPMAPCOUNT = 11; + var PVR_HEADER_METADATA = 12; + var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; + var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; + var PVR_TO_FORMAT = (_a = {}, + _a[PVR_FORMAT_2BPP_RGB] = COMPRESSED_RGB_PVRTC_2BPPV1_IMG, + _a[PVR_FORMAT_2BPP_RGBA] = COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, + _a[PVR_FORMAT_4BPP_RGB] = COMPRESSED_RGB_PVRTC_4BPPV1_IMG, + _a[PVR_FORMAT_4BPP_RGBA] = COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, + _a[PVR_FORMAT_ETC1] = COMPRESSED_RGB_ETC1_WEBGL, + _a[PVR_FORMAT_DXT1] = COMPRESSED_RGB_S3TC_DXT1_EXT, + _a[PVR_FORMAT_DXT3] = COMPRESSED_RGBA_S3TC_DXT3_EXT, + _a[PVR_FORMAT_DXT5] = COMPRESSED_RGBA_S3TC_DXT5_EXT, + _a); + var PVRTCLoader = (function (_super) { + __extends(PVRTCLoader, _super); + function PVRTCLoader(_image) { + return _super.call(this, _image) || this; + } + PVRTCLoader.prototype.load = function (arrayBuffer) { + if (!pixi_compressed_textures.DDSLoader.test(arrayBuffer)) { + throw "Invalid magic number in PVR header"; + } + var header = new Int32Array(arrayBuffer, 0, PVR_HEADER_LENGTH); + var format = header[PVR_HEADER_FORMAT]; + var internalFormat = PVR_TO_FORMAT[format] || -1; + var width = header[PVR_HEADER_WIDTH]; + var height = header[PVR_HEADER_HEIGHT]; + var levels = header[PVR_HEADER_MIPMAPCOUNT]; + var dataOffset = header[PVR_HEADER_METADATA] + 52; + var pvrtcData = new Uint8Array(arrayBuffer, dataOffset); + var dest = this._image; + this._format = internalFormat; + dest.init(dest.src, pvrtcData, 'PVR', width, height, levels, internalFormat); + return dest; + }; + PVRTCLoader.test = function (buffer) { + var magic = new Int32Array(buffer, 0, 1); + return magic[0] === PVR_MAGIC; + }; + PVRTCLoader.prototype.levelBufferSize = function (width, height, mipLevel) { + if (mipLevel === void 0) { mipLevel = 0; } + switch (this._format) { + case COMPRESSED_RGB_S3TC_DXT1_EXT: + case COMPRESSED_RGB_ETC1_WEBGL: + return ((width + 3) >> 2) * ((height + 3) >> 2) * 8; + case COMPRESSED_RGBA_S3TC_DXT3_EXT: + case COMPRESSED_RGBA_S3TC_DXT5_EXT: + return ((width + 3) >> 2) * ((height + 3) >> 2) * 16; + case COMPRESSED_RGB_PVRTC_4BPPV1_IMG: + case COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: + return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8); + case COMPRESSED_RGB_PVRTC_2BPPV1_IMG: + case COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: + return Math.floor((Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8); + default: + return 0; + } + }; + PVRTCLoader.type = "PVR"; + return PVRTCLoader; + }(pixi_compressed_textures.AbstractInternalLoader)); + pixi_compressed_textures.PVRTCLoader = PVRTCLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var _a, _b; + var BASIS_FORMAT = { + cTFETC1: 0, + cTFBC1: 2, + cTFBC3: 3, + cTFPVRTC1_4_RGB: 8, + cTFPVRTC1_4_RGBA: 9, + cTFASTC_4x4: 10, + cTFRGBA32: 11 + }; + var BASIS_HAS_ALPHA = (_a = {}, + _a[3] = true, + _a[9] = true, + _a[10] = true, + _a[11] = true, + _a); + var NON_COMPRESSED = -1; + var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; + var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; + var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; + var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; + var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; + var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0; + var BASIS_TO_FMT = (_b = {}, + _b[BASIS_FORMAT.cTFRGBA32] = NON_COMPRESSED, + _b[BASIS_FORMAT.cTFETC1] = COMPRESSED_RGB_ETC1_WEBGL, + _b[BASIS_FORMAT.cTFBC1] = COMPRESSED_RGB_S3TC_DXT1_EXT, + _b[BASIS_FORMAT.cTFBC3] = COMPRESSED_RGBA_S3TC_DXT5_EXT, + _b[BASIS_FORMAT.cTFPVRTC1_4_RGB] = COMPRESSED_RGB_PVRTC_4BPPV1_IMG, + _b[BASIS_FORMAT.cTFPVRTC1_4_RGBA] = COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, + _b[BASIS_FORMAT.cTFASTC_4x4] = COMPRESSED_RGBA_ASTC_4x4_KHR, + _b); + var FMT_TO_BASIS = Object.keys(BASIS_TO_FMT).reduce(function (acc, next) { + acc[BASIS_TO_FMT[+next]] = +next; + return acc; + }, {}); + var BASISLoader = (function (_super) { + __extends(BASISLoader, _super); + function BASISLoader(_image) { + var _this = _super.call(this, _image) || this; + _this.type = "BASIS"; + _this._file = undefined; + return _this; + } + BASISLoader.test = function (array) { + var header = new Uint32Array(array, 0, 1)[0]; + var decoder = !!BASISLoader.BASIS_BINDING; + var isValid = header === 0x134273 && decoder; + var isSupported = BASISLoader.RGB_FORMAT && BASISLoader.RGBA_FORMAT; + if (!isValid && isSupported) { + console.warn("[BASIS LOADER] Is Supported, but transcoder not binded or file is not BASIS file!"); + } + return (isSupported && isValid); + }; + BASISLoader.bindTranscoder = function (fileCtr, ext) { + if (!fileCtr || !ext) { + throw "Invalid state! undef fileCtr or ext invalid!"; + } + ; + var plain = Object.keys(ext) + .reduce(function (acc, key) { + var val = ext[key]; + if (!val) { + return acc; + } + ; + return Object.assign(acc, val.__proto__); + }, {}); + var latestOp = undefined; + var lastestAlpha = undefined; + for (var v in plain) { + var native = plain[v]; + if (FMT_TO_BASIS[native] !== undefined) { + var basis = FMT_TO_BASIS[native]; + if (BASIS_HAS_ALPHA[basis]) { + lastestAlpha = { + native: native, name: v, basis: basis + }; + } + else { + latestOp = { + native: native, name: v, basis: basis + }; + } + } + } + BASISLoader.RGB_FORMAT = latestOp || lastestAlpha; + BASISLoader.RGBA_FORMAT = lastestAlpha || latestOp; + BASISLoader.BASIS_BINDING = fileCtr; + console.log("[BASISLoader] Supported formats:", "\nRGB:" + BASISLoader.RGB_FORMAT.name + "\nRGBA:" + BASISLoader.RGBA_FORMAT.name); + pixi_compressed_textures.RegisterCompressedLoader(BASISLoader); + pixi_compressed_textures.RegisterCompressedExtensions('basis'); + }; + BASISLoader.prototype.load = function (buffer) { + if (!BASISLoader.test(buffer)) { + throw "BASIS Transcoder not binded or transcoding not supported =(!"; + } + this._loadAsync(buffer); + return this._image; + }; + BASISLoader.prototype._loadAsync = function (buffer) { + return __awaiter(this, void 0, void 0, function () { + var startTime, BasisFileCtr, basisFile, width, height, levels, hasAlpha, dest, target, dst, _a, name; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + startTime = performance.now(); + BasisFileCtr = BASISLoader.BASIS_BINDING; + basisFile = new BasisFileCtr(new Uint8Array(buffer)); + return [4, basisFile.getImageWidth(0, 0)]; + case 1: + width = _b.sent(); + return [4, basisFile.getImageHeight(0, 0)]; + case 2: + height = _b.sent(); + levels = 1; + return [4, basisFile.getHasAlpha()]; + case 3: + hasAlpha = _b.sent(); + dest = this._image; + return [4, basisFile.startTranscoding()]; + case 4: + if (!(_b.sent())) { + throw "Transcoding error!"; + } + target = hasAlpha ? BASISLoader.RGBA_FORMAT : BASISLoader.RGB_FORMAT; + console.log("Grats! BASIS will be transcoded to:", target); + _a = Uint8Array.bind; + return [4, basisFile.getImageTranscodedSizeInBytes(0, 0, target.basis)]; + case 5: + dst = new (_a.apply(Uint8Array, [void 0, _b.sent()]))(); + return [4, basisFile.transcodeImage(dst, 0, 0, target.basis, !!0, !!0)]; + case 6: + if (!(_b.sent())) { + throw "Transcoding error!"; + } + console.log("[BASISLoader] Totla transcoding time:", performance.now() - startTime); + this._format = target.native; + this._file = basisFile; + name = target.name.replace("COMPRESSED_", ""); + return [2, dest.init(dest.src, dst, 'BASIS|' + name, width, height, levels, target.native)]; + } + }); + }); + }; + BASISLoader.prototype.levelBufferSize = function (width, height, level) { + return this._file ? this._file.getImageTranscodedSizeInBytes(0, level, FMT_TO_BASIS[this._format]) : undefined; + }; + BASISLoader.BASIS_BINDING = undefined; + return BASISLoader; + }(pixi_compressed_textures.AbstractInternalLoader)); + pixi_compressed_textures.BASISLoader = BASISLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var CRN_Module = window.CRN_Module; + function arrayBufferCopy(src, dst, dstByteOffset, numBytes) { + var dst32Offset = dstByteOffset / 4; + var tail = (numBytes % 4); + var src32 = new Uint32Array(src.buffer, 0, (numBytes - tail) / 4); + var dst32 = new Uint32Array(dst.buffer); + for (var ii = 0; ii < src32.length; ii++) { + dst32[dst32Offset + ii] = src32[ii]; + } + for (var i = numBytes - tail; i < numBytes; i++) { + dst[dstByteOffset + i] = src[i]; + } + } + var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; + var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; + var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; + var DXT_FORMAT_MAP = [ + COMPRESSED_RGB_S3TC_DXT1_EXT, + COMPRESSED_RGBA_S3TC_DXT3_EXT, + COMPRESSED_RGBA_S3TC_DXT5_EXT + ]; + var CRNLoader = (function (_super) { + __extends(CRNLoader, _super); + function CRNLoader(_image) { + return _super.call(this, _image) || this; + } + CRNLoader.prototype.load = function (arrayBuffer) { + var srcSize = arrayBuffer.byteLength; + var bytes = new Uint8Array(arrayBuffer); + var src = CRN_Module._malloc(srcSize); + arrayBufferCopy(bytes, CRN_Module.HEAPU8, src, srcSize); + var width = CRN_Module._crn_get_width(src, srcSize); + var height = CRN_Module._crn_get_height(src, srcSize); + var levels = CRN_Module._crn_get_levels(src, srcSize); + var format = CRN_Module._crn_get_dxt_format(src, srcSize); + var dstSize = CRN_Module._crn_get_uncompressed_size(src, srcSize, 0); + var dst = CRN_Module._malloc(dstSize); + CRN_Module._crn_decompress(src, srcSize, dst, dstSize, 0); + var dxtData = new Uint8Array(CRN_Module.HEAPU8.buffer, dst, dstSize); + var internalFormat = DXT_FORMAT_MAP[format]; + var dest = this._image; + this._format = internalFormat; + this._caches = [src, dst]; + return dest.init(dest.src, dxtData, 'CRN', width, height, levels, internalFormat); + }; + CRNLoader.prototype.levelBufferSize = function (width, height, mipLevel) { + if (mipLevel === void 0) { mipLevel = 0; } + return pixi_compressed_textures.DDSLoader.prototype.levelBufferSize.call(this, width, height, mipLevel); + }; + CRNLoader.prototype.free = function () { + CRN_Module._free(this._caches[0]); + CRN_Module._free(this._caches[1]); + }; + CRNLoader.test = function (buffer) { + return !!CRN_Module; + }; + CRNLoader.type = "CRN"; + return CRNLoader; + }(pixi_compressed_textures.AbstractInternalLoader)); + pixi_compressed_textures.CRNLoader = CRNLoader; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + pixi_compressed_textures.Loaders = [ + pixi_compressed_textures.DDSLoader, + pixi_compressed_textures.PVRTCLoader, + pixi_compressed_textures.ASTCLoader, + pixi_compressed_textures.CRNLoader + ]; + PIXI.systems.TextureSystem.prototype.initCompressed = function () { + var gl = this.gl; + if (!this.compressedExtensions) { + this.compressedExtensions = { + dxt: gl.getExtension("WEBGL_compressed_texture_s3tc"), + pvrtc: (gl.getExtension("WEBGL_compressed_texture_pvrtc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")), + astc: gl.getExtension("WEBGL_compressed_texture_astc"), + atc: gl.getExtension("WEBGL_compressed_texture_atc"), + etc1: gl.getExtension("WEBGL_compressed_texture_etc1") + }; + this.compressedExtensions.crn = this.compressedExtensions.dxt; + } + }; + function RegisterCompressedLoader() { + var loaders = []; + for (var _i = 0; _i < arguments.length; _i++) { + loaders[_i] = arguments[_i]; + } + pixi_compressed_textures.Loaders = pixi_compressed_textures.Loaders || []; + for (var e in loaders) { + if (pixi_compressed_textures.Loaders.indexOf(loaders[e]) < 0) { + pixi_compressed_textures.Loaders.push(loaders[e]); + } + } + } + pixi_compressed_textures.RegisterCompressedLoader = RegisterCompressedLoader; + function detectExtensions(renderer, resolution) { + var extensions = []; + if (renderer instanceof PIXI.Renderer) { + renderer.texture.initCompressed(); + var data = renderer.texture.compressedExtensions; + if (data.dxt) + extensions.push('.dds'); + if (data.pvrtc) + extensions.push('.pvr'); + if (data.atc) + extensions.push('.atc'); + if (data.astc) + extensions.push('.astc'); + if (data.etc1) + extensions.push('.etc1'); + } + resolution = resolution || renderer.resolution; + var res = "@" + resolution + "x"; + var ext = extensions.slice(0); + while (ext.length > 0) { + extensions.push(res + ext.pop()); + } + extensions.push(res + ".png"); + extensions.push(res + ".jpg"); + extensions.push(res + ".json"); + extensions.push(res + ".atlas"); + return extensions; + } + pixi_compressed_textures.detectExtensions = detectExtensions; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var Resource = PIXI.LoaderResource; + pixi_compressed_textures.TEXTURE_EXTENSIONS = []; + function RegisterCompressedExtensions() { + var exts = []; + for (var _i = 0; _i < arguments.length; _i++) { + exts[_i] = arguments[_i]; + } + for (var e in exts) { + if (pixi_compressed_textures.TEXTURE_EXTENSIONS.indexOf(exts[e]) < 0) { + pixi_compressed_textures.TEXTURE_EXTENSIONS.push(exts[e]); + Resource.setExtensionXhrType(exts[e], Resource.XHR_RESPONSE_TYPE.BUFFER); + } + } + } + pixi_compressed_textures.RegisterCompressedExtensions = RegisterCompressedExtensions; + var ImageParser = (function () { + function ImageParser() { + } + ImageParser.use = function (resource, next) { + var url = resource.url; + var idx = url.lastIndexOf('.'); + var amper = url.lastIndexOf('?'); + var ext = url.substring(idx + 1, amper > 0 ? amper : url.length); + if (pixi_compressed_textures.TEXTURE_EXTENSIONS.indexOf(ext) < 0) { + next(); + return; + } + if (!resource.data) { + throw new Error("compressedImageParser middleware for PixiJS v5 must be specified in loader.use()" + + " and must have resource.data when completed"); + } + if (resource.compressedImage) { + next(); + return; + } + resource.compressedImage = new pixi_compressed_textures.CompressedImage(resource.url); + resource.compressedImage.loadFromArrayBuffer(resource.data, ext === 'crn'); + resource.isCompressedImage = true; + resource.texture = fromResource(resource.compressedImage, resource.url, resource.name); + next(); + }; + return ImageParser; + }()); + pixi_compressed_textures.ImageParser = ImageParser; + function fromResource(resource, imageUrl, name) { + var baseTexture = new PIXI.BaseTexture(resource, { + scaleMode: PIXI.settings.SCALE_MODE, + resolution: PIXI.utils.getResolutionOfUrl(imageUrl), + }); + var texture = new PIXI.Texture(baseTexture); + if (!name) { + name = imageUrl; + } + PIXI.BaseTexture.addToCache(texture.baseTexture, name); + PIXI.Texture.addToCache(texture, name); + if (name !== imageUrl) { + PIXI.BaseTexture.addToCache(texture.baseTexture, imageUrl); + PIXI.Texture.addToCache(texture, imageUrl); + } + return texture; + } + RegisterCompressedExtensions('dds', 'crn', 'pvr', 'etc1', 'astc'); + PIXI.Loader.registerPlugin(ImageParser); +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + function extensionChooser(supportedExtensions) { + if (supportedExtensions === void 0) { supportedExtensions = []; } + return function (resource, next) { + var ext = resource.metadata.choice; + if (!ext) { + return next(); + } + var url = resource.url; + var k = 0; + if (!resource._defaultUrlChoice) { + resource._defaultUrlChoice = url; + k = url.lastIndexOf("."); + if (k >= 0) { + resource._baseUrl = url.substring(0, k); + if (k >= 4 && url.substring(k - 3, 3) === '@1x') { + resource._baseUrl = url.substring(0, k); + } + } + else { + return next(); + } + } + for (var i = ext.length - 1; i >= 0; i--) { + url = resource._baseUrl + ext[i]; + var isSupported = false; + for (var j = 0; j < supportedExtensions.length; j++) { + if (ext[i] === supportedExtensions[j]) { + resource.url = url; + var pureExt = ext[i]; + if (pureExt.indexOf('@') > -1) { + pureExt = pureExt.replace(/@[0-9.]*x/, ""); + } + k = pureExt.indexOf('.'); + if (k >= 0) { + pureExt = pureExt.substring(k + 1); + } + resource.extension = pureExt; + resource.loadType = resource._determineLoadType(); + next(); + return; + } + } + } + next(); + }; + } + pixi_compressed_textures.extensionChooser = extensionChooser; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + var ExtensionFixer = (function () { + function ExtensionFixer() { + } + ExtensionFixer.use = function (resource, next) { + if (resource.texture && resource._defaultUrlChoice && resource._defaultUrl !== resource.url) { + var texture = resource.texture; + var baseTexture = texture.baseTexture; + var oldUrl = resource.url; + var newUrl = resource._defaultUrlChoice; + var ind = baseTexture.textureCacheIds.indexOf(oldUrl); + if (ind >= 0) { + baseTexture.textureCacheIds[ind] = newUrl; + delete PIXI.utils.BaseTextureCache[resource.url]; + PIXI.utils.BaseTextureCache[newUrl] = baseTexture; + } + ind = texture.textureCacheIds.indexOf(oldUrl); + if (ind >= 0) { + texture.textureCacheIds[ind] = newUrl; + delete PIXI.utils.TextureCache[resource.url]; + PIXI.utils.TextureCache[newUrl] = baseTexture; + } + } + next(); + }; + return ExtensionFixer; + }()); + pixi_compressed_textures.ExtensionFixer = ExtensionFixer; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); +var pixi_compressed_textures; +(function (pixi_compressed_textures) { + PIXI.compressedTextures = pixi_compressed_textures; +})(pixi_compressed_textures || (pixi_compressed_textures = {})); /*! * pixi-filters - v3.0.3 @@ -49123,2058 +49123,2058 @@ this.PIXI = this.PIXI || {}; (function (exports, pixi) { 'use strict'; - /** - * A single node in a PropertyList. - */ - var PropertyNode = /** @class */ (function () { - /** - * @param value The value for this node - * @param time The time for this node, between 0-1 - * @param [ease] Custom ease for this list. Only relevant for the first node. - */ - function PropertyNode(value, time, ease) { - this.value = value; - this.time = time; - this.next = null; - this.isStepped = false; - if (ease) { - this.ease = typeof ease == "function" ? ease : exports.ParticleUtils.generateEase(ease); - } - else { - this.ease = null; - } - } - /** - * Creates a list of property values from a data object {list, isStepped} with a list of objects in - * the form {value, time}. Alternatively, the data object can be in the deprecated form of - * {start, end}. - * @param data The data for the list. - * @param data.list The array of value and time objects. - * @param data.isStepped If the list is stepped rather than interpolated. - * @param data.ease Custom ease for this list. - * @return The first node in the list - */ - PropertyNode.createList = function (data) { - if ("list" in data) { - var array = data.list; - var node = void 0, first = void 0; - var _a = array[0], value = _a.value, time = _a.time; - first = node = new PropertyNode(typeof value === 'string' ? exports.ParticleUtils.hexToRGB(value) : value, time, data.ease); - //only set up subsequent nodes if there are a bunch or the 2nd one is different from the first - if (array.length > 2 || (array.length === 2 && array[1].value !== value)) { - for (var i = 1; i < array.length; ++i) { - var _b = array[i], value_1 = _b.value, time_1 = _b.time; - node.next = new PropertyNode(typeof value_1 === 'string' ? exports.ParticleUtils.hexToRGB(value_1) : value_1, time_1); - node = node.next; - } - } - first.isStepped = !!data.isStepped; - return first; - } - else { - //Handle deprecated version here - var start = new PropertyNode(typeof data.start === 'string' ? exports.ParticleUtils.hexToRGB(data.start) : data.start, 0); - //only set up a next value if it is different from the starting value - if (data.end !== data.start) - start.next = new PropertyNode(typeof data.end === 'string' ? exports.ParticleUtils.hexToRGB(data.end) : data.end, 1); - return start; - } - }; - return PropertyNode; + /** + * A single node in a PropertyList. + */ + var PropertyNode = /** @class */ (function () { + /** + * @param value The value for this node + * @param time The time for this node, between 0-1 + * @param [ease] Custom ease for this list. Only relevant for the first node. + */ + function PropertyNode(value, time, ease) { + this.value = value; + this.time = time; + this.next = null; + this.isStepped = false; + if (ease) { + this.ease = typeof ease == "function" ? ease : exports.ParticleUtils.generateEase(ease); + } + else { + this.ease = null; + } + } + /** + * Creates a list of property values from a data object {list, isStepped} with a list of objects in + * the form {value, time}. Alternatively, the data object can be in the deprecated form of + * {start, end}. + * @param data The data for the list. + * @param data.list The array of value and time objects. + * @param data.isStepped If the list is stepped rather than interpolated. + * @param data.ease Custom ease for this list. + * @return The first node in the list + */ + PropertyNode.createList = function (data) { + if ("list" in data) { + var array = data.list; + var node = void 0, first = void 0; + var _a = array[0], value = _a.value, time = _a.time; + first = node = new PropertyNode(typeof value === 'string' ? exports.ParticleUtils.hexToRGB(value) : value, time, data.ease); + //only set up subsequent nodes if there are a bunch or the 2nd one is different from the first + if (array.length > 2 || (array.length === 2 && array[1].value !== value)) { + for (var i = 1; i < array.length; ++i) { + var _b = array[i], value_1 = _b.value, time_1 = _b.time; + node.next = new PropertyNode(typeof value_1 === 'string' ? exports.ParticleUtils.hexToRGB(value_1) : value_1, time_1); + node = node.next; + } + } + first.isStepped = !!data.isStepped; + return first; + } + else { + //Handle deprecated version here + var start = new PropertyNode(typeof data.start === 'string' ? exports.ParticleUtils.hexToRGB(data.start) : data.start, 0); + //only set up a next value if it is different from the starting value + if (data.end !== data.start) + start.next = new PropertyNode(typeof data.end === 'string' ? exports.ParticleUtils.hexToRGB(data.end) : data.end, 1); + return start; + } + }; + return PropertyNode; }()); - // get Texture.from()/Texture.fromImage(), in V4 and V5 friendly methods - /** - * @hidden - */ - var TextureFromString; - // to avoid Rollup transforming our import, save pixi namespace in a variable - var pixiNS = pixi; - if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { - TextureFromString = pixiNS.Texture.fromImage; - } - else { - TextureFromString = pixiNS.Texture.from; - } - function GetTextureFromString(s) { - return TextureFromString(s); - } - (function (ParticleUtils) { - /** - * If errors and warnings should be logged within the library. - */ - ParticleUtils.verbose = false; - ParticleUtils.DEG_TO_RADS = Math.PI / 180; - /** - * Rotates a point by a given angle. - * @param angle The angle to rotate by in degrees - * @param p The point to rotate around 0,0. - */ - function rotatePoint(angle, p) { - if (!angle) - return; - angle *= ParticleUtils.DEG_TO_RADS; - var s = Math.sin(angle); - var c = Math.cos(angle); - var xnew = p.x * c - p.y * s; - var ynew = p.x * s + p.y * c; - p.x = xnew; - p.y = ynew; - } - ParticleUtils.rotatePoint = rotatePoint; - /** - * Combines separate color components (0-255) into a single uint color. - * @param r The red value of the color - * @param g The green value of the color - * @param b The blue value of the color - * @return The color in the form of 0xRRGGBB - */ - function combineRGBComponents(r, g, b /*, a*/) { - return /*a << 24 |*/ r << 16 | g << 8 | b; - } - ParticleUtils.combineRGBComponents = combineRGBComponents; - /** - * Reduces the point to a length of 1. - * @param point The point to normalize - */ - function normalize(point) { - var oneOverLen = 1 / ParticleUtils.length(point); - point.x *= oneOverLen; - point.y *= oneOverLen; - } - ParticleUtils.normalize = normalize; - /** - * Multiplies the x and y values of this point by a value. - * @param point The point to scaleBy - * @param value The value to scale by. - */ - function scaleBy(point, value) { - point.x *= value; - point.y *= value; - } - ParticleUtils.scaleBy = scaleBy; - /** - * Returns the length (or magnitude) of this point. - * @param point The point to measure length - * @return The length of this point. - */ - function length(point) { - return Math.sqrt(point.x * point.x + point.y * point.y); - } - ParticleUtils.length = length; - /** - * Converts a hex string from "#AARRGGBB", "#RRGGBB", "0xAARRGGBB", "0xRRGGBB", - * "AARRGGBB", or "RRGGBB" to an object of ints of 0-255, as - * {r, g, b, (a)}. - * @param color The input color string. - * @param output An object to put the output in. If omitted, a new object is created. - * @return The object with r, g, and b properties, possibly with an a property. - */ - function hexToRGB(color, output) { - if (!output) - output = {}; - if (color.charAt(0) == "#") - color = color.substr(1); - else if (color.indexOf("0x") === 0) - color = color.substr(2); - var alpha; - if (color.length == 8) { - alpha = color.substr(0, 2); - color = color.substr(2); - } - output.r = parseInt(color.substr(0, 2), 16); //Red - output.g = parseInt(color.substr(2, 2), 16); //Green - output.b = parseInt(color.substr(4, 2), 16); //Blue - if (alpha) - output.a = parseInt(alpha, 16); - return output; - } - ParticleUtils.hexToRGB = hexToRGB; - /** - * Generates a custom ease function, based on the GreenSock custom ease, as demonstrated - * by the related tool at http://www.greensock.com/customease/. - * @param segments An array of segments, as created by - * http://www.greensock.com/customease/. - * @return A function that calculates the percentage of change at - * a given point in time (0-1 inclusive). - */ - function generateEase(segments) { - var qty = segments.length; - var oneOverQty = 1 / qty; - /* - * Calculates the percentage of change at a given point in time (0-1 inclusive). - * @param {Number} time The time of the ease, 0-1 inclusive. - * @return {Number} The percentage of the change, 0-1 inclusive (unless your - * ease goes outside those bounds). - */ - return function (time) { - var t, s; - var i = (qty * time) | 0; //do a quick floor operation - t = (time - (i * oneOverQty)) * qty; - s = segments[i] || segments[qty - 1]; - return (s.s + t * (2 * (1 - t) * (s.cp - s.s) + t * (s.e - s.s))); - }; - } - ParticleUtils.generateEase = generateEase; - /** - * Gets a blend mode, ensuring that it is valid. - * @param name The name of the blend mode to get. - * @return The blend mode as specified in the PIXI.BLEND_MODES enumeration. - */ - function getBlendMode(name) { - if (!name) - return pixi.BLEND_MODES.NORMAL; - name = name.toUpperCase(); - while (name.indexOf(" ") >= 0) - name = name.replace(" ", "_"); - return pixi.BLEND_MODES[name] || pixi.BLEND_MODES.NORMAL; - } - ParticleUtils.getBlendMode = getBlendMode; - /** - * Converts a list of {value, time} objects starting at time 0 and ending at time 1 into an evenly - * spaced stepped list of PropertyNodes for color values. This is primarily to handle conversion of - * linear gradients to fewer colors, allowing for some optimization for Canvas2d fallbacks. - * @param list The list of data to convert. - * @param [numSteps=10] The number of steps to use. - * @return The blend mode as specified in the PIXI.blendModes enumeration. - */ - function createSteppedGradient(list, numSteps) { - if (numSteps === void 0) { numSteps = 10; } - if (typeof numSteps !== 'number' || numSteps <= 0) - numSteps = 10; - var first = new PropertyNode(ParticleUtils.hexToRGB(list[0].value), list[0].time); - first.isStepped = true; - var currentNode = first; - var current = list[0]; - var nextIndex = 1; - var next = list[nextIndex]; - for (var i = 1; i < numSteps; ++i) { - var lerp = i / numSteps; - //ensure we are on the right segment, if multiple - while (lerp > next.time) { - current = next; - next = list[++nextIndex]; - } - //convert the lerp value to the segment range - lerp = (lerp - current.time) / (next.time - current.time); - var curVal = ParticleUtils.hexToRGB(current.value); - var nextVal = ParticleUtils.hexToRGB(next.value); - var output = { - r: (nextVal.r - curVal.r) * lerp + curVal.r, - g: (nextVal.g - curVal.g) * lerp + curVal.g, - b: (nextVal.b - curVal.b) * lerp + curVal.b, - }; - currentNode.next = new PropertyNode(output, i / numSteps); - currentNode = currentNode.next; - } - //we don't need to have a PropertyNode for time of 1, because in a stepped version at that point - //the particle has died of old age - return first; - } - ParticleUtils.createSteppedGradient = createSteppedGradient; + // get Texture.from()/Texture.fromImage(), in V4 and V5 friendly methods + /** + * @hidden + */ + var TextureFromString; + // to avoid Rollup transforming our import, save pixi namespace in a variable + var pixiNS = pixi; + if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { + TextureFromString = pixiNS.Texture.fromImage; + } + else { + TextureFromString = pixiNS.Texture.from; + } + function GetTextureFromString(s) { + return TextureFromString(s); + } + (function (ParticleUtils) { + /** + * If errors and warnings should be logged within the library. + */ + ParticleUtils.verbose = false; + ParticleUtils.DEG_TO_RADS = Math.PI / 180; + /** + * Rotates a point by a given angle. + * @param angle The angle to rotate by in degrees + * @param p The point to rotate around 0,0. + */ + function rotatePoint(angle, p) { + if (!angle) + return; + angle *= ParticleUtils.DEG_TO_RADS; + var s = Math.sin(angle); + var c = Math.cos(angle); + var xnew = p.x * c - p.y * s; + var ynew = p.x * s + p.y * c; + p.x = xnew; + p.y = ynew; + } + ParticleUtils.rotatePoint = rotatePoint; + /** + * Combines separate color components (0-255) into a single uint color. + * @param r The red value of the color + * @param g The green value of the color + * @param b The blue value of the color + * @return The color in the form of 0xRRGGBB + */ + function combineRGBComponents(r, g, b /*, a*/) { + return /*a << 24 |*/ r << 16 | g << 8 | b; + } + ParticleUtils.combineRGBComponents = combineRGBComponents; + /** + * Reduces the point to a length of 1. + * @param point The point to normalize + */ + function normalize(point) { + var oneOverLen = 1 / ParticleUtils.length(point); + point.x *= oneOverLen; + point.y *= oneOverLen; + } + ParticleUtils.normalize = normalize; + /** + * Multiplies the x and y values of this point by a value. + * @param point The point to scaleBy + * @param value The value to scale by. + */ + function scaleBy(point, value) { + point.x *= value; + point.y *= value; + } + ParticleUtils.scaleBy = scaleBy; + /** + * Returns the length (or magnitude) of this point. + * @param point The point to measure length + * @return The length of this point. + */ + function length(point) { + return Math.sqrt(point.x * point.x + point.y * point.y); + } + ParticleUtils.length = length; + /** + * Converts a hex string from "#AARRGGBB", "#RRGGBB", "0xAARRGGBB", "0xRRGGBB", + * "AARRGGBB", or "RRGGBB" to an object of ints of 0-255, as + * {r, g, b, (a)}. + * @param color The input color string. + * @param output An object to put the output in. If omitted, a new object is created. + * @return The object with r, g, and b properties, possibly with an a property. + */ + function hexToRGB(color, output) { + if (!output) + output = {}; + if (color.charAt(0) == "#") + color = color.substr(1); + else if (color.indexOf("0x") === 0) + color = color.substr(2); + var alpha; + if (color.length == 8) { + alpha = color.substr(0, 2); + color = color.substr(2); + } + output.r = parseInt(color.substr(0, 2), 16); //Red + output.g = parseInt(color.substr(2, 2), 16); //Green + output.b = parseInt(color.substr(4, 2), 16); //Blue + if (alpha) + output.a = parseInt(alpha, 16); + return output; + } + ParticleUtils.hexToRGB = hexToRGB; + /** + * Generates a custom ease function, based on the GreenSock custom ease, as demonstrated + * by the related tool at http://www.greensock.com/customease/. + * @param segments An array of segments, as created by + * http://www.greensock.com/customease/. + * @return A function that calculates the percentage of change at + * a given point in time (0-1 inclusive). + */ + function generateEase(segments) { + var qty = segments.length; + var oneOverQty = 1 / qty; + /* + * Calculates the percentage of change at a given point in time (0-1 inclusive). + * @param {Number} time The time of the ease, 0-1 inclusive. + * @return {Number} The percentage of the change, 0-1 inclusive (unless your + * ease goes outside those bounds). + */ + return function (time) { + var t, s; + var i = (qty * time) | 0; //do a quick floor operation + t = (time - (i * oneOverQty)) * qty; + s = segments[i] || segments[qty - 1]; + return (s.s + t * (2 * (1 - t) * (s.cp - s.s) + t * (s.e - s.s))); + }; + } + ParticleUtils.generateEase = generateEase; + /** + * Gets a blend mode, ensuring that it is valid. + * @param name The name of the blend mode to get. + * @return The blend mode as specified in the PIXI.BLEND_MODES enumeration. + */ + function getBlendMode(name) { + if (!name) + return pixi.BLEND_MODES.NORMAL; + name = name.toUpperCase(); + while (name.indexOf(" ") >= 0) + name = name.replace(" ", "_"); + return pixi.BLEND_MODES[name] || pixi.BLEND_MODES.NORMAL; + } + ParticleUtils.getBlendMode = getBlendMode; + /** + * Converts a list of {value, time} objects starting at time 0 and ending at time 1 into an evenly + * spaced stepped list of PropertyNodes for color values. This is primarily to handle conversion of + * linear gradients to fewer colors, allowing for some optimization for Canvas2d fallbacks. + * @param list The list of data to convert. + * @param [numSteps=10] The number of steps to use. + * @return The blend mode as specified in the PIXI.blendModes enumeration. + */ + function createSteppedGradient(list, numSteps) { + if (numSteps === void 0) { numSteps = 10; } + if (typeof numSteps !== 'number' || numSteps <= 0) + numSteps = 10; + var first = new PropertyNode(ParticleUtils.hexToRGB(list[0].value), list[0].time); + first.isStepped = true; + var currentNode = first; + var current = list[0]; + var nextIndex = 1; + var next = list[nextIndex]; + for (var i = 1; i < numSteps; ++i) { + var lerp = i / numSteps; + //ensure we are on the right segment, if multiple + while (lerp > next.time) { + current = next; + next = list[++nextIndex]; + } + //convert the lerp value to the segment range + lerp = (lerp - current.time) / (next.time - current.time); + var curVal = ParticleUtils.hexToRGB(current.value); + var nextVal = ParticleUtils.hexToRGB(next.value); + var output = { + r: (nextVal.r - curVal.r) * lerp + curVal.r, + g: (nextVal.g - curVal.g) * lerp + curVal.g, + b: (nextVal.b - curVal.b) * lerp + curVal.b, + }; + currentNode.next = new PropertyNode(output, i / numSteps); + currentNode = currentNode.next; + } + //we don't need to have a PropertyNode for time of 1, because in a stepped version at that point + //the particle has died of old age + return first; + } + ParticleUtils.createSteppedGradient = createSteppedGradient; })(exports.ParticleUtils || (exports.ParticleUtils = {})); - /*! ***************************************************************************** - Copyright (c) Microsoft Corporation. All rights reserved. - Licensed under the Apache License, Version 2.0 (the "License"); you may not use - this file except in compliance with the License. You may obtain a copy of the - License at http://www.apache.org/licenses/LICENSE-2.0 - - THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED - WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, - MERCHANTABLITY OR NON-INFRINGEMENT. - - See the Apache Version 2.0 License for specific language governing permissions - and limitations under the License. - ***************************************************************************** */ - /* global Reflect, Promise */ - - var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - - function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - } - - var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - - function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; - } - - function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - } - - function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - } - - function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - } - - function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - } - - function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - } - - function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - } - - function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - } - - function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; - } - - function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - } - - function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - } - - function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - } - - function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - } - - function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - } - - function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; - } - - function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + /* global Reflect, Promise */ + + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + + function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } - /** - * Singly linked list container for keeping track of interpolated properties for particles. - * Each Particle will have one of these for each interpolated property. - */ - var PropertyList = /** @class */ (function () { - /** - * @param isColor If this list handles color values - */ - function PropertyList(isColor) { - if (isColor === void 0) { isColor = false; } - this.current = null; - this.next = null; - this.isColor = !!isColor; - this.interpolate = null; - this.ease = null; - } - /** - * Resets the list for use. - * @param first The first node in the list. - * @param first.isStepped If the values should be stepped instead of interpolated linearly. - */ - PropertyList.prototype.reset = function (first) { - this.current = first; - this.next = first.next; - var isSimple = this.next && this.next.time >= 1; - if (isSimple) { - this.interpolate = this.isColor ? intColorSimple : intValueSimple; - } - else if (first.isStepped) { - this.interpolate = this.isColor ? intColorStepped : intValueStepped; - } - else { - this.interpolate = this.isColor ? intColorComplex : intValueComplex; - } - this.ease = this.current.ease; - }; - return PropertyList; - }()); - function intValueSimple(lerp) { - if (this.ease) - lerp = this.ease(lerp); - return (this.next.value - this.current.value) * lerp + this.current.value; - } - function intColorSimple(lerp) { - if (this.ease) - lerp = this.ease(lerp); - var curVal = this.current.value, nextVal = this.next.value; - var r = (nextVal.r - curVal.r) * lerp + curVal.r; - var g = (nextVal.g - curVal.g) * lerp + curVal.g; - var b = (nextVal.b - curVal.b) * lerp + curVal.b; - return exports.ParticleUtils.combineRGBComponents(r, g, b); - } - function intValueComplex(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - //convert the lerp value to the segment range - lerp = (lerp - this.current.time) / (this.next.time - this.current.time); - return (this.next.value - this.current.value) * lerp + this.current.value; - } - function intColorComplex(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - //convert the lerp value to the segment range - lerp = (lerp - this.current.time) / (this.next.time - this.current.time); - var curVal = this.current.value, nextVal = this.next.value; - var r = (nextVal.r - curVal.r) * lerp + curVal.r; - var g = (nextVal.g - curVal.g) * lerp + curVal.g; - var b = (nextVal.b - curVal.b) * lerp + curVal.b; - return exports.ParticleUtils.combineRGBComponents(r, g, b); - } - function intValueStepped(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (this.next && lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - return this.current.value; - } - function intColorStepped(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (this.next && lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - var curVal = this.current.value; - return exports.ParticleUtils.combineRGBComponents(curVal.r, curVal.g, curVal.b); + var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + + function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; } - /** - * An individual particle image. You shouldn't have to deal with these. - */ - var Particle = /** @class */ (function (_super) { - __extends(Particle, _super); - /** - * @param {PIXI.particles.Emitter} emitter The emitter that controls this particle. - */ - function Particle(emitter) { - var _this = - //start off the sprite with a blank texture, since we are going to replace it - //later when the particle is initialized. - _super.call(this) || this; - _this.emitter = emitter; - //particles should be centered - _this.anchor.x = _this.anchor.y = 0.5; - _this.velocity = new pixi.Point(); - _this.rotationSpeed = 0; - _this.rotationAcceleration = 0; - _this.maxLife = 0; - _this.age = 0; - _this.ease = null; - _this.extraData = null; - _this.alphaList = new PropertyList(); - _this.speedList = new PropertyList(); - _this.speedMultiplier = 1; - _this.acceleration = new pixi.Point(); - _this.maxSpeed = NaN; - _this.scaleList = new PropertyList(); - _this.scaleMultiplier = 1; - _this.colorList = new PropertyList(true); - _this._doAlpha = false; - _this._doScale = false; - _this._doSpeed = false; - _this._doAcceleration = false; - _this._doColor = false; - _this._doNormalMovement = false; - _this._oneOverLife = 0; - _this.next = null; - _this.prev = null; - //save often used functions on the instance instead of the prototype for better speed - _this.init = _this.init; - _this.Particle_init = Particle.prototype.init; - _this.update = _this.update; - _this.Particle_update = Particle.prototype.update; - _this.Sprite_destroy = _super.prototype.destroy; - _this.Particle_destroy = Particle.prototype.destroy; - _this.applyArt = _this.applyArt; - _this.kill = _this.kill; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - Particle.prototype.init = function () { - //reset the age - this.age = 0; - //set up the velocity based on the start speed and rotation - this.velocity.x = this.speedList.current.value * this.speedMultiplier; - this.velocity.y = 0; - exports.ParticleUtils.rotatePoint(this.rotation, this.velocity); - if (this.noRotation) { - this.rotation = 0; - } - else { - //convert rotation to Radians from Degrees - this.rotation *= exports.ParticleUtils.DEG_TO_RADS; - } - //convert rotation speed to Radians from Degrees - this.rotationSpeed *= exports.ParticleUtils.DEG_TO_RADS; - this.rotationAcceleration *= exports.ParticleUtils.DEG_TO_RADS; - //set alpha to inital alpha - this.alpha = this.alphaList.current.value; - //set scale to initial scale - this.scale.x = this.scale.y = this.scaleList.current.value; - //figure out what we need to interpolate - this._doAlpha = !!this.alphaList.current.next; - this._doSpeed = !!this.speedList.current.next; - this._doScale = !!this.scaleList.current.next; - this._doColor = !!this.colorList.current.next; - this._doAcceleration = this.acceleration.x !== 0 || this.acceleration.y !== 0; - //_doNormalMovement can be cancelled by subclasses - this._doNormalMovement = this._doSpeed || this.speedList.current.value !== 0 || this._doAcceleration; - //save our lerp helper - this._oneOverLife = 1 / this.maxLife; - //set the inital color - var color = this.colorList.current.value; - this.tint = exports.ParticleUtils.combineRGBComponents(color.r, color.g, color.b); - //ensure visibility - this.visible = true; - }; - /** - * Sets the texture for the particle. This can be overridden to allow - * for an animated particle. - * @param art The texture to set. - */ - Particle.prototype.applyArt = function (art) { - this.texture = art || pixi.Texture.EMPTY; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - * @return The standard interpolation multiplier (0-1) used for all - * relevant particle properties. A value of -1 means the particle - * died of old age instead. - */ - Particle.prototype.update = function (delta) { - //increase age - this.age += delta; - //recycle particle if it is too old - if (this.age >= this.maxLife || this.age < 0) { - this.kill(); - return -1; - } - //determine our interpolation value - var lerp = this.age * this._oneOverLife; //lifetime / maxLife; - if (this.ease) { - if (this.ease.length == 4) { - //the t, b, c, d parameters that some tween libraries use - //(time, initial value, end value, duration) - lerp = this.ease(lerp, 0, 1, 1); - } - else { - //the simplified version that we like that takes - //one parameter, time from 0-1. TweenJS eases provide this usage. - lerp = this.ease(lerp); - } - } - //interpolate alpha - if (this._doAlpha) - this.alpha = this.alphaList.interpolate(lerp); - //interpolate scale - if (this._doScale) { - var scale = this.scaleList.interpolate(lerp) * this.scaleMultiplier; - this.scale.x = this.scale.y = scale; - } - //handle movement - if (this._doNormalMovement) { - var deltaX = void 0; - var deltaY = void 0; - //interpolate speed - if (this._doSpeed) { - var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; - exports.ParticleUtils.normalize(this.velocity); - exports.ParticleUtils.scaleBy(this.velocity, speed); - deltaX = this.velocity.x * delta; - deltaY = this.velocity.y * delta; - } - else if (this._doAcceleration) { - var oldVX = this.velocity.x; - var oldVY = this.velocity.y; - this.velocity.x += this.acceleration.x * delta; - this.velocity.y += this.acceleration.y * delta; - if (this.maxSpeed) { - var currentSpeed = exports.ParticleUtils.length(this.velocity); - //if we are going faster than we should, clamp at the max speed - //DO NOT recalculate vector length - if (currentSpeed > this.maxSpeed) { - exports.ParticleUtils.scaleBy(this.velocity, this.maxSpeed / currentSpeed); - } - } - // calculate position delta by the midpoint between our old velocity and our new velocity - deltaX = (oldVX + this.velocity.x) / 2 * delta; - deltaY = (oldVY + this.velocity.y) / 2 * delta; - } - else { - deltaX = this.velocity.x * delta; - deltaY = this.velocity.y * delta; - } - //adjust position based on velocity - this.position.x += deltaX; - this.position.y += deltaY; - } - //interpolate color - if (this._doColor) { - this.tint = this.colorList.interpolate(lerp); - } - //update rotation - if (this.rotationAcceleration !== 0) { - var newRotationSpeed = this.rotationSpeed + this.rotationAcceleration * delta; - this.rotation += (this.rotationSpeed + newRotationSpeed) / 2 * delta; - this.rotationSpeed = newRotationSpeed; - } - else if (this.rotationSpeed !== 0) { - this.rotation += this.rotationSpeed * delta; - } - else if (this.acceleration && !this.noRotation) { - this.rotation = Math.atan2(this.velocity.y, this.velocity.x); // + Math.PI / 2; - } - return lerp; - }; - /** - * Kills the particle, removing it from the display list - * and telling the emitter to recycle it. - */ - Particle.prototype.kill = function () { - this.emitter.recycle(this); - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - Particle.prototype.destroy = function () { - if (this.parent) - this.parent.removeChild(this); - this.Sprite_destroy(); - this.emitter = this.velocity = this.colorList = this.scaleList = this.alphaList = - this.speedList = this.ease = this.next = this.prev = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. - * @param art The array of art data. For Particle, it should be an array of - * Textures. Any strings in the array will be converted to - * Textures via Texture.from(). - * @return The art, after any needed modifications. - */ - Particle.parseArt = function (art) { - //convert any strings to Textures. - var i; - for (i = art.length; i >= 0; --i) { - if (typeof art[i] == "string") - art[i] = GetTextureFromString(art[i]); - } - //particles from different base textures will be slower in WebGL than if they - //were from one spritesheet - if (exports.ParticleUtils.verbose) { - for (i = art.length - 1; i > 0; --i) { - if (art[i].baseTexture != art[i - 1].baseTexture) { - if (window.console) - console.warn("PixiParticles: using particle textures from different images may hinder performance in WebGL"); - break; - } - } - } - return art; - }; - /** - * Parses extra emitter data to ensure it is set up for this particle class. - * Particle does nothing to the extra data. - * @param extraData The extra data from the particle config. - * @return The parsed extra data. - */ - Particle.parseData = function (extraData) { - return extraData; - }; - return Particle; + function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + } + + function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + } + + function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + } + + function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + } + + function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + } + + function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + + function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + } + + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + + function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + } + + function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + } + + function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + } + + function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + } + + function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + } + + function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result.default = mod; + return result; + } + + function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; + } + + /** + * Singly linked list container for keeping track of interpolated properties for particles. + * Each Particle will have one of these for each interpolated property. + */ + var PropertyList = /** @class */ (function () { + /** + * @param isColor If this list handles color values + */ + function PropertyList(isColor) { + if (isColor === void 0) { isColor = false; } + this.current = null; + this.next = null; + this.isColor = !!isColor; + this.interpolate = null; + this.ease = null; + } + /** + * Resets the list for use. + * @param first The first node in the list. + * @param first.isStepped If the values should be stepped instead of interpolated linearly. + */ + PropertyList.prototype.reset = function (first) { + this.current = first; + this.next = first.next; + var isSimple = this.next && this.next.time >= 1; + if (isSimple) { + this.interpolate = this.isColor ? intColorSimple : intValueSimple; + } + else if (first.isStepped) { + this.interpolate = this.isColor ? intColorStepped : intValueStepped; + } + else { + this.interpolate = this.isColor ? intColorComplex : intValueComplex; + } + this.ease = this.current.ease; + }; + return PropertyList; + }()); + function intValueSimple(lerp) { + if (this.ease) + lerp = this.ease(lerp); + return (this.next.value - this.current.value) * lerp + this.current.value; + } + function intColorSimple(lerp) { + if (this.ease) + lerp = this.ease(lerp); + var curVal = this.current.value, nextVal = this.next.value; + var r = (nextVal.r - curVal.r) * lerp + curVal.r; + var g = (nextVal.g - curVal.g) * lerp + curVal.g; + var b = (nextVal.b - curVal.b) * lerp + curVal.b; + return exports.ParticleUtils.combineRGBComponents(r, g, b); + } + function intValueComplex(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + //convert the lerp value to the segment range + lerp = (lerp - this.current.time) / (this.next.time - this.current.time); + return (this.next.value - this.current.value) * lerp + this.current.value; + } + function intColorComplex(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + //convert the lerp value to the segment range + lerp = (lerp - this.current.time) / (this.next.time - this.current.time); + var curVal = this.current.value, nextVal = this.next.value; + var r = (nextVal.r - curVal.r) * lerp + curVal.r; + var g = (nextVal.g - curVal.g) * lerp + curVal.g; + var b = (nextVal.b - curVal.b) * lerp + curVal.b; + return exports.ParticleUtils.combineRGBComponents(r, g, b); + } + function intValueStepped(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (this.next && lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + return this.current.value; + } + function intColorStepped(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (this.next && lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + var curVal = this.current.value; + return exports.ParticleUtils.combineRGBComponents(curVal.r, curVal.g, curVal.b); + } + + /** + * An individual particle image. You shouldn't have to deal with these. + */ + var Particle = /** @class */ (function (_super) { + __extends(Particle, _super); + /** + * @param {PIXI.particles.Emitter} emitter The emitter that controls this particle. + */ + function Particle(emitter) { + var _this = + //start off the sprite with a blank texture, since we are going to replace it + //later when the particle is initialized. + _super.call(this) || this; + _this.emitter = emitter; + //particles should be centered + _this.anchor.x = _this.anchor.y = 0.5; + _this.velocity = new pixi.Point(); + _this.rotationSpeed = 0; + _this.rotationAcceleration = 0; + _this.maxLife = 0; + _this.age = 0; + _this.ease = null; + _this.extraData = null; + _this.alphaList = new PropertyList(); + _this.speedList = new PropertyList(); + _this.speedMultiplier = 1; + _this.acceleration = new pixi.Point(); + _this.maxSpeed = NaN; + _this.scaleList = new PropertyList(); + _this.scaleMultiplier = 1; + _this.colorList = new PropertyList(true); + _this._doAlpha = false; + _this._doScale = false; + _this._doSpeed = false; + _this._doAcceleration = false; + _this._doColor = false; + _this._doNormalMovement = false; + _this._oneOverLife = 0; + _this.next = null; + _this.prev = null; + //save often used functions on the instance instead of the prototype for better speed + _this.init = _this.init; + _this.Particle_init = Particle.prototype.init; + _this.update = _this.update; + _this.Particle_update = Particle.prototype.update; + _this.Sprite_destroy = _super.prototype.destroy; + _this.Particle_destroy = Particle.prototype.destroy; + _this.applyArt = _this.applyArt; + _this.kill = _this.kill; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + Particle.prototype.init = function () { + //reset the age + this.age = 0; + //set up the velocity based on the start speed and rotation + this.velocity.x = this.speedList.current.value * this.speedMultiplier; + this.velocity.y = 0; + exports.ParticleUtils.rotatePoint(this.rotation, this.velocity); + if (this.noRotation) { + this.rotation = 0; + } + else { + //convert rotation to Radians from Degrees + this.rotation *= exports.ParticleUtils.DEG_TO_RADS; + } + //convert rotation speed to Radians from Degrees + this.rotationSpeed *= exports.ParticleUtils.DEG_TO_RADS; + this.rotationAcceleration *= exports.ParticleUtils.DEG_TO_RADS; + //set alpha to inital alpha + this.alpha = this.alphaList.current.value; + //set scale to initial scale + this.scale.x = this.scale.y = this.scaleList.current.value; + //figure out what we need to interpolate + this._doAlpha = !!this.alphaList.current.next; + this._doSpeed = !!this.speedList.current.next; + this._doScale = !!this.scaleList.current.next; + this._doColor = !!this.colorList.current.next; + this._doAcceleration = this.acceleration.x !== 0 || this.acceleration.y !== 0; + //_doNormalMovement can be cancelled by subclasses + this._doNormalMovement = this._doSpeed || this.speedList.current.value !== 0 || this._doAcceleration; + //save our lerp helper + this._oneOverLife = 1 / this.maxLife; + //set the inital color + var color = this.colorList.current.value; + this.tint = exports.ParticleUtils.combineRGBComponents(color.r, color.g, color.b); + //ensure visibility + this.visible = true; + }; + /** + * Sets the texture for the particle. This can be overridden to allow + * for an animated particle. + * @param art The texture to set. + */ + Particle.prototype.applyArt = function (art) { + this.texture = art || pixi.Texture.EMPTY; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + * @return The standard interpolation multiplier (0-1) used for all + * relevant particle properties. A value of -1 means the particle + * died of old age instead. + */ + Particle.prototype.update = function (delta) { + //increase age + this.age += delta; + //recycle particle if it is too old + if (this.age >= this.maxLife || this.age < 0) { + this.kill(); + return -1; + } + //determine our interpolation value + var lerp = this.age * this._oneOverLife; //lifetime / maxLife; + if (this.ease) { + if (this.ease.length == 4) { + //the t, b, c, d parameters that some tween libraries use + //(time, initial value, end value, duration) + lerp = this.ease(lerp, 0, 1, 1); + } + else { + //the simplified version that we like that takes + //one parameter, time from 0-1. TweenJS eases provide this usage. + lerp = this.ease(lerp); + } + } + //interpolate alpha + if (this._doAlpha) + this.alpha = this.alphaList.interpolate(lerp); + //interpolate scale + if (this._doScale) { + var scale = this.scaleList.interpolate(lerp) * this.scaleMultiplier; + this.scale.x = this.scale.y = scale; + } + //handle movement + if (this._doNormalMovement) { + var deltaX = void 0; + var deltaY = void 0; + //interpolate speed + if (this._doSpeed) { + var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; + exports.ParticleUtils.normalize(this.velocity); + exports.ParticleUtils.scaleBy(this.velocity, speed); + deltaX = this.velocity.x * delta; + deltaY = this.velocity.y * delta; + } + else if (this._doAcceleration) { + var oldVX = this.velocity.x; + var oldVY = this.velocity.y; + this.velocity.x += this.acceleration.x * delta; + this.velocity.y += this.acceleration.y * delta; + if (this.maxSpeed) { + var currentSpeed = exports.ParticleUtils.length(this.velocity); + //if we are going faster than we should, clamp at the max speed + //DO NOT recalculate vector length + if (currentSpeed > this.maxSpeed) { + exports.ParticleUtils.scaleBy(this.velocity, this.maxSpeed / currentSpeed); + } + } + // calculate position delta by the midpoint between our old velocity and our new velocity + deltaX = (oldVX + this.velocity.x) / 2 * delta; + deltaY = (oldVY + this.velocity.y) / 2 * delta; + } + else { + deltaX = this.velocity.x * delta; + deltaY = this.velocity.y * delta; + } + //adjust position based on velocity + this.position.x += deltaX; + this.position.y += deltaY; + } + //interpolate color + if (this._doColor) { + this.tint = this.colorList.interpolate(lerp); + } + //update rotation + if (this.rotationAcceleration !== 0) { + var newRotationSpeed = this.rotationSpeed + this.rotationAcceleration * delta; + this.rotation += (this.rotationSpeed + newRotationSpeed) / 2 * delta; + this.rotationSpeed = newRotationSpeed; + } + else if (this.rotationSpeed !== 0) { + this.rotation += this.rotationSpeed * delta; + } + else if (this.acceleration && !this.noRotation) { + this.rotation = Math.atan2(this.velocity.y, this.velocity.x); // + Math.PI / 2; + } + return lerp; + }; + /** + * Kills the particle, removing it from the display list + * and telling the emitter to recycle it. + */ + Particle.prototype.kill = function () { + this.emitter.recycle(this); + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + Particle.prototype.destroy = function () { + if (this.parent) + this.parent.removeChild(this); + this.Sprite_destroy(); + this.emitter = this.velocity = this.colorList = this.scaleList = this.alphaList = + this.speedList = this.ease = this.next = this.prev = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. + * @param art The array of art data. For Particle, it should be an array of + * Textures. Any strings in the array will be converted to + * Textures via Texture.from(). + * @return The art, after any needed modifications. + */ + Particle.parseArt = function (art) { + //convert any strings to Textures. + var i; + for (i = art.length; i >= 0; --i) { + if (typeof art[i] == "string") + art[i] = GetTextureFromString(art[i]); + } + //particles from different base textures will be slower in WebGL than if they + //were from one spritesheet + if (exports.ParticleUtils.verbose) { + for (i = art.length - 1; i > 0; --i) { + if (art[i].baseTexture != art[i - 1].baseTexture) { + if (window.console) + console.warn("PixiParticles: using particle textures from different images may hinder performance in WebGL"); + break; + } + } + } + return art; + }; + /** + * Parses extra emitter data to ensure it is set up for this particle class. + * Particle does nothing to the extra data. + * @param extraData The extra data from the particle config. + * @return The parsed extra data. + */ + Particle.parseData = function (extraData) { + return extraData; + }; + return Particle; }(pixi.Sprite)); - /** - * Chain of line segments for generating spawn positions. - */ - var PolygonalChain = /** @class */ (function () { - /** - * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. - */ - function PolygonalChain(data) { - this.segments = []; - this.countingLengths = []; - this.totalLength = 0; - this.init(data); - } - /** - * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. - */ - PolygonalChain.prototype.init = function (data) { - // if data is not present, set up a segment of length 0 - if (!data || !data.length) { - this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 }); - } - else { - if (Array.isArray(data[0])) { - // list of segment chains, each defined as a list of points - for (var i = 0; i < data.length; ++i) { - // loop through the chain, connecting points - var chain = data[i]; - var prevPoint = chain[0]; - for (var j = 1; j < chain.length; ++j) { - var second = chain[j]; - this.segments.push({ p1: prevPoint, p2: second, l: 0 }); - prevPoint = second; - } - } - } - else { - var prevPoint = data[0]; - // list of points - for (var i = 1; i < data.length; ++i) { - var second = data[i]; - this.segments.push({ p1: prevPoint, p2: second, l: 0 }); - prevPoint = second; - } - } - } - // now go through our segments to calculate the lengths so that we - // can set up a nice weighted random distribution - for (var i = 0; i < this.segments.length; ++i) { - var _a = this.segments[i], p1 = _a.p1, p2 = _a.p2; - var segLength = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)); - // save length so we can turn a random number into a 0-1 interpolation value later - this.segments[i].l = segLength; - this.totalLength += segLength; - // keep track of the length so far, counting up - this.countingLengths.push(this.totalLength); - } - }; - /** - * Gets a random point in the chain. - * @param out The point to store the selected position in. - */ - PolygonalChain.prototype.getRandomPoint = function (out) { - // select a random spot in the length of the chain - var rand = Math.random() * this.totalLength; - var chosenSeg; - var lerp; - // if only one segment, it wins - if (this.segments.length === 1) { - chosenSeg = this.segments[0]; - lerp = rand; - } - else { - // otherwise, go through countingLengths until we have determined - // which segment we chose - for (var i = 0; i < this.countingLengths.length; ++i) { - if (rand < this.countingLengths[i]) { - chosenSeg = this.segments[i]; - // set lerp equal to the length into that segment (i.e. the remainder after subtracting all the segments before it) - lerp = i === 0 ? rand : rand - this.countingLengths[i - 1]; - break; - } - } - } - // divide lerp by the segment length, to result in a 0-1 number. - lerp /= chosenSeg.l || 1; - var p1 = chosenSeg.p1, p2 = chosenSeg.p2; - // now calculate the position in the segment that the lerp value represents - out.x = p1.x + lerp * (p2.x - p1.x); - out.y = p1.y + lerp * (p2.y - p1.y); - }; - return PolygonalChain; + /** + * Chain of line segments for generating spawn positions. + */ + var PolygonalChain = /** @class */ (function () { + /** + * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. + */ + function PolygonalChain(data) { + this.segments = []; + this.countingLengths = []; + this.totalLength = 0; + this.init(data); + } + /** + * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. + */ + PolygonalChain.prototype.init = function (data) { + // if data is not present, set up a segment of length 0 + if (!data || !data.length) { + this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 }); + } + else { + if (Array.isArray(data[0])) { + // list of segment chains, each defined as a list of points + for (var i = 0; i < data.length; ++i) { + // loop through the chain, connecting points + var chain = data[i]; + var prevPoint = chain[0]; + for (var j = 1; j < chain.length; ++j) { + var second = chain[j]; + this.segments.push({ p1: prevPoint, p2: second, l: 0 }); + prevPoint = second; + } + } + } + else { + var prevPoint = data[0]; + // list of points + for (var i = 1; i < data.length; ++i) { + var second = data[i]; + this.segments.push({ p1: prevPoint, p2: second, l: 0 }); + prevPoint = second; + } + } + } + // now go through our segments to calculate the lengths so that we + // can set up a nice weighted random distribution + for (var i = 0; i < this.segments.length; ++i) { + var _a = this.segments[i], p1 = _a.p1, p2 = _a.p2; + var segLength = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)); + // save length so we can turn a random number into a 0-1 interpolation value later + this.segments[i].l = segLength; + this.totalLength += segLength; + // keep track of the length so far, counting up + this.countingLengths.push(this.totalLength); + } + }; + /** + * Gets a random point in the chain. + * @param out The point to store the selected position in. + */ + PolygonalChain.prototype.getRandomPoint = function (out) { + // select a random spot in the length of the chain + var rand = Math.random() * this.totalLength; + var chosenSeg; + var lerp; + // if only one segment, it wins + if (this.segments.length === 1) { + chosenSeg = this.segments[0]; + lerp = rand; + } + else { + // otherwise, go through countingLengths until we have determined + // which segment we chose + for (var i = 0; i < this.countingLengths.length; ++i) { + if (rand < this.countingLengths[i]) { + chosenSeg = this.segments[i]; + // set lerp equal to the length into that segment (i.e. the remainder after subtracting all the segments before it) + lerp = i === 0 ? rand : rand - this.countingLengths[i - 1]; + break; + } + } + } + // divide lerp by the segment length, to result in a 0-1 number. + lerp /= chosenSeg.l || 1; + var p1 = chosenSeg.p1, p2 = chosenSeg.p2; + // now calculate the position in the segment that the lerp value represents + out.x = p1.x + lerp * (p2.x - p1.x); + out.y = p1.y + lerp * (p2.y - p1.y); + }; + return PolygonalChain; }()); - // get the shared ticker, in V4 and V5 friendly methods - /** - * @hidden - */ - var ticker; - // to avoid Rollup transforming our import, save pixi namespace in a variable - var pixiNS$1 = pixi; - if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { - ticker = pixiNS$1.ticker.shared; - } - else { - ticker = pixiNS$1.Ticker.shared; - } - /** - * @hidden - */ - var helperPoint = new pixi.Point(); - /** - * A particle emitter. - */ - var Emitter = /** @class */ (function () { - /** - * @param particleParent The container to add the particles to. - * @param particleImages A texture or array of textures to use - * for the particles. Strings will be turned - * into textures via Texture.fromImage(). - * @param config A configuration object containing settings for the emitter. - * @param config.emit If config.emit is explicitly passed as false, the - * Emitter will start disabled. - * @param config.autoUpdate If config.autoUpdate is explicitly passed as - * true, the Emitter will automatically call - * update via the PIXI shared ticker. - */ - function Emitter(particleParent, particleImages, config) { - this._particleConstructor = Particle; - //properties for individual particles - this.particleImages = null; - this.startAlpha = null; - this.startSpeed = null; - this.minimumSpeedMultiplier = 1; - this.acceleration = null; - this.maxSpeed = NaN; - this.startScale = null; - this.minimumScaleMultiplier = 1; - this.startColor = null; - this.minLifetime = 0; - this.maxLifetime = 0; - this.minStartRotation = 0; - this.maxStartRotation = 0; - this.noRotation = false; - this.minRotationSpeed = 0; - this.maxRotationSpeed = 0; - this.particleBlendMode = 0; - this.customEase = null; - this.extraData = null; - //properties for spawning particles - this._frequency = 1; - this.spawnChance = 1; - this.maxParticles = 1000; - this.emitterLifetime = -1; - this.spawnPos = null; - this.spawnType = null; - this._spawnFunc = null; - this.spawnRect = null; - this.spawnCircle = null; - this.spawnPolygonalChain = null; - this.particlesPerWave = 1; - this.particleSpacing = 0; - this.angleStart = 0; - //emitter properties - this.rotation = 0; - this.ownerPos = null; - this._prevEmitterPos = null; - this._prevPosIsValid = false; - this._posChanged = false; - this._parent = null; - this.addAtBack = false; - this.particleCount = 0; - this._emit = false; - this._spawnTimer = 0; - this._emitterLife = -1; - this._activeParticlesFirst = null; - this._activeParticlesLast = null; - this._poolFirst = null; - this._origConfig = null; - this._origArt = null; - this._autoUpdate = false; - this._destroyWhenComplete = false; - this._completeCallback = null; - //set the initial parent - this.parent = particleParent; - if (particleImages && config) - this.init(particleImages, config); - //save often used functions on the instance instead of the prototype for better speed - this.recycle = this.recycle; - this.update = this.update; - this.rotate = this.rotate; - this.updateSpawnPos = this.updateSpawnPos; - this.updateOwnerPos = this.updateOwnerPos; - } - Object.defineProperty(Emitter.prototype, "frequency", { - /** - * Time between particle spawns in seconds. If this value is not a number greater than 0, - * it will be set to 1 (particle per second) to prevent infinite loops. - */ - get: function () { return this._frequency; }, - set: function (value) { - //do some error checking to prevent infinite loops - if (typeof value == "number" && value > 0) - this._frequency = value; - else - this._frequency = 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Emitter.prototype, "particleConstructor", { - /** - * The constructor used to create new particles. The default is - * the built in Particle class. Setting this will dump any active or - * pooled particles, if the emitter has already been used. - */ - get: function () { return this._particleConstructor; }, - set: function (value) { - if (value != this._particleConstructor) { - this._particleConstructor = value; - //clean up existing particles - this.cleanup(); - //scrap all the particles - for (var particle = this._poolFirst; particle; particle = particle.next) { - particle.destroy(); - } - this._poolFirst = null; - //re-initialize the emitter so that the new constructor can do anything it needs to - if (this._origConfig && this._origArt) - this.init(this._origArt, this._origConfig); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Emitter.prototype, "parent", { - /** - * The container to add particles to. Settings this will dump any active particles. - */ - get: function () { return this._parent; }, - set: function (value) { - this.cleanup(); - this._parent = value; - }, - enumerable: true, - configurable: true - }); - /** - * Sets up the emitter based on the config settings. - * @param art A texture or array of textures to use for the particles. - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.init = function (art, config) { - if (!art || !config) - return; - //clean up any existing particles - this.cleanup(); - //store the original config and particle images, in case we need to re-initialize - //when the particle constructor is changed - this._origConfig = config; - this._origArt = art; - //set up the array of data, also ensuring that it is an array - art = Array.isArray(art) ? art.slice() : [art]; - //run the art through the particle class's parsing function - var partClass = this._particleConstructor; - this.particleImages = partClass.parseArt ? partClass.parseArt(art) : art; - /////////////////////////// - // Particle Properties // - /////////////////////////// - //set up the alpha - if (config.alpha) { - this.startAlpha = PropertyNode.createList(config.alpha); - } - else - this.startAlpha = new PropertyNode(1, 0); - //set up the speed - if (config.speed) { - this.startSpeed = PropertyNode.createList(config.speed); - this.minimumSpeedMultiplier = ('minimumSpeedMultiplier' in config ? config.minimumSpeedMultiplier : config.speed.minimumSpeedMultiplier) || 1; - } - else { - this.minimumSpeedMultiplier = 1; - this.startSpeed = new PropertyNode(0, 0); - } - //set up acceleration - var acceleration = config.acceleration; - if (acceleration && (acceleration.x || acceleration.y)) { - //make sure we disable speed interpolation - this.startSpeed.next = null; - this.acceleration = new pixi.Point(acceleration.x, acceleration.y); - this.maxSpeed = config.maxSpeed || NaN; - } - else - this.acceleration = new pixi.Point(); - //set up the scale - if (config.scale) { - this.startScale = PropertyNode.createList(config.scale); - this.minimumScaleMultiplier = ('minimumScaleMultiplier' in config ? config.minimumScaleMultiplier : config.scale.minimumScaleMultiplier) || 1; - } - else { - this.startScale = new PropertyNode(1, 0); - this.minimumScaleMultiplier = 1; - } - //set up the color - if (config.color) { - this.startColor = PropertyNode.createList(config.color); - } - else { - this.startColor = new PropertyNode({ r: 0xFF, g: 0xFF, b: 0xFF }, 0); - } - //set up the start rotation - if (config.startRotation) { - this.minStartRotation = config.startRotation.min; - this.maxStartRotation = config.startRotation.max; - } - else - this.minStartRotation = this.maxStartRotation = 0; - if (config.noRotation && - (this.minStartRotation || this.maxStartRotation)) { - this.noRotation = !!config.noRotation; - } - else - this.noRotation = false; - //set up the rotation speed - if (config.rotationSpeed) { - this.minRotationSpeed = config.rotationSpeed.min; - this.maxRotationSpeed = config.rotationSpeed.max; - } - else - this.minRotationSpeed = this.maxRotationSpeed = 0; - this.rotationAcceleration = config.rotationAcceleration || 0; - //set up the lifetime - this.minLifetime = config.lifetime.min; - this.maxLifetime = config.lifetime.max; - //get the blend mode - this.particleBlendMode = exports.ParticleUtils.getBlendMode(config.blendMode); - //use the custom ease if provided - if (config.ease) { - this.customEase = typeof config.ease == "function" ? - config.ease : exports.ParticleUtils.generateEase(config.ease); - } - else - this.customEase = null; - //set up the extra data, running it through the particle class's parseData function. - if (partClass.parseData) - this.extraData = partClass.parseData(config.extraData); - else - this.extraData = config.extraData || null; - ////////////////////////// - // Emitter Properties // - ////////////////////////// - //reset spawn type specific settings - this.spawnRect = this.spawnCircle = null; - this.particlesPerWave = 1; - if (config.particlesPerWave && config.particlesPerWave > 1) - this.particlesPerWave = config.particlesPerWave; - this.particleSpacing = 0; - this.angleStart = 0; - //determine the spawn function to use - this.parseSpawnType(config); - //set the spawning frequency - this.frequency = config.frequency; - this.spawnChance = (typeof config.spawnChance === 'number' && config.spawnChance > 0) ? config.spawnChance : 1; - //set the emitter lifetime - this.emitterLifetime = config.emitterLifetime || -1; - //set the max particles - this.maxParticles = config.maxParticles > 0 ? config.maxParticles : 1000; - //determine if we should add the particle at the back of the list or not - this.addAtBack = !!config.addAtBack; - //reset the emitter position and rotation variables - this.rotation = 0; - this.ownerPos = new pixi.Point(); - this.spawnPos = new pixi.Point(config.pos.x, config.pos.y); - this.initAdditional(art, config); - this._prevEmitterPos = this.spawnPos.clone(); - //previous emitter position is invalid and should not be used for interpolation - this._prevPosIsValid = false; - //start emitting - this._spawnTimer = 0; - this.emit = config.emit === undefined ? true : !!config.emit; - this.autoUpdate = !!config.autoUpdate; - }; - /** - * Sets up additional parameters to the emitter from config settings. - * Using for parsing additional parameters on classes that extend from Emitter - * @param art A texture or array of textures to use for the particles. - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.initAdditional = function (art, config) { - }; - /** - * Parsing emitter spawn type from config settings. - * Place for override and add new kind of spawn type - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.parseSpawnType = function (config) { - var spawnCircle; - switch (config.spawnType) { - case "rect": - this.spawnType = "rect"; - this._spawnFunc = this._spawnRect; - var spawnRect = config.spawnRect; - this.spawnRect = new pixi.Rectangle(spawnRect.x, spawnRect.y, spawnRect.w, spawnRect.h); - break; - case "circle": - this.spawnType = "circle"; - this._spawnFunc = this._spawnCircle; - spawnCircle = config.spawnCircle; - this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); - break; - case "ring": - this.spawnType = "ring"; - this._spawnFunc = this._spawnRing; - spawnCircle = config.spawnCircle; - this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); - this.spawnCircle.minRadius = spawnCircle.minR; - break; - case "burst": - this.spawnType = "burst"; - this._spawnFunc = this._spawnBurst; - this.particleSpacing = config.particleSpacing; - this.angleStart = config.angleStart ? config.angleStart : 0; - break; - case "point": - this.spawnType = "point"; - this._spawnFunc = this._spawnPoint; - break; - case "polygonalChain": - this.spawnType = "polygonalChain"; - this._spawnFunc = this._spawnPolygonalChain; - this.spawnPolygonalChain = new PolygonalChain(config.spawnPolygon); - break; - default: - this.spawnType = "point"; - this._spawnFunc = this._spawnPoint; - break; - } - }; - /** - * Recycles an individual particle. For internal use only. - * @param particle The particle to recycle. - * @internal - */ - Emitter.prototype.recycle = function (particle) { - if (particle.next) - particle.next.prev = particle.prev; - if (particle.prev) - particle.prev.next = particle.next; - if (particle == this._activeParticlesLast) - this._activeParticlesLast = particle.prev; - if (particle == this._activeParticlesFirst) - this._activeParticlesFirst = particle.next; - //add to pool - particle.prev = null; - particle.next = this._poolFirst; - this._poolFirst = particle; - //remove child from display, or make it invisible if it is in a ParticleContainer - if (particle.parent) - particle.parent.removeChild(particle); - //decrease count - --this.particleCount; - }; - /** - * Sets the rotation of the emitter to a new value. - * @param newRot The new rotation, in degrees. - */ - Emitter.prototype.rotate = function (newRot) { - if (this.rotation == newRot) - return; - //caclulate the difference in rotation for rotating spawnPos - var diff = newRot - this.rotation; - this.rotation = newRot; - //rotate spawnPos - exports.ParticleUtils.rotatePoint(diff, this.spawnPos); - //mark the position as having changed - this._posChanged = true; - }; - /** - * Changes the spawn position of the emitter. - * @param x The new x value of the spawn position for the emitter. - * @param y The new y value of the spawn position for the emitter. - */ - Emitter.prototype.updateSpawnPos = function (x, y) { - this._posChanged = true; - this.spawnPos.x = x; - this.spawnPos.y = y; - }; - /** - * Changes the position of the emitter's owner. You should call this if you are adding - * particles to the world container that your emitter's owner is moving around in. - * @param x The new x value of the emitter's owner. - * @param y The new y value of the emitter's owner. - */ - Emitter.prototype.updateOwnerPos = function (x, y) { - this._posChanged = true; - this.ownerPos.x = x; - this.ownerPos.y = y; - }; - /** - * Prevents emitter position interpolation in the next update. - * This should be used if you made a major position change of your emitter's owner - * that was not normal movement. - */ - Emitter.prototype.resetPositionTracking = function () { - this._prevPosIsValid = false; - }; - Object.defineProperty(Emitter.prototype, "emit", { - /** - * If particles should be emitted during update() calls. Setting this to false - * stops new particles from being created, but allows existing ones to die out. - */ - get: function () { return this._emit; }, - set: function (value) { - this._emit = !!value; - this._emitterLife = this.emitterLifetime; - }, - enumerable: true, - configurable: true - }); - ; - Object.defineProperty(Emitter.prototype, "autoUpdate", { - /** - * If the update function is called automatically from the shared ticker. - * Setting this to false requires calling the update function manually. - */ - get: function () { return this._autoUpdate; }, - set: function (value) { - if (this._autoUpdate && !value) { - ticker.remove(this.update, this); - } - else if (!this._autoUpdate && value) { - ticker.add(this.update, this); - } - this._autoUpdate = !!value; - }, - enumerable: true, - configurable: true - }); - /** - * Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself - * when particle emission is complete. - * @param callback Callback for when emission is complete (all particles have died off) - */ - Emitter.prototype.playOnceAndDestroy = function (callback) { - this.autoUpdate = true; - this.emit = true; - this._destroyWhenComplete = true; - this._completeCallback = callback; - }; - /** - * Starts emitting particles and optionally calls a callback when particle emission is complete. - * @param callback Callback for when emission is complete (all particles have died off) - */ - Emitter.prototype.playOnce = function (callback) { - this.emit = true; - this._completeCallback = callback; - }; - /** - * Updates all particles spawned by this emitter and emits new ones. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - Emitter.prototype.update = function (delta) { - if (this._autoUpdate) { - delta = delta / pixi.settings.TARGET_FPMS / 1000; - } - //if we don't have a parent to add particles to, then don't do anything. - //this also works as a isDestroyed check - if (!this._parent) - return; - //update existing particles - var i, particle, next; - for (particle = this._activeParticlesFirst; particle; particle = next) { - next = particle.next; - particle.update(delta); - } - var prevX, prevY; - //if the previous position is valid, store these for later interpolation - if (this._prevPosIsValid) { - prevX = this._prevEmitterPos.x; - prevY = this._prevEmitterPos.y; - } - //store current position of the emitter as local variables - var curX = this.ownerPos.x + this.spawnPos.x; - var curY = this.ownerPos.y + this.spawnPos.y; - //spawn new particles - if (this._emit) { - //decrease spawn timer - this._spawnTimer -= delta < 0 ? 0 : delta; - //while _spawnTimer < 0, we have particles to spawn - while (this._spawnTimer <= 0) { - //determine if the emitter should stop spawning - if (this._emitterLife > 0) { - this._emitterLife -= this._frequency; - if (this._emitterLife <= 0) { - this._spawnTimer = 0; - this._emitterLife = 0; - this.emit = false; - break; - } - } - //determine if we have hit the particle limit - if (this.particleCount >= this.maxParticles) { - this._spawnTimer += this._frequency; - continue; - } - //determine the particle lifetime - var lifetime = void 0; - if (this.minLifetime == this.maxLifetime) - lifetime = this.minLifetime; - else - lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime; - //only make the particle if it wouldn't immediately destroy itself - if (-this._spawnTimer < lifetime) { - //If the position has changed and this isn't the first spawn, - //interpolate the spawn position - var emitPosX = void 0, emitPosY = void 0; - if (this._prevPosIsValid && this._posChanged) { - //1 - _spawnTimer / delta, but _spawnTimer is negative - var lerp = 1 + this._spawnTimer / delta; - emitPosX = (curX - prevX) * lerp + prevX; - emitPosY = (curY - prevY) * lerp + prevY; - } - else //otherwise just set to the spawn position - { - emitPosX = curX; - emitPosY = curY; - } - //create enough particles to fill the wave (non-burst types have a wave of 1) - i = 0; - for (var len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount); i < len; ++i) { - //see if we actually spawn one - if (this.spawnChance < 1 && Math.random() >= this.spawnChance) - continue; - //create particle - var p = void 0; - if (this._poolFirst) { - p = this._poolFirst; - this._poolFirst = this._poolFirst.next; - p.next = null; - } - else { - p = new this.particleConstructor(this); - } - //set a random texture if we have more than one - if (this.particleImages.length > 1) { - p.applyArt(this.particleImages[Math.floor(Math.random() * this.particleImages.length)]); - } - else { - //if they are actually the same texture, a standard particle - //will quit early from the texture setting in setTexture(). - p.applyArt(this.particleImages[0]); - } - //set up the start and end values - p.alphaList.reset(this.startAlpha); - if (this.minimumSpeedMultiplier != 1) { - p.speedMultiplier = Math.random() * (1 - this.minimumSpeedMultiplier) + this.minimumSpeedMultiplier; - } - p.speedList.reset(this.startSpeed); - p.acceleration.x = this.acceleration.x; - p.acceleration.y = this.acceleration.y; - p.maxSpeed = this.maxSpeed; - if (this.minimumScaleMultiplier != 1) { - p.scaleMultiplier = Math.random() * (1 - this.minimumScaleMultiplier) + this.minimumScaleMultiplier; - } - p.scaleList.reset(this.startScale); - p.colorList.reset(this.startColor); - //randomize the rotation speed - if (this.minRotationSpeed == this.maxRotationSpeed) - p.rotationSpeed = this.minRotationSpeed; - else - p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed; - p.rotationAcceleration = this.rotationAcceleration; - p.noRotation = this.noRotation; - //set up the lifetime - p.maxLife = lifetime; - //set the blend mode - p.blendMode = this.particleBlendMode; - //set the custom ease, if any - p.ease = this.customEase; - //set the extra data, if any - p.extraData = this.extraData; - //set additional properties to particle - this.applyAdditionalProperties(p); - //call the proper function to handle rotation and position of particle - this._spawnFunc(p, emitPosX, emitPosY, i); - //initialize particle - p.init(); - //update the particle by the time passed, so the particles are spread out properly - p.update(-this._spawnTimer); //we want a positive delta, because a negative delta messes things up - //add the particle to the display list - if (!p.parent) { - if (this.addAtBack) - this._parent.addChildAt(p, 0); - else - this._parent.addChild(p); - } - else { - //kind of hacky, but performance friendly - //shuffle children to correct place - var children = this._parent.children; - //avoid using splice if possible - if (children[0] == p) - children.shift(); - else if (children[children.length - 1] == p) - children.pop(); - else { - var index = children.indexOf(p); - children.splice(index, 1); - } - if (this.addAtBack) - children.unshift(p); - else - children.push(p); - } - //add particle to list of active particles - if (this._activeParticlesLast) { - this._activeParticlesLast.next = p; - p.prev = this._activeParticlesLast; - this._activeParticlesLast = p; - } - else { - this._activeParticlesLast = this._activeParticlesFirst = p; - } - ++this.particleCount; - } - } - //increase timer and continue on to any other particles that need to be created - this._spawnTimer += this._frequency; - } - } - //if the position changed before this update, then keep track of that - if (this._posChanged) { - this._prevEmitterPos.x = curX; - this._prevEmitterPos.y = curY; - this._prevPosIsValid = true; - this._posChanged = false; - } - //if we are all done and should destroy ourselves, take care of that - if (!this._emit && !this._activeParticlesFirst) { - if (this._completeCallback) { - var cb = this._completeCallback; - this._completeCallback = null; - cb(); - } - if (this._destroyWhenComplete) { - this.destroy(); - } - } - }; - /** - * Set additional properties to new particle. - * Using on classes that extend from Emitter - * @param p The particle - */ - Emitter.prototype.applyAdditionalProperties = function (p) { - }; - /** - * Positions a particle for a point type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnPoint = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on - //starting particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; - //drop the particle at the emitter's position - p.position.x = emitPosX; - p.position.y = emitPosY; - }; - /** - * Positions a particle for a rectangle type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnRect = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; - //place the particle at a random point in the rectangle - helperPoint.x = Math.random() * this.spawnRect.width + this.spawnRect.x; - helperPoint.y = Math.random() * this.spawnRect.height + this.spawnRect.y; - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a circle type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnCircle = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - //place the particle at a random radius in the circle - helperPoint.x = Math.random() * this.spawnCircle.radius; - helperPoint.y = 0; - //rotate the point to a random angle in the circle - exports.ParticleUtils.rotatePoint(Math.random() * 360, helperPoint); - //offset by the circle's center - helperPoint.x += this.spawnCircle.x; - helperPoint.y += this.spawnCircle.y; - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a ring type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnRing = function (p, emitPosX, emitPosY) { - var spawnCircle = this.spawnCircle; - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - //place the particle at a random radius in the ring - if (spawnCircle.minRadius !== spawnCircle.radius) { - helperPoint.x = Math.random() * (spawnCircle.radius - spawnCircle.minRadius) + - spawnCircle.minRadius; - } - else - helperPoint.x = spawnCircle.radius; - helperPoint.y = 0; - //rotate the point to a random angle in the circle - var angle = Math.random() * 360; - p.rotation += angle; - exports.ParticleUtils.rotatePoint(angle, helperPoint); - //offset by the circle's center - helperPoint.x += this.spawnCircle.x; - helperPoint.y += this.spawnCircle.y; - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for polygonal chain. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnPolygonalChain = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - // get random point on the polygon chain - this.spawnPolygonalChain.getRandomPoint(helperPoint); - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a burst type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. - */ - Emitter.prototype._spawnBurst = function (p, emitPosX, emitPosY, i) { - //set the initial rotation/direction of the particle based on spawn - //angle and rotation of emitter - if (this.particleSpacing === 0) - p.rotation = Math.random() * 360; - else - p.rotation = this.angleStart + (this.particleSpacing * i) + this.rotation; - //drop the particle at the emitter's position - p.position.x = emitPosX; - p.position.y = emitPosY; - }; - /** - * Kills all active particles immediately. - */ - Emitter.prototype.cleanup = function () { - var particle, next; - for (particle = this._activeParticlesFirst; particle; particle = next) { - next = particle.next; - this.recycle(particle); - if (particle.parent) - particle.parent.removeChild(particle); - } - this._activeParticlesFirst = this._activeParticlesLast = null; - this.particleCount = 0; - }; - /** - * Destroys the emitter and all of its particles. - */ - Emitter.prototype.destroy = function () { - //make sure we aren't still listening to any tickers - this.autoUpdate = false; - //puts all active particles in the pool, and removes them from the particle parent - this.cleanup(); - //wipe the pool clean - var next; - for (var particle = this._poolFirst; particle; particle = next) { - //store next value so we don't lose it in our destroy call - next = particle.next; - particle.destroy(); - } - this._poolFirst = this._parent = this.particleImages = this.spawnPos = this.ownerPos = - this.startColor = this.startScale = this.startAlpha = this.startSpeed = - this.customEase = this._completeCallback = null; - }; - return Emitter; + // get the shared ticker, in V4 and V5 friendly methods + /** + * @hidden + */ + var ticker; + // to avoid Rollup transforming our import, save pixi namespace in a variable + var pixiNS$1 = pixi; + if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { + ticker = pixiNS$1.ticker.shared; + } + else { + ticker = pixiNS$1.Ticker.shared; + } + /** + * @hidden + */ + var helperPoint = new pixi.Point(); + /** + * A particle emitter. + */ + var Emitter = /** @class */ (function () { + /** + * @param particleParent The container to add the particles to. + * @param particleImages A texture or array of textures to use + * for the particles. Strings will be turned + * into textures via Texture.fromImage(). + * @param config A configuration object containing settings for the emitter. + * @param config.emit If config.emit is explicitly passed as false, the + * Emitter will start disabled. + * @param config.autoUpdate If config.autoUpdate is explicitly passed as + * true, the Emitter will automatically call + * update via the PIXI shared ticker. + */ + function Emitter(particleParent, particleImages, config) { + this._particleConstructor = Particle; + //properties for individual particles + this.particleImages = null; + this.startAlpha = null; + this.startSpeed = null; + this.minimumSpeedMultiplier = 1; + this.acceleration = null; + this.maxSpeed = NaN; + this.startScale = null; + this.minimumScaleMultiplier = 1; + this.startColor = null; + this.minLifetime = 0; + this.maxLifetime = 0; + this.minStartRotation = 0; + this.maxStartRotation = 0; + this.noRotation = false; + this.minRotationSpeed = 0; + this.maxRotationSpeed = 0; + this.particleBlendMode = 0; + this.customEase = null; + this.extraData = null; + //properties for spawning particles + this._frequency = 1; + this.spawnChance = 1; + this.maxParticles = 1000; + this.emitterLifetime = -1; + this.spawnPos = null; + this.spawnType = null; + this._spawnFunc = null; + this.spawnRect = null; + this.spawnCircle = null; + this.spawnPolygonalChain = null; + this.particlesPerWave = 1; + this.particleSpacing = 0; + this.angleStart = 0; + //emitter properties + this.rotation = 0; + this.ownerPos = null; + this._prevEmitterPos = null; + this._prevPosIsValid = false; + this._posChanged = false; + this._parent = null; + this.addAtBack = false; + this.particleCount = 0; + this._emit = false; + this._spawnTimer = 0; + this._emitterLife = -1; + this._activeParticlesFirst = null; + this._activeParticlesLast = null; + this._poolFirst = null; + this._origConfig = null; + this._origArt = null; + this._autoUpdate = false; + this._destroyWhenComplete = false; + this._completeCallback = null; + //set the initial parent + this.parent = particleParent; + if (particleImages && config) + this.init(particleImages, config); + //save often used functions on the instance instead of the prototype for better speed + this.recycle = this.recycle; + this.update = this.update; + this.rotate = this.rotate; + this.updateSpawnPos = this.updateSpawnPos; + this.updateOwnerPos = this.updateOwnerPos; + } + Object.defineProperty(Emitter.prototype, "frequency", { + /** + * Time between particle spawns in seconds. If this value is not a number greater than 0, + * it will be set to 1 (particle per second) to prevent infinite loops. + */ + get: function () { return this._frequency; }, + set: function (value) { + //do some error checking to prevent infinite loops + if (typeof value == "number" && value > 0) + this._frequency = value; + else + this._frequency = 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Emitter.prototype, "particleConstructor", { + /** + * The constructor used to create new particles. The default is + * the built in Particle class. Setting this will dump any active or + * pooled particles, if the emitter has already been used. + */ + get: function () { return this._particleConstructor; }, + set: function (value) { + if (value != this._particleConstructor) { + this._particleConstructor = value; + //clean up existing particles + this.cleanup(); + //scrap all the particles + for (var particle = this._poolFirst; particle; particle = particle.next) { + particle.destroy(); + } + this._poolFirst = null; + //re-initialize the emitter so that the new constructor can do anything it needs to + if (this._origConfig && this._origArt) + this.init(this._origArt, this._origConfig); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Emitter.prototype, "parent", { + /** + * The container to add particles to. Settings this will dump any active particles. + */ + get: function () { return this._parent; }, + set: function (value) { + this.cleanup(); + this._parent = value; + }, + enumerable: true, + configurable: true + }); + /** + * Sets up the emitter based on the config settings. + * @param art A texture or array of textures to use for the particles. + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.init = function (art, config) { + if (!art || !config) + return; + //clean up any existing particles + this.cleanup(); + //store the original config and particle images, in case we need to re-initialize + //when the particle constructor is changed + this._origConfig = config; + this._origArt = art; + //set up the array of data, also ensuring that it is an array + art = Array.isArray(art) ? art.slice() : [art]; + //run the art through the particle class's parsing function + var partClass = this._particleConstructor; + this.particleImages = partClass.parseArt ? partClass.parseArt(art) : art; + /////////////////////////// + // Particle Properties // + /////////////////////////// + //set up the alpha + if (config.alpha) { + this.startAlpha = PropertyNode.createList(config.alpha); + } + else + this.startAlpha = new PropertyNode(1, 0); + //set up the speed + if (config.speed) { + this.startSpeed = PropertyNode.createList(config.speed); + this.minimumSpeedMultiplier = ('minimumSpeedMultiplier' in config ? config.minimumSpeedMultiplier : config.speed.minimumSpeedMultiplier) || 1; + } + else { + this.minimumSpeedMultiplier = 1; + this.startSpeed = new PropertyNode(0, 0); + } + //set up acceleration + var acceleration = config.acceleration; + if (acceleration && (acceleration.x || acceleration.y)) { + //make sure we disable speed interpolation + this.startSpeed.next = null; + this.acceleration = new pixi.Point(acceleration.x, acceleration.y); + this.maxSpeed = config.maxSpeed || NaN; + } + else + this.acceleration = new pixi.Point(); + //set up the scale + if (config.scale) { + this.startScale = PropertyNode.createList(config.scale); + this.minimumScaleMultiplier = ('minimumScaleMultiplier' in config ? config.minimumScaleMultiplier : config.scale.minimumScaleMultiplier) || 1; + } + else { + this.startScale = new PropertyNode(1, 0); + this.minimumScaleMultiplier = 1; + } + //set up the color + if (config.color) { + this.startColor = PropertyNode.createList(config.color); + } + else { + this.startColor = new PropertyNode({ r: 0xFF, g: 0xFF, b: 0xFF }, 0); + } + //set up the start rotation + if (config.startRotation) { + this.minStartRotation = config.startRotation.min; + this.maxStartRotation = config.startRotation.max; + } + else + this.minStartRotation = this.maxStartRotation = 0; + if (config.noRotation && + (this.minStartRotation || this.maxStartRotation)) { + this.noRotation = !!config.noRotation; + } + else + this.noRotation = false; + //set up the rotation speed + if (config.rotationSpeed) { + this.minRotationSpeed = config.rotationSpeed.min; + this.maxRotationSpeed = config.rotationSpeed.max; + } + else + this.minRotationSpeed = this.maxRotationSpeed = 0; + this.rotationAcceleration = config.rotationAcceleration || 0; + //set up the lifetime + this.minLifetime = config.lifetime.min; + this.maxLifetime = config.lifetime.max; + //get the blend mode + this.particleBlendMode = exports.ParticleUtils.getBlendMode(config.blendMode); + //use the custom ease if provided + if (config.ease) { + this.customEase = typeof config.ease == "function" ? + config.ease : exports.ParticleUtils.generateEase(config.ease); + } + else + this.customEase = null; + //set up the extra data, running it through the particle class's parseData function. + if (partClass.parseData) + this.extraData = partClass.parseData(config.extraData); + else + this.extraData = config.extraData || null; + ////////////////////////// + // Emitter Properties // + ////////////////////////// + //reset spawn type specific settings + this.spawnRect = this.spawnCircle = null; + this.particlesPerWave = 1; + if (config.particlesPerWave && config.particlesPerWave > 1) + this.particlesPerWave = config.particlesPerWave; + this.particleSpacing = 0; + this.angleStart = 0; + //determine the spawn function to use + this.parseSpawnType(config); + //set the spawning frequency + this.frequency = config.frequency; + this.spawnChance = (typeof config.spawnChance === 'number' && config.spawnChance > 0) ? config.spawnChance : 1; + //set the emitter lifetime + this.emitterLifetime = config.emitterLifetime || -1; + //set the max particles + this.maxParticles = config.maxParticles > 0 ? config.maxParticles : 1000; + //determine if we should add the particle at the back of the list or not + this.addAtBack = !!config.addAtBack; + //reset the emitter position and rotation variables + this.rotation = 0; + this.ownerPos = new pixi.Point(); + this.spawnPos = new pixi.Point(config.pos.x, config.pos.y); + this.initAdditional(art, config); + this._prevEmitterPos = this.spawnPos.clone(); + //previous emitter position is invalid and should not be used for interpolation + this._prevPosIsValid = false; + //start emitting + this._spawnTimer = 0; + this.emit = config.emit === undefined ? true : !!config.emit; + this.autoUpdate = !!config.autoUpdate; + }; + /** + * Sets up additional parameters to the emitter from config settings. + * Using for parsing additional parameters on classes that extend from Emitter + * @param art A texture or array of textures to use for the particles. + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.initAdditional = function (art, config) { + }; + /** + * Parsing emitter spawn type from config settings. + * Place for override and add new kind of spawn type + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.parseSpawnType = function (config) { + var spawnCircle; + switch (config.spawnType) { + case "rect": + this.spawnType = "rect"; + this._spawnFunc = this._spawnRect; + var spawnRect = config.spawnRect; + this.spawnRect = new pixi.Rectangle(spawnRect.x, spawnRect.y, spawnRect.w, spawnRect.h); + break; + case "circle": + this.spawnType = "circle"; + this._spawnFunc = this._spawnCircle; + spawnCircle = config.spawnCircle; + this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); + break; + case "ring": + this.spawnType = "ring"; + this._spawnFunc = this._spawnRing; + spawnCircle = config.spawnCircle; + this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); + this.spawnCircle.minRadius = spawnCircle.minR; + break; + case "burst": + this.spawnType = "burst"; + this._spawnFunc = this._spawnBurst; + this.particleSpacing = config.particleSpacing; + this.angleStart = config.angleStart ? config.angleStart : 0; + break; + case "point": + this.spawnType = "point"; + this._spawnFunc = this._spawnPoint; + break; + case "polygonalChain": + this.spawnType = "polygonalChain"; + this._spawnFunc = this._spawnPolygonalChain; + this.spawnPolygonalChain = new PolygonalChain(config.spawnPolygon); + break; + default: + this.spawnType = "point"; + this._spawnFunc = this._spawnPoint; + break; + } + }; + /** + * Recycles an individual particle. For internal use only. + * @param particle The particle to recycle. + * @internal + */ + Emitter.prototype.recycle = function (particle) { + if (particle.next) + particle.next.prev = particle.prev; + if (particle.prev) + particle.prev.next = particle.next; + if (particle == this._activeParticlesLast) + this._activeParticlesLast = particle.prev; + if (particle == this._activeParticlesFirst) + this._activeParticlesFirst = particle.next; + //add to pool + particle.prev = null; + particle.next = this._poolFirst; + this._poolFirst = particle; + //remove child from display, or make it invisible if it is in a ParticleContainer + if (particle.parent) + particle.parent.removeChild(particle); + //decrease count + --this.particleCount; + }; + /** + * Sets the rotation of the emitter to a new value. + * @param newRot The new rotation, in degrees. + */ + Emitter.prototype.rotate = function (newRot) { + if (this.rotation == newRot) + return; + //caclulate the difference in rotation for rotating spawnPos + var diff = newRot - this.rotation; + this.rotation = newRot; + //rotate spawnPos + exports.ParticleUtils.rotatePoint(diff, this.spawnPos); + //mark the position as having changed + this._posChanged = true; + }; + /** + * Changes the spawn position of the emitter. + * @param x The new x value of the spawn position for the emitter. + * @param y The new y value of the spawn position for the emitter. + */ + Emitter.prototype.updateSpawnPos = function (x, y) { + this._posChanged = true; + this.spawnPos.x = x; + this.spawnPos.y = y; + }; + /** + * Changes the position of the emitter's owner. You should call this if you are adding + * particles to the world container that your emitter's owner is moving around in. + * @param x The new x value of the emitter's owner. + * @param y The new y value of the emitter's owner. + */ + Emitter.prototype.updateOwnerPos = function (x, y) { + this._posChanged = true; + this.ownerPos.x = x; + this.ownerPos.y = y; + }; + /** + * Prevents emitter position interpolation in the next update. + * This should be used if you made a major position change of your emitter's owner + * that was not normal movement. + */ + Emitter.prototype.resetPositionTracking = function () { + this._prevPosIsValid = false; + }; + Object.defineProperty(Emitter.prototype, "emit", { + /** + * If particles should be emitted during update() calls. Setting this to false + * stops new particles from being created, but allows existing ones to die out. + */ + get: function () { return this._emit; }, + set: function (value) { + this._emit = !!value; + this._emitterLife = this.emitterLifetime; + }, + enumerable: true, + configurable: true + }); + ; + Object.defineProperty(Emitter.prototype, "autoUpdate", { + /** + * If the update function is called automatically from the shared ticker. + * Setting this to false requires calling the update function manually. + */ + get: function () { return this._autoUpdate; }, + set: function (value) { + if (this._autoUpdate && !value) { + ticker.remove(this.update, this); + } + else if (!this._autoUpdate && value) { + ticker.add(this.update, this); + } + this._autoUpdate = !!value; + }, + enumerable: true, + configurable: true + }); + /** + * Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself + * when particle emission is complete. + * @param callback Callback for when emission is complete (all particles have died off) + */ + Emitter.prototype.playOnceAndDestroy = function (callback) { + this.autoUpdate = true; + this.emit = true; + this._destroyWhenComplete = true; + this._completeCallback = callback; + }; + /** + * Starts emitting particles and optionally calls a callback when particle emission is complete. + * @param callback Callback for when emission is complete (all particles have died off) + */ + Emitter.prototype.playOnce = function (callback) { + this.emit = true; + this._completeCallback = callback; + }; + /** + * Updates all particles spawned by this emitter and emits new ones. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + Emitter.prototype.update = function (delta) { + if (this._autoUpdate) { + delta = delta / pixi.settings.TARGET_FPMS / 1000; + } + //if we don't have a parent to add particles to, then don't do anything. + //this also works as a isDestroyed check + if (!this._parent) + return; + //update existing particles + var i, particle, next; + for (particle = this._activeParticlesFirst; particle; particle = next) { + next = particle.next; + particle.update(delta); + } + var prevX, prevY; + //if the previous position is valid, store these for later interpolation + if (this._prevPosIsValid) { + prevX = this._prevEmitterPos.x; + prevY = this._prevEmitterPos.y; + } + //store current position of the emitter as local variables + var curX = this.ownerPos.x + this.spawnPos.x; + var curY = this.ownerPos.y + this.spawnPos.y; + //spawn new particles + if (this._emit) { + //decrease spawn timer + this._spawnTimer -= delta < 0 ? 0 : delta; + //while _spawnTimer < 0, we have particles to spawn + while (this._spawnTimer <= 0) { + //determine if the emitter should stop spawning + if (this._emitterLife > 0) { + this._emitterLife -= this._frequency; + if (this._emitterLife <= 0) { + this._spawnTimer = 0; + this._emitterLife = 0; + this.emit = false; + break; + } + } + //determine if we have hit the particle limit + if (this.particleCount >= this.maxParticles) { + this._spawnTimer += this._frequency; + continue; + } + //determine the particle lifetime + var lifetime = void 0; + if (this.minLifetime == this.maxLifetime) + lifetime = this.minLifetime; + else + lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime; + //only make the particle if it wouldn't immediately destroy itself + if (-this._spawnTimer < lifetime) { + //If the position has changed and this isn't the first spawn, + //interpolate the spawn position + var emitPosX = void 0, emitPosY = void 0; + if (this._prevPosIsValid && this._posChanged) { + //1 - _spawnTimer / delta, but _spawnTimer is negative + var lerp = 1 + this._spawnTimer / delta; + emitPosX = (curX - prevX) * lerp + prevX; + emitPosY = (curY - prevY) * lerp + prevY; + } + else //otherwise just set to the spawn position + { + emitPosX = curX; + emitPosY = curY; + } + //create enough particles to fill the wave (non-burst types have a wave of 1) + i = 0; + for (var len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount); i < len; ++i) { + //see if we actually spawn one + if (this.spawnChance < 1 && Math.random() >= this.spawnChance) + continue; + //create particle + var p = void 0; + if (this._poolFirst) { + p = this._poolFirst; + this._poolFirst = this._poolFirst.next; + p.next = null; + } + else { + p = new this.particleConstructor(this); + } + //set a random texture if we have more than one + if (this.particleImages.length > 1) { + p.applyArt(this.particleImages[Math.floor(Math.random() * this.particleImages.length)]); + } + else { + //if they are actually the same texture, a standard particle + //will quit early from the texture setting in setTexture(). + p.applyArt(this.particleImages[0]); + } + //set up the start and end values + p.alphaList.reset(this.startAlpha); + if (this.minimumSpeedMultiplier != 1) { + p.speedMultiplier = Math.random() * (1 - this.minimumSpeedMultiplier) + this.minimumSpeedMultiplier; + } + p.speedList.reset(this.startSpeed); + p.acceleration.x = this.acceleration.x; + p.acceleration.y = this.acceleration.y; + p.maxSpeed = this.maxSpeed; + if (this.minimumScaleMultiplier != 1) { + p.scaleMultiplier = Math.random() * (1 - this.minimumScaleMultiplier) + this.minimumScaleMultiplier; + } + p.scaleList.reset(this.startScale); + p.colorList.reset(this.startColor); + //randomize the rotation speed + if (this.minRotationSpeed == this.maxRotationSpeed) + p.rotationSpeed = this.minRotationSpeed; + else + p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed; + p.rotationAcceleration = this.rotationAcceleration; + p.noRotation = this.noRotation; + //set up the lifetime + p.maxLife = lifetime; + //set the blend mode + p.blendMode = this.particleBlendMode; + //set the custom ease, if any + p.ease = this.customEase; + //set the extra data, if any + p.extraData = this.extraData; + //set additional properties to particle + this.applyAdditionalProperties(p); + //call the proper function to handle rotation and position of particle + this._spawnFunc(p, emitPosX, emitPosY, i); + //initialize particle + p.init(); + //update the particle by the time passed, so the particles are spread out properly + p.update(-this._spawnTimer); //we want a positive delta, because a negative delta messes things up + //add the particle to the display list + if (!p.parent) { + if (this.addAtBack) + this._parent.addChildAt(p, 0); + else + this._parent.addChild(p); + } + else { + //kind of hacky, but performance friendly + //shuffle children to correct place + var children = this._parent.children; + //avoid using splice if possible + if (children[0] == p) + children.shift(); + else if (children[children.length - 1] == p) + children.pop(); + else { + var index = children.indexOf(p); + children.splice(index, 1); + } + if (this.addAtBack) + children.unshift(p); + else + children.push(p); + } + //add particle to list of active particles + if (this._activeParticlesLast) { + this._activeParticlesLast.next = p; + p.prev = this._activeParticlesLast; + this._activeParticlesLast = p; + } + else { + this._activeParticlesLast = this._activeParticlesFirst = p; + } + ++this.particleCount; + } + } + //increase timer and continue on to any other particles that need to be created + this._spawnTimer += this._frequency; + } + } + //if the position changed before this update, then keep track of that + if (this._posChanged) { + this._prevEmitterPos.x = curX; + this._prevEmitterPos.y = curY; + this._prevPosIsValid = true; + this._posChanged = false; + } + //if we are all done and should destroy ourselves, take care of that + if (!this._emit && !this._activeParticlesFirst) { + if (this._completeCallback) { + var cb = this._completeCallback; + this._completeCallback = null; + cb(); + } + if (this._destroyWhenComplete) { + this.destroy(); + } + } + }; + /** + * Set additional properties to new particle. + * Using on classes that extend from Emitter + * @param p The particle + */ + Emitter.prototype.applyAdditionalProperties = function (p) { + }; + /** + * Positions a particle for a point type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnPoint = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on + //starting particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; + //drop the particle at the emitter's position + p.position.x = emitPosX; + p.position.y = emitPosY; + }; + /** + * Positions a particle for a rectangle type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnRect = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; + //place the particle at a random point in the rectangle + helperPoint.x = Math.random() * this.spawnRect.width + this.spawnRect.x; + helperPoint.y = Math.random() * this.spawnRect.height + this.spawnRect.y; + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a circle type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnCircle = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + //place the particle at a random radius in the circle + helperPoint.x = Math.random() * this.spawnCircle.radius; + helperPoint.y = 0; + //rotate the point to a random angle in the circle + exports.ParticleUtils.rotatePoint(Math.random() * 360, helperPoint); + //offset by the circle's center + helperPoint.x += this.spawnCircle.x; + helperPoint.y += this.spawnCircle.y; + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a ring type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnRing = function (p, emitPosX, emitPosY) { + var spawnCircle = this.spawnCircle; + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + //place the particle at a random radius in the ring + if (spawnCircle.minRadius !== spawnCircle.radius) { + helperPoint.x = Math.random() * (spawnCircle.radius - spawnCircle.minRadius) + + spawnCircle.minRadius; + } + else + helperPoint.x = spawnCircle.radius; + helperPoint.y = 0; + //rotate the point to a random angle in the circle + var angle = Math.random() * 360; + p.rotation += angle; + exports.ParticleUtils.rotatePoint(angle, helperPoint); + //offset by the circle's center + helperPoint.x += this.spawnCircle.x; + helperPoint.y += this.spawnCircle.y; + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for polygonal chain. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnPolygonalChain = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + // get random point on the polygon chain + this.spawnPolygonalChain.getRandomPoint(helperPoint); + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a burst type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. + */ + Emitter.prototype._spawnBurst = function (p, emitPosX, emitPosY, i) { + //set the initial rotation/direction of the particle based on spawn + //angle and rotation of emitter + if (this.particleSpacing === 0) + p.rotation = Math.random() * 360; + else + p.rotation = this.angleStart + (this.particleSpacing * i) + this.rotation; + //drop the particle at the emitter's position + p.position.x = emitPosX; + p.position.y = emitPosY; + }; + /** + * Kills all active particles immediately. + */ + Emitter.prototype.cleanup = function () { + var particle, next; + for (particle = this._activeParticlesFirst; particle; particle = next) { + next = particle.next; + this.recycle(particle); + if (particle.parent) + particle.parent.removeChild(particle); + } + this._activeParticlesFirst = this._activeParticlesLast = null; + this.particleCount = 0; + }; + /** + * Destroys the emitter and all of its particles. + */ + Emitter.prototype.destroy = function () { + //make sure we aren't still listening to any tickers + this.autoUpdate = false; + //puts all active particles in the pool, and removes them from the particle parent + this.cleanup(); + //wipe the pool clean + var next; + for (var particle = this._poolFirst; particle; particle = next) { + //store next value so we don't lose it in our destroy call + next = particle.next; + particle.destroy(); + } + this._poolFirst = this._parent = this.particleImages = this.spawnPos = this.ownerPos = + this.startColor = this.startScale = this.startAlpha = this.startSpeed = + this.customEase = this._completeCallback = null; + }; + return Emitter; }()); - /** - * A helper point for math things. - * @hidden - */ - var helperPoint$1 = new pixi.Point(); - /** - * A hand picked list of Math functions (and a couple properties) that are - * allowable. They should be used without the preceding "Math." - * @hidden - */ - var MATH_FUNCS = [ - "pow", - "sqrt", - "abs", - "floor", - "round", - "ceil", - "E", - "PI", - "sin", - "cos", - "tan", - "asin", - "acos", - "atan", - "atan2", - "log" - ]; - /** - * create an actual regular expression object from the string - * @hidden - */ - var WHITELISTER = new RegExp([ - //Allow the 4 basic operations, parentheses and all numbers/decimals, as well - //as 'x', for the variable usage. - "[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]", - ].concat(MATH_FUNCS).join("|"), "g"); - /** - * Parses a string into a function for path following. - * This involves whitelisting the string for safety, inserting "Math." to math function - * names, and using `new Function()` to generate a function. - * @hidden - * @param pathString The string to parse. - * @return The path function - takes x, outputs y. - */ - var parsePath = function (pathString) { - var matches = pathString.match(WHITELISTER); - for (var i = matches.length - 1; i >= 0; --i) { - if (MATH_FUNCS.indexOf(matches[i]) >= 0) - matches[i] = "Math." + matches[i]; - } - pathString = matches.join(""); - return new Function("x", "return " + pathString + ";"); - }; - /** - * An particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or - * "5x + 3". - * To use this class, the particle config must have a "path" string in the - * "extraData" parameter. This string should have "x" in it to represent movement (from the - * speed settings of the particle). It may have numbers, parentheses, the four basic - * operations, and the following Math functions or properties (without the preceding "Math."): - * "pow", "sqrt", "abs", "floor", "round", "ceil", "E", "PI", "sin", "cos", "tan", "asin", - * "acos", "atan", "atan2", "log". - * The overall movement of the particle and the expression value become x and y positions for - * the particle, respectively. The final position is rotated by the spawn rotation/angle of - * the particle. - * - * Some example paths: - * - * "sin(x/10) * 20" // A sine wave path. - * "cos(x/100) * 30" // Particles curve counterclockwise (for medium speed/low lifetime particles) - * "pow(x/10, 2) / 2" // Particles curve clockwise (remember, +y is down). - */ - var PathParticle = /** @class */ (function (_super) { - __extends(PathParticle, _super); - /** - * @param {PIXI.particles.Emitter} emitter The emitter that controls this PathParticle. - */ - function PathParticle(emitter) { - var _this = _super.call(this, emitter) || this; - _this.path = null; - _this.initialRotation = 0; - _this.initialPosition = new pixi.Point(); - _this.movement = 0; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - PathParticle.prototype.init = function () { - //get initial rotation before it is converted to radians - this.initialRotation = this.rotation; - //standard init - this.Particle_init(); - //set the path for the particle - this.path = this.extraData.path; - //cancel the normal movement behavior - this._doNormalMovement = !this.path; - //reset movement - this.movement = 0; - //grab position - this.initialPosition.x = this.position.x; - this.initialPosition.y = this.position.y; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - PathParticle.prototype.update = function (delta) { - var lerp = this.Particle_update(delta); - //if the particle died during the update, then don't bother - if (lerp >= 0 && this.path) { - //increase linear movement based on speed - var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; - this.movement += speed * delta; - //set up the helper point for rotation - helperPoint$1.x = this.movement; - helperPoint$1.y = this.path(this.movement); - exports.ParticleUtils.rotatePoint(this.initialRotation, helperPoint$1); - this.position.x = this.initialPosition.x + helperPoint$1.x; - this.position.y = this.initialPosition.y + helperPoint$1.y; - } - return lerp; - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - PathParticle.prototype.destroy = function () { - this.Particle_destroy(); - this.path = this.initialPosition = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. This just runs Particle.parseArt(). - * @param art The array of art data. For Particle, it should be an array of - * Textures. Any strings in the array will be converted to - * Textures via Texture.fromImage(). - * @return The art, after any needed modifications. - */ - PathParticle.parseArt = function (art) { - return Particle.parseArt(art); - }; - /** - * Parses extra emitter data to ensure it is set up for this particle class. - * PathParticle checks for the existence of path data, and parses the path data for use - * by particle instances. - * @param extraData The extra data from the particle config. - * @return The parsed extra data. - */ - PathParticle.parseData = function (extraData) { - var output = {}; - if (extraData && extraData.path) { - try { - output.path = parsePath(extraData.path); - } - catch (e) { - if (exports.ParticleUtils.verbose) - console.error("PathParticle: error in parsing path expression"); - output.path = null; - } - } - else { - if (exports.ParticleUtils.verbose) - console.error("PathParticle requires a path string in extraData!"); - output.path = null; - } - return output; - }; - return PathParticle; + /** + * A helper point for math things. + * @hidden + */ + var helperPoint$1 = new pixi.Point(); + /** + * A hand picked list of Math functions (and a couple properties) that are + * allowable. They should be used without the preceding "Math." + * @hidden + */ + var MATH_FUNCS = [ + "pow", + "sqrt", + "abs", + "floor", + "round", + "ceil", + "E", + "PI", + "sin", + "cos", + "tan", + "asin", + "acos", + "atan", + "atan2", + "log" + ]; + /** + * create an actual regular expression object from the string + * @hidden + */ + var WHITELISTER = new RegExp([ + //Allow the 4 basic operations, parentheses and all numbers/decimals, as well + //as 'x', for the variable usage. + "[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]", + ].concat(MATH_FUNCS).join("|"), "g"); + /** + * Parses a string into a function for path following. + * This involves whitelisting the string for safety, inserting "Math." to math function + * names, and using `new Function()` to generate a function. + * @hidden + * @param pathString The string to parse. + * @return The path function - takes x, outputs y. + */ + var parsePath = function (pathString) { + var matches = pathString.match(WHITELISTER); + for (var i = matches.length - 1; i >= 0; --i) { + if (MATH_FUNCS.indexOf(matches[i]) >= 0) + matches[i] = "Math." + matches[i]; + } + pathString = matches.join(""); + return new Function("x", "return " + pathString + ";"); + }; + /** + * An particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or + * "5x + 3". + * To use this class, the particle config must have a "path" string in the + * "extraData" parameter. This string should have "x" in it to represent movement (from the + * speed settings of the particle). It may have numbers, parentheses, the four basic + * operations, and the following Math functions or properties (without the preceding "Math."): + * "pow", "sqrt", "abs", "floor", "round", "ceil", "E", "PI", "sin", "cos", "tan", "asin", + * "acos", "atan", "atan2", "log". + * The overall movement of the particle and the expression value become x and y positions for + * the particle, respectively. The final position is rotated by the spawn rotation/angle of + * the particle. + * + * Some example paths: + * + * "sin(x/10) * 20" // A sine wave path. + * "cos(x/100) * 30" // Particles curve counterclockwise (for medium speed/low lifetime particles) + * "pow(x/10, 2) / 2" // Particles curve clockwise (remember, +y is down). + */ + var PathParticle = /** @class */ (function (_super) { + __extends(PathParticle, _super); + /** + * @param {PIXI.particles.Emitter} emitter The emitter that controls this PathParticle. + */ + function PathParticle(emitter) { + var _this = _super.call(this, emitter) || this; + _this.path = null; + _this.initialRotation = 0; + _this.initialPosition = new pixi.Point(); + _this.movement = 0; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + PathParticle.prototype.init = function () { + //get initial rotation before it is converted to radians + this.initialRotation = this.rotation; + //standard init + this.Particle_init(); + //set the path for the particle + this.path = this.extraData.path; + //cancel the normal movement behavior + this._doNormalMovement = !this.path; + //reset movement + this.movement = 0; + //grab position + this.initialPosition.x = this.position.x; + this.initialPosition.y = this.position.y; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + PathParticle.prototype.update = function (delta) { + var lerp = this.Particle_update(delta); + //if the particle died during the update, then don't bother + if (lerp >= 0 && this.path) { + //increase linear movement based on speed + var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; + this.movement += speed * delta; + //set up the helper point for rotation + helperPoint$1.x = this.movement; + helperPoint$1.y = this.path(this.movement); + exports.ParticleUtils.rotatePoint(this.initialRotation, helperPoint$1); + this.position.x = this.initialPosition.x + helperPoint$1.x; + this.position.y = this.initialPosition.y + helperPoint$1.y; + } + return lerp; + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + PathParticle.prototype.destroy = function () { + this.Particle_destroy(); + this.path = this.initialPosition = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. This just runs Particle.parseArt(). + * @param art The array of art data. For Particle, it should be an array of + * Textures. Any strings in the array will be converted to + * Textures via Texture.fromImage(). + * @return The art, after any needed modifications. + */ + PathParticle.parseArt = function (art) { + return Particle.parseArt(art); + }; + /** + * Parses extra emitter data to ensure it is set up for this particle class. + * PathParticle checks for the existence of path data, and parses the path data for use + * by particle instances. + * @param extraData The extra data from the particle config. + * @return The parsed extra data. + */ + PathParticle.parseData = function (extraData) { + var output = {}; + if (extraData && extraData.path) { + try { + output.path = parsePath(extraData.path); + } + catch (e) { + if (exports.ParticleUtils.verbose) + console.error("PathParticle: error in parsing path expression"); + output.path = null; + } + } + else { + if (exports.ParticleUtils.verbose) + console.error("PathParticle requires a path string in extraData!"); + output.path = null; + } + return output; + }; + return PathParticle; }(Particle)); - /** - * An individual particle image with an animation. Art data passed to the emitter must be - * formatted in a particular way for AnimatedParticle to be able to handle it: - * - * ```typescript - * { - * //framerate is required. It is the animation speed of the particle in frames per - * //second. - * //A value of "matchLife" causes the animation to match the lifetime of an individual - * //particle, instead of at a constant framerate. This causes the animation to play - * //through one time, completing when the particle expires. - * framerate: 6, - * //loop is optional, and defaults to false. - * loop: true, - * //textures is required, and can be an array of any (non-zero) length. - * textures: [ - * //each entry represents a single texture that should be used for one or more - * //frames. Any strings will be converted to Textures with Texture.from(). - * //Instances of PIXI.Texture will be used directly. - * "animFrame1.png", - * //entries can be an object with a 'count' property, telling AnimatedParticle to - * //use that texture for 'count' frames sequentially. - * { - * texture: "animFrame2.png", - * count: 3 - * }, - * "animFrame3.png" - * ] - * } - * ``` - */ - var AnimatedParticle = /** @class */ (function (_super) { - __extends(AnimatedParticle, _super); - /** - * @param emitter The emitter that controls this AnimatedParticle. - */ - function AnimatedParticle(emitter) { - var _this = _super.call(this, emitter) || this; - _this.textures = null; - _this.duration = 0; - _this.framerate = 0; - _this.elapsed = 0; - _this.loop = false; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - AnimatedParticle.prototype.init = function () { - this.Particle_init(); - this.elapsed = 0; - //if the animation needs to match the particle's life, then cacluate variables - if (this.framerate < 0) { - this.duration = this.maxLife; - this.framerate = this.textures.length / this.duration; - } - }; - /** - * Sets the textures for the particle. - * @param art An array of PIXI.Texture objects for this animated particle. - */ - AnimatedParticle.prototype.applyArt = function (art) { - this.textures = art.textures; - this.framerate = art.framerate; - this.duration = art.duration; - this.loop = art.loop; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - AnimatedParticle.prototype.update = function (delta) { - var lerp = this.Particle_update(delta); - //only animate the particle if it is still alive - if (lerp >= 0) { - this.elapsed += delta; - if (this.elapsed > this.duration) { - //loop elapsed back around - if (this.loop) - this.elapsed = this.elapsed % this.duration; - //subtract a small amount to prevent attempting to go past the end of the animation - else - this.elapsed = this.duration - 0.000001; - } - // add a very small number to the frame and then floor it to avoid - // the frame being one short due to floating point errors. - var frame = (this.elapsed * this.framerate + 0.0000001) | 0; - this.texture = this.textures[frame] || pixi.Texture.EMPTY; - } - return lerp; - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - AnimatedParticle.prototype.destroy = function () { - this.Particle_destroy(); - this.textures = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. - * @param art The array of art data, properly formatted for AnimatedParticle. - * @return The art, after any needed modifications. - */ - AnimatedParticle.parseArt = function (art) { - var data, output, textures, tex, outTextures; - var outArr = []; - for (var i = 0; i < art.length; ++i) { - data = art[i]; - outArr[i] = output = {}; - output.textures = outTextures = []; - textures = data.textures; - for (var j = 0; j < textures.length; ++j) { - tex = textures[j]; - if (typeof tex == "string") - outTextures.push(GetTextureFromString(tex)); - else if (tex instanceof pixi.Texture) - outTextures.push(tex); - //assume an object with extra data determining duplicate frame data - else { - var dupe = tex.count || 1; - if (typeof tex.texture == "string") - tex = GetTextureFromString(tex.texture); - else // if(tex.texture instanceof Texture) - tex = tex.texture; - for (; dupe > 0; --dupe) { - outTextures.push(tex); - } - } - } - //use these values to signify that the animation should match the particle life time. - if (data.framerate == "matchLife") { - //-1 means that it should be calculated - output.framerate = -1; - output.duration = 0; - output.loop = false; - } - else { - //determine if the animation should loop - output.loop = !!data.loop; - //get the framerate, default to 60 - output.framerate = data.framerate > 0 ? data.framerate : 60; - //determine the duration - output.duration = outTextures.length / output.framerate; - } - } - return outArr; - }; - return AnimatedParticle; + /** + * An individual particle image with an animation. Art data passed to the emitter must be + * formatted in a particular way for AnimatedParticle to be able to handle it: + * + * ```typescript + * { + * //framerate is required. It is the animation speed of the particle in frames per + * //second. + * //A value of "matchLife" causes the animation to match the lifetime of an individual + * //particle, instead of at a constant framerate. This causes the animation to play + * //through one time, completing when the particle expires. + * framerate: 6, + * //loop is optional, and defaults to false. + * loop: true, + * //textures is required, and can be an array of any (non-zero) length. + * textures: [ + * //each entry represents a single texture that should be used for one or more + * //frames. Any strings will be converted to Textures with Texture.from(). + * //Instances of PIXI.Texture will be used directly. + * "animFrame1.png", + * //entries can be an object with a 'count' property, telling AnimatedParticle to + * //use that texture for 'count' frames sequentially. + * { + * texture: "animFrame2.png", + * count: 3 + * }, + * "animFrame3.png" + * ] + * } + * ``` + */ + var AnimatedParticle = /** @class */ (function (_super) { + __extends(AnimatedParticle, _super); + /** + * @param emitter The emitter that controls this AnimatedParticle. + */ + function AnimatedParticle(emitter) { + var _this = _super.call(this, emitter) || this; + _this.textures = null; + _this.duration = 0; + _this.framerate = 0; + _this.elapsed = 0; + _this.loop = false; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + AnimatedParticle.prototype.init = function () { + this.Particle_init(); + this.elapsed = 0; + //if the animation needs to match the particle's life, then cacluate variables + if (this.framerate < 0) { + this.duration = this.maxLife; + this.framerate = this.textures.length / this.duration; + } + }; + /** + * Sets the textures for the particle. + * @param art An array of PIXI.Texture objects for this animated particle. + */ + AnimatedParticle.prototype.applyArt = function (art) { + this.textures = art.textures; + this.framerate = art.framerate; + this.duration = art.duration; + this.loop = art.loop; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + AnimatedParticle.prototype.update = function (delta) { + var lerp = this.Particle_update(delta); + //only animate the particle if it is still alive + if (lerp >= 0) { + this.elapsed += delta; + if (this.elapsed > this.duration) { + //loop elapsed back around + if (this.loop) + this.elapsed = this.elapsed % this.duration; + //subtract a small amount to prevent attempting to go past the end of the animation + else + this.elapsed = this.duration - 0.000001; + } + // add a very small number to the frame and then floor it to avoid + // the frame being one short due to floating point errors. + var frame = (this.elapsed * this.framerate + 0.0000001) | 0; + this.texture = this.textures[frame] || pixi.Texture.EMPTY; + } + return lerp; + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + AnimatedParticle.prototype.destroy = function () { + this.Particle_destroy(); + this.textures = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. + * @param art The array of art data, properly formatted for AnimatedParticle. + * @return The art, after any needed modifications. + */ + AnimatedParticle.parseArt = function (art) { + var data, output, textures, tex, outTextures; + var outArr = []; + for (var i = 0; i < art.length; ++i) { + data = art[i]; + outArr[i] = output = {}; + output.textures = outTextures = []; + textures = data.textures; + for (var j = 0; j < textures.length; ++j) { + tex = textures[j]; + if (typeof tex == "string") + outTextures.push(GetTextureFromString(tex)); + else if (tex instanceof pixi.Texture) + outTextures.push(tex); + //assume an object with extra data determining duplicate frame data + else { + var dupe = tex.count || 1; + if (typeof tex.texture == "string") + tex = GetTextureFromString(tex.texture); + else // if(tex.texture instanceof Texture) + tex = tex.texture; + for (; dupe > 0; --dupe) { + outTextures.push(tex); + } + } + } + //use these values to signify that the animation should match the particle life time. + if (data.framerate == "matchLife") { + //-1 means that it should be calculated + output.framerate = -1; + output.duration = 0; + output.loop = false; + } + else { + //determine if the animation should loop + output.loop = !!data.loop; + //get the framerate, default to 60 + output.framerate = data.framerate > 0 ? data.framerate : 60; + //determine the duration + output.duration = outTextures.length / output.framerate; + } + } + return outArr; + }; + return AnimatedParticle; }(Particle)); exports.GetTextureFromString = GetTextureFromString; @@ -51189,3654 +51189,3654 @@ this.PIXI = this.PIXI || {}; }(this.PIXI.particles = this.PIXI.particles || {}, PIXI)); -var pixi_projection; -(function (pixi_projection) { - var utils; - (function (utils) { - function getIntersectionFactor(p1, p2, p3, p4, out) { - var A1 = p2.x - p1.x, B1 = p3.x - p4.x, C1 = p3.x - p1.x; - var A2 = p2.y - p1.y, B2 = p3.y - p4.y, C2 = p3.y - p1.y; - var D = A1 * B2 - A2 * B1; - if (Math.abs(D) < 1e-7) { - out.x = A1; - out.y = A2; - return 0; - } - var T = C1 * B2 - C2 * B1; - var U = A1 * C2 - A2 * C1; - var t = T / D, u = U / D; - if (u < (1e-6) || u - 1 > -1e-6) { - return -1; - } - out.x = p1.x + t * (p2.x - p1.x); - out.y = p1.y + t * (p2.y - p1.y); - return 1; - } - utils.getIntersectionFactor = getIntersectionFactor; - function getPositionFromQuad(p, anchor, out) { - out = out || new PIXI.Point(); - var a1 = 1.0 - anchor.x, a2 = 1.0 - a1; - var b1 = 1.0 - anchor.y, b2 = 1.0 - b1; - out.x = (p[0].x * a1 + p[1].x * a2) * b1 + (p[3].x * a1 + p[2].x * a2) * b2; - out.y = (p[0].y * a1 + p[1].y * a2) * b1 + (p[3].y * a1 + p[2].y * a2) * b2; - return out; - } - utils.getPositionFromQuad = getPositionFromQuad; - })(utils = pixi_projection.utils || (pixi_projection.utils = {})); -})(pixi_projection || (pixi_projection = {})); -PIXI.projection = pixi_projection; -var pixi_projection; -(function (pixi_projection) { - var AbstractProjection = (function () { - function AbstractProjection(legacy, enable) { - if (enable === void 0) { enable = true; } - this._enabled = false; - this.legacy = legacy; - if (enable) { - this.enabled = true; - } - this.legacy.proj = this; - } - Object.defineProperty(AbstractProjection.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this._enabled = value; - }, - enumerable: true, - configurable: true - }); - AbstractProjection.prototype.clear = function () { - }; - return AbstractProjection; - }()); - pixi_projection.AbstractProjection = AbstractProjection; - var TRANSFORM_STEP; - (function (TRANSFORM_STEP) { - TRANSFORM_STEP[TRANSFORM_STEP["NONE"] = 0] = "NONE"; - TRANSFORM_STEP[TRANSFORM_STEP["BEFORE_PROJ"] = 4] = "BEFORE_PROJ"; - TRANSFORM_STEP[TRANSFORM_STEP["PROJ"] = 5] = "PROJ"; - TRANSFORM_STEP[TRANSFORM_STEP["ALL"] = 9] = "ALL"; - })(TRANSFORM_STEP = pixi_projection.TRANSFORM_STEP || (pixi_projection.TRANSFORM_STEP = {})); -})(pixi_projection || (pixi_projection = {})); -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var pixi_projection; -(function (pixi_projection) { - function transformHack(parentTransform) { - var proj = this.proj; - var ta = this; - var pwid = parentTransform._worldID; - var lt = ta.localTransform; - var scaleAfterAffine = proj.scaleAfterAffine && proj.affine >= 2; - if (ta._localID !== ta._currentLocalID) { - if (scaleAfterAffine) { - lt.a = ta._cx; - lt.b = ta._sx; - lt.c = ta._cy; - lt.d = ta._sy; - lt.tx = ta.position._x; - lt.ty = ta.position._y; - } - else { - lt.a = ta._cx * ta.scale._x; - lt.b = ta._sx * ta.scale._x; - lt.c = ta._cy * ta.scale._y; - lt.d = ta._sy * ta.scale._y; - lt.tx = ta.position._x - ((ta.pivot._x * lt.a) + (ta.pivot._y * lt.c)); - lt.ty = ta.position._y - ((ta.pivot._x * lt.b) + (ta.pivot._y * lt.d)); - } - ta._currentLocalID = ta._localID; - proj._currentProjID = -1; - } - var _matrixID = proj._projID; - if (proj._currentProjID !== _matrixID) { - proj._currentProjID = _matrixID; - proj.updateLocalTransform(lt); - ta._parentID = -1; - } - if (ta._parentID !== pwid) { - var pp = parentTransform.proj; - if (pp && !pp._affine) { - proj.world.setToMult(pp.world, proj.local); - } - else { - proj.world.setToMultLegacy(parentTransform.worldTransform, proj.local); - } - var wa = ta.worldTransform; - proj.world.copyTo(wa, proj._affine, proj.affinePreserveOrientation); - if (scaleAfterAffine) { - wa.a *= ta.scale._x; - wa.b *= ta.scale._x; - wa.c *= ta.scale._y; - wa.d *= ta.scale._y; - wa.tx -= ((ta.pivot._x * wa.a) + (ta.pivot._y * wa.c)); - wa.ty -= ((ta.pivot._x * wa.b) + (ta.pivot._y * wa.d)); - } - ta._parentID = pwid; - ta._worldID++; - } - } - var LinearProjection = (function (_super) { - __extends(LinearProjection, _super); - function LinearProjection() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._projID = 0; - _this._currentProjID = -1; - _this._affine = pixi_projection.AFFINE.NONE; - _this.affinePreserveOrientation = false; - _this.scaleAfterAffine = true; - return _this; - } - LinearProjection.prototype.updateLocalTransform = function (lt) { - }; - Object.defineProperty(LinearProjection.prototype, "affine", { - get: function () { - return this._affine; - }, - set: function (value) { - if (this._affine == value) - return; - this._affine = value; - this._currentProjID = -1; - this.legacy._currentLocalID = -1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearProjection.prototype, "enabled", { - set: function (value) { - if (value === this._enabled) { - return; - } - this._enabled = value; - if (value) { - this.legacy.updateTransform = transformHack; - this.legacy._parentID = -1; - } - else { - this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; - this.legacy._parentID = -1; - } - }, - enumerable: true, - configurable: true - }); - LinearProjection.prototype.clear = function () { - this._currentProjID = -1; - this._projID = 0; - }; - return LinearProjection; - }(pixi_projection.AbstractProjection)); - pixi_projection.LinearProjection = LinearProjection; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var TYPES = PIXI.TYPES; - var premultiplyTint = PIXI.utils.premultiplyTint; - var shaderVert = "precision highp float;\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * aVertexPosition;\n gl_Position.z = 0.0;\n \n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n"; - var shaderFrag = "\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\nvec4 color;\n%forloop%\ngl_FragColor = color * vColor;\n}"; - var Batch3dGeometry = (function (_super) { - __extends(Batch3dGeometry, _super); - function Batch3dGeometry(_static) { - if (_static === void 0) { _static = false; } - var _this = _super.call(this) || this; - _this._buffer = new PIXI.Buffer(null, _static, false); - _this._indexBuffer = new PIXI.Buffer(null, _static, true); - _this.addAttribute('aVertexPosition', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aTextureCoord', _this._buffer, 2, false, TYPES.FLOAT) - .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) - .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT) - .addIndex(_this._indexBuffer); - return _this; - } - return Batch3dGeometry; - }(PIXI.Geometry)); - pixi_projection.Batch3dGeometry = Batch3dGeometry; - var Batch2dPluginFactory = (function () { - function Batch2dPluginFactory() { - } - Batch2dPluginFactory.create = function (options) { - var _a = Object.assign({ - vertex: shaderVert, - fragment: shaderFrag, - geometryClass: Batch3dGeometry, - vertexSize: 7, - }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; - return (function (_super) { - __extends(BatchPlugin, _super); - function BatchPlugin(renderer) { - var _this = _super.call(this, renderer) || this; - _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); - _this.geometryClass = geometryClass; - _this.vertexSize = vertexSize; - return _this; - } - BatchPlugin.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) { - var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View; - var p = aIndex / this.vertexSize; - var uvs = element.uvs; - var indicies = element.indices; - var vertexData = element.vertexData; - var vertexData2d = element.vertexData2d; - var textureId = element._texture.baseTexture._id; - var alpha = Math.min(element.worldAlpha, 1.0); - var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) - : element._tintRGB + (alpha * 255 << 24); - if (vertexData2d) { - var j = 0; - for (var i = 0; i < vertexData2d.length; i += 3, j += 2) { - float32View[aIndex++] = vertexData2d[i]; - float32View[aIndex++] = vertexData2d[i + 1]; - float32View[aIndex++] = vertexData2d[i + 2]; - float32View[aIndex++] = uvs[j]; - float32View[aIndex++] = uvs[j + 1]; - uint32View[aIndex++] = argb; - float32View[aIndex++] = textureId; - } - } - else { - for (var i = 0; i < vertexData.length; i += 2) { - float32View[aIndex++] = vertexData[i]; - float32View[aIndex++] = vertexData[i + 1]; - float32View[aIndex++] = 1.0; - float32View[aIndex++] = uvs[i]; - float32View[aIndex++] = uvs[i + 1]; - uint32View[aIndex++] = argb; - float32View[aIndex++] = textureId; - } - } - for (var i = 0; i < indicies.length; i++) { - indexBuffer[iIndex++] = p + indicies[i]; - } - }; - return BatchPlugin; - }(PIXI.AbstractBatchRenderer)); - }; - return Batch2dPluginFactory; - }()); - pixi_projection.Batch2dPluginFactory = Batch2dPluginFactory; - PIXI.Renderer.registerPlugin('batch2d', Batch2dPluginFactory.create({})); -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var UniformBatchRenderer = (function (_super) { - __extends(UniformBatchRenderer, _super); - function UniformBatchRenderer() { - return _super !== null && _super.apply(this, arguments) || this; - } - UniformBatchRenderer.prototype.addToBatch = function (sprite) { - }; - return UniformBatchRenderer; - }(PIXI.AbstractBatchRenderer)); - pixi_projection.UniformBatchRenderer = UniformBatchRenderer; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var p = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; - var a = [0, 0, 0, 0]; - var Surface = (function () { - function Surface() { - this.surfaceID = "default"; - this._updateID = 0; - this.vertexSrc = ""; - this.fragmentSrc = ""; - } - Surface.prototype.fillUniforms = function (uniforms) { - }; - Surface.prototype.clear = function () { - }; - Surface.prototype.boundsQuad = function (v, out, after) { - var minX = out[0], minY = out[1]; - var maxX = out[0], maxY = out[1]; - for (var i = 2; i < 8; i += 2) { - if (minX > out[i]) - minX = out[i]; - if (maxX < out[i]) - maxX = out[i]; - if (minY > out[i + 1]) - minY = out[i + 1]; - if (maxY < out[i + 1]) - maxY = out[i + 1]; - } - p[0].set(minX, minY); - this.apply(p[0], p[0]); - p[1].set(maxX, minY); - this.apply(p[1], p[1]); - p[2].set(maxX, maxY); - this.apply(p[2], p[2]); - p[3].set(minX, maxY); - this.apply(p[3], p[3]); - if (after) { - after.apply(p[0], p[0]); - after.apply(p[1], p[1]); - after.apply(p[2], p[2]); - after.apply(p[3], p[3]); - out[0] = p[0].x; - out[1] = p[0].y; - out[2] = p[1].x; - out[3] = p[1].y; - out[4] = p[2].x; - out[5] = p[2].y; - out[6] = p[3].x; - out[7] = p[3].y; - } - else { - for (var i = 1; i <= 3; i++) { - if (p[i].y < p[0].y || p[i].y == p[0].y && p[i].x < p[0].x) { - var t = p[0]; - p[0] = p[i]; - p[i] = t; - } - } - for (var i = 1; i <= 3; i++) { - a[i] = Math.atan2(p[i].y - p[0].y, p[i].x - p[0].x); - } - for (var i = 1; i <= 3; i++) { - for (var j = i + 1; j <= 3; j++) { - if (a[i] > a[j]) { - var t = p[i]; - p[i] = p[j]; - p[j] = t; - var t2 = a[i]; - a[i] = a[j]; - a[j] = t2; - } - } - } - out[0] = p[0].x; - out[1] = p[0].y; - out[2] = p[1].x; - out[3] = p[1].y; - out[4] = p[2].x; - out[5] = p[2].y; - out[6] = p[3].x; - out[7] = p[3].y; - if ((p[3].x - p[2].x) * (p[1].y - p[2].y) - (p[1].x - p[2].x) * (p[3].y - p[2].y) < 0) { - out[4] = p[3].x; - out[5] = p[3].y; - return; - } - } - }; - return Surface; - }()); - pixi_projection.Surface = Surface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempMat = new PIXI.Matrix(); - var tempRect = new PIXI.Rectangle(); - var tempPoint = new PIXI.Point(); - var BilinearSurface = (function (_super) { - __extends(BilinearSurface, _super); - function BilinearSurface() { - var _this = _super.call(this) || this; - _this.distortion = new PIXI.Point(); - return _this; - } - BilinearSurface.prototype.clear = function () { - this.distortion.set(0, 0); - }; - BilinearSurface.prototype.apply = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var d = this.distortion; - var m = pos.x * pos.y; - newPos.x = pos.x + d.x * m; - newPos.y = pos.y + d.y * m; - return newPos; - }; - BilinearSurface.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var vx = pos.x, vy = pos.y; - var dx = this.distortion.x, dy = this.distortion.y; - if (dx == 0.0) { - newPos.x = vx; - newPos.y = vy / (1.0 + dy * vx); - } - else if (dy == 0.0) { - newPos.y = vy; - newPos.x = vx / (1.0 + dx * vy); - } - else { - var b = (vy * dx - vx * dy + 1.0) * 0.5 / dy; - var d = b * b + vx / dy; - if (d <= 0.00001) { - newPos.set(NaN, NaN); - return; - } - if (dy > 0.0) { - newPos.x = -b + Math.sqrt(d); - } - else { - newPos.x = -b - Math.sqrt(d); - } - newPos.y = (vx / newPos.x - 1.0) / dx; - } - return newPos; - }; - BilinearSurface.prototype.mapSprite = function (sprite, quad, outTransform) { - var tex = sprite.texture; - tempRect.x = -sprite.anchor.x * tex.orig.width; - tempRect.y = -sprite.anchor.y * tex.orig.height; - tempRect.width = tex.orig.width; - tempRect.height = tex.orig.height; - return this.mapQuad(tempRect, quad, outTransform || sprite.transform); - }; - BilinearSurface.prototype.mapQuad = function (rect, quad, outTransform) { - var ax = -rect.x / rect.width; - var ay = -rect.y / rect.height; - var ax2 = (1.0 - rect.x) / rect.width; - var ay2 = (1.0 - rect.y) / rect.height; - var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax); - var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax); - var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2); - var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2); - var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax); - var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax); - var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2); - var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2); - var x00 = up1x * (1.0 - ay) + down1x * ay; - var y00 = up1y * (1.0 - ay) + down1y * ay; - var x10 = up2x * (1.0 - ay) + down2x * ay; - var y10 = up2y * (1.0 - ay) + down2y * ay; - var x01 = up1x * (1.0 - ay2) + down1x * ay2; - var y01 = up1y * (1.0 - ay2) + down1y * ay2; - var x11 = up2x * (1.0 - ay2) + down2x * ay2; - var y11 = up2y * (1.0 - ay2) + down2y * ay2; - var mat = tempMat; - mat.tx = x00; - mat.ty = y00; - mat.a = x10 - x00; - mat.b = y10 - y00; - mat.c = x01 - x00; - mat.d = y01 - y00; - tempPoint.set(x11, y11); - mat.applyInverse(tempPoint, tempPoint); - this.distortion.set(tempPoint.x - 1, tempPoint.y - 1); - outTransform.setFromMatrix(mat); - return this; - }; - BilinearSurface.prototype.fillUniforms = function (uniforms) { - uniforms.distortion = uniforms.distortion || new Float32Array([0, 0, 0, 0]); - var ax = Math.abs(this.distortion.x); - var ay = Math.abs(this.distortion.y); - uniforms.distortion[0] = ax * 10000 <= ay ? 0 : this.distortion.x; - uniforms.distortion[1] = ay * 10000 <= ax ? 0 : this.distortion.y; - uniforms.distortion[2] = 1.0 / uniforms.distortion[0]; - uniforms.distortion[3] = 1.0 / uniforms.distortion[1]; - }; - return BilinearSurface; - }(pixi_projection.Surface)); - pixi_projection.BilinearSurface = BilinearSurface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Container2s = (function (_super) { - __extends(Container2s, _super); - function Container2s() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - return _this; - } - Object.defineProperty(Container2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Container2s; - }(PIXI.Container)); - pixi_projection.Container2s = Container2s; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var fun = PIXI.Transform.prototype.updateTransform; - function transformHack(parentTransform) { - var proj = this.proj; - var pp = parentTransform.proj; - var ta = this; - if (!pp) { - fun.call(this, parentTransform); - proj._activeProjection = null; - return; - } - if (pp._surface) { - proj._activeProjection = pp; - this.updateLocalTransform(); - this.localTransform.copyFrom(this.worldTransform); - if (ta._parentID < 0) { - ++ta._worldID; - } - return; - } - fun.call(this, parentTransform); - proj._activeProjection = pp._activeProjection; - } - var ProjectionSurface = (function (_super) { - __extends(ProjectionSurface, _super); - function ProjectionSurface(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this._surface = null; - _this._activeProjection = null; - _this._currentSurfaceID = -1; - _this._currentLegacyID = -1; - _this._lastUniforms = null; - return _this; - } - Object.defineProperty(ProjectionSurface.prototype, "enabled", { - set: function (value) { - if (value === this._enabled) { - return; - } - this._enabled = value; - if (value) { - this.legacy.updateTransform = transformHack; - this.legacy._parentID = -1; - } - else { - this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; - this.legacy._parentID = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ProjectionSurface.prototype, "surface", { - get: function () { - return this._surface; - }, - set: function (value) { - if (this._surface == value) { - return; - } - this._surface = value || null; - this.legacy._parentID = -1; - }, - enumerable: true, - configurable: true - }); - ProjectionSurface.prototype.applyPartial = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this.legacy.worldTransform.apply(pos, newPos); - return this._activeProjection.surface.apply(newPos, newPos); - } - if (this._surface !== null) { - return this.surface.apply(pos, newPos); - } - return this.legacy.worldTransform.apply(pos, newPos); - }; - ProjectionSurface.prototype.apply = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this.legacy.worldTransform.apply(pos, newPos); - this._activeProjection.surface.apply(newPos, newPos); - return this._activeProjection.legacy.worldTransform.apply(newPos, newPos); - } - if (this._surface !== null) { - newPos = this.surface.apply(pos, newPos); - return this.legacy.worldTransform.apply(newPos, newPos); - } - return this.legacy.worldTransform.apply(pos, newPos); - }; - ProjectionSurface.prototype.applyInverse = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this._activeProjection.legacy.worldTransform.applyInverse(pos, newPos); - this._activeProjection._surface.applyInverse(newPos, newPos); - return this.legacy.worldTransform.applyInverse(newPos, newPos); - } - if (this._surface !== null) { - newPos = this.legacy.worldTransform.applyInverse(pos, newPos); - return this._surface.applyInverse(newPos, newPos); - } - return this.legacy.worldTransform.applyInverse(pos, newPos); - }; - ProjectionSurface.prototype.mapBilinearSprite = function (sprite, quad) { - if (!(this._surface instanceof pixi_projection.BilinearSurface)) { - this.surface = new pixi_projection.BilinearSurface(); - } - this.surface.mapSprite(sprite, quad, this.legacy); - }; - ProjectionSurface.prototype.clear = function () { - if (this.surface) { - this.surface.clear(); - } - }; - Object.defineProperty(ProjectionSurface.prototype, "uniforms", { - get: function () { - if (this._currentLegacyID === this.legacy._worldID && - this._currentSurfaceID === this.surface._updateID) { - return this._lastUniforms; - } - this._lastUniforms = this._lastUniforms || {}; - this._lastUniforms.worldTransform = this.legacy.worldTransform.toArray(true); - this._surface.fillUniforms(this._lastUniforms); - return this._lastUniforms; - }, - enumerable: true, - configurable: true - }); - return ProjectionSurface; - }(pixi_projection.AbstractProjection)); - pixi_projection.ProjectionSurface = ProjectionSurface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var TYPES = PIXI.TYPES; - var premultiplyTint = PIXI.utils.premultiplyTint; - var shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n"; - var shaderFrag = "precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 distortion;\n\nvoid main(void){\nvec2 surface;\nvec2 surface2;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat dx = distortion.x;\nfloat dy = distortion.y;\nfloat revx = distortion.z;\nfloat revy = distortion.w;\n\nif (distortion.x == 0.0) {\n surface.x = vx;\n surface.y = vy / (1.0 + dy * vx);\n surface2 = surface;\n} else\nif (distortion.y == 0.0) {\n surface.y = vy;\n surface.x = vx/ (1.0 + dx * vy);\n surface2 = surface;\n} else {\n float c = vy * dx - vx * dy;\n float b = (c + 1.0) * 0.5;\n float b2 = (-c + 1.0) * 0.5;\n float d = b * b + vx * dy;\n if (d < -0.00001) {\n discard;\n }\n d = sqrt(max(d, 0.0));\n surface.x = (- b + d) * revy;\n surface2.x = (- b - d) * revy;\n surface.y = (- b2 + d) * revx;\n surface2.y = (- b2 - d) * revx;\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nif (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\n%forloop%\ngl_FragColor = color * rColor;\n}"; - var BatchBilineardGeometry = (function (_super) { - __extends(BatchBilineardGeometry, _super); - function BatchBilineardGeometry(_static) { - if (_static === void 0) { _static = false; } - var _this = _super.call(this) || this; - _this._buffer = new PIXI.Buffer(null, _static, false); - _this._indexBuffer = new PIXI.Buffer(null, _static, true); - _this.addAttribute('aVertexPosition', _this._buffer, 2, false, TYPES.FLOAT) - .addAttribute('aTrans1', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aTrans2', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aFrame', _this._buffer, 4, false, TYPES.FLOAT) - .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) - .addIndex(_this._indexBuffer); - return _this; - } - return BatchBilineardGeometry; - }(PIXI.Geometry)); - pixi_projection.BatchBilineardGeometry = BatchBilineardGeometry; - var BatchBilinearPluginFactory = (function () { - function BatchBilinearPluginFactory() { - } - BatchBilinearPluginFactory.create = function (options) { - var _a = Object.assign({ - vertex: shaderVert, - fragment: shaderFrag, - geometryClass: pixi_projection.Batch3dGeometry, - vertexSize: 7, - }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; - return (function (_super) { - __extends(BatchPlugin, _super); - function BatchPlugin(renderer) { - var _this = _super.call(this, renderer) || this; - _this.defUniforms = { - worldTransform: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]), - distortion: new Float32Array([0, 0]) - }; - _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); - _this.geometryClass = geometryClass; - _this.vertexSize = vertexSize; - return _this; - } - BatchPlugin.prototype.getUniforms = function (sprite) { - var proj = sprite.proj; - var shader = this._shader; - if (proj.surface !== null) { - return proj.uniforms; - } - if (proj._activeProjection !== null) { - return proj._activeProjection.uniforms; - } - return this.defUniforms; - }; - BatchPlugin.prototype.packGeometry = function (element, float32View, uint32View, indexBuffer, index, indexCount) { - var p = index / this.vertexSize; - var uvs = element.uvs; - var indices = element.indices; - var vertexData = element.vertexData; - var tex = element._texture; - var frame = tex._frame; - var aTrans = element.aTrans; - var alpha = Math.min(element.worldAlpha, 1.0); - var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) - : element._tintRGB + (alpha * 255 << 24); - for (var i = 0; i < vertexData.length; i += 2) { - float32View[index] = vertexData[i * 2]; - float32View[index + 1] = vertexData[i * 2 + 1]; - float32View[index + 2] = aTrans.a; - float32View[index + 3] = aTrans.c; - float32View[index + 4] = aTrans.tx; - float32View[index + 5] = aTrans.b; - float32View[index + 6] = aTrans.d; - float32View[index + 7] = aTrans.ty; - float32View[index + 8] = frame.x; - float32View[index + 9] = frame.y; - float32View[index + 10] = frame.x + frame.width; - float32View[index + 11] = frame.y + frame.height; - uint32View[index + 12] = argb; - index += 13; - } - for (var i = 0; i < indices.length; i++) { - indexBuffer[indexCount++] = p + indices[i]; - } - }; - return BatchPlugin; - }(PIXI.AbstractBatchRenderer)); - }; - return BatchBilinearPluginFactory; - }()); - pixi_projection.BatchBilinearPluginFactory = BatchBilinearPluginFactory; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite2s = (function (_super) { - __extends(Sprite2s, _super); - function Sprite2s(texture) { - var _this = _super.call(this, texture) || this; - _this.aTrans = new PIXI.Matrix(); - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - _this.pluginName = 'batch_bilinear'; - return _this; - } - Sprite2s.prototype._calculateBounds = function () { - this.calculateTrimmedVertices(); - this._bounds.addQuad(this.vertexTrimmedData); - }; - Sprite2s.prototype.calculateVertices = function () { - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - this._transformID = wid; - this._textureID = tuid; - var texture = this._texture; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - if (this.proj._surface) { - vertexData[0] = w1; - vertexData[1] = h1; - vertexData[2] = w0; - vertexData[3] = h1; - vertexData[4] = w0; - vertexData[5] = h0; - vertexData[6] = w1; - vertexData[7] = h0; - this.proj._surface.boundsQuad(vertexData, vertexData); - } - else { - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - vertexData[0] = (a * w1) + (c * h1) + tx; - vertexData[1] = (d * h1) + (b * w1) + ty; - vertexData[2] = (a * w0) + (c * h1) + tx; - vertexData[3] = (d * h1) + (b * w0) + ty; - vertexData[4] = (a * w0) + (c * h0) + tx; - vertexData[5] = (d * h0) + (b * w0) + ty; - vertexData[6] = (a * w1) + (c * h0) + tx; - vertexData[7] = (d * h0) + (b * w1) + ty; - if (this.proj._activeProjection) { - this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData); - } - } - if (!texture.uvMatrix) { - texture.uvMatrix = new PIXI.TextureMatrix(texture); - } - texture.uvMatrix.update(); - var aTrans = this.aTrans; - aTrans.set(orig.width, 0, 0, orig.height, w1, h1); - if (this.proj._surface === null) { - aTrans.prepend(this.transform.worldTransform); - } - aTrans.invert(); - aTrans.prepend(texture.uvMatrix.mapCoord); - }; - Sprite2s.prototype.calculateTrimmedVertices = function () { - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - if (this.proj._surface) { - vertexData[0] = w1; - vertexData[1] = h1; - vertexData[2] = w0; - vertexData[3] = h1; - vertexData[4] = w0; - vertexData[5] = h0; - vertexData[6] = w1; - vertexData[7] = h0; - this.proj._surface.boundsQuad(vertexData, vertexData, this.transform.worldTransform); - } - else { - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - vertexData[0] = (a * w1) + (c * h1) + tx; - vertexData[1] = (d * h1) + (b * w1) + ty; - vertexData[2] = (a * w0) + (c * h1) + tx; - vertexData[3] = (d * h1) + (b * w0) + ty; - vertexData[4] = (a * w0) + (c * h0) + tx; - vertexData[5] = (d * h0) + (b * w0) + ty; - vertexData[6] = (a * w1) + (c * h0) + tx; - vertexData[7] = (d * h0) + (b * w1) + ty; - if (this.proj._activeProjection) { - this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData, this.proj._activeProjection.legacy.worldTransform); - } - } - }; - Object.defineProperty(Sprite2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Sprite2s; - }(PIXI.Sprite)); - pixi_projection.Sprite2s = Sprite2s; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text2s = (function (_super) { - __extends(Text2s, _super); - function Text2s(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.aTrans = new PIXI.Matrix(); - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - _this.pluginName = 'batch_bilinear'; - return _this; - } - Object.defineProperty(Text2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Text2s; - }(PIXI.Text)); - pixi_projection.Text2s = Text2s; - Text2s.prototype.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; - Text2s.prototype.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; - Text2s.prototype._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.Sprite.prototype.convertTo2s = function () { - if (this.proj) - return; - this.pluginName = 'sprite_bilinear'; - this.aTrans = new PIXI.Matrix(); - this.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; - PIXI.Container.prototype.convertTo2s.call(this); - }; - PIXI.Container.prototype.convertTo2s = function () { - if (this.proj) - return; - this.proj = new pixi_projection.Projection2d(this.transform); - Object.defineProperty(this, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - }; - PIXI.Container.prototype.convertSubtreeTo2s = function () { - this.convertTo2s(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo2s(); - } - }; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function container2dWorldTransform() { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - } - pixi_projection.container2dWorldTransform = container2dWorldTransform; - var Container2d = (function (_super) { - __extends(Container2d, _super); - function Container2d() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.Projection2d(_this.transform); - return _this; - } - Container2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - if (from) { - position = from.toGlobal(position, point, skipUpdate); - } - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - } - if (step >= pixi_projection.TRANSFORM_STEP.PROJ) { - if (!skipUpdate) { - this.displayObjectUpdateTransform(); - } - if (this.proj.affine) { - return this.transform.worldTransform.applyInverse(position, point); - } - return this.proj.world.applyInverse(position, point); - } - if (this.parent) { - point = this.parent.worldTransform.applyInverse(position, point); - } - else { - point.copyFrom(position); - } - if (step === pixi_projection.TRANSFORM_STEP.NONE) { - return point; - } - return this.transform.localTransform.applyInverse(point, point); - }; - Object.defineProperty(Container2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Container2d; - }(PIXI.Container)); - pixi_projection.Container2d = Container2d; - pixi_projection.container2dToLocal = Container2d.prototype.toLocal; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Point = PIXI.Point; - var mat3id = [1, 0, 0, 0, 1, 0, 0, 0, 1]; - var AFFINE; - (function (AFFINE) { - AFFINE[AFFINE["NONE"] = 0] = "NONE"; - AFFINE[AFFINE["FREE"] = 1] = "FREE"; - AFFINE[AFFINE["AXIS_X"] = 2] = "AXIS_X"; - AFFINE[AFFINE["AXIS_Y"] = 3] = "AXIS_Y"; - AFFINE[AFFINE["POINT"] = 4] = "POINT"; - AFFINE[AFFINE["AXIS_XR"] = 5] = "AXIS_XR"; - })(AFFINE = pixi_projection.AFFINE || (pixi_projection.AFFINE = {})); - var Matrix2d = (function () { - function Matrix2d(backingArray) { - this.floatArray = null; - this.mat3 = new Float64Array(backingArray || mat3id); - } - Object.defineProperty(Matrix2d.prototype, "a", { - get: function () { - return this.mat3[0] / this.mat3[8]; - }, - set: function (value) { - this.mat3[0] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "b", { - get: function () { - return this.mat3[1] / this.mat3[8]; - }, - set: function (value) { - this.mat3[1] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "c", { - get: function () { - return this.mat3[3] / this.mat3[8]; - }, - set: function (value) { - this.mat3[3] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "d", { - get: function () { - return this.mat3[4] / this.mat3[8]; - }, - set: function (value) { - this.mat3[4] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "tx", { - get: function () { - return this.mat3[6] / this.mat3[8]; - }, - set: function (value) { - this.mat3[6] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "ty", { - get: function () { - return this.mat3[7] / this.mat3[8]; - }, - set: function (value) { - this.mat3[7] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Matrix2d.prototype.set = function (a, b, c, d, tx, ty) { - var mat3 = this.mat3; - mat3[0] = a; - mat3[1] = b; - mat3[2] = 0; - mat3[3] = c; - mat3[4] = d; - mat3[5] = 0; - mat3[6] = tx; - mat3[7] = ty; - mat3[8] = 1; - return this; - }; - Matrix2d.prototype.toArray = function (transpose, out) { - if (!this.floatArray) { - this.floatArray = new Float32Array(9); - } - var array = out || this.floatArray; - var mat3 = this.mat3; - if (transpose) { - array[0] = mat3[0]; - array[1] = mat3[1]; - array[2] = mat3[2]; - array[3] = mat3[3]; - array[4] = mat3[4]; - array[5] = mat3[5]; - array[6] = mat3[6]; - array[7] = mat3[7]; - array[8] = mat3[8]; - } - else { - array[0] = mat3[0]; - array[1] = mat3[3]; - array[2] = mat3[6]; - array[3] = mat3[1]; - array[4] = mat3[4]; - array[5] = mat3[7]; - array[6] = mat3[2]; - array[7] = mat3[5]; - array[8] = mat3[8]; - } - return array; - }; - Matrix2d.prototype.apply = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var mat3 = this.mat3; - var x = pos.x; - var y = pos.y; - var z = 1.0 / (mat3[2] * x + mat3[5] * y + mat3[8]); - newPos.x = z * (mat3[0] * x + mat3[3] * y + mat3[6]); - newPos.y = z * (mat3[1] * x + mat3[4] * y + mat3[7]); - return newPos; - }; - Matrix2d.prototype.translate = function (tx, ty) { - var mat3 = this.mat3; - mat3[0] += tx * mat3[2]; - mat3[1] += ty * mat3[2]; - mat3[3] += tx * mat3[5]; - mat3[4] += ty * mat3[5]; - mat3[6] += tx * mat3[8]; - mat3[7] += ty * mat3[8]; - return this; - }; - Matrix2d.prototype.scale = function (x, y) { - var mat3 = this.mat3; - mat3[0] *= x; - mat3[1] *= y; - mat3[3] *= x; - mat3[4] *= y; - mat3[6] *= x; - mat3[7] *= y; - return this; - }; - Matrix2d.prototype.scaleAndTranslate = function (scaleX, scaleY, tx, ty) { - var mat3 = this.mat3; - mat3[0] = scaleX * mat3[0] + tx * mat3[2]; - mat3[1] = scaleY * mat3[1] + ty * mat3[2]; - mat3[3] = scaleX * mat3[3] + tx * mat3[5]; - mat3[4] = scaleY * mat3[4] + ty * mat3[5]; - mat3[6] = scaleX * mat3[6] + tx * mat3[8]; - mat3[7] = scaleY * mat3[7] + ty * mat3[8]; - }; - Matrix2d.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new Point(); - var a = this.mat3; - var x = pos.x; - var y = pos.y; - var a00 = a[0], a01 = a[3], a02 = a[6], a10 = a[1], a11 = a[4], a12 = a[7], a20 = a[2], a21 = a[5], a22 = a[8]; - var newX = (a22 * a11 - a12 * a21) * x + (-a22 * a01 + a02 * a21) * y + (a12 * a01 - a02 * a11); - var newY = (-a22 * a10 + a12 * a20) * x + (a22 * a00 - a02 * a20) * y + (-a12 * a00 + a02 * a10); - var newZ = (a21 * a10 - a11 * a20) * x + (-a21 * a00 + a01 * a20) * y + (a11 * a00 - a01 * a10); - newPos.x = newX / newZ; - newPos.y = newY / newZ; - return newPos; - }; - Matrix2d.prototype.invert = function () { - var a = this.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b01 = a22 * a11 - a12 * a21, b11 = -a22 * a10 + a12 * a20, b21 = a21 * a10 - a11 * a20; - var det = a00 * b01 + a01 * b11 + a02 * b21; - if (!det) { - return this; - } - det = 1.0 / det; - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - return this; - }; - Matrix2d.prototype.identity = function () { - var mat3 = this.mat3; - mat3[0] = 1; - mat3[1] = 0; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = 1; - mat3[5] = 0; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 1; - return this; - }; - Matrix2d.prototype.clone = function () { - return new Matrix2d(this.mat3); - }; - Matrix2d.prototype.copyTo2dOr3d = function (matrix) { - var mat3 = this.mat3; - var ar2 = matrix.mat3; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[2]; - ar2[3] = mat3[3]; - ar2[4] = mat3[4]; - ar2[5] = mat3[5]; - ar2[6] = mat3[6]; - ar2[7] = mat3[7]; - ar2[8] = mat3[8]; - return matrix; - }; - Matrix2d.prototype.copyTo = function (matrix, affine, preserveOrientation) { - var mat3 = this.mat3; - var d = 1.0 / mat3[8]; - var tx = mat3[6] * d, ty = mat3[7] * d; - matrix.a = (mat3[0] - mat3[2] * tx) * d; - matrix.b = (mat3[1] - mat3[2] * ty) * d; - matrix.c = (mat3[3] - mat3[5] * tx) * d; - matrix.d = (mat3[4] - mat3[5] * ty) * d; - matrix.tx = tx; - matrix.ty = ty; - if (affine >= 2) { - var D = matrix.a * matrix.d - matrix.b * matrix.c; - if (!preserveOrientation) { - D = Math.abs(D); - } - if (affine === AFFINE.POINT) { - if (D > 0) { - D = 1; - } - else - D = -1; - matrix.a = D; - matrix.b = 0; - matrix.c = 0; - matrix.d = D; - } - else if (affine === AFFINE.AXIS_X) { - D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); - matrix.c = 0; - matrix.d = D; - } - else if (affine === AFFINE.AXIS_Y) { - D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); - matrix.a = D; - matrix.c = 0; - } - else if (affine === AFFINE.AXIS_XR) { - matrix.a = matrix.d * D; - matrix.c = -matrix.b * D; - } - } - return matrix; - }; - Matrix2d.prototype.copyFrom = function (matrix) { - var mat3 = this.mat3; - mat3[0] = matrix.a; - mat3[1] = matrix.b; - mat3[2] = 0; - mat3[3] = matrix.c; - mat3[4] = matrix.d; - mat3[5] = 0; - mat3[6] = matrix.tx; - mat3[7] = matrix.ty; - mat3[8] = 1.0; - return this; - }; - Matrix2d.prototype.setToMultLegacy = function (pt, lt) { - var out = this.mat3; - var b = lt.mat3; - var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a20 = pt.tx, a21 = pt.ty, b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b02; - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b12; - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b22; - return this; - }; - Matrix2d.prototype.setToMultLegacy2 = function (pt, lt) { - var out = this.mat3; - var a = pt.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b20 = lt.tx, b21 = lt.ty; - out[0] = b00 * a00 + b01 * a10; - out[1] = b00 * a01 + b01 * a11; - out[2] = b00 * a02 + b01 * a12; - out[3] = b10 * a00 + b11 * a10; - out[4] = b10 * a01 + b11 * a11; - out[5] = b10 * a02 + b11 * a12; - out[6] = b20 * a00 + b21 * a10 + a20; - out[7] = b20 * a01 + b21 * a11 + a21; - out[8] = b20 * a02 + b21 * a12 + a22; - return this; - }; - Matrix2d.prototype.setToMult = function (pt, lt) { - var out = this.mat3; - var a = pt.mat3, b = lt.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b00 * a02 + b01 * a12 + b02 * a22; - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b10 * a02 + b11 * a12 + b12 * a22; - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b20 * a02 + b21 * a12 + b22 * a22; - return this; - }; - Matrix2d.prototype.prepend = function (lt) { - if (lt.mat3) { - return this.setToMult(lt, this); - } - else { - return this.setToMultLegacy(lt, this); - } - }; - Matrix2d.IDENTITY = new Matrix2d(); - Matrix2d.TEMP_MATRIX = new Matrix2d(); - return Matrix2d; - }()); - pixi_projection.Matrix2d = Matrix2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var t0 = new PIXI.Point(); - var tt = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; - var tempRect = new PIXI.Rectangle(); - var tempMat = new pixi_projection.Matrix2d(); - var Projection2d = (function (_super) { - __extends(Projection2d, _super); - function Projection2d(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this.matrix = new pixi_projection.Matrix2d(); - _this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0); - _this.reverseLocalOrder = false; - _this.local = new pixi_projection.Matrix2d(); - _this.world = new pixi_projection.Matrix2d(); - return _this; - } - Projection2d.prototype.onChange = function () { - var pivot = this.pivot; - var mat3 = this.matrix.mat3; - mat3[6] = -(pivot._x * mat3[0] + pivot._y * mat3[3]); - mat3[7] = -(pivot._x * mat3[1] + pivot._y * mat3[4]); - this._projID++; - }; - Projection2d.prototype.setAxisX = function (p, factor) { - if (factor === void 0) { factor = 1; } - var x = p.x, y = p.y; - var d = Math.sqrt(x * x + y * y); - var mat3 = this.matrix.mat3; - mat3[0] = x / d; - mat3[1] = y / d; - mat3[2] = factor / d; - this.onChange(); - }; - Projection2d.prototype.setAxisY = function (p, factor) { - if (factor === void 0) { factor = 1; } - var x = p.x, y = p.y; - var d = Math.sqrt(x * x + y * y); - var mat3 = this.matrix.mat3; - mat3[3] = x / d; - mat3[4] = y / d; - mat3[5] = factor / d; - this.onChange(); - }; - Projection2d.prototype.mapSprite = function (sprite, quad) { - var tex = sprite.texture; - tempRect.x = -sprite.anchor.x * tex.orig.width; - tempRect.y = -sprite.anchor.y * tex.orig.height; - tempRect.width = tex.orig.width; - tempRect.height = tex.orig.height; - return this.mapQuad(tempRect, quad); - }; - Projection2d.prototype.mapQuad = function (rect, p) { - tt[0].set(rect.x, rect.y); - tt[1].set(rect.x + rect.width, rect.y); - tt[2].set(rect.x + rect.width, rect.y + rect.height); - tt[3].set(rect.x, rect.y + rect.height); - var k1 = 1, k2 = 2, k3 = 3; - var f = pixi_projection.utils.getIntersectionFactor(p[0], p[2], p[1], p[3], t0); - if (f !== 0) { - k1 = 1; - k2 = 3; - k3 = 2; - } - else { - return; - } - var d0 = Math.sqrt((p[0].x - t0.x) * (p[0].x - t0.x) + (p[0].y - t0.y) * (p[0].y - t0.y)); - var d1 = Math.sqrt((p[k1].x - t0.x) * (p[k1].x - t0.x) + (p[k1].y - t0.y) * (p[k1].y - t0.y)); - var d2 = Math.sqrt((p[k2].x - t0.x) * (p[k2].x - t0.x) + (p[k2].y - t0.y) * (p[k2].y - t0.y)); - var d3 = Math.sqrt((p[k3].x - t0.x) * (p[k3].x - t0.x) + (p[k3].y - t0.y) * (p[k3].y - t0.y)); - var q0 = (d0 + d3) / d3; - var q1 = (d1 + d2) / d2; - var q2 = (d1 + d2) / d1; - var mat3 = this.matrix.mat3; - mat3[0] = tt[0].x * q0; - mat3[1] = tt[0].y * q0; - mat3[2] = q0; - mat3[3] = tt[k1].x * q1; - mat3[4] = tt[k1].y * q1; - mat3[5] = q1; - mat3[6] = tt[k2].x * q2; - mat3[7] = tt[k2].y * q2; - mat3[8] = q2; - this.matrix.invert(); - mat3 = tempMat.mat3; - mat3[0] = p[0].x; - mat3[1] = p[0].y; - mat3[2] = 1; - mat3[3] = p[k1].x; - mat3[4] = p[k1].y; - mat3[5] = 1; - mat3[6] = p[k2].x; - mat3[7] = p[k2].y; - mat3[8] = 1; - this.matrix.setToMult(tempMat, this.matrix); - this._projID++; - }; - Projection2d.prototype.updateLocalTransform = function (lt) { - if (this._projID !== 0) { - if (this.reverseLocalOrder) { - this.local.setToMultLegacy2(this.matrix, lt); - } - else { - this.local.setToMultLegacy(lt, this.matrix); - } - } - else { - this.local.copyFrom(lt); - } - }; - Projection2d.prototype.clear = function () { - _super.prototype.clear.call(this); - this.matrix.identity(); - this.pivot.set(0, 0); - }; - return Projection2d; - }(pixi_projection.LinearProjection)); - pixi_projection.Projection2d = Projection2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Mesh2d = (function (_super) { - __extends(Mesh2d, _super); - function Mesh2d(geometry, shader, state, drawMode) { - var _this = _super.call(this, geometry, shader, state, drawMode) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - return _this; - } - Mesh2d.prototype.calculateVertices = function () { - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - var geometry = this.geometry; - var vertices = geometry.buffers[0].data; - var thisAny = this; - if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { - return; - } - thisAny._transformID = thisAny.transform._worldID; - if (thisAny.vertexData.length !== vertices.length) { - thisAny.vertexData = new Float32Array(vertices.length); - } - if (this.vertexData2d.length !== vertices.length * 3 / 2) { - this.vertexData2d = new Float32Array(vertices.length * 3); - } - var wt = this.proj.world.mat3; - var vertexData2d = this.vertexData2d; - var vertexData = thisAny.vertexData; - for (var i = 0; i < vertexData.length / 2; i++) { - var x = vertices[(i * 2)]; - var y = vertices[(i * 2) + 1]; - var xx = (wt[0] * x) + (wt[3] * y) + wt[6]; - var yy = (wt[1] * x) + (wt[4] * y) + wt[7]; - var ww = (wt[2] * x) + (wt[5] * y) + wt[8]; - vertexData2d[i * 3] = xx; - vertexData2d[i * 3 + 1] = yy; - vertexData2d[i * 3 + 2] = ww; - vertexData[(i * 2)] = xx / ww; - vertexData[(i * 2) + 1] = yy / ww; - } - thisAny.vertexDirty = geometry.vertexDirtyId; - }; - Mesh2d.prototype._renderDefault = function (renderer) { - var shader = this.shader; - shader.alpha = this.worldAlpha; - if (shader.update) { - shader.update(); - } - renderer.batch.flush(); - if (shader.program.uniformData.translationMatrix) { - shader.uniforms.translationMatrix = this.worldTransform.toArray(true); - } - renderer.shader.bind(shader, false); - renderer.state.set(this.state); - renderer.geometry.bind(this.geometry, shader); - renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount); - }; - Mesh2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Object.defineProperty(Mesh2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Mesh2d.defaultVertexShader = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n"; - Mesh2d.defaultFragmentShader = "\nvarying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}"; - return Mesh2d; - }(PIXI.Mesh)); - pixi_projection.Mesh2d = Mesh2d; - var SimpleMesh2d = (function (_super) { - __extends(SimpleMesh2d, _super); - function SimpleMesh2d(texture, vertices, uvs, indices, drawMode) { - var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { - program: PIXI.Program.from(Mesh2d.defaultVertexShader, Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }), null, drawMode) || this; - _this.autoUpdate = true; - _this.geometry.getBuffer('aVertexPosition').static = false; - return _this; - } - Object.defineProperty(SimpleMesh2d.prototype, "vertices", { - get: function () { - return this.geometry.getBuffer('aVertexPosition').data; - }, - set: function (value) { - this.geometry.getBuffer('aVertexPosition').data = value; - }, - enumerable: true, - configurable: true - }); - SimpleMesh2d.prototype._render = function (renderer) { - if (this.autoUpdate) { - this.geometry.getBuffer('aVertexPosition').update(); - } - _super.prototype._render.call(this, renderer); - }; - return SimpleMesh2d; - }(Mesh2d)); - pixi_projection.SimpleMesh2d = SimpleMesh2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite2d = (function (_super) { - __extends(Sprite2d, _super); - function Sprite2d(texture) { - var _this = _super.call(this, texture) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Sprite2d.prototype._calculateBounds = function () { - this.calculateTrimmedVertices(); - this._bounds.addQuad(this.vertexTrimmedData); - }; - Sprite2d.prototype.calculateVertices = function () { - var texture = this._texture; - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - if (!this.vertexData2d) { - this.vertexData2d = new Float32Array(12); - } - var wid = this.transform._worldID; - var tuid = texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - if (this._textureID !== tuid) { - this.uvs = texture._uvs.uvsFloat32; - } - this._transformID = wid; - this._textureID = tuid; - var wt = this.proj.world.mat3; - var vertexData2d = this.vertexData2d; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - vertexData2d[0] = (wt[0] * w1) + (wt[3] * h1) + wt[6]; - vertexData2d[1] = (wt[1] * w1) + (wt[4] * h1) + wt[7]; - vertexData2d[2] = (wt[2] * w1) + (wt[5] * h1) + wt[8]; - vertexData2d[3] = (wt[0] * w0) + (wt[3] * h1) + wt[6]; - vertexData2d[4] = (wt[1] * w0) + (wt[4] * h1) + wt[7]; - vertexData2d[5] = (wt[2] * w0) + (wt[5] * h1) + wt[8]; - vertexData2d[6] = (wt[0] * w0) + (wt[3] * h0) + wt[6]; - vertexData2d[7] = (wt[1] * w0) + (wt[4] * h0) + wt[7]; - vertexData2d[8] = (wt[2] * w0) + (wt[5] * h0) + wt[8]; - vertexData2d[9] = (wt[0] * w1) + (wt[3] * h0) + wt[6]; - vertexData2d[10] = (wt[1] * w1) + (wt[4] * h0) + wt[7]; - vertexData2d[11] = (wt[2] * w1) + (wt[5] * h0) + wt[8]; - vertexData[0] = vertexData2d[0] / vertexData2d[2]; - vertexData[1] = vertexData2d[1] / vertexData2d[2]; - vertexData[2] = vertexData2d[3] / vertexData2d[5]; - vertexData[3] = vertexData2d[4] / vertexData2d[5]; - vertexData[4] = vertexData2d[6] / vertexData2d[8]; - vertexData[5] = vertexData2d[7] / vertexData2d[8]; - vertexData[6] = vertexData2d[9] / vertexData2d[11]; - vertexData[7] = vertexData2d[10] / vertexData2d[11]; - }; - Sprite2d.prototype.calculateTrimmedVertices = function () { - if (this.proj._affine) { - _super.prototype.calculateTrimmedVertices.call(this); - return; - } - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var wt = this.proj.world.mat3; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - var z = 1.0 / (wt[2] * w1 + wt[5] * h1 + wt[8]); - vertexData[0] = z * ((wt[0] * w1) + (wt[3] * h1) + wt[6]); - vertexData[1] = z * ((wt[1] * w1) + (wt[4] * h1) + wt[7]); - z = 1.0 / (wt[2] * w0 + wt[5] * h1 + wt[8]); - vertexData[2] = z * ((wt[0] * w0) + (wt[3] * h1) + wt[6]); - vertexData[3] = z * ((wt[1] * w0) + (wt[4] * h1) + wt[7]); - z = 1.0 / (wt[2] * w0 + wt[5] * h0 + wt[8]); - vertexData[4] = z * ((wt[0] * w0) + (wt[3] * h0) + wt[6]); - vertexData[5] = z * ((wt[1] * w0) + (wt[4] * h0) + wt[7]); - z = 1.0 / (wt[2] * w1 + wt[5] * h0 + wt[8]); - vertexData[6] = z * ((wt[0] * w1) + (wt[3] * h0) + wt[6]); - vertexData[7] = z * ((wt[1] * w1) + (wt[4] * h0) + wt[7]); - }; - Sprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Object.defineProperty(Sprite2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Sprite2d; - }(PIXI.Sprite)); - pixi_projection.Sprite2d = Sprite2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text2d = (function (_super) { - __extends(Text2d, _super); - function Text2d(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Object.defineProperty(Text2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Text2d; - }(PIXI.Text)); - pixi_projection.Text2d = Text2d; - Text2d.prototype.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; - Text2d.prototype.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; - Text2d.prototype._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function convertTo2d() { - if (this.proj) - return; - this.proj = new pixi_projection.Projection2d(this.transform); - this.toLocal = pixi_projection.Container2d.prototype.toLocal; - Object.defineProperty(this, "worldTransform", { - get: pixi_projection.container2dWorldTransform, - enumerable: true, - configurable: true - }); - } - PIXI.Container.prototype.convertTo2d = convertTo2d; - PIXI.Sprite.prototype.convertTo2d = function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; - this.pluginName = 'sprite2d'; - convertTo2d.call(this); - }; - PIXI.Container.prototype.convertSubtreeTo2d = function () { - this.convertTo2d(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo2d(); - } - }; - if (PIXI.SimpleMesh) { - PIXI.SimpleMesh.prototype.convertTo2d = - PIXI.SimpleRope.prototype.convertTo2d = - function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Mesh2d.prototype.calculateVertices; - this._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; - if (this.material.pluginName !== 'batch2d') { - this.material = new PIXI.MeshMaterial(this.material.texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }); - } - convertTo2d.call(this); - }; - } -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempTransform = new PIXI.Transform(); - var TilingSprite2d = (function (_super) { - __extends(TilingSprite2d, _super); - function TilingSprite2d(texture, width, height) { - var _this = _super.call(this, texture, width, height) || this; - _this.tileProj = new pixi_projection.Projection2d(_this.tileTransform); - _this.tileProj.reverseLocalOrder = true; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'tilingSprite2d'; - _this.uvRespectAnchor = true; - return _this; - } - Object.defineProperty(TilingSprite2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - TilingSprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - TilingSprite2d.prototype._render = function (renderer) { - var texture = this._texture; - if (!texture || !texture.valid) { - return; - } - this.tileTransform.updateTransform(tempTransform); - this.uvMatrix.update(); - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - return TilingSprite2d; - }(PIXI.TilingSprite)); - pixi_projection.TilingSprite2d = TilingSprite2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var shaderVert = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec3 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n\n vTextureCoord = uTransform * vec3(aTextureCoord, 1.0);\n}\n"; - var shaderFrag = "\nvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord.xy / vTextureCoord.z - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n"; - var shaderSimpleFrag = "\n\tvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord.xy / vTextureCoord.z);\n gl_FragColor = sample * uColor;\n}\n"; - var tempMat = new pixi_projection.Matrix2d(); - var WRAP_MODES = PIXI.WRAP_MODES; - var utils = PIXI.utils; - var TilingSprite2dRenderer = (function (_super) { - __extends(TilingSprite2dRenderer, _super); - function TilingSprite2dRenderer(renderer) { - var _this = _super.call(this, renderer) || this; - _this.quad = new PIXI.QuadUv(); - var uniforms = { globals: _this.renderer.globalUniforms }; - _this.shader = PIXI.Shader.from(shaderVert, shaderFrag, uniforms); - _this.simpleShader = PIXI.Shader.from(shaderVert, shaderSimpleFrag, uniforms); - return _this; - } - TilingSprite2dRenderer.prototype.render = function (ts) { - var renderer = this.renderer; - var quad = this.quad; - var vertices = quad.vertices; - vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x; - vertices[1] = vertices[3] = ts._height * -ts.anchor.y; - vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); - vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - if (ts.uvRespectAnchor) { - vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; - } - quad.invalidate(); - var tex = ts._texture; - var baseTex = tex.baseTexture; - var lt = ts.tileProj.world; - var uv = ts.uvMatrix; - var isSimple = baseTex.isPowerOfTwo - && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; - if (isSimple) { - if (!baseTex._glTextures[renderer.CONTEXT_UID]) { - if (baseTex.wrapMode === WRAP_MODES.CLAMP) { - baseTex.wrapMode = WRAP_MODES.REPEAT; - } - } - else { - isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP; - } - } - var shader = isSimple ? this.simpleShader : this.shader; - tempMat.identity(); - tempMat.scale(tex.width, tex.height); - tempMat.prepend(lt); - tempMat.scale(1.0 / ts._width, 1.0 / ts._height); - tempMat.invert(); - if (isSimple) { - tempMat.prepend(uv.mapCoord); - } - else { - shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); - shader.uniforms.uClampFrame = uv.uClampFrame; - shader.uniforms.uClampOffset = uv.uClampOffset; - } - shader.uniforms.uTransform = tempMat.toArray(true); - shader.uniforms.uColor = utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultiplyAlpha); - shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); - shader.uniforms.uSampler = tex; - renderer.shader.bind(shader, false); - renderer.geometry.bind(quad, undefined); - renderer.state.setBlendMode(utils.correctBlendMode(ts.blendMode, baseTex.premultiplyAlpha)); - renderer.geometry.draw(PIXI.DRAW_MODES.TRIANGLES, 6, 0); - }; - return TilingSprite2dRenderer; - }(PIXI.ObjectRenderer)); - pixi_projection.TilingSprite2dRenderer = TilingSprite2dRenderer; - PIXI.Renderer.registerPlugin('tilingSprite2d', TilingSprite2dRenderer); -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.systems.MaskSystem.prototype.pushSpriteMask = function (target, maskData) { - var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; - if (!alphaMaskFilter) { - alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new pixi_projection.SpriteMaskFilter2d(maskData)]; - } - alphaMaskFilter[0].resolution = this.renderer.resolution; - alphaMaskFilter[0].maskSprite = maskData; - target.filterArea = maskData.getBounds(true); - this.renderer.filter.push(target, alphaMaskFilter); - this.alphaMaskIndex++; - }; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var spriteMaskVert = "\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n\tvTextureCoord = aTextureCoord;\n\tvMaskCoord = otherMatrix * vec3( aTextureCoord, 1.0);\n}\n"; - var spriteMaskFrag = "\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n vec2 uv = vMaskCoord.xy / vMaskCoord.z;\n \n float clip = step(3.5,\n step(maskClamp.x, uv.x) +\n step(maskClamp.y, uv.y) +\n step(uv.x, maskClamp.z) +\n step(uv.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, uv);\n \n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n"; - var tempMat = new pixi_projection.Matrix2d(); - var SpriteMaskFilter2d = (function (_super) { - __extends(SpriteMaskFilter2d, _super); - function SpriteMaskFilter2d(sprite) { - var _this = _super.call(this, spriteMaskVert, spriteMaskFrag) || this; - _this.maskMatrix = new pixi_projection.Matrix2d(); - sprite.renderable = false; - _this.maskSprite = sprite; - return _this; - } - SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear) { - var maskSprite = this.maskSprite; - var tex = this.maskSprite.texture; - if (!tex.valid) { - return; - } - if (!tex.uvMatrix) { - tex.uvMatrix = new PIXI.TextureMatrix(tex, 0.0); - } - tex.uvMatrix.update(); - this.uniforms.mask = maskSprite.texture; - this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(input, this.maskMatrix, maskSprite) - .prepend(tex.uvMatrix.mapCoord); - this.uniforms.alpha = maskSprite.worldAlpha; - this.uniforms.maskClamp = tex.uvMatrix.uClampFrame; - filterManager.applyFilter(this, input, output, clear); - }; - SpriteMaskFilter2d.calculateSpriteMatrix = function (input, mappedMatrix, sprite) { - var proj = sprite.proj; - var filterArea = input.filterFrame; - var worldTransform = proj && !proj._affine ? proj.world.copyTo2dOr3d(tempMat) : tempMat.copyFrom(sprite.transform.worldTransform); - var texture = sprite.texture.orig; - mappedMatrix.set(input.width, 0, 0, input.height, filterArea.x, filterArea.y); - worldTransform.invert(); - mappedMatrix.setToMult(worldTransform, mappedMatrix); - mappedMatrix.scaleAndTranslate(1.0 / texture.width, 1.0 / texture.height, sprite.anchor.x, sprite.anchor.y); - return mappedMatrix; - }; - return SpriteMaskFilter2d; - }(PIXI.Filter)); - pixi_projection.SpriteMaskFilter2d = SpriteMaskFilter2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function container3dWorldTransform() { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - } - pixi_projection.container3dWorldTransform = container3dWorldTransform; - var Container3d = (function (_super) { - __extends(Container3d, _super); - function Container3d() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.Projection3d(_this.transform); - return _this; - } - Container3d.prototype.isFrontFace = function (forceUpdate) { - if (forceUpdate === void 0) { forceUpdate = false; } - if (forceUpdate) { - this._recursivePostUpdateTransform(); - this.displayObjectUpdateTransform(); - } - var mat = this.proj.world.mat4; - var dx1 = mat[0] * mat[15] - mat[3] * mat[12]; - var dy1 = mat[1] * mat[15] - mat[3] * mat[13]; - var dx2 = mat[4] * mat[15] - mat[7] * mat[12]; - var dy2 = mat[5] * mat[15] - mat[7] * mat[13]; - return dx1 * dy2 - dx2 * dy1 > 0; - }; - Container3d.prototype.getDepth = function (forceUpdate) { - if (forceUpdate === void 0) { forceUpdate = false; } - if (forceUpdate) { - this._recursivePostUpdateTransform(); - this.displayObjectUpdateTransform(); - } - var mat4 = this.proj.world.mat4; - return mat4[14] / mat4[15]; - }; - Container3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - if (from) { - position = from.toGlobal(position, point, skipUpdate); - } - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - } - if (step === pixi_projection.TRANSFORM_STEP.ALL) { - if (!skipUpdate) { - this.displayObjectUpdateTransform(); - } - if (this.proj.affine) { - return this.transform.worldTransform.applyInverse(position, point); - } - return this.proj.world.applyInverse(position, point); - } - if (this.parent) { - point = this.parent.worldTransform.applyInverse(position, point); - } - else { - point.copyFrom(position); - } - if (step === pixi_projection.TRANSFORM_STEP.NONE) { - return point; - } - point = this.transform.localTransform.applyInverse(point, point); - if (step === pixi_projection.TRANSFORM_STEP.PROJ && this.proj.cameraMode) { - point = this.proj.cameraMatrix.applyInverse(point, point); - } - return point; - }; - Object.defineProperty(Container3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Container3d; - }(PIXI.Container)); - pixi_projection.Container3d = Container3d; - pixi_projection.container3dToLocal = Container3d.prototype.toLocal; - pixi_projection.container3dGetDepth = Container3d.prototype.getDepth; - pixi_projection.container3dIsFrontFace = Container3d.prototype.isFrontFace; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Camera3d = (function (_super) { - __extends(Camera3d, _super); - function Camera3d() { - var _this = _super.call(this) || this; - _this._far = 0; - _this._near = 0; - _this._focus = 0; - _this._orthographic = false; - _this.proj.cameraMode = true; - _this.setPlanes(400, 10, 10000, false); - return _this; - } - Object.defineProperty(Camera3d.prototype, "far", { - get: function () { - return this._far; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "near", { - get: function () { - return this._near; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "focus", { - get: function () { - return this._focus; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "ortographic", { - get: function () { - return this._orthographic; - }, - enumerable: true, - configurable: true - }); - Camera3d.prototype.setPlanes = function (focus, near, far, orthographic) { - if (near === void 0) { near = 10; } - if (far === void 0) { far = 10000; } - if (orthographic === void 0) { orthographic = false; } - this._focus = focus; - this._near = near; - this._far = far; - this._orthographic = orthographic; - var proj = this.proj; - var mat4 = proj.cameraMatrix.mat4; - proj._projID++; - mat4[10] = 1.0 / (far - near); - mat4[14] = (focus - near) / (far - near); - if (this._orthographic) { - mat4[11] = 0; - } - else { - mat4[11] = 1.0 / focus; - } - }; - return Camera3d; - }(pixi_projection.Container3d)); - pixi_projection.Camera3d = Camera3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Euler = (function () { - function Euler(x, y, z) { - this._quatUpdateId = -1; - this._quatDirtyId = 0; - this._sign = 1; - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this.quaternion = new Float64Array(4); - this.quaternion[3] = 1; - this.update(); - } - Object.defineProperty(Euler.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "pitch", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "yaw", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "roll", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Euler.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = y || 0; - var _z = z || 0; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - } - }; - ; - Euler.prototype.copyFrom = function (euler) { - var _x = euler.x; - var _y = euler.y; - var _z = euler.z; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - } - }; - Euler.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - Euler.prototype.equals = function (euler) { - return this._x === euler.x - && this._y === euler.y - && this._z === euler.z; - }; - Euler.prototype.clone = function () { - return new Euler(this._x, this._y, this._z); - }; - Euler.prototype.update = function () { - if (this._quatUpdateId === this._quatDirtyId) { - return false; - } - this._quatUpdateId = this._quatDirtyId; - var c1 = Math.cos(this._x / 2); - var c2 = Math.cos(this._y / 2); - var c3 = Math.cos(this._z / 2); - var s = this._sign; - var s1 = s * Math.sin(this._x / 2); - var s2 = s * Math.sin(this._y / 2); - var s3 = s * Math.sin(this._z / 2); - var q = this.quaternion; - q[0] = s1 * c2 * c3 + c1 * s2 * s3; - q[1] = c1 * s2 * c3 - s1 * c2 * s3; - q[2] = c1 * c2 * s3 + s1 * s2 * c3; - q[3] = c1 * c2 * c3 - s1 * s2 * s3; - return true; - }; - return Euler; - }()); - pixi_projection.Euler = Euler; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var mat4id = [1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]; - var Matrix3d = (function () { - function Matrix3d(backingArray) { - this.floatArray = null; - this._dirtyId = 0; - this._updateId = -1; - this._mat4inv = null; - this.cacheInverse = false; - this.mat4 = new Float64Array(backingArray || mat4id); - } - Object.defineProperty(Matrix3d.prototype, "a", { - get: function () { - return this.mat4[0] / this.mat4[15]; - }, - set: function (value) { - this.mat4[0] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "b", { - get: function () { - return this.mat4[1] / this.mat4[15]; - }, - set: function (value) { - this.mat4[1] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "c", { - get: function () { - return this.mat4[4] / this.mat4[15]; - }, - set: function (value) { - this.mat4[4] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "d", { - get: function () { - return this.mat4[5] / this.mat4[15]; - }, - set: function (value) { - this.mat4[5] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "tx", { - get: function () { - return this.mat4[12] / this.mat4[15]; - }, - set: function (value) { - this.mat4[12] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "ty", { - get: function () { - return this.mat4[13] / this.mat4[15]; - }, - set: function (value) { - this.mat4[13] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Matrix3d.prototype.set = function (a, b, c, d, tx, ty) { - var mat4 = this.mat4; - mat4[0] = a; - mat4[1] = b; - mat4[2] = 0; - mat4[3] = 0; - mat4[4] = c; - mat4[5] = d; - mat4[6] = 0; - mat4[7] = 0; - mat4[8] = 0; - mat4[9] = 0; - mat4[10] = 1; - mat4[11] = 0; - mat4[12] = tx; - mat4[13] = ty; - mat4[14] = 0; - mat4[15] = 1; - return this; - }; - Matrix3d.prototype.toArray = function (transpose, out) { - if (!this.floatArray) { - this.floatArray = new Float32Array(9); - } - var array = out || this.floatArray; - var mat3 = this.mat4; - if (transpose) { - array[0] = mat3[0]; - array[1] = mat3[1]; - array[2] = mat3[3]; - array[3] = mat3[4]; - array[4] = mat3[5]; - array[5] = mat3[7]; - array[6] = mat3[12]; - array[7] = mat3[13]; - array[8] = mat3[15]; - } - else { - array[0] = mat3[0]; - array[1] = mat3[4]; - array[2] = mat3[12]; - array[3] = mat3[2]; - array[4] = mat3[6]; - array[5] = mat3[13]; - array[6] = mat3[3]; - array[7] = mat3[7]; - array[8] = mat3[15]; - } - return array; - }; - Matrix3d.prototype.setToTranslation = function (tx, ty, tz) { - var mat4 = this.mat4; - mat4[0] = 1; - mat4[1] = 0; - mat4[2] = 0; - mat4[3] = 0; - mat4[4] = 0; - mat4[5] = 1; - mat4[6] = 0; - mat4[7] = 0; - mat4[8] = 0; - mat4[9] = 0; - mat4[10] = 1; - mat4[11] = 0; - mat4[12] = tx; - mat4[13] = ty; - mat4[14] = tz; - mat4[15] = 1; - }; - Matrix3d.prototype.setToRotationTranslationScale = function (quat, tx, ty, tz, sx, sy, sz) { - var out = this.mat4; - var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = tx; - out[13] = ty; - out[14] = tz; - out[15] = 1; - return out; - }; - Matrix3d.prototype.apply = function (pos, newPos) { - newPos = newPos || new pixi_projection.Point3d(); - var mat4 = this.mat4; - var x = pos.x; - var y = pos.y; - var z = pos.z || 0; - var w = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - newPos.x = w * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - newPos.y = w * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - newPos.z = w * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - return newPos; - }; - Matrix3d.prototype.translate = function (tx, ty, tz) { - var a = this.mat4; - a[12] = a[0] * tx + a[4] * ty + a[8] * tz + a[12]; - a[13] = a[1] * tx + a[5] * ty + a[9] * tz + a[13]; - a[14] = a[2] * tx + a[6] * ty + a[10] * tz + a[14]; - a[15] = a[3] * tx + a[7] * ty + a[11] * tz + a[15]; - return this; - }; - Matrix3d.prototype.scale = function (x, y, z) { - var mat4 = this.mat4; - mat4[0] *= x; - mat4[1] *= x; - mat4[2] *= x; - mat4[3] *= x; - mat4[4] *= y; - mat4[5] *= y; - mat4[6] *= y; - mat4[7] *= y; - if (z !== undefined) { - mat4[8] *= z; - mat4[9] *= z; - mat4[10] *= z; - mat4[11] *= z; - } - return this; - }; - Matrix3d.prototype.scaleAndTranslate = function (scaleX, scaleY, scaleZ, tx, ty, tz) { - var mat4 = this.mat4; - mat4[0] = scaleX * mat4[0] + tx * mat4[3]; - mat4[1] = scaleY * mat4[1] + ty * mat4[3]; - mat4[2] = scaleZ * mat4[2] + tz * mat4[3]; - mat4[4] = scaleX * mat4[4] + tx * mat4[7]; - mat4[5] = scaleY * mat4[5] + ty * mat4[7]; - mat4[6] = scaleZ * mat4[6] + tz * mat4[7]; - mat4[8] = scaleX * mat4[8] + tx * mat4[11]; - mat4[9] = scaleY * mat4[9] + ty * mat4[11]; - mat4[10] = scaleZ * mat4[10] + tz * mat4[11]; - mat4[12] = scaleX * mat4[12] + tx * mat4[15]; - mat4[13] = scaleY * mat4[13] + ty * mat4[15]; - mat4[14] = scaleZ * mat4[14] + tz * mat4[15]; - }; - Matrix3d.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new pixi_projection.Point3d(); - if (!this._mat4inv) { - this._mat4inv = new Float64Array(16); - } - var mat4 = this._mat4inv; - var a = this.mat4; - var x = pos.x; - var y = pos.y; - var z = pos.z || 0; - if (!this.cacheInverse || this._updateId !== this._dirtyId) { - this._updateId = this._dirtyId; - Matrix3d.glMatrixMat4Invert(mat4, a); - } - var w1 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - var x1 = w1 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - var y1 = w1 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - var z1 = w1 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - z += 1.0; - var w2 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - var x2 = w2 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - var y2 = w2 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - var z2 = w2 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - if (Math.abs(z1 - z2) < 1e-10) { - newPos.set(NaN, NaN, 0); - } - var alpha = (0 - z1) / (z2 - z1); - newPos.set((x2 - x1) * alpha + x1, (y2 - y1) * alpha + y1, 0.0); - return newPos; - }; - Matrix3d.prototype.invert = function () { - Matrix3d.glMatrixMat4Invert(this.mat4, this.mat4); - return this; - }; - Matrix3d.prototype.invertCopyTo = function (matrix) { - if (!this._mat4inv) { - this._mat4inv = new Float64Array(16); - } - var mat4 = this._mat4inv; - var a = this.mat4; - if (!this.cacheInverse || this._updateId !== this._dirtyId) { - this._updateId = this._dirtyId; - Matrix3d.glMatrixMat4Invert(mat4, a); - } - matrix.mat4.set(mat4); - }; - Matrix3d.prototype.identity = function () { - var mat3 = this.mat4; - mat3[0] = 1; - mat3[1] = 0; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = 0; - mat3[5] = 1; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 0; - mat3[9] = 0; - mat3[10] = 1; - mat3[11] = 0; - mat3[12] = 0; - mat3[13] = 0; - mat3[14] = 0; - mat3[15] = 1; - return this; - }; - Matrix3d.prototype.clone = function () { - return new Matrix3d(this.mat4); - }; - Matrix3d.prototype.copyTo3d = function (matrix) { - var mat3 = this.mat4; - var ar2 = matrix.mat4; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[2]; - ar2[3] = mat3[3]; - ar2[4] = mat3[4]; - ar2[5] = mat3[5]; - ar2[6] = mat3[6]; - ar2[7] = mat3[7]; - ar2[8] = mat3[8]; - return matrix; - }; - Matrix3d.prototype.copyTo2d = function (matrix) { - var mat3 = this.mat4; - var ar2 = matrix.mat3; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[3]; - ar2[3] = mat3[4]; - ar2[4] = mat3[5]; - ar2[5] = mat3[7]; - ar2[6] = mat3[12]; - ar2[7] = mat3[13]; - ar2[8] = mat3[15]; - return matrix; - }; - Matrix3d.prototype.copyTo2dOr3d = function (matrix) { - if (matrix instanceof pixi_projection.Matrix2d) { - return this.copyTo2d(matrix); - } - else { - return this.copyTo3d(matrix); - } - }; - Matrix3d.prototype.copyTo = function (matrix, affine, preserveOrientation) { - var mat3 = this.mat4; - var d = 1.0 / mat3[15]; - var tx = mat3[12] * d, ty = mat3[13] * d; - matrix.a = (mat3[0] - mat3[3] * tx) * d; - matrix.b = (mat3[1] - mat3[3] * ty) * d; - matrix.c = (mat3[4] - mat3[7] * tx) * d; - matrix.d = (mat3[5] - mat3[7] * ty) * d; - matrix.tx = tx; - matrix.ty = ty; - if (affine >= 2) { - var D = matrix.a * matrix.d - matrix.b * matrix.c; - if (!preserveOrientation) { - D = Math.abs(D); - } - if (affine === pixi_projection.AFFINE.POINT) { - if (D > 0) { - D = 1; - } - else - D = -1; - matrix.a = D; - matrix.b = 0; - matrix.c = 0; - matrix.d = D; - } - else if (affine === pixi_projection.AFFINE.AXIS_X) { - D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); - matrix.c = 0; - matrix.d = D; - } - else if (affine === pixi_projection.AFFINE.AXIS_Y) { - D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); - matrix.a = D; - matrix.c = 0; - } - } - return matrix; - }; - Matrix3d.prototype.copyFrom = function (matrix) { - var mat3 = this.mat4; - mat3[0] = matrix.a; - mat3[1] = matrix.b; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = matrix.c; - mat3[5] = matrix.d; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 0; - mat3[9] = 0; - mat3[10] = 1; - mat3[11] = 0; - mat3[12] = matrix.tx; - mat3[13] = matrix.ty; - mat3[14] = 0; - mat3[15] = 1; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMultLegacy = function (pt, lt) { - var out = this.mat4; - var b = lt.mat4; - var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a30 = pt.tx, a31 = pt.ty; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0 * a00 + b1 * a10 + b3 * a30; - out[1] = b0 * a01 + b1 * a11 + b3 * a31; - out[2] = b2; - out[3] = b3; - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - out[4] = b0 * a00 + b1 * a10 + b3 * a30; - out[5] = b0 * a01 + b1 * a11 + b3 * a31; - out[6] = b2; - out[7] = b3; - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - out[8] = b0 * a00 + b1 * a10 + b3 * a30; - out[9] = b0 * a01 + b1 * a11 + b3 * a31; - out[10] = b2; - out[11] = b3; - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - out[12] = b0 * a00 + b1 * a10 + b3 * a30; - out[13] = b0 * a01 + b1 * a11 + b3 * a31; - out[14] = b2; - out[15] = b3; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMultLegacy2 = function (pt, lt) { - var out = this.mat4; - var a = pt.mat4; - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b30 = lt.tx, b31 = lt.ty; - out[0] = b00 * a00 + b01 * a10; - out[1] = b00 * a01 + b01 * a11; - out[2] = b00 * a02 + b01 * a12; - out[3] = b00 * a03 + b01 * a13; - out[4] = b10 * a00 + b11 * a10; - out[5] = b10 * a01 + b11 * a11; - out[6] = b10 * a02 + b11 * a12; - out[7] = b10 * a03 + b11 * a13; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = b30 * a00 + b31 * a10 + a[12]; - out[13] = b30 * a01 + b31 * a11 + a[13]; - out[14] = b30 * a02 + b31 * a12 + a[14]; - out[15] = b30 * a03 + b31 * a13 + a[15]; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMult = function (pt, lt) { - Matrix3d.glMatrixMat4Multiply(this.mat4, pt.mat4, lt.mat4); - this._dirtyId++; - return this; - }; - Matrix3d.prototype.prepend = function (lt) { - if (lt.mat4) { - this.setToMult(lt, this); - } - else { - this.setToMultLegacy(lt, this); - } - }; - Matrix3d.glMatrixMat4Invert = function (out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) { - return null; - } - det = 1.0 / det; - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - return out; - }; - Matrix3d.glMatrixMat4Multiply = function (out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - return out; - }; - Matrix3d.IDENTITY = new Matrix3d(); - Matrix3d.TEMP_MATRIX = new Matrix3d(); - return Matrix3d; - }()); - pixi_projection.Matrix3d = Matrix3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var ObservableEuler = (function () { - function ObservableEuler(cb, scope, x, y, z) { - this.cb = cb; - this.scope = scope; - this._quatUpdateId = -1; - this._quatDirtyId = 0; - this._sign = 1; - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this.quaternion = new Float64Array(4); - this.quaternion[3] = 1; - this.update(); - } - Object.defineProperty(ObservableEuler.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "pitch", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "yaw", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "roll", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - ObservableEuler.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = y || 0; - var _z = z || 0; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }; - ; - ObservableEuler.prototype.copyFrom = function (euler) { - var _x = euler.x; - var _y = euler.y; - var _z = euler.z; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }; - ObservableEuler.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - ObservableEuler.prototype.equals = function (euler) { - return this._x === euler.x - && this._y === euler.y - && this._z === euler.z; - }; - ObservableEuler.prototype.clone = function () { - return new pixi_projection.Euler(this._x, this._y, this._z); - }; - ObservableEuler.prototype.update = function () { - if (this._quatUpdateId === this._quatDirtyId) { - return false; - } - this._quatUpdateId = this._quatDirtyId; - var c1 = Math.cos(this._x / 2); - var c2 = Math.cos(this._y / 2); - var c3 = Math.cos(this._z / 2); - var s = this._sign; - var s1 = s * Math.sin(this._x / 2); - var s2 = s * Math.sin(this._y / 2); - var s3 = s * Math.sin(this._z / 2); - var q = this.quaternion; - q[0] = s1 * c2 * c3 + c1 * s2 * s3; - q[1] = c1 * s2 * c3 - s1 * c2 * s3; - q[2] = c1 * c2 * s3 + s1 * s2 * c3; - q[3] = c1 * c2 * c3 - s1 * s2 * s3; - return true; - }; - return ObservableEuler; - }()); - pixi_projection.ObservableEuler = ObservableEuler; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.ObservablePoint.prototype.copy = function (point) { - }; - var Point3d = (function (_super) { - __extends(Point3d, _super); - function Point3d(x, y, z) { - var _this = _super.call(this, x, y) || this; - _this.z = z; - return _this; - } - Point3d.prototype.set = function (x, y, z) { - this.x = x || 0; - this.y = (y === undefined) ? this.x : (y || 0); - this.z = (y === undefined) ? this.x : (z || 0); - }; - Point3d.prototype.copyFrom = function (p) { - this.set(p.x, p.y, p.z || 0); - return this; - }; - Point3d.prototype.copyTo = function (p) { - p.set(this.x, this.y, this.z); - return p; - }; - return Point3d; - }(PIXI.Point)); - pixi_projection.Point3d = Point3d; - var ObservablePoint3d = (function (_super) { - __extends(ObservablePoint3d, _super); - function ObservablePoint3d() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._z = 0; - return _this; - } - Object.defineProperty(ObservablePoint3d.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - ObservablePoint3d.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = (y === undefined) ? _x : (y || 0); - var _z = (y === undefined) ? _x : (z || 0); - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this.cb.call(this.scope); - } - }; - ObservablePoint3d.prototype.copyFrom = function (p) { - this.set(p.x, p.y, p.z || 0); - return this; - }; - ObservablePoint3d.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - return ObservablePoint3d; - }(PIXI.ObservablePoint)); - pixi_projection.ObservablePoint3d = ObservablePoint3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempMat = new pixi_projection.Matrix3d(); - var Projection3d = (function (_super) { - __extends(Projection3d, _super); - function Projection3d(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this.cameraMatrix = null; - _this._cameraMode = false; - _this.position = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); - _this.scale = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 1, 1); - _this.euler = new pixi_projection.ObservableEuler(_this.onChange, _this, 0, 0, 0); - _this.pivot = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); - _this.local = new pixi_projection.Matrix3d(); - _this.world = new pixi_projection.Matrix3d(); - _this.local.cacheInverse = true; - _this.world.cacheInverse = true; - _this.position._z = 0; - _this.scale._z = 1; - _this.pivot._z = 0; - return _this; - } - Object.defineProperty(Projection3d.prototype, "cameraMode", { - get: function () { - return this._cameraMode; - }, - set: function (value) { - if (this._cameraMode === value) { - return; - } - this._cameraMode = value; - this.euler._sign = this._cameraMode ? -1 : 1; - this.euler._quatDirtyId++; - if (value) { - this.cameraMatrix = new pixi_projection.Matrix3d(); - } - }, - enumerable: true, - configurable: true - }); - Projection3d.prototype.onChange = function () { - this._projID++; - }; - Projection3d.prototype.clear = function () { - if (this.cameraMatrix) { - this.cameraMatrix.identity(); - } - this.position.set(0, 0, 0); - this.scale.set(1, 1, 1); - this.euler.set(0, 0, 0); - this.pivot.set(0, 0, 0); - _super.prototype.clear.call(this); - }; - Projection3d.prototype.updateLocalTransform = function (lt) { - if (this._projID === 0) { - this.local.copyFrom(lt); - return; - } - var matrix = this.local; - var euler = this.euler; - var pos = this.position; - var scale = this.scale; - var pivot = this.pivot; - euler.update(); - if (!this.cameraMode) { - matrix.setToRotationTranslationScale(euler.quaternion, pos._x, pos._y, pos._z, scale._x, scale._y, scale._z); - matrix.translate(-pivot._x, -pivot._y, -pivot._z); - matrix.setToMultLegacy(lt, matrix); - return; - } - matrix.setToMultLegacy(lt, this.cameraMatrix); - matrix.translate(pivot._x, pivot._y, pivot._z); - matrix.scale(1.0 / scale._x, 1.0 / scale._y, 1.0 / scale._z); - tempMat.setToRotationTranslationScale(euler.quaternion, 0, 0, 0, 1, 1, 1); - matrix.setToMult(matrix, tempMat); - matrix.translate(-pos._x, -pos._y, -pos._z); - this.local._dirtyId++; - }; - return Projection3d; - }(pixi_projection.LinearProjection)); - pixi_projection.Projection3d = Projection3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Mesh3d2d = (function (_super) { - __extends(Mesh3d2d, _super); - function Mesh3d2d(geometry, shader, state, drawMode) { - var _this = _super.call(this, geometry, shader, state, drawMode) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection3d(_this.transform); - return _this; - } - Mesh3d2d.prototype.calculateVertices = function () { - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - var geometry = this.geometry; - var vertices = geometry.buffers[0].data; - var thisAny = this; - if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { - return; - } - thisAny._transformID = thisAny.transform._worldID; - if (thisAny.vertexData.length !== vertices.length) { - thisAny.vertexData = new Float32Array(vertices.length); - } - if (this.vertexData2d.length !== vertices.length * 3 / 2) { - this.vertexData2d = new Float32Array(vertices.length * 3); - } - var wt = this.proj.world.mat4; - var vertexData2d = this.vertexData2d; - var vertexData = thisAny.vertexData; - for (var i = 0; i < vertexData.length / 2; i++) { - var x = vertices[(i * 2)]; - var y = vertices[(i * 2) + 1]; - var xx = (wt[0] * x) + (wt[4] * y) + wt[12]; - var yy = (wt[1] * x) + (wt[5] * y) + wt[13]; - var ww = (wt[3] * x) + (wt[7] * y) + wt[15]; - vertexData2d[i * 3] = xx; - vertexData2d[i * 3 + 1] = yy; - vertexData2d[i * 3 + 2] = ww; - vertexData[(i * 2)] = xx / ww; - vertexData[(i * 2) + 1] = yy / ww; - } - thisAny.vertexDirty = geometry.vertexDirtyId; - }; - Object.defineProperty(Mesh3d2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Mesh3d2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Mesh3d2d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Mesh3d2d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Mesh3d2d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Mesh3d2d; - }(PIXI.Mesh)); - pixi_projection.Mesh3d2d = Mesh3d2d; - Mesh3d2d.prototype._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; - var SimpleMesh3d2d = (function (_super) { - __extends(SimpleMesh3d2d, _super); - function SimpleMesh3d2d(texture, vertices, uvs, indices, drawMode) { - var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }), null, drawMode) || this; - _this.autoUpdate = true; - _this.geometry.getBuffer('aVertexPosition').static = false; - return _this; - } - Object.defineProperty(SimpleMesh3d2d.prototype, "vertices", { - get: function () { - return this.geometry.getBuffer('aVertexPosition').data; - }, - set: function (value) { - this.geometry.getBuffer('aVertexPosition').data = value; - }, - enumerable: true, - configurable: true - }); - SimpleMesh3d2d.prototype._render = function (renderer) { - if (this.autoUpdate) { - this.geometry.getBuffer('aVertexPosition').update(); - } - _super.prototype._render.call(this, renderer); - }; - return SimpleMesh3d2d; - }(Mesh3d2d)); - pixi_projection.SimpleMesh3d2d = SimpleMesh3d2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite3d = (function (_super) { - __extends(Sprite3d, _super); - function Sprite3d(texture) { - var _this = _super.call(this, texture) || this; - _this.vertexData2d = null; - _this.culledByFrustrum = false; - _this.trimmedCulledByFrustrum = false; - _this.proj = new pixi_projection.Projection3d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Sprite3d.prototype.calculateVertices = function () { - var texture = this._texture; - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - if (!this.vertexData2d) { - this.vertexData2d = new Float32Array(12); - } - var wid = this.transform._worldID; - var tuid = texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - if (this._textureID !== tuid) { - this.uvs = texture._uvs.uvsFloat32; - } - this._transformID = wid; - this._textureID = tuid; - var wt = this.proj.world.mat4; - var vertexData2d = this.vertexData2d; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - var culled = false; - var z; - vertexData2d[0] = (wt[0] * w1) + (wt[4] * h1) + wt[12]; - vertexData2d[1] = (wt[1] * w1) + (wt[5] * h1) + wt[13]; - z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; - vertexData2d[2] = (wt[3] * w1) + (wt[7] * h1) + wt[15]; - culled = culled || z < 0; - vertexData2d[3] = (wt[0] * w0) + (wt[4] * h1) + wt[12]; - vertexData2d[4] = (wt[1] * w0) + (wt[5] * h1) + wt[13]; - z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; - vertexData2d[5] = (wt[3] * w0) + (wt[7] * h1) + wt[15]; - culled = culled || z < 0; - vertexData2d[6] = (wt[0] * w0) + (wt[4] * h0) + wt[12]; - vertexData2d[7] = (wt[1] * w0) + (wt[5] * h0) + wt[13]; - z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; - vertexData2d[8] = (wt[3] * w0) + (wt[7] * h0) + wt[15]; - culled = culled || z < 0; - vertexData2d[9] = (wt[0] * w1) + (wt[4] * h0) + wt[12]; - vertexData2d[10] = (wt[1] * w1) + (wt[5] * h0) + wt[13]; - z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; - vertexData2d[11] = (wt[3] * w1) + (wt[7] * h0) + wt[15]; - culled = culled || z < 0; - this.culledByFrustrum = culled; - vertexData[0] = vertexData2d[0] / vertexData2d[2]; - vertexData[1] = vertexData2d[1] / vertexData2d[2]; - vertexData[2] = vertexData2d[3] / vertexData2d[5]; - vertexData[3] = vertexData2d[4] / vertexData2d[5]; - vertexData[4] = vertexData2d[6] / vertexData2d[8]; - vertexData[5] = vertexData2d[7] / vertexData2d[8]; - vertexData[6] = vertexData2d[9] / vertexData2d[11]; - vertexData[7] = vertexData2d[10] / vertexData2d[11]; - }; - Sprite3d.prototype.calculateTrimmedVertices = function () { - if (this.proj._affine) { - _super.prototype.calculateTrimmedVertices.call(this); - return; - } - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var wt = this.proj.world.mat4; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - var culled = false; - var z; - var w = 1.0 / ((wt[3] * w1) + (wt[7] * h1) + wt[15]); - vertexData[0] = w * ((wt[0] * w1) + (wt[4] * h1) + wt[12]); - vertexData[1] = w * ((wt[1] * w1) + (wt[5] * h1) + wt[13]); - z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w0) + (wt[7] * h1) + wt[15]); - vertexData[2] = w * ((wt[0] * w0) + (wt[4] * h1) + wt[12]); - vertexData[3] = w * ((wt[1] * w0) + (wt[5] * h1) + wt[13]); - z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w0) + (wt[7] * h0) + wt[15]); - vertexData[4] = w * ((wt[0] * w0) + (wt[4] * h0) + wt[12]); - vertexData[5] = w * ((wt[1] * w0) + (wt[5] * h0) + wt[13]); - z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w1) + (wt[7] * h0) + wt[15]); - vertexData[6] = w * ((wt[0] * w1) + (wt[4] * h0) + wt[12]); - vertexData[7] = w * ((wt[1] * w1) + (wt[5] * h0) + wt[13]); - z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; - culled = culled || z < 0; - this.culledByFrustrum = culled; - }; - Sprite3d.prototype._calculateBounds = function () { - this.calculateVertices(); - if (this.culledByFrustrum) { - return; - } - var trim = this._texture.trim; - var orig = this._texture.orig; - if (!trim || (trim.width === orig.width && trim.height === orig.height)) { - this._bounds.addQuad(this.vertexData); - return; - } - this.calculateTrimmedVertices(); - if (!this.trimmedCulledByFrustrum) { - this._bounds.addQuad(this.vertexTrimmedData); - } - }; - Sprite3d.prototype._render = function (renderer) { - this.calculateVertices(); - if (this.culledByFrustrum) { - return; - } - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - Sprite3d.prototype.containsPoint = function (point) { - if (this.culledByFrustrum) { - return false; - } - return _super.prototype.containsPoint.call(this, point); - }; - Object.defineProperty(Sprite3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Sprite3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Sprite3d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Sprite3d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Sprite3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Sprite3d; - }(PIXI.Sprite)); - pixi_projection.Sprite3d = Sprite3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text3d = (function (_super) { - __extends(Text3d, _super); - function Text3d(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection3d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Object.defineProperty(Text3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Text3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Text3d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Text3d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Text3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Text3d; - }(PIXI.Text)); - pixi_projection.Text3d = Text3d; - Text3d.prototype.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; - Text3d.prototype.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; - Text3d.prototype._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; - Text3d.prototype.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; - Text3d.prototype._render = pixi_projection.Sprite3d.prototype._render; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var containerProps = { - worldTransform: { - get: pixi_projection.container3dWorldTransform, - enumerable: true, - configurable: true - }, - position3d: { - get: function () { return this.proj.position; }, - set: function (value) { this.proj.position.copy(value); } - }, - scale3d: { - get: function () { return this.proj.scale; }, - set: function (value) { this.proj.scale.copy(value); } - }, - pivot3d: { - get: function () { return this.proj.pivot; }, - set: function (value) { this.proj.pivot.copy(value); } - }, - euler: { - get: function () { return this.proj.euler; }, - set: function (value) { this.proj.euler.copy(value); } - } - }; - function convertTo3d() { - if (this.proj) - return; - this.proj = new pixi_projection.Projection3d(this.transform); - this.toLocal = pixi_projection.Container3d.prototype.toLocal; - this.isFrontFace = pixi_projection.Container3d.prototype.isFrontFace; - this.getDepth = pixi_projection.Container3d.prototype.getDepth; - Object.defineProperties(this, containerProps); - } - PIXI.Container.prototype.convertTo3d = convertTo3d; - PIXI.Sprite.prototype.convertTo3d = function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; - this.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; - this.pluginName = 'batch2d'; - convertTo3d.call(this); - }; - PIXI.Container.prototype.convertSubtreeTo3d = function () { - this.convertTo3d(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo3d(); - } - }; - if (PIXI.SimpleMesh) { - PIXI.SimpleMesh.prototype.convertTo3d = - PIXI.SimpleRope.prototype.convertTo3d = - function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Mesh3d2d.prototype.calculateVertices; - this._renderDefault = pixi_projection.Mesh3d2d.prototype._renderDefault; - if (this.material.pluginName !== 'batch2d') { - this.material = new PIXI.MeshMaterial(this.material.texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }); - } - convertTo3d.call(this); - }; - } -})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var utils; + (function (utils) { + function getIntersectionFactor(p1, p2, p3, p4, out) { + var A1 = p2.x - p1.x, B1 = p3.x - p4.x, C1 = p3.x - p1.x; + var A2 = p2.y - p1.y, B2 = p3.y - p4.y, C2 = p3.y - p1.y; + var D = A1 * B2 - A2 * B1; + if (Math.abs(D) < 1e-7) { + out.x = A1; + out.y = A2; + return 0; + } + var T = C1 * B2 - C2 * B1; + var U = A1 * C2 - A2 * C1; + var t = T / D, u = U / D; + if (u < (1e-6) || u - 1 > -1e-6) { + return -1; + } + out.x = p1.x + t * (p2.x - p1.x); + out.y = p1.y + t * (p2.y - p1.y); + return 1; + } + utils.getIntersectionFactor = getIntersectionFactor; + function getPositionFromQuad(p, anchor, out) { + out = out || new PIXI.Point(); + var a1 = 1.0 - anchor.x, a2 = 1.0 - a1; + var b1 = 1.0 - anchor.y, b2 = 1.0 - b1; + out.x = (p[0].x * a1 + p[1].x * a2) * b1 + (p[3].x * a1 + p[2].x * a2) * b2; + out.y = (p[0].y * a1 + p[1].y * a2) * b1 + (p[3].y * a1 + p[2].y * a2) * b2; + return out; + } + utils.getPositionFromQuad = getPositionFromQuad; + })(utils = pixi_projection.utils || (pixi_projection.utils = {})); +})(pixi_projection || (pixi_projection = {})); +PIXI.projection = pixi_projection; +var pixi_projection; +(function (pixi_projection) { + var AbstractProjection = (function () { + function AbstractProjection(legacy, enable) { + if (enable === void 0) { enable = true; } + this._enabled = false; + this.legacy = legacy; + if (enable) { + this.enabled = true; + } + this.legacy.proj = this; + } + Object.defineProperty(AbstractProjection.prototype, "enabled", { + get: function () { + return this._enabled; + }, + set: function (value) { + this._enabled = value; + }, + enumerable: true, + configurable: true + }); + AbstractProjection.prototype.clear = function () { + }; + return AbstractProjection; + }()); + pixi_projection.AbstractProjection = AbstractProjection; + var TRANSFORM_STEP; + (function (TRANSFORM_STEP) { + TRANSFORM_STEP[TRANSFORM_STEP["NONE"] = 0] = "NONE"; + TRANSFORM_STEP[TRANSFORM_STEP["BEFORE_PROJ"] = 4] = "BEFORE_PROJ"; + TRANSFORM_STEP[TRANSFORM_STEP["PROJ"] = 5] = "PROJ"; + TRANSFORM_STEP[TRANSFORM_STEP["ALL"] = 9] = "ALL"; + })(TRANSFORM_STEP = pixi_projection.TRANSFORM_STEP || (pixi_projection.TRANSFORM_STEP = {})); +})(pixi_projection || (pixi_projection = {})); +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var pixi_projection; +(function (pixi_projection) { + function transformHack(parentTransform) { + var proj = this.proj; + var ta = this; + var pwid = parentTransform._worldID; + var lt = ta.localTransform; + var scaleAfterAffine = proj.scaleAfterAffine && proj.affine >= 2; + if (ta._localID !== ta._currentLocalID) { + if (scaleAfterAffine) { + lt.a = ta._cx; + lt.b = ta._sx; + lt.c = ta._cy; + lt.d = ta._sy; + lt.tx = ta.position._x; + lt.ty = ta.position._y; + } + else { + lt.a = ta._cx * ta.scale._x; + lt.b = ta._sx * ta.scale._x; + lt.c = ta._cy * ta.scale._y; + lt.d = ta._sy * ta.scale._y; + lt.tx = ta.position._x - ((ta.pivot._x * lt.a) + (ta.pivot._y * lt.c)); + lt.ty = ta.position._y - ((ta.pivot._x * lt.b) + (ta.pivot._y * lt.d)); + } + ta._currentLocalID = ta._localID; + proj._currentProjID = -1; + } + var _matrixID = proj._projID; + if (proj._currentProjID !== _matrixID) { + proj._currentProjID = _matrixID; + proj.updateLocalTransform(lt); + ta._parentID = -1; + } + if (ta._parentID !== pwid) { + var pp = parentTransform.proj; + if (pp && !pp._affine) { + proj.world.setToMult(pp.world, proj.local); + } + else { + proj.world.setToMultLegacy(parentTransform.worldTransform, proj.local); + } + var wa = ta.worldTransform; + proj.world.copyTo(wa, proj._affine, proj.affinePreserveOrientation); + if (scaleAfterAffine) { + wa.a *= ta.scale._x; + wa.b *= ta.scale._x; + wa.c *= ta.scale._y; + wa.d *= ta.scale._y; + wa.tx -= ((ta.pivot._x * wa.a) + (ta.pivot._y * wa.c)); + wa.ty -= ((ta.pivot._x * wa.b) + (ta.pivot._y * wa.d)); + } + ta._parentID = pwid; + ta._worldID++; + } + } + var LinearProjection = (function (_super) { + __extends(LinearProjection, _super); + function LinearProjection() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._projID = 0; + _this._currentProjID = -1; + _this._affine = pixi_projection.AFFINE.NONE; + _this.affinePreserveOrientation = false; + _this.scaleAfterAffine = true; + return _this; + } + LinearProjection.prototype.updateLocalTransform = function (lt) { + }; + Object.defineProperty(LinearProjection.prototype, "affine", { + get: function () { + return this._affine; + }, + set: function (value) { + if (this._affine == value) + return; + this._affine = value; + this._currentProjID = -1; + this.legacy._currentLocalID = -1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LinearProjection.prototype, "enabled", { + set: function (value) { + if (value === this._enabled) { + return; + } + this._enabled = value; + if (value) { + this.legacy.updateTransform = transformHack; + this.legacy._parentID = -1; + } + else { + this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; + this.legacy._parentID = -1; + } + }, + enumerable: true, + configurable: true + }); + LinearProjection.prototype.clear = function () { + this._currentProjID = -1; + this._projID = 0; + }; + return LinearProjection; + }(pixi_projection.AbstractProjection)); + pixi_projection.LinearProjection = LinearProjection; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var TYPES = PIXI.TYPES; + var premultiplyTint = PIXI.utils.premultiplyTint; + var shaderVert = "precision highp float;\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * aVertexPosition;\n gl_Position.z = 0.0;\n \n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n"; + var shaderFrag = "\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\nvec4 color;\n%forloop%\ngl_FragColor = color * vColor;\n}"; + var Batch3dGeometry = (function (_super) { + __extends(Batch3dGeometry, _super); + function Batch3dGeometry(_static) { + if (_static === void 0) { _static = false; } + var _this = _super.call(this) || this; + _this._buffer = new PIXI.Buffer(null, _static, false); + _this._indexBuffer = new PIXI.Buffer(null, _static, true); + _this.addAttribute('aVertexPosition', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aTextureCoord', _this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) + .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT) + .addIndex(_this._indexBuffer); + return _this; + } + return Batch3dGeometry; + }(PIXI.Geometry)); + pixi_projection.Batch3dGeometry = Batch3dGeometry; + var Batch2dPluginFactory = (function () { + function Batch2dPluginFactory() { + } + Batch2dPluginFactory.create = function (options) { + var _a = Object.assign({ + vertex: shaderVert, + fragment: shaderFrag, + geometryClass: Batch3dGeometry, + vertexSize: 7, + }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; + return (function (_super) { + __extends(BatchPlugin, _super); + function BatchPlugin(renderer) { + var _this = _super.call(this, renderer) || this; + _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); + _this.geometryClass = geometryClass; + _this.vertexSize = vertexSize; + return _this; + } + BatchPlugin.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) { + var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View; + var p = aIndex / this.vertexSize; + var uvs = element.uvs; + var indicies = element.indices; + var vertexData = element.vertexData; + var vertexData2d = element.vertexData2d; + var textureId = element._texture.baseTexture._id; + var alpha = Math.min(element.worldAlpha, 1.0); + var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) + : element._tintRGB + (alpha * 255 << 24); + if (vertexData2d) { + var j = 0; + for (var i = 0; i < vertexData2d.length; i += 3, j += 2) { + float32View[aIndex++] = vertexData2d[i]; + float32View[aIndex++] = vertexData2d[i + 1]; + float32View[aIndex++] = vertexData2d[i + 2]; + float32View[aIndex++] = uvs[j]; + float32View[aIndex++] = uvs[j + 1]; + uint32View[aIndex++] = argb; + float32View[aIndex++] = textureId; + } + } + else { + for (var i = 0; i < vertexData.length; i += 2) { + float32View[aIndex++] = vertexData[i]; + float32View[aIndex++] = vertexData[i + 1]; + float32View[aIndex++] = 1.0; + float32View[aIndex++] = uvs[i]; + float32View[aIndex++] = uvs[i + 1]; + uint32View[aIndex++] = argb; + float32View[aIndex++] = textureId; + } + } + for (var i = 0; i < indicies.length; i++) { + indexBuffer[iIndex++] = p + indicies[i]; + } + }; + return BatchPlugin; + }(PIXI.AbstractBatchRenderer)); + }; + return Batch2dPluginFactory; + }()); + pixi_projection.Batch2dPluginFactory = Batch2dPluginFactory; + PIXI.Renderer.registerPlugin('batch2d', Batch2dPluginFactory.create({})); +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var UniformBatchRenderer = (function (_super) { + __extends(UniformBatchRenderer, _super); + function UniformBatchRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + UniformBatchRenderer.prototype.addToBatch = function (sprite) { + }; + return UniformBatchRenderer; + }(PIXI.AbstractBatchRenderer)); + pixi_projection.UniformBatchRenderer = UniformBatchRenderer; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var p = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; + var a = [0, 0, 0, 0]; + var Surface = (function () { + function Surface() { + this.surfaceID = "default"; + this._updateID = 0; + this.vertexSrc = ""; + this.fragmentSrc = ""; + } + Surface.prototype.fillUniforms = function (uniforms) { + }; + Surface.prototype.clear = function () { + }; + Surface.prototype.boundsQuad = function (v, out, after) { + var minX = out[0], minY = out[1]; + var maxX = out[0], maxY = out[1]; + for (var i = 2; i < 8; i += 2) { + if (minX > out[i]) + minX = out[i]; + if (maxX < out[i]) + maxX = out[i]; + if (minY > out[i + 1]) + minY = out[i + 1]; + if (maxY < out[i + 1]) + maxY = out[i + 1]; + } + p[0].set(minX, minY); + this.apply(p[0], p[0]); + p[1].set(maxX, minY); + this.apply(p[1], p[1]); + p[2].set(maxX, maxY); + this.apply(p[2], p[2]); + p[3].set(minX, maxY); + this.apply(p[3], p[3]); + if (after) { + after.apply(p[0], p[0]); + after.apply(p[1], p[1]); + after.apply(p[2], p[2]); + after.apply(p[3], p[3]); + out[0] = p[0].x; + out[1] = p[0].y; + out[2] = p[1].x; + out[3] = p[1].y; + out[4] = p[2].x; + out[5] = p[2].y; + out[6] = p[3].x; + out[7] = p[3].y; + } + else { + for (var i = 1; i <= 3; i++) { + if (p[i].y < p[0].y || p[i].y == p[0].y && p[i].x < p[0].x) { + var t = p[0]; + p[0] = p[i]; + p[i] = t; + } + } + for (var i = 1; i <= 3; i++) { + a[i] = Math.atan2(p[i].y - p[0].y, p[i].x - p[0].x); + } + for (var i = 1; i <= 3; i++) { + for (var j = i + 1; j <= 3; j++) { + if (a[i] > a[j]) { + var t = p[i]; + p[i] = p[j]; + p[j] = t; + var t2 = a[i]; + a[i] = a[j]; + a[j] = t2; + } + } + } + out[0] = p[0].x; + out[1] = p[0].y; + out[2] = p[1].x; + out[3] = p[1].y; + out[4] = p[2].x; + out[5] = p[2].y; + out[6] = p[3].x; + out[7] = p[3].y; + if ((p[3].x - p[2].x) * (p[1].y - p[2].y) - (p[1].x - p[2].x) * (p[3].y - p[2].y) < 0) { + out[4] = p[3].x; + out[5] = p[3].y; + return; + } + } + }; + return Surface; + }()); + pixi_projection.Surface = Surface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempMat = new PIXI.Matrix(); + var tempRect = new PIXI.Rectangle(); + var tempPoint = new PIXI.Point(); + var BilinearSurface = (function (_super) { + __extends(BilinearSurface, _super); + function BilinearSurface() { + var _this = _super.call(this) || this; + _this.distortion = new PIXI.Point(); + return _this; + } + BilinearSurface.prototype.clear = function () { + this.distortion.set(0, 0); + }; + BilinearSurface.prototype.apply = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var d = this.distortion; + var m = pos.x * pos.y; + newPos.x = pos.x + d.x * m; + newPos.y = pos.y + d.y * m; + return newPos; + }; + BilinearSurface.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var vx = pos.x, vy = pos.y; + var dx = this.distortion.x, dy = this.distortion.y; + if (dx == 0.0) { + newPos.x = vx; + newPos.y = vy / (1.0 + dy * vx); + } + else if (dy == 0.0) { + newPos.y = vy; + newPos.x = vx / (1.0 + dx * vy); + } + else { + var b = (vy * dx - vx * dy + 1.0) * 0.5 / dy; + var d = b * b + vx / dy; + if (d <= 0.00001) { + newPos.set(NaN, NaN); + return; + } + if (dy > 0.0) { + newPos.x = -b + Math.sqrt(d); + } + else { + newPos.x = -b - Math.sqrt(d); + } + newPos.y = (vx / newPos.x - 1.0) / dx; + } + return newPos; + }; + BilinearSurface.prototype.mapSprite = function (sprite, quad, outTransform) { + var tex = sprite.texture; + tempRect.x = -sprite.anchor.x * tex.orig.width; + tempRect.y = -sprite.anchor.y * tex.orig.height; + tempRect.width = tex.orig.width; + tempRect.height = tex.orig.height; + return this.mapQuad(tempRect, quad, outTransform || sprite.transform); + }; + BilinearSurface.prototype.mapQuad = function (rect, quad, outTransform) { + var ax = -rect.x / rect.width; + var ay = -rect.y / rect.height; + var ax2 = (1.0 - rect.x) / rect.width; + var ay2 = (1.0 - rect.y) / rect.height; + var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax); + var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax); + var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2); + var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2); + var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax); + var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax); + var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2); + var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2); + var x00 = up1x * (1.0 - ay) + down1x * ay; + var y00 = up1y * (1.0 - ay) + down1y * ay; + var x10 = up2x * (1.0 - ay) + down2x * ay; + var y10 = up2y * (1.0 - ay) + down2y * ay; + var x01 = up1x * (1.0 - ay2) + down1x * ay2; + var y01 = up1y * (1.0 - ay2) + down1y * ay2; + var x11 = up2x * (1.0 - ay2) + down2x * ay2; + var y11 = up2y * (1.0 - ay2) + down2y * ay2; + var mat = tempMat; + mat.tx = x00; + mat.ty = y00; + mat.a = x10 - x00; + mat.b = y10 - y00; + mat.c = x01 - x00; + mat.d = y01 - y00; + tempPoint.set(x11, y11); + mat.applyInverse(tempPoint, tempPoint); + this.distortion.set(tempPoint.x - 1, tempPoint.y - 1); + outTransform.setFromMatrix(mat); + return this; + }; + BilinearSurface.prototype.fillUniforms = function (uniforms) { + uniforms.distortion = uniforms.distortion || new Float32Array([0, 0, 0, 0]); + var ax = Math.abs(this.distortion.x); + var ay = Math.abs(this.distortion.y); + uniforms.distortion[0] = ax * 10000 <= ay ? 0 : this.distortion.x; + uniforms.distortion[1] = ay * 10000 <= ax ? 0 : this.distortion.y; + uniforms.distortion[2] = 1.0 / uniforms.distortion[0]; + uniforms.distortion[3] = 1.0 / uniforms.distortion[1]; + }; + return BilinearSurface; + }(pixi_projection.Surface)); + pixi_projection.BilinearSurface = BilinearSurface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Container2s = (function (_super) { + __extends(Container2s, _super); + function Container2s() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + return _this; + } + Object.defineProperty(Container2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Container2s; + }(PIXI.Container)); + pixi_projection.Container2s = Container2s; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var fun = PIXI.Transform.prototype.updateTransform; + function transformHack(parentTransform) { + var proj = this.proj; + var pp = parentTransform.proj; + var ta = this; + if (!pp) { + fun.call(this, parentTransform); + proj._activeProjection = null; + return; + } + if (pp._surface) { + proj._activeProjection = pp; + this.updateLocalTransform(); + this.localTransform.copyFrom(this.worldTransform); + if (ta._parentID < 0) { + ++ta._worldID; + } + return; + } + fun.call(this, parentTransform); + proj._activeProjection = pp._activeProjection; + } + var ProjectionSurface = (function (_super) { + __extends(ProjectionSurface, _super); + function ProjectionSurface(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this._surface = null; + _this._activeProjection = null; + _this._currentSurfaceID = -1; + _this._currentLegacyID = -1; + _this._lastUniforms = null; + return _this; + } + Object.defineProperty(ProjectionSurface.prototype, "enabled", { + set: function (value) { + if (value === this._enabled) { + return; + } + this._enabled = value; + if (value) { + this.legacy.updateTransform = transformHack; + this.legacy._parentID = -1; + } + else { + this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; + this.legacy._parentID = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ProjectionSurface.prototype, "surface", { + get: function () { + return this._surface; + }, + set: function (value) { + if (this._surface == value) { + return; + } + this._surface = value || null; + this.legacy._parentID = -1; + }, + enumerable: true, + configurable: true + }); + ProjectionSurface.prototype.applyPartial = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this.legacy.worldTransform.apply(pos, newPos); + return this._activeProjection.surface.apply(newPos, newPos); + } + if (this._surface !== null) { + return this.surface.apply(pos, newPos); + } + return this.legacy.worldTransform.apply(pos, newPos); + }; + ProjectionSurface.prototype.apply = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this.legacy.worldTransform.apply(pos, newPos); + this._activeProjection.surface.apply(newPos, newPos); + return this._activeProjection.legacy.worldTransform.apply(newPos, newPos); + } + if (this._surface !== null) { + newPos = this.surface.apply(pos, newPos); + return this.legacy.worldTransform.apply(newPos, newPos); + } + return this.legacy.worldTransform.apply(pos, newPos); + }; + ProjectionSurface.prototype.applyInverse = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this._activeProjection.legacy.worldTransform.applyInverse(pos, newPos); + this._activeProjection._surface.applyInverse(newPos, newPos); + return this.legacy.worldTransform.applyInverse(newPos, newPos); + } + if (this._surface !== null) { + newPos = this.legacy.worldTransform.applyInverse(pos, newPos); + return this._surface.applyInverse(newPos, newPos); + } + return this.legacy.worldTransform.applyInverse(pos, newPos); + }; + ProjectionSurface.prototype.mapBilinearSprite = function (sprite, quad) { + if (!(this._surface instanceof pixi_projection.BilinearSurface)) { + this.surface = new pixi_projection.BilinearSurface(); + } + this.surface.mapSprite(sprite, quad, this.legacy); + }; + ProjectionSurface.prototype.clear = function () { + if (this.surface) { + this.surface.clear(); + } + }; + Object.defineProperty(ProjectionSurface.prototype, "uniforms", { + get: function () { + if (this._currentLegacyID === this.legacy._worldID && + this._currentSurfaceID === this.surface._updateID) { + return this._lastUniforms; + } + this._lastUniforms = this._lastUniforms || {}; + this._lastUniforms.worldTransform = this.legacy.worldTransform.toArray(true); + this._surface.fillUniforms(this._lastUniforms); + return this._lastUniforms; + }, + enumerable: true, + configurable: true + }); + return ProjectionSurface; + }(pixi_projection.AbstractProjection)); + pixi_projection.ProjectionSurface = ProjectionSurface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var TYPES = PIXI.TYPES; + var premultiplyTint = PIXI.utils.premultiplyTint; + var shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n"; + var shaderFrag = "precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 distortion;\n\nvoid main(void){\nvec2 surface;\nvec2 surface2;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat dx = distortion.x;\nfloat dy = distortion.y;\nfloat revx = distortion.z;\nfloat revy = distortion.w;\n\nif (distortion.x == 0.0) {\n surface.x = vx;\n surface.y = vy / (1.0 + dy * vx);\n surface2 = surface;\n} else\nif (distortion.y == 0.0) {\n surface.y = vy;\n surface.x = vx/ (1.0 + dx * vy);\n surface2 = surface;\n} else {\n float c = vy * dx - vx * dy;\n float b = (c + 1.0) * 0.5;\n float b2 = (-c + 1.0) * 0.5;\n float d = b * b + vx * dy;\n if (d < -0.00001) {\n discard;\n }\n d = sqrt(max(d, 0.0));\n surface.x = (- b + d) * revy;\n surface2.x = (- b - d) * revy;\n surface.y = (- b2 + d) * revx;\n surface2.y = (- b2 - d) * revx;\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nif (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\n%forloop%\ngl_FragColor = color * rColor;\n}"; + var BatchBilineardGeometry = (function (_super) { + __extends(BatchBilineardGeometry, _super); + function BatchBilineardGeometry(_static) { + if (_static === void 0) { _static = false; } + var _this = _super.call(this) || this; + _this._buffer = new PIXI.Buffer(null, _static, false); + _this._indexBuffer = new PIXI.Buffer(null, _static, true); + _this.addAttribute('aVertexPosition', _this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aTrans1', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aTrans2', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aFrame', _this._buffer, 4, false, TYPES.FLOAT) + .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) + .addIndex(_this._indexBuffer); + return _this; + } + return BatchBilineardGeometry; + }(PIXI.Geometry)); + pixi_projection.BatchBilineardGeometry = BatchBilineardGeometry; + var BatchBilinearPluginFactory = (function () { + function BatchBilinearPluginFactory() { + } + BatchBilinearPluginFactory.create = function (options) { + var _a = Object.assign({ + vertex: shaderVert, + fragment: shaderFrag, + geometryClass: pixi_projection.Batch3dGeometry, + vertexSize: 7, + }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; + return (function (_super) { + __extends(BatchPlugin, _super); + function BatchPlugin(renderer) { + var _this = _super.call(this, renderer) || this; + _this.defUniforms = { + worldTransform: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]), + distortion: new Float32Array([0, 0]) + }; + _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); + _this.geometryClass = geometryClass; + _this.vertexSize = vertexSize; + return _this; + } + BatchPlugin.prototype.getUniforms = function (sprite) { + var proj = sprite.proj; + var shader = this._shader; + if (proj.surface !== null) { + return proj.uniforms; + } + if (proj._activeProjection !== null) { + return proj._activeProjection.uniforms; + } + return this.defUniforms; + }; + BatchPlugin.prototype.packGeometry = function (element, float32View, uint32View, indexBuffer, index, indexCount) { + var p = index / this.vertexSize; + var uvs = element.uvs; + var indices = element.indices; + var vertexData = element.vertexData; + var tex = element._texture; + var frame = tex._frame; + var aTrans = element.aTrans; + var alpha = Math.min(element.worldAlpha, 1.0); + var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) + : element._tintRGB + (alpha * 255 << 24); + for (var i = 0; i < vertexData.length; i += 2) { + float32View[index] = vertexData[i * 2]; + float32View[index + 1] = vertexData[i * 2 + 1]; + float32View[index + 2] = aTrans.a; + float32View[index + 3] = aTrans.c; + float32View[index + 4] = aTrans.tx; + float32View[index + 5] = aTrans.b; + float32View[index + 6] = aTrans.d; + float32View[index + 7] = aTrans.ty; + float32View[index + 8] = frame.x; + float32View[index + 9] = frame.y; + float32View[index + 10] = frame.x + frame.width; + float32View[index + 11] = frame.y + frame.height; + uint32View[index + 12] = argb; + index += 13; + } + for (var i = 0; i < indices.length; i++) { + indexBuffer[indexCount++] = p + indices[i]; + } + }; + return BatchPlugin; + }(PIXI.AbstractBatchRenderer)); + }; + return BatchBilinearPluginFactory; + }()); + pixi_projection.BatchBilinearPluginFactory = BatchBilinearPluginFactory; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite2s = (function (_super) { + __extends(Sprite2s, _super); + function Sprite2s(texture) { + var _this = _super.call(this, texture) || this; + _this.aTrans = new PIXI.Matrix(); + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + _this.pluginName = 'batch_bilinear'; + return _this; + } + Sprite2s.prototype._calculateBounds = function () { + this.calculateTrimmedVertices(); + this._bounds.addQuad(this.vertexTrimmedData); + }; + Sprite2s.prototype.calculateVertices = function () { + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + this._transformID = wid; + this._textureID = tuid; + var texture = this._texture; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + if (this.proj._surface) { + vertexData[0] = w1; + vertexData[1] = h1; + vertexData[2] = w0; + vertexData[3] = h1; + vertexData[4] = w0; + vertexData[5] = h0; + vertexData[6] = w1; + vertexData[7] = h0; + this.proj._surface.boundsQuad(vertexData, vertexData); + } + else { + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + if (this.proj._activeProjection) { + this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData); + } + } + if (!texture.uvMatrix) { + texture.uvMatrix = new PIXI.TextureMatrix(texture); + } + texture.uvMatrix.update(); + var aTrans = this.aTrans; + aTrans.set(orig.width, 0, 0, orig.height, w1, h1); + if (this.proj._surface === null) { + aTrans.prepend(this.transform.worldTransform); + } + aTrans.invert(); + aTrans.prepend(texture.uvMatrix.mapCoord); + }; + Sprite2s.prototype.calculateTrimmedVertices = function () { + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + if (this.proj._surface) { + vertexData[0] = w1; + vertexData[1] = h1; + vertexData[2] = w0; + vertexData[3] = h1; + vertexData[4] = w0; + vertexData[5] = h0; + vertexData[6] = w1; + vertexData[7] = h0; + this.proj._surface.boundsQuad(vertexData, vertexData, this.transform.worldTransform); + } + else { + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + if (this.proj._activeProjection) { + this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData, this.proj._activeProjection.legacy.worldTransform); + } + } + }; + Object.defineProperty(Sprite2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Sprite2s; + }(PIXI.Sprite)); + pixi_projection.Sprite2s = Sprite2s; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text2s = (function (_super) { + __extends(Text2s, _super); + function Text2s(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.aTrans = new PIXI.Matrix(); + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + _this.pluginName = 'batch_bilinear'; + return _this; + } + Object.defineProperty(Text2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Text2s; + }(PIXI.Text)); + pixi_projection.Text2s = Text2s; + Text2s.prototype.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; + Text2s.prototype.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; + Text2s.prototype._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + PIXI.Sprite.prototype.convertTo2s = function () { + if (this.proj) + return; + this.pluginName = 'sprite_bilinear'; + this.aTrans = new PIXI.Matrix(); + this.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; + PIXI.Container.prototype.convertTo2s.call(this); + }; + PIXI.Container.prototype.convertTo2s = function () { + if (this.proj) + return; + this.proj = new pixi_projection.Projection2d(this.transform); + Object.defineProperty(this, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + }; + PIXI.Container.prototype.convertSubtreeTo2s = function () { + this.convertTo2s(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo2s(); + } + }; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function container2dWorldTransform() { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + } + pixi_projection.container2dWorldTransform = container2dWorldTransform; + var Container2d = (function (_super) { + __extends(Container2d, _super); + function Container2d() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.Projection2d(_this.transform); + return _this; + } + Container2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + if (from) { + position = from.toGlobal(position, point, skipUpdate); + } + if (!skipUpdate) { + this._recursivePostUpdateTransform(); + } + if (step >= pixi_projection.TRANSFORM_STEP.PROJ) { + if (!skipUpdate) { + this.displayObjectUpdateTransform(); + } + if (this.proj.affine) { + return this.transform.worldTransform.applyInverse(position, point); + } + return this.proj.world.applyInverse(position, point); + } + if (this.parent) { + point = this.parent.worldTransform.applyInverse(position, point); + } + else { + point.copyFrom(position); + } + if (step === pixi_projection.TRANSFORM_STEP.NONE) { + return point; + } + return this.transform.localTransform.applyInverse(point, point); + }; + Object.defineProperty(Container2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Container2d; + }(PIXI.Container)); + pixi_projection.Container2d = Container2d; + pixi_projection.container2dToLocal = Container2d.prototype.toLocal; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Point = PIXI.Point; + var mat3id = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + var AFFINE; + (function (AFFINE) { + AFFINE[AFFINE["NONE"] = 0] = "NONE"; + AFFINE[AFFINE["FREE"] = 1] = "FREE"; + AFFINE[AFFINE["AXIS_X"] = 2] = "AXIS_X"; + AFFINE[AFFINE["AXIS_Y"] = 3] = "AXIS_Y"; + AFFINE[AFFINE["POINT"] = 4] = "POINT"; + AFFINE[AFFINE["AXIS_XR"] = 5] = "AXIS_XR"; + })(AFFINE = pixi_projection.AFFINE || (pixi_projection.AFFINE = {})); + var Matrix2d = (function () { + function Matrix2d(backingArray) { + this.floatArray = null; + this.mat3 = new Float64Array(backingArray || mat3id); + } + Object.defineProperty(Matrix2d.prototype, "a", { + get: function () { + return this.mat3[0] / this.mat3[8]; + }, + set: function (value) { + this.mat3[0] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "b", { + get: function () { + return this.mat3[1] / this.mat3[8]; + }, + set: function (value) { + this.mat3[1] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "c", { + get: function () { + return this.mat3[3] / this.mat3[8]; + }, + set: function (value) { + this.mat3[3] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "d", { + get: function () { + return this.mat3[4] / this.mat3[8]; + }, + set: function (value) { + this.mat3[4] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "tx", { + get: function () { + return this.mat3[6] / this.mat3[8]; + }, + set: function (value) { + this.mat3[6] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "ty", { + get: function () { + return this.mat3[7] / this.mat3[8]; + }, + set: function (value) { + this.mat3[7] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Matrix2d.prototype.set = function (a, b, c, d, tx, ty) { + var mat3 = this.mat3; + mat3[0] = a; + mat3[1] = b; + mat3[2] = 0; + mat3[3] = c; + mat3[4] = d; + mat3[5] = 0; + mat3[6] = tx; + mat3[7] = ty; + mat3[8] = 1; + return this; + }; + Matrix2d.prototype.toArray = function (transpose, out) { + if (!this.floatArray) { + this.floatArray = new Float32Array(9); + } + var array = out || this.floatArray; + var mat3 = this.mat3; + if (transpose) { + array[0] = mat3[0]; + array[1] = mat3[1]; + array[2] = mat3[2]; + array[3] = mat3[3]; + array[4] = mat3[4]; + array[5] = mat3[5]; + array[6] = mat3[6]; + array[7] = mat3[7]; + array[8] = mat3[8]; + } + else { + array[0] = mat3[0]; + array[1] = mat3[3]; + array[2] = mat3[6]; + array[3] = mat3[1]; + array[4] = mat3[4]; + array[5] = mat3[7]; + array[6] = mat3[2]; + array[7] = mat3[5]; + array[8] = mat3[8]; + } + return array; + }; + Matrix2d.prototype.apply = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var mat3 = this.mat3; + var x = pos.x; + var y = pos.y; + var z = 1.0 / (mat3[2] * x + mat3[5] * y + mat3[8]); + newPos.x = z * (mat3[0] * x + mat3[3] * y + mat3[6]); + newPos.y = z * (mat3[1] * x + mat3[4] * y + mat3[7]); + return newPos; + }; + Matrix2d.prototype.translate = function (tx, ty) { + var mat3 = this.mat3; + mat3[0] += tx * mat3[2]; + mat3[1] += ty * mat3[2]; + mat3[3] += tx * mat3[5]; + mat3[4] += ty * mat3[5]; + mat3[6] += tx * mat3[8]; + mat3[7] += ty * mat3[8]; + return this; + }; + Matrix2d.prototype.scale = function (x, y) { + var mat3 = this.mat3; + mat3[0] *= x; + mat3[1] *= y; + mat3[3] *= x; + mat3[4] *= y; + mat3[6] *= x; + mat3[7] *= y; + return this; + }; + Matrix2d.prototype.scaleAndTranslate = function (scaleX, scaleY, tx, ty) { + var mat3 = this.mat3; + mat3[0] = scaleX * mat3[0] + tx * mat3[2]; + mat3[1] = scaleY * mat3[1] + ty * mat3[2]; + mat3[3] = scaleX * mat3[3] + tx * mat3[5]; + mat3[4] = scaleY * mat3[4] + ty * mat3[5]; + mat3[6] = scaleX * mat3[6] + tx * mat3[8]; + mat3[7] = scaleY * mat3[7] + ty * mat3[8]; + }; + Matrix2d.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new Point(); + var a = this.mat3; + var x = pos.x; + var y = pos.y; + var a00 = a[0], a01 = a[3], a02 = a[6], a10 = a[1], a11 = a[4], a12 = a[7], a20 = a[2], a21 = a[5], a22 = a[8]; + var newX = (a22 * a11 - a12 * a21) * x + (-a22 * a01 + a02 * a21) * y + (a12 * a01 - a02 * a11); + var newY = (-a22 * a10 + a12 * a20) * x + (a22 * a00 - a02 * a20) * y + (-a12 * a00 + a02 * a10); + var newZ = (a21 * a10 - a11 * a20) * x + (-a21 * a00 + a01 * a20) * y + (a11 * a00 - a01 * a10); + newPos.x = newX / newZ; + newPos.y = newY / newZ; + return newPos; + }; + Matrix2d.prototype.invert = function () { + var a = this.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b01 = a22 * a11 - a12 * a21, b11 = -a22 * a10 + a12 * a20, b21 = a21 * a10 - a11 * a20; + var det = a00 * b01 + a01 * b11 + a02 * b21; + if (!det) { + return this; + } + det = 1.0 / det; + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + return this; + }; + Matrix2d.prototype.identity = function () { + var mat3 = this.mat3; + mat3[0] = 1; + mat3[1] = 0; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = 1; + mat3[5] = 0; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 1; + return this; + }; + Matrix2d.prototype.clone = function () { + return new Matrix2d(this.mat3); + }; + Matrix2d.prototype.copyTo2dOr3d = function (matrix) { + var mat3 = this.mat3; + var ar2 = matrix.mat3; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[2]; + ar2[3] = mat3[3]; + ar2[4] = mat3[4]; + ar2[5] = mat3[5]; + ar2[6] = mat3[6]; + ar2[7] = mat3[7]; + ar2[8] = mat3[8]; + return matrix; + }; + Matrix2d.prototype.copyTo = function (matrix, affine, preserveOrientation) { + var mat3 = this.mat3; + var d = 1.0 / mat3[8]; + var tx = mat3[6] * d, ty = mat3[7] * d; + matrix.a = (mat3[0] - mat3[2] * tx) * d; + matrix.b = (mat3[1] - mat3[2] * ty) * d; + matrix.c = (mat3[3] - mat3[5] * tx) * d; + matrix.d = (mat3[4] - mat3[5] * ty) * d; + matrix.tx = tx; + matrix.ty = ty; + if (affine >= 2) { + var D = matrix.a * matrix.d - matrix.b * matrix.c; + if (!preserveOrientation) { + D = Math.abs(D); + } + if (affine === AFFINE.POINT) { + if (D > 0) { + D = 1; + } + else + D = -1; + matrix.a = D; + matrix.b = 0; + matrix.c = 0; + matrix.d = D; + } + else if (affine === AFFINE.AXIS_X) { + D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); + matrix.c = 0; + matrix.d = D; + } + else if (affine === AFFINE.AXIS_Y) { + D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); + matrix.a = D; + matrix.c = 0; + } + else if (affine === AFFINE.AXIS_XR) { + matrix.a = matrix.d * D; + matrix.c = -matrix.b * D; + } + } + return matrix; + }; + Matrix2d.prototype.copyFrom = function (matrix) { + var mat3 = this.mat3; + mat3[0] = matrix.a; + mat3[1] = matrix.b; + mat3[2] = 0; + mat3[3] = matrix.c; + mat3[4] = matrix.d; + mat3[5] = 0; + mat3[6] = matrix.tx; + mat3[7] = matrix.ty; + mat3[8] = 1.0; + return this; + }; + Matrix2d.prototype.setToMultLegacy = function (pt, lt) { + var out = this.mat3; + var b = lt.mat3; + var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a20 = pt.tx, a21 = pt.ty, b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b02; + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b12; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b22; + return this; + }; + Matrix2d.prototype.setToMultLegacy2 = function (pt, lt) { + var out = this.mat3; + var a = pt.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b20 = lt.tx, b21 = lt.ty; + out[0] = b00 * a00 + b01 * a10; + out[1] = b00 * a01 + b01 * a11; + out[2] = b00 * a02 + b01 * a12; + out[3] = b10 * a00 + b11 * a10; + out[4] = b10 * a01 + b11 * a11; + out[5] = b10 * a02 + b11 * a12; + out[6] = b20 * a00 + b21 * a10 + a20; + out[7] = b20 * a01 + b21 * a11 + a21; + out[8] = b20 * a02 + b21 * a12 + a22; + return this; + }; + Matrix2d.prototype.setToMult = function (pt, lt) { + var out = this.mat3; + var a = pt.mat3, b = lt.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; + return this; + }; + Matrix2d.prototype.prepend = function (lt) { + if (lt.mat3) { + return this.setToMult(lt, this); + } + else { + return this.setToMultLegacy(lt, this); + } + }; + Matrix2d.IDENTITY = new Matrix2d(); + Matrix2d.TEMP_MATRIX = new Matrix2d(); + return Matrix2d; + }()); + pixi_projection.Matrix2d = Matrix2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var t0 = new PIXI.Point(); + var tt = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; + var tempRect = new PIXI.Rectangle(); + var tempMat = new pixi_projection.Matrix2d(); + var Projection2d = (function (_super) { + __extends(Projection2d, _super); + function Projection2d(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this.matrix = new pixi_projection.Matrix2d(); + _this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0); + _this.reverseLocalOrder = false; + _this.local = new pixi_projection.Matrix2d(); + _this.world = new pixi_projection.Matrix2d(); + return _this; + } + Projection2d.prototype.onChange = function () { + var pivot = this.pivot; + var mat3 = this.matrix.mat3; + mat3[6] = -(pivot._x * mat3[0] + pivot._y * mat3[3]); + mat3[7] = -(pivot._x * mat3[1] + pivot._y * mat3[4]); + this._projID++; + }; + Projection2d.prototype.setAxisX = function (p, factor) { + if (factor === void 0) { factor = 1; } + var x = p.x, y = p.y; + var d = Math.sqrt(x * x + y * y); + var mat3 = this.matrix.mat3; + mat3[0] = x / d; + mat3[1] = y / d; + mat3[2] = factor / d; + this.onChange(); + }; + Projection2d.prototype.setAxisY = function (p, factor) { + if (factor === void 0) { factor = 1; } + var x = p.x, y = p.y; + var d = Math.sqrt(x * x + y * y); + var mat3 = this.matrix.mat3; + mat3[3] = x / d; + mat3[4] = y / d; + mat3[5] = factor / d; + this.onChange(); + }; + Projection2d.prototype.mapSprite = function (sprite, quad) { + var tex = sprite.texture; + tempRect.x = -sprite.anchor.x * tex.orig.width; + tempRect.y = -sprite.anchor.y * tex.orig.height; + tempRect.width = tex.orig.width; + tempRect.height = tex.orig.height; + return this.mapQuad(tempRect, quad); + }; + Projection2d.prototype.mapQuad = function (rect, p) { + tt[0].set(rect.x, rect.y); + tt[1].set(rect.x + rect.width, rect.y); + tt[2].set(rect.x + rect.width, rect.y + rect.height); + tt[3].set(rect.x, rect.y + rect.height); + var k1 = 1, k2 = 2, k3 = 3; + var f = pixi_projection.utils.getIntersectionFactor(p[0], p[2], p[1], p[3], t0); + if (f !== 0) { + k1 = 1; + k2 = 3; + k3 = 2; + } + else { + return; + } + var d0 = Math.sqrt((p[0].x - t0.x) * (p[0].x - t0.x) + (p[0].y - t0.y) * (p[0].y - t0.y)); + var d1 = Math.sqrt((p[k1].x - t0.x) * (p[k1].x - t0.x) + (p[k1].y - t0.y) * (p[k1].y - t0.y)); + var d2 = Math.sqrt((p[k2].x - t0.x) * (p[k2].x - t0.x) + (p[k2].y - t0.y) * (p[k2].y - t0.y)); + var d3 = Math.sqrt((p[k3].x - t0.x) * (p[k3].x - t0.x) + (p[k3].y - t0.y) * (p[k3].y - t0.y)); + var q0 = (d0 + d3) / d3; + var q1 = (d1 + d2) / d2; + var q2 = (d1 + d2) / d1; + var mat3 = this.matrix.mat3; + mat3[0] = tt[0].x * q0; + mat3[1] = tt[0].y * q0; + mat3[2] = q0; + mat3[3] = tt[k1].x * q1; + mat3[4] = tt[k1].y * q1; + mat3[5] = q1; + mat3[6] = tt[k2].x * q2; + mat3[7] = tt[k2].y * q2; + mat3[8] = q2; + this.matrix.invert(); + mat3 = tempMat.mat3; + mat3[0] = p[0].x; + mat3[1] = p[0].y; + mat3[2] = 1; + mat3[3] = p[k1].x; + mat3[4] = p[k1].y; + mat3[5] = 1; + mat3[6] = p[k2].x; + mat3[7] = p[k2].y; + mat3[8] = 1; + this.matrix.setToMult(tempMat, this.matrix); + this._projID++; + }; + Projection2d.prototype.updateLocalTransform = function (lt) { + if (this._projID !== 0) { + if (this.reverseLocalOrder) { + this.local.setToMultLegacy2(this.matrix, lt); + } + else { + this.local.setToMultLegacy(lt, this.matrix); + } + } + else { + this.local.copyFrom(lt); + } + }; + Projection2d.prototype.clear = function () { + _super.prototype.clear.call(this); + this.matrix.identity(); + this.pivot.set(0, 0); + }; + return Projection2d; + }(pixi_projection.LinearProjection)); + pixi_projection.Projection2d = Projection2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Mesh2d = (function (_super) { + __extends(Mesh2d, _super); + function Mesh2d(geometry, shader, state, drawMode) { + var _this = _super.call(this, geometry, shader, state, drawMode) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + return _this; + } + Mesh2d.prototype.calculateVertices = function () { + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + var geometry = this.geometry; + var vertices = geometry.buffers[0].data; + var thisAny = this; + if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { + return; + } + thisAny._transformID = thisAny.transform._worldID; + if (thisAny.vertexData.length !== vertices.length) { + thisAny.vertexData = new Float32Array(vertices.length); + } + if (this.vertexData2d.length !== vertices.length * 3 / 2) { + this.vertexData2d = new Float32Array(vertices.length * 3); + } + var wt = this.proj.world.mat3; + var vertexData2d = this.vertexData2d; + var vertexData = thisAny.vertexData; + for (var i = 0; i < vertexData.length / 2; i++) { + var x = vertices[(i * 2)]; + var y = vertices[(i * 2) + 1]; + var xx = (wt[0] * x) + (wt[3] * y) + wt[6]; + var yy = (wt[1] * x) + (wt[4] * y) + wt[7]; + var ww = (wt[2] * x) + (wt[5] * y) + wt[8]; + vertexData2d[i * 3] = xx; + vertexData2d[i * 3 + 1] = yy; + vertexData2d[i * 3 + 2] = ww; + vertexData[(i * 2)] = xx / ww; + vertexData[(i * 2) + 1] = yy / ww; + } + thisAny.vertexDirty = geometry.vertexDirtyId; + }; + Mesh2d.prototype._renderDefault = function (renderer) { + var shader = this.shader; + shader.alpha = this.worldAlpha; + if (shader.update) { + shader.update(); + } + renderer.batch.flush(); + if (shader.program.uniformData.translationMatrix) { + shader.uniforms.translationMatrix = this.worldTransform.toArray(true); + } + renderer.shader.bind(shader, false); + renderer.state.set(this.state); + renderer.geometry.bind(this.geometry, shader); + renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount); + }; + Mesh2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Object.defineProperty(Mesh2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Mesh2d.defaultVertexShader = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n"; + Mesh2d.defaultFragmentShader = "\nvarying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}"; + return Mesh2d; + }(PIXI.Mesh)); + pixi_projection.Mesh2d = Mesh2d; + var SimpleMesh2d = (function (_super) { + __extends(SimpleMesh2d, _super); + function SimpleMesh2d(texture, vertices, uvs, indices, drawMode) { + var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { + program: PIXI.Program.from(Mesh2d.defaultVertexShader, Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }), null, drawMode) || this; + _this.autoUpdate = true; + _this.geometry.getBuffer('aVertexPosition').static = false; + return _this; + } + Object.defineProperty(SimpleMesh2d.prototype, "vertices", { + get: function () { + return this.geometry.getBuffer('aVertexPosition').data; + }, + set: function (value) { + this.geometry.getBuffer('aVertexPosition').data = value; + }, + enumerable: true, + configurable: true + }); + SimpleMesh2d.prototype._render = function (renderer) { + if (this.autoUpdate) { + this.geometry.getBuffer('aVertexPosition').update(); + } + _super.prototype._render.call(this, renderer); + }; + return SimpleMesh2d; + }(Mesh2d)); + pixi_projection.SimpleMesh2d = SimpleMesh2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite2d = (function (_super) { + __extends(Sprite2d, _super); + function Sprite2d(texture) { + var _this = _super.call(this, texture) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Sprite2d.prototype._calculateBounds = function () { + this.calculateTrimmedVertices(); + this._bounds.addQuad(this.vertexTrimmedData); + }; + Sprite2d.prototype.calculateVertices = function () { + var texture = this._texture; + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + if (!this.vertexData2d) { + this.vertexData2d = new Float32Array(12); + } + var wid = this.transform._worldID; + var tuid = texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + if (this._textureID !== tuid) { + this.uvs = texture._uvs.uvsFloat32; + } + this._transformID = wid; + this._textureID = tuid; + var wt = this.proj.world.mat3; + var vertexData2d = this.vertexData2d; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + vertexData2d[0] = (wt[0] * w1) + (wt[3] * h1) + wt[6]; + vertexData2d[1] = (wt[1] * w1) + (wt[4] * h1) + wt[7]; + vertexData2d[2] = (wt[2] * w1) + (wt[5] * h1) + wt[8]; + vertexData2d[3] = (wt[0] * w0) + (wt[3] * h1) + wt[6]; + vertexData2d[4] = (wt[1] * w0) + (wt[4] * h1) + wt[7]; + vertexData2d[5] = (wt[2] * w0) + (wt[5] * h1) + wt[8]; + vertexData2d[6] = (wt[0] * w0) + (wt[3] * h0) + wt[6]; + vertexData2d[7] = (wt[1] * w0) + (wt[4] * h0) + wt[7]; + vertexData2d[8] = (wt[2] * w0) + (wt[5] * h0) + wt[8]; + vertexData2d[9] = (wt[0] * w1) + (wt[3] * h0) + wt[6]; + vertexData2d[10] = (wt[1] * w1) + (wt[4] * h0) + wt[7]; + vertexData2d[11] = (wt[2] * w1) + (wt[5] * h0) + wt[8]; + vertexData[0] = vertexData2d[0] / vertexData2d[2]; + vertexData[1] = vertexData2d[1] / vertexData2d[2]; + vertexData[2] = vertexData2d[3] / vertexData2d[5]; + vertexData[3] = vertexData2d[4] / vertexData2d[5]; + vertexData[4] = vertexData2d[6] / vertexData2d[8]; + vertexData[5] = vertexData2d[7] / vertexData2d[8]; + vertexData[6] = vertexData2d[9] / vertexData2d[11]; + vertexData[7] = vertexData2d[10] / vertexData2d[11]; + }; + Sprite2d.prototype.calculateTrimmedVertices = function () { + if (this.proj._affine) { + _super.prototype.calculateTrimmedVertices.call(this); + return; + } + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var wt = this.proj.world.mat3; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + var z = 1.0 / (wt[2] * w1 + wt[5] * h1 + wt[8]); + vertexData[0] = z * ((wt[0] * w1) + (wt[3] * h1) + wt[6]); + vertexData[1] = z * ((wt[1] * w1) + (wt[4] * h1) + wt[7]); + z = 1.0 / (wt[2] * w0 + wt[5] * h1 + wt[8]); + vertexData[2] = z * ((wt[0] * w0) + (wt[3] * h1) + wt[6]); + vertexData[3] = z * ((wt[1] * w0) + (wt[4] * h1) + wt[7]); + z = 1.0 / (wt[2] * w0 + wt[5] * h0 + wt[8]); + vertexData[4] = z * ((wt[0] * w0) + (wt[3] * h0) + wt[6]); + vertexData[5] = z * ((wt[1] * w0) + (wt[4] * h0) + wt[7]); + z = 1.0 / (wt[2] * w1 + wt[5] * h0 + wt[8]); + vertexData[6] = z * ((wt[0] * w1) + (wt[3] * h0) + wt[6]); + vertexData[7] = z * ((wt[1] * w1) + (wt[4] * h0) + wt[7]); + }; + Sprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Object.defineProperty(Sprite2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Sprite2d; + }(PIXI.Sprite)); + pixi_projection.Sprite2d = Sprite2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text2d = (function (_super) { + __extends(Text2d, _super); + function Text2d(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Object.defineProperty(Text2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Text2d; + }(PIXI.Text)); + pixi_projection.Text2d = Text2d; + Text2d.prototype.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; + Text2d.prototype.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; + Text2d.prototype._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function convertTo2d() { + if (this.proj) + return; + this.proj = new pixi_projection.Projection2d(this.transform); + this.toLocal = pixi_projection.Container2d.prototype.toLocal; + Object.defineProperty(this, "worldTransform", { + get: pixi_projection.container2dWorldTransform, + enumerable: true, + configurable: true + }); + } + PIXI.Container.prototype.convertTo2d = convertTo2d; + PIXI.Sprite.prototype.convertTo2d = function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; + this.pluginName = 'sprite2d'; + convertTo2d.call(this); + }; + PIXI.Container.prototype.convertSubtreeTo2d = function () { + this.convertTo2d(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo2d(); + } + }; + if (PIXI.SimpleMesh) { + PIXI.SimpleMesh.prototype.convertTo2d = + PIXI.SimpleRope.prototype.convertTo2d = + function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Mesh2d.prototype.calculateVertices; + this._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; + if (this.material.pluginName !== 'batch2d') { + this.material = new PIXI.MeshMaterial(this.material.texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }); + } + convertTo2d.call(this); + }; + } +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempTransform = new PIXI.Transform(); + var TilingSprite2d = (function (_super) { + __extends(TilingSprite2d, _super); + function TilingSprite2d(texture, width, height) { + var _this = _super.call(this, texture, width, height) || this; + _this.tileProj = new pixi_projection.Projection2d(_this.tileTransform); + _this.tileProj.reverseLocalOrder = true; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'tilingSprite2d'; + _this.uvRespectAnchor = true; + return _this; + } + Object.defineProperty(TilingSprite2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + TilingSprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + TilingSprite2d.prototype._render = function (renderer) { + var texture = this._texture; + if (!texture || !texture.valid) { + return; + } + this.tileTransform.updateTransform(tempTransform); + this.uvMatrix.update(); + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + return TilingSprite2d; + }(PIXI.TilingSprite)); + pixi_projection.TilingSprite2d = TilingSprite2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var shaderVert = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec3 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n\n vTextureCoord = uTransform * vec3(aTextureCoord, 1.0);\n}\n"; + var shaderFrag = "\nvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord.xy / vTextureCoord.z - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n"; + var shaderSimpleFrag = "\n\tvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord.xy / vTextureCoord.z);\n gl_FragColor = sample * uColor;\n}\n"; + var tempMat = new pixi_projection.Matrix2d(); + var WRAP_MODES = PIXI.WRAP_MODES; + var utils = PIXI.utils; + var TilingSprite2dRenderer = (function (_super) { + __extends(TilingSprite2dRenderer, _super); + function TilingSprite2dRenderer(renderer) { + var _this = _super.call(this, renderer) || this; + _this.quad = new PIXI.QuadUv(); + var uniforms = { globals: _this.renderer.globalUniforms }; + _this.shader = PIXI.Shader.from(shaderVert, shaderFrag, uniforms); + _this.simpleShader = PIXI.Shader.from(shaderVert, shaderSimpleFrag, uniforms); + return _this; + } + TilingSprite2dRenderer.prototype.render = function (ts) { + var renderer = this.renderer; + var quad = this.quad; + var vertices = quad.vertices; + vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x; + vertices[1] = vertices[3] = ts._height * -ts.anchor.y; + vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); + vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); + if (ts.uvRespectAnchor) { + vertices = quad.uvs; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } + quad.invalidate(); + var tex = ts._texture; + var baseTex = tex.baseTexture; + var lt = ts.tileProj.world; + var uv = ts.uvMatrix; + var isSimple = baseTex.isPowerOfTwo + && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; + if (isSimple) { + if (!baseTex._glTextures[renderer.CONTEXT_UID]) { + if (baseTex.wrapMode === WRAP_MODES.CLAMP) { + baseTex.wrapMode = WRAP_MODES.REPEAT; + } + } + else { + isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP; + } + } + var shader = isSimple ? this.simpleShader : this.shader; + tempMat.identity(); + tempMat.scale(tex.width, tex.height); + tempMat.prepend(lt); + tempMat.scale(1.0 / ts._width, 1.0 / ts._height); + tempMat.invert(); + if (isSimple) { + tempMat.prepend(uv.mapCoord); + } + else { + shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); + shader.uniforms.uClampFrame = uv.uClampFrame; + shader.uniforms.uClampOffset = uv.uClampOffset; + } + shader.uniforms.uTransform = tempMat.toArray(true); + shader.uniforms.uColor = utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultiplyAlpha); + shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); + shader.uniforms.uSampler = tex; + renderer.shader.bind(shader, false); + renderer.geometry.bind(quad, undefined); + renderer.state.setBlendMode(utils.correctBlendMode(ts.blendMode, baseTex.premultiplyAlpha)); + renderer.geometry.draw(PIXI.DRAW_MODES.TRIANGLES, 6, 0); + }; + return TilingSprite2dRenderer; + }(PIXI.ObjectRenderer)); + pixi_projection.TilingSprite2dRenderer = TilingSprite2dRenderer; + PIXI.Renderer.registerPlugin('tilingSprite2d', TilingSprite2dRenderer); +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + PIXI.systems.MaskSystem.prototype.pushSpriteMask = function (target, maskData) { + var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; + if (!alphaMaskFilter) { + alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new pixi_projection.SpriteMaskFilter2d(maskData)]; + } + alphaMaskFilter[0].resolution = this.renderer.resolution; + alphaMaskFilter[0].maskSprite = maskData; + target.filterArea = maskData.getBounds(true); + this.renderer.filter.push(target, alphaMaskFilter); + this.alphaMaskIndex++; + }; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var spriteMaskVert = "\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n\tvTextureCoord = aTextureCoord;\n\tvMaskCoord = otherMatrix * vec3( aTextureCoord, 1.0);\n}\n"; + var spriteMaskFrag = "\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n vec2 uv = vMaskCoord.xy / vMaskCoord.z;\n \n float clip = step(3.5,\n step(maskClamp.x, uv.x) +\n step(maskClamp.y, uv.y) +\n step(uv.x, maskClamp.z) +\n step(uv.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, uv);\n \n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n"; + var tempMat = new pixi_projection.Matrix2d(); + var SpriteMaskFilter2d = (function (_super) { + __extends(SpriteMaskFilter2d, _super); + function SpriteMaskFilter2d(sprite) { + var _this = _super.call(this, spriteMaskVert, spriteMaskFrag) || this; + _this.maskMatrix = new pixi_projection.Matrix2d(); + sprite.renderable = false; + _this.maskSprite = sprite; + return _this; + } + SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear) { + var maskSprite = this.maskSprite; + var tex = this.maskSprite.texture; + if (!tex.valid) { + return; + } + if (!tex.uvMatrix) { + tex.uvMatrix = new PIXI.TextureMatrix(tex, 0.0); + } + tex.uvMatrix.update(); + this.uniforms.mask = maskSprite.texture; + this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(input, this.maskMatrix, maskSprite) + .prepend(tex.uvMatrix.mapCoord); + this.uniforms.alpha = maskSprite.worldAlpha; + this.uniforms.maskClamp = tex.uvMatrix.uClampFrame; + filterManager.applyFilter(this, input, output, clear); + }; + SpriteMaskFilter2d.calculateSpriteMatrix = function (input, mappedMatrix, sprite) { + var proj = sprite.proj; + var filterArea = input.filterFrame; + var worldTransform = proj && !proj._affine ? proj.world.copyTo2dOr3d(tempMat) : tempMat.copyFrom(sprite.transform.worldTransform); + var texture = sprite.texture.orig; + mappedMatrix.set(input.width, 0, 0, input.height, filterArea.x, filterArea.y); + worldTransform.invert(); + mappedMatrix.setToMult(worldTransform, mappedMatrix); + mappedMatrix.scaleAndTranslate(1.0 / texture.width, 1.0 / texture.height, sprite.anchor.x, sprite.anchor.y); + return mappedMatrix; + }; + return SpriteMaskFilter2d; + }(PIXI.Filter)); + pixi_projection.SpriteMaskFilter2d = SpriteMaskFilter2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function container3dWorldTransform() { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + } + pixi_projection.container3dWorldTransform = container3dWorldTransform; + var Container3d = (function (_super) { + __extends(Container3d, _super); + function Container3d() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.Projection3d(_this.transform); + return _this; + } + Container3d.prototype.isFrontFace = function (forceUpdate) { + if (forceUpdate === void 0) { forceUpdate = false; } + if (forceUpdate) { + this._recursivePostUpdateTransform(); + this.displayObjectUpdateTransform(); + } + var mat = this.proj.world.mat4; + var dx1 = mat[0] * mat[15] - mat[3] * mat[12]; + var dy1 = mat[1] * mat[15] - mat[3] * mat[13]; + var dx2 = mat[4] * mat[15] - mat[7] * mat[12]; + var dy2 = mat[5] * mat[15] - mat[7] * mat[13]; + return dx1 * dy2 - dx2 * dy1 > 0; + }; + Container3d.prototype.getDepth = function (forceUpdate) { + if (forceUpdate === void 0) { forceUpdate = false; } + if (forceUpdate) { + this._recursivePostUpdateTransform(); + this.displayObjectUpdateTransform(); + } + var mat4 = this.proj.world.mat4; + return mat4[14] / mat4[15]; + }; + Container3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + if (from) { + position = from.toGlobal(position, point, skipUpdate); + } + if (!skipUpdate) { + this._recursivePostUpdateTransform(); + } + if (step === pixi_projection.TRANSFORM_STEP.ALL) { + if (!skipUpdate) { + this.displayObjectUpdateTransform(); + } + if (this.proj.affine) { + return this.transform.worldTransform.applyInverse(position, point); + } + return this.proj.world.applyInverse(position, point); + } + if (this.parent) { + point = this.parent.worldTransform.applyInverse(position, point); + } + else { + point.copyFrom(position); + } + if (step === pixi_projection.TRANSFORM_STEP.NONE) { + return point; + } + point = this.transform.localTransform.applyInverse(point, point); + if (step === pixi_projection.TRANSFORM_STEP.PROJ && this.proj.cameraMode) { + point = this.proj.cameraMatrix.applyInverse(point, point); + } + return point; + }; + Object.defineProperty(Container3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Container3d; + }(PIXI.Container)); + pixi_projection.Container3d = Container3d; + pixi_projection.container3dToLocal = Container3d.prototype.toLocal; + pixi_projection.container3dGetDepth = Container3d.prototype.getDepth; + pixi_projection.container3dIsFrontFace = Container3d.prototype.isFrontFace; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Camera3d = (function (_super) { + __extends(Camera3d, _super); + function Camera3d() { + var _this = _super.call(this) || this; + _this._far = 0; + _this._near = 0; + _this._focus = 0; + _this._orthographic = false; + _this.proj.cameraMode = true; + _this.setPlanes(400, 10, 10000, false); + return _this; + } + Object.defineProperty(Camera3d.prototype, "far", { + get: function () { + return this._far; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "near", { + get: function () { + return this._near; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "focus", { + get: function () { + return this._focus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "ortographic", { + get: function () { + return this._orthographic; + }, + enumerable: true, + configurable: true + }); + Camera3d.prototype.setPlanes = function (focus, near, far, orthographic) { + if (near === void 0) { near = 10; } + if (far === void 0) { far = 10000; } + if (orthographic === void 0) { orthographic = false; } + this._focus = focus; + this._near = near; + this._far = far; + this._orthographic = orthographic; + var proj = this.proj; + var mat4 = proj.cameraMatrix.mat4; + proj._projID++; + mat4[10] = 1.0 / (far - near); + mat4[14] = (focus - near) / (far - near); + if (this._orthographic) { + mat4[11] = 0; + } + else { + mat4[11] = 1.0 / focus; + } + }; + return Camera3d; + }(pixi_projection.Container3d)); + pixi_projection.Camera3d = Camera3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Euler = (function () { + function Euler(x, y, z) { + this._quatUpdateId = -1; + this._quatDirtyId = 0; + this._sign = 1; + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this.quaternion = new Float64Array(4); + this.quaternion[3] = 1; + this.update(); + } + Object.defineProperty(Euler.prototype, "x", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "pitch", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "yaw", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "roll", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Euler.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = y || 0; + var _z = z || 0; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + } + }; + ; + Euler.prototype.copyFrom = function (euler) { + var _x = euler.x; + var _y = euler.y; + var _z = euler.z; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + } + }; + Euler.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + Euler.prototype.equals = function (euler) { + return this._x === euler.x + && this._y === euler.y + && this._z === euler.z; + }; + Euler.prototype.clone = function () { + return new Euler(this._x, this._y, this._z); + }; + Euler.prototype.update = function () { + if (this._quatUpdateId === this._quatDirtyId) { + return false; + } + this._quatUpdateId = this._quatDirtyId; + var c1 = Math.cos(this._x / 2); + var c2 = Math.cos(this._y / 2); + var c3 = Math.cos(this._z / 2); + var s = this._sign; + var s1 = s * Math.sin(this._x / 2); + var s2 = s * Math.sin(this._y / 2); + var s3 = s * Math.sin(this._z / 2); + var q = this.quaternion; + q[0] = s1 * c2 * c3 + c1 * s2 * s3; + q[1] = c1 * s2 * c3 - s1 * c2 * s3; + q[2] = c1 * c2 * s3 + s1 * s2 * c3; + q[3] = c1 * c2 * c3 - s1 * s2 * s3; + return true; + }; + return Euler; + }()); + pixi_projection.Euler = Euler; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var mat4id = [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1]; + var Matrix3d = (function () { + function Matrix3d(backingArray) { + this.floatArray = null; + this._dirtyId = 0; + this._updateId = -1; + this._mat4inv = null; + this.cacheInverse = false; + this.mat4 = new Float64Array(backingArray || mat4id); + } + Object.defineProperty(Matrix3d.prototype, "a", { + get: function () { + return this.mat4[0] / this.mat4[15]; + }, + set: function (value) { + this.mat4[0] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "b", { + get: function () { + return this.mat4[1] / this.mat4[15]; + }, + set: function (value) { + this.mat4[1] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "c", { + get: function () { + return this.mat4[4] / this.mat4[15]; + }, + set: function (value) { + this.mat4[4] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "d", { + get: function () { + return this.mat4[5] / this.mat4[15]; + }, + set: function (value) { + this.mat4[5] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "tx", { + get: function () { + return this.mat4[12] / this.mat4[15]; + }, + set: function (value) { + this.mat4[12] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "ty", { + get: function () { + return this.mat4[13] / this.mat4[15]; + }, + set: function (value) { + this.mat4[13] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Matrix3d.prototype.set = function (a, b, c, d, tx, ty) { + var mat4 = this.mat4; + mat4[0] = a; + mat4[1] = b; + mat4[2] = 0; + mat4[3] = 0; + mat4[4] = c; + mat4[5] = d; + mat4[6] = 0; + mat4[7] = 0; + mat4[8] = 0; + mat4[9] = 0; + mat4[10] = 1; + mat4[11] = 0; + mat4[12] = tx; + mat4[13] = ty; + mat4[14] = 0; + mat4[15] = 1; + return this; + }; + Matrix3d.prototype.toArray = function (transpose, out) { + if (!this.floatArray) { + this.floatArray = new Float32Array(9); + } + var array = out || this.floatArray; + var mat3 = this.mat4; + if (transpose) { + array[0] = mat3[0]; + array[1] = mat3[1]; + array[2] = mat3[3]; + array[3] = mat3[4]; + array[4] = mat3[5]; + array[5] = mat3[7]; + array[6] = mat3[12]; + array[7] = mat3[13]; + array[8] = mat3[15]; + } + else { + array[0] = mat3[0]; + array[1] = mat3[4]; + array[2] = mat3[12]; + array[3] = mat3[2]; + array[4] = mat3[6]; + array[5] = mat3[13]; + array[6] = mat3[3]; + array[7] = mat3[7]; + array[8] = mat3[15]; + } + return array; + }; + Matrix3d.prototype.setToTranslation = function (tx, ty, tz) { + var mat4 = this.mat4; + mat4[0] = 1; + mat4[1] = 0; + mat4[2] = 0; + mat4[3] = 0; + mat4[4] = 0; + mat4[5] = 1; + mat4[6] = 0; + mat4[7] = 0; + mat4[8] = 0; + mat4[9] = 0; + mat4[10] = 1; + mat4[11] = 0; + mat4[12] = tx; + mat4[13] = ty; + mat4[14] = tz; + mat4[15] = 1; + }; + Matrix3d.prototype.setToRotationTranslationScale = function (quat, tx, ty, tz, sx, sy, sz) { + var out = this.mat4; + var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = tx; + out[13] = ty; + out[14] = tz; + out[15] = 1; + return out; + }; + Matrix3d.prototype.apply = function (pos, newPos) { + newPos = newPos || new pixi_projection.Point3d(); + var mat4 = this.mat4; + var x = pos.x; + var y = pos.y; + var z = pos.z || 0; + var w = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + newPos.x = w * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + newPos.y = w * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + newPos.z = w * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + return newPos; + }; + Matrix3d.prototype.translate = function (tx, ty, tz) { + var a = this.mat4; + a[12] = a[0] * tx + a[4] * ty + a[8] * tz + a[12]; + a[13] = a[1] * tx + a[5] * ty + a[9] * tz + a[13]; + a[14] = a[2] * tx + a[6] * ty + a[10] * tz + a[14]; + a[15] = a[3] * tx + a[7] * ty + a[11] * tz + a[15]; + return this; + }; + Matrix3d.prototype.scale = function (x, y, z) { + var mat4 = this.mat4; + mat4[0] *= x; + mat4[1] *= x; + mat4[2] *= x; + mat4[3] *= x; + mat4[4] *= y; + mat4[5] *= y; + mat4[6] *= y; + mat4[7] *= y; + if (z !== undefined) { + mat4[8] *= z; + mat4[9] *= z; + mat4[10] *= z; + mat4[11] *= z; + } + return this; + }; + Matrix3d.prototype.scaleAndTranslate = function (scaleX, scaleY, scaleZ, tx, ty, tz) { + var mat4 = this.mat4; + mat4[0] = scaleX * mat4[0] + tx * mat4[3]; + mat4[1] = scaleY * mat4[1] + ty * mat4[3]; + mat4[2] = scaleZ * mat4[2] + tz * mat4[3]; + mat4[4] = scaleX * mat4[4] + tx * mat4[7]; + mat4[5] = scaleY * mat4[5] + ty * mat4[7]; + mat4[6] = scaleZ * mat4[6] + tz * mat4[7]; + mat4[8] = scaleX * mat4[8] + tx * mat4[11]; + mat4[9] = scaleY * mat4[9] + ty * mat4[11]; + mat4[10] = scaleZ * mat4[10] + tz * mat4[11]; + mat4[12] = scaleX * mat4[12] + tx * mat4[15]; + mat4[13] = scaleY * mat4[13] + ty * mat4[15]; + mat4[14] = scaleZ * mat4[14] + tz * mat4[15]; + }; + Matrix3d.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new pixi_projection.Point3d(); + if (!this._mat4inv) { + this._mat4inv = new Float64Array(16); + } + var mat4 = this._mat4inv; + var a = this.mat4; + var x = pos.x; + var y = pos.y; + var z = pos.z || 0; + if (!this.cacheInverse || this._updateId !== this._dirtyId) { + this._updateId = this._dirtyId; + Matrix3d.glMatrixMat4Invert(mat4, a); + } + var w1 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + var x1 = w1 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + var y1 = w1 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + var z1 = w1 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + z += 1.0; + var w2 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + var x2 = w2 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + var y2 = w2 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + var z2 = w2 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + if (Math.abs(z1 - z2) < 1e-10) { + newPos.set(NaN, NaN, 0); + } + var alpha = (0 - z1) / (z2 - z1); + newPos.set((x2 - x1) * alpha + x1, (y2 - y1) * alpha + y1, 0.0); + return newPos; + }; + Matrix3d.prototype.invert = function () { + Matrix3d.glMatrixMat4Invert(this.mat4, this.mat4); + return this; + }; + Matrix3d.prototype.invertCopyTo = function (matrix) { + if (!this._mat4inv) { + this._mat4inv = new Float64Array(16); + } + var mat4 = this._mat4inv; + var a = this.mat4; + if (!this.cacheInverse || this._updateId !== this._dirtyId) { + this._updateId = this._dirtyId; + Matrix3d.glMatrixMat4Invert(mat4, a); + } + matrix.mat4.set(mat4); + }; + Matrix3d.prototype.identity = function () { + var mat3 = this.mat4; + mat3[0] = 1; + mat3[1] = 0; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = 0; + mat3[5] = 1; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 0; + mat3[9] = 0; + mat3[10] = 1; + mat3[11] = 0; + mat3[12] = 0; + mat3[13] = 0; + mat3[14] = 0; + mat3[15] = 1; + return this; + }; + Matrix3d.prototype.clone = function () { + return new Matrix3d(this.mat4); + }; + Matrix3d.prototype.copyTo3d = function (matrix) { + var mat3 = this.mat4; + var ar2 = matrix.mat4; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[2]; + ar2[3] = mat3[3]; + ar2[4] = mat3[4]; + ar2[5] = mat3[5]; + ar2[6] = mat3[6]; + ar2[7] = mat3[7]; + ar2[8] = mat3[8]; + return matrix; + }; + Matrix3d.prototype.copyTo2d = function (matrix) { + var mat3 = this.mat4; + var ar2 = matrix.mat3; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[3]; + ar2[3] = mat3[4]; + ar2[4] = mat3[5]; + ar2[5] = mat3[7]; + ar2[6] = mat3[12]; + ar2[7] = mat3[13]; + ar2[8] = mat3[15]; + return matrix; + }; + Matrix3d.prototype.copyTo2dOr3d = function (matrix) { + if (matrix instanceof pixi_projection.Matrix2d) { + return this.copyTo2d(matrix); + } + else { + return this.copyTo3d(matrix); + } + }; + Matrix3d.prototype.copyTo = function (matrix, affine, preserveOrientation) { + var mat3 = this.mat4; + var d = 1.0 / mat3[15]; + var tx = mat3[12] * d, ty = mat3[13] * d; + matrix.a = (mat3[0] - mat3[3] * tx) * d; + matrix.b = (mat3[1] - mat3[3] * ty) * d; + matrix.c = (mat3[4] - mat3[7] * tx) * d; + matrix.d = (mat3[5] - mat3[7] * ty) * d; + matrix.tx = tx; + matrix.ty = ty; + if (affine >= 2) { + var D = matrix.a * matrix.d - matrix.b * matrix.c; + if (!preserveOrientation) { + D = Math.abs(D); + } + if (affine === pixi_projection.AFFINE.POINT) { + if (D > 0) { + D = 1; + } + else + D = -1; + matrix.a = D; + matrix.b = 0; + matrix.c = 0; + matrix.d = D; + } + else if (affine === pixi_projection.AFFINE.AXIS_X) { + D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); + matrix.c = 0; + matrix.d = D; + } + else if (affine === pixi_projection.AFFINE.AXIS_Y) { + D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); + matrix.a = D; + matrix.c = 0; + } + } + return matrix; + }; + Matrix3d.prototype.copyFrom = function (matrix) { + var mat3 = this.mat4; + mat3[0] = matrix.a; + mat3[1] = matrix.b; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = matrix.c; + mat3[5] = matrix.d; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 0; + mat3[9] = 0; + mat3[10] = 1; + mat3[11] = 0; + mat3[12] = matrix.tx; + mat3[13] = matrix.ty; + mat3[14] = 0; + mat3[15] = 1; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMultLegacy = function (pt, lt) { + var out = this.mat4; + var b = lt.mat4; + var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a30 = pt.tx, a31 = pt.ty; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0 * a00 + b1 * a10 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b3 * a31; + out[2] = b2; + out[3] = b3; + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + out[4] = b0 * a00 + b1 * a10 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b3 * a31; + out[6] = b2; + out[7] = b3; + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + out[8] = b0 * a00 + b1 * a10 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b3 * a31; + out[10] = b2; + out[11] = b3; + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + out[12] = b0 * a00 + b1 * a10 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b3 * a31; + out[14] = b2; + out[15] = b3; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMultLegacy2 = function (pt, lt) { + var out = this.mat4; + var a = pt.mat4; + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b30 = lt.tx, b31 = lt.ty; + out[0] = b00 * a00 + b01 * a10; + out[1] = b00 * a01 + b01 * a11; + out[2] = b00 * a02 + b01 * a12; + out[3] = b00 * a03 + b01 * a13; + out[4] = b10 * a00 + b11 * a10; + out[5] = b10 * a01 + b11 * a11; + out[6] = b10 * a02 + b11 * a12; + out[7] = b10 * a03 + b11 * a13; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = b30 * a00 + b31 * a10 + a[12]; + out[13] = b30 * a01 + b31 * a11 + a[13]; + out[14] = b30 * a02 + b31 * a12 + a[14]; + out[15] = b30 * a03 + b31 * a13 + a[15]; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMult = function (pt, lt) { + Matrix3d.glMatrixMat4Multiply(this.mat4, pt.mat4, lt.mat4); + this._dirtyId++; + return this; + }; + Matrix3d.prototype.prepend = function (lt) { + if (lt.mat4) { + this.setToMult(lt, this); + } + else { + this.setToMultLegacy(lt, this); + } + }; + Matrix3d.glMatrixMat4Invert = function (out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (!det) { + return null; + } + det = 1.0 / det; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + return out; + }; + Matrix3d.glMatrixMat4Multiply = function (out, a, b) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + return out; + }; + Matrix3d.IDENTITY = new Matrix3d(); + Matrix3d.TEMP_MATRIX = new Matrix3d(); + return Matrix3d; + }()); + pixi_projection.Matrix3d = Matrix3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var ObservableEuler = (function () { + function ObservableEuler(cb, scope, x, y, z) { + this.cb = cb; + this.scope = scope; + this._quatUpdateId = -1; + this._quatDirtyId = 0; + this._sign = 1; + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this.quaternion = new Float64Array(4); + this.quaternion[3] = 1; + this.update(); + } + Object.defineProperty(ObservableEuler.prototype, "x", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "pitch", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "yaw", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "roll", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + ObservableEuler.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = y || 0; + var _z = z || 0; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }; + ; + ObservableEuler.prototype.copyFrom = function (euler) { + var _x = euler.x; + var _y = euler.y; + var _z = euler.z; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }; + ObservableEuler.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + ObservableEuler.prototype.equals = function (euler) { + return this._x === euler.x + && this._y === euler.y + && this._z === euler.z; + }; + ObservableEuler.prototype.clone = function () { + return new pixi_projection.Euler(this._x, this._y, this._z); + }; + ObservableEuler.prototype.update = function () { + if (this._quatUpdateId === this._quatDirtyId) { + return false; + } + this._quatUpdateId = this._quatDirtyId; + var c1 = Math.cos(this._x / 2); + var c2 = Math.cos(this._y / 2); + var c3 = Math.cos(this._z / 2); + var s = this._sign; + var s1 = s * Math.sin(this._x / 2); + var s2 = s * Math.sin(this._y / 2); + var s3 = s * Math.sin(this._z / 2); + var q = this.quaternion; + q[0] = s1 * c2 * c3 + c1 * s2 * s3; + q[1] = c1 * s2 * c3 - s1 * c2 * s3; + q[2] = c1 * c2 * s3 + s1 * s2 * c3; + q[3] = c1 * c2 * c3 - s1 * s2 * s3; + return true; + }; + return ObservableEuler; + }()); + pixi_projection.ObservableEuler = ObservableEuler; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + PIXI.ObservablePoint.prototype.copy = function (point) { + }; + var Point3d = (function (_super) { + __extends(Point3d, _super); + function Point3d(x, y, z) { + var _this = _super.call(this, x, y) || this; + _this.z = z; + return _this; + } + Point3d.prototype.set = function (x, y, z) { + this.x = x || 0; + this.y = (y === undefined) ? this.x : (y || 0); + this.z = (y === undefined) ? this.x : (z || 0); + }; + Point3d.prototype.copyFrom = function (p) { + this.set(p.x, p.y, p.z || 0); + return this; + }; + Point3d.prototype.copyTo = function (p) { + p.set(this.x, this.y, this.z); + return p; + }; + return Point3d; + }(PIXI.Point)); + pixi_projection.Point3d = Point3d; + var ObservablePoint3d = (function (_super) { + __extends(ObservablePoint3d, _super); + function ObservablePoint3d() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._z = 0; + return _this; + } + Object.defineProperty(ObservablePoint3d.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + ObservablePoint3d.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = (y === undefined) ? _x : (y || 0); + var _z = (y === undefined) ? _x : (z || 0); + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this.cb.call(this.scope); + } + }; + ObservablePoint3d.prototype.copyFrom = function (p) { + this.set(p.x, p.y, p.z || 0); + return this; + }; + ObservablePoint3d.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + return ObservablePoint3d; + }(PIXI.ObservablePoint)); + pixi_projection.ObservablePoint3d = ObservablePoint3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempMat = new pixi_projection.Matrix3d(); + var Projection3d = (function (_super) { + __extends(Projection3d, _super); + function Projection3d(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this.cameraMatrix = null; + _this._cameraMode = false; + _this.position = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); + _this.scale = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 1, 1); + _this.euler = new pixi_projection.ObservableEuler(_this.onChange, _this, 0, 0, 0); + _this.pivot = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); + _this.local = new pixi_projection.Matrix3d(); + _this.world = new pixi_projection.Matrix3d(); + _this.local.cacheInverse = true; + _this.world.cacheInverse = true; + _this.position._z = 0; + _this.scale._z = 1; + _this.pivot._z = 0; + return _this; + } + Object.defineProperty(Projection3d.prototype, "cameraMode", { + get: function () { + return this._cameraMode; + }, + set: function (value) { + if (this._cameraMode === value) { + return; + } + this._cameraMode = value; + this.euler._sign = this._cameraMode ? -1 : 1; + this.euler._quatDirtyId++; + if (value) { + this.cameraMatrix = new pixi_projection.Matrix3d(); + } + }, + enumerable: true, + configurable: true + }); + Projection3d.prototype.onChange = function () { + this._projID++; + }; + Projection3d.prototype.clear = function () { + if (this.cameraMatrix) { + this.cameraMatrix.identity(); + } + this.position.set(0, 0, 0); + this.scale.set(1, 1, 1); + this.euler.set(0, 0, 0); + this.pivot.set(0, 0, 0); + _super.prototype.clear.call(this); + }; + Projection3d.prototype.updateLocalTransform = function (lt) { + if (this._projID === 0) { + this.local.copyFrom(lt); + return; + } + var matrix = this.local; + var euler = this.euler; + var pos = this.position; + var scale = this.scale; + var pivot = this.pivot; + euler.update(); + if (!this.cameraMode) { + matrix.setToRotationTranslationScale(euler.quaternion, pos._x, pos._y, pos._z, scale._x, scale._y, scale._z); + matrix.translate(-pivot._x, -pivot._y, -pivot._z); + matrix.setToMultLegacy(lt, matrix); + return; + } + matrix.setToMultLegacy(lt, this.cameraMatrix); + matrix.translate(pivot._x, pivot._y, pivot._z); + matrix.scale(1.0 / scale._x, 1.0 / scale._y, 1.0 / scale._z); + tempMat.setToRotationTranslationScale(euler.quaternion, 0, 0, 0, 1, 1, 1); + matrix.setToMult(matrix, tempMat); + matrix.translate(-pos._x, -pos._y, -pos._z); + this.local._dirtyId++; + }; + return Projection3d; + }(pixi_projection.LinearProjection)); + pixi_projection.Projection3d = Projection3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Mesh3d2d = (function (_super) { + __extends(Mesh3d2d, _super); + function Mesh3d2d(geometry, shader, state, drawMode) { + var _this = _super.call(this, geometry, shader, state, drawMode) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection3d(_this.transform); + return _this; + } + Mesh3d2d.prototype.calculateVertices = function () { + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + var geometry = this.geometry; + var vertices = geometry.buffers[0].data; + var thisAny = this; + if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { + return; + } + thisAny._transformID = thisAny.transform._worldID; + if (thisAny.vertexData.length !== vertices.length) { + thisAny.vertexData = new Float32Array(vertices.length); + } + if (this.vertexData2d.length !== vertices.length * 3 / 2) { + this.vertexData2d = new Float32Array(vertices.length * 3); + } + var wt = this.proj.world.mat4; + var vertexData2d = this.vertexData2d; + var vertexData = thisAny.vertexData; + for (var i = 0; i < vertexData.length / 2; i++) { + var x = vertices[(i * 2)]; + var y = vertices[(i * 2) + 1]; + var xx = (wt[0] * x) + (wt[4] * y) + wt[12]; + var yy = (wt[1] * x) + (wt[5] * y) + wt[13]; + var ww = (wt[3] * x) + (wt[7] * y) + wt[15]; + vertexData2d[i * 3] = xx; + vertexData2d[i * 3 + 1] = yy; + vertexData2d[i * 3 + 2] = ww; + vertexData[(i * 2)] = xx / ww; + vertexData[(i * 2) + 1] = yy / ww; + } + thisAny.vertexDirty = geometry.vertexDirtyId; + }; + Object.defineProperty(Mesh3d2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Mesh3d2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Mesh3d2d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Mesh3d2d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Mesh3d2d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Mesh3d2d; + }(PIXI.Mesh)); + pixi_projection.Mesh3d2d = Mesh3d2d; + Mesh3d2d.prototype._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; + var SimpleMesh3d2d = (function (_super) { + __extends(SimpleMesh3d2d, _super); + function SimpleMesh3d2d(texture, vertices, uvs, indices, drawMode) { + var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }), null, drawMode) || this; + _this.autoUpdate = true; + _this.geometry.getBuffer('aVertexPosition').static = false; + return _this; + } + Object.defineProperty(SimpleMesh3d2d.prototype, "vertices", { + get: function () { + return this.geometry.getBuffer('aVertexPosition').data; + }, + set: function (value) { + this.geometry.getBuffer('aVertexPosition').data = value; + }, + enumerable: true, + configurable: true + }); + SimpleMesh3d2d.prototype._render = function (renderer) { + if (this.autoUpdate) { + this.geometry.getBuffer('aVertexPosition').update(); + } + _super.prototype._render.call(this, renderer); + }; + return SimpleMesh3d2d; + }(Mesh3d2d)); + pixi_projection.SimpleMesh3d2d = SimpleMesh3d2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite3d = (function (_super) { + __extends(Sprite3d, _super); + function Sprite3d(texture) { + var _this = _super.call(this, texture) || this; + _this.vertexData2d = null; + _this.culledByFrustrum = false; + _this.trimmedCulledByFrustrum = false; + _this.proj = new pixi_projection.Projection3d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Sprite3d.prototype.calculateVertices = function () { + var texture = this._texture; + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + if (!this.vertexData2d) { + this.vertexData2d = new Float32Array(12); + } + var wid = this.transform._worldID; + var tuid = texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + if (this._textureID !== tuid) { + this.uvs = texture._uvs.uvsFloat32; + } + this._transformID = wid; + this._textureID = tuid; + var wt = this.proj.world.mat4; + var vertexData2d = this.vertexData2d; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + var culled = false; + var z; + vertexData2d[0] = (wt[0] * w1) + (wt[4] * h1) + wt[12]; + vertexData2d[1] = (wt[1] * w1) + (wt[5] * h1) + wt[13]; + z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; + vertexData2d[2] = (wt[3] * w1) + (wt[7] * h1) + wt[15]; + culled = culled || z < 0; + vertexData2d[3] = (wt[0] * w0) + (wt[4] * h1) + wt[12]; + vertexData2d[4] = (wt[1] * w0) + (wt[5] * h1) + wt[13]; + z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; + vertexData2d[5] = (wt[3] * w0) + (wt[7] * h1) + wt[15]; + culled = culled || z < 0; + vertexData2d[6] = (wt[0] * w0) + (wt[4] * h0) + wt[12]; + vertexData2d[7] = (wt[1] * w0) + (wt[5] * h0) + wt[13]; + z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; + vertexData2d[8] = (wt[3] * w0) + (wt[7] * h0) + wt[15]; + culled = culled || z < 0; + vertexData2d[9] = (wt[0] * w1) + (wt[4] * h0) + wt[12]; + vertexData2d[10] = (wt[1] * w1) + (wt[5] * h0) + wt[13]; + z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; + vertexData2d[11] = (wt[3] * w1) + (wt[7] * h0) + wt[15]; + culled = culled || z < 0; + this.culledByFrustrum = culled; + vertexData[0] = vertexData2d[0] / vertexData2d[2]; + vertexData[1] = vertexData2d[1] / vertexData2d[2]; + vertexData[2] = vertexData2d[3] / vertexData2d[5]; + vertexData[3] = vertexData2d[4] / vertexData2d[5]; + vertexData[4] = vertexData2d[6] / vertexData2d[8]; + vertexData[5] = vertexData2d[7] / vertexData2d[8]; + vertexData[6] = vertexData2d[9] / vertexData2d[11]; + vertexData[7] = vertexData2d[10] / vertexData2d[11]; + }; + Sprite3d.prototype.calculateTrimmedVertices = function () { + if (this.proj._affine) { + _super.prototype.calculateTrimmedVertices.call(this); + return; + } + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var wt = this.proj.world.mat4; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + var culled = false; + var z; + var w = 1.0 / ((wt[3] * w1) + (wt[7] * h1) + wt[15]); + vertexData[0] = w * ((wt[0] * w1) + (wt[4] * h1) + wt[12]); + vertexData[1] = w * ((wt[1] * w1) + (wt[5] * h1) + wt[13]); + z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w0) + (wt[7] * h1) + wt[15]); + vertexData[2] = w * ((wt[0] * w0) + (wt[4] * h1) + wt[12]); + vertexData[3] = w * ((wt[1] * w0) + (wt[5] * h1) + wt[13]); + z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w0) + (wt[7] * h0) + wt[15]); + vertexData[4] = w * ((wt[0] * w0) + (wt[4] * h0) + wt[12]); + vertexData[5] = w * ((wt[1] * w0) + (wt[5] * h0) + wt[13]); + z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w1) + (wt[7] * h0) + wt[15]); + vertexData[6] = w * ((wt[0] * w1) + (wt[4] * h0) + wt[12]); + vertexData[7] = w * ((wt[1] * w1) + (wt[5] * h0) + wt[13]); + z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; + culled = culled || z < 0; + this.culledByFrustrum = culled; + }; + Sprite3d.prototype._calculateBounds = function () { + this.calculateVertices(); + if (this.culledByFrustrum) { + return; + } + var trim = this._texture.trim; + var orig = this._texture.orig; + if (!trim || (trim.width === orig.width && trim.height === orig.height)) { + this._bounds.addQuad(this.vertexData); + return; + } + this.calculateTrimmedVertices(); + if (!this.trimmedCulledByFrustrum) { + this._bounds.addQuad(this.vertexTrimmedData); + } + }; + Sprite3d.prototype._render = function (renderer) { + this.calculateVertices(); + if (this.culledByFrustrum) { + return; + } + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + Sprite3d.prototype.containsPoint = function (point) { + if (this.culledByFrustrum) { + return false; + } + return _super.prototype.containsPoint.call(this, point); + }; + Object.defineProperty(Sprite3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Sprite3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Sprite3d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Sprite3d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Sprite3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Sprite3d; + }(PIXI.Sprite)); + pixi_projection.Sprite3d = Sprite3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text3d = (function (_super) { + __extends(Text3d, _super); + function Text3d(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection3d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Object.defineProperty(Text3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Text3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Text3d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Text3d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Text3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Text3d; + }(PIXI.Text)); + pixi_projection.Text3d = Text3d; + Text3d.prototype.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; + Text3d.prototype.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; + Text3d.prototype._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; + Text3d.prototype.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; + Text3d.prototype._render = pixi_projection.Sprite3d.prototype._render; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var containerProps = { + worldTransform: { + get: pixi_projection.container3dWorldTransform, + enumerable: true, + configurable: true + }, + position3d: { + get: function () { return this.proj.position; }, + set: function (value) { this.proj.position.copy(value); } + }, + scale3d: { + get: function () { return this.proj.scale; }, + set: function (value) { this.proj.scale.copy(value); } + }, + pivot3d: { + get: function () { return this.proj.pivot; }, + set: function (value) { this.proj.pivot.copy(value); } + }, + euler: { + get: function () { return this.proj.euler; }, + set: function (value) { this.proj.euler.copy(value); } + } + }; + function convertTo3d() { + if (this.proj) + return; + this.proj = new pixi_projection.Projection3d(this.transform); + this.toLocal = pixi_projection.Container3d.prototype.toLocal; + this.isFrontFace = pixi_projection.Container3d.prototype.isFrontFace; + this.getDepth = pixi_projection.Container3d.prototype.getDepth; + Object.defineProperties(this, containerProps); + } + PIXI.Container.prototype.convertTo3d = convertTo3d; + PIXI.Sprite.prototype.convertTo3d = function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; + this.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; + this.pluginName = 'batch2d'; + convertTo3d.call(this); + }; + PIXI.Container.prototype.convertSubtreeTo3d = function () { + this.convertTo3d(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo3d(); + } + }; + if (PIXI.SimpleMesh) { + PIXI.SimpleMesh.prototype.convertTo3d = + PIXI.SimpleRope.prototype.convertTo3d = + function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Mesh3d2d.prototype.calculateVertices; + this._renderDefault = pixi_projection.Mesh3d2d.prototype._renderDefault; + if (this.material.pluginName !== 'batch2d') { + this.material = new PIXI.MeshMaterial(this.material.texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }); + } + convertTo3d.call(this); + }; + } +})(pixi_projection || (pixi_projection = {})); /*! * VERSION: 2.1.3 @@ -74907,14 +74907,14 @@ var Wait = require('./wait'); var Ease = function (_Events) { _inherits(Ease, _Events); - /** - * Main class for creating eases - * @param {object} [options] - * @param {boolean} [options.noTicker] don't add the update function to PIXI.ticker - * @param {PIXI.ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for the list - * @extends eventemitter - * @fire done - * @fire each + /** + * Main class for creating eases + * @param {object} [options] + * @param {boolean} [options.noTicker] don't add the update function to PIXI.ticker + * @param {PIXI.ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for the list + * @extends eventemitter + * @fire done + * @fire each */ function Ease(options) { _classCallCheck(this, Ease); @@ -74936,10 +74936,10 @@ var Ease = function (_Events) { return _this; } - /** - * Add animation(s) to animation list - * @param {(object|object[])} any animation class - * @return {object} first animation + /** + * Add animation(s) to animation list + * @param {(object|object[])} any animation class + * @return {object} first animation */ @@ -75007,9 +75007,9 @@ var Ease = function (_Events) { return first; } - /** - * remove animation(s) - * @param {object|array} animate - the animation (or array of animations) to remove; can be null + /** + * remove animation(s) + * @param {object|array} animate - the animation (or array of animations) to remove; can be null */ }, { @@ -75025,9 +75025,9 @@ var Ease = function (_Events) { } } - /** - * remove all animations from list - * @inherited from yy-loop + /** + * remove all animations from list + * @inherited from yy-loop */ }, { @@ -75040,11 +75040,11 @@ var Ease = function (_Events) { } } - /** - * update frame - * this is automatically added to PIXI.ticker unless options.noTicker is set - * if using options.noTicker, this should be called manually - * @param {number} elasped time in MS since last update + /** + * update frame + * this is automatically added to PIXI.ticker unless options.noTicker is set + * if using options.noTicker, this should be called manually + * @param {number} elasped time in MS since last update */ }, { @@ -75073,50 +75073,50 @@ var Ease = function (_Events) { } } - /** - * number of animations - * @type {number} + /** + * number of animations + * @type {number} */ }, { key: 'to', - /** - * default options for all eases - * @typedef {object} EaseOptions - * @param {object} [EaseOptions.options] - * @param {number} [EaseOptions.options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [EaseOptions.options.pause] start the animation paused - * @param {boolean|number} [EaseOptions.options.repeat] true: repeat animation forever n: repeat animation n times - * @param {boolean|number} [EaseOptions.options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * @param {Function} [EaseOptions.options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {string|Function} [EaseOptions.options.ease] name or function from easing.js (see http://easings.net for examples) + /** + * default options for all eases + * @typedef {object} EaseOptions + * @param {object} [EaseOptions.options] + * @param {number} [EaseOptions.options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [EaseOptions.options.pause] start the animation paused + * @param {boolean|number} [EaseOptions.options.repeat] true: repeat animation forever n: repeat animation n times + * @param {boolean|number} [EaseOptions.options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * @param {Function} [EaseOptions.options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {string|Function} [EaseOptions.options.ease] name or function from easing.js (see http://easings.net for examples) */ - /** - * ease parameters of object - * @param {PIXI.DisplayObject} object to animate - * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} - * @param {number} duration - time to run - * @fires done - * @fires wait - * @fires first - * @fires each - * @fires loop - * @fires reverse + /** + * ease parameters of object + * @param {PIXI.DisplayObject} object to animate + * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} + * @param {number} duration - time to run + * @fires done + * @fires wait + * @fires first + * @fires each + * @fires loop + * @fires reverse */ value: function to() { return this.add(new (Function.prototype.bind.apply(To, [null].concat(Array.prototype.slice.call(arguments))))()); } - /** - * animate object's {x, y} using an angle - * @param {object} object to animate - * @param {number} angle in radians - * @param {number} speed in pixels/millisecond - * @param {number} [duration=0] in milliseconds; if 0, then continues forever - * @param {object} [options] @see {@link Wait} + /** + * animate object's {x, y} using an angle + * @param {object} object to animate + * @param {number} angle in radians + * @param {number} speed in pixels/millisecond + * @param {number} [duration=0] in milliseconds; if 0, then continues forever + * @param {object} [options] @see {@link Wait} */ }, { @@ -75186,9 +75186,9 @@ var Ease = function (_Events) { return this.list.length; } - /** - * number of active animations - * @type {number} + /** + * number of active animations + * @type {number} */ }, { @@ -75780,24 +75780,24 @@ var wait = require('./wait'); var to = function (_wait) { _inherits(to, _wait); - /** - * @private - * @param {object} object to animate - * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} - * @param {number} duration - time to run - * @param {object} [options] - * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [options.pause] start the animation paused - * @param {boolean|number} [options.repeat] true: repeat animation forever n: repeat animation n times - * @param {boolean|number} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {string|Function} [options.ease] name or function from easing.js (see http://easings.net for examples) - * @emits to:done animation expires - * @emits to:wait each update during a wait - * @emits to:first first update when animation starts - * @emits to:each each update while animation is running - * @emits to:loop when animation is repeated - * @emits to:reverse when animation is reversed + /** + * @private + * @param {object} object to animate + * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} + * @param {number} duration - time to run + * @param {object} [options] + * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [options.pause] start the animation paused + * @param {boolean|number} [options.repeat] true: repeat animation forever n: repeat animation n times + * @param {boolean|number} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {string|Function} [options.ease] name or function from easing.js (see http://easings.net for examples) + * @emits to:done animation expires + * @emits to:wait each update during a wait + * @emits to:first first update when animation starts + * @emits to:each each update while animation is running + * @emits to:loop when animation is repeated + * @emits to:reverse when animation is reversed */ function to(object, goto, duration, options) { _classCallCheck(this, to); @@ -75822,9 +75822,9 @@ var to = function (_wait) { return _this; } - /** - * converts scale from { scale: n } to { scale: { x: n, y: n }} - * @private + /** + * converts scale from { scale: n } to { scale: { x: n, y: n }} + * @private */ @@ -75976,24 +75976,24 @@ var EventEmitter = require('eventemitter3'); var wait = function (_EventEmitter) { _inherits(wait, _EventEmitter); - /** - * @param {object|object[]} object or list of objects to animate - * @param {object} [options] - * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [options.pause] start the animation paused - * @param {(boolean|number)} [options.repeat] true: repeat animation forever n: repeat animation n times - * @param {(boolean|number)} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * - * @param {number} [options.id] user-generated id (e.g., I use it to properly load animations when an object has multiple animations running) - * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {Function|string} [options.ease] function (or penner function name) from easing.js (see http://easings.net for examples)* - * - * @emits {done} animation expires - * @emits {wait} each update during a wait - * @emits {first} first update when animation starts - * @emits {each} each update while animation is running - * @emits {loop} when animation is repeated - * @emits {reverse} when animation is reversed + /** + * @param {object|object[]} object or list of objects to animate + * @param {object} [options] + * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [options.pause] start the animation paused + * @param {(boolean|number)} [options.repeat] true: repeat animation forever n: repeat animation n times + * @param {(boolean|number)} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * + * @param {number} [options.id] user-generated id (e.g., I use it to properly load animations when an object has multiple animations running) + * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {Function|string} [options.ease] function (or penner function name) from easing.js (see http://easings.net for examples)* + * + * @emits {done} animation expires + * @emits {wait} each update during a wait + * @emits {first} first update when animation starts + * @emits {each} each update while animation is running + * @emits {loop} when animation is repeated + * @emits {reverse} when animation is reversed */ function wait(object, options) { _classCallCheck(this, wait); @@ -76060,9 +76060,9 @@ var wait = function (_EventEmitter) { this.duration = _load.duration; } - /** - * pause this entry - * @type {boolean} + /** + * pause this entry + * @type {boolean} */ }, { @@ -78794,19 +78794,19 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Bounce, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') - * @param {number} [options.friction=0.5] friction to apply to decelerate if active - * @param {number} [options.time=150] time in ms to finish bounce - * @param {string|function} [ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @fires bounce-start-x - * @fires bounce.end-x - * @fires bounce-start-y - * @fires bounce-end-y + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') + * @param {number} [options.friction=0.5] friction to apply to decelerate if active + * @param {number} [options.time=150] time in ms to finish bounce + * @param {string|function} [ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @fires bounce-start-x + * @fires bounce.end-x + * @fires bounce-start-y + * @fires bounce-end-y */ function Bounce(parent, options) { _classCallCheck(this, Bounce); @@ -79004,13 +79004,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(ClampZoom, _Plugin); - /** - * @private - * @param {object} [options] - * @param {number} [options.minWidth] minimum width - * @param {number} [options.minHeight] minimum height - * @param {number} [options.maxWidth] maximum width - * @param {number} [options.maxHeight] maximum height + /** + * @private + * @param {object} [options] + * @param {number} [options.minWidth] minimum width + * @param {number} [options.minHeight] minimum height + * @param {number} [options.maxWidth] maximum width + * @param {number} [options.maxHeight] maximum height */ function ClampZoom(parent, options) { _classCallCheck(this, ClampZoom); @@ -79083,15 +79083,15 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(clamp, _Plugin); - /** - * @private - * @param {object} options - * @param {(number|boolean)} [options.left] clamp left; true=0 - * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth - * @param {(number|boolean)} [options.top] clamp top; true=0 - * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight - * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * @private + * @param {object} options + * @param {(number|boolean)} [options.left] clamp left; true=0 + * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth + * @param {(number|boolean)} [options.top] clamp top; true=0 + * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight + * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ function clamp(parent, options) { _classCallCheck(this, clamp); @@ -79248,13 +79248,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Decelerate, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.friction=0.95] percent to decelerate after movement - * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) - * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.friction=0.95] percent to decelerate after movement + * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) + * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration */ function Decelerate(parent, options) { _classCallCheck(this, Decelerate); @@ -79328,11 +79328,11 @@ module.exports = function (_Plugin) { } } - /** - * manually activate plugin - * @param {object} options - * @param {number} [options.x] - * @param {number} [options.y] + /** + * manually activate plugin + * @param {object} options + * @param {number} [options.x] + * @param {number} [options.y] */ }, { @@ -79404,17 +79404,17 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Drag, _Plugin); - /** - * enable one-finger touch to drag - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {string} [options.direction=all] direction to drag (all, x, or y) - * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) - * @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin - * @param {boolean} [options.reverse] reverse the direction of the wheel scroll - * @param {boolean|string} [options.clampWheel] (true, x, or y) clamp wheel (to avoid weird bounce with mouse wheel) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * enable one-finger touch to drag + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {string} [options.direction=all] direction to drag (all, x, or y) + * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) + * @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin + * @param {boolean} [options.reverse] reverse the direction of the wheel scroll + * @param {boolean|string} [options.clampWheel] (true, x, or y) clamp wheel (to avoid weird bounce with mouse wheel) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ function Drag(parent, options) { _classCallCheck(this, Drag); @@ -79619,13 +79619,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Follow, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) - * @param {object} [options] - * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) - * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport + /** + * @private + * @param {Viewport} parent + * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) + * @param {object} [options] + * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) + * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport */ function Follow(parent, target, options) { _classCallCheck(this, Follow); @@ -79698,24 +79698,24 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(MouseEdges, _Plugin); - /** - * Scroll viewport when mouse hovers near one of the edges. - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.radius] distance from center of screen in screen pixels - * @param {number} [options.distance] distance from all sides in screen pixels - * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) - * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) - * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) - * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) - * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport - * @param {boolean} [options.reverse] reverse direction of scroll - * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed - * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) - * - * @event mouse-edge-start(Viewport) emitted when mouse-edge starts - * @event mouse-edge-end(Viewport) emitted when mouse-edge ends + /** + * Scroll viewport when mouse hovers near one of the edges. + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.radius] distance from center of screen in screen pixels + * @param {number} [options.distance] distance from all sides in screen pixels + * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) + * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) + * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) + * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) + * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport + * @param {boolean} [options.reverse] reverse direction of scroll + * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed + * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) + * + * @event mouse-edge-start(Viewport) emitted when mouse-edge starts + * @event mouse-edge-end(Viewport) emitted when mouse-edge ends */ function MouseEdges(parent, options) { _classCallCheck(this, MouseEdges); @@ -79871,13 +79871,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Pinch, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {boolean} [options.noDrag] disable two-finger dragging - * @param {number} [options.percent=1.0] percent to modify pinch speed - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {boolean} [options.noDrag] disable two-finger dragging + * @param {number} [options.percent=1.0] percent to modify pinch speed + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers */ function Pinch(parent, options) { _classCallCheck(this, Pinch); @@ -80045,24 +80045,24 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(SnapZoom, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom - * @param {boolean} [options.noMove] zoom but do not move - * - * @event snap-zoom-start(Viewport) emitted each time a fit animation starts - * @event snap-zoom-end(Viewport) emitted each time fit reaches its target - * @event snap-zoom-end(Viewport) emitted each time fit reaches its target + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom + * @param {boolean} [options.noMove] zoom but do not move + * + * @event snap-zoom-start(Viewport) emitted each time a fit animation starts + * @event snap-zoom-end(Viewport) emitted each time fit reaches its target + * @event snap-zoom-end(Viewport) emitted each time fit reaches its target */ function SnapZoom(parent, options) { _classCallCheck(this, SnapZoom); @@ -80219,25 +80219,25 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(Snap, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {number} x - * @param {number} y - * @param {object} [options] - * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center - * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location - * - * @event snap-start(Viewport) emitted each time a snap animation starts - * @event snap-restart(Viewport) emitted each time a snap resets because of a change in viewport size - * @event snap-end(Viewport) emitted each time snap reaches its target - * @event snap-remove(Viewport) emitted if snap plugin is removed + /** + * @private + * @param {Viewport} parent + * @param {number} x + * @param {number} y + * @param {object} [options] + * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center + * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location + * + * @event snap-start(Viewport) emitted each time a snap animation starts + * @event snap-restart(Viewport) emitted each time a snap resets because of a change in viewport size + * @event snap-end(Viewport) emitted each time snap reaches its target + * @event snap-remove(Viewport) emitted if snap plugin is removed */ function Snap(parent, x, y, options) { _classCallCheck(this, Snap); @@ -80413,45 +80413,45 @@ var PLUGIN_ORDER = ['drag', 'pinch', 'wheel', 'follow', 'mouse-edges', 'decelera var Viewport = function (_PIXI$Container) { _inherits(Viewport, _PIXI$Container); - /** - * @extends PIXI.Container - * @extends EventEmitter - * @param {object} [options] - * @param {number} [options.screenWidth=window.innerWidth] - * @param {number} [options.screenHeight=window.innerHeight] - * @param {number} [options.worldWidth=this.width] - * @param {number} [options.worldHeight=this.height] - * @param {number} [options.threshold = 5] number of pixels to move to trigger an input event (e.g., drag, pinch) - * @param {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} [options.forceHitArea] change the default hitArea from world size to a new value - * @param {PIXI.ticker.Ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for updates - * @param {PIXI.InteractionManager} [options.interaction=null] InteractionManager, available from instantiated WebGLRenderer/CanvasRenderer.plugins.interaction - used to calculate pointer postion relative to canvas location on screen - * @param {HTMLElement} [options.divWheel=document.body] div to attach the wheel event - * @fires clicked - * @fires drag-start - * @fires drag-end - * @fires drag-remove - * @fires pinch-start - * @fires pinch-end - * @fires pinch-remove - * @fires snap-start - * @fires snap-end - * @fires snap-remove - * @fires snap-zoom-start - * @fires snap-zoom-end - * @fires snap-zoom-remove - * @fires bounce-x-start - * @fires bounce-x-end - * @fires bounce-y-start - * @fires bounce-y-end - * @fires bounce-remove - * @fires wheel - * @fires wheel-remove - * @fires wheel-scroll - * @fires wheel-scroll-remove - * @fires mouse-edge-start - * @fires mouse-edge-end - * @fires mouse-edge-remove - * @fires moved + /** + * @extends PIXI.Container + * @extends EventEmitter + * @param {object} [options] + * @param {number} [options.screenWidth=window.innerWidth] + * @param {number} [options.screenHeight=window.innerHeight] + * @param {number} [options.worldWidth=this.width] + * @param {number} [options.worldHeight=this.height] + * @param {number} [options.threshold = 5] number of pixels to move to trigger an input event (e.g., drag, pinch) + * @param {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} [options.forceHitArea] change the default hitArea from world size to a new value + * @param {PIXI.ticker.Ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for updates + * @param {PIXI.InteractionManager} [options.interaction=null] InteractionManager, available from instantiated WebGLRenderer/CanvasRenderer.plugins.interaction - used to calculate pointer postion relative to canvas location on screen + * @param {HTMLElement} [options.divWheel=document.body] div to attach the wheel event + * @fires clicked + * @fires drag-start + * @fires drag-end + * @fires drag-remove + * @fires pinch-start + * @fires pinch-end + * @fires pinch-remove + * @fires snap-start + * @fires snap-end + * @fires snap-remove + * @fires snap-zoom-start + * @fires snap-zoom-end + * @fires snap-zoom-remove + * @fires bounce-x-start + * @fires bounce-x-end + * @fires bounce-y-start + * @fires bounce-y-end + * @fires bounce-remove + * @fires wheel + * @fires wheel-remove + * @fires wheel-scroll + * @fires wheel-scroll-remove + * @fires mouse-edge-start + * @fires mouse-edge-end + * @fires mouse-edge-remove + * @fires moved */ function Viewport(options) { _classCallCheck(this, Viewport); @@ -80473,10 +80473,10 @@ var Viewport = function (_PIXI$Container) { _this.div = options.divWheel || document.body; _this.listeners(_this.div); - /** - * active touch point ids on the viewport - * @type {number[]} - * @readonly + /** + * active touch point ids on the viewport + * @type {number[]} + * @readonly */ _this.touches = []; @@ -80488,9 +80488,9 @@ var Viewport = function (_PIXI$Container) { return _this; } - /** - * removes all event listeners from viewport - * (useful for cleanup of wheel and ticker events when removing viewport) + /** + * removes all event listeners from viewport + * (useful for cleanup of wheel and ticker events when removing viewport) */ @@ -80501,8 +80501,8 @@ var Viewport = function (_PIXI$Container) { this.div.removeEventListener('wheel', this.wheelFunction); } - /** - * overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners + /** + * overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners */ }, { @@ -80512,9 +80512,9 @@ var Viewport = function (_PIXI$Container) { this.removeListeners(); } - /** - * update animations - * @private + /** + * update animations + * @private */ }, { @@ -80554,12 +80554,12 @@ var Viewport = function (_PIXI$Container) { } } - /** - * use this to set screen and world sizes--needed for pinch/wheel/clamp/bounce - * @param {number} screenWidth - * @param {number} screenHeight - * @param {number} [worldWidth] - * @param {number} [worldHeight] + /** + * use this to set screen and world sizes--needed for pinch/wheel/clamp/bounce + * @param {number} screenWidth + * @param {number} screenHeight + * @param {number} [worldWidth] + * @param {number} [worldHeight] */ }, { @@ -80572,9 +80572,9 @@ var Viewport = function (_PIXI$Container) { this.resizePlugins(); } - /** - * called after a worldWidth/Height change - * @private + /** + * called after a worldWidth/Height change + * @private */ }, { @@ -80606,18 +80606,18 @@ var Viewport = function (_PIXI$Container) { } } - /** - * screen width in screen pixels - * @type {number} + /** + * screen width in screen pixels + * @type {number} */ }, { key: 'listeners', - /** - * add input listeners - * @private + /** + * add input listeners + * @private */ value: function listeners(div) { var _this2 = this; @@ -80639,9 +80639,9 @@ var Viewport = function (_PIXI$Container) { this.leftDown = false; } - /** - * handle down events - * @private + /** + * handle down events + * @private */ }, { @@ -80697,10 +80697,10 @@ var Viewport = function (_PIXI$Container) { } } - /** - * whether change exceeds threshold - * @private - * @param {number} change + /** + * whether change exceeds threshold + * @private + * @param {number} change */ }, { @@ -80712,9 +80712,9 @@ var Viewport = function (_PIXI$Container) { return false; } - /** - * handle move events - * @private + /** + * handle move events + * @private */ }, { @@ -80758,9 +80758,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * handle up events - * @private + /** + * handle up events + * @private */ }, { @@ -80814,10 +80814,10 @@ var Viewport = function (_PIXI$Container) { } } - /** - * gets pointer position if this.interaction is set - * @param {UIEvent} evt - * @private + /** + * gets pointer position if this.interaction is set + * @param {UIEvent} evt + * @private */ }, { @@ -80833,9 +80833,9 @@ var Viewport = function (_PIXI$Container) { return point; } - /** - * handle wheel events - * @private + /** + * handle wheel events + * @private */ }, { @@ -80880,11 +80880,11 @@ var Viewport = function (_PIXI$Container) { } } - /** - * change coordinates from screen to world - * @param {number|PIXI.Point} x - * @param {number} [y] - * @returns {PIXI.Point} + /** + * change coordinates from screen to world + * @param {number|PIXI.Point} x + * @param {number} [y] + * @returns {PIXI.Point} */ }, { @@ -80899,11 +80899,11 @@ var Viewport = function (_PIXI$Container) { } } - /** - * change coordinates from world to screen - * @param {number|PIXI.Point} x - * @param {number} [y] - * @returns {PIXI.Point} + /** + * change coordinates from world to screen + * @param {number|PIXI.Point} x + * @param {number} [y] + * @returns {PIXI.Point} */ }, { @@ -80919,21 +80919,21 @@ var Viewport = function (_PIXI$Container) { } } - /** - * screen width in world coordinates - * @type {number} - * @readonly + /** + * screen width in world coordinates + * @type {number} + * @readonly */ }, { key: 'moveCenter', - /** - * move center of viewport to point - * @param {(number|PIXI.PointLike)} x or point - * @param {number} [y] - * @return {Viewport} this + /** + * move center of viewport to point + * @param {(number|PIXI.PointLike)} x or point + * @param {number} [y] + * @return {Viewport} this */ value: function moveCenter() /*x, y | PIXI.Point*/{ var x = void 0, @@ -80950,20 +80950,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * top-left corner - * @type {PIXI.PointLike} + /** + * top-left corner + * @type {PIXI.PointLike} */ }, { key: 'moveCorner', - /** - * move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) - * @param {number|PIXI.Point} x|point - * @param {number} y - * @return {Viewport} this + /** + * move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) + * @param {number|PIXI.Point} x|point + * @param {number} y + * @return {Viewport} this */ value: function moveCorner() /*x, y | point*/{ if (arguments.length === 1) { @@ -80975,11 +80975,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so the width fits in the viewport - * @param {number} [width=this._worldWidth] in world coordinates - * @param {boolean} [center] maintain the same center - * @return {Viewport} this + /** + * change zoom so the width fits in the viewport + * @param {number} [width=this._worldWidth] in world coordinates + * @param {boolean} [center] maintain the same center + * @return {Viewport} this */ }, { @@ -80998,11 +80998,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so the height fits in the viewport - * @param {number} [height=this._worldHeight] in world coordinates - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} this + /** + * change zoom so the height fits in the viewport + * @param {number} [height=this._worldHeight] in world coordinates + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} this */ }, { @@ -81021,10 +81021,10 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so it fits the entire world in the viewport - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} this + /** + * change zoom so it fits the entire world in the viewport + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} this */ }, { @@ -81047,12 +81047,12 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so it fits the size or the entire world in the viewport - * @param {boolean} [center] maintain the same center of the screen after zoom - * @param {number} [width] desired width - * @param {number} [height] desired height - * @return {Viewport} this + /** + * change zoom so it fits the size or the entire world in the viewport + * @param {boolean} [center] maintain the same center of the screen after zoom + * @param {number} [width] desired width + * @param {number} [height] desired height + * @return {Viewport} this */ }, { @@ -81077,11 +81077,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom viewport by a certain percent (in both x and y direction) - * @param {number} percent change (e.g., 0.25 would increase a starting scale of 1.0 to 1.25) - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} the viewport + /** + * zoom viewport by a certain percent (in both x and y direction) + * @param {number} percent change (e.g., 0.25 would increase a starting scale of 1.0 to 1.25) + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} the viewport */ }, { @@ -81099,11 +81099,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom viewport by increasing/decreasing width by a certain number of pixels - * @param {number} change in pixels - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} the viewport + /** + * zoom viewport by increasing/decreasing width by a certain number of pixels + * @param {number} change in pixels + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} the viewport */ }, { @@ -81113,17 +81113,17 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * @param {object} [options] - * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom + /** + * @param {object} [options] + * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom */ }, { @@ -81134,20 +81134,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * @private - * @typedef OutOfBounds - * @type {object} - * @property {boolean} left - * @property {boolean} right - * @property {boolean} top - * @property {boolean} bottom + /** + * @private + * @typedef OutOfBounds + * @type {object} + * @property {boolean} left + * @property {boolean} right + * @property {boolean} top + * @property {boolean} bottom */ - /** - * is container out of world bounds - * @return {OutOfBounds} - * @private + /** + * is container out of world bounds + * @return {OutOfBounds} + * @private */ }, { @@ -81165,28 +81165,28 @@ var Viewport = function (_PIXI$Container) { return result; } - /** - * world coordinates of the right edge of the screen - * @type {number} + /** + * world coordinates of the right edge of the screen + * @type {number} */ }, { key: 'countDownPointers', - /** - * count of mouse/touch pointers that are down on the viewport - * @private - * @return {number} + /** + * count of mouse/touch pointers that are down on the viewport + * @private + * @return {number} */ value: function countDownPointers() { return (this.leftDown ? 1 : 0) + this.touches.length; } - /** - * array of touch pointers that are down on the viewport - * @private - * @return {PIXI.InteractionTrackingData[]} + /** + * array of touch pointers that are down on the viewport + * @private + * @return {PIXI.InteractionTrackingData[]} */ }, { @@ -81203,10 +81203,10 @@ var Viewport = function (_PIXI$Container) { return results; } - /** - * array of pointers that are down on the viewport - * @private - * @return {PIXI.InteractionTrackingData[]} + /** + * array of pointers that are down on the viewport + * @private + * @return {PIXI.InteractionTrackingData[]} */ }, { @@ -81220,9 +81220,9 @@ var Viewport = function (_PIXI$Container) { return results; } - /** - * clamps and resets bounce and decelerate (as needed) after manually moving viewport - * @private + /** + * clamps and resets bounce and decelerate (as needed) after manually moving viewport + * @private */ }, { @@ -81249,9 +81249,9 @@ var Viewport = function (_PIXI$Container) { // PLUGINS - /** - * removes installed plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * removes installed plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -81264,9 +81264,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * pause plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * pause plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -81277,9 +81277,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * resume plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * resume plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -81290,9 +81290,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * sort plugins for updates - * @private + /** + * sort plugins for updates + * @private */ }, { @@ -81327,14 +81327,14 @@ var Viewport = function (_PIXI$Container) { } } - /** - * enable one-finger touch to drag - * @param {object} [options] - * @param {string} [options.direction=all] direction to drag (all, x, or y) - * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) - * @param {number} [options.wheelScroll=10] number of pixels to scroll with each wheel spin - * @param {boolean} [options.reverse] reverse the direction of the wheel scroll - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * enable one-finger touch to drag + * @param {object} [options] + * @param {string} [options.direction=all] direction to drag (all, x, or y) + * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) + * @param {number} [options.wheelScroll=10] number of pixels to scroll with each wheel spin + * @param {boolean} [options.reverse] reverse the direction of the wheel scroll + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ }, { @@ -81345,19 +81345,19 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * clamp to world boundaries or other provided boundaries - * NOTES: - * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping - * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {(number|boolean)} [options.left] clamp left; true=0 - * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth - * @param {(number|boolean)} [options.top] clamp top; true=0 - * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight - * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @return {Viewport} this + /** + * clamp to world boundaries or other provided boundaries + * NOTES: + * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping + * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {(number|boolean)} [options.left] clamp left; true=0 + * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth + * @param {(number|boolean)} [options.top] clamp top; true=0 + * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight + * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @return {Viewport} this */ }, { @@ -81368,13 +81368,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * decelerate after a move - * @param {object} [options] - * @param {number} [options.friction=0.95] percent to decelerate after movement - * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) - * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration - * @return {Viewport} this + /** + * decelerate after a move + * @param {object} [options] + * @param {number} [options.friction=0.95] percent to decelerate after movement + * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) + * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration + * @return {Viewport} this */ }, { @@ -81385,16 +81385,16 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * bounce on borders - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') - * @param {number} [options.friction=0.5] friction to apply to decelerate if active - * @param {number} [options.time=150] time in ms to finish bounce - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @return {Viewport} this + /** + * bounce on borders + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') + * @param {number} [options.friction=0.5] friction to apply to decelerate if active + * @param {number} [options.time=150] time in ms to finish bounce + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @return {Viewport} this */ }, { @@ -81405,13 +81405,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * enable pinch to zoom and two-finger touch to drag - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {number} [options.percent=1.0] percent to modify pinch speed - * @param {boolean} [options.noDrag] disable two-finger dragging - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers - * @return {Viewport} this + /** + * enable pinch to zoom and two-finger touch to drag + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {number} [options.percent=1.0] percent to modify pinch speed + * @param {boolean} [options.noDrag] disable two-finger dragging + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers + * @return {Viewport} this */ }, { @@ -81422,20 +81422,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * snap to a point - * @param {number} x - * @param {number} y - * @param {object} [options] - * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center - * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location - * @return {Viewport} this + /** + * snap to a point + * @param {number} x + * @param {number} y + * @param {object} [options] + * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center + * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location + * @return {Viewport} this */ }, { @@ -81446,13 +81446,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * follow a target - * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) - * @param {object} [options] - * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) - * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport - * @return {Viewport} this + /** + * follow a target + * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) + * @param {object} [options] + * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) + * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport + * @return {Viewport} this */ }, { @@ -81463,13 +81463,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom using mouse wheel - * @param {object} [options] - * @param {number} [options.percent=0.1] percent to scroll with each spin - * @param {boolean} [options.reverse] reverse the direction of the scroll - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position - * @return {Viewport} this + /** + * zoom using mouse wheel + * @param {object} [options] + * @param {number} [options.percent=0.1] percent to scroll with each spin + * @param {boolean} [options.reverse] reverse the direction of the scroll + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position + * @return {Viewport} this */ }, { @@ -81480,15 +81480,15 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * enable clamping of zoom to constraints - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {number} [options.minWidth] minimum width - * @param {number} [options.minHeight] minimum height - * @param {number} [options.maxWidth] maximum width - * @param {number} [options.maxHeight] maximum height - * @return {Viewport} this + /** + * enable clamping of zoom to constraints + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {number} [options.minWidth] minimum width + * @param {number} [options.minHeight] minimum height + * @param {number} [options.maxWidth] maximum width + * @param {number} [options.maxHeight] maximum height + * @return {Viewport} this */ }, { @@ -81499,19 +81499,19 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * Scroll viewport when mouse hovers near one of the edges or radius-distance from center of screen. - * @param {object} [options] - * @param {number} [options.radius] distance from center of screen in screen pixels - * @param {number} [options.distance] distance from all sides in screen pixels - * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) - * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) - * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) - * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) - * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport - * @param {boolean} [options.reverse] reverse direction of scroll - * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed - * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) + /** + * Scroll viewport when mouse hovers near one of the edges or radius-distance from center of screen. + * @param {object} [options] + * @param {number} [options.radius] distance from center of screen in screen pixels + * @param {number} [options.distance] distance from all sides in screen pixels + * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) + * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) + * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) + * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) + * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport + * @param {boolean} [options.reverse] reverse direction of scroll + * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed + * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) */ }, { @@ -81522,10 +81522,10 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * pause viewport (including animation updates such as decelerate) - * NOTE: when setting pause=true, all touches and mouse actions are cleared (i.e., if mousedown was active, it becomes inactive for purposes of the viewport) - * @type {boolean} + /** + * pause viewport (including animation updates such as decelerate) + * NOTE: when setting pause=true, all touches and mouse actions are cleared (i.e., if mousedown was active, it becomes inactive for purposes of the viewport) + * @type {boolean} */ }, { @@ -81537,9 +81537,9 @@ var Viewport = function (_PIXI$Container) { this._screenWidth = value; } - /** - * screen height in screen pixels - * @type {number} + /** + * screen height in screen pixels + * @type {number} */ }, { @@ -81551,9 +81551,9 @@ var Viewport = function (_PIXI$Container) { this._screenHeight = value; } - /** - * world width in pixels - * @type {number} + /** + * world width in pixels + * @type {number} */ }, { @@ -81570,9 +81570,9 @@ var Viewport = function (_PIXI$Container) { this.resizePlugins(); } - /** - * world height in pixels - * @type {number} + /** + * world height in pixels + * @type {number} */ }, { @@ -81594,10 +81594,10 @@ var Viewport = function (_PIXI$Container) { return this._screenWidth / this.scale.x; } - /** - * screen height in world coordinates - * @type {number} - * @readonly + /** + * screen height in world coordinates + * @type {number} + * @readonly */ }, { @@ -81606,10 +81606,10 @@ var Viewport = function (_PIXI$Container) { return this._screenHeight / this.scale.y; } - /** - * world width in screen coordinates - * @type {number} - * @readonly + /** + * world width in screen coordinates + * @type {number} + * @readonly */ }, { @@ -81618,10 +81618,10 @@ var Viewport = function (_PIXI$Container) { return this._worldWidth * this.scale.x; } - /** - * world height in screen coordinates - * @type {number} - * @readonly + /** + * world height in screen coordinates + * @type {number} + * @readonly */ }, { @@ -81630,9 +81630,9 @@ var Viewport = function (_PIXI$Container) { return this._worldHeight * this.scale.y; } - /** - * get center of screen in world coordinates - * @type {PIXI.PointLike} + /** + * get center of screen in world coordinates + * @type {PIXI.PointLike} */ }, { @@ -81661,9 +81661,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the left edge of the screen - * @type {number} + /** + * world coordinates of the left edge of the screen + * @type {number} */ }, { @@ -81676,9 +81676,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the top edge of the screen - * @type {number} + /** + * world coordinates of the top edge of the screen + * @type {number} */ }, { @@ -81691,9 +81691,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the bottom edge of the screen - * @type {number} + /** + * world coordinates of the bottom edge of the screen + * @type {number} */ }, { @@ -81705,9 +81705,9 @@ var Viewport = function (_PIXI$Container) { this.y = -value * this.scale.y + this.screenHeight; this._reset(); } - /** - * determines whether the viewport is dirty (i.e., needs to be renderered to the screen because of a change) - * @type {boolean} + /** + * determines whether the viewport is dirty (i.e., needs to be renderered to the screen because of a change) + * @type {boolean} */ }, { @@ -81719,10 +81719,10 @@ var Viewport = function (_PIXI$Container) { this._dirty = value; } - /** - * permanently changes the Viewport's hitArea - *

NOTE: normally the hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth, Viewport.worldScreenHeight)

- * @type {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} + /** + * permanently changes the Viewport's hitArea + *

NOTE: normally the hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth, Viewport.worldScreenHeight)

+ * @type {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} */ }, { @@ -81756,136 +81756,136 @@ var Viewport = function (_PIXI$Container) { return Viewport; }(PIXI.Container); -/** - * fires after a mouse or touch click - * @event Viewport#clicked - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires after a mouse or touch click + * @event Viewport#clicked + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a drag starts - * @event Viewport#drag-start - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires when a drag starts + * @event Viewport#drag-start + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a drag ends - * @event Viewport#drag-end - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires when a drag ends + * @event Viewport#drag-end + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a pinch starts - * @event Viewport#pinch-start - * @type {Viewport} +/** + * fires when a pinch starts + * @event Viewport#pinch-start + * @type {Viewport} */ -/** - * fires when a pinch end - * @event Viewport#pinch-end - * @type {Viewport} +/** + * fires when a pinch end + * @event Viewport#pinch-end + * @type {Viewport} */ -/** - * fires when a snap starts - * @event Viewport#snap-start - * @type {Viewport} +/** + * fires when a snap starts + * @event Viewport#snap-start + * @type {Viewport} */ -/** - * fires when a snap ends - * @event Viewport#snap-end - * @type {Viewport} +/** + * fires when a snap ends + * @event Viewport#snap-end + * @type {Viewport} */ -/** - * fires when a snap-zoom starts - * @event Viewport#snap-zoom-start - * @type {Viewport} +/** + * fires when a snap-zoom starts + * @event Viewport#snap-zoom-start + * @type {Viewport} */ -/** - * fires when a snap-zoom ends - * @event Viewport#snap-zoom-end - * @type {Viewport} +/** + * fires when a snap-zoom ends + * @event Viewport#snap-zoom-end + * @type {Viewport} */ -/** - * fires when a bounce starts in the x direction - * @event Viewport#bounce-x-start - * @type {Viewport} +/** + * fires when a bounce starts in the x direction + * @event Viewport#bounce-x-start + * @type {Viewport} */ -/** - * fires when a bounce ends in the x direction - * @event Viewport#bounce-x-end - * @type {Viewport} +/** + * fires when a bounce ends in the x direction + * @event Viewport#bounce-x-end + * @type {Viewport} */ -/** - * fires when a bounce starts in the y direction - * @event Viewport#bounce-y-start - * @type {Viewport} +/** + * fires when a bounce starts in the y direction + * @event Viewport#bounce-y-start + * @type {Viewport} */ -/** - * fires when a bounce ends in the y direction - * @event Viewport#bounce-y-end - * @type {Viewport} +/** + * fires when a bounce ends in the y direction + * @event Viewport#bounce-y-end + * @type {Viewport} */ -/** - * fires when for a mouse wheel event - * @event Viewport#wheel - * @type {object} - * @property {object} wheel - * @property {number} wheel.dx - * @property {number} wheel.dy - * @property {number} wheel.dz - * @property {Viewport} viewport +/** + * fires when for a mouse wheel event + * @event Viewport#wheel + * @type {object} + * @property {object} wheel + * @property {number} wheel.dx + * @property {number} wheel.dy + * @property {number} wheel.dz + * @property {Viewport} viewport */ -/** - * fires when a wheel-scroll occurs - * @event Viewport#wheel-scroll - * @type {Viewport} +/** + * fires when a wheel-scroll occurs + * @event Viewport#wheel-scroll + * @type {Viewport} */ -/** - * fires when a mouse-edge starts to scroll - * @event Viewport#mouse-edge-start - * @type {Viewport} +/** + * fires when a mouse-edge starts to scroll + * @event Viewport#mouse-edge-start + * @type {Viewport} */ -/** - * fires when the mouse-edge scrolling ends - * @event Viewport#mouse-edge-end - * @type {Viewport} +/** + * fires when the mouse-edge scrolling ends + * @event Viewport#mouse-edge-end + * @type {Viewport} */ -/** - * fires when viewport moves through UI interaction, deceleration, or follow - * @event Viewport#moved - * @type {object} - * @property {Viewport} viewport - * @property {string} type (drag, snap, pinch, follow, bounce-x, bounce-y, clamp-x, clamp-y, decelerate, mouse-edges, wheel) +/** + * fires when viewport moves through UI interaction, deceleration, or follow + * @event Viewport#moved + * @type {object} + * @property {Viewport} viewport + * @property {string} type (drag, snap, pinch, follow, bounce-x, bounce-y, clamp-x, clamp-y, decelerate, mouse-edges, wheel) */ -/** - * fires when viewport moves through UI interaction, deceleration, or follow - * @event Viewport#zoomed - * @type {object} - * @property {Viewport} viewport - * @property {string} type (drag-zoom, pinch, wheel, clamp-zoom) +/** + * fires when viewport moves through UI interaction, deceleration, or follow + * @event Viewport#zoomed + * @type {object} + * @property {Viewport} viewport + * @property {string} type (drag-zoom, pinch, wheel, clamp-zoom) */ PIXI.extras.Viewport = Viewport; @@ -81908,15 +81908,15 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Wheel, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.percent=0.1] percent to scroll with each spin - * @param {boolean} [options.reverse] reverse the direction of the scroll - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position - * - * @event wheel({wheel: {dx, dy, dz}, event, viewport}) + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.percent=0.1] percent to scroll with each spin + * @param {boolean} [options.reverse] reverse the direction of the scroll + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position + * + * @event wheel({wheel: {dx, dy, dz}, event, viewport}) */ function Wheel(parent, options) { _classCallCheck(this, Wheel);