@alfadocs/ui-kit-debug 1.36.1 → 1.37.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 (230) hide show
  1. package/dist/_chunks/appointment-peek-5S4O1VQP.js +115 -0
  2. package/dist/_chunks/appointment-peek-5S4O1VQP.js.map +1 -0
  3. package/dist/_chunks/appointment-peek.agent-C539tNFM.js +17 -0
  4. package/dist/_chunks/appointment-peek.agent-C539tNFM.js.map +1 -0
  5. package/dist/_chunks/building-2-D33bLCWL.js +24 -0
  6. package/dist/_chunks/building-2-D33bLCWL.js.map +1 -0
  7. package/dist/_chunks/calendar-workspace-BqKBj26r.js +9715 -0
  8. package/dist/_chunks/calendar-workspace-BqKBj26r.js.map +1 -0
  9. package/dist/_chunks/{control-room-rail-Ds45_g4f.js → control-room-rail-DQoHdE1U.js} +2 -2
  10. package/dist/_chunks/{control-room-rail-Ds45_g4f.js.map → control-room-rail-DQoHdE1U.js.map} +1 -1
  11. package/dist/_chunks/editable-description-BOfAeY3T.js +112 -0
  12. package/dist/_chunks/editable-description-BOfAeY3T.js.map +1 -0
  13. package/dist/_chunks/editable-description.agent-Bm_LBV2j.js +21 -0
  14. package/dist/_chunks/editable-description.agent-Bm_LBV2j.js.map +1 -0
  15. package/dist/_chunks/{money.agent-Dw55UxUA.js → money-BY-HmKhZ.js} +33 -47
  16. package/dist/_chunks/money-BY-HmKhZ.js.map +1 -0
  17. package/dist/_chunks/money.agent-BjJ6gOkx.js +17 -0
  18. package/dist/_chunks/money.agent-BjJ6gOkx.js.map +1 -0
  19. package/dist/_chunks/notes-panel-4y5JioWN.js +556 -0
  20. package/dist/_chunks/notes-panel-4y5JioWN.js.map +1 -0
  21. package/dist/_chunks/panel-subview-BNXN8OEL.js +160 -0
  22. package/dist/_chunks/panel-subview-BNXN8OEL.js.map +1 -0
  23. package/dist/_chunks/panel-subview.agent-BIBvE-IW.js +17 -0
  24. package/dist/_chunks/panel-subview.agent-BIBvE-IW.js.map +1 -0
  25. package/dist/_chunks/{patient-details-f7SSXkTJ.js → patient-details-2cIaL-Zb.js} +2 -2
  26. package/dist/_chunks/{patient-details-f7SSXkTJ.js.map → patient-details-2cIaL-Zb.js.map} +1 -1
  27. package/dist/_chunks/{patient-field-row-BQZoP4m2.js → patient-field-row-IHb2VFc2.js} +193 -172
  28. package/dist/_chunks/patient-field-row-IHb2VFc2.js.map +1 -0
  29. package/dist/_chunks/{patient-summary-card-Bz7KdUin.js → patient-summary-card-BzmJH9a-.js} +2 -2
  30. package/dist/_chunks/{patient-summary-card-Bz7KdUin.js.map → patient-summary-card-BzmJH9a-.js.map} +1 -1
  31. package/dist/_chunks/{section-card.agent-W18CHEgX.js → section-card-XR2bW1Ie.js} +20 -34
  32. package/dist/_chunks/{section-card.agent-W18CHEgX.js.map → section-card-XR2bW1Ie.js.map} +1 -1
  33. package/dist/_chunks/section-card.agent-Bz1BhM_j.js +17 -0
  34. package/dist/_chunks/section-card.agent-Bz1BhM_j.js.map +1 -0
  35. package/dist/_chunks/smartphone-DaPcFw-X.js +32 -0
  36. package/dist/_chunks/smartphone-DaPcFw-X.js.map +1 -0
  37. package/dist/_chunks/{task-card-BalrLkSz.js → task-card-qTKD1fIT.js} +39 -57
  38. package/dist/_chunks/task-card-qTKD1fIT.js.map +1 -0
  39. package/dist/_chunks/{task-tray-wl9eti6J.js → task-tray-CQ8UAR2j.js} +2 -2
  40. package/dist/_chunks/{task-tray-wl9eti6J.js.map → task-tray-CQ8UAR2j.js.map} +1 -1
  41. package/dist/_chunks/{tasks-panel-BDNB7hsZ.js → tasks-panel-CBGMtQ_f.js} +2 -2
  42. package/dist/_chunks/{tasks-panel-BDNB7hsZ.js.map → tasks-panel-CBGMtQ_f.js.map} +1 -1
  43. package/dist/_chunks/{tool-rail-Bq5eiFMG.js → tool-rail-BP8sjxCw.js} +310 -231
  44. package/dist/_chunks/tool-rail-BP8sjxCw.js.map +1 -0
  45. package/dist/_chunks/treatment-receipt-D4kOLXOk.js +94 -0
  46. package/dist/_chunks/treatment-receipt-D4kOLXOk.js.map +1 -0
  47. package/dist/_chunks/treatment-receipt.agent-bpFm2RPH.js +21 -0
  48. package/dist/_chunks/treatment-receipt.agent-bpFm2RPH.js.map +1 -0
  49. package/dist/_chunks/use-presence-transition-cDwWUXV-.js +58 -0
  50. package/dist/_chunks/use-presence-transition-cDwWUXV-.js.map +1 -0
  51. package/dist/_chunks/{workflow-map-D-LEni11.js → workflow-map-CXdsxvUj.js} +140 -156
  52. package/dist/_chunks/workflow-map-CXdsxvUj.js.map +1 -0
  53. package/dist/agent-catalog.json +65 -1
  54. package/dist/components/appointment-peek/appointment-peek.agent.d.ts +3 -0
  55. package/dist/components/appointment-peek/appointment-peek.agent.d.ts.map +1 -0
  56. package/dist/components/appointment-peek/appointment-peek.d.ts +45 -0
  57. package/dist/components/appointment-peek/appointment-peek.d.ts.map +1 -0
  58. package/dist/components/appointment-peek/index.d.ts +4 -0
  59. package/dist/components/appointment-peek/index.d.ts.map +1 -0
  60. package/dist/components/appointment-peek/index.js +7 -0
  61. package/dist/components/appointment-peek/index.js.map +1 -0
  62. package/dist/components/control-room-rail/index.js +1 -1
  63. package/dist/components/editable-description/editable-description.agent.d.ts +3 -0
  64. package/dist/components/editable-description/editable-description.agent.d.ts.map +1 -0
  65. package/dist/components/editable-description/editable-description.d.ts +20 -0
  66. package/dist/components/editable-description/editable-description.d.ts.map +1 -0
  67. package/dist/components/editable-description/index.d.ts +4 -0
  68. package/dist/components/editable-description/index.d.ts.map +1 -0
  69. package/dist/components/editable-description/index.js +7 -0
  70. package/dist/components/editable-description/index.js.map +1 -0
  71. package/dist/components/index.d.ts +4 -0
  72. package/dist/components/index.d.ts.map +1 -1
  73. package/dist/components/money/index.js +2 -1
  74. package/dist/components/money/index.js.map +1 -1
  75. package/dist/components/notes-panel/index.js +1 -1
  76. package/dist/components/notes-panel/notes-panel.d.ts +16 -0
  77. package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
  78. package/dist/components/panel-subview/index.d.ts +4 -0
  79. package/dist/components/panel-subview/index.d.ts.map +1 -0
  80. package/dist/components/panel-subview/index.js +7 -0
  81. package/dist/components/panel-subview/index.js.map +1 -0
  82. package/dist/components/panel-subview/panel-subview.agent.d.ts +3 -0
  83. package/dist/components/panel-subview/panel-subview.agent.d.ts.map +1 -0
  84. package/dist/components/panel-subview/panel-subview.d.ts +32 -0
  85. package/dist/components/panel-subview/panel-subview.d.ts.map +1 -0
  86. package/dist/components/patient-details/index.js +1 -1
  87. package/dist/components/patient-summary-card/index.js +1 -1
  88. package/dist/components/section-card/index.js +4 -3
  89. package/dist/components/section-card/index.js.map +1 -1
  90. package/dist/components/task-card/index.js +1 -1
  91. package/dist/components/task-tray/index.js +1 -1
  92. package/dist/components/tasks-panel/index.js +1 -1
  93. package/dist/components/tool-rail/index.js +1 -1
  94. package/dist/components/tool-rail/tool-rail.d.ts.map +1 -1
  95. package/dist/components/treatment-receipt/index.d.ts +4 -0
  96. package/dist/components/treatment-receipt/index.d.ts.map +1 -0
  97. package/dist/components/treatment-receipt/index.js +7 -0
  98. package/dist/components/treatment-receipt/index.js.map +1 -0
  99. package/dist/components/treatment-receipt/treatment-receipt.agent.d.ts +3 -0
  100. package/dist/components/treatment-receipt/treatment-receipt.agent.d.ts.map +1 -0
  101. package/dist/components/treatment-receipt/treatment-receipt.d.ts +30 -0
  102. package/dist/components/treatment-receipt/treatment-receipt.d.ts.map +1 -0
  103. package/dist/components/workflow/index.js +1 -1
  104. package/dist/hooks/index.d.ts +1 -0
  105. package/dist/hooks/index.d.ts.map +1 -1
  106. package/dist/hooks/index.js +9 -7
  107. package/dist/hooks/index.js.map +1 -1
  108. package/dist/hooks/use-presence-transition.d.ts +40 -0
  109. package/dist/hooks/use-presence-transition.d.ts.map +1 -0
  110. package/dist/host-compat.css +7 -1
  111. package/dist/i18n/locales/ar.d.ts +29 -5
  112. package/dist/i18n/locales/ar.d.ts.map +1 -1
  113. package/dist/i18n/locales/ar.js +29 -5
  114. package/dist/i18n/locales/ar.js.map +1 -1
  115. package/dist/i18n/locales/de.d.ts +29 -5
  116. package/dist/i18n/locales/de.d.ts.map +1 -1
  117. package/dist/i18n/locales/de.js +29 -5
  118. package/dist/i18n/locales/de.js.map +1 -1
  119. package/dist/i18n/locales/el.d.ts +29 -5
  120. package/dist/i18n/locales/el.d.ts.map +1 -1
  121. package/dist/i18n/locales/el.js +29 -5
  122. package/dist/i18n/locales/el.js.map +1 -1
  123. package/dist/i18n/locales/en.d.ts +29 -5
  124. package/dist/i18n/locales/en.d.ts.map +1 -1
  125. package/dist/i18n/locales/en.js +29 -5
  126. package/dist/i18n/locales/en.js.map +1 -1
  127. package/dist/i18n/locales/es.d.ts +29 -5
  128. package/dist/i18n/locales/es.d.ts.map +1 -1
  129. package/dist/i18n/locales/es.js +29 -5
  130. package/dist/i18n/locales/es.js.map +1 -1
  131. package/dist/i18n/locales/fr.d.ts +29 -5
  132. package/dist/i18n/locales/fr.d.ts.map +1 -1
  133. package/dist/i18n/locales/fr.js +29 -5
  134. package/dist/i18n/locales/fr.js.map +1 -1
  135. package/dist/i18n/locales/hi.d.ts +29 -5
  136. package/dist/i18n/locales/hi.d.ts.map +1 -1
  137. package/dist/i18n/locales/hi.js +29 -5
  138. package/dist/i18n/locales/hi.js.map +1 -1
  139. package/dist/i18n/locales/it.d.ts +29 -5
  140. package/dist/i18n/locales/it.d.ts.map +1 -1
  141. package/dist/i18n/locales/it.js +29 -5
  142. package/dist/i18n/locales/it.js.map +1 -1
  143. package/dist/i18n/locales/ja.d.ts +29 -5
  144. package/dist/i18n/locales/ja.d.ts.map +1 -1
  145. package/dist/i18n/locales/ja.js +29 -5
  146. package/dist/i18n/locales/ja.js.map +1 -1
  147. package/dist/i18n/locales/nl.d.ts +29 -5
  148. package/dist/i18n/locales/nl.d.ts.map +1 -1
  149. package/dist/i18n/locales/nl.js +29 -5
  150. package/dist/i18n/locales/nl.js.map +1 -1
  151. package/dist/i18n/locales/pl.d.ts +29 -5
  152. package/dist/i18n/locales/pl.d.ts.map +1 -1
  153. package/dist/i18n/locales/pl.js +29 -5
  154. package/dist/i18n/locales/pl.js.map +1 -1
  155. package/dist/i18n/locales/pt.d.ts +29 -5
  156. package/dist/i18n/locales/pt.d.ts.map +1 -1
  157. package/dist/i18n/locales/pt.js +29 -5
  158. package/dist/i18n/locales/pt.js.map +1 -1
  159. package/dist/i18n/locales/ro.d.ts +29 -5
  160. package/dist/i18n/locales/ro.d.ts.map +1 -1
  161. package/dist/i18n/locales/ro.js +29 -5
  162. package/dist/i18n/locales/ro.js.map +1 -1
  163. package/dist/i18n/locales/ru.d.ts +29 -5
  164. package/dist/i18n/locales/ru.d.ts.map +1 -1
  165. package/dist/i18n/locales/ru.js +29 -5
  166. package/dist/i18n/locales/ru.js.map +1 -1
  167. package/dist/i18n/locales/sq.d.ts +29 -5
  168. package/dist/i18n/locales/sq.d.ts.map +1 -1
  169. package/dist/i18n/locales/sq.js +29 -5
  170. package/dist/i18n/locales/sq.js.map +1 -1
  171. package/dist/i18n/locales/sv.d.ts +29 -5
  172. package/dist/i18n/locales/sv.d.ts.map +1 -1
  173. package/dist/i18n/locales/sv.js +29 -5
  174. package/dist/i18n/locales/sv.js.map +1 -1
  175. package/dist/i18n/locales/tr.d.ts +29 -5
  176. package/dist/i18n/locales/tr.d.ts.map +1 -1
  177. package/dist/i18n/locales/tr.js +29 -5
  178. package/dist/i18n/locales/tr.js.map +1 -1
  179. package/dist/i18n/locales/zh.d.ts +29 -5
  180. package/dist/i18n/locales/zh.d.ts.map +1 -1
  181. package/dist/i18n/locales/zh.js +29 -5
  182. package/dist/i18n/locales/zh.js.map +1 -1
  183. package/dist/index.js +958 -940
  184. package/dist/index.js.map +1 -1
  185. package/dist/locales/ar.json +29 -5
  186. package/dist/locales/de.json +29 -5
  187. package/dist/locales/el.json +29 -5
  188. package/dist/locales/en.json +29 -5
  189. package/dist/locales/es.json +29 -5
  190. package/dist/locales/fr.json +29 -5
  191. package/dist/locales/hi.json +29 -5
  192. package/dist/locales/it.json +29 -5
  193. package/dist/locales/ja.json +29 -5
  194. package/dist/locales/nl.json +29 -5
  195. package/dist/locales/pl.json +29 -5
  196. package/dist/locales/pt.json +29 -5
  197. package/dist/locales/ro.json +29 -5
  198. package/dist/locales/ru.json +29 -5
  199. package/dist/locales/sq.json +29 -5
  200. package/dist/locales/sv.json +29 -5
  201. package/dist/locales/tr.json +29 -5
  202. package/dist/locales/zh.json +29 -5
  203. package/dist/patterns/calendar/calendar-appointment-details.d.ts +15 -6
  204. package/dist/patterns/calendar/calendar-appointment-details.d.ts.map +1 -1
  205. package/dist/patterns/calendar/calendar-appointment-details.sections.d.ts +23 -23
  206. package/dist/patterns/calendar/calendar-appointment-details.sections.d.ts.map +1 -1
  207. package/dist/patterns/calendar/calendar-info-hover.d.ts +18 -0
  208. package/dist/patterns/calendar/calendar-info-hover.d.ts.map +1 -0
  209. package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
  210. package/dist/patterns/calendar/calendar.journey.d.ts +10 -0
  211. package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
  212. package/dist/patterns/calendar/calendar.sheets.d.ts +2 -2
  213. package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
  214. package/dist/patterns/calendar/calendar.surface.d.ts.map +1 -1
  215. package/dist/patterns/calendar/index.js +1 -1
  216. package/dist/tokens.css +1 -1
  217. package/package.json +17 -1
  218. package/dist/_chunks/calendar-workspace-BYwQK7fz.js +0 -9478
  219. package/dist/_chunks/calendar-workspace-BYwQK7fz.js.map +0 -1
  220. package/dist/_chunks/hourglass-BEAzW1wE.js +0 -26
  221. package/dist/_chunks/hourglass-BEAzW1wE.js.map +0 -1
  222. package/dist/_chunks/money.agent-Dw55UxUA.js.map +0 -1
  223. package/dist/_chunks/notes-panel-Co8D3uDd.js +0 -469
  224. package/dist/_chunks/notes-panel-Co8D3uDd.js.map +0 -1
  225. package/dist/_chunks/patient-field-row-BQZoP4m2.js.map +0 -1
  226. package/dist/_chunks/smartphone-C0rFF2if.js +0 -15
  227. package/dist/_chunks/smartphone-C0rFF2if.js.map +0 -1
  228. package/dist/_chunks/task-card-BalrLkSz.js.map +0 -1
  229. package/dist/_chunks/tool-rail-Bq5eiFMG.js.map +0 -1
  230. package/dist/_chunks/workflow-map-D-LEni11.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patient-field-row-IHb2VFc2.js","sources":["../../node_modules/lucide-react/dist/esm/icons/hourglass.mjs","../../node_modules/lucide-react/dist/esm/icons/mars.mjs","../../node_modules/lucide-react/dist/esm/icons/venus.mjs","../../src/components/_shared/patient-fields.ts","../../src/components/_shared/field-visibility.ts","../../src/components/_shared/field-visibility-cog.tsx","../../src/components/_shared/field-value.tsx","../../src/components/_shared/patient-field-row.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M5 22h14\", key: \"ehvnwv\" }],\n [\"path\", { d: \"M5 2h14\", key: \"pdyrp9\" }],\n [\n \"path\",\n {\n d: \"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22\",\n key: \"1d314k\"\n }\n ],\n [\n \"path\",\n { d: \"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2\", key: \"1vvvr6\" }\n ]\n];\nconst Hourglass = createLucideIcon(\"hourglass\", __iconNode);\n\nexport { __iconNode, Hourglass as default };\n//# sourceMappingURL=hourglass.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M16 3h5v5\", key: \"1806ms\" }],\n [\"path\", { d: \"m21 3-6.75 6.75\", key: \"pv0uzu\" }],\n [\"circle\", { cx: \"10\", cy: \"14\", r: \"6\", key: \"1qwbdc\" }]\n];\nconst Mars = createLucideIcon(\"mars\", __iconNode);\n\nexport { __iconNode, Mars as default };\n//# sourceMappingURL=mars.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 15v7\", key: \"t2xh3l\" }],\n [\"path\", { d: \"M9 19h6\", key: \"456am0\" }],\n [\"circle\", { cx: \"12\", cy: \"9\", r: \"6\", key: \"1nw4tq\" }]\n];\nconst Venus = createLucideIcon(\"venus\", __iconNode);\n\nexport { __iconNode, Venus as default };\n//# sourceMappingURL=venus.mjs.map\n","import type { ReactElement, ReactNode } from 'react';\n\n/* -------------------------------------------------------------------- */\n/* Shared patient-field model */\n/* */\n/* The single field VOCABULARY every patient surface speaks — consumed */\n/* by both `PatientDetails` (full, inline-editable) and */\n/* `PatientSummaryCard` (compact). Either can surface a \"Customize */\n/* fields\" cog (show/hide + drag-and-drop reorder). The kit owns the */\n/* SHAPE; the CONSUMER owns the registry (which DoctorPatient field maps */\n/* to which id/label/PHI flag). */\n/* */\n/* Visibility + order are PER-CONTEXT, not global: the kit never persists */\n/* them — each PLACEMENT is wired to its own `visibleFieldOrder` / */\n/* `onVisibleFieldsChange`, so the SAME vocabulary can display */\n/* differently in different parts of the app (a care-plan card vs the */\n/* patient folder). The consumer chooses the persistence scope — global */\n/* per-user, or per-surface (PRS §Security; design doc D1/D2). */\n/* -------------------------------------------------------------------- */\n\n/**\n * Canonical field TYPE. When set (and no explicit `value` is supplied), the\n * kit renders the field's canonical chip from the shared `<FieldValue>`\n * registry instead of plain text — so the SAME field type looks the same on\n * every surface. Each chip is a high-contrast neutral pill with a glyph:\n *\n * - `sex` → Venus / Mars / User glyph + localised label\n * - `age` → hourglass glyph + localised, pluralised age\n * - `dob` → calendar glyph + locale-formatted date\n * - `fiscalCode` → hash glyph + monospace code (already mono — no `mono` flag\n * needed; copy + PHI lock stay the row-level affordance via\n * `copyable` / `sensitive`)\n * - `discount` → `TransactionChip` `state=\"discount\"` (the canonical monetary\n * discount chip — magnitude + `currency`, sign owned by the chip)\n * - `email` → a `mailto:` `Link` (the address is both display + target)\n * - `phone` → a `tel:` `Link` (formatted display, target normalised to\n * `+` and digits)\n *\n * The raw datum is read from `editValue` (the same scalar that seeds the\n * editor): a number for `age` / `discount`, an ISO string or `Date` for `dob`,\n * a code string for `sex`, the code string for `fiscalCode`. For the contact\n * link kinds the DISPLAY string is read from `value` (or `editValue`) and the\n * href is derived from it — so a plain-string `value` still becomes a link.\n * For every OTHER kind an explicit `value` ALWAYS wins, so a consumer can still\n * override per placement.\n */\nexport type PatientFieldKind =\n | 'sex'\n | 'age'\n | 'dob'\n | 'fiscalCode'\n | 'discount'\n | 'email'\n | 'phone';\n\n/** Editor control rendered when a field enters inline-edit mode. */\nexport type PatientFieldEditType =\n | 'text'\n | 'textarea'\n | 'select'\n | 'boolean'\n | 'date'\n | 'number'\n // Typed text variants — each renders the kit's dedicated input (validation,\n // formatting, masking) instead of a bare TextInput. Their edited value still\n // serialises to a plain string through the shared save callback.\n | 'email'\n | 'phone'\n | 'fiscalCode'\n // Address / location variants — each renders the dedicated kit picker.\n // `province`/`country`/`city` emit a plain string (UPPER sigla / alpha-2\n // lower / city name); `postalCode` validates the IT CAP format on blur.\n | 'province'\n | 'country'\n | 'postalCode'\n | 'city';\n\n/** A choice for an `editType: 'select'` field. */\nexport interface PatientFieldOption {\n value: string;\n label: string;\n}\n\n/**\n * Raw value seeded into an editor. The kit never inspects this beyond\n * handing it to the matching control and back through a save callback.\n */\nexport type PatientFieldEditValue =\n | string\n | number\n | boolean\n | Date\n | null\n | undefined;\n\n/** One label→value patient field. */\nexport interface PatientField {\n /**\n * Stable field key — drives visibility, ordering, the `data-field-id`\n * hook, and agent addressing. MUST NOT be the value (no PHI in keys).\n */\n id: string;\n /** Display label (already localised by the consumer, or a kit label). */\n label: string;\n /**\n * Display node — formatted by the consumer (Badge / Tag / Link / text).\n * Optional: omit it and set `kind` to let the kit render the field's\n * canonical chip from `editValue`. When present, `value` ALWAYS wins.\n */\n value?: ReactNode;\n /**\n * Canonical field type — when set and `value` is omitted, the kit renders\n * the matching canonical chip from the shared registry. Presentation only;\n * NEVER emitted into any `data-*` attribute (same rule as `sensitive`).\n */\n kind?: PatientFieldKind;\n /** Leading icon (a single lucide element). */\n icon?: ReactElement | null;\n /** Render the copy-to-clipboard affordance (fiscal code, ids). */\n copyable?: boolean;\n /** Text written to the clipboard when `copyable`. */\n copyText?: string;\n /** Render the value monospaced (codes, ids). */\n mono?: boolean;\n /**\n * High-sensitivity PHI marker — renders a lock glyph next to the label.\n * Presentation only; NEVER emitted into any `data-*` attribute.\n */\n sensitive?: boolean;\n /** Whether this field can be inline-edited (consumer gates by permission). */\n editable?: boolean;\n /** Control used in edit mode. Defaults to `'text'`. */\n editType?: PatientFieldEditType;\n /** Options for `editType: 'select'`. */\n options?: PatientFieldOption[];\n /** Value seeded into the editor when editing begins. */\n editValue?: PatientFieldEditValue;\n /** Currency code for `editType: 'number'` (renders a currency input). */\n currency?: string;\n}\n\n/** A labelled, collapsible group of fields. */\nexport interface PatientFieldSection {\n /** Stable section key. */\n id: string;\n /** Section heading. */\n heading: string;\n fields: PatientField[];\n /** Wrap the section in a Collapsible (default `true`). Honoured by PatientDetails. */\n collapsible?: boolean;\n /** Initial open state when `collapsible` (default `true`). */\n defaultOpen?: boolean;\n}\n\n/** The flat declaration-order list of every field id — the \"show everything\" default. */\nexport function patientFieldCatalogue(\n sections: PatientFieldSection[],\n): string[] {\n return sections.flatMap((s) => s.fields.map((f) => f.id));\n}\n\n/** A section paired with its currently-visible fields, in the chosen order. */\nexport interface ResolvedPatientSection {\n section: PatientFieldSection;\n fields: PatientField[];\n}\n\n/**\n * Project `sections` to the visible fields per section, ordered by\n * `visibleFieldOrder`. This is the single piece of visibility logic shared\n * by every patient surface, so the card and the details panel always agree\n * on what is shown and in what order.\n *\n * `visibleFieldOrder` omitted (`undefined`) ⇒ every field visible in\n * declaration order (\"show everything by default\", design doc D3). An explicit\n * empty array `[]` ⇒ NO fields visible — a surface that starts collapsed and\n * reveals fields via the customize-fields cog. Unknown ids are ignored.\n * Sections stay in declaration order; only intra-section field order follows\n * `visibleFieldOrder`.\n */\nexport function resolveVisibleFields(\n sections: PatientFieldSection[],\n visibleFieldOrder?: string[],\n): ResolvedPatientSection[] {\n const order = visibleFieldOrder ?? patientFieldCatalogue(sections);\n const orderIndex = new Map(order.map((id, index) => [id, index]));\n return sections.map((section) => ({\n section,\n fields: section.fields\n .filter((field) => orderIndex.has(field.id))\n .sort(\n (a, b) =>\n (orderIndex.get(a.id) as number) - (orderIndex.get(b.id) as number),\n ),\n }));\n}\n","import { useCallback, useMemo } from 'react';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport {\n patientFieldCatalogue,\n type PatientField,\n type PatientFieldSection,\n} from './patient-fields';\n\n/* -------------------------------------------------------------------- */\n/* usePatientFieldVisibility */\n/* */\n/* The single visibility + ordering engine behind the patient field */\n/* picker, shared by every surface that lets a user curate which patient */\n/* fields show and in what order (PatientDetails, PatientSummaryCard). */\n/* */\n/* CONTEXT-SCOPED, not global: the order is a per-INSTANCE prop the kit */\n/* never persists. Each placement (a care-plan card, the patient-folder */\n/* summary, the Control Room details panel) is wired to its OWN */\n/* `value` / `onChange`, so the SAME field vocabulary can be displayed */\n/* differently in different parts of the app. The consumer owns the */\n/* persistence scope — global per-user, or per-context. */\n/* */\n/* Every mutation filters to known field ids, so persisted / agent input */\n/* can never smuggle an unknown key into the visible set. */\n/* -------------------------------------------------------------------- */\n\nexport interface UsePatientFieldVisibilityOptions {\n /** Controlled ordered list of visible field ids. */\n value?: string[];\n /** Uncontrolled initial order. Omit both ⇒ every field, declaration order. */\n defaultValue?: string[];\n /** Fired on any show / hide / reorder, with the next ordered visible set. */\n onChange?: (orderedIds: string[]) => void;\n}\n\nexport interface PatientFieldVisibility {\n /** Current ordered list of visible field ids (filtered to known fields). */\n visible: string[];\n /** Flat declaration-order catalogue of every field id (\"show everything\"). */\n catalogueIds: string[];\n /** field id → its field + owning section id. */\n fieldById: Map<string, { field: PatientField; sectionId: string }>;\n /** Replace the visible set / order (filtered to known fields). */\n setOrder: (orderedIds: string[]) => void;\n /** Show or hide a single field. */\n toggleField: (fieldId: string) => void;\n /** Show or hide every field in a section. */\n toggleSection: (sectionId: string, show: boolean) => void;\n /**\n * Move a field to land at another field's slot, WITHIN its section's\n * visible subsequence. Cross-section moves are ignored — sections stay in\n * declaration order. Drives both pointer drops and keyboard (Alt+Arrow).\n */\n moveFieldOnto: (fromId: string, toId: string) => void;\n /** Reset to `defaultValue` (or the full catalogue when none was given). */\n reset: () => void;\n}\n\nexport function usePatientFieldVisibility(\n sections: PatientFieldSection[],\n { value, defaultValue, onChange }: UsePatientFieldVisibilityOptions = {},\n): PatientFieldVisibility {\n const catalogueIds = useMemo(\n () => patientFieldCatalogue(sections),\n [sections],\n );\n\n const [orderState, setOrderState] = useControllableState<string[]>({\n value,\n defaultValue: defaultValue ?? catalogueIds,\n onChange,\n });\n // `useControllableState` may yield `undefined` before the first write.\n const visible = orderState ?? defaultValue ?? catalogueIds;\n\n const fieldById = useMemo(() => {\n const map = new Map<string, { field: PatientField; sectionId: string }>();\n for (const section of sections) {\n for (const field of section.fields) {\n map.set(field.id, { field, sectionId: section.id });\n }\n }\n return map;\n }, [sections]);\n\n const setOrder = useCallback(\n (next: string[]) => {\n // Drop unknown ids so persisted / agent input can't smuggle keys.\n setOrderState(next.filter((fid) => fieldById.has(fid)));\n },\n [setOrderState, fieldById],\n );\n\n const toggleField = useCallback(\n (fieldId: string) => {\n setOrder(\n visible.includes(fieldId)\n ? visible.filter((fid) => fid !== fieldId)\n : [...visible, fieldId],\n );\n },\n [visible, setOrder],\n );\n\n const toggleSection = useCallback(\n (sectionId: string, show: boolean) => {\n const sectionIds =\n sections.find((s) => s.id === sectionId)?.fields.map((f) => f.id) ?? [];\n const sectionSet = new Set(sectionIds);\n if (show) {\n const missing = sectionIds.filter((fid) => !visible.includes(fid));\n setOrder([...visible, ...missing]);\n } else {\n setOrder(visible.filter((fid) => !sectionSet.has(fid)));\n }\n },\n [sections, visible, setOrder],\n );\n\n const moveFieldOnto = useCallback(\n (fromId: string, toId: string) => {\n if (fromId === toId) return;\n const fromSection = fieldById.get(fromId)?.sectionId;\n const toSection = fieldById.get(toId)?.sectionId;\n if (!fromSection || fromSection !== toSection) return;\n const sectionIds = new Set(\n sections.find((s) => s.id === fromSection)?.fields.map((f) => f.id) ??\n [],\n );\n const siblings = visible.filter((fid) => sectionIds.has(fid));\n const fromIdx = siblings.indexOf(fromId);\n const toIdx = siblings.indexOf(toId);\n if (fromIdx < 0 || toIdx < 0) return;\n const [moved] = siblings.splice(fromIdx, 1);\n siblings.splice(toIdx, 0, moved);\n // Splice the reordered siblings back into their positions in `visible`.\n let k = 0;\n const next = visible.map((fid) =>\n sectionIds.has(fid) ? siblings[k++] : fid,\n );\n setOrder(next);\n },\n [fieldById, sections, visible, setOrder],\n );\n\n const reset = useCallback(() => {\n setOrder(defaultValue ?? catalogueIds);\n }, [defaultValue, catalogueIds, setOrder]);\n\n return {\n visible,\n catalogueIds,\n fieldById,\n setOrder,\n toggleField,\n toggleSection,\n moveFieldOnto,\n reset,\n };\n}\n","import {\n useCallback,\n useMemo,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { GripVertical, Settings } from 'lucide-react';\nimport { Button, IconButton } from '../button';\nimport { Checkbox } from '../checkbox/checkbox';\nimport { Popover } from '../popover/popover';\nimport { Separator } from '../separator/separator';\nimport type { PatientFieldSection } from './patient-fields';\n\n/* -------------------------------------------------------------------- */\n/* FieldVisibilityCog — the patient field picker */\n/* */\n/* The shared \"Customize fields\" cog: a Popover of per-field checkboxes */\n/* (grouped by section, with a section-level toggle-all where the section */\n/* is named), a drag handle per visible field for pointer reordering, and */\n/* the canonical Sidebar keyboard reorder gesture (Alt+Arrow / Alt+Home / */\n/* Alt+End) with an sr-only live announcement. Pure UI — the visibility */\n/* state + reducers live in `usePatientFieldVisibility`, so PatientDetails */\n/* and PatientSummaryCard share ONE picker driving each surface's own */\n/* per-context order. */\n/* */\n/* Native-HTML5 DnD (no library), mirroring data-table's ColumnToggle; */\n/* the grip adds the keyboard channel that pattern lacks. Sections with an */\n/* empty heading render their fields flat with no toggle-all (the card's */\n/* legacy single-section mode) so no empty-named checkbox is emitted. */\n/* -------------------------------------------------------------------- */\n\nexport interface FieldVisibilityCogProps {\n /** The sectioned field catalogue. */\n sections: PatientFieldSection[];\n /** Current ordered visible field ids. */\n visible: string[];\n /** Show / hide a single field. */\n onToggleField: (fieldId: string) => void;\n /** Show / hide every field in a section. */\n onToggleSection: (sectionId: string, show: boolean) => void;\n /** Move a field onto another field's slot within its section. */\n onMoveFieldOnto: (fromId: string, toId: string) => void;\n /** Reset to the default field set / order. */\n onReset: () => void;\n /** Override the cog trigger's accessible name. */\n label?: string;\n}\n\nexport function FieldVisibilityCog({\n sections,\n visible,\n onToggleField,\n onToggleSection,\n onMoveFieldOnto,\n onReset,\n label,\n}: FieldVisibilityCogProps): ReactNode {\n const { t } = useTranslation();\n const visibleSet = useMemo(() => new Set(visible), [visible]);\n\n // Drag-and-drop reorder (pointer). The keyboard channel runs through each\n // grip handle's Alt+Arrow keys; both routes share `onMoveFieldOnto`.\n const [draggingId, setDraggingId] = useState<string | null>(null);\n const [dragOverId, setDragOverId] = useState<string | null>(null);\n const [announcement, setAnnouncement] = useState('');\n\n // Field id → section id and → label: the cross-section drop guard and the\n // move announcement both need the DRAGGED field's section/label, which isn't\n // in the drop row's render scope.\n const { sectionOfField, labelOfField } = useMemo(() => {\n const sectionMap = new Map<string, string>();\n const labelMap = new Map<string, string>();\n for (const section of sections) {\n for (const field of section.fields) {\n sectionMap.set(field.id, section.id);\n labelMap.set(field.id, field.label);\n }\n }\n return { sectionOfField: sectionMap, labelOfField: labelMap };\n }, [sections]);\n\n const draggingSectionId = draggingId\n ? sectionOfField.get(draggingId)\n : undefined;\n\n const clearDrag = useCallback(() => {\n setDraggingId(null);\n setDragOverId(null);\n }, []);\n\n // Announce the moved field's new 1-based position to assistive tech.\n const announceMoved = useCallback(\n (fieldId: string, newIndex: number, count: number) => {\n setAnnouncement(\n t('fieldPicker.moved', {\n field: labelOfField.get(fieldId) ?? '',\n position: newIndex + 1,\n count,\n defaultValue: 'Moved {{field}} to position {{position}} of {{count}}',\n }),\n );\n },\n [t, labelOfField],\n );\n\n return (\n <Popover.Root>\n <Popover.Trigger asChild>\n <IconButton\n size=\"sm\"\n intent=\"outline\"\n icon={<Settings aria-hidden=\"true\" />}\n aria-label={\n label ??\n t('fieldPicker.trigger', { defaultValue: 'Customize fields' })\n }\n className=\"ds:shrink-0\"\n />\n </Popover.Trigger>\n <Popover.Content align=\"end\" size=\"sm\">\n <Popover.Heading>\n {t('fieldPicker.title', { defaultValue: 'Customize fields' })}\n </Popover.Heading>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:mt-[var(--spacing-xs)]\">\n {sections.map((section) => {\n const fieldIds = section.fields.map((f) => f.id);\n const shownCount = fieldIds.filter((fid) =>\n visibleSet.has(fid),\n ).length;\n // Visible siblings in display order — the subsequence reordering\n // operates on. The keyboard arrows' no-op bounds key off the\n // field's index HERE, not the full declaration array.\n const orderedVisible = visible.filter((fid) =>\n fieldIds.includes(fid),\n );\n const sectionState: boolean | 'indeterminate' =\n shownCount === 0\n ? false\n : shownCount === fieldIds.length\n ? true\n : 'indeterminate';\n // A named section gets a toggle-all checkbox + indented field list;\n // an unnamed one (the card's single legacy section) renders flat.\n const named = !!section.heading;\n return (\n <div\n key={section.id}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]\"\n >\n {named ? (\n <Checkbox\n size=\"sm\"\n label={section.heading}\n checked={sectionState}\n onCheckedChange={(checked) =>\n onToggleSection(section.id, checked === true)\n }\n />\n ) : null}\n <ul\n className={[\n 'ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-2xs)]',\n named ? 'ds:ps-[var(--spacing-md)]' : 'ds:ps-0',\n ].join(' ')}\n >\n {section.fields.map((field) => {\n const shown = visibleSet.has(field.id);\n const visIndex = orderedVisible.indexOf(field.id);\n const count = orderedVisible.length;\n const isDragging = draggingId === field.id;\n const isDragOver =\n dragOverId === field.id &&\n draggingId !== null &&\n draggingId !== field.id &&\n draggingSectionId === section.id;\n\n // Native-HTML5 DnD wiring, applied only to visible rows —\n // a hidden field is neither a drag source nor a drop slot.\n const dragProps: HTMLAttributes<HTMLLIElement> = shown\n ? {\n draggable: true,\n onDragStart: (e) => {\n setDraggingId(field.id);\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/plain', field.id);\n },\n onDragOver: (e) => {\n // Same-section drops only; sections stay fixed.\n if (\n draggingId === null ||\n draggingSectionId !== section.id\n )\n return;\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n setDragOverId(field.id);\n },\n onDragLeave: () =>\n setDragOverId((prev) =>\n prev === field.id ? null : prev,\n ),\n onDrop: (e) => {\n e.preventDefault();\n const fromId = e.dataTransfer.getData('text/plain');\n if (\n fromId &&\n fromId !== field.id &&\n sectionOfField.get(fromId) === section.id\n ) {\n onMoveFieldOnto(fromId, field.id);\n announceMoved(fromId, visIndex, count);\n }\n clearDrag();\n },\n onDragEnd: clearDrag,\n }\n : {};\n\n return (\n <li\n key={field.id}\n {...dragProps}\n className={[\n 'ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-2xs)] ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-2xs)] ds:py-[var(--spacing-2xs)] ds:transition-colors ds:motion-reduce:transition-none',\n isDragging ? 'ds:opacity-50' : '',\n isDragOver\n ? 'ds:bg-[color:color-mix(in_srgb,var(--primary)_8%,transparent)]'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <Checkbox\n size=\"sm\"\n label={field.label}\n checked={shown}\n onCheckedChange={() => onToggleField(field.id)}\n />\n {shown ? (\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={<GripVertical aria-hidden=\"true\" />}\n aria-label={t('fieldPicker.reorder', {\n field: field.label,\n defaultValue:\n 'Reorder {{field}}. Press Alt + Up or Alt + Down to move.',\n })}\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown Alt+Home Alt+End\"\n className=\"ds:shrink-0 ds:cursor-grab ds:active:cursor-grabbing\"\n onKeyDown={(e) => {\n // Reorder gestures mirror the canonical Sidebar\n // handle: Alt+Arrow (+ Alt+Home / Alt+End). Bare\n // arrows fall through to the browser default.\n if (!e.altKey) return;\n if (e.key === 'ArrowUp') {\n if (visIndex <= 0) return;\n e.preventDefault();\n onMoveFieldOnto(\n field.id,\n orderedVisible[visIndex - 1],\n );\n announceMoved(field.id, visIndex - 1, count);\n } else if (e.key === 'ArrowDown') {\n if (visIndex >= count - 1) return;\n e.preventDefault();\n onMoveFieldOnto(\n field.id,\n orderedVisible[visIndex + 1],\n );\n announceMoved(field.id, visIndex + 1, count);\n } else if (e.key === 'Home') {\n if (visIndex <= 0) return;\n e.preventDefault();\n onMoveFieldOnto(field.id, orderedVisible[0]);\n announceMoved(field.id, 0, count);\n } else if (e.key === 'End') {\n if (visIndex >= count - 1) return;\n e.preventDefault();\n onMoveFieldOnto(\n field.id,\n orderedVisible[count - 1],\n );\n announceMoved(field.id, count - 1, count);\n }\n }}\n />\n ) : null}\n </li>\n );\n })}\n </ul>\n </div>\n );\n })}\n <Separator orientation=\"horizontal\" />\n <Button type=\"button\" size=\"sm\" intent=\"ghost\" onClick={onReset}>\n {t('fieldPicker.reset', { defaultValue: 'Reset to defaults' })}\n </Button>\n </div>\n {/* Reorder announcements for assistive tech (drag drop + arrow keys). */}\n <span role=\"status\" className=\"ds:sr-only\">\n {announcement}\n </span>\n </Popover.Content>\n </Popover.Root>\n );\n}\n","import { cloneElement, type ReactElement, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { CalendarDays, Hash, Hourglass, Mars, User, Venus } from 'lucide-react';\nimport { Badge } from '../badge/badge';\nimport { Link } from '../link/link';\nimport { TransactionChip } from '../transaction-chip/transaction-chip';\nimport type { PatientField } from './patient-fields';\n\n/* -------------------------------------------------------------------- */\n/* FieldValue — the canonical field-chip registry */\n/* */\n/* Renders ONE patient field's value slot. When the consumer supplies an */\n/* explicit `value` (legacy rows, per-placement overrides) it wins */\n/* verbatim. Otherwise `kind` selects the canonical chip and the raw */\n/* datum is read from `editValue`, so a known field type looks the same */\n/* on every surface (PatientSummaryCard + PatientDetails share this). */\n/* */\n/* The per-type chips (`SexChip` / `AgeChip` / `NeutralChip`) are exported */\n/* so the PatientSummaryCard identity line renders the SAME chips under */\n/* the name. */\n/* */\n/* Pure composition over already-marked kit primitives (Badge / */\n/* TransactionChip) — it mounts no surface of its own, so it carries no */\n/* `data-component` (allowlisted in check-data-component-coverage.mjs). */\n/* -------------------------------------------------------------------- */\n\n// The neutral Badge's own text colour (`--muted-foreground`) is too low\n// contrast for primary demographic data — grey text on the grey pill reads at\n// ~5.8:1. The chip label + glyph are pinned to `--foreground` (~11:1) so the\n// data stays legible on every theme.\nconst STRONG = 'ds:text-[color:var(--foreground)]';\n\n/** Default English labels — real translations live under `patientField.*`. */\nconst SEX_LABEL_DEFAULT: Record<string, string> = {\n m: 'Male',\n f: 'Female',\n x: 'Other',\n};\n\n/** A neutral pill with high-contrast text + an optional leading glyph. */\nexport function NeutralChip({\n icon,\n mono,\n children,\n}: {\n icon?: ReactElement;\n mono?: boolean;\n children: ReactNode;\n}): ReactNode {\n return (\n <Badge\n variant=\"neutral\"\n className={mono ? 'ds:font-mono' : undefined}\n // Clone the glyph (don't wrap it) so it stays Badge's DIRECT <svg> child —\n // Badge's `[&>svg]:size-*` rule only sizes a direct child, so wrapping it\n // left the glyph at lucide's default 24px. The clone also carries `STRONG`.\n leading={\n icon\n ? cloneElement(icon as ReactElement<{ className?: string }>, {\n className: STRONG,\n })\n : undefined\n }\n >\n <span className={STRONG}>{children}</span>\n </Badge>\n );\n}\n\n/** Sex chip — Venus / Mars / User glyph + localised label. Female / male carry a\n * tonal pink / blue FILL; unspecified stays the neutral pill. */\nexport function SexChip({ code }: { code: string }): ReactNode {\n const { t } = useTranslation();\n const c = code.toLowerCase();\n const label = t(`patientField.sex.${c}`, {\n defaultValue: SEX_LABEL_DEFAULT[c] ?? code,\n });\n // The fill carries the colour; Badge sizes + tones the glyph from the variant.\n // `accentSoft` is the kit's tonal magenta (≈ pink); `info` the tonal indigo\n // (≈ blue, the closest the closed palette has to blue). Other → neutral.\n if (c === 'f') {\n return (\n <Badge variant=\"accentSoft\" leading={<Venus />}>\n {label}\n </Badge>\n );\n }\n if (c === 'm') {\n return (\n <Badge variant=\"info\" leading={<Mars />}>\n {label}\n </Badge>\n );\n }\n return <NeutralChip icon={<User />}>{label}</NeutralChip>;\n}\n\n/** Age chip — hourglass glyph + localised, pluralised age. */\nexport function AgeChip({ years }: { years: number }): ReactNode {\n const { t } = useTranslation();\n return (\n <NeutralChip icon={<Hourglass />}>\n {t('patientField.age', {\n count: years,\n defaultValue: '{{count}} years old',\n })}\n </NeutralChip>\n );\n}\n\nexport function FieldValue({ field }: { field: PatientField }): ReactNode {\n const { i18n } = useTranslation();\n\n // Contact kinds render as a mailto:/tel: Link — the display string is read\n // from `value` (or `editValue`), the href is derived from it. Checked BEFORE\n // the explicit-value short-circuit so a plain-string `value` still links.\n if (field.kind === 'email' || field.kind === 'phone') {\n const display =\n typeof field.value === 'string'\n ? field.value\n : (field.copyText ??\n (typeof field.editValue === 'string' ? field.editValue : ''));\n if (display) {\n // mailto: trims surrounding whitespace; tel: keeps only `+` and digits\n // (dialler-safe), leaving the formatted text as the visible label.\n const href =\n field.kind === 'email'\n ? `mailto:${display.trim()}`\n : `tel:${display.replace(/[^+\\d]/g, '')}`;\n return <Link href={href}>{display}</Link>;\n }\n // No string to link — fall through to any explicit node value below.\n }\n\n // An explicit value always wins — legacy rows + per-placement overrides.\n if (field.value != null) {\n return <>{field.value}</>;\n }\n if (!field.kind) {\n return null;\n }\n\n switch (field.kind) {\n case 'sex':\n return <SexChip code={String(field.editValue ?? '')} />;\n case 'age': {\n const years =\n typeof field.editValue === 'number'\n ? field.editValue\n : Number(field.editValue);\n if (!Number.isFinite(years)) {\n return null;\n }\n return <AgeChip years={years} />;\n }\n case 'dob': {\n const raw = field.editValue;\n const date = raw instanceof Date ? raw : new Date(String(raw ?? ''));\n const formatted = Number.isNaN(date.getTime())\n ? String(raw ?? '')\n : new Intl.DateTimeFormat(i18n.language, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n }).format(date);\n if (!formatted) {\n return null;\n }\n return <NeutralChip icon={<CalendarDays />}>{formatted}</NeutralChip>;\n }\n case 'fiscalCode': {\n // Copy + PHI lock stay the consumer's row-level affordance (PatientDetails\n // renders them from `copyable` / `sensitive`); the chip is the mono pill.\n const code =\n field.copyText ??\n (typeof field.editValue === 'string' ? field.editValue : '');\n if (!code) {\n return null;\n }\n return (\n <NeutralChip icon={<Hash />} mono>\n {code}\n </NeutralChip>\n );\n }\n case 'discount': {\n // The canonical monetary discount chip — magnitude + currency, the sign\n // (\"−\") and glyph owned by TransactionChip. The row label gives context,\n // so the chip itself shows only the amount (no duplicate state label).\n const amount =\n typeof field.editValue === 'number'\n ? field.editValue\n : Number(field.editValue);\n if (!Number.isFinite(amount)) {\n return null;\n }\n return (\n <TransactionChip\n state=\"discount\"\n amount={Math.abs(amount)}\n currency={field.currency}\n size=\"sm\"\n />\n );\n }\n default:\n return null;\n }\n}\n","/* -------------------------------------------------------------------- */\n/* Patient field row — display ↔ inline edit */\n/* */\n/* The single implementation of an editable patient field, shared by */\n/* every surface that renders the `PatientField` model: PatientDetails */\n/* (the full record panel) and PatientSummaryCard (the compact card). */\n/* */\n/* It lives here rather than in either component because the two must not */\n/* drift: the same field, shown on a card and in the panel, has to offer */\n/* the same edit affordance, the same validation seam, the same optimistic*/\n/* -free save (the row stays in edit mode until the host resolves), and */\n/* the same PHI treatment (`sensitive` renders a lock, and NEVER reaches */\n/* a data-* attribute). */\n/* */\n/* The write path is the host's: the row owns the draft and the control, */\n/* the consumer owns `onFieldSave`. There is no second channel. */\n/* -------------------------------------------------------------------- */\n\nimport {\n useCallback,\n useId,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Check, Copy, Lock, Pencil, X } from 'lucide-react';\nimport type { PatientField, PatientFieldEditValue } from './patient-fields';\nimport { DescriptionList } from '../description-list';\nimport { FieldValue } from './field-value';\nimport { IconButton } from '../button/icon-button';\nimport { CityInput } from '../city-input/city-input';\nimport { CountrySelect } from '../country-select/country-select';\nimport { DatePicker } from '../date-picker/date-picker';\nimport { EmailInput } from '../email-input/email-input';\nimport { FiscalCodeInput } from '../fiscal-code-input/fiscal-code-input';\nimport { NumberInput } from '../number-input/number-input';\nimport { PhoneInput } from '../phone-input/phone-input';\nimport { PostalCodeInput } from '../postal-code-input/postal-code-input';\nimport { ProvinceSelect } from '../province-select/province-select';\nimport { Select } from '../select/select';\nimport { Switch } from '../switch/switch';\nimport { TextArea } from '../text-area/text-area';\nimport { TextInput } from '../text-input/text-input';\n\n/* -------------------------------------------------------------------- */\n/* FieldRow — display ↔ inline-edit */\n/* -------------------------------------------------------------------- */\n\nexport interface PatientFieldCellProps {\n field: PatientField;\n /** Master switch — an `editable` field shows its edit affordance. */\n editable: boolean;\n /** The single write channel. Without it, nothing is editable. */\n onFieldSave?: (fieldId: string, value: unknown) => Promise<void>;\n /** Return a message to block the save and keep the row in edit mode. */\n validate?: (fieldId: string, value: unknown) => string | null;\n locale?: string;\n}\n\n/**\n * The LABEL side of a patient field: its text plus the PHI lock when the\n * field is marked sensitive.\n */\nexport function PatientFieldLabel({\n field,\n}: {\n field: PatientField;\n}): ReactNode {\n const { t } = useTranslation();\n return (\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-2xs)]\">\n {field.label}\n {field.sensitive ? (\n <Lock\n aria-label={t('patientDetails.sensitive', {\n defaultValue: 'Sensitive',\n })}\n className=\"ds:size-3 ds:shrink-0 ds:text-[color:var(--muted-foreground)]\"\n />\n ) : null}\n </span>\n );\n}\n\n/**\n * The VALUE side of a patient field: the formatted value, its copy button,\n * and the inline editor once opened. List-shape agnostic on purpose — it\n * carries no row markup, so `PatientDetails` can place it in a\n * `DescriptionList` and `PatientSummaryCard` in a `KeyValueList` while the\n * edit behaviour stays one implementation.\n *\n * The edit affordance reveals on hover / focus of an ancestor marked\n * `ds:group`, so whichever list wraps this must set that class on its row.\n */\nexport function PatientFieldValueCell({\n field,\n editable,\n onFieldSave,\n validate,\n locale,\n}: PatientFieldCellProps): ReactNode {\n const { t } = useTranslation();\n const errorId = useId();\n const canEdit = editable && !!field.editable && !!onFieldSave;\n\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState<PatientFieldEditValue>(field.editValue);\n const [error, setError] = useState<string | null>(null);\n const [saving, setSaving] = useState(false);\n\n const beginEdit = useCallback(() => {\n setDraft(field.editValue);\n setError(null);\n setEditing(true);\n }, [field.editValue]);\n\n const cancelEdit = useCallback(() => {\n setEditing(false);\n setError(null);\n }, []);\n\n const commitEdit = useCallback(async () => {\n if (!onFieldSave) return;\n const validationError = validate?.(field.id, draft) ?? null;\n if (validationError) {\n setError(validationError);\n return;\n }\n setSaving(true);\n setError(null);\n try {\n await onFieldSave(field.id, draft);\n setEditing(false);\n } catch (err) {\n // Keep the row in edit mode + surface the failure; the value the\n // consumer holds is unchanged (no optimistic mutation of `value`).\n setError(\n err instanceof Error && err.message\n ? err.message\n : t('patientDetails.edit.saveFailed', {\n defaultValue: 'Could not save. Try again.',\n }),\n );\n } finally {\n setSaving(false);\n }\n }, [onFieldSave, validate, field.id, draft, t]);\n\n // Best-effort plain text for the truncated value's hover tooltip — the full\n // value also stays reachable via inline edit and (when copyable) the copy button.\n const valueTitle =\n typeof field.value === 'string'\n ? field.value\n : (field.copyText ??\n (typeof field.editValue === 'string' ? field.editValue : undefined));\n\n return editing ? (\n <span className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]\">\n <span className=\"ds:flex ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <FieldEditor\n field={field}\n value={draft}\n onChange={setDraft}\n invalid={!!error}\n errorId={error ? errorId : undefined}\n locale={locale}\n disabled={saving}\n />\n <IconButton\n size=\"sm\"\n intent=\"primary\"\n icon={<Check aria-hidden=\"true\" />}\n aria-label={t('patientDetails.edit.save', { defaultValue: 'Save' })}\n loading={saving}\n onClick={commitEdit}\n />\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={<X aria-hidden=\"true\" />}\n aria-label={t('patientDetails.edit.cancel', {\n defaultValue: 'Cancel',\n })}\n disabled={saving}\n onClick={cancelEdit}\n />\n </span>\n {error ? (\n <span\n id={errorId}\n role=\"alert\"\n className=\"type-meta ds:text-[color:var(--destructive)]\"\n >\n {error}\n </span>\n ) : null}\n </span>\n ) : (\n <span className=\"ds:flex ds:items-start ds:gap-[var(--spacing-2xs)] ds:min-w-0\">\n {/* Single-line values truncate so the read row matches the editor height\n (no shift on open); textarea fields keep wrapping. */}\n <span\n className={`ds:min-w-0 ${field.editType === 'textarea' ? '' : 'ds:truncate'}${field.mono ? ' ds:font-mono' : ''}`}\n title={valueTitle}\n >\n <FieldValue field={field} />\n </span>\n {field.copyable && field.copyText ? (\n <CopyButton text={field.copyText} label={field.label} />\n ) : null}\n {canEdit ? (\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n // Reveal on row hover / keyboard focus only — stays in the tab order\n // (opacity, not display) so keyboard + SR users always reach it.\n className=\"ds:shrink-0 ds:opacity-0 ds:transition-opacity ds:motion-reduce:transition-none ds:group-hover:opacity-100 ds:focus-visible:opacity-100\"\n icon={<Pencil aria-hidden=\"true\" />}\n aria-label={t('patientDetails.edit.editField', {\n field: field.label,\n defaultValue: 'Edit {{field}}',\n })}\n onClick={beginEdit}\n />\n ) : null}\n </span>\n );\n}\n\n/**\n * One patient field as a `DescriptionList` row — the shape `PatientDetails`\n * uses. `PatientSummaryCard` composes the same cells into its own list\n * instead, so the two surfaces share the editing behaviour without sharing a\n * list primitive.\n */\nexport function PatientFieldRow({\n field,\n icon,\n ...cell\n}: PatientFieldCellProps & {\n icon?: ReactElement | null;\n}): ReactNode {\n return (\n <DescriptionList.Row\n icon={icon ?? null}\n data-field-id={field.id}\n // `group` is what reveals the edit pencil on hover / focus.\n className=\"ds:group\"\n >\n <DescriptionList.Term>\n <PatientFieldLabel field={field} />\n </DescriptionList.Term>\n <DescriptionList.Detail>\n <PatientFieldValueCell field={field} {...cell} />\n </DescriptionList.Detail>\n </DescriptionList.Row>\n );\n}\n\n/* -------------------------------------------------------------------- */\n/* FieldEditor — the right control per editType */\n/* -------------------------------------------------------------------- */\n\nfunction FieldEditor({\n field,\n value,\n onChange,\n invalid,\n errorId,\n locale,\n disabled,\n}: {\n field: PatientField;\n value: PatientFieldEditValue;\n onChange: (next: PatientFieldEditValue) => void;\n invalid: boolean;\n errorId?: string;\n locale?: string;\n disabled?: boolean;\n}): ReactNode {\n const { t } = useTranslation();\n const tone = invalid ? 'error' : 'default';\n const editType = field.editType ?? 'text';\n\n switch (editType) {\n case 'textarea':\n return (\n <TextArea\n size=\"sm\"\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => onChange(e.target.value)}\n tone={tone}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n className=\"ds:flex-1\"\n />\n );\n case 'select':\n return (\n <Select\n size=\"sm\"\n options={field.options ?? []}\n value={typeof value === 'string' ? value : ''}\n onValueChange={(next) => onChange(next)}\n tone={tone}\n disabled={disabled}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n />\n );\n case 'boolean':\n return (\n <Switch\n label={field.label}\n checked={value === true}\n onCheckedChange={(checked) => onChange(checked)}\n disabled={disabled}\n />\n );\n case 'date':\n return (\n <DatePicker\n size=\"sm\"\n value={value instanceof Date ? value : undefined}\n onChange={(next) => onChange(next ?? null)}\n disabled={disabled}\n aria-label={field.label}\n />\n );\n case 'number':\n return (\n <NumberInput\n size=\"sm\"\n value={typeof value === 'number' ? value : null}\n onChange={(next) => onChange(next)}\n mode={field.currency ? 'currency' : 'decimal'}\n currency={field.currency}\n locale={locale}\n tone={tone}\n disabled={disabled}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n />\n );\n case 'email':\n return (\n <EmailInput\n size=\"sm\"\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => onChange(e.target.value)}\n // EmailInput owns format validation — it surfaces its own border +\n // \"Invalid email\" message. PatientDetails' `validate` layers on top\n // for business rules (e.g. already-in-use), never format.\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n className=\"ds:flex-1\"\n />\n );\n case 'phone':\n return (\n <PhoneInput\n size=\"sm\"\n // E.164 string in / out — the dialling-code split is the input's own\n // internal state, never part of the saved value.\n value={typeof value === 'string' ? value : ''}\n onChange={(e164) => onChange(e164)}\n tone={tone}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n className=\"ds:flex-1\"\n />\n );\n case 'fiscalCode':\n return (\n <FiscalCodeInput\n size=\"sm\"\n // The input normalises (uppercase, strip, ≤16) and hands back the\n // plain string; that normalised value is what we save.\n value={typeof value === 'string' ? value : ''}\n onChange={(raw) => onChange(raw)}\n tone={tone}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n className=\"ds:flex-1\"\n />\n );\n // Address / location pickers. Inline edit has no FormField, so we pass\n // aria-invalid / aria-describedby explicitly (the components fall back to\n // these props outside a FormFieldContext) so the invalid state isn't\n // conveyed by colour alone.\n case 'province':\n return (\n <ProvinceSelect\n size=\"sm\"\n country=\"it\"\n value={typeof value === 'string' ? value : ''}\n onValueChange={(next) => onChange(next)}\n tone={tone}\n disabled={disabled}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n className=\"ds:flex-1\"\n />\n );\n case 'country':\n return (\n <CountrySelect\n size=\"sm\"\n value={typeof value === 'string' ? value : ''}\n onValueChange={(next) => onChange(next)}\n tone={tone}\n disabled={disabled}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n className=\"ds:flex-1\"\n />\n );\n case 'postalCode':\n // PostalCodeInput owns its tone (derived from CAP-format blur\n // validation), so we don't pass `tone`; it accepts aria-invalid /\n // aria-describedby for the business-rule layer above.\n return (\n <PostalCodeInput\n size=\"sm\"\n country=\"it\"\n value={typeof value === 'string' ? value : ''}\n onValueChange={(next) => onChange(next)}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n className=\"ds:flex-1\"\n />\n );\n case 'city':\n return (\n <CityInput\n size=\"sm\"\n value={typeof value === 'string' ? value : ''}\n onValueChange={(next) => onChange(next)}\n tone={tone}\n disabled={disabled}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n className=\"ds:flex-1\"\n />\n );\n case 'text':\n default:\n return (\n <TextInput\n size=\"sm\"\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => onChange(e.target.value)}\n tone={tone}\n aria-label={field.label}\n aria-invalid={invalid || undefined}\n aria-describedby={errorId}\n disabled={disabled}\n clearable\n placeholder={t('patientDetails.edit.placeholder', {\n defaultValue: 'Enter a value',\n })}\n className=\"ds:flex-1\"\n />\n );\n }\n}\n\n/* -------------------------------------------------------------------- */\n/* CopyButton — copy a field value (rendered INSIDE the <dd>) */\n/* */\n/* Rendered inside the Detail so the <dl> grouping <div> contains only */\n/* <dt>/<dd> (the axe `definition-list` rule forbids buttons as siblings */\n/* of dt/dd). Reuses the shared keyValuePair.* copy strings. */\n/* -------------------------------------------------------------------- */\n\nfunction CopyButton({\n text,\n label,\n}: {\n text: string;\n label: string;\n}): ReactNode {\n const { t } = useTranslation();\n const [copied, setCopied] = useState(false);\n const [announcement, setAnnouncement] = useState('');\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n setAnnouncement(t('keyValuePair.copied', { defaultValue: 'Copied' }));\n setTimeout(() => {\n setCopied(false);\n setAnnouncement('');\n }, 2000);\n } catch {\n setAnnouncement(\n t('keyValuePair.notAvailable', { defaultValue: 'Copy not available' }),\n );\n setTimeout(() => setAnnouncement(''), 3000);\n }\n }, [text, t]);\n\n return (\n <>\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={\n copied ? <Check aria-hidden=\"true\" /> : <Copy aria-hidden=\"true\" />\n }\n aria-label={t('keyValuePair.copy', {\n label,\n defaultValue: 'Copy {{label}}',\n })}\n onClick={handleCopy}\n />\n <span role=\"status\" className=\"ds:sr-only\">\n {announcement}\n </span>\n </>\n );\n}\n"],"names":["__iconNode","Hourglass","createLucideIcon","Mars","Venus","patientFieldCatalogue","sections","s","f","resolveVisibleFields","visibleFieldOrder","order","orderIndex","id","index","section","field","a","b","usePatientFieldVisibility","value","defaultValue","onChange","catalogueIds","useMemo","orderState","setOrderState","useControllableState","visible","fieldById","map","setOrder","useCallback","next","fid","toggleField","fieldId","toggleSection","sectionId","show","sectionIds","_a","sectionSet","missing","moveFieldOnto","fromId","toId","fromSection","toSection","_b","_c","siblings","fromIdx","toIdx","moved","k","reset","FieldVisibilityCog","onToggleField","onToggleSection","onMoveFieldOnto","onReset","label","t","useTranslation","visibleSet","draggingId","setDraggingId","useState","dragOverId","setDragOverId","announcement","setAnnouncement","sectionOfField","labelOfField","sectionMap","labelMap","draggingSectionId","clearDrag","announceMoved","newIndex","count","jsxs","Popover","jsx","IconButton","Settings","fieldIds","shownCount","orderedVisible","sectionState","named","Checkbox","checked","shown","visIndex","isDragging","isDragOver","e","prev","GripVertical","Separator","Button","STRONG","SEX_LABEL_DEFAULT","NeutralChip","icon","mono","children","Badge","cloneElement","SexChip","code","c","User","AgeChip","years","FieldValue","i18n","display","href","Link","Fragment","raw","date","formatted","CalendarDays","Hash","amount","TransactionChip","PatientFieldLabel","Lock","PatientFieldValueCell","editable","onFieldSave","validate","locale","errorId","useId","canEdit","editing","setEditing","draft","setDraft","error","setError","saving","setSaving","beginEdit","cancelEdit","commitEdit","validationError","err","valueTitle","FieldEditor","Check","X","CopyButton","Pencil","PatientFieldRow","cell","DescriptionList","invalid","disabled","tone","TextArea","Select","Switch","DatePicker","NumberInput","EmailInput","PhoneInput","e164","FiscalCodeInput","ProvinceSelect","CountrySelect","PostalCodeInput","CityInput","TextInput","text","copied","setCopied","handleCopy","Copy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE;AAAA,IACE;AAAA,IACA,EAAE,GAAG,0EAA0E,KAAK,SAAQ;AAAA,EAChG;AACA,GACMC,KAAYC,EAAiB,aAAaF,EAAU;ACxB1D;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,aAAa,KAAK,SAAQ,CAAE;AAAA,EAC1C,CAAC,QAAQ,EAAE,GAAG,mBAAmB,KAAK,SAAQ,CAAE;AAAA,EAChD,CAAC,UAAU,EAAE,IAAI,MAA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,QAAO;AAAA,QACP,MACE+F,IAAS,gBAAAhG,EAACuE,GAAA,EAAM,eAAY,QAAO,IAAK,gBAAAvE,EAACmG,IAAA,EAAK,eAAY,OAAA,CAAO;AAAA,QAEnE,cAAYxH,EAAE,qBAAqB;AAAA,UACjC,OAAAD;AAAA,UACA,cAAc;AAAA,QAAA,CACf;AAAA,QACD,SAASwH;AAAA,MAAA;AAAA,IAAA;AAAA,sBAEV,QAAA,EAAK,MAAK,UAAS,WAAU,cAC3B,UAAA/G,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;","x_google_ignoreList":[0,1,2]}
@@ -14,7 +14,7 @@ import { T as Ke } from "./transaction-chip-Dth1nThY.js";
14
14
  import { T as je } from "./tooltip-Cp-PLePW.js";
15
15
  import { H as G } from "./hover-card-Bcku1GQu.js";
16
16
  import { i as de } from "./is-safe-url-DkETxeHz.js";
17
- import { u as qe, r as We, a as He, b as Je, F as Qe, S as Xe, A as Ye, N as Ze } from "./patient-field-row-BQZoP4m2.js";
17
+ import { u as qe, r as We, a as He, b as Je, F as Qe, S as Xe, A as Ye, N as Ze } from "./patient-field-row-IHb2VFc2.js";
18
18
  import { u as Oe } from "./registry-DvAUVLHh.js";
19
19
  import { M as ea } from "./mail-BqXVF2zH.js";
20
20
  import { P as aa } from "./phone-FceYcIFQ.js";
@@ -530,4 +530,4 @@ export {
530
530
  Ca as P,
531
531
  ma as p
532
532
  };
533
- //# sourceMappingURL=patient-summary-card-Bz7KdUin.js.map
533
+ //# sourceMappingURL=patient-summary-card-BzmJH9a-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"patient-summary-card-Bz7KdUin.js","sources":["../../node_modules/lucide-react/dist/esm/icons/file-exclamation-point.mjs","../../node_modules/lucide-react/dist/esm/icons/message-square-warning.mjs","../../src/components/patient-summary-card/patient-summary-card.agent.ts","../../src/components/patient-summary-card/patient-summary-card.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\",\n key: \"1oefj6\"\n }\n ],\n [\"path\", { d: \"M12 9v4\", key: \"juzpu7\" }],\n [\"path\", { d: \"M12 17h.01\", key: \"p32p05\" }]\n];\nconst FileExclamationPoint = createLucideIcon(\"file-exclamation-point\", __iconNode);\n\nexport { __iconNode, FileExclamationPoint as default };\n//# sourceMappingURL=file-exclamation-point.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\",\n key: \"18887p\"\n }\n ],\n [\"path\", { d: \"M12 15h.01\", key: \"q59x07\" }],\n [\"path\", { d: \"M12 7v4\", key: \"xawao1\" }]\n];\nconst MessageSquareWarning = createLucideIcon(\"message-square-warning\", __iconNode);\n\nexport { __iconNode, MessageSquareWarning as default };\n//# sourceMappingURL=message-square-warning.mjs.map\n","import type { AgentAdapter } from '../../agent/types';\nimport type { PatientSummaryCardHandle } from './patient-summary-card';\n\n/* -------------------------------------------------------------------- */\n/* Agent adapter — PatientSummaryCard */\n/* */\n/* Read-only adapter. Surfaces a STRUCTURAL snapshot of the patient */\n/* overview — counts, flags, and the consumer id only. Never the patient */\n/* name, age, contact details, or any clinical content, so an agent / */\n/* MCP runtime can answer \"does this patient have unpaid balances / */\n/* unsigned documents / AI consent?\" without re-parsing the DOM and */\n/* without leaking PHI (PRS §Security). */\n/* -------------------------------------------------------------------- */\n\nexport const patientSummaryCardAgent: AgentAdapter<PatientSummaryCardHandle> = {\n id: 'patient-summary-card',\n // The agent surface is a structural snapshot only — the single handle method\n // is a getSummary projection. The card MAY be human-customized (the optional\n // per-context \"Customize fields\" cog), but that field reordering is a UI\n // concern and is deliberately NOT exposed as an agent action; programmatic\n // field-set control lives on PatientDetails' adapter (set_field_order).\n capabilities: [],\n state: {\n summary: {\n type: '{ id?: string; hasUnpaid: boolean; unsignedDocumentsCount: number; highlightedAnamnesisCount: number; aiConsentGranted: boolean }',\n descriptionKey: 'ui.agent.patientSummaryCard.state.summary',\n description:\n 'Structural summary of the patient card — identifiers, counts, and consent flags only. Never patient identity or clinical content.',\n read: (handle) => handle.getSummary(),\n },\n },\n actions: {},\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'patient-summary-card',\n description: 'Marks the PatientSummaryCard root region.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useId,\n useMemo,\n type ComponentPropsWithoutRef,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n ArrowUpRight,\n CalendarDays,\n FileExclamationPoint,\n Mail,\n MapPin,\n MessageSquareWarning,\n Phone,\n ShieldCheck,\n Astroid,\n Users,\n type LucideIcon,\n} from 'lucide-react';\nimport { Avatar } from '../avatar/avatar';\nimport { Badge } from '../badge/badge';\nimport { IconButton } from '../button/icon-button';\nimport { Card } from '../card/card';\nimport { KeyValueList, KeyValuePair } from '../key-value-pair/key-value-pair';\nimport { Link } from '../link/link';\nimport { Skeleton } from '../skeleton/skeleton';\nimport { Tag } from '../tag/tag';\nimport { TransactionChip } from '../transaction-chip/transaction-chip';\nimport { Tooltip } from '../tooltip';\nimport { HoverCard } from '../hover-card';\nimport { isSafeEntityUrl } from '../_shared/is-safe-url';\nimport {\n resolveVisibleFields,\n type PatientField,\n type PatientFieldSection,\n} from '../_shared/patient-fields';\nimport { usePatientFieldVisibility } from '../_shared/field-visibility';\nimport { FieldVisibilityCog } from '../_shared/field-visibility-cog';\nimport { AgeChip, NeutralChip, SexChip } from '../_shared/field-value';\nimport {\n PatientFieldLabel,\n PatientFieldValueCell,\n} from '../_shared/patient-field-row';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { patientSummaryCardAgent } from './patient-summary-card.agent';\n\n/** A section list reference that stays stable across renders (legacy mode). */\nconst NO_SECTIONS: PatientFieldSection[] = [];\n\n/* -------------------------------------------------------------------- */\n/* PatientSummaryCard */\n/* */\n/* The patient-overview profile card every AlfaDocs in-app surface */\n/* composes by hand today (platform patient header, alfascribe patient */\n/* sidebar, check-in landing). Templated on ContactProfileCard: composes */\n/* Card + Avatar + KeyValueList + KeyValuePair + Badge + Tag + */\n/* TransactionChip + Link so the contact rows share a column and every */\n/* row uses the same lucide icon family. */\n/* */\n/* The kit owns the ORDER, ICONS, and LABELS — consumers pass data. No */\n/* free-text clinical content (anamnesis notes, diagnoses) ever lives */\n/* here: only counts/flags/relations are surfaced, so the card stays */\n/* PHI-light and the agent state can be derived without leaking patient */\n/* identity. */\n/* */\n/* All visible text flows through `useTranslation('ui')` against the */\n/* `patientSummaryCard.*` namespace. */\n/* -------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------- */\n/* CVA — root */\n/* -------------------------------------------------------------------- */\n\nconst rootVariants = cva('ds:w-full ds:text-[color:var(--foreground)]', {\n variants: {\n // Matches the kit's other `surface` props (ContactProfileCard,\n // OperatorHero). `'elevated'` wraps the content in `<Card>`.\n surface: {\n flat: '',\n elevated: '',\n },\n // Density tunes the avatar size + body padding. `comfortable` reads\n // as a page header; `compact` fits an embedded sidebar / aside.\n density: {\n comfortable: '',\n compact: '',\n },\n },\n defaultVariants: {\n surface: 'elevated',\n density: 'comfortable',\n },\n});\n\n/* -------------------------------------------------------------------- */\n/* Public types */\n/* -------------------------------------------------------------------- */\n\n/** Patient phone number — already formatted for display by the consumer. */\nexport interface PatientSummaryCardPhone {\n /** Display string, e.g. `\"+39 055 123 4567\"`. Compiled into a `tel:` link. */\n prefixAndNumber: string;\n /** Optional label that distinguishes this number (e.g. \"Mobile\"). */\n label?: string;\n /** Whether SMS is enabled for this number — shows a small \"SMS\" chip. */\n smsEnabled?: boolean;\n}\n\n/** A family relation row — links one patient to another. */\nexport interface PatientSummaryCardFamilyRelation {\n /** Localised relation label, consumer-supplied (e.g. \"Mother\", \"Child\"). */\n relation: string;\n /** The related patient — name + optional in-app profile URL. */\n relatedPatient: {\n name: string;\n url?: string;\n };\n}\n\n/** Operator the patient is assigned to. */\nexport interface PatientSummaryCardAssignee {\n name: string;\n avatarUrl?: string;\n}\n\n/** AI-consent grant metadata — structural only, never the consented content. */\nexport interface PatientSummaryCardAiConsent {\n /** ISO-8601 / display string of when consent was granted. */\n grantedAt: string;\n /** Optional name of who recorded the grant. */\n grantedBy?: string;\n}\n\n/** Addressable attention flags — the keys `onFlagActivate` accepts. */\nexport type PatientSummaryCardFlagId =\n | 'highlightedAnamnesis'\n | 'unsignedDocuments'\n | 'unpaid';\n\n/** Status flags rendered as glyph badges (counts / amounts only — no PHI). */\nexport interface PatientSummaryCardFlags {\n /** Number of anamnesis answers highlighted for clinical attention. */\n highlightedAnamnesisCount?: number;\n /** Outstanding balance in the smallest currency unit (cents). */\n unpaidAmountCents?: number;\n /** Number of documents awaiting the patient's signature. */\n unsignedDocumentsCount?: number;\n}\n\n/** Marketing-consent tri-state. */\nexport type PatientSummaryCardMarketingConsent = 'no' | 'yes' | 'not_specified';\n\nexport interface PatientSummaryCardHandle {\n /** Structural snapshot — identifiers and counts only, never patient identity. */\n getSummary: () => {\n id?: string;\n hasUnpaid: boolean;\n unsignedDocumentsCount: number;\n highlightedAnamnesisCount: number;\n aiConsentGranted: boolean;\n };\n}\n\nexport interface PatientSummaryCardProps extends Omit<\n ComponentPropsWithoutRef<'div'>,\n 'aria-label' | 'children'\n> {\n /** Patient display name. Rendered as the heading. */\n name: string;\n /** Honorific — `'mr'` / `'ms'`. Prepended to the name in the heading. */\n title?: 'mr' | 'ms';\n /** Patient age in whole years — rendered in the identity line. */\n ageYears?: number;\n /** Date of birth — already formatted for display by the consumer. */\n dateOfBirth?: string;\n /** Biological sex marker — `'m'` / `'f'`. Drives the identity-line glyph copy. */\n gender?: 'm' | 'f';\n /** Optional avatar / photo URL. Falls back to initials. */\n avatarUrl?: string;\n /**\n * In-app patient profile URL. When safe, the heading becomes a link.\n * Guarded by the shared `isSafeEntityUrl` allow-list — unsafe URLs are\n * dropped and the heading renders as plain text.\n */\n patientUrl?: string;\n\n /* ----- Shared field model (preferred) ----- */\n\n /**\n * Patient fields in the shared model — the SAME `sections` shape\n * `PatientDetails` consumes (`@alfadocs/ui-kit` `PatientFieldSection`).\n * When provided, the card renders these (honouring `visibleFieldOrder`)\n * instead of the legacy contact props, so a consumer defines its patient-\n * field registry once and reuses it across every patient surface.\n *\n * The card renders each field's `label`, `value`, and `icon` only — it is\n * flat (section headings are not shown in the body) and never inline-edits;\n * `sensitive` / `copyable` / `mono` / `editable` are honoured by\n * `PatientDetails`, not the card (so the PHI lock glyph does not appear here).\n *\n * Pass `onVisibleFieldsChange` alongside `sections` to make THIS placement\n * self-curating (a \"Customize fields\" cog appears — show/hide + drag-and-drop\n * reorder).\n */\n sections?: PatientFieldSection[];\n /**\n * Ordered visible field ids for THIS placement. The order is a\n * per-INSTANCE, per-CONTEXT preference the kit never persists — wire it to\n * whatever scope the consumer wants (e.g. a global per-user setting, or a\n * different config in the care-plan view vs the patient folder). The same\n * field vocabulary can therefore display differently in different parts of\n * the app. Omit (`undefined`) ⇒ show every field; an explicit empty array\n * `[]` ⇒ show none (a card that starts collapsed to name + identity chips and\n * reveals fields via the cog). Also applied to the legacy contact rows (ids\n * `email` / `phone` / `cityProvince` / `marketingConsent` / `aiConsent` /\n * `assignedTo`).\n */\n visibleFieldOrder?: string[];\n /**\n * Make this card's field set user-customizable. When provided alongside\n * `sections`, a \"Customize fields\" cog renders in the header (show/hide +\n * drag-and-drop / Alt+Arrow reorder), and this fires with the next ordered\n * visible set. The consumer owns persistence + its scope — editing here\n * writes only THIS context's preference, never a shared/global one.\n */\n onVisibleFieldsChange?: (orderedIds: string[]) => void;\n\n /* ----- Contact rows (legacy — prefer `sections`) ----- */\n\n /** @deprecated Pass via `sections`. Patient email — `mailto:` link when `emailEnabled`. */\n email?: string;\n /** Whether email contact is enabled — gates the `mailto:` link. */\n emailEnabled?: boolean;\n /** Phone number block. Compiled into a `tel:` link. */\n phone?: PatientSummaryCardPhone;\n /** City / province display string. */\n cityProvince?: string;\n\n /* ----- Consent ----- */\n\n /** Marketing-consent tri-state. */\n marketingConsent?: PatientSummaryCardMarketingConsent;\n /** AI-consent grant metadata. When present, an \"AI consent\" row renders. */\n aiConsent?: PatientSummaryCardAiConsent;\n\n /* ----- Status flags ----- */\n\n /** Counts / amounts surfaced as glyph badges. */\n flags?: PatientSummaryCardFlags;\n\n /* ----- Relations & assignment ----- */\n\n /** Family relations — rendered as `<Tag>` chips, optionally linked. */\n familyRelations?: PatientSummaryCardFamilyRelation[];\n /** Operator the patient is assigned to. */\n assignedTo?: PatientSummaryCardAssignee;\n\n /* ----- Formatting ----- */\n\n /** ISO-4217 currency code for the unpaid-amount chip. Defaults to `EUR`. */\n currency?: string;\n /** BCP-47 locale override. Defaults to the active i18next language. */\n locale?: string;\n\n /* ----- States ----- */\n\n /** Render the skeleton loading placeholder. */\n loading?: boolean;\n\n /* ----- Slots & callbacks ----- */\n\n /** Rendered at the inline-end of the heading row (e.g. an action menu). */\n actionSlot?: ReactNode;\n\n /**\n * Make an attention chip actionable. A handler turns that chip into a\n * button — \"2 unsigned documents\" opens the signing flow, the unpaid\n * balance opens invoicing. Without a handler the chip stays a read-only\n * badge, which is the default: most surfaces have nowhere to send the\n * reader.\n */\n onFlagActivate?: Partial<Record<PatientSummaryCardFlagId, () => void>>;\n /**\n * Explain a chip on hover / focus. The chip states WHAT (\"2 unsigned\n * documents\"); this states what the reader cannot see — how the signature\n * was requested, why the balance is outstanding.\n *\n * A string renders a `Tooltip`; a node renders a `HoverCard` with that node\n * as its content, for a host that wants the fuller card grammar (an eyebrow,\n * fact rows, a hint line). Either way the chip's own text stays the\n * accessible name and the surface only describes it.\n */\n flagHover?: Partial<Record<PatientSummaryCardFlagId, ReactNode>>;\n /**\n * Accessible name for the open button a hover CARD shows in its top-end\n * corner. The button appears only where the flag has BOTH a card and an\n * `onFlagActivate` handler — it mirrors the chip's own click so a pointer\n * that has travelled into the card can still act. Name the destination\n * (\"Open signing\"), not the gesture.\n *\n * Without a label there is no button: a card that merely describes should\n * not sprout an affordance the chip does not have.\n */\n flagOpenLabel?: Partial<Record<PatientSummaryCardFlagId, string>>;\n /**\n * Extra chips appended to the attention row, for signals the CARD cannot\n * model because they do not belong to the patient. An appointment panel\n * adds its own to-invoice and paid-online chips here; the card keeps its\n * patient-level flags and does not grow an appointment vocabulary.\n */\n extraChips?: ReactNode;\n\n /* ----- Inline editing (kit-owned controls, consumer-owned write) ----- */\n\n /**\n * Master switch — show the edit affordance on fields marked `editable` in\n * `sections`. The card edits through the SAME shared control as\n * `PatientDetails`, so a field offers the same affordance and the same\n * validation wherever it is shown.\n */\n editable?: boolean;\n /**\n * The single write channel. A rejected promise keeps the row in edit mode\n * and shows the message inline — the card never optimistically mutates the\n * value it was given.\n */\n onFieldSave?: (fieldId: string, value: unknown) => Promise<void>;\n /** Return a message to block the save and keep the row in edit mode. */\n validateField?: (fieldId: string, value: unknown) => string | null;\n /** Fires when the whole card / heading is activated. */\n onActivate?: () => void;\n\n /* ----- Styling ----- */\n\n /** `'elevated'` (default) wraps in `<Card>`; `'flat'` drops the chrome. */\n surface?: 'flat' | 'elevated';\n /** `'comfortable'` (default) reads as a header; `'compact'` for asides. */\n density?: 'comfortable' | 'compact';\n\n /* ----- a11y ----- */\n\n /** Override the default region aria-label. */\n 'aria-label'?: string;\n /** Agent-readiness consumer id, surfaced as `data-component-id`. */\n id?: string;\n}\n\n/* -------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------- */\n\n/** Strip everything except digits + leading `+` for `tel:` URLs. */\nfunction normalisePhone(raw: string): string {\n return raw.replace(/[^\\d+]/g, '');\n}\n\n/* -------------------------------------------------------------------- */\n/* Flag glyphs — the closed set of status indicators */\n/* -------------------------------------------------------------------- */\n\n/** The closed set of status-flag keys (icon + tonal variant defined below). */\ntype FlagKey = 'highlightedAnamnesis' | 'unsignedDocuments';\n\nconst FLAG_ICON: Record<FlagKey, LucideIcon> = {\n highlightedAnamnesis: MessageSquareWarning,\n unsignedDocuments: FileExclamationPoint,\n};\n\nconst FLAG_VARIANT: Record<FlagKey, 'warning' | 'error'> = {\n highlightedAnamnesis: 'warning',\n unsignedDocuments: 'error',\n};\n\n/** English fallbacks for the flag badge accessible names (count-interpolated). */\nconst FLAG_LABEL_DEFAULTS: Record<FlagKey, string> = {\n highlightedAnamnesis: '{{count}} highlighted anamnesis answers',\n unsignedDocuments: '{{count}} unsigned documents',\n};\n\n/** English fallbacks for the marketing-consent tri-state chip. */\nconst MARKETING_CONSENT_DEFAULTS: Record<\n PatientSummaryCardMarketingConsent,\n string\n> = {\n yes: 'Yes',\n no: 'No',\n not_specified: 'Not specified',\n};\n\n/* -------------------------------------------------------------------- */\n/* Component */\n/* -------------------------------------------------------------------- */\n\nexport const PatientSummaryCard = forwardRef<\n HTMLDivElement,\n PatientSummaryCardProps\n>(\n (\n {\n name,\n title,\n ageYears,\n dateOfBirth,\n gender,\n avatarUrl,\n patientUrl,\n sections,\n visibleFieldOrder,\n onVisibleFieldsChange,\n email,\n emailEnabled = false,\n phone,\n cityProvince,\n marketingConsent,\n aiConsent,\n flags,\n familyRelations,\n assignedTo,\n currency = 'EUR',\n locale,\n loading = false,\n actionSlot,\n onFlagActivate,\n flagHover,\n flagOpenLabel,\n extraChips,\n editable = false,\n onFieldSave,\n validateField,\n onActivate,\n surface = 'elevated',\n density = 'comfortable',\n 'aria-label': ariaLabel,\n id,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const headingId = useId();\n const activeLocale = locale ?? i18n.language ?? 'en';\n\n const unpaidAmountCents = flags?.unpaidAmountCents;\n const unsignedDocumentsCount = flags?.unsignedDocumentsCount ?? 0;\n const highlightedAnamnesisCount = flags?.highlightedAnamnesisCount ?? 0;\n const hasUnpaid = unpaidAmountCents != null && unpaidAmountCents > 0;\n\n // Imperative handle — structural snapshot only (counts/flags/ids),\n // never the patient name or any clinical content.\n const handle = useMemo<PatientSummaryCardHandle>(\n () => ({\n getSummary: () => ({\n id,\n hasUnpaid,\n unsignedDocumentsCount,\n highlightedAnamnesisCount,\n aiConsentGranted: aiConsent != null,\n }),\n }),\n [\n id,\n hasUnpaid,\n unsignedDocumentsCount,\n highlightedAnamnesisCount,\n aiConsent,\n ],\n );\n useAgentRegistration(patientSummaryCardAgent, handle, id);\n\n // Per-context field visibility. The cog (and live reordering) only engages\n // with the shared `sections` model AND an `onVisibleFieldsChange` handler;\n // legacy contact-prop cards stay read-only. The order is this placement's\n // own preference — never shared across surfaces.\n const customizable = !!sections && !!onVisibleFieldsChange;\n const fieldVisibility = usePatientFieldVisibility(sections ?? NO_SECTIONS, {\n value: visibleFieldOrder,\n onChange: onVisibleFieldsChange,\n });\n\n const resolvedAriaLabel =\n ariaLabel ??\n t('patientSummaryCard.regionLabel', { defaultValue: 'Patient overview' });\n\n // Heading text: optional honorific prefix + name.\n const TITLE_DEFAULTS: Record<'mr' | 'ms', string> = {\n mr: 'Mr.',\n ms: 'Ms.',\n };\n const honorific = title\n ? t(`patientSummaryCard.title.${title}`, {\n defaultValue: TITLE_DEFAULTS[title],\n })\n : undefined;\n const headingText = honorific ? `${honorific} ${name}` : name;\n\n // Identity line: the canonical sex / age / dob chips below the name — the\n // SAME chips the field model renders, so the header and the field rows\n // agree. Each chip is added only when its prop is present. (`dateOfBirth`\n // is a consumer-preformatted display string, so it goes through NeutralChip\n // directly rather than the date-parsing `dob` kind.)\n const identityChips: ReactNode[] = [];\n if (gender) {\n identityChips.push(<SexChip key=\"sex\" code={gender} />);\n }\n if (ageYears != null) {\n identityChips.push(<AgeChip key=\"age\" years={ageYears} />);\n }\n if (dateOfBirth) {\n identityChips.push(\n <NeutralChip key=\"dob\" icon={<CalendarDays />}>\n {dateOfBirth}\n </NeutralChip>,\n );\n }\n\n const isUrlSafe = !!patientUrl && isSafeEntityUrl(patientUrl);\n\n const avatarSize = density === 'comfortable' ? 'xl' : 'lg';\n const headingClass =\n density === 'comfortable' ? 'type-title-card' : 'type-title-item';\n const bodyGapClass =\n density === 'comfortable'\n ? 'ds:gap-[var(--spacing-md)]'\n : 'ds:gap-[var(--spacing-sm)]';\n\n /* ---------------------------------------------------------------- */\n /* Contact rows */\n /* ---------------------------------------------------------------- */\n\n const rows: Array<{\n key: string;\n icon: ReactElement;\n label: string;\n value: ReactNode;\n }> = [];\n\n if (email) {\n rows.push({\n key: 'email',\n icon: <Mail aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.email', { defaultValue: 'Email' }),\n value: emailEnabled ? (\n <Link href={`mailto:${email}`} intent=\"default\" onClick={onActivate}>\n {email}\n </Link>\n ) : (\n <span className=\"ds:text-[color:var(--muted-foreground)]\">\n {email}\n </span>\n ),\n });\n }\n\n if (phone) {\n rows.push({\n key: 'phone',\n icon: <Phone aria-hidden=\"true\" />,\n label:\n phone.label ??\n t('patientSummaryCard.label.phone', { defaultValue: 'Phone' }),\n value: (\n <span className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-2xs)]\">\n <Link\n href={`tel:${normalisePhone(phone.prefixAndNumber)}`}\n intent=\"default\"\n >\n {phone.prefixAndNumber}\n </Link>\n {phone.smsEnabled ? (\n <Badge variant=\"success\" size=\"sm\">\n {t('patientSummaryCard.value.smsEnabled', {\n defaultValue: 'SMS',\n })}\n </Badge>\n ) : null}\n </span>\n ),\n });\n }\n\n if (cityProvince) {\n rows.push({\n key: 'cityProvince',\n icon: <MapPin aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.cityProvince', {\n defaultValue: 'City / province',\n }),\n value: cityProvince,\n });\n }\n\n if (marketingConsent) {\n rows.push({\n key: 'marketingConsent',\n icon: <ShieldCheck aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.marketingConsent', {\n defaultValue: 'Marketing consent',\n }),\n value: (\n <Badge\n variant={\n marketingConsent === 'yes'\n ? 'success'\n : marketingConsent === 'no'\n ? 'error'\n : 'neutral'\n }\n size=\"sm\"\n withDot\n >\n {t(`patientSummaryCard.marketingConsent.${marketingConsent}`, {\n defaultValue: MARKETING_CONSENT_DEFAULTS[marketingConsent],\n })}\n </Badge>\n ),\n });\n }\n\n if (aiConsent) {\n rows.push({\n key: 'aiConsent',\n icon: <Astroid aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.aiConsent', {\n defaultValue: 'AI consent',\n }),\n value: aiConsent.grantedBy\n ? t('patientSummaryCard.value.aiConsentGrantedBy', {\n date: aiConsent.grantedAt,\n by: aiConsent.grantedBy,\n defaultValue: 'Granted {{date}} by {{by}}',\n })\n : t('patientSummaryCard.value.aiConsentGrantedAt', {\n date: aiConsent.grantedAt,\n defaultValue: 'Granted {{date}}',\n }),\n });\n }\n\n if (assignedTo) {\n rows.push({\n key: 'assignedTo',\n icon: <Users aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.assignedTo', {\n defaultValue: 'Assigned to',\n }),\n value: (\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <Avatar\n size=\"xs\"\n name={assignedTo.name}\n src={assignedTo.avatarUrl}\n />\n <span>{assignedTo.name}</span>\n </span>\n ),\n });\n }\n\n /* ---------------------------------------------------------------- */\n /* Attention-flag chips (VERBOSE — shown in the identity line) */\n /* */\n /* The unpaid balance + warning counts sit in the chip row under the */\n /* name, BEFORE the sex / age chips, each as a self-describing chip */\n /* (\"2 unsigned documents\") rather than a collapsed count badge in a */\n /* separate strip — the attention signals lead the patient's chips. */\n /* ---------------------------------------------------------------- */\n\n const flagBadges: Array<{ key: FlagKey; count: number }> = [];\n if (highlightedAnamnesisCount > 0) {\n flagBadges.push({\n key: 'highlightedAnamnesis',\n count: highlightedAnamnesisCount,\n });\n }\n if (unsignedDocumentsCount > 0) {\n flagBadges.push({\n key: 'unsignedDocuments',\n count: unsignedDocumentsCount,\n });\n }\n\n /* A chip becomes a BUTTON only when the host gave it somewhere to go.\n The chip's own text is already its accessible name, so the wrapper adds\n no label of its own and contributes no padding — the strip's rhythm is\n identical whether or not a chip is actionable. */\n /* A chip becomes a CONTROL when it has something to reveal or somewhere\n to go, and the trigger is always a real <button> — `asChild` on a bare\n <span> badge stamps `aria-haspopup` onto something a keyboard can never\n reach, which is both a dead end and an axe violation.\n\n The division of labour is the same on every chip: the chip opens its\n card (hover, or click / Enter for keyboard and touch), and the card's\n own top-end button performs the action. One gesture to learn, and no\n chip that acts differently from its neighbour. */\n const asAction = (id: PatientSummaryCardFlagId, chip: ReactNode) => {\n const onActivateFlag = onFlagActivate?.[id];\n const hover = flagHover?.[id];\n if (hover == null && !onActivateFlag) return chip;\n\n const triggerClasses =\n 'ds:inline-flex ds:cursor-pointer ds:rounded-[var(--radius-full)] ds:p-0 ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]';\n\n // No card: the chip itself is the action.\n if (hover == null) {\n return (\n <button\n key={id}\n type=\"button\"\n data-flag-action={id}\n onClick={onActivateFlag}\n className={triggerClasses}\n >\n {chip}\n </button>\n );\n }\n\n const trigger = (\n <button\n key={id}\n type=\"button\"\n data-flag-action={onActivateFlag ? id : undefined}\n data-flag-hover={id}\n className={triggerClasses}\n >\n {chip}\n </button>\n );\n\n // A string still renders a plain Tooltip, for a chip that needs naming\n // rather than a card.\n if (typeof hover === 'string') {\n return (\n <Tooltip key={id} label={hover} side=\"bottom\">\n {trigger}\n </Tooltip>\n );\n }\n\n return (\n <HoverCard key={id}>\n <HoverCard.Trigger asChild>{trigger}</HoverCard.Trigger>\n <HoverCard.Content\n side=\"bottom\"\n align=\"start\"\n size=\"sm\"\n headerAction={\n onActivateFlag && flagOpenLabel?.[id] ? (\n <IconButton\n icon={<ArrowUpRight />}\n /* Outline, not ghost: the card's own surface is already\n light, so a borderless glyph reads as decoration rather\n than a control. */\n intent=\"outline\"\n background=\"surface\"\n size=\"sm\"\n aria-label={flagOpenLabel[id] as string}\n onClick={onActivateFlag}\n />\n ) : undefined\n }\n >\n {hover}\n </HoverCard.Content>\n </HoverCard>\n );\n };\n\n const attentionChips: ReactNode[] = [];\n if (hasUnpaid) {\n attentionChips.push(\n asAction(\n 'unpaid',\n <TransactionChip\n key=\"unpaid\"\n state=\"debt\"\n amount={(unpaidAmountCents as number) / 100}\n currency={currency}\n locale={activeLocale}\n size=\"md\"\n showLabel\n />,\n ),\n );\n }\n flagBadges.forEach(({ key, count }) => {\n const FlagIcon = FLAG_ICON[key];\n // The Badge's visible text IS the count-interpolated label, so it's its\n // own accessible name — the leading glyph is decorative (aria-hidden).\n attentionChips.push(\n asAction(\n key,\n <Badge\n key={key}\n variant={FLAG_VARIANT[key]}\n size=\"md\"\n leading={<FlagIcon aria-hidden=\"true\" />}\n >\n {t(`patientSummaryCard.flag.${key}`, {\n count,\n defaultValue: FLAG_LABEL_DEFAULTS[key],\n })}\n </Badge>,\n ),\n );\n });\n if (extraChips) attentionChips.push(extraChips);\n\n /* ---------------------------------------------------------------- */\n /* Loading skeleton */\n /* ---------------------------------------------------------------- */\n\n const skeletonBody = (\n <div className={`ds:flex ds:flex-col ${bodyGapClass}`}>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-md)]\">\n <Skeleton variant=\"circular\" size=\"lg\" />\n <div className=\"ds:flex ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <Skeleton variant=\"text\" width=\"60%\" />\n <Skeleton variant=\"text\" width=\"40%\" />\n </div>\n </div>\n <Skeleton variant=\"text\" lines={3} />\n </div>\n );\n\n /* ---------------------------------------------------------------- */\n /* Header */\n /* ---------------------------------------------------------------- */\n\n const heading = isUrlSafe ? (\n <Link\n href={patientUrl as string}\n intent=\"default\"\n weight=\"strong\"\n onClick={onActivate}\n className={`${headingClass} ds:no-underline`}\n >\n <span id={headingId}>{headingText}</span>\n </Link>\n ) : (\n <span\n id={headingId}\n className={`${headingClass} ds:text-[color:var(--foreground)]`}\n >\n {headingText}\n </span>\n );\n\n const header = (\n <div className=\"ds:flex ds:items-start ds:gap-[var(--spacing-md)]\">\n <Avatar\n size={avatarSize}\n name={name}\n src={avatarUrl}\n className=\"ds:shrink-0\"\n />\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]\">\n {heading}\n {attentionChips.length > 0 || identityChips.length > 0 ? (\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]\">\n {/* Attention flags lead, then the sex / age / dob identity chips. */}\n {attentionChips}\n {identityChips}\n </div>\n ) : null}\n </div>\n {customizable || actionSlot ? (\n <div className=\"ds:ms-auto ds:flex ds:shrink-0 ds:items-center ds:gap-[var(--spacing-xs)]\">\n {customizable && sections ? (\n <FieldVisibilityCog\n sections={sections}\n visible={fieldVisibility.visible}\n onToggleField={fieldVisibility.toggleField}\n onToggleSection={fieldVisibility.toggleSection}\n onMoveFieldOnto={fieldVisibility.moveFieldOnto}\n onReset={fieldVisibility.reset}\n />\n ) : null}\n {actionSlot}\n </div>\n ) : null}\n </div>\n );\n\n /* ---------------------------------------------------------------- */\n /* Family relations */\n /* ---------------------------------------------------------------- */\n\n const familyBlock =\n familyRelations && familyRelations.length > 0 ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label ds:text-[color:var(--muted-foreground)]\">\n {t('patientSummaryCard.label.familyRelations', {\n defaultValue: 'Family relations',\n })}\n </span>\n <div className=\"ds:flex ds:flex-wrap ds:gap-[var(--spacing-2xs)]\">\n {familyRelations.map((rel, index) => {\n const safeUrl =\n !!rel.relatedPatient.url &&\n isSafeEntityUrl(rel.relatedPatient.url);\n const tagLabel = t('patientSummaryCard.value.familyRelation', {\n relation: rel.relation,\n name: rel.relatedPatient.name,\n defaultValue: '{{relation}}: {{name}}',\n });\n return safeUrl ? (\n <Link\n key={`${rel.relation}-${index}`}\n href={rel.relatedPatient.url as string}\n intent=\"default\"\n className=\"ds:no-underline\"\n >\n <Tag label={tagLabel} variant=\"neutral\" />\n </Link>\n ) : (\n <Tag\n key={`${rel.relation}-${index}`}\n label={tagLabel}\n variant=\"neutral\"\n />\n );\n })}\n </div>\n </div>\n ) : null;\n\n /* ---------------------------------------------------------------- */\n /* Body */\n /* ---------------------------------------------------------------- */\n\n // Field rows resolve through the SHARED model: when the consumer passes\n // `sections` (preferred), render those; otherwise wrap the legacy contact\n // rows as a single section. Either way `resolveVisibleFields` applies the\n // shared `visibleFieldOrder` preference, so the card and PatientDetails\n // always show the same fields, honouring the same per-user choice.\n const legacyFields: PatientField[] = rows.map((row) => ({\n id: row.key,\n label: row.label,\n value: row.value,\n icon: row.icon,\n }));\n const effectiveSections: PatientFieldSection[] = sections ?? [\n { id: 'contact', heading: '', fields: legacyFields },\n ];\n // With the shared `sections` model the order comes from the visibility hook\n // (so a cog reorder reflects live); legacy contact rows honour the raw\n // `visibleFieldOrder` prop.\n const order = sections ? fieldVisibility.visible : visibleFieldOrder;\n const visibleFields = resolveVisibleFields(\n effectiveSections,\n order,\n ).flatMap((resolved) => resolved.fields);\n\n const body = (\n <div className={`ds:flex ds:flex-col ${bodyGapClass}`}>\n {header}\n {visibleFields.length > 0 ? (\n // Container-queried so the fields flow into two columns when the\n // card is wide enough (the banner spans the full folder width), and\n // stay single-column in a narrow rail. The list's KeyValuePair\n // children already `col-span-3`; doubling the parent to six tracks\n // (`repeat(2, …)`) lets grid auto-flow place two fields per row while\n // each column keeps its own subgrid label/value alignment.\n // 672px, not the `@2xl` rem alias: container-query `rem` follows the\n // host root font-size, so a non-16px root moves the threshold.\n <div className=\"ds:@container/pfields\">\n <KeyValueList\n rowGap=\"sm\"\n className=\"ds:@[672px]/pfields:grid-cols-[repeat(2,auto_auto_minmax(0,1fr))]\"\n >\n {visibleFields.map((field) => (\n <KeyValuePair\n key={field.id}\n icon={field.icon ?? undefined}\n label={field.label}\n labelNode={<PatientFieldLabel field={field} />}\n // `group` is what reveals the edit pencil on hover / focus;\n // the cell itself carries no row markup.\n className=\"ds:group\"\n data-field-id={field.id}\n value={\n <PatientFieldValueCell\n field={field}\n editable={editable}\n onFieldSave={onFieldSave}\n validate={validateField}\n locale={locale}\n />\n }\n />\n ))}\n </KeyValueList>\n </div>\n ) : null}\n {familyBlock}\n </div>\n );\n\n const inner = loading ? skeletonBody : body;\n\n return (\n <div\n ref={ref}\n role=\"region\"\n // When the heading is rendered, the patient name (via\n // aria-labelledby) is the region's accessible name — the more\n // meaningful label than a generic \"Patient overview\". A consumer\n // aria-label still wins; the generic fallback only applies when\n // there is no heading to point at (loading state).\n aria-label={loading || ariaLabel ? resolvedAriaLabel : undefined}\n aria-labelledby={loading || ariaLabel ? undefined : headingId}\n aria-busy={loading || undefined}\n data-component=\"patient-summary-card\"\n data-component-id={id}\n data-density={density}\n id={id}\n className={rootVariants({ surface, density, className })}\n {...rest}\n >\n {surface === 'elevated' ? (\n <Card variant=\"elevated\">\n <Card.Body>{inner}</Card.Body>\n </Card>\n ) : (\n inner\n )}\n </div>\n );\n },\n);\n\nPatientSummaryCard.displayName = 'PatientSummaryCard';\n\n/** Variant unions re-exported for downstream typing. */\nexport type PatientSummaryCardSurface = NonNullable<\n VariantProps<typeof rootVariants>['surface']\n>;\nexport type PatientSummaryCardDensity = NonNullable<\n VariantProps<typeof rootVariants>['density']\n>;\n"],"names":["__iconNode","FileExclamationPoint","createLucideIcon","MessageSquareWarning","patientSummaryCardAgent","handle","NO_SECTIONS","rootVariants","cva","normalisePhone","raw","FLAG_ICON","FLAG_VARIANT","FLAG_LABEL_DEFAULTS","MARKETING_CONSENT_DEFAULTS","PatientSummaryCard","forwardRef","name","title","ageYears","dateOfBirth","gender","avatarUrl","patientUrl","sections","visibleFieldOrder","onVisibleFieldsChange","email","emailEnabled","phone","cityProvince","marketingConsent","aiConsent","flags","familyRelations","assignedTo","currency","locale","loading","actionSlot","onFlagActivate","flagHover","flagOpenLabel","extraChips","editable","onFieldSave","validateField","onActivate","surface","density","ariaLabel","id","className","rest","ref","i18n","useTranslation","headingId","useId","activeLocale","unpaidAmountCents","unsignedDocumentsCount","highlightedAnamnesisCount","hasUnpaid","useMemo","useAgentRegistration","customizable","fieldVisibility","usePatientFieldVisibility","resolvedAriaLabel","TITLE_DEFAULTS","honorific","headingText","identityChips","jsx","SexChip","AgeChip","NeutralChip","CalendarDays","isUrlSafe","isSafeEntityUrl","avatarSize","headingClass","bodyGapClass","rows","Mail","Link","Phone","jsxs","Badge","MapPin","ShieldCheck","Astroid","Users","Avatar","flagBadges","asAction","chip","onActivateFlag","hover","triggerClasses","trigger","Tooltip","HoverCard","IconButton","ArrowUpRight","attentionChips","TransactionChip","key","count","FlagIcon","skeletonBody","Skeleton","heading","header","FieldVisibilityCog","familyBlock","rel","index","safeUrl","tagLabel","Tag","legacyFields","row","effectiveSections","order","visibleFields","resolveVisibleFields","resolved","body","KeyValueList","field","KeyValuePair","PatientFieldLabel","PatientFieldValueCell","inner","Card"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GA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AAA,oBACA,aAAAC;AAAA,oBACA,UAAUC;AAAA,oBACV,QAAAT;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACF;AAAA,cAfG8F,EAAM;AAAA,YAAA,CAkBd;AAAA,UAAA;AAAA,QAAA,EACH,CACF;AAAA,UACE;AAAA,MACHf;AAAA,IAAA,GACH,GAGImB,KAAQjG,IAAUyE,KAAekB;AAEvC,WACE,gBAAAvD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAApB;AAAA,QACA,MAAK;AAAA,QAML,cAAYhB,KAAWY,IAAYmB,KAAoB;AAAA,QACvD,mBAAiB/B,KAAWY,IAAY,SAAYO;AAAA,QACpD,aAAWnB,KAAW;AAAA,QACtB,kBAAe;AAAA,QACf,qBAAmBa;AAAA,QACnB,gBAAcF;AAAA,QACd,IAAAE;AAAA,QACA,WAAW5C,GAAa,EAAE,SAAAyC,GAAS,SAAAC,GAAS,WAAAG,IAAW;AAAA,QACtD,GAAGC;AAAA,QAEH,UAAAL,MAAY,aACX,gBAAA0B,EAAC8D,IAAA,EAAK,SAAQ,YACZ,UAAA,gBAAA9D,EAAC8D,GAAK,MAAL,EAAW,UAAAD,GAAA,CAAM,EAAA,CACpB,IAEAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAxH,GAAmB,cAAc;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"patient-summary-card-BzmJH9a-.js","sources":["../../node_modules/lucide-react/dist/esm/icons/file-exclamation-point.mjs","../../node_modules/lucide-react/dist/esm/icons/message-square-warning.mjs","../../src/components/patient-summary-card/patient-summary-card.agent.ts","../../src/components/patient-summary-card/patient-summary-card.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\",\n key: \"1oefj6\"\n }\n ],\n [\"path\", { d: \"M12 9v4\", key: \"juzpu7\" }],\n [\"path\", { d: \"M12 17h.01\", key: \"p32p05\" }]\n];\nconst FileExclamationPoint = createLucideIcon(\"file-exclamation-point\", __iconNode);\n\nexport { __iconNode, FileExclamationPoint as default };\n//# sourceMappingURL=file-exclamation-point.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\",\n key: \"18887p\"\n }\n ],\n [\"path\", { d: \"M12 15h.01\", key: \"q59x07\" }],\n [\"path\", { d: \"M12 7v4\", key: \"xawao1\" }]\n];\nconst MessageSquareWarning = createLucideIcon(\"message-square-warning\", __iconNode);\n\nexport { __iconNode, MessageSquareWarning as default };\n//# sourceMappingURL=message-square-warning.mjs.map\n","import type { AgentAdapter } from '../../agent/types';\nimport type { PatientSummaryCardHandle } from './patient-summary-card';\n\n/* -------------------------------------------------------------------- */\n/* Agent adapter — PatientSummaryCard */\n/* */\n/* Read-only adapter. Surfaces a STRUCTURAL snapshot of the patient */\n/* overview — counts, flags, and the consumer id only. Never the patient */\n/* name, age, contact details, or any clinical content, so an agent / */\n/* MCP runtime can answer \"does this patient have unpaid balances / */\n/* unsigned documents / AI consent?\" without re-parsing the DOM and */\n/* without leaking PHI (PRS §Security). */\n/* -------------------------------------------------------------------- */\n\nexport const patientSummaryCardAgent: AgentAdapter<PatientSummaryCardHandle> = {\n id: 'patient-summary-card',\n // The agent surface is a structural snapshot only — the single handle method\n // is a getSummary projection. The card MAY be human-customized (the optional\n // per-context \"Customize fields\" cog), but that field reordering is a UI\n // concern and is deliberately NOT exposed as an agent action; programmatic\n // field-set control lives on PatientDetails' adapter (set_field_order).\n capabilities: [],\n state: {\n summary: {\n type: '{ id?: string; hasUnpaid: boolean; unsignedDocumentsCount: number; highlightedAnamnesisCount: number; aiConsentGranted: boolean }',\n descriptionKey: 'ui.agent.patientSummaryCard.state.summary',\n description:\n 'Structural summary of the patient card — identifiers, counts, and consent flags only. Never patient identity or clinical content.',\n read: (handle) => handle.getSummary(),\n },\n },\n actions: {},\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'patient-summary-card',\n description: 'Marks the PatientSummaryCard root region.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useId,\n useMemo,\n type ComponentPropsWithoutRef,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n ArrowUpRight,\n CalendarDays,\n FileExclamationPoint,\n Mail,\n MapPin,\n MessageSquareWarning,\n Phone,\n ShieldCheck,\n Astroid,\n Users,\n type LucideIcon,\n} from 'lucide-react';\nimport { Avatar } from '../avatar/avatar';\nimport { Badge } from '../badge/badge';\nimport { IconButton } from '../button/icon-button';\nimport { Card } from '../card/card';\nimport { KeyValueList, KeyValuePair } from '../key-value-pair/key-value-pair';\nimport { Link } from '../link/link';\nimport { Skeleton } from '../skeleton/skeleton';\nimport { Tag } from '../tag/tag';\nimport { TransactionChip } from '../transaction-chip/transaction-chip';\nimport { Tooltip } from '../tooltip';\nimport { HoverCard } from '../hover-card';\nimport { isSafeEntityUrl } from '../_shared/is-safe-url';\nimport {\n resolveVisibleFields,\n type PatientField,\n type PatientFieldSection,\n} from '../_shared/patient-fields';\nimport { usePatientFieldVisibility } from '../_shared/field-visibility';\nimport { FieldVisibilityCog } from '../_shared/field-visibility-cog';\nimport { AgeChip, NeutralChip, SexChip } from '../_shared/field-value';\nimport {\n PatientFieldLabel,\n PatientFieldValueCell,\n} from '../_shared/patient-field-row';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { patientSummaryCardAgent } from './patient-summary-card.agent';\n\n/** A section list reference that stays stable across renders (legacy mode). */\nconst NO_SECTIONS: PatientFieldSection[] = [];\n\n/* -------------------------------------------------------------------- */\n/* PatientSummaryCard */\n/* */\n/* The patient-overview profile card every AlfaDocs in-app surface */\n/* composes by hand today (platform patient header, alfascribe patient */\n/* sidebar, check-in landing). Templated on ContactProfileCard: composes */\n/* Card + Avatar + KeyValueList + KeyValuePair + Badge + Tag + */\n/* TransactionChip + Link so the contact rows share a column and every */\n/* row uses the same lucide icon family. */\n/* */\n/* The kit owns the ORDER, ICONS, and LABELS — consumers pass data. No */\n/* free-text clinical content (anamnesis notes, diagnoses) ever lives */\n/* here: only counts/flags/relations are surfaced, so the card stays */\n/* PHI-light and the agent state can be derived without leaking patient */\n/* identity. */\n/* */\n/* All visible text flows through `useTranslation('ui')` against the */\n/* `patientSummaryCard.*` namespace. */\n/* -------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------- */\n/* CVA — root */\n/* -------------------------------------------------------------------- */\n\nconst rootVariants = cva('ds:w-full ds:text-[color:var(--foreground)]', {\n variants: {\n // Matches the kit's other `surface` props (ContactProfileCard,\n // OperatorHero). `'elevated'` wraps the content in `<Card>`.\n surface: {\n flat: '',\n elevated: '',\n },\n // Density tunes the avatar size + body padding. `comfortable` reads\n // as a page header; `compact` fits an embedded sidebar / aside.\n density: {\n comfortable: '',\n compact: '',\n },\n },\n defaultVariants: {\n surface: 'elevated',\n density: 'comfortable',\n },\n});\n\n/* -------------------------------------------------------------------- */\n/* Public types */\n/* -------------------------------------------------------------------- */\n\n/** Patient phone number — already formatted for display by the consumer. */\nexport interface PatientSummaryCardPhone {\n /** Display string, e.g. `\"+39 055 123 4567\"`. Compiled into a `tel:` link. */\n prefixAndNumber: string;\n /** Optional label that distinguishes this number (e.g. \"Mobile\"). */\n label?: string;\n /** Whether SMS is enabled for this number — shows a small \"SMS\" chip. */\n smsEnabled?: boolean;\n}\n\n/** A family relation row — links one patient to another. */\nexport interface PatientSummaryCardFamilyRelation {\n /** Localised relation label, consumer-supplied (e.g. \"Mother\", \"Child\"). */\n relation: string;\n /** The related patient — name + optional in-app profile URL. */\n relatedPatient: {\n name: string;\n url?: string;\n };\n}\n\n/** Operator the patient is assigned to. */\nexport interface PatientSummaryCardAssignee {\n name: string;\n avatarUrl?: string;\n}\n\n/** AI-consent grant metadata — structural only, never the consented content. */\nexport interface PatientSummaryCardAiConsent {\n /** ISO-8601 / display string of when consent was granted. */\n grantedAt: string;\n /** Optional name of who recorded the grant. */\n grantedBy?: string;\n}\n\n/** Addressable attention flags — the keys `onFlagActivate` accepts. */\nexport type PatientSummaryCardFlagId =\n | 'highlightedAnamnesis'\n | 'unsignedDocuments'\n | 'unpaid';\n\n/** Status flags rendered as glyph badges (counts / amounts only — no PHI). */\nexport interface PatientSummaryCardFlags {\n /** Number of anamnesis answers highlighted for clinical attention. */\n highlightedAnamnesisCount?: number;\n /** Outstanding balance in the smallest currency unit (cents). */\n unpaidAmountCents?: number;\n /** Number of documents awaiting the patient's signature. */\n unsignedDocumentsCount?: number;\n}\n\n/** Marketing-consent tri-state. */\nexport type PatientSummaryCardMarketingConsent = 'no' | 'yes' | 'not_specified';\n\nexport interface PatientSummaryCardHandle {\n /** Structural snapshot — identifiers and counts only, never patient identity. */\n getSummary: () => {\n id?: string;\n hasUnpaid: boolean;\n unsignedDocumentsCount: number;\n highlightedAnamnesisCount: number;\n aiConsentGranted: boolean;\n };\n}\n\nexport interface PatientSummaryCardProps extends Omit<\n ComponentPropsWithoutRef<'div'>,\n 'aria-label' | 'children'\n> {\n /** Patient display name. Rendered as the heading. */\n name: string;\n /** Honorific — `'mr'` / `'ms'`. Prepended to the name in the heading. */\n title?: 'mr' | 'ms';\n /** Patient age in whole years — rendered in the identity line. */\n ageYears?: number;\n /** Date of birth — already formatted for display by the consumer. */\n dateOfBirth?: string;\n /** Biological sex marker — `'m'` / `'f'`. Drives the identity-line glyph copy. */\n gender?: 'm' | 'f';\n /** Optional avatar / photo URL. Falls back to initials. */\n avatarUrl?: string;\n /**\n * In-app patient profile URL. When safe, the heading becomes a link.\n * Guarded by the shared `isSafeEntityUrl` allow-list — unsafe URLs are\n * dropped and the heading renders as plain text.\n */\n patientUrl?: string;\n\n /* ----- Shared field model (preferred) ----- */\n\n /**\n * Patient fields in the shared model — the SAME `sections` shape\n * `PatientDetails` consumes (`@alfadocs/ui-kit` `PatientFieldSection`).\n * When provided, the card renders these (honouring `visibleFieldOrder`)\n * instead of the legacy contact props, so a consumer defines its patient-\n * field registry once and reuses it across every patient surface.\n *\n * The card renders each field's `label`, `value`, and `icon` only — it is\n * flat (section headings are not shown in the body) and never inline-edits;\n * `sensitive` / `copyable` / `mono` / `editable` are honoured by\n * `PatientDetails`, not the card (so the PHI lock glyph does not appear here).\n *\n * Pass `onVisibleFieldsChange` alongside `sections` to make THIS placement\n * self-curating (a \"Customize fields\" cog appears — show/hide + drag-and-drop\n * reorder).\n */\n sections?: PatientFieldSection[];\n /**\n * Ordered visible field ids for THIS placement. The order is a\n * per-INSTANCE, per-CONTEXT preference the kit never persists — wire it to\n * whatever scope the consumer wants (e.g. a global per-user setting, or a\n * different config in the care-plan view vs the patient folder). The same\n * field vocabulary can therefore display differently in different parts of\n * the app. Omit (`undefined`) ⇒ show every field; an explicit empty array\n * `[]` ⇒ show none (a card that starts collapsed to name + identity chips and\n * reveals fields via the cog). Also applied to the legacy contact rows (ids\n * `email` / `phone` / `cityProvince` / `marketingConsent` / `aiConsent` /\n * `assignedTo`).\n */\n visibleFieldOrder?: string[];\n /**\n * Make this card's field set user-customizable. When provided alongside\n * `sections`, a \"Customize fields\" cog renders in the header (show/hide +\n * drag-and-drop / Alt+Arrow reorder), and this fires with the next ordered\n * visible set. The consumer owns persistence + its scope — editing here\n * writes only THIS context's preference, never a shared/global one.\n */\n onVisibleFieldsChange?: (orderedIds: string[]) => void;\n\n /* ----- Contact rows (legacy — prefer `sections`) ----- */\n\n /** @deprecated Pass via `sections`. Patient email — `mailto:` link when `emailEnabled`. */\n email?: string;\n /** Whether email contact is enabled — gates the `mailto:` link. */\n emailEnabled?: boolean;\n /** Phone number block. Compiled into a `tel:` link. */\n phone?: PatientSummaryCardPhone;\n /** City / province display string. */\n cityProvince?: string;\n\n /* ----- Consent ----- */\n\n /** Marketing-consent tri-state. */\n marketingConsent?: PatientSummaryCardMarketingConsent;\n /** AI-consent grant metadata. When present, an \"AI consent\" row renders. */\n aiConsent?: PatientSummaryCardAiConsent;\n\n /* ----- Status flags ----- */\n\n /** Counts / amounts surfaced as glyph badges. */\n flags?: PatientSummaryCardFlags;\n\n /* ----- Relations & assignment ----- */\n\n /** Family relations — rendered as `<Tag>` chips, optionally linked. */\n familyRelations?: PatientSummaryCardFamilyRelation[];\n /** Operator the patient is assigned to. */\n assignedTo?: PatientSummaryCardAssignee;\n\n /* ----- Formatting ----- */\n\n /** ISO-4217 currency code for the unpaid-amount chip. Defaults to `EUR`. */\n currency?: string;\n /** BCP-47 locale override. Defaults to the active i18next language. */\n locale?: string;\n\n /* ----- States ----- */\n\n /** Render the skeleton loading placeholder. */\n loading?: boolean;\n\n /* ----- Slots & callbacks ----- */\n\n /** Rendered at the inline-end of the heading row (e.g. an action menu). */\n actionSlot?: ReactNode;\n\n /**\n * Make an attention chip actionable. A handler turns that chip into a\n * button — \"2 unsigned documents\" opens the signing flow, the unpaid\n * balance opens invoicing. Without a handler the chip stays a read-only\n * badge, which is the default: most surfaces have nowhere to send the\n * reader.\n */\n onFlagActivate?: Partial<Record<PatientSummaryCardFlagId, () => void>>;\n /**\n * Explain a chip on hover / focus. The chip states WHAT (\"2 unsigned\n * documents\"); this states what the reader cannot see — how the signature\n * was requested, why the balance is outstanding.\n *\n * A string renders a `Tooltip`; a node renders a `HoverCard` with that node\n * as its content, for a host that wants the fuller card grammar (an eyebrow,\n * fact rows, a hint line). Either way the chip's own text stays the\n * accessible name and the surface only describes it.\n */\n flagHover?: Partial<Record<PatientSummaryCardFlagId, ReactNode>>;\n /**\n * Accessible name for the open button a hover CARD shows in its top-end\n * corner. The button appears only where the flag has BOTH a card and an\n * `onFlagActivate` handler — it mirrors the chip's own click so a pointer\n * that has travelled into the card can still act. Name the destination\n * (\"Open signing\"), not the gesture.\n *\n * Without a label there is no button: a card that merely describes should\n * not sprout an affordance the chip does not have.\n */\n flagOpenLabel?: Partial<Record<PatientSummaryCardFlagId, string>>;\n /**\n * Extra chips appended to the attention row, for signals the CARD cannot\n * model because they do not belong to the patient. An appointment panel\n * adds its own to-invoice and paid-online chips here; the card keeps its\n * patient-level flags and does not grow an appointment vocabulary.\n */\n extraChips?: ReactNode;\n\n /* ----- Inline editing (kit-owned controls, consumer-owned write) ----- */\n\n /**\n * Master switch — show the edit affordance on fields marked `editable` in\n * `sections`. The card edits through the SAME shared control as\n * `PatientDetails`, so a field offers the same affordance and the same\n * validation wherever it is shown.\n */\n editable?: boolean;\n /**\n * The single write channel. A rejected promise keeps the row in edit mode\n * and shows the message inline — the card never optimistically mutates the\n * value it was given.\n */\n onFieldSave?: (fieldId: string, value: unknown) => Promise<void>;\n /** Return a message to block the save and keep the row in edit mode. */\n validateField?: (fieldId: string, value: unknown) => string | null;\n /** Fires when the whole card / heading is activated. */\n onActivate?: () => void;\n\n /* ----- Styling ----- */\n\n /** `'elevated'` (default) wraps in `<Card>`; `'flat'` drops the chrome. */\n surface?: 'flat' | 'elevated';\n /** `'comfortable'` (default) reads as a header; `'compact'` for asides. */\n density?: 'comfortable' | 'compact';\n\n /* ----- a11y ----- */\n\n /** Override the default region aria-label. */\n 'aria-label'?: string;\n /** Agent-readiness consumer id, surfaced as `data-component-id`. */\n id?: string;\n}\n\n/* -------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------- */\n\n/** Strip everything except digits + leading `+` for `tel:` URLs. */\nfunction normalisePhone(raw: string): string {\n return raw.replace(/[^\\d+]/g, '');\n}\n\n/* -------------------------------------------------------------------- */\n/* Flag glyphs — the closed set of status indicators */\n/* -------------------------------------------------------------------- */\n\n/** The closed set of status-flag keys (icon + tonal variant defined below). */\ntype FlagKey = 'highlightedAnamnesis' | 'unsignedDocuments';\n\nconst FLAG_ICON: Record<FlagKey, LucideIcon> = {\n highlightedAnamnesis: MessageSquareWarning,\n unsignedDocuments: FileExclamationPoint,\n};\n\nconst FLAG_VARIANT: Record<FlagKey, 'warning' | 'error'> = {\n highlightedAnamnesis: 'warning',\n unsignedDocuments: 'error',\n};\n\n/** English fallbacks for the flag badge accessible names (count-interpolated). */\nconst FLAG_LABEL_DEFAULTS: Record<FlagKey, string> = {\n highlightedAnamnesis: '{{count}} highlighted anamnesis answers',\n unsignedDocuments: '{{count}} unsigned documents',\n};\n\n/** English fallbacks for the marketing-consent tri-state chip. */\nconst MARKETING_CONSENT_DEFAULTS: Record<\n PatientSummaryCardMarketingConsent,\n string\n> = {\n yes: 'Yes',\n no: 'No',\n not_specified: 'Not specified',\n};\n\n/* -------------------------------------------------------------------- */\n/* Component */\n/* -------------------------------------------------------------------- */\n\nexport const PatientSummaryCard = forwardRef<\n HTMLDivElement,\n PatientSummaryCardProps\n>(\n (\n {\n name,\n title,\n ageYears,\n dateOfBirth,\n gender,\n avatarUrl,\n patientUrl,\n sections,\n visibleFieldOrder,\n onVisibleFieldsChange,\n email,\n emailEnabled = false,\n phone,\n cityProvince,\n marketingConsent,\n aiConsent,\n flags,\n familyRelations,\n assignedTo,\n currency = 'EUR',\n locale,\n loading = false,\n actionSlot,\n onFlagActivate,\n flagHover,\n flagOpenLabel,\n extraChips,\n editable = false,\n onFieldSave,\n validateField,\n onActivate,\n surface = 'elevated',\n density = 'comfortable',\n 'aria-label': ariaLabel,\n id,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const headingId = useId();\n const activeLocale = locale ?? i18n.language ?? 'en';\n\n const unpaidAmountCents = flags?.unpaidAmountCents;\n const unsignedDocumentsCount = flags?.unsignedDocumentsCount ?? 0;\n const highlightedAnamnesisCount = flags?.highlightedAnamnesisCount ?? 0;\n const hasUnpaid = unpaidAmountCents != null && unpaidAmountCents > 0;\n\n // Imperative handle — structural snapshot only (counts/flags/ids),\n // never the patient name or any clinical content.\n const handle = useMemo<PatientSummaryCardHandle>(\n () => ({\n getSummary: () => ({\n id,\n hasUnpaid,\n unsignedDocumentsCount,\n highlightedAnamnesisCount,\n aiConsentGranted: aiConsent != null,\n }),\n }),\n [\n id,\n hasUnpaid,\n unsignedDocumentsCount,\n highlightedAnamnesisCount,\n aiConsent,\n ],\n );\n useAgentRegistration(patientSummaryCardAgent, handle, id);\n\n // Per-context field visibility. The cog (and live reordering) only engages\n // with the shared `sections` model AND an `onVisibleFieldsChange` handler;\n // legacy contact-prop cards stay read-only. The order is this placement's\n // own preference — never shared across surfaces.\n const customizable = !!sections && !!onVisibleFieldsChange;\n const fieldVisibility = usePatientFieldVisibility(sections ?? NO_SECTIONS, {\n value: visibleFieldOrder,\n onChange: onVisibleFieldsChange,\n });\n\n const resolvedAriaLabel =\n ariaLabel ??\n t('patientSummaryCard.regionLabel', { defaultValue: 'Patient overview' });\n\n // Heading text: optional honorific prefix + name.\n const TITLE_DEFAULTS: Record<'mr' | 'ms', string> = {\n mr: 'Mr.',\n ms: 'Ms.',\n };\n const honorific = title\n ? t(`patientSummaryCard.title.${title}`, {\n defaultValue: TITLE_DEFAULTS[title],\n })\n : undefined;\n const headingText = honorific ? `${honorific} ${name}` : name;\n\n // Identity line: the canonical sex / age / dob chips below the name — the\n // SAME chips the field model renders, so the header and the field rows\n // agree. Each chip is added only when its prop is present. (`dateOfBirth`\n // is a consumer-preformatted display string, so it goes through NeutralChip\n // directly rather than the date-parsing `dob` kind.)\n const identityChips: ReactNode[] = [];\n if (gender) {\n identityChips.push(<SexChip key=\"sex\" code={gender} />);\n }\n if (ageYears != null) {\n identityChips.push(<AgeChip key=\"age\" years={ageYears} />);\n }\n if (dateOfBirth) {\n identityChips.push(\n <NeutralChip key=\"dob\" icon={<CalendarDays />}>\n {dateOfBirth}\n </NeutralChip>,\n );\n }\n\n const isUrlSafe = !!patientUrl && isSafeEntityUrl(patientUrl);\n\n const avatarSize = density === 'comfortable' ? 'xl' : 'lg';\n const headingClass =\n density === 'comfortable' ? 'type-title-card' : 'type-title-item';\n const bodyGapClass =\n density === 'comfortable'\n ? 'ds:gap-[var(--spacing-md)]'\n : 'ds:gap-[var(--spacing-sm)]';\n\n /* ---------------------------------------------------------------- */\n /* Contact rows */\n /* ---------------------------------------------------------------- */\n\n const rows: Array<{\n key: string;\n icon: ReactElement;\n label: string;\n value: ReactNode;\n }> = [];\n\n if (email) {\n rows.push({\n key: 'email',\n icon: <Mail aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.email', { defaultValue: 'Email' }),\n value: emailEnabled ? (\n <Link href={`mailto:${email}`} intent=\"default\" onClick={onActivate}>\n {email}\n </Link>\n ) : (\n <span className=\"ds:text-[color:var(--muted-foreground)]\">\n {email}\n </span>\n ),\n });\n }\n\n if (phone) {\n rows.push({\n key: 'phone',\n icon: <Phone aria-hidden=\"true\" />,\n label:\n phone.label ??\n t('patientSummaryCard.label.phone', { defaultValue: 'Phone' }),\n value: (\n <span className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-2xs)]\">\n <Link\n href={`tel:${normalisePhone(phone.prefixAndNumber)}`}\n intent=\"default\"\n >\n {phone.prefixAndNumber}\n </Link>\n {phone.smsEnabled ? (\n <Badge variant=\"success\" size=\"sm\">\n {t('patientSummaryCard.value.smsEnabled', {\n defaultValue: 'SMS',\n })}\n </Badge>\n ) : null}\n </span>\n ),\n });\n }\n\n if (cityProvince) {\n rows.push({\n key: 'cityProvince',\n icon: <MapPin aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.cityProvince', {\n defaultValue: 'City / province',\n }),\n value: cityProvince,\n });\n }\n\n if (marketingConsent) {\n rows.push({\n key: 'marketingConsent',\n icon: <ShieldCheck aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.marketingConsent', {\n defaultValue: 'Marketing consent',\n }),\n value: (\n <Badge\n variant={\n marketingConsent === 'yes'\n ? 'success'\n : marketingConsent === 'no'\n ? 'error'\n : 'neutral'\n }\n size=\"sm\"\n withDot\n >\n {t(`patientSummaryCard.marketingConsent.${marketingConsent}`, {\n defaultValue: MARKETING_CONSENT_DEFAULTS[marketingConsent],\n })}\n </Badge>\n ),\n });\n }\n\n if (aiConsent) {\n rows.push({\n key: 'aiConsent',\n icon: <Astroid aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.aiConsent', {\n defaultValue: 'AI consent',\n }),\n value: aiConsent.grantedBy\n ? t('patientSummaryCard.value.aiConsentGrantedBy', {\n date: aiConsent.grantedAt,\n by: aiConsent.grantedBy,\n defaultValue: 'Granted {{date}} by {{by}}',\n })\n : t('patientSummaryCard.value.aiConsentGrantedAt', {\n date: aiConsent.grantedAt,\n defaultValue: 'Granted {{date}}',\n }),\n });\n }\n\n if (assignedTo) {\n rows.push({\n key: 'assignedTo',\n icon: <Users aria-hidden=\"true\" />,\n label: t('patientSummaryCard.label.assignedTo', {\n defaultValue: 'Assigned to',\n }),\n value: (\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <Avatar\n size=\"xs\"\n name={assignedTo.name}\n src={assignedTo.avatarUrl}\n />\n <span>{assignedTo.name}</span>\n </span>\n ),\n });\n }\n\n /* ---------------------------------------------------------------- */\n /* Attention-flag chips (VERBOSE — shown in the identity line) */\n /* */\n /* The unpaid balance + warning counts sit in the chip row under the */\n /* name, BEFORE the sex / age chips, each as a self-describing chip */\n /* (\"2 unsigned documents\") rather than a collapsed count badge in a */\n /* separate strip — the attention signals lead the patient's chips. */\n /* ---------------------------------------------------------------- */\n\n const flagBadges: Array<{ key: FlagKey; count: number }> = [];\n if (highlightedAnamnesisCount > 0) {\n flagBadges.push({\n key: 'highlightedAnamnesis',\n count: highlightedAnamnesisCount,\n });\n }\n if (unsignedDocumentsCount > 0) {\n flagBadges.push({\n key: 'unsignedDocuments',\n count: unsignedDocumentsCount,\n });\n }\n\n /* A chip becomes a BUTTON only when the host gave it somewhere to go.\n The chip's own text is already its accessible name, so the wrapper adds\n no label of its own and contributes no padding — the strip's rhythm is\n identical whether or not a chip is actionable. */\n /* A chip becomes a CONTROL when it has something to reveal or somewhere\n to go, and the trigger is always a real <button> — `asChild` on a bare\n <span> badge stamps `aria-haspopup` onto something a keyboard can never\n reach, which is both a dead end and an axe violation.\n\n The division of labour is the same on every chip: the chip opens its\n card (hover, or click / Enter for keyboard and touch), and the card's\n own top-end button performs the action. One gesture to learn, and no\n chip that acts differently from its neighbour. */\n const asAction = (id: PatientSummaryCardFlagId, chip: ReactNode) => {\n const onActivateFlag = onFlagActivate?.[id];\n const hover = flagHover?.[id];\n if (hover == null && !onActivateFlag) return chip;\n\n const triggerClasses =\n 'ds:inline-flex ds:cursor-pointer ds:rounded-[var(--radius-full)] ds:p-0 ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]';\n\n // No card: the chip itself is the action.\n if (hover == null) {\n return (\n <button\n key={id}\n type=\"button\"\n data-flag-action={id}\n onClick={onActivateFlag}\n className={triggerClasses}\n >\n {chip}\n </button>\n );\n }\n\n const trigger = (\n <button\n key={id}\n type=\"button\"\n data-flag-action={onActivateFlag ? id : undefined}\n data-flag-hover={id}\n className={triggerClasses}\n >\n {chip}\n </button>\n );\n\n // A string still renders a plain Tooltip, for a chip that needs naming\n // rather than a card.\n if (typeof hover === 'string') {\n return (\n <Tooltip key={id} label={hover} side=\"bottom\">\n {trigger}\n </Tooltip>\n );\n }\n\n return (\n <HoverCard key={id}>\n <HoverCard.Trigger asChild>{trigger}</HoverCard.Trigger>\n <HoverCard.Content\n side=\"bottom\"\n align=\"start\"\n size=\"sm\"\n headerAction={\n onActivateFlag && flagOpenLabel?.[id] ? (\n <IconButton\n icon={<ArrowUpRight />}\n /* Outline, not ghost: the card's own surface is already\n light, so a borderless glyph reads as decoration rather\n than a control. */\n intent=\"outline\"\n background=\"surface\"\n size=\"sm\"\n aria-label={flagOpenLabel[id] as string}\n onClick={onActivateFlag}\n />\n ) : undefined\n }\n >\n {hover}\n </HoverCard.Content>\n </HoverCard>\n );\n };\n\n const attentionChips: ReactNode[] = [];\n if (hasUnpaid) {\n attentionChips.push(\n asAction(\n 'unpaid',\n <TransactionChip\n key=\"unpaid\"\n state=\"debt\"\n amount={(unpaidAmountCents as number) / 100}\n currency={currency}\n locale={activeLocale}\n size=\"md\"\n showLabel\n />,\n ),\n );\n }\n flagBadges.forEach(({ key, count }) => {\n const FlagIcon = FLAG_ICON[key];\n // The Badge's visible text IS the count-interpolated label, so it's its\n // own accessible name — the leading glyph is decorative (aria-hidden).\n attentionChips.push(\n asAction(\n key,\n <Badge\n key={key}\n variant={FLAG_VARIANT[key]}\n size=\"md\"\n leading={<FlagIcon aria-hidden=\"true\" />}\n >\n {t(`patientSummaryCard.flag.${key}`, {\n count,\n defaultValue: FLAG_LABEL_DEFAULTS[key],\n })}\n </Badge>,\n ),\n );\n });\n if (extraChips) attentionChips.push(extraChips);\n\n /* ---------------------------------------------------------------- */\n /* Loading skeleton */\n /* ---------------------------------------------------------------- */\n\n const skeletonBody = (\n <div className={`ds:flex ds:flex-col ${bodyGapClass}`}>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-md)]\">\n <Skeleton variant=\"circular\" size=\"lg\" />\n <div className=\"ds:flex ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <Skeleton variant=\"text\" width=\"60%\" />\n <Skeleton variant=\"text\" width=\"40%\" />\n </div>\n </div>\n <Skeleton variant=\"text\" lines={3} />\n </div>\n );\n\n /* ---------------------------------------------------------------- */\n /* Header */\n /* ---------------------------------------------------------------- */\n\n const heading = isUrlSafe ? (\n <Link\n href={patientUrl as string}\n intent=\"default\"\n weight=\"strong\"\n onClick={onActivate}\n className={`${headingClass} ds:no-underline`}\n >\n <span id={headingId}>{headingText}</span>\n </Link>\n ) : (\n <span\n id={headingId}\n className={`${headingClass} ds:text-[color:var(--foreground)]`}\n >\n {headingText}\n </span>\n );\n\n const header = (\n <div className=\"ds:flex ds:items-start ds:gap-[var(--spacing-md)]\">\n <Avatar\n size={avatarSize}\n name={name}\n src={avatarUrl}\n className=\"ds:shrink-0\"\n />\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]\">\n {heading}\n {attentionChips.length > 0 || identityChips.length > 0 ? (\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]\">\n {/* Attention flags lead, then the sex / age / dob identity chips. */}\n {attentionChips}\n {identityChips}\n </div>\n ) : null}\n </div>\n {customizable || actionSlot ? (\n <div className=\"ds:ms-auto ds:flex ds:shrink-0 ds:items-center ds:gap-[var(--spacing-xs)]\">\n {customizable && sections ? (\n <FieldVisibilityCog\n sections={sections}\n visible={fieldVisibility.visible}\n onToggleField={fieldVisibility.toggleField}\n onToggleSection={fieldVisibility.toggleSection}\n onMoveFieldOnto={fieldVisibility.moveFieldOnto}\n onReset={fieldVisibility.reset}\n />\n ) : null}\n {actionSlot}\n </div>\n ) : null}\n </div>\n );\n\n /* ---------------------------------------------------------------- */\n /* Family relations */\n /* ---------------------------------------------------------------- */\n\n const familyBlock =\n familyRelations && familyRelations.length > 0 ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label ds:text-[color:var(--muted-foreground)]\">\n {t('patientSummaryCard.label.familyRelations', {\n defaultValue: 'Family relations',\n })}\n </span>\n <div className=\"ds:flex ds:flex-wrap ds:gap-[var(--spacing-2xs)]\">\n {familyRelations.map((rel, index) => {\n const safeUrl =\n !!rel.relatedPatient.url &&\n isSafeEntityUrl(rel.relatedPatient.url);\n const tagLabel = t('patientSummaryCard.value.familyRelation', {\n relation: rel.relation,\n name: rel.relatedPatient.name,\n defaultValue: '{{relation}}: {{name}}',\n });\n return safeUrl ? (\n <Link\n key={`${rel.relation}-${index}`}\n href={rel.relatedPatient.url as string}\n intent=\"default\"\n className=\"ds:no-underline\"\n >\n <Tag label={tagLabel} variant=\"neutral\" />\n </Link>\n ) : (\n <Tag\n key={`${rel.relation}-${index}`}\n label={tagLabel}\n variant=\"neutral\"\n />\n );\n })}\n </div>\n </div>\n ) : null;\n\n /* ---------------------------------------------------------------- */\n /* Body */\n /* ---------------------------------------------------------------- */\n\n // Field rows resolve through the SHARED model: when the consumer passes\n // `sections` (preferred), render those; otherwise wrap the legacy contact\n // rows as a single section. Either way `resolveVisibleFields` applies the\n // shared `visibleFieldOrder` preference, so the card and PatientDetails\n // always show the same fields, honouring the same per-user choice.\n const legacyFields: PatientField[] = rows.map((row) => ({\n id: row.key,\n label: row.label,\n value: row.value,\n icon: row.icon,\n }));\n const effectiveSections: PatientFieldSection[] = sections ?? [\n { id: 'contact', heading: '', fields: legacyFields },\n ];\n // With the shared `sections` model the order comes from the visibility hook\n // (so a cog reorder reflects live); legacy contact rows honour the raw\n // `visibleFieldOrder` prop.\n const order = sections ? fieldVisibility.visible : visibleFieldOrder;\n const visibleFields = resolveVisibleFields(\n effectiveSections,\n order,\n ).flatMap((resolved) => resolved.fields);\n\n const body = (\n <div className={`ds:flex ds:flex-col ${bodyGapClass}`}>\n {header}\n {visibleFields.length > 0 ? (\n // Container-queried so the fields flow into two columns when the\n // card is wide enough (the banner spans the full folder width), and\n // stay single-column in a narrow rail. The list's KeyValuePair\n // children already `col-span-3`; doubling the parent to six tracks\n // (`repeat(2, …)`) lets grid auto-flow place two fields per row while\n // each column keeps its own subgrid label/value alignment.\n // 672px, not the `@2xl` rem alias: container-query `rem` follows the\n // host root font-size, so a non-16px root moves the threshold.\n <div className=\"ds:@container/pfields\">\n <KeyValueList\n rowGap=\"sm\"\n className=\"ds:@[672px]/pfields:grid-cols-[repeat(2,auto_auto_minmax(0,1fr))]\"\n >\n {visibleFields.map((field) => (\n <KeyValuePair\n key={field.id}\n icon={field.icon ?? undefined}\n label={field.label}\n labelNode={<PatientFieldLabel field={field} />}\n // `group` is what reveals the edit pencil on hover / focus;\n // the cell itself carries no row markup.\n className=\"ds:group\"\n data-field-id={field.id}\n value={\n <PatientFieldValueCell\n field={field}\n editable={editable}\n onFieldSave={onFieldSave}\n validate={validateField}\n locale={locale}\n />\n }\n />\n ))}\n </KeyValueList>\n </div>\n ) : null}\n {familyBlock}\n </div>\n );\n\n const inner = loading ? skeletonBody : body;\n\n return (\n <div\n ref={ref}\n role=\"region\"\n // When the heading is rendered, the patient name (via\n // aria-labelledby) is the region's accessible name — the more\n // meaningful label than a generic \"Patient overview\". A consumer\n // aria-label still wins; the generic fallback only applies when\n // there is no heading to point at (loading state).\n aria-label={loading || ariaLabel ? resolvedAriaLabel : undefined}\n aria-labelledby={loading || ariaLabel ? undefined : headingId}\n aria-busy={loading || undefined}\n data-component=\"patient-summary-card\"\n data-component-id={id}\n data-density={density}\n id={id}\n className={rootVariants({ surface, density, className })}\n {...rest}\n >\n {surface === 'elevated' ? (\n <Card variant=\"elevated\">\n <Card.Body>{inner}</Card.Body>\n </Card>\n ) : (\n inner\n )}\n </div>\n );\n },\n);\n\nPatientSummaryCard.displayName = 'PatientSummaryCard';\n\n/** Variant unions re-exported for downstream typing. */\nexport type PatientSummaryCardSurface = NonNullable<\n VariantProps<typeof rootVariants>['surface']\n>;\nexport type PatientSummaryCardDensity = NonNullable<\n VariantProps<typeof rootVariants>['density']\n>;\n"],"names":["__iconNode","FileExclamationPoint","createLucideIcon","MessageSquareWarning","patientSummaryCardAgent","handle","NO_SECTIONS","rootVariants","cva","normalisePhone","raw","FLAG_ICON","FLAG_VARIANT","FLAG_LABEL_DEFAULTS","MARKETING_CONSENT_DEFAULTS","PatientSummaryCard","forwardRef","name","title","ageYears","dateOfBirth","gender","avatarUrl","patientUrl","sections","visibleFieldOrder","onVisibleFieldsChange","email","emailEnabled","phone","cityProvince","marketingConsent","aiConsent","flags","familyRelations","assignedTo","currency","locale","loading","actionSlot","onFlagActivate","flagHover","flagOpenLabel","extraChips","editable","onFieldSave","validateField","onActivate","surface","density","ariaLabel","id","className","rest","ref","i18n","useTranslation","headingId","useId","activeLocale","unpaidAmountCents","unsignedDocumentsCount","highlightedAnamnesisCount","hasUnpaid","useMemo","useAgentRegistration","customizable","fieldVisibility","usePatientFieldVisibility","resolvedAriaLabel","TITLE_DEFAULTS","honorific","headingText","identityChips","jsx","SexChip","AgeChip","NeutralChip","CalendarDays","isUrlSafe","isSafeEntityUrl","avatarSize","headingClass","bodyGapClass","rows","Mail","Link","Phone","jsxs","Badge","MapPin","ShieldCheck","Astroid","Users","Avatar","flagBadges","asAction","chip","onActivateFlag","hover","triggerClasses","trigger","Tooltip","HoverCard","IconButton","ArrowUpRight","attentionChips","TransactionChip","key","count","FlagIcon","skeletonBody","Skeleton","heading","header","FieldVisibilityCog","familyBlock","rel","index","safeUrl","tagLabel","Tag","legacyFields","row","effectiveSections","order","visibleFields","resolveVisibleFields","resolved","body","KeyValueList","field","KeyValuePair","PatientFieldLabel","PatientFieldValueCell","inner","Card"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,cAAc,KAAK,SAAQ,CAAE;AAC7C,GACMC,KAAuBC,GAAiB,0BAA0BF,EAAU;ACpBlF;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,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