@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.esm.js CHANGED
@@ -3432,6 +3432,7 @@ var paymentMethod_fr = {
3432
3432
  };
3433
3433
 
3434
3434
  var title$d = "Enter your email to subscribe to our newsletter";
3435
+ var updateTitle$1 = "Update newsletter selections";
3435
3436
  var subtitle$7 = "We may use your email for other marketing communication";
3436
3437
  var labels$l = {
3437
3438
  submit: "Submit",
@@ -3443,22 +3444,21 @@ var labels$l = {
3443
3444
  };
3444
3445
  var messages$p = {
3445
3446
  alreadyHaveAccount: "Already have an account?",
3447
+ success: "Newsletters were successfully updated",
3446
3448
  loginHere: "Login here.",
3447
3449
  createAnAccount: " Create an account by clicking ",
3448
3450
  here: "here"
3449
3451
  };
3450
- var errors$b = {
3451
- "": ""
3452
- };
3453
3452
  var newsletter_en = {
3454
3453
  title: title$d,
3454
+ updateTitle: updateTitle$1,
3455
3455
  subtitle: subtitle$7,
3456
3456
  labels: labels$l,
3457
- messages: messages$p,
3458
- errors: errors$b
3457
+ messages: messages$p
3459
3458
  };
3460
3459
 
3461
3460
  var title$c = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
3461
+ var updateTitle = "Mettre à jour son choix d'infolettres";
3462
3462
  var subtitle$6 = "Nous pouvons utiliser votre adresse courriel pour d’autres communications marketing";
3463
3463
  var labels$k = {
3464
3464
  submit: "Lire l’article !",
@@ -3470,19 +3470,17 @@ var labels$k = {
3470
3470
  };
3471
3471
  var messages$o = {
3472
3472
  alreadyHaveAccount: "Vous avez déjà un compte ?",
3473
+ success: "Votre choix d'infolettres à été mis à jour",
3473
3474
  loginHere: "Connectez-vous ici",
3474
3475
  createAnAccount: " Créez un compte en cliquant ",
3475
3476
  here: "ici"
3476
3477
  };
3477
- var errors$a = {
3478
- "": ""
3479
- };
3480
3478
  var newsletter_fr = {
3481
3479
  title: title$c,
3480
+ updateTitle: updateTitle,
3482
3481
  subtitle: subtitle$6,
3483
3482
  labels: labels$k,
3484
- messages: messages$o,
3485
- errors: errors$a
3483
+ messages: messages$o
3486
3484
  };
3487
3485
 
3488
3486
  var labels$j = {
@@ -3591,7 +3589,8 @@ var labels$h = {
3591
3589
  code: "Coupon code",
3592
3590
  "for": "for",
3593
3591
  interval: "{{count}} {{interval}}",
3594
- interval_plural: "{{count}} {{interval}}s"
3592
+ interval_plural: "{{count}} {{interval}}s",
3593
+ tax: "+ Tax"
3595
3594
  };
3596
3595
  var checkoutForm_en = {
3597
3596
  messages: messages$j,
@@ -3616,7 +3615,8 @@ var labels$g = {
3616
3615
  code: "Code promo",
3617
3616
  "for": "pour",
3618
3617
  interval: "{{count}} {{interval}}",
3619
- interval_plural: "{{count}} {{interval}}s"
3618
+ interval_plural: "{{count}} {{interval}}s",
3619
+ tax: "+ Taxe"
3620
3620
  };
3621
3621
  var checkoutForm_fr = {
3622
3622
  messages: messages$i,
@@ -4345,6 +4345,7 @@ var labels$3 = {
4345
4345
  profile: "Profile",
4346
4346
  updateProfile: "Edit profile",
4347
4347
  changePassword: "Change password",
4348
+ editNewsletters: "Edit newsletters",
4348
4349
  edit: "Edit",
4349
4350
  gifts: "Gifts",
4350
4351
  redeemGift: "Redeem gift",
@@ -4421,6 +4422,7 @@ var labels$2 = {
4421
4422
  profile: "Profil",
4422
4423
  updateProfile: "Mettre à jour le profil",
4423
4424
  changePassword: "Changer le mot de passe",
4425
+ editNewsletters: "Modifier les newsletters",
4424
4426
  edit: "Modifier",
4425
4427
  gifts: "Cadeaux",
4426
4428
  redeemGift: "Échanger un cadeau",
@@ -5897,7 +5899,7 @@ class PelcroActions {
5897
5899
  view,
5898
5900
  cartItems,
5899
5901
  ...otherStateFields
5900
- } = initialState$f;
5902
+ } = initialState$g;
5901
5903
  this.set(otherStateFields);
5902
5904
  });
5903
5905
 
@@ -6187,7 +6189,7 @@ class PelcroCallbacks {
6187
6189
 
6188
6190
  }
6189
6191
 
6190
- const initialState$f = {
6192
+ const initialState$g = {
6191
6193
  // View
6192
6194
  view: null,
6193
6195
  // Plans
@@ -6215,7 +6217,7 @@ const createPelcroStore = () => createStore(middleware_3((set, get) => {
6215
6217
  return {
6216
6218
  // Store setter
6217
6219
  set,
6218
- ...initialState$f,
6220
+ ...initialState$g,
6219
6221
  // State actions
6220
6222
  ...actions,
6221
6223
  // Callbacks
@@ -6346,11 +6348,40 @@ const calcAndFormatItemsTotal = (items, currency) => {
6346
6348
  */
6347
6349
 
6348
6350
  const isValidViewFromURL = viewID => {
6349
- 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)) {
6351
+ 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()) {
6350
6352
  return true;
6351
6353
  }
6352
6354
 
6353
6355
  return false;
6356
+
6357
+ function hasValidNewsletterUpdateUrl() {
6358
+ var _window$Pelcro, _window$Pelcro$uiSett;
6359
+
6360
+ if (viewID !== "newsletter-update") return false;
6361
+ const newsletters = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.newsletters;
6362
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6363
+
6364
+ if (!siteHasNewslettersDefined) {
6365
+ return false;
6366
+ }
6367
+
6368
+ const queryParamEmail = window.Pelcro.helpers.getURLParameter("email");
6369
+
6370
+ if (queryParamEmail && window.Pelcro.user.isAuthenticated()) {
6371
+ var _window$Pelcro$user$r4;
6372
+
6373
+ if (queryParamEmail !== ((_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.email)) {
6374
+ console.error("email query parameter and user account email are different, url email query parameter must match user email if user is logged in");
6375
+ return false;
6376
+ }
6377
+ }
6378
+
6379
+ if (!queryParamEmail && !window.Pelcro.user.isAuthenticated()) {
6380
+ return false;
6381
+ }
6382
+
6383
+ return true;
6384
+ }
6354
6385
  };
6355
6386
  /**
6356
6387
  * Returns the current stable viewID from all old variations
@@ -6382,7 +6413,7 @@ const disableScroll = () => {
6382
6413
  }
6383
6414
  };
6384
6415
  const trackSubscriptionOnGA = () => {
6385
- 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;
6416
+ 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;
6386
6417
 
6387
6418
  const {
6388
6419
  product,
@@ -6404,7 +6435,7 @@ const trackSubscriptionOnGA = () => {
6404
6435
  }
6405
6436
 
6406
6437
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
6407
- 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
6438
+ 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
6408
6439
  });
6409
6440
  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", {
6410
6441
  id: lastSubscriptionId,
@@ -6432,9 +6463,9 @@ const trackSubscriptionOnGA = () => {
6432
6463
  */
6433
6464
 
6434
6465
  const userHasPaymentMethod = () => {
6435
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
6466
+ var _window$Pelcro$user$r7, _window$Pelcro$user$r8;
6436
6467
 
6437
- 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 : [];
6468
+ 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 : [];
6438
6469
  return sources.length > 0;
6439
6470
  };
6440
6471
  /**
@@ -6816,8 +6847,8 @@ const saveToMetadataButton = new SaveToMetadataButtonClass();
6816
6847
 
6817
6848
  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}}
6818
6849
 
6819
- function _extends$t() {
6820
- _extends$t = Object.assign || function (target) {
6850
+ function _extends$u() {
6851
+ _extends$u = Object.assign || function (target) {
6821
6852
  for (var i = 1; i < arguments.length; i++) {
6822
6853
  var source = arguments[i];
6823
6854
 
@@ -6831,7 +6862,7 @@ function _extends$t() {
6831
6862
  return target;
6832
6863
  };
6833
6864
 
6834
- return _extends$t.apply(this, arguments);
6865
+ return _extends$u.apply(this, arguments);
6835
6866
  }
6836
6867
 
6837
6868
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -6921,7 +6952,7 @@ var clearFromRemoveQueue = function clearFromRemoveQueue(toastId) {
6921
6952
  var reducer = function reducer(state, action) {
6922
6953
  switch (action.type) {
6923
6954
  case ActionType.ADD_TOAST:
6924
- return _extends$t({}, state, {
6955
+ return _extends$u({}, state, {
6925
6956
  toasts: [action.toast].concat(state.toasts).slice(0, TOAST_LIMIT)
6926
6957
  });
6927
6958
 
@@ -6931,9 +6962,9 @@ var reducer = function reducer(state, action) {
6931
6962
  clearFromRemoveQueue(action.toast.id);
6932
6963
  }
6933
6964
 
6934
- return _extends$t({}, state, {
6965
+ return _extends$u({}, state, {
6935
6966
  toasts: state.toasts.map(function (t) {
6936
- return t.id === action.toast.id ? _extends$t({}, t, action.toast) : t;
6967
+ return t.id === action.toast.id ? _extends$u({}, t, action.toast) : t;
6937
6968
  })
6938
6969
  });
6939
6970
 
@@ -6960,9 +6991,9 @@ var reducer = function reducer(state, action) {
6960
6991
  });
6961
6992
  }
6962
6993
 
6963
- return _extends$t({}, state, {
6994
+ return _extends$u({}, state, {
6964
6995
  toasts: state.toasts.map(function (t) {
6965
- return t.id === toastId || toastId === undefined ? _extends$t({}, t, {
6996
+ return t.id === toastId || toastId === undefined ? _extends$u({}, t, {
6966
6997
  visible: false
6967
6998
  }) : t;
6968
6999
  })
@@ -6970,28 +7001,28 @@ var reducer = function reducer(state, action) {
6970
7001
 
6971
7002
  case ActionType.REMOVE_TOAST:
6972
7003
  if (action.toastId === undefined) {
6973
- return _extends$t({}, state, {
7004
+ return _extends$u({}, state, {
6974
7005
  toasts: []
6975
7006
  });
6976
7007
  }
6977
7008
 
6978
- return _extends$t({}, state, {
7009
+ return _extends$u({}, state, {
6979
7010
  toasts: state.toasts.filter(function (t) {
6980
7011
  return t.id !== action.toastId;
6981
7012
  })
6982
7013
  });
6983
7014
 
6984
7015
  case ActionType.START_PAUSE:
6985
- return _extends$t({}, state, {
7016
+ return _extends$u({}, state, {
6986
7017
  pausedAt: action.time
6987
7018
  });
6988
7019
 
6989
7020
  case ActionType.END_PAUSE:
6990
7021
  var diff = action.time - (state.pausedAt || 0);
6991
- return _extends$t({}, state, {
7022
+ return _extends$u({}, state, {
6992
7023
  pausedAt: undefined,
6993
7024
  toasts: state.toasts.map(function (t) {
6994
- return _extends$t({}, t, {
7025
+ return _extends$u({}, t, {
6995
7026
  pauseDuration: t.pauseDuration + diff
6996
7027
  });
6997
7028
  })
@@ -7038,12 +7069,12 @@ var useStore = function useStore(toastOptions) {
7038
7069
  var mergedToasts = state.toasts.map(function (t) {
7039
7070
  var _toastOptions$t$type, _toastOptions, _toastOptions$t$type2;
7040
7071
 
7041
- return _extends$t({}, toastOptions, toastOptions[t.type], t, {
7072
+ return _extends$u({}, toastOptions, toastOptions[t.type], t, {
7042
7073
  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],
7043
- style: _extends$t({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7074
+ style: _extends$u({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7044
7075
  });
7045
7076
  });
7046
- return _extends$t({}, state, {
7077
+ return _extends$u({}, state, {
7047
7078
  toasts: mergedToasts
7048
7079
  });
7049
7080
  };
@@ -7053,7 +7084,7 @@ var createToast = function createToast(message, type, opts) {
7053
7084
  type = 'blank';
7054
7085
  }
7055
7086
 
7056
- return _extends$t({
7087
+ return _extends$u({
7057
7088
  createdAt: Date.now(),
7058
7089
  visible: true,
7059
7090
  type: type,
@@ -7103,14 +7134,14 @@ toast.remove = function (toastId) {
7103
7134
  };
7104
7135
 
7105
7136
  toast.promise = function (promise, msgs, opts) {
7106
- var id = toast.loading(msgs.loading, _extends$t({}, opts, opts == null ? void 0 : opts.loading));
7137
+ var id = toast.loading(msgs.loading, _extends$u({}, opts, opts == null ? void 0 : opts.loading));
7107
7138
  promise.then(function (p) {
7108
- toast.success(resolveValue(msgs.success, p), _extends$t({
7139
+ toast.success(resolveValue(msgs.success, p), _extends$u({
7109
7140
  id: id
7110
7141
  }, opts, opts == null ? void 0 : opts.success));
7111
7142
  return p;
7112
7143
  })["catch"](function (e) {
7113
- toast.error(resolveValue(msgs.error, e), _extends$t({
7144
+ toast.error(resolveValue(msgs.error, e), _extends$u({
7114
7145
  id: id
7115
7146
  }, opts, opts == null ? void 0 : opts.error));
7116
7147
  });
@@ -7449,7 +7480,7 @@ var ToastBar = /*#__PURE__*/memo(function (_ref2) {
7449
7480
  var message = createElement(Message, Object.assign({}, toast.ariaProps), resolveValue(toast.message, toast));
7450
7481
  return createElement(ToastBarBase, {
7451
7482
  className: toast.className,
7452
- style: _extends$t({}, animationStyle, style, toast.style)
7483
+ style: _extends$u({}, animationStyle, style, toast.style)
7453
7484
  }, typeof children === 'function' ? children({
7454
7485
  icon: icon,
7455
7486
  message: message
@@ -7479,7 +7510,7 @@ var getPositionStyle = function getPositionStyle(position, offset) {
7479
7510
  } : position.includes('right') ? {
7480
7511
  justifyContent: 'flex-end'
7481
7512
  } : {};
7482
- return _extends$t({
7513
+ return _extends$u({
7483
7514
  left: 0,
7484
7515
  right: 0,
7485
7516
  display: 'flex',
@@ -7506,7 +7537,7 @@ var Toaster = function Toaster(_ref) {
7506
7537
  handlers = _useToaster.handlers;
7507
7538
 
7508
7539
  return createElement("div", {
7509
- style: _extends$t({
7540
+ style: _extends$u({
7510
7541
  position: 'fixed',
7511
7542
  zIndex: 9999,
7512
7543
  top: DEFAULT_OFFSET,
@@ -7541,82 +7572,82 @@ var Toaster = function Toaster(_ref) {
7541
7572
  }));
7542
7573
  };
7543
7574
 
7544
- var _path$q;
7575
+ var _path$r;
7545
7576
 
7546
- 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); }
7577
+ 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); }
7547
7578
 
7548
7579
  function SvgCheckSolid(props) {
7549
- return /*#__PURE__*/React.createElement("svg", _extends$s({
7580
+ return /*#__PURE__*/React.createElement("svg", _extends$t({
7550
7581
  xmlns: "http://www.w3.org/2000/svg",
7551
7582
  className: "h-5 w-5",
7552
7583
  viewBox: "0 0 20 20",
7553
7584
  fill: "currentColor"
7554
- }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
7585
+ }, props), _path$r || (_path$r = /*#__PURE__*/React.createElement("path", {
7555
7586
  fillRule: "evenodd",
7556
7587
  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",
7557
7588
  clipRule: "evenodd"
7558
7589
  })));
7559
7590
  }
7560
7591
 
7561
- var _path$p;
7592
+ var _path$q;
7562
7593
 
7563
- 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); }
7594
+ 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); }
7564
7595
 
7565
7596
  function SvgXIcon(props) {
7566
- return /*#__PURE__*/React.createElement("svg", _extends$r({
7597
+ return /*#__PURE__*/React.createElement("svg", _extends$s({
7567
7598
  xmlns: "http://www.w3.org/2000/svg",
7568
7599
  viewBox: "0 0 20 20",
7569
7600
  fill: "currentColor"
7570
- }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
7601
+ }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
7571
7602
  fill: "evenodd",
7572
7603
  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",
7573
7604
  clipRule: "evenodd"
7574
7605
  })));
7575
7606
  }
7576
7607
 
7577
- var _path$o;
7608
+ var _path$p;
7578
7609
 
7579
- 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); }
7610
+ 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); }
7580
7611
 
7581
7612
  function SvgXIconSolid(props) {
7582
- return /*#__PURE__*/React.createElement("svg", _extends$q({
7613
+ return /*#__PURE__*/React.createElement("svg", _extends$r({
7583
7614
  className: "plc-w-4 plc-h-4",
7584
7615
  fill: "currentColor",
7585
7616
  xmlns: "http://www.w3.org/2000/svg",
7586
7617
  viewBox: "0 0 100 100"
7587
- }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
7618
+ }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
7588
7619
  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"
7589
7620
  })));
7590
7621
  }
7591
7622
 
7592
- var _path$n;
7623
+ var _path$o;
7593
7624
 
7594
- 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); }
7625
+ 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); }
7595
7626
 
7596
7627
  function SvgExclamation(props) {
7597
- return /*#__PURE__*/React.createElement("svg", _extends$p({
7628
+ return /*#__PURE__*/React.createElement("svg", _extends$q({
7598
7629
  className: "plc-w-4 plc-h-4 plc-mr-1",
7599
7630
  xmlns: "http://www.w3.org/2000/svg",
7600
7631
  viewBox: "0 0 20 20",
7601
7632
  fill: "currentColor"
7602
- }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
7633
+ }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
7603
7634
  fillRule: "evenodd",
7604
7635
  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",
7605
7636
  clipRule: "evenodd"
7606
7637
  })));
7607
7638
  }
7608
7639
 
7609
- var _path$m, _path2$3;
7640
+ var _path$n, _path2$3;
7610
7641
 
7611
- 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); }
7642
+ 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); }
7612
7643
 
7613
7644
  function SvgSpinner(props) {
7614
- return /*#__PURE__*/React.createElement("svg", _extends$o({
7645
+ return /*#__PURE__*/React.createElement("svg", _extends$p({
7615
7646
  className: "plc-animate-spin",
7616
7647
  viewBox: "0 0 24 24",
7617
7648
  fill: "currentColor",
7618
7649
  xmlns: "http://www.w3.org/2000/svg"
7619
- }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
7650
+ }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
7620
7651
  opacity: 0.2,
7621
7652
  fill: "evenodd",
7622
7653
  clipRule: "evenodd",
@@ -7842,6 +7873,16 @@ const init$1 = () => {
7842
7873
  }
7843
7874
  }
7844
7875
 
7876
+ const pelcroUpdateNewslettersButtons = document.getElementsByClassName("pelcro-update-newsletters-button");
7877
+
7878
+ if (pelcroUpdateNewslettersButtons.length !== 0) {
7879
+ for (let i = 0; i < pelcroUpdateNewslettersButtons.length; i++) {
7880
+ pelcroUpdateNewslettersButtons[i].addEventListener("click", () => {
7881
+ switchView("newsletter-update");
7882
+ });
7883
+ }
7884
+ }
7885
+
7845
7886
  const pelcroCartButtonsByClass = document.getElementsByClassName("pelcro-cart-button");
7846
7887
 
7847
7888
  if (pelcroCartButtonsByClass.length !== 0) {
@@ -8057,87 +8098,71 @@ function Link({
8057
8098
 
8058
8099
  const init = () => {
8059
8100
  const {
8060
- whenSiteReady,
8061
- view,
8062
- resetView,
8063
8101
  switchView,
8064
8102
  set
8065
8103
  } = usePelcro.getStore();
8066
- whenSiteReady(() => {
8067
- const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8104
+ const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8068
8105
 
8069
- if (entitlementsProtectedElements.length === 0) {
8070
- return;
8071
- }
8106
+ if (entitlementsProtectedElements.length === 0) {
8107
+ return false;
8108
+ }
8072
8109
 
8073
- if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8074
- 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");
8075
- return;
8076
- }
8110
+ if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8111
+ 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");
8112
+ return false;
8113
+ }
8077
8114
 
8078
- entitlementsProtectedElements.forEach(elem => {
8079
- const entitlements = getEntitlementsFromElem(elem);
8115
+ for (const elem of entitlementsProtectedElements) {
8116
+ const entitlements = getEntitlementsFromElem(elem);
8080
8117
 
8081
- if (entitlements.length === 0) {
8082
- console.error("invalid data-pelcro-entitlements attribute value", elem);
8083
- return;
8084
- }
8118
+ if (entitlements.length === 0) {
8119
+ console.error("invalid data-pelcro-entitlements attribute value", elem);
8120
+ return false;
8121
+ }
8085
8122
 
8086
- if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8087
- 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)");
8088
- }
8123
+ if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8124
+ 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)");
8125
+ }
8089
8126
 
8090
- if (shouldBlurContent(entitlements)) {
8091
- // remove all event listeners from the elem by replacing it with a deep clone of itself
8092
- const elemDeepClone = elem.cloneNode(true);
8093
- elem.replaceWith(elemDeepClone);
8094
- disableKeyboardInteractions(elemDeepClone);
8095
- elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8096
- unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8097
- /*
8098
- showing both the meter and the entitlements notification doesn't make sense from
8099
- a product prespective + they would take half the screen on mobile devies, so we're
8100
- hiding the meter, and showing the entitlements notification only.
8101
- */
8127
+ if (shouldBlurContent(entitlements)) {
8128
+ // remove all event listeners from the elem by replacing it with a deep clone of itself
8129
+ const elemDeepClone = elem.cloneNode(true);
8130
+ elem.replaceWith(elemDeepClone);
8131
+ disableKeyboardInteractions(elemDeepClone);
8132
+ elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8133
+ unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8134
+ const NOTIFICATION_ID = "entitlement";
8135
+ notify( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
8136
+ i18nKey: "messages:entitlement"
8137
+ }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default.createElement(Link, {
8138
+ onClick: () => {
8139
+ const productId = Number(elem.dataset.productId);
8140
+ const planId = Number(elem.dataset.planId);
8141
+ const selectedProduct = window.Pelcro.product.getById(productId);
8142
+ const selectedPlan = window.Pelcro.plan.getById(planId);
8143
+ const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8102
8144
 
8103
- if (view === "meter") {
8104
- resetView();
8105
- }
8145
+ if (hasValidProductAndPlan) {
8146
+ set({
8147
+ product: selectedProduct,
8148
+ plan: selectedPlan
8149
+ });
8150
+ }
8106
8151
 
8107
- const NOTIFICATION_ID = "entitlement";
8108
- notify( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
8109
- i18nKey: "messages:entitlement"
8110
- }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default.createElement(Link, {
8111
- onClick: () => {
8112
- const productId = Number(elem.dataset.productId);
8113
- const planId = Number(elem.dataset.planId);
8114
- const selectedProduct = window.Pelcro.product.getById(productId);
8115
- const selectedPlan = window.Pelcro.plan.getById(planId);
8116
- const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8117
-
8118
- if (hasValidProductAndPlan) {
8119
- set({
8120
- product: selectedProduct,
8121
- plan: selectedPlan
8122
- });
8123
- }
8152
+ notify.dismiss(NOTIFICATION_ID);
8153
+ switchView("_plan-select-entitlements");
8154
+ }
8155
+ }, "Subscribe"), "now to get full page access.")), {
8156
+ className: "pelcro-notification-entitlement",
8157
+ position: "bottom-right",
8158
+ duration: Infinity,
8159
+ id: NOTIFICATION_ID
8160
+ });
8161
+ }
8162
+ }
8124
8163
 
8125
- notify.dismiss(NOTIFICATION_ID);
8126
- switchView("_plan-select-entitlements");
8127
- }
8128
- }, "Subscribe"), "now to get full page access.")), {
8129
- className: "pelcro-notification-entitlement",
8130
- position: "bottom-right",
8131
- duration: Infinity,
8132
- id: NOTIFICATION_ID
8133
- });
8134
- }
8135
- });
8136
- });
8164
+ return true;
8137
8165
  };
8138
- /**
8139
- *
8140
- */
8141
8166
 
8142
8167
  function allElemsHaveSameEntitlements(elems) {
8143
8168
  const entitlements = getEntitlementsFromElem(elems[0]);
@@ -8147,10 +8172,6 @@ function allElemsHaveSameEntitlements(elems) {
8147
8172
  return entitlements.every(ent => elemEntitlements.includes(ent));
8148
8173
  });
8149
8174
  }
8150
- /**
8151
- *
8152
- */
8153
-
8154
8175
 
8155
8176
  function disableKeyboardInteractions(elem) {
8156
8177
  elem.addEventListener("keydown", event => {
@@ -8163,10 +8184,6 @@ function disableKeyboardInteractions(elem) {
8163
8184
  }
8164
8185
  }, true);
8165
8186
  }
8166
- /**
8167
- *
8168
- */
8169
-
8170
8187
 
8171
8188
  function unblurElemWhenUserSubscribes(elem, entitlements) {
8172
8189
  document.addEventListener("PelcroSubscriptionCreate", event => {
@@ -8174,11 +8191,11 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8174
8191
  isGift
8175
8192
  } = usePelcro.getStore();
8176
8193
  if (isGift) return;
8177
- const latestSub = event.detail.data.subscriptions[0];
8194
+ const latestSub = event.detail.data.subscriptions[event.detail.data.subscriptions.length - 1];
8178
8195
  const shouldUnblurContent = entitlements.some(ent => {
8179
- var _latestSub$plan$entit, _latestSub$plan$entit2;
8196
+ var _latestSub$plan$entit, _latestSub$plan, _latestSub$plan$entit2;
8180
8197
 
8181
- 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;
8198
+ 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;
8182
8199
  });
8183
8200
 
8184
8201
  if (shouldUnblurContent) {
@@ -8186,10 +8203,6 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8186
8203
  }
8187
8204
  });
8188
8205
  }
8189
- /**
8190
- *
8191
- */
8192
-
8193
8206
 
8194
8207
  function shouldBlurContent(entitlements) {
8195
8208
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
@@ -8236,7 +8249,9 @@ const initPaywalls = () => {
8236
8249
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
8237
8250
 
8238
8251
  if (((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.settings) === "subscription") {
8239
- // Skip if article is not restricted
8252
+ // blur entitlements based content
8253
+ const didBlurContent = init(); // Skip paywall if article is not restricted
8254
+
8240
8255
  if (isValidViewFromURL(viewFromURL) || !paywallMethods.isArticleRestricted()) {
8241
8256
  return;
8242
8257
  }
@@ -8246,9 +8261,14 @@ const initPaywalls = () => {
8246
8261
  } = usePelcro.getStore();
8247
8262
 
8248
8263
  if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
8249
- switchView("meter"); // initializing content entitlement here because it interacts with meter
8250
-
8251
- init();
8264
+ /*
8265
+ showing both the meter and the entitlements notification doesn't make sense from
8266
+ a product prespective + they would take half the screen on mobile devies, so we're
8267
+ not showing the meter, and only showing the entitlements notification.
8268
+ */
8269
+ if (!didBlurContent) {
8270
+ switchView("meter");
8271
+ }
8252
8272
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
8253
8273
  switchView("newsletter");
8254
8274
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
@@ -8852,6 +8872,7 @@ const GET_STATES_SUCCESS = "GET_STATES_SUCCESS";
8852
8872
  const GET_STATES_FETCH = "GET_STATES_FETCH";
8853
8873
  const HANDLE_SUBMIT = "HANDLE_SUBMIT";
8854
8874
  const SET_UPDATED_PRICE = "SET_UPDATED_PRICE";
8875
+ const SET_TAX_AMOUNT = "SET_TAX_AMOUNT";
8855
8876
  const SET_CAN_MAKE_PAYMENT = "SET_CAN_MAKE_PAYMENT";
8856
8877
  const SET_PAYMENT_REQUEST = "SET_PAYMENT_REQUEST";
8857
8878
  const INIT_CONTAINER = "INIT_CONTAINER";
@@ -8880,6 +8901,9 @@ const SET_IMAGE_SRC = "SET_IMAGE_SRC";
8880
8901
  const PASSWORD_CHANGE_SUCCESS = "PASSWORD_CHANGE_SUCCESS";
8881
8902
  const SELECT_PAYMENT_METHOD = "SELECT_PAYMENT_METHOD";
8882
8903
  const LOAD_PAYMENT_METHODS = "LOAD_PAYMENT_METHODS";
8904
+ const GET_NEWSLETTERS_FETCH = "GET_NEWSLETTERS_FETCH";
8905
+ const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
8906
+ const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
8883
8907
 
8884
8908
  /**
8885
8909
  * Extracts error message from the response error object
@@ -8941,7 +8965,7 @@ const debounce = (func, waitTime) => {
8941
8965
  };
8942
8966
  };
8943
8967
 
8944
- const initialState$e = {
8968
+ const initialState$f = {
8945
8969
  email: "",
8946
8970
  password: "",
8947
8971
  emailError: null,
@@ -8952,10 +8976,10 @@ const initialState$e = {
8952
8976
  content: ""
8953
8977
  }
8954
8978
  };
8955
- const store$e = /*#__PURE__*/createContext(initialState$e);
8979
+ const store$f = /*#__PURE__*/createContext(initialState$f);
8956
8980
  const {
8957
- Provider: Provider$e
8958
- } = store$e;
8981
+ Provider: Provider$f
8982
+ } = store$f;
8959
8983
 
8960
8984
  const LoginContainer = ({
8961
8985
  style,
@@ -9062,7 +9086,7 @@ const LoginContainer = ({
9062
9086
  });
9063
9087
 
9064
9088
  case RESET_LOGIN_FORM:
9065
- return initialState$e;
9089
+ return initialState$f;
9066
9090
 
9067
9091
  case DISABLE_LOGIN_BUTTON:
9068
9092
  return lib_7({ ...state,
@@ -9080,12 +9104,12 @@ const LoginContainer = ({
9080
9104
  default:
9081
9105
  return state;
9082
9106
  }
9083
- }, initialState$e);
9107
+ }, initialState$f);
9084
9108
  return /*#__PURE__*/React__default.createElement("div", {
9085
9109
  style: { ...style
9086
9110
  },
9087
9111
  className: `pelcro-container pelcro-login-container ${className}`
9088
- }, /*#__PURE__*/React__default.createElement(Provider$e, {
9112
+ }, /*#__PURE__*/React__default.createElement(Provider$f, {
9089
9113
  value: {
9090
9114
  state,
9091
9115
  dispatch
@@ -9093,12 +9117,12 @@ const LoginContainer = ({
9093
9117
  }, children.length ? children.map((child, i) => {
9094
9118
  if (child) {
9095
9119
  return /*#__PURE__*/React__default.cloneElement(child, {
9096
- store: store$e,
9120
+ store: store$f,
9097
9121
  key: i
9098
9122
  });
9099
9123
  }
9100
9124
  }) : /*#__PURE__*/React__default.cloneElement(children, {
9101
- store: store$e
9125
+ store: store$f
9102
9126
  })));
9103
9127
  };
9104
9128
 
@@ -9343,7 +9367,7 @@ const LoginButton = ({
9343
9367
  buttonDisabled
9344
9368
  },
9345
9369
  dispatch
9346
- } = useContext(store$e);
9370
+ } = useContext(store$f);
9347
9371
  const {
9348
9372
  t
9349
9373
  } = useTranslation("login");
@@ -9364,23 +9388,23 @@ const LoginButton = ({
9364
9388
  };
9365
9389
 
9366
9390
  const LoginEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
9367
- store: store$e
9391
+ store: store$f
9368
9392
  }, props));
9369
9393
 
9370
9394
  const LoginPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
9371
- store: store$e
9395
+ store: store$f
9372
9396
  }, props));
9373
9397
 
9374
- var _path$l;
9398
+ var _path$m;
9375
9399
 
9376
- 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); }
9400
+ 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); }
9377
9401
 
9378
9402
  function SvgCheck(props) {
9379
- return /*#__PURE__*/React.createElement("svg", _extends$n({
9403
+ return /*#__PURE__*/React.createElement("svg", _extends$o({
9380
9404
  xmlns: "http://www.w3.org/2000/svg",
9381
9405
  fill: "currentColor",
9382
9406
  viewBox: "0 0 20 20"
9383
- }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
9407
+ }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
9384
9408
  fillRule: "evenodd",
9385
9409
  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",
9386
9410
  clipRule: "evenodd"
@@ -9445,7 +9469,7 @@ var facebookLoginRenderProps = createCommonjsModule(function (module, exports) {
9445
9469
  var FacebookLogin = unwrapExports(facebookLoginRenderProps);
9446
9470
  facebookLoginRenderProps.FacebookLogin;
9447
9471
 
9448
- const initialState$d = {
9472
+ const initialState$e = {
9449
9473
  email: "",
9450
9474
  password: "",
9451
9475
  emailError: null,
@@ -9462,10 +9486,10 @@ const initialState$d = {
9462
9486
  content: ""
9463
9487
  }
9464
9488
  };
9465
- const store$d = /*#__PURE__*/createContext(initialState$d);
9489
+ const store$e = /*#__PURE__*/createContext(initialState$e);
9466
9490
  const {
9467
- Provider: Provider$d
9468
- } = store$d;
9491
+ Provider: Provider$e
9492
+ } = store$e;
9469
9493
 
9470
9494
  const RegisterContainer = ({
9471
9495
  style,
@@ -9630,7 +9654,7 @@ const RegisterContainer = ({
9630
9654
  });
9631
9655
 
9632
9656
  case RESET_LOGIN_FORM:
9633
- return initialState$d;
9657
+ return initialState$e;
9634
9658
 
9635
9659
  case DISABLE_REGISTRATION_BUTTON:
9636
9660
  return lib_7({ ...state,
@@ -9648,12 +9672,12 @@ const RegisterContainer = ({
9648
9672
  default:
9649
9673
  return state;
9650
9674
  }
9651
- }, initialState$d);
9675
+ }, initialState$e);
9652
9676
  return /*#__PURE__*/React__default.createElement("div", {
9653
9677
  style: { ...style
9654
9678
  },
9655
9679
  className: `pelcro-container pelcro-register-container ${className}`
9656
- }, /*#__PURE__*/React__default.createElement(Provider$d, {
9680
+ }, /*#__PURE__*/React__default.createElement(Provider$e, {
9657
9681
  value: {
9658
9682
  state,
9659
9683
  dispatch
@@ -9661,24 +9685,24 @@ const RegisterContainer = ({
9661
9685
  }, children.length ? children.map((child, i) => {
9662
9686
  if (child) {
9663
9687
  return /*#__PURE__*/React__default.cloneElement(child, {
9664
- store: store$d,
9688
+ store: store$e,
9665
9689
  key: i
9666
9690
  });
9667
9691
  }
9668
9692
  }) : /*#__PURE__*/React__default.cloneElement(children, {
9669
- store: store$d
9693
+ store: store$e
9670
9694
  })));
9671
9695
  };
9672
9696
 
9673
- var _path$k;
9697
+ var _path$l;
9674
9698
 
9675
- 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); }
9699
+ 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); }
9676
9700
 
9677
9701
  function SvgFacebookLogo(props) {
9678
- return /*#__PURE__*/React.createElement("svg", _extends$m({
9702
+ return /*#__PURE__*/React.createElement("svg", _extends$n({
9679
9703
  xmlns: "http://www.w3.org/2000/svg",
9680
9704
  viewBox: "88.428 12.828 107.543 207.085"
9681
- }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
9705
+ }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
9682
9706
  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",
9683
9707
  fill: "#3c5a9a"
9684
9708
  })));
@@ -9695,10 +9719,10 @@ const FacebookLoginButton = ({
9695
9719
  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;
9696
9720
  const {
9697
9721
  dispatch: loginDispatch
9698
- } = useContext(store$e);
9722
+ } = useContext(store$f);
9699
9723
  const {
9700
9724
  dispatch: registerDispatch
9701
- } = useContext(store$d);
9725
+ } = useContext(store$e);
9702
9726
 
9703
9727
  const onSuccess = facebookUser => {
9704
9728
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
@@ -9751,15 +9775,15 @@ var googleLogin = createCommonjsModule(function (module, exports) {
9751
9775
  unwrapExports(googleLogin);
9752
9776
  var googleLogin_1 = googleLogin.GoogleLogin;
9753
9777
 
9754
- var _path$j, _path2$2, _path3$1, _path4;
9778
+ var _path$k, _path2$2, _path3$1, _path4;
9755
9779
 
9756
- 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); }
9780
+ 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); }
9757
9781
 
9758
9782
  function SvgGoogleLogo(props) {
9759
- return /*#__PURE__*/React.createElement("svg", _extends$l({
9783
+ return /*#__PURE__*/React.createElement("svg", _extends$m({
9760
9784
  viewBox: "0 0 24 24",
9761
9785
  xmlns: "http://www.w3.org/2000/svg"
9762
- }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
9786
+ }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
9763
9787
  fill: "#4285F4",
9764
9788
  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"
9765
9789
  })), _path2$2 || (_path2$2 = /*#__PURE__*/React.createElement("path", {
@@ -9785,10 +9809,10 @@ const GoogleLoginButton = ({
9785
9809
  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;
9786
9810
  const {
9787
9811
  dispatch: loginDispatch
9788
- } = useContext(store$e);
9812
+ } = useContext(store$f);
9789
9813
  const {
9790
9814
  dispatch: registerDispatch
9791
- } = useContext(store$d);
9815
+ } = useContext(store$e);
9792
9816
 
9793
9817
  const onSuccess = response => {
9794
9818
  var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
@@ -9893,15 +9917,15 @@ function LoginView(props) {
9893
9917
  }, /*#__PURE__*/React__default.createElement(GoogleLoginButton, null), /*#__PURE__*/React__default.createElement(FacebookLoginButton, null))))));
9894
9918
  }
9895
9919
 
9896
- var _path$i, _path2$1, _path3;
9920
+ var _path$j, _path2$1, _path3;
9897
9921
 
9898
- 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); }
9922
+ 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); }
9899
9923
 
9900
9924
  function SvgPelcroAuthorship(props) {
9901
- return /*#__PURE__*/React.createElement("svg", _extends$k({
9925
+ return /*#__PURE__*/React.createElement("svg", _extends$l({
9902
9926
  xmlns: "http://www.w3.org/2000/svg",
9903
9927
  viewBox: "0 -80.652 497.072 179.991"
9904
- }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
9928
+ }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
9905
9929
  fill: "none",
9906
9930
  stroke: "#4a4a4a",
9907
9931
  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"
@@ -10048,11 +10072,11 @@ function LoginModal({
10048
10072
  LoginModal.viewId = "login";
10049
10073
 
10050
10074
  const RegisterEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
10051
- store: store$d
10075
+ store: store$e
10052
10076
  }, props));
10053
10077
 
10054
10078
  const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
10055
- store: store$d
10079
+ store: store$e
10056
10080
  }, props));
10057
10081
 
10058
10082
  const RegisterButton = ({
@@ -10069,7 +10093,7 @@ const RegisterButton = ({
10069
10093
  buttonDisabled
10070
10094
  },
10071
10095
  dispatch
10072
- } = useContext(store$d);
10096
+ } = useContext(store$e);
10073
10097
  const {
10074
10098
  t
10075
10099
  } = useTranslation("register");
@@ -10204,7 +10228,7 @@ function FirstName({
10204
10228
  }
10205
10229
 
10206
10230
  const RegisterFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
10207
- store: store$d
10231
+ store: store$e
10208
10232
  }, props));
10209
10233
 
10210
10234
  function LastName({
@@ -10235,7 +10259,7 @@ function LastName({
10235
10259
  }
10236
10260
 
10237
10261
  const RegisterLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
10238
- store: store$d
10262
+ store: store$e
10239
10263
  }, props));
10240
10264
 
10241
10265
  /**
@@ -10339,7 +10363,7 @@ function TextInput({
10339
10363
 
10340
10364
  const RegisterTextInput = props => {
10341
10365
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
10342
- store: store$d
10366
+ store: store$e
10343
10367
  }));
10344
10368
  };
10345
10369
 
@@ -12304,13 +12328,14 @@ class PaypalGateWay {
12304
12328
  * @property {unknown} canMakePayment
12305
12329
  * @property {unknown} paymentRequest
12306
12330
  * @property {number} updatedPrice
12331
+ * @property {number} taxAmount
12307
12332
  * @property {object} currentPlan
12308
12333
  * @property {object} alert
12309
12334
  */
12310
12335
 
12311
12336
  /** @type {PaymentStateType} */
12312
12337
 
12313
- const initialState$c = {
12338
+ const initialState$d = {
12314
12339
  disableSubmit: false,
12315
12340
  isLoading: false,
12316
12341
  disableCouponButton: false,
@@ -12322,16 +12347,17 @@ const initialState$c = {
12322
12347
  canMakePayment: false,
12323
12348
  paymentRequest: null,
12324
12349
  updatedPrice: null,
12350
+ taxAmount: null,
12325
12351
  currentPlan: null,
12326
12352
  alert: {
12327
12353
  type: "error",
12328
12354
  content: ""
12329
12355
  }
12330
12356
  };
12331
- const store$c = /*#__PURE__*/createContext(initialState$c);
12357
+ const store$d = /*#__PURE__*/createContext(initialState$d);
12332
12358
  const {
12333
- Provider: Provider$c
12334
- } = store$c;
12359
+ Provider: Provider$d
12360
+ } = store$d;
12335
12361
 
12336
12362
  const PaymentMethodContainerWithoutStripe = ({
12337
12363
  style,
@@ -12372,6 +12398,7 @@ const PaymentMethodContainerWithoutStripe = ({
12372
12398
  dispatch({
12373
12399
  type: INIT_CONTAINER
12374
12400
  });
12401
+ updateTotalAmountWithTax();
12375
12402
  }, []);
12376
12403
 
12377
12404
  const initPaymentRequest = (state, dispatch) => {
@@ -12438,6 +12465,45 @@ const PaymentMethodContainerWithoutStripe = ({
12438
12465
  console.log("Google Pay/Apple pay isn't available in this country");
12439
12466
  }
12440
12467
  };
12468
+ /**
12469
+ * Updates the total amount after adding taxes only if site taxes are enabled
12470
+ */
12471
+
12472
+
12473
+ const updateTotalAmountWithTax = () => {
12474
+ var _window$Pelcro$site$r;
12475
+
12476
+ 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;
12477
+
12478
+ if (taxesEnabled && type === "createPayment") {
12479
+ dispatch({
12480
+ type: DISABLE_SUBMIT,
12481
+ payload: true
12482
+ });
12483
+ resolveTaxCalculation().then(res => {
12484
+ if (res) {
12485
+ dispatch({
12486
+ type: SET_TAX_AMOUNT,
12487
+ payload: res.taxAmount
12488
+ });
12489
+ dispatch({
12490
+ type: SET_UPDATED_PRICE,
12491
+ payload: res.totalAmountWithTax
12492
+ });
12493
+ dispatch({
12494
+ type: UPDATE_PAYMENT_REQUEST
12495
+ });
12496
+ }
12497
+ }).catch(error => {
12498
+ handlePaymentError(error);
12499
+ }).finally(() => {
12500
+ dispatch({
12501
+ type: DISABLE_SUBMIT,
12502
+ payload: false
12503
+ });
12504
+ });
12505
+ }
12506
+ };
12441
12507
 
12442
12508
  const onApplyCouponCode = (state, dispatch) => {
12443
12509
  const {
@@ -12464,6 +12530,10 @@ const PaymentMethodContainerWithoutStripe = ({
12464
12530
  });
12465
12531
  }
12466
12532
 
12533
+ dispatch({
12534
+ type: SET_COUPON_ERROR,
12535
+ payload: ""
12536
+ });
12467
12537
  dispatch({
12468
12538
  type: SHOW_ALERT,
12469
12539
  payload: {
@@ -12479,6 +12549,10 @@ const PaymentMethodContainerWithoutStripe = ({
12479
12549
  type: SET_PERCENT_OFF,
12480
12550
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
12481
12551
  });
12552
+ dispatch({
12553
+ type: SET_TAX_AMOUNT,
12554
+ payload: res.data.taxes
12555
+ });
12482
12556
  dispatch({
12483
12557
  type: SET_UPDATED_PRICE,
12484
12558
  payload: res.data.total
@@ -12488,6 +12562,29 @@ const PaymentMethodContainerWithoutStripe = ({
12488
12562
  });
12489
12563
  };
12490
12564
 
12565
+ if ((couponCode === null || couponCode === void 0 ? void 0 : couponCode.trim()) === "") {
12566
+ dispatch({
12567
+ type: SET_COUPON,
12568
+ payload: null
12569
+ });
12570
+ dispatch({
12571
+ type: SET_PERCENT_OFF,
12572
+ payload: ""
12573
+ });
12574
+ dispatch({
12575
+ type: SET_UPDATED_PRICE,
12576
+ payload: null
12577
+ });
12578
+ dispatch({
12579
+ type: SET_TAX_AMOUNT,
12580
+ payload: null
12581
+ });
12582
+ dispatch({
12583
+ type: UPDATE_PAYMENT_REQUEST
12584
+ });
12585
+ updateTotalAmountWithTax();
12586
+ }
12587
+
12491
12588
  if (couponCode !== null && couponCode !== void 0 && couponCode.trim()) {
12492
12589
  dispatch({
12493
12590
  type: DISABLE_COUPON_BUTTON,
@@ -12874,33 +12971,37 @@ const PaymentMethodContainerWithoutStripe = ({
12874
12971
  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();
12875
12972
 
12876
12973
  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) {
12877
- return resolveTaxCalculation().then(totalAmountWithTax => generate3DSecureSource(source, totalAmountWithTax !== null && totalAmountWithTax !== void 0 ? totalAmountWithTax : totalAmount).then(({
12878
- source,
12879
- error
12880
- }) => {
12881
- if (error) {
12882
- return handlePaymentError(error);
12883
- }
12884
-
12885
- toggleAuthenticationPendingView(true, source);
12886
- }));
12887
- }
12974
+ return resolveTaxCalculation().then(res => {
12975
+ var _res$totalAmountWithT;
12888
12976
 
12889
- return handlePayment(source);
12890
- }).catch(error => {
12891
- return handlePaymentError(error);
12892
- });
12977
+ return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
12978
+ source,
12979
+ error
12980
+ }) => {
12981
+ if (error) {
12982
+ return handlePaymentError(error);
12983
+ }
12984
+
12985
+ toggleAuthenticationPendingView(true, source);
12986
+ });
12987
+ });
12988
+ }
12989
+
12990
+ return handlePayment(source);
12991
+ }).catch(error => {
12992
+ return handlePaymentError(error);
12993
+ });
12893
12994
  };
12894
12995
  /**
12895
- * Resolves with the total including taxes incase taxes enabled by site
12996
+ * Resolves with the total & tax amount incase taxes enabled by site
12896
12997
  * @return {Promise}
12897
12998
  */
12898
12999
 
12899
13000
 
12900
13001
  const resolveTaxCalculation = () => {
12901
- var _window$Pelcro$site$r;
13002
+ var _window$Pelcro$site$r2;
12902
13003
 
12903
- 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;
13004
+ 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;
12904
13005
  return new Promise((resolve, reject) => {
12905
13006
  // resolve early if taxes isn't enabled
12906
13007
  if (!taxesEnabled) {
@@ -12913,14 +13014,18 @@ const PaymentMethodContainerWithoutStripe = ({
12913
13014
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
12914
13015
  address_id: selectedAddressId
12915
13016
  }, (error, res) => {
12916
- var _res$data;
13017
+ var _res$data, _res$data2;
12917
13018
 
12918
13019
  if (error) {
12919
13020
  return reject(error);
12920
13021
  }
12921
13022
 
12922
- const totalAmountWithTax = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.total;
12923
- resolve(totalAmountWithTax);
13023
+ const taxAmount = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.taxes;
13024
+ const totalAmountWithTax = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.total;
13025
+ resolve({
13026
+ totalAmountWithTax,
13027
+ taxAmount
13028
+ });
12924
13029
  });
12925
13030
  });
12926
13031
  };
@@ -12975,13 +13080,13 @@ const PaymentMethodContainerWithoutStripe = ({
12975
13080
  const handlePaymentError = error => {
12976
13081
  if (error.type === "validation_error" && // Subscription creation & renewal
12977
13082
  type === "createPayment") {
12978
- var _state$coupon;
13083
+ var _state$couponObject;
12979
13084
 
12980
13085
  const {
12981
13086
  updatedPrice
12982
13087
  } = state; // When price is 0, we allow submitting without card info
12983
13088
 
12984
- if (updatedPrice === 0 && ((_state$coupon = state.coupon) === null || _state$coupon === void 0 ? void 0 : _state$coupon.duration) === "forever") {
13089
+ if (updatedPrice === 0 && ((_state$couponObject = state.couponObject) === null || _state$couponObject === void 0 ? void 0 : _state$couponObject.duration) === "forever") {
12985
13090
  return subscribe({}, state, dispatch);
12986
13091
  }
12987
13092
  }
@@ -13109,6 +13214,11 @@ const PaymentMethodContainerWithoutStripe = ({
13109
13214
  updatedPrice: action.payload
13110
13215
  });
13111
13216
 
13217
+ case SET_TAX_AMOUNT:
13218
+ return lib_7({ ...state,
13219
+ taxAmount: action.payload
13220
+ });
13221
+
13112
13222
  case SET_CAN_MAKE_PAYMENT:
13113
13223
  return lib_7({ ...state,
13114
13224
  canMakePayment: action.payload
@@ -13126,7 +13236,7 @@ const PaymentMethodContainerWithoutStripe = ({
13126
13236
 
13127
13237
  case SET_COUPON:
13128
13238
  return lib_7({ ...state,
13129
- coupon: action.payload
13239
+ couponObject: action.payload
13130
13240
  });
13131
13241
 
13132
13242
  case SET_COUPON_ERROR:
@@ -13152,21 +13262,21 @@ const PaymentMethodContainerWithoutStripe = ({
13152
13262
  default:
13153
13263
  return state;
13154
13264
  }
13155
- }, initialState$c);
13265
+ }, initialState$d);
13156
13266
  return /*#__PURE__*/React__default.createElement("div", {
13157
13267
  style: { ...style
13158
13268
  },
13159
13269
  className: `pelcro-container pelcro-payment-container ${className}`
13160
- }, /*#__PURE__*/React__default.createElement(Provider$c, {
13270
+ }, /*#__PURE__*/React__default.createElement(Provider$d, {
13161
13271
  value: {
13162
13272
  state,
13163
13273
  dispatch
13164
13274
  }
13165
13275
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
13166
- store: store$c,
13276
+ store: store$d,
13167
13277
  key: i
13168
13278
  })) : /*#__PURE__*/React__default.cloneElement(children, {
13169
- store: store$c
13279
+ store: store$d
13170
13280
  })));
13171
13281
  };
13172
13282
 
@@ -13179,7 +13289,7 @@ const PaymentMethodContainer = props => {
13179
13289
  stripeAccount: window.Pelcro.site.read().account_id,
13180
13290
  locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13181
13291
  }, /*#__PURE__*/React__default.createElement(es_11, null, /*#__PURE__*/React__default.createElement(UnwrappedForm, Object.assign({
13182
- store: store$c
13292
+ store: store$d
13183
13293
  }, props))));
13184
13294
  }
13185
13295
 
@@ -13232,7 +13342,7 @@ const PelcroPaymentRequestButton = props => {
13232
13342
  currentPlan,
13233
13343
  updatedPrice
13234
13344
  }
13235
- } = useContext(store$c);
13345
+ } = useContext(store$d);
13236
13346
 
13237
13347
  const updatePaymentRequest = () => {
13238
13348
  // Make sure payment request is up to date, eg. user added a coupon code.
@@ -13285,9 +13395,10 @@ const DiscountedPrice = props => {
13285
13395
  const {
13286
13396
  state: {
13287
13397
  updatedPrice,
13398
+ taxAmount,
13288
13399
  percentOff
13289
13400
  }
13290
- } = useContext(store$c);
13401
+ } = useContext(store$d);
13291
13402
  const {
13292
13403
  default_locale
13293
13404
  } = Pelcro.site.read();
@@ -13297,12 +13408,15 @@ const DiscountedPrice = props => {
13297
13408
  } = usePelcro();
13298
13409
  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;
13299
13410
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13300
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : updatedPrice * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13411
+ const discountedPriceWithoutTax = updatedPrice - taxAmount;
13412
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13301
13413
 
13302
13414
  if (percentOff) {
13303
13415
  return /*#__PURE__*/React__default.createElement("div", Object.assign({
13304
- className: "plc-my-2"
13305
- }, props), "(-", percentOff, ") ", priceFormatted);
13416
+ className: "plc-flex plc-justify-center plc-mt-2 pelcro-discount"
13417
+ }, props), "(-", percentOff, ")", " ", /*#__PURE__*/React__default.createElement("span", {
13418
+ className: "plc-font-bold pelcro-discounted-price"
13419
+ }, priceFormatted));
13306
13420
  }
13307
13421
 
13308
13422
  return "";
@@ -13327,7 +13441,7 @@ const SubmitPaymentMethod = ({
13327
13441
  isLoading,
13328
13442
  updatedPrice
13329
13443
  }
13330
- } = useContext(store$c);
13444
+ } = useContext(store$d);
13331
13445
  const {
13332
13446
  default_locale
13333
13447
  } = Pelcro.site.read();
@@ -13351,17 +13465,17 @@ const SubmitPaymentMethod = ({
13351
13465
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
13352
13466
  };
13353
13467
 
13354
- var _path$h;
13468
+ var _path$i;
13355
13469
 
13356
- 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); }
13470
+ 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); }
13357
13471
 
13358
13472
  function SvgArrowLeft(props) {
13359
- return /*#__PURE__*/React.createElement("svg", _extends$j({
13473
+ return /*#__PURE__*/React.createElement("svg", _extends$k({
13360
13474
  xmlns: "http://www.w3.org/2000/svg",
13361
13475
  fill: "none",
13362
13476
  viewBox: "0 0 24 24",
13363
13477
  stroke: "currentColor"
13364
- }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
13478
+ }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
13365
13479
  strokeLinecap: "round",
13366
13480
  strokeLinejoin: "round",
13367
13481
  strokeWidth: 2,
@@ -13380,7 +13494,7 @@ const ApplyCouponButton = ({
13380
13494
  disableCouponButton
13381
13495
  },
13382
13496
  dispatch
13383
- } = useContext(store$c);
13497
+ } = useContext(store$d);
13384
13498
  const {
13385
13499
  t
13386
13500
  } = useTranslation("checkoutForm");
@@ -13414,7 +13528,7 @@ const CouponCodeField = props => {
13414
13528
  couponCode,
13415
13529
  couponError
13416
13530
  }
13417
- } = useContext(store$c);
13531
+ } = useContext(store$d);
13418
13532
 
13419
13533
  const onCouponCodeChange = e => {
13420
13534
  dispatch({
@@ -13432,6 +13546,7 @@ const CouponCodeField = props => {
13432
13546
 
13433
13547
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({
13434
13548
  className: "plc-h-12",
13549
+ wrapperClassName: "plc-mb-1",
13435
13550
  errorClassName: "plc-h-12 sm:plc-h-8",
13436
13551
  error: couponError,
13437
13552
  "aria-label": t("labels.code"),
@@ -13442,17 +13557,17 @@ const CouponCodeField = props => {
13442
13557
  }, props));
13443
13558
  };
13444
13559
 
13445
- var _path$g;
13560
+ var _path$h;
13446
13561
 
13447
- 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); }
13562
+ 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); }
13448
13563
 
13449
13564
  function SvgTicket(props) {
13450
- return /*#__PURE__*/React.createElement("svg", _extends$i({
13565
+ return /*#__PURE__*/React.createElement("svg", _extends$j({
13451
13566
  xmlns: "http://www.w3.org/2000/svg",
13452
13567
  fill: "none",
13453
13568
  viewBox: "0 0 24 24",
13454
13569
  stroke: "currentColor"
13455
- }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
13570
+ }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
13456
13571
  strokeLinecap: "round",
13457
13572
  strokeLinejoin: "round",
13458
13573
  strokeWidth: 2,
@@ -13469,7 +13584,7 @@ const CouponCode = ({
13469
13584
  state: {
13470
13585
  enableCouponField
13471
13586
  }
13472
- } = useContext(store$c);
13587
+ } = useContext(store$d);
13473
13588
  const {
13474
13589
  t
13475
13590
  } = useTranslation("checkoutForm");
@@ -13483,16 +13598,16 @@ const CouponCode = ({
13483
13598
  };
13484
13599
 
13485
13600
  return /*#__PURE__*/React__default.createElement("div", {
13486
- className: "plc-my-4"
13601
+ className: "plc-mt-4"
13487
13602
  }, /*#__PURE__*/React__default.createElement(Button, Object.assign({
13488
- className: "plc-text-base plc-text-gray-500",
13603
+ className: "plc-mb-2 plc-text-base plc-text-gray-500",
13489
13604
  variant: "ghost",
13490
13605
  icon: /*#__PURE__*/React__default.createElement(SvgTicket, {
13491
13606
  className: "plc-w-5 plc-h-5 plc-mr-2"
13492
13607
  }),
13493
13608
  onClick: showCouponField
13494
13609
  }, otherProps), !enableCouponField ? t("labels.addCode") : t("labels.hideCode")), enableCouponField && /*#__PURE__*/React__default.createElement("div", {
13495
- className: "plc-flex plc-w-full plc-my-4 pelcro-apply-coupon-wrapper"
13610
+ className: "plc-flex plc-w-full plc-mt-2 pelcro-apply-coupon-wrapper"
13496
13611
  }, /*#__PURE__*/React__default.createElement(CouponCodeField, null), /*#__PURE__*/React__default.createElement(ApplyCouponButton, null)));
13497
13612
  };
13498
13613
 
@@ -13726,7 +13841,7 @@ const PaypalSubscribeButton = props => {
13726
13841
  const {
13727
13842
  dispatch,
13728
13843
  state
13729
- } = useContext(store$c);
13844
+ } = useContext(store$d);
13730
13845
  const {
13731
13846
  product,
13732
13847
  plan,
@@ -13811,16 +13926,16 @@ const BankRedirection = () => {
13811
13926
  }));
13812
13927
  };
13813
13928
 
13814
- var _path$f;
13929
+ var _path$g;
13815
13930
 
13816
- 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); }
13931
+ 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); }
13817
13932
 
13818
13933
  function SvgLock(props) {
13819
- return /*#__PURE__*/React.createElement("svg", _extends$h({
13934
+ return /*#__PURE__*/React.createElement("svg", _extends$i({
13820
13935
  xmlns: "http://www.w3.org/2000/svg",
13821
13936
  viewBox: "0 0 20 20",
13822
13937
  fill: "currentColor"
13823
- }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
13938
+ }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
13824
13939
  fillRule: "evenodd",
13825
13940
  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",
13826
13941
  clipRule: "evenodd"
@@ -13837,7 +13952,7 @@ const SelectedPaymentMethod = () => {
13837
13952
  state: {
13838
13953
  isLoading
13839
13954
  }
13840
- } = useContext(store$c);
13955
+ } = useContext(store$d);
13841
13956
  const {
13842
13957
  switchView,
13843
13958
  selectedPaymentMethodId
@@ -13869,6 +13984,37 @@ const SelectedPaymentMethod = () => {
13869
13984
  }, t("select.buttons.changePaymentMethod")))));
13870
13985
  };
13871
13986
 
13987
+ const TaxAmount = () => {
13988
+ var _plan$quantity;
13989
+
13990
+ const {
13991
+ t
13992
+ } = useTranslation("checkoutForm");
13993
+ const {
13994
+ state: {
13995
+ taxAmount
13996
+ }
13997
+ } = useContext(store$d);
13998
+ const {
13999
+ default_locale
14000
+ } = Pelcro.site.read();
14001
+ const {
14002
+ plan
14003
+ } = usePelcro();
14004
+ const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14005
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14006
+
14007
+ if (taxAmount) {
14008
+ return /*#__PURE__*/React__default.createElement("div", {
14009
+ className: "plc-text-center pelcro-tax-amount"
14010
+ }, t("labels.tax"), " ", /*#__PURE__*/React__default.createElement("span", {
14011
+ className: "plc-font-bold"
14012
+ }, priceFormatted));
14013
+ }
14014
+
14015
+ return null;
14016
+ };
14017
+
13872
14018
  /**
13873
14019
  *
13874
14020
  */
@@ -13905,7 +14051,9 @@ function PaymentMethodView({
13905
14051
  onFailure: onFailure
13906
14052
  }, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(AlertWithContext, {
13907
14053
  className: "plc-mb-2"
13908
- }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement("div", {
14054
+ }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement("div", {
14055
+ className: "plc-mb-2"
14056
+ }, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
13909
14057
  className: "plc-grid plc-mt-4 plc-gap-y-2"
13910
14058
  }, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)))))));
13911
14059
  }
@@ -14012,12 +14160,12 @@ function SubscriptionRenewModal({
14012
14160
  }
14013
14161
  SubscriptionRenewModal.viewId = "subscription-renew";
14014
14162
 
14015
- var _path$e;
14163
+ var _path$f;
14016
14164
 
14017
- 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); }
14165
+ 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); }
14018
14166
 
14019
14167
  function SvgGift(props) {
14020
- return /*#__PURE__*/React.createElement("svg", _extends$g({
14168
+ return /*#__PURE__*/React.createElement("svg", _extends$h({
14021
14169
  className: "plc-w-6 plc-h-6 plc-mr-2",
14022
14170
  fill: "none",
14023
14171
  stroke: "currentColor",
@@ -14026,7 +14174,7 @@ function SvgGift(props) {
14026
14174
  strokeWidth: 2,
14027
14175
  viewBox: "0 0 24 24",
14028
14176
  xmlns: "http://www.w3.org/2000/svg"
14029
- }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
14177
+ }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
14030
14178
  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"
14031
14179
  })));
14032
14180
  }
@@ -14357,6 +14505,292 @@ class DefaultNewsLetter extends Component {
14357
14505
 
14358
14506
  const NewsLetter = withTranslation("newsletter")(DefaultNewsLetter);
14359
14507
 
14508
+ const initialState$c = {
14509
+ didSubToNewslettersBefore: false,
14510
+ newsletters: [],
14511
+ isListLoading: true,
14512
+ isSubmitting: false,
14513
+ alert: {
14514
+ type: "error",
14515
+ content: ""
14516
+ }
14517
+ };
14518
+ const store$c = /*#__PURE__*/createContext(initialState$c);
14519
+ const {
14520
+ Provider: Provider$c
14521
+ } = store$c;
14522
+
14523
+ const NewsletterUpdateContainer = ({
14524
+ style,
14525
+ className = "",
14526
+ onSuccess = () => {},
14527
+ onFailure = () => {},
14528
+ children
14529
+ }) => {
14530
+ const [t] = useTranslation("newsletter");
14531
+
14532
+ const handleSubmit = ({
14533
+ newsletters,
14534
+ didSubToNewslettersBefore
14535
+ }, dispatch) => {
14536
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2;
14537
+
14538
+ const callback = (err, res) => {
14539
+ dispatch({
14540
+ type: LOADING,
14541
+ payload: false
14542
+ });
14543
+
14544
+ if (err) {
14545
+ dispatch({
14546
+ type: SHOW_ALERT,
14547
+ payload: {
14548
+ type: "error",
14549
+ content: getErrorMessages(err)
14550
+ }
14551
+ });
14552
+ onFailure(err);
14553
+ } else {
14554
+ if (!didSubToNewslettersBefore) {
14555
+ dispatch({
14556
+ type: SWITCH_TO_UPDATE
14557
+ });
14558
+ }
14559
+
14560
+ dispatch({
14561
+ type: SHOW_ALERT,
14562
+ payload: {
14563
+ type: "success",
14564
+ content: t("messages.success")
14565
+ }
14566
+ });
14567
+ onSuccess(res);
14568
+ }
14569
+ };
14570
+
14571
+ const requestData = {
14572
+ 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"),
14573
+ source: "web",
14574
+ lists: newsletters.filter(newsletter => newsletter.selected).map(newsletter => newsletter.id).join(",")
14575
+ };
14576
+
14577
+ if (didSubToNewslettersBefore) {
14578
+ window.Pelcro.newsletter.update(requestData, callback);
14579
+ } else {
14580
+ window.Pelcro.newsletter.create(requestData, callback);
14581
+ }
14582
+ };
14583
+
14584
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
14585
+ switch (action.type) {
14586
+ case GET_NEWSLETTERS_FETCH:
14587
+ return lib_7({ ...state,
14588
+ isListLoading: true
14589
+ });
14590
+
14591
+ case GET_NEWSLETTERS_SUCCESS:
14592
+ return lib_7({ ...state,
14593
+ newsletters: action.payload.newsletters,
14594
+ didSubToNewslettersBefore: action.payload.didSubToNewslettersBefore,
14595
+ isListLoading: false
14596
+ });
14597
+
14598
+ case SET_SELECT:
14599
+ return lib_7({ ...state,
14600
+ newsletters: state.newsletters.map(newsletter => {
14601
+ if (newsletter.id === action.payload) {
14602
+ return { ...newsletter,
14603
+ selected: !newsletter.selected
14604
+ };
14605
+ }
14606
+
14607
+ return newsletter;
14608
+ })
14609
+ });
14610
+
14611
+ case SWITCH_TO_UPDATE:
14612
+ return lib_7({ ...state,
14613
+ didSubToNewslettersBefore: true
14614
+ });
14615
+
14616
+ case SHOW_ALERT:
14617
+ return lib_7({ ...state,
14618
+ alert: action.payload
14619
+ });
14620
+
14621
+ case LOADING:
14622
+ return lib_7({ ...state,
14623
+ isSubmitting: action.payload
14624
+ });
14625
+
14626
+ case HANDLE_SUBMIT:
14627
+ return lib_5({ ...state,
14628
+ isSubmitting: true
14629
+ }, (state, dispatch) => handleSubmit(state, dispatch));
14630
+
14631
+ default:
14632
+ return state;
14633
+ }
14634
+ }, initialState$c);
14635
+ useEffect(() => {
14636
+ const getUserNewsletters = () => {
14637
+ var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
14638
+
14639
+ dispatch({
14640
+ type: GET_NEWSLETTERS_FETCH
14641
+ });
14642
+ 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");
14643
+ window.Pelcro.newsletter.getByEmail(email, (err, res) => {
14644
+ var _window$Pelcro$uiSett, _window$Pelcro, _window$Pelcro$uiSett2, _res$data$lists$split, _res$data$lists;
14645
+
14646
+ if (err) {
14647
+ return dispatch({
14648
+ type: SHOW_ALERT,
14649
+ payload: {
14650
+ type: "error",
14651
+ content: getErrorMessages(err)
14652
+ }
14653
+ });
14654
+ }
14655
+
14656
+ 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 : [];
14657
+ 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 : [];
14658
+ const allNewslettersWithSelectedField = newsletters.map(newsletter => ({ ...newsletter,
14659
+ id: String(newsletter.id),
14660
+ selected: selectedNewsletters.includes(String(newsletter.id))
14661
+ }));
14662
+ dispatch({
14663
+ type: GET_NEWSLETTERS_SUCCESS,
14664
+ payload: {
14665
+ newsletters: allNewslettersWithSelectedField,
14666
+ didSubToNewslettersBefore: Boolean(res.data.email)
14667
+ }
14668
+ });
14669
+ });
14670
+ };
14671
+
14672
+ getUserNewsletters();
14673
+ }, []);
14674
+ return /*#__PURE__*/React__default.createElement("div", {
14675
+ style: { ...style
14676
+ },
14677
+ className: `pelcro-container pelcro-newsletter-update-container ${className}`
14678
+ }, /*#__PURE__*/React__default.createElement(Provider$c, {
14679
+ value: {
14680
+ state,
14681
+ dispatch
14682
+ }
14683
+ }, children.length ? children.map((child, i) => {
14684
+ if (child) {
14685
+ return /*#__PURE__*/React__default.cloneElement(child, {
14686
+ store: store$c,
14687
+ key: i
14688
+ });
14689
+ }
14690
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
14691
+ store: store$c
14692
+ })));
14693
+ };
14694
+
14695
+ const NewsletterUpdateButton = ({
14696
+ name,
14697
+ onClick,
14698
+ ...otherProps
14699
+ }) => {
14700
+ const {
14701
+ dispatch,
14702
+ state: {
14703
+ isSubmitting,
14704
+ isListLoading
14705
+ }
14706
+ } = useContext(store$c);
14707
+ const {
14708
+ t
14709
+ } = useTranslation("newsletter");
14710
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
14711
+ onClick: () => {
14712
+ dispatch({
14713
+ type: HANDLE_SUBMIT
14714
+ });
14715
+ onClick === null || onClick === void 0 ? void 0 : onClick();
14716
+ },
14717
+ disabled: isListLoading,
14718
+ isLoading: isSubmitting
14719
+ }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
14720
+ };
14721
+
14722
+ const NewsletterUpdateList = () => {
14723
+ const handleSelectNewsletter = event => {
14724
+ dispatch({
14725
+ type: SET_SELECT,
14726
+ payload: event.target.value
14727
+ });
14728
+ };
14729
+
14730
+ const {
14731
+ dispatch,
14732
+ state: {
14733
+ newsletters,
14734
+ isListLoading
14735
+ }
14736
+ } = useContext(store$c);
14737
+
14738
+ if (isListLoading) {
14739
+ return /*#__PURE__*/React__default.createElement(Loader, {
14740
+ width: 60,
14741
+ height: 100
14742
+ });
14743
+ }
14744
+
14745
+ return /*#__PURE__*/React__default.createElement("div", {
14746
+ className: "plc-max-h-80 plc-overflow-y-auto pelcro-newsletters-wrapper"
14747
+ }, newsletters.map(newsletter => /*#__PURE__*/React__default.createElement("div", {
14748
+ key: newsletter.id,
14749
+ 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"
14750
+ }, /*#__PURE__*/React__default.createElement(Checkbox, {
14751
+ className: "pelcro-select-newsletter-checkbox",
14752
+ labelClassName: "plc-cursor-pointer plc-w-full",
14753
+ id: `pelcro-newsletter-update-${newsletter.id}`,
14754
+ checked: newsletter.selected,
14755
+ value: newsletter.id,
14756
+ onChange: handleSelectNewsletter
14757
+ }, newsletter.label))));
14758
+ };
14759
+
14760
+ const NewsletterUpdateView = props => {
14761
+ const {
14762
+ t
14763
+ } = useTranslation("newsletter");
14764
+ return /*#__PURE__*/React__default.createElement("div", {
14765
+ id: "pelcro-newsletter-update-view"
14766
+ }, /*#__PURE__*/React__default.createElement("div", {
14767
+ className: "plc-mb-6 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
14768
+ }, /*#__PURE__*/React__default.createElement("h4", {
14769
+ className: "plc-text-2xl plc-font-semibold"
14770
+ }, t("updateTitle"))), /*#__PURE__*/React__default.createElement("form", {
14771
+ action: "javascript:void(0);",
14772
+ className: "plc-mt-2 pelcro-form"
14773
+ }, /*#__PURE__*/React__default.createElement(NewsletterUpdateContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), /*#__PURE__*/React__default.createElement(NewsletterUpdateList, null), /*#__PURE__*/React__default.createElement(NewsletterUpdateButton, {
14774
+ role: "submit",
14775
+ className: "plc-mt-4 plc-w-full",
14776
+ name: t("labels.submit"),
14777
+ id: "pelcro-submit"
14778
+ }))));
14779
+ };
14780
+
14781
+ const NewsletterUpdateModal = ({
14782
+ onDisplay,
14783
+ onClose,
14784
+ ...otherProps
14785
+ }) => {
14786
+ return /*#__PURE__*/React__default.createElement(Modal, {
14787
+ id: "pelcro-newsletter-update-modal",
14788
+ onDisplay: onDisplay,
14789
+ onClose: onClose
14790
+ }, /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(NewsletterUpdateView, otherProps)), /*#__PURE__*/React__default.createElement(ModalFooter, null, /*#__PURE__*/React__default.createElement(Authorship, null)));
14791
+ };
14792
+ NewsletterUpdateModal.viewId = "newsletter-update";
14793
+
14360
14794
  const MeterView = () => {
14361
14795
  var _paywallProduct$paywa, _paywallProduct$paywa2;
14362
14796
 
@@ -14408,7 +14842,7 @@ const MeterModal = props => {
14408
14842
  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"
14409
14843
  }, /*#__PURE__*/React__default.createElement("button", {
14410
14844
  type: "button",
14411
- className: "plc-absolute plc-top-0 plc-text-2xl plc-text-gray-500 plc-right-1 pelcro-close-btn",
14845
+ 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",
14412
14846
  "aria-label": "Close",
14413
14847
  onClick: onClose
14414
14848
  }, /*#__PURE__*/React__default.createElement("span", null, "\xD7")), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(MeterView, props)));
@@ -14744,17 +15178,17 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default.createElement(Phone
14744
15178
 
14745
15179
  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";
14746
15180
 
14747
- var _path$d;
15181
+ var _path$e;
14748
15182
 
14749
- 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); }
15183
+ 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); }
14750
15184
 
14751
15185
  function SvgEdit(props) {
14752
- return /*#__PURE__*/React.createElement("svg", _extends$f({
15186
+ return /*#__PURE__*/React.createElement("svg", _extends$g({
14753
15187
  className: "plc-w-6 plc-h-6",
14754
15188
  xmlns: "http://www.w3.org/2000/svg",
14755
15189
  viewBox: "0 0 20 20",
14756
15190
  fill: "currentColor"
14757
- }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
15191
+ }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
14758
15192
  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"
14759
15193
  })));
14760
15194
  }
@@ -17865,18 +18299,18 @@ const GiftCreateLastName = props => /*#__PURE__*/React__default.createElement(La
17865
18299
  store: store$4
17866
18300
  }, props));
17867
18301
 
17868
- var _path$c;
18302
+ var _path$d;
17869
18303
 
17870
- 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); }
18304
+ 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); }
17871
18305
 
17872
18306
  function SvgInfoCircle(props) {
17873
- return /*#__PURE__*/React.createElement("svg", _extends$e({
18307
+ return /*#__PURE__*/React.createElement("svg", _extends$f({
17874
18308
  xmlns: "http://www.w3.org/2000/svg",
17875
18309
  className: "plc-w-5 plc-h-5",
17876
18310
  fill: "none",
17877
18311
  viewBox: "0 0 24 24",
17878
18312
  stroke: "currentColor"
17879
- }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
18313
+ }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
17880
18314
  strokeLinecap: "round",
17881
18315
  strokeLinejoin: "round",
17882
18316
  strokeWidth: 2,
@@ -18863,8 +19297,8 @@ const PaymentMethodSelectModal = ({
18863
19297
  };
18864
19298
  PaymentMethodSelectModal.viewId = "payment-method-select";
18865
19299
 
18866
- function _extends$d() {
18867
- _extends$d = Object.assign || function (target) {
19300
+ function _extends$e() {
19301
+ _extends$e = Object.assign || function (target) {
18868
19302
  for (var i = 1; i < arguments.length; i++) {
18869
19303
  var source = arguments[i];
18870
19304
 
@@ -18878,7 +19312,7 @@ function _extends$d() {
18878
19312
  return target;
18879
19313
  };
18880
19314
 
18881
- return _extends$d.apply(this, arguments);
19315
+ return _extends$e.apply(this, arguments);
18882
19316
  }
18883
19317
 
18884
19318
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -19062,7 +19496,7 @@ function render(props, propsBag, defaultTag, features, visible) {
19062
19496
  return match(strategy, (_match = {}, _match[RenderStrategy.Unmount] = function () {
19063
19497
  return null;
19064
19498
  }, _match[RenderStrategy.Hidden] = function () {
19065
- return _render(_extends$d({}, _rest, {
19499
+ return _render(_extends$e({}, _rest, {
19066
19500
  hidden: true,
19067
19501
  style: {
19068
19502
  display: 'none'
@@ -19590,7 +20024,7 @@ function TransitionChild(props) {
19590
20024
  var passthroughProps = rest;
19591
20025
  return React__default.createElement(NestingContext.Provider, {
19592
20026
  value: nesting
19593
- }, render(_extends$d({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
20027
+ }, render(_extends$e({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
19594
20028
  }
19595
20029
 
19596
20030
  function Transition(props) {
@@ -19634,7 +20068,7 @@ function Transition(props) {
19634
20068
  value: nestingBag
19635
20069
  }, React__default.createElement(TransitionContext.Provider, {
19636
20070
  value: transitionBag
19637
- }, render(_extends$d({}, sharedProps, {
20071
+ }, render(_extends$e({}, sharedProps, {
19638
20072
  as: Fragment,
19639
20073
  children: React__default.createElement(TransitionChild, Object.assign({}, sharedProps, passthroughProps))
19640
20074
  }), propsBag, Fragment, TransitionChildRenderFeatures, state === TreeStates.Visible)));
@@ -19761,12 +20195,12 @@ var ActionTypes;
19761
20195
  })(ActionTypes || (ActionTypes = {}));
19762
20196
 
19763
20197
  (_reducers = {}, _reducers[ActionTypes.CloseMenu] = function (state) {
19764
- return _extends$d({}, state, {
20198
+ return _extends$e({}, state, {
19765
20199
  activeItemIndex: null,
19766
20200
  menuState: MenuStates.Closed
19767
20201
  });
19768
20202
  }, _reducers[ActionTypes.OpenMenu] = function (state) {
19769
- return _extends$d({}, state, {
20203
+ return _extends$e({}, state, {
19770
20204
  menuState: MenuStates.Open
19771
20205
  });
19772
20206
  }, _reducers[ActionTypes.GoToItem] = function (state, action) {
@@ -19785,7 +20219,7 @@ var ActionTypes;
19785
20219
  }
19786
20220
  });
19787
20221
  if (state.searchQuery === '' && state.activeItemIndex === activeItemIndex) return state;
19788
- return _extends$d({}, state, {
20222
+ return _extends$e({}, state, {
19789
20223
  searchQuery: '',
19790
20224
  activeItemIndex: activeItemIndex
19791
20225
  });
@@ -19796,19 +20230,19 @@ var ActionTypes;
19796
20230
 
19797
20231
  return ((_item$dataRef$current = item.dataRef.current.textValue) == null ? void 0 : _item$dataRef$current.startsWith(searchQuery)) && !item.dataRef.current.disabled;
19798
20232
  });
19799
- if (match === -1 || match === state.activeItemIndex) return _extends$d({}, state, {
20233
+ if (match === -1 || match === state.activeItemIndex) return _extends$e({}, state, {
19800
20234
  searchQuery: searchQuery
19801
20235
  });
19802
- return _extends$d({}, state, {
20236
+ return _extends$e({}, state, {
19803
20237
  searchQuery: searchQuery,
19804
20238
  activeItemIndex: match
19805
20239
  });
19806
20240
  }, _reducers[ActionTypes.ClearSearch] = function (state) {
19807
- return _extends$d({}, state, {
20241
+ return _extends$e({}, state, {
19808
20242
  searchQuery: ''
19809
20243
  });
19810
20244
  }, _reducers[ActionTypes.RegisterItem] = function (state, action) {
19811
- return _extends$d({}, state, {
20245
+ return _extends$e({}, state, {
19812
20246
  items: [].concat(state.items, [{
19813
20247
  id: action.id,
19814
20248
  dataRef: action.dataRef
@@ -19821,7 +20255,7 @@ var ActionTypes;
19821
20255
  return a.id === action.id;
19822
20256
  });
19823
20257
  if (idx !== -1) nextItems.splice(idx, 1);
19824
- return _extends$d({}, state, {
20258
+ return _extends$e({}, state, {
19825
20259
  items: nextItems,
19826
20260
  activeItemIndex: function () {
19827
20261
  if (idx === state.activeItemIndex) return null;
@@ -19860,19 +20294,19 @@ var ActionTypes$1;
19860
20294
  (_reducers$1 = {}, _reducers$1[ActionTypes$1.CloseListbox] = function (state) {
19861
20295
  if (state.disabled) return state;
19862
20296
  if (state.listboxState === ListboxStates.Closed) return state;
19863
- return _extends$d({}, state, {
20297
+ return _extends$e({}, state, {
19864
20298
  activeOptionIndex: null,
19865
20299
  listboxState: ListboxStates.Closed
19866
20300
  });
19867
20301
  }, _reducers$1[ActionTypes$1.OpenListbox] = function (state) {
19868
20302
  if (state.disabled) return state;
19869
20303
  if (state.listboxState === ListboxStates.Open) return state;
19870
- return _extends$d({}, state, {
20304
+ return _extends$e({}, state, {
19871
20305
  listboxState: ListboxStates.Open
19872
20306
  });
19873
20307
  }, _reducers$1[ActionTypes$1.SetDisabled] = function (state, action) {
19874
20308
  if (state.disabled === action.disabled) return state;
19875
- return _extends$d({}, state, {
20309
+ return _extends$e({}, state, {
19876
20310
  disabled: action.disabled
19877
20311
  });
19878
20312
  }, _reducers$1[ActionTypes$1.GoToOption] = function (state, action) {
@@ -19893,7 +20327,7 @@ var ActionTypes$1;
19893
20327
  }
19894
20328
  });
19895
20329
  if (state.searchQuery === '' && state.activeOptionIndex === activeOptionIndex) return state;
19896
- return _extends$d({}, state, {
20330
+ return _extends$e({}, state, {
19897
20331
  searchQuery: '',
19898
20332
  activeOptionIndex: activeOptionIndex
19899
20333
  });
@@ -19906,10 +20340,10 @@ var ActionTypes$1;
19906
20340
 
19907
20341
  return !option.dataRef.current.disabled && ((_option$dataRef$curre = option.dataRef.current.textValue) == null ? void 0 : _option$dataRef$curre.startsWith(searchQuery));
19908
20342
  });
19909
- if (match === -1 || match === state.activeOptionIndex) return _extends$d({}, state, {
20343
+ if (match === -1 || match === state.activeOptionIndex) return _extends$e({}, state, {
19910
20344
  searchQuery: searchQuery
19911
20345
  });
19912
- return _extends$d({}, state, {
20346
+ return _extends$e({}, state, {
19913
20347
  searchQuery: searchQuery,
19914
20348
  activeOptionIndex: match
19915
20349
  });
@@ -19917,11 +20351,11 @@ var ActionTypes$1;
19917
20351
  if (state.disabled) return state;
19918
20352
  if (state.listboxState === ListboxStates.Closed) return state;
19919
20353
  if (state.searchQuery === '') return state;
19920
- return _extends$d({}, state, {
20354
+ return _extends$e({}, state, {
19921
20355
  searchQuery: ''
19922
20356
  });
19923
20357
  }, _reducers$1[ActionTypes$1.RegisterOption] = function (state, action) {
19924
- return _extends$d({}, state, {
20358
+ return _extends$e({}, state, {
19925
20359
  options: [].concat(state.options, [{
19926
20360
  id: action.id,
19927
20361
  dataRef: action.dataRef
@@ -19934,7 +20368,7 @@ var ActionTypes$1;
19934
20368
  return a.id === action.id;
19935
20369
  });
19936
20370
  if (idx !== -1) nextOptions.splice(idx, 1);
19937
- return _extends$d({}, state, {
20371
+ return _extends$e({}, state, {
19938
20372
  options: nextOptions,
19939
20373
  activeOptionIndex: function () {
19940
20374
  if (idx === state.activeOptionIndex) return null;
@@ -19995,18 +20429,18 @@ const getPaymentCardIcon = name => {
19995
20429
  }));
19996
20430
  };
19997
20431
 
19998
- var _path$b;
20432
+ var _path$c;
19999
20433
 
20000
- 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); }
20434
+ 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); }
20001
20435
 
20002
20436
  function SvgChevronRight(props) {
20003
- return /*#__PURE__*/React.createElement("svg", _extends$c({
20437
+ return /*#__PURE__*/React.createElement("svg", _extends$d({
20004
20438
  className: "plc-w-6 plc-h-6",
20005
20439
  xmlns: "http://www.w3.org/2000/svg",
20006
20440
  fill: "none",
20007
20441
  viewBox: "0 0 24 24",
20008
20442
  stroke: "currentColor"
20009
- }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
20443
+ }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
20010
20444
  strokeLinecap: "round",
20011
20445
  strokeLinejoin: "round",
20012
20446
  strokeWidth: 2,
@@ -20305,18 +20739,18 @@ Accordion.item = function AccordionItem({
20305
20739
  }, content)) : null;
20306
20740
  };
20307
20741
 
20308
- var _path$a;
20742
+ var _path$b;
20309
20743
 
20310
- 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); }
20744
+ 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); }
20311
20745
 
20312
20746
  function SvgExit(props) {
20313
- return /*#__PURE__*/React.createElement("svg", _extends$b({
20747
+ return /*#__PURE__*/React.createElement("svg", _extends$c({
20314
20748
  className: "plc-w-6 plc-h-6",
20315
20749
  xmlns: "http://www.w3.org/2000/svg",
20316
20750
  fill: "none",
20317
20751
  viewBox: "0 0 24 24",
20318
20752
  stroke: "currentColor"
20319
- }, props), _path$a || (_path$a = /*#__PURE__*/React.createElement("path", {
20753
+ }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
20320
20754
  strokeLinecap: "round",
20321
20755
  strokeLinejoin: "round",
20322
20756
  strokeWidth: 2,
@@ -20324,30 +20758,49 @@ function SvgExit(props) {
20324
20758
  })));
20325
20759
  }
20326
20760
 
20327
- var _path$9;
20761
+ var _path$a;
20328
20762
 
20329
- 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); }
20763
+ 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); }
20330
20764
 
20331
20765
  function SvgCheckMark(props) {
20332
- return /*#__PURE__*/React.createElement("svg", _extends$a({
20766
+ return /*#__PURE__*/React.createElement("svg", _extends$b({
20333
20767
  className: "plc-w-4 plc-h-4 plc-mr-1",
20334
20768
  xmlns: "http://www.w3.org/2000/svg",
20335
20769
  viewBox: "0 0 20 20",
20336
20770
  fill: "currentColor"
20337
- }, props), _path$9 || (_path$9 = /*#__PURE__*/React.createElement("path", {
20771
+ }, props), _path$a || (_path$a = /*#__PURE__*/React.createElement("path", {
20338
20772
  fillRule: "evenodd",
20339
20773
  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",
20340
20774
  clipRule: "evenodd"
20341
20775
  })));
20342
20776
  }
20343
20777
 
20778
+ var _path$9;
20779
+
20780
+ 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); }
20781
+
20782
+ function SvgUser(props) {
20783
+ return /*#__PURE__*/React.createElement("svg", _extends$a({
20784
+ xmlns: "http://www.w3.org/2000/svg",
20785
+ fill: "none",
20786
+ viewBox: "0 0 24 24",
20787
+ stroke: "currentColor"
20788
+ }, props), _path$9 || (_path$9 = /*#__PURE__*/React.createElement("path", {
20789
+ strokeLinecap: "round",
20790
+ strokeLinejoin: "round",
20791
+ strokeWidth: 2,
20792
+ 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"
20793
+ })));
20794
+ }
20795
+
20344
20796
  var _path$8;
20345
20797
 
20346
20798
  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); }
20347
20799
 
20348
- function SvgUser(props) {
20800
+ function SvgNewsletter(props) {
20349
20801
  return /*#__PURE__*/React.createElement("svg", _extends$9({
20350
20802
  xmlns: "http://www.w3.org/2000/svg",
20803
+ className: "plc-h-5 plc-w-5",
20351
20804
  fill: "none",
20352
20805
  viewBox: "0 0 24 24",
20353
20806
  stroke: "currentColor"
@@ -20355,7 +20808,7 @@ function SvgUser(props) {
20355
20808
  strokeLinecap: "round",
20356
20809
  strokeLinejoin: "round",
20357
20810
  strokeWidth: 2,
20358
- 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"
20811
+ 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"
20359
20812
  })));
20360
20813
  }
20361
20814
 
@@ -20594,6 +21047,24 @@ class Dashboard extends Component {
20594
21047
  });
20595
21048
  });
20596
21049
 
21050
+ _defineProperty$3(this, "componentWillUnmount", () => {
21051
+ document.removeEventListener("click", this.hideMenuIfClickedOutside);
21052
+ });
21053
+
21054
+ _defineProperty$3(this, "initializeHideMenuHandler", () => {
21055
+ document.addEventListener("click", this.hideMenuIfClickedOutside);
21056
+ });
21057
+
21058
+ _defineProperty$3(this, "hideMenuIfClickedOutside", event => {
21059
+ const didClickOutsideMenu = this.state.isOpen && this.menuRef.current && !this.menuRef.current.contains(event.target);
21060
+
21061
+ if (didClickOutsideMenu) {
21062
+ this.setState({
21063
+ isOpen: false
21064
+ });
21065
+ }
21066
+ });
21067
+
20597
21068
  _defineProperty$3(this, "cancelSubscription", (subscription_id, onSuccess, onFailure) => {
20598
21069
  // disable the Login button to prevent repeated clicks
20599
21070
  window.Pelcro.subscription.cancel({
@@ -20631,6 +21102,10 @@ class Dashboard extends Component {
20631
21102
  return this.props.setView("password-change");
20632
21103
  });
20633
21104
 
21105
+ _defineProperty$3(this, "displayNewsletterUpdate", () => {
21106
+ return this.props.setView("newsletter-update");
21107
+ });
21108
+
20634
21109
  _defineProperty$3(this, "displayProductSelect", ({
20635
21110
  isGift
20636
21111
  }) => {
@@ -20790,21 +21265,21 @@ class Dashboard extends Component {
20790
21265
  className: "plc-inline-block plc-mt-1"
20791
21266
  }, sub.shipments_remaining, " ", this.locale("labels.shipments")) : null)), /*#__PURE__*/React__default.createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(Button, {
20792
21267
  variant: "ghost",
20793
- className: "plc-text-red-500 focus:plc-ring-red-500",
21268
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
20794
21269
  icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
20795
21270
  onClick: onCancelClick,
20796
21271
  disabled: this.state.disableSubmit,
20797
21272
  "data-key": sub.id
20798
21273
  }, this.locale("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default.createElement(Button, {
20799
21274
  variant: "ghost",
20800
- className: "plc-text-green-400 focus:plc-ring-green-300",
21275
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
20801
21276
  icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
20802
21277
  onClick: onReactivateClick,
20803
21278
  disabled: this.state.disableSubmit,
20804
21279
  "data-key": sub.id
20805
21280
  }, this.locale("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default.createElement(Button, {
20806
21281
  variant: "ghost",
20807
- className: "plc-text-blue-400",
21282
+ className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
20808
21283
  icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
20809
21284
  onClick: onRenewClick,
20810
21285
  disabled: this.state.disableSubmit,
@@ -20985,28 +21460,33 @@ class Dashboard extends Component {
20985
21460
  this.site = window.Pelcro.site.read();
20986
21461
  this.locale = this.props.t;
20987
21462
  this.user = window.Pelcro.user.read();
21463
+ this.menuRef = /*#__PURE__*/React__default.createRef();
20988
21464
  }
20989
21465
 
20990
21466
  render() {
20991
- var _window$Pelcro$user$r3, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
21467
+ var _window$Pelcro$user$r3, _window$Pelcro, _window$Pelcro$uiSett, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
20992
21468
 
20993
21469
  const {
20994
21470
  isOpen
20995
21471
  } = this.state;
20996
21472
  const userHasName = this.user.first_name || this.user.last_name;
20997
21473
  const profilePicture = (_window$Pelcro$user$r3 = window.Pelcro.user.read().profile_photo) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : userSolidIcon;
21474
+ 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;
21475
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
20998
21476
  return /*#__PURE__*/React__default.createElement(Transition, {
20999
21477
  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",
21000
21478
  show: isOpen,
21001
21479
  enter: "plc-transform plc-transition plc-duration-500",
21002
21480
  enterFrom: "plc-translate-x-full",
21003
21481
  enterTo: "plc-translate-x-0",
21482
+ afterEnter: this.initializeHideMenuHandler,
21004
21483
  leave: "plc-transform plc-transition plc-duration-500",
21005
21484
  leaveFrom: "plc-translate-x-0",
21006
21485
  leaveTo: "plc-translate-x-full",
21007
21486
  afterLeave: this.props.onClose
21008
21487
  }, /*#__PURE__*/React__default.createElement("div", {
21009
- id: "pelcro-view-dashboard"
21488
+ id: "pelcro-view-dashboard",
21489
+ ref: this.menuRef
21010
21490
  }, /*#__PURE__*/React__default.createElement("header", {
21011
21491
  className: "plc-flex plc-flex-col plc-p-4 plc-pl-2 plc-min-h-40 sm:plc-pr-8 plc-bg-primary-500"
21012
21492
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -21069,7 +21549,14 @@ class Dashboard extends Component {
21069
21549
  }),
21070
21550
  className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21071
21551
  onClick: this.displayChangePassword
21072
- }, this.locale("labels.changePassword")))
21552
+ }, this.locale("labels.changePassword")), siteHasNewslettersDefined && /*#__PURE__*/React__default.createElement(Button, {
21553
+ variant: "ghost",
21554
+ icon: /*#__PURE__*/React__default.createElement(SvgNewsletter, {
21555
+ className: "plc-w-5 plc-h-5 plc-mr-1"
21556
+ }),
21557
+ className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21558
+ onClick: this.displayNewsletterUpdate
21559
+ }, this.locale("labels.editNewsletters")))
21073
21560
  }), /*#__PURE__*/React__default.createElement(Accordion.item, {
21074
21561
  name: SUB_MENUS.PAYMENT_CARDS,
21075
21562
  icon: /*#__PURE__*/React__default.createElement(SvgPaymentCard, null),
@@ -21145,7 +21632,7 @@ const DashboardOpenButton = () => {
21145
21632
  return /*#__PURE__*/React__default.createElement("div", {
21146
21633
  className: "plc-fixed plc-right-4 plc-bottom-4 pelcro-open-dashboard-btn"
21147
21634
  }, /*#__PURE__*/React__default.createElement("button", {
21148
- className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300",
21635
+ className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300 hover:plc-bg-white",
21149
21636
  name: "menu",
21150
21637
  id: "pelcro-view-menu",
21151
21638
  onClick: () => switchView("dashboard")
@@ -22978,4 +23465,4 @@ function ProfilePicChangeModal({
22978
23465
  }
22979
23466
  ProfilePicChangeModal.viewId = "profile-picture";
22980
23467
 
22981
- export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, ApplyCouponButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, notify, unauthenticatedButtons, usePelcro };
23468
+ export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, notify, unauthenticatedButtons, usePelcro };