var w="https://js.stripe.com/v3",g=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var j=function(){for(var r=document.querySelectorAll('script[src^="'.concat(w,'"]')),e=0;e<r.length;e++){var n=r[e];if(g.test(n.src))return n}return null},p=function(r){var e="",n=document.createElement("script");n.src="".concat(w).concat(e);var a=document.head||document.body;if(!a)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return a.appendChild(n),n},y=function(r,e){!r||!r._registerWrapper||r._registerWrapper({name:"stripe-js",version:"3.4.1",startTime:e})},d=null,l=null,f=null,x=function(r){return function(){r(new Error("Failed to load Stripe.js?v=1773287522785"))}},L=function(r,e){return function(){window.Stripe?r(window.Stripe):e(new Error("Stripe.js not available"))}},T=function(r){return d!==null?d:(d=new Promise(function(e,n){if(typeof window>"u"||typeof document>"u"){e(null);return}if(window.Stripe){e(window.Stripe);return}try{var a=j();if(!(a&&r)){if(!a)a=p(r);else if(a&&f!==null&&l!==null){var i;a.removeEventListener("load",f),a.removeEventListener("error",l),(i=a.parentNode)===null||i===void 0||i.removeChild(a),a=p(r)}}f=L(e,n),l=x(n),a.addEventListener("load",f),a.addEventListener("error",l)}catch(o){n(o);return}}),d.catch(function(e){return d=null,Promise.reject(e)}))},C=function(r,e,n){if(r===null)return null;var a=r.apply(void 0,e);return y(a,n),a},s,h=!1,b=function(){return s||(s=T(null).catch(function(r){return s=null,Promise.reject(r)}),s)};Promise.resolve().then(function(){return b()}).catch(function(t){h||console.warn(t)});var I=function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];h=!0;var a=Date.now();return b().then(function(i){return C(i,e,a)})};function q(t,r){var e=document.querySelector('script[src="'.concat(t,'"]'));if(e===null)return null;var n=S(t,r),a=e.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(a.dataset).forEach(function(o){a.dataset[o]!==n.dataset[o]&&(i=!1)}),i?e:null}function A(t){var r=t.url,e=t.attributes,n=t.onSuccess,a=t.onError,i=S(r,e);i.onerror=a,i.onload=n,document.head.insertBefore(i,document.head.firstElementChild)}function O(t){var r=t.environment,e=r==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete t.environment,t.sdkBaseUrl&&(e=t.sdkBaseUrl,delete t.sdkBaseUrl);var n=t,a=Object.keys(n).filter(function(u){return typeof n[u]<"u"&&n[u]!==null&&n[u]!==""}).reduce(function(u,c){var v=n[c].toString();return c=W(c),c.substring(0,4)==="data"||c==="crossorigin"?u.attributes[c]=v:u.queryParams[c]=v,u},{queryParams:{},attributes:{}}),i=a.queryParams,o=a.attributes;return i["merchant-id"]&&i["merchant-id"].indexOf(",")!==-1&&(o["data-merchant-id"]=i["merchant-id"],i["merchant-id"]="*"),{url:"".concat(e,"?").concat(B(i)),attributes:o}}function W(t){var r=function(e,n){return(n?"-":"")+e.toLowerCase()};return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)}function B(t){var r="";return Object.keys(t).forEach(function(e){r.length!==0&&(r+="&"),r+=e+"="+t[e]}),r}function S(t,r){r===void 0&&(r={});var e=document.createElement("script");return e.src=t,Object.keys(r).forEach(function(n){e.setAttribute(n,r[n]),n==="data-csp-nonce"&&e.setAttribute("nonce",r["data-csp-nonce"])}),e}function N(t,r){if(r===void 0&&(r=Promise),E(t,r),typeof document>"u")return r.resolve(null);var e=O(t),n=e.url,a=e.attributes,i=a["data-namespace"]||"paypal",o=m(i);return a["data-js-sdk-library"]||(a["data-js-sdk-library"]="paypal-js"),q(n,a)&&o?r.resolve(o):U({url:n,attributes:a},r).then(function(){var u=m(i);if(u)return u;throw new Error("The window.".concat(i," global variable is not available."))})}function U(t,r){r===void 0&&(r=Promise),E(t,r);var e=t.url,n=t.attributes;if(typeof e!="string"||e.length===0)throw new Error("Invalid url.");if(typeof n<"u"&&typeof n!="object")throw new Error("Expected attributes to be an object.");return new r(function(a,i){if(typeof document>"u")return a();A({url:e,attributes:n,onSuccess:function(){return a()},onError:function(){var o=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return i(o)}})})}function m(t){return window[t]}function E(t,r){if(typeof t!="object"||t===null)throw new Error("Expected an options object.");var e=t.environment;if(e&&e!=="production"&&e!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(typeof r<"u"&&typeof r!="function")throw new Error("Expected PromisePonyfill to be a function.")}export{I as a,N as l};
