UNPKG

synora-react-payment-modal-library

Version:

A comprehensive, production-ready React payment modal component library with multi-currency support, dark/light themes, and multiple payment methods.

1,429 lines (1,427 loc) 62.6 kB
import er, { useEffect as ce, useState as le, useCallback as Tr } from "react"; import { Row as kr, Col as Fr, Card as Pr, Typography as re, Form as p, InputNumber as V, Select as z, Input as Y, Steps as rr, Button as Ke, ConfigProvider as Ir, theme as We, Modal as Vr, message as ie } from "antd"; import { DollarSign as Or, CreditCard as $r, Building2 as Lr, FileText as qr, ArrowLeft as Mr, Check as Ur } from "lucide-react"; var Re = { exports: {} }, Z = {}; /** * @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 He; function zr() { if (He) return Z; He = 1; var u = er, R = Symbol.for("react.element"), S = Symbol.for("react.fragment"), h = Object.prototype.hasOwnProperty, l = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, _ = { key: !0, ref: !0, __self: !0, __source: !0 }; function o(a, d, A) { var i, b = {}, m = null, s = null; A !== void 0 && (m = "" + A), d.key !== void 0 && (m = "" + d.key), d.ref !== void 0 && (s = d.ref); for (i in d) h.call(d, i) && !_.hasOwnProperty(i) && (b[i] = d[i]); if (a && a.defaultProps) for (i in d = a.defaultProps, d) b[i] === void 0 && (b[i] = d[i]); return { $$typeof: R, type: a, key: m, ref: s, props: b, _owner: l.current }; } return Z.Fragment = S, Z.jsx = o, Z.jsxs = o, Z; } var ee = {}; /** * @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 Je; function Br() { return Je || (Je = 1, process.env.NODE_ENV !== "production" && function() { var u = er, R = Symbol.for("react.element"), S = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), _ = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), A = Symbol.for("react.suspense"), i = Symbol.for("react.suspense_list"), b = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), s = Symbol.for("react.offscreen"), f = Symbol.iterator, j = "@@iterator"; function y(e) { if (e === null || typeof e != "object") return null; var t = f && e[f] || e[j]; return typeof t == "function" ? t : null; } var N = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function C(e) { { for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), c = 1; c < t; c++) n[c - 1] = arguments[c]; M("error", e, n); } } function M(e, t, n) { { var c = N.ReactDebugCurrentFrame, v = c.getStackAddendum(); v !== "" && (t += "%s", n = n.concat([v])); var E = n.map(function(x) { return String(x); }); E.unshift("Warning: " + t), Function.prototype.apply.call(console[e], console, E); } } var J = !1, de = !1, fe = !1, me = !1, he = !1, te; te = Symbol.for("react.module.reference"); function P(e) { return !!(typeof e == "string" || typeof e == "function" || e === h || e === _ || he || e === l || e === A || e === i || me || e === s || J || de || fe || typeof e == "object" && e !== null && (e.$$typeof === m || e.$$typeof === b || e.$$typeof === o || e.$$typeof === a || e.$$typeof === d || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. e.$$typeof === te || e.getModuleId !== void 0)); } function k(e, t, n) { var c = e.displayName; if (c) return c; var v = t.displayName || t.name || ""; return v !== "" ? n + "(" + v + ")" : n; } function B(e) { return e.displayName || "Context"; } function F(e) { if (e == null) return null; if (typeof e.tag == "number" && C("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 h: return "Fragment"; case S: return "Portal"; case _: return "Profiler"; case l: return "StrictMode"; case A: return "Suspense"; case i: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case a: var t = e; return B(t) + ".Consumer"; case o: var n = e; return B(n._context) + ".Provider"; case d: return k(e, e.render, "ForwardRef"); case b: var c = e.displayName || null; return c !== null ? c : F(e.type) || "Memo"; case m: { var v = e, E = v._payload, x = v._init; try { return F(x(E)); } catch { return null; } } } return null; } var O = Object.assign, U = 0, Se, _e, Ae, Ne, we, De, Te; function ke() { } ke.__reactDisabledLog = !0; function nr() { { if (U === 0) { Se = console.log, _e = console.info, Ae = console.warn, Ne = console.error, we = console.group, De = console.groupCollapsed, Te = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: ke, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } U++; } } function sr() { { if (U--, U === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: O({}, e, { value: Se }), info: O({}, e, { value: _e }), warn: O({}, e, { value: Ae }), error: O({}, e, { value: Ne }), group: O({}, e, { value: we }), groupCollapsed: O({}, e, { value: De }), groupEnd: O({}, e, { value: Te }) }); } U < 0 && C("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var ge = N.ReactCurrentDispatcher, pe; function ae(e, t, n) { { if (pe === void 0) try { throw Error(); } catch (v) { var c = v.stack.trim().match(/\n( *(at )?)/); pe = c && c[1] || ""; } return ` ` + pe + e; } } var ye = !1, ne; { var or = typeof WeakMap == "function" ? WeakMap : Map; ne = new or(); } function Fe(e, t) { if (!e || ye) return ""; { var n = ne.get(e); if (n !== void 0) return n; } var c; ye = !0; var v = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var E; E = ge.current, ge.current = null, nr(); try { if (t) { var x = function() { throw Error(); }; if (Object.defineProperty(x.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(x, []); } catch ($) { c = $; } Reflect.construct(e, [], x); } else { try { x.call(); } catch ($) { c = $; } e.call(x.prototype); } } else { try { throw Error(); } catch ($) { c = $; } e(); } } catch ($) { if ($ && c && typeof $.stack == "string") { for (var g = $.stack.split(` `), I = c.stack.split(` `), w = g.length - 1, D = I.length - 1; w >= 1 && D >= 0 && g[w] !== I[D]; ) D--; for (; w >= 1 && D >= 0; w--, D--) if (g[w] !== I[D]) { if (w !== 1 || D !== 1) do if (w--, D--, D < 0 || g[w] !== I[D]) { var q = ` ` + g[w].replace(" at new ", " at "); return e.displayName && q.includes("<anonymous>") && (q = q.replace("<anonymous>", e.displayName)), typeof e == "function" && ne.set(e, q), q; } while (w >= 1 && D >= 0); break; } } } finally { ye = !1, ge.current = E, sr(), Error.prepareStackTrace = v; } var H = e ? e.displayName || e.name : "", G = H ? ae(H) : ""; return typeof e == "function" && ne.set(e, G), G; } function lr(e, t, n) { return Fe(e, !1); } function ir(e) { var t = e.prototype; return !!(t && t.isReactComponent); } function se(e, t, n) { if (e == null) return ""; if (typeof e == "function") return Fe(e, ir(e)); if (typeof e == "string") return ae(e); switch (e) { case A: return ae("Suspense"); case i: return ae("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case d: return lr(e.render); case b: return se(e.type, t, n); case m: { var c = e, v = c._payload, E = c._init; try { return se(E(v), t, n); } catch { } } } return ""; } var X = Object.prototype.hasOwnProperty, Pe = {}, Ie = N.ReactDebugCurrentFrame; function oe(e) { if (e) { var t = e._owner, n = se(e.type, e._source, t ? t.type : null); Ie.setExtraStackFrame(n); } else Ie.setExtraStackFrame(null); } function cr(e, t, n, c, v) { { var E = Function.call.bind(X); for (var x in e) if (E(e, x)) { var g = void 0; try { if (typeof e[x] != "function") { var I = Error((c || "React class") + ": " + n + " type `" + x + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[x] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw I.name = "Invariant Violation", I; } g = e[x](t, x, c, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (w) { g = w; } g && !(g instanceof Error) && (oe(v), C("%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).", c || "React class", n, x, typeof g), oe(null)), g instanceof Error && !(g.message in Pe) && (Pe[g.message] = !0, oe(v), C("Failed %s type: %s", n, g.message), oe(null)); } } } var ur = Array.isArray; function xe(e) { return ur(e); } function dr(e) { { var t = typeof Symbol == "function" && Symbol.toStringTag, n = t && e[Symbol.toStringTag] || e.constructor.name || "Object"; return n; } } function fr(e) { try { return Ve(e), !1; } catch { return !0; } } function Ve(e) { return "" + e; } function Oe(e) { if (fr(e)) return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", dr(e)), Ve(e); } var Q = N.ReactCurrentOwner, mr = { key: !0, ref: !0, __self: !0, __source: !0 }, $e, Le, ve; ve = {}; function hr(e) { if (X.call(e, "ref")) { var t = Object.getOwnPropertyDescriptor(e, "ref").get; if (t && t.isReactWarning) return !1; } return e.ref !== void 0; } function gr(e) { if (X.call(e, "key")) { var t = Object.getOwnPropertyDescriptor(e, "key").get; if (t && t.isReactWarning) return !1; } return e.key !== void 0; } function pr(e, t) { if (typeof e.ref == "string" && Q.current && t && Q.current.stateNode !== t) { var n = F(Q.current.type); ve[n] || (C('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', F(Q.current.type), e.ref), ve[n] = !0); } } function yr(e, t) { { var n = function() { $e || ($e = !0, C("%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)", t)); }; n.isReactWarning = !0, Object.defineProperty(e, "key", { get: n, configurable: !0 }); } } function xr(e, t) { { var n = function() { Le || (Le = !0, C("%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)", t)); }; n.isReactWarning = !0, Object.defineProperty(e, "ref", { get: n, configurable: !0 }); } } var vr = function(e, t, n, c, v, E, x) { var g = { // This tag allows us to uniquely identify this as a React Element $$typeof: R, // Built-in properties that belong on the element type: e, key: t, ref: n, props: x, // Record the component responsible for creating this element. _owner: E }; return g._store = {}, Object.defineProperty(g._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(g, "_self", { configurable: !1, enumerable: !1, writable: !1, value: c }), Object.defineProperty(g, "_source", { configurable: !1, enumerable: !1, writable: !1, value: v }), Object.freeze && (Object.freeze(g.props), Object.freeze(g)), g; }; function br(e, t, n, c, v) { { var E, x = {}, g = null, I = null; n !== void 0 && (Oe(n), g = "" + n), gr(t) && (Oe(t.key), g = "" + t.key), hr(t) && (I = t.ref, pr(t, v)); for (E in t) X.call(t, E) && !mr.hasOwnProperty(E) && (x[E] = t[E]); if (e && e.defaultProps) { var w = e.defaultProps; for (E in w) x[E] === void 0 && (x[E] = w[E]); } if (g || I) { var D = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; g && yr(x, D), I && xr(x, D); } return vr(e, g, I, v, c, Q.current, x); } } var be = N.ReactCurrentOwner, qe = N.ReactDebugCurrentFrame; function W(e) { if (e) { var t = e._owner, n = se(e.type, e._source, t ? t.type : null); qe.setExtraStackFrame(n); } else qe.setExtraStackFrame(null); } var je; je = !1; function Ee(e) { return typeof e == "object" && e !== null && e.$$typeof === R; } function Me() { { if (be.current) { var e = F(be.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function jr(e) { return ""; } var Ue = {}; function Er(e) { { var t = Me(); if (!t) { var n = typeof e == "string" ? e : e.displayName || e.name; n && (t = ` Check the top-level render call using <` + n + ">."); } return t; } } function ze(e, t) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var n = Er(t); if (Ue[n]) return; Ue[n] = !0; var c = ""; e && e._owner && e._owner !== be.current && (c = " It was passed a child from " + F(e._owner.type) + "."), W(e), C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, c), W(null); } } function Be(e, t) { { if (typeof e != "object") return; if (xe(e)) for (var n = 0; n < e.length; n++) { var c = e[n]; Ee(c) && ze(c, t); } else if (Ee(e)) e._store && (e._store.validated = !0); else if (e) { var v = y(e); if (typeof v == "function" && v !== e.entries) for (var E = v.call(e), x; !(x = E.next()).done; ) Ee(x.value) && ze(x.value, t); } } } function Cr(e) { { var t = e.type; if (t == null || typeof t == "string") return; var n; if (typeof t == "function") n = t.propTypes; else if (typeof t == "object" && (t.$$typeof === d || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. t.$$typeof === b)) n = t.propTypes; else return; if (n) { var c = F(t); cr(n, e.props, "prop", c, e); } else if (t.PropTypes !== void 0 && !je) { je = !0; var v = F(t); C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", v || "Unknown"); } typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Rr(e) { { for (var t = Object.keys(e.props), n = 0; n < t.length; n++) { var c = t[n]; if (c !== "children" && c !== "key") { W(e), C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", c), W(null); break; } } e.ref !== null && (W(e), C("Invalid attribute `ref` supplied to `React.Fragment`."), W(null)); } } var Ge = {}; function Ye(e, t, n, c, v, E) { { var x = P(e); if (!x) { var g = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (g += " 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 I = jr(); I ? g += I : g += Me(); var w; e === null ? w = "null" : xe(e) ? w = "array" : e !== void 0 && e.$$typeof === R ? (w = "<" + (F(e.type) || "Unknown") + " />", g = " Did you accidentally export a JSX literal instead of a component?") : w = typeof e, C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", w, g); } var D = br(e, t, n, v, E); if (D == null) return D; if (x) { var q = t.children; if (q !== void 0) if (c) if (xe(q)) { for (var H = 0; H < q.length; H++) Be(q[H], e); Object.freeze && Object.freeze(q); } else C("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 Be(q, e); } if (X.call(t, "key")) { var G = F(e), $ = Object.keys(t).filter(function(Dr) { return Dr !== "key"; }), Ce = $.length > 0 ? "{key: someKey, " + $.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Ge[G + Ce]) { var wr = $.length > 0 ? "{" + $.join(": ..., ") + ": ...}" : "{}"; C(`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} />`, Ce, G, wr, G), Ge[G + Ce] = !0; } } return e === h ? Rr(D) : Cr(D), D; } } function Sr(e, t, n) { return Ye(e, t, n, !0); } function _r(e, t, n) { return Ye(e, t, n, !1); } var Ar = _r, Nr = Sr; ee.Fragment = h, ee.jsx = Ar, ee.jsxs = Nr; }()), ee; } process.env.NODE_ENV === "production" ? Re.exports = zr() : Re.exports = Br(); var r = Re.exports, L = /* @__PURE__ */ ((u) => (u.CASH = "CASH", u.ATM = "ATM", u.BANK_TRANSFER = "BANK_TRANSFER", u.CHEQUE = "CHEQUE", u))(L || {}), tr = /* @__PURE__ */ ((u) => (u.VISA = "VISA", u.MASTERCARD = "MASTERCARD", u.AMEX = "AMEX", u.DISCOVER = "DISCOVER", u))(tr || {}), ar = /* @__PURE__ */ ((u) => (u.SAVINGS = "SAVINGS", u.CURRENT = "CURRENT", u.FIXED_DEPOSIT = "FIXED_DEPOSIT", u))(ar || {}), T = /* @__PURE__ */ ((u) => (u.LIGHT = "light", u.DARK = "dark", u))(T || {}); const { Title: Xe, Text: Gr } = re, Yr = [ { type: L.CASH, title: "Cash Payment", description: "Pay with physical cash", icon: Or, color: "#52c41a" }, { type: L.ATM, title: "ATM/Debit Card", description: "Pay using debit or credit card", icon: $r, color: "#1890ff" }, { type: L.BANK_TRANSFER, title: "Bank Transfer", description: "Direct bank account transfer", icon: Lr, color: "#722ed1" }, { type: L.CHEQUE, title: "Cheque Payment", description: "Pay using bank cheque", icon: qr, color: "#fa8c16" } ], Kr = ({ selectedType: u, onTypeSelect: R, theme: S = T.LIGHT }) => { const h = S.toLowerCase() === T.DARK.toLowerCase(); return /* @__PURE__ */ r.jsxs("div", { className: "payment-type-selector", children: [ /* @__PURE__ */ r.jsx(Xe, { level: 4, className: `mb-4 ${h ? "text-white" : "text-gray-900"}`, children: "Select Payment Method" }), /* @__PURE__ */ r.jsx(kr, { gutter: [16, 16], children: Yr.map(({ type: l, title: _, description: o, icon: a, color: d }) => /* @__PURE__ */ r.jsx(Fr, { xs: 24, sm: 12, children: /* @__PURE__ */ r.jsx( Pr, { hoverable: !0, className: `payment-type-card cursor-pointer transition-all duration-200 ${u === l ? `border-2 shadow-lg ${h ? "border-blue-400 bg-gray-800" : "border-blue-500 bg-white"}` : `border hover:shadow-md ${h ? "border-gray-600 bg-gray-800 hover:border-blue-400 hover:bg-gray-750" : "border-gray-200 bg-white hover:border-blue-300"}`}`, onClick: () => R(l), bodyStyle: { padding: "20px", backgroundColor: h ? u === l ? "#374151" : "#1f2937" : "#ffffff" }, children: /* @__PURE__ */ r.jsxs("div", { className: "flex items-center space-x-3", children: [ /* @__PURE__ */ r.jsx( "div", { className: "p-3 rounded-full", style: { backgroundColor: h ? `${d}30` : `${d}20`, border: h ? `1px solid ${d}60` : "none" }, children: /* @__PURE__ */ r.jsx( a, { size: 24, style: { color: d } } ) } ), /* @__PURE__ */ r.jsxs("div", { children: [ /* @__PURE__ */ r.jsx(Xe, { level: 5, className: `mb-1 ${h ? "text-white" : "text-gray-800"}`, children: _ }), /* @__PURE__ */ r.jsx(Gr, { className: `text-sm ${h ? "text-gray-300" : "text-gray-600"}`, children: o }) ] }) ] }) } ) }, l)) }) ] }); }, K = { USD: { code: "USD", locale: "en-US", symbol: "$", name: "US Dollar" }, LKR: { code: "LKR", locale: "en-LK", symbol: "Rs.", name: "Sri Lankan Rupee" }, EUR: { code: "EUR", locale: "en-EU", symbol: "€", name: "Euro" }, GBP: { code: "GBP", locale: "en-GB", symbol: "£", name: "British Pound" }, INR: { code: "INR", locale: "en-IN", symbol: "₹", name: "Indian Rupee" }, JPY: { code: "JPY", locale: "ja-JP", symbol: "¥", name: "Japanese Yen" }, AUD: { code: "AUD", locale: "en-AU", symbol: "A$", name: "Australian Dollar" }, CAD: { code: "CAD", locale: "en-CA", symbol: "C$", name: "Canadian Dollar" } }, Wr = (u, R = "USD") => { const S = K[R] || K.USD; return new Intl.NumberFormat(S.locale, { style: "currency", currency: S.code, minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(u); }, ct = (u, R = "USD") => Wr(u, R), ue = (u = "USD") => (K[u] || K.USD).symbol, ut = (u = "USD") => (K[u] || K.USD).name, dt = () => Object.values(K), { Title: Hr } = re, Jr = ({ initialValues: u, onChange: R, theme: S = T.LIGHT, amountToPay: h, currency: l = "USD" }) => { const [_] = p.useForm(), o = S.toLocaleLowerCase() === T.DARK.toLocaleLowerCase(), a = ue(l); ce(() => { if (h !== void 0) { const m = _.getFieldValue("giftVoucher") || 0, s = _.getFieldValue("loyaltyPoints") || 0, f = Math.max(0, h - m - s); _.setFieldsValue({ amount: h, finalAmount: f }); const y = { ..._.getFieldsValue(), amount: h, finalAmount: f }; y.amountTendered && (y.amountChange = Math.max(0, y.amountTendered - f)), R(y); } }, [h, _, R]); const d = (m, s) => { const f = h !== void 0 ? h : s.amount || 0, j = s.giftVoucher || 0, y = s.loyaltyPoints || 0, N = Math.max(0, f - j - y), C = s.amountTendered || 0, M = Math.max(0, C - N), J = { ...s, amount: f, finalAmount: N, amountChange: M }; _.setFieldsValue({ finalAmount: N, amountChange: M }), R(J); }, A = { backgroundColor: o ? "#374151" : "#ffffff", borderColor: o ? "#4b5563" : "#d9d9d9", color: o ? "#ffffff" : "#000000" }, i = { backgroundColor: o ? "#1f2937" : "#f5f5f5", borderColor: o ? "#374151" : "#d9d9d9", color: o ? "#9ca3af" : "#666666" }, b = h !== void 0 ? h : _.getFieldValue("amount") || 0; return /* @__PURE__ */ r.jsxs("div", { className: "cash-payment-form", children: [ /* @__PURE__ */ r.jsx(Hr, { level: 4, className: `mb-4 ${o ? "text-green-400" : "text-green-600"}`, children: "Cash Payment Details" }), /* @__PURE__ */ r.jsxs( p, { form: _, layout: "vertical", initialValues: u, onValuesChange: d, requiredMark: !1, children: [ /* @__PURE__ */ r.jsx( p.Item, { name: "amount", label: /* @__PURE__ */ r.jsxs("span", { className: o ? "text-gray-200" : "text-gray-700", children: [ "Total Amount ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Total amount is required" }, { type: "number", min: 0.01, message: "Total amount must be greater than 0" } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter total amount", prefix: a, precision: 2, min: 0, size: "large", disabled: h !== void 0, style: h !== void 0 ? i : A } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "giftVoucher", label: /* @__PURE__ */ r.jsx("span", { className: o ? "text-gray-200" : "text-gray-700", children: "Gift Voucher Amount" }), rules: [ { type: "number", min: 0, message: "Gift voucher amount must be 0 or greater" }, { validator: (m, s) => s && s > b ? Promise.reject(new Error(`Gift voucher cannot exceed total amount (${a}${b.toFixed(2)})`)) : Promise.resolve() } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter gift voucher amount (optional)", prefix: a, precision: 2, min: 0, max: b, size: "large", style: A } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "loyaltyPoints", label: /* @__PURE__ */ r.jsx("span", { className: o ? "text-gray-200" : "text-gray-700", children: "Loyalty Points Amount" }), rules: [ { type: "number", min: 0, message: "Loyalty points amount must be 0 or greater" }, { validator: (m, s) => { const f = _.getFieldValue("giftVoucher") || 0; return (s || 0) + f > b ? Promise.reject(new Error(`Total deductions cannot exceed amount (${a}${b.toFixed(2)})`)) : Promise.resolve(); } } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter loyalty points amount (optional)", prefix: a, precision: 2, min: 0, size: "large", style: A } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "finalAmount", label: /* @__PURE__ */ r.jsx("span", { className: o ? "text-gray-200" : "text-gray-700", children: "Final Amount (After Deductions)" }), children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Final amount after gift voucher deduction", prefix: a, precision: 2, min: 0, size: "large", readOnly: !0, style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "amountTendered", label: /* @__PURE__ */ r.jsxs("span", { className: o ? "text-gray-200" : "text-gray-700", children: [ "Amount Tendered ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Amount tendered is required" }, { type: "number", min: 0.01, message: "Amount tendered must be greater than 0" } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter amount received", prefix: a, precision: 2, min: 0, size: "large", style: A } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "amountChange", label: /* @__PURE__ */ r.jsx("span", { className: o ? "text-gray-200" : "text-gray-700", children: "Change Amount" }), children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Change will be calculated automatically", prefix: a, precision: 2, min: 0, size: "large", readOnly: !0, style: i } ) } ) ] } ) ] }); }, { Title: Xr } = re, { Option: Qe } = z, Qr = ({ banks: u, initialValues: R, onChange: S, theme: h = T.LIGHT, amountToPay: l, currency: _ = "USD" }) => { const [o] = p.useForm(), a = h.toLocaleLowerCase() === T.DARK.toLocaleLowerCase(), d = ue(_); ce(() => { if (l !== void 0) { const s = o.getFieldValue("giftVoucher") || 0, f = o.getFieldValue("loyaltyPoints") || 0, j = Math.max(0, l - s - f); o.setFieldsValue({ amount: l, finalAmount: j }); const N = { ...o.getFieldsValue(), amount: l, finalAmount: j }; S(N); } }, [l, o, S]); const A = (s, f) => { const j = l !== void 0 ? l : f.amount || 0, y = f.giftVoucher || 0, N = f.loyaltyPoints || 0, C = Math.max(0, j - y - N), M = { ...f, amount: j, finalAmount: C }; o.setFieldsValue({ finalAmount: C }), S(M); }, i = { backgroundColor: a ? "#374151" : "#ffffff", borderColor: a ? "#4b5563" : "#d9d9d9", color: a ? "#ffffff" : "#000000" }, b = { backgroundColor: a ? "#1f2937" : "#f5f5f5", borderColor: a ? "#374151" : "#d9d9d9", color: a ? "#9ca3af" : "#666666" }, m = l !== void 0 ? l : o.getFieldValue("amount") || 0; return /* @__PURE__ */ r.jsxs("div", { className: "atm-payment-form", children: [ /* @__PURE__ */ r.jsx(Xr, { level: 4, className: `mb-4 ${a ? "text-blue-400" : "text-blue-600"}`, children: "ATM/Card Payment Details" }), /* @__PURE__ */ r.jsxs( p, { form: o, layout: "vertical", initialValues: R, onValuesChange: A, requiredMark: !1, children: [ /* @__PURE__ */ r.jsx( p.Item, { name: "amount", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Total Amount ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Total amount is required" }, { type: "number", min: 0.01, message: "Total amount must be greater than 0" } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter total amount", prefix: d, precision: 2, min: 0, size: "large", disabled: l !== void 0, style: l !== void 0 ? b : i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "giftVoucher", label: /* @__PURE__ */ r.jsx("span", { className: a ? "text-gray-200" : "text-gray-700", children: "Gift Voucher Amount" }), rules: [ { type: "number", min: 0, message: "Gift voucher amount must be 0 or greater" }, { validator: (s, f) => f && f > m ? Promise.reject(new Error(`Gift voucher cannot exceed total amount (${d}${m.toFixed(2)})`)) : Promise.resolve() } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter gift voucher amount (optional)", prefix: d, precision: 2, min: 0, max: m, size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "loyaltyPoints", label: /* @__PURE__ */ r.jsx("span", { className: a ? "text-gray-200" : "text-gray-700", children: "Loyalty Points Amount" }), rules: [ { type: "number", min: 0, message: "Loyalty points amount must be 0 or greater" }, { validator: (s, f) => { const j = o.getFieldValue("giftVoucher") || 0; return (f || 0) + j > m ? Promise.reject(new Error(`Total deductions cannot exceed amount (${d}${m.toFixed(2)})`)) : Promise.resolve(); } } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter loyalty points amount (optional)", prefix: d, precision: 2, min: 0, size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "finalAmount", label: /* @__PURE__ */ r.jsx("span", { className: a ? "text-gray-200" : "text-gray-700", children: "Final Amount (After Deductions)" }), children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Final amount after gift voucher deduction", prefix: d, precision: 2, min: 0, size: "large", readOnly: !0, style: b } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "cardType", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Card Type ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Card type is required" }], children: /* @__PURE__ */ r.jsx( z, { placeholder: "Select card type", size: "large", style: i, dropdownStyle: { backgroundColor: a ? "#374151" : "#ffffff", color: a ? "#ffffff" : "#000000" }, children: Object.values(tr).map((s) => /* @__PURE__ */ r.jsx(Qe, { value: s, children: s }, s)) } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "last_4_digit", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Last 4 Digits of Card ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Last 4 digits are required" }, { pattern: /^\d{4}$/, message: "Must be exactly 4 digits" } ], children: /* @__PURE__ */ r.jsx( Y, { placeholder: "Enter last 4 digits", maxLength: 4, size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "holder", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Card Holder Name ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Card holder name is required" }, { min: 2, message: "Name must be at least 2 characters long" } ], children: /* @__PURE__ */ r.jsx( Y, { placeholder: "Enter card holder name", size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "bank", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Issuing Bank ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Issuing bank is required" }], children: /* @__PURE__ */ r.jsx( z, { placeholder: "Select issuing bank", size: "large", style: i, dropdownStyle: { backgroundColor: a ? "#374151" : "#ffffff", color: a ? "#ffffff" : "#000000" }, children: u.map((s) => /* @__PURE__ */ r.jsx(Qe, { value: s, children: s }, s)) } ) } ) ] } ) ] }); }, { Title: Zr } = re, { Option: Ze } = z, { TextArea: et } = Y, rt = ({ banks: u, initialValues: R, onChange: S, theme: h = T.LIGHT, amountToPay: l, currency: _ = "USD" }) => { const [o] = p.useForm(), a = h.toLocaleLowerCase() === T.DARK.toLocaleLowerCase(), d = ue(_); ce(() => { if (l !== void 0) { o.setFieldsValue({ amount: l }); const s = { ...o.getFieldsValue(), amount: l }; S(s); } }, [l, o, S]); const A = (m, s) => { const f = l !== void 0 ? l : s.amount || 0, j = { ...s, amount: f }; S(j); }, i = { backgroundColor: a ? "#374151" : "#ffffff", borderColor: a ? "#4b5563" : "#d9d9d9", color: a ? "#ffffff" : "#000000" }, b = { backgroundColor: a ? "#1f2937" : "#f5f5f5", borderColor: a ? "#374151" : "#d9d9d9", color: a ? "#9ca3af" : "#666666" }; return /* @__PURE__ */ r.jsxs("div", { className: "cheque-payment-form", children: [ /* @__PURE__ */ r.jsx(Zr, { level: 4, className: `mb-4 ${a ? "text-orange-400" : "text-orange-600"}`, children: "Cheque Payment Details" }), /* @__PURE__ */ r.jsxs( p, { form: o, layout: "vertical", initialValues: R, onValuesChange: A, requiredMark: !1, children: [ /* @__PURE__ */ r.jsx( p.Item, { name: "amount", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Total Amount ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Total amount is required" }, { type: "number", min: 0.01, message: "Total amount must be greater than 0" } ], children: /* @__PURE__ */ r.jsx( V, { className: "w-full", placeholder: "Enter total amount", prefix: d, precision: 2, min: 0, size: "large", disabled: l !== void 0, style: l !== void 0 ? b : i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "acc_type", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Account Type ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Account type is required" }], children: /* @__PURE__ */ r.jsx( z, { placeholder: "Select account type", size: "large", style: i, dropdownStyle: { backgroundColor: a ? "#374151" : "#ffffff", color: a ? "#ffffff" : "#000000" }, children: Object.values(ar).map((m) => /* @__PURE__ */ r.jsx(Ze, { value: m, children: m.replace("_", " ") }, m)) } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "cheq_no", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Cheque Number ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [ { required: !0, message: "Cheque number is required" }, { min: 6, message: "Cheque number must be at least 6 characters long" } ], children: /* @__PURE__ */ r.jsx( Y, { placeholder: "Enter cheque number", size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "bank", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Bank ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Bank selection is required" }], children: /* @__PURE__ */ r.jsx( z, { placeholder: "Select bank", size: "large", style: i, dropdownStyle: { backgroundColor: a ? "#374151" : "#ffffff", color: a ? "#ffffff" : "#000000" }, children: u.map((m) => /* @__PURE__ */ r.jsx(Ze, { value: m, children: m }, m)) } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "refNo", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Reference Number ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Reference number is required" }], children: /* @__PURE__ */ r.jsx( Y, { placeholder: "Enter reference number", size: "large", style: i } ) } ), /* @__PURE__ */ r.jsx( p.Item, { name: "remarks", label: /* @__PURE__ */ r.jsxs("span", { className: a ? "text-gray-200" : "text-gray-700", children: [ "Remarks ", /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "*" }) ] }), rules: [{ required: !0, message: "Remarks are required" }], children: /* @__PURE__ */ r.jsx( et, { placeholder: "Enter any additional remarks", rows: 3, size: "large", style: i } ) } ) ] } ) ] }); }, { Title: tt } = re, { Option: at } = z, nt = ({ banks: u, initialValues: R, onChange: S, theme: h = T.LIGHT, amountToPay: l, currency: _ = "USD" }) => { const [o] = p.useForm(), a = h.toLocaleLowerCase() === T.DARK.toLocaleLowerCase(), d = ue(_); ce(() => { if (l !== void 0) { const s = o.getFieldValue("giftVoucher") || 0, f = o.getFieldValue("loyaltyPoints") || 0, j = Math.max(0, l - s - f); o.setFieldsValue({ amount: l, finalAmount: j }); const N = { ...o.getFieldsValue(), amount: l, finalAmount: j }; S(N); } }, [l, o, S]); const A = (s, f) => { const j = l !== void 0 ? l : f.amount || 0, y = f.giftVoucher || 0, N = f.loyaltyPoints || 0, C = Math.max(0, j - y - N), M = { ...f, amount: j, finalAmount: C }; o.setFieldsValue({ finalAmount: C }), S(M); }, i = { backgroundColor: a ? "#374151