@apextelemed/partner-core 0.6.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +5 -3
- package/dist/{cart-D4mVX_zx.d.ts → cart-o6DpAu5y.d.ts} +1 -0
- package/dist/chunk/{4ZSZHZQV.jsx → 2OOCTPLG.jsx} +2 -2
- package/dist/chunk/{MLXPHJLR.js → 4HOG2LES.js} +7 -3
- package/dist/chunk/4HOG2LES.js.map +1 -0
- package/dist/chunk/{5HNZ7SEM.jsx → 6UXFHBE2.jsx} +45 -219
- package/dist/chunk/{HXMLRDIJ.jsx → AW6DQGQR.jsx} +647 -122
- package/dist/chunk/{NSRQXBHK.js → EHKYRS2R.js} +25 -189
- package/dist/chunk/EHKYRS2R.js.map +1 -0
- package/dist/chunk/{YJEHCCLY.js → EXXI5Y7I.js} +4 -3
- package/dist/chunk/EXXI5Y7I.js.map +1 -0
- package/dist/chunk/{WLEIDQ5M.jsx → GL3OY7W5.jsx} +6 -2
- package/dist/chunk/{ZDBW3JDO.jsx → GNPMRN6O.jsx} +3348 -1428
- package/dist/chunk/{QTGJY3YQ.js → HEQMD3X4.js} +3 -3
- package/dist/chunk/{QTGJY3YQ.js.map → HEQMD3X4.js.map} +1 -1
- package/dist/chunk/{WUE4VQBA.js → HKXDH266.js} +520 -23
- package/dist/chunk/HKXDH266.js.map +1 -0
- package/dist/chunk/{MTCQREMZ.js → HYLIHVIE.js} +4176 -2111
- package/dist/chunk/HYLIHVIE.js.map +1 -0
- package/dist/chunk/{EVCGDF5D.jsx → JF2KCOOX.jsx} +18 -1
- package/dist/chunk/{NBB2VTQK.jsx → QAFLR3EN.jsx} +2 -2
- package/dist/chunk/{2OXI5TKO.jsx → RSMUKR4J.jsx} +3 -2
- package/dist/chunk/{BEDW4XUM.js → RUA3XYFO.js} +19 -3
- package/dist/chunk/RUA3XYFO.js.map +1 -0
- package/dist/chunk/{BVLA7ATM.js → ZOZBYBNI.js} +3 -3
- package/dist/chunk/{BVLA7ATM.js.map → ZOZBYBNI.js.map} +1 -1
- package/dist/{client-B6Kt7LWo.d.ts → client-ZnA3JEbd.d.ts} +91 -8
- package/dist/flows/index.d.ts +246 -13
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +31 -13
- package/dist/index/index.d.ts +4 -4
- package/dist/index/index.js +8 -8
- package/dist/index/index.jsx +48 -16
- package/dist/pages/index.d.ts +41 -6
- package/dist/pages/index.js +5 -5
- package/dist/pages/index.jsx +19 -7
- package/dist/primitives/default/index.js +1 -1
- package/dist/primitives/default/index.jsx +1 -1
- package/dist/stores/index.d.ts +2 -2
- package/dist/stores/index.js +2 -2
- package/dist/stores/index.jsx +2 -2
- package/dist/testing/seam-suite.js +1 -1
- package/dist/theme/admin.css +406 -1
- package/dist/theme/member-portal.css +5 -5
- package/package.json +1 -1
- package/dist/chunk/BEDW4XUM.js.map +0 -1
- package/dist/chunk/MLXPHJLR.js.map +0 -1
- package/dist/chunk/MTCQREMZ.js.map +0 -1
- package/dist/chunk/NSRQXBHK.js.map +0 -1
- package/dist/chunk/WUE4VQBA.js.map +0 -1
- package/dist/chunk/YJEHCCLY.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './
|
|
2
|
-
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './
|
|
3
|
-
import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, affiliatePortalApi, ApiError, ordersApi,
|
|
1
|
+
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './HEQMD3X4.js';
|
|
2
|
+
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './4HOG2LES.js';
|
|
3
|
+
import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, ApiError, ordersApi, messagesApi, authApi } from './RUA3XYFO.js';
|
|
4
4
|
import { getConfig } from './5XGPFYIJ.js';
|
|
5
|
-
import { createSignal, onMount, createEffect, onCleanup, createResource } from 'solid-js';
|
|
5
|
+
import { createSignal, onMount, createEffect, on, onCleanup, createResource, createMemo } from 'solid-js';
|
|
6
6
|
import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
|
|
7
7
|
import { createLocalDraftStore, draftKey as draftKey$1 } from '@apextelemed/survey-core';
|
|
8
8
|
|
|
@@ -116,13 +116,23 @@ function useSurveyFlow(options = {}) {
|
|
|
116
116
|
const [createRequestKey, setCreateRequestKey] = createSignal(newIdempotencyKey());
|
|
117
117
|
const [hydrated, setHydrated] = createSignal(false);
|
|
118
118
|
const totalSteps = () => steps().length;
|
|
119
|
-
const isLastStep = () => currentStep() >= totalSteps() - 1;
|
|
120
119
|
const step2 = () => steps()[currentStep()] ?? null;
|
|
121
120
|
const visibleQuestions = () => {
|
|
122
121
|
const s = step2();
|
|
123
122
|
if (!s) return [];
|
|
124
123
|
return s.questions.filter((q) => isQuestionVisible(q, answers()));
|
|
125
124
|
};
|
|
125
|
+
const stepHasVisibleQuestions = (i) => {
|
|
126
|
+
const s = steps()[i];
|
|
127
|
+
return !!s && s.questions.some((q) => isQuestionVisible(q, answers()));
|
|
128
|
+
};
|
|
129
|
+
const nearestVisibleStep = (from, dir) => {
|
|
130
|
+
for (let i = from + dir; i >= 0 && i < steps().length; i += dir) {
|
|
131
|
+
if (stepHasVisibleQuestions(i)) return i;
|
|
132
|
+
}
|
|
133
|
+
return -1;
|
|
134
|
+
};
|
|
135
|
+
const isLastStep = () => nearestVisibleStep(currentStep(), 1) === -1;
|
|
126
136
|
onMount(async () => {
|
|
127
137
|
const cartItems = cart_default.items();
|
|
128
138
|
const hasCart = cartItems.length > 0;
|
|
@@ -184,7 +194,12 @@ function useSurveyFlow(options = {}) {
|
|
|
184
194
|
const draft = loadSurveyDraft();
|
|
185
195
|
if (draft.surveyId === sid) {
|
|
186
196
|
if (draft.answers) setAnswers(draft.answers);
|
|
187
|
-
|
|
197
|
+
const restoredStep = Math.min(Math.max(draft.currentStep ?? 0, 0), Math.max(flat.length - 1, 0));
|
|
198
|
+
setCurrentStep(restoredStep);
|
|
199
|
+
if (!stepHasVisibleQuestions(restoredStep)) {
|
|
200
|
+
const fwd = nearestVisibleStep(restoredStep, 1);
|
|
201
|
+
setCurrentStep(fwd !== -1 ? fwd : Math.max(nearestVisibleStep(restoredStep, -1), 0));
|
|
202
|
+
}
|
|
188
203
|
if (draft.responseId) setResponseId(draft.responseId);
|
|
189
204
|
if (draft.submitSurveyKey) setSubmitSurveyKey(draft.submitSurveyKey);
|
|
190
205
|
if (draft.createRequestKey) setCreateRequestKey(draft.createRequestKey);
|
|
@@ -419,11 +434,13 @@ function useSurveyFlow(options = {}) {
|
|
|
419
434
|
} finally {
|
|
420
435
|
setSubmitting(false);
|
|
421
436
|
}
|
|
422
|
-
|
|
437
|
+
const nextStep = nearestVisibleStep(currentStep(), 1);
|
|
438
|
+
if (nextStep !== -1) setCurrentStep(nextStep);
|
|
423
439
|
}
|
|
424
440
|
function back() {
|
|
425
441
|
setValidationError(null);
|
|
426
|
-
|
|
442
|
+
const prev = nearestVisibleStep(currentStep(), -1);
|
|
443
|
+
if (prev !== -1) setCurrentStep(prev);
|
|
427
444
|
}
|
|
428
445
|
async function confirmDrugSelection() {
|
|
429
446
|
if (!selectedDrugId()) {
|
|
@@ -708,6 +725,85 @@ function useAddressPair(options = {}) {
|
|
|
708
725
|
applyNormalized
|
|
709
726
|
};
|
|
710
727
|
}
|
|
728
|
+
var DEBOUNCE_MS = 300;
|
|
729
|
+
var STATE_RE = /^[A-Za-z]{2}$/;
|
|
730
|
+
var INERT_DECISION = {
|
|
731
|
+
unavailableIds: [],
|
|
732
|
+
blocking: false,
|
|
733
|
+
degraded: false
|
|
734
|
+
};
|
|
735
|
+
function deriveCatalogAvailabilityDecision(result) {
|
|
736
|
+
if (!result) return INERT_DECISION;
|
|
737
|
+
if (result.degraded === true) return { ...INERT_DECISION, degraded: true };
|
|
738
|
+
const unavailableIds = result.items.filter((item) => item.checked && item.available === false).map((item) => item.id);
|
|
739
|
+
return { unavailableIds, blocking: unavailableIds.length > 0, degraded: false };
|
|
740
|
+
}
|
|
741
|
+
function useCatalogAvailability(ids, state) {
|
|
742
|
+
const [loading, setLoading] = createSignal(false);
|
|
743
|
+
const [unavailableIds, setUnavailableIds] = createSignal([]);
|
|
744
|
+
const [degraded, setDegraded] = createSignal(false);
|
|
745
|
+
let generation = 0;
|
|
746
|
+
let timer;
|
|
747
|
+
let pending = null;
|
|
748
|
+
function markPending() {
|
|
749
|
+
if (pending) return;
|
|
750
|
+
let resolve;
|
|
751
|
+
const promise = new Promise((r) => resolve = r);
|
|
752
|
+
pending = { promise, resolve };
|
|
753
|
+
}
|
|
754
|
+
function markSettled() {
|
|
755
|
+
pending?.resolve();
|
|
756
|
+
pending = null;
|
|
757
|
+
}
|
|
758
|
+
function settleInert() {
|
|
759
|
+
setLoading(false);
|
|
760
|
+
setUnavailableIds([]);
|
|
761
|
+
setDegraded(false);
|
|
762
|
+
markSettled();
|
|
763
|
+
}
|
|
764
|
+
createEffect(
|
|
765
|
+
on([ids, state], ([currentIds, currentState]) => {
|
|
766
|
+
if (timer) clearTimeout(timer);
|
|
767
|
+
const requestedIds = [...new Set(currentIds.map((id) => id.trim()).filter(Boolean))];
|
|
768
|
+
const normalizedState = (currentState ?? "").trim().toUpperCase();
|
|
769
|
+
const gen = ++generation;
|
|
770
|
+
if (requestedIds.length === 0 || !STATE_RE.test(normalizedState)) {
|
|
771
|
+
settleInert();
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
setLoading(true);
|
|
775
|
+
markPending();
|
|
776
|
+
timer = setTimeout(() => {
|
|
777
|
+
catalogApi.availability(requestedIds, normalizedState).then((result) => {
|
|
778
|
+
if (gen !== generation) return;
|
|
779
|
+
const decision = deriveCatalogAvailabilityDecision(result);
|
|
780
|
+
setUnavailableIds(decision.unavailableIds);
|
|
781
|
+
setDegraded(decision.degraded);
|
|
782
|
+
}).catch(() => {
|
|
783
|
+
if (gen !== generation) return;
|
|
784
|
+
setUnavailableIds([]);
|
|
785
|
+
setDegraded(false);
|
|
786
|
+
}).finally(() => {
|
|
787
|
+
if (gen !== generation) return;
|
|
788
|
+
setLoading(false);
|
|
789
|
+
markSettled();
|
|
790
|
+
});
|
|
791
|
+
}, DEBOUNCE_MS);
|
|
792
|
+
})
|
|
793
|
+
);
|
|
794
|
+
onCleanup(() => {
|
|
795
|
+
if (timer) clearTimeout(timer);
|
|
796
|
+
generation++;
|
|
797
|
+
markSettled();
|
|
798
|
+
});
|
|
799
|
+
const blocking = () => !degraded() && unavailableIds().length > 0;
|
|
800
|
+
const isUnavailable = (id) => unavailableIds().includes(id);
|
|
801
|
+
const settled = () => pending?.promise ?? Promise.resolve();
|
|
802
|
+
return { loading, blocking, degraded, unavailableIds, isUnavailable, settled };
|
|
803
|
+
}
|
|
804
|
+
function catalogUnavailableMessage(itemName, state) {
|
|
805
|
+
return `${itemName} isn\u2019t available for delivery to ${stateLabel(state)}.`;
|
|
806
|
+
}
|
|
711
807
|
function useCardTokenizer() {
|
|
712
808
|
const [config, setConfig] = createSignal(null);
|
|
713
809
|
const [scriptLoaded, setScriptLoaded] = createSignal(false);
|
|
@@ -910,7 +1006,14 @@ function useCheckoutFlow(options = {}) {
|
|
|
910
1006
|
promoCode: cart_default.appliedPromo()?.code
|
|
911
1007
|
};
|
|
912
1008
|
};
|
|
913
|
-
const
|
|
1009
|
+
const availability = useCatalogAvailability(
|
|
1010
|
+
() => {
|
|
1011
|
+
const drugId = prescription()?.drugId;
|
|
1012
|
+
return drugId ? [drugId] : [];
|
|
1013
|
+
},
|
|
1014
|
+
() => address.shipping().state
|
|
1015
|
+
);
|
|
1016
|
+
const canSubmit = () => (hasPaymentMethod() || accept.ready()) && !availability.blocking();
|
|
914
1017
|
onMount(async () => {
|
|
915
1018
|
try {
|
|
916
1019
|
const [profileRes, subsRes] = await Promise.all([
|
|
@@ -985,6 +1088,11 @@ function useCheckoutFlow(options = {}) {
|
|
|
985
1088
|
setPaymentError("Missing medication details.");
|
|
986
1089
|
return;
|
|
987
1090
|
}
|
|
1091
|
+
await availability.settled();
|
|
1092
|
+
if (availability.blocking()) {
|
|
1093
|
+
setPaymentError(catalogUnavailableMessage(rx.drugName || "This medication", address.shipping().state));
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
988
1096
|
if (!address.validate()) {
|
|
989
1097
|
const badShipping = hasErrors(address.shippingErrors());
|
|
990
1098
|
const badBilling = hasErrors(address.billingErrors());
|
|
@@ -1064,6 +1172,7 @@ function useCheckoutFlow(options = {}) {
|
|
|
1064
1172
|
outcome,
|
|
1065
1173
|
profile,
|
|
1066
1174
|
address,
|
|
1175
|
+
availability,
|
|
1067
1176
|
pricing,
|
|
1068
1177
|
hasPaymentMethod,
|
|
1069
1178
|
tokenizerReady: accept.ready,
|
|
@@ -1125,6 +1234,10 @@ function useCartCheckoutFlow() {
|
|
|
1125
1234
|
});
|
|
1126
1235
|
const items = () => cart_default.items().filter((i) => i.isSubscription !== true);
|
|
1127
1236
|
const skippedSubscriptionItems = () => cart_default.items().filter((i) => i.isSubscription === true);
|
|
1237
|
+
const availability = useCatalogAvailability(
|
|
1238
|
+
() => items().map((i) => i.productId),
|
|
1239
|
+
() => address.shipping().state
|
|
1240
|
+
);
|
|
1128
1241
|
const pricing = () => {
|
|
1129
1242
|
const subtotalCents = items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);
|
|
1130
1243
|
const promo = cart_default.appliedPromo();
|
|
@@ -1142,7 +1255,7 @@ function useCartCheckoutFlow() {
|
|
|
1142
1255
|
promoCode: promo?.code
|
|
1143
1256
|
};
|
|
1144
1257
|
};
|
|
1145
|
-
const canSubmit = () => accept.ready();
|
|
1258
|
+
const canSubmit = () => accept.ready() && !availability.blocking();
|
|
1146
1259
|
onMount(async () => {
|
|
1147
1260
|
if (!auth_default.isAuthenticated()) {
|
|
1148
1261
|
setOutcome({ kind: "needs_auth" });
|
|
@@ -1211,6 +1324,13 @@ function useCartCheckoutFlow() {
|
|
|
1211
1324
|
setOutcome({ kind: "needs_cart" });
|
|
1212
1325
|
return;
|
|
1213
1326
|
}
|
|
1327
|
+
await availability.settled();
|
|
1328
|
+
if (availability.blocking()) {
|
|
1329
|
+
setPaymentError(
|
|
1330
|
+
"One or more items in your cart aren\u2019t available for delivery to your address. Please remove them or update your shipping state."
|
|
1331
|
+
);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1214
1334
|
if (!address.validate()) {
|
|
1215
1335
|
const badShipping = hasErrors(address.shippingErrors());
|
|
1216
1336
|
const badBilling = hasErrors(address.billingErrors());
|
|
@@ -1309,6 +1429,7 @@ function useCartCheckoutFlow() {
|
|
|
1309
1429
|
address,
|
|
1310
1430
|
items,
|
|
1311
1431
|
skippedSubscriptionItems,
|
|
1432
|
+
availability,
|
|
1312
1433
|
pricing,
|
|
1313
1434
|
tokenizerReady: accept.ready,
|
|
1314
1435
|
acceptJsLoaded: accept.ready,
|
|
@@ -1382,6 +1503,10 @@ function useSignupFlow(options) {
|
|
|
1382
1503
|
const [tokenizedData, setTokenizedData] = createSignal(null);
|
|
1383
1504
|
const [promoCode, setPromoCode] = createSignal("");
|
|
1384
1505
|
const [idempotencyKey, setIdempotencyKey] = createSignal(newIdempotencyKey());
|
|
1506
|
+
const cartIsEmpty = () => cart_default.items().length === 0;
|
|
1507
|
+
onMount(() => {
|
|
1508
|
+
if (options.requireCart && cartIsEmpty()) setOutcome({ kind: "needs_cart" });
|
|
1509
|
+
});
|
|
1385
1510
|
onMount(() => {
|
|
1386
1511
|
createEffect(() => {
|
|
1387
1512
|
saveDraft({
|
|
@@ -1487,6 +1612,10 @@ function useSignupFlow(options) {
|
|
|
1487
1612
|
}
|
|
1488
1613
|
async function submit() {
|
|
1489
1614
|
if (submitting()) return;
|
|
1615
|
+
if (options.requireCart && cartIsEmpty()) {
|
|
1616
|
+
setOutcome({ kind: "needs_cart" });
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1490
1619
|
const opaque = tokenizedData();
|
|
1491
1620
|
if (!opaque) {
|
|
1492
1621
|
setError("Card not tokenized. Please go back and re-enter your card details.");
|
|
@@ -1866,10 +1995,18 @@ function useSubscribeFlow(options) {
|
|
|
1866
1995
|
const [outcome, setOutcome] = createSignal({ kind: "loading" });
|
|
1867
1996
|
const [error, setError] = createSignal(null);
|
|
1868
1997
|
const [submitting, setSubmitting] = createSignal(false);
|
|
1998
|
+
const [quote, setQuote] = createSignal(null);
|
|
1999
|
+
const [quoteError, setQuoteError] = createSignal(null);
|
|
1869
2000
|
const [street, setStreet] = createSignal("");
|
|
1870
2001
|
const [city, setCity] = createSignal("");
|
|
1871
2002
|
const [state, setState] = createSignal("");
|
|
1872
2003
|
const [zip, setZip] = createSignal("");
|
|
2004
|
+
const [profileState, setProfileState] = createSignal("");
|
|
2005
|
+
const shipState = () => profileState() || state();
|
|
2006
|
+
const availability = useCatalogAvailability(
|
|
2007
|
+
() => cart_default.items().map((i) => i.productId),
|
|
2008
|
+
shipState
|
|
2009
|
+
);
|
|
1873
2010
|
const [cardNumberRaw, setCardNumberRaw] = createSignal("", { equals: false });
|
|
1874
2011
|
const [expiryRaw, setExpiryRaw] = createSignal("", { equals: false });
|
|
1875
2012
|
const [cvvRaw, setCvvRaw] = createSignal("", { equals: false });
|
|
@@ -1897,12 +2034,90 @@ function useSubscribeFlow(options) {
|
|
|
1897
2034
|
setStreet(p.address1 || p.street || "");
|
|
1898
2035
|
setCity(p.city || "");
|
|
1899
2036
|
setState(normalizeState(p.state || ""));
|
|
2037
|
+
setProfileState(normalizeState(p.state || ""));
|
|
1900
2038
|
setZip(p.zip || "");
|
|
1901
2039
|
}
|
|
1902
2040
|
} catch {
|
|
1903
2041
|
}
|
|
1904
2042
|
setOutcome({ kind: "in_progress" });
|
|
1905
2043
|
});
|
|
2044
|
+
const cartProducts = () => cart_default.items().map((i) => ({
|
|
2045
|
+
productId: i.productId,
|
|
2046
|
+
productName: i.productName,
|
|
2047
|
+
quantity: i.quantity,
|
|
2048
|
+
dosage: i.dosage
|
|
2049
|
+
}));
|
|
2050
|
+
function estimateFromCart() {
|
|
2051
|
+
const lines = cart_default.items().map((i) => ({
|
|
2052
|
+
productId: i.productId,
|
|
2053
|
+
productName: i.productName,
|
|
2054
|
+
dosage: i.dosage || null,
|
|
2055
|
+
quantity: i.quantity || 1,
|
|
2056
|
+
amountCents: i.priceCents * (i.quantity || 1)
|
|
2057
|
+
}));
|
|
2058
|
+
let subtotalCents = lines.reduce((s, l) => s + l.amountCents, 0);
|
|
2059
|
+
if (subtotalCents === 0 && lines.length === 0) subtotalCents = options.membershipAmountCents;
|
|
2060
|
+
const discountCents = Math.min(subtotalCents, cart_default.appliedPromo()?.discountCents ?? 0);
|
|
2061
|
+
return {
|
|
2062
|
+
source: "estimate",
|
|
2063
|
+
model: "per_product",
|
|
2064
|
+
intervalDays: options.membershipIntervalDays ?? 30,
|
|
2065
|
+
lines,
|
|
2066
|
+
subtotalCents,
|
|
2067
|
+
discountCents,
|
|
2068
|
+
totalCents: subtotalCents - discountCents
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
let quoteSeq = 0;
|
|
2072
|
+
async function refreshQuote() {
|
|
2073
|
+
const seq = ++quoteSeq;
|
|
2074
|
+
setQuoteError(null);
|
|
2075
|
+
try {
|
|
2076
|
+
const p = await subscriptionsApi.preview({
|
|
2077
|
+
products: cartProducts(),
|
|
2078
|
+
productId: cartProducts()[0]?.productId,
|
|
2079
|
+
promoCode: cart_default.appliedPromo()?.code,
|
|
2080
|
+
intervalDays: options.membershipIntervalDays
|
|
2081
|
+
});
|
|
2082
|
+
if (seq !== quoteSeq) return;
|
|
2083
|
+
if (p.alreadySubscribed) {
|
|
2084
|
+
setOutcome({ kind: "already_subscribed" });
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
setQuote({
|
|
2088
|
+
source: "server",
|
|
2089
|
+
model: p.model,
|
|
2090
|
+
intervalDays: p.intervalDays,
|
|
2091
|
+
lines: (p.lines ?? []).map((l) => ({
|
|
2092
|
+
productId: l.productId,
|
|
2093
|
+
productName: l.productName,
|
|
2094
|
+
dosage: l.dosage ?? null,
|
|
2095
|
+
quantity: l.quantity,
|
|
2096
|
+
amountCents: l.amountCents
|
|
2097
|
+
})),
|
|
2098
|
+
subtotalCents: p.subtotalCents,
|
|
2099
|
+
discountCents: p.discountCents,
|
|
2100
|
+
totalCents: p.totalCents
|
|
2101
|
+
});
|
|
2102
|
+
} catch (e) {
|
|
2103
|
+
if (seq !== quoteSeq) return;
|
|
2104
|
+
const status = e instanceof ApiError ? e.status : void 0;
|
|
2105
|
+
if (status && status >= 400 && status < 500 && status !== 404 && status !== 405) {
|
|
2106
|
+
setQuote(null);
|
|
2107
|
+
setQuoteError(e instanceof Error ? e.message : "This order cannot be priced right now.");
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
setQuote(estimateFromCart());
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
createEffect(
|
|
2114
|
+
on(
|
|
2115
|
+
() => [outcome().kind, cart_default.items(), cart_default.appliedPromo()],
|
|
2116
|
+
([kind]) => {
|
|
2117
|
+
if (kind === "in_progress") void refreshQuote();
|
|
2118
|
+
}
|
|
2119
|
+
)
|
|
2120
|
+
);
|
|
1906
2121
|
function validate() {
|
|
1907
2122
|
const a = validateAddress(
|
|
1908
2123
|
{ street: street(), city: city(), state: state(), zip: zip() },
|
|
@@ -1916,6 +2131,7 @@ function useSubscribeFlow(options) {
|
|
|
1916
2131
|
if (!cvvRaw().trim()) return "CVV is required.";
|
|
1917
2132
|
return null;
|
|
1918
2133
|
}
|
|
2134
|
+
let awaitingAvailability = false;
|
|
1919
2135
|
async function submit() {
|
|
1920
2136
|
if (submitting()) return;
|
|
1921
2137
|
if (!auth_default.isAuthenticated()) {
|
|
@@ -1926,6 +2142,22 @@ function useSubscribeFlow(options) {
|
|
|
1926
2142
|
setOutcome({ kind: "needs_cart" });
|
|
1927
2143
|
return;
|
|
1928
2144
|
}
|
|
2145
|
+
if (quoteError()) {
|
|
2146
|
+
setError(quoteError());
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
if (awaitingAvailability) return;
|
|
2150
|
+
awaitingAvailability = true;
|
|
2151
|
+
try {
|
|
2152
|
+
await availability.settled();
|
|
2153
|
+
} finally {
|
|
2154
|
+
awaitingAvailability = false;
|
|
2155
|
+
}
|
|
2156
|
+
if (availability.blocking()) {
|
|
2157
|
+
const unavailableItem = cart_default.items().find((i) => availability.isUnavailable(i.productId));
|
|
2158
|
+
setError(catalogUnavailableMessage(unavailableItem?.productName ?? "One of your items", shipState()));
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
1929
2161
|
const err = validate();
|
|
1930
2162
|
if (err) {
|
|
1931
2163
|
setError(err);
|
|
@@ -1949,7 +2181,9 @@ function useSubscribeFlow(options) {
|
|
|
1949
2181
|
const res = await subscriptionsApi.create(
|
|
1950
2182
|
{
|
|
1951
2183
|
opaqueData: opaque,
|
|
1952
|
-
|
|
2184
|
+
// Informational only — the backend prices the cart itself. Send what
|
|
2185
|
+
// the customer was shown so the two are auditable together.
|
|
2186
|
+
amountCents: quote()?.totalCents ?? options.membershipAmountCents,
|
|
1953
2187
|
intervalDays: options.membershipIntervalDays ?? 30,
|
|
1954
2188
|
billingAddress: {
|
|
1955
2189
|
street: street().trim(),
|
|
@@ -1997,6 +2231,8 @@ function useSubscribeFlow(options) {
|
|
|
1997
2231
|
acceptJsError: accept.error,
|
|
1998
2232
|
error,
|
|
1999
2233
|
submitting,
|
|
2234
|
+
quote,
|
|
2235
|
+
quoteError,
|
|
2000
2236
|
street,
|
|
2001
2237
|
setStreet,
|
|
2002
2238
|
city,
|
|
@@ -2005,6 +2241,8 @@ function useSubscribeFlow(options) {
|
|
|
2005
2241
|
setState,
|
|
2006
2242
|
zip,
|
|
2007
2243
|
setZip,
|
|
2244
|
+
availability,
|
|
2245
|
+
shipState,
|
|
2008
2246
|
cardNumber: cardNumberRaw,
|
|
2009
2247
|
setCardNumber: (v) => setCardNumberRaw(formatCardNumber(v)),
|
|
2010
2248
|
expiry: expiryRaw,
|
|
@@ -2374,7 +2612,7 @@ var LIFECYCLE_LABEL = {
|
|
|
2374
2612
|
past_due: "Past due",
|
|
2375
2613
|
paused: "Paused",
|
|
2376
2614
|
incomplete: "Incomplete signup",
|
|
2377
|
-
cancelled: "
|
|
2615
|
+
cancelled: "Canceled",
|
|
2378
2616
|
card_declined: "Card declined",
|
|
2379
2617
|
awaiting_prescriber: "Awaiting prescriber",
|
|
2380
2618
|
never_subscribed: "Never subscribed"
|
|
@@ -2528,12 +2766,12 @@ function lifecycleReason(o) {
|
|
|
2528
2766
|
o.subscriptions.filter((x) => x.status === "cancelled"),
|
|
2529
2767
|
(x) => x.cancelledAt
|
|
2530
2768
|
)[0] ?? sub;
|
|
2531
|
-
if (!s) return "Subscription
|
|
2769
|
+
if (!s) return "Subscription canceled.";
|
|
2532
2770
|
const started = ms(s.createdAt);
|
|
2533
2771
|
const ended = ms(s.cancelledAt);
|
|
2534
2772
|
const months = started !== null && ended !== null ? Math.max(0, Math.round((ended - started) / (30 * DAY_MS2))) : null;
|
|
2535
2773
|
const tenure = months !== null && months > 0 ? ` after ${months} month${months === 1 ? "" : "s"}` : "";
|
|
2536
|
-
return `
|
|
2774
|
+
return `Canceled on ${fmtDay(s.cancelledAt)}${tenure}.`;
|
|
2537
2775
|
}
|
|
2538
2776
|
default:
|
|
2539
2777
|
return o.lifecycle.label || "";
|
|
@@ -2659,7 +2897,7 @@ function deriveAttention(o, now = /* @__PURE__ */ new Date()) {
|
|
|
2659
2897
|
id: "cancelled-with-pending",
|
|
2660
2898
|
severity: "warning",
|
|
2661
2899
|
title: `${pending.length} unapproved prescription request${pending.length === 1 ? " is" : "s are"} still in the prescriber queue after cancellation`,
|
|
2662
|
-
detail: "A
|
|
2900
|
+
detail: "A canceled customer should not be prescribed. Cancel the pending requests.",
|
|
2663
2901
|
action: { kind: "cancel_unapproved", label: "Cancel unapproved requests" }
|
|
2664
2902
|
});
|
|
2665
2903
|
}
|
|
@@ -2685,8 +2923,8 @@ var JOURNEY_LABEL = {
|
|
|
2685
2923
|
shipped: "Shipped",
|
|
2686
2924
|
renewing: "Renewing"
|
|
2687
2925
|
};
|
|
2688
|
-
function step(key, state, date = null, detail = null) {
|
|
2689
|
-
return { key, label
|
|
2926
|
+
function step(key, state, date = null, detail = null, label = JOURNEY_LABEL[key]) {
|
|
2927
|
+
return { key, label, state, date, detail };
|
|
2690
2928
|
}
|
|
2691
2929
|
function deriveJourney(o) {
|
|
2692
2930
|
const steps = [];
|
|
@@ -2818,7 +3056,7 @@ function deriveJourney(o) {
|
|
|
2818
3056
|
}
|
|
2819
3057
|
} else if (subs.some((s) => s.status === "cancelled")) {
|
|
2820
3058
|
const c = newestFirst(subs.filter((s) => s.status === "cancelled"), (s) => s.cancelledAt)[0];
|
|
2821
|
-
steps.push(step("renewing", "blocked", c?.cancelledAt ?? null, "
|
|
3059
|
+
steps.push(step("renewing", "blocked", c?.cancelledAt ?? null, "Subscription ended", "Canceled"));
|
|
2822
3060
|
} else {
|
|
2823
3061
|
steps.push(step("renewing", "upcoming"));
|
|
2824
3062
|
}
|
|
@@ -2918,7 +3156,7 @@ function buildTimeline(o, limit = 200) {
|
|
|
2918
3156
|
ev.push({ id: `sub-paused-${s.id}`, at: s.pausedAt, kind: "subscription", title: "Subscription paused", tone: "neutral" });
|
|
2919
3157
|
}
|
|
2920
3158
|
if (s.cancelledAt) {
|
|
2921
|
-
ev.push({ id: `sub-cancelled-${s.id}`, at: s.cancelledAt, kind: "subscription", title: "Subscription
|
|
3159
|
+
ev.push({ id: `sub-cancelled-${s.id}`, at: s.cancelledAt, kind: "subscription", title: "Subscription canceled", tone: "danger" });
|
|
2922
3160
|
}
|
|
2923
3161
|
for (const a of s.billingAttempts ?? []) {
|
|
2924
3162
|
if (a.status === "succeeded") continue;
|
|
@@ -3203,10 +3441,12 @@ async function subscribeToSupportTopic(topic, onPing) {
|
|
|
3203
3441
|
try {
|
|
3204
3442
|
const config = await supportApi.getRealtimeToken();
|
|
3205
3443
|
if (!config?.token || !config.url || !config.anonKey) return null;
|
|
3444
|
+
const topicName = typeof topic === "string" ? topic : config.topics ? topic(config.topics) : void 0;
|
|
3445
|
+
if (!topicName) return null;
|
|
3206
3446
|
const { createClient } = await import('@supabase/supabase-js');
|
|
3207
3447
|
const client = createClient(config.url, config.anonKey);
|
|
3208
3448
|
await client.realtime.setAuth(config.token);
|
|
3209
|
-
const channel = client.channel(
|
|
3449
|
+
const channel = client.channel(topicName, {
|
|
3210
3450
|
config: { private: true }
|
|
3211
3451
|
});
|
|
3212
3452
|
channel.on("broadcast", { event: "thread_updated" }, (message) => {
|
|
@@ -3701,6 +3941,224 @@ function useMessagesThread(options = {}) {
|
|
|
3701
3941
|
resolveAttachmentUrl
|
|
3702
3942
|
};
|
|
3703
3943
|
}
|
|
3944
|
+
function priceForDosage(product, dosage) {
|
|
3945
|
+
const overlay = (product.dosage_prices ?? []).find((d) => d.dosage === dosage);
|
|
3946
|
+
if (overlay && overlay.price != null) return overlay.price;
|
|
3947
|
+
return product.price;
|
|
3948
|
+
}
|
|
3949
|
+
function lowestPrice(product) {
|
|
3950
|
+
const available = product.available_dosages ?? [];
|
|
3951
|
+
if (available.length === 0) return product.price;
|
|
3952
|
+
let min = null;
|
|
3953
|
+
for (const dose of available) {
|
|
3954
|
+
const p = priceForDosage(product, dose);
|
|
3955
|
+
if (p != null && (min == null || p < min)) min = p;
|
|
3956
|
+
}
|
|
3957
|
+
return min ?? product.price;
|
|
3958
|
+
}
|
|
3959
|
+
function salePriceForBase(product, basePrice) {
|
|
3960
|
+
if (basePrice == null || !product.activeSale) return null;
|
|
3961
|
+
const sale = product.activeSale;
|
|
3962
|
+
const baseCents = Math.round(basePrice * 100);
|
|
3963
|
+
if (sale.discountCents <= 0) return null;
|
|
3964
|
+
if (product.salePriceCents != null && product.price != null && Math.abs(product.price - basePrice) < 1e-3) {
|
|
3965
|
+
return product.salePriceCents / 100;
|
|
3966
|
+
}
|
|
3967
|
+
if (product.price != null && product.salePriceCents != null && product.price > 0) {
|
|
3968
|
+
const ratio = product.salePriceCents / Math.round(product.price * 100);
|
|
3969
|
+
return Math.max(0, basePrice * ratio);
|
|
3970
|
+
}
|
|
3971
|
+
return Math.max(0, (baseCents - sale.discountCents) / 100);
|
|
3972
|
+
}
|
|
3973
|
+
function lowestSalePrice(product, basePrice) {
|
|
3974
|
+
return salePriceForBase(product, basePrice);
|
|
3975
|
+
}
|
|
3976
|
+
function useCatalog() {
|
|
3977
|
+
const [products] = createResource(async () => {
|
|
3978
|
+
try {
|
|
3979
|
+
const res = await productsApi.list();
|
|
3980
|
+
return res.products;
|
|
3981
|
+
} catch {
|
|
3982
|
+
return [];
|
|
3983
|
+
}
|
|
3984
|
+
});
|
|
3985
|
+
const weightLoss = () => (products() ?? []).filter((p) => (p.categories ?? []).includes("weight-loss"));
|
|
3986
|
+
const peptides = () => (products() ?? []).filter((p) => !(p.categories ?? []).includes("weight-loss"));
|
|
3987
|
+
const filterByCategory = (slug) => (products() ?? []).filter((p) => (p.categories ?? []).includes(slug));
|
|
3988
|
+
return { products, weightLoss, peptides, filterByCategory };
|
|
3989
|
+
}
|
|
3990
|
+
function useProductDetail(productId) {
|
|
3991
|
+
const [product] = createResource(productId, async (id) => {
|
|
3992
|
+
if (!id) return null;
|
|
3993
|
+
try {
|
|
3994
|
+
const res = await productsApi.list();
|
|
3995
|
+
return res.products.find((p) => p.id === id) ?? null;
|
|
3996
|
+
} catch {
|
|
3997
|
+
return null;
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
4000
|
+
const pricingMode = createMemo(
|
|
4001
|
+
() => product()?.pricing_mode ?? "per_dose"
|
|
4002
|
+
);
|
|
4003
|
+
const dosageOptions = createMemo(() => {
|
|
4004
|
+
const p = product();
|
|
4005
|
+
if (!p) return [];
|
|
4006
|
+
const all = (p.available_dosages ?? []).map((dosage) => {
|
|
4007
|
+
const overlay = (p.dosage_prices ?? []).find((d) => d.dosage === dosage);
|
|
4008
|
+
const price = overlay && overlay.price != null ? overlay.price : p.price;
|
|
4009
|
+
return { dosage, price, savingsPrice: overlay?.savingsPrice ?? null };
|
|
4010
|
+
}).filter((o) => o.price != null);
|
|
4011
|
+
if (pricingMode() !== "flat_fee" || all.length === 0) return all;
|
|
4012
|
+
const override = p.dosage_override;
|
|
4013
|
+
const chosen = override && all.find((d) => d.dosage === override) || all[0];
|
|
4014
|
+
return [chosen];
|
|
4015
|
+
});
|
|
4016
|
+
const [selectedDosage, setSelectedDosage] = createSignal("");
|
|
4017
|
+
createMemo(() => {
|
|
4018
|
+
const opts = dosageOptions();
|
|
4019
|
+
if (opts.length > 0 && !selectedDosage()) setSelectedDosage(opts[0].dosage);
|
|
4020
|
+
});
|
|
4021
|
+
const selectedPrice = createMemo(() => {
|
|
4022
|
+
const opts = dosageOptions();
|
|
4023
|
+
const chosen = opts.find((d) => d.dosage === selectedDosage());
|
|
4024
|
+
if (chosen) return chosen.price;
|
|
4025
|
+
return product()?.price ?? null;
|
|
4026
|
+
});
|
|
4027
|
+
const selectedSalePrice = createMemo(() => {
|
|
4028
|
+
const p = product();
|
|
4029
|
+
const base = selectedPrice();
|
|
4030
|
+
if (!p || base == null || !p.activeSale) return null;
|
|
4031
|
+
if (p.salePriceCents != null && p.price != null && p.price > 0) {
|
|
4032
|
+
const ratio = p.salePriceCents / Math.round(p.price * 100);
|
|
4033
|
+
return Math.max(0, base * ratio);
|
|
4034
|
+
}
|
|
4035
|
+
return Math.max(0, base - p.activeSale.discountCents / 100);
|
|
4036
|
+
});
|
|
4037
|
+
const inCart = createMemo(() => {
|
|
4038
|
+
const p = product();
|
|
4039
|
+
if (!p) return false;
|
|
4040
|
+
const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
|
|
4041
|
+
const key = cart_default.itemKey(p.id, dosage);
|
|
4042
|
+
return cart_default.items().some((i) => cart_default.itemKey(i.productId, i.dosage) === key);
|
|
4043
|
+
});
|
|
4044
|
+
function addToCart() {
|
|
4045
|
+
const p = product();
|
|
4046
|
+
if (!p) return;
|
|
4047
|
+
const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
|
|
4048
|
+
const effective = selectedSalePrice() ?? selectedPrice() ?? 0;
|
|
4049
|
+
const priceCents = Math.round(effective * 100);
|
|
4050
|
+
cart_default.add({
|
|
4051
|
+
productId: p.id,
|
|
4052
|
+
productName: p.name,
|
|
4053
|
+
dosage,
|
|
4054
|
+
quantity: 1,
|
|
4055
|
+
priceCents,
|
|
4056
|
+
drugId: p.id,
|
|
4057
|
+
apexDrugId: p.apex_drug_id ?? null,
|
|
4058
|
+
categories: p.categories ?? [],
|
|
4059
|
+
thumbnailUrl: p.thumbnail_url ?? void 0,
|
|
4060
|
+
hideDoseLabel: pricingMode() === "flat_fee" ? true : void 0,
|
|
4061
|
+
isSubscription: p.is_subscription ? true : void 0
|
|
4062
|
+
});
|
|
4063
|
+
cart_default.open();
|
|
4064
|
+
}
|
|
4065
|
+
return {
|
|
4066
|
+
product,
|
|
4067
|
+
dosageOptions,
|
|
4068
|
+
selectedDosage,
|
|
4069
|
+
setSelectedDosage,
|
|
4070
|
+
selectedPrice,
|
|
4071
|
+
selectedSalePrice,
|
|
4072
|
+
pricingMode,
|
|
4073
|
+
inCart,
|
|
4074
|
+
addToCart
|
|
4075
|
+
};
|
|
4076
|
+
}
|
|
4077
|
+
function useMedicationSelect(options = {}) {
|
|
4078
|
+
const catalog = useCatalog();
|
|
4079
|
+
function selectMedication(product) {
|
|
4080
|
+
medication_default.select({ drugId: product.id, drugName: product.name });
|
|
4081
|
+
options.onSelected?.();
|
|
4082
|
+
}
|
|
4083
|
+
function selectGeneralConsultation() {
|
|
4084
|
+
medication_default.select({
|
|
4085
|
+
drugId: null,
|
|
4086
|
+
drugName: options.generalConsultationLabel ?? "General Consultation"
|
|
4087
|
+
});
|
|
4088
|
+
options.onSelected?.();
|
|
4089
|
+
}
|
|
4090
|
+
return {
|
|
4091
|
+
products: catalog.products,
|
|
4092
|
+
weightLoss: catalog.weightLoss,
|
|
4093
|
+
peptides: catalog.peptides,
|
|
4094
|
+
selectMedication,
|
|
4095
|
+
selectGeneralConsultation
|
|
4096
|
+
};
|
|
4097
|
+
}
|
|
4098
|
+
function snapshotChanged(before, after) {
|
|
4099
|
+
return before.productName !== after.productName || before.priceCents !== after.priceCents || (before.apexDrugId ?? null) !== (after.apexDrugId ?? null) || !!before.isSubscription !== !!after.isSubscription || !!before.hideDoseLabel !== !!after.hideDoseLabel;
|
|
4100
|
+
}
|
|
4101
|
+
function reconcileCartLines(items, products, opts = {}) {
|
|
4102
|
+
const byId = new Map(products.map((p) => [p.id, p]));
|
|
4103
|
+
const kept = [];
|
|
4104
|
+
const dropped = [];
|
|
4105
|
+
const refreshed = [];
|
|
4106
|
+
for (const item of items) {
|
|
4107
|
+
const product = byId.get(item.productId);
|
|
4108
|
+
if (!product) {
|
|
4109
|
+
dropped.push({ item, reason: "unavailable" });
|
|
4110
|
+
continue;
|
|
4111
|
+
}
|
|
4112
|
+
if (opts.requireApexDrug && !product.apex_drug_id) {
|
|
4113
|
+
dropped.push({ item, reason: "not_prescribable" });
|
|
4114
|
+
continue;
|
|
4115
|
+
}
|
|
4116
|
+
const base = priceForDosage(product, item.dosage);
|
|
4117
|
+
if (base == null) {
|
|
4118
|
+
dropped.push({ item, reason: "unpriced" });
|
|
4119
|
+
continue;
|
|
4120
|
+
}
|
|
4121
|
+
const effective = salePriceForBase(product, base) ?? base;
|
|
4122
|
+
const next = {
|
|
4123
|
+
...item,
|
|
4124
|
+
productName: product.name,
|
|
4125
|
+
priceCents: Math.round(effective * 100),
|
|
4126
|
+
apexDrugId: product.apex_drug_id ?? null,
|
|
4127
|
+
categories: product.categories ?? [],
|
|
4128
|
+
thumbnailUrl: product.thumbnail_url ?? void 0,
|
|
4129
|
+
hideDoseLabel: product.pricing_mode === "flat_fee" ? true : void 0,
|
|
4130
|
+
isSubscription: product.is_subscription ? true : void 0
|
|
4131
|
+
};
|
|
4132
|
+
if (snapshotChanged(item, next)) refreshed.push(next);
|
|
4133
|
+
kept.push(next);
|
|
4134
|
+
}
|
|
4135
|
+
return { items: kept, dropped, refreshed, checked: true };
|
|
4136
|
+
}
|
|
4137
|
+
var UNCHECKED = { items: [], dropped: [], refreshed: [], checked: false };
|
|
4138
|
+
async function reconcileCartAgainstCatalog(opts = {}) {
|
|
4139
|
+
const items = cart_default.items();
|
|
4140
|
+
if (items.length === 0) return { ...UNCHECKED, checked: true };
|
|
4141
|
+
let products;
|
|
4142
|
+
try {
|
|
4143
|
+
products = (await productsApi.list()).products ?? [];
|
|
4144
|
+
} catch {
|
|
4145
|
+
return UNCHECKED;
|
|
4146
|
+
}
|
|
4147
|
+
if (products.length === 0) return UNCHECKED;
|
|
4148
|
+
const result = reconcileCartLines(items, products, opts);
|
|
4149
|
+
if (result.dropped.length > 0 || result.refreshed.length > 0) {
|
|
4150
|
+
cart_default.replace(result.items);
|
|
4151
|
+
}
|
|
4152
|
+
return result;
|
|
4153
|
+
}
|
|
4154
|
+
function useCartReconcile(opts = {}) {
|
|
4155
|
+
const [result] = createResource(() => reconcileCartAgainstCatalog(opts));
|
|
4156
|
+
return {
|
|
4157
|
+
dropped: () => result()?.dropped ?? [],
|
|
4158
|
+
refreshed: () => result()?.refreshed ?? [],
|
|
4159
|
+
pending: () => result.loading
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
3704
4162
|
function useAffiliateStats() {
|
|
3705
4163
|
const [stats, { refetch }] = createResource(
|
|
3706
4164
|
() => affiliateAuth_default.isAuthenticated(),
|
|
@@ -3761,6 +4219,45 @@ function useAffiliateLinks() {
|
|
|
3761
4219
|
return { links, refetch: () => refetch() };
|
|
3762
4220
|
}
|
|
3763
4221
|
|
|
4222
|
+
// src/flows/categoryVisual.ts
|
|
4223
|
+
function hashId(id) {
|
|
4224
|
+
let h = 5381;
|
|
4225
|
+
for (let i = 0; i < id.length; i++) h = (h << 5) + h + id.charCodeAt(i) | 0;
|
|
4226
|
+
return Math.abs(h);
|
|
4227
|
+
}
|
|
4228
|
+
var DEFAULT_COLOR_PALETTE = [
|
|
4229
|
+
"#4f46e5",
|
|
4230
|
+
// indigo
|
|
4231
|
+
"#0891b2",
|
|
4232
|
+
// cyan
|
|
4233
|
+
"#0d9488",
|
|
4234
|
+
// teal
|
|
4235
|
+
"#f59e0b",
|
|
4236
|
+
// amber
|
|
4237
|
+
"#e11d48",
|
|
4238
|
+
// rose
|
|
4239
|
+
"#10b981",
|
|
4240
|
+
// emerald
|
|
4241
|
+
"#8b5cf6",
|
|
4242
|
+
// violet
|
|
4243
|
+
"#f97316"
|
|
4244
|
+
// orange
|
|
4245
|
+
];
|
|
4246
|
+
function categoryColor(id, opts = {}) {
|
|
4247
|
+
const palette = opts.palette ?? DEFAULT_COLOR_PALETTE;
|
|
4248
|
+
if (palette.length === 0) return "currentColor";
|
|
4249
|
+
return palette[hashId(id) % palette.length];
|
|
4250
|
+
}
|
|
4251
|
+
function isCssColorValue(value) {
|
|
4252
|
+
return /^(#[0-9a-f]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^;{}()]*\)|var\(--[\w-]+\))$/i.test(
|
|
4253
|
+
value.trim()
|
|
4254
|
+
);
|
|
4255
|
+
}
|
|
4256
|
+
function resolveCategoryColor(category, opts = {}) {
|
|
4257
|
+
const set = category.color?.trim();
|
|
4258
|
+
return set && isCssColorValue(set) ? set : categoryColor(category.id, opts);
|
|
4259
|
+
}
|
|
4260
|
+
|
|
3764
4261
|
// src/flows/funnel.ts
|
|
3765
4262
|
var FORWARDED = /* @__PURE__ */ new Set([
|
|
3766
4263
|
"survey:loaded",
|
|
@@ -3968,6 +4465,6 @@ async function uploadPrescriptionPhoto(file) {
|
|
|
3968
4465
|
return { photoId: parsed.photoId };
|
|
3969
4466
|
}
|
|
3970
4467
|
|
|
3971
|
-
export { ACCOUNT_SOURCE_LABEL, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, categoryLabel, createFunnelTelemetry, deriveAttention, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, markEmailGateAnswered, normalizeState, primarySubscription, redeemResumeLink, resetResumeRedemption, resolveSurveyV2DrugIntent, stateAvailabilityNote, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCheckoutFlow, useDashboardData, useMemberPortalData, useMessagesThread, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
3972
|
-
//# sourceMappingURL=
|
|
3973
|
-
//# sourceMappingURL=
|
|
4468
|
+
export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, primarySubscription, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, resetResumeRedemption, resolveCategoryColor, resolveSurveyV2DrugIntent, salePriceForBase, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
4469
|
+
//# sourceMappingURL=HKXDH266.js.map
|
|
4470
|
+
//# sourceMappingURL=HKXDH266.js.map
|