"use strict";var pure$1={};function _typeof(e){return _typeof="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},_typeof(e)}Object.defineProperty(pure$1,"__esModule",{value:!0});var loadParams,V3_URL="https://js.stripe.com/v3",V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",findScript=function(){for(var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]')),r=0;r<e.length;r++){var t=e[r];if(V3_URL_REGEX.test(t.src))return t}return null},injectScript=function(e){var r=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src="".concat(V3_URL).concat(r);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(t),t},registerWrapper=function(e,r){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:r})},stripePromise=null,loadScript=function(e){return null!==stripePromise?stripePromise:stripePromise=new Promise((function(r,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(EXISTING_SCRIPT_MESSAGE),window.Stripe)r(window.Stripe);else try{var n=findScript();n&&e?console.warn(EXISTING_SCRIPT_MESSAGE):n||(n=injectScript(e)),n.addEventListener("load",(function(){window.Stripe?r(window.Stripe):t(new Error("Stripe.js not available"))})),n.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else r(null)}))},initStripe=function(e,r,t){if(null===e)return null;var n=e.apply(void 0,r);return registerWrapper(n,t),n},validateLoadParams=function(e){var r="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"!==_typeof(e))throw new Error(r);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(r)},loadStripeCalled=!1,loadStripe=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];loadStripeCalled=!0;var n=Date.now();return loadScript(loadParams).then((function(e){return initStripe(e,r,n)}))};loadStripe.setLoadParameters=function(e){if(loadStripeCalled&&loadParams){var r=validateLoadParams(e);if(Object.keys(r).reduce((function(r,t){var n;return r&&e[t]===(null===(n=loadParams)||void 0===n?void 0:n[t])}),!0))return}if(loadStripeCalled)throw new Error("You cannot change load parameters after calling loadStripe");loadParams=validateLoadParams(e)},pure$1.loadStripe=loadStripe;var pure=pure$1;exports.pure=pure;