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;la.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;u7)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>>3]|=Q<<7-(O&7)}),new a(d,t,L,i)},a.prototype.getModule=function(e,t){return 0<=e&&e>>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=d)&&g.push(I[P])})},w=0;w=1;r-=2){r==6&&(r=5);for(var n=0;n>>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;t5&&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;u5&&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;ta.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>>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=1<0?o[v-1][f]:!1,s=v0?o[v][f-1]:!1,a=f>>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};