Build 533169stable
Module 354729
3,078 characters · in no known chunkDependencies
Source Raw
function(e,t){"use strict";function n(e){return(n="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 r,i="basil",s=function(e){return 3===e?"v3":e},a="https://js.stripe.com",o="".concat(a,"/").concat(i,"/stripe.js"),l=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,u=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,c="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",d=function(e){return l.test(e)||u.test(e)},_=function(){for(var e=document.querySelectorAll('script[src^="'.concat(a,'"]')),t=0;t<e.length;t++){var n=e[t];if(d(n.src))return n}return null},f=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(o).concat(t);var r=document.head||document.body;if(!r)throw Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n},p=function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"7.3.1",startTime:t})},h=null,m=null,E=null,g=function(e){return function(t){e(Error("Failed to load Stripe.js",{cause:t}))}},A=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error("Stripe.js not available"))}},I=function(e){return null!==h?h:(h=new Promise(function(t,n){if("u"<typeof window||"u"<typeof document)return void t(null);if(window.Stripe&&e&&console.warn(c),window.Stripe)return void t(window.Stripe);try{var r,i=_();i&&e?console.warn(c):i?i&&null!==E&&null!==m&&(i.removeEventListener("load",E),i.removeEventListener("error",m),null==(r=i.parentNode)||r.removeChild(i),i=f(e)):i=f(e),E=A(t,n),m=g(n),i.addEventListener("load",E),i.addEventListener("error",m)}catch(e){n(e);return}})).catch(function(e){return h=null,Promise.reject(e)})},T=function(e,t,n){if(null===e)return null;var r=t[0].match(/^pk_test/),a=s(e.version),o=i;r&&a!==o&&console.warn("Stripe.js@".concat(a," was loaded on the page, but @stripe/stripe-js@").concat("7.3.1"," expected Stripe.js@").concat(o,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var l=e.apply(void 0,t);return p(l,n),l},S=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"!==n(e))throw Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw Error(t)},y=!1,v=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];y=!0;var i=Date.now();return I(r).then(function(e){return T(e,t,i)})};v.setLoadParameters=function(e){if(!(y&&r&&Object.keys(S(e)).reduce(function(t,n){var i;return t&&e[n]===(null==(i=r)?void 0:i[n])},!0))){if(y)throw Error("You cannot change load parameters after calling loadStripe");r=S(e)}},t.loadStripe=v}