import{jsx as e,jsxs as r,Fragment as o}from"react/jsx-runtime";import l from"qrcode";import t from"react";import{styled as i}from"styled-components";import{u as c}from"./context-BKnOUECq.mjs";import{w as n,x as g}from"./wallet-connect-58EobR5U.mjs";const a=r=>/*#__PURE__*/e("svg",{viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e("rect",{width:"50",height:"50",fill:"black",rx:10,ry:10})});let m=(e,r,o,l,t)=>{for(let i=r;i<r+l;i++)for(let r=o;r<o+t;r++){let o=e?.[r];o&&o[i]&&(o[i]=0)}return e},h=(e,r)=>{let o=l.create(e,{errorCorrectionLevel:r}).modules,t=n(Array.from(o.data),o.size);return t=m(t,0,0,7,7),t=m(t,t.length-7,0,7,7),m(t,0,t.length-7,7,7)},d=({x:r,y:l,cellSize:t,bgColor:i,fgColor:c})=>
/*#__PURE__*/e(o,{children:[0,1,2].map((o=>/*#__PURE__*/e("circle",{r:t*(7-2*o)/2,cx:r+7*t/2,cy:l+7*t/2,fill:o%2!=0?i:c},`finder-${r}-${l}-${o}`)))}),s=({cellSize:r,matrixSize:l,bgColor:t,fgColor:i})=>/*#__PURE__*/e(o,{children:[[0,0],[(l-7)*r,0],[0,(l-7)*r]].map((([o,l])=>/*#__PURE__*/e(d,{x:o,y:l,cellSize:r,bgColor:t,fgColor:i},`finder-${o}-${l}`)))}),p=({matrix:r,cellSize:l,color:i})=>/*#__PURE__*/e(o,{children:r.map(((r,o)=>r.map(((r,c)=>r?/*#__PURE__*/e("rect",{height:l-.4,width:l-.4,x:o*l+.1*l,y:c*l+.1*l,rx:.5*l,ry:.5*l,fill:i},`cell-${o}-${c}`):/*#__PURE__*/e(t.Fragment,{},`circle-${o}-${c}`)))))}),u=({cellSize:l,matrixSize:t,element:i,sizePercentage:c,bgColor:n})=>{if(!i)/*#__PURE__*/return e(o,{});let g=t*(c||.14),a=Math.floor(t/2-g/2),m=Math.floor(t/2+g/2);(m-a)%2!=t%2&&(m+=1);let h=(m-a)*l,d=h-.2*h,s=a*l;/*#__PURE__*/return r(o,{children:[/*#__PURE__*/e("rect",{x:a*l,y:a*l,width:h,height:h,fill:n}),/*#__PURE__*/e(i,{x:s+.1*h,y:s+.1*h,height:d,width:d})]})},f=o=>{let l=o.outputSize,t=h(o.url,o.errorCorrectionLevel),i=l/t.length,c=g(2*i,{min:.025*l,max:.036*l});/*#__PURE__*/return r("svg",{height:o.outputSize,width:o.outputSize,viewBox:`0 0 ${o.outputSize} ${o.outputSize}`,style:{height:"100%",width:"100%",padding:`${c}px`},children:[/*#__PURE__*/e(p,{matrix:t,cellSize:i,color:o.fgColor}),/*#__PURE__*/e(s,{cellSize:i,matrixSize:t.length,fgColor:o.fgColor,bgColor:o.bgColor}),/*#__PURE__*/e(u,{cellSize:i,element:o.logo?.element,bgColor:o.bgColor,matrixSize:t.length})]})},x=i.div.attrs({className:"ph-no-capture"})`
  display: flex;
  justify-content: center;
  align-items: center;
  height: ${e=>`${e.$size}px`};
  width: ${e=>`${e.$size}px`};
  margin: auto;
  background-color: ${e=>e.$bgColor};

  && {
    border-width: 2px;
    border-color: ${e=>e.$borderColor};
    border-radius: var(--privy-border-radius-md);
  }
`;const C=r=>{let{appearance:o}=c(),l=r.bgColor||"#FFFFFF",t=r.fgColor||"#000000",i=r.size||160,n="dark"===o.palette.colorScheme?l:t;/*#__PURE__*/return e(x,{$size:i,$bgColor:l,$fgColor:t,$borderColor:n,children:/*#__PURE__*/e(f,{url:r.url,logo:r.hideLogo?void 0:{element:r.squareLogoElement??a},outputSize:i,bgColor:l,fgColor:t,errorCorrectionLevel:r.errorCorrectionLevel||"Q"})})};export{C as Q};
//# sourceMappingURL=QrCode-CvO4k-hN.mjs.map
