@apextelemed/partner-core 0.25.0-dev.91 → 0.25.1

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.
@@ -848,19 +848,176 @@ function catalogUnavailableMessage(itemName, state) {
848
848
  }
849
849
 
850
850
  // src/flows/checkout.ts
851
- import { createSignal as createSignal5, createEffect as createEffect3, onMount as onMount3 } from "solid-js";
851
+ import { createSignal as createSignal5, createEffect as createEffect4, onMount as onMount3 } from "solid-js";
852
852
 
853
853
  // src/flows/_internal/cardTokenizer.ts
854
- import { createSignal as createSignal4, onMount as onMount2, onCleanup as onCleanup2 } from "solid-js";
854
+ import { createSignal as createSignal4, createEffect as createEffect3, onMount as onMount2, onCleanup as onCleanup2 } from "solid-js";
855
+ var collectJsLoad = null;
856
+ function loadCollectJs(src, tokenizationKey) {
857
+ if (collectJsLoad?.src === src) return collectJsLoad.promise;
858
+ const promise = new Promise((resolve, reject) => {
859
+ if (typeof document === "undefined") {
860
+ reject(new Error("No document"));
861
+ return;
862
+ }
863
+ const script = document.createElement("script");
864
+ script.src = src;
865
+ script.async = true;
866
+ script.dataset.tokenizationKey = tokenizationKey;
867
+ script.dataset.variant = "inline";
868
+ script.onload = () => window.CollectJS ? resolve(window.CollectJS) : reject(new Error("Collect.js loaded without CollectJS"));
869
+ script.onerror = () => reject(new Error("Collect.js failed to load"));
870
+ document.head.appendChild(script);
871
+ });
872
+ collectJsLoad = { src, promise };
873
+ promise.catch(() => {
874
+ if (collectJsLoad?.promise === promise) collectJsLoad = null;
875
+ });
876
+ return promise;
877
+ }
878
+ var hostedFieldSeq = 0;
879
+ function selectorFor(el) {
880
+ if (!el.id) el.id = `apc-hosted-card-${++hostedFieldSeq}`;
881
+ const escape = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape : (s) => s.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
882
+ return `#${escape(el.id)}`;
883
+ }
884
+ var FIELD_ORDER = ["ccnumber", "ccexp", "cvv"];
885
+ var FIELD_LABEL = {
886
+ ccnumber: "card number",
887
+ ccexp: "expiration date",
888
+ cvv: "CVV"
889
+ };
890
+ var OUR_FIELD = { ccnumber: "number", ccexp: "expiry", cvv: "cvv" };
891
+ var GENERIC_FONTS = /^(serif|sans-serif|monospace|cursive|fantasy|system-ui|math|emoji|fangsong|inherit|initial|-apple-system|blinkmacsystemfont|ui-[a-z-]+)$/i;
892
+ function googleFontFor(fontFamily, fontWeight) {
893
+ const first = fontFamily.split(",")[0]?.trim().replace(/^['"]|['"]$/g, "");
894
+ if (!first || GENERIC_FONTS.test(first)) return void 0;
895
+ const weight = /^\d{3}$/.test(fontWeight) ? fontWeight : "400";
896
+ return `${first}:${weight}`;
897
+ }
898
+ function cssVar(cs, names, fallback) {
899
+ for (const n of names) {
900
+ const v = cs?.getPropertyValue(n).trim();
901
+ if (v) return v;
902
+ }
903
+ return fallback;
904
+ }
905
+ var NO_OUTLINE = { "outline-style": "none", "outline-width": "0", "outline-color": "transparent" };
906
+ var COLLECT_TIMEOUT_MS = 2e4;
855
907
  function useCardTokenizer() {
856
908
  const [config, setConfig] = createSignal4(null);
857
909
  const [scriptLoaded, setScriptLoaded] = createSignal4(false);
858
910
  const [error, setError] = createSignal4(null);
911
+ const [collectJs, setCollectJs] = createSignal4(null);
912
+ const [hostedEls, setHostedEls] = createSignal4({});
913
+ const [hostedFieldsLive, setHostedFieldsLive] = createSignal4(false);
914
+ let pendingNmi = null;
915
+ const invalidDuringSubmit = /* @__PURE__ */ new Map();
916
+ let invalidReport = null;
917
+ const hostedFields = () => config()?.provider === "nmi";
859
918
  const ready = () => {
860
919
  const cfg = config();
861
920
  if (!cfg) return false;
862
- return cfg.provider === "authorizenet" ? scriptLoaded() : true;
921
+ if (cfg.provider === "authorizenet") return scriptLoaded();
922
+ if (cfg.provider === "nmi") return hostedFieldsLive();
923
+ return true;
863
924
  };
925
+ const listeners = /* @__PURE__ */ new Map();
926
+ function registerHostedField(field, el) {
927
+ if (!el) return;
928
+ if (!listeners.has(el)) {
929
+ const onFocus = () => el.setAttribute("data-focused", "");
930
+ const onBlur = () => el.removeAttribute("data-focused");
931
+ el.addEventListener("focus", onFocus, true);
932
+ el.addEventListener("blur", onBlur, true);
933
+ listeners.set(el, () => {
934
+ el.removeEventListener("focus", onFocus, true);
935
+ el.removeEventListener("blur", onBlur, true);
936
+ });
937
+ }
938
+ setHostedEls((prev) => prev[field] === el ? prev : { ...prev, [field]: el });
939
+ }
940
+ onCleanup2(() => {
941
+ for (const off of listeners.values()) off();
942
+ listeners.clear();
943
+ });
944
+ function settleNmi(outcome) {
945
+ const p = pendingNmi;
946
+ if (!p) return;
947
+ pendingNmi = null;
948
+ if (invalidReport) clearTimeout(invalidReport);
949
+ invalidReport = null;
950
+ invalidDuringSubmit.clear();
951
+ clearTimeout(p.timer);
952
+ if ("token" in outcome) p.resolve(outcome.token);
953
+ else p.reject(outcome.error);
954
+ }
955
+ createEffect3(() => {
956
+ const cj = collectJs();
957
+ const els = hostedEls();
958
+ if (!cj || !els.number || !els.expiry || !els.cvv) return;
959
+ setHostedFieldsLive(false);
960
+ try {
961
+ const cs = typeof getComputedStyle === "function" ? getComputedStyle(els.number) : null;
962
+ const text = cs ? { color: cs.color, "font-size": cs.fontSize, "font-family": cs.fontFamily, "font-weight": cs.fontWeight } : {};
963
+ const googleFont = cs ? googleFontFor(cs.fontFamily, cs.fontWeight) : void 0;
964
+ const danger = cssVar(cs, ["--apc-card-danger", "--app-flow-danger"], "#c0392b");
965
+ cj.configure({
966
+ variant: "inline",
967
+ styleSniffer: false,
968
+ ...googleFont ? { googleFont } : {},
969
+ // Collect.js keeps only the CSS properties it allows and silently drops
970
+ // the rest: the `outline` and `background` SHORTHANDS are dropped (which
971
+ // left Chrome's black focus box in the field), their longhands survive.
972
+ // The container shows focus instead (`data-focused`, set below).
973
+ customCss: { ...text, border: "none", ...NO_OUTLINE, "background-color": "transparent", padding: "0", height: "100%" },
974
+ placeholderCss: cs ? { color: cs.color, opacity: "0.4" } : {},
975
+ invalidCss: { color: danger },
976
+ validCss: {},
977
+ focusCss: { ...NO_OUTLINE, border: "none", "box-shadow": "none" },
978
+ fields: {
979
+ ccnumber: { selector: selectorFor(els.number), title: "Card number", placeholder: "1234 1234 1234 1234", enableCardBrandPreviews: false },
980
+ ccexp: { selector: selectorFor(els.expiry), title: "Expiration date", placeholder: "MM / YY" },
981
+ cvv: { display: "required", selector: selectorFor(els.cvv), title: "CVV", placeholder: "123" }
982
+ },
983
+ // Fires once every iframe has loaded and can take input.
984
+ fieldsAvailableCallback: () => setHostedFieldsLive(true),
985
+ // A field that fails Collect.js's own check (bad number, past expiry,
986
+ // empty) during a submit stops the submit: Collect.js never calls
987
+ // `callback` then, so say why instead of waiting it out.
988
+ // Collect.js reports every bad field, in no particular order (CVV
989
+ // first, seen live), so collect them for a moment and name the first
990
+ // one on screen.
991
+ validationCallback: (field, valid, message) => {
992
+ const container = hostedEls()[OUR_FIELD[field]];
993
+ if (container) {
994
+ if (valid) container.removeAttribute("data-invalid");
995
+ else container.setAttribute("data-invalid", "");
996
+ }
997
+ if (valid || !pendingNmi) return;
998
+ invalidDuringSubmit.set(field, message);
999
+ if (invalidReport) return;
1000
+ invalidReport = setTimeout(() => {
1001
+ invalidReport = null;
1002
+ const first = FIELD_ORDER.find((f) => invalidDuringSubmit.has(f)) ?? [...invalidDuringSubmit.keys()][0];
1003
+ const msg = invalidDuringSubmit.get(first) ?? "";
1004
+ invalidDuringSubmit.clear();
1005
+ const label = FIELD_LABEL[first] ?? "card details";
1006
+ settleNmi({ error: new Error(msg && !/^field is empty$/i.test(msg) ? `Check the ${label}: ${msg}` : `Enter the ${label}.`) });
1007
+ }, 30);
1008
+ },
1009
+ callback: (response) => {
1010
+ if (response?.token) settleNmi({ token: { token: response.token } });
1011
+ else settleNmi({ error: new Error("Card processing failed. Please check your card details.") });
1012
+ },
1013
+ timeoutDuration: COLLECT_TIMEOUT_MS,
1014
+ timeoutCallback: () => settleNmi({ error: new Error("The payment form took too long to respond. Please try again.") })
1015
+ });
1016
+ } catch (err) {
1017
+ fail("The secure card form could not be set up. Please refresh the page.", err);
1018
+ }
1019
+ });
1020
+ onCleanup2(() => settleNmi({ error: new Error("The payment form was closed.") }));
864
1021
  const status = () => error() ? "failed" : ready() ? "ready" : "loading";
865
1022
  function fail(userMessage, logDetail) {
866
1023
  console.warn(`[useCardTokenizer] ${userMessage}`, logDetail ?? "");
@@ -881,6 +1038,18 @@ function useCardTokenizer() {
881
1038
  setConfig({ provider: "mxmerchant" });
882
1039
  return;
883
1040
  }
1041
+ if (raw.provider === "nmi") {
1042
+ if (typeof raw.tokenizationKey !== "string" || !raw.tokenizationKey || typeof raw.collectJsUrl !== "string" || !raw.collectJsUrl) {
1043
+ fail("Payments are not fully configured for this site yet. Please contact support.");
1044
+ return;
1045
+ }
1046
+ setConfig({ provider: "nmi", tokenizationKey: raw.tokenizationKey, collectJsUrl: raw.collectJsUrl });
1047
+ loadCollectJs(raw.collectJsUrl, raw.tokenizationKey).then(
1048
+ setCollectJs,
1049
+ (err) => fail("The secure payment library could not load. Check your connection (or ad blocker) and refresh the page.", err)
1050
+ );
1051
+ return;
1052
+ }
884
1053
  if (!raw.apiLoginId || !raw.clientKey) {
885
1054
  fail("Payments are not fully configured for this site yet. Please contact support.");
886
1055
  return;
@@ -1020,13 +1189,32 @@ function useCardTokenizer() {
1020
1189
  lastMxCard = { key, token };
1021
1190
  return token;
1022
1191
  }
1192
+ function tokenizeNmi() {
1193
+ const cj = collectJs();
1194
+ if (!cj || !hostedFieldsLive()) return Promise.reject(new Error("The secure card form is still loading. Please try again in a moment."));
1195
+ if (pendingNmi) return Promise.reject(new Error("Your card is already being processed."));
1196
+ return new Promise((resolve, reject) => {
1197
+ const timer = setTimeout(
1198
+ () => settleNmi({ error: new Error("The payment form took too long to respond. Please try again.") }),
1199
+ COLLECT_TIMEOUT_MS + 5e3
1200
+ );
1201
+ pendingNmi = { resolve, reject, timer };
1202
+ try {
1203
+ cj.startPaymentRequest();
1204
+ } catch (err) {
1205
+ settleNmi({ error: new Error("Card processing failed. Please try again.") });
1206
+ console.warn("[useCardTokenizer] Collect.js startPaymentRequest threw", err);
1207
+ }
1208
+ });
1209
+ }
1023
1210
  function tokenize(card) {
1024
1211
  const cfg = config();
1025
1212
  if (!cfg) return Promise.reject(new Error("Payment configuration not loaded. Please refresh."));
1213
+ if (cfg.provider === "nmi") return tokenizeNmi();
1026
1214
  if (cfg.provider === "mxmerchant") return tokenizeMxMerchant(card);
1027
1215
  return cfg.provider === "quickbooks" ? tokenizeQuickBooks(card, cfg) : tokenizeAcceptJs(card, cfg);
1028
1216
  }
1029
- return { ready, status, error, tokenize };
1217
+ return { ready, status, error, tokenize, hostedFields, registerHostedField };
1030
1218
  }
1031
1219
 
1032
1220
  // src/flows/checkout.ts
@@ -1080,7 +1268,7 @@ function useCheckoutFlow(options = {}) {
1080
1268
  const [paymentError, setPaymentError] = createSignal5(null);
1081
1269
  const [processing, setProcessing] = createSignal5(false);
1082
1270
  const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal5(false);
1083
- createEffect3(() => {
1271
+ createEffect4(() => {
1084
1272
  address.shipping();
1085
1273
  setCorrectionAcknowledged(false);
1086
1274
  });
@@ -1185,9 +1373,11 @@ function useCheckoutFlow(options = {}) {
1185
1373
  }
1186
1374
  });
1187
1375
  function validateCard() {
1188
- if (!cardNumberRaw().replace(/\s/g, "").trim()) return "Card number is required.";
1189
- if (!expiryRaw().trim()) return "Expiration date is required.";
1190
- if (!cvvRaw().trim()) return "CVV is required.";
1376
+ if (!accept.hostedFields()) {
1377
+ if (!cardNumberRaw().replace(/\s/g, "").trim()) return "Card number is required.";
1378
+ if (!expiryRaw().trim()) return "Expiration date is required.";
1379
+ if (!cvvRaw().trim()) return "CVV is required.";
1380
+ }
1191
1381
  return null;
1192
1382
  }
1193
1383
  async function submit() {
@@ -1296,6 +1486,8 @@ function useCheckoutFlow(options = {}) {
1296
1486
  expiry: expiryRaw,
1297
1487
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
1298
1488
  cvv: cvvRaw,
1489
+ hostedCardFields: accept.hostedFields,
1490
+ registerCardField: accept.registerHostedField,
1299
1491
  setCvv: (v) => setCvvRaw(formatCvv(v)),
1300
1492
  paymentError,
1301
1493
  processing,
@@ -1305,7 +1497,7 @@ function useCheckoutFlow(options = {}) {
1305
1497
  }
1306
1498
 
1307
1499
  // src/flows/cartCheckout.ts
1308
- import { createSignal as createSignal6, createEffect as createEffect4, onMount as onMount4 } from "solid-js";
1500
+ import { createSignal as createSignal6, createEffect as createEffect5, onMount as onMount4 } from "solid-js";
1309
1501
  var memoryKeys = /* @__PURE__ */ new Map();
1310
1502
  var ATTEMPT_SCOPE = "cart";
1311
1503
  function keyStorageKey(scope) {
@@ -1343,7 +1535,7 @@ function useCartCheckoutFlow() {
1343
1535
  const [paymentError, setPaymentError] = createSignal6(null);
1344
1536
  const [processing, setProcessing] = createSignal6(false);
1345
1537
  const [correctionAcknowledged, setCorrectionAcknowledged] = createSignal6(false);
1346
- createEffect4(() => {
1538
+ createEffect5(() => {
1347
1539
  address.shipping();
1348
1540
  setCorrectionAcknowledged(false);
1349
1541
  });
@@ -1397,9 +1589,11 @@ function useCartCheckoutFlow() {
1397
1589
  setOutcome({ kind: "in_progress" });
1398
1590
  });
1399
1591
  function validateCard() {
1400
- if (!cardNumberRaw().replace(/\s/g, "").trim()) return "Card number is required.";
1401
- if (!expiryRaw().trim()) return "Expiration date is required.";
1402
- if (!cvvRaw().trim()) return "CVV is required.";
1592
+ if (!accept.hostedFields()) {
1593
+ if (!cardNumberRaw().replace(/\s/g, "").trim()) return "Card number is required.";
1594
+ if (!expiryRaw().trim()) return "Expiration date is required.";
1595
+ if (!cvvRaw().trim()) return "CVV is required.";
1596
+ }
1403
1597
  return null;
1404
1598
  }
1405
1599
  function orderMatchesSubmission(order, submitted) {
@@ -1556,6 +1750,8 @@ function useCartCheckoutFlow() {
1556
1750
  expiry: expiryRaw,
1557
1751
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
1558
1752
  cvv: cvvRaw,
1753
+ hostedCardFields: accept.hostedFields,
1754
+ registerCardField: accept.registerHostedField,
1559
1755
  setCvv: (v) => setCvvRaw(formatCvv(v)),
1560
1756
  paymentError,
1561
1757
  processing,
@@ -1578,7 +1774,7 @@ function formatUsPhone(raw) {
1578
1774
  }
1579
1775
 
1580
1776
  // src/flows/_internal/smsConsent.ts
1581
- import { createEffect as createEffect5, createSignal as createSignal7, on as on2, onCleanup as onCleanup3, onMount as onMount5 } from "solid-js";
1777
+ import { createEffect as createEffect6, createSignal as createSignal7, on as on2, onCleanup as onCleanup3, onMount as onMount5 } from "solid-js";
1582
1778
  function offerFromConfig(cfg) {
1583
1779
  if (!cfg.enabled || !cfg.consentText || !cfg.consentTextVersion) return null;
1584
1780
  return {
@@ -1611,7 +1807,7 @@ function useSmsConsent(phone, restoredVersion) {
1611
1807
  setLoaded(true);
1612
1808
  });
1613
1809
  });
1614
- createEffect5(
1810
+ createEffect6(
1615
1811
  on2(
1616
1812
  phoneOk,
1617
1813
  (ok) => {
@@ -1643,7 +1839,7 @@ function useSmsConsent(phone, restoredVersion) {
1643
1839
  }
1644
1840
 
1645
1841
  // src/flows/signup.ts
1646
- import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1842
+ import { createEffect as createEffect7, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1647
1843
  var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
1648
1844
  var MAX_RESTORABLE_STEP = 2;
1649
1845
  function draftKey() {
@@ -1706,7 +1902,7 @@ function useSignupFlow(options) {
1706
1902
  if (options.requireCart && cartIsEmpty()) setOutcome({ kind: "needs_cart" });
1707
1903
  });
1708
1904
  onMount6(() => {
1709
- createEffect6(() => {
1905
+ createEffect7(() => {
1710
1906
  saveDraft({
1711
1907
  step: step2(),
1712
1908
  firstName: firstName(),
@@ -1745,9 +1941,11 @@ function useSignupFlow(options) {
1745
1941
  if (!zip().trim()) return "ZIP code is required.";
1746
1942
  if (!/^\d{5}(-\d{4})?$/.test(zip().trim())) return "Enter a valid ZIP code.";
1747
1943
  } else if (s === 2) {
1748
- if (!cardNumberRaw().trim()) return "Card number is required.";
1749
- if (!expiryRaw().trim()) return "Expiration date is required.";
1750
- if (!cvvRaw().trim()) return "CVV is required.";
1944
+ if (!accept.hostedFields()) {
1945
+ if (!cardNumberRaw().trim()) return "Card number is required.";
1946
+ if (!expiryRaw().trim()) return "Expiration date is required.";
1947
+ if (!cvvRaw().trim()) return "CVV is required.";
1948
+ }
1751
1949
  }
1752
1950
  return null;
1753
1951
  }
@@ -1936,6 +2134,8 @@ function useSignupFlow(options) {
1936
2134
  expiry: expiryRaw,
1937
2135
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
1938
2136
  cvv: cvvRaw,
2137
+ hostedCardFields: accept.hostedFields,
2138
+ registerCardField: accept.registerHostedField,
1939
2139
  setCvv: (v) => setCvvRaw(formatCvv(v)),
1940
2140
  promoCode,
1941
2141
  setPromoCode,
@@ -1944,7 +2144,7 @@ function useSignupFlow(options) {
1944
2144
  }
1945
2145
 
1946
2146
  // src/flows/register.ts
1947
- import { createEffect as createEffect7, createSignal as createSignal9, onMount as onMount7 } from "solid-js";
2147
+ import { createEffect as createEffect8, createSignal as createSignal9, onMount as onMount7 } from "solid-js";
1948
2148
  var DRAFT_TTL_MS2 = 7 * 24 * 3600 * 1e3;
1949
2149
  var MAX_RESTORABLE_STEP2 = 1;
1950
2150
  function draftKey2() {
@@ -1999,7 +2199,7 @@ function useRegisterFlow() {
1999
2199
  setOutcome({ kind: "already_authenticated" });
2000
2200
  return;
2001
2201
  }
2002
- createEffect7(() => {
2202
+ createEffect8(() => {
2003
2203
  saveDraft2({
2004
2204
  step: step2(),
2005
2205
  firstName: firstName(),
@@ -2197,7 +2397,7 @@ function isLive(status) {
2197
2397
  }
2198
2398
 
2199
2399
  // src/flows/subscribe.ts
2200
- import { createEffect as createEffect8, createSignal as createSignal10, on as on3, onMount as onMount8 } from "solid-js";
2400
+ import { createEffect as createEffect9, createSignal as createSignal10, on as on3, onMount as onMount8 } from "solid-js";
2201
2401
  async function hasActiveSubscription() {
2202
2402
  const subsRes = await subscriptionsApi.list();
2203
2403
  return (subsRes?.subscriptions ?? []).some((s) => s.status === "active");
@@ -2326,7 +2526,7 @@ function useSubscribeFlow(options) {
2326
2526
  setQuote(estimateFromCart());
2327
2527
  }
2328
2528
  }
2329
- createEffect8(
2529
+ createEffect9(
2330
2530
  on3(
2331
2531
  () => [outcome().kind, cart_default.items(), cart_default.appliedPromo()],
2332
2532
  ([kind]) => {
@@ -2342,9 +2542,11 @@ function useSubscribeFlow(options) {
2342
2542
  );
2343
2543
  const addrErr = firstAddressError(a);
2344
2544
  if (addrErr) return addrErr;
2345
- if (!cardNumberRaw().trim()) return "Card number is required.";
2346
- if (!expiryRaw().trim()) return "Expiration date is required.";
2347
- if (!cvvRaw().trim()) return "CVV is required.";
2545
+ if (!accept.hostedFields()) {
2546
+ if (!cardNumberRaw().trim()) return "Card number is required.";
2547
+ if (!expiryRaw().trim()) return "Expiration date is required.";
2548
+ if (!cvvRaw().trim()) return "CVV is required.";
2549
+ }
2348
2550
  return null;
2349
2551
  }
2350
2552
  let awaitingAvailability = false;
@@ -2465,6 +2667,8 @@ function useSubscribeFlow(options) {
2465
2667
  expiry: expiryRaw,
2466
2668
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
2467
2669
  cvv: cvvRaw,
2670
+ hostedCardFields: accept.hostedFields,
2671
+ registerCardField: accept.registerHostedField,
2468
2672
  setCvv: (v) => setCvvRaw(formatCvv(v)),
2469
2673
  submit
2470
2674
  };
@@ -3591,7 +3795,7 @@ function useMemberPortalData() {
3591
3795
  }
3592
3796
 
3593
3797
  // src/flows/updatePaymentMethod.ts
3594
- import { createEffect as createEffect9, createSignal as createSignal11 } from "solid-js";
3798
+ import { createEffect as createEffect10, createSignal as createSignal11 } from "solid-js";
3595
3799
  function useUpdatePaymentMethodFlow(subscriptionId) {
3596
3800
  const accept = useCardTokenizer();
3597
3801
  const [cardNumber, setCardNumberRaw] = createSignal11("");
@@ -3601,7 +3805,7 @@ function useUpdatePaymentMethodFlow(subscriptionId) {
3601
3805
  const [error, setError] = createSignal11(null);
3602
3806
  const billing = useAddressPair();
3603
3807
  const [billingLoaded, setBillingLoaded] = createSignal11(false);
3604
- createEffect9(() => {
3808
+ createEffect10(() => {
3605
3809
  const id = subscriptionId();
3606
3810
  if (!id || billingLoaded()) return;
3607
3811
  void (async () => {
@@ -3625,7 +3829,8 @@ function useUpdatePaymentMethodFlow(subscriptionId) {
3625
3829
  const setCardNumber = (v) => setCardNumberRaw(formatCardNumber(v));
3626
3830
  const setExpiry = (v) => setExpiryRaw(formatExpiry(v));
3627
3831
  const setCvv = (v) => setCvvRaw(formatCvv(v));
3628
- const canSubmit = () => accept.ready() && !submitting() && cardNumber().trim().length > 0 && expiry().trim().length > 0 && cvv().trim().length > 0;
3832
+ const canSubmit = () => accept.ready() && !submitting() && // Hosted fields (NMI): the card is in the gateway's iframes, which check it on submit.
3833
+ (accept.hostedFields() || cardNumber().trim().length > 0 && expiry().trim().length > 0 && cvv().trim().length > 0);
3629
3834
  async function submit() {
3630
3835
  const id = subscriptionId();
3631
3836
  if (!id) {
@@ -3662,6 +3867,8 @@ function useUpdatePaymentMethodFlow(subscriptionId) {
3662
3867
  expiry,
3663
3868
  setExpiry,
3664
3869
  cvv,
3870
+ hostedCardFields: accept.hostedFields,
3871
+ registerCardField: accept.registerHostedField,
3665
3872
  setCvv,
3666
3873
  ready: accept.ready,
3667
3874
  submitting,
@@ -4826,7 +5033,7 @@ function offerSummaryText(o) {
4826
5033
  }
4827
5034
 
4828
5035
  // src/flows/productCatalog.ts
4829
- import { createEffect as createEffect10, createMemo as createMemo2, createSignal as createSignal14, on as on4 } from "solid-js";
5036
+ import { createEffect as createEffect11, createMemo as createMemo2, createSignal as createSignal14, on as on4 } from "solid-js";
4830
5037
  var messageOf = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
4831
5038
  function classifyCatalogError(err) {
4832
5039
  const e = err ?? {};
@@ -5107,7 +5314,7 @@ function useProductCatalogEditor(opts) {
5107
5314
  else setLoad({ kind: "blocked", message: failure.message });
5108
5315
  };
5109
5316
  const identity = createMemo2(() => `${opts.product().id}|${opts.enabled ? opts.enabled() : true}`);
5110
- createEffect10(
5317
+ createEffect11(
5111
5318
  on4(
5112
5319
  identity,
5113
5320
  () => {
@@ -5522,7 +5729,7 @@ async function createCatalogProduct(input) {
5522
5729
  }
5523
5730
 
5524
5731
  // src/flows/catalogConversion.ts
5525
- import { createEffect as createEffect11, createMemo as createMemo3, createSignal as createSignal15, on as on5, onCleanup as onCleanup5 } from "solid-js";
5732
+ import { createEffect as createEffect12, createMemo as createMemo3, createSignal as createSignal15, on as on5, onCleanup as onCleanup5 } from "solid-js";
5526
5733
  function canOfferConversion(product) {
5527
5734
  const id = product.apexDrugId;
5528
5735
  return typeof id === "string" && id.length > 0 && !isCatalogItemId(id) && !product.catalogOverlay;
@@ -5747,7 +5954,7 @@ function useCatalogConversion(opts) {
5747
5954
  await load(preview() ? "refresh" : "initial");
5748
5955
  };
5749
5956
  const identity = createMemo3(() => `${opts.product().id}|${enabled()}`);
5750
- createEffect11(
5957
+ createEffect12(
5751
5958
  on5(identity, () => {
5752
5959
  generation += 1;
5753
5960
  stopTimer();
@@ -6805,4 +7012,4 @@ export {
6805
7012
  useAddPharmacy,
6806
7013
  useSmsPreferences
6807
7014
  };
6808
- //# sourceMappingURL=HGKZ6FBS.jsx.map
7015
+ //# sourceMappingURL=6MPJIVNJ.jsx.map
@@ -1,5 +1,5 @@
1
1
  import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './WCBIY4IC.js';
2
- import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './POF64TCZ.js';
2
+ import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './LIGPTJRM.js';
3
3
  import { auth_default, cart_default } from './X4YVV27O.js';
4
4
  import { promoCodesApi, subscriptionsApi, offersApi, newIdempotencyKey, usersApi, ApiError } from './PNQNOYWY.js';
5
5
  import { getConfig } from './2IFPDU4D.js';
@@ -41,7 +41,9 @@ function useSubscriptionIntakeFlow(options) {
41
41
  const accept = useCardTokenizer();
42
42
  let restored = {};
43
43
  if (typeof window !== "undefined") restored = loadDraft();
44
- const [step, setStep] = createSignal(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
44
+ const [step, setStep] = createSignal(
45
+ auth_default.isAuthenticated() ? Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP) : 0
46
+ );
45
47
  const [error, setError] = createSignal(null);
46
48
  const [tokenizing, setTokenizing] = createSignal(false);
47
49
  const [submitting, setSubmitting] = createSignal(false);
@@ -248,9 +250,11 @@ function useSubscriptionIntakeFlow(options) {
248
250
  } else if (s === 1) {
249
251
  return firstAddressError(validateAddress(addr.shipping(), "", { enforceAvailability: true }));
250
252
  } else if (s === 2) {
251
- if (!cardNumberRaw().trim()) return "Card number is required.";
252
- if (!expiryRaw().trim()) return "Expiration date is required.";
253
- if (!cvvRaw().trim()) return "CVV is required.";
253
+ if (!accept.hostedFields()) {
254
+ if (!cardNumberRaw().trim()) return "Card number is required.";
255
+ if (!expiryRaw().trim()) return "Expiration date is required.";
256
+ if (!cvvRaw().trim()) return "CVV is required.";
257
+ }
254
258
  }
255
259
  return null;
256
260
  }
@@ -270,6 +274,12 @@ function useSubscriptionIntakeFlow(options) {
270
274
  let awaitingAvailability = false;
271
275
  async function submit() {
272
276
  if (awaitingAvailability) return;
277
+ const accountErr = validateStep(0);
278
+ if (accountErr) {
279
+ setStep(0);
280
+ setError(accountErr);
281
+ return;
282
+ }
273
283
  awaitingAvailability = true;
274
284
  try {
275
285
  await availability.settled();
@@ -447,6 +457,8 @@ function useSubscriptionIntakeFlow(options) {
447
457
  expiry: expiryRaw,
448
458
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
449
459
  cvv: cvvRaw,
460
+ hostedCardFields: accept.hostedFields,
461
+ registerCardField: accept.registerHostedField,
450
462
  setCvv: (v) => setCvvRaw(formatCvv(v)),
451
463
  promoCode,
452
464
  setPromoCode,
@@ -613,5 +625,5 @@ function startCartCapture(opts = {}) {
613
625
  }
614
626
 
615
627
  export { OFFER_BEATS_PROMO_NOTICE, restoreCartFromLink, startCartCapture, useSubscriptionIntakeFlow, validateResumedPromo };
616
- //# sourceMappingURL=OJV5HNJM.js.map
617
- //# sourceMappingURL=OJV5HNJM.js.map
628
+ //# sourceMappingURL=7IQKUSD5.js.map
629
+ //# sourceMappingURL=7IQKUSD5.js.map