@eshal-bot/chat-widget 0.2.39 → 0.2.41

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.
@@ -88770,7 +88770,9 @@
88770
88770
  /** "14:59" for a lockout's time left. */
88771
88771
  function clock(seconds) {
88772
88772
  const s = Math.max(0, Math.ceil(seconds));
88773
- return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
88773
+ // "4:59:59" past an hour (a daily limit).
88774
+ const mmss = `${String(Math.floor(s % 3600 / 60)).padStart(s >= 3600 ? 2 : 1, '0')}:${String(s % 60).padStart(2, '0')}`;
88775
+ return s >= 3600 ? `${Math.floor(s / 3600)}:${mmss}` : mmss;
88774
88776
  }
88775
88777
  function boxStyle(isDark) {
88776
88778
  return {
@@ -88848,6 +88850,9 @@
88848
88850
  // EV-4939: a lockout's end from the server, and the allowed calling codes.
88849
88851
  const [lockUntil, setLockUntil] = React.useState(null);
88850
88852
  const [lockIn, setLockIn] = React.useState(0);
88853
+ // EV-4939 item 8: the number a per-number limit holds; null holds every
88854
+ // number (a lockout is for the conversation).
88855
+ const [lockFor, setLockFor] = React.useState(null);
88851
88856
  const [callingCodes, setCallingCodes] = React.useState(null);
88852
88857
  const resumedRef = React.useRef(false);
88853
88858
  const pendingKey = React.useRef(Symbol('verify-card'));
@@ -88959,6 +88964,7 @@
88959
88964
  if (res.ok) {
88960
88965
  setMasked(res.body?.masked || address.trim());
88961
88966
  setLockUntil(null);
88967
+ setLockFor(null);
88962
88968
  // EV-4941: if the card goes back to the number step (lockout, expiry,
88963
88969
  // a new number), the field reads "+91 90749 76138", not "+919074976138".
88964
88970
  if (res.body?.formatted) setAddress(String(res.body.formatted));
@@ -88968,8 +88974,9 @@
88968
88974
  } else {
88969
88975
  setError(res.body?.error || t('verifyGenericError'));
88970
88976
  if (res.body?.resendAfterS) setResendIn(Number(res.body.resendAfterS));
88971
- if (res.body?.code === 'locked' && res.body?.lockedUntil) {
88977
+ if ((res.body?.code === 'locked' || res.body?.code === 'too_many') && res.body?.lockedUntil) {
88972
88978
  setLockUntil(Date.parse(res.body.lockedUntil));
88979
+ setLockFor(res.body.code === 'too_many' ? address.trim() : null);
88973
88980
  setResendIn(0);
88974
88981
  }
88975
88982
  }
@@ -89006,7 +89013,7 @@
89006
89013
  });
89007
89014
  }
89008
89015
  } else if (res.body?.code === 'wrong_code' && typeof res.body?.triesLeft === 'number') {
89009
- setError(fill(t('verifyTriesLeft'), {
89016
+ setError(fill(t(res.body.triesLeft === 1 ? 'verifyTryLeft' : 'verifyTriesLeft'), {
89010
89017
  count: res.body.triesLeft
89011
89018
  }));
89012
89019
  setCode('');
@@ -89016,6 +89023,7 @@
89016
89023
  // EV-4939: a lockout holds Send for its whole length, as a countdown.
89017
89024
  if (res.body?.code === 'locked' && res.body?.lockedUntil) {
89018
89025
  setLockUntil(Date.parse(res.body.lockedUntil));
89026
+ setLockFor(null);
89019
89027
  setResendIn(0);
89020
89028
  }
89021
89029
  }
@@ -89049,7 +89057,8 @@
89049
89057
  },
89050
89058
  children: text
89051
89059
  }) : null;
89052
- const sendDisabled = busy || !address.trim() || resendIn > 0 || lockIn > 0 || countryBlocked;
89060
+ const held = lockIn > 0 && (lockFor === null || lockFor === address.trim());
89061
+ const sendDisabled = busy || !address.trim() || resendIn > 0 || held || countryBlocked;
89053
89062
  return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
89054
89063
  style: boxStyle(isDark),
89055
89064
  "data-testid": "verify-card",
@@ -89087,7 +89096,7 @@
89087
89096
  style: buttonStyle(sendDisabled),
89088
89097
  disabled: sendDisabled,
89089
89098
  onClick: send,
89090
- children: busy ? t('verifySending') : lockIn > 0 ? fill(t('verifyLockedFor'), {
89099
+ children: busy ? t('verifySending') : held ? fill(t('verifyLockedFor'), {
89091
89100
  time: clock(lockIn)
89092
89101
  }) : resendIn > 0 ? fill(t('verifyResendIn'), {
89093
89102
  seconds: resendIn