rapier-jxl 2.2.0 → 2.2.1
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/AGENTS.md +23 -28
- package/README.md +63 -158
- package/{effort.min.mjs → dist/effort.min.mjs} +1 -1
- package/{jpeg-ans.min.mjs → dist/jpeg-ans.min.mjs} +1 -1
- package/{jpeg.min.mjs → dist/jpeg.min.mjs} +1 -1
- package/{photo-ans.min.mjs → dist/photo-ans.min.mjs} +1 -1
- package/{photo.min.mjs → dist/photo.min.mjs} +1 -1
- package/{rapier-jxl.min.mjs → dist/rapier-jxl.min.mjs} +1 -1
- package/{sizes.json → dist/sizes.json} +24 -24
- package/{wasm.min.mjs → dist/wasm.min.mjs} +1 -1
- package/{build-jxl-kernels.mjs → kernels/build.mjs} +6 -4
- package/package.json +32 -39
- package/ENCODER-COMPARISON.md +0 -185
- package/KERNELS.md +0 -58
- package/public/encoder-sizes.json +0 -355
- package/public/encoders.json +0 -139
- package/public/examples/browser.html +0 -39
- package/public/examples/worker.mjs +0 -42
- package/public/measure-encoders.mjs +0 -60
- /package/{kernels-probe.wat → kernels/kernels-probe.wat} +0 -0
- /package/{kernels-scalar.wat → kernels/kernels-scalar.wat} +0 -0
- /package/{kernels-simd.wat → kernels/kernels-simd.wat} +0 -0
- /package/{admit.mjs → src/admit.mjs} +0 -0
- /package/{ans.mjs → src/ans.mjs} +0 -0
- /package/{bits.mjs → src/bits.mjs} +0 -0
- /package/{coefficient-ans.mjs → src/coefficient-ans.mjs} +0 -0
- /package/{coefficient-effort.mjs → src/coefficient-effort.mjs} +0 -0
- /package/{effort-job.mjs → src/effort-job.mjs} +0 -0
- /package/{effort-level.mjs → src/effort-level.mjs} +0 -0
- /package/{effort.d.mts → src/effort.d.mts} +0 -0
- /package/{effort.mjs → src/effort.mjs} +0 -0
- /package/{entropy.mjs → src/entropy.mjs} +0 -0
- /package/{frame.mjs → src/frame.mjs} +0 -0
- /package/{index.d.mts → src/index.d.mts} +0 -0
- /package/{index.mjs → src/index.mjs} +0 -0
- /package/{jfif.mjs → src/jfif.mjs} +0 -0
- /package/{jpeg-ans.d.mts → src/jpeg-ans.d.mts} +0 -0
- /package/{jpeg-ans.mjs → src/jpeg-ans.mjs} +0 -0
- /package/{jpeg-job.mjs → src/jpeg-job.mjs} +0 -0
- /package/{jpeg.d.mts → src/jpeg.d.mts} +0 -0
- /package/{jpeg.mjs → src/jpeg.mjs} +0 -0
- /package/{kernel-control.d.mts → src/kernel-control.d.mts} +0 -0
- /package/{kernel-hooks.mjs → src/kernel-hooks.mjs} +0 -0
- /package/{kernels-bytes.mjs → src/kernels-bytes.mjs} +0 -0
- /package/{kernels.mjs → src/kernels.mjs} +0 -0
- /package/{local.mjs → src/local.mjs} +0 -0
- /package/{lossless-coding.mjs → src/lossless-coding.mjs} +0 -0
- /package/{lossless.mjs → src/lossless.mjs} +0 -0
- /package/{lossy.mjs → src/lossy.mjs} +0 -0
- /package/{modular.mjs → src/modular.mjs} +0 -0
- /package/{photo-ans.d.mts → src/photo-ans.d.mts} +0 -0
- /package/{photo-ans.mjs → src/photo-ans.mjs} +0 -0
- /package/{photo-dct.mjs → src/photo-dct.mjs} +0 -0
- /package/{photo-job.mjs → src/photo-job.mjs} +0 -0
- /package/{photo-quant.mjs → src/photo-quant.mjs} +0 -0
- /package/{photo.d.mts → src/photo.d.mts} +0 -0
- /package/{photo.mjs → src/photo.mjs} +0 -0
- /package/{pool.mjs → src/pool.mjs} +0 -0
- /package/{prefix.mjs → src/prefix.mjs} +0 -0
- /package/{rct-search.mjs → src/rct-search.mjs} +0 -0
- /package/{squeeze.mjs → src/squeeze.mjs} +0 -0
- /package/{vardct.mjs → src/vardct.mjs} +0 -0
- /package/{wasm.d.mts → src/wasm.d.mts} +0 -0
- /package/{wasm.mjs → src/wasm.mjs} +0 -0
- /package/{weighted.mjs → src/weighted.mjs} +0 -0
- /package/{writer.mjs → src/writer.mjs} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Rapier JXL 2.2.
|
|
1
|
+
/*! Rapier JXL 2.2.1 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
2
2
|
const t=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),o=Object.freeze({bytes:16777216,pixels:64e6,edge:16384}),n=[1];for(let t=1;t<=32;t++)n.push(2*n[t-1]);class r{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.t=0,this.pending=0}write(t,o){if(!(o>=0&&o<n[t]))throw new Error("bit write out of range: "+t+" bits, "+o);let r=this.t+o*(1<<this.pending),e=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const i=this.bytes;for(;e>=8;)i[this.at++]=255&r,r=Math.floor(r/256),e-=8;this.t=r,this.pending=e}o(t,o){for(let r=0;r<4;r++){const[e,i]=t[r];if(o>=i&&o-i<n[e])return this.write(2,r),void(e&&this.write(e,o-i))}throw new Error("U32 value out of range: "+o)}i(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.t,this.t=0,this.pending=0)}get u(){return 8*this.at+this.pending}grow(o=0){const n=t.bytes+64;if(this.at+o+16>n)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const r=new Uint8Array(Math.min(n,Math.max(2*this.bytes.length,this.at+o+16)));r.set(this.bytes.subarray(0,this.at)),this.bytes=r}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let o=0;o<t.at;o++)this.write(8,t.bytes[o]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.t)}finish(){const t=this.at+(this.pending?1:0),o=this.bytes.slice(0,t);return this.pending&&(o[this.at]=this.t),o}}function e(t){return t>=0?2*t:2*-t-1}function i(t){return 31-Math.clz32(t)}function s(t){return t<=1?0:32-Math.clz32(t-1)}function f(t){if(0===t)return 0;const o=t<0?32768:0;if(!((t=Math.abs(t))<65520))throw new Error("half float out of range: "+t);let n=0,r=t;for(;r>=2;)r/=2,n++;for(;r<1;)r*=2,n--;n<-14?(r=16384*t,n=-15):r-=1;let e=Math.round(1024*r);return 1024===e&&(e=0,n++),o|n+15<<10|e}const c=[0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63];function a(t,o="JXL_JPEG"){return Object.assign(new Error("JPEG: "+t),{code:o})}function l(t,o){const n=new Uint16Array(65536);let r=0,e=0;for(let i=1;i<=16;i++){for(let s=0;s<t[i-1];s++){const t=o[e++],s=r<<16-i,f=1<<16-i;if(s+f>=65536)throw a("bad Huffman table");n.fill(i<<8|t,s,s+f),r++}r<<=1}return n}const h=[.436,.2225,.0139,.3851,.7169,.0971,.143,.0606,.7139],u=[.5151,.2412,-.001,.292,.6922,.0419,.1571,.0666,.7841],w=[0,.00516,.01435,.02934,.05088,.07958,.11602,.16068,.21404,.27652,.34851,.43039,.52252,.62523,.73884,.86367,1],d=[2.4,1/1.055,.055/1.055,1/12.92,.04045];function p(t){if(t<=.04045)return t/12.92;const o=(t+.055)/1.055;let n=1;for(let t=0;t<24;t++)n=(4*n+o/(n*n*n*n))/5;return o*o*n*n}function y(t,o,n){const r=77===t[o]&&77===t[o+1];if(!r&&(73!==t[o]||73!==t[o+1]))return 1;const e=o=>o+2>n?0:r?t[o]<<8|t[o+1]:t[o]|t[o+1]<<8;if(42!==e(o+2))return 1;const i=o+(o=>o+4>n?0:r?(t[o]<<24|t[o+1]<<16|t[o+2]<<8|t[o+3])>>>0:(t[o]|t[o+1]<<8|t[o+2]<<16|t[o+3]<<24)>>>0)(o+4),s=e(i);for(let t=0,o=i+2;t<s&&o+12<=n;t++,o+=12){if(274!==e(o))continue;const t=e(o+8);return t>=1&&t<=8?t:1}return 1}function b(t,o,n,r,e,i,s,f,l){!function(t,o,n,r,e,i){if(!t.progressive){if(0!==n||63!==r||0!==e||0!==i)throw a("a bad spectral selection");for(const t of o){if(t.component.coverage.some(t=>-1!==t))throw a("a component coded twice");t.component.coverage.fill(0)}return}if(i>13||e&&e!==i+1)throw a("a bad successive approximation");if(0===n){if(0!==r)throw a("a bad spectral selection");for(const{component:t}of o){if(t.coverage[0]!==(e||-1))throw a(e?"a refinement scan out of order":"a DC scan twice");t.coverage[0]=i}return}if(1!==o.length)throw a("an interleaved AC scan");if(r>63||n>r)throw a("a bad spectral selection");const{coverage:s}=o[0].component;if(-1===s[0])throw a("an AC scan before the DC scan");for(let t=n;t<=r;t++){if(s[t]!==(e||-1))throw a(e?"a refinement scan out of order":"a band coded twice");s[t]=i}}(n,r,e,i,s,f);let h=o,u=0,w=0,d=0,p=!1;const y=()=>{for(;w<=24;){let o=0;if(p||h>=t.length)p=!0,d+=8;else if(o=t[h],255===o){const n=t[h+1];if(0===n)h+=2;else{if(255===n){h++;continue}p=!0,o=0,d+=8}}else h++;u=(u<<8|o)>>>0,w+=8}},b=()=>a("a scan cut short"),m=t=>{if(!t)return 0;if(y(),t>w-d)throw b();const o=u>>>w-t&(1<<t)-1;return w-=t,o},g=(t,o)=>t<1<<o-1?t-(1<<o)+1:t,M=t=>{if(!t)throw a("a scan without its Huffman table");y();const o=t[u>>>w-16&65535];if(!o)throw a("bad Huffman code");if(o>>8>w-d)throw b();return w-=o>>8,255&o},A=()=>{const o=w-d;if(o>=8)throw a("bytes left over in a scan");if(E)throw a("an end-of-band run past its interval");if(o&&(u>>>d&(1<<o)-1)!=(1<<o)-1)throw a("bad scan padding");for(;h+1<t.length&&255===t[h]&&255===t[h+1];)h++},U=o=>{if(A(),255!==t[h]||t[h+1]!==208+(7&o))throw a("a restart marker missing or out of order");h+=2,u=0,w=0,d=0,p=!1;for(const t of r)t.component.pred=0;E=0},x=(t,o)=>{if(o>11)throw a("a DC value out of range");const n=o?g(m(o),o):0;if(t.component.pred+=n,t.component.pred>2047||t.component.pred<-2048)throw a("a DC value out of range");return t.component.pred},I=(t,o)=>{if(t>10)throw a("an AC value out of range");const n=g(m(t),t)*(1<<o);if(n>1023||n<-1023)throw a("an AC value out of range");return n};let E=0;const v=1===r.length,C=n.progressive,S=()=>a("coefficients past the "+(C?"band":"block")),J=(t,o,n)=>{if(E>0)E--;else for(let r=e||1;r<=i;){const e=M(t.ac),s=e>>4,l=15&e;if(l){if(r+=s,r>i)throw S();o[n+c[r]]=I(l,f),r++}else{if(s<15){if(s&&!C)throw a("an end-of-band run in a sequential scan");E=(1<<s)-1+(s?m(s):0);break}if(r+=16,r>i+1)throw S()}}},L=C?0===e?0===s?(t,o,n)=>{const r=x(t,M(t.dc))*(1<<f);if(r>2047||r<-2048)throw a("a DC value out of range");o[n]=r}:(t,o,n)=>{m(1)&&(o[n]|=1<<f)}:0===s?J:(t,o,n)=>{const r=1<<f,s=-1<<f;let l=e;if(E<=0)for(;l<=i;l++){const e=M(t.ac);let f=e>>4,h=0;const u=15&e;if(u){if(1!==u)throw a("a bad refinement code");h=m(1)?r:s}else if(15!==f){E=1<<f,f&&(E+=m(f));break}for(;l<=i;l++){const t=n+c[l];if(0!==o[t])m(1)&&0===(o[t]&r)&&(o[t]+=o[t]>=0?r:s);else if(--f<0)break}if(f>=0||h&&l>i)throw a("coefficients past the band");h&&(o[n+c[l]]=h)}if(E>0){for(;l<=i;l++){const t=n+c[l];0!==o[t]&&m(1)&&0===(o[t]&r)&&(o[t]+=o[t]>=0?r:s)}E--}}:(t,o,n)=>{o[n]=x(t,M(t.dc)),J(t,o,n)};for(const t of r)t.component.pred=0;const X=r[0].component,k=v?X.blocksW*X.blocksH:n.mcusX*n.mcusY;for(let t=0;t<k;t++)if(l&&t>0&&t%l===0&&U(t/l-1),v){const o=t/X.blocksW|0,n=t-o*X.blocksW;L(r[0],X.coeffs,64*(o*X.stride+n))}else{const o=t/n.mcusX|0,e=t-o*n.mcusX;for(const t of r){const n=t.component;for(let r=0;r<n.v;r++)for(let i=0;i<n.h;i++)L(t,n.coeffs,64*((o*n.v+r)*n.stride+e*n.h+i))}}if(A(),255===t[h]&&t[h+1]>=208&&t[h+1]<=215){if(!l||k%l||t[h+1]!==208+(k/l-1&7))throw a("a restart marker out of order");for(h+=2;h+1<t.length&&255===t[h]&&255===t[h+1];)h++}if(h<t.length&&!(255===t[h]&&h+1<t.length&&0!==t[h+1]&&255!==t[h+1]))throw a("bytes left over after a scan");return h}const m=(t,o)=>Object.assign(new Error(o),{code:t});function g(o){if(o>t.bytes)throw m("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function M(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw m("JXL_MEMORY","Not enough memory for this picture.");throw t}}function A(n,r,e){const i=function(t={}){if(null===t||"object"!=typeof t)throw m("JXL_INPUT","Options are an object.");const o=void 0===t.effort?1:t.effort;if(!Number.isInteger(o)||o<1||o>9)throw m("JXL_INPUT","Effort is a whole number from 1 to 9.");return o}(r);if(!(n instanceof Uint8Array&&n.length))throw m("JXL_INPUT","A JPEG is a non-empty Uint8Array.");if(n.length>o.bytes)throw m("JXL_SIZE","A JPEG is at most 16 MiB.");const s=function(t){const o=function*(){let n,r;for(;!(n=M(()=>t.next(o.hurry))).done;)yield r=n.value;return r<1&&(yield 1),o.bytes=function(t){return g(t.length),t}(n.value)}();return o.bytes=null,o.hurry=!1,o}(function*(n,r,e,i){const f=function(t){if(!(t.length>4)||255!==t[0]||216!==t[1])throw a("not a JPEG");const n=[],r=[[],[]],e=new Set,i={count:0,p:[]};let s=null,f=0,m=-1,g=!1,M=1,A=2;const U=o=>t[o]<<8|t[o+1],x=(o,n)=>{for(let r=0;r<n.length;r++)if(t[o+r]!==n.charCodeAt(r))return!1;return!0};for(;;){if(A>=t.length){if(s&&s.scans)break;throw a("truncated")}if(255!==t[A])throw a("marker expected");for(;255===t[A];)A++;const h=t[A++];if(217===h)break;if(216===h)throw a("a second start");if(h>=208&&h<=215)throw a("a restart marker outside a scan");if(1===h)continue;if(A+2>t.length)throw a("truncated");const u=U(A),w=A+2,d=A+u;if(u<2||d>t.length)throw a("bad segment");if(A=d,219===h)for(let o=w;o<d;){const r=t[o]>>4,e=15&t[o];if(r>1||e>3||o+1+(r?128:64)>d)throw a("bad quantisation table");o++;const i=new Int32Array(64);for(let n=0;n<64;n++)if(i[c[n]]=r?U(o):t[o],o+=r?2:1,!i[c[n]])throw a("a zero quantisation step");if(s?.progressive&&s.components.some(t=>t.tq===e&&t.quant&&t.coverage.some(t=>0!==t)&&t.quant.some((t,o)=>t!==i[o])))throw a("a quantisation table changed between progressive scans");n[e]=i}else if(196===h)for(let o=w;o<d;){const n=t[o]>>4,i=15&t[o];if(n>1||i>3||o+17>d)throw a("bad Huffman table");o++;const s=t.subarray(o,o+16);let f=0;for(const t of s)f+=t;if(f>256||o+16+f>d)throw a("bad Huffman table");const c=t.subarray(o+16,o+16+f);r[n][i]=l(s,c),0===n&&(c.some(t=>t>15)?e.add(i):e.delete(i)),o+=16+f}else if(192===h||193===h||194===h){if(s)throw a("two frames");if(d-w<6)throw a("bad frame header");if(8!==t[w])throw a("only 8-bit samples");const n=U(w+1),r=U(w+3),e=t[w+5];if(!r||!n)throw a("a height left to a DNL marker");if(1!==e&&3!==e)throw a("only grey or three components");if(d-w<6+3*e)throw a("bad frame header");if(r>o.edge||n>o.edge)throw a("a picture past "+o.edge+" pixels on a side","JXL_DIMENSIONS");if(r*n>o.pixels)throw a("a picture past "+o.pixels+" pixels","JXL_DIMENSIONS");const i=[];let f=0;for(let o=0,n=w+6;o<e;o++,n+=3){const o=t[n+1]>>4,r=15&t[n+1],e=t[n+2];if(o<1||o>4||r<1||r>4)throw a("bad sampling");if(e>3)throw a("bad quantisation table");if(i.some(o=>o.id===t[n]))throw a("two components with one id");f+=o*r,i.push({id:t[n],h:o,v:r,tq:e,pred:0,coverage:new Int8Array(64).fill(-1)})}if(f>10)throw a("bad sampling");const c=Math.max(...i.map(t=>t.h)),l=Math.max(...i.map(t=>t.v)),u=Math.ceil(r/(8*c)),p=Math.ceil(n/(8*l));for(const t of i)t.blocksW=Math.ceil(Math.ceil(r*t.h/c)/8),t.blocksH=Math.ceil(Math.ceil(n*t.v/l)/8),t.stride=u*t.h,t.rows=p*t.v,t.coeffs=new Int16Array(t.stride*t.rows*64);s={progressive:194===h,width:r,height:n,components:i,hmax:c,vmax:l,mcusX:u,mcusY:p,scans:0}}else{if(195===h||h>=197&&h<=199||h>=201&&h<=203||h>=205&&h<=207)throw a("lossless, hierarchical or arithmetic coding");if(221===h){if(u<4)throw a("bad segment");f=U(w)}else{if(220===h)throw a("a DNL marker");if(218===h){if(!s)throw a("a scan before the frame");const o=t[w],i=[];if(o<1||o>4||w+1+2*o+3>d)throw a("bad scan header");let c=w+1;for(let e=0;e<o;e++,c+=2){const o=s.components.find(o=>o.id===t[c]);if(!o)throw a("a scan of an unknown component");if(i.some(t=>t.component===o))throw a("a component twice in one scan");if(o.quant||(o.quant=n[o.tq]),!o.quant)throw a("a scan without its quantisation table");i.push({component:o,dc:r[0][t[c+1]>>4],ac:r[1][15&t[c+1]],dcSlot:t[c+1]>>4})}const l=t[c],h=t[c+1],u=t[c+2]>>4,p=15&t[c+2];if((!s.progressive||0===l&&0===u)&&i.some(t=>e.has(t.dcSlot)))throw a("bad Huffman table");A=b(t,d,s,i,l,h,u,p,f),s.scans++}else if(224===h)x(w,"JFIF")&&(g=!0);else if(225===h)1===M&&x(w,"Exif")&&(M=y(t,w+6,d));else if(226===h){if(u>=16&&x(w,"ICC_PROFILE\0")){const o=t[w+12],n=t[w+13];if(!o||!n||o>n||i.count&&i.count!==n||i.p[o])throw a("a colour profile cut short");i.count=n,i.p[o]=t.subarray(w+14,d)}}else 238===h&&u>=14&&x(w,"Adobe")&&(m=t[w+11])}}}if(!s||!s.scans)throw a("no picture");for(const t of s.components)for(let o=0;o<64;o++)if(0!==t.coverage[o])throw a(s.progressive?"a progressive JPEG whose scans do not finish every coefficient":"a component without its scan");let I="srgb";if(i.count){const t=[];for(let o=1;o<=i.count;o++){if(!i.p[o])throw a("a colour profile cut short");t.push(i.p[o])}const o=new Uint8Array(t.reduce((t,o)=>t+o.length,0));for(let n=0,r=0;n<t.length;r+=t[n].length,n++)o.set(t[n],r);if(I=function(t){const o=t.length,n=o=>t[o]<<8|t[o+1],r=n=>n+4<=o?(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0:0,e=n=>n+4<=o?String.fromCharCode(t[n],t[n+1],t[n+2],t[n+3]):"",i=t=>(0|r(t))/65536,s=r(128);if(o<132||132+12*s>o||"acsp"!==e(36)||"XYZ "!==e(20))return null;const f=t=>{for(let n=0;n<s;n++){const i=132+12*n,s=r(i+4);if(e(i)===t)return s+r(i+8)<=o?s:-1}return-1},c=t=>{const s=f(t);if(s<0)return!1;if("para"===e(s)){const t=n(s+8),o=[1,3,4,5,7][t];if(3!==t&&4!==t)return!1;for(let t=0;t<o;t++)if(Math.abs(i(s+12+4*t)-(t<5?d[t]:0))>(t?.002:.01))return!1;return!0}const c="curv"===e(s)?r(s+8):0;if(c<2||s+12+2*c>o)return!1;for(let t=0;t<c;t++)if(Math.abs(n(s+12+2*t)/65535-p(t/(c-1)))>.001)return!1;return w.every((t,o)=>{const r=o*(c-1)/16,e=Math.floor(r),i=Math.min(c-1,e+1),f=r-e;return Math.abs((n(s+12+2*e)*(1-f)+n(s+12+2*i)*f)/65535-t)<=.001})};if(["A2B0","A2B1","A2B2"].some(t=>f(t)>=0))return null;if("GRAY"===e(16))return c("kTRC")?"srgb":null;if("RGB "!==e(16)||!["rTRC","gTRC","bTRC"].every(c))return null;const a=["rXYZ","gXYZ","bXYZ"].flatMap(t=>{const o=f(t);return o>=0&&"XYZ "===e(o)?[i(o+8),i(o+12),i(o+16)]:[9,9,9]}),l=t=>t.every((t,o)=>Math.abs(a[o]-t)<=.004);return l(h)?"srgb":l(u)?"display-p3":null}(o),!I)throw a("a colour profile other than sRGB or Display P3 (decode the picture and encode its pixels)")}let E=!1;return 3!==s.components.length||g||(E=m>=0?0===m:82===s.components[0].id&&71===s.components[1].id&&66===s.components[2].id),{width:s.width,height:s.height,components:s.components,progressive:s.progressive,ycbcr:!E,orientation:M,colorSpace:I}}(n);!function(o,n,r=t){if(!Number.isInteger(o)||!Number.isInteger(n)||o<1||n<1)throw m("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(o>r.edge||n>r.edge)throw m("JXL_DIMENSIONS","A picture is at most "+r.edge+" pixels on a side.");if(o*n>r.pixels)throw m("JXL_DIMENSIONS","A picture is at most "+r.pixels.toLocaleString("en-US")+" pixels.")}(f.width,f.height,o);const g=f.orientation>=5;return(t=>{Object.assign(s,t)})({width:g?f.height:f.width,height:g?f.width:f.height,orientation:f.orientation}),yield*i(f,r)}(n,i,0,e));return s}const U=256;function x(t,o){t.o([[9,1],[13,1],[18,1],[30,1]],o)}const I={channel:null,weighted:null,fill:null},E=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],v=[2,4,3,2,2,4],C=[0,7,3,2,1,15];function S(t,o){const n=new Uint8Array(t.length),r=[];for(let o=0;o<t.length;o++)t[o]>0&&r.push(o);if(!r.length)return n;if(1===r.length)return n[r[0]]=1,n;for(let e=1;;e*=2){const i=r.map(o=>({w:Math.max(t[o],e),m:o,l:null,r:null})).sort((t,o)=>t.w-o.w||t.m-o.m),s=[];let f=0,c=0;const a=()=>f<i.length&&(c>=s.length||i[f].w<=s[c].w)?i[f++]:s[c++];for(;i.length-f+(s.length-c)>1;){const t=a(),o=a();s.push({w:t.w+o.w,m:-1,l:t,r:o})}const l=[[a(),0]];let h=0;for(;l.length;){const[t,o]=l.pop();t.m>=0?(n[t.m]=o,o>h&&(h=o)):l.push([t.l,o+1],[t.r,o+1])}if(h<=o)return n}}function J(t,o,n,r,e,i){const s=[];for(;s.push(r&e),r>>=i;)r--;for(let r=s.length-1;r>=0;r--)t.push(n),o.push(s[r])}function L(t,o){let n=0;for(let r=0;r<o;r++)n=n<<1|1&t,t>>=1;return n}function X(t){const o=new Uint32Array(17),n=new Uint32Array(17),r=new Uint16Array(t.length);for(const n of t)o[n]++;o[0]=0;for(let t=1,r=0;t<=16;t++)r=r+o[t-1]<<1,n[t]=r;for(let o=0;o<t.length;o++)t[o]&&(r[o]=L(n[t[o]]++,t[o]));return r}function k(t){const o=[];for(let n=0;n<t.length;n++)t[n]>0&&o.push(n);const n=o.length,r=o[n-1]+1||1,e=n<=4?new Uint8Array(r):S(t,15).subarray(0,r);let i=0;if(n<=4){o.sort((o,n)=>t[n]-t[o]||o-n),i=4===n&&t[o[0]]>t[o[2]]+t[o[3]]?1:0;const r=n<2?[0]:2===n?[1,1]:3===n?[1,2,2]:i?[1,2,3,3]:[2,2,2,2];o.forEach((t,o)=>{e[t]=r[o]}),o.sort((t,o)=>e[t]-e[o]||t-o)}return{M:r,A:e,U:X(e),I:n&&n<=4?o:null,C:i}}function N(t,o){if(o.M<=1)return;if(o.I){const n=i(o.M-1)+1;t.write(2,1),t.write(2,o.I.length-1);for(const r of o.I)t.write(n,r);return void(4===o.I.length&&t.write(1,o.C))}const n=o.A,r=[],e=[];let s=n.length-1;for(;s>0&&!n[s];)s--;let f=8;for(let t=0;t<=s;){const o=n[t];let i=1;for(;t+i<=s&&n[t+i]===o;)i++;let c=i;if(o&&o!==f&&(r.push(o),e.push(0),c--,f=o),c<3)for(let t=0;t<c;t++)r.push(o),e.push(0);else J(r,e,o?16:17,c-3,o?3:7,o?2:3);t+=i}const c=new Uint32Array(18);for(const t of r)c[t]++;let a=0;for(const t of c)t&&a++;1===a&&(c[r[0]?0:1]=c[r[0]]);const l=S(c,5),h=X(l);let u=18;for(;u>0&&!l[E[u-1]];)u--;t.write(2,0);for(let o=0;o<u;o++){const n=l[E[o]];t.write(v[n],C[n])}for(let o=0;o<r.length;o++){const n=r[o];t.write(l[n],h[n]),16===n?t.write(2,e[o]):17===n&&t.write(3,e[o])}}function O(t,o=0,n=0){return{split:t,S:o,J:n,L:1<<t}}function T(t,o,n=15){t.write(s(n+1),o.split),o.split!==n&&(t.write(s(o.split+1),o.S),t.write(s(o.split-o.S+1),o.J))}function _(t,o,n){if(o<t.L)return n[0]=o,n[1]=0,void(n[2]=0);const r=i(o),e=o-(1<<r),s=r-t.S-t.J;n[0]=t.L+(r-t.split<<t.S+t.J|e>>r-t.S<<t.J|e&(1<<t.J)-1),n[1]=s,n[2]=o>>t.J&(1<<s)-1}function D(t,o,n,r=0){_(t,o,P),n[r+P[0]]++}const P=[0,0,0];function G(t,o,n,r,e=0){_(n,r,P);const i=e+P[0];t.write(o.A[i],o.U[i]),P[1]&&t.write(P[1],P[2])}function R(t,o){let n=0;for(const t of o)n=Math.max(n,t);const r=n?s(n+1):0;if(r<=3){if(t.write(1,1),t.write(2,r),r)for(const n of o)t.write(r,n);return}t.write(1,0),t.write(1,0);const e=O(8),i=O(4),f=o.length>=64,c=new Uint32Array(f?257:n+1),a=[];for(let t=0;t<o.length;){let n=1;for(;f&&t+n<o.length&&o[t+n]===o[t];)n++;if(n>=8)a.push([o[t],n-1]),c[o[t]]++,D(i,n-1-7,c,224),t+=n;else{for(let r=0;r<n;r++)a.push([o[t],0]),c[o[t]]++;t+=n}}const l=k(c);if(!f){q(t,{X:new Uint8Array(1),k:[{config:e,code:l}]});for(const[o]of a)G(t,l,e,o);return}const h=new Uint32Array(1);h[0]=1,q(t,{N:{O:224,minLength:7,T:i},X:new Uint8Array([1,0]),k:[{config:O(0),code:k(h)},{config:e,code:l}]});for(const[o,n]of a)G(t,l,e,o),n&&G(t,l,i,n-7,224)}function q(t,{N:o=null,X:n,k:r}){t.write(1,o?1:0),o&&(t.o([[0,224],[0,512],[0,4096],[15,8]],o.O),t.o([[0,3],[0,4],[2,5],[8,9]],o.minLength),T(t,o.T,8)),n.length>1&&R(t,n),t.write(1,1);for(const o of r)T(t,o.config,15);for(const o of r){const n=o.code.M-1;if(n){const o=i(n);t.write(1,1),t.write(4,o),t.write(o,n-(1<<o))}else t.write(1,0)}for(const o of r)N(t,o.code)}const B=O(4),Z=Object.freeze({O:224,minLength:7,T:B}),j=O(0);function z(t,o){const n=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===o.type)t.write(2,0),t.o(n,o._),t.o([[0,6],[2,0],[4,2],[6,10]],o.D??6);else if("palette"===o.type)t.write(2,1),t.o(n,o._),t.o([[0,1],[0,3],[0,4],[13,1]],o.P),t.o([[8,0],[10,256],[12,1280],[16,5376]],o.G),t.o([[0,0],[8,1],[10,257],[16,1281]],o.R??0),t.write(4,o.q??0);else{if("squeeze"!==o.type)throw new Error("unknown transform "+o.type);{t.write(2,2);const r=o.B??[];t.o([[0,0],[4,1],[6,9],[8,41]],r.length);for(const o of r)t.write(1,o.Z?1:0),t.write(1,o.j?1:0),t.o(n,o._),t.o([[0,1],[0,2],[0,3],[4,4]],o.P)}}}function Y(t,o,n,r,i,s,f=!1){if(I.channel?.(t,o,n,r,i,s,f))return;const c=s.q,a=s.offset,l=s.Y,h=s.config||j,u=B;let w=0;const d=(n,r=h,e=0)=>{t?G(t,o,r,n,e):f&&!e?o[n]++:D(r,n,o,f?o.length-33:e)},p=()=>{if(w){if(w>=8)d(0),d(w-7-1,u,224);else for(let t=0;t<w;t++)d(0);w=0}},y=(t,o)=>{const r=n[t];let i;1===l?i=r-o-a:(i=Math.round((r-o-a)/l),n[t]=o+a+i*l),0!==i?(p(),d(e(i))):w++};for(let t=0,o=0;t<i;t++)for(let e=0;e<r;e++,o++){let i;if(0===c)i=0;else{const s=e?n[o-1]:t?n[o-r]:0,f=t?n[o-r]:s;if(1===c)i=s;else if(2===c)i=f;else if(3===c)i=(s+f)/2|0;else{const a=s+f-(e&&t?n[o-r-1]:s);if(5===c){const t=s<f?s:f,o=s<f?f:s;i=a<t?t:a>o?o:a}else{if(4!==c)throw new Error("predictor "+c+" is not coded here");i=Math.abs(a-s)<Math.abs(a-f)?s:f}}}y(o,i)}p()}const H=[O(0),O(1),O(2),O(3),O(4),O(4,1,1),O(5,1,1),O(2,0,1),O(3,0,1)],F=O(4,1,1);class K{constructor(t){this.H=t,this.small=new Uint32Array(64*t),this.F=Array.from({length:t},()=>null),this.K=new Float64Array(t)}add(t,o){if(this.K[t]++,o<64)return void this.small[64*t+o]++;const n=this.F[t]||(this.F[t]=new Map);n.set(o,(n.get(o)||0)+1)}V(t,o,n=64){const r=new Uint32Array(n);for(const n of t){const t=64*n;for(let n=0;n<64;n++)this.small[t+n]&&(r[V(o,n)]+=this.small[t+n]);const e=this.F[n];if(e)for(const[t,n]of e)r[V(o,t)]+=n}return r}W(t,o){let n=tt(this.V(t,o));for(const r of t){const t=64*r;for(let r=o.L;r<64;r++)this.small[t+r]&&(n+=this.small[t+r]*(i(r)-o.S-o.J));const e=this.F[r];if(e)for(const[t,r]of e)n+=r*(i(t)-o.S-o.J)}return n}}const Q=[0,0,0];function V(t,o){return _(t,o,Q),Q[0]}const W=[1];for(let t=1;t<32;t++)W.push(W[t-1]/2);function $(t){let o=0;for(t>=2&&t<4294967296&&(o=31-Math.clz32(t),t*=W[o]);t>=1.4142135623730951;)t/=2,o++;for(;t<.7071067811865476;)t*=2,o--;const n=(t-1)/(t+1),r=n*n;let e=n,i=n;for(let t=3;t<30;t+=2)i+=(e*=r)/t;return o+2.885390081777927*i}function tt(t){let o=0,n=0;for(const n of t)o+=n;for(const r of t)r&&(n+=r*$(o/r));return n}function ot(t,{maxClusters:o=48,newClusterCost:n=320}={}){const r=[];for(let o=0;o<t.H;o++)t.K[o]>0&&r.push(o);r.sort((o,n)=>t.K[n]-t.K[o]);const e=[];for(const i of r){const r=t.V([i],F),s=tt(r);let f=-1,c=1/0;for(let t=0;t<e.length;t++){const o=e[t],n=new Uint32Array(64);for(let t=0;t<64;t++)n[t]=o.$[t]+r[t];const i=tt(n)-o.tt-s;i<c&&(c=i,f=t)}if(f<0||e.length<o&&c>n)e.push({H:[i],$:r,tt:s});else{const t=e[f];t.H.push(i);for(let o=0;o<64;o++)t.$[o]+=r[o];t.tt=tt(t.$)}}e.length||e.push({H:[],$:new Uint32Array(64),tt:0});const i=new Uint8Array(t.H);let s=2*t.H;const f=e.map((o,n)=>{for(const t of o.H)i[t]=n;let r=H[0],e=1/0;for(const n of H){const i=t.W(o.H,n);i<e&&(e=i,r=n)}const f=k(t.V(o.H,r,128));return s+=e+3*f.M+40,{config:r,code:f}});return{X:i,k:f,write:(t,o,n)=>{const r=f[i[o]];G(t,r.code,r.config,n)},tt:s}}const nt=[0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30],rt=[0,0,31,62,62,93,93,93,93,123,123,123,123,152,152,152,152,152,152,152,152,180,180,180,180,180,180,180,180,180,180,180,180,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206],et=c.map(t=>(7&t)<<3|t>>3),it=(t,o,n)=>2*(rt[t]+nt[o])+n;function st(t,o,n){const r=[];if(o>0){const n=new Uint32Array(2048);let e=0;for(const o of t)n[Math.min(2047,Math.max(0,o+1024))]++,e++;let i=0,s=e/(o+1);for(let t=0;t<2048&&r.length<o;t++)i+=n[t],i>s&&(r.push(t-1025),s=e*(r.length+1)/(o+1))}const e=r.length+1,i=new Uint8Array(39*e);for(let t=0;t<e;t++)for(let o=0;o<13;o++)i[(0+o)*e+t]=t,i[(13+o)*e+t]=n?e:e+(t>>1),i[(26+o)*e+t]=n?e:e+(e-1>>1)+1+(t>>1);let s=0;for(const t of i)s=Math.max(s,t+1);return{thresholds:r,ot:e,map:i,nt:s,rt:t=>{let o=0;for(const n of r)t>n&&o++;return o},et:(t,o)=>i[13*(t<2?1^t:2)*e+o],it:(t,o)=>(Math.min(t,64)<8?Math.min(t,64):4+(Math.min(t,64)>>1))*s+o,st:t=>37*s+458*t,H:495*s}}function ft(t,o,n){const r=o.map(()=>function(t,o=0,n=1){return{q:t,offset:o,Y:n,context:-1}}(n)),i=r.map(()=>new Uint32Array(257));o.forEach((t,o)=>Y(null,i[o],t.data,t.w,t.h,r[o])),function(t,{ft:o=!0,ct:n=[]}={}){t.write(1,o?1:0),t.write(1,1),t.o([[0,0],[0,1],[4,2],[8,18]],n.length);for(const o of n)z(t,o)}(t,{ft:!1,ct:[]});const s=function(t,o){const n=[o],r=[],i=[];for(const t of n){if(t.left){r.push(t.lt+1,e(t.ht)),n.push(t.left,t.right);continue}t.context=i.length,i.push(t);const o=1===t.Y?0:31-Math.clz32(t.Y&-t.Y);r.push(0,t.q,e(t.offset),o,(t.Y>>o)-1)}const s=new Uint32Array(64);for(const t of r)D(j,t,s);const f=k(s);q(t,{X:new Uint8Array(6),k:[{config:j,code:f}]});for(const o of r)G(t,f,j,o);return i}(t,function(t){return function(t,o){const n=(r,e)=>{if(r===e)return o?t[r].ut:t[r];const i=r+e>>1;return function(t,o,n,r){return{lt:t,ht:o,left:n,right:r}}(o,o?t[i].wt:i,n(i+1,e),n(r,i))};return n(0,t.length-1)}(t,0)}(r)),f=function(t,o,n,r=t=>t.context,e=()=>j){const i=new Uint8Array(o.length+1);for(const t of o)i[t.context]=r(t)+1;const s=new Uint32Array(2);s[1]=1;const f=[{config:j,code:k(s)}],c=Math.max(...i);for(let t=0;t<c;t++)f.push({config:e(t),code:k(n[t])});return q(t,{N:Z,X:i,k:f}),f}(t,s,i,t=>r.indexOf(t));o.forEach((o,n)=>Y(t,f[n+1].code,o.data,o.w,o.h,r[n]))}function*ct(t,o={}){const{width:n,height:i,components:c,alpha:l}=t,h=1===c.length,u=t.quantScale||1;let w=t.quantFieldBase||1;for(;w/(2040*u)<1/16384;)w*=2;const d=t.ycbcr||h,p=h?[0,0,0]:d?[1,0,2]:[0,1,2],y=p.map(t=>c[t]),b=o.orders?p.map(t=>o.orders[t].map(t=>et[t])):[et,et,et],m=t=>1===t?0:2===t?1:-1,M=y.map(t=>m(t.h)),A=y.map(t=>m(t.v));if(M.includes(-1)||A.includes(-1))throw a("sampling factors other than one or two");const I=Math.max(...M),E=Math.max(...A),v=t=>I-M[t],C=t=>E-A[t];if(!d&&(I||E))throw a("an RGB JPEG with subsampling");const S=Math.ceil(n/(8<<I))<<I,J=Math.ceil(i/(8<<E))<<E,L=Math.ceil(n/U),X=Math.ceil(i/U),N=L*X,T=Math.ceil(S/256),_=T*Math.ceil(J/256),P=1===N,B=(t,o,n)=>{const r=y[t];return h&&1!==t?-1:64*(n*r.stride+o)},Z=t=>{let o=1024;for(;t%o;)o>>=1;return o},j=y.map(t=>d?1:t.quant[0]/Z(t.quant[0])),z=y.map(t=>d?0:1024/Z(t.quant[0])),Y=new Int32Array(S*J);for(let t=0;t<J;t++)for(let o=0;o<S;o++)Y[t*S+o]=y[1].coeffs[B(1,o,t)]*j[1]+z[1];const H=y[1].quant,F=(H[8]+H[16]+H[24]+H[32]+H[40])/u,Q=S*J,V=Q<256?0:Math.max(1,Math.min(7,s(Q)-s(F)-7));let W=st(Y,V,h);const $=new r(256);if(function(t,o,n,r,e,{xyb:i=!1,orientation:s=1,colorSpace:f}={}){t.write(16,2815),t.write(1,0),x(t,n),t.write(3,0),x(t,o),t.write(1,0);const c=1!==s;t.write(1,c?1:0),c&&t.write(6,s-1),t.write(4,8),e?t.write(3,5):t.write(2,0),t.write(1,i?1:0),3===r&&"display-p3"===f?t.write(21,903568):3===r?t.write(1,1):t.write(15,14100),c&&t.write(1,1),t.write(2,0),t.write(1,1),t.i()}($,n,i,h?1:3,!!l,{orientation:t.orientation,colorSpace:t.colorSpace}),$.write(1,0),$.write(2,0),$.write(1,0),$.write(2,2),$.write(8,111),$.write(1,d?1:0),d)for(let t=0;t<3;t++)$.write(2,0===M[t]&&0===A[t]?0:1===M[t]&&1===A[t]?1:1===M[t]?2:3);$.write(2,0),l&&$.write(2,0),function(t,o){t.write(o?7:5,0),t.write(11,1)}($,l);const tt=[0,1,2].map(()=>new Int32Array(1024)),nt=(t,o)=>{const n=t%L*32,r=32*(t/L|0),i=Math.min(32,S-n),s=Math.min(32,J-r);for(let t=0;t<s;t++)for(let s=0;s<i;s++)for(const i of[1,0,2]){const f=v(i),c=C(i),a=s>>f,l=t>>c;if(a<<f!==s||l<<c!==t)continue;const h=B(i,(n>>f)+a,(r>>c)+l),u=y[i].coeffs;let w=0;if(h>=0)for(let t=1;t<64;t++)u[h+t]&&w++;const d=tt[i],p=0===a?0===l?32:d[32*(l-1)]:0===l?d[32*l+a-1]:d[32*(l-1)+a]+d[32*l+a-1]+1>>1;d[32*l+a]=w;const m=W.et(i,W.rt(Y[(r+t)*S+n+s]));o(W.it(p,m),w);const g=W.st(m);let M=w>4?0:1,A=w;for(let t=1;t<64&&A;t++){const n=u[h+b[i][t]];o(g+it(A,t,M),e(n)),M=n?1:0,A-=M}}},rt=(V>0?3:2)*N+_;let ct=0;const at=function*(t){W=t;const n=new K(t.H);for(let t=0;t<N;t++)nt(t,(t,o)=>n.add(t,o)),yield++ct/rt;return(o.coding||ot)(n,o.clusters)};let lt=yield*at(W);if(V>0){const t=W,o=st(Y,0,h),n=yield*at(o);n.tt<=lt.tt?lt=n:W=t}const ht=Array.from({length:P?1:2+_+N},()=>null),ut=t=>ht[P?0:t]||(ht[P?0:t]=new r(4096)),wt=new Uint32Array(ht.length);let dt=0;const pt=t=>{t=P?0:t;const o=Math.ceil(ht[t].u/8);dt+=o-wt[t],wt[t]=o,g(dt)},yt=ut(0);yt.write(1,0);const bt=(t,o)=>{const r=t*U,e=o*U,s=Math.min(U,n-r),f=Math.min(U,i-e),c=new Int32Array(s*f);for(let t=0;t<f;t++)for(let o=0;o<s;o++)c[t*s+o]=l[4*((e+t)*n+r+o)+3];return{w:s,h:f,data:c}};for(let t=0;t<3;t++)yt.write(16,f(y[t].quant[0]/j[t]/(2040*u)*128));yt.write(2,3),yt.write(16,57343),yt.write(2,1),yt.write(5,0),yt.write(1,0),yt.write(4,0),yt.write(4,W.thresholds.length);for(const t of W.thresholds)yt.o([[4,0],[8,16],[16,272],[32,65808]],e(t));yt.write(4,0),yt.write(4,0),R(yt,W.map),yt.write(1,0),yt.write(2,0),yt.write(16,0),yt.write(16,0),yt.write(8,128),yt.write(8,128),yt.write(1,0),l&&ft(yt,[P?bt(0,0):{w:0,h:0,data:new Int32Array(0)}],5),pt(0);for(let o=0;o<_;o++){const n=ut(1+o),r=o%T*256,e=256*(o/T|0),i=Math.min(256,S-r),f=Math.min(256,J-e);n.write(2,0),ft(n,[1,0,2].map(t=>{const o=i>>v(t),n=f>>C(t),s=new Int32Array(o*n),c=j[t],a=z[t];for(let i=0;i<n;i++)for(let n=0;n<o;n++){const f=B(t,(r>>v(t))+n,(e>>C(t))+i);s[i*o+n]=f<0?0:y[t].coeffs[f]*c+a}return{w:o,h:n,data:s}}),5);const c=i*f,a=s(c);a&&n.write(a,c-1);const l=i+7>>3,h=f+7>>3,u=new Int32Array(2*c).fill(w-1,c);if(t.quantFields)for(let o=0;o<f;o++)for(let n=0;n<i;n++)u[c+o*i+n]=t.quantFields[(e+o)*S+r+n]-1;ft(n,[{w:l,h:h,data:new Int32Array(l*h)},{w:l,h:h,data:new Int32Array(l*h)},{w:c,h:2,data:u},{w:i,h:f,data:new Int32Array(c)}],w>1?5:0),pt(1+o),yield++ct/rt}const mt=ut(1+_);mt.write(1,0),mt.write(3,7),mt.write(16,f(w/(2040*u))),ft(mt,[0,1,2].map(t=>{const o=new Int32Array(64),n=y[t].quant;for(let t=0;t<8;t++)for(let r=0;r<8;r++)o[8*r+t]=n[8*t+r];return{w:8,h:8,data:o}}),5);for(let t=1;t<17;t++)mt.write(3,0);if(N>1&&mt.write(s(N),0),o.orders){mt.o([[0,95],[0,19],[0,0],[13,0]],1);const t=[];for(const n of p){const r=Array.from({length:64},(t,o)=>o),e=o.orders[n].map(t=>{const o=r.indexOf(t);return r.splice(o,1),o});let i=64;for(;i>1&&!e[i-1];)i--;t.push(i-1,...e.slice(1,i))}const n=O(0),r=new Uint32Array(64);for(const o of t)D(n,o,r);const e=k(r);q(mt,{X:new Uint8Array(8),k:[{config:n,code:e}]});for(const o of t)G(mt,e,n,o)}else mt.write(2,2);lt.writeHistograms?lt.writeHistograms(mt):q(mt,{X:lt.X,k:lt.k}),pt(1+_);for(let t=0;t<N;t++){const o=ut(2+_+t);nt(t,(t,n)=>lt.write(o,t,n)),lt.flush&<.flush(o),l&&!P&&ft(o,[bt(t%L,Math.floor(t/L))],5),pt(2+_+t),yield++ct/rt}return function(t,o){const n=o.map(t=>t.length);!function(t,o){t.write(1,0),t.i();for(const n of o)t.o([[10,0],[14,1024],[22,17408],[30,4211712]],n);t.i()}(t,n);const r=t.finish(),e=r.length+n.reduce((t,o)=>t+o,0);g(e);const i=new Uint8Array(e);i.set(r);let s=r.length;for(const t of o)i.set(t,s),s+=t.length;return i}($,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(ht))}function*at(t,o,n){if(o<3&&!n)return yield*ct(t);let r=n;try{const n=ct(t);let e,i;for(;!(e=n.next()).done;)if(i=yield e.value/2,i&&r&&e.value<1)return n.return(),r;if((!r||e.value.length<r.length)&&(r=e.value),i||o<3)return r;const s=o<4?1:3,f=ct(t,{clusters:{maxClusters:32,newClusterCost:160}});for(;!(e=f.next()).done;)if(i=yield.5+e.value/(2*s),i&&e.value<1)return f.return(),r;if(e.value.length<r.length&&(r=e.value),i||o<4)return r;const a=function*(t){const o=c.map(t=>(7&t)<<3|t>>3),n=t.map(()=>new Uint32Array(64)),r=t.reduce((t,o)=>t+o.coeffs.length,0);let e=0;for(let i=0;i<t.length;i++){const{coeffs:s}=t[i],f=n[i];for(let t=0;t<s.length;t+=65536){const n=Math.min(t+65536,s.length);for(let r=t;r<n;r+=64)for(let t=1;t<64;t++)s[r+o[t]]&&f[t]++;if(e+=n-t,yield e/r)return null}}return n.map(t=>[0,...Array.from({length:63},(t,o)=>o+1).sort((o,n)=>Math.floor(t[n]/8)-Math.floor(t[o]/8)||o-n)])}(t.components);for(;!(e=a.next()).done;)if(yield.5+(1+e.value)/6)return a.return(),r;const l=ct(t,{orders:e.value});for(;!(e=l.next()).done;)if(i=yield.5+(2+e.value)/6,i&&e.value<1)return l.return(),r;return e.value.length<r.length?e.value:r}catch(t){if(!r||(!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t;return r}}function lt(t,o){return function(t){return function(t){let o;for(;!(o=t.next()).done;);o.value}(t),{bytes:t.bytes,width:t.width,height:t.height,orientation:t.orientation}}(ht(t,o))}function ht(t,o){return A(t,o,at)}export{o as LIMITS,lt as transcode,ht as transcodeSteps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Rapier JXL 2.2.
|
|
1
|
+
/*! Rapier JXL 2.2.1 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
2
2
|
function*t(t,n,o){let r,e;for(;!(r=t.next(e)).done;)e=yield ft(r.value,t=>(n+t)/o);return r.value}function n(t){return t>=0?2*t:2*-t-1}function o(t){return 31-Math.clz32(t)}function r(t){return t<=1?0:32-Math.clz32(t-1)}function e(t){if(0===t)return 0;const n=t<0?32768:0;if(!((t=Math.abs(t))<65520))throw new Error("half float out of range: "+t);let o=0,r=t;for(;r>=2;)r/=2,o++;for(;r<1;)r*=2,o--;o<-14?(r=16384*t,o=-15):r-=1;let e=Math.round(1024*r);return 1024===e&&(e=0,o++),n|o+15<<10|e}function s(t){if(t>et.bytes)throw lt("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function i(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw lt("JXL_MEMORY","Not enough memory for this picture.");throw t}}function c(t,n){t.t([[9,1],[13,1],[18,1],[30,1]],n)}function f(t,n,o,r,e,{xyb:s=!1,orientation:i=1,colorSpace:f}={}){t.write(16,2815),t.write(1,0),c(t,o),t.write(3,0),c(t,n),t.write(1,0);const l=1!==i;t.write(1,l?1:0),l&&t.write(6,i-1),t.write(4,8),e?t.write(3,5):t.write(2,0),t.write(1,s?1:0),3===r&&"display-p3"===f?t.write(21,903568):3===r?t.write(1,1):t.write(15,14100),l&&t.write(1,1),t.write(2,0),t.write(1,1),t.o()}function l(t,n){t.write(n?7:5,0),t.write(11,1)}function*a(t,n,o,r){if(t.pooled){const n=yield t;return n?(n.results.forEach((t,n)=>r(n,t)),n.hurried):null}let e=!1;for(let r=0;r<n;r++)if(o(r),e=yield t.at(r),e&&t.stop(r))return null;return e}function u(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.o();for(const o of n)t.t([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.o()}(t,o);const r=t.finish(),e=r.length+o.reduce((t,n)=>t+n,0);s(e);const i=new Uint8Array(e);i.set(r);let c=r.length;for(const t of n)i.set(t,c),c+=t.length;return i}function h(t,n){const o=new Uint8Array(t.length),r=[];for(let n=0;n<t.length;n++)t[n]>0&&r.push(n);if(!r.length)return o;if(1===r.length)return o[r[0]]=1,o;for(let e=1;;e*=2){const s=r.map(n=>({w:Math.max(t[n],e),i:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.i-n.i),i=[];let c=0,f=0;const l=()=>c<s.length&&(f>=i.length||s[c].w<=i[f].w)?s[c++]:i[f++];for(;s.length-c+(i.length-f)>1;){const t=l(),n=l();i.push({w:t.w+n.w,i:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.i>=0?(o[t.i]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function y(t,n,o,r,e,s){const i=[];for(;i.push(r&e),r>>=s;)r--;for(let r=i.length-1;r>=0;r--)t.push(o),n.push(i[r])}function w(t,n){let o=0;for(let r=0;r<n;r++)o=o<<1|1&t,t>>=1;return o}function d(t){const n=new Uint32Array(17),o=new Uint32Array(17),r=new Uint16Array(t.length);for(const o of t)n[o]++;n[0]=0;for(let t=1,r=0;t<=16;t++)r=r+n[t-1]<<1,o[t]=r;for(let n=0;n<t.length;n++)t[n]&&(r[n]=w(o[t[n]]++,t[n]));return r}function p(t){const n=[];for(let o=0;o<t.length;o++)t[o]>0&&n.push(o);const o=n.length,r=n[o-1]+1||1,e=o<=4?new Uint8Array(r):h(t,15).subarray(0,r);let s=0;if(o<=4){n.sort((n,o)=>t[o]-t[n]||n-o),s=4===o&&t[n[0]]>t[n[2]]+t[n[3]]?1:0;const r=o<2?[0]:2===o?[1,1]:3===o?[1,2,2]:s?[1,2,3,3]:[2,2,2,2];n.forEach((t,n)=>{e[t]=r[n]}),n.sort((t,n)=>e[t]-e[n]||t-n)}return{u:r,p:e,M:d(e),A:o&&o<=4?n:null,U:s}}function M(t,n){if(n.u<=1)return;if(n.A){const r=o(n.u-1)+1;t.write(2,1),t.write(2,n.A.length-1);for(const o of n.A)t.write(r,o);return void(4===n.A.length&&t.write(1,n.U))}const r=n.p,e=[],s=[];let i=r.length-1;for(;i>0&&!r[i];)i--;let c=8;for(let t=0;t<=i;){const n=r[t];let o=1;for(;t+o<=i&&r[t+o]===n;)o++;let f=o;if(n&&n!==c&&(e.push(n),s.push(0),f--,c=n),f<3)for(let t=0;t<f;t++)e.push(n),s.push(0);else y(e,s,n?16:17,f-3,n?3:7,n?2:3);t+=o}const f=new Uint32Array(18);for(const t of e)f[t]++;let l=0;for(const t of f)t&&l++;1===l&&(f[e[0]?0:1]=f[e[0]]);const a=h(f,5),u=d(a);let w=18;for(;w>0&&!a[ht[w-1]];)w--;t.write(2,0);for(let n=0;n<w;n++){const o=a[ht[n]];t.write(yt[o],wt[o])}for(let n=0;n<e.length;n++){const o=e[n];t.write(a[o],u[o]),16===o?t.write(2,s[n]):17===o&&t.write(3,s[n])}}function A(t,n=0,o=0){return{split:t,m:n,I:o,S:1<<t}}function g(t,n,o=15){t.write(r(o+1),n.split),n.split!==o&&(t.write(r(n.split+1),n.m),t.write(r(n.split-n.m+1),n.I))}function U(t,n,r){if(n<t.S)return r[0]=n,r[1]=0,void(r[2]=0);const e=o(n),s=n-(1<<e),i=e-t.m-t.I;r[0]=t.S+(e-t.split<<t.m+t.I|s>>e-t.m<<t.I|s&(1<<t.I)-1),r[1]=i,r[2]=n>>t.I&(1<<i)-1}function b(t,n,o,r=0){U(t,n,dt),o[r+dt[0]]++}function m(t,n,o,r,e=0){U(o,r,dt);const s=e+dt[0];t.write(n.p[s],n.M[s]),dt[1]&&t.write(dt[1],dt[2])}function I(t,n){let o=0;for(const t of n)o=Math.max(o,t);const e=o?r(o+1):0;if(e<=3){if(t.write(1,1),t.write(2,e),e)for(const o of n)t.write(e,o);return}t.write(1,0),t.write(1,0);const s=A(8),i=A(4),c=n.length>=64,f=new Uint32Array(c?257:o+1),l=[];for(let t=0;t<n.length;){let o=1;for(;c&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)l.push([n[t],o-1]),f[n[t]]++,b(i,o-1-7,f,224),t+=o;else{for(let r=0;r<o;r++)l.push([n[t],0]),f[n[t]]++;t+=o}}const a=p(f);if(!c){x(t,{L:new Uint8Array(1),J:[{config:s,code:a}]});for(const[n]of l)m(t,a,s,n);return}const u=new Uint32Array(1);u[0]=1,x(t,{X:{T:224,minLength:7,_:i},L:new Uint8Array([1,0]),J:[{config:A(0),code:p(u)},{config:s,code:a}]});for(const[n,o]of l)m(t,a,s,n),o&&m(t,a,i,o-7,224)}function x(t,{X:n=null,L:r,J:e}){t.write(1,n?1:0),n&&(t.t([[0,224],[0,512],[0,4096],[15,8]],n.T),t.t([[0,3],[0,4],[2,5],[8,9]],n.minLength),g(t,n._,8)),r.length>1&&I(t,r),t.write(1,1);for(const n of e)g(t,n.config,15);for(const n of e){const r=n.code.u-1;if(r){const n=o(r);t.write(1,1),t.write(4,n),t.write(n,r-(1<<n))}else t.write(1,0)}for(const n of e)M(t,n.code)}function S(t,n=0,o=1){return{N:t,offset:n,C:o,context:-1}}function E(t){return function(t,n){const o=(r,e)=>{if(r===e)return n?t[r].O:t[r];const s=r+e>>1;return function(t,n,o,r){return{P:t,q:n,left:o,right:r}}(n,n?t[s].F:s,o(s+1,e),o(r,s))};return o(0,t.length-1)}(t,0)}function L(t,o){const r=[o],e=[],s=[];for(const t of r){if(t.left){e.push(t.P+1,n(t.q)),r.push(t.left,t.right);continue}t.context=s.length,s.push(t);const o=1===t.C?0:31-Math.clz32(t.C&-t.C);e.push(0,t.N,n(t.offset),o,(t.C>>o)-1)}const i=new Uint32Array(64);for(const t of e)b(Ut,t,i);const c=p(i);x(t,{L:new Uint8Array(6),J:[{config:Ut,code:c}]});for(const n of e)m(t,c,Ut,n);return s}function J(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.t(o,n.G),t.t([[0,6],[2,0],[4,2],[6,10]],n.j??6);else if("palette"===n.type)t.write(2,1),t.t(o,n.G),t.t([[0,1],[0,3],[0,4],[13,1]],n.k),t.t([[8,0],[10,256],[12,1280],[16,5376]],n.R),t.t([[0,0],[8,1],[10,257],[16,1281]],n.B??0),t.write(4,n.N??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const r=n.Z??[];t.t([[0,0],[4,1],[6,9],[8,41]],r.length);for(const n of r)t.write(1,n.D?1:0),t.write(1,n.Y?1:0),t.t(o,n.G),t.t([[0,1],[0,2],[0,3],[4,4]],n.k)}}}function X(t,{H:n=!0,K:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.t([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)J(t,n)}function v(t,n,o,r=t=>t.context,e=()=>Ut){const s=new Uint8Array(n.length+1);for(const t of n)s[t.context]=r(t)+1;const i=new Uint32Array(2);i[1]=1;const c=[{config:Ut,code:p(i)}],f=Math.max(...s);for(let t=0;t<f;t++)c.push({config:e(t),code:p(o[t])});return x(t,{X:gt,L:s,J:c}),c}function T(t,o,r,e,s,i,c=!1){if(at.channel?.(t,o,r,e,s,i,c))return;const f=i.N,l=i.offset,a=i.C,u=i.config||Ut,h=At;let y=0;const w=(n,r=u,e=0)=>{t?m(t,o,r,n,e):c&&!e?o[n]++:b(r,n,o,c?o.length-33:e)},d=()=>{if(y){if(y>=8)w(0),w(y-7-1,h,224);else for(let t=0;t<y;t++)w(0);y=0}},p=(t,o)=>{const e=r[t];let s;1===a?s=e-o-l:(s=Math.round((e-o-l)/a),r[t]=o+l+s*a),0!==s?(d(),w(n(s))):y++};for(let t=0,n=0;t<s;t++)for(let o=0;o<e;o++,n++){let s;if(0===f)s=0;else{const i=o?r[n-1]:t?r[n-e]:0,c=t?r[n-e]:i;if(1===f)s=i;else if(2===f)s=c;else if(3===f)s=(i+c)/2|0;else{const l=i+c-(o&&t?r[n-e-1]:i);if(5===f){const t=i<c?i:c,n=i<c?c:i;s=l<t?t:l>n?n:l}else{if(4!==f)throw new Error("predictor "+f+" is not coded here");s=Math.abs(l-i)<Math.abs(l-c)?i:c}}}p(n,s)}d()}function _(t){const n=t.length-33,r=[0,0,0];let e,s;for(const i of bt){const c=new Uint32Array(257);let f=0;for(let o=0;o<n;o++)t[o]&&(U(i,o,r),c[r[0]]+=t[o],f+=t[o]*r[1]);for(let o=0;o<33;o++)c[224+o]=t[n+o],f+=t[n+o]*Math.max(0,o-12);const l=p(c),a=new ct(128);g(a,i),M(a,l);let u=a.V+f+(1===l.u?1:5+o(l.u-1));for(let t=0;t<c.length;t++)c[t]&&(u+=c[t]*l.p[t]);const h={config:i,W:c,$:u,extra:f};e||(e=h),(!s||u<s.$)&&(s=h)}return[e,s]}function N(t,n,o,{palette:r=!0}={}){const e=n*o;let s=!0,i=!0;for(let n=0,o=0;o<e&&(255===t[n+3]||(s=!1,i))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(i=!1,s));o++,n+=4);const c=i?1:3,f=!s,l=c+(f?1:0),a=n=>mt(t,n,i,f),u=new Map;let h=null;for(let t=0,n=0;r&&n<e;n++,t+=4){const n=a(t);if(0!==n&&!u.has(n)&&(u.set(n,1),u.size>=2048))break}if(r&&u.size<2048){const t=[...u.keys()],n=(t,n)=>t>>>8*n&255,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===l?n(t,3):1);t.sort((t,n)=>o(t)-o(n)),h={colours:[0,...t],byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function C({channels:t,alpha:n,palette:o},r){const e=t-(n?1:0)==1,s=o&&new Map(o.map((t,n)=>[t,n]));return(i,c,f,l,a,u,h)=>{if(r&&!o&&t>=3)r.fill(i,c,f,l,a,u,h);else if(o||!at.fill?.(c,f,l,a,u,h,t,i))for(let r=0;r<h;r++){let h=4*((a+r)*f+l),y=r*u;for(let r=0;r<u;r++,h+=4,y++)if(o)i[0][y]=s.get(mt(c,h,e,n));else if(t>=3){const n=c[h],o=c[h+1],r=c[h+2],e=n-r,s=r+(e>>1),f=o-s;i[0][y]=s+(f>>1),i[1][y]=e,i[2][y]=f,4===t&&(i[3][y]=c[h+3])}else i[0][y]=c[h],2===t&&(i[1][y]=c[h+3])}}}function O(t,n){const{leaves:o,picture:r,M:e}=t,s=C(t,n),i=r.map(()=>new Int16Array(65536));return(t,n,c,f,l,a,u)=>{if(s(i,t,n,c,f,l,a),!e)return void r.forEach((t,n)=>T(null,u[t],i[n],l,a,o[t],!0));const h=u||new ct(l*a*r.length+64);return u||X(h,{H:!0,K:[]}),r.forEach((t,n)=>T(h,e[t],i[n],l,a,o[t])),u?void 0:h.finish()}}function*P(t,n,o,r,e,s,i){const{channels:c,alpha:h,palette:y}=r,w=function(t,n,o=256){const r=Math.ceil(t/o),e=Math.ceil(n/o);return{tt:r,nt:e,ot:Math.ceil(t/(8*o)),rt:Math.ceil(n/(8*o)),et:1===r&&1===e}}(n,o),d=w.tt*w.nt,A=y?2:c,g=Array.from({length:A},()=>S(Mt)),U=E(g),b={channels:c,alpha:h,palette:y&&y.colours,rct:s?.type,leaves:g,picture:y?[w.et?1:0]:g.map((t,n)=>n)},m=C(b,s),I=Array.from({length:c},()=>new Int16Array(1024)),x=t=>function(t,n,o,r){const e=r%t.tt*ut,s=(r/t.tt|0)*ut;return[e,s,Math.min(ut,n-e),Math.min(ut,o-s)]}(w,n,o,t);let J=null;if(y){const t=y.colours.length;J=new Int16Array(t*c),y.colours.forEach((n,o)=>{for(let r=0;r<c;r++)J[r*t+o]=y.byte(n,r)})}if(!y){const r=t=>{const n=p(t),o=new ct(128);M(o,n);let r=o.V;for(let o=0;o<t.length;o++)t[o]&&(r+=t[o]*(n.p[o]+Math.max(0,o<224?o-1:o-236)));return r},e=Math.min(n,32),s=Math.min(o,32),i=[Mt,pt].map(t=>({N:t,W:g.map(()=>new Uint32Array(257))}));for(const r of[0,.5,1]){m(I,t,n,Math.floor((n-e)*r),Math.floor((o-s)*r),e,s);for(const t of i)for(let n=0;n<c;n++)T(null,t.W[n],I[n],e,s,S(t.N))}g.forEach((t,n)=>{const o=i.map(t=>r(t.W[n])),e=o[1]<o[0]?1:0;t.N=i[e].N})}const N=y?[{type:"palette",G:0,k:c,R:y.colours.length}]:c>=3&&0!==s?.type?[{type:"rct",G:0,j:s?.type??6}]:[];let P=g.map(()=>new Uint32Array(33+(y?4096:1024)));J&&T(null,P[0],J,y.colours.length,c,g[0],!0);const q=O(b,s);yield*a({pooled:i,kind:"plan",setup:{...b,sizes:P.map(t=>t.length)},at:t=>(t+1)/(2*d),stop:()=>!1},d,o=>q(t,n,...x(o),P),(t,n)=>function(t,n){t.forEach((t,o)=>{const r=n[o];for(let n=0;n<t.length;n++)t[n]+=r[n]})}(P,n));const F=P.map(_),G=F.reduce((t,n)=>t+n[0].$-n[1].$,0)>27*(w.et?1:d+1)+8?1:0;g.forEach((t,n)=>{t.config=F[n][G].config}),P=F.map(t=>t[G].W);const j=new ct(256);f(j,n,o,r.colour,r.alpha,{colorSpace:e}),function(t,{alpha:n,shift:o=1}){t.write(9,8),n&&t.write(2,0),t.write(2,o),l(t,n)}(j,{alpha:r.alpha});const k=new ct(4096);k.write(1,1),k.write(1,1);const z=v(k,L(k,U),P,t=>g.indexOf(t),t=>g[t].config),R={...b,M:g.map((t,n)=>z[n+1]?.code)},B=O(R,s);X(k,{H:!0,K:N}),J&&T(k,R.M[0],J,y.colours.length,c,g[0]);const Z=[];if(w.et)B(t,n,0,0,n,o,k),yield 1,Z.push(k.finish());else{Z.push(k.finish());for(let t=0;t<w.ot*w.rt+1;t++)Z.push(new Uint8Array(0));const o=Z.length,r=(t,n)=>{Z[o+t]=n};yield*a({pooled:i,kind:"plan",setup:R,at:t=>(d+t+1)/(2*d),stop:()=>!1},d,o=>r(o,B(t,n,...x(o))),r)}return u(j,Z)}function q(t,n,o,r){let e=0;return e+=t[n]*It[r],e+=t[n+o]*It[r+1],e+=t[n+2*o]*It[r+2],e+=t[n+3*o]*It[r+3],e+=t[n+4*o]*It[r+4],e+=t[n+5*o]*It[r+5],e+=t[n+6*o]*It[r+6],e+=t[n+7*o]*It[r+7],e}function F(t,n,o){const r=new Float64Array(192),e=new Float64Array(64),s=new Float64Array(192);return(i,c)=>{for(let e=0;e<8;e++)for(let s=0;s<8;s++){const f=4*(Math.min(o-1,8*c+e)*n+Math.min(n-1,8*i+s)),l=t[f],a=t[f+1],u=t[f+2],h=8*e+s;r[h]=.299*l+.587*a+.114*u-128,r[64+h]=-.168735892*l-.331264108*a+.5*u,r[128+h]=.5*l-.418687589*a-.081312411*u}for(let t=0;t<3;t++){for(let n=0;n<8;n++)for(let o=0;o<8;o++)e[8*n+o]=q(r,64*t+8*n,1,8*o);for(let n=0;n<8;n++)for(let o=0;o<8;o++)s[64*t+8*n+o]=q(e,o,8,8*n)}return s}}function*G(t,n,o,r,e){const s=Math.ceil(n/8),i=Math.ceil(o/8),c=r>=30?.1+.09*(100-r):53/3e3*r*r-1.15*r+25,f=[0,1,2].map(t=>({h:1,v:1,stride:s,rows:i,quant:Int32Array.from(xt,(n,o)=>Math.max(1,Math.round(16*c*(t?18:10)*(o?n:.25)))),coeffs:new Int16Array(s*i*64)})),l=F(t,n,o),a=(t,n)=>{for(let o=t;o<n;o++)for(let t=0;t<s;t++){const n=l(t,o),r=64*(o*s+t);for(let t=0;t<3;t++)for(let o=0;o<64;o++)f[t].coeffs[r+o]=Math.round(16*n[64*t+o]/f[t].quant[o])}};for(let t=0;t<i;t+=32)a(t,Math.min(i,t+32)),yield Math.min(i,t+32)/i;let u=null;for(let n=3;n<t.length;n+=4)if(255!==t[n]){u=t;break}return{width:n,height:o,components:f,quantScale:16,ycbcr:!0,orientation:1,alpha:u,colorSpace:e}}function j(n,o,r,c,f){const{quality:l,colorSpace:a}=function(t={},n=100){if(null===t||"object"!=typeof t)throw lt("JXL_INPUT","Options are an object: {quality, colorSpace}.");if(void 0!==t.quality&&(n=t.quality),"number"!=typeof n||!Number.isFinite(n)||n<1||n>100)throw lt("JXL_INPUT","Quality is a number from 1 to 100.");const o=void 0===t.colorSpace?"srgb":t.colorSpace;if("srgb"!==o&&"display-p3"!==o)throw lt("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(c,90),u=function(t={}){if(null===t||"object"!=typeof t)throw lt("JXL_INPUT","Options are an object.");const n=void 0===t.effort?1:t.effort;if(!Number.isInteger(n)||n<1||n>9)throw lt("JXL_INPUT","Effort is a whole number from 1 to 9.");return n}(c);return function(t,n,o,r){if(function(t,n,o=et){if(!Number.isInteger(t)||!Number.isInteger(n)||t<1||n<1)throw lt("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>o.edge||n>o.edge)throw lt("JXL_DIMENSIONS","A picture is at most "+o.edge+" pixels on a side.");if(t*n>o.pixels)throw lt("JXL_DIMENSIONS","A picture is at most "+o.pixels.toLocaleString("en-US")+" pixels.")}(n,o,r),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw lt("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==n*o*4)throw lt("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(n,o,r,st),function(t){const n=function*(){let o,r;for(;!(o=i(()=>t.next(n.hurry))).done;)yield r=o.value;return r<1&&(yield 1),n.bytes=(s((e=o.value).length),e);var e}();return n.bytes=null,n.hurry=!1,n}(function*(n,o,r,s,i,c,f){if(s>=100)return yield*function*(n,o,r,{shape:e=N(n,o,r),colorSpace:s,rct:i,pooled:c}={}){let f,l;const a=e.palette?[e,{...e,palette:null}]:[e];for(let e=0;e<a.length;e++)try{const l=yield*t(P(n,o,r,a[e],s,i,c),e,a.length);(!f||l.length<f.length)&&(f=l)}catch(t){if("JXL_SIZE"!==t.code)throw t;l=t}if(!f)throw l;return f}(n,o,r,{colorSpace:i});if(c<5)return yield*t(f(yield*t(G(n,o,r,s,i),0,2),c),1,2);const l=yield*t(G(n,o,r,s,i),0,4);let a=yield*t(f(l,4),1,4);if(yield.5)return a;try{const o=yield*t(function*(t,n,o=0){const{width:r,height:s,components:i,quantScale:c}=n,f=i[0].stride,l=i[0].rows,a=f*l,u=St.length;if(t.byteLength+i.reduce((t,n)=>t+n.coeffs.byteLength,0)+Math.max(a*(10*u+2)+o,7*st.bytes)>Jt)return null;const h=new Float64Array(a*u),y=new Uint16Array(a*u),w=F(t,r,s),d=i.map(t=>t.quant),p=i.map(t=>t.coeffs),M=St.map(t=>d.map(n=>Float64Array.from(n,n=>n*function(t){const n=e(t);let o=1+(1023&n)/1024,r=(n>>10)-15;for(;r<0;)o/=2,r++;for(;r>0;)o*=2,r--;return o}(4/(2040*c))*8*255/t))),A=new Int16Array(192),g=new Float64Array(3),U=new Int32Array(6),b=new Float64Array(6),m=new Float64Array(6);let I=0,x=0;const S=(t,n,o)=>{let r=0,e=0;const s=Et[o]*d[0][1]*d[0][1]/(c*c);for(let i=1;i<64;i++){if(!o){for(let r=0;r<3;r++){const s=p[r][64*n+i];g[r]=Xt(s,r)*M[o][r][i]-t[64*r+i],s&&(e+=2+2*(32-Math.clz32(Math.abs(s))))}r+=vt(g[0],g[1],g[2]);continue}for(let n=0;n<3;n++){const r=t[64*n+i],e=M[o][n][i],s=Math.floor(r/e);for(let t=0;t<2;t++){const o=s+t;U[2*n+t]=o,m[2*n+t]=o?2+2*(32-Math.clz32(Math.abs(o))):0,b[2*n+t]=o<-32768||o>32767?1/0:Xt(o,n)*e-r}}let c=0,f=1/0,l=0;for(let t=0;t<8;t++){const n=vt(b[1&t],b[2+(t>>1&1)],b[4+(t>>2)]),o=n+s*(m[1&t]+m[2+(t>>1&1)]+m[4+(t>>2)]);o<f&&(f=o,c=t,l=n)}if(f===1/0)return{error:1/0,rate:65535};r+=l;for(let t=0;t<3;t++){const n=U[2*t+(c>>t&1)];A[64*t+i]=n,n&&(e+=2+2*(32-Math.clz32(Math.abs(n))))}}return{error:r,rate:e}};for(let t=0;t<l;t++)for(let n=0;n<f;n++){const o=t*f+n,r=w(n,t);for(let t=0;t<u;t++){const n=S(r,o,t),e=o*u+t;h[e]=n.error,y[e]=n.rate,t||(I+=n.error,x+=n.rate)}if(((o+1)%1024==0||o+1===a)&&(yield(o+1)/(3*a)))return null}const E=new Uint8Array(a);let L=0;const J=function*(t,n){let o=0,r=0;for(let e=0;e<a;e++){const s=e*u;let i=0,c=h[s]+t*y[s];for(let n=1;n<u;n++){const o=h[s+n]+t*y[s+n];o<c&&(c=o,i=n)}if(o+=h[s+i],r+=y[s+i],n&&(E[e]=i),((e+1)%1024==0||e+1===a)&&(yield 1/3+(L+(e+1)/a)/147))return null}return L++,{error:o,rate:r}};let X=0,v=Math.max(1,I/Math.max(1,x));for(let t=0;t<24;t++){const t=yield*J(v,!1);if(!t)return null;if(t.error>I)break;v*=2}for(let t=0;t<24;t++){const t=(X+v)/2,n=yield*J(t,!1);if(!n)return null;n.error<=I?X=t:v=t}const T=yield*J(X,!0);if(!T||T.error>I||T.rate>=x||!E.some(t=>t))return null;const _=new Uint8Array(a);for(let t=0;t<l;t++)for(let n=0;n<f;n++){const o=t*f+n,r=E[o];if(_[o]=St[r],r){S(w(n,t),o,r);for(let t=0;t<3;t++)for(let n=1;n<64;n++)p[t][64*o+n]=A[64*t+n]}if(((o+1)%1024==0||o+1===a)&&(yield 2/3+(o+1)/(3*a)))return null}return{...n,quantFieldBase:4,quantFields:_,reconstructionError:{baseline:I,candidate:T.error}}}(n,l,a.byteLength),2,4);o&&(a=yield*t(f(o,4,a),3,4))}catch(t){if((!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t}return a}(n,o,r,l,a,u,f))}function k(t,n){return U(t,n,Ct),Ct[0]}function z(t){let n=0;for(t>=2&&t<4294967296&&(n=31-Math.clz32(t),t*=Ot[n]);t>=1.4142135623730951;)t/=2,n++;for(;t<.7071067811865476;)t*=2,n--;const o=(t-1)/(t+1),r=o*o;let e=o,s=o;for(let t=3;t<30;t+=2)s+=(e*=r)/t;return n+2.885390081777927*s}function R(t){let n=0,o=0;for(const o of t)n+=o;for(const r of t)r&&(o+=r*z(n/r));return o}function B(t,{maxClusters:n=48,newClusterCost:o=320}={}){const r=[];for(let n=0;n<t.st;n++)t.it[n]>0&&r.push(n);r.sort((n,o)=>t.it[o]-t.it[n]);const e=[];for(const s of r){const r=t.ct([s],_t),i=R(r);let c=-1,f=1/0;for(let t=0;t<e.length;t++){const n=e[t],o=new Uint32Array(64);for(let t=0;t<64;t++)o[t]=n.W[t]+r[t];const s=R(o)-n.$-i;s<f&&(f=s,c=t)}if(c<0||e.length<n&&f>o)e.push({st:[s],W:r,$:i});else{const t=e[c];t.st.push(s);for(let n=0;n<64;n++)t.W[n]+=r[n];t.$=R(t.W)}}e.length||e.push({st:[],W:new Uint32Array(64),$:0});const s=new Uint8Array(t.st);let i=2*t.st;const c=e.map((n,o)=>{for(const t of n.st)s[t]=o;let r=Tt[0],e=1/0;for(const o of Tt){const s=t.ft(n.st,o);s<e&&(e=s,r=o)}const c=p(t.ct(n.st,r,128));return i+=e+3*c.u+40,{config:r,code:c}});return{L:s,J:c,write:(t,n,o)=>{const r=c[s[n]];m(t,r.code,r.config,o)},$:i}}function Z(t,n="JXL_JPEG"){return Object.assign(new Error("JPEG: "+t),{code:n})}function D(t,n,o){const r=[];if(n>0){const o=new Uint32Array(2048);let e=0;for(const n of t)o[Math.min(2047,Math.max(0,n+1024))]++,e++;let s=0,i=e/(n+1);for(let t=0;t<2048&&r.length<n;t++)s+=o[t],s>i&&(r.push(t-1025),i=e*(r.length+1)/(n+1))}const e=r.length+1,s=new Uint8Array(39*e);for(let t=0;t<e;t++)for(let n=0;n<qt;n++)s[(0+n)*e+t]=t,s[(13+n)*e+t]=o?e:e+(t>>1),s[(26+n)*e+t]=o?e:e+(e-1>>1)+1+(t>>1);let i=0;for(const t of s)i=Math.max(i,t+1);return{thresholds:r,lt:e,map:s,ut:i,ht:t=>{let n=0;for(const o of r)t>o&&n++;return n},yt:(t,n)=>s[(t<2?1^t:2)*qt*e+n],wt:(t,n)=>(Math.min(t,64)<8?Math.min(t,64):4+(Math.min(t,64)>>1))*i+n,dt:t=>37*i+458*t,st:495*i}}function Y(t,n,o){const r=n.map(()=>S(o)),e=r.map(()=>new Uint32Array(257));n.forEach((t,n)=>T(null,e[n],t.data,t.w,t.h,r[n])),X(t,{H:!1,K:[]});const s=L(t,E(r)),i=v(t,s,e,t=>r.indexOf(t));n.forEach((n,o)=>T(t,i[o+1].code,n.data,n.w,n.h,r[o]))}function*H(t,o={}){const{width:i,height:c,components:a,alpha:h}=t,y=1===a.length,w=t.quantScale||1;let d=t.quantFieldBase||1;for(;d/(2040*w)<1/16384;)d*=2;const M=t.ycbcr||y,g=y?[0,0,0]:M?[1,0,2]:[0,1,2],U=g.map(t=>a[t]),S=o.orders?g.map(t=>o.orders[t].map(t=>jt[t])):[jt,jt,jt],E=t=>1===t?0:2===t?1:-1,L=U.map(t=>E(t.h)),J=U.map(t=>E(t.v));if(L.includes(-1)||J.includes(-1))throw Z("sampling factors other than one or two");const X=Math.max(...L),v=Math.max(...J),T=t=>X-L[t],_=t=>v-J[t];if(!M&&(X||v))throw Z("an RGB JPEG with subsampling");const N=Math.ceil(i/(8<<X))<<X,C=Math.ceil(c/(8<<v))<<v,O=Math.ceil(i/ut),P=Math.ceil(c/ut),q=O*P,F=Math.ceil(N/256),G=F*Math.ceil(C/256),j=1===q,k=(t,n,o)=>{const r=U[t];return y&&1!==t?-1:64*(o*r.stride+n)},z=t=>{let n=1024;for(;t%n;)n>>=1;return n},R=U.map(t=>M?1:t.quant[0]/z(t.quant[0])),H=U.map(t=>M?0:1024/z(t.quant[0])),Q=new Int32Array(N*C);for(let t=0;t<C;t++)for(let n=0;n<N;n++)Q[t*N+n]=U[1].coeffs[k(1,n,t)]*R[1]+H[1];const K=U[1].quant,V=(K[8]+K[16]+K[24]+K[32]+K[40])/w,W=N*C,$=W<256?0:Math.max(1,Math.min(7,r(W)-r(V)-7));let tt=D(Q,$,y);const nt=new ct(256);if(f(nt,i,c,y?1:3,!!h,{orientation:t.orientation,colorSpace:t.colorSpace}),nt.write(1,0),nt.write(2,0),nt.write(1,0),nt.write(2,2),nt.write(8,111),nt.write(1,M?1:0),M)for(let t=0;t<3;t++)nt.write(2,0===L[t]&&0===J[t]?0:1===L[t]&&1===J[t]?1:1===L[t]?2:3);nt.write(2,0),h&&nt.write(2,0),l(nt,h);const ot=[0,1,2].map(()=>new Int32Array(1024)),rt=(t,o)=>{const r=t%O*32,e=32*(t/O|0),s=Math.min(32,N-r),i=Math.min(32,C-e);for(let t=0;t<i;t++)for(let i=0;i<s;i++)for(const s of[1,0,2]){const c=T(s),f=_(s),l=i>>c,a=t>>f;if(l<<c!==i||a<<f!==t)continue;const u=k(s,(r>>c)+l,(e>>f)+a),h=U[s].coeffs;let y=0;if(u>=0)for(let t=1;t<64;t++)h[u+t]&&y++;const w=ot[s],d=0===l?0===a?32:w[32*(a-1)]:0===a?w[32*a+l-1]:w[32*(a-1)+l]+w[32*a+l-1]+1>>1;w[32*a+l]=y;const p=tt.yt(s,tt.ht(Q[(e+t)*N+r+i]));o(tt.wt(d,p),y);const M=tt.dt(p);let A=y>4?0:1,g=y;for(let t=1;t<64&&g;t++){const r=h[u+S[s][t]];o(M+kt(g,t,A),n(r)),A=r?1:0,g-=A}}},et=($>0?3:2)*q+G;let st=0;const it=function*(t){tt=t;const n=new Nt(t.st);for(let t=0;t<q;t++)rt(t,(t,o)=>n.add(t,o)),yield++st/et;return(o.coding||B)(n,o.clusters)};let ft=yield*it(tt);if($>0){const t=tt,n=D(Q,0,y),o=yield*it(n);o.$<=ft.$?ft=o:tt=t}const lt=Array.from({length:j?1:2+G+q},()=>null),at=t=>lt[j?0:t]||(lt[j?0:t]=new ct(4096)),ht=new Uint32Array(lt.length);let yt=0;const wt=t=>{t=j?0:t;const n=Math.ceil(lt[t].V/8);yt+=n-ht[t],ht[t]=n,s(yt)},dt=at(0);dt.write(1,0);const pt=(t,n)=>{const o=t*ut,r=n*ut,e=Math.min(ut,i-o),s=Math.min(ut,c-r),f=new Int32Array(e*s);for(let t=0;t<s;t++)for(let n=0;n<e;n++)f[t*e+n]=h[4*((r+t)*i+o+n)+3];return{w:e,h:s,data:f}};for(let t=0;t<3;t++)dt.write(16,e(U[t].quant[0]/R[t]/(2040*w)*128));dt.write(2,3),dt.write(16,57343),dt.write(2,1),dt.write(5,0),dt.write(1,0),dt.write(4,0),dt.write(4,tt.thresholds.length);for(const t of tt.thresholds)dt.t([[4,0],[8,16],[16,272],[32,65808]],n(t));dt.write(4,0),dt.write(4,0),I(dt,tt.map),dt.write(1,0),dt.write(2,0),dt.write(16,0),dt.write(16,0),dt.write(8,128),dt.write(8,128),dt.write(1,0),h&&Y(dt,[j?pt(0,0):{w:0,h:0,data:new Int32Array(0)}],Mt),wt(0);for(let n=0;n<G;n++){const o=at(1+n),e=n%F*256,s=256*(n/F|0),i=Math.min(256,N-e),c=Math.min(256,C-s);o.write(2,0),Y(o,[1,0,2].map(t=>{const n=i>>T(t),o=c>>_(t),r=new Int32Array(n*o),f=R[t],l=H[t];for(let i=0;i<o;i++)for(let o=0;o<n;o++){const c=k(t,(e>>T(t))+o,(s>>_(t))+i);r[i*n+o]=c<0?0:U[t].coeffs[c]*f+l}return{w:n,h:o,data:r}}),Mt);const f=i*c,l=r(f);l&&o.write(l,f-1);const a=i+7>>3,u=c+7>>3,h=new Int32Array(2*f).fill(d-1,f);if(t.quantFields)for(let n=0;n<c;n++)for(let o=0;o<i;o++)h[f+n*i+o]=t.quantFields[(s+n)*N+e+o]-1;Y(o,[{w:a,h:u,data:new Int32Array(a*u)},{w:a,h:u,data:new Int32Array(a*u)},{w:f,h:2,data:h},{w:i,h:c,data:new Int32Array(f)}],d>1?Mt:0),wt(1+n),yield++st/et}const At=at(1+G);At.write(1,0),At.write(3,7),At.write(16,e(d/(2040*w))),Y(At,[0,1,2].map(t=>{const n=new Int32Array(64),o=U[t].quant;for(let t=0;t<8;t++)for(let r=0;r<8;r++)n[8*r+t]=o[8*t+r];return{w:8,h:8,data:n}}),Mt);for(let t=1;t<17;t++)At.write(3,0);if(q>1&&At.write(r(q),0),o.orders){At.t([[0,95],[0,19],[0,0],[13,0]],1);const t=[];for(const n of g){const r=Array.from({length:64},(t,n)=>n),e=o.orders[n].map(t=>{const n=r.indexOf(t);return r.splice(n,1),n});let s=64;for(;s>1&&!e[s-1];)s--;t.push(s-1,...e.slice(1,s))}const n=A(0),r=new Uint32Array(64);for(const o of t)b(n,o,r);const e=p(r);x(At,{L:new Uint8Array(8),J:[{config:n,code:e}]});for(const o of t)m(At,e,n,o)}else At.write(2,2);ft.writeHistograms?ft.writeHistograms(At):x(At,{L:ft.L,J:ft.J}),wt(1+G);for(let t=0;t<q;t++){const n=at(2+G+t);rt(t,(t,o)=>ft.write(n,t,o)),ft.flush&&ft.flush(n),h&&!j&&Y(n,[pt(t%O,Math.floor(t/O))],Mt),wt(2+G+t),yield++st/et}return u(nt,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(lt))}function*Q(t,n,o){if(n<3&&!o)return yield*H(t);let r=o;try{const o=H(t);let e,s;for(;!(e=o.next()).done;)if(s=yield e.value/2,s&&r&&e.value<1)return o.return(),r;if((!r||e.value.length<r.length)&&(r=e.value),s||n<3)return r;const i=n<4?1:3,c=H(t,{clusters:{maxClusters:32,newClusterCost:160}});for(;!(e=c.next()).done;)if(s=yield.5+e.value/(2*i),s&&e.value<1)return c.return(),r;if(e.value.length<r.length&&(r=e.value),s||n<4)return r;const f=function*(t){const n=Pt.map(t=>(7&t)<<3|t>>3),o=t.map(()=>new Uint32Array(64)),r=t.reduce((t,n)=>t+n.coeffs.length,0);let e=0;for(let s=0;s<t.length;s++){const{coeffs:i}=t[s],c=o[s];for(let t=0;t<i.length;t+=65536){const o=Math.min(t+65536,i.length);for(let r=t;r<o;r+=64)for(let t=1;t<64;t++)i[r+n[t]]&&c[t]++;if(e+=o-t,yield e/r)return null}}return o.map(t=>[0,...Array.from({length:63},(t,n)=>n+1).sort((n,o)=>Math.floor(t[o]/8)-Math.floor(t[n]/8)||n-o)])}(t.components);for(;!(e=f.next()).done;)if(yield.5+(1+e.value)/6)return f.return(),r;const l=H(t,{orders:e.value});for(;!(e=l.next()).done;)if(s=yield.5+(2+e.value)/6,s&&e.value<1)return l.return(),r;return e.value.length<r.length?e.value:r}catch(t){if(!r||(!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t;return r}}function K(t,n){if(!n)return void t.write(1,0);const r=o(n);t.write(1,1),t.write(3,r),t.write(r,n-(1<<r))}function V(t){let n=0,o=0;for(let r=0;r<t.length;r++)n+=t[r],t[r]&&(o=r+1);const r=new Uint16Array(o||1);if(!n)return r[0]=4096,r;let e=0;for(let s=0;s<o;s++)t[s]&&(e+=r[s]=Math.max(1,Math.round(4096*t[s]/n)));for(;4096!==e;){const s=e<4096?1:-1;let i=-1,c=-1/0;for(let e=0;e<o;e++)if(t[e]&&(s>0||r[e]>1)){const o=s*(4096*t[e]-r[e]*n);o>c&&(i=e,c=o)}r[i]+=s,e+=s}return r}function W(t,n){const r=[];let e=0;for(let t=0;t<n.length;t++)n[t]&&r.push(t),n[t]>n[e]&&(e=t);if(r.length<=2){t.write(1,1),t.write(1,r.length-1);for(const n of r)K(t,n);return void(2===r.length&&t.write(12,n[r[0]]))}t.write(1,0),t.write(1,0),t.write(3,7),t.write(3,5),K(t,n.length-3);const s=new Uint8Array(n.length);let i=0;for(let t=0;t<n.length;t++)t!==e&&n[t]&&(s[t]=o(n[t])+1,i=Math.max(i,s[t]+(t<e?1:0)));s[e]=i;for(const n of s)t.write(zt[n],Rt[n]);for(let o=0;o<n.length;o++)if(o!==e&&s[o]>1){const r=s[o]-1;t.write(r,n[o]-(1<<r))}}function $(t,n){const o=1<<n,r=4096>>n,e=new Uint16Array(t.length+1),s=new Uint16Array(4096);let i=-1;for(let n=0;n<t.length;n++)e[n+1]=e[n]+t[n],4096===t[n]&&(i=n);if(i>=0){for(let t=0;t<4096;t++)s[t]=t;return{starts:e,reverse:s}}const c=new Int32Array(o),f=new Uint16Array(o),l=new Int32Array(o),a=[],u=[];c.set(t);for(let t=0;t<o;t++)c[t]<r?a.push(t):c[t]>r&&u.push(t);for(;u.length;){const t=u.pop(),n=a.pop(),o=r-c[n];c[t]-=o,f[n]=t,l[n]=c[t]-c[n],c[t]<r?a.push(t):c[t]>r&&u.push(t)}for(let t=0;t<o;t++)for(let n=0;n<r;n++){const o=n<c[t],i=o?t:f[t],a=o?n:n+l[t];s[e[i]+a]=t*r+n}return{starts:e,reverse:s}}function tt(t,n){const o=B(t,n),e=o.J.map(()=>[]);for(let n=0;n<t.st;n++)t.it[n]&&e[o.L[n]].push(n);const s=o.J.map(({config:n},o)=>({config:n,counts:V(t.ct(e[o],n,256))})),i=Math.max(5,r(Math.max(...s.map(t=>t.counts.length))));for(const t of s)Object.assign(t,$(t.counts,i));const c=new ct;c.write(1,0),o.L.length>1&&I(c,o.L),c.write(1,0),c.write(2,i-5);for(const t of s)g(c,t.config,i);for(const t of s)W(c,t.counts);const f=new Uint32Array(Bt),l=new Uint8Array(Bt),a=new Uint16Array(Bt),u=[0,0,0];let h=0;return{$:o.$,write:(t,n,r)=>{f[h]=r,l[h++]=o.L[n]},flush:t=>{let n=1245184;for(let t=h-1;t>=0;t--){const o=s[l[t]];U(o.config,f[t],u);const r=u[0],e=o.counts[r];f[t]=u[2],l[t]=u[1],n>>>20>=e&&(a[t]=65535&n,l[t]|=64,n>>>=16);const i=Math.floor(n/e);n=4096*i+o.reverse[o.starts[r]+n-i*e]}t.write(32,n);for(let n=0;n<h;n++){64&l[n]&&t.write(16,a[n]);const o=63&l[n];o&&t.write(o,f[n])}h=0},writeHistograms:t=>t.append(c)}}function*nt(n,o,r){if(o<2)return yield*Q(n,o,r);let e=yield*t(Q(n,o,r),0,2);if(yield.5)return e;try{const t=H(n,{coding:tt});let o;for(;!(o=t.next()).done;)if((yield.5+o.value/2)&&o.value<1)return t.return(),e;o.value.length<e.length&&(e=o.value)}catch(t){if((!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t}return e}function ot(t,n,o,r){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(rt(t,n,o,r))}function rt(t,n,o,r){return j(t,n,o,r,nt)}const et=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),st=Object.freeze({bytes:16777216,pixels:4e7,edge:16384}),it=[1];for(let t=1;t<=32;t++)it.push(2*it[t-1]);class ct{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.Mt=0,this.pending=0}write(t,n){if(!(n>=0&&n<it[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let o=this.Mt+n*(1<<this.pending),r=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const e=this.bytes;for(;r>=8;)e[this.at++]=255&o,o=Math.floor(o/256),r-=8;this.Mt=o,this.pending=r}t(t,n){for(let o=0;o<4;o++){const[r,e]=t[o];if(n>=e&&n-e<it[r])return this.write(2,o),void(r&&this.write(r,n-e))}throw new Error("U32 value out of range: "+n)}o(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.Mt,this.Mt=0,this.pending=0)}get V(){return 8*this.at+this.pending}grow(t=0){const n=et.bytes+64;if(this.at+t+16>n)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const o=new Uint8Array(Math.min(n,Math.max(2*this.bytes.length,this.at+t+16)));o.set(this.bytes.subarray(0,this.at)),this.bytes=o}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let n=0;n<t.at;n++)this.write(8,t.bytes[n]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.Mt)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.Mt),n}}const ft=(t,n)=>"number"==typeof t?n(t):{...t,at:o=>n(t.at(o))},lt=(t,n)=>Object.assign(new Error(n),{code:t}),at={channel:null,weighted:null,fill:null},ut=256,ht=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],yt=[2,4,3,2,2,4],wt=[0,7,3,2,1,15],dt=[0,0,0],pt=3,Mt=5,At=A(4),gt=Object.freeze({T:224,minLength:7,_:At}),Ut=A(0),bt=[A(0),A(4),A(4,1,1),A(3,0,1)],mt=(t,n,o,r)=>o?r?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(r?16777216*t[n+3]:0),It=Float64Array.of(.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.4903926402016152,.4157348061512726,.27778511650980114,.09754516100806417,-.0975451610080641,-.277785116509801,-.4157348061512727,-.4903926402016152,.46193976625564337,.19134171618254492,-.19134171618254486,-.46193976625564337,-.4619397662556434,-.19134171618254517,.191341716182545,.46193976625564326,.4157348061512726,-.0975451610080641,-.4903926402016152,-.2777851165098011,.2777851165098009,.4903926402016152,.09754516100806439,-.41573480615127256,.3535533905932738,-.35355339059327373,-.35355339059327384,.3535533905932737,.35355339059327384,-.35355339059327334,-.35355339059327356,.3535533905932733,.27778511650980114,-.4903926402016152,.09754516100806415,.4157348061512728,-.41573480615127256,-.09754516100806401,.4903926402016153,-.27778511650980076,.19134171618254492,-.4619397662556434,.46193976625564326,-.19134171618254495,-.19134171618254528,.46193976625564337,-.4619397662556432,.19134171618254478,.09754516100806417,-.2777851165098011,.4157348061512728,-.4903926402016153,.4903926402016152,-.4157348061512725,.27778511650980076,-.09754516100806429),xt=Float64Array.from({length:64},(t,n)=>{const o=.26236426446749106*Math.max(0,5*Math.sqrt((7&n)*(7&n)+(n>>3)*(n>>3))/Math.sqrt(98)-1);let r=1,e=1;for(let t=1;t<30;t++)e+=r=r*o/t;return e}),St=[4,4,4,4,3,2,6,8],Et=[0,.125,.25,.5,.25,.25,.25,.25],Lt=[.9299455010825141,.945349926692846,.9500648966626563],Jt=10.5*st.pixels,Xt=(t,n)=>Math.abs(t)<2?t*Lt[n]:t-.145/t,vt=(t,n,o)=>{const r=t+1.402*o,e=t-.344136286*n-.714136286*o,s=t+1.772*n;return r*r+e*e+s*s},Tt=[A(0),A(1),A(2),A(3),A(4),A(4,1,1),A(5,1,1),A(2,0,1),A(3,0,1)],_t=A(4,1,1);class Nt{constructor(t){this.st=t,this.small=new Uint32Array(64*t),this.At=Array.from({length:t},()=>null),this.it=new Float64Array(t)}add(t,n){if(this.it[t]++,n<64)return void this.small[64*t+n]++;const o=this.At[t]||(this.At[t]=new Map);o.set(n,(o.get(n)||0)+1)}ct(t,n,o=64){const r=new Uint32Array(o);for(const o of t){const t=64*o;for(let o=0;o<64;o++)this.small[t+o]&&(r[k(n,o)]+=this.small[t+o]);const e=this.At[o];if(e)for(const[t,o]of e)r[k(n,t)]+=o}return r}ft(t,n){let r=R(this.ct(t,n));for(const e of t){const t=64*e;for(let e=n.S;e<64;e++)this.small[t+e]&&(r+=this.small[t+e]*(o(e)-n.m-n.I));const s=this.At[e];if(s)for(const[t,e]of s)r+=e*(o(t)-n.m-n.I)}return r}}const Ct=[0,0,0],Ot=[1];for(let t=1;t<32;t++)Ot.push(Ot[t-1]/2);const Pt=[0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63],qt=13,Ft=[0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30],Gt=[0,0,31,62,62,93,93,93,93,123,123,123,123,152,152,152,152,152,152,152,152,180,180,180,180,180,180,180,180,180,180,180,180,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206],jt=Pt.map(t=>(7&t)<<3|t>>3),kt=(t,n,o)=>2*(Gt[t]+Ft[n])+o,zt=[5,4,4,4,4,4,3,3,3,3,3,6,7],Rt=[17,11,15,3,9,7,4,2,5,6,0,33,1],Bt=196608;export{st as LIMITS,ot as encodePhoto,rt as encodePhotoSteps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Rapier JXL 2.2.
|
|
1
|
+
/*! Rapier JXL 2.2.1 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
2
2
|
function*t(t,n,o){let r,e;for(;!(r=t.next(e)).done;)e=yield ot(r.value,t=>(n+t)/o);return r.value}function n(t){return t>=0?2*t:2*-t-1}function o(t){return 31-Math.clz32(t)}function r(t){return t<=1?0:32-Math.clz32(t-1)}function e(t){if(0===t)return 0;const n=t<0?32768:0;if(!((t=Math.abs(t))<65520))throw new Error("half float out of range: "+t);let o=0,r=t;for(;r>=2;)r/=2,o++;for(;r<1;)r*=2,o--;o<-14?(r=16384*t,o=-15):r-=1;let e=Math.round(1024*r);return 1024===e&&(e=0,o++),n|o+15<<10|e}function s(t){if(t>W.bytes)throw rt("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function i(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw rt("JXL_MEMORY","Not enough memory for this picture.");throw t}}function c(t,n){t.t([[9,1],[13,1],[18,1],[30,1]],n)}function f(t,n,o,r,e,{xyb:s=!1,orientation:i=1,colorSpace:f}={}){t.write(16,2815),t.write(1,0),c(t,o),t.write(3,0),c(t,n),t.write(1,0);const l=1!==i;t.write(1,l?1:0),l&&t.write(6,i-1),t.write(4,8),e?t.write(3,5):t.write(2,0),t.write(1,s?1:0),3===r&&"display-p3"===f?t.write(21,903568):3===r?t.write(1,1):t.write(15,14100),l&&t.write(1,1),t.write(2,0),t.write(1,1),t.o()}function l(t,n){t.write(n?7:5,0),t.write(11,1)}function*a(t,n,o,r){if(t.pooled){const n=yield t;return n?(n.results.forEach((t,n)=>r(n,t)),n.hurried):null}let e=!1;for(let r=0;r<n;r++)if(o(r),e=yield t.at(r),e&&t.stop(r))return null;return e}function u(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.o();for(const o of n)t.t([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.o()}(t,o);const r=t.finish(),e=r.length+o.reduce((t,n)=>t+n,0);s(e);const i=new Uint8Array(e);i.set(r);let c=r.length;for(const t of n)i.set(t,c),c+=t.length;return i}function h(t,n){const o=new Uint8Array(t.length),r=[];for(let n=0;n<t.length;n++)t[n]>0&&r.push(n);if(!r.length)return o;if(1===r.length)return o[r[0]]=1,o;for(let e=1;;e*=2){const s=r.map(n=>({w:Math.max(t[n],e),i:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.i-n.i),i=[];let c=0,f=0;const l=()=>c<s.length&&(f>=i.length||s[c].w<=i[f].w)?s[c++]:i[f++];for(;s.length-c+(i.length-f)>1;){const t=l(),n=l();i.push({w:t.w+n.w,i:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.i>=0?(o[t.i]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function y(t,n,o,r,e,s){const i=[];for(;i.push(r&e),r>>=s;)r--;for(let r=i.length-1;r>=0;r--)t.push(o),n.push(i[r])}function w(t,n){let o=0;for(let r=0;r<n;r++)o=o<<1|1&t,t>>=1;return o}function d(t){const n=new Uint32Array(17),o=new Uint32Array(17),r=new Uint16Array(t.length);for(const o of t)n[o]++;n[0]=0;for(let t=1,r=0;t<=16;t++)r=r+n[t-1]<<1,o[t]=r;for(let n=0;n<t.length;n++)t[n]&&(r[n]=w(o[t[n]]++,t[n]));return r}function p(t){const n=[];for(let o=0;o<t.length;o++)t[o]>0&&n.push(o);const o=n.length,r=n[o-1]+1||1,e=o<=4?new Uint8Array(r):h(t,15).subarray(0,r);let s=0;if(o<=4){n.sort((n,o)=>t[o]-t[n]||n-o),s=4===o&&t[n[0]]>t[n[2]]+t[n[3]]?1:0;const r=o<2?[0]:2===o?[1,1]:3===o?[1,2,2]:s?[1,2,3,3]:[2,2,2,2];n.forEach((t,n)=>{e[t]=r[n]}),n.sort((t,n)=>e[t]-e[n]||t-n)}return{u:r,p:e,M:d(e),A:o&&o<=4?n:null,m:s}}function M(t,n){if(n.u<=1)return;if(n.A){const r=o(n.u-1)+1;t.write(2,1),t.write(2,n.A.length-1);for(const o of n.A)t.write(r,o);return void(4===n.A.length&&t.write(1,n.m))}const r=n.p,e=[],s=[];let i=r.length-1;for(;i>0&&!r[i];)i--;let c=8;for(let t=0;t<=i;){const n=r[t];let o=1;for(;t+o<=i&&r[t+o]===n;)o++;let f=o;if(n&&n!==c&&(e.push(n),s.push(0),f--,c=n),f<3)for(let t=0;t<f;t++)e.push(n),s.push(0);else y(e,s,n?16:17,f-3,n?3:7,n?2:3);t+=o}const f=new Uint32Array(18);for(const t of e)f[t]++;let l=0;for(const t of f)t&&l++;1===l&&(f[e[0]?0:1]=f[e[0]]);const a=h(f,5),u=d(a);let w=18;for(;w>0&&!a[it[w-1]];)w--;t.write(2,0);for(let n=0;n<w;n++){const o=a[it[n]];t.write(ct[o],ft[o])}for(let n=0;n<e.length;n++){const o=e[n];t.write(a[o],u[o]),16===o?t.write(2,s[n]):17===o&&t.write(3,s[n])}}function A(t,n=0,o=0){return{split:t,U:n,I:o,S:1<<t}}function g(t,n,o=15){t.write(r(o+1),n.split),n.split!==o&&(t.write(r(n.split+1),n.U),t.write(r(n.split-n.U+1),n.I))}function b(t,n,r){if(n<t.S)return r[0]=n,r[1]=0,void(r[2]=0);const e=o(n),s=n-(1<<e),i=e-t.U-t.I;r[0]=t.S+(e-t.split<<t.U+t.I|s>>e-t.U<<t.I|s&(1<<t.I)-1),r[1]=i,r[2]=n>>t.I&(1<<i)-1}function m(t,n,o,r=0){b(t,n,lt),o[r+lt[0]]++}function U(t,n,o,r,e=0){b(o,r,lt);const s=e+lt[0];t.write(n.p[s],n.M[s]),lt[1]&&t.write(lt[1],lt[2])}function I(t,n){let o=0;for(const t of n)o=Math.max(o,t);const e=o?r(o+1):0;if(e<=3){if(t.write(1,1),t.write(2,e),e)for(const o of n)t.write(e,o);return}t.write(1,0),t.write(1,0);const s=A(8),i=A(4),c=n.length>=64,f=new Uint32Array(c?257:o+1),l=[];for(let t=0;t<n.length;){let o=1;for(;c&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)l.push([n[t],o-1]),f[n[t]]++,m(i,o-1-7,f,224),t+=o;else{for(let r=0;r<o;r++)l.push([n[t],0]),f[n[t]]++;t+=o}}const a=p(f);if(!c){x(t,{L:new Uint8Array(1),J:[{config:s,code:a}]});for(const[n]of l)U(t,a,s,n);return}const u=new Uint32Array(1);u[0]=1,x(t,{T:{X:224,minLength:7,N:i},L:new Uint8Array([1,0]),J:[{config:A(0),code:p(u)},{config:s,code:a}]});for(const[n,o]of l)U(t,a,s,n),o&&U(t,a,i,o-7,224)}function x(t,{T:n=null,L:r,J:e}){t.write(1,n?1:0),n&&(t.t([[0,224],[0,512],[0,4096],[15,8]],n.X),t.t([[0,3],[0,4],[2,5],[8,9]],n.minLength),g(t,n.N,8)),r.length>1&&I(t,r),t.write(1,1);for(const n of e)g(t,n.config,15);for(const n of e){const r=n.code.u-1;if(r){const n=o(r);t.write(1,1),t.write(4,n),t.write(n,r-(1<<n))}else t.write(1,0)}for(const n of e)M(t,n.code)}function S(t,n=0,o=1){return{_:t,offset:n,C:o,context:-1}}function E(t){return function(t,n){const o=(r,e)=>{if(r===e)return n?t[r].O:t[r];const s=r+e>>1;return function(t,n,o,r){return{P:t,q:n,left:o,right:r}}(n,n?t[s].F:s,o(s+1,e),o(r,s))};return o(0,t.length-1)}(t,0)}function L(t,o){const r=[o],e=[],s=[];for(const t of r){if(t.left){e.push(t.P+1,n(t.q)),r.push(t.left,t.right);continue}t.context=s.length,s.push(t);const o=1===t.C?0:31-Math.clz32(t.C&-t.C);e.push(0,t._,n(t.offset),o,(t.C>>o)-1)}const i=new Uint32Array(64);for(const t of e)m(wt,t,i);const c=p(i);x(t,{L:new Uint8Array(6),J:[{config:wt,code:c}]});for(const n of e)U(t,c,wt,n);return s}function J(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.t(o,n.G),t.t([[0,6],[2,0],[4,2],[6,10]],n.j??6);else if("palette"===n.type)t.write(2,1),t.t(o,n.G),t.t([[0,1],[0,3],[0,4],[13,1]],n.k),t.t([[8,0],[10,256],[12,1280],[16,5376]],n.B),t.t([[0,0],[8,1],[10,257],[16,1281]],n.R??0),t.write(4,n._??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const r=n.Z??[];t.t([[0,0],[4,1],[6,9],[8,41]],r.length);for(const n of r)t.write(1,n.D?1:0),t.write(1,n.Y?1:0),t.t(o,n.G),t.t([[0,1],[0,2],[0,3],[4,4]],n.k)}}}function T(t,{H:n=!0,K:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.t([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)J(t,n)}function X(t,n,o,r=t=>t.context,e=()=>wt){const s=new Uint8Array(n.length+1);for(const t of n)s[t.context]=r(t)+1;const i=new Uint32Array(2);i[1]=1;const c=[{config:wt,code:p(i)}],f=Math.max(...s);for(let t=0;t<f;t++)c.push({config:e(t),code:p(o[t])});return x(t,{T:yt,L:s,J:c}),c}function N(t,o,r,e,s,i,c=!1){if(et.channel?.(t,o,r,e,s,i,c))return;const f=i._,l=i.offset,a=i.C,u=i.config||wt,h=ht;let y=0;const w=(n,r=u,e=0)=>{t?U(t,o,r,n,e):c&&!e?o[n]++:m(r,n,o,c?o.length-33:e)},d=()=>{if(y){if(y>=8)w(0),w(y-7-1,h,224);else for(let t=0;t<y;t++)w(0);y=0}},p=(t,o)=>{const e=r[t];let s;1===a?s=e-o-l:(s=Math.round((e-o-l)/a),r[t]=o+l+s*a),0!==s?(d(),w(n(s))):y++};for(let t=0,n=0;t<s;t++)for(let o=0;o<e;o++,n++){let s;if(0===f)s=0;else{const i=o?r[n-1]:t?r[n-e]:0,c=t?r[n-e]:i;if(1===f)s=i;else if(2===f)s=c;else if(3===f)s=(i+c)/2|0;else{const l=i+c-(o&&t?r[n-e-1]:i);if(5===f){const t=i<c?i:c,n=i<c?c:i;s=l<t?t:l>n?n:l}else{if(4!==f)throw new Error("predictor "+f+" is not coded here");s=Math.abs(l-i)<Math.abs(l-c)?i:c}}}p(n,s)}d()}function _(t){const n=t.length-33,r=[0,0,0];let e,s;for(const i of dt){const c=new Uint32Array(257);let f=0;for(let o=0;o<n;o++)t[o]&&(b(i,o,r),c[r[0]]+=t[o],f+=t[o]*r[1]);for(let o=0;o<33;o++)c[224+o]=t[n+o],f+=t[n+o]*Math.max(0,o-12);const l=p(c),a=new nt(128);g(a,i),M(a,l);let u=a.V+f+(1===l.u?1:5+o(l.u-1));for(let t=0;t<c.length;t++)c[t]&&(u+=c[t]*l.p[t]);const h={config:i,W:c,$:u,extra:f};e||(e=h),(!s||u<s.$)&&(s=h)}return[e,s]}function v(t,n,o,{palette:r=!0}={}){const e=n*o;let s=!0,i=!0;for(let n=0,o=0;o<e&&(255===t[n+3]||(s=!1,i))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(i=!1,s));o++,n+=4);const c=i?1:3,f=!s,l=c+(f?1:0),a=n=>pt(t,n,i,f),u=new Map;let h=null;for(let t=0,n=0;r&&n<e;n++,t+=4){const n=a(t);if(0!==n&&!u.has(n)&&(u.set(n,1),u.size>=2048))break}if(r&&u.size<2048){const t=[...u.keys()],n=(t,n)=>t>>>8*n&255,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===l?n(t,3):1);t.sort((t,n)=>o(t)-o(n)),h={colours:[0,...t],byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function C({channels:t,alpha:n,palette:o},r){const e=t-(n?1:0)==1,s=o&&new Map(o.map((t,n)=>[t,n]));return(i,c,f,l,a,u,h)=>{if(r&&!o&&t>=3)r.fill(i,c,f,l,a,u,h);else if(o||!et.fill?.(c,f,l,a,u,h,t,i))for(let r=0;r<h;r++){let h=4*((a+r)*f+l),y=r*u;for(let r=0;r<u;r++,h+=4,y++)if(o)i[0][y]=s.get(pt(c,h,e,n));else if(t>=3){const n=c[h],o=c[h+1],r=c[h+2],e=n-r,s=r+(e>>1),f=o-s;i[0][y]=s+(f>>1),i[1][y]=e,i[2][y]=f,4===t&&(i[3][y]=c[h+3])}else i[0][y]=c[h],2===t&&(i[1][y]=c[h+3])}}}function O(t,n){const{leaves:o,picture:r,M:e}=t,s=C(t,n),i=r.map(()=>new Int16Array(65536));return(t,n,c,f,l,a,u)=>{if(s(i,t,n,c,f,l,a),!e)return void r.forEach((t,n)=>N(null,u[t],i[n],l,a,o[t],!0));const h=u||new nt(l*a*r.length+64);return u||T(h,{H:!0,K:[]}),r.forEach((t,n)=>N(h,e[t],i[n],l,a,o[t])),u?void 0:h.finish()}}function*P(t,n,o,r,e,s,i){const{channels:c,alpha:h,palette:y}=r,w=function(t,n,o=256){const r=Math.ceil(t/o),e=Math.ceil(n/o);return{tt:r,nt:e,ot:Math.ceil(t/(8*o)),rt:Math.ceil(n/(8*o)),et:1===r&&1===e}}(n,o),d=w.tt*w.nt,A=y?2:c,g=Array.from({length:A},()=>S(ut)),b=E(g),m={channels:c,alpha:h,palette:y&&y.colours,rct:s?.type,leaves:g,picture:y?[w.et?1:0]:g.map((t,n)=>n)},U=C(m,s),I=Array.from({length:c},()=>new Int16Array(1024)),x=t=>function(t,n,o,r){const e=r%t.tt*st,s=(r/t.tt|0)*st;return[e,s,Math.min(st,n-e),Math.min(st,o-s)]}(w,n,o,t);let J=null;if(y){const t=y.colours.length;J=new Int16Array(t*c),y.colours.forEach((n,o)=>{for(let r=0;r<c;r++)J[r*t+o]=y.byte(n,r)})}if(!y){const r=t=>{const n=p(t),o=new nt(128);M(o,n);let r=o.V;for(let o=0;o<t.length;o++)t[o]&&(r+=t[o]*(n.p[o]+Math.max(0,o<224?o-1:o-236)));return r},e=Math.min(n,32),s=Math.min(o,32),i=[ut,at].map(t=>({_:t,W:g.map(()=>new Uint32Array(257))}));for(const r of[0,.5,1]){U(I,t,n,Math.floor((n-e)*r),Math.floor((o-s)*r),e,s);for(const t of i)for(let n=0;n<c;n++)N(null,t.W[n],I[n],e,s,S(t._))}g.forEach((t,n)=>{const o=i.map(t=>r(t.W[n])),e=o[1]<o[0]?1:0;t._=i[e]._})}const v=y?[{type:"palette",G:0,k:c,B:y.colours.length}]:c>=3&&0!==s?.type?[{type:"rct",G:0,j:s?.type??6}]:[];let P=g.map(()=>new Uint32Array(33+(y?4096:1024)));J&&N(null,P[0],J,y.colours.length,c,g[0],!0);const q=O(m,s);yield*a({pooled:i,kind:"plan",setup:{...m,sizes:P.map(t=>t.length)},at:t=>(t+1)/(2*d),stop:()=>!1},d,o=>q(t,n,...x(o),P),(t,n)=>function(t,n){t.forEach((t,o)=>{const r=n[o];for(let n=0;n<t.length;n++)t[n]+=r[n]})}(P,n));const F=P.map(_),G=F.reduce((t,n)=>t+n[0].$-n[1].$,0)>27*(w.et?1:d+1)+8?1:0;g.forEach((t,n)=>{t.config=F[n][G].config}),P=F.map(t=>t[G].W);const j=new nt(256);f(j,n,o,r.colour,r.alpha,{colorSpace:e}),function(t,{alpha:n,shift:o=1}){t.write(9,8),n&&t.write(2,0),t.write(2,o),l(t,n)}(j,{alpha:r.alpha});const k=new nt(4096);k.write(1,1),k.write(1,1);const z=X(k,L(k,b),P,t=>g.indexOf(t),t=>g[t].config),B={...m,M:g.map((t,n)=>z[n+1]?.code)},R=O(B,s);T(k,{H:!0,K:v}),J&&N(k,B.M[0],J,y.colours.length,c,g[0]);const Z=[];if(w.et)R(t,n,0,0,n,o,k),yield 1,Z.push(k.finish());else{Z.push(k.finish());for(let t=0;t<w.ot*w.rt+1;t++)Z.push(new Uint8Array(0));const o=Z.length,r=(t,n)=>{Z[o+t]=n};yield*a({pooled:i,kind:"plan",setup:B,at:t=>(d+t+1)/(2*d),stop:()=>!1},d,o=>r(o,R(t,n,...x(o))),r)}return u(j,Z)}function q(t,n,o,r){let e=0;return e+=t[n]*Mt[r],e+=t[n+o]*Mt[r+1],e+=t[n+2*o]*Mt[r+2],e+=t[n+3*o]*Mt[r+3],e+=t[n+4*o]*Mt[r+4],e+=t[n+5*o]*Mt[r+5],e+=t[n+6*o]*Mt[r+6],e+=t[n+7*o]*Mt[r+7],e}function F(t,n,o){const r=new Float64Array(192),e=new Float64Array(64),s=new Float64Array(192);return(i,c)=>{for(let e=0;e<8;e++)for(let s=0;s<8;s++){const f=4*(Math.min(o-1,8*c+e)*n+Math.min(n-1,8*i+s)),l=t[f],a=t[f+1],u=t[f+2],h=8*e+s;r[h]=.299*l+.587*a+.114*u-128,r[64+h]=-.168735892*l-.331264108*a+.5*u,r[128+h]=.5*l-.418687589*a-.081312411*u}for(let t=0;t<3;t++){for(let n=0;n<8;n++)for(let o=0;o<8;o++)e[8*n+o]=q(r,64*t+8*n,1,8*o);for(let n=0;n<8;n++)for(let o=0;o<8;o++)s[64*t+8*n+o]=q(e,o,8,8*n)}return s}}function*G(t,n,o,r,e){const s=Math.ceil(n/8),i=Math.ceil(o/8),c=r>=30?.1+.09*(100-r):53/3e3*r*r-1.15*r+25,f=[0,1,2].map(t=>({h:1,v:1,stride:s,rows:i,quant:Int32Array.from(At,(n,o)=>Math.max(1,Math.round(16*c*(t?18:10)*(o?n:.25)))),coeffs:new Int16Array(s*i*64)})),l=F(t,n,o),a=(t,n)=>{for(let o=t;o<n;o++)for(let t=0;t<s;t++){const n=l(t,o),r=64*(o*s+t);for(let t=0;t<3;t++)for(let o=0;o<64;o++)f[t].coeffs[r+o]=Math.round(16*n[64*t+o]/f[t].quant[o])}};for(let t=0;t<i;t+=32)a(t,Math.min(i,t+32)),yield Math.min(i,t+32)/i;let u=null;for(let n=3;n<t.length;n+=4)if(255!==t[n]){u=t;break}return{width:n,height:o,components:f,quantScale:16,ycbcr:!0,orientation:1,alpha:u,colorSpace:e}}function j(n,o,r,c,f){const{quality:l,colorSpace:a}=function(t={},n=100){if(null===t||"object"!=typeof t)throw rt("JXL_INPUT","Options are an object: {quality, colorSpace}.");if(void 0!==t.quality&&(n=t.quality),"number"!=typeof n||!Number.isFinite(n)||n<1||n>100)throw rt("JXL_INPUT","Quality is a number from 1 to 100.");const o=void 0===t.colorSpace?"srgb":t.colorSpace;if("srgb"!==o&&"display-p3"!==o)throw rt("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(c,90),u=function(t={}){if(null===t||"object"!=typeof t)throw rt("JXL_INPUT","Options are an object.");const n=void 0===t.effort?1:t.effort;if(!Number.isInteger(n)||n<1||n>9)throw rt("JXL_INPUT","Effort is a whole number from 1 to 9.");return n}(c);return function(t,n,o,r){if(function(t,n,o=W){if(!Number.isInteger(t)||!Number.isInteger(n)||t<1||n<1)throw rt("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>o.edge||n>o.edge)throw rt("JXL_DIMENSIONS","A picture is at most "+o.edge+" pixels on a side.");if(t*n>o.pixels)throw rt("JXL_DIMENSIONS","A picture is at most "+o.pixels.toLocaleString("en-US")+" pixels.")}(n,o,r),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw rt("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==n*o*4)throw rt("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(n,o,r,$),function(t){const n=function*(){let o,r;for(;!(o=i(()=>t.next(n.hurry))).done;)yield r=o.value;return r<1&&(yield 1),n.bytes=(s((e=o.value).length),e);var e}();return n.bytes=null,n.hurry=!1,n}(function*(n,o,r,s,i,c,f){if(s>=100)return yield*function*(n,o,r,{shape:e=v(n,o,r),colorSpace:s,rct:i,pooled:c}={}){let f,l;const a=e.palette?[e,{...e,palette:null}]:[e];for(let e=0;e<a.length;e++)try{const l=yield*t(P(n,o,r,a[e],s,i,c),e,a.length);(!f||l.length<f.length)&&(f=l)}catch(t){if("JXL_SIZE"!==t.code)throw t;l=t}if(!f)throw l;return f}(n,o,r,{colorSpace:i});if(c<5)return yield*t(f(yield*t(G(n,o,r,s,i),0,2),c),1,2);const l=yield*t(G(n,o,r,s,i),0,4);let a=yield*t(f(l,4),1,4);if(yield.5)return a;try{const o=yield*t(function*(t,n,o=0){const{width:r,height:s,components:i,quantScale:c}=n,f=i[0].stride,l=i[0].rows,a=f*l,u=gt.length;if(t.byteLength+i.reduce((t,n)=>t+n.coeffs.byteLength,0)+Math.max(a*(10*u+2)+o,7*$.bytes)>Ut)return null;const h=new Float64Array(a*u),y=new Uint16Array(a*u),w=F(t,r,s),d=i.map(t=>t.quant),p=i.map(t=>t.coeffs),M=gt.map(t=>d.map(n=>Float64Array.from(n,n=>n*function(t){const n=e(t);let o=1+(1023&n)/1024,r=(n>>10)-15;for(;r<0;)o/=2,r++;for(;r>0;)o*=2,r--;return o}(4/(2040*c))*8*255/t))),A=new Int16Array(192),g=new Float64Array(3),b=new Int32Array(6),m=new Float64Array(6),U=new Float64Array(6);let I=0,x=0;const S=(t,n,o)=>{let r=0,e=0;const s=bt[o]*d[0][1]*d[0][1]/(c*c);for(let i=1;i<64;i++){if(!o){for(let r=0;r<3;r++){const s=p[r][64*n+i];g[r]=It(s,r)*M[o][r][i]-t[64*r+i],s&&(e+=2+2*(32-Math.clz32(Math.abs(s))))}r+=xt(g[0],g[1],g[2]);continue}for(let n=0;n<3;n++){const r=t[64*n+i],e=M[o][n][i],s=Math.floor(r/e);for(let t=0;t<2;t++){const o=s+t;b[2*n+t]=o,U[2*n+t]=o?2+2*(32-Math.clz32(Math.abs(o))):0,m[2*n+t]=o<-32768||o>32767?1/0:It(o,n)*e-r}}let c=0,f=1/0,l=0;for(let t=0;t<8;t++){const n=xt(m[1&t],m[2+(t>>1&1)],m[4+(t>>2)]),o=n+s*(U[1&t]+U[2+(t>>1&1)]+U[4+(t>>2)]);o<f&&(f=o,c=t,l=n)}if(f===1/0)return{error:1/0,rate:65535};r+=l;for(let t=0;t<3;t++){const n=b[2*t+(c>>t&1)];A[64*t+i]=n,n&&(e+=2+2*(32-Math.clz32(Math.abs(n))))}}return{error:r,rate:e}};for(let t=0;t<l;t++)for(let n=0;n<f;n++){const o=t*f+n,r=w(n,t);for(let t=0;t<u;t++){const n=S(r,o,t),e=o*u+t;h[e]=n.error,y[e]=n.rate,t||(I+=n.error,x+=n.rate)}if(((o+1)%1024==0||o+1===a)&&(yield(o+1)/(3*a)))return null}const E=new Uint8Array(a);let L=0;const J=function*(t,n){let o=0,r=0;for(let e=0;e<a;e++){const s=e*u;let i=0,c=h[s]+t*y[s];for(let n=1;n<u;n++){const o=h[s+n]+t*y[s+n];o<c&&(c=o,i=n)}if(o+=h[s+i],r+=y[s+i],n&&(E[e]=i),((e+1)%1024==0||e+1===a)&&(yield 1/3+(L+(e+1)/a)/147))return null}return L++,{error:o,rate:r}};let T=0,X=Math.max(1,I/Math.max(1,x));for(let t=0;t<24;t++){const t=yield*J(X,!1);if(!t)return null;if(t.error>I)break;X*=2}for(let t=0;t<24;t++){const t=(T+X)/2,n=yield*J(t,!1);if(!n)return null;n.error<=I?T=t:X=t}const N=yield*J(T,!0);if(!N||N.error>I||N.rate>=x||!E.some(t=>t))return null;const _=new Uint8Array(a);for(let t=0;t<l;t++)for(let n=0;n<f;n++){const o=t*f+n,r=E[o];if(_[o]=gt[r],r){S(w(n,t),o,r);for(let t=0;t<3;t++)for(let n=1;n<64;n++)p[t][64*o+n]=A[64*t+n]}if(((o+1)%1024==0||o+1===a)&&(yield 2/3+(o+1)/(3*a)))return null}return{...n,quantFieldBase:4,quantFields:_,reconstructionError:{baseline:I,candidate:N.error}}}(n,l,a.byteLength),2,4);o&&(a=yield*t(f(o,4,a),3,4))}catch(t){if((!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t}return a}(n,o,r,l,a,u,f))}function k(t,n){return b(t,n,Jt),Jt[0]}function z(t){let n=0;for(t>=2&&t<4294967296&&(n=31-Math.clz32(t),t*=Tt[n]);t>=1.4142135623730951;)t/=2,n++;for(;t<.7071067811865476;)t*=2,n--;const o=(t-1)/(t+1),r=o*o;let e=o,s=o;for(let t=3;t<30;t+=2)s+=(e*=r)/t;return n+2.885390081777927*s}function B(t){let n=0,o=0;for(const o of t)n+=o;for(const r of t)r&&(o+=r*z(n/r));return o}function R(t,{maxClusters:n=48,newClusterCost:o=320}={}){const r=[];for(let n=0;n<t.st;n++)t.it[n]>0&&r.push(n);r.sort((n,o)=>t.it[o]-t.it[n]);const e=[];for(const s of r){const r=t.ct([s],Et),i=B(r);let c=-1,f=1/0;for(let t=0;t<e.length;t++){const n=e[t],o=new Uint32Array(64);for(let t=0;t<64;t++)o[t]=n.W[t]+r[t];const s=B(o)-n.$-i;s<f&&(f=s,c=t)}if(c<0||e.length<n&&f>o)e.push({st:[s],W:r,$:i});else{const t=e[c];t.st.push(s);for(let n=0;n<64;n++)t.W[n]+=r[n];t.$=B(t.W)}}e.length||e.push({st:[],W:new Uint32Array(64),$:0});const s=new Uint8Array(t.st);let i=2*t.st;const c=e.map((n,o)=>{for(const t of n.st)s[t]=o;let r=St[0],e=1/0;for(const o of St){const s=t.ft(n.st,o);s<e&&(e=s,r=o)}const c=p(t.ct(n.st,r,128));return i+=e+3*c.u+40,{config:r,code:c}});return{L:s,J:c,write:(t,n,o)=>{const r=c[s[n]];U(t,r.code,r.config,o)},$:i}}function Z(t,n="JXL_JPEG"){return Object.assign(new Error("JPEG: "+t),{code:n})}function D(t,n,o){const r=[];if(n>0){const o=new Uint32Array(2048);let e=0;for(const n of t)o[Math.min(2047,Math.max(0,n+1024))]++,e++;let s=0,i=e/(n+1);for(let t=0;t<2048&&r.length<n;t++)s+=o[t],s>i&&(r.push(t-1025),i=e*(r.length+1)/(n+1))}const e=r.length+1,s=new Uint8Array(39*e);for(let t=0;t<e;t++)for(let n=0;n<Nt;n++)s[(0+n)*e+t]=t,s[(13+n)*e+t]=o?e:e+(t>>1),s[(26+n)*e+t]=o?e:e+(e-1>>1)+1+(t>>1);let i=0;for(const t of s)i=Math.max(i,t+1);return{thresholds:r,lt:e,map:s,ut:i,ht:t=>{let n=0;for(const o of r)t>o&&n++;return n},yt:(t,n)=>s[(t<2?1^t:2)*Nt*e+n],wt:(t,n)=>(Math.min(t,64)<8?Math.min(t,64):4+(Math.min(t,64)>>1))*i+n,dt:t=>37*i+458*t,st:495*i}}function Y(t,n,o){const r=n.map(()=>S(o)),e=r.map(()=>new Uint32Array(257));n.forEach((t,n)=>N(null,e[n],t.data,t.w,t.h,r[n])),T(t,{H:!1,K:[]});const s=L(t,E(r)),i=X(t,s,e,t=>r.indexOf(t));n.forEach((n,o)=>N(t,i[o+1].code,n.data,n.w,n.h,r[o]))}function*Q(t,o={}){const{width:i,height:c,components:a,alpha:h}=t,y=1===a.length,w=t.quantScale||1;let d=t.quantFieldBase||1;for(;d/(2040*w)<1/16384;)d*=2;const M=t.ycbcr||y,g=y?[0,0,0]:M?[1,0,2]:[0,1,2],b=g.map(t=>a[t]),S=o.orders?g.map(t=>o.orders[t].map(t=>Ct[t])):[Ct,Ct,Ct],E=t=>1===t?0:2===t?1:-1,L=b.map(t=>E(t.h)),J=b.map(t=>E(t.v));if(L.includes(-1)||J.includes(-1))throw Z("sampling factors other than one or two");const T=Math.max(...L),X=Math.max(...J),N=t=>T-L[t],_=t=>X-J[t];if(!M&&(T||X))throw Z("an RGB JPEG with subsampling");const v=Math.ceil(i/(8<<T))<<T,C=Math.ceil(c/(8<<X))<<X,O=Math.ceil(i/st),P=Math.ceil(c/st),q=O*P,F=Math.ceil(v/256),G=F*Math.ceil(C/256),j=1===q,k=(t,n,o)=>{const r=b[t];return y&&1!==t?-1:64*(o*r.stride+n)},z=t=>{let n=1024;for(;t%n;)n>>=1;return n},B=b.map(t=>M?1:t.quant[0]/z(t.quant[0])),Q=b.map(t=>M?0:1024/z(t.quant[0])),H=new Int32Array(v*C);for(let t=0;t<C;t++)for(let n=0;n<v;n++)H[t*v+n]=b[1].coeffs[k(1,n,t)]*B[1]+Q[1];const K=b[1].quant,V=(K[8]+K[16]+K[24]+K[32]+K[40])/w,W=v*C,$=W<256?0:Math.max(1,Math.min(7,r(W)-r(V)-7));let tt=D(H,$,y);const ot=new nt(256);if(f(ot,i,c,y?1:3,!!h,{orientation:t.orientation,colorSpace:t.colorSpace}),ot.write(1,0),ot.write(2,0),ot.write(1,0),ot.write(2,2),ot.write(8,111),ot.write(1,M?1:0),M)for(let t=0;t<3;t++)ot.write(2,0===L[t]&&0===J[t]?0:1===L[t]&&1===J[t]?1:1===L[t]?2:3);ot.write(2,0),h&&ot.write(2,0),l(ot,h);const rt=[0,1,2].map(()=>new Int32Array(1024)),et=(t,o)=>{const r=t%O*32,e=32*(t/O|0),s=Math.min(32,v-r),i=Math.min(32,C-e);for(let t=0;t<i;t++)for(let i=0;i<s;i++)for(const s of[1,0,2]){const c=N(s),f=_(s),l=i>>c,a=t>>f;if(l<<c!==i||a<<f!==t)continue;const u=k(s,(r>>c)+l,(e>>f)+a),h=b[s].coeffs;let y=0;if(u>=0)for(let t=1;t<64;t++)h[u+t]&&y++;const w=rt[s],d=0===l?0===a?32:w[32*(a-1)]:0===a?w[32*a+l-1]:w[32*(a-1)+l]+w[32*a+l-1]+1>>1;w[32*a+l]=y;const p=tt.yt(s,tt.ht(H[(e+t)*v+r+i]));o(tt.wt(d,p),y);const M=tt.dt(p);let A=y>4?0:1,g=y;for(let t=1;t<64&&g;t++){const r=h[u+S[s][t]];o(M+Ot(g,t,A),n(r)),A=r?1:0,g-=A}}},it=($>0?3:2)*q+G;let ct=0;const ft=function*(t){tt=t;const n=new Lt(t.st);for(let t=0;t<q;t++)et(t,(t,o)=>n.add(t,o)),yield++ct/it;return(o.coding||R)(n,o.clusters)};let lt=yield*ft(tt);if($>0){const t=tt,n=D(H,0,y),o=yield*ft(n);o.$<=lt.$?lt=o:tt=t}const at=Array.from({length:j?1:2+G+q},()=>null),ht=t=>at[j?0:t]||(at[j?0:t]=new nt(4096)),yt=new Uint32Array(at.length);let wt=0;const dt=t=>{t=j?0:t;const n=Math.ceil(at[t].V/8);wt+=n-yt[t],yt[t]=n,s(wt)},pt=ht(0);pt.write(1,0);const Mt=(t,n)=>{const o=t*st,r=n*st,e=Math.min(st,i-o),s=Math.min(st,c-r),f=new Int32Array(e*s);for(let t=0;t<s;t++)for(let n=0;n<e;n++)f[t*e+n]=h[4*((r+t)*i+o+n)+3];return{w:e,h:s,data:f}};for(let t=0;t<3;t++)pt.write(16,e(b[t].quant[0]/B[t]/(2040*w)*128));pt.write(2,3),pt.write(16,57343),pt.write(2,1),pt.write(5,0),pt.write(1,0),pt.write(4,0),pt.write(4,tt.thresholds.length);for(const t of tt.thresholds)pt.t([[4,0],[8,16],[16,272],[32,65808]],n(t));pt.write(4,0),pt.write(4,0),I(pt,tt.map),pt.write(1,0),pt.write(2,0),pt.write(16,0),pt.write(16,0),pt.write(8,128),pt.write(8,128),pt.write(1,0),h&&Y(pt,[j?Mt(0,0):{w:0,h:0,data:new Int32Array(0)}],ut),dt(0);for(let n=0;n<G;n++){const o=ht(1+n),e=n%F*256,s=256*(n/F|0),i=Math.min(256,v-e),c=Math.min(256,C-s);o.write(2,0),Y(o,[1,0,2].map(t=>{const n=i>>N(t),o=c>>_(t),r=new Int32Array(n*o),f=B[t],l=Q[t];for(let i=0;i<o;i++)for(let o=0;o<n;o++){const c=k(t,(e>>N(t))+o,(s>>_(t))+i);r[i*n+o]=c<0?0:b[t].coeffs[c]*f+l}return{w:n,h:o,data:r}}),ut);const f=i*c,l=r(f);l&&o.write(l,f-1);const a=i+7>>3,u=c+7>>3,h=new Int32Array(2*f).fill(d-1,f);if(t.quantFields)for(let n=0;n<c;n++)for(let o=0;o<i;o++)h[f+n*i+o]=t.quantFields[(s+n)*v+e+o]-1;Y(o,[{w:a,h:u,data:new Int32Array(a*u)},{w:a,h:u,data:new Int32Array(a*u)},{w:f,h:2,data:h},{w:i,h:c,data:new Int32Array(f)}],d>1?ut:0),dt(1+n),yield++ct/it}const At=ht(1+G);At.write(1,0),At.write(3,7),At.write(16,e(d/(2040*w))),Y(At,[0,1,2].map(t=>{const n=new Int32Array(64),o=b[t].quant;for(let t=0;t<8;t++)for(let r=0;r<8;r++)n[8*r+t]=o[8*t+r];return{w:8,h:8,data:n}}),ut);for(let t=1;t<17;t++)At.write(3,0);if(q>1&&At.write(r(q),0),o.orders){At.t([[0,95],[0,19],[0,0],[13,0]],1);const t=[];for(const n of g){const r=Array.from({length:64},(t,n)=>n),e=o.orders[n].map(t=>{const n=r.indexOf(t);return r.splice(n,1),n});let s=64;for(;s>1&&!e[s-1];)s--;t.push(s-1,...e.slice(1,s))}const n=A(0),r=new Uint32Array(64);for(const o of t)m(n,o,r);const e=p(r);x(At,{L:new Uint8Array(8),J:[{config:n,code:e}]});for(const o of t)U(At,e,n,o)}else At.write(2,2);lt.writeHistograms?lt.writeHistograms(At):x(At,{L:lt.L,J:lt.J}),dt(1+G);for(let t=0;t<q;t++){const n=ht(2+G+t);et(t,(t,o)=>lt.write(n,t,o)),lt.flush&<.flush(n),h&&!j&&Y(n,[Mt(t%O,Math.floor(t/O))],ut),dt(2+G+t),yield++ct/it}return u(ot,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(at))}function*H(t,n,o){if(n<3&&!o)return yield*Q(t);let r=o;try{const o=Q(t);let e,s;for(;!(e=o.next()).done;)if(s=yield e.value/2,s&&r&&e.value<1)return o.return(),r;if((!r||e.value.length<r.length)&&(r=e.value),s||n<3)return r;const i=n<4?1:3,c=Q(t,{clusters:{maxClusters:32,newClusterCost:160}});for(;!(e=c.next()).done;)if(s=yield.5+e.value/(2*i),s&&e.value<1)return c.return(),r;if(e.value.length<r.length&&(r=e.value),s||n<4)return r;const f=function*(t){const n=Xt.map(t=>(7&t)<<3|t>>3),o=t.map(()=>new Uint32Array(64)),r=t.reduce((t,n)=>t+n.coeffs.length,0);let e=0;for(let s=0;s<t.length;s++){const{coeffs:i}=t[s],c=o[s];for(let t=0;t<i.length;t+=65536){const o=Math.min(t+65536,i.length);for(let r=t;r<o;r+=64)for(let t=1;t<64;t++)i[r+n[t]]&&c[t]++;if(e+=o-t,yield e/r)return null}}return o.map(t=>[0,...Array.from({length:63},(t,n)=>n+1).sort((n,o)=>Math.floor(t[o]/8)-Math.floor(t[n]/8)||n-o)])}(t.components);for(;!(e=f.next()).done;)if(yield.5+(1+e.value)/6)return f.return(),r;const l=Q(t,{orders:e.value});for(;!(e=l.next()).done;)if(s=yield.5+(2+e.value)/6,s&&e.value<1)return l.return(),r;return e.value.length<r.length?e.value:r}catch(t){if(!r||(!(t instanceof RangeError)||t.code)&&"JXL_SIZE"!==t.code)throw t;return r}}function K(t,n,o,r){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(V(t,n,o,r))}function V(t,n,o,r){return j(t,n,o,r,H)}const W=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),$=Object.freeze({bytes:16777216,pixels:4e7,edge:16384}),tt=[1];for(let t=1;t<=32;t++)tt.push(2*tt[t-1]);class nt{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.Mt=0,this.pending=0}write(t,n){if(!(n>=0&&n<tt[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let o=this.Mt+n*(1<<this.pending),r=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const e=this.bytes;for(;r>=8;)e[this.at++]=255&o,o=Math.floor(o/256),r-=8;this.Mt=o,this.pending=r}t(t,n){for(let o=0;o<4;o++){const[r,e]=t[o];if(n>=e&&n-e<tt[r])return this.write(2,o),void(r&&this.write(r,n-e))}throw new Error("U32 value out of range: "+n)}o(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.Mt,this.Mt=0,this.pending=0)}get V(){return 8*this.at+this.pending}grow(t=0){const n=W.bytes+64;if(this.at+t+16>n)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const o=new Uint8Array(Math.min(n,Math.max(2*this.bytes.length,this.at+t+16)));o.set(this.bytes.subarray(0,this.at)),this.bytes=o}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let n=0;n<t.at;n++)this.write(8,t.bytes[n]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.Mt)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.Mt),n}}const ot=(t,n)=>"number"==typeof t?n(t):{...t,at:o=>n(t.at(o))},rt=(t,n)=>Object.assign(new Error(n),{code:t}),et={channel:null,weighted:null,fill:null},st=256,it=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],ct=[2,4,3,2,2,4],ft=[0,7,3,2,1,15],lt=[0,0,0],at=3,ut=5,ht=A(4),yt=Object.freeze({X:224,minLength:7,N:ht}),wt=A(0),dt=[A(0),A(4),A(4,1,1),A(3,0,1)],pt=(t,n,o,r)=>o?r?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(r?16777216*t[n+3]:0),Mt=Float64Array.of(.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.3535533905932738,.4903926402016152,.4157348061512726,.27778511650980114,.09754516100806417,-.0975451610080641,-.277785116509801,-.4157348061512727,-.4903926402016152,.46193976625564337,.19134171618254492,-.19134171618254486,-.46193976625564337,-.4619397662556434,-.19134171618254517,.191341716182545,.46193976625564326,.4157348061512726,-.0975451610080641,-.4903926402016152,-.2777851165098011,.2777851165098009,.4903926402016152,.09754516100806439,-.41573480615127256,.3535533905932738,-.35355339059327373,-.35355339059327384,.3535533905932737,.35355339059327384,-.35355339059327334,-.35355339059327356,.3535533905932733,.27778511650980114,-.4903926402016152,.09754516100806415,.4157348061512728,-.41573480615127256,-.09754516100806401,.4903926402016153,-.27778511650980076,.19134171618254492,-.4619397662556434,.46193976625564326,-.19134171618254495,-.19134171618254528,.46193976625564337,-.4619397662556432,.19134171618254478,.09754516100806417,-.2777851165098011,.4157348061512728,-.4903926402016153,.4903926402016152,-.4157348061512725,.27778511650980076,-.09754516100806429),At=Float64Array.from({length:64},(t,n)=>{const o=.26236426446749106*Math.max(0,5*Math.sqrt((7&n)*(7&n)+(n>>3)*(n>>3))/Math.sqrt(98)-1);let r=1,e=1;for(let t=1;t<30;t++)e+=r=r*o/t;return e}),gt=[4,4,4,4,3,2,6,8],bt=[0,.125,.25,.5,.25,.25,.25,.25],mt=[.9299455010825141,.945349926692846,.9500648966626563],Ut=10.5*$.pixels,It=(t,n)=>Math.abs(t)<2?t*mt[n]:t-.145/t,xt=(t,n,o)=>{const r=t+1.402*o,e=t-.344136286*n-.714136286*o,s=t+1.772*n;return r*r+e*e+s*s},St=[A(0),A(1),A(2),A(3),A(4),A(4,1,1),A(5,1,1),A(2,0,1),A(3,0,1)],Et=A(4,1,1);class Lt{constructor(t){this.st=t,this.small=new Uint32Array(64*t),this.At=Array.from({length:t},()=>null),this.it=new Float64Array(t)}add(t,n){if(this.it[t]++,n<64)return void this.small[64*t+n]++;const o=this.At[t]||(this.At[t]=new Map);o.set(n,(o.get(n)||0)+1)}ct(t,n,o=64){const r=new Uint32Array(o);for(const o of t){const t=64*o;for(let o=0;o<64;o++)this.small[t+o]&&(r[k(n,o)]+=this.small[t+o]);const e=this.At[o];if(e)for(const[t,o]of e)r[k(n,t)]+=o}return r}ft(t,n){let r=B(this.ct(t,n));for(const e of t){const t=64*e;for(let e=n.S;e<64;e++)this.small[t+e]&&(r+=this.small[t+e]*(o(e)-n.U-n.I));const s=this.At[e];if(s)for(const[t,e]of s)r+=e*(o(t)-n.U-n.I)}return r}}const Jt=[0,0,0],Tt=[1];for(let t=1;t<32;t++)Tt.push(Tt[t-1]/2);const Xt=[0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63],Nt=13,_t=[0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30],vt=[0,0,31,62,62,93,93,93,93,123,123,123,123,152,152,152,152,152,152,152,152,180,180,180,180,180,180,180,180,180,180,180,180,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206],Ct=Xt.map(t=>(7&t)<<3|t>>3),Ot=(t,n,o)=>2*(vt[t]+_t[n])+o;export{$ as LIMITS,K as encodePhoto,V as encodePhotoSteps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Rapier JXL 2.2.
|
|
1
|
+
/*! Rapier JXL 2.2.1 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
2
2
|
const t={channel:null,weighted:null,fill:null},n=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),o=[1];for(let t=1;t<=32;t++)o.push(2*o[t-1]);class e{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.t=0,this.pending=0}write(t,n){if(!(n>=0&&n<o[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let e=this.t+n*(1<<this.pending),r=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const i=this.bytes;for(;r>=8;)i[this.at++]=255&e,e=Math.floor(e/256),r-=8;this.t=e,this.pending=r}o(t,n){for(let e=0;e<4;e++){const[r,i]=t[e];if(n>=i&&n-i<o[r])return this.write(2,e),void(r&&this.write(r,n-i))}throw new Error("U32 value out of range: "+n)}i(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.t,this.t=0,this.pending=0)}get u(){return 8*this.at+this.pending}grow(t=0){const o=n.bytes+64;if(this.at+t+16>o)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const e=new Uint8Array(Math.min(o,Math.max(2*this.bytes.length,this.at+t+16)));e.set(this.bytes.subarray(0,this.at)),this.bytes=e}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let n=0;n<t.at;n++)this.write(8,t.bytes[n]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.t)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.t),n}}function*r(t,n,o){let e,r;for(;!(e=t.next(r)).done;)r=yield i(e.value,t=>(n+t)/o);return e.value}const i=(t,n)=>"number"==typeof t?n(t):{...t,at:o=>n(t.at(o))};function s(t){return t>=0?2*t:2*-t-1}function c(t){return 31-Math.clz32(t)}function f(t){return t<=1?0:32-Math.clz32(t-1)}const l=(t,n)=>Object.assign(new Error(n),{code:t});function a(t){if(t>n.bytes)throw l("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function u(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw l("JXL_MEMORY","Not enough memory for this picture.");throw t}}const h=256;function p(t,n){t.o([[9,1],[13,1],[18,1],[30,1]],n)}function y(t,n,o,e,r,{xyb:i=!1,orientation:s=1,colorSpace:c}={}){t.write(16,2815),t.write(1,0),p(t,o),t.write(3,0),p(t,n),t.write(1,0);const f=1!==s;t.write(1,f?1:0),f&&t.write(6,s-1),t.write(4,8),r?t.write(3,5):t.write(2,0),t.write(1,i?1:0),3===e&&"display-p3"===c?t.write(21,903568):3===e?t.write(1,1):t.write(15,14100),f&&t.write(1,1),t.write(2,0),t.write(1,1),t.i()}function w(t,{alpha:n,shift:o=1}){t.write(9,8),n&&t.write(2,0),t.write(2,o),function(t,n){t.write(n?7:5,0),t.write(11,1)}(t,n)}function d(t,n,o=256){const e=Math.ceil(t/o),r=Math.ceil(n/o);return{p:e,m:r,M:Math.ceil(t/(8*o)),A:Math.ceil(n/(8*o)),U:1===e&&1===r}}function*g(t,n,o,e){if(t.pooled){const n=yield t;return n?(n.results.forEach((t,n)=>e(n,t)),n.hurried):null}let r=!1;for(let e=0;e<n;e++)if(o(e),r=yield t.at(e),r&&t.stop(e))return null;return r}function m(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.i();for(const o of n)t.o([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.i()}(t,o);const e=t.finish(),r=e.length+o.reduce((t,n)=>t+n,0);a(r);const i=new Uint8Array(r);i.set(e);let s=e.length;for(const t of n)i.set(t,s),s+=t.length;return i}const b=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],M=[2,4,3,2,2,4],A=[0,7,3,2,1,15];function U(t,n){const o=new Uint8Array(t.length),e=[];for(let n=0;n<t.length;n++)t[n]>0&&e.push(n);if(!e.length)return o;if(1===e.length)return o[e[0]]=1,o;for(let r=1;;r*=2){const i=e.map(n=>({w:Math.max(t[n],r),S:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.S-n.S),s=[];let c=0,f=0;const l=()=>c<i.length&&(f>=s.length||i[c].w<=s[f].w)?i[c++]:s[f++];for(;i.length-c+(s.length-f)>1;){const t=l(),n=l();s.push({w:t.w+n.w,S:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.S>=0?(o[t.S]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function S(t,n,o,e,r,i){const s=[];for(;s.push(e&r),e>>=i;)e--;for(let e=s.length-1;e>=0;e--)t.push(o),n.push(s[e])}function I(t,n){let o=0;for(let e=0;e<n;e++)o=o<<1|1&t,t>>=1;return o}function x(t){const n=new Uint32Array(17),o=new Uint32Array(17),e=new Uint16Array(t.length);for(const o of t)n[o]++;n[0]=0;for(let t=1,e=0;t<=16;t++)e=e+n[t-1]<<1,o[t]=e;for(let n=0;n<t.length;n++)t[n]&&(e[n]=I(o[t[n]]++,t[n]));return e}function C(t){const n=[];for(let o=0;o<t.length;o++)t[o]>0&&n.push(o);const o=n.length,e=n[o-1]+1||1,r=o<=4?new Uint8Array(e):U(t,15).subarray(0,e);let i=0;if(o<=4){n.sort((n,o)=>t[o]-t[n]||n-o),i=4===o&&t[n[0]]>t[n[2]]+t[n[3]]?1:0;const e=o<2?[0]:2===o?[1,1]:3===o?[1,2,2]:i?[1,2,3,3]:[2,2,2,2];n.forEach((t,n)=>{r[t]=e[n]}),n.sort((t,n)=>r[t]-r[n]||t-n)}return{I:e,C:r,T:x(r),v:o&&o<=4?n:null,L:i}}function T(t,n){if(n.I<=1)return;if(n.v){const o=c(n.I-1)+1;t.write(2,1),t.write(2,n.v.length-1);for(const e of n.v)t.write(o,e);return void(4===n.v.length&&t.write(1,n.L))}const o=n.C,e=[],r=[];let i=o.length-1;for(;i>0&&!o[i];)i--;let s=8;for(let t=0;t<=i;){const n=o[t];let c=1;for(;t+c<=i&&o[t+c]===n;)c++;let f=c;if(n&&n!==s&&(e.push(n),r.push(0),f--,s=n),f<3)for(let t=0;t<f;t++)e.push(n),r.push(0);else S(e,r,n?16:17,f-3,n?3:7,n?2:3);t+=c}const f=new Uint32Array(18);for(const t of e)f[t]++;let l=0;for(const t of f)t&&l++;1===l&&(f[e[0]?0:1]=f[e[0]]);const a=U(f,5),u=x(a);let h=18;for(;h>0&&!a[b[h-1]];)h--;t.write(2,0);for(let n=0;n<h;n++){const o=a[b[n]];t.write(M[o],A[o])}for(let n=0;n<e.length;n++){const o=e[n];t.write(a[o],u[o]),16===o?t.write(2,r[n]):17===o&&t.write(3,r[n])}}function v(t,n=0,o=0){return{split:t,X:n,N:o,P:1<<t}}function E(t,n,o=15){t.write(f(o+1),n.split),n.split!==o&&(t.write(f(n.split+1),n.X),t.write(f(n.split-n.X+1),n.N))}function L(t,n,o){if(n<t.P)return o[0]=n,o[1]=0,void(o[2]=0);const e=c(n),r=n-(1<<e),i=e-t.X-t.N;o[0]=t.P+(e-t.split<<t.X+t.N|r>>e-t.X<<t.N|r&(1<<t.N)-1),o[1]=i,o[2]=n>>t.N&(1<<i)-1}function X(t,n,o,e=0){L(t,n,N),o[e+N[0]]++}const N=[0,0,0];function P(t,n,o,e,r=0){L(o,e,N);const i=r+N[0];t.write(n.C[i],n.T[i]),N[1]&&t.write(N[1],N[2])}function z(t,{J:n=null,_:o,q:e}){t.write(1,n?1:0),n&&(t.o([[0,224],[0,512],[0,4096],[15,8]],n.G),t.o([[0,3],[0,4],[2,5],[8,9]],n.minLength),E(t,n.O,8)),o.length>1&&function(t,n){let o=0;for(const t of n)o=Math.max(o,t);const e=o?f(o+1):0;if(e<=3){if(t.write(1,1),t.write(2,e),e)for(const o of n)t.write(e,o);return}t.write(1,0),t.write(1,0);const r=v(8),i=v(4),s=n.length>=64,c=new Uint32Array(s?257:o+1),l=[];for(let t=0;t<n.length;){let o=1;for(;s&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)l.push([n[t],o-1]),c[n[t]]++,X(i,o-1-7,c,224),t+=o;else{for(let e=0;e<o;e++)l.push([n[t],0]),c[n[t]]++;t+=o}}const a=C(c);if(!s){z(t,{_:new Uint8Array(1),q:[{config:r,code:a}]});for(const[n]of l)P(t,a,r,n);return}const u=new Uint32Array(1);u[0]=1,z(t,{J:{G:224,minLength:7,O:i},_:new Uint8Array([1,0]),q:[{config:v(0),code:C(u)},{config:r,code:a}]});for(const[n,o]of l)P(t,a,r,n),o&&P(t,a,i,o-7,224)}(t,o),t.write(1,1);for(const n of e)E(t,n.config,15);for(const n of e){const o=n.code.I-1;if(o){const n=c(o);t.write(1,1),t.write(4,n),t.write(n,o-(1<<n))}else t.write(1,0)}for(const n of e)T(t,n.code)}const J=3,_=5,q=v(4),G=Object.freeze({G:224,minLength:7,O:q}),O=v(0);function j(t,n=0,o=1){return{j:t,offset:n,k:o,context:-1}}function k(t,n){const o=(e,r)=>{if(e===r)return n?t[e].B:t[e];const i=e+r>>1;return function(t,n,o,e){return{R:t,Z:n,left:o,right:e}}(n,n?t[i].Y:i,o(i+1,r),o(e,i))};return o(0,t.length-1)}function B(t){return k(t,0)}function R(t,n){const o=[n],e=[],r=[];for(const t of o){if(t.left){e.push(t.R+1,s(t.Z)),o.push(t.left,t.right);continue}t.context=r.length,r.push(t);const n=1===t.k?0:31-Math.clz32(t.k&-t.k);e.push(0,t.j,s(t.offset),n,(t.k>>n)-1)}const i=new Uint32Array(64);for(const t of e)X(O,t,i);const c=C(i);z(t,{_:new Uint8Array(6),q:[{config:O,code:c}]});for(const n of e)P(t,c,O,n);return r}function Z(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.o(o,n.D),t.o([[0,6],[2,0],[4,2],[6,10]],n.F??6);else if("palette"===n.type)t.write(2,1),t.o(o,n.D),t.o([[0,1],[0,3],[0,4],[13,1]],n.H),t.o([[8,0],[10,256],[12,1280],[16,5376]],n.K),t.o([[0,0],[8,1],[10,257],[16,1281]],n.V??0),t.write(4,n.j??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const e=n.W??[];t.o([[0,0],[4,1],[6,9],[8,41]],e.length);for(const n of e)t.write(1,n.$?1:0),t.write(1,n.tt?1:0),t.o(o,n.D),t.o([[0,1],[0,2],[0,3],[4,4]],n.H)}}}function Y(t,{nt:n=!0,ot:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.o([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)Z(t,n)}function D(t,n,o,e=t=>t.context,r=()=>O){const i=new Uint8Array(n.length+1);for(const t of n)i[t.context]=e(t)+1;const s=new Uint32Array(2);s[1]=1;const c=[{config:O,code:C(s)}],f=Math.max(...i);for(let t=0;t<f;t++)c.push({config:r(t),code:C(o[t])});return z(t,{J:G,_:i,q:c}),c}function Q(n,o,e,r,i,c,f=!1){if(t.channel?.(n,o,e,r,i,c,f))return;const l=c.j,a=c.offset,u=c.k,h=c.config||O,p=q;let y=0;const w=(t,e=h,r=0)=>{n?P(n,o,e,t,r):f&&!r?o[t]++:X(e,t,o,f?o.length-33:r)},d=()=>{if(y){if(y>=8)w(0),w(y-7-1,p,224);else for(let t=0;t<y;t++)w(0);y=0}},g=(t,n)=>{const o=e[t];let r;1===u?r=o-n-a:(r=Math.round((o-n-a)/u),e[t]=n+a+r*u),0!==r?(d(),w(s(r))):y++};for(let t=0,n=0;t<i;t++)for(let o=0;o<r;o++,n++){let i;if(0===l)i=0;else{const s=o?e[n-1]:t?e[n-r]:0,c=t?e[n-r]:s;if(1===l)i=s;else if(2===l)i=c;else if(3===l)i=(s+c)/2|0;else{const f=s+c-(o&&t?e[n-r-1]:s);if(5===l){const t=s<c?s:c,n=s<c?c:s;i=f<t?t:f>n?n:f}else{if(4!==l)throw new Error("predictor "+l+" is not coded here");i=Math.abs(f-s)<Math.abs(f-c)?s:c}}}g(n,i)}d()}const F=[v(0),v(4),v(4,1,1),v(3,0,1)];function H(t){const n=t.length-33,o=[0,0,0];let r,i;for(const s of F){const f=new Uint32Array(257);let l=0;for(let e=0;e<n;e++)t[e]&&(L(s,e,o),f[o[0]]+=t[e],l+=t[e]*o[1]);for(let o=0;o<33;o++)f[224+o]=t[n+o],l+=t[n+o]*Math.max(0,o-12);const a=C(f),u=new e(128);E(u,s),T(u,a);let h=u.u+l+(1===a.I?1:5+c(a.I-1));for(let t=0;t<f.length;t++)f[t]&&(h+=f[t]*a.C[t]);const p={config:s,et:f,rt:h,extra:l};r||(r=p),(!i||h<i.rt)&&(i=p)}return[r,i]}const K=(t,n,o,e)=>o?e?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(e?16777216*t[n+3]:0);function V(t,n,o,{palette:e=!0}={}){const r=n*o;let i=!0,s=!0;for(let n=0,o=0;o<r&&(255===t[n+3]||(i=!1,s))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(s=!1,i));o++,n+=4);const c=s?1:3,f=!i,l=c+(f?1:0),a=n=>K(t,n,s,f),u=new Map;let h=null;for(let t=0,n=0;e&&n<r;n++,t+=4){const n=a(t);if(0!==n&&!u.has(n)&&(u.set(n,1),u.size>=2048))break}if(e&&u.size<2048){const t=[...u.keys()],n=(t,n)=>t>>>8*n&255,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===l?n(t,3):1);t.sort((t,n)=>o(t)-o(n)),h={colours:[0,...t],byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function W({channels:n,alpha:o,palette:e},r){const i=n-(o?1:0)==1,s=e&&new Map(e.map((t,n)=>[t,n]));return(c,f,l,a,u,h,p)=>{if(r&&!e&&n>=3)r.fill(c,f,l,a,u,h,p);else if(e||!t.fill?.(f,l,a,u,h,p,n,c))for(let t=0;t<p;t++){let r=4*((u+t)*l+a),p=t*h;for(let t=0;t<h;t++,r+=4,p++)if(e)c[0][p]=s.get(K(f,r,i,o));else if(n>=3){const t=f[r],o=f[r+1],e=f[r+2],i=t-e,s=e+(i>>1),l=o-s;c[0][p]=s+(l>>1),c[1][p]=i,c[2][p]=l,4===n&&(c[3][p]=f[r+3])}else c[0][p]=f[r],2===n&&(c[1][p]=f[r+3])}}}function $(t,n){const{leaves:o,picture:r,T:i}=t,s=W(t,n),c=r.map(()=>new Int16Array(65536));return(t,n,f,l,a,u,h)=>{if(s(c,t,n,f,l,a,u),!i)return void r.forEach((t,n)=>Q(null,h[t],c[n],a,u,o[t],!0));const p=h||new e(a*u*r.length+64);return h||Y(p,{nt:!0,ot:[]}),r.forEach((t,n)=>Q(p,i[t],c[n],a,u,o[t])),h?void 0:p.finish()}}function*tt(t,n,o,{shape:e=V(t,n,o),colorSpace:i,rct:s,pooled:c}={}){let f,l;const a=e.palette?[e,{...e,palette:null}]:[e];for(let e=0;e<a.length;e++)try{const l=yield*r(nt(t,n,o,a[e],i,s,c),e,a.length);(!f||l.length<f.length)&&(f=l)}catch(t){if("JXL_SIZE"!==t.code)throw t;l=t}if(!f)throw l;return f}function*nt(t,n,o,r,i,s,c){const{channels:f,alpha:l,palette:a}=r,u=d(n,o),p=u.p*u.m,b=a?2:f,M=Array.from({length:b},()=>j(_)),A=B(M),U={channels:f,alpha:l,palette:a&&a.colours,rct:s?.type,leaves:M,picture:a?[u.U?1:0]:M.map((t,n)=>n)},S=W(U,s),I=Array.from({length:f},()=>new Int16Array(1024)),x=t=>function(t,n,o,e){const r=e%t.p*h,i=(e/t.p|0)*h;return[r,i,Math.min(h,n-r),Math.min(h,o-i)]}(u,n,o,t);let v=null;if(a){const t=a.colours.length;v=new Int16Array(t*f),a.colours.forEach((n,o)=>{for(let e=0;e<f;e++)v[e*t+o]=a.byte(n,e)})}if(!a){const r=t=>{const n=C(t),o=new e(128);T(o,n);let r=o.u;for(let o=0;o<t.length;o++)t[o]&&(r+=t[o]*(n.C[o]+Math.max(0,o<224?o-1:o-236)));return r},i=Math.min(n,32),s=Math.min(o,32),c=[_,J].map(t=>({j:t,et:M.map(()=>new Uint32Array(257))}));for(const e of[0,.5,1]){S(I,t,n,Math.floor((n-i)*e),Math.floor((o-s)*e),i,s);for(const t of c)for(let n=0;n<f;n++)Q(null,t.et[n],I[n],i,s,j(t.j))}M.forEach((t,n)=>{const o=c.map(t=>r(t.et[n])),e=o[1]<o[0]?1:0;t.j=c[e].j})}const E=a?[{type:"palette",D:0,H:f,K:a.colours.length}]:f>=3&&0!==s?.type?[{type:"rct",D:0,F:s?.type??6}]:[];let L=M.map(()=>new Uint32Array(33+(a?4096:1024)));v&&Q(null,L[0],v,a.colours.length,f,M[0],!0);const X=$(U,s);yield*g({pooled:c,kind:"plan",setup:{...U,sizes:L.map(t=>t.length)},at:t=>(t+1)/(2*p),stop:()=>!1},p,o=>X(t,n,...x(o),L),(t,n)=>function(t,n){t.forEach((t,o)=>{const e=n[o];for(let n=0;n<t.length;n++)t[n]+=e[n]})}(L,n));const N=L.map(H),P=N.reduce((t,n)=>t+n[0].rt-n[1].rt,0)>27*(u.U?1:p+1)+8?1:0;M.forEach((t,n)=>{t.config=N[n][P].config}),L=N.map(t=>t[P].et);const z=new e(256);y(z,n,o,r.colour,r.alpha,{colorSpace:i}),w(z,{alpha:r.alpha});const q=new e(4096);q.write(1,1),q.write(1,1);const G=D(q,R(q,A),L,t=>M.indexOf(t),t=>M[t].config),O={...U,T:M.map((t,n)=>G[n+1]?.code)},k=$(O,s);Y(q,{nt:!0,ot:E}),v&&Q(q,O.T[0],v,a.colours.length,f,M[0]);const Z=[];if(u.U)k(t,n,0,0,n,o,q),yield 1,Z.push(q.finish());else{Z.push(q.finish());for(let t=0;t<u.M*u.A+1;t++)Z.push(new Uint8Array(0));const o=Z.length,e=(t,n)=>{Z[o+t]=n};yield*g({pooled:c,kind:"plan",setup:O,at:t=>(p+t+1)/(2*p),stop:()=>!1},p,o=>e(o,k(t,n,...x(o))),e)}return m(z,Z)}const ot=(t,n)=>t+n+(t>n?1:0)>>1;function et(t,n,o){const e=t>=n&&n>=o?1:t<=n&&n<=o?-1:0;if(!e)return 0;let r=(4*(t*=e)-3*(o*=e)-(n*=e)+6)/12|0;return r-(1&r)>2*(t-n)&&(r=2*(t-n)+1),r+(1&r)>2*(n-o)&&(r=2*(n-o)),e*r}function rt(t,n){const{w:o,h:e,data:r}=t,i=n?o:e,s=i+1>>1,c=i-s,f=n?s:o,l=n?e:s,a=n?c:o,u=n?e:c,h=new Int16Array(f*l),p=new Int16Array(a*u),y=n?1:o;for(let t=0;t<l;t++)for(let e=0;e<f;e++){const s=n?e:t,l=n?t*o+2*e:2*t*o+e;if(s===c){h[t*f+e]=r[l];continue}const u=r[l],w=r[l+y],d=ot(u,w),g=s+1<c?ot(r[l+2*y],r[l+3*y]):1&i?r[l+2*y]:d;h[t*f+e]=d,p[t*a+e]=u-w-et(s?r[l-y]:d,d,g)}const w=(o,e,r)=>({w:e,h:r,it:t.it+ +n,st:t.st+!n,data:o});return[w(h,f,l),w(p,a,u)]}function it(t){const n=[],o=t.length;let e=t[0].w,r=t[0].h;for(o>2&&t[1].w===e&&t[1].h===r&&(n.push({$:!0,tt:!1,D:1,H:2}),n.push({$:!1,tt:!1,D:1,H:2})),!(e>r)&&r>8&&(n.push({$:!1,tt:!0,D:0,H:o}),r=r+1>>1);e>8||r>8;)e>8&&(n.push({$:!0,tt:!0,D:0,H:o}),e=e+1>>1),r>8&&(n.push({$:!1,tt:!0,D:0,H:o}),r=r+1>>1);return n}const st=1024,ct=8192;function*ft(t,n,o,{quality:r=90,shape:i=V(t,n,o,{palette:!1}),colorSpace:s}={}){const c=function(t){return t>=100?0:t>=30?.1+.09*(100-t):53/3e3*t*t-1.15*t+25}(r);if(!(c>0))throw new Error("lossy encoding needs a quality below 100");const{colour:f,alpha:l,channels:a}=i,u=n*o,h=Array.from({length:a},()=>new Int16Array(u));for(let n=0,o=0;o<u;o++,n+=4){if(3===f){const e=t[n],r=t[n+1],i=t[n+2],s=e-i,c=i+(s>>1),f=r-c;h[0][o]=c+(f>>1),h[1][o]=s,h[2][o]=f}else h[0][o]=t[n];l&&(h[a-1][o]=t[n+3])}const p=h.map((t,e)=>({w:n,h:o,it:0,st:0,data:t,component:3===f?e:0===e?0:3})),g=1===n&&o>st&&3===f,b=g?it(p).filter(t=>!t.$):1!==n&&1!==o||3!==f?[]:it(p),M=function(t,n=it(t)){const o=t.map(t=>({...t,level:0,ct:!1}));for(const t of n){const n=t.D+t.H-1,e=t.tt?n+1:o.length;for(let r=t.D;r<=n;r++){const[n,i]=rt(o[r],t.$),s=o[r].level+1;o[r]={...n,level:s,ct:o[r].ct,component:o[r].component},o.splice(e+(r-t.D),0,{...i,level:s,ct:!0,component:o[r].component})}}return o}(p,b.length?b:void 0),A=t=>t.ct?0:_,U=t=>function(t,n,o,e){let r=Math.min(16,n+o);if(r>0&&r--,3===t)return 1;const i=.25*function(t){let n=1;for(let o=0;o<24;o++)n=(4*n+t/(n*n*n*n))/5;return t*n}(e),s=1<<r,c=1===t||2===t?.35*i*Math.max(.5,1024/s):.35*i*1.1*(163.84/s);return Math.max(1,Math.floor(c))}(t.component,t.it+(g&&t.component>0&&t.component<3?1:0),t.st,c),S=[...3===f?[{type:"rct",D:0,F:6}]:[],{type:"squeeze",W:b}],I=d(n,o,st),x=I.M*I.A,C=I.p*I.m;let T=0;for(;T<M.length&&M[T].w<=st&&M[T].h<=st;)T++;const v=(t,n,o,e)=>{const r=n>>t.it,i=o>>t.st;return{x:r,y:i,w:Math.min(t.w,r+(e>>t.it))-r,h:Math.min(t.h,i+(e>>t.st))-i}},E=[{index:0,Y:0,ft:[]}];for(let t=0;t<T;t++)E[0].ft.push({c:t,rect:{x:0,y:0,w:M[t].w,h:M[t].h}});if(!I.U){for(let t=0;t<x;t++){const n=t%I.M,o=t/I.M|0,e={index:1+t,Y:1+x+t,ft:[]};for(let t=T;t<M.length;t++){const r=M[t];if(Math.min(r.it,r.st)<3)continue;const i=v(r,n*ct,o*ct,ct);i.w>0&&i.h>0&&e.ft.push({c:t,rect:i})}E.push(e)}for(let t=0;t<C;t++){const n=t%I.p,o=t/I.p|0,e={index:2+x+t,Y:1+3*x+17+t,ft:[]};for(let t=T;t<M.length;t++){const r=M[t];if(Math.min(r.it,r.st)>2)continue;const i=v(r,n*st,o*st,st);i.w>0&&i.h>0&&e.ft.push({c:t,rect:i})}E.push(e)}}for(const t of E)for(const n of t.ft){const t=M[n.c];n.lt=j(A(t),0,U(t)),n.lt.channel=n.c}const L=E.filter(t=>t.ft.length),X=1===L.length?B(L[0].ft.map(t=>t.lt)):function(t){return k(t,1)}(L.map(t=>({Y:t.Y,B:B(t.ft.map(t=>t.lt))}))),N=new Int16Array(1048576),P=t=>{const n=M[t.c],o=t.rect;if(o.w===n.w&&o.h===n.h)return n.data;for(let t=0;t<o.h;t++)N.set(n.data.subarray((o.y+t)*n.w+o.x,(o.y+t)*n.w+o.x+o.w),t*o.w);return N},z=[...new Set(E.flatMap(t=>t.ft.map(t=>t.c)))].sort((t,n)=>t-n),J=new Map(z.map((t,n)=>[t,n])),q=z.map(()=>new Uint32Array(257)),G=1+2*E.length;let O=1;yield O/G;for(const t of E){for(const n of t.ft)Q(null,q[J.get(n.c)],P(n),n.rect.w,n.rect.h,n.lt);yield++O/G}const Z=new e(256);y(Z,n,o,f,l,{colorSpace:s}),w(Z,{alpha:l,shift:n>256||o>256?3:1});const F=Array.from({length:I.U?1:2+x+C},()=>null),H=F[0]=new e(65536);H.write(1,1),H.write(1,1);const K=D(H,R(H,X),q,t=>J.get(t.channel));Y(H,{nt:!0,ot:S});for(const t of E){let n=F[t.index];n||(n=F[t.index]=new e(4096),t.ft.length&&Y(n,{nt:!0,ot:[]}));for(const o of t.ft)Q(n,K[J.get(o.c)+1].code,P(o),o.rect.w,o.rect.h,o.lt);yield++O/G}return m(Z,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(F))}function lt(t,n,o,e){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(at(t,n,o,e))}function at(t,o,e,i){const{quality:s,colorSpace:c}=function(t={},n=100){if(null===t||"object"!=typeof t)throw l("JXL_INPUT","Options are an object: {quality, colorSpace}.");if(void 0!==t.quality&&(n=t.quality),"number"!=typeof n||!Number.isFinite(n)||n<1||n>100)throw l("JXL_INPUT","Quality is a number from 1 to 100.");const o=void 0===t.colorSpace?"srgb":t.colorSpace;if("srgb"!==o&&"display-p3"!==o)throw l("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(i);return function(t,o,e,r){if(function(t,o,e=n){if(!Number.isInteger(t)||!Number.isInteger(o)||t<1||o<1)throw l("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>e.edge||o>e.edge)throw l("JXL_DIMENSIONS","A picture is at most "+e.edge+" pixels on a side.");if(t*o>e.pixels)throw l("JXL_DIMENSIONS","A picture is at most "+e.pixels.toLocaleString("en-US")+" pixels.")}(o,e,r),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw l("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==o*e*4)throw l("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(t,o,e),function(t){const n=function*(){let o,e;for(;!(o=u(()=>t.next(n.hurry))).done;)yield e=o.value;return e<1&&(yield 1),n.bytes=function(t){return a(t.length),t}(o.value)}();return n.bytes=null,n.hurry=!1,n}(function*(t,n,o,e,i){const s=V(t,n,o);if(e>=100)return yield*tt(t,n,o,{shape:s,colorSpace:i});if(!s.palette)return yield*ft(t,n,o,{quality:e,shape:s,colorSpace:i});const c=yield*r(tt(t,n,o,{shape:s,colorSpace:i}),0,2);let f;try{f=yield*r(ft(t,n,o,{quality:e,shape:s,colorSpace:i}),1,2)}catch(t){if("JXL_SIZE"!==t.code&&(!(t instanceof RangeError)||t.code))throw t;f=c}return c.length<=f.length?c:f}(t,o,e,s,c))}export{n as LIMITS,lt as encode,at as encodeSteps};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "rapier-jxl",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"measured": "exact bytes of the staged files; gzip level 9; Brotli quality 11, text mode; added is a door bundled with the core less the core alone, or the door alone less the core where it covers the core (effort); every measured bundle loads as a module",
|
|
5
5
|
"node": "v22.22.2",
|
|
6
6
|
"terser": "5.51.2",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
{
|
|
52
52
|
"entry": ".",
|
|
53
53
|
"module": "index",
|
|
54
|
-
"file": "rapier-jxl.min.mjs",
|
|
54
|
+
"file": "dist/rapier-jxl.min.mjs",
|
|
55
55
|
"exports": [
|
|
56
56
|
"LIMITS",
|
|
57
57
|
"encode",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"bytes": 21326,
|
|
75
75
|
"gzip": 9271,
|
|
76
76
|
"brotli": 8233,
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "3a6707df3d9f45ad6c736a1bc8659aac47f09a7fbf92543df4ea75d242b6b7fe",
|
|
78
78
|
"compress": {
|
|
79
79
|
"passes": 2,
|
|
80
80
|
"inline": 1,
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
{
|
|
92
92
|
"entry": "./jpeg",
|
|
93
93
|
"module": "jpeg",
|
|
94
|
-
"file": "jpeg.min.mjs",
|
|
94
|
+
"file": "dist/jpeg.min.mjs",
|
|
95
95
|
"exports": [
|
|
96
96
|
"LIMITS",
|
|
97
97
|
"transcode",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"bytes": 32354,
|
|
117
117
|
"gzip": 13505,
|
|
118
118
|
"brotli": 11946,
|
|
119
|
-
"sha256": "
|
|
119
|
+
"sha256": "889a97a98a22bb79e8aecc94cc896c2f5cb2726619e7eed0a39b9349ae547854",
|
|
120
120
|
"compress": {
|
|
121
121
|
"passes": 2,
|
|
122
122
|
"inline": 1,
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
{
|
|
134
134
|
"entry": "./photo",
|
|
135
135
|
"module": "photo",
|
|
136
|
-
"file": "photo.min.mjs",
|
|
136
|
+
"file": "dist/photo.min.mjs",
|
|
137
137
|
"exports": [
|
|
138
138
|
"LIMITS",
|
|
139
139
|
"encodePhoto",
|
|
@@ -161,8 +161,8 @@
|
|
|
161
161
|
"alone": {
|
|
162
162
|
"bytes": 33011,
|
|
163
163
|
"gzip": 13616,
|
|
164
|
-
"brotli":
|
|
165
|
-
"sha256": "
|
|
164
|
+
"brotli": 12084,
|
|
165
|
+
"sha256": "d141bd23af55cbd78b6a4e13413451cd251ca7e8d8a9da7db5a64aa8ed5b3db3",
|
|
166
166
|
"compress": {
|
|
167
167
|
"passes": 2,
|
|
168
168
|
"hoist_funs": true,
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
{
|
|
181
181
|
"entry": "./jpeg-ans",
|
|
182
182
|
"module": "jpeg-ans",
|
|
183
|
-
"file": "jpeg-ans.min.mjs",
|
|
183
|
+
"file": "dist/jpeg-ans.min.mjs",
|
|
184
184
|
"exports": [
|
|
185
185
|
"LIMITS",
|
|
186
186
|
"transcode",
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
"alone": {
|
|
207
207
|
"bytes": 35491,
|
|
208
208
|
"gzip": 14608,
|
|
209
|
-
"brotli":
|
|
210
|
-
"sha256": "
|
|
209
|
+
"brotli": 12896,
|
|
210
|
+
"sha256": "74389c293cc6d07fa578b86ca8c3a98d185b861aae8d2de9ace8328312d50d39",
|
|
211
211
|
"compress": {
|
|
212
212
|
"passes": 2,
|
|
213
213
|
"inline": 1,
|
|
@@ -217,14 +217,14 @@
|
|
|
217
217
|
"added": {
|
|
218
218
|
"bytes": 24689,
|
|
219
219
|
"gzip": 9580,
|
|
220
|
-
"brotli":
|
|
220
|
+
"brotli": 8480
|
|
221
221
|
},
|
|
222
222
|
"provedByteCases": 13
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
"entry": "./photo-ans",
|
|
226
226
|
"module": "photo-ans",
|
|
227
|
-
"file": "photo-ans.min.mjs",
|
|
227
|
+
"file": "dist/photo-ans.min.mjs",
|
|
228
228
|
"exports": [
|
|
229
229
|
"LIMITS",
|
|
230
230
|
"encodePhoto",
|
|
@@ -254,8 +254,8 @@
|
|
|
254
254
|
"alone": {
|
|
255
255
|
"bytes": 35994,
|
|
256
256
|
"gzip": 14650,
|
|
257
|
-
"brotli":
|
|
258
|
-
"sha256": "
|
|
257
|
+
"brotli": 12983,
|
|
258
|
+
"sha256": "73f6dee8d0067f40924edc6701dc643065ccf770907d2c2f6ae966f9ba5a0d40",
|
|
259
259
|
"compress": {
|
|
260
260
|
"passes": 2,
|
|
261
261
|
"hoist_funs": true,
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
{
|
|
274
274
|
"entry": "./effort",
|
|
275
275
|
"module": "effort",
|
|
276
|
-
"file": "effort.min.mjs",
|
|
276
|
+
"file": "dist/effort.min.mjs",
|
|
277
277
|
"exports": [
|
|
278
278
|
"LIMITS",
|
|
279
279
|
"encode",
|
|
@@ -299,8 +299,8 @@
|
|
|
299
299
|
"alone": {
|
|
300
300
|
"bytes": 33584,
|
|
301
301
|
"gzip": 13793,
|
|
302
|
-
"brotli":
|
|
303
|
-
"sha256": "
|
|
302
|
+
"brotli": 12205,
|
|
303
|
+
"sha256": "105c5be10bd7a803e228a400c728126d08cbb7d236a793883a94ac4235682c19",
|
|
304
304
|
"compress": {
|
|
305
305
|
"passes": 2,
|
|
306
306
|
"inline": 1,
|
|
@@ -310,14 +310,14 @@
|
|
|
310
310
|
"added": {
|
|
311
311
|
"bytes": 12258,
|
|
312
312
|
"gzip": 4522,
|
|
313
|
-
"brotli":
|
|
313
|
+
"brotli": 3972
|
|
314
314
|
},
|
|
315
315
|
"provedByteCases": 98
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
318
|
"entry": "./wasm",
|
|
319
319
|
"module": "wasm",
|
|
320
|
-
"file": "wasm.min.mjs",
|
|
320
|
+
"file": "dist/wasm.min.mjs",
|
|
321
321
|
"exports": [
|
|
322
322
|
"LIMITS",
|
|
323
323
|
"configureKernels",
|
|
@@ -348,8 +348,8 @@
|
|
|
348
348
|
"alone": {
|
|
349
349
|
"bytes": 43535,
|
|
350
350
|
"gzip": 18533,
|
|
351
|
-
"brotli":
|
|
352
|
-
"sha256": "
|
|
351
|
+
"brotli": 16233,
|
|
352
|
+
"sha256": "7120e389303d6db47e30bac0c41b61e7a5130e7b6aac1d95a9c0bfce0a1580a5",
|
|
353
353
|
"compress": {
|
|
354
354
|
"passes": 2,
|
|
355
355
|
"hoist_funs": true,
|
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
"added": {
|
|
361
361
|
"bytes": 22209,
|
|
362
362
|
"gzip": 9262,
|
|
363
|
-
"brotli":
|
|
363
|
+
"brotli": 8000
|
|
364
364
|
},
|
|
365
365
|
"provedByteCases": 98
|
|
366
366
|
}
|
|
@@ -385,6 +385,6 @@
|
|
|
385
385
|
],
|
|
386
386
|
"bytes": 74625,
|
|
387
387
|
"gzip": 30285,
|
|
388
|
-
"brotli":
|
|
388
|
+
"brotli": 26416
|
|
389
389
|
}
|
|
390
390
|
}
|