@apextelemed/partner-core 0.7.0 → 0.9.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 (43) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/api/index.jsx +5 -3
  4. package/dist/chunk/{4SFB2SS2.jsx → 33QXG46Z.jsx} +2 -2
  5. package/dist/chunk/{J3IRPONP.js → 35C2PAUI.js} +143 -10
  6. package/dist/chunk/35C2PAUI.js.map +1 -0
  7. package/dist/chunk/{J3OK2PQA.js → 65LD7XAZ.js} +3 -3
  8. package/dist/chunk/{J3OK2PQA.js.map → 65LD7XAZ.js.map} +1 -1
  9. package/dist/chunk/{UPZPR5TU.js → 75B7QHIN.js} +32 -7
  10. package/dist/chunk/75B7QHIN.js.map +1 -0
  11. package/dist/chunk/{64RJJFEH.js → AJR7CBZ3.js} +3 -3
  12. package/dist/chunk/{64RJJFEH.js.map → AJR7CBZ3.js.map} +1 -1
  13. package/dist/chunk/{SHXH72AC.jsx → C7RXQWXM.jsx} +24 -5
  14. package/dist/chunk/{CBOGAYTL.jsx → DEDIHIWD.jsx} +2 -2
  15. package/dist/chunk/{7AMVRNYX.jsx → IYLVDYRI.jsx} +1591 -819
  16. package/dist/chunk/{KXO4U2C6.js → JOX6EJMB.js} +23 -6
  17. package/dist/chunk/JOX6EJMB.js.map +1 -0
  18. package/dist/chunk/{F34QLV7Z.js → MCSS436N.js} +1816 -754
  19. package/dist/chunk/MCSS436N.js.map +1 -0
  20. package/dist/chunk/{4S4MTN2K.jsx → MUEGVUP2.jsx} +2 -2
  21. package/dist/chunk/{7AFUT5S3.jsx → NTYUIUQO.jsx} +31 -5
  22. package/dist/chunk/{PA66KUAU.jsx → VKSLQCMA.jsx} +251 -110
  23. package/dist/chunk/{GODF2NJN.js → Y2VD7NYA.js} +3 -3
  24. package/dist/chunk/{GODF2NJN.js.map → Y2VD7NYA.js.map} +1 -1
  25. package/dist/{client-CiHb-dIf.d.ts → client-RY9ghN5Q.d.ts} +80 -5
  26. package/dist/flows/index.d.ts +91 -7
  27. package/dist/flows/index.js +6 -6
  28. package/dist/flows/index.jsx +12 -6
  29. package/dist/index/index.d.ts +2 -2
  30. package/dist/index/index.js +7 -7
  31. package/dist/index/index.jsx +15 -7
  32. package/dist/pages/index.d.ts +2 -2
  33. package/dist/pages/index.js +5 -5
  34. package/dist/pages/index.jsx +5 -5
  35. package/dist/stores/index.d.ts +1 -1
  36. package/dist/stores/index.js +2 -2
  37. package/dist/stores/index.jsx +2 -2
  38. package/dist/theme/admin.css +262 -0
  39. package/package.json +4 -1
  40. package/dist/chunk/F34QLV7Z.js.map +0 -1
  41. package/dist/chunk/J3IRPONP.js.map +0 -1
  42. package/dist/chunk/KXO4U2C6.js.map +0 -1
  43. package/dist/chunk/UPZPR5TU.js.map +0 -1
@@ -6,19 +6,20 @@ import {
6
6
  readResumeToken,
7
7
  saveFunnelDraft,
8
8
  stripResumeToken
9
- } from "./4SFB2SS2.jsx";
9
+ } from "./33QXG46Z.jsx";
10
10
  import {
11
11
  affiliateAuth_default,
12
12
  auth_default,
13
13
  cart_default,
14
14
  medication_default
15
- } from "./4S4MTN2K.jsx";
15
+ } from "./MUEGVUP2.jsx";
16
16
  import {
17
17
  ApiError,
18
18
  addressesApi,
19
19
  affiliatePortalApi,
20
20
  apexApi,
21
21
  authApi,
22
+ catalogApi,
22
23
  membersApi,
23
24
  messagesApi,
24
25
  newIdempotencyKey,
@@ -28,7 +29,7 @@ import {
28
29
  subscriptionsApi,
29
30
  supportApi,
30
31
  usersApi
31
- } from "./7AFUT5S3.jsx";
32
+ } from "./NTYUIUQO.jsx";
32
33
  import {
33
34
  getConfig
34
35
  } from "./LDZIUFDM.jsx";
@@ -758,15 +759,97 @@ function useAddressPair(options = {}) {
758
759
  };
759
760
  }
760
761
 
762
+ // src/flows/catalogAvailability.ts
763
+ import { createEffect as createEffect2, createSignal as createSignal3, on, onCleanup } from "solid-js";
764
+ var DEBOUNCE_MS = 300;
765
+ var STATE_RE = /^[A-Za-z]{2}$/;
766
+ var INERT_DECISION = {
767
+ unavailableIds: [],
768
+ blocking: false,
769
+ degraded: false
770
+ };
771
+ function deriveCatalogAvailabilityDecision(result) {
772
+ if (!result) return INERT_DECISION;
773
+ if (result.degraded === true) return { ...INERT_DECISION, degraded: true };
774
+ const unavailableIds = result.items.filter((item) => item.checked && item.available === false).map((item) => item.id);
775
+ return { unavailableIds, blocking: unavailableIds.length > 0, degraded: false };
776
+ }
777
+ function useCatalogAvailability(ids, state) {
778
+ const [loading, setLoading] = createSignal3(false);
779
+ const [unavailableIds, setUnavailableIds] = createSignal3([]);
780
+ const [degraded, setDegraded] = createSignal3(false);
781
+ let generation = 0;
782
+ let timer;
783
+ let pending = null;
784
+ function markPending() {
785
+ if (pending) return;
786
+ let resolve;
787
+ const promise = new Promise((r) => resolve = r);
788
+ pending = { promise, resolve };
789
+ }
790
+ function markSettled() {
791
+ pending?.resolve();
792
+ pending = null;
793
+ }
794
+ function settleInert() {
795
+ setLoading(false);
796
+ setUnavailableIds([]);
797
+ setDegraded(false);
798
+ markSettled();
799
+ }
800
+ createEffect2(
801
+ on([ids, state], ([currentIds, currentState]) => {
802
+ if (timer) clearTimeout(timer);
803
+ const requestedIds = [...new Set(currentIds.map((id) => id.trim()).filter(Boolean))];
804
+ const normalizedState = (currentState ?? "").trim().toUpperCase();
805
+ const gen = ++generation;
806
+ if (requestedIds.length === 0 || !STATE_RE.test(normalizedState)) {
807
+ settleInert();
808
+ return;
809
+ }
810
+ setLoading(true);
811
+ markPending();
812
+ timer = setTimeout(() => {
813
+ catalogApi.availability(requestedIds, normalizedState).then((result) => {
814
+ if (gen !== generation) return;
815
+ const decision = deriveCatalogAvailabilityDecision(result);
816
+ setUnavailableIds(decision.unavailableIds);
817
+ setDegraded(decision.degraded);
818
+ }).catch(() => {
819
+ if (gen !== generation) return;
820
+ setUnavailableIds([]);
821
+ setDegraded(false);
822
+ }).finally(() => {
823
+ if (gen !== generation) return;
824
+ setLoading(false);
825
+ markSettled();
826
+ });
827
+ }, DEBOUNCE_MS);
828
+ })
829
+ );
830
+ onCleanup(() => {
831
+ if (timer) clearTimeout(timer);
832
+ generation++;
833
+ markSettled();
834
+ });
835
+ const blocking = () => !degraded() && unavailableIds().length > 0;
836
+ const isUnavailable = (id) => unavailableIds().includes(id);
837
+ const settled = () => pending?.promise ?? Promise.resolve();
838
+ return { loading, blocking, degraded, unavailableIds, isUnavailable, settled };
839
+ }
840
+ function catalogUnavailableMessage(itemName, state) {
841
+ return `${itemName} isn\u2019t available for delivery to ${stateLabel(state)}.`;
842
+ }
843
+
761
844
  // src/flows/checkout.ts
762
- import { createSignal as createSignal4, createEffect as createEffect2, onMount as onMount3 } from "solid-js";
845
+ import { createSignal as createSignal5, createEffect as createEffect3, onMount as onMount3 } from "solid-js";
763
846
 
764
847
  // src/flows/_internal/cardTokenizer.ts
765
- import { createSignal as createSignal3, onMount as onMount2, onCleanup } from "solid-js";
848
+ import { createSignal as createSignal4, onMount as onMount2, onCleanup as onCleanup2 } from "solid-js";
766
849
  function useCardTokenizer() {
767
- const [config, setConfig] = createSignal3(null);
768
- const [scriptLoaded, setScriptLoaded] = createSignal3(false);
769
- const [error, setError] = createSignal3(null);
850
+ const [config, setConfig] = createSignal4(null);
851
+ const [scriptLoaded, setScriptLoaded] = createSignal4(false);
852
+ const [error, setError] = createSignal4(null);
770
853
  const ready = () => {
771
854
  const cfg = config();
772
855
  if (!cfg) return false;
@@ -819,7 +902,7 @@ function useCardTokenizer() {
819
902
  "The secure payment library could not load. Check your connection (or ad blocker) and refresh the page."
820
903
  );
821
904
  document.head.appendChild(script);
822
- onCleanup(() => {
905
+ onCleanup2(() => {
823
906
  script.onload = null;
824
907
  script.onerror = null;
825
908
  });
@@ -918,17 +1001,17 @@ function formatCvv(raw) {
918
1001
  function useCheckoutFlow(options = {}) {
919
1002
  const accept = useCardTokenizer();
920
1003
  const address = useAddressPair();
921
- const [outcome, setOutcome] = createSignal4({ kind: "loading" });
922
- const [profile, setProfile] = createSignal4(null);
923
- const [prescription, setPrescription] = createSignal4(null);
924
- const [hasPaymentMethod, setHasPaymentMethod] = createSignal4(false);
925
- const [cardNumberRaw, setCardNumberRaw] = createSignal4("", { equals: false });
926
- const [expiryRaw, setExpiryRaw] = createSignal4("", { equals: false });
927
- const [cvvRaw, setCvvRaw] = createSignal4("", { equals: false });
928
- const [paymentError, setPaymentError] = createSignal4(null);
929
- const [processing, setProcessing] = createSignal4(false);
930
- const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal4(false);
931
- createEffect2(() => {
1004
+ const [outcome, setOutcome] = createSignal5({ kind: "loading" });
1005
+ const [profile, setProfile] = createSignal5(null);
1006
+ const [prescription, setPrescription] = createSignal5(null);
1007
+ const [hasPaymentMethod, setHasPaymentMethod] = createSignal5(false);
1008
+ const [cardNumberRaw, setCardNumberRaw] = createSignal5("", { equals: false });
1009
+ const [expiryRaw, setExpiryRaw] = createSignal5("", { equals: false });
1010
+ const [cvvRaw, setCvvRaw] = createSignal5("", { equals: false });
1011
+ const [paymentError, setPaymentError] = createSignal5(null);
1012
+ const [processing, setProcessing] = createSignal5(false);
1013
+ const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal5(false);
1014
+ createEffect3(() => {
932
1015
  address.shipping();
933
1016
  setCorrectionAcknowledged(false);
934
1017
  });
@@ -965,7 +1048,14 @@ function useCheckoutFlow(options = {}) {
965
1048
  promoCode: cart_default.appliedPromo()?.code
966
1049
  };
967
1050
  };
968
- const canSubmit = () => hasPaymentMethod() || accept.ready();
1051
+ const availability = useCatalogAvailability(
1052
+ () => {
1053
+ const drugId = prescription()?.drugId;
1054
+ return drugId ? [drugId] : [];
1055
+ },
1056
+ () => address.shipping().state
1057
+ );
1058
+ const canSubmit = () => (hasPaymentMethod() || accept.ready()) && !availability.blocking();
969
1059
  onMount3(async () => {
970
1060
  try {
971
1061
  const [profileRes, subsRes] = await Promise.all([
@@ -1040,6 +1130,11 @@ function useCheckoutFlow(options = {}) {
1040
1130
  setPaymentError("Missing medication details.");
1041
1131
  return;
1042
1132
  }
1133
+ await availability.settled();
1134
+ if (availability.blocking()) {
1135
+ setPaymentError(catalogUnavailableMessage(rx.drugName || "This medication", address.shipping().state));
1136
+ return;
1137
+ }
1043
1138
  if (!address.validate()) {
1044
1139
  const badShipping = hasErrors(address.shippingErrors());
1045
1140
  const badBilling = hasErrors(address.billingErrors());
@@ -1119,6 +1214,7 @@ function useCheckoutFlow(options = {}) {
1119
1214
  outcome,
1120
1215
  profile,
1121
1216
  address,
1217
+ availability,
1122
1218
  pricing,
1123
1219
  hasPaymentMethod,
1124
1220
  tokenizerReady: accept.ready,
@@ -1139,7 +1235,7 @@ function useCheckoutFlow(options = {}) {
1139
1235
  }
1140
1236
 
1141
1237
  // src/flows/cartCheckout.ts
1142
- import { createSignal as createSignal5, createEffect as createEffect3, onMount as onMount4 } from "solid-js";
1238
+ import { createSignal as createSignal6, createEffect as createEffect4, onMount as onMount4 } from "solid-js";
1143
1239
  var memoryKeys = /* @__PURE__ */ new Map();
1144
1240
  var ATTEMPT_SCOPE = "cart";
1145
1241
  function keyStorageKey(scope) {
@@ -1169,20 +1265,24 @@ function clearAttemptKey(scope) {
1169
1265
  function useCartCheckoutFlow() {
1170
1266
  const accept = useCardTokenizer();
1171
1267
  const address = useAddressPair();
1172
- const [outcome, setOutcome] = createSignal5({ kind: "loading" });
1173
- const [profile, setProfile] = createSignal5(null);
1174
- const [cardNumberRaw, setCardNumberRaw] = createSignal5("", { equals: false });
1175
- const [expiryRaw, setExpiryRaw] = createSignal5("", { equals: false });
1176
- const [cvvRaw, setCvvRaw] = createSignal5("", { equals: false });
1177
- const [paymentError, setPaymentError] = createSignal5(null);
1178
- const [processing, setProcessing] = createSignal5(false);
1179
- const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal5(false);
1180
- createEffect3(() => {
1268
+ const [outcome, setOutcome] = createSignal6({ kind: "loading" });
1269
+ const [profile, setProfile] = createSignal6(null);
1270
+ const [cardNumberRaw, setCardNumberRaw] = createSignal6("", { equals: false });
1271
+ const [expiryRaw, setExpiryRaw] = createSignal6("", { equals: false });
1272
+ const [cvvRaw, setCvvRaw] = createSignal6("", { equals: false });
1273
+ const [paymentError, setPaymentError] = createSignal6(null);
1274
+ const [processing, setProcessing] = createSignal6(false);
1275
+ const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal6(false);
1276
+ createEffect4(() => {
1181
1277
  address.shipping();
1182
1278
  setCorrectionAcknowledged(false);
1183
1279
  });
1184
1280
  const items = () => cart_default.items().filter((i) => i.isSubscription !== true);
1185
1281
  const skippedSubscriptionItems = () => cart_default.items().filter((i) => i.isSubscription === true);
1282
+ const availability = useCatalogAvailability(
1283
+ () => items().map((i) => i.productId),
1284
+ () => address.shipping().state
1285
+ );
1186
1286
  const pricing = () => {
1187
1287
  const subtotalCents = items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);
1188
1288
  const promo = cart_default.appliedPromo();
@@ -1200,7 +1300,7 @@ function useCartCheckoutFlow() {
1200
1300
  promoCode: promo?.code
1201
1301
  };
1202
1302
  };
1203
- const canSubmit = () => accept.ready();
1303
+ const canSubmit = () => accept.ready() && !availability.blocking();
1204
1304
  onMount4(async () => {
1205
1305
  if (!auth_default.isAuthenticated()) {
1206
1306
  setOutcome({ kind: "needs_auth" });
@@ -1269,6 +1369,13 @@ function useCartCheckoutFlow() {
1269
1369
  setOutcome({ kind: "needs_cart" });
1270
1370
  return;
1271
1371
  }
1372
+ await availability.settled();
1373
+ if (availability.blocking()) {
1374
+ setPaymentError(
1375
+ "One or more items in your cart aren\u2019t available for delivery to your address. Please remove them or update your shipping state."
1376
+ );
1377
+ return;
1378
+ }
1272
1379
  if (!address.validate()) {
1273
1380
  const badShipping = hasErrors(address.shippingErrors());
1274
1381
  const badBilling = hasErrors(address.billingErrors());
@@ -1367,6 +1474,7 @@ function useCartCheckoutFlow() {
1367
1474
  address,
1368
1475
  items,
1369
1476
  skippedSubscriptionItems,
1477
+ availability,
1370
1478
  pricing,
1371
1479
  tokenizerReady: accept.ready,
1372
1480
  acceptJsLoaded: accept.ready,
@@ -1386,7 +1494,7 @@ function useCartCheckoutFlow() {
1386
1494
  }
1387
1495
 
1388
1496
  // src/flows/signup.ts
1389
- import { createEffect as createEffect4, createSignal as createSignal6, onMount as onMount5 } from "solid-js";
1497
+ import { createEffect as createEffect5, createSignal as createSignal7, onMount as onMount5 } from "solid-js";
1390
1498
  var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
1391
1499
  var MAX_RESTORABLE_STEP = 2;
1392
1500
  function draftKey() {
@@ -1422,33 +1530,33 @@ function useSignupFlow(options) {
1422
1530
  const accept = useCardTokenizer();
1423
1531
  let restored = {};
1424
1532
  if (typeof window !== "undefined") restored = loadDraft();
1425
- const [step2, setStep] = createSignal6(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
1426
- const [error, setError] = createSignal6(null);
1427
- const [tokenizing, setTokenizing] = createSignal6(false);
1428
- const [submitting, setSubmitting] = createSignal6(false);
1429
- const [outcome, setOutcome] = createSignal6({ kind: "in_progress" });
1430
- const [firstName, setFirstName] = createSignal6(restored.firstName ?? "");
1431
- const [lastName, setLastName] = createSignal6(restored.lastName ?? "");
1432
- const [email, setEmail] = createSignal6(restored.email ?? "");
1433
- const [password, setPassword] = createSignal6("");
1434
- const [dateOfBirth, setDateOfBirth] = createSignal6(restored.dateOfBirth ?? "");
1435
- const [phone, setPhone] = createSignal6(restored.phone ?? "");
1436
- const [street, setStreet] = createSignal6(restored.street ?? "");
1437
- const [city, setCity] = createSignal6(restored.city ?? "");
1438
- const [state, setState] = createSignal6(restored.state ?? "");
1439
- const [zip, setZip] = createSignal6(restored.zip ?? "");
1440
- const [cardNumberRaw, setCardNumberRaw] = createSignal6("", { equals: false });
1441
- const [expiryRaw, setExpiryRaw] = createSignal6("", { equals: false });
1442
- const [cvvRaw, setCvvRaw] = createSignal6("", { equals: false });
1443
- const [tokenizedData, setTokenizedData] = createSignal6(null);
1444
- const [promoCode, setPromoCode] = createSignal6("");
1445
- const [idempotencyKey, setIdempotencyKey] = createSignal6(newIdempotencyKey());
1533
+ const [step2, setStep] = createSignal7(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
1534
+ const [error, setError] = createSignal7(null);
1535
+ const [tokenizing, setTokenizing] = createSignal7(false);
1536
+ const [submitting, setSubmitting] = createSignal7(false);
1537
+ const [outcome, setOutcome] = createSignal7({ kind: "in_progress" });
1538
+ const [firstName, setFirstName] = createSignal7(restored.firstName ?? "");
1539
+ const [lastName, setLastName] = createSignal7(restored.lastName ?? "");
1540
+ const [email, setEmail] = createSignal7(restored.email ?? "");
1541
+ const [password, setPassword] = createSignal7("");
1542
+ const [dateOfBirth, setDateOfBirth] = createSignal7(restored.dateOfBirth ?? "");
1543
+ const [phone, setPhone] = createSignal7(restored.phone ?? "");
1544
+ const [street, setStreet] = createSignal7(restored.street ?? "");
1545
+ const [city, setCity] = createSignal7(restored.city ?? "");
1546
+ const [state, setState] = createSignal7(restored.state ?? "");
1547
+ const [zip, setZip] = createSignal7(restored.zip ?? "");
1548
+ const [cardNumberRaw, setCardNumberRaw] = createSignal7("", { equals: false });
1549
+ const [expiryRaw, setExpiryRaw] = createSignal7("", { equals: false });
1550
+ const [cvvRaw, setCvvRaw] = createSignal7("", { equals: false });
1551
+ const [tokenizedData, setTokenizedData] = createSignal7(null);
1552
+ const [promoCode, setPromoCode] = createSignal7("");
1553
+ const [idempotencyKey, setIdempotencyKey] = createSignal7(newIdempotencyKey());
1446
1554
  const cartIsEmpty = () => cart_default.items().length === 0;
1447
1555
  onMount5(() => {
1448
1556
  if (options.requireCart && cartIsEmpty()) setOutcome({ kind: "needs_cart" });
1449
1557
  });
1450
1558
  onMount5(() => {
1451
- createEffect4(() => {
1559
+ createEffect5(() => {
1452
1560
  saveDraft({
1453
1561
  step: step2(),
1454
1562
  firstName: firstName(),
@@ -1680,7 +1788,7 @@ function useSignupFlow(options) {
1680
1788
  }
1681
1789
 
1682
1790
  // src/flows/register.ts
1683
- import { createEffect as createEffect5, createSignal as createSignal7, onMount as onMount6 } from "solid-js";
1791
+ import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1684
1792
  var DRAFT_TTL_MS2 = 7 * 24 * 3600 * 1e3;
1685
1793
  var MAX_RESTORABLE_STEP2 = 1;
1686
1794
  function draftKey2() {
@@ -1715,26 +1823,26 @@ function clearDraft2() {
1715
1823
  function useRegisterFlow() {
1716
1824
  let restored = {};
1717
1825
  if (typeof window !== "undefined") restored = loadDraft2();
1718
- const [step2, setStep] = createSignal7(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP2));
1719
- const [error, setError] = createSignal7(null);
1720
- const [submitting, setSubmitting] = createSignal7(false);
1721
- const [outcome, setOutcome] = createSignal7({ kind: "in_progress" });
1722
- const [firstName, setFirstName] = createSignal7(restored.firstName ?? "");
1723
- const [lastName, setLastName] = createSignal7(restored.lastName ?? "");
1724
- const [email, setEmail] = createSignal7(restored.email ?? "");
1725
- const [password, setPassword] = createSignal7("");
1726
- const [dateOfBirth, setDateOfBirth] = createSignal7(restored.dateOfBirth ?? "");
1727
- const [phone, setPhone] = createSignal7(restored.phone ?? "");
1728
- const [street, setStreet] = createSignal7(restored.street ?? "");
1729
- const [city, setCity] = createSignal7(restored.city ?? "");
1730
- const [state, setState] = createSignal7(restored.state ?? "");
1731
- const [zip, setZip] = createSignal7(restored.zip ?? "");
1826
+ const [step2, setStep] = createSignal8(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP2));
1827
+ const [error, setError] = createSignal8(null);
1828
+ const [submitting, setSubmitting] = createSignal8(false);
1829
+ const [outcome, setOutcome] = createSignal8({ kind: "in_progress" });
1830
+ const [firstName, setFirstName] = createSignal8(restored.firstName ?? "");
1831
+ const [lastName, setLastName] = createSignal8(restored.lastName ?? "");
1832
+ const [email, setEmail] = createSignal8(restored.email ?? "");
1833
+ const [password, setPassword] = createSignal8("");
1834
+ const [dateOfBirth, setDateOfBirth] = createSignal8(restored.dateOfBirth ?? "");
1835
+ const [phone, setPhone] = createSignal8(restored.phone ?? "");
1836
+ const [street, setStreet] = createSignal8(restored.street ?? "");
1837
+ const [city, setCity] = createSignal8(restored.city ?? "");
1838
+ const [state, setState] = createSignal8(restored.state ?? "");
1839
+ const [zip, setZip] = createSignal8(restored.zip ?? "");
1732
1840
  onMount6(() => {
1733
1841
  if (auth_default.isAuthenticated()) {
1734
1842
  setOutcome({ kind: "already_authenticated" });
1735
1843
  return;
1736
1844
  }
1737
- createEffect5(() => {
1845
+ createEffect6(() => {
1738
1846
  saveDraft2({
1739
1847
  step: step2(),
1740
1848
  firstName: firstName(),
@@ -1927,7 +2035,7 @@ function isLive(status) {
1927
2035
  }
1928
2036
 
1929
2037
  // src/flows/subscribe.ts
1930
- import { createEffect as createEffect6, createSignal as createSignal8, on, onMount as onMount7 } from "solid-js";
2038
+ import { createEffect as createEffect7, createSignal as createSignal9, on as on2, onMount as onMount7 } from "solid-js";
1931
2039
  async function hasActiveSubscription() {
1932
2040
  const subsRes = await subscriptionsApi.list();
1933
2041
  return (subsRes?.subscriptions ?? []).some((s) => s.status === "active");
@@ -1938,19 +2046,25 @@ async function hasReconcilableSubscription() {
1938
2046
  }
1939
2047
  function useSubscribeFlow(options) {
1940
2048
  const accept = useCardTokenizer();
1941
- const [outcome, setOutcome] = createSignal8({ kind: "loading" });
1942
- const [error, setError] = createSignal8(null);
1943
- const [submitting, setSubmitting] = createSignal8(false);
1944
- const [quote, setQuote] = createSignal8(null);
1945
- const [quoteError, setQuoteError] = createSignal8(null);
1946
- const [street, setStreet] = createSignal8("");
1947
- const [city, setCity] = createSignal8("");
1948
- const [state, setState] = createSignal8("");
1949
- const [zip, setZip] = createSignal8("");
1950
- const [cardNumberRaw, setCardNumberRaw] = createSignal8("", { equals: false });
1951
- const [expiryRaw, setExpiryRaw] = createSignal8("", { equals: false });
1952
- const [cvvRaw, setCvvRaw] = createSignal8("", { equals: false });
1953
- const [idempotencyKey, setIdempotencyKey] = createSignal8(newIdempotencyKey());
2049
+ const [outcome, setOutcome] = createSignal9({ kind: "loading" });
2050
+ const [error, setError] = createSignal9(null);
2051
+ const [submitting, setSubmitting] = createSignal9(false);
2052
+ const [quote, setQuote] = createSignal9(null);
2053
+ const [quoteError, setQuoteError] = createSignal9(null);
2054
+ const [street, setStreet] = createSignal9("");
2055
+ const [city, setCity] = createSignal9("");
2056
+ const [state, setState] = createSignal9("");
2057
+ const [zip, setZip] = createSignal9("");
2058
+ const [profileState, setProfileState] = createSignal9("");
2059
+ const shipState = () => profileState() || state();
2060
+ const availability = useCatalogAvailability(
2061
+ () => cart_default.items().map((i) => i.productId),
2062
+ shipState
2063
+ );
2064
+ const [cardNumberRaw, setCardNumberRaw] = createSignal9("", { equals: false });
2065
+ const [expiryRaw, setExpiryRaw] = createSignal9("", { equals: false });
2066
+ const [cvvRaw, setCvvRaw] = createSignal9("", { equals: false });
2067
+ const [idempotencyKey, setIdempotencyKey] = createSignal9(newIdempotencyKey());
1954
2068
  onMount7(async () => {
1955
2069
  if (!auth_default.isAuthenticated()) {
1956
2070
  setOutcome({ kind: "needs_auth" });
@@ -1974,6 +2088,7 @@ function useSubscribeFlow(options) {
1974
2088
  setStreet(p.address1 || p.street || "");
1975
2089
  setCity(p.city || "");
1976
2090
  setState(normalizeState(p.state || ""));
2091
+ setProfileState(normalizeState(p.state || ""));
1977
2092
  setZip(p.zip || "");
1978
2093
  }
1979
2094
  } catch {
@@ -2049,8 +2164,8 @@ function useSubscribeFlow(options) {
2049
2164
  setQuote(estimateFromCart());
2050
2165
  }
2051
2166
  }
2052
- createEffect6(
2053
- on(
2167
+ createEffect7(
2168
+ on2(
2054
2169
  () => [outcome().kind, cart_default.items(), cart_default.appliedPromo()],
2055
2170
  ([kind]) => {
2056
2171
  if (kind === "in_progress") void refreshQuote();
@@ -2070,6 +2185,7 @@ function useSubscribeFlow(options) {
2070
2185
  if (!cvvRaw().trim()) return "CVV is required.";
2071
2186
  return null;
2072
2187
  }
2188
+ let awaitingAvailability = false;
2073
2189
  async function submit() {
2074
2190
  if (submitting()) return;
2075
2191
  if (!auth_default.isAuthenticated()) {
@@ -2084,6 +2200,18 @@ function useSubscribeFlow(options) {
2084
2200
  setError(quoteError());
2085
2201
  return;
2086
2202
  }
2203
+ if (awaitingAvailability) return;
2204
+ awaitingAvailability = true;
2205
+ try {
2206
+ await availability.settled();
2207
+ } finally {
2208
+ awaitingAvailability = false;
2209
+ }
2210
+ if (availability.blocking()) {
2211
+ const unavailableItem = cart_default.items().find((i) => availability.isUnavailable(i.productId));
2212
+ setError(catalogUnavailableMessage(unavailableItem?.productName ?? "One of your items", shipState()));
2213
+ return;
2214
+ }
2087
2215
  const err = validate();
2088
2216
  if (err) {
2089
2217
  setError(err);
@@ -2167,6 +2295,8 @@ function useSubscribeFlow(options) {
2167
2295
  setState,
2168
2296
  zip,
2169
2297
  setZip,
2298
+ availability,
2299
+ shipState,
2170
2300
  cardNumber: cardNumberRaw,
2171
2301
  setCardNumber: (v) => setCardNumberRaw(formatCardNumber(v)),
2172
2302
  expiry: expiryRaw,
@@ -2853,6 +2983,13 @@ var JOURNEY_LABEL = {
2853
2983
  function step(key, state, date = null, detail = null, label = JOURNEY_LABEL[key]) {
2854
2984
  return { key, label, state, date, detail };
2855
2985
  }
2986
+ function intakeEvidence(o) {
2987
+ if (o.funnel.captures.length > 0) return { kind: "capture" };
2988
+ if (o.requests.items.length > 0) return { kind: "inferred", from: "a prescription request" };
2989
+ if (o.subscriptions.length > 0) return { kind: "inferred", from: "a subscription" };
2990
+ if (o.lifecycle.facts?.hasFunnelCapture) return { kind: "inferred", from: "the account record" };
2991
+ return { kind: "none" };
2992
+ }
2856
2993
  function deriveJourney(o) {
2857
2994
  const steps = [];
2858
2995
  const source = accountSource(o);
@@ -2868,7 +3005,7 @@ function deriveJourney(o) {
2868
3005
  (p) => p.createdAt
2869
3006
  )[0];
2870
3007
  steps.push(step("account", "done", o.customer.createdAt, ACCOUNT_SOURCE_LABEL[source]));
2871
- const intakeDone = !!capture || o.lifecycle.facts?.hasFunnelCapture || anySub || o.requests.items.length > 0;
3008
+ const intakeDone = intakeEvidence(o).kind !== "none";
2872
3009
  if (intakeDone) {
2873
3010
  steps.push(
2874
3011
  step(
@@ -3283,17 +3420,17 @@ function useMemberPortalData() {
3283
3420
  }
3284
3421
 
3285
3422
  // src/flows/updatePaymentMethod.ts
3286
- import { createEffect as createEffect7, createSignal as createSignal9 } from "solid-js";
3423
+ import { createEffect as createEffect8, createSignal as createSignal10 } from "solid-js";
3287
3424
  function useUpdatePaymentMethodFlow(subscriptionId) {
3288
3425
  const accept = useCardTokenizer();
3289
- const [cardNumber, setCardNumberRaw] = createSignal9("");
3290
- const [expiry, setExpiryRaw] = createSignal9("");
3291
- const [cvv, setCvvRaw] = createSignal9("");
3292
- const [submitting, setSubmitting] = createSignal9(false);
3293
- const [error, setError] = createSignal9(null);
3426
+ const [cardNumber, setCardNumberRaw] = createSignal10("");
3427
+ const [expiry, setExpiryRaw] = createSignal10("");
3428
+ const [cvv, setCvvRaw] = createSignal10("");
3429
+ const [submitting, setSubmitting] = createSignal10(false);
3430
+ const [error, setError] = createSignal10(null);
3294
3431
  const billing = useAddressPair();
3295
- const [billingLoaded, setBillingLoaded] = createSignal9(false);
3296
- createEffect7(() => {
3432
+ const [billingLoaded, setBillingLoaded] = createSignal10(false);
3433
+ createEffect8(() => {
3297
3434
  const id = subscriptionId();
3298
3435
  if (!id || billingLoaded()) return;
3299
3436
  void (async () => {
@@ -3368,7 +3505,7 @@ function useUpdatePaymentMethodFlow(subscriptionId) {
3368
3505
  }
3369
3506
 
3370
3507
  // src/flows/messages.ts
3371
- import { createSignal as createSignal10, onMount as onMount8, onCleanup as onCleanup2 } from "solid-js";
3508
+ import { createSignal as createSignal11, onMount as onMount8, onCleanup as onCleanup3 } from "solid-js";
3372
3509
 
3373
3510
  // src/flows/supportRealtime.ts
3374
3511
  var TOKEN_REFRESH_MS = 4 * 60 * 1e3;
@@ -3539,15 +3676,15 @@ function useMessagesThread(options = {}) {
3539
3676
  const conversationPollMs = options.pollIntervalMs?.conversations ?? DEFAULT_CONVERSATION_POLL_MS;
3540
3677
  const messagePollMs = options.pollIntervalMs?.messages ?? DEFAULT_MESSAGE_POLL_MS;
3541
3678
  const autoPoll = options.autoPoll !== false;
3542
- const [conversations, setConversations] = createSignal10([]);
3543
- const [selectedId, setSelectedId] = createSignal10(null);
3544
- const [messages, setMessages] = createSignal10([]);
3545
- const [draft, setDraft] = createSignal10("");
3546
- const [loadingConversations, setLoadingConversations] = createSignal10(true);
3547
- const [loadingMessages, setLoadingMessages] = createSignal10(false);
3548
- const [sending, setSending] = createSignal10(false);
3549
- const [startingThread, setStartingThread] = createSignal10(false);
3550
- const [startingCareTeamThread, setStartingCareTeamThread] = createSignal10(false);
3679
+ const [conversations, setConversations] = createSignal11([]);
3680
+ const [selectedId, setSelectedId] = createSignal11(null);
3681
+ const [messages, setMessages] = createSignal11([]);
3682
+ const [draft, setDraft] = createSignal11("");
3683
+ const [loadingConversations, setLoadingConversations] = createSignal11(true);
3684
+ const [loadingMessages, setLoadingMessages] = createSignal11(false);
3685
+ const [sending, setSending] = createSignal11(false);
3686
+ const [startingThread, setStartingThread] = createSignal11(false);
3687
+ const [startingCareTeamThread, setStartingCareTeamThread] = createSignal11(false);
3551
3688
  let pendingDeepLinkId = readDeepLinkedConversationId();
3552
3689
  let convoPollTimer;
3553
3690
  let msgPollTimer;
@@ -3847,7 +3984,7 @@ function useMessagesThread(options = {}) {
3847
3984
  }, conversationPollMs);
3848
3985
  }
3849
3986
  });
3850
- onCleanup2(() => {
3987
+ onCleanup3(() => {
3851
3988
  if (convoPollTimer) clearInterval(convoPollTimer);
3852
3989
  if (msgPollTimer) clearInterval(msgPollTimer);
3853
3990
  void stopRealtime();
@@ -3879,7 +4016,7 @@ function useMessagesThread(options = {}) {
3879
4016
  }
3880
4017
 
3881
4018
  // src/flows/products.ts
3882
- import { createMemo, createResource as createResource3, createSignal as createSignal11 } from "solid-js";
4019
+ import { createMemo, createResource as createResource3, createSignal as createSignal12 } from "solid-js";
3883
4020
  function priceForDosage(product, dosage) {
3884
4021
  const overlay = (product.dosage_prices ?? []).find((d) => d.dosage === dosage);
3885
4022
  if (overlay && overlay.price != null) return overlay.price;
@@ -3952,7 +4089,7 @@ function useProductDetail(productId) {
3952
4089
  const chosen = override && all.find((d) => d.dosage === override) || all[0];
3953
4090
  return [chosen];
3954
4091
  });
3955
- const [selectedDosage, setSelectedDosage] = createSignal11("");
4092
+ const [selectedDosage, setSelectedDosage] = createSignal12("");
3956
4093
  createMemo(() => {
3957
4094
  const opts = dosageOptions();
3958
4095
  if (opts.length > 0 && !selectedDosage()) setSelectedDosage(opts[0].dosage);
@@ -4431,6 +4568,9 @@ export {
4431
4568
  hasErrors,
4432
4569
  firstAddressError,
4433
4570
  useAddressPair,
4571
+ deriveCatalogAvailabilityDecision,
4572
+ useCatalogAvailability,
4573
+ catalogUnavailableMessage,
4434
4574
  formatCardNumber,
4435
4575
  formatExpiry,
4436
4576
  formatCvv,
@@ -4460,6 +4600,7 @@ export {
4460
4600
  accountSource,
4461
4601
  lifecycleReason,
4462
4602
  deriveAttention,
4603
+ intakeEvidence,
4463
4604
  deriveJourney,
4464
4605
  toTrackerRequest,
4465
4606
  buildTimeline,
@@ -4499,4 +4640,4 @@ export {
4499
4640
  useSurveyV2Flow,
4500
4641
  uploadPrescriptionPhoto
4501
4642
  };
4502
- //# sourceMappingURL=PA66KUAU.jsx.map
4643
+ //# sourceMappingURL=VKSLQCMA.jsx.map
@@ -1,4 +1,4 @@
1
- import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './UPZPR5TU.js';
1
+ import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './75B7QHIN.js';
2
2
  import { onConfigured, getConfig } from './5XGPFYIJ.js';
3
3
  import { createRoot, createSignal, createMemo, batch } from 'solid-js';
4
4
 
@@ -382,5 +382,5 @@ var medicationStore = createRoot(createMedicationStore);
382
382
  var medication_default = medicationStore;
383
383
 
384
384
  export { affiliateAuth_default, auth_default, cart_default, medication_default };
385
- //# sourceMappingURL=GODF2NJN.js.map
386
- //# sourceMappingURL=GODF2NJN.js.map
385
+ //# sourceMappingURL=Y2VD7NYA.js.map
386
+ //# sourceMappingURL=Y2VD7NYA.js.map