2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
import"./base-xgxQQEpV.js";import{e as ee}from"./el-overlay-hge8bsIn.js";import{A as G,G as p,h as y,g as T,i as te,Y as re,F as $,z as ae,j as U,l as Y,p as ne,a4 as oe,s as ie,n as K,o as D,k,t as q,c as ue}from"./vendor-vue-WbiK4TmU.js";import{b as le,d as se}from"./auth-B5cl_nsV.js";import{_ as ce}from"./style-CEbARg1o.js";import{E as H}from"./http-BoPYlvwK.js";var A=function(){return A=Object.assign||function(v){for(var f,l=1,s=arguments.length;l<s;l++){f=arguments[l];for(var c in f)Object.prototype.hasOwnProperty.call(f,c)&&(v[c]=f[c])}return v},A.apply(this,arguments)};var _;(function(o){var v=(function(){function a(e,t,r,n){if(this.version=e,this.errorCorrectionLevel=t,this.modules=[],this.isFunction=[],e<a.MIN_VERSION||e>a.MAX_VERSION)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;for(var i=[],u=0;u<this.size;u++)i.push(!1);for(var u=0;u<this.size;u++)this.modules.push(i.slice()),this.isFunction.push(i.slice());this.drawFunctionPatterns();var d=this.addEccAndInterleave(r);if(this.drawCodewords(d),n==-1)for(var E=1e9,u=0;u<8;u++){this.applyMask(u),this.drawFormatBits(u);var M=this.getPenaltyScore();M<E&&(n=u,E=M),this.applyMask(u)}s(0<=n&&n<=7),this.mask=n,this.applyMask(n),this.drawFormatBits(n),this.isFunction=[]}return a.encodeText=function(e,t){var r=o.QrSegment.makeSegments(e);return a.encodeSegments(r,t)},a.encodeBinary=function(e,t){var r=o.QrSegment.makeBytes(e);return a.encodeSegments([r],t)},a.encodeSegments=function(e,t,r,n,i,u){if(r===void 0&&(r=1),n===void 0&&(n=40),i===void 0&&(i=-1),u===void 0&&(u=!0),!(a.MIN_VERSION<=r&&r<=n&&n<=a.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");var d,E;for(d=r;;d++){var M=a.getNumDataCodewords(d,t)*8,R=c.getTotalBits(e,d);if(R<=M){E=R;break}if(d>=n)throw new RangeError("Data too long")}for(var w=0,S=[a.Ecc.MEDIUM,a.Ecc.QUARTILE,a.Ecc.HIGH];w<S.length;w++){var m=S[w];u&&E<=a.getNumDataCodewords(d,m)*8&&(t=m)}for(var h=[],g=0,C=e;g<C.length;g++){var P=C[g];f(P.mode.modeBits,4,h),f(P.numChars,P.mode.numCharCountBits(d),h);for(var I=0,N=P.getData();I<N.length;I++){var F=N[I];h.push(F)}}s(h.length==E);var b=a.getNumDataCodewords(d,t)*8;s(h.length<=b),f(0,Math.min(4,b-h.length),h),f(0,(8-h.length%8)%8,h),s(h.length%8==0);for(var z=236;h.length<b;z^=253)f(z,8,h);for(var L=[];L.length*8<h.length;)L.push(0);return h.forEach(function(Q,O){return L[O>>>3]|=Q<<7-(O&7)}),new a(d,t,L,i)},a.prototype.getModule=function(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]},a.prototype.getModules=function(){return this.modules},a.prototype.drawFunctionPatterns=function(){for(var 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);for(var t=this.getAlignmentPatternPositions(),r=t.length,e=0;e<r;e++)for(var n=0;n<r;n++)e==0&&n==0||e==0&&n==r-1||e==r-1&&n==0||this.drawAlignmentPattern(t[e],t[n]);this.drawFormatBits(0),this.drawVersion()},a.prototype.drawFormatBits=function(e){for(var t=this.errorCorrectionLevel.formatBits<<3|e,r=t,n=0;n<10;n++)r=r<<1^(r>>>9)*1335;var i=(t<<10|r)^21522;s(i>>>15==0);for(var n=0;n<=5;n++)this.setFunctionModule(8,n,l(i,n));this.setFunctionModule(8,7,l(i,6)),this.setFunctionModule(8,8,l(i,7)),this.setFunctionModule(7,8,l(i,8));for(var n=9;n<15;n++)this.setFunctionModule(14-n,8,l(i,n));for(var n=0;n<8;n++)this.setFunctionModule(this.size-1-n,8,l(i,n));for(var n=8;n<15;n++)this.setFunctionModule(8,this.size-15+n,l(i,n));this.setFunctionModule(8,this.size-8,!0)},a.prototype.drawVersion=function(){if(!(this.version<7)){for(var e=this.version,t=0;t<12;t++)e=e<<1^(e>>>11)*7973;var r=this.version<<12|e;s(r>>>18==0);for(var t=0;t<18;t++){var n=l(r,t),i=this.size-11+t%3,u=Math.floor(t/3);this.setFunctionModule(i,u,n),this.setFunctionModule(u,i,n)}}},a.prototype.drawFinderPattern=function(e,t){for(var r=-4;r<=4;r++)for(var n=-4;n<=4;n++){var i=Math.max(Math.abs(n),Math.abs(r)),u=e+n,d=t+r;0<=u&&u<this.size&&0<=d&&d<this.size&&this.setFunctionModule(u,d,i!=2&&i!=4)}},a.prototype.drawAlignmentPattern=function(e,t){for(var r=-2;r<=2;r++)for(var n=-2;n<=2;n++)this.setFunctionModule(e+n,t+r,Math.max(Math.abs(n),Math.abs(r))!=1)},a.prototype.setFunctionModule=function(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0},a.prototype.addEccAndInterleave=function(e){var t=this.version,r=this.errorCorrectionLevel;if(e.length!=a.getNumDataCodewords(t,r))throw new RangeError("Invalid argument");for(var n=a.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t],i=a.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t],u=Math.floor(a.getNumRawDataModules(t)/8),d=n-u%n,E=Math.floor(u/n),M=[],R=a.reedSolomonComputeDivisor(i),w=0,S=0;w<n;w++){var m=e.slice(S,S+E-i+(w<d?0:1));S+=m.length;var h=a.reedSolomonComputeRemainder(m,R);w<d&&m.push(0),M.push(m.concat(h))}for(var g=[],C=function(P){M.forEach(function(I,N){(P!=E-i||N>=d)&&g.push(I[P])})},w=0;w<M[0].length;w++)C(w);return s(g.length==u),g},a.prototype.drawCodewords=function(e){if(e.length!=Math.floor(a.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");for(var t=0,r=this.size-1;r>=1;r-=2){r==6&&(r=5);for(var n=0;n<this.size;n++)for(var i=0;i<2;i++){var u=r-i,d=(r+1&2)==0,E=d?this.size-1-n:n;!this.isFunction[E][u]&&t<e.length*8&&(this.modules[E][u]=l(e[t>>>3],7-(t&7)),t++)}}s(t==e.length*8)},a.prototype.applyMask=function(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(var t=0;t<this.size;t++)for(var r=0;r<this.size;r++){var n=void 0;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}},a.prototype.getPenaltyScore=function(){for(var e=0,t=0;t<this.size;t++){for(var r=!1,n=0,i=[0,0,0,0,0,0,0],u=0;u<this.size;u++)this.modules[t][u]==r?(n++,n==5?e+=a.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,i),r||(e+=this.finderPenaltyCountPatterns(i)*a.PENALTY_N3),r=this.modules[t][u],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,i)*a.PENALTY_N3}for(var u=0;u<this.size;u++){for(var r=!1,d=0,i=[0,0,0,0,0,0,0],t=0;t<this.size;t++)this.modules[t][u]==r?(d++,d==5?e+=a.PENALTY_N1:d>5&&e++):(this.finderPenaltyAddHistory(d,i),r||(e+=this.finderPenaltyCountPatterns(i)*a.PENALTY_N3),r=this.modules[t][u],d=1);e+=this.finderPenaltyTerminateAndCount(r,d,i)*a.PENALTY_N3}for(var t=0;t<this.size-1;t++)for(var u=0;u<this.size-1;u++){var E=this.modules[t][u];E==this.modules[t][u+1]&&E==this.modules[t+1][u]&&E==this.modules[t+1][u+1]&&(e+=a.PENALTY_N2)}for(var M=0,R=0,w=this.modules;R<w.length;R++){var S=w[R];M=S.reduce(function(g,C){return g+(C?1:0)},M)}var m=this.size*this.size,h=Math.ceil(Math.abs(M*20-m*10)/m)-1;return s(0<=h&&h<=9),e+=h*a.PENALTY_N4,s(0<=e&&e<=2568888),e},a.prototype.getAlignmentPatternPositions=function(){if(this.version==1)return[];for(var e=Math.floor(this.version/7)+2,t=Math.floor((this.version*8+e*3+5)/(e*4-4))*2,r=[6],n=this.size-7;r.length<e;n-=t)r.splice(1,0,n);return r},a.getNumRawDataModules=function(e){if(e<a.MIN_VERSION||e>a.MAX_VERSION)throw new RangeError("Version number out of range");var t=(16*e+128)*e+64;if(e>=2){var r=Math.floor(e/7)+2;t-=(25*r-10)*r-55,e>=7&&(t-=36)}return s(208<=t&&t<=29648),t},a.getNumDataCodewords=function(e,t){return Math.floor(a.getNumRawDataModules(e)/8)-a.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e]*a.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][e]},a.reedSolomonComputeDivisor=function(e){if(e<1||e>255)throw new RangeError("Degree out of range");for(var t=[],r=0;r<e-1;r++)t.push(0);t.push(1);for(var n=1,r=0;r<e;r++){for(var i=0;i<t.length;i++)t[i]=a.reedSolomonMultiply(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=a.reedSolomonMultiply(n,2)}return t},a.reedSolomonComputeRemainder=function(e,t){for(var r=t.map(function(E){return 0}),n=function(E){var M=E^r.shift();r.push(0),t.forEach(function(R,w){return r[w]^=a.reedSolomonMultiply(R,M)})},i=0,u=e;i<u.length;i++){var d=u[i];n(d)}return r},a.reedSolomonMultiply=function(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");for(var r=0,n=7;n>=0;n--)r=r<<1^(r>>>7)*285,r^=(t>>>n&1)*e;return s(r>>>8==0),r},a.prototype.finderPenaltyCountPatterns=function(e){var t=e[1];s(t<=this.size*3);var 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)},a.prototype.finderPenaltyTerminateAndCount=function(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)},a.prototype.finderPenaltyAddHistory=function(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)},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]],a})();o.QrCode=v;function f(a,e,t){if(e<0||e>31||a>>>e)throw new RangeError("Value out of range");for(var r=e-1;r>=0;r--)t.push(a>>>r&1)}function l(a,e){return(a>>>e&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}var c=(function(){function a(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}return a.makeBytes=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];f(i,8,t)}return new a(a.Mode.BYTE,e.length,t)},a.makeNumeric=function(e){if(!a.isNumeric(e))throw new RangeError("String contains non-numeric characters");for(var t=[],r=0;r<e.length;){var n=Math.min(e.length-r,3);f(parseInt(e.substring(r,r+n),10),n*3+1,t),r+=n}return new a(a.Mode.NUMERIC,e.length,t)},a.makeAlphanumeric=function(e){if(!a.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");var t=[],r;for(r=0;r+2<=e.length;r+=2){var n=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r))*45;n+=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r+1)),f(n,11,t)}return r<e.length&&f(a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r)),6,t),new a(a.Mode.ALPHANUMERIC,e.length,t)},a.makeSegments=function(e){return e==""?[]:a.isNumeric(e)?[a.makeNumeric(e)]:a.isAlphanumeric(e)?[a.makeAlphanumeric(e)]:[a.makeBytes(a.toUtf8ByteArray(e))]},a.makeEci=function(e){var t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)f(e,8,t);else if(e<16384)f(2,2,t),f(e,14,t);else if(e<1e6)f(6,3,t),f(e,21,t);else throw new RangeError("ECI assignment value out of range");return new a(a.Mode.ECI,0,t)},a.isNumeric=function(e){return a.NUMERIC_REGEX.test(e)},a.isAlphanumeric=function(e){return a.ALPHANUMERIC_REGEX.test(e)},a.prototype.getData=function(){return this.bitData.slice()},a.getTotalBits=function(e,t){for(var r=0,n=0,i=e;n<i.length;n++){var u=i[n],d=u.mode.numCharCountBits(t);if(u.numChars>=1<<d)return 1/0;r+=4+d+u.bitData.length}return r},a.toUtf8ByteArray=function(e){e=encodeURI(e);for(var t=[],r=0;r<e.length;r++)e.charAt(r)!="%"?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t},a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",a})();o.QrSegment=c})(_||(_={}));(function(o){(function(v){var f=(function(){function l(s,c){this.ordinal=s,this.formatBits=c}return l.LOW=new l(0,1),l.MEDIUM=new l(1,0),l.QUARTILE=new l(2,3),l.HIGH=new l(3,2),l})();v.Ecc=f})(o.QrCode||(o.QrCode={}))})(_||(_={}));(function(o){(function(v){var f=(function(){function l(s,c){this.modeBits=s,this.numBitsCharCount=c}return l.prototype.numCharCountBits=function(s){return this.numBitsCharCount[Math.floor((s+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]),l})();v.Mode=f})(o.QrSegment||(o.QrSegment={}))})(_||(_={}));var B=_,fe=0;function de(o){return o||"v-".concat(fe++)}var W="L",ve=100,X=0,he=.1,ge=2,Z={L:B.QrCode.Ecc.LOW,M:B.QrCode.Ecc.MEDIUM,Q:B.QrCode.Ecc.QUARTILE,H:B.QrCode.Ecc.HIGH},me=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})();function J(o){return o in Z}function Ee(o,v,f){var l=v>0?o[v-1][f]:!1,s=v<o.length-1?o[v+1][f]:!1,c=f>0?o[v][f-1]:!1,a=f<o[v].length-1?o[v][f+1]:!1;return{nw:!l&&!c,ne:!l&&!a,se:!s&&!a,sw:!s&&!c}}function Ce(o,v,f){v===void 0&&(v=0),f===void 0&&(f=0);for(var l=[],s=Math.min(f,.5),c=0;c<o.length;c++)for(var a=0;a<o[c].length;a++)if(o[c][a]){var e=Ee(o,c,a),t=e.nw,r=e.ne,n=e.se,i=e.sw,u=a+v,d=c+v;l.push("M".concat(u+(t?s:0)," ").concat(d),"L".concat(u+1-(r?s:0)," ").concat(d)),r&&l.push("A".concat(s," ").concat(s," 0 0 1 ").concat(u+1," ").concat(d+s)),l.push("L".concat(u+1," ").concat(d+1-(n?s:0))),n&&l.push("A".concat(s," ").concat(s," 0 0 1 ").concat(u+1-s," ").concat(d+1)),l.push("L".concat(u+(i?s:0)," ").concat(d+1)),i&&l.push("A".concat(s," ").concat(s," 0 0 1 ").concat(u," ").concat(d+1-s)),l.push("L".concat(u," ").concat(d+(t?s:0))),t&&l.push("A".concat(s," ").concat(s," 0 0 1 ").concat(u+s," ").concat(d)),l.push("z")}return l.join("")}function we(o,v){v===void 0&&(v=0);for(var f=[],l=0;l<o.length;l++)for(var s=o[l],c=null,a=0;a<s.length;a++){var e=s[a];if(!e&&c!==null){f.push("M".concat(c+v," ").concat(l+v,"h").concat(a-c,"v1H").concat(c+v,"z")),c=null;continue}if(a===s.length-1){if(!e)continue;c===null?f.push("M".concat(a+v,",").concat(l+v," h1v1H").concat(a+v,"z")):f.push("M".concat(c+v,",").concat(l+v," h").concat(a+1-c,"v1H").concat(c+v,"z"));continue}e&&c===null&&(c=a)}return f.join("")}function Me(o,v,f,l){var s=l.width,c=l.height,a=l.x,e=l.y,t=o.length+f*2,r=Math.floor(v*he),n=t/v,i=(s||r)*n,u=(c||r)*n,d=a==null?o.length/2-i/2:a*n,E=e==null?o.length/2-u/2:e*n,M=(l.borderRadius||0)*n;return{x:d,y:E,h:u,w:i,borderRadius:M}}function x(o){var v=y(function(){var e;return((e=o.margin)!==null&&e!==void 0?e:X)>>>0}),f=y(function(){var e=J(o.level)?o.level:W;return B.QrCode.encodeText(o.value,Z[e]).getModules()}),l=y(function(){return f.value.length+v.value*2}),s=y(function(){return o.radius>0?Ce(f.value,v.value,o.radius):we(f.value,v.value)}),c=y(function(){if(!o.imageSettings.src)return null;var e=Me(f.value,o.size,v.value,o.imageSettings);return{x:e.x+v.value,y:e.y+v.value,width:e.w,height:e.h,borderRadius:e.borderRadius}}),a=y(function(){if(!o.imageSettings.excavate||!c.value)return null;var e=ge/(o.size/l.value);return{x:c.value.x-e,y:c.value.y-e,width:c.value.width+e*2,height:c.value.height+e*2,borderRadius:c.value.borderRadius}});return{margin:v,numCells:l,cells:f,fgPath:s,imageProps:c,imageBorderProps:a}}var V={value:{type:String,required:!0,default:""},size:{type:Number,default:ve},level:{type:String,default:W,validator:function(o){return J(o)}},background:{type:String,default:"#fff"},foreground:{type:String,default:"#000"},margin:{type:Number,required:!1,default:X},imageSettings:{type:Object,required:!1,default:function(){return{}}},gradient:{type:Boolean,required:!1,default:!1},gradientType:{type:String,required:!1,default:"linear",validator:function(o){return["linear","radial"].indexOf(o)>-1}},gradientStartColor:{type:String,required:!1,default:"#000"},gradientEndColor:{type:String,required:!1,default:"#fff"},radius:{type:Number,required:!1,default:0,validator:function(o){return!isNaN(o)&&o>=0&&o<=.5}},id:{type:String,required:!1}},Re=A(A({},V),{renderAs:{type:String,required:!1,default:"canvas",validator:function(o){return["canvas","svg"].indexOf(o)>-1}}}),Pe=G({name:"QRCodeSvg",props:V,setup:function(o){var v=x(o),f=v.numCells,l=v.fgPath,s=v.imageProps,c=v.imageBorderProps,a=de(o.id),e="qrcode.vue-gradient-".concat(a),t="qrcode.vue-logo-clip-path-".concat(a),r=y(function(){if(!o.gradient)return null;var i=o.gradientType==="linear"?{x1:"0%",y1:"0%",x2:"100%",y2:"100%"}:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"};return p(o.gradientType==="linear"?"linearGradient":"radialGradient",A({id:e},i),[p("stop",{offset:"0%",style:{stopColor:o.gradientStartColor}}),p("stop",{offset:"100%",style:{stopColor:o.gradientEndColor}})])}),n=y(function(){if(!s.value)return null;var i=s.value.borderRadius;return i<=0?null:p("clipPath",{id:t},[p("rect",{x:s.value.x,y:s.value.y,width:s.value.width,height:s.value.height,rx:i,ry:i})])});return function(){return p("svg",{width:o.size,height:o.size,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(f.value," ").concat(f.value),role:"img","aria-label":o.value},[p("defs",{},[r.value,n.value]),p("rect",{width:"100%",height:"100%",fill:o.background}),p("path",{fill:o.gradient?"url(#".concat(e,")"):o.foreground,d:l.value}),c.value&&p("rect",{x:c.value.x,y:c.value.y,width:c.value.width,height:c.value.height,fill:o.background,rx:c.value.borderRadius,ry:c.value.borderRadius}),o.imageSettings.src&&s.value&&p("image",A(A({href:o.imageSettings.src},s.value),s.value.borderRadius>0?{"clip-path":"url(#".concat(t,")")}:{}))])}}}),pe=G({name:"QRCodeCanvas",props:V,setup:function(o,v){var f=x(o),l=f.margin,s=f.cells,c=f.numCells,a=f.fgPath,e=f.imageProps,t=f.imageBorderProps,r=T(null),n=T(null),i=function(d,E,M,R,w,S){d.beginPath(),d.roundRect?d.roundRect(E,M,R,w,S):d.rect(E,M,R,w)},u=function(){var d=o.size,E=o.background,M=o.foreground,R=o.gradient,w=o.gradientType,S=o.gradientStartColor,m=o.gradientEndColor,h=r.value;if(h){var g=h.getContext("2d");if(g){var C=n.value,P=typeof window<"u"&&window.devicePixelRatio||1,I=d/c.value*P;if(h.height=h.width=d*P,g.setTransform(I,0,0,I,0,0),g.fillStyle=E,g.fillRect(0,0,c.value,c.value),R){var N=void 0;w==="linear"?N=g.createLinearGradient(0,0,c.value,c.value):N=g.createRadialGradient(c.value/2,c.value/2,0,c.value/2,c.value/2,c.value/2),N.addColorStop(0,S),N.addColorStop(1,m),g.fillStyle=N}else g.fillStyle=M;me?g.fill(new Path2D(a.value)):s.value.forEach(function(L,Q){L.forEach(function(O,j){O&&g.fillRect(j+l.value,Q+l.value,1,1)})});var F=o.imageSettings.src&&C&&C.naturalWidth!==0&&C.naturalHeight!==0;if(F&&e.value){if(t.value){var b=t.value;g.fillStyle=o.background,i(g,b.x,b.y,b.width,b.height,b.borderRadius),g.fill()}var z=e.value.borderRadius;z>0?(g.save(),i(g,e.value.x,e.value.y,e.value.width,e.value.height,z),g.clip(),g.drawImage(C,e.value.x,e.value.y,e.value.width,e.value.height),g.restore()):g.drawImage(C,e.value.x,e.value.y,e.value.width,e.value.height)}}}};return te(u),re(u),function(){return p($,[p("canvas",A(A({},v.attrs),{ref:r,role:"img","aria-label":o.value,style:A(A({},v.attrs.style),{width:"".concat(o.size,"px"),height:"".concat(o.size,"px")})})),o.imageSettings.src&&p("img",{ref:n,src:o.imageSettings.src,style:{display:"none"},onLoad:u})])}}}),Se=G({name:"Qrcode",props:Re,setup:function(o){return function(){return p(o.renderAs==="svg"?Pe:pe,{value:o.value,size:o.size,margin:o.margin,level:o.level,background:o.background,foreground:o.foreground,imageSettings:o.imageSettings,gradient:o.gradient,gradientType:o.gradientType,gradientStartColor:o.gradientStartColor,gradientEndColor:o.gradientEndColor,radius:o.radius,id:o.id})}}});const Ae=["disabled","onClick"],Ne={class:"social-icon"},be={class:"social-qr-box"},ye={class:"social-qr-prompt"},Ie={__name:"SocialLoginButtons",props:{providers:{type:Array,default:()=>[]},mode:{type:String,default:"login"},redirectUri:{type:String,required:!0},block:{type:Boolean,default:!1}},emits:["error"],setup(o,{emit:v}){const f=o,l=v,s={qq:"QQ",wx:"微信",alipay:"支付宝"},c=T(""),a=T(!1),e=T(""),t=T("wx");let r=null,n=0;const i=y(()=>f.providers.filter(m=>s[m]));function u(){r&&(window.clearTimeout(r),r=null)}function d(){u(),a.value=!1,e.value=""}function E(m){return m==="wx"?"请使用微信扫描二维码点关注后登录":m==="qq"?"请使用 QQ 扫描二维码登录":"请使用支付宝扫描二维码登录"}function M(m){return m==="wx"?"微":m==="qq"?"Q":"支"}function R(m,h){const g=m?.response?.data,C=g?.error||g?.message||h;l("error",C),H.error(C)}function w(m,h,g){u(),n=Date.now();const C=async()=>{if(Date.now()-n>300*1e3){d(),H.warning("二维码已过期,请重新获取");return}try{const P=await se({provider:m,state:h});if(P?.status==="authorized"&&P?.url){d(),window.location.assign(P.url);return}r=window.setTimeout(C,Math.max(Number(g||2),2)*1e3)}catch(P){d(),R(P,"扫码状态获取失败,请重新尝试")}};r=window.setTimeout(C,Math.max(Number(g),2)*1e3)}async function S(m){if(!c.value){c.value=m;try{const h=await le({provider:m,mode:f.mode==="bind"?"bind":"login",redirect_uri:f.redirectUri});if(m!=="wx"){window.location.assign(h.url);return}const g=h.scan_url||h.qrcode||h.url;if(!g||!h.scan_state){H.error("微信二维码获取失败");return}t.value=m,e.value=g,a.value=!0,w(m,h.scan_state,h.scan_poll_interval||2)}catch(h){R(h,"获取聚合登录地址失败")}finally{c.value=""}}}return ae(()=>{u()}),(m,h)=>{const g=ee;return i.value.length?(D(),U("div",{key:0,class:K(["social-login-buttons",{block:o.block}])},[(D(!0),U($,null,oe(i.value,C=>(D(),U("button",{key:C,type:"button",class:K(["social-btn",`provider-${C}`]),disabled:!!c.value,onClick:P=>S(C)},[k("span",Ne,q(M(C)),1),k("span",null,q(o.mode==="bind"?`绑定${s[C]}`:`${s[C]}登录`),1)],10,Ae))),128)),ne(g,{modelValue:a.value,"onUpdate:modelValue":h[0]||(h[0]=C=>a.value=C),title:`${s[t.value]}登录`,width:"min(340px, 92vw)",onClose:d},{default:ie(()=>[k("div",be,[e.value?(D(),ue(Se,{key:0,value:e.value,size:220,level:"M"},null,8,["value"])):Y("",!0),k("div",ye,q(E(t.value)),1)])]),_:1},8,["modelValue","title"])],2)):Y("",!0)}}},De=ce(Ie,[["__scopeId","data-v-809d50db"]]);export{De as S};
|