import"./index-Dx5_zIAw.js";/* empty css *//* empty css *//* empty css */import{k as e,l as t,r,bD as n,d as i,F as o,M as a,w as s,P as u,D as l,x as h,G as d,$ as f,aL as c,bi as g,R as v,b2 as m,X as p,aN as w}from"./vendor-CgKklJ4r.js";import{_ as E}from"./_plugin-vue_export-helper-BCo6x5W8.js"; /*! * qrcode.vue v3.6.0 * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3 * © 2017-PRESENT @scopewu(https://github.com/scopewu) * MIT License. */var C,y,M,R,A=function(){return A=Object.assign||function(e){for(var t,r=1,n=arguments.length;rt.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=4*e+17;for(var a=[],s=0;s7)throw new RangeError("Invalid value");var h,d;for(h=a;;h++){var f=8*t.getNumDataCodewords(h,n),c=o.getTotalBits(e,h);if(c<=f){d=c;break}if(h>=s)throw new RangeError("Data too long")}for(var g=0,v=[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH];g>>3]|=e<<7-(7&t)})),new t(h,n,N,u)},t.prototype.getModule=function(e,t){return 0<=e&&e>>9);var a=21522^(t<<10|r);i(a>>>15==0);for(o=0;o<=5;o++)this.setFunctionModule(8,o,n(a,o));this.setFunctionModule(8,7,n(a,6)),this.setFunctionModule(8,8,n(a,7)),this.setFunctionModule(7,8,n(a,8));for(o=9;o<15;o++)this.setFunctionModule(14-o,8,n(a,o));for(o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,n(a,o));for(o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,n(a,o));this.setFunctionModule(8,this.size-8,!0)},t.prototype.drawVersion=function(){if(!(this.version<7)){for(var e=this.version,t=0;t<12;t++)e=e<<1^7973*(e>>>11);var r=this.version<<12|e;i(r>>>18==0);for(t=0;t<18;t++){var o=n(r,t),a=this.size-11+t%3,s=Math.floor(t/3);this.setFunctionModule(a,s,o),this.setFunctionModule(s,a,o)}}},t.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)),o=e+n,a=t+r;0<=o&&o=u)&&m.push(t[e])}))};for(f=0;f=1;o-=2){6==o&&(o=5);for(var a=0;a>>3],7-(7&r)),r++)}}i(r==8*e.length)},t.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(o,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],o=1);e+=this.finderPenaltyTerminateAndCount(n,o,a)*t.PENALTY_N3}for(s=0;s5&&e++:(this.finderPenaltyAddHistory(u,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],u=1);e+=this.finderPenaltyTerminateAndCount(n,u,a)*t.PENALTY_N3}for(r=0;rt.MAX_VERSION)throw new RangeError("Version number out of range");var r=(16*e+128)*e+64;if(e>=2){var n=Math.floor(e/7)+2;r-=(25*n-10)*n-55,e>=7&&(r-=36)}return i(208<=r&&r<=29648),r},t.getNumDataCodewords=function(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]},t.reedSolomonComputeDivisor=function(e){if(e<1||e>255)throw new RangeError("Degree out of range");for(var r=[],n=0;n>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");for(var r=0,n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(t>>>n&1)*e;return i(r>>>8==0),r},t.prototype.finderPenaltyCountPatterns=function(e){var t=e[1];i(t<=3*this.size);var r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(r&&e[0]>=4*t&&e[6]>=t?1:0)+(r&&e[6]>=4*t&&e[0]>=t?1:0)},t.prototype.finderPenaltyTerminateAndCount=function(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)},t.prototype.finderPenaltyAddHistory=function(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)},t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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]],t}();function r(e,t,r){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(var n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw new Error("Assertion error")}e.QrCode=t;var o=function(){function e(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 e.makeBytes=function(t){for(var n=[],i=0,o=t;i=1<=t.y+t.h?e:e.map((function(e,r){return(r=t.x+t.w)&&e}))}))}var k={value:{type:String,required:!0,default:""},size:{type:Number,default:100},level:{type:String,default:"L",validator:function(e){return I(e)}},background:{type:String,default:"#fff"},foreground:{type:String,default:"#000"},margin:{type:Number,required:!1,default:0},imageSettings:{type:Object,required:!1,default:function(){return{}}},gradient:{type:Boolean,required:!1,default:!1},gradientType:{type:String,required:!1,default:"linear",validator:function(e){return["linear","radial"].indexOf(e)>-1}},gradientStartColor:{type:String,required:!1,default:"#000"},gradientEndColor:{type:String,required:!1,default:"#fff"}},L=A(A({},k),{renderAs:{type:String,required:!1,default:"canvas",validator:function(e){return["canvas","svg"].indexOf(e)>-1}}}),b=e({name:"QRCodeSvg",props:k,setup:function(e){var i,o=r(0),a=r(""),s=function(){var t=e.value,r=e.level,n=e.margin>>>0,s=I(r)?r:"L",u=S.QrCode.encodeText(t,N[s]).getModules();if(o.value=u.length+2*n,e.imageSettings.src){var l=z(u,e.size,n,e.imageSettings);i={x:l.x+n,y:l.y+n,width:l.w,height:l.h},l.excavation&&(u=x(u,l.excavation))}a.value=_(u,n)},u=function(){if(!e.gradient)return null;var r="linear"===e.gradientType?{x1:"0%",y1:"0%",x2:"100%",y2:"100%"}:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"};return t("linear"===e.gradientType?"linearGradient":"radialGradient",A({id:"qr-gradient"},r),[t("stop",{offset:"0%",style:{stopColor:e.gradientStartColor}}),t("stop",{offset:"100%",style:{stopColor:e.gradientEndColor}})])};return s(),n(s),function(){return t("svg",{width:e.size,height:e.size,"shape-rendering":"crispEdges",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(o.value," ").concat(o.value)},[t("defs",{},[u()]),t("rect",{width:"100%",height:"100%",fill:e.background}),t("path",{fill:e.gradient?"url(#qr-gradient)":e.foreground,d:a.value}),e.imageSettings.src&&t("image",A({href:e.imageSettings.src},i))])}}}),O=e({name:"QRCodeCanvas",props:k,setup:function(e,a){var s=r(null),u=r(null),l=function(){var t=e.value,r=e.level,n=e.size,i=e.margin,o=e.background,a=e.foreground,l=e.gradient,h=e.gradientType,d=e.gradientStartColor,f=e.gradientEndColor,c=i>>>0,g=I(r)?r:"L",v=s.value;if(v){var m=v.getContext("2d");if(m){var p=S.QrCode.encodeText(t,N[g]).getModules(),w=p.length+2*c,E=u.value,C={x:0,y:0,width:0,height:0},y=e.imageSettings.src&&null!=E&&0!==E.naturalWidth&&0!==E.naturalHeight;if(y){var M=z(p,e.size,c,e.imageSettings);C={x:M.x+c,y:M.y+c,width:M.w,height:M.h},M.excavation&&(p=x(p,M.excavation))}var R=window.devicePixelRatio||1,A=n/w*R;if(v.height=v.width=n*R,m.scale(A,A),m.fillStyle=o,m.fillRect(0,0,w,w),l){var k=void 0;(k="linear"===h?m.createLinearGradient(0,0,w,w):m.createRadialGradient(w/2,w/2,0,w/2,w/2,w/2)).addColorStop(0,d),k.addColorStop(1,f),m.fillStyle=k}else m.fillStyle=a;P?m.fill(new Path2D(_(p,c))):p.forEach((function(e,t){e.forEach((function(e,r){e&&m.fillRect(r+c,t+c,1,1)}))})),y&&m.drawImage(E,C.x,C.y,C.width,C.height)}}};i(l),n(l);var h=a.attrs.style;return function(){return t(o,[t("canvas",A(A({},a.attrs),{ref:s,style:A(A({},h),{width:"".concat(e.size,"px"),height:"".concat(e.size,"px")})})),e.imageSettings.src&&t("img",{ref:u,src:e.imageSettings.src,style:{display:"none"},onLoad:l})])}}}),T=e({name:"Qrcode",render:function(){var e=this.$props,r=e.renderAs,n=e.value,i=e.size,o=e.margin,a=e.level,s=e.background,u=e.foreground,l=e.imageSettings,h=e.gradient,d=e.gradientType,f=e.gradientStartColor,c=e.gradientEndColor;return t("svg"===r?b:O,{value:n,size:i,margin:o,level:a,background:s,foreground:u,imageSettings:l,gradient:h,gradientType:d,gradientStartColor:f,gradientEndColor:c})},props:L});const D={class:"page-content"},F={class:"card-header"},H={class:"qrcode-preview"},B=E(e({__name:"index",setup(e){const t=r("https://www.lingchen.kim"),n=r(!1),i=[{title:"渲染成 svg 标签",config:{size:160,level:"H",renderAs:"svg",margin:0,background:"#ffffff",foreground:"#000000"}},{title:"渲染成 canvas 标签",config:{size:160,level:"H",renderAs:"canvas",margin:0,background:"#ffffff",foreground:"#000000"}},{title:"自定义颜色",config:{size:160,level:"H",renderAs:"canvas",margin:0,background:"#f0f0f0",foreground:"#4080ff"}},{title:"带有Logo",config:{size:160,level:"H",renderAs:"canvas",margin:0,background:"#ffffff",foreground:"#000000",imageSettings:{src:"https://www.lingchen.kim/art-design-pro/assets/avatar-DJIoI-3F.png",width:40,height:40,excavate:!0}}}],E=a({size:160,level:"H",renderAs:"canvas",margin:0,background:"#ffffff",foreground:"#000000",imageSettings:{src:"https://www.lingchen.kim/art-design-pro/assets/avatar-DJIoI-3F.png",width:40,height:40,excavate:!0}});return s(n,(e=>{E.imageSettings=e?{src:"https://www.lingchen.kim/art-design-pro/assets/avatar-DJIoI-3F.png",width:40,height:40,excavate:!0}:{}})),(e,r)=>{const n=g,a=c,s=w;return l(),u("div",D,[h(s,{gutter:20},{default:d((()=>[(l(),u(o,null,f(i,(e=>h(a,{span:6,key:e.title},{default:d((()=>[h(n,{class:"qrcode-card",shadow:"never"},{header:d((()=>[v("div",F,[v("span",null,p(e.title),1)])])),default:d((()=>[v("div",H,[h(T,m({value:t.value},{ref_for:!0},e.config),null,16,["value"])])])),_:2},1024)])),_:2},1024))),64))])),_:1})])}}}),[["__scopeId","data-v-778be315"]]);export{B as default};