@pelcro/react-pelcro-js 2.4.0-beta.9 → 2.6.0-beta.2

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.cjs.js CHANGED
@@ -3462,6 +3462,7 @@ var paymentMethod_fr = {
3462
3462
  };
3463
3463
 
3464
3464
  var title$d = "Enter your email to subscribe to our newsletter";
3465
+ var updateTitle$1 = "Update newsletter selections";
3465
3466
  var subtitle$7 = "We may use your email for other marketing communication";
3466
3467
  var labels$l = {
3467
3468
  submit: "Submit",
@@ -3473,22 +3474,21 @@ var labels$l = {
3473
3474
  };
3474
3475
  var messages$p = {
3475
3476
  alreadyHaveAccount: "Already have an account?",
3477
+ success: "Newsletters were successfully updated",
3476
3478
  loginHere: "Login here.",
3477
3479
  createAnAccount: " Create an account by clicking ",
3478
3480
  here: "here"
3479
3481
  };
3480
- var errors$b = {
3481
- "": ""
3482
- };
3483
3482
  var newsletter_en = {
3484
3483
  title: title$d,
3484
+ updateTitle: updateTitle$1,
3485
3485
  subtitle: subtitle$7,
3486
3486
  labels: labels$l,
3487
- messages: messages$p,
3488
- errors: errors$b
3487
+ messages: messages$p
3489
3488
  };
3490
3489
 
3491
3490
  var title$c = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
3491
+ var updateTitle = "Mettre à jour son choix d'infolettres";
3492
3492
  var subtitle$6 = "Nous pouvons utiliser votre adresse courriel pour d’autres communications marketing";
3493
3493
  var labels$k = {
3494
3494
  submit: "Lire l’article !",
@@ -3500,19 +3500,17 @@ var labels$k = {
3500
3500
  };
3501
3501
  var messages$o = {
3502
3502
  alreadyHaveAccount: "Vous avez déjà un compte ?",
3503
+ success: "Votre choix d'infolettres à été mis à jour",
3503
3504
  loginHere: "Connectez-vous ici",
3504
3505
  createAnAccount: " Créez un compte en cliquant ",
3505
3506
  here: "ici"
3506
3507
  };
3507
- var errors$a = {
3508
- "": ""
3509
- };
3510
3508
  var newsletter_fr = {
3511
3509
  title: title$c,
3510
+ updateTitle: updateTitle,
3512
3511
  subtitle: subtitle$6,
3513
3512
  labels: labels$k,
3514
- messages: messages$o,
3515
- errors: errors$a
3513
+ messages: messages$o
3516
3514
  };
3517
3515
 
3518
3516
  var labels$j = {
@@ -3621,7 +3619,8 @@ var labels$h = {
3621
3619
  code: "Coupon code",
3622
3620
  "for": "for",
3623
3621
  interval: "{{count}} {{interval}}",
3624
- interval_plural: "{{count}} {{interval}}s"
3622
+ interval_plural: "{{count}} {{interval}}s",
3623
+ tax: "+ Tax"
3625
3624
  };
3626
3625
  var checkoutForm_en = {
3627
3626
  messages: messages$j,
@@ -3646,7 +3645,8 @@ var labels$g = {
3646
3645
  code: "Code promo",
3647
3646
  "for": "pour",
3648
3647
  interval: "{{count}} {{interval}}",
3649
- interval_plural: "{{count}} {{interval}}s"
3648
+ interval_plural: "{{count}} {{interval}}s",
3649
+ tax: "+ Taxe"
3650
3650
  };
3651
3651
  var checkoutForm_fr = {
3652
3652
  messages: messages$i,
@@ -4375,6 +4375,7 @@ var labels$3 = {
4375
4375
  profile: "Profile",
4376
4376
  updateProfile: "Edit profile",
4377
4377
  changePassword: "Change password",
4378
+ editNewsletters: "Edit newsletters",
4378
4379
  edit: "Edit",
4379
4380
  gifts: "Gifts",
4380
4381
  redeemGift: "Redeem gift",
@@ -4451,6 +4452,7 @@ var labels$2 = {
4451
4452
  profile: "Profil",
4452
4453
  updateProfile: "Mettre à jour le profil",
4453
4454
  changePassword: "Changer le mot de passe",
4455
+ editNewsletters: "Modifier les newsletters",
4454
4456
  edit: "Modifier",
4455
4457
  gifts: "Cadeaux",
4456
4458
  redeemGift: "Échanger un cadeau",
@@ -5927,7 +5929,7 @@ class PelcroActions {
5927
5929
  view,
5928
5930
  cartItems,
5929
5931
  ...otherStateFields
5930
- } = initialState$f;
5932
+ } = initialState$g;
5931
5933
  this.set(otherStateFields);
5932
5934
  });
5933
5935
 
@@ -6217,7 +6219,7 @@ class PelcroCallbacks {
6217
6219
 
6218
6220
  }
6219
6221
 
6220
- const initialState$f = {
6222
+ const initialState$g = {
6221
6223
  // View
6222
6224
  view: null,
6223
6225
  // Plans
@@ -6245,7 +6247,7 @@ const createPelcroStore = () => createStore(middleware_3((set, get) => {
6245
6247
  return {
6246
6248
  // Store setter
6247
6249
  set,
6248
- ...initialState$f,
6250
+ ...initialState$g,
6249
6251
  // State actions
6250
6252
  ...actions,
6251
6253
  // Callbacks
@@ -6376,11 +6378,40 @@ const calcAndFormatItemsTotal = (items, currency) => {
6376
6378
  */
6377
6379
 
6378
6380
  const isValidViewFromURL = viewID => {
6379
- if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart"].includes(viewID)) {
6381
+ if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6380
6382
  return true;
6381
6383
  }
6382
6384
 
6383
6385
  return false;
6386
+
6387
+ function hasValidNewsletterUpdateUrl() {
6388
+ var _window$Pelcro, _window$Pelcro$uiSett;
6389
+
6390
+ if (viewID !== "newsletter-update") return false;
6391
+ 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;
6392
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6393
+
6394
+ if (!siteHasNewslettersDefined) {
6395
+ return false;
6396
+ }
6397
+
6398
+ const queryParamEmail = window.Pelcro.helpers.getURLParameter("email");
6399
+
6400
+ if (queryParamEmail && window.Pelcro.user.isAuthenticated()) {
6401
+ var _window$Pelcro$user$r4;
6402
+
6403
+ if (queryParamEmail !== ((_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.email)) {
6404
+ console.error("email query parameter and user account email are different, url email query parameter must match user email if user is logged in");
6405
+ return false;
6406
+ }
6407
+ }
6408
+
6409
+ if (!queryParamEmail && !window.Pelcro.user.isAuthenticated()) {
6410
+ return false;
6411
+ }
6412
+
6413
+ return true;
6414
+ }
6384
6415
  };
6385
6416
  /**
6386
6417
  * Returns the current stable viewID from all old variations
@@ -6412,7 +6443,7 @@ const disableScroll = () => {
6412
6443
  }
6413
6444
  };
6414
6445
  const trackSubscriptionOnGA = () => {
6415
- var _ReactGA$set, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6446
+ var _ReactGA$set, _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6416
6447
 
6417
6448
  const {
6418
6449
  product,
@@ -6434,7 +6465,7 @@ const trackSubscriptionOnGA = () => {
6434
6465
  }
6435
6466
 
6436
6467
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
6437
- currencyCode: (_window$Pelcro$user$r4 = (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.currency) !== null && _window$Pelcro$user$r4 !== void 0 ? _window$Pelcro$user$r4 : plan.currency
6468
+ currencyCode: (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency
6438
6469
  });
6439
6470
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin = ReactGA.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$execu = _ReactGA$plugin.execute) === null || _ReactGA$plugin$execu === void 0 ? void 0 : _ReactGA$plugin$execu.call(_ReactGA$plugin, "ecommerce", "addTransaction", {
6440
6471
  id: lastSubscriptionId,
@@ -6462,9 +6493,9 @@ const trackSubscriptionOnGA = () => {
6462
6493
  */
6463
6494
 
6464
6495
  const userHasPaymentMethod = () => {
6465
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
6496
+ var _window$Pelcro$user$r7, _window$Pelcro$user$r8;
6466
6497
 
6467
- const sources = (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.sources) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : [];
6498
+ const sources = (_window$Pelcro$user$r7 = (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.sources) !== null && _window$Pelcro$user$r7 !== void 0 ? _window$Pelcro$user$r7 : [];
6468
6499
  return sources.length > 0;
6469
6500
  };
6470
6501
  /**
@@ -6846,8 +6877,8 @@ const saveToMetadataButton = new SaveToMetadataButtonClass();
6846
6877
 
6847
6878
  let e={data:""},t=t=>"undefined"!=typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||e,l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(})/g,a=/\/\*[^]*?\*\/|\s\s+|\n/g,n=(e,t)=>{let r,l="",a="",o="";for(let c in e){let s=e[c];"object"==typeof s?(r=t?t.replace(/([^,])+/g,e=>c.replace(/([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):c,a+="@"==c[0]?"f"==c[1]?n(s,c):c+"{"+n(s,"k"==c[1]?"":t)+"}":n(s,r)):"@"==c[0]&&"i"==c[1]?l=c+" "+s+";":(c=c.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=n.p?n.p(c,s):c+":"+s+";");}return o[0]?(r=t?t+"{"+o+"}":o,l+r+a):l+a},o={},c=e=>{let t="";for(let r in e)t+=r+("object"==typeof e[r]?c(e[r]):e[r]);return t},s=(e,t,r,s,i)=>{let p="object"==typeof e?c(e):e,u=o[p]||(o[p]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return "go"+r})(p));if(!o[u]){let t="object"==typeof e?e:(e=>{let t,r=[{}];for(;t=l.exec(e.replace(a,""));)t[4]&&r.shift(),t[3]?r.unshift(r[0][t[3]]=r[0][t[3]]||{}):t[4]||(r[0][t[1]]=t[2]);return r[0]})(e);o[u]=n(i?{["@keyframes "+u]:t}:t,r?"":"."+u);}return ((e,t,r)=>{-1==t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e);})(o[u],t,s),u},i=(e,t,r)=>e.reduce((e,l,a)=>{let o=t[a];if(o&&o.call){let e=o(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;o=t?"."+t:e&&"object"==typeof e?e.props?"":n(e,""):e;}return e+l+(null==o?"":o)},"");function p(e){let r=this||{},l=e.call?e(r.p):e;return s(l.unshift?l.raw?i(l,[].slice.call(arguments,1),r.p):l.reduce((e,t)=>t?Object.assign(e,t.call?t(r.p):t):e,{}):l,t(r.target),r.g,r.o,r.k)}let u,f,d;p.bind({g:1});let b=p.bind({k:1});function h(e,t,r,l){n.p=t,u=e,f=r,d=l;}function y(e,t){let r=this||{};return function(){let l=arguments;function a(n,o){let c=Object.assign({},n),s=c.className||a.className;r.p=Object.assign({theme:f&&f()},c),r.o=/ *go\d+/.test(s),c.className=p.apply(r,l)+(s?" "+s:""),t&&(c.ref=o);let i=c.as||e;return d&&i[0]&&d(c),u(i,c)}return t?t(a):a}}
6848
6879
 
6849
- function _extends$t() {
6850
- _extends$t = Object.assign || function (target) {
6880
+ function _extends$u() {
6881
+ _extends$u = Object.assign || function (target) {
6851
6882
  for (var i = 1; i < arguments.length; i++) {
6852
6883
  var source = arguments[i];
6853
6884
 
@@ -6861,7 +6892,7 @@ function _extends$t() {
6861
6892
  return target;
6862
6893
  };
6863
6894
 
6864
- return _extends$t.apply(this, arguments);
6895
+ return _extends$u.apply(this, arguments);
6865
6896
  }
6866
6897
 
6867
6898
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -6951,7 +6982,7 @@ var clearFromRemoveQueue = function clearFromRemoveQueue(toastId) {
6951
6982
  var reducer = function reducer(state, action) {
6952
6983
  switch (action.type) {
6953
6984
  case ActionType.ADD_TOAST:
6954
- return _extends$t({}, state, {
6985
+ return _extends$u({}, state, {
6955
6986
  toasts: [action.toast].concat(state.toasts).slice(0, TOAST_LIMIT)
6956
6987
  });
6957
6988
 
@@ -6961,9 +6992,9 @@ var reducer = function reducer(state, action) {
6961
6992
  clearFromRemoveQueue(action.toast.id);
6962
6993
  }
6963
6994
 
6964
- return _extends$t({}, state, {
6995
+ return _extends$u({}, state, {
6965
6996
  toasts: state.toasts.map(function (t) {
6966
- return t.id === action.toast.id ? _extends$t({}, t, action.toast) : t;
6997
+ return t.id === action.toast.id ? _extends$u({}, t, action.toast) : t;
6967
6998
  })
6968
6999
  });
6969
7000
 
@@ -6990,9 +7021,9 @@ var reducer = function reducer(state, action) {
6990
7021
  });
6991
7022
  }
6992
7023
 
6993
- return _extends$t({}, state, {
7024
+ return _extends$u({}, state, {
6994
7025
  toasts: state.toasts.map(function (t) {
6995
- return t.id === toastId || toastId === undefined ? _extends$t({}, t, {
7026
+ return t.id === toastId || toastId === undefined ? _extends$u({}, t, {
6996
7027
  visible: false
6997
7028
  }) : t;
6998
7029
  })
@@ -7000,28 +7031,28 @@ var reducer = function reducer(state, action) {
7000
7031
 
7001
7032
  case ActionType.REMOVE_TOAST:
7002
7033
  if (action.toastId === undefined) {
7003
- return _extends$t({}, state, {
7034
+ return _extends$u({}, state, {
7004
7035
  toasts: []
7005
7036
  });
7006
7037
  }
7007
7038
 
7008
- return _extends$t({}, state, {
7039
+ return _extends$u({}, state, {
7009
7040
  toasts: state.toasts.filter(function (t) {
7010
7041
  return t.id !== action.toastId;
7011
7042
  })
7012
7043
  });
7013
7044
 
7014
7045
  case ActionType.START_PAUSE:
7015
- return _extends$t({}, state, {
7046
+ return _extends$u({}, state, {
7016
7047
  pausedAt: action.time
7017
7048
  });
7018
7049
 
7019
7050
  case ActionType.END_PAUSE:
7020
7051
  var diff = action.time - (state.pausedAt || 0);
7021
- return _extends$t({}, state, {
7052
+ return _extends$u({}, state, {
7022
7053
  pausedAt: undefined,
7023
7054
  toasts: state.toasts.map(function (t) {
7024
- return _extends$t({}, t, {
7055
+ return _extends$u({}, t, {
7025
7056
  pauseDuration: t.pauseDuration + diff
7026
7057
  });
7027
7058
  })
@@ -7068,12 +7099,12 @@ var useStore = function useStore(toastOptions) {
7068
7099
  var mergedToasts = state.toasts.map(function (t) {
7069
7100
  var _toastOptions$t$type, _toastOptions, _toastOptions$t$type2;
7070
7101
 
7071
- return _extends$t({}, toastOptions, toastOptions[t.type], t, {
7102
+ return _extends$u({}, toastOptions, toastOptions[t.type], t, {
7072
7103
  duration: t.duration || ((_toastOptions$t$type = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type.duration) || ((_toastOptions = toastOptions) == null ? void 0 : _toastOptions.duration) || defaultTimeouts[t.type],
7073
- style: _extends$t({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7104
+ style: _extends$u({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7074
7105
  });
7075
7106
  });
7076
- return _extends$t({}, state, {
7107
+ return _extends$u({}, state, {
7077
7108
  toasts: mergedToasts
7078
7109
  });
7079
7110
  };
@@ -7083,7 +7114,7 @@ var createToast = function createToast(message, type, opts) {
7083
7114
  type = 'blank';
7084
7115
  }
7085
7116
 
7086
- return _extends$t({
7117
+ return _extends$u({
7087
7118
  createdAt: Date.now(),
7088
7119
  visible: true,
7089
7120
  type: type,
@@ -7133,14 +7164,14 @@ toast.remove = function (toastId) {
7133
7164
  };
7134
7165
 
7135
7166
  toast.promise = function (promise, msgs, opts) {
7136
- var id = toast.loading(msgs.loading, _extends$t({}, opts, opts == null ? void 0 : opts.loading));
7167
+ var id = toast.loading(msgs.loading, _extends$u({}, opts, opts == null ? void 0 : opts.loading));
7137
7168
  promise.then(function (p) {
7138
- toast.success(resolveValue(msgs.success, p), _extends$t({
7169
+ toast.success(resolveValue(msgs.success, p), _extends$u({
7139
7170
  id: id
7140
7171
  }, opts, opts == null ? void 0 : opts.success));
7141
7172
  return p;
7142
7173
  })["catch"](function (e) {
7143
- toast.error(resolveValue(msgs.error, e), _extends$t({
7174
+ toast.error(resolveValue(msgs.error, e), _extends$u({
7144
7175
  id: id
7145
7176
  }, opts, opts == null ? void 0 : opts.error));
7146
7177
  });
@@ -7479,7 +7510,7 @@ var ToastBar = /*#__PURE__*/React.memo(function (_ref2) {
7479
7510
  var message = React.createElement(Message, Object.assign({}, toast.ariaProps), resolveValue(toast.message, toast));
7480
7511
  return React.createElement(ToastBarBase, {
7481
7512
  className: toast.className,
7482
- style: _extends$t({}, animationStyle, style, toast.style)
7513
+ style: _extends$u({}, animationStyle, style, toast.style)
7483
7514
  }, typeof children === 'function' ? children({
7484
7515
  icon: icon,
7485
7516
  message: message
@@ -7509,7 +7540,7 @@ var getPositionStyle = function getPositionStyle(position, offset) {
7509
7540
  } : position.includes('right') ? {
7510
7541
  justifyContent: 'flex-end'
7511
7542
  } : {};
7512
- return _extends$t({
7543
+ return _extends$u({
7513
7544
  left: 0,
7514
7545
  right: 0,
7515
7546
  display: 'flex',
@@ -7536,7 +7567,7 @@ var Toaster = function Toaster(_ref) {
7536
7567
  handlers = _useToaster.handlers;
7537
7568
 
7538
7569
  return React.createElement("div", {
7539
- style: _extends$t({
7570
+ style: _extends$u({
7540
7571
  position: 'fixed',
7541
7572
  zIndex: 9999,
7542
7573
  top: DEFAULT_OFFSET,
@@ -7571,82 +7602,82 @@ var Toaster = function Toaster(_ref) {
7571
7602
  }));
7572
7603
  };
7573
7604
 
7574
- var _path$q;
7605
+ var _path$r;
7575
7606
 
7576
- function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
7607
+ function _extends$t() { _extends$t = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
7577
7608
 
7578
7609
  function SvgCheckSolid(props) {
7579
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$s({
7610
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$t({
7580
7611
  xmlns: "http://www.w3.org/2000/svg",
7581
7612
  className: "h-5 w-5",
7582
7613
  viewBox: "0 0 20 20",
7583
7614
  fill: "currentColor"
7584
- }, props), _path$q || (_path$q = /*#__PURE__*/React__namespace.createElement("path", {
7615
+ }, props), _path$r || (_path$r = /*#__PURE__*/React__namespace.createElement("path", {
7585
7616
  fillRule: "evenodd",
7586
7617
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
7587
7618
  clipRule: "evenodd"
7588
7619
  })));
7589
7620
  }
7590
7621
 
7591
- var _path$p;
7622
+ var _path$q;
7592
7623
 
7593
- function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
7624
+ function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
7594
7625
 
7595
7626
  function SvgXIcon(props) {
7596
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$r({
7627
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$s({
7597
7628
  xmlns: "http://www.w3.org/2000/svg",
7598
7629
  viewBox: "0 0 20 20",
7599
7630
  fill: "currentColor"
7600
- }, props), _path$p || (_path$p = /*#__PURE__*/React__namespace.createElement("path", {
7631
+ }, props), _path$q || (_path$q = /*#__PURE__*/React__namespace.createElement("path", {
7601
7632
  fill: "evenodd",
7602
7633
  d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
7603
7634
  clipRule: "evenodd"
7604
7635
  })));
7605
7636
  }
7606
7637
 
7607
- var _path$o;
7638
+ var _path$p;
7608
7639
 
7609
- function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
7640
+ function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
7610
7641
 
7611
7642
  function SvgXIconSolid(props) {
7612
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$q({
7643
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$r({
7613
7644
  className: "plc-w-4 plc-h-4",
7614
7645
  fill: "currentColor",
7615
7646
  xmlns: "http://www.w3.org/2000/svg",
7616
7647
  viewBox: "0 0 100 100"
7617
- }, props), _path$o || (_path$o = /*#__PURE__*/React__namespace.createElement("path", {
7648
+ }, props), _path$p || (_path$p = /*#__PURE__*/React__namespace.createElement("path", {
7618
7649
  d: "M94.842 48.408c0 24.852-20.148 44.999-45.002 44.999-24.851 0-44.997-20.146-44.997-44.999 0-24.854 20.146-45 44.997-45 24.853 0 45.002 20.146 45.002 45zM71.073 64.841L54.73 48.497l16.344-16.344-4.979-4.979-16.343 16.345-16.343-16.344-4.799 4.799 16.344 16.344L28.61 64.661l4.979 4.978 16.344-16.344 16.343 16.344 4.797-4.798z"
7619
7650
  })));
7620
7651
  }
7621
7652
 
7622
- var _path$n;
7653
+ var _path$o;
7623
7654
 
7624
- function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
7655
+ function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
7625
7656
 
7626
7657
  function SvgExclamation(props) {
7627
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$p({
7658
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$q({
7628
7659
  className: "plc-w-4 plc-h-4 plc-mr-1",
7629
7660
  xmlns: "http://www.w3.org/2000/svg",
7630
7661
  viewBox: "0 0 20 20",
7631
7662
  fill: "currentColor"
7632
- }, props), _path$n || (_path$n = /*#__PURE__*/React__namespace.createElement("path", {
7663
+ }, props), _path$o || (_path$o = /*#__PURE__*/React__namespace.createElement("path", {
7633
7664
  fillRule: "evenodd",
7634
7665
  d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
7635
7666
  clipRule: "evenodd"
7636
7667
  })));
7637
7668
  }
7638
7669
 
7639
- var _path$m, _path2$3;
7670
+ var _path$n, _path2$3;
7640
7671
 
7641
- function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
7672
+ function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
7642
7673
 
7643
7674
  function SvgSpinner(props) {
7644
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$o({
7675
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$p({
7645
7676
  className: "plc-animate-spin",
7646
7677
  viewBox: "0 0 24 24",
7647
7678
  fill: "currentColor",
7648
7679
  xmlns: "http://www.w3.org/2000/svg"
7649
- }, props), _path$m || (_path$m = /*#__PURE__*/React__namespace.createElement("path", {
7680
+ }, props), _path$n || (_path$n = /*#__PURE__*/React__namespace.createElement("path", {
7650
7681
  opacity: 0.2,
7651
7682
  fill: "evenodd",
7652
7683
  clipRule: "evenodd",
@@ -7872,6 +7903,16 @@ const init$1 = () => {
7872
7903
  }
7873
7904
  }
7874
7905
 
7906
+ const pelcroUpdateNewslettersButtons = document.getElementsByClassName("pelcro-update-newsletters-button");
7907
+
7908
+ if (pelcroUpdateNewslettersButtons.length !== 0) {
7909
+ for (let i = 0; i < pelcroUpdateNewslettersButtons.length; i++) {
7910
+ pelcroUpdateNewslettersButtons[i].addEventListener("click", () => {
7911
+ switchView("newsletter-update");
7912
+ });
7913
+ }
7914
+ }
7915
+
7875
7916
  const pelcroCartButtonsByClass = document.getElementsByClassName("pelcro-cart-button");
7876
7917
 
7877
7918
  if (pelcroCartButtonsByClass.length !== 0) {
@@ -8087,87 +8128,71 @@ function Link({
8087
8128
 
8088
8129
  const init = () => {
8089
8130
  const {
8090
- whenSiteReady,
8091
- view,
8092
- resetView,
8093
8131
  switchView,
8094
8132
  set
8095
8133
  } = usePelcro.getStore();
8096
- whenSiteReady(() => {
8097
- const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8134
+ const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8098
8135
 
8099
- if (entitlementsProtectedElements.length === 0) {
8100
- return;
8101
- }
8136
+ if (entitlementsProtectedElements.length === 0) {
8137
+ return false;
8138
+ }
8102
8139
 
8103
- if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8104
- console.error("not all elements protected by entitlements have the same entitlements, all elements protected by entitlements must have the exact same data-pelcro-entitlements attribute value");
8105
- return;
8106
- }
8140
+ if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8141
+ console.error("not all elements protected by entitlements have the same entitlements, all elements protected by entitlements must have the exact same data-pelcro-entitlements attribute value");
8142
+ return false;
8143
+ }
8107
8144
 
8108
- entitlementsProtectedElements.forEach(elem => {
8109
- const entitlements = getEntitlementsFromElem(elem);
8145
+ for (const elem of entitlementsProtectedElements) {
8146
+ const entitlements = getEntitlementsFromElem(elem);
8110
8147
 
8111
- if (entitlements.length === 0) {
8112
- console.error("invalid data-pelcro-entitlements attribute value", elem);
8113
- return;
8114
- }
8148
+ if (entitlements.length === 0) {
8149
+ console.error("invalid data-pelcro-entitlements attribute value", elem);
8150
+ return false;
8151
+ }
8115
8152
 
8116
- if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8117
- console.warn("user can't subscribe to any plan that has any of the entitlement(s) needed, this is usually unintentional, make sure that the entitlements are spelled correctly, entitlements are case sensitive. make sure that your plans are configured in a way that allows users from all supported countries, using all supported currencies, to have access to your content by subscribing to certain plans that provide the needed entitlement(s)");
8118
- }
8153
+ if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8154
+ console.warn("user can't subscribe to any plan that has any of the entitlement(s) needed, this is usually unintentional, make sure that the entitlements are spelled correctly, entitlements are case sensitive. make sure that your plans are configured in a way that allows users from all supported countries, using all supported currencies, to have access to your content by subscribing to certain plans that provide the needed entitlement(s)");
8155
+ }
8119
8156
 
8120
- if (shouldBlurContent(entitlements)) {
8121
- // remove all event listeners from the elem by replacing it with a deep clone of itself
8122
- const elemDeepClone = elem.cloneNode(true);
8123
- elem.replaceWith(elemDeepClone);
8124
- disableKeyboardInteractions(elemDeepClone);
8125
- elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8126
- unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8127
- /*
8128
- showing both the meter and the entitlements notification doesn't make sense from
8129
- a product prespective + they would take half the screen on mobile devies, so we're
8130
- hiding the meter, and showing the entitlements notification only.
8131
- */
8157
+ if (shouldBlurContent(entitlements)) {
8158
+ // remove all event listeners from the elem by replacing it with a deep clone of itself
8159
+ const elemDeepClone = elem.cloneNode(true);
8160
+ elem.replaceWith(elemDeepClone);
8161
+ disableKeyboardInteractions(elemDeepClone);
8162
+ elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8163
+ unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8164
+ const NOTIFICATION_ID = "entitlement";
8165
+ notify( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
8166
+ i18nKey: "messages:entitlement"
8167
+ }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default['default'].createElement(Link, {
8168
+ onClick: () => {
8169
+ const productId = Number(elem.dataset.productId);
8170
+ const planId = Number(elem.dataset.planId);
8171
+ const selectedProduct = window.Pelcro.product.getById(productId);
8172
+ const selectedPlan = window.Pelcro.plan.getById(planId);
8173
+ const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8132
8174
 
8133
- if (view === "meter") {
8134
- resetView();
8135
- }
8175
+ if (hasValidProductAndPlan) {
8176
+ set({
8177
+ product: selectedProduct,
8178
+ plan: selectedPlan
8179
+ });
8180
+ }
8136
8181
 
8137
- const NOTIFICATION_ID = "entitlement";
8138
- notify( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
8139
- i18nKey: "messages:entitlement"
8140
- }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default['default'].createElement(Link, {
8141
- onClick: () => {
8142
- const productId = Number(elem.dataset.productId);
8143
- const planId = Number(elem.dataset.planId);
8144
- const selectedProduct = window.Pelcro.product.getById(productId);
8145
- const selectedPlan = window.Pelcro.plan.getById(planId);
8146
- const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8147
-
8148
- if (hasValidProductAndPlan) {
8149
- set({
8150
- product: selectedProduct,
8151
- plan: selectedPlan
8152
- });
8153
- }
8182
+ notify.dismiss(NOTIFICATION_ID);
8183
+ switchView("_plan-select-entitlements");
8184
+ }
8185
+ }, "Subscribe"), "now to get full page access.")), {
8186
+ className: "pelcro-notification-entitlement",
8187
+ position: "bottom-right",
8188
+ duration: Infinity,
8189
+ id: NOTIFICATION_ID
8190
+ });
8191
+ }
8192
+ }
8154
8193
 
8155
- notify.dismiss(NOTIFICATION_ID);
8156
- switchView("_plan-select-entitlements");
8157
- }
8158
- }, "Subscribe"), "now to get full page access.")), {
8159
- className: "pelcro-notification-entitlement",
8160
- position: "bottom-right",
8161
- duration: Infinity,
8162
- id: NOTIFICATION_ID
8163
- });
8164
- }
8165
- });
8166
- });
8194
+ return true;
8167
8195
  };
8168
- /**
8169
- *
8170
- */
8171
8196
 
8172
8197
  function allElemsHaveSameEntitlements(elems) {
8173
8198
  const entitlements = getEntitlementsFromElem(elems[0]);
@@ -8177,10 +8202,6 @@ function allElemsHaveSameEntitlements(elems) {
8177
8202
  return entitlements.every(ent => elemEntitlements.includes(ent));
8178
8203
  });
8179
8204
  }
8180
- /**
8181
- *
8182
- */
8183
-
8184
8205
 
8185
8206
  function disableKeyboardInteractions(elem) {
8186
8207
  elem.addEventListener("keydown", event => {
@@ -8193,10 +8214,6 @@ function disableKeyboardInteractions(elem) {
8193
8214
  }
8194
8215
  }, true);
8195
8216
  }
8196
- /**
8197
- *
8198
- */
8199
-
8200
8217
 
8201
8218
  function unblurElemWhenUserSubscribes(elem, entitlements) {
8202
8219
  document.addEventListener("PelcroSubscriptionCreate", event => {
@@ -8204,11 +8221,11 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8204
8221
  isGift
8205
8222
  } = usePelcro.getStore();
8206
8223
  if (isGift) return;
8207
- const latestSub = event.detail.data.subscriptions[0];
8224
+ const latestSub = event.detail.data.subscriptions[event.detail.data.subscriptions.length - 1];
8208
8225
  const shouldUnblurContent = entitlements.some(ent => {
8209
- var _latestSub$plan$entit, _latestSub$plan$entit2;
8226
+ var _latestSub$plan$entit, _latestSub$plan, _latestSub$plan$entit2;
8210
8227
 
8211
- return (_latestSub$plan$entit = (_latestSub$plan$entit2 = latestSub.plan.entitlements) === null || _latestSub$plan$entit2 === void 0 ? void 0 : _latestSub$plan$entit2.includes(ent)) !== null && _latestSub$plan$entit !== void 0 ? _latestSub$plan$entit : false;
8228
+ return (_latestSub$plan$entit = latestSub === null || latestSub === void 0 ? void 0 : (_latestSub$plan = latestSub.plan) === null || _latestSub$plan === void 0 ? void 0 : (_latestSub$plan$entit2 = _latestSub$plan.entitlements) === null || _latestSub$plan$entit2 === void 0 ? void 0 : _latestSub$plan$entit2.includes(ent)) !== null && _latestSub$plan$entit !== void 0 ? _latestSub$plan$entit : false;
8212
8229
  });
8213
8230
 
8214
8231
  if (shouldUnblurContent) {
@@ -8216,10 +8233,6 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8216
8233
  }
8217
8234
  });
8218
8235
  }
8219
- /**
8220
- *
8221
- */
8222
-
8223
8236
 
8224
8237
  function shouldBlurContent(entitlements) {
8225
8238
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
@@ -8266,7 +8279,9 @@ const initPaywalls = () => {
8266
8279
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
8267
8280
 
8268
8281
  if (((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.settings) === "subscription") {
8269
- // Skip if article is not restricted
8282
+ // blur entitlements based content
8283
+ const didBlurContent = init(); // Skip paywall if article is not restricted
8284
+
8270
8285
  if (isValidViewFromURL(viewFromURL) || !paywallMethods.isArticleRestricted()) {
8271
8286
  return;
8272
8287
  }
@@ -8276,9 +8291,14 @@ const initPaywalls = () => {
8276
8291
  } = usePelcro.getStore();
8277
8292
 
8278
8293
  if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
8279
- switchView("meter"); // initializing content entitlement here because it interacts with meter
8280
-
8281
- init();
8294
+ /*
8295
+ showing both the meter and the entitlements notification doesn't make sense from
8296
+ a product prespective + they would take half the screen on mobile devies, so we're
8297
+ not showing the meter, and only showing the entitlements notification.
8298
+ */
8299
+ if (!didBlurContent) {
8300
+ switchView("meter");
8301
+ }
8282
8302
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
8283
8303
  switchView("newsletter");
8284
8304
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
@@ -8882,6 +8902,7 @@ const GET_STATES_SUCCESS = "GET_STATES_SUCCESS";
8882
8902
  const GET_STATES_FETCH = "GET_STATES_FETCH";
8883
8903
  const HANDLE_SUBMIT = "HANDLE_SUBMIT";
8884
8904
  const SET_UPDATED_PRICE = "SET_UPDATED_PRICE";
8905
+ const SET_TAX_AMOUNT = "SET_TAX_AMOUNT";
8885
8906
  const SET_CAN_MAKE_PAYMENT = "SET_CAN_MAKE_PAYMENT";
8886
8907
  const SET_PAYMENT_REQUEST = "SET_PAYMENT_REQUEST";
8887
8908
  const INIT_CONTAINER = "INIT_CONTAINER";
@@ -8910,6 +8931,9 @@ const SET_IMAGE_SRC = "SET_IMAGE_SRC";
8910
8931
  const PASSWORD_CHANGE_SUCCESS = "PASSWORD_CHANGE_SUCCESS";
8911
8932
  const SELECT_PAYMENT_METHOD = "SELECT_PAYMENT_METHOD";
8912
8933
  const LOAD_PAYMENT_METHODS = "LOAD_PAYMENT_METHODS";
8934
+ const GET_NEWSLETTERS_FETCH = "GET_NEWSLETTERS_FETCH";
8935
+ const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
8936
+ const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
8913
8937
 
8914
8938
  /**
8915
8939
  * Extracts error message from the response error object
@@ -8971,7 +8995,7 @@ const debounce = (func, waitTime) => {
8971
8995
  };
8972
8996
  };
8973
8997
 
8974
- const initialState$e = {
8998
+ const initialState$f = {
8975
8999
  email: "",
8976
9000
  password: "",
8977
9001
  emailError: null,
@@ -8982,10 +9006,10 @@ const initialState$e = {
8982
9006
  content: ""
8983
9007
  }
8984
9008
  };
8985
- const store$e = /*#__PURE__*/React.createContext(initialState$e);
9009
+ const store$f = /*#__PURE__*/React.createContext(initialState$f);
8986
9010
  const {
8987
- Provider: Provider$e
8988
- } = store$e;
9011
+ Provider: Provider$f
9012
+ } = store$f;
8989
9013
 
8990
9014
  const LoginContainer = ({
8991
9015
  style,
@@ -9092,7 +9116,7 @@ const LoginContainer = ({
9092
9116
  });
9093
9117
 
9094
9118
  case RESET_LOGIN_FORM:
9095
- return initialState$e;
9119
+ return initialState$f;
9096
9120
 
9097
9121
  case DISABLE_LOGIN_BUTTON:
9098
9122
  return lib_7({ ...state,
@@ -9110,12 +9134,12 @@ const LoginContainer = ({
9110
9134
  default:
9111
9135
  return state;
9112
9136
  }
9113
- }, initialState$e);
9137
+ }, initialState$f);
9114
9138
  return /*#__PURE__*/React__default['default'].createElement("div", {
9115
9139
  style: { ...style
9116
9140
  },
9117
9141
  className: `pelcro-container pelcro-login-container ${className}`
9118
- }, /*#__PURE__*/React__default['default'].createElement(Provider$e, {
9142
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$f, {
9119
9143
  value: {
9120
9144
  state,
9121
9145
  dispatch
@@ -9123,12 +9147,12 @@ const LoginContainer = ({
9123
9147
  }, children.length ? children.map((child, i) => {
9124
9148
  if (child) {
9125
9149
  return /*#__PURE__*/React__default['default'].cloneElement(child, {
9126
- store: store$e,
9150
+ store: store$f,
9127
9151
  key: i
9128
9152
  });
9129
9153
  }
9130
9154
  }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
9131
- store: store$e
9155
+ store: store$f
9132
9156
  })));
9133
9157
  };
9134
9158
 
@@ -9373,7 +9397,7 @@ const LoginButton = ({
9373
9397
  buttonDisabled
9374
9398
  },
9375
9399
  dispatch
9376
- } = React.useContext(store$e);
9400
+ } = React.useContext(store$f);
9377
9401
  const {
9378
9402
  t
9379
9403
  } = useTranslation("login");
@@ -9394,23 +9418,23 @@ const LoginButton = ({
9394
9418
  };
9395
9419
 
9396
9420
  const LoginEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
9397
- store: store$e
9421
+ store: store$f
9398
9422
  }, props));
9399
9423
 
9400
9424
  const LoginPassword = props => /*#__PURE__*/React__default['default'].createElement(Password, Object.assign({
9401
- store: store$e
9425
+ store: store$f
9402
9426
  }, props));
9403
9427
 
9404
- var _path$l;
9428
+ var _path$m;
9405
9429
 
9406
- function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
9430
+ function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
9407
9431
 
9408
9432
  function SvgCheck(props) {
9409
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$n({
9433
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$o({
9410
9434
  xmlns: "http://www.w3.org/2000/svg",
9411
9435
  fill: "currentColor",
9412
9436
  viewBox: "0 0 20 20"
9413
- }, props), _path$l || (_path$l = /*#__PURE__*/React__namespace.createElement("path", {
9437
+ }, props), _path$m || (_path$m = /*#__PURE__*/React__namespace.createElement("path", {
9414
9438
  fillRule: "evenodd",
9415
9439
  d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
9416
9440
  clipRule: "evenodd"
@@ -9475,7 +9499,7 @@ var facebookLoginRenderProps = createCommonjsModule(function (module, exports) {
9475
9499
  var FacebookLogin = unwrapExports(facebookLoginRenderProps);
9476
9500
  facebookLoginRenderProps.FacebookLogin;
9477
9501
 
9478
- const initialState$d = {
9502
+ const initialState$e = {
9479
9503
  email: "",
9480
9504
  password: "",
9481
9505
  emailError: null,
@@ -9492,10 +9516,10 @@ const initialState$d = {
9492
9516
  content: ""
9493
9517
  }
9494
9518
  };
9495
- const store$d = /*#__PURE__*/React.createContext(initialState$d);
9519
+ const store$e = /*#__PURE__*/React.createContext(initialState$e);
9496
9520
  const {
9497
- Provider: Provider$d
9498
- } = store$d;
9521
+ Provider: Provider$e
9522
+ } = store$e;
9499
9523
 
9500
9524
  const RegisterContainer = ({
9501
9525
  style,
@@ -9660,7 +9684,7 @@ const RegisterContainer = ({
9660
9684
  });
9661
9685
 
9662
9686
  case RESET_LOGIN_FORM:
9663
- return initialState$d;
9687
+ return initialState$e;
9664
9688
 
9665
9689
  case DISABLE_REGISTRATION_BUTTON:
9666
9690
  return lib_7({ ...state,
@@ -9678,12 +9702,12 @@ const RegisterContainer = ({
9678
9702
  default:
9679
9703
  return state;
9680
9704
  }
9681
- }, initialState$d);
9705
+ }, initialState$e);
9682
9706
  return /*#__PURE__*/React__default['default'].createElement("div", {
9683
9707
  style: { ...style
9684
9708
  },
9685
9709
  className: `pelcro-container pelcro-register-container ${className}`
9686
- }, /*#__PURE__*/React__default['default'].createElement(Provider$d, {
9710
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$e, {
9687
9711
  value: {
9688
9712
  state,
9689
9713
  dispatch
@@ -9691,24 +9715,24 @@ const RegisterContainer = ({
9691
9715
  }, children.length ? children.map((child, i) => {
9692
9716
  if (child) {
9693
9717
  return /*#__PURE__*/React__default['default'].cloneElement(child, {
9694
- store: store$d,
9718
+ store: store$e,
9695
9719
  key: i
9696
9720
  });
9697
9721
  }
9698
9722
  }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
9699
- store: store$d
9723
+ store: store$e
9700
9724
  })));
9701
9725
  };
9702
9726
 
9703
- var _path$k;
9727
+ var _path$l;
9704
9728
 
9705
- function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
9729
+ function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
9706
9730
 
9707
9731
  function SvgFacebookLogo(props) {
9708
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$m({
9732
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$n({
9709
9733
  xmlns: "http://www.w3.org/2000/svg",
9710
9734
  viewBox: "88.428 12.828 107.543 207.085"
9711
- }, props), _path$k || (_path$k = /*#__PURE__*/React__namespace.createElement("path", {
9735
+ }, props), _path$l || (_path$l = /*#__PURE__*/React__namespace.createElement("path", {
9712
9736
  d: "M158.232 219.912v-94.461h31.707l4.747-36.813h-36.454V65.134c0-10.658 2.96-17.922 18.245-17.922l19.494-.009V14.278c-3.373-.447-14.944-1.449-28.406-1.449-28.106 0-47.348 17.155-47.348 48.661v27.149H88.428v36.813h31.788v94.461l38.016-.001z",
9713
9737
  fill: "#3c5a9a"
9714
9738
  })));
@@ -9725,10 +9749,10 @@ const FacebookLoginButton = ({
9725
9749
  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;
9726
9750
  const {
9727
9751
  dispatch: loginDispatch
9728
- } = React.useContext(store$e);
9752
+ } = React.useContext(store$f);
9729
9753
  const {
9730
9754
  dispatch: registerDispatch
9731
- } = React.useContext(store$d);
9755
+ } = React.useContext(store$e);
9732
9756
 
9733
9757
  const onSuccess = facebookUser => {
9734
9758
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
@@ -9781,15 +9805,15 @@ var googleLogin = createCommonjsModule(function (module, exports) {
9781
9805
  unwrapExports(googleLogin);
9782
9806
  var googleLogin_1 = googleLogin.GoogleLogin;
9783
9807
 
9784
- var _path$j, _path2$2, _path3$1, _path4;
9808
+ var _path$k, _path2$2, _path3$1, _path4;
9785
9809
 
9786
- function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
9810
+ function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
9787
9811
 
9788
9812
  function SvgGoogleLogo(props) {
9789
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$l({
9813
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$m({
9790
9814
  viewBox: "0 0 24 24",
9791
9815
  xmlns: "http://www.w3.org/2000/svg"
9792
- }, props), _path$j || (_path$j = /*#__PURE__*/React__namespace.createElement("path", {
9816
+ }, props), _path$k || (_path$k = /*#__PURE__*/React__namespace.createElement("path", {
9793
9817
  fill: "#4285F4",
9794
9818
  d: "M23.745 12.27c0-.79-.07-1.54-.19-2.27h-11.3v4.51h6.47c-.29 1.48-1.14 2.73-2.4 3.58v3h3.86c2.26-2.09 3.56-5.17 3.56-8.82z"
9795
9819
  })), _path2$2 || (_path2$2 = /*#__PURE__*/React__namespace.createElement("path", {
@@ -9815,10 +9839,10 @@ const GoogleLoginButton = ({
9815
9839
  const googleLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
9816
9840
  const {
9817
9841
  dispatch: loginDispatch
9818
- } = React.useContext(store$e);
9842
+ } = React.useContext(store$f);
9819
9843
  const {
9820
9844
  dispatch: registerDispatch
9821
- } = React.useContext(store$d);
9845
+ } = React.useContext(store$e);
9822
9846
 
9823
9847
  const onSuccess = response => {
9824
9848
  var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
@@ -9923,15 +9947,15 @@ function LoginView(props) {
9923
9947
  }, /*#__PURE__*/React__default['default'].createElement(GoogleLoginButton, null), /*#__PURE__*/React__default['default'].createElement(FacebookLoginButton, null))))));
9924
9948
  }
9925
9949
 
9926
- var _path$i, _path2$1, _path3;
9950
+ var _path$j, _path2$1, _path3;
9927
9951
 
9928
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
9952
+ function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
9929
9953
 
9930
9954
  function SvgPelcroAuthorship(props) {
9931
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
9955
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$l({
9932
9956
  xmlns: "http://www.w3.org/2000/svg",
9933
9957
  viewBox: "0 -80.652 497.072 179.991"
9934
- }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
9958
+ }, props), _path$j || (_path$j = /*#__PURE__*/React__namespace.createElement("path", {
9935
9959
  fill: "none",
9936
9960
  stroke: "#4a4a4a",
9937
9961
  d: "M487.89 42.299c0 13.158-10.671 23.829-23.829 23.829H37.074c-13.162 0-23.832-10.671-23.832-23.829v-63.552c0-13.158 10.67-23.831 23.832-23.831H464.06c13.158 0 23.829 10.672 23.829 23.831l.001 63.552z"
@@ -10078,11 +10102,11 @@ function LoginModal({
10078
10102
  LoginModal.viewId = "login";
10079
10103
 
10080
10104
  const RegisterEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
10081
- store: store$d
10105
+ store: store$e
10082
10106
  }, props));
10083
10107
 
10084
10108
  const RegisterPassword = props => /*#__PURE__*/React__default['default'].createElement(Password, Object.assign({
10085
- store: store$d
10109
+ store: store$e
10086
10110
  }, props));
10087
10111
 
10088
10112
  const RegisterButton = ({
@@ -10099,7 +10123,7 @@ const RegisterButton = ({
10099
10123
  buttonDisabled
10100
10124
  },
10101
10125
  dispatch
10102
- } = React.useContext(store$d);
10126
+ } = React.useContext(store$e);
10103
10127
  const {
10104
10128
  t
10105
10129
  } = useTranslation("register");
@@ -10234,7 +10258,7 @@ function FirstName({
10234
10258
  }
10235
10259
 
10236
10260
  const RegisterFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
10237
- store: store$d
10261
+ store: store$e
10238
10262
  }, props));
10239
10263
 
10240
10264
  function LastName({
@@ -10265,7 +10289,7 @@ function LastName({
10265
10289
  }
10266
10290
 
10267
10291
  const RegisterLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
10268
- store: store$d
10292
+ store: store$e
10269
10293
  }, props));
10270
10294
 
10271
10295
  /**
@@ -10369,7 +10393,7 @@ function TextInput({
10369
10393
 
10370
10394
  const RegisterTextInput = props => {
10371
10395
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
10372
- store: store$d
10396
+ store: store$e
10373
10397
  }));
10374
10398
  };
10375
10399
 
@@ -12334,13 +12358,14 @@ class PaypalGateWay {
12334
12358
  * @property {unknown} canMakePayment
12335
12359
  * @property {unknown} paymentRequest
12336
12360
  * @property {number} updatedPrice
12361
+ * @property {number} taxAmount
12337
12362
  * @property {object} currentPlan
12338
12363
  * @property {object} alert
12339
12364
  */
12340
12365
 
12341
12366
  /** @type {PaymentStateType} */
12342
12367
 
12343
- const initialState$c = {
12368
+ const initialState$d = {
12344
12369
  disableSubmit: false,
12345
12370
  isLoading: false,
12346
12371
  disableCouponButton: false,
@@ -12352,16 +12377,17 @@ const initialState$c = {
12352
12377
  canMakePayment: false,
12353
12378
  paymentRequest: null,
12354
12379
  updatedPrice: null,
12380
+ taxAmount: null,
12355
12381
  currentPlan: null,
12356
12382
  alert: {
12357
12383
  type: "error",
12358
12384
  content: ""
12359
12385
  }
12360
12386
  };
12361
- const store$c = /*#__PURE__*/React.createContext(initialState$c);
12387
+ const store$d = /*#__PURE__*/React.createContext(initialState$d);
12362
12388
  const {
12363
- Provider: Provider$c
12364
- } = store$c;
12389
+ Provider: Provider$d
12390
+ } = store$d;
12365
12391
 
12366
12392
  const PaymentMethodContainerWithoutStripe = ({
12367
12393
  style,
@@ -12402,6 +12428,7 @@ const PaymentMethodContainerWithoutStripe = ({
12402
12428
  dispatch({
12403
12429
  type: INIT_CONTAINER
12404
12430
  });
12431
+ updateTotalAmountWithTax();
12405
12432
  }, []);
12406
12433
 
12407
12434
  const initPaymentRequest = (state, dispatch) => {
@@ -12468,6 +12495,45 @@ const PaymentMethodContainerWithoutStripe = ({
12468
12495
  console.log("Google Pay/Apple pay isn't available in this country");
12469
12496
  }
12470
12497
  };
12498
+ /**
12499
+ * Updates the total amount after adding taxes only if site taxes are enabled
12500
+ */
12501
+
12502
+
12503
+ const updateTotalAmountWithTax = () => {
12504
+ var _window$Pelcro$site$r;
12505
+
12506
+ const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
12507
+
12508
+ if (taxesEnabled && type === "createPayment") {
12509
+ dispatch({
12510
+ type: DISABLE_SUBMIT,
12511
+ payload: true
12512
+ });
12513
+ resolveTaxCalculation().then(res => {
12514
+ if (res) {
12515
+ dispatch({
12516
+ type: SET_TAX_AMOUNT,
12517
+ payload: res.taxAmount
12518
+ });
12519
+ dispatch({
12520
+ type: SET_UPDATED_PRICE,
12521
+ payload: res.totalAmountWithTax
12522
+ });
12523
+ dispatch({
12524
+ type: UPDATE_PAYMENT_REQUEST
12525
+ });
12526
+ }
12527
+ }).catch(error => {
12528
+ handlePaymentError(error);
12529
+ }).finally(() => {
12530
+ dispatch({
12531
+ type: DISABLE_SUBMIT,
12532
+ payload: false
12533
+ });
12534
+ });
12535
+ }
12536
+ };
12471
12537
 
12472
12538
  const onApplyCouponCode = (state, dispatch) => {
12473
12539
  const {
@@ -12494,6 +12560,10 @@ const PaymentMethodContainerWithoutStripe = ({
12494
12560
  });
12495
12561
  }
12496
12562
 
12563
+ dispatch({
12564
+ type: SET_COUPON_ERROR,
12565
+ payload: ""
12566
+ });
12497
12567
  dispatch({
12498
12568
  type: SHOW_ALERT,
12499
12569
  payload: {
@@ -12509,6 +12579,10 @@ const PaymentMethodContainerWithoutStripe = ({
12509
12579
  type: SET_PERCENT_OFF,
12510
12580
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
12511
12581
  });
12582
+ dispatch({
12583
+ type: SET_TAX_AMOUNT,
12584
+ payload: res.data.taxes
12585
+ });
12512
12586
  dispatch({
12513
12587
  type: SET_UPDATED_PRICE,
12514
12588
  payload: res.data.total
@@ -12518,6 +12592,29 @@ const PaymentMethodContainerWithoutStripe = ({
12518
12592
  });
12519
12593
  };
12520
12594
 
12595
+ if ((couponCode === null || couponCode === void 0 ? void 0 : couponCode.trim()) === "") {
12596
+ dispatch({
12597
+ type: SET_COUPON,
12598
+ payload: null
12599
+ });
12600
+ dispatch({
12601
+ type: SET_PERCENT_OFF,
12602
+ payload: ""
12603
+ });
12604
+ dispatch({
12605
+ type: SET_UPDATED_PRICE,
12606
+ payload: null
12607
+ });
12608
+ dispatch({
12609
+ type: SET_TAX_AMOUNT,
12610
+ payload: null
12611
+ });
12612
+ dispatch({
12613
+ type: UPDATE_PAYMENT_REQUEST
12614
+ });
12615
+ updateTotalAmountWithTax();
12616
+ }
12617
+
12521
12618
  if (couponCode !== null && couponCode !== void 0 && couponCode.trim()) {
12522
12619
  dispatch({
12523
12620
  type: DISABLE_COUPON_BUTTON,
@@ -12904,33 +13001,37 @@ const PaymentMethodContainerWithoutStripe = ({
12904
13001
  const totalAmount = (_ref = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
12905
13002
 
12906
13003
  if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
12907
- return resolveTaxCalculation().then(totalAmountWithTax => generate3DSecureSource(source, totalAmountWithTax !== null && totalAmountWithTax !== void 0 ? totalAmountWithTax : totalAmount).then(({
12908
- source,
12909
- error
12910
- }) => {
12911
- if (error) {
12912
- return handlePaymentError(error);
12913
- }
12914
-
12915
- toggleAuthenticationPendingView(true, source);
12916
- }));
12917
- }
13004
+ return resolveTaxCalculation().then(res => {
13005
+ var _res$totalAmountWithT;
12918
13006
 
12919
- return handlePayment(source);
12920
- }).catch(error => {
12921
- return handlePaymentError(error);
12922
- });
13007
+ return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
13008
+ source,
13009
+ error
13010
+ }) => {
13011
+ if (error) {
13012
+ return handlePaymentError(error);
13013
+ }
13014
+
13015
+ toggleAuthenticationPendingView(true, source);
13016
+ });
13017
+ });
13018
+ }
13019
+
13020
+ return handlePayment(source);
13021
+ }).catch(error => {
13022
+ return handlePaymentError(error);
13023
+ });
12923
13024
  };
12924
13025
  /**
12925
- * Resolves with the total including taxes incase taxes enabled by site
13026
+ * Resolves with the total & tax amount incase taxes enabled by site
12926
13027
  * @return {Promise}
12927
13028
  */
12928
13029
 
12929
13030
 
12930
13031
  const resolveTaxCalculation = () => {
12931
- var _window$Pelcro$site$r;
13032
+ var _window$Pelcro$site$r2;
12932
13033
 
12933
- const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
13034
+ const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
12934
13035
  return new Promise((resolve, reject) => {
12935
13036
  // resolve early if taxes isn't enabled
12936
13037
  if (!taxesEnabled) {
@@ -12943,14 +13044,18 @@ const PaymentMethodContainerWithoutStripe = ({
12943
13044
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
12944
13045
  address_id: selectedAddressId
12945
13046
  }, (error, res) => {
12946
- var _res$data;
13047
+ var _res$data, _res$data2;
12947
13048
 
12948
13049
  if (error) {
12949
13050
  return reject(error);
12950
13051
  }
12951
13052
 
12952
- const totalAmountWithTax = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.total;
12953
- resolve(totalAmountWithTax);
13053
+ const taxAmount = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.taxes;
13054
+ const totalAmountWithTax = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.total;
13055
+ resolve({
13056
+ totalAmountWithTax,
13057
+ taxAmount
13058
+ });
12954
13059
  });
12955
13060
  });
12956
13061
  };
@@ -13005,13 +13110,13 @@ const PaymentMethodContainerWithoutStripe = ({
13005
13110
  const handlePaymentError = error => {
13006
13111
  if (error.type === "validation_error" && // Subscription creation & renewal
13007
13112
  type === "createPayment") {
13008
- var _state$coupon;
13113
+ var _state$couponObject;
13009
13114
 
13010
13115
  const {
13011
13116
  updatedPrice
13012
13117
  } = state; // When price is 0, we allow submitting without card info
13013
13118
 
13014
- if (updatedPrice === 0 && ((_state$coupon = state.coupon) === null || _state$coupon === void 0 ? void 0 : _state$coupon.duration) === "forever") {
13119
+ if (updatedPrice === 0 && ((_state$couponObject = state.couponObject) === null || _state$couponObject === void 0 ? void 0 : _state$couponObject.duration) === "forever") {
13015
13120
  return subscribe({}, state, dispatch);
13016
13121
  }
13017
13122
  }
@@ -13139,6 +13244,11 @@ const PaymentMethodContainerWithoutStripe = ({
13139
13244
  updatedPrice: action.payload
13140
13245
  });
13141
13246
 
13247
+ case SET_TAX_AMOUNT:
13248
+ return lib_7({ ...state,
13249
+ taxAmount: action.payload
13250
+ });
13251
+
13142
13252
  case SET_CAN_MAKE_PAYMENT:
13143
13253
  return lib_7({ ...state,
13144
13254
  canMakePayment: action.payload
@@ -13156,7 +13266,7 @@ const PaymentMethodContainerWithoutStripe = ({
13156
13266
 
13157
13267
  case SET_COUPON:
13158
13268
  return lib_7({ ...state,
13159
- coupon: action.payload
13269
+ couponObject: action.payload
13160
13270
  });
13161
13271
 
13162
13272
  case SET_COUPON_ERROR:
@@ -13182,21 +13292,21 @@ const PaymentMethodContainerWithoutStripe = ({
13182
13292
  default:
13183
13293
  return state;
13184
13294
  }
13185
- }, initialState$c);
13295
+ }, initialState$d);
13186
13296
  return /*#__PURE__*/React__default['default'].createElement("div", {
13187
13297
  style: { ...style
13188
13298
  },
13189
13299
  className: `pelcro-container pelcro-payment-container ${className}`
13190
- }, /*#__PURE__*/React__default['default'].createElement(Provider$c, {
13300
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$d, {
13191
13301
  value: {
13192
13302
  state,
13193
13303
  dispatch
13194
13304
  }
13195
13305
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
13196
- store: store$c,
13306
+ store: store$d,
13197
13307
  key: i
13198
13308
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
13199
- store: store$c
13309
+ store: store$d
13200
13310
  })));
13201
13311
  };
13202
13312
 
@@ -13209,7 +13319,7 @@ const PaymentMethodContainer = props => {
13209
13319
  stripeAccount: window.Pelcro.site.read().account_id,
13210
13320
  locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13211
13321
  }, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
13212
- store: store$c
13322
+ store: store$d
13213
13323
  }, props))));
13214
13324
  }
13215
13325
 
@@ -13262,7 +13372,7 @@ const PelcroPaymentRequestButton = props => {
13262
13372
  currentPlan,
13263
13373
  updatedPrice
13264
13374
  }
13265
- } = React.useContext(store$c);
13375
+ } = React.useContext(store$d);
13266
13376
 
13267
13377
  const updatePaymentRequest = () => {
13268
13378
  // Make sure payment request is up to date, eg. user added a coupon code.
@@ -13315,9 +13425,10 @@ const DiscountedPrice = props => {
13315
13425
  const {
13316
13426
  state: {
13317
13427
  updatedPrice,
13428
+ taxAmount,
13318
13429
  percentOff
13319
13430
  }
13320
- } = React.useContext(store$c);
13431
+ } = React.useContext(store$d);
13321
13432
  const {
13322
13433
  default_locale
13323
13434
  } = Pelcro.site.read();
@@ -13327,12 +13438,15 @@ const DiscountedPrice = props => {
13327
13438
  } = usePelcro();
13328
13439
  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;
13329
13440
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13330
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : updatedPrice * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13441
+ const discountedPriceWithoutTax = updatedPrice - taxAmount;
13442
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13331
13443
 
13332
13444
  if (percentOff) {
13333
13445
  return /*#__PURE__*/React__default['default'].createElement("div", Object.assign({
13334
- className: "plc-my-2"
13335
- }, props), "(-", percentOff, ") ", priceFormatted);
13446
+ className: "plc-flex plc-justify-center plc-mt-2 pelcro-discount"
13447
+ }, props), "(-", percentOff, ")", " ", /*#__PURE__*/React__default['default'].createElement("span", {
13448
+ className: "plc-font-bold pelcro-discounted-price"
13449
+ }, priceFormatted));
13336
13450
  }
13337
13451
 
13338
13452
  return "";
@@ -13357,7 +13471,7 @@ const SubmitPaymentMethod = ({
13357
13471
  isLoading,
13358
13472
  updatedPrice
13359
13473
  }
13360
- } = React.useContext(store$c);
13474
+ } = React.useContext(store$d);
13361
13475
  const {
13362
13476
  default_locale
13363
13477
  } = Pelcro.site.read();
@@ -13381,17 +13495,17 @@ const SubmitPaymentMethod = ({
13381
13495
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
13382
13496
  };
13383
13497
 
13384
- var _path$h;
13498
+ var _path$i;
13385
13499
 
13386
- function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
13500
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
13387
13501
 
13388
13502
  function SvgArrowLeft(props) {
13389
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$j({
13503
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
13390
13504
  xmlns: "http://www.w3.org/2000/svg",
13391
13505
  fill: "none",
13392
13506
  viewBox: "0 0 24 24",
13393
13507
  stroke: "currentColor"
13394
- }, props), _path$h || (_path$h = /*#__PURE__*/React__namespace.createElement("path", {
13508
+ }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
13395
13509
  strokeLinecap: "round",
13396
13510
  strokeLinejoin: "round",
13397
13511
  strokeWidth: 2,
@@ -13410,7 +13524,7 @@ const ApplyCouponButton = ({
13410
13524
  disableCouponButton
13411
13525
  },
13412
13526
  dispatch
13413
- } = React.useContext(store$c);
13527
+ } = React.useContext(store$d);
13414
13528
  const {
13415
13529
  t
13416
13530
  } = useTranslation("checkoutForm");
@@ -13444,7 +13558,7 @@ const CouponCodeField = props => {
13444
13558
  couponCode,
13445
13559
  couponError
13446
13560
  }
13447
- } = React.useContext(store$c);
13561
+ } = React.useContext(store$d);
13448
13562
 
13449
13563
  const onCouponCodeChange = e => {
13450
13564
  dispatch({
@@ -13462,6 +13576,7 @@ const CouponCodeField = props => {
13462
13576
 
13463
13577
  return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
13464
13578
  className: "plc-h-12",
13579
+ wrapperClassName: "plc-mb-1",
13465
13580
  errorClassName: "plc-h-12 sm:plc-h-8",
13466
13581
  error: couponError,
13467
13582
  "aria-label": t("labels.code"),
@@ -13472,17 +13587,17 @@ const CouponCodeField = props => {
13472
13587
  }, props));
13473
13588
  };
13474
13589
 
13475
- var _path$g;
13590
+ var _path$h;
13476
13591
 
13477
- function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
13592
+ function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
13478
13593
 
13479
13594
  function SvgTicket(props) {
13480
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$i({
13595
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$j({
13481
13596
  xmlns: "http://www.w3.org/2000/svg",
13482
13597
  fill: "none",
13483
13598
  viewBox: "0 0 24 24",
13484
13599
  stroke: "currentColor"
13485
- }, props), _path$g || (_path$g = /*#__PURE__*/React__namespace.createElement("path", {
13600
+ }, props), _path$h || (_path$h = /*#__PURE__*/React__namespace.createElement("path", {
13486
13601
  strokeLinecap: "round",
13487
13602
  strokeLinejoin: "round",
13488
13603
  strokeWidth: 2,
@@ -13499,7 +13614,7 @@ const CouponCode = ({
13499
13614
  state: {
13500
13615
  enableCouponField
13501
13616
  }
13502
- } = React.useContext(store$c);
13617
+ } = React.useContext(store$d);
13503
13618
  const {
13504
13619
  t
13505
13620
  } = useTranslation("checkoutForm");
@@ -13513,16 +13628,16 @@ const CouponCode = ({
13513
13628
  };
13514
13629
 
13515
13630
  return /*#__PURE__*/React__default['default'].createElement("div", {
13516
- className: "plc-my-4"
13631
+ className: "plc-mt-4"
13517
13632
  }, /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
13518
- className: "plc-text-base plc-text-gray-500",
13633
+ className: "plc-mb-2 plc-text-base plc-text-gray-500",
13519
13634
  variant: "ghost",
13520
13635
  icon: /*#__PURE__*/React__default['default'].createElement(SvgTicket, {
13521
13636
  className: "plc-w-5 plc-h-5 plc-mr-2"
13522
13637
  }),
13523
13638
  onClick: showCouponField
13524
13639
  }, otherProps), !enableCouponField ? t("labels.addCode") : t("labels.hideCode")), enableCouponField && /*#__PURE__*/React__default['default'].createElement("div", {
13525
- className: "plc-flex plc-w-full plc-my-4 pelcro-apply-coupon-wrapper"
13640
+ className: "plc-flex plc-w-full plc-mt-2 pelcro-apply-coupon-wrapper"
13526
13641
  }, /*#__PURE__*/React__default['default'].createElement(CouponCodeField, null), /*#__PURE__*/React__default['default'].createElement(ApplyCouponButton, null)));
13527
13642
  };
13528
13643
 
@@ -13756,7 +13871,7 @@ const PaypalSubscribeButton = props => {
13756
13871
  const {
13757
13872
  dispatch,
13758
13873
  state
13759
- } = React.useContext(store$c);
13874
+ } = React.useContext(store$d);
13760
13875
  const {
13761
13876
  product,
13762
13877
  plan,
@@ -13841,16 +13956,16 @@ const BankRedirection = () => {
13841
13956
  }));
13842
13957
  };
13843
13958
 
13844
- var _path$f;
13959
+ var _path$g;
13845
13960
 
13846
- function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
13961
+ function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
13847
13962
 
13848
13963
  function SvgLock(props) {
13849
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$h({
13964
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$i({
13850
13965
  xmlns: "http://www.w3.org/2000/svg",
13851
13966
  viewBox: "0 0 20 20",
13852
13967
  fill: "currentColor"
13853
- }, props), _path$f || (_path$f = /*#__PURE__*/React__namespace.createElement("path", {
13968
+ }, props), _path$g || (_path$g = /*#__PURE__*/React__namespace.createElement("path", {
13854
13969
  fillRule: "evenodd",
13855
13970
  d: "M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",
13856
13971
  clipRule: "evenodd"
@@ -13867,7 +13982,7 @@ const SelectedPaymentMethod = () => {
13867
13982
  state: {
13868
13983
  isLoading
13869
13984
  }
13870
- } = React.useContext(store$c);
13985
+ } = React.useContext(store$d);
13871
13986
  const {
13872
13987
  switchView,
13873
13988
  selectedPaymentMethodId
@@ -13899,6 +14014,37 @@ const SelectedPaymentMethod = () => {
13899
14014
  }, t("select.buttons.changePaymentMethod")))));
13900
14015
  };
13901
14016
 
14017
+ const TaxAmount = () => {
14018
+ var _plan$quantity;
14019
+
14020
+ const {
14021
+ t
14022
+ } = useTranslation("checkoutForm");
14023
+ const {
14024
+ state: {
14025
+ taxAmount
14026
+ }
14027
+ } = React.useContext(store$d);
14028
+ const {
14029
+ default_locale
14030
+ } = Pelcro.site.read();
14031
+ const {
14032
+ plan
14033
+ } = usePelcro();
14034
+ const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14035
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14036
+
14037
+ if (taxAmount) {
14038
+ return /*#__PURE__*/React__default['default'].createElement("div", {
14039
+ className: "plc-text-center pelcro-tax-amount"
14040
+ }, t("labels.tax"), " ", /*#__PURE__*/React__default['default'].createElement("span", {
14041
+ className: "plc-font-bold"
14042
+ }, priceFormatted));
14043
+ }
14044
+
14045
+ return null;
14046
+ };
14047
+
13902
14048
  /**
13903
14049
  *
13904
14050
  */
@@ -13935,7 +14081,9 @@ function PaymentMethodView({
13935
14081
  onFailure: onFailure
13936
14082
  }, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
13937
14083
  className: "plc-mb-2"
13938
- }), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement("div", {
14084
+ }), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default['default'].createElement("div", {
14085
+ className: "plc-mb-2"
14086
+ }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
13939
14087
  className: "plc-grid plc-mt-4 plc-gap-y-2"
13940
14088
  }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)))))));
13941
14089
  }
@@ -14042,12 +14190,12 @@ function SubscriptionRenewModal({
14042
14190
  }
14043
14191
  SubscriptionRenewModal.viewId = "subscription-renew";
14044
14192
 
14045
- var _path$e;
14193
+ var _path$f;
14046
14194
 
14047
- function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
14195
+ function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
14048
14196
 
14049
14197
  function SvgGift(props) {
14050
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$g({
14198
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$h({
14051
14199
  className: "plc-w-6 plc-h-6 plc-mr-2",
14052
14200
  fill: "none",
14053
14201
  stroke: "currentColor",
@@ -14056,7 +14204,7 @@ function SvgGift(props) {
14056
14204
  strokeWidth: 2,
14057
14205
  viewBox: "0 0 24 24",
14058
14206
  xmlns: "http://www.w3.org/2000/svg"
14059
- }, props), _path$e || (_path$e = /*#__PURE__*/React__namespace.createElement("path", {
14207
+ }, props), _path$f || (_path$f = /*#__PURE__*/React__namespace.createElement("path", {
14060
14208
  d: "M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7zM12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z"
14061
14209
  })));
14062
14210
  }
@@ -14387,6 +14535,292 @@ class DefaultNewsLetter extends React.Component {
14387
14535
 
14388
14536
  const NewsLetter = withTranslation("newsletter")(DefaultNewsLetter);
14389
14537
 
14538
+ const initialState$c = {
14539
+ didSubToNewslettersBefore: false,
14540
+ newsletters: [],
14541
+ isListLoading: true,
14542
+ isSubmitting: false,
14543
+ alert: {
14544
+ type: "error",
14545
+ content: ""
14546
+ }
14547
+ };
14548
+ const store$c = /*#__PURE__*/React.createContext(initialState$c);
14549
+ const {
14550
+ Provider: Provider$c
14551
+ } = store$c;
14552
+
14553
+ const NewsletterUpdateContainer = ({
14554
+ style,
14555
+ className = "",
14556
+ onSuccess = () => {},
14557
+ onFailure = () => {},
14558
+ children
14559
+ }) => {
14560
+ const [t] = useTranslation("newsletter");
14561
+
14562
+ const handleSubmit = ({
14563
+ newsletters,
14564
+ didSubToNewslettersBefore
14565
+ }, dispatch) => {
14566
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2;
14567
+
14568
+ const callback = (err, res) => {
14569
+ dispatch({
14570
+ type: LOADING,
14571
+ payload: false
14572
+ });
14573
+
14574
+ if (err) {
14575
+ dispatch({
14576
+ type: SHOW_ALERT,
14577
+ payload: {
14578
+ type: "error",
14579
+ content: getErrorMessages(err)
14580
+ }
14581
+ });
14582
+ onFailure(err);
14583
+ } else {
14584
+ if (!didSubToNewslettersBefore) {
14585
+ dispatch({
14586
+ type: SWITCH_TO_UPDATE
14587
+ });
14588
+ }
14589
+
14590
+ dispatch({
14591
+ type: SHOW_ALERT,
14592
+ payload: {
14593
+ type: "success",
14594
+ content: t("messages.success")
14595
+ }
14596
+ });
14597
+ onSuccess(res);
14598
+ }
14599
+ };
14600
+
14601
+ const requestData = {
14602
+ email: (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.email) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : window.Pelcro.helpers.getURLParameter("email"),
14603
+ source: "web",
14604
+ lists: newsletters.filter(newsletter => newsletter.selected).map(newsletter => newsletter.id).join(",")
14605
+ };
14606
+
14607
+ if (didSubToNewslettersBefore) {
14608
+ window.Pelcro.newsletter.update(requestData, callback);
14609
+ } else {
14610
+ window.Pelcro.newsletter.create(requestData, callback);
14611
+ }
14612
+ };
14613
+
14614
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
14615
+ switch (action.type) {
14616
+ case GET_NEWSLETTERS_FETCH:
14617
+ return lib_7({ ...state,
14618
+ isListLoading: true
14619
+ });
14620
+
14621
+ case GET_NEWSLETTERS_SUCCESS:
14622
+ return lib_7({ ...state,
14623
+ newsletters: action.payload.newsletters,
14624
+ didSubToNewslettersBefore: action.payload.didSubToNewslettersBefore,
14625
+ isListLoading: false
14626
+ });
14627
+
14628
+ case SET_SELECT:
14629
+ return lib_7({ ...state,
14630
+ newsletters: state.newsletters.map(newsletter => {
14631
+ if (newsletter.id === action.payload) {
14632
+ return { ...newsletter,
14633
+ selected: !newsletter.selected
14634
+ };
14635
+ }
14636
+
14637
+ return newsletter;
14638
+ })
14639
+ });
14640
+
14641
+ case SWITCH_TO_UPDATE:
14642
+ return lib_7({ ...state,
14643
+ didSubToNewslettersBefore: true
14644
+ });
14645
+
14646
+ case SHOW_ALERT:
14647
+ return lib_7({ ...state,
14648
+ alert: action.payload
14649
+ });
14650
+
14651
+ case LOADING:
14652
+ return lib_7({ ...state,
14653
+ isSubmitting: action.payload
14654
+ });
14655
+
14656
+ case HANDLE_SUBMIT:
14657
+ return lib_5({ ...state,
14658
+ isSubmitting: true
14659
+ }, (state, dispatch) => handleSubmit(state, dispatch));
14660
+
14661
+ default:
14662
+ return state;
14663
+ }
14664
+ }, initialState$c);
14665
+ React.useEffect(() => {
14666
+ const getUserNewsletters = () => {
14667
+ var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
14668
+
14669
+ dispatch({
14670
+ type: GET_NEWSLETTERS_FETCH
14671
+ });
14672
+ const email = (_window$Pelcro$user$r3 = (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.email) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : window.Pelcro.helpers.getURLParameter("email");
14673
+ window.Pelcro.newsletter.getByEmail(email, (err, res) => {
14674
+ var _window$Pelcro$uiSett, _window$Pelcro, _window$Pelcro$uiSett2, _res$data$lists$split, _res$data$lists;
14675
+
14676
+ if (err) {
14677
+ return dispatch({
14678
+ type: SHOW_ALERT,
14679
+ payload: {
14680
+ type: "error",
14681
+ content: getErrorMessages(err)
14682
+ }
14683
+ });
14684
+ }
14685
+
14686
+ const newsletters = (_window$Pelcro$uiSett = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett2 = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett2 === void 0 ? void 0 : _window$Pelcro$uiSett2.newsletters) !== null && _window$Pelcro$uiSett !== void 0 ? _window$Pelcro$uiSett : [];
14687
+ const selectedNewsletters = (_res$data$lists$split = (_res$data$lists = res.data.lists) === null || _res$data$lists === void 0 ? void 0 : _res$data$lists.split(",")) !== null && _res$data$lists$split !== void 0 ? _res$data$lists$split : [];
14688
+ const allNewslettersWithSelectedField = newsletters.map(newsletter => ({ ...newsletter,
14689
+ id: String(newsletter.id),
14690
+ selected: selectedNewsletters.includes(String(newsletter.id))
14691
+ }));
14692
+ dispatch({
14693
+ type: GET_NEWSLETTERS_SUCCESS,
14694
+ payload: {
14695
+ newsletters: allNewslettersWithSelectedField,
14696
+ didSubToNewslettersBefore: Boolean(res.data.email)
14697
+ }
14698
+ });
14699
+ });
14700
+ };
14701
+
14702
+ getUserNewsletters();
14703
+ }, []);
14704
+ return /*#__PURE__*/React__default['default'].createElement("div", {
14705
+ style: { ...style
14706
+ },
14707
+ className: `pelcro-container pelcro-newsletter-update-container ${className}`
14708
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$c, {
14709
+ value: {
14710
+ state,
14711
+ dispatch
14712
+ }
14713
+ }, children.length ? children.map((child, i) => {
14714
+ if (child) {
14715
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
14716
+ store: store$c,
14717
+ key: i
14718
+ });
14719
+ }
14720
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
14721
+ store: store$c
14722
+ })));
14723
+ };
14724
+
14725
+ const NewsletterUpdateButton = ({
14726
+ name,
14727
+ onClick,
14728
+ ...otherProps
14729
+ }) => {
14730
+ const {
14731
+ dispatch,
14732
+ state: {
14733
+ isSubmitting,
14734
+ isListLoading
14735
+ }
14736
+ } = React.useContext(store$c);
14737
+ const {
14738
+ t
14739
+ } = useTranslation("newsletter");
14740
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
14741
+ onClick: () => {
14742
+ dispatch({
14743
+ type: HANDLE_SUBMIT
14744
+ });
14745
+ onClick === null || onClick === void 0 ? void 0 : onClick();
14746
+ },
14747
+ disabled: isListLoading,
14748
+ isLoading: isSubmitting
14749
+ }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
14750
+ };
14751
+
14752
+ const NewsletterUpdateList = () => {
14753
+ const handleSelectNewsletter = event => {
14754
+ dispatch({
14755
+ type: SET_SELECT,
14756
+ payload: event.target.value
14757
+ });
14758
+ };
14759
+
14760
+ const {
14761
+ dispatch,
14762
+ state: {
14763
+ newsletters,
14764
+ isListLoading
14765
+ }
14766
+ } = React.useContext(store$c);
14767
+
14768
+ if (isListLoading) {
14769
+ return /*#__PURE__*/React__default['default'].createElement(Loader, {
14770
+ width: 60,
14771
+ height: 100
14772
+ });
14773
+ }
14774
+
14775
+ return /*#__PURE__*/React__default['default'].createElement("div", {
14776
+ className: "plc-max-h-80 plc-overflow-y-auto pelcro-newsletters-wrapper"
14777
+ }, newsletters.map(newsletter => /*#__PURE__*/React__default['default'].createElement("div", {
14778
+ key: newsletter.id,
14779
+ className: "plc-p-2 plc-mx-3 plc-mt-2 plc-border plc-border-gray-400 plc-border-solid plc-rounded plc-text-gray-900 pelcro-newsletter-wrapper"
14780
+ }, /*#__PURE__*/React__default['default'].createElement(Checkbox, {
14781
+ className: "pelcro-select-newsletter-checkbox",
14782
+ labelClassName: "plc-cursor-pointer plc-w-full",
14783
+ id: `pelcro-newsletter-update-${newsletter.id}`,
14784
+ checked: newsletter.selected,
14785
+ value: newsletter.id,
14786
+ onChange: handleSelectNewsletter
14787
+ }, newsletter.label))));
14788
+ };
14789
+
14790
+ const NewsletterUpdateView = props => {
14791
+ const {
14792
+ t
14793
+ } = useTranslation("newsletter");
14794
+ return /*#__PURE__*/React__default['default'].createElement("div", {
14795
+ id: "pelcro-newsletter-update-view"
14796
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
14797
+ className: "plc-mb-6 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
14798
+ }, /*#__PURE__*/React__default['default'].createElement("h4", {
14799
+ className: "plc-text-2xl plc-font-semibold"
14800
+ }, t("updateTitle"))), /*#__PURE__*/React__default['default'].createElement("form", {
14801
+ action: "javascript:void(0);",
14802
+ className: "plc-mt-2 pelcro-form"
14803
+ }, /*#__PURE__*/React__default['default'].createElement(NewsletterUpdateContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(NewsletterUpdateList, null), /*#__PURE__*/React__default['default'].createElement(NewsletterUpdateButton, {
14804
+ role: "submit",
14805
+ className: "plc-mt-4 plc-w-full",
14806
+ name: t("labels.submit"),
14807
+ id: "pelcro-submit"
14808
+ }))));
14809
+ };
14810
+
14811
+ const NewsletterUpdateModal = ({
14812
+ onDisplay,
14813
+ onClose,
14814
+ ...otherProps
14815
+ }) => {
14816
+ return /*#__PURE__*/React__default['default'].createElement(Modal, {
14817
+ id: "pelcro-newsletter-update-modal",
14818
+ onDisplay: onDisplay,
14819
+ onClose: onClose
14820
+ }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(NewsletterUpdateView, otherProps)), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
14821
+ };
14822
+ NewsletterUpdateModal.viewId = "newsletter-update";
14823
+
14390
14824
  const MeterView = () => {
14391
14825
  var _paywallProduct$paywa, _paywallProduct$paywa2;
14392
14826
 
@@ -14438,7 +14872,7 @@ const MeterModal = props => {
14438
14872
  className: "plc-fixed plc-bottom-0 plc-right-0 plc-w-full plc-p-4 plc-bg-white plc-border-t-4 plc-rounded plc-shadow-md motion-safe:plc-animate-slideInBottom sm:plc-m-4 sm:plc-max-w-md plc-z-max plc-border-primary-500"
14439
14873
  }, /*#__PURE__*/React__default['default'].createElement("button", {
14440
14874
  type: "button",
14441
- className: "plc-absolute plc-top-0 plc-text-2xl plc-text-gray-500 plc-right-1 pelcro-close-btn",
14875
+ className: "plc-absolute plc-top-0 plc-text-2xl plc-text-gray-500 hover:plc-text-black focus:plc-text-black plc-right-1 plc-border-0 plc-bg-transparent hover:plc-bg-transparent focus:plc-bg-transparent pelcro-close-btn",
14442
14876
  "aria-label": "Close",
14443
14877
  onClick: onClose
14444
14878
  }, /*#__PURE__*/React__default['default'].createElement("span", null, "\xD7")), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(MeterView, props)));
@@ -14774,17 +15208,17 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default['default'].createEl
14774
15208
 
14775
15209
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
14776
15210
 
14777
- var _path$d;
15211
+ var _path$e;
14778
15212
 
14779
- function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
15213
+ function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
14780
15214
 
14781
15215
  function SvgEdit(props) {
14782
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$f({
15216
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$g({
14783
15217
  className: "plc-w-6 plc-h-6",
14784
15218
  xmlns: "http://www.w3.org/2000/svg",
14785
15219
  viewBox: "0 0 20 20",
14786
15220
  fill: "currentColor"
14787
- }, props), _path$d || (_path$d = /*#__PURE__*/React__namespace.createElement("path", {
15221
+ }, props), _path$e || (_path$e = /*#__PURE__*/React__namespace.createElement("path", {
14788
15222
  d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
14789
15223
  })));
14790
15224
  }
@@ -17895,18 +18329,18 @@ const GiftCreateLastName = props => /*#__PURE__*/React__default['default'].creat
17895
18329
  store: store$4
17896
18330
  }, props));
17897
18331
 
17898
- var _path$c;
18332
+ var _path$d;
17899
18333
 
17900
- function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
18334
+ function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
17901
18335
 
17902
18336
  function SvgInfoCircle(props) {
17903
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$e({
18337
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$f({
17904
18338
  xmlns: "http://www.w3.org/2000/svg",
17905
18339
  className: "plc-w-5 plc-h-5",
17906
18340
  fill: "none",
17907
18341
  viewBox: "0 0 24 24",
17908
18342
  stroke: "currentColor"
17909
- }, props), _path$c || (_path$c = /*#__PURE__*/React__namespace.createElement("path", {
18343
+ }, props), _path$d || (_path$d = /*#__PURE__*/React__namespace.createElement("path", {
17910
18344
  strokeLinecap: "round",
17911
18345
  strokeLinejoin: "round",
17912
18346
  strokeWidth: 2,
@@ -18893,8 +19327,8 @@ const PaymentMethodSelectModal = ({
18893
19327
  };
18894
19328
  PaymentMethodSelectModal.viewId = "payment-method-select";
18895
19329
 
18896
- function _extends$d() {
18897
- _extends$d = Object.assign || function (target) {
19330
+ function _extends$e() {
19331
+ _extends$e = Object.assign || function (target) {
18898
19332
  for (var i = 1; i < arguments.length; i++) {
18899
19333
  var source = arguments[i];
18900
19334
 
@@ -18908,7 +19342,7 @@ function _extends$d() {
18908
19342
  return target;
18909
19343
  };
18910
19344
 
18911
- return _extends$d.apply(this, arguments);
19345
+ return _extends$e.apply(this, arguments);
18912
19346
  }
18913
19347
 
18914
19348
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -19092,7 +19526,7 @@ function render(props, propsBag, defaultTag, features, visible) {
19092
19526
  return match(strategy, (_match = {}, _match[RenderStrategy.Unmount] = function () {
19093
19527
  return null;
19094
19528
  }, _match[RenderStrategy.Hidden] = function () {
19095
- return _render(_extends$d({}, _rest, {
19529
+ return _render(_extends$e({}, _rest, {
19096
19530
  hidden: true,
19097
19531
  style: {
19098
19532
  display: 'none'
@@ -19620,7 +20054,7 @@ function TransitionChild(props) {
19620
20054
  var passthroughProps = rest;
19621
20055
  return React__default['default'].createElement(NestingContext.Provider, {
19622
20056
  value: nesting
19623
- }, render(_extends$d({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
20057
+ }, render(_extends$e({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
19624
20058
  }
19625
20059
 
19626
20060
  function Transition(props) {
@@ -19664,7 +20098,7 @@ function Transition(props) {
19664
20098
  value: nestingBag
19665
20099
  }, React__default['default'].createElement(TransitionContext.Provider, {
19666
20100
  value: transitionBag
19667
- }, render(_extends$d({}, sharedProps, {
20101
+ }, render(_extends$e({}, sharedProps, {
19668
20102
  as: React.Fragment,
19669
20103
  children: React__default['default'].createElement(TransitionChild, Object.assign({}, sharedProps, passthroughProps))
19670
20104
  }), propsBag, React.Fragment, TransitionChildRenderFeatures, state === TreeStates.Visible)));
@@ -19791,12 +20225,12 @@ var ActionTypes;
19791
20225
  })(ActionTypes || (ActionTypes = {}));
19792
20226
 
19793
20227
  (_reducers = {}, _reducers[ActionTypes.CloseMenu] = function (state) {
19794
- return _extends$d({}, state, {
20228
+ return _extends$e({}, state, {
19795
20229
  activeItemIndex: null,
19796
20230
  menuState: MenuStates.Closed
19797
20231
  });
19798
20232
  }, _reducers[ActionTypes.OpenMenu] = function (state) {
19799
- return _extends$d({}, state, {
20233
+ return _extends$e({}, state, {
19800
20234
  menuState: MenuStates.Open
19801
20235
  });
19802
20236
  }, _reducers[ActionTypes.GoToItem] = function (state, action) {
@@ -19815,7 +20249,7 @@ var ActionTypes;
19815
20249
  }
19816
20250
  });
19817
20251
  if (state.searchQuery === '' && state.activeItemIndex === activeItemIndex) return state;
19818
- return _extends$d({}, state, {
20252
+ return _extends$e({}, state, {
19819
20253
  searchQuery: '',
19820
20254
  activeItemIndex: activeItemIndex
19821
20255
  });
@@ -19826,19 +20260,19 @@ var ActionTypes;
19826
20260
 
19827
20261
  return ((_item$dataRef$current = item.dataRef.current.textValue) == null ? void 0 : _item$dataRef$current.startsWith(searchQuery)) && !item.dataRef.current.disabled;
19828
20262
  });
19829
- if (match === -1 || match === state.activeItemIndex) return _extends$d({}, state, {
20263
+ if (match === -1 || match === state.activeItemIndex) return _extends$e({}, state, {
19830
20264
  searchQuery: searchQuery
19831
20265
  });
19832
- return _extends$d({}, state, {
20266
+ return _extends$e({}, state, {
19833
20267
  searchQuery: searchQuery,
19834
20268
  activeItemIndex: match
19835
20269
  });
19836
20270
  }, _reducers[ActionTypes.ClearSearch] = function (state) {
19837
- return _extends$d({}, state, {
20271
+ return _extends$e({}, state, {
19838
20272
  searchQuery: ''
19839
20273
  });
19840
20274
  }, _reducers[ActionTypes.RegisterItem] = function (state, action) {
19841
- return _extends$d({}, state, {
20275
+ return _extends$e({}, state, {
19842
20276
  items: [].concat(state.items, [{
19843
20277
  id: action.id,
19844
20278
  dataRef: action.dataRef
@@ -19851,7 +20285,7 @@ var ActionTypes;
19851
20285
  return a.id === action.id;
19852
20286
  });
19853
20287
  if (idx !== -1) nextItems.splice(idx, 1);
19854
- return _extends$d({}, state, {
20288
+ return _extends$e({}, state, {
19855
20289
  items: nextItems,
19856
20290
  activeItemIndex: function () {
19857
20291
  if (idx === state.activeItemIndex) return null;
@@ -19890,19 +20324,19 @@ var ActionTypes$1;
19890
20324
  (_reducers$1 = {}, _reducers$1[ActionTypes$1.CloseListbox] = function (state) {
19891
20325
  if (state.disabled) return state;
19892
20326
  if (state.listboxState === ListboxStates.Closed) return state;
19893
- return _extends$d({}, state, {
20327
+ return _extends$e({}, state, {
19894
20328
  activeOptionIndex: null,
19895
20329
  listboxState: ListboxStates.Closed
19896
20330
  });
19897
20331
  }, _reducers$1[ActionTypes$1.OpenListbox] = function (state) {
19898
20332
  if (state.disabled) return state;
19899
20333
  if (state.listboxState === ListboxStates.Open) return state;
19900
- return _extends$d({}, state, {
20334
+ return _extends$e({}, state, {
19901
20335
  listboxState: ListboxStates.Open
19902
20336
  });
19903
20337
  }, _reducers$1[ActionTypes$1.SetDisabled] = function (state, action) {
19904
20338
  if (state.disabled === action.disabled) return state;
19905
- return _extends$d({}, state, {
20339
+ return _extends$e({}, state, {
19906
20340
  disabled: action.disabled
19907
20341
  });
19908
20342
  }, _reducers$1[ActionTypes$1.GoToOption] = function (state, action) {
@@ -19923,7 +20357,7 @@ var ActionTypes$1;
19923
20357
  }
19924
20358
  });
19925
20359
  if (state.searchQuery === '' && state.activeOptionIndex === activeOptionIndex) return state;
19926
- return _extends$d({}, state, {
20360
+ return _extends$e({}, state, {
19927
20361
  searchQuery: '',
19928
20362
  activeOptionIndex: activeOptionIndex
19929
20363
  });
@@ -19936,10 +20370,10 @@ var ActionTypes$1;
19936
20370
 
19937
20371
  return !option.dataRef.current.disabled && ((_option$dataRef$curre = option.dataRef.current.textValue) == null ? void 0 : _option$dataRef$curre.startsWith(searchQuery));
19938
20372
  });
19939
- if (match === -1 || match === state.activeOptionIndex) return _extends$d({}, state, {
20373
+ if (match === -1 || match === state.activeOptionIndex) return _extends$e({}, state, {
19940
20374
  searchQuery: searchQuery
19941
20375
  });
19942
- return _extends$d({}, state, {
20376
+ return _extends$e({}, state, {
19943
20377
  searchQuery: searchQuery,
19944
20378
  activeOptionIndex: match
19945
20379
  });
@@ -19947,11 +20381,11 @@ var ActionTypes$1;
19947
20381
  if (state.disabled) return state;
19948
20382
  if (state.listboxState === ListboxStates.Closed) return state;
19949
20383
  if (state.searchQuery === '') return state;
19950
- return _extends$d({}, state, {
20384
+ return _extends$e({}, state, {
19951
20385
  searchQuery: ''
19952
20386
  });
19953
20387
  }, _reducers$1[ActionTypes$1.RegisterOption] = function (state, action) {
19954
- return _extends$d({}, state, {
20388
+ return _extends$e({}, state, {
19955
20389
  options: [].concat(state.options, [{
19956
20390
  id: action.id,
19957
20391
  dataRef: action.dataRef
@@ -19964,7 +20398,7 @@ var ActionTypes$1;
19964
20398
  return a.id === action.id;
19965
20399
  });
19966
20400
  if (idx !== -1) nextOptions.splice(idx, 1);
19967
- return _extends$d({}, state, {
20401
+ return _extends$e({}, state, {
19968
20402
  options: nextOptions,
19969
20403
  activeOptionIndex: function () {
19970
20404
  if (idx === state.activeOptionIndex) return null;
@@ -20025,18 +20459,18 @@ const getPaymentCardIcon = name => {
20025
20459
  }));
20026
20460
  };
20027
20461
 
20028
- var _path$b;
20462
+ var _path$c;
20029
20463
 
20030
- function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
20464
+ function _extends$d() { _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
20031
20465
 
20032
20466
  function SvgChevronRight(props) {
20033
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$c({
20467
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$d({
20034
20468
  className: "plc-w-6 plc-h-6",
20035
20469
  xmlns: "http://www.w3.org/2000/svg",
20036
20470
  fill: "none",
20037
20471
  viewBox: "0 0 24 24",
20038
20472
  stroke: "currentColor"
20039
- }, props), _path$b || (_path$b = /*#__PURE__*/React__namespace.createElement("path", {
20473
+ }, props), _path$c || (_path$c = /*#__PURE__*/React__namespace.createElement("path", {
20040
20474
  strokeLinecap: "round",
20041
20475
  strokeLinejoin: "round",
20042
20476
  strokeWidth: 2,
@@ -20335,18 +20769,18 @@ Accordion.item = function AccordionItem({
20335
20769
  }, content)) : null;
20336
20770
  };
20337
20771
 
20338
- var _path$a;
20772
+ var _path$b;
20339
20773
 
20340
- function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
20774
+ function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
20341
20775
 
20342
20776
  function SvgExit(props) {
20343
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$b({
20777
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$c({
20344
20778
  className: "plc-w-6 plc-h-6",
20345
20779
  xmlns: "http://www.w3.org/2000/svg",
20346
20780
  fill: "none",
20347
20781
  viewBox: "0 0 24 24",
20348
20782
  stroke: "currentColor"
20349
- }, props), _path$a || (_path$a = /*#__PURE__*/React__namespace.createElement("path", {
20783
+ }, props), _path$b || (_path$b = /*#__PURE__*/React__namespace.createElement("path", {
20350
20784
  strokeLinecap: "round",
20351
20785
  strokeLinejoin: "round",
20352
20786
  strokeWidth: 2,
@@ -20354,30 +20788,49 @@ function SvgExit(props) {
20354
20788
  })));
20355
20789
  }
20356
20790
 
20357
- var _path$9;
20791
+ var _path$a;
20358
20792
 
20359
- function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
20793
+ function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
20360
20794
 
20361
20795
  function SvgCheckMark(props) {
20362
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$a({
20796
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$b({
20363
20797
  className: "plc-w-4 plc-h-4 plc-mr-1",
20364
20798
  xmlns: "http://www.w3.org/2000/svg",
20365
20799
  viewBox: "0 0 20 20",
20366
20800
  fill: "currentColor"
20367
- }, props), _path$9 || (_path$9 = /*#__PURE__*/React__namespace.createElement("path", {
20801
+ }, props), _path$a || (_path$a = /*#__PURE__*/React__namespace.createElement("path", {
20368
20802
  fillRule: "evenodd",
20369
20803
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
20370
20804
  clipRule: "evenodd"
20371
20805
  })));
20372
20806
  }
20373
20807
 
20808
+ var _path$9;
20809
+
20810
+ function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
20811
+
20812
+ function SvgUser(props) {
20813
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$a({
20814
+ xmlns: "http://www.w3.org/2000/svg",
20815
+ fill: "none",
20816
+ viewBox: "0 0 24 24",
20817
+ stroke: "currentColor"
20818
+ }, props), _path$9 || (_path$9 = /*#__PURE__*/React__namespace.createElement("path", {
20819
+ strokeLinecap: "round",
20820
+ strokeLinejoin: "round",
20821
+ strokeWidth: 2,
20822
+ d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zm-4 7a7 7 0 00-7 7h14a7 7 0 00-7-7z"
20823
+ })));
20824
+ }
20825
+
20374
20826
  var _path$8;
20375
20827
 
20376
20828
  function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
20377
20829
 
20378
- function SvgUser(props) {
20830
+ function SvgNewsletter(props) {
20379
20831
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$9({
20380
20832
  xmlns: "http://www.w3.org/2000/svg",
20833
+ className: "plc-h-5 plc-w-5",
20381
20834
  fill: "none",
20382
20835
  viewBox: "0 0 24 24",
20383
20836
  stroke: "currentColor"
@@ -20385,7 +20838,7 @@ function SvgUser(props) {
20385
20838
  strokeLinecap: "round",
20386
20839
  strokeLinejoin: "round",
20387
20840
  strokeWidth: 2,
20388
- d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zm-4 7a7 7 0 00-7 7h14a7 7 0 00-7-7z"
20841
+ d: "M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"
20389
20842
  })));
20390
20843
  }
20391
20844
 
@@ -20624,6 +21077,24 @@ class Dashboard extends React.Component {
20624
21077
  });
20625
21078
  });
20626
21079
 
21080
+ _defineProperty$3(this, "componentWillUnmount", () => {
21081
+ document.removeEventListener("click", this.hideMenuIfClickedOutside);
21082
+ });
21083
+
21084
+ _defineProperty$3(this, "initializeHideMenuHandler", () => {
21085
+ document.addEventListener("click", this.hideMenuIfClickedOutside);
21086
+ });
21087
+
21088
+ _defineProperty$3(this, "hideMenuIfClickedOutside", event => {
21089
+ const didClickOutsideMenu = this.state.isOpen && this.menuRef.current && !this.menuRef.current.contains(event.target);
21090
+
21091
+ if (didClickOutsideMenu) {
21092
+ this.setState({
21093
+ isOpen: false
21094
+ });
21095
+ }
21096
+ });
21097
+
20627
21098
  _defineProperty$3(this, "cancelSubscription", (subscription_id, onSuccess, onFailure) => {
20628
21099
  // disable the Login button to prevent repeated clicks
20629
21100
  window.Pelcro.subscription.cancel({
@@ -20661,6 +21132,10 @@ class Dashboard extends React.Component {
20661
21132
  return this.props.setView("password-change");
20662
21133
  });
20663
21134
 
21135
+ _defineProperty$3(this, "displayNewsletterUpdate", () => {
21136
+ return this.props.setView("newsletter-update");
21137
+ });
21138
+
20664
21139
  _defineProperty$3(this, "displayProductSelect", ({
20665
21140
  isGift
20666
21141
  }) => {
@@ -20820,21 +21295,21 @@ class Dashboard extends React.Component {
20820
21295
  className: "plc-inline-block plc-mt-1"
20821
21296
  }, sub.shipments_remaining, " ", this.locale("labels.shipments")) : null)), /*#__PURE__*/React__default['default'].createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(Button, {
20822
21297
  variant: "ghost",
20823
- className: "plc-text-red-500 focus:plc-ring-red-500",
21298
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
20824
21299
  icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
20825
21300
  onClick: onCancelClick,
20826
21301
  disabled: this.state.disableSubmit,
20827
21302
  "data-key": sub.id
20828
21303
  }, this.locale("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default['default'].createElement(Button, {
20829
21304
  variant: "ghost",
20830
- className: "plc-text-green-400 focus:plc-ring-green-300",
21305
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
20831
21306
  icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
20832
21307
  onClick: onReactivateClick,
20833
21308
  disabled: this.state.disableSubmit,
20834
21309
  "data-key": sub.id
20835
21310
  }, this.locale("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default['default'].createElement(Button, {
20836
21311
  variant: "ghost",
20837
- className: "plc-text-blue-400",
21312
+ className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
20838
21313
  icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
20839
21314
  onClick: onRenewClick,
20840
21315
  disabled: this.state.disableSubmit,
@@ -21015,28 +21490,33 @@ class Dashboard extends React.Component {
21015
21490
  this.site = window.Pelcro.site.read();
21016
21491
  this.locale = this.props.t;
21017
21492
  this.user = window.Pelcro.user.read();
21493
+ this.menuRef = /*#__PURE__*/React__default['default'].createRef();
21018
21494
  }
21019
21495
 
21020
21496
  render() {
21021
- var _window$Pelcro$user$r3, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
21497
+ var _window$Pelcro$user$r3, _window$Pelcro, _window$Pelcro$uiSett, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
21022
21498
 
21023
21499
  const {
21024
21500
  isOpen
21025
21501
  } = this.state;
21026
21502
  const userHasName = this.user.first_name || this.user.last_name;
21027
21503
  const profilePicture = (_window$Pelcro$user$r3 = window.Pelcro.user.read().profile_photo) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : userSolidIcon;
21504
+ 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;
21505
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
21028
21506
  return /*#__PURE__*/React__default['default'].createElement(Transition, {
21029
21507
  className: "plc-fixed plc-inset-y-0 plc-right-0 plc-h-full plc-max-w-xl plc-overflow-y-auto plc-text-left plc-bg-white plc-shadow-xl plc-z-max",
21030
21508
  show: isOpen,
21031
21509
  enter: "plc-transform plc-transition plc-duration-500",
21032
21510
  enterFrom: "plc-translate-x-full",
21033
21511
  enterTo: "plc-translate-x-0",
21512
+ afterEnter: this.initializeHideMenuHandler,
21034
21513
  leave: "plc-transform plc-transition plc-duration-500",
21035
21514
  leaveFrom: "plc-translate-x-0",
21036
21515
  leaveTo: "plc-translate-x-full",
21037
21516
  afterLeave: this.props.onClose
21038
21517
  }, /*#__PURE__*/React__default['default'].createElement("div", {
21039
- id: "pelcro-view-dashboard"
21518
+ id: "pelcro-view-dashboard",
21519
+ ref: this.menuRef
21040
21520
  }, /*#__PURE__*/React__default['default'].createElement("header", {
21041
21521
  className: "plc-flex plc-flex-col plc-p-4 plc-pl-2 plc-min-h-40 sm:plc-pr-8 plc-bg-primary-500"
21042
21522
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -21099,7 +21579,14 @@ class Dashboard extends React.Component {
21099
21579
  }),
21100
21580
  className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21101
21581
  onClick: this.displayChangePassword
21102
- }, this.locale("labels.changePassword")))
21582
+ }, this.locale("labels.changePassword")), siteHasNewslettersDefined && /*#__PURE__*/React__default['default'].createElement(Button, {
21583
+ variant: "ghost",
21584
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgNewsletter, {
21585
+ className: "plc-w-5 plc-h-5 plc-mr-1"
21586
+ }),
21587
+ className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21588
+ onClick: this.displayNewsletterUpdate
21589
+ }, this.locale("labels.editNewsletters")))
21103
21590
  }), /*#__PURE__*/React__default['default'].createElement(Accordion.item, {
21104
21591
  name: SUB_MENUS.PAYMENT_CARDS,
21105
21592
  icon: /*#__PURE__*/React__default['default'].createElement(SvgPaymentCard, null),
@@ -21175,7 +21662,7 @@ const DashboardOpenButton = () => {
21175
21662
  return /*#__PURE__*/React__default['default'].createElement("div", {
21176
21663
  className: "plc-fixed plc-right-4 plc-bottom-4 pelcro-open-dashboard-btn"
21177
21664
  }, /*#__PURE__*/React__default['default'].createElement("button", {
21178
- className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300",
21665
+ className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300 hover:plc-bg-white",
21179
21666
  name: "menu",
21180
21667
  id: "pelcro-view-menu",
21181
21668
  onClick: () => switchView("dashboard")
@@ -23040,6 +23527,7 @@ exports.AddressUpdateSubmit = AddressUpdateSubmit;
23040
23527
  exports.AddressUpdateTextInput = AddressUpdateTextInput;
23041
23528
  exports.AddressUpdateView = AddressUpdateView;
23042
23529
  exports.Alert = AlertWithContext;
23530
+ exports.AlertElement = Alert;
23043
23531
  exports.ApplyCouponButton = ApplyCouponButton;
23044
23532
  exports.Badge = Badge;
23045
23533
  exports.BankRedirection = BankRedirection;
@@ -23091,6 +23579,11 @@ exports.Modal = Modal;
23091
23579
  exports.ModalBody = ModalBody;
23092
23580
  exports.ModalFooter = ModalFooter;
23093
23581
  exports.NewsLetter = NewsletterWithHook;
23582
+ exports.NewsletterUpdateButton = NewsletterUpdateButton;
23583
+ exports.NewsletterUpdateContainer = NewsletterUpdateContainer;
23584
+ exports.NewsletterUpdateList = NewsletterUpdateList;
23585
+ exports.NewsletterUpdateModal = NewsletterUpdateModal;
23586
+ exports.NewsletterUpdateView = NewsletterUpdateView;
23094
23587
  exports.Notification = Notification;
23095
23588
  exports.OrderConfirmModal = OrderConfirmModal;
23096
23589
  exports.OrderCreateContainer = OrderCreateContainer;
@@ -23169,6 +23662,7 @@ exports.SubscriptionCreateView = SubscriptionCreateView;
23169
23662
  exports.SubscriptionRenewContainer = SubscriptionRenewContainer;
23170
23663
  exports.SubscriptionRenewModal = SubscriptionRenewModal;
23171
23664
  exports.SubscriptionRenewView = SubscriptionRenewView;
23665
+ exports.TaxAmount = TaxAmount;
23172
23666
  exports.TextArea = TextArea;
23173
23667
  exports.Tooltip = Tooltip;
23174
23668
  exports.UserUpdateButton = UserUpdateButton;