brotli/js/decode.min.js

1 line
149 KiB
JavaScript
Raw Normal View History

window.BrotliDecode=function(){"use strict";function e(e){this.data=e,this.offset=0}function t(e){if(e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16),0==S(e,1))return 16;var t=S(e,3);return 0!=t?17+t:0!=(t=S(e,3))?8+t:17}function i(e,i){if(0!=e.l)throw"State MUST be uninitialized";e.h=new Int32Array(6480),e.input=i,z(e);var n=t(e);if(9==n)throw"Invalid 'windowBits' code";e.p=1<<n,e.u=e.p-16,e.l=1}function n(e){if(0==e.l)throw"State MUST be initialized";11!=e.l&&(e.l=11,null!=e.input&&(e.input,e.input=null))}function a(e){if(e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16),0!=S(e,1)){var t=S(e,3);return 0==t?1:S(e,t)+(1<<t)}return 0}function o(e){if(e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16),e.m=S(e,1),e.g=0,e.P=0,e.$=0,0==e.m||0==S(e,1)){var t=S(e,2)+4;if(7==t){if(e.$=1,0!=S(e,1))throw"Corrupted reserved bit";var i=S(e,2);if(0==i)return;for(n=0;n<i;n++){if(e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16),0==(a=S(e,8))&&n+1==i&&i>1)throw"Exuberant nibble";e.g|=a<<8*n}}else for(var n=0;n<t;n++){e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16);var a=S(e,4);if(0==a&&n+1==t&&t>4)throw"Exuberant nibble";e.g|=a<<4*n}e.g++,0==e.m&&(e.P=S(e,1))}}function r(e,t,i){var n=i.i>>>i.t,a=e[t+=255&n]>>16,o=65535&e[t];return a<=8?(i.t+=a,o):(t+=o,t+=(n&(1<<a)-1)>>>8,i.t+=8+(e[t]>>16),65535&e[t])}function s(e,t,i){i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16);var n=r(e,t,i),a=ee[n];return i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16),Z[n]+(a<=16?S(i,a):E(i,a))}function l(e,t,i){return e<16?(i+=_[e],i&=3,t[i]+G[e]):e-16+1}function c(e,t){for(var i=e[t];t>0;t--)e[t]=e[t-1];e[0]=i}function d(e,t){for(var i=new Int32Array(256),n=0;n<256;n++)i[n]=n;for(n=0;n<t;n++){var a=255&e[n];e[n]=i[a],0!=a&&c(i,a)}}function h(e,t,i,n){var a=0,o=8,r=0,s=0,l=32768,c=new Int32Array(32);for(q(c,0,5,e,18);a<t&&l>0;){n.s>2030&&I(n),n.t>=16&&(n.i=n.o[n.s++]<<16|n.i>>>16,n.t-=16);var d=n.i>>>n.t&31;n.t+=c[d]>>16;var h=65535&c[d];if(h<16)r=0,i[a++]=h,0!=h&&(o=h,l-=32768>>h);else{var f=h-14,p=0;16==h&&(p=o),s!=p&&(r=0,s=p);var u=r;r>0&&(r-=2,r<<=f),n.t>=16&&(n.i=n.o[n.s++]<<16|n.i>>>16,n.t-=16);var m=(r+=S(n,f)+3)-u;if(a+m>t)throw"symbol + repeatDelta > numSymbols";for(var g=0;g<m;g++)i[a++]=s;0!=s&&(l-=m<<15-s)}}if(0!=l)throw"Unused space";i.fill(0,a,t)}function f(e,t){for(var i=0;i<t-1;++i)for(var n=i+1;n<t;++n)if(e[i]==e[n])return 0;return 1}function p(e,t,i,n){var a,o=1;n.s>2030&&I(n);var r=new Int32Array(e);if(n.t>=16&&(n.i=n.o[n.s++]<<16|n.i>>>16,n.t-=16),1==(a=S(n,2))){for(var s=e-1,l=0,c=new Int32Array(4),d=S(n,2)+1;0!=s;)s>>=1,l++;for(g=0;g<d;g++)n.t>=16&&(n.i=n.o[n.s++]<<16|n.i>>>16,n.t-=16),c[g]=S(n,l)%e,r[c[g]]=2;switch(r[c[0]]=1,d){case 2:r[c[1]]=1;break;case 4:1==S(n,1)?(r[c[2]]=3,r[c[3]]=3):r[c[0]]=2}o=f(c,d)}else{for(var p=new Int32Array(18),u=32,m=0,g=a;g<18&&u>0;g++){var P=W[g];n.t>=16&&(n.i=n.o[n.s++]<<16|n.i>>>16,n.t-=16);var $=n.i>>>n.t&15;n.t+=J[$]>>16;var b=65535&J[$];p[P]=b,0!=b&&(u-=32>>b,m++)}0!=u&&1!=m&&(o=0),h(p,e,r,n)}if(0==o)throw"Can't readHuffmanCode";q(t,i,8,r,e)}function u(e,t,i){i.s>2030&&I(i);var n=a(i)+1;if(1==n)return t.fill(0,0,e),n;i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16);var o=0;0!=S(i,1)&&(o=S(i,4)+1);var s=new Int32Array(1080);p(n+o,s,0,i);for(var l=0;l<e;){i.s>2030&&I(i),i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16);var c=r(s,0,i);if(0==c)t[l]=0,l++;else if(c<=o){i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16);for(var h=(1<<c)+S(i,c);0!=h;){if(l>=e)throw"Corrupted context map";t[l]=0,l++,h--}}else t[l]=c-o,l++}return i.t>=16&&(i.i=i.o[i.s++]<<16|i.i>>>16,i.t-=16),1==S(i,1)&&d(t,e),n}function m(e,t,i){var n=e.v,a=4+2*t;e.t>=16&&(e.i=e.o[e.s++]<<16|e.i>>>16,e.t-=16);var o=r(e.h,1080*t,e),l=s(e.h,1080*(t+3),e);return 1==o?o=n[a+1]+1:0==o?o=n[a]:o-=2,o>=i&&(o-=i),n[a]=n[a+1],n[a+1]=o,l}function g(e){e.X=m(e,0,e.Y);var t=e.v[5];e.k=t<<6,e.C=255&e.j[e.k],e.A=e.q[e.C];var i=e.I[t];e.T=i<<9,e.S=e.T+256}function P(e){e.D=m(e,1,e.F),e.N=e.B[e.v[7]]}function $(e){e.M=m(e,2,e.U),e.H=e.v[9]<<2}function b(e){var t=e.p;if(t>e.R){for(var i=e.R;t>>1>i;)t>>=1;0==e.m&&t<16384&&e.p>=16384&&(t=16384)}if(!(t<=e.O)){var n=t+37,a=new Int8Arr