import{j as _,r as I,h as Q,F as re,s as x,f as N,ao as oe,v as ne,w as se,d4 as ie,cd as ae,ai as le,ag as ce,T as ue,z as he,D as de,Q as fe,K as me}from"./index-DT8qTvyx.js";var ge=Object.defineProperty,L=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,U=(h,n,a)=>n in h?ge(h,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):h[n]=a,b=(h,n)=>{for(var a in n||(n={}))k.call(n,a)&&U(h,a,n[a]);if(L)for(var a of L(n))H.call(n,a)&&U(h,a,n[a]);return h},O=(h,n)=>{var a={};for(var i in h)k.call(h,i)&&n.indexOf(i)<0&&(a[i]=h[i]);if(h!=null&&L)for(var i of L(h))n.indexOf(i)<0&&H.call(h,i)&&(a[i]=h[i]);return a},A;(h=>{const n=class{constructor(e,t,r,o){if(this.version=e,this.errorCorrectionLevel=t,this.modules=[],this.isFunction=[],en.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=[];for(let l=0;l7)throw new RangeError("Invalid value");let l,g;for(l=r;;l++){const C=n.getNumDataCodewords(l,t)*8,p=E.getTotalBits(e,l);if(p<=C){g=p;break}if(l>=o)throw new RangeError("Data too long")}for(const C of[n.Ecc.MEDIUM,n.Ecc.QUARTILE,n.Ecc.HIGH])c&&g<=n.getNumDataCodewords(l,C)*8&&(t=C);let f=[];for(const C of e){i(C.mode.modeBits,4,f),i(C.numChars,C.mode.numCharCountBits(l),f);for(const p of C.getData())f.push(p)}u(f.length==g);const M=n.getNumDataCodewords(l,t)*8;u(f.length<=M),i(0,Math.min(4,M-f.length),f),i(0,(8-f.length%8)%8,f),u(f.length%8==0);for(let C=236;f.lengthv[p>>>3]|=C<<7-(p&7)),new n(l,t,v,s)}getModule(e,t){return 0<=e&&e>>9)*1335;const o=(t<<10|r)^21522;u(o>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,m(o,s));this.setFunctionModule(8,7,m(o,6)),this.setFunctionModule(8,8,m(o,7)),this.setFunctionModule(7,8,m(o,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,m(o,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,m(o,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,m(o,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^(e>>>11)*7973;const t=this.version<<12|e;u(t>>>18==0);for(let r=0;r<18;r++){const o=m(t,r),s=this.size-11+r%3,c=Math.floor(r/3);this.setFunctionModule(s,c,o),this.setFunctionModule(c,s,o)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let o=-4;o<=4;o++){const s=Math.max(Math.abs(o),Math.abs(r)),c=e+o,l=t+r;0<=c&&c{(C!=g-s||w>=l)&&v.push(p[C])});return u(v.length==c),v}drawCodewords(e){if(e.length!=Math.floor(n.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let r=this.size-1;r>=1;r-=2){r==6&&(r=5);for(let o=0;o>>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;t5&&e++):(this.finderPenaltyAddHistory(l,g),c||(e+=this.finderPenaltyCountPatterns(g)*n.PENALTY_N3),c=this.modules[s][f],l=1);e+=this.finderPenaltyTerminateAndCount(c,l,g)*n.PENALTY_N3}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(l,g),c||(e+=this.finderPenaltyCountPatterns(g)*n.PENALTY_N3),c=this.modules[f][s],l=1);e+=this.finderPenaltyTerminateAndCount(c,l,g)*n.PENALTY_N3}for(let s=0;sc+(l?1:0),t);const r=this.size*this.size,o=Math.ceil(Math.abs(t*20-r*10)/r)-1;return u(0<=o&&o<=9),e+=o*n.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let r=[6];for(let o=this.size-7;r.lengthn.MAX_VERSION)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const r=Math.floor(e/7)+2;t-=(25*r-10)*r-55,e>=7&&(t-=36)}return u(208<=t&&t<=29648),t}static getNumDataCodewords(e,t){return Math.floor(n.getNumRawDataModules(e)/8)-n.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e]*n.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 o=0;o0);for(const o of e){const s=o^r.shift();r.push(0),t.forEach((c,l)=>r[l]^=n.reedSolomonMultiply(c,s))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let r=0;for(let o=7;o>=0;o--)r=r<<1^(r>>>7)*285,r^=(t>>>o&1)*e;return u(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];u(t<=this.size*3);const r=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(r&&e[0]>=t*4&&e[6]>=t?1:0)+(r&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};let a=n;a.MIN_VERSION=1,a.MAX_VERSION=40,a.PENALTY_N1=3,a.PENALTY_N2=3,a.PENALTY_N3=40,a.PENALTY_N4=10,a.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]],a.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]],h.QrCode=a;function i(e,t,r){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let o=t-1;o>=0;o--)r.push(e>>>o&1)}function m(e,t){return(e>>>t&1)!=0}function u(e){if(!e)throw new Error("Assertion error")}const d=class{constructor(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let t=[];for(const r of e)i(r,8,t);return new d(d.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!d.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let r=0;r=1<{(n=>{const a=class{constructor(m,u){this.ordinal=m,this.formatBits=u}};let i=a;i.LOW=new a(0,1),i.MEDIUM=new a(1,0),i.QUARTILE=new a(2,3),i.HIGH=new a(3,2),n.Ecc=i})(h.QrCode||(h.QrCode={}))})(A||(A={}));(h=>{(n=>{const a=class{constructor(m,u){this.modeBits=m,this.numBitsCharCount=u}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};let i=a;i.NUMERIC=new a(1,[10,12,14]),i.ALPHANUMERIC=new a(2,[9,11,13]),i.BYTE=new a(4,[8,16,16]),i.KANJI=new a(8,[8,10,12]),i.ECI=new a(7,[0,0,0]),n.Mode=i})(h.QrSegment||(h.QrSegment={}))})(A||(A={}));var P=A;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var $={L:P.QrCode.Ecc.LOW,M:P.QrCode.Ecc.MEDIUM,Q:P.QrCode.Ecc.QUARTILE,H:P.QrCode.Ecc.HIGH},Y=128,j="L",V="#FFFFFF",G="#000000",X=!1,B=4,Ce=.1;function W(h,n=0){const a=[];return h.forEach(function(i,m){let u=null;i.forEach(function(d,E){if(!d&&u!==null){a.push(`M${u+n} ${m+n}h${E-u}v1H${u+n}z`),u=null;return}if(E===i.length-1){if(!d)return;u===null?a.push(`M${E+n},${m+n} h1v1H${E+n}z`):a.push(`M${u+n},${m+n} h${E+1-u}v1H${u+n}z`);return}d&&u===null&&(u=E)})}),a.join("")}function K(h,n){return h.slice().map((a,i)=>i=n.y+n.h?a:a.map((m,u)=>u=n.x+n.w?m:!1))}function q(h,n,a,i){if(i==null)return null;const m=a?B:0,u=h.length+m*2,d=Math.floor(n*Ce),E=u/n,e=(i.width||d)*E,t=(i.height||d)*E,r=i.x==null?h.length/2-e/2:i.x*E,o=i.y==null?h.length/2-t/2:i.y*E;let s=null;if(i.excavate){let c=Math.floor(r),l=Math.floor(o),g=Math.ceil(e+r-c),f=Math.ceil(t+o-l);s={x:c,y:l,w:g,h:f}}return{x:r,y:o,h:t,w:e,excavation:s}}var Ee=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}();function pe(h){const n=h,{value:a,size:i=Y,level:m=j,bgColor:u=V,fgColor:d=G,includeMargin:E=X,style:e,imageSettings:t}=n,r=O(n,["value","size","level","bgColor","fgColor","includeMargin","style","imageSettings"]),o=t==null?void 0:t.src,s=I.useRef(null),c=I.useRef(null),[l,g]=I.useState(!1);I.useEffect(()=>{if(s.current!=null){const v=s.current,C=v.getContext("2d");if(!C)return;let p=P.QrCode.encodeText(a,$[m]).getModules();const w=E?B:0,y=p.length+w*2,R=q(p,i,E,t),S=c.current,F=R!=null&&S!==null&&S.complete&&S.naturalHeight!==0&&S.naturalWidth!==0;F&&R.excavation!=null&&(p=K(p,R.excavation));const T=window.devicePixelRatio||1;v.height=v.width=i*T;const z=i/y*T;C.scale(z,z),C.fillStyle=u,C.fillRect(0,0,y,y),C.fillStyle=d,Ee?C.fill(new Path2D(W(p,w))):p.forEach(function(Z,J){Z.forEach(function(ee,te){ee&&C.fillRect(te+w,J+w,1,1)})}),F&&C.drawImage(S,R.x+w,R.y+w,R.w,R.h)}}),I.useEffect(()=>{g(!1)},[o]);const f=b({height:i,width:i},e);let M=null;return o!=null&&(M=_("img",{src:o,style:{display:"none"},onLoad:()=>{g(!0)},ref:c},o)),Q(re,{children:[_("canvas",{...b({style:f,height:i,width:i,ref:s},r)}),M]})}function we(h){const n=h,{value:a,size:i=Y,level:m=j,bgColor:u=V,fgColor:d=G,includeMargin:E=X,imageSettings:e}=n,t=O(n,["value","size","level","bgColor","fgColor","includeMargin","imageSettings"]);let r=P.QrCode.encodeText(a,$[m]).getModules();const o=E?B:0,s=r.length+o*2,c=q(r,i,E,e);let l=null;e!=null&&c!=null&&(c.excavation!=null&&(r=K(r,c.excavation)),l=_("image",{xlinkHref:e.src,height:c.h,width:c.w,x:c.x+o,y:c.y+o,preserveAspectRatio:"none"}));const g=W(r,o);return Q("svg",{...b({height:i,width:i,viewBox:`0 0 ${s} ${s}`},t),children:[_("path",{fill:u,d:`M0,0 h${s}v${s}H0z`,shapeRendering:"crispEdges"}),_("path",{fill:d,d:g,shapeRendering:"crispEdges"}),l]})}var ve=h=>{const n=h,{renderAs:a}=n,i=O(n,["renderAs"]);return a==="svg"?_(we,{...b({},i)}):_(pe,{...b({},i)})};function D(h,n){var a=URL.createObjectURL(h),i=document.createElement("a");i.href=a,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(function(){return URL.revokeObjectURL(a)},500)}var Me=function(h){x(n,h);function n(a){var i=h.call(this,a)||this;return i.ref=N.createRef(),i}return n.prototype.getImageSettings=function(){var a=this.props,i=a.imageSettings,m=a.data;if(!(!i||!oe(i)||!i.src||typeof i.src!="string"))return ne(i.src)&&(i.src=se(i.src,m,"| raw")),ie(i,function(u,d){return~["width","height","x","y"].indexOf(d)?ae(u)?Number(u):null:u})},n.prototype.doAction=function(a,i,m,u){var d,E=this.props.codeSize,e=a==null?void 0:a.actionType;if(e==="saveAs"&&!((d=this.ref)===null||d===void 0)&&d.current)if(this.props.mode==="svg"){var t=this.ref.current.querySelector("svg");if(t){var r=' `).concat(t.innerHTML,` `),o=new Blob([r],{type:"image/svg+xml"});D(o,(u==null?void 0:u.name)||"qr-code.svg")}}else{var s=this.ref.current.querySelector("canvas");s&&s.toBlob(function(c){c&&D(c,u!=null&&u.name?u.name.replace(/\.svg$/,".png"):"qr-code.png")},"image/png")}},n.prototype.render=function(){var a=this.props,i=a.className,m=a.style,u=a.qrcodeClassName,d=a.codeSize,E=a.backgroundColor,e=a.foregroundColor,t=a.placeholder,r=a.level,o=a.defaultValue,s=a.data,c=a.mode,l=a.translate,g=a.classPrefix,f=le(this.props,function(){return me(o,s,"| raw")||void 0});return N.createElement("div",{className:ce("".concat(g,"QrCode"),i),style:m,ref:this.ref},f?f.length>2953?N.createElement("span",{className:"text-danger"},l("QRCode.tooLong",{max:2953})):N.createElement(ve,{className:u,value:f,size:d,bgColor:E,fgColor:e,level:r||"L",imageSettings:this.getImageSettings(),renderAs:c}):N.createElement("span",{className:"".concat(g,"QrCode--placeholder")},t))},n.defaultProps={codeSize:128,qrcodeClassName:"",backgroundColor:"#fff",foregroundColor:"#000",level:"L",placeholder:"-",mode:"canvas"},n}(N.Component),_e=function(h){x(n,h);function n(a,i){var m=h.call(this,a)||this,u=i;return u.registerComponent(m),m}return n.prototype.componentWillUnmount=function(){var a;(a=h.prototype.componentWillUnmount)===null||a===void 0||a.call(this);var i=this.context;i.unRegisterComponent(this)},n.contextType=ue,n=he([de({type:"qrcode",alias:["qr-code"],name:"qrcode"}),fe("design:paramtypes",[Object,Object])],n),n}(Me);export{_e as QRCodeRenderer,Me as default};