Browse Source

support gzip-compressed emoticons map

Andrew Dolgov 5 months ago
parent
commit
bc32d915c9
4 changed files with 70 additions and 11 deletions
  1. 1 1
      .gitignore
  2. 1 0
      index.php
  3. 17 10
      js/tt-irc.js
  4. 51 0
      lib/zlib_and_gzip.min.js

+ 1 - 1
.gitignore

@@ -21,7 +21,7 @@ emoticons/*.ogg
 emoticons/*.jpg
 emoticons/*/*.png
 emoticons/*.*.jpg
-emoticons/emoticons.json
+emoticons/emoticons.json*
 emoticons/Makefile
 emoticons/*.php
 manifest.mf

+ 1 - 0
index.php

@@ -72,6 +72,7 @@
 				"lib/localforage.min.js",
 				"lib/highlightjs/highlight.pack.js",
 				"lib/knockout.js",
+				"lib/zlib_and_gzip.min.js",
 				"js/functions.js",
 				"js/tt-irc.js",
 				"js/prefs.js",

+ 17 - 10
js/tt-irc.js

@@ -1156,18 +1156,25 @@ function init_second_stage(params) {
 			if (!obj || obj.mtime != params.emoticons_mtime) {
 				console.log('re-requesting emoticons...');
 
-				fetch("emoticons/emoticons.json?" + params.emoticons_mtime).then(function(resp) {
-					return resp.json();
-				}).then(function(json) {
-					$.each(Object.keys(json), function(i, k) {
-						emoticons_map = $.extend(emoticons_map, json[k]);
-					});
+				fetch("emoticons/emoticons.json.gz?" + params.emoticons_mtime).then(function(resp) {
+					return resp.arrayBuffer();
+				}).then(function(buf) {
+					const gunzip = new Zlib.Gunzip(new Uint8Array(buf));
+					const dec = gunzip.decompress();
+
+					if (dec) {
+						const json = JSON.parse(new TextDecoder("utf-8").decode(dec));
 
-					localforage.setItem("ttirc.emoticons-cache",
-							{mtime: params.emoticons_mtime, map: emoticons_map, fullmap: json})
-						.then(function() {
-							window.location.reload();
+						$.each(Object.keys(json), function(i, k) {
+							emoticons_map = $.extend(emoticons_map, json[k]);
 						});
+
+						localforage.setItem("ttirc.emoticons-cache",
+								{mtime: params.emoticons_mtime, map: emoticons_map, fullmap: json})
+							.then(function() {
+								window.location.reload();
+							});
+					}
 				});
 
 			} else {

+ 51 - 0
lib/zlib_and_gzip.min.js

@@ -0,0 +1,51 @@
+/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';function q(d){throw d;}var t=void 0,v=!0,ca=this;function B(d,a){var c=d.split("."),b=ca;!(c[0]in b)&&b.execScript&&b.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&a!==t?b[e]=a:b=b[e]?b[e]:b[e]={}};var E="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function H(d,a){this.index="number"===typeof a?a:0;this.m=0;this.buffer=d instanceof(E?Uint8Array:Array)?d:new (E?Uint8Array:Array)(32768);2*this.buffer.length<=this.index&&q(Error("invalid index"));this.buffer.length<=this.index&&this.f()}H.prototype.f=function(){var d=this.buffer,a,c=d.length,b=new (E?Uint8Array:Array)(c<<1);if(E)b.set(d);else for(a=0;a<c;++a)b[a]=d[a];return this.buffer=b};
+H.prototype.d=function(d,a,c){var b=this.buffer,e=this.index,f=this.m,g=b[e],k;c&&1<a&&(d=8<a?(J[d&255]<<24|J[d>>>8&255]<<16|J[d>>>16&255]<<8|J[d>>>24&255])>>32-a:J[d]>>8-a);if(8>a+f)g=g<<a|d,f+=a;else for(k=0;k<a;++k)g=g<<1|d>>a-k-1&1,8===++f&&(f=0,b[e++]=J[g],g=0,e===b.length&&(b=this.f()));b[e]=g;this.buffer=b;this.m=f;this.index=e};H.prototype.finish=function(){var d=this.buffer,a=this.index,c;0<this.m&&(d[a]<<=8-this.m,d[a]=J[d[a]],a++);E?c=d.subarray(0,a):(d.length=a,c=d);return c};
+var da=new (E?Uint8Array:Array)(256),ea;for(ea=0;256>ea;++ea){for(var M=ea,fa=M,ka=7,M=M>>>1;M;M>>>=1)fa<<=1,fa|=M&1,--ka;da[ea]=(fa<<ka&255)>>>0}var J=da;function la(d,a,c){var b,e="number"===typeof a?a:a=0,f="number"===typeof c?c:d.length;b=-1;for(e=f&7;e--;++a)b=b>>>8^S[(b^d[a])&255];for(e=f>>3;e--;a+=8)b=b>>>8^S[(b^d[a])&255],b=b>>>8^S[(b^d[a+1])&255],b=b>>>8^S[(b^d[a+2])&255],b=b>>>8^S[(b^d[a+3])&255],b=b>>>8^S[(b^d[a+4])&255],b=b>>>8^S[(b^d[a+5])&255],b=b>>>8^S[(b^d[a+6])&255],b=b>>>8^S[(b^d[a+7])&255];return(b^4294967295)>>>0}
+var ma=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,
+2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,
+2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,
+2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,
+3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,
+936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],S=E?new Uint32Array(ma):ma;function T(){}T.prototype.getName=function(){return this.name};T.prototype.getData=function(){return this.data};T.prototype.X=function(){return this.Y};function na(d){this.buffer=new (E?Uint16Array:Array)(2*d);this.length=0}na.prototype.getParent=function(d){return 2*((d-2)/4|0)};na.prototype.push=function(d,a){var c,b,e=this.buffer,f;c=this.length;e[this.length++]=a;for(e[this.length++]=d;0<c;)if(b=this.getParent(c),e[c]>e[b])f=e[c],e[c]=e[b],e[b]=f,f=e[c+1],e[c+1]=e[b+1],e[b+1]=f,c=b;else break;return this.length};
+na.prototype.pop=function(){var d,a,c=this.buffer,b,e,f;a=c[0];d=c[1];this.length-=2;c[0]=c[this.length];c[1]=c[this.length+1];for(f=0;;){e=2*f+2;if(e>=this.length)break;e+2<this.length&&c[e+2]>c[e]&&(e+=2);if(c[e]>c[f])b=c[f],c[f]=c[e],c[e]=b,b=c[f+1],c[f+1]=c[e+1],c[e+1]=b;else break;f=e}return{index:d,value:a,length:this.length}};function U(d){var a=d.length,c=0,b=Number.POSITIVE_INFINITY,e,f,g,k,h,m,r,p,l,n;for(p=0;p<a;++p)d[p]>c&&(c=d[p]),d[p]<b&&(b=d[p]);e=1<<c;f=new (E?Uint32Array:Array)(e);g=1;k=0;for(h=2;g<=c;){for(p=0;p<a;++p)if(d[p]===g){m=0;r=k;for(l=0;l<g;++l)m=m<<1|r&1,r>>=1;n=g<<16|p;for(l=m;l<e;l+=h)f[l]=n;++k}++g;k<<=1;h<<=1}return[f,c,b]};function oa(d,a){this.k=ra;this.I=0;this.input=E&&d instanceof Array?new Uint8Array(d):d;this.b=0;a&&(a.lazy&&(this.I=a.lazy),"number"===typeof a.compressionType&&(this.k=a.compressionType),a.outputBuffer&&(this.a=E&&a.outputBuffer instanceof Array?new Uint8Array(a.outputBuffer):a.outputBuffer),"number"===typeof a.outputIndex&&(this.b=a.outputIndex));this.a||(this.a=new (E?Uint8Array:Array)(32768))}var ra=2,sa={NONE:0,v:1,o:ra,aa:3},ta=[],V;
+for(V=0;288>V;V++)switch(v){case 143>=V:ta.push([V+48,8]);break;case 255>=V:ta.push([V-144+400,9]);break;case 279>=V:ta.push([V-256+0,7]);break;case 287>=V:ta.push([V-280+192,8]);break;default:q("invalid literal: "+V)}
+oa.prototype.g=function(){var d,a,c,b,e=this.input;switch(this.k){case 0:c=0;for(b=e.length;c<b;){a=E?e.subarray(c,c+65535):e.slice(c,c+65535);c+=a.length;var f=a,g=c===b,k=t,h=t,m=t,r=t,p=t,l=this.a,n=this.b;if(E){for(l=new Uint8Array(this.a.buffer);l.length<=n+f.length+5;)l=new Uint8Array(l.length<<1);l.set(this.a)}k=g?1:0;l[n++]=k|0;h=f.length;m=~h+65536&65535;l[n++]=h&255;l[n++]=h>>>8&255;l[n++]=m&255;l[n++]=m>>>8&255;if(E)l.set(f,n),n+=f.length,l=l.subarray(0,n);else{r=0;for(p=f.length;r<p;++r)l[n++]=
+f[r];l.length=n}this.b=n;this.a=l}break;case 1:var s=new H(E?new Uint8Array(this.a.buffer):this.a,this.b);s.d(1,1,v);s.d(1,2,v);var u=ua(this,e),w,C,x;w=0;for(C=u.length;w<C;w++)if(x=u[w],H.prototype.d.apply(s,ta[x]),256<x)s.d(u[++w],u[++w],v),s.d(u[++w],5),s.d(u[++w],u[++w],v);else if(256===x)break;this.a=s.finish();this.b=this.a.length;break;case ra:var D=new H(E?new Uint8Array(this.a.buffer):this.a,this.b),N,z,O,$,aa,pb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ga,La,ha,Ma,pa,xa=Array(19),
+Na,ba,qa,F,Oa;N=ra;D.d(1,1,v);D.d(N,2,v);z=ua(this,e);ga=va(this.V,15);La=wa(ga);ha=va(this.U,7);Ma=wa(ha);for(O=286;257<O&&0===ga[O-1];O--);for($=30;1<$&&0===ha[$-1];$--);var Pa=O,Qa=$,L=new (E?Uint32Array:Array)(Pa+Qa),y,P,A,ia,K=new (E?Uint32Array:Array)(316),I,G,Q=new (E?Uint8Array:Array)(19);for(y=P=0;y<Pa;y++)L[P++]=ga[y];for(y=0;y<Qa;y++)L[P++]=ha[y];if(!E){y=0;for(ia=Q.length;y<ia;++y)Q[y]=0}y=I=0;for(ia=L.length;y<ia;y+=P){for(P=1;y+P<ia&&L[y+P]===L[y];++P);A=P;if(0===L[y])if(3>A)for(;0<
+A--;)K[I++]=0,Q[0]++;else for(;0<A;)G=138>A?A:138,G>A-3&&G<A&&(G=A-3),10>=G?(K[I++]=17,K[I++]=G-3,Q[17]++):(K[I++]=18,K[I++]=G-11,Q[18]++),A-=G;else if(K[I++]=L[y],Q[L[y]]++,A--,3>A)for(;0<A--;)K[I++]=L[y],Q[L[y]]++;else for(;0<A;)G=6>A?A:6,G>A-3&&G<A&&(G=A-3),K[I++]=16,K[I++]=G-3,Q[16]++,A-=G}d=E?K.subarray(0,I):K.slice(0,I);pa=va(Q,7);for(F=0;19>F;F++)xa[F]=pa[pb[F]];for(aa=19;4<aa&&0===xa[aa-1];aa--);Na=wa(pa);D.d(O-257,5,v);D.d($-1,5,v);D.d(aa-4,4,v);for(F=0;F<aa;F++)D.d(xa[F],3,v);F=0;for(Oa=
+d.length;F<Oa;F++)if(ba=d[F],D.d(Na[ba],pa[ba],v),16<=ba){F++;switch(ba){case 16:qa=2;break;case 17:qa=3;break;case 18:qa=7;break;default:q("invalid code: "+ba)}D.d(d[F],qa,v)}var Ra=[La,ga],Sa=[Ma,ha],R,Ta,ja,Aa,Ua,Va,Wa,Xa;Ua=Ra[0];Va=Ra[1];Wa=Sa[0];Xa=Sa[1];R=0;for(Ta=z.length;R<Ta;++R)if(ja=z[R],D.d(Ua[ja],Va[ja],v),256<ja)D.d(z[++R],z[++R],v),Aa=z[++R],D.d(Wa[Aa],Xa[Aa],v),D.d(z[++R],z[++R],v);else if(256===ja)break;this.a=D.finish();this.b=this.a.length;break;default:q("invalid compression type")}return this.a};
+function ya(d,a){this.length=d;this.P=a}
+var za=function(){function d(a){switch(v){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,
+a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:q("invalid length: "+a)}}var a=[],c,b;for(c=3;258>=c;c++)b=d(c),a[c]=b[2]<<24|b[1]<<
+16|b[0];return a}(),Ba=E?new Uint32Array(za):za;
+function ua(d,a){function c(a,c){var b=a.P,d=[],e=0,f;f=Ba[a.length];d[e++]=f&65535;d[e++]=f>>16&255;d[e++]=f>>24;var g;switch(v){case 1===b:g=[0,b-1,0];break;case 2===b:g=[1,b-2,0];break;case 3===b:g=[2,b-3,0];break;case 4===b:g=[3,b-4,0];break;case 6>=b:g=[4,b-5,1];break;case 8>=b:g=[5,b-7,1];break;case 12>=b:g=[6,b-9,2];break;case 16>=b:g=[7,b-13,2];break;case 24>=b:g=[8,b-17,3];break;case 32>=b:g=[9,b-25,3];break;case 48>=b:g=[10,b-33,4];break;case 64>=b:g=[11,b-49,4];break;case 96>=b:g=[12,b-
+65,5];break;case 128>=b:g=[13,b-97,5];break;case 192>=b:g=[14,b-129,6];break;case 256>=b:g=[15,b-193,6];break;case 384>=b:g=[16,b-257,7];break;case 512>=b:g=[17,b-385,7];break;case 768>=b:g=[18,b-513,8];break;case 1024>=b:g=[19,b-769,8];break;case 1536>=b:g=[20,b-1025,9];break;case 2048>=b:g=[21,b-1537,9];break;case 3072>=b:g=[22,b-2049,10];break;case 4096>=b:g=[23,b-3073,10];break;case 6144>=b:g=[24,b-4097,11];break;case 8192>=b:g=[25,b-6145,11];break;case 12288>=b:g=[26,b-8193,12];break;case 16384>=
+b:g=[27,b-12289,12];break;case 24576>=b:g=[28,b-16385,13];break;case 32768>=b:g=[29,b-24577,13];break;default:q("invalid distance")}f=g;d[e++]=f[0];d[e++]=f[1];d[e++]=f[2];var h,k;h=0;for(k=d.length;h<k;++h)l[n++]=d[h];u[d[0]]++;w[d[3]]++;s=a.length+c-1;p=null}var b,e,f,g,k,h={},m,r,p,l=E?new Uint16Array(2*a.length):[],n=0,s=0,u=new (E?Uint32Array:Array)(286),w=new (E?Uint32Array:Array)(30),C=d.I,x;if(!E){for(f=0;285>=f;)u[f++]=0;for(f=0;29>=f;)w[f++]=0}u[256]=1;b=0;for(e=a.length;b<e;++b){f=k=0;
+for(g=3;f<g&&b+f!==e;++f)k=k<<8|a[b+f];h[k]===t&&(h[k]=[]);m=h[k];if(!(0<s--)){for(;0<m.length&&32768<b-m[0];)m.shift();if(b+3>=e){p&&c(p,-1);f=0;for(g=e-b;f<g;++f)x=a[b+f],l[n++]=x,++u[x];break}0<m.length?(r=Ca(a,b,m),p?p.length<r.length?(x=a[b-1],l[n++]=x,++u[x],c(r,0)):c(p,-1):r.length<C?p=r:c(r,0)):p?c(p,-1):(x=a[b],l[n++]=x,++u[x])}m.push(b)}l[n++]=256;u[256]++;d.V=u;d.U=w;return E?l.subarray(0,n):l}
+function Ca(d,a,c){var b,e,f=0,g,k,h,m,r=d.length;k=0;m=c.length;a:for(;k<m;k++){b=c[m-k-1];g=3;if(3<f){for(h=f;3<h;h--)if(d[b+h-1]!==d[a+h-1])continue a;g=f}for(;258>g&&a+g<r&&d[b+g]===d[a+g];)++g;g>f&&(e=b,f=g);if(258===g)break}return new ya(f,a-e)}
+function va(d,a){var c=d.length,b=new na(572),e=new (E?Uint8Array:Array)(c),f,g,k,h,m;if(!E)for(h=0;h<c;h++)e[h]=0;for(h=0;h<c;++h)0<d[h]&&b.push(h,d[h]);f=Array(b.length/2);g=new (E?Uint32Array:Array)(b.length/2);if(1===f.length)return e[b.pop().index]=1,e;h=0;for(m=b.length/2;h<m;++h)f[h]=b.pop(),g[h]=f[h].value;k=Da(g,g.length,a);h=0;for(m=f.length;h<m;++h)e[f[h].index]=k[h];return e}
+function Da(d,a,c){function b(c){var d=h[c][m[c]];d===a?(b(c+1),b(c+1)):--g[d];++m[c]}var e=new (E?Uint16Array:Array)(c),f=new (E?Uint8Array:Array)(c),g=new (E?Uint8Array:Array)(a),k=Array(c),h=Array(c),m=Array(c),r=(1<<c)-a,p=1<<c-1,l,n,s,u,w;e[c-1]=a;for(n=0;n<c;++n)r<p?f[n]=0:(f[n]=1,r-=p),r<<=1,e[c-2-n]=(e[c-1-n]/2|0)+a;e[0]=f[0];k[0]=Array(e[0]);h[0]=Array(e[0]);for(n=1;n<c;++n)e[n]>2*e[n-1]+f[n]&&(e[n]=2*e[n-1]+f[n]),k[n]=Array(e[n]),h[n]=Array(e[n]);for(l=0;l<a;++l)g[l]=c;for(s=0;s<e[c-1];++s)k[c-
+1][s]=d[s],h[c-1][s]=s;for(l=0;l<c;++l)m[l]=0;1===f[c-1]&&(--g[0],++m[c-1]);for(n=c-2;0<=n;--n){u=l=0;w=m[n+1];for(s=0;s<e[n];s++)u=k[n+1][w]+k[n+1][w+1],u>d[l]?(k[n][s]=u,h[n][s]=a,w+=2):(k[n][s]=d[l],h[n][s]=l,++l);m[n]=0;1===f[n]&&b(n)}return g}
+function wa(d){var a=new (E?Uint16Array:Array)(d.length),c=[],b=[],e=0,f,g,k,h;f=0;for(g=d.length;f<g;f++)c[d[f]]=(c[d[f]]|0)+1;f=1;for(g=16;f<=g;f++)b[f]=e,e+=c[f]|0,e<<=1;f=0;for(g=d.length;f<g;f++){e=b[d[f]];b[d[f]]+=1;k=a[f]=0;for(h=d[f];k<h;k++)a[f]=a[f]<<1|e&1,e>>>=1}return a};function Ea(d,a){this.input=d;this.b=this.c=0;this.i={};a&&(a.flags&&(this.i=a.flags),"string"===typeof a.filename&&(this.filename=a.filename),"string"===typeof a.comment&&(this.A=a.comment),a.deflateOptions&&(this.l=a.deflateOptions));this.l||(this.l={})}
+Ea.prototype.g=function(){var d,a,c,b,e,f,g,k,h=new (E?Uint8Array:Array)(32768),m=0,r=this.input,p=this.c,l=this.filename,n=this.A;h[m++]=31;h[m++]=139;h[m++]=8;d=0;this.i.fname&&(d|=Fa);this.i.fcomment&&(d|=Ga);this.i.fhcrc&&(d|=Ha);h[m++]=d;a=(Date.now?Date.now():+new Date)/1E3|0;h[m++]=a&255;h[m++]=a>>>8&255;h[m++]=a>>>16&255;h[m++]=a>>>24&255;h[m++]=0;h[m++]=Ia;if(this.i.fname!==t){g=0;for(k=l.length;g<k;++g)f=l.charCodeAt(g),255<f&&(h[m++]=f>>>8&255),h[m++]=f&255;h[m++]=0}if(this.i.comment){g=
+0;for(k=n.length;g<k;++g)f=n.charCodeAt(g),255<f&&(h[m++]=f>>>8&255),h[m++]=f&255;h[m++]=0}this.i.fhcrc&&(c=la(h,0,m)&65535,h[m++]=c&255,h[m++]=c>>>8&255);this.l.outputBuffer=h;this.l.outputIndex=m;e=new oa(r,this.l);h=e.g();m=e.b;E&&(m+8>h.buffer.byteLength?(this.a=new Uint8Array(m+8),this.a.set(new Uint8Array(h.buffer)),h=this.a):h=new Uint8Array(h.buffer));b=la(r,t,t);h[m++]=b&255;h[m++]=b>>>8&255;h[m++]=b>>>16&255;h[m++]=b>>>24&255;k=r.length;h[m++]=k&255;h[m++]=k>>>8&255;h[m++]=k>>>16&255;h[m++]=
+k>>>24&255;this.c=p;E&&m<h.length&&(this.a=h=h.subarray(0,m));return h};var Ia=255,Ha=2,Fa=8,Ga=16;function W(d,a){this.p=[];this.q=32768;this.e=this.j=this.c=this.u=0;this.input=E?new Uint8Array(d):d;this.w=!1;this.r=Ja;this.L=!1;if(a||!(a={}))a.index&&(this.c=a.index),a.bufferSize&&(this.q=a.bufferSize),a.bufferType&&(this.r=a.bufferType),a.resize&&(this.L=a.resize);switch(this.r){case Ka:this.b=32768;this.a=new (E?Uint8Array:Array)(32768+this.q+258);break;case Ja:this.b=0;this.a=new (E?Uint8Array:Array)(this.q);this.f=this.T;this.B=this.Q;this.s=this.S;break;default:q(Error("invalid inflate mode"))}}
+var Ka=0,Ja=1,Ya={N:Ka,M:Ja};
+W.prototype.h=function(){for(;!this.w;){var d=X(this,3);d&1&&(this.w=v);d>>>=1;switch(d){case 0:var a=this.input,c=this.c,b=this.a,e=this.b,f=a.length,g=t,k=t,h=b.length,m=t;this.e=this.j=0;c+1>=f&&q(Error("invalid uncompressed block header: LEN"));g=a[c++]|a[c++]<<8;c+1>=f&&q(Error("invalid uncompressed block header: NLEN"));k=a[c++]|a[c++]<<8;g===~k&&q(Error("invalid uncompressed block header: length verify"));c+g>a.length&&q(Error("input buffer is broken"));switch(this.r){case Ka:for(;e+g>b.length;){m=
+h-e;g-=m;if(E)b.set(a.subarray(c,c+m),e),e+=m,c+=m;else for(;m--;)b[e++]=a[c++];this.b=e;b=this.f();e=this.b}break;case Ja:for(;e+g>b.length;)b=this.f({F:2});break;default:q(Error("invalid inflate mode"))}if(E)b.set(a.subarray(c,c+g),e),e+=g,c+=g;else for(;g--;)b[e++]=a[c++];this.c=c;this.b=e;this.a=b;break;case 1:this.s(Za,$a);break;case 2:for(var r=X(this,5)+257,p=X(this,5)+1,l=X(this,4)+4,n=new (E?Uint8Array:Array)(ab.length),s=t,u=t,w=t,C=t,x=t,D=t,N=t,z=t,O=t,z=0;z<l;++z)n[ab[z]]=X(this,3);if(!E){z=
+l;for(l=n.length;z<l;++z)n[ab[z]]=0}s=U(n);C=new (E?Uint8Array:Array)(r+p);z=0;for(O=r+p;z<O;)switch(x=bb(this,s),x){case 16:for(N=3+X(this,2);N--;)C[z++]=D;break;case 17:for(N=3+X(this,3);N--;)C[z++]=0;D=0;break;case 18:for(N=11+X(this,7);N--;)C[z++]=0;D=0;break;default:D=C[z++]=x}u=E?U(C.subarray(0,r)):U(C.slice(0,r));w=E?U(C.subarray(r)):U(C.slice(r));this.s(u,w);break;default:q(Error("unknown BTYPE: "+d))}}return this.B()};
+var cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ab=E?new Uint16Array(cb):cb,db=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],eb=E?new Uint16Array(db):db,fb=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],gb=E?new Uint8Array(fb):fb,hb=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ib=E?new Uint16Array(hb):hb,jb=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,
+10,11,11,12,12,13,13],kb=E?new Uint8Array(jb):jb,lb=new (E?Uint8Array:Array)(288),Y,mb;Y=0;for(mb=lb.length;Y<mb;++Y)lb[Y]=143>=Y?8:255>=Y?9:279>=Y?7:8;var Za=U(lb),nb=new (E?Uint8Array:Array)(30),ob,qb;ob=0;for(qb=nb.length;ob<qb;++ob)nb[ob]=5;var $a=U(nb);function X(d,a){for(var c=d.j,b=d.e,e=d.input,f=d.c,g=e.length,k;b<a;)f>=g&&q(Error("input buffer is broken")),c|=e[f++]<<b,b+=8;k=c&(1<<a)-1;d.j=c>>>a;d.e=b-a;d.c=f;return k}
+function bb(d,a){for(var c=d.j,b=d.e,e=d.input,f=d.c,g=e.length,k=a[0],h=a[1],m,r;b<h&&!(f>=g);)c|=e[f++]<<b,b+=8;m=k[c&(1<<h)-1];r=m>>>16;r>b&&q(Error("invalid code length: "+r));d.j=c>>r;d.e=b-r;d.c=f;return m&65535}
+W.prototype.s=function(d,a){var c=this.a,b=this.b;this.C=d;for(var e=c.length-258,f,g,k,h;256!==(f=bb(this,d));)if(256>f)b>=e&&(this.b=b,c=this.f(),b=this.b),c[b++]=f;else{g=f-257;h=eb[g];0<gb[g]&&(h+=X(this,gb[g]));f=bb(this,a);k=ib[f];0<kb[f]&&(k+=X(this,kb[f]));b>=e&&(this.b=b,c=this.f(),b=this.b);for(;h--;)c[b]=c[b++-k]}for(;8<=this.e;)this.e-=8,this.c--;this.b=b};
+W.prototype.S=function(d,a){var c=this.a,b=this.b;this.C=d;for(var e=c.length,f,g,k,h;256!==(f=bb(this,d));)if(256>f)b>=e&&(c=this.f(),e=c.length),c[b++]=f;else{g=f-257;h=eb[g];0<gb[g]&&(h+=X(this,gb[g]));f=bb(this,a);k=ib[f];0<kb[f]&&(k+=X(this,kb[f]));b+h>e&&(c=this.f(),e=c.length);for(;h--;)c[b]=c[b++-k]}for(;8<=this.e;)this.e-=8,this.c--;this.b=b};
+W.prototype.f=function(){var d=new (E?Uint8Array:Array)(this.b-32768),a=this.b-32768,c,b,e=this.a;if(E)d.set(e.subarray(32768,d.length));else{c=0;for(b=d.length;c<b;++c)d[c]=e[c+32768]}this.p.push(d);this.u+=d.length;if(E)e.set(e.subarray(a,a+32768));else for(c=0;32768>c;++c)e[c]=e[a+c];this.b=32768;return e};
+W.prototype.T=function(d){var a,c=this.input.length/this.c+1|0,b,e,f,g=this.input,k=this.a;d&&("number"===typeof d.F&&(c=d.F),"number"===typeof d.O&&(c+=d.O));2>c?(b=(g.length-this.c)/this.C[2],f=258*(b/2)|0,e=f<k.length?k.length+f:k.length<<1):e=k.length*c;E?(a=new Uint8Array(e),a.set(k)):a=k;return this.a=a};
+W.prototype.B=function(){var d=0,a=this.a,c=this.p,b,e=new (E?Uint8Array:Array)(this.u+(this.b-32768)),f,g,k,h;if(0===c.length)return E?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);f=0;for(g=c.length;f<g;++f){b=c[f];k=0;for(h=b.length;k<h;++k)e[d++]=b[k]}f=32768;for(g=this.b;f<g;++f)e[d++]=a[f];this.p=[];return this.buffer=e};
+W.prototype.Q=function(){var d,a=this.b;E?this.L?(d=new Uint8Array(a),d.set(this.a.subarray(0,a))):d=this.a.subarray(0,a):(this.a.length>a&&(this.a.length=a),d=this.a);return this.buffer=d};function rb(d){this.input=d;this.c=0;this.t=[];this.D=!1}rb.prototype.W=function(){this.D||this.h();return this.t.slice()};
+rb.prototype.h=function(){for(var d=this.input.length;this.c<d;){var a=new T,c=t,b=t,e=t,f=t,g=t,k=t,h=t,m=t,r=t,p=this.input,l=this.c;a.G=p[l++];a.H=p[l++];(31!==a.G||139!==a.H)&&q(Error("invalid file signature:"+a.G+","+a.H));a.z=p[l++];switch(a.z){case 8:break;default:q(Error("unknown compression method: "+a.z))}a.n=p[l++];m=p[l++]|p[l++]<<8|p[l++]<<16|p[l++]<<24;a.Y=new Date(1E3*m);a.ea=p[l++];a.da=p[l++];0<(a.n&4)&&(a.$=p[l++]|p[l++]<<8,l+=a.$);if(0<(a.n&Fa)){h=[];for(k=0;0<(g=p[l++]);)h[k++]=
+String.fromCharCode(g);a.name=h.join("")}if(0<(a.n&Ga)){h=[];for(k=0;0<(g=p[l++]);)h[k++]=String.fromCharCode(g);a.A=h.join("")}0<(a.n&Ha)&&(a.R=la(p,0,l)&65535,a.R!==(p[l++]|p[l++]<<8)&&q(Error("invalid header crc16")));c=p[p.length-4]|p[p.length-3]<<8|p[p.length-2]<<16|p[p.length-1]<<24;p.length-l-4-4<512*c&&(f=c);b=new W(p,{index:l,bufferSize:f});a.data=e=b.h();l=b.c;a.ba=r=(p[l++]|p[l++]<<8|p[l++]<<16|p[l++]<<24)>>>0;la(e,t,t)!==r&&q(Error("invalid CRC-32 checksum: 0x"+la(e,t,t).toString(16)+
+" / 0x"+r.toString(16)));a.ca=c=(p[l++]|p[l++]<<8|p[l++]<<16|p[l++]<<24)>>>0;(e.length&4294967295)!==c&&q(Error("invalid input size: "+(e.length&4294967295)+" / "+c));this.t.push(a);this.c=l}this.D=v;var n=this.t,s,u,w=0,C=0,x;s=0;for(u=n.length;s<u;++s)C+=n[s].data.length;if(E){x=new Uint8Array(C);for(s=0;s<u;++s)x.set(n[s].data,w),w+=n[s].data.length}else{x=[];for(s=0;s<u;++s)x[s]=n[s].data;x=Array.prototype.concat.apply([],x)}return x};function sb(d){if("string"===typeof d){var a=d.split(""),c,b;c=0;for(b=a.length;c<b;c++)a[c]=(a[c].charCodeAt(0)&255)>>>0;d=a}for(var e=1,f=0,g=d.length,k,h=0;0<g;){k=1024<g?1024:g;g-=k;do e+=d[h++],f+=e;while(--k);e%=65521;f%=65521}return(f<<16|e)>>>0};function tb(d,a){var c,b;this.input=d;this.c=0;if(a||!(a={}))a.index&&(this.c=a.index),a.verify&&(this.Z=a.verify);c=d[this.c++];b=d[this.c++];switch(c&15){case ub:this.method=ub;break;default:q(Error("unsupported compression method"))}0!==((c<<8)+b)%31&&q(Error("invalid fcheck flag:"+((c<<8)+b)%31));b&32&&q(Error("fdict flag is not supported"));this.K=new W(d,{index:this.c,bufferSize:a.bufferSize,bufferType:a.bufferType,resize:a.resize})}
+tb.prototype.h=function(){var d=this.input,a,c;a=this.K.h();this.c=this.K.c;this.Z&&(c=(d[this.c++]<<24|d[this.c++]<<16|d[this.c++]<<8|d[this.c++])>>>0,c!==sb(a)&&q(Error("invalid adler-32 checksum")));return a};var ub=8;function vb(d,a){this.input=d;this.a=new (E?Uint8Array:Array)(32768);this.k=Z.o;var c={},b;if((a||!(a={}))&&"number"===typeof a.compressionType)this.k=a.compressionType;for(b in a)c[b]=a[b];c.outputBuffer=this.a;this.J=new oa(this.input,c)}var Z=sa;
+vb.prototype.g=function(){var d,a,c,b,e,f,g,k=0;g=this.a;d=ub;switch(d){case ub:a=Math.LOG2E*Math.log(32768)-8;break;default:q(Error("invalid compression method"))}c=a<<4|d;g[k++]=c;switch(d){case ub:switch(this.k){case Z.NONE:e=0;break;case Z.v:e=1;break;case Z.o:e=2;break;default:q(Error("unsupported compression type"))}break;default:q(Error("invalid compression method"))}b=e<<6|0;g[k++]=b|31-(256*c+b)%31;f=sb(this.input);this.J.b=k;g=this.J.g();k=g.length;E&&(g=new Uint8Array(g.buffer),g.length<=
+k+4&&(this.a=new Uint8Array(g.length+4),this.a.set(g),g=this.a),g=g.subarray(0,k+4));g[k++]=f>>24&255;g[k++]=f>>16&255;g[k++]=f>>8&255;g[k++]=f&255;return g};function wb(d,a){var c,b,e,f;if(Object.keys)c=Object.keys(a);else for(b in c=[],e=0,a)c[e++]=b;e=0;for(f=c.length;e<f;++e)b=c[e],B(d+"."+b,a[b])};B("Zlib.Inflate",tb);B("Zlib.Inflate.prototype.decompress",tb.prototype.h);wb("Zlib.Inflate.BufferType",{ADAPTIVE:Ya.M,BLOCK:Ya.N});B("Zlib.Deflate",vb);B("Zlib.Deflate.compress",function(d,a){return(new vb(d,a)).g()});B("Zlib.Deflate.prototype.compress",vb.prototype.g);wb("Zlib.Deflate.CompressionType",{NONE:Z.NONE,FIXED:Z.v,DYNAMIC:Z.o});B("Zlib.Gzip",Ea);B("Zlib.Gzip.prototype.compress",Ea.prototype.g);B("Zlib.Gunzip",rb);B("Zlib.Gunzip.prototype.decompress",rb.prototype.h);B("Zlib.Gunzip.prototype.getMembers",rb.prototype.W);B("Zlib.GunzipMember",T);B("Zlib.GunzipMember.prototype.getName",T.prototype.getName);B("Zlib.GunzipMember.prototype.getData",T.prototype.getData);B("Zlib.GunzipMember.prototype.getMtime",T.prototype.X);}).call(this);