@alfadocs/ui-kit 1.138.0 → 1.139.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 (232) hide show
  1. package/dist/_chunks/{address-fields-DvSWdeR0.js → address-fields-Bh9JZJHZ.js} +4 -4
  2. package/dist/_chunks/{ai-prompt-input-CVNeusoW.js → ai-prompt-input-B2QFwuJ1.js} +2 -2
  3. package/dist/_chunks/{anamnesis-summary-rows-Dr2V1Rtf.js → anamnesis-summary-rows-BgfBnjp0.js} +4 -4
  4. package/dist/_chunks/{audio-recorder-BOF5YYoC.js → audio-recorder-6dUq8I38.js} +2 -2
  5. package/dist/_chunks/autocomplete-HZNW7_Pa.js +642 -0
  6. package/dist/_chunks/{balance-badge-cell-BSB02Bwo.js → balance-badge-cell-CRrIv2hy.js} +4 -4
  7. package/dist/_chunks/{bill-line-table-By-YL2ms.js → bill-line-table-DCqxhode.js} +3 -3
  8. package/dist/_chunks/{bishop-score-DWGESRP9.js → bishop-score-M7Fi-ykx.js} +2 -2
  9. package/dist/_chunks/{calendar-appointment-editor-dialog-SxSkOTnO.js → calendar-appointment-editor-dialog-GdnaPIOV.js} +7 -7
  10. package/dist/_chunks/{calendar-editor-discard-host-DjUhoFr2.js → calendar-editor-discard-host-BcMEgVEq.js} +2 -2
  11. package/dist/_chunks/{calendar-waiting-list-panel-331vzAdl.js → calendar-waiting-list-panel-CkZBAv_E.js} +3 -3
  12. package/dist/_chunks/{calendar.sheets-aodjllWd.js → calendar.sheets-B0jP2Yt0.js} +112 -111
  13. package/dist/_chunks/{calls-panel-BIfatK90.js → calls-panel-CtxJAzkJ.js} +2 -2
  14. package/dist/_chunks/{city-input-DXipzTfZ.js → city-input-DARVDJhH.js} +2 -2
  15. package/dist/_chunks/{combobox-BBCVQS-S.js → combobox-BYl6mY4c.js} +12 -13
  16. package/dist/_chunks/{communications-panel-SQ-55e3V.js → communications-panel-DBWM9II9.js} +2 -2
  17. package/dist/_chunks/{country-select-C2GdvRtS.js → country-select-BPISkYVU.js} +3 -3
  18. package/dist/_chunks/{data-grid-CxKz8flO.js → data-grid-bQ6iFm10.js} +15 -7
  19. package/dist/_chunks/{data-table-_tgj0C_T.js → data-table-CnLfOwxg.js} +2 -2
  20. package/dist/_chunks/{default-tabs-oDWQzbN7.js → default-tabs-Dm_vk6hd.js} +3 -3
  21. package/dist/_chunks/{document-preview-CirR3C_m.js → document-preview-FTCHXYhk.js} +2 -2
  22. package/dist/_chunks/{face-scheme-D_Y1StPl.js → face-scheme-Bxt7ZnJn.js} +2 -2
  23. package/dist/_chunks/{file-manager-CEi4z2i0.js → file-manager-Bsccb8Jj.js} +2 -2
  24. package/dist/_chunks/{forgot-password-form-YvI9vX-G.js → forgot-password-form-B4ufmBFn.js} +5 -4
  25. package/dist/_chunks/{gestational-age-calculator-CHbpC4vL.js → gestational-age-calculator-DXSPWG8u.js} +2 -2
  26. package/dist/_chunks/{heatmap-_546qI2V.js → heatmap-CFPaEKD_.js} +2 -2
  27. package/dist/_chunks/{invoice-upload-list-CQI9MUl6.js → invoice-upload-list-Dz3CXHPP.js} +3 -3
  28. package/dist/_chunks/{kit-extensions-BNBf4m8O.js → kit-extensions-BB_ksnVl.js} +3 -3
  29. package/dist/_chunks/{link-cell-renderer-Xx5T8u5Q.js → link-cell-renderer-CSA0KKPe.js} +5 -5
  30. package/dist/_chunks/{login-dev-card-Dz3ezx1o.js → login-dev-card-oRh9h7N2.js} +18 -17
  31. package/dist/_chunks/medication-I6QvOq6k.js +21 -0
  32. package/dist/_chunks/medication-line-CHdlh-F7.js +222 -0
  33. package/dist/_chunks/medication-search-DoEDakoM.js +380 -0
  34. package/dist/_chunks/{multi-select-Df3R8lv_.js → multi-select-DeMiHm8T.js} +4 -5
  35. package/dist/_chunks/{muscle-scheme-D_rSyGDj.js → muscle-scheme-BB2eBfww.js} +2 -2
  36. package/dist/_chunks/normalize-diacritics-DhJjQ3Bp.js +7 -0
  37. package/dist/_chunks/{notes-panel-DsEKNtsw.js → notes-panel-CnmQqhwq.js} +2 -2
  38. package/dist/_chunks/{optical-prescription-DaSbsh4p.js → optical-prescription-C4jpDFOE.js} +2 -2
  39. package/dist/_chunks/{option-row-Dc7BrbK8.js → option-row-DpCnuUqo.js} +25 -12
  40. package/dist/_chunks/{patient-account-settings-Cs9y-pVA.js → patient-account-settings-DfEPHmCh.js} +2 -2
  41. package/dist/_chunks/{patient-check-in-resume-4qi_klQV.js → patient-check-in-resume-TWs8CPQr.js} +3 -3
  42. package/dist/_chunks/{patient-details-Dv7EiTCo.js → patient-details-DQTxSWY4.js} +2 -2
  43. package/dist/_chunks/{patient-field-row-DuHWGlLz.js → patient-field-row-CXuWQeQJ.js} +6 -6
  44. package/dist/_chunks/patient-picker-CQNsqYn2.js +163 -0
  45. package/dist/_chunks/{patient-search-DBvLFArV.js → patient-search-aTFd7p9s.js} +2 -2
  46. package/dist/_chunks/{patient-summary-card-D-cDzOim.js → patient-summary-card-j5u7c5Us.js} +2 -2
  47. package/dist/_chunks/{phone-input-BL8Sj6OG.js → phone-input-DRKcJUi4.js} +2 -2
  48. package/dist/_chunks/{portal-details-BGc_FLQk.js → portal-details-VfeOI4PB.js} +2 -2
  49. package/dist/_chunks/{portal-documents-BSI1U5lI.js → portal-documents-hGHlwmbv.js} +2 -2
  50. package/dist/_chunks/{pregnancy-dating-lJbzai73.js → pregnancy-dating-C-3NLI6K.js} +2 -2
  51. package/dist/_chunks/prescription-history-748qDVwZ.js +1544 -0
  52. package/dist/_chunks/print-sheet-CSeqkM3_.js +318 -0
  53. package/dist/_chunks/{province-select-CTM8A9SM.js → province-select-D-iY9bQG.js} +3 -3
  54. package/dist/_chunks/{registration-form-CuLiTA52.js → registration-form-Cs9o6e5q.js} +7 -6
  55. package/dist/_chunks/{reserved.agent-CabZHFJC.js → reserved.agent-L2ElYPuj.js} +7 -7
  56. package/dist/_chunks/{reset-password-form-D_TePSM1.js → reset-password-form-DwtSNhnA.js} +18 -17
  57. package/dist/_chunks/{rich-text-editor-C48omVjq.js → rich-text-editor-DFsH5RAj.js} +2 -2
  58. package/dist/_chunks/save-Dn8uje3f.js +22 -0
  59. package/dist/_chunks/{search-bar-CQ9_V3EJ.js → search-bar-k1mS5yZl.js} +2 -2
  60. package/dist/_chunks/{select-CIXKyUMw.js → select-Bm8s3q-X.js} +16 -17
  61. package/dist/_chunks/{send-registration-link-form-BjkXr0TD.js → send-registration-link-form-C1vw6H1M.js} +6 -5
  62. package/dist/_chunks/{signature-request-vJDSHZld.js → signature-request-D3sLLOM6.js} +2 -2
  63. package/dist/_chunks/sync-tray-BhnkgXKK.js +567 -0
  64. package/dist/_chunks/{tabs-Czkmw5ou.js → tabs-BXr5XeGq.js} +2 -2
  65. package/dist/_chunks/{task-editor-wKbFbGqW.js → task-editor-DDVDPKJf.js} +26 -25
  66. package/dist/_chunks/{tasks-panel-DbtJS4QI.js → tasks-panel-BHXaPNOZ.js} +2 -2
  67. package/dist/_chunks/{toolbar-DjG-cpD_.js → toolbar-Dz_hAUIZ.js} +2 -2
  68. package/dist/_chunks/{unit-converter-CUAUTu2B.js → unit-converter-CBy7S4Tl.js} +2 -2
  69. package/dist/_chunks/{use-appointment-details-read-jGkJalX8.js → use-appointment-details-read-CBSpX4DI.js} +2 -2
  70. package/dist/_chunks/use-error-summary-CecJZo6w.js +32 -0
  71. package/dist/_chunks/use-registration-submit-CVukOAQk.js +84 -0
  72. package/dist/_chunks/{variables-menu-DQl8H4Gh.js → variables-menu-C4NcClKi.js} +2 -2
  73. package/dist/_chunks/{voice-control-panel-Cp4vs1iy.js → voice-control-panel-Dc_NFH2R.js} +2 -2
  74. package/dist/agent-catalog.json +455 -1
  75. package/dist/agent-i18n/en.json +53 -0
  76. package/dist/appointment-editor-panel/index.js +2 -2
  77. package/dist/browser-support.js +1 -1
  78. package/dist/components/_shared/medication.d.ts +28 -0
  79. package/dist/components/_shared/normalize-diacritics.d.ts +5 -0
  80. package/dist/components/_shared/patient-picker.d.ts +7 -0
  81. package/dist/components/address-fields/index.js +1 -1
  82. package/dist/components/ai-prompt-input/index.js +1 -1
  83. package/dist/components/appointment-details-panel/index.js +1 -1
  84. package/dist/components/audio-recorder/index.js +1 -1
  85. package/dist/components/autocomplete/autocomplete.d.ts +50 -0
  86. package/dist/components/autocomplete/index.d.ts +1 -1
  87. package/dist/components/autocomplete/index.js +1 -1
  88. package/dist/components/bill-line-table/index.js +1 -1
  89. package/dist/components/bill-table/index.js +1 -1
  90. package/dist/components/bishop-score/index.js +1 -1
  91. package/dist/components/booking/index.js +1 -1
  92. package/dist/components/calls-panel/index.js +1 -1
  93. package/dist/components/city-input/index.js +1 -1
  94. package/dist/components/combobox/index.js +1 -1
  95. package/dist/components/communications-panel/index.js +1 -1
  96. package/dist/components/country-select/index.js +1 -1
  97. package/dist/components/data-grid/index.js +2 -2
  98. package/dist/components/data-table/index.js +2 -2
  99. package/dist/components/document-preview/index.js +1 -1
  100. package/dist/components/face-scheme/index.js +1 -1
  101. package/dist/components/file-manager/index.js +1 -1
  102. package/dist/components/gestational-age-calculator/index.js +1 -1
  103. package/dist/components/heatmap/index.js +1 -1
  104. package/dist/components/index.d.ts +5 -0
  105. package/dist/components/invoice-upload-list/index.js +1 -1
  106. package/dist/components/medication-line/index.d.ts +6 -0
  107. package/dist/components/medication-line/index.js +7 -0
  108. package/dist/components/medication-line/medication-line.agent.d.ts +14 -0
  109. package/dist/components/medication-line/medication-line.d.ts +40 -0
  110. package/dist/components/medication-search/index.d.ts +6 -0
  111. package/dist/components/medication-search/index.js +10 -0
  112. package/dist/components/medication-search/medication-search.agent.d.ts +15 -0
  113. package/dist/components/medication-search/medication-search.d.ts +49 -0
  114. package/dist/components/multi-select/index.js +1 -1
  115. package/dist/components/muscle-scheme/index.js +1 -1
  116. package/dist/components/notes-panel/index.js +1 -1
  117. package/dist/components/optical-prescription/index.js +1 -1
  118. package/dist/components/patient-details/index.js +1 -1
  119. package/dist/components/patient-search/index.js +1 -1
  120. package/dist/components/patient-summary-card/index.js +1 -1
  121. package/dist/components/patient-table/index.js +1 -1
  122. package/dist/components/phone-input/index.js +1 -1
  123. package/dist/components/pregnancy-dating/index.js +1 -1
  124. package/dist/components/print-sheet/index.d.ts +5 -0
  125. package/dist/components/print-sheet/index.js +6 -0
  126. package/dist/components/print-sheet/print-isolation.d.ts +17 -0
  127. package/dist/components/print-sheet/print-sheet.agent.d.ts +19 -0
  128. package/dist/components/print-sheet/print-sheet.d.ts +54 -0
  129. package/dist/components/province-select/index.js +1 -1
  130. package/dist/components/rich-text-editor/index.js +2 -2
  131. package/dist/components/search-bar/index.js +1 -1
  132. package/dist/components/select/index.js +1 -1
  133. package/dist/components/skeleton-scheme/index.js +1 -1
  134. package/dist/components/sync-tray/index.d.ts +4 -0
  135. package/dist/components/sync-tray/index.js +7 -0
  136. package/dist/components/sync-tray/sync-tray.agent.d.ts +15 -0
  137. package/dist/components/sync-tray/sync-tray.d.ts +77 -0
  138. package/dist/components/tabs/index.js +1 -1
  139. package/dist/components/task-editor/index.js +1 -1
  140. package/dist/components/tasks-panel/index.js +1 -1
  141. package/dist/components/unit-converter/index.js +1 -1
  142. package/dist/components/variables-menu/index.js +1 -1
  143. package/dist/components/voice-control-panel/index.js +1 -1
  144. package/dist/core.css +1 -1
  145. package/dist/find-free-slots-panel/index.js +1 -1
  146. package/dist/host-compat.css +13 -1
  147. package/dist/i18n/locales/ar.d.ts +134 -0
  148. package/dist/i18n/locales/ar.js +134 -0
  149. package/dist/i18n/locales/de.d.ts +134 -0
  150. package/dist/i18n/locales/de.js +134 -0
  151. package/dist/i18n/locales/el.d.ts +134 -0
  152. package/dist/i18n/locales/el.js +134 -0
  153. package/dist/i18n/locales/en.d.ts +134 -0
  154. package/dist/i18n/locales/en.js +134 -0
  155. package/dist/i18n/locales/es.d.ts +134 -0
  156. package/dist/i18n/locales/es.js +134 -0
  157. package/dist/i18n/locales/fr.d.ts +134 -0
  158. package/dist/i18n/locales/fr.js +134 -0
  159. package/dist/i18n/locales/hi.d.ts +134 -0
  160. package/dist/i18n/locales/hi.js +134 -0
  161. package/dist/i18n/locales/it.d.ts +134 -0
  162. package/dist/i18n/locales/it.js +134 -0
  163. package/dist/i18n/locales/ja.d.ts +134 -0
  164. package/dist/i18n/locales/ja.js +134 -0
  165. package/dist/i18n/locales/nl.d.ts +134 -0
  166. package/dist/i18n/locales/nl.js +134 -0
  167. package/dist/i18n/locales/pl.d.ts +134 -0
  168. package/dist/i18n/locales/pl.js +134 -0
  169. package/dist/i18n/locales/pt.d.ts +134 -0
  170. package/dist/i18n/locales/pt.js +134 -0
  171. package/dist/i18n/locales/ro.d.ts +134 -0
  172. package/dist/i18n/locales/ro.js +134 -0
  173. package/dist/i18n/locales/ru.d.ts +134 -0
  174. package/dist/i18n/locales/ru.js +134 -0
  175. package/dist/i18n/locales/sq.d.ts +134 -0
  176. package/dist/i18n/locales/sq.js +134 -0
  177. package/dist/i18n/locales/sv.d.ts +134 -0
  178. package/dist/i18n/locales/sv.js +134 -0
  179. package/dist/i18n/locales/tr.d.ts +134 -0
  180. package/dist/i18n/locales/tr.js +134 -0
  181. package/dist/i18n/locales/zh.d.ts +134 -0
  182. package/dist/i18n/locales/zh.js +134 -0
  183. package/dist/index.js +1002 -974
  184. package/dist/locales/ar.json +134 -0
  185. package/dist/locales/de.json +134 -0
  186. package/dist/locales/el.json +134 -0
  187. package/dist/locales/en.json +134 -0
  188. package/dist/locales/es.json +134 -0
  189. package/dist/locales/fr.json +134 -0
  190. package/dist/locales/hi.json +134 -0
  191. package/dist/locales/it.json +134 -0
  192. package/dist/locales/ja.json +134 -0
  193. package/dist/locales/nl.json +134 -0
  194. package/dist/locales/pl.json +134 -0
  195. package/dist/locales/pt.json +134 -0
  196. package/dist/locales/ro.json +134 -0
  197. package/dist/locales/ru.json +134 -0
  198. package/dist/locales/sq.json +134 -0
  199. package/dist/locales/sv.json +134 -0
  200. package/dist/locales/tr.json +134 -0
  201. package/dist/locales/zh.json +134 -0
  202. package/dist/online-bookings-panel/index.js +1 -1
  203. package/dist/patterns/anamnesis/index.js +1 -1
  204. package/dist/patterns/calendar/index.js +3 -3
  205. package/dist/patterns/forgot-password-form/index.js +1 -1
  206. package/dist/patterns/login-form/index.js +1 -1
  207. package/dist/patterns/patient-account-settings/index.js +1 -1
  208. package/dist/patterns/patient-check-in/index.js +1 -1
  209. package/dist/patterns/patient-portal/index.js +2 -2
  210. package/dist/patterns/prescription/index.d.ts +11 -0
  211. package/dist/patterns/prescription/index.js +13 -0
  212. package/dist/patterns/prescription/prescription-composer-errors.d.ts +6 -0
  213. package/dist/patterns/prescription/prescription-composer-item.d.ts +34 -0
  214. package/dist/patterns/prescription/prescription-composer.d.ts +89 -0
  215. package/dist/patterns/prescription/prescription-history.d.ts +48 -0
  216. package/dist/patterns/prescription/prescription-patient-block.d.ts +13 -0
  217. package/dist/patterns/prescription/prescription-sheet.d.ts +52 -0
  218. package/dist/patterns/prescription/prescription-status-badge.d.ts +5 -0
  219. package/dist/patterns/prescription/prescription-types.d.ts +97 -0
  220. package/dist/patterns/prescription/prescription-validation.d.ts +40 -0
  221. package/dist/patterns/registration-form/index.js +1 -1
  222. package/dist/patterns/reset-password-form/index.js +1 -1
  223. package/dist/patterns/send-registration-link-form/index.js +1 -1
  224. package/dist/patterns/signature-request/index.js +1 -1
  225. package/dist/tokens.css +1 -1
  226. package/dist/waiting-list-panel/index.js +2 -2
  227. package/package.json +21 -1
  228. package/dist/_chunks/autocomplete-D10ydpgi.js +0 -562
  229. package/dist/_chunks/group-options-BvKhQ3xb.js +0 -16
  230. package/dist/_chunks/normalize-diacritics-BNGbFNlJ.js +0 -7
  231. package/dist/_chunks/patient-picker-BZJuOgMw.js +0 -173
  232. package/dist/_chunks/use-registration-submit-CLGHxwoT.js +0 -112
@@ -0,0 +1,1544 @@
1
+ import { jsxs as y, jsx as r, Fragment as Ge } from "react/jsx-runtime";
2
+ import { forwardRef as Ae, useId as we, useState as H, useRef as A, useEffect as ge, useCallback as C, useMemo as $e, useImperativeHandle as ft } from "react";
3
+ import { c as _ } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as le } from "react-i18next";
5
+ import { A as se } from "./alert-C4WKViaS.js";
6
+ import { B as qe } from "./button-DohK_Ak_.js";
7
+ import { E as Bt } from "./empty-state-DwJ5YNzz.js";
8
+ import { E as Ot } from "./error-summary-DxNhwf_G.js";
9
+ import { F as _t } from "./field-array-CA-gn526.js";
10
+ import { F as ce } from "./form-field-CyHfOVKF.js";
11
+ import { S as ot } from "./select-Bm8s3q-X.js";
12
+ import { S as Ne } from "./skeleton-tTWJpvAq.js";
13
+ import { P as jt } from "./patient-picker-CQNsqYn2.js";
14
+ import { p as ht } from "./privacy-mask-text-B8YfzB7L.js";
15
+ import { u as Gt } from "./use-controllable-state-BiY4xTzM.js";
16
+ import { u as Se } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
17
+ import { u as qt, a as Ht } from "./use-error-summary-CecJZo6w.js";
18
+ import { T as ct } from "./text-input-B6iAgCr3.js";
19
+ import { M as Kt } from "./medication-search-DoEDakoM.js";
20
+ import { a as Wt, S as Yt } from "./suggestion-chip-BNRWZL51.js";
21
+ import { T as Ut } from "./timestamp-DPLDWdxA.js";
22
+ import { I as Xt } from "./icon-button-S8_weU3g.js";
23
+ import { B as Qt } from "./button-group-DuQuuulC.js";
24
+ import { D as xe } from "./dropdown-menu-DBWaW4pq.js";
25
+ import { K as Jt, a as He, S as Zt } from "./key-value-pair-DOTl68_U.js";
26
+ import { a as er, M as tr } from "./medication-line-CHdlh-F7.js";
27
+ import { P as rr } from "./print-sheet-CSeqkM3_.js";
28
+ import { a as ir } from "./whatsapp-button-XbozeDl_.js";
29
+ import { f as Le } from "./intl-locale-FWh-Y5_3.js";
30
+ import { A as gt } from "./avatar-Dp5apm1d.js";
31
+ import { V as bt } from "./visually-hidden-BHxEUGyT.js";
32
+ import { P as vt } from "./printer-rkK0T1gi.js";
33
+ import { D as sr } from "./download-CfYKJO_j.js";
34
+ import { M as nr } from "./mail-BqXVF2zH.js";
35
+ import { M as ar } from "./message-square-Bye4ATvx.js";
36
+ import { C as or } from "./chevron-down-DWE7GSq9.js";
37
+ import { I as cr } from "./icon-button-group-SmkdVCNx.js";
38
+ import { B as yt } from "./badge-BUk4RjTS.js";
39
+ import { T as lr } from "./tag-BNlcEJfE.js";
40
+ import { R as dr } from "./row-actions-BF2-uizV.js";
41
+ import { e as pr } from "./data-grid-bQ6iFm10.js";
42
+ import { D as ee } from "./toolbar-Dz_hAUIZ.js";
43
+ import { C as mr } from "./check-DrFSN__t.js";
44
+ import { L as ur } from "./loader-circle-BECIU_8N.js";
45
+ import { C as fr } from "./circle-alert-rGDZ73Wh.js";
46
+ import { E as hr } from "./eye-BjhN2nYf.js";
47
+ function gr(e, a) {
48
+ const n = {};
49
+ if (e.patientId && a.patientId && (n.patientId = e.patientId), e.prescriberId && a.prescriberId && (n.prescriberId = e.prescriberId), e.link && a.link === e.link && (n.link = e.link), e.items && a.items && (n.items = e.items), e.itemErrors) {
50
+ const l = e.itemErrors.map(
51
+ (d, k) => {
52
+ var N;
53
+ const v = (N = a.itemErrors) == null ? void 0 : N[k];
54
+ if (!d || !v) return;
55
+ const o = {};
56
+ return d.medicationId && v.medicationId && (o.medicationId = d.medicationId), d.dosage && v.dosage && (o.dosage = d.dosage), Object.keys(o).length > 0 ? o : void 0;
57
+ }
58
+ );
59
+ l.some((d) => d !== void 0) && (n.itemErrors = l);
60
+ }
61
+ return n;
62
+ }
63
+ const br = 5, vr = _(
64
+ "ds:@container/rxline ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
65
+ {
66
+ variants: {
67
+ separated: {
68
+ true: "ds:border-t ds:border-[color:var(--border)] ds:pt-[var(--spacing-lg)]",
69
+ false: "ds:pt-[var(--spacing-xs)]"
70
+ }
71
+ },
72
+ defaultVariants: { separated: !1 }
73
+ }
74
+ );
75
+ function yr({
76
+ index: e,
77
+ item: a,
78
+ medication: n,
79
+ medicationFieldId: l,
80
+ dosageFieldId: d,
81
+ medicationError: k,
82
+ dosageError: v,
83
+ announceMedicationError: o,
84
+ announceDosageError: N,
85
+ searchMedications: R,
86
+ codeLabel: $,
87
+ catalogueStatus: j,
88
+ onCatalogueRetry: D,
89
+ suggestions: U,
90
+ onMedicationChange: c,
91
+ onDosageChange: X,
92
+ onNotesChange: w,
93
+ medicationSearchId: z,
94
+ medicationRef: h,
95
+ dosageInputRef: Q,
96
+ onSuggestionChosen: G
97
+ }) {
98
+ const { t: L } = le("ui"), S = e + 1, P = `${l}-legend`, M = U.slice(0, br), V = `${l}-hint`;
99
+ return /* @__PURE__ */ y(
100
+ "div",
101
+ {
102
+ role: "group",
103
+ "aria-labelledby": P,
104
+ "data-slot": "prescription-item",
105
+ "data-index": e,
106
+ className: vr({ separated: e > 0 }),
107
+ children: [
108
+ /* @__PURE__ */ r("p", { id: P, className: "type-label ds:text-foreground", children: L("prescription.composer.medicationLegend", { number: S }) }),
109
+ /* @__PURE__ */ r(
110
+ ce,
111
+ {
112
+ id: l,
113
+ label: L("prescription.composer.medication"),
114
+ required: !0,
115
+ error: k,
116
+ announceError: o,
117
+ children: /* @__PURE__ */ r(
118
+ Kt,
119
+ {
120
+ ref: h,
121
+ id: z,
122
+ loadOptions: R,
123
+ value: n,
124
+ onValueChange: c,
125
+ codeLabel: $,
126
+ status: j,
127
+ onRetry: D
128
+ }
129
+ )
130
+ }
131
+ ),
132
+ /* @__PURE__ */ y("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:@[576px]/rxline:grid-cols-2", children: [
133
+ /* @__PURE__ */ r(
134
+ ce,
135
+ {
136
+ id: d,
137
+ label: L("prescription.composer.dosage"),
138
+ required: !0,
139
+ error: v,
140
+ announceError: N,
141
+ children: /* @__PURE__ */ r(
142
+ ct,
143
+ {
144
+ ref: Q,
145
+ dir: "auto",
146
+ value: a.dosage,
147
+ onChange: (x) => X(x.target.value)
148
+ }
149
+ )
150
+ }
151
+ ),
152
+ /* @__PURE__ */ r(ce, { label: L("prescription.composer.notes"), optional: !0, children: /* @__PURE__ */ r(
153
+ ct,
154
+ {
155
+ dir: "auto",
156
+ value: a.notes,
157
+ onChange: (x) => w(x.target.value)
158
+ }
159
+ ) })
160
+ ] }),
161
+ n && M.length > 0 ? /* @__PURE__ */ y(
162
+ "div",
163
+ {
164
+ "data-slot": "dosage-suggestions",
165
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
166
+ children: [
167
+ /* @__PURE__ */ r("p", { id: V, className: "type-body-sm ds:text-muted-foreground", children: L("prescription.composer.dosageSuggestionsHint") }),
168
+ /* @__PURE__ */ r(
169
+ Wt,
170
+ {
171
+ label: L("prescription.composer.dosageSuggestions"),
172
+ "aria-describedby": V,
173
+ children: M.map((x) => /* @__PURE__ */ r(
174
+ Yt,
175
+ {
176
+ value: x,
177
+ dir: "auto",
178
+ keepOnSelect: !0,
179
+ onSelect: G,
180
+ children: x
181
+ },
182
+ x
183
+ ))
184
+ }
185
+ )
186
+ ]
187
+ }
188
+ ) : null
189
+ ]
190
+ }
191
+ );
192
+ }
193
+ const kr = /^(\d{4})-(\d{2})-(\d{2})$/;
194
+ function Ir(e, a) {
195
+ const n = kr.exec(e);
196
+ if (!n) return e;
197
+ const l = Number(n[1]), d = Number(n[2]), k = Number(n[3]), v = new Date(2e3, d - 1, k);
198
+ return v.setFullYear(l), Number.isNaN(v.getTime()) || v.getMonth() !== d - 1 || v.getDate() !== k ? e : new Intl.DateTimeFormat(Le(a), {
199
+ dateStyle: "long"
200
+ }).format(v);
201
+ }
202
+ function Te(e) {
203
+ return e !== void 0 && e.trim() !== "";
204
+ }
205
+ const Nr = _("ds:@container/pblock ds:flex ds:items-start", {
206
+ variants: {
207
+ density: {
208
+ default: "ds:gap-[var(--spacing-md)]",
209
+ compact: "ds:gap-[var(--spacing-sm)]"
210
+ }
211
+ },
212
+ defaultVariants: { density: "default" }
213
+ }), Ye = Ae(
214
+ ({
215
+ patient: e,
216
+ privacyMode: a = !1,
217
+ density: n = "default",
218
+ showAvatar: l = !1,
219
+ className: d,
220
+ ...k
221
+ }, v) => {
222
+ const { t: o, i18n: N } = le("ui"), R = () => /* @__PURE__ */ y(Ge, { children: [
223
+ /* @__PURE__ */ r(bt, { children: o("calendarWorkspace.privacy.hidden") }),
224
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: ht() })
225
+ ] }), $ = [];
226
+ Te(e.firstName) && $.push({
227
+ key: "firstName",
228
+ label: o("prescription.patient.firstName"),
229
+ value: a ? R() : /* @__PURE__ */ r("span", { dir: "auto", children: e.firstName })
230
+ }), Te(e.lastName) && $.push({
231
+ key: "lastName",
232
+ label: o("prescription.patient.lastName"),
233
+ value: a ? R() : /* @__PURE__ */ r("span", { dir: "auto", children: e.lastName })
234
+ }), Te(e.dateOfBirth) && $.push({
235
+ key: "dateOfBirth",
236
+ label: o("prescription.patient.dateOfBirth"),
237
+ value: a ? R() : Ir(e.dateOfBirth, N.language)
238
+ }), Te(e.fiscalCode) && $.push({
239
+ key: "fiscalCode",
240
+ label: o("prescription.patient.fiscalCode"),
241
+ value: a ? R() : e.fiscalCode,
242
+ mono: !0
243
+ });
244
+ const j = `${e.firstName} ${e.lastName}`.trim();
245
+ return /* @__PURE__ */ y(
246
+ "div",
247
+ {
248
+ ...k,
249
+ ref: v,
250
+ role: "group",
251
+ "aria-label": o("prescription.patient.details"),
252
+ className: Nr({ density: n, className: d }),
253
+ "data-component": "prescription-patient-block",
254
+ "data-density": n,
255
+ "data-privacy": a ? "masked" : void 0,
256
+ children: [
257
+ l ? (
258
+ /* Under privacy mode the avatar shows no initials: an empty name
259
+ gives the Avatar's own neutral icon, at the same size. */
260
+ /* @__PURE__ */ r(
261
+ gt,
262
+ {
263
+ name: a ? "" : j,
264
+ size: "md",
265
+ className: "ds:shrink-0",
266
+ "aria-hidden": "true",
267
+ role: "presentation",
268
+ "aria-label": void 0
269
+ }
270
+ )
271
+ ) : null,
272
+ /* @__PURE__ */ r(
273
+ Jt,
274
+ {
275
+ semantic: !0,
276
+ rowGap: n === "compact" ? "sm" : "md",
277
+ className: "ds:min-w-0 ds:flex-1 ds:@[448px]/pblock:grid-cols-[repeat(2,auto_fit-content(40%)_minmax(0,1fr))]",
278
+ children: $.map((D) => /* @__PURE__ */ r(
279
+ He,
280
+ {
281
+ label: D.label,
282
+ value: D.value,
283
+ mono: D.mono,
284
+ "data-field": D.key
285
+ },
286
+ D.key
287
+ ))
288
+ }
289
+ )
290
+ ]
291
+ }
292
+ );
293
+ }
294
+ );
295
+ Ye.displayName = "PrescriptionPatientBlock";
296
+ const Ee = Object.freeze({
297
+ medicationId: "",
298
+ dosage: "",
299
+ notes: ""
300
+ });
301
+ function Sr(e = "") {
302
+ return {
303
+ patientId: "",
304
+ prescriberId: e,
305
+ link: null,
306
+ items: [{ ...Ee }]
307
+ };
308
+ }
309
+ function te(e) {
310
+ return e == null || e.trim() === "";
311
+ }
312
+ function Ke(e) {
313
+ return te(e.medicationId) && te(e.dosage) && te(e.notes);
314
+ }
315
+ function xr(e, { requireLink: a = !0, linkOptions: n }) {
316
+ const l = e.link;
317
+ if (l == null)
318
+ return a ? "required" : void 0;
319
+ if (l.kind !== "treatment" && l.kind !== "carePlan" || te(l.id) || n && !n.some(
320
+ (d) => d.kind === l.kind && d.id === l.id
321
+ ))
322
+ return "invalid";
323
+ }
324
+ function lt(e, a = {}) {
325
+ const n = {};
326
+ te(e.patientId) && (n.patientId = "required"), te(e.prescriberId) && (n.prescriberId = "required");
327
+ const l = xr(e, a);
328
+ l && (n.link = l);
329
+ const d = e.items ?? [];
330
+ if (d.filter((o) => !Ke(o)).length === 0)
331
+ return n.items = "required", d.length > 0 && (n.itemErrors = d.map(
332
+ (o, N) => N === 0 ? { medicationId: "required" } : void 0
333
+ )), n;
334
+ const v = d.map((o) => {
335
+ if (Ke(o)) return;
336
+ const N = {};
337
+ return te(o.medicationId) && (N.medicationId = "required"), te(o.dosage) && (N.dosage = "required"), Object.keys(N).length > 0 ? N : void 0;
338
+ });
339
+ return v.some((o) => o !== void 0) && (n.itemErrors = v), n;
340
+ }
341
+ function dt(e) {
342
+ return Object.keys(e).length === 0;
343
+ }
344
+ function Tr(e) {
345
+ return {
346
+ patientId: e.patientId.trim(),
347
+ prescriberId: e.prescriberId.trim(),
348
+ link: e.link ? { kind: e.link.kind, id: e.link.id } : null,
349
+ items: e.items.filter((a) => !Ke(a)).map((a) => ({
350
+ medicationId: a.medicationId.trim(),
351
+ dosage: a.dosage.trim(),
352
+ notes: a.notes.trim()
353
+ }))
354
+ };
355
+ }
356
+ const wr = _(
357
+ "ds:flex ds:w-full ds:flex-col ds:gap-[var(--spacing-lg)]"
358
+ );
359
+ function _e(e) {
360
+ return `${e.firstName} ${e.lastName}`.trim();
361
+ }
362
+ function pt(e) {
363
+ return e.items.length > 0 ? e : { ...e, items: [{ ...Ee }] };
364
+ }
365
+ function je(e) {
366
+ return e ? `${e.kind}:${e.id}` : "";
367
+ }
368
+ function $r(e) {
369
+ const a = e.indexOf(":");
370
+ if (a < 0) return null;
371
+ const n = e.slice(0, a);
372
+ return n !== "treatment" && n !== "carePlan" ? null : { kind: n, id: e.slice(a + 1) };
373
+ }
374
+ const Er = Ae(function({
375
+ patients: a,
376
+ searchPatients: n,
377
+ linkOptions: l,
378
+ prescribers: d,
379
+ defaultPrescriberId: k,
380
+ searchMedications: v,
381
+ resolveMedication: o,
382
+ suggestDosages: N,
383
+ codeLabel: R,
384
+ catalogueStatus: $ = "ready",
385
+ onCatalogueRetry: j,
386
+ value: D,
387
+ defaultValue: U,
388
+ onChange: c,
389
+ onSubmit: X,
390
+ onPatientChange: w,
391
+ requireLink: z = !0,
392
+ loading: h = !1,
393
+ error: Q,
394
+ privacyMode: G = !1,
395
+ lockPatient: L = !1,
396
+ submitLabel: S,
397
+ id: P,
398
+ className: M,
399
+ ...V
400
+ }, x) {
401
+ const { t: p } = le("ui"), K = we(), I = P ?? K, [F] = H(
402
+ () => U ?? Sr(
403
+ k && d.some((t) => t.id === k) ? k : ""
404
+ )
405
+ ), [O, i] = Gt({
406
+ value: D,
407
+ defaultValue: F,
408
+ onChange: c
409
+ }), m = pt(O ?? F), g = A(m);
410
+ Se(() => {
411
+ g.current = m;
412
+ });
413
+ const [W, J] = H({}), [Y, re] = H(!1), [de, pe] = H(!1), me = A(!1), u = A(!0);
414
+ ge(() => (u.current = !0, () => {
415
+ u.current = !1;
416
+ }), []);
417
+ const [ne, ue] = H(() => /* @__PURE__ */ new Map()), [be, Pe] = H(() => /* @__PURE__ */ new Map()), Ve = C(
418
+ (t) => {
419
+ Pe((s) => {
420
+ if (t.every((b) => s.get(b.id) === b)) return s;
421
+ const f = new Map(s);
422
+ for (const b of t) f.set(b.id, b);
423
+ return f;
424
+ });
425
+ },
426
+ []
427
+ ), Ue = A(v);
428
+ Se(() => {
429
+ Ue.current = v;
430
+ });
431
+ const It = C(
432
+ async (t, s) => {
433
+ const f = await Ue.current(t, s);
434
+ return s.signal.aborted || Ve(f), f;
435
+ },
436
+ [Ve]
437
+ ), Xe = A(n);
438
+ Se(() => {
439
+ Xe.current = n;
440
+ });
441
+ const Qe = n !== void 0, Nt = $e(() => {
442
+ if (Qe)
443
+ return async (t, s) => {
444
+ const f = Xe.current, b = f ? await f(t, s) : [];
445
+ return s.signal.aborted || ue((B) => {
446
+ const he = new Map(B);
447
+ for (const T of b) he.set(T.id, T);
448
+ return he;
449
+ }), b.map((B) => ({ id: B.id, name: _e(B) }));
450
+ };
451
+ }, [Qe]), ie = m.patientId, fe = ie ? (a == null ? void 0 : a.find((t) => t.id === ie)) ?? ne.get(ie) : void 0, E = C(
452
+ (t) => {
453
+ g.current = t, i(t), J(
454
+ (s) => Object.keys(s).length === 0 ? s : gr(
455
+ s,
456
+ lt(t, { requireLink: z, linkOptions: l })
457
+ )
458
+ );
459
+ },
460
+ [i, z, l]
461
+ ), Ce = C(
462
+ (t) => {
463
+ const s = g.current;
464
+ t !== s.patientId && (J({}), re(!1), E({
465
+ patientId: t,
466
+ prescriberId: s.prescriberId,
467
+ link: null,
468
+ items: [{ ...Ee }]
469
+ }), w == null || w(t));
470
+ },
471
+ [E, w]
472
+ ), Je = A(!1), De = C(
473
+ (t) => {
474
+ Je.current = !0, E({ ...g.current, prescriberId: t });
475
+ },
476
+ [E]
477
+ ), Ze = A(!1);
478
+ ge(() => {
479
+ if (Ze.current || Je.current || !k || !d.some((s) => s.id === k))
480
+ return;
481
+ Ze.current = !0;
482
+ const t = g.current;
483
+ t.prescriberId === "" && E({ ...t, prescriberId: k });
484
+ }, [k, d, E]);
485
+ const Me = C(
486
+ (t) => E({ ...g.current, link: t }),
487
+ [E]
488
+ ), ae = C(
489
+ (t, s) => {
490
+ const f = g.current;
491
+ t < 0 || t >= f.items.length || E({
492
+ ...f,
493
+ items: f.items.map(
494
+ (b, B) => B === t ? { ...b, ...s } : b
495
+ )
496
+ });
497
+ },
498
+ [E]
499
+ ), Re = C(
500
+ (t) => {
501
+ const s = g.current;
502
+ return E({
503
+ ...s,
504
+ items: [...s.items, { ...Ee, ...t }]
505
+ }), s.items.length;
506
+ },
507
+ [E]
508
+ ), ze = C(
509
+ (t) => {
510
+ const s = g.current;
511
+ s.items.length <= 1 || t < 0 || t >= s.items.length || E({
512
+ ...s,
513
+ items: s.items.filter((f, b) => b !== t)
514
+ });
515
+ },
516
+ [E]
517
+ ), et = A(null), Fe = A(/* @__PURE__ */ new Map()), Be = A(/* @__PURE__ */ new Map()), [oe, ve] = H(null);
518
+ ge(() => {
519
+ var t, s, f, b;
520
+ oe && (oe.kind === "medication" ? (t = Fe.current.get(oe.index)) == null || t.focus() : oe.kind === "dosage" ? (s = Be.current.get(oe.index)) == null || s.focus() : (b = (f = document.getElementById(`${I}-items`)) == null ? void 0 : f.querySelector(":scope > button")) == null || b.focus(), ve(null));
521
+ }, [oe, I]);
522
+ const St = (t) => {
523
+ const s = g.current.items.length;
524
+ ze(t), !(s <= 1) && ve(
525
+ s - 1 === 1 ? { kind: "add" } : { kind: "medication", index: Math.min(t, s - 2) }
526
+ );
527
+ }, Z = (t) => {
528
+ var B;
529
+ if (t === "patient")
530
+ return W.patientId ? p("prescription.composer.errors.patient") : void 0;
531
+ if (t === "prescriber")
532
+ return W.prescriberId ? p("prescription.composer.errors.prescriber") : void 0;
533
+ if (t === "link")
534
+ return W.link ? W.link === "invalid" ? p("prescription.composer.errors.linkInvalid") : p("prescription.composer.errors.link") : void 0;
535
+ if (t === "items")
536
+ return W.items ? p("prescription.composer.errors.items") : void 0;
537
+ const [s, f] = t.split(":"), b = (B = W.itemErrors) == null ? void 0 : B[Number(f)];
538
+ return s === "medication" ? b != null && b.medicationId && !W.items ? p("prescription.composer.errors.medication") : void 0 : b != null && b.dosage ? p("prescription.composer.errors.dosage") : void 0;
539
+ }, xt = [
540
+ "patient",
541
+ "prescriber",
542
+ "link",
543
+ "items",
544
+ ...m.items.flatMap((t, s) => [`medication:${s}`, `dosage:${s}`])
545
+ ], q = qt(xt, Z), tt = q.listed.length > 0, Tt = (t) => {
546
+ if (t === "items") return `${I}-medication-0`;
547
+ const [s, f] = t.split(":");
548
+ return f === void 0 ? `${I}-${t}` : `${I}-${s}-${f}`;
549
+ }, wt = (t) => {
550
+ const [s, f] = t.split(":");
551
+ return s === "medication" ? p("prescription.composer.errors.medicationLine", {
552
+ number: Number(f) + 1
553
+ }) : s === "dosage" ? p("prescription.composer.errors.dosageLine", {
554
+ number: Number(f) + 1
555
+ }) : Z(t) ?? "";
556
+ }, ye = C(
557
+ (t) => {
558
+ J(t), q.open();
559
+ },
560
+ // eslint-disable-next-line react-hooks/exhaustive-deps
561
+ [q.open]
562
+ ), ke = C(
563
+ () => lt(g.current, { requireLink: z, linkOptions: l }),
564
+ [z, l]
565
+ ), rt = A(X);
566
+ Se(() => {
567
+ rt.current = X;
568
+ });
569
+ const Oe = C(async () => {
570
+ if (me.current) return;
571
+ const t = ke();
572
+ if (!dt(t)) {
573
+ ye(t);
574
+ return;
575
+ }
576
+ J({}), re(!1), me.current = !0, pe(!0);
577
+ try {
578
+ return await rt.current(
579
+ Tr(g.current)
580
+ ) ?? void 0;
581
+ } catch {
582
+ u.current && re(!0);
583
+ return;
584
+ } finally {
585
+ me.current = !1, u.current && pe(!1);
586
+ }
587
+ }, [ke, ye]), it = C(() => {
588
+ const t = g.current;
589
+ J({}), re(!1), E(pt(F)), t.patientId !== F.patientId && (w == null || w(F.patientId));
590
+ }, [E, F, w]);
591
+ ft(
592
+ x,
593
+ () => ({
594
+ getDraft: () => g.current,
595
+ setPatient: Ce,
596
+ setPrescriber: De,
597
+ setLink: Me,
598
+ addItem: Re,
599
+ updateItem: ae,
600
+ removeItem: ze,
601
+ validate: () => {
602
+ const t = ke();
603
+ return dt(t) ? J({}) : ye(t), t;
604
+ },
605
+ submit: Oe,
606
+ reset: it,
607
+ focusTitle: () => {
608
+ var t;
609
+ return (t = et.current) == null ? void 0 : t.focus();
610
+ }
611
+ }),
612
+ [
613
+ Ce,
614
+ De,
615
+ Me,
616
+ Re,
617
+ ae,
618
+ ze,
619
+ ke,
620
+ ye,
621
+ Oe,
622
+ it
623
+ ]
624
+ );
625
+ const Ie = Q ?? (Y ? p("prescription.composer.errors.submit") : void 0), $t = Ht(Ie, tt), Et = L && fe !== void 0, st = `${I}-message`, [At, Lt] = H("");
626
+ ge(() => {
627
+ Lt(h ? p("prescription.composer.loading") : "");
628
+ }, [h, p]);
629
+ const Pt = {
630
+ ...V,
631
+ "data-component": "prescription-composer",
632
+ "data-component-id": P,
633
+ "data-has-patient": ie !== "" ? !0 : void 0,
634
+ "data-submitting": de ? !0 : void 0
635
+ }, Vt = wr({ className: M }), Ct = (a ?? []).map((t) => ({
636
+ id: t.id,
637
+ name: _e(t)
638
+ })), Dt = !G && fe ? _e(fe) : void 0, Mt = (l ?? []).filter(
639
+ (t) => t.kind === "treatment"
640
+ ), Rt = (l ?? []).filter(
641
+ (t) => t.kind === "carePlan"
642
+ ), nt = [
643
+ ...Mt.map((t) => ({
644
+ value: je(t),
645
+ label: t.label,
646
+ group: p("prescription.composer.treatments"),
647
+ dir: "auto"
648
+ })),
649
+ ...Rt.map((t) => ({
650
+ value: je(t),
651
+ label: t.label,
652
+ group: p("prescription.composer.carePlans"),
653
+ dir: "auto"
654
+ }))
655
+ ], zt = d.map((t) => ({
656
+ value: t.id,
657
+ label: t.name,
658
+ description: t.specialty,
659
+ dir: "auto"
660
+ })), Ft = (t) => {
661
+ t.preventDefault(), Oe();
662
+ }, at = Ie ? /* @__PURE__ */ r(se, { id: st, variant: "error", announce: $t, children: /* @__PURE__ */ r(se.Description, { children: Ie }) }) : null;
663
+ return /* @__PURE__ */ y("div", { ...Pt, className: Vt, children: [
664
+ /* @__PURE__ */ r("div", { role: "status", className: "ds:sr-only", children: At }),
665
+ h ? /* @__PURE__ */ y(
666
+ "div",
667
+ {
668
+ "aria-hidden": "true",
669
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
670
+ children: [
671
+ /* @__PURE__ */ r(Ne, { variant: "rounded", size: "sm" }),
672
+ /* @__PURE__ */ r(Ne, { variant: "text", lines: 3 }),
673
+ /* @__PURE__ */ r(Ne, { variant: "rounded", size: "sm" }),
674
+ /* @__PURE__ */ r(Ne, { variant: "rounded", size: "lg" })
675
+ ]
676
+ }
677
+ ) : /* @__PURE__ */ y(
678
+ "form",
679
+ {
680
+ noValidate: !0,
681
+ onSubmit: Ft,
682
+ "aria-labelledby": `${I}-title`,
683
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
684
+ children: [
685
+ /* @__PURE__ */ r(
686
+ "h2",
687
+ {
688
+ ref: et,
689
+ id: `${I}-title`,
690
+ tabIndex: -1,
691
+ className: "type-title-section ds:m-0 ds:focus:outline-none",
692
+ children: p("prescription.composer.title")
693
+ }
694
+ ),
695
+ tt ? /* @__PURE__ */ r(
696
+ Ot,
697
+ {
698
+ ref: q.ref,
699
+ title: p("prescription.composer.errorTitle"),
700
+ headingLevel: 3,
701
+ "aria-describedby": Ie ? st : void 0,
702
+ errors: q.listed.map((t) => ({
703
+ field: t,
704
+ message: wt(t),
705
+ targetId: Tt(t)
706
+ }))
707
+ }
708
+ ) : null,
709
+ Et ? null : /* @__PURE__ */ r(
710
+ ce,
711
+ {
712
+ id: `${I}-patient`,
713
+ label: p("prescription.composer.patient"),
714
+ required: !0,
715
+ description: G && ie !== "" ? p("calendarWorkspace.privacy.hidden") : void 0,
716
+ error: Z("patient"),
717
+ announceError: !q.lists("patient"),
718
+ children: /* @__PURE__ */ r(
719
+ jt,
720
+ {
721
+ value: ie,
722
+ onValueChange: Ce,
723
+ patients: Ct,
724
+ searchPatients: Nt,
725
+ selectedLabel: Dt,
726
+ privacyMask: G ? ht() : void 0,
727
+ placeholder: p("prescription.composer.patientPlaceholder")
728
+ }
729
+ )
730
+ }
731
+ ),
732
+ ie === "" ? /* @__PURE__ */ y(Ge, { children: [
733
+ /* @__PURE__ */ r(
734
+ Bt,
735
+ {
736
+ variant: "first-use",
737
+ size: "sm",
738
+ title: p("prescription.composer.choosePatientTitle"),
739
+ description: p("prescription.composer.choosePatientBody")
740
+ }
741
+ ),
742
+ at
743
+ ] }) : /* @__PURE__ */ y(Ge, { children: [
744
+ fe ? /* @__PURE__ */ r(
745
+ Ye,
746
+ {
747
+ patient: fe,
748
+ privacyMode: G,
749
+ showAvatar: !0
750
+ }
751
+ ) : null,
752
+ /* @__PURE__ */ r(
753
+ ce,
754
+ {
755
+ id: `${I}-link`,
756
+ label: p("prescription.composer.link"),
757
+ ...z ? { required: !0 } : { optional: !0 },
758
+ description: nt.length === 0 ? p("prescription.composer.linkEmpty") : void 0,
759
+ error: Z("link"),
760
+ announceError: !q.lists("link"),
761
+ children: /* @__PURE__ */ r(
762
+ ot,
763
+ {
764
+ options: nt,
765
+ value: je(m.link),
766
+ onValueChange: (t) => Me($r(t)),
767
+ id: `${I}-link-select`,
768
+ placeholder: p("prescription.composer.linkPlaceholder"),
769
+ clearable: !z
770
+ }
771
+ )
772
+ }
773
+ ),
774
+ /* @__PURE__ */ r(
775
+ ce,
776
+ {
777
+ id: `${I}-prescriber`,
778
+ label: p("prescription.composer.prescriber"),
779
+ required: !0,
780
+ error: Z("prescriber"),
781
+ announceError: !q.lists("prescriber"),
782
+ children: /* @__PURE__ */ r(
783
+ ot,
784
+ {
785
+ options: zt,
786
+ value: m.prescriberId,
787
+ onValueChange: De,
788
+ id: `${I}-prescriber-select`,
789
+ placeholder: p("prescription.composer.prescriberPlaceholder"),
790
+ showDescriptions: !0
791
+ }
792
+ )
793
+ }
794
+ ),
795
+ /* @__PURE__ */ r(
796
+ _t,
797
+ {
798
+ id: `${I}-items`,
799
+ 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)]",
800
+ legend: p("prescription.composer.medications"),
801
+ items: m.items,
802
+ min: 1,
803
+ addLabel: p("prescription.composer.addMedication"),
804
+ removeItemLabel: (t) => p("prescription.composer.removeMedication", {
805
+ number: t + 1
806
+ }),
807
+ onAdd: () => {
808
+ const t = Re();
809
+ ve({ kind: "medication", index: t });
810
+ },
811
+ onRemove: St,
812
+ renderItem: (t, s) => {
813
+ const f = t.medicationId ? be.get(t.medicationId) ?? (o == null ? void 0 : o(t.medicationId)) ?? null : null, b = `medication:${s}`, B = `dosage:${s}`, he = s === 0 ? Z("items") : void 0;
814
+ return /* @__PURE__ */ r(
815
+ yr,
816
+ {
817
+ index: s,
818
+ item: t,
819
+ medication: f,
820
+ medicationFieldId: `${I}-medication-${s}`,
821
+ dosageFieldId: `${I}-dosage-${s}`,
822
+ medicationError: he ?? Z(b),
823
+ dosageError: Z(B),
824
+ announceMedicationError: !q.lists(he ? "items" : b),
825
+ announceDosageError: !q.lists(B),
826
+ searchMedications: It,
827
+ codeLabel: R,
828
+ catalogueStatus: $,
829
+ onCatalogueRetry: j,
830
+ suggestions: f && N ? N(f) : [],
831
+ onMedicationChange: (T) => {
832
+ T && Ve([T]), ae(s, { medicationId: (T == null ? void 0 : T.id) ?? "" });
833
+ },
834
+ onDosageChange: (T) => ae(s, { dosage: T }),
835
+ onNotesChange: (T) => ae(s, { notes: T }),
836
+ medicationSearchId: `${I}-medication-${s}-search`,
837
+ medicationRef: (T) => {
838
+ T ? Fe.current.set(s, T) : Fe.current.delete(s);
839
+ },
840
+ dosageInputRef: (T) => {
841
+ T ? Be.current.set(s, T) : Be.current.delete(s);
842
+ },
843
+ onSuggestionChosen: (T) => {
844
+ ae(s, { dosage: T }), ve({ kind: "dosage", index: s });
845
+ }
846
+ }
847
+ );
848
+ }
849
+ }
850
+ ),
851
+ at,
852
+ /* @__PURE__ */ r(
853
+ qe,
854
+ {
855
+ type: "submit",
856
+ loading: de,
857
+ className: "ds:self-start ds:min-h-[var(--min-target-size)]",
858
+ children: S ?? p("prescription.composer.save")
859
+ }
860
+ )
861
+ ] })
862
+ ]
863
+ }
864
+ )
865
+ ] });
866
+ });
867
+ Er.displayName = "PrescriptionComposer";
868
+ const Ar = {
869
+ sent: "success",
870
+ sending: "info",
871
+ failed: "error"
872
+ };
873
+ function kt({
874
+ status: e
875
+ }) {
876
+ const { t: a } = le("ui"), n = e === "sent" ? /* @__PURE__ */ r(mr, { "aria-hidden": "true" }) : e === "sending" ? /* @__PURE__ */ r(
877
+ ur,
878
+ {
879
+ "aria-hidden": "true",
880
+ className: "ds:animate-spin ds:motion-reduce:animate-none"
881
+ }
882
+ ) : /* @__PURE__ */ r(fr, { "aria-hidden": "true" });
883
+ return /* @__PURE__ */ r(yt, { size: "sm", variant: Ar[e], leading: n, children: a(e === "sent" ? "prescription.status.sent" : e === "sending" ? "prescription.status.sending" : "prescription.status.failed") });
884
+ }
885
+ const Lr = _("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]"), Pr = _("ds:flex ds:flex-col", {
886
+ variants: {
887
+ density: {
888
+ default: "ds:gap-[var(--spacing-lg)]",
889
+ compact: "ds:gap-[var(--spacing-md)]"
890
+ }
891
+ },
892
+ defaultVariants: { density: "default" }
893
+ });
894
+ function Vr(e) {
895
+ if (typeof globalThis.reportError == "function") {
896
+ globalThis.reportError(e);
897
+ return;
898
+ }
899
+ setTimeout(() => {
900
+ throw e;
901
+ }, 0);
902
+ }
903
+ function Cr({
904
+ label: e,
905
+ items: a,
906
+ blocked: n,
907
+ describedBy: l,
908
+ ...d
909
+ }) {
910
+ const [k, v] = H(!1);
911
+ return /* @__PURE__ */ y(
912
+ xe.Root,
913
+ {
914
+ open: k && !n,
915
+ onOpenChange: (o) => v(o && !n),
916
+ children: [
917
+ /* @__PURE__ */ r(xe.Trigger, { asChild: !0, children: /* @__PURE__ */ r(
918
+ Xt,
919
+ {
920
+ ...d,
921
+ icon: /* @__PURE__ */ r(or, { "aria-hidden": "true" }),
922
+ "aria-label": e,
923
+ "aria-haspopup": "menu",
924
+ "aria-disabled": n || void 0,
925
+ "aria-describedby": l,
926
+ "data-action": "moreActions",
927
+ className: "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]"
928
+ }
929
+ ) }),
930
+ /* @__PURE__ */ r(xe.Content, { align: "end", children: a.map((o) => /* @__PURE__ */ r(
931
+ xe.Item,
932
+ {
933
+ startIcon: o.icon,
934
+ "data-action": o.action,
935
+ "aria-busy": o.busy || void 0,
936
+ onSelect: () => {
937
+ o.busy || o.run();
938
+ },
939
+ children: o.label
940
+ },
941
+ o.action
942
+ )) })
943
+ ]
944
+ }
945
+ );
946
+ }
947
+ function Dr(e) {
948
+ return typeof e == "object" && e !== null && typeof e.then == "function";
949
+ }
950
+ const Mr = Ae(
951
+ ({
952
+ record: e,
953
+ practiceHeader: a,
954
+ size: n = "a4",
955
+ density: l = "default",
956
+ codeLabel: d,
957
+ privacyMode: k = !1,
958
+ isolateBrowserPrint: v = !1,
959
+ numberLabel: o,
960
+ onPrint: N,
961
+ onDownloadPdf: R,
962
+ onSendEmail: $,
963
+ onSendSms: j,
964
+ onSendWhatsApp: D,
965
+ onResend: U,
966
+ id: c,
967
+ className: X,
968
+ ...w
969
+ }, z) => {
970
+ const { t: h, i18n: Q } = le("ui"), G = Le(Q.language), L = A(null), S = we(), P = we(), M = we(), V = e.sendStatus, x = V === "sending" || V === "failed", p = A(x);
971
+ p.current = x;
972
+ const K = A(e);
973
+ K.current = e;
974
+ const I = $e(
975
+ () => ({
976
+ print: () => {
977
+ var u;
978
+ p.current || (u = L.current) == null || u.print();
979
+ },
980
+ getRecordId: () => K.current.id,
981
+ focusTitle: () => {
982
+ var u;
983
+ return (u = L.current) == null ? void 0 : u.focusTitle();
984
+ }
985
+ }),
986
+ []
987
+ );
988
+ ft(z, () => I, [I]);
989
+ const [F, O] = H(() => /* @__PURE__ */ new Set()), i = A(/* @__PURE__ */ new Set()), m = A(!0);
990
+ ge(() => (m.current = !0, () => {
991
+ m.current = !1;
992
+ }), []);
993
+ const g = C(
994
+ (u, ne) => {
995
+ if (!ne || i.current.has(u) || p.current && u !== "resend") return;
996
+ let ue;
997
+ try {
998
+ ue = ne(K.current);
999
+ } catch (Pe) {
1000
+ Vr(Pe);
1001
+ return;
1002
+ }
1003
+ if (!Dr(ue)) return;
1004
+ i.current.add(u), O(new Set(i.current));
1005
+ const be = () => {
1006
+ i.current.delete(u), m.current && O(new Set(i.current));
1007
+ };
1008
+ ue.then(be, be);
1009
+ },
1010
+ []
1011
+ ), W = C(() => {
1012
+ var u;
1013
+ i.current.has("print") || ((u = L.current) == null || u.print(), g("print", N));
1014
+ }, [g, N]), J = [
1015
+ N && {
1016
+ action: "print",
1017
+ label: h("prescription.sheet.print"),
1018
+ icon: /* @__PURE__ */ r(vt, { "aria-hidden": "true" }),
1019
+ run: W
1020
+ },
1021
+ R && {
1022
+ action: "downloadPdf",
1023
+ label: h("prescription.sheet.downloadPdf"),
1024
+ icon: /* @__PURE__ */ r(sr, { "aria-hidden": "true" }),
1025
+ run: () => g("downloadPdf", R)
1026
+ },
1027
+ $ && {
1028
+ action: "sendEmail",
1029
+ label: h("prescription.sheet.sendEmail"),
1030
+ icon: /* @__PURE__ */ r(nr, { "aria-hidden": "true" }),
1031
+ run: () => g("sendEmail", $)
1032
+ },
1033
+ j && {
1034
+ action: "sendSms",
1035
+ label: h("prescription.sheet.sendSms"),
1036
+ icon: /* @__PURE__ */ r(ar, { "aria-hidden": "true" }),
1037
+ run: () => g("sendSms", j)
1038
+ },
1039
+ D && {
1040
+ action: "sendWhatsApp",
1041
+ label: h("prescription.sheet.sendWhatsApp"),
1042
+ icon: /* @__PURE__ */ r(ir, {}),
1043
+ run: () => g("sendWhatsApp", D)
1044
+ }
1045
+ ].filter((u) => !!u), [Y, ...re] = J, de = Y ? /* @__PURE__ */ r(
1046
+ qe,
1047
+ {
1048
+ type: "button",
1049
+ intent: "outline",
1050
+ startIcon: Y.icon,
1051
+ loading: F.has(Y.action),
1052
+ "aria-disabled": x || void 0,
1053
+ "aria-describedby": x ? M : void 0,
1054
+ onClick: x ? void 0 : Y.run,
1055
+ "data-action": Y.action,
1056
+ className: "ds:min-h-[var(--min-target-size)]",
1057
+ children: Y.label
1058
+ }
1059
+ ) : null, pe = Y && re.length > 0 ? /* @__PURE__ */ y(Qt, { label: h("prescription.sheet.shareActions"), children: [
1060
+ de,
1061
+ /* @__PURE__ */ r(
1062
+ Cr,
1063
+ {
1064
+ blocked: x,
1065
+ describedBy: x ? M : void 0,
1066
+ label: h("prescription.sheet.moreActions"),
1067
+ items: re.map((u) => ({
1068
+ ...u,
1069
+ busy: F.has(u.action)
1070
+ }))
1071
+ }
1072
+ )
1073
+ ] }) : de, me = pe !== null;
1074
+ return /* @__PURE__ */ y(
1075
+ "div",
1076
+ {
1077
+ ...w,
1078
+ id: c,
1079
+ className: Lr({ className: X }),
1080
+ "data-component": "prescription-sheet",
1081
+ "data-component-id": c,
1082
+ "data-prescription-id": e.id,
1083
+ children: [
1084
+ V ? /* @__PURE__ */ r(
1085
+ "div",
1086
+ {
1087
+ id: M,
1088
+ "data-slot": "send-status",
1089
+ "data-send-status": V,
1090
+ className: "ds:mx-auto ds:flex ds:w-full ds:max-w-3xl ds:justify-center ds:print:hidden",
1091
+ children: V === "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: [
1092
+ /* @__PURE__ */ r(kt, { status: "sent" }),
1093
+ e.sentAt ? /* @__PURE__ */ y("span", { children: [
1094
+ h("prescription.sheet.sentAt"),
1095
+ " ",
1096
+ /* @__PURE__ */ r(
1097
+ Ut,
1098
+ {
1099
+ locale: G,
1100
+ value: e.sentAt,
1101
+ format: "absolute",
1102
+ shape: "bare",
1103
+ absoluteFormat: {
1104
+ dateStyle: "medium",
1105
+ timeStyle: "short"
1106
+ }
1107
+ }
1108
+ )
1109
+ ] }) : null
1110
+ ] }) : V === "sending" ? /* @__PURE__ */ r(se, { variant: "info", announce: "polite", className: "ds:w-full", children: /* @__PURE__ */ r(se.Title, { as: "p", children: h("prescription.sheet.sendingTitle") }) }) : /* @__PURE__ */ y(se, { variant: "error", className: "ds:w-full", children: [
1111
+ /* @__PURE__ */ r(se.Title, { as: "p", children: h("prescription.sheet.sendFailedTitle") }),
1112
+ /* @__PURE__ */ r(se.Description, { children: e.sendError ?? h("prescription.sheet.sendFailedBody") }),
1113
+ U ? /* @__PURE__ */ r(
1114
+ qe,
1115
+ {
1116
+ type: "button",
1117
+ intent: "primary",
1118
+ loading: F.has("resend"),
1119
+ onClick: () => g("resend", U),
1120
+ "data-action": "resend",
1121
+ className: "ds:mt-[var(--spacing-sm)] ds:min-h-[var(--min-target-size)]",
1122
+ children: h("prescription.sheet.resend")
1123
+ }
1124
+ ) : null
1125
+ ] })
1126
+ }
1127
+ ) : null,
1128
+ me ? /* @__PURE__ */ r(
1129
+ "div",
1130
+ {
1131
+ role: "group",
1132
+ "aria-label": h("prescription.sheet.actions"),
1133
+ "data-slot": "actions",
1134
+ className: "ds:flex ds:flex-wrap ds:items-center ds:justify-center ds:gap-[var(--spacing-sm)] ds:print:hidden",
1135
+ children: pe
1136
+ }
1137
+ ) : null,
1138
+ /* @__PURE__ */ r(
1139
+ rr,
1140
+ {
1141
+ ref: L,
1142
+ id: c ? `${c}-sheet` : void 0,
1143
+ size: n,
1144
+ density: l,
1145
+ isolateBrowserPrint: v,
1146
+ header: a,
1147
+ title: h("prescription.sheet.title"),
1148
+ date: e.createdAt,
1149
+ signature: {
1150
+ name: e.prescriber.name,
1151
+ detail: e.prescriber.specialty
1152
+ },
1153
+ children: /* @__PURE__ */ y("div", { className: Pr({ density: l }), children: [
1154
+ e.link || e.number ? /* @__PURE__ */ y(Zt, { children: [
1155
+ e.number ? /* @__PURE__ */ r(
1156
+ He,
1157
+ {
1158
+ label: o ?? h("prescription.sheet.number"),
1159
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.number }),
1160
+ mono: !0,
1161
+ "data-field": "number"
1162
+ }
1163
+ ) : null,
1164
+ e.link ? /* @__PURE__ */ r(
1165
+ He,
1166
+ {
1167
+ label: h(
1168
+ e.link.kind === "treatment" ? "prescription.sheet.treatment" : "prescription.sheet.carePlan"
1169
+ ),
1170
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.link.label }),
1171
+ "data-field": "link"
1172
+ }
1173
+ ) : null
1174
+ ] }) : null,
1175
+ /* @__PURE__ */ y(
1176
+ "section",
1177
+ {
1178
+ "aria-labelledby": S,
1179
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1180
+ children: [
1181
+ /* @__PURE__ */ r(
1182
+ "h3",
1183
+ {
1184
+ id: S,
1185
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1186
+ children: h("prescription.sheet.patient")
1187
+ }
1188
+ ),
1189
+ /* @__PURE__ */ r(
1190
+ Ye,
1191
+ {
1192
+ patient: e.patient,
1193
+ privacyMode: k,
1194
+ density: l
1195
+ }
1196
+ )
1197
+ ]
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ y(
1201
+ "section",
1202
+ {
1203
+ "aria-labelledby": P,
1204
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1205
+ children: [
1206
+ /* @__PURE__ */ r(
1207
+ "h3",
1208
+ {
1209
+ id: P,
1210
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1211
+ children: h("prescription.sheet.medications")
1212
+ }
1213
+ ),
1214
+ /* @__PURE__ */ r(
1215
+ er,
1216
+ {
1217
+ density: l,
1218
+ "aria-labelledby": P,
1219
+ children: e.items.map((u, ne) => /* @__PURE__ */ r(
1220
+ tr,
1221
+ {
1222
+ as: "li",
1223
+ medication: u.medication,
1224
+ dosage: u.dosage,
1225
+ notes: u.notes,
1226
+ codeLabel: d
1227
+ },
1228
+ `${u.medication.id}-${ne}`
1229
+ ))
1230
+ }
1231
+ )
1232
+ ]
1233
+ }
1234
+ )
1235
+ ] })
1236
+ }
1237
+ )
1238
+ ]
1239
+ }
1240
+ );
1241
+ }
1242
+ );
1243
+ Mr.displayName = "PrescriptionSheet";
1244
+ const Rr = _("ds:block ds:min-w-0 ds:w-full"), zr = _(
1245
+ "ds:inline-flex ds:min-w-0 ds:items-center ds:gap-[var(--spacing-xs)]"
1246
+ ), We = _("ds:min-w-0 ds:break-words"), Fr = _("ds:flex ds:flex-wrap ds:gap-[var(--spacing-2xs)]"), Br = "11rem", Or = _(
1247
+ "ds:min-w-0 ds:break-words ds:text-[color:var(--muted-foreground)]"
1248
+ ), _r = _("ds:font-mono ds:tabular-nums"), jr = [
1249
+ { colId: "date", sort: "desc" }
1250
+ ], Gr = {
1251
+ dateStyle: "medium",
1252
+ timeStyle: "short"
1253
+ };
1254
+ function mt(e, a) {
1255
+ const n = new Date(e.createdAt);
1256
+ return Number.isNaN(n.getTime()) ? e.createdAt : new Intl.DateTimeFormat(Le(a), Gr).format(
1257
+ n
1258
+ );
1259
+ }
1260
+ function ut({ name: e }) {
1261
+ return /* @__PURE__ */ y("span", { className: zr(), children: [
1262
+ /* @__PURE__ */ r(
1263
+ gt,
1264
+ {
1265
+ name: e,
1266
+ size: "xs",
1267
+ className: "ds:shrink-0",
1268
+ "aria-hidden": "true",
1269
+ role: "presentation",
1270
+ "aria-label": void 0
1271
+ }
1272
+ ),
1273
+ /* @__PURE__ */ r("span", { dir: "auto", className: We(), children: e })
1274
+ ] });
1275
+ }
1276
+ const Ri = Ae(function({
1277
+ records: a,
1278
+ status: n = "ready",
1279
+ onOpen: l,
1280
+ onReprint: d,
1281
+ onRetry: k,
1282
+ caption: v,
1283
+ showPatient: o = !1,
1284
+ privacyMode: N = !1,
1285
+ showSendStatus: R,
1286
+ id: $,
1287
+ className: j,
1288
+ ...D
1289
+ }, U) {
1290
+ const { t: c, i18n: X } = le("ui"), w = X.language || "en", z = l !== void 0 || d !== void 0, h = R ?? a.some((S) => S.sendStatus !== void 0), Q = $e(() => {
1291
+ const S = [];
1292
+ return l && S.push({
1293
+ id: "open",
1294
+ icon: /* @__PURE__ */ r(hr, {}),
1295
+ label: c("prescription.history.open"),
1296
+ onClick: l
1297
+ }), d && S.push({
1298
+ id: "reprint",
1299
+ icon: /* @__PURE__ */ r(vt, {}),
1300
+ label: c("prescription.history.reprint"),
1301
+ onClick: d
1302
+ }), S;
1303
+ }, [c, l, d]), G = $e(() => {
1304
+ const S = new Intl.Collator(Le(w)), P = (i) => mt(i, w), M = (i) => `${i.patient.lastName} ${i.patient.firstName}`.trim(), V = (i) => c(i === "treatment" ? "prescription.sheet.treatment" : "prescription.sheet.carePlan"), x = (i) => c(i === "sent" ? "prescription.status.sent" : i === "sending" ? "prescription.status.sending" : "prescription.status.failed"), p = /* @__PURE__ */ r("span", { className: Or(), children: c("prescription.history.notLinked") }), K = 3, I = 2, F = o ? 2 : 1, O = [
1305
+ {
1306
+ id: "date",
1307
+ header: c("prescription.history.date"),
1308
+ headerLabel: c("prescription.history.date"),
1309
+ rowHeader: !0,
1310
+ sort: "date",
1311
+ sortDescFirst: !0,
1312
+ value: (i) => new Date(i.createdAt),
1313
+ exportValue: P,
1314
+ filter: { kind: "dateRange" },
1315
+ search: !1,
1316
+ size: 130,
1317
+ wrap: !0,
1318
+ cell: (i) => /* @__PURE__ */ r("time", { dateTime: i.createdAt, children: P(i) })
1319
+ }
1320
+ ];
1321
+ if (h && (O.push({
1322
+ id: "number",
1323
+ header: c("prescription.history.number"),
1324
+ headerLabel: c("prescription.history.number"),
1325
+ responsiveTier: I,
1326
+ sort: "text",
1327
+ value: (i) => i.number ?? null,
1328
+ exportValue: (i) => i.number ?? "",
1329
+ filter: { kind: "text" },
1330
+ size: 132,
1331
+ cell: (i) => i.number ? /* @__PURE__ */ r("span", { dir: "ltr", className: _r(), children: i.number }) : null
1332
+ }), O.push({
1333
+ id: "status",
1334
+ header: c("prescription.history.status"),
1335
+ headerLabel: c("prescription.history.status"),
1336
+ responsiveTier: F,
1337
+ sort: "text",
1338
+ value: (i) => i.sendStatus ?? null,
1339
+ exportValue: (i) => i.sendStatus ? x(i.sendStatus) : "",
1340
+ filter: {
1341
+ kind: "select",
1342
+ options: ["sent", "sending", "failed"].map((i) => ({
1343
+ value: i,
1344
+ label: x(i)
1345
+ }))
1346
+ },
1347
+ search: !1,
1348
+ size: 112,
1349
+ cell: (i) => i.sendStatus ? /* @__PURE__ */ r(kt, { status: i.sendStatus }) : null
1350
+ })), o && O.push({
1351
+ id: "patient",
1352
+ header: c("prescription.history.patient"),
1353
+ headerLabel: c("prescription.history.patient"),
1354
+ responsiveTier: 1,
1355
+ wrap: !0,
1356
+ privacy: "mask",
1357
+ sort: (i, m) => S.compare(M(i), M(m)),
1358
+ value: M,
1359
+ exportValue: M,
1360
+ filter: { kind: "text" },
1361
+ size: 160,
1362
+ cell: (i) => /* @__PURE__ */ r(ut, { name: M(i) })
1363
+ }), O.push(
1364
+ {
1365
+ id: "linkKind",
1366
+ header: c("prescription.history.linkKind"),
1367
+ headerLabel: c("prescription.history.linkKind"),
1368
+ responsiveTier: K,
1369
+ sort: "text",
1370
+ value: (i) => {
1371
+ var m;
1372
+ return ((m = i.link) == null ? void 0 : m.kind) ?? null;
1373
+ },
1374
+ exportValue: (i) => i.link ? V(i.link.kind) : "",
1375
+ filter: {
1376
+ kind: "select",
1377
+ options: ["treatment", "carePlan"].map((i) => ({
1378
+ value: i,
1379
+ label: V(i)
1380
+ }))
1381
+ },
1382
+ search: !1,
1383
+ size: 100,
1384
+ cell: (i) => i.link ? /* @__PURE__ */ r(yt, { size: "sm", variant: "neutral", children: V(i.link.kind) }) : null
1385
+ },
1386
+ {
1387
+ id: "link",
1388
+ header: c("prescription.history.link"),
1389
+ headerLabel: c("prescription.history.link"),
1390
+ responsiveTier: K,
1391
+ wrap: !0,
1392
+ sort: "text",
1393
+ value: (i) => {
1394
+ var m;
1395
+ return ((m = i.link) == null ? void 0 : m.label) ?? null;
1396
+ },
1397
+ exportValue: (i) => {
1398
+ var m;
1399
+ return ((m = i.link) == null ? void 0 : m.label) ?? "";
1400
+ },
1401
+ filter: { kind: "text" },
1402
+ size: 130,
1403
+ cell: (i) => i.link ? /* @__PURE__ */ r("span", { dir: "auto", className: We(), children: i.link.label }) : p
1404
+ },
1405
+ {
1406
+ id: "medications",
1407
+ header: c("prescription.history.medications"),
1408
+ headerLabel: c("prescription.history.medications"),
1409
+ wrap: !0,
1410
+ value: (i) => i.items.map((m) => m.medication.name).join("; "),
1411
+ exportValue: (i) => i.items.map((m) => m.medication.name).join("; "),
1412
+ /* The grid's filters read one scalar per row, so the drug filter is
1413
+ a text "contains" on the names, not a list of drugs. */
1414
+ filter: { kind: "text" },
1415
+ size: 216,
1416
+ cell: (i) => /* @__PURE__ */ r("span", { className: Fr(), children: i.items.map((m, g) => /* @__PURE__ */ r(
1417
+ lr,
1418
+ {
1419
+ label: m.medication.name,
1420
+ size: "sm",
1421
+ variant: "neutral",
1422
+ maxInlineSize: Br
1423
+ },
1424
+ `${m.medication.id}-${g}`
1425
+ )) })
1426
+ },
1427
+ {
1428
+ id: "prescriber",
1429
+ header: c("prescription.history.prescriber"),
1430
+ headerLabel: c("prescription.history.prescriber"),
1431
+ responsiveTier: o ? K : I,
1432
+ wrap: !0,
1433
+ sort: "text",
1434
+ value: (i) => i.prescriber.name,
1435
+ exportValue: (i) => i.prescriber.name,
1436
+ filter: { kind: "select" },
1437
+ search: !0,
1438
+ size: 150,
1439
+ cell: (i) => /* @__PURE__ */ r(ut, { name: i.prescriber.name })
1440
+ },
1441
+ {
1442
+ id: "specialty",
1443
+ header: c("prescription.history.specialty"),
1444
+ headerLabel: c("prescription.history.specialty"),
1445
+ defaultHidden: !0,
1446
+ wrap: !0,
1447
+ sort: "text",
1448
+ value: (i) => i.prescriber.specialty ?? null,
1449
+ exportValue: (i) => i.prescriber.specialty ?? "",
1450
+ filter: { kind: "select" },
1451
+ size: 140,
1452
+ cell: (i) => i.prescriber.specialty ? /* @__PURE__ */ r("span", { dir: "auto", className: We(), children: i.prescriber.specialty }) : null
1453
+ }
1454
+ ), z) {
1455
+ const i = c("prescription.history.actions");
1456
+ O.push({
1457
+ id: "actions",
1458
+ header: /* @__PURE__ */ r(bt, { children: i }),
1459
+ headerLabel: i,
1460
+ pin: "end",
1461
+ size: 64,
1462
+ hideable: !1,
1463
+ reorderable: !1,
1464
+ pinnable: !1,
1465
+ resizable: !1,
1466
+ exportable: !1,
1467
+ printable: !1,
1468
+ search: !1,
1469
+ /* The kit RowActions leaf, menu only: one "Actions" button per row,
1470
+ named by reference with the row's own name. */
1471
+ cell: (m, g) => /* @__PURE__ */ r(
1472
+ dr,
1473
+ {
1474
+ row: m,
1475
+ actions: Q,
1476
+ maxInline: 0,
1477
+ "aria-labelledby": g.inputLabelledBy
1478
+ }
1479
+ )
1480
+ });
1481
+ }
1482
+ return O;
1483
+ }, [c, w, z, o, h, Q]), L = /* @__PURE__ */ y(ee, { children: [
1484
+ /* @__PURE__ */ y(ee.FilterBar, { children: [
1485
+ /* @__PURE__ */ r(ee.QuickSearch, {}),
1486
+ /* @__PURE__ */ r(ee.FilterChips, {})
1487
+ ] }),
1488
+ /* @__PURE__ */ r(ee.Actions, { children: /* @__PURE__ */ y(cr, { "aria-label": c("dataTable.tableActions"), children: [
1489
+ /* @__PURE__ */ r(ee.ExportMenu, {}),
1490
+ /* @__PURE__ */ r(ee.Print, {}),
1491
+ /* @__PURE__ */ r(ee.ColumnToggle, {})
1492
+ ] }) })
1493
+ ] });
1494
+ return /* @__PURE__ */ r(
1495
+ "div",
1496
+ {
1497
+ ...D,
1498
+ ref: U,
1499
+ "data-component": "prescription-history",
1500
+ "data-component-id": $,
1501
+ className: Rr({ className: j }),
1502
+ children: /* @__PURE__ */ r(
1503
+ pr,
1504
+ {
1505
+ columns: G,
1506
+ rows: a,
1507
+ getRowId: (S) => S.id,
1508
+ getRowLabel: (S) => {
1509
+ const P = c("prescription.history.rowLabel", {
1510
+ date: mt(S, w)
1511
+ });
1512
+ return o ? `${P}, ${S.patient.lastName} ${S.patient.firstName}` : P;
1513
+ },
1514
+ privacyMode: N,
1515
+ toolbar: L,
1516
+ caption: v ?? c("prescription.history.caption"),
1517
+ defaultSorting: jr,
1518
+ status: n,
1519
+ gridId: $ ? `${$}-grid` : void 0,
1520
+ empty: {
1521
+ title: c("prescription.history.emptyTitle"),
1522
+ description: c("prescription.history.emptyBody")
1523
+ },
1524
+ error: {
1525
+ title: c("prescription.history.errorTitle"),
1526
+ onRetry: k
1527
+ }
1528
+ }
1529
+ )
1530
+ }
1531
+ );
1532
+ });
1533
+ export {
1534
+ Ee as E,
1535
+ Er as P,
1536
+ Ri as a,
1537
+ Mr as b,
1538
+ Sr as c,
1539
+ dt as d,
1540
+ Ke as i,
1541
+ Tr as n,
1542
+ lt as v
1543
+ };
1544
+ //# sourceMappingURL=prescription-history-748qDVwZ.js.map