@woosh/meep-engine 2.69.0 → 2.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +498 -429
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +498 -429
- package/package.json +1 -1
- package/src/core/__module.js +1 -0
- package/src/core/binary/BinaryBuffer.js +37 -31
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +21 -24
- package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +2 -4
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +3 -2
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +34 -0
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +2 -1
- package/src/core/geom/3d/quaternion/quat3_createFromAxisAngle.js +11 -0
- package/src/core/geom/3d/quaternion/quat_decode_from_uint32.js +53 -0
- package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +105 -0
- package/src/core/geom/Quaternion.js +8 -142
- package/src/core/geom/Vector2.js +6 -7
- package/src/core/geom/Vector3.js +15 -82
- package/src/core/geom/vec3/v3_binary_equality_decode.js +44 -0
- package/src/core/geom/vec3/v3_binary_equality_encode.js +47 -0
- package/src/core/math/remap.js +5 -1
- package/src/core/math/statistics/computeStatisticalPartialMedian.js +1 -1
- package/src/core/primitives/numbers/computeHashFloat.js +2 -2
- package/src/core/process/task/Task.js +53 -34
- package/src/engine/achievements/AchievementManager.js +19 -19
- package/src/engine/animation/curve/compression/prototypeCurveCompression.js +6 -6
- package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +11 -6
- package/src/engine/ecs/dynamic_actions/DynamicActor.js +5 -10
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +82 -89
- package/src/engine/ecs/dynamic_actions/RuleExecution.js +10 -12
- package/src/engine/ecs/gui/GUIElement.js +44 -61
- package/src/engine/ecs/gui/GUIElementSystem.js +26 -24
- package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +12 -15
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +15 -15
- package/src/engine/ecs/gui/parallax/GuiElementParallax.js +3 -3
- package/src/engine/ecs/gui/parallax/GuiElementParallaxSystem.js +2 -2
- package/src/engine/ecs/gui/position/ViewportPosition.js +5 -50
- package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.js +42 -0
- package/src/engine/ecs/transform/Transform.js +8 -9
- package/src/engine/ecs/transform/TransformSerializationAdapter.js +20 -14
- package/src/engine/graphics/ecs/mesh/Mesh.js +11 -11
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +20 -20
- package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +12 -12
- package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +1 -4
- package/src/core/binary/ValidatingBitSetWrapper.js +0 -81
- package/src/core/binary/jsonToStringToByteArray.js +0 -27
- package/src/engine/ecs/components/AreaOfEffect.js +0 -12
- package/src/engine/ecs/components/Mortality.js +0 -27
- package/src/engine/ecs/systems/AreaOfEffectSystem.js +0 -48
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([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]),i=new Uint8Array([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]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),a=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new Array(576);t(r);const s=new Array(60);t(s);const o=new Array(512);t(o);const h=new Array(256);t(h);const l=new Array(29);t(l);const d=new Array(30);function c(t,e,i,n,a){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=a,this.has_stree=t&&t.length}let f,u,_;function p(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const w=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},b=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,g(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},m=(t,e,i)=>{b(t,i[2*e],i[2*e+1])},y=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},k=(t,e,i)=>{const n=new Array(16);let a,r,s=0;for(a=1;a<=15;a++)n[a]=s=s+i[a-1]<<1;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=y(n[e]++,e))}},v=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},x=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},U=(t,e,i,n)=>{const a=2*e,r=2*i;return t[a]<t[r]||t[a]===t[r]&&n[e]<=n[i]},E=(t,e,i)=>{const n=t.heap[i];let a=i<<1;for(;a<=t.heap_len&&(a<t.heap_len&&U(e,t.heap[a+1],t.heap[a],t.depth)&&a++,!U(e,n,t.heap[a],t.depth));)t.heap[i]=t.heap[a],i=a,a<<=1;t.heap[i]=n},A=(t,n,a)=>{let r,s,o,c,f=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],s=t.pending_buf[t.l_buf+f],f++,0===r?m(t,s,n):(o=h[s],m(t,o+256+1,n),c=e[o],0!==c&&(s-=l[o],b(t,s,c)),r--,o=w(r),m(t,o,a),c=i[o],0!==c&&(r-=d[o],b(t,r,c)))}while(f<t.last_lit);m(t,256,n)},z=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,r=e.stat_desc.elems;let s,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<r;s++)0!==i[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):i[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,i[2*h]=1,t.depth[h]=0,t.opt_len--,a&&(t.static_len-=n[2*h+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)E(t,i,s);h=r;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],E(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=o,i[2*h]=i[2*s]+i[2*o],t.depth[h]=(t.depth[s]>=t.depth[o]?t.depth[s]:t.depth[o])+1,i[2*s+1]=i[2*o+1]=h,t.heap[1]=h++,E(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,a=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,c,f,u,_,p=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],f=i[2*i[2*d+1]+1]+1,f>h&&(f=h,p++),i[2*d+1]=f,d>n||(t.bl_count[f]++,u=0,d>=o&&(u=s[d-o]),_=i[2*d],t.opt_len+=_*(f+u),r&&(t.static_len+=_*(a[2*d+1]+u)));if(0!==p){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(f=h;0!==f;f--)for(d=t.bl_count[f];0!==d;)c=t.heap[--l],c>n||(i[2*c+1]!==f&&(t.opt_len+=(f-i[2*c+1])*i[2*c],i[2*c+1]=f),d--)}})(t,e),k(i,l,t.bl_count)},I=(t,e,i)=>{let n,a,r=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)a=s,s=e[2*(n+1)+1],++o<h&&a===s||(o<l?t.bl_tree[2*a]+=o:0!==a?(a!==r&&t.bl_tree[2*a]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,r=a,0===s?(h=138,l=3):a===s?(h=6,l=3):(h=7,l=4))},S=(t,e,i)=>{let n,a,r=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=i;n++)if(a=s,s=e[2*(n+1)+1],!(++o<h&&a===s)){if(o<l)do{m(t,a,t.bl_tree)}while(0!=--o);else 0!==a?(a!==r&&(m(t,a,t.bl_tree),o--),m(t,16,t.bl_tree),b(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),b(t,o-3,3)):(m(t,18,t.bl_tree),b(t,o-11,7));o=0,r=a,0===s?(h=138,l=3):a===s?(h=6,l=3):(h=7,l=4)}};let T=!1;const R=(t,e,i,n)=>{b(t,0+(n?1:0),3),((t,e,i,n)=>{x(t),g(t,i),g(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var C={_tr_init:t=>{T||((()=>{let t,a,p,w,g;const b=new Array(16);for(p=0,w=0;w<28;w++)for(l[w]=p,t=0;t<1<<e[w];t++)h[p++]=w;for(h[p-1]=w,g=0,w=0;w<16;w++)for(d[w]=g,t=0;t<1<<i[w];t++)o[g++]=w;for(g>>=7;w<30;w++)for(d[w]=g<<7,t=0;t<1<<i[w]-7;t++)o[256+g++]=w;for(a=0;a<=15;a++)b[a]=0;for(t=0;t<=143;)r[2*t+1]=8,t++,b[8]++;for(;t<=255;)r[2*t+1]=9,t++,b[9]++;for(;t<=279;)r[2*t+1]=7,t++,b[7]++;for(;t<=287;)r[2*t+1]=8,t++,b[8]++;for(k(r,287,b),t=0;t<30;t++)s[2*t+1]=5,s[2*t]=y(t,5);f=new c(r,e,257,286,15),u=new c(s,i,0,30,15),_=new c(new Array(0),n,0,19,7)})(),T=!0),t.l_desc=new p(t.dyn_ltree,f),t.d_desc=new p(t.dyn_dtree,u),t.bl_desc=new p(t.bl_tree,_),t.bi_buf=0,t.bi_valid=0,v(t)},_tr_stored_block:R,_tr_flush_block:(t,e,i,n)=>{let o,h,l=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),z(t,t.l_desc),z(t,t.d_desc),l=(t=>{let e;for(I(t,t.dyn_ltree,t.l_desc.max_code),I(t,t.dyn_dtree,t.d_desc.max_code),z(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*a[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,h=t.static_len+3+7>>>3,h<=o&&(o=h)):o=h=i+5,i+4<=o&&-1!==e?R(t,e,i,n):4===t.strategy||h===o?(b(t,2+(n?1:0),3),A(t,r,s)):(b(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(b(t,e-257,5),b(t,i-1,5),b(t,n-4,4),r=0;r<n;r++)b(t,t.bl_tree[2*a[r]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,l+1),A(t,t.dyn_ltree,t.dyn_dtree)),v(t),n&&x(t)},_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(h[i]+256+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{b(t,2,3),m(t,256,r),(t=>{16===t.bi_valid?(g(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},F=(t,e,i,n)=>{let a=65535&t|0,r=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{a=a+e[n++]|0,r=r+a|0}while(--s);a%=65521,r%=65521}return a|r<<16|0};const N=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var D=(t,e,i,n)=>{const a=N,r=n+i;t^=-1;for(let i=n;i<r;i++)t=t>>>8^a[255&(t^e[i])];return-1^t},B={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Z={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:L,_tr_stored_block:O,_tr_flush_block:V,_tr_tally:M,_tr_align:$}=C,{Z_NO_FLUSH:H,Z_PARTIAL_FLUSH:P,Z_FULL_FLUSH:j,Z_FINISH:G,Z_BLOCK:K,Z_OK:Y,Z_STREAM_END:q,Z_STREAM_ERROR:W,Z_DATA_ERROR:X,Z_BUF_ERROR:J,Z_DEFAULT_COMPRESSION:Q,Z_FILTERED:tt,Z_HUFFMAN_ONLY:et,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:at,Z_UNKNOWN:rt,Z_DEFLATED:st}=Z,ot=258,ht=262,lt=103,dt=113,ct=666,ft=(t,e)=>(t.msg=B[e],e),ut=t=>(t<<1)-(t>4?9:0),_t=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const wt=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},gt=(t,e)=>{V(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,wt(t.strm)},bt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,n)=>{let a=t.avail_in;return a>n&&(a=n),0===a?0:(t.avail_in-=a,e.set(t.input.subarray(t.next_in,t.next_in+a),i),1===t.state.wrap?t.adler=F(t.adler,e,a,i):2===t.state.wrap&&(t.adler=D(t.adler,e,a,i)),t.next_in+=a,t.total_in+=a,a)},kt=(t,e)=>{let i,n,a=t.max_chain_length,r=t.strstart,s=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-ht?t.strstart-(t.w_size-ht):0,l=t.window,d=t.w_mask,c=t.prev,f=t.strstart+ot;let u=l[r+s-1],_=l[r+s];t.prev_length>=t.good_match&&(a>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+s]===_&&l[i+s-1]===u&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do{}while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(n=ot-(f-r),r=f-ot,n>s){if(t.match_start=e,s=n,n>=o)break;u=l[r+s-1],_=l[r+s]}}}while((e=c[e&d])>h&&0!=--a);return s<=t.lookahead?s:t.lookahead},vt=t=>{const e=t.w_size;let i,n,a,r,s;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ht)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{a=t.head[--i],t.head[i]=a>=e?a-e:0}while(--n);n=e,i=n;do{a=t.prev[--i],t.prev[i]=a>=e?a-e:0}while(--n);r+=e}if(0===t.strm.avail_in)break;if(n=yt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ht&&0!==t.strm.avail_in)},xt=(t,e)=>{let i,n;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i)),t.match_length>=3)if(n=M(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else n=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2},Ut=(t,e)=>{let i,n,a;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i),t.match_length<=5&&(t.strategy===tt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,n=M(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(gt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=M(t,0,t.window[t.strstart-1]),n&>(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=M(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,i,n,a){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=a}const At=[new Et(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(vt(t),0===t.lookahead&&e===H)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,gt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ht&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(gt(t,!1),t.strm.avail_out),1)})),new Et(4,4,8,4,xt),new Et(4,5,16,8,xt),new Et(4,6,32,32,xt),new Et(4,4,16,16,Ut),new Et(8,16,32,32,Ut),new Et(8,16,128,128,Ut),new Et(8,32,128,256,Ut),new Et(32,128,258,1024,Ut),new Et(32,258,258,4096,Ut)];function zt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=st,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_t(this.dyn_ltree),_t(this.dyn_dtree),_t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_t(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const It=t=>{if(!t||!t.state)return ft(t,W);t.total_in=t.total_out=0,t.data_type=rt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:dt,t.adler=2===e.wrap?0:1,e.last_flush=H,L(e),Y},St=t=>{const e=It(t);var i;return e===Y&&((i=t.state).window_size=2*i.w_size,_t(i.head),i.max_lazy_match=At[i.level].max_lazy,i.good_match=At[i.level].good_length,i.nice_match=At[i.level].nice_length,i.max_chain_length=At[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Tt=(t,e,i,n,a,r)=>{if(!t)return W;let s=1;if(e===Q&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),a<1||a>9||i!==st||n<8||n>15||e<0||e>9||r<0||r>nt)return ft(t,W);8===n&&(n=9);const o=new zt;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=r,o.method=i,St(t)};var Rt={deflateInit:(t,e)=>Tt(t,e,st,15,8,at),deflateInit2:Tt,deflateReset:St,deflateResetKeep:It,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?W:(t.state.gzhead=e,Y):W,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>K||e<0)return t?ft(t,W):W;const a=t.state;if(!t.output||!t.input&&0!==t.avail_in||a.status===ct&&e!==G)return ft(t,0===t.avail_out?J:W);a.strm=t;const r=a.last_flush;if(a.last_flush=e,42===a.status)if(2===a.wrap)t.adler=0,bt(a,31),bt(a,139),bt(a,8),a.gzhead?(bt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),bt(a,255&a.gzhead.time),bt(a,a.gzhead.time>>8&255),bt(a,a.gzhead.time>>16&255),bt(a,a.gzhead.time>>24&255),bt(a,9===a.level?2:a.strategy>=et||a.level<2?4:0),bt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(bt(a,255&a.gzhead.extra.length),bt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=D(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69):(bt(a,0),bt(a,0),bt(a,0),bt(a,0),bt(a,0),bt(a,9===a.level?2:a.strategy>=et||a.level<2?4:0),bt(a,3),a.status=dt);else{let e=st+(a.w_bits-8<<4)<<8,i=-1;i=a.strategy>=et||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,a.status=dt,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1}if(69===a.status)if(a.gzhead.extra){for(i=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending!==a.pending_buf_size));)bt(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=73)}else a.status=73;if(73===a.status)if(a.gzhead.name){i=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending===a.pending_buf_size)){n=1;break}n=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,bt(a,n)}while(0!==n);a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),0===n&&(a.gzindex=0,a.status=91)}else a.status=91;if(91===a.status)if(a.gzhead.comment){i=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending===a.pending_buf_size)){n=1;break}n=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,bt(a,n)}while(0!==n);a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),0===n&&(a.status=lt)}else a.status=lt;if(a.status===lt&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&wt(t),a.pending+2<=a.pending_buf_size&&(bt(a,255&t.adler),bt(a,t.adler>>8&255),t.adler=0,a.status=dt)):a.status=dt),0!==a.pending){if(wt(t),0===t.avail_out)return a.last_flush=-1,Y}else if(0===t.avail_in&&ut(e)<=ut(r)&&e!==G)return ft(t,J);if(a.status===ct&&0!==t.avail_in)return ft(t,J);if(0!==t.avail_in||0!==a.lookahead||e!==H&&a.status!==ct){let i=a.strategy===et?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(vt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.strategy===it?((t,e)=>{let i,n,a,r;const s=t.window;for(;;){if(t.lookahead<=ot){if(vt(t),t.lookahead<=ot&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(a=t.strstart-1,n=s[a],n===s[++a]&&n===s[++a]&&n===s[++a])){r=t.strstart+ot;do{}while(n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&a<r);t.match_length=ot-(r-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=M(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(a,e):At[a.level].func(a,e);if(3!==i&&4!==i||(a.status=ct),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),Y;if(2===i&&(e===P?$(a):e!==K&&(O(a,0,0,!1),e===j&&(_t(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),wt(t),0===t.avail_out))return a.last_flush=-1,Y}return e!==G?Y:a.wrap<=0?q:(2===a.wrap?(bt(a,255&t.adler),bt(a,t.adler>>8&255),bt(a,t.adler>>16&255),bt(a,t.adler>>24&255),bt(a,255&t.total_in),bt(a,t.total_in>>8&255),bt(a,t.total_in>>16&255),bt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),wt(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?Y:q)},deflateEnd:t=>{if(!t||!t.state)return W;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==lt&&e!==dt&&e!==ct?ft(t,W):(t.state=null,e===dt?ft(t,X):Y)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return W;const n=t.state,a=n.wrap;if(2===a||1===a&&42!==n.status||n.lookahead)return W;if(1===a&&(t.adler=F(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===a&&(_t(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const r=t.avail_in,s=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,vt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=pt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,vt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=o,t.avail_in=r,n.wrap=a,Y},deflateInfo:"pako deflate (from Nodeca project)"};const Ct=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ft={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Ct(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,a=t.length;e<a;e++){let a=t[e];i.set(a,n),n+=a.length}return i}};let Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Dt=new Uint8Array(256);for(let t=0;t<256;t++)Dt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Dt[254]=Dt[254]=1;var Bt={string2buf:t=>{let e,i,n,a,r,s=t.length,o=0;for(a=0;a<s;a++)i=t.charCodeAt(a),55296==(64512&i)&&a+1<s&&(n=t.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),r=0,a=0;r<o;a++)i=t.charCodeAt(a),55296==(64512&i)&&a+1<s&&(n=t.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),i<128?e[r++]=i:i<2048?(e[r++]=192|i>>>6,e[r++]=128|63&i):i<65536?(e[r++]=224|i>>>12,e[r++]=128|i>>>6&63,e[r++]=128|63&i):(e[r++]=240|i>>>18,e[r++]=128|i>>>12&63,e[r++]=128|i>>>6&63,e[r++]=128|63&i);return e},buf2string:(t,e)=>{let i,n;const a=e||t.length,r=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){r[n++]=e;continue}let s=Dt[e];if(s>4)r[n++]=65533,i+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&i<a;)e=e<<6|63&t[i++],s--;s>1?r[n++]=65533:e<65536?r[n++]=e:(e-=65536,r[n++]=55296|e>>10&1023,r[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Nt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(r,n)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Dt[t[i]]>e?i:e}},Zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Lt=Object.prototype.toString,{Z_NO_FLUSH:Ot,Z_SYNC_FLUSH:Vt,Z_FULL_FLUSH:Mt,Z_FINISH:$t,Z_OK:Ht,Z_STREAM_END:Pt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=Z;function Yt(t){this.options=Ft.assign({level:jt,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let 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 Zt,this.strm.avail_out=0;let i=Rt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Ht)throw new Error(B[i]);if(e.header&&Rt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Bt.string2buf(e.dictionary):"[object ArrayBuffer]"===Lt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Rt.deflateSetDictionary(this.strm,t),i!==Ht)throw new Error(B[i]);this._dict_set=!0}}function qt(t,e){const i=new Yt(e);if(i.push(t,!0),i.err)throw i.msg||B[i.err];return i.result}Yt.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let a,r;if(this.ended)return!1;for(r=e===~~e?e:!0===e?$t:Ot,"string"==typeof t?i.input=Bt.string2buf(t):"[object ArrayBuffer]"===Lt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(r===Vt||r===Mt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(a=Rt.deflate(i,r),a===Pt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),a=Rt.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Ht;if(0!==i.avail_out){if(r>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Yt.prototype.onData=function(t){this.chunks.push(t)},Yt.prototype.onEnd=function(t){t===Ht&&(this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Wt={Deflate:Yt,deflate:qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,qt(t,e)},constants:Z},Xt=function(t,e){let i,n,a,r,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,x,U,E;const A=t.state;i=t.next_in,U=t.input,n=i+(t.avail_in-5),a=t.next_out,E=t.output,r=a-(e-t.avail_out),s=a+(t.avail_out-257),o=A.dmax,h=A.wsize,l=A.whave,d=A.wnext,c=A.window,f=A.hold,u=A.bits,_=A.lencode,p=A.distcode,w=(1<<A.lenbits)-1,g=(1<<A.distbits)-1;t:do{u<15&&(f+=U[i++]<<u,u+=8,f+=U[i++]<<u,u+=8),b=_[f&w];e:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,0===m)E[a++]=65535&b;else{if(!(16&m)){if(0==(64&m)){b=_[(65535&b)+(f&(1<<m)-1)];continue e}if(32&m){A.mode=12;break t}t.msg="invalid literal/length code",A.mode=30;break t}y=65535&b,m&=15,m&&(u<m&&(f+=U[i++]<<u,u+=8),y+=f&(1<<m)-1,f>>>=m,u-=m),u<15&&(f+=U[i++]<<u,u+=8,f+=U[i++]<<u,u+=8),b=p[f&g];i:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,!(16&m)){if(0==(64&m)){b=p[(65535&b)+(f&(1<<m)-1)];continue i}t.msg="invalid distance code",A.mode=30;break t}if(k=65535&b,m&=15,u<m&&(f+=U[i++]<<u,u+=8,u<m&&(f+=U[i++]<<u,u+=8)),k+=f&(1<<m)-1,k>o){t.msg="invalid distance too far back",A.mode=30;break t}if(f>>>=m,u-=m,m=a-r,k>m){if(m=k-m,m>l&&A.sane){t.msg="invalid distance too far back",A.mode=30;break t}if(v=0,x=c,0===d){if(v+=h-m,m<y){y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}}else if(d<m){if(v+=h+d-m,m-=d,m<y){y-=m;do{E[a++]=c[v++]}while(--m);if(v=0,d<y){m=d,y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}}}else if(v+=d-m,m<y){y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}for(;y>2;)E[a++]=x[v++],E[a++]=x[v++],E[a++]=x[v++],y-=3;y&&(E[a++]=x[v++],y>1&&(E[a++]=x[v++]))}else{v=a-k;do{E[a++]=E[v++],E[a++]=E[v++],E[a++]=E[v++],y-=3}while(y>2);y&&(E[a++]=E[v++],y>1&&(E[a++]=E[v++]))}break}}break}}while(i<n&&a<s);y=u>>3,i-=y,u-=y<<3,f&=(1<<u)-1,t.next_in=i,t.next_out=a,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=a<s?s-a+257:257-(a-s),A.hold=f,A.bits=u};const Jt=new Uint16Array([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,0,0]),Qt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),te=new Uint16Array([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,0,0]),ee=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ie=(t,e,i,n,a,r,s,o)=>{const h=o.bits;let l,d,c,f,u,_,p=0,w=0,g=0,b=0,m=0,y=0,k=0,v=0,x=0,U=0,E=null,A=0;const z=new Uint16Array(16),I=new Uint16Array(16);let S,T,R,C=null,F=0;for(p=0;p<=15;p++)z[p]=0;for(w=0;w<n;w++)z[e[i+w]]++;for(m=h,b=15;b>=1&&0===z[b];b--);if(m>b&&(m=b),0===b)return a[r++]=20971520,a[r++]=20971520,o.bits=1,0;for(g=1;g<b&&0===z[g];g++);for(m<g&&(m=g),v=1,p=1;p<=15;p++)if(v<<=1,v-=z[p],v<0)return-1;if(v>0&&(0===t||1!==b))return-1;for(I[1]=0,p=1;p<15;p++)I[p+1]=I[p]+z[p];for(w=0;w<n;w++)0!==e[i+w]&&(s[I[e[i+w]]++]=w);if(0===t?(E=C=s,_=19):1===t?(E=Jt,A-=257,C=Qt,F-=257,_=256):(E=te,C=ee,_=-1),U=0,w=0,p=g,u=r,y=m,k=0,c=-1,x=1<<m,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){S=p-k,s[w]<_?(T=0,R=s[w]):s[w]>_?(T=C[F+s[w]],R=E[A+s[w]]):(T=96,R=0),l=1<<p-k,d=1<<y,g=d;do{d-=l,a[u+(U>>k)+d]=S<<24|T<<16|R|0}while(0!==d);for(l=1<<p-1;U&l;)l>>=1;if(0!==l?(U&=l-1,U+=l):U=0,w++,0==--z[p]){if(p===b)break;p=e[i+s[w]]}if(p>m&&(U&f)!==c){for(0===k&&(k=m),u+=g,y=p-k,v=1<<y;y+k<b&&(v-=z[y+k],!(v<=0));)y++,v<<=1;if(x+=1<<y,1===t&&x>852||2===t&&x>592)return 1;c=U&f,a[c]=m<<24|y<<16|u-r|0}}return 0!==U&&(a[u+U]=p-k<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ne,Z_BLOCK:ae,Z_TREES:re,Z_OK:se,Z_STREAM_END:oe,Z_NEED_DICT:he,Z_STREAM_ERROR:le,Z_DATA_ERROR:de,Z_MEM_ERROR:ce,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=Z,_e=12,pe=30,we=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const be=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},me=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,be(t)},ye=(t,e)=>{let i;if(!t||!t.state)return le;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,me(t))},ke=(t,e)=>{if(!t)return le;const i=new ge;t.state=i,i.window=null;const n=ye(t,e);return n!==se&&(t.state=null),n};let ve,xe,Ue=!0;const Ee=t=>{if(Ue){ve=new Int32Array(512),xe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ie(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ie(2,t.lens,0,32,xe,0,t.work,{bits:5}),Ue=!1}t.lencode=ve,t.lenbits=9,t.distcode=xe,t.distbits=5},Ae=(t,e,i,n)=>{let a;const r=t.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),n>=r.wsize?(r.window.set(e.subarray(i-r.wsize,i),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>n&&(a=n),r.window.set(e.subarray(i-n,i-n+a),r.wnext),(n-=a)?(r.window.set(e.subarray(i-n,i),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0};var ze={inflateReset:me,inflateReset2:ye,inflateResetKeep:be,inflateInit:t=>ke(t,15),inflateInit2:ke,inflate:(t,e)=>{let i,n,a,r,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,x,U=0;const E=new Uint8Array(4);let A,z;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;i=t.state,i.mode===_e&&(i.mode=13),s=t.next_out,a=t.output,h=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,c=o,f=h,x=se;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=pe;break}if((15&l)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(l>>>=4,d-=4,v=8+(15&l),0===i.wbits)i.wbits=v;else if(v>i.wbits){t.msg="invalid window size",i.mode=pe;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&l?10:_e,l=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(i.flags=l,(255&i.flags)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=pe;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,E[2]=l>>>16&255,E[3]=l>>>24&255,i.check=D(i.check,E,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(r,r+u),v)),512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{v=n[r+u++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,v)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;u=0;do{v=n[r+u++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,v)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l!==(65535&i.check)){t.msg="header crc mismatch",i.mode=pe;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=_e;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}t.adler=i.check=we(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,he;t.adler=i.check=1,i.mode=_e;case _e:if(e===ae||e===re)break t;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}switch(i.last=1&l,l>>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Ee(i),i.mode=20,e===re){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=pe}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",i.mode=pe;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===re)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;a.set(n.subarray(r,r+u),s),o-=u,r+=u,h-=u,s+=u,i.length-=u;break}i.mode=_e;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=pe;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.lens[I[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[I[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},x=ie(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,x){t.msg="invalid code lengths set",i.mode=pe;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;U=i.lencode[l&(1<<i.lenbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(b<16)l>>>=w,d-=w,i.lens[i.have++]=b;else{if(16===b){for(z=w+2;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l>>>=w,d-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=pe;break}v=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===b){for(z=w+3;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=w,d-=w,v=0,u=3+(7&l),l>>>=3,d-=3}else{for(z=w+7;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=w,d-=w,v=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=pe;break}for(;u--;)i.lens[i.have++]=v}}if(i.mode===pe)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=pe;break}if(i.lenbits=9,A={bits:i.lenbits},x=ie(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,x){t.msg="invalid literal/lengths set",i.mode=pe;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},x=ie(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,x){t.msg="invalid distances set",i.mode=pe;break}if(i.mode=20,e===re)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,Xt(t,f),s=t.next_out,a=t.output,h=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===_e&&(i.back=-1);break}for(i.back=0;U=i.lencode[l&(1<<i.lenbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(g&&0==(240&g)){for(m=w,y=g,k=b;U=i.lencode[k+((l&(1<<m+y)-1)>>m)],w=U>>>24,g=U>>>16&255,b=65535&U,!(m+w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,i.length=b,0===g){i.mode=26;break}if(32&g){i.back=-1,i.mode=_e;break}if(64&g){t.msg="invalid literal/length code",i.mode=pe;break}i.extra=15&g,i.mode=22;case 22:if(i.extra){for(z=i.extra;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;U=i.distcode[l&(1<<i.distbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(0==(240&g)){for(m=w,y=g,k=b;U=i.distcode[k+((l&(1<<m+y)-1)>>m)],w=U>>>24,g=U>>>16&255,b=65535&U,!(m+w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,64&g){t.msg="invalid distance code",i.mode=pe;break}i.offset=b,i.extra=15&g,i.mode=24;case 24:if(i.extra){for(z=i.extra;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=pe;break}i.mode=25;case 25:if(0===h)break t;if(u=f-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=pe;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=a,_=s-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{a[s++]=p[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;a[s++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[r++]<<d,d+=8}if(f-=h,t.total_out+=f,i.total+=f,f&&(t.adler=i.check=i.flags?D(i.check,a,f,s-f):F(i.check,a,f,s-f)),f=h,(i.flags?l:we(l))!==i.check){t.msg="incorrect data check",i.mode=pe;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=pe;break}l=0,d=0}i.mode=29;case 29:x=oe;break t;case pe:x=de;break t;case 31:return ce;default:return le}return t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,(i.wsize||f!==t.avail_out&&i.mode<pe&&(i.mode<27||e!==ne))&&Ae(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,i.total+=f,i.wrap&&f&&(t.adler=i.check=i.flags?D(i.check,a,f,t.next_out-f):F(i.check,a,f,t.next_out-f)),t.data_type=i.bits+(i.last?64:0)+(i.mode===_e?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===f||e===ne)&&x===se&&(x=fe),x},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const i=t.state;return 0==(2&i.wrap)?le:(i.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,a,r;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?le:11===n.mode&&(a=1,a=F(a,e,i,0),a!==n.check)?de:(r=Ae(t,e,i,i),r?(n.mode=31,ce):(n.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"},Ie=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Se=Object.prototype.toString,{Z_NO_FLUSH:Te,Z_FINISH:Re,Z_OK:Ce,Z_STREAM_END:Fe,Z_NEED_DICT:Ne,Z_STREAM_ERROR:De,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ze}=Z;function Le(t){this.options=Ft.assign({chunkSize:65536,windowBits:15,to:""},t||{});const 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 Zt,this.strm.avail_out=0;let i=ze.inflateInit2(this.strm,e.windowBits);if(i!==Ce)throw new Error(B[i]);if(this.header=new Ie,ze.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Bt.string2buf(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=ze.inflateSetDictionary(this.strm,e.dictionary),i!==Ce)))throw new Error(B[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||B[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let r,s,o;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Re:Te,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),r=ze.inflate(i,s),r===Ne&&a&&(r=ze.inflateSetDictionary(i,a),r===Ce?r=ze.inflate(i,s):r===Be&&(r=Ne));i.avail_in>0&&r===Fe&&i.state.wrap>0&&0!==t[i.next_in];)ze.inflateReset(i),r=ze.inflate(i,s);switch(r){case De:case Be:case Ne:case Ze:return this.onEnd(r),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||r===Fe))if("string"===this.options.to){let t=Bt.utf8border(i.output,i.next_out),e=i.next_out-t,a=Bt.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(a)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(r!==Ce||0!==o){if(r===Fe)return r=ze.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Ce&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ve={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:Z};const{Deflate:Me,deflate:$e,deflateRaw:He,gzip:Pe}=Wt,{Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Ye}=Ve;var qe={Deflate:Me,deflate:$e,deflateRaw:He,gzip:Pe,Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Ye,constants:Z};function We(){this.width=0,this.height=0,this.bitDepth=0,this.colorType=0,this.compressionMethod=0,this.filterMethod=0,this.interlaceMethod=0,this.colors=0,this.alpha=!1,this.pixelBits=0,this.palette=null,this.pixels=null,this.trns=null,this.text={}}function Xe(t,e){const i=t.length;if(i!==e.length)return!1;let n=0;for(;n<i;n++)if(t[n]!==e[n])return!1;return!0}We.prototype.getWidth=function(){return this.width},We.prototype.setWidth=function(t){this.width=t},We.prototype.getHeight=function(){return this.height},We.prototype.setHeight=function(t){this.height=t},We.prototype.getBitDepth=function(){return this.bitDepth},We.prototype.setBitDepth=function(t){if(-1===[2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t},We.prototype.getColorType=function(){return this.colorType},We.prototype.setColorType=function(t){var e=0,i=!1;switch(t){case 0:case 3:e=1;break;case 2:e=3;break;case 4:e=2,i=!0;break;case 6:e=4,i=!0;break;default:throw new Error("invalid color type")}this.colors=e,this.alpha=i,this.colorType=t},We.prototype.getCompressionMethod=function(){return this.compressionMethod},We.prototype.setCompressionMethod=function(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t},We.prototype.getFilterMethod=function(){return this.filterMethod},We.prototype.setFilterMethod=function(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t},We.prototype.getInterlaceMethod=function(){return this.interlaceMethod},We.prototype.setInterlaceMethod=function(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t},We.prototype.setTRNS=function(t){this.trns=t},We.prototype.setPalette=function(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t},We.prototype.getPalette=function(){return this.palette},We.prototype.getPixel=function(t,e,i,n){var a=this.pixels;if(!a)throw new Error("pixel data is empty");if(i>=this.width||n>=this.height)throw new Error("x,y position out of bound");var r=this.colors*this.bitDepth/8*(n*this.width+i);let s,o,h,l;switch(this.colorType){case 0:s=a[r],o=s,h=s,l=255;break;case 2:s=a[r],o=a[r+1],h=a[r+2],l=255;break;case 3:l=255,null!=this.trns&&(l=this.trns[a[r]]);const t=3*a[r],e=this.palette;s=e[t],o=e[t+1],h=e[t+2];break;case 4:s=a[r],o=s,h=s,l=a[r+1];break;case 6:s=a[r],o=a[r+1],h=a[r+2],l=a[r+3];break;default:throw new Error("Unsupported color type")}t[e+0]=s,t[e+1]=o,t[e+2]=h,t[e+3]=l},We.prototype.getRGBA8Array_fromRGB=function(t){const e=this.height,i=this.width*e,n=this.pixels;for(let e=0;e<i;e++){const i=3*e,a=i+e;t[a]=n[i],t[a+1]=n[i+1],t[a+2]=n[i+2],t[a+3]=255}},We.prototype.getRGBA8Array_generic=function(t){const e=this.height,i=this.width;for(var n=0;n<e;n++){const e=n*i;for(var a=0;a<i;a++){const i=4*(e+a);this.getPixel(t,i,a,n)}}},We.prototype.getRGBA8Array=function(){if(6===this.colorType)return this.pixels;const t=this.height,e=this.width;var i=new Uint8Array(e*t*4);return 2===this.colorType?this.getRGBA8Array_fromRGB(i):this.getRGBA8Array_generic(i),i},We.prototype.getUint8Data_case3=function(){const t=this.width*this.height;let e;const i=this.trns;e=null!==i?4:3;const n=new Uint8Array(t*e),a=this.pixels,r=this.palette,s=this.colors*this.bitDepth/8;for(let i=0;i<t;i++){const t=i*e,o=3*a[i*s];n[t]=r[o],n[t+1]=r[o+1],n[t+2]=r[o+2]}if(null!==i){const e=i.length;for(let r=0;r<t;r++){const t=a[r*s];n[4*r+3]=t>=e?255:i[t]}}return{data:n,itemSize:e}},We.prototype.getUint8Data=function(){let t,e=0;switch(this.colorType){case 0:t=this.pixels,e=1;break;case 2:t=this.pixels,e=3;break;case 3:const i=this.getUint8Data_case3();t=i.data,e=i.itemSize;break;case 4:t=this.pixels,e=2;break;case 6:t=this.pixels,e=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:e}};class Je{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,i,n){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,i,n){throw new Error("Not Implemented")}}class Qe{describeTo(t){throw new Error("Not Implemented")}}class ti extends Qe{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class ei{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new ti(t)}}class ii extends Je{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,i,n){return this.appendList(t,e,i,new ei(n)),this}appendList(t,e,i,n){let a=!1;this.appendText(t);const r=n[Symbol.iterator]();for(let t=r.next();!0!==t.done;t=r.next())a&&this.appendText(e),this.appendDescriptionOf(t.value),a=!0;return this.appendText(i),this}}class ni extends ii{value="";appendText(t){return this.value+=t,this}}function ai(t,e){if(!t)throw new Error(e||"AssertionError")}ai.enum=function(t,e,i="value"){for(let i in e)if(e[i]===t)return;throw new Error(`${i}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},ai.notEqual=function(t,e,i){ai(t!==e,i)},ai.notOk=function(t,e){ai(!t,e)},ai.equal=function(t,e,i){if(t!==e)throw new Error(void 0!==i?i:`${t} !== ${e}`)},ai.logicalyEqual=function(t,e,i){},ai.ok=ai,ai.greaterThan=function(t,e,i){if(!(t>e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} > ${e}.`,new Error(n)}},ai.greaterThanOrEqual=function(t,e,i){if(!(t>=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} >= ${e}.`,new Error(n)}},ai.lessThan=function(t,e,i){if(!(t<e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} < ${e}.`,new Error(n)}},ai.lessThanOrEqual=function(t,e,i){if(!(t<=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} <= ${e}.`,new Error(n)}},ai.typeOf=function(t,e,i="value"){const n=typeof t;if(n!==e)throw new Error(`expected ${i} to be ${e}, instead was '${n}'(=${t})`)},ai.arrayHas=function(t,e,i="Array does not contain the item"){},ai.arrayHasNo=function(t,e,i="Array contains the item"){},ai.arrayEqual=function(t,e,i="Arrays are not equal"){if(!Xe(t,e))throw new Error(i)},ai.isInstanceOf=function(t,e,i="value",n=e.name){},ai.isNumber=function(t,e="value"){const i=typeof t;if("number"!==i)throw new Error(`expected ${e} to be a number, instead was '${i}'(=${t})`)},ai.isString=function(t,e="value"){const i=typeof t;if("string"!==i)throw new Error(`expected ${e} to be a string, instead was '${i}'(=${t})`)},ai.isBoolean=function(t,e="value"){const i=typeof t;if("boolean"!==i)throw new Error(`expected ${e} to be a boolean, instead was '${i}'(=${t})`)},ai.isFunction=function(t,e="value"){const i=typeof t;if("function"!==i)throw new Error(`expected ${e} to be a function, instead was '${i}'(=${t})`)},ai.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},ai.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},ai.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},ai.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(i=t,i instanceof Int8Array||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int16Array||i instanceof Uint16Array||i instanceof Int32Array||i instanceof Uint32Array||i instanceof Float32Array||i instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var i},ai.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},ai.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},ai.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},ai.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},ai.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},ai.that=function(t,e,i){if(i.matches(t))return;const n=new ni;throw n.appendText(`Expected ${e} to be `),i.describeTo(n),n.appendText(" instead "),i.describeMismatch(t,n),new Error(n.value)};const ri=!1,si=!0;class oi{endianness=ri;position=0;length=0;capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.length=this.capacity,this.position=0}trim(){return this.setCapacity(this.position),this}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);const e=this.__data_uint8,i=new Uint8Array(t),n=Math.min(i.length,e.length);i.set(e.subarray(0,n),0),this.data=i.buffer,this.__data_uint8=i,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){if(this.capacity<t){const e=Math.ceil(Math.max(t,this.capacity*this.__growFactor,this.capacity+1024));this.setCapacity(e)}}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,si);return this.position+=2,t}readUint16BE(){const t=this.dataView.getUint16(this.position,ri);return this.position+=2,t}readUint24(){return this.endianness===ri?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,t|e<<8|i<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,i|e<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,si);return this.position+=4,t}readUint32BE(){const t=this.dataView.getUint32(this.position,ri);return this.position+=4,t}readUint8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint8()}readUint16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint16()}readUint32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint32()}readInt8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt8()}readInt16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt16()}readInt32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt32()}readFloat32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat32()}readFloat64Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat64()}writeFloat32Array(t,e,i){for(let n=0;n<i;n++)this.writeFloat32(t[n+e])}writeFloat32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setFloat32(this.position,t,this.endianness),this.position=e}writeFloat64(t){const e=this.position+8;this.ensureCapacity(e),this.dataView.setFloat64(this.position,t,this.endianness),this.position=e}writeInt8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setInt8(this.position,t),this.position=e}writeInt16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,this.endianness),this.position=e}writeInt32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,this.endianness),this.position=e}writeUint8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setUint8(this.position,t),this.position=e}writeUint8Array(t,e,i){for(let n=0;n<i;n++)this.writeUint8(t[e+n])}writeUint16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,this.endianness),this.position=e}writeUint16BE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,ri),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,si),this.position=e}writeUint16Array(t,e,i){for(let n=0;n<i;n++)this.writeUint16(t[e+n])}writeUint24(t){this.endianness===ri?this.writeUint24BE(t):this.writeUint24LE(t)}writeUint24BE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,a=t>>16&255;this.dataView.setUint8(this.position,a),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,i),this.position=e}writeUint24LE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,a=t>>16&255;this.dataView.setUint8(this.position,i),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,a),this.position=e}writeUintVar(t){let e=!0;for(;e||0!==t;){e=!1;let i=127&t;(t>>=7)>0&&(i|=128),this.writeUint8(i)}}readUintVar(){let t=!0,e=0,i=0;for(;t;){let n=this.readUint8();t=0!=(128&n),e|=(127&n)<<i,i+=7}return e}writeUint32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,this.endianness),this.position=e}writeUint32BE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,ri),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,si),this.position=e}writeUint32Array(t,e,i){for(let n=0;n<i;n++)this.writeUint32(t[e+n])}writeBytes(t,e,i){const n=e+i,a=this.position,r=a+i;if(this.ensureCapacity(r),0===e&&t.length===i)this.__data_uint8.set(t,a);else if("function"==typeof t.subarray)this.__data_uint8.set(t.subarray(e,n),a);else for(let n=0;n<i;n++)this.__data_uint8[a+n]=t[e+n];this.position=r}readBytes(t,e,i){const n=this.position,a=n+i,r=this.__data_uint8;i<128?function(t,e,i,n,a){let r,s,o;for(o=0;o<a;o++)r=e+o,s=n+o,i[s]=t[r]}(r,n,t,e,i):t.set(r.subarray(n,a),e),this.position=a}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let e=0;const i=t.length;if(i>=4294967294)throw new Error("String is too long");this.writeUint32(i);const n=this.position;let a=n,r=Math.max(32,i+(i>>1)+7);this.ensureCapacity(r+a);let s=this.__data_uint8;for(;e<i;){let o=t.charCodeAt(e++);if(o>=55296&&o<=56319){if(e<i){const i=t.charCodeAt(e);56320==(64512&i)&&(++e,o=((1023&o)<<10)+(1023&i)+65536)}if(o>=55296&&o<=56319)continue}if(a+4>this.capacity&&(r+=8,r*=1+e/i*2,r=r>>3<<3,this.ensureCapacity(r+n),s=this.__data_uint8),0!=(4294967168&o)){if(0==(4294965248&o))s[a++]=o>>6&31|192;else if(0==(4294901760&o))s[a++]=o>>12&15|224,s[a++]=o>>6&63|128;else{if(0!=(4292870144&o))continue;s[a++]=o>>18&7|240,s[a++]=o>>12&63|128,s[a++]=o>>6&63|128}s[a++]=63&o|128}else s[a++]=o}this.position=a}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const e=this.__data_uint8;let i="",n=this.position,a=0;for(;n<this.capacity&&a<t;){const t=e[n++];let r;if(0===t)break;0==(128&t)?r=t:192==(224&t)?r=(31&t)<<6|63&e[n++]:224==(240&t)?r=(31&t)<<12|(63&e[n++])<<6|63&e[n++]:240==(248&t)&&(r=(7&t)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++],r>65535&&(r-=65536,i+=String.fromCharCode(r>>>10&1023|55296),a++,r=56320|1023&r)),a++,i+=String.fromCharCode(r)}return this.position=n,i}writeASCIIString(t){const e=t.length,i=this.position,n=i+e;this.ensureCapacity(n);for(let n=0;n<e;n++){const e=t.charCodeAt(n);if(e>255)throw new Error(`Character ${String.fromCharCode(e)} can't be represented by a US-ASCII byte.`);this.__data_uint8[i+n]=e}this.position=n}readASCIICharacters(t,e=!1){let i="";for(let n=0;n<t;n++){const t=this.readUint8();if(e&&0===t)break;i+=String.fromCharCode(t)}return i}static fromArrayBuffer(t){const e=new oi;return e.fromArrayBuffer(t),e}static copyUTF8String(t,e){const i=t.readUTF8String();return e.writeUTF8String(i),i}static copyUintVar(t,e){const i=t.readUintVar();return e.writeUintVar(i),i}static copyUint8(t,e){const i=t.readUint8();return e.writeUint8(i),i}static copyUint16(t,e){const i=t.readUint16();return e.writeUint16(i),i}static copyUint32(t,e){const i=t.readUint32();return e.writeUint32(i),i}static copyFloat32(t,e){const i=t.readFloat32();return e.writeFloat32(i),i}static copyFloat64(t,e){const i=t.readFloat64();return e.writeFloat64(i),i}static copyBytes(t,e,i){const n=new Uint8Array(i);return t.readBytes(n,0,i),e.writeBytes(n,0,i),n}}oi.prototype.isBinaryBuffer=!0;const hi=[137,80,78,71,13,10,26,10],li=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;li[t]=e}function di(t,e){return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]}function ci(t,e){return t[e]}function fi(t){this.i=0,this.bytes=new Uint8Array(t),this.png=new We,this.dataChunks=[],this.buffer=new oi,this.buffer.fromArrayBuffer(t),this.crc_enabled=!1}fi.prototype.readBytes=function(t){const e=new Uint8Array(t);return this.buffer.readBytes(e,0,t),e},fi.prototype.decodeHeader=function(){if(0!==this.i)throw new Error("file pointer should be at 0 to read the header");const t=this.buffer,e=new Uint8Array(8);if(t.readBytes(e,0,8),!Xe(e,hi))throw new Error("invalid PNGReader file (bad signature)");this.header=e},fi.prototype.decodeChunk=function(){const t=this.buffer,e=t.readUint32();if(e<0)throw new Error("Bad chunk length "+(4294967295&e));const i=t.position,n=t.readASCIICharacters(4),a=this.readBytes(e);switch(t.readUint32(),this.crc_enabled&&function(t,e,i,n){let a=4294967295;const r=i+n;for(let t=i;t<r;t++){const i=255&(a^e[t]);a=li[i]^a>>>8}}(0,t.raw_bytes,i,e+4),n){case"IHDR":this.decodeIHDR(a);break;case"PLTE":this.decodePLTE(a);break;case"IDAT":this.decodeIDAT(a);break;case"tRNS":this.decodeTRNS(a);break;case"IEND":this.decodeIEND(a)}return n},fi.prototype.decodetEXt=function(t){const e=oi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=e.readASCIICharacters(i.length-1,!1);this.png.text[i]=n},fi.prototype.decodeiEXt=function(t){const e=oi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(e.readUint8(),e.readUint8(),e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),e.readUTF8String(),0!==e.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=e.readUTF8String();this.png.text[i]=n},fi.prototype.decodeIHDR=function(t){var e=this.png;e.setWidth(di(t,0)),e.setHeight(di(t,4)),e.setBitDepth(ci(t,8)),e.setColorType(ci(t,9)),e.setCompressionMethod(ci(t,10)),e.setFilterMethod(ci(t,11)),e.setInterlaceMethod(ci(t,12))},fi.prototype.decodePLTE=function(t){this.png.setPalette(t)},fi.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},fi.prototype.decodeTRNS=function(t){this.png.setTRNS(t)},fi.prototype.decodeIEND=function(){},fi.prototype.decodePixels=function(){var t=this.png;const e=new qe.Inflate,i=this.dataChunks,n=i.length;for(let t=0;t<n;t++)if(e.push(i[t]),e.err)throw new Error(e.err);const a=e.result;0===t.getInterlaceMethod()?this.interlaceNone(a):this.interlaceAdam7(a)},fi.prototype.interlaceNone=function(t){var e=this.png,i=Math.max(1,e.colors*e.bitDepth/8);const n=i*e.width;var a=new Uint8Array(i*e.width*e.height),r=0;const s=t.length;for(var o=0;o<s;o+=n+1){const e=o+1,s=ci(t,o);switch(s){case 0:this.unFilterNone(t,e,a,i,r,n);break;case 1:this.unFilterSub(t,e,a,i,r,n);break;case 2:this.unFilterUp(t,e,a,i,r,n);break;case 3:this.unFilterAverage(t,e,a,i,r,n);break;case 4:this.unFilterPaeth(t,e,a,i,r,n);break;default:throw new Error(`unknown filtered scanline type '${s}'`)}r+=n}e.pixels=a},fi.prototype.interlaceAdam7=function(t){throw new Error("Adam7 interlacing is not implemented yet")},fi.prototype.unFilterNone=function(t,e,i,n,a,r){for(let n=0;n<r;n++)i[a+n]=t[n+e]},fi.prototype.unFilterSub=function(t,e,i,n,a,r){for(var s=0;s<n;s++)i[a+s]=t[s+e];for(;s<r;s++){const r=a+s;i[r]=t[s+e]+i[r-n]&255}},fi.prototype.unFilterUp=function(t,e,i,n,a,r){var s,o,h=0;if(a-r<0)for(;h<r;h++)i[a+h]=t[h+e];else for(;h<r;h++)s=t[h+e],o=i[a+h-r],i[a+h]=s+o&255},fi.prototype.unFilterAverage=function(t,e,i,n,a,r){var s,o,h,l=0;if(a-r<0){for(;l<n;l++)i[a+l]=t[l+e];for(;l<r;l++){const r=a+l;i[r]=t[l+e]+(i[r-n]>>1)&255}}else{for(;l<n;l++){const n=a+l;i[n]=t[l+e]+(i[n-r]>>1)&255}for(;l<r;l++){s=t[l+e];const d=a+l;o=i[d-n],h=i[d-r],i[d]=s+(o+h>>1)&255}}},fi.prototype.unFilterPaeth=function(t,e,i,n,a,r){var s,o,h,l,d,c,f,u,_,p=0;if(a-r<0){for(;p<n;p++)i[a+p]=t[p+e];for(;p<r;p++)i[a+p]=t[p+e]+i[a+p-n]&255}else{const w=a-r;for(;p<n;p++)i[a+p]=t[p+e]+i[w+p]&255;for(;p<r;p++){s=t[p+e];const w=a+p;l=i[w-r-n],h=i[w-r],d=(o=i[w-n])+h-l,c=Math.abs(d-o),f=Math.abs(d-h),u=Math.abs(d-l),_=c<=f&&c<=u?o:f<=u?h:l,i[w]=s+_&255}}},fi.prototype.parse=function(){for(this.decodeHeader();this.buffer.position<this.buffer.length&&"IEND"!==this.decodeChunk(););var t=this.png;return this.decodePixels(),t},self.Lib={decode:async function(t,e="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===e.toLowerCase())return await async function(t){return new Promise(((e,i)=>{const n=new fi(t).parse(),a=n.getUint8Data(),r=n.getWidth(),s=n.getHeight();e({data:a.data.buffer,width:r,height:s,itemSize:a.itemSize,bitDepth:n.bitDepth})}))}(t);throw new Error("Unsupported type")}};
|
|
1
|
+
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([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]),i=new Uint8Array([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]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),a=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new Array(576);t(r);const s=new Array(60);t(s);const o=new Array(512);t(o);const h=new Array(256);t(h);const l=new Array(29);t(l);const d=new Array(30);function c(t,e,i,n,a){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=a,this.has_stree=t&&t.length}let f,u,_;function p(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const w=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},b=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,g(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},m=(t,e,i)=>{b(t,i[2*e],i[2*e+1])},y=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},k=(t,e,i)=>{const n=new Array(16);let a,r,s=0;for(a=1;a<=15;a++)n[a]=s=s+i[a-1]<<1;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=y(n[e]++,e))}},v=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},x=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},U=(t,e,i,n)=>{const a=2*e,r=2*i;return t[a]<t[r]||t[a]===t[r]&&n[e]<=n[i]},E=(t,e,i)=>{const n=t.heap[i];let a=i<<1;for(;a<=t.heap_len&&(a<t.heap_len&&U(e,t.heap[a+1],t.heap[a],t.depth)&&a++,!U(e,n,t.heap[a],t.depth));)t.heap[i]=t.heap[a],i=a,a<<=1;t.heap[i]=n},A=(t,n,a)=>{let r,s,o,c,f=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],s=t.pending_buf[t.l_buf+f],f++,0===r?m(t,s,n):(o=h[s],m(t,o+256+1,n),c=e[o],0!==c&&(s-=l[o],b(t,s,c)),r--,o=w(r),m(t,o,a),c=i[o],0!==c&&(r-=d[o],b(t,r,c)))}while(f<t.last_lit);m(t,256,n)},z=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,r=e.stat_desc.elems;let s,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<r;s++)0!==i[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):i[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,i[2*h]=1,t.depth[h]=0,t.opt_len--,a&&(t.static_len-=n[2*h+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)E(t,i,s);h=r;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],E(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=o,i[2*h]=i[2*s]+i[2*o],t.depth[h]=(t.depth[s]>=t.depth[o]?t.depth[s]:t.depth[o])+1,i[2*s+1]=i[2*o+1]=h,t.heap[1]=h++,E(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,a=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,c,f,u,_,p=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],f=i[2*i[2*d+1]+1]+1,f>h&&(f=h,p++),i[2*d+1]=f,d>n||(t.bl_count[f]++,u=0,d>=o&&(u=s[d-o]),_=i[2*d],t.opt_len+=_*(f+u),r&&(t.static_len+=_*(a[2*d+1]+u)));if(0!==p){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(f=h;0!==f;f--)for(d=t.bl_count[f];0!==d;)c=t.heap[--l],c>n||(i[2*c+1]!==f&&(t.opt_len+=(f-i[2*c+1])*i[2*c],i[2*c+1]=f),d--)}})(t,e),k(i,l,t.bl_count)},I=(t,e,i)=>{let n,a,r=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)a=s,s=e[2*(n+1)+1],++o<h&&a===s||(o<l?t.bl_tree[2*a]+=o:0!==a?(a!==r&&t.bl_tree[2*a]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,r=a,0===s?(h=138,l=3):a===s?(h=6,l=3):(h=7,l=4))},S=(t,e,i)=>{let n,a,r=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=i;n++)if(a=s,s=e[2*(n+1)+1],!(++o<h&&a===s)){if(o<l)do{m(t,a,t.bl_tree)}while(0!=--o);else 0!==a?(a!==r&&(m(t,a,t.bl_tree),o--),m(t,16,t.bl_tree),b(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),b(t,o-3,3)):(m(t,18,t.bl_tree),b(t,o-11,7));o=0,r=a,0===s?(h=138,l=3):a===s?(h=6,l=3):(h=7,l=4)}};let T=!1;const R=(t,e,i,n)=>{b(t,0+(n?1:0),3),((t,e,i,n)=>{x(t),g(t,i),g(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var C={_tr_init:t=>{T||((()=>{let t,a,p,w,g;const b=new Array(16);for(p=0,w=0;w<28;w++)for(l[w]=p,t=0;t<1<<e[w];t++)h[p++]=w;for(h[p-1]=w,g=0,w=0;w<16;w++)for(d[w]=g,t=0;t<1<<i[w];t++)o[g++]=w;for(g>>=7;w<30;w++)for(d[w]=g<<7,t=0;t<1<<i[w]-7;t++)o[256+g++]=w;for(a=0;a<=15;a++)b[a]=0;for(t=0;t<=143;)r[2*t+1]=8,t++,b[8]++;for(;t<=255;)r[2*t+1]=9,t++,b[9]++;for(;t<=279;)r[2*t+1]=7,t++,b[7]++;for(;t<=287;)r[2*t+1]=8,t++,b[8]++;for(k(r,287,b),t=0;t<30;t++)s[2*t+1]=5,s[2*t]=y(t,5);f=new c(r,e,257,286,15),u=new c(s,i,0,30,15),_=new c(new Array(0),n,0,19,7)})(),T=!0),t.l_desc=new p(t.dyn_ltree,f),t.d_desc=new p(t.dyn_dtree,u),t.bl_desc=new p(t.bl_tree,_),t.bi_buf=0,t.bi_valid=0,v(t)},_tr_stored_block:R,_tr_flush_block:(t,e,i,n)=>{let o,h,l=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),z(t,t.l_desc),z(t,t.d_desc),l=(t=>{let e;for(I(t,t.dyn_ltree,t.l_desc.max_code),I(t,t.dyn_dtree,t.d_desc.max_code),z(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*a[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,h=t.static_len+3+7>>>3,h<=o&&(o=h)):o=h=i+5,i+4<=o&&-1!==e?R(t,e,i,n):4===t.strategy||h===o?(b(t,2+(n?1:0),3),A(t,r,s)):(b(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(b(t,e-257,5),b(t,i-1,5),b(t,n-4,4),r=0;r<n;r++)b(t,t.bl_tree[2*a[r]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,l+1),A(t,t.dyn_ltree,t.dyn_dtree)),v(t),n&&x(t)},_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(h[i]+256+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{b(t,2,3),m(t,256,r),(t=>{16===t.bi_valid?(g(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},F=(t,e,i,n)=>{let a=65535&t|0,r=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{a=a+e[n++]|0,r=r+a|0}while(--s);a%=65521,r%=65521}return a|r<<16|0};const N=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var D=(t,e,i,n)=>{const a=N,r=n+i;t^=-1;for(let i=n;i<r;i++)t=t>>>8^a[255&(t^e[i])];return-1^t},B={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Z={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:L,_tr_stored_block:O,_tr_flush_block:V,_tr_tally:M,_tr_align:$}=C,{Z_NO_FLUSH:H,Z_PARTIAL_FLUSH:P,Z_FULL_FLUSH:j,Z_FINISH:G,Z_BLOCK:K,Z_OK:Y,Z_STREAM_END:q,Z_STREAM_ERROR:W,Z_DATA_ERROR:X,Z_BUF_ERROR:J,Z_DEFAULT_COMPRESSION:Q,Z_FILTERED:tt,Z_HUFFMAN_ONLY:et,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:at,Z_UNKNOWN:rt,Z_DEFLATED:st}=Z,ot=258,ht=262,lt=103,dt=113,ct=666,ft=(t,e)=>(t.msg=B[e],e),ut=t=>(t<<1)-(t>4?9:0),_t=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const wt=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},gt=(t,e)=>{V(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,wt(t.strm)},bt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,n)=>{let a=t.avail_in;return a>n&&(a=n),0===a?0:(t.avail_in-=a,e.set(t.input.subarray(t.next_in,t.next_in+a),i),1===t.state.wrap?t.adler=F(t.adler,e,a,i):2===t.state.wrap&&(t.adler=D(t.adler,e,a,i)),t.next_in+=a,t.total_in+=a,a)},kt=(t,e)=>{let i,n,a=t.max_chain_length,r=t.strstart,s=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-ht?t.strstart-(t.w_size-ht):0,l=t.window,d=t.w_mask,c=t.prev,f=t.strstart+ot;let u=l[r+s-1],_=l[r+s];t.prev_length>=t.good_match&&(a>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+s]===_&&l[i+s-1]===u&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do{}while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(n=ot-(f-r),r=f-ot,n>s){if(t.match_start=e,s=n,n>=o)break;u=l[r+s-1],_=l[r+s]}}}while((e=c[e&d])>h&&0!=--a);return s<=t.lookahead?s:t.lookahead},vt=t=>{const e=t.w_size;let i,n,a,r,s;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ht)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{a=t.head[--i],t.head[i]=a>=e?a-e:0}while(--n);n=e,i=n;do{a=t.prev[--i],t.prev[i]=a>=e?a-e:0}while(--n);r+=e}if(0===t.strm.avail_in)break;if(n=yt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ht&&0!==t.strm.avail_in)},xt=(t,e)=>{let i,n;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i)),t.match_length>=3)if(n=M(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else n=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2},Ut=(t,e)=>{let i,n,a;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i),t.match_length<=5&&(t.strategy===tt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,n=M(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(gt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=M(t,0,t.window[t.strstart-1]),n&>(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=M(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2};function Et(t,e,i,n,a){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=a}const At=[new Et(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(vt(t),0===t.lookahead&&e===H)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,gt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ht&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(gt(t,!1),t.strm.avail_out),1)})),new Et(4,4,8,4,xt),new Et(4,5,16,8,xt),new Et(4,6,32,32,xt),new Et(4,4,16,16,Ut),new Et(8,16,32,32,Ut),new Et(8,16,128,128,Ut),new Et(8,32,128,256,Ut),new Et(32,128,258,1024,Ut),new Et(32,258,258,4096,Ut)];function zt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=st,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_t(this.dyn_ltree),_t(this.dyn_dtree),_t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_t(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const It=t=>{if(!t||!t.state)return ft(t,W);t.total_in=t.total_out=0,t.data_type=rt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:dt,t.adler=2===e.wrap?0:1,e.last_flush=H,L(e),Y},St=t=>{const e=It(t);var i;return e===Y&&((i=t.state).window_size=2*i.w_size,_t(i.head),i.max_lazy_match=At[i.level].max_lazy,i.good_match=At[i.level].good_length,i.nice_match=At[i.level].nice_length,i.max_chain_length=At[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Tt=(t,e,i,n,a,r)=>{if(!t)return W;let s=1;if(e===Q&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),a<1||a>9||i!==st||n<8||n>15||e<0||e>9||r<0||r>nt)return ft(t,W);8===n&&(n=9);const o=new zt;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=r,o.method=i,St(t)};var Rt={deflateInit:(t,e)=>Tt(t,e,st,15,8,at),deflateInit2:Tt,deflateReset:St,deflateResetKeep:It,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?W:(t.state.gzhead=e,Y):W,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>K||e<0)return t?ft(t,W):W;const a=t.state;if(!t.output||!t.input&&0!==t.avail_in||a.status===ct&&e!==G)return ft(t,0===t.avail_out?J:W);a.strm=t;const r=a.last_flush;if(a.last_flush=e,42===a.status)if(2===a.wrap)t.adler=0,bt(a,31),bt(a,139),bt(a,8),a.gzhead?(bt(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),bt(a,255&a.gzhead.time),bt(a,a.gzhead.time>>8&255),bt(a,a.gzhead.time>>16&255),bt(a,a.gzhead.time>>24&255),bt(a,9===a.level?2:a.strategy>=et||a.level<2?4:0),bt(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(bt(a,255&a.gzhead.extra.length),bt(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=D(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69):(bt(a,0),bt(a,0),bt(a,0),bt(a,0),bt(a,0),bt(a,9===a.level?2:a.strategy>=et||a.level<2?4:0),bt(a,3),a.status=dt);else{let e=st+(a.w_bits-8<<4)<<8,i=-1;i=a.strategy>=et||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,a.status=dt,mt(a,e),0!==a.strstart&&(mt(a,t.adler>>>16),mt(a,65535&t.adler)),t.adler=1}if(69===a.status)if(a.gzhead.extra){for(i=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending!==a.pending_buf_size));)bt(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=73)}else a.status=73;if(73===a.status)if(a.gzhead.name){i=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending===a.pending_buf_size)){n=1;break}n=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,bt(a,n)}while(0!==n);a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),0===n&&(a.gzindex=0,a.status=91)}else a.status=91;if(91===a.status)if(a.gzhead.comment){i=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),wt(t),i=a.pending,a.pending===a.pending_buf_size)){n=1;break}n=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,bt(a,n)}while(0!==n);a.gzhead.hcrc&&a.pending>i&&(t.adler=D(t.adler,a.pending_buf,a.pending-i,i)),0===n&&(a.status=lt)}else a.status=lt;if(a.status===lt&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&wt(t),a.pending+2<=a.pending_buf_size&&(bt(a,255&t.adler),bt(a,t.adler>>8&255),t.adler=0,a.status=dt)):a.status=dt),0!==a.pending){if(wt(t),0===t.avail_out)return a.last_flush=-1,Y}else if(0===t.avail_in&&ut(e)<=ut(r)&&e!==G)return ft(t,J);if(a.status===ct&&0!==t.avail_in)return ft(t,J);if(0!==t.avail_in||0!==a.lookahead||e!==H&&a.status!==ct){let i=a.strategy===et?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(vt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.strategy===it?((t,e)=>{let i,n,a,r;const s=t.window;for(;;){if(t.lookahead<=ot){if(vt(t),t.lookahead<=ot&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(a=t.strstart-1,n=s[a],n===s[++a]&&n===s[++a]&&n===s[++a])){r=t.strstart+ot;do{}while(n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&n===s[++a]&&a<r);t.match_length=ot-(r-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=M(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(a,e):At[a.level].func(a,e);if(3!==i&&4!==i||(a.status=ct),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),Y;if(2===i&&(e===P?$(a):e!==K&&(O(a,0,0,!1),e===j&&(_t(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),wt(t),0===t.avail_out))return a.last_flush=-1,Y}return e!==G?Y:a.wrap<=0?q:(2===a.wrap?(bt(a,255&t.adler),bt(a,t.adler>>8&255),bt(a,t.adler>>16&255),bt(a,t.adler>>24&255),bt(a,255&t.total_in),bt(a,t.total_in>>8&255),bt(a,t.total_in>>16&255),bt(a,t.total_in>>24&255)):(mt(a,t.adler>>>16),mt(a,65535&t.adler)),wt(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?Y:q)},deflateEnd:t=>{if(!t||!t.state)return W;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==lt&&e!==dt&&e!==ct?ft(t,W):(t.state=null,e===dt?ft(t,X):Y)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return W;const n=t.state,a=n.wrap;if(2===a||1===a&&42!==n.status||n.lookahead)return W;if(1===a&&(t.adler=F(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===a&&(_t(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const r=t.avail_in,s=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,vt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=pt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,vt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=o,t.avail_in=r,n.wrap=a,Y},deflateInfo:"pako deflate (from Nodeca project)"};const Ct=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ft={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Ct(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,a=t.length;e<a;e++){let a=t[e];i.set(a,n),n+=a.length}return i}};let Nt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nt=!1}const Dt=new Uint8Array(256);for(let t=0;t<256;t++)Dt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Dt[254]=Dt[254]=1;var Bt={string2buf:t=>{let e,i,n,a,r,s=t.length,o=0;for(a=0;a<s;a++)i=t.charCodeAt(a),55296==(64512&i)&&a+1<s&&(n=t.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),r=0,a=0;r<o;a++)i=t.charCodeAt(a),55296==(64512&i)&&a+1<s&&(n=t.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),i<128?e[r++]=i:i<2048?(e[r++]=192|i>>>6,e[r++]=128|63&i):i<65536?(e[r++]=224|i>>>12,e[r++]=128|i>>>6&63,e[r++]=128|63&i):(e[r++]=240|i>>>18,e[r++]=128|i>>>12&63,e[r++]=128|i>>>6&63,e[r++]=128|63&i);return e},buf2string:(t,e)=>{let i,n;const a=e||t.length,r=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){r[n++]=e;continue}let s=Dt[e];if(s>4)r[n++]=65533,i+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&i<a;)e=e<<6|63&t[i++],s--;s>1?r[n++]=65533:e<65536?r[n++]=e:(e-=65536,r[n++]=55296|e>>10&1023,r[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Nt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(r,n)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Dt[t[i]]>e?i:e}},Zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Lt=Object.prototype.toString,{Z_NO_FLUSH:Ot,Z_SYNC_FLUSH:Vt,Z_FULL_FLUSH:Mt,Z_FINISH:$t,Z_OK:Ht,Z_STREAM_END:Pt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=Z;function Yt(t){this.options=Ft.assign({level:jt,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let 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 Zt,this.strm.avail_out=0;let i=Rt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Ht)throw new Error(B[i]);if(e.header&&Rt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Bt.string2buf(e.dictionary):"[object ArrayBuffer]"===Lt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Rt.deflateSetDictionary(this.strm,t),i!==Ht)throw new Error(B[i]);this._dict_set=!0}}function qt(t,e){const i=new Yt(e);if(i.push(t,!0),i.err)throw i.msg||B[i.err];return i.result}Yt.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let a,r;if(this.ended)return!1;for(r=e===~~e?e:!0===e?$t:Ot,"string"==typeof t?i.input=Bt.string2buf(t):"[object ArrayBuffer]"===Lt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(r===Vt||r===Mt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(a=Rt.deflate(i,r),a===Pt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),a=Rt.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Ht;if(0!==i.avail_out){if(r>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Yt.prototype.onData=function(t){this.chunks.push(t)},Yt.prototype.onEnd=function(t){t===Ht&&(this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Wt={Deflate:Yt,deflate:qt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,qt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,qt(t,e)},constants:Z},Xt=function(t,e){let i,n,a,r,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,x,U,E;const A=t.state;i=t.next_in,U=t.input,n=i+(t.avail_in-5),a=t.next_out,E=t.output,r=a-(e-t.avail_out),s=a+(t.avail_out-257),o=A.dmax,h=A.wsize,l=A.whave,d=A.wnext,c=A.window,f=A.hold,u=A.bits,_=A.lencode,p=A.distcode,w=(1<<A.lenbits)-1,g=(1<<A.distbits)-1;t:do{u<15&&(f+=U[i++]<<u,u+=8,f+=U[i++]<<u,u+=8),b=_[f&w];e:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,0===m)E[a++]=65535&b;else{if(!(16&m)){if(0==(64&m)){b=_[(65535&b)+(f&(1<<m)-1)];continue e}if(32&m){A.mode=12;break t}t.msg="invalid literal/length code",A.mode=30;break t}y=65535&b,m&=15,m&&(u<m&&(f+=U[i++]<<u,u+=8),y+=f&(1<<m)-1,f>>>=m,u-=m),u<15&&(f+=U[i++]<<u,u+=8,f+=U[i++]<<u,u+=8),b=p[f&g];i:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,!(16&m)){if(0==(64&m)){b=p[(65535&b)+(f&(1<<m)-1)];continue i}t.msg="invalid distance code",A.mode=30;break t}if(k=65535&b,m&=15,u<m&&(f+=U[i++]<<u,u+=8,u<m&&(f+=U[i++]<<u,u+=8)),k+=f&(1<<m)-1,k>o){t.msg="invalid distance too far back",A.mode=30;break t}if(f>>>=m,u-=m,m=a-r,k>m){if(m=k-m,m>l&&A.sane){t.msg="invalid distance too far back",A.mode=30;break t}if(v=0,x=c,0===d){if(v+=h-m,m<y){y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}}else if(d<m){if(v+=h+d-m,m-=d,m<y){y-=m;do{E[a++]=c[v++]}while(--m);if(v=0,d<y){m=d,y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}}}else if(v+=d-m,m<y){y-=m;do{E[a++]=c[v++]}while(--m);v=a-k,x=E}for(;y>2;)E[a++]=x[v++],E[a++]=x[v++],E[a++]=x[v++],y-=3;y&&(E[a++]=x[v++],y>1&&(E[a++]=x[v++]))}else{v=a-k;do{E[a++]=E[v++],E[a++]=E[v++],E[a++]=E[v++],y-=3}while(y>2);y&&(E[a++]=E[v++],y>1&&(E[a++]=E[v++]))}break}}break}}while(i<n&&a<s);y=u>>3,i-=y,u-=y<<3,f&=(1<<u)-1,t.next_in=i,t.next_out=a,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=a<s?s-a+257:257-(a-s),A.hold=f,A.bits=u};const Jt=new Uint16Array([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,0,0]),Qt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),te=new Uint16Array([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,0,0]),ee=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ie=(t,e,i,n,a,r,s,o)=>{const h=o.bits;let l,d,c,f,u,_,p=0,w=0,g=0,b=0,m=0,y=0,k=0,v=0,x=0,U=0,E=null,A=0;const z=new Uint16Array(16),I=new Uint16Array(16);let S,T,R,C=null,F=0;for(p=0;p<=15;p++)z[p]=0;for(w=0;w<n;w++)z[e[i+w]]++;for(m=h,b=15;b>=1&&0===z[b];b--);if(m>b&&(m=b),0===b)return a[r++]=20971520,a[r++]=20971520,o.bits=1,0;for(g=1;g<b&&0===z[g];g++);for(m<g&&(m=g),v=1,p=1;p<=15;p++)if(v<<=1,v-=z[p],v<0)return-1;if(v>0&&(0===t||1!==b))return-1;for(I[1]=0,p=1;p<15;p++)I[p+1]=I[p]+z[p];for(w=0;w<n;w++)0!==e[i+w]&&(s[I[e[i+w]]++]=w);if(0===t?(E=C=s,_=19):1===t?(E=Jt,A-=257,C=Qt,F-=257,_=256):(E=te,C=ee,_=-1),U=0,w=0,p=g,u=r,y=m,k=0,c=-1,x=1<<m,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){S=p-k,s[w]<_?(T=0,R=s[w]):s[w]>_?(T=C[F+s[w]],R=E[A+s[w]]):(T=96,R=0),l=1<<p-k,d=1<<y,g=d;do{d-=l,a[u+(U>>k)+d]=S<<24|T<<16|R|0}while(0!==d);for(l=1<<p-1;U&l;)l>>=1;if(0!==l?(U&=l-1,U+=l):U=0,w++,0==--z[p]){if(p===b)break;p=e[i+s[w]]}if(p>m&&(U&f)!==c){for(0===k&&(k=m),u+=g,y=p-k,v=1<<y;y+k<b&&(v-=z[y+k],!(v<=0));)y++,v<<=1;if(x+=1<<y,1===t&&x>852||2===t&&x>592)return 1;c=U&f,a[c]=m<<24|y<<16|u-r|0}}return 0!==U&&(a[u+U]=p-k<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ne,Z_BLOCK:ae,Z_TREES:re,Z_OK:se,Z_STREAM_END:oe,Z_NEED_DICT:he,Z_STREAM_ERROR:le,Z_DATA_ERROR:de,Z_MEM_ERROR:ce,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=Z,_e=12,pe=30,we=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const be=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},me=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,be(t)},ye=(t,e)=>{let i;if(!t||!t.state)return le;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,me(t))},ke=(t,e)=>{if(!t)return le;const i=new ge;t.state=i,i.window=null;const n=ye(t,e);return n!==se&&(t.state=null),n};let ve,xe,Ue=!0;const Ee=t=>{if(Ue){ve=new Int32Array(512),xe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ie(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ie(2,t.lens,0,32,xe,0,t.work,{bits:5}),Ue=!1}t.lencode=ve,t.lenbits=9,t.distcode=xe,t.distbits=5},Ae=(t,e,i,n)=>{let a;const r=t.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),n>=r.wsize?(r.window.set(e.subarray(i-r.wsize,i),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>n&&(a=n),r.window.set(e.subarray(i-n,i-n+a),r.wnext),(n-=a)?(r.window.set(e.subarray(i-n,i),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0};var ze={inflateReset:me,inflateReset2:ye,inflateResetKeep:be,inflateInit:t=>ke(t,15),inflateInit2:ke,inflate:(t,e)=>{let i,n,a,r,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,x,U=0;const E=new Uint8Array(4);let A,z;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;i=t.state,i.mode===_e&&(i.mode=13),s=t.next_out,a=t.output,h=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,c=o,f=h,x=se;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=pe;break}if((15&l)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(l>>>=4,d-=4,v=8+(15&l),0===i.wbits)i.wbits=v;else if(v>i.wbits){t.msg="invalid window size",i.mode=pe;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&l?10:_e,l=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(i.flags=l,(255&i.flags)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=pe;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,E[2]=l>>>16&255,E[3]=l>>>24&255,i.check=D(i.check,E,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(E[0]=255&l,E[1]=l>>>8&255,i.check=D(i.check,E,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(r,r+u),v)),512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{v=n[r+u++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,v)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;u=0;do{v=n[r+u++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=D(i.check,n,u,r)),o-=u,r+=u,v)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l!==(65535&i.check)){t.msg="header crc mismatch",i.mode=pe;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=_e;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}t.adler=i.check=we(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,he;t.adler=i.check=1,i.mode=_e;case _e:if(e===ae||e===re)break t;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}switch(i.last=1&l,l>>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Ee(i),i.mode=20,e===re){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=pe}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",i.mode=pe;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===re)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;a.set(n.subarray(r,r+u),s),o-=u,r+=u,h-=u,s+=u,i.length-=u;break}i.mode=_e;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=pe;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.lens[I[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[I[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},x=ie(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,x){t.msg="invalid code lengths set",i.mode=pe;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;U=i.lencode[l&(1<<i.lenbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(b<16)l>>>=w,d-=w,i.lens[i.have++]=b;else{if(16===b){for(z=w+2;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l>>>=w,d-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=pe;break}v=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===b){for(z=w+3;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=w,d-=w,v=0,u=3+(7&l),l>>>=3,d-=3}else{for(z=w+7;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=w,d-=w,v=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=pe;break}for(;u--;)i.lens[i.have++]=v}}if(i.mode===pe)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=pe;break}if(i.lenbits=9,A={bits:i.lenbits},x=ie(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,x){t.msg="invalid literal/lengths set",i.mode=pe;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},x=ie(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,x){t.msg="invalid distances set",i.mode=pe;break}if(i.mode=20,e===re)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,Xt(t,f),s=t.next_out,a=t.output,h=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===_e&&(i.back=-1);break}for(i.back=0;U=i.lencode[l&(1<<i.lenbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(g&&0==(240&g)){for(m=w,y=g,k=b;U=i.lencode[k+((l&(1<<m+y)-1)>>m)],w=U>>>24,g=U>>>16&255,b=65535&U,!(m+w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,i.length=b,0===g){i.mode=26;break}if(32&g){i.back=-1,i.mode=_e;break}if(64&g){t.msg="invalid literal/length code",i.mode=pe;break}i.extra=15&g,i.mode=22;case 22:if(i.extra){for(z=i.extra;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;U=i.distcode[l&(1<<i.distbits)-1],w=U>>>24,g=U>>>16&255,b=65535&U,!(w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(0==(240&g)){for(m=w,y=g,k=b;U=i.distcode[k+((l&(1<<m+y)-1)>>m)],w=U>>>24,g=U>>>16&255,b=65535&U,!(m+w<=d);){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,64&g){t.msg="invalid distance code",i.mode=pe;break}i.offset=b,i.extra=15&g,i.mode=24;case 24:if(i.extra){for(z=i.extra;d<z;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=pe;break}i.mode=25;case 25:if(0===h)break t;if(u=f-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=pe;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=a,_=s-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{a[s++]=p[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;a[s++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[r++]<<d,d+=8}if(f-=h,t.total_out+=f,i.total+=f,f&&(t.adler=i.check=i.flags?D(i.check,a,f,s-f):F(i.check,a,f,s-f)),f=h,(i.flags?l:we(l))!==i.check){t.msg="incorrect data check",i.mode=pe;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===o)break t;o--,l+=n[r++]<<d,d+=8}if(l!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=pe;break}l=0,d=0}i.mode=29;case 29:x=oe;break t;case pe:x=de;break t;case 31:return ce;default:return le}return t.next_out=s,t.avail_out=h,t.next_in=r,t.avail_in=o,i.hold=l,i.bits=d,(i.wsize||f!==t.avail_out&&i.mode<pe&&(i.mode<27||e!==ne))&&Ae(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,i.total+=f,i.wrap&&f&&(t.adler=i.check=i.flags?D(i.check,a,f,t.next_out-f):F(i.check,a,f,t.next_out-f)),t.data_type=i.bits+(i.last?64:0)+(i.mode===_e?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===f||e===ne)&&x===se&&(x=fe),x},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const i=t.state;return 0==(2&i.wrap)?le:(i.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,a,r;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?le:11===n.mode&&(a=1,a=F(a,e,i,0),a!==n.check)?de:(r=Ae(t,e,i,i),r?(n.mode=31,ce):(n.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"},Ie=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Se=Object.prototype.toString,{Z_NO_FLUSH:Te,Z_FINISH:Re,Z_OK:Ce,Z_STREAM_END:Fe,Z_NEED_DICT:Ne,Z_STREAM_ERROR:De,Z_DATA_ERROR:Be,Z_MEM_ERROR:Ze}=Z;function Le(t){this.options=Ft.assign({chunkSize:65536,windowBits:15,to:""},t||{});const 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 Zt,this.strm.avail_out=0;let i=ze.inflateInit2(this.strm,e.windowBits);if(i!==Ce)throw new Error(B[i]);if(this.header=new Ie,ze.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Bt.string2buf(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=ze.inflateSetDictionary(this.strm,e.dictionary),i!==Ce)))throw new Error(B[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||B[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let r,s,o;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Re:Te,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),r=ze.inflate(i,s),r===Ne&&a&&(r=ze.inflateSetDictionary(i,a),r===Ce?r=ze.inflate(i,s):r===Be&&(r=Ne));i.avail_in>0&&r===Fe&&i.state.wrap>0&&0!==t[i.next_in];)ze.inflateReset(i),r=ze.inflate(i,s);switch(r){case De:case Be:case Ne:case Ze:return this.onEnd(r),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||r===Fe))if("string"===this.options.to){let t=Bt.utf8border(i.output,i.next_out),e=i.next_out-t,a=Bt.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(a)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(r!==Ce||0!==o){if(r===Fe)return r=ze.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Ce&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ve={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:Z};const{Deflate:Me,deflate:$e,deflateRaw:He,gzip:Pe}=Wt,{Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Ye}=Ve;var qe={Deflate:Me,deflate:$e,deflateRaw:He,gzip:Pe,Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Ye,constants:Z};function We(){this.width=0,this.height=0,this.bitDepth=0,this.colorType=0,this.compressionMethod=0,this.filterMethod=0,this.interlaceMethod=0,this.colors=0,this.alpha=!1,this.pixelBits=0,this.palette=null,this.pixels=null,this.trns=null,this.text={}}function Xe(t,e){const i=t.length;if(i!==e.length)return!1;let n=0;for(;n<i;n++)if(t[n]!==e[n])return!1;return!0}We.prototype.getWidth=function(){return this.width},We.prototype.setWidth=function(t){this.width=t},We.prototype.getHeight=function(){return this.height},We.prototype.setHeight=function(t){this.height=t},We.prototype.getBitDepth=function(){return this.bitDepth},We.prototype.setBitDepth=function(t){if(-1===[2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t},We.prototype.getColorType=function(){return this.colorType},We.prototype.setColorType=function(t){var e=0,i=!1;switch(t){case 0:case 3:e=1;break;case 2:e=3;break;case 4:e=2,i=!0;break;case 6:e=4,i=!0;break;default:throw new Error("invalid color type")}this.colors=e,this.alpha=i,this.colorType=t},We.prototype.getCompressionMethod=function(){return this.compressionMethod},We.prototype.setCompressionMethod=function(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t},We.prototype.getFilterMethod=function(){return this.filterMethod},We.prototype.setFilterMethod=function(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t},We.prototype.getInterlaceMethod=function(){return this.interlaceMethod},We.prototype.setInterlaceMethod=function(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t},We.prototype.setTRNS=function(t){this.trns=t},We.prototype.setPalette=function(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t},We.prototype.getPalette=function(){return this.palette},We.prototype.getPixel=function(t,e,i,n){var a=this.pixels;if(!a)throw new Error("pixel data is empty");if(i>=this.width||n>=this.height)throw new Error("x,y position out of bound");var r=this.colors*this.bitDepth/8*(n*this.width+i);let s,o,h,l;switch(this.colorType){case 0:s=a[r],o=s,h=s,l=255;break;case 2:s=a[r],o=a[r+1],h=a[r+2],l=255;break;case 3:l=255,null!=this.trns&&(l=this.trns[a[r]]);const t=3*a[r],e=this.palette;s=e[t],o=e[t+1],h=e[t+2];break;case 4:s=a[r],o=s,h=s,l=a[r+1];break;case 6:s=a[r],o=a[r+1],h=a[r+2],l=a[r+3];break;default:throw new Error("Unsupported color type")}t[e+0]=s,t[e+1]=o,t[e+2]=h,t[e+3]=l},We.prototype.getRGBA8Array_fromRGB=function(t){const e=this.height,i=this.width*e,n=this.pixels;for(let e=0;e<i;e++){const i=3*e,a=i+e;t[a]=n[i],t[a+1]=n[i+1],t[a+2]=n[i+2],t[a+3]=255}},We.prototype.getRGBA8Array_generic=function(t){const e=this.height,i=this.width;for(var n=0;n<e;n++){const e=n*i;for(var a=0;a<i;a++){const i=4*(e+a);this.getPixel(t,i,a,n)}}},We.prototype.getRGBA8Array=function(){if(6===this.colorType)return this.pixels;const t=this.height,e=this.width;var i=new Uint8Array(e*t*4);return 2===this.colorType?this.getRGBA8Array_fromRGB(i):this.getRGBA8Array_generic(i),i},We.prototype.getUint8Data_case3=function(){const t=this.width*this.height;let e;const i=this.trns;e=null!==i?4:3;const n=new Uint8Array(t*e),a=this.pixels,r=this.palette,s=this.colors*this.bitDepth/8;for(let i=0;i<t;i++){const t=i*e,o=3*a[i*s];n[t]=r[o],n[t+1]=r[o+1],n[t+2]=r[o+2]}if(null!==i){const e=i.length;for(let r=0;r<t;r++){const t=a[r*s];n[4*r+3]=t>=e?255:i[t]}}return{data:n,itemSize:e}},We.prototype.getUint8Data=function(){let t,e=0;switch(this.colorType){case 0:t=this.pixels,e=1;break;case 2:t=this.pixels,e=3;break;case 3:const i=this.getUint8Data_case3();t=i.data,e=i.itemSize;break;case 4:t=this.pixels,e=2;break;case 6:t=this.pixels,e=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:e}};class Je{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,i,n){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,i,n){throw new Error("Not Implemented")}}class Qe{describeTo(t){throw new Error("Not Implemented")}}class ti extends Qe{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class ei{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new ti(t)}}class ii extends Je{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,i,n){return this.appendList(t,e,i,new ei(n)),this}appendList(t,e,i,n){let a=!1;this.appendText(t);const r=n[Symbol.iterator]();for(let t=r.next();!0!==t.done;t=r.next())a&&this.appendText(e),this.appendDescriptionOf(t.value),a=!0;return this.appendText(i),this}}class ni extends ii{value="";appendText(t){return this.value+=t,this}}function ai(t,e){if(!t)throw new Error(e||"AssertionError")}function ri(t,e,i,n,a){let r,s,o;for(o=0;o<a;o++)r=e+o,s=n+o,i[s]=t[r]}ai.enum=function(t,e,i="value"){for(let i in e)if(e[i]===t)return;throw new Error(`${i}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},ai.notEqual=function(t,e,i){ai(t!==e,i)},ai.notOk=function(t,e){ai(!t,e)},ai.equal=function(t,e,i){if(t!==e)throw new Error(void 0!==i?i:`${t} !== ${e}`)},ai.logicalyEqual=function(t,e,i){},ai.ok=ai,ai.greaterThan=function(t,e,i){if(!(t>e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} > ${e}.`,new Error(n)}},ai.greaterThanOrEqual=function(t,e,i){if(!(t>=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} >= ${e}.`,new Error(n)}},ai.lessThan=function(t,e,i){if(!(t<e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} < ${e}.`,new Error(n)}},ai.lessThanOrEqual=function(t,e,i){if(!(t<=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} <= ${e}.`,new Error(n)}},ai.typeOf=function(t,e,i="value"){const n=typeof t;if(n!==e)throw new Error(`expected ${i} to be ${e}, instead was '${n}'(=${t})`)},ai.arrayHas=function(t,e,i="Array does not contain the item"){},ai.arrayHasNo=function(t,e,i="Array contains the item"){},ai.arrayEqual=function(t,e,i="Arrays are not equal"){if(!Xe(t,e))throw new Error(i)},ai.isInstanceOf=function(t,e,i="value",n=e.name){},ai.isNumber=function(t,e="value"){const i=typeof t;if("number"!==i)throw new Error(`expected ${e} to be a number, instead was '${i}'(=${t})`)},ai.isString=function(t,e="value"){const i=typeof t;if("string"!==i)throw new Error(`expected ${e} to be a string, instead was '${i}'(=${t})`)},ai.isBoolean=function(t,e="value"){const i=typeof t;if("boolean"!==i)throw new Error(`expected ${e} to be a boolean, instead was '${i}'(=${t})`)},ai.isFunction=function(t,e="value"){const i=typeof t;if("function"!==i)throw new Error(`expected ${e} to be a function, instead was '${i}'(=${t})`)},ai.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},ai.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},ai.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},ai.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(i=t,i instanceof Int8Array||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int16Array||i instanceof Uint16Array||i instanceof Int32Array||i instanceof Uint32Array||i instanceof Float32Array||i instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var i},ai.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},ai.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},ai.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},ai.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},ai.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},ai.that=function(t,e,i){if(i.matches(t))return;const n=new ni;throw n.appendText(`Expected ${e} to be `),i.describeTo(n),n.appendText(" instead "),i.describeMismatch(t,n),new Error(n.value)};const si=!1,oi=!0;class hi{endianness=si;position=0;length=0;capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.length=this.capacity,this.position=0}trim(){return this.setCapacity(this.position),this}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);const e=this.__data_uint8,i=new Uint8Array(t);!function(t,e){const i=e.length;i>=t.length?e.set(t,0):ri(t,0,e,0,i)}(e,i),this.data=i.buffer,this.__data_uint8=i,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){const e=this.capacity;if(e>=t)return;const i=Math.ceil(Math.max(t,e*this.__growFactor,e+1024));this.setCapacity(i)}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,oi);return this.position+=2,t}readUint16BE(){const t=this.dataView.getUint16(this.position,si);return this.position+=2,t}readUint24(){return this.endianness===si?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,t|e<<8|i<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,i|e<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,oi);return this.position+=4,t}readUint32BE(){const t=this.dataView.getUint32(this.position,si);return this.position+=4,t}readUint8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint8()}readUint16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint16()}readUint32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint32()}readInt8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt8()}readInt16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt16()}readInt32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt32()}readFloat32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat32()}readFloat64Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat64()}writeFloat32Array(t,e,i){for(let n=0;n<i;n++)this.writeFloat32(t[n+e])}writeFloat32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setFloat32(this.position,t,this.endianness),this.position=e}writeFloat64(t){const e=this.position+8;this.ensureCapacity(e),this.dataView.setFloat64(this.position,t,this.endianness),this.position=e}writeInt8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setInt8(this.position,t),this.position=e}writeInt16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,this.endianness),this.position=e}writeInt32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,this.endianness),this.position=e}writeUint8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setUint8(this.position,t),this.position=e}writeUint8Array(t,e,i){for(let n=0;n<i;n++)this.writeUint8(t[e+n])}writeUint16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,this.endianness),this.position=e}writeUint16BE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,si),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,oi),this.position=e}writeUint16Array(t,e,i){for(let n=0;n<i;n++)this.writeUint16(t[e+n])}writeUint24(t){this.endianness===si?this.writeUint24BE(t):this.writeUint24LE(t)}writeUint24BE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,a=t>>16&255;this.dataView.setUint8(this.position,a),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,i),this.position=e}writeUint24LE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,a=t>>16&255;this.dataView.setUint8(this.position,i),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,a),this.position=e}writeUintVar(t){let e=!0;for(;e||0!==t;){e=!1;let i=127&t;(t>>=7)>0&&(i|=128),this.writeUint8(i)}}readUintVar(){let t=!0,e=0,i=0;for(;t;){let n=this.readUint8();t=0!=(128&n),e|=(127&n)<<i,i+=7}return e}writeUint32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,this.endianness),this.position=e}writeUint32BE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,si),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,oi),this.position=e}writeUint32Array(t,e,i){for(let n=0;n<i;n++)this.writeUint32(t[e+n])}writeBytes(t,e,i){const n=e+i,a=this.position,r=a+i;if(this.ensureCapacity(r),0===e&&t.length===i)this.__data_uint8.set(t,a);else if("function"==typeof t.subarray)this.__data_uint8.set(t.subarray(e,n),a);else for(let n=0;n<i;n++)this.__data_uint8[a+n]=t[e+n];this.position=r}readBytes(t,e,i){const n=this.position,a=n+i,r=this.__data_uint8;i<128?ri(r,n,t,e,i):t.set(r.subarray(n,a),e),this.position=a}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let e=0;const i=t.length;if(i>=4294967294)throw new Error("String is too long");this.writeUint32(i);let n=this.position;const a=Math.max(32,i+(i>>1)+7);this.ensureCapacity(a+n);let r=this.__data_uint8,s=this.capacity;for(;e<i;){let a=t.charCodeAt(e++);if(a>=55296&&a<=56319){if(e<i){const i=t.charCodeAt(e);56320==(64512&i)&&(++e,a=((1023&a)<<10)+(1023&i)+65536)}if(a>=55296&&a<=56319)continue}if(n+4>s&&(this.ensureCapacity(n+4),s=this.capacity,r=this.__data_uint8),0!=(4294967168&a)){if(0==(4294965248&a))r[n++]=a>>6&31|192;else if(0==(4294901760&a))r[n++]=a>>12&15|224,r[n++]=a>>6&63|128;else{if(0!=(4292870144&a))continue;r[n++]=a>>18&7|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128}r[n++]=63&a|128}else r[n++]=a}this.position=n}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const e=this.__data_uint8;let i="",n=this.position,a=0;for(;n<this.capacity&&a<t;){const t=e[n++];let r;if(0===t)break;0==(128&t)?r=t:192==(224&t)?r=(31&t)<<6|63&e[n++]:224==(240&t)?r=(31&t)<<12|(63&e[n++])<<6|63&e[n++]:240==(248&t)&&(r=(7&t)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++],r>65535&&(r-=65536,i+=String.fromCharCode(r>>>10&1023|55296),a++,r=56320|1023&r)),a++,i+=String.fromCharCode(r)}return this.position=n,i}writeASCIIString(t){const e=t.length,i=this.position,n=i+e;this.ensureCapacity(n);for(let n=0;n<e;n++){const e=t.charCodeAt(n);if(e>255)throw new Error(`Character ${String.fromCharCode(e)} can't be represented by a US-ASCII byte.`);this.__data_uint8[i+n]=e}this.position=n}readASCIICharacters(t,e=!1){let i="";for(let n=0;n<t;n++){const t=this.readUint8();if(e&&0===t)break;i+=String.fromCharCode(t)}return i}static fromArrayBuffer(t){const e=new hi;return e.fromArrayBuffer(t),e}static copyUTF8String(t,e){const i=t.readUTF8String();return e.writeUTF8String(i),i}static copyUintVar(t,e){const i=t.readUintVar();return e.writeUintVar(i),i}static copyUint8(t,e){const i=t.readUint8();return e.writeUint8(i),i}static copyUint16(t,e){const i=t.readUint16();return e.writeUint16(i),i}static copyUint32(t,e){const i=t.readUint32();return e.writeUint32(i),i}static copyFloat32(t,e){const i=t.readFloat32();return e.writeFloat32(i),i}static copyFloat64(t,e){const i=t.readFloat64();return e.writeFloat64(i),i}static copyBytes(t,e,i){const n=new Uint8Array(i);return t.readBytes(n,0,i),e.writeBytes(n,0,i),n}}hi.prototype.isBinaryBuffer=!0;const li=[137,80,78,71,13,10,26,10],di=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;di[t]=e}function ci(t,e){return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]}function fi(t,e){return t[e]}function ui(t){this.i=0,this.bytes=new Uint8Array(t),this.png=new We,this.dataChunks=[],this.buffer=new hi,this.buffer.fromArrayBuffer(t),this.crc_enabled=!1}ui.prototype.readBytes=function(t){const e=new Uint8Array(t);return this.buffer.readBytes(e,0,t),e},ui.prototype.decodeHeader=function(){if(0!==this.i)throw new Error("file pointer should be at 0 to read the header");const t=this.buffer,e=new Uint8Array(8);if(t.readBytes(e,0,8),!Xe(e,li))throw new Error("invalid PNGReader file (bad signature)");this.header=e},ui.prototype.decodeChunk=function(){const t=this.buffer,e=t.readUint32();if(e<0)throw new Error("Bad chunk length "+(4294967295&e));const i=t.position,n=t.readASCIICharacters(4),a=this.readBytes(e);switch(t.readUint32(),this.crc_enabled&&function(t,e,i,n){let a=4294967295;const r=i+n;for(let t=i;t<r;t++){const i=255&(a^e[t]);a=di[i]^a>>>8}}(0,t.raw_bytes,i,e+4),n){case"IHDR":this.decodeIHDR(a);break;case"PLTE":this.decodePLTE(a);break;case"IDAT":this.decodeIDAT(a);break;case"tRNS":this.decodeTRNS(a);break;case"IEND":this.decodeIEND(a)}return n},ui.prototype.decodetEXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=e.readASCIICharacters(i.length-1,!1);this.png.text[i]=n},ui.prototype.decodeiEXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(e.readUint8(),e.readUint8(),e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),e.readUTF8String(),0!==e.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=e.readUTF8String();this.png.text[i]=n},ui.prototype.decodeIHDR=function(t){var e=this.png;e.setWidth(ci(t,0)),e.setHeight(ci(t,4)),e.setBitDepth(fi(t,8)),e.setColorType(fi(t,9)),e.setCompressionMethod(fi(t,10)),e.setFilterMethod(fi(t,11)),e.setInterlaceMethod(fi(t,12))},ui.prototype.decodePLTE=function(t){this.png.setPalette(t)},ui.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},ui.prototype.decodeTRNS=function(t){this.png.setTRNS(t)},ui.prototype.decodeIEND=function(){},ui.prototype.decodePixels=function(){var t=this.png;const e=new qe.Inflate,i=this.dataChunks,n=i.length;for(let t=0;t<n;t++)if(e.push(i[t]),e.err)throw new Error(e.err);const a=e.result;0===t.getInterlaceMethod()?this.interlaceNone(a):this.interlaceAdam7(a)},ui.prototype.interlaceNone=function(t){var e=this.png,i=Math.max(1,e.colors*e.bitDepth/8);const n=i*e.width;var a=new Uint8Array(i*e.width*e.height),r=0;const s=t.length;for(var o=0;o<s;o+=n+1){const e=o+1,s=fi(t,o);switch(s){case 0:this.unFilterNone(t,e,a,i,r,n);break;case 1:this.unFilterSub(t,e,a,i,r,n);break;case 2:this.unFilterUp(t,e,a,i,r,n);break;case 3:this.unFilterAverage(t,e,a,i,r,n);break;case 4:this.unFilterPaeth(t,e,a,i,r,n);break;default:throw new Error(`unknown filtered scanline type '${s}'`)}r+=n}e.pixels=a},ui.prototype.interlaceAdam7=function(t){throw new Error("Adam7 interlacing is not implemented yet")},ui.prototype.unFilterNone=function(t,e,i,n,a,r){for(let n=0;n<r;n++)i[a+n]=t[n+e]},ui.prototype.unFilterSub=function(t,e,i,n,a,r){for(var s=0;s<n;s++)i[a+s]=t[s+e];for(;s<r;s++){const r=a+s;i[r]=t[s+e]+i[r-n]&255}},ui.prototype.unFilterUp=function(t,e,i,n,a,r){var s,o,h=0;if(a-r<0)for(;h<r;h++)i[a+h]=t[h+e];else for(;h<r;h++)s=t[h+e],o=i[a+h-r],i[a+h]=s+o&255},ui.prototype.unFilterAverage=function(t,e,i,n,a,r){var s,o,h,l=0;if(a-r<0){for(;l<n;l++)i[a+l]=t[l+e];for(;l<r;l++){const r=a+l;i[r]=t[l+e]+(i[r-n]>>1)&255}}else{for(;l<n;l++){const n=a+l;i[n]=t[l+e]+(i[n-r]>>1)&255}for(;l<r;l++){s=t[l+e];const d=a+l;o=i[d-n],h=i[d-r],i[d]=s+(o+h>>1)&255}}},ui.prototype.unFilterPaeth=function(t,e,i,n,a,r){var s,o,h,l,d,c,f,u,_,p=0;if(a-r<0){for(;p<n;p++)i[a+p]=t[p+e];for(;p<r;p++)i[a+p]=t[p+e]+i[a+p-n]&255}else{const w=a-r;for(;p<n;p++)i[a+p]=t[p+e]+i[w+p]&255;for(;p<r;p++){s=t[p+e];const w=a+p;l=i[w-r-n],h=i[w-r],d=(o=i[w-n])+h-l,c=Math.abs(d-o),f=Math.abs(d-h),u=Math.abs(d-l),_=c<=f&&c<=u?o:f<=u?h:l,i[w]=s+_&255}}},ui.prototype.parse=function(){for(this.decodeHeader();this.buffer.position<this.buffer.length&&"IEND"!==this.decodeChunk(););var t=this.png;return this.decodePixels(),t},self.Lib={decode:async function(t,e="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===e.toLowerCase())return await async function(t){return new Promise(((e,i)=>{const n=new ui(t).parse(),a=n.getUint8Data(),r=n.getWidth(),s=n.getHeight();e({data:a.data.buffer,width:r,height:s,itemSize:a.itemSize,bitDepth:n.bitDepth})}))}(t);throw new Error("Unsupported type")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;let i=0;for(;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}function c(t,e){return t<e?e:t}function d(t,e){return t<e?t:e}function u(t,e,n,i,r,s){t[e+0]=d(n[i+0],r[s+0]),t[e+1]=d(n[i+1],r[s+1]),t[e+2]=d(n[i+2],r[s+2]),t[e+3]=c(n[i+3],r[s+3]),t[e+4]=c(n[i+4],r[s+4]),t[e+5]=c(n[i+5],r[s+5])}function l(t,e,n,i,r,s,o,a){t[e+0]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function f(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function g(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function _(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function p(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function m(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];l(t,e,i,r,s,i,r,s)}function w(t,e,n){const i=t[e],r=t[e+1],s=t[e+2],o=t[e+3];return a=(r+t[e+4])/2,h=(s+t[e+5])/2,g((i+o)/2)|g(a)<<1|g(h)<<2;var a,h}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e)throw new Error(void 0!==n?n:`${t} !== ${e}`)},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const y=new Float32Array(18),v=[];class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}setLeafData(t,e,n,i,r,s,o,a){const h=7*t+6*this.__node_count_binary;l(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=f(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){return this.readBounds(t,y,0),this.readBounds(e,y,6),this.readBounds(n,y,12),f(p(y[0],y[6],y[12]),p(y[1],y[7],y[13]),p(y[2],y[8],y[14]),_(y[3],y[9],y[15]),_(y[4],y[10],y[16]),_(y[5],y[11],y[17]))}__fitness_function_should_swap_leaves_sah(t,e){const n=c(t-1,0),i=d(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,u=7*c(e-1,0)+r,l=7*d(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(u,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(u,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const t=v[r+1],o=v[r];n=o,i=t;const a=w(s,7*(o+t>>1)+e);for(;n<=i;){for(;w(s,7*n+e)<a;)n++;for(;w(s,7*i+e)>a;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}o<i&&(v[r++]=o,v[r++]=i),n<t&&(v[r++]=n,v[r++]=t)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){let s,o,a;for(a=0;a<7;a++){s=e+a,o=i+a;const r=n[o];n[o]=t[s],t[s]=r}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=2*n,r=t+1,s=e+7*t;r<a?u(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):m(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=Math.pow(2,o),s=r-1,n=0;n<r;n++){const t=1+(s<<1);u(c,6*s,c,6*t,c,6*(t+1)),s++}}}function b(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],m=n[h],w=n[h+1],y=n[h+2],v=p(c,l,m),x=p(d,f,w),b=p(u,g,y),A=_(c,l,m),E=_(d,f,w),S=_(u,g,y);t.setLeafData(e,e,v,x,b,A,E,S)}function A(t,e,n){return t<e?e:t>n?n:t}const E=function(t,e,n){return(e-t)*n+t},S="uint8",U="uint16",$="uint32",M="int8",F="int16",z="int32",B="float32",C="float64";function V(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return S;case Uint16Array:return U;case Uint32Array:return $;case Int8Array:return M;case Int16Array:return F;case Int32Array:return z;case Float32Array:return B;case Float64Array:return C;default:throw new Error("unsupported constructor type")}}const q={[S]:Uint8Array,[U]:Uint16Array,[$]:Uint32Array,[M]:Int8Array,[F]:Int16Array,[z]:Int32Array,float16:Uint16Array,[B]:Float32Array,[C]:Float64Array},L=[],T=[],I="undefined"!=typeof Uint8Array?Uint8Array:Array,N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)L[t]=N[t],T[N.charCodeAt(t)]=t;function k(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(L[(r=e)>>18&63]+L[r>>12&63]+L[r>>6&63]+L[63&r])}var r;return i.join("")}T["-".charCodeAt(0)]=62,T["_".charCodeAt(0)]=63;class O{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=k(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(L[e>>2]+L[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(L[e>>10]+L[e>>4&63]+L[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new I(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=T[t.charCodeAt(n)]<<18|T[t.charCodeAt(n+1)]<<12|T[t.charCodeAt(n+2)]<<6|T[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=T[t.charCodeAt(n)]<<2|T[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=T[t.charCodeAt(n)]<<10|T[t.charCodeAt(n+1)]<<4|T[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}class D{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}computeMax(t=0){throw new Error("deprecated, use sampler2d_channel_compute_max")}computeMinIndices(t,e=0,n=0){throw new Error("deprecated, use sampler2d_channel_compute_min_indices")}computeMin(t=0){throw new Error("deprecated, use sampler2d_channel_compute_min")}get(t,e,n){const i=[];return this.sampleBilinear(t,e,i,0),void 0!==n?(n.readFromArray(i,0),n):i[0]}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,m=i+2,w=r+2,y=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(y,p,n)*f*h,x+=this.sampleChannelBilinear(m,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(y,v,n)*f*g,x+=this.sampleChannelBilinear(m,v,n)*u*g,x+=this.sampleChannelBilinear(_,w,n)*a*l,x+=this.sampleChannelBilinear(y,w,n)*f*l,x+=this.sampleChannelBilinear(m,w,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,u=s-1,l=A(t,0,h),f=A(e,0,u),g=0|l,_=0|f,p=l-g,m=f-_,w=c(0,g-1),y=c(0,_-1),v=d(h,g+1),x=d(u,_+1),b=d(h,v+1),E=y*a+n,S=_*a+n,U=x*a+n,$=d(u,x+1)*a+n,M=w*i,F=g*i,z=v*i,B=b*i,C=o[E+M],V=o[E+F],q=o[E+z],L=o[E+B],T=o[S+M],I=o[S+F],N=o[S+z],k=o[S+B],O=o[U+M],D=o[U+F],R=o[U+z],J=o[U+B],P=o[$+M],W=o[$+F],H=o[$+z],G=o[$+B],Y=j(p,C,V,q,L),K=j(p,T,I,N,k),Q=j(p,O,D,R,J),X=j(p,P,W,H,G);return j(m,Y,K,Q,X)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=A(t,0,r-1),h=A(e,0,o),c=0|a,d=0|h,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,m=p[f];if(c===g&&d===_)return m;const w=a-c,y=h-d,v=g*i+n,x=_*s,b=x+l,S=x+v,U=p[u+v],$=p[b],M=p[S],F=E(m,U,w),z=E($,M,w);return E(F,z,y)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(A(s,0,i-1),A(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++){const e=this.data[s+t];n[t]=e}}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copyWithMargin(t,e,n,i,r,s,o,a,h,c,d){const u=this.itemSize,l=t.itemSize,f=Math.min(u,l),g=u*this.width,_=l*t.width,p=t.data,m=this.data;let w,y,v,x,b,A,E,S,U;for(U=n*_+e*u,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];for(E=n*_,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=0;w<s;w++)for(S=A+(w+i)*u,U=E+(w+e)*u,v=0;v<f;v++)m[S+v]=p[U+v];for(U=n*_+(e+s-1)*u,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];for(y=0;y<o;y++)for(A=(y+r)*g,E=(y+n)*_,U=E+e*u,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];for(this.copy(t,e,n,i,r,s,o),y=0;y<o;y++)for(A=(y+r)*g,E=(y+n)*_,U=E+(e+s-1)*u,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];for(U=(n+o-1)*_+e*u,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];for(E=(n+o-1)*_,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=0;w<s;w++)for(S=A+(w+i)*u,U=E+(w+e)*u,v=0;v<f;v++)m[S+v]=p[U+v];for(U=(n+o-1)*_+(e+s-1)*u,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[U+v];this.version++}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,m,w;for(m=0;m<h;m++){const t=(m+r)*l,s=(m+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(w=0;w<u;w++)_[n+w]=g[r+w]}}this.version++}copy_sameItemSize(t,e,n,i,r,s,o){const a=this.itemSize;t.itemSize;const h=Math.min(s,t.width-e,this.width-i),c=Math.min(o,t.height-n,this.height-r),d=a*this.width,u=a*t.width,l=t.data,f=this.data,g=h*a;let _,p;for(_=0;_<c;_++){const t=(_+r)*d+i*a,s=(_+n)*u+e*a;for(p=0;p<g;p++)f[t+p]=l[s+p]}this.version++}paint(t,e,n,i,r,s,o,a=0){let h;if(0!==a)throw new Error(`Unsupported blendType(=${a})`);h=R;const c=Math.min(s,t.width-e,this.width-i),d=Math.min(o,t.height-n,this.height-r),u=Math.max(0,-i),l=[0,0,0,255],f=[0,0,0,255],g=[];let _,p;for(p=Math.max(0,-r);p<d;p++)for(_=u;_<c;_++){const e=Math.round(_+i),s=Math.round(p+r);this.read(e,s,l);const o=Math.round(_+n),a=Math.round(p+n);t.read(o,a,f),h(f,l,g),this.set(e,s,g)}}zeroFill(t,e,n,i){const r=A(t,0,this.width),s=A(e,0,this.height),o=A(t+n,0,this.width),a=A(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}fill_channel(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=A(t,0,s),h=A(e,0,o),c=A(t+n,0,s),d=A(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=d(e,r),o=d(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}toBinaryBuffer(t){throw new Error("Deprecated, use Sampler2DSerializationAdapter instead")}fromBinaryBuffer(t){throw new Error("Deprecated, use Sampler2DSerializationAdapter instead")}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=31*r+t[e]|0;return r}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new D(t,this.itemSize,this.width,this.height)}toJSON(){const t=O.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:V(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=q[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=O.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new D(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new D(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new D(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new D(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new D(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new D(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new D(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new D(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new D(i,t,e,n)}}function j(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}function R(t,e,n){const i=t[3]/255,r=e[3]/255;n[0]=t[0]*i+e[0]*(1-i),n[1]=t[1]*i+e[1]*(1-i),n[2]=t[2]*i+e[2]*(1-i),n[3]=255*(i+r*(1-i))}D.prototype.isSampler2D=!0,D.typeName="Sampler2D";const J={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,m;const w=n.y/r.y/c,y=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,S,U;for(p=0;p<a;p++){const e=p*w+v;for(U=e*A,m=0;m<o;m++){const n=m*y+x;E=n*b,S=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=S,f[d+2]=U,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const $=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(m=0;m<h;m++){const t=m+o*p,e=m+o*(p+1),n=m+1+o*(p+1),i=m+1+o*p;$[d]=t,$[d+1]=e,$[d+2]=i,$[d+3]=e,$[d+4]=n,$[d+5]=i,d+=6}return function(t,e,n){let i,r,s,o,a,h,c,d,u,l,f,g,_,p,m,w,y,v,x,b,A,E=0;const S=n.length;for(;E<S;E+=3)i=3*n[E],r=3*n[E+1],s=3*n[E+2],o=t[i],a=t[i+1],h=t[i+2],c=t[r],d=t[r+1],u=t[r+2],l=t[s],f=t[s+1],g=t[s+2],_=l-c,p=f-d,m=g-u,w=o-c,y=a-d,v=h-u,x=p*v-m*y,b=m*w-_*v,A=_*y-p*w,e[i]+=x,e[i+1]+=b,e[i+2]+=A,e[r]+=x,e[r+1]+=b,e[r+2]+=A,e[s]+=x,e[s+1]+=b,e[s+2]+=A;!function(t){let e,n,i,r,s=0;const o=t.length;for(;s<o;s+=3)e=t[s],n=t[s+1],i=t[s+2],r=1/Math.sqrt(e*e+n*n+i*i),t[s]*=r,t[s+1]*=r,t[s+2]*=r}(e)}(f,g,$),{indices:$,vertices:f,normals:g,uvs:_}}};function P(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}function W(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function H(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let G=0;class Y{constructor(){this.index=G++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new Y;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return 1===this.faces.length}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){W(this.faces,t)}removeFace(t){P(this.faces,t)}getOtherVertex(t){return H(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function K(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}Y.prototype.isTopoEdge=!0;var Q,X="undefined"!=typeof Float32Array?Float32Array:Array;function Z(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),Q=new X(3),X!=Float32Array&&(Q[0]=0,Q[1]=0,Q[2]=0);let tt=0;class et{constructor(){this.index=tt++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),Z(this.normal,t.normal)}clone(){const t=new et;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){K(this.edges,t,e)}replaceVertex(t,e){K(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}removeEdge(t){P(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){!function(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,m=l*p-f*_,w=f*g-u*p,y=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(m,w,y);if(0===v)return t[0]=0,t[1]=1,void(t[2]=0);const x=1/Math.sqrt(v),b=m*x,A=w*x,E=y*x;t[0]=b,t[1]=A,t[2]=E}(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}et.prototype.isTopoFace=!0;class nt{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new nt;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z,Math.sqrt(function(t,e,n,i,r,s){const o=t-i,a=e-r,h=n-s;return o*o+a*a+h*h}(e,n,i,r,s,o));var e,n,i,r,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return W(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){P(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return P(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}function it(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}nt.prototype.isTopoVertex=!0;class rt{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new rt;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new et;Z(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new nt,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n);const r=n.vertices,s=r[0],o=r[1],a=r[2],h=this.ensureEdge(s,o),c=this.ensureEdge(o,a),d=this.ensureEdge(a,s);h.addUniqueFace(n),c.addUniqueFace(n),d.addUniqueFace(n),n.addUniqueEdge(h),n.addUniqueEdge(c),n.addUniqueEdge(d)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){W(this.vertices,t)}removeVertex(t){var e;e=t,P(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(H(i,t)===e)return i}const r=new Y;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new nt;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new et;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${it(this.vertices.length)}, edges: ${it(this.getEdges().size)}, faces: ${it(this.getFaces().size)} }`}}rt.prototype.isTopoMesh=!0,self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:D,BufferedGeometryArraysBuilder:J,tensionOptimizeUV:function(t,e,n,i){const r=new rt;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(r.isTopologyBorder())continue t;const s=2*r.getOtherVertex(n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
|
|
1
|
+
function t(t,e){const n=t.length;if(n!==e.length)return!1;let i=0;for(;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e)throw new Error(void 0!==n?n:`${t} !== ${e}`)},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const c=new Uint32Array(781250);function d(t,e){return t<e?e:t}function u(t,e){return t<e?t:e}function l(t,e,n,i,r,s){t[e+0]=u(n[i+0],r[s+0]),t[e+1]=u(n[i+1],r[s+1]),t[e+2]=u(n[i+2],r[s+2]),t[e+3]=d(n[i+3],r[s+3]),t[e+4]=d(n[i+4],r[s+4]),t[e+5]=d(n[i+5],r[s+5])}function f(t,e,n,i,r,s,o,a){t[e+0]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function g(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function p(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function m(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function w(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];f(t,e,i,r,s,i,r,s)}function y(t,e,n){const i=t[e],r=t[e+1],s=t[e+2];return function(t,e,n,i){const r=i[0],s=i[1],o=i[2],a=1023*(t-r)/(i[3]-r),h=1023*(e-s)/(i[4]-s),c=1023*(n-o)/(i[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(h),Math.round(c))}(.5*(i+t[e+3]),.5*(r+t[e+4]),.5*(s+t[e+5]),n)}c.pointer=0;const v=c;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}setLeafData(t,e,n,i,r,s,o,a){const h=7*t+6*this.__node_count_binary;f(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=g(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){const i=this.__data_float32;return g(m(i[t+0],i[e+0],i[n+0]),m(i[t+1],i[e+1],i[n+1]),m(i[t+2],i[e+2],i[n+2]),p(i[t+3],i[e+3],i[n+3]),p(i[t+4],i[e+4],i[n+4]),p(i[t+5],i[e+5],i[n+5]))}__fitness_function_should_swap_leaves_sah(t,e){const n=d(t-1,0),i=u(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,c=7*d(e-1,0)+r,l=7*u(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(c,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(c,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const o=v[r+1],a=v[r];n=a,i=o;const h=y(s,7*(a+o>>1)+e,t);for(;n<=i;){for(;y(s,7*n+e,t)<h;)n++;for(;y(s,7*i+e,t)>h;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}a<i&&(v[r++]=a,v[r++]=i),n<o&&(v[r++]=n,v[r++]=o)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){let s,o,a;for(a=0;a<7;a++){s=e+a,o=i+a;const r=n[o];n[o]=t[s],t[s]=r}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=2*n,r=t+1,s=e+7*t;r<a?l(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):w(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=Math.pow(2,o),s=r-1,n=0;n<r;n++){const t=1+(s<<1);l(c,6*s,c,6*t,c,6*(t+1)),s++}}}function b(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],_=n[h],w=n[h+1],y=n[h+2],v=m(c,l,_),x=m(d,f,w),b=m(u,g,y),A=p(c,l,_),E=p(d,f,w),S=p(u,g,y);t.setLeafData(e,e,v,x,b,A,E,S)}function A(t,e,n){return t<e?e:t>n?n:t}const E=function(t,e,n){return(e-t)*n+t},S="uint8",M="uint16",U="uint32",$="int8",F="int16",z="int32",C="float32",B="float64";function V(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return S;case Uint16Array:return M;case Uint32Array:return U;case Int8Array:return $;case Int16Array:return F;case Int32Array:return z;case Float32Array:return C;case Float64Array:return B;default:throw new Error("unsupported constructor type")}}const q={[S]:Uint8Array,[M]:Uint16Array,[U]:Uint32Array,[$]:Int8Array,[F]:Int16Array,[z]:Int32Array,float16:Uint16Array,[C]:Float32Array,[B]:Float64Array},L=[],T=[],I="undefined"!=typeof Uint8Array?Uint8Array:Array,N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)L[t]=N[t],T[N.charCodeAt(t)]=t;function k(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(L[(r=e)>>18&63]+L[r>>12&63]+L[r>>6&63]+L[63&r])}var r;return i.join("")}T["-".charCodeAt(0)]=62,T["_".charCodeAt(0)]=63;class O{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=k(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(L[e>>2]+L[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(L[e>>10]+L[e>>4&63]+L[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new I(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=T[t.charCodeAt(n)]<<18|T[t.charCodeAt(n+1)]<<12|T[t.charCodeAt(n+2)]<<6|T[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=T[t.charCodeAt(n)]<<2|T[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=T[t.charCodeAt(n)]<<10|T[t.charCodeAt(n+1)]<<4|T[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}class D{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}computeMax(t=0){throw new Error("deprecated, use sampler2d_channel_compute_max")}computeMinIndices(t,e=0,n=0){throw new Error("deprecated, use sampler2d_channel_compute_min_indices")}computeMin(t=0){throw new Error("deprecated, use sampler2d_channel_compute_min")}get(t,e,n){const i=[];return this.sampleBilinear(t,e,i,0),void 0!==n?(n.readFromArray(i,0),n):i[0]}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,m=i+2,w=r+2,y=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(y,p,n)*f*h,x+=this.sampleChannelBilinear(m,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(y,v,n)*f*g,x+=this.sampleChannelBilinear(m,v,n)*u*g,x+=this.sampleChannelBilinear(_,w,n)*a*l,x+=this.sampleChannelBilinear(y,w,n)*f*l,x+=this.sampleChannelBilinear(m,w,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,c=s-1,l=A(t,0,h),f=A(e,0,c),g=0|l,_=0|f,p=l-g,m=f-_,w=d(0,g-1),y=d(0,_-1),v=u(h,g+1),x=u(c,_+1),b=u(h,v+1),E=y*a+n,S=_*a+n,M=x*a+n,U=u(c,x+1)*a+n,$=w*i,F=g*i,z=v*i,C=b*i,B=o[E+$],V=o[E+F],q=o[E+z],L=o[E+C],T=o[S+$],I=o[S+F],N=o[S+z],k=o[S+C],O=o[M+$],D=o[M+F],R=o[M+z],J=o[M+C],P=o[U+$],W=o[U+F],H=o[U+z],G=o[U+C],Y=j(p,B,V,q,L),K=j(p,T,I,N,k),Q=j(p,O,D,R,J),X=j(p,P,W,H,G);return j(m,Y,K,Q,X)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=A(t,0,r-1),h=A(e,0,o),c=0|a,d=0|h,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,m=p[f];if(c===g&&d===_)return m;const w=a-c,y=h-d,v=g*i+n,x=_*s,b=x+l,S=x+v,M=p[u+v],U=p[b],$=p[S],F=E(m,M,w),z=E(U,$,w);return E(F,z,y)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(A(s,0,i-1),A(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++){const e=this.data[s+t];n[t]=e}}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copyWithMargin(t,e,n,i,r,s,o,a,h,c,d){const u=this.itemSize,l=t.itemSize,f=Math.min(u,l),g=u*this.width,_=l*t.width,p=t.data,m=this.data;let w,y,v,x,b,A,E,S,M;for(M=n*_+e*u,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];for(E=n*_,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=0;w<s;w++)for(S=A+(w+i)*u,M=E+(w+e)*u,v=0;v<f;v++)m[S+v]=p[M+v];for(M=n*_+(e+s-1)*u,y=Math.max(0,r-c),b=r;y<b;y++)for(A=y*g,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];for(y=0;y<o;y++)for(A=(y+r)*g,E=(y+n)*_,M=E+e*u,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];for(this.copy(t,e,n,i,r,s,o),y=0;y<o;y++)for(A=(y+r)*g,E=(y+n)*_,M=E+(e+s-1)*u,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];for(M=(n+o-1)*_+e*u,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=Math.max(0,i-a),x=i;w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];for(E=(n+o-1)*_,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=0;w<s;w++)for(S=A+(w+i)*u,M=E+(w+e)*u,v=0;v<f;v++)m[S+v]=p[M+v];for(M=(n+o-1)*_+(e+s-1)*u,y=r+s,b=Math.min(this.height,y+d);y<b;y++)for(A=y*g,w=i+s,x=Math.min(this.width,w+h);w<x;w++)for(S=A+w*u,v=0;v<f;v++)m[S+v]=p[M+v];this.version++}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,m,w;for(m=0;m<h;m++){const t=(m+r)*l,s=(m+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(w=0;w<u;w++)_[n+w]=g[r+w]}}this.version++}copy_sameItemSize(t,e,n,i,r,s,o){const a=this.itemSize;t.itemSize;const h=Math.min(s,t.width-e,this.width-i),c=Math.min(o,t.height-n,this.height-r),d=a*this.width,u=a*t.width,l=t.data,f=this.data,g=h*a;let _,p;for(_=0;_<c;_++){const t=(_+r)*d+i*a,s=(_+n)*u+e*a;for(p=0;p<g;p++)f[t+p]=l[s+p]}this.version++}paint(t,e,n,i,r,s,o,a=0){let h;if(0!==a)throw new Error(`Unsupported blendType(=${a})`);h=R;const c=Math.min(s,t.width-e,this.width-i),d=Math.min(o,t.height-n,this.height-r),u=Math.max(0,-i),l=[0,0,0,255],f=[0,0,0,255],g=[];let _,p;for(p=Math.max(0,-r);p<d;p++)for(_=u;_<c;_++){const e=Math.round(_+i),s=Math.round(p+r);this.read(e,s,l);const o=Math.round(_+n),a=Math.round(p+n);t.read(o,a,f),h(f,l,g),this.set(e,s,g)}}zeroFill(t,e,n,i){const r=A(t,0,this.width),s=A(e,0,this.height),o=A(t+n,0,this.width),a=A(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}fill_channel(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=A(t,0,s),h=A(e,0,o),c=A(t+n,0,s),d=A(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=u(e,r),o=u(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}toBinaryBuffer(t){throw new Error("Deprecated, use Sampler2DSerializationAdapter instead")}fromBinaryBuffer(t){throw new Error("Deprecated, use Sampler2DSerializationAdapter instead")}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=31*r+t[e]|0;return r}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new D(t,this.itemSize,this.width,this.height)}toJSON(){const t=O.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:V(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=q[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=O.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new D(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new D(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new D(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new D(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new D(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new D(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new D(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new D(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new D(i,t,e,n)}}function j(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}function R(t,e,n){const i=t[3]/255,r=e[3]/255;n[0]=t[0]*i+e[0]*(1-i),n[1]=t[1]*i+e[1]*(1-i),n[2]=t[2]*i+e[2]*(1-i),n[3]=255*(i+r*(1-i))}D.prototype.isSampler2D=!0,D.typeName="Sampler2D";const J={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,m;const w=n.y/r.y/c,y=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,S,M;for(p=0;p<a;p++){const e=p*w+v;for(M=e*A,m=0;m<o;m++){const n=m*y+x;E=n*b,S=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=S,f[d+2]=M,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const U=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(m=0;m<h;m++){const t=m+o*p,e=m+o*(p+1),n=m+1+o*(p+1),i=m+1+o*p;U[d]=t,U[d+1]=e,U[d+2]=i,U[d+3]=e,U[d+4]=n,U[d+5]=i,d+=6}return function(t,e,n){let i,r,s,o,a,h,c,d,u,l,f,g,_,p,m,w,y,v,x,b,A,E=0;const S=n.length;for(;E<S;E+=3)i=3*n[E],r=3*n[E+1],s=3*n[E+2],o=t[i],a=t[i+1],h=t[i+2],c=t[r],d=t[r+1],u=t[r+2],l=t[s],f=t[s+1],g=t[s+2],_=l-c,p=f-d,m=g-u,w=o-c,y=a-d,v=h-u,x=p*v-m*y,b=m*w-_*v,A=_*y-p*w,e[i]+=x,e[i+1]+=b,e[i+2]+=A,e[r]+=x,e[r+1]+=b,e[r+2]+=A,e[s]+=x,e[s+1]+=b,e[s+2]+=A;!function(t){let e,n,i,r,s=0;const o=t.length;for(;s<o;s+=3)e=t[s],n=t[s+1],i=t[s+2],r=1/Math.sqrt(e*e+n*n+i*i),t[s]*=r,t[s+1]*=r,t[s+2]*=r}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};function P(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}function W(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function H(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let G=0;class Y{constructor(){this.index=G++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new Y;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return 1===this.faces.length}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){W(this.faces,t)}removeFace(t){P(this.faces,t)}getOtherVertex(t){return H(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function K(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}Y.prototype.isTopoEdge=!0;var Q,X="undefined"!=typeof Float32Array?Float32Array:Array;function Z(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),Q=new X(3),X!=Float32Array&&(Q[0]=0,Q[1]=0,Q[2]=0);let tt=0;class et{constructor(){this.index=tt++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),Z(this.normal,t.normal)}clone(){const t=new et;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){K(this.edges,t,e)}replaceVertex(t,e){K(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}removeEdge(t){P(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){!function(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,m=l*p-f*_,w=f*g-u*p,y=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(m,w,y);if(0===v)return t[0]=0,t[1]=1,void(t[2]=0);const x=1/Math.sqrt(v),b=m*x,A=w*x,E=y*x;t[0]=b,t[1]=A,t[2]=E}(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}et.prototype.isTopoFace=!0;class nt{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new nt;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,o=t.z,Math.sqrt(function(t,e,n,i,r,s){const o=t-i,a=e-r,h=n-s;return o*o+a*a+h*h}(e,n,i,r,s,o));var e,n,i,r,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return W(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){P(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return P(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}function it(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}nt.prototype.isTopoVertex=!0;class rt{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new rt;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new et;Z(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new nt,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n);const r=n.vertices,s=r[0],o=r[1],a=r[2],h=this.ensureEdge(s,o),c=this.ensureEdge(o,a),d=this.ensureEdge(a,s);h.addUniqueFace(n),c.addUniqueFace(n),d.addUniqueFace(n),n.addUniqueEdge(h),n.addUniqueEdge(c),n.addUniqueEdge(d)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){W(this.vertices,t)}removeVertex(t){var e;e=t,P(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(H(i,t)===e)return i}const r=new Y;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new nt;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new et;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${it(this.vertices.length)}, edges: ${it(this.getEdges().size)}, faces: ${it(this.getFaces().size)} }`}}rt.prototype.isTopoMesh=!0,self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:D,BufferedGeometryArraysBuilder:J,tensionOptimizeUV:function(t,e,n,i){const r=new rt;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(r.isTopologyBorder())continue t;const s=2*r.getOtherVertex(n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
|