diff --git a/packages/examples/static/index.html b/packages/examples/static/index.html index e0643543..3eaf7d22 100644 --- a/packages/examples/static/index.html +++ b/packages/examples/static/index.html @@ -1 +1 @@ -二维码
\ No newline at end of file +二维码
\ No newline at end of file diff --git a/packages/examples/static/public/js/02056e3f16bc64f3.js b/packages/examples/static/public/js/497247729aec879a.js similarity index 97% rename from packages/examples/static/public/js/02056e3f16bc64f3.js rename to packages/examples/static/public/js/497247729aec879a.js index b88f9c23..60813e1c 100644 --- a/packages/examples/static/public/js/02056e3f16bc64f3.js +++ b/packages/examples/static/public/js/497247729aec879a.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,r,o,u,i,f={},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return f[e](n,n.exports,c),n.exports}c.m=f,e=[],c.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(c.O).every(function(e){return c.O[e](n[a])})?n.splice(a--,1):(f=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(c.O).every(function(e){return c.O[e](n[a])})?n.splice(a--,1):(f=!1,o>1&1431655765,((e=(858993459&e)+(e>>2&858993459))+(e>>4)&252645135)*16843009>>24}function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0;for(let i=t;i - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class i{#e;#t;#n;#r;constructor(e,t,n){let r=Math.ceil(e/32),i=r*t;if(this.#e=e,this.#t=t,this.#n=r,n instanceof Int32Array){if(n.length!==i)throw Error(`matrix bits capacity mismatch: ${i}`);this.#r=n}else this.#r=new Int32Array(i)}#i(e,t){return t*this.#n+(0|e/32)}get width(){return this.#e}get height(){return this.#t}set(e,t){let n=this.#i(e,t);this.#r[n]|=1<<(31&e)}get(e,t){let n=this.#i(e,t);return this.#r[n]>>>(31&e)&1}flip(e,t){if(null!=e&&null!=t){let n=this.#i(e,t);this.#r[n]^=1<<(31&e)}else{let e=this.#r,{length:t}=e;for(let n=0;n>3;return 7&e&&t++,t}function o(e,t){return e<2?2:Math.min(e,t)}function l(e,t){return(e<<=3)>t?t:e}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class w{#s;#o;constructor(e,t){this.#s=e,this.#o=t}get x(){return this.#s}get y(){return this.#o}}function a(e,t){return Math.sqrt(u(e,t))}function u(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function h(e,t,n){let{x:r,y:i}=e,{x:s,y:o}=t,{x:l,y:w}=n;return Math.abs(r*(o-w)+s*(w-i)+l*(i-o))/2}class f extends w{#l;#e;#t;#w;#a;#u=1;#h;#f;static noise(e){return e.#l}static width(e){return e.#e}static height(e){return e.#t}static combined(e){return e.#u}static rect(e){return e.#w}static equals(e,t,n,r,i){let{modules:s}=e.#h,o=e.#f;if(Math.abs(t-e.x)<=o&&Math.abs(n-e.y)<=o){let t=e.#a,n=Math.abs((r+i)/s/2-t);if(n<=1||n<=t)return!0}return!1}static combine(e,t,n,r,i,s){let o=e.#u,l=o+1,w=(e.x*o+t)/l,a=(e.y*o+n)/l,u=(e.#l*o+s)/l,h=(e.#e*o+r)/l,c=(e.#t*o+i)/l,d=new f(e.#h,w,a,h,c,u);return d.#u=l,d}constructor(e,t,n,r,i,s){super(t,n);let{modules:o}=e,l=r/2,w=i/2,a=r/o,u=i/o,h=a/2,f=u/2,c=/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e){let{ratios:t}=e;return t[0|t.length/2]/2}(e),d=(a+u)/2;this.#l=s,this.#e=r,this.#t=i,this.#h=e,this.#a=d,this.#w=[t-l+h,n-w+f,t+l-h,n+w-f],this.#f=d*c}get moduleSize(){return this.#a}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class c{#c;#d;constructor(e,t){this.#c=e,this.#d=t}sample(e,t){let n=this.#c,r=n.width,s=this.#d,o=n.height,l=new i(e,t);for(let i=0;i=0&&u>=0&&a - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class d{#g;#m;constructor(e,t){this.#g=e,this.#m=t}get count(){return this.#g}get numDataCodewords(){return this.#m}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class g{#b;#y;#p;#x;#I;constructor(e,...t){let n=0,r=0;for(let{count:e,numDataCodewords:i}of t)n+=e,r+=i*e;let i=e*n;this.#b=t,this.#p=i,this.#x=r,this.#I=e,this.#y=r+i}get ecBlocks(){return this.#b}get numTotalCodewords(){return this.#y}get numTotalECCodewords(){return this.#p}get numTotalDataCodewords(){return this.#x}get numECCodewordsPerBlock(){return this.#I}}let m=[31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017];class b{#z;#E;#b;#C;constructor(e,t,...n){this.#E=e,this.#b=n,this.#z=17+4*e,this.#C=t}get size(){return this.#z}get version(){return this.#E}get alignmentPatterns(){return this.#C}getECBlocks(e){let{level:t}=e;return this.#b[t]}}let y=[new b(1,[],new g(7,new d(1,19)),new g(10,new d(1,16)),new g(13,new d(1,13)),new g(17,new d(1,9))),new b(2,[6,18],new g(10,new d(1,34)),new g(16,new d(1,28)),new g(22,new d(1,22)),new g(28,new d(1,16))),new b(3,[6,22],new g(15,new d(1,55)),new g(26,new d(1,44)),new g(18,new d(2,17)),new g(22,new d(2,13))),new b(4,[6,26],new g(20,new d(1,80)),new g(18,new d(2,32)),new g(26,new d(2,24)),new g(16,new d(4,9))),new b(5,[6,30],new g(26,new d(1,108)),new g(24,new d(2,43)),new g(18,new d(2,15),new d(2,16)),new g(22,new d(2,11),new d(2,12))),new b(6,[6,34],new g(18,new d(2,68)),new g(16,new d(4,27)),new g(24,new d(4,19)),new g(28,new d(4,15))),new b(7,[6,22,38],new g(20,new d(2,78)),new g(18,new d(4,31)),new g(18,new d(2,14),new d(4,15)),new g(26,new d(4,13),new d(1,14))),new b(8,[6,24,42],new g(24,new d(2,97)),new g(22,new d(2,38),new d(2,39)),new g(22,new d(4,18),new d(2,19)),new g(26,new d(4,14),new d(2,15))),new b(9,[6,26,46],new g(30,new d(2,116)),new g(22,new d(3,36),new d(2,37)),new g(20,new d(4,16),new d(4,17)),new g(24,new d(4,12),new d(4,13))),new b(10,[6,28,50],new g(18,new d(2,68),new d(2,69)),new g(26,new d(4,43),new d(1,44)),new g(24,new d(6,19),new d(2,20)),new g(28,new d(6,15),new d(2,16))),new b(11,[6,30,54],new g(20,new d(4,81)),new g(30,new d(1,50),new d(4,51)),new g(28,new d(4,22),new d(4,23)),new g(24,new d(3,12),new d(8,13))),new b(12,[6,32,58],new g(24,new d(2,92),new d(2,93)),new g(22,new d(6,36),new d(2,37)),new g(26,new d(4,20),new d(6,21)),new g(28,new d(7,14),new d(4,15))),new b(13,[6,34,62],new g(26,new d(4,107)),new g(22,new d(8,37),new d(1,38)),new g(24,new d(8,20),new d(4,21)),new g(22,new d(12,11),new d(4,12))),new b(14,[6,26,46,66],new g(30,new d(3,115),new d(1,116)),new g(24,new d(4,40),new d(5,41)),new g(20,new d(11,16),new d(5,17)),new g(24,new d(11,12),new d(5,13))),new b(15,[6,26,48,70],new g(22,new d(5,87),new d(1,88)),new g(24,new d(5,41),new d(5,42)),new g(30,new d(5,24),new d(7,25)),new g(24,new d(11,12),new d(7,13))),new b(16,[6,26,50,74],new g(24,new d(5,98),new d(1,99)),new g(28,new d(7,45),new d(3,46)),new g(24,new d(15,19),new d(2,20)),new g(30,new d(3,15),new d(13,16))),new b(17,[6,30,54,78],new g(28,new d(1,107),new d(5,108)),new g(28,new d(10,46),new d(1,47)),new g(28,new d(1,22),new d(15,23)),new g(28,new d(2,14),new d(17,15))),new b(18,[6,30,56,82],new g(30,new d(5,120),new d(1,121)),new g(26,new d(9,43),new d(4,44)),new g(28,new d(17,22),new d(1,23)),new g(28,new d(2,14),new d(19,15))),new b(19,[6,30,58,86],new g(28,new d(3,113),new d(4,114)),new g(26,new d(3,44),new d(11,45)),new g(26,new d(17,21),new d(4,22)),new g(26,new d(9,13),new d(16,14))),new b(20,[6,34,62,90],new g(28,new d(3,107),new d(5,108)),new g(26,new d(3,41),new d(13,42)),new g(30,new d(15,24),new d(5,25)),new g(28,new d(15,15),new d(10,16))),new b(21,[6,28,50,72,94],new g(28,new d(4,116),new d(4,117)),new g(26,new d(17,42)),new g(28,new d(17,22),new d(6,23)),new g(30,new d(19,16),new d(6,17))),new b(22,[6,26,50,74,98],new g(28,new d(2,111),new d(7,112)),new g(28,new d(17,46)),new g(30,new d(7,24),new d(16,25)),new g(24,new d(34,13))),new b(23,[6,30,54,78,102],new g(30,new d(4,121),new d(5,122)),new g(28,new d(4,47),new d(14,48)),new g(30,new d(11,24),new d(14,25)),new g(30,new d(16,15),new d(14,16))),new b(24,[6,28,54,80,106],new g(30,new d(6,117),new d(4,118)),new g(28,new d(6,45),new d(14,46)),new g(30,new d(11,24),new d(16,25)),new g(30,new d(30,16),new d(2,17))),new b(25,[6,32,58,84,110],new g(26,new d(8,106),new d(4,107)),new g(28,new d(8,47),new d(13,48)),new g(30,new d(7,24),new d(22,25)),new g(30,new d(22,15),new d(13,16))),new b(26,[6,30,58,86,114],new g(28,new d(10,114),new d(2,115)),new g(28,new d(19,46),new d(4,47)),new g(28,new d(28,22),new d(6,23)),new g(30,new d(33,16),new d(4,17))),new b(27,[6,34,62,90,118],new g(30,new d(8,122),new d(4,123)),new g(28,new d(22,45),new d(3,46)),new g(30,new d(8,23),new d(26,24)),new g(30,new d(12,15),new d(28,16))),new b(28,[6,26,50,74,98,122],new g(30,new d(3,117),new d(10,118)),new g(28,new d(3,45),new d(23,46)),new g(30,new d(4,24),new d(31,25)),new g(30,new d(11,15),new d(31,16))),new b(29,[6,30,54,78,102,126],new g(30,new d(7,116),new d(7,117)),new g(28,new d(21,45),new d(7,46)),new g(30,new d(1,23),new d(37,24)),new g(30,new d(19,15),new d(26,16))),new b(30,[6,26,52,78,104,130],new g(30,new d(5,115),new d(10,116)),new g(28,new d(19,47),new d(10,48)),new g(30,new d(15,24),new d(25,25)),new g(30,new d(23,15),new d(25,16))),new b(31,[6,30,56,82,108,134],new g(30,new d(13,115),new d(3,116)),new g(28,new d(2,46),new d(29,47)),new g(30,new d(42,24),new d(1,25)),new g(30,new d(23,15),new d(28,16))),new b(32,[6,34,60,86,112,138],new g(30,new d(17,115)),new g(28,new d(10,46),new d(23,47)),new g(30,new d(10,24),new d(35,25)),new g(30,new d(19,15),new d(35,16))),new b(33,[6,30,58,86,114,142],new g(30,new d(17,115),new d(1,116)),new g(28,new d(14,46),new d(21,47)),new g(30,new d(29,24),new d(19,25)),new g(30,new d(11,15),new d(46,16))),new b(34,[6,34,62,90,118,146],new g(30,new d(13,115),new d(6,116)),new g(28,new d(14,46),new d(23,47)),new g(30,new d(44,24),new d(7,25)),new g(30,new d(59,16),new d(1,17))),new b(35,[6,30,54,78,102,126,150],new g(30,new d(12,121),new d(7,122)),new g(28,new d(12,47),new d(26,48)),new g(30,new d(39,24),new d(14,25)),new g(30,new d(22,15),new d(41,16))),new b(36,[6,24,50,76,102,128,154],new g(30,new d(6,121),new d(14,122)),new g(28,new d(6,47),new d(34,48)),new g(30,new d(46,24),new d(10,25)),new g(30,new d(2,15),new d(64,16))),new b(37,[6,28,54,80,106,132,158],new g(30,new d(17,122),new d(4,123)),new g(28,new d(29,46),new d(14,47)),new g(30,new d(49,24),new d(10,25)),new g(30,new d(24,15),new d(46,16))),new b(38,[6,32,58,84,110,136,162],new g(30,new d(4,122),new d(18,123)),new g(28,new d(13,46),new d(32,47)),new g(30,new d(48,24),new d(14,25)),new g(30,new d(42,15),new d(32,16))),new b(39,[6,26,54,82,110,138,166],new g(30,new d(20,117),new d(4,118)),new g(28,new d(40,47),new d(7,48)),new g(30,new d(43,24),new d(22,25)),new g(30,new d(10,15),new d(67,16))),new b(40,[6,30,58,86,114,142,170],new g(30,new d(19,118),new d(6,119)),new g(28,new d(18,47),new d(31,48)),new g(30,new d(34,24),new d(34,25)),new g(30,new d(20,15),new d(61,16)))];/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class p{#S;#v;#A;#O;#k;#M;constructor(e,t){let n=0|t.x,r=0|t.y,i=0|e.x,s=0|e.y,o=Math.abs(r-s)>Math.abs(n-i);o&&([i,s,n,r]=[s,i,r,n]);let l=i0){if(h===n)break;h+=i,a-=s}}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function x(e,t,n){let r=0,{width:i,height:s}=e,o=new w((t.x+n.x)/2,(t.y+n.y)/2);for(let[n,l]of new p(t,o).points()){if(n<0||l<0||n>=i||l>=s){if(2===r)return a(t,new w(n,l));break}if(1===r==(1===e.get(n,l))){if(2===r)return a(t,new w(n,l));r++}}return NaN}function I(e,t,n){let r=x(e,t,n);if(Number.isNaN(r))return NaN;let{x:i,y:s}=n,{x:o,y:l}=t,a=x(e,t,new w(o-(i-o),l-(s-l)));return Number.isNaN(a)?NaN:r+a-1}function z(e,t,n){let r=new w(0|t.x,0|t.y),i=new w(0|n.x,0|n.y),s=I(e,r,i),o=I(e,i,r);return Number.isNaN(s)?o/7:Number.isNaN(o)?s/7:(s+o)/14}function E(e,t){var n,r,i,s;let o=Math.max((n=f.width(e))>(r=f.width(t))?n/r:r/n,(i=f.height(e))>(s=f.height(t))?i/s:s/i);return o*o}class C{#T;#z;#c;#_;#a;#N;#R;static moduleSizes(e){if(null==e.#R){let t=e.#c,[n,r,i]=e.#N;e.#R=[z(t,n,r),z(t,n,i)]}return e.#R}static size(n){if(null==n.#z){let r=e.moduleSize(n);n.#z=function(e,n){let[r,i,s]=e,o=t((a(r,i)+a(r,s))/n/2)+7;switch(3&o){case 0:return o+1;case 2:return o-1;case 3:return Math.min(o+2,177)}return o}(n.#N,r)}return n.#z}static moduleSize(t){return null==t.#a&&(t.#a=r(e.moduleSizes(t))/2),t.#a}static contains(t,n){let r=t.#D(),[i,s,o]=t.#N,l=e.bottomRight(t),w=h(i,s,n);return w+h(s,l,n)+h(l,o,n)+h(o,i,n)-r<1}static bottomRight(e){return null==e.#_&&(e.#_=function(e){let[t,n,r]=e,{x:i,y:s}=t;return new w(n.x+r.x-i,n.y+r.y-s)}(e.#N)),e.#_}constructor(e,t){this.#c=e,this.#N=function(e){let t,n,r;let[i,s,o]=e,l=u(i,s)*E(i,s),w=u(i,o)*E(i,o),a=u(s,o)*E(s,o);return a>=l&&a>=w?[t,r,n]=e:w>=a&&w>=l?[r,t,n]=e:[r,n,t]=e,0>function(e,t,n){let{x:r,y:i}=t;return(n.x-r)*(e.y-i)-(n.y-i)*(e.x-r)}(r,t,n)&&([r,n]=[n,r]),[t,n,r]}(t)}get topLeft(){return this.#N[0]}get topRight(){return this.#N[1]}get bottomLeft(){return this.#N[2]}#D(){let[t,n,r]=this.#N,i=e.bottomRight(this);if(null==this.#T){let e=h(t,n,i),s=h(i,r,t);this.#T=e+s}return this.#T}}e=C;/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class S{#c;#B;#P;#d;constructor(e,t,n,r){let i=new c(e,t),s=C.size(n);this.#c=e,this.#d=t,this.#P=n,this.#B=r,this.#c=i.sample(s,s)}get matrix(){return this.#c}get finder(){return this.#P}get alignment(){return this.#B}get size(){return C.size(this.#P)}get moduleSize(){return C.moduleSize(this.#P)}mapping(e,t){return[e,t]=this.#d.mapping(e,t),new w(e,t)}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class v{#U;#F;#L;#Z;#H;#j;#$;#q;#G;constructor(e,t,n,r,i,s,o,l,w){this.#U=e,this.#F=r,this.#L=o,this.#Z=t,this.#H=i,this.#j=l,this.#$=n,this.#q=s,this.#G=w}inverse(){let e=this.#U,t=this.#F,n=this.#L,r=this.#Z,i=this.#H,s=this.#j,o=this.#$,l=this.#q,w=this.#G;return new v(i*w-s*l,s*o-r*w,r*l-i*o,n*l-t*w,e*w-n*o,t*o-e*l,t*s-n*i,n*r-e*s,e*i-t*r)}times(e){let t=this.#U,n=this.#F,r=this.#L,i=this.#Z,s=this.#H,o=this.#j,l=this.#$,w=this.#q,a=this.#G,u=e.#U,h=e.#F,f=e.#L,c=e.#Z,d=e.#H,g=e.#j,m=e.#$,b=e.#q,y=e.#G;return new v(t*u+i*h+l*f,t*c+i*d+l*g,t*m+i*b+l*y,n*u+s*h+w*f,n*c+s*d+w*g,n*m+s*b+w*y,r*u+o*h+a*f,r*c+o*d+a*g,r*m+o*b+a*y)}mapping(e,t){let n=this.#U,r=this.#F,i=this.#L,s=this.#Z,o=this.#H,l=this.#j,w=this.#$,a=this.#q,u=i*e+l*t+this.#G;return[(n*e+s*t+w)/u,(r*e+o*t+a)/u]}}function A(e,t,n,r,i,s,o,l){let w=e-n+i-o,a=t-r+s-l;if(0===w&&0===a)return new v(n-e,i-n,e,r-t,s-r,t,0,0,1);{let u=n-i,h=o-i,f=r-s,c=l-s,d=u*c-h*f,g=(w*c-h*a)/d,m=(u*a-w*f)/d;return new v(n-e+g*n,o-e+m*o,e,r-t+g*r,l-t+m*l,t,g,m,1)}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function O(e,t){let n,r,i,s;let{x:o,y:l}=e.topLeft,{x:w,y:a}=e.topRight,{x:u,y:h}=e.bottomLeft,f=C.size(e)-3.5;return null!=t?(n=t.x,r=t.y,s=i=f-3):(n=w+u-o,r=a+h-l,i=f,s=f),function(e,t,n,r,i,s,o,l,w,a,u,h,f,c,d,g){let m=A(3.5,3.5,n,3.5,i,s,3.5,l).inverse();return A(w,a,u,h,f,c,d,g).times(m)}(0,0,f,0,i,s,0,f,o,l,w,a,n,r,u,h)}function k(e,t){let[n,,r]=f.rect(e);return t>0?r:t<0?n:e.x}function M(e,t){let[,n,,r]=f.rect(e);return t>0?r:t<0?n:e.y}function T(e,t,n,r){let{x:i,y:s}=t,{x:o,y:l}=e,{x:a,y:u}=n,h=a>i?1:as?1:ui))return!1}return o>=r-14-Math.max(2,(r-17)/4)}function N(e,t,n){let{topLeft:r,topRight:i,bottomLeft:s}=t,[o,l]=n?T(r,s,i,!0):T(r,i,s);return _(e,o,l,C.size(t))}function R(e,t,n,r){let[i,s]=t.mapping(r?6.5:7.5,r?7.5:6.5),[o,l]=t.mapping(r?6.5:n-7.5,r?n-7.5:6.5);return _(e,new w(i,s),new w(o,l),n)}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class D{#V;#h;constructor(e){this.#h=e,this.#V=r(e)}get modules(){return this.#V}get ratios(){return this.#h}}let B=new D([1,1,3,1,1]),P=new D([1,1,1,1,1]),U=new D([1,1,1]);function F(e,t){let{length:n}=e,r=n-1;for(let t=0;t{o+=s,l-=s*h},c=()=>e.get(o,l);for(;o>=0&&l>=0&&l=0&&l>=0&&l=0&&l>=0&&l=0&&l=0&&l=0&&l - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */let H=Math.PI/180,j=40*H,$=140*H;function q(e,t,n,r,i,s){let[o,l]=function(e,t,n,r,i){t|=0,n|=0;let s=i?n:t,o=[0,0,0,0,0],l=i?e.height:e.width,w=()=>i?e.get(t,s):e.get(s,n);for(;s>=0&&w();)s--,o[2]++;for(;s>=0&&!w();)s--,o[1]++;for(;s>=0&&o[0]t&&([e,t]=[t,e]),t-e<=t*n}function V(e,t){let{ratios:n,modules:r}=t,{length:i}=e,s=function(e){let t=0;for(let n of e){if(0===n)return NaN;t+=n}return t}(e);if(s>=r){let t=s/r,o=.625*t+.5;for(let r=0;ro)return!1}return!0}return!1}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class Y{#Y;#c;#h;#N=[];constructor(e,t,n){this.#c=e,this.#h=t,this.#Y=n}get matrix(){return this.#c}get patterns(){return this.#N}match(e,t,n,i){let s=this.#c,o=this.#h,l=Z(n,e),[w,a]=q(s,l,t,i,o,!0);if(w>=0){let e;if([l,e]=q(s,l,w,i,o),l>=0){let t=L(s,l,w,i),n=L(s,l,w,i,!0);if(this.#Y?V(t,o)&&V(n,o):V(t,o)||V(n,o)){let i=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e,t){let{ratios:n,modules:i}=t,s=0,{length:o}=n,l=r(e),w=l/i;for(let t=0;tf.combined(e)>=3&&1.5>=f.noise(e)),{length:n}=e;if(3===n){let t=new C(this.matrix,e),n=C.size(t);n>=21&&n<=177&&(yield t)}else if(n>3){let r=n-2,i=n-1,s=new Map;for(let o=0;o=j&&d<=$){let[o,l]=C.moduleSizes(c);if(o>=1&&l>=1){let{topLeft:w,topRight:u,bottomLeft:d}=c,g=a(w,u),m=a(w,d);if(4>=Math.abs(t(g/o)-t(m/l))){let t=C.size(c);t>=21&&t<=177&&!/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e,t,n){let r=0,{topLeft:i,topRight:s,bottomLeft:o}=e;for(let l of t)if(l!==i&&l!==s&&l!==o){let t;if(n.has(l)&&(t=C.contains(e,l))||1>f.noise(l)&&(null==t?C.contains(e,l):t)&&++r>3)return!0}return!1}(c,e,s)&&(N(h,c)||N(h,c,!0))&&(yield c)&&(s.set(r,!0),s.set(i,!0),s.set(n,!0))}}}}}}}}find(e,t,n,r){let{matrix:i}=this,s=e+n,o=t+r,l=(e,t,n,r,i,s)=>{F(n,r),F(i,s),1===i[0]&&0===i[1]&&1===i[2]&&0===i[3]&&1===i[4]&&V(n,B)&&this.match(e,t,n,n[2])};for(let n=t;n - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class K extends Y{constructor(e,t){super(e,P,t)}filter(e,t){let n=this.patterns.filter(e=>2.5>=f.noise(e)&&G(e.moduleSize,t,.5));n.length>1&&n.sort((n,r)=>{let i=f.noise(n),s=f.noise(r),o=Math.abs(n.moduleSize-t),l=Math.abs(r.moduleSize-t);return(a(n,e)+o)*i-(a(r,e)+l)*s});let r=n.slice(0,2);return r.push(e),r}find(e,t,n,r){let{matrix:i}=this,s=e+n,o=t+r,l=(e,t,n,r,i,s)=>{F(n,r),F(i,s),0===i[0]&&1===i[1]&&0===i[2]&&V(n,U)&&this.match(e,t,n,n[1])};for(let n=t;n=25)for(let s of function(e,t,n){let r=C.size(t),i=/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e){let{x:t,y:n}=e.topLeft,r=1-3/(C.size(e)-7),i=C.bottomRight(e),[s,o]=C.moduleSizes(e);return new f(P,t+(i.x-t)*r,n+(i.y-n)*r,5*s,5*o,0)}(t),s=new K(e,n),o=C.moduleSize(t),{x:l,y:w}=i,a=Math.ceil(o*Math.min(20,0|r/4)),u=0|Math.max(0,w-a),h=0|Math.max(0,l-a),c=0|Math.min(e.width-1,l+a),d=0|Math.min(e.height-1,w+a);return s.find(h,u,c-h,d-u),s.filter(i,o)}(e,r,t)){let t=O(r,s);if(R(e,t,i)&&R(e,t,i,!0)&&(n=yield new S(e,t,r,s)))break}else{let t=O(r);R(e,t,i)&&R(e,t,i,!0)&&(n=yield new S(e,t,r))}o=s.next(n)}}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class W{#K;#Q;#W;#E;#X;#ee;constructor(e,t,{mask:n,level:r},i,s){this.#K=n,this.#Q=r,this.#W=s,this.#E=t,this.#ee=e,this.#X=i}get mask(){return this.#K}get level(){return this.#Q.name}get version(){return this.#E.version}get mirror(){return this.#W}get content(){return this.#ee.content}get corrected(){return this.#X}get symbology(){return this.#ee.symbology}get fnc1(){return this.#ee.fnc1}get codewords(){return this.#ee.codewords}get structured(){return this.#ee.structured}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class X{#et;#en;#er;constructor(e){this.#et=e,this.#en=0,this.#er=0}get bitOffset(){return this.#en}get byteOffset(){return this.#er}read(e){let t=0,n=this.#en,r=this.#er,i=this.#et;if(n>0){let s=8-n,o=Math.min(e,s),l=s-o;e-=o,n+=o,t=(i[r]&255>>8-o<>l,8===n&&(r++,n=0)}if(e>0){for(;e>=8;)e-=8,t=t<<8|255&i[r++];if(e>0){let s=8-e;n+=e,t=t<>s<>s}}return this.#en=n,this.#er=r,t}available(){return 8*(this.#et.length-this.#er)-this.#en}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */let ee=new Map;class et{#r;#ei;static TERMINATOR=new et([0,0,0],0);static NUMERIC=new et([10,12,14],1);static ALPHANUMERIC=new et([9,11,13],2);static STRUCTURED_APPEND=new et([0,0,0],3);static BYTE=new et([8,16,16],4);static ECI=new et([0,0,0],7);static KANJI=new et([8,10,12],8);static FNC1_FIRST_POSITION=new et([0,0,0],5);static FNC1_SECOND_POSITION=new et([0,0,0],9);static HANZI=new et([8,10,12],13);constructor(e,t){this.#r=t,this.#ei=new Int32Array(e),ee.set(t,this)}get bits(){return this.#r}getCharacterCountBits(e){let t,{version:n}=e;return t=n<=9?0:n<=26?1:2,this.#ei[t]}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */let en=new Map;class er{#es;#eo;static CP437=new er("cp437",2,0);static ISO_8859_1=new er("iso-8859-1",3,1);static ISO_8859_2=new er("iso-8859-2",4);static ISO_8859_3=new er("iso-8859-3",5);static ISO_8859_4=new er("iso-8859-4",6);static ISO_8859_5=new er("iso-8859-5",7);static ISO_8859_6=new er("iso-8859-6",8);static ISO_8859_7=new er("iso-8859-7",9);static ISO_8859_8=new er("iso-8859-8",10);static ISO_8859_9=new er("iso-8859-9",11);static ISO_8859_10=new er("iso-8859-10",12);static ISO_8859_11=new er("iso-8859-11",13);static ISO_8859_13=new er("iso-8859-13",15);static ISO_8859_14=new er("iso-8859-14",16);static ISO_8859_15=new er("iso-8859-15",17);static ISO_8859_16=new er("iso-8859-16",18);static SHIFT_JIS=new er("shift-jis",20);static CP1250=new er("cp1250",21);static CP1251=new er("cp1251",22);static CP1252=new er("cp1252",23);static CP1256=new er("cp1256",24);static UTF_16BE=new er("utf-16be",25);static UTF_8=new er("utf-8",26);static ASCII=new er("ascii",27);static BIG5=new er("big5",28);static GB2312=new er("gb2312",29);static EUC_KR=new er("euc-kr",30);static GB18030=new er("gb18030",32);static UTF_16LE=new er("utf-16le",33);static UTF_32BE=new er("utf-32be",34);static UTF_32LE=new er("utf-32le",35);static ISO_646_INV=new er("iso-646-inv",170);static BINARY=new er("binary",899);constructor(e,...t){for(let n of(this.#es=e,this.#eo=Object.freeze(t),t))if(n>=0&&n<=999999&&Number.isInteger(n))en.set(n,this);else throw Error("illegal extended channel interpretation value")}get label(){return this.#es}get values(){return this.#eo}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function ei(e){let t=0,n=new Map;for(let r of e)n.set(r,t++);return n}function es(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r>8,255&n),s.push(n);let{length:w}=s,a=l.decode(new Uint8Array(i));for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:256,i=n.length-1,s=[];for(let o=e;o{let t=1&e.length;return e=e.replace(/%%/g,"%"),t?e.replace(/%$/,"\x1d"):e})}ei(ew);/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */let eu=new Map;class eh{#el;#r;#Q;static L=new eh("L",0,1);static M=new eh("M",1,0);static Q=new eh("Q",2,3);static H=new eh("H",3,2);constructor(e,t,n){this.#r=n,this.#el=e,this.#Q=t,eu.set(n,this)}get bits(){return this.#r}get name(){return this.#el}get level(){return this.#Q}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */let ef=[[21522,0],[20773,1],[24188,2],[23371,3],[17913,4],[16590,5],[20375,6],[19104,7],[30660,8],[29427,9],[32170,10],[30877,11],[26159,12],[25368,13],[27713,14],[26998,15],[5769,16],[5054,17],[7399,18],[6608,19],[1890,20],[597,21],[3340,22],[2107,23],[13663,24],[12392,25],[16177,26],[14854,27],[9396,28],[8579,29],[11994,30],[11245,31]];class ec{#K;#Q;constructor(e){this.#K=7&e,this.#Q=function(e){let t=eu.get(e);if(null!=t)return t;throw Error("illegal error correction bits")}(e>>3&3)}get mask(){return this.#K}get level(){return this.#Q}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function ed(e,t,n,r){return e.get(t,n)?r<<1|1:r<<1}class eg{#z;#c;constructor(e){let{width:t,height:n}=e;this.#c=e.clone(),this.#z=Math.min(t,n)}readVersion(){let e=this.#z,t=0|(e-17)/4;if(t<1)throw Error("illegal version");if(t<=6)return y[t-1];let r=0,i=0,s=e-11,o=this.#c;for(let t=5;t>=0;t--)for(let n=e-9;n>=s;n--)r=ed(o,n,t,r);for(let t=5;t>=0;t--)for(let n=e-9;n>=s;n--)i=ed(o,t,n,i);let l=function(e,t){let r=32,i=0,{length:s}=m;for(let o=0;o=7)return y[i-1];throw Error("unable to decode version")}(r,i);if(l.size>e)throw Error("matrix size too small for version");return l}readFormatInfo(){let e=0,t=0,r=this.#c,i=this.#z,s=i-7;for(let t=0;t<=8;t++)6!==t&&(e=ed(r,t,8,e));for(let t=7;t>=0;t--)6!==t&&(e=ed(r,8,t,e));for(let e=i-1;e>=s;e--)t=ed(r,8,e,t);for(let e=i-8;e6&&(o.setRegion(t-11,0,3,6),o.setRegion(0,t-11,6,3)),o}(e),h=new Uint8Array(a.numTotalCodewords);for(let e=l-1;e>0;e-=2){6===e&&e--;for(let t=0;t - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class em{#ew;#m;constructor(e,t){this.#ew=e,this.#m=t}get codewords(){return this.#ew}get numDataCodewords(){return this.#m}}/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class eb{#ea;#eu;constructor(e,t){let{length:n}=t;if(n<=0)throw Error("polynomial coefficients cannot empty");if(this.#ea=e,n>1&&0===t[0]){let e=1;for(;e=e.getDegree()&&!r.isZero();){let i=r.getDegree(),o=i-e.getDegree(),l=t.multiply(r.getCoefficient(i),s),w=e.multiplyByMonomial(o,l),a=t.buildPolynomial(o,l);n=n.addOrSubtract(a),r=r.addOrSubtract(w)}return[n,r]}}let ey=new /** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */class{#z;#eh;#ef;#ec;#ed;#eg;constructor(e,t,n){let r=1,i=new Int32Array(t);for(let n=0;n=t&&(r^=e,r&=t-1);let s=new Int32Array(t);for(let e=0,n=t-1;e - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e,t,n,r){t.getDegree()=r;){let t=l,n=o;if(l=s,(o=i).isZero())throw Error("remainder last was zero");i=n;let r=e.zero,w=i.getDegree(),a=o.getDegree(),u=o.getCoefficient(a),h=e.invert(u);for(;w>=a&&!i.isZero();){let t=i.getDegree()-a,n=e.multiply(i.getCoefficient(w),h);r=r.addOrSubtract(e.buildPolynomial(t,n)),w=(i=i.addOrSubtract(o.multiplyByMonomial(t,n))).getDegree()}if(s=r.multiply(l).addOrSubtract(t),w>=a)throw Error("division algorithm failed to reduce polynomial")}let w=s.getCoefficient(0);if(0===w)throw Error("sigma tilde(0) was zero");let a=e.invert(w);return[s.multiply(a),i.multiply(a)]}(r,r.buildPolynomial(t,1),n,t),l=function(e,t){let n=t.getDegree();if(1===n)return new Int32Array([t.getCoefficient(1)]);let r=0,{size:i}=e,s=new Int32Array(n);for(let o=1;o - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function eI(e,t,n){let{mask:r,level:i}=n,s=0,o=0;e.unmask(r);let l=t.getECBlocks(i),w=function(e,t,n){let{ecBlocks:r,numTotalCodewords:i,numECCodewordsPerBlock:s}=t.getECBlocks(n);if(e.length!==i)throw Error("failed to get data blocks");let o=[];for(let{count:e,numDataCodewords:t}of r)for(let n=0;n=0&&o[w].codewords.length!==a;)w--;w++;let u=0,h=a-s;for(let t=0;t - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e,t){let n=new Int32Array(e),r=e.length-t,i=new ep().decode(n,r);return[n,i]}(e,t);a.set(n.subarray(0,t),s),o+=r,s+=t}return[a,o]}class ez{#em;constructor({decode:e=ex}={}){this.#em=e}decode(e){let t,n,r,i=0,s=!1,o=new eg(e);try{t=o.readVersion(),r=o.readFormatInfo(),[n,i]=eI(o,t,r)}catch{null!=r&&o.remask(r.mask),o.mirror(),s=!0,t=o.readVersion(),r=o.readFormatInfo(),[n,i]=eI(o,t,r)}return new W(function(e,t,n){let r,i,s,o="",l=-1,w=!1,a=!1,u=!1,h=!1,f=new X(e);do switch(i=4>f.available()?et.TERMINATOR:function(e){let t=ee.get(e);if(null!=t)return t;throw Error("illegal mode bits")}(f.read(4))){case et.TERMINATOR:break;case et.FNC1_FIRST_POSITION:w=!0;break;case et.FNC1_SECOND_POSITION:a=!0,l=f.read(8);break;case et.STRUCTURED_APPEND:if(16>f.available())throw Error("illegal structured append");h=Object.freeze({index:f.read(4),count:f.read(4)+1,parity:f.read(8)});break;case et.ECI:s=/** - * @module QRCode - * @package @nuintun/qrcode - * @license MIT - * @version 4.1.0 - * @author nuintun - * @description A pure JavaScript QRCode encode and decode library. - * @see https://github.com/nuintun/qrcode#readme - */function(e){let t=e.read(8);if((128&t)==0)return 127&t;if((192&t)==128)return(63&t)<<8|e.read(8);if((224&t)==192)return(31&t)<<16|e.read(16);throw Error("illegal extended channel interpretation value")}(f);break;default:if(i===et.HANZI&&1!==f.read(4))throw Error("illegal hanzi subset");let c=f.read(i.getCharacterCountBits(t));switch(i){case et.ALPHANUMERIC:o+=function(e,t,n){let r="";for(;t>1;){if(11>e.available())throw Error("illegal bits length");let n=e.read(11);r+=ew.charAt(n/45)+ew.charAt(n%45),t-=2}if(1===t){if(6>e.available())throw Error("illegal bits length");r+=ew.charAt(e.read(6))}return n?ea(r):r}(f,c,w||a);break;case et.BYTE:o+=function(e,t,n,r,i){if(e.available()<8*t)throw Error("illegal bits length");let s=new Uint8Array(t),o=null!=i?function(e){let t=en.get(e);if(t)return t;throw Error("illegal charset value")}(i):er.ISO_8859_1;for(let n=0;n0;){let i=e.read(13),s=i/96<<8|i%96;s<2560?s+=41377:s+=42657,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("gb2312").decode(r)}(f,c);break;case et.KANJI:o+=function(e,t){if(e.available()<13*t)throw Error("illegal bits length");let n=0,r=new Uint8Array(2*t);for(;t>0;){let i=e.read(13),s=i/192<<8|i%192;s<7936?s+=33088:s+=49472,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("shift-jis").decode(r)}(f,c);break;case et.NUMERIC:o+=function(e,t){let n="";for(;t>=3;){if(10>e.available())throw Error("illegal bits length");let r=e.read(10);if(r>=1e3)throw Error("illegal numeric codeword");n+=el.charAt(r/100)+el.charAt(r/10%10)+el.charAt(r%10),t-=3}if(2===t){if(7>e.available())throw Error("illegal bits length");let t=e.read(7);if(t>=100)throw Error("illegal numeric codeword");n+=el.charAt(t/10)+el.charAt(t%10)}else if(1===t){if(4>e.available())throw Error("illegal bits length");let t=e.read(4);if(t>=10)throw Error("illegal numeric codeword");n+=el.charAt(t)}return n}(f,c);break;default:throw Error("illegal mode")}}while(i!==et.TERMINATOR);return w?u=Object.freeze(["GS1"]):a&&(u=Object.freeze(["AIM",l])),r=null!=s?w?4:a?6:2:w?3:a?5:1,{content:o,codewords:e,structured:h,symbology:`]Q${r}`,fnc1:u}}(n,t,this.#em),t,r,i,s)}}function eE(e){return{x:e.x,y:e.y}}function eC(e){return{x:e.x,y:e.y,moduleSize:e.moduleSize}}self.addEventListener("message",async e=>{let{data:t}=e,{uid:n,image:r}=t,{width:w,height:a}=r,u=new OffscreenCanvas(w,a).getContext("2d");u.drawImage(r,0,0);let h=function(e,t,n){if(e.length!==t*n)throw Error("luminances length must be equals to width * height");return t<40||n<40?function(e,t,n){let r=new i(t,n),s=new Int32Array(32);for(let r=1;r<5;r++){let i=0|4*t/5,o=(0|n*r/5)*t;for(let n=0|t/5;n>3]++}}let o=function(e){let t=0,n=0,r=0,{length:i}=e;for(let s=0;sn&&(t=s,n=e[s]),e[s]>r&&(r=e[s]);let s=0,o=0;for(let n=0;no&&(s=n,o=i)}if(t>s&&([t,s]=[s,t]),s-t<=2)return -1;let l=-1,w=s-1;for(let n=s-1;n>t;n--){let i=n-t,o=i*i*(s-n)*(r-e[n]);o>l&&(w=n,l=o)}return w<<3}(s);if(o>0)for(let i=0;ia&&(a=n)}if(a-u>24)for(n++,r+=t;n<8;n++,r+=t)for(let t=0;t<8;t++)w+=e[r+t]}let f=w>>6;if(a-u<=24&&(f=u/2,n>0&&o>0)){let e=(r[n-1][o]+2*r[n][o-1]+r[n-1][o-1])/4;u>10}}return i}(u.getImageData(0,0,w,a)),w,a);t.invert&&h.flip();let f=new Q({strict:t.strict}).detect(h),c=[],d=new ez,g=f.next();for(;!g.done;){let e=!1,t=g.value;try{let{size:n,finder:r,alignment:i}=t,s=d.decode(t.matrix),{topLeft:o,topRight:l,bottomLeft:w}=r,a=t.mapping(0,0),u=t.mapping(n,0),h=t.mapping(n,n),f=t.mapping(0,n),g=t.mapping(6.5,6.5),m=t.mapping(n-6.5,6.5),b=t.mapping(6.5,n-6.5);c.push({fnc1:s.fnc1,mask:s.mask,level:s.level,mirror:s.mirror,content:s.content,version:s.version,corrected:s.corrected,symbology:s.symbology,structured:s.structured,alignment:i?eC(i):null,finder:[eC(o),eC(l),eC(w)],timing:[eE(g),eE(m),eE(b)],corners:[eE(a),eE(u),eE(h),eE(f)]}),e=!0}catch{}g=f.next(e)}c.length>0?self.postMessage({type:"ok",payload:{uid:n,image:r,items:c}},[r]):self.postMessage({type:"error",message:"未发现二维码"})})}(); \ No newline at end of file diff --git a/packages/examples/static/public/js/9749a08166d51ee7.js b/packages/examples/static/public/js/c9a6fac6153c0fe3.js similarity index 93% rename from packages/examples/static/public/js/9749a08166d51ee7.js rename to packages/examples/static/public/js/c9a6fac6153c0fe3.js index 15e28866..aa95ca15 100644 --- a/packages/examples/static/public/js/9749a08166d51ee7.js +++ b/packages/examples/static/public/js/c9a6fac6153c0fe3.js @@ -30,7 +30,7 @@ * @author nuintun * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function a(e){let t=0,n=new Map;for(let r of e)n.set(r,t++);return n}function c(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r>8,255&n),i.push(n);let{length:l}=i,a=o.decode(new Uint8Array(w));for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:256,w=n.length-1,i=[];for(let s=e;s1?t-1:0),r=1;r>8,255&n),i.push(n);let{length:l}=i,a=o.decode(new Uint8Array(w));for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:256,w=n.length-1,i=[];for(let s=e;s * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function b(e){let t=d.get(e);if(null!=t)return t;throw Error(`illegal numeric character: ${e}`)}class y{#s;constructor(e){l(e),this.#s=e}get mode(){return t.NUMERIC}get content(){return this.#s}encode(){let e=new i,t=this.#s,{length:n}=t;for(let r=0;r * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function I(e){let t=p.get(e);if(null!=t)return t;throw Error(`illegal alphanumeric character: ${e}`)}class m{#s;constructor(e){l(e),this.#s=e}get mode(){return t.ALPHANUMERIC}get content(){return this.#s}encode(){let e=new i,t=this.#s,{length:n}=t;for(let r=0;r * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function(e){let t=u.get(e);return null!=t?t:NaN}(t);if(n>=41377&&n<=43774)n-=41377;else if(n>=45217&&n<=64254)n-=42657;else throw Error(`illegal hanzi character: ${t}`);n=(n>>8)*96+(255&n),e.append(n,13)}return e}}class A{#s;constructor(e){l(e),this.#s=e}get mode(){return t.KANJI}get content(){return this.#s}encode(){let e=new i;for(let t of this.#s){let n=/** + */function(e){let t=u.get(e);return null!=t?t:NaN}(t);if(n>=41377&&n<=43774)n-=41377;else if(n>=45217&&n<=64254)n-=42657;else throw Error(`illegal hanzi character: ${t}`);n=(n>>8)*96+(255&n),e.append(n,13)}return e}}class _{#s;constructor(e){l(e),this.#s=e}get mode(){return t.KANJI}get content(){return this.#s}encode(){let e=new i;for(let t of this.#s){let n=/** * @module QRCode * @package @nuintun/qrcode * @license MIT @@ -78,7 +78,7 @@ * @author nuintun * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */class _{#s;#o;constructor(e,t=o.ISO_8859_1){l(e),function(e){if(!(e instanceof o))throw Error("illegal charset")}(t),this.#s=e,this.#o=t}get mode(){return t.BYTE}get content(){return this.#s}get charset(){return this.#o}encode(e){let t=new i;for(let n of e(this.#s,this.#o))t.append(n,8);return t}}function E(e,t,n){return 1===e.get(t,n)}function B(e,t){let n=0,{size:r}=e;for(let w=0;w=5&&(n+=3+(s-5)),i=r,s=1)}s>=5&&(n+=3+(s-5))}return n}function S(e,t,n,r,w){if(n<0||r>e.size)return!1;for(let i=n;i=5&&(n+=3+(s-5)),i=r,s=1)}s>=5&&(n+=3+(s-5))}return n}function S(e,t,n,r,w){if(n<0||r>e.size)return!1;for(let i=n;i * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */class H{#C;#A;constructor(e,t){let{length:n}=t;if(n<=0)throw Error("polynomial coefficients cannot empty");if(this.#C=e,n>1&&0===t[0]){let e=1;for(;e=e.getDegree()&&!r.isZero();){let w=r.getDegree(),s=w-e.getDegree(),o=t.multiply(r.getCoefficient(w),i),l=e.multiplyByMonomial(s,o),a=t.buildPolynomial(s,o);n=n.addOrSubtract(a),r=r.addOrSubtract(l)}return[n,r]}}let Z=new /** + */class H{#C;#_;constructor(e,t){let{length:n}=t;if(n<=0)throw Error("polynomial coefficients cannot empty");if(this.#C=e,n>1&&0===t[0]){let e=1;for(;e=e.getDegree()&&!r.isZero();){let w=r.getDegree(),s=w-e.getDegree(),o=t.multiply(r.getCoefficient(w),i),l=e.multiplyByMonomial(s,o),a=t.buildPolynomial(s,o);n=n.addOrSubtract(a),r=r.addOrSubtract(l)}return[n,r]}}let Z=new /** * @module QRCode * @package @nuintun/qrcode * @license MIT @@ -126,7 +126,7 @@ * @author nuintun * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */class{#l;#_;#E;#B;#S;#v;constructor(e,t,n){let r=1,w=new Int32Array(t);for(let n=0;n=t&&(r^=e,r&=t-1);let i=new Int32Array(t);for(let e=0,n=t-1;e=t&&(r^=e,r&=t-1);let i=new Int32Array(t);for(let e=0,n=t-1;e * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function(e,t,n){let{length:r}=t;if(n>=r){let{generator:w}=e,i=t[r-1];for(let s=r;s<=n;s++){let n=new Int32Array([1,e.exp(s-1+w)]),r=i.multiply(new H(e,n));t.push(r),i=r}}return t[n]}(this.#C,this.#T,t);r.set(e.subarray(0,n));let[,i]=new H(this.#C,r).multiplyByMonomial(t,1).divide(w),{coefficients:s}=i,o=n+(t-s.length);e.fill(0,n,o),e.set(s,o)}}function j(e){return e.mode===t.BYTE}function K(e,t){e.append(t.bits,4)}function Y(e,t,n){return t.getECBlocks(n).numTotalDataCodewords>=Math.ceil(e/8)}function J(e,t){for(let n of N)if(Y(e,n,t))return n;throw Error("data too big for all versions")}function Q(e,t){let n=0;for(let{mode:r,head:w,data:i}of e)n+=w.length+r.getCharacterCountBits(t)+i.length;return n}class V{#O;#z;#e;#M;#l;#N;#k;constructor(e){let t=1<4095)return!1;this.#k.set(e<<8|t,n++);let r=this.#e,w=this.#l;return n>w&&(w=1<<++r),this.#e=r,this.#l=w,this.#N=n,!0}get(e,t){return this.#k.get(e<<8|t)}}/** + */function(e,t,n){let{length:r}=t;if(n>=r){let{generator:w}=e,i=t[r-1];for(let s=r;s<=n;s++){let n=new Int32Array([1,e.exp(s-1+w)]),r=i.multiply(new H(e,n));t.push(r),i=r}}return t[n]}(this.#C,this.#T,t);r.set(e.subarray(0,n));let[,i]=new H(this.#C,r).multiplyByMonomial(t,1).divide(w),{coefficients:s}=i,o=n+(t-s.length);e.fill(0,n,o),e.set(s,o)}}function j(e){return e.mode===t.BYTE}function K(e,t){e.append(t.bits,4)}function Y(e,t,n){return t.getECBlocks(n).numTotalDataCodewords>=Math.ceil(e/8)}function J(e,t){for(let n of N)if(Y(e,n,t))return n;throw Error("data too big for all versions")}function Q(e,t){let n=0;for(let{mode:r,head:w,body:i}of e)n+=w.length+r.getCharacterCountBits(t)+i.length;return n}class V{#O;#z;#e;#M;#l;#N;#k;constructor(e){let t=1<4095)return!1;this.#k.set(e<<8|t,n++);let r=this.#e,w=this.#l;return n>w&&(w=1<<++r),this.#e=r,this.#l=w,this.#N=n,!0}get(e,t){return this.#k.get(e<<8|t)}}/** * @module QRCode * @package @nuintun/qrcode * @license MIT @@ -206,7 +206,7 @@ * @author nuintun * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */class el{#Y;#G;#H;#b;constructor({hints:e={},level:t="L",version:n="Auto",encode:r=eo}={}){!function(e){let{fnc1:t}=e;if(null!=t){let[e]=t;if("GS1"!==e&&"AIM"!==e)throw Error("illegal fn1 hint");if("AIM"===e){let[,e]=t;if(e<0||e>255||!Number.isInteger(e))throw Error("illegal fn1 application indicator")}}}(e),function(e){if(0>["L","M","Q","H"].indexOf(e))throw Error("illegal error correction level")}(t),function(e){if("Auto"!==e&&(e<1||e>40||!Number.isInteger(e)))throw Error("illegal version")}(n),this.#Y=e,this.#H=r,this.#b=n,this.#G=ei[t]}encode(){let e;for(var n=arguments.length,r=Array(n),w=0;w0)for(let t=r;t<8;t++)e.append(0);let w=t-e.byteLength;for(let t=0;t255||!Number.isInteger(e))throw Error("illegal fn1 application indicator")}}}(e),function(e){if(0>["L","M","Q","H"].indexOf(e))throw Error("illegal error correction level")}(t),function(e){if("Auto"!==e&&(e<1||e>40||!Number.isInteger(e)))throw Error("illegal version")}(n),this.#Y=e,this.#H=r,this.#b=n,this.#G=ei[t]}encode(){let e;for(var n=arguments.length,r=Array(n),w=0;w0)for(let t=r;t<8;t++)e.append(0);let w=t-e.byteLength;for(let t=0;t * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function(e,t){let n=e.length,r=new Int32Array(n+t);return r.set(e),new G().encode(r,t),new Uint8Array(r.subarray(n))}(t,r);l.push(new $(t,n)),o+=i,w=Math.max(w,n.length),s=Math.max(s,i)}let a=new i;for(let e=0;e>16&255,t>>8&255,255&t]}self.addEventListener("message",e=>{let{data:t}=e,{level:n,version:r}=t,w=new el({level:n,version:r,hints:function(e){let{fnc1:t,aimIndicator:n}=e;switch(t){case"GS1":return{fnc1:["GS1"]};case"AIM":return{fnc1:["AIM",+n]}}}(t)});try{let e=w.encode(function(e){let{mode:t,content:n,charset:r}=e;switch(t){case"Auto":if(/^\d+$/.test(n))return new y(n);if(/^[0-9A-Z$%*+-./: ]+$/.test(n))return new m(n);let w=new C(n);try{return w.encode(),w}catch{}let i=new A(n);try{return i.encode(),i}catch{}return new _(n,o[r]);case"Hanzi":return new C(n);case"Kanji":return new A(n);case"Numeric":return new y(n);case"Alphanumeric":return new m(n);default:return new _(n,o[r])}}(t)),{moduleSize:n,quietZone:r,background:i,foreground:s}=t,l={type:"ok",payload:e.toDataURL(n,{margin:r,background:ea(i),foreground:ea(s)})};self.postMessage(l)}catch(t){let e={type:"error",message:t.message};self.postMessage(e)}})}(); \ No newline at end of file + */function(e,t){let n=e.length,r=new Int32Array(n+t);return r.set(e),new G().encode(r,t),new Uint8Array(r.subarray(n))}(t,r);l.push(new $(t,n)),o+=i,w=Math.max(w,n.length),s=Math.max(s,i)}let a=new i;for(let e=0;e>16&255,t>>8&255,255&t]}self.addEventListener("message",e=>{let{data:t}=e,{level:n,version:r}=t,w=new el({level:n,version:r,hints:function(e){let{fnc1:t,aimIndicator:n}=e;switch(t){case"GS1":return{fnc1:["GS1"]};case"AIM":return{fnc1:["AIM",+n]}}}(t)});try{let e=w.encode(function(e){let{mode:t,content:n,charset:r}=e;switch(t){case"Auto":if(/^\d+$/.test(n))return new y(n);if(/^[0-9A-Z$%*+-./: ]+$/.test(n))return new m(n);let w=new C(n);try{return w.encode(),w}catch{}let i=new _(n);try{return i.encode(),i}catch{}return new A(n,o[r]);case"Hanzi":return new C(n);case"Kanji":return new _(n);case"Numeric":return new y(n);case"Alphanumeric":return new m(n);default:return new A(n,o[r])}}(t)),{moduleSize:n,quietZone:r,background:i,foreground:s}=t,l={type:"ok",payload:e.toDataURL(n,{margin:r,background:ea(i),foreground:ea(s)})};self.postMessage(l)}catch(t){let e={type:"error",message:t.message};self.postMessage(e)}})}(); \ No newline at end of file diff --git a/packages/examples/static/public/js/edb519fb71c4d139.js b/packages/examples/static/public/js/edb519fb71c4d139.js new file mode 100644 index 00000000..e4db7cd8 --- /dev/null +++ b/packages/examples/static/public/js/edb519fb71c4d139.js @@ -0,0 +1,265 @@ +!function(){"use strict";var e;function t(e){return 0|e+(e<0?-.5:.5)}function n(e,t){let n=e.at(t);return null!=n?n:""}function r(e){return e-=e>>1&1431655765,((e=(858993459&e)+(e>>2&858993459))+(e>>4)&252645135)*16843009>>24}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0;for(let i=t;i + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class s{#e;#t;#n;#r;constructor(e,t,n){let r=Math.ceil(e/32),i=r*t;if(this.#e=e,this.#t=t,this.#n=r,n instanceof Int32Array){if(n.length!==i)throw Error(`matrix bits capacity mismatch: ${i}`);this.#r=n}else this.#r=new Int32Array(i)}#i(e,t){return t*this.#n+(0|e/32)}get width(){return this.#e}get height(){return this.#t}set(e,t){let n=this.#i(e,t);this.#r[n]|=1<<(31&e)}get(e,t){let n=this.#i(e,t);return this.#r[n]>>>(31&e)&1}flip(e,t){if(null!=e&&null!=t){let n=this.#i(e,t);this.#r[n]^=1<<(31&e)}else{let e=this.#r,{length:t}=e;for(let n=0;n>3;return 7&e&&t++,t}function o(e,t){return e<2?2:Math.min(e,t)}function w(e,t){return(e<<=3)>t?t:e}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class a{#s;#l;constructor(e,t){this.#s=e,this.#l=t}get x(){return this.#s}get y(){return this.#l}}function u(e,t){return Math.sqrt(f(e,t))}function f(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function h(e,t,n){let{x:r,y:i}=e,{x:s,y:l}=t,{x:o,y:w}=n;return Math.abs(r*(l-w)+s*(w-i)+o*(i-l))/2}class c extends a{#o;#e;#t;#w;#a;#u=1;#f;#h;static noise(e){return e.#o}static width(e){return e.#e}static height(e){return e.#t}static combined(e){return e.#u}static rect(e){return e.#w}static equals(e,t,n,r,i){let{modules:s}=e.#f,l=e.#h;if(Math.abs(t-e.x)<=l&&Math.abs(n-e.y)<=l){let t=e.#a,n=Math.abs((r+i)/s/2-t);if(n<=1||n<=t)return!0}return!1}static combine(e,t,n,r,i,s){let l=e.#u,o=l+1,w=(e.x*l+t)/o,a=(e.y*l+n)/o,u=(e.#o*l+s)/o,f=(e.#e*l+r)/o,h=(e.#t*l+i)/o,d=new c(e.#f,w,a,f,h,u);return d.#u=o,d}constructor(e,t,n,r,i,s){super(t,n);let{modules:l}=e,o=r/2,w=i/2,a=r/l,u=i/l,f=a/2,h=u/2,c=/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e){let{ratios:t}=e;return t[0|t.length/2]/2}(e),d=(a+u)/2;this.#o=s,this.#e=r,this.#t=i,this.#f=e,this.#a=d,this.#w=[t-o+f,n-w+h,t+o-f,n+w-h],this.#h=d*c}get moduleSize(){return this.#a}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class d{#c;#d;constructor(e,t){this.#c=e,this.#d=t}sample(e,t){let n=this.#c,r=n.width,i=this.#d,l=n.height,o=new s(e,t);for(let s=0;s=0&&u>=0&&a + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class g{#g;#m;constructor(e,t){this.#g=e,this.#m=t}get count(){return this.#g}get numDataCodewords(){return this.#m}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class m{#b;#y;#p;#x;#I;constructor(e,...t){let n=0,r=0;for(let{count:e,numDataCodewords:i}of t)n+=e,r+=i*e;let i=e*n;this.#b=t,this.#p=i,this.#x=r,this.#I=e,this.#y=r+i}get ecBlocks(){return this.#b}get numTotalCodewords(){return this.#y}get numTotalECCodewords(){return this.#p}get numTotalDataCodewords(){return this.#x}get numECCodewordsPerBlock(){return this.#I}}let b=[31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017];class y{#z;#E;#b;#C;constructor(e,t,...n){this.#E=e,this.#b=n,this.#z=17+4*e,this.#C=t}get size(){return this.#z}get version(){return this.#E}get alignmentPatterns(){return this.#C}getECBlocks(e){let{level:t}=e;return this.#b[t]}}let p=[new y(1,[],new m(7,new g(1,19)),new m(10,new g(1,16)),new m(13,new g(1,13)),new m(17,new g(1,9))),new y(2,[6,18],new m(10,new g(1,34)),new m(16,new g(1,28)),new m(22,new g(1,22)),new m(28,new g(1,16))),new y(3,[6,22],new m(15,new g(1,55)),new m(26,new g(1,44)),new m(18,new g(2,17)),new m(22,new g(2,13))),new y(4,[6,26],new m(20,new g(1,80)),new m(18,new g(2,32)),new m(26,new g(2,24)),new m(16,new g(4,9))),new y(5,[6,30],new m(26,new g(1,108)),new m(24,new g(2,43)),new m(18,new g(2,15),new g(2,16)),new m(22,new g(2,11),new g(2,12))),new y(6,[6,34],new m(18,new g(2,68)),new m(16,new g(4,27)),new m(24,new g(4,19)),new m(28,new g(4,15))),new y(7,[6,22,38],new m(20,new g(2,78)),new m(18,new g(4,31)),new m(18,new g(2,14),new g(4,15)),new m(26,new g(4,13),new g(1,14))),new y(8,[6,24,42],new m(24,new g(2,97)),new m(22,new g(2,38),new g(2,39)),new m(22,new g(4,18),new g(2,19)),new m(26,new g(4,14),new g(2,15))),new y(9,[6,26,46],new m(30,new g(2,116)),new m(22,new g(3,36),new g(2,37)),new m(20,new g(4,16),new g(4,17)),new m(24,new g(4,12),new g(4,13))),new y(10,[6,28,50],new m(18,new g(2,68),new g(2,69)),new m(26,new g(4,43),new g(1,44)),new m(24,new g(6,19),new g(2,20)),new m(28,new g(6,15),new g(2,16))),new y(11,[6,30,54],new m(20,new g(4,81)),new m(30,new g(1,50),new g(4,51)),new m(28,new g(4,22),new g(4,23)),new m(24,new g(3,12),new g(8,13))),new y(12,[6,32,58],new m(24,new g(2,92),new g(2,93)),new m(22,new g(6,36),new g(2,37)),new m(26,new g(4,20),new g(6,21)),new m(28,new g(7,14),new g(4,15))),new y(13,[6,34,62],new m(26,new g(4,107)),new m(22,new g(8,37),new g(1,38)),new m(24,new g(8,20),new g(4,21)),new m(22,new g(12,11),new g(4,12))),new y(14,[6,26,46,66],new m(30,new g(3,115),new g(1,116)),new m(24,new g(4,40),new g(5,41)),new m(20,new g(11,16),new g(5,17)),new m(24,new g(11,12),new g(5,13))),new y(15,[6,26,48,70],new m(22,new g(5,87),new g(1,88)),new m(24,new g(5,41),new g(5,42)),new m(30,new g(5,24),new g(7,25)),new m(24,new g(11,12),new g(7,13))),new y(16,[6,26,50,74],new m(24,new g(5,98),new g(1,99)),new m(28,new g(7,45),new g(3,46)),new m(24,new g(15,19),new g(2,20)),new m(30,new g(3,15),new g(13,16))),new y(17,[6,30,54,78],new m(28,new g(1,107),new g(5,108)),new m(28,new g(10,46),new g(1,47)),new m(28,new g(1,22),new g(15,23)),new m(28,new g(2,14),new g(17,15))),new y(18,[6,30,56,82],new m(30,new g(5,120),new g(1,121)),new m(26,new g(9,43),new g(4,44)),new m(28,new g(17,22),new g(1,23)),new m(28,new g(2,14),new g(19,15))),new y(19,[6,30,58,86],new m(28,new g(3,113),new g(4,114)),new m(26,new g(3,44),new g(11,45)),new m(26,new g(17,21),new g(4,22)),new m(26,new g(9,13),new g(16,14))),new y(20,[6,34,62,90],new m(28,new g(3,107),new g(5,108)),new m(26,new g(3,41),new g(13,42)),new m(30,new g(15,24),new g(5,25)),new m(28,new g(15,15),new g(10,16))),new y(21,[6,28,50,72,94],new m(28,new g(4,116),new g(4,117)),new m(26,new g(17,42)),new m(28,new g(17,22),new g(6,23)),new m(30,new g(19,16),new g(6,17))),new y(22,[6,26,50,74,98],new m(28,new g(2,111),new g(7,112)),new m(28,new g(17,46)),new m(30,new g(7,24),new g(16,25)),new m(24,new g(34,13))),new y(23,[6,30,54,78,102],new m(30,new g(4,121),new g(5,122)),new m(28,new g(4,47),new g(14,48)),new m(30,new g(11,24),new g(14,25)),new m(30,new g(16,15),new g(14,16))),new y(24,[6,28,54,80,106],new m(30,new g(6,117),new g(4,118)),new m(28,new g(6,45),new g(14,46)),new m(30,new g(11,24),new g(16,25)),new m(30,new g(30,16),new g(2,17))),new y(25,[6,32,58,84,110],new m(26,new g(8,106),new g(4,107)),new m(28,new g(8,47),new g(13,48)),new m(30,new g(7,24),new g(22,25)),new m(30,new g(22,15),new g(13,16))),new y(26,[6,30,58,86,114],new m(28,new g(10,114),new g(2,115)),new m(28,new g(19,46),new g(4,47)),new m(28,new g(28,22),new g(6,23)),new m(30,new g(33,16),new g(4,17))),new y(27,[6,34,62,90,118],new m(30,new g(8,122),new g(4,123)),new m(28,new g(22,45),new g(3,46)),new m(30,new g(8,23),new g(26,24)),new m(30,new g(12,15),new g(28,16))),new y(28,[6,26,50,74,98,122],new m(30,new g(3,117),new g(10,118)),new m(28,new g(3,45),new g(23,46)),new m(30,new g(4,24),new g(31,25)),new m(30,new g(11,15),new g(31,16))),new y(29,[6,30,54,78,102,126],new m(30,new g(7,116),new g(7,117)),new m(28,new g(21,45),new g(7,46)),new m(30,new g(1,23),new g(37,24)),new m(30,new g(19,15),new g(26,16))),new y(30,[6,26,52,78,104,130],new m(30,new g(5,115),new g(10,116)),new m(28,new g(19,47),new g(10,48)),new m(30,new g(15,24),new g(25,25)),new m(30,new g(23,15),new g(25,16))),new y(31,[6,30,56,82,108,134],new m(30,new g(13,115),new g(3,116)),new m(28,new g(2,46),new g(29,47)),new m(30,new g(42,24),new g(1,25)),new m(30,new g(23,15),new g(28,16))),new y(32,[6,34,60,86,112,138],new m(30,new g(17,115)),new m(28,new g(10,46),new g(23,47)),new m(30,new g(10,24),new g(35,25)),new m(30,new g(19,15),new g(35,16))),new y(33,[6,30,58,86,114,142],new m(30,new g(17,115),new g(1,116)),new m(28,new g(14,46),new g(21,47)),new m(30,new g(29,24),new g(19,25)),new m(30,new g(11,15),new g(46,16))),new y(34,[6,34,62,90,118,146],new m(30,new g(13,115),new g(6,116)),new m(28,new g(14,46),new g(23,47)),new m(30,new g(44,24),new g(7,25)),new m(30,new g(59,16),new g(1,17))),new y(35,[6,30,54,78,102,126,150],new m(30,new g(12,121),new g(7,122)),new m(28,new g(12,47),new g(26,48)),new m(30,new g(39,24),new g(14,25)),new m(30,new g(22,15),new g(41,16))),new y(36,[6,24,50,76,102,128,154],new m(30,new g(6,121),new g(14,122)),new m(28,new g(6,47),new g(34,48)),new m(30,new g(46,24),new g(10,25)),new m(30,new g(2,15),new g(64,16))),new y(37,[6,28,54,80,106,132,158],new m(30,new g(17,122),new g(4,123)),new m(28,new g(29,46),new g(14,47)),new m(30,new g(49,24),new g(10,25)),new m(30,new g(24,15),new g(46,16))),new y(38,[6,32,58,84,110,136,162],new m(30,new g(4,122),new g(18,123)),new m(28,new g(13,46),new g(32,47)),new m(30,new g(48,24),new g(14,25)),new m(30,new g(42,15),new g(32,16))),new y(39,[6,26,54,82,110,138,166],new m(30,new g(20,117),new g(4,118)),new m(28,new g(40,47),new g(7,48)),new m(30,new g(43,24),new g(22,25)),new m(30,new g(10,15),new g(67,16))),new y(40,[6,30,58,86,114,142,170],new m(30,new g(19,118),new g(6,119)),new m(28,new g(18,47),new g(31,48)),new m(30,new g(34,24),new g(34,25)),new m(30,new g(20,15),new g(61,16)))];/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class x{#S;#v;#O;#k;#M;#A;constructor(e,t){let n=0|t.x,r=0|t.y,i=0|e.x,s=0|e.y,l=Math.abs(r-s)>Math.abs(n-i);l&&([i,s,n,r]=[s,i,r,n]);let o=i0){if(f===n)break;f+=i,a-=s}}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function I(e,t,n){let r=0,{width:i,height:s}=e,l=new a((t.x+n.x)/2,(t.y+n.y)/2);for(let[n,o]of new x(t,l).points()){if(n<0||o<0||n>=i||o>=s){if(2===r)return u(t,new a(n,o));break}if(1===r==(1===e.get(n,o))){if(2===r)return u(t,new a(n,o));r++}}return NaN}function z(e,t,n){let r=I(e,t,n);if(Number.isNaN(r))return NaN;let{x:i,y:s}=n,{x:l,y:o}=t,w=I(e,t,new a(l-(i-l),o-(s-o)));return Number.isNaN(w)?NaN:r+w-1}function E(e,t,n){let r=new a(0|t.x,0|t.y),i=new a(0|n.x,0|n.y),s=z(e,r,i),l=z(e,i,r);return Number.isNaN(s)?l/7:Number.isNaN(l)?s/7:(s+l)/14}function C(e,t){var n,r,i,s;let l=Math.max((n=c.width(e))>(r=c.width(t))?n/r:r/n,(i=c.height(e))>(s=c.height(t))?i/s:s/i);return l*l}class S{#T;#z;#c;#_;#a;#N;#R;static moduleSizes(e){if(null==e.#R){let t=e.#c,[n,r,i]=e.#N;e.#R=[E(t,n,r),E(t,n,i)]}return e.#R}static size(n){if(null==n.#z){let r=e.moduleSize(n);n.#z=function(e,n){let[r,i,s]=e,l=t((u(r,i)+u(r,s))/n/2)+7;switch(3&l){case 0:return l+1;case 2:return l-1;case 3:return Math.min(l+2,177)}return l}(n.#N,r)}return n.#z}static moduleSize(t){return null==t.#a&&(t.#a=i(e.moduleSizes(t))/2),t.#a}static contains(t,n){let r=t.#D(),[i,s,l]=t.#N,o=e.bottomRight(t),w=h(i,s,n);return w+h(s,o,n)+h(o,l,n)+h(l,i,n)-r<1}static bottomRight(e){return null==e.#_&&(e.#_=function(e){let[t,n,r]=e,{x:i,y:s}=t;return new a(n.x+r.x-i,n.y+r.y-s)}(e.#N)),e.#_}constructor(e,t){this.#c=e,this.#N=function(e){let t,n,r;let[i,s,l]=e,o=f(i,s)*C(i,s),w=f(i,l)*C(i,l),a=f(s,l)*C(s,l);return a>=o&&a>=w?[t,r,n]=e:w>=a&&w>=o?[r,t,n]=e:[r,n,t]=e,0>function(e,t,n){let{x:r,y:i}=t;return(n.x-r)*(e.y-i)-(n.y-i)*(e.x-r)}(r,t,n)&&([r,n]=[n,r]),[t,n,r]}(t)}get topLeft(){return this.#N[0]}get topRight(){return this.#N[1]}get bottomLeft(){return this.#N[2]}#D(){let[t,n,r]=this.#N,i=e.bottomRight(this);if(null==this.#T){let e=h(t,n,i),s=h(i,r,t);this.#T=e+s}return this.#T}}e=S;/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class v{#c;#B;#P;#d;constructor(e,t,n,r){let i=new d(e,t),s=S.size(n);this.#c=e,this.#d=t,this.#P=n,this.#B=r,this.#c=i.sample(s,s)}get matrix(){return this.#c}get finder(){return this.#P}get alignment(){return this.#B}get size(){return S.size(this.#P)}get moduleSize(){return S.moduleSize(this.#P)}mapping(e,t){return[e,t]=this.#d.mapping(e,t),new a(e,t)}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class O{#U;#F;#L;#Z;#H;#j;#$;#q;#G;constructor(e,t,n,r,i,s,l,o,w){this.#U=e,this.#F=r,this.#L=l,this.#Z=t,this.#H=i,this.#j=o,this.#$=n,this.#q=s,this.#G=w}inverse(){let e=this.#U,t=this.#F,n=this.#L,r=this.#Z,i=this.#H,s=this.#j,l=this.#$,o=this.#q,w=this.#G;return new O(i*w-s*o,s*l-r*w,r*o-i*l,n*o-t*w,e*w-n*l,t*l-e*o,t*s-n*i,n*r-e*s,e*i-t*r)}times(e){let t=this.#U,n=this.#F,r=this.#L,i=this.#Z,s=this.#H,l=this.#j,o=this.#$,w=this.#q,a=this.#G,u=e.#U,f=e.#F,h=e.#L,c=e.#Z,d=e.#H,g=e.#j,m=e.#$,b=e.#q,y=e.#G;return new O(t*u+i*f+o*h,t*c+i*d+o*g,t*m+i*b+o*y,n*u+s*f+w*h,n*c+s*d+w*g,n*m+s*b+w*y,r*u+l*f+a*h,r*c+l*d+a*g,r*m+l*b+a*y)}mapping(e,t){let n=this.#U,r=this.#F,i=this.#L,s=this.#Z,l=this.#H,o=this.#j,w=this.#$,a=this.#q,u=i*e+o*t+this.#G;return[(n*e+s*t+w)/u,(r*e+l*t+a)/u]}}function k(e,t,n,r,i,s,l,o){let w=e-n+i-l,a=t-r+s-o;if(0===w&&0===a)return new O(n-e,i-n,e,r-t,s-r,t,0,0,1);{let u=n-i,f=l-i,h=r-s,c=o-s,d=u*c-f*h,g=(w*c-f*a)/d,m=(u*a-w*h)/d;return new O(n-e+g*n,l-e+m*l,e,r-t+g*r,o-t+m*o,t,g,m,1)}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function M(e,t){let n,r,i,s;let{x:l,y:o}=e.topLeft,{x:w,y:a}=e.topRight,{x:u,y:f}=e.bottomLeft,h=S.size(e)-3.5;return null!=t?(n=t.x,r=t.y,s=i=h-3):(n=w+u-l,r=a+f-o,i=h,s=h),function(e,t,n,r,i,s,l,o,w,a,u,f,h,c,d,g){let m=k(3.5,3.5,n,3.5,i,s,3.5,o).inverse();return k(w,a,u,f,h,c,d,g).times(m)}(0,0,h,0,i,s,0,h,l,o,w,a,n,r,u,f)}function A(e,t){let[n,,r]=c.rect(e);return t>0?r:t<0?n:e.x}function T(e,t){let[,n,,r]=c.rect(e);return t>0?r:t<0?n:e.y}function _(e,t,n,r){let{x:i,y:s}=t,{x:l,y:o}=e,{x:w,y:u}=n,f=w>i?1:ws?1:ui))return!1}return l>=r-14-Math.max(2,(r-17)/4)}function R(e,t,n){let{topLeft:r,topRight:i,bottomLeft:s}=t,[l,o]=n?_(r,s,i,!0):_(r,i,s);return N(e,l,o,S.size(t))}function D(e,t,n,r){let[i,s]=t.mapping(r?6.5:7.5,r?7.5:6.5),[l,o]=t.mapping(r?6.5:n-7.5,r?n-7.5:6.5);return N(e,new a(i,s),new a(l,o),n)}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class B{#V;#f;constructor(e){this.#f=e,this.#V=i(e)}get modules(){return this.#V}get ratios(){return this.#f}}let P=new B([1,1,3,1,1]),U=new B([1,1,1,1,1]),F=new B([1,1,1]);function L(e,t){let{length:n}=e,r=n-1;for(let t=0;t{l+=s,o-=s*f},c=()=>e.get(l,o);for(;l>=0&&o>=0&&o=0&&o>=0&&o=0&&o>=0&&o=0&&o=0&&o=0&&o + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */let j=Math.PI/180,$=40*j,q=140*j;function G(e,t,n,r,i,s){let[l,o]=function(e,t,n,r,i){t|=0,n|=0;let s=i?n:t,l=[0,0,0,0,0],o=i?e.height:e.width,w=()=>i?e.get(t,s):e.get(s,n);for(;s>=0&&w();)s--,l[2]++;for(;s>=0&&!w();)s--,l[1]++;for(;s>=0&&l[0]t&&([e,t]=[t,e]),t-e<=t*n}function Y(e,t){let{ratios:n,modules:r}=t,{length:i}=e,s=function(e){let t=0;for(let n of e){if(0===n)return NaN;t+=n}return t}(e);if(s>=r){let t=s/r,l=.625*t+.5;for(let r=0;rl)return!1}return!0}return!1}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class J{#Y;#c;#f;#N=[];constructor(e,t,n){this.#c=e,this.#f=t,this.#Y=n}get matrix(){return this.#c}get patterns(){return this.#N}match(e,t,n,r){let s=this.#c,l=this.#f,o=H(n,e),[w,a]=G(s,o,t,r,l,!0);if(w>=0){let e;if([o,e]=G(s,o,w,r,l),o>=0){let t=Z(s,o,w,r),n=Z(s,o,w,r,!0);if(this.#Y?Y(t,l)&&Y(n,l):Y(t,l)||Y(n,l)){let r=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e,t){let{ratios:n,modules:r}=t,s=0,{length:l}=n,o=i(e),w=o/r;for(let t=0;tc.combined(e)>=3&&1.5>=c.noise(e)),{length:n}=e;if(3===n){let t=new S(this.matrix,e),n=S.size(t);n>=21&&n<=177&&(yield t)}else if(n>3){let r=n-2,i=n-1,s=new Map;for(let l=0;l=$&&d<=q){let[l,o]=S.moduleSizes(h);if(l>=1&&o>=1){let{topLeft:w,topRight:a,bottomLeft:d}=h,g=u(w,a),m=u(w,d);if(4>=Math.abs(t(g/l)-t(m/o))){let t=S.size(h);t>=21&&t<=177&&!/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e,t,n){let r=0,{topLeft:i,topRight:s,bottomLeft:l}=e;for(let o of t)if(o!==i&&o!==s&&o!==l){let t;if(n.has(o)&&(t=S.contains(e,o))||1>c.noise(o)&&(null==t?S.contains(e,o):t)&&++r>3)return!0}return!1}(h,e,s)&&(R(f,h)||R(f,h,!0))&&(yield h)&&(s.set(r,!0),s.set(i,!0),s.set(n,!0))}}}}}}}}find(e,t,n,r){let{matrix:i}=this,s=e+n,l=t+r,o=(e,t,n,r,i,s)=>{L(n,r),L(i,s),1===i[0]&&0===i[1]&&1===i[2]&&0===i[3]&&1===i[4]&&Y(n,P)&&this.match(e,t,n,n[2])};for(let n=t;n + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class Q extends J{constructor(e,t){super(e,U,t)}filter(e,t){let n=this.patterns.filter(e=>2.5>=c.noise(e)&&V(e.moduleSize,t,.5));n.length>1&&n.sort((n,r)=>{let i=c.noise(n),s=c.noise(r),l=Math.abs(n.moduleSize-t),o=Math.abs(r.moduleSize-t);return(u(n,e)+l)*i-(u(r,e)+o)*s});let r=n.slice(0,2);return r.push(e),r}find(e,t,n,r){let{matrix:i}=this,s=e+n,l=t+r,o=(e,t,n,r,i,s)=>{L(n,r),L(i,s),0===i[0]&&1===i[1]&&0===i[2]&&Y(n,F)&&this.match(e,t,n,n[1])};for(let n=t;n=25)for(let s of function(e,t,n){let r=S.size(t),i=/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e){let{x:t,y:n}=e.topLeft,r=1-3/(S.size(e)-7),i=S.bottomRight(e),[s,l]=S.moduleSizes(e);return new c(U,t+(i.x-t)*r,n+(i.y-n)*r,5*s,5*l,0)}(t),s=new Q(e,n),l=S.moduleSize(t),{x:o,y:w}=i,a=Math.ceil(l*Math.min(20,0|r/4)),u=0|Math.max(0,w-a),f=0|Math.max(0,o-a),h=0|Math.min(e.width-1,o+a),d=0|Math.min(e.height-1,w+a);return s.find(f,u,h-f,d-u),s.filter(i,l)}(e,r,t)){let t=M(r,s);if(D(e,t,i)&&D(e,t,i,!0)&&(n=yield new v(e,t,r,s)))break}else{let t=M(r);D(e,t,i)&&D(e,t,i,!0)&&(n=yield new v(e,t,r))}l=s.next(n)}}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class X{#K;#Q;#W;#E;#X;#ee;constructor(e,t,{mask:n,level:r},i,s){this.#K=n,this.#Q=r,this.#W=s,this.#E=t,this.#ee=e,this.#X=i}get mask(){return this.#K}get level(){return this.#Q.name}get version(){return this.#E.version}get mirror(){return this.#W}get content(){return this.#ee.content}get corrected(){return this.#X}get symbology(){return this.#ee.symbology}get fnc1(){return this.#ee.fnc1}get codewords(){return this.#ee.codewords}get structured(){return this.#ee.structured}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class ee{#et;#en;#er;constructor(e){this.#et=e,this.#en=0,this.#er=0}get bitOffset(){return this.#en}get byteOffset(){return this.#er}read(e){let t=0,n=this.#en,r=this.#er,i=this.#et;if(n>0){let s=8-n,l=Math.min(e,s),o=s-l;e-=l,n+=l,t=(i[r]&255>>8-l<>o,8===n&&(r++,n=0)}if(e>0){for(;e>=8;)e-=8,t=t<<8|255&i[r++];if(e>0){let s=8-e;n+=e,t=t<>s<>s}}return this.#en=n,this.#er=r,t}available(){return 8*(this.#et.length-this.#er)-this.#en}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */let et=new Map;class en{#r;#ei;static TERMINATOR=new en([0,0,0],0);static NUMERIC=new en([10,12,14],1);static ALPHANUMERIC=new en([9,11,13],2);static STRUCTURED_APPEND=new en([0,0,0],3);static BYTE=new en([8,16,16],4);static ECI=new en([0,0,0],7);static KANJI=new en([8,10,12],8);static FNC1_FIRST_POSITION=new en([0,0,0],5);static FNC1_SECOND_POSITION=new en([0,0,0],9);static HANZI=new en([8,10,12],13);constructor(e,t){this.#r=t,this.#ei=new Int32Array(e),et.set(t,this)}get bits(){return this.#r}getCharacterCountBits(e){let t,{version:n}=e;return t=n<=9?0:n<=26?1:2,this.#ei[t]}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */let er=new Map;class ei{#es;#el;static CP437=new ei("cp437",2,0);static ISO_8859_1=new ei("iso-8859-1",3,1);static ISO_8859_2=new ei("iso-8859-2",4);static ISO_8859_3=new ei("iso-8859-3",5);static ISO_8859_4=new ei("iso-8859-4",6);static ISO_8859_5=new ei("iso-8859-5",7);static ISO_8859_6=new ei("iso-8859-6",8);static ISO_8859_7=new ei("iso-8859-7",9);static ISO_8859_8=new ei("iso-8859-8",10);static ISO_8859_9=new ei("iso-8859-9",11);static ISO_8859_10=new ei("iso-8859-10",12);static ISO_8859_11=new ei("iso-8859-11",13);static ISO_8859_13=new ei("iso-8859-13",15);static ISO_8859_14=new ei("iso-8859-14",16);static ISO_8859_15=new ei("iso-8859-15",17);static ISO_8859_16=new ei("iso-8859-16",18);static SHIFT_JIS=new ei("shift-jis",20);static CP1250=new ei("cp1250",21);static CP1251=new ei("cp1251",22);static CP1252=new ei("cp1252",23);static CP1256=new ei("cp1256",24);static UTF_16BE=new ei("utf-16be",25);static UTF_8=new ei("utf-8",26);static ASCII=new ei("ascii",27);static BIG5=new ei("big5",28);static GB2312=new ei("gb2312",29);static EUC_KR=new ei("euc-kr",30);static GB18030=new ei("gb18030",32);static UTF_16LE=new ei("utf-16le",33);static UTF_32BE=new ei("utf-32be",34);static UTF_32LE=new ei("utf-32le",35);static ISO_646_INV=new ei("iso-646-inv",170);static BINARY=new ei("binary",899);constructor(e,...t){for(let n of(this.#es=e,this.#el=Object.freeze(t),t))if(n>=0&&n<=999999&&Number.isInteger(n))er.set(n,this);else throw Error("illegal extended channel interpretation value")}get label(){return this.#es}get values(){return this.#el}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function es(e){let t=0,n=new Map;for(let r of e)n.set(r,t++);return n}function el(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i>8,255&n),l.push(n);let{length:a}=l,u=w.decode(new Uint8Array(s));for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:256,i=n.length-1,s=[];for(let l=e;l{let t=1&e.length;return e=e.replace(/%%/g,"%"),t?e.replace(/%$/,"\x1d"):e})}es(ea);/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */let ef=new Map;class eh{#eo;#r;#Q;static L=new eh("L",0,1);static M=new eh("M",1,0);static Q=new eh("Q",2,3);static H=new eh("H",3,2);constructor(e,t,n){this.#r=n,this.#eo=e,this.#Q=t,ef.set(n,this)}get bits(){return this.#r}get name(){return this.#eo}get level(){return this.#Q}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */let ec=[[21522,0],[20773,1],[24188,2],[23371,3],[17913,4],[16590,5],[20375,6],[19104,7],[30660,8],[29427,9],[32170,10],[30877,11],[26159,12],[25368,13],[27713,14],[26998,15],[5769,16],[5054,17],[7399,18],[6608,19],[1890,20],[597,21],[3340,22],[2107,23],[13663,24],[12392,25],[16177,26],[14854,27],[9396,28],[8579,29],[11994,30],[11245,31]];class ed{#K;#Q;constructor(e){this.#K=7&e,this.#Q=function(e){let t=ef.get(e);if(null!=t)return t;throw Error("illegal error correction bits")}(e>>3&3)}get mask(){return this.#K}get level(){return this.#Q}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function eg(e,t,n,r){return e.get(t,n)?r<<1|1:r<<1}class em{#z;#c;constructor(e){let{width:t,height:n}=e;this.#c=e.clone(),this.#z=Math.min(t,n)}readVersion(){let e=this.#z,t=0|(e-17)/4;if(t<1)throw Error("illegal version");if(t<=6)return p[t-1];let n=0,i=0,s=e-11,l=this.#c;for(let t=5;t>=0;t--)for(let r=e-9;r>=s;r--)n=eg(l,r,t,n);for(let t=5;t>=0;t--)for(let n=e-9;n>=s;n--)i=eg(l,t,n,i);let o=function(e,t){let n=32,i=0,{length:s}=b;for(let l=0;l=7)return p[i-1];throw Error("unable to decode version")}(n,i);if(o.size>e)throw Error("matrix size too small for version");return o}readFormatInfo(){let e=0,t=0,n=this.#c,i=this.#z,s=i-7;for(let t=0;t<=8;t++)6!==t&&(e=eg(n,t,8,e));for(let t=7;t>=0;t--)6!==t&&(e=eg(n,8,t,e));for(let e=i-1;e>=s;e--)t=eg(n,8,e,t);for(let e=i-8;e6&&(l.setRegion(t-11,0,3,6),l.setRegion(0,t-11,6,3)),l}(e),f=new Uint8Array(a.numTotalCodewords);for(let e=o-1;e>0;e-=2){6===e&&e--;for(let t=0;t + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class eb{#ew;#m;constructor(e,t){this.#ew=e,this.#m=t}get codewords(){return this.#ew}get numDataCodewords(){return this.#m}}/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class ey{#ea;#eu;constructor(e,t){let{length:n}=t;if(n<=0)throw Error("polynomial coefficients cannot empty");if(this.#ea=e,n>1&&0===t[0]){let e=1;for(;e=e.getDegree()&&!r.isZero();){let i=r.getDegree(),l=i-e.getDegree(),o=t.multiply(r.getCoefficient(i),s),w=e.multiplyByMonomial(l,o),a=t.buildPolynomial(l,o);n=n.addOrSubtract(a),r=r.addOrSubtract(w)}return[n,r]}}let ep=new /** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */class{#z;#ef;#eh;#ec;#ed;#eg;constructor(e,t,n){let r=1,i=new Int32Array(t);for(let n=0;n=t&&(r^=e,r&=t-1);let s=new Int32Array(t);for(let e=0,n=t-1;e + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e,t,n,r){t.getDegree()=r;){let t=o,n=l;if(o=s,(l=i).isZero())throw Error("remainder last was zero");i=n;let r=e.zero,w=i.getDegree(),a=l.getDegree(),u=l.getCoefficient(a),f=e.invert(u);for(;w>=a&&!i.isZero();){let t=i.getDegree()-a,n=e.multiply(i.getCoefficient(w),f);r=r.addOrSubtract(e.buildPolynomial(t,n)),w=(i=i.addOrSubtract(l.multiplyByMonomial(t,n))).getDegree()}if(s=r.multiply(o).addOrSubtract(t),w>=a)throw Error("division algorithm failed to reduce polynomial")}let w=s.getCoefficient(0);if(0===w)throw Error("sigma tilde(0) was zero");let a=e.invert(w);return[s.multiply(a),i.multiply(a)]}(r,r.buildPolynomial(t,1),n,t),o=function(e,t){let n=t.getDegree();if(1===n)return new Int32Array([t.getCoefficient(1)]);let r=0,{size:i}=e,s=new Int32Array(n);for(let l=1;l + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function ez(e,t,n){let{mask:r,level:i}=n,s=0,l=0;e.unmask(r);let o=t.getECBlocks(i),w=function(e,t,n){let{ecBlocks:r,numTotalCodewords:i,numECCodewordsPerBlock:s}=t.getECBlocks(n);if(e.length!==i)throw Error("failed to get data blocks");let l=[];for(let{count:e,numDataCodewords:t}of r)for(let n=0;n=0&&l[w].codewords.length!==a;)w--;w++;let u=0,f=a-s;for(let t=0;t + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e,t){let n=new Int32Array(e),r=e.length-t,i=new ex().decode(n,r);return[n,i]}(e,t);a.set(n.subarray(0,t),s),l+=r,s+=t}return[a,l]}class eE{#em;constructor({decode:e=eI}={}){this.#em=e}decode(e){let t,r,i,s=0,l=!1,o=new em(e);try{t=o.readVersion(),i=o.readFormatInfo(),[r,s]=ez(o,t,i)}catch{null!=i&&o.remask(i.mask),o.mirror(),l=!0,t=o.readVersion(),i=o.readFormatInfo(),[r,s]=ez(o,t,i)}return new X(function(e,t,r){let i,s,l,o="",w=-1,a=!1,u=!1,f=!1,h=!1,c=new ee(e);do switch(s=4>c.available()?en.TERMINATOR:function(e){let t=et.get(e);if(null!=t)return t;throw Error("illegal mode bits")}(c.read(4))){case en.TERMINATOR:break;case en.FNC1_FIRST_POSITION:a=!0;break;case en.FNC1_SECOND_POSITION:u=!0,w=c.read(8);break;case en.STRUCTURED_APPEND:if(16>c.available())throw Error("illegal structured append");h=Object.freeze({index:c.read(4),count:c.read(4)+1,parity:c.read(8)});break;case en.ECI:l=/** + * @module QRCode + * @package @nuintun/qrcode + * @license MIT + * @version 4.1.0 + * @author nuintun + * @description A pure JavaScript QRCode encode and decode library. + * @see https://github.com/nuintun/qrcode#readme + */function(e){let t=e.read(8);if((128&t)==0)return 127&t;if((192&t)==128)return(63&t)<<8|e.read(8);if((224&t)==192)return(31&t)<<16|e.read(16);throw Error("illegal extended channel interpretation value")}(c);break;default:if(s===en.HANZI&&1!==c.read(4))throw Error("illegal hanzi subset");let d=c.read(s.getCharacterCountBits(t));switch(s){case en.ALPHANUMERIC:o+=function(e,t,r){let i="";for(;t>1;){if(11>e.available())throw Error("illegal bits length");let r=e.read(11);i+=n(ea,r/45)+n(ea,r%45),t-=2}if(1===t){if(6>e.available())throw Error("illegal bits length");i+=n(ea,e.read(6))}return r?eu(i):i}(c,d,a||u);break;case en.BYTE:o+=function(e,t,n,r,i){if(e.available()<8*t)throw Error("illegal bits length");let s=new Uint8Array(t),l=null!=i?function(e){let t=er.get(e);if(t)return t;throw Error("illegal charset value")}(i):ei.ISO_8859_1;for(let n=0;n0;){let i=e.read(13),s=i/96<<8|i%96;s<2560?s+=41377:s+=42657,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("gb2312").decode(r)}(c,d);break;case en.KANJI:o+=function(e,t){if(e.available()<13*t)throw Error("illegal bits length");let n=0,r=new Uint8Array(2*t);for(;t>0;){let i=e.read(13),s=i/192<<8|i%192;s<7936?s+=33088:s+=49472,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("shift-jis").decode(r)}(c,d);break;case en.NUMERIC:o+=function(e,t){let r="";for(;t>=3;){if(10>e.available())throw Error("illegal bits length");let i=e.read(10);if(i>=1e3)throw Error("illegal numeric codeword");r+=n(ew,i/100)+n(ew,i/10%10)+n(ew,i%10),t-=3}if(2===t){if(7>e.available())throw Error("illegal bits length");let t=e.read(7);if(t>=100)throw Error("illegal numeric codeword");r+=n(ew,t/10)+n(ew,t%10)}else if(1===t){if(4>e.available())throw Error("illegal bits length");let t=e.read(4);if(t>=10)throw Error("illegal numeric codeword");r+=n(ew,t)}return r}(c,d);break;default:throw Error("illegal mode")}}while(s!==en.TERMINATOR);return a?f=Object.freeze(["GS1"]):u&&(f=Object.freeze(["AIM",w])),i=null!=l?a?4:u?6:2:a?3:u?5:1,{content:o,codewords:e,structured:h,symbology:`]Q${i}`,fnc1:f}}(r,t,this.#em),t,i,s,l)}}function eC(e){return{x:e.x,y:e.y}}function eS(e){return{x:e.x,y:e.y,moduleSize:e.moduleSize}}self.addEventListener("message",async e=>{let{data:t}=e,{uid:n,image:r}=t,{width:i,height:a}=r,u=new OffscreenCanvas(i,a).getContext("2d");u.drawImage(r,0,0);let f=function(e,t,n){if(e.length!==t*n)throw Error("luminances length must be equals to width * height");return t<40||n<40?function(e,t,n){let r=new s(t,n),i=new Int32Array(32);for(let r=1;r<5;r++){let s=0|4*t/5,l=(0|n*r/5)*t;for(let n=0|t/5;n>3]++}}let l=function(e){let t=0,n=0,r=0,{length:i}=e;for(let s=0;sn&&(t=s,n=e[s]),e[s]>r&&(r=e[s]);let s=0,l=0;for(let n=0;nl&&(s=n,l=i)}if(t>s&&([t,s]=[s,t]),s-t<=2)return -1;let o=-1,w=s-1;for(let n=s-1;n>t;n--){let i=n-t,l=i*i*(s-n)*(r-e[n]);l>o&&(w=n,o=l)}return w<<3}(i);if(l>0)for(let i=0;ia&&(a=n)}if(a-u>24)for(n++,r+=t;n<8;n++,r+=t)for(let t=0;t<8;t++)o+=e[r+t]}let h=o>>6;if(a-u<=24&&(h=u/2,n>0&&s>0)){let e=(r[n-1][s]+2*r[n][s-1]+r[n-1][s-1])/4;u>10}}return i}(u.getImageData(0,0,i,a)),i,a);t.invert&&f.flip();let h=new W({strict:t.strict}).detect(f),c=[],d=new eE,g=h.next();for(;!g.done;){let e=!1,t=g.value;try{let{size:n,finder:r,alignment:i}=t,s=d.decode(t.matrix),{topLeft:l,topRight:o,bottomLeft:w}=r,a=t.mapping(0,0),u=t.mapping(n,0),f=t.mapping(n,n),h=t.mapping(0,n),g=t.mapping(6.5,6.5),m=t.mapping(n-6.5,6.5),b=t.mapping(6.5,n-6.5);c.push({fnc1:s.fnc1,mask:s.mask,level:s.level,mirror:s.mirror,content:s.content,version:s.version,corrected:s.corrected,symbology:s.symbology,structured:s.structured,alignment:i?eS(i):null,finder:[eS(l),eS(o),eS(w)],timing:[eC(g),eC(m),eC(b)],corners:[eC(a),eC(u),eC(f),eC(h)]}),e=!0}catch{}g=h.next(e)}c.length>0?self.postMessage({type:"ok",payload:{uid:n,image:r,items:c}},[r]):self.postMessage({type:"error",message:"未发现二维码"})})}(); \ No newline at end of file