UNPKG

react-squadpay

Version:
690 lines (686 loc) 23.2 kB
import Ce, { useState as ir, useEffect as ur } from "react"; const sr = (l) => { function g() { l = document.createElement("div"), l.style.padding = "0.6rem 0.6rem", l.style.backgroundColor = "#fff3cd", l.style.color = "#664d03", l.style.borderColor = "#ffecb5", l.style.borderRadius = "0.25rem", l.style.position = "fixed", l.style.width = "100%", l.style.top = "0px", l.style.textAlign = "center"; let h = document.createElement("p"); h.innerText = "Ooop! There seems to be an issue. please reload and try again!", h.style.fontWeight = "700"; const i = document.createElement("button"); i.innerText = "close", i.style.color = "#000", i.style.backgroundColor = "#f8f9fa", i.style.borderColor = "#f8f9fa", i.style.backgroundColor = "transparent", i.style.border = "1px solid transparent", i.style.padding = "0.375rem 0.75rem", i.style.fontSize = "1rem", i.style.borderRadius = "0.25rem", i.style.transition = "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out", i.onclick = function() { l = null, document.body.removeChild(l); }, l.appendChild(h), l.appendChild(i), document.body.prepend(l); } return g; }, lr = () => { const [l, g] = ir(!1); let h = !0; return ur(() => { function i() { const T = "https://checkout.squadco.com/widget/squad.min.js", d = document.createElement("script"), _ = () => { g(!0), d.removeEventListener("error", b), d.removeEventListener("load", _); }, b = () => { g(!1), d.removeEventListener("error", b), d.removeEventListener("load", _); }; d.src = T, console.log(T), d.async = !0, d.setAttribute("data-testid", "squad-script"), document.body.appendChild(d), d.addEventListener("load", _), d.addEventListener("error", b); } return h && i(), () => { h = !1; }; }, []), l; }; var Te = { exports: {} }, A = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var _e; function cr() { if (_e) return A; _e = 1; var l = Ce, g = Symbol.for("react.element"), h = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, T = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, d = { key: !0, ref: !0, __self: !0, __source: !0 }; function _(b, v, O) { var p, R = {}, C = null, W = null; O !== void 0 && (C = "" + O), v.key !== void 0 && (C = "" + v.key), v.ref !== void 0 && (W = v.ref); for (p in v) i.call(v, p) && !d.hasOwnProperty(p) && (R[p] = v[p]); if (b && b.defaultProps) for (p in v = b.defaultProps, v) R[p] === void 0 && (R[p] = v[p]); return { $$typeof: g, type: b, key: C, ref: W, props: R, _owner: T.current }; } return A.Fragment = h, A.jsx = _, A.jsxs = _, A; } var I = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Re; function fr() { return Re || (Re = 1, process.env.NODE_ENV !== "production" && function() { var l = Ce, g = Symbol.for("react.element"), h = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), T = Symbol.for("react.strict_mode"), d = Symbol.for("react.profiler"), _ = Symbol.for("react.provider"), b = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), W = Symbol.for("react.offscreen"), H = Symbol.iterator, Se = "@@iterator"; function we(e) { if (e === null || typeof e != "object") return null; var r = H && e[H] || e[Se]; return typeof r == "function" ? r : null; } var x = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function y(e) { { for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) t[n - 1] = arguments[n]; Oe("error", e, t); } } function Oe(e, r, t) { { var n = x.ReactDebugCurrentFrame, u = n.getStackAddendum(); u !== "" && (r += "%s", t = t.concat([u])); var s = t.map(function(o) { return String(o); }); s.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, s); } } var Pe = !1, xe = !1, ke = !1, je = !1, De = !1, X; X = Symbol.for("react.module.reference"); function Fe(e) { return !!(typeof e == "string" || typeof e == "function" || e === i || e === d || De || e === T || e === O || e === p || je || e === W || Pe || xe || ke || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === R || e.$$typeof === _ || e.$$typeof === b || e.$$typeof === v || e.$$typeof === X || e.getModuleId !== void 0)); } function Ae(e, r, t) { var n = e.displayName; if (n) return n; var u = r.displayName || r.name || ""; return u !== "" ? t + "(" + u + ")" : t; } function Z(e) { return e.displayName || "Context"; } function S(e) { if (e == null) return null; if (typeof e.tag == "number" && y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") return e.displayName || e.name || null; if (typeof e == "string") return e; switch (e) { case i: return "Fragment"; case h: return "Portal"; case d: return "Profiler"; case T: return "StrictMode"; case O: return "Suspense"; case p: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case b: var r = e; return Z(r) + ".Consumer"; case _: var t = e; return Z(t._context) + ".Provider"; case v: return Ae(e, e.render, "ForwardRef"); case R: var n = e.displayName || null; return n !== null ? n : S(e.type) || "Memo"; case C: { var u = e, s = u._payload, o = u._init; try { return S(o(s)); } catch { return null; } } } return null; } var P = Object.assign, D = 0, Q, ee, re, te, ne, ae, oe; function ie() { } ie.__reactDisabledLog = !0; function Ie() { { if (D === 0) { Q = console.log, ee = console.info, re = console.warn, te = console.error, ne = console.group, ae = console.groupCollapsed, oe = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: ie, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } D++; } } function We() { { if (D--, D === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: P({}, e, { value: Q }), info: P({}, e, { value: ee }), warn: P({}, e, { value: re }), error: P({}, e, { value: te }), group: P({}, e, { value: ne }), groupCollapsed: P({}, e, { value: ae }), groupEnd: P({}, e, { value: oe }) }); } D < 0 && y("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var U = x.ReactCurrentDispatcher, V; function L(e, r, t) { { if (V === void 0) try { throw Error(); } catch (u) { var n = u.stack.trim().match(/\n( *(at )?)/); V = n && n[1] || ""; } return ` ` + V + e; } } var q = !1, $; { var Le = typeof WeakMap == "function" ? WeakMap : Map; $ = new Le(); } function ue(e, r) { if (!e || q) return ""; { var t = $.get(e); if (t !== void 0) return t; } var n; q = !0; var u = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var s; s = U.current, U.current = null, Ie(); try { if (r) { var o = function() { throw Error(); }; if (Object.defineProperty(o.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(o, []); } catch (w) { n = w; } Reflect.construct(e, [], o); } else { try { o.call(); } catch (w) { n = w; } e.call(o.prototype); } } else { try { throw Error(); } catch (w) { n = w; } e(); } } catch (w) { if (w && n && typeof w.stack == "string") { for (var a = w.stack.split(` `), m = n.stack.split(` `), c = a.length - 1, f = m.length - 1; c >= 1 && f >= 0 && a[c] !== m[f]; ) f--; for (; c >= 1 && f >= 0; c--, f--) if (a[c] !== m[f]) { if (c !== 1 || f !== 1) do if (c--, f--, f < 0 || a[c] !== m[f]) { var E = ` ` + a[c].replace(" at new ", " at "); return e.displayName && E.includes("<anonymous>") && (E = E.replace("<anonymous>", e.displayName)), typeof e == "function" && $.set(e, E), E; } while (c >= 1 && f >= 0); break; } } } finally { q = !1, U.current = s, We(), Error.prepareStackTrace = u; } var j = e ? e.displayName || e.name : "", Ee = j ? L(j) : ""; return typeof e == "function" && $.set(e, Ee), Ee; } function $e(e, r, t) { return ue(e, !1); } function Ye(e) { var r = e.prototype; return !!(r && r.isReactComponent); } function Y(e, r, t) { if (e == null) return ""; if (typeof e == "function") return ue(e, Ye(e)); if (typeof e == "string") return L(e); switch (e) { case O: return L("Suspense"); case p: return L("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case v: return $e(e.render); case R: return Y(e.type, r, t); case C: { var n = e, u = n._payload, s = n._init; try { return Y(s(u), r, t); } catch { } } } return ""; } var N = Object.prototype.hasOwnProperty, se = {}, le = x.ReactDebugCurrentFrame; function M(e) { if (e) { var r = e._owner, t = Y(e.type, e._source, r ? r.type : null); le.setExtraStackFrame(t); } else le.setExtraStackFrame(null); } function Ne(e, r, t, n, u) { { var s = Function.call.bind(N); for (var o in e) if (s(e, o)) { var a = void 0; try { if (typeof e[o] != "function") { var m = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw m.name = "Invariant Violation", m; } a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (c) { a = c; } a && !(a instanceof Error) && (M(u), y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), M(null)), a instanceof Error && !(a.message in se) && (se[a.message] = !0, M(u), y("Failed %s type: %s", t, a.message), M(null)); } } } var Me = Array.isArray; function B(e) { return Me(e); } function Ue(e) { { var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; return t; } } function Ve(e) { try { return ce(e), !1; } catch { return !0; } } function ce(e) { return "" + e; } function fe(e) { if (Ve(e)) return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ue(e)), ce(e); } var F = x.ReactCurrentOwner, qe = { key: !0, ref: !0, __self: !0, __source: !0 }, de, ve, G; G = {}; function Be(e) { if (N.call(e, "ref")) { var r = Object.getOwnPropertyDescriptor(e, "ref").get; if (r && r.isReactWarning) return !1; } return e.ref !== void 0; } function Ge(e) { if (N.call(e, "key")) { var r = Object.getOwnPropertyDescriptor(e, "key").get; if (r && r.isReactWarning) return !1; } return e.key !== void 0; } function Je(e, r) { if (typeof e.ref == "string" && F.current && r && F.current.stateNode !== r) { var t = S(F.current.type); G[t] || (y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', S(F.current.type), e.ref), G[t] = !0); } } function ze(e, r) { { var t = function() { de || (de = !0, y("%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://reactjs.org/link/special-props)", r)); }; t.isReactWarning = !0, Object.defineProperty(e, "key", { get: t, configurable: !0 }); } } function Ke(e, r) { { var t = function() { ve || (ve = !0, y("%s: `ref` 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://reactjs.org/link/special-props)", r)); }; t.isReactWarning = !0, Object.defineProperty(e, "ref", { get: t, configurable: !0 }); } } var He = function(e, r, t, n, u, s, o) { var a = { $$typeof: g, type: e, key: r, ref: t, props: o, _owner: s }; return a._store = {}, Object.defineProperty(a._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(a, "_self", { configurable: !1, enumerable: !1, writable: !1, value: n }), Object.defineProperty(a, "_source", { configurable: !1, enumerable: !1, writable: !1, value: u }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a; }; function Xe(e, r, t, n, u) { { var s, o = {}, a = null, m = null; t !== void 0 && (fe(t), a = "" + t), Ge(r) && (fe(r.key), a = "" + r.key), Be(r) && (m = r.ref, Je(r, u)); for (s in r) N.call(r, s) && !qe.hasOwnProperty(s) && (o[s] = r[s]); if (e && e.defaultProps) { var c = e.defaultProps; for (s in c) o[s] === void 0 && (o[s] = c[s]); } if (a || m) { var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; a && ze(o, f), m && Ke(o, f); } return He(e, a, m, u, n, F.current, o); } } var J = x.ReactCurrentOwner, pe = x.ReactDebugCurrentFrame; function k(e) { if (e) { var r = e._owner, t = Y(e.type, e._source, r ? r.type : null); pe.setExtraStackFrame(t); } else pe.setExtraStackFrame(null); } var z; z = !1; function K(e) { return typeof e == "object" && e !== null && e.$$typeof === g; } function ye() { { if (J.current) { var e = S(J.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function Ze(e) { { if (e !== void 0) { var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber; return ` Check your code at ` + r + ":" + t + "."; } return ""; } } var me = {}; function Qe(e) { { var r = ye(); if (!r) { var t = typeof e == "string" ? e : e.displayName || e.name; t && (r = ` Check the top-level render call using <` + t + ">."); } return r; } } function be(e, r) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var t = Qe(r); if (me[t]) return; me[t] = !0; var n = ""; e && e._owner && e._owner !== J.current && (n = " It was passed a child from " + S(e._owner.type) + "."), k(e), y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), k(null); } } function ge(e, r) { { if (typeof e != "object") return; if (B(e)) for (var t = 0; t < e.length; t++) { var n = e[t]; K(n) && be(n, r); } else if (K(e)) e._store && (e._store.validated = !0); else if (e) { var u = we(e); if (typeof u == "function" && u !== e.entries) for (var s = u.call(e), o; !(o = s.next()).done; ) K(o.value) && be(o.value, r); } } } function er(e) { { var r = e.type; if (r == null || typeof r == "string") return; var t; if (typeof r == "function") t = r.propTypes; else if (typeof r == "object" && (r.$$typeof === v || r.$$typeof === R)) t = r.propTypes; else return; if (t) { var n = S(r); Ne(t, e.props, "prop", n, e); } else if (r.PropTypes !== void 0 && !z) { z = !0; var u = S(r); y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown"); } typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function rr(e) { { for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { var n = r[t]; if (n !== "children" && n !== "key") { k(e), y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), k(null); break; } } e.ref !== null && (k(e), y("Invalid attribute `ref` supplied to `React.Fragment`."), k(null)); } } function he(e, r, t, n, u, s) { { var o = Fe(e); if (!o) { var a = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var m = Ze(u); m ? a += m : a += ye(); var c; e === null ? c = "null" : B(e) ? c = "array" : e !== void 0 && e.$$typeof === g ? (c = "<" + (S(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : c = typeof e, y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", c, a); } var f = Xe(e, r, t, u, s); if (f == null) return f; if (o) { var E = r.children; if (E !== void 0) if (n) if (B(E)) { for (var j = 0; j < E.length; j++) ge(E[j], e); Object.freeze && Object.freeze(E); } else y("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 ge(E, e); } return e === i ? rr(f) : er(f), f; } } function tr(e, r, t) { return he(e, r, t, !0); } function nr(e, r, t) { return he(e, r, t, !1); } var ar = nr, or = tr; I.Fragment = i, I.jsx = ar, I.jsxs = or; }()), I; } (function(l) { process.env.NODE_ENV === "production" ? l.exports = cr() : l.exports = fr(); })(Te); const dr = Te.exports.jsx, pr = ({ children: l, className: g, text: h, params: i, onClose: T, onLoad: d, onSuccess: _ }) => { const b = lr(), O = sr(null); function p() { if (!b) { O(); return; } const R = { onClose: T, onLoad: d, onSuccess: _, key: i.key, email: i.email, amount: i.amount * 100, currency_code: i.currencyCode || "NGN", transaction_ref: i.reference || null, payment_channels: i.paymentChannels || null, Customer_name: i.customerName || null, callback_url: i.callbackUrl || null, metadata: i.metaData || null, pass_charge: i.passCharge || !1 }, C = new squad(R); C.setup(), C.open(); } return /* @__PURE__ */ dr("button", { className: g, onClick: p, children: h || l }); }; export { pr as default };