@apextelemed/partner-core 0.25.0-dev.91 → 0.26.0-dev.93

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.
@@ -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';
@@ -248,9 +248,11 @@ function useSubscriptionIntakeFlow(options) {
248
248
  } else if (s === 1) {
249
249
  return firstAddressError(validateAddress(addr.shipping(), "", { enforceAvailability: true }));
250
250
  } 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.";
251
+ if (!accept.hostedFields()) {
252
+ if (!cardNumberRaw().trim()) return "Card number is required.";
253
+ if (!expiryRaw().trim()) return "Expiration date is required.";
254
+ if (!cvvRaw().trim()) return "CVV is required.";
255
+ }
254
256
  }
255
257
  return null;
256
258
  }
@@ -447,6 +449,8 @@ function useSubscriptionIntakeFlow(options) {
447
449
  expiry: expiryRaw,
448
450
  setExpiry: (v) => setExpiryRaw(formatExpiry(v)),
449
451
  cvv: cvvRaw,
452
+ hostedCardFields: accept.hostedFields,
453
+ registerCardField: accept.registerHostedField,
450
454
  setCvv: (v) => setCvvRaw(formatCvv(v)),
451
455
  promoCode,
452
456
  setPromoCode,
@@ -613,5 +617,5 @@ function startCartCapture(opts = {}) {
613
617
  }
614
618
 
615
619
  export { OFFER_BEATS_PROMO_NOTICE, restoreCartFromLink, startCartCapture, useSubscriptionIntakeFlow, validateResumedPromo };
616
- //# sourceMappingURL=OJV5HNJM.js.map
617
- //# sourceMappingURL=OJV5HNJM.js.map
620
+ //# sourceMappingURL=T2VOCKL2.js.map
621
+ //# sourceMappingURL=T2VOCKL2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/flows/subscriptionIntake.ts","../../src/flows/cartCapture.ts"],"names":["createEffect","on"],"mappings":";;;;;;;AA0BA,IAAM,YAAA,GAAe,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAA;AACrC,IAAM,mBAAA,GAAsB,CAAA;AAsB5B,SAAS,QAAA,GAAmB;AAC1B,EAAA,OAAO,CAAA,EAAG,SAAA,EAAU,CAAE,aAAa,CAAA,0BAAA,CAAA;AACrC;AAEA,SAAS,SAAA,GAAyB;AAChC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,YAAA,CAAa,OAAA,CAAQ,QAAA,EAAU,CAAA;AAC3C,IAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,IAAI,OAAO,OAAA,IAAW,IAAA,CAAK,KAAI,GAAI,MAAA,CAAO,UAAU,YAAA,EAAc;AAChE,MAAA,YAAA,CAAa,UAAA,CAAW,UAAU,CAAA;AAClC,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,OAAO,UAAU,EAAC;AAAA,EACpB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EAC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KL2.js","sourcesContent":["import { createEffect, createSignal, on, onMount, type Accessor } from 'solid-js';\nimport {\n offersApi,\n promoCodesApi,\n subscriptionsApi,\n usersApi,\n newIdempotencyKey,\n ApiError,\n type MemberOffer,\n type PromoValidationResponse,\n type ApiResponse,\n} from '../api/client';\nimport { bestOfferDiscount, offerBeatsPromo } from './offers';\nimport { readPromoCode, clearPromoCode } from '../api/promoRef';\nimport authStore from '../stores/auth';\nimport { useCardTokenizer, type HostedCardField } from './_internal/cardTokenizer';\nimport { formatCardNumber, formatExpiry, formatCvv } from './checkout';\nimport { getConfig } from '../config';\nimport { PHONE_ERROR, isValidUsPhone } from './phone';\nimport { useSmsConsent, type SmsConsent } from './_internal/smsConsent';\nimport { useAddressPair, validateAddress, firstAddressError, type AddressPair } from './address';\nimport { isLive } from './subscriptionStatus';\nimport { useCatalogAvailability, catalogUnavailableMessage, type CatalogAvailabilityState } from './catalogAvailability';\n\n// ── Draft persistence ───────────────────────────────────────────────\n\nconst DRAFT_TTL_MS = 7 * 24 * 3600 * 1000;\nconst MAX_RESTORABLE_STEP = 1; // Account + Address only; never restore into Payment\n\ninterface IntakeDraft {\n step?: number;\n firstName?: string;\n lastName?: string;\n dateOfBirth?: string;\n email?: string;\n phone?: string;\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n /** Version of the text-message consent wording the visitor ticked. */\n smsConsentVersion?: string;\n /** Idempotency key for THIS draft's create/signup attempt. Persisted so a\n * refresh mid-submit retries with the SAME key and the backend dedupes\n * instead of double-charging; rotated after a definitive rejection. */\n idempotencyKey?: string;\n savedAt?: number;\n}\n\nfunction draftKey(): string {\n return `${getConfig().storagePrefix}-subscription-intake-draft`;\n}\n\nfunction loadDraft(): IntakeDraft {\n try {\n const raw = localStorage.getItem(draftKey());\n if (!raw) return {};\n const parsed = JSON.parse(raw) as IntakeDraft;\n if (parsed.savedAt && Date.now() - parsed.savedAt > DRAFT_TTL_MS) {\n localStorage.removeItem(draftKey());\n return {};\n }\n return parsed ?? {};\n } catch {\n return {};\n }\n}\n\nfunction saveDraft(draft: IntakeDraft) {\n try {\n localStorage.setItem(draftKey(), JSON.stringify({ ...draft, savedAt: Date.now() }));\n } catch {\n // noop\n }\n}\n\nfunction clearDraft() {\n try {\n localStorage.removeItem(draftKey());\n } catch {\n // noop\n }\n}\n\n// ── Types ───────────────────────────────────────────────────────────\n\nexport interface SurveyResult {\n surveyResponseId: string;\n /**\n * v2 survey response id. When set, the Rx is linked to the Apex survey\n * snapshot and Apex generates the prescriber case notes from it (no local\n * caseNotes synthesis). Leave unset for the legacy v1 flow.\n */\n v2SurveyResponseId?: string;\n caseNotes?: string;\n drugId: string;\n drugName: string;\n dosage: string;\n}\n\nexport interface MedicationPricing {\n productId: string;\n productName: string;\n priceCents: number;\n savingsPriceCents?: number | null;\n}\n\nexport type SubscriptionIntakeOutcome =\n | { kind: 'in_progress' }\n | { kind: 'tokenizing' }\n | { kind: 'submitting' }\n /**\n * The member already holds a live subscription, so this intake must not create\n * a second one. Emitted ONLY under `singleSubscription` — without that option\n * the flow behaves exactly as before, so existing consumers that switch on\n * 'completed' alone are unaffected.\n *\n * Deliberately NOT 'completed': that kind means *this* purchase succeeded, and\n * hosts navigate onward celebrating it. This one means the member arrived\n * already subscribed and needs telling, not congratulating.\n */\n | { kind: 'already_subscribed'; productId?: string }\n | { kind: 'completed' };\n\nexport interface UseSubscriptionIntakeFlowOptions {\n surveyResult: SurveyResult;\n pricing: MedicationPricing;\n intervalDays?: number;\n /**\n * Whether the member is enrolled in the savings program — read reactively, so\n * a verification that completes mid-intake re-quotes. When true and the\n * product defines `savingsPriceCents`, that rate is quoted instead of list.\n *\n * Must track the same member the SERVER will resolve at charge time (the\n * persisted savings link), or the quote and the charge disagree.\n */\n isSavingsMember?: () => boolean;\n /**\n * The verified savings member id to send on the unauthenticated signup path,\n * so an account created AT checkout is linked and charged the savings rate\n * (the backend accepts and links `savingsMemberId` on register-and-subscribe,\n * but it was never sent). Read at submit time; null/empty sends nothing. The\n * authenticated path ignores it — the server prices off the persisted link.\n */\n savingsMemberId?: () => string | null;\n /**\n * Single-subscription tenants: the site sells ONE subscription program, so a\n * member may hold at most one live subscription — of ANY product.\n *\n * Widens the mount reconcile below from \"already subscribed to THIS product\"\n * to \"already subscribed to anything\", and turns the server's\n * `SUBSCRIPTION_EXISTS` rejection into an `already_subscribed` outcome instead\n * of a raw error banner. Mirrors `features.singleSubscription` on the tenant;\n * setting it here without the tenant flag still guards the common paths, but\n * the server is what actually enforces it.\n */\n singleSubscription?: boolean;\n}\n\nexport interface PromoPricing {\n baseCents: number;\n /** What is actually taken off: the promo's discount or the offer's, never both. */\n discountCents: number;\n finalCents: number;\n /** Set when the typed promo code is the discount applied. */\n promoCode?: string;\n /**\n * Set ONLY when the member's own offer is the discount applied — it beat the\n * typed promo code, or there was none. Absent whenever `promoCode` is set.\n */\n offer?: {\n label: string;\n /** \"$10\" / \"15%\". */\n amountText: string;\n /** The last day to claim it, ready to print (\"November 11, 2026\"). */\n deadlineText: string;\n recurringIndefinite: boolean;\n /** Rebills after the first charge that carry the discount. */\n recurringCharges: number;\n discountCents: number;\n };\n}\n\n/** Shown when a typed code is valid but the member's offer is worth more. */\nexport const OFFER_BEATS_PROMO_NOTICE =\n 'Your offer is the better discount, so it is the one applied. A promo code does not combine with an offer.';\n\nexport interface SubscriptionIntakeFlow {\n // Step 0 = Account, 1 = Address, 2 = Payment\n step: Accessor<number>;\n stepCount: 3;\n next: () => Promise<void>;\n back: () => void;\n\n outcome: Accessor<SubscriptionIntakeOutcome>;\n error: Accessor<string | null>;\n submitting: Accessor<boolean>;\n tokenizing: Accessor<boolean>;\n /** True once the card tokenizer is ready (config loaded; for AuthNet, Accept.js loaded too). Gate submission on this. */\n tokenizerReady: Accessor<boolean>;\n /** @deprecated alias of tokenizerReady (pre-rename name). */\n acceptJsReady: Accessor<boolean>;\n /** Non-null when payment setup failed to initialize — render as a banner. */\n /** Tokenizer init failure, or null. */\n tokenizerError: Accessor<string | null>;\n /** @deprecated alias of tokenizerError (pre-rename name). */\n acceptJsError: Accessor<string | null>;\n\n // Step 0 — Account\n firstName: Accessor<string>; setFirstName: (v: string) => void;\n lastName: Accessor<string>; setLastName: (v: string) => void;\n email: Accessor<string>; setEmail: (v: string) => void;\n password: Accessor<string>; setPassword: (v: string) => void;\n dateOfBirth: Accessor<string>; setDateOfBirth: (v: string) => void;\n phone: Accessor<string>; setPhone: (v: string) => void;\n /**\n * Optional opt-in to text messages. `smsConsent.offer()` is null unless the\n * tenant texts customers; render the checkbox only when it isn't. Never\n * required — leaving it unticked sends nothing and the purchase proceeds. A\n * guest's grant rides the register-and-subscribe call; a signed-in member's\n * rides the profile PATCH the intake already makes.\n */\n smsConsent: SmsConsent;\n\n // Step 1 — Address (delivery + billing override; see AddressPair).\n // `address.billingSameAsShipping` is this flow's \"billing same as delivery\".\n address: AddressPair;\n\n /** Per-item deliverability for `medication.productId` in the address's\n * shipping state — a catalog item routed to a pharmacy that doesn't serve\n * that state. Per ITEM, on top of the tenant-level `unavailableStates`\n * gating the address step already applies. `submit()` refuses to charge\n * while `availability.blocking()` is true. */\n availability: CatalogAvailabilityState;\n\n // Step 2 — Payment\n cardNumber: Accessor<string>; setCardNumber: (v: string) => void;\n expiry: Accessor<string>; setExpiry: (v: string) => void;\n cvv: Accessor<string>; setCvv: (v: string) => void;\n /**\n * True when the card is typed into the gateway's own hosted fields (NMI's\n * Collect.js) instead of cardNumber/expiry/cvv: render three containers and\n * pass each to registerCardField instead of card inputs.\n */\n hostedCardFields: Accessor<boolean>;\n /** Ref callback for a hosted card field container: `ref={(el) => flow.registerCardField('number', el)}`. */\n registerCardField: (field: HostedCardField, el: HTMLElement) => void;\n\n // Promo\n promoCode: Accessor<string>; setPromoCode: (v: string) => void;\n promoValidating: Accessor<boolean>;\n promoError: Accessor<string | null>;\n promoApplied: Accessor<PromoValidationResponse | null>;\n applyPromo: () => Promise<void>;\n clearPromo: () => void;\n /**\n * Plain words for the member when their valid promo code is NOT the discount\n * applied because their offer is worth more; null otherwise. Render it by the\n * promo field so a code that \"did nothing\" is explained.\n */\n promoNotice: Accessor<string | null>;\n\n // Pricing (reflects the applied promo or the member's offer, whichever is better)\n pricing: Accessor<PromoPricing>;\n\n // Context (read-only, from options)\n surveyResult: SurveyResult;\n medication: MedicationPricing;\n\n submit: () => Promise<void>;\n}\n\n// ── Hook ────────────────────────────────────────────────────────────\n\nexport function useSubscriptionIntakeFlow(\n options: UseSubscriptionIntakeFlowOptions,\n): SubscriptionIntakeFlow {\n const accept = useCardTokenizer();\n\n let restored: IntakeDraft = {};\n if (typeof window !== 'undefined') restored = loadDraft();\n\n const [step, setStep] = createSignal(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));\n const [error, setError] = createSignal<string | null>(null);\n const [tokenizing, setTokenizing] = createSignal(false);\n const [submitting, setSubmitting] = createSignal(false);\n const [outcome, setOutcome] = createSignal<SubscriptionIntakeOutcome>({ kind: 'in_progress' });\n\n // Account\n const [firstName, setFirstName] = createSignal(restored.firstName ?? '');\n const [lastName, setLastName] = createSignal(restored.lastName ?? '');\n const [email, setEmail] = createSignal(restored.email ?? '');\n const [password, setPassword] = createSignal('');\n const [dateOfBirth, setDateOfBirth] = createSignal(restored.dateOfBirth ?? '');\n const [phone, setPhone] = createSignal(restored.phone ?? '');\n const smsConsent = useSmsConsent(phone, restored.smsConsentVersion);\n\n // Address (delivery/shipping + billing override), backed by the shared\n // useAddressPair so validation and the same-as / copy-on-uncheck behavior\n // match the checkout flow. The individual accessors below keep this flow's\n // public interface stable for consuming storefronts (no breaking change).\n const addr = useAddressPair({\n initialShipping: {\n street: restored.street ?? '',\n city: restored.city ?? '',\n state: restored.state ?? '',\n zip: restored.zip ?? '',\n },\n });\n\n // Internal shipping getters for draft persistence + payload building; the full\n // read/write surface (incl. billing override) is exposed as `address` below.\n const street = () => addr.shipping().street;\n const city = () => addr.shipping().city;\n const state = () => addr.shipping().state;\n const zip = () => addr.shipping().zip;\n\n // Effective billing address sent as the charge's billTo.\n const effectiveBillingAddress = () => {\n const b = addr.effectiveBilling();\n return { street: b.street.trim(), city: b.city.trim(), state: b.state, zip: b.zip.trim() };\n };\n\n // Single-item intake: `medication.productId` (the-backend product id) is\n // the same id the survey composed against. Runs from mount — harmless\n // before the address step, since `state` is empty and the hook skips the\n // call until it isn't.\n const availability = useCatalogAvailability(\n () => [options.pricing.productId],\n () => state(),\n );\n\n // Payment\n const [cardNumberRaw, setCardNumberRaw] = createSignal('', { equals: false });\n const [expiryRaw, setExpiryRaw] = createSignal('', { equals: false });\n const [cvvRaw, setCvvRaw] = createSignal('', { equals: false });\n\n // Promo\n const [promoCode, setPromoCode] = createSignal('');\n const [promoValidating, setPromoValidating] = createSignal(false);\n const [promoError, setPromoError] = createSignal<string | null>(null);\n const [promoApplied, setPromoApplied] = createSignal<PromoValidationResponse | null>(null);\n\n // ── Pre-fill from a `?promo=` landing ───────────────────────────\n //\n // A campaign link stashes its code (see api/promoRef). Being inside the\n // storage window says nothing about the CODE still being live — a sale can end\n // while the stash is fresh — so re-validate before showing it to anyone, and\n // drop it silently when the server says no. An expired or withdrawn code must\n // not greet a member with an error they did nothing to cause.\n //\n // A code that validates is APPLIED, not merely pre-filled. The page that\n // handed it over already showed the member a price with it taken off (the\n // savings page quotes \"an extra $X off with TRUE10\"); leaving it for them to\n // press Apply meant most were charged $X more than they were shown. The\n // validation above is the same one Apply runs, so a code the server refuses\n // — expired, or exclusive for a savings member — is dropped silently rather\n // than surfacing a refusal on arrival.\n //\n // Yields to anything already in the field. Nothing sets it before mount today\n // (the draft does not persist a promo), but a member's own entry must never be\n // overwritten by a stale link if that changes.\n onMount(async () => {\n if (promoCode().trim()) return;\n const stashed = readPromoCode();\n if (!stashed) return;\n try {\n const res = await promoCodesApi.validate(stashed, {\n productIds: [options.pricing.productId],\n subtotalCents: savingsBaseCents(),\n });\n if (res.valid) {\n setPromoCode(stashed);\n setPromoApplied(res);\n } else clearPromoCode();\n } catch {\n // Network/-server blip: leave the stash for the next visit rather than\n // discarding a code that may be perfectly good.\n }\n });\n\n // Idempotency key for the create/signup POST — restored with the draft so a\n // retry after a refresh presents the same key (see IntakeDraft.idempotencyKey).\n const [idemKey, setIdemKey] = createSignal(restored.idempotencyKey ?? '');\n\n // ── Auto-save draft ─────────────────────────────────────────────\n\n onMount(() => {\n createEffect(() => {\n saveDraft({\n step: step(),\n firstName: firstName(),\n lastName: lastName(),\n dateOfBirth: dateOfBirth(),\n email: email(),\n phone: phone(),\n street: street(),\n city: city(),\n state: state(),\n zip: zip(),\n smsConsentVersion: smsConsent.draftVersion(),\n idempotencyKey: idemKey() || undefined,\n });\n });\n });\n\n // ── Mount reconcile (authenticated re-subscribe path) ───────────\n //\n // The restored draft re-arms submit with no memory of a create that already\n // committed: if the subscription landed server-side but this client never saw\n // the response (refresh mid-submit, dropped connection), the user is invited\n // to subscribe — and be charged — again. Ask the server before offering the\n // form.\n //\n // Scope depends on the tenant's model:\n // default → THIS product only. A subscription to a different\n // medication is a legitimate separate purchase and\n // must not block this intake.\n // singleSubscription → any live subscription. The program IS the\n // subscription, so a second one of any product is a\n // double charge, not a second purchase.\n //\n // The unauthenticated path needs no reconcile (a committed signup makes the\n // email taken, so a re-submit fails instead of double-charging). Fails open —\n // the server refuses the duplicate regardless, and blocking a real intake on a\n // lookup blip costs a customer.\n onMount(async () => {\n if (!authStore.isAuthenticated()) return;\n try {\n const res = (await subscriptionsApi.list()) as {\n subscriptions?: Array<{ productId?: string; status?: string }>;\n } | null;\n const existing = res?.subscriptions?.find(\n (s) =>\n isLive(s.status) &&\n (options.singleSubscription || s.productId === options.pricing.productId),\n );\n if (existing) {\n clearDraft();\n // Same-product is the ambiguous-retry case this reconcile was built for:\n // the purchase this very flow was configured for already exists, so the\n // member is done. A DIFFERENT product means they came back to buy\n // something they can't have alongside what they hold — a distinct\n // outcome, and only reachable under singleSubscription.\n setOutcome(\n existing.productId === options.pricing.productId\n ? { kind: 'completed' }\n : { kind: 'already_subscribed', productId: existing.productId },\n );\n }\n } catch {\n // Reconcile is a guard, not a gate — never block intake on a lookup blip.\n }\n });\n\n // ── Pricing ─────────────────────────────────────────────────────\n\n /**\n * The base price to quote: the product's savings rate for an enrolled member,\n * otherwise list.\n *\n * `savingsPriceCents` was carried on MedicationPricing but never actually\n * read, so enrolled members were quoted (and charged) list price. This mirrors\n * the SERVER rule exactly — `resolveProductPricing` in the-backend keys off\n * the member's savings link and treats a null savings price as \"no savings\n * rate for this item\", never as free — because the server re-derives the\n * charge from the DB and ignores the amount posted here. If the two rules ever\n * disagree, the member sees one number and is charged another; that mismatch\n * is the whole reason this exists, so keep them in step.\n */\n const savingsBaseCents = (): number => {\n const list = options.pricing.priceCents;\n const savings = options.pricing.savingsPriceCents;\n return options.isSavingsMember?.() && savings != null ? savings : list;\n };\n\n // ── The member's own offers ─────────────────────────────────────\n //\n // An offer is a discount this person holds (the-backend offers.ts). The\n // server applies it at checkout without being asked, so the total shown here\n // has to include it or the member reads one number and is charged a lower\n // one. Loaded for the session when there is one, and for a guest by the address\n // they are registering with, so nobody reaches the payment step looking at a\n // price they will not be charged. A failed read is \"no offers\": a backend from before\n // offers has no such endpoint, and a discount we cannot show must never\n // stand between a member and checkout.\n const [offers, setOffers] = createSignal<MemberOffer[]>([]);\n // Who to ask about: the session when there is one; otherwise the address a\n // guest has given, once they are past the Account step — it cannot change\n // from there on, so this asks once, not per keystroke. '' = nobody yet.\n const offerSubject = (): string => {\n if (authStore.isAuthenticated()) return 'session';\n const address = email().trim().toLowerCase();\n return step() > 0 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(address) ? address : '';\n };\n createEffect(\n on(offerSubject, (subject) => {\n if (!subject) {\n setOffers([]);\n return;\n }\n void (async () => {\n let found: MemberOffer[] = [];\n try {\n const res = subject === 'session' ? await offersApi.mine() : await offersApi.forEmail(subject);\n if (Array.isArray(res?.offers)) found = res.offers;\n } catch {\n // No offers to show; the server still applies any they hold.\n }\n // The session or the address may have changed while this was in flight.\n setOffers(offerSubject() === subject ? found : []);\n })();\n }),\n );\n\n /**\n * One slot, two contenders: the typed promo code and the member's best offer.\n * The larger discount applies and the other is dropped — they never add up —\n * and a tie goes to the code. Same rule as the server's discount engine,\n * which is what actually prices the charge.\n */\n const pricing = (): PromoPricing => {\n const baseCents = savingsBaseCents();\n const promo = promoApplied();\n const promoCents = promo?.valid && promo.discountCents ? Math.min(baseCents, promo.discountCents) : 0;\n const best = bestOfferDiscount(offers(), { productIds: [options.pricing.productId], baseCents });\n\n if (best && offerBeatsPromo(best.discountCents, promoCents)) {\n const o = best.offer;\n return {\n baseCents,\n discountCents: best.discountCents,\n finalCents: baseCents - best.discountCents,\n offer: {\n label: o.label,\n amountText: o.amountText,\n deadlineText: o.deadlineText,\n recurringIndefinite: o.recurringIndefinite,\n recurringCharges: o.recurringCharges ?? 0,\n discountCents: best.discountCents,\n },\n };\n }\n if (promoCents === 0) {\n return { baseCents, discountCents: 0, finalCents: baseCents };\n }\n return {\n baseCents,\n discountCents: promoCents,\n finalCents: promo!.finalCents ?? Math.max(0, baseCents - promoCents),\n promoCode: promo!.promoCode?.code,\n };\n };\n\n const promoNotice = (): string | null =>\n promoApplied()?.valid && pricing().offer ? OFFER_BEATS_PROMO_NOTICE : null;\n\n // ── Promo code ──────────────────────────────────────────────────\n\n async function applyPromo() {\n const code = promoCode().trim();\n if (!code) {\n setPromoError('Enter a promo code.');\n return;\n }\n setPromoError(null);\n setPromoValidating(true);\n try {\n const res = await promoCodesApi.validate(code, {\n productIds: [options.pricing.productId],\n // The base the promo will actually be applied to. For a savings member\n // that is the savings price, not list: the server discounts the\n // savings-substituted subtotal at checkout, so quoting off list would\n // show a percentage promo as a bigger saving than it is (10% of $399\n // displayed, 10% of $280 charged). Same rule as savingsBaseCents — keep\n // the two in step.\n subtotalCents: savingsBaseCents(),\n });\n if (!res.valid) {\n setPromoError(res.error ?? 'Invalid promo code.');\n setPromoApplied(null);\n } else {\n setPromoApplied(res);\n setPromoError(null);\n }\n } catch {\n setPromoError('Could not validate promo code. Please try again.');\n setPromoApplied(null);\n } finally {\n setPromoValidating(false);\n }\n }\n\n function clearPromo() {\n setPromoCode('');\n setPromoApplied(null);\n setPromoError(null);\n }\n\n // ── Validation per step ─────────────────────────────────────────\n\n function validateStep(s: number): string | null {\n if (s === 0) {\n if (!firstName().trim()) return 'First name is required.';\n if (!lastName().trim()) return 'Last name is required.';\n // Authenticated members already have an account — they don't re-enter\n // credentials; submit() subscribes their existing account instead.\n if (!authStore.isAuthenticated()) {\n if (!email().trim()) return 'Email is required.';\n if (!password().trim()) return 'Password is required.';\n if (password().length < 8) return 'Password must be at least 8 characters.';\n }\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(dateOfBirth())) return 'Enter a valid date of birth.';\n const dob = new Date(dateOfBirth() + 'T00:00:00');\n if (Number.isNaN(dob.getTime())) return 'Enter a valid date of birth.';\n const age = (Date.now() - dob.getTime()) / (365.25 * 24 * 3600 * 1000);\n if (age < 18) return 'You must be at least 18 to register.';\n if (age > 120) return 'Enter a valid date of birth.';\n // Phone stays optional here; when one is given it has to be dialable.\n if (phone().trim() && !isValidUsPhone(phone())) return PHONE_ERROR;\n } else if (s === 1) {\n return firstAddressError(validateAddress(addr.shipping(), '', { enforceAvailability: true }));\n } else if (s === 2) {\n // Hosted fields (NMI): the card is in the gateway's iframes, which check it on submit.\n if (!accept.hostedFields()) {\n if (!cardNumberRaw().trim()) return 'Card number is required.';\n if (!expiryRaw().trim()) return 'Expiration date is required.';\n if (!cvvRaw().trim()) return 'CVV is required.';\n }\n }\n return null;\n }\n\n // ── Navigation ───────────────────────────────────────────────────\n\n async function next() {\n const err = validateStep(step());\n if (err) {\n setError(err);\n return;\n }\n setError(null);\n setStep((s) => s + 1);\n }\n\n function back() {\n setError(null);\n if (step() > 0) setStep((s) => s - 1);\n }\n\n // ── Submit (from Payment step) ──────────────────────────────────\n\n let awaitingAvailability = false;\n\n async function submit() {\n // Never charge (or create the Rx) for an item Apex just told us can't be\n // filled at this shipping address — checked before tokenizing so a\n // blocked patient never enters a card for nothing.\n // Held across the wait: a second click while the check is pending must\n // not start a second submit (the submitting flag is only set below).\n if (awaitingAvailability) return;\n awaitingAvailability = true;\n try {\n await availability.settled();\n } finally {\n awaitingAvailability = false;\n }\n if (availability.blocking()) {\n setError(catalogUnavailableMessage(options.pricing.productName, state()));\n return;\n }\n\n const finalPricing = pricing();\n const isFree = finalPricing.finalCents === 0;\n\n if (!isFree) {\n const cardErr = validateStep(2);\n if (cardErr) {\n setError(cardErr);\n return;\n }\n if (addr.billingIsOverride()) {\n const bErr = firstAddressError(validateAddress(addr.billing(), 'Billing'));\n if (bErr) { setError(bErr); return; }\n }\n }\n\n setError(null);\n\n let opaque: Record<string, unknown> | undefined;\n if (!isFree) {\n setTokenizing(true);\n setOutcome({ kind: 'tokenizing' });\n try {\n opaque = await accept.tokenize({\n cardNumber: cardNumberRaw(),\n expiry: expiryRaw(),\n cvv: cvvRaw(),\n billing: effectiveBillingAddress(),\n });\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Card tokenization failed.');\n setTokenizing(false);\n setOutcome({ kind: 'in_progress' });\n return;\n }\n setTokenizing(false);\n }\n\n setSubmitting(true);\n setOutcome({ kind: 'submitting' });\n\n // One key per logical purchase attempt: minted on first submit, persisted in\n // the draft (the auto-save effect tracks it), reused verbatim on retries so\n // the backend's idempotency middleware can collapse a replay of a create\n // that already committed.\n let idempotencyKey = idemKey();\n if (!idempotencyKey) {\n idempotencyKey = newIdempotencyKey();\n setIdemKey(idempotencyKey);\n }\n\n try {\n const promo = promoApplied();\n const smsGrant = smsConsent.grant();\n\n if (authStore.isAuthenticated()) {\n // Logged-in member (e.g. a savings member who created an account first):\n // subscribe their EXISTING account instead of creating a second one. The\n // account may be name-only, so first persist the profile entered during\n // intake, then create the subscription + Apex Rx on that account.\n await usersApi.updateProfile({\n firstName: firstName().trim(),\n lastName: lastName().trim(),\n dateOfBirth: dateOfBirth(),\n phone: phone().trim() || undefined,\n address1: street().trim(),\n city: city().trim(),\n state: state(),\n zip: zip().trim(),\n // Same PATCH as the phone, so the server applies the number first and\n // the grant covers it. Alongside other fields a refused grant is a\n // note in the reply, never a failed intake.\n ...(smsGrant ? { smsConsent: { ...smsGrant, source: 'intake' as const } } : {}),\n });\n\n const res = await subscriptionsApi.create({\n opaqueData: opaque,\n amountCents: finalPricing.baseCents,\n intervalDays: options.intervalDays ?? 30,\n billingAddress: effectiveBillingAddress(),\n products: [{\n productId: options.pricing.productId,\n productName: options.pricing.productName,\n quantity: 1,\n dosage: options.surveyResult.dosage,\n }],\n productId: options.pricing.productId,\n promoCode: promo?.valid ? promo.promoCode?.code : undefined,\n metadata: {\n drugId: options.surveyResult.drugId,\n selectedDosage: options.surveyResult.dosage,\n caseNotes: options.surveyResult.caseNotes,\n v2SurveyResponseId: options.surveyResult.v2SurveyResponseId,\n },\n }, { idempotencyKey });\n if ((res as ApiResponse).error) {\n throw new Error((res as ApiResponse).error || 'Subscription failed. Please try again.');\n }\n } else {\n const savingsMemberId = options.savingsMemberId?.() || undefined;\n await authStore.signupAndSubscribe({\n email: email().trim(),\n password: password(),\n member: {\n firstName: firstName().trim(),\n lastName: lastName().trim(),\n dateOfBirth: dateOfBirth(),\n phone: phone().trim() || undefined,\n address1: street().trim(),\n city: city().trim(),\n state: state(),\n zip: zip().trim(),\n },\n opaqueData: opaque,\n amountCents: finalPricing.baseCents,\n intervalDays: options.intervalDays ?? 30,\n medication: options.surveyResult.drugId,\n products: [{\n productId: options.pricing.productId,\n productName: options.pricing.productName,\n quantity: 1,\n dosage: options.surveyResult.dosage,\n }],\n billingAddress: effectiveBillingAddress(),\n surveyResponseId: options.surveyResult.surveyResponseId,\n v2SurveyResponseId: options.surveyResult.v2SurveyResponseId,\n caseNotes: options.surveyResult.caseNotes,\n promoCode: promo?.valid ? promo.promoCode?.code : undefined,\n ...(savingsMemberId ? { savingsMemberId } : {}),\n ...(smsGrant ? { smsConsent: smsGrant } : {}),\n }, { idempotencyKey });\n }\n\n clearDraft();\n setOutcome({ kind: 'completed' });\n } catch (err) {\n // The server refused because this member already holds a live\n // subscription. Not an error the member can act on by retrying — nothing\n // is wrong with what they typed — so surface it as its own outcome and\n // let the host explain, rather than as a red banner over a form that will\n // never succeed. Draft cleared so a later legitimate intake (after a\n // cancellation) starts clean.\n if (err instanceof ApiError && err.code === 'SUBSCRIPTION_EXISTS') {\n clearDraft();\n setOutcome({ kind: 'already_subscribed' });\n return;\n }\n\n // A definitive rejection (4xx: decline, validation) means nothing was\n // committed — the next attempt is a NEW operation and must not be\n // deduped against this one, so rotate the key. An AMBIGUOUS failure\n // (connection dropped, 5xx) may have committed server-side: keep the key\n // so the retry collapses into the original instead of charging twice.\n const maybeCommitted = err instanceof ApiError && err.ambiguous;\n if (!maybeCommitted) setIdemKey(newIdempotencyKey());\n\n setError(err instanceof Error ? err.message : 'Registration failed. Please try again.');\n setOutcome({ kind: 'in_progress' });\n } finally {\n setSubmitting(false);\n }\n }\n\n return {\n step,\n stepCount: 3,\n next,\n back,\n\n outcome,\n error,\n submitting,\n tokenizing,\n tokenizerReady: accept.ready,\n acceptJsReady: accept.ready,\n tokenizerError: accept.error,\n acceptJsError: accept.error,\n\n firstName, setFirstName,\n lastName, setLastName,\n email, setEmail,\n password, setPassword,\n dateOfBirth, setDateOfBirth,\n phone, setPhone,\n smsConsent,\n\n address: addr,\n availability,\n\n cardNumber: cardNumberRaw,\n setCardNumber: (v) => setCardNumberRaw(formatCardNumber(v)),\n expiry: expiryRaw,\n setExpiry: (v) => setExpiryRaw(formatExpiry(v)),\n cvv: cvvRaw,\n hostedCardFields: accept.hostedFields,\n registerCardField: accept.registerHostedField,\n setCvv: (v) => setCvvRaw(formatCvv(v)),\n\n promoCode,\n setPromoCode,\n promoValidating,\n promoError,\n promoApplied,\n applyPromo,\n clearPromo,\n promoNotice,\n\n pricing,\n\n surveyResult: options.surveyResult,\n medication: options.pricing,\n\n submit,\n };\n}\n","import { createEffect, createRoot, on } from 'solid-js';\nimport cartStore, { type CartItem } from '../stores/cart';\nimport { promoCodesApi } from '../api/client';\nimport {\n adoptCartId,\n fetchCartConfig,\n fetchResumedCart,\n postCartSnapshot,\n readCartToken,\n resetCartId,\n stripCartToken,\n type CartSnapshotLine,\n type ResumedCart,\n} from '../api/cart';\n\n// Abandoned-cart capture, wired to core's cart store by default and to a\n// site's own basket via `options.source` (see CartSource).\n//\n// Two halves, both best-effort:\n//\n// - SNAPSHOT: every cart change is mirrored to the-backend (debounced, plus a\n// flush on pagehide — a shopper leaving is exactly the moment this exists\n// for). Identity only; the server re-prices.\n// - RESTORE: a `?cart=` token in the URL is traded for the saved cart and\n// rebuilt locally, so a recovery email opened on a phone brings the basket\n// with it.\n//\n// Nothing here may block, slow or break shopping. Every failure path ends in\n// \"carry on with the cart this browser already had\".\n\nexport interface CartCaptureOptions {\n /** Debounce for snapshot writes. Quantity steppers fire fast. */\n debounceMs?: number;\n /**\n * Address for an anonymous shopper, if the site collected one outside the\n * survey's email gate (e.g. checkout step 1). Logged-in shoppers need\n * nothing here — the backend reads their email off the token.\n */\n email?: () => string | null | undefined;\n /**\n * Where the basket lives, for a site that has no catalog cart.\n *\n * Abandonment is not a storefront-only event: a single-subscription partner\n * (mytruemeds, axiom-md) lets a patient choose a medication and a dose and\n * then walk away from the payment step, which is the same loss and the same\n * recoverable moment — but the selection lives in that site's own intake\n * state, not in `stores/cart`, so the default wiring watches an empty store\n * forever.\n *\n * Read and write are one option rather than two on purpose: a site that\n * supplies its own items must also say how a resumed cart gets back in, or\n * the `?cart=` link would rebuild into core's cart store, which such a site\n * never renders. Omit entirely to drive core's cart store (the default).\n */\n source?: CartSource;\n}\n\n/** A site's own basket, in the shape the wire already speaks. */\nexport interface CartSource {\n /** Current lines. Must be reactive — this is tracked. */\n items: () => CartSnapshotLine[];\n /** Promo code riding on the cart, if the site has one. */\n promoCode?: () => string | null | undefined;\n /**\n * Rebuild the site's own state from a cart resumed off a `?cart=` link. The\n * lines are re-priced against today's catalog; the promo code (if any) is\n * NOT re-validated for a custom source — `validateResumedPromo` does that\n * for a site that wants it.\n */\n restore: (cart: ResumedCart) => void;\n}\n\nfunction toSnapshotLines(items: CartItem[]): CartSnapshotLine[] {\n return items.map((i) => ({\n productId: i.productId,\n ...(i.dosage ? { dosage: i.dosage } : {}),\n quantity: i.quantity || 1,\n }));\n}\n\n/**\n * Who a resumed cart is handed to. Default rebuilds core's cart store; a site\n * with its own basket claims it in `startCartCapture` (synchronously, before\n * anything can await), so a later `restoreCartFromLink()` reaches the right\n * place.\n */\nlet restoreTarget: ((cart: ResumedCart) => void) | null = null;\n\n/** Rebuild the local cart from a resumed one, replacing whatever was there. */\nfunction applyResumedCart(resumed: ResumedCart): void {\n cartStore.clear();\n for (const line of resumed.items) {\n cartStore.add({\n productId: line.productId,\n productName: line.name,\n dosage: line.dosage ?? '',\n quantity: 1,\n // The sale price when one is running — same figure the catalog shows.\n priceCents: line.salePriceCents ?? line.priceCents,\n drugId: line.productId,\n apexDrugId: line.apexDrugId,\n categories: line.categories,\n thumbnailUrl: line.thumbnailUrl ?? undefined,\n hideDoseLabel: line.hideDoseLabel || undefined,\n isSubscription: line.isSubscription || undefined,\n });\n if (line.quantity > 1) {\n cartStore.setQuantity(cartStore.itemKey(line.productId, line.dosage ?? ''), line.quantity);\n }\n }\n}\n\nexport interface ValidatedResumedPromo {\n code: string;\n discountType: 'percent' | 'fixed';\n discountValueCents: number;\n discountCents: number;\n}\n\n/**\n * Re-check the promo code a resumed cart was carrying, against today's rules\n * and today's lines. Null when there was no code, when it no longer validates,\n * or when the check itself fails — the cart is restored either way.\n *\n * Exported because a site with its own `CartSource` needs the same guarantee\n * without core's cart store: showing a discount checkout won't honor is worse\n * than showing none.\n */\nexport async function validateResumedPromo(resumed: ResumedCart): Promise<ValidatedResumedPromo | null> {\n if (!resumed.promoCode) return null;\n try {\n const res = await promoCodesApi.validate(resumed.promoCode, {\n productIds: resumed.items.map((i) => i.productId),\n subtotalCents: resumed.subtotalCents,\n });\n if (!res.valid || !res.promoCode) return null;\n return {\n code: res.promoCode.code,\n discountType: res.promoCode.discountType,\n discountValueCents: res.promoCode.discountValueCents,\n discountCents: res.discountCents ?? 0,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Re-apply the promo code the cart was carrying when it was abandoned, to\n * core's cart store. Re-VALIDATED, never trusted: a code can expire, get\n * revoked, or stop covering the products still in the cart between abandonment\n * and return.\n */\nasync function restorePromo(resumed: ResumedCart): Promise<void> {\n const promo = await validateResumedPromo(resumed);\n if (promo) cartStore.setPromo(promo);\n}\n\nlet restoreInFlight: Promise<ResumedCart | null> | null = null;\n\n/**\n * Redeem a `?cart=` token if the URL carries one.\n *\n * Exported for sites that want to act on the restore — opening their cart\n * drawer on arrival, say, or waiting for their catalog first.\n *\n * Single-flight: `startCartCapture()` restores on its own, so a site calling\n * this directly would otherwise race it — both read the token before either\n * strips it, and the cart gets rebuilt twice. Concurrent callers share one\n * restore and one result.\n */\nexport function restoreCartFromLink(): Promise<ResumedCart | null> {\n if (!restoreInFlight) {\n restoreInFlight = runRestore().finally(() => {\n restoreInFlight = null;\n });\n }\n return restoreInFlight;\n}\n\nasync function runRestore(): Promise<ResumedCart | null> {\n const token = readCartToken();\n if (!token) return null;\n\n const resumed = await fetchResumedCart(token);\n // Strip either way: a dead token that stays in the URL re-fires this on\n // every navigation and, worse, gets shared or bookmarked.\n stripCartToken();\n if (!resumed) return null;\n\n // Keep writing to the cart the email was about, not the one this browser\n // happened to mint — otherwise the reminder history and the conversion land\n // on different rows.\n adoptCartId(resumed.cartId);\n if (restoreTarget) {\n // A site with its own basket. It owns the promo too — core has no store to\n // put one in — so `validateResumedPromo` is left for it to call.\n restoreTarget(resumed);\n } else {\n applyResumedCart(resumed);\n void restorePromo(resumed);\n }\n return resumed;\n}\n\nlet running = false;\n\n/**\n * Start mirroring the cart. Call once at app boot; returns a disposer.\n *\n * No-ops for tenants that never opted in (`GET /config/cart`), so it is safe to\n * call unconditionally from shared site scaffolding.\n */\nexport function startCartCapture(opts: CartCaptureOptions = {}): () => void {\n if (running) return () => {};\n running = true;\n\n // Claim the restore BEFORE anything awaits, so a site that calls\n // `restoreCartFromLink()` itself can't race core's cart store into place.\n restoreTarget = opts.source?.restore ?? null;\n\n // Core's cart store is just the default source; the wire shape is the same\n // either way, so everything below reads lines, not cart items.\n const source: CartSource = opts.source ?? {\n items: () => toSnapshotLines(cartStore.items()),\n promoCode: () => cartStore.appliedPromo()?.code ?? null,\n restore: applyResumedCart,\n };\n\n const debounceMs = opts.debounceMs ?? 2000;\n let enabled: boolean | null = null;\n let pending: CartSnapshotLine[] | null = null;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let lastSentEmpty = true;\n\n function flush(): void {\n if (timer) clearTimeout(timer);\n timer = undefined;\n const items = pending;\n pending = null;\n if (!items || enabled !== true) return;\n\n // An empty cart is not an abandoned one: the snapshot deletes the row, and\n // the id is retired so the next basket starts a clean one. This is also the\n // post-purchase path — checkout clears the cart — which is why converting\n // doesn't need its own wiring here.\n if (items.length === 0) {\n if (lastSentEmpty) return;\n postCartSnapshot({ items: [], promoCode: null });\n resetCartId();\n lastSentEmpty = true;\n return;\n }\n\n postCartSnapshot({\n items,\n promoCode: source.promoCode?.() ?? null,\n email: opts.email?.() ?? null,\n });\n lastSentEmpty = false;\n }\n\n function schedule(ms: number): void {\n if (timer) clearTimeout(timer);\n timer = setTimeout(flush, ms);\n }\n\n const dispose = createRoot((disposeRoot) => {\n // `defer` so merely starting capture doesn't post the cart the shopper\n // hasn't touched; the first real change schedules the first write.\n createEffect(\n on(\n source.items,\n (items) => {\n pending = items;\n if (enabled === true) schedule(debounceMs);\n },\n { defer: true },\n ),\n );\n return disposeRoot;\n });\n\n void fetchCartConfig().then((cfg) => {\n enabled = cfg.snapshot;\n if (!enabled) return;\n void restoreCartFromLink();\n if (pending) schedule(0);\n });\n\n // The shopper leaving with items in the cart is the whole point; don't let a\n // pending debounce die with the page.\n const onPageHide = () => flush();\n if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {\n window.addEventListener('pagehide', onPageHide);\n }\n\n return () => {\n if (timer) clearTimeout(timer);\n if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {\n window.removeEventListener('pagehide', onPageHide);\n }\n dispose();\n restoreTarget = null;\n running = false;\n };\n}\n"]}
@@ -86,7 +86,7 @@ import {
86
86
  useSurveyV2Flow,
87
87
  useUpdatePaymentMethodFlow,
88
88
  visibleWarnings
89
- } from "./HGKZ6FBS.jsx";
89
+ } from "./6MPJIVNJ.jsx";
90
90
  import {
91
91
  affiliateAuth_default,
92
92
  auth_default,
@@ -2239,6 +2239,79 @@ function QuestionField2(props) {
2239
2239
  // src/pages/Checkout.tsx
2240
2240
  import { Show as Show5, createEffect as createEffect3 } from "solid-js";
2241
2241
 
2242
+ // src/components/SecureCardPanel.tsx
2243
+ import { onMount } from "solid-js";
2244
+ var STYLE_ID = "apc-secure-card-panel-css";
2245
+ var CSS = `
2246
+ .apc-card{--_bg:var(--apc-card-bg,var(--app-flow-surface,#fff));--_head:var(--apc-card-head-bg,var(--app-flow-surface-inset,#f6f6f4));--_border:var(--apc-card-border,var(--app-flow-border,rgba(0,0,0,.14)));--_radius:var(--apc-card-radius,var(--app-flow-radius,12px));--_fg:var(--apc-card-fg,var(--app-flow-fg,inherit));--_muted:var(--apc-card-muted,var(--app-flow-fg-muted,#6b6b6b));--_accent:var(--apc-card-accent,var(--app-flow-primary,#2563eb));--_danger:var(--apc-card-danger,var(--app-flow-danger,#c0392b));--_ok:var(--apc-card-success,var(--app-flow-success,#4caf50));
2247
+ border:1px solid var(--_border);border-radius:var(--_radius);background:var(--_bg);color:var(--_fg);overflow:hidden;text-align:left;box-shadow:0 1px 2px rgba(0,0,0,.03),0 8px 24px -14px rgba(0,0,0,.18)}
2248
+ .apc-card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 16px;background:var(--_head);border-bottom:1px solid var(--_border);font-size:13px;line-height:1.2}
2249
+ .apc-card-title{display:flex;align-items:center;gap:8px;font-weight:600;margin:0;font-size:inherit}
2250
+ .apc-card-badge{display:flex;align-items:center;gap:6px;color:var(--_muted);font-size:12px;white-space:nowrap}
2251
+ .apc-card-badge::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--_ok);box-shadow:0 0 0 3px color-mix(in srgb,var(--_ok) 25%,transparent)}
2252
+ .apc-card-grid{display:grid;grid-template-columns:1fr 1fr}
2253
+ .apc-card-grid.apc-inline{grid-template-columns:2fr 1fr 1fr}
2254
+ .apc-card-cell{position:relative;padding:10px 16px 9px;min-width:0}
2255
+ .apc-card-cell.apc-full{grid-column:1/-1}
2256
+ .apc-card-grid:not(.apc-inline) .apc-card-cell+.apc-card-cell:not(.apc-full){border-left:1px solid var(--_border)}
2257
+ .apc-card-grid:not(.apc-inline) .apc-full{border-bottom:1px solid var(--_border)}
2258
+ .apc-card-grid.apc-inline .apc-card-cell+.apc-card-cell{border-left:1px solid var(--_border)}
2259
+ .apc-card-label{display:block;font-size:11px;font-weight:500;letter-spacing:.06em;text-transform:uppercase;color:var(--_muted);margin-bottom:3px;transition:color .15s}
2260
+ .apc-card-slot{height:26px;font-size:17px;color:var(--_fg)}
2261
+ .apc-card-slot iframe{display:block;width:100%;height:100%!important;border:0;outline:none}
2262
+ .apc-card-cell::after{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:transparent;transition:background .15s}
2263
+ .apc-card-cell:has(>[data-focused])::after{background:var(--_accent)}
2264
+ .apc-card-cell:has(>[data-focused]) .apc-card-label{color:var(--_accent)}
2265
+ .apc-card-cell:has(>[data-invalid])::after{background:var(--_danger)}
2266
+ .apc-card-cell:has(>[data-invalid]) .apc-card-label{color:var(--_danger)}
2267
+ .apc-card-note{display:flex;gap:8px;align-items:flex-start;margin:10px 4px 0;color:var(--_muted);font-size:12px;line-height:1.45}
2268
+ .apc-card-note svg{flex:none;margin-top:1px}
2269
+ `;
2270
+ function ensureStyles() {
2271
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID)) return;
2272
+ const el = document.createElement("style");
2273
+ el.id = STYLE_ID;
2274
+ el.textContent = CSS;
2275
+ document.head.insertBefore(el, document.head.firstChild);
2276
+ }
2277
+ var Lock = () => <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
2278
+ <rect x="3" y="11" width="18" height="10" rx="2" />
2279
+ <path d="M7 11V7a5 5 0 0 1 10 0v4" />
2280
+ </svg>;
2281
+ var Shield = () => <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true">
2282
+ <path d="M12 2l8 4v6c0 5-3.5 9-8 10-4.5-1-8-5-8-10V6z" />
2283
+ </svg>;
2284
+ function SecureCardPanel(props) {
2285
+ onMount(ensureStyles);
2286
+ const cell = (field2, label3, full = false) => <div class={full ? "apc-card-cell apc-full" : "apc-card-cell"}>
2287
+ <span class="apc-card-label">{label3}</span>
2288
+ <div class="apc-card-slot" role="group" aria-label={label3} data-hosted-field={field2} ref={(el) => props.register(field2, el)} />
2289
+ </div>;
2290
+ return <div>
2291
+ <div class={props.class ? `apc-card ${props.class}` : "apc-card"}>
2292
+ <div class="apc-card-head">
2293
+ <p class="apc-card-title">
2294
+ <Lock />
2295
+ {props.title ?? "Card details"}
2296
+ </p>
2297
+ <span class="apc-card-badge">Encrypted</span>
2298
+ </div>
2299
+ <div class={props.inline ? "apc-card-grid apc-inline" : "apc-card-grid"}>
2300
+ {cell("number", "Card number", !props.inline)}
2301
+ {cell("expiry", "Expires")}
2302
+ {cell("cvv", "CVV")}
2303
+ </div>
2304
+ </div>
2305
+ <p class="apc-card-note">
2306
+ <Shield />
2307
+ <span>
2308
+ Your card goes straight to our payment processor.{" "}
2309
+ {props.merchantName ? `${props.merchantName} never sees or stores the number.` : "We never see or store the number."}
2310
+ </span>
2311
+ </p>
2312
+ </div>;
2313
+ }
2314
+
2242
2315
  // src/components/AddressFields.tsx
2243
2316
  import { Show as Show4 } from "solid-js";
2244
2317
  function formatAddress(a) {
@@ -2761,6 +2834,10 @@ function PurchaseForm(props) {
2761
2834
  "margin-top": "1rem",
2762
2835
  "margin-bottom": "1.5rem"
2763
2836
  }}
2837
+ >
2838
+ <Show5
2839
+ when={!flow.hostedCardFields()}
2840
+ fallback={<SecureCardPanel register={flow.registerCardField} />}
2764
2841
  >
2765
2842
  <TextField
2766
2843
  label="Card Number"
@@ -2788,6 +2865,7 @@ function PurchaseForm(props) {
2788
2865
  inputmode="numeric"
2789
2866
  />
2790
2867
  </div>
2868
+ </Show5>
2791
2869
  </div>
2792
2870
  </Show5>
2793
2871
 
@@ -3057,6 +3135,10 @@ function PurchaseForm2(props) {
3057
3135
 
3058
3136
  <div
3059
3137
  style={{ "margin-top": "0.75rem", display: "flex", "flex-direction": "column", gap: "1rem" }}
3138
+ >
3139
+ <Show6
3140
+ when={!flow.hostedCardFields()}
3141
+ fallback={<SecureCardPanel register={flow.registerCardField} />}
3060
3142
  >
3061
3143
  <TextField
3062
3144
  label="Card Number"
@@ -3084,6 +3166,7 @@ function PurchaseForm2(props) {
3084
3166
  inputmode="numeric"
3085
3167
  />
3086
3168
  </div>
3169
+ </Show6>
3087
3170
  </div>
3088
3171
  </div>
3089
3172
 
@@ -3427,6 +3510,10 @@ function PaymentStep(props) {
3427
3510
  </div>
3428
3511
  </Card3>
3429
3512
 
3513
+ <Show8
3514
+ when={!flow.hostedCardFields()}
3515
+ fallback={<SecureCardPanel register={flow.registerCardField} />}
3516
+ >
3430
3517
  <TextField
3431
3518
  label="Card Number"
3432
3519
  value={flow.cardNumber()}
@@ -3454,6 +3541,7 @@ function PaymentStep(props) {
3454
3541
  inputmode="numeric"
3455
3542
  />
3456
3543
  </div>
3544
+ </Show8>
3457
3545
 
3458
3546
  <Show8 when={props.promoField}>
3459
3547
  {props.promoField({
@@ -4028,6 +4116,10 @@ function SubscribeContent(props) {
4028
4116
  />
4029
4117
 
4030
4118
  <SectionLabel>Card Details</SectionLabel>
4119
+ <Show10
4120
+ when={!flow.hostedCardFields()}
4121
+ fallback={<SecureCardPanel register={flow.registerCardField} />}
4122
+ >
4031
4123
  <div style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
4032
4124
  <TextField
4033
4125
  value={flow.cardNumber()}
@@ -4053,6 +4145,7 @@ function SubscribeContent(props) {
4053
4145
  />
4054
4146
  </div>
4055
4147
  </div>
4148
+ </Show10>
4056
4149
 
4057
4150
  {
4058
4151
  /* Payment-setup init failure: without this the Subscribe button
@@ -9962,7 +10055,7 @@ function Categories() {
9962
10055
  }
9963
10056
 
9964
10057
  // src/pages/admin/Customers.tsx
9965
- import { createSignal as createSignal27, onCleanup as onCleanup2, onMount, Show as Show45 } from "solid-js";
10058
+ import { createSignal as createSignal27, onCleanup as onCleanup2, onMount as onMount2, Show as Show45 } from "solid-js";
9966
10059
 
9967
10060
  // src/pages/admin/customers/CustomerDetail.tsx
9968
10061
  import { createMemo as createMemo11, createResource as createResource14, createSignal as createSignal25, For as For30, Show as Show43 } from "solid-js";
@@ -12117,6 +12210,12 @@ function cardLabel(card) {
12117
12210
  }
12118
12211
  function UpdateCardModal(props) {
12119
12212
  const tokenizer = useCardTokenizer();
12213
+ const hostedBox = (field2) => <div
12214
+ class="app-admin-input"
12215
+ style={{ height: "2.5rem", padding: "0 0.75rem", display: "flex", "align-items": "center" }}
12216
+ data-hosted-field={field2}
12217
+ ref={(el) => tokenizer.registerHostedField(field2, el)}
12218
+ />;
12120
12219
  const [onFile, { refetch: refetchCard }] = createResource11(() => props.customer.uid, (uid) => adminApi.getCustomerCard(uid));
12121
12220
  const [number, setNumber] = createSignal21("");
12122
12221
  const [expiry, setExpiry] = createSignal21("");
@@ -12272,7 +12371,7 @@ function UpdateCardModal(props) {
12272
12371
  type="submit"
12273
12372
  form="update-card-form"
12274
12373
  class="app-admin-btn app-admin-btn-primary"
12275
- disabled={working() || stopped() || !tokenizer.ready() || !number() || !expiry() || !cvv()}
12374
+ disabled={working() || stopped() || !tokenizer.ready() || !tokenizer.hostedFields() && (!number() || !expiry() || !cvv())}
12276
12375
  >
12277
12376
  {working() ? "Saving\u2026" : chargeNow() && props.due.length > 0 ? `Save card and charge ${centsToUsd(dueTotal())}` : "Save card"}
12278
12377
  </button>
@@ -12313,7 +12412,8 @@ function UpdateCardModal(props) {
12313
12412
 
12314
12413
  <fieldset disabled={stopped() || working()} style={{ border: 0, margin: 0, padding: 0 }} class="app-admin-section-stack">
12315
12414
  <FormRow label="Card number">
12316
- <input
12415
+ <Show39 when={!tokenizer.hostedFields()} fallback={hostedBox("number")}>
12416
+ <input
12317
12417
  class="app-admin-input"
12318
12418
  inputmode="numeric"
12319
12419
  autocomplete="off"
@@ -12321,13 +12421,18 @@ function UpdateCardModal(props) {
12321
12421
  onInput={(e) => setNumber(e.currentTarget.value.replace(/[^\d ]/g, ""))}
12322
12422
  placeholder={refused() ? "Re-enter the card number" : ""}
12323
12423
  />
12424
+ </Show39>
12324
12425
  </FormRow>
12325
12426
  <div class="app-admin-form-grid">
12326
12427
  <FormRow label="Expires (MM/YY)">
12327
- <input class="app-admin-input" inputmode="numeric" autocomplete="off" value={expiry()} onInput={(e) => setExpiry(e.currentTarget.value)} placeholder="MM/YY" />
12428
+ <Show39 when={!tokenizer.hostedFields()} fallback={hostedBox("expiry")}>
12429
+ <input class="app-admin-input" inputmode="numeric" autocomplete="off" value={expiry()} onInput={(e) => setExpiry(e.currentTarget.value)} placeholder="MM/YY" />
12430
+ </Show39>
12328
12431
  </FormRow>
12329
12432
  <FormRow label="CVV">
12330
- <input class="app-admin-input" inputmode="numeric" autocomplete="off" type="password" value={cvv()} onInput={(e) => setCvv(e.currentTarget.value.replace(/\D/g, ""))} maxlength="4" />
12433
+ <Show39 when={!tokenizer.hostedFields()} fallback={hostedBox("cvv")}>
12434
+ <input class="app-admin-input" inputmode="numeric" autocomplete="off" type="password" value={cvv()} onInput={(e) => setCvv(e.currentTarget.value.replace(/\D/g, ""))} maxlength="4" />
12435
+ </Show39>
12331
12436
  </FormRow>
12332
12437
  <FormRow label="Billing ZIP">
12333
12438
  <input class="app-admin-input" inputmode="numeric" autocomplete="off" value={zip()} onInput={(e) => setZip(e.currentTarget.value)} />
@@ -13737,7 +13842,7 @@ function Customers(props = {}) {
13737
13842
  setInternalUid(next);
13738
13843
  pushCustomerUrl(next);
13739
13844
  };
13740
- onMount(() => {
13845
+ onMount2(() => {
13741
13846
  if (controlled()) return;
13742
13847
  if (props.initialUid) pushCustomerUrl(props.initialUid);
13743
13848
  const off = onCustomerUrlChange((fromUrl) => setInternalUid(fromUrl));
@@ -14389,11 +14494,11 @@ function RecurringRevenue(props) {
14389
14494
  import { createResource as createResource20, createSignal as createSignal31, For as For35, Show as Show50 } from "solid-js";
14390
14495
 
14391
14496
  // src/pages/admin/QuickBooksCard.tsx
14392
- import { createResource as createResource19, createSignal as createSignal30, Show as Show49, onMount as onMount2 } from "solid-js";
14497
+ import { createResource as createResource19, createSignal as createSignal30, Show as Show49, onMount as onMount3 } from "solid-js";
14393
14498
  function QuickBooksCard() {
14394
14499
  const [status, { refetch }] = createResource19(() => adminApi.quickbooksStatus().catch(() => null));
14395
14500
  const [connecting, setConnecting] = createSignal30(false);
14396
- onMount2(() => {
14501
+ onMount3(() => {
14397
14502
  const params = new URLSearchParams(window.location.search);
14398
14503
  const result = params.get("quickbooks");
14399
14504
  if (result === "connected") {
@@ -14929,7 +15034,7 @@ function CategoriesPopover(props) {
14929
15034
  }
14930
15035
 
14931
15036
  // src/pages/admin/ProductCatalogSections.tsx
14932
- import { createMemo as createMemo17, createSignal as createSignal34, For as For38, onMount as onMount3, Show as Show53 } from "solid-js";
15037
+ import { createMemo as createMemo17, createSignal as createSignal34, For as For38, onMount as onMount4, Show as Show53 } from "solid-js";
14933
15038
 
14934
15039
  // src/pages/admin/ProductPharmacies.tsx
14935
15040
  import { createEffect as createEffect10, createMemo as createMemo16, createSignal as createSignal33, For as For37, Index, Match as Match4, onCleanup as onCleanup4, Show as Show52, Switch as Switch4 } from "solid-js";
@@ -16085,7 +16190,7 @@ function NewCatalogProductDialog(props) {
16085
16190
  const [error, setError] = createSignal34("");
16086
16191
  const [pending, setPending] = createSignal34(null);
16087
16192
  const [locked, setLocked] = createSignal34(false);
16088
- onMount3(async () => {
16193
+ onMount4(async () => {
16089
16194
  try {
16090
16195
  setDrugs((await adminCatalogApi.listDrugs()).drugs ?? []);
16091
16196
  } catch (err) {
@@ -18836,7 +18941,7 @@ function Products(props) {
18836
18941
  }
18837
18942
 
18838
18943
  // src/pages/admin/Offers.tsx
18839
- import { createMemo as createMemo20, createResource as createResource22, createSignal as createSignal37, For as For41, onMount as onMount4, Show as Show56 } from "solid-js";
18944
+ import { createMemo as createMemo20, createResource as createResource22, createSignal as createSignal37, For as For41, onMount as onMount5, Show as Show56 } from "solid-js";
18840
18945
 
18841
18946
  // src/pages/admin/funnelShared.ts
18842
18947
  var SEGMENT_KEYS = {
@@ -19200,7 +19305,7 @@ function OfferGrants(props) {
19200
19305
  if (reset) setGrants([]);
19201
19306
  }
19202
19307
  };
19203
- onMount4(() => void load(true));
19308
+ onMount5(() => void load(true));
19204
19309
  const changed = () => {
19205
19310
  void load(true);
19206
19311
  props.onChanged();
@@ -19973,7 +20078,7 @@ function Sales() {
19973
20078
  }
19974
20079
 
19975
20080
  // src/pages/admin/Support.tsx
19976
- import { createResource as createResource26, createSignal as createSignal40, For as For46, onCleanup as onCleanup6, onMount as onMount5, Show as Show61 } from "solid-js";
20081
+ import { createResource as createResource26, createSignal as createSignal40, For as For46, onCleanup as onCleanup6, onMount as onMount6, Show as Show61 } from "solid-js";
19977
20082
 
19978
20083
  // src/pages/admin/support/format.ts
19979
20084
  function customerLabel(thread) {
@@ -21057,7 +21162,7 @@ function Support(props = {}) {
21057
21162
  const row = threads().find((t) => t.id === thread.id);
21058
21163
  if (row?.adminUnread && !thread.adminUnread) refreshQueue();
21059
21164
  }
21060
- onMount5(() => {
21165
+ onMount6(() => {
21061
21166
  const timer = setInterval(refreshQueue, POLL_MS);
21062
21167
  let sub = null;
21063
21168
  let cancelled = false;
@@ -21272,7 +21377,7 @@ import { createEffect as createEffect15, createSignal as createSignal44, createR
21272
21377
  import { createSignal as createSignal43, For as For49, Show as Show64 } from "solid-js";
21273
21378
 
21274
21379
  // src/pages/admin/EmailBodyEditor.tsx
21275
- import { createEffect as createEffect14, createSignal as createSignal42, For as For48, on as on9, onCleanup as onCleanup7, onMount as onMount6, Show as Show63 } from "solid-js";
21380
+ import { createEffect as createEffect14, createSignal as createSignal42, For as For48, on as on9, onCleanup as onCleanup7, onMount as onMount7, Show as Show63 } from "solid-js";
21276
21381
  import { Editor } from "@tiptap/core";
21277
21382
 
21278
21383
  // src/pages/admin/emailBodyExtensions.ts
@@ -21515,7 +21620,7 @@ function EmailBodyEditor(props) {
21515
21620
  })
21516
21621
  );
21517
21622
  };
21518
- onMount6(() => {
21623
+ onMount7(() => {
21519
21624
  load(props.value);
21520
21625
  props.ref?.({
21521
21626
  insertPlaceholder,
@@ -21639,7 +21744,7 @@ function EmailBodyEditor(props) {
21639
21744
  const t = e.target;
21640
21745
  if (!menuEl?.contains(t) && !menuButton.contains(t)) closeMenu();
21641
21746
  };
21642
- onMount6(() => document.addEventListener("mousedown", onDocPointerDown));
21747
+ onMount7(() => document.addEventListener("mousedown", onDocPointerDown));
21643
21748
  onCleanup7(() => document.removeEventListener("mousedown", onDocPointerDown));
21644
21749
  const moveFocus = (items, current2, delta) => {
21645
21750
  if (items.length === 0) return;
@@ -24329,7 +24434,7 @@ function SmsCard(props) {
24329
24434
  }
24330
24435
 
24331
24436
  // src/pages/admin/sms/SmsLogCard.tsx
24332
- import { createSignal as createSignal50, For as For56, onMount as onMount7, Show as Show72 } from "solid-js";
24437
+ import { createSignal as createSignal50, For as For56, onMount as onMount8, Show as Show72 } from "solid-js";
24333
24438
  var PAGE_SIZE2 = 25;
24334
24439
  var BASE_STATUSES = ["delivered", "sent", "failed", "blocked"];
24335
24440
  var humanize4 = (key) => key.replace(/([A-Z])/g, " $1").replace(/[_-]/g, " ").replace(/^\w/, (c) => c.toUpperCase()).trim();
@@ -24383,7 +24488,7 @@ function SmsLogCard(props) {
24383
24488
  if (mine === generation) setLoading(false);
24384
24489
  }
24385
24490
  };
24386
- onMount7(() => void load(false));
24491
+ onMount8(() => void load(false));
24387
24492
  const statuses = () => [.../* @__PURE__ */ new Set([...BASE_STATUSES, ...seen()])];
24388
24493
  const eventLabel = (key) => props.labels()[key] ?? humanize4(key);
24389
24494
  return <SmsCard
@@ -25741,6 +25846,10 @@ function UpdatePaymentMethod(props) {
25741
25846
  </Show78>
25742
25847
 
25743
25848
  <div style={{ display: "grid", gap: "1rem", "margin-bottom": "1.5rem" }}>
25849
+ <Show78
25850
+ when={!flow.hostedCardFields()}
25851
+ fallback={<SecureCardPanel register={flow.registerCardField} />}
25852
+ >
25744
25853
  <TextField
25745
25854
  label="Card number"
25746
25855
  value={flow.cardNumber()}
@@ -25767,6 +25876,7 @@ function UpdatePaymentMethod(props) {
25767
25876
  inputmode="numeric"
25768
25877
  />
25769
25878
  </div>
25879
+ </Show78>
25770
25880
  </div>
25771
25881
 
25772
25882
  {
@@ -25799,7 +25909,7 @@ function UpdatePaymentMethod(props) {
25799
25909
  }
25800
25910
 
25801
25911
  // src/pages/MemberPortal.tsx
25802
- import { Show as Show87, Switch as Switch9, Match as Match9, For as For67, createSignal as createSignal62, onMount as onMount8 } from "solid-js";
25912
+ import { Show as Show87, Switch as Switch9, Match as Match9, For as For67, createSignal as createSignal62, onMount as onMount9 } from "solid-js";
25803
25913
 
25804
25914
  // src/pages/member/OrderTracker.tsx
25805
25915
  import { Show as Show79, For as For61, createSignal as createSignal55 } from "solid-js";
@@ -27701,14 +27811,14 @@ function MemberPortal(props) {
27701
27811
  };
27702
27812
  const [tab, setTab] = createSignal62(resolveTabFromUrl() ?? "tracker");
27703
27813
  const [intent, setIntent] = createSignal62(resolveIntentFromUrl());
27704
- onMount8(() => {
27814
+ onMount9(() => {
27705
27815
  const resolved = resolveTabFromUrl();
27706
27816
  if (resolved && resolved !== tab()) setTab(resolved);
27707
27817
  const resolvedIntent = resolveIntentFromUrl();
27708
27818
  if (resolvedIntent) setIntent(resolvedIntent);
27709
27819
  });
27710
27820
  const [offers, setOffers] = createSignal62([]);
27711
- onMount8(() => {
27821
+ onMount9(() => {
27712
27822
  if (!props.auth.isAuthenticated()) return;
27713
27823
  offersApi.mine().then((r) => setOffers(r.offers ?? [])).catch(() => setOffers([]));
27714
27824
  });
@@ -29974,6 +30084,7 @@ function primaryButtonStyle2(submitting) {
29974
30084
  export {
29975
30085
  SurveyPage,
29976
30086
  SurveyV2Page,
30087
+ SecureCardPanel,
29977
30088
  AddressFields,
29978
30089
  CheckoutPage,
29979
30090
  CartCheckoutPage,
@@ -30001,4 +30112,4 @@ export {
30001
30112
  AffiliateForgotPassword,
30002
30113
  AffiliateResetPassword
30003
30114
  };
30004
- //# sourceMappingURL=Q5OPCOWX.jsx.map
30115
+ //# sourceMappingURL=XJF3Z2IM.jsx.map