ohif-viewer/Packages/ohif-cornerstone/public/js/cornerstoneWADOImageLoaderCodecs.es5.js

2790 lines
1.5 MiB
JavaScript
Raw Normal View History

/*! cornerstone-wado-image-loader - v0.14.2 - 2017-02-22 | (c) 2016 Chris Hafey | https://github.com/chafey/cornerstoneWADOImageLoader */
/*! CharLS.js - v2.0.1 - 2016-06-08 | (c) 2016 Chris Hafey | https://github.com/chafey/charls */
var CharLS = function(Module) {
Module = Module || {};
var Module;if(!Module)Module=(typeof CharLS!=="undefined"?CharLS:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){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:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_S
var asm=(function(global,env,buffer) {
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=env.___dso_handle|0;var o=0;var p=0;var q=0;var r=0;var s=global.NaN,t=global.Infinity;var u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0.0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=0;var N=global.Math.floor;var O=global.Math.abs;var P=global.Math.sqrt;var Q=global.Math.pow;var R=global.Math.cos;var S=global.Math.sin;var T=global.Math.tan;var U=global.Math.acos;var V=global.Math.asin;var W=global.Math.atan;var X=global.Math.atan2;var Y=global.Math.exp;var Z=global.Math.log;var _=global.Math.ceil;var $=global.Math.imul;var aa=global.Math.min;var ba=global.Math.clz32;var ca=env.abort;var da=env.assert;var ea=env.invoke_iiiiiiii;var fa=env.invoke_viiiii;var ga=env.invoke_iiiiiid;var ha=env.invoke_vi;var ia=env.invoke_vii;var ja=env.invoke_iiiiiii;var ka=env.invoke_ii;var la=env.invoke_iiiiiiiiiiii;var ma=env.invoke_iiii;var na=env.invoke_viiiiiiiiiiiiiii;var oa=env.invoke_viiiiii;var pa=env.invoke_viiiiiii;var qa=env.invoke_viiiiiiiiii;var ra=env.invoke_iii;var sa=env.invoke_iiiiii;var ta=env.invoke_diii;var ua=env.invoke_i;var va=env.invoke_iiiii;var wa=env.invoke_viii;var xa=env.invoke_v;var ya=env.invoke_iiiiiiiii;var za=env.invoke_iiiiid;var Aa=env.invoke_viiii;var Ba=env._fabs;var Ca=env._strftime;var Da=env._pthread_cond_wait;var Ea=env.___lock;var Fa=env._pthread_key_create;var Ga=env._abort;var Ha=env.___cxa_guard_acquire;var Ia=env.___setErrNo;var Ja=env.___gxx_personality_v0;var Ka=env.___assert_fail;var La=env.___cxa_free_exception;var Ma=env.___cxa_allocate_exception;var Na=env.___cxa_find_matching_catch;var Oa=env.__isLeapYear;var Pa=env.___cxa_guard_release;var Qa=env.__addDays;var Ra=env._strftime_l;var Sa=env._emscripten_set_main_loop_timing;var Ta=env._llvm_eh_typeid_for;var Ua=env._sbrk;var Va=env.___cxa_begin_catch;var Wa=env._emscripten_memcpy_big;var Xa=env.___cxa_end_catch;var Ya=env.___resumeException;var Za=env.__ZSt18uncaught_exceptionv;var _a=env._sysconf;var $a=env._pthread_getspecific;var ab=env.__arraySum;var bb=env._pthread_self;var cb=env._pthread_mutex_unlock;var db=env._pthread_once;var eb=env.___syscall54;var fb=env.___unlock;var gb=env._pthread_cleanup_pop;var hb=env._pthread_cond_broadcast;var ib=env._emscripten_set_main_loop;var jb=env._pthread_setspecific;var kb=env.___cxa_atexit;var lb=env.___cxa_throw;var mb=env.___cxa_rethrow;var nb=env.___syscall6;var ob=env._pthread_cleanup_push;var pb=env.___cxa_pure_virtual;var qb=env._time;var rb=env._pthread_mutex_lock;var sb=env.___cxa_guard_abort;var tb=env._atexit;var ub=env.___syscall140;var vb=env.___syscall145;var wb=env.___syscall146;var xb=0.0;
// EMSCRIPTEN_START_FUNCS
function Vb(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function Wb(){return i|0}function Xb(a){a=a|0;i=a}function Yb(a,b){a=a|0;b=b|0;i=a;j=b}function Zb(a,b){a=a|0;b=b|0;if(!o){o=a;p=b}}function _b(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function $b(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function ac(a){a=a|0;D=a}function bc(){return D|0}function cc(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=i;i=i+128|0;p=w+44|0;s=w+8|0;l=w+4|0;n=w;q=e+4|0;r=e+8|0;o=0;Aa(35,c[e>>2]|0,c[q>>2]|0,c[r>>2]|0,f|0);m=o;o=0;if(!(m&1)){j=p;h=j+84|0;do{c[j>>2]=c[f>>2];j=j+4|0;f=f+4|0}while((j|0)<(h|0));f=p+12|0;if((c[f>>2]|0)==0?(k=$(((c[p+8>>2]|0)+7|0)/8|0,c[p>>2]|0)|0,c[f>>2]=k,(c[p+24>>2]|0)!=0):0)c[f>>2]=$(c[p+16>>2]|0,k)|0;o=0;ha(176,s|0);m=o;o=0;if(!(m&1)){f=p+56|0;do if(c[f>>2]|0){o=0;f=ka(66,f|0)|0;m=o;o=0;if(!(m&1)){c[l>>2]=f;h=s+28|0;j=c[h>>2]|0;if(j>>>0<(c[s+32>>2]|0)>>>0){c[j>>2]=f;c[h>>2]=j+4;c[l>>2]=0;t=19;break}o=0;ia(57,s+24|0,l|0);m=o;o=0;if(m&1){h=Na(824,0)|0;f=D;j=c[l>>2]|0;c[l>>2]=0;if(!j)break;Bb[c[(c[j>>2]|0)+4>>2]&255](j);break}else{f=c[l>>2]|0;c[l>>2]=0;if(!f){t=19;break}Bb[c[(c[f>>2]|0)+4>>2]&255](f);t=19;break}}else t=15}else t=19;while(0);a:do if((t|0)==19){j=p+4|0;k=p+8|0;l=p+16|0;o=0;f=va(14,c[p>>2]|0,c[j>>2]|0,c[k>>2]|0,c[l>>2]|0)|0;m=o;o=0;if(!(m&1)){c[n>>2]=f;m=s+28|0;h=c[m>>2]|0;do if(h>>>0>=(c[s+32>>2]|0)>>>0){o=0;ia(57,s+24|0,n|0);h=o;o=0;if(h&1){h=Na(824,0)|0;f=D;j=c[n>>2]|0;c[n>>2]=0;if(!j)break a;Bb[c[(c[j>>2]|0)+4>>2]&255](j);break a}else{f=c[n>>2]|0;c[n>>2]=0;if(!f)break;Bb[c[(c[f>>2]|0)+4>>2]&255](f);break}}else{c[h>>2]=f;c[m>>2]=h+4;c[n>>2]=0}while(0);f=c[p+28>>2]|0;if((f|0)!=0?(o=0,ia(58,s|0,f|0),t=o,o=0,t&1):0){t=15;break}b:do if(!(c[p+24>>2]|0)){f=$(c[j>>2]|0,c[p>>2]|0)|0;f=$(f,((c[k>>2]|0)+7|0)/8|0)|0;if((c[l>>2]|0)>0){j=0;while(1){o=0;wa(4,s|0,e|0,p|0);t=o;o=0;if(t&1)break;h=c[q>>2]|0;if(h){c[q>>2]=h+f;c[r>>2]=(c[r>>2]|0)-f}j=j+1|0;if((j|0)>=(c[l>>2]|0))break b}h=Na(824,0)|0;f=D;t=16;break a}}else{o=0;wa(4,s|0,e|0,p|0);t=o;o=0;if(t&1){t=15;break a}}while(0);o=0;ra(33,s|0,b|0)|0;t=o;o=0;if(!(t&1)){c[d>>2]=c[s+16>>2];if(g)a[g>>0]=0;j=s+24|0;f=c[j>>2]|0;if(f){h=c[m>>2]|0;if((h|0)!=(f|0)){do{g=h+-4|0;c[m>>2]=g;h=c[g>>2]|0;c[g>>2]=0;if(h)Bb[c[(c[h>>2]|0)+4>>2]&255](h);h=c[m>>2]|0}while((h|0)!=(f|0));f=c[j>>2]|0}cj(f)}g=0;i=w;return g|0}else t=15}else t=15}while(0);if((t|0)==15){h=Na(824,0)|0;f=D;t=16}m=s+24|0;j=c[m>>2]|0;if(j){l=s+28|0;k=c[l>>2]|0;if((k|0)!=(j|0)){do{s=k+-4|0;c[l>>2]=s;k=c[s>>2]|0;c[s>>2]=0;if(k)Bb[c[(c[k>>2]|0)+4>>2]&255](k);k=c[l>>2]|0}while((k|0)!=(j|0));j=c[m>>2]|0}cj(j)}}else t=5}else t=5;if((t|0)==5){h=Na(824,0)|0;f=D}s=(f|0)==(Ta(824)|0);k=Va(h|0)|0;f=(g|0)==0;if(!s){if(!f)a[g>>0]=0;Xa();g=14;i=w;return g|0}j=k+12|0;do if(!f){f=c[j>>2]|0;o=0;h=ua(1)|0;s=o;o=0;if(!(s&1))if((f|0)==(h|0)){ml(g,Eb[c[(c[k>>2]|0)+8>>2]&127](k)|0)|0;t=60;break}else{a[g>>0]=0;t=60;break}}else t=60;while(0);if((t|0)==60?(u=c[j>>2]|0,o=0,v=ua(1)|0,g=o,o=0,!(g&1)):0){g=(u|0)==(v|0)?c[k+8>>2]|0:13;Xa();i=w;return g|0}f=Na()|0;o=0;xa(3);w=o;o=0;if(w&1){w=Na(0)|0;ec(w)}else Ya(f|0);return 0}function dc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0;l=i;i=i+112|0;g=l+96|0;k=l+84|0;m=l+72|0;n=l+60|0;p=l+48|0;q=l+36|0;r=l+24|0;s=l+12|0;t=l;j=(b|0)==0;if((a|0)==0&j){f=Ma(16)|0;o=0;wa(5,g|0,48504,52);t=o;o=0;if(!(t&1)){o=0;b=ua(1)|0;t=o;o=0;if(!(t&1)?(o=0,Aa(36,f|0,1,b|0,g|0),t=o,o=0,!(t&1)):0){o=0;wa(6,f|0,824,96);o=0;a=0}else a=1;b=Na()|0;Im(g);if(!a){t=b;Ya(t|0)}}else b=Na()|0;La(f|0);t=b;Ya(t|0)}h=c[e>>2]|0;if((h+-1|0)>>>0>65534){f=Ma(16)|0;o=0;wa(5,k|0,48557,41);t=o;o=0;if(!(t&1)){o=0;b=ua(1)|0;t=o;o=0;if(!(t&1)?(o=0,Aa(36,f|0,1,b|0,k|0),t=o,o=0,!(t&1)):0){o=0;wa(6,f|0,824,96);o=0;a=0}else a=1;b=Na()|0;Im(k);if(!a){t=b;Ya(t|0)}}else b=Na()|0;La(f|0);t=b;Ya(t|0)}g=c[e+4>>2]|0;if((g+-1|0)>>>0>65534){f=Ma(16)|0;o=0;wa(5,m|0,48599,42);t
function pe(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;w=i;i=i+352|0;x=w+328|0;y=w+192|0;e=w+343|0;f=w+342|0;g=w+341|0;h=w+340|0;r=w+176|0;k=w+168|0;l=w+160|0;m=w+152|0;v=w;t=w+136|0;if((c[b+32>>2]|0)!=0?(c[b+24>>2]|0)!=1:0){s=b+8|0;u=b+36|0;j=c[u>>2]|0;if(!j){b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[e>>0]|0;Aa(37,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}b=c[b+16>>2]|0;if((b|0)==16)switch(j|0){case 1:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[f>>0]|0;Aa(38,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[g>>0]|0;Aa(39,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[h>>0]|0;Aa(40,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}default:{j=y+56|0;g=y+4|0;c[y>>2]=36160;c[j>>2]=36180;o=0;ia(62,y+56|0,g|0);w=o;o=0;if(w&1){z=Na()|0;fn(j);Ya(z|0)}c[y+128>>2]=0;c[y+132>>2]=-1;c[y>>2]=36200;c[y+56>>2]=36220;o=0;ha(180,g|0);w=o;o=0;do if(w&1)b=Na()|0;else{c[g>>2]=36236;h=y+36|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[y+52>>2]=16;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;o=0;ia(63,g|0,x|0);w=o;o=0;if(w&1){b=Na()|0;Im(x);Im(h);nn(g);break}Im(x);o=0;b=ma(28,y|0,49007,21)|0;x=o;o=0;do if((!(x&1)?(o=0,p=ra(36,b|0,c[u>>2]|0)|0,x=o,o=0,!(x&1)):0)?(o=0,ma(28,p|0,50997,18)|0,x=o,o=0,!(x&1)):0){f=Ma(16)|0;o=0;ia(64,r|0,g|0);x=o;o=0;if(!(x&1)){if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;Aa(36,f|0,9,35648,r|0);x=o;o=0;if(x&1)e=1;else{o=0;wa(6,f|0,824,96);o=0;e=0}b=Na()|0;Im(r);if(!e)break}else b=Na()|0;La(f|0)}else z=34;while(0);if((z|0)==34)b=Na()|0;c[y>>2]=36200;c[j>>2]=36220;c[g>>2]=36236;Im(h);nn(g);fn(j);z=b;Ya(z|0)}while(0);z=b;fn(j);Ya(z|0)}}if((b|0)<=8){b=Ma(16)|0;if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;wa(7,b|0,8,35648);z=o;o=0;if(!(z&1))lb(b|0,824,96);z=Na()|0;La(b|0);Ya(z|0)}e=16-b|0;switch(j|0){case 1:{b=bj(60)|0;c[k>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[k>>2];c[x+4>>2]=c[k+4>>2];Aa(41,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(60)|0;c[l>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[l>>2];c[x+4>>2]=c[l+4>>2];Aa(42,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(60)|0;c[m>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[m>>2];c[x+4>>2]=c[m+4>>2];Aa(43,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}default:{j=v+56|0;g=v+4|0;c[v>>2]=36160;c[j>>2]=36180;o=0;ia(62,v+56|0,g|0);y=o;o=0;if(y&1){z=Na()|0;fn(j);Ya(z|0)}c[v+128>>2]=0;c[v+132>>2]=-1;c[v>>2]=36200;c[v+56>>2]=36220;o=0;ha(180,g|0);y=o;o=0;do if(y&1)b=Na()|0;else{c[g>>2]=36236;h=v+36|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[v+52>>2]=16;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;o=0;ia(63,g|0,x|0);y=o;o=0;if(y&1){b=Na()|0;Im(x);Im(h);nn(g);break}Im(x);o=0;b=ma(28,v|0,49007,21)|0;y=o;o=0;do if((!(y&1)?(o=0,q=ra(36,b|0,c[u>>2]|0)|0,y=o,o=0,!(y&1)):0)?(o=0,ma(28,q|0,50997,18)|0,y=o,o=0,!(y&1)):0){f=Ma(16)|0;o=0;ia(64,t|0,g|0);y=o;o=0;if(!(y&1)){if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;Aa(36,f|0,9,35648,t|0);y=o;o=0;if(y&1)e=1;else{o=0;wa(6,f|0,824,96);o=0;e=0}b=Na()|0;Im(t);if(!e)break}else b=Na()|0;La(f|0)}else z=64;while(0);if((z|0)==64)b=Na()|0;c[v>>2]=36200;c[j>>2]=36220;c[g>>2]=36236;Im(h);nn(g);fn(j);z=b;Ya(z|0)}while(0);z=b;fn(j);Ya(z|0)}}}e=c[d+4>>2]|0;f=bj(16)|0;b=c[b+20>>2]|0;if(!e){z=c[d>>2]|0;c[f>>2]=36132;c[f+4>>2]=z;c[f+8>>2]=6;c[f+12>>2]=b;z=f;i=w;return z|0}else{c[f>>2]=36108;c[f+4>>2]=e;c[f+8>>2]=6;c[f+12>>2]=b;z=f;i=w;return z|0}return 0}function qe(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;u=i;i=i+32|0;w=u+12|0;t
function og(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;w=i;i=i+352|0;x=w+328|0;y=w+192|0;e=w+343|0;f=w+342|0;g=w+341|0;h=w+340|0;r=w+176|0;k=w+168|0;l=w+160|0;m=w+152|0;v=w;t=w+136|0;if((c[b+32>>2]|0)!=0?(c[b+24>>2]|0)!=1:0){s=b+8|0;u=b+36|0;j=c[u>>2]|0;if(!j){b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[e>>0]|0;Aa(44,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}b=c[b+16>>2]|0;if((b|0)==8)switch(j|0){case 1:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[f>>0]|0;Aa(45,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[g>>0]|0;Aa(46,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[h>>0]|0;Aa(47,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}default:{j=y+56|0;g=y+4|0;c[y>>2]=36160;c[j>>2]=36180;o=0;ia(62,y+56|0,g|0);w=o;o=0;if(w&1){z=Na()|0;fn(j);Ya(z|0)}c[y+128>>2]=0;c[y+132>>2]=-1;c[y>>2]=36200;c[y+56>>2]=36220;o=0;ha(180,g|0);w=o;o=0;do if(w&1)b=Na()|0;else{c[g>>2]=36236;h=y+36|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[y+52>>2]=16;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;o=0;ia(63,g|0,x|0);w=o;o=0;if(w&1){b=Na()|0;Im(x);Im(h);nn(g);break}Im(x);o=0;b=ma(28,y|0,49007,21)|0;x=o;o=0;do if((!(x&1)?(o=0,p=ra(36,b|0,c[u>>2]|0)|0,x=o,o=0,!(x&1)):0)?(o=0,ma(28,p|0,50997,18)|0,x=o,o=0,!(x&1)):0){f=Ma(16)|0;o=0;ia(64,r|0,g|0);x=o;o=0;if(!(x&1)){if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;Aa(36,f|0,9,35648,r|0);x=o;o=0;if(x&1)e=1;else{o=0;wa(6,f|0,824,96);o=0;e=0}b=Na()|0;Im(r);if(!e)break}else b=Na()|0;La(f|0)}else z=34;while(0);if((z|0)==34)b=Na()|0;c[y>>2]=36200;c[j>>2]=36220;c[g>>2]=36236;Im(h);nn(g);fn(j);z=b;Ya(z|0)}while(0);z=b;fn(j);Ya(z|0)}}if((b|0)<=8){b=Ma(16)|0;if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;wa(7,b|0,8,35648);z=o;o=0;if(!(z&1))lb(b|0,824,96);z=Na()|0;La(b|0);Ya(z|0)}e=16-b|0;switch(j|0){case 1:{b=bj(60)|0;c[k>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[k>>2];c[x+4>>2]=c[k+4>>2];Aa(41,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(60)|0;c[l>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[l>>2];c[x+4>>2]=c[l+4>>2];Aa(42,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(60)|0;c[m>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[m>>2];c[x+4>>2]=c[m+4>>2];Aa(43,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}default:{j=v+56|0;g=v+4|0;c[v>>2]=36160;c[j>>2]=36180;o=0;ia(62,v+56|0,g|0);y=o;o=0;if(y&1){z=Na()|0;fn(j);Ya(z|0)}c[v+128>>2]=0;c[v+132>>2]=-1;c[v>>2]=36200;c[v+56>>2]=36220;o=0;ha(180,g|0);y=o;o=0;do if(y&1)b=Na()|0;else{c[g>>2]=36236;h=v+36|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[v+52>>2]=16;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;o=0;ia(63,g|0,x|0);y=o;o=0;if(y&1){b=Na()|0;Im(x);Im(h);nn(g);break}Im(x);o=0;b=ma(28,v|0,49007,21)|0;y=o;o=0;do if((!(y&1)?(o=0,q=ra(36,b|0,c[u>>2]|0)|0,y=o,o=0,!(y&1)):0)?(o=0,ma(28,q|0,50997,18)|0,y=o,o=0,!(y&1)):0){f=Ma(16)|0;o=0;ia(64,t|0,g|0);y=o;o=0;if(!(y&1)){if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;Aa(36,f|0,9,35648,t|0);y=o;o=0;if(y&1)e=1;else{o=0;wa(6,f|0,824,96);o=0;e=0}b=Na()|0;Im(t);if(!e)break}else b=Na()|0;La(f|0)}else z=64;while(0);if((z|0)==64)b=Na()|0;c[v>>2]=36200;c[j>>2]=36220;c[g>>2]=36236;Im(h);nn(g);fn(j);z=b;Ya(z|0)}while(0);z=b;fn(j);Ya(z|0)}}}e=c[d+4>>2]|0;f=bj(16)|0;b=c[b+20>>2]|0;if(!e){z=c[d>>2]|0;c[f>>2]=36132;c[f+4>>2]=z;c[f+8>>2]=1;c[f+12>>2]=b;z=f;i=w;return z|0}else{c[f>>2]=36108;c[f+4>>2]=e;c[f+8>>2]=1;c[f+12>>2]=b;z=f;i=w;return z|0}return 0}function pg(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;u=i;i=i+32|0;w=u+12|0;t=u;r=
function Lp(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0;n=i;i=i+128|0;h=n;q=n+116|0;r=n+104|0;k=n+20|0;m=n+16|0;l=n+12|0;p=n+8|0;j=n+4|0;a[q>>0]=a[58887]|0;a[q+1>>0]=a[58888]|0;a[q+2>>0]=a[58889]|0;a[q+3>>0]=a[58890]|0;a[q+4>>0]=a[58891]|0;a[q+5>>0]=a[58892]|0;up(q+1|0,58893,0,c[e+4>>2]|0);b=Xo()|0;c[h>>2]=g;g=r+(Su(r,12,b,q,h)|0)|0;q=vp(r,g,e)|0;b=jn(e)|0;c[p>>2]=b;o=0;pa(3,r|0,q|0,g|0,k|0,m|0,l|0,p|0);g=o;o=0;if(g&1){r=Na()|0;pm(b)|0;Ya(r|0)}else{pm(b)|0;c[j>>2]=c[d>>2];q=c[m>>2]|0;r=c[l>>2]|0;c[h>>2]=c[j>>2];r=Uu(h,k,q,r,e,f)|0;i=n;return r|0}return 0}function Mp(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0;n=i;i=i+240|0;h=n+8|0;a=n;q=n+204|0;k=n+32|0;m=n+28|0;l=n+24|0;p=n+20|0;j=n+16|0;r=a;c[r>>2]=37;c[r+4>>2]=0;up(a+1|0,58895,0,c[d+4>>2]|0);r=Xo()|0;s=h;c[s>>2]=f;c[s+4>>2]=g;g=q+(Su(q,23,r,a,h)|0)|0;f=vp(q,g,d)|0;a=jn(d)|0;c[p>>2]=a;o=0;pa(3,q|0,f|0,g|0,k|0,m|0,l|0,p|0);g=o;o=0;if(g&1){s=Na()|0;pm(a)|0;Ya(s|0)}else{pm(a)|0;c[j>>2]=c[b>>2];r=c[m>>2]|0;s=c[l>>2]|0;c[h>>2]=c[j>>2];s=Uu(h,k,r,s,d,e)|0;i=n;return s|0}return 0}function Np(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;var g=0,j=0,k=0,l=0,m=0,n=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;z=i;i=i+352|0;u=z+312|0;q=z+48|0;p=z+32|0;l=z+24|0;g=z+8|0;n=z;s=z+316|0;t=z+80|0;k=z+84|0;y=z+76|0;x=z+72|0;v=z+68|0;w=z+64|0;m=n;c[m>>2]=37;c[m+4>>2]=0;m=Bp(n+1|0,58898,c[d+4>>2]|0)|0;c[t>>2]=s;a=Xo()|0;if(m){c[g>>2]=c[d+8>>2];h[g+8>>3]=f;g=Su(s,30,a,n,g)|0}else{h[l>>3]=f;g=Su(s,30,a,n,l)|0}a:do if((g|0)>29){o=0;a=ua(3)|0;g=o;o=0;g=g&1;if(m){if(!g?(o=0,c[p>>2]=c[d+8>>2],h[p+8>>3]=f,j=va(17,t|0,a|0,n|0,p|0)|0,r=o,o=0,!(r&1)):0)A=12}else if(!g?(o=0,c[q>>2]=c[d+8>>2],h[q+8>>3]=f,r=va(17,t|0,a|0,n|0,q|0)|0,q=o,o=0,!(q&1)):0){j=r;A=12}do if((A|0)==12){a=c[t>>2]|0;if(!a){o=0;xa(6);r=o;o=0;if(r&1)break;g=c[t>>2]|0}else g=a;a=g;n=g;A=16;break a}while(0);a=Na()|0}else{a=c[t>>2]|0;n=0;j=g;A=16}while(0);if((A|0)==16){l=a+j|0;m=vp(a,l,d)|0;do if((a|0)==(s|0)){a=s;g=0;A=22}else{j=Fl(j<<3)|0;if(!j){o=0;xa(6);A=o;o=0;if(A&1){g=0;A=20;break}a=c[t>>2]|0}g=j;k=j;A=22}while(0);do if((A|0)==22){o=0;j=ka(68,d|0)|0;t=o;o=0;if(!(t&1)){c[v>>2]=j;o=0;pa(4,a|0,m|0,l|0,k|0,y|0,x|0,v|0);v=o;o=0;if(v&1){a=Na()|0;pm(j)|0;break}pm(j)|0;c[w>>2]=c[b>>2];A=c[y>>2]|0;a=c[x>>2]|0;o=0;c[u>>2]=c[w>>2];a=ja(40,u|0,k|0,A|0,a|0,d|0,e|0)|0;A=o;o=0;if(!(A&1)){c[b>>2]=a;if(g)Gl(g);if(n)Gl(n);i=z;return a|0}else A=20}else A=20}while(0);if((A|0)==20)a=Na()|0;if(g)Gl(g);if(n)Gl(n)}Ya(a|0);return 0}function Op(b,d,e,f,g,h,j){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=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;y=i;i=i+16|0;z=y;x=Is(j,44212)|0;v=Is(j,44368)|0;Cb[c[(c[v>>2]|0)+20>>2]&127](z,v);c[h>>2]=f;j=a[b>>0]|0;switch(j<<24>>24){case 43:case 45:{o=0;j=ra(c[(c[x>>2]|0)+44>>2]|0,x|0,j|0)|0;w=o;o=0;if(w&1)u=8;else{m=c[h>>2]|0;c[h>>2]=m+4;c[m>>2]=j;m=b+1|0;u=10}break}default:{m=b;u=10}}a:do if((u|0)==10){w=e;b:do if((w-m|0)>1?(a[m>>0]|0)==48:0){k=m+1|0;switch(a[k>>0]|0){case 88:case 120:break;default:{u=11;break b}}o=0;j=ra(c[(c[x>>2]|0)+44>>2]|0,x|0,48)|0;t=o;o=0;if(t&1){u=8;break a}t=c[h>>2]|0;c[h>>2]=t+4;c[t>>2]=j;m=m+2|0;o=0;j=ra(c[(c[x>>2]|0)+44>>2]|0,x|0,a[k>>0]|0)|0;t=o;o=0;if(t&1){u=8;break a}t=c[h>>2]|0;c[h>>2]=t+4;c[t>>2]=j;if(m>>>0<e>>>0){j=m;while(1){k=a[j>>0]|0;o=0;l=ua(3)|0;t=o;o=0;if(t&1)break;o=0;k=ra(39,k<<24>>24|0,l|0)|0;t=o;o=0;if(t&1)break;if(!k){t=m;break b}j=j+1|0;if(j>>>0>=e>>>0){t=m;break b}}j=Na()|0;break a}else{t=m;j=m}}else u=11;while(0);c:do if((u|0)==11)if(m>>>0<e>>>0){j=m;while(1){k=a[j>>0]|0;o=0;l=ua(3)|0;t=o;o=0;if(t&1)break;o=0;k=ra(40,k<<24>>24|0,l|0)|0;t=o;o=0;if(t&1)break;if(!k){t=m;break c}j=j+1|0;if(j>>>0>=e>>>0){t=m;break c}}j=Na()|0;break a}else{t=m;j=m}while(0);r=a[z>>0]|0;s=z+4|0;if(((r&1)==0?(r&255)>>>1:c[s>>2]|0)|0){if((t|0)!=(j|0)?(n=j+-1|0,t>>>0<n>>>0):0){l=t;k=n;do{r=a[l>>0]|0;a[l>>0]=a[k>>0]|0;a[k>>0]=r;l=l+1|0;k=k+-1|0}while(l>>>0<k>>>0)}o=0;n=ka(c[(c[v>>2]|0)+16>>2]|0,v|0)|0;r=o;o=0;if(r&1){u=8;break}p=z+8|0;q=z+1|0;d:do if(t>>>0<j>>>0){k=0;l=0;r=t;while(1){m=a
function xl(e,f,g,j,l){e=e|0;f=f|0;g=g|0;j=j|0;l=l|0;var m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=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,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;ha=i;i=i+624|0;ca=ha+24|0;ea=ha+16|0;da=ha+588|0;Y=ha+576|0;ba=ha;V=ha+536|0;ga=ha+8|0;fa=ha+528|0;M=(e|0)!=0;N=V+40|0;U=N;V=V+39|0;W=ga+4|0;X=Y+12|0;Y=Y+11|0;Z=da;_=X;aa=_-Z|0;O=-2-Z|0;P=_+2|0;Q=ca+288|0;R=da+9|0;S=R;T=da+8|0;m=0;w=f;n=0;f=0;a:while(1){do if((m|0)>-1)if((n|0)>(2147483647-m|0)){c[(ck()|0)>>2]=75;m=-1;break}else{m=n+m|0;break}while(0);n=a[w>>0]|0;if(!(n<<24>>24)){L=245;break}else o=w;b:while(1){switch(n<<24>>24){case 37:{n=o;L=9;break b}case 0:{n=o;break b}default:{}}K=o+1|0;n=a[K>>0]|0;o=K}c:do if((L|0)==9)while(1){L=0;if((a[n+1>>0]|0)!=37)break c;o=o+1|0;n=n+2|0;if((a[n>>0]|0)==37)L=9;else break}while(0);y=o-w|0;if(M?(c[e>>2]&32|0)==0:0)Xk(w,y,e)|0;if((o|0)!=(w|0)){w=n;n=y;continue}r=n+1|0;o=a[r>>0]|0;p=(o<<24>>24)+-48|0;if(p>>>0<10){K=(a[n+2>>0]|0)==36;r=K?n+3|0:r;o=a[r>>0]|0;u=K?p:-1;f=K?1:f}else u=-1;n=o<<24>>24;d:do if((n&-32|0)==32){p=0;while(1){if(!(1<<n+-32&75913)){s=p;n=r;break d}p=1<<(o<<24>>24)+-32|p;r=r+1|0;o=a[r>>0]|0;n=o<<24>>24;if((n&-32|0)!=32){s=p;n=r;break}}}else{s=0;n=r}while(0);do if(o<<24>>24==42){p=n+1|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+2>>0]|0)==36:0){c[l+(o<<2)>>2]=10;f=1;n=n+3|0;o=c[j+((a[p>>0]|0)+-48<<3)>>2]|0}else{if(f){m=-1;break a}if(!M){x=s;n=p;f=0;K=0;break}f=(c[g>>2]|0)+(4-1)&~(4-1);o=c[f>>2]|0;c[g>>2]=f+4;f=0;n=p}if((o|0)<0){x=s|8192;K=0-o|0}else{x=s;K=o}}else{p=(o<<24>>24)+-48|0;if(p>>>0<10){o=0;do{o=(o*10|0)+p|0;n=n+1|0;p=(a[n>>0]|0)+-48|0}while(p>>>0<10);if((o|0)<0){m=-1;break a}else{x=s;K=o}}else{x=s;K=0}}while(0);e:do if((a[n>>0]|0)==46){p=n+1|0;o=a[p>>0]|0;if(o<<24>>24!=42){r=(o<<24>>24)+-48|0;if(r>>>0<10){n=p;o=0}else{n=p;r=0;break}while(1){o=(o*10|0)+r|0;n=n+1|0;r=(a[n>>0]|0)+-48|0;if(r>>>0>=10){r=o;break e}}}p=n+2|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+3>>0]|0)==36:0){c[l+(o<<2)>>2]=10;n=n+4|0;r=c[j+((a[p>>0]|0)+-48<<3)>>2]|0;break}if(f){m=-1;break a}if(M){n=(c[g>>2]|0)+(4-1)&~(4-1);r=c[n>>2]|0;c[g>>2]=n+4;n=p}else{n=p;r=0}}else r=-1;while(0);t=0;while(1){o=(a[n>>0]|0)+-65|0;if(o>>>0>57){m=-1;break a}p=n+1|0;o=a[56223+(t*58|0)+o>>0]|0;s=o&255;if((s+-1|0)>>>0<8){n=p;t=s}else{J=p;break}}if(!(o<<24>>24)){m=-1;break}p=(u|0)>-1;do if(o<<24>>24==19)if(p){m=-1;break a}else L=52;else{if(p){c[l+(u<<2)>>2]=s;H=j+(u<<3)|0;I=c[H+4>>2]|0;L=ba;c[L>>2]=c[H>>2];c[L+4>>2]=I;L=52;break}if(!M){m=0;break a}Cl(ba,s,g)}while(0);if((L|0)==52?(L=0,!M):0){w=J;n=y;continue}u=a[n>>0]|0;u=(t|0)!=0&(u&15|0)==3?u&-33:u;p=x&-65537;I=(x&8192|0)==0?x:p;f:do switch(u|0){case 110:switch(t|0){case 0:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 1:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 2:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}case 3:{b[c[ba>>2]>>1]=m;w=J;n=y;continue a}case 4:{a[c[ba>>2]>>0]=m;w=J;n=y;continue a}case 6:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 7:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}default:{w=J;n=y;continue a}}case 112:{t=I|8;r=r>>>0>8?r:8;u=120;L=64;break}case 88:case 120:{t=I;L=64;break}case 111:{p=ba;o=c[p>>2]|0;p=c[p+4>>2]|0;if((o|0)==0&(p|0)==0)n=N;else{n=N;do{n=n+-1|0;a[n>>0]=o&7|48;o=kw(o|0,p|0,3)|0;p=D}while(!((o|0)==0&(p|0)==0))}if(!(I&8)){o=I;t=0;s=56703;L=77}else{t=U-n+1|0;o=I;r=(r|0)<(t|0)?t:r;t=0;s=56703;L=77}break}case 105:case 100:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;if((o|0)<0){n=hw(0,0,n|0,o|0)|0;o=D;p=ba;c[p>>2]=n;c[p+4>>2]=o;p=1;s=56703;L=76;break f}if(!(I&2048)){s=I&1;p=s;s=(s|0)==0?56703:56705;L=76}else{p=1;s=56704;L=76}break}case 117:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;p=0;s=56703;L=76;break}case 99:{a[V>>0]=c[ba>>2];w=V;o=1;t=0;u=56703;n=N;break}case 109:{n=dk(c[(ck()|0)>>2]|0)|0;L=82;break}case 115:{n=c[ba>>2]|0;n=(n|0)!=0?n:56713;L=82;break}case 67:{c[ga>>2]=c[ba>>2];c[W>>2]=0;c[ba>>2]=ga;r=-1;L=86;break}case 83:{if(!r){El(e,32,K,0,I);n=0;L=98}else L=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{q=+h[ba>>3];
function ut(b,d,e,f,g,h,j,k){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;var l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;u=i;i=i+16|0;s=u;q=u+8|0;a:do if((e|0)==(f|0))l=f;else{l=e;while(1){if(!(c[l>>2]|0))break a;l=l+4|0;if((l|0)==(f|0)){l=f;break}}}while(0);c[k>>2]=h;c[g>>2]=e;n=j;r=b+8|0;b:do if(!((h|0)==(j|0)|(e|0)==(f|0))){b=h;m=l;c:while(1){w=d;h=c[w+4>>2]|0;l=s;c[l>>2]=c[w>>2];c[l+4>>2]=h;l=qk(c[r>>2]|0)|0;o=0;h=sa(21,b|0,g|0,m-e>>2|0,n-b|0,d|0)|0;w=o;o=0;if(w&1){v=9;break}if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){v=8;break}switch(h|0){case 0:{p=1;break b}case -1:{l=b;v=14;break c}default:{}}l=(c[k>>2]|0)+h|0;c[k>>2]=l;if((l|0)==(j|0)){v=27;break}if((m|0)==(f|0)){e=c[g>>2]|0;b=l;l=f}else{l=qk(c[r>>2]|0)|0;o=0;e=ma(34,q|0,0,d|0)|0;w=o;o=0;if(w&1){v=35;break}if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){v=34;break}if((e|0)==-1){p=2;break b}if(e>>>0>(n-(c[k>>2]|0)|0)>>>0){p=1;break b}if(e){l=q;while(1){m=a[l>>0]|0;w=c[k>>2]|0;c[k>>2]=w+1;a[w>>0]=m;e=e+-1|0;if(!e)break;else l=l+1|0}}e=(c[g>>2]|0)+4|0;c[g>>2]=e;d:do if((e|0)==(f|0))l=f;else{l=e;while(1){if(!(c[l>>2]|0))break d;l=l+4|0;if((l|0)==(f|0)){l=f;break}}}while(0);b=c[k>>2]|0}if((b|0)==(j|0)|(e|0)==(f|0)){v=47;break b}else m=l}if((v|0)==8){w=Na(0)|0;ec(w)}else if((v|0)==9){e=Na()|0;if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}else if((v|0)==14){c[k>>2]=l;e:do if((e|0)!=(c[g>>2]|0)){while(1){w=c[e>>2]|0;b=qk(c[r>>2]|0)|0;o=0;l=ma(34,l|0,w|0,s|0)|0;w=o;o=0;if(w&1){t=b;break}if((b|0)!=0?(o=0,ka(75,b|0)|0,w=o,o=0,w&1):0){v=18;break}if((l|0)==-1)break e;l=(c[k>>2]|0)+l|0;c[k>>2]=l;e=e+4|0;if((e|0)==(c[g>>2]|0))break e}if((v|0)==18){w=Na(0)|0;ec(w)}e=Na()|0;if((t|0)!=0?(o=0,ka(75,t|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}while(0);c[g>>2]=e;p=2;break}else if((v|0)==27){e=c[g>>2]|0;v=47;break}else if((v|0)==34){w=Na(0)|0;ec(w)}else if((v|0)==35){e=Na()|0;if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}}else v=47;while(0);if((v|0)==47)p=(e|0)!=(f|0)&1;i=u;return p|0}function vt(b,d,e,f,g,h,j,k){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;var l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;u=i;i=i+16|0;t=u;a:do if((e|0)==(f|0))l=f;else{l=e;while(1){if(!(a[l>>0]|0))break a;l=l+1|0;if((l|0)==(f|0)){l=f;break}}}while(0);c[k>>2]=h;c[g>>2]=e;p=j;r=b+8|0;b:do if(!((h|0)==(j|0)|(e|0)==(f|0))){b=h;n=l;c:while(1){m=d;l=c[m+4>>2]|0;h=t;c[h>>2]=c[m>>2];c[h+4>>2]=l;h=n;l=qk(c[r>>2]|0)|0;o=0;m=sa(22,b|0,g|0,h-e|0,p-b>>2|0,d|0)|0;w=o;o=0;if(w&1){v=9;break}if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){v=8;break}switch(m|0){case 0:{q=2;break b}case -1:{l=b;v=14;break c}default:{}}b=(c[k>>2]|0)+(m<<2)|0;c[k>>2]=b;if((b|0)==(j|0)){v=31;break}e=c[g>>2]|0;if((n|0)==(f|0))l=f;else{l=qk(c[r>>2]|0)|0;o=0;e=va(20,b|0,e|0,1,d|0)|0;w=o;o=0;if(w&1){v=38;break}if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){v=37;break}if(e){q=2;break b}c[k>>2]=(c[k>>2]|0)+4;e=(c[g>>2]|0)+1|0;c[g>>2]=e;d:do if((e|0)==(f|0))l=f;else{l=e;while(1){if(!(a[l>>0]|0))break d;l=l+1|0;if((l|0)==(f|0)){l=f;break}}}while(0);b=c[k>>2]|0}if((b|0)==(j|0)|(e|0)==(f|0)){v=47;break b}else n=l}if((v|0)==8){w=Na(0)|0;ec(w)}else if((v|0)==9){e=Na()|0;if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}else if((v|0)==14){c[k>>2]=l;e:do if((e|0)!=(c[g>>2]|0)){b=l;f:while(1){l=qk(c[r>>2]|0)|0;o=0;b=va(20,b|0,e|0,h-e|0,t|0)|0;w=o;o=0;if(w&1){v=19;break}if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){v=18;break}switch(b|0){case -1:{v=25;break f}case -2:{v=26;break f}case 0:{e=e+1|0;break}default:e=e+b|0}b=(c[k>>2]|0)+4|0;c[k>>2]=b;if((e|0)==(c[g>>2]|0)){s=e;break e}}if((v|0)==18){w=Na(0)|0;ec(w)}else if((v|0)==19){e=Na()|0;if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}else if((v|0)==25){c[g>>2]=e;q=2;break b}else if((v|0)==26){c[g>>2]=e;q=1;break b}}else s=e;while(0);c[g>>2]=s;q=(s|0)!=(f|0)&1;break}else if((v|0)==31){e=c[g>>2]|0;v=47;break}else if((v|0)==37){w=Na(0)|0;ec(w)}else if((v|0)==38){e=Na()|0;if((l|0)!=0?(o=0,ka(75,l|0)|0,w=o,o=0,w&1):0){w=Na(0)|0;ec(w)}Ya(e|0)}}else v=47;while(0);if((v|0)==47)q=(e|0)!=(f|0)&1;i=u;return q|0}funct
function di(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+32|0;k=m;Ei(k,255,0);l=b+152|0;if(((c[k+4>>2]|0)==(c[l>>2]|0)?(c[k+8>>2]|0)==(c[b+156>>2]|0):0)?(c[k+12>>2]|0)==(c[b+160>>2]|0):0){l=c[8900]|0;c[b+4580>>2]=l+(((c[8901]|0)-l|0)>>>1);i=m;return}e=b+4584|0;f=b+4588|0;g=c[f>>2]|0;d=c[e>>2]|0;h=g-d|0;if(h>>>0>=512){if(h>>>0>512?(j=d+512|0,(g|0)!=(j|0)):0)c[f>>2]=j}else{ie(e,512-h|0);d=c[e>>2]|0}k=b+4580|0;c[k>>2]=d+256;j=b+160|0;g=b+156|0;h=-256;while(1){d=c[j>>2]|0;if((h|0)>(0-d|0)){e=c[g>>2]|0;if((h|0)>(0-e|0)){f=c[l>>2]|0;if((h|0)>(0-f|0))if((h|0)>=0){if((h|0)<1){a[(c[k>>2]|0)+h>>0]=0;h=1;continue}if((f|0)<=(h|0))if((e|0)>(h|0))d=2;else d=(d|0)>(h|0)?3:4;else d=1}else d=-1;else d=-2}else d=-3}else d=-4;a[(c[k>>2]|0)+h>>0]=d;h=h+1|0;if((h|0)==256)break}i=m;return}function ei(a){a=a|0;var b=0,d=0;c[a>>2]=35660;b=c[a+4608>>2]|0;if(b){d=a+4612|0;if((c[d>>2]|0)!=(b|0))c[d>>2]=b;cj(b)}c[a>>2]=36736;b=c[a+92>>2]|0;if(b){d=a+96|0;if((c[d>>2]|0)!=(b|0))c[d>>2]=b;cj(b)}a=a+88|0;b=c[a>>2]|0;c[a>>2]=0;if(!b)return;Bb[c[(c[b>>2]|0)+4>>2]&255](b);return}function fi(a){a=a|0;var b=0,d=0;c[a>>2]=35660;b=c[a+4608>>2]|0;if(b){d=a+4612|0;if((c[d>>2]|0)!=(b|0))c[d>>2]=b;cj(b)}c[a>>2]=36736;b=c[a+92>>2]|0;if(b){d=a+96|0;if((c[d>>2]|0)!=(b|0))c[d>>2]=b;cj(b)}d=a+88|0;b=c[d>>2]|0;c[d>>2]=0;if(!b){cj(a);return}Bb[c[(c[b>>2]|0)+4>>2]&255](b);cj(a);return}function gi(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;w=i;i=i+352|0;x=w+328|0;y=w+192|0;e=w+343|0;f=w+342|0;g=w+341|0;h=w+340|0;r=w+176|0;k=w+168|0;l=w+160|0;m=w+152|0;v=w;t=w+136|0;if((c[b+28>>2]|0)!=0?(c[b+20>>2]|0)!=1:0){s=b+4|0;u=b+32|0;j=c[u>>2]|0;if(!j){b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[e>>0]|0;Aa(44,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}b=c[b+12>>2]|0;if((b|0)==8)switch(j|0){case 1:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[f>>0]|0;Aa(45,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[g>>0]|0;Aa(46,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(48)|0;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];a[x>>0]=a[h>>0]|0;Aa(47,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}default:{j=y+56|0;g=y+4|0;c[y>>2]=36160;c[j>>2]=36180;o=0;ia(62,y+56|0,g|0);w=o;o=0;if(w&1){z=Na()|0;fn(j);Ya(z|0)}c[y+128>>2]=0;c[y+132>>2]=-1;c[y>>2]=36200;c[y+56>>2]=36220;o=0;ha(180,g|0);w=o;o=0;do if(w&1)b=Na()|0;else{c[g>>2]=36236;h=y+36|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[y+52>>2]=16;c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;o=0;ia(63,g|0,x|0);w=o;o=0;if(w&1){b=Na()|0;Im(x);Im(h);nn(g);break}Im(x);o=0;b=ma(28,y|0,49007,21)|0;x=o;o=0;do if((!(x&1)?(o=0,p=ra(36,b|0,c[u>>2]|0)|0,x=o,o=0,!(x&1)):0)?(o=0,ma(28,p|0,50997,18)|0,x=o,o=0,!(x&1)):0){f=Ma(16)|0;o=0;ia(64,r|0,g|0);x=o;o=0;if(!(x&1)){if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;Aa(36,f|0,9,35648,r|0);x=o;o=0;if(x&1)e=1;else{o=0;wa(6,f|0,824,96);o=0;e=0}b=Na()|0;Im(r);if(!e)break}else b=Na()|0;La(f|0)}else z=34;while(0);if((z|0)==34)b=Na()|0;c[y>>2]=36200;c[j>>2]=36220;c[g>>2]=36236;Im(h);nn(g);fn(j);z=b;Ya(z|0)}while(0);z=b;fn(j);Ya(z|0)}}if((b|0)<=8){b=Ma(16)|0;if((a[8]|0)==0?(Ha(8)|0)!=0:0){kb(72,35648,n|0)|0;Pa(8)}o=0;wa(7,b|0,8,35648);z=o;o=0;if(!(z&1))lb(b|0,824,96);z=Na()|0;La(b|0);Ya(z|0)}e=16-b|0;switch(j|0){case 1:{b=bj(60)|0;c[k>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[k>>2];c[x+4>>2]=c[k+4>>2];Aa(41,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 2:{b=bj(60)|0;c[l>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[l>>2];c[x+4>>2]=c[l+4>>2];Aa(42,b|0,y|0,s|0,x|0);z=o;o=0;if(!(z&1)){z=b;i=w;return z|0}z=Na()|0;cj(b);Ya(z|0)}case 3:{b=bj(60)|0;c[m>>2]=e;o=0;c[y>>2]=c[d>>2];c[y+4>>2]=c[d+4>>2];c[y+8>>2]=c[d+8>>2];c[x>>2]=c[m>>2];c[x+4>>2]=c[m
// EMSCRIPTEN_END_FUNCS
var yb=[Uw,Qq,Uq,Or,Sr,Xr,Zr,xu,Iu,Uw,Uw,Uw,Uw,Uw,Uw,Uw];var zb=[Vw,ii,Yh,Mh,Ah,oh,ch,Sg,Bg,Mj,Lj,Ij,Vw,Vw,Vw,Vw];var Ab=[Ww,bs,hs,Ww];var Bb=[Xw,ei,fi,Uh,Vh,Ih,Jh,wh,xh,kh,lh,_g,$g,Og,Pg,xg,yg,kg,lg,_f,$f,Of,Pf,Cf,Df,qf,rf,ye,ze,le,me,tc,uc,Pd,Td,Qd,bo,eo,co,fo,kd,ld,Qi,md,dd,ed,Ic,Jc,Qc,Rc,Xc,Yc,nd,od,ud,vd,Bd,Cd,Id,Jd,je,ke,He,Ie,Oe,Pe,Ve,We,af,bf,Mg,Ng,Dm,qi,Ai,Bi,Ri,Si,fj,gj,mj,nj,rj,sj,uj,xj,vj,wj,yj,zj,Cn,Tl,Zl,nn,cm,im,Bm,Cm,on,Dn,Rn,Tn,Sn,Un,Xn,Zn,Yn,_n,ko,mo,lo,no,uo,vo,en,wo,xo,yo,Ao,Ks,Eo,Fo,Jo,Ko,Yo,Zo,qp,rp,Fp,Gp,Sp,Tp,pq,qq,Nq,Pq,Sq,Tq,Wq,Xq,fr,gr,qr,rr,Br,Cr,Mr,Nr,Vr,Wr,$r,as,fs,gs,ls,ms,qs,rs,ys,zs,at,bt,wu,tt,Vt,Wt,Xt,Yt,zo,Js,Ms,kt,Bt,Jt,Rt,St,Ti,Ii,$i,sc,pn,Wn,_d,Eg,Wj,ul,vl,Ml,mk,Pr,Rr,Ls,Gv,Nv,Ov,Pv,Qv,Rv,Sv,Im,Wm,Gl,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw,Xw];var Cb=[Yw,hi,Xh,Lh,zh,nh,bh,Rg,Ag,mg,ag,Qf,Ef,sf,Ae,ne,vc,qn,Ci,Fi,Ul,Yl,dm,hm,Fn,_q,$q,ar,br,dr,er,jr,kr,lr,mr,or,pr,ur,vr,wr,xr,zr,Ar,Fr,Gr,Hr,Ir,Kr,Lr,ps,us,bu,du,fu,cu,eu,gu,kc,Ui,Gi,Hi,Ji,kn,Cc,Ec,go,dn,Qm,Zd,re,jf,wf,If,Uf,eg,qg,Dg,Ug,eh,qh,Ch,Oh,_h,ki,yi,Zi,sm,qm,hn,oo,rm,Om,_m,Zm,av,bv,cv,dv,ev,fv,st,gv,hv,iv,jv,kv,lv,mv,nv,ov,pv,qv,rv,sv,tv,uv,vv,wv,xv,yv,zv,Av,Bv,Cv,Ev,Yv,Yw,Yw];var Db=[Zw,Lo,Mo,No,Oo,Po,Qo,Ro,So,To,Uo,Vo,_o,$o,ap,bp,cp,dp,ep,fp,gp,hp,ip,xp,zp,Kp,Mp,Vp,Wp,Xp,Zp,$p,sq,tq,uq,wq,yq,es,ks,cd,Uu,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw,Zw];var Eb=[_w,un,vn,hd,yn,ri,hj,oj,tj,Mk,Vl,Kn,Mn,Nn,Jn,_l,$l,em,xn,jm,km,qo,Up,iu,ku,mu,su,uu,ou,qu,rq,ju,lu,nu,tu,vu,pu,ru,Yq,Zq,cr,hr,ir,nr,sr,tr,yr,Dr,Er,Jr,xt,yt,At,Zt,$t,_t,au,ot,pt,rt,Ft,Gt,It,Nt,Ot,Qt,ui,bj,jn,Li,Vn,$n,$w,ax,bx,qk,pl,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w,_w];var Fb=[cx,Qr,Yr,cx];var Gb=[dx,rn,wn,An,um,vm,Aj,Bl,Pk,Ok,Nk,Qk,Gn,Ln,Wl,Pn,fm,Do,Io,ns,ss,dt,ft,it,Ns,Us,Xs,_s,Dc,yl,Rm,pk,Zu,$u,Fk,Ek,zk,bl,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx,dx];var Hb=[ex,ds,js,ex];var Ib=[fx,fd,Pj,Oj,Nj,Hn,sn,os,ts,fx,fx,fx,fx,fx,fx,fx];var Jb=[gx,wp,Cp,Jp,Op,gx,gx,gx];var Kb=[hx,Tr,_r,cs,is,hx,hx,hx];var Lb=[ix,gi,Wh,Kh,yh,mh,ah,Qg,zg,og,cg,Sf,Gf,uf,Ce,pe,xc,id,jd,On,Xl,am,Qn,zn,gm,lm,Bn,ct,et,gt,Ss,Vs,Ys,Vi,oc,qc,io,Is,jo,ok,nk,Km,Xm,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix,ix];var Mb=[jx,Bo,Go,sp,tp,yp,Ep,Hp,Ip,Lp,Qp,jt,wt,zt,$s,nt,qt,Et,Ht,Mt,Pt,Gk,Ck,jx,jx,jx,jx,jx,jx,jx,jx,jx];var Nb=[kx,$v,_v,Zv];var Ob=[lx,lc,aj,Xo,Bs,Cs,Ds,Zj,$j,_j,lx,lx,lx,lx,lx,lx];var Pb=[mx,ng,bg,Rf,Ff,tf,Be,oe,wc,ht,Ps,Qs,Rs,Zs,ti,zi,Hu,Tu,Dk,kk,Ak,fw,ew,dw,cw,bw,aw,mx,mx,mx,mx,mx];var Qb=[nx,tm,si,ro,Wi,Gm,ox,Am,Mm,Ki,xm,to,Xu,Yu,_u,Um];var Rb=[px,qx,Tj,rx,Uj,sx,Sj,px];var Sb=[tx,bq,Aq,ut,vt,lt,mt,Ct,Dt,Kt,Lt,tx,tx,tx,tx,tx];var Tb=[ux,Ap,Dp,Np,Pp,ux,ux,ux];var Ub=[vx,Ud,Vd,Rd,Sd,gd,Kc,Lc,Sc,Tc,Zc,_c,pd,qd,wd,xd,Dd,Ed,Kd,Ld,Je,Ke,Qe,Re,Xe,Ye,cf,df,Cj,Dj,Fj,In,tn,Co,Ho,dc,zm,yc,zc,Ac,Bc,Fc,Gc,Hc,De,Ee,Fe,Ge,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx];return{_jpegls_encode:Yi,___cxa_can_catch:Qj,_free:Gl,_jpegls_decode:Xi,___cxa_is_pointer_type:Rj,_i64Add:jw,_memmove:nw,_i64Subtract:hw,_memset:iw,_malloc:Fl,_memcpy:lw,_bitshift64Lshr:kw,_bitshift64Shl:mw,__GLOBAL__I_000101:Nl,__GLOBAL__sub_I_jpegls_cpp:rc,__GLOBAL__sub_I_iostream_cpp:Ol,runPostSets:gw,stackAlloc:Vb,stackSave:Wb,stackRestore:Xb,establishStackSpace:Yb,setThrew:Zb,setTempRet0:ac,getTempRet0:bc,dynCall_iiiiiiii:xw,dynCall_viiiii:yw,dynCall_iiiiiid:zw,dynCall_vi:Aw,dynCall_vii:Bw,dynCall_iiiiiii:Cw,dynCall_ii:Dw,dynCall_iiiiiiiiiiii:Ew,dynCall_iiii:Fw,dynCall_viiiiiiiiiiiiiii:Gw,dynCall_viiiiii:Hw,dynCall_viiiiiii:Iw,dynCall_viiiiiiiiii:Jw,dynCall_iii:Kw,dynCall_iiiiii:Lw,dynCall_diii:Mw,dynCall_i:Nw,dynCall_iiiii:Ow,dynCall_viii:Pw,dynCall_v:Qw,dynCall_iiiiiiiii:Rw,dynCall_iiiiid:Sw,dynCall_viiii:Tw}})
// EMSCRIPTEN_END_ASM
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _jpegls_encode=Module["_jpegls_encode"]=asm["_jpegls_encode"];var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var _free=Module["_free"]=asm["_free"];var _jpegls_decode=Module["_jpegls_decode"]=asm["_jpegls_decode"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _memmove=Module["_memmove"]=asm["_memmove"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _memset=Module["_memset"]=asm["_memset"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var __GLOBAL__sub_I_iostream_cpp=Module["__GLOBAL__sub_I_iostream_cpp"]=asm["__GLOBAL__sub_I_iostream_cpp"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var __GLOBAL__sub_I_jpegls_cpp=Module["__GLOBAL__sub_I_jpegls_cpp"]=asm["__GLOBAL__sub_I_jpegls_cpp"];var __GLOBAL__I_000101=Module["__GLOBAL__I_000101"]=asm["__GLOBAL__I_000101"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var dynCall_iiiiiiii=Module["dynCall_iiiiiiii"]=asm["dynCall_iiiiiiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_iiiiiid=Module["dynCall_iiiiiid"]=asm["dynCall_iiiiiid"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iiiiiiiiiiii=Module["dynCall_iiiiiiiiiiii"]=asm["dynCall_iiiiiiiiiiii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiiiiiiiiiiiii=Module["dynCall_viiiiiiiiiiiiiii"]=asm["dynCall_viiiiiiiiiiiiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=asm["dynCall_viiiiiii"];var dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=asm["dynCall_viiiiiiiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiiiii=Module["dynCall_iiiiii"]=asm["dynCall_iiiiii"];var dynCall_diii=Module["dynCall_diii"]=asm["dynCall_diii"];var dynCall_i=Module["dynCall_i"]=asm["dynCall_i"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_iiiiiiiii=Module["dynCall_iiiiiiiii"]=asm["dynCall_iiiiiiiii"];var dynCall_iiiiid=Module["dynCall_iiiiid"]=asm["dynCall_iiiiid"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called");args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i<argc-1;i=i+1){argv.push(allocate(intArrayFromString(args[i]),"i8",ALLOC_NORMAL));pad()}argv.push(0);argv=allocate(argv,"i32",ALLOC_NORMAL);try{var ret=Module["_main"](argc,argv,0);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="SimulateInfiniteLoop"){Module["noExitRuntime"]=true;return}else{if(e&&
return Module;
};
// jshint ignore: start
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/*
Copyright 2011 notmasteryet
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// - The JPEG specification can be found in the ITU CCITT Recommendation T.81
// (www.w3.org/Graphics/JPEG/itu-t81.pdf)
// - The JFIF specification can be found in the JPEG File Interchange Format
// (www.w3.org/Graphics/JPEG/jfif3.pdf)
// - The Adobe Application-Specific JPEG markers in the Supporting the DCT Filters
// in PostScript Level 2, Technical Note #5116
// (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf)
var ColorSpace = {Unkown: 0, Grayscale: 1, AdobeRGB: 2, RGB: 3, CYMK: 4};
var JpegImage = (function jpegImage() {
"use strict";
var dctZigZag = new Int32Array([
0,
1, 8,
16, 9, 2,
3, 10, 17, 24,
32, 25, 18, 11, 4,
5, 12, 19, 26, 33, 40,
48, 41, 34, 27, 20, 13, 6,
7, 14, 21, 28, 35, 42, 49, 56,
57, 50, 43, 36, 29, 22, 15,
23, 30, 37, 44, 51, 58,
59, 52, 45, 38, 31,
39, 46, 53, 60,
61, 54, 47,
55, 62,
63
]);
var dctCos1 = 4017; // cos(pi/16)
var dctSin1 = 799; // sin(pi/16)
var dctCos3 = 3406; // cos(3*pi/16)
var dctSin3 = 2276; // sin(3*pi/16)
var dctCos6 = 1567; // cos(6*pi/16)
var dctSin6 = 3784; // sin(6*pi/16)
var dctSqrt2 = 5793; // sqrt(2)
var dctSqrt1d2 = 2896; // sqrt(2) / 2
function constructor() {
}
function buildHuffmanTable(codeLengths, values) {
var k = 0, code = [], i, j, length = 16;
while (length > 0 && !codeLengths[length - 1])
length--;
code.push({children: [], index: 0});
var p = code[0], q;
for (i = 0; i < length; i++) {
for (j = 0; j < codeLengths[i]; j++) {
p = code.pop();
p.children[p.index] = values[k];
while (p.index > 0) {
p = code.pop();
}
p.index++;
code.push(p);
while (code.length <= i) {
code.push(q = {children: [], index: 0});
p.children[p.index] = q.children;
p = q;
}
k++;
}
if (i + 1 < length) {
// p here points to last code
code.push(q = {children: [], index: 0});
p.children[p.index] = q.children;
p = q;
}
}
return code[0].children;
}
function getBlockBufferOffset(component, row, col) {
return 64 * ((component.blocksPerLine + 1) * row + col);
}
function decodeScan(data, offset,
frame, components, resetInterval,
spectralStart, spectralEnd,
successivePrev, successive) {
var precision = frame.precision;
var samplesPerLine = frame.samplesPerLine;
var scanLines = frame.scanLines;
var mcusPerLine = frame.mcusPerLine;
var progressive = frame.progressive;
var maxH = frame.maxH, maxV = frame.maxV;
var startOffset = offset, bitsData = 0, bitsCount = 0;
function readBit() {
if (bitsCount > 0) {
bitsCount--;
return (bitsData >> bitsCount) & 1;
}
bitsData = data[offset++];
if (bitsData == 0xFF) {
var nextByte = data[offset++];
if (nextByte) {
throw "unexpected marker: " + ((bitsData << 8) | nextByte).toString(16);
}
// unstuff 0
}
bitsCount = 7;
return bitsData >>> 7;
}
function decodeHuffman(tree) {
var node = tree;
var bit;
while ((bit = readBit()) !== null) {
node = node[bit];
if (typeof node === 'number')
return node;
if (typeof node !== 'object')
throw "invalid huffman sequence";
}
return null;
}
function receive(length) {
var n = 0;
while (length > 0) {
var bit = readBit();
if (bit === null)
return;
n = (n << 1) | bit;
length--;
}
return n;
}
function receiveAndExtend(length) {
var n = receive(length);
if (n >= 1 << (length - 1))
return n;
return n + (-1 << length) + 1;
}
function decodeBaseline(component, offset) {
var t = decodeHuffman(component.huffmanTableDC);
var diff = t === 0 ? 0 : receiveAndExtend(t);
component.blockData[offset] = (component.pred += diff);
var k = 1;
while (k < 64) {
var rs = decodeHuffman(component.huffmanTableAC);
var s = rs & 15, r = rs >> 4;
if (s === 0) {
if (r < 15)
break;
k += 16;
continue;
}
k += r;
var z = dctZigZag[k];
component.blockData[offset + z] = receiveAndExtend(s);
k++;
}
}
function decodeDCFirst(component, offset) {
var t = decodeHuffman(component.huffmanTableDC);
var diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);
component.blockData[offset] = (component.pred += diff);
}
function decodeDCSuccessive(component, offset) {
component.blockData[offset] |= readBit() << successive;
}
var eobrun = 0;
function decodeACFirst(component, offset) {
if (eobrun > 0) {
eobrun--;
return;
}
var k = spectralStart, e = spectralEnd;
while (k <= e) {
var rs = decodeHuffman(component.huffmanTableAC);
var s = rs & 15, r = rs >> 4;
if (s === 0) {
if (r < 15) {
eobrun = receive(r) + (1 << r) - 1;
break;
}
k += 16;
continue;
}
k += r;
var z = dctZigZag[k];
component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
k++;
}
}
var successiveACState = 0, successiveACNextValue;
function decodeACSuccessive(component, offset) {
var k = spectralStart, e = spectralEnd, r = 0;
while (k <= e) {
var z = dctZigZag[k];
switch (successiveACState) {
case 0: // initial state
var rs = decodeHuffman(component.huffmanTableAC);
var s = rs & 15;
r = rs >> 4;
if (s === 0) {
if (r < 15) {
eobrun = receive(r) + (1 << r);
successiveACState = 4;
} else {
r = 16;
successiveACState = 1;
}
} else {
if (s !== 1)
throw "invalid ACn encoding";
successiveACNextValue = receiveAndExtend(s);
successiveACState = r ? 2 : 3;
}
continue;
case 1: // skipping r zero items
case 2:
if (component.blockData[offset + z]) {
component.blockData[offset + z] += (readBit() << successive);
} else {
r--;
if (r === 0)
successiveACState = successiveACState == 2 ? 3 : 0;
}
break;
case 3: // set value for a zero item
if (component.blockData[offset + z]) {
component.blockData[offset + z] += (readBit() << successive);
} else {
component.blockData[offset + z] = successiveACNextValue << successive;
successiveACState = 0;
}
break;
case 4: // eob
if (component.blockData[offset + z]) {
component.blockData[offset + z] += (readBit() << successive);
}
break;
}
k++;
}
if (successiveACState === 4) {
eobrun--;
if (eobrun === 0)
successiveACState = 0;
}
}
function decodeMcu(component, decode, mcu, row, col) {
var mcuRow = (mcu / mcusPerLine) | 0;
var mcuCol = mcu % mcusPerLine;
var blockRow = mcuRow * component.v + row;
var blockCol = mcuCol * component.h + col;
var offset = getBlockBufferOffset(component, blockRow, blockCol);
decode(component, offset);
}
function decodeBlock(component, decode, mcu) {
var blockRow = (mcu / component.blocksPerLine) | 0;
var blockCol = mcu % component.blocksPerLine;
var offset = getBlockBufferOffset(component, blockRow, blockCol);
decode(component, offset);
}
var componentsLength = components.length;
var component, i, j, k, n;
var decodeFn;
if (progressive) {
if (spectralStart === 0)
decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
else
decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
} else {
decodeFn = decodeBaseline;
}
var mcu = 0, marker;
var mcuExpected;
if (componentsLength == 1) {
mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
} else {
mcuExpected = mcusPerLine * frame.mcusPerColumn;
}
if (!resetInterval) {
resetInterval = mcuExpected;
}
var h, v;
while (mcu < mcuExpected) {
// reset interval stuff
for (i = 0; i < componentsLength; i++) {
components[i].pred = 0;
}
eobrun = 0;
if (componentsLength == 1) {
component = components[0];
for (n = 0; n < resetInterval; n++) {
decodeBlock(component, decodeFn, mcu);
mcu++;
}
} else {
for (n = 0; n < resetInterval; n++) {
for (i = 0; i < componentsLength; i++) {
component = components[i];
h = component.h;
v = component.v;
for (j = 0; j < v; j++) {
for (k = 0; k < h; k++) {
decodeMcu(component, decodeFn, mcu, j, k);
}
}
}
mcu++;
}
}
// find marker
bitsCount = 0;
marker = (data[offset] << 8) | data[offset + 1];
if (marker <= 0xFF00) {
throw "marker was not found";
}
if (marker >= 0xFFD0 && marker <= 0xFFD7) { // RSTx
offset += 2;
} else {
break;
}
}
return offset - startOffset;
}
// A port of poppler's IDCT method which in turn is taken from:
// Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz,
// "Practical Fast 1-D DCT Algorithms with 11 Multiplications",
// IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989,
// 988-991.
function quantizeAndInverse(component, blockBufferOffset, p) {
var qt = component.quantizationTable;
var v0, v1, v2, v3, v4, v5, v6, v7, t;
var i;
// dequant
for (i = 0; i < 64; i++) {
p[i] = component.blockData[blockBufferOffset + i] * qt[i];
}
// inverse DCT on rows
for (i = 0; i < 8; ++i) {
var row = 8 * i;
// check for all-zero AC coefficients
if (p[1 + row] === 0 && p[2 + row] === 0 && p[3 + row] === 0 &&
p[4 + row] === 0 && p[5 + row] === 0 && p[6 + row] === 0 &&
p[7 + row] === 0) {
t = (dctSqrt2 * p[0 + row] + 512) >> 10;
p[0 + row] = t;
p[1 + row] = t;
p[2 + row] = t;
p[3 + row] = t;
p[4 + row] = t;
p[5 + row] = t;
p[6 + row] = t;
p[7 + row] = t;
continue;
}
// stage 4
v0 = (dctSqrt2 * p[0 + row] + 128) >> 8;
v1 = (dctSqrt2 * p[4 + row] + 128) >> 8;
v2 = p[2 + row];
v3 = p[6 + row];
v4 = (dctSqrt1d2 * (p[1 + row] - p[7 + row]) + 128) >> 8;
v7 = (dctSqrt1d2 * (p[1 + row] + p[7 + row]) + 128) >> 8;
v5 = p[3 + row] << 4;
v6 = p[5 + row] << 4;
// stage 3
t = (v0 - v1 + 1) >> 1;
v0 = (v0 + v1 + 1) >> 1;
v1 = t;
t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8;
v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8;
v3 = t;
t = (v4 - v6 + 1) >> 1;
v4 = (v4 + v6 + 1) >> 1;
v6 = t;
t = (v7 + v5 + 1) >> 1;
v5 = (v7 - v5 + 1) >> 1;
v7 = t;
// stage 2
t = (v0 - v3 + 1) >> 1;
v0 = (v0 + v3 + 1) >> 1;
v3 = t;
t = (v1 - v2 + 1) >> 1;
v1 = (v1 + v2 + 1) >> 1;
v2 = t;
t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
v7 = t;
t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
v6 = t;
// stage 1
p[0 + row] = v0 + v7;
p[7 + row] = v0 - v7;
p[1 + row] = v1 + v6;
p[6 + row] = v1 - v6;
p[2 + row] = v2 + v5;
p[5 + row] = v2 - v5;
p[3 + row] = v3 + v4;
p[4 + row] = v3 - v4;
}
// inverse DCT on columns
for (i = 0; i < 8; ++i) {
var col = i;
// check for all-zero AC coefficients
if (p[1 * 8 + col] === 0 && p[2 * 8 + col] === 0 && p[3 * 8 + col] === 0 &&
p[4 * 8 + col] === 0 && p[5 * 8 + col] === 0 && p[6 * 8 + col] === 0 &&
p[7 * 8 + col] === 0) {
t = (dctSqrt2 * p[i + 0] + 8192) >> 14;
p[0 * 8 + col] = t;
p[1 * 8 + col] = t;
p[2 * 8 + col] = t;
p[3 * 8 + col] = t;
p[4 * 8 + col] = t;
p[5 * 8 + col] = t;
p[6 * 8 + col] = t;
p[7 * 8 + col] = t;
continue;
}
// stage 4
v0 = (dctSqrt2 * p[0 * 8 + col] + 2048) >> 12;
v1 = (dctSqrt2 * p[4 * 8 + col] + 2048) >> 12;
v2 = p[2 * 8 + col];
v3 = p[6 * 8 + col];
v4 = (dctSqrt1d2 * (p[1 * 8 + col] - p[7 * 8 + col]) + 2048) >> 12;
v7 = (dctSqrt1d2 * (p[1 * 8 + col] + p[7 * 8 + col]) + 2048) >> 12;
v5 = p[3 * 8 + col];
v6 = p[5 * 8 + col];
// stage 3
t = (v0 - v1 + 1) >> 1;
v0 = (v0 + v1 + 1) >> 1;
v1 = t;
t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12;
v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12;
v3 = t;
t = (v4 - v6 + 1) >> 1;
v4 = (v4 + v6 + 1) >> 1;
v6 = t;
t = (v7 + v5 + 1) >> 1;
v5 = (v7 - v5 + 1) >> 1;
v7 = t;
// stage 2
t = (v0 - v3 + 1) >> 1;
v0 = (v0 + v3 + 1) >> 1;
v3 = t;
t = (v1 - v2 + 1) >> 1;
v1 = (v1 + v2 + 1) >> 1;
v2 = t;
t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
v7 = t;
t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
v6 = t;
// stage 1
p[0 * 8 + col] = v0 + v7;
p[7 * 8 + col] = v0 - v7;
p[1 * 8 + col] = v1 + v6;
p[6 * 8 + col] = v1 - v6;
p[2 * 8 + col] = v2 + v5;
p[5 * 8 + col] = v2 - v5;
p[3 * 8 + col] = v3 + v4;
p[4 * 8 + col] = v3 - v4;
}
// convert to 8-bit integers
for (i = 0; i < 64; ++i) {
var index = blockBufferOffset + i;
var q = p[i];
q = (q <= -2056 / component.bitConversion) ? 0 :
(q >= 2024 / component.bitConversion) ? 255 / component.bitConversion :
(q + 2056 / component.bitConversion) >> 4;
component.blockData[index] = q;
}
}
function buildComponentData(frame, component) {
var lines = [];
var blocksPerLine = component.blocksPerLine;
var blocksPerColumn = component.blocksPerColumn;
var samplesPerLine = blocksPerLine << 3;
var computationBuffer = new Int32Array(64);
var i, j, ll = 0;
for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
var offset = getBlockBufferOffset(component, blockRow, blockCol);
quantizeAndInverse(component, offset, computationBuffer);
}
}
return component.blockData;
}
function clampToUint8(a) {
return a <= 0 ? 0 : a >= 255 ? 255 : a | 0;
}
constructor.prototype = {
load: function load(path) {
var handleData = (function (data) {
this.parse(data);
if (this.onload)
this.onload();
}).bind(this);
if (path.indexOf("data:") > -1) {
var offset = path.indexOf("base64,") + 7;
var data = atob(path.substring(offset));
var arr = new Uint8Array(data.length);
for (var i = data.length - 1; i >= 0; i--) {
arr[i] = data.charCodeAt(i);
}
handleData(data);
} else {
var xhr = new XMLHttpRequest();
xhr.open("GET", path, true);
xhr.responseType = "arraybuffer";
xhr.onload = (function () {
// TODO catch parse error
var data = new Uint8Array(xhr.response);
handleData(data);
}).bind(this);
xhr.send(null);
}
},
parse: function parse(data) {
function readUint16() {
var value = (data[offset] << 8) | data[offset + 1];
offset += 2;
return value;
}
function readDataBlock() {
var length = readUint16();
var array = data.subarray(offset, offset + length - 2);
offset += array.length;
return array;
}
function prepareComponents(frame) {
var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
for (var i = 0; i < frame.components.length; i++) {
component = frame.components[i];
var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
var blocksPerLineForMcu = mcusPerLine * component.h;
var blocksPerColumnForMcu = mcusPerColumn * component.v;
var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
component.blockData = new Int16Array(blocksBufferSize);
component.blocksPerLine = blocksPerLine;
component.blocksPerColumn = blocksPerColumn;
}
frame.mcusPerLine = mcusPerLine;
frame.mcusPerColumn = mcusPerColumn;
}
var offset = 0, length = data.length;
var jfif = null;
var adobe = null;
var pixels = null;
var frame, resetInterval;
var quantizationTables = [];
var huffmanTablesAC = [], huffmanTablesDC = [];
var fileMarker = readUint16();
if (fileMarker != 0xFFD8) { // SOI (Start of Image)
throw "SOI not found";
}
fileMarker = readUint16();
while (fileMarker != 0xFFD9) { // EOI (End of image)
var i, j, l;
switch (fileMarker) {
case 0xFFE0: // APP0 (Application Specific)
case 0xFFE1: // APP1
case 0xFFE2: // APP2
case 0xFFE3: // APP3
case 0xFFE4: // APP4
case 0xFFE5: // APP5
case 0xFFE6: // APP6
case 0xFFE7: // APP7
case 0xFFE8: // APP8
case 0xFFE9: // APP9
case 0xFFEA: // APP10
case 0xFFEB: // APP11
case 0xFFEC: // APP12
case 0xFFED: // APP13
case 0xFFEE: // APP14
case 0xFFEF: // APP15
case 0xFFFE: // COM (Comment)
var appData = readDataBlock();
if (fileMarker === 0xFFE0) {
if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 &&
appData[3] === 0x46 && appData[4] === 0) { // 'JFIF\x00'
jfif = {
version: {major: appData[5], minor: appData[6]},
densityUnits: appData[7],
xDensity: (appData[8] << 8) | appData[9],
yDensity: (appData[10] << 8) | appData[11],
thumbWidth: appData[12],
thumbHeight: appData[13],
thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
};
}
}
// TODO APP1 - Exif
if (fileMarker === 0xFFEE) {
if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F &&
appData[3] === 0x62 && appData[4] === 0x65 && appData[5] === 0) { // 'Adobe\x00'
adobe = {
version: appData[6],
flags0: (appData[7] << 8) | appData[8],
flags1: (appData[9] << 8) | appData[10],
transformCode: appData[11]
};
}
}
break;
case 0xFFDB: // DQT (Define Quantization Tables)
var quantizationTablesLength = readUint16();
var quantizationTablesEnd = quantizationTablesLength + offset - 2;
while (offset < quantizationTablesEnd) {
var quantizationTableSpec = data[offset++];
var tableData = new Int32Array(64);
if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
for (j = 0; j < 64; j++) {
var z = dctZigZag[j];
tableData[z] = data[offset++];
}
} else if ((quantizationTableSpec >> 4) === 1) { //16 bit
for (j = 0; j < 64; j++) {
var zz = dctZigZag[j];
tableData[zz] = readUint16();
}
} else
throw "DQT: invalid table spec";
quantizationTables[quantizationTableSpec & 15] = tableData;
}
break;
case 0xFFC0: // SOF0 (Start of Frame, Baseline DCT)
case 0xFFC1: // SOF1 (Start of Frame, Extended DCT)
case 0xFFC2: // SOF2 (Start of Frame, Progressive DCT)
if (frame) {
throw "Only single frame JPEGs supported";
}
readUint16(); // skip data length
frame = {};
frame.extended = (fileMarker === 0xFFC1);
frame.progressive = (fileMarker === 0xFFC2);
frame.precision = data[offset++];
frame.scanLines = readUint16();
frame.samplesPerLine = readUint16();
frame.components = [];
frame.componentIds = {};
var componentsCount = data[offset++], componentId;
var maxH = 0, maxV = 0;
for (i = 0; i < componentsCount; i++) {
componentId = data[offset];
var h = data[offset + 1] >> 4;
var v = data[offset + 1] & 15;
if (maxH < h)
maxH = h;
if (maxV < v)
maxV = v;
var qId = data[offset + 2];
l = frame.components.push({
h: h,
v: v,
quantizationTable: quantizationTables[qId],
quantizationTableId: qId,
bitConversion: 255 / ((1 << frame.precision) - 1)
});
frame.componentIds[componentId] = l - 1;
offset += 3;
}
frame.maxH = maxH;
frame.maxV = maxV;
prepareComponents(frame);
break;
case 0xFFC4: // DHT (Define Huffman Tables)
var huffmanLength = readUint16();
for (i = 2; i < huffmanLength; ) {
var huffmanTableSpec = data[offset++];
var codeLengths = new Uint8Array(16);
var codeLengthSum = 0;
for (j = 0; j < 16; j++, offset++)
codeLengthSum += (codeLengths[j] = data[offset]);
var huffmanValues = new Uint8Array(codeLengthSum);
for (j = 0; j < codeLengthSum; j++, offset++)
huffmanValues[j] = data[offset];
i += 17 + codeLengthSum;
((huffmanTableSpec >> 4) === 0 ?
huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] =
buildHuffmanTable(codeLengths, huffmanValues);
}
break;
case 0xFFDD: // DRI (Define Restart Interval)
readUint16(); // skip data length
resetInterval = readUint16();
break;
case 0xFFDA: // SOS (Start of Scan)
var scanLength = readUint16();
var selectorsCount = data[offset++];
var components = [], component;
for (i = 0; i < selectorsCount; i++) {
var componentIndex = frame.componentIds[data[offset++]];
component = frame.components[componentIndex];
var tableSpec = data[offset++];
component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
components.push(component);
}
var spectralStart = data[offset++];
var spectralEnd = data[offset++];
var successiveApproximation = data[offset++];
var processed = decodeScan(data, offset,
frame, components, resetInterval,
spectralStart, spectralEnd,
successiveApproximation >> 4, successiveApproximation & 15);
offset += processed;
break;
default:
if (data[offset - 3] == 0xFF &&
data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
// could be incorrect encoding -- last 0xFF byte of the previous
// block was eaten by the encoder
offset -= 3;
break;
}
throw "unknown JPEG marker " + fileMarker.toString(16);
}
fileMarker = readUint16();
}
this.width = frame.samplesPerLine;
this.height = frame.scanLines;
this.jfif = jfif;
this.adobe = adobe;
this.components = [];
switch (frame.components.length)
{
case 1:
this.colorspace = ColorSpace.Grayscale;
break;
case 3:
if (this.adobe)
this.colorspace = ColorSpace.AdobeRGB;
else
this.colorspace = ColorSpace.RGB;
break;
case 4:
this.colorspace = ColorSpace.CYMK;
break;
default:
this.colorspace = ColorSpace.Unknown;
}
for (var i = 0; i < frame.components.length; i++) {
var component = frame.components[i];
if (!component.quantizationTable && component.quantizationTableId !== null)
component.quantizationTable = quantizationTables[component.quantizationTableId];
this.components.push({
output: buildComponentData(frame, component),
scaleX: component.h / frame.maxH,
scaleY: component.v / frame.maxV,
blocksPerLine: component.blocksPerLine,
blocksPerColumn: component.blocksPerColumn,
bitConversion: component.bitConversion
});
}
},
getData16: function getData16(width, height) {
if (this.components.length !== 1)
throw 'Unsupported color mode';
var scaleX = this.width / width, scaleY = this.height / height;
var component, componentScaleX, componentScaleY;
var x, y, i;
var offset = 0;
var numComponents = this.components.length;
var dataLength = width * height * numComponents;
var data = new Uint16Array(dataLength);
var componentLine;
// lineData is reused for all components. Assume first component is
// the biggest
var lineData = new Uint16Array((this.components[0].blocksPerLine << 3) *
this.components[0].blocksPerColumn * 8);
// First construct image data ...
for (i = 0; i < numComponents; i++) {
component = this.components[i];
var blocksPerLine = component.blocksPerLine;
var blocksPerColumn = component.blocksPerColumn;
var samplesPerLine = blocksPerLine << 3;
var j, k, ll = 0;
var lineOffset = 0;
for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
var scanLine = blockRow << 3;
for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
var bufferOffset = getBlockBufferOffset(component, blockRow, blockCol);
var offset = 0, sample = blockCol << 3;
for (j = 0; j < 8; j++) {
var lineOffset = (scanLine + j) * samplesPerLine;
for (k = 0; k < 8; k++) {
lineData[lineOffset + sample + k] =
component.output[bufferOffset + offset++];
}
}
}
}
componentScaleX = component.scaleX * scaleX;
componentScaleY = component.scaleY * scaleY;
offset = i;
var cx, cy;
var index;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
cy = 0 | (y * componentScaleY);
cx = 0 | (x * componentScaleX);
index = cy * samplesPerLine + cx;
data[offset] = lineData[index];
offset += numComponents;
}
}
}
return data;
},
getData: function getData(width, height) {
var scaleX = this.width / width, scaleY = this.height / height;
var component, componentScaleX, componentScaleY;
var x, y, i;
var offset = 0;
var Y, Cb, Cr, K, C, M, Ye, R, G, B;
var colorTransform;
var numComponents = this.components.length;
var dataLength = width * height * numComponents;
var data = new Uint8Array(dataLength);
var componentLine;
// lineData is reused for all components. Assume first component is
// the biggest
var lineData = new Uint8Array((this.components[0].blocksPerLine << 3) *
this.components[0].blocksPerColumn * 8);
// First construct image data ...
for (i = 0; i < numComponents; i++) {
component = this.components[i];
var blocksPerLine = component.blocksPerLine;
var blocksPerColumn = component.blocksPerColumn;
var samplesPerLine = blocksPerLine << 3;
var j, k, ll = 0;
var lineOffset = 0;
for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
var scanLine = blockRow << 3;
for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
var bufferOffset = getBlockBufferOffset(component, blockRow, blockCol);
var offset = 0, sample = blockCol << 3;
for (j = 0; j < 8; j++) {
var lineOffset = (scanLine + j) * samplesPerLine;
for (k = 0; k < 8; k++) {
lineData[lineOffset + sample + k] =
component.output[bufferOffset + offset++] * component.bitConversion;
}
}
}
}
componentScaleX = component.scaleX * scaleX;
componentScaleY = component.scaleY * scaleY;
offset = i;
var cx, cy;
var index;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
cy = 0 | (y * componentScaleY);
cx = 0 | (x * componentScaleX);
index = cy * samplesPerLine + cx;
data[offset] = lineData[index];
offset += numComponents;
}
}
}
// ... then transform colors, if necessary
switch (numComponents) {
case 1:
case 2:
break;
// no color conversion for one or two compoenents
case 3:
// The default transform for three components is true
colorTransform = true;
// The adobe transform marker overrides any previous setting
if (this.adobe && this.adobe.transformCode)
colorTransform = true;
else if (typeof this.colorTransform !== 'undefined')
colorTransform = !!this.colorTransform;
if (colorTransform) {
for (i = 0; i < dataLength; i += numComponents) {
Y = data[i ];
Cb = data[i + 1];
Cr = data[i + 2];
R = clampToUint8(Y - 179.456 + 1.402 * Cr);
G = clampToUint8(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
B = clampToUint8(Y - 226.816 + 1.772 * Cb);
data[i ] = R;
data[i + 1] = G;
data[i + 2] = B;
}
}
break;
case 4:
if (!this.adobe)
throw 'Unsupported color mode (4 components)';
// The default transform for four components is false
colorTransform = false;
// The adobe transform marker overrides any previous setting
if (this.adobe && this.adobe.transformCode)
colorTransform = true;
else if (typeof this.colorTransform !== 'undefined')
colorTransform = !!this.colorTransform;
if (colorTransform) {
for (i = 0; i < dataLength; i += numComponents) {
Y = data[i];
Cb = data[i + 1];
Cr = data[i + 2];
C = clampToUint8(434.456 - Y - 1.402 * Cr);
M = clampToUint8(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
Y = clampToUint8(481.816 - Y - 1.772 * Cb);
data[i ] = C;
data[i + 1] = M;
data[i + 2] = Y;
// K is unchanged
}
}
break;
default:
throw 'Unsupported color mode';
}
return data;
}
};
return constructor;
})();
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jpeg = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
/*** Constructor ***/
jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || function () {
this.hSamp = 0; // Horizontal sampling factor
this.quantTableSel = 0; // Quantization table destination selector
this.vSamp = 0; // Vertical
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.ComponentSpec;
}
},{}],2:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
/*** Constructor ***/
jpeg.lossless.DataStream = jpeg.lossless.DataStream || function (data, offset, length) {
this.buffer = new DataView(data, offset, length);
this.index = 0;
};
jpeg.lossless.DataStream.prototype.get16 = function () {
var value = this.buffer.getUint16(this.index, false);
this.index += 2;
return value;
};
jpeg.lossless.DataStream.prototype.get8 = function () {
var value = this.buffer.getUint8(this.index);
this.index += 1;
return value;
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.DataStream;
}
},{}],3:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || ((typeof require !== 'undefined') ? require('./huffman-table.js') : null);
jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || ((typeof require !== 'undefined') ? require('./quantization-table.js') : null);
jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || ((typeof require !== 'undefined') ? require('./scan-header.js') : null);
jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || ((typeof require !== 'undefined') ? require('./frame-header.js') : null);
jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
/*** Constructor ***/
jpeg.lossless.Decoder = jpeg.lossless.Decoder || function (buffer, numBytes) {
this.buffer = buffer;
this.frame = new jpeg.lossless.FrameHeader();
this.huffTable = new jpeg.lossless.HuffmanTable();
this.quantTable = new jpeg.lossless.QuantizationTable();
this.scan = new jpeg.lossless.ScanHeader();
this.DU = jpeg.lossless.Utils.createArray(10, 4, 64); // at most 10 data units in a MCU, at most 4 data units in one component
this.HuffTab = jpeg.lossless.Utils.createArray(4, 2, 50 * 256);
this.IDCT_Source = [];
this.nBlock = []; // number of blocks in the i-th Comp in a scan
this.acTab = jpeg.lossless.Utils.createArray(10, 1); // ac HuffTab for the i-th Comp in a scan
this.dcTab = jpeg.lossless.Utils.createArray(10, 1); // dc HuffTab for the i-th Comp in a scan
this.qTab = jpeg.lossless.Utils.createArray(10, 1); // quantization table for the i-th Comp in a scan
this.marker = 0;
this.markerIndex = 0;
this.numComp = 0;
this.restartInterval = 0;
this.selection = 0;
this.xDim = 0;
this.yDim = 0;
this.xLoc = 0;
this.yLoc = 0;
this.numBytes = 0;
this.outputData = null;
this.restarting = false;
this.mask = 0;
if (typeof numBytes !== "undefined") {
this.numBytes = numBytes;
}
};
/*** Static Pseudo-constants ***/
jpeg.lossless.Decoder.IDCT_P = [0, 5, 40, 16, 45, 2, 7, 42, 21, 56, 8, 61, 18, 47, 1, 4, 41, 23, 58, 13, 32, 24, 37, 10, 63, 17, 44, 3, 6, 43, 20,
57, 15, 34, 29, 48, 53, 26, 39, 9, 60, 19, 46, 22, 59, 12, 33, 31, 50, 55, 25, 36, 11, 62, 14, 35, 28, 49, 52, 27, 38, 30, 51, 54];
jpeg.lossless.Decoder.TABLE = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53,
10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63];
jpeg.lossless.Decoder.MAX_HUFFMAN_SUBTREE = 50;
jpeg.lossless.Decoder.MSB = 0x80000000;
jpeg.lossless.Decoder.RESTART_MARKER_BEGIN = 0xFFD0;
jpeg.lossless.Decoder.RESTART_MARKER_END = 0xFFD7;
/*** Prototype Methods ***/
jpeg.lossless.Decoder.prototype.decompress = function (buffer, offset, length) {
return this.decode(buffer, offset, length).buffer;
};
jpeg.lossless.Decoder.prototype.decode = function (buffer, offset, length, numBytes) {
/*jslint bitwise: true */
var current, scanNum = 0, pred = [], i, compN, temp = [], index = [], mcuNum;
if (typeof buffer !== "undefined") {
this.buffer = buffer;
}
if (typeof numBytes !== "undefined") {
this.numBytes = numBytes;
}
this.stream = new jpeg.lossless.DataStream(this.buffer, offset, length);
this.buffer = null;
this.xLoc = 0;
this.yLoc = 0;
current = this.stream.get16();
if (current !== 0xFFD8) { // SOI
throw new Error("Not a JPEG file");
}
current = this.stream.get16();
while ((((current >> 4) !== 0x0FFC) || (current === 0xFFC4))) { // SOF 0~15
switch (current) {
case 0xFFC4: // DHT
this.huffTable.read(this.stream, this.HuffTab);
break;
case 0xFFCC: // DAC
throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
case 0xFFDB:
this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
break;
case 0xFFDD:
this.restartInterval = this.readNumber();
break;
case 0xFFE0:
case 0xFFE1:
case 0xFFE2:
case 0xFFE3:
case 0xFFE4:
case 0xFFE5:
case 0xFFE6:
case 0xFFE7:
case 0xFFE8:
case 0xFFE9:
case 0xFFEA:
case 0xFFEB:
case 0xFFEC:
case 0xFFED:
case 0xFFEE:
case 0xFFEF:
this.readApp();
break;
case 0xFFFE:
this.readComment();
break;
default:
if ((current >> 8) !== 0xFF) {
throw new Error("ERROR: format throw new IOException! (decode)");
}
}
current = this.stream.get16();
}
if ((current < 0xFFC0) || (current > 0xFFC7)) {
throw new Error("ERROR: could not handle arithmetic code!");
}
this.frame.read(this.stream);
current = this.stream.get16();
do {
while (current !== 0x0FFDA) { // SOS
switch (current) {
case 0xFFC4: // DHT
this.huffTable.read(this.stream, this.HuffTab);
break;
case 0xFFCC: // DAC
throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
case 0xFFDB:
this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
break;
case 0xFFDD:
this.restartInterval = this.readNumber();
break;
case 0xFFE0:
case 0xFFE1:
case 0xFFE2:
case 0xFFE3:
case 0xFFE4:
case 0xFFE5:
case 0xFFE6:
case 0xFFE7:
case 0xFFE8:
case 0xFFE9:
case 0xFFEA:
case 0xFFEB:
case 0xFFEC:
case 0xFFED:
case 0xFFEE:
case 0xFFEF:
this.readApp();
break;
case 0xFFFE:
this.readComment();
break;
default:
if ((current >> 8) !== 0xFF) {
throw new Error("ERROR: format throw new IOException! (Parser.decode)");
}
}
current = this.stream.get16();
}
this.precision = this.frame.precision;
this.components = this.frame.components;
if (!this.numBytes) {
this.numBytes = parseInt(Math.ceil(this.precision / 8));
}
if (this.numBytes == 1) {
this.mask = 0xFF;
} else {
this.mask = 0xFFFF;
}
this.scan.read(this.stream);
this.numComp = this.scan.numComp;
this.selection = this.scan.selection;
if (this.numBytes === 1) {
if (this.numComp === 3) {
this.getter = this.getValueRGB;
this.setter = this.setValueRGB;
this.output = this.outputRGB;
} else {
this.getter = this.getValue8;
this.setter = this.setValue8;
this.output = this.outputSingle;
}
} else {
this.getter = this.getValue16;
this.setter = this.setValue16;
this.output = this.outputSingle;
}
switch (this.selection) {
case 2:
this.selector = this.select2;
break;
case 3:
this.selector = this.select3;
break;
case 4:
this.selector = this.select4;
break;
case 5:
this.selector = this.select5;
break;
case 6:
this.selector = this.select6;
break;
case 7:
this.selector = this.select7;
break;
default:
this.selector = this.select1;
break;
}
this.scanComps = this.scan.components;
this.quantTables = this.quantTable.quantTables;
for (i = 0; i < this.numComp; i+=1) {
compN = this.scanComps[i].scanCompSel;
this.qTab[i] = this.quantTables[this.components[compN].quantTableSel];
this.nBlock[i] = this.components[compN].vSamp * this.components[compN].hSamp;
this.dcTab[i] = this.HuffTab[this.scanComps[i].dcTabSel][0];
this.acTab[i] = this.HuffTab[this.scanComps[i].acTabSel][1];
}
this.xDim = this.frame.dimX;
this.yDim = this.frame.dimY;
this.outputData = new DataView(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
scanNum+=1;
while (true) { // Decode one scan
temp[0] = 0;
index[0] = 0;
for (i = 0; i < 10; i+=1) {
pred[i] = (1 << (this.precision - 1));
}
if (this.restartInterval === 0) {
current = this.decodeUnit(pred, temp, index);
while ((current === 0) && ((this.xLoc < this.xDim) && (this.yLoc < this.yDim))) {
this.output(pred);
current = this.decodeUnit(pred, temp, index);
}
break; //current=MARKER
}
for (mcuNum = 0; mcuNum < this.restartInterval; mcuNum+=1) {
this.restarting = (mcuNum == 0);
current = this.decodeUnit(pred, temp, index);
this.output(pred);
if (current !== 0) {
break;
}
}
if (current === 0) {
if (this.markerIndex !== 0) {
current = (0xFF00 | this.marker);
this.markerIndex = 0;
} else {
current = this.stream.get16();
}
}
if (!((current >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN) &&
(current <= jpeg.lossless.Decoder.RESTART_MARKER_END))) {
break; //current=MARKER
}
}
if ((current === 0xFFDC) && (scanNum === 1)) { //DNL
this.readNumber();
current = this.stream.get16();
}
} while ((current !== 0xFFD9) && ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) && (scanNum === 0));
return this.outputData;
};
jpeg.lossless.Decoder.prototype.decodeUnit = function (prev, temp, index) {
if (this.numComp == 1) {
return this.decodeSingle(prev, temp, index);
} else if (this.numComp == 3) {
return this.decodeRGB(prev, temp, index);
} else {
return -1;
}
};
jpeg.lossless.Decoder.prototype.select1 = function (compOffset) {
return this.getPreviousX(compOffset);
};
jpeg.lossless.Decoder.prototype.select2 = function (compOffset) {
return this.getPreviousY(compOffset);
};
jpeg.lossless.Decoder.prototype.select3 = function (compOffset) {
return this.getPreviousXY(compOffset);
};
jpeg.lossless.Decoder.prototype.select4 = function (compOffset) {
return (this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) - this.getPreviousXY(compOffset);
};
jpeg.lossless.Decoder.prototype.select5 = function (compOffset) {
return this.getPreviousX(compOffset) + ((this.getPreviousY(compOffset) - this.getPreviousXY(compOffset)) >> 1);
};
jpeg.lossless.Decoder.prototype.select6 = function (compOffset) {
return this.getPreviousY(compOffset) + ((this.getPreviousX(compOffset) - this.getPreviousXY(compOffset)) >> 1);
};
jpeg.lossless.Decoder.prototype.select7 = function (compOffset) {
return ((this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) / 2);
};
jpeg.lossless.Decoder.prototype.decodeRGB = function (prev, temp, index) {
/*jslint bitwise: true */
var value, actab, dctab, qtab, ctrC, i, k, j;
prev[0] = this.selector(0);
prev[1] = this.selector(1);
prev[2] = this.selector(2);
for (ctrC = 0; ctrC < this.numComp; ctrC+=1) {
qtab = this.qTab[ctrC];
actab = this.acTab[ctrC];
dctab = this.dcTab[ctrC];
for (i = 0; i < this.nBlock[ctrC]; i+=1) {
for (k = 0; k < this.IDCT_Source.length; k+=1) {
this.IDCT_Source[k] = 0;
}
value = this.getHuffmanValue(dctab, temp, index);
if (value >= 0xFF00) {
return value;
}
prev[ctrC] = this.IDCT_Source[0] = prev[ctrC] + this.getn(index, value, temp, index);
this.IDCT_Source[0] *= qtab[0];
for (j = 1; j < 64; j+=1) {
value = this.getHuffmanValue(actab, temp, index);
if (value >= 0xFF00) {
return value;
}
j += (value >> 4);
if ((value & 0x0F) === 0) {
if ((value >> 4) === 0) {
break;
}
} else {
this.IDCT_Source[jpeg.lossless.Decoder.IDCT_P[j]] = this.getn(index, value & 0x0F, temp, index) * qtab[j];
}
}
}
}
return 0;
};
jpeg.lossless.Decoder.prototype.decodeSingle = function (prev, temp, index) {
/*jslint bitwise: true */
var value, i, n, nRestart;
if (this.restarting) {
this.restarting = false;
prev[0] = (1 << (this.frame.precision - 1));
} else {
prev[0] = this.selector();
}
for (i = 0; i < this.nBlock[0]; i+=1) {
value = this.getHuffmanValue(this.dcTab[0], temp, index);
if (value >= 0xFF00) {
return value;
}
n = this.getn(prev, value, temp, index);
nRestart = (n >> 8);
if ((nRestart >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN) && (nRestart <= jpeg.lossless.Decoder.RESTART_MARKER_END)) {
return nRestart;
}
prev[0] += n;
}
return 0;
};
// Huffman table for fast search: (HuffTab) 8-bit Look up table 2-layer search architecture, 1st-layer represent 256 node (8 bits) if codeword-length > 8
// bits, then the entry of 1st-layer = (# of 2nd-layer table) | MSB and it is stored in the 2nd-layer Size of tables in each layer are 256.
// HuffTab[*][*][0-256] is always the only 1st-layer table.
//
// An entry can be: (1) (# of 2nd-layer table) | MSB , for code length > 8 in 1st-layer (2) (Code length) << 8 | HuffVal
//
// HuffmanValue(table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
// ):
// return: Huffman Value of table
// 0xFF?? if it receives a MARKER
// Parameter: table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
// temp temp storage for remainded bits
// index index to bit of temp
// in FILE pointer
// Effect:
// temp store new remainded bits
// index change to new index
// in change to new position
// NOTE:
// Initial by temp=0; index=0;
// NOTE: (explain temp and index)
// temp: is always in the form at calling time or returning time
// | byte 4 | byte 3 | byte 2 | byte 1 |
// | 0 | 0 | 00000000 | 00000??? | if not a MARKER
// ^index=3 (from 0 to 15)
// 321
// NOTE (marker and marker_index):
// If get a MARKER from 'in', marker=the low-byte of the MARKER
// and marker_index=9
// If marker_index=9 then index is always > 8, or HuffmanValue()
// will not be called
jpeg.lossless.Decoder.prototype.getHuffmanValue = function (table, temp, index) {
/*jslint bitwise: true */
var code, input, mask;
mask = 0xFFFF;
if (index[0] < 8) {
temp[0] <<= 8;
input = this.stream.get8();
if (input === 0xFF) {
this.marker = this.stream.get8();
if (this.marker !== 0) {
this.markerIndex = 9;
}
}
temp[0] |= input;
} else {
index[0] -= 8;
}
code = table[temp[0] >> index[0]];
if ((code & jpeg.lossless.Decoder.MSB) !== 0) {
if (this.markerIndex !== 0) {
this.markerIndex = 0;
return 0xFF00 | this.marker;
}
temp[0] &= (mask >> (16 - index[0]));
temp[0] <<= 8;
input = this.stream.get8();
if (input === 0xFF) {
this.marker = this.stream.get8();
if (this.marker !== 0) {
this.markerIndex = 9;
}
}
temp[0] |= input;
code = table[((code & 0xFF) * 256) + (temp[0] >> index[0])];
index[0] += 8;
}
index[0] += 8 - (code >> 8);
if (index[0] < 0) {
throw new Error("index=" + index[0] + " temp=" + temp[0] + " code=" + code + " in HuffmanValue()");
}
if (index[0] < this.markerIndex) {
this.markerIndex = 0;
return 0xFF00 | this.marker;
}
temp[0] &= (mask >> (16 - index[0]));
return code & 0xFF;
};
jpeg.lossless.Decoder.prototype.getn = function (PRED, n, temp, index) {
/*jslint bitwise: true */
var result, one, n_one, mask, input;
one = 1;
n_one = -1;
mask = 0xFFFF;
if (n === 0) {
return 0;
}
if (n === 16) {
if (PRED[0] >= 0) {
return -32768;
} else {
return 32768;
}
}
index[0] -= n;
if (index[0] >= 0) {
if ((index[0] < this.markerIndex) && !this.isLastPixel()) { // this was corrupting the last pixel in some cases
this.markerIndex = 0;
return (0xFF00 | this.marker) << 8;
}
result = temp[0] >> index[0];
temp[0] &= (mask >> (16 - index[0]));
} else {
temp[0] <<= 8;
input = this.stream.get8();
if (input === 0xFF) {
this.marker = this.stream.get8();
if (this.marker !== 0) {
this.markerIndex = 9;
}
}
temp[0] |= input;
index[0] += 8;
if (index[0] < 0) {
if (this.markerIndex !== 0) {
this.markerIndex = 0;
return (0xFF00 | this.marker) << 8;
}
temp[0] <<= 8;
input = this.stream.get8();
if (input === 0xFF) {
this.marker = this.stream.get8();
if (this.marker !== 0) {
this.markerIndex = 9;
}
}
temp[0] |= input;
index[0] += 8;
}
if (index[0] < 0) {
throw new Error("index=" + index[0] + " in getn()");
}
if (index[0] < this.markerIndex) {
this.markerIndex = 0;
return (0xFF00 | this.marker) << 8;
}
result = temp[0] >> index[0];
temp[0] &= (mask >> (16 - index[0]));
}
if (result < (one << (n - 1))) {
result += (n_one << n) + 1;
}
return result;
};
jpeg.lossless.Decoder.prototype.getPreviousX = function (compOffset) {
/*jslint bitwise: true */
if (this.xLoc > 0) {
return this.getter((((this.yLoc * this.xDim) + this.xLoc) - 1), compOffset);
} else if (this.yLoc > 0) {
return this.getPreviousY(compOffset);
} else {
return (1 << (this.frame.precision - 1));
}
};
jpeg.lossless.Decoder.prototype.getPreviousXY = function (compOffset) {
/*jslint bitwise: true */
if ((this.xLoc > 0) && (this.yLoc > 0)) {
return this.getter(((((this.yLoc - 1) * this.xDim) + this.xLoc) - 1), compOffset);
} else {
return this.getPreviousY(compOffset);
}
};
jpeg.lossless.Decoder.prototype.getPreviousY = function (compOffset) {
/*jslint bitwise: true */
if (this.yLoc > 0) {
return this.getter((((this.yLoc - 1) * this.xDim) + this.xLoc), compOffset);
} else {
return this.getPreviousX(compOffset);
}
};
jpeg.lossless.Decoder.prototype.isLastPixel = function () {
return (this.xLoc === (this.xDim - 1)) && (this.yLoc === (this.yDim - 1));
};
jpeg.lossless.Decoder.prototype.outputSingle = function (PRED) {
if ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) {
this.setter((((this.yLoc * this.xDim) + this.xLoc)), this.mask & PRED[0]);
this.xLoc+=1;
if (this.xLoc >= this.xDim) {
this.yLoc+=1;
this.xLoc = 0;
}
}
};
jpeg.lossless.Decoder.prototype.outputRGB = function (PRED) {
var offset = ((this.yLoc * this.xDim) + this.xLoc);
if ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) {
this.setter(offset, PRED[0], 0);
this.setter(offset, PRED[1], 1);
this.setter(offset, PRED[2], 2);
this.xLoc+=1;
if (this.xLoc >= this.xDim) {
this.yLoc+=1;
this.xLoc = 0;
}
}
};
jpeg.lossless.Decoder.prototype.setValue16 = function (index, val) {
this.outputData.setInt16(index * 2, val, true);
};
jpeg.lossless.Decoder.prototype.getValue16 = function (index) {
return this.outputData.getInt16(index * 2, true) & this.mask;
};
jpeg.lossless.Decoder.prototype.setValue8 = function (index, val) {
this.outputData.setInt8(index, val);
};
jpeg.lossless.Decoder.prototype.getValue8 = function (index) {
return this.outputData.getInt8(index) & this.mask;
};
jpeg.lossless.Decoder.prototype.setValueRGB = function (index, val, compOffset) {
this.outputData.setUint8(index * 3 + compOffset, val);
};
jpeg.lossless.Decoder.prototype.getValueRGB = function (index, compOffset) {
return this.outputData.getUint8(index * 3 + compOffset);
};
jpeg.lossless.Decoder.prototype.readApp = function() {
var count = 0, length = this.stream.get16();
count += 2;
while (count < length) {
this.stream.get8();
count+=1;
}
return length;
};
jpeg.lossless.Decoder.prototype.readComment = function () {
var sb = "", count = 0, length;
length = this.stream.get16();
count += 2;
while (count < length) {
sb += this.stream.get8();
count+=1;
}
return sb;
};
jpeg.lossless.Decoder.prototype.readNumber = function() {
var Ld = this.stream.get16();
if (Ld !== 4) {
throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");
}
return this.stream.get16();
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.Decoder;
}
},{"./data-stream.js":2,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-header.js":9,"./utils.js":10}],4:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || ((typeof require !== 'undefined') ? require('./component-spec.js') : null);
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
/*** Constructor ***/
jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || function () {
this.components = []; // Components
this.dimX = 0; // Number of samples per line
this.dimY = 0; // Number of lines
this.numComp = 0; // Number of component in the frame
this.precision = 0; // Sample Precision (from the original image)
};
/*** Prototype Methods ***/
jpeg.lossless.FrameHeader.prototype.read = function (data) {
/*jslint bitwise: true */
var count = 0, length, i, c, temp;
length = data.get16();
count += 2;
this.precision = data.get8();
count+=1;
this.dimY = data.get16();
count += 2;
this.dimX = data.get16();
count += 2;
this.numComp = data.get8();
count+=1;
for (i = 1; i <= this.numComp; i+=1) {
if (count > length) {
throw new Error("ERROR: frame format error");
}
c = data.get8();
count+=1;
if (count >= length) {
throw new Error("ERROR: frame format error [c>=Lf]");
}
temp = data.get8();
count+=1;
if (!this.components[c]) {
this.components[c] = new jpeg.lossless.ComponentSpec();
}
this.components[c].hSamp = temp >> 4;
this.components[c].vSamp = temp & 0x0F;
this.components[c].quantTableSel = data.get8();
count+=1;
}
if (count !== length) {
throw new Error("ERROR: frame format error [Lf!=count]");
}
return 1;
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.FrameHeader;
}
},{"./component-spec.js":1,"./data-stream.js":2}],5:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
/*** Constructor ***/
jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || function () {
this.l = jpeg.lossless.Utils.createArray(4, 2, 16);
this.th = [];
this.v = jpeg.lossless.Utils.createArray(4, 2, 16, 200);
this.tc = jpeg.lossless.Utils.createArray(4, 2);
this.tc[0][0] = 0;
this.tc[1][0] = 0;
this.tc[2][0] = 0;
this.tc[3][0] = 0;
this.tc[0][1] = 0;
this.tc[1][1] = 0;
this.tc[2][1] = 0;
this.tc[3][1] = 0;
this.th[0] = 0;
this.th[1] = 0;
this.th[2] = 0;
this.th[3] = 0;
};
/*** Static Pseudo-constants ***/
jpeg.lossless.HuffmanTable.MSB = 0x80000000;
/*** Prototype Methods ***/
jpeg.lossless.HuffmanTable.prototype.read = function(data, HuffTab) {
/*jslint bitwise: true */
var count = 0, length, temp, t, c, i, j;
length = data.get16();
count += 2;
while (count < length) {
temp = data.get8();
count+=1;
t = temp & 0x0F;
if (t > 3) {
throw new Error("ERROR: Huffman table ID > 3");
}
c = temp >> 4;
if (c > 2) {
throw new Error("ERROR: Huffman table [Table class > 2 ]");
}
this.th[t] = 1;
this.tc[t][c] = 1;
for (i = 0; i < 16; i+=1) {
this.l[t][c][i] = data.get8();
count+=1;
}
for (i = 0; i < 16; i+=1) {
for (j = 0; j < this.l[t][c][i]; j+=1) {
if (count > length) {
throw new Error("ERROR: Huffman table format error [count>Lh]");
}
this.v[t][c][i][j] = data.get8();
count+=1;
}
}
}
if (count !== length) {
throw new Error("ERROR: Huffman table format error [count!=Lf]");
}
for (i = 0; i < 4; i+=1) {
for (j = 0; j < 2; j+=1) {
if (this.tc[i][j] !== 0) {
this.buildHuffTable(HuffTab[i][j], this.l[i][j], this.v[i][j]);
}
}
}
return 1;
};
// Build_HuffTab()
// Parameter: t table ID
// c table class ( 0 for DC, 1 for AC )
// L[i] # of codewords which length is i
// V[i][j] Huffman Value (length=i)
// Effect:
// build up HuffTab[t][c] using L and V.
jpeg.lossless.HuffmanTable.prototype.buildHuffTable = function(tab, L, V) {
/*jslint bitwise: true */
var currentTable, temp, k, i, j, n;
temp = 256;
k = 0;
for (i = 0; i < 8; i+=1) { // i+1 is Code length
for (j = 0; j < L[i]; j+=1) {
for (n = 0; n < (temp >> (i + 1)); n+=1) {
tab[k] = V[i][j] | ((i + 1) << 8);
k+=1;
}
}
}
for (i = 1; k < 256; i+=1, k+=1) {
tab[k] = i | jpeg.lossless.HuffmanTable.MSB;
}
currentTable = 1;
k = 0;
for (i = 8; i < 16; i+=1) { // i+1 is Code length
for (j = 0; j < L[i]; j+=1) {
for (n = 0; n < (temp >> (i - 7)); n+=1) {
tab[(currentTable * 256) + k] = V[i][j] | ((i + 1) << 8);
k+=1;
}
if (k >= 256) {
if (k > 256) {
throw new Error("ERROR: Huffman table error(1)!");
}
k = 0;
currentTable+=1;
}
}
}
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.HuffmanTable;
}
},{"./data-stream.js":2,"./utils.js":10}],6:[function(require,module,exports){
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ****/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || ((typeof require !== 'undefined') ? require('./component-spec.js') : null);
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
jpeg.lossless.Decoder = jpeg.lossless.Decoder || ((typeof require !== 'undefined') ? require('./decoder.js') : null);
jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || ((typeof require !== 'undefined') ? require('./frame-header.js') : null);
jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || ((typeof require !== 'undefined') ? require('./huffman-table.js') : null);
jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || ((typeof require !== 'undefined') ? require('./quantization-table.js') : null);
jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || ((typeof require !== 'undefined') ? require('./scan-component.js') : null);
jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || ((typeof require !== 'undefined') ? require('./scan-header.js') : null);
jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg;
}
},{"./component-spec.js":1,"./data-stream.js":2,"./decoder.js":3,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-component.js":8,"./scan-header.js":9,"./utils.js":10}],7:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
/*** Constructor ***/
jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || function () {
this.precision = []; // Quantization precision 8 or 16
this.tq = []; // 1: this table is presented
this.quantTables = jpeg.lossless.Utils.createArray(4, 64); // Tables
this.tq[0] = 0;
this.tq[1] = 0;
this.tq[2] = 0;
this.tq[3] = 0;
};
/*** Static Methods ***/
jpeg.lossless.QuantizationTable.enhanceQuantizationTable = function(qtab, table) {
/*jslint bitwise: true */
var i;
for (i = 0; i < 8; i+=1) {
qtab[table[(0 * 8) + i]] *= 90;
qtab[table[(4 * 8) + i]] *= 90;
qtab[table[(2 * 8) + i]] *= 118;
qtab[table[(6 * 8) + i]] *= 49;
qtab[table[(5 * 8) + i]] *= 71;
qtab[table[(1 * 8) + i]] *= 126;
qtab[table[(7 * 8) + i]] *= 25;
qtab[table[(3 * 8) + i]] *= 106;
}
for (i = 0; i < 8; i+=1) {
qtab[table[0 + (8 * i)]] *= 90;
qtab[table[4 + (8 * i)]] *= 90;
qtab[table[2 + (8 * i)]] *= 118;
qtab[table[6 + (8 * i)]] *= 49;
qtab[table[5 + (8 * i)]] *= 71;
qtab[table[1 + (8 * i)]] *= 126;
qtab[table[7 + (8 * i)]] *= 25;
qtab[table[3 + (8 * i)]] *= 106;
}
for (i = 0; i < 64; i+=1) {
qtab[i] >>= 6;
}
};
/*** Prototype Methods ***/
jpeg.lossless.QuantizationTable.prototype.read = function (data, table) {
/*jslint bitwise: true */
var count = 0, length, temp, t, i;
length = data.get16();
count += 2;
while (count < length) {
temp = data.get8();
count+=1;
t = temp & 0x0F;
if (t > 3) {
throw new Error("ERROR: Quantization table ID > 3");
}
this.precision[t] = temp >> 4;
if (this.precision[t] === 0) {
this.precision[t] = 8;
} else if (this.precision[t] === 1) {
this.precision[t] = 16;
} else {
throw new Error("ERROR: Quantization table precision error");
}
this.tq[t] = 1;
if (this.precision[t] === 8) {
for (i = 0; i < 64; i+=1) {
if (count > length) {
throw new Error("ERROR: Quantization table format error");
}
this.quantTables[t][i] = data.get8();
count+=1;
}
jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
} else {
for (i = 0; i < 64; i+=1) {
if (count > length) {
throw new Error("ERROR: Quantization table format error");
}
this.quantTables[t][i] = data.get16();
count += 2;
}
jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
}
}
if (count !== length) {
throw new Error("ERROR: Quantization table error [count!=Lq]");
}
return 1;
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.QuantizationTable;
}
},{"./data-stream.js":2,"./utils.js":10}],8:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
/*** Constructor ***/
jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || function () {
this.acTabSel = 0; // AC table selector
this.dcTabSel = 0; // DC table selector
this.scanCompSel = 0; // Scan component selector
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.ScanComponent;
}
},{}],9:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || ((typeof require !== 'undefined') ? require('./scan-component.js') : null);
/*** Constructor ***/
jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || function () {
this.ah = 0;
this.al = 0;
this.numComp = 0; // Number of components in the scan
this.selection = 0; // Start of spectral or predictor selection
this.spectralEnd = 0; // End of spectral selection
this.components = [];
};
/*** Prototype Methods ***/
jpeg.lossless.ScanHeader.prototype.read = function(data) {
/*jslint bitwise: true */
var count = 0, length, i, temp;
length = data.get16();
count += 2;
this.numComp = data.get8();
count+=1;
for (i = 0; i < this.numComp; i+=1) {
this.components[i] = new jpeg.lossless.ScanComponent();
if (count > length) {
throw new Error("ERROR: scan header format error");
}
this.components[i].scanCompSel = data.get8();
count+=1;
temp = data.get8();
count+=1;
this.components[i].dcTabSel = (temp >> 4);
this.components[i].acTabSel = (temp & 0x0F);
}
this.selection = data.get8();
count+=1;
this.spectralEnd = data.get8();
count+=1;
temp = data.get8();
this.ah = (temp >> 4);
this.al = (temp & 0x0F);
count+=1;
if (count !== length) {
throw new Error("ERROR: scan header format error [count!=Ns]");
}
return 1;
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.ScanHeader;
}
},{"./data-stream.js":2,"./scan-component.js":8}],10:[function(require,module,exports){
/*
* Copyright (C) 2015 Michael Martinez
* Changes: Added support for selection values 2-7, fixed minor bugs &
* warnings, split into multiple class files, and general clean up.
*
* 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
*/
/*
* Copyright (C) Helmut Dersch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*jslint browser: true, node: true */
/*global require, module */
"use strict";
/*** Imports ***/
var jpeg = jpeg || {};
jpeg.lossless = jpeg.lossless || {};
/*** Constructor ***/
jpeg.lossless.Utils = jpeg.lossless.Utils || {};
/*** Static methods ***/
// http://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript
jpeg.lossless.Utils.createArray = function (length) {
var arr = new Array(length || 0),
i = length;
if (arguments.length > 1) {
var args = Array.prototype.slice.call(arguments, 1);
while(i--) arr[length-1 - i] = jpeg.lossless.Utils.createArray.apply(this, args);
}
return arr;
};
// http://stackoverflow.com/questions/18638900/javascript-crc32
jpeg.lossless.Utils.makeCRCTable = function(){
var c;
var crcTable = [];
for(var n =0; n < 256; n++){
c = n;
for(var k =0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
crcTable[n] = c;
}
return crcTable;
};
jpeg.lossless.Utils.crc32 = function(dataView) {
var crcTable = jpeg.lossless.Utils.crcTable || (jpeg.lossless.Utils.crcTable = jpeg.lossless.Utils.makeCRCTable());
var crc = 0 ^ (-1);
for (var i = 0; i < dataView.byteLength; i++ ) {
crc = (crc >>> 8) ^ crcTable[(crc ^ dataView.getUint8(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
};
/*** Exports ***/
var moduleType = typeof module;
if ((moduleType !== 'undefined') && module.exports) {
module.exports = jpeg.lossless.Utils;
}
},{}]},{},[6])(6)
});
/*! image-JPEG2000 - v0.3.1 - 2015-08-26 | https://github.com/OHIF/image-JPEG2000 */
"use strict";function info(a){PDFJS.verbosity>=PDFJS.VERBOSITY_LEVELS.infos&&console.log("Info: "+a)}function warn(a){PDFJS.verbosity>=PDFJS.VERBOSITY_LEVELS.warnings&&console.log("Warning: "+a)}function error(a){if(arguments.length>1){var b=["Error:"];b.push.apply(b,arguments),console.log.apply(console,b),a=[].join.call(arguments," ")}else console.log("Error: "+a);throw console.log(backtrace()),UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown),new Error(a)}function backtrace(){try{throw new Error}catch(a){return a.stack?a.stack.split("\n").slice(2).join("\n"):""}}function assert(a,b){a||error(b)}function combineUrl(a,b){if(!b)return a;if(/^[a-z][a-z0-9+\-.]*:/i.test(b))return b;var c;if("/"===b.charAt(0))return c=a.indexOf("://"),"/"===b.charAt(1)?++c:c=a.indexOf("/",c+3),a.substring(0,c)+b;var d=a.length;c=a.lastIndexOf("#"),d=c>=0?c:d,c=a.lastIndexOf("?",d),d=c>=0?c:d;var e=a.lastIndexOf("/",d);return a.substring(0,e+1)+b}function isValidUrl(a,b){if(!a)return!1;var c=/^[a-z][a-z0-9+\-.]*(?=:)/i.exec(a);if(!c)return b;switch(c=c[0].toLowerCase()){case"http":case"https":case"ftp":case"mailto":case"tel":return!0;default:return!1}}function shadow(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!1}),c}function bytesToString(a){assert(null!==a&&"object"==typeof a&&void 0!==a.length,"Invalid argument for bytesToString");var b=a.length,c=8192;if(c>b)return String.fromCharCode.apply(null,a);for(var d=[],e=0;b>e;e+=c){var f=Math.min(e+c,b),g=a.subarray(e,f);d.push(String.fromCharCode.apply(null,g))}return d.join("")}function stringToBytes(a){assert("string"==typeof a,"Invalid argument for stringToBytes");for(var b=a.length,c=new Uint8Array(b),d=0;b>d;++d)c[d]=255&a.charCodeAt(d);return c}function string32(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)}function log2(a){for(var b=1,c=0;a>b;)b<<=1,c++;return c}function readInt8(a,b){return a[b]<<24>>24}function readUint16(a,b){return a[b]<<8|a[b+1]}function readUint32(a,b){return(a[b]<<24|a[b+1]<<16|a[b+2]<<8|a[b+3])>>>0}function isLittleEndian(){var a=new Uint8Array(2);a[0]=1;var b=new Uint16Array(a.buffer);return 1===b[0]}function hasCanvasTypedArrays(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d"),c=b.createImageData(1,1);return"undefined"!=typeof c.data.buffer}function stringToPDFString(a){var b,c=a.length,d=[];if("þ"===a[0]&&"ÿ"===a[1])for(b=2;c>b;b+=2)d.push(String.fromCharCode(a.charCodeAt(b)<<8|a.charCodeAt(b+1)));else for(b=0;c>b;++b){var e=PDFStringTranslateTable[a.charCodeAt(b)];d.push(e?String.fromCharCode(e):a.charAt(b))}return d.join("")}function stringToUTF8String(a){return decodeURIComponent(escape(a))}function isEmptyObj(a){for(var b in a)return!1;return!0}function isBool(a){return"boolean"==typeof a}function isInt(a){return"number"==typeof a&&(0|a)===a}function isNum(a){return"number"==typeof a}function isString(a){return"string"==typeof a}function isNull(a){return null===a}function isName(a){return a instanceof Name}function isCmd(a,b){return a instanceof Cmd&&(void 0===b||a.cmd===b)}function isDict(a,b){if(!(a instanceof Dict))return!1;if(!b)return!0;var c=a.get("Type");return isName(c)&&c.name===b}function isArray(a){return a instanceof Array}function isStream(a){return"object"==typeof a&&null!==a&&void 0!==a.getBytes}function isArrayBuffer(a){return"object"==typeof a&&null!==a&&void 0!==a.byteLength}function isRef(a){return a instanceof Ref}function createPromiseCapability(){var a={};return a.promise=new Promise(function(b,c){a.resolve=b,a.reject=c}),a}function MessageHandler(a,b){this.name=a,this.comObj=b,this.callbackIndex=1,this.postMessageTransfers=!0;var c=this.callbacksCapabilities={},d=this.actionHandler={};d.console_log=[function(a){console.log.apply(console,a)}],d.console_error=[function(a){console.error.apply(console,a)}],d._unsupported_feature=[function(a){UnsupportedManager.notify(a)}],b.onmessage=function(a){var e=a.data;if(e.isReply){var f=e.callbackId;if(e.callbackId in c){var g=c[f];delete c[f],"error"in e?g.reject(e.error):g.resolve(e.data
qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];return a.prototype={byteIn:function(){var a=this.data,b=this.bp;if(255===a[b]){var c=a[b+1];c>143?(this.clow+=65280,this.ct=8):(b++,this.clow+=a[b]<<9,this.ct=7,this.bp=b)}else b++,this.clow+=b<this.dataEnd?a[b]<<8:65280,this.ct=8,this.bp=b;this.clow>65535&&(this.chigh+=this.clow>>16,this.clow&=65535)},readBit:function(a,c){var d,e=a[c]>>1,f=1&a[c],g=b[e],h=g.qe,i=this.a-h;if(this.chigh<h)h>i?(i=h,d=f,e=g.nmps):(i=h,d=1^f,1===g.switchFlag&&(f=d),e=g.nlps);else{if(this.chigh-=h,0!==(32768&i))return this.a=i,f;h>i?(d=1^f,1===g.switchFlag&&(f=d),e=g.nlps):(d=f,e=g.nmps)}do 0===this.ct&&this.byteIn(),i<<=1,this.chigh=this.chigh<<1&65535|this.clow>>15&1,this.clow=this.clow<<1&65535,this.ct--;while(0===(32768&i));return this.a=i,a[c]=e<<1|f,d}},a}(),globalScope="undefined"==typeof window?this:window,isWorker="undefined"==typeof window,FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0],TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},AnnotationType={WIDGET:1,TEXT:2,LINK:3},StreamType={UNKNOWN:0,FLATE:1,LZW:2,DCT:3,JPX:4,JBIG:5,A85:6,AHX:7,CCF:8,RL:9},FontType={UNKNOWN:0,TYPE1:1,TYPE1C:2,CIDFONTTYPE0:3,CIDFONTTYPE0C:4,TRUETYPE:5,CIDFONTTYPE2:6,TYPE3:7,OPENTYPE:8,TYPE0:9,MMTYPE1:10};globalScope.PDFJS||(globalScope.PDFJS={}),globalScope.PDFJS.pdfBug=!1,PDFJS.VERBOSITY_LEVELS={errors:0,warnings:1,infos:5};var OPS=PDFJS.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},UNSUPPORTED_FEATURES=PDFJS.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font"},UnsupportedManager=PDFJS.UnsupportedManager=function(){var a=[];return{listen:function(b){a.push(b)},notif
/*! OpenJPEG.js - v0.2.0 - 2016-06-07 | (c) 2016 Chris Hafey | https://github.com/chafey/openjpeg */
var OpenJPEG = function(Module) {
Module = Module || {};
var Module;if(!Module)Module=(typeof OpenJPEG!=="undefined"?OpenJPEG:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){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:{if(type[type.length-1]==="*"){return Runtime.QUANTUM
var asm=(function(global,env,buffer) {
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=0;var o=0;var p=0;var q=0;var r=global.NaN,s=global.Infinity;var t=0,u=0,v=0,w=0,x=0.0,y=0,z=0,A=0,B=0.0;var C=0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=global.Math.floor;var N=global.Math.abs;var O=global.Math.sqrt;var P=global.Math.pow;var Q=global.Math.cos;var R=global.Math.sin;var S=global.Math.tan;var T=global.Math.acos;var U=global.Math.asin;var V=global.Math.atan;var W=global.Math.atan2;var X=global.Math.exp;var Y=global.Math.log;var Z=global.Math.ceil;var _=global.Math.imul;var $=global.Math.min;var aa=global.Math.clz32;var ba=env.abort;var ca=env.assert;var da=env.invoke_iiiiiiii;var ea=env.invoke_iiii;var fa=env.invoke_di;var ga=env.invoke_vi;var ha=env.invoke_vii;var ia=env.invoke_iiiiiii;var ja=env.invoke_ii;var ka=env.invoke_viii;var la=env.invoke_iiiiiiiiiiii;var ma=env.invoke_iiiii;var na=env.invoke_iii;var oa=env.invoke_iiiiii;var pa=env.invoke_viiii;var qa=env._pthread_cleanup_pop;var ra=env.___syscall221;var sa=env._llvm_pow_f64;var ta=env._abort;var ua=env._pthread_cleanup_push;var va=env._ceilf;var wa=env._emscripten_set_main_loop_timing;var xa=env._sbrk;var ya=env._emscripten_memcpy_big;var za=env._sysconf;var Aa=env.___setErrNo;var Ba=env._floor;var Ca=env._pthread_self;var Da=env._sqrt;var Ea=env._floorf;var Fa=env.___syscall54;var Ga=env.___unlock;var Ha=env._emscripten_set_main_loop;var Ia=env.___lock;var Ja=env.___syscall6;var Ka=env.___syscall5;var La=env._time;var Ma=env.___syscall140;var Na=env.___syscall145;var Oa=env.___syscall146;var Pa=0.0;
// EMSCRIPTEN_START_FUNCS
function fe(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+48|0;f=m+32|0;l=m+28|0;c[f>>2]=d;if((c[a+8>>2]|0)==16)k=(c[a+164>>2]|0)+((c[a+200>>2]|0)*5640|0)|0;else k=c[a+12>>2]|0;g=(c[a+80>>2]|0)+16|0;h=(c[g>>2]|0)>>>0<257?1:2;j=h+1|0;if(j>>>0>d>>>0){Ub(e,1,14585,m)|0;e=0;i=m;return e|0}c[f>>2]=d-j;qb(b,l,h);d=c[l>>2]|0;if(d>>>0>=(c[g>>2]|0)>>>0){Ub(e,1,14611,m+8|0)|0;e=0;i=m;return e|0}qb(b+h|0,(c[k+5584>>2]|0)+(d*1080|0)|0,1);if(!(Fe(a,c[l>>2]|0,b+j|0,f,e)|0)){Ub(e,1,14585,m+16|0)|0;e=0;i=m;return e|0}if(!(c[f>>2]|0)){e=1;i=m;return e|0}Ub(e,1,14585,m+24|0)|0;e=0;i=m;return e|0}function ge(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;k=i;i=i+32|0;j=k+8|0;f=k+20|0;h=c[(c[a+80>>2]|0)+16>>2]|0;g=h>>>0<257?1:2;if((g+2|0)!=(d|0)){Ub(e,1,14502,k)|0;j=0;i=k;return j|0}if((c[a+8>>2]|0)==16)a=(c[a+164>>2]|0)+((c[a+200>>2]|0)*5640|0)|0;else a=c[a+12>>2]|0;qb(b,f,g);qb(b+g|0,k+16|0,1);d=c[f>>2]|0;if(d>>>0<h>>>0){qb(b+(g+1)|0,(c[a+5584>>2]|0)+(d*1080|0)+808|0,1);j=1;i=k;return j|0}else{c[j>>2]=d;c[j+4>>2]=h;Ub(e,1,14528,j)|0;j=0;i=k;return j|0}return 0}function he(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=i;i=i+16|0;f=h+12|0;c[f>>2]=d;if(!(Ee(a,0,b,f,e)|0)){Ub(e,1,14476,h)|0;g=0;i=h;return g|0}if(c[f>>2]|0){Ub(e,1,14476,h+8|0)|0;g=0;i=h;return g|0}if((c[a+8>>2]|0)==16)f=(c[a+164>>2]|0)+((c[a+200>>2]|0)*5640|0)|0;else f=c[a+12>>2]|0;f=c[f+5584>>2]|0;d=a+80|0;if((c[(c[d>>2]|0)+16>>2]|0)>>>0<=1){g=1;i=h;return g|0}e=f+24|0;a=f+804|0;g=f+28|0;b=1;while(1){c[f+1104>>2]=c[e>>2];c[f+1884>>2]=c[a>>2];Ui(f+1108|0,g|0,776)|0;b=b+1|0;if(b>>>0>=(c[(c[d>>2]|0)+16>>2]|0)>>>0){f=1;break}else f=f+1080|0}i=h;return f|0}function ie(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;o=i;i=i+48|0;n=o+32|0;m=o+24|0;l=o+16|0;g=o+8|0;f=o;k=o+40|0;h=o+36|0;c[k>>2]=d;j=a+80|0;do if((c[(c[j>>2]|0)+16>>2]|0)>>>0<257){if(d){qb(b,h,1);g=b+1|0;b=d+-1|0;break}Ub(e,1,14129,f)|0;n=0;i=o;return n|0}else{if(d>>>0>=2){qb(b,h,2);g=b+2|0;b=d+-2|0;break}Ub(e,1,14129,g)|0;n=0;i=o;return n|0}while(0);c[k>>2]=b;f=c[h>>2]|0;b=c[(c[j>>2]|0)+16>>2]|0;if(f>>>0>=b>>>0){c[l>>2]=f;c[l+4>>2]=b;Ub(e,1,14155,l)|0;n=0;i=o;return n|0}if(!(Ee(a,f,g,k,e)|0)){Ub(e,1,14129,m)|0;n=0;i=o;return n|0}if(!(c[k>>2]|0)){n=1;i=o;return n|0}Ub(e,1,14129,n)|0;n=0;i=o;return n|0}function je(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=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;t=i;i=i+16|0;h=t+8|0;s=t+12|0;r=c[(c[b+80>>2]|0)+16>>2]|0;q=r>>>0<257?1:2;p=(q<<1)+5|0;g=(e>>>0)/(p>>>0)|0;if((g|0)==0|((e>>>0)%(p>>>0)|0|0)!=0){Ub(f,1,14085,t)|0;s=0;i=t;return s|0}if((c[b+8>>2]|0)==16)p=(c[b+164>>2]|0)+((c[b+200>>2]|0)*5640|0)|0;else p=c[b+12>>2]|0;e=p+5636|0;b=a[e>>0]|0;if(!(b&4))o=0;else o=(c[p+420>>2]|0)+1|0;n=o+g|0;if(n>>>0>31){c[h>>2]=n;Ub(f,1,14111,h)|0;s=0;i=t;return s|0}a[e>>0]=b|4;if(o>>>0<n>>>0){f=q+1|0;m=p+8|0;h=q+3|0;j=q|4;k=j+q|0;l=k+1|0;b=d;g=o;e=p+424+(o*148|0)|0;while(1){qb(b,e,1);qb(b+1|0,e+4|0,q);d=e+8|0;qb(b+f|0,d,2);u=c[d>>2]|0;o=c[m>>2]|0;c[d>>2]=u>>>0<o>>>0?u:o;qb(b+h|0,e+12|0,1);d=e+16|0;qb(b+j|0,d,q);qb(b+k|0,s,1);c[e+36>>2]=c[s>>2];o=c[d>>2]|0;c[d>>2]=o>>>0<r>>>0?o:r;g=g+1|0;if(g>>>0>=n>>>0)break;else{b=b+l|0;e=e+148|0}}}c[p+420>>2]=n+-1;u=1;i=t;return u|0}function ke(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var h=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,A=0,B=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;M=i;i=i+144|0;L=M+128|0;H=M+120|0;G=M+112|0;F=M+104|0;E=M+96|0;D=M+88|0;A=M+72|0;t=M+64|0;r=M+56|0;q=M+48|0;p=M+40|0;s=M+32|0;l=M+24|0;j=M+16|0;h=M+136|0;w=M+132|0;J=c[d+80>>2]|0;K=d+88|0;if(f>>>0<36){Ub(g,1,13440,M)|0;g=0;i=M;return g|0}I=f+-36|0;o=(I>>>0)/3|0;if((I>>>0)%3|0){Ub(g,1,13440,M+8|0)|0;g=0;i=M;return g|0}qb(e,h,2);b[K>>1]=c[h>>2];x=J+8|0;qb(e+2|0,x,4);B=J+12|0;qb(e+6|0,B,4);qb(e+10|0,J,4);n=J+4|0;qb(e+14|0,n,4);v=d+100|0;qb(e+18|0,v,4);z=d+104|0;qb(e+22|0,z,4);u=d+92|0;qb(e+26|0,u,4);y=d+96|0;qb(e+30|0,y,4);qb(e+34|0,h,2);k=e+36|0;f=c[h>>2]|0;if(f>>>0>=16385){c[j>>2]=f;Ub(g,1,13468,j)|0;g=0;i=M;return g|0}f=f&65535;I=J+16|0;c[I>>2]=f;if((f|0)!=(o|0)){c[l>>2]=f;c[l+4>>2]=o;Ub(g,1,
function bb(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function cb(){return i|0}function db(a){a=a|0;i=a}function eb(a,b){a=a|0;b=b|0;i=a;j=b}function fb(a,b){a=a|0;b=b|0;if(!n){n=a;o=b}}function gb(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function hb(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function ib(a){a=a|0;C=a}function jb(){return C|0}function kb(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0;o=i;i=i+8272|0;k=o+16|0;m=o+12|0;j=o;c[m>>2]=0;if((c[a>>2]|0)==1375686655)n=gc(0)|0;else n=gc(2)|0;bc(n,1,0)|0;cc(n,2,0)|0;dc(n,3,0)|0;hc(k);c[j>>2]=a;c[j+4>>2]=a;c[j+8>>2]=b;l=ec(j,1)|0;if(!(ic(n,k)|0)){mi(4476)|0;Fb(l);zc(n);g=1;i=o;return g|0}if(!(jc(l,n,m)|0)){mi(4528)|0;Fb(l);zc(n);Zb(c[m>>2]|0);g=1;i=o;return g|0}if(!(oc(n,l,c[m>>2]|0,c[k+8228>>2]|0)|0)){mi(4578)|0;zc(n);Fb(l);Zb(c[m>>2]|0);g=1;i=o;return g|0}j=c[m>>2]|0;c[f>>2]=c[j+8>>2];c[g>>2]=c[j+12>>2];a=c[j+16>>2]|0;c[h>>2]=a;a=_(_(a<<2,c[f>>2]|0)|0,c[g>>2]|0)|0;c[e>>2]=a;e=Fi(a)|0;c[d>>2]=e;switch(c[h>>2]|0){case 1:{Ui(e|0,c[(c[j+24>>2]|0)+44>>2]|0,a|0)|0;break}case 3:{if((_(c[g>>2]|0,c[f>>2]|0)|0)>0){b=c[j+24>>2]|0;j=c[b+44>>2]|0;a=c[b+96>>2]|0;b=c[b+148>>2]|0;k=0;do{h=k*3|0;c[e+(h<<2)>>2]=c[j+(k<<2)>>2];c[e+(h+1<<2)>>2]=c[a+(k<<2)>>2];c[e+(h+2<<2)>>2]=c[b+(k<<2)>>2];k=k+1|0}while((k|0)<(_(c[g>>2]|0,c[f>>2]|0)|0))}break}default:{}}Fb(l);zc(n);Zb(c[m>>2]|0);g=0;i=o;return g|0}function lb(){return fc()|0}function mb(a,b){a=a|0;b=b|0;return}function nb(a,b){a=a|0;b=b|0;return}function ob(a,b){a=a|0;b=b|0;var d=0;b=i;i=i+16|0;d=b;c[d>>2]=a;li(4625,d)|0;i=b;return}function pb(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;h=i;i=i+16|0;g=h;c[g>>2]=d;if(!e){i=h;return}d=b;f=0;b=g+(e+-1)|0;while(1){a[d>>0]=a[b>>0]|0;f=f+1|0;if((f|0)==(e|0))break;else{d=d+1|0;b=b+-1|0}}i=h;return}function qb(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;c[d>>2]=0;if(!e)return;f=0;d=d+(e+-1)|0;while(1){a[d>>0]=a[b>>0]|0;f=f+1|0;if((f|0)==(e|0))break;else{b=b+1|0;d=d+-1|0}}return}function rb(b,d){b=b|0;d=+d;var e=0,f=0,g=0,j=0,l=0;e=i;i=i+16|0;j=e;h[j>>3]=d;j=j+8|0;h[k>>3]=d;f=c[k>>2]|0;g=c[k+4>>2]|0;l=Ti(f|0,g|0,56)|0;a[b>>0]=l;l=Ti(f|0,g|0,48)|0;a[b+1>>0]=l;l=Ti(f|0,g|0,40)|0;a[b+2>>0]=l;a[b+3>>0]=g;a[b+4>>0]=a[j+-5>>0]|0;a[b+5>>0]=a[j+-6>>0]|0;g=Ti(f|0,g|0,8)|0;a[b+6>>0]=g;a[b+7>>0]=f;i=e;return}function sb(b,c){b=b|0;c=c|0;var d=0;d=c+8|0;a[d+-1>>0]=a[b>>0]|0;a[d+-2>>0]=a[b+1>>0]|0;a[d+-3>>0]=a[b+2>>0]|0;a[d+-4>>0]=a[b+3>>0]|0;a[d+-5>>0]=a[b+4>>0]|0;a[d+-6>>0]=a[b+5>>0]|0;a[d+-7>>0]=a[b+6>>0]|0;a[c>>0]=a[b+7>>0]|0;return}function tb(b,d){b=b|0;d=+d;var e=0;e=(g[k>>2]=d,c[k>>2]|0);a[b>>0]=e>>>24;a[b+1>>0]=e>>>16;a[b+2>>0]=e>>>8;a[b+3>>0]=e;return}function ub(b,c){b=b|0;c=c|0;var d=0;d=c+4|0;a[d+-1>>0]=a[b>>0]|0;a[d+-2>>0]=a[b+1>>0]|0;a[d+-3>>0]=a[b+2>>0]|0;a[c>>0]=a[b+3>>0]|0;return}function vb(a,b){a=a|0;b=b|0;var d=0,e=0;e=Qc(1,72)|0;if(!e){b=0;return b|0}c[e+64>>2]=a;a=Pc(a)|0;c[e+32>>2]=a;if(!a){Uc(e);b=0;return b|0}c[e+36>>2]=a;a=e+68|0;d=c[a>>2]|0;if(!b){c[a>>2]=d|1;c[e+40>>2]=31;c[e+44>>2]=32}else{c[a>>2]=d|2;c[e+40>>2]=29;c[e+44>>2]=30}c[e+16>>2]=4;c[e+20>>2]=5;c[e+24>>2]=6;c[e+28>>2]=7;b=e;return b|0}function wb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;n=i;i=i+16|0;m=n;f=a+48|0;g=c[f>>2]|0;if(g>>>0>=b>>>0){m=a+36|0;c[m>>2]=(c[m>>2]|0)+b;c[f>>2]=g-b;m=a+56|0;a=m;a=Si(c[a>>2]|0,c[a+4>>2]|0,b|0,d|0)|0;c[m>>2]=a;c[m+4>>2]=C;m=d;a=b;C=m;i=n;return a|0}l=a+68|0;if(c[l>>2]&4){m=a+36|0;c[m>>2]=(c[m>>2]|0)+g;c[f>>2]=0;a=a+56|0;m=a;m=Si(c[m>>2]|0,c[m+4>>2]|0,g|0,0)|0;c[a>>2]=m;c[a+4>>2]=C;a=(g|0)!=0;m=a?0:-1;a=a?g:-1;C=m;i=n;return a|0}if(!g){g=0;f=0}else{c[a+36>>2]=c[a+32>>2];b=Oi(b|0,d|0,g|0,0)|0;c[f>>2]=0;f=0;d=C}a:do if((d|0)>0|(d|0)==0&b>>>0>0){k=a+24|0;while(1){h=Ra[c[k>>2]&63](b,d,c[a>>2]|0)|0;j=C;if((h|0)==-1&(j|0)==-1)break;b=Oi(b|0,d|0,h|0,j|0)|0;d=C;g=Si(h|0,j|0,g|0,f|0)|0;f=C;if(!((d|0)>0|(d|0)==0&b>>>0>0))break a}Ub(e,4,4636,m)|0;c[l>>2]=c[l>>2]|4;a=a+56|0
function lg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=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;u=i;i=i+272|0;n=u;s=u+136|0;t=u+8|0;if(!a){t=0;i=u;return t|0}m=a+4|0;if((c[a>>2]|0)==(b|0)?(c[m>>2]|0)==(d|0):0)f=a+8|0;else{c[a>>2]=b;c[m>>2]=d;c[s>>2]=b;c[t>>2]=d;f=a+8|0;c[f>>2]=0;g=0;j=d;k=b;l=0;while(1){r=_(j,k)|0;k=(k+1|0)/2|0;h=l+1|0;c[s+(h<<2)>>2]=k;j=(j+1|0)/2|0;c[t+(h<<2)>>2]=j;g=g+r|0;if(r>>>0<=1)break;else l=h}c[f>>2]=g;if(!g){f=a+12|0;g=c[f>>2]|0;if(g){Uc(g);c[f>>2]=0}Uc(a);t=0;i=u;return t|0}h=g<<4;j=a+16|0;k=a+12|0;do if(h>>>0>(c[j>>2]|0)>>>0){g=Tc(c[k>>2]|0,h)|0;if(g){c[k>>2]=g;d=c[j>>2]|0;Qi(g+d|0,0,h-d|0)|0;c[j>>2]=h;d=c[m>>2]|0;b=c[a>>2]|0;break}Ub(e,1,20166,n)|0;f=c[k>>2]|0;if(f){Uc(f);c[k>>2]=0}Uc(a);t=0;i=u;return t|0}while(0);g=c[k>>2]|0;b=g+((_(d,b)|0)<<4)|0;if(l){r=0;d=b;do{p=c[t+(r<<2)>>2]|0;a:do if((p|0)>0){q=c[s+(r<<2)>>2]|0;if((q|0)<=0){h=p+-1|0;j=0;while(1){o=(j&1|0)!=0|(j|0)==(h|0);k=o?d:b+(q<<4)|0;d=o?d:b;j=j+1|0;if((j|0)>=(p|0)){b=k;break a}else b=k}}o=((q+2+((q|0)<2?~q:-3)|0)>>>1)+1|0;e=p+-1|0;n=0;while(1){m=q;k=d;while(1){c[g>>2]=k;h=g+16|0;j=m;m=m+-2|0;if((m|0)>-1){c[h>>2]=k;g=g+32|0}else g=h;if((j|0)<=2)break;else k=k+16|0}d=d+(o<<4)|0;m=(n&1|0)!=0|(n|0)==(e|0);h=m?d:b+(q<<4)|0;d=m?d:b;n=n+1|0;if((n|0)>=(p|0)){b=h;break}else b=h}}while(0);r=r+1|0}while((r|0)!=(l|0))}c[g>>2]=0}f=c[f>>2]|0;if(!f){t=a;i=u;return t|0}g=0;b=c[a+12>>2]|0;while(1){c[b+4>>2]=999;c[b+8>>2]=0;c[b+12>>2]=0;g=g+1|0;if((g|0)==(f|0))break;else b=b+16|0}i=u;return a|0}function mg(a){a=a|0;var b=0,d=0;if(!a)return;b=a+12|0;d=c[b>>2]|0;if(d){Uc(d);c[b>>2]=0}Uc(a);return}function ng(a,b,d){a=a|0;b=b|0;d=d|0;b=(c[a+12>>2]|0)+(b<<4)|0;if(!b)return;while(1){a=b+4|0;if((c[a>>2]|0)<=(d|0)){b=4;break}c[a>>2]=d;b=c[b>>2]|0;if(!b){b=4;break}}if((b|0)==4)return}function og(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;k=i;i=i+128|0;j=k;d=(c[b+12>>2]|0)+(d<<4)|0;if(!(c[d>>2]|0)){f=0;g=j}else{f=d;b=j;while(1){g=b+4|0;c[b>>2]=d;d=c[f>>2]|0;if(!(c[d>>2]|0)){f=0;break}else{f=d;b=g}}}while(1){h=d+8|0;b=c[h>>2]|0;if((f|0)>(b|0)){c[h>>2]=f;b=f}a:do if((b|0)<(e|0)){f=d+4|0;while(1){if((b|0)>=(c[f>>2]|0))break;Bg(a,0,1);b=b+1|0;if((b|0)>=(e|0)){d=b;break a}}d=d+12|0;if(!(c[d>>2]|0)){Bg(a,1,1);c[d>>2]=1;d=b}else d=b}else d=b;while(0);c[h>>2]=d;if((g|0)==(j|0))break;h=g+-4|0;f=d;d=c[h>>2]|0;g=h}i=k;return}function pg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;k=i;i=i+128|0;j=k;d=(c[b+12>>2]|0)+(d<<4)|0;if(!(c[d>>2]|0)){b=0;g=j}else{f=d;b=j;while(1){g=b+4|0;c[b>>2]=d;d=c[f>>2]|0;if(!(c[d>>2]|0)){b=0;break}else{f=d;b=g}}}while(1){h=d+8|0;f=c[h>>2]|0;if((b|0)>(f|0))c[h>>2]=b;else b=f;d=d+4|0;a:do if((b|0)<(e|0)){while(1){if((b|0)>=(c[d>>2]|0))break a;if(Cg(a,1)|0)break;b=b+1|0;if((b|0)>=(e|0))break a}c[d>>2]=b}while(0);c[h>>2]=b;if((g|0)==(j|0))break;h=g+-4|0;d=c[h>>2]|0;g=h}i=k;return (c[d>>2]|0)<(e|0)|0}function qg(){var a=0,b=0;a=Qc(1,12)|0;if(!a){a=0;return a|0}c[a+4>>2]=10;b=Qc(10,4)|0;c[a+8>>2]=b;if(b){b=a;return b|0}Uc(a);b=0;return b|0}function rg(a){a=a|0;var b=0;if(!a)return;b=c[a+8>>2]|0;if(b)Uc(b);Uc(a);return}function sg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;h=j;g=a+4|0;f=c[g>>2]|0;e=c[a>>2]|0;do if((f|0)==(e|0)){f=f+10|0;c[g>>2]=f;e=a+8|0;f=Tc(c[e>>2]|0,f<<2)|0;if(f){c[e>>2]=f;e=c[a>>2]|0;break}Uc(c[e>>2]|0);c[g>>2]=0;c[a>>2]=0;Ub(d,1,20214,h)|0;a=0;i=j;return a|0}else f=c[a+8>>2]|0;while(0);c[f+(e<<2)>>2]=b;c[a>>2]=e+1;a=1;i=j;return a|0}function tg(a){a=a|0;return c[a>>2]|0}function ug(a){a=a|0;return c[a+8>>2]|0}function vg(a){a=a|0;c[a>>2]=0;return}function wg(){return Pc(20)|0}function xg(a){a=a|0;if(!a)return;Uc(a);return}function yg(a){a=a|0;return (c[a+8>>2]|0)-(c[a>>2]|0)|0}function zg(a,b,d){a=a|0;b=b|0;d=d|0;c[a>>2]=b;c[a+4>>2]=b+d;c[a+8>>2]=b;c[a+12>>2]=0;c[a+16>>2]=8;return}function Ag(a,b,d){a=a|0;b=b|0;d=d|0;c[a>>2]=b;c[a+4>>2]=b+d;c[a+8>>2]=b;c[a+12>>2]=0;c[a+16>>2]=0;return}function Bg(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(!e)return;k=b+16|0;l=b+12|0;m=b+8|0;h=b+4|0;b=c[k>>2]|0;j=e+-1|0;do{i=d>>>j&1;if(!b){g=c[l>>2]|0;b=g<<8&6528
function Ai(e,f,g,j,l){e=e|0;f=f|0;g=g|0;j=j|0;l=l|0;var m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=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,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;ha=i;i=i+624|0;ca=ha+24|0;ea=ha+16|0;da=ha+588|0;Y=ha+576|0;ba=ha;V=ha+536|0;ga=ha+8|0;fa=ha+528|0;M=(e|0)!=0;N=V+40|0;U=N;V=V+39|0;W=ga+4|0;X=Y+12|0;Y=Y+11|0;Z=da;$=X;aa=$-Z|0;O=-2-Z|0;P=$+2|0;Q=ca+288|0;R=da+9|0;S=R;T=da+8|0;m=0;w=f;n=0;f=0;a:while(1){do if((m|0)>-1)if((n|0)>(2147483647-m|0)){c[(Bh()|0)>>2]=75;m=-1;break}else{m=n+m|0;break}while(0);n=a[w>>0]|0;if(!(n<<24>>24)){L=245;break}else o=w;b:while(1){switch(n<<24>>24){case 37:{n=o;L=9;break b}case 0:{n=o;break b}default:{}}K=o+1|0;n=a[K>>0]|0;o=K}c:do if((L|0)==9)while(1){L=0;if((a[n+1>>0]|0)!=37)break c;o=o+1|0;n=n+2|0;if((a[n>>0]|0)==37)L=9;else break}while(0);y=o-w|0;if(M?(c[e>>2]&32|0)==0:0)ji(w,y,e)|0;if((o|0)!=(w|0)){w=n;n=y;continue}r=n+1|0;o=a[r>>0]|0;p=(o<<24>>24)+-48|0;if(p>>>0<10){K=(a[n+2>>0]|0)==36;r=K?n+3|0:r;o=a[r>>0]|0;u=K?p:-1;f=K?1:f}else u=-1;n=o<<24>>24;d:do if((n&-32|0)==32){p=0;while(1){if(!(1<<n+-32&75913)){s=p;n=r;break d}p=1<<(o<<24>>24)+-32|p;r=r+1|0;o=a[r>>0]|0;n=o<<24>>24;if((n&-32|0)!=32){s=p;n=r;break}}}else{s=0;n=r}while(0);do if(o<<24>>24==42){p=n+1|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+2>>0]|0)==36:0){c[l+(o<<2)>>2]=10;f=1;n=n+3|0;o=c[j+((a[p>>0]|0)+-48<<3)>>2]|0}else{if(f){m=-1;break a}if(!M){x=s;n=p;f=0;K=0;break}f=(c[g>>2]|0)+(4-1)&~(4-1);o=c[f>>2]|0;c[g>>2]=f+4;f=0;n=p}if((o|0)<0){x=s|8192;K=0-o|0}else{x=s;K=o}}else{p=(o<<24>>24)+-48|0;if(p>>>0<10){o=0;do{o=(o*10|0)+p|0;n=n+1|0;p=(a[n>>0]|0)+-48|0}while(p>>>0<10);if((o|0)<0){m=-1;break a}else{x=s;K=o}}else{x=s;K=0}}while(0);e:do if((a[n>>0]|0)==46){p=n+1|0;o=a[p>>0]|0;if(o<<24>>24!=42){r=(o<<24>>24)+-48|0;if(r>>>0<10){n=p;o=0}else{n=p;r=0;break}while(1){o=(o*10|0)+r|0;n=n+1|0;r=(a[n>>0]|0)+-48|0;if(r>>>0>=10){r=o;break e}}}p=n+2|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+3>>0]|0)==36:0){c[l+(o<<2)>>2]=10;n=n+4|0;r=c[j+((a[p>>0]|0)+-48<<3)>>2]|0;break}if(f){m=-1;break a}if(M){n=(c[g>>2]|0)+(4-1)&~(4-1);r=c[n>>2]|0;c[g>>2]=n+4;n=p}else{n=p;r=0}}else r=-1;while(0);t=0;while(1){o=(a[n>>0]|0)+-65|0;if(o>>>0>57){m=-1;break a}p=n+1|0;o=a[25126+(t*58|0)+o>>0]|0;s=o&255;if((s+-1|0)>>>0<8){n=p;t=s}else{J=p;break}}if(!(o<<24>>24)){m=-1;break}p=(u|0)>-1;do if(o<<24>>24==19)if(p){m=-1;break a}else L=52;else{if(p){c[l+(u<<2)>>2]=s;H=j+(u<<3)|0;I=c[H+4>>2]|0;L=ba;c[L>>2]=c[H>>2];c[L+4>>2]=I;L=52;break}if(!M){m=0;break a}Ci(ba,s,g)}while(0);if((L|0)==52?(L=0,!M):0){w=J;n=y;continue}u=a[n>>0]|0;u=(t|0)!=0&(u&15|0)==3?u&-33:u;p=x&-65537;I=(x&8192|0)==0?x:p;f:do switch(u|0){case 110:switch(t|0){case 0:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 1:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 2:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}case 3:{b[c[ba>>2]>>1]=m;w=J;n=y;continue a}case 4:{a[c[ba>>2]>>0]=m;w=J;n=y;continue a}case 6:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 7:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}default:{w=J;n=y;continue a}}case 112:{t=I|8;r=r>>>0>8?r:8;u=120;L=64;break}case 88:case 120:{t=I;L=64;break}case 111:{p=ba;o=c[p>>2]|0;p=c[p+4>>2]|0;if((o|0)==0&(p|0)==0)n=N;else{n=N;do{n=n+-1|0;a[n>>0]=o&7|48;o=Ti(o|0,p|0,3)|0;p=C}while(!((o|0)==0&(p|0)==0))}if(!(I&8)){o=I;t=0;s=25606;L=77}else{t=U-n+1|0;o=I;r=(r|0)<(t|0)?t:r;t=0;s=25606;L=77}break}case 105:case 100:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;if((o|0)<0){n=Oi(0,0,n|0,o|0)|0;o=C;p=ba;c[p>>2]=n;c[p+4>>2]=o;p=1;s=25606;L=76;break f}if(!(I&2048)){s=I&1;p=s;s=(s|0)==0?25606:25608;L=76}else{p=1;s=25607;L=76}break}case 117:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;p=0;s=25606;L=76;break}case 99:{a[V>>0]=c[ba>>2];w=V;o=1;t=0;u=25606;n=N;break}case 109:{n=Ch(c[(Bh()|0)>>2]|0)|0;L=82;break}case 115:{n=c[ba>>2]|0;n=(n|0)!=0?n:25616;L=82;break}case 67:{c[ga>>2]=c[ba>>2];c[W>>2]=0;c[ba>>2]=ga;r=-1;L=86;break}case 83:{if(!r){Ei(e,32,K,0,I);n=0;L=98}else L=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{q=+h[ba>>3];c[ea
// EMSCRIPTEN_END_FUNCS
var Qa=[oj,ed,We,oj];var Ra=[pj,Bi,Vh,Th,Ab,Bb,Cb,Db,Hc,Ic,Kc,$c,nd,Oe,af,od,pd,Ne,Pe,Lc,Mc,Nc,Oc,td,ud,vd,wd,yd,zd,Bd,Cd,Dd,Ed,Fd,Gd,Hd,Id,Jd,Kd,Ld,Md,Nd,Od,Pd,Qd,Rd,Sd,Td,Ud,Vd,Wd,Xd,ef,ff,gf,hf,jf,kf,lf,mf,Sh,Uh,pj,pj];var Sa=[qj,Yd,Zd,qj];var Ta=[rj,Yc,Ve,gg,hg,xi,yi,rj];var Ua=[sj,mb,nb,ob,Wb,Wc,Le,sj];var Va=[tj,dd,Ue,rd,Te,tj,tj,tj];var Wa=[uj,Rh,jd,kd,$e,_e,Yh,Kg,Hg,uj,uj,uj,uj,uj,uj,uj];var Xa=[vj,Ge,He,Ie,Je,Ae,Be,Ce,De,we,xe,ye,ze,gd,Ze,vj];var Ya=[wj,cd,Se,wj];var Za=[xj,de,ee,fe,ge,he,ie,je,ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,xf,yf,zf,rf,sf,tf,uf,vf,wf,wb,xb,yb,zb,ld,ad,Ke,Re,qd,Zc,Qe,Me,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj,xj];var _a=[yj,Jc,nf,of,pf,qf,yj,yj];var $a=[zj,md,Xe,zj];var ab=[Aj,Og,Rg,Aj];return{_opj_stream_destroy:Fb,_opj_stream_set_read_function:Gb,_opj_read_tile_header:mc,_opj_set_warning_handler:cc,_opj_destroy_cstr_info:Cc,_opj_image_create:Yb,_opj_set_error_handler:dc,_opj_stream_set_user_data:Kb,_opj_end_decompress:wc,_bitshift64Lshr:Ti,_opj_stream_set_seek_function:Hb,_opj_decode:kc,_opj_set_decoded_resolution_factor:pc,_i64Add:Si,_opj_stream_create_default_file_stream:Fc,_opj_set_default_decoder_parameters:hc,_bitshift64Ashr:Pi,_opj_get_decoded_tile:oc,_memset:Qi,_opj_version:fc,_memcpy:Ui,_opj_destroy_cstr_index:Ec,_opj_stream_set_user_data_length:Lb,_opj_stream_set_skip_function:Jb,_opj_image_destroy:Zb,_opj_stream_create_file_stream:Gc,_opj_setup_encoder:sc,_opj_stream_default_create:Eb,_bitshift64Shl:Ri,_opj_stream_create:vb,_jp2_version:lb,_i64Subtract:Oi,_opj_get_cstr_index:Dc,_opj_encode:uc,_opj_read_header:jc,_opj_get_cstr_info:Bc,_opj_set_default_encoder_parameters:rc,_opj_set_decode_area:lc,_opj_stream_set_write_function:Ib,_opj_dump_codec:Ac,_opj_create_decompress:gc,_opj_decode_tile_data:nc,_free:Gi,_opj_image_tile_create:ac,_opj_set_MCT:xc,_opj_set_info_handler:bc,_opj_start_compress:tc,_opj_write_tile:yc,_opj_setup_decoder:ic,_malloc:Fi,_opj_end_compress:vc,_opj_destroy_codec:zc,_jp2_decode:kb,_opj_stream_create_buffer_stream:ec,_opj_create_compress:qc,runPostSets:Ni,stackAlloc:bb,stackSave:cb,stackRestore:db,establishStackSpace:eb,setThrew:fb,setTempRet0:ib,getTempRet0:jb,dynCall_iiiiiiii:bj,dynCall_iiii:cj,dynCall_di:dj,dynCall_vi:ej,dynCall_vii:fj,dynCall_iiiiiii:gj,dynCall_ii:hj,dynCall_viii:ij,dynCall_iiiiiiiiiiii:jj,dynCall_iiiii:kj,dynCall_iii:lj,dynCall_iiiiii:mj,dynCall_viiii:nj}})
// EMSCRIPTEN_END_ASM
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _opj_stream_destroy=Module["_opj_stream_destroy"]=asm["_opj_stream_destroy"];var _opj_stream_set_read_function=Module["_opj_stream_set_read_function"]=asm["_opj_stream_set_read_function"];var _opj_read_tile_header=Module["_opj_read_tile_header"]=asm["_opj_read_tile_header"];var _opj_set_warning_handler=Module["_opj_set_warning_handler"]=asm["_opj_set_warning_handler"];var _opj_destroy_cstr_info=Module["_opj_destroy_cstr_info"]=asm["_opj_destroy_cstr_info"];var _opj_image_create=Module["_opj_image_create"]=asm["_opj_image_create"];var _opj_set_error_handler=Module["_opj_set_error_handler"]=asm["_opj_set_error_handler"];var _opj_image_tile_create=Module["_opj_image_tile_create"]=asm["_opj_image_tile_create"];var _opj_end_decompress=Module["_opj_end_decompress"]=asm["_opj_end_decompress"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _opj_stream_set_seek_function=Module["_opj_stream_set_seek_function"]=asm["_opj_stream_set_seek_function"];var _opj_decode=Module["_opj_decode"]=asm["_opj_decode"];var _opj_set_decoded_resolution_factor=Module["_opj_set_decoded_resolution_factor"]=asm["_opj_set_decoded_resolution_factor"];var _opj_stream_create_default_file_stream=Module["_opj_stream_create_default_file_stream"]=asm["_opj_stream_create_default_file_stream"];var _opj_encode=Module["_opj_encode"]=asm["_opj_encode"];var _bitshift64Ashr=Module["_bitshift64Ashr"]=asm["_bitshift64Ashr"];var _opj_get_decoded_tile=Module["_opj_get_decoded_tile"]=asm["_opj_get_decoded_tile"];var _memset=Module["_memset"]=asm["_memset"];var _opj_version=Module["_opj_version"]=asm["_opj_version"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _opj_destroy_cstr_index=Module["_opj_destroy_cstr_index"]=asm["_opj_destroy_cstr_index"];var _opj_stream_set_user_data_length=Module["_opj_stream_set_user_data_length"]=asm["_opj_stream_set_user_data_length"];var _opj_stream_set_skip_function=Module["_opj_stream_set_skip_function"]=asm["_opj_stream_set_skip_function"];var _opj_image_destroy=Module["_opj_image_destroy"]=asm["_opj_image_destroy"];var _opj_stream_create_file_stream=Module["_opj_stream_create_file_stream"]=asm["_opj_stream_create_file_stream"];var _opj_setup_encoder=Module["_opj_setup_encoder"]=asm["_opj_setup_encoder"];var _opj_stream_default_create=Module["_opj_stream_default_create"]=asm["_opj_stream_default_create"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _opj_stream_create=Module["_opj_stream_create"]=asm["_opj_stream_create"];var _jp2_version=Module["_jp2_version"]=asm["_jp2_version"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _opj_get_cstr_index=Module["_opj_get_cstr_index"]=asm["_opj_get_cstr_index"];var _opj_set_default_decoder_parameters=Module["_opj_set_default_decoder_parameters"]=asm["_opj_set_default_decoder_parameters"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _opj_get_cstr_info=Module["_opj_get_cstr_info"]=asm["_opj_get_cstr_info"];var _opj_set_default_encoder_parameters=Module["_opj_set_default_encoder_parameters"]=asm["_opj_set_default_encoder_parameters"];var _opj_set_decode_area=Module["_opj_set_decode_area"]=asm["_opj_set_decode_area"];var _opj_stream_set_write_function=Module["_opj_stream_set_write_function"]=asm["_opj_stream_set_write_function"];var _opj_dump_codec=Module["_opj_dump_codec"]=asm["_opj_dump_codec"];var _opj_read_header=Module["_opj_read_header"]=asm["_opj_read_header"];var _opj_create_decompress=Module["_opj_create_decompress"]=asm["_opj_create_decompress"];var _opj_decode_tile_data=Module["_opj_decode_tile_data"]=asm["_opj_decode_tile_data"];var _opj_set_info_handler=Module["_opj_set_info_handler"]=asm["_opj_set_info_handler"];var _opj_stream_set_user_data=Module["_opj_stream_set_user_data"]=asm["_opj_stream_set_user_data"];var _opj_set_MCT=Module["_opj_set_MCT"]=asm["_opj_set_MCT"];var _free=Module["_free"]=asm["_free"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _opj_start_compress=Module["_opj_start_compress"]=asm["_opj_start_compress"];var _opj_write_tile
return Module;
};
/* pako 0.2.8 nodeca/pako */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.pako=t()}}(function(){return function t(e,a,i){function n(s,o){if(!a[s]){if(!e[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(r)return r(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var d=a[s]={exports:{}};e[s][0].call(d.exports,function(t){var a=e[s][1][t];return n(a?a:t)},d,d.exports,t,e,a,i)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,a){"use strict";function i(t,e){var a=new v(e);if(a.push(t,!0),a.err)throw a.msg;return a.result}function n(t,e){return e=e||{},e.raw=!0,i(t,e)}function r(t,e){return e=e||{},e.gzip=!0,i(t,e)}var s=t("./zlib/deflate.js"),o=t("./utils/common"),l=t("./utils/strings"),h=t("./zlib/messages"),d=t("./zlib/zstream"),f=Object.prototype.toString,_=0,u=4,c=0,b=1,g=2,m=-1,w=0,p=8,v=function(t){this.options=o.assign({level:m,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:w,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var a=s.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==c)throw new Error(h[a]);e.header&&s.deflateSetHeader(this.strm,e.header)};v.prototype.push=function(t,e){var a,i,n=this.strm,r=this.options.chunkSize;if(this.ended)return!1;i=e===~~e?e:e===!0?u:_,"string"==typeof t?n.input=l.string2buf(t):"[object ArrayBuffer]"===f.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(0===n.avail_out&&(n.output=new o.Buf8(r),n.next_out=0,n.avail_out=r),a=s.deflate(n,i),a!==b&&a!==c)return this.onEnd(a),this.ended=!0,!1;(0===n.avail_out||0===n.avail_in&&(i===u||i===g))&&this.onData("string"===this.options.to?l.buf2binstring(o.shrinkBuf(n.output,n.next_out)):o.shrinkBuf(n.output,n.next_out))}while((n.avail_in>0||0===n.avail_out)&&a!==b);return i===u?(a=s.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===c):i===g?(this.onEnd(c),n.avail_out=0,!0):!0},v.prototype.onData=function(t){this.chunks.push(t)},v.prototype.onEnd=function(t){t===c&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},a.Deflate=v,a.deflate=i,a.deflateRaw=n,a.gzip=r},{"./utils/common":3,"./utils/strings":4,"./zlib/deflate.js":8,"./zlib/messages":13,"./zlib/zstream":15}],2:[function(t,e,a){"use strict";function i(t,e){var a=new u(e);if(a.push(t,!0),a.err)throw a.msg;return a.result}function n(t,e){return e=e||{},e.raw=!0,i(t,e)}var r=t("./zlib/inflate.js"),s=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),d=t("./zlib/zstream"),f=t("./zlib/gzheader"),_=Object.prototype.toString,u=function(t){this.options=s.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0===(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var a=r.inflateInit2(this.strm,e.windowBits);if(a!==l.Z_OK)throw new Error(h[a]);this.header=new f,r.inflateGetHeader(this.strm,this.header)};u.prototype.push=function(t,e){var a,i,n,h,d,f=this.strm,u=this.options.chunkSize,c=!1;if(this.ended)return!1;i=e===~~e?e:e===!0?l.Z_FINISH:l.Z_NO_FLUSH,"string"==typeof t?f.input=o.binstring2buf(t):"[object ArrayBuffer]"===_.call(t)?f.input=new Uint8Array(t):f.input=t,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new s.Buf8(u),f.next_out=0,f.avail_out=
a.mode=ft;break}if(a.lenbits=9,zt={bits:a.lenbits},yt=k(y,a.lens,0,a.nlen,a.lencode,0,a.work,zt),a.lenbits=zt.bits,yt){t.msg="invalid literal/lengths set",a.mode=ft;break}if(a.distbits=6,a.distcode=a.distdyn,zt={bits:a.distbits},yt=k(z,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,zt),a.distbits=zt.bits,yt){t.msg="invalid distances set",a.mode=ft;break}if(a.mode=et,e===E)break t;case et:a.mode=at;case at:if(l>=6&&h>=258){t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=l,a.hold=_,a.bits=u,v(t,b),o=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,n=t.input,l=t.avail_in,_=a.hold,u=a.bits,a.mode===G&&(a.back=-1);break}for(a.back=0;St=a.lencode[_&(1<<a.lenbits)-1],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(u>=gt);){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}if(mt&&0===(240&mt)){for(pt=gt,vt=mt,kt=wt;St=a.lencode[kt+((_&(1<<pt+vt)-1)>>pt)],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(u>=pt+gt);){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}_>>>=pt,u-=pt,a.back+=pt}if(_>>>=gt,u-=gt,a.back+=gt,a.length=wt,0===mt){a.mode=ot;break}if(32&mt){a.back=-1,a.mode=G;break}if(64&mt){t.msg="invalid literal/length code",a.mode=ft;break}a.extra=15&mt,a.mode=it;case it:if(a.extra){for(Bt=a.extra;Bt>u;){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}a.length+=_&(1<<a.extra)-1,_>>>=a.extra,u-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=nt;case nt:for(;St=a.distcode[_&(1<<a.distbits)-1],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(u>=gt);){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}if(0===(240&mt)){for(pt=gt,vt=mt,kt=wt;St=a.distcode[kt+((_&(1<<pt+vt)-1)>>pt)],gt=St>>>24,mt=St>>>16&255,wt=65535&St,!(u>=pt+gt);){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}_>>>=pt,u-=pt,a.back+=pt}if(_>>>=gt,u-=gt,a.back+=gt,64&mt){t.msg="invalid distance code",a.mode=ft;break}a.offset=wt,a.extra=15&mt,a.mode=rt;case rt:if(a.extra){for(Bt=a.extra;Bt>u;){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}a.offset+=_&(1<<a.extra)-1,_>>>=a.extra,u-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=ft;break}a.mode=st;case st:if(0===h)break t;if(g=b-h,a.offset>g){if(g=a.offset-g,g>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=ft;break}g>a.wnext?(g-=a.wnext,ct=a.wsize-g):ct=a.wnext-g,g>a.length&&(g=a.length),bt=a.window}else bt=r,ct=o-a.offset,g=a.length;g>h&&(g=h),h-=g,a.length-=g;do r[o++]=bt[ct++];while(--g);0===a.length&&(a.mode=at);break;case ot:if(0===h)break t;r[o++]=a.length,h--,a.mode=at;break;case lt:if(a.wrap){for(;32>u;){if(0===l)break t;l--,_|=n[s++]<<u,u+=8}if(b-=h,t.total_out+=b,a.total+=b,b&&(t.adler=a.check=a.flags?p(a.check,r,b,o-b):w(a.check,r,b,o-b)),b=h,(a.flags?_:i(_))!==a.check){t.msg="incorrect data check",a.mode=ft;break}_=0,u=0}a.mode=ht;case ht:if(a.wrap&&a.flags){for(;32>u;){if(0===l)break t;l--,_+=n[s++]<<u,u+=8}if(_!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=ft;break}_=0,u=0}a.mode=dt;case dt:yt=Z;break t;case ft:yt=N;break t;case _t:return O;case ut:default:return C}return t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=l,a.hold=_,a.bits=u,(a.wsize||b!==t.avail_out&&a.mode<ft&&(a.mode<lt||e!==B))&&f(t,t.output,t.next_out,b-t.avail_out)?(a.mode=_t,O):(c-=t.avail_in,b-=t.avail_out,t.total_in+=c,t.total_out+=b,a.total+=b,a.wrap&&b&&(t.adler=a.check=a.flags?p(a.check,r,b,t.next_out-b):w(a.check,r,b,t.next_out-b)),t.data_type=a.bits+(a.last?64:0)+(a.mode===G?128:0)+(a.mode===et||a.mode===J?256:0),(0===c&&0===b||e===B)&&yt===A&&(yt=I),yt)}function u(t){if(!t||!t.state)return C;var e=t.state;return e.window&&(e.window=null),t.state=null,A}function c(t,e){var a;return t&&t.state?(a=t.state,0===(2&a.wrap)?C:(a.head=e,e.done=!1,A)):C}var b,g,m=t("../utils/common"),w=t("./adler32"),p=t("./crc32"),v=t("./inffast"),k=t("./inftrees"),x=0,y=1,z=2,B=4,S=5,E=6,A=0,Z=1,R=2,C=-2,N=-3,O=-4,I=-5,U=8,F=1,T=2,D=3,L=4,H=5,j=6,K=7,M=8,P=9,Y=10,q=11,G=12,X=13,W=14,J=15,Q=16,V=17,$=18,tt=19,et=20,at=21,it=22,nt=23,rt=24,st=25,ot=26,lt=27,ht=28,dt=29,ft=30,_t=31,ut=32,ct=852,bt=592,gt=15,mt=gt,wt=!0;a.inflateReset=s,a.inflateReset2=o,a.inflateResetKeep=r,a.inflateInit=h,a.inflateInit2=l,a.inflate=_,a.inflateEnd=u,a.inflateGetHeader=c,a.infla