rapier-jxl 1.1.21 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- /*! Rapier JXL 1.1.21 | 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
- function t(t){return t>=0?2*t:2*-t-1}function n(t){return 31-Math.clz32(t)}function o(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=Math.floor(Math.log2(t)),e=t/2**o-1;o<-14&&(e=t/2**-14,o=-15);let r=Math.round(1024*e);return 1024===r&&(r=0,o++),n|o+15<<10|r}function r(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 s=e.map(n=>({w:Math.max(t[n],r),t:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.t-n.t),i=[];let f=0,c=0;const a=()=>f<s.length&&(c>=i.length||s[f].w<=i[c].w)?s[f++]:i[c++];for(;s.length-f+(i.length-c)>1;){const t=a(),n=a();i.push({w:t.w+n.w,t:-1,l:t,r:n})}const l=[[a(),0]];let h=0;for(;l.length;){const[t,n]=l.pop();t.t>=0?(o[t.t]=n,n>h&&(h=n)):l.push([t.l,n+1],[t.r,n+1])}if(h<=n)return o}}function s(t,n,o,e,r,s){const i=[];for(;i.push(e&r),e>>=s;)e--;for(let e=i.length-1;e>=0;e--)t.push(o),n.push(i[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 f(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,s=o<=4?new Uint8Array(e):r(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)=>{s[t]=e[n]}),n.sort((t,n)=>s[t]-s[n]||t-n)}return{o:e,i:s,u:f(s),p:o&&o<=4?n:null,m:i}}function a(t,o){if(o.o<=1)return;if(o.p){const e=n(o.o-1)+1;t.write(2,1),t.write(2,o.p.length-1);for(const n of o.p)t.write(e,n);return void(4===o.p.length&&t.write(1,o.m))}const e=o.i,i=[],c=[];let a=e.length-1;for(;a>0&&!e[a];)a--;let l=8;for(let t=0;t<=a;){const n=e[t];let o=1;for(;t+o<=a&&e[t+o]===n;)o++;let r=o;if(n&&n!==l&&(i.push(n),c.push(0),r--,l=n),r<3)for(let t=0;t<r;t++)i.push(n),c.push(0);else s(i,c,n?16:17,r-3,n?3:7,n?2:3);t+=o}const h=new Uint32Array(18);for(const t of i)h[t]++;let u=0;for(const t of h)t&&u++;1===u&&(h[i[0]?0:1]=h[i[0]]);const w=r(h,5),d=f(w);let p=18;for(;p>0&&!w[ft[p-1]];)p--;t.write(2,0);for(let n=0;n<p;n++){const o=w[ft[n]];t.write(ct[o],at[o])}for(let n=0;n<i.length;n++){const o=i[n];t.write(w[o],d[o]),16===o?t.write(2,c[n]):17===o&&t.write(3,c[n])}}function l(t,n=0,o=0){return{split:t,M:n,A:o,U:1<<t}}function h(t,n,e=15){t.write(o(e+1),n.split),n.split!==e&&(t.write(o(n.split+1),n.M),t.write(o(n.split-n.M+1),n.A))}function u(t,o,e){if(o<t.U)return e[0]=o,e[1]=0,void(e[2]=0);const r=n(o),s=o-(1<<r),i=r-t.M-t.A;e[0]=t.U+(r-t.split<<t.M+t.A|s>>r-t.M<<t.A|s&(1<<t.A)-1),e[1]=i,e[2]=o>>t.A&(1<<i)-1}function w(t,n,o,e=0){u(t,n,lt),o[e+lt[0]]++}function d(t,n,o,e,r=0){u(o,e,lt);const s=r+lt[0];t.write(n.i[s],n.u[s]),lt[1]&&t.write(lt[1],lt[2])}function p(t,n){let e=0;for(const t of n)e=Math.max(e,t);const r=e?o(e+1):0;if(r<=3){if(t.write(1,1),t.write(2,r),r)for(const o of n)t.write(r,o);return}t.write(1,0),t.write(1,0);const s=l(8),i=l(4),f=n.length>=64,a=new Uint32Array(f?257:e+1),h=[];for(let t=0;t<n.length;){let o=1;for(;f&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)h.push([n[t],o-1]),a[n[t]]++,w(i,o-1-7,a,224),t+=o;else{for(let e=0;e<o;e++)h.push([n[t],0]),a[n[t]]++;t+=o}}const u=c(a);if(!f){y(t,{I:new Uint8Array(1),C:[{config:s,code:u}]});for(const[n]of h)d(t,u,s,n);return}const p=new Uint32Array(1);p[0]=1,y(t,{J:{S:224,minLength:7,L:i},I:new Uint8Array([1,0]),C:[{config:l(0),code:c(p)},{config:s,code:u}]});for(const[n,o]of h)d(t,u,s,n),o&&d(t,u,i,o-7,224)}function y(t,{J:o=null,I:e,C:r}){t.write(1,o?1:0),o&&(t.P([[0,224],[0,512],[0,4096],[15,8]],o.S),t.P([[0,3],[0,4],[2,5],[8,9]],o.minLength),h(t,o.L,8)),e.length>1&&p(t,e),t.write(1,1);for(const n of r)h(t,n.config,15);for(const o of r){const e=o.code.o-1;if(e){const o=n(e);t.write(1,1),t.write(4,o),t.write(o,e-(1<<o))}else t.write(1,0)}for(const n of r)a(t,n.code)}function m(t,n=0,o=1){return{G:t,offset:n,N:o,context:-1}}function b(t,n){const o=(e,r)=>{if(e===r)return n?t[e].k:t[e];const s=e+r>>1;return function(t,n,o,e){return{X:t,T:n,left:o,right:e}}(n,n?t[s].q:s,o(s+1,r),o(e,s))};return o(0,t.length-1)}function M(t){return b(t,0)}function g(n,o){const e=[o],r=[],s=[];for(const n of e){if(n.left){r.push(n.X+1,t(n.T)),e.push(n.left,n.right);continue}n.context=s.length,s.push(n);const o=1===n.N?0:31-Math.clz32(n.N&-n.N);r.push(0,n.G,t(n.offset),o,(n.N>>o)-1)}const i=new Uint32Array(64);for(const t of r)w(pt,t,i);const f=c(i);y(n,{I:new Uint8Array(6),C:[{config:pt,code:f}]});for(const t of r)d(n,f,pt,t);return s}function A(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.P(o,n._),t.P([[0,6],[2,0],[4,2],[6,10]],n.O??6);else if("palette"===n.type)t.write(2,1),t.P(o,n._),t.P([[0,1],[0,3],[0,4],[13,1]],n.D),t.P([[8,0],[10,256],[12,1280],[16,5376]],n.B),t.P([[0,0],[8,1],[10,257],[16,1281]],n.R??0),t.write(4,n.G??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const e=n.j??[];t.P([[0,0],[4,1],[6,9],[8,41]],e.length);for(const n of e)t.write(1,n.H?1:0),t.write(1,n.Z?1:0),t.P(o,n._),t.P([[0,1],[0,2],[0,3],[4,4]],n.D)}}}function U(t,{F:n=!0,Y:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.P([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)A(t,n)}function I(t,n,o,e=t=>t.context){const r=new Uint8Array(n.length+1);for(const t of n)r[t.context]=e(t)+1;const s=new Uint32Array(2);s[1]=1;const i=[{config:pt,code:c(s)}],f=Math.max(...r);for(let t=0;t<f;t++)i.push({config:pt,code:c(o[t])});return y(t,{J:dt,I:r,C:i}),i}function x(n,o,e,r,s,i){const f=i.G,c=i.offset,a=i.N,l=pt,h=wt;let u=0;const p=(t,e=l,r=0)=>{n?d(n,o,e,t,r):w(e,t,o,r)},y=()=>{if(u){if(u>=8)p(0),p(u-7-1,h,224);else for(let t=0;t<u;t++)p(0);u=0}},m=(n,o)=>{const r=e[n];let s;1===a?s=r-o-c:(s=Math.round((r-o-c)/a),e[n]=o+c+s*a),0!==s?(y(),p(t(s))):u++};for(let t=0,n=0;t<s;t++)for(let o=0;o<r;o++,n++){let s;if(0===f)s=0;else{const i=o?e[n-1]:t?e[n-r]:0,c=t?e[n-r]:i;if(1===f)s=i;else if(2===f)s=c;else if(3===f)s=(i+c)/2|0;else{const a=i+c-(o&&t?e[n-r-1]:i);if(5===f){const t=i<c?i:c,n=i<c?c:i;s=a<t?t:a>n?n:a}else{if(4!==f)throw new Error("predictor "+f+" is not coded here");s=Math.abs(a-i)<Math.abs(a-c)?i:c}}}m(n,s)}y()}function C(t,n){t.P([[9,1],[13,1],[18,1],[30,1]],n)}function v(t,n,o,e,r,{xyb:s=!1,orientation:i=1}={}){t.write(16,2815),t.write(1,0),C(t,o),t.write(3,0),C(t,n),t.write(1,0);const f=1!==i;t.write(1,f?1:0),f&&t.write(6,i-1),t.write(4,8),r?t.write(3,5):t.write(2,0),t.write(1,s?1:0),3===e?t.write(1,1):t.write(15,14100),f&&t.write(1,1),t.write(2,0),t.write(1,1),t.K()}function E(t,{alpha:n}){t.write(9,8),n&&t.write(2,0),t.write(2,1),J(t,n)}function J(t,n){t.write(n?7:5,0),t.write(11,1)}function S(t,n){const o=Math.ceil(t/mt),e=Math.ceil(n/mt);return{V:o,W:e,$:Math.ceil(t/bt),tt:Math.ceil(n/bt),nt:1===o&&1===e}}function L(t){return t.map(t=>t?t.finish():new Uint8Array(0))}function P(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.K();for(const o of n)t.P([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.K()}(t,o);const e=t.finish(),r=new Uint8Array(e.length+o.reduce((t,n)=>t+n,0));r.set(e);let s=e.length;for(const t of n)r.set(t,s),s+=t.length;return r}function G(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 N(t,n){const{w:o,h:e,data:r}=t,s=n?o:e,i=s+1>>1,f=s-i,c=n?i:o,a=n?e:i,l=n?f:o,h=n?e:f,u=new Int16Array(c*a),w=new Int16Array(l*h),d=n?1:o;for(let t=0;t<a;t++)for(let e=0;e<c;e++){const i=n?e:t,a=n?t*o+2*e:2*t*o+e;if(i===f){u[t*c+e]=r[a];continue}const h=r[a],p=r[a+d],y=Mt(h,p),m=i+1<f?Mt(r[a+2*d],r[a+3*d]):1&s?r[a+2*d]:y;u[t*c+e]=y,w[t*l+e]=h-p-G(i?r[a-d]:y,y,m)}const p=(o,e,r)=>({w:e,h:r,ot:t.ot+ +n,et:t.et+!n,data:o});return[p(u,c,a),p(w,l,h)]}function k(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({H:!0,Z:!1,_:1,D:2}),n.push({H:!1,Z:!1,_:1,D:2})),!(e>r)&&r>8&&(n.push({H:!1,Z:!0,_:0,D:o}),r=r+1>>1);e>8||r>8;)e>8&&(n.push({H:!0,Z:!0,_:0,D:o}),e=e+1>>1),r>8&&(n.push({H:!1,Z:!0,_:0,D:o}),r=r+1>>1);return n}function X(t,n,o,{palette:e=!0}={}){const r=n*o;let s=!0,i=!0;for(let n=0,o=0;o<r&&(255===t[n+3]||(s=!1,i))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(i=!1,s));o++,n+=4);const f=i?1:3,c=!s,a=f+(c?1:0),l=n=>i?c?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(c?16777216*t[n+3]:0),h=new Map;let u=null;for(let t=0,n=0;e&&n<r;n++,t+=4){const n=l(t);if(0!==n&&!h.has(n)&&(h.set(n,1),h.size>=2048))break}if(e&&h.size<2048){const t=[...h.keys()],n=(t,n)=>Math.floor(t/256**n)%256,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===a?n(t,3):1);t.sort((t,n)=>o(t)-o(n));const e=new Map([[0,0]]);t.forEach((t,n)=>e.set(t,n+1)),u={colours:[0,...t],index:e,key:l,byte:n}}return{colour:f,alpha:c,channels:a,palette:u}}function T(t,n,o,{shape:e=X(t,n,o)}={}){let r,s;for(const i of e.palette?[e,{...e,palette:null}]:[e])try{const e=q(t,n,o,i);(!r||e.length<r.length)&&(r=e)}catch(t){if("JXL_SIZE"!==t.code)throw t;s=t}if(!r)throw s;return r}function q(t,n,o,e){const{channels:r,palette:s}=e,i=S(n,o),f=s?2:r,l=Array.from({length:f},()=>m(ut)),h=M(l),u=Array.from({length:f},()=>new Int16Array(65536)),w=(o,e,i,f)=>{for(let c=0;c<f;c++){let f=4*((e+c)*n+o),a=c*i;for(let n=0;n<i;n++,f+=4,a++)if(s)u[0][a]=s.index.get(s.key(f));else if(r>=3){const n=t[f],o=t[f+1],e=t[f+2],s=n-e,i=e+(s>>1),c=o-i;u[0][a]=i+(c>>1),u[1][a]=s,u[2][a]=c,4===r&&(u[3][a]=t[f+3])}else u[0][a]=t[f],2===r&&(u[1][a]=t[f+3])}};let d=null;if(s){const t=s.colours.length;d=new Int16Array(t*r),s.colours.forEach((n,o)=>{for(let e=0;e<r;e++)d[e*t+o]=s.byte(n,e)})}const p=t=>l[s?i.nt?1:0:t],y=s?1:r,b=t=>{for(let e=0;e<i.W;e++)for(let r=0;r<i.V;r++){const s=r*mt,f=e*mt,c=Math.min(mt,n-s),a=Math.min(mt,o-f);w(s,f,c,a),t(e*i.V+r,c,a)}};if(!s){const t=t=>{const n=c(t),o=new it(128);a(o,n);let e=o.rt;for(let o=0;o<t.length;o++)t[o]&&(e+=t[o]*(n.i[o]+Math.max(0,o<224?o-1:o-236)));return e},e=Math.min(n,32),s=Math.min(o,32),i=[ut,ht].map(t=>({G:t,st:l.map(()=>new Uint32Array(yt))}));for(const t of[0,.5,1]){w(Math.floor((n-e)*t),Math.floor((o-s)*t),e,s);for(const t of i)for(let n=0;n<r;n++)x(null,t.st[n],u[n],e,s,m(t.G))}l.forEach((n,o)=>{const e=i.map(n=>t(n.st[o])),r=e[1]<e[0]?1:0;n.G=i[r].G})}const A=s?[{type:"palette",_:0,D:r,B:s.colours.length}]:r>=3?[{type:"rct",_:0,O:6}]:[],C=l.map(()=>new Uint32Array(yt)),J=t=>C[l.indexOf(t)];d&&x(null,J(l[0]),d,s.colours.length,r,l[0]),b((t,n,o)=>{for(let t=0;t<y;t++)x(null,J(p(t)),u[t],n,o,p(t))});const L=new it(256);v(L,n,o,e.colour,e.alpha),E(L,{alpha:e.alpha});const G=new it(4096);G.write(1,1),G.write(1,1);const N=g(G,h),k=I(G,N,C,t=>l.indexOf(t)),X=t=>k[l.indexOf(t)+1].code;U(G,{F:!0,Y:A}),d&&x(G,X(l[0]),d,s.colours.length,r,l[0]);const T=[];if(i.nt)b((t,n,o)=>{for(let t=0;t<y;t++)x(G,X(p(t)),u[t],n,o,p(t))}),T.push(G.finish());else{T.push(G.finish());for(let t=0;t<i.$*i.tt+1;t++)T.push(new Uint8Array(0));b((t,n,o)=>{const e=new it(n*o*y+64);U(e,{F:!0,Y:[]});for(let t=0;t<y;t++)x(e,X(p(t)),u[t],n,o,p(t));T.push(e.finish())})}return P(L,T)}function _(t,n,o,{quality:e=90,shape:r=X(t,n,o,{palette:!1})}={}){const s=function(t){return t>=100?0:t>=30?.1+.09*(100-t):53/3e3*t*t-1.15*t+25}(e);if(!(s>0))throw new Error("lossy encoding needs a quality below 100");const{colour:i,alpha:f,channels:c}=r,a=n*o,l=Array.from({length:c},()=>new Int16Array(a));for(let n=0,o=0;o<a;o++,n+=4){if(3===i){const e=t[n],r=t[n+1],s=t[n+2],i=e-s,f=s+(i>>1),c=r-f;l[0][o]=f+(c>>1),l[1][o]=i,l[2][o]=c}else l[0][o]=t[n];f&&(l[c-1][o]=t[n+3])}const h=l.map((t,e)=>({w:n,h:o,ot:0,et:0,data:t,component:3===i?e:0===e?0:3})),u=1===n&&o>mt&&3===i?k(h).filter(t=>!t.H):[],w=function(t,n=k(t)){const o=t.map(t=>({...t,level:0,it:!1}));for(const t of n){const n=t._+t.D-1,e=t.Z?n+1:o.length;for(let r=t._;r<=n;r++){const[n,s]=N(o[r],t.H),i=o[r].level+1;o[r]={...n,level:i,it:o[r].it,component:o[r].component},o.splice(e+(r-t._),0,{...s,level:i,it:!0,component:o[r].component})}}return o}(h,u.length?u:void 0),d=t=>t.it?0:ut,p=t=>function(t,n,o,e){let r=Math.min(16,n+o);if(r>0&&r--,3===t)return 1;const s=.25*e**1.2,i=2**r,f=1===t||2===t?.35*s*Math.max(.5,1024/i):.35*s*1.1*(163.84/i);return Math.max(1,Math.floor(f))}(t.component,t.ot+(u.length&&t.component>0&&t.component<3?1:0),t.et,s),y=[...3===i?[{type:"rct",_:0,O:6}]:[],{type:"squeeze",j:u}],A=S(n,o),C=A.$*A.tt,J=A.V*A.W;let G=0;for(;G<w.length&&w[G].w<=mt&&w[G].h<=mt;)G++;const T=(t,n,o,e)=>{const r=n>>t.ot,s=o>>t.et;return{x:r,y:s,w:Math.min(t.w,r+(e>>t.ot))-r,h:Math.min(t.h,s+(e>>t.et))-s}},q=[{index:0,q:0,ft:[]}];for(let t=0;t<G;t++)q[0].ft.push({c:t,rect:{x:0,y:0,w:w[t].w,h:w[t].h}});if(!A.nt){for(let t=0;t<C;t++){const n=t%A.$,o=t/A.$|0,e={index:1+t,q:1+C+t,ft:[]};for(let t=G;t<w.length;t++){const r=w[t];if(Math.min(r.ot,r.et)<3)continue;const s=T(r,n*bt,o*bt,bt);s.w>0&&s.h>0&&e.ft.push({c:t,rect:s})}q.push(e)}for(let t=0;t<J;t++){const n=t%A.V,o=t/A.V|0,e={index:2+C+t,q:1+3*C+17+t,ft:[]};for(let t=G;t<w.length;t++){const r=w[t];if(Math.min(r.ot,r.et)>2)continue;const s=T(r,n*mt,o*mt,mt);s.w>0&&s.h>0&&e.ft.push({c:t,rect:s})}q.push(e)}}for(const t of q)for(const n of t.ft){const t=w[n.c];n.ct=m(d(t),0,p(t)),n.ct.channel=n.c}const _=q.filter(t=>t.ft.length),O=1===_.length?M(_[0].ft.map(t=>t.ct)):function(t){return b(t,1)}(_.map(t=>({q:t.q,k:M(t.ft.map(t=>t.ct))}))),z=new Int16Array(65536),D=t=>{const n=w[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++)z.set(n.data.subarray((o.y+t)*n.w+o.x,(o.y+t)*n.w+o.x+o.w),t*o.w);return z},B=[...new Set(q.flatMap(t=>t.ft.map(t=>t.c)))].sort((t,n)=>t-n),R=new Map(B.map((t,n)=>[t,n])),j=B.map(()=>new Uint32Array(yt));for(const t of q)for(const n of t.ft)x(null,j[R.get(n.c)],D(n),n.rect.w,n.rect.h,n.ct);const H=new it(256);v(H,n,o,i,f),E(H,{alpha:f});const Z=Array.from({length:A.nt?1:2+C+J},()=>null),F=Z[0]=new it(65536);F.write(1,1),F.write(1,1);const Y=I(F,g(F,O),j,t=>R.get(t.channel));U(F,{F:!0,Y:y});for(const t of q){let n=Z[t.index];n||(n=Z[t.index]=new it(4096),t.ft.length&&U(n,{F:!0,Y:[]}));for(const o of t.ft)x(n,Y[R.get(o.c)+1].code,D(o),o.rect.w,o.rect.h,o.ct)}return P(H,L(Z))}function O(t,n="JXL_JPEG"){return Object.assign(new Error("JPEG: "+t),{code:n})}function z(t,n){const o=new Uint16Array(65536);let e=0,r=0;for(let s=1;s<=16;s++){for(let i=0;i<t[s-1];i++){const t=n[r++],i=e<<16-s,f=1<<16-s;if(i+f>=65536)throw O("bad Huffman table");o.fill(s<<8|t,i,i+f),e++}e<<=1}return o}function D(t){if(!(t.length>4)||255!==t[0]||216!==t[1])throw O("not a JPEG");const n=[],o=[[],[]],e=new Set,r={count:0,lt:[]};let s=null,i=0,f=-1,c=!1,a=1,l=2;const h=n=>t[n]<<8|t[n+1],u=(n,o)=>{for(let e=0;e<o.length;e++)if(t[n+e]!==o.charCodeAt(e))return!1;return!0};for(;;){if(l>=t.length){if(s&&s.scans)break;throw O("truncated")}if(255!==t[l])throw O("marker expected");for(;255===t[l];)l++;const w=t[l++];if(217===w)break;if(216===w)throw O("a second start");if(w>=208&&w<=215)throw O("a restart marker outside a scan");if(1===w)continue;if(l+2>t.length)throw O("truncated");const d=h(l),p=l+2,y=l+d;if(d<2||y>t.length)throw O("bad segment");if(l=y,219===w)for(let o=p;o<y;){const e=t[o]>>4,r=15&t[o];if(e>1||r>3||o+1+(e?128:64)>y)throw O("bad quantisation table");o++;const i=new Int32Array(64);for(let n=0;n<64;n++)if(i[gt[n]]=e?h(o):t[o],o+=e?2:1,!i[gt[n]])throw O("a zero quantisation step");if(s?.progressive&&s.components.some(t=>t.tq===r&&t.quant&&t.coverage.some(t=>0!==t)&&t.quant.some((t,n)=>t!==i[n])))throw O("a quantisation table changed between progressive scans");n[r]=i}else if(196===w)for(let n=p;n<y;){const r=t[n]>>4,s=15&t[n];if(r>1||s>3||n+17>y)throw O("bad Huffman table");n++;const i=t.subarray(n,n+16);let f=0;for(const t of i)f+=t;if(f>256||n+16+f>y)throw O("bad Huffman table");const c=t.subarray(n+16,n+16+f);o[r][s]=z(i,c),0===r&&(c.some(t=>t>15)?e.add(s):e.delete(s)),n+=16+f}else if(192===w||193===w||194===w){if(s)throw O("two frames");if(y-p<6)throw O("bad frame header");if(8!==t[p])throw O("only 8-bit samples");const n=h(p+1),o=h(p+3),e=t[p+5];if(!o||!n)throw O("a height left to a DNL marker");if(1!==e&&3!==e)throw O("only grey or three components");if(y-p<6+3*e)throw O("bad frame header");if(o>rt.edge||n>rt.edge)throw O("a picture past "+rt.edge+" pixels on a side","JXL_DIMENSIONS");if(o*n>rt.pixels)throw O("a picture past "+rt.pixels+" pixels","JXL_DIMENSIONS");const r=[];let i=0;for(let n=0,o=p+6;n<e;n++,o+=3){const n=t[o+1]>>4,e=15&t[o+1],s=t[o+2];if(n<1||n>4||e<1||e>4)throw O("bad sampling");if(s>3)throw O("bad quantisation table");if(r.some(n=>n.id===t[o]))throw O("two components with one id");i+=n*e,r.push({id:t[o],h:n,v:e,tq:s,pred:0,coverage:new Int8Array(64).fill(-1)})}if(i>10)throw O("bad sampling");const f=Math.max(...r.map(t=>t.h)),c=Math.max(...r.map(t=>t.v)),a=Math.ceil(o/(8*f)),l=Math.ceil(n/(8*c));for(const t of r)t.blocksW=Math.ceil(Math.ceil(o*t.h/f)/8),t.blocksH=Math.ceil(Math.ceil(n*t.v/c)/8),t.stride=a*t.h,t.rows=l*t.v,t.coeffs=new Int16Array(t.stride*t.rows*64);s={progressive:194===w,width:o,height:n,components:r,hmax:f,vmax:c,mcusX:a,mcusY:l,scans:0}}else{if(195===w||w>=197&&w<=199||w>=201&&w<=203||w>=205&&w<=207)throw O("lossless, hierarchical or arithmetic coding");if(221===w){if(d<4)throw O("bad segment");i=h(p)}else{if(220===w)throw O("a DNL marker");if(218===w){if(!s)throw O("a scan before the frame");const r=t[p],f=[];if(r<1||r>4||p+1+2*r+3>y)throw O("bad scan header");let c=p+1;for(let e=0;e<r;e++,c+=2){const e=s.components.find(n=>n.id===t[c]);if(!e)throw O("a scan of an unknown component");if(f.some(t=>t.component===e))throw O("a component twice in one scan");if(e.quant||(e.quant=n[e.tq]),!e.quant)throw O("a scan without its quantisation table");f.push({component:e,dc:o[0][t[c+1]>>4],ac:o[1][15&t[c+1]],dcSlot:t[c+1]>>4})}const a=t[c],h=t[c+1],u=t[c+2]>>4,w=15&t[c+2];if((!s.progressive||0===a&&0===u)&&f.some(t=>e.has(t.dcSlot)))throw O("bad Huffman table");l=R(t,y,s,f,a,h,u,w,i),s.scans++}else if(224===w)u(p,"JFIF")&&(c=!0);else if(225===w)1===a&&u(p,"Exif")&&(a=B(t,p+6,y));else if(226===w){if(d>=16&&u(p,"ICC_PROFILE\0")){const n=t[p+12],o=t[p+13];if(!n||!o||n>o||r.count&&r.count!==o||r.lt[n])throw O("a colour profile cut short");r.count=o,r.lt[n]=t.subarray(p+14,y)}}else 238===w&&d>=14&&u(p,"Adobe")&&(f=t[p+11])}}}if(!s||!s.scans)throw O("no picture");for(const t of s.components)for(let n=0;n<64;n++)if(0!==t.coverage[n])throw O(s.progressive?"a progressive JPEG whose scans do not finish every coefficient":"a component without its scan");if(r.count&&!function(t){const n=[];for(let o=1;o<=t.count;o++){if(!t.lt[o])throw O("a colour profile cut short");n.push(t.lt[o])}const o=n.reduce((t,n)=>t+n.length,0),e=new Uint8Array(o);for(let t=0,o=0;t<n.length;o+=n[t].length,t++)e.set(n[t],o);const r=t=>t+4<=o?(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0:0,s=t=>t+4<=o?String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]):"",i=r(128);if(o<132||132+12*i>o)return!1;for(let t=0;t<i;t++){const n=132+12*t;if("desc"!==s(n))continue;const i=r(n+4),f=r(n+8);if(i+f>o||f<16)return!1;let c="";if("desc"===s(i)){const t=Math.min(r(i+8),f-12);for(let n=0;n<t;n++)c+=String.fromCharCode(e[i+12+n])}else{if("mluc"!==s(i))return!1;{if(!r(i+8)||f<28)return!1;const t=r(i+20),n=i+r(i+24);if(n+t>o)return!1;for(let o=0;o+1<t;o+=2)c+=String.fromCharCode(e[n+o]<<8|e[n+o+1])}}return/sRGB|sGray|IEC ?61966/i.test(c)}return!1}(r))throw O("a colour profile other than sRGB (decode the picture and encode its pixels)");let w=!1;return 3!==s.components.length||c||(w=f>=0?0===f: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:!w,orientation:a}}function B(t,n,o){const e=77===t[n]&&77===t[n+1];if(!e&&(73!==t[n]||73!==t[n+1]))return 1;const r=n=>n+2>o?0:e?t[n]<<8|t[n+1]:t[n]|t[n+1]<<8;if(42!==r(n+2))return 1;const s=n+((f=n+4)+4>o?0:e?(t[f]<<24|t[f+1]<<16|t[f+2]<<8|t[f+3])>>>0:(t[f]|t[f+1]<<8|t[f+2]<<16|t[f+3]<<24)>>>0),i=r(s);var f;for(let t=0,n=s+2;t<i&&n+12<=o;t++,n+=12){if(274!==r(n))continue;const t=r(n+8);return t>=1&&t<=8?t:1}return 1}function R(t,n,o,e,r,s,i,f,c){!function(t,n,o,e,r,s){if(!t.progressive){if(0!==o||63!==e||0!==r||0!==s)throw O("a bad spectral selection");for(const t of n){if(t.component.coverage.some(t=>-1!==t))throw O("a component coded twice");t.component.coverage.fill(0)}return}if(s>13||r&&r!==s+1)throw O("a bad successive approximation");if(0===o){if(0!==e)throw O("a bad spectral selection");for(const{component:t}of n){if(t.coverage[0]!==(r||-1))throw O(r?"a refinement scan out of order":"a DC scan twice");t.coverage[0]=s}return}if(1!==n.length)throw O("an interleaved AC scan");if(e>63||o>e)throw O("a bad spectral selection");const{coverage:i}=n[0].component;if(-1===i[0])throw O("an AC scan before the DC scan");for(let t=o;t<=e;t++){if(i[t]!==(r||-1))throw O(r?"a refinement scan out of order":"a band coded twice");i[t]=s}}(o,e,r,s,i,f);let a=n,l=0,h=0,u=0,w=!1;const d=()=>{for(;h<=24;){let n=0;if(w||a>=t.length)w=!0,u+=8;else if(n=t[a],255===n){const o=t[a+1];if(0===o)a+=2;else{if(255===o){a++;continue}w=!0,n=0,u+=8}}else a++;l=(l<<8|n)>>>0,h+=8}},p=()=>O("a scan cut short"),y=t=>{if(!t)return 0;if(d(),t>h-u)throw p();const n=l>>>h-t&(1<<t)-1;return h-=t,n},m=(t,n)=>t<1<<n-1?t-(1<<n)+1:t,b=t=>{if(!t)throw O("a scan without its Huffman table");d();const n=t[l>>>h-16&65535];if(!n)throw O("bad Huffman code");if(n>>8>h-u)throw p();return h-=n>>8,255&n},M=()=>{const n=h-u;if(n>=8)throw O("bytes left over in a scan");if(I)throw O("an end-of-band run past its interval");if(n&&(l>>>u&(1<<n)-1)!=(1<<n)-1)throw O("bad scan padding");for(;a+1<t.length&&255===t[a]&&255===t[a+1];)a++},g=n=>{if(M(),255!==t[a]||t[a+1]!==208+(7&n))throw O("a restart marker missing or out of order");a+=2,l=0,h=0,u=0,w=!1;for(const t of e)t.component.pred=0;I=0},A=(t,n)=>{if(n>11)throw O("a DC value out of range");const o=n?m(y(n),n):0;if(t.component.pred+=o,t.component.pred>2047||t.component.pred<-2048)throw O("a DC value out of range");return t.component.pred},U=(t,n)=>{if(t>10)throw O("an AC value out of range");const o=m(y(t),t)*(1<<n);if(o>1023||o<-1023)throw O("an AC value out of range");return o};let I=0;const x=1===e.length,C=o.progressive,v=()=>O("coefficients past the "+(C?"band":"block")),E=(t,n,o)=>{if(I>0)I--;else for(let e=r||1;e<=s;){const r=b(t.ac),i=r>>4,c=15&r;if(c){if(e+=i,e>s)throw v();n[o+gt[e]]=U(c,f),e++}else{if(i<15){if(i&&!C)throw O("an end-of-band run in a sequential scan");I=(1<<i)-1+(i?y(i):0);break}if(e+=16,e>s+1)throw v()}}},J=C?0===r?0===i?(t,n,o)=>{const e=A(t,b(t.dc))*(1<<f);if(e>2047||e<-2048)throw O("a DC value out of range");n[o]=e}:(t,n,o)=>{y(1)&&(n[o]|=1<<f)}:0===i?E:(t,n,o)=>{const e=1<<f,i=-1<<f;let c=r;if(I<=0)for(;c<=s;c++){const r=b(t.ac);let f=r>>4,a=0;const l=15&r;if(l){if(1!==l)throw O("a bad refinement code");a=y(1)?e:i}else if(15!==f){I=1<<f,f&&(I+=y(f));break}for(;c<=s;c++){const t=o+gt[c];if(0!==n[t])y(1)&&0===(n[t]&e)&&(n[t]+=n[t]>=0?e:i);else if(--f<0)break}if(f>=0||a&&c>s)throw O("coefficients past the band");a&&(n[o+gt[c]]=a)}if(I>0){for(;c<=s;c++){const t=o+gt[c];0!==n[t]&&y(1)&&0===(n[t]&e)&&(n[t]+=n[t]>=0?e:i)}I--}}:(t,n,o)=>{n[o]=A(t,b(t.dc)),E(t,n,o)};for(const t of e)t.component.pred=0;const S=e[0].component,L=x?S.blocksW*S.blocksH:o.mcusX*o.mcusY;for(let t=0;t<L;t++)if(c&&t>0&&t%c===0&&g(t/c-1),x){const n=t/S.blocksW|0,o=t-n*S.blocksW;J(e[0],S.coeffs,64*(n*S.stride+o))}else{const n=t/o.mcusX|0,r=t-n*o.mcusX;for(const t of e){const o=t.component;for(let e=0;e<o.v;e++)for(let s=0;s<o.h;s++)J(t,o.coeffs,64*((n*o.v+e)*o.stride+r*o.h+s))}}if(M(),255===t[a]&&t[a+1]>=208&&t[a+1]<=215){if(!c||L%c||t[a+1]!==208+(L/c-1&7))throw O("a restart marker out of order");for(a+=2;a+1<t.length&&255===t[a]&&255===t[a+1];)a++}if(a<t.length&&!(255===t[a]&&a+1<t.length&&0!==t[a+1]&&255!==t[a+1]))throw O("bytes left over after a scan");return a}function j(t,n){return u(t,n,xt),xt[0]}function H(t){let n=0,o=0;for(const o of t)n+=o;for(const e of t)e&&(o+=e*Math.log2(n/e));return o}function Z(t,n,o){const e=[];if(n>0){const o=new Uint32Array(2048);let r=0;for(const n of t)o[Math.min(2047,Math.max(0,n+1024))]++,r++;let s=0,i=r/(n+1);for(let t=0;t<2048&&e.length<n;t++)s+=o[t],s>i&&(e.push(t-1025),i=r*(e.length+1)/(n+1))}const r=e.length+1,s=new Uint8Array(39*r);for(let t=0;t<r;t++)for(let n=0;n<Ct;n++)s[(0+n)*r+t]=t,s[(13+n)*r+t]=o?r:r+(t>>1),s[(26+n)*r+t]=o?r:r+(r-1>>1)+1+(t>>1);let i=0;for(const t of s)i=Math.max(i,t+1);return{thresholds:e,ht:r,map:s,ut:i,wt:t=>{let n=0;for(const o of e)t>o&&n++;return n},dt:(t,n)=>s[(t<2?1^t:2)*Ct*r+n],yt:(t,n)=>(Math.min(t,64)<8?Math.min(t,64):4+(Math.min(t,64)>>1))*i+n,bt:t=>37*i+458*t,Mt:495*i}}function F(t,n,o){const e=n.map(()=>m(o)),r=e.map(()=>new Uint32Array(yt));n.forEach((t,n)=>x(null,r[n],t.data,t.w,t.h,e[n])),U(t,{F:!1,Y:[]});const s=g(t,M(e)),i=I(t,s,r,t=>e.indexOf(t));n.forEach((n,o)=>x(t,i[o+1].code,n.data,n.w,n.h,e[o]))}function Y(n,r=D(n)){return function(n){const{width:r,height:s,components:i,alpha:f}=n,a=1===i.length,l=n.quantScale||1,h=n.ycbcr||a,u=(a?[0,0,0]:h?[1,0,2]:[0,1,2]).map(t=>i[t]),w=t=>1===t?0:2===t?1:-1,m=u.map(t=>w(t.h)),b=u.map(t=>w(t.v));if(m.includes(-1)||b.includes(-1))throw O("sampling factors other than one or two");const M=Math.max(...m),g=Math.max(...b),A=t=>M-m[t],U=t=>g-b[t];if(!h&&(M||g))throw O("an RGB JPEG with subsampling");const I=Math.ceil(r/(8<<M))<<M,x=Math.ceil(s/(8<<g))<<g,C=Math.ceil(r/mt),E=Math.ceil(s/mt),S=C*E,G=Math.ceil(I/256),N=G*Math.ceil(x/256),k=1===S,X=(t,n,o)=>{const e=u[t];return a&&1!==t?-1:64*(o*e.stride+n)},T=t=>{let n=1024;for(;t%n;)n>>=1;return n},q=u.map(t=>h?1:t.quant[0]/T(t.quant[0])),_=u.map(t=>h?0:1024/T(t.quant[0])),z=new Int32Array(I*x);for(let t=0;t<x;t++)for(let n=0;n<I;n++)z[t*I+n]=u[1].coeffs[X(1,n,t)]*q[1]+_[1];const D=u[1].quant,B=(D[8]+D[16]+D[24]+D[32]+D[40])/l,R=I*x,j=R<256?0:Math.max(1,Math.min(7,o(R)-o(B)-7));let Y=Z(z,j,a);const Q=new it(256);if(v(Q,r,s,a?1:3,!!f,{orientation:n.orientation}),Q.write(1,0),Q.write(2,0),Q.write(1,0),Q.write(2,2),Q.write(8,111),Q.write(1,h?1:0),h)for(let t=0;t<3;t++)Q.write(2,0===m[t]&&0===b[t]?0:1===m[t]&&1===b[t]?1:1===m[t]?2:3);Q.write(2,0),f&&Q.write(2,0),J(Q,f);const K=[0,1,2].map(()=>new Int32Array(1024)),V=(n,o)=>{const e=n%C*32,r=32*(n/C|0),s=Math.min(32,I-e),i=Math.min(32,x-r);for(let n=0;n<i;n++)for(let i=0;i<s;i++)for(const s of[1,0,2]){const f=A(s),c=U(s),a=i>>f,l=n>>c;if(a<<f!==i||l<<c!==n)continue;const h=X(s,(e>>f)+a,(r>>c)+l),w=u[s].coeffs;let d=0;if(h>=0)for(let t=1;t<64;t++)w[h+t]&&d++;const p=K[s],y=0===a?0===l?32:p[32*(l-1)]:0===l?p[32*l+a-1]:p[32*(l-1)+a]+p[32*l+a-1]+1>>1;p[32*l+a]=d;const m=Y.dt(s,Y.wt(z[(r+n)*I+e+i]));o(Y.yt(y,m),d);const b=Y.bt(m);let M=d>4?0:1,g=d;for(let n=1;n<64&&g;n++){const e=w[h+Jt[n]];o(b+St(g,n,M),t(e)),M=e?1:0,g-=M}}},W=t=>{Y=t;const n=new It(t.Mt);for(let t=0;t<S;t++)V(t,(t,o)=>n.add(t,o));return function(t,{maxClusters:n=48,newClusterCost:o=320}={}){const e=[];for(let n=0;n<t.Mt;n++)t.gt[n]>0&&e.push(n);e.sort((n,o)=>t.gt[o]-t.gt[n]);const r=[];for(const s of e){const e=t.At([s],Ut),i=H(e);let f=-1,c=1/0;for(let t=0;t<r.length;t++){const n=r[t],o=new Uint32Array(64);for(let t=0;t<64;t++)o[t]=n.st[t]+e[t];const s=H(o)-n.Ut-i;s<c&&(c=s,f=t)}if(f<0||r.length<n&&c>o)r.push({Mt:[s],st:e,Ut:i});else{const t=r[f];t.Mt.push(s);for(let n=0;n<64;n++)t.st[n]+=e[n];t.Ut=H(t.st)}}r.length||r.push({Mt:[],st:new Uint32Array(64),Ut:0});const s=new Uint8Array(t.Mt);let i=2*t.Mt;const f=r.map((n,o)=>{for(const t of n.Mt)s[t]=o;let e=At[0],r=1/0;for(const o of At){const s=t.It(n.Mt,o);s<r&&(r=s,e=o)}const f=c(t.At(n.Mt,e,128));return i+=r+3*f.o+40,{config:e,code:f}});return{I:s,C:f,write:(t,n,o)=>{const e=f[s[n]];d(t,e.code,e.config,o)},Ut:i}}(n)};let $=W(Y);if(j>0){const t=Y,n=W(Z(z,0,a));n.Ut<=$.Ut?$=n:Y=t}const tt=Array.from({length:k?1:2+N+S},()=>null),nt=t=>tt[k?0:t]||(tt[k?0:t]=new it(4096)),ot=nt(0);ot.write(1,0);const et=(t,n)=>{const o=t*mt,e=n*mt,i=Math.min(mt,r-o),c=Math.min(mt,s-e),a=new Int32Array(i*c);for(let t=0;t<c;t++)for(let n=0;n<i;n++)a[t*i+n]=f[4*((e+t)*r+o+n)+3];return{w:i,h:c,data:a}};for(let t=0;t<3;t++)ot.write(16,e(u[t].quant[0]/q[t]/(2040*l)*128));ot.write(2,3),ot.write(16,57343),ot.write(2,1),ot.write(5,0),ot.write(1,0),ot.write(4,0),ot.write(4,Y.thresholds.length);for(const n of Y.thresholds)ot.P([[4,0],[8,16],[16,272],[32,65808]],t(n));ot.write(4,0),ot.write(4,0),p(ot,Y.map),ot.write(1,0),ot.write(2,0),ot.write(16,0),ot.write(16,0),ot.write(8,128),ot.write(8,128),ot.write(1,0),f&&F(ot,[k?et(0,0):{w:0,h:0,data:new Int32Array(0)}],ut);for(let t=0;t<N;t++){const n=nt(1+t),e=t%G*256,r=256*(t/G|0),s=Math.min(256,I-e),i=Math.min(256,x-r);n.write(2,0),F(n,[1,0,2].map(t=>{const n=s>>A(t),o=i>>U(t),f=new Int32Array(n*o),c=q[t],a=_[t];for(let s=0;s<o;s++)for(let o=0;o<n;o++){const i=X(t,(e>>A(t))+o,(r>>U(t))+s);f[s*n+o]=i<0?0:u[t].coeffs[i]*c+a}return{w:n,h:o,data:f}}),ut);const f=s*i,c=o(f);c&&n.write(c,f-1);const a=s+7>>3,l=i+7>>3;F(n,[{w:a,h:l,data:new Int32Array(a*l)},{w:a,h:l,data:new Int32Array(a*l)},{w:f,h:2,data:new Int32Array(2*f)},{w:s,h:i,data:new Int32Array(f)}],0)}const rt=nt(1+N);rt.write(1,0),rt.write(3,7),rt.write(16,e(1/(2040*l))),F(rt,[0,1,2].map(t=>{const n=new Int32Array(64),o=u[t].quant;for(let t=0;t<8;t++)for(let e=0;e<8;e++)n[8*e+t]=o[8*t+e];return{w:8,h:8,data:n}}),ut);for(let t=1;t<17;t++)rt.write(3,0);S>1&&rt.write(o(S),0),rt.write(2,2),y(rt,{I:$.I,C:$.C});for(let t=0;t<S;t++){const n=nt(2+N+t);V(t,(t,o)=>$.write(n,t,o)),f&&!k&&F(n,[et(t%C,Math.floor(t/C))],ut)}return P(Q,L(tt))}(r)}function Q(t,n){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>rt.edge||n>rt.edge)throw Lt("JXL_DIMENSIONS","A picture is at most "+rt.edge+" pixels on a side.");if(t*n>rt.pixels)throw Lt("JXL_DIMENSIONS","A picture is at most "+rt.pixels.toLocaleString("en-US")+" pixels.")}function K(t,n,o){if(Q(n,o),!(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.")}function V(t){if("number"!=typeof t||!Number.isFinite(t)||t<1||t>100)throw Lt("JXL_INPUT","Quality is a number from 1 to 100.")}function W(t){if(t.length>rt.bytes)throw Lt("JXL_SIZE","The encoded picture exceeds 16 MiB.");return t}function $(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 tt(t,n,o){return K(t,n,o),$(()=>W(T(t,n,o,{shape:X(t,n,o)})))}function nt(t,n,o,e=90){return K(t,n,o),V(e),$(()=>{const r=X(t,n,o);if(e>=100)return W(T(t,n,o,{shape:r}));if(!r.palette)return W(_(t,n,o,{quality:e,shape:r}));const s=T(t,n,o,{shape:r});let i;try{i=_(t,n,o,{quality:e,shape:r})}catch(t){if(!(t instanceof RangeError)||t.code)throw t;i=s}return W(s.length<=i.length?s:i)})}function ot(t,n,o,e={}){if(null===e||"object"!=typeof e)throw Lt("JXL_INPUT","Options are an object: {quality}.");const r=void 0===e.quality?100:e.quality;return V(r),r>=100?tt(t,n,o):nt(t,n,o,r)}function et(t){if(!(t instanceof Uint8Array&&t.length))throw Lt("JXL_INPUT","A JPEG is a non-empty Uint8Array.");if(t.length>rt.bytes)throw Lt("JXL_SIZE","A JPEG is at most 16 MiB.");return $(()=>{const n=D(t);Q(n.width,n.height);const o=W(Y(t,n)),e=n.orientation>=5;return{bytes:o,width:e?n.height:n.width,height:e?n.width:n.height,orientation:n.orientation}})}const rt=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),st=Array.from({length:33},(t,n)=>2**n);class it{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.xt=0,this.pending=0}write(t,n){if(t>32||n<0||n>=(st[t]??2**t))throw new Error("bit write out of range: "+t+" bits, "+n);let o=this.xt+n*(1<<this.pending),e=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const r=this.bytes;for(;e>=8;)r[this.at++]=255&o,o=Math.floor(o/256),e-=8;this.xt=o,this.pending=e}P(t,n){for(let o=0;o<4;o++){const[e,r]=t[o];if(n>=r&&n-r<2**e)return this.write(2,o),void(e&&this.write(e,n-r))}throw new Error("U32 value out of range: "+n)}K(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.xt,this.xt=0,this.pending=0)}get rt(){return 8*this.at+this.pending}grow(t=0){const n=rt.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.xt)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.xt),n}}const ft=[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],at=[0,7,3,2,1,15],lt=[0,0,0],ht=3,ut=5,wt=l(4),dt=Object.freeze({S:224,minLength:7,L:wt}),pt=l(0),yt=257,mt=256,bt=2048,Mt=(t,n)=>t+n+(t>n?1:0)>>1,gt=[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],At=[l(0),l(1),l(2),l(3),l(4),l(4,1,1),l(5,1,1),l(2,0,1),l(3,0,1)],Ut=l(4,1,1);class It{constructor(t){this.Mt=t,this.small=new Uint32Array(64*t),this.Ct=Array.from({length:t},()=>null),this.gt=new Float64Array(t)}add(t,n){if(this.gt[t]++,n<64)return void this.small[64*t+n]++;const o=this.Ct[t]||(this.Ct[t]=new Map);o.set(n,(o.get(n)||0)+1)}At(t,n,o=64){const e=new Uint32Array(o);for(const o of t){const t=64*o;for(let o=0;o<64;o++)this.small[t+o]&&(e[j(n,o)]+=this.small[t+o]);const r=this.Ct[o];if(r)for(const[t,o]of r)e[j(n,t)]+=o}return e}It(t,o){let e=H(this.At(t,o));for(const r of t){const t=64*r;for(let r=o.U;r<64;r++)this.small[t+r]&&(e+=this.small[t+r]*(n(r)-o.M-o.A));const s=this.Ct[r];if(s)for(const[t,r]of s)e+=r*(n(t)-o.M-o.A)}return e}}const xt=[0,0,0],Ct=13,vt=[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],Et=[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=gt.map(t=>(7&t)<<3|t>>3),St=(t,n,o)=>2*(Et[t]+vt[n])+o,Lt=(t,n)=>Object.assign(new Error(n),{code:t});export{ot as encode,tt as encodeLosslessRGBA,nt as encodeLossyRGBA,et as transcode,rt as LIMITS,T as encodeLossless,_ as encodeLossy,Y as transcodeJPEG,D as parseJPEG,X as inspectPixels};
1
+ /*! Rapier JXL 2.1.0 | 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
+ function*t(t,n,o){let e,r;for(;!(e=t.next(r)).done;)r=yield(n+e.value)/o;return e.value}function n(t){return t>=0?2*t:2*-t-1}function o(t){return 31-Math.clz32(t)}function e(t){return t<=1?0:32-Math.clz32(t-1)}function r(t){if(t>j.bytes)throw k("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function i(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw k("JXL_MEMORY","Not enough memory for this picture.");throw t}}function s(t,n){t.t([[9,1],[13,1],[18,1],[30,1]],n)}function c(t,n,o,e,r,{xyb:i=!1,orientation:c=1,colorSpace:f}={}){t.write(16,2815),t.write(1,0),s(t,o),t.write(3,0),s(t,n),t.write(1,0);const l=1!==c;t.write(1,l?1:0),l&&t.write(6,c-1),t.write(4,8),r?t.write(3,5):t.write(2,0),t.write(1,i?1:0),3===e&&"display-p3"===f?t.write(21,903568):3===e?t.write(1,1):t.write(15,14100),l&&t.write(1,1),t.write(2,0),t.write(1,1),t.o()}function f(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 l(t,n,o=256){const e=Math.ceil(t/o),r=Math.ceil(n/o);return{i:e,u:r,p:Math.ceil(t/(8*o)),m:Math.ceil(n/(8*o)),M:1===e&&1===r}}function a(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 e=t.finish(),i=e.length+o.reduce((t,n)=>t+n,0);r(i);const s=new Uint8Array(i);s.set(e);let c=e.length;for(const t of n)s.set(t,c),c+=t.length;return s}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),A:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.A-n.A),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,A:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.A>=0?(o[t.A]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function h(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 p(t,n){let o=0;for(let e=0;e<n;e++)o=o<<1|1&t,t>>=1;return o}function y(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]=p(o[t[n]]++,t[n]));return e}function w(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{U:e,S:r,I:y(r),C:o&&o<=4?n:null,T:i}}function d(t,n){if(n.U<=1)return;if(n.C){const e=o(n.U-1)+1;t.write(2,1),t.write(2,n.C.length-1);for(const o of n.C)t.write(e,o);return void(4===n.C.length&&t.write(1,n.T))}const e=n.S,r=[],i=[];let s=e.length-1;for(;s>0&&!e[s];)s--;let c=8;for(let t=0;t<=s;){const n=e[t];let o=1;for(;t+o<=s&&e[t+o]===n;)o++;let f=o;if(n&&n!==c&&(r.push(n),i.push(0),f--,c=n),f<3)for(let t=0;t<f;t++)r.push(n),i.push(0);else h(r,i,n?16:17,f-3,n?3:7,n?2:3);t+=o}const f=new Uint32Array(18);for(const t of r)f[t]++;let l=0;for(const t of f)t&&l++;1===l&&(f[r[0]?0:1]=f[r[0]]);const a=u(f,5),p=y(a);let w=18;for(;w>0&&!a[Y[w-1]];)w--;t.write(2,0);for(let n=0;n<w;n++){const o=a[Y[n]];t.write(D[o],Q[o])}for(let n=0;n<r.length;n++){const o=r[n];t.write(a[o],p[o]),16===o?t.write(2,i[n]):17===o&&t.write(3,i[n])}}function g(t,n=0,o=0){return{split:t,L:n,X:o,v:1<<t}}function m(t,n,o=15){t.write(e(o+1),n.split),n.split!==o&&(t.write(e(n.split+1),n.L),t.write(e(n.split-n.L+1),n.X))}function M(t,n,e){if(n<t.v)return e[0]=n,e[1]=0,void(e[2]=0);const r=o(n),i=n-(1<<r),s=r-t.L-t.X;e[0]=t.v+(r-t.split<<t.L+t.X|i>>r-t.L<<t.X|i&(1<<t.X)-1),e[1]=s,e[2]=n>>t.X&(1<<s)-1}function b(t,n,o,e=0){M(t,n,F),o[e+F[0]]++}function A(t,n,o,e,r=0){M(o,e,F);const i=r+F[0];t.write(n.S[i],n.I[i]),F[1]&&t.write(F[1],F[2])}function U(t,{N:n=null,P:r,J:i}){t.write(1,n?1:0),n&&(t.t([[0,224],[0,512],[0,4096],[15,8]],n._),t.t([[0,3],[0,4],[2,5],[8,9]],n.minLength),m(t,n.q,8)),r.length>1&&function(t,n){let o=0;for(const t of n)o=Math.max(o,t);const r=o?e(o+1):0;if(r<=3){if(t.write(1,1),t.write(2,r),r)for(const o of n)t.write(r,o);return}t.write(1,0),t.write(1,0);const i=g(8),s=g(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(s,o-1-7,f,224),t+=o;else{for(let e=0;e<o;e++)l.push([n[t],0]),f[n[t]]++;t+=o}}const a=w(f);if(!c){U(t,{P:new Uint8Array(1),J:[{config:i,code:a}]});for(const[n]of l)A(t,a,i,n);return}const u=new Uint32Array(1);u[0]=1,U(t,{N:{_:224,minLength:7,q:s},P:new Uint8Array([1,0]),J:[{config:g(0),code:w(u)},{config:i,code:a}]});for(const[n,o]of l)A(t,a,i,n),o&&A(t,a,s,o-7,224)}(t,r),t.write(1,1);for(const n of i)m(t,n.config,15);for(const n of i){const e=n.code.U-1;if(e){const n=o(e);t.write(1,1),t.write(4,n),t.write(n,e-(1<<n))}else t.write(1,0)}for(const n of i)d(t,n.code)}function S(t,n=0,o=1){return{G:t,offset:n,O:o,context:-1}}function I(t,n){const o=(e,r)=>{if(e===r)return n?t[e].j:t[e];const i=e+r>>1;return function(t,n,o,e){return{B:t,R:n,left:o,right:e}}(n,n?t[i].k:i,o(i+1,r),o(e,i))};return o(0,t.length-1)}function x(t){return I(t,0)}function C(t,o){const e=[o],r=[],i=[];for(const t of e){if(t.left){r.push(t.B+1,n(t.R)),e.push(t.left,t.right);continue}t.context=i.length,i.push(t);const o=1===t.O?0:31-Math.clz32(t.O&-t.O);r.push(0,t.G,n(t.offset),o,(t.O>>o)-1)}const s=new Uint32Array(64);for(const t of r)b($,t,s);const c=w(s);U(t,{P:new Uint8Array(6),J:[{config:$,code:c}]});for(const n of r)A(t,c,$,n);return i}function T(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.t(o,n.Z),t.t([[0,6],[2,0],[4,2],[6,10]],n.Y??6);else if("palette"===n.type)t.write(2,1),t.t(o,n.Z),t.t([[0,1],[0,3],[0,4],[13,1]],n.D),t.t([[8,0],[10,256],[12,1280],[16,5376]],n.F),t.t([[0,0],[8,1],[10,257],[16,1281]],n.H??0),t.write(4,n.G??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const e=n.K??[];t.t([[0,0],[4,1],[6,9],[8,41]],e.length);for(const n of e)t.write(1,n.V?1:0),t.write(1,n.W?1:0),t.t(o,n.Z),t.t([[0,1],[0,2],[0,3],[4,4]],n.D)}}}function E(t,{$:n=!0,tt: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)T(t,n)}function L(t,n,o,e=t=>t.context){const r=new Uint8Array(n.length+1);for(const t of n)r[t.context]=e(t)+1;const i=new Uint32Array(2);i[1]=1;const s=[{config:$,code:w(i)}],c=Math.max(...r);for(let t=0;t<c;t++)s.push({config:$,code:w(o[t])});return U(t,{N:W,P:r,J:s}),s}function X(t,o,e,r,i,s){const c=s.G,f=s.offset,l=s.O,a=$,u=V;let h=0;const p=(n,e=a,r=0)=>{t?A(t,o,e,n,r):b(e,n,o,r)},y=()=>{if(h){if(h>=8)p(0),p(h-7-1,u,224);else for(let t=0;t<h;t++)p(0);h=0}},w=(t,o)=>{const r=e[t];let i;1===l?i=r-o-f:(i=Math.round((r-o-f)/l),e[t]=o+f+i*l),0!==i?(y(),p(n(i))):h++};for(let t=0,n=0;t<i;t++)for(let o=0;o<r;o++,n++){let i;if(0===c)i=0;else{const s=o?e[n-1]:t?e[n-r]:0,f=t?e[n-r]:s;if(1===c)i=s;else if(2===c)i=f;else if(3===c)i=(s+f)/2|0;else{const l=s+f-(o&&t?e[n-r-1]:s);if(5===c){const t=s<f?s:f,n=s<f?f:s;i=l<t?t:l>n?n:l}else{if(4!==c)throw new Error("predictor "+c+" is not coded here");i=Math.abs(l-s)<Math.abs(l-f)?s:f}}}w(n,i)}y()}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=>s?f?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(f?16777216*t[n+3]:0),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));const e=new Map([[0,0]]);t.forEach((t,n)=>e.set(t,n+1)),h={colours:[0,...t],index:e,key:a,byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function*N(n,o,e,{shape:r=v(n,o,e),colorSpace:i}={}){let s,c;const f=r.palette?[r,{...r,palette:null}]:[r];for(let r=0;r<f.length;r++)try{const c=yield*t(P(n,o,e,f[r],i),r,f.length);(!s||c.length<s.length)&&(s=c)}catch(t){if("JXL_SIZE"!==t.code)throw t;c=t}if(!s)throw c;return s}function*P(t,n,o,e,r){const{channels:i,palette:s}=e,u=l(n,o),h=s?2:i,p=Array.from({length:h},()=>S(K)),y=x(p),g=Array.from({length:h},()=>new Int16Array(65536)),m=(o,e,r,c)=>{for(let f=0;f<c;f++){let c=4*((e+f)*n+o),l=f*r;for(let n=0;n<r;n++,c+=4,l++)if(s)g[0][l]=s.index.get(s.key(c));else if(i>=3){const n=t[c],o=t[c+1],e=t[c+2],r=n-e,s=e+(r>>1),f=o-s;g[0][l]=s+(f>>1),g[1][l]=r,g[2][l]=f,4===i&&(g[3][l]=t[c+3])}else g[0][l]=t[c],2===i&&(g[1][l]=t[c+3])}};let M=null;if(s){const t=s.colours.length;M=new Int16Array(t*i),s.colours.forEach((n,o)=>{for(let e=0;e<i;e++)M[e*t+o]=s.byte(n,e)})}const b=t=>p[s?u.M?1:0:t],A=s?1:i,U=u.i*u.u,I=2*U,T=(t,e)=>{const r=t%u.i*Z,i=(t/u.i|0)*Z,s=Math.min(Z,n-r),c=Math.min(Z,o-i);m(r,i,s,c),e(s,c)};let v=0;if(!s){const t=t=>{const n=w(t),o=new R(128);d(o,n);let e=o.nt;for(let o=0;o<t.length;o++)t[o]&&(e+=t[o]*(n.S[o]+Math.max(0,o<224?o-1:o-236)));return e},e=Math.min(n,32),r=Math.min(o,32),s=[K,H].map(t=>({G:t,ot:p.map(()=>new Uint32Array(257))}));for(const t of[0,.5,1]){m(Math.floor((n-e)*t),Math.floor((o-r)*t),e,r);for(const t of s)for(let n=0;n<i;n++)X(null,t.ot[n],g[n],e,r,S(t.G))}p.forEach((n,o)=>{const e=s.map(n=>t(n.ot[o])),r=e[1]<e[0]?1:0;n.G=s[r].G})}const N=s?[{type:"palette",Z:0,D:i,F:s.colours.length}]:i>=3?[{type:"rct",Z:0,Y:6}]:[],P=p.map(()=>new Uint32Array(257)),J=t=>P[p.indexOf(t)];M&&X(null,J(p[0]),M,s.colours.length,i,p[0]);for(let t=0;t<U;t++)T(t,(t,n)=>{for(let o=0;o<A;o++)X(null,J(b(o)),g[o],t,n,b(o))}),yield++v/I;const _=new R(256);c(_,n,o,e.colour,e.alpha,{colorSpace:r}),f(_,{alpha:e.alpha});const z=new R(4096);z.write(1,1),z.write(1,1);const q=C(z,y),G=L(z,q,P,t=>p.indexOf(t)),O=t=>G[p.indexOf(t)+1].code;E(z,{$:!0,tt:N}),M&&X(z,O(p[0]),M,s.colours.length,i,p[0]);const j=[];if(u.M)T(0,(t,n)=>{for(let o=0;o<A;o++)X(z,O(b(o)),g[o],t,n,b(o))}),yield 1,j.push(z.finish());else{j.push(z.finish());for(let t=0;t<u.p*u.m+1;t++)j.push(new Uint8Array(0));for(let t=0;t<U;t++)T(t,(t,n)=>{const o=new R(t*n*A+64);E(o,{$:!0,tt:[]});for(let e=0;e<A;e++)X(o,O(b(e)),g[e],t,n,b(e));j.push(o.finish())}),yield++v/I}return a(_,j)}function J(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 _(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=tt(u,w),g=s+1<c?tt(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-J(s?r[l-y]:d,d,g)}const w=(o,e,r)=>({w:e,h:r,et:t.et+ +n,rt:t.rt+!n,data:o});return[w(h,f,l),w(p,a,u)]}function z(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({V:!0,W:!1,Z:1,D:2}),n.push({V:!1,W:!1,Z:1,D:2})),!(e>r)&&r>8&&(n.push({V:!1,W:!0,Z:0,D:o}),r=r+1>>1);e>8||r>8;)e>8&&(n.push({V:!0,W:!0,Z:0,D:o}),e=e+1>>1),r>8&&(n.push({V:!1,W:!0,Z:0,D:o}),r=r+1>>1);return n}function*q(t,n,o,{quality:e=90,shape:r=v(t,n,o,{palette:!1}),colorSpace:i}={}){const s=function(t){return t>=100?0:t>=30?.1+.09*(100-t):53/3e3*t*t-1.15*t+25}(e);if(!(s>0))throw new Error("lossy encoding needs a quality below 100");const{colour:u,alpha:h,channels:p}=r,y=n*o,w=Array.from({length:p},()=>new Int16Array(y));for(let n=0,o=0;o<y;o++,n+=4){if(3===u){const e=t[n],r=t[n+1],i=t[n+2],s=e-i,c=i+(s>>1),f=r-c;w[0][o]=c+(f>>1),w[1][o]=s,w[2][o]=f}else w[0][o]=t[n];h&&(w[p-1][o]=t[n+3])}const d=w.map((t,e)=>({w:n,h:o,et:0,rt:0,data:t,component:3===u?e:0===e?0:3})),g=1===n&&o>nt&&3===u,m=g?z(d).filter(t=>!t.V):1!==n&&1!==o||3!==u?[]:z(d),M=function(t,n=z(t)){const o=t.map(t=>({...t,level:0,it:!1}));for(const t of n){const n=t.Z+t.D-1,e=t.W?n+1:o.length;for(let r=t.Z;r<=n;r++){const[n,i]=_(o[r],t.V),s=o[r].level+1;o[r]={...n,level:s,it:o[r].it,component:o[r].component},o.splice(e+(r-t.Z),0,{...i,level:s,it:!0,component:o[r].component})}}return o}(d,m.length?m:void 0),b=t=>t.it?0:K,A=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.et+(g&&t.component>0&&t.component<3?1:0),t.rt,s),U=[...3===u?[{type:"rct",Z:0,Y:6}]:[],{type:"squeeze",K:m}],T=l(n,o,nt),N=T.p*T.m,P=T.i*T.u;let J=0;for(;J<M.length&&M[J].w<=nt&&M[J].h<=nt;)J++;const q=(t,n,o,e)=>{const r=n>>t.et,i=o>>t.rt;return{x:r,y:i,w:Math.min(t.w,r+(e>>t.et))-r,h:Math.min(t.h,i+(e>>t.rt))-i}},G=[{index:0,k:0,st:[]}];for(let t=0;t<J;t++)G[0].st.push({c:t,rect:{x:0,y:0,w:M[t].w,h:M[t].h}});if(!T.M){for(let t=0;t<N;t++){const n=t%T.p,o=t/T.p|0,e={index:1+t,k:1+N+t,st:[]};for(let t=J;t<M.length;t++){const r=M[t];if(Math.min(r.et,r.rt)<3)continue;const i=q(r,n*ot,o*ot,ot);i.w>0&&i.h>0&&e.st.push({c:t,rect:i})}G.push(e)}for(let t=0;t<P;t++){const n=t%T.i,o=t/T.i|0,e={index:2+N+t,k:1+3*N+17+t,st:[]};for(let t=J;t<M.length;t++){const r=M[t];if(Math.min(r.et,r.rt)>2)continue;const i=q(r,n*nt,o*nt,nt);i.w>0&&i.h>0&&e.st.push({c:t,rect:i})}G.push(e)}}for(const t of G)for(const n of t.st){const t=M[n.c];n.ct=S(b(t),0,A(t)),n.ct.channel=n.c}const O=G.filter(t=>t.st.length),j=1===O.length?x(O[0].st.map(t=>t.ct)):function(t){return I(t,1)}(O.map(t=>({k:t.k,j:x(t.st.map(t=>t.ct))}))),B=new Int16Array(1048576),k=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++)B.set(n.data.subarray((o.y+t)*n.w+o.x,(o.y+t)*n.w+o.x+o.w),t*o.w);return B},Z=[...new Set(G.flatMap(t=>t.st.map(t=>t.c)))].sort((t,n)=>t-n),Y=new Map(Z.map((t,n)=>[t,n])),D=Z.map(()=>new Uint32Array(257)),Q=1+2*G.length;let F=1;yield F/Q;for(const t of G){for(const n of t.st)X(null,D[Y.get(n.c)],k(n),n.rect.w,n.rect.h,n.ct);yield++F/Q}const H=new R(256);c(H,n,o,u,h,{colorSpace:i}),f(H,{alpha:h,shift:n>256||o>256?3:1});const V=Array.from({length:T.M?1:2+N+P},()=>null),W=V[0]=new R(65536);W.write(1,1),W.write(1,1);const $=L(W,C(W,j),D,t=>Y.get(t.channel));E(W,{$:!0,tt:U});for(const t of G){let n=V[t.index];n||(n=V[t.index]=new R(4096),t.st.length&&E(n,{$:!0,tt:[]}));for(const o of t.st)X(n,$[Y.get(o.c)+1].code,k(o),o.rect.w,o.rect.h,o.ct);yield++F/Q}return a(H,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(V))}function G(t,n,o,e){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(O(t,n,o,e))}function O(n,o,e,s){const{quality:c,colorSpace:f}=function(t={},n=100){if(null===t||"object"!=typeof t)throw k("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 k("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 k("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(s);return function(t,n,o,e){if(function(t,n,o=j){if(!Number.isInteger(t)||!Number.isInteger(n)||t<1||n<1)throw k("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>o.edge||n>o.edge)throw k("JXL_DIMENSIONS","A picture is at most "+o.edge+" pixels on a side.");if(t*n>o.pixels)throw k("JXL_DIMENSIONS","A picture is at most "+o.pixels.toLocaleString("en-US")+" pixels.")}(n,o,e),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw k("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==n*o*4)throw k("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(n,o,e),function(t){const n=function*(){let o,e;for(;!(o=i(()=>t.next(n.hurry))).done;)yield e=o.value;return e<1&&(yield 1),n.bytes=(r((s=o.value).length),s);var s}();return n.bytes=null,n.hurry=!1,n}(function*(n,o,e,r,i){const s=v(n,o,e);if(r>=100)return yield*N(n,o,e,{shape:s,colorSpace:i});if(!s.palette)return yield*q(n,o,e,{quality:r,shape:s,colorSpace:i});const c=yield*t(N(n,o,e,{shape:s,colorSpace:i}),0,2);let f;try{f=yield*t(q(n,o,e,{quality:r,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}(n,o,e,c,f))}const j=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),B=[1];for(let t=1;t<=32;t++)B.push(2*B[t-1]);class R{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.ft=0,this.pending=0}write(t,n){if(!(n>=0&&n<B[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let o=this.ft+n*(1<<this.pending),e=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const r=this.bytes;for(;e>=8;)r[this.at++]=255&o,o=Math.floor(o/256),e-=8;this.ft=o,this.pending=e}t(t,n){for(let o=0;o<4;o++){const[e,r]=t[o];if(n>=r&&n-r<B[e])return this.write(2,o),void(e&&this.write(e,n-r))}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.ft,this.ft=0,this.pending=0)}get nt(){return 8*this.at+this.pending}grow(t=0){const n=j.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.ft)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.ft),n}}const k=(t,n)=>Object.assign(new Error(n),{code:t}),Z=256,Y=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],D=[2,4,3,2,2,4],Q=[0,7,3,2,1,15],F=[0,0,0],H=3,K=5,V=g(4),W=Object.freeze({_:224,minLength:7,q:V}),$=g(0),tt=(t,n)=>t+n+(t>n?1:0)>>1,nt=1024,ot=8192;export{j as LIMITS,G as encode,O as encodeSteps};
package/sizes.json CHANGED
@@ -1,108 +1,318 @@
1
1
  {
2
2
  "package": "rapier-jxl",
3
- "version": "1.1.21",
4
- "measured": "exact bytes of the staged files; gzip level 9; Brotli quality 11, text mode",
3
+ "version": "2.1.0",
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",
7
7
  "privateProperties": "^(alphabetSize|lengths|codes|simple|treeSelect|splitToken|msb|lsb|contextMap|histograms|predictor|multiplier|context|splitval|property|offset|left|right|channel|acc|pending|at|bitLength|grow|zeroPadToByte|writeU32|append|finish|write|small|large|totals|contexts|tokens|cost|bucketOf|contextOf|nonZero|zeroDensityOffset|thresholds|numDc|numCtxs|freqs|hshift|vshift|residual|component|inPlace|horizontal|beginC|numC|rctType|nbColors|nbDeltas|useGlobalTree|streamId|pieces|rect|minSymbol|minLength|lengthConfig|params|type|leaf|groupsX|groupsY|dcGroupsX|dcGroupsY|single|config|bits|sym|tree|count|parts|lz77|transforms)$",
8
8
  "source": {
9
- "bytes": 102565,
10
- "gzip": 31745,
9
+ "bytes": 174894,
10
+ "gzip": 53445,
11
11
  "sha256": {
12
- "bits.mjs": "b2f5a8dab741cc1ba5450f734fa76b94a21b99468a381bedc86e9d0735e50196",
13
- "prefix.mjs": "ed51a5b6a3cf0a98b66fe54b3a1c050122ed312f7c47b136aa9fd5c84ac1a180",
12
+ "admit.mjs": "ccdbee9f68a0e0125853d5d786b95075bc39807e9a6e95d8a185a6c0c7b2fca4",
13
+ "ans.mjs": "c604457516a86c8697810d9ded6af20f91b59650f0ed5aea6683fc9f2051f79e",
14
+ "bits.mjs": "aee959d6bf46344f38291b461e8c40c225a23b7f4f093b21848432d9223abf3a",
15
+ "coefficient-ans.mjs": "8b7a080f440bc1894d7d13f6ee76b3a85fce7bbd0cfadc53ad06e4b58ed81ed1",
16
+ "coefficient-effort.mjs": "2d55459c7b96f85d7a6d029d87f0e4c2905d5982aa64334e38c4a401c2beebfb",
17
+ "effort.mjs": "911f906e3f5f0e1b09aa82c5370f1577104673bae019736ed149e5c7794fedaf",
18
+ "effort-level.mjs": "fe46adf2e34546c65e821400804cbd51c17c5a6d04b769310567082581b64f5d",
19
+ "entropy.mjs": "9cb52a9d174d63dc2b694725267c5ab0e8d693f5366e76fa0134f87cc878fe3a",
20
+ "frame.mjs": "f4c4bf0486b1942d65875661419b56c02371279a042004c4eaee304c4825a68b",
21
+ "index.mjs": "adf5f0d4ca70ce3e88c67a718d057c5dcab5098bd07308f4bf9406c365d81efe",
22
+ "jfif.mjs": "6b9a59f0b81ce5063191d1da9f658727ef03535144cd92b3908b249dfc99ed17",
23
+ "jpeg.mjs": "41bf5579a99f1870bc219228eb649589d027c807bdaee5c8b128a7aaa6711c95",
24
+ "jpeg-ans.mjs": "4a9cafe6eaf83f7c37f87513cc42458d6c2997c420830b0449d591c103993072",
25
+ "jpeg-job.mjs": "61370ed45ebd8c15c8edb3d043139dcde8a8bf7bd1ea52d030f3f73de5d6fa60",
26
+ "local.mjs": "3ad6d5f1369f316fddd0a6ed4844fbc42e60ae897610fa6cfc542c152e252b6a",
27
+ "lossless.mjs": "6260af5e685a94360ee7eb2c0f3e6ac94dc931ab0f199a7d5102ba13893f390c",
28
+ "lossy.mjs": "e297311f5f2d304d17ea277fb156d2a575599aecb5d2473cbfbbd1be6b76ff6d",
14
29
  "modular.mjs": "9be937ceb8d4eb015a54f7e9f92aeff7be42eeaef94fd13a32530ea5ff204662",
15
- "frame.mjs": "e156569816bb3142e810bd83feb53583e271107d26da72dc2fb6bf9e34eb2168",
30
+ "photo.mjs": "4da303eebca4f52d8fea265a76ca879a06ebe394c699615195067339206f6c98",
31
+ "photo-ans.mjs": "23e2af95d9ac6c80a9b3e1ce4bec7ab39a93ebd2575182f548a0213aa527e387",
32
+ "photo-dct.mjs": "cc7252d877389885baa1d9866489f58a55d0a4d00800f0b358b54904b3cf91ad",
33
+ "photo-job.mjs": "271452713a2c03fbb472f5050483748de5d0cc7b3a0e0589decd143b0f087a68",
34
+ "photo-quant.mjs": "94854a56333a1d5c1346117e576013472857662f2e01a3fa54852d5567256a00",
35
+ "prefix.mjs": "ed51a5b6a3cf0a98b66fe54b3a1c050122ed312f7c47b136aa9fd5c84ac1a180",
16
36
  "squeeze.mjs": "ec01352dcf22b7346c7f0014e17e6ba2e4fe8243c358db77eee5fc830a3217e8",
17
- "lossless.mjs": "34c22f34b024120ca751b55b33554c07618212337bbbde29e4dac90ba9672512",
18
- "lossy.mjs": "14a6f0dec06ebd45141ff61d2634d36f7f7ee6dab9f07fa1da6c9b1f3297567c",
19
- "jpeg.mjs": "a8baf12b09b8c221503df4b8854540c960e6ed3997422624ac39785054b6deba",
20
- "entropy.mjs": "639028e81f06933ea9ca9100f25f48964e0d39620140a0b0623f4a0e40ff1fa6",
21
- "vardct.mjs": "f4c3e606cab6d737a498f427b8f45597e7fbbfcd675c81ba14d744ca980f85f8",
22
- "index.mjs": "1e981e0943f4321a4903048daae0ee2f5a0df1d16e242d4259239d0d53a1fab5",
23
- "photo.mjs": "3458e73edbc2322bedace0ab52b39f3c5e4e18bea078bb1366f5a7739af45393"
37
+ "vardct.mjs": "2befa3c606124fa6aa1f5ab7e856a4734217f0baefa5b3324fabbbbe13c04cd9",
38
+ "weighted.mjs": "94872c63be7d3a09972bdcad55485d06f4942fecf7eadf6c28feedbc68fb8f50",
39
+ "writer.mjs": "f8ec54c0d79cdf148f6be797d72f375cf9635cb00097897bdf1d570457d3fcc9"
24
40
  }
25
41
  },
26
- "bundles": [
42
+ "doors": [
27
43
  {
44
+ "entry": ".",
45
+ "module": "index",
28
46
  "file": "rapier-jxl.min.mjs",
29
- "entry": "./min",
30
47
  "exports": [
48
+ "LIMITS",
31
49
  "encode",
32
- "encodeLosslessRGBA",
33
- "encodeLossyRGBA",
34
- "transcode",
50
+ "encodeSteps"
51
+ ],
52
+ "modules": [
53
+ "bits",
54
+ "admit",
55
+ "frame",
56
+ "prefix",
57
+ "modular",
58
+ "lossless",
59
+ "squeeze",
60
+ "lossy",
61
+ "index"
62
+ ],
63
+ "alone": {
64
+ "bytes": 19539,
65
+ "gzip": 8511,
66
+ "brotli": 7515,
67
+ "sha256": "31c5b5fe523a45fdda4d0a859ab95450a72370a50e801352db35b4655fdd5592",
68
+ "compress": {
69
+ "passes": 2,
70
+ "hoist_funs": true,
71
+ "hoist_vars": true,
72
+ "module": true
73
+ }
74
+ },
75
+ "added": {
76
+ "bytes": 0,
77
+ "gzip": 0,
78
+ "brotli": 0
79
+ },
80
+ "provedByteCases": 98
81
+ },
82
+ {
83
+ "entry": "./jpeg",
84
+ "module": "jpeg",
85
+ "file": "jpeg.min.mjs",
86
+ "exports": [
35
87
  "LIMITS",
36
- "encodeLossless",
37
- "encodeLossy",
38
- "transcodeJPEG",
39
- "parseJPEG",
40
- "inspectPixels"
88
+ "transcode",
89
+ "transcodeSteps"
41
90
  ],
42
- "bytes": 36284,
43
- "gzip": 14987,
44
- "brotli": 13315,
45
- "sha256": "ab003954f9d33375dddb1a86342f0ce80d1d0cd43133431fceae663383d31d0f",
46
- "compress": {
47
- "passes": 2,
48
- "hoist_funs": true,
49
- "hoist_vars": true,
50
- "module": true
51
- }
91
+ "modules": [
92
+ "bits",
93
+ "jfif",
94
+ "admit",
95
+ "effort-level",
96
+ "jpeg-job",
97
+ "frame",
98
+ "prefix",
99
+ "modular",
100
+ "entropy",
101
+ "vardct",
102
+ "coefficient-effort",
103
+ "jpeg"
104
+ ],
105
+ "alone": {
106
+ "bytes": 32218,
107
+ "gzip": 13439,
108
+ "brotli": 11874,
109
+ "sha256": "8326d88968781fbe951c2ab76e3e797992123648609f8875bb122a3bb4609a4e",
110
+ "compress": {
111
+ "passes": 2,
112
+ "inline": 1,
113
+ "module": true
114
+ }
115
+ },
116
+ "added": {
117
+ "bytes": 21890,
118
+ "gzip": 8497,
119
+ "brotli": 7558
120
+ },
121
+ "provedByteCases": 13
52
122
  },
53
123
  {
54
- "file": "lossless.min.mjs",
55
- "entry": "./lossless",
124
+ "entry": "./photo",
125
+ "module": "photo",
126
+ "file": "photo.min.mjs",
56
127
  "exports": [
57
- "encodeLosslessRGBA",
58
- "LIMITS"
128
+ "LIMITS",
129
+ "encodePhoto",
130
+ "encodePhotoSteps"
59
131
  ],
60
- "bytes": 13754,
61
- "gzip": 6131,
62
- "brotli": 5401,
63
- "sha256": "dcb99eb53fddda0524663408b205facf6ff076345085ded402ceaa17cb3a2c75",
64
- "compress": {
65
- "passes": 2,
66
- "hoist_funs": true,
67
- "hoist_vars": true,
68
- "module": true
69
- }
132
+ "modules": [
133
+ "bits",
134
+ "admit",
135
+ "effort-level",
136
+ "frame",
137
+ "prefix",
138
+ "modular",
139
+ "lossless",
140
+ "photo-dct",
141
+ "photo-quant",
142
+ "photo-job",
143
+ "entropy",
144
+ "jfif",
145
+ "vardct",
146
+ "coefficient-effort",
147
+ "photo"
148
+ ],
149
+ "alone": {
150
+ "bytes": 31288,
151
+ "gzip": 12872,
152
+ "brotli": 11370,
153
+ "sha256": "0389fcce9845e8d6c9625d07467be61e7c5f19346a820c013e9ce4d7a1966700",
154
+ "compress": {
155
+ "passes": 2,
156
+ "hoist_funs": true,
157
+ "hoist_vars": true,
158
+ "module": true
159
+ }
160
+ },
161
+ "added": {
162
+ "bytes": 16643,
163
+ "gzip": 6257,
164
+ "brotli": 5527
165
+ },
166
+ "provedByteCases": 43
70
167
  },
71
168
  {
72
- "file": "jpeg.min.mjs",
73
- "entry": "./jpeg",
169
+ "entry": "./jpeg-ans",
170
+ "module": "jpeg-ans",
171
+ "file": "jpeg-ans.min.mjs",
74
172
  "exports": [
173
+ "LIMITS",
75
174
  "transcode",
76
- "LIMITS"
175
+ "transcodeSteps"
77
176
  ],
78
- "bytes": 27750,
79
- "gzip": 11590,
80
- "brotli": 10217,
81
- "sha256": "f6206ae33c35c3a7ff548e7f18588871d487587820684b59da959835723d8fe4",
82
- "compress": {
83
- "passes": 2,
84
- "hoist_funs": true,
85
- "hoist_vars": true,
86
- "module": true
87
- }
177
+ "modules": [
178
+ "bits",
179
+ "jfif",
180
+ "admit",
181
+ "effort-level",
182
+ "jpeg-job",
183
+ "frame",
184
+ "prefix",
185
+ "modular",
186
+ "entropy",
187
+ "vardct",
188
+ "coefficient-effort",
189
+ "ans",
190
+ "coefficient-ans",
191
+ "jpeg-ans"
192
+ ],
193
+ "alone": {
194
+ "bytes": 35281,
195
+ "gzip": 14506,
196
+ "brotli": 12804,
197
+ "sha256": "ed7517a5c7e1c92e1a9dde601e1d11e6a6c927839912024a741c4581b84be4e5",
198
+ "compress": {
199
+ "passes": 2,
200
+ "inline": 1,
201
+ "module": true
202
+ }
203
+ },
204
+ "added": {
205
+ "bytes": 24878,
206
+ "gzip": 9564,
207
+ "brotli": 8497
208
+ },
209
+ "provedByteCases": 13
88
210
  },
89
211
  {
90
- "file": "photo.min.mjs",
91
- "entry": "./photo",
212
+ "entry": "./photo-ans",
213
+ "module": "photo-ans",
214
+ "file": "photo-ans.min.mjs",
215
+ "exports": [
216
+ "LIMITS",
217
+ "encodePhoto",
218
+ "encodePhotoSteps"
219
+ ],
220
+ "modules": [
221
+ "bits",
222
+ "admit",
223
+ "effort-level",
224
+ "frame",
225
+ "prefix",
226
+ "modular",
227
+ "lossless",
228
+ "photo-dct",
229
+ "photo-quant",
230
+ "photo-job",
231
+ "entropy",
232
+ "jfif",
233
+ "vardct",
234
+ "coefficient-effort",
235
+ "ans",
236
+ "coefficient-ans",
237
+ "photo-ans"
238
+ ],
239
+ "alone": {
240
+ "bytes": 34293,
241
+ "gzip": 13899,
242
+ "brotli": 12295,
243
+ "sha256": "ddb5c091d9361350e365bd64b2bf3d4eaba4c3a39722bfbdae6bc18c3ca1743d",
244
+ "compress": {
245
+ "passes": 2,
246
+ "hoist_funs": true,
247
+ "hoist_vars": true,
248
+ "module": true
249
+ }
250
+ },
251
+ "added": {
252
+ "bytes": 19626,
253
+ "gzip": 7298,
254
+ "brotli": 6468
255
+ },
256
+ "provedByteCases": 43
257
+ },
258
+ {
259
+ "entry": "./effort",
260
+ "module": "effort",
261
+ "file": "effort.min.mjs",
92
262
  "exports": [
93
- "encodePhotoRGBA",
94
- "LIMITS"
263
+ "LIMITS",
264
+ "encode",
265
+ "encodeSteps"
266
+ ],
267
+ "modules": [
268
+ "bits",
269
+ "admit",
270
+ "frame",
271
+ "prefix",
272
+ "modular",
273
+ "lossless",
274
+ "squeeze",
275
+ "lossy",
276
+ "weighted",
277
+ "local",
278
+ "effort"
95
279
  ],
96
- "bytes": 22563,
97
- "gzip": 9768,
98
- "brotli": 8635,
99
- "sha256": "3ae179c6544fa06612da6e22b211fe7edde0ebf0d4ccca927b4e75d27a0e58aa",
100
- "compress": {
101
- "passes": 2,
102
- "hoist_funs": true,
103
- "hoist_vars": true,
104
- "module": true
105
- }
280
+ "alone": {
281
+ "bytes": 30008,
282
+ "gzip": 12320,
283
+ "brotli": 10860,
284
+ "sha256": "ec76b4fcdf79cebb7f2370c5167228188f95cfff8e4a6bafe23b1efba92585aa",
285
+ "compress": {
286
+ "passes": 2,
287
+ "inline": 1,
288
+ "module": true
289
+ }
290
+ },
291
+ "added": {
292
+ "bytes": 10469,
293
+ "gzip": 3809,
294
+ "brotli": 3345
295
+ },
296
+ "provedByteCases": 98
106
297
  }
107
- ]
298
+ ],
299
+ "all": {
300
+ "exports": [
301
+ "LIMITS",
302
+ "encode",
303
+ "encodePhoto",
304
+ "encodePhotoSteps",
305
+ "encodeSteps",
306
+ "transcode",
307
+ "transcodeSteps"
308
+ ],
309
+ "doors": [
310
+ "./effort",
311
+ "./jpeg-ans",
312
+ "./photo-ans"
313
+ ],
314
+ "bytes": 61101,
315
+ "gzip": 24091,
316
+ "brotli": 21147
317
+ }
108
318
  }