Socket
Socket
Sign inDemoInstall

@paypal/react-paypal-js

Package Overview
Dependencies
9
Maintainers
22
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.8.2 to 7.8.3

6

dist/cjs/react-paypal-js.js
/*!
* react-paypal-js v7.8.2 (2022-11-30T19:31:44.159Z)
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -517,3 +517,3 @@ *

validateArguments(options, PromisePonyfill);
if (typeof window === "undefined") return PromisePonyfill.resolve(null);
if (typeof document === "undefined") return PromisePonyfill.resolve(null);
var _a = processOptions(options),

@@ -552,3 +552,3 @@ url = _a.url,

return new PromisePonyfill(function (resolve, reject) {
if (typeof window === "undefined") return resolve();
if (typeof document === "undefined") return resolve();
insertScriptElement({

@@ -555,0 +555,0 @@ url: url,

/*!
* react-paypal-js v7.8.2 (2022-11-30T19:31:44.159Z)
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i="data-react-paypal-script-id",c="data-client-token",s="data-user-id-token",u="data-sdk-integration-source",l="react-paypal-js",d="data-namespace",p="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),f="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),P=function(){return(P=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}).apply(this,arguments)};function E(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function v(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function h(e){return void 0===e&&(e="paypal"),window[e]}function S(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function T(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(i,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return P(P({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return A(e.options[i]),delete t.value[i],P(P({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:P(P({},t.value),(n={},n[i]="".concat(T(t.value)),n[u]=l,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return P(P({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[P(P({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[c])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[s]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var R=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,c=t.children,s=t.forceReRender,u=void 0===s?[]:s,l=E(t,["className","disabled","children","forceReRender"]),p=i?{opacity:.38}:{},f="".concat(r," ").concat(i?"paypal-buttons-disabled":"").trim(),T=e.useRef(null),A=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],_=O[1],b=e.useState(!0),w=b[0],g=b[1],D=e.useState(null)[1];function x(){null!==A.current&&A.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return x;var e=h(y[d]);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(S({reactComponentName:R.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[d]}))})),x;try{A.current=e.Buttons(P(P({},l),{onInit:function(e,t){_(t),"function"==typeof l.onInit&&l.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===A.current.isEligible()?(g(!1),x):T.current?(A.current.render(T.current).catch((function(e){null!==T.current&&0!==T.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),v(v([I],u,!0),[l.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===i?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[i,C]),a.default.createElement(a.default.Fragment,null,w?a.default.createElement("div",{ref:T,style:p,className:f}):c)};function _(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(b(r)),dataAttributes:o}}function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function w(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function g(e,t){if(void 0===t&&(t=x()),k(e,t),"undefined"==typeof window)return t.resolve(null);var n=_(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=L(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=w(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):D({url:r,attributes:o},t).then((function(){var e=L(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function D(e,t){void 0===t&&(t=x()),k(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=w(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function x(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function L(e){return window[e]}function k(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}R.displayName="PayPalButtons";var F=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([D({url:p}),D({url:f})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},H=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,i=E(t,["className","children"]),c=N()[0],s=c.isResolved,u=c.options,l=e.useRef(null),p=e.useState(!0),f=p[0],v=p[1],T=e.useState(null)[1];return e.useEffect((function(){if(!1!==s){var e=h(u[d]);if(void 0===e||void 0===e.Marks)return T((function(){throw new Error(S({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:u.components,sdkDataNamespace:u[d]}))}));!function(e){var t=l.current;if(!t||!e.isEligible())return v(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&T((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(P({},i)))}}),[s,i.fundingSource]),a.default.createElement(a.default.Fragment,null,f?a.default.createElement("div",{ref:l,className:r}):o)};H.displayName="PayPalMarks";var j=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,i=void 0===o?[]:o,c=E(t,["className","forceReRender"]),s=N()[0],u=s.isResolved,l=s.options,p=e.useRef(null),f=e.useRef(null),T=e.useState(null)[1];return e.useEffect((function(){if(!1!==u){var e=h(l[d]);if(void 0===e||void 0===e.Messages)return T((function(){throw new Error(S({reactComponentName:j.displayName,sdkComponentKey:"messages",sdkRequestedComponents:l.components,sdkDataNamespace:l[d]}))}));f.current=e.Messages(P({},c)),f.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&T((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),v([u],i,!0)),a.default.createElement("div",{ref:p,className:r})};j.displayName="PayPalMessages";var G=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},B=function(e){G(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},Y={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,u=t.children,l=t.forceReRender,d=void 0===l?[]:l,p=t.braintreeNamespace,f=t.merchantAccountId,v=E(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),h=e.useState(null)[1],S=O(),T=S[0],A=S[1];return e.useEffect((function(){F(p).then((function(e){var t=T.options[s],n=T.options[c];return e.client.create({authorization:t||n}).then((function(t){var n=f?{merchantAccountId:f}:{};return e.paypalCheckout.create(P(P({},n),{client:t}))})).then((function(e){A({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){h((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[T.options]),a.default.createElement(a.default.Fragment,null,T.braintreePayPalCheckoutInstance&&a.default.createElement(R,P({className:r,disabled:i,forceReRender:d},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,P(P({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,P(P({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,P(P({},n),{braintree:t}))}),P({},e)}(v,T.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=Y,exports.PayPalButtons=R,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=E(t,["hostedFieldType","options"]),i=e.useContext(C);return e.useEffect((function(){var e;if(!(null==i?void 0:i.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");i.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",P({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,i=t.children,c=t.installments,s=O()[0],u=s.options,l=s.loadingStatus,p=e.useState(!0),f=p[0],E=p[1],v=e.useState(),S=v[0],T=v[1],A=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=P(P({},n.current),e)}]}(),N=y[0],R=y[1];return e.useEffect((function(){var e;if(B(Object.keys(N.current)),l===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=h(u[d]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[d],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:u.components})[d]=u[d],e)));if(!I.current.isEligible())return E(!1);S&&S.teardown(),I.current.render({createOrder:r,fields:N.current,installments:c,styles:n}).then((function(e){m.current&&T(e)})).catch((function(e){A((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[l,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:S,registerHostedField:R}},i):o)},exports.PayPalMarks=H,exports.PayPalMessages=j,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,s=t.deferLoading,d=void 0!==s&&s,p=e.useReducer(m,{options:P(P({},o),(n={},n[i]="".concat(T(o)),n[u]=l,n)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),f=p[0],E=p[1];return e.useEffect((function(){if(!1===d&&f.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(f.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return g(f.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[f.options,d,f.loadingStatus]),a.default.createElement(I.Provider,{value:P(P({},f),{dispatch:E})},c)},exports.ScriptContext=I,exports.destroySDKScript=A,exports.getScriptID=T,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i="data-react-paypal-script-id",c="data-client-token",s="data-user-id-token",u="data-sdk-integration-source",l="react-paypal-js",d="data-namespace",p="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),f="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),P=function(){return(P=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}).apply(this,arguments)};function E(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function v(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function h(e){return void 0===e&&(e="paypal"),window[e]}function S(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function T(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(i,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return P(P({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return A(e.options[i]),delete t.value[i],P(P({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:P(P({},t.value),(n={},n[i]="".concat(T(t.value)),n[u]=l,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return P(P({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[P(P({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[c])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[s]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var R=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,c=t.children,s=t.forceReRender,u=void 0===s?[]:s,l=E(t,["className","disabled","children","forceReRender"]),p=i?{opacity:.38}:{},f="".concat(r," ").concat(i?"paypal-buttons-disabled":"").trim(),T=e.useRef(null),A=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],_=O[1],b=e.useState(!0),g=b[0],w=b[1],D=e.useState(null)[1];function x(){null!==A.current&&A.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return x;var e=h(y[d]);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(S({reactComponentName:R.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[d]}))})),x;try{A.current=e.Buttons(P(P({},l),{onInit:function(e,t){_(t),"function"==typeof l.onInit&&l.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===A.current.isEligible()?(w(!1),x):T.current?(A.current.render(T.current).catch((function(e){null!==T.current&&0!==T.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),v(v([I],u,!0),[l.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===i?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[i,C]),a.default.createElement(a.default.Fragment,null,g?a.default.createElement("div",{ref:T,style:p,className:f}):c)};function _(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(b(r)),dataAttributes:o}}function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function g(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function w(e,t){if(void 0===t&&(t=x()),k(e,t),"undefined"==typeof document)return t.resolve(null);var n=_(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=L(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=g(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):D({url:r,attributes:o},t).then((function(){var e=L(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function D(e,t){void 0===t&&(t=x()),k(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=g(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function x(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function L(e){return window[e]}function k(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}R.displayName="PayPalButtons";var F=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([D({url:p}),D({url:f})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},H=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,i=E(t,["className","children"]),c=N()[0],s=c.isResolved,u=c.options,l=e.useRef(null),p=e.useState(!0),f=p[0],v=p[1],T=e.useState(null)[1];return e.useEffect((function(){if(!1!==s){var e=h(u[d]);if(void 0===e||void 0===e.Marks)return T((function(){throw new Error(S({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:u.components,sdkDataNamespace:u[d]}))}));!function(e){var t=l.current;if(!t||!e.isEligible())return v(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&T((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(P({},i)))}}),[s,i.fundingSource]),a.default.createElement(a.default.Fragment,null,f?a.default.createElement("div",{ref:l,className:r}):o)};H.displayName="PayPalMarks";var j=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,i=void 0===o?[]:o,c=E(t,["className","forceReRender"]),s=N()[0],u=s.isResolved,l=s.options,p=e.useRef(null),f=e.useRef(null),T=e.useState(null)[1];return e.useEffect((function(){if(!1!==u){var e=h(l[d]);if(void 0===e||void 0===e.Messages)return T((function(){throw new Error(S({reactComponentName:j.displayName,sdkComponentKey:"messages",sdkRequestedComponents:l.components,sdkDataNamespace:l[d]}))}));f.current=e.Messages(P({},c)),f.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&T((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),v([u],i,!0)),a.default.createElement("div",{ref:p,className:r})};j.displayName="PayPalMessages";var G=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},B=function(e){G(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},Y={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,u=t.children,l=t.forceReRender,d=void 0===l?[]:l,p=t.braintreeNamespace,f=t.merchantAccountId,v=E(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),h=e.useState(null)[1],S=O(),T=S[0],A=S[1];return e.useEffect((function(){F(p).then((function(e){var t=T.options[s],n=T.options[c];return e.client.create({authorization:t||n}).then((function(t){var n=f?{merchantAccountId:f}:{};return e.paypalCheckout.create(P(P({},n),{client:t}))})).then((function(e){A({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){h((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[T.options]),a.default.createElement(a.default.Fragment,null,T.braintreePayPalCheckoutInstance&&a.default.createElement(R,P({className:r,disabled:i,forceReRender:d},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,P(P({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,P(P({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,P(P({},n),{braintree:t}))}),P({},e)}(v,T.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=Y,exports.PayPalButtons=R,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=E(t,["hostedFieldType","options"]),i=e.useContext(C);return e.useEffect((function(){var e;if(!(null==i?void 0:i.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");i.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",P({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,i=t.children,c=t.installments,s=O()[0],u=s.options,l=s.loadingStatus,p=e.useState(!0),f=p[0],E=p[1],v=e.useState(),S=v[0],T=v[1],A=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=P(P({},n.current),e)}]}(),N=y[0],R=y[1];return e.useEffect((function(){var e;if(B(Object.keys(N.current)),l===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=h(u[d]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[d],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:u.components})[d]=u[d],e)));if(!I.current.isEligible())return E(!1);S&&S.teardown(),I.current.render({createOrder:r,fields:N.current,installments:c,styles:n}).then((function(e){m.current&&T(e)})).catch((function(e){A((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[l,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:S,registerHostedField:R}},i):o)},exports.PayPalMarks=H,exports.PayPalMessages=j,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,s=t.deferLoading,d=void 0!==s&&s,p=e.useReducer(m,{options:P(P({},o),(n={},n[i]="".concat(T(o)),n[u]=l,n)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),f=p[0],E=p[1];return e.useEffect((function(){if(!1===d&&f.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(f.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return w(f.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[f.options,d,f.loadingStatus]),a.default.createElement(I.Provider,{value:P(P({},f),{dispatch:E})},c)},exports.ScriptContext=I,exports.destroySDKScript=A,exports.getScriptID=T,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
/*!
* react-paypal-js v7.8.2 (2022-11-30T19:31:44.159Z)
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -620,3 +620,3 @@ *

validateArguments(options, PromisePonyfill);
if (typeof window === "undefined") return PromisePonyfill.resolve(null);
if (typeof document === "undefined") return PromisePonyfill.resolve(null);

@@ -666,3 +666,3 @@ var _a = processOptions(options),

return new PromisePonyfill(function (resolve, reject) {
if (typeof window === "undefined") return resolve();
if (typeof document === "undefined") return resolve();
insertScriptElement({

@@ -669,0 +669,0 @@ url: url,

/*!
* react-paypal-js v7.8.2 (2022-11-30T19:31:44.159Z)
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,l,s;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(l||(l={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(s||(s={}));var u="data-react-paypal-script-id",d="data-client-token",f="data-user-id-token",p="data-sdk-integration-source",v="react-paypal-js",h="data-namespace",m="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),y="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),E=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}).apply(this,arguments)};function P(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function b(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function w(e){return void 0===e&&(e="paypal"),window[e]}function N(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),l="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var s=[o,n].filter(Boolean).join();l+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(s,"'}}>`.")}return l}function g(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n;switch(t.type){case l.LOADING_STATUS:return E(E({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return A(e.options[u]),delete t.value[u],E(E({},e),{loadingStatus:c.PENDING,options:E(E({},t.value),(n={},n[u]="".concat(g(t.value)),n[p]=v,n))});case l.SET_BRAINTREE_INSTANCE:return E(E({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var O=t(null);function S(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function T(){var e=S(n(O));return[E(E({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[d])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[f]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(S(n(O)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,s=t.children,u=t.forceReRender,d=void 0===u?[]:u,f=P(t,["className","disabled","children","forceReRender"]),p=l?{opacity:.38}:{},v="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),m=r(null),y=r(null),g=T()[0],A=g.isResolved,I=g.options,O=o(null),S=O[0],R=O[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==y.current&&y.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=w(I[h]);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(N({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[h]}))})),F;try{y.current=e.Buttons(E(E({},f),{onInit:function(e,t){R(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===y.current.isEligible()?(j(!1),F):m.current?(y.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),b(b([A],d,!0),[f.fundingSource],!1)),a((function(){null!==S&&(!0===l?S.disable().catch((function(){})):S.enable().catch((function(){})))}),[l,S]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:m,style:p,className:v}):s)};function j(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(L(r)),dataAttributes:o}}function L(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function F(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function B(e,t){if(void 0===t&&(t=U()),x(e,t),"undefined"==typeof window)return t.resolve(null);var n=j(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=_(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=F(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):M({url:r,attributes:o},t).then((function(){var e=_(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function M(e,t){void 0===t&&(t=U()),x(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=F(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function U(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function _(e){return window[e]}function x(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var H=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([M({url:m}),M({url:y})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},G=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,s=t.children,u=t.forceReRender,p=void 0===u?[]:u,v=t.braintreeNamespace,h=t.merchantAccountId,m=P(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),y=o(null)[1],b=R(),w=b[0],N=b[1];return a((function(){H(v).then((function(e){var t=w.options[f],n=w.options[d];return e.client.create({authorization:t||n}).then((function(t){var n=h?{merchantAccountId:h}:{};return e.paypalCheckout.create(E(E({},n),{client:t}))})).then((function(e){N({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){y((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[w.options]),e.createElement(e.Fragment,null,w.braintreePayPalCheckoutInstance&&e.createElement(D,E({className:r,disabled:c,forceReRender:p},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,E(E({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,E(E({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,E(E({},n),{braintree:t}))}),E({},e)}(m,w.braintreePayPalCheckoutInstance)),s))},K=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=P(t,["className","children"]),s=T()[0],u=s.isResolved,d=s.options,f=r(null),p=o(!0),v=p[0],m=p[1],y=o(null)[1];return a((function(){if(!1!==u){var e=w(d[h]);if(void 0===e||void 0===e.Marks)return y((function(){throw new Error(N({reactComponentName:K.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[h]}))}));!function(e){var t=f.current;if(!t||!e.isEligible())return m(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&y((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(E({},l)))}}),[u,l.fundingSource]),e.createElement(e.Fragment,null,v?e.createElement("div",{ref:f,className:i}):c)};K.displayName="PayPalMarks";var Y=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,s=P(t,["className","forceReRender"]),u=T()[0],d=u.isResolved,f=u.options,p=r(null),v=r(null),m=o(null)[1];return a((function(){if(!1!==d){var e=w(f[h]);if(void 0===e||void 0===e.Messages)return m((function(){throw new Error(N({reactComponentName:Y.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[h]}))}));v.current=e.Messages(E({},s)),v.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&m((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),b([d],l,!0)),e.createElement("div",{ref:p,className:i})};Y.displayName="PayPalMessages";var V=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,s=t.children,d=t.deferLoading,f=void 0!==d&&d,h=i(I,{options:E(E({},o),(n={},n[u]="".concat(g(o)),n[p]=v,n)),loadingStatus:f?c.INITIAL:c.PENDING}),m=h[0],y=h[1];return a((function(){if(!1===f&&m.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(m.loadingStatus===c.PENDING){var e=!0;return B(m.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[m.options,f,m.loadingStatus]),e.createElement(O.Provider,{value:E(E({},m),{dispatch:y})},s)},q=function(e){if(!e.includes(s.NUMBER)||!e.includes(s.CVV)||function(e){return!e.includes(s.EXPIRATION_DATE)&&!e.includes(s.EXPIRATION_MONTH)&&!e.includes(s.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},X=function(e){q(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},z=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,s=t.children,u=t.installments,d=R()[0],f=d.options,p=d.loadingStatus,v=o(!0),m=v[0],y=v[1],P=o(),b=P[0],N=P[1],g=o(null)[1],A=r(null),I=r(),O=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=E(E({},t.current),e)}]}(),S=O[0],T=O[1];return a((function(){var e;if(X(Object.keys(S.current)),p===c.RESOLVED){if(I.current=w(f[h]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[h],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[h]=f[h],e)));if(!I.current.isEligible())return y(!1);b&&b.teardown(),I.current.render({createOrder:i,fields:S.current,installments:u,styles:n}).then((function(e){A.current&&N(e)})).catch((function(e){g((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[p,n]),e.createElement("div",{ref:A},m?e.createElement(C.Provider,{value:{cardFields:b,registerHostedField:T}},s):l)},J=function(t){var r=t.hostedFieldType,o=t.options,i=P(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",E({},i))},W={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{G as BraintreePayPalButtons,l as DISPATCH_ACTION,W as FUNDING,s as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,J as PayPalHostedField,z as PayPalHostedFieldsProvider,K as PayPalMarks,Y as PayPalMessages,V as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,O as ScriptContext,A as destroySDKScript,g as getScriptID,I as scriptReducer,k as usePayPalHostedFields,T as usePayPalScriptReducer,R as useScriptProviderContext};
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,l,u;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(l||(l={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(u||(u={}));var s="data-react-paypal-script-id",d="data-client-token",f="data-user-id-token",p="data-sdk-integration-source",v="react-paypal-js",h="data-namespace",m="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),y="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),E=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}).apply(this,arguments)};function P(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function b(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function N(e){return void 0===e&&(e="paypal"),window[e]}function g(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),l="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();l+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return l}function w(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(s,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n;switch(t.type){case l.LOADING_STATUS:return E(E({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return A(e.options[s]),delete t.value[s],E(E({},e),{loadingStatus:c.PENDING,options:E(E({},t.value),(n={},n[s]="".concat(w(t.value)),n[p]=v,n))});case l.SET_BRAINTREE_INSTANCE:return E(E({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var O=t(null);function S(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function T(){var e=S(n(O));return[E(E({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[d])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[f]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(S(n(O)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,u=t.children,s=t.forceReRender,d=void 0===s?[]:s,f=P(t,["className","disabled","children","forceReRender"]),p=l?{opacity:.38}:{},v="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),m=r(null),y=r(null),w=T()[0],A=w.isResolved,I=w.options,O=o(null),S=O[0],R=O[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==y.current&&y.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=N(I[h]);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(g({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[h]}))})),F;try{y.current=e.Buttons(E(E({},f),{onInit:function(e,t){R(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===y.current.isEligible()?(j(!1),F):m.current?(y.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),b(b([A],d,!0),[f.fundingSource],!1)),a((function(){null!==S&&(!0===l?S.disable().catch((function(){})):S.enable().catch((function(){})))}),[l,S]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:m,style:p,className:v}):u)};function j(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(L(r)),dataAttributes:o}}function L(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function F(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function B(e,t){if(void 0===t&&(t=U()),x(e,t),"undefined"==typeof document)return t.resolve(null);var n=j(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=_(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=F(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):M({url:r,attributes:o},t).then((function(){var e=_(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function M(e,t){void 0===t&&(t=U()),x(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=F(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function U(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function _(e){return window[e]}function x(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var H=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([M({url:m}),M({url:y})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},G=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,u=t.children,s=t.forceReRender,p=void 0===s?[]:s,v=t.braintreeNamespace,h=t.merchantAccountId,m=P(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),y=o(null)[1],b=R(),N=b[0],g=b[1];return a((function(){H(v).then((function(e){var t=N.options[f],n=N.options[d];return e.client.create({authorization:t||n}).then((function(t){var n=h?{merchantAccountId:h}:{};return e.paypalCheckout.create(E(E({},n),{client:t}))})).then((function(e){g({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){y((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[N.options]),e.createElement(e.Fragment,null,N.braintreePayPalCheckoutInstance&&e.createElement(D,E({className:r,disabled:c,forceReRender:p},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,E(E({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,E(E({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,E(E({},n),{braintree:t}))}),E({},e)}(m,N.braintreePayPalCheckoutInstance)),u))},K=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=P(t,["className","children"]),u=T()[0],s=u.isResolved,d=u.options,f=r(null),p=o(!0),v=p[0],m=p[1],y=o(null)[1];return a((function(){if(!1!==s){var e=N(d[h]);if(void 0===e||void 0===e.Marks)return y((function(){throw new Error(g({reactComponentName:K.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[h]}))}));!function(e){var t=f.current;if(!t||!e.isEligible())return m(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&y((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(E({},l)))}}),[s,l.fundingSource]),e.createElement(e.Fragment,null,v?e.createElement("div",{ref:f,className:i}):c)};K.displayName="PayPalMarks";var Y=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,u=P(t,["className","forceReRender"]),s=T()[0],d=s.isResolved,f=s.options,p=r(null),v=r(null),m=o(null)[1];return a((function(){if(!1!==d){var e=N(f[h]);if(void 0===e||void 0===e.Messages)return m((function(){throw new Error(g({reactComponentName:Y.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[h]}))}));v.current=e.Messages(E({},u)),v.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&m((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),b([d],l,!0)),e.createElement("div",{ref:p,className:i})};Y.displayName="PayPalMessages";var V=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,u=t.children,d=t.deferLoading,f=void 0!==d&&d,h=i(I,{options:E(E({},o),(n={},n[s]="".concat(w(o)),n[p]=v,n)),loadingStatus:f?c.INITIAL:c.PENDING}),m=h[0],y=h[1];return a((function(){if(!1===f&&m.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(m.loadingStatus===c.PENDING){var e=!0;return B(m.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[m.options,f,m.loadingStatus]),e.createElement(O.Provider,{value:E(E({},m),{dispatch:y})},u)},q=function(e){if(!e.includes(u.NUMBER)||!e.includes(u.CVV)||function(e){return!e.includes(u.EXPIRATION_DATE)&&!e.includes(u.EXPIRATION_MONTH)&&!e.includes(u.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},X=function(e){q(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},z=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,u=t.children,s=t.installments,d=R()[0],f=d.options,p=d.loadingStatus,v=o(!0),m=v[0],y=v[1],P=o(),b=P[0],g=P[1],w=o(null)[1],A=r(null),I=r(),O=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=E(E({},t.current),e)}]}(),S=O[0],T=O[1];return a((function(){var e;if(X(Object.keys(S.current)),p===c.RESOLVED){if(I.current=N(f[h]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[h],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[h]=f[h],e)));if(!I.current.isEligible())return y(!1);b&&b.teardown(),I.current.render({createOrder:i,fields:S.current,installments:s,styles:n}).then((function(e){A.current&&g(e)})).catch((function(e){w((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[p,n]),e.createElement("div",{ref:A},m?e.createElement(C.Provider,{value:{cardFields:b,registerHostedField:T}},u):l)},J=function(t){var r=t.hostedFieldType,o=t.options,i=P(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",E({},i))},W={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{G as BraintreePayPalButtons,l as DISPATCH_ACTION,W as FUNDING,u as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,J as PayPalHostedField,z as PayPalHostedFieldsProvider,K as PayPalMarks,Y as PayPalMessages,V as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,O as ScriptContext,A as destroySDKScript,w as getScriptID,I as scriptReducer,k as usePayPalHostedFields,T as usePayPalScriptReducer,R as useScriptProviderContext};
{
"name": "@paypal/react-paypal-js",
"version": "7.8.2",
"version": "7.8.3",
"description": "React components for the PayPal JS SDK",

@@ -48,3 +48,3 @@ "keywords": [

"dependencies": {
"@paypal/paypal-js": "^5.1.4",
"@paypal/paypal-js": "^5.1.6",
"@paypal/sdk-constants": "^1.0.122"

@@ -51,0 +51,0 @@ },

@@ -6,3 +6,3 @@ # react-paypal-js

<div class="badges">
<a href="https://github.com/paypal/react-paypal-js/actions?query=workflow%3Avalidate"><img src="https://img.shields.io/github/workflow/status/paypal/react-paypal-js/validate?logo=github&style=flat-square" alt="build status"></a>
<a href="https://github.com/paypal/react-paypal-js/actions?query=workflow%3Avalidate"><img src="https://img.shields.io/github/actions/workflow/status/paypal/react-paypal-js/validate.yml?branch=main&logo=github&style=flat-square" alt="build status"></a>
<a href="https://codecov.io/github/paypal/react-paypal-js/"><img src="https://img.shields.io/codecov/c/github/paypal/react-paypal-js.svg?style=flat-square" alt="coverage"></a>

@@ -106,3 +106,3 @@ <a href="https://www.npmjs.com/package/@paypal/react-paypal-js"><img src="https://img.shields.io/npm/v/@paypal/react-paypal-js.svg?style=flat-square" alt="npm version"></a>

To learn more, check out the [defer loading example in storybook](https://paypal.github.io/react-paypal-js/?path=/story/example-paypalscriptprovider--defer-loading).
To learn more, check out the [defer loading example in storybook](https://paypal.github.io/react-paypal-js/?path=/story/example-paypalscriptprovider--default&args=deferLoading:true).

@@ -133,3 +133,3 @@ #### Tracking loading state

To learn more, check out the [loading spinner example in storybook](https://paypal.github.io/react-paypal-js/?path=/story/example-usepaypalscriptreducer--loading-spinner).
To learn more, check out the [loading spinner example in storybook](https://paypal.github.io/react-paypal-js/?path=/story/example-paypalbuttons--default&args=showSpinner:true).

@@ -167,3 +167,3 @@ #### Reloading when parameters change

To learn more, check out the [dynamic currency example in storybook](https://paypal.github.io/react-paypal-js/?path=/story/example-usepaypalscriptreducer--currency).
To learn more, check out the [dynamic currency example in storybook](https://paypal.github.io/react-paypal-js/?path=/docs/example-paypalbuttons--default).

@@ -250,3 +250,3 @@ ### PayPalButtons

Check out the docs page for the [BraintreePayPalButtons](https://paypal.github.io/react-paypal-js/?path=/docs/example-braintreepaypalbuttons--default) to learn more about the available props.
Check out the docs page for the [BraintreePayPalButtons](https://paypal.github.io/react-paypal-js/?path=/docs/braintree-braintreepaypalbuttons--default) to learn more about the available props.

@@ -253,0 +253,0 @@ ### PayPal Hosted Fields

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc