@metaboliccode-dev/widget 0.2.83 → 0.2.84

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.
@@ -4,8 +4,8 @@ export declare class SoapNotesError extends Error {
4
4
  readonly status: number;
5
5
  constructor(status: number, code: string);
6
6
  }
7
- /** Reads the audience-scoped notes for a report without loading charts or report pages. */
7
+ /** Reads audience-scoped notes, following the backend's current assessment revision. */
8
8
  export declare function fetchMetabolicReportSoapNotes(config: MetabolicDashboardReportHttpConfig & {
9
9
  reportId: string;
10
10
  }, signal?: AbortSignal): Promise<SoapNotesData>;
11
- export declare function createSoapNotesClient(config: MetabolicDashboardReportHttpConfig, readPage?: "questionnaire-analysis"): (reportId: string | undefined, operation: SoapNoteOperation | "list", input?: SoapNoteInput, signal?: AbortSignal) => Promise<SoapNotesData>;
11
+ export declare function createSoapNotesClient(config: MetabolicDashboardReportHttpConfig, readPage?: "questionnaire-analysis", resolveLatestReport?: boolean): (reportId: string | undefined, operation: SoapNoteOperation | "list", input?: SoapNoteInput, signal?: AbortSignal) => Promise<SoapNotesData>;
package/dist/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { l as s, m as t, n as o, o as i, p as r, q as E, s as l, t as _, u as R, M as c, v as n, k as M, w as S, S as b, x as T, y as A, z as h, A as I, B as L, C as d, D as m, F as O, G as P, H as u, I as C, e as B, K as f, L as p, N, O as H, P as U, Q as g, R as D, g as F, T as Y, U as x, V as k, W as Q, j as W, X as v, Y as y, Z as G, _ as J, $ as q, a0 as z, a1 as V, a2 as K, a3 as X, i as j, h as w, f as Z, a4 as $, r as ee, a5 as ae, a6 as se, a7 as te, a8 as oe } from "./entry-api-MIuk8VYF.js";
1
+ import { l as s, m as t, n as o, o as i, p as r, q as E, s as l, t as _, u as R, M as c, v as n, k as M, w as S, S as b, x as T, y as A, z as h, A as I, B as L, C as d, D as m, F as O, G as P, H as u, I as C, e as B, K as f, L as p, N, O as H, P as U, Q as g, R as D, g as F, T as Y, U as x, V as k, W as Q, j as W, X as v, Y as y, Z as G, _ as J, $ as q, a0 as z, a1 as V, a2 as K, a3 as X, i as j, h as w, f as Z, a4 as $, r as ee, a5 as ae, a6 as se, a7 as te, a8 as oe } from "./entry-api-n7RYttkh.js";
2
2
  export {
3
3
  s as METABOLIC_DASHBOARD_RENDER_CONTEXT_QUERY_KEY,
4
4
  t as METABOLIC_IFRAME_CONFIG_QUERY_KEY,
@@ -36,33 +36,33 @@ function se({
36
36
  refreshAuthToken: r,
37
37
  refreshSession: n
38
38
  }) {
39
- let o = U(e), s = null, i = null;
39
+ let o = U(e), i = null, s = null;
40
40
  const u = async (c) => {
41
41
  if (r)
42
- return s || (s = (async () => {
43
- const a = await j(c), d = await r({
42
+ return i || (i = (async () => {
43
+ const d = await j(c), a = await r({
44
44
  authToken: o,
45
45
  status: 401,
46
- responseBody: a
46
+ responseBody: d
47
47
  });
48
- return oe(d);
48
+ return oe(a);
49
49
  })().finally(() => {
50
- s = null;
51
- })), s;
52
- }, l = async (c) => n ? (i || (i = (async () => {
53
- const a = await j(c);
50
+ i = null;
51
+ })), i;
52
+ }, l = async (c) => n ? (s || (s = (async () => {
53
+ const d = await j(c);
54
54
  return !!await n({
55
55
  status: 401,
56
- responseBody: a
56
+ responseBody: d
57
57
  });
58
58
  })().finally(() => {
59
- i = null;
60
- })), i) : !1;
61
- return async (c, a) => {
62
- const d = await t(c, M(a, o));
63
- if (d.status !== 401) return d;
64
- const h = await u(d);
65
- return h ? (o = h, t(c, M(a, o))) : await l(d) ? t(c, M(a, o)) : d;
59
+ s = null;
60
+ })), s) : !1;
61
+ return async (c, d) => {
62
+ const a = await t(c, M(d, o));
63
+ if (a.status !== 401) return a;
64
+ const p = await u(a);
65
+ return p ? (o = p, t(c, M(d, o))) : await l(a) ? t(c, M(d, o)) : a;
66
66
  };
67
67
  }
68
68
  const O = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_AG_CHARTS_LICENSE_KEY: "Using_this_{AG_Charts}_Enterprise_key_{AG-125036}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Metabolic_Code}_is_granted_a_{Single_Application}_Developer_License_for_the_application_{Metabolic_Code}_only_for_{1}_Front-End_JavaScript_developer___All_Front-End_JavaScript_developers_working_on_{Metabolic_Code}_need_to_be_licensed___{Metabolic_Code}_has_been_granted_a_Deployment_License_Add-on_for_{1}_Production_Environment___This_key_works_with_{AG_Charts}_Enterprise_versions_released_before_{31_March_2027}____[v3]_[02]_MTgwNjQ0NzYwMDAwMA==4e5dbf88087527cd3b1cf09b0557ec38", VITE_METABOLIC_LMS_API_BASE_URL: "https://mc-api-us.metaboliccode.com", VITE_METABOLIC_LMS_FRONTEND_BASE_URL: "https://mc-lms.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL: "https://mc-api-us.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_CA: "https://mc-api-ca.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_US: "https://mc-api-us.metaboliccode.com" }, ie = "https://mc-api-us.metaboliccode.com", ae = "https://mc-api-us.metaboliccode.com", ce = "https://mc-lms.metaboliccode.com";
@@ -77,16 +77,16 @@ function A(e) {
77
77
  return;
78
78
  }
79
79
  }
80
- const B = A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_US") ?? A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL") ?? ie, le = A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_CA") ?? B, de = B, fe = A("VITE_METABOLIC_LMS_API_BASE_URL") ?? ae, pe = A("VITE_METABOLIC_LMS_FRONTEND_BASE_URL") ?? ce;
80
+ const B = A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_US") ?? A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL") ?? ie, le = A("VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_CA") ?? B, de = B, fe = A("VITE_METABOLIC_LMS_API_BASE_URL") ?? ae, _e = A("VITE_METABOLIC_LMS_FRONTEND_BASE_URL") ?? ce;
81
81
  function v(e) {
82
82
  return e.replace(/\/+$/, "");
83
83
  }
84
- function _e(e) {
84
+ function pe(e) {
85
85
  const t = e == null ? void 0 : e.trim().toLowerCase();
86
86
  return t === "ca" || t === "canada" ? "ca" : "us";
87
87
  }
88
88
  function he(e, t) {
89
- return _e(e) === "ca" ? v(t.ca || t.fallback || t.us || "") : v(t.us || t.fallback || "");
89
+ return pe(e) === "ca" ? v(t.ca || t.fallback || t.us || "") : v(t.us || t.fallback || "");
90
90
  }
91
91
  function N(e) {
92
92
  return he(e, {
@@ -103,8 +103,8 @@ function S({
103
103
  }) {
104
104
  const o = t || e;
105
105
  if (!o && !r && n == null) return;
106
- const s = new Headers(n ?? void 0);
107
- return o && s.set("Authorization", `Bearer ${o}`), r && s.set("Content-Type", "application/json"), s;
106
+ const i = new Headers(n ?? void 0);
107
+ return o && i.set("Authorization", `Bearer ${o}`), r && i.set("Content-Type", "application/json"), i;
108
108
  }
109
109
  function me(e) {
110
110
  const t = {};
@@ -124,34 +124,34 @@ class L extends Error {
124
124
  }
125
125
  }
126
126
  function st(e, t) {
127
- return Ee(e)(e.reportId, "list", void 0, t);
127
+ return Ee(e, void 0, !0)(e.reportId, "list", void 0, t);
128
128
  }
129
- function Ee(e, t) {
130
- const r = se(e), n = e.baseUrl ?? N(e.backendRegion);
131
- return async (o, s, i, u) => {
129
+ function Ee(e, t, r = !1) {
130
+ const n = se(e), o = e.baseUrl ?? N(e.backendRegion);
131
+ return async (i, s, u, l) => {
132
132
  if (t && s !== "list") throw new L(403, "forbidden");
133
- const l = t ? `pages/${t}` : `report/soap-notes/${s}`, c = await r(`${n.replace(/\/$/, "")}/api/v1/${l}`, {
133
+ const c = t ? `pages/${t}` : `report/soap-notes/${s}`, d = await n(`${o.replace(/\/$/, "")}/api/v1/${c}`, {
134
134
  method: "POST",
135
135
  credentials: "include",
136
136
  cache: "no-store",
137
- signal: u,
137
+ signal: l,
138
138
  headers: S({ ...e, json: !0 }),
139
139
  body: JSON.stringify({
140
- report_id: o,
140
+ report_id: i,
141
141
  ...t ? { questionnaire_response_id: e.questionnaireResponseId } : {},
142
142
  user_type: e.userType,
143
- ...i
143
+ ...u
144
144
  })
145
145
  });
146
- let a = await c.json().catch(() => null);
147
- if (!c.ok) {
148
- const h = a && typeof a == "object" && "error" in a ? String(a.error) : "notes_unavailable";
149
- throw new L(c.status, h);
146
+ let a = await d.json().catch(() => null);
147
+ if (!d.ok) {
148
+ const b = a && typeof a == "object" && "error" in a ? String(a.error) : "notes_unavailable";
149
+ throw new L(d.status, b);
150
150
  }
151
- if (t && (a = a && typeof a == "object" && "soap_notes" in a ? a.soap_notes : null), !a || typeof a != "object" || !("items" in a) || !Array.isArray(a.items) || !("targets" in a) || !Array.isArray(a.targets) || !("report_id" in a) || typeof a.report_id != "string" || !t && a.report_id !== o)
151
+ if (t && (a = a && typeof a == "object" && "soap_notes" in a ? a.soap_notes : null), !a || typeof a != "object" || !("items" in a) || !Array.isArray(a.items) || !("targets" in a) || !Array.isArray(a.targets) || !("report_id" in a) || typeof a.report_id != "string" || !t && !(r && s === "list") && a.report_id !== i)
152
152
  throw new L(502, "notes_unavailable");
153
- const d = a;
154
- return t ? { ...d, can_manage: !1 } : d;
153
+ const p = a;
154
+ return t ? { ...p, can_manage: !1 } : p;
155
155
  };
156
156
  }
157
157
  const H = "mb_config";
@@ -163,10 +163,10 @@ function ye(e) {
163
163
  }
164
164
  function Se(e) {
165
165
  try {
166
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = t.length % 4, n = r ? t + "=".repeat(4 - r) : t, o = atob(n), s = new Uint8Array(o.length);
167
- for (let i = 0; i < o.length; i++)
168
- s[i] = o.charCodeAt(i);
169
- return s;
166
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = t.length % 4, n = r ? t + "=".repeat(4 - r) : t, o = atob(n), i = new Uint8Array(o.length);
167
+ for (let s = 0; s < o.length; s++)
168
+ i[s] = o.charCodeAt(s);
169
+ return i;
170
170
  } catch {
171
171
  return null;
172
172
  }
@@ -251,7 +251,7 @@ function ut({
251
251
  }) {
252
252
  if (typeof window > "u" || window.parent === window)
253
253
  return Promise.resolve(void 0);
254
- const o = Ae(), s = F(r) ?? Ie(), i = s ?? "*", u = {
254
+ const o = Ae(), i = F(r) ?? Ie(), s = i ?? "*", u = {
255
255
  type: D,
256
256
  requestId: o,
257
257
  reason: t,
@@ -259,23 +259,23 @@ function ut({
259
259
  };
260
260
  return new Promise((l) => {
261
261
  const c = () => {
262
- window.clearTimeout(a), window.removeEventListener("message", d);
263
- }, a = window.setTimeout(() => {
262
+ window.clearTimeout(d), window.removeEventListener("message", a);
263
+ }, d = window.setTimeout(() => {
264
264
  c(), l(void 0);
265
- }, n), d = (h) => {
266
- h.source === window.parent && (s && h.origin !== s || Oe(h.data) && h.data.requestId === o && (c(), l(P(h.data.embedToken))));
265
+ }, n), a = (p) => {
266
+ p.source === window.parent && (i && p.origin !== i || Oe(p.data) && p.data.requestId === o && (c(), l(P(p.data.embedToken))));
267
267
  };
268
- window.addEventListener("message", d), window.parent.postMessage(u, i);
268
+ window.addEventListener("message", a), window.parent.postMessage(u, s);
269
269
  });
270
270
  }
271
271
  function Le(e, t, r, n) {
272
- var i;
273
- const o = Te(r), s = {
272
+ var s;
273
+ const o = Te(r), i = {
274
274
  type: C,
275
275
  requestId: t.requestId,
276
276
  ...o ? { embedToken: o } : { error: "embed_token_unavailable" }
277
277
  };
278
- (i = e.contentWindow) == null || i.postMessage(s, n);
278
+ (s = e.contentWindow) == null || s.postMessage(i, n);
279
279
  }
280
280
  function lt({
281
281
  iframe: e,
@@ -283,16 +283,16 @@ function lt({
283
283
  refreshEmbedSession: r
284
284
  }) {
285
285
  const n = (o) => {
286
- o.source === e.contentWindow && o.origin === t && Me(o.data) && Promise.resolve(r(o.data)).then((s) => {
287
- Le(e, o.data, s, t);
288
- }).catch((s) => {
286
+ o.source === e.contentWindow && o.origin === t && Me(o.data) && Promise.resolve(r(o.data)).then((i) => {
287
+ Le(e, o.data, i, t);
288
+ }).catch((i) => {
289
289
  var u;
290
- const i = {
290
+ const s = {
291
291
  type: C,
292
292
  requestId: o.data.requestId,
293
- error: s instanceof Error ? s.message : "embed_token_unavailable"
293
+ error: i instanceof Error ? i.message : "embed_token_unavailable"
294
294
  };
295
- (u = e.contentWindow) == null || u.postMessage(i, t);
295
+ (u = e.contentWindow) == null || u.postMessage(s, t);
296
296
  });
297
297
  };
298
298
  return window.addEventListener("message", n), () => window.removeEventListener("message", n);
@@ -313,21 +313,21 @@ async function Be(e) {
313
313
  headers: r,
314
314
  authToken: n,
315
315
  backendRegion: o,
316
- baseUrl: s,
317
- questionnaireResponseId: i,
316
+ baseUrl: i,
317
+ questionnaireResponseId: s,
318
318
  fetchImpl: u = globalThis.fetch.bind(globalThis),
319
319
  signal: l
320
- } = e, c = s ?? N(o), a = Pe(c), d = me({ reportId: t, questionnaireResponseId: i }), h = S({
320
+ } = e, c = i ?? N(o), d = Pe(c), a = me({ reportId: t, questionnaireResponseId: s }), p = S({
321
321
  authToken: n,
322
322
  json: !0,
323
323
  headers: r
324
324
  });
325
325
  let b;
326
326
  try {
327
- b = await u(a, {
327
+ b = await u(d, {
328
328
  method: "POST",
329
- headers: h,
330
- body: d,
329
+ headers: p,
330
+ body: a,
331
331
  credentials: "include",
332
332
  signal: l
333
333
  });
@@ -395,30 +395,30 @@ async function ft({
395
395
  fetchImpl: n = fetch,
396
396
  signal: o
397
397
  }) {
398
- const s = J(t), i = S({ authToken: e, headers: r }), u = await n(`${s}/api/v1/patient/progress`, {
398
+ const i = J(t), s = S({ authToken: e, headers: r }), u = await n(`${i}/api/v1/patient/progress`, {
399
399
  method: "GET",
400
- headers: i,
400
+ headers: s,
401
401
  credentials: "include",
402
402
  cache: "no-store",
403
403
  signal: o
404
404
  });
405
405
  return x(u);
406
406
  }
407
- async function pt({
407
+ async function _t({
408
408
  authToken: e,
409
409
  backendRegion: t,
410
410
  headers: r,
411
411
  questionnaireResponseId: n,
412
412
  fetchImpl: o = fetch,
413
- signal: s
413
+ signal: i
414
414
  }) {
415
- const i = J(t), u = S({ authToken: e, json: !0, headers: r }), l = n != null && n.trim() ? JSON.stringify({ questionnaire_response_id: n.trim() }) : void 0, c = await o(`${i}/api/v1/patient/short_report_summary`, {
415
+ const s = J(t), u = S({ authToken: e, json: !0, headers: r }), l = n != null && n.trim() ? JSON.stringify({ questionnaire_response_id: n.trim() }) : void 0, c = await o(`${s}/api/v1/patient/short_report_summary`, {
416
416
  method: "POST",
417
417
  headers: u,
418
418
  body: l,
419
419
  credentials: "include",
420
420
  cache: "no-store",
421
- signal: s
421
+ signal: i
422
422
  });
423
423
  return x(c);
424
424
  }
@@ -441,7 +441,7 @@ function z() {
441
441
  return V(fe);
442
442
  }
443
443
  function $e() {
444
- return V(pe);
444
+ return V(_e);
445
445
  }
446
446
  function je(e) {
447
447
  const t = f(e);
@@ -468,7 +468,7 @@ function ve(e) {
468
468
  resourceKey: o
469
469
  };
470
470
  }
471
- function _t(e, t) {
471
+ function pt(e, t) {
472
472
  const r = /* @__PURE__ */ new Set(), n = [];
473
473
  for (const o of t)
474
474
  r.has(o.id) || (r.add(o.id), n.push(o));
@@ -482,15 +482,15 @@ async function ht({
482
482
  fetchImpl: r = fetch,
483
483
  signal: n
484
484
  }) {
485
- const o = S({ authToken: e, headers: t }), s = await r(`${z()}/api/v1/lms/partner_resources`, {
485
+ const o = S({ authToken: e, headers: t }), i = await r(`${z()}/api/v1/lms/partner_resources`, {
486
486
  method: "GET",
487
487
  headers: o,
488
488
  credentials: "include",
489
489
  cache: "no-store",
490
490
  signal: n
491
491
  });
492
- if (!s.ok) return [];
493
- const i = await G(s), u = i == null ? void 0 : i.resources;
492
+ if (!i.ok) return [];
493
+ const s = await G(i), u = s == null ? void 0 : s.resources;
494
494
  return Array.isArray(u) ? u.map(
495
495
  (l) => ve(l)
496
496
  ).filter((l) => l !== null) : [];
@@ -501,13 +501,13 @@ async function mt({
501
501
  externalUserId: r,
502
502
  email: n,
503
503
  displayName: o,
504
- courseSlug: s,
505
- resourceKey: i,
504
+ courseSlug: i,
505
+ resourceKey: s,
506
506
  fetchImpl: u = fetch,
507
507
  signal: l
508
508
  }) {
509
509
  var b;
510
- const c = S({ authToken: e, json: !0, headers: t }), a = await u(`${z()}/api/v1/lms/partner_launches`, {
510
+ const c = S({ authToken: e, json: !0, headers: t }), d = await u(`${z()}/api/v1/lms/partner_launches`, {
511
511
  method: "POST",
512
512
  headers: c,
513
513
  credentials: "include",
@@ -518,44 +518,44 @@ async function mt({
518
518
  external_user_id: r,
519
519
  email: n,
520
520
  display_name: o,
521
- course_slug: s,
522
- resource_key: i
521
+ course_slug: i,
522
+ resource_key: s
523
523
  }
524
524
  })
525
- }), d = await G(a);
526
- if (!a.ok) {
527
- const g = typeof (d == null ? void 0 : d.error) == "string" ? d.error : "lms_launch_failed";
525
+ }), a = await G(d);
526
+ if (!d.ok) {
527
+ const g = typeof (a == null ? void 0 : a.error) == "string" ? a.error : "lms_launch_failed";
528
528
  throw new Error(g);
529
529
  }
530
- const h = f(d == null ? void 0 : d.launch_token);
531
- if (!h) throw new Error("lms_launch_failed");
530
+ const p = f(a == null ? void 0 : a.launch_token);
531
+ if (!p) throw new Error("lms_launch_failed");
532
532
  return {
533
- launchUrl: je(h),
534
- expiresAt: f(d == null ? void 0 : d.expires_at),
535
- courseTitle: f((b = d == null ? void 0 : d.course) == null ? void 0 : b.title)
533
+ launchUrl: je(p),
534
+ expiresAt: f(a == null ? void 0 : a.expires_at),
535
+ courseTitle: f((b = a == null ? void 0 : a.course) == null ? void 0 : b.title)
536
536
  };
537
537
  }
538
538
  const qe = "enroll.questionnaire.completed", He = "metabolic_code.short_report.completed", De = "enroll.junction_order.created";
539
539
  class q extends Error {
540
- constructor(r, n, o, s) {
540
+ constructor(r, n, o, i) {
541
541
  super(r);
542
542
  I(this, "status");
543
543
  I(this, "statusText");
544
544
  I(this, "body");
545
- this.name = "MetabolicStealthHealthRequestError", this.status = n, this.statusText = o, this.body = s;
545
+ this.name = "MetabolicStealthHealthRequestError", this.status = n, this.statusText = o, this.body = i;
546
546
  }
547
547
  }
548
548
  function Fe(e) {
549
549
  return e.replace(/\/+$/, "");
550
550
  }
551
- function p(e) {
551
+ function _(e) {
552
552
  return typeof e == "string" ? e.trim() : "";
553
553
  }
554
554
  function Je(e) {
555
555
  return Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
556
556
  }
557
557
  function Y(e, t) {
558
- const r = p(e);
558
+ const r = _(e);
559
559
  if (!r)
560
560
  throw new Error("Stealth Health Functions base URL is required.");
561
561
  return `${Fe(r)}/${t}`;
@@ -595,13 +595,13 @@ async function bt({
595
595
  questionnaireId: r,
596
596
  enrollSlug: n,
597
597
  profileData: o,
598
- selectedMedication: s,
599
- partnerRef: i,
598
+ selectedMedication: i,
599
+ partnerRef: s,
600
600
  whiteLabelDomain: u,
601
601
  fetchImpl: l = fetch,
602
602
  signal: c
603
603
  }) {
604
- const a = await l(
604
+ const d = await l(
605
605
  Y(e, "processQuestionnaireSubmission"),
606
606
  {
607
607
  method: "POST",
@@ -610,17 +610,17 @@ async function bt({
610
610
  Je({
611
611
  questionnaireResponseId: t,
612
612
  questionnaireId: r,
613
- enrollSlug: p(n) || void 0,
613
+ enrollSlug: _(n) || void 0,
614
614
  profileData: o,
615
- selectedMedication: s,
616
- partnerRef: i,
615
+ selectedMedication: i,
616
+ partnerRef: s,
617
617
  whiteLabelDomain: u
618
618
  })
619
619
  ),
620
620
  signal: c
621
621
  }
622
622
  );
623
- return W(a);
623
+ return W(d);
624
624
  }
625
625
  async function Et({
626
626
  functionsBaseUrl: e,
@@ -660,7 +660,7 @@ function $(e) {
660
660
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && !!n.trim()) : [];
661
661
  }
662
662
  function Q(e, t) {
663
- return p(e.slug) || p(t) || $(e)[0] || "";
663
+ return _(e.slug) || _(t) || $(e)[0] || "";
664
664
  }
665
665
  function Ve({
666
666
  appointmentId: e,
@@ -668,29 +668,29 @@ function Ve({
668
668
  enrollSlug: r,
669
669
  questionnaireId: n,
670
670
  questionnaireResponseId: o,
671
- responseData: s,
672
- user: i,
671
+ responseData: i,
672
+ user: s,
673
673
  occurredAt: u = (/* @__PURE__ */ new Date()).toISOString()
674
674
  }) {
675
- const l = k(s), c = l.questionnaireSnapshot && typeof l.questionnaireSnapshot == "object" && !Array.isArray(l.questionnaireSnapshot) ? l.questionnaireSnapshot : {}, a = Q(t, r);
675
+ const l = k(i), c = l.questionnaireSnapshot && typeof l.questionnaireSnapshot == "object" && !Array.isArray(l.questionnaireSnapshot) ? l.questionnaireSnapshot : {}, d = Q(t, r);
676
676
  return {
677
677
  event: qe,
678
678
  occurredAt: u,
679
679
  enrollPage: {
680
680
  id: t.id,
681
- slug: a,
681
+ slug: d,
682
682
  slugs: $(t)
683
683
  },
684
684
  appointment: { id: e },
685
685
  appointmentId: e,
686
686
  user: {
687
- id: i.uid,
688
- uid: i.uid,
689
- email: i.email,
690
- firstname: i.firstname,
691
- lastname: i.lastname,
692
- birthday: i.birthday,
693
- telephone: i.telephone
687
+ id: s.uid,
688
+ uid: s.uid,
689
+ email: s.email,
690
+ firstname: s.firstname,
691
+ lastname: s.lastname,
692
+ birthday: s.birthday,
693
+ telephone: s.telephone
694
694
  },
695
695
  questionnaire: {
696
696
  id: n,
@@ -708,7 +708,7 @@ function yt({
708
708
  submissionId: e,
709
709
  ...t
710
710
  }) {
711
- const r = p(e) || t.questionnaireResponseId;
711
+ const r = _(e) || t.questionnaireResponseId;
712
712
  return {
713
713
  ...Ve({
714
714
  ...t,
@@ -727,11 +727,11 @@ function K(e, t) {
727
727
  }
728
728
  function Ge(e) {
729
729
  const t = w(e), r = K(t, "order");
730
- return p(t == null ? void 0 : t.junctionOrderId) || p(t == null ? void 0 : t.junction_order_id) || p(t == null ? void 0 : t.orderId) || p(r == null ? void 0 : r.id);
730
+ return _(t == null ? void 0 : t.junctionOrderId) || _(t == null ? void 0 : t.junction_order_id) || _(t == null ? void 0 : t.orderId) || _(r == null ? void 0 : r.id);
731
731
  }
732
732
  function ze(e) {
733
733
  const t = w(e), r = K(t, "order");
734
- return p(t == null ? void 0 : t.status) || p(t == null ? void 0 : t.junctionStatus) || p(t == null ? void 0 : t.labOrderStatus) || p(r == null ? void 0 : r.status);
734
+ return _(t == null ? void 0 : t.status) || _(t == null ? void 0 : t.junctionStatus) || _(t == null ? void 0 : t.labOrderStatus) || _(r == null ? void 0 : r.status);
735
735
  }
736
736
  function St({
737
737
  enrollPage: e,
@@ -740,19 +740,19 @@ function St({
740
740
  appointmentData: n,
741
741
  occurredAt: o = (/* @__PURE__ */ new Date()).toISOString()
742
742
  }) {
743
- const s = w(r), i = p(s == null ? void 0 : s.appointmentId) || p(t == null ? void 0 : t.appointmentId), u = Ge(r);
744
- if (!i || !u) return null;
745
- const l = p(t == null ? void 0 : t.questionnaireResponseId) || p(n == null ? void 0 : n.questionnaireResponseId), c = ze(r), a = Q(e);
743
+ const i = w(r), s = _(i == null ? void 0 : i.appointmentId) || _(t == null ? void 0 : t.appointmentId), u = Ge(r);
744
+ if (!s || !u) return null;
745
+ const l = _(t == null ? void 0 : t.questionnaireResponseId) || _(n == null ? void 0 : n.questionnaireResponseId), c = ze(r), d = Q(e);
746
746
  return {
747
747
  event: De,
748
748
  occurredAt: o,
749
749
  enrollPage: {
750
750
  id: e.id,
751
- slug: a,
751
+ slug: d,
752
752
  slugs: $(e)
753
753
  },
754
- appointment: { id: i },
755
- appointmentId: i,
754
+ appointment: { id: s },
755
+ appointmentId: s,
756
756
  ...l ? { questionnaireResponseId: l } : {},
757
757
  junctionOrder: {
758
758
  id: u,
@@ -770,10 +770,10 @@ function Ye(e) {
770
770
  }
771
771
  function We(e) {
772
772
  try {
773
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = t.length % 4, n = r ? t + "=".repeat(4 - r) : t, o = atob(n), s = new Uint8Array(o.length);
774
- for (let i = 0; i < o.length; i++)
775
- s[i] = o.charCodeAt(i);
776
- return s;
773
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = t.length % 4, n = r ? t + "=".repeat(4 - r) : t, o = atob(n), i = new Uint8Array(o.length);
774
+ for (let s = 0; s < o.length; s++)
775
+ i[s] = o.charCodeAt(s);
776
+ return i;
777
777
  } catch {
778
778
  return null;
779
779
  }
@@ -795,18 +795,18 @@ function Ke(e) {
795
795
  }
796
796
  }
797
797
  const X = "mb_context";
798
- function _(e) {
798
+ function h(e) {
799
799
  if (typeof e != "string") return;
800
800
  const t = e.trim();
801
801
  return t || void 0;
802
802
  }
803
803
  function Z(e) {
804
804
  var t;
805
- return (t = _(e)) == null ? void 0 : t.replace(/\s/g, "+");
805
+ return (t = h(e)) == null ? void 0 : t.replace(/\s/g, "+");
806
806
  }
807
807
  function Xe(e) {
808
808
  var r;
809
- const t = (r = _(e)) == null ? void 0 : r.toLowerCase();
809
+ const t = (r = h(e)) == null ? void 0 : r.toLowerCase();
810
810
  if (t === "patient" || t === "practitioner") return t;
811
811
  }
812
812
  function ee(e) {
@@ -817,31 +817,31 @@ function Ze(e) {
817
817
  const t = ee(e);
818
818
  if (!t) return;
819
819
  const r = {
820
- id: _(t.id),
821
- reportId: _(t.reportId),
822
- fullName: _(t.fullName),
820
+ id: h(t.id),
821
+ reportId: h(t.reportId),
822
+ fullName: h(t.fullName),
823
823
  email: Z(t.email),
824
- avatarSrc: _(t.avatarSrc)
824
+ avatarSrc: h(t.avatarSrc)
825
825
  };
826
826
  return Object.values(r).some(Boolean) ? r : void 0;
827
827
  }
828
828
  function et(e) {
829
829
  const t = ee(e);
830
830
  if (!t) return null;
831
- const r = Xe(t.role), n = _(t.authToken), o = _(t.embedToken);
831
+ const r = Xe(t.role), n = h(t.authToken), o = h(t.embedToken);
832
832
  return !r || !n && !o ? null : {
833
833
  role: r,
834
834
  authToken: n,
835
835
  embedToken: o,
836
- subject: _(t.subject),
836
+ subject: h(t.subject),
837
837
  backendRegion: nt(t.backendRegion),
838
- backendBaseUrl: _(t.backendBaseUrl),
838
+ backendBaseUrl: h(t.backendBaseUrl),
839
839
  email: Z(t.email),
840
- displayName: _(t.displayName),
841
- avatarSrc: _(t.avatarSrc),
842
- reportId: _(t.reportId),
843
- questionnaireResponseId: _(t.questionnaireResponseId),
844
- activeNavItemId: _(t.activeNavItemId),
840
+ displayName: h(t.displayName),
841
+ avatarSrc: h(t.avatarSrc),
842
+ reportId: h(t.reportId),
843
+ questionnaireResponseId: h(t.questionnaireResponseId),
844
+ activeNavItemId: h(t.activeNavItemId),
845
845
  patient: Ze(t.patient)
846
846
  };
847
847
  }
@@ -858,7 +858,7 @@ function gt(e) {
858
858
  }
859
859
  function nt(e) {
860
860
  var r;
861
- const t = (r = _(e)) == null ? void 0 : r.toLowerCase();
861
+ const t = (r = h(e)) == null ? void 0 : r.toLowerCase();
862
862
  if (t === "us" || t === "usa") return "us";
863
863
  if (t === "ca" || t === "canada") return "ca";
864
864
  }
@@ -867,9 +867,9 @@ function Rt(e, t) {
867
867
  return `${e}${n}${X}=${r}`;
868
868
  }
869
869
  function Tt(e) {
870
- var s, i, u, l, c;
870
+ var i, s, u, l, c;
871
871
  if (!e) return;
872
- const t = e.reportId ?? ((s = e.patient) == null ? void 0 : s.reportId) ?? ((i = e.patient) == null ? void 0 : i.id), r = e.role === "practitioner" && !t, n = (u = e.patient) != null && u.fullName || (l = e.patient) != null && l.email || (c = e.patient) != null && c.avatarSrc ? {
872
+ const t = e.reportId ?? ((i = e.patient) == null ? void 0 : i.reportId) ?? ((s = e.patient) == null ? void 0 : s.id), r = e.role === "practitioner" && !t, n = (u = e.patient) != null && u.fullName || (l = e.patient) != null && l.email || (c = e.patient) != null && c.avatarSrc ? {
873
873
  displayName: e.patient.fullName ?? e.patient.email,
874
874
  email: e.patient.email,
875
875
  avatarSrc: e.patient.avatarSrc
@@ -928,16 +928,16 @@ export {
928
928
  ft as O,
929
929
  Be as P,
930
930
  st as Q,
931
- pt as R,
931
+ _t as R,
932
932
  qe as S,
933
933
  J as T,
934
934
  z as U,
935
935
  $e as V,
936
936
  Me as W,
937
- _t as X,
937
+ pt as X,
938
938
  at as Y,
939
939
  Rt as Z,
940
- _e as _,
940
+ pe as _,
941
941
  se as a,
942
942
  ve as a0,
943
943
  x as a1,
@@ -963,7 +963,7 @@ export {
963
963
  D as n,
964
964
  C as o,
965
965
  fe as p,
966
- pe as q,
966
+ _e as q,
967
967
  Tt as r,
968
968
  de as s,
969
969
  le as t,
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import './index.css';var Zq = Object.defineProperty;
2
2
  var Cq = (A, l, p) => l in A ? Zq(A, l, { enumerable: !0, configurable: !0, writable: !0, value: p }) : A[l] = p;
3
3
  var rp = (A, l, p) => Cq(A, typeof l != "symbol" ? l + "" : l, p);
4
4
  import { useAgCharts as Xt, ensureAgChartsModules as Xq } from "./ag-charts.js";
5
- import { c as xq, g as XA, b as ml, a as Pl, d as xt, r as Lq, e as gq, f as Bq, h as hq, i as Fq, j as fq, M as Gq, k as np } from "./entry-api-MIuk8VYF.js";
6
- import { l as Lc, m as gc, n as Bc, o as hc, p as Fc, q as fc, s as Gc, t as vc, u as Dc, v as wc, w as Mc, S as Yc, x as _c, y as $c, z as Au, A as tu, B as lu, C as pu, D as Su, E as qu, F as au, G as Uu, H as Vu, I as ru, J as nu, K as Ku, L as eu, N as du, O as cu, P as uu, Q as ku, R as ou, T as Wu, U as bu, V as Ru, W as Ju, X as Ou, Y as ju, Z as Iu, _ as Tu, $ as iu, a0 as yu, a1 as su, a2 as Eu, a3 as Hu, a4 as mu, a5 as Pu, a6 as Nu, a7 as Qu, a8 as zu } from "./entry-api-MIuk8VYF.js";
5
+ import { c as xq, g as XA, b as ml, a as Pl, d as xt, r as Lq, e as gq, f as Bq, h as hq, i as Fq, j as fq, M as Gq, k as np } from "./entry-api-n7RYttkh.js";
6
+ import { l as Lc, m as gc, n as Bc, o as hc, p as Fc, q as fc, s as Gc, t as vc, u as Dc, v as wc, w as Mc, S as Yc, x as _c, y as $c, z as Au, A as tu, B as lu, C as pu, D as Su, E as qu, F as au, G as Uu, H as Vu, I as ru, J as nu, K as Ku, L as eu, N as du, O as cu, P as uu, Q as ku, R as ou, T as Wu, U as bu, V as Ru, W as Ju, X as Ou, Y as ju, Z as Iu, _ as Tu, $ as iu, a0 as yu, a1 as su, a2 as Eu, a3 as Hu, a4 as mu, a5 as Pu, a6 as Nu, a7 as Qu, a8 as zu } from "./entry-api-n7RYttkh.js";
7
7
  import { jsx as t, jsxs as a, Fragment as pA } from "react/jsx-runtime";
8
8
  import { useId as xA, useRef as L, useState as y, useLayoutEffect as Jl, useMemo as C, useEffect as h, useCallback as B, useContext as LA, createContext as dt, isValidElement as vq, cloneElement as Dq, lazy as sA, useReducer as wq, Component as Mq, Suspense as Yq, StrictMode as _q } from "react";
9
9
  import { A as Nl, a as $q } from "./vendor-ag-charts-W8mi59GS.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaboliccode-dev/widget",
3
- "version": "0.2.83",
3
+ "version": "0.2.84",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",