@alfadocs/ui-kit-debug 1.78.0 → 1.79.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 (199) hide show
  1. package/dist/_chunks/{address-fields-BUPRs3n-.js → address-fields-GnoSkvh6.js} +2 -2
  2. package/dist/_chunks/{address-fields-BUPRs3n-.js.map → address-fields-GnoSkvh6.js.map} +1 -1
  3. package/dist/_chunks/{anamnesis-summary-rows-vNDyE5HW.js → anamnesis-summary-rows-lONg-zja.js} +2 -2
  4. package/dist/_chunks/{anamnesis-summary-rows-vNDyE5HW.js.map → anamnesis-summary-rows-lONg-zja.js.map} +1 -1
  5. package/dist/_chunks/{bishop-score-CdbU9Nl4.js → bishop-score-C5di6oAV.js} +2 -2
  6. package/dist/_chunks/{bishop-score-CdbU9Nl4.js.map → bishop-score-C5di6oAV.js.map} +1 -1
  7. package/dist/_chunks/{bmi-calculator-DnfiDh4Q.js → bmi-calculator-BIExHBZV.js} +2 -2
  8. package/dist/_chunks/{bmi-calculator-DnfiDh4Q.js.map → bmi-calculator-BIExHBZV.js.map} +1 -1
  9. package/dist/_chunks/{booking-Cz_QjIJe.js → booking-BV2s2J3C.js} +3 -3
  10. package/dist/_chunks/{booking-Cz_QjIJe.js.map → booking-BV2s2J3C.js.map} +1 -1
  11. package/dist/_chunks/{calendar-appointment-editor-dialog-cvUpUjj-.js → calendar-appointment-editor-dialog-DhTTWgXw.js} +3 -3
  12. package/dist/_chunks/{calendar-appointment-editor-dialog-cvUpUjj-.js.map → calendar-appointment-editor-dialog-DhTTWgXw.js.map} +1 -1
  13. package/dist/_chunks/{cycle-calculator-HO3s5InI.js → cycle-calculator-CQkjVSD2.js} +2 -2
  14. package/dist/_chunks/{cycle-calculator-HO3s5InI.js.map → cycle-calculator-CQkjVSD2.js.map} +1 -1
  15. package/dist/_chunks/{due-date-calculator-CDWTSblh.js → due-date-calculator-NjTlmoFK.js} +2 -2
  16. package/dist/_chunks/{due-date-calculator-CDWTSblh.js.map → due-date-calculator-NjTlmoFK.js.map} +1 -1
  17. package/dist/_chunks/{fetal-weight-CrtBFJl-.js → fetal-weight-Brl3n4LN.js} +2 -2
  18. package/dist/_chunks/{fetal-weight-CrtBFJl-.js.map → fetal-weight-Brl3n4LN.js.map} +1 -1
  19. package/dist/_chunks/{forgot-password-form-BSOZVrZG.js → forgot-password-form-BQPvDS7i.js} +2 -2
  20. package/dist/_chunks/{forgot-password-form-BSOZVrZG.js.map → forgot-password-form-BQPvDS7i.js.map} +1 -1
  21. package/dist/_chunks/form-field-CyHfOVKF.js +185 -0
  22. package/dist/_chunks/form-field-CyHfOVKF.js.map +1 -0
  23. package/dist/_chunks/{gestational-age-calculator-CTHeJJdb.js → gestational-age-calculator-Dr9hdDta.js} +2 -2
  24. package/dist/_chunks/{gestational-age-calculator-CTHeJJdb.js.map → gestational-age-calculator-Dr9hdDta.js.map} +1 -1
  25. package/dist/_chunks/{hcg-doubling-BBk-a33g.js → hcg-doubling-K41Wy7LB.js} +2 -2
  26. package/dist/_chunks/{hcg-doubling-BBk-a33g.js.map → hcg-doubling-K41Wy7LB.js.map} +1 -1
  27. package/dist/_chunks/{help-me-write-templates-Ds1FY-WY.js → help-me-write-templates-BJSf24xS.js} +2 -2
  28. package/dist/_chunks/{help-me-write-templates-Ds1FY-WY.js.map → help-me-write-templates-BJSf24xS.js.map} +1 -1
  29. package/dist/_chunks/key-round-DIgsnJSg.js +21 -0
  30. package/dist/_chunks/key-round-DIgsnJSg.js.map +1 -0
  31. package/dist/_chunks/{kit-extensions-sNTZWkoo.js → kit-extensions-a0G4COFH.js} +6 -6
  32. package/dist/_chunks/{kit-extensions-sNTZWkoo.js.map → kit-extensions-a0G4COFH.js.map} +1 -1
  33. package/dist/_chunks/login-dev-card-CvLHj-_N.js +353 -0
  34. package/dist/_chunks/login-dev-card-CvLHj-_N.js.map +1 -0
  35. package/dist/_chunks/{pregnancy-dating-JBAUbM40.js → pregnancy-dating-BHvfDxz4.js} +2 -2
  36. package/dist/_chunks/{pregnancy-dating-JBAUbM40.js.map → pregnancy-dating-BHvfDxz4.js.map} +1 -1
  37. package/dist/_chunks/{pregnancy-weight-gain--Bqv6AWu.js → pregnancy-weight-gain-BeQRxwdP.js} +2 -2
  38. package/dist/_chunks/{pregnancy-weight-gain--Bqv6AWu.js.map → pregnancy-weight-gain-BeQRxwdP.js.map} +1 -1
  39. package/dist/_chunks/{radiograph-panel.agent-DQh2SX8G.js → radiograph-panel.agent-BQ95uFCd.js} +2 -2
  40. package/dist/_chunks/{radiograph-panel.agent-DQh2SX8G.js.map → radiograph-panel.agent-BQ95uFCd.js.map} +1 -1
  41. package/dist/_chunks/registration-form-CNBfUduG.js +1337 -0
  42. package/dist/_chunks/registration-form-CNBfUduG.js.map +1 -0
  43. package/dist/_chunks/reset-password-form-Cf9QPEJu.js +367 -0
  44. package/dist/_chunks/reset-password-form-Cf9QPEJu.js.map +1 -0
  45. package/dist/_chunks/{send-registration-link-form-__DWY62q.js → send-registration-link-form-vTn1HxjA.js} +2 -2
  46. package/dist/_chunks/{send-registration-link-form-__DWY62q.js.map → send-registration-link-form-vTn1HxjA.js.map} +1 -1
  47. package/dist/_chunks/{task-editor-CRhfwP9T.js → task-editor-Cpw-NmND.js} +2 -2
  48. package/dist/_chunks/{task-editor-CRhfwP9T.js.map → task-editor-Cpw-NmND.js.map} +1 -1
  49. package/dist/_chunks/{unit-converter-D59L-gkf.js → unit-converter-BH5ueIhT.js} +2 -2
  50. package/dist/_chunks/{unit-converter-D59L-gkf.js.map → unit-converter-BH5ueIhT.js.map} +1 -1
  51. package/dist/_chunks/{voice-control-panel-DQJwe6_Q.js → voice-control-panel-BziKE-KK.js} +2 -2
  52. package/dist/_chunks/{voice-control-panel-DQJwe6_Q.js.map → voice-control-panel-BziKE-KK.js.map} +1 -1
  53. package/dist/_chunks/{workflow-webhook-action-BvVPZVpG.js → workflow-webhook-action-DulCpCRz.js} +96 -111
  54. package/dist/_chunks/workflow-webhook-action-DulCpCRz.js.map +1 -0
  55. package/dist/agent-catalog.json +89 -3
  56. package/dist/agent-i18n/en.json +11 -2
  57. package/dist/components/address-fields/index.js +1 -1
  58. package/dist/components/bishop-score/index.js +1 -1
  59. package/dist/components/bmi-calculator/index.js +1 -1
  60. package/dist/components/booking/index.js +1 -1
  61. package/dist/components/cycle-calculator/index.js +1 -1
  62. package/dist/components/due-date-calculator/index.js +1 -1
  63. package/dist/components/fetal-weight/index.js +1 -1
  64. package/dist/components/form-field/form-field.d.ts +6 -0
  65. package/dist/components/form-field/form-field.d.ts.map +1 -1
  66. package/dist/components/form-field/index.js +1 -1
  67. package/dist/components/gestational-age-calculator/index.js +1 -1
  68. package/dist/components/hcg-doubling/index.js +1 -1
  69. package/dist/components/index.d.ts +1 -0
  70. package/dist/components/index.d.ts.map +1 -1
  71. package/dist/components/pregnancy-dating/index.js +1 -1
  72. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  73. package/dist/components/radiograph-panel/index.js +1 -1
  74. package/dist/components/rich-text-editor/index.js +1 -1
  75. package/dist/components/task-editor/index.js +1 -1
  76. package/dist/components/unit-converter/index.js +1 -1
  77. package/dist/components/voice-control-panel/index.js +1 -1
  78. package/dist/i18n/locales/ar.d.ts +26 -0
  79. package/dist/i18n/locales/ar.d.ts.map +1 -1
  80. package/dist/i18n/locales/ar.js +27 -1
  81. package/dist/i18n/locales/ar.js.map +1 -1
  82. package/dist/i18n/locales/de.d.ts +26 -0
  83. package/dist/i18n/locales/de.d.ts.map +1 -1
  84. package/dist/i18n/locales/de.js +27 -1
  85. package/dist/i18n/locales/de.js.map +1 -1
  86. package/dist/i18n/locales/el.d.ts +26 -0
  87. package/dist/i18n/locales/el.d.ts.map +1 -1
  88. package/dist/i18n/locales/el.js +27 -1
  89. package/dist/i18n/locales/el.js.map +1 -1
  90. package/dist/i18n/locales/en.d.ts +26 -0
  91. package/dist/i18n/locales/en.d.ts.map +1 -1
  92. package/dist/i18n/locales/en.js +26 -0
  93. package/dist/i18n/locales/en.js.map +1 -1
  94. package/dist/i18n/locales/es.d.ts +26 -0
  95. package/dist/i18n/locales/es.d.ts.map +1 -1
  96. package/dist/i18n/locales/es.js +27 -1
  97. package/dist/i18n/locales/es.js.map +1 -1
  98. package/dist/i18n/locales/fr.d.ts +26 -0
  99. package/dist/i18n/locales/fr.d.ts.map +1 -1
  100. package/dist/i18n/locales/fr.js +27 -1
  101. package/dist/i18n/locales/fr.js.map +1 -1
  102. package/dist/i18n/locales/hi.d.ts +26 -0
  103. package/dist/i18n/locales/hi.d.ts.map +1 -1
  104. package/dist/i18n/locales/hi.js +27 -1
  105. package/dist/i18n/locales/hi.js.map +1 -1
  106. package/dist/i18n/locales/it.d.ts +26 -0
  107. package/dist/i18n/locales/it.d.ts.map +1 -1
  108. package/dist/i18n/locales/it.js +27 -1
  109. package/dist/i18n/locales/it.js.map +1 -1
  110. package/dist/i18n/locales/ja.d.ts +26 -0
  111. package/dist/i18n/locales/ja.d.ts.map +1 -1
  112. package/dist/i18n/locales/ja.js +27 -1
  113. package/dist/i18n/locales/ja.js.map +1 -1
  114. package/dist/i18n/locales/nl.d.ts +26 -0
  115. package/dist/i18n/locales/nl.d.ts.map +1 -1
  116. package/dist/i18n/locales/nl.js +27 -1
  117. package/dist/i18n/locales/nl.js.map +1 -1
  118. package/dist/i18n/locales/pl.d.ts +26 -0
  119. package/dist/i18n/locales/pl.d.ts.map +1 -1
  120. package/dist/i18n/locales/pl.js +27 -1
  121. package/dist/i18n/locales/pl.js.map +1 -1
  122. package/dist/i18n/locales/pt.d.ts +26 -0
  123. package/dist/i18n/locales/pt.d.ts.map +1 -1
  124. package/dist/i18n/locales/pt.js +27 -1
  125. package/dist/i18n/locales/pt.js.map +1 -1
  126. package/dist/i18n/locales/ro.d.ts +26 -0
  127. package/dist/i18n/locales/ro.d.ts.map +1 -1
  128. package/dist/i18n/locales/ro.js +27 -1
  129. package/dist/i18n/locales/ro.js.map +1 -1
  130. package/dist/i18n/locales/ru.d.ts +26 -0
  131. package/dist/i18n/locales/ru.d.ts.map +1 -1
  132. package/dist/i18n/locales/ru.js +27 -1
  133. package/dist/i18n/locales/ru.js.map +1 -1
  134. package/dist/i18n/locales/sq.d.ts +26 -0
  135. package/dist/i18n/locales/sq.d.ts.map +1 -1
  136. package/dist/i18n/locales/sq.js +27 -1
  137. package/dist/i18n/locales/sq.js.map +1 -1
  138. package/dist/i18n/locales/sv.d.ts +26 -0
  139. package/dist/i18n/locales/sv.d.ts.map +1 -1
  140. package/dist/i18n/locales/sv.js +27 -1
  141. package/dist/i18n/locales/sv.js.map +1 -1
  142. package/dist/i18n/locales/tr.d.ts +26 -0
  143. package/dist/i18n/locales/tr.d.ts.map +1 -1
  144. package/dist/i18n/locales/tr.js +27 -1
  145. package/dist/i18n/locales/tr.js.map +1 -1
  146. package/dist/i18n/locales/zh.d.ts +26 -0
  147. package/dist/i18n/locales/zh.d.ts.map +1 -1
  148. package/dist/i18n/locales/zh.js +27 -1
  149. package/dist/i18n/locales/zh.js.map +1 -1
  150. package/dist/index.js +89 -86
  151. package/dist/index.js.map +1 -1
  152. package/dist/locales/ar.json +27 -1
  153. package/dist/locales/de.json +27 -1
  154. package/dist/locales/el.json +27 -1
  155. package/dist/locales/en.json +26 -0
  156. package/dist/locales/es.json +27 -1
  157. package/dist/locales/fr.json +27 -1
  158. package/dist/locales/hi.json +27 -1
  159. package/dist/locales/it.json +27 -1
  160. package/dist/locales/ja.json +27 -1
  161. package/dist/locales/nl.json +27 -1
  162. package/dist/locales/pl.json +27 -1
  163. package/dist/locales/pt.json +27 -1
  164. package/dist/locales/ro.json +27 -1
  165. package/dist/locales/ru.json +27 -1
  166. package/dist/locales/sq.json +27 -1
  167. package/dist/locales/sv.json +27 -1
  168. package/dist/locales/tr.json +27 -1
  169. package/dist/locales/zh.json +27 -1
  170. package/dist/patterns/_shared/password-policy.d.ts +3 -0
  171. package/dist/patterns/_shared/password-policy.d.ts.map +1 -0
  172. package/dist/patterns/anamnesis/index.js +1 -1
  173. package/dist/patterns/calendar/index.js +1 -1
  174. package/dist/patterns/forgot-password-form/index.js +1 -1
  175. package/dist/patterns/help-me-write-templates/index.js +1 -1
  176. package/dist/patterns/login-form/index.js +1 -1
  177. package/dist/patterns/login-form/login-form.d.ts +24 -7
  178. package/dist/patterns/login-form/login-form.d.ts.map +1 -1
  179. package/dist/patterns/registration-form/index.d.ts +1 -1
  180. package/dist/patterns/registration-form/index.d.ts.map +1 -1
  181. package/dist/patterns/registration-form/index.js +1 -1
  182. package/dist/patterns/registration-form/registration-form.d.ts +27 -0
  183. package/dist/patterns/registration-form/registration-form.d.ts.map +1 -1
  184. package/dist/patterns/reset-password-form/index.d.ts +3 -0
  185. package/dist/patterns/reset-password-form/index.d.ts.map +1 -0
  186. package/dist/patterns/reset-password-form/index.js +6 -0
  187. package/dist/patterns/reset-password-form/index.js.map +1 -0
  188. package/dist/patterns/reset-password-form/reset-password-form.d.ts +108 -0
  189. package/dist/patterns/reset-password-form/reset-password-form.d.ts.map +1 -0
  190. package/dist/patterns/send-registration-link-form/index.js +1 -1
  191. package/dist/patterns/workflow-webhook-action/index.js +1 -1
  192. package/package.json +5 -1
  193. package/dist/_chunks/form-field-Ani72sVY.js +0 -176
  194. package/dist/_chunks/form-field-Ani72sVY.js.map +0 -1
  195. package/dist/_chunks/login-dev-card-DRxTPkE9.js +0 -332
  196. package/dist/_chunks/login-dev-card-DRxTPkE9.js.map +0 -1
  197. package/dist/_chunks/registration-form-xORq2s4p.js +0 -1310
  198. package/dist/_chunks/registration-form-xORq2s4p.js.map +0 -1
  199. package/dist/_chunks/workflow-webhook-action-BvVPZVpG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"task-editor-CRhfwP9T.js","sources":["../../node_modules/lucide-react/dist/esm/icons/circle-off.mjs","../../node_modules/lucide-react/dist/esm/icons/save.mjs","../../src/components/_shared/compact-editor-fields.ts","../../src/components/_shared/patient-picker.tsx","../../src/components/task-editor/task-editor.agent.ts","../../src/components/task-editor/use-task-editor-form.ts","../../src/components/task-editor/task-editor.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: \"m2 2 20 20\", key: \"1ooewy\" }],\n [\"path\", { d: \"M8.35 2.69A10 10 0 0 1 21.3 15.65\", key: \"1pfsoa\" }],\n [\"path\", { d: \"M19.08 19.08A10 10 0 1 1 4.92 4.92\", key: \"1ablyi\" }]\n];\nconst CircleOff = createLucideIcon(\"circle-off\", __iconNode);\n\nexport { __iconNode, CircleOff as default };\n//# sourceMappingURL=circle-off.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: \"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z\",\n key: \"1c8476\"\n }\n ],\n [\"path\", { d: \"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7\", key: \"1ydtos\" }],\n [\"path\", { d: \"M7 3v4a1 1 0 0 0 1 1h7\", key: \"t51u73\" }]\n];\nconst Save = createLucideIcon(\"save\", __iconNode);\n\nexport { __iconNode, Save as default };\n//# sourceMappingURL=save.mjs.map\n","/**\n * Compact fields for the calendar's appointment and waiting-list entry\n * editors and for the published TaskEditor, which the calendar's task route\n * also renders: 32px high with `--radius-md` corners, the height and shape\n * of the calendar toolbar's controls, where the kit default is 44px with\n * `--radius-sm`. Shared here so a published component can use it.\n *\n * INTENTIONAL EXCEPTION — do not \"fix\" these back to 44px. 32px sits below\n * `--min-target-size` on purpose: it is the toolbar's sanctioned sub-target\n * trade (documented beside `--min-target-size` in `src/tokens/index.css` and\n * in `calendar-toolbar.mdx`). 32×32 clears WCAG 2.5.8 (AA, 24×24), and\n * every field keeps at least `--spacing-md` of clear space from the next.\n *\n * Scoped by a class on each editor's form root, reaching the fields through\n * their `data-component` markers, so the kit-wide `TextInput`, `Select`,\n * `DatePicker`, `TimePicker`, `Combobox` and `NumberInput` defaults stay\n * untouched. The\n * descendant selector outranks each field's own height utility, so no\n * `size` prop is needed — and `Select`'s `size=\"sm\"` would also have shrunk\n * its menu items, which must keep the kit's target.\n *\n * The raise is opt-in, as on the toolbar: under `.theme-accessible` every\n * field goes back to `--min-target-size` (48px), and below the `sm`\n * breakpoint, where the pointer is a finger, to the full target as well.\n * `min-block-size` beats `h-8`, so the raise lands without undoing it.\n */\nexport const EDITOR_COMPACT_FIELDS_CLASS = [\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:h-8',\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:rounded-[var(--radius-md)]',\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:[min-block-size:var(--accessible-target-floor,auto)]',\n 'ds:max-sm:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:[min-block-size:var(--min-target-size)]',\n /* Multi-line notes keep their height but share the corners. */\n 'ds:[&_[data-component=text-area]_textarea]:rounded-[var(--radius-md)]',\n /* The time field's hour and minute segments are 32px at the kit default;\n inside a 32px box they take the kit's `sm` segment height instead,\n and get the default back wherever the field is raised. */\n 'ds:[&_[data-component=time-picker]_[role=spinbutton]]:h-[calc(var(--ds-spacing)*(6+2*var(--accessible-on,0)))]',\n 'ds:max-sm:[&_[data-component=time-picker]_[role=spinbutton]]:h-8',\n].join(' ');\n\n/**\n * The same exception for a `variant=\"segmented\"` RadioGroup (the task\n * editor's \"Concerns\" switch): pass it as the group's `className`. The\n * track takes 32px and its segments stretch to fill it; accessible themes\n * give each segment `--min-target-size` back and let the track grow.\n */\nexport const EDITOR_COMPACT_SEGMENTED_CLASS = [\n 'ds:h-[var(--accessible-auto,calc(var(--ds-spacing)*8))] ds:[&_[role=radio]]:[min-block-size:var(--accessible-target-floor,0px)]',\n 'ds:max-sm:h-auto ds:max-sm:[&_[role=radio]]:min-h-[var(--min-target-size)]',\n].join(' ');\n","/* One id-valued patient control, shared by the published TaskEditor and the\n calendar's editors. It lists a host typeahead's results when one is given,\n or filters a list on the client. The caller names the selected patient and\n translates the placeholder. Moved from the calendar pattern so published\n components can use it. */\nimport { useEffect, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Combobox } from '../combobox';\nimport { Button } from '../button';\nimport { normalizeDiacritics } from './normalize-diacritics';\nimport type { PatientIdentity } from './patient-identity';\n\n/** Host typeahead. Called 250 ms after typing stops, for non-blank trimmed\n * queries only. Abort a superseded call through `signal`. The host's order\n * is kept, so matches by phone or number stay. Reject on failure; `[]` is a\n * successful search with no match. */\nexport type PatientSearch = (\n query: string,\n options: { signal: AbortSignal },\n) => Promise<readonly PatientIdentity[]>;\n\nexport interface PatientPickerProps {\n value: string;\n onValueChange: (value: string) => void;\n /** Filtered on the client when `searchPatients` is absent. */\n patients?: readonly PatientIdentity[];\n /** Wins over `patients` for listing. */\n searchPatients?: PatientSearch;\n /** Names `value` when neither the list nor a search result does. */\n selectedLabel?: string;\n /** Already translated. Also the idle line under a search. */\n placeholder: string;\n size?: 'sm' | 'md';\n disabled?: boolean;\n}\n\nexport function PatientPicker({\n patients = [],\n searchPatients,\n ...props\n}: PatientPickerProps) {\n if (searchPatients) {\n return <PatientSearchPicker {...props} searchPatients={searchPatients} />;\n }\n const { value, onValueChange, selectedLabel, placeholder, size, disabled } =\n props;\n return (\n <Combobox\n value={value}\n onValueChange={onValueChange}\n options={[\n ...(value && !patients.some((p) => p.id === value)\n ? [{ value, label: selectedLabel ?? '' }]\n : []),\n ...patients.map((p) => ({ value: p.id, label: p.name })),\n ]}\n placeholder={placeholder}\n size={size}\n disabled={disabled}\n clearable\n />\n );\n}\n\ninterface SearchState {\n query: string;\n source: PatientSearch;\n status: 'loading' | 'ready' | 'error';\n patients: readonly PatientIdentity[];\n}\n\nfunction PatientSearchPicker({\n value,\n onValueChange,\n selectedLabel,\n placeholder,\n size,\n disabled,\n searchPatients,\n}: Omit<PatientPickerProps, 'patients' | 'searchPatients'> & {\n searchPatients: PatientSearch;\n}) {\n const { t } = useTranslation('ui');\n const [query, setQuery] = useState('');\n const [retry, setRetry] = useState(0);\n const [picked, setPicked] = useState<PatientIdentity>();\n const [state, setState] = useState<SearchState>();\n const inputRef = useRef<HTMLInputElement>(null);\n const trimmedQuery = query.trim();\n\n useEffect(() => {\n if (!trimmedQuery) return;\n const controller = new AbortController();\n const base = { query: trimmedQuery, source: searchPatients };\n setState({ ...base, status: 'loading', patients: [] });\n const timer = setTimeout(() => {\n Promise.resolve()\n .then(() => searchPatients(trimmedQuery, { signal: controller.signal }))\n .then(\n (patients) => {\n if (!controller.signal.aborted)\n setState({ ...base, status: 'ready', patients });\n },\n () => {\n if (!controller.signal.aborted)\n setState({ ...base, status: 'error', patients: [] });\n },\n );\n }, 250);\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [trimmedQuery, searchPatients, retry]);\n\n const current =\n state?.query === trimmedQuery && state.source === searchPatients;\n const status = !trimmedQuery ? 'idle' : current ? state.status : 'loading';\n const patients = current && status === 'ready' ? state.patients : [];\n const message =\n status === 'loading'\n ? t('inputs.search.loading')\n : status === 'error'\n ? t('emptyState.error.description')\n : status === 'idle'\n ? placeholder\n : patients.length === 0\n ? t('inputs.combobox.empty')\n : '';\n const options = patients.map((patient) => ({\n value: patient.id,\n label: patient.name,\n }));\n if (value && !patients.some((patient) => patient.id === value)) {\n options.push({\n value,\n label: picked?.id === value ? picked.name : (selectedLabel ?? ''),\n });\n }\n\n return (\n <div\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\"\n data-component=\"patient-picker\"\n data-status={status}\n >\n <Combobox\n ref={inputRef}\n options={options}\n value={value}\n onValueChange={(next) => {\n setPicked(\n (prev) =>\n patients.find((patient) => patient.id === next) ??\n (prev?.id === next ? prev : undefined),\n );\n onValueChange(next);\n }}\n onQueryChange={setQuery}\n onOpenChange={(open) => {\n // Retry lives outside the popover. Preserve its failed query\n // when focusing that button dismisses the option list.\n if (!open && status !== 'error') setQuery('');\n }}\n /* Keep the held option for its label, but do not present it as a\n * search match unless the server actually returned it. */\n filter={(candidate) =>\n !trimmedQuery ||\n patients.some((p) => normalizeDiacritics(p.id) === candidate)\n ? 1\n : 0\n }\n size={size}\n disabled={disabled}\n placeholder={placeholder}\n emptyMessage={message || undefined}\n clearable\n />\n {/* A retained selection can keep Command.Empty hidden. Status lives\n * outside the listbox so loading and errors are still announced. */}\n <p role=\"status\" className=\"type-body-sm ds:text-muted-foreground\">\n {message}\n </p>\n {status === 'error' ? (\n <Button\n size=\"sm\"\n intent=\"ghost\"\n onClick={() => {\n setRetry((prev) => prev + 1);\n inputRef.current?.focus();\n }}\n >\n {t('emptyState.error.cta')}\n </Button>\n ) : null}\n </div>\n );\n}\n","/* -------------------------------------------------------------------- */\n/* Agent adapter: TaskEditor. */\n/* */\n/* Reads the form's status and draft (identifiers and structure, never */\n/* the note body or a patient name) and drives the same code paths as */\n/* the buttons. Writes return the host's promise, so a refusal reaches */\n/* the agent as a rejection and the form shows the same error. */\n/* */\n/* Safety follows kit precedent: set_fields and save carry a note body */\n/* and a patient link, so `phi` (as notes-panel add_note); set_done is a */\n/* `write` toggle (as tasks-panel toggle_done); delete is `destructive` */\n/* and skips the dialog, because the runtime's own confirmation replaces */\n/* it; cancel can drop typed input, so `destructive` (as dialog dismiss). */\n/* `delete` has no capability of its own, as notes-panel pin and flag */\n/* have none. */\n/* */\n/* Footer actions carry data-action \"cancel-task\", \"save-task\" and */\n/* \"delete-task\"; a failed load's Retry carries \"retry-load\". In the */\n/* subview, the PanelSubview section repeats data-component-id, so */\n/* [data-component-id=\"…\"] reaches the footer in both variants. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { TaskEditorFieldPatch, TaskEditorHandle } from './task-editor';\n\nexport const taskEditorAgent: AgentAdapter<TaskEditorHandle> = {\n id: 'task-editor',\n // set_value backs set_fields and set_done; submit backs save; dismiss\n // backs cancel.\n capabilities: ['set_value', 'submit', 'dismiss'],\n state: {\n status: {\n type: \"'loading' | 'ready' | 'error' | 'locked' | 'withheld'\",\n descriptionKey: 'ui.agent.taskEditor.state.status',\n description:\n \"Where the form is: loading the task, ready, failed to load, locked (edit mode with nothing to load) or withheld behind the privacy notice. Writes need 'ready'.\",\n read: (handle) => handle.getStatus(),\n },\n draft: {\n type: '{ mode: string; dateIso: string | null; about: string; patientId: string | null; companyId: string | null; operatorId: string | null; typeId: string | null; assigneeId: string | null; done: boolean; hasNote: boolean; noteLength: number }',\n descriptionKey: 'ui.agent.taskEditor.state.draft',\n description:\n 'The draft as Save would send it: ids and structure only, never the note body. done is the last value the host confirmed.',\n read: (handle) => handle.getDraft(),\n },\n canSave: {\n type: 'boolean',\n descriptionKey: 'ui.agent.taskEditor.state.canSave',\n description:\n 'Whether save would reach the host now: the form is ready, the note is filled, a chosen counterpart has an id and no write is pending.',\n read: (handle) => handle.canSave(),\n },\n },\n actions: {\n set_fields: {\n safety: 'phi',\n argsType:\n \"{ dateIso?: string; note?: string; typeId?: string; assigneeId?: string | null; about?: 'nobody' | 'patient' | 'company' | 'operator'; patientId?: string; companyId?: string; operatorId?: string }\",\n argsSchema: {\n type: 'object',\n properties: {\n dateIso: { type: 'string', format: 'date-time' },\n note: { type: 'string' },\n typeId: { type: 'string' },\n assigneeId: { type: ['string', 'null'] },\n about: {\n type: 'string',\n enum: ['nobody', 'patient', 'company', 'operator'],\n },\n patientId: { type: 'string' },\n companyId: { type: 'string' },\n operatorId: { type: 'string' },\n },\n },\n idempotent: true,\n errors: [\n 'An id the host lists, its patient search or the stored task do not resolve.',\n 'More than one of patientId, companyId and operatorId.',\n 'The form is not ready, is read-only or is withheld.',\n ],\n descriptionKey: 'ui.agent.taskEditor.actions.setFields',\n description:\n 'Set draft fields. Ids must come from the host lists, a patient the host search returned, or equal the stored one. At most one counterpart per call, and it selects its branch; assigneeId null is nobody. Nothing is saved.',\n invoke: (handle, args: TaskEditorFieldPatch) => {\n handle.setFields(args);\n },\n },\n save: {\n safety: 'phi',\n // Reaches the host's data source; the result is the host's promise.\n openWorld: true,\n descriptionKey: 'ui.agent.taskEditor.actions.save',\n description:\n 'Save the task through the host. Resolves once the write lands and rejects with the host error, which the form also shows.',\n invoke: (handle) => handle.save(),\n },\n set_done: {\n safety: 'write',\n argsType: '{ done: boolean }',\n argsSchema: {\n type: 'object',\n properties: { done: { type: 'boolean' } },\n required: ['done'],\n },\n openWorld: true,\n errors: [\n 'The form is not ready, is read-only or has no Done seam.',\n 'A save, a delete or another Done change is in flight.',\n 'The task was already saved or deleted in this session.',\n ],\n descriptionKey: 'ui.agent.taskEditor.actions.setDone',\n description:\n 'Mark an existing task done or not done through the host. A rejection rolls the switch back.',\n invoke: (handle, args: { done: boolean }) => handle.setDone(args.done),\n },\n delete: {\n safety: 'destructive',\n idempotent: true,\n openWorld: true,\n descriptionKey: 'ui.agent.taskEditor.actions.delete',\n description:\n 'Delete the task through the host, without the confirmation dialog. Resolves once the delete lands.',\n invoke: (handle) => handle.deleteTask(),\n },\n cancel: {\n safety: 'destructive',\n errors: ['A save or delete is in flight: wait for it to settle.'],\n descriptionKey: 'ui.agent.taskEditor.actions.cancel',\n description:\n 'Close the editor without saving. Anything typed since the last save is lost. Refused while a save or delete is in flight.',\n invoke: (handle) => {\n handle.cancel();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'task-editor',\n description:\n 'Marks the TaskEditor body. It also carries data-variant and data-status. In the subview variant it sits inside the panel-subview section, which repeats data-component-id, data-variant and data-status and holds the heading and footer.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop, or generated. Addresses one editor from the agent. [data-component-id] reaches the footer actions in both variants.',\n },\n },\n};\n","/* The TaskEditor's form state machine. Private to the component: it holds the\n draft, loads the record, and runs the three writes. Moved from the\n calendar's task editor with every CalendarData read turned into an option,\n plus sessions (a subview reopen starts a fresh draft), an abortable load\n with Retry, and writes that return the host's promise for the agent. */\nimport { useEffect, useRef, useState } from 'react';\nimport { getErrorMessage } from '../_shared/get-error-message';\nimport { handledRejection } from '../_shared/handled-rejection';\nimport type {\n TaskEditorAbout,\n TaskEditorDraft,\n TaskEditorDraftState,\n TaskEditorFieldPatch,\n TaskEditorOption,\n TaskEditorPatient,\n TaskEditorProps,\n TaskEditorStatus,\n TaskEditorTask,\n TaskEditorTaskType,\n} from './task-editor';\n\n/** The \"unset\" value of the operator and assignee selects. */\nexport const NONE = 'none';\n\nexport interface TaskEditorFields {\n date: Date | undefined;\n time: { hours: number; minutes: number };\n note: string;\n /** `NONE` until an operator is chosen. */\n operatorId: string;\n /** '' until something chooses one. Read through `chosenTypeId`. */\n typeId: string;\n /** The practice user, not the operator. `NONE` is nobody. */\n assigneeId: string;\n about: TaskEditorAbout;\n patientId: string;\n /** A real id from the host list, never a typed name. */\n companyId: string;\n}\n\ninterface UiState {\n showError: boolean;\n saving: boolean;\n saveError: string | undefined;\n /* `done` is the DISPLAYED value, optimistic while a toggle is pending;\n `confirmedDone` is the last value the host accepted, and is what Save\n sends. */\n done: boolean;\n confirmedDone: boolean;\n donePending: boolean;\n doneError: string | undefined;\n deleting: boolean;\n deleteError: string | undefined;\n confirmDeleteOpen: boolean;\n /** A save or delete landed: the form stops writing until a new session. */\n accepted: boolean;\n}\n\nconst INITIAL_UI: UiState = {\n showError: false,\n saving: false,\n saveError: undefined,\n done: false,\n confirmedDone: false,\n donePending: false,\n doneError: undefined,\n deleting: false,\n deleteError: undefined,\n confirmDeleteOpen: false,\n accepted: false,\n};\n\n/* One per session: the synchronous guards a double click or two agent calls\n in one tick would race past in React state. Replaced, never reset, so a\n write from an earlier session can tell it is stale. */\ninterface Session {\n subject: string;\n saving: boolean;\n deleting: boolean;\n donePending: boolean;\n accepted: boolean;\n}\n\nexport function aboutOf(task: {\n patientId?: string;\n companyId?: string;\n operatorId?: string;\n}): TaskEditorAbout {\n /* Order matters only for a legacy record that holds two: the platform\n cannot have written one, and the patient is the least surprising\n reading of it. */\n if (task.patientId) return 'patient';\n if (task.companyId) return 'company';\n if (task.operatorId) return 'operator';\n return 'nobody';\n}\n\nfunction timeOf(date: Date): { hours: number; minutes: number } {\n return { hours: date.getHours(), minutes: date.getMinutes() };\n}\n\nfunction blankFields(initialDate: Date | undefined): TaskEditorFields {\n const date = initialDate ?? new Date();\n return {\n date,\n time: timeOf(date),\n note: '',\n operatorId: NONE,\n typeId: '',\n assigneeId: NONE,\n about: 'nobody',\n patientId: '',\n companyId: '',\n };\n}\n\nfunction fieldsOf(task: TaskEditorTask): TaskEditorFields {\n /* An instant: parsed, never sliced. A zone-less value reads as local. */\n const date = new Date(task.dateIso);\n return {\n date,\n time: timeOf(date),\n note: task.note,\n /* `||`, not `??`: a host's '' is unset, like patient and company. */\n operatorId: task.operatorId || NONE,\n /* A stored type wins. With none, '' falls through to the first entry. */\n typeId: task.typeId ?? '',\n /* `||` too: '' would become a Select option with an empty value. */\n assigneeId: task.assigneeId || NONE,\n about: aboutOf(task),\n patientId: task.patientId ?? '',\n companyId: task.companyId ?? '',\n };\n}\n\nconst COUNTERPARTS = [\n ['patientId', 'patient'],\n ['companyId', 'company'],\n ['operatorId', 'operator'],\n] as const;\n\nexport interface UseTaskEditorFormOptions {\n mode: 'create' | 'edit';\n taskId: string | undefined;\n initialDate: Date | undefined;\n /** Panel: always. Subview: while `open`. A false-to-true change starts a\n * fresh session. */\n active: boolean;\n taskTypes: ReadonlyArray<TaskEditorTaskType>;\n assignees: ReadonlyArray<TaskEditorOption>;\n companies: ReadonlyArray<TaskEditorOption>;\n operators: ReadonlyArray<TaskEditorOption>;\n patients: ReadonlyArray<TaskEditorPatient>;\n /** Names the host's search has returned, by id: a patient picked from\n * search stays nameable, and settable by the agent. */\n searchedPatients: ReadonlyMap<string, string>;\n resolvePatientLabel: TaskEditorProps['resolvePatientLabel'];\n loadTask: TaskEditorProps['loadTask'];\n onCreateTask: TaskEditorProps['onCreateTask'];\n onUpdateTask: TaskEditorProps['onUpdateTask'];\n onDeleteTask: TaskEditorProps['onDeleteTask'];\n onSetTaskDone: TaskEditorProps['onSetTaskDone'];\n onSaved: TaskEditorProps['onSaved'];\n onDeleted: TaskEditorProps['onDeleted'];\n readOnly: boolean;\n /** The privacy notice covers an existing task: nothing loads. */\n withheld: boolean;\n /** The patient shows as the mask, so none may be picked. */\n maskPatient: boolean;\n /** Shown when a rejection carries no message of its own. */\n fallbackError: string;\n}\n\nexport function useTaskEditorForm({\n mode,\n taskId,\n initialDate,\n active,\n taskTypes,\n assignees,\n companies,\n operators,\n patients,\n searchedPatients,\n resolvePatientLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onSaved,\n onDeleted,\n readOnly,\n withheld,\n maskPatient,\n fallbackError,\n}: UseTaskEditorFormOptions) {\n const isEdit = mode === 'edit';\n\n /* Each false-to-true change of `active` is a new session. Derived during\n render, so the entering subview already shows the fresh draft. */\n const [session, setSession] = useState(0);\n const [wasActive, setWasActive] = useState(active);\n if (wasActive !== active) {\n setWasActive(active);\n if (active) setSession((previous) => previous + 1);\n }\n const subject = `${mode}|${taskId ?? ''}|${session}`;\n\n const [fields, setFields] = useState<TaskEditorFields>(() =>\n blankFields(initialDate),\n );\n const [ui, setUi] = useState<UiState>(INITIAL_UI);\n /** The record as loaded: what \"the stored link\" means. */\n const [stored, setStored] = useState<TaskEditorTask>();\n const patchUi = (next: Partial<UiState>) =>\n setUi((previous) => ({ ...previous, ...next }));\n const patchFields = (next: Partial<TaskEditorFields>) =>\n setFields((previous) => ({ ...previous, ...next }));\n\n /* A new subject (mode, task or session) starts from a blank draft, which\n reads `initialDate` again. Edit mode then hydrates from the load. */\n const [currentSubject, setCurrentSubject] = useState(subject);\n if (currentSubject !== subject) {\n setCurrentSubject(subject);\n setFields(blankFields(initialDate));\n setUi(INITIAL_UI);\n setStored(undefined);\n }\n const sessionRef = useRef<Session>({\n subject,\n saving: false,\n deleting: false,\n donePending: false,\n accepted: false,\n });\n if (sessionRef.current.subject !== subject) {\n sessionRef.current = {\n subject,\n saving: false,\n deleting: false,\n donePending: false,\n accepted: false,\n };\n }\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n const live = (owner: Session) =>\n mountedRef.current && sessionRef.current === owner;\n\n /* ---- Load ---------------------------------------------------------- */\n /* Read through a ref, never as a dependency: one load per subject, and a\n fresh `loadTask` arrow per render must not re-run it over the user's\n edits. Losing the seam still locks. */\n const loadTaskRef = useRef(loadTask);\n loadTaskRef.current = loadTask;\n const hasLoadTask = Boolean(loadTask);\n const [attempt, setAttempt] = useState(0);\n const [loaded, setLoaded] = useState<{\n subject: string;\n status: 'ready' | 'error';\n message?: string;\n } | null>(null);\n const loadedRef = useRef(loaded);\n loadedRef.current = loaded;\n const canLoad =\n active && isEdit && Boolean(taskId) && hasLoadTask && !withheld;\n\n useEffect(() => {\n const load = loadTaskRef.current;\n if (!canLoad || !taskId || !load) return undefined;\n const owner = sessionRef.current;\n const done = loadedRef.current;\n /* Hydrated already: a privacy toggle or a late list never reloads over\n the draft. */\n if (done?.subject === owner.subject && done.status === 'ready') {\n return undefined;\n }\n const controller = new AbortController();\n Promise.resolve()\n .then(() =>\n /* Cleaned up before this ran (StrictMode's replay, a quick re-run):\n never call the host with a signal already aborted. */\n controller.signal.aborted\n ? Promise.reject(controller.signal.reason)\n : load(taskId, { signal: controller.signal }),\n )\n .then(\n (task) => {\n if (controller.signal.aborted || !live(owner)) return;\n setFields(fieldsOf(task));\n patchUi({ done: task.done, confirmedDone: task.done });\n setStored(task);\n setLoaded({ subject: owner.subject, status: 'ready' });\n },\n (error: unknown) => {\n if (controller.signal.aborted || !live(owner)) return;\n setLoaded({\n subject: owner.subject,\n status: 'error',\n message: getErrorMessage(error, fallbackError),\n });\n },\n );\n /* A superseded answer is ignored: a new task, a closed subview or a\n privacy notice aborts it. */\n return () => controller.abort();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- one load per subject and attempt; see the refs above\n }, [canLoad, subject, attempt]);\n\n /* `locked`: edit mode with no task id, or no seam to resolve it. There\n is no confirmed record to show, so the form must never render blank\n and savable, which would overwrite the real task on Save. */\n const status: TaskEditorStatus = !isEdit\n ? 'ready'\n : !taskId || !hasLoadTask\n ? 'locked'\n : withheld\n ? 'withheld'\n : loaded?.subject === subject\n ? loaded.status\n : 'loading';\n\n const retry = () => {\n if (status !== 'error') return;\n setLoaded(null);\n setAttempt((previous) => previous + 1);\n };\n\n /* ---- Derived ------------------------------------------------------- */\n /* Derived, not stored: a host whose `taskTypes` arrive late still gets\n the required field defaulted to the first entry, and a host with no\n list keeps whatever was loaded. */\n const chosenTypeId = fields.typeId || (taskTypes[0]?.id ?? '');\n /* A chosen branch needs a real id, or Save would send no counterpart\n and silently unlink the task. Nobody is the only empty choice. */\n const counterpartChosen =\n fields.about === 'nobody' ||\n (fields.about === 'patient' && fields.patientId !== '') ||\n (fields.about === 'company' && fields.companyId !== '') ||\n (fields.about === 'operator' && fields.operatorId !== NONE);\n /* `!donePending`: a Done toggle in flight is not confirmed yet, and the\n draft sends the confirmed value. Saving now would discard the toggle\n once it lands. */\n const canSave =\n !readOnly &&\n fields.note.trim() !== '' &&\n fields.date !== undefined &&\n counterpartChosen &&\n /* Required whenever the host offers a list. */\n (taskTypes.length === 0 || chosenTypeId !== '') &&\n !ui.saving &&\n !ui.donePending;\n const saveSeam = isEdit ? onUpdateTask : onCreateTask;\n\n const buildDraft = (): TaskEditorDraft | undefined => {\n const { date, time } = fields;\n if (!date) return undefined;\n const dateIso = new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n time.hours,\n time.minutes,\n 0,\n 0,\n ).toISOString();\n return {\n dateIso,\n note: fields.note.trim(),\n /* Sent whatever the host's list says, including a value the list no\n longer resolves: a real link must survive a Save that never\n offered to change it. */\n typeId: chosenTypeId === '' ? undefined : chosenTypeId,\n assigneeId: fields.assigneeId === NONE ? undefined : fields.assigneeId,\n /* ONE counterpart, decided by `about` alone: the platform refuses a\n task carrying two. Never gated on a list being loaded, or a list\n that empties mid-edit would unlink the task on Save. */\n patientId:\n fields.about === 'patient' && fields.patientId\n ? fields.patientId\n : undefined,\n companyId:\n fields.about === 'company' && fields.companyId\n ? fields.companyId\n : undefined,\n operatorId:\n fields.about === 'operator' && fields.operatorId !== NONE\n ? fields.operatorId\n : undefined,\n /* The last CONFIRMED value only, never an optimistic or rolled-back\n toggle. */\n done: ui.confirmedDone,\n };\n };\n\n const refuse = (reason: string) =>\n handledRejection(new Error(`TaskEditor: ${reason}`));\n\n /* ---- Writes -------------------------------------------------------- */\n /* Each returns the host's promise, marked handled so a click that\n ignores it raises no warning. It resolves only once the write lands. */\n const submit = (): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready') return refuse(`cannot save while ${status}.`);\n if (!saveSeam) return refuse('the host gave no save seam.');\n if (owner.accepted) return refuse('this task was already saved.');\n if (owner.deleting) return refuse('a delete is in flight.');\n if (owner.saving || !canSave) return refuse('the task cannot be saved.');\n const draft = buildDraft();\n if (!draft) {\n patchUi({ showError: true });\n return refuse('the task has no date.');\n }\n const id = taskId;\n owner.saving = true;\n patchUi({ saving: true, saveError: undefined });\n const write = (async () => {\n try {\n if (isEdit) {\n await onUpdateTask?.(id as string, draft);\n /* Only once the promise resolves: a rejection leaves the form\n open and resubmittable. */\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true });\n onSaved?.({\n ...draft,\n id: id as string,\n done: draft.done ?? false,\n });\n }\n } else {\n const created = await onCreateTask?.(draft);\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true });\n if (created) onSaved?.(created);\n }\n }\n } catch (error) {\n if (live(owner)) {\n patchUi({ saveError: getErrorMessage(error, fallbackError) });\n }\n throw error;\n } finally {\n owner.saving = false;\n if (live(owner)) patchUi({ saving: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n const setDone = (next: boolean): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready')\n return refuse(`cannot change Done while ${status}.`);\n if (!isEdit || !taskId || !onSetTaskDone || readOnly) {\n return refuse('the host gave no Done seam.');\n }\n if (owner.donePending) return refuse('a Done change is already pending.');\n /* A Save in flight re-sends the whole record with the done value it\n captured, so a toggle now would be undone when it lands. */\n if (owner.saving || owner.deleting) {\n return refuse('a save or delete is in flight.');\n }\n if (owner.accepted)\n return refuse('this task was already saved or deleted.');\n if (next === ui.done) return Promise.resolve();\n const previous = ui.confirmedDone;\n const id = taskId;\n owner.donePending = true;\n patchUi({ done: next, donePending: true, doneError: undefined });\n const write = (async () => {\n try {\n await onSetTaskDone(id, next);\n if (live(owner)) patchUi({ confirmedDone: next });\n } catch (error) {\n if (live(owner)) {\n /* Back to the last CONFIRMED value, not just `!next`: a second\n failure in a row must not compound on an unconfirmed one. */\n patchUi({\n done: previous,\n doneError: getErrorMessage(error, fallbackError),\n });\n }\n throw error;\n } finally {\n owner.donePending = false;\n if (live(owner)) patchUi({ donePending: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n const remove = (): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready') return refuse(`cannot delete while ${status}.`);\n if (!isEdit || !taskId || !onDeleteTask || readOnly) {\n return refuse('the host gave no delete seam.');\n }\n if (owner.saving || owner.accepted || owner.deleting) {\n return refuse('the task cannot be deleted now.');\n }\n const id = taskId;\n owner.deleting = true;\n patchUi({ deleting: true, deleteError: undefined });\n const write = (async () => {\n try {\n await onDeleteTask(id);\n /* Only once the write is confirmed: a rejected delete keeps the\n dialog open with its error, and the form unlocked. */\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true, confirmDeleteOpen: false });\n onDeleted?.(id);\n }\n } catch (error) {\n if (live(owner)) {\n patchUi({ deleteError: getErrorMessage(error, fallbackError) });\n }\n throw error;\n } finally {\n owner.deleting = false;\n if (live(owner)) patchUi({ deleting: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n /* ---- Agent --------------------------------------------------------- */\n const knows = (\n list: ReadonlyArray<{ id: string }>,\n id: string,\n storedId: string | undefined,\n ) =>\n /* '' is never an id, even when the stored record holds one. */\n id !== '' && (id === storedId || list.some((entry) => entry.id === id));\n\n /** The agent's `set_fields`: validated, then applied as one patch. */\n const applyPatch = (patch: TaskEditorFieldPatch): void => {\n if (status !== 'ready') {\n throw new Error(`TaskEditor: cannot set fields while ${status}.`);\n }\n if (readOnly) throw new Error('TaskEditor: the task is read-only.');\n const chosen = COUNTERPARTS.filter(([key]) => patch[key] !== undefined);\n if (chosen.length > 1) {\n throw new Error(\n 'TaskEditor: set at most one of patientId, companyId and operatorId.',\n );\n }\n const branch = chosen[0]?.[1];\n if (patch.about !== undefined && branch && patch.about !== branch) {\n throw new Error(\n `TaskEditor: about \"${patch.about}\" does not match the ${branch} id.`,\n );\n }\n if (\n patch.typeId !== undefined &&\n !knows(taskTypes, patch.typeId, stored?.typeId)\n ) {\n throw new Error(`TaskEditor: unknown typeId \"${patch.typeId}\".`);\n }\n if (\n patch.assigneeId !== undefined &&\n patch.assigneeId !== null &&\n !knows(assignees, patch.assigneeId, stored?.assigneeId)\n ) {\n throw new Error(`TaskEditor: unknown assigneeId \"${patch.assigneeId}\".`);\n }\n if (\n patch.companyId !== undefined &&\n !knows(companies, patch.companyId, stored?.companyId)\n ) {\n throw new Error(`TaskEditor: unknown companyId \"${patch.companyId}\".`);\n }\n if (\n patch.operatorId !== undefined &&\n !knows(operators, patch.operatorId, stored?.operatorId)\n ) {\n throw new Error(`TaskEditor: unknown operatorId \"${patch.operatorId}\".`);\n }\n if (patch.patientId !== undefined) {\n if (maskPatient) {\n throw new Error('TaskEditor: no patient can be set in privacy mode.');\n }\n const resolvable =\n knows(patients, patch.patientId, stored?.patientId) ||\n searchedPatients.has(patch.patientId) ||\n resolvePatientLabel?.(patch.patientId) !== undefined;\n if (!resolvable) {\n throw new Error(`TaskEditor: unknown patientId \"${patch.patientId}\".`);\n }\n }\n const next: Partial<TaskEditorFields> = {};\n if (patch.dateIso !== undefined) {\n const date = new Date(patch.dateIso);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`TaskEditor: \"${patch.dateIso}\" is not a date.`);\n }\n next.date = date;\n next.time = timeOf(date);\n }\n if (patch.note !== undefined) next.note = patch.note;\n if (patch.typeId !== undefined) next.typeId = patch.typeId;\n if (patch.assigneeId !== undefined) {\n next.assigneeId = patch.assigneeId ?? NONE;\n }\n if (patch.about !== undefined) next.about = patch.about;\n if (patch.patientId !== undefined) {\n next.patientId = patch.patientId;\n next.about = 'patient';\n }\n if (patch.companyId !== undefined) {\n next.companyId = patch.companyId;\n next.about = 'company';\n }\n if (patch.operatorId !== undefined) {\n next.operatorId = patch.operatorId;\n next.about = 'operator';\n }\n patchFields(next);\n };\n\n /** Identifiers and structure only, never the note body. */\n const draftState = (): TaskEditorDraftState => {\n const draft = buildDraft();\n return {\n mode,\n dateIso: draft?.dateIso ?? null,\n about: fields.about,\n patientId: draft?.patientId ?? null,\n companyId: draft?.companyId ?? null,\n operatorId: draft?.operatorId ?? null,\n typeId: draft?.typeId ?? null,\n assigneeId: draft?.assigneeId ?? null,\n done: ui.confirmedDone,\n hasNote: fields.note.trim() !== '',\n noteLength: fields.note.trim().length,\n };\n };\n\n return {\n status,\n loadError: loaded?.subject === subject ? loaded.message : undefined,\n retry,\n fields,\n patchFields,\n stored,\n chosenTypeId,\n canSave,\n /** What the agent's `canSave` reports: the button's rule plus the\n * status, the seam and a save that has not landed yet. */\n agentCanSave:\n status === 'ready' && Boolean(saveSeam) && canSave && !ui.accepted,\n showSave: !readOnly && Boolean(saveSeam),\n showDelete: isEdit && !readOnly && Boolean(onDeleteTask) && Boolean(taskId),\n showDone: isEdit && !readOnly && Boolean(onSetTaskDone),\n ui,\n patchUi,\n /** True once a save or delete landed in this session. */\n isAccepted: () => sessionRef.current.accepted,\n /** A save or delete is in flight: closing now would lose its outcome. */\n isBusy: () => sessionRef.current.saving || sessionRef.current.deleting,\n submit,\n setDone,\n remove,\n applyPatch,\n draftState,\n };\n}\n\nexport type TaskEditorForm = ReturnType<typeof useTaskEditorForm>;\n","/**\n * TaskEditor: the published form for one task (platform `DoctorReminder`).\n * It creates, edits, completes and deletes a task through host seams, and\n * takes every list, label and seam as a prop, so a host builds it without\n * any calendar context. The calendar's own task route renders it through a\n * thin adapter.\n *\n * A note is the only field every host needs, beside ONE optional\n * counterpart: a patient, a company or an operator, never two, because the\n * platform refuses a task with \"More than one counterpart is set\". A host\n * that supplies `taskTypes` also gets a required Type select, and one that\n * supplies `assignees` an optional \"Assigned to\" (a practice user, not the\n * operator). A missing list or seam WITHHOLDS the control it backs; it never\n * renders that control disabled.\n *\n * Two layouts: `variant=\"panel\"` fills a rail tool panel with its own header,\n * scroll body and pinned footer; `variant=\"subview\"` IS a PanelSubview, for a\n * form stacked over a list such as TasksPanel.\n *\n * DOM hooks: `data-component=\"task-editor\"` with `data-variant`,\n * `data-status` and `data-component-id`; the footer actions carry\n * `data-action` \"cancel-task\", \"save-task\" and \"delete-task\", and a failed\n * load's Retry carries \"retry-load\". In the subview the marker sits on the\n * body, so the PanelSubview section repeats `data-component-id`,\n * `data-variant` and `data-status`: `[data-component-id=\"…\"]` reaches the\n * heading and the footer in both variants.\n */\nimport {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n Building2,\n CircleOff,\n LoaderCircle,\n Lock,\n Save as SaveIcon,\n SquareCheckBig,\n Stethoscope,\n Trash2,\n User,\n X,\n} from 'lucide-react';\nimport { Alert } from '../alert';\nimport { Button, IconButton } from '../button';\nimport { Combobox } from '../combobox';\nimport { Dialog } from '../dialog';\nimport { DatePicker } from '../date-picker';\nimport { FormField } from '../form-field';\nimport { IconButtonGroup } from '../icon-button-group';\nimport { PanelHeader } from '../panel-header';\nimport { PanelSubview } from '../panel-subview';\nimport { Radio, RadioGroup } from '../radio-group';\nimport { ScrollArea } from '../scroll-area';\nimport { Select } from '../select';\nimport { Skeleton } from '../skeleton';\nimport { Switch } from '../switch';\nimport { TextArea } from '../text-area';\nimport { TextInput } from '../text-input';\nimport { TimePicker } from '../time-picker';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\nimport { composeRefs } from '../_shared/compose-refs';\nimport {\n EDITOR_COMPACT_FIELDS_CLASS,\n EDITOR_COMPACT_SEGMENTED_CLASS,\n} from '../_shared/compact-editor-fields';\nimport type { PatientIdentity } from '../_shared/patient-identity';\nimport { PatientPicker, type PatientSearch } from '../_shared/patient-picker';\nimport { PrivacyNotice, privacyMask } from '../_shared/privacy-mask';\nimport { taskEditorAgent } from './task-editor.agent';\nimport { NONE, useTaskEditorForm } from './use-task-editor-form';\n\n/* -------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------- */\n\n/**\n * A task as the editor loads and saves it: platform `DoctorReminder`. At\n * most ONE counterpart (patient, company or operator); the platform refuses\n * a task naming two. `note` is required here though the platform allows an\n * empty one. There is no title, priority or duration: the platform has none.\n */\nexport interface TaskEditorTask {\n id: string;\n /** An instant as ISO 8601 (platform `date`). The editor emits\n * `toISOString()`, so UTC with a `Z`. Parse it with `new Date()`, never by\n * slicing; a zone-less value reads as local time. */\n dateIso: string;\n /** The task text (platform `note`). Required here, though the platform\n * allows an empty one. Never exposed through the agent. */\n note: string;\n /** The clinician the task concerns: platform `doctorOperator`, an id from\n * `operators`. NOT the assignee. Exclusive with `patientId` and\n * `companyId`. */\n operatorId?: string;\n /** The patient the task concerns: platform `doctorPatient` (column\n * `patientId`). Exclusive with `companyId` and `operatorId`. */\n patientId?: string;\n /** Platform `doctorCompany`, an id from `companies`. Exclusive with\n * `patientId` and `operatorId`. */\n companyId?: string;\n /** An opaque token from `taskTypes`, round-tripped untouched. Without\n * `taskTypes` the Type field is withheld and a new task sends none; a\n * stored one is still re-sent. */\n typeId?: string;\n /** The practice USER the task is assigned to: platform `practiceUser`, an\n * id from `assignees`. Independent of the counterpart. Absent or '':\n * nobody. */\n assigneeId?: string;\n /** Platform `done`. */\n done: boolean;\n}\n\n/** What `onCreateTask` receives and what an edit save re-sends IN FULL,\n * never a patch. `done` carries the last value the host CONFIRMED, never an\n * optimistic or rolled-back toggle. */\nexport type TaskEditorDraft = Omit<TaskEditorTask, 'id' | 'done'> & {\n done?: boolean;\n};\n\n/** One row of a host list. `label` is the host's own string, already\n * translated. `id` is opaque, unique in its list, never '' and never\n * 'none' (reserved for \"Nobody\"). */\nexport interface TaskEditorOption {\n id: string;\n label: string;\n}\n\n/** A task type. `custom` (practice-defined) only groups the Type select,\n * and only when the list mixes custom and standard types. */\nexport interface TaskEditorTaskType extends TaskEditorOption {\n custom?: boolean;\n}\n\n/** A patient as the picker needs one: an id and a display name.\n * `CalendarPatient` satisfies it. */\nexport type TaskEditorPatient = PatientIdentity;\n\n/** Host patient typeahead. Called 250 ms after typing stops, for non-blank\n * trimmed queries only. Abort a superseded call through `signal`. The\n * host's order is kept, so matches by phone or number stay. Reject on\n * failure (the picker offers Retry); `[]` is a successful search with no\n * match. The same contract as `CalendarData.searchPatients`. */\nexport type TaskEditorSearchPatients = (\n query: string,\n options: { signal: AbortSignal },\n) => Promise<readonly TaskEditorPatient[]>;\n\n/** Where the form is. 'error': the load failed, with Retry. 'locked': edit\n * mode without `taskId` or `loadTask`, never a blank savable form.\n * 'withheld': the privacy notice covers an existing task. */\nexport type TaskEditorStatus =\n | 'loading'\n | 'ready'\n | 'error'\n | 'locked'\n | 'withheld';\n\n/** The one counterpart choice (\"Concerns\"). */\nexport type TaskEditorAbout = 'nobody' | 'patient' | 'company' | 'operator';\n\n/** The draft as the agent reads it: identifiers and structure, never the\n * note body. Counterpart ids are what Save would send. */\nexport interface TaskEditorDraftState {\n mode: 'create' | 'edit';\n dateIso: string | null;\n about: TaskEditorAbout;\n patientId: string | null;\n companyId: string | null;\n operatorId: string | null;\n typeId: string | null;\n assigneeId: string | null;\n /** The last CONFIRMED done value. */\n done: boolean;\n hasNote: boolean;\n noteLength: number;\n}\n\n/** Fields an agent may set. Ids must resolve in the host lists, among the\n * patients the host's search returned, or equal the stored one. At most\n * one of `patientId`, `companyId` and `operatorId` per call; each also\n * selects its `about` branch. `assigneeId: null` is Nobody. */\nexport interface TaskEditorFieldPatch {\n dateIso?: string;\n note?: string;\n typeId?: string;\n assigneeId?: string | null;\n about?: TaskEditorAbout;\n patientId?: string;\n companyId?: string;\n operatorId?: string;\n}\n\n/** Curated agent handle. Writes return the host's promise, so a refusal\n * reaches the agent as a rejection. Every write fails unless the status is\n * 'ready' and the form is not read-only. */\nexport interface TaskEditorHandle {\n getStatus: () => TaskEditorStatus;\n getDraft: () => TaskEditorDraftState;\n canSave: () => boolean;\n /** Throws on an unknown id, two counterparts or a form not ready. */\n setFields: (patch: TaskEditorFieldPatch) => void;\n save: () => Promise<void>;\n setDone: (done: boolean) => Promise<void>;\n /** Skips the confirmation dialog: the agent runtime confirms instead. */\n deleteTask: () => Promise<void>;\n /** Throws while a save or delete is in flight, as Cancel waits. */\n cancel: () => void;\n}\n\nexport interface TaskEditorProps extends Omit<\n HTMLAttributes<HTMLElement>,\n 'children' | 'id' | 'title'\n> {\n /** Stable instance id, surfaced as `data-component-id` for the agent\n * registry. Generated when absent. */\n id?: string;\n mode: 'create' | 'edit';\n /** Edit mode: the task `loadTask` resolves. Without it, or without\n * `loadTask`, edit mode is 'locked'. */\n taskId?: string;\n /** Create mode: the local date and time to prefill. Read at mount, when\n * the mode or task changes and at each subview reopen. Default: now. */\n initialDate?: Date;\n /** 'panel' (default): fills its box with its own header, scroll body and\n * pinned footer, for a rail tool panel. 'subview': the editor IS a\n * PanelSubview; render it as the LAST, DIRECT child of a\n * `PanelSubview.Host`. */\n variant?: 'panel' | 'subview';\n /** Subview only. Default true. Each change from false to true starts a\n * fresh session: the draft resets and edit mode reloads. Keep one editor\n * mounted and toggle this, so it slides in and returns focus. */\n open?: boolean;\n /** Subview only: fires once the exit has played. */\n onExited?: () => void;\n\n /* Host lists. Absent or [] WITHHOLDS the field it backs. */\n /** The required Type select, defaulting to the first entry. */\n taskTypes?: ReadonlyArray<TaskEditorTaskType>;\n /** The optional \"Assigned to\" select: practice users, not operators. */\n assignees?: ReadonlyArray<TaskEditorOption>;\n /** The Company counterpart: a searchable Combobox matching the label,\n * never the id. */\n companies?: ReadonlyArray<TaskEditorOption>;\n /** The Operator counterpart: clinicians. */\n operators?: ReadonlyArray<TaskEditorOption>;\n /** Filtered on the client when `searchPatients` is absent. With neither,\n * the Patient counterpart is withheld; a stored link still shows\n * read-only and is re-sent on Save. */\n patients?: ReadonlyArray<TaskEditorPatient>;\n /** Host typeahead. Wins over `patients` for listing. May change identity\n * between renders; the next query uses the latest. */\n searchPatients?: TaskEditorSearchPatients;\n /** Display name of the task's STORED patient when nothing else resolves\n * it, for example from the TasksPanel row that opened the form. */\n patientLabel?: string;\n /** Resolves any patient id to a name. Tried before `patients` and\n * `patientLabel`. */\n resolvePatientLabel?: (patientId: string) => string | undefined;\n /** Display name of a STORED company that `companies` does not list.\n * Without it the read-only row names the id. */\n companyLabel?: string;\n /** Display name of a STORED operator that `operators` does not list.\n * Without it the row names the id. Each of the three labels names only\n * its own stored link, so a host may pass a TasksPanel row's\n * `linkedLabel` to the one its `linkType` names. */\n operatorLabel?: string;\n /** Subview only: the back arrow's name and tooltip. Already translated.\n * Default \"Back to tasks\". */\n backLabel?: string;\n\n /* Seams. An absent seam WITHHOLDS its control (Save, Delete, Done). Each\n resolves only once the write has landed; reject with a translated\n message and the form shows it. */\n /** Resolves the record for edit mode, once per task and session. Aborted\n * through `signal` when the task changes, the subview closes or the\n * privacy notice covers the form; a superseded answer is ignored. */\n loadTask?: (\n id: string,\n options: { signal: AbortSignal },\n ) => Promise<TaskEditorTask>;\n /** Must resolve WITH the saved record: the host assigns the id. */\n onCreateTask?: (draft: TaskEditorDraft) => Promise<TaskEditorTask>;\n /** A full re-send. Resolves with nothing. */\n onUpdateTask?: (id: string, draft: TaskEditorDraft) => Promise<void>;\n /** Called only after the confirmation dialog. */\n onDeleteTask?: (id: string) => Promise<void>;\n /** The Done switch (edit mode), called on the click. A rejection rolls\n * the switch back. */\n onSetTaskDone?: (id: string, done: boolean) => Promise<void>;\n\n /* Outcomes. */\n /** Cancel, plus Back and Escape in the subview. Close the editor. None of\n * them fires while a save or delete is in flight. */\n onCancel: () => void;\n /** After a create or update LANDS. The form then stops writing until it\n * is closed, remounted or reopened. The form cannot be cancelled while a\n * write is in flight, so this fires for every save the user started,\n * unless the host closes or unmounts the editor itself first. */\n onSaved?: (task: TaskEditorTask) => void;\n /** After a delete LANDS. */\n onDeleted?: (id: string) => void;\n\n /* Modes. */\n /** Withholds every write control and disables the fieldset. */\n readOnly?: boolean;\n /** Privacy mode: the linked patient shows as the mask, never the name. */\n privacy?: boolean;\n /** How an EXISTING task opens under `privacy`. 'notice' (default): the\n * privacy notice covers the form, the record is not loaded, and the\n * footer holds Cancel only. 'mask': the form opens with the patient\n * masked and the note visible. Create mode always opens masked. */\n privacyMode?: 'notice' | 'mask';\n /** The notice's \"Turn off privacy mode\" action. Absent: no button. */\n onPrivacyOff?: () => void;\n}\n\n/* -------------------------------------------------------------------- */\n/* Variants */\n/* -------------------------------------------------------------------- */\n\nconst taskEditorVariants = cva('ds:flex ds:min-h-0 ds:flex-col', {\n variants: {\n /** The panel fills its box; the subview body sits in its scroll area. */\n variant: {\n /* Focusable from script only, as the subview section is: where focus\n waits when a control takes itself away. */\n panel: 'ds:h-full ds:focus-visible:outline-none',\n /* The states pad themselves, so the subview's ring inset is cancelled. */\n subview: 'ds:-m-[var(--panel-subview-inset)]',\n },\n },\n defaultVariants: { variant: 'panel' },\n});\n\n/* `min-w-0`: a fieldset keeps the browser's min-content width, so the\n Concerns segments would hold it wider than the rail and never collapse. */\nconst fieldsetVariants = cva(\n `ds:m-0 ds:min-w-0 ds:border-0 ds:p-[var(--spacing-md)] ${EDITOR_COMPACT_FIELDS_CLASS}`,\n {\n variants: {\n /** 'form': the fields in a column. 'notice': the locked notice. */\n layout: {\n form: 'ds:flex ds:flex-col ds:gap-[var(--spacing-md)]',\n notice: 'ds:flex-1',\n },\n },\n defaultVariants: { layout: 'form' },\n },\n);\n\nconst key = (suffix: string): string =>\n `calendarWorkspace.taskEditor.${suffix}`;\n\n/** Matches the company name only, never its id, and keeps the host's\n * order. Both sides arrive diacritics-stripped and lower-cased. */\nconst companyFilter = (_value: string, search: string, label: string) =>\n label.includes(search) ? 1 : 0;\n\nconst EMPTY: ReadonlyArray<never> = [];\n\n/** The list's task rows under the Host, never inside the subview itself. */\nconst rowsIn = (host: HTMLElement, subview: HTMLElement): HTMLElement[] =>\n Array.from(host.querySelectorAll<HTMLElement>('[data-task-id]')).filter(\n (row) => !subview.contains(row),\n );\n\nconst FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Where focus may go in a row, best first: the control that opened the\n * editor, the row's open-task activator, then any focusable control. */\nconst controlsIn = (\n row: HTMLElement | undefined,\n action: string | undefined,\n): HTMLElement[] => {\n if (!row) return [];\n const actions = Array.from(\n row.querySelectorAll<HTMLElement>('[data-action]'),\n );\n return [\n ...actions.filter((el) => action && el.dataset.action === action),\n ...actions.filter((el) => el.dataset.action === 'open-task'),\n ...Array.from(row.querySelectorAll<HTMLElement>(FOCUSABLE)),\n ];\n};\n\n/* -------------------------------------------------------------------- */\n/* TaskEditor */\n/* -------------------------------------------------------------------- */\n\nexport const TaskEditor = forwardRef<HTMLElement, TaskEditorProps>(\n (\n {\n id,\n mode,\n taskId,\n initialDate,\n variant = 'panel',\n open = true,\n onExited,\n taskTypes = EMPTY,\n assignees = EMPTY,\n companies = EMPTY,\n operators = EMPTY,\n patients = EMPTY,\n searchPatients,\n patientLabel,\n resolvePatientLabel,\n companyLabel,\n operatorLabel,\n backLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onCancel,\n onSaved,\n onDeleted,\n readOnly = false,\n privacy = false,\n privacyMode = 'notice',\n onPrivacyOff,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation('ui');\n const reactId = useId();\n const instanceId = id ?? reactId;\n const isEdit = mode === 'edit';\n const isSubview = variant === 'subview';\n const active = !isSubview || open;\n /* The notice covers an EXISTING task only; a new one has no stored\n patient to reveal, so create mode opens masked. */\n const withheld = privacy && isEdit && privacyMode === 'notice';\n const maskPatient = privacy && !withheld;\n\n /* Every patient the host's search returned, by id. The picker forgets\n its pick when it unmounts (a switch to Company and back), and a\n search-only host has no list to name it from. */\n const [searched] = useState(() => new Map<string, string>());\n\n const form = useTaskEditorForm({\n mode,\n taskId,\n initialDate,\n active,\n taskTypes,\n assignees,\n companies,\n operators,\n patients,\n searchedPatients: searched,\n resolvePatientLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onSaved,\n onDeleted,\n readOnly,\n withheld,\n maskPatient,\n fallbackError: t('emptyState.error.title'),\n });\n const { status, fields, ui, stored } = form;\n\n /* A stable search seam: a host's inline arrow must not restart the\n picker's debounce on every render. */\n const searchRef = useRef(searchPatients);\n searchRef.current = searchPatients;\n const hasSearch = Boolean(searchPatients);\n const search = useMemo<PatientSearch | undefined>(\n () =>\n hasSearch\n ? async (query, options) => {\n const found = await (\n searchRef.current as TaskEditorSearchPatients\n )(query, options);\n for (const patient of found) {\n searched.set(patient.id, patient.name);\n }\n return found;\n }\n : undefined,\n [hasSearch, searched],\n );\n\n /* ---- Agent handle ------------------------------------------------ */\n const formRef = useRef(form);\n formRef.current = form;\n const onCancelRef = useRef(onCancel);\n onCancelRef.current = onCancel;\n const handle = useMemo<TaskEditorHandle>(\n () => ({\n getStatus: () => formRef.current.status,\n getDraft: () => formRef.current.draftState(),\n canSave: () => formRef.current.agentCanSave,\n setFields: (patch) => formRef.current.applyPatch(patch),\n save: () => formRef.current.submit(),\n setDone: (next) => formRef.current.setDone(next),\n deleteTask: () => formRef.current.remove(),\n cancel: () => {\n if (formRef.current.isBusy()) {\n throw new Error('TaskEditor: a save or delete is in flight.');\n }\n onCancelRef.current();\n },\n }),\n [],\n );\n /* A closed subview is not an instance an agent can drive. */\n useAgentRegistration(taskEditorAgent, active ? handle : null, instanceId);\n const localRoot = useRef<HTMLElement | null>(null);\n const rootRef = useMemo(\n () => composeRefs<HTMLElement>(ref, localRoot),\n [ref],\n );\n const deleteButtonRef = useRef<HTMLButtonElement>(null);\n\n /* ---- Focus after Back ------------------------------------------- */\n /* PanelSubview hands focus back to its opener only while the opener\n exists. A row the host reloaded away meanwhile (a task marked done,\n say) needs the nearest surviving one, as TasksPanel's own rescue. */\n const openerRef = useRef<HTMLElement | null>(null);\n const subviewOpenRef = useRef(false);\n if (isSubview && open && !subviewOpenRef.current) {\n /* Recorded while rendering the opening pass, before focus moves. */\n openerRef.current =\n typeof document !== 'undefined' &&\n document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n }\n subviewOpenRef.current = isSubview && open;\n const openRef = useRef(open);\n openRef.current = open;\n const editedTaskRef = useRef(taskId);\n editedTaskRef.current = isEdit ? taskId : undefined;\n\n useEffect(() => {\n const section = localRoot.current;\n const host = section?.parentElement;\n if (!isSubview || !open || !section || !host) return undefined;\n const opener = openerRef.current;\n const fromList =\n opener && host.contains(opener) && !section.contains(opener)\n ? opener\n : null;\n /* A click on a row may leave focus nowhere: use the edited task's. */\n const edited = editedTaskRef.current;\n const row =\n fromList?.closest<HTMLElement>('[data-task-id]') ??\n rowsIn(host, section).find((r) => r.dataset.taskId === edited);\n const rowId = row?.dataset.taskId;\n const action =\n fromList?.closest<HTMLElement>('[data-action]')?.dataset.action;\n const index = row ? rowsIn(host, section).indexOf(row) : -1;\n return () => {\n /* StrictMode replays this cleanup while the subview is still open. */\n if (openRef.current && section.isConnected) return;\n /* Runs after PanelSubview's own return: act only if focus was lost. */\n const lost = document.activeElement;\n if (!host.isConnected || (lost && lost !== document.body)) return;\n const rows = rowsIn(host, section);\n const candidates = [\n ...controlsIn(\n rows.find((r) => rowId !== undefined && r.dataset.taskId === rowId),\n action,\n ),\n /* The row that took its place, or the last row when it was last. */\n ...(index >= 0\n ? controlsIn(rows[Math.min(index, rows.length - 1)], action)\n : []),\n host.querySelector<HTMLElement>('[data-action=\"add-task\"]'),\n host.querySelector<HTMLElement>('[data-tasks-panel-region]'),\n ];\n for (const candidate of candidates) {\n if (!candidate || section.contains(candidate)) continue;\n candidate.focus();\n if (document.activeElement === candidate) return;\n }\n };\n }, [open, isSubview]);\n\n /* ---- Focus after Retry or Turn off ------------------------------ */\n /* Both buttons leave with the state they belong to. Focus waits on the\n editor's root while the task loads, then on a new Retry if it fails. */\n const retryRef = useRef<HTMLButtonElement>(null);\n const rescueRef = useRef(false);\n const rescuing = (run: () => void) => () => {\n rescueRef.current = true;\n run();\n };\n useIsomorphicLayoutEffect(() => {\n if (!rescueRef.current) return;\n const root = localRoot.current;\n const active = document.activeElement;\n /* Focus the user put somewhere else stays there. */\n if (active && active !== document.body && active !== root) {\n rescueRef.current = false;\n return;\n }\n if (status !== 'loading') rescueRef.current = false;\n (status === 'error' ? retryRef.current : root)?.focus({\n preventScroll: true,\n });\n }, [status]);\n\n /* ---- Labels and options ------------------------------------------ */\n const title = t(key(isEdit ? 'editTitle' : 'title'));\n const hasCompanies = companies.length > 0;\n const hasOperators = operators.length > 0;\n const hasPatientSource = hasSearch || patients.length > 0;\n const companyOptions = useMemo(\n () => companies.map((c) => ({ value: c.id, label: c.label })),\n [companies],\n );\n const patientName = (patientId: string): string =>\n resolvePatientLabel?.(patientId) ??\n patients.find((p) => p.id === patientId)?.name ??\n searched.get(patientId) ??\n (patientId === stored?.patientId ? patientLabel : undefined) ??\n t('calendarWorkspace.details.patientNotLoaded');\n const unresolvedOperatorLabel = (operatorId: string): string =>\n operatorId === stored?.operatorId && operatorLabel\n ? operatorLabel\n : t(key('operatorUnresolved'), { id: operatorId });\n\n const operatorOptions = [\n { value: NONE, label: t(key('operatorNone')) },\n ...operators.map((o) => ({ value: o.id, label: o.label })),\n /* An operator the roster no longer lists is still a real link, so it\n stays pickable and survives a Save. */\n ...(fields.operatorId !== NONE &&\n !operators.some((o) => o.id === fields.operatorId)\n ? [\n {\n value: fields.operatorId,\n label: unresolvedOperatorLabel(fields.operatorId),\n },\n ]\n : []),\n ];\n /* Grouped only when the host mixes standard and practice-defined\n types: a lone \"Standard\" heading over every option is noise. */\n const groupTypes =\n taskTypes.some((type) => type.custom) &&\n taskTypes.some((type) => !type.custom);\n const typeOptions = [\n ...taskTypes.map((type) => ({\n value: type.id,\n label: type.label,\n group: groupTypes\n ? t(key(type.custom ? 'typeGroupCustom' : 'typeGroupStandard'))\n : undefined,\n })),\n /* An id the list no longer resolves is still a real link: offered as\n its own option so Save re-sends it. */\n ...(form.chosenTypeId &&\n !taskTypes.some((type) => type.id === form.chosenTypeId)\n ? [\n {\n value: form.chosenTypeId,\n label: t(key('typeUnresolved'), { id: form.chosenTypeId }),\n },\n ]\n : []),\n ];\n const assigneeOptions = [\n { value: NONE, label: t(key('assigneeNone')) },\n ...assignees.map((user) => ({ value: user.id, label: user.label })),\n ...(fields.assigneeId !== NONE &&\n !assignees.some((user) => user.id === fields.assigneeId)\n ? [\n {\n value: fields.assigneeId,\n label: t(key('assigneeUnresolved'), { id: fields.assigneeId }),\n },\n ]\n : []),\n ];\n /* A company id the list does not resolve is still a real link: shown\n read-only, and only picking Nobody or a listed company changes it.\n Includes the no-list case. */\n const unresolvedCompanyId =\n fields.about === 'company' &&\n fields.companyId &&\n !companies.some((c) => c.id === fields.companyId)\n ? fields.companyId\n : undefined;\n const unresolvedCompanyLabel =\n unresolvedCompanyId &&\n unresolvedCompanyId === stored?.companyId &&\n companyLabel\n ? companyLabel\n : t(key('companyUnresolved'), { id: unresolvedCompanyId });\n\n /* ---- Pieces ------------------------------------------------------ */\n const readOnlyNotice = (\n <Alert variant=\"info\" announce=\"off\" icon={<Lock aria-hidden=\"true\" />}>\n <Alert.Title as=\"p\">\n {t('calendarWorkspace.details.readOnlyTitle')}\n </Alert.Title>\n <Alert.Description>{t(key('readOnlyBody'))}</Alert.Description>\n </Alert>\n );\n\n /* Cancel, Back and Escape wait for a write in flight, as the\n appointment description does: closing now would hide a refusal and,\n after a reopen, drop `onSaved`. */\n const busy = ui.saving || ui.deleting;\n const requestCancel = () => {\n if (!form.isBusy()) onCancel();\n };\n\n const cancelButton = (\n <IconButton\n size=\"sm\"\n intent=\"outline\"\n icon={<X aria-hidden=\"true\" />}\n aria-label={t(key('cancel'))}\n tooltip={t(key('cancel'))}\n data-action=\"cancel-task\"\n disabled={busy}\n onClick={requestCancel}\n />\n );\n /* Save keeps focus while it runs, so it is aria-disabled, not disabled,\n and the status line says why. After a landed save it stays inert. */\n const saveInert = ui.saving || ui.accepted;\n\n /* The appointment editor's footer: one icon-only toolbar, the names on\n aria-label and tooltip, Save at the inline end. */\n const footerFor = (withWrites: boolean): ReactNode => (\n <>\n {withWrites && form.showDelete ? (\n <IconButton\n ref={deleteButtonRef}\n size=\"sm\"\n intent=\"destructiveOutline\"\n icon={<Trash2 aria-hidden=\"true\" />}\n aria-label={t(key('delete'))}\n tooltip={t(key('delete'))}\n data-action=\"delete-task\"\n /* The confirm would be refused mid-save or after a landed\n write, so the trigger waits too. */\n disabled={busy || ui.accepted}\n /* A fresh confirmation: an earlier refusal is not this one. */\n onClick={() =>\n form.patchUi({ confirmDeleteOpen: true, deleteError: undefined })\n }\n />\n ) : null}\n <IconButtonGroup\n role=\"toolbar\"\n aria-label={t(key('actionsLabel'))}\n className=\"ds:ms-auto\"\n >\n {cancelButton}\n {withWrites && form.showSave ? (\n <IconButton\n size=\"sm\"\n intent=\"primary\"\n icon={\n ui.saving ? (\n <LoaderCircle\n aria-hidden=\"true\"\n className=\"ds:animate-spin ds:motion-reduce:animate-none\"\n />\n ) : (\n <SaveIcon aria-hidden=\"true\" />\n )\n }\n aria-label={t(key('save'))}\n tooltip={t(key('save'))}\n disabled={!saveInert && !form.canSave}\n aria-disabled={saveInert || undefined}\n aria-busy={ui.saving || undefined}\n data-action=\"save-task\"\n onClick={() => {\n if (!saveInert) void form.submit();\n }}\n />\n ) : null}\n </IconButtonGroup>\n {withWrites && form.showSave ? (\n /* Out of flow, so it never moves the footer's two ends. */\n <span role=\"status\" className=\"ds:sr-only\">\n {ui.saving ? t(key('saving')) : ''}\n </span>\n ) : null}\n </>\n );\n\n const loadingBody = (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]\">\n {/* Outside the aria-hidden skeletons, so it is announced. */}\n <span role=\"status\" className=\"ds:sr-only\">\n {t('common.loading')}\n </span>\n <div\n aria-hidden=\"true\"\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) + var(--spacing-sm))\"\n />\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) * 3)\"\n stagger={1}\n />\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) + var(--spacing-sm))\"\n stagger={2}\n />\n </div>\n </div>\n );\n\n const errorBody = (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]\">\n <Alert variant=\"error\">\n <Alert.Description>{form.loadError}</Alert.Description>\n </Alert>\n <Button\n ref={retryRef}\n intent=\"outline\"\n data-action=\"retry-load\"\n onClick={rescuing(form.retry)}\n >\n {t('emptyState.error.cta')}\n </Button>\n </div>\n );\n\n /* Disabled, like the ready state's read-only fieldset: the whole body\n is inert, not merely toned down. */\n const lockedBody = (\n <fieldset disabled className={fieldsetVariants({ layout: 'notice' })}>\n {readOnlyNotice}\n </fieldset>\n );\n\n const patientField = (): ReactNode => {\n if (fields.about !== 'patient') return null;\n if (maskPatient) {\n return (\n <FormField label={t(key('aboutPatient'))}>\n <TextInput value={privacyMask()} disabled readOnly />\n </FormField>\n );\n }\n if (hasPatientSource) {\n return (\n <FormField label={t(key('aboutPatient'))}>\n <PatientPicker\n value={fields.patientId}\n onValueChange={(patientId) => form.patchFields({ patientId })}\n patients={patients}\n searchPatients={search}\n selectedLabel={\n fields.patientId ? patientName(fields.patientId) : undefined\n }\n placeholder={t('calendarWorkspace.editor.patientSearch')}\n disabled={readOnly}\n />\n </FormField>\n );\n }\n /* Nothing to pick from: name the stored link read-only. */\n return fields.patientId ? (\n <FormField label={t(key('aboutPatient'))}>\n <TextInput value={patientName(fields.patientId)} disabled readOnly />\n </FormField>\n ) : null;\n };\n\n const formFields = (\n <fieldset disabled={readOnly} className={fieldsetVariants()}>\n {readOnly ? readOnlyNotice : null}\n <FormField label={t(key('date'))}>\n <DatePicker\n value={fields.date}\n onChange={(date) => form.patchFields({ date })}\n />\n </FormField>\n <FormField label={t(key('time'))}>\n <TimePicker\n value={fields.time}\n onChange={(time) => form.patchFields({ time })}\n />\n </FormField>\n <FormField\n label={t(key('note'))}\n required\n error={\n ui.showError && fields.note.trim() === ''\n ? t(key('noteRequired'))\n : undefined\n }\n >\n <TextArea\n value={fields.note}\n onChange={(e) => {\n form.patchFields({ note: e.target.value });\n form.patchUi({ showError: false });\n }}\n minRows={3}\n autoResize\n />\n </FormField>\n {taskTypes.length > 0 ? (\n <FormField label={t(key('type'))} required>\n <Select\n options={typeOptions}\n value={form.chosenTypeId}\n onValueChange={(v) => v && form.patchFields({ typeId: v })}\n />\n </FormField>\n ) : null}\n {assignees.length > 0 ? (\n <FormField label={t(key('assignee'))}>\n <Select\n options={assigneeOptions}\n value={fields.assigneeId}\n onValueChange={(v) => v && form.patchFields({ assigneeId: v })}\n />\n </FormField>\n ) : null}\n <RadioGroup\n label={t(key('about'))}\n variant=\"segmented\"\n className={EDITOR_COMPACT_SEGMENTED_CLASS}\n value={fields.about}\n onValueChange={(v) =>\n form.patchFields({ about: v as typeof fields.about })\n }\n >\n {/* Every segment carries an icon: without one the group's\n collapse-to-icon net cannot fire. */}\n <Radio\n value=\"nobody\"\n label={t(key('aboutNobody'))}\n icon={<CircleOff aria-hidden=\"true\" />}\n />\n {/* Withheld with nothing to pick from, as Company is. Kept while\n chosen, so the group never loses its checked value, and while\n the stored record holds that link, so switching away and back\n can restore it. */}\n {hasPatientSource ||\n fields.about === 'patient' ||\n Boolean(stored?.patientId) ? (\n <Radio\n value=\"patient\"\n label={t(key('aboutPatient'))}\n icon={<User aria-hidden=\"true\" />}\n />\n ) : null}\n {hasCompanies ||\n fields.about === 'company' ||\n Boolean(stored?.companyId) ? (\n <Radio\n value=\"company\"\n label={t(key('aboutCompany'))}\n icon={<Building2 aria-hidden=\"true\" />}\n />\n ) : null}\n {/* The operator is a COUNTERPART, not a field beside them: the\n platform refuses a task that names two. */}\n {hasOperators ||\n fields.about === 'operator' ||\n Boolean(stored?.operatorId) ? (\n <Radio\n value=\"operator\"\n label={t(key('aboutOperator'))}\n icon={<Stethoscope aria-hidden=\"true\" />}\n />\n ) : null}\n </RadioGroup>\n {patientField()}\n {fields.about === 'company' ? (\n <>\n {unresolvedCompanyId ? (\n <FormField label={t(key('companyName'))}>\n <TextInput value={unresolvedCompanyLabel} disabled readOnly />\n </FormField>\n ) : null}\n {/* One picker in one slot for both states, so replacing an\n unresolved company keeps focus in the field. Clearing empties\n the id, which disables Save. */}\n {hasCompanies ? (\n <FormField\n label={t(\n key(unresolvedCompanyId ? 'companyReplace' : 'companyName'),\n )}\n >\n <Combobox\n options={companyOptions}\n value={unresolvedCompanyId ? '' : fields.companyId}\n onValueChange={(v) =>\n unresolvedCompanyId\n ? v && form.patchFields({ companyId: v })\n : form.patchFields({ companyId: v })\n }\n /* The Combobox cannot see the disabled fieldset. */\n clearable={!unresolvedCompanyId && !readOnly}\n filter={companyFilter}\n placeholder={t(key('companySearch'))}\n aria-label={t(\n key(unresolvedCompanyId ? 'companyReplace' : 'companyName'),\n )}\n />\n </FormField>\n ) : null}\n </>\n ) : null}\n {fields.about === 'operator' ? (\n hasOperators ? (\n <FormField label={t(key('operator'))}>\n <Select\n options={operatorOptions}\n value={fields.operatorId}\n onValueChange={(v) => v && form.patchFields({ operatorId: v })}\n />\n </FormField>\n ) : fields.operatorId !== NONE ? (\n /* No roster to pick from: name the link read-only. */\n <FormField label={t(key('operator'))}>\n <TextInput\n value={unresolvedOperatorLabel(fields.operatorId)}\n disabled\n readOnly\n />\n </FormField>\n ) : null\n ) : null}\n {form.showDone ? (\n <>\n <Switch\n label={t(key('done'))}\n checked={ui.done}\n /* A Save in flight re-sends the done value it captured, and a\n landed save or delete ends the session's writes. */\n disabled={busy || ui.accepted}\n /* Its own write keeps focus: aria-disabled, not disabled. */\n aria-disabled={ui.donePending || undefined}\n aria-busy={ui.donePending || undefined}\n className=\"ds:aria-disabled:cursor-progress\"\n onCheckedChange={(next) => {\n if (!ui.donePending) void form.setDone(next);\n }}\n />\n {ui.doneError ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.doneError}</Alert.Description>\n </Alert>\n ) : null}\n </>\n ) : null}\n {ui.saveError ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.saveError}</Alert.Description>\n </Alert>\n ) : null}\n {/* An agent delete skips the dialog, so its refusal shows here. */}\n {ui.deleteError && !ui.confirmDeleteOpen ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.deleteError}</Alert.Description>\n </Alert>\n ) : null}\n </fieldset>\n );\n\n const body =\n status === 'loading' ? (\n loadingBody\n ) : status === 'error' ? (\n errorBody\n ) : status === 'locked' ? (\n lockedBody\n ) : status === 'withheld' ? (\n <PrivacyNotice\n onTurnOff={onPrivacyOff ? rescuing(onPrivacyOff) : undefined}\n />\n ) : isSubview ? (\n formFields\n ) : (\n <ScrollArea orientation=\"vertical\" className=\"ds:min-h-0 ds:flex-1\">\n {formFields}\n </ScrollArea>\n );\n /* Loading and a failed load have no footer, as before; the locked and\n withheld states keep the way out. */\n const footer =\n status === 'ready'\n ? footerFor(true)\n : status === 'locked' || status === 'withheld'\n ? footerFor(false)\n : null;\n const hasDelete = status === 'ready' && form.showDelete;\n\n const deleteDialog = isEdit ? (\n <Dialog\n open={ui.confirmDeleteOpen && active}\n onOpenChange={(next) => {\n /* A failed delete keeps the dialog open with its error; closing\n it any other way clears that error, so a reopened dialog never\n shows a stale one. */\n if (ui.deleting) return;\n form.patchUi(\n next\n ? { confirmDeleteOpen: true }\n : { confirmDeleteOpen: false, deleteError: undefined },\n );\n }}\n >\n <Dialog.Content\n size=\"sm\"\n variant=\"alert\"\n onCloseAutoFocus={(event) => {\n /* The delete button is not a Dialog.Trigger, so Radix would\n drop focus on the body. Keep or Escape hands it back; once\n the task is gone, it must not land on its delete button. */\n event.preventDefault();\n if (!form.isAccepted()) deleteButtonRef.current?.focus();\n }}\n >\n <Dialog.Header>\n <Dialog.Title>{t(key('deleteConfirmTitle'))}</Dialog.Title>\n <Dialog.Description>\n {t(key('deleteConfirmBody'))}\n </Dialog.Description>\n </Dialog.Header>\n {ui.deleteError ? (\n <Dialog.Body>\n <Alert variant=\"error\">\n <Alert.Description>{ui.deleteError}</Alert.Description>\n </Alert>\n </Dialog.Body>\n ) : null}\n <Dialog.Footer divider>\n {/* Both keep focus while the delete runs, so a refusal is read\n in the dialog: aria-disabled, and onOpenChange waits. */}\n <Dialog.Close asChild>\n <Button intent=\"outline\" aria-disabled={ui.deleting || undefined}>\n {t(key('deleteCancel'))}\n </Button>\n </Dialog.Close>\n <Button\n intent=\"destructive\"\n startIcon={<Trash2 aria-hidden=\"true\" />}\n aria-disabled={ui.deleting || undefined}\n aria-busy={ui.deleting || undefined}\n onClick={() => {\n if (!ui.deleting) void form.remove();\n }}\n >\n {t(key('deleteConfirm'))}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n ) : null;\n\n const marker = {\n 'data-component': 'task-editor',\n 'data-component-id': instanceId,\n 'data-variant': variant,\n 'data-status': status,\n };\n\n if (isSubview) {\n return (\n <>\n <PanelSubview\n {...rest}\n /* The section holds the heading and footer too: repeat the\n instance hooks there so one selector reaches every action. */\n data-component-id={instanceId}\n data-variant={variant}\n data-status={status}\n ref={rootRef}\n open={open}\n onBack={requestCancel}\n onExited={onExited}\n title={title}\n icon={<SquareCheckBig aria-hidden=\"true\" />}\n backLabel={backLabel ?? t(key('back'))}\n footer={footer}\n footerAlign={hasDelete ? 'between' : 'end'}\n className={className}\n >\n <div {...marker} className={taskEditorVariants({ variant })}>\n {body}\n </div>\n </PanelSubview>\n {deleteDialog}\n </>\n );\n }\n\n return (\n <>\n <div\n tabIndex={-1}\n {...rest}\n {...marker}\n ref={rootRef}\n className={taskEditorVariants({ variant, className })}\n >\n <PanelHeader\n title={title}\n icon={<SquareCheckBig aria-hidden=\"true\" />}\n sticky\n divider\n />\n {body}\n {footer ? (\n <div className=\"ds:relative ds:z-[var(--z-sticky)] ds:shrink-0 ds:border-t ds:border-[color:var(--border)] ds:bg-[var(--background)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]\">\n {footer}\n </div>\n </div>\n ) : null}\n </div>\n {deleteDialog}\n </>\n );\n },\n);\nTaskEditor.displayName = 'TaskEditor';\n"],"names":["__iconNode","CircleOff","createLucideIcon","Save","EDITOR_COMPACT_FIELDS_CLASS","EDITOR_COMPACT_SEGMENTED_CLASS","PatientPicker","patients","searchPatients","props","jsx","PatientSearchPicker","value","onValueChange","selectedLabel","placeholder","size","disabled","Combobox","p","t","useTranslation","query","setQuery","useState","retry","setRetry","picked","setPicked","state","setState","inputRef","useRef","trimmedQuery","useEffect","controller","base","timer","current","status","message","options","patient","jsxs","next","prev","open","candidate","normalizeDiacritics","Button","_a","taskEditorAgent","handle","args","NONE","INITIAL_UI","aboutOf","task","timeOf","date","blankFields","initialDate","fieldsOf","COUNTERPARTS","useTaskEditorForm","mode","taskId","active","taskTypes","assignees","companies","operators","searchedPatients","resolvePatientLabel","loadTask","onCreateTask","onUpdateTask","onDeleteTask","onSetTaskDone","onSaved","onDeleted","readOnly","withheld","maskPatient","fallbackError","isEdit","session","setSession","wasActive","setWasActive","previous","subject","fields","setFields","ui","setUi","stored","setStored","patchUi","patchFields","currentSubject","setCurrentSubject","sessionRef","mountedRef","live","owner","loadTaskRef","hasLoadTask","attempt","setAttempt","loaded","setLoaded","loadedRef","canLoad","load","done","error","getErrorMessage","chosenTypeId","counterpartChosen","canSave","saveSeam","buildDraft","time","refuse","reason","handledRejection","submit","draft","id","write","created","setDone","remove","knows","list","storedId","entry","applyPatch","patch","chosen","key","branch","draftState","taskEditorVariants","cva","fieldsetVariants","suffix","companyFilter","_value","search","label","EMPTY","rowsIn","host","subview","row","FOCUSABLE","controlsIn","action","actions","el","TaskEditor","forwardRef","variant","onExited","patientLabel","companyLabel","operatorLabel","backLabel","onCancel","privacy","privacyMode","onPrivacyOff","className","rest","ref","reactId","useId","instanceId","isSubview","searched","form","searchRef","hasSearch","useMemo","found","formRef","onCancelRef","useAgentRegistration","localRoot","rootRef","composeRefs","deleteButtonRef","openerRef","subviewOpenRef","openRef","editedTaskRef","section","opener","fromList","edited","r","rowId","index","lost","rows","candidates","retryRef","rescueRef","rescuing","run","useIsomorphicLayoutEffect","root","title","hasCompanies","hasOperators","hasPatientSource","companyOptions","c","patientName","patientId","unresolvedOperatorLabel","operatorId","operatorOptions","o","groupTypes","type","typeOptions","assigneeOptions","user","unresolvedCompanyId","unresolvedCompanyLabel","readOnlyNotice","Alert","Lock","busy","requestCancel","cancelButton","IconButton","X","saveInert","footerFor","withWrites","Fragment","Trash2","IconButtonGroup","LoaderCircle","SaveIcon","loadingBody","Skeleton","errorBody","lockedBody","patientField","FormField","TextInput","privacyMask","formFields","DatePicker","TimePicker","TextArea","e","Select","v","RadioGroup","Radio","User","Building2","Stethoscope","Switch","body","PrivacyNotice","ScrollArea","footer","hasDelete","deleteDialog","Dialog","event","marker","PanelSubview","SquareCheckBig","PanelHeader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,cAAc,KAAK,SAAQ,CAAE;AAAA,EAC3C,CAAC,QAAQ,EAAE,GAAG,qCAAqC,KAAK,SAAQ,CAAE;AAAA,EAClE,CAAC,QAAQ,EAAE,GAAG,sCAAsC,KAAK,SAAQ,CAAE;AACrE,GACMC,KAAYC,GAAiB,cAAcF,EAAU;ACd3D;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,6CAA6C,KAAK,SAAQ,CAAE;AAAA,EAC1E,CAAC,QAAQ,EAAE,GAAG,0BAA0B,KAAK,SAAQ,CAAE;AACzD,GACMG,KAAOD,GAAiB,QAAQF,EAAU,GCMnCI,KAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AACF,EAAE,KAAK,GAAG,GAQGC,KAAiC;AAAA,EAC5C;AAAA,EACA;AACF,EAA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AAC;AAAA,QAAA;AAAA,UACC,UAAU;AAAA,UACT,GAAGoI;AAAA,UACH,GAAGuG;AAAA,UACJ,KAAKvF;AAAA,UACL,WAAW/C,GAAmB,EAAE,SAAAoB,GAAS,WAAAU,GAAW;AAAA,UAEpD,UAAA;AAAA,YAAA,gBAAApK;AAAA,cAAC+Q;AAAA,cAAA;AAAA,gBACC,OAAAnE;AAAA,gBACA,MAAM,gBAAA5M,EAAC8Q,IAAA,EAAe,eAAY,OAAA,CAAO;AAAA,gBACzC,QAAM;AAAA,gBACN,SAAO;AAAA,cAAA;AAAA,YAAA;AAAA,YAERV;AAAA,YACAG,KACC,gBAAAvQ,EAAC,OAAA,EAAI,WAAU,wHACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,+EACZ,UAAAuQ,GAAA,CACH,EAAA,CACF,IACE;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAELE;AAAA,IAAA,GACH;AAAA,EAEJ;AACF;AACAjH,GAAW,cAAc;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"task-editor-Cpw-NmND.js","sources":["../../node_modules/lucide-react/dist/esm/icons/circle-off.mjs","../../node_modules/lucide-react/dist/esm/icons/save.mjs","../../src/components/_shared/compact-editor-fields.ts","../../src/components/_shared/patient-picker.tsx","../../src/components/task-editor/task-editor.agent.ts","../../src/components/task-editor/use-task-editor-form.ts","../../src/components/task-editor/task-editor.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: \"m2 2 20 20\", key: \"1ooewy\" }],\n [\"path\", { d: \"M8.35 2.69A10 10 0 0 1 21.3 15.65\", key: \"1pfsoa\" }],\n [\"path\", { d: \"M19.08 19.08A10 10 0 1 1 4.92 4.92\", key: \"1ablyi\" }]\n];\nconst CircleOff = createLucideIcon(\"circle-off\", __iconNode);\n\nexport { __iconNode, CircleOff as default };\n//# sourceMappingURL=circle-off.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: \"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z\",\n key: \"1c8476\"\n }\n ],\n [\"path\", { d: \"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7\", key: \"1ydtos\" }],\n [\"path\", { d: \"M7 3v4a1 1 0 0 0 1 1h7\", key: \"t51u73\" }]\n];\nconst Save = createLucideIcon(\"save\", __iconNode);\n\nexport { __iconNode, Save as default };\n//# sourceMappingURL=save.mjs.map\n","/**\n * Compact fields for the calendar's appointment and waiting-list entry\n * editors and for the published TaskEditor, which the calendar's task route\n * also renders: 32px high with `--radius-md` corners, the height and shape\n * of the calendar toolbar's controls, where the kit default is 44px with\n * `--radius-sm`. Shared here so a published component can use it.\n *\n * INTENTIONAL EXCEPTION — do not \"fix\" these back to 44px. 32px sits below\n * `--min-target-size` on purpose: it is the toolbar's sanctioned sub-target\n * trade (documented beside `--min-target-size` in `src/tokens/index.css` and\n * in `calendar-toolbar.mdx`). 32×32 clears WCAG 2.5.8 (AA, 24×24), and\n * every field keeps at least `--spacing-md` of clear space from the next.\n *\n * Scoped by a class on each editor's form root, reaching the fields through\n * their `data-component` markers, so the kit-wide `TextInput`, `Select`,\n * `DatePicker`, `TimePicker`, `Combobox` and `NumberInput` defaults stay\n * untouched. The\n * descendant selector outranks each field's own height utility, so no\n * `size` prop is needed — and `Select`'s `size=\"sm\"` would also have shrunk\n * its menu items, which must keep the kit's target.\n *\n * The raise is opt-in, as on the toolbar: under `.theme-accessible` every\n * field goes back to `--min-target-size` (48px), and below the `sm`\n * breakpoint, where the pointer is a finger, to the full target as well.\n * `min-block-size` beats `h-8`, so the raise lands without undoing it.\n */\nexport const EDITOR_COMPACT_FIELDS_CLASS = [\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:h-8',\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:rounded-[var(--radius-md)]',\n 'ds:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:[min-block-size:var(--accessible-target-floor,auto)]',\n 'ds:max-sm:[&_:is([data-component=select][role=combobox],[data-component=text-input],[data-component=text-input]_input,[data-component=date-picker]_input,[data-component=combobox],[data-component=time-picker],[data-component=number-input])]:[min-block-size:var(--min-target-size)]',\n /* Multi-line notes keep their height but share the corners. */\n 'ds:[&_[data-component=text-area]_textarea]:rounded-[var(--radius-md)]',\n /* The time field's hour and minute segments are 32px at the kit default;\n inside a 32px box they take the kit's `sm` segment height instead,\n and get the default back wherever the field is raised. */\n 'ds:[&_[data-component=time-picker]_[role=spinbutton]]:h-[calc(var(--ds-spacing)*(6+2*var(--accessible-on,0)))]',\n 'ds:max-sm:[&_[data-component=time-picker]_[role=spinbutton]]:h-8',\n].join(' ');\n\n/**\n * The same exception for a `variant=\"segmented\"` RadioGroup (the task\n * editor's \"Concerns\" switch): pass it as the group's `className`. The\n * track takes 32px and its segments stretch to fill it; accessible themes\n * give each segment `--min-target-size` back and let the track grow.\n */\nexport const EDITOR_COMPACT_SEGMENTED_CLASS = [\n 'ds:h-[var(--accessible-auto,calc(var(--ds-spacing)*8))] ds:[&_[role=radio]]:[min-block-size:var(--accessible-target-floor,0px)]',\n 'ds:max-sm:h-auto ds:max-sm:[&_[role=radio]]:min-h-[var(--min-target-size)]',\n].join(' ');\n","/* One id-valued patient control, shared by the published TaskEditor and the\n calendar's editors. It lists a host typeahead's results when one is given,\n or filters a list on the client. The caller names the selected patient and\n translates the placeholder. Moved from the calendar pattern so published\n components can use it. */\nimport { useEffect, useRef, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Combobox } from '../combobox';\nimport { Button } from '../button';\nimport { normalizeDiacritics } from './normalize-diacritics';\nimport type { PatientIdentity } from './patient-identity';\n\n/** Host typeahead. Called 250 ms after typing stops, for non-blank trimmed\n * queries only. Abort a superseded call through `signal`. The host's order\n * is kept, so matches by phone or number stay. Reject on failure; `[]` is a\n * successful search with no match. */\nexport type PatientSearch = (\n query: string,\n options: { signal: AbortSignal },\n) => Promise<readonly PatientIdentity[]>;\n\nexport interface PatientPickerProps {\n value: string;\n onValueChange: (value: string) => void;\n /** Filtered on the client when `searchPatients` is absent. */\n patients?: readonly PatientIdentity[];\n /** Wins over `patients` for listing. */\n searchPatients?: PatientSearch;\n /** Names `value` when neither the list nor a search result does. */\n selectedLabel?: string;\n /** Already translated. Also the idle line under a search. */\n placeholder: string;\n size?: 'sm' | 'md';\n disabled?: boolean;\n}\n\nexport function PatientPicker({\n patients = [],\n searchPatients,\n ...props\n}: PatientPickerProps) {\n if (searchPatients) {\n return <PatientSearchPicker {...props} searchPatients={searchPatients} />;\n }\n const { value, onValueChange, selectedLabel, placeholder, size, disabled } =\n props;\n return (\n <Combobox\n value={value}\n onValueChange={onValueChange}\n options={[\n ...(value && !patients.some((p) => p.id === value)\n ? [{ value, label: selectedLabel ?? '' }]\n : []),\n ...patients.map((p) => ({ value: p.id, label: p.name })),\n ]}\n placeholder={placeholder}\n size={size}\n disabled={disabled}\n clearable\n />\n );\n}\n\ninterface SearchState {\n query: string;\n source: PatientSearch;\n status: 'loading' | 'ready' | 'error';\n patients: readonly PatientIdentity[];\n}\n\nfunction PatientSearchPicker({\n value,\n onValueChange,\n selectedLabel,\n placeholder,\n size,\n disabled,\n searchPatients,\n}: Omit<PatientPickerProps, 'patients' | 'searchPatients'> & {\n searchPatients: PatientSearch;\n}) {\n const { t } = useTranslation('ui');\n const [query, setQuery] = useState('');\n const [retry, setRetry] = useState(0);\n const [picked, setPicked] = useState<PatientIdentity>();\n const [state, setState] = useState<SearchState>();\n const inputRef = useRef<HTMLInputElement>(null);\n const trimmedQuery = query.trim();\n\n useEffect(() => {\n if (!trimmedQuery) return;\n const controller = new AbortController();\n const base = { query: trimmedQuery, source: searchPatients };\n setState({ ...base, status: 'loading', patients: [] });\n const timer = setTimeout(() => {\n Promise.resolve()\n .then(() => searchPatients(trimmedQuery, { signal: controller.signal }))\n .then(\n (patients) => {\n if (!controller.signal.aborted)\n setState({ ...base, status: 'ready', patients });\n },\n () => {\n if (!controller.signal.aborted)\n setState({ ...base, status: 'error', patients: [] });\n },\n );\n }, 250);\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [trimmedQuery, searchPatients, retry]);\n\n const current =\n state?.query === trimmedQuery && state.source === searchPatients;\n const status = !trimmedQuery ? 'idle' : current ? state.status : 'loading';\n const patients = current && status === 'ready' ? state.patients : [];\n const message =\n status === 'loading'\n ? t('inputs.search.loading')\n : status === 'error'\n ? t('emptyState.error.description')\n : status === 'idle'\n ? placeholder\n : patients.length === 0\n ? t('inputs.combobox.empty')\n : '';\n const options = patients.map((patient) => ({\n value: patient.id,\n label: patient.name,\n }));\n if (value && !patients.some((patient) => patient.id === value)) {\n options.push({\n value,\n label: picked?.id === value ? picked.name : (selectedLabel ?? ''),\n });\n }\n\n return (\n <div\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\"\n data-component=\"patient-picker\"\n data-status={status}\n >\n <Combobox\n ref={inputRef}\n options={options}\n value={value}\n onValueChange={(next) => {\n setPicked(\n (prev) =>\n patients.find((patient) => patient.id === next) ??\n (prev?.id === next ? prev : undefined),\n );\n onValueChange(next);\n }}\n onQueryChange={setQuery}\n onOpenChange={(open) => {\n // Retry lives outside the popover. Preserve its failed query\n // when focusing that button dismisses the option list.\n if (!open && status !== 'error') setQuery('');\n }}\n /* Keep the held option for its label, but do not present it as a\n * search match unless the server actually returned it. */\n filter={(candidate) =>\n !trimmedQuery ||\n patients.some((p) => normalizeDiacritics(p.id) === candidate)\n ? 1\n : 0\n }\n size={size}\n disabled={disabled}\n placeholder={placeholder}\n emptyMessage={message || undefined}\n clearable\n />\n {/* A retained selection can keep Command.Empty hidden. Status lives\n * outside the listbox so loading and errors are still announced. */}\n <p role=\"status\" className=\"type-body-sm ds:text-muted-foreground\">\n {message}\n </p>\n {status === 'error' ? (\n <Button\n size=\"sm\"\n intent=\"ghost\"\n onClick={() => {\n setRetry((prev) => prev + 1);\n inputRef.current?.focus();\n }}\n >\n {t('emptyState.error.cta')}\n </Button>\n ) : null}\n </div>\n );\n}\n","/* -------------------------------------------------------------------- */\n/* Agent adapter: TaskEditor. */\n/* */\n/* Reads the form's status and draft (identifiers and structure, never */\n/* the note body or a patient name) and drives the same code paths as */\n/* the buttons. Writes return the host's promise, so a refusal reaches */\n/* the agent as a rejection and the form shows the same error. */\n/* */\n/* Safety follows kit precedent: set_fields and save carry a note body */\n/* and a patient link, so `phi` (as notes-panel add_note); set_done is a */\n/* `write` toggle (as tasks-panel toggle_done); delete is `destructive` */\n/* and skips the dialog, because the runtime's own confirmation replaces */\n/* it; cancel can drop typed input, so `destructive` (as dialog dismiss). */\n/* `delete` has no capability of its own, as notes-panel pin and flag */\n/* have none. */\n/* */\n/* Footer actions carry data-action \"cancel-task\", \"save-task\" and */\n/* \"delete-task\"; a failed load's Retry carries \"retry-load\". In the */\n/* subview, the PanelSubview section repeats data-component-id, so */\n/* [data-component-id=\"…\"] reaches the footer in both variants. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { TaskEditorFieldPatch, TaskEditorHandle } from './task-editor';\n\nexport const taskEditorAgent: AgentAdapter<TaskEditorHandle> = {\n id: 'task-editor',\n // set_value backs set_fields and set_done; submit backs save; dismiss\n // backs cancel.\n capabilities: ['set_value', 'submit', 'dismiss'],\n state: {\n status: {\n type: \"'loading' | 'ready' | 'error' | 'locked' | 'withheld'\",\n descriptionKey: 'ui.agent.taskEditor.state.status',\n description:\n \"Where the form is: loading the task, ready, failed to load, locked (edit mode with nothing to load) or withheld behind the privacy notice. Writes need 'ready'.\",\n read: (handle) => handle.getStatus(),\n },\n draft: {\n type: '{ mode: string; dateIso: string | null; about: string; patientId: string | null; companyId: string | null; operatorId: string | null; typeId: string | null; assigneeId: string | null; done: boolean; hasNote: boolean; noteLength: number }',\n descriptionKey: 'ui.agent.taskEditor.state.draft',\n description:\n 'The draft as Save would send it: ids and structure only, never the note body. done is the last value the host confirmed.',\n read: (handle) => handle.getDraft(),\n },\n canSave: {\n type: 'boolean',\n descriptionKey: 'ui.agent.taskEditor.state.canSave',\n description:\n 'Whether save would reach the host now: the form is ready, the note is filled, a chosen counterpart has an id and no write is pending.',\n read: (handle) => handle.canSave(),\n },\n },\n actions: {\n set_fields: {\n safety: 'phi',\n argsType:\n \"{ dateIso?: string; note?: string; typeId?: string; assigneeId?: string | null; about?: 'nobody' | 'patient' | 'company' | 'operator'; patientId?: string; companyId?: string; operatorId?: string }\",\n argsSchema: {\n type: 'object',\n properties: {\n dateIso: { type: 'string', format: 'date-time' },\n note: { type: 'string' },\n typeId: { type: 'string' },\n assigneeId: { type: ['string', 'null'] },\n about: {\n type: 'string',\n enum: ['nobody', 'patient', 'company', 'operator'],\n },\n patientId: { type: 'string' },\n companyId: { type: 'string' },\n operatorId: { type: 'string' },\n },\n },\n idempotent: true,\n errors: [\n 'An id the host lists, its patient search or the stored task do not resolve.',\n 'More than one of patientId, companyId and operatorId.',\n 'The form is not ready, is read-only or is withheld.',\n ],\n descriptionKey: 'ui.agent.taskEditor.actions.setFields',\n description:\n 'Set draft fields. Ids must come from the host lists, a patient the host search returned, or equal the stored one. At most one counterpart per call, and it selects its branch; assigneeId null is nobody. Nothing is saved.',\n invoke: (handle, args: TaskEditorFieldPatch) => {\n handle.setFields(args);\n },\n },\n save: {\n safety: 'phi',\n // Reaches the host's data source; the result is the host's promise.\n openWorld: true,\n descriptionKey: 'ui.agent.taskEditor.actions.save',\n description:\n 'Save the task through the host. Resolves once the write lands and rejects with the host error, which the form also shows.',\n invoke: (handle) => handle.save(),\n },\n set_done: {\n safety: 'write',\n argsType: '{ done: boolean }',\n argsSchema: {\n type: 'object',\n properties: { done: { type: 'boolean' } },\n required: ['done'],\n },\n openWorld: true,\n errors: [\n 'The form is not ready, is read-only or has no Done seam.',\n 'A save, a delete or another Done change is in flight.',\n 'The task was already saved or deleted in this session.',\n ],\n descriptionKey: 'ui.agent.taskEditor.actions.setDone',\n description:\n 'Mark an existing task done or not done through the host. A rejection rolls the switch back.',\n invoke: (handle, args: { done: boolean }) => handle.setDone(args.done),\n },\n delete: {\n safety: 'destructive',\n idempotent: true,\n openWorld: true,\n descriptionKey: 'ui.agent.taskEditor.actions.delete',\n description:\n 'Delete the task through the host, without the confirmation dialog. Resolves once the delete lands.',\n invoke: (handle) => handle.deleteTask(),\n },\n cancel: {\n safety: 'destructive',\n errors: ['A save or delete is in flight: wait for it to settle.'],\n descriptionKey: 'ui.agent.taskEditor.actions.cancel',\n description:\n 'Close the editor without saving. Anything typed since the last save is lost. Refused while a save or delete is in flight.',\n invoke: (handle) => {\n handle.cancel();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'task-editor',\n description:\n 'Marks the TaskEditor body. It also carries data-variant and data-status. In the subview variant it sits inside the panel-subview section, which repeats data-component-id, data-variant and data-status and holds the heading and footer.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop, or generated. Addresses one editor from the agent. [data-component-id] reaches the footer actions in both variants.',\n },\n },\n};\n","/* The TaskEditor's form state machine. Private to the component: it holds the\n draft, loads the record, and runs the three writes. Moved from the\n calendar's task editor with every CalendarData read turned into an option,\n plus sessions (a subview reopen starts a fresh draft), an abortable load\n with Retry, and writes that return the host's promise for the agent. */\nimport { useEffect, useRef, useState } from 'react';\nimport { getErrorMessage } from '../_shared/get-error-message';\nimport { handledRejection } from '../_shared/handled-rejection';\nimport type {\n TaskEditorAbout,\n TaskEditorDraft,\n TaskEditorDraftState,\n TaskEditorFieldPatch,\n TaskEditorOption,\n TaskEditorPatient,\n TaskEditorProps,\n TaskEditorStatus,\n TaskEditorTask,\n TaskEditorTaskType,\n} from './task-editor';\n\n/** The \"unset\" value of the operator and assignee selects. */\nexport const NONE = 'none';\n\nexport interface TaskEditorFields {\n date: Date | undefined;\n time: { hours: number; minutes: number };\n note: string;\n /** `NONE` until an operator is chosen. */\n operatorId: string;\n /** '' until something chooses one. Read through `chosenTypeId`. */\n typeId: string;\n /** The practice user, not the operator. `NONE` is nobody. */\n assigneeId: string;\n about: TaskEditorAbout;\n patientId: string;\n /** A real id from the host list, never a typed name. */\n companyId: string;\n}\n\ninterface UiState {\n showError: boolean;\n saving: boolean;\n saveError: string | undefined;\n /* `done` is the DISPLAYED value, optimistic while a toggle is pending;\n `confirmedDone` is the last value the host accepted, and is what Save\n sends. */\n done: boolean;\n confirmedDone: boolean;\n donePending: boolean;\n doneError: string | undefined;\n deleting: boolean;\n deleteError: string | undefined;\n confirmDeleteOpen: boolean;\n /** A save or delete landed: the form stops writing until a new session. */\n accepted: boolean;\n}\n\nconst INITIAL_UI: UiState = {\n showError: false,\n saving: false,\n saveError: undefined,\n done: false,\n confirmedDone: false,\n donePending: false,\n doneError: undefined,\n deleting: false,\n deleteError: undefined,\n confirmDeleteOpen: false,\n accepted: false,\n};\n\n/* One per session: the synchronous guards a double click or two agent calls\n in one tick would race past in React state. Replaced, never reset, so a\n write from an earlier session can tell it is stale. */\ninterface Session {\n subject: string;\n saving: boolean;\n deleting: boolean;\n donePending: boolean;\n accepted: boolean;\n}\n\nexport function aboutOf(task: {\n patientId?: string;\n companyId?: string;\n operatorId?: string;\n}): TaskEditorAbout {\n /* Order matters only for a legacy record that holds two: the platform\n cannot have written one, and the patient is the least surprising\n reading of it. */\n if (task.patientId) return 'patient';\n if (task.companyId) return 'company';\n if (task.operatorId) return 'operator';\n return 'nobody';\n}\n\nfunction timeOf(date: Date): { hours: number; minutes: number } {\n return { hours: date.getHours(), minutes: date.getMinutes() };\n}\n\nfunction blankFields(initialDate: Date | undefined): TaskEditorFields {\n const date = initialDate ?? new Date();\n return {\n date,\n time: timeOf(date),\n note: '',\n operatorId: NONE,\n typeId: '',\n assigneeId: NONE,\n about: 'nobody',\n patientId: '',\n companyId: '',\n };\n}\n\nfunction fieldsOf(task: TaskEditorTask): TaskEditorFields {\n /* An instant: parsed, never sliced. A zone-less value reads as local. */\n const date = new Date(task.dateIso);\n return {\n date,\n time: timeOf(date),\n note: task.note,\n /* `||`, not `??`: a host's '' is unset, like patient and company. */\n operatorId: task.operatorId || NONE,\n /* A stored type wins. With none, '' falls through to the first entry. */\n typeId: task.typeId ?? '',\n /* `||` too: '' would become a Select option with an empty value. */\n assigneeId: task.assigneeId || NONE,\n about: aboutOf(task),\n patientId: task.patientId ?? '',\n companyId: task.companyId ?? '',\n };\n}\n\nconst COUNTERPARTS = [\n ['patientId', 'patient'],\n ['companyId', 'company'],\n ['operatorId', 'operator'],\n] as const;\n\nexport interface UseTaskEditorFormOptions {\n mode: 'create' | 'edit';\n taskId: string | undefined;\n initialDate: Date | undefined;\n /** Panel: always. Subview: while `open`. A false-to-true change starts a\n * fresh session. */\n active: boolean;\n taskTypes: ReadonlyArray<TaskEditorTaskType>;\n assignees: ReadonlyArray<TaskEditorOption>;\n companies: ReadonlyArray<TaskEditorOption>;\n operators: ReadonlyArray<TaskEditorOption>;\n patients: ReadonlyArray<TaskEditorPatient>;\n /** Names the host's search has returned, by id: a patient picked from\n * search stays nameable, and settable by the agent. */\n searchedPatients: ReadonlyMap<string, string>;\n resolvePatientLabel: TaskEditorProps['resolvePatientLabel'];\n loadTask: TaskEditorProps['loadTask'];\n onCreateTask: TaskEditorProps['onCreateTask'];\n onUpdateTask: TaskEditorProps['onUpdateTask'];\n onDeleteTask: TaskEditorProps['onDeleteTask'];\n onSetTaskDone: TaskEditorProps['onSetTaskDone'];\n onSaved: TaskEditorProps['onSaved'];\n onDeleted: TaskEditorProps['onDeleted'];\n readOnly: boolean;\n /** The privacy notice covers an existing task: nothing loads. */\n withheld: boolean;\n /** The patient shows as the mask, so none may be picked. */\n maskPatient: boolean;\n /** Shown when a rejection carries no message of its own. */\n fallbackError: string;\n}\n\nexport function useTaskEditorForm({\n mode,\n taskId,\n initialDate,\n active,\n taskTypes,\n assignees,\n companies,\n operators,\n patients,\n searchedPatients,\n resolvePatientLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onSaved,\n onDeleted,\n readOnly,\n withheld,\n maskPatient,\n fallbackError,\n}: UseTaskEditorFormOptions) {\n const isEdit = mode === 'edit';\n\n /* Each false-to-true change of `active` is a new session. Derived during\n render, so the entering subview already shows the fresh draft. */\n const [session, setSession] = useState(0);\n const [wasActive, setWasActive] = useState(active);\n if (wasActive !== active) {\n setWasActive(active);\n if (active) setSession((previous) => previous + 1);\n }\n const subject = `${mode}|${taskId ?? ''}|${session}`;\n\n const [fields, setFields] = useState<TaskEditorFields>(() =>\n blankFields(initialDate),\n );\n const [ui, setUi] = useState<UiState>(INITIAL_UI);\n /** The record as loaded: what \"the stored link\" means. */\n const [stored, setStored] = useState<TaskEditorTask>();\n const patchUi = (next: Partial<UiState>) =>\n setUi((previous) => ({ ...previous, ...next }));\n const patchFields = (next: Partial<TaskEditorFields>) =>\n setFields((previous) => ({ ...previous, ...next }));\n\n /* A new subject (mode, task or session) starts from a blank draft, which\n reads `initialDate` again. Edit mode then hydrates from the load. */\n const [currentSubject, setCurrentSubject] = useState(subject);\n if (currentSubject !== subject) {\n setCurrentSubject(subject);\n setFields(blankFields(initialDate));\n setUi(INITIAL_UI);\n setStored(undefined);\n }\n const sessionRef = useRef<Session>({\n subject,\n saving: false,\n deleting: false,\n donePending: false,\n accepted: false,\n });\n if (sessionRef.current.subject !== subject) {\n sessionRef.current = {\n subject,\n saving: false,\n deleting: false,\n donePending: false,\n accepted: false,\n };\n }\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n const live = (owner: Session) =>\n mountedRef.current && sessionRef.current === owner;\n\n /* ---- Load ---------------------------------------------------------- */\n /* Read through a ref, never as a dependency: one load per subject, and a\n fresh `loadTask` arrow per render must not re-run it over the user's\n edits. Losing the seam still locks. */\n const loadTaskRef = useRef(loadTask);\n loadTaskRef.current = loadTask;\n const hasLoadTask = Boolean(loadTask);\n const [attempt, setAttempt] = useState(0);\n const [loaded, setLoaded] = useState<{\n subject: string;\n status: 'ready' | 'error';\n message?: string;\n } | null>(null);\n const loadedRef = useRef(loaded);\n loadedRef.current = loaded;\n const canLoad =\n active && isEdit && Boolean(taskId) && hasLoadTask && !withheld;\n\n useEffect(() => {\n const load = loadTaskRef.current;\n if (!canLoad || !taskId || !load) return undefined;\n const owner = sessionRef.current;\n const done = loadedRef.current;\n /* Hydrated already: a privacy toggle or a late list never reloads over\n the draft. */\n if (done?.subject === owner.subject && done.status === 'ready') {\n return undefined;\n }\n const controller = new AbortController();\n Promise.resolve()\n .then(() =>\n /* Cleaned up before this ran (StrictMode's replay, a quick re-run):\n never call the host with a signal already aborted. */\n controller.signal.aborted\n ? Promise.reject(controller.signal.reason)\n : load(taskId, { signal: controller.signal }),\n )\n .then(\n (task) => {\n if (controller.signal.aborted || !live(owner)) return;\n setFields(fieldsOf(task));\n patchUi({ done: task.done, confirmedDone: task.done });\n setStored(task);\n setLoaded({ subject: owner.subject, status: 'ready' });\n },\n (error: unknown) => {\n if (controller.signal.aborted || !live(owner)) return;\n setLoaded({\n subject: owner.subject,\n status: 'error',\n message: getErrorMessage(error, fallbackError),\n });\n },\n );\n /* A superseded answer is ignored: a new task, a closed subview or a\n privacy notice aborts it. */\n return () => controller.abort();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- one load per subject and attempt; see the refs above\n }, [canLoad, subject, attempt]);\n\n /* `locked`: edit mode with no task id, or no seam to resolve it. There\n is no confirmed record to show, so the form must never render blank\n and savable, which would overwrite the real task on Save. */\n const status: TaskEditorStatus = !isEdit\n ? 'ready'\n : !taskId || !hasLoadTask\n ? 'locked'\n : withheld\n ? 'withheld'\n : loaded?.subject === subject\n ? loaded.status\n : 'loading';\n\n const retry = () => {\n if (status !== 'error') return;\n setLoaded(null);\n setAttempt((previous) => previous + 1);\n };\n\n /* ---- Derived ------------------------------------------------------- */\n /* Derived, not stored: a host whose `taskTypes` arrive late still gets\n the required field defaulted to the first entry, and a host with no\n list keeps whatever was loaded. */\n const chosenTypeId = fields.typeId || (taskTypes[0]?.id ?? '');\n /* A chosen branch needs a real id, or Save would send no counterpart\n and silently unlink the task. Nobody is the only empty choice. */\n const counterpartChosen =\n fields.about === 'nobody' ||\n (fields.about === 'patient' && fields.patientId !== '') ||\n (fields.about === 'company' && fields.companyId !== '') ||\n (fields.about === 'operator' && fields.operatorId !== NONE);\n /* `!donePending`: a Done toggle in flight is not confirmed yet, and the\n draft sends the confirmed value. Saving now would discard the toggle\n once it lands. */\n const canSave =\n !readOnly &&\n fields.note.trim() !== '' &&\n fields.date !== undefined &&\n counterpartChosen &&\n /* Required whenever the host offers a list. */\n (taskTypes.length === 0 || chosenTypeId !== '') &&\n !ui.saving &&\n !ui.donePending;\n const saveSeam = isEdit ? onUpdateTask : onCreateTask;\n\n const buildDraft = (): TaskEditorDraft | undefined => {\n const { date, time } = fields;\n if (!date) return undefined;\n const dateIso = new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n time.hours,\n time.minutes,\n 0,\n 0,\n ).toISOString();\n return {\n dateIso,\n note: fields.note.trim(),\n /* Sent whatever the host's list says, including a value the list no\n longer resolves: a real link must survive a Save that never\n offered to change it. */\n typeId: chosenTypeId === '' ? undefined : chosenTypeId,\n assigneeId: fields.assigneeId === NONE ? undefined : fields.assigneeId,\n /* ONE counterpart, decided by `about` alone: the platform refuses a\n task carrying two. Never gated on a list being loaded, or a list\n that empties mid-edit would unlink the task on Save. */\n patientId:\n fields.about === 'patient' && fields.patientId\n ? fields.patientId\n : undefined,\n companyId:\n fields.about === 'company' && fields.companyId\n ? fields.companyId\n : undefined,\n operatorId:\n fields.about === 'operator' && fields.operatorId !== NONE\n ? fields.operatorId\n : undefined,\n /* The last CONFIRMED value only, never an optimistic or rolled-back\n toggle. */\n done: ui.confirmedDone,\n };\n };\n\n const refuse = (reason: string) =>\n handledRejection(new Error(`TaskEditor: ${reason}`));\n\n /* ---- Writes -------------------------------------------------------- */\n /* Each returns the host's promise, marked handled so a click that\n ignores it raises no warning. It resolves only once the write lands. */\n const submit = (): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready') return refuse(`cannot save while ${status}.`);\n if (!saveSeam) return refuse('the host gave no save seam.');\n if (owner.accepted) return refuse('this task was already saved.');\n if (owner.deleting) return refuse('a delete is in flight.');\n if (owner.saving || !canSave) return refuse('the task cannot be saved.');\n const draft = buildDraft();\n if (!draft) {\n patchUi({ showError: true });\n return refuse('the task has no date.');\n }\n const id = taskId;\n owner.saving = true;\n patchUi({ saving: true, saveError: undefined });\n const write = (async () => {\n try {\n if (isEdit) {\n await onUpdateTask?.(id as string, draft);\n /* Only once the promise resolves: a rejection leaves the form\n open and resubmittable. */\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true });\n onSaved?.({\n ...draft,\n id: id as string,\n done: draft.done ?? false,\n });\n }\n } else {\n const created = await onCreateTask?.(draft);\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true });\n if (created) onSaved?.(created);\n }\n }\n } catch (error) {\n if (live(owner)) {\n patchUi({ saveError: getErrorMessage(error, fallbackError) });\n }\n throw error;\n } finally {\n owner.saving = false;\n if (live(owner)) patchUi({ saving: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n const setDone = (next: boolean): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready')\n return refuse(`cannot change Done while ${status}.`);\n if (!isEdit || !taskId || !onSetTaskDone || readOnly) {\n return refuse('the host gave no Done seam.');\n }\n if (owner.donePending) return refuse('a Done change is already pending.');\n /* A Save in flight re-sends the whole record with the done value it\n captured, so a toggle now would be undone when it lands. */\n if (owner.saving || owner.deleting) {\n return refuse('a save or delete is in flight.');\n }\n if (owner.accepted)\n return refuse('this task was already saved or deleted.');\n if (next === ui.done) return Promise.resolve();\n const previous = ui.confirmedDone;\n const id = taskId;\n owner.donePending = true;\n patchUi({ done: next, donePending: true, doneError: undefined });\n const write = (async () => {\n try {\n await onSetTaskDone(id, next);\n if (live(owner)) patchUi({ confirmedDone: next });\n } catch (error) {\n if (live(owner)) {\n /* Back to the last CONFIRMED value, not just `!next`: a second\n failure in a row must not compound on an unconfirmed one. */\n patchUi({\n done: previous,\n doneError: getErrorMessage(error, fallbackError),\n });\n }\n throw error;\n } finally {\n owner.donePending = false;\n if (live(owner)) patchUi({ donePending: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n const remove = (): Promise<void> => {\n const owner = sessionRef.current;\n if (status !== 'ready') return refuse(`cannot delete while ${status}.`);\n if (!isEdit || !taskId || !onDeleteTask || readOnly) {\n return refuse('the host gave no delete seam.');\n }\n if (owner.saving || owner.accepted || owner.deleting) {\n return refuse('the task cannot be deleted now.');\n }\n const id = taskId;\n owner.deleting = true;\n patchUi({ deleting: true, deleteError: undefined });\n const write = (async () => {\n try {\n await onDeleteTask(id);\n /* Only once the write is confirmed: a rejected delete keeps the\n dialog open with its error, and the form unlocked. */\n owner.accepted = true;\n if (live(owner)) {\n patchUi({ accepted: true, confirmDeleteOpen: false });\n onDeleted?.(id);\n }\n } catch (error) {\n if (live(owner)) {\n patchUi({ deleteError: getErrorMessage(error, fallbackError) });\n }\n throw error;\n } finally {\n owner.deleting = false;\n if (live(owner)) patchUi({ deleting: false });\n }\n })();\n write.catch(() => undefined);\n return write;\n };\n\n /* ---- Agent --------------------------------------------------------- */\n const knows = (\n list: ReadonlyArray<{ id: string }>,\n id: string,\n storedId: string | undefined,\n ) =>\n /* '' is never an id, even when the stored record holds one. */\n id !== '' && (id === storedId || list.some((entry) => entry.id === id));\n\n /** The agent's `set_fields`: validated, then applied as one patch. */\n const applyPatch = (patch: TaskEditorFieldPatch): void => {\n if (status !== 'ready') {\n throw new Error(`TaskEditor: cannot set fields while ${status}.`);\n }\n if (readOnly) throw new Error('TaskEditor: the task is read-only.');\n const chosen = COUNTERPARTS.filter(([key]) => patch[key] !== undefined);\n if (chosen.length > 1) {\n throw new Error(\n 'TaskEditor: set at most one of patientId, companyId and operatorId.',\n );\n }\n const branch = chosen[0]?.[1];\n if (patch.about !== undefined && branch && patch.about !== branch) {\n throw new Error(\n `TaskEditor: about \"${patch.about}\" does not match the ${branch} id.`,\n );\n }\n if (\n patch.typeId !== undefined &&\n !knows(taskTypes, patch.typeId, stored?.typeId)\n ) {\n throw new Error(`TaskEditor: unknown typeId \"${patch.typeId}\".`);\n }\n if (\n patch.assigneeId !== undefined &&\n patch.assigneeId !== null &&\n !knows(assignees, patch.assigneeId, stored?.assigneeId)\n ) {\n throw new Error(`TaskEditor: unknown assigneeId \"${patch.assigneeId}\".`);\n }\n if (\n patch.companyId !== undefined &&\n !knows(companies, patch.companyId, stored?.companyId)\n ) {\n throw new Error(`TaskEditor: unknown companyId \"${patch.companyId}\".`);\n }\n if (\n patch.operatorId !== undefined &&\n !knows(operators, patch.operatorId, stored?.operatorId)\n ) {\n throw new Error(`TaskEditor: unknown operatorId \"${patch.operatorId}\".`);\n }\n if (patch.patientId !== undefined) {\n if (maskPatient) {\n throw new Error('TaskEditor: no patient can be set in privacy mode.');\n }\n const resolvable =\n knows(patients, patch.patientId, stored?.patientId) ||\n searchedPatients.has(patch.patientId) ||\n resolvePatientLabel?.(patch.patientId) !== undefined;\n if (!resolvable) {\n throw new Error(`TaskEditor: unknown patientId \"${patch.patientId}\".`);\n }\n }\n const next: Partial<TaskEditorFields> = {};\n if (patch.dateIso !== undefined) {\n const date = new Date(patch.dateIso);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`TaskEditor: \"${patch.dateIso}\" is not a date.`);\n }\n next.date = date;\n next.time = timeOf(date);\n }\n if (patch.note !== undefined) next.note = patch.note;\n if (patch.typeId !== undefined) next.typeId = patch.typeId;\n if (patch.assigneeId !== undefined) {\n next.assigneeId = patch.assigneeId ?? NONE;\n }\n if (patch.about !== undefined) next.about = patch.about;\n if (patch.patientId !== undefined) {\n next.patientId = patch.patientId;\n next.about = 'patient';\n }\n if (patch.companyId !== undefined) {\n next.companyId = patch.companyId;\n next.about = 'company';\n }\n if (patch.operatorId !== undefined) {\n next.operatorId = patch.operatorId;\n next.about = 'operator';\n }\n patchFields(next);\n };\n\n /** Identifiers and structure only, never the note body. */\n const draftState = (): TaskEditorDraftState => {\n const draft = buildDraft();\n return {\n mode,\n dateIso: draft?.dateIso ?? null,\n about: fields.about,\n patientId: draft?.patientId ?? null,\n companyId: draft?.companyId ?? null,\n operatorId: draft?.operatorId ?? null,\n typeId: draft?.typeId ?? null,\n assigneeId: draft?.assigneeId ?? null,\n done: ui.confirmedDone,\n hasNote: fields.note.trim() !== '',\n noteLength: fields.note.trim().length,\n };\n };\n\n return {\n status,\n loadError: loaded?.subject === subject ? loaded.message : undefined,\n retry,\n fields,\n patchFields,\n stored,\n chosenTypeId,\n canSave,\n /** What the agent's `canSave` reports: the button's rule plus the\n * status, the seam and a save that has not landed yet. */\n agentCanSave:\n status === 'ready' && Boolean(saveSeam) && canSave && !ui.accepted,\n showSave: !readOnly && Boolean(saveSeam),\n showDelete: isEdit && !readOnly && Boolean(onDeleteTask) && Boolean(taskId),\n showDone: isEdit && !readOnly && Boolean(onSetTaskDone),\n ui,\n patchUi,\n /** True once a save or delete landed in this session. */\n isAccepted: () => sessionRef.current.accepted,\n /** A save or delete is in flight: closing now would lose its outcome. */\n isBusy: () => sessionRef.current.saving || sessionRef.current.deleting,\n submit,\n setDone,\n remove,\n applyPatch,\n draftState,\n };\n}\n\nexport type TaskEditorForm = ReturnType<typeof useTaskEditorForm>;\n","/**\n * TaskEditor: the published form for one task (platform `DoctorReminder`).\n * It creates, edits, completes and deletes a task through host seams, and\n * takes every list, label and seam as a prop, so a host builds it without\n * any calendar context. The calendar's own task route renders it through a\n * thin adapter.\n *\n * A note is the only field every host needs, beside ONE optional\n * counterpart: a patient, a company or an operator, never two, because the\n * platform refuses a task with \"More than one counterpart is set\". A host\n * that supplies `taskTypes` also gets a required Type select, and one that\n * supplies `assignees` an optional \"Assigned to\" (a practice user, not the\n * operator). A missing list or seam WITHHOLDS the control it backs; it never\n * renders that control disabled.\n *\n * Two layouts: `variant=\"panel\"` fills a rail tool panel with its own header,\n * scroll body and pinned footer; `variant=\"subview\"` IS a PanelSubview, for a\n * form stacked over a list such as TasksPanel.\n *\n * DOM hooks: `data-component=\"task-editor\"` with `data-variant`,\n * `data-status` and `data-component-id`; the footer actions carry\n * `data-action` \"cancel-task\", \"save-task\" and \"delete-task\", and a failed\n * load's Retry carries \"retry-load\". In the subview the marker sits on the\n * body, so the PanelSubview section repeats `data-component-id`,\n * `data-variant` and `data-status`: `[data-component-id=\"…\"]` reaches the\n * heading and the footer in both variants.\n */\nimport {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n Building2,\n CircleOff,\n LoaderCircle,\n Lock,\n Save as SaveIcon,\n SquareCheckBig,\n Stethoscope,\n Trash2,\n User,\n X,\n} from 'lucide-react';\nimport { Alert } from '../alert';\nimport { Button, IconButton } from '../button';\nimport { Combobox } from '../combobox';\nimport { Dialog } from '../dialog';\nimport { DatePicker } from '../date-picker';\nimport { FormField } from '../form-field';\nimport { IconButtonGroup } from '../icon-button-group';\nimport { PanelHeader } from '../panel-header';\nimport { PanelSubview } from '../panel-subview';\nimport { Radio, RadioGroup } from '../radio-group';\nimport { ScrollArea } from '../scroll-area';\nimport { Select } from '../select';\nimport { Skeleton } from '../skeleton';\nimport { Switch } from '../switch';\nimport { TextArea } from '../text-area';\nimport { TextInput } from '../text-input';\nimport { TimePicker } from '../time-picker';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\nimport { composeRefs } from '../_shared/compose-refs';\nimport {\n EDITOR_COMPACT_FIELDS_CLASS,\n EDITOR_COMPACT_SEGMENTED_CLASS,\n} from '../_shared/compact-editor-fields';\nimport type { PatientIdentity } from '../_shared/patient-identity';\nimport { PatientPicker, type PatientSearch } from '../_shared/patient-picker';\nimport { PrivacyNotice, privacyMask } from '../_shared/privacy-mask';\nimport { taskEditorAgent } from './task-editor.agent';\nimport { NONE, useTaskEditorForm } from './use-task-editor-form';\n\n/* -------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------- */\n\n/**\n * A task as the editor loads and saves it: platform `DoctorReminder`. At\n * most ONE counterpart (patient, company or operator); the platform refuses\n * a task naming two. `note` is required here though the platform allows an\n * empty one. There is no title, priority or duration: the platform has none.\n */\nexport interface TaskEditorTask {\n id: string;\n /** An instant as ISO 8601 (platform `date`). The editor emits\n * `toISOString()`, so UTC with a `Z`. Parse it with `new Date()`, never by\n * slicing; a zone-less value reads as local time. */\n dateIso: string;\n /** The task text (platform `note`). Required here, though the platform\n * allows an empty one. Never exposed through the agent. */\n note: string;\n /** The clinician the task concerns: platform `doctorOperator`, an id from\n * `operators`. NOT the assignee. Exclusive with `patientId` and\n * `companyId`. */\n operatorId?: string;\n /** The patient the task concerns: platform `doctorPatient` (column\n * `patientId`). Exclusive with `companyId` and `operatorId`. */\n patientId?: string;\n /** Platform `doctorCompany`, an id from `companies`. Exclusive with\n * `patientId` and `operatorId`. */\n companyId?: string;\n /** An opaque token from `taskTypes`, round-tripped untouched. Without\n * `taskTypes` the Type field is withheld and a new task sends none; a\n * stored one is still re-sent. */\n typeId?: string;\n /** The practice USER the task is assigned to: platform `practiceUser`, an\n * id from `assignees`. Independent of the counterpart. Absent or '':\n * nobody. */\n assigneeId?: string;\n /** Platform `done`. */\n done: boolean;\n}\n\n/** What `onCreateTask` receives and what an edit save re-sends IN FULL,\n * never a patch. `done` carries the last value the host CONFIRMED, never an\n * optimistic or rolled-back toggle. */\nexport type TaskEditorDraft = Omit<TaskEditorTask, 'id' | 'done'> & {\n done?: boolean;\n};\n\n/** One row of a host list. `label` is the host's own string, already\n * translated. `id` is opaque, unique in its list, never '' and never\n * 'none' (reserved for \"Nobody\"). */\nexport interface TaskEditorOption {\n id: string;\n label: string;\n}\n\n/** A task type. `custom` (practice-defined) only groups the Type select,\n * and only when the list mixes custom and standard types. */\nexport interface TaskEditorTaskType extends TaskEditorOption {\n custom?: boolean;\n}\n\n/** A patient as the picker needs one: an id and a display name.\n * `CalendarPatient` satisfies it. */\nexport type TaskEditorPatient = PatientIdentity;\n\n/** Host patient typeahead. Called 250 ms after typing stops, for non-blank\n * trimmed queries only. Abort a superseded call through `signal`. The\n * host's order is kept, so matches by phone or number stay. Reject on\n * failure (the picker offers Retry); `[]` is a successful search with no\n * match. The same contract as `CalendarData.searchPatients`. */\nexport type TaskEditorSearchPatients = (\n query: string,\n options: { signal: AbortSignal },\n) => Promise<readonly TaskEditorPatient[]>;\n\n/** Where the form is. 'error': the load failed, with Retry. 'locked': edit\n * mode without `taskId` or `loadTask`, never a blank savable form.\n * 'withheld': the privacy notice covers an existing task. */\nexport type TaskEditorStatus =\n | 'loading'\n | 'ready'\n | 'error'\n | 'locked'\n | 'withheld';\n\n/** The one counterpart choice (\"Concerns\"). */\nexport type TaskEditorAbout = 'nobody' | 'patient' | 'company' | 'operator';\n\n/** The draft as the agent reads it: identifiers and structure, never the\n * note body. Counterpart ids are what Save would send. */\nexport interface TaskEditorDraftState {\n mode: 'create' | 'edit';\n dateIso: string | null;\n about: TaskEditorAbout;\n patientId: string | null;\n companyId: string | null;\n operatorId: string | null;\n typeId: string | null;\n assigneeId: string | null;\n /** The last CONFIRMED done value. */\n done: boolean;\n hasNote: boolean;\n noteLength: number;\n}\n\n/** Fields an agent may set. Ids must resolve in the host lists, among the\n * patients the host's search returned, or equal the stored one. At most\n * one of `patientId`, `companyId` and `operatorId` per call; each also\n * selects its `about` branch. `assigneeId: null` is Nobody. */\nexport interface TaskEditorFieldPatch {\n dateIso?: string;\n note?: string;\n typeId?: string;\n assigneeId?: string | null;\n about?: TaskEditorAbout;\n patientId?: string;\n companyId?: string;\n operatorId?: string;\n}\n\n/** Curated agent handle. Writes return the host's promise, so a refusal\n * reaches the agent as a rejection. Every write fails unless the status is\n * 'ready' and the form is not read-only. */\nexport interface TaskEditorHandle {\n getStatus: () => TaskEditorStatus;\n getDraft: () => TaskEditorDraftState;\n canSave: () => boolean;\n /** Throws on an unknown id, two counterparts or a form not ready. */\n setFields: (patch: TaskEditorFieldPatch) => void;\n save: () => Promise<void>;\n setDone: (done: boolean) => Promise<void>;\n /** Skips the confirmation dialog: the agent runtime confirms instead. */\n deleteTask: () => Promise<void>;\n /** Throws while a save or delete is in flight, as Cancel waits. */\n cancel: () => void;\n}\n\nexport interface TaskEditorProps extends Omit<\n HTMLAttributes<HTMLElement>,\n 'children' | 'id' | 'title'\n> {\n /** Stable instance id, surfaced as `data-component-id` for the agent\n * registry. Generated when absent. */\n id?: string;\n mode: 'create' | 'edit';\n /** Edit mode: the task `loadTask` resolves. Without it, or without\n * `loadTask`, edit mode is 'locked'. */\n taskId?: string;\n /** Create mode: the local date and time to prefill. Read at mount, when\n * the mode or task changes and at each subview reopen. Default: now. */\n initialDate?: Date;\n /** 'panel' (default): fills its box with its own header, scroll body and\n * pinned footer, for a rail tool panel. 'subview': the editor IS a\n * PanelSubview; render it as the LAST, DIRECT child of a\n * `PanelSubview.Host`. */\n variant?: 'panel' | 'subview';\n /** Subview only. Default true. Each change from false to true starts a\n * fresh session: the draft resets and edit mode reloads. Keep one editor\n * mounted and toggle this, so it slides in and returns focus. */\n open?: boolean;\n /** Subview only: fires once the exit has played. */\n onExited?: () => void;\n\n /* Host lists. Absent or [] WITHHOLDS the field it backs. */\n /** The required Type select, defaulting to the first entry. */\n taskTypes?: ReadonlyArray<TaskEditorTaskType>;\n /** The optional \"Assigned to\" select: practice users, not operators. */\n assignees?: ReadonlyArray<TaskEditorOption>;\n /** The Company counterpart: a searchable Combobox matching the label,\n * never the id. */\n companies?: ReadonlyArray<TaskEditorOption>;\n /** The Operator counterpart: clinicians. */\n operators?: ReadonlyArray<TaskEditorOption>;\n /** Filtered on the client when `searchPatients` is absent. With neither,\n * the Patient counterpart is withheld; a stored link still shows\n * read-only and is re-sent on Save. */\n patients?: ReadonlyArray<TaskEditorPatient>;\n /** Host typeahead. Wins over `patients` for listing. May change identity\n * between renders; the next query uses the latest. */\n searchPatients?: TaskEditorSearchPatients;\n /** Display name of the task's STORED patient when nothing else resolves\n * it, for example from the TasksPanel row that opened the form. */\n patientLabel?: string;\n /** Resolves any patient id to a name. Tried before `patients` and\n * `patientLabel`. */\n resolvePatientLabel?: (patientId: string) => string | undefined;\n /** Display name of a STORED company that `companies` does not list.\n * Without it the read-only row names the id. */\n companyLabel?: string;\n /** Display name of a STORED operator that `operators` does not list.\n * Without it the row names the id. Each of the three labels names only\n * its own stored link, so a host may pass a TasksPanel row's\n * `linkedLabel` to the one its `linkType` names. */\n operatorLabel?: string;\n /** Subview only: the back arrow's name and tooltip. Already translated.\n * Default \"Back to tasks\". */\n backLabel?: string;\n\n /* Seams. An absent seam WITHHOLDS its control (Save, Delete, Done). Each\n resolves only once the write has landed; reject with a translated\n message and the form shows it. */\n /** Resolves the record for edit mode, once per task and session. Aborted\n * through `signal` when the task changes, the subview closes or the\n * privacy notice covers the form; a superseded answer is ignored. */\n loadTask?: (\n id: string,\n options: { signal: AbortSignal },\n ) => Promise<TaskEditorTask>;\n /** Must resolve WITH the saved record: the host assigns the id. */\n onCreateTask?: (draft: TaskEditorDraft) => Promise<TaskEditorTask>;\n /** A full re-send. Resolves with nothing. */\n onUpdateTask?: (id: string, draft: TaskEditorDraft) => Promise<void>;\n /** Called only after the confirmation dialog. */\n onDeleteTask?: (id: string) => Promise<void>;\n /** The Done switch (edit mode), called on the click. A rejection rolls\n * the switch back. */\n onSetTaskDone?: (id: string, done: boolean) => Promise<void>;\n\n /* Outcomes. */\n /** Cancel, plus Back and Escape in the subview. Close the editor. None of\n * them fires while a save or delete is in flight. */\n onCancel: () => void;\n /** After a create or update LANDS. The form then stops writing until it\n * is closed, remounted or reopened. The form cannot be cancelled while a\n * write is in flight, so this fires for every save the user started,\n * unless the host closes or unmounts the editor itself first. */\n onSaved?: (task: TaskEditorTask) => void;\n /** After a delete LANDS. */\n onDeleted?: (id: string) => void;\n\n /* Modes. */\n /** Withholds every write control and disables the fieldset. */\n readOnly?: boolean;\n /** Privacy mode: the linked patient shows as the mask, never the name. */\n privacy?: boolean;\n /** How an EXISTING task opens under `privacy`. 'notice' (default): the\n * privacy notice covers the form, the record is not loaded, and the\n * footer holds Cancel only. 'mask': the form opens with the patient\n * masked and the note visible. Create mode always opens masked. */\n privacyMode?: 'notice' | 'mask';\n /** The notice's \"Turn off privacy mode\" action. Absent: no button. */\n onPrivacyOff?: () => void;\n}\n\n/* -------------------------------------------------------------------- */\n/* Variants */\n/* -------------------------------------------------------------------- */\n\nconst taskEditorVariants = cva('ds:flex ds:min-h-0 ds:flex-col', {\n variants: {\n /** The panel fills its box; the subview body sits in its scroll area. */\n variant: {\n /* Focusable from script only, as the subview section is: where focus\n waits when a control takes itself away. */\n panel: 'ds:h-full ds:focus-visible:outline-none',\n /* The states pad themselves, so the subview's ring inset is cancelled. */\n subview: 'ds:-m-[var(--panel-subview-inset)]',\n },\n },\n defaultVariants: { variant: 'panel' },\n});\n\n/* `min-w-0`: a fieldset keeps the browser's min-content width, so the\n Concerns segments would hold it wider than the rail and never collapse. */\nconst fieldsetVariants = cva(\n `ds:m-0 ds:min-w-0 ds:border-0 ds:p-[var(--spacing-md)] ${EDITOR_COMPACT_FIELDS_CLASS}`,\n {\n variants: {\n /** 'form': the fields in a column. 'notice': the locked notice. */\n layout: {\n form: 'ds:flex ds:flex-col ds:gap-[var(--spacing-md)]',\n notice: 'ds:flex-1',\n },\n },\n defaultVariants: { layout: 'form' },\n },\n);\n\nconst key = (suffix: string): string =>\n `calendarWorkspace.taskEditor.${suffix}`;\n\n/** Matches the company name only, never its id, and keeps the host's\n * order. Both sides arrive diacritics-stripped and lower-cased. */\nconst companyFilter = (_value: string, search: string, label: string) =>\n label.includes(search) ? 1 : 0;\n\nconst EMPTY: ReadonlyArray<never> = [];\n\n/** The list's task rows under the Host, never inside the subview itself. */\nconst rowsIn = (host: HTMLElement, subview: HTMLElement): HTMLElement[] =>\n Array.from(host.querySelectorAll<HTMLElement>('[data-task-id]')).filter(\n (row) => !subview.contains(row),\n );\n\nconst FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Where focus may go in a row, best first: the control that opened the\n * editor, the row's open-task activator, then any focusable control. */\nconst controlsIn = (\n row: HTMLElement | undefined,\n action: string | undefined,\n): HTMLElement[] => {\n if (!row) return [];\n const actions = Array.from(\n row.querySelectorAll<HTMLElement>('[data-action]'),\n );\n return [\n ...actions.filter((el) => action && el.dataset.action === action),\n ...actions.filter((el) => el.dataset.action === 'open-task'),\n ...Array.from(row.querySelectorAll<HTMLElement>(FOCUSABLE)),\n ];\n};\n\n/* -------------------------------------------------------------------- */\n/* TaskEditor */\n/* -------------------------------------------------------------------- */\n\nexport const TaskEditor = forwardRef<HTMLElement, TaskEditorProps>(\n (\n {\n id,\n mode,\n taskId,\n initialDate,\n variant = 'panel',\n open = true,\n onExited,\n taskTypes = EMPTY,\n assignees = EMPTY,\n companies = EMPTY,\n operators = EMPTY,\n patients = EMPTY,\n searchPatients,\n patientLabel,\n resolvePatientLabel,\n companyLabel,\n operatorLabel,\n backLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onCancel,\n onSaved,\n onDeleted,\n readOnly = false,\n privacy = false,\n privacyMode = 'notice',\n onPrivacyOff,\n className,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation('ui');\n const reactId = useId();\n const instanceId = id ?? reactId;\n const isEdit = mode === 'edit';\n const isSubview = variant === 'subview';\n const active = !isSubview || open;\n /* The notice covers an EXISTING task only; a new one has no stored\n patient to reveal, so create mode opens masked. */\n const withheld = privacy && isEdit && privacyMode === 'notice';\n const maskPatient = privacy && !withheld;\n\n /* Every patient the host's search returned, by id. The picker forgets\n its pick when it unmounts (a switch to Company and back), and a\n search-only host has no list to name it from. */\n const [searched] = useState(() => new Map<string, string>());\n\n const form = useTaskEditorForm({\n mode,\n taskId,\n initialDate,\n active,\n taskTypes,\n assignees,\n companies,\n operators,\n patients,\n searchedPatients: searched,\n resolvePatientLabel,\n loadTask,\n onCreateTask,\n onUpdateTask,\n onDeleteTask,\n onSetTaskDone,\n onSaved,\n onDeleted,\n readOnly,\n withheld,\n maskPatient,\n fallbackError: t('emptyState.error.title'),\n });\n const { status, fields, ui, stored } = form;\n\n /* A stable search seam: a host's inline arrow must not restart the\n picker's debounce on every render. */\n const searchRef = useRef(searchPatients);\n searchRef.current = searchPatients;\n const hasSearch = Boolean(searchPatients);\n const search = useMemo<PatientSearch | undefined>(\n () =>\n hasSearch\n ? async (query, options) => {\n const found = await (\n searchRef.current as TaskEditorSearchPatients\n )(query, options);\n for (const patient of found) {\n searched.set(patient.id, patient.name);\n }\n return found;\n }\n : undefined,\n [hasSearch, searched],\n );\n\n /* ---- Agent handle ------------------------------------------------ */\n const formRef = useRef(form);\n formRef.current = form;\n const onCancelRef = useRef(onCancel);\n onCancelRef.current = onCancel;\n const handle = useMemo<TaskEditorHandle>(\n () => ({\n getStatus: () => formRef.current.status,\n getDraft: () => formRef.current.draftState(),\n canSave: () => formRef.current.agentCanSave,\n setFields: (patch) => formRef.current.applyPatch(patch),\n save: () => formRef.current.submit(),\n setDone: (next) => formRef.current.setDone(next),\n deleteTask: () => formRef.current.remove(),\n cancel: () => {\n if (formRef.current.isBusy()) {\n throw new Error('TaskEditor: a save or delete is in flight.');\n }\n onCancelRef.current();\n },\n }),\n [],\n );\n /* A closed subview is not an instance an agent can drive. */\n useAgentRegistration(taskEditorAgent, active ? handle : null, instanceId);\n const localRoot = useRef<HTMLElement | null>(null);\n const rootRef = useMemo(\n () => composeRefs<HTMLElement>(ref, localRoot),\n [ref],\n );\n const deleteButtonRef = useRef<HTMLButtonElement>(null);\n\n /* ---- Focus after Back ------------------------------------------- */\n /* PanelSubview hands focus back to its opener only while the opener\n exists. A row the host reloaded away meanwhile (a task marked done,\n say) needs the nearest surviving one, as TasksPanel's own rescue. */\n const openerRef = useRef<HTMLElement | null>(null);\n const subviewOpenRef = useRef(false);\n if (isSubview && open && !subviewOpenRef.current) {\n /* Recorded while rendering the opening pass, before focus moves. */\n openerRef.current =\n typeof document !== 'undefined' &&\n document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n }\n subviewOpenRef.current = isSubview && open;\n const openRef = useRef(open);\n openRef.current = open;\n const editedTaskRef = useRef(taskId);\n editedTaskRef.current = isEdit ? taskId : undefined;\n\n useEffect(() => {\n const section = localRoot.current;\n const host = section?.parentElement;\n if (!isSubview || !open || !section || !host) return undefined;\n const opener = openerRef.current;\n const fromList =\n opener && host.contains(opener) && !section.contains(opener)\n ? opener\n : null;\n /* A click on a row may leave focus nowhere: use the edited task's. */\n const edited = editedTaskRef.current;\n const row =\n fromList?.closest<HTMLElement>('[data-task-id]') ??\n rowsIn(host, section).find((r) => r.dataset.taskId === edited);\n const rowId = row?.dataset.taskId;\n const action =\n fromList?.closest<HTMLElement>('[data-action]')?.dataset.action;\n const index = row ? rowsIn(host, section).indexOf(row) : -1;\n return () => {\n /* StrictMode replays this cleanup while the subview is still open. */\n if (openRef.current && section.isConnected) return;\n /* Runs after PanelSubview's own return: act only if focus was lost. */\n const lost = document.activeElement;\n if (!host.isConnected || (lost && lost !== document.body)) return;\n const rows = rowsIn(host, section);\n const candidates = [\n ...controlsIn(\n rows.find((r) => rowId !== undefined && r.dataset.taskId === rowId),\n action,\n ),\n /* The row that took its place, or the last row when it was last. */\n ...(index >= 0\n ? controlsIn(rows[Math.min(index, rows.length - 1)], action)\n : []),\n host.querySelector<HTMLElement>('[data-action=\"add-task\"]'),\n host.querySelector<HTMLElement>('[data-tasks-panel-region]'),\n ];\n for (const candidate of candidates) {\n if (!candidate || section.contains(candidate)) continue;\n candidate.focus();\n if (document.activeElement === candidate) return;\n }\n };\n }, [open, isSubview]);\n\n /* ---- Focus after Retry or Turn off ------------------------------ */\n /* Both buttons leave with the state they belong to. Focus waits on the\n editor's root while the task loads, then on a new Retry if it fails. */\n const retryRef = useRef<HTMLButtonElement>(null);\n const rescueRef = useRef(false);\n const rescuing = (run: () => void) => () => {\n rescueRef.current = true;\n run();\n };\n useIsomorphicLayoutEffect(() => {\n if (!rescueRef.current) return;\n const root = localRoot.current;\n const active = document.activeElement;\n /* Focus the user put somewhere else stays there. */\n if (active && active !== document.body && active !== root) {\n rescueRef.current = false;\n return;\n }\n if (status !== 'loading') rescueRef.current = false;\n (status === 'error' ? retryRef.current : root)?.focus({\n preventScroll: true,\n });\n }, [status]);\n\n /* ---- Labels and options ------------------------------------------ */\n const title = t(key(isEdit ? 'editTitle' : 'title'));\n const hasCompanies = companies.length > 0;\n const hasOperators = operators.length > 0;\n const hasPatientSource = hasSearch || patients.length > 0;\n const companyOptions = useMemo(\n () => companies.map((c) => ({ value: c.id, label: c.label })),\n [companies],\n );\n const patientName = (patientId: string): string =>\n resolvePatientLabel?.(patientId) ??\n patients.find((p) => p.id === patientId)?.name ??\n searched.get(patientId) ??\n (patientId === stored?.patientId ? patientLabel : undefined) ??\n t('calendarWorkspace.details.patientNotLoaded');\n const unresolvedOperatorLabel = (operatorId: string): string =>\n operatorId === stored?.operatorId && operatorLabel\n ? operatorLabel\n : t(key('operatorUnresolved'), { id: operatorId });\n\n const operatorOptions = [\n { value: NONE, label: t(key('operatorNone')) },\n ...operators.map((o) => ({ value: o.id, label: o.label })),\n /* An operator the roster no longer lists is still a real link, so it\n stays pickable and survives a Save. */\n ...(fields.operatorId !== NONE &&\n !operators.some((o) => o.id === fields.operatorId)\n ? [\n {\n value: fields.operatorId,\n label: unresolvedOperatorLabel(fields.operatorId),\n },\n ]\n : []),\n ];\n /* Grouped only when the host mixes standard and practice-defined\n types: a lone \"Standard\" heading over every option is noise. */\n const groupTypes =\n taskTypes.some((type) => type.custom) &&\n taskTypes.some((type) => !type.custom);\n const typeOptions = [\n ...taskTypes.map((type) => ({\n value: type.id,\n label: type.label,\n group: groupTypes\n ? t(key(type.custom ? 'typeGroupCustom' : 'typeGroupStandard'))\n : undefined,\n })),\n /* An id the list no longer resolves is still a real link: offered as\n its own option so Save re-sends it. */\n ...(form.chosenTypeId &&\n !taskTypes.some((type) => type.id === form.chosenTypeId)\n ? [\n {\n value: form.chosenTypeId,\n label: t(key('typeUnresolved'), { id: form.chosenTypeId }),\n },\n ]\n : []),\n ];\n const assigneeOptions = [\n { value: NONE, label: t(key('assigneeNone')) },\n ...assignees.map((user) => ({ value: user.id, label: user.label })),\n ...(fields.assigneeId !== NONE &&\n !assignees.some((user) => user.id === fields.assigneeId)\n ? [\n {\n value: fields.assigneeId,\n label: t(key('assigneeUnresolved'), { id: fields.assigneeId }),\n },\n ]\n : []),\n ];\n /* A company id the list does not resolve is still a real link: shown\n read-only, and only picking Nobody or a listed company changes it.\n Includes the no-list case. */\n const unresolvedCompanyId =\n fields.about === 'company' &&\n fields.companyId &&\n !companies.some((c) => c.id === fields.companyId)\n ? fields.companyId\n : undefined;\n const unresolvedCompanyLabel =\n unresolvedCompanyId &&\n unresolvedCompanyId === stored?.companyId &&\n companyLabel\n ? companyLabel\n : t(key('companyUnresolved'), { id: unresolvedCompanyId });\n\n /* ---- Pieces ------------------------------------------------------ */\n const readOnlyNotice = (\n <Alert variant=\"info\" announce=\"off\" icon={<Lock aria-hidden=\"true\" />}>\n <Alert.Title as=\"p\">\n {t('calendarWorkspace.details.readOnlyTitle')}\n </Alert.Title>\n <Alert.Description>{t(key('readOnlyBody'))}</Alert.Description>\n </Alert>\n );\n\n /* Cancel, Back and Escape wait for a write in flight, as the\n appointment description does: closing now would hide a refusal and,\n after a reopen, drop `onSaved`. */\n const busy = ui.saving || ui.deleting;\n const requestCancel = () => {\n if (!form.isBusy()) onCancel();\n };\n\n const cancelButton = (\n <IconButton\n size=\"sm\"\n intent=\"outline\"\n icon={<X aria-hidden=\"true\" />}\n aria-label={t(key('cancel'))}\n tooltip={t(key('cancel'))}\n data-action=\"cancel-task\"\n disabled={busy}\n onClick={requestCancel}\n />\n );\n /* Save keeps focus while it runs, so it is aria-disabled, not disabled,\n and the status line says why. After a landed save it stays inert. */\n const saveInert = ui.saving || ui.accepted;\n\n /* The appointment editor's footer: one icon-only toolbar, the names on\n aria-label and tooltip, Save at the inline end. */\n const footerFor = (withWrites: boolean): ReactNode => (\n <>\n {withWrites && form.showDelete ? (\n <IconButton\n ref={deleteButtonRef}\n size=\"sm\"\n intent=\"destructiveOutline\"\n icon={<Trash2 aria-hidden=\"true\" />}\n aria-label={t(key('delete'))}\n tooltip={t(key('delete'))}\n data-action=\"delete-task\"\n /* The confirm would be refused mid-save or after a landed\n write, so the trigger waits too. */\n disabled={busy || ui.accepted}\n /* A fresh confirmation: an earlier refusal is not this one. */\n onClick={() =>\n form.patchUi({ confirmDeleteOpen: true, deleteError: undefined })\n }\n />\n ) : null}\n <IconButtonGroup\n role=\"toolbar\"\n aria-label={t(key('actionsLabel'))}\n className=\"ds:ms-auto\"\n >\n {cancelButton}\n {withWrites && form.showSave ? (\n <IconButton\n size=\"sm\"\n intent=\"primary\"\n icon={\n ui.saving ? (\n <LoaderCircle\n aria-hidden=\"true\"\n className=\"ds:animate-spin ds:motion-reduce:animate-none\"\n />\n ) : (\n <SaveIcon aria-hidden=\"true\" />\n )\n }\n aria-label={t(key('save'))}\n tooltip={t(key('save'))}\n disabled={!saveInert && !form.canSave}\n aria-disabled={saveInert || undefined}\n aria-busy={ui.saving || undefined}\n data-action=\"save-task\"\n onClick={() => {\n if (!saveInert) void form.submit();\n }}\n />\n ) : null}\n </IconButtonGroup>\n {withWrites && form.showSave ? (\n /* Out of flow, so it never moves the footer's two ends. */\n <span role=\"status\" className=\"ds:sr-only\">\n {ui.saving ? t(key('saving')) : ''}\n </span>\n ) : null}\n </>\n );\n\n const loadingBody = (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]\">\n {/* Outside the aria-hidden skeletons, so it is announced. */}\n <span role=\"status\" className=\"ds:sr-only\">\n {t('common.loading')}\n </span>\n <div\n aria-hidden=\"true\"\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n >\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) + var(--spacing-sm))\"\n />\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) * 3)\"\n stagger={1}\n />\n <Skeleton\n variant=\"rounded\"\n height=\"calc(var(--spacing-xl) + var(--spacing-sm))\"\n stagger={2}\n />\n </div>\n </div>\n );\n\n const errorBody = (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]\">\n <Alert variant=\"error\">\n <Alert.Description>{form.loadError}</Alert.Description>\n </Alert>\n <Button\n ref={retryRef}\n intent=\"outline\"\n data-action=\"retry-load\"\n onClick={rescuing(form.retry)}\n >\n {t('emptyState.error.cta')}\n </Button>\n </div>\n );\n\n /* Disabled, like the ready state's read-only fieldset: the whole body\n is inert, not merely toned down. */\n const lockedBody = (\n <fieldset disabled className={fieldsetVariants({ layout: 'notice' })}>\n {readOnlyNotice}\n </fieldset>\n );\n\n const patientField = (): ReactNode => {\n if (fields.about !== 'patient') return null;\n if (maskPatient) {\n return (\n <FormField label={t(key('aboutPatient'))}>\n <TextInput value={privacyMask()} disabled readOnly />\n </FormField>\n );\n }\n if (hasPatientSource) {\n return (\n <FormField label={t(key('aboutPatient'))}>\n <PatientPicker\n value={fields.patientId}\n onValueChange={(patientId) => form.patchFields({ patientId })}\n patients={patients}\n searchPatients={search}\n selectedLabel={\n fields.patientId ? patientName(fields.patientId) : undefined\n }\n placeholder={t('calendarWorkspace.editor.patientSearch')}\n disabled={readOnly}\n />\n </FormField>\n );\n }\n /* Nothing to pick from: name the stored link read-only. */\n return fields.patientId ? (\n <FormField label={t(key('aboutPatient'))}>\n <TextInput value={patientName(fields.patientId)} disabled readOnly />\n </FormField>\n ) : null;\n };\n\n const formFields = (\n <fieldset disabled={readOnly} className={fieldsetVariants()}>\n {readOnly ? readOnlyNotice : null}\n <FormField label={t(key('date'))}>\n <DatePicker\n value={fields.date}\n onChange={(date) => form.patchFields({ date })}\n />\n </FormField>\n <FormField label={t(key('time'))}>\n <TimePicker\n value={fields.time}\n onChange={(time) => form.patchFields({ time })}\n />\n </FormField>\n <FormField\n label={t(key('note'))}\n required\n error={\n ui.showError && fields.note.trim() === ''\n ? t(key('noteRequired'))\n : undefined\n }\n >\n <TextArea\n value={fields.note}\n onChange={(e) => {\n form.patchFields({ note: e.target.value });\n form.patchUi({ showError: false });\n }}\n minRows={3}\n autoResize\n />\n </FormField>\n {taskTypes.length > 0 ? (\n <FormField label={t(key('type'))} required>\n <Select\n options={typeOptions}\n value={form.chosenTypeId}\n onValueChange={(v) => v && form.patchFields({ typeId: v })}\n />\n </FormField>\n ) : null}\n {assignees.length > 0 ? (\n <FormField label={t(key('assignee'))}>\n <Select\n options={assigneeOptions}\n value={fields.assigneeId}\n onValueChange={(v) => v && form.patchFields({ assigneeId: v })}\n />\n </FormField>\n ) : null}\n <RadioGroup\n label={t(key('about'))}\n variant=\"segmented\"\n className={EDITOR_COMPACT_SEGMENTED_CLASS}\n value={fields.about}\n onValueChange={(v) =>\n form.patchFields({ about: v as typeof fields.about })\n }\n >\n {/* Every segment carries an icon: without one the group's\n collapse-to-icon net cannot fire. */}\n <Radio\n value=\"nobody\"\n label={t(key('aboutNobody'))}\n icon={<CircleOff aria-hidden=\"true\" />}\n />\n {/* Withheld with nothing to pick from, as Company is. Kept while\n chosen, so the group never loses its checked value, and while\n the stored record holds that link, so switching away and back\n can restore it. */}\n {hasPatientSource ||\n fields.about === 'patient' ||\n Boolean(stored?.patientId) ? (\n <Radio\n value=\"patient\"\n label={t(key('aboutPatient'))}\n icon={<User aria-hidden=\"true\" />}\n />\n ) : null}\n {hasCompanies ||\n fields.about === 'company' ||\n Boolean(stored?.companyId) ? (\n <Radio\n value=\"company\"\n label={t(key('aboutCompany'))}\n icon={<Building2 aria-hidden=\"true\" />}\n />\n ) : null}\n {/* The operator is a COUNTERPART, not a field beside them: the\n platform refuses a task that names two. */}\n {hasOperators ||\n fields.about === 'operator' ||\n Boolean(stored?.operatorId) ? (\n <Radio\n value=\"operator\"\n label={t(key('aboutOperator'))}\n icon={<Stethoscope aria-hidden=\"true\" />}\n />\n ) : null}\n </RadioGroup>\n {patientField()}\n {fields.about === 'company' ? (\n <>\n {unresolvedCompanyId ? (\n <FormField label={t(key('companyName'))}>\n <TextInput value={unresolvedCompanyLabel} disabled readOnly />\n </FormField>\n ) : null}\n {/* One picker in one slot for both states, so replacing an\n unresolved company keeps focus in the field. Clearing empties\n the id, which disables Save. */}\n {hasCompanies ? (\n <FormField\n label={t(\n key(unresolvedCompanyId ? 'companyReplace' : 'companyName'),\n )}\n >\n <Combobox\n options={companyOptions}\n value={unresolvedCompanyId ? '' : fields.companyId}\n onValueChange={(v) =>\n unresolvedCompanyId\n ? v && form.patchFields({ companyId: v })\n : form.patchFields({ companyId: v })\n }\n /* The Combobox cannot see the disabled fieldset. */\n clearable={!unresolvedCompanyId && !readOnly}\n filter={companyFilter}\n placeholder={t(key('companySearch'))}\n aria-label={t(\n key(unresolvedCompanyId ? 'companyReplace' : 'companyName'),\n )}\n />\n </FormField>\n ) : null}\n </>\n ) : null}\n {fields.about === 'operator' ? (\n hasOperators ? (\n <FormField label={t(key('operator'))}>\n <Select\n options={operatorOptions}\n value={fields.operatorId}\n onValueChange={(v) => v && form.patchFields({ operatorId: v })}\n />\n </FormField>\n ) : fields.operatorId !== NONE ? (\n /* No roster to pick from: name the link read-only. */\n <FormField label={t(key('operator'))}>\n <TextInput\n value={unresolvedOperatorLabel(fields.operatorId)}\n disabled\n readOnly\n />\n </FormField>\n ) : null\n ) : null}\n {form.showDone ? (\n <>\n <Switch\n label={t(key('done'))}\n checked={ui.done}\n /* A Save in flight re-sends the done value it captured, and a\n landed save or delete ends the session's writes. */\n disabled={busy || ui.accepted}\n /* Its own write keeps focus: aria-disabled, not disabled. */\n aria-disabled={ui.donePending || undefined}\n aria-busy={ui.donePending || undefined}\n className=\"ds:aria-disabled:cursor-progress\"\n onCheckedChange={(next) => {\n if (!ui.donePending) void form.setDone(next);\n }}\n />\n {ui.doneError ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.doneError}</Alert.Description>\n </Alert>\n ) : null}\n </>\n ) : null}\n {ui.saveError ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.saveError}</Alert.Description>\n </Alert>\n ) : null}\n {/* An agent delete skips the dialog, so its refusal shows here. */}\n {ui.deleteError && !ui.confirmDeleteOpen ? (\n <Alert variant=\"error\">\n <Alert.Description>{ui.deleteError}</Alert.Description>\n </Alert>\n ) : null}\n </fieldset>\n );\n\n const body =\n status === 'loading' ? (\n loadingBody\n ) : status === 'error' ? (\n errorBody\n ) : status === 'locked' ? (\n lockedBody\n ) : status === 'withheld' ? (\n <PrivacyNotice\n onTurnOff={onPrivacyOff ? rescuing(onPrivacyOff) : undefined}\n />\n ) : isSubview ? (\n formFields\n ) : (\n <ScrollArea orientation=\"vertical\" className=\"ds:min-h-0 ds:flex-1\">\n {formFields}\n </ScrollArea>\n );\n /* Loading and a failed load have no footer, as before; the locked and\n withheld states keep the way out. */\n const footer =\n status === 'ready'\n ? footerFor(true)\n : status === 'locked' || status === 'withheld'\n ? footerFor(false)\n : null;\n const hasDelete = status === 'ready' && form.showDelete;\n\n const deleteDialog = isEdit ? (\n <Dialog\n open={ui.confirmDeleteOpen && active}\n onOpenChange={(next) => {\n /* A failed delete keeps the dialog open with its error; closing\n it any other way clears that error, so a reopened dialog never\n shows a stale one. */\n if (ui.deleting) return;\n form.patchUi(\n next\n ? { confirmDeleteOpen: true }\n : { confirmDeleteOpen: false, deleteError: undefined },\n );\n }}\n >\n <Dialog.Content\n size=\"sm\"\n variant=\"alert\"\n onCloseAutoFocus={(event) => {\n /* The delete button is not a Dialog.Trigger, so Radix would\n drop focus on the body. Keep or Escape hands it back; once\n the task is gone, it must not land on its delete button. */\n event.preventDefault();\n if (!form.isAccepted()) deleteButtonRef.current?.focus();\n }}\n >\n <Dialog.Header>\n <Dialog.Title>{t(key('deleteConfirmTitle'))}</Dialog.Title>\n <Dialog.Description>\n {t(key('deleteConfirmBody'))}\n </Dialog.Description>\n </Dialog.Header>\n {ui.deleteError ? (\n <Dialog.Body>\n <Alert variant=\"error\">\n <Alert.Description>{ui.deleteError}</Alert.Description>\n </Alert>\n </Dialog.Body>\n ) : null}\n <Dialog.Footer divider>\n {/* Both keep focus while the delete runs, so a refusal is read\n in the dialog: aria-disabled, and onOpenChange waits. */}\n <Dialog.Close asChild>\n <Button intent=\"outline\" aria-disabled={ui.deleting || undefined}>\n {t(key('deleteCancel'))}\n </Button>\n </Dialog.Close>\n <Button\n intent=\"destructive\"\n startIcon={<Trash2 aria-hidden=\"true\" />}\n aria-disabled={ui.deleting || undefined}\n aria-busy={ui.deleting || undefined}\n onClick={() => {\n if (!ui.deleting) void form.remove();\n }}\n >\n {t(key('deleteConfirm'))}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n ) : null;\n\n const marker = {\n 'data-component': 'task-editor',\n 'data-component-id': instanceId,\n 'data-variant': variant,\n 'data-status': status,\n };\n\n if (isSubview) {\n return (\n <>\n <PanelSubview\n {...rest}\n /* The section holds the heading and footer too: repeat the\n instance hooks there so one selector reaches every action. */\n data-component-id={instanceId}\n data-variant={variant}\n data-status={status}\n ref={rootRef}\n open={open}\n onBack={requestCancel}\n onExited={onExited}\n title={title}\n icon={<SquareCheckBig aria-hidden=\"true\" />}\n backLabel={backLabel ?? t(key('back'))}\n footer={footer}\n footerAlign={hasDelete ? 'between' : 'end'}\n className={className}\n >\n <div {...marker} className={taskEditorVariants({ variant })}>\n {body}\n </div>\n </PanelSubview>\n {deleteDialog}\n </>\n );\n }\n\n return (\n <>\n <div\n tabIndex={-1}\n {...rest}\n {...marker}\n ref={rootRef}\n className={taskEditorVariants({ variant, className })}\n >\n <PanelHeader\n title={title}\n icon={<SquareCheckBig aria-hidden=\"true\" />}\n sticky\n divider\n />\n {body}\n {footer ? (\n <div className=\"ds:relative ds:z-[var(--z-sticky)] ds:shrink-0 ds:border-t ds:border-[color:var(--border)] ds:bg-[var(--background)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]\">\n {footer}\n </div>\n </div>\n ) : null}\n </div>\n {deleteDialog}\n </>\n );\n },\n);\nTaskEditor.displayName = 'TaskEditor';\n"],"names":["__iconNode","CircleOff","createLucideIcon","Save","EDITOR_COMPACT_FIELDS_CLASS","EDITOR_COMPACT_SEGMENTED_CLASS","PatientPicker","patients","searchPatients","props","jsx","PatientSearchPicker","value","onValueChange","selectedLabel","placeholder","size","disabled","Combobox","p","t","useTranslation","query","setQuery","useState","retry","setRetry","picked","setPicked","state","setState","inputRef","useRef","trimmedQuery","useEffect","controller","base","timer","current","status","message","options","patient","jsxs","next","prev","open","candidate","normalizeDiacritics","Button","_a","taskEditorAgent","handle","args","NONE","INITIAL_UI","aboutOf","task","timeOf","date","blankFields","initialDate","fieldsOf","COUNTERPARTS","useTaskEditorForm","mode","taskId","active","taskTypes","assignees","companies","operators","searchedPatients","resolvePatientLabel","loadTask","onCreateTask","onUpdateTask","onDeleteTask","onSetTaskDone","onSaved","onDeleted","readOnly","withheld","maskPatient","fallbackError","isEdit","session","setSession","wasActive","setWasActive","previous","subject","fields","setFields","ui","setUi","stored","setStored","patchUi","patchFields","currentSubject","setCurrentSubject","sessionRef","mountedRef","live","owner","loadTaskRef","hasLoadTask","attempt","setAttempt","loaded","setLoaded","loadedRef","canLoad","load","done","error","getErrorMessage","chosenTypeId","counterpartChosen","canSave","saveSeam","buildDraft","time","refuse","reason","handledRejection","submit","draft","id","write","created","setDone","remove","knows","list","storedId","entry","applyPatch","patch","chosen","key","branch","draftState","taskEditorVariants","cva","fieldsetVariants","suffix","companyFilter","_value","search","label","EMPTY","rowsIn","host","subview","row","FOCUSABLE","controlsIn","action","actions","el","TaskEditor","forwardRef","variant","onExited","patientLabel","companyLabel","operatorLabel","backLabel","onCancel","privacy","privacyMode","onPrivacyOff","className","rest","ref","reactId","useId","instanceId","isSubview","searched","form","searchRef","hasSearch","useMemo","found","formRef","onCancelRef","useAgentRegistration","localRoot","rootRef","composeRefs","deleteButtonRef","openerRef","subviewOpenRef","openRef","editedTaskRef","section","opener","fromList","edited","r","rowId","index","lost","rows","candidates","retryRef","rescueRef","rescuing","run","useIsomorphicLayoutEffect","root","title","hasCompanies","hasOperators","hasPatientSource","companyOptions","c","patientName","patientId","unresolvedOperatorLabel","operatorId","operatorOptions","o","groupTypes","type","typeOptions","assigneeOptions","user","unresolvedCompanyId","unresolvedCompanyLabel","readOnlyNotice","Alert","Lock","busy","requestCancel","cancelButton","IconButton","X","saveInert","footerFor","withWrites","Fragment","Trash2","IconButtonGroup","LoaderCircle","SaveIcon","loadingBody","Skeleton","errorBody","lockedBody","patientField","FormField","TextInput","privacyMask","formFields","DatePicker","TimePicker","TextArea","e","Select","v","RadioGroup","Radio","User","Building2","Stethoscope","Switch","body","PrivacyNotice","ScrollArea","footer","hasDelete","deleteDialog","Dialog","event","marker","PanelSubview","SquareCheckBig","PanelHeader"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