@apextelemed/partner-core 0.17.0-dev.50 → 0.17.0-dev.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/api/index.jsx +3 -3
  4. package/dist/chunk/{YQK6OTY6.jsx → 3SPMZ7FK.jsx} +2 -2
  5. package/dist/chunk/{OVRA6JBK.jsx → 545PPOE5.jsx} +2 -2
  6. package/dist/chunk/{EGP7AQDM.js → ANKLNWGB.js} +6 -6
  7. package/dist/chunk/{EGP7AQDM.js.map → ANKLNWGB.js.map} +1 -1
  8. package/dist/chunk/{H7RY2N5U.js → AXXQJC6M.js} +3 -3
  9. package/dist/chunk/{H7RY2N5U.js.map → AXXQJC6M.js.map} +1 -1
  10. package/dist/chunk/{6QI7MVTN.jsx → HM5L6J62.jsx} +2 -2
  11. package/dist/chunk/{ISC5GVA2.js → ICGZXU3R.js} +4 -4
  12. package/dist/chunk/ICGZXU3R.js.map +1 -0
  13. package/dist/chunk/{BVJPX54P.js → L4DFQMYM.js} +451 -358
  14. package/dist/chunk/L4DFQMYM.js.map +1 -0
  15. package/dist/chunk/{R5WTYT2O.js → LFSDVMIY.js} +93 -19
  16. package/dist/chunk/LFSDVMIY.js.map +1 -0
  17. package/dist/chunk/{XV5WXVPT.jsx → OZZGMI6C.jsx} +69 -9
  18. package/dist/chunk/{HADRZNID.jsx → P4NWFY4T.jsx} +5 -5
  19. package/dist/chunk/{3CWWN7H2.jsx → PHSZOZVK.jsx} +3 -3
  20. package/dist/chunk/{KADMJCZL.js → TFA64PLK.js} +3 -3
  21. package/dist/chunk/{KADMJCZL.js.map → TFA64PLK.js.map} +1 -1
  22. package/dist/chunk/{GVXPPYZZ.jsx → VE5ACNFB.jsx} +92 -17
  23. package/dist/chunk/{2CHHHNFT.js → Z6PDUPOU.js} +3 -3
  24. package/dist/chunk/{2CHHHNFT.js.map → Z6PDUPOU.js.map} +1 -1
  25. package/dist/{client-Da9ye3z4.d.ts → client-Baf1FSEp.d.ts} +33 -2
  26. package/dist/flows/index.d.ts +17 -3
  27. package/dist/flows/index.js +6 -6
  28. package/dist/flows/index.jsx +6 -6
  29. package/dist/index/index.d.ts +1 -1
  30. package/dist/index/index.js +7 -7
  31. package/dist/index/index.jsx +7 -7
  32. package/dist/pages/index.d.ts +1 -1
  33. package/dist/pages/index.js +5 -5
  34. package/dist/pages/index.jsx +5 -5
  35. package/dist/stores/index.d.ts +1 -1
  36. package/dist/stores/index.js +2 -2
  37. package/dist/stores/index.jsx +2 -2
  38. package/package.json +1 -1
  39. package/dist/chunk/BVJPX54P.js.map +0 -1
  40. package/dist/chunk/ISC5GVA2.js.map +0 -1
  41. package/dist/chunk/R5WTYT2O.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './2CHHHNFT.js';
2
- import { cart_default, medication_default, auth_default, affiliateAuth_default } from './H7RY2N5U.js';
3
- import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, adminApi, adminCatalogApi, adminProductPharmaciesApi, ApiError, ordersApi, adminCatalogConversionApi, messagesApi, authApi } from './ISC5GVA2.js';
1
+ import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './Z6PDUPOU.js';
2
+ import { cart_default, medication_default, auth_default, affiliateAuth_default } from './AXXQJC6M.js';
3
+ import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, adminApi, adminCatalogApi, adminProductPharmaciesApi, ApiError, ordersApi, adminCatalogConversionApi, messagesApi, authApi } from './ICGZXU3R.js';
4
4
  import { getConfig } from './2IFPDU4D.js';
5
5
  import { createSignal, onMount, createEffect, on, onCleanup, createResource, createMemo } from 'solid-js';
6
6
  import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
@@ -5867,6 +5867,14 @@ function useCatalogConversion(opts) {
5867
5867
  lastCommit
5868
5868
  };
5869
5869
  }
5870
+ var REPLAN_DEBOUNCE_MS = 300;
5871
+ var matchKey = (source) => JSON.stringify([source.dosage, source.apexSkuId]);
5872
+ function matchAnswersBody(questions, answers) {
5873
+ return questions.flatMap((q) => {
5874
+ const key = matchKey(q.source);
5875
+ return Object.prototype.hasOwnProperty.call(answers, key) ? [{ source: { dosage: q.source.dosage, apexSkuId: q.source.apexSkuId }, doseId: answers[key] }] : [];
5876
+ });
5877
+ }
5870
5878
  function visibleWarnings(plan) {
5871
5879
  return plan.warnings.filter((w) => w.audience === "admin");
5872
5880
  }
@@ -5885,7 +5893,7 @@ function strengthsChanged(plan) {
5885
5893
  return plan.strengthsAfter.some((s) => !before.has(s.dosage) || before.get(s.dosage) !== s.price);
5886
5894
  }
5887
5895
  function needsReview(plan) {
5888
- return plan.blockers.length > 0 || visibleWarnings(plan).length > 0 || plan.pricesRequired.length > 0 || strengthsChanged(plan);
5896
+ return plan.blockers.length > 0 || visibleWarnings(plan).length > 0 || plan.pricesRequired.length > 0 || (plan.matchQuestions?.length ?? 0) > 0 || strengthsChanged(plan);
5889
5897
  }
5890
5898
  function compareStrengths(plan) {
5891
5899
  const after = new Map(plan.strengthsAfter.map((s) => [s.dosage, s]));
@@ -5902,17 +5910,19 @@ function compareStrengths(plan) {
5902
5910
  function pharmacyLabel(plan) {
5903
5911
  return plan.pharmacy.pharmacyName ?? plan.pharmacy.drugName;
5904
5912
  }
5905
- function buildSaveBody(plan, prices, savingsPrices = {}) {
5913
+ function buildSaveBody(plan, prices, savingsPrices = {}, matchAnswers = {}) {
5906
5914
  const entries = plan.pricesRequired.flatMap((r) => {
5907
5915
  const price = parseMoney(prices[r.doseId]);
5908
5916
  if (price === null) return [];
5909
5917
  const savings = parseMoney(savingsPrices[r.doseId]);
5910
5918
  return [{ doseId: r.doseId, price, ...savings !== null ? { savingsPrice: savings } : {} }];
5911
5919
  });
5920
+ const doseMatches = matchAnswersBody(plan.matchQuestions ?? [], matchAnswers);
5912
5921
  return {
5913
5922
  drugId: plan.pharmacy.drugId,
5914
5923
  ...plan.planHash ? { planHash: plan.planHash } : {},
5915
- ...entries.length > 0 ? { prices: entries } : {}
5924
+ ...entries.length > 0 ? { prices: entries } : {},
5925
+ ...doseMatches.length > 0 ? { doseMatches } : {}
5916
5926
  };
5917
5927
  }
5918
5928
  function pharmacyIsOnProduct(product, plan) {
@@ -5964,9 +5974,22 @@ function useAddPharmacy(opts) {
5964
5974
  const [prices, setPrices] = createSignal({});
5965
5975
  const [savingsPrices, setSavingsPrices] = createSignal({});
5966
5976
  const [flagged, setFlagged] = createSignal(/* @__PURE__ */ new Set());
5977
+ const [matchAnswers, setMatchAnswers] = createSignal({});
5978
+ const [replanning, setReplanning] = createSignal(false);
5979
+ const [replanStale, setReplanStale] = createSignal(false);
5967
5980
  let generation = 0;
5981
+ let replanTimer;
5982
+ let replanSeq = 0;
5983
+ const dropReplan = () => {
5984
+ clearTimeout(replanTimer);
5985
+ replanTimer = void 0;
5986
+ replanSeq++;
5987
+ setReplanning(false);
5988
+ setReplanStale(false);
5989
+ };
5968
5990
  onCleanup(() => {
5969
5991
  generation++;
5992
+ dropReplan();
5970
5993
  });
5971
5994
  const current = () => state();
5972
5995
  const kindIs = (k) => current().kind === k;
@@ -5987,7 +6010,7 @@ function useAddPharmacy(opts) {
5987
6010
  };
5988
6011
  const canSave = () => {
5989
6012
  const plan2 = reviewingPlan();
5990
- return !!plan2 && plan2.ready && plan2.blockers.length === 0 && missing().length === 0 && savingsInvalid().length === 0;
6013
+ return !!plan2 && !replanning() && !replanStale() && plan2.ready && plan2.blockers.length === 0 && missing().length === 0 && savingsInvalid().length === 0;
5991
6014
  };
5992
6015
  const loadDrugs = async (gen) => {
5993
6016
  setDrugsStatus("loading");
@@ -6004,6 +6027,8 @@ function useAddPharmacy(opts) {
6004
6027
  const open = (drugId) => {
6005
6028
  if (busy()) return;
6006
6029
  const gen = ++generation;
6030
+ dropReplan();
6031
+ setMatchAnswers({});
6007
6032
  setNotice(null);
6008
6033
  setSelected(drugId ?? "");
6009
6034
  setState({ kind: "picking" });
@@ -6012,12 +6037,15 @@ function useAddPharmacy(opts) {
6012
6037
  const cancel = () => {
6013
6038
  if (kindIs("saving")) return;
6014
6039
  generation++;
6040
+ dropReplan();
6015
6041
  setNotice(null);
6016
6042
  setState({ kind: "idle" });
6017
6043
  };
6018
6044
  const backToPicking = () => {
6019
6045
  if (busy()) return;
6020
6046
  const gen = ++generation;
6047
+ dropReplan();
6048
+ setMatchAnswers({});
6021
6049
  setNotice(null);
6022
6050
  setState({ kind: "picking" });
6023
6051
  if (drugsStatus() !== "ready") void loadDrugs(gen);
@@ -6033,6 +6061,8 @@ function useAddPharmacy(opts) {
6033
6061
  }
6034
6062
  setPrices(nextPrices);
6035
6063
  setSavingsPrices(nextSavings);
6064
+ const questions = new Set((plan2.matchQuestions ?? []).map((q) => matchKey(q.source)));
6065
+ setMatchAnswers((prev) => Object.fromEntries(Object.entries(prev).filter(([k]) => questions.has(k))));
6036
6066
  setFlagged(/* @__PURE__ */ new Set());
6037
6067
  setNotice(next);
6038
6068
  setState({ kind: "reviewing", plan: plan2 });
@@ -6041,12 +6071,15 @@ function useAddPharmacy(opts) {
6041
6071
  setNotice(null);
6042
6072
  setState({ kind: "failed", message, drugId, plan: plan2, unconfirmed: flags.unconfirmed ?? false, canRetry: flags.canRetry ?? true });
6043
6073
  };
6044
- const runPlan = async (drugId, next = null) => {
6074
+ const runPlan = async (drugId, next = null, prior) => {
6045
6075
  const gen = ++generation;
6076
+ dropReplan();
6077
+ const doseMatches = prior ? matchAnswersBody(prior.matchQuestions ?? [], matchAnswers()) : [];
6078
+ if (!prior) setMatchAnswers({});
6046
6079
  setNotice(null);
6047
6080
  setState({ kind: "planning", drugId });
6048
6081
  try {
6049
- const plan2 = await adminProductPharmaciesApi.plan(opts.productId(), drugId);
6082
+ const plan2 = await (doseMatches.length > 0 ? adminProductPharmaciesApi.plan(opts.productId(), drugId, doseMatches) : adminProductPharmaciesApi.plan(opts.productId(), drugId));
6050
6083
  if (gen !== generation) return;
6051
6084
  adoptPlan(plan2, next);
6052
6085
  } catch (err) {
@@ -6060,6 +6093,40 @@ function useAddPharmacy(opts) {
6060
6093
  if (!kindIs("picking") || !drugId) return;
6061
6094
  await runPlan(drugId);
6062
6095
  };
6096
+ const replan = async (gen) => {
6097
+ const p = reviewingPlan();
6098
+ if (!p || gen !== generation) return;
6099
+ const seq = ++replanSeq;
6100
+ const doseMatches = matchAnswersBody(p.matchQuestions ?? [], matchAnswers());
6101
+ try {
6102
+ const fresh = await adminProductPharmaciesApi.plan(opts.productId(), p.pharmacy.drugId, doseMatches);
6103
+ if (gen !== generation || seq !== replanSeq) return;
6104
+ setReplanning(false);
6105
+ setReplanStale(false);
6106
+ adoptPlan(fresh, null);
6107
+ } catch (err) {
6108
+ if (gen !== generation || seq !== replanSeq) return;
6109
+ setReplanning(false);
6110
+ setReplanStale(true);
6111
+ setNotice({
6112
+ tone: "danger",
6113
+ code: "replan_failed",
6114
+ message: `We couldn\u2019t update the prices for that choice: ${classifyAddPharmacyError(err).message} Choose again to retry.`
6115
+ });
6116
+ }
6117
+ };
6118
+ const setMatchAnswer = (source, doseId) => {
6119
+ if (!reviewingPlan()) return;
6120
+ setMatchAnswers((prev) => ({ ...prev, [matchKey(source)]: doseId }));
6121
+ const gen = generation;
6122
+ clearTimeout(replanTimer);
6123
+ replanSeq++;
6124
+ setReplanning(true);
6125
+ replanTimer = setTimeout(() => {
6126
+ replanTimer = void 0;
6127
+ void replan(gen);
6128
+ }, REPLAN_DEBOUNCE_MS);
6129
+ };
6063
6130
  const confirmOnProduct = async (p) => {
6064
6131
  const res = await adminApi.getProduct(opts.productId());
6065
6132
  return pharmacyIsOnProduct(res?.product, p);
@@ -6079,7 +6146,7 @@ function useAddPharmacy(opts) {
6079
6146
  const p = reviewingPlan();
6080
6147
  if (!p || !canSave()) return;
6081
6148
  const gen = ++generation;
6082
- const body = buildSaveBody(p, prices(), savingsPrices());
6149
+ const body = buildSaveBody(p, prices(), savingsPrices(), matchAnswers());
6083
6150
  setNotice(null);
6084
6151
  setState({ kind: "saving", plan: p });
6085
6152
  try {
@@ -6091,17 +6158,21 @@ function useAddPharmacy(opts) {
6091
6158
  const f = classifyAddPharmacyError(err);
6092
6159
  const drugId = p.pharmacy.drugId;
6093
6160
  if (f.kind === "replan") {
6094
- await runPlan(drugId, {
6095
- tone: "warn",
6096
- code: f.code,
6097
- message: "Something changed while you were reviewing, so we updated this. Check it over, then save again."
6098
- });
6161
+ await runPlan(
6162
+ drugId,
6163
+ {
6164
+ tone: "warn",
6165
+ code: f.code,
6166
+ message: "Something changed while you were reviewing, so we updated this. Check it over, then save again."
6167
+ },
6168
+ p
6169
+ );
6099
6170
  return;
6100
6171
  }
6101
6172
  if (f.kind === "prices_required") {
6102
6173
  const owed = new Set(p.pricesRequired.map((r) => r.doseId));
6103
6174
  if (f.missing.some((id) => !owed.has(id))) {
6104
- await runPlan(drugId, { tone: "warn", code: "prices_required", message: "More prices are needed than we first showed. Enter them below." });
6175
+ await runPlan(drugId, { tone: "warn", code: "prices_required", message: "More prices are needed than we first showed. Enter them below." }, p);
6105
6176
  return;
6106
6177
  }
6107
6178
  setFlagged(new Set(f.missing));
@@ -6196,12 +6267,15 @@ function useAddPharmacy(opts) {
6196
6267
  flagged,
6197
6268
  savingsInvalid,
6198
6269
  canSave,
6270
+ matchAnswers,
6271
+ setMatchAnswer,
6272
+ replanning,
6199
6273
  save,
6200
6274
  retry,
6201
6275
  startOver
6202
6276
  };
6203
6277
  }
6204
6278
 
6205
- export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, MATCH_DEPENDENT_WARNINGS, MATCH_HOW_LABEL, ORPHAN_REASON, READINESS_LABEL, SOURCE_FIELD_NOTE, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, addCatalogItemAsProduct, applyPriceDrafts, availableStateOptions, availableStates, bestOfferDiscount, buildFulfillmentRows, buildMatrixView, buildRefillView, buildSaveBody, buildStrengthRows, buildTimeline, buildTrackerView, buildTrackingUrl, canLeaveUnmatched, canOfferConversion, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, classifyAddPharmacyError, classifyCatalogError, classifyConversionError, compareStrengths, createCatalogProduct, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, describeConversion, emailGateAnswered, explainFinding, findStoredDosePrice, firstAddressError, flaggedSubscribers, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, groupDrugsByPharmacy, hasBlockers, hasConversion, hasErrors, hasStateRestrictions, initialMatches, intakeEvidence, invalidDraftKeys, isCatalogItemId, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, liveDoses, lowestPrice, lowestSalePrice, markEmailGateAnswered, matchProblem, matchesComplete, missingPrices, moveInOrder, needsReview, normalizeState, normalizeStates, offerBeatsPromo, offerDurationText, offerSummaryText, orphanKey, parseMoney, pharmacyIsOnProduct, pharmacyLabel, primarySubscription, readinessStatus, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, removeStoredDosePrice, resetResumeRedemption, resolveCategoryColor, resolveStrengthPrices, resolveSurveyV2DrugIntent, salePriceForBase, skuBindingModeFor, sourceKey, sourceLabel, stateAvailabilityNote, strengthsChanged, subscribeToSupportTopic, toChoices, toTrackerRequest, uploadPrescriptionPhoto, upsertDosePrice, useAddPharmacy, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCatalogConversion, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductCatalogEditor, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress, visibleWarnings };
6206
- //# sourceMappingURL=R5WTYT2O.js.map
6207
- //# sourceMappingURL=R5WTYT2O.js.map
6279
+ export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, MATCH_DEPENDENT_WARNINGS, MATCH_HOW_LABEL, ORPHAN_REASON, READINESS_LABEL, SOURCE_FIELD_NOTE, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, addCatalogItemAsProduct, applyPriceDrafts, availableStateOptions, availableStates, bestOfferDiscount, buildFulfillmentRows, buildMatrixView, buildRefillView, buildSaveBody, buildStrengthRows, buildTimeline, buildTrackerView, buildTrackingUrl, canLeaveUnmatched, canOfferConversion, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, classifyAddPharmacyError, classifyCatalogError, classifyConversionError, compareStrengths, createCatalogProduct, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, describeConversion, emailGateAnswered, explainFinding, findStoredDosePrice, firstAddressError, flaggedSubscribers, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, groupDrugsByPharmacy, hasBlockers, hasConversion, hasErrors, hasStateRestrictions, initialMatches, intakeEvidence, invalidDraftKeys, isCatalogItemId, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, liveDoses, lowestPrice, lowestSalePrice, markEmailGateAnswered, matchKey, matchProblem, matchesComplete, missingPrices, moveInOrder, needsReview, normalizeState, normalizeStates, offerBeatsPromo, offerDurationText, offerSummaryText, orphanKey, parseMoney, pharmacyIsOnProduct, pharmacyLabel, primarySubscription, readinessStatus, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, removeStoredDosePrice, resetResumeRedemption, resolveCategoryColor, resolveStrengthPrices, resolveSurveyV2DrugIntent, salePriceForBase, skuBindingModeFor, sourceKey, sourceLabel, stateAvailabilityNote, strengthsChanged, subscribeToSupportTopic, toChoices, toTrackerRequest, uploadPrescriptionPhoto, upsertDosePrice, useAddPharmacy, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCatalogConversion, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductCatalogEditor, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress, visibleWarnings };
6280
+ //# sourceMappingURL=LFSDVMIY.js.map
6281
+ //# sourceMappingURL=LFSDVMIY.js.map