@1interface/chat-shell 0.10.0-dev.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Adapter-BXquRkJb.cjs +1 -0
- package/dist/Adapter-Btgjo8Dw.js +1 -0
- package/dist/Adapter-NYa2rsBP.js +1 -0
- package/dist/Adapter-cx5XZUQA.cjs +1 -0
- package/dist/PaymentProviderHost-DctZpdV2.js +1 -0
- package/dist/PaymentProviderHost-DsqmNubh.cjs +1 -0
- package/dist/PaymentResultChannel-BeNC8yyV.cjs +1 -0
- package/dist/PaymentResultChannel-Cxl4EZJx.js +1 -0
- package/dist/chat-shell.css +1 -1
- package/dist/index-CBfElPm_.js +1 -0
- package/dist/index-hPiV7e_i.cjs +1 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/native/hooks/useOAuthBrowser.native.js +1 -1
- package/native/index.js +1 -1
- package/native/index.native.js +1 -1
- package/native/payment/PaymentProvider.js +1 -1
- package/native/payment/PaymentProviderHost.js +1 -1
- package/native/payment/PaymentResultChannel.js +1 -1
- package/native/payment/adapters/atb/Adapter.js +1 -0
- package/native/payment/adapters/atb/AtbCheckoutFrame.js +1 -1
- package/native/payment/adapters/atb/agentText.js +1 -0
- package/native/payment/adapters/atb/codes.js +1 -0
- package/native/payment/adapters/atb/gatewayMessage.js +1 -0
- package/native/payment/adapters/atb/result.js +1 -0
- package/native/payment/adapters/atb/spec.js +1 -0
- package/native/payment/adapters/atb/types.js +0 -0
- package/native/payment/adapters/registry.js +1 -0
- package/native/payment/adapters/registry.native.js +1 -0
- package/native/payment/adapters/specHelpers.js +1 -0
- package/native/payment/adapters/specs.js +1 -0
- package/native/payment/adapters/stripe/Adapter.js +1 -0
- package/native/payment/adapters/stripe/outcome.js +1 -0
- package/native/payment/adapters/stripe/spec.js +1 -0
- package/native/payment/adapters/stripe/types.js +0 -0
- package/native/payment/preload.js +1 -0
- package/native/providers/ChatClientProvider.js +1 -1
- package/package.json +5 -7
- package/dist/PaymentProviderHost-BTdzqJNn.cjs +0 -1
- package/dist/PaymentProviderHost-DAkTAIUt.js +0 -1
- package/native/payment/adapters/AtbPaymentAdapter.js +0 -1
- package/native/payment/adapters/ChargebeePaymentAdapter.js +0 -83
- package/native/payment/adapters/MoyasarPaymentAdapter.js +0 -1
- package/native/payment/adapters/StripePaymentAdapter.js +0 -1
- package/native/payment/adapters/chargebeeModalSize.js +0 -1
- package/native/payment/adapters/index.js +0 -1
- package/native/payment/adapters/moyasar/ApplePayButton.js +0 -12
- package/native/payment/adapters/moyasar/CardBrandIcon.js +0 -1
- package/native/payment/adapters/moyasar/CustomCardForm.js +0 -1
- package/native/payment/adapters/moyasar/Moyasar3DSIframe.js +0 -1
- package/native/payment/adapters/moyasar/api.js +0 -1
- package/native/payment/adapters/moyasar/applePayApi.js +0 -1
- package/native/payment/adapters/moyasar/cardValidation.js +0 -1
- package/native/payment/adapters/moyasar/constants.js +0 -1
- package/native/payment/adapters/moyasar/index.js +0 -1
- package/native/payment/adapters/moyasar/metadata.js +0 -1
- package/native/payment/adapters/moyasar/useApplePaySupported.js +0 -1
- package/native/payment/adapters/stripe/index.js +0 -1
- package/native/payment/adapters/stripe/providerWrapper.js +0 -1
- package/native/payment/createPaymentAdapter.js +0 -1
- package/native/payment/index.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import r,{forwardRef as o,createElement as a,useState as i,useRef as c,useCallback as s,useMemo as l,createContext as u,useContext as d,useEffect as p,useLayoutEffect as f}from"react";import{buildBrandSkin as m,parseMoyasarCallbackFromUrl as y,buildCallbackUrl as h,resolveAtbOrigin as g,buildAtbResult as v,ATB_OUTCOMES as b,ATB_FAILURE_CODES as w,ATB_FAILURE_MESSAGES as x,isAtbMessage as S,ATB_MESSAGE_TYPES as E,readAtbCompletion as C,readAtbRedirect as k,readAtbOutcome as P,isAtbCheckoutUrl as O,DEFAULT_PAYMENT_PROVIDER as _,formatAmount as j}from"@1interface/chat-core";import{useBranding as A,showErrorToast as I,logger as N,getPaymentProviderHint as T}from"@1interface/shared-core";const M=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},F=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),R=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var $={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const D=o(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:c,...s},l)=>a("svg",{ref:l,...$,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:F("lucide",o),...!i&&!R(s)&&{"aria-hidden":"true"},...s},[...c.map(([e,t])=>a(e,t)),...Array.isArray(i)?i:[i]])),V=((e,t)=>{const n=o(({className:n,...r},o)=>{return a(D,{ref:o,iconNode:t,className:F(`lucide-${i=M(e),i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r});var i});return n.displayName=M(e),n})("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function L(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var B,z,U,q,W,Y,H,J,K,X,Z,G,Q,ee,te,ne,re={exports:{}},oe={exports:{}},ae={},ie={};function ce(){return U||(U=1,oe.exports="production"===process.env.NODE_ENV?function(){if(B)return ae;B=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,s=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case s:case l:case r:case a:case o:case d:return e;default:switch(e=e&&e.$$typeof){case c:case u:case m:case f:case i:return e;default:return p}}case n:return p}}}function w(e){return b(e)===l}return ae.AsyncMode=s,ae.ConcurrentMode=l,ae.ContextConsumer=c,ae.ContextProvider=i,ae.Element=t,ae.ForwardRef=u,ae.Fragment=r,ae.Lazy=m,ae.Memo=f,ae.Portal=n,ae.Profiler=a,ae.StrictMode=o,ae.Suspense=d,ae.isAsyncMode=function(e){return w(e)||b(e)===s},ae.isConcurrentMode=w,ae.isContextConsumer=function(e){return b(e)===c},ae.isContextProvider=function(e){return b(e)===i},ae.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ae.isForwardRef=function(e){return b(e)===u},ae.isFragment=function(e){return b(e)===r},ae.isLazy=function(e){return b(e)===m},ae.isMemo=function(e){return b(e)===f},ae.isPortal=function(e){return b(e)===n},ae.isProfiler=function(e){return b(e)===a},ae.isStrictMode=function(e){return b(e)===o},ae.isSuspense=function(e){return b(e)===d},ae.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===i||e.$$typeof===c||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y)},ae.typeOf=b,ae}():(z||(z=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,s=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var y=e.type;switch(y){case s:case l:case r:case a:case o:case d:return y;default:var h=y&&y.$$typeof;switch(h){case c:case u:case m:case f:case i:return h;default:return p}}case n:return p}}}var w=l,x=c,S=i,E=t,C=u,k=r,P=m,O=f,_=n,j=a,A=o,I=d,N=!1;function T(e){return b(e)===l}ie.AsyncMode=s,ie.ConcurrentMode=w,ie.ContextConsumer=x,ie.ContextProvider=S,ie.Element=E,ie.ForwardRef=C,ie.Fragment=k,ie.Lazy=P,ie.Memo=O,ie.Portal=_,ie.Profiler=j,ie.StrictMode=A,ie.Suspense=I,ie.isAsyncMode=function(e){return N||(N=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),T(e)||b(e)===s},ie.isConcurrentMode=T,ie.isContextConsumer=function(e){return b(e)===c},ie.isContextProvider=function(e){return b(e)===i},ie.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},ie.isForwardRef=function(e){return b(e)===u},ie.isFragment=function(e){return b(e)===r},ie.isLazy=function(e){return b(e)===m},ie.isMemo=function(e){return b(e)===f},ie.isPortal=function(e){return b(e)===n},ie.isProfiler=function(e){return b(e)===a},ie.isStrictMode=function(e){return b(e)===o},ie.isSuspense=function(e){return b(e)===d},ie.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===i||e.$$typeof===c||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y)},ie.typeOf=b}()),ie)),oe.exports}function se(){return H?Y:(H=1,Y="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}function le(){return K?J:(K=1,J=Function.call.bind(Object.prototype.hasOwnProperty))}function ue(){if(Z)return X;Z=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=se(),n={},r=le();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,a,i,c,s){if("production"!==process.env.NODE_ENV)for(var l in o)if(r(o,l)){var u;try{if("function"!=typeof o[l]){var d=Error((c||"React class")+": "+i+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}u=o[l](a,l,c,i,null,t)}catch(e){u=e}if(!u||u instanceof Error||e((c||"React class")+": type specification of "+i+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". 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 instanceof Error&&!(u.message in n)){n[u.message]=!0;var p=s?s():"";e("Failed "+i+" type: "+u.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},X=o}function de(){if(Q)return G;Q=1;var e=ce(),t=function(){if(W)return q;W=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return q=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,o){for(var a,i,c=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),s=1;s<arguments.length;s++){for(var l in a=Object(arguments[s]))t.call(a,l)&&(c[l]=a[l]);if(e){i=e(a);for(var u=0;u<i.length;u++)n.call(a,i[u])&&(c[i[u]]=a[i[u]])}}return c},q}(),n=se(),r=le(),o=ue(),a=function(){};function i(){return null}return"production"!==process.env.NODE_ENV&&(a=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),G=function(c,s){var l="function"==typeof Symbol&&Symbol.iterator,u="<<anonymous>>",d={array:y("array"),bigint:y("bigint"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:m(i),arrayOf:function(e){return m(function(t,r,o,a,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var c=t[r];if(!Array.isArray(c))return new f("Invalid "+a+" `"+i+"` of type `"+v(c)+"` supplied to `"+o+"`, expected an array.");for(var s=0;s<c.length;s++){var l=e(c,s,o,a,i+"["+s+"]",n);if(l instanceof Error)return l}return null})},element:m(function(e,t,n,r,o){var a=e[t];return c(a)?null:new f("Invalid "+r+" `"+o+"` of type `"+v(a)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:m(function(t,n,r,o,a){var i=t[n];return e.isValidElementType(i)?null:new f("Invalid "+o+" `"+a+"` of type `"+v(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return m(function(t,n,r,o,a){return t[n]instanceof e?null:new f("Invalid "+o+" `"+a+"` of type `"+((i=t[n]).constructor&&i.constructor.name?i.constructor.name:u)+"` supplied to `"+r+"`, expected instance of `"+(e.name||u)+"`.");var i})},node:m(function(e,t,n,r,o){return g(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return m(function(t,o,a,i,c){if("function"!=typeof e)return new f("Property `"+c+"` of component `"+a+"` has invalid PropType notation inside objectOf.");var s=t[o],l=v(s);if("object"!==l)return new f("Invalid "+i+" `"+c+"` of type `"+l+"` supplied to `"+a+"`, expected an object.");for(var u in s)if(r(s,u)){var d=e(s,u,a,i,c+"."+u,n);if(d instanceof Error)return d}return null})},oneOf:function(e){return Array.isArray(e)?m(function(t,n,r,o,a){for(var i=t[n],c=0;c<e.length;c++)if(p(i,e[c]))return null;var s=JSON.stringify(e,function(e,t){return"symbol"===b(t)?String(t):t});return new f("Invalid "+o+" `"+a+"` of value `"+String(i)+"` supplied to `"+r+"`, expected one of "+s+".")}):("production"!==process.env.NODE_ENV&&a(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),i)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&a("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+w(o)+" at index "+t+"."),i}return m(function(t,o,a,i,c){for(var s=[],l=0;l<e.length;l++){var u=(0,e[l])(t,o,a,i,c,n);if(null==u)return null;u.data&&r(u.data,"expectedType")&&s.push(u.data.expectedType)}return new f("Invalid "+i+" `"+c+"` supplied to `"+a+"`"+(s.length>0?", expected one of type ["+s.join(", ")+"]":"")+".")})},shape:function(e){return m(function(t,r,o,a,i){var c=t[r],s=v(c);if("object"!==s)return new f("Invalid "+a+" `"+i+"` of type `"+s+"` supplied to `"+o+"`, expected `object`.");for(var l in e){var u=e[l];if("function"!=typeof u)return h(o,a,i,l,b(u));var d=u(c,l,o,a,i+"."+l,n);if(d)return d}return null})},exact:function(e){return m(function(o,a,i,c,s){var l=o[a],u=v(l);if("object"!==u)return new f("Invalid "+c+" `"+s+"` of type `"+u+"` supplied to `"+i+"`, expected `object`.");var d=t({},o[a],e);for(var p in d){var m=e[p];if(r(e,p)&&"function"!=typeof m)return h(i,c,s,p,b(m));if(!m)return new f("Invalid "+c+" `"+s+"` key `"+p+"` supplied to `"+i+"`.\nBad object: "+JSON.stringify(o[a],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=m(l,p,i,c,s+"."+p,n);if(y)return y}return null})}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function m(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,i,c,l,d,p,m){if(l=l||u,p=p||c,m!==n){if(s){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var h=l+":"+c;!t[h]&&r<3&&(a("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[h]=!0,r++)}}return null==i[c]?o?new f(null===i[c]?"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `null`.":"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(i,c,l,d,p)}var i=o.bind(null,!1);return i.isRequired=o.bind(null,!0),i}function y(e){return m(function(t,n,r,o,a,i){var c=t[n];return v(c)!==e?new f("Invalid "+o+" `"+a+"` of type `"+b(c)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null})}function h(e,t,n,r,o){return new f((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function g(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(g);if(null===e||c(e))return!0;var t=function(e){var t=e&&(l&&e[l]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!g(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!g(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function w(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return f.prototype=Error.prototype,d.checkPropTypes=o,d.resetWarningCache=o.resetWarningCache,d.PropTypes=d,d},G}function pe(){if(te)return ee;te=1;var e=se();function t(){}function n(){}return n.resetWarningCache=t,ee=function(){function r(t,n,r,o,a,i){if(i!==e){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function o(){return r}r.isRequired=r;var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a}}function fe(){if(ne)return re.exports;if(ne=1,"production"!==process.env.NODE_ENV){var e=ce();re.exports=de()(e.isElement,!0)}else re.exports=pe()();return re.exports}const me=L(fe());function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function he(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach(function(t){ve(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ve(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function be(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?we(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var xe=function(e,t,n){var o=!!n,a=r.useRef(n);r.useEffect(function(){a.current=n},[n]),r.useEffect(function(){if(!o||!e)return function(){};var n=function(){a.current&&a.current.apply(a,arguments)};return e.on(t,n),function(){e.off(t,n)}},[o,t,e,a])},Se=function(e){var t=r.useRef(e);return r.useEffect(function(){t.current=e},[e]),t.current},Ee=function(e){return null!==e&&"object"===ge(e)},Ce="[object Object]",ke=function e(t,n){if(!Ee(t)||!Ee(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===Ce;if(o!==(Object.prototype.toString.call(n)===Ce))return!1;if(!o&&!r)return t===n;var a=Object.keys(t),i=Object.keys(n);if(a.length!==i.length)return!1;for(var c={},s=0;s<a.length;s+=1)c[a[s]]=!0;for(var l=0;l<i.length;l+=1)c[i[l]]=!0;var u=Object.keys(c);if(u.length!==a.length)return!1;var d=t,p=n;return u.every(function(t){return e(d[t],p[t])})},Pe=function(e,t,n){return Ee(e)?Object.keys(e).reduce(function(r,o){var a=!Ee(t)||!ke(e[o],t[o]);return n.includes(o)?(a&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),r):a?he(he({},r||{}),{},ve({},o,e[o])):r},null):null},Oe="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",_e=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe;if(null===e||Ee(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},je=r.createContext(null);je.displayName="ElementsContext";var Ae=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},Ie=function(e){var t=e.stripe,n=e.options,o=e.children,a=r.useMemo(function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe;if(function(e){return Ee(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return _e(e,t)})};var n=_e(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}}(t)},[t]),i=be(r.useState(function(){return{stripe:"sync"===a.tag?a.stripe:null,elements:"sync"===a.tag?a.stripe.elements(n):null}}),2),c=i[0],s=i[1];r.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return"async"!==a.tag||c.stripe?"sync"!==a.tag||c.stripe||t(a.stripe):a.stripePromise.then(function(n){n&&e&&t(n)}),function(){e=!1}},[a,c,n]);var l=Se(t);r.useEffect(function(){null!==l&&l!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[l,t]);var u=Se(n);return r.useEffect(function(){if(c.elements){var e=Pe(n,u,["clientSecret","fonts"]);e&&c.elements.update(e)}},[n,u,c.elements]),r.useEffect(function(){var e;(e=c.stripe)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},[c.stripe]),r.createElement(je.Provider,{value:c},o)};Ie.propTypes={stripe:me.any,options:me.object};var Ne=r.createContext(null);Ne.displayName="CheckoutSdkContext",r.createContext(null).displayName="CheckoutContext",me.shape({fetchClientSecret:me.func.isRequired,elementsOptions:me.object});var Te=function(e){var t=r.useContext(Ne),n=r.useContext(je);if(t&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return t?function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e}(t,e):Ae(n,e)},Me=["mode"],Fe=function(e,t){var n,o="".concat((n=e).charAt(0).toUpperCase()+n.slice(1),"Element"),a=t?function(e){return Te("mounts <".concat(o,">")),r.createElement("div",{id:e.id,className:e.className})}:function(t){var n,a=t.id,i=t.className,c=t.options,s=void 0===c?{}:c,l=t.onBlur,u=t.onFocus,d=t.onReady,p=t.onChange,f=t.onEscape,m=t.onClick,y=t.onLoadError,h=t.onLoaderStart,g=t.onNetworksChange,v=t.onConfirm,b=t.onCancel,w=t.onShippingAddressChange,x=t.onShippingRateChange,S=t.onSavedPaymentMethodRemove,E=t.onSavedPaymentMethodUpdate,C=Te("mounts <".concat(o,">")),k="elements"in C?C.elements:null,P="checkoutSdk"in C?C.checkoutSdk:null,O=be(r.useState(null),2),_=O[0],j=O[1],A=r.useRef(null),I=r.useRef(null);xe(_,"blur",l),xe(_,"focus",u),xe(_,"escape",f),xe(_,"click",m),xe(_,"loaderror",y),xe(_,"loaderstart",h),xe(_,"networkschange",g),xe(_,"confirm",v),xe(_,"cancel",b),xe(_,"shippingaddresschange",w),xe(_,"shippingratechange",x),xe(_,"savedpaymentmethodremove",S),xe(_,"savedpaymentmethodupdate",E),xe(_,"change",p),d&&(n="expressCheckout"===e?d:function(){d(_)}),xe(_,"ready",n),r.useLayoutEffect(function(){if(null===A.current&&null!==I.current&&(k||P)){var t=null;if(P)switch(e){case"payment":t=P.createPaymentElement(s);break;case"address":if(!("mode"in s))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var n=s.mode,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(s,Me);if("shipping"===n)t=P.createShippingAddressElement(r);else{if("billing"!==n)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");t=P.createBillingAddressElement(r)}break;case"expressCheckout":t=P.createExpressCheckoutElement(s);break;case"currencySelector":t=P.createCurrencySelectorElement();break;case"taxId":t=P.createTaxIdElement(s);break;default:throw new Error("Invalid Element type ".concat(o,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else k&&(t=k.create(e,s));A.current=t,j(t),t&&t.mount(I.current)}},[k,P,s]);var N=Se(s);return r.useEffect(function(){if(A.current){var e=Pe(s,N,["paymentRequest"]);e&&"update"in A.current&&A.current.update(e)}},[s,N]),r.useLayoutEffect(function(){return function(){if(A.current&&"function"==typeof A.current.destroy)try{A.current.destroy(),A.current=null}catch(e){}}},[]),r.createElement("div",{id:a,className:i,ref:I})};return a.propTypes={id:me.string,className:me.string,onChange:me.func,onBlur:me.func,onFocus:me.func,onReady:me.func,onEscape:me.func,onClick:me.func,onLoadError:me.func,onLoaderStart:me.func,onNetworksChange:me.func,onConfirm:me.func,onCancel:me.func,onShippingAddressChange:me.func,onShippingRateChange:me.func,onSavedPaymentMethodRemove:me.func,onSavedPaymentMethodUpdate:me.func,options:me.object},a.displayName=o,a.__elementType=e,a},Re="undefined"==typeof window;r.createContext(null).displayName="EmbeddedCheckoutProviderContext",Fe("auBankAccount",Re),Fe("card",Re),Fe("cardNumber",Re),Fe("cardExpiry",Re),Fe("cardCvc",Re),Fe("fpxBank",Re),Fe("iban",Re),Fe("idealBank",Re),Fe("p24Bank",Re),Fe("epsBank",Re);var $e=Fe("payment",Re);Fe("expressCheckout",Re),Fe("currencySelector",Re),Fe("paymentRequestButton",Re),Fe("linkAuthentication",Re),Fe("address",Re),Fe("shippingAddress",Re),Fe("paymentMethodMessaging",Re),Fe("affirmMessage",Re),Fe("afterpayClearpayMessage",Re),Fe("taxId",Re);const De=u(null),Ve=({onResult:t,children:n})=>{const[r,o]=i(null),[a,u]=i(null),d=c(t);d.current=t;const p=s(e=>{d.current(e)},[]),f=s(e=>{o(e)},[]),m=s(e=>{u(e)},[]),y=l(()=>({emitResult:p,registerConfirm:f,confirmHandle:r,reportSummary:m,summary:a}),[p,f,r,m,a]);return e(De.Provider,{value:y,children:n})},Le=()=>{const e=d(De);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e},Be=()=>Le().emitResult,ze=()=>Le().registerConfirm,Ue=()=>Le().reportSummary;function qe(e){return(qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var We,Ye="https://js.stripe.com/v3",He=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Je="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Ke=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(Ye).concat(t);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n},Xe=null,Ze=null,Ge=null,Qe=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==qe(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},et=!1,tt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];et=!0;var r,o=Date.now();return(r=We,null!==Xe?Xe:(Xe=new Promise(function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&r&&console.warn(Je),window.Stripe)e(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Ye,'"]')),t=0;t<e.length;t++){var n=e[t];if(He.test(n.src))return n}return null}();if(n&&r)console.warn(Je);else if(n){if(n&&null!==Ge&&null!==Ze){var o;n.removeEventListener("load",Ge),n.removeEventListener("error",Ze),null===(o=n.parentNode)||void 0===o||o.removeChild(n),n=Ke(r)}}else n=Ke(r);Ge=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(e,t),Ze=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(t),n.addEventListener("load",Ge),n.addEventListener("error",Ze)}catch(e){return void t(e)}else e(null)})).catch(function(e){return Xe=null,Promise.reject(e)})).then(function(e){return function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})}(r,n),r}(e,t,o)})};tt.setLoadParameters=function(e){if(et&&We){var t=Qe(e);if(Object.keys(t).reduce(function(t,n){var r;return t&&e[n]===(null===(r=We)||void 0===r?void 0:r[n])},!0))return}if(et)throw new Error("You cannot change load parameters after calling loadStripe");We=Qe(e)};const nt=u(null),rt=({onReady:t})=>{const n=Te("calls useStripe()").stripe,o=(y=r.useContext(je),Ae(y,"calls useElements()")).elements,{paymentInit:a}=Rn(),c=Be(),l=ze(),u=Ue(),[d,f]=i(!1),m="stripe"===a?.provider?a.config.client_secret:null;var y;p(()=>{if(!n||!m)return;let e=!1;return n.retrievePaymentIntent(m).then(t=>{if(e)return;const n=t.paymentIntent;n&&"number"==typeof n.amount&&n.currency&&u({amount:n.amount,currency:n.currency})}),()=>{e=!0}},[n,m,u]);const h=s(async()=>{if(!n||!o||!m)return;f(!0);const{error:e}=await o.submit();if(e)return void f(!1);const{error:t,paymentIntent:r}=await n.confirmPayment({elements:o,clientSecret:m,confirmParams:{return_url:window.location.href},redirect:"if_required"});f(!1),t||!r||"succeeded"!==r.status&&"requires_capture"!==r.status||c({status:"success",provider:"stripe",paymentId:r.id,amount:r.amount,currency:r.currency})},[n,o,m,c]);return p(()=>(l({confirm:h,isConfirming:d}),()=>l(null)),[h,d,l]),e($e,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:t})},ot={type:"stripe",label:"Stripe",ProviderWrapper:({children:t})=>{const{paymentInit:n}=Rn(),[r,o]=i(null),a="stripe"===n?.provider?n.config.publishable_key:null;p(()=>{a&&a.startsWith("pk_")&&o(tt(a))},[a]);const c=l(()=>({stripePromise:r}),[r]);return e(nt.Provider,{value:c,children:t})},FormComponent:({onReady:t})=>{const{themeStyles:n,theme:r}=A(),{stripePromise:o}=(()=>{const e=d(nt);if(!e)throw new Error("Stripe adapter components must be used inside StripeProviderWrapper");return e})(),{paymentInit:a}=Rn(),i=l(()=>m(n,r),[n,r]),c=l(()=>function(e,t,n){return{theme:"dark"===t?"night":"stripe",variables:{colorPrimary:e.statusDiscovery.solid,colorBackground:n.cardBg,colorText:n.text,colorDanger:"#df1b41",fontFamily:n.fontFamily,borderRadius:`${n.radius}px`,spacingUnit:"3px",fontSizeBase:"16px"}}}(n,r,i),[n,r,i]),s="stripe"===a?.provider?a.config.client_secret:null,u=l(()=>s?{clientSecret:s,appearance:c}:null,[s,c]);return o&&u?e(Ie,{stripe:o,options:u,children:e(rt,{onReady:t})},s):null}};function at(e){const t={};if(e.config.metadata)for(const[n,r]of Object.entries(e.config.metadata))null!=r&&(t[n]=String(r));if(e.config.customer){const{name:n,email:r,phone:o,reference_id:a}=e.config.customer;n&&(t.customer_name=n),r&&(t.customer_email=r),o&&(t.customer_phone=o),a&&(t.customer_reference_id=a)}return t}class it extends Error{constructor(e,t,n){super(e),this.status=t,this.body=n,this.name="MoyasarApiError"}}async function ct(e){const t=await st("https://api.moyasar.com/v1/payments",e);if(!t.ok)throw new it(lt(t.body)??`Payment creation failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id||"string"!=typeof n.status)throw new it("Payment creation returned no id/status",t.status,n);return n}async function st(e,t){const n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Payment request timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new it(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}return{ok:o.ok,status:o.status,body:a}}function lt(e){if(!e||"object"!=typeof e)return null;if("string"==typeof e.message&&e.message.length>0)return e.message;if(e.errors&&"object"==typeof e.errors){const t=e.errors;for(const[e,n]of Object.entries(t)){if(Array.isArray(n)&&"string"==typeof n[0])return`${ut(e)}: ${n[0]}`;if("string"==typeof n)return`${ut(e)}: ${n}`}}return null}function ut(e){return e.replace(/_/g," ")}const dt=({url:n,onResult:r,skin:o})=>{const a=c(r);a.current=r;const l=c(!1),[u,d]=i(!1),f=c(!1),m=s(e=>{l.current||(l.current=!0,a.current({status:"failure",provider:"moyasar",message:e}))},[]);return p(()=>{const e=window.location.origin,t=t=>{if(t.origin!==e)return;if(l.current)return;if(!(n=t.data)||"object"!=typeof n||"moyasar-iframe-callback"!==n.type||"string"!=typeof n.search)return;var n;const r=y(t.data.search);r&&(l.current=!0,a.current(r.result))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[]),p(()=>{const e=setTimeout(()=>{f.current||m("3D Secure challenge failed to load")},6e4);return()=>clearTimeout(e)},[m]),t("div",{className:"absolute inset-0 z-[105]",style:{background:o.cardBg},role:"dialog","aria-label":"3D Secure authentication",children:[!u&&e("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:o.muted,fontFamily:o.fontFamily},children:"Loading…"}),e("iframe",{src:n,title:"3D Secure",className:"w-full h-full",style:{border:0,background:"white"},onLoad:()=>{f.current=!0,d(!0)},onError:()=>{m("3D Secure challenge failed to load")},allow:"payment *",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation-by-user-activation",referrerPolicy:"no-referrer"})]})},pt=["mada","visa","masterCard"],ft="data-aiatcore-apple-pay",mt=({skin:r})=>{const{paymentInit:o}=Rn(),a=o&&"moyasar"===o.provider?o:null,l=Be(),[u,d]=i(null),f=c(l);f.current=l,p(()=>{!function(){if("undefined"==typeof document)return;if(document.querySelector(`style[${ft}]`))return;const e=document.createElement("style");e.setAttribute(ft,"true"),e.textContent="\n .aiatcore-apple-pay-button {\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: pay;\n -apple-pay-button-style: black;\n width: 100%;\n cursor: pointer;\n border: none;\n padding: 0;\n margin: 0;\n }\n ",document.head.appendChild(e)}()},[]);const m=s(()=>{if(!a)return;const e=window.ApplePaySession;if(!e)return void I("Apple Pay is not available on this device.");const t=a.config.apple_pay?.label??a.config.description??"Payment",n=a.config.apple_pay?.country??"SA",r=a.config.currency.toUpperCase(),o=(a.config.amount/100).toFixed(2),i={countryCode:n,currencyCode:r,supportedNetworks:pt,merchantCapabilities:["supports3DS","supportsDebit","supportsCredit"],total:{label:t,amount:o}};let c;try{c=new e(5,i)}catch(e){return void I(e instanceof Error?e.message:"Failed to start Apple Pay")}c.onvalidatemerchant=async e=>{try{const n=await async function(e){const t={validation_url:e.validationUrl,display_name:e.displayName,domain_name:e.domainName??window.location.hostname,publishable_api_key:e.publishableApiKey},n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch("https://api.moyasar.com/v1/applepay/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Apple Pay merchant validation timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new it(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}if(!o.ok)throw new it(function(e){return e&&"object"==typeof e&&"string"==typeof e.message&&e.message.length>0?e.message:null}(a)??`Apple Pay merchant validation failed (${o.status})`,o.status,a);return a}({validationUrl:e.validationURL,displayName:t,publishableApiKey:a.config.publishable_key});c.completeMerchantValidation(n)}catch(e){const t=e instanceof Error?e.message:"Merchant validation failed";c.abort(),l({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}},c.onpaymentauthorized=async t=>{try{const n=at(a),o=await ct({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:r,description:a.config.description,callback_url:h(a.config.given_id),source:{type:"applepay",token:t.payment.token},...Object.keys(n).length>0?{metadata:n}:{}}),i=o.source?.transaction_url??o.transaction_url;if(i)return c.completePayment({status:e.STATUS_SUCCESS}),void d(i);const s=o.status;if("paid"===s||"authorized"===s||"captured"===s)c.completePayment({status:e.STATUS_SUCCESS}),l({status:"success",provider:"moyasar",paymentId:o.id,amount:o.amount,currency:o.currency});else if("failed"===s){const t=o.source?.message??"Payment failed";c.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",code:"failed",message:t,paymentId:o.id})}else{const t=`Unexpected payment status: ${s}`;c.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",code:s,message:t,paymentId:o.id})}}catch(t){const n=t instanceof it||t instanceof Error?t.message:"Payment failed";c.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",message:n,paymentId:a.config.given_id})}},c.oncancel=()=>{};try{c.begin()}catch(e){I(e instanceof Error?e.message:"Failed to start Apple Pay")}},[a,l]);return a?t(n,{children:[e("button",{type:"button",onClick:m,className:"aiatcore-apple-pay-button",style:{borderRadius:r.radius,height:44},"aria-label":"Pay with Apple Pay"}),u&&e(dt,{url:u,skin:r,onResult:e=>{d(null),f.current(e)}})]}):null};var yt,ht,gt,vt={},bt={};function wt(){return gt||(gt=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null}),bt}var xt,St,Et,Ct,kt,Pt,Ot={},_t={},jt={};function At(){if(Pt)return kt;Pt=1;var e=kt&&kt.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)},t=ht?yt:(ht=1,yt={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[62207,62209],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},verve:{niceType:"Verve",type:"verve",patterns:[[506099,506127],506129,[506133,506150],[506158,506163],506166,506168,506170,506173,[506176,506180],506184,[506187,506188],506191,506195,506197,507865,507866,[507868,507877],[507880,507888],507900,507941],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}}),n=function(){if(St)return vt;St=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.addMatchingCardsToResults=function(n,r,o){var a,i;for(a=0;a<r.patterns.length;a++){var c=r.patterns[a];if((0,t.matches)(n,c)){var s=(0,e.clone)(r);i=Array.isArray(c)?String(c[0]).length:String(c).length,n.length>=i&&(s.matchStrength=i),o.push(s);break}}};var e=wt(),t=(xt||(xt=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.matches=function(e,t){return Array.isArray(t)?function(e,t,n){var r=String(t).length,o=e.substr(0,r),a=parseInt(o,10);return t=parseInt(String(t).substr(0,o.length),10),n=parseInt(String(n).substr(0,o.length),10),a>=t&&a<=n}(e,t[0],t[1]):function(e,t){return(t=String(t)).substring(0,e.length)===e.substring(0,t.length)}(e,t)}),Ot);return vt}(),r=(Et||(Et=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.isValidInputType=function(e){return"string"==typeof e||e instanceof String}),_t),o=(Ct||(Ct=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.findBestMatch=function(e){return function(e){var t=e.filter(function(e){return e.matchStrength}).length;return t>0&&t===e.length}(e)?e.reduce(function(e,t){return e?Number(e.matchStrength)<Number(t.matchStrength)?t:e:t}):null}),jt),a=wt(),i={},c={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",VERVE:"verve",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},s=[c.VISA,c.MASTERCARD,c.AMERICAN_EXPRESS,c.DINERS_CLUB,c.DISCOVER,c.JCB,c.UNIONPAY,c.VERVE,c.MAESTRO,c.ELO,c.MIR,c.HIPER,c.HIPERCARD],l=(0,a.clone)(s);function u(e){return i[e]||t[e]}function d(e,t){void 0===t&&(t=!1);var n=l.indexOf(e);if(!t&&-1===n)throw new Error('"'+e+'" is not a supported card type.');return n}function p(e){var t=[];if(!(0,r.isValidInputType)(e))return t;if(0===e.length)return l.map(function(e){return(0,a.clone)(u(e))});l.forEach(function(r){var o=u(r);(0,n.addMatchingCardsToResults)(e,o,t)});var i=(0,o.findBestMatch)(t);return i?[i]:t}return p.getTypeInfo=function(e){return(0,a.clone)(u(e))},p.removeCard=function(e){var t=d(e);l.splice(t,1)},p.addCard=function(e){var t=d(e.type,!0);i[e.type]=e,-1===t&&l.push(e.type)},p.updateCard=function(n,r){var o=i[n]||t[n];if(!o)throw new Error('"'.concat(n,"\" is not a recognized type. Use `addCard` instead.'"));if(r.type&&o.type!==r.type)throw new Error("Cannot overwrite type parameter.");var c=(0,a.clone)(o);c=e(e({},c),r),i[c.type]=c},p.changeOrder=function(e,t){var n=d(e);l.splice(n,1),l.splice(t,0,e)},p.resetModifications=function(){l=(0,a.clone)(s),i={}},p.types=c,kt=p}var It,Nt,Tt,Mt,Ft,Rt={},$t={},Dt={},Vt={},Lt={};function Bt(){if(Ft)return Lt;Ft=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.expirationYear=function(n,r){var o;if(void 0===r&&(r=e),"string"!=typeof n)return t(!1,!1);if(""===n.replace(/\s/g,""))return t(!1,!0);if(!/^\d*$/.test(n))return t(!1,!1);var a=n.length;if(a<2)return t(!1,!0);var i=(new Date).getFullYear();if(3===a)return t(!1,n.slice(0,2)===String(i).slice(0,2));if(a>4)return t(!1,!1);var c=parseInt(n,10),s=Number(String(i).substr(2,2)),l=!1;if(2===a){if(String(i).substr(0,2)===n)return t(!1,!0);o=s===c,l=c>=s&&c<=s+r}else 4===a&&(o=i===c,l=c>=i&&c<=i+r);return t(l,l,o)};var e=19;function t(e,t,n){return{isValid:e,isPotentiallyValid:t,isCurrentYear:n||!1}}return Lt}var zt,Ut,qt,Wt,Yt={},Ht={};function Jt(){if(qt)return Ht;function e(e,t,n){return{isValid:e,isPotentiallyValid:t,isValidForThisYear:n||!1}}return qt=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.expirationMonth=function(t){var n=(new Date).getMonth()+1;if("string"!=typeof t)return e(!1,!1);if(""===t.replace(/\s/g,"")||"0"===t)return e(!1,!0);if(!/^\d*$/.test(t))return e(!1,!1);var r=parseInt(t,10);if(isNaN(Number(t)))return e(!1,!1);var o=r>0&&r<13;return e(o,o,o&&r>=n)},Ht}var Kt,Xt,Zt,Gt,Qt={},en={};const tn=L(function(){if(Gt)return Zt;Gt=1;var e=Zt&&Zt.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),t=Zt&&Zt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=(Zt&&Zt.__importStar||function(){var n=function(e){return(n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t})(e)};return function(r){if(r&&r.__esModule)return r;var o={};if(null!=r)for(var a=n(r),i=0;i<a.length;i++)"default"!==a[i]&&e(o,r,a[i]);return t(o,r),o}}())(At()),r=function(){if(It)return Rt;It=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.cardholderName=function(r){return"string"!=typeof r?n(!1,!1):0===r.length?n(!1,!0):r.length>t?n(!1,!1):e.test(r)?n(!1,!0):n(!0,!0)};var e=/^[\d\s-]*$/,t=255;function n(e,t){return{isValid:e,isPotentiallyValid:t}}return Rt}(),o=function(){if(Mt)return $t;Mt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.cardNumber=function(r,o){var a,i;if(void 0===o&&(o={}),"string"!=typeof r&&"number"!=typeof r)return n(null,!1,!1);var c=String(r).replace(/-|\s/g,"");if(!/^\d*$/.test(c))return n(null,!1,!1);var s=t(c);if(0===s.length)return n(null,!1,!1);if(1!==s.length)return n(null,!0,!1);var l=s[0];if(o.maxLength&&c.length>o.maxLength)return n(l,!1,!1);a=!0===o.skipLuhnValidation||l.type===t.types.UNIONPAY&&!0!==o.luhnValidateUnionPay||e(c),i=Math.max.apply(null,l.lengths),o.maxLength&&(i=Math.min(o.maxLength,i));for(var u=0;u<l.lengths.length;u++)if(l.lengths[u]===c.length)return n(l,c.length<i||a,a);return n(l,c.length<i,!1)};var e=Tt?Nt:(Tt=1,Nt=function(e){for(var t,n=0,r=!1,o=e.length-1;o>=0;)t=parseInt(e.charAt(o),10),r&&(t*=2)>9&&(t=t%10+1),r=!r,n+=t,o--;return n%10==0}),t=At();function n(e,t,n){return{card:e,isPotentiallyValid:t,isValid:n}}return $t}(),a=function(){if(Wt)return Dt;Wt=1;var e=Dt&&Dt.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.expirationDate=function(a,i){var c;if("string"==typeof a)a=a.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),c=(0,t.parseDate)(String(a));else{if(null===a||"object"!=typeof a)return o(!1,!1,null,null);var s=e({},a);c={month:String(s.month),year:String(s.year)}}var l=(0,n.expirationMonth)(c.month),u=(0,r.expirationYear)(c.year,i);if(l.isValid){if(u.isCurrentYear){var d=l.isValidForThisYear;return o(d,d,c.month,c.year)}if(u.isValid)return o(!0,!0,c.month,c.year)}return o(!1,!(!l.isPotentiallyValid||!u.isPotentiallyValid),null,null)};var t=function(){if(Ut)return Vt;Ut=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.parseDate=function(n){var r;if(/^\d{4}-\d{1,2}$/.test(n)?r=n.split("-").reverse():/\//.test(n)?r=n.split(/\s*\/\s*/g):/\s/.test(n)&&(r=n.split(/ +/g)),(0,t.isArray)(r))return{month:r[0]||"",year:r.slice(1).join()};var o,a,i,c=(o=n,0===(i=Number(o[0]))?2:i>1||1===i&&Number(o[1])>2?1:1===i?(a=o.substr(1),(0,e.expirationYear)(a).isPotentiallyValid?1:2):5===o.length?1:o.length>5?2:1),s=n.substr(0,c);return{month:s,year:n.substr(s.length)}};var e=Bt(),t=(zt||(zt=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.isArray=void 0,Yt.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Yt);return Vt}(),n=Jt(),r=Bt();function o(e,t,n,r){return{isValid:e,isPotentiallyValid:t,month:n,year:r}}return Dt}(),i=Jt(),c=Bt(),s=function(){if(Kt)return Qt;Kt=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.cvv=function(n,r){return void 0===r&&(r=e),r=r instanceof Array?r:[r],"string"!=typeof n?t(!1,!1):/^\d*$/.test(n)?function(e,t){for(var n=0;n<e.length;n++)if(t===e[n])return!0;return!1}(r,n.length)?t(!0,!0):n.length<Math.min.apply(null,r)?t(!1,!0):n.length>function(t){for(var n=e,r=0;r<t.length;r++)n=t[r]>n?t[r]:n;return n}(r)?t(!1,!1):t(!0,!0):t(!1,!1)};var e=3;function t(e,t){return{isValid:e,isPotentiallyValid:t}}return Qt}(),l=function(){if(Xt)return en;Xt=1,Object.defineProperty(en,"__esModule",{value:!0}),en.postalCode=function(r,o){void 0===o&&(o={});var a=o.minLength||e;return"string"!=typeof r?n(!1,!1):r.length<a?n(!1,!0):t.test(r.trim().slice(0,a))?n(!0,!0):n(!1,!0)};var e=2,t=new RegExp(/^[a-z0-9]+$/i);function n(e,t){return{isValid:e,isPotentiallyValid:t}}return en}();return Zt={creditCardType:n,cardholderName:r.cardholderName,number:o.cardNumber,expirationDate:a.expirationDate,expirationMonth:i.expirationMonth,expirationYear:c.expirationYear,cvv:s.cvv,postalCode:l.postalCode}}()),nn=L(At());let rn=!1;rn||(rn=!0,nn.addCard({niceType:"Mada",type:"mada",patterns:[440647,440795,446404,446672,419593,428331,428671,432328,440533,446393,457865,458456,462220,484783,484800,493428,504300,521076,529415,535825,536023,537767,543357,557606,558848,588845,589206],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}));const on=({brand:t,fallbackColor:n,height:r=22})=>{if(!t)return null;switch(t){case"Visa":return e(an,{height:r});case"Mastercard":return e(cn,{height:r});case"American Express":return e(sn,{height:r});case"Mada":return e(ln,{height:r});case"Discover":return e(un,{height:r});case"JCB":return e(dn,{height:r});default:return e("span",{className:"text-xs font-medium",style:{color:n},"aria-label":`Card brand: ${t}`,children:t})}},an=({height:n})=>t("svg",{role:"img","aria-label":"Visa",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#1A1F71"}),e("text",{x:"24",y:"12",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"11",fill:"#FFFFFF",letterSpacing:"1.4",children:"VISA"})]}),cn=({height:n})=>t("svg",{role:"img","aria-label":"Mastercard",viewBox:"0 0 32 20",height:n,width:32*n/20,style:{display:"block"},children:[e("circle",{cx:"12",cy:"10",r:"7",fill:"#EB001B"}),e("circle",{cx:"20",cy:"10",r:"7",fill:"#F79E1B"}),e("path",{d:"M16 4.5a7 7 0 0 1 0 11 7 7 0 0 1 0-11Z",fill:"#FF5F00","aria-hidden":"true"})]}),sn=({height:n})=>t("svg",{role:"img","aria-label":"American Express",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#2E77BB"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.4",children:"AMEX"})]}),ln=({height:n})=>t("svg",{role:"img","aria-label":"Mada",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#84B740"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.6",children:"mada"})]}),un=({height:n})=>t("svg",{role:"img","aria-label":"Discover",viewBox:"0 0 56 16",height:n,width:56*n/16,style:{display:"block"},children:[e("rect",{width:"56",height:"16",rx:"2",fill:"#FFFFFF",stroke:"#E5E7EB"}),e("text",{x:"20",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"8",fill:"#231F20",letterSpacing:"0.2",children:"DISCOVER"}),e("circle",{cx:"44",cy:"8",r:"4",fill:"#FF6000"})]}),dn=({height:n})=>t("svg",{role:"img","aria-label":"JCB",viewBox:"0 0 32 16",height:n,width:32*n/16,style:{display:"block"},children:[e("rect",{x:"0",y:"0",width:"10.66",height:"16",rx:"2",fill:"#0E4C96"}),e("rect",{x:"10.66",y:"0",width:"10.66",height:"16",fill:"#B41E25"}),e("rect",{x:"21.33",y:"0",width:"10.66",height:"16",rx:"2",fill:"#1B8A3A"}),e("text",{x:"16",y:"11",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"9",fill:"#FFFFFF",children:"JCB"})]}),pn=({skin:r})=>{const{paymentInit:o}=Rn(),a=o&&"moyasar"===o.provider?o:null,u=Be(),d=ze(),f=Ue(),[m,y]=i(""),[g,v]=i(""),[b,w]=i(""),[x,S]=i(""),[E,C]=i(!1),[k,P]=i({}),[O,_]=i(null),j=c({number:m,expiry:g,cvc:b,name:x});j.current={number:m,expiry:g,cvc:b,name:x};const A=c(u);A.current=u,p(()=>{a&&f({amount:a.config.amount,currency:a.config.currency.toUpperCase()})},[a,f]);const I=s(async()=>{if(!a)return;const e=function(e,t=new Date){const n=[],r=tn.number(e.number),o=e.number.replace(/\D/g,"");o?r.isValid||n.push({field:"number",message:"Invalid card number"}):n.push({field:"number",message:"Card number is required"});const a=tn.expirationDate(e.expiry);let i=null,c=null;const s=e.expiry.trim();if(s)if(a.isValid){i=Number.parseInt(a.month??"",10);const e=Number.parseInt(a.year??"",10);c=2===(a.year??"").length?e+2e3:e}else{const e=function(e){let t="",n="";if(e.includes("/")){const[r,o]=e.split("/");t=(r??"").replace(/\D/g,""),n=(o??"").replace(/\D/g,"")}else{const r=e.replace(/\D/g,"");t=r.slice(0,2),n=r.slice(2)}const r=Number.parseInt(t,10),o=Number.parseInt(n,10);return Number.isNaN(r)||Number.isNaN(o)?null:{month:r,year:2===n.length?o+2e3:o}}(s);e&&function(e,t,n){const r=n.getFullYear(),o=n.getMonth()+1;return t<r||t===r&&e<o}(e.month,e.year,t)?n.push({field:"expiry",message:"Card expired"}):n.push({field:"expiry",message:"Invalid expiry"})}else n.push({field:"expiry",message:"Expiry is required"});const l=tn.cvv(e.cvc,r.card?.code.size??[3,4]),u=e.cvc.replace(/\D/g,"");u?l.isValid||n.push({field:"cvc",message:"Invalid CVC"}):n.push({field:"cvc",message:"CVC is required"});const d=tn.cardholderName(e.name),p=e.name.trim();return p?d.isValid||n.push({field:"name",message:"Invalid cardholder name"}):n.push({field:"name",message:"Cardholder name is required"}),n.length>0||null==i||null==c?{ok:!1,errors:n}:{ok:!0,card:{number:o,month:String(i).padStart(2,"0"),year:String(c),cvc:u,name:p}}}(j.current);if(!1===e.ok){const t={};for(const n of e.errors)t[n.field]||(t[n.field]=n.message);return void P(t)}P({}),C(!0);try{const t=await async function(e){const t=await st("https://api.moyasar.com/v1/tokens",{...e,save_only:!0});if(!t.ok)throw new it(lt(t.body)??`Tokenization failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id)throw new it("Tokenization returned no token id",t.status,n);return{id:n.id}}({publishable_api_key:a.config.publishable_key,name:e.card.name,number:e.card.number,month:e.card.month,year:e.card.year,cvc:e.card.cvc}),n=at(a),r=await ct({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:a.config.currency.toUpperCase(),description:a.config.description,callback_url:h(a.config.given_id),source:{type:"token",token:t.id},...Object.keys(n).length>0?{metadata:n}:{}}),o=r.source?.transaction_url??r.transaction_url;if(o)return void _(o);const i=r.status;A.current("paid"===i||"authorized"===i||"captured"===i?{status:"success",provider:"moyasar",paymentId:r.id,amount:r.amount,currency:r.currency}:"failed"===i?{status:"failure",provider:"moyasar",code:"failed",message:r.source?.message??"Payment failed",paymentId:r.id}:{status:"failure",provider:"moyasar",code:i,message:`Unexpected payment status: ${i}`,paymentId:r.id})}catch(e){const t=e instanceof it||e instanceof Error?e.message:"Payment failed";A.current({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}finally{C(!1)}},[a]);p(()=>(d({confirm:I,isConfirming:E}),()=>d(null)),[I,E,d]);const N=l(()=>Math.max(r.radius-4,4),[r.radius]),T=l(()=>function(e){const t=e.replace(/\D/g,"");if(t.length<2)return null;const n=nn(t);return n[0]?.niceType??null}(m),[m]);return a?t(n,{children:[t("div",{className:"space-y-3",style:{fontFamily:r.fontFamily},children:[e(mn,{label:"Card number",value:m,onChange:e=>y(e.replace(/\D/g,"").slice(0,19).replace(/(\d{4})(?=\d)/g,"$1 ")),autoComplete:"cc-number",inputMode:"numeric",placeholder:"1234 5678 9012 3456",error:k.number,skin:r,radius:N,endAdornment:T?e(on,{brand:T,fallbackColor:r.muted}):null}),t("div",{className:"grid grid-cols-2 gap-3",children:[e(mn,{label:"Expiry",value:g,onChange:e=>v(function(e){const t=e.replace(/\D/g,"").slice(0,4);return t.length<=2?t:`${t.slice(0,2)}/${t.slice(2)}`}(e)),autoComplete:"cc-exp",inputMode:"numeric",placeholder:"MM / YY",error:k.expiry,skin:r,radius:N}),e(mn,{label:"CVC",value:b,onChange:e=>w(e.replace(/\D/g,"").slice(0,4)),autoComplete:"cc-csc",inputMode:"numeric",placeholder:"123",error:k.cvc,skin:r,radius:N})]}),e(mn,{label:"Name on card",value:x,onChange:S,autoComplete:"cc-name",inputMode:"text",placeholder:"Full name",error:k.name,skin:r,radius:N})]}),O&&e(dt,{url:O,skin:r,onResult:e=>{_(null),A.current(e)}})]}):null};function fn(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);r>=48&&r<=57&&t++}return t}const mn=({label:n,value:r,onChange:o,placeholder:a,autoComplete:i,inputMode:s,error:l,skin:u,radius:d,endAdornment:p})=>{const m=l?"#dc2626":u.divider,y=c(null),h=c(null),g="numeric"===s;return f(()=>{const e=h.current;if(null===e||!y.current)return;h.current=null;const t=y.current.value;let n=0,r=0;for(;r<t.length&&!(n>=e);)/\d/.test(t[r])&&n++,r++;y.current.setSelectionRange(r,r)},[r]),t("label",{className:"block",children:[e("span",{className:"block text-xs mb-1",style:{color:u.muted},children:n}),t("div",{className:"relative",children:[e("input",{ref:y,type:"text",value:r,onChange:e=>{g&&(h.current=fn(e.target.value.slice(0,e.target.selectionStart??e.target.value.length))),o(e.target.value)},onKeyDown:e=>{if(!g||"Backspace"!==e.key)return;const t=e.currentTarget,n=t.selectionStart??0;if(n!==(t.selectionEnd??0)||n<2)return;const r=t.value[n-1];if(!r||/\d/.test(r))return;e.preventDefault();const a=t.value.slice(0,n-2)+t.value.slice(n);h.current=fn(a.slice(0,n-2)),o(a)},placeholder:a,autoComplete:i,inputMode:s,spellCheck:!1,className:"w-full py-3 px-3 outline-none text-sm transition-colors",style:{background:u.pillBg,color:u.text,border:`1px solid ${m}`,borderRadius:d,paddingRight:p?96:void 0}}),p&&e("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium pointer-events-none",style:{color:u.muted},"aria-label":"Card brand",children:p})]}),l&&e("span",{className:"block mt-1 text-xs",style:{color:"#dc2626"},children:l})]})},yn=["creditcard","applepay"],hn=({skin:n})=>t("div",{className:"relative",children:[e("div",{className:"absolute inset-x-0 top-1/2",style:{borderTop:`1px solid ${n.divider}`}}),e("div",{className:"relative flex justify-center",children:e("span",{className:"px-2 text-xs uppercase tracking-wide",style:{background:n.cardBg,color:n.muted,fontFamily:n.fontFamily},children:"or"})})]}),gn={type:"moyasar",label:"Moyasar",FormComponent:({skin:n,onReady:r})=>{const{paymentInit:o}=Rn(),a=o&&"moyasar"===o.provider?o:null,s=function(){const[e,t]=i(!1);return p(()=>{if("undefined"==typeof window)return;const e=window.ApplePaySession;if(e&&"function"==typeof e.canMakePayments)try{t(!0===e.canMakePayments())}catch{t(!1)}},[]),e}(),l=c(r);if(l.current=r,p(()=>{l.current?.()},[]),!a)return null;const u=a.config.methods??yn,d=u.includes("creditcard"),f=u.includes("applepay")&&s;return t("div",{className:"space-y-4",children:[d&&e(pn,{skin:n}),d&&f&&e(hn,{skin:n}),f&&e(mt,{skin:n})]})}},vn="5vh",bn="5vw",wn="aiatcore-chargebee-modal-style",xn="aiatcore-chargebee-close-button",Sn="aiatcore-chargebee-loader",En="aiatcore-cb-spin",Cn='#cb-container, .cb-container, [id^="cb-modal"], [class*="cb-modal"], [class*="cb-checkout"], div[class*="cb-"][class*="overlay"]',kn="aiatcore-chargebee-open";function Pn(){document.getElementById(xn)?.remove()}function On(){document.getElementById(Sn)?.remove()}const _n={type:"chargebee",label:"Chargebee",FormComponent:({amount:e,currency:t,onReady:n})=>{const{paymentInit:r}=Rn(),o=Be(),a=Ue(),i=ze(),s=c(!1);return p(()=>(i(null),()=>i(null)),[i]),p(()=>{if("chargebee"!==r?.provider)return;const{site:i,hosted_page_url:c,amount:l,currency:u,expires_at:d}=r.config,p=l??e,f=u??t;null!=p&&f&&a({amount:p,currency:f}),s.current=!1;let m=!1,y=null,h=null;const g=e=>{s.current||(s.current=!0,o(e))};return n?.(),null!=d&&Date.now()>=1e3*d?(g({status:"failure",provider:"chargebee",message:"Payment link has expired. Please request a new one."}),()=>{m=!0}):(function(){const e=document.getElementById(wn)??document.createElement("style");e.id=wn,e.textContent=`\n /* Prevent horizontal page scroll only while Chargebee's overlay is mounted */\n html.${kn}, body.${kn} {\n overflow-x: hidden !important;\n }\n\n /* Outer Chargebee overlay container — broad selector net so we catch\n whatever wrapper Chargebee actually uses */\n #cb-container,\n .cb-container,\n [id^="cb-modal"],\n [class*="cb-modal"],\n [class*="cb-checkout"],\n div[class*="cb-"][class*="overlay"] {\n position: fixed !important;\n inset: ${vn} max(${bn}, calc((100vw - 1500px) / 2)) !important;\n width: auto !important;\n height: auto !important;\n max-width: none !important;\n max-height: none !important;\n margin: 0 !important;\n border-radius: 12px !important;\n box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;\n overflow: hidden !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n }\n\n /* Inner iframe — fill the container fully and ensure it receives clicks */\n [id^="cb-frame"] {\n width: 100% !important;\n height: 100% !important;\n border: none !important;\n display: block !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n outline: none !important;\n box-shadow: none !important;\n }\n\n @keyframes ${En} {\n to { transform: rotate(360deg); }\n }\n `,e.parentElement||document.head.appendChild(e),document.documentElement.classList.add(kn),document.body.classList.add(kn)}(),function(e){if(window.Chargebee)return Promise.resolve();const t=document.querySelector('script[src*="js.chargebee.com"]');return t?"1"===t.dataset.cbLoaded?Promise.resolve():new Promise((e,n)=>{t.addEventListener("load",()=>e()),t.addEventListener("error",()=>n(new Error("Chargebee.js failed to load")))}):new Promise((t,n)=>{const r=document.createElement("script");r.src="https://js.chargebee.com/v2/chargebee.js",r.setAttribute("data-cb-site",e),r.onload=()=>{r.dataset.cbLoaded="1",t()},r.onerror=()=>n(new Error("Chargebee.js failed to load")),document.head.appendChild(r)})}(i).then(()=>{if(m)return;let e;try{e=window.Chargebee.getInstance()??window.Chargebee.init({site:i})}catch{e=window.Chargebee.init({site:i})}e.openCheckout({hostedPage:()=>Promise.resolve({id:r.payment_id,url:c,type:"checkout_one_time",state:"created"}),success:e=>{Pn(),On(),g({status:"success",provider:"chargebee",paymentId:e,amount:p??void 0,currency:f??void 0})},close:()=>{Pn(),On(),g({status:"cancel",provider:"chargebee"})},error:e=>{Pn(),On(),g({status:"failure",provider:"chargebee",message:e?.message??"Payment failed"})}}),h=function(){let e=0,t=0,n=0,r=null,o=null;const a=Date.now()+5e3,i=()=>{if(m||s.current)return;const t=document.querySelector(Cn);if(t instanceof HTMLElement){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){!function(){On();const e=document.createElement("div");e.id=Sn,e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.style.cssText=`\n position: fixed;\n inset: ${vn} max(${bn}, calc((100vw - 1500px) / 2));\n z-index: 2147483646;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 14px;\n background: #f8f8f8;\n border-radius: 12px;\n color: #6b7280;\n font: 500 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n pointer-events: none;\n `;const t=document.createElement("div");t.style.cssText=`\n width: 32px;\n height: 32px;\n border: 2.5px solid rgba(17, 24, 39, 0.08);\n border-top-color: #6366f1;\n border-radius: 50%;\n animation: ${En} 0.8s linear infinite;\n `;const n=document.createElement("p");n.textContent="Loading payment…",n.style.cssText="margin: 0;",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}();const e=document.querySelector('[id^="cb-frame"]');return void(e instanceof HTMLIFrameElement&&(r=e,o=()=>{n=window.setTimeout(On,400)},r.addEventListener("load",o)))}}Date.now()>=a||(e=window.requestAnimationFrame(i))};return t=window.setTimeout(i,100),()=>{window.clearTimeout(t),window.clearTimeout(n),e&&window.cancelAnimationFrame(e),r&&o&&r.removeEventListener("load",o),On()}}(),y=function(e){let t=0,n=0;const r=Date.now()+5e3,o=()=>{if(m||s.current)return;const n=document.querySelector(Cn);if(n instanceof HTMLElement){const t=n.getBoundingClientRect();if(t.width>0&&t.height>0)return void function(e){Pn();const t=document.createElement("button");t.id=xn,t.type="button",t.setAttribute("aria-label","Close payment"),t.textContent="×",t.style.cssText=`\n position: fixed;\n top: calc(${vn} + 12px);\n right: calc(max(${bn}, calc((100vw - 1500px) / 2)) + 12px);\n z-index: 2147483647;\n width: 32px;\n height: 32px;\n border: 0;\n border-radius: 9999px;\n background: rgba(17, 24, 39, 0.72);\n color: #ffffff;\n font: 600 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n cursor: pointer;\n pointer-events: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);\n `,t.addEventListener("click",e),document.body.appendChild(t)}(e)}Date.now()>=r||(t=window.requestAnimationFrame(o))};return n=window.setTimeout(o,100),()=>{window.clearTimeout(n),t&&window.cancelAnimationFrame(t)}}(()=>{Pn(),On(),document.querySelectorAll(Cn).forEach(e=>{e instanceof HTMLElement&&(e.style.display="none")}),g({status:"cancel",provider:"chargebee"});try{e.closeAll()}catch{}})}).catch(e=>{g({status:"failure",provider:"chargebee",message:e?.message??"Failed to load payment form"})}),()=>{m=!0,y?.(),h?.(),Pn(),On(),document.documentElement.classList.remove(kn),document.body.classList.remove(kn),document.getElementById(wn)?.remove();try{window.Chargebee?.getInstance?.()?.closeAll?.()}catch{}})},[r,e,t,a,n,o]),null},hideShellSubmit:!0},jn="atb-payment";function An(){const e=document.createElement("div");e.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:scroll;",document.body.appendChild(e);const t=e.offsetWidth-e.clientWidth;return e.remove(),Math.max(0,t)}const In=({init:n,onResult:r,skin:o})=>{const a=c(null),u=c(!1),d=c(!1),[f,m]=i(!1),[y]=i(An),h=l(()=>g(n.config.url),[n.config.url]),O=n.payment_id,_=s((e,t={})=>{u.current||(u.current=!0,N.info({message:"[atb] outcome",api_name:jn,reference_id:O,outcome:e}),r(v({outcome:e,init:n,...t})))},[n,O,r]),j=s(()=>{d.current=!0,m(!0)},[]);return p(()=>{if(!h)return;const e=e=>{if(e.source!==a.current?.contentWindow)return;if(e.origin!==h)return;if(!S(e.data))return;const{type:t,data:n}=e.data,r=t===E.COMPLETED?C(n):{};switch(N.info({message:"[atb] gateway event",api_name:jn,reference_id:O,type:t,status:r.status??null,checkout_id:r.checkoutId??null}),t){case E.READY:return void j();case E.COMPLETED:return void _(P(r.status),{checkoutId:r.checkoutId});case E.ERROR:return void _(b.FAILED,{message:x.SESSION_INVALID,code:w.SESSION_INVALID});case E.REDIRECT:{const e=k(n);if(!e)return void N.warn({message:"ATB wallet redirect carried no https url",api_name:jn});N.info({message:"[atb] wallet redirect in frame",api_name:jn,reference_id:O}),a.current&&(a.current.src=e)}}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[h,O,j,_]),p(()=>{const e=setTimeout(()=>{d.current||_(b.FAILED,{message:x.LOAD_FAILED,code:w.LOAD_FAILED})},6e4);return()=>clearTimeout(e)},[_]),e("div",{className:"absolute inset-0 z-[105] flex flex-col overflow-hidden",style:{background:o.cardBg},role:"region","aria-label":"Payment",children:t("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[!f&&e("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:o.muted,fontFamily:o.fontFamily},children:"Loading…"}),e("iframe",{ref:a,src:n.config.url,title:"Payment",className:"min-h-0 flex-1 "+(f?"":"invisible"),style:{border:0,background:"white",width:`calc(100% + ${y}px)`},allow:"payment",referrerPolicy:"no-referrer"})]})})},Nn=({init:t,skin:n})=>{const r=Be(),[o]=i(()=>!O(t.config.url)),a=c(!1);return p(()=>{o&&!a.current&&(a.current=!0,N.warn({message:"ATB checkout url is not https",api_name:"atb-payment",reference_id:t.payment_id}),r(v({outcome:b.FAILED,init:t,message:x.SESSION_INVALID,code:w.SESSION_INVALID})))},[o,t,r]),o?null:e(In,{init:t,onResult:r,skin:n})},Tn={type:"atb",label:"ATB",hideShellSubmit:!0,hideShellFooter:!0,FormComponent:({skin:t,onReady:n})=>{const{paymentInit:r}=Rn(),o="atb"===r?.provider?r:null;return p(()=>{n?.()},[n]),o?e(Nn,{init:o,skin:t},o.payment_id):null}},Mn=u(void 0),Fn=({children:t,paymentProvider:n,paymentInit:r=null,conversationId:o=null})=>{const a=r?.provider||n||_,i=l(()=>function(e){switch(e){case"stripe":return ot;case"moyasar":return gn;case"chargebee":return _n;case"atb":return Tn;default:throw new Error(`Unknown payment provider: "${e}". Supported providers: stripe, moyasar, chargebee, atb`)}}(a),[a]),c=l(()=>({adapter:i,paymentProvider:a,paymentInit:r,conversationId:o}),[i,a,r,o]),s=i.ProviderWrapper;return e(Mn.Provider,{value:c,children:s?e(s,{children:t}):t})},Rn=()=>{const e=d(Mn);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e},$n=({provider:t,paymentInit:n=null,onResult:r,conversationId:o=null})=>e(Fn,{paymentInit:n,conversationId:o,paymentProvider:T(),children:e(Ve,{onResult:e=>{r?.(e)},children:e(Dn,{provider:t,paymentInit:n})})},n?.provider??"default"),Dn=({provider:n,paymentInit:r})=>{const{themeStyles:o,theme:a}=A(),{adapter:c}=Rn(),u=Le().summary,[d,p]=i(!1),f=s(()=>p(!0),[]),y=l(()=>m(o,a),[o,a]),h="moyasar"===r?.provider?r.config:null,g="chargebee"===r?.provider?r.config:null,v=u?.amount??h?.amount??g?.amount??0,b=u?.currency??h?.currency??g?.currency??"usd",w=null!=u?.amount||null!=h?.amount||null!=g?.amount,x=((e,t)=>j(e,t)??"")(v,b),S=n??c.label,E=c.FormComponent;return t("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:y.pageBg,color:y.text,fontFamily:y.fontFamily,colorScheme:y.colorScheme},children:[!d&&e(Vn,{skin:y}),e("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:d?"visible":"hidden"},children:t("div",{className:"w-full max-w-lg p-6",style:{background:y.cardBg,borderRadius:y.radius,boxShadow:y.cardShadow,color:y.text},children:[e("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:y.heading},children:"Payment Options"}),e("div",{className:"mb-3.5",children:e(E,{amount:v,currency:b,skin:y,onReady:f})}),!c.hideShellSubmit&&w&&e(Ln,{label:`Pay ${x}`,background:o.statusDiscovery.solid,color:o.statusDiscovery.text,radius:y.radius}),!c.hideShellFooter&&t("p",{className:"text-xs text-center mt-2.5",style:{color:y.muted},children:["Powered by ",S]})]})})]})},Vn=({skin:n})=>t("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:n.pageBg,color:n.text},"aria-live":"polite","aria-busy":"true",children:[e(V,{className:"h-8 w-8 animate-spin",style:{color:n.accent}}),e("p",{className:"text-sm",style:{color:n.muted},children:"Loading payment…"})]}),Ln=({label:t,background:n,color:r,radius:o})=>{const a=Le().confirmHandle;return e("button",{type:"button",onClick:()=>a?.confirm(),disabled:!a||a.isConfirming,className:"w-full p-3 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:n,color:r,borderRadius:o},children:a?.isConfirming?"Processing…":t})};export{$n as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as u}from"react/jsx-runtime";import{useEffect as m,useRef as a,useState as s}from"react";import{ATB_FAILURE_CODES as i,ATB_FAILURE_MESSAGES as p,ATB_OUTCOMES as c,buildAtbResult as l,isAtbCheckoutUrl as A}from"@1interface/chat-core";import{logger as y}from"@1interface/shared-core";import{usePaymentAdapter as b}from"../PaymentProvider";import{useResultEmitter as f}from"../PaymentResultChannel";import{AtbCheckoutFrame as S}from"./atb/AtbCheckoutFrame";const d=({init:t,skin:n})=>{const r=f(),[e]=s(()=>!A(t.config.url)),o=a(!1);return m(()=>{!e||o.current||(o.current=!0,y.warn({message:"ATB checkout url is not https",api_name:"atb-payment",reference_id:t.payment_id}),r(l({outcome:c.FAILED,init:t,message:p.SESSION_INVALID,code:i.SESSION_INVALID})))},[e,t,r]),e?null:u(S,{init:t,onResult:r,skin:n})},E=({skin:t,onReady:n})=>{const{paymentInit:r}=b(),e=r?.provider==="atb"?r:null;return m(()=>{n?.()},[n]),e?u(d,{init:e,skin:t},e.payment_id):null},R={type:"atb",label:"ATB",hideShellSubmit:!0,hideShellFooter:!0,FormComponent:E};export{R as atbPaymentAdapter};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import{useEffect as S,useRef as k}from"react";import{useConfirmRegistration as D,useResultEmitter as O,useSummaryReporter as F}from"../PaymentResultChannel";import{usePaymentAdapter as H}from"../PaymentProvider";import{CHARGEBEE_MODAL_INSET_H as v,CHARGEBEE_MODAL_INSET_V as w,CHARGEBEE_MODAL_MAX_WIDTH_PX as E}from"./chargebeeModalSize";function $(e){if(window.Chargebee)return Promise.resolve();const t=document.querySelector('script[src*="js.chargebee.com"]');return t?t.dataset.cbLoaded==="1"?Promise.resolve():new Promise((n,r)=>{t.addEventListener("load",()=>n()),t.addEventListener("error",()=>r(new Error("Chargebee.js failed to load")))}):new Promise((n,r)=>{const o=document.createElement("script");o.src="https://js.chargebee.com/v2/chargebee.js",o.setAttribute("data-cb-site",e),o.onload=()=>{o.dataset.cbLoaded="1",n()},o.onerror=()=>r(new Error("Chargebee.js failed to load")),document.head.appendChild(o)})}const x="aiatcore-chargebee-modal-style",T="aiatcore-chargebee-close-button",P="aiatcore-chargebee-loader",B="aiatcore-cb-spin",_='#cb-container, .cb-container, [id^="cb-modal"], [class*="cb-modal"], [class*="cb-checkout"], div[class*="cb-"][class*="overlay"]',u="aiatcore-chargebee-open";function j(){const e=document.getElementById(x)??document.createElement("style");e.id=x,e.textContent=`
|
|
2
|
-
/* Prevent horizontal page scroll only while Chargebee's overlay is mounted */
|
|
3
|
-
html.${u}, body.${u} {
|
|
4
|
-
overflow-x: hidden !important;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/* Outer Chargebee overlay container \u2014 broad selector net so we catch
|
|
8
|
-
whatever wrapper Chargebee actually uses */
|
|
9
|
-
#cb-container,
|
|
10
|
-
.cb-container,
|
|
11
|
-
[id^="cb-modal"],
|
|
12
|
-
[class*="cb-modal"],
|
|
13
|
-
[class*="cb-checkout"],
|
|
14
|
-
div[class*="cb-"][class*="overlay"] {
|
|
15
|
-
position: fixed !important;
|
|
16
|
-
inset: ${w} max(${v}, calc((100vw - ${E}px) / 2)) !important;
|
|
17
|
-
width: auto !important;
|
|
18
|
-
height: auto !important;
|
|
19
|
-
max-width: none !important;
|
|
20
|
-
max-height: none !important;
|
|
21
|
-
margin: 0 !important;
|
|
22
|
-
border-radius: 12px !important;
|
|
23
|
-
box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;
|
|
24
|
-
overflow: hidden !important;
|
|
25
|
-
z-index: 2147483646 !important;
|
|
26
|
-
pointer-events: all !important;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Inner iframe \u2014 fill the container fully and ensure it receives clicks */
|
|
30
|
-
[id^="cb-frame"] {
|
|
31
|
-
width: 100% !important;
|
|
32
|
-
height: 100% !important;
|
|
33
|
-
border: none !important;
|
|
34
|
-
display: block !important;
|
|
35
|
-
z-index: 2147483646 !important;
|
|
36
|
-
pointer-events: all !important;
|
|
37
|
-
outline: none !important;
|
|
38
|
-
box-shadow: none !important;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@keyframes ${B} {
|
|
42
|
-
to { transform: rotate(360deg); }
|
|
43
|
-
}
|
|
44
|
-
`,e.parentElement||document.head.appendChild(e),document.documentElement.classList.add(u),document.body.classList.add(u)}function q(){document.documentElement.classList.remove(u),document.body.classList.remove(u),document.getElementById(x)?.remove()}function p(){document.getElementById(T)?.remove()}function N(){document.querySelectorAll(_).forEach(e=>{e instanceof HTMLElement&&(e.style.display="none")})}function z(e){p();const t=document.createElement("button");t.id=T,t.type="button",t.setAttribute("aria-label","Close payment"),t.textContent="\xD7",t.style.cssText=`
|
|
45
|
-
position: fixed;
|
|
46
|
-
top: calc(${w} + 12px);
|
|
47
|
-
right: calc(max(${v}, calc((100vw - ${E}px) / 2)) + 12px);
|
|
48
|
-
z-index: 2147483647;
|
|
49
|
-
width: 32px;
|
|
50
|
-
height: 32px;
|
|
51
|
-
border: 0;
|
|
52
|
-
border-radius: 9999px;
|
|
53
|
-
background: rgba(17, 24, 39, 0.72);
|
|
54
|
-
color: #ffffff;
|
|
55
|
-
font: 600 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
pointer-events: auto;
|
|
58
|
-
display: flex;
|
|
59
|
-
align-items: center;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
|
|
62
|
-
`,t.addEventListener("click",e),document.body.appendChild(t)}const R=5e3;function l(){document.getElementById(P)?.remove()}function U(){l();const e=document.createElement("div");e.id=P,e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.style.cssText=`
|
|
63
|
-
position: fixed;
|
|
64
|
-
inset: ${w} max(${v}, calc((100vw - ${E}px) / 2));
|
|
65
|
-
z-index: 2147483646;
|
|
66
|
-
display: flex;
|
|
67
|
-
flex-direction: column;
|
|
68
|
-
align-items: center;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
gap: 14px;
|
|
71
|
-
background: #f8f8f8;
|
|
72
|
-
border-radius: 12px;
|
|
73
|
-
color: #6b7280;
|
|
74
|
-
font: 500 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
75
|
-
pointer-events: none;
|
|
76
|
-
`;const t=document.createElement("div");t.style.cssText=`
|
|
77
|
-
width: 32px;
|
|
78
|
-
height: 32px;
|
|
79
|
-
border: 2.5px solid rgba(17, 24, 39, 0.08);
|
|
80
|
-
border-top-color: #6366f1;
|
|
81
|
-
border-radius: 50%;
|
|
82
|
-
animation: ${B} 0.8s linear infinite;
|
|
83
|
-
`;const n=document.createElement("p");n.textContent="Loading payment\u2026",n.style.cssText="margin: 0;",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}const W=400;function G(e){let t=0,n=0,r=0,o=null,i=null;const c=Date.now()+R,a=()=>{if(e())return;const d=document.querySelector(_);if(d instanceof HTMLElement){const f=d.getBoundingClientRect();if(f.width>0&&f.height>0){U();const g=document.querySelector('[id^="cb-frame"]');g instanceof HTMLIFrameElement&&(o=g,i=()=>{r=window.setTimeout(l,W)},o.addEventListener("load",i));return}}Date.now()>=c||(t=window.requestAnimationFrame(a))};return n=window.setTimeout(a,100),()=>{window.clearTimeout(n),window.clearTimeout(r),t&&window.cancelAnimationFrame(t),o&&i&&o.removeEventListener("load",i),l()}}function Y(e,t){let n=0,r=0;const o=Date.now()+R,i=()=>{if(t())return;const c=document.querySelector(_);if(c instanceof HTMLElement){const a=c.getBoundingClientRect();if(a.width>0&&a.height>0){z(e);return}}Date.now()>=o||(n=window.requestAnimationFrame(i))};return r=window.setTimeout(i,100),()=>{window.clearTimeout(r),n&&window.cancelAnimationFrame(n)}}const V=({amount:e,currency:t,onReady:n})=>{const{paymentInit:r}=H(),o=O(),i=F(),c=D(),a=k(!1);return S(()=>(c(null),()=>c(null)),[c]),S(()=>{if(r?.provider!=="chargebee")return;const{site:d,hosted_page_url:f,amount:g,currency:M,expires_at:L}=r.config,b=g??e,y=M??t;b!=null&&y&&i({amount:b,currency:y}),a.current=!1;let h=!1,A=null,I=null;const m=s=>{a.current||(a.current=!0,o(s))};return n?.(),L!=null&&Date.now()>=L*1e3?(m({status:"failure",provider:"chargebee",message:"Payment link has expired. Please request a new one."}),()=>{h=!0}):(j(),$(d).then(()=>{if(h)return;let s;try{s=window.Chargebee.getInstance()??window.Chargebee.init({site:d})}catch{s=window.Chargebee.init({site:d})}s.openCheckout({hostedPage:()=>Promise.resolve({id:r.payment_id,url:f,type:"checkout_one_time",state:"created"}),success:C=>{p(),l(),m({status:"success",provider:"chargebee",paymentId:C,amount:b??void 0,currency:y??void 0})},close:()=>{p(),l(),m({status:"cancel",provider:"chargebee"})},error:C=>{p(),l(),m({status:"failure",provider:"chargebee",message:C?.message??"Payment failed"})}}),I=G(()=>h||a.current),A=Y(()=>{p(),l(),N(),m({status:"cancel",provider:"chargebee"});try{s.closeAll()}catch{}},()=>h||a.current)}).catch(s=>{m({status:"failure",provider:"chargebee",message:s?.message??"Failed to load payment form"})}),()=>{h=!0,A?.(),I?.(),p(),l(),q();try{window.Chargebee?.getInstance?.()?.closeAll?.()}catch{}})},[r,e,t,i,n,o]),null},ee={type:"chargebee",label:"Chargebee",FormComponent:V,hideShellSubmit:!0};export{ee as chargebeePaymentAdapter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as t,jsxs as c}from"react/jsx-runtime";import{useEffect as d,useRef as l}from"react";import{usePaymentAdapter as y}from"../PaymentProvider";import{ApplePayButton as u}from"./moyasar/ApplePayButton";import{CustomCardForm as f}from"./moyasar/CustomCardForm";import{useApplePaySupported as P}from"./moyasar/useApplePaySupported";const v=["creditcard","applepay"],F=({skin:e,onReady:o})=>{const{paymentInit:a}=y(),r=a&&a.provider==="moyasar"?a:null,i=P(),s=l(o);if(s.current=o,d(()=>{s.current?.()},[]),!r)return null;const n=r.config.methods??v,p=n.includes("creditcard"),m=n.includes("applepay")&&i;return c("div",{className:"space-y-4",children:[p&&t(f,{skin:e}),p&&m&&t(A,{skin:e}),m&&t(u,{skin:e})]})},A=({skin:e})=>c("div",{className:"relative",children:[t("div",{className:"absolute inset-x-0 top-1/2",style:{borderTop:`1px solid ${e.divider}`}}),t("div",{className:"relative flex justify-center",children:t("span",{className:"px-2 text-xs uppercase tracking-wide",style:{background:e.cardBg,color:e.muted,fontFamily:e.fontFamily},children:"or"})})]}),b={type:"moyasar",label:"Moyasar",FormComponent:F};export{b as moyasarPaymentAdapter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as d}from"react/jsx-runtime";import{useCallback as C,useEffect as S,useMemo as y,useState as v}from"react";import{Elements as E,PaymentElement as R,useElements as b,useStripe as g}from"@stripe/react-stripe-js";import{buildBrandSkin as F}from"@1interface/chat-core";import{useBranding as I}from"@1interface/shared-core";import{useConfirmRegistration as h,useResultEmitter as w,useSummaryReporter as A}from"../PaymentResultChannel";import{usePaymentAdapter as P}from"../PaymentProvider";import{buildStripeAppearance as _,StripeProviderWrapper as k,useStripeContext as O}from"./stripe";const q=({amount:l,currency:r,skin:m,onReady:u})=>{const{themeStyles:o,theme:n}=I(),{stripePromise:a}=O(),{paymentInit:c}=P(),p=y(()=>F(o,n),[o,n]),t=y(()=>_(o,n,p),[o,n,p]),i=c?.provider==="stripe"?c.config.client_secret:null,s=y(()=>i?{clientSecret:i,appearance:t}:null,[i,t]);return!a||!s?null:d(E,{stripe:a,options:s,children:d(B,{onReady:u})},i)},B=({onReady:l})=>{const r=g(),m=b(),{paymentInit:u}=P(),o=w(),n=h(),a=A(),[c,p]=v(!1),t=u?.provider==="stripe"?u.config.client_secret:null;S(()=>{if(!r||!t)return;let s=!1;return r.retrievePaymentIntent(t).then(f=>{if(s)return;const e=f.paymentIntent;e&&typeof e.amount=="number"&&e.currency&&a({amount:e.amount,currency:e.currency})}),()=>{s=!0}},[r,t,a]);const i=C(async()=>{if(!r||!m||!t)return;p(!0);const{error:s}=await m.submit();if(s){p(!1);return}const{error:f,paymentIntent:e}=await r.confirmPayment({elements:m,clientSecret:t,confirmParams:{return_url:window.location.href},redirect:"if_required"});p(!1),!f&&e&&(e.status==="succeeded"||e.status==="requires_capture")&&o({status:"success",provider:"stripe",paymentId:e.id,amount:e.amount,currency:e.currency})},[r,m,t,o]);return S(()=>(n({confirm:i,isConfirming:c}),()=>n(null)),[i,c,n]),d(R,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:l})},J={type:"stripe",label:"Stripe",ProviderWrapper:k,FormComponent:q};export{J as stripePaymentAdapter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const E=1500,_="5vh",A="5vw";export{A as CHARGEBEE_MODAL_INSET_H,_ as CHARGEBEE_MODAL_INSET_V,E as CHARGEBEE_MODAL_MAX_WIDTH_PX};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{stripePaymentAdapter as t}from"./StripePaymentAdapter";import{moyasarPaymentAdapter as m}from"./MoyasarPaymentAdapter";import{chargebeePaymentAdapter as p}from"./ChargebeePaymentAdapter";import{atbPaymentAdapter as d}from"./AtbPaymentAdapter";export{d as atbPaymentAdapter,p as chargebeePaymentAdapter,m as moyasarPaymentAdapter,t as stripePaymentAdapter};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{Fragment as q,jsx as A,jsxs as z}from"react/jsx-runtime";import{useCallback as U,useEffect as k,useRef as C,useState as E}from"react";import{buildCallbackUrl as T}from"@1interface/chat-core";import{showErrorToast as u}from"@1interface/shared-core";import{usePaymentAdapter as R}from"../../PaymentProvider";import{useResultEmitter as w}from"../../PaymentResultChannel";import{buildMetadata as I}from"./metadata";import{createPayment as L,MoyasarApiError as F}from"./api";import{validateApplePayMerchant as M}from"./applePayApi";import{Moyasar3DSIframe as N}from"./Moyasar3DSIframe";const D=5,x="SA",O=["mada","visa","masterCard"],b="data-aiatcore-apple-pay";function Y(){if(typeof document>"u"||document.querySelector(`style[${b}]`))return;const i=document.createElement("style");i.setAttribute(b,"true"),i.textContent=`
|
|
2
|
-
.aiatcore-apple-pay-button {
|
|
3
|
-
-webkit-appearance: -apple-pay-button;
|
|
4
|
-
-apple-pay-button-type: pay;
|
|
5
|
-
-apple-pay-button-style: black;
|
|
6
|
-
width: 100%;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
border: none;
|
|
9
|
-
padding: 0;
|
|
10
|
-
margin: 0;
|
|
11
|
-
}
|
|
12
|
-
`,document.head.appendChild(i)}const X=({skin:i})=>{const{paymentInit:p}=R(),e=p&&p.provider==="moyasar"?p:null,s=w(),[m,y]=E(null),d=C(s);d.current=s,k(()=>{Y()},[]);const P=U(()=>{if(!e)return;const o=window.ApplePaySession;if(!o){u("Apple Pay is not available on this device.");return}const f=e.config.apple_pay?.label??e.config.description??"Payment",v=e.config.apple_pay?.country??x,g=e.config.currency.toUpperCase(),h=(e.config.amount/100).toFixed(2),_={countryCode:v,currencyCode:g,supportedNetworks:O,merchantCapabilities:["supports3DS","supportsDebit","supportsCredit"],total:{label:f,amount:h}};let a;try{a=new o(D,_)}catch(r){u(r instanceof Error?r.message:"Failed to start Apple Pay");return}a.onvalidatemerchant=async r=>{try{const n=await M({validationUrl:r.validationURL,displayName:f,publishableApiKey:e.config.publishable_key});a.completeMerchantValidation(n)}catch(n){const t=n instanceof Error?n.message:"Merchant validation failed";a.abort(),s({status:"failure",provider:"moyasar",message:t,paymentId:e.config.given_id})}},a.onpaymentauthorized=async r=>{try{const n=I(e),t=await L({publishable_api_key:e.config.publishable_key,given_id:e.config.given_id,amount:e.config.amount,currency:g,description:e.config.description,callback_url:T(e.config.given_id),source:{type:"applepay",token:r.payment.token},...Object.keys(n).length>0?{metadata:n}:{}}),S=t.source?.transaction_url??t.transaction_url;if(S){a.completePayment({status:o.STATUS_SUCCESS}),y(S);return}const c=t.status;if(c==="paid"||c==="authorized"||c==="captured")a.completePayment({status:o.STATUS_SUCCESS}),s({status:"success",provider:"moyasar",paymentId:t.id,amount:t.amount,currency:t.currency});else if(c==="failed"){const l=t.source?.message??"Payment failed";a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",code:"failed",message:l,paymentId:t.id})}else{const l=`Unexpected payment status: ${c}`;a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",code:c,message:l,paymentId:t.id})}}catch(n){const t=n instanceof F||n instanceof Error?n.message:"Payment failed";a.completePayment({status:o.STATUS_FAILURE}),s({status:"failure",provider:"moyasar",message:t,paymentId:e.config.given_id})}},a.oncancel=()=>{};try{a.begin()}catch(r){u(r instanceof Error?r.message:"Failed to start Apple Pay")}},[e,s]);return e?z(q,{children:[A("button",{type:"button",onClick:P,className:"aiatcore-apple-pay-button",style:{borderRadius:i.radius,height:44},"aria-label":"Pay with Apple Pay"}),m&&A(N,{url:m,skin:i,onResult:o=>{y(null),d.current(o)}})]}):null};export{X as ApplePayButton};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";const g=({brand:t,fallbackColor:r,height:i=22})=>{if(!t)return null;switch(t){case"Visa":return e(a,{height:i});case"Mastercard":return e(c,{height:i});case"American Express":return e(s,{height:i});case"Mada":return e(n,{height:i});case"Discover":return e(o,{height:i});case"JCB":return e(h,{height:i});default:return e("span",{className:"text-xs font-medium",style:{color:r},"aria-label":`Card brand: ${t}`,children:t})}},a=({height:t})=>l("svg",{role:"img","aria-label":"Visa",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#1A1F71"}),e("text",{x:"24",y:"12",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"11",fill:"#FFFFFF",letterSpacing:"1.4",children:"VISA"})]}),c=({height:t})=>l("svg",{role:"img","aria-label":"Mastercard",viewBox:"0 0 32 20",height:t,width:t*32/20,style:{display:"block"},children:[e("circle",{cx:"12",cy:"10",r:"7",fill:"#EB001B"}),e("circle",{cx:"20",cy:"10",r:"7",fill:"#F79E1B"}),e("path",{d:"M16 4.5a7 7 0 0 1 0 11 7 7 0 0 1 0-11Z",fill:"#FF5F00","aria-hidden":"true"})]}),s=({height:t})=>l("svg",{role:"img","aria-label":"American Express",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#2E77BB"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.4",children:"AMEX"})]}),n=({height:t})=>l("svg",{role:"img","aria-label":"Mada",viewBox:"0 0 48 16",height:t,width:t*48/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#84B740"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.6",children:"mada"})]}),o=({height:t})=>l("svg",{role:"img","aria-label":"Discover",viewBox:"0 0 56 16",height:t,width:t*56/16,style:{display:"block"},children:[e("rect",{width:"56",height:"16",rx:"2",fill:"#FFFFFF",stroke:"#E5E7EB"}),e("text",{x:"20",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"8",fill:"#231F20",letterSpacing:"0.2",children:"DISCOVER"}),e("circle",{cx:"44",cy:"8",r:"4",fill:"#FF6000"})]}),h=({height:t})=>l("svg",{role:"img","aria-label":"JCB",viewBox:"0 0 32 16",height:t,width:t*32/16,style:{display:"block"},children:[e("rect",{x:"0",y:"0",width:"10.66",height:"16",rx:"2",fill:"#0E4C96"}),e("rect",{x:"10.66",y:"0",width:"10.66",height:"16",fill:"#B41E25"}),e("rect",{x:"21.33",y:"0",width:"10.66",height:"16",rx:"2",fill:"#1B8A3A"}),e("text",{x:"16",y:"11",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"9",fill:"#FFFFFF",children:"JCB"})]});export{g as CardBrandIcon};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fragment as ne,jsx as i,jsxs as M}from"react/jsx-runtime";import{useCallback as K,useEffect as T,useLayoutEffect as z,useMemo as A,useRef as S,useState as C}from"react";import{buildCallbackUrl as Y}from"@1interface/chat-core";import{usePaymentAdapter as $}from"../../PaymentProvider";import{useConfirmRegistration as O,useResultEmitter as V,useSummaryReporter as j}from"../../PaymentResultChannel";import{buildMetadata as q}from"./metadata";import{createPayment as G,MoyasarApiError as J,tokenizeCard as Q}from"./api";import{detectCardBrand as W,formatCardNumber as X,formatCvc as Z,formatExpiry as ee,validateCard as te}from"./cardValidation";import{Moyasar3DSIframe as re}from"./Moyasar3DSIframe";import{CardBrandIcon as ae}from"./CardBrandIcon";const ge=({skin:a})=>{const{paymentInit:l}=$(),e=l&&l.provider==="moyasar"?l:null,g=V(),h=O(),R=j(),[u,y]=C(""),[x,k]=C(""),[E,b]=C(""),[p,N]=C(""),[_,I]=C(!1),[t,n]=C({}),[o,s]=C(null),F=S({number:u,expiry:x,cvc:E,name:p});F.current={number:u,expiry:x,cvc:E,name:p};const m=S(g);m.current=g,T(()=>{e&&R({amount:e.config.amount,currency:e.config.currency.toUpperCase()})},[e,R]);const U=K(async()=>{if(!e)return;const r=te(F.current);if(r.ok===!1){const c={};for(const f of r.errors)c[f.field]||(c[f.field]=f.message);n(c);return}n({}),I(!0);try{const c=await Q({publishable_api_key:e.config.publishable_key,name:r.card.name,number:r.card.number,month:r.card.month,year:r.card.year,cvc:r.card.cvc}),f=q(e),d=await G({publishable_api_key:e.config.publishable_key,given_id:e.config.given_id,amount:e.config.amount,currency:e.config.currency.toUpperCase(),description:e.config.description,callback_url:Y(e.config.given_id),source:{type:"token",token:c.id},...Object.keys(f).length>0?{metadata:f}:{}}),L=d.source?.transaction_url??d.transaction_url;if(L){s(L);return}const v=d.status;if(v==="paid"||v==="authorized"||v==="captured")m.current({status:"success",provider:"moyasar",paymentId:d.id,amount:d.amount,currency:d.currency});else if(v==="failed"){const D=d.source?.message??"Payment failed";m.current({status:"failure",provider:"moyasar",code:"failed",message:D,paymentId:d.id})}else{const D=`Unexpected payment status: ${v}`;m.current({status:"failure",provider:"moyasar",code:v,message:D,paymentId:d.id})}}catch(c){const f=c instanceof J||c instanceof Error?c.message:"Payment failed";m.current({status:"failure",provider:"moyasar",message:f,paymentId:e.config.given_id})}finally{I(!1)}},[e]);T(()=>(h({confirm:U,isConfirming:_}),()=>h(null)),[U,_,h]);const P=A(()=>Math.max(a.radius-4,4),[a.radius]),B=A(()=>W(u),[u]);return e?M(ne,{children:[M("div",{className:"space-y-3",style:{fontFamily:a.fontFamily},children:[i(w,{label:"Card number",value:u,onChange:r=>y(X(r)),autoComplete:"cc-number",inputMode:"numeric",placeholder:"1234 5678 9012 3456",error:t.number,skin:a,radius:P,endAdornment:B?i(ae,{brand:B,fallbackColor:a.muted}):null}),M("div",{className:"grid grid-cols-2 gap-3",children:[i(w,{label:"Expiry",value:x,onChange:r=>k(ee(r)),autoComplete:"cc-exp",inputMode:"numeric",placeholder:"MM / YY",error:t.expiry,skin:a,radius:P}),i(w,{label:"CVC",value:E,onChange:r=>b(Z(r)),autoComplete:"cc-csc",inputMode:"numeric",placeholder:"123",error:t.cvc,skin:a,radius:P})]}),i(w,{label:"Name on card",value:p,onChange:N,autoComplete:"cc-name",inputMode:"text",placeholder:"Full name",error:t.name,skin:a,radius:P})]}),o&&i(re,{url:o,skin:a,onResult:r=>{s(null),m.current(r)}})]}):null};function H(a){let l=0;for(let e=0;e<a.length;e++){const g=a.charCodeAt(e);g>=48&&g<=57&&l++}return l}const w=({label:a,value:l,onChange:e,placeholder:g,autoComplete:h,inputMode:R,error:u,skin:y,radius:x,endAdornment:k})=>{const E=u?"#dc2626":y.divider,b=S(null),p=S(null),N=R==="numeric",_=t=>{if(N){const n=t.target.selectionStart??t.target.value.length;p.current=H(t.target.value.slice(0,n))}e(t.target.value)},I=t=>{if(!N||t.key!=="Backspace")return;const n=t.currentTarget,o=n.selectionStart??0,s=n.selectionEnd??0;if(o!==s||o<2)return;const F=n.value[o-1];if(!F||/\d/.test(F))return;t.preventDefault();const m=n.value.slice(0,o-2)+n.value.slice(o);p.current=H(m.slice(0,o-2)),e(m)};return z(()=>{const t=p.current;if(t===null||!b.current)return;p.current=null;const n=b.current.value;let o=0,s=0;for(;s<n.length&&!(o>=t);)/\d/.test(n[s])&&o++,s++;b.current.setSelectionRange(s,s)},[l]),M("label",{className:"block",children:[i("span",{className:"block text-xs mb-1",style:{color:y.muted},children:a}),M("div",{className:"relative",children:[i("input",{ref:b,type:"text",value:l,onChange:_,onKeyDown:I,placeholder:g,autoComplete:h,inputMode:R,spellCheck:!1,className:"w-full py-3 px-3 outline-none text-sm transition-colors",style:{background:y.pillBg,color:y.text,border:`1px solid ${E}`,borderRadius:x,paddingRight:k?96:void 0}}),k&&i("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium pointer-events-none",style:{color:y.muted},"aria-label":"Card brand",children:k})]}),u&&i("span",{className:"block mt-1 text-xs",style:{color:"#dc2626"},children:u})]})};export{ge as CustomCardForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as f,jsxs as S}from"react/jsx-runtime";import{useCallback as h,useEffect as m,useRef as l,useState as y}from"react";import{parseMoyasarCallbackFromUrl as b}from"@1interface/chat-core";const w="moyasar-iframe-callback",k=6e4;function v(e){if(!e||typeof e!="object")return!1;const a=e;return a.type===w&&typeof a.search=="string"}const E=({url:e,onResult:a,skin:o})=>{const s=l(a);s.current=a;const r=l(!1),[p,g]=y(!1),c=l(!1),n=h(t=>{r.current||(r.current=!0,s.current({status:"failure",provider:"moyasar",message:t}))},[]);return m(()=>{const t=window.location.origin,u=i=>{if(i.origin!==t||r.current||!v(i.data))return;const d=b(i.data.search);d&&(r.current=!0,s.current(d.result))};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),m(()=>{const t=setTimeout(()=>{c.current||n("3D Secure challenge failed to load")},k);return()=>clearTimeout(t)},[n]),S("div",{className:"absolute inset-0 z-[105]",style:{background:o.cardBg},role:"dialog","aria-label":"3D Secure authentication",children:[!p&&f("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:o.muted,fontFamily:o.fontFamily},children:"Loading\u2026"}),f("iframe",{src:e,title:"3D Secure",className:"w-full h-full",style:{border:0,background:"white"},onLoad:()=>{c.current=!0,g(!0)},onError:()=>{n("3D Secure challenge failed to load")},allow:"payment *",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation-by-user-activation",referrerPolicy:"no-referrer"})]})};export{E as Moyasar3DSIframe};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{MOYASAR_API_TIMEOUT_MS as l}from"./constants";const m="https://api.moyasar.com/v1/tokens",g="https://api.moyasar.com/v1/payments";class s extends Error{constructor(t,o,r){super(t);this.status=o;this.body=r;this.name="MoyasarApiError"}}async function k(n){const e=await u(m,{...n,save_only:!0});if(!e.ok)throw new s(c(e.body)??`Tokenization failed (${e.status})`,e.status,e.body);const t=e.body;if(!t||typeof t.id!="string")throw new s("Tokenization returned no token id",e.status,t);return{id:t.id}}async function b(n){const e=await u(g,n);if(!e.ok)throw new s(c(e.body)??`Payment creation failed (${e.status})`,e.status,e.body);const t=e.body;if(!t||typeof t.id!="string"||typeof t.status!="string")throw new s("Payment creation returned no id/status",e.status,t);return t}async function u(n,e){const t=new AbortController,o=setTimeout(()=>t.abort(new DOMException("Request timed out","TimeoutError")),l);let r;try{r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t.signal})}catch(a){const y=a instanceof DOMException&&a.name==="TimeoutError"?"Payment request timed out \u2014 please try again.":a instanceof Error?a.message:"Network request failed";throw new s(y)}finally{clearTimeout(o)}let i=null;try{i=await r.json()}catch{i=null}return{ok:r.ok,status:r.status,body:i}}function c(n){if(!n||typeof n!="object")return null;const e=n;if(typeof e.message=="string"&&e.message.length>0)return e.message;if(e.errors&&typeof e.errors=="object"){const t=e.errors;for(const[o,r]of Object.entries(t)){if(Array.isArray(r)&&typeof r[0]=="string")return`${p(o)}: ${r[0]}`;if(typeof r=="string")return`${p(o)}: ${r}`}}return null}function p(n){return n.replace(/_/g," ")}export{s as MoyasarApiError,b as createPayment,k as tokenizeCard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{MoyasarApiError as r}from"./api";import{MOYASAR_API_TIMEOUT_MS as p}from"./constants";const m="https://api.moyasar.com/v1/applepay/initiate";async function g(e){const t={validation_url:e.validationUrl,display_name:e.displayName,domain_name:e.domainName??window.location.hostname,publishable_api_key:e.publishableApiKey},o=new AbortController,s=setTimeout(()=>o.abort(new DOMException("Request timed out","TimeoutError")),p);let n;try{n=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:o.signal})}catch(i){const l=i instanceof DOMException&&i.name==="TimeoutError"?"Apple Pay merchant validation timed out \u2014 please try again.":i instanceof Error?i.message:"Network request failed";throw new r(l)}finally{clearTimeout(s)}let a=null;try{a=await n.json()}catch{a=null}if(!n.ok)throw new r(c(a)??`Apple Pay merchant validation failed (${n.status})`,n.status,a);return a}function c(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.message=="string"&&t.message.length>0?t.message:null}export{g as validateApplePayMerchant};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import d from"card-validator";import p from"credit-card-type";const C=[440647,440795,446404,446672,419593,428331,428671,432328,440533,446393,457865,458456,462220,484783,484800,493428,504300,521076,529415,535825,536023,537767,543357,557606,558848,588845,589206];let g=!1;function b(){g||(g=!0,p.addCard({niceType:"Mada",type:"mada",patterns:C,gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}))}b();function V(e,n=new Date){const r=[],i=d.number(e.number),t=e.number.replace(/\D/g,"");t?i.isValid||r.push({field:"number",message:"Invalid card number"}):r.push({field:"number",message:"Card number is required"});const s=d.expirationDate(e.expiry);let a=null,c=null;const o=e.expiry.trim();if(!o)r.push({field:"expiry",message:"Expiry is required"});else if(s.isValid){a=Number.parseInt(s.month??"",10);const l=Number.parseInt(s.year??"",10);c=(s.year??"").length===2?l+2e3:l}else{const l=x(o);l&&v(l.month,l.year,n)?r.push({field:"expiry",message:"Card expired"}):r.push({field:"expiry",message:"Invalid expiry"})}const f=i.card?.code.size??[3,4],h=d.cvv(e.cvc,f),m=e.cvc.replace(/\D/g,"");m?h.isValid||r.push({field:"cvc",message:"Invalid CVC"}):r.push({field:"cvc",message:"CVC is required"});const y=d.cardholderName(e.name),u=e.name.trim();return u?y.isValid||r.push({field:"name",message:"Invalid cardholder name"}):r.push({field:"name",message:"Cardholder name is required"}),r.length>0||a==null||c==null?{ok:!1,errors:r}:{ok:!0,card:{number:t,month:String(a).padStart(2,"0"),year:String(c),cvc:m,name:u}}}function x(e){let n="",r="";if(e.includes("/")){const[a,c]=e.split("/");n=(a??"").replace(/\D/g,""),r=(c??"").replace(/\D/g,"")}else{const a=e.replace(/\D/g,"");n=a.slice(0,2),r=a.slice(2)}const i=Number.parseInt(n,10),t=Number.parseInt(r,10);if(Number.isNaN(i)||Number.isNaN(t))return null;const s=r.length===2?t+2e3:t;return{month:i,year:s}}function v(e,n,r){const i=r.getFullYear(),t=r.getMonth()+1;return n<i||n===i&&e<t}function E(e){return e.replace(/\D/g,"").slice(0,19).replace(/(\d{4})(?=\d)/g,"$1 ")}function k(e){const n=e.replace(/\D/g,"").slice(0,4);return n.length<=2?n:`${n.slice(0,2)}/${n.slice(2)}`}function I(e){return e.replace(/\D/g,"").slice(0,4)}function S(e){const n=e.replace(/\D/g,"");return n.length<2?null:p(n)[0]?.niceType??null}export{S as detectCardBrand,E as formatCardNumber,I as formatCvc,k as formatExpiry,V as validateCard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const _=3e4;export{_ as MOYASAR_API_TIMEOUT_MS};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{buildMetadata as a}from"./metadata";import{CustomCardForm as o}from"./CustomCardForm";import{ApplePayButton as y}from"./ApplePayButton";import{createPayment as m,MoyasarApiError as i,tokenizeCard as n}from"./api";import{validateApplePayMerchant as l}from"./applePayApi";import{formatCardNumber as u,formatCvc as f,formatExpiry as P,validateCard as c}from"./cardValidation";export{y as ApplePayButton,o as CustomCardForm,i as MoyasarApiError,a as buildMetadata,m as createPayment,u as formatCardNumber,f as formatCvc,P as formatExpiry,n as tokenizeCard,l as validateApplePayMerchant,c as validateCard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function c(t){const e={};if(t.config.metadata)for(const[o,r]of Object.entries(t.config.metadata))r!=null&&(e[o]=String(r));if(t.config.customer){const{name:o,email:r,phone:n,reference_id:a}=t.config.customer;o&&(e.customer_name=o),r&&(e.customer_email=r),n&&(e.customer_phone=n),a&&(e.customer_reference_id=a)}return e}export{c as buildMetadata};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useEffect as o,useState as a}from"react";function p(){const[t,n]=a(!1);return o(()=>{if(typeof window>"u")return;const e=window.ApplePaySession;if(!(!e||typeof e.canMakePayments!="function"))try{n(e.canMakePayments()===!0)}catch{n(!1)}},[]),t}export{p as useApplePaySupported};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{buildStripeAppearance as p}from"./appearance";import{StripeProviderWrapper as o,useStripeContext as i}from"./providerWrapper";export{o as StripeProviderWrapper,p as buildStripeAppearance,i as useStripeContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as d}from"react/jsx-runtime";import{createContext as s,useContext as l,useEffect as u,useMemo as a,useState as c}from"react";import{loadStripe as m}from"@stripe/stripe-js/pure";import{usePaymentAdapter as S}from"../../PaymentProvider";const i=s(null),v=()=>{const e=l(i);if(!e)throw new Error("Stripe adapter components must be used inside StripeProviderWrapper");return e},y=({children:e})=>{const{paymentInit:r}=S(),[o,p]=c(null),t=r?.provider==="stripe"?r.config.publishable_key:null;u(()=>{t&&t.startsWith("pk_")&&p(m(t))},[t]);const n=a(()=>({stripePromise:o}),[o]);return d(i.Provider,{value:n,children:e})};export{y as StripeProviderWrapper,v as useStripeContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{atbPaymentAdapter as r,chargebeePaymentAdapter as t,moyasarPaymentAdapter as a,stripePaymentAdapter as n}from"./adapters";function o(e){switch(e){case"stripe":return n;case"moyasar":return a;case"chargebee":return t;case"atb":return r;default:throw new Error(`Unknown payment provider: "${e}". Supported providers: stripe, moyasar, chargebee, atb`)}}export{o as createPaymentAdapter};
|
package/native/payment/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{PaymentProvider as t,usePaymentAdapter as m}from"./PaymentProvider";import{createPaymentAdapter as a}from"./createPaymentAdapter";import{PaymentResultChannelProvider as u,useResultEmitter as s,useConfirmRegistration as i,useConfirmHandle as p,useSummaryReporter as d,useReportedSummary as y}from"./PaymentResultChannel";export{t as PaymentProvider,u as PaymentResultChannelProvider,a as createPaymentAdapter,p as useConfirmHandle,i as useConfirmRegistration,m as usePaymentAdapter,y as useReportedSummary,s as useResultEmitter,d as useSummaryReporter};
|