@apextelemed/partner-core 0.18.0-dev.59 → 0.18.0

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.
Files changed (50) hide show
  1. package/dist/api/index.d.ts +23 -2
  2. package/dist/api/index.js +4 -4
  3. package/dist/api/index.jsx +8 -4
  4. package/dist/chunk/{AXCXMZKP.js → 22EFLJGO.js} +18 -8
  5. package/dist/chunk/22EFLJGO.js.map +1 -0
  6. package/dist/chunk/{P6RRDH3K.jsx → 2Q4GK4WD.jsx} +41 -3
  7. package/dist/chunk/{C4V7G2WO.js → BPF2SSKF.js} +3 -3
  8. package/dist/chunk/{C4V7G2WO.js.map → BPF2SSKF.js.map} +1 -1
  9. package/dist/chunk/{HWUNDWNY.js → CED3IYWX.js} +40 -4
  10. package/dist/chunk/CED3IYWX.js.map +1 -0
  11. package/dist/chunk/ESNAWOHG.jsx +1 -0
  12. package/dist/chunk/{23TRH45I.jsx → FL3DS5WN.jsx} +370 -131
  13. package/dist/chunk/{B3IHYFCS.js → GSYL4J57.js} +2712 -1452
  14. package/dist/chunk/GSYL4J57.js.map +1 -0
  15. package/dist/chunk/{HECRSRX5.jsx → GULO22W6.jsx} +2 -2
  16. package/dist/chunk/{IJR3CERD.js → GYAT2X65.js} +51 -3
  17. package/dist/chunk/GYAT2X65.js.map +1 -0
  18. package/dist/chunk/{QMMIJ5T5.jsx → I7L5WVA2.jsx} +20 -7
  19. package/dist/chunk/{WSP34CNN.jsx → PWEK34Q4.jsx} +50 -2
  20. package/dist/chunk/{OMHZD4JU.jsx → U5DE7VZP.jsx} +3156 -2314
  21. package/dist/chunk/{6D2HEGRD.js → UM5K75Y4.js} +3 -3
  22. package/dist/chunk/{6D2HEGRD.js.map → UM5K75Y4.js.map} +1 -1
  23. package/dist/chunk/{QN3GGUYU.jsx → W5QWCMTE.jsx} +2 -2
  24. package/dist/chunk/{PJVEDHQN.js → XPYBZU45.js} +240 -14
  25. package/dist/chunk/XPYBZU45.js.map +1 -0
  26. package/dist/chunk/XZVVZIRZ.js +3 -0
  27. package/dist/chunk/XZVVZIRZ.js.map +1 -0
  28. package/dist/{client-DUg3WI5F.d.ts → client-BQ8AEx5S.d.ts} +191 -2
  29. package/dist/flows/index.d.ts +113 -2
  30. package/dist/flows/index.js +6 -6
  31. package/dist/flows/index.jsx +14 -6
  32. package/dist/index/index.d.ts +26 -5
  33. package/dist/index/index.js +8 -8
  34. package/dist/index/index.jsx +22 -8
  35. package/dist/pages/index.d.ts +2 -2
  36. package/dist/pages/index.js +5 -5
  37. package/dist/pages/index.jsx +5 -5
  38. package/dist/stores/index.d.ts +1 -1
  39. package/dist/stores/index.js +2 -2
  40. package/dist/stores/index.jsx +2 -2
  41. package/dist/theme/member-portal.css +43 -0
  42. package/package.json +1 -1
  43. package/dist/chunk/ACE7M2YA.jsx +0 -1
  44. package/dist/chunk/AXCXMZKP.js.map +0 -1
  45. package/dist/chunk/B3IHYFCS.js.map +0 -1
  46. package/dist/chunk/HWUNDWNY.js.map +0 -1
  47. package/dist/chunk/IJR3CERD.js.map +0 -1
  48. package/dist/chunk/JSHO46VZ.js +0 -3
  49. package/dist/chunk/JSHO46VZ.js.map +0 -1
  50. package/dist/chunk/PJVEDHQN.js.map +0 -1
@@ -2,17 +2,19 @@ import {
2
2
  adoptFunnelSessionId,
3
3
  fetchFunnelConfig,
4
4
  fetchResumedDraft,
5
+ fetchSmsConfig,
5
6
  postFunnelEvent,
6
7
  readResumeToken,
8
+ resetSmsConfigCache,
7
9
  saveFunnelDraft,
8
10
  stripResumeToken
9
- } from "./P6RRDH3K.jsx";
11
+ } from "./2Q4GK4WD.jsx";
10
12
  import {
11
13
  affiliateAuth_default,
12
14
  auth_default,
13
15
  cart_default,
14
16
  medication_default
15
- } from "./QN3GGUYU.jsx";
17
+ } from "./W5QWCMTE.jsx";
16
18
  import {
17
19
  ApiError,
18
20
  addressesApi,
@@ -33,7 +35,7 @@ import {
33
35
  subscriptionsApi,
34
36
  supportApi,
35
37
  usersApi
36
- } from "./WSP34CNN.jsx";
38
+ } from "./PWEK34Q4.jsx";
37
39
  import {
38
40
  getConfig
39
41
  } from "./QVZ7BRNO.jsx";
@@ -1562,8 +1564,88 @@ function useCartCheckoutFlow() {
1562
1564
  };
1563
1565
  }
1564
1566
 
1567
+ // src/flows/phone.ts
1568
+ var PHONE_ERROR = "Enter a valid 10-digit US phone number.";
1569
+ function isValidUsPhone(raw) {
1570
+ const digits = raw.replace(/\D/g, "");
1571
+ return digits.length === 10 || digits.length === 11 && digits.startsWith("1");
1572
+ }
1573
+ function formatUsPhone(raw) {
1574
+ const digits = raw.replace(/\D/g, "");
1575
+ const ten = digits.length === 11 && digits.startsWith("1") ? digits.slice(1) : digits;
1576
+ if (ten.length !== 10) return raw;
1577
+ return `(${ten.slice(0, 3)}) ${ten.slice(3, 6)}-${ten.slice(6)}`;
1578
+ }
1579
+
1580
+ // src/flows/signup.ts
1581
+ import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1582
+
1583
+ // src/flows/_internal/smsConsent.ts
1584
+ import { createEffect as createEffect5, createSignal as createSignal7, on as on2, onCleanup as onCleanup3, onMount as onMount5 } from "solid-js";
1585
+ function offerFromConfig(cfg) {
1586
+ if (!cfg.enabled || !cfg.consentText || !cfg.consentTextVersion) return null;
1587
+ return {
1588
+ text: cfg.consentText,
1589
+ textVersion: cfg.consentTextVersion,
1590
+ brandName: cfg.brandName,
1591
+ termsUrl: cfg.termsUrl,
1592
+ privacyUrl: cfg.privacyUrl
1593
+ };
1594
+ }
1595
+ var SMS_CONSENT_PHONE_HINT = "Enter a valid mobile number above to turn this on.";
1596
+ function useSmsConsent(phone, restoredVersion) {
1597
+ const [offer, setOffer] = createSignal7(null);
1598
+ const [loaded, setLoaded] = createSignal7(false);
1599
+ const [raw, setRaw] = createSignal7(false);
1600
+ const phoneOk = () => isValidUsPhone(phone());
1601
+ const enabled = () => offer() !== null && phoneOk();
1602
+ onMount5(() => {
1603
+ let alive = true;
1604
+ onCleanup3(() => {
1605
+ alive = false;
1606
+ });
1607
+ void fetchSmsConfig().then((cfg) => {
1608
+ if (!alive) return;
1609
+ const next = offerFromConfig(cfg);
1610
+ if (next) {
1611
+ setOffer(next);
1612
+ if (restoredVersion && restoredVersion === next.textVersion && phoneOk()) setRaw(true);
1613
+ }
1614
+ setLoaded(true);
1615
+ });
1616
+ });
1617
+ createEffect5(
1618
+ on2(
1619
+ phoneOk,
1620
+ (ok) => {
1621
+ if (!ok) setRaw(false);
1622
+ },
1623
+ { defer: true }
1624
+ )
1625
+ );
1626
+ const checked = () => raw() && enabled();
1627
+ return {
1628
+ offer,
1629
+ checked,
1630
+ setChecked: (v) => {
1631
+ if (v && !enabled()) return;
1632
+ setRaw(v);
1633
+ },
1634
+ enabled,
1635
+ hint: () => offer() && !phoneOk() ? SMS_CONSENT_PHONE_HINT : null,
1636
+ grant: () => {
1637
+ const o = offer();
1638
+ return o && checked() ? { granted: true, textVersion: o.textVersion } : void 0;
1639
+ },
1640
+ draftVersion: () => {
1641
+ if (!loaded()) return restoredVersion;
1642
+ const o = offer();
1643
+ return o && checked() ? o.textVersion : void 0;
1644
+ }
1645
+ };
1646
+ }
1647
+
1565
1648
  // src/flows/signup.ts
1566
- import { createEffect as createEffect5, createSignal as createSignal7, onMount as onMount5 } from "solid-js";
1567
1649
  var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
1568
1650
  var MAX_RESTORABLE_STEP = 2;
1569
1651
  function draftKey() {
@@ -1599,33 +1681,34 @@ function useSignupFlow(options) {
1599
1681
  const accept = useCardTokenizer();
1600
1682
  let restored = {};
1601
1683
  if (typeof window !== "undefined") restored = loadDraft();
1602
- const [step2, setStep] = createSignal7(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
1603
- const [error, setError] = createSignal7(null);
1604
- const [tokenizing, setTokenizing] = createSignal7(false);
1605
- const [submitting, setSubmitting] = createSignal7(false);
1606
- const [outcome, setOutcome] = createSignal7({ kind: "in_progress" });
1607
- const [firstName, setFirstName] = createSignal7(restored.firstName ?? "");
1608
- const [lastName, setLastName] = createSignal7(restored.lastName ?? "");
1609
- const [email, setEmail] = createSignal7(restored.email ?? "");
1610
- const [password, setPassword] = createSignal7("");
1611
- const [dateOfBirth, setDateOfBirth] = createSignal7(restored.dateOfBirth ?? "");
1612
- const [phone, setPhone] = createSignal7(restored.phone ?? "");
1613
- const [street, setStreet] = createSignal7(restored.street ?? "");
1614
- const [city, setCity] = createSignal7(restored.city ?? "");
1615
- const [state, setState] = createSignal7(restored.state ?? "");
1616
- const [zip, setZip] = createSignal7(restored.zip ?? "");
1617
- const [cardNumberRaw, setCardNumberRaw] = createSignal7("", { equals: false });
1618
- const [expiryRaw, setExpiryRaw] = createSignal7("", { equals: false });
1619
- const [cvvRaw, setCvvRaw] = createSignal7("", { equals: false });
1620
- const [tokenizedData, setTokenizedData] = createSignal7(null);
1621
- const [promoCode, setPromoCode] = createSignal7("");
1622
- const [idempotencyKey, setIdempotencyKey] = createSignal7(newIdempotencyKey());
1684
+ const [step2, setStep] = createSignal8(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
1685
+ const [error, setError] = createSignal8(null);
1686
+ const [tokenizing, setTokenizing] = createSignal8(false);
1687
+ const [submitting, setSubmitting] = createSignal8(false);
1688
+ const [outcome, setOutcome] = createSignal8({ kind: "in_progress" });
1689
+ const [firstName, setFirstName] = createSignal8(restored.firstName ?? "");
1690
+ const [lastName, setLastName] = createSignal8(restored.lastName ?? "");
1691
+ const [email, setEmail] = createSignal8(restored.email ?? "");
1692
+ const [password, setPassword] = createSignal8("");
1693
+ const [dateOfBirth, setDateOfBirth] = createSignal8(restored.dateOfBirth ?? "");
1694
+ const [phone, setPhone] = createSignal8(restored.phone ?? "");
1695
+ const smsConsent = useSmsConsent(phone, restored.smsConsentVersion);
1696
+ const [street, setStreet] = createSignal8(restored.street ?? "");
1697
+ const [city, setCity] = createSignal8(restored.city ?? "");
1698
+ const [state, setState] = createSignal8(restored.state ?? "");
1699
+ const [zip, setZip] = createSignal8(restored.zip ?? "");
1700
+ const [cardNumberRaw, setCardNumberRaw] = createSignal8("", { equals: false });
1701
+ const [expiryRaw, setExpiryRaw] = createSignal8("", { equals: false });
1702
+ const [cvvRaw, setCvvRaw] = createSignal8("", { equals: false });
1703
+ const [tokenizedData, setTokenizedData] = createSignal8(null);
1704
+ const [promoCode, setPromoCode] = createSignal8("");
1705
+ const [idempotencyKey, setIdempotencyKey] = createSignal8(newIdempotencyKey());
1623
1706
  const cartIsEmpty = () => cart_default.items().length === 0;
1624
- onMount5(() => {
1707
+ onMount6(() => {
1625
1708
  if (options.requireCart && cartIsEmpty()) setOutcome({ kind: "needs_cart" });
1626
1709
  });
1627
- onMount5(() => {
1628
- createEffect5(() => {
1710
+ onMount6(() => {
1711
+ createEffect6(() => {
1629
1712
  saveDraft({
1630
1713
  step: step2(),
1631
1714
  firstName: firstName(),
@@ -1636,7 +1719,8 @@ function useSignupFlow(options) {
1636
1719
  street: street(),
1637
1720
  city: city(),
1638
1721
  state: state(),
1639
- zip: zip()
1722
+ zip: zip(),
1723
+ smsConsentVersion: smsConsent.draftVersion()
1640
1724
  });
1641
1725
  });
1642
1726
  });
@@ -1649,6 +1733,7 @@ function useSignupFlow(options) {
1649
1733
  if (!password().trim()) return "Password is required.";
1650
1734
  if (password().length < 8) return "Password must be at least 8 characters.";
1651
1735
  if (!phone().trim()) return "Phone number is required.";
1736
+ if (!isValidUsPhone(phone())) return PHONE_ERROR;
1652
1737
  if (!/^\d{4}-\d{2}-\d{2}$/.test(dateOfBirth())) return "Enter a valid date of birth.";
1653
1738
  const dob = /* @__PURE__ */ new Date(dateOfBirth() + "T00:00:00");
1654
1739
  if (Number.isNaN(dob.getTime())) return "Enter a valid date of birth.";
@@ -1751,6 +1836,7 @@ function useSignupFlow(options) {
1751
1836
  dosage: i.dosage
1752
1837
  })) : void 0;
1753
1838
  const savingsMemberId = options.savingsMemberId?.() || void 0;
1839
+ const smsGrant = smsConsent.grant();
1754
1840
  await auth_default.signupAndSubscribe(
1755
1841
  {
1756
1842
  email: email().trim(),
@@ -1777,7 +1863,8 @@ function useSignupFlow(options) {
1777
1863
  zip: zip().trim()
1778
1864
  },
1779
1865
  promoCode: promoCode().trim() || void 0,
1780
- ...savingsMemberId ? { savingsMemberId } : {}
1866
+ ...savingsMemberId ? { savingsMemberId } : {},
1867
+ ...smsGrant ? { smsConsent: smsGrant } : {}
1781
1868
  },
1782
1869
  { idempotencyKey: idempotencyKey() }
1783
1870
  );
@@ -1837,6 +1924,7 @@ function useSignupFlow(options) {
1837
1924
  setDateOfBirth,
1838
1925
  phone,
1839
1926
  setPhone,
1927
+ smsConsent,
1840
1928
  street,
1841
1929
  setStreet,
1842
1930
  city,
@@ -1858,7 +1946,7 @@ function useSignupFlow(options) {
1858
1946
  }
1859
1947
 
1860
1948
  // src/flows/register.ts
1861
- import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1949
+ import { createEffect as createEffect7, createSignal as createSignal9, onMount as onMount7 } from "solid-js";
1862
1950
  var DRAFT_TTL_MS2 = 7 * 24 * 3600 * 1e3;
1863
1951
  var MAX_RESTORABLE_STEP2 = 1;
1864
1952
  function draftKey2() {
@@ -1893,26 +1981,27 @@ function clearDraft2() {
1893
1981
  function useRegisterFlow() {
1894
1982
  let restored = {};
1895
1983
  if (typeof window !== "undefined") restored = loadDraft2();
1896
- const [step2, setStep] = createSignal8(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP2));
1897
- const [error, setError] = createSignal8(null);
1898
- const [submitting, setSubmitting] = createSignal8(false);
1899
- const [outcome, setOutcome] = createSignal8({ kind: "in_progress" });
1900
- const [firstName, setFirstName] = createSignal8(restored.firstName ?? "");
1901
- const [lastName, setLastName] = createSignal8(restored.lastName ?? "");
1902
- const [email, setEmail] = createSignal8(restored.email ?? "");
1903
- const [password, setPassword] = createSignal8("");
1904
- const [dateOfBirth, setDateOfBirth] = createSignal8(restored.dateOfBirth ?? "");
1905
- const [phone, setPhone] = createSignal8(restored.phone ?? "");
1906
- const [street, setStreet] = createSignal8(restored.street ?? "");
1907
- const [city, setCity] = createSignal8(restored.city ?? "");
1908
- const [state, setState] = createSignal8(restored.state ?? "");
1909
- const [zip, setZip] = createSignal8(restored.zip ?? "");
1910
- onMount6(() => {
1984
+ const [step2, setStep] = createSignal9(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP2));
1985
+ const [error, setError] = createSignal9(null);
1986
+ const [submitting, setSubmitting] = createSignal9(false);
1987
+ const [outcome, setOutcome] = createSignal9({ kind: "in_progress" });
1988
+ const [firstName, setFirstName] = createSignal9(restored.firstName ?? "");
1989
+ const [lastName, setLastName] = createSignal9(restored.lastName ?? "");
1990
+ const [email, setEmail] = createSignal9(restored.email ?? "");
1991
+ const [password, setPassword] = createSignal9("");
1992
+ const [dateOfBirth, setDateOfBirth] = createSignal9(restored.dateOfBirth ?? "");
1993
+ const [phone, setPhone] = createSignal9(restored.phone ?? "");
1994
+ const smsConsent = useSmsConsent(phone, restored.smsConsentVersion);
1995
+ const [street, setStreet] = createSignal9(restored.street ?? "");
1996
+ const [city, setCity] = createSignal9(restored.city ?? "");
1997
+ const [state, setState] = createSignal9(restored.state ?? "");
1998
+ const [zip, setZip] = createSignal9(restored.zip ?? "");
1999
+ onMount7(() => {
1911
2000
  if (auth_default.isAuthenticated()) {
1912
2001
  setOutcome({ kind: "already_authenticated" });
1913
2002
  return;
1914
2003
  }
1915
- createEffect6(() => {
2004
+ createEffect7(() => {
1916
2005
  saveDraft2({
1917
2006
  step: step2(),
1918
2007
  firstName: firstName(),
@@ -1923,7 +2012,8 @@ function useRegisterFlow() {
1923
2012
  street: street(),
1924
2013
  city: city(),
1925
2014
  state: state(),
1926
- zip: zip()
2015
+ zip: zip(),
2016
+ smsConsentVersion: smsConsent.draftVersion()
1927
2017
  });
1928
2018
  });
1929
2019
  });
@@ -1936,6 +2026,7 @@ function useRegisterFlow() {
1936
2026
  if (!password().trim()) return "Password is required.";
1937
2027
  if (password().length < 8) return "Password must be at least 8 characters.";
1938
2028
  if (!phone().trim()) return "Phone number is required.";
2029
+ if (!isValidUsPhone(phone())) return PHONE_ERROR;
1939
2030
  if (!/^\d{4}-\d{2}-\d{2}$/.test(dateOfBirth())) return "Enter a valid date of birth.";
1940
2031
  const dob = /* @__PURE__ */ new Date(dateOfBirth() + "T00:00:00");
1941
2032
  if (Number.isNaN(dob.getTime())) return "Enter a valid date of birth.";
@@ -2008,6 +2099,7 @@ function useRegisterFlow() {
2008
2099
  setSubmitting(true);
2009
2100
  setOutcome({ kind: "submitting" });
2010
2101
  try {
2102
+ const smsGrant = smsConsent.grant();
2011
2103
  await auth_default.signup({
2012
2104
  email: email().trim(),
2013
2105
  password: password(),
@@ -2020,7 +2112,8 @@ function useRegisterFlow() {
2020
2112
  city: city().trim(),
2021
2113
  state: state(),
2022
2114
  zip: zip().trim()
2023
- }
2115
+ },
2116
+ ...smsGrant ? { smsConsent: smsGrant } : {}
2024
2117
  });
2025
2118
  if (finishIfAuthenticated()) return;
2026
2119
  if (await reconcileViaLogin()) return;
@@ -2070,6 +2163,7 @@ function useRegisterFlow() {
2070
2163
  setDateOfBirth,
2071
2164
  phone,
2072
2165
  setPhone,
2166
+ smsConsent,
2073
2167
  street,
2074
2168
  setStreet,
2075
2169
  city,
@@ -2105,7 +2199,7 @@ function isLive(status) {
2105
2199
  }
2106
2200
 
2107
2201
  // src/flows/subscribe.ts
2108
- import { createEffect as createEffect7, createSignal as createSignal9, on as on2, onMount as onMount7 } from "solid-js";
2202
+ import { createEffect as createEffect8, createSignal as createSignal10, on as on3, onMount as onMount8 } from "solid-js";
2109
2203
  async function hasActiveSubscription() {
2110
2204
  const subsRes = await subscriptionsApi.list();
2111
2205
  return (subsRes?.subscriptions ?? []).some((s) => s.status === "active");
@@ -2116,26 +2210,26 @@ async function hasReconcilableSubscription() {
2116
2210
  }
2117
2211
  function useSubscribeFlow(options) {
2118
2212
  const accept = useCardTokenizer();
2119
- const [outcome, setOutcome] = createSignal9({ kind: "loading" });
2120
- const [error, setError] = createSignal9(null);
2121
- const [submitting, setSubmitting] = createSignal9(false);
2122
- const [quote, setQuote] = createSignal9(null);
2123
- const [quoteError, setQuoteError] = createSignal9(null);
2124
- const [street, setStreet] = createSignal9("");
2125
- const [city, setCity] = createSignal9("");
2126
- const [state, setState] = createSignal9("");
2127
- const [zip, setZip] = createSignal9("");
2128
- const [profileState, setProfileState] = createSignal9("");
2213
+ const [outcome, setOutcome] = createSignal10({ kind: "loading" });
2214
+ const [error, setError] = createSignal10(null);
2215
+ const [submitting, setSubmitting] = createSignal10(false);
2216
+ const [quote, setQuote] = createSignal10(null);
2217
+ const [quoteError, setQuoteError] = createSignal10(null);
2218
+ const [street, setStreet] = createSignal10("");
2219
+ const [city, setCity] = createSignal10("");
2220
+ const [state, setState] = createSignal10("");
2221
+ const [zip, setZip] = createSignal10("");
2222
+ const [profileState, setProfileState] = createSignal10("");
2129
2223
  const shipState = () => profileState() || state();
2130
2224
  const availability = useCatalogAvailability(
2131
2225
  () => cart_default.items().map((i) => i.productId),
2132
2226
  shipState
2133
2227
  );
2134
- const [cardNumberRaw, setCardNumberRaw] = createSignal9("", { equals: false });
2135
- const [expiryRaw, setExpiryRaw] = createSignal9("", { equals: false });
2136
- const [cvvRaw, setCvvRaw] = createSignal9("", { equals: false });
2137
- const [idempotencyKey, setIdempotencyKey] = createSignal9(newIdempotencyKey());
2138
- onMount7(async () => {
2228
+ const [cardNumberRaw, setCardNumberRaw] = createSignal10("", { equals: false });
2229
+ const [expiryRaw, setExpiryRaw] = createSignal10("", { equals: false });
2230
+ const [cvvRaw, setCvvRaw] = createSignal10("", { equals: false });
2231
+ const [idempotencyKey, setIdempotencyKey] = createSignal10(newIdempotencyKey());
2232
+ onMount8(async () => {
2139
2233
  if (!auth_default.isAuthenticated()) {
2140
2234
  setOutcome({ kind: "needs_auth" });
2141
2235
  return;
@@ -2234,8 +2328,8 @@ function useSubscribeFlow(options) {
2234
2328
  setQuote(estimateFromCart());
2235
2329
  }
2236
2330
  }
2237
- createEffect7(
2238
- on2(
2331
+ createEffect8(
2332
+ on3(
2239
2333
  () => [outcome().kind, cart_default.items(), cart_default.appliedPromo()],
2240
2334
  ([kind]) => {
2241
2335
  if (kind === "in_progress") void refreshQuote();
@@ -3499,17 +3593,17 @@ function useMemberPortalData() {
3499
3593
  }
3500
3594
 
3501
3595
  // src/flows/updatePaymentMethod.ts
3502
- import { createEffect as createEffect8, createSignal as createSignal10 } from "solid-js";
3596
+ import { createEffect as createEffect9, createSignal as createSignal11 } from "solid-js";
3503
3597
  function useUpdatePaymentMethodFlow(subscriptionId) {
3504
3598
  const accept = useCardTokenizer();
3505
- const [cardNumber, setCardNumberRaw] = createSignal10("");
3506
- const [expiry, setExpiryRaw] = createSignal10("");
3507
- const [cvv, setCvvRaw] = createSignal10("");
3508
- const [submitting, setSubmitting] = createSignal10(false);
3509
- const [error, setError] = createSignal10(null);
3599
+ const [cardNumber, setCardNumberRaw] = createSignal11("");
3600
+ const [expiry, setExpiryRaw] = createSignal11("");
3601
+ const [cvv, setCvvRaw] = createSignal11("");
3602
+ const [submitting, setSubmitting] = createSignal11(false);
3603
+ const [error, setError] = createSignal11(null);
3510
3604
  const billing = useAddressPair();
3511
- const [billingLoaded, setBillingLoaded] = createSignal10(false);
3512
- createEffect8(() => {
3605
+ const [billingLoaded, setBillingLoaded] = createSignal11(false);
3606
+ createEffect9(() => {
3513
3607
  const id = subscriptionId();
3514
3608
  if (!id || billingLoaded()) return;
3515
3609
  void (async () => {
@@ -3585,7 +3679,7 @@ function useUpdatePaymentMethodFlow(subscriptionId) {
3585
3679
  }
3586
3680
 
3587
3681
  // src/flows/messages.ts
3588
- import { createSignal as createSignal11, onMount as onMount8, onCleanup as onCleanup3 } from "solid-js";
3682
+ import { createSignal as createSignal12, onMount as onMount9, onCleanup as onCleanup4 } from "solid-js";
3589
3683
 
3590
3684
  // src/flows/supportRealtime.ts
3591
3685
  var TOKEN_REFRESH_MS = 4 * 60 * 1e3;
@@ -3756,16 +3850,16 @@ function useMessagesThread(options = {}) {
3756
3850
  const conversationPollMs = options.pollIntervalMs?.conversations ?? DEFAULT_CONVERSATION_POLL_MS;
3757
3851
  const messagePollMs = options.pollIntervalMs?.messages ?? DEFAULT_MESSAGE_POLL_MS;
3758
3852
  const autoPoll = options.autoPoll !== false;
3759
- const [conversations, setConversations] = createSignal11([]);
3760
- const [selectedId, setSelectedId] = createSignal11(null);
3761
- const [supportChannel, setSupportChannel] = createSignal11("portal");
3762
- const [messages, setMessages] = createSignal11([]);
3763
- const [draft, setDraft] = createSignal11("");
3764
- const [loadingConversations, setLoadingConversations] = createSignal11(true);
3765
- const [loadingMessages, setLoadingMessages] = createSignal11(false);
3766
- const [sending, setSending] = createSignal11(false);
3767
- const [startingThread, setStartingThread] = createSignal11(false);
3768
- const [startingCareTeamThread, setStartingCareTeamThread] = createSignal11(false);
3853
+ const [conversations, setConversations] = createSignal12([]);
3854
+ const [selectedId, setSelectedId] = createSignal12(null);
3855
+ const [supportChannel, setSupportChannel] = createSignal12("portal");
3856
+ const [messages, setMessages] = createSignal12([]);
3857
+ const [draft, setDraft] = createSignal12("");
3858
+ const [loadingConversations, setLoadingConversations] = createSignal12(true);
3859
+ const [loadingMessages, setLoadingMessages] = createSignal12(false);
3860
+ const [sending, setSending] = createSignal12(false);
3861
+ const [startingThread, setStartingThread] = createSignal12(false);
3862
+ const [startingCareTeamThread, setStartingCareTeamThread] = createSignal12(false);
3769
3863
  let pendingDeepLinkId = readDeepLinkedConversationId();
3770
3864
  let convoPollTimer;
3771
3865
  let msgPollTimer;
@@ -4075,7 +4169,7 @@ function useMessagesThread(options = {}) {
4075
4169
  setStartingCareTeamThread(false);
4076
4170
  }
4077
4171
  }
4078
- onMount8(() => {
4172
+ onMount9(() => {
4079
4173
  fetchConversations(true);
4080
4174
  if (autoPoll) {
4081
4175
  convoPollTimer = setInterval(() => {
@@ -4083,7 +4177,7 @@ function useMessagesThread(options = {}) {
4083
4177
  }, conversationPollMs);
4084
4178
  }
4085
4179
  });
4086
- onCleanup3(() => {
4180
+ onCleanup4(() => {
4087
4181
  if (convoPollTimer) clearInterval(convoPollTimer);
4088
4182
  if (msgPollTimer) clearInterval(msgPollTimer);
4089
4183
  void stopRealtime();
@@ -4117,7 +4211,7 @@ function useMessagesThread(options = {}) {
4117
4211
  }
4118
4212
 
4119
4213
  // src/flows/products.ts
4120
- import { createMemo, createResource as createResource3, createSignal as createSignal12 } from "solid-js";
4214
+ import { createMemo, createResource as createResource3, createSignal as createSignal13 } from "solid-js";
4121
4215
  function priceForDosage(product, dosage) {
4122
4216
  const overlay = (product.dosage_prices ?? []).find((d) => d.dosage === dosage);
4123
4217
  if (overlay && overlay.price != null) return overlay.price;
@@ -4190,7 +4284,7 @@ function useProductDetail(productId) {
4190
4284
  const chosen = override && all.find((d) => d.dosage === override) || all[0];
4191
4285
  return [chosen];
4192
4286
  });
4193
- const [selectedDosage, setSelectedDosage] = createSignal12("");
4287
+ const [selectedDosage, setSelectedDosage] = createSignal13("");
4194
4288
  createMemo(() => {
4195
4289
  const opts = dosageOptions();
4196
4290
  if (opts.length > 0 && !selectedDosage()) setSelectedDosage(opts[0].dosage);
@@ -4680,7 +4774,7 @@ function offerSummaryText(o) {
4680
4774
  }
4681
4775
 
4682
4776
  // src/flows/productCatalog.ts
4683
- import { createEffect as createEffect9, createMemo as createMemo2, createSignal as createSignal13, on as on3 } from "solid-js";
4777
+ import { createEffect as createEffect10, createMemo as createMemo2, createSignal as createSignal14, on as on4 } from "solid-js";
4684
4778
  var messageOf = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
4685
4779
  function classifyCatalogError(err) {
4686
4780
  const e = err ?? {};
@@ -4906,15 +5000,15 @@ function groupDrugsByPharmacy(drugs, mappedPharmacyIds = /* @__PURE__ */ new Set
4906
5000
  var UNAVAILABLE_MESSAGE = "The prescribing platform is unavailable right now, so strengths and pharmacies cannot be changed.";
4907
5001
  var UNCONFIRMED_MESSAGE = "We couldn't confirm whether that was saved. Reload before changing anything else here.";
4908
5002
  function useProductCatalogEditor(opts) {
4909
- const [product, setProduct] = createSignal13(opts.product());
4910
- const [readiness, setReadiness] = createSignal13(null);
4911
- const [drugs, setDrugs] = createSignal13([]);
4912
- const [load, setLoad] = createSignal13({ kind: "loading" });
4913
- const [busy, setBusy] = createSignal13(null);
4914
- const [errors, setErrors] = createSignal13({});
4915
- const [drafts, setDrafts] = createSignal13({});
4916
- const [doseSuggestions, setDoseSuggestions] = createSignal13(null);
4917
- const [equivalents, setEquivalents] = createSignal13(null);
5003
+ const [product, setProduct] = createSignal14(opts.product());
5004
+ const [readiness, setReadiness] = createSignal14(null);
5005
+ const [drugs, setDrugs] = createSignal14([]);
5006
+ const [load, setLoad] = createSignal14({ kind: "loading" });
5007
+ const [busy, setBusy] = createSignal14(null);
5008
+ const [errors, setErrors] = createSignal14({});
5009
+ const [drafts, setDrafts] = createSignal14({});
5010
+ const [doseSuggestions, setDoseSuggestions] = createSignal14(null);
5011
+ const [equivalents, setEquivalents] = createSignal14(null);
4918
5012
  let generation = 0;
4919
5013
  const itemId = () => product().apexDrugId;
4920
5014
  const setError = (key, message) => setErrors((prev) => ({ ...prev, [key]: message }));
@@ -4961,8 +5055,8 @@ function useProductCatalogEditor(opts) {
4961
5055
  else setLoad({ kind: "blocked", message: failure.message });
4962
5056
  };
4963
5057
  const identity = createMemo2(() => `${opts.product().id}|${opts.enabled ? opts.enabled() : true}`);
4964
- createEffect9(
4965
- on3(
5058
+ createEffect10(
5059
+ on4(
4966
5060
  identity,
4967
5061
  () => {
4968
5062
  setProduct(opts.product());
@@ -5376,7 +5470,7 @@ async function createCatalogProduct(input) {
5376
5470
  }
5377
5471
 
5378
5472
  // src/flows/catalogConversion.ts
5379
- import { createEffect as createEffect10, createMemo as createMemo3, createSignal as createSignal14, on as on4, onCleanup as onCleanup4 } from "solid-js";
5473
+ import { createEffect as createEffect11, createMemo as createMemo3, createSignal as createSignal15, on as on5, onCleanup as onCleanup5 } from "solid-js";
5380
5474
  function canOfferConversion(product) {
5381
5475
  const id = product.apexDrugId;
5382
5476
  return typeof id === "string" && id.length > 0 && !isCatalogItemId(id) && !product.catalogOverlay;
@@ -5517,14 +5611,14 @@ var DEFAULT_POLL_MS = 5e3;
5517
5611
  var DEFAULT_WATCH_MS = 12e4;
5518
5612
  var REVIEW_STAGES = ["ready_to_commit", "active_not_committed"];
5519
5613
  function useCatalogConversion(opts) {
5520
- const [preview, setPreview] = createSignal14(null);
5521
- const [phase, setPhase] = createSignal14({ kind: "rest" });
5522
- const [notice, setNotice] = createSignal14(null);
5523
- const [matches, setMatches] = createSignal14({});
5524
- const [matchesPlan, setMatchesPlan] = createSignal14(void 0);
5525
- const [confirming, setConfirming] = createSignal14(false);
5526
- const [convertedOrigin, setConvertedOrigin] = createSignal14("existing");
5527
- const [lastCommit, setLastCommit] = createSignal14(null);
5614
+ const [preview, setPreview] = createSignal15(null);
5615
+ const [phase, setPhase] = createSignal15({ kind: "rest" });
5616
+ const [notice2, setNotice] = createSignal15(null);
5617
+ const [matches, setMatches] = createSignal15({});
5618
+ const [matchesPlan, setMatchesPlan] = createSignal15(void 0);
5619
+ const [confirming, setConfirming] = createSignal15(false);
5620
+ const [convertedOrigin, setConvertedOrigin] = createSignal15("existing");
5621
+ const [lastCommit, setLastCommit] = createSignal15(null);
5528
5622
  let generation = 0;
5529
5623
  let timer;
5530
5624
  let announcedConverted = false;
@@ -5537,7 +5631,7 @@ function useCatalogConversion(opts) {
5537
5631
  if (timer !== void 0) clearTimeout(timer);
5538
5632
  timer = void 0;
5539
5633
  };
5540
- onCleanup4(() => {
5634
+ onCleanup5(() => {
5541
5635
  generation += 1;
5542
5636
  stopTimer();
5543
5637
  });
@@ -5601,8 +5695,8 @@ function useCatalogConversion(opts) {
5601
5695
  await load(preview() ? "refresh" : "initial");
5602
5696
  };
5603
5697
  const identity = createMemo3(() => `${opts.product().id}|${enabled()}`);
5604
- createEffect10(
5605
- on4(identity, () => {
5698
+ createEffect11(
5699
+ on5(identity, () => {
5606
5700
  generation += 1;
5607
5701
  stopTimer();
5608
5702
  setPreview(null);
@@ -5934,7 +6028,7 @@ function useCatalogConversion(opts) {
5934
6028
  return {
5935
6029
  state,
5936
6030
  preview,
5937
- notice,
6031
+ notice: notice2,
5938
6032
  dismissNotice: () => setNotice(null),
5939
6033
  busy,
5940
6034
  reload,
@@ -5960,7 +6054,7 @@ function useCatalogConversion(opts) {
5960
6054
  }
5961
6055
 
5962
6056
  // src/flows/addPharmacy.ts
5963
- import { createSignal as createSignal15, onCleanup as onCleanup5 } from "solid-js";
6057
+ import { createSignal as createSignal16, onCleanup as onCleanup6 } from "solid-js";
5964
6058
  var REPLAN_DEBOUNCE_MS = 300;
5965
6059
  var matchKey = (source) => JSON.stringify([source.dosage, source.apexSkuId]);
5966
6060
  function matchAnswersBody(questions, answers) {
@@ -6060,17 +6154,17 @@ function classifyAddPharmacyError(err) {
6060
6154
  };
6061
6155
  }
6062
6156
  function useAddPharmacy(opts) {
6063
- const [state, setState] = createSignal15({ kind: "idle" });
6064
- const [notice, setNotice] = createSignal15(null);
6065
- const [drugs, setDrugs] = createSignal15([]);
6066
- const [drugsStatus, setDrugsStatus] = createSignal15("idle");
6067
- const [selected, setSelected] = createSignal15("");
6068
- const [prices, setPrices] = createSignal15({});
6069
- const [savingsPrices, setSavingsPrices] = createSignal15({});
6070
- const [flagged, setFlagged] = createSignal15(/* @__PURE__ */ new Set());
6071
- const [matchAnswers, setMatchAnswers] = createSignal15({});
6072
- const [replanning, setReplanning] = createSignal15(false);
6073
- const [replanStale, setReplanStale] = createSignal15(false);
6157
+ const [state, setState] = createSignal16({ kind: "idle" });
6158
+ const [notice2, setNotice] = createSignal16(null);
6159
+ const [drugs, setDrugs] = createSignal16([]);
6160
+ const [drugsStatus, setDrugsStatus] = createSignal16("idle");
6161
+ const [selected, setSelected] = createSignal16("");
6162
+ const [prices, setPrices] = createSignal16({});
6163
+ const [savingsPrices, setSavingsPrices] = createSignal16({});
6164
+ const [flagged, setFlagged] = createSignal16(/* @__PURE__ */ new Set());
6165
+ const [matchAnswers, setMatchAnswers] = createSignal16({});
6166
+ const [replanning, setReplanning] = createSignal16(false);
6167
+ const [replanStale, setReplanStale] = createSignal16(false);
6074
6168
  let generation = 0;
6075
6169
  let replanTimer;
6076
6170
  let replanSeq = 0;
@@ -6081,7 +6175,7 @@ function useAddPharmacy(opts) {
6081
6175
  setReplanning(false);
6082
6176
  setReplanStale(false);
6083
6177
  };
6084
- onCleanup5(() => {
6178
+ onCleanup6(() => {
6085
6179
  generation++;
6086
6180
  dropReplan();
6087
6181
  });
@@ -6335,7 +6429,7 @@ function useAddPharmacy(opts) {
6335
6429
  return {
6336
6430
  state,
6337
6431
  busy,
6338
- notice,
6432
+ notice: notice2,
6339
6433
  dismissNotice: () => setNotice(null),
6340
6434
  drugs,
6341
6435
  drugsStatus,
@@ -6370,6 +6464,146 @@ function useAddPharmacy(opts) {
6370
6464
  };
6371
6465
  }
6372
6466
 
6467
+ // src/flows/smsPreferences.ts
6468
+ import { createSignal as createSignal17, onCleanup as onCleanup7, onMount as onMount10 } from "solid-js";
6469
+ var NOTICES = {
6470
+ needs_consent: "Your number was updated. Texts are off for the new number until you turn them on again.",
6471
+ stale_text: "Our text-message terms were updated. Please read the new wording and turn texts on again.",
6472
+ no_phone: "Add a mobile number before turning on texts.",
6473
+ unavailable: "Text messages are not available right now."
6474
+ };
6475
+ var notice = (kind) => ({ kind, message: NOTICES[kind] });
6476
+ function useSmsPreferences() {
6477
+ const [state, setState] = createSignal17(null);
6478
+ const [offer, setOffer] = createSignal17(null);
6479
+ const [loading, setLoading] = createSignal17(true);
6480
+ const [busy, setBusy] = createSignal17(false);
6481
+ const [error, setError] = createSignal17(null);
6482
+ const [currentNotice, setNotice] = createSignal17(null);
6483
+ let alive = true;
6484
+ onCleanup7(() => {
6485
+ alive = false;
6486
+ });
6487
+ async function refresh() {
6488
+ const next = await usersApi.getSmsState();
6489
+ if (alive) setState(next);
6490
+ }
6491
+ async function reload() {
6492
+ setLoading(true);
6493
+ try {
6494
+ const [next, cfg] = await Promise.all([usersApi.getSmsState(), fetchSmsConfig()]);
6495
+ if (!alive) return;
6496
+ setState(next);
6497
+ setOffer(offerFromConfig(cfg));
6498
+ } catch {
6499
+ if (alive) setState(null);
6500
+ } finally {
6501
+ if (alive) setLoading(false);
6502
+ }
6503
+ }
6504
+ onMount10(() => void reload());
6505
+ async function run(fn) {
6506
+ if (busy()) return false;
6507
+ setBusy(true);
6508
+ setError(null);
6509
+ setNotice(null);
6510
+ try {
6511
+ return await fn() !== false;
6512
+ } catch (err) {
6513
+ setError(err instanceof Error ? err.message : "Something went wrong. Please try again.");
6514
+ return false;
6515
+ } finally {
6516
+ if (alive) setBusy(false);
6517
+ }
6518
+ }
6519
+ async function refused(reason) {
6520
+ if (reason === "stale_text") {
6521
+ resetSmsConfigCache();
6522
+ const cfg = await fetchSmsConfig();
6523
+ if (alive) setOffer(offerFromConfig(cfg));
6524
+ setNotice(notice("stale_text"));
6525
+ } else if (reason === "no_phone") {
6526
+ setNotice(notice("no_phone"));
6527
+ } else {
6528
+ setNotice(notice("unavailable"));
6529
+ await refresh().catch(() => {
6530
+ });
6531
+ }
6532
+ }
6533
+ async function setPhone(raw) {
6534
+ const phone = raw.trim();
6535
+ if (busy()) return false;
6536
+ if (!isValidUsPhone(phone)) {
6537
+ setNotice(null);
6538
+ setError(PHONE_ERROR);
6539
+ return false;
6540
+ }
6541
+ return run(async () => {
6542
+ const hadConsent = state()?.consented === true;
6543
+ await usersApi.updateProfile({ phone });
6544
+ await refresh();
6545
+ if (hadConsent && state()?.consented !== true) setNotice(notice("needs_consent"));
6546
+ });
6547
+ }
6548
+ async function optIn() {
6549
+ return run(async () => {
6550
+ const shown = offer();
6551
+ if (!shown) {
6552
+ setNotice(notice("unavailable"));
6553
+ return false;
6554
+ }
6555
+ try {
6556
+ const res = await usersApi.updateProfile({
6557
+ smsConsent: { granted: true, textVersion: shown.textVersion, source: "profile" }
6558
+ });
6559
+ if (res?.smsConsent?.status === "refused") {
6560
+ await refused(res.smsConsent.reason);
6561
+ return false;
6562
+ }
6563
+ } catch (err) {
6564
+ if (err instanceof ApiError && err.status === 409) {
6565
+ await refused(err.reason);
6566
+ return false;
6567
+ }
6568
+ throw err;
6569
+ }
6570
+ await refresh();
6571
+ });
6572
+ }
6573
+ async function optOut() {
6574
+ return run(async () => {
6575
+ await usersApi.updateProfile({ smsConsent: { granted: false } });
6576
+ await refresh();
6577
+ });
6578
+ }
6579
+ async function setEvent(key, enabled) {
6580
+ return run(async () => {
6581
+ const next = await usersApi.setSmsEvents({ [key]: enabled });
6582
+ if (alive) setState(next);
6583
+ });
6584
+ }
6585
+ return {
6586
+ loading,
6587
+ state,
6588
+ available: () => state()?.available === true,
6589
+ phone: () => state()?.phone ?? null,
6590
+ consented: () => state()?.consented === true,
6591
+ optedOutByStop: () => state()?.optedOutByStop === true,
6592
+ fromNumber: () => state()?.fromNumber,
6593
+ events: () => state()?.events ?? [],
6594
+ showEvents: () => state()?.consented === true && state()?.optedOutByStop !== true,
6595
+ consentOffer: offer,
6596
+ busy,
6597
+ error,
6598
+ notice: currentNotice,
6599
+ reload,
6600
+ setPhone,
6601
+ optIn,
6602
+ optOut,
6603
+ setEvent
6604
+ };
6605
+ }
6606
+
6373
6607
  export {
6374
6608
  isQuestionVisible,
6375
6609
  useSurveyFlow,
@@ -6393,6 +6627,10 @@ export {
6393
6627
  formatCvv,
6394
6628
  useCheckoutFlow,
6395
6629
  useCartCheckoutFlow,
6630
+ PHONE_ERROR,
6631
+ isValidUsPhone,
6632
+ formatUsPhone,
6633
+ useSmsConsent,
6396
6634
  useSignupFlow,
6397
6635
  useRegisterFlow,
6398
6636
  TERMINAL_SUBSCRIPTION_STATUSES,
@@ -6512,6 +6750,7 @@ export {
6512
6750
  buildSaveBody,
6513
6751
  pharmacyIsOnProduct,
6514
6752
  classifyAddPharmacyError,
6515
- useAddPharmacy
6753
+ useAddPharmacy,
6754
+ useSmsPreferences
6516
6755
  };
6517
- //# sourceMappingURL=23TRH45I.jsx.map
6756
+ //# sourceMappingURL=FL3DS5WN.jsx.map