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.

32 lines (29 loc) 37.1 kB
(function(w,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react"),require("antd"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","antd","lucide-react"],P):(w=typeof globalThis<"u"?globalThis:w||self,P(w.SynoraReactPaymentModal={},w.React,w.antd,w.LucideReact))})(this,function(w,P,a,K){"use strict";var le={exports:{}},J={};/** * @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 Ee;function Xe(){if(Ee)return J;Ee=1;var f=P,S=Symbol.for("react.element"),R=Symbol.for("react.fragment"),h=Object.prototype.hasOwnProperty,i=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,N={key:!0,ref:!0,__self:!0,__source:!0};function l(n,d,_){var c,v={},p=null,o=null;_!==void 0&&(p=""+_),d.key!==void 0&&(p=""+d.key),d.ref!==void 0&&(o=d.ref);for(c in d)h.call(d,c)&&!N.hasOwnProperty(c)&&(v[c]=d[c]);if(n&&n.defaultProps)for(c in d=n.defaultProps,d)v[c]===void 0&&(v[c]=d[c]);return{$$typeof:S,type:n,key:p,ref:o,props:v,_owner:i.current}}return J.Fragment=R,J.jsx=l,J.jsxs=l,J}var X={};/** * @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 Se;function Qe(){return Se||(Se=1,process.env.NODE_ENV!=="production"&&function(){var f=P,S=Symbol.for("react.element"),R=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),n=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),o=Symbol.for("react.offscreen"),m=Symbol.iterator,j="@@iterator";function y(e){if(e===null||typeof e!="object")return null;var t=m&&e[m]||e[j];return typeof t=="function"?t:null}var A=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(e){{for(var t=arguments.length,s=new Array(t>1?t-1:0),u=1;u<t;u++)s[u-1]=arguments[u];$("error",e,s)}}function $(e,t,s){{var u=A.ReactDebugCurrentFrame,b=u.getStackAddendum();b!==""&&(t+="%s",s=s.concat([b]));var C=s.map(function(x){return String(x)});C.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,C)}}var Z=!1,ue=!1,fe=!1,de=!1,me=!1,te;te=Symbol.for("react.module.reference");function V(e){return!!(typeof e=="string"||typeof e=="function"||e===h||e===N||me||e===i||e===_||e===c||de||e===o||Z||ue||fe||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===v||e.$$typeof===l||e.$$typeof===n||e.$$typeof===d||e.$$typeof===te||e.getModuleId!==void 0))}function k(e,t,s){var u=e.displayName;if(u)return u;var b=t.displayName||t.name||"";return b!==""?s+"("+b+")":s}function G(e){return e.displayName||"Context"}function I(e){if(e==null)return null;if(typeof e.tag=="number"&&E("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 R:return"Portal";case N:return"Profiler";case i:return"StrictMode";case _:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case n:var t=e;return G(t)+".Consumer";case l:var s=e;return G(s._context)+".Provider";case d:return k(e,e.render,"ForwardRef");case v:var u=e.displayName||null;return u!==null?u:I(e.type)||"Memo";case p:{var b=e,C=b._payload,x=b._init;try{return I(x(C))}catch{return null}}}return null}var q=Object.assign,z=0,Fe,Te,we,De,ke,Ie,Pe;function Ve(){}Ve.__reactDisabledLog=!0;function yr(){{if(z===0){Fe=console.log,Te=console.info,we=console.warn,De=console.error,ke=console.group,Ie=console.groupCollapsed,Pe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}z++}}function xr(){{if(z--,z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:q({},e,{value:Fe}),info:q({},e,{value:Te}),warn:q({},e,{value:we}),error:q({},e,{value:De}),group:q({},e,{value:ke}),groupCollapsed:q({},e,{value:Ie}),groupEnd:q({},e,{value:Pe})})}z<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pe=A.ReactCurrentDispatcher,he;function ae(e,t,s){{if(he===void 0)try{throw Error()}catch(b){var u=b.stack.trim().match(/\n( *(at )?)/);he=u&&u[1]||""}return` `+he+e}}var ge=!1,ne;{var br=typeof WeakMap=="function"?WeakMap:Map;ne=new br}function Oe(e,t){if(!e||ge)return"";{var s=ne.get(e);if(s!==void 0)return s}var u;ge=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=pe.current,pe.current=null,yr();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(M){u=M}Reflect.construct(e,[],x)}else{try{x.call()}catch(M){u=M}e.call(x.prototype)}}else{try{throw Error()}catch(M){u=M}e()}}catch(M){if(M&&u&&typeof M.stack=="string"){for(var g=M.stack.split(` `),O=u.stack.split(` `),F=g.length-1,T=O.length-1;F>=1&&T>=0&&g[F]!==O[T];)T--;for(;F>=1&&T>=0;F--,T--)if(g[F]!==O[T]){if(F!==1||T!==1)do if(F--,T--,T<0||g[F]!==O[T]){var U=` `+g[F].replace(" at new "," at ");return e.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",e.displayName)),typeof e=="function"&&ne.set(e,U),U}while(F>=1&&T>=0);break}}}finally{ge=!1,pe.current=C,xr(),Error.prepareStackTrace=b}var H=e?e.displayName||e.name:"",Y=H?ae(H):"";return typeof e=="function"&&ne.set(e,Y),Y}function vr(e,t,s){return Oe(e,!1)}function jr(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function se(e,t,s){if(e==null)return"";if(typeof e=="function")return Oe(e,jr(e));if(typeof e=="string")return ae(e);switch(e){case _:return ae("Suspense");case c:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return vr(e.render);case v:return se(e.type,t,s);case p:{var u=e,b=u._payload,C=u._init;try{return se(C(b),t,s)}catch{}}}return""}var ee=Object.prototype.hasOwnProperty,Le={},qe=A.ReactDebugCurrentFrame;function oe(e){if(e){var t=e._owner,s=se(e.type,e._source,t?t.type:null);qe.setExtraStackFrame(s)}else qe.setExtraStackFrame(null)}function Cr(e,t,s,u,b){{var C=Function.call.bind(ee);for(var x in e)if(C(e,x)){var g=void 0;try{if(typeof e[x]!="function"){var O=Error((u||"React class")+": "+s+" 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 O.name="Invariant Violation",O}g=e[x](t,x,u,s,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(F){g=F}g&&!(g instanceof Error)&&(oe(b),E("%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).",u||"React class",s,x,typeof g),oe(null)),g instanceof Error&&!(g.message in Le)&&(Le[g.message]=!0,oe(b),E("Failed %s type: %s",s,g.message),oe(null))}}}var Er=Array.isArray;function ye(e){return Er(e)}function Sr(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,s=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s}}function Rr(e){try{return Me(e),!1}catch{return!0}}function Me(e){return""+e}function Ue(e){if(Rr(e))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Sr(e)),Me(e)}var re=A.ReactCurrentOwner,Nr={key:!0,ref:!0,__self:!0,__source:!0},$e,ze,xe;xe={};function _r(e){if(ee.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Ar(e){if(ee.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Fr(e,t){if(typeof e.ref=="string"&&re.current&&t&&re.current.stateNode!==t){var s=I(re.current.type);xe[s]||(E('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',I(re.current.type),e.ref),xe[s]=!0)}}function Tr(e,t){{var s=function(){$e||($e=!0,E("%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))};s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}}function wr(e,t){{var s=function(){ze||(ze=!0,E("%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))};s.isReactWarning=!0,Object.defineProperty(e,"ref",{get:s,configurable:!0})}}var Dr=function(e,t,s,u,b,C,x){var g={$$typeof:S,type:e,key:t,ref:s,props:x,_owner:C};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:u}),Object.defineProperty(g,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g};function kr(e,t,s,u,b){{var C,x={},g=null,O=null;s!==void 0&&(Ue(s),g=""+s),Ar(t)&&(Ue(t.key),g=""+t.key),_r(t)&&(O=t.ref,Fr(t,b));for(C in t)ee.call(t,C)&&!Nr.hasOwnProperty(C)&&(x[C]=t[C]);if(e&&e.defaultProps){var F=e.defaultProps;for(C in F)x[C]===void 0&&(x[C]=F[C])}if(g||O){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;g&&Tr(x,T),O&&wr(x,T)}return Dr(e,g,O,b,u,re.current,x)}}var be=A.ReactCurrentOwner,Be=A.ReactDebugCurrentFrame;function W(e){if(e){var t=e._owner,s=se(e.type,e._source,t?t.type:null);Be.setExtraStackFrame(s)}else Be.setExtraStackFrame(null)}var ve;ve=!1;function je(e){return typeof e=="object"&&e!==null&&e.$$typeof===S}function Ge(){{if(be.current){var e=I(be.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function Ir(e){return""}var Ye={};function Pr(e){{var t=Ge();if(!t){var s=typeof e=="string"?e:e.displayName||e.name;s&&(t=` Check the top-level render call using <`+s+">.")}return t}}function Ke(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=Pr(t);if(Ye[s])return;Ye[s]=!0;var u="";e&&e._owner&&e._owner!==be.current&&(u=" It was passed a child from "+I(e._owner.type)+"."),W(e),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,u),W(null)}}function We(e,t){{if(typeof e!="object")return;if(ye(e))for(var s=0;s<e.length;s++){var u=e[s];je(u)&&Ke(u,t)}else if(je(e))e._store&&(e._store.validated=!0);else if(e){var b=y(e);if(typeof b=="function"&&b!==e.entries)for(var C=b.call(e),x;!(x=C.next()).done;)je(x.value)&&Ke(x.value,t)}}}function Vr(e){{var t=e.type;if(t==null||typeof t=="string")return;var s;if(typeof t=="function")s=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===d||t.$$typeof===v))s=t.propTypes;else return;if(s){var u=I(t);Cr(s,e.props,"prop",u,e)}else if(t.PropTypes!==void 0&&!ve){ve=!0;var b=I(t);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Or(e){{for(var t=Object.keys(e.props),s=0;s<t.length;s++){var u=t[s];if(u!=="children"&&u!=="key"){W(e),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),W(null);break}}e.ref!==null&&(W(e),E("Invalid attribute `ref` supplied to `React.Fragment`."),W(null))}}var He={};function Je(e,t,s,u,b,C){{var x=V(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 O=Ir();O?g+=O:g+=Ge();var F;e===null?F="null":ye(e)?F="array":e!==void 0&&e.$$typeof===S?(F="<"+(I(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):F=typeof e,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,g)}var T=kr(e,t,s,b,C);if(T==null)return T;if(x){var U=t.children;if(U!==void 0)if(u)if(ye(U)){for(var H=0;H<U.length;H++)We(U[H],e);Object.freeze&&Object.freeze(U)}else E("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 We(U,e)}if(ee.call(t,"key")){var Y=I(e),M=Object.keys(t).filter(function(zr){return zr!=="key"}),Ce=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!He[Y+Ce]){var $r=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";E(`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,Y,$r,Y),He[Y+Ce]=!0}}return e===h?Or(T):Vr(T),T}}function Lr(e,t,s){return Je(e,t,s,!0)}function qr(e,t,s){return Je(e,t,s,!1)}var Mr=qr,Ur=Lr;X.Fragment=h,X.jsx=Mr,X.jsxs=Ur}()),X}process.env.NODE_ENV==="production"?le.exports=Xe():le.exports=Qe();var r=le.exports,L=(f=>(f.CASH="CASH",f.ATM="ATM",f.BANK_TRANSFER="BANK_TRANSFER",f.CHEQUE="CHEQUE",f))(L||{}),ie=(f=>(f.VISA="VISA",f.MASTERCARD="MASTERCARD",f.AMEX="AMEX",f.DISCOVER="DISCOVER",f))(ie||{}),ce=(f=>(f.SAVINGS="SAVINGS",f.CURRENT="CURRENT",f.FIXED_DEPOSIT="FIXED_DEPOSIT",f))(ce||{}),D=(f=>(f.LIGHT="light",f.DARK="dark",f))(D||{});const{Title:Re,Text:Ze}=a.Typography,er=[{type:L.CASH,title:"Cash Payment",description:"Pay with physical cash",icon:K.DollarSign,color:"#52c41a"},{type:L.ATM,title:"ATM/Debit Card",description:"Pay using debit or credit card",icon:K.CreditCard,color:"#1890ff"},{type:L.BANK_TRANSFER,title:"Bank Transfer",description:"Direct bank account transfer",icon:K.Building2,color:"#722ed1"},{type:L.CHEQUE,title:"Cheque Payment",description:"Pay using bank cheque",icon:K.FileText,color:"#fa8c16"}],rr=({selectedType:f,onTypeSelect:S,theme:R=D.LIGHT})=>{const h=R.toLowerCase()===D.DARK.toLowerCase();return r.jsxs("div",{className:"payment-type-selector",children:[r.jsx(Re,{level:4,className:`mb-4 ${h?"text-white":"text-gray-900"}`,children:"Select Payment Method"}),r.jsx(a.Row,{gutter:[16,16],children:er.map(({type:i,title:N,description:l,icon:n,color:d})=>r.jsx(a.Col,{xs:24,sm:12,children:r.jsx(a.Card,{hoverable:!0,className:`payment-type-card cursor-pointer transition-all duration-200 ${f===i?`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:()=>S(i),bodyStyle:{padding:"20px",backgroundColor:h?f===i?"#374151":"#1f2937":"#ffffff"},children:r.jsxs("div",{className:"flex items-center space-x-3",children:[r.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:h?`${d}30`:`${d}20`,border:h?`1px solid ${d}60`:"none"},children:r.jsx(n,{size:24,style:{color:d}})}),r.jsxs("div",{children:[r.jsx(Re,{level:5,className:`mb-1 ${h?"text-white":"text-gray-800"}`,children:N}),r.jsx(Ze,{className:`text-sm ${h?"text-gray-300":"text-gray-600"}`,children:l})]})]})})},i))})]})},B={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"}},Ne=(f,S="USD")=>{const R=B[S]||B.USD;return new Intl.NumberFormat(R.locale,{style:"currency",currency:R.code,minimumFractionDigits:2,maximumFractionDigits:2}).format(f)},tr=(f,S="USD")=>Ne(f,S),Q=(f="USD")=>(B[f]||B.USD).symbol,ar=(f="USD")=>(B[f]||B.USD).name,nr=()=>Object.values(B),{Title:sr}=a.Typography,or=({initialValues:f,onChange:S,theme:R=D.LIGHT,amountToPay:h,currency:i="USD"})=>{const[N]=a.Form.useForm(),l=R.toLocaleLowerCase()===D.DARK.toLocaleLowerCase(),n=Q(i);P.useEffect(()=>{if(h!==void 0){const p=N.getFieldValue("giftVoucher")||0,o=N.getFieldValue("loyaltyPoints")||0,m=Math.max(0,h-p-o);N.setFieldsValue({amount:h,finalAmount:m});const y={...N.getFieldsValue(),amount:h,finalAmount:m};y.amountTendered&&(y.amountChange=Math.max(0,y.amountTendered-m)),S(y)}},[h,N,S]);const d=(p,o)=>{const m=h!==void 0?h:o.amount||0,j=o.giftVoucher||0,y=o.loyaltyPoints||0,A=Math.max(0,m-j-y),E=o.amountTendered||0,$=Math.max(0,E-A),Z={...o,amount:m,finalAmount:A,amountChange:$};N.setFieldsValue({finalAmount:A,amountChange:$}),S(Z)},_={backgroundColor:l?"#374151":"#ffffff",borderColor:l?"#4b5563":"#d9d9d9",color:l?"#ffffff":"#000000"},c={backgroundColor:l?"#1f2937":"#f5f5f5",borderColor:l?"#374151":"#d9d9d9",color:l?"#9ca3af":"#666666"},v=h!==void 0?h:N.getFieldValue("amount")||0;return r.jsxs("div",{className:"cash-payment-form",children:[r.jsx(sr,{level:4,className:`mb-4 ${l?"text-green-400":"text-green-600"}`,children:"Cash Payment Details"}),r.jsxs(a.Form,{form:N,layout:"vertical",initialValues:f,onValuesChange:d,requiredMark:!1,children:[r.jsx(a.Form.Item,{name:"amount",label:r.jsxs("span",{className:l?"text-gray-200":"text-gray-700",children:["Total Amount ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Total amount is required"},{type:"number",min:.01,message:"Total amount must be greater than 0"}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter total amount",prefix:n,precision:2,min:0,size:"large",disabled:h!==void 0,style:h!==void 0?c:_})}),r.jsx(a.Form.Item,{name:"giftVoucher",label:r.jsx("span",{className:l?"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:(p,o)=>o&&o>v?Promise.reject(new Error(`Gift voucher cannot exceed total amount (${n}${v.toFixed(2)})`)):Promise.resolve()}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter gift voucher amount (optional)",prefix:n,precision:2,min:0,max:v,size:"large",style:_})}),r.jsx(a.Form.Item,{name:"loyaltyPoints",label:r.jsx("span",{className:l?"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:(p,o)=>{const m=N.getFieldValue("giftVoucher")||0;return(o||0)+m>v?Promise.reject(new Error(`Total deductions cannot exceed amount (${n}${v.toFixed(2)})`)):Promise.resolve()}}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter loyalty points amount (optional)",prefix:n,precision:2,min:0,size:"large",style:_})}),r.jsx(a.Form.Item,{name:"finalAmount",label:r.jsx("span",{className:l?"text-gray-200":"text-gray-700",children:"Final Amount (After Deductions)"}),children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Final amount after gift voucher deduction",prefix:n,precision:2,min:0,size:"large",readOnly:!0,style:c})}),r.jsx(a.Form.Item,{name:"amountTendered",label:r.jsxs("span",{className:l?"text-gray-200":"text-gray-700",children:["Amount Tendered ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Amount tendered is required"},{type:"number",min:.01,message:"Amount tendered must be greater than 0"}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter amount received",prefix:n,precision:2,min:0,size:"large",style:_})}),r.jsx(a.Form.Item,{name:"amountChange",label:r.jsx("span",{className:l?"text-gray-200":"text-gray-700",children:"Change Amount"}),children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Change will be calculated automatically",prefix:n,precision:2,min:0,size:"large",readOnly:!0,style:c})})]})]})},{Title:lr}=a.Typography,{Option:_e}=a.Select,ir=({banks:f,initialValues:S,onChange:R,theme:h=D.LIGHT,amountToPay:i,currency:N="USD"})=>{const[l]=a.Form.useForm(),n=h.toLocaleLowerCase()===D.DARK.toLocaleLowerCase(),d=Q(N);P.useEffect(()=>{if(i!==void 0){const o=l.getFieldValue("giftVoucher")||0,m=l.getFieldValue("loyaltyPoints")||0,j=Math.max(0,i-o-m);l.setFieldsValue({amount:i,finalAmount:j});const A={...l.getFieldsValue(),amount:i,finalAmount:j};R(A)}},[i,l,R]);const _=(o,m)=>{const j=i!==void 0?i:m.amount||0,y=m.giftVoucher||0,A=m.loyaltyPoints||0,E=Math.max(0,j-y-A),$={...m,amount:j,finalAmount:E};l.setFieldsValue({finalAmount:E}),R($)},c={backgroundColor:n?"#374151":"#ffffff",borderColor:n?"#4b5563":"#d9d9d9",color:n?"#ffffff":"#000000"},v={backgroundColor:n?"#1f2937":"#f5f5f5",borderColor:n?"#374151":"#d9d9d9",color:n?"#9ca3af":"#666666"},p=i!==void 0?i:l.getFieldValue("amount")||0;return r.jsxs("div",{className:"atm-payment-form",children:[r.jsx(lr,{level:4,className:`mb-4 ${n?"text-blue-400":"text-blue-600"}`,children:"ATM/Card Payment Details"}),r.jsxs(a.Form,{form:l,layout:"vertical",initialValues:S,onValuesChange:_,requiredMark:!1,children:[r.jsx(a.Form.Item,{name:"amount",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Total Amount ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Total amount is required"},{type:"number",min:.01,message:"Total amount must be greater than 0"}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter total amount",prefix:d,precision:2,min:0,size:"large",disabled:i!==void 0,style:i!==void 0?v:c})}),r.jsx(a.Form.Item,{name:"giftVoucher",label:r.jsx("span",{className:n?"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:(o,m)=>m&&m>p?Promise.reject(new Error(`Gift voucher cannot exceed total amount (${d}${p.toFixed(2)})`)):Promise.resolve()}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter gift voucher amount (optional)",prefix:d,precision:2,min:0,max:p,size:"large",style:c})}),r.jsx(a.Form.Item,{name:"loyaltyPoints",label:r.jsx("span",{className:n?"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:(o,m)=>{const j=l.getFieldValue("giftVoucher")||0;return(m||0)+j>p?Promise.reject(new Error(`Total deductions cannot exceed amount (${d}${p.toFixed(2)})`)):Promise.resolve()}}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter loyalty points amount (optional)",prefix:d,precision:2,min:0,size:"large",style:c})}),r.jsx(a.Form.Item,{name:"finalAmount",label:r.jsx("span",{className:n?"text-gray-200":"text-gray-700",children:"Final Amount (After Deductions)"}),children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Final amount after gift voucher deduction",prefix:d,precision:2,min:0,size:"large",readOnly:!0,style:v})}),r.jsx(a.Form.Item,{name:"cardType",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Card Type ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Card type is required"}],children:r.jsx(a.Select,{placeholder:"Select card type",size:"large",style:c,dropdownStyle:{backgroundColor:n?"#374151":"#ffffff",color:n?"#ffffff":"#000000"},children:Object.values(ie).map(o=>r.jsx(_e,{value:o,children:o},o))})}),r.jsx(a.Form.Item,{name:"last_4_digit",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Last 4 Digits of Card ",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:r.jsx(a.Input,{placeholder:"Enter last 4 digits",maxLength:4,size:"large",style:c})}),r.jsx(a.Form.Item,{name:"holder",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Card Holder Name ",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:r.jsx(a.Input,{placeholder:"Enter card holder name",size:"large",style:c})}),r.jsx(a.Form.Item,{name:"bank",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Issuing Bank ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Issuing bank is required"}],children:r.jsx(a.Select,{placeholder:"Select issuing bank",size:"large",style:c,dropdownStyle:{backgroundColor:n?"#374151":"#ffffff",color:n?"#ffffff":"#000000"},children:f.map(o=>r.jsx(_e,{value:o,children:o},o))})})]})]})},{Title:cr}=a.Typography,{Option:Ae}=a.Select,{TextArea:ur}=a.Input,fr=({banks:f,initialValues:S,onChange:R,theme:h=D.LIGHT,amountToPay:i,currency:N="USD"})=>{const[l]=a.Form.useForm(),n=h.toLocaleLowerCase()===D.DARK.toLocaleLowerCase(),d=Q(N);P.useEffect(()=>{if(i!==void 0){l.setFieldsValue({amount:i});const o={...l.getFieldsValue(),amount:i};R(o)}},[i,l,R]);const _=(p,o)=>{const m=i!==void 0?i:o.amount||0,j={...o,amount:m};R(j)},c={backgroundColor:n?"#374151":"#ffffff",borderColor:n?"#4b5563":"#d9d9d9",color:n?"#ffffff":"#000000"},v={backgroundColor:n?"#1f2937":"#f5f5f5",borderColor:n?"#374151":"#d9d9d9",color:n?"#9ca3af":"#666666"};return r.jsxs("div",{className:"cheque-payment-form",children:[r.jsx(cr,{level:4,className:`mb-4 ${n?"text-orange-400":"text-orange-600"}`,children:"Cheque Payment Details"}),r.jsxs(a.Form,{form:l,layout:"vertical",initialValues:S,onValuesChange:_,requiredMark:!1,children:[r.jsx(a.Form.Item,{name:"amount",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Total Amount ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Total amount is required"},{type:"number",min:.01,message:"Total amount must be greater than 0"}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter total amount",prefix:d,precision:2,min:0,size:"large",disabled:i!==void 0,style:i!==void 0?v:c})}),r.jsx(a.Form.Item,{name:"acc_type",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Account Type ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Account type is required"}],children:r.jsx(a.Select,{placeholder:"Select account type",size:"large",style:c,dropdownStyle:{backgroundColor:n?"#374151":"#ffffff",color:n?"#ffffff":"#000000"},children:Object.values(ce).map(p=>r.jsx(Ae,{value:p,children:p.replace("_"," ")},p))})}),r.jsx(a.Form.Item,{name:"cheq_no",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Cheque Number ",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:r.jsx(a.Input,{placeholder:"Enter cheque number",size:"large",style:c})}),r.jsx(a.Form.Item,{name:"bank",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Bank ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Bank selection is required"}],children:r.jsx(a.Select,{placeholder:"Select bank",size:"large",style:c,dropdownStyle:{backgroundColor:n?"#374151":"#ffffff",color:n?"#ffffff":"#000000"},children:f.map(p=>r.jsx(Ae,{value:p,children:p},p))})}),r.jsx(a.Form.Item,{name:"refNo",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Reference Number ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Reference number is required"}],children:r.jsx(a.Input,{placeholder:"Enter reference number",size:"large",style:c})}),r.jsx(a.Form.Item,{name:"remarks",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Remarks ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Remarks are required"}],children:r.jsx(ur,{placeholder:"Enter any additional remarks",rows:3,size:"large",style:c})})]})]})},{Title:dr}=a.Typography,{Option:mr}=a.Select,pr=({banks:f,initialValues:S,onChange:R,theme:h=D.LIGHT,amountToPay:i,currency:N="USD"})=>{const[l]=a.Form.useForm(),n=h.toLocaleLowerCase()===D.DARK.toLocaleLowerCase(),d=Q(N);P.useEffect(()=>{if(i!==void 0){const o=l.getFieldValue("giftVoucher")||0,m=l.getFieldValue("loyaltyPoints")||0,j=Math.max(0,i-o-m);l.setFieldsValue({amount:i,finalAmount:j});const A={...l.getFieldsValue(),amount:i,finalAmount:j};R(A)}},[i,l,R]);const _=(o,m)=>{const j=i!==void 0?i:m.amount||0,y=m.giftVoucher||0,A=m.loyaltyPoints||0,E=Math.max(0,j-y-A),$={...m,amount:j,finalAmount:E};l.setFieldsValue({finalAmount:E}),R($)},c={backgroundColor:n?"#374151":"#ffffff",borderColor:n?"#4b5563":"#d9d9d9",color:n?"#ffffff":"#000000"},v={backgroundColor:n?"#1f2937":"#f5f5f5",borderColor:n?"#374151":"#d9d9d9",color:n?"#9ca3af":"#666666"},p=i!==void 0?i:l.getFieldValue("amount")||0;return r.jsxs("div",{className:"bank-transfer-form",children:[r.jsx(dr,{level:4,className:`mb-4 ${n?"text-purple-400":"text-purple-600"}`,children:"Bank Transfer Details"}),r.jsxs(a.Form,{form:l,layout:"vertical",initialValues:S,onValuesChange:_,requiredMark:!1,children:[r.jsx(a.Form.Item,{name:"amount",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Total Amount ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Total amount is required"},{type:"number",min:.01,message:"Total amount must be greater than 0"}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter total amount",prefix:d,precision:2,min:0,size:"large",disabled:i!==void 0,style:i!==void 0?v:c})}),r.jsx(a.Form.Item,{name:"giftVoucher",label:r.jsx("span",{className:n?"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:(o,m)=>m&&m>p?Promise.reject(new Error(`Gift voucher cannot exceed total amount (${d}${p.toFixed(2)})`)):Promise.resolve()}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter gift voucher amount (optional)",prefix:d,precision:2,min:0,max:p,size:"large",style:c})}),r.jsx(a.Form.Item,{name:"loyaltyPoints",label:r.jsx("span",{className:n?"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:(o,m)=>{const j=l.getFieldValue("giftVoucher")||0;return(m||0)+j>p?Promise.reject(new Error(`Total deductions cannot exceed amount (${d}${p.toFixed(2)})`)):Promise.resolve()}}],children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Enter loyalty points amount (optional)",prefix:d,precision:2,min:0,size:"large",style:c})}),r.jsx(a.Form.Item,{name:"finalAmount",label:r.jsx("span",{className:n?"text-gray-200":"text-gray-700",children:"Final Amount (After Deductions)"}),children:r.jsx(a.InputNumber,{className:"w-full",placeholder:"Final amount after gift voucher deduction",prefix:d,precision:2,min:0,size:"large",readOnly:!0,style:v})}),r.jsx(a.Form.Item,{name:"acc_holder_name",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Account Holder Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Account holder name is required"},{min:2,message:"Name must be at least 2 characters long"}],children:r.jsx(a.Input,{placeholder:"Enter account holder name",size:"large",style:c})}),r.jsx(a.Form.Item,{name:"acc_no",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Account Number ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Account number is required"},{pattern:/^\d+$/,message:"Account number must contain only digits"},{min:8,message:"Account number must be at least 8 digits long"}],children:r.jsx(a.Input,{placeholder:"Enter account number",size:"large",style:c})}),r.jsx(a.Form.Item,{name:"bank",label:r.jsxs("span",{className:n?"text-gray-200":"text-gray-700",children:["Bank ",r.jsx("span",{className:"text-red-500",children:"*"})]}),rules:[{required:!0,message:"Bank selection is required"}],children:r.jsx(a.Select,{placeholder:"Select bank",size:"large",style:c,dropdownStyle:{backgroundColor:n?"#374151":"#ffffff",color:n?"#ffffff":"#000000"},children:f.map(o=>r.jsx(mr,{value:o,children:o},o))})})]})]})},{Step:hr}=a.Steps,gr=({banks:f,onPaymentComplete:S,visible:R=!1,onCancel:h,title:i="Payment Details",theme:N=D.LIGHT,amountToPay:l,currency:n="USD"})=>{const[d,_]=P.useState(0),[c,v]=P.useState(null),[p,o]=P.useState(null),[m,j]=P.useState(!1),y=N.toLowerCase()===D.DARK.toLowerCase(),A=P.useCallback(()=>{_(0),v(null),o(null),j(!1)},[]),E=()=>{A(),h==null||h()},$=V=>{v(V),_(1)},Z=()=>{_(0),v(null),o(null)},ue=(V,k)=>{switch(V){case L.CASH:const G=k;return!!(G.amount&&G.amountTendered&&G.amountChange!==void 0&&G.amountChange>=0);case L.ATM:const I=k;return!!(I.cardType&&I.last_4_digit&&I.holder&&I.bank&&I.amount);case L.CHEQUE:const q=k;return!!(q.acc_type&&q.cheq_no&&q.bank&&q.refNo&&q.remarks&&q.amount);case L.BANK_TRANSFER:const z=k;return!!(z.acc_holder_name&&z.acc_no&&z.bank&&z.amount);default:return!1}},fe=async()=>{if(!c||!p){a.message.error("Please complete all required fields");return}if(!ue(c,p)){a.message.error("Please fill in all mandatory fields correctly");return}j(!0);try{await S({paymentType:c,paymentData:p}),a.message.success("Payment details saved successfully!"),A()}catch{a.message.error("Failed to process payment details")}finally{j(!1)}},de=()=>{if(!c)return null;const V={banks:f,onChange:o,theme:y?D.DARK:D.LIGHT,amountToPay:l,currency:n};switch(c){case L.CASH:return r.jsx(or,{...V,onChange:k=>o(k)});case L.ATM:return r.jsx(ir,{...V,onChange:k=>o(k)});case L.CHEQUE:return r.jsx(fr,{...V,onChange:k=>o(k)});case L.BANK_TRANSFER:return r.jsx(pr,{...V,onChange:k=>o(k)});default:return null}},me=[{title:"Payment Method",description:"Choose payment type"},{title:"Payment Details",description:"Enter payment information"}],te=r.jsxs("div",{className:`p-4 ${y?"bg-gray-900":"bg-white"}`,children:[r.jsx(a.Steps,{current:d,className:"mb-8",children:me.map((V,k)=>r.jsx(hr,{title:V.title,description:V.description},k))}),r.jsxs("div",{className:"min-h-[400px]",children:[d===0&&r.jsx(rr,{selectedType:c,onTypeSelect:$,theme:y?D.DARK:D.LIGHT}),d===1&&de()]}),r.jsxs("div",{className:`flex justify-between items-center mt-8 pt-4 border-t ${y?"border-gray-700":"border-gray-200"}`,children:[d===1&&r.jsx(a.Button,{icon:r.jsx(K.ArrowLeft,{size:16}),onClick:Z,size:"large",className:y?"bg-gray-700 border-gray-600 text-white hover:bg-gray-600":"",children:"Back"}),d===0&&r.jsx("div",{className:"flex-1"}),d===1&&r.jsx(a.Button,{type:"primary",icon:r.jsx(K.Check,{size:16}),onClick:fe,loading:m,size:"large",className:"ml-auto",children:"Complete Payment"})]})]});return r.jsx(a.ConfigProvider,{theme:{algorithm:y?a.theme.darkAlgorithm:a.theme.defaultAlgorithm,token:{colorPrimary:"#1890ff",colorBgContainer:y?"#1f1f1f":"#ffffff",colorText:y?"#ffffff":"#000000",colorTextSecondary:y?"#a0a0a0":"#666666",colorBorder:y?"#404040":"#d9d9d9",colorBgElevated:y?"#262626":"#ffffff"}},children:r.jsx(a.Modal,{title:r.jsx("span",{className:y?"text-white":"text-gray-900",children:i}),open:R,onCancel:E,width:800,footer:null,destroyOnClose:!0,className:`payment-modal ${y?"dark-theme":"light-theme"}`,styles:{content:{backgroundColor:y?"#1f1f1f":"#ffffff",color:y?"#ffffff":"#000000"},header:{backgroundColor:y?"#1f1f1f":"#ffffff",borderBottom:`1px solid ${y?"#404040":"#f0f0f0"}`}},children:te})})};w.AccountType=ce,w.CardType=ie,w.MonetaryCalc=Ne,w.PaymentModal=gr,w.PaymentType=L,w.Theme=D,w.formatCurrency=tr,w.getAllCurrencies=nr,w.getCurrencyName=ar,w.getCurrencySymbol=Q,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=index.umd.js.map