1
0
Fork 0
owl-admin-starter/public/admin-assets/assets/QRCode-BVoow0vj.js

4 lines
20 KiB
JavaScript

import{l as S,r as Q,j as H,t as T,aw as V,w as q,x as Y,dk as W,cm as X,aq as G,ag as K,U as Z,D as j,E as _,T as J,dY as ee,L as te}from"./index-CEmnTf-r.js";function P(a,n,r){return r=y(r),`M ${y(a-r)}, ${y(n)} a ${r},${r} 0 1,0 ${2*r},0 a ${r},${r} 0 1,0 ${-2*r},0`}function O(a,n,r){a=y(a),n=y(n);const s=y(a+r),l=y(n+r);return`M ${a}, ${n} L ${s}, ${n} L ${s}, ${l} L ${a}, ${l} Z `}function oe(a,n,r,s){a=y(a),n=y(n);const l=y(a+s),u=y(n+s),h=y(a+r-s),f=y(n+r-s),m=y(a+r),e=y(n+r);return`M${l} ${n}L${m} ${n}L${m} ${e}L${a} ${e}L${a} ${n}L${l} ${n}L${l} ${f}L${h} ${f}L${h} ${u}L${l} ${u}Z `}function re(a,n,r,s,l){a=y(a),n=y(n),l=y(l);const u=y(a+l),h=y(a+r-l),f=y(n+l),m=y(n+r-l),e=y(a+s),t=y(n+s),o=y(a+r-s),i=y(n+r-s),c=y(a+r),g=y(n+r),d=y(l-s/2),C=y(e+d),p=y(t+d),v=y(o-d),w=y(i-d),E=y(u+d);return`M${u} ${n}L${h} ${n}A${l} ${l} 0 0 1 ${c} ${f}L${c} ${m}A${l} ${l} 0 0 1 ${h} ${g}L${u} ${g}A${l} ${l} 0 0 1 ${a} ${m}L${a} ${f}A${l} ${l} 0 0 1 ${u} ${n}L${u} ${n}L${E} ${i}L${v} ${i}A${d} ${d} 0 0 0 ${o} ${w}L${o} ${p}A${d} ${d} 0 0 0 ${v} ${t}L${C} ${t}A${d} ${d} 0 0 0 ${e} ${p}L${e} ${w}A${d} ${d} 0 0 0 ${C} ${i}L${E} ${i}Z`}function ne(a,n,r,s){const l=y(r),u=y(r-s);n=y(n),a=y(a);const h=y(n-l),f=y(n-u),m=y(n+l),e=y(n+u);return`M${a},${h} A${l},${l} 0 1,1 ${a},${m} A${l},${l} 0 1,1 ${a},${h} M${a},${f} A${u},${u} 0 1,0 ${a},${e} A${u},${u} 0 1,0 ${a},${f} Z`}function ie(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=oe(l,u,n,r*s),f=O(l+r*2,u+r*2,n-r*4);return{eyeBorder:h,eyeInner:f}}function se(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=re(l,u,n,r*s,r*2),f=P(l+n/2,u+n/2,n/2-r*2);return{eyeBorder:h,eyeInner:f}}function ae(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=ne(l+n/2,u+n/2,n/2,r*s),f=P(l+n/2,u+n/2,n/2-r*2);return{eyeBorder:h,eyeInner:f}}const le={default:ie,rounded:se,circle:ae};function ce(a){const n={default:1,sm:.8,xs:.5};return r=>{const{size:s,dotSize:l,borderSize:u,margin:h}=r,{eyeSize:f,positions:m}=$e(s,l,h);let e="",t="";for(const o of m){const{eyeBorder:i,eyeInner:c}=a({size:f,dotSize:l,borderSize:n[u],x:o.x,y:o.y});e+=i,t+=c}return{eyeBorder:e,eyeInner:t}}}function ue(a){const n=le[a];return ce(n)}function de(a){const{x:n,y:r,dotSize:s,dotScale:l,margin:u}=a;let h="";const f=s*l;return h+=O(n*s+(s-f)/2+u,r*s+(s-f)/2+u,f),h}function he(a){const{x:n,y:r,dotSize:s,dotScale:l,margin:u}=a;let h="",f=s/2*l,m=n*s+(s-f*2)/2+f+u,e=r*s+(s-f*2)/2+f+u;return h+=P(m,e,f),h}const fe={default:de,circle:he};function ge(a){const n={default:1,sm:.8,xs:.5};return r=>{const{modules:s,dotSize:l,pointSize:u,customSize:h,margin:f}=r;let m="";for(let e=0;e<s.length;e++)for(let t=0;t<s.length;t++)if(s[e][t]&&!Ee(s,t,e)){let o=h[e][t]||1;m+=a({x:t,y:e,dotSize:l,dotScale:n[u]*o,margin:f})}return m}}function me(a){const n=fe[a];return ge(n)}var N;(a=>{const n=class ${constructor(e,t,o,i){if(this.version=e,this.errorCorrectionLevel=t,this.modules=[],this.isFunction=[],e<$.MIN_VERSION||e>$.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let c=[];for(let d=0;d<this.size;d++)c.push(!1);for(let d=0;d<this.size;d++)this.modules.push(c.slice()),this.isFunction.push(c.slice());this.drawFunctionPatterns();const g=this.addEccAndInterleave(o);if(this.drawCodewords(g),i==-1){let d=1e9;for(let C=0;C<8;C++){this.applyMask(C),this.drawFormatBits(C);const p=this.getPenaltyScore();p<d&&(i=C,d=p),this.applyMask(C)}}u(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(e,t){const o=a.QrSegment.makeSegments(e);return $.encodeSegments(o,t)}static encodeBinary(e,t){const o=a.QrSegment.makeBytes(e);return $.encodeSegments([o],t)}static encodeSegments(e,t,o=1,i=40,c=-1,g=!0){if(!($.MIN_VERSION<=o&&o<=i&&i<=$.MAX_VERSION)||c<-1||c>7)throw new RangeError("Invalid value");let d,C;for(d=o;;d++){const E=$.getNumDataCodewords(d,t)*8,R=f.getTotalBits(e,d);if(R<=E){C=R;break}if(d>=i)throw new RangeError("Data too long")}for(const E of[$.Ecc.MEDIUM,$.Ecc.QUARTILE,$.Ecc.HIGH])g&&C<=$.getNumDataCodewords(d,E)*8&&(t=E);let p=[];for(const E of e){s(E.mode.modeBits,4,p),s(E.numChars,E.mode.numCharCountBits(d),p);for(const R of E.getData())p.push(R)}u(p.length==C);const v=$.getNumDataCodewords(d,t)*8;u(p.length<=v),s(0,Math.min(4,v-p.length),p),s(0,(8-p.length%8)%8,p),u(p.length%8==0);for(let E=236;p.length<v;E^=253)s(E,8,p);let w=[];for(;w.length*8<p.length;)w.push(0);return p.forEach((E,R)=>w[R>>>3]|=E<<7-(R&7)),new $(d,t,w,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let o=0;o<this.size;o++)this.setFunctionModule(6,o,o%2==0),this.setFunctionModule(o,6,o%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let o=0;o<t;o++)for(let i=0;i<t;i++)o==0&&i==0||o==0&&i==t-1||o==t-1&&i==0||this.drawAlignmentPattern(e[o],e[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let o=t;for(let c=0;c<10;c++)o=o<<1^(o>>>9)*1335;const i=(t<<10|o)^21522;u(i>>>15==0);for(let c=0;c<=5;c++)this.setFunctionModule(8,c,l(i,c));this.setFunctionModule(8,7,l(i,6)),this.setFunctionModule(8,8,l(i,7)),this.setFunctionModule(7,8,l(i,8));for(let c=9;c<15;c++)this.setFunctionModule(14-c,8,l(i,c));for(let c=0;c<8;c++)this.setFunctionModule(this.size-1-c,8,l(i,c));for(let c=8;c<15;c++)this.setFunctionModule(8,this.size-15+c,l(i,c));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let o=0;o<12;o++)e=e<<1^(e>>>11)*7973;const t=this.version<<12|e;u(t>>>18==0);for(let o=0;o<18;o++){const i=l(t,o),c=this.size-11+o%3,g=Math.floor(o/3);this.setFunctionModule(c,g,i),this.setFunctionModule(g,c,i)}}drawFinderPattern(e,t){for(let o=-4;o<=4;o++)for(let i=-4;i<=4;i++){const c=Math.max(Math.abs(i),Math.abs(o)),g=e+i,d=t+o;0<=g&&g<this.size&&0<=d&&d<this.size&&this.setFunctionModule(g,d,c!=2&&c!=4)}}drawAlignmentPattern(e,t){for(let o=-2;o<=2;o++)for(let i=-2;i<=2;i++)this.setFunctionModule(e+i,t+o,Math.max(Math.abs(i),Math.abs(o))!=1)}setFunctionModule(e,t,o){this.modules[t][e]=o,this.isFunction[t][e]=!0}addEccAndInterleave(e){const t=this.version,o=this.errorCorrectionLevel;if(e.length!=$.getNumDataCodewords(t,o))throw new RangeError("Invalid argument");const i=$.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][t],c=$.ECC_CODEWORDS_PER_BLOCK[o.ordinal][t],g=Math.floor($.getNumRawDataModules(t)/8),d=i-g%i,C=Math.floor(g/i);let p=[];const v=$.reedSolomonComputeDivisor(c);for(let E=0,R=0;E<i;E++){let z=e.slice(R,R+C-c+(E<d?0:1));R+=z.length;const A=$.reedSolomonComputeRemainder(z,v);E<d&&z.push(0),p.push(z.concat(A))}let w=[];for(let E=0;E<p[0].length;E++)p.forEach((R,z)=>{(E!=C-c||z>=d)&&w.push(R[E])});return u(w.length==g),w}drawCodewords(e){if(e.length!=Math.floor($.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let o=this.size-1;o>=1;o-=2){o==6&&(o=5);for(let i=0;i<this.size;i++)for(let c=0;c<2;c++){const g=o-c,d=o+1&2?i:this.size-1-i;!this.isFunction[d][g]&&t<e.length*8&&(this.modules[d][g]=l(e[t>>>3],7-(t&7)),t++)}}u(t==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let o=0;o<this.size;o++){let i;switch(e){case 0:i=(o+t)%2==0;break;case 1:i=t%2==0;break;case 2:i=o%3==0;break;case 3:i=(o+t)%3==0;break;case 4:i=(Math.floor(o/3)+Math.floor(t/2))%2==0;break;case 5:i=o*t%2+o*t%3==0;break;case 6:i=(o*t%2+o*t%3)%2==0;break;case 7:i=((o+t)%2+o*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][o]&&i&&(this.modules[t][o]=!this.modules[t][o])}}getPenaltyScore(){let e=0;for(let c=0;c<this.size;c++){let g=!1,d=0,C=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[c][p]==g?(d++,d==5?e+=$.PENALTY_N1:d>5&&e++):(this.finderPenaltyAddHistory(d,C),g||(e+=this.finderPenaltyCountPatterns(C)*$.PENALTY_N3),g=this.modules[c][p],d=1);e+=this.finderPenaltyTerminateAndCount(g,d,C)*$.PENALTY_N3}for(let c=0;c<this.size;c++){let g=!1,d=0,C=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[p][c]==g?(d++,d==5?e+=$.PENALTY_N1:d>5&&e++):(this.finderPenaltyAddHistory(d,C),g||(e+=this.finderPenaltyCountPatterns(C)*$.PENALTY_N3),g=this.modules[p][c],d=1);e+=this.finderPenaltyTerminateAndCount(g,d,C)*$.PENALTY_N3}for(let c=0;c<this.size-1;c++)for(let g=0;g<this.size-1;g++){const d=this.modules[c][g];d==this.modules[c][g+1]&&d==this.modules[c+1][g]&&d==this.modules[c+1][g+1]&&(e+=$.PENALTY_N2)}let t=0;for(const c of this.modules)t=c.reduce((g,d)=>g+(d?1:0),t);const o=this.size*this.size,i=Math.ceil(Math.abs(t*20-o*10)/o)-1;return u(0<=i&&i<=9),e+=i*$.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,t=Math.floor((this.version*8+e*3+5)/(e*4-4))*2;let o=[6];for(let i=this.size-7;o.length<e;i-=t)o.splice(1,0,i);return o}}static getNumRawDataModules(e){if(e<$.MIN_VERSION||e>$.MAX_VERSION)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const o=Math.floor(e/7)+2;t-=(25*o-10)*o-55,e>=7&&(t-=36)}return u(208<=t&&t<=29648),t}static getNumDataCodewords(e,t){return Math.floor($.getNumRawDataModules(e)/8)-$.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e]*$.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let t=[];for(let i=0;i<e-1;i++)t.push(0);t.push(1);let o=1;for(let i=0;i<e;i++){for(let c=0;c<t.length;c++)t[c]=$.reedSolomonMultiply(t[c],o),c+1<t.length&&(t[c]^=t[c+1]);o=$.reedSolomonMultiply(o,2)}return t}static reedSolomonComputeRemainder(e,t){let o=t.map(i=>0);for(const i of e){const c=i^o.shift();o.push(0),t.forEach((g,d)=>o[d]^=$.reedSolomonMultiply(g,c))}return o}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let o=0;for(let i=7;i>=0;i--)o=o<<1^(o>>>7)*285,o^=(t>>>i&1)*e;return u(o>>>8==0),o}finderPenaltyCountPatterns(e){const t=e[1];u(t<=this.size*3);const o=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(o&&e[0]>=t*4&&e[6]>=t?1:0)+(o&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,o){return e&&(this.finderPenaltyAddHistory(t,o),t=0),t+=this.size,this.finderPenaltyAddHistory(t,o),this.finderPenaltyCountPatterns(o)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];let r=n;a.QrCode=r;function s(m,e,t){if(e<0||e>31||m>>>e)throw new RangeError("Value out of range");for(let o=e-1;o>=0;o--)t.push(m>>>o&1)}function l(m,e){return(m>>>e&1)!=0}function u(m){if(!m)throw new Error("Assertion error")}const h=class M{constructor(e,t,o){if(this.mode=e,this.numChars=t,this.bitData=o,t<0)throw new RangeError("Invalid argument");this.bitData=o.slice()}static makeBytes(e){let t=[];for(const o of e)s(o,8,t);return new M(M.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!M.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let o=0;o<e.length;){const i=Math.min(e.length-o,3);s(parseInt(e.substring(o,o+i),10),i*3+1,t),o+=i}return new M(M.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!M.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let t=[],o;for(o=0;o+2<=e.length;o+=2){let i=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o))*45;i+=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o+1)),s(i,11,t)}return o<e.length&&s(M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)),6,t),new M(M.Mode.ALPHANUMERIC,e.length,t)}static makeSegments(e){return e==""?[]:M.isNumeric(e)?[M.makeNumeric(e)]:M.isAlphanumeric(e)?[M.makeAlphanumeric(e)]:[M.makeBytes(M.toUtf8ByteArray(e))]}static makeEci(e){let t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)s(e,8,t);else if(e<16384)s(2,2,t),s(e,14,t);else if(e<1e6)s(6,3,t),s(e,21,t);else throw new RangeError("ECI assignment value out of range");return new M(M.Mode.ECI,0,t)}static isNumeric(e){return M.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return M.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let o=0;for(const i of e){const c=i.mode.numCharCountBits(t);if(i.numChars>=1<<c)return 1/0;o+=4+c+i.bitData.length}return o}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let o=0;o<e.length;o++)e.charAt(o)!="%"?t.push(e.charCodeAt(o)):(t.push(parseInt(e.substring(o+1,o+3),16)),o+=2);return t}};h.NUMERIC_REGEX=/^[0-9]*$/,h.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,h.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let f=h;a.QrSegment=f})(N||(N={}));(a=>{(n=>{const r=class{constructor(u,h){this.ordinal=u,this.formatBits=h}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2);let s=r;n.Ecc=s})(a.QrCode||(a.QrCode={}))})(N||(N={}));(a=>{(n=>{const r=class{constructor(u,h){this.modeBits=u,this.numBitsCharCount=h}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]);let s=r;n.Mode=s})(a.QrSegment||(a.QrSegment={}))})(N||(N={}));const I=N,pe=I.QrCode,ye={L:I.QrCode.Ecc.LOW,M:I.QrCode.Ecc.MEDIUM,Q:I.QrCode.Ecc.QUARTILE,H:I.QrCode.Ecc.HIGH};function Ce(a,n){const{level:r="L",minVersion:s=2,maxVersion:l,mask:u,boostLevel:h}=n||{},f=I.QrSegment.makeSegments(a),m=pe.encodeSegments(f,ye[r],s,l,u,h),e=[];for(let t=0;t<m.size;t++){e.push([]);for(let o=0;o<m.size;o++)e[t].push(m.getModule(o,t))}return e}function $e(a,n,r){const s=n*7,l=[{x:r,y:r},{x:r,y:a-s-r},{x:a-s-r,y:r}];return{eyeSize:s,positions:l}}function Ee(a,n,r){const s=a.length,l=8;return n<l&&r<l||n<l&&r>s-l||n>s-l&&r<l}function we(a){const{modules:n,size:r,dotSize:s,margin:l=0,eyeType:u="default",eyeBorderSize:h="default",pointType:f="default",customSize:m,pointSize:e="default"}=a,t=me(f)({margin:l,modules:n,dotSize:s,pointSize:e,customSize:m}),{eyeBorder:o,eyeInner:i}=ue(u)({margin:l,dotSize:s,borderSize:h,size:r});return{points:t,eyeBorder:o,eyeInner:i}}function y(a,n=2){return Number(a.toFixed(n))}function F(a){const{config:n,styleConfig:r,logoConfig:s,value:l}=a,{size:u=200,margin:h=0,eyeType:f,eyeBorderSize:m,pointType:e,pointSize:t,pointSizeRandom:o}=r||{},i=S.useMemo(()=>Ce(l,n),[l,n]),c=S.useMemo(()=>y((u-h*2)/i.length),[i,u,h]),g=S.useMemo(()=>{let C=[];for(let p=0;p<i.length;p++){C.push([]);for(let v=0;v<i.length;v++)o?C[p].push(Math.random()<.5?1:.8):C[p].push(1)}return C},[i,o]),d=S.useMemo(()=>we({modules:i,margin:h,size:u,dotSize:c,eyeType:f,eyeBorderSize:m,pointType:e,pointSize:t,customSize:g}),[i,c,r]);return{logo:S.useMemo(()=>{if(!s)return;let C=u-h*2,{src:p,width:v=C/5,height:w=C/5,x:E=C/2-v/2+h,y:R=C/2-w/2+h}=s||{};const z=i.length,A=Array.from({length:z},(L,U)=>U*c+h),x=A[A.findIndex(L=>L>E)-2]-.5||E,B=A[A.findIndex(L=>L>R)-2]-.5||R,k=v+(E-x)*2,D=w+(R-B)*2;return{src:p,width:v,height:w,x:E,y:R,bg:{x,y:B,width:k,height:D}}},[i,c,h,s]),path:d}}function Se(a){const{value:n,config:r,styleConfig:s,logoConfig:l,className:u}=a,{size:h=200,margin:f=0,color:m="#000",bgColor:e="#fff",eyeBorderColor:t,eyeInnerColor:o}=s||{},{path:i,logo:c}=F({config:r,styleConfig:s,logoConfig:l,value:n}),{src:g,x:d,y:C,width:p,height:v,bg:w}=c||{};return S.createElement("svg",{width:h,height:h,viewBox:`0 0 ${h} ${h}`,style:{backgroundColor:e},className:"qr-container qr-svg"+(u?` ${u}`:"")},S.createElement("g",{fill:m},S.createElement("path",{fill:t||m,d:i.eyeBorder}),S.createElement("path",{fill:o||m,d:i.eyeInner}),S.createElement("path",{d:i.points}),g&&S.createElement(S.Fragment,null,S.createElement("rect",{fill:e,x:w==null?void 0:w.x,y:w==null?void 0:w.y,width:w==null?void 0:w.width,height:w==null?void 0:w.height}),S.createElement("image",{href:g,width:p,height:v,x:d,y:C}))))}function Me({ctx:a,bgColor:n="#fff",logo:r}){const{src:s,width:l,height:u,x:h,y:f,bg:m}=r||{};if(!s)return;const e=new Image;e.src=s,e.onload=()=>{a.fillStyle=n,a.fillRect(m.x,m.y,m.width,m.height);const t=e.width/e.height;let o=l,i=u;t>1?i=l/t:o=u*t,a.drawImage(e,h+(l-o)/2,f+(u-i)/2,o,i)}}function Re(a){const{ctx:n,path:r,styleConfig:s}=a,{color:l="#000",bgColor:u="#fff",eyeBorderColor:h,eyeInnerColor:f}=s||{};n.clearRect(0,0,n.canvas.width,n.canvas.height),n.fillStyle=u,n.fillRect(0,0,n.canvas.width,n.canvas.height),n.fillStyle=h||l,n.fill(new Path2D(r.eyeBorder)),n.fillStyle=f||l,n.fill(new Path2D(r.eyeInner)),n.fillStyle=l,n.fill(new Path2D(r.points))}function ve(a){const{value:n,config:r,styleConfig:s,logoConfig:l,className:u}=a,{size:h=200,bgColor:f}=s||{},{path:m,logo:e}=F({config:r,styleConfig:s,logoConfig:l,value:n}),t=S.useRef(null);return Q.useEffect(()=>{if(m&&t.current){const o=t.current.getContext("2d");Re({ctx:o,path:m,styleConfig:s}),e&&Me({ctx:o,bgColor:f,logo:e})}},[m,l,s]),H("canvas",{width:h,height:h,ref:t,className:"qr-container qr-canvas"+(u?` ${u}`:"")})}function ze(a){const{mode:n="canvas"}=a;return n==="svg"?S.createElement(Se,{...a}):S.createElement(ve,{...a})}function b(a,n){return ee.saveAs(a,n)}var Ae=function(a){T(n,a);function n(r){var s=a.call(this,r)||this;return s.ref=S.createRef(),s}return n.prototype.getImageSettings=function(){var r=this.props,s=r.imageSettings,l=r.data;if(!(!s||!V(s)||!s.src||typeof s.src!="string"))return q(s.src)&&(s.src=Y(s.src,l,"| raw")),W(s,function(u,h){return~["width","height","x","y"].indexOf(h)?X(u)?Number(u):null:u})},n.prototype.doAction=function(r,s,l,u){var h,f=this.props.codeSize,m=r==null?void 0:r.actionType;if(m==="saveAs"&&!((h=this.ref)===null||h===void 0)&&h.current)if(this.props.mode==="svg"){var e=this.ref.current.querySelector("svg");if(e){var t='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="'.concat(f,'" width="').concat(f,'" viewBox="').concat(e.getAttribute("viewBox")||"0 0 37 37",`">
`).concat(e.innerHTML,`
</svg>`),o=new Blob([t],{type:"image/svg+xml"});b(o,(u==null?void 0:u.name)||"qr-code.svg")}}else{var i=this.ref.current.querySelector("canvas");i&&i.toBlob(function(c){c&&b(c,u!=null&&u.name?u.name.replace(/\.svg$/,".png"):"qr-code.png")},"image/png")}},n.prototype.render=function(){var r=this.props,s=r.className,l=r.style,u=r.qrcodeClassName,h=r.codeSize,f=r.backgroundColor,m=r.foregroundColor,e=r.placeholder,t=r.level,o=r.defaultValue,i=r.data,c=r.mode,g=r.eyeType,d=r.eyeBorderColor,C=r.eyeBorderSize,p=r.eyeInnerColor,v=r.pointType,w=r.pointSize,E=r.pointSizeRandom,R=r.translate,z=r.classPrefix,A=G(this.props,function(){return te(o,i,"| raw")||void 0});return S.createElement("div",{className:K("".concat(z,"QrCode"),s),style:l,ref:this.ref},A?A.length>2953?S.createElement("span",{className:"text-danger"},R("QRCode.tooLong",{max:2953})):S.createElement(ze,{className:u,value:A,config:{level:t||"L",minVersion:2,boostLevel:!0},styleConfig:{size:h,bgColor:f,color:m,eyeType:g,eyeBorderColor:d,eyeBorderSize:C,eyeInnerColor:p,pointType:v,pointSize:w,pointSizeRandom:E},logoConfig:this.getImageSettings(),mode:c}):S.createElement("span",{className:"".concat(z,"QrCode--placeholder")},e))},n.defaultProps={codeSize:128,qrcodeClassName:"",backgroundColor:"#fff",foregroundColor:"#000",level:"L",placeholder:"-",mode:"canvas"},n}(S.Component),Pe=function(a){T(n,a);function n(r,s){var l=a.call(this,r)||this,u=s;return u.registerComponent(l),l}return n.prototype.componentWillUnmount=function(){var r;(r=a.prototype.componentWillUnmount)===null||r===void 0||r.call(this);var s=this.context;s.unRegisterComponent(this)},n.contextType=Z,n=j([_({type:"qrcode",alias:["qr-code"],name:"qrcode"}),J("design:paramtypes",[Object,Object])],n),n}(Ae);export{Pe as QRCodeRenderer,Ae as default};