@pelcro/react-pelcro-js 2.6.0-beta.2 → 2.6.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -6297,13 +6297,34 @@ const getAddressById = id => {
6297
6297
  };
6298
6298
  /**
6299
6299
  * Transforms locale names stored in our backend like
6300
- * "en_US" into the standerd accepted in core i18n methods: "en-US"
6300
+ * "en_US" into the standard accepted in core i18n methods: "en-US"
6301
6301
  * @param {string} localeName
6302
6302
  * @return {string | undefined}
6303
6303
  * @example getCanonicalLocaleFormat("en_US") => "en-US"
6304
6304
  */
6305
6305
 
6306
6306
  const getCanonicalLocaleFormat = localeName => localeName === null || localeName === void 0 ? void 0 : localeName.replace("_", "-");
6307
+ /**
6308
+ * @param {string} localeName
6309
+ * @return {string | undefined}
6310
+ * @example getLanguageWithoutRegion("en-US") => "en"
6311
+ */
6312
+
6313
+ const getLanguageWithoutRegion = localeName => {
6314
+ var _getCanonicalLocaleFo;
6315
+
6316
+ return (_getCanonicalLocaleFo = getCanonicalLocaleFormat(localeName)) === null || _getCanonicalLocaleFo === void 0 ? void 0 : _getCanonicalLocaleFo.split("-")[0];
6317
+ };
6318
+ /**
6319
+ * Gets the current page language or fallbacks to site default
6320
+ * @return {string | undefined}
6321
+ */
6322
+
6323
+ const getPageOrDefaultLanguage = () => {
6324
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6325
+
6326
+ return (_window$Pelcro$helper = window.Pelcro.helpers.getHtmlLanguageAttribute()) !== null && _window$Pelcro$helper !== void 0 ? _window$Pelcro$helper : getLanguageWithoutRegion((_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale);
6327
+ };
6307
6328
  /**
6308
6329
  * Returns a formatted price string depending on locale
6309
6330
  * @param {number} amount
@@ -6313,7 +6334,7 @@ const getCanonicalLocaleFormat = localeName => localeName === null || localeName
6313
6334
  * @example getFormattedPriceByLocal(10, 'USD', 'en-US') => "$10.00"
6314
6335
  */
6315
6336
 
6316
- const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en-US") => {
6337
+ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6317
6338
  const formatter = new Intl.NumberFormat(getCanonicalLocaleFormat(locale), {
6318
6339
  style: "currency",
6319
6340
  currency
@@ -6338,8 +6359,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6338
6359
  totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6339
6360
  }
6340
6361
 
6341
- const locale = window.Pelcro.site.read().default_locale;
6342
- return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, locale);
6362
+ return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
6343
6363
  };
6344
6364
  /**
6345
6365
  * returns true if the URL contains a supported view trigger URL
@@ -6353,12 +6373,15 @@ const isValidViewFromURL = viewID => {
6353
6373
  }
6354
6374
 
6355
6375
  return false;
6376
+ /**
6377
+ *
6378
+ */
6356
6379
 
6357
6380
  function hasValidNewsletterUpdateUrl() {
6358
- var _window$Pelcro, _window$Pelcro$uiSett;
6381
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
6359
6382
 
6360
6383
  if (viewID !== "newsletter-update") return false;
6361
- const newsletters = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.newsletters;
6384
+ const newsletters = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$uiSet = _window$Pelcro2.uiSettings) === null || _window$Pelcro2$uiSet === void 0 ? void 0 : _window$Pelcro2$uiSet.newsletters;
6362
6385
  const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6363
6386
 
6364
6387
  if (!siteHasNewslettersDefined) {
@@ -6531,10 +6554,20 @@ const getPaymentCardIcon$1 = name => {
6531
6554
  d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
6532
6555
  }));
6533
6556
  };
6557
+ /**
6558
+ * Gets the current date with time set to 0
6559
+ * @param {Date} dateObject
6560
+ * @return {Date}
6561
+ */
6562
+
6563
+ function getDateWithoutTime(dateObject) {
6564
+ const date = new Date(dateObject.getTime());
6565
+ date.setHours(0, 0, 0, 0);
6566
+ return date;
6567
+ }
6534
6568
 
6535
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6536
6569
  const resources = {
6537
- "en-US": {
6570
+ en: {
6538
6571
  common: common_en,
6539
6572
  paymentMethod: paymentMethod_en,
6540
6573
  newsletter: newsletter_en,
@@ -6556,7 +6589,7 @@ const resources = {
6556
6589
  select: select_en,
6557
6590
  notification: notification_en
6558
6591
  },
6559
- "fr-CA": {
6592
+ fr: {
6560
6593
  common: common_fr,
6561
6594
  paymentMethod: paymentMethod_fr,
6562
6595
  newsletter: newsletter_fr,
@@ -6578,13 +6611,14 @@ const resources = {
6578
6611
  select: select_fr,
6579
6612
  notification: notification_fr
6580
6613
  }
6581
- };
6582
- let locale = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale;
6583
- if (!locale) locale = "en-US";
6614
+ }; // set UI language to the page language or default to the language in site settings
6615
+
6616
+ const locale = getPageOrDefaultLanguage();
6584
6617
  i18next.use(initReactI18next) // passes i18n down to react-i18next,
6585
6618
  .init({
6586
6619
  resources,
6587
- lng: getCanonicalLocaleFormat(locale),
6620
+ lng: locale,
6621
+ fallbackLng: "en",
6588
6622
  // debug: true,
6589
6623
  interpolation: {
6590
6624
  escapeValue: false // react already safes from xss
@@ -6595,6 +6629,16 @@ i18next.use(initReactI18next) // passes i18n down to react-i18next,
6595
6629
 
6596
6630
  }
6597
6631
  });
6632
+ const pageLanguageObserver = new MutationObserver(mutationsList => {
6633
+ mutationsList.forEach(mutationRecord => {
6634
+ if (mutationRecord.attributeName === "lang") {
6635
+ i18next.changeLanguage(window.Pelcro.helpers.getHtmlLanguageAttribute());
6636
+ }
6637
+ });
6638
+ });
6639
+ pageLanguageObserver.observe(document.documentElement, {
6640
+ attributes: true
6641
+ });
6598
6642
 
6599
6643
  function _classPrivateFieldGet(receiver, privateMap) {
6600
6644
  var descriptor = privateMap.get(receiver);
@@ -8208,6 +8252,175 @@ function shouldBlurContent(entitlements) {
8208
8252
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
8209
8253
  }
8210
8254
 
8255
+ var pure$1 = createCommonjsModule(function (module, exports) {
8256
+
8257
+ Object.defineProperty(exports, '__esModule', { value: true });
8258
+
8259
+ function _typeof(obj) {
8260
+ "@babel/helpers - typeof";
8261
+
8262
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
8263
+ _typeof = function (obj) {
8264
+ return typeof obj;
8265
+ };
8266
+ } else {
8267
+ _typeof = function (obj) {
8268
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8269
+ };
8270
+ }
8271
+
8272
+ return _typeof(obj);
8273
+ }
8274
+
8275
+ var V3_URL = 'https://js.stripe.com/v3';
8276
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
8277
+ var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
8278
+ var findScript = function findScript() {
8279
+ var scripts = document.querySelectorAll("script[src^=\"".concat(V3_URL, "\"]"));
8280
+
8281
+ for (var i = 0; i < scripts.length; i++) {
8282
+ var script = scripts[i];
8283
+
8284
+ if (!V3_URL_REGEX.test(script.src)) {
8285
+ continue;
8286
+ }
8287
+
8288
+ return script;
8289
+ }
8290
+
8291
+ return null;
8292
+ };
8293
+
8294
+ var injectScript = function injectScript(params) {
8295
+ var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
8296
+ var script = document.createElement('script');
8297
+ script.src = "".concat(V3_URL).concat(queryString);
8298
+ var headOrBody = document.head || document.body;
8299
+
8300
+ if (!headOrBody) {
8301
+ throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
8302
+ }
8303
+
8304
+ headOrBody.appendChild(script);
8305
+ return script;
8306
+ };
8307
+
8308
+ var registerWrapper = function registerWrapper(stripe, startTime) {
8309
+ if (!stripe || !stripe._registerWrapper) {
8310
+ return;
8311
+ }
8312
+
8313
+ stripe._registerWrapper({
8314
+ name: 'stripe-js',
8315
+ version: "1.21.1",
8316
+ startTime: startTime
8317
+ });
8318
+ };
8319
+
8320
+ var stripePromise = null;
8321
+ var loadScript = function loadScript(params) {
8322
+ // Ensure that we only attempt to load Stripe.js at most once
8323
+ if (stripePromise !== null) {
8324
+ return stripePromise;
8325
+ }
8326
+
8327
+ stripePromise = new Promise(function (resolve, reject) {
8328
+ if (typeof window === 'undefined') {
8329
+ // Resolve to null when imported server side. This makes the module
8330
+ // safe to import in an isomorphic code base.
8331
+ resolve(null);
8332
+ return;
8333
+ }
8334
+
8335
+ if (window.Stripe && params) {
8336
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8337
+ }
8338
+
8339
+ if (window.Stripe) {
8340
+ resolve(window.Stripe);
8341
+ return;
8342
+ }
8343
+
8344
+ try {
8345
+ var script = findScript();
8346
+
8347
+ if (script && params) {
8348
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8349
+ } else if (!script) {
8350
+ script = injectScript(params);
8351
+ }
8352
+
8353
+ script.addEventListener('load', function () {
8354
+ if (window.Stripe) {
8355
+ resolve(window.Stripe);
8356
+ } else {
8357
+ reject(new Error('Stripe.js not available'));
8358
+ }
8359
+ });
8360
+ script.addEventListener('error', function () {
8361
+ reject(new Error('Failed to load Stripe.js'));
8362
+ });
8363
+ } catch (error) {
8364
+ reject(error);
8365
+ return;
8366
+ }
8367
+ });
8368
+ return stripePromise;
8369
+ };
8370
+ var initStripe = function initStripe(maybeStripe, args, startTime) {
8371
+ if (maybeStripe === null) {
8372
+ return null;
8373
+ }
8374
+
8375
+ var stripe = maybeStripe.apply(undefined, args);
8376
+ registerWrapper(stripe, startTime);
8377
+ return stripe;
8378
+ };
8379
+ var validateLoadParams = function validateLoadParams(params) {
8380
+ var errorMessage = "invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(params), "\n");
8381
+
8382
+ if (params === null || _typeof(params) !== 'object') {
8383
+ throw new Error(errorMessage);
8384
+ }
8385
+
8386
+ if (Object.keys(params).length === 1 && typeof params.advancedFraudSignals === 'boolean') {
8387
+ return params;
8388
+ }
8389
+
8390
+ throw new Error(errorMessage);
8391
+ };
8392
+
8393
+ var loadParams;
8394
+ var loadStripeCalled = false;
8395
+ var loadStripe = function loadStripe() {
8396
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8397
+ args[_key] = arguments[_key];
8398
+ }
8399
+
8400
+ loadStripeCalled = true;
8401
+ var startTime = Date.now();
8402
+ return loadScript(loadParams).then(function (maybeStripe) {
8403
+ return initStripe(maybeStripe, args, startTime);
8404
+ });
8405
+ };
8406
+
8407
+ loadStripe.setLoadParameters = function (params) {
8408
+ if (loadStripeCalled) {
8409
+ throw new Error('You cannot change load parameters after calling loadStripe');
8410
+ }
8411
+
8412
+ loadParams = validateLoadParams(params);
8413
+ };
8414
+
8415
+ exports.loadStripe = loadStripe;
8416
+ });
8417
+
8418
+ unwrapExports(pure$1);
8419
+ pure$1.loadStripe;
8420
+
8421
+ var pure = pure$1;
8422
+ var pure_1 = pure.loadStripe;
8423
+
8211
8424
  /**
8212
8425
  * @typedef {Object} OptionsType
8213
8426
  * @property {boolean} loadPaymentSDKs
@@ -8233,6 +8446,7 @@ const optionsController = options => {
8233
8446
  enableURLTriggers: initViewFromURL,
8234
8447
  enableTheme: applyPelcroTheme,
8235
8448
  enablePaywalls: initPaywalls,
8449
+ loadSecuritySDK: initSecuritySdk,
8236
8450
  enableGoogleAnalytics: initGATracking
8237
8451
  }; // Only execute enabled options
8238
8452
 
@@ -8277,8 +8491,15 @@ const initPaywalls = () => {
8277
8491
  }
8278
8492
  };
8279
8493
  const loadPaymentSDKs = () => {
8280
- // Load stripe's SDK
8281
- window.Pelcro.helpers.loadSDK("https://js.stripe.com/v3/", "pelcro-sdk-stripe-id"); // Load PayPal SDK's
8494
+ // Lazy load stripe's SDK
8495
+ const {
8496
+ whenUserReady
8497
+ } = usePelcro.getStore();
8498
+ whenUserReady(() => {
8499
+ if (!window.Stripe) {
8500
+ pure_1(window.Pelcro.environment.stripe);
8501
+ }
8502
+ }); // Load PayPal SDK's
8282
8503
 
8283
8504
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
8284
8505
 
@@ -8287,6 +8508,18 @@ const loadPaymentSDKs = () => {
8287
8508
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8288
8509
  }
8289
8510
  };
8511
+ const initSecuritySdk = () => {
8512
+ const {
8513
+ whenSiteReady
8514
+ } = usePelcro.getStore();
8515
+ whenSiteReady(() => {
8516
+ var _window$Pelcro$site$r2;
8517
+
8518
+ const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
8519
+ if (!securityKey) return;
8520
+ window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
8521
+ });
8522
+ };
8290
8523
  const initGATracking = () => {
8291
8524
  var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
8292
8525
 
@@ -8373,9 +8606,9 @@ const applyPelcroTheme = () => {
8373
8606
  };
8374
8607
 
8375
8608
  whenSiteReady(() => {
8376
- var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
8609
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
8377
8610
 
8378
- const primaryColorHex = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : (_window$Pelcro$site$r3 = _window$Pelcro$site$r2.design_settings) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.primary_color;
8611
+ const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
8379
8612
 
8380
8613
  if (!primaryColorHex) {
8381
8614
  return;
@@ -8574,6 +8807,7 @@ const defaultOptions = {
8574
8807
  enableURLTriggers: true,
8575
8808
  enableTheme: true,
8576
8809
  enablePaywalls: true,
8810
+ loadSecuritySDK: true,
8577
8811
  enableGoogleAnalytics: false
8578
8812
  };
8579
8813
  const PelcroModalController = ({
@@ -9514,35 +9748,53 @@ const RegisterContainer = ({
9514
9748
  jobTitle,
9515
9749
  selectFields
9516
9750
  } = filteredData;
9517
- window.Pelcro.user.register({
9518
- email,
9519
- password,
9520
- first_name: firstName,
9521
- last_name: lastName,
9522
- metadata: {
9523
- organization,
9524
- jobTitle,
9525
- ...selectFields
9526
- }
9527
- }, (err, res) => {
9528
- dispatch({
9529
- type: DISABLE_REGISTRATION_BUTTON,
9530
- payload: false
9751
+
9752
+ if (!hasSecurityTokenEnabled()) {
9753
+ sendRegisterRequest();
9754
+ return;
9755
+ }
9756
+
9757
+ window.grecaptcha.enterprise.ready(async () => {
9758
+ var _window$Pelcro$site$r;
9759
+
9760
+ const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
9761
+ action: "register"
9531
9762
  });
9763
+ sendRegisterRequest(token);
9764
+ });
9532
9765
 
9533
- if (err) {
9766
+ function sendRegisterRequest(securityToken) {
9767
+ window.Pelcro.user.register({
9768
+ email,
9769
+ password,
9770
+ first_name: firstName,
9771
+ last_name: lastName,
9772
+ security_token: securityToken,
9773
+ metadata: {
9774
+ organization,
9775
+ jobTitle,
9776
+ ...selectFields
9777
+ }
9778
+ }, (err, res) => {
9534
9779
  dispatch({
9535
- type: SHOW_ALERT,
9536
- payload: {
9537
- type: "error",
9538
- content: getErrorMessages(err)
9539
- }
9780
+ type: DISABLE_REGISTRATION_BUTTON,
9781
+ payload: false
9540
9782
  });
9541
- onFailure(err);
9542
- } else {
9543
- onSuccess(res);
9544
- }
9545
- });
9783
+
9784
+ if (err) {
9785
+ dispatch({
9786
+ type: SHOW_ALERT,
9787
+ payload: {
9788
+ type: "error",
9789
+ content: getErrorMessages(err)
9790
+ }
9791
+ });
9792
+ onFailure(err);
9793
+ } else {
9794
+ onSuccess(res);
9795
+ }
9796
+ });
9797
+ }
9546
9798
  };
9547
9799
 
9548
9800
  const handleSocialLogin = ({
@@ -9693,6 +9945,15 @@ const RegisterContainer = ({
9693
9945
  store: store$e
9694
9946
  })));
9695
9947
  };
9948
+ /**
9949
+ * Checks if the current site has security token enabled
9950
+ * @return {boolean}
9951
+ */
9952
+
9953
+ function hasSecurityTokenEnabled() {
9954
+ const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
9955
+ return hasSecuritySdkLoaded;
9956
+ }
9696
9957
 
9697
9958
  var _path$l;
9698
9959
 
@@ -9714,7 +9975,7 @@ const FacebookLoginButton = ({
9714
9975
  labelClassName = "",
9715
9976
  iconClassName = ""
9716
9977
  }) => {
9717
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9978
+ var _window$Pelcro$site$r;
9718
9979
 
9719
9980
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
9720
9981
  const {
@@ -9753,7 +10014,7 @@ const FacebookLoginButton = ({
9753
10014
 
9754
10015
  return facebookLoginEnabled ? /*#__PURE__*/React__default.createElement(FacebookLogin, {
9755
10016
  appId: window.Pelcro.site.read().facebook_app_id,
9756
- language: (_window$Pelcro$site$r2 = window.Pelcro.site.read().default_locale) !== null && _window$Pelcro$site$r2 !== void 0 ? _window$Pelcro$site$r2 : "en_US",
10017
+ language: getPageOrDefaultLanguage(),
9757
10018
  fields: "first_name,last_name,email,picture",
9758
10019
  callback: onSuccess,
9759
10020
  onFailure: onFailure,
@@ -10082,8 +10343,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Pass
10082
10343
  const RegisterButton = ({
10083
10344
  name,
10084
10345
  onClick,
10346
+ className,
10085
10347
  ...otherProps
10086
10348
  }) => {
10349
+ var _window$Pelcro$site$r;
10350
+
10087
10351
  const {
10088
10352
  state: {
10089
10353
  emailError,
@@ -10109,7 +10373,10 @@ const RegisterButton = ({
10109
10373
  onClick === null || onClick === void 0 ? void 0 : onClick();
10110
10374
  },
10111
10375
  disabled: isDisabled,
10112
- isLoading: buttonDisabled
10376
+ isLoading: buttonDisabled,
10377
+ className: `${className} g-recaptcha`,
10378
+ "data-action": "register",
10379
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
10113
10380
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
10114
10381
  };
10115
10382
 
@@ -13287,7 +13554,7 @@ const PaymentMethodContainer = props => {
13287
13554
  return /*#__PURE__*/React__default.createElement(es_13, {
13288
13555
  apiKey: window.Pelcro.environment.stripe,
13289
13556
  stripeAccount: window.Pelcro.site.read().account_id,
13290
- locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13557
+ locale: getPageOrDefaultLanguage()
13291
13558
  }, /*#__PURE__*/React__default.createElement(es_11, null, /*#__PURE__*/React__default.createElement(UnwrappedForm, Object.assign({
13292
13559
  store: store$d
13293
13560
  }, props))));
@@ -13399,9 +13666,6 @@ const DiscountedPrice = props => {
13399
13666
  percentOff
13400
13667
  }
13401
13668
  } = useContext(store$d);
13402
- const {
13403
- default_locale
13404
- } = Pelcro.site.read();
13405
13669
  const {
13406
13670
  order,
13407
13671
  plan
@@ -13409,7 +13673,7 @@ const DiscountedPrice = props => {
13409
13673
  const ecommOrderCurrency = (_order$currency = order === null || order === void 0 ? void 0 : order.currency) !== null && _order$currency !== void 0 ? _order$currency : order === null || order === void 0 ? void 0 : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
13410
13674
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13411
13675
  const discountedPriceWithoutTax = updatedPrice - taxAmount;
13412
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13676
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13413
13677
 
13414
13678
  if (percentOff) {
13415
13679
  return /*#__PURE__*/React__default.createElement("div", Object.assign({
@@ -13442,12 +13706,9 @@ const SubmitPaymentMethod = ({
13442
13706
  updatedPrice
13443
13707
  }
13444
13708
  } = useContext(store$d);
13445
- const {
13446
- default_locale
13447
- } = Pelcro.site.read();
13448
13709
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13449
13710
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
13450
- const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13711
+ const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13451
13712
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
13452
13713
  role: "submit",
13453
13714
  className: "plc-w-full plc-py-3",
@@ -13692,7 +13953,7 @@ class PaypalClient {
13692
13953
  this.paypalButton = window.paypal.Buttons({
13693
13954
  fundingSource: window.paypal.FUNDING.PAYPAL,
13694
13955
  // button locale
13695
- locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : this.siteInfo.default_locale,
13956
+ locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : getPageOrDefaultLanguage(),
13696
13957
  // button style
13697
13958
  style: (_this$config$style = this.config.style) !== null && _this$config$style !== void 0 ? _this$config$style : defaultButtonStyle,
13698
13959
  // create payment handler
@@ -13789,7 +14050,7 @@ class PaypalClient {
13789
14050
  } : undefined,
13790
14051
  shippingAddressEditable: this.config.shippingAddressEditable,
13791
14052
  displayName: (_this$config$displayN = this.config.displayName) !== null && _this$config$displayN !== void 0 ? _this$config$displayN : this.siteInfo.name,
13792
- locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : this.siteInfo.default_locale
14053
+ locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : getPageOrDefaultLanguage()
13793
14054
  };
13794
14055
  }
13795
14056
  });
@@ -13798,7 +14059,7 @@ class PaypalClient {
13798
14059
  writable: true,
13799
14060
  value: () => {
13800
14061
  const totalAmount = (this.product.quantity || 1) * this.amount;
13801
- const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, this.siteInfo.default_locale);
14062
+ const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, getPageOrDefaultLanguage());
13802
14063
  const autoRenewed = this.product.auto_renew;
13803
14064
  const {
13804
14065
  interval,
@@ -13995,14 +14256,11 @@ const TaxAmount = () => {
13995
14256
  taxAmount
13996
14257
  }
13997
14258
  } = useContext(store$d);
13998
- const {
13999
- default_locale
14000
- } = Pelcro.site.read();
14001
14259
  const {
14002
14260
  plan
14003
14261
  } = usePelcro();
14004
14262
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14005
- const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14263
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14006
14264
 
14007
14265
  if (taxAmount) {
14008
14266
  return /*#__PURE__*/React__default.createElement("div", {
@@ -14875,10 +15133,7 @@ const SubscriptionCreateView = ({
14875
15133
  interval,
14876
15134
  count: interval_count
14877
15135
  });
14878
- const {
14879
- default_locale
14880
- } = Pelcro.site.read();
14881
- const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
15136
+ const priceFormatted = getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14882
15137
  return /*#__PURE__*/React__default.createElement("p", {
14883
15138
  className: "plc-text-gray-600"
14884
15139
  }, /*#__PURE__*/React__default.createElement("span", {
@@ -18055,7 +18310,6 @@ const OrderConfirmModal = props => {
18055
18310
  const userOrders = window.Pelcro.user.read().orders;
18056
18311
  const latestOrder = userOrders === null || userOrders === void 0 ? void 0 : userOrders[userOrders.length - 1];
18057
18312
  const latestOrderDiscount = latestOrder === null || latestOrder === void 0 ? void 0 : (_latestOrder$coupon = latestOrder.coupon) === null || _latestOrder$coupon === void 0 ? void 0 : _latestOrder$coupon.percent_off;
18058
- const locale = window.Pelcro.site.read().default_locale;
18059
18313
  const {
18060
18314
  t
18061
18315
  } = useTranslation("shop");
@@ -18114,7 +18368,7 @@ const OrderConfirmModal = props => {
18114
18368
  className: "plc-mr-1 pelcro-summary-total-text"
18115
18369
  }, t("labels.total")), /*#__PURE__*/React__default.createElement("p", {
18116
18370
  className: "pelcro-summary-total"
18117
- }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, locale)))), /*#__PURE__*/React__default.createElement("div", {
18371
+ }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("div", {
18118
18372
  className: "plc-flex plc-justify-center plc-mt-6"
18119
18373
  }, /*#__PURE__*/React__default.createElement(Button, {
18120
18374
  id: "pelcro-submit",
@@ -18176,9 +18430,9 @@ const GiftCreateContainer = ({
18176
18430
  }
18177
18431
 
18178
18432
  if (giftRecipient.startDate) {
18179
- const nowDate = new Date();
18180
- const yearFromNowDate = new Date(new Date().setFullYear(nowDate.getFullYear() + 1));
18181
- const submittedDate = new Date(giftRecipient.startDate);
18433
+ const nowDate = getDateWithoutTime(new Date());
18434
+ const yearFromNowDate = getDateWithoutTime(new Date(new Date().setFullYear(nowDate.getFullYear() + 1)));
18435
+ const submittedDate = getDateWithoutTime(new Date(giftRecipient.startDate));
18182
18436
 
18183
18437
  if (submittedDate < nowDate || submittedDate > yearFromNowDate) {
18184
18438
  dispatch({
@@ -20483,7 +20737,6 @@ const OrderItems = ({
20483
20737
  const {
20484
20738
  t
20485
20739
  } = useTranslation("dashboard");
20486
- const site = window.Pelcro.site.read();
20487
20740
  return !(orders !== null && orders !== void 0 && orders.length) ? /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20488
20741
  colSpan: "3",
20489
20742
  className: "plc-text-center plc-text-gray-500"
@@ -20499,7 +20752,7 @@ const OrderItems = ({
20499
20752
  className: "plc-py-4 plc-pl-2"
20500
20753
  }, /*#__PURE__*/React__default.createElement("span", {
20501
20754
  className: "plc-text-xl plc-font-semibold "
20502
- }, getFormattedPriceByLocal(order.amount, order.currency, site.default_locale)), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20755
+ }, getFormattedPriceByLocal(order.amount, order.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20503
20756
  className: "plc-text-xs plc-text-gray-400 plc-uppercase"
20504
20757
  }, t("labels.orders.itemsAmount", {
20505
20758
  count: getItemsAmount(order.id)
@@ -20528,7 +20781,7 @@ const OrderItems = ({
20528
20781
  className: ""
20529
20782
  }, item.product_sku_name))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
20530
20783
  className: "plc-font-semibold"
20531
- }, getFormattedPriceByLocal(item.amount, order.currency, site.default_locale))));
20784
+ }, getFormattedPriceByLocal(item.amount, order.currency, getPageOrDefaultLanguage()))));
20532
20785
  }), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20533
20786
  colSpan: "3"
20534
20787
  }, /*#__PURE__*/React__default.createElement("hr", {
@@ -21255,7 +21508,7 @@ class Dashboard extends Component {
21255
21508
  className: "plc-font-semibold plc-text-gray-500"
21256
21509
  }, sub.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
21257
21510
  className: "plc-text-xs plc-text-gray-400"
21258
- }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, this.site.default_locale)))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21511
+ }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21259
21512
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(sub).bgColor} plc-uppercase ${this.getSubscriptionStatus(sub).textColor} plc-rounded-lg`
21260
21513
  }, this.getSubscriptionStatus(sub).icon, this.getSubscriptionStatus(sub).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21261
21514
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
@@ -21358,7 +21611,7 @@ class Dashboard extends Component {
21358
21611
  className: "plc-font-semibold plc-text-gray-500"
21359
21612
  }, recipient.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
21360
21613
  className: "plc-text-xs plc-text-gray-400"
21361
- }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, this.site.default_locale)))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21614
+ }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, getPageOrDefaultLanguage())))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21362
21615
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(recipient).bgColor} plc-uppercase ${this.getSubscriptionStatus(recipient).textColor} plc-rounded-lg`
21363
21616
  }, this.getSubscriptionStatus(recipient).icon, this.getSubscriptionStatus(recipient).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21364
21617
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"