Module 342393

16,357 characters · in no known chunk
Dependencies
Lazily required by (0)none
Requires (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){!function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function i(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach(function(t){s(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function r(e){return(r="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 s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},s=Object.keys(e);for(i=0;i<s.length;i++)n=s[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)n=s[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=e&&("u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var s=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var u,d,c,_,h,f={exports:{}};f.exports=(function(){if(h)return _;h=1;var e=c?d:(c=1,d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");function t(){}function n(){}return n.resetWarningCache=t,_=function(){function i(t,n,i,r,s,a){if(a!==e){var o=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 o.name="Invariant Violation",o}}function r(){return i}i.isRequired=i;var s={array:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:r,element:i,elementType:i,instanceOf:r,node:i,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return s.PropTypes=s,s}})()();var E=(u=f.exports)&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u,p=function(e,n,i){var r=!!i,s=t.useRef(i);t.useEffect(function(){s.current=i},[i]),t.useEffect(function(){if(!r||!e)return function(){};var t=function(){s.current&&s.current.apply(s,arguments)};return e.on(n,t),function(){e.off(n,t)}},[r,n,e,s])},m=function(e){var n=t.useRef(e);return t.useEffect(function(){n.current=e},[e]),n.current},g=function(e){return null!==e&&"object"===r(e)},A="[object Object]",I=function e(t,n){if(!g(t)||!g(n))return t===n;var i=Array.isArray(t);if(i!==Array.isArray(n))return!1;var r=Object.prototype.toString.call(t)===A;if(r!==(Object.prototype.toString.call(n)===A))return!1;if(!r&&!i)return t===n;var s=Object.keys(t),a=Object.keys(n);if(s.length!==a.length)return!1;for(var o={},l=0;l<s.length;l+=1)o[s[l]]=!0;for(var u=0;u<a.length;u+=1)o[a[u]]=!0;var d=Object.keys(o);return d.length===s.length&&d.every(function(i){return e(t[i],n[i])})},T=function(e,t,n){return g(e)?Object.keys(e).reduce(function(r,a){var o=!g(t)||!I(e[a],t[a]);return n.includes(a)?(o&&console.warn("Unsupported prop change: options.".concat(a," is not a mutable property.")),r):o?i(i({},r||{}),{},s({},a,e[a])):r},null):null},S="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.",N=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S;if(null===e||g(e)&&"function"==typeof e.elements&&"function"==typeof e.createToken&&"function"==typeof e.createPaymentMethod&&"function"==typeof e.confirmCardPayment)return e;throw Error(t)},C=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S;if(g(e)&&"function"==typeof e.then)return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return N(e,t)})};var n=N(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},y=function(e){e&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.7.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.7.0",url:"https://stripe.com/docs/stripe-js/react"}))},v=t.createContext(null);v.displayName="ElementsContext";var R=function(e,t){if(!e)throw Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},O=function(e){var n=e.stripe,i=e.options,r=e.children,s=t.useMemo(function(){return C(n)},[n]),a=o(t.useState(function(){return{stripe:"sync"===s.tag?s.stripe:null,elements:"sync"===s.tag?s.stripe.elements(i):null}}),2),l=a[0],u=a[1];t.useEffect(function(){var e=!0,t=function(e){u(function(t){return t.stripe?t:{stripe:e,elements:e.elements(i)}})};return"async"!==s.tag||l.stripe?"sync"!==s.tag||l.stripe||t(s.stripe):s.stripePromise.then(function(n){n&&e&&t(n)}),function(){e=!1}},[s,l,i]);var d=m(n);t.useEffect(function(){null!==d&&d!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[d,n]);var c=m(i);return t.useEffect(function(){if(l.elements){var e=T(i,c,["clientSecret","fonts"]);e&&l.elements.update(e)}},[i,c,l.elements]),t.useEffect(function(){y(l.stripe)},[l.stripe]),t.createElement(v.Provider,{value:l},r)};O.propTypes={stripe:E.any,options:E.object};var b=function(e){return R(t.useContext(v),e)},L=function(e){return(0,e.children)(b("mounts <ElementsConsumer>"))};L.propTypes={children:E.func.isRequired};var D=["on","session"],P=t.createContext(null);P.displayName="CheckoutSdkContext";var w=function(e,t){if(!e)throw Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e},M=t.createContext(null);M.displayName="CheckoutContext";var x=function(e,t){if(!e)return null;e.on,e.session;var n=a(e,D);return t?Object.assign(t,n):Object.assign(e.session(),n)},U=function(e){var n=e.stripe,i=e.options,r=e.children,s=t.useMemo(function(){return C(n,"Invalid prop `stripe` supplied to `CheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},[n]),a=o(t.useState(null),2),l=a[0],u=a[1],d=o(t.useState(function(){return{stripe:"sync"===s.tag?s.stripe:null,checkoutSdk:null}}),2),c=d[0],_=d[1],h=function(e,t){_(function(n){return n.stripe&&n.checkoutSdk?n:{stripe:e,checkoutSdk:t}})},f=t.useRef(!1);t.useEffect(function(){var e=!0;return"async"!==s.tag||c.stripe?"sync"===s.tag&&s.stripe&&!f.current&&(f.current=!0,s.stripe.initCheckout(i).then(function(e){e&&(h(s.stripe,e),e.on("change",u))})):s.stripePromise.then(function(t){t&&e&&!f.current&&(f.current=!0,t.initCheckout(i).then(function(e){e&&(h(t,e),e.on("change",u))}))}),function(){e=!1}},[s,c,i,u]);var E=m(n);t.useEffect(function(){null!==E&&E!==n&&console.warn("Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.")},[E,n]);var p=m(i),g=m(c.checkoutSdk);t.useEffect(function(){if(c.checkoutSdk){var e,t,n=null==p||null==(e=p.elementsOptions)?void 0:e.appearance,r=null==i||null==(t=i.elementsOptions)?void 0:t.appearance,s=!I(r,n),a=!g&&c.checkoutSdk;r&&(s||a)&&c.checkoutSdk.changeAppearance(r)}},[i,p,c.checkoutSdk,g]),t.useEffect(function(){y(c.stripe)},[c.stripe]);var A=t.useMemo(function(){return x(c.checkoutSdk,l)},[c.checkoutSdk,l]);return c.checkoutSdk?t.createElement(P.Provider,{value:c},t.createElement(M.Provider,{value:A},r)):null};U.propTypes={stripe:E.any,options:E.shape({fetchClientSecret:E.func.isRequired,elementsOptions:E.object}).isRequired};var k=function(e){var n=t.useContext(P),i=t.useContext(v);if(n&&i)throw Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return n?w(n,e):R(i,e)},G=["mode"],V=function(e,n){var i="".concat(e.charAt(0).toUpperCase()+e.slice(1),"Element"),r=n?function(e){k("mounts <".concat(i,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r,s=n.id,l=n.className,u=n.options,d=void 0===u?{}:u,c=n.onBlur,_=n.onFocus,h=n.onReady,f=n.onChange,E=n.onEscape,g=n.onClick,A=n.onLoadError,I=n.onLoaderStart,S=n.onNetworksChange,N=n.onConfirm,C=n.onCancel,y=n.onShippingAddressChange,v=n.onShippingRateChange,R=k("mounts <".concat(i,">")),O="elements"in R?R.elements:null,b="checkoutSdk"in R?R.checkoutSdk:null,L=o(t.useState(null),2),D=L[0],P=L[1],w=t.useRef(null),M=t.useRef(null);p(D,"blur",c),p(D,"focus",_),p(D,"escape",E),p(D,"click",g),p(D,"loaderror",A),p(D,"loaderstart",I),p(D,"networkschange",S),p(D,"confirm",N),p(D,"cancel",C),p(D,"shippingaddresschange",y),p(D,"shippingratechange",v),p(D,"change",f),h&&(r="expressCheckout"===e?h:function(){h(D)}),p(D,"ready",r),t.useLayoutEffect(function(){if(null===w.current&&null!==M.current&&(O||b)){var t=null;if(b)switch(e){case"payment":t=b.createPaymentElement(d);break;case"address":if("mode"in d){var n=d.mode,r=a(d,G);if("shipping"===n)t=b.createShippingAddressElement(r);else if("billing"===n)t=b.createBillingAddressElement(r);else throw Error("Invalid options.mode. mode must be 'billing' or 'shipping'.")}else throw Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");break;case"expressCheckout":t=b.createExpressCheckoutElement(d);break;case"currencySelector":t=b.createCurrencySelectorElement();break;default:throw Error("Invalid Element type ".concat(i,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else O&&(t=O.create(e,d));w.current=t,P(t),t&&t.mount(M.current)}},[O,b,d]);var x=m(d);return t.useEffect(function(){if(w.current){var e=T(d,x,["paymentRequest"]);e&&"update"in w.current&&w.current.update(e)}},[d,x]),t.useLayoutEffect(function(){return function(){if(w.current&&"function"==typeof w.current.destroy)try{w.current.destroy(),w.current=null}catch(e){}}},[]),t.createElement("div",{id:s,className:l,ref:M})};return r.propTypes={id:E.string,className:E.string,onChange:E.func,onBlur:E.func,onFocus:E.func,onReady:E.func,onEscape:E.func,onClick:E.func,onLoadError:E.func,onLoaderStart:E.func,onNetworksChange:E.func,onConfirm:E.func,onCancel:E.func,onShippingAddressChange:E.func,onShippingRateChange:E.func,options:E.object},r.displayName=i,r.__elementType=e,r},F="u"<typeof window,B=t.createContext(null);B.displayName="EmbeddedCheckoutProviderContext";var j=function(){var e=t.useContext(B);if(!e)throw Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return e},H=F?function(e){var n=e.id,i=e.className;return j(),t.createElement("div",{id:n,className:i})}:function(e){var n=e.id,i=e.className,r=j().embeddedCheckout,s=t.useRef(!1),a=t.useRef(null);return t.useLayoutEffect(function(){return!s.current&&r&&null!==a.current&&(r.mount(a.current),s.current=!0),function(){if(s.current&&r)try{r.unmount(),s.current=!1}catch(e){}}},[r]),t.createElement("div",{ref:a,id:n,className:i})},W=V("auBankAccount",F),Y=V("card",F),K=V("cardNumber",F),$=V("cardExpiry",F),z=V("cardCvc",F),q=V("fpxBank",F),Z=V("iban",F),X=V("idealBank",F),Q=V("p24Bank",F),J=V("epsBank",F),ee=V("payment",F),et=V("expressCheckout",F),en=V("currencySelector",F),ei=V("paymentRequestButton",F),er=V("linkAuthentication",F),es=V("address",F),ea=V("shippingAddress",F),eo=V("paymentMethodMessaging",F),el=V("affirmMessage",F),eu=V("afterpayClearpayMessage",F);e.AddressElement=es,e.AffirmMessageElement=el,e.AfterpayClearpayMessageElement=eu,e.AuBankAccountElement=W,e.CardCvcElement=z,e.CardElement=Y,e.CardExpiryElement=$,e.CardNumberElement=K,e.CheckoutProvider=U,e.CurrencySelectorElement=en,e.Elements=O,e.ElementsConsumer=L,e.EmbeddedCheckout=H,e.EmbeddedCheckoutProvider=function(e){var n=e.stripe,i=e.options,r=e.children,s=t.useMemo(function(){return C(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},[n]),a=t.useRef(null),l=t.useRef(null),u=o(t.useState({embeddedCheckout:null}),2),d=u[0],c=u[1];t.useEffect(function(){if(!l.current&&!a.current){var e=function(e){l.current||a.current||(l.current=e,a.current=l.current.initEmbeddedCheckout(i).then(function(e){c({embeddedCheckout:e})}))};"async"===s.tag&&!l.current&&(i.clientSecret||i.fetchClientSecret)?s.stripePromise.then(function(t){t&&e(t)}):"sync"===s.tag&&!l.current&&(i.clientSecret||i.fetchClientSecret)&&e(s.stripe)}},[s,i,d,l]),t.useEffect(function(){return function(){d.embeddedCheckout?(a.current=null,d.embeddedCheckout.destroy()):a.current&&a.current.then(function(){a.current=null,d.embeddedCheckout&&d.embeddedCheckout.destroy()})}},[d.embeddedCheckout]),t.useEffect(function(){y(l)},[l]);var _=m(n);t.useEffect(function(){null!==_&&_!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")},[_,n]);var h=m(i);return t.useEffect(function(){if(null!=h){if(null==i)return void console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them.");void 0===i.clientSecret&&void 0===i.fetchClientSecret&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),null!=h.clientSecret&&i.clientSecret!==h.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=h.fetchClientSecret&&i.fetchClientSecret!==h.fetchClientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=h.onComplete&&i.onComplete!==h.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it."),null!=h.onShippingDetailsChange&&i.onShippingDetailsChange!==h.onShippingDetailsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it."),null!=h.onLineItemsChange&&i.onLineItemsChange!==h.onLineItemsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.")}},[h,i]),t.createElement(B.Provider,{value:d},r)},e.EpsBankElement=J,e.ExpressCheckoutElement=et,e.FpxBankElement=q,e.IbanElement=Z,e.IdealBankElement=X,e.LinkAuthenticationElement=er,e.P24BankElement=Q,e.PaymentElement=ee,e.PaymentMethodMessagingElement=eo,e.PaymentRequestButtonElement=ei,e.ShippingAddressElement=ea,e.useCheckout=function(){w(t.useContext(P),"calls useCheckout()");var e=t.useContext(M);if(!e)throw Error("Could not find Checkout Context; You need to wrap the part of your app that calls useCheckout() in an <CheckoutProvider> provider.");return e},e.useElements=function(){return b("calls useElements()").elements},e.useStripe=function(){return k("calls useStripe()").stripe}}(t,n(64700))}