import{defineComponent as R,ref as S,computed as k,createVNode as t,Fragment as y}from"vue";import{ReloadOutlined as $}from"@ant-design/icons-vue";import{withInstall as b}from"../_util/type.mjs";import"../button/index.mjs";import z from"../config-provider/hooks/useConfigInject.mjs";import{useLocaleReceiver as Q}from"../locale/LocaleReceiver.mjs";import"../spin/index.mjs";import{useToken as q}from"../theme/internal.mjs";import{QRCodeCanvas as w,QRCodeSVG as L}from"./QRCode.mjs";import{qrcodeProps as I}from"./interface.mjs";import A from"./style/index.mjs";import D from"../spin/Spin.mjs";import M from"../button/button.mjs";const P=R({name:"AQrcode",inheritAttrs:!1,props:I(),emits:["refresh"],setup(e,{emit:c,attrs:i,expose:m}){const[l]=Q("QRCode"),{prefixCls:s}=z("qrcode",e),[v,f]=A(s),[,n]=q(),u=S();m({toDataURL:(o,r)=>u.value?.toDataURL(o,r)});const a=k(()=>{const{value:o,icon:r="",size:p=160,iconSize:d=40,color:C=n.value.colorText,bgColor:g="transparent",errorLevel:h="M"}=e,x={src:r,x:void 0,y:void 0,height:d,width:d,excavate:!0};return{value:o,size:p-(n.value.paddingSM+n.value.lineWidth)*2,level:h,bgColor:g,fgColor:C,imageSettings:r?x:void 0}});return()=>{const o=s.value;return v(t("div",{...i,style:[i.style,{width:`${e.size}px`,height:`${e.size}px`,backgroundColor:a.value.bgColor}],class:[f.value,o,{[`${o}-borderless`]:!e.bordered}]},[e.status!=="active"&&t("div",{class:`${o}-mask`},[e.status==="loading"&&t(D,null,null),e.status==="expired"&&t(y,null,[t("p",{class:`${o}-expired`},[l.value.expired]),t(M,{type:"link",onClick:r=>c("refresh",r)},{default:()=>[l.value.refresh],icon:()=>t($,null,null)})]),e.status==="scanned"&&t("p",{class:`${o}-scanned`},[l.value.scanned])]),e.type==="canvas"?t(w,{ref:u,...a.value},null):t(L,a.value,null)]))}}}),K=b(P);export{K as default};
