@alfadocs/ui-kit 1.144.0 → 1.146.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.
Files changed (94) hide show
  1. package/dist/_chunks/{calendar-appointment-editor-dialog-CA69bdbI.js → calendar-appointment-editor-dialog-sY-k0GGW.js} +3 -3
  2. package/dist/_chunks/{calendar-waiting-list-panel-Du_jtVbl.js → calendar-waiting-list-panel-Bm7NAZdk.js} +2 -2
  3. package/dist/_chunks/{calendar.sheets-CGwr4t2p.js → calendar.sheets-CCvdZF-R.js} +2 -2
  4. package/dist/_chunks/{editor-overlay-Cl6IhKNG.js → editor-overlay-jc9HUeQ2.js} +29 -26
  5. package/dist/_chunks/{help-me-write-templates-BdCQ-kFO.js → help-me-write-templates-DlA54nu5.js} +2 -2
  6. package/dist/_chunks/{notes-panel-DnBmONPb.js → notes-panel-C9aB1Cma.js} +2 -2
  7. package/dist/_chunks/prescription-history-CYCg6nxp.js +1772 -0
  8. package/dist/_chunks/registry-connection-panel-BEAkwivy.js +503 -0
  9. package/dist/_chunks/rich-text-editor-CJXc5GgH.js +4351 -0
  10. package/dist/agent-catalog.json +115 -1
  11. package/dist/agent-i18n/en.json +12 -0
  12. package/dist/appointment-editor-panel/index.js +1 -1
  13. package/dist/aws-transcribe/index.js +176 -152
  14. package/dist/browser-support.js +1 -1
  15. package/dist/components/_shared/medication.d.ts +4 -0
  16. package/dist/components/editor-overlay/index.js +1 -1
  17. package/dist/components/index.d.ts +1 -0
  18. package/dist/components/notes-panel/index.js +1 -1
  19. package/dist/components/registry-connection-panel/index.d.ts +3 -0
  20. package/dist/components/registry-connection-panel/index.js +5 -0
  21. package/dist/components/registry-connection-panel/registry-connection-panel.agent.d.ts +4 -0
  22. package/dist/components/registry-connection-panel/registry-connection-panel.d.ts +67 -0
  23. package/dist/components/rich-text-editor/help-me-write-overlay.d.ts +2 -0
  24. package/dist/components/rich-text-editor/index.js +1 -1
  25. package/dist/components/rich-text-editor/rich-text-editor.d.ts +7 -0
  26. package/dist/find-free-slots-panel/index.js +1 -1
  27. package/dist/i18n/locales/ar.d.ts +30 -0
  28. package/dist/i18n/locales/ar.js +31 -1
  29. package/dist/i18n/locales/de.d.ts +30 -0
  30. package/dist/i18n/locales/de.js +31 -1
  31. package/dist/i18n/locales/el.d.ts +30 -0
  32. package/dist/i18n/locales/el.js +31 -1
  33. package/dist/i18n/locales/en.d.ts +30 -0
  34. package/dist/i18n/locales/en.js +31 -1
  35. package/dist/i18n/locales/es.d.ts +30 -0
  36. package/dist/i18n/locales/es.js +31 -1
  37. package/dist/i18n/locales/fr.d.ts +30 -0
  38. package/dist/i18n/locales/fr.js +31 -1
  39. package/dist/i18n/locales/hi.d.ts +30 -0
  40. package/dist/i18n/locales/hi.js +31 -1
  41. package/dist/i18n/locales/it.d.ts +30 -0
  42. package/dist/i18n/locales/it.js +31 -1
  43. package/dist/i18n/locales/ja.d.ts +30 -0
  44. package/dist/i18n/locales/ja.js +31 -1
  45. package/dist/i18n/locales/nl.d.ts +30 -0
  46. package/dist/i18n/locales/nl.js +31 -1
  47. package/dist/i18n/locales/pl.d.ts +30 -0
  48. package/dist/i18n/locales/pl.js +31 -1
  49. package/dist/i18n/locales/pt.d.ts +30 -0
  50. package/dist/i18n/locales/pt.js +31 -1
  51. package/dist/i18n/locales/ro.d.ts +30 -0
  52. package/dist/i18n/locales/ro.js +31 -1
  53. package/dist/i18n/locales/ru.d.ts +30 -0
  54. package/dist/i18n/locales/ru.js +31 -1
  55. package/dist/i18n/locales/sq.d.ts +30 -0
  56. package/dist/i18n/locales/sq.js +31 -1
  57. package/dist/i18n/locales/sv.d.ts +30 -0
  58. package/dist/i18n/locales/sv.js +31 -1
  59. package/dist/i18n/locales/tr.d.ts +30 -0
  60. package/dist/i18n/locales/tr.js +31 -1
  61. package/dist/i18n/locales/zh.d.ts +30 -0
  62. package/dist/i18n/locales/zh.js +31 -1
  63. package/dist/index.js +860 -858
  64. package/dist/locales/ar.json +31 -1
  65. package/dist/locales/de.json +31 -1
  66. package/dist/locales/el.json +31 -1
  67. package/dist/locales/en.json +31 -1
  68. package/dist/locales/es.json +31 -1
  69. package/dist/locales/fr.json +31 -1
  70. package/dist/locales/hi.json +31 -1
  71. package/dist/locales/it.json +31 -1
  72. package/dist/locales/ja.json +31 -1
  73. package/dist/locales/nl.json +31 -1
  74. package/dist/locales/pl.json +31 -1
  75. package/dist/locales/pt.json +31 -1
  76. package/dist/locales/ro.json +31 -1
  77. package/dist/locales/ru.json +31 -1
  78. package/dist/locales/sq.json +31 -1
  79. package/dist/locales/sv.json +31 -1
  80. package/dist/locales/tr.json +31 -1
  81. package/dist/locales/zh.json +31 -1
  82. package/dist/online-bookings-panel/index.js +1 -1
  83. package/dist/patterns/calendar/index.js +2 -2
  84. package/dist/patterns/help-me-write-templates/index.js +1 -1
  85. package/dist/patterns/prescription/index.js +1 -1
  86. package/dist/patterns/prescription/prescription-sheet.d.ts +7 -1
  87. package/dist/patterns/prescription/prescription-validation.d.ts +7 -3
  88. package/dist/redactor.css +3 -0
  89. package/dist/speech/aws-transcribe.d.ts +9 -0
  90. package/dist/tokens.css +3 -0
  91. package/dist/waiting-list-panel/index.js +2 -2
  92. package/package.json +5 -1
  93. package/dist/_chunks/prescription-history-CD3e3U3I.js +0 -1719
  94. package/dist/_chunks/rich-text-editor-Cx9cA4pd.js +0 -4305
@@ -0,0 +1,1772 @@
1
+ import { jsxs as y, jsx as r, Fragment as Be } from "react/jsx-runtime";
2
+ import { forwardRef as Ge, useId as ve, useState as U, useRef as w, useEffect as qe, useCallback as A, useMemo as _e, useImperativeHandle as Et } from "react";
3
+ import { c as _ } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as Ie } from "react-i18next";
5
+ import { A as he } from "./alert-C4WKViaS.js";
6
+ import { B as Re } from "./button-Dp4j9ygh.js";
7
+ import { E as Wt } from "./empty-state-5REM7oDM.js";
8
+ import { E as Qt } from "./error-summary-DxNhwf_G.js";
9
+ import { F as Yt } from "./field-array-kwUgFOIr.js";
10
+ import { F as pe } from "./form-field-CyHfOVKF.js";
11
+ import { S as Nt } from "./select-Bw5FvGJ7.js";
12
+ import { S as Ve } from "./skeleton-tTWJpvAq.js";
13
+ import { P as Ut } from "./patient-picker-Dm74jHIk.js";
14
+ import { p as ct } from "./privacy-mask-text-B8YfzB7L.js";
15
+ import { u as Xt } from "./use-controllable-state-BiY4xTzM.js";
16
+ import { u as Ee } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
17
+ import { u as Jt, a as Zt } from "./use-error-summary-CecJZo6w.js";
18
+ import { C as er } from "./checkbox-DV4sNDeB.js";
19
+ import { N as tr } from "./number-input-Bi5Yk6PX.js";
20
+ import { T as nt } from "./text-input-B6iAgCr3.js";
21
+ import { M as rr } from "./medication-search-CTUtXuPT.js";
22
+ import { a as ir, S as sr } from "./suggestion-chip-BNRWZL51.js";
23
+ import { V as lt } from "./visually-hidden-BHxEUGyT.js";
24
+ import { T as nr } from "./timestamp-UMF1llBs.js";
25
+ import { I as ar } from "./icon-button-u9VMQn3x.js";
26
+ import { B as or } from "./button-group-N60L3HMa.js";
27
+ import { D as De } from "./dropdown-menu-Bm1KALnk.js";
28
+ import { K as cr, a as ie, S as St } from "./key-value-pair-BykhMTcP.js";
29
+ import { a as lr, M as dr } from "./medication-line-DFa5oFhf.js";
30
+ import { P as pr } from "./print-sheet-gaxObGcm.js";
31
+ import { a as ur } from "./whatsapp-button-XbozeDl_.js";
32
+ import { f as Oe } from "./intl-locale-FWh-Y5_3.js";
33
+ import { A as qt } from "./avatar-Dp5apm1d.js";
34
+ import { P as Ct } from "./printer-rkK0T1gi.js";
35
+ import { D as mr } from "./download-CfYKJO_j.js";
36
+ import { M as fr } from "./mail-BqXVF2zH.js";
37
+ import { M as hr } from "./message-square-Bye4ATvx.js";
38
+ import { C as br } from "./chevron-down-DWE7GSq9.js";
39
+ import { I as gr } from "./icon-button-group-DEAx9M5v.js";
40
+ import { T as yr } from "./tag-BNlcEJfE.js";
41
+ import { R as vr } from "./row-actions-CA938TAd.js";
42
+ import { e as Ir } from "./data-grid-CujX-2tF.js";
43
+ import { D as de } from "./toolbar-z_6tE7zG.js";
44
+ import { B as Nr } from "./badge-BUk4RjTS.js";
45
+ import { C as Sr } from "./check-DrFSN__t.js";
46
+ import { L as kr } from "./loader-circle-BECIU_8N.js";
47
+ import { C as xr } from "./circle-alert-rGDZ73Wh.js";
48
+ import { E as Tr } from "./eye-BjhN2nYf.js";
49
+ function wr(e, n) {
50
+ const a = {};
51
+ if (e.patientId && n.patientId && (a.patientId = e.patientId), e.prescriberId && n.prescriberId && (a.prescriberId = e.prescriberId), e.treatmentId && n.treatmentId === e.treatmentId && (a.treatmentId = e.treatmentId), e.items && n.items && (a.items = e.items), e.itemErrors) {
52
+ const h = e.itemErrors.map(
53
+ (u, k) => {
54
+ var N;
55
+ const b = (N = n.itemErrors) == null ? void 0 : N[k];
56
+ if (!u || !b) return;
57
+ const c = {};
58
+ return u.medicationId && b.medicationId && (c.medicationId = u.medicationId), u.dosage && b.dosage && (c.dosage = u.dosage), u.quantity && b.quantity && (c.quantity = u.quantity), Object.keys(c).length > 0 ? c : void 0;
59
+ }
60
+ );
61
+ h.some((u) => u !== void 0) && (a.itemErrors = h);
62
+ }
63
+ return a;
64
+ }
65
+ const $r = 5, Er = _(
66
+ "ds:@container/rxline ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
67
+ {
68
+ variants: {
69
+ separated: {
70
+ true: "ds:border-t ds:border-[color:var(--border)] ds:pt-[var(--spacing-lg)]",
71
+ false: "ds:pt-[var(--spacing-xs)]"
72
+ }
73
+ },
74
+ defaultVariants: { separated: !1 }
75
+ }
76
+ );
77
+ function qr({
78
+ index: e,
79
+ item: n,
80
+ medication: a,
81
+ medicationFieldId: h,
82
+ dosageFieldId: u,
83
+ quantityFieldId: k,
84
+ medicationError: b,
85
+ dosageError: c,
86
+ quantityError: N,
87
+ announceMedicationError: C,
88
+ announceDosageError: x,
89
+ announceQuantityError: j,
90
+ searchMedications: L,
91
+ codeLabel: se,
92
+ catalogueStatus: d,
93
+ onCatalogueRetry: J,
94
+ suggestions: D,
95
+ onMedicationChange: E,
96
+ onDosageChange: G,
97
+ onNotesChange: ne,
98
+ onQuantityChange: O,
99
+ onDurationChange: m,
100
+ onNotSubstitutableChange: $,
101
+ medicationSearchId: F,
102
+ medicationRef: V,
103
+ dosageInputRef: Z,
104
+ onSuggestionChosen: ee
105
+ }) {
106
+ const { t: o } = Ie("ui"), H = e + 1, v = `${h}-legend`, S = D.slice(0, $r), s = `${h}-hint`;
107
+ return /* @__PURE__ */ y(
108
+ "div",
109
+ {
110
+ role: "group",
111
+ "aria-labelledby": v,
112
+ "data-slot": "prescription-item",
113
+ "data-index": e,
114
+ className: Er({ separated: e > 0 }),
115
+ children: [
116
+ /* @__PURE__ */ r("p", { id: v, className: "type-label ds:text-foreground", children: o("prescription.composer.medicationLegend", { number: H }) }),
117
+ /* @__PURE__ */ r(
118
+ pe,
119
+ {
120
+ id: h,
121
+ label: o("prescription.composer.medication"),
122
+ required: !0,
123
+ error: b,
124
+ announceError: C,
125
+ children: /* @__PURE__ */ r(
126
+ rr,
127
+ {
128
+ ref: V,
129
+ id: F,
130
+ loadOptions: L,
131
+ value: a,
132
+ onValueChange: E,
133
+ codeLabel: se,
134
+ status: d,
135
+ onRetry: J
136
+ }
137
+ )
138
+ }
139
+ ),
140
+ /* @__PURE__ */ r(
141
+ pe,
142
+ {
143
+ id: u,
144
+ label: o("prescription.composer.dosage"),
145
+ required: !0,
146
+ error: c,
147
+ announceError: x,
148
+ children: /* @__PURE__ */ r(
149
+ nt,
150
+ {
151
+ ref: Z,
152
+ dir: "auto",
153
+ value: n.dosage,
154
+ onChange: (f) => G(f.target.value)
155
+ }
156
+ )
157
+ }
158
+ ),
159
+ a && S.length > 0 ? /* @__PURE__ */ y(
160
+ "div",
161
+ {
162
+ "data-slot": "dosage-suggestions",
163
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
164
+ children: [
165
+ /* @__PURE__ */ r("p", { id: s, className: "type-body-sm ds:text-muted-foreground", children: o("prescription.composer.dosageSuggestionsHint") }),
166
+ /* @__PURE__ */ r(
167
+ ir,
168
+ {
169
+ label: o("prescription.composer.dosageSuggestions"),
170
+ "aria-describedby": s,
171
+ children: S.map((f) => /* @__PURE__ */ r(
172
+ sr,
173
+ {
174
+ value: f,
175
+ dir: "auto",
176
+ keepOnSelect: !0,
177
+ onSelect: ee,
178
+ children: f
179
+ },
180
+ f
181
+ ))
182
+ }
183
+ )
184
+ ]
185
+ }
186
+ ) : null,
187
+ /* @__PURE__ */ y("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:@[576px]/rxline:grid-cols-[minmax(8rem,10rem)_minmax(0,1fr)_minmax(0,1fr)]", children: [
188
+ /* @__PURE__ */ r(
189
+ pe,
190
+ {
191
+ id: k,
192
+ label: o("prescription.composer.quantity"),
193
+ required: !0,
194
+ description: a == null ? void 0 : a.packsHint,
195
+ error: N,
196
+ announceError: j,
197
+ children: /* @__PURE__ */ r(
198
+ tr,
199
+ {
200
+ min: 1,
201
+ max: a == null ? void 0 : a.maxPacks,
202
+ step: 1,
203
+ value: Number.isFinite(n.quantity) ? n.quantity : null,
204
+ onChange: (f) => O(f ?? Number.NaN)
205
+ }
206
+ )
207
+ }
208
+ ),
209
+ /* @__PURE__ */ r(pe, { label: o("prescription.composer.notes"), optional: !0, children: /* @__PURE__ */ r(
210
+ nt,
211
+ {
212
+ dir: "auto",
213
+ value: n.notes,
214
+ onChange: (f) => ne(f.target.value)
215
+ }
216
+ ) }),
217
+ /* @__PURE__ */ r(pe, { label: o("prescription.composer.duration"), optional: !0, children: /* @__PURE__ */ r(
218
+ nt,
219
+ {
220
+ dir: "auto",
221
+ value: n.duration,
222
+ onChange: (f) => m(f.target.value)
223
+ }
224
+ ) })
225
+ ] }),
226
+ /* @__PURE__ */ r(
227
+ er,
228
+ {
229
+ label: o("prescription.composer.notSubstitutable"),
230
+ checked: n.notSubstitutable,
231
+ disabled: !(a != null && a.code) && !n.notSubstitutable,
232
+ disabledReason: o("prescription.composer.notSubstitutableNeedsCode"),
233
+ onCheckedChange: (f) => $(f === !0)
234
+ }
235
+ )
236
+ ]
237
+ }
238
+ );
239
+ }
240
+ const Cr = /^(\d{4})-(\d{2})-(\d{2})$/;
241
+ function Pr(e, n) {
242
+ const a = Cr.exec(e);
243
+ if (!a) return e;
244
+ const h = Number(a[1]), u = Number(a[2]), k = Number(a[3]), b = new Date(2e3, u - 1, k);
245
+ return b.setFullYear(h), Number.isNaN(b.getTime()) || b.getMonth() !== u - 1 || b.getDate() !== k ? e : new Intl.DateTimeFormat(Oe(n), {
246
+ dateStyle: "long"
247
+ }).format(b);
248
+ }
249
+ function Fe(e) {
250
+ return e !== void 0 && e.trim() !== "";
251
+ }
252
+ const Ar = _("ds:@container/pblock ds:flex ds:items-start", {
253
+ variants: {
254
+ density: {
255
+ default: "ds:gap-[var(--spacing-md)]",
256
+ compact: "ds:gap-[var(--spacing-sm)]"
257
+ }
258
+ },
259
+ defaultVariants: { density: "default" }
260
+ }), dt = Ge(
261
+ ({
262
+ patient: e,
263
+ privacyMode: n = !1,
264
+ density: a = "default",
265
+ showAvatar: h = !1,
266
+ className: u,
267
+ ...k
268
+ }, b) => {
269
+ const { t: c, i18n: N } = Ie("ui"), C = () => /* @__PURE__ */ y(Be, { children: [
270
+ /* @__PURE__ */ r(lt, { children: c("calendarWorkspace.privacy.hidden") }),
271
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: ct() })
272
+ ] }), x = [];
273
+ Fe(e.firstName) && x.push({
274
+ key: "firstName",
275
+ label: c("prescription.patient.firstName"),
276
+ value: n ? C() : /* @__PURE__ */ r("span", { dir: "auto", children: e.firstName })
277
+ }), Fe(e.lastName) && x.push({
278
+ key: "lastName",
279
+ label: c("prescription.patient.lastName"),
280
+ value: n ? C() : /* @__PURE__ */ r("span", { dir: "auto", children: e.lastName })
281
+ }), Fe(e.dateOfBirth) && x.push({
282
+ key: "dateOfBirth",
283
+ label: c("prescription.patient.dateOfBirth"),
284
+ value: n ? C() : Pr(e.dateOfBirth, N.language)
285
+ }), Fe(e.fiscalCode) && x.push({
286
+ key: "fiscalCode",
287
+ label: c("prescription.patient.fiscalCode"),
288
+ value: n ? C() : e.fiscalCode,
289
+ mono: !0
290
+ });
291
+ const j = `${e.firstName} ${e.lastName}`.trim();
292
+ return /* @__PURE__ */ y(
293
+ "div",
294
+ {
295
+ ...k,
296
+ ref: b,
297
+ role: "group",
298
+ "aria-label": c("prescription.patient.details"),
299
+ className: Ar({ density: a, className: u }),
300
+ "data-component": "prescription-patient-block",
301
+ "data-density": a,
302
+ "data-privacy": n ? "masked" : void 0,
303
+ children: [
304
+ h ? (
305
+ /* Under privacy mode the avatar shows no initials: an empty name
306
+ gives the Avatar's own neutral icon, at the same size. */
307
+ /* @__PURE__ */ r(
308
+ qt,
309
+ {
310
+ name: n ? "" : j,
311
+ size: "md",
312
+ className: "ds:shrink-0",
313
+ "aria-hidden": "true",
314
+ role: "presentation",
315
+ "aria-label": void 0
316
+ }
317
+ )
318
+ ) : null,
319
+ /* @__PURE__ */ r(
320
+ cr,
321
+ {
322
+ semantic: !0,
323
+ rowGap: a === "compact" ? "sm" : "md",
324
+ className: "ds:min-w-0 ds:flex-1 ds:@[448px]/pblock:grid-cols-[repeat(2,auto_fit-content(40%)_minmax(0,1fr))]",
325
+ children: x.map((L) => /* @__PURE__ */ r(
326
+ ie,
327
+ {
328
+ label: L.label,
329
+ value: L.value,
330
+ mono: L.mono,
331
+ "data-field": L.key
332
+ },
333
+ L.key
334
+ ))
335
+ }
336
+ )
337
+ ]
338
+ }
339
+ );
340
+ }
341
+ );
342
+ dt.displayName = "PrescriptionPatientBlock";
343
+ const je = Object.freeze({
344
+ medicationId: "",
345
+ dosage: "",
346
+ notes: "",
347
+ quantity: 1,
348
+ notSubstitutable: !1,
349
+ duration: ""
350
+ });
351
+ function Mr(e = "") {
352
+ return {
353
+ patientId: "",
354
+ prescriberId: e,
355
+ treatmentId: "",
356
+ items: [{ ...je }]
357
+ };
358
+ }
359
+ function X(e) {
360
+ return e == null || e.trim() === "";
361
+ }
362
+ function ot(e) {
363
+ return X(e.medicationId) && X(e.dosage) && X(e.notes) && X(e.duration) && !e.notSubstitutable;
364
+ }
365
+ function Lr(e, n) {
366
+ if (typeof e != "number" || Number.isNaN(e)) return "required";
367
+ if (!Number.isInteger(e) || e < 1) return "invalid";
368
+ if (n !== void 0 && e > n) return "tooMany";
369
+ }
370
+ function Vr(e, {
371
+ treatmentOptions: n,
372
+ treatmentOptionsPatientId: a
373
+ }) {
374
+ if (X(e.treatmentId)) return "required";
375
+ if (a !== void 0 && a !== e.patientId || n && !n.some((h) => h.id === e.treatmentId))
376
+ return "invalid";
377
+ }
378
+ function kt(e, n = {}) {
379
+ const a = {};
380
+ X(e.patientId) && (a.patientId = "required"), X(e.prescriberId) && (a.prescriberId = "required");
381
+ const h = Vr(e, n);
382
+ h && (a.treatmentId = h);
383
+ const u = e.items ?? [];
384
+ if (u.filter((c) => !ot(c)).length === 0)
385
+ return a.items = "required", u.length > 0 && (a.itemErrors = u.map(
386
+ (c, N) => N === 0 ? { medicationId: "required" } : void 0
387
+ )), a;
388
+ const b = u.map((c) => {
389
+ var x;
390
+ if (ot(c)) return;
391
+ const N = {};
392
+ X(c.medicationId) && (N.medicationId = "required"), X(c.dosage) && (N.dosage = "required");
393
+ const C = Lr(
394
+ c.quantity,
395
+ X(c.medicationId) || (x = n.maxPacksFor) == null ? void 0 : x.call(n, c.medicationId.trim())
396
+ );
397
+ return C && (N.quantity = C), Object.keys(N).length > 0 ? N : void 0;
398
+ });
399
+ return b.some((c) => c !== void 0) && (a.itemErrors = b), a;
400
+ }
401
+ function xt(e) {
402
+ return Object.keys(e).length === 0;
403
+ }
404
+ function Dr(e) {
405
+ return {
406
+ patientId: e.patientId.trim(),
407
+ prescriberId: e.prescriberId.trim(),
408
+ treatmentId: e.treatmentId.trim(),
409
+ items: e.items.filter((n) => !ot(n)).map((n) => ({
410
+ medicationId: n.medicationId.trim(),
411
+ dosage: n.dosage.trim(),
412
+ notes: n.notes.trim(),
413
+ quantity: n.quantity,
414
+ notSubstitutable: n.notSubstitutable,
415
+ duration: (n.duration ?? "").trim()
416
+ }))
417
+ };
418
+ }
419
+ const Fr = _(
420
+ "ds:flex ds:w-full ds:flex-col ds:gap-[var(--spacing-lg)]"
421
+ );
422
+ function at(e) {
423
+ return `${e.firstName} ${e.lastName}`.trim();
424
+ }
425
+ function Tt(e) {
426
+ return e.items.length > 0 ? e : { ...e, items: [{ ...je }] };
427
+ }
428
+ const Rr = Ge(function({
429
+ patients: n,
430
+ searchPatients: a,
431
+ treatmentOptions: h,
432
+ treatmentOptionsPatientId: u,
433
+ prescribers: k,
434
+ defaultPrescriberId: b,
435
+ searchMedications: c,
436
+ resolveMedication: N,
437
+ suggestDosages: C,
438
+ codeLabel: x,
439
+ catalogueStatus: j = "ready",
440
+ onCatalogueRetry: L,
441
+ value: se,
442
+ defaultValue: d,
443
+ onChange: J,
444
+ onSubmit: D,
445
+ onPatientChange: E,
446
+ loading: G = !1,
447
+ error: ne,
448
+ privacyMode: O = !1,
449
+ lockPatient: m = !1,
450
+ submitLabel: $,
451
+ id: F,
452
+ className: V,
453
+ ...Z
454
+ }, ee) {
455
+ const { t: o } = Ie("ui"), H = ve(), v = F ?? H, [S] = U(
456
+ () => d ?? Mr(
457
+ b && k.some((t) => t.id === b) ? b : ""
458
+ )
459
+ ), [s, f] = Xt({
460
+ value: se,
461
+ defaultValue: S,
462
+ onChange: J
463
+ }), T = Tt(s ?? S), q = w(T);
464
+ Ee(() => {
465
+ q.current = T;
466
+ });
467
+ const [R, K] = U({}), [Ne, ue] = U(!1), [me, Se] = U(!1), W = w(!1), ae = w(!0);
468
+ qe(() => (ae.current = !0, () => {
469
+ ae.current = !1;
470
+ }), []);
471
+ const [z, He] = U(() => /* @__PURE__ */ new Map()), [Ke, Q] = U(() => /* @__PURE__ */ new Map()), ke = w(/* @__PURE__ */ new Map()), fe = w(N);
472
+ Ee(() => {
473
+ fe.current = N;
474
+ });
475
+ const oe = A(
476
+ (t) => {
477
+ var i, l;
478
+ return (l = ke.current.get(t) ?? ((i = fe.current) == null ? void 0 : i.call(fe, t))) == null ? void 0 : l.maxPacks;
479
+ },
480
+ []
481
+ ), xe = A(
482
+ (t) => {
483
+ for (const i of t) ke.current.set(i.id, i);
484
+ Q((i) => {
485
+ if (t.every((p) => i.get(p.id) === p)) return i;
486
+ const l = new Map(i);
487
+ for (const p of t) l.set(p.id, p);
488
+ return l;
489
+ });
490
+ },
491
+ []
492
+ ), g = w(c);
493
+ Ee(() => {
494
+ g.current = c;
495
+ });
496
+ const be = A(
497
+ async (t, i) => {
498
+ const l = await g.current(t, i);
499
+ return i.signal.aborted || xe(l), l;
500
+ },
501
+ [xe]
502
+ ), ge = w(a);
503
+ Ee(() => {
504
+ ge.current = a;
505
+ });
506
+ const Te = a !== void 0, We = _e(() => {
507
+ if (Te)
508
+ return async (t, i) => {
509
+ const l = ge.current, p = l ? await l(t, i) : [];
510
+ return i.signal.aborted || He((M) => {
511
+ const Y = new Map(M);
512
+ for (const le of p) Y.set(le.id, le);
513
+ return Y;
514
+ }), p.map((M) => ({ id: M.id, name: at(M) }));
515
+ };
516
+ }, [Te]), ce = T.patientId, we = ce ? (n == null ? void 0 : n.find((t) => t.id === ce)) ?? z.get(ce) : void 0, P = A(
517
+ (t) => {
518
+ q.current = t, f(t), K(
519
+ (i) => Object.keys(i).length === 0 ? i : wr(
520
+ i,
521
+ kt(t, {
522
+ treatmentOptions: h,
523
+ treatmentOptionsPatientId: u,
524
+ maxPacksFor: oe
525
+ })
526
+ )
527
+ );
528
+ },
529
+ [f, h, u, oe]
530
+ ), Qe = A(
531
+ (t) => {
532
+ const i = q.current;
533
+ t !== i.patientId && (K({}), ue(!1), P({
534
+ patientId: t,
535
+ prescriberId: i.prescriberId,
536
+ treatmentId: "",
537
+ items: [{ ...je }]
538
+ }), E == null || E(t));
539
+ },
540
+ [P, E]
541
+ ), pt = w(!1), Ye = A(
542
+ (t) => {
543
+ pt.current = !0, P({ ...q.current, prescriberId: t });
544
+ },
545
+ [P]
546
+ ), ut = w(!1);
547
+ qe(() => {
548
+ if (ut.current || pt.current || !b || !k.some((i) => i.id === b))
549
+ return;
550
+ ut.current = !0;
551
+ const t = q.current;
552
+ t.prescriberId === "" && P({ ...t, prescriberId: b });
553
+ }, [b, k, P]);
554
+ const Ue = A(
555
+ (t) => P({ ...q.current, treatmentId: t }),
556
+ [P]
557
+ ), te = A(
558
+ (t, i) => {
559
+ const l = q.current;
560
+ t < 0 || t >= l.items.length || P({
561
+ ...l,
562
+ items: l.items.map((p, M) => {
563
+ if (M !== t) return p;
564
+ const Y = i.medicationId !== void 0 && i.medicationId !== p.medicationId;
565
+ return {
566
+ ...p,
567
+ ...Y ? { notSubstitutable: !1 } : {},
568
+ ...i
569
+ };
570
+ })
571
+ });
572
+ },
573
+ [P]
574
+ ), Xe = A(
575
+ (t) => {
576
+ const i = q.current;
577
+ return P({
578
+ ...i,
579
+ items: [...i.items, { ...je, ...t }]
580
+ }), i.items.length;
581
+ },
582
+ [P]
583
+ ), Je = A(
584
+ (t) => {
585
+ const i = q.current;
586
+ i.items.length <= 1 || t < 0 || t >= i.items.length || P({
587
+ ...i,
588
+ items: i.items.filter((l, p) => p !== t)
589
+ });
590
+ },
591
+ [P]
592
+ ), mt = w(null), Ze = w(/* @__PURE__ */ new Map()), et = w(/* @__PURE__ */ new Map()), [ye, Ce] = U(null);
593
+ qe(() => {
594
+ var t, i, l, p;
595
+ ye && (ye.kind === "medication" ? (t = Ze.current.get(ye.index)) == null || t.focus() : ye.kind === "dosage" ? (i = et.current.get(ye.index)) == null || i.focus() : (p = (l = document.getElementById(`${v}-items`)) == null ? void 0 : l.querySelector(":scope > button")) == null || p.focus(), Ce(null));
596
+ }, [ye, v]);
597
+ const At = (t) => {
598
+ const i = q.current.items.length;
599
+ Je(t), !(i <= 1) && Ce(
600
+ i - 1 === 1 ? { kind: "add" } : { kind: "medication", index: Math.min(t, i - 2) }
601
+ );
602
+ }, ft = (t) => {
603
+ var i;
604
+ return o("prescription.composer.errors.quantityMax", {
605
+ max: oe(((i = T.items[t]) == null ? void 0 : i.medicationId) ?? "")
606
+ });
607
+ }, re = (t) => {
608
+ var M;
609
+ if (t === "patient")
610
+ return R.patientId ? o("prescription.composer.errors.patient") : void 0;
611
+ if (t === "prescriber")
612
+ return R.prescriberId ? o("prescription.composer.errors.prescriber") : void 0;
613
+ if (t === "treatment")
614
+ return R.treatmentId ? R.treatmentId === "invalid" ? o("prescription.composer.errors.treatmentInvalid") : o("prescription.composer.errors.treatment") : void 0;
615
+ if (t === "items")
616
+ return R.items ? o("prescription.composer.errors.items") : void 0;
617
+ const [i, l] = t.split(":"), p = (M = R.itemErrors) == null ? void 0 : M[Number(l)];
618
+ return i === "medication" ? p != null && p.medicationId && !R.items ? o("prescription.composer.errors.medication") : void 0 : i === "quantity" ? p != null && p.quantity ? p.quantity === "tooMany" ? ft(Number(l)) : p.quantity === "invalid" ? o("prescription.composer.errors.quantityInvalid") : o("prescription.composer.errors.quantity") : void 0 : p != null && p.dosage ? o("prescription.composer.errors.dosage") : void 0;
619
+ }, Mt = [
620
+ "patient",
621
+ "treatment",
622
+ "prescriber",
623
+ "items",
624
+ ...T.items.flatMap((t, i) => [
625
+ `medication:${i}`,
626
+ `dosage:${i}`,
627
+ `quantity:${i}`
628
+ ])
629
+ ], B = Jt(Mt, re), ht = B.listed.length > 0, Lt = (t) => {
630
+ if (t === "items") return `${v}-medication-0`;
631
+ const [i, l] = t.split(":");
632
+ return l === void 0 ? `${v}-${t}` : `${v}-${i}-${l}`;
633
+ }, Vt = (t) => {
634
+ var p, M, Y, le;
635
+ const [i, l] = t.split(":");
636
+ return i === "medication" ? o("prescription.composer.errors.medicationLine", {
637
+ number: Number(l) + 1
638
+ }) : i === "dosage" ? o("prescription.composer.errors.dosageLine", {
639
+ number: Number(l) + 1
640
+ }) : i === "quantity" ? ((M = (p = R.itemErrors) == null ? void 0 : p[Number(l)]) == null ? void 0 : M.quantity) === "tooMany" ? ft(Number(l)) : ((le = (Y = R.itemErrors) == null ? void 0 : Y[Number(l)]) == null ? void 0 : le.quantity) === "invalid" ? o("prescription.composer.errors.quantityInvalidLine", {
641
+ number: Number(l) + 1
642
+ }) : o("prescription.composer.errors.quantityLine", {
643
+ number: Number(l) + 1
644
+ }) : re(t) ?? "";
645
+ }, Pe = A(
646
+ (t) => {
647
+ K(t), B.open();
648
+ },
649
+ // eslint-disable-next-line react-hooks/exhaustive-deps
650
+ [B.open]
651
+ ), Ae = A(
652
+ () => kt(q.current, {
653
+ treatmentOptions: h,
654
+ treatmentOptionsPatientId: u,
655
+ maxPacksFor: oe
656
+ }),
657
+ [h, u, oe]
658
+ ), bt = w(D);
659
+ Ee(() => {
660
+ bt.current = D;
661
+ });
662
+ const tt = A(async () => {
663
+ if (W.current) return;
664
+ const t = Ae();
665
+ if (!xt(t)) {
666
+ Pe(t);
667
+ return;
668
+ }
669
+ K({}), ue(!1), W.current = !0, Se(!0);
670
+ try {
671
+ return await bt.current(
672
+ Dr(q.current)
673
+ ) ?? void 0;
674
+ } catch {
675
+ ae.current && ue(!0);
676
+ return;
677
+ } finally {
678
+ W.current = !1, ae.current && Se(!1);
679
+ }
680
+ }, [Ae, Pe]), gt = A(() => {
681
+ const t = q.current;
682
+ K({}), ue(!1), P(Tt(S)), t.patientId !== S.patientId && (E == null || E(S.patientId));
683
+ }, [P, S, E]);
684
+ Et(
685
+ ee,
686
+ () => ({
687
+ getDraft: () => q.current,
688
+ setPatient: Qe,
689
+ setPrescriber: Ye,
690
+ setTreatment: Ue,
691
+ addItem: Xe,
692
+ updateItem: te,
693
+ removeItem: Je,
694
+ validate: () => {
695
+ const t = Ae();
696
+ return xt(t) ? K({}) : Pe(t), t;
697
+ },
698
+ submit: tt,
699
+ reset: gt,
700
+ focusTitle: () => {
701
+ var t;
702
+ return (t = mt.current) == null ? void 0 : t.focus();
703
+ }
704
+ }),
705
+ [
706
+ Qe,
707
+ Ye,
708
+ Ue,
709
+ Xe,
710
+ te,
711
+ Je,
712
+ Ae,
713
+ Pe,
714
+ tt,
715
+ gt
716
+ ]
717
+ );
718
+ const Me = ne ?? (Ne ? o("prescription.composer.errors.submit") : void 0), Dt = Zt(Me, ht), Ft = m && we !== void 0, yt = `${v}-message`, [Rt, zt] = U("");
719
+ qe(() => {
720
+ zt(G ? o("prescription.composer.loading") : "");
721
+ }, [G, o]);
722
+ const Bt = {
723
+ ...Z,
724
+ "data-component": "prescription-composer",
725
+ "data-component-id": F,
726
+ "data-has-patient": ce !== "" ? !0 : void 0,
727
+ "data-submitting": me ? !0 : void 0
728
+ }, _t = Fr({ className: V }), jt = (n ?? []).map((t) => ({
729
+ id: t.id,
730
+ name: at(t)
731
+ })), Gt = !O && we ? at(we) : void 0, rt = u !== void 0 && u !== ce, Le = rt ? [] : h ?? [], $e = [];
732
+ for (const t of Le)
733
+ t.carePlan && !$e.some((i) => {
734
+ var l;
735
+ return i.id === ((l = t.carePlan) == null ? void 0 : l.id);
736
+ }) && $e.push(t.carePlan);
737
+ const Ot = (t) => {
738
+ const i = $e.filter((p) => p.label === t.label), l = i.length > 1 ? `${t.label} (${i.findIndex((p) => p.id === t.id) + 1})` : t.label;
739
+ return o("prescription.composer.carePlanGroup", {
740
+ label: `⁨${l}⁩`
741
+ });
742
+ }, it = (t, i) => ({
743
+ value: t.id,
744
+ label: t.label,
745
+ group: i,
746
+ dir: "auto"
747
+ }), vt = $e.length === 0 ? Le.map((t) => it(t, void 0)) : [
748
+ ...$e.flatMap(
749
+ (t) => Le.filter((i) => {
750
+ var l;
751
+ return ((l = i.carePlan) == null ? void 0 : l.id) === t.id;
752
+ }).map((i) => it(i, Ot(t)))
753
+ ),
754
+ ...Le.filter((t) => !t.carePlan).map(
755
+ (t) => it(
756
+ t,
757
+ o("prescription.composer.treatmentsStandalone")
758
+ )
759
+ )
760
+ ], Ht = k.map((t) => ({
761
+ value: t.id,
762
+ label: t.name,
763
+ description: t.specialty,
764
+ dir: "auto"
765
+ })), Kt = (t) => {
766
+ t.preventDefault(), tt();
767
+ }, It = Me ? /* @__PURE__ */ r(he, { id: yt, variant: "error", announce: Dt, children: /* @__PURE__ */ r(he.Description, { children: Me }) }) : null;
768
+ return /* @__PURE__ */ y("div", { ...Bt, className: _t, children: [
769
+ /* @__PURE__ */ r("div", { role: "status", className: "ds:sr-only", children: Rt }),
770
+ G ? /* @__PURE__ */ y(
771
+ "div",
772
+ {
773
+ "aria-hidden": "true",
774
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
775
+ children: [
776
+ /* @__PURE__ */ r(Ve, { variant: "rounded", size: "sm" }),
777
+ /* @__PURE__ */ r(Ve, { variant: "text", lines: 3 }),
778
+ /* @__PURE__ */ r(Ve, { variant: "rounded", size: "sm" }),
779
+ /* @__PURE__ */ r(Ve, { variant: "rounded", size: "lg" })
780
+ ]
781
+ }
782
+ ) : /* @__PURE__ */ y(
783
+ "form",
784
+ {
785
+ noValidate: !0,
786
+ onSubmit: Kt,
787
+ "aria-labelledby": `${v}-title`,
788
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
789
+ children: [
790
+ /* @__PURE__ */ r(
791
+ "h2",
792
+ {
793
+ ref: mt,
794
+ id: `${v}-title`,
795
+ tabIndex: -1,
796
+ className: "type-title-section ds:m-0 ds:focus:outline-none",
797
+ children: o("prescription.composer.title")
798
+ }
799
+ ),
800
+ ht ? /* @__PURE__ */ r(
801
+ Qt,
802
+ {
803
+ ref: B.ref,
804
+ title: o("prescription.composer.errorTitle"),
805
+ headingLevel: 3,
806
+ "aria-describedby": Me ? yt : void 0,
807
+ errors: B.listed.map((t) => ({
808
+ field: t,
809
+ message: Vt(t),
810
+ targetId: Lt(t)
811
+ }))
812
+ }
813
+ ) : null,
814
+ Ft ? null : /* @__PURE__ */ r(
815
+ pe,
816
+ {
817
+ id: `${v}-patient`,
818
+ label: o("prescription.composer.patient"),
819
+ required: !0,
820
+ description: O && ce !== "" ? o("calendarWorkspace.privacy.hidden") : void 0,
821
+ error: re("patient"),
822
+ announceError: !B.lists("patient"),
823
+ children: /* @__PURE__ */ r(
824
+ Ut,
825
+ {
826
+ value: ce,
827
+ onValueChange: Qe,
828
+ patients: jt,
829
+ searchPatients: We,
830
+ selectedLabel: Gt,
831
+ privacyMask: O ? ct() : void 0,
832
+ placeholder: o("prescription.composer.patientPlaceholder")
833
+ }
834
+ )
835
+ }
836
+ ),
837
+ ce === "" ? /* @__PURE__ */ y(Be, { children: [
838
+ /* @__PURE__ */ r(
839
+ Wt,
840
+ {
841
+ variant: "first-use",
842
+ size: "sm",
843
+ title: o("prescription.composer.choosePatientTitle"),
844
+ description: o("prescription.composer.choosePatientBody")
845
+ }
846
+ ),
847
+ It
848
+ ] }) : /* @__PURE__ */ y(Be, { children: [
849
+ we ? /* @__PURE__ */ r(
850
+ dt,
851
+ {
852
+ patient: we,
853
+ privacyMode: O,
854
+ showAvatar: !0
855
+ }
856
+ ) : null,
857
+ /* @__PURE__ */ r(
858
+ pe,
859
+ {
860
+ id: `${v}-treatment`,
861
+ label: o("prescription.composer.treatment"),
862
+ required: !0,
863
+ description: vt.length === 0 && !rt ? o("prescription.composer.treatmentEmpty") : void 0,
864
+ error: re("treatment"),
865
+ announceError: !B.lists("treatment"),
866
+ children: /* @__PURE__ */ r(
867
+ Nt,
868
+ {
869
+ options: vt,
870
+ value: T.treatmentId,
871
+ onValueChange: Ue,
872
+ id: `${v}-treatment-select`,
873
+ disabled: rt,
874
+ placeholder: o("prescription.composer.treatmentPlaceholder")
875
+ }
876
+ )
877
+ }
878
+ ),
879
+ /* @__PURE__ */ r(
880
+ pe,
881
+ {
882
+ id: `${v}-prescriber`,
883
+ label: o("prescription.composer.prescriber"),
884
+ required: !0,
885
+ error: re("prescriber"),
886
+ announceError: !B.lists("prescriber"),
887
+ children: /* @__PURE__ */ r(
888
+ Nt,
889
+ {
890
+ options: Ht,
891
+ value: T.prescriberId,
892
+ onValueChange: Ye,
893
+ id: `${v}-prescriber-select`,
894
+ placeholder: o("prescription.composer.prescriberPlaceholder"),
895
+ showDescriptions: !0
896
+ }
897
+ )
898
+ }
899
+ ),
900
+ /* @__PURE__ */ r(
901
+ Yt,
902
+ {
903
+ id: `${v}-items`,
904
+ className: "ds:gap-[var(--spacing-lg)] ds:[&>legend]:[--type-label-size:var(--type-title-item-size)] ds:[&>legend]:[--type-label-weight:var(--type-title-item-weight)] ds:[&>legend]:[--type-label-line-height:var(--type-title-item-line-height)]",
905
+ legend: o("prescription.composer.medications"),
906
+ items: T.items,
907
+ min: 1,
908
+ addLabel: o("prescription.composer.addMedication"),
909
+ removeItemLabel: (t) => o("prescription.composer.removeMedication", {
910
+ number: t + 1
911
+ }),
912
+ onAdd: () => {
913
+ const t = Xe();
914
+ Ce({ kind: "medication", index: t });
915
+ },
916
+ onRemove: At,
917
+ renderItem: (t, i) => {
918
+ const l = t.medicationId ? Ke.get(t.medicationId) ?? (N == null ? void 0 : N(t.medicationId)) ?? null : null, p = `medication:${i}`, M = `dosage:${i}`, Y = `quantity:${i}`, le = i === 0 ? re("items") : void 0;
919
+ return /* @__PURE__ */ r(
920
+ qr,
921
+ {
922
+ index: i,
923
+ item: t,
924
+ medication: l,
925
+ medicationFieldId: `${v}-medication-${i}`,
926
+ dosageFieldId: `${v}-dosage-${i}`,
927
+ quantityFieldId: `${v}-quantity-${i}`,
928
+ medicationError: le ?? re(p),
929
+ dosageError: re(M),
930
+ quantityError: re(Y),
931
+ announceMedicationError: !B.lists(le ? "items" : p),
932
+ announceDosageError: !B.lists(M),
933
+ announceQuantityError: !B.lists(Y),
934
+ searchMedications: be,
935
+ codeLabel: x,
936
+ catalogueStatus: j,
937
+ onCatalogueRetry: L,
938
+ suggestions: l && C ? C(l) : [],
939
+ onMedicationChange: (I) => {
940
+ I && xe([I]);
941
+ const st = I == null ? void 0 : I.maxPacks;
942
+ te(i, {
943
+ medicationId: (I == null ? void 0 : I.id) ?? "",
944
+ ...st !== void 0 && t.quantity > st ? { quantity: st } : {}
945
+ });
946
+ },
947
+ onDosageChange: (I) => te(i, { dosage: I }),
948
+ onNotesChange: (I) => te(i, { notes: I }),
949
+ onQuantityChange: (I) => te(i, { quantity: I }),
950
+ onDurationChange: (I) => te(i, { duration: I }),
951
+ onNotSubstitutableChange: (I) => te(i, { notSubstitutable: I }),
952
+ medicationSearchId: `${v}-medication-${i}-search`,
953
+ medicationRef: (I) => {
954
+ I ? Ze.current.set(i, I) : Ze.current.delete(i);
955
+ },
956
+ dosageInputRef: (I) => {
957
+ I ? et.current.set(i, I) : et.current.delete(i);
958
+ },
959
+ onSuggestionChosen: (I) => {
960
+ te(i, { dosage: I }), Ce({ kind: "dosage", index: i });
961
+ }
962
+ }
963
+ );
964
+ }
965
+ }
966
+ ),
967
+ It,
968
+ /* @__PURE__ */ r(
969
+ Re,
970
+ {
971
+ type: "submit",
972
+ loading: me,
973
+ className: "ds:self-start ds:min-h-[var(--min-target-size)]",
974
+ children: $ ?? o("prescription.composer.save")
975
+ }
976
+ )
977
+ ] })
978
+ ]
979
+ }
980
+ )
981
+ ] });
982
+ });
983
+ Rr.displayName = "PrescriptionComposer";
984
+ const zr = {
985
+ sent: "success",
986
+ sending: "info",
987
+ failed: "error"
988
+ };
989
+ function Pt({
990
+ status: e
991
+ }) {
992
+ const { t: n } = Ie("ui"), a = e === "sent" ? /* @__PURE__ */ r(Sr, { "aria-hidden": "true" }) : e === "sending" ? /* @__PURE__ */ r(
993
+ kr,
994
+ {
995
+ "aria-hidden": "true",
996
+ className: "ds:animate-spin ds:motion-reduce:animate-none"
997
+ }
998
+ ) : /* @__PURE__ */ r(xr, { "aria-hidden": "true" });
999
+ return /* @__PURE__ */ r(Nr, { size: "sm", variant: zr[e], leading: a, children: n(e === "sent" ? "prescription.status.sent" : e === "sending" ? "prescription.status.sending" : "prescription.status.failed") });
1000
+ }
1001
+ const Br = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]"), _r = _("ds:flex ds:flex-col", {
1002
+ variants: {
1003
+ density: {
1004
+ default: "ds:gap-[var(--spacing-lg)]",
1005
+ compact: "ds:gap-[var(--spacing-md)]"
1006
+ }
1007
+ },
1008
+ defaultVariants: { density: "default" }
1009
+ });
1010
+ function jr(e) {
1011
+ if (typeof globalThis.reportError == "function") {
1012
+ globalThis.reportError(e);
1013
+ return;
1014
+ }
1015
+ setTimeout(() => {
1016
+ throw e;
1017
+ }, 0);
1018
+ }
1019
+ function Gr({
1020
+ label: e,
1021
+ items: n,
1022
+ blocked: a,
1023
+ describedBy: h,
1024
+ ...u
1025
+ }) {
1026
+ const [k, b] = U(!1);
1027
+ return /* @__PURE__ */ y(
1028
+ De.Root,
1029
+ {
1030
+ open: k && !a,
1031
+ onOpenChange: (c) => b(c && !a),
1032
+ children: [
1033
+ /* @__PURE__ */ r(De.Trigger, { asChild: !0, children: /* @__PURE__ */ r(
1034
+ ar,
1035
+ {
1036
+ ...u,
1037
+ icon: /* @__PURE__ */ r(br, { "aria-hidden": "true" }),
1038
+ "aria-label": e,
1039
+ "aria-haspopup": "menu",
1040
+ "aria-disabled": a || void 0,
1041
+ "aria-describedby": h,
1042
+ "data-action": "moreActions",
1043
+ className: "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]"
1044
+ }
1045
+ ) }),
1046
+ /* @__PURE__ */ r(De.Content, { align: "end", children: n.map((c) => /* @__PURE__ */ r(
1047
+ De.Item,
1048
+ {
1049
+ startIcon: c.icon,
1050
+ "data-action": c.action,
1051
+ "aria-busy": c.busy || void 0,
1052
+ onSelect: () => {
1053
+ c.busy || c.run();
1054
+ },
1055
+ children: c.label
1056
+ },
1057
+ c.action
1058
+ )) })
1059
+ ]
1060
+ }
1061
+ );
1062
+ }
1063
+ function Or(e) {
1064
+ return typeof e == "object" && e !== null && typeof e.then == "function";
1065
+ }
1066
+ const Hr = Ge(
1067
+ ({
1068
+ record: e,
1069
+ practiceHeader: n,
1070
+ size: a = "a4",
1071
+ density: h = "default",
1072
+ codeLabel: u,
1073
+ privacyMode: k = !1,
1074
+ isolateBrowserPrint: b = !1,
1075
+ numberLabel: c,
1076
+ pinLabel: N,
1077
+ printMode: C,
1078
+ onPrint: x,
1079
+ onDownloadPdf: j,
1080
+ onSendEmail: L,
1081
+ onSendSms: se,
1082
+ onSendWhatsApp: d,
1083
+ onResend: J,
1084
+ onEdit: D,
1085
+ id: E,
1086
+ className: G,
1087
+ ...ne
1088
+ }, O) => {
1089
+ const { t: m, i18n: $ } = Ie("ui"), F = Oe($.language), V = w(null), Z = ve(), ee = ve(), o = ve(), H = ve(), v = ve(), S = e.sendStatus, s = S === "sending" || S === "failed", T = (C ?? (S ? "host" : "sheet")) === "host", q = w(() => {
1090
+ }), R = w(T);
1091
+ R.current = T;
1092
+ const K = w(s);
1093
+ K.current = s;
1094
+ const Ne = w(e);
1095
+ Ne.current = e;
1096
+ const ue = _e(
1097
+ () => ({
1098
+ print: () => {
1099
+ var g;
1100
+ K.current || (R.current ? q.current() : (g = V.current) == null || g.print());
1101
+ },
1102
+ getRecordId: () => Ne.current.id,
1103
+ focusTitle: () => {
1104
+ var g;
1105
+ return (g = V.current) == null ? void 0 : g.focusTitle();
1106
+ }
1107
+ }),
1108
+ []
1109
+ );
1110
+ Et(O, () => ue, [ue]);
1111
+ const [me, Se] = U(() => /* @__PURE__ */ new Set()), W = w(/* @__PURE__ */ new Set()), ae = w(!0);
1112
+ qe(() => (ae.current = !0, () => {
1113
+ ae.current = !1;
1114
+ }), []);
1115
+ const z = A(
1116
+ (g, be) => {
1117
+ if (!be || W.current.has(g) || K.current && g !== "resend" && g !== "edit")
1118
+ return;
1119
+ let ge;
1120
+ try {
1121
+ ge = be(Ne.current);
1122
+ } catch (We) {
1123
+ jr(We);
1124
+ return;
1125
+ }
1126
+ if (!Or(ge)) return;
1127
+ W.current.add(g), Se(new Set(W.current));
1128
+ const Te = () => {
1129
+ W.current.delete(g), ae.current && Se(new Set(W.current));
1130
+ };
1131
+ ge.then(Te, Te);
1132
+ },
1133
+ []
1134
+ ), He = A(() => {
1135
+ var g;
1136
+ W.current.has("print") || (T || (g = V.current) == null || g.print(), z("print", x));
1137
+ }, [z, x, T]);
1138
+ q.current = () => z("print", x);
1139
+ const Ke = [
1140
+ x && {
1141
+ action: "print",
1142
+ label: m("prescription.sheet.print"),
1143
+ icon: /* @__PURE__ */ r(Ct, { "aria-hidden": "true" }),
1144
+ run: He
1145
+ },
1146
+ j && {
1147
+ action: "downloadPdf",
1148
+ label: m("prescription.sheet.downloadPdf"),
1149
+ icon: /* @__PURE__ */ r(mr, { "aria-hidden": "true" }),
1150
+ run: () => z("downloadPdf", j)
1151
+ },
1152
+ L && {
1153
+ action: "sendEmail",
1154
+ label: m("prescription.sheet.sendEmail"),
1155
+ icon: /* @__PURE__ */ r(fr, { "aria-hidden": "true" }),
1156
+ run: () => z("sendEmail", L)
1157
+ },
1158
+ se && {
1159
+ action: "sendSms",
1160
+ label: m("prescription.sheet.sendSms"),
1161
+ icon: /* @__PURE__ */ r(hr, { "aria-hidden": "true" }),
1162
+ run: () => z("sendSms", se)
1163
+ },
1164
+ d && {
1165
+ action: "sendWhatsApp",
1166
+ label: m("prescription.sheet.sendWhatsApp"),
1167
+ icon: /* @__PURE__ */ r(ur, {}),
1168
+ run: () => z("sendWhatsApp", d)
1169
+ }
1170
+ ].filter((g) => !!g), [Q, ...ke] = Ke, fe = Q ? /* @__PURE__ */ r(
1171
+ Re,
1172
+ {
1173
+ type: "button",
1174
+ intent: "outline",
1175
+ startIcon: Q.icon,
1176
+ loading: me.has(Q.action),
1177
+ "aria-disabled": s || void 0,
1178
+ "aria-describedby": [
1179
+ s ? H : void 0,
1180
+ T && Q.action === "print" ? v : void 0
1181
+ ].filter(Boolean).join(" ") || void 0,
1182
+ onClick: s ? void 0 : Q.run,
1183
+ "data-action": Q.action,
1184
+ className: "ds:min-h-[var(--min-target-size)]",
1185
+ children: Q.label
1186
+ }
1187
+ ) : null, oe = Q && ke.length > 0 ? /* @__PURE__ */ y(or, { label: m("prescription.sheet.shareActions"), children: [
1188
+ fe,
1189
+ /* @__PURE__ */ r(
1190
+ Gr,
1191
+ {
1192
+ blocked: s,
1193
+ describedBy: s ? H : void 0,
1194
+ label: m("prescription.sheet.moreActions"),
1195
+ items: ke.map((g) => ({
1196
+ ...g,
1197
+ busy: me.has(g.action)
1198
+ }))
1199
+ }
1200
+ )
1201
+ ] }) : fe, xe = oe !== null;
1202
+ return /* @__PURE__ */ y(
1203
+ "div",
1204
+ {
1205
+ ...ne,
1206
+ id: E,
1207
+ className: Br({ className: G }),
1208
+ "data-component": "prescription-sheet",
1209
+ "data-component-id": E,
1210
+ "data-prescription-id": e.id,
1211
+ children: [
1212
+ S ? /* @__PURE__ */ r(
1213
+ "div",
1214
+ {
1215
+ id: H,
1216
+ "data-slot": "send-status",
1217
+ "data-send-status": S,
1218
+ className: "ds:mx-auto ds:flex ds:w-full ds:max-w-3xl ds:justify-center ds:print:hidden",
1219
+ children: S === "sent" ? /* @__PURE__ */ y("p", { className: "ds:m-0 ds:flex ds:flex-wrap ds:items-center ds:justify-center ds:gap-[var(--spacing-sm)] type-body-sm", children: [
1220
+ /* @__PURE__ */ r(Pt, { status: "sent" }),
1221
+ e.sentAt ? /* @__PURE__ */ y("span", { children: [
1222
+ m("prescription.sheet.sentAt"),
1223
+ " ",
1224
+ /* @__PURE__ */ r(
1225
+ nr,
1226
+ {
1227
+ locale: F,
1228
+ value: e.sentAt,
1229
+ format: "absolute",
1230
+ shape: "bare",
1231
+ absoluteFormat: {
1232
+ dateStyle: "medium",
1233
+ timeStyle: "short"
1234
+ }
1235
+ }
1236
+ )
1237
+ ] }) : null
1238
+ ] }) : S === "sending" ? /* @__PURE__ */ r(he, { variant: "info", announce: "polite", className: "ds:w-full", children: /* @__PURE__ */ r(he.Title, { as: "p", children: m("prescription.sheet.sendingTitle") }) }) : /* @__PURE__ */ y(he, { variant: "error", className: "ds:w-full", children: [
1239
+ /* @__PURE__ */ r(he.Title, { as: "p", children: m("prescription.sheet.sendFailedTitle") }),
1240
+ /* @__PURE__ */ r(he.Description, { children: e.sendError ?? m("prescription.sheet.sendFailedBody") }),
1241
+ J || D ? /* @__PURE__ */ y(
1242
+ "div",
1243
+ {
1244
+ "data-slot": "failed-actions",
1245
+ className: "ds:mt-[var(--spacing-sm)] ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
1246
+ children: [
1247
+ J ? /* @__PURE__ */ r(
1248
+ Re,
1249
+ {
1250
+ type: "button",
1251
+ intent: "primary",
1252
+ loading: me.has("resend"),
1253
+ onClick: () => z("resend", J),
1254
+ "data-action": "resend",
1255
+ className: "ds:min-h-[var(--min-target-size)]",
1256
+ children: m("prescription.sheet.resend")
1257
+ }
1258
+ ) : null,
1259
+ D ? /* @__PURE__ */ r(
1260
+ Re,
1261
+ {
1262
+ type: "button",
1263
+ intent: "secondary",
1264
+ loading: me.has("edit"),
1265
+ onClick: () => z("edit", D),
1266
+ "data-action": "edit",
1267
+ className: "ds:min-h-[var(--min-target-size)]",
1268
+ children: m("prescription.sheet.edit")
1269
+ }
1270
+ ) : null
1271
+ ]
1272
+ }
1273
+ ) : null
1274
+ ] })
1275
+ }
1276
+ ) : null,
1277
+ xe ? /* @__PURE__ */ r(
1278
+ "div",
1279
+ {
1280
+ role: "group",
1281
+ "aria-label": m("prescription.sheet.actions"),
1282
+ "data-slot": "actions",
1283
+ className: "ds:flex ds:flex-wrap ds:items-center ds:justify-center ds:gap-[var(--spacing-sm)] ds:print:hidden",
1284
+ children: oe
1285
+ }
1286
+ ) : null,
1287
+ T ? (
1288
+ /* Not print:hidden: when the page itself is printed (Ctrl or Cmd+P),
1289
+ the summary prints with its note, right above the sheet. */
1290
+ /* @__PURE__ */ r(
1291
+ "p",
1292
+ {
1293
+ id: v,
1294
+ "data-slot": "summary-note",
1295
+ className: "ds:m-0 ds:text-center type-body-sm ds:text-[color:var(--muted-foreground)]",
1296
+ children: m("prescription.sheet.summaryNote")
1297
+ }
1298
+ )
1299
+ ) : null,
1300
+ /* @__PURE__ */ r(
1301
+ pr,
1302
+ {
1303
+ ref: V,
1304
+ registerAgent: !1,
1305
+ id: E ? `${E}-sheet` : void 0,
1306
+ size: a,
1307
+ density: h,
1308
+ isolateBrowserPrint: T ? !1 : b,
1309
+ header: n,
1310
+ title: m("prescription.sheet.title"),
1311
+ date: e.createdAt,
1312
+ signature: {
1313
+ name: e.prescriber.name,
1314
+ detail: e.prescriber.specialty
1315
+ },
1316
+ children: /* @__PURE__ */ y("div", { className: _r({ density: h }), children: [
1317
+ /* @__PURE__ */ y(St, { children: [
1318
+ e.number ? /* @__PURE__ */ r(
1319
+ ie,
1320
+ {
1321
+ label: c ?? m("prescription.sheet.number"),
1322
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.number }),
1323
+ mono: !0,
1324
+ "data-field": "number"
1325
+ }
1326
+ ) : null,
1327
+ e.pin ? /* @__PURE__ */ r(
1328
+ ie,
1329
+ {
1330
+ label: N ?? m("prescription.sheet.pin"),
1331
+ value: k ? /* @__PURE__ */ y(Be, { children: [
1332
+ /* @__PURE__ */ r(lt, { children: m("calendarWorkspace.privacy.hidden") }),
1333
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: ct() })
1334
+ ] }) : /* @__PURE__ */ r("span", { dir: "ltr", children: e.pin }),
1335
+ mono: !0,
1336
+ "data-field": "pin"
1337
+ }
1338
+ ) : null,
1339
+ /* @__PURE__ */ r(
1340
+ ie,
1341
+ {
1342
+ label: m("prescription.sheet.treatment"),
1343
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.treatment.label }),
1344
+ "data-field": "treatment"
1345
+ }
1346
+ ),
1347
+ e.treatment.carePlan ? /* @__PURE__ */ r(
1348
+ ie,
1349
+ {
1350
+ label: m("prescription.sheet.carePlan"),
1351
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.treatment.carePlan.label }),
1352
+ "data-field": "carePlan"
1353
+ }
1354
+ ) : null
1355
+ ] }),
1356
+ /* @__PURE__ */ y(
1357
+ "section",
1358
+ {
1359
+ "aria-labelledby": Z,
1360
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1361
+ children: [
1362
+ /* @__PURE__ */ r(
1363
+ "h3",
1364
+ {
1365
+ id: Z,
1366
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1367
+ children: m("prescription.sheet.patient")
1368
+ }
1369
+ ),
1370
+ /* @__PURE__ */ r(
1371
+ dt,
1372
+ {
1373
+ patient: e.patient,
1374
+ privacyMode: k,
1375
+ density: h
1376
+ }
1377
+ )
1378
+ ]
1379
+ }
1380
+ ),
1381
+ /* @__PURE__ */ y(
1382
+ "section",
1383
+ {
1384
+ "aria-labelledby": ee,
1385
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1386
+ children: [
1387
+ /* @__PURE__ */ r(
1388
+ "h3",
1389
+ {
1390
+ id: ee,
1391
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1392
+ children: m("prescription.sheet.medications")
1393
+ }
1394
+ ),
1395
+ /* @__PURE__ */ r(
1396
+ lr,
1397
+ {
1398
+ density: h,
1399
+ "aria-labelledby": ee,
1400
+ children: e.items.map((g, be) => /* @__PURE__ */ r(
1401
+ dr,
1402
+ {
1403
+ as: "li",
1404
+ medication: g.medication,
1405
+ dosage: g.dosage,
1406
+ notes: g.notes,
1407
+ quantity: g.quantity,
1408
+ duration: g.duration,
1409
+ notSubstitutable: g.notSubstitutable,
1410
+ codeLabel: u
1411
+ },
1412
+ `${g.medication.id}-${be}`
1413
+ ))
1414
+ }
1415
+ )
1416
+ ]
1417
+ }
1418
+ ),
1419
+ /* @__PURE__ */ y(
1420
+ "section",
1421
+ {
1422
+ "aria-labelledby": o,
1423
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1424
+ children: [
1425
+ /* @__PURE__ */ r(
1426
+ "h3",
1427
+ {
1428
+ id: o,
1429
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1430
+ children: m("prescription.sheet.prescriber")
1431
+ }
1432
+ ),
1433
+ /* @__PURE__ */ y(St, { children: [
1434
+ /* @__PURE__ */ r(
1435
+ ie,
1436
+ {
1437
+ label: m("prescription.sheet.prescriberName"),
1438
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.prescriber.name }),
1439
+ "data-field": "prescriber"
1440
+ }
1441
+ ),
1442
+ e.prescriber.specialty ? /* @__PURE__ */ r(
1443
+ ie,
1444
+ {
1445
+ label: m("prescription.history.specialty"),
1446
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.prescriber.specialty }),
1447
+ "data-field": "specialty"
1448
+ }
1449
+ ) : null,
1450
+ e.prescriber.fiscalCode ? /* @__PURE__ */ r(
1451
+ ie,
1452
+ {
1453
+ label: m("prescription.sheet.prescriberFiscalCode"),
1454
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.prescriber.fiscalCode }),
1455
+ mono: !0,
1456
+ "data-field": "prescriberFiscalCode"
1457
+ }
1458
+ ) : null,
1459
+ e.prescriber.registrationNumber ? /* @__PURE__ */ r(
1460
+ ie,
1461
+ {
1462
+ label: m("prescription.sheet.registrationNumber"),
1463
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.prescriber.registrationNumber }),
1464
+ mono: !0,
1465
+ "data-field": "registrationNumber"
1466
+ }
1467
+ ) : null
1468
+ ] })
1469
+ ]
1470
+ }
1471
+ )
1472
+ ] })
1473
+ }
1474
+ )
1475
+ ]
1476
+ }
1477
+ );
1478
+ }
1479
+ );
1480
+ Hr.displayName = "PrescriptionSheet";
1481
+ const Kr = _("ds:block ds:min-w-0 ds:w-full"), Wr = _(
1482
+ "ds:inline-flex ds:min-w-0 ds:items-center ds:gap-[var(--spacing-xs)]"
1483
+ ), ze = _("ds:min-w-0 ds:break-words"), Qr = _("ds:flex ds:flex-wrap ds:gap-[var(--spacing-2xs)]"), Yr = "11rem", Ur = _(
1484
+ "ds:min-w-0 ds:break-words ds:text-[color:var(--muted-foreground)]"
1485
+ ), Xr = _("ds:font-mono ds:tabular-nums"), Jr = [
1486
+ { colId: "date", sort: "desc" }
1487
+ ], Zr = {
1488
+ dateStyle: "medium",
1489
+ timeStyle: "short"
1490
+ };
1491
+ function wt(e, n) {
1492
+ const a = new Date(e.createdAt);
1493
+ return Number.isNaN(a.getTime()) ? e.createdAt : new Intl.DateTimeFormat(Oe(n), Zr).format(
1494
+ a
1495
+ );
1496
+ }
1497
+ function $t({ name: e }) {
1498
+ return /* @__PURE__ */ y("span", { className: Wr(), children: [
1499
+ /* @__PURE__ */ r(
1500
+ qt,
1501
+ {
1502
+ name: e,
1503
+ size: "xs",
1504
+ className: "ds:shrink-0",
1505
+ "aria-hidden": "true",
1506
+ role: "presentation",
1507
+ "aria-label": void 0
1508
+ }
1509
+ ),
1510
+ /* @__PURE__ */ r("span", { dir: "auto", className: ze(), children: e })
1511
+ ] });
1512
+ }
1513
+ const Qi = Ge(function({
1514
+ records: n,
1515
+ status: a = "ready",
1516
+ onOpen: h,
1517
+ onReprint: u,
1518
+ onRetry: k,
1519
+ caption: b,
1520
+ showPatient: c = !1,
1521
+ privacyMode: N = !1,
1522
+ showSendStatus: C,
1523
+ id: x,
1524
+ className: j,
1525
+ ...L
1526
+ }, se) {
1527
+ const { t: d, i18n: J } = Ie("ui"), D = J.language || "en", E = h !== void 0 || u !== void 0, G = C ?? n.some(($) => $.sendStatus !== void 0), ne = _e(() => {
1528
+ const $ = [];
1529
+ return h && $.push({
1530
+ id: "open",
1531
+ icon: /* @__PURE__ */ r(Tr, {}),
1532
+ label: d("prescription.history.open"),
1533
+ onClick: h
1534
+ }), u && $.push({
1535
+ id: "reprint",
1536
+ icon: /* @__PURE__ */ r(Ct, {}),
1537
+ label: d("prescription.history.reprint"),
1538
+ onClick: u
1539
+ }), $;
1540
+ }, [d, h, u]), O = _e(() => {
1541
+ const $ = new Intl.Collator(Oe(D)), F = (s) => wt(s, D), V = (s) => `${s.patient.lastName} ${s.patient.firstName}`.trim(), Z = (s) => d(s === "sent" ? "prescription.status.sent" : s === "sending" ? "prescription.status.sending" : "prescription.status.failed"), ee = /* @__PURE__ */ r("span", { className: Ur(), children: d("prescription.history.noCarePlan") }), o = 3, H = 2, v = c ? 2 : 1, S = [
1542
+ {
1543
+ id: "date",
1544
+ header: d("prescription.history.date"),
1545
+ headerLabel: d("prescription.history.date"),
1546
+ rowHeader: !0,
1547
+ sort: "date",
1548
+ sortDescFirst: !0,
1549
+ value: (s) => new Date(s.createdAt),
1550
+ exportValue: F,
1551
+ filter: { kind: "dateRange" },
1552
+ search: !1,
1553
+ size: 124,
1554
+ wrap: !0,
1555
+ cell: (s) => /* @__PURE__ */ r("time", { dateTime: s.createdAt, children: F(s) })
1556
+ }
1557
+ ];
1558
+ if (G && (S.push({
1559
+ id: "number",
1560
+ header: d("prescription.history.number"),
1561
+ headerLabel: d("prescription.history.number"),
1562
+ responsiveTier: H,
1563
+ sort: "text",
1564
+ value: (s) => s.number ?? null,
1565
+ exportValue: (s) => s.number ?? "",
1566
+ filter: { kind: "text" },
1567
+ size: 124,
1568
+ cell: (s) => s.number ? /* @__PURE__ */ r("span", { dir: "ltr", className: Xr(), children: s.number }) : null
1569
+ }), S.push({
1570
+ id: "status",
1571
+ header: d("prescription.history.status"),
1572
+ headerLabel: d("prescription.history.status"),
1573
+ responsiveTier: v,
1574
+ sort: "text",
1575
+ value: (s) => s.sendStatus ?? null,
1576
+ exportValue: (s) => s.sendStatus ? Z(s.sendStatus) : "",
1577
+ filter: {
1578
+ kind: "select",
1579
+ options: ["sent", "sending", "failed"].map((s) => ({
1580
+ value: s,
1581
+ label: Z(s)
1582
+ }))
1583
+ },
1584
+ search: !1,
1585
+ size: 108,
1586
+ cell: (s) => s.sendStatus ? /* @__PURE__ */ r(Pt, { status: s.sendStatus }) : null
1587
+ })), c && S.push({
1588
+ id: "patient",
1589
+ header: d("prescription.history.patient"),
1590
+ headerLabel: d("prescription.history.patient"),
1591
+ responsiveTier: 1,
1592
+ wrap: !0,
1593
+ privacy: "mask",
1594
+ sort: (s, f) => $.compare(V(s), V(f)),
1595
+ value: V,
1596
+ exportValue: V,
1597
+ filter: { kind: "text" },
1598
+ size: 144,
1599
+ cell: (s) => /* @__PURE__ */ r($t, { name: V(s) })
1600
+ }), S.push(
1601
+ {
1602
+ id: "treatment",
1603
+ header: d("prescription.history.treatment"),
1604
+ headerLabel: d("prescription.history.treatment"),
1605
+ responsiveTier: o,
1606
+ wrap: !0,
1607
+ sort: "text",
1608
+ value: (s) => s.treatment.label,
1609
+ exportValue: (s) => s.treatment.label,
1610
+ filter: { kind: "text" },
1611
+ size: 136,
1612
+ cell: (s) => /* @__PURE__ */ r("span", { dir: "auto", className: ze(), children: s.treatment.label })
1613
+ },
1614
+ {
1615
+ id: "carePlan",
1616
+ header: d("prescription.history.carePlan"),
1617
+ headerLabel: d("prescription.history.carePlan"),
1618
+ responsiveTier: o,
1619
+ wrap: !0,
1620
+ sort: "text",
1621
+ value: (s) => {
1622
+ var f;
1623
+ return ((f = s.treatment.carePlan) == null ? void 0 : f.label) ?? null;
1624
+ },
1625
+ exportValue: (s) => {
1626
+ var f;
1627
+ return ((f = s.treatment.carePlan) == null ? void 0 : f.label) ?? "";
1628
+ },
1629
+ filter: { kind: "select" },
1630
+ size: 128,
1631
+ cell: (s) => s.treatment.carePlan ? /* @__PURE__ */ r("span", { dir: "auto", className: ze(), children: s.treatment.carePlan.label }) : ee
1632
+ },
1633
+ {
1634
+ id: "medications",
1635
+ header: d("prescription.history.medications"),
1636
+ headerLabel: d("prescription.history.medications"),
1637
+ wrap: !0,
1638
+ value: (s) => s.items.map((f) => f.medication.name).join("; "),
1639
+ exportValue: (s) => s.items.map((f) => f.medication.name).join("; "),
1640
+ /* The grid's filters read one scalar per row, so the drug filter is
1641
+ a text "contains" on the names, not a list of drugs. */
1642
+ filter: { kind: "text" },
1643
+ size: 216,
1644
+ cell: (s) => /* @__PURE__ */ r("span", { className: Qr(), children: s.items.map((f, T) => /* @__PURE__ */ r(
1645
+ yr,
1646
+ {
1647
+ label: f.medication.name,
1648
+ size: "sm",
1649
+ variant: "neutral",
1650
+ maxInlineSize: Yr
1651
+ },
1652
+ `${f.medication.id}-${T}`
1653
+ )) })
1654
+ },
1655
+ {
1656
+ id: "prescriber",
1657
+ header: d("prescription.history.prescriber"),
1658
+ headerLabel: d("prescription.history.prescriber"),
1659
+ responsiveTier: c ? o : H,
1660
+ wrap: !0,
1661
+ sort: "text",
1662
+ value: (s) => s.prescriber.name,
1663
+ exportValue: (s) => s.prescriber.name,
1664
+ filter: { kind: "select" },
1665
+ search: !0,
1666
+ size: 136,
1667
+ cell: (s) => /* @__PURE__ */ r($t, { name: s.prescriber.name })
1668
+ },
1669
+ {
1670
+ id: "specialty",
1671
+ header: d("prescription.history.specialty"),
1672
+ headerLabel: d("prescription.history.specialty"),
1673
+ defaultHidden: !0,
1674
+ wrap: !0,
1675
+ sort: "text",
1676
+ value: (s) => s.prescriber.specialty ?? null,
1677
+ exportValue: (s) => s.prescriber.specialty ?? "",
1678
+ filter: { kind: "select" },
1679
+ size: 140,
1680
+ cell: (s) => s.prescriber.specialty ? /* @__PURE__ */ r("span", { dir: "auto", className: ze(), children: s.prescriber.specialty }) : null
1681
+ }
1682
+ ), E) {
1683
+ const s = d("prescription.history.actions");
1684
+ S.push({
1685
+ id: "actions",
1686
+ header: /* @__PURE__ */ r(lt, { children: s }),
1687
+ headerLabel: s,
1688
+ pin: "end",
1689
+ size: 64,
1690
+ hideable: !1,
1691
+ reorderable: !1,
1692
+ pinnable: !1,
1693
+ resizable: !1,
1694
+ exportable: !1,
1695
+ printable: !1,
1696
+ search: !1,
1697
+ /* The kit RowActions leaf, menu only: one "Actions" button per row,
1698
+ named by reference with the row's own name. */
1699
+ cell: (f, T) => /* @__PURE__ */ r(
1700
+ vr,
1701
+ {
1702
+ row: f,
1703
+ actions: ne,
1704
+ maxInline: 0,
1705
+ "aria-labelledby": T.inputLabelledBy
1706
+ }
1707
+ )
1708
+ });
1709
+ }
1710
+ return S;
1711
+ }, [d, D, E, c, G, ne]), m = /* @__PURE__ */ y(de, { children: [
1712
+ /* @__PURE__ */ y(de.FilterBar, { children: [
1713
+ /* @__PURE__ */ r(de.QuickSearch, {}),
1714
+ /* @__PURE__ */ r(de.FilterChips, {})
1715
+ ] }),
1716
+ /* @__PURE__ */ r(de.Actions, { children: /* @__PURE__ */ y(gr, { "aria-label": d("dataTable.tableActions"), children: [
1717
+ /* @__PURE__ */ r(de.ExportMenu, {}),
1718
+ /* @__PURE__ */ r(de.Print, {}),
1719
+ /* @__PURE__ */ r(de.ColumnToggle, {})
1720
+ ] }) })
1721
+ ] });
1722
+ return /* @__PURE__ */ r(
1723
+ "div",
1724
+ {
1725
+ ...L,
1726
+ ref: se,
1727
+ "data-component": "prescription-history",
1728
+ "data-component-id": x,
1729
+ className: Kr({ className: j }),
1730
+ children: /* @__PURE__ */ r(
1731
+ Ir,
1732
+ {
1733
+ columns: O,
1734
+ rows: n,
1735
+ getRowId: ($) => $.id,
1736
+ getRowLabel: ($) => {
1737
+ const F = d("prescription.history.rowLabel", {
1738
+ date: wt($, D)
1739
+ });
1740
+ return c ? `${F}, ${$.patient.lastName} ${$.patient.firstName}` : F;
1741
+ },
1742
+ privacyMode: N,
1743
+ toolbar: m,
1744
+ caption: b ?? d("prescription.history.caption"),
1745
+ defaultSorting: Jr,
1746
+ status: a,
1747
+ gridId: x ? `${x}-grid` : void 0,
1748
+ empty: {
1749
+ title: d("prescription.history.emptyTitle"),
1750
+ description: d("prescription.history.emptyBody")
1751
+ },
1752
+ error: {
1753
+ title: d("prescription.history.errorTitle"),
1754
+ onRetry: k
1755
+ }
1756
+ }
1757
+ )
1758
+ }
1759
+ );
1760
+ });
1761
+ export {
1762
+ je as E,
1763
+ Rr as P,
1764
+ Qi as a,
1765
+ Hr as b,
1766
+ Mr as c,
1767
+ xt as d,
1768
+ ot as i,
1769
+ Dr as n,
1770
+ kt as v
1771
+ };
1772
+ //# sourceMappingURL=prescription-history-CYCg6nxp.js.map