UNPKG

btcdonate

Version:

A standalone React component for BTC donations.

1,355 lines (1,348 loc) 60.4 kB
import S, { useState as U, useEffect as ne, useCallback as Ae } from "react"; var K = { exports: {} }, Z = {}; /** * @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 le; function Me() { if (le) return Z; le = 1; var u = Symbol.for("react.transitional.element"), l = Symbol.for("react.fragment"); function a(c, h, f) { var R = null; if (f !== void 0 && (R = "" + f), h.key !== void 0 && (R = "" + h.key), "key" in h) { f = {}; for (var x in h) x !== "key" && (f[x] = h[x]); } else f = h; return h = f.ref, { $$typeof: u, type: c, key: R, ref: h !== void 0 ? h : null, props: f }; } return Z.Fragment = l, Z.jsx = a, Z.jsxs = a, Z; } var q = {}; /** * @license React * react-jsx-runtime.development.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 ce; function Se() { return ce || (ce = 1, process.env.NODE_ENV !== "production" && function() { function u(s) { if (s == null) return null; if (typeof s == "function") return s.$$typeof === Y ? null : s.displayName || s.name || null; if (typeof s == "string") return s; switch (s) { case m: return "Fragment"; case O: return "Profiler"; case p: return "StrictMode"; case P: return "Suspense"; case L: return "SuspenseList"; case $: return "Activity"; } if (typeof s == "object") switch (typeof s.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), s.$$typeof) { case i: return "Portal"; case g: return (s.displayName || "Context") + ".Provider"; case A: return (s._context.displayName || "Context") + ".Consumer"; case y: var E = s.render; return s = s.displayName, s || (s = E.displayName || E.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s; case H: return E = s.displayName || null, E !== null ? E : u(s.type) || "Memo"; case F: E = s._payload, s = s._init; try { return u(s(E)); } catch { } } return null; } function l(s) { return "" + s; } function a(s) { try { l(s); var E = !1; } catch { E = !0; } if (E) { E = console; var v = E.error, T = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object"; return v.call( E, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", T ), l(s); } } function c(s) { if (s === m) return "<>"; if (typeof s == "object" && s !== null && s.$$typeof === F) return "<...>"; try { var E = u(s); return E ? "<" + E + ">" : "<...>"; } catch { return "<...>"; } } function h() { var s = k.A; return s === null ? null : s.getOwner(); } function f() { return Error("react-stack-top-frame"); } function R(s) { if (W.call(s, "key")) { var E = Object.getOwnPropertyDescriptor(s, "key").get; if (E && E.isReactWarning) return !1; } return s.key !== void 0; } function x(s, E) { function v() { I || (I = !0, console.error( "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", E )); } v.isReactWarning = !0, Object.defineProperty(s, "key", { get: v, configurable: !0 }); } function e() { var s = u(this.type); return C[s] || (C[s] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), s = this.props.ref, s !== void 0 ? s : null; } function r(s, E, v, T, B, D, te, re) { return v = D.ref, s = { $$typeof: d, type: s, key: E, props: D, _owner: B }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(s, "ref", { enumerable: !1, get: e }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(s, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(s, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: te }), Object.defineProperty(s, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: re }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s; } function t(s, E, v, T, B, D, te, re) { var _ = E.children; if (_ !== void 0) if (T) if (V(_)) { for (T = 0; T < _.length; T++) o(_[T]); Object.freeze && Object.freeze(_); } else console.error( "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead." ); else o(_); if (W.call(E, "key")) { _ = u(s); var X = Object.keys(E).filter(function(ye) { return ye !== "key"; }); T = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", G[_ + T] || (X = 0 < X.length ? "{" + X.join(": ..., ") + ": ...}" : "{}", console.error( `A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, T, _, X, _ ), G[_ + T] = !0); } if (_ = null, v !== void 0 && (a(v), _ = "" + v), R(E) && (a(E.key), _ = "" + E.key), "key" in E) { v = {}; for (var oe in E) oe !== "key" && (v[oe] = E[oe]); } else v = E; return _ && x( v, typeof s == "function" ? s.displayName || s.name || "Unknown" : s ), r( s, _, D, B, h(), v, te, re ); } function o(s) { typeof s == "object" && s !== null && s.$$typeof === d && s._store && (s._store.validated = 1); } var n = S, d = Symbol.for("react.transitional.element"), i = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), p = Symbol.for("react.strict_mode"), O = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), g = Symbol.for("react.context"), y = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), L = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), $ = Symbol.for("react.activity"), Y = Symbol.for("react.client.reference"), k = n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, V = Array.isArray, j = console.createTask ? console.createTask : function() { return null; }; n = { react_stack_bottom_frame: function(s) { return s(); } }; var I, C = {}, N = n.react_stack_bottom_frame.bind( n, f )(), z = j(c(f)), G = {}; q.Fragment = m, q.jsx = function(s, E, v, T, B) { var D = 1e4 > k.recentlyCreatedOwnerStacks++; return t( s, E, v, !1, T, B, D ? Error("react-stack-top-frame") : N, D ? j(c(s)) : z ); }, q.jsxs = function(s, E, v, T, B) { var D = 1e4 > k.recentlyCreatedOwnerStacks++; return t( s, E, v, !0, T, B, D ? Error("react-stack-top-frame") : N, D ? j(c(s)) : z ); }; }()), q; } var ue; function Ne() { return ue || (ue = 1, process.env.NODE_ENV === "production" ? K.exports = Me() : K.exports = Se()), K.exports; } var b = Ne(), Pe = Object.defineProperty, ee = Object.getOwnPropertySymbols, fe = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable, de = (u, l, a) => l in u ? Pe(u, l, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[l] = a, ae = (u, l) => { for (var a in l || (l = {})) fe.call(l, a) && de(u, a, l[a]); if (ee) for (var a of ee(l)) he.call(l, a) && de(u, a, l[a]); return u; }, ie = (u, l) => { var a = {}; for (var c in u) fe.call(u, c) && l.indexOf(c) < 0 && (a[c] = u[c]); if (u != null && ee) for (var c of ee(u)) l.indexOf(c) < 0 && he.call(u, c) && (a[c] = u[c]); return a; }; /** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */ var Q; ((u) => { const l = class w { /*-- Constructor (low level) and fields --*/ // Creates a new QR Code with the given version number, // error correction level, data codeword bytes, and mask number. // This is a low-level API that most users should not use directly. // A mid-level API is the encodeSegments() function. constructor(e, r, t, o) { if (this.version = e, this.errorCorrectionLevel = r, this.modules = [], this.isFunction = [], e < w.MIN_VERSION || e > w.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 = 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 d = this.addEccAndInterleave(t); if (this.drawCodewords(d), o == -1) { let i = 1e9; for (let m = 0; m < 8; m++) { this.applyMask(m), this.drawFormatBits(m); const p = this.getPenaltyScore(); p < i && (o = m, i = p), this.applyMask(m); } } h(0 <= o && o <= 7), this.mask = o, this.applyMask(o), this.drawFormatBits(o), this.isFunction = []; } /*-- Static factory functions (high level) --*/ // Returns a QR Code representing the given Unicode text string at the given error correction level. // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the // ecl argument if it can be done without increasing the version. static encodeText(e, r) { const t = u.QrSegment.makeSegments(e); return w.encodeSegments(t, r); } // Returns a QR Code representing the given binary data at the given error correction level. // This function always encodes using the binary segment mode, not any text mode. The maximum number of // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. static encodeBinary(e, r) { const t = u.QrSegment.makeBytes(e); return w.encodeSegments([t], r); } /*-- Static factory functions (mid level) --*/ // Returns a QR Code representing the given segments with the given encoding parameters. // The smallest possible QR Code version within the given range is automatically // chosen for the output. Iff boostEcl is true, then the ECC level of the result // may be higher than the ecl argument if it can be done without increasing the // version. The mask number is either between 0 to 7 (inclusive) to force that // mask, or -1 to automatically choose an appropriate mask (which may be slow). // This function allows the user to create a custom sequence of segments that switches // between modes (such as alphanumeric and byte) to encode text in less space. // This is a mid-level API; the high-level API is encodeText() and encodeBinary(). static encodeSegments(e, r, t = 1, o = 40, n = -1, d = !0) { if (!(w.MIN_VERSION <= t && t <= o && o <= w.MAX_VERSION) || n < -1 || n > 7) throw new RangeError("Invalid value"); let i, m; for (i = t; ; i++) { const g = w.getNumDataCodewords(i, r) * 8, y = R.getTotalBits(e, i); if (y <= g) { m = y; break; } if (i >= o) throw new RangeError("Data too long"); } for (const g of [w.Ecc.MEDIUM, w.Ecc.QUARTILE, w.Ecc.HIGH]) d && m <= w.getNumDataCodewords(i, g) * 8 && (r = g); let p = []; for (const g of e) { a(g.mode.modeBits, 4, p), a(g.numChars, g.mode.numCharCountBits(i), p); for (const y of g.getData()) p.push(y); } h(p.length == m); const O = w.getNumDataCodewords(i, r) * 8; h(p.length <= O), a(0, Math.min(4, O - p.length), p), a(0, (8 - p.length % 8) % 8, p), h(p.length % 8 == 0); for (let g = 236; p.length < O; g ^= 253) a(g, 8, p); let A = []; for (; A.length * 8 < p.length; ) A.push(0); return p.forEach((g, y) => A[y >>> 3] |= g << 7 - (y & 7)), new w(i, r, A, n); } /*-- Accessor methods --*/ // Returns the color of the module (pixel) at the given coordinates, which is false // for light or true for dark. The top left corner has the coordinates (x=0, y=0). // If the given coordinates are out of bounds, then false (light) is returned. getModule(e, r) { return 0 <= e && e < this.size && 0 <= r && r < this.size && this.modules[r][e]; } // Modified to expose modules for easy access getModules() { return this.modules; } /*-- Private helper methods for constructor: Drawing function modules --*/ // Reads this object's version field, and draws and marks all function 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(), r = e.length; for (let t = 0; t < r; t++) for (let o = 0; o < r; o++) t == 0 && o == 0 || t == 0 && o == r - 1 || t == r - 1 && o == 0 || this.drawAlignmentPattern(e[t], e[o]); this.drawFormatBits(0), this.drawVersion(); } // Draws two copies of the format bits (with its own error correction code) // based on the given mask and this object's error correction level field. drawFormatBits(e) { const r = this.errorCorrectionLevel.formatBits << 3 | e; let t = r; for (let n = 0; n < 10; n++) t = t << 1 ^ (t >>> 9) * 1335; const o = (r << 10 | t) ^ 21522; h(o >>> 15 == 0); for (let n = 0; n <= 5; n++) this.setFunctionModule(8, n, c(o, n)); this.setFunctionModule(8, 7, c(o, 6)), this.setFunctionModule(8, 8, c(o, 7)), this.setFunctionModule(7, 8, c(o, 8)); for (let n = 9; n < 15; n++) this.setFunctionModule(14 - n, 8, c(o, n)); for (let n = 0; n < 8; n++) this.setFunctionModule(this.size - 1 - n, 8, c(o, n)); for (let n = 8; n < 15; n++) this.setFunctionModule(8, this.size - 15 + n, c(o, n)); this.setFunctionModule(8, this.size - 8, !0); } // Draws two copies of the version bits (with its own error correction code), // based on this object's version field, iff 7 <= version <= 40. drawVersion() { if (this.version < 7) return; let e = this.version; for (let t = 0; t < 12; t++) e = e << 1 ^ (e >>> 11) * 7973; const r = this.version << 12 | e; h(r >>> 18 == 0); for (let t = 0; t < 18; t++) { const o = c(r, t), n = this.size - 11 + t % 3, d = Math.floor(t / 3); this.setFunctionModule(n, d, o), this.setFunctionModule(d, n, o); } } // Draws a 9*9 finder pattern including the border separator, // with the center module at (x, y). Modules can be out of bounds. drawFinderPattern(e, r) { for (let t = -4; t <= 4; t++) for (let o = -4; o <= 4; o++) { const n = Math.max(Math.abs(o), Math.abs(t)), d = e + o, i = r + t; 0 <= d && d < this.size && 0 <= i && i < this.size && this.setFunctionModule(d, i, n != 2 && n != 4); } } // Draws a 5*5 alignment pattern, with the center module // at (x, y). All modules must be in bounds. drawAlignmentPattern(e, r) { for (let t = -2; t <= 2; t++) for (let o = -2; o <= 2; o++) this.setFunctionModule(e + o, r + t, Math.max(Math.abs(o), Math.abs(t)) != 1); } // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in bounds. setFunctionModule(e, r, t) { this.modules[r][e] = t, this.isFunction[r][e] = !0; } /*-- Private helper methods for constructor: Codewords and masking --*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. addEccAndInterleave(e) { const r = this.version, t = this.errorCorrectionLevel; if (e.length != w.getNumDataCodewords(r, t)) throw new RangeError("Invalid argument"); const o = w.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][r], n = w.ECC_CODEWORDS_PER_BLOCK[t.ordinal][r], d = Math.floor(w.getNumRawDataModules(r) / 8), i = o - d % o, m = Math.floor(d / o); let p = []; const O = w.reedSolomonComputeDivisor(n); for (let g = 0, y = 0; g < o; g++) { let P = e.slice(y, y + m - n + (g < i ? 0 : 1)); y += P.length; const L = w.reedSolomonComputeRemainder(P, O); g < i && P.push(0), p.push(P.concat(L)); } let A = []; for (let g = 0; g < p[0].length; g++) p.forEach((y, P) => { (g != m - n || P >= i) && A.push(y[g]); }); return h(A.length == d), A; } // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code. Function modules need to be marked off before this is called. drawCodewords(e) { if (e.length != Math.floor(w.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument"); let r = 0; for (let t = this.size - 1; t >= 1; t -= 2) { t == 6 && (t = 5); for (let o = 0; o < this.size; o++) for (let n = 0; n < 2; n++) { const d = t - n, m = (t + 1 & 2) == 0 ? this.size - 1 - o : o; !this.isFunction[m][d] && r < e.length * 8 && (this.modules[m][d] = c(e[r >>> 3], 7 - (r & 7)), r++); } } h(r == e.length * 8); } // XORs the codeword modules in this QR Code with the given mask pattern. // The function modules must be marked and the codeword bits must be drawn // before masking. Due to the arithmetic of XOR, calling applyMask() with // the same mask value a second time will undo the mask. A final well-formed // QR Code needs exactly one (not zero, two, etc.) mask applied. applyMask(e) { if (e < 0 || e > 7) throw new RangeError("Mask value out of range"); for (let r = 0; r < this.size; r++) for (let t = 0; t < this.size; t++) { let o; switch (e) { case 0: o = (t + r) % 2 == 0; break; case 1: o = r % 2 == 0; break; case 2: o = t % 3 == 0; break; case 3: o = (t + r) % 3 == 0; break; case 4: o = (Math.floor(t / 3) + Math.floor(r / 2)) % 2 == 0; break; case 5: o = t * r % 2 + t * r % 3 == 0; break; case 6: o = (t * r % 2 + t * r % 3) % 2 == 0; break; case 7: o = ((t + r) % 2 + t * r % 3) % 2 == 0; break; default: throw new Error("Unreachable"); } !this.isFunction[r][t] && o && (this.modules[r][t] = !this.modules[r][t]); } } // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. getPenaltyScore() { let e = 0; for (let n = 0; n < this.size; n++) { let d = !1, i = 0, m = [0, 0, 0, 0, 0, 0, 0]; for (let p = 0; p < this.size; p++) this.modules[n][p] == d ? (i++, i == 5 ? e += w.PENALTY_N1 : i > 5 && e++) : (this.finderPenaltyAddHistory(i, m), d || (e += this.finderPenaltyCountPatterns(m) * w.PENALTY_N3), d = this.modules[n][p], i = 1); e += this.finderPenaltyTerminateAndCount(d, i, m) * w.PENALTY_N3; } for (let n = 0; n < this.size; n++) { let d = !1, i = 0, m = [0, 0, 0, 0, 0, 0, 0]; for (let p = 0; p < this.size; p++) this.modules[p][n] == d ? (i++, i == 5 ? e += w.PENALTY_N1 : i > 5 && e++) : (this.finderPenaltyAddHistory(i, m), d || (e += this.finderPenaltyCountPatterns(m) * w.PENALTY_N3), d = this.modules[p][n], i = 1); e += this.finderPenaltyTerminateAndCount(d, i, m) * w.PENALTY_N3; } for (let n = 0; n < this.size - 1; n++) for (let d = 0; d < this.size - 1; d++) { const i = this.modules[n][d]; i == this.modules[n][d + 1] && i == this.modules[n + 1][d] && i == this.modules[n + 1][d + 1] && (e += w.PENALTY_N2); } let r = 0; for (const n of this.modules) r = n.reduce((d, i) => d + (i ? 1 : 0), r); const t = this.size * this.size, o = Math.ceil(Math.abs(r * 20 - t * 10) / t) - 1; return h(0 <= o && o <= 9), e += o * w.PENALTY_N4, h(0 <= e && e <= 2568888), e; } /*-- Private helper functions --*/ // Returns an ascending list of positions of alignment patterns for this version number. // Each position is in the range [0,177), and are used on both the x and y axes. // This could be implemented as lookup table of 40 variable-length lists of integers. getAlignmentPatternPositions() { if (this.version == 1) return []; { const e = Math.floor(this.version / 7) + 2, r = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2; let t = [6]; for (let o = this.size - 7; t.length < e; o -= r) t.splice(1, 0, o); return t; } } // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. static getNumRawDataModules(e) { if (e < w.MIN_VERSION || e > w.MAX_VERSION) throw new RangeError("Version number out of range"); let r = (16 * e + 128) * e + 64; if (e >= 2) { const t = Math.floor(e / 7) + 2; r -= (25 * t - 10) * t - 55, e >= 7 && (r -= 36); } return h(208 <= r && r <= 29648), r; } // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. static getNumDataCodewords(e, r) { return Math.floor(w.getNumRawDataModules(e) / 8) - w.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e] * w.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]; } // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be // implemented as a lookup table over all possible parameter values, instead of as an algorithm. static reedSolomonComputeDivisor(e) { if (e < 1 || e > 255) throw new RangeError("Degree out of range"); let r = []; for (let o = 0; o < e - 1; o++) r.push(0); r.push(1); let t = 1; for (let o = 0; o < e; o++) { for (let n = 0; n < r.length; n++) r[n] = w.reedSolomonMultiply(r[n], t), n + 1 < r.length && (r[n] ^= r[n + 1]); t = w.reedSolomonMultiply(t, 2); } return r; } // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials. static reedSolomonComputeRemainder(e, r) { let t = r.map((o) => 0); for (const o of e) { const n = o ^ t.shift(); t.push(0), r.forEach((d, i) => t[i] ^= w.reedSolomonMultiply(d, n)); } return t; } // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. static reedSolomonMultiply(e, r) { if (e >>> 8 || r >>> 8) throw new RangeError("Byte out of range"); let t = 0; for (let o = 7; o >= 0; o--) t = t << 1 ^ (t >>> 7) * 285, t ^= (r >>> o & 1) * e; return h(t >>> 8 == 0), t; } // Can only be called immediately after a light run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). finderPenaltyCountPatterns(e) { const r = e[1]; h(r <= this.size * 3); const t = r > 0 && e[2] == r && e[3] == r * 3 && e[4] == r && e[5] == r; return (t && e[0] >= r * 4 && e[6] >= r ? 1 : 0) + (t && e[6] >= r * 4 && e[0] >= r ? 1 : 0); } // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore(). finderPenaltyTerminateAndCount(e, r, t) { return e && (this.finderPenaltyAddHistory(r, t), r = 0), r += this.size, this.finderPenaltyAddHistory(r, t), this.finderPenaltyCountPatterns(t); } // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). finderPenaltyAddHistory(e, r) { r[0] == 0 && (e += this.size), r.pop(), r.unshift(e); } }; l.MIN_VERSION = 1, l.MAX_VERSION = 40, l.PENALTY_N1 = 3, l.PENALTY_N2 = 3, l.PENALTY_N3 = 40, l.PENALTY_N4 = 10, l.ECC_CODEWORDS_PER_BLOCK = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [-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], // Low [-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], // Medium [-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], // Quartile [-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] // High ], l.NUM_ERROR_CORRECTION_BLOCKS = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [-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], // Low [-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], // Medium [-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], // Quartile [-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] // High ], u.QrCode = l; function a(x, e, r) { if (e < 0 || e > 31 || x >>> e) throw new RangeError("Value out of range"); for (let t = e - 1; t >= 0; t--) r.push(x >>> t & 1); } function c(x, e) { return (x >>> e & 1) != 0; } function h(x) { if (!x) throw new Error("Assertion error"); } const f = class M { /*-- Constructor (low level) and fields --*/ // Creates a new QR Code segment with the given attributes and data. // The character count (numChars) must agree with the mode and the bit buffer length, // but the constraint isn't checked. The given bit buffer is cloned and stored. constructor(e, r, t) { if (this.mode = e, this.numChars = r, this.bitData = t, r < 0) throw new RangeError("Invalid argument"); this.bitData = t.slice(); } /*-- Static factory functions (mid level) --*/ // Returns a segment representing the given binary data encoded in // byte mode. All input byte arrays are acceptable. Any text string // can be converted to UTF-8 bytes and encoded as a byte mode segment. static makeBytes(e) { let r = []; for (const t of e) a(t, 8, r); return new M(M.Mode.BYTE, e.length, r); } // Returns a segment representing the given string of decimal digits encoded in numeric mode. static makeNumeric(e) { if (!M.isNumeric(e)) throw new RangeError("String contains non-numeric characters"); let r = []; for (let t = 0; t < e.length; ) { const o = Math.min(e.length - t, 3); a(parseInt(e.substring(t, t + o), 10), o * 3 + 1, r), t += o; } return new M(M.Mode.NUMERIC, e.length, r); } // Returns a segment representing the given text string encoded in alphanumeric mode. // The characters allowed are: 0 to 9, A to Z (uppercase only), space, // dollar, percent, asterisk, plus, hyphen, period, slash, colon. static makeAlphanumeric(e) { if (!M.isAlphanumeric(e)) throw new RangeError("String contains unencodable characters in alphanumeric mode"); let r = [], t; for (t = 0; t + 2 <= e.length; t += 2) { let o = M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)) * 45; o += M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t + 1)), a(o, 11, r); } return t < e.length && a(M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)), 6, r), new M(M.Mode.ALPHANUMERIC, e.length, r); } // Returns a new mutable list of zero or more segments to represent the given Unicode text string. // The result may use various segment modes and switch modes to optimize the length of the bit stream. static makeSegments(e) { return e == "" ? [] : M.isNumeric(e) ? [M.makeNumeric(e)] : M.isAlphanumeric(e) ? [M.makeAlphanumeric(e)] : [M.makeBytes(M.toUtf8ByteArray(e))]; } // Returns a segment representing an Extended Channel Interpretation // (ECI) designator with the given assignment value. static makeEci(e) { let r = []; if (e < 0) throw new RangeError("ECI assignment value out of range"); if (e < 128) a(e, 8, r); else if (e < 16384) a(2, 2, r), a(e, 14, r); else if (e < 1e6) a(6, 3, r), a(e, 21, r); else throw new RangeError("ECI assignment value out of range"); return new M(M.Mode.ECI, 0, r); } // Tests whether the given string can be encoded as a segment in numeric mode. // A string is encodable iff each character is in the range 0 to 9. static isNumeric(e) { return M.NUMERIC_REGEX.test(e); } // Tests whether the given string can be encoded as a segment in alphanumeric mode. // A string is encodable iff each character is in the following set: 0 to 9, A to Z // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. static isAlphanumeric(e) { return M.ALPHANUMERIC_REGEX.test(e); } /*-- Methods --*/ // Returns a new copy of the data bits of this segment. getData() { return this.bitData.slice(); } // (Package-private) Calculates and returns the number of bits needed to encode the given segments at // the given version. The result is infinity if a segment has too many characters to fit its length field. static getTotalBits(e, r) { let t = 0; for (const o of e) { const n = o.mode.numCharCountBits(r); if (o.numChars >= 1 << n) return 1 / 0; t += 4 + n + o.bitData.length; } return t; } // Returns a new array of bytes representing the given string encoded in UTF-8. static toUtf8ByteArray(e) { e = encodeURI(e); let r = []; for (let t = 0; t < e.length; t++) e.charAt(t) != "%" ? r.push(e.charCodeAt(t)) : (r.push(parseInt(e.substring(t + 1, t + 3), 16)), t += 2); return r; } }; f.NUMERIC_REGEX = /^[0-9]*$/, f.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, f.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; let R = f; u.QrSegment = f; })(Q || (Q = {})); ((u) => { ((l) => { const a = class { // The QR Code can tolerate about 30% erroneous codewords /*-- Constructor and fields --*/ constructor(h, f) { this.ordinal = h, this.formatBits = f; } }; a.LOW = new a(0, 1), a.MEDIUM = new a(1, 0), a.QUARTILE = new a(2, 3), a.HIGH = new a(3, 2), l.Ecc = a; })(u.QrCode || (u.QrCode = {})); })(Q || (Q = {})); ((u) => { ((l) => { const a = class { /*-- Constructor and fields --*/ constructor(h, f) { this.modeBits = h, this.numBitsCharCount = f; } /*-- Method --*/ // (Package-private) Returns the bit width of the character count field for a segment in // this mode in a QR Code at the given version number. The result is in the range [0, 16]. numCharCountBits(h) { return this.numBitsCharCount[Math.floor((h + 7) / 17)]; } }; a.NUMERIC = new a(1, [10, 12, 14]), a.ALPHANUMERIC = new a(2, [9, 11, 13]), a.BYTE = new a(4, [8, 16, 16]), a.KANJI = new a(8, [8, 10, 12]), a.ECI = new a(7, [0, 0, 0]), l.Mode = a; })(u.QrSegment || (u.QrSegment = {})); })(Q || (Q = {})); var J = Q; /** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */ var Te = { L: J.QrCode.Ecc.LOW, M: J.QrCode.Ecc.MEDIUM, Q: J.QrCode.Ecc.QUARTILE, H: J.QrCode.Ecc.HIGH }, pe = 128, me = "L", ge = "#FFFFFF", Ee = "#000000", we = !1, be = 1, ke = 4, Oe = 0, _e = 0.1; function Ce(u, l = 0) { const a = []; return u.forEach(function(c, h) { let f = null; c.forEach(function(R, x) { if (!R && f !== null) { a.push( `M${f + l} ${h + l}h${x - f}v1H${f + l}z` ), f = null; return; } if (x === c.length - 1) { if (!R) return; f === null ? a.push(`M${x + l},${h + l} h1v1H${x + l}z`) : a.push( `M${f + l},${h + l} h${x + 1 - f}v1H${f + l}z` ); return; } R && f === null && (f = x); }); }), a.join(""); } function xe(u, l) { return u.slice().map((a, c) => c < l.y || c >= l.y + l.h ? a : a.map((h, f) => f < l.x || f >= l.x + l.w ? h : !1)); } function Ie(u, l, a, c) { if (c == null) return null; const h = u.length + a * 2, f = Math.floor(l * _e), R = h / l, x = (c.width || f) * R, e = (c.height || f) * R, r = c.x == null ? u.length / 2 - x / 2 : c.x * R, t = c.y == null ? u.length / 2 - e / 2 : c.y * R, o = c.opacity == null ? 1 : c.opacity; let n = null; if (c.excavate) { let i = Math.floor(r), m = Math.floor(t), p = Math.ceil(x + r - i), O = Math.ceil(e + t - m); n = { x: i, y: m, w: p, h: O }; } const d = c.crossOrigin; return { x: r, y: t, h: e, w: x, excavation: n, opacity: o, crossOrigin: d }; } function je(u, l) { return l != null ? Math.max(Math.floor(l), 0) : u ? ke : Oe; } function Re({ value: u, level: l, minVersion: a, includeMargin: c, marginSize: h, imageSettings: f, size: R, boostLevel: x }) { let e = S.useMemo(() => { const i = (Array.isArray(u) ? u : [u]).reduce((m, p) => (m.push(...J.QrSegment.makeSegments(p)), m), []); return J.QrCode.encodeSegments( i, Te[l], a, void 0, void 0, x ); }, [u, l, a, x]); const { cells: r, margin: t, numCells: o, calculatedImageSettings: n } = S.useMemo(() => { let d = e.getModules(); const i = je(c, h), m = d.length + i * 2, p = Ie( d, R, i, f ); return { cells: d, margin: i, numCells: m, calculatedImageSettings: p }; }, [e, R, f, c, h]); return { qrcode: e, margin: t, cells: r, numCells: o, calculatedImageSettings: n }; } var Le = function() { try { new Path2D().addPath(new Path2D()); } catch { return !1; } return !0; }(), ve = S.forwardRef( function(l, a) { const c = l, { value: h, size: f = pe, level: R = me, bgColor: x = ge, fgColor: e = Ee, includeMargin: r = we, minVersion: t = be, boostLevel: o, marginSize: n, imageSettings: d } = c, m = ie(c, [ "value", "size", "level", "bgColor", "fgColor", "includeMargin", "minVersion", "boostLevel", "marginSize", "imageSettings" ]), { style: p } = m, O = ie(m, ["style"]), A = d?.src, g = S.useRef(null), y = S.useRef(null), P = S.useCallback( (j) => { g.current = j, typeof a == "function" ? a(j) : a && (a.current = j); }, [a] ), [L, H] = S.useState(!1), { margin: F, cells: $, numCells: Y, calculatedImageSettings: k } = Re({ value: h, level: R, minVersion: t, boostLevel: o, includeMargin: r, marginSize: n, imageSettings: d, size: f }); S.useEffect(() => { if (g.current != null) { const j = g.current, I = j.getContext("2d"); if (!I) return; let C = $; const N = y.current, z = k != null && N !== null && N.complete && N.naturalHeight !== 0 && N.naturalWidth !== 0; z && k.excavation != null && (C = xe( $, k.excavation )); const G = window.devicePixelRatio || 1; j.height = j.width = f * G; const s = f / Y * G; I.scale(s, s), I.fillStyle = x, I.fillRect(0, 0, Y, Y), I.fillStyle = e, Le ? I.fill(new Path2D(Ce(C, F))) : $.forEach(function(E, v) { E.forEach(function(T, B) { T && I.fillRect(B + F, v + F, 1, 1); }); }), k && (I.globalAlpha = k.opacity), z && I.drawImage( N, k.x + F, k.y + F, k.w, k.h ); } }), S.useEffect(() => { H(!1); }, [A]); const W = ae({ height: f, width: f }, p); let V = null; return A != null && (V = /* @__PURE__ */ S.createElement( "img", { src: A, key: A, style: { display: "none" }, onLoad: () => { H(!0); }, ref: y, crossOrigin: k?.crossOrigin } )), /* @__PURE__ */ S.createElement(S.Fragment, null, /* @__PURE__ */ S.createElement( "canvas", ae({ style: W, height: f, width: f, ref: P, role: "img" }, O) ), V); } ); ve.displayName = "QRCodeCanvas"; var Fe = S.forwardRef( function(l, a) { const c = l, { value: h, size: f = pe, level: R = me, bgColor: x = ge, fgColor: e = Ee, includeMargin: r = we, minVersion: t = be, boostLevel: o, title: n, marginSize: d, imageSettings: i } = c, m = ie(c, [ "value", "size", "level", "bgColor", "fgColor", "includeMargin", "minVersion", "boostLevel", "title", "marginSize", "imageSettings" ]), { margin: p, cells: O, numCells: A, calculatedImageSettings: g } = Re({ value: h, level: R, minVersion: t, boostLevel: o, includeMargin: r, marginSize: d, imageSettings: i, size: f }); let y = O, P = null; i != null && g != null && (g.excavation != null && (y = xe( O, g.excavation )), P = /* @__PURE__ */ S.createElement( "image", { href: i.src, height: g.h, width: g.w, x: g.x + p, y: g.y + p, preserveAspectRatio: "none", opacity: g.opacity, crossOrigin: g.crossOrigin } )); const L = Ce(y, p); return /* @__PURE__ */ S.createElement( "svg", ae({ height: f, width: f, viewBox: `0 0 ${A} ${A}`, ref: a, role: "img" }, m), !!n && /* @__PURE__ */ S.createElement("title", null, n), /* @__PURE__ */ S.createElement( "path", { fill: x, d: `M0,0 h${A}v${A}H0z`, shapeRendering: "crispEdges" } ), /* @__PURE__ */ S.createElement("path", { fill: e, d: L, shapeRendering: "crispEdges" }), P ); } ); Fe.displayName = "QRCodeSVG"; const se = (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 "$"; } }, ze = () => { const [u, l] = U(!1), [a, c] = U("複製"), h = Ae((f) => { navigator.clipboard.writeText(f).then( () => { l(!0), c("已複製!"), setTimeout(() => { l(!1), c("複製"); }, 2e3); }, (R) => { console.error("無法複製到剪貼簿", R), c("複製失敗"), setTimeout(() => c("複製"), 2e3); } ); }, []); return [u, h, a]; }, $e = ({ address: u = "bc1qx6xswq65n5x864vwj77lrtn0xn2rmlh3ypfkk8", title: l = "Donate", description: a = "Use this QR code or address below", currency: c = "usd", presets: h = [50, 100, 200], showButton: f = !0, buttonText: R = "Support Bitcoin.org", onClose: x }) => { const [e, r] = U(!1), [t, o] = U(""), [n, d] = U(""), [i, m] = U(112776), [p, O] = U(""), [A, g, y] = ze(), [P, L] = U(null), [H, F] = U(se(c.toLowerCase())); ne(() => { (async () => { try { const N = c.toLowerCase(); F(se(N)); const z = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${N}`); if (!z.ok) throw new Error(`HTTP error! Status: ${z.status}`); const s = (await z.json()).bitcoin?.[N]; s ? m(s) : console.warn(`Could not find rate for currency: ${N}`); } catch (N) { console.error("Error fetching Bitcoin rate:", N), m(112776), c = "usd"; const z = c.toLowerCase(); F(se(z)); } })(); }, [c]), ne(() => { if (P === "usd") { const C = parseFloat(t); if (isNaN(C)) d(""); else { const N = (C / i).toFixed(8); d(N); } } }, [t, i, P]), ne(() => { if (P === "btc") { const C = parseFloat(n); if (isNaN(C)) o(""); else { const N = (C * i).toFixed(2); o(N); } } }, [n, i, P]); const $ = `bitcoin:${u}?amount=${parseFloat(n)}${p ? `&message=${encodeURIComponent(p)}` : ""}`, Y = () => { r(!1), x?.(); }, k = (C) => { o(C.target.value), L("usd"); }, W = (C) => { d(C.target.value), L("btc"); }, V = (C) => { o(C.toString()), L("usd"); }, j = () => /* @__PURE__ */ b.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: [ /* @__PURE__ */ b.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), /* @__PURE__ */ b.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }) ] } ), I = () => /* @__PURE__ */ b.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: /* @__PURE__ */ b.jsx("polyline", { points: "20 6 9 17 4 12" }) } ); return /* @__PURE__ */ b.jsxs(b.Fragment, { children: [ f && /* @__PURE__ */ b.jsx( "button", { onClick: () => r(!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: (C) => C.currentTarget.style.backgroundColor = "#4a4a4a", onMouseOut: (C) => C.currentTarget.style.backgroundColor = "#2a2a2a", children: R } ), e && /* @__PURE__ */ b.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: [ /* @__PURE__ */ b.jsx("style", { children: ` @keyframes fadeInZoom { 0% { opacity: 0; transform: scale(0.5); } 100% { opacity: 1; transform: scale(1); } } .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; color: "#646464"; animation: fadeInZoom 0.3s ease-out; transform-origin: top; } .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 { display: flex; gap: 0.5rem; justify-content: center; justify-content: space-between; margin-bottom: 2rem; } .donate-inputs { display: flex; gap: 1rem; } .donate-input-wrapper { position: relative; flex: 1; } .donate-input-wrapper input { width: 100%; border: 1px solid #d1d5db; padding: 15px 15px 15px 20