UNPKG

@freeunionp/btcdonate

Version:

A standalone React component for BTC donations.

156 lines (148 loc) 28.7 kB
(function(B,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],x):(B=typeof globalThis<"u"?globalThis:B||self,x(B.BitcoinDonate={},B.React))})(this,function(B,x){"use strict";var H={exports:{}},j={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var J;function de(){if(J)return j;J=1;var u=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(l,h,d){var b=null;if(d!==void 0&&(b=""+d),h.key!==void 0&&(b=""+h.key),"key"in h){d={};for(var C in h)C!=="key"&&(d[C]=h[C])}else d=h;return h=d.ref,{$$typeof:u,type:l,key:b,ref:h!==void 0?h:null,props:d}}return j.Fragment=a,j.jsx=s,j.jsxs=s,j}var Z;function he(){return Z||(Z=1,H.exports=de()),H.exports}var w=he(),fe=Object.defineProperty,_=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,ee=(u,a,s)=>a in u?fe(u,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[a]=s,Y=(u,a)=>{for(var s in a||(a={}))q.call(a,s)&&ee(u,s,a[s]);if(_)for(var s of _(a))K.call(a,s)&&ee(u,s,a[s]);return u},G=(u,a)=>{var s={};for(var l in u)q.call(u,l)&&a.indexOf(l)<0&&(s[l]=u[l]);if(u!=null&&_)for(var l of _(u))a.indexOf(l)<0&&K.call(u,l)&&(s[l]=u[l]);return s};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var O;(u=>{const a=class g{constructor(e,o,t,r){if(this.version=e,this.errorCorrectionLevel=o,this.modules=[],this.isFunction=[],e<g.MIN_VERSION||e>g.MAX_VERSION)throw new RangeError("Version value out of range");if(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let n=[];for(let i=0;i<this.size;i++)n.push(!1);for(let i=0;i<this.size;i++)this.modules.push(n.slice()),this.isFunction.push(n.slice());this.drawFunctionPatterns();const c=this.addEccAndInterleave(t);if(this.drawCodewords(c),r==-1){let i=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const f=this.getPenaltyScore();f<i&&(r=p,i=f),this.applyMask(p)}}h(0<=r&&r<=7),this.mask=r,this.applyMask(r),this.drawFormatBits(r),this.isFunction=[]}static encodeText(e,o){const t=u.QrSegment.makeSegments(e);return g.encodeSegments(t,o)}static encodeBinary(e,o){const t=u.QrSegment.makeBytes(e);return g.encodeSegments([t],o)}static encodeSegments(e,o,t=1,r=40,n=-1,c=!0){if(!(g.MIN_VERSION<=t&&t<=r&&r<=g.MAX_VERSION)||n<-1||n>7)throw new RangeError("Invalid value");let i,p;for(i=t;;i++){const m=g.getNumDataCodewords(i,o)*8,v=b.getTotalBits(e,i);if(v<=m){p=v;break}if(i>=r)throw new RangeError("Data too long")}for(const m of[g.Ecc.MEDIUM,g.Ecc.QUARTILE,g.Ecc.HIGH])c&&p<=g.getNumDataCodewords(i,m)*8&&(o=m);let f=[];for(const m of e){s(m.mode.modeBits,4,f),s(m.numChars,m.mode.numCharCountBits(i),f);for(const v of m.getData())f.push(v)}h(f.length==p);const R=g.getNumDataCodewords(i,o)*8;h(f.length<=R),s(0,Math.min(4,R-f.length),f),s(0,(8-f.length%8)%8,f),h(f.length%8==0);for(let m=236;f.length<R;m^=253)s(m,8,f);let M=[];for(;M.length*8<f.length;)M.push(0);return f.forEach((m,v)=>M[v>>>3]|=m<<7-(v&7)),new g(i,o,M,n)}getModule(e,o){return 0<=e&&e<this.size&&0<=o&&o<this.size&&this.modules[o][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),o=e.length;for(let t=0;t<o;t++)for(let r=0;r<o;r++)t==0&&r==0||t==0&&r==o-1||t==o-1&&r==0||this.drawAlignmentPattern(e[t],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const o=this.errorCorrectionLevel.formatBits<<3|e;let t=o;for(let n=0;n<10;n++)t=t<<1^(t>>>9)*1335;const r=(o<<10|t)^21522;h(r>>>15==0);for(let n=0;n<=5;n++)this.setFunctionModule(8,n,l(r,n));this.setFunctionModule(8,7,l(r,6)),this.setFunctionModule(8,8,l(r,7)),this.setFunctionModule(7,8,l(r,8));for(let n=9;n<15;n++)this.setFunctionModule(14-n,8,l(r,n));for(let n=0;n<8;n++)this.setFunctionModule(this.size-1-n,8,l(r,n));for(let n=8;n<15;n++)this.setFunctionModule(8,this.size-15+n,l(r,n));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const o=this.version<<12|e;h(o>>>18==0);for(let t=0;t<18;t++){const r=l(o,t),n=this.size-11+t%3,c=Math.floor(t/3);this.setFunctionModule(n,c,r),this.setFunctionModule(c,n,r)}}drawFinderPattern(e,o){for(let t=-4;t<=4;t++)for(let r=-4;r<=4;r++){const n=Math.max(Math.abs(r),Math.abs(t)),c=e+r,i=o+t;0<=c&&c<this.size&&0<=i&&i<this.size&&this.setFunctionModule(c,i,n!=2&&n!=4)}}drawAlignmentPattern(e,o){for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,o+t,Math.max(Math.abs(r),Math.abs(t))!=1)}setFunctionModule(e,o,t){this.modules[o][e]=t,this.isFunction[o][e]=!0}addEccAndInterleave(e){const o=this.version,t=this.errorCorrectionLevel;if(e.length!=g.getNumDataCodewords(o,t))throw new RangeError("Invalid argument");const r=g.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][o],n=g.ECC_CODEWORDS_PER_BLOCK[t.ordinal][o],c=Math.floor(g.getNumRawDataModules(o)/8),i=r-c%r,p=Math.floor(c/r);let f=[];const R=g.reedSolomonComputeDivisor(n);for(let m=0,v=0;m<r;m++){let A=e.slice(v,v+p-n+(m<i?0:1));v+=A.length;const I=g.reedSolomonComputeRemainder(A,R);m<i&&A.push(0),f.push(A.concat(I))}let M=[];for(let m=0;m<f[0].length;m++)f.forEach((v,A)=>{(m!=p-n||A>=i)&&M.push(v[m])});return h(M.length==c),M}drawCodewords(e){if(e.length!=Math.floor(g.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let o=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let r=0;r<this.size;r++)for(let n=0;n<2;n++){const c=t-n,p=(t+1&2)==0?this.size-1-r:r;!this.isFunction[p][c]&&o<e.length*8&&(this.modules[p][c]=l(e[o>>>3],7-(o&7)),o++)}}h(o==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let o=0;o<this.size;o++)for(let t=0;t<this.size;t++){let r;switch(e){case 0:r=(t+o)%2==0;break;case 1:r=o%2==0;break;case 2:r=t%3==0;break;case 3:r=(t+o)%3==0;break;case 4:r=(Math.floor(t/3)+Math.floor(o/2))%2==0;break;case 5:r=t*o%2+t*o%3==0;break;case 6:r=(t*o%2+t*o%3)%2==0;break;case 7:r=((t+o)%2+t*o%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[o][t]&&r&&(this.modules[o][t]=!this.modules[o][t])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let c=!1,i=0,p=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[n][f]==c?(i++,i==5?e+=g.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,p),c||(e+=this.finderPenaltyCountPatterns(p)*g.PENALTY_N3),c=this.modules[n][f],i=1);e+=this.finderPenaltyTerminateAndCount(c,i,p)*g.PENALTY_N3}for(let n=0;n<this.size;n++){let c=!1,i=0,p=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[f][n]==c?(i++,i==5?e+=g.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,p),c||(e+=this.finderPenaltyCountPatterns(p)*g.PENALTY_N3),c=this.modules[f][n],i=1);e+=this.finderPenaltyTerminateAndCount(c,i,p)*g.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let c=0;c<this.size-1;c++){const i=this.modules[n][c];i==this.modules[n][c+1]&&i==this.modules[n+1][c]&&i==this.modules[n+1][c+1]&&(e+=g.PENALTY_N2)}let o=0;for(const n of this.modules)o=n.reduce((c,i)=>c+(i?1:0),o);const t=this.size*this.size,r=Math.ceil(Math.abs(o*20-t*10)/t)-1;return h(0<=r&&r<=9),e+=r*g.PENALTY_N4,h(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,o=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let r=this.size-7;t.length<e;r-=o)t.splice(1,0,r);return t}}static getNumRawDataModules(e){if(e<g.MIN_VERSION||e>g.MAX_VERSION)throw new RangeError("Version number out of range");let o=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;o-=(25*t-10)*t-55,e>=7&&(o-=36)}return h(208<=o&&o<=29648),o}static getNumDataCodewords(e,o){return Math.floor(g.getNumRawDataModules(e)/8)-g.ECC_CODEWORDS_PER_BLOCK[o.ordinal][e]*g.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let o=[];for(let r=0;r<e-1;r++)o.push(0);o.push(1);let t=1;for(let r=0;r<e;r++){for(let n=0;n<o.length;n++)o[n]=g.reedSolomonMultiply(o[n],t),n+1<o.length&&(o[n]^=o[n+1]);t=g.reedSolomonMultiply(t,2)}return o}static reedSolomonComputeRemainder(e,o){let t=o.map(r=>0);for(const r of e){const n=r^t.shift();t.push(0),o.forEach((c,i)=>t[i]^=g.reedSolomonMultiply(c,n))}return t}static reedSolomonMultiply(e,o){if(e>>>8||o>>>8)throw new RangeError("Byte out of range");let t=0;for(let r=7;r>=0;r--)t=t<<1^(t>>>7)*285,t^=(o>>>r&1)*e;return h(t>>>8==0),t}finderPenaltyCountPatterns(e){const o=e[1];h(o<=this.size*3);const t=o>0&&e[2]==o&&e[3]==o*3&&e[4]==o&&e[5]==o;return(t&&e[0]>=o*4&&e[6]>=o?1:0)+(t&&e[6]>=o*4&&e[0]>=o?1:0)}finderPenaltyTerminateAndCount(e,o,t){return e&&(this.finderPenaltyAddHistory(o,t),o=0),o+=this.size,this.finderPenaltyAddHistory(o,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,o){o[0]==0&&(e+=this.size),o.pop(),o.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]],u.QrCode=a;function s(C,e,o){if(e<0||e>31||C>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)o.push(C>>>t&1)}function l(C,e){return(C>>>e&1)!=0}function h(C){if(!C)throw new Error("Assertion error")}const d=class y{constructor(e,o,t){if(this.mode=e,this.numChars=o,this.bitData=t,o<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let o=[];for(const t of e)s(t,8,o);return new y(y.Mode.BYTE,e.length,o)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let o=[];for(let t=0;t<e.length;){const r=Math.min(e.length-t,3);s(parseInt(e.substring(t,t+r),10),r*3+1,o),t+=r}return new y(y.Mode.NUMERIC,e.length,o)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let o=[],t;for(t=0;t+2<=e.length;t+=2){let r=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;r+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),s(r,11,o)}return t<e.length&&s(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,o),new y(y.Mode.ALPHANUMERIC,e.length,o)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let o=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)s(e,8,o);else if(e<16384)s(2,2,o),s(e,14,o);else if(e<1e6)s(6,3,o),s(e,21,o);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,o)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,o){let t=0;for(const r of e){const n=r.mode.numCharCountBits(o);if(r.numChars>=1<<n)return 1/0;t+=4+n+r.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let o=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?o.push(e.charCodeAt(t)):(o.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return o}};d.NUMERIC_REGEX=/^[0-9]*$/,d.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,d.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let b=d;u.QrSegment=d})(O||(O={})),(u=>{(a=>{const s=class{constructor(h,d){this.ordinal=h,this.formatBits=d}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),a.Ecc=s})(u.QrCode||(u.QrCode={}))})(O||(O={})),(u=>{(a=>{const s=class{constructor(h,d){this.modeBits=h,this.numBitsCharCount=d}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),a.Mode=s})(u.QrSegment||(u.QrSegment={}))})(O||(O={}));var z=O;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var pe={L:z.QrCode.Ecc.LOW,M:z.QrCode.Ecc.MEDIUM,Q:z.QrCode.Ecc.QUARTILE,H:z.QrCode.Ecc.HIGH},te=128,oe="L",re="#FFFFFF",ne="#000000",se=!1,ie=1,me=4,ge=0,xe=.1;function ae(u,a=0){const s=[];return u.forEach(function(l,h){let d=null;l.forEach(function(b,C){if(!b&&d!==null){s.push(`M${d+a} ${h+a}h${C-d}v1H${d+a}z`),d=null;return}if(C===l.length-1){if(!b)return;d===null?s.push(`M${C+a},${h+a} h1v1H${C+a}z`):s.push(`M${d+a},${h+a} h${C+1-d}v1H${d+a}z`);return}b&&d===null&&(d=C)})}),s.join("")}function le(u,a){return u.slice().map((s,l)=>l<a.y||l>=a.y+a.h?s:s.map((h,d)=>d<a.x||d>=a.x+a.w?h:!1))}function we(u,a,s,l){if(l==null)return null;const h=u.length+s*2,d=Math.floor(a*xe),b=h/a,C=(l.width||d)*b,e=(l.height||d)*b,o=l.x==null?u.length/2-C/2:l.x*b,t=l.y==null?u.length/2-e/2:l.y*b,r=l.opacity==null?1:l.opacity;let n=null;if(l.excavate){let i=Math.floor(o),p=Math.floor(t),f=Math.ceil(C+o-i),R=Math.ceil(e+t-p);n={x:i,y:p,w:f,h:R}}const c=l.crossOrigin;return{x:o,y:t,h:e,w:C,excavation:n,opacity:r,crossOrigin:c}}function Ce(u,a){return a!=null?Math.max(Math.floor(a),0):u?me:ge}function ce({value:u,level:a,minVersion:s,includeMargin:l,marginSize:h,imageSettings:d,size:b,boostLevel:C}){let e=x.useMemo(()=>{const i=(Array.isArray(u)?u:[u]).reduce((p,f)=>(p.push(...z.QrSegment.makeSegments(f)),p),[]);return z.QrCode.encodeSegments(i,pe[a],s,void 0,void 0,C)},[u,a,s,C]);const{cells:o,margin:t,numCells:r,calculatedImageSettings:n}=x.useMemo(()=>{let c=e.getModules();const i=Ce(l,h),p=c.length+i*2,f=we(c,b,i,d);return{cells:c,margin:i,numCells:p,calculatedImageSettings:f}},[e,b,d,l,h]);return{qrcode:e,margin:t,cells:o,numCells:r,calculatedImageSettings:n}}var Ee=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ue=x.forwardRef(function(a,s){const l=a,{value:h,size:d=te,level:b=oe,bgColor:C=re,fgColor:e=ne,includeMargin:o=se,minVersion:t=ie,boostLevel:r,marginSize:n,imageSettings:c}=l,p=G(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:f}=p,R=G(p,["style"]),M=c?.src,m=x.useRef(null),v=x.useRef(null),A=x.useCallback(L=>{m.current=L,typeof s=="function"?s(L):s&&(s.current=L)},[s]),[I,Q]=x.useState(!1),{margin:T,cells:F,numCells:D,calculatedImageSettings:N}=ce({value:h,level:b,minVersion:t,boostLevel:r,includeMargin:o,marginSize:n,imageSettings:c,size:d});x.useEffect(()=>{if(m.current!=null){const L=m.current,P=L.getContext("2d");if(!P)return;let E=F;const S=v.current,k=N!=null&&S!==null&&S.complete&&S.naturalHeight!==0&&S.naturalWidth!==0;k&&N.excavation!=null&&(E=le(F,N.excavation));const X=window.devicePixelRatio||1;L.height=L.width=d*X;const U=d/D*X;P.scale(U,U),P.fillStyle=C,P.fillRect(0,0,D,D),P.fillStyle=e,Ee?P.fill(new Path2D(ae(E,T))):F.forEach(function(Me,Ae){Me.forEach(function(Se,Re){Se&&P.fillRect(Re+T,Ae+T,1,1)})}),N&&(P.globalAlpha=N.opacity),k&&P.drawImage(S,N.x+T,N.y+T,N.w,N.h)}}),x.useEffect(()=>{Q(!1)},[M]);const W=Y({height:d,width:d},f);let $=null;return M!=null&&($=x.createElement("img",{src:M,key:M,style:{display:"none"},onLoad:()=>{Q(!0)},ref:v,crossOrigin:N?.crossOrigin})),x.createElement(x.Fragment,null,x.createElement("canvas",Y({style:W,height:d,width:d,ref:A,role:"img"},R)),$)});ue.displayName="QRCodeCanvas";var be=x.forwardRef(function(a,s){const l=a,{value:h,size:d=te,level:b=oe,bgColor:C=re,fgColor:e=ne,includeMargin:o=se,minVersion:t=ie,boostLevel:r,title:n,marginSize:c,imageSettings:i}=l,p=G(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:f,cells:R,numCells:M,calculatedImageSettings:m}=ce({value:h,level:b,minVersion:t,boostLevel:r,includeMargin:o,marginSize:c,imageSettings:i,size:d});let v=R,A=null;i!=null&&m!=null&&(m.excavation!=null&&(v=le(R,m.excavation)),A=x.createElement("image",{href:i.src,height:m.h,width:m.w,x:m.x+f,y:m.y+f,preserveAspectRatio:"none",opacity:m.opacity,crossOrigin:m.crossOrigin}));const I=ae(v,f);return x.createElement("svg",Y({height:d,width:d,viewBox:`0 0 ${M} ${M}`,ref:s,role:"img"},p),!!n&&x.createElement("title",null,n),x.createElement("path",{fill:C,d:`M0,0 h${M}v${M}H0z`,shapeRendering:"crispEdges"}),x.createElement("path",{fill:e,d:I,shapeRendering:"crispEdges"}),A)});be.displayName="QRCodeSVG";const V=u=>{switch(u){case"usd":return"$";case"eur":return"€";case"gbp":return"£";case"jpy":case"cny":return"¥";case"aed":return"د.إ";case"zar":return"R";case"brl":return"R$";default:return"$"}},ye=()=>{const[u,a]=x.useState(!1),[s,l]=x.useState("複製"),h=x.useCallback(d=>{navigator.clipboard.writeText(d).then(()=>{a(!0),l("已複製!"),setTimeout(()=>{a(!1),l("複製")},2e3)},b=>{console.error("無法複製到剪貼簿",b),l("複製失敗"),setTimeout(()=>l("複製"),2e3)})},[]);return[u,h,s]},ve=({address:u="bc1qx6xswq65n5x864vwj77lrtn0xn2rmlh3ypfkk8",title:a="Donate",description:s="Use this QR code or address below",currency:l="usd",presets:h=[50,100,200],showButton:d=!0,buttonText:b="Support Bitcoin.org",onClose:C})=>{const[e,o]=x.useState(!1),[t,r]=x.useState(""),[n,c]=x.useState(""),[i,p]=x.useState(112776),[f,R]=x.useState(""),[M,m,v]=ye(),[A,I]=x.useState(null),[Q,T]=x.useState(V(l.toLowerCase()));x.useEffect(()=>{(async()=>{try{const S=l.toLowerCase();T(V(S));const k=await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${S}`);if(!k.ok)throw new Error(`HTTP error! Status: ${k.status}`);const U=(await k.json()).bitcoin?.[S];U?p(U):console.warn(`Could not find rate for currency: ${S}`)}catch(S){console.error("Error fetching Bitcoin rate:",S),p(112776),l="usd";const k=l.toLowerCase();T(V(k))}})()},[l]),x.useEffect(()=>{if(A==="usd"){const E=parseFloat(t);if(isNaN(E))c("");else{const S=(E/i).toFixed(8);c(S)}}},[t,i,A]),x.useEffect(()=>{if(A==="btc"){const E=parseFloat(n);if(isNaN(E))r("");else{const S=(E*i).toFixed(2);r(S)}}},[n,i,A]);const F=`bitcoin:${u}?amount=${parseFloat(n)}${f?`&message=${encodeURIComponent(f)}`:""}`,D=()=>{o(!1),C?.()},N=E=>{r(E.target.value),I("usd")},W=E=>{c(E.target.value),I("btc")},$=E=>{r(E.toString()),I("usd")},L=()=>w.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),w.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),P=()=>w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("polyline",{points:"20 6 9 17 4 12"})});return w.jsxs(w.Fragment,{children:[d&&w.jsx("button",{onClick:()=>o(!0),style:{padding:"12px 24px",backgroundColor:"#2a2a2a",color:"white",borderRadius:"8px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",transition:"all 0.2s",border:"none",cursor:"pointer",fontSize:"1rem",fontWeight:"bold"},onMouseOver:E=>E.currentTarget.style.backgroundColor="#4a4a4a",onMouseOut:E=>E.currentTarget.style.backgroundColor="#2a2a2a",children:b}),e&&w.jsxs("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",overflowY:"auto",padding:"1rem"},children:[w.jsx("style",{children:` @keyframes fadeInZoom { 0% { opacity: 0; transform: scale(0.5); } 100% { opacity: 1; transform: scale(1); } } h2{ margin-top: 0; } .donate-modal { background-color: white; width: 100%; width: 770px; max-width: 770px; margin: 0; padding: 1.5rem; height: 755px; padding: 20px 90px; border-radius: 1rem; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); position: relative; box-sizing: border-box; color: "#646464"; animation: fadeInZoom 0.3s ease-out; transform-origin: top; } .donate-modal textarea{ box-sizing: border-box; } .donate-modal input::placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ opacity: 1; /* 瀏覽器可能會預設降低 opacity,這會強制它為 1 */ } .donate-modal input::-webkit-input-placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ } .donate-modal input::-moz-placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ } .donate-modal textarea::placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ opacity: 1; /* 瀏覽器可能會預設降低 opacity,這會強制它為 1 */ } .donate-modal textarea::-webkit-input-placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ } .donate-modal textarea::-moz-placeholder { color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */ } .focus-effect:focus { border-width: 2px; /* 變粗 */ border-color: #555; /* 顏色變深 */ } .copy-btn{ padding:0 } .donate-presets { box-sizing: border-box; display: flex; gap: 0.5rem; justify-content: center; justify-content: space-between; margin-bottom: 2rem; } .donate-inputs { box-sizing: border-box; display: flex; gap: 1rem; } .donate-input-wrapper { box-sizing: border-box; position: relative; flex: 1; } .donate-input-wrapper input { box-sizing: border-box; width: 100%; border: 1px solid #d1d5db; padding: 15px 15px 15px 20px; border-radius: 6px; border-radius: 1px; line-height: 1.25rem; outline: none; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075); } .donate-input-wrapper input:focus { border-radius: 4px; } .donate-input-wrapper span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #6b7280; font-size: 0.875rem; } @media handheld, only screen and ( max-width: 60em ), only screen and ( max-device-width: 60em ){ .donate-modal { padding: 20px 38px; width: 620px; height: 700px; } } @media (max-width: 640px) { .donate-modal { padding: 1rem; border-radius: 0.5rem; } .donate-presets { flex-wrap: wrap; } .donate-presets button { flex: auto; width: auto; } .donate-inputs { flex-direction: column; flex-direction: row; } .donate-input-wrapper { flex: auto; } .focus-effect:focus { border-color: #F7931A; /* 顏色變深 */ } } `}),w.jsxs("div",{className:"donate-modal",children:[w.jsx("div",{onClick:D,style:{position:"absolute",top:"1rem",right:"1rem",fontSize:"2rem",lineHeight:.5,height:"32px",width:"32px",padding:"0.5rem",color:"#6b7280",border:"none",background:"transparent",cursor:"pointer"},onMouseOver:E=>E.currentTarget.style.color="#4a4a4a",onMouseOut:E=>E.currentTarget.style.color="#6b7280",children:"×"}),w.jsx("h2",{style:{fontSize:"1.5rem",textAlign:"center",color:"#FF7E00",fontWeight:"normal",marginBottom:"20px",lineHeight:"65px"},children:a}),w.jsx("p",{style:{textAlign:"center",fontSize:"20px",lineHeight:"34px",color:"#6b7280",marginBottom:"1rem"},children:s}),w.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"0.75rem"},children:w.jsx(ue,{value:F,size:160,level:"L"})}),w.jsxs("div",{style:{textAlign:"center",position:"relative",marginBottom:"1.5rem"},children:[w.jsx("p",{style:{color:"#3498db",fontSize:"0.875rem",wordBreak:"break-all",paddingRight:"35px",paddingLeft:"35px",fontWeight:"bold",margin:"27px 0 25px"},children:w.jsx("a",{style:{color:"#3498db",fontSize:"0.875rem",wordBreak:"break-all",fontWeight:"bold"},href:F,target:"_blank",children:u})}),w.jsx("button",{onClick:()=>m(u),title:"複製比特幣地址","aria-label":"複製比特幣地址","data-status":v,style:{position:"absolute",right:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:"transparent",border:"none",cursor:"pointer",color:"#6b7280",padding:"0.25rem"},children:M?w.jsx(P,{}):w.jsx(L,{})})]}),w.jsx("div",{className:"donate-presets",children:h.map(E=>w.jsxs("button",{onClick:()=>$(E),style:{flex:1,padding:"8px 0",borderRadius:"1px",transition:"all 0.15s",border:"none",cursor:"pointer",backgroundColor:"#F7931A",maxWidth:"170px",color:"white",height:"65px"},children:[Q," ",E,w.jsx("br",{}),w.jsxs("span",{style:{fontSize:"0.75rem",display:"block",color:"white"},children:["(",(E/i).toFixed(6)," BTC)"]})]},E))}),w.jsxs("div",{className:"donate-inputs",children:[w.jsx("div",{className:"donate-input-wrapper",children:w.jsx("input",{type:"text",placeholder:"Custom amount(BTC)",value:n,onChange:W,onBlur:()=>I(null),className:"focus-effect"})}),w.jsx("div",{className:"donate-input-wrapper",children:w.jsx("input",{type:"text",placeholder:`Custom amount(${l.toUpperCase()})`,value:t,onChange:N,onBlur:()=>I(null),className:"focus-effect"})})]}),w.jsx("textarea",{className:"focus-effect",style:{width:"100%",border:"1px solid #d1d5db",padding:" 15px 15px 15px 20px",borderRadius:"1px",margin:" 30px 0 10px",lineHeight:"1.25rem",boxShadow:"inset 0 1px 2px rgba(0, 0, 0, 0.075)"},placeholder:"Optional description (for your wallet or contact info)",value:f,onChange:E=>R(E.target.value),rows:2,name:"note",id:"note"}),w.jsxs("div",{style:{textAlign:"center",marginTop:"auto"},children:[w.jsx("span",{style:{color:"#4b5563",fontSize:"0.75rem",lineHeight:"1rem"},children:"Current Rate:"}),w.jsxs("span",{style:{marginLeft:"0.5rem",fontSize:"0.875rem",lineHeight:"1.25rem"},children:["1 BTC ≈ ",i.toLocaleString()," ",l.toUpperCase()]})]})]})]})]})};B.BitcoinDonate=ve,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});