2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
import{m as Q,aF as tt,_ as b,r as et,cg as nt,bP as I,k as ot,j as y,bR as st,d9 as it,y as rt,cQ as lt,S as at,ay as ct}from"./bootstrap-CvQmCMXe.js";import{j as C,m as L,aa as D,bl as P,bF as U,w as ut,I as $,b9 as ht}from"../jse/index-index-CAIAj58w.js";const ft=r=>{const{componentCls:s}=r;return{[s]:b(b({},et(r)),{display:"flex",justifyContent:"center",alignItems:"center",padding:r.paddingSM,backgroundColor:r.colorWhite,borderRadius:r.borderRadiusLG,border:`${r.lineWidth}px ${r.lineType} ${r.colorSplit}`,position:"relative",width:"100%",height:"100%",overflow:"hidden",[`& > ${s}-mask`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,zIndex:10,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",color:r.colorText,lineHeight:r.lineHeight,background:r.QRCodeMaskBackgroundColor,textAlign:"center",[`& > ${s}-expired , & > ${s}-scanned`]:{color:r.QRCodeTextColor}},"&-icon":{marginBlockEnd:r.marginXS,fontSize:r.controlHeight}}),[`${s}-borderless`]:{borderColor:"transparent"}}},dt=Q("QRCode",r=>ft(tt(r,{QRCodeTextColor:"rgba(0, 0, 0, 0.88)",QRCodeMaskBackgroundColor:"rgba(255, 255, 255, 0.96)"})));var gt={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"};function F(r){for(var s=1;s<arguments.length;s++){var l=arguments[s]!=null?Object(arguments[s]):{},f=Object.keys(l);typeof Object.getOwnPropertySymbols=="function"&&(f=f.concat(Object.getOwnPropertySymbols(l).filter(function(h){return Object.getOwnPropertyDescriptor(l,h).enumerable}))),f.forEach(function(h){mt(r,h,l[h])})}return r}function mt(r,s,l){return s in r?Object.defineProperty(r,s,{value:l,enumerable:!0,configurable:!0,writable:!0}):r[s]=l,r}var z=function(s,l){var f=F({},s,l.attrs);return C(nt,F({},f,{icon:gt}),null)};z.displayName="ReloadOutlined";z.inheritAttrs=!1;const O=()=>({size:{type:Number,default:160},value:{type:String,required:!0},type:I("canvas"),color:String,bgColor:String,includeMargin:Boolean,imageSettings:ot()}),Et=()=>b(b({},O()),{errorLevel:I("M"),icon:String,iconSize:{type:Number,default:40},status:I("active"),bordered:{type:Boolean,default:!0}});var R;(function(r){class s{static encodeText(t,n){const e=r.QrSegment.makeSegments(t);return s.encodeSegments(e,n)}static encodeBinary(t,n){const e=r.QrSegment.makeBytes(t);return s.encodeSegments([e],n)}static encodeSegments(t,n){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:40,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1,u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;if(!(s.MIN_VERSION<=e&&e<=o&&o<=s.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");let c,g;for(c=e;;c++){const m=s.getNumDataCodewords(c,n)*8,M=a.getTotalBits(t,c);if(M<=m){g=M;break}if(c>=o)throw new RangeError("Data too long")}for(const m of[s.Ecc.MEDIUM,s.Ecc.QUARTILE,s.Ecc.HIGH])u&&g<=s.getNumDataCodewords(c,m)*8&&(n=m);const d=[];for(const m of t){l(m.mode.modeBits,4,d),l(m.numChars,m.mode.numCharCountBits(c),d);for(const M of m.getData())d.push(M)}h(d.length==g);const p=s.getNumDataCodewords(c,n)*8;h(d.length<=p),l(0,Math.min(4,p-d.length),d),l(0,(8-d.length%8)%8,d),h(d.length%8==0);for(let m=236;d.length<p;m^=253)l(m,8,d);const w=[];for(;w.length*8<d.length;)w.push(0);return d.forEach((m,M)=>w[M>>>3]|=m<<7-(M&7)),new s(c,n,w,i)}constructor(t,n,e,o){if(this.version=t,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],t<s.MIN_VERSION||t>s.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=t*4+17;const i=[];for(let c=0;c<this.size;c++)i.push(!1);for(let c=0;c<this.size;c++)this.modules.push(i.slice()),this.isFunction.push(i.slice());this.drawFunctionPatterns();const u=this.addEccAndInterleave(e);if(this.drawCodewords(u),o==-1){let c=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const d=this.getPenaltyScore();d<c&&(o=g,c=d),this.applyMask(g)}}h(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}getModule(t,n){return 0<=t&&t<this.size&&0<=n&&n<this.size&&this.modules[n][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let e=0;e<n;e++)for(let o=0;o<n;o++)e==0&&o==0||e==0&&o==n-1||e==n-1&&o==0||this.drawAlignmentPattern(t[e],t[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.errorCorrectionLevel.formatBits<<3|t;let e=n;for(let i=0;i<10;i++)e=e<<1^(e>>>9)*1335;const o=(n<<10|e)^21522;h(o>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,f(o,i));this.setFunctionModule(8,7,f(o,6)),this.setFunctionModule(8,8,f(o,7)),this.setFunctionModule(7,8,f(o,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,f(o,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,f(o,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,f(o,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let e=0;e<12;e++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;h(n>>>18==0);for(let e=0;e<18;e++){const o=f(n,e),i=this.size-11+e%3,u=Math.floor(e/3);this.setFunctionModule(i,u,o),this.setFunctionModule(u,i,o)}}drawFinderPattern(t,n){for(let e=-4;e<=4;e++)for(let o=-4;o<=4;o++){const i=Math.max(Math.abs(o),Math.abs(e)),u=t+o,c=n+e;0<=u&&u<this.size&&0<=c&&c<this.size&&this.setFunctionModule(u,c,i!=2&&i!=4)}}drawAlignmentPattern(t,n){for(let e=-2;e<=2;e++)for(let o=-2;o<=2;o++)this.setFunctionModule(t+o,n+e,Math.max(Math.abs(o),Math.abs(e))!=1)}setFunctionModule(t,n,e){this.modules[n][t]=e,this.isFunction[n][t]=!0}addEccAndInterleave(t){const n=this.version,e=this.errorCorrectionLevel;if(t.length!=s.getNumDataCodewords(n,e))throw new RangeError("Invalid argument");const o=s.NUM_ERROR_CORRECTION_BLOCKS[e.ordinal][n],i=s.ECC_CODEWORDS_PER_BLOCK[e.ordinal][n],u=Math.floor(s.getNumRawDataModules(n)/8),c=o-u%o,g=Math.floor(u/o),d=[],p=s.reedSolomonComputeDivisor(i);for(let m=0,M=0;m<o;m++){const v=t.slice(M,M+g-i+(m<c?0:1));M+=v.length;const A=s.reedSolomonComputeRemainder(v,p);m<c&&v.push(0),d.push(v.concat(A))}const w=[];for(let m=0;m<d[0].length;m++)d.forEach((M,v)=>{(m!=g-i||v>=c)&&w.push(M[m])});return h(w.length==u),w}drawCodewords(t){if(t.length!=Math.floor(s.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let e=this.size-1;e>=1;e-=2){e==6&&(e=5);for(let o=0;o<this.size;o++)for(let i=0;i<2;i++){const u=e-i,g=(e+1&2)==0?this.size-1-o:o;!this.isFunction[g][u]&&n<t.length*8&&(this.modules[g][u]=f(t[n>>>3],7-(n&7)),n++)}}h(n==t.length*8)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let e=0;e<this.size;e++){let o;switch(t){case 0:o=(e+n)%2==0;break;case 1:o=n%2==0;break;case 2:o=e%3==0;break;case 3:o=(e+n)%3==0;break;case 4:o=(Math.floor(e/3)+Math.floor(n/2))%2==0;break;case 5:o=e*n%2+e*n%3==0;break;case 6:o=(e*n%2+e*n%3)%2==0;break;case 7:o=((e+n)%2+e*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][e]&&o&&(this.modules[n][e]=!this.modules[n][e])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let u=!1,c=0;const g=[0,0,0,0,0,0,0];for(let d=0;d<this.size;d++)this.modules[i][d]==u?(c++,c==5?t+=s.PENALTY_N1:c>5&&t++):(this.finderPenaltyAddHistory(c,g),u||(t+=this.finderPenaltyCountPatterns(g)*s.PENALTY_N3),u=this.modules[i][d],c=1);t+=this.finderPenaltyTerminateAndCount(u,c,g)*s.PENALTY_N3}for(let i=0;i<this.size;i++){let u=!1,c=0;const g=[0,0,0,0,0,0,0];for(let d=0;d<this.size;d++)this.modules[d][i]==u?(c++,c==5?t+=s.PENALTY_N1:c>5&&t++):(this.finderPenaltyAddHistory(c,g),u||(t+=this.finderPenaltyCountPatterns(g)*s.PENALTY_N3),u=this.modules[d][i],c=1);t+=this.finderPenaltyTerminateAndCount(u,c,g)*s.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let u=0;u<this.size-1;u++){const c=this.modules[i][u];c==this.modules[i][u+1]&&c==this.modules[i+1][u]&&c==this.modules[i+1][u+1]&&(t+=s.PENALTY_N2)}let n=0;for(const i of this.modules)n=i.reduce((u,c)=>u+(c?1:0),n);const e=this.size*this.size,o=Math.ceil(Math.abs(n*20-e*10)/e)-1;return h(0<=o&&o<=9),t+=o*s.PENALTY_N4,h(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{const t=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,e=[6];for(let o=this.size-7;e.length<t;o-=n)e.splice(1,0,o);return e}}static getNumRawDataModules(t){if(t<s.MIN_VERSION||t>s.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return h(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(s.getNumRawDataModules(t)/8)-s.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*s.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");const n=[];for(let o=0;o<t-1;o++)n.push(0);n.push(1);let e=1;for(let o=0;o<t;o++){for(let i=0;i<n.length;i++)n[i]=s.reedSolomonMultiply(n[i],e),i+1<n.length&&(n[i]^=n[i+1]);e=s.reedSolomonMultiply(e,2)}return n}static reedSolomonComputeRemainder(t,n){const e=n.map(o=>0);for(const o of t){const i=o^e.shift();e.push(0),n.forEach((u,c)=>e[c]^=s.reedSolomonMultiply(u,i))}return e}static reedSolomonMultiply(t,n){if(t>>>8||n>>>8)throw new RangeError("Byte out of range");let e=0;for(let o=7;o>=0;o--)e=e<<1^(e>>>7)*285,e^=(n>>>o&1)*t;return h(e>>>8==0),e}finderPenaltyCountPatterns(t){const n=t[1];h(n<=this.size*3);const e=n>0&&t[2]==n&&t[3]==n*3&&t[4]==n&&t[5]==n;return(e&&t[0]>=n*4&&t[6]>=n?1:0)+(e&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,e){return t&&(this.finderPenaltyAddHistory(n,e),n=0),n+=this.size,this.finderPenaltyAddHistory(n,e),this.finderPenaltyCountPatterns(e)}finderPenaltyAddHistory(t,n){n[0]==0&&(t+=this.size),n.pop(),n.unshift(t)}}s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.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]],s.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]],r.QrCode=s;function l(E,t,n){if(t<0||t>31||E>>>t)throw new RangeError("Value out of range");for(let e=t-1;e>=0;e--)n.push(E>>>e&1)}function f(E,t){return(E>>>t&1)!=0}function h(E){if(!E)throw new Error("Assertion error")}class a{static makeBytes(t){const n=[];for(const e of t)l(e,8,n);return new a(a.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!a.isNumeric(t))throw new RangeError("String contains non-numeric characters");const n=[];for(let e=0;e<t.length;){const o=Math.min(t.length-e,3);l(parseInt(t.substring(e,e+o),10),o*3+1,n),e+=o}return new a(a.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!a.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");const n=[];let e;for(e=0;e+2<=t.length;e+=2){let o=a.ALPHANUMERIC_CHARSET.indexOf(t.charAt(e))*45;o+=a.ALPHANUMERIC_CHARSET.indexOf(t.charAt(e+1)),l(o,11,n)}return e<t.length&&l(a.ALPHANUMERIC_CHARSET.indexOf(t.charAt(e)),6,n),new a(a.Mode.ALPHANUMERIC,t.length,n)}static makeSegments(t){return t==""?[]:a.isNumeric(t)?[a.makeNumeric(t)]:a.isAlphanumeric(t)?[a.makeAlphanumeric(t)]:[a.makeBytes(a.toUtf8ByteArray(t))]}static makeEci(t){const n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)l(t,8,n);else if(t<16384)l(2,2,n),l(t,14,n);else if(t<1e6)l(6,3,n),l(t,21,n);else throw new RangeError("ECI assignment value out of range");return new a(a.Mode.ECI,0,n)}static isNumeric(t){return a.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return a.ALPHANUMERIC_REGEX.test(t)}constructor(t,n,e){if(this.mode=t,this.numChars=n,this.bitData=e,n<0)throw new RangeError("Invalid argument");this.bitData=e.slice()}getData(){return this.bitData.slice()}static getTotalBits(t,n){let e=0;for(const o of t){const i=o.mode.numCharCountBits(n);if(o.numChars>=1<<i)return 1/0;e+=4+i+o.bitData.length}return e}static toUtf8ByteArray(t){t=encodeURI(t);const n=[];for(let e=0;e<t.length;e++)t.charAt(e)!="%"?n.push(t.charCodeAt(e)):(n.push(parseInt(t.substring(e+1,e+3),16)),e+=2);return n}}a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",r.QrSegment=a})(R||(R={}));(function(r){(function(s){class l{constructor(h,a){this.ordinal=h,this.formatBits=a}}l.LOW=new l(0,1),l.MEDIUM=new l(1,0),l.QUARTILE=new l(2,3),l.HIGH=new l(3,2),s.Ecc=l})(r.QrCode||(r.QrCode={}))})(R||(R={}));(function(r){(function(s){class l{constructor(h,a){this.modeBits=h,this.numBitsCharCount=a}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}}l.NUMERIC=new l(1,[10,12,14]),l.ALPHANUMERIC=new l(2,[9,11,13]),l.BYTE=new l(4,[8,16,16]),l.KANJI=new l(8,[8,10,12]),l.ECI=new l(7,[0,0,0]),s.Mode=l})(r.QrSegment||(r.QrSegment={}))})(R||(R={}));const k={L:R.QrCode.Ecc.LOW,M:R.QrCode.Ecc.MEDIUM,Q:R.QrCode.Ecc.QUARTILE,H:R.QrCode.Ecc.HIGH},S=128,H="L",G="#FFFFFF",Y="#000000",j=!1,Mt=4,wt=0,Ct=.1;function V(r){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const l=[];return r.forEach(function(f,h){let a=null;f.forEach(function(E,t){if(!E&&a!==null){l.push(`M${a+s} ${h+s}h${t-a}v1H${a+s}z`),a=null;return}if(t===f.length-1){if(!E)return;a===null?l.push(`M${t+s},${h+s} h1v1H${t+s}z`):l.push(`M${a+s},${h+s} h${t+1-a}v1H${a+s}z`);return}E&&a===null&&(a=t)})}),l.join("")}function _(r,s){return r.slice().map((l,f)=>f<s.y||f>=s.y+s.h?l:l.map((h,a)=>a<s.x||a>=s.x+s.w?h:!1))}function X(r,s,l,f){if(f==null)return null;const h=r.length+l*2,a=Math.floor(s*Ct),E=h/s,t=(f.width||a)*E,n=(f.height||a)*E,e=f.x==null?r.length/2-t/2:f.x*E,o=f.y==null?r.length/2-n/2:f.y*E;let i=null;if(f.excavate){const u=Math.floor(e),c=Math.floor(o),g=Math.ceil(t+e-u),d=Math.ceil(n+o-c);i={x:u,y:c,w:g,h:d}}return{x:e,y:o,h:n,w:t,excavation:i}}function W(r,s){return s!=null?Math.floor(s):r?Mt:wt}const Rt=function(){try{new Path2D().addPath(new Path2D)}catch(r){return!1}return!0}(),pt=L({name:"QRCodeCanvas",inheritAttrs:!1,props:b(b({},O()),{level:String,bgColor:String,fgColor:String,marginSize:Number}),setup(r,s){let{attrs:l,expose:f}=s;const h=D(()=>{var n;return(n=r.imageSettings)===null||n===void 0?void 0:n.src}),a=P(null),E=P(null),t=P(!1);return f({toDataURL:(n,e)=>{var o;return(o=a.value)===null||o===void 0?void 0:o.toDataURL(n,e)}}),U(()=>{const{value:n,size:e=S,level:o=H,bgColor:i=G,fgColor:u=Y,includeMargin:c=j,marginSize:g,imageSettings:d}=r;if(a.value!=null){const p=a.value,w=p.getContext("2d");if(!w)return;let m=R.QrCode.encodeText(n,k[o]).getModules();const M=W(c,g),v=m.length+M*2,A=X(m,e,M,d),N=E.value,x=t.value&&A!=null&&N!==null&&N.complete&&N.naturalHeight!==0&&N.naturalWidth!==0;x&&A.excavation!=null&&(m=_(m,A.excavation));const B=window.devicePixelRatio||1;p.height=p.width=e*B;const T=e/v*B;w.scale(T,T),w.fillStyle=i,w.fillRect(0,0,v,v),w.fillStyle=u,Rt?w.fill(new Path2D(V(m,M))):m.forEach(function(K,Z){K.forEach(function(q,J){q&&w.fillRect(J+M,Z+M,1,1)})}),x&&w.drawImage(N,A.x+M,A.y+M,A.w,A.h)}},{flush:"post"}),ut(h,()=>{t.value=!1}),()=>{var n;const e=(n=r.size)!==null&&n!==void 0?n:S,o={height:`${e}px`,width:`${e}px`};let i=null;return h.value!=null&&(i=C("img",{src:h.value,key:h.value,style:{display:"none"},onLoad:()=>{t.value=!0},ref:E},null)),C($,null,[C("canvas",y(y({},l),{},{style:[o,l.style],ref:a}),null),i])}}}),vt=L({name:"QRCodeSVG",inheritAttrs:!1,props:b(b({},O()),{color:String,level:String,bgColor:String,fgColor:String,marginSize:Number,title:String}),setup(r){let s=null,l=null,f=null,h=null,a=null,E=null;return U(()=>{const{value:t,size:n=S,level:e=H,includeMargin:o=j,marginSize:i,imageSettings:u}=r;s=R.QrCode.encodeText(t,k[e]).getModules(),l=W(o,i),f=s.length+l*2,h=X(s,n,l,u),u!=null&&h!=null&&(h.excavation!=null&&(s=_(s,h.excavation)),E=C("image",{"xlink:href":u.src,height:h.h,width:h.w,x:h.x+l,y:h.y+l,preserveAspectRatio:"none"},null)),a=V(s,l)}),()=>{const t=r.bgColor&&G,n=r.fgColor&&Y;return C("svg",{height:r.size,width:r.size,viewBox:`0 0 ${f} ${f}`},[!!r.title&&C("title",null,[r.title]),C("path",{fill:t,d:`M0,0 h${f}v${f}H0z`,"shape-rendering":"crispEdges"},null),C("path",{fill:n,d:a,"shape-rendering":"crispEdges"},null),E])}}}),At=L({name:"AQrcode",inheritAttrs:!1,props:Et(),emits:["refresh"],setup(r,s){let{emit:l,attrs:f,expose:h}=s;const[a]=it("QRCode"),{prefixCls:E}=rt("qrcode",r),[t,n]=dt(E),[,e]=lt(),o=ht();h({toDataURL:(u,c)=>{var g;return(g=o.value)===null||g===void 0?void 0:g.toDataURL(u,c)}});const i=D(()=>{const{value:u,icon:c="",size:g=160,iconSize:d=40,color:p=e.value.colorText,bgColor:w="transparent",errorLevel:m="M"}=r,M={src:c,x:void 0,y:void 0,height:d,width:d,excavate:!0};return{value:u,size:g-(e.value.paddingSM+e.value.lineWidth)*2,level:m,bgColor:w,fgColor:p,imageSettings:c?M:void 0}});return()=>{const u=E.value;return t(C("div",y(y({},f),{},{style:[f.style,{width:`${r.size}px`,height:`${r.size}px`,backgroundColor:i.value.bgColor}],class:[n.value,u,{[`${u}-borderless`]:!r.bordered}]}),[r.status!=="active"&&C("div",{class:`${u}-mask`},[r.status==="loading"&&C(at,null,null),r.status==="expired"&&C($,null,[C("p",{class:`${u}-expired`},[a.value.expired]),C(ct,{type:"link",onClick:c=>l("refresh",c)},{default:()=>[a.value.refresh],icon:()=>C(z,null,null)})]),r.status==="scanned"&&C("p",{class:`${u}-scanned`},[a.value.scanned])]),r.type==="canvas"?C(pt,y({ref:o},i.value),null):C(vt,i.value,null)]))}}}),yt=st(At);export{yt as Q};
|