@alfadocs/ui-kit 1.147.2 → 1.149.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 (115) hide show
  1. package/dist/_chunks/{appointment-timeline-D5qbZ7in.js → appointment-timeline-CuZW-CGT.js} +2 -2
  2. package/dist/_chunks/{bill-line-table-DnkFqMnM.js → bill-line-table-B8Cc2pTH.js} +2 -2
  3. package/dist/_chunks/button-group-CHQD8GJ0.js +449 -0
  4. package/dist/_chunks/{calendar-appointment-editor-dialog-CoIFwj9g.js → calendar-appointment-editor-dialog-Dx9_KIWA.js} +7 -7
  5. package/dist/_chunks/{calendar-waiting-list-panel-DuALuqLD.js → calendar-waiting-list-panel-BKBHfBpn.js} +3 -3
  6. package/dist/_chunks/{calendar.sheets-CueyPkTT.js → calendar.sheets-lgAqJB34.js} +3 -3
  7. package/dist/_chunks/{data-grid-CujX-2tF.js → data-grid-CkzbCZSo.js} +486 -476
  8. package/dist/_chunks/{default-tabs-CqP1uWdx.js → default-tabs-C45FVzsG.js} +3 -3
  9. package/dist/_chunks/{face-scheme-ByYeboH9.js → face-scheme-BC2whb1S.js} +2 -2
  10. package/dist/_chunks/{invoice-upload-list-srvWy5_d.js → invoice-upload-list-BReimsvV.js} +3 -3
  11. package/dist/_chunks/notes-panel-Cw06dLDm.js +1135 -0
  12. package/dist/_chunks/prescription-history-CQuJmd4H.js +1846 -0
  13. package/dist/_chunks/rich-text-editor-eGdYDPK2.js +4405 -0
  14. package/dist/_chunks/task-editor-4zFL10oM.js +1153 -0
  15. package/dist/_chunks/{tasks-panel-DsjfS_k5.js → tasks-panel-BDPQPOP6.js} +475 -461
  16. package/dist/_chunks/{toolbar-z_6tE7zG.js → toolbar-B9oh9XY9.js} +2 -2
  17. package/dist/_chunks/{use-appointment-details-read-CC74Y-r5.js → use-appointment-details-read-Bl1DHXQ2.js} +568 -554
  18. package/dist/agent-catalog.json +9 -7
  19. package/dist/agent-i18n/en.json +4 -4
  20. package/dist/appointment-editor-panel/index.js +1 -1
  21. package/dist/aws-transcribe/index.js +287 -181
  22. package/dist/browser-support.js +1 -1
  23. package/dist/calendar-action-buttons/index.js +1 -1
  24. package/dist/components/_shared/save-outcome.d.ts +23 -0
  25. package/dist/components/appointment-details-panel/index.js +1 -1
  26. package/dist/components/appointment-timeline/index.js +1 -1
  27. package/dist/components/bill-line-table/index.js +1 -1
  28. package/dist/components/bill-table/index.js +1 -1
  29. package/dist/components/button-group/button-group.d.ts +2 -1
  30. package/dist/components/button-group/index.js +1 -1
  31. package/dist/components/data-grid/data-grid.variants.d.ts +7 -1
  32. package/dist/components/data-grid/index.js +2 -2
  33. package/dist/components/face-scheme/index.js +1 -1
  34. package/dist/components/index.d.ts +1 -0
  35. package/dist/components/invoice-upload-list/index.js +1 -1
  36. package/dist/components/notes-panel/index.js +1 -1
  37. package/dist/components/rich-text-editor/help-me-write-overlay.d.ts +12 -1
  38. package/dist/components/rich-text-editor/index.js +1 -1
  39. package/dist/components/rich-text-editor/rich-text-editor.d.ts +5 -3
  40. package/dist/components/task-editor/index.js +1 -1
  41. package/dist/components/task-editor/use-task-editor-form.d.ts +7 -1
  42. package/dist/components/tasks-panel/index.js +1 -1
  43. package/dist/core.css +1 -1
  44. package/dist/find-free-slots-panel/index.js +1 -1
  45. package/dist/host-compat.css +7 -1
  46. package/dist/i18n/locales/ar.d.ts +1 -0
  47. package/dist/i18n/locales/ar.js +2 -1
  48. package/dist/i18n/locales/de.d.ts +1 -0
  49. package/dist/i18n/locales/de.js +2 -1
  50. package/dist/i18n/locales/el.d.ts +1 -0
  51. package/dist/i18n/locales/el.js +2 -1
  52. package/dist/i18n/locales/en.d.ts +1 -0
  53. package/dist/i18n/locales/en.js +2 -1
  54. package/dist/i18n/locales/es.d.ts +1 -0
  55. package/dist/i18n/locales/es.js +2 -1
  56. package/dist/i18n/locales/fr.d.ts +1 -0
  57. package/dist/i18n/locales/fr.js +2 -1
  58. package/dist/i18n/locales/hi.d.ts +1 -0
  59. package/dist/i18n/locales/hi.js +2 -1
  60. package/dist/i18n/locales/it.d.ts +1 -0
  61. package/dist/i18n/locales/it.js +2 -1
  62. package/dist/i18n/locales/ja.d.ts +1 -0
  63. package/dist/i18n/locales/ja.js +2 -1
  64. package/dist/i18n/locales/nl.d.ts +1 -0
  65. package/dist/i18n/locales/nl.js +2 -1
  66. package/dist/i18n/locales/pl.d.ts +1 -0
  67. package/dist/i18n/locales/pl.js +2 -1
  68. package/dist/i18n/locales/pt.d.ts +1 -0
  69. package/dist/i18n/locales/pt.js +2 -1
  70. package/dist/i18n/locales/ro.d.ts +1 -0
  71. package/dist/i18n/locales/ro.js +2 -1
  72. package/dist/i18n/locales/ru.d.ts +1 -0
  73. package/dist/i18n/locales/ru.js +2 -1
  74. package/dist/i18n/locales/sq.d.ts +1 -0
  75. package/dist/i18n/locales/sq.js +2 -1
  76. package/dist/i18n/locales/sv.d.ts +1 -0
  77. package/dist/i18n/locales/sv.js +2 -1
  78. package/dist/i18n/locales/tr.d.ts +1 -0
  79. package/dist/i18n/locales/tr.js +2 -1
  80. package/dist/i18n/locales/zh.d.ts +1 -0
  81. package/dist/i18n/locales/zh.js +2 -1
  82. package/dist/index.js +1408 -1404
  83. package/dist/locales/ar.json +2 -1
  84. package/dist/locales/de.json +2 -1
  85. package/dist/locales/el.json +2 -1
  86. package/dist/locales/en.json +2 -1
  87. package/dist/locales/es.json +2 -1
  88. package/dist/locales/fr.json +2 -1
  89. package/dist/locales/hi.json +2 -1
  90. package/dist/locales/it.json +2 -1
  91. package/dist/locales/ja.json +2 -1
  92. package/dist/locales/nl.json +2 -1
  93. package/dist/locales/pl.json +2 -1
  94. package/dist/locales/pt.json +2 -1
  95. package/dist/locales/ro.json +2 -1
  96. package/dist/locales/ru.json +2 -1
  97. package/dist/locales/sq.json +2 -1
  98. package/dist/locales/sv.json +2 -1
  99. package/dist/locales/tr.json +2 -1
  100. package/dist/locales/zh.json +2 -1
  101. package/dist/online-bookings-panel/index.js +1 -1
  102. package/dist/patterns/calendar/index.js +2 -2
  103. package/dist/patterns/prescription/index.d.ts +1 -1
  104. package/dist/patterns/prescription/index.js +1 -1
  105. package/dist/patterns/prescription/prescription-history.d.ts +28 -0
  106. package/dist/save-outcome/index.js +20 -0
  107. package/dist/speech/aws-transcribe.d.ts +30 -6
  108. package/dist/tokens.css +1 -1
  109. package/dist/waiting-list-panel/index.js +2 -2
  110. package/package.json +5 -1
  111. package/dist/_chunks/button-group-N60L3HMa.js +0 -408
  112. package/dist/_chunks/notes-panel-BHMnLbEH.js +0 -1116
  113. package/dist/_chunks/prescription-history-CFs3JMIE.js +0 -1773
  114. package/dist/_chunks/rich-text-editor-BAcJq1PO.js +0 -4359
  115. package/dist/_chunks/task-editor-B9YpfwcW.js +0 -1095
@@ -0,0 +1,1135 @@
1
+ import { jsxs as b, jsx as a, Fragment as Dn } from "react/jsx-runtime";
2
+ import { forwardRef as _n, useRef as u, useState as T, useId as Mn, useEffect as S, useCallback as W, useMemo as wt, useImperativeHandle as zn } from "react";
3
+ import { c as Nt } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as Hn } from "react-i18next";
5
+ import { g as yt } from "./get-error-message-DbFUzuja.js";
6
+ import { useSaveOutcomeUnknownMessage as Wn, isSaveOutcomeUnknownError as Me } from "../save-outcome/index.js";
7
+ import { h as At } from "./handled-rejection-C-6Dq0As.js";
8
+ import { u as $n } from "./registry-DvAUVLHh.js";
9
+ import { C as Bn } from "./clinical-note-card-D-9xmRpf.js";
10
+ import { R as Kn } from "./rich-text-editor-eGdYDPK2.js";
11
+ import { T as Un } from "./text-area-COMVJ1yE.js";
12
+ import { A } from "./alert-C4WKViaS.js";
13
+ import { B as re } from "./button-Dp4j9ygh.js";
14
+ import { I as bt } from "./icon-button-u9VMQn3x.js";
15
+ import { S as In } from "./switch-DO6uC4HJ.js";
16
+ import { T as Yn } from "./tooltip-uEBdD1-5.js";
17
+ import { C as Pt } from "./card-n6W6LW-N.js";
18
+ import { C as Gn, S as ye } from "./skeleton-tTWJpvAq.js";
19
+ import { D as L } from "./dialog-239Geb7Z.js";
20
+ import { P as Jn } from "./panel-header-CbtlTe85.js";
21
+ import { a as Qn, u as Xn, R as Zn } from "./use-list-reflow-C7O4Uqnl.js";
22
+ import { u as er } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
23
+ import { u as tr } from "./use-resolved-theme-B0f1_oyq.js";
24
+ import { N as nr } from "./notebook-pen-CO7HoM-W.js";
25
+ import { P as rr } from "./pencil-B1sKKyuT.js";
26
+ import { T as sr } from "./trash-2-uumy3fy1.js";
27
+ const ar = {
28
+ id: "notes-panel",
29
+ // 'submit' backs add_note (compose + commit a note). pin / flag are toggles
30
+ // with no dedicated capability in the closed vocabulary.
31
+ capabilities: ["submit"],
32
+ state: {
33
+ notes: {
34
+ type: "Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean; deleted: boolean }>",
35
+ descriptionKey: "ui.agent.notesPanel.state.notes",
36
+ description: "Timeline note ids + pinned / flagged / clinical / deleted flags. Never the note body or author (both PHI). A note whose delete is in flight is left out; a pin or flag in flight is reported with its new value. A deleted note takes no pin or flag.",
37
+ read: (o) => o.getNotes()
38
+ },
39
+ canAddClinical: {
40
+ type: "boolean",
41
+ descriptionKey: "ui.agent.notesPanel.state.canAddClinical",
42
+ description: "Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).",
43
+ read: (o) => o.canAddClinical()
44
+ },
45
+ currentNoteId: {
46
+ type: "string | null",
47
+ descriptionKey: "ui.agent.notesPanel.state.currentNoteId",
48
+ description: "Id of the note the host has addressed — the one marked, scrolled to and focused. Null when none is. An id only, never note content.",
49
+ read: (o) => o.getCurrentNoteId()
50
+ }
51
+ },
52
+ actions: {
53
+ add_note: {
54
+ // Writes a clinical/admin note body — patient-identifiable content. PHI.
55
+ safety: "phi",
56
+ argsType: "{ content: string; clinical: boolean }",
57
+ argsSchema: {
58
+ type: "object",
59
+ properties: {
60
+ content: {
61
+ type: "string",
62
+ description: "Note body. Rich HTML for the rich composer, else plain text."
63
+ },
64
+ clinical: {
65
+ type: "boolean",
66
+ description: "Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed."
67
+ }
68
+ },
69
+ required: ["content", "clinical"]
70
+ },
71
+ openWorld: !0,
72
+ descriptionKey: "ui.agent.notesPanel.actions.addNote",
73
+ description: "Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).",
74
+ examples: [
75
+ {
76
+ args: { content: "Patient reported improvement.", clinical: !0 },
77
+ note: "Add a clinical note."
78
+ }
79
+ ],
80
+ invoke: (o, f) => o.addNote(f)
81
+ },
82
+ toggle_pin: {
83
+ // A host write; it re-orders the timeline (pinned notes lead).
84
+ safety: "write",
85
+ argsType: "{ id: string }",
86
+ argsSchema: {
87
+ type: "object",
88
+ properties: { id: { type: "string" } },
89
+ required: ["id"]
90
+ },
91
+ idempotent: !1,
92
+ // Reaches the host's data source; the result is the host's promise.
93
+ openWorld: !0,
94
+ errors: [
95
+ "The panel offers no pin here: no onTogglePin, no note with this id, a deleted note, or actions.pin is false.",
96
+ "A pin or delete for this note is still pending. Read notes again once it has settled.",
97
+ "The host refused the change. The pin is restored and the panel shows the host's message.",
98
+ "The host rejected with SaveOutcomeUnknownError (the save hit its time limit and may still have landed). The pin keeps the value it moved to and the panel shows the kit's neutral message. Read notes again after a reload."
99
+ ],
100
+ descriptionKey: "ui.agent.notesPanel.actions.togglePin",
101
+ description: "Toggle the pinned state of the note with the given id. Returns the host's promise; a refusal restores the pin and the panel shows the host's message, except a SaveOutcomeUnknownError, which keeps the new value and shows the kit's neutral message. Rejects without reaching the host when the panel refuses: a deleted note, actions.pin false, or a write for the note still pending.",
102
+ invoke: (o, f) => o.togglePin(f.id)
103
+ },
104
+ toggle_flag: {
105
+ safety: "write",
106
+ argsType: "{ id: string }",
107
+ argsSchema: {
108
+ type: "object",
109
+ properties: { id: { type: "string" } },
110
+ required: ["id"]
111
+ },
112
+ idempotent: !1,
113
+ // Reaches the host's data source; the result is the host's promise.
114
+ openWorld: !0,
115
+ errors: [
116
+ "The panel offers no flag here: no onToggleFlag, no note with this id, a deleted note, or actions.flag is false.",
117
+ "A flag or delete for this note is still pending. Read notes again once it has settled.",
118
+ "The host refused the change. The flag is restored and the panel shows the host's message.",
119
+ "The host rejected with SaveOutcomeUnknownError (the save hit its time limit and may still have landed). The flag keeps the value it moved to and the panel shows the kit's neutral message. Read notes again after a reload."
120
+ ],
121
+ descriptionKey: "ui.agent.notesPanel.actions.toggleFlag",
122
+ description: "Toggle the flagged state of the note with the given id. Returns the host's promise; a refusal restores the flag and the panel shows the host's message, except a SaveOutcomeUnknownError, which keeps the new value and shows the kit's neutral message. Rejects without reaching the host when the panel refuses: a deleted note, actions.flag false, or a write for the note still pending.",
123
+ invoke: (o, f) => o.toggleFlag(f.id)
124
+ }
125
+ },
126
+ domHooks: {
127
+ root: {
128
+ attr: "data-component",
129
+ value: "notes-panel",
130
+ description: "Marks the NotesPanel region."
131
+ },
132
+ instanceId: {
133
+ attr: "data-component-id",
134
+ sourceProp: "id",
135
+ description: "Sourced from the id prop. Required to address a specific notes panel from the agent."
136
+ },
137
+ item: {
138
+ attr: "data-note-id",
139
+ description: "Stable note id on each rendered note row. Row controls carry data-note-action: edit, delete, pin or flag."
140
+ }
141
+ }
142
+ }, ir = "ds:isolate ds:[&_[data-component=card]>*]:relative ds:[&_[data-component=card]>*]:z-[1]", lr = Nt(
143
+ "ds:relative ds:flex ds:flex-col ds:rounded-[var(--radius-lg)]",
144
+ {
145
+ variants: {
146
+ current: {
147
+ true: "ds:focus:outline-[length:var(--focus-ring-width)] ds:focus:outline-solid ds:focus:outline-[color:var(--ring)] ds:focus:outline-offset-[length:var(--focus-ring-offset)]",
148
+ false: ""
149
+ },
150
+ washed: { true: ir, false: "" }
151
+ },
152
+ defaultVariants: { current: !1, washed: !1 }
153
+ }
154
+ ), xt = Nt(
155
+ "ds:pointer-events-none ds:absolute ds:inset-0 ds:rounded-[var(--radius-lg)] ds:bg-[color:var(--accent)]",
156
+ {
157
+ variants: {
158
+ state: {
159
+ addressed: [
160
+ // At rest the wash is clear; the accessible themes hold it at 12%
161
+ // instead of playing it (--accessible-on is 1 there).
162
+ "ds:opacity-[calc(var(--opacity-12)*var(--accessible-on,0))]",
163
+ "ds:animate-[var(--accessible-off,note-addressed_calc(var(--animation-duration)*9)_var(--ease-in-out))]",
164
+ "ds:motion-reduce:animate-none ds:motion-reduce:opacity-[var(--opacity-12)]"
165
+ ].join(" "),
166
+ editing: "ds:opacity-[var(--opacity-12)]"
167
+ }
168
+ }
169
+ }
170
+ ), Ft = [
171
+ "ds:rounded-[var(--radius-lg)] ds:outline-none",
172
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
173
+ "ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]"
174
+ ].join(" "), or = ["ds:flex ds:flex-col", Ft].join(" "), dr = "ds:opacity-0", cr = [
175
+ "ds:transition-opacity ds:duration-[var(--animation-duration)]",
176
+ "ds:ease-[var(--ease-out)] ds:motion-reduce:transition-none"
177
+ ].join(" "), ur = [3, 2, 3];
178
+ function Tt(o) {
179
+ return o ? /<img\b/i.test(o) ? !0 : o.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").trim().length > 0 : !1;
180
+ }
181
+ function St(o, f, y) {
182
+ const v = o == null ? void 0 : o.toggle(f, y), w = v ? v.refusal : "the panel is not mounted";
183
+ return w === void 0 ? v == null ? void 0 : v.result : At(new Error(`NotesPanel: ${y} refused (${w}).`));
184
+ }
185
+ const Ct = /* @__PURE__ */ new Map(), Et = /* @__PURE__ */ new Set();
186
+ function be(o) {
187
+ return o.map(
188
+ (f) => `${f.id ?? ""}:${f.pinned ? 1 : 0}${f.flagged ? 1 : 0}${f.deleted ? 1 : 0}`
189
+ ).join("|");
190
+ }
191
+ function Rt(o) {
192
+ return typeof (o == null ? void 0 : o.then) == "function";
193
+ }
194
+ function kt(o, f, y) {
195
+ const v = o.indexOf(y);
196
+ if (v >= 0) return v;
197
+ const w = f.indexOf(y);
198
+ if (w < 0) return -1;
199
+ const se = new Set(o);
200
+ return f.slice(0, w).filter((C) => se.has(C)).length;
201
+ }
202
+ function fr(o) {
203
+ if (o.hasAttribute("tabindex")) {
204
+ o.focus();
205
+ return;
206
+ }
207
+ const f = () => o.removeAttribute("tabindex");
208
+ o.setAttribute("tabindex", "-1"), o.focus(), document.activeElement === o ? o.addEventListener("blur", f, { once: !0 }) : f();
209
+ }
210
+ const Mr = _n(
211
+ function({
212
+ id: f,
213
+ notes: y,
214
+ onAddNote: v,
215
+ status: w = "ready",
216
+ onRetry: se,
217
+ currentNoteId: C,
218
+ currentNoteKey: ze,
219
+ composer: F = "rich",
220
+ editorToolbar: Ot = "standard",
221
+ redactor: jt,
222
+ imageUploadUrl: Vt,
223
+ showClinicalToggle: Lt = !0,
224
+ canAddClinicalNote: ae = !0,
225
+ clinicalGatedReason: qt,
226
+ defaultClinical: $ = !1,
227
+ onRequestAiDraft: Dt,
228
+ aiDraftFormat: _t,
229
+ aiPrivacyNotice: Mt,
230
+ onDictate: zt,
231
+ onProofread: Ht,
232
+ onAutoFormat: Wt,
233
+ aiConsent: $t,
234
+ variables: Bt,
235
+ validateVariable: Kt,
236
+ onVariableValidityChange: Ut,
237
+ renderHelpMeWrite: It,
238
+ aiTemplates: Yt,
239
+ onAiApplied: Gt,
240
+ onUploadImage: Jt,
241
+ onAiCreditsExhausted: Qt,
242
+ showExtensions: Xt,
243
+ aiCreditsNotice: Zt,
244
+ extensions: en,
245
+ extensionContext: tn,
246
+ onExtensionRun: nn,
247
+ composerBefore: rn,
248
+ composerAfter: sn,
249
+ onTogglePin: He,
250
+ onToggleFlag: We,
251
+ noteActions: $e,
252
+ onEditNote: B,
253
+ editClinical: an = !1,
254
+ onDeleteNote: K,
255
+ onWriteError: Be,
256
+ confirmDelete: Ke = !0,
257
+ title: ln,
258
+ composerPlaceholder: on,
259
+ addNoteLabel: dn,
260
+ emptyState: cn,
261
+ className: un,
262
+ "aria-label": Pe,
263
+ ...fn
264
+ }, gn) {
265
+ var vt;
266
+ const { t: l, i18n: Ue } = Hn("ui"), xe = Wn(), q = u(null), [_, U] = T(""), [ie, le] = T($), [P, Ie] = T(!1), [I, oe] = T(null), [g, Te] = T(null), Ye = u(g);
267
+ Ye.current = g;
268
+ const Ge = u(!1);
269
+ w === "loading" && (Ge.current = !0);
270
+ const hn = Ge.current ? Gn : "", pn = ln ?? l("notesPanel.title", { defaultValue: "Notes" }), Je = Mn(), Qe = on ?? l("notesPanel.placeholder", { defaultValue: "Add a note…" }), Xe = g !== null ? l("notesPanel.edit", { defaultValue: "Edit note" }) : l("notesPanel.composerLabel", { defaultValue: "New note" }), mn = F === "rich" ? Tt(_) : _.trim().length > 0, E = u(y);
271
+ E.current = y;
272
+ const [Y, vn] = T(Ct), R = u(Ct), [wn, yn] = T(Et), G = u(Et), O = u(!0);
273
+ S(() => (O.current = !0, () => {
274
+ O.current = !1;
275
+ }), []);
276
+ const j = u(null), D = u(Be);
277
+ D.current = Be;
278
+ const Se = W(() => {
279
+ const e = j.current;
280
+ return !O.current || !e || e.closest('[hidden],[inert],[aria-hidden="true"]') ? !1 : typeof e.checkVisibility == "function" ? e.checkVisibility() : !0;
281
+ }, []), J = u([]), [bn, Pn] = T(0), Ce = W((e) => {
282
+ if (!O.current) {
283
+ e(!1);
284
+ return;
285
+ }
286
+ J.current.push(e), Pn((t) => t + 1);
287
+ }, []);
288
+ S(() => {
289
+ const e = J.current;
290
+ J.current = [], e.forEach((t) => t(!0));
291
+ }, [bn]), S(
292
+ () => () => {
293
+ const e = J.current;
294
+ J.current = [], e.forEach((t) => t(!1));
295
+ },
296
+ []
297
+ );
298
+ const Ze = (e) => {
299
+ const t = new Map(R.current);
300
+ e(t), R.current = t, vn(t);
301
+ }, Ee = (e) => {
302
+ const t = new Set(G.current);
303
+ e(t), G.current = t, yn(t);
304
+ }, de = (e, t) => {
305
+ var n;
306
+ return (n = R.current.get(e)) == null ? void 0 : n[t];
307
+ }, Q = (e, t, n) => Ze((i) => {
308
+ const s = { ...i.get(e) };
309
+ n ? s[t] = n : delete s[t], Object.keys(s).length > 0 ? i.set(e, s) : i.delete(e);
310
+ }), et = (e) => {
311
+ var t;
312
+ return e != null && !!((t = R.current.get(e)) != null && t.delete);
313
+ }, xn = W(() => {
314
+ var h;
315
+ if (!(g !== null ? B : v) || P) return;
316
+ const t = F === "rich", n = t ? ((h = q.current) == null ? void 0 : h.getHTML()) ?? _ : _.trim();
317
+ if (t ? !Tt(n) : !n) return;
318
+ const i = () => {
319
+ var c;
320
+ t && ((c = q.current) == null || c.clear()), U(""), le($), Te(null);
321
+ };
322
+ oe(null);
323
+ const s = g, r = (c) => Ce((m) => {
324
+ var k;
325
+ const x = m && (s === null || Ye.current === s && E.current.some((ne) => ne.id === s && !ne.deleted));
326
+ x && oe(
327
+ Me(c) ? { text: xe, unknown: !0 } : {
328
+ text: yt(c, l("notesPanel.addFailed")),
329
+ unknown: !1
330
+ }
331
+ ), (k = D.current) == null || k.call(D, {
332
+ kind: s !== null ? "edit" : "add",
333
+ noteId: s ?? void 0,
334
+ error: c,
335
+ shown: x && Se()
336
+ });
337
+ });
338
+ let d;
339
+ try {
340
+ d = g !== null && B ? B(g, { content: n, clinical: ie }) : v == null ? void 0 : v({ content: n, clinical: ie });
341
+ } catch (c) {
342
+ r(c);
343
+ return;
344
+ }
345
+ if (!d || typeof d.then != "function") return i();
346
+ Ie(!0), Promise.resolve(d).then(i, r).finally(() => Ie(!1));
347
+ }, [
348
+ F,
349
+ _,
350
+ ie,
351
+ $,
352
+ g,
353
+ Ce,
354
+ v,
355
+ B,
356
+ Se,
357
+ P,
358
+ xe,
359
+ l
360
+ ]), tt = Lt && (g === null || an), Tn = g !== null && !!((vt = Y.get(g)) != null && vt.delete), ce = W(
361
+ (e) => {
362
+ try {
363
+ return new Intl.DateTimeFormat(Ue.language, {
364
+ day: "numeric",
365
+ month: "long",
366
+ year: "numeric",
367
+ hour: "2-digit",
368
+ minute: "2-digit"
369
+ }).format(new Date(e.dateIso));
370
+ } catch {
371
+ return e.dateIso;
372
+ }
373
+ },
374
+ [Ue.language]
375
+ ), Sn = W(
376
+ (e) => {
377
+ var n, i, s, r;
378
+ if (!e.id || P || (n = R.current.get(e.id)) != null && n.delete) return;
379
+ const t = e.content ?? "";
380
+ oe(null), Te(e.id), le(e.clinical ?? !1), U(t), F === "rich" && ((i = q.current) == null || i.clear(), (s = q.current) == null || s.insertAtCursor(t, { asHtml: !0 })), (r = q.current) == null || r.focus();
381
+ },
382
+ [F, P]
383
+ ), ue = W(() => {
384
+ var e;
385
+ F === "rich" && ((e = q.current) == null || e.clear()), U(""), le($), oe(null), Te(null);
386
+ }, [F, $]), nt = g === null || y.some((e) => e.id === g && !e.deleted);
387
+ S(() => {
388
+ nt || ue();
389
+ }, [nt, ue]);
390
+ const Re = (e) => {
391
+ var t, n;
392
+ return (e.id ? (n = (t = Y.get(e.id)) == null ? void 0 : t.pin) == null ? void 0 : n.next : void 0) ?? !!e.pinned;
393
+ }, Cn = (e) => {
394
+ var t, n;
395
+ return (e.id ? (n = (t = Y.get(e.id)) == null ? void 0 : t.flag) == null ? void 0 : n.next : void 0) ?? !!e.flagged;
396
+ }, M = y.filter((e) => !e.id || !wn.has(e.id)).sort((e, t) => Number(Re(t)) - Number(Re(e))), rt = M.flatMap((e) => e.id ? [e.id] : []), z = u([]);
397
+ z.current = rt.filter(
398
+ (e) => {
399
+ var t;
400
+ return !((t = Y.get(e)) != null && t.delete);
401
+ }
402
+ );
403
+ const ke = u([]);
404
+ ke.current = rt;
405
+ const { isAccessible: En } = tr(j), st = En || void 0, { containerRef: Rn } = Qn({
406
+ key: M.map((e) => e.id).join(),
407
+ reduceMotion: st
408
+ }), fe = Xn({ reduceMotion: st }), [p, ge] = T(null), at = u(0), Ne = u(0), it = () => {
409
+ Ne.current += 1, ge(null);
410
+ }, he = (e, t, n, i = !0) => {
411
+ const s = Ne.current;
412
+ Ce((r) => {
413
+ var h;
414
+ const d = r && i && s === Ne.current && Se() && E.current.some((c) => c.id === t) && (e === "delete" || !et(t) && !G.current.has(t));
415
+ d && (at.current += 1, ge({
416
+ kind: e,
417
+ noteId: t,
418
+ message: yt(n, ""),
419
+ unknown: Me(n),
420
+ seq: at.current
421
+ })), (h = D.current) == null || h.call(D, { kind: e, noteId: t, error: n, shown: d });
422
+ });
423
+ }, kn = (e) => {
424
+ const t = y.find((i) => i.id === e.noteId), n = t != null && t.dateIso ? ce(t) : "";
425
+ if (n)
426
+ switch (e.kind) {
427
+ case "delete":
428
+ return l("notesPanel.deleteFailedNamed", { date: n });
429
+ case "pin":
430
+ return l("notesPanel.pinFailedNamed", { date: n });
431
+ case "unpin":
432
+ return l("notesPanel.unpinFailedNamed", { date: n });
433
+ case "flag":
434
+ return l("notesPanel.flagFailedNamed", { date: n });
435
+ default:
436
+ return l("notesPanel.unflagFailedNamed", { date: n });
437
+ }
438
+ switch (e.kind) {
439
+ case "delete":
440
+ return l("notesPanel.deleteFailed");
441
+ case "pin":
442
+ return l("notesPanel.pinFailed");
443
+ case "unpin":
444
+ return l("notesPanel.unpinFailed");
445
+ case "flag":
446
+ return l("notesPanel.flagFailed");
447
+ default:
448
+ return l("notesPanel.unflagFailed");
449
+ }
450
+ }, pe = p !== null && y.some((e) => e.id === p.noteId), lt = u(null);
451
+ p && pe && (lt.current = p), S(() => {
452
+ p && !pe && ge(null);
453
+ }, [p, pe]);
454
+ const [Ae, ot] = T({ text: "", seq: 0 }), Fe = u(void 0), dt = (e) => {
455
+ ot((t) => ({ text: e, seq: t.seq + 1 })), window.clearTimeout(Fe.current), Fe.current = window.setTimeout(
456
+ () => ot((t) => ({ ...t, text: "" })),
457
+ 1e3
458
+ );
459
+ };
460
+ S(() => () => window.clearTimeout(Fe.current), []);
461
+ const ct = () => dt(l("notesPanel.deleted")), me = u(0), ut = u(w);
462
+ S(() => {
463
+ ut.current === "loading" && w === "ready" && (me.current += 1), ut.current = w;
464
+ }, [w]);
465
+ const ft = () => {
466
+ const e = E.current, t = be(e), n = new Map(e.map((r) => [r.id, r])), i = [];
467
+ if (R.current.forEach((r, d) => {
468
+ const h = n.get(d);
469
+ Object.keys(r).forEach((c) => {
470
+ const m = r[c];
471
+ if (!m) return;
472
+ if (!h) {
473
+ i.push([d, c]);
474
+ return;
475
+ }
476
+ if (!m.settled) return;
477
+ const x = c === "delete" ? h.deleted === !0 : (c === "pin" ? !!h.pinned : !!h.flagged) === m.next, k = me.current > m.edgeAtSettle || c !== "delete" && t !== m.sigAtSettle;
478
+ (x || k) && i.push([d, c]);
479
+ });
480
+ }), i.length === 0) return;
481
+ Ze(
482
+ (r) => i.forEach(([d, h]) => {
483
+ const c = { ...r.get(d) };
484
+ delete c[h], Object.keys(c).length > 0 ? r.set(d, c) : r.delete(d);
485
+ })
486
+ );
487
+ const s = i.filter(([, r]) => r === "delete").map(([r]) => r);
488
+ s.some((r) => G.current.has(r)) && Ee((r) => s.forEach((d) => r.delete(d))), s.forEach((r) => fe.cancel(r));
489
+ }, Oe = (e, t, n) => de(e, t) !== n ? !1 : (Q(e, t, {
490
+ ...n,
491
+ settled: !0,
492
+ edgeAtSettle: me.current,
493
+ sigAtSettle: be(E.current)
494
+ }), ft(), !0), gt = (e, t, n) => de(e, t) !== n ? !1 : (Q(e, t, void 0), t !== "delete" || (G.current.has(e) && Ee((i) => i.delete(e)), fe.cancel(e)), !0), Nn = wt(() => be(y), [y]);
495
+ S(() => {
496
+ ft();
497
+ }, [Nn, w]);
498
+ const je = (e, t) => {
499
+ var k, ne;
500
+ const n = t === "pin" ? He : We, i = (N) => ({
501
+ started: !1,
502
+ refusal: N
503
+ });
504
+ if (!n)
505
+ return i(t === "pin" ? "no onTogglePin" : "no onToggleFlag");
506
+ const s = E.current.find((N) => N.id === e);
507
+ if (!s) return i("no note has this id");
508
+ if (s.deleted) return i("the note is deleted");
509
+ if (t === "pin" && ((k = s.actions) == null ? void 0 : k.pin) === !1)
510
+ return i("actions.pin is false for this note");
511
+ if (t === "flag" && ((ne = s.actions) == null ? void 0 : ne.flag) === !1)
512
+ return i("actions.flag is false for this note");
513
+ const r = R.current.get(e);
514
+ if (r != null && r.delete) return i("the note is being deleted");
515
+ if (r != null && r[t])
516
+ return i(`a ${t} write for this note is still pending`);
517
+ const d = !(t === "pin" ? s.pinned : s.flagged), h = t === "pin" ? d ? "pin" : "unpin" : d ? "flag" : "unflag";
518
+ it();
519
+ let c;
520
+ try {
521
+ c = n(e, d);
522
+ } catch (N) {
523
+ return he(h, e, N), { started: !1, result: At(N) };
524
+ }
525
+ if (!Rt(c)) return { started: !0, result: c };
526
+ const m = {
527
+ next: d,
528
+ settled: !1,
529
+ edgeAtSettle: 0,
530
+ sigAtSettle: ""
531
+ };
532
+ Q(e, t, m);
533
+ const x = Promise.resolve(c);
534
+ return x.then(
535
+ () => {
536
+ O.current && Oe(e, t, m);
537
+ },
538
+ (N) => {
539
+ const qn = O.current && (Me(N) ? Oe(e, t, m) : gt(e, t, m));
540
+ he(h, e, N, qn);
541
+ }
542
+ ), { started: !0, result: x };
543
+ }, ht = (e) => {
544
+ var i;
545
+ if (!K) return !1;
546
+ const t = E.current.find((s) => s.id === e);
547
+ if (!t || t.deleted || ((i = t.actions) == null ? void 0 : i.delete) === !1 || de(e, "delete")) return !1;
548
+ it();
549
+ let n;
550
+ try {
551
+ n = K(e);
552
+ } catch (s) {
553
+ return he("delete", e, s), !1;
554
+ }
555
+ if (Rt(n)) {
556
+ const s = {
557
+ settled: !1,
558
+ edgeAtSettle: 0,
559
+ sigAtSettle: ""
560
+ };
561
+ Q(e, "delete", s), t.keptOnDelete && dt(
562
+ t.dateIso ? l("notesPanel.deletingNamed", { date: ce(t) }) : l("notesPanel.deleting")
563
+ ), Promise.resolve(n).then(
564
+ () => {
565
+ O.current && (ct(), Oe(e, "delete", s));
566
+ },
567
+ (r) => {
568
+ const d = O.current && gt(e, "delete", s);
569
+ he("delete", e, r, d);
570
+ }
571
+ );
572
+ } else
573
+ Q(e, "delete", {
574
+ settled: !0,
575
+ edgeAtSettle: me.current,
576
+ sigAtSettle: be(E.current)
577
+ }), ct();
578
+ return t.keptOnDelete || fe.leave(e, () => {
579
+ de(e, "delete") && Ee((s) => s.add(e));
580
+ }), !0;
581
+ }, [X, Z] = T(null), ve = u(null), An = (e) => {
582
+ if (!(!K || et(e)) && !(P && g === e)) {
583
+ if (!Ke) {
584
+ ht(e);
585
+ return;
586
+ }
587
+ ve.current = { noteId: e, index: -1, started: !1 }, Z(e);
588
+ }
589
+ }, Fn = () => {
590
+ const e = X;
591
+ if (!e) return;
592
+ const t = z.current.indexOf(e);
593
+ ht(e) && (ve.current = { noteId: e, index: t, started: !0 }), Z(null);
594
+ }, Ve = X !== null && y.some((e) => e.id === X && !e.deleted);
595
+ S(() => {
596
+ X !== null && !Ve && Z(null);
597
+ }, [X, Ve]), zn(gn, () => j.current, []);
598
+ const V = (e, t) => {
599
+ var n;
600
+ return e ? ((n = j.current) == null ? void 0 : n.querySelector(
601
+ `[data-note-id="${CSS.escape(e)}"] ${t ? `[data-note-action="${CSS.escape(t)}"]` : "[data-note-action]"}`
602
+ )) ?? null : null;
603
+ }, we = (e, t) => {
604
+ const n = z.current;
605
+ return V(n[e], t) ?? V(n[e - 1], t) ?? V(n[e], null) ?? V(n[e - 1], null);
606
+ }, On = () => {
607
+ const e = j.current, t = (e == null ? void 0 : e.querySelector("[data-notes-panel-empty]")) ?? e;
608
+ t && fr(t);
609
+ }, ee = (e) => {
610
+ e ? e.focus() : On();
611
+ }, jn = (e) => {
612
+ const t = ve.current;
613
+ if (ve.current = null, !t || e.defaultPrevented) return;
614
+ e.preventDefault();
615
+ const n = V(t.noteId, "delete");
616
+ ee(
617
+ t.started ? we(t.index, "delete") ?? n : n
618
+ );
619
+ }, Le = u(null), pt = (e) => {
620
+ const t = e.kind === "delete" ? "delete" : e.kind.endsWith("pin") ? "pin" : "flag", n = z.current.indexOf(e.noteId);
621
+ return V(e.noteId, t) ?? V(e.noteId, null) ?? (n >= 0 ? we(n, t) : null);
622
+ }, Vn = (e) => {
623
+ var t;
624
+ (t = Le.current) != null && t.contains(document.activeElement) && ee(pt(e)), ge(null);
625
+ }, H = u(null);
626
+ S(() => {
627
+ const e = j.current;
628
+ if (!e) return;
629
+ const t = (i) => {
630
+ var d, h;
631
+ const s = i.target;
632
+ if (!(s instanceof HTMLElement)) return;
633
+ const r = ((d = s.closest("[data-note-id]")) == null ? void 0 : d.dataset.noteId) ?? null;
634
+ H.current = {
635
+ el: s,
636
+ noteId: r,
637
+ action: ((h = s.closest("[data-note-action]")) == null ? void 0 : h.dataset.noteAction) ?? null,
638
+ index: r ? kt(z.current, ke.current, r) : -1,
639
+ inWriteError: !!s.closest("[data-notes-panel-write-error]")
640
+ };
641
+ }, n = (i) => {
642
+ const s = i.relatedTarget;
643
+ if (s instanceof Node) {
644
+ e.contains(s) || (H.current = null);
645
+ return;
646
+ }
647
+ const r = i.target;
648
+ queueMicrotask(() => {
649
+ const d = H.current;
650
+ d && d.el === r && d.el.isConnected && document.activeElement !== d.el && (H.current = null);
651
+ });
652
+ };
653
+ return e.addEventListener("focusin", t), e.addEventListener("focusout", n), () => {
654
+ e.removeEventListener("focusin", t), e.removeEventListener("focusout", n);
655
+ };
656
+ }, []), er(() => {
657
+ var i;
658
+ const e = H.current;
659
+ if (!e || !j.current) return;
660
+ if (e.el.isConnected) {
661
+ const s = e.noteId ? kt(
662
+ z.current,
663
+ ke.current,
664
+ e.noteId
665
+ ) : -1;
666
+ s >= 0 && (e.index = s);
667
+ return;
668
+ }
669
+ H.current = null;
670
+ const t = document.activeElement;
671
+ if (t && t !== document.body) return;
672
+ const n = e.action ? V(e.noteId, e.action) : null;
673
+ if (n) n.focus();
674
+ else if (e.noteId)
675
+ ee(we(e.index, e.action));
676
+ else if (e.el.hasAttribute("data-notes-panel-empty"))
677
+ ee(we(0, "delete"));
678
+ else if (e.inWriteError) {
679
+ const s = (i = Le.current) == null ? void 0 : i.querySelector(
680
+ "[data-alert-dismiss]"
681
+ ), r = lt.current;
682
+ s ? s.focus() : ee(r ? pt(r) : null);
683
+ }
684
+ });
685
+ const qe = u(null);
686
+ S(() => {
687
+ var e, t;
688
+ C && ((e = qe.current) == null || e.scrollIntoView({ block: "center" }), (t = qe.current) == null || t.focus());
689
+ }, [C, ze]);
690
+ const te = u(v);
691
+ te.current = v;
692
+ const De = u(ae);
693
+ De.current = ae;
694
+ const mt = u(C);
695
+ mt.current = C;
696
+ const _e = u(null);
697
+ _e.current = { toggle: je };
698
+ const Ln = wt(
699
+ () => ({
700
+ // Ids + flags only — never the note body or author (both PHI).
701
+ getNotes: () => E.current.filter((e) => {
702
+ var t;
703
+ return !(e.id && ((t = R.current.get(e.id)) != null && t.delete));
704
+ }).map((e) => {
705
+ var n, i;
706
+ const t = e.id ? R.current.get(e.id) : void 0;
707
+ return {
708
+ id: e.id,
709
+ pinned: ((n = t == null ? void 0 : t.pin) == null ? void 0 : n.next) ?? !!e.pinned,
710
+ flagged: ((i = t == null ? void 0 : t.flag) == null ? void 0 : i.next) ?? !!e.flagged,
711
+ clinical: !!e.clinical,
712
+ deleted: !!e.deleted
713
+ };
714
+ }),
715
+ canAddNote: () => !!te.current,
716
+ canAddClinical: () => De.current,
717
+ getCurrentNoteId: () => mt.current ?? null,
718
+ addNote: (e) => {
719
+ var t;
720
+ if (!(e.clinical && !De.current))
721
+ return (t = te.current) == null ? void 0 : t.call(te, e);
722
+ },
723
+ togglePin: (e) => St(_e.current, e, "pin"),
724
+ toggleFlag: (e) => St(_e.current, e, "flag")
725
+ }),
726
+ []
727
+ );
728
+ return $n(ar, Ln, f), /* @__PURE__ */ b(
729
+ "section",
730
+ {
731
+ ref: j,
732
+ "data-component": "notes-panel",
733
+ "data-component-id": f,
734
+ "aria-labelledby": Pe ? void 0 : Je,
735
+ "aria-label": Pe,
736
+ className: [or, un].filter(Boolean).join(" "),
737
+ ...fn,
738
+ children: [
739
+ /* @__PURE__ */ a(
740
+ Jn,
741
+ {
742
+ title: pn,
743
+ icon: /* @__PURE__ */ a(nr, { "aria-hidden": "true" }),
744
+ headingId: Pe ? void 0 : Je,
745
+ sticky: !0,
746
+ divider: !0
747
+ }
748
+ ),
749
+ /* @__PURE__ */ b("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
750
+ v || g !== null ? /* @__PURE__ */ b(
751
+ "div",
752
+ {
753
+ "data-notes-panel-composer": g !== null ? "edit" : "add",
754
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
755
+ children: [
756
+ rn,
757
+ F === "rich" ? /* @__PURE__ */ a(
758
+ Kn,
759
+ {
760
+ ref: q,
761
+ ariaLabel: Xe,
762
+ placeholder: Qe,
763
+ toolbar: Ot,
764
+ minHeight: "fill",
765
+ redactor: jt,
766
+ imageUploadUrl: Vt,
767
+ readOnly: P,
768
+ onChange: ({ html: e }) => U(e),
769
+ onRequestAiDraft: Dt,
770
+ aiDraftFormat: _t,
771
+ aiPrivacyNotice: Mt,
772
+ onDictate: zt,
773
+ onProofread: Ht,
774
+ onAutoFormat: Wt,
775
+ aiConsent: $t,
776
+ variables: Bt,
777
+ validateVariable: Kt,
778
+ onVariableValidityChange: Ut,
779
+ renderHelpMeWrite: It,
780
+ aiTemplates: Yt,
781
+ onAiApplied: Gt,
782
+ onUploadImage: Jt,
783
+ onAiCreditsExhausted: Qt,
784
+ showExtensions: Xt,
785
+ aiCreditsNotice: Zt,
786
+ extensions: en,
787
+ extensionContext: tn,
788
+ onExtensionRun: nn,
789
+ aiConsentHeadingLevel: 3
790
+ }
791
+ ) : /* @__PURE__ */ a(
792
+ Un,
793
+ {
794
+ value: _,
795
+ readOnly: P,
796
+ onChange: (e) => U(e.target.value),
797
+ placeholder: Qe,
798
+ autoResize: !0,
799
+ minRows: 2,
800
+ maxRows: 6,
801
+ "aria-label": Xe
802
+ }
803
+ ),
804
+ /* @__PURE__ */ b(
805
+ "div",
806
+ {
807
+ className: [
808
+ "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
809
+ tt ? "ds:justify-between" : "ds:justify-end"
810
+ ].join(" "),
811
+ children: [
812
+ tt ? (() => {
813
+ const e = P || !ae, t = ae ? void 0 : qt ?? l("notesPanel.clinicalGated", {
814
+ defaultValue: "You do not have permission to write clinical notes."
815
+ }), n = /* @__PURE__ */ a(
816
+ In,
817
+ {
818
+ size: "sm",
819
+ label: l("notesPanel.clinicalToggle", {
820
+ defaultValue: "Clinical note"
821
+ }),
822
+ checked: ie,
823
+ onCheckedChange: le,
824
+ disabled: e
825
+ }
826
+ );
827
+ return e && t ? /* @__PURE__ */ a(Yn, { label: t, children: /* @__PURE__ */ a("span", { tabIndex: 0, children: n }) }) : n;
828
+ })() : null,
829
+ /* @__PURE__ */ b("span", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
830
+ g !== null ? /* @__PURE__ */ a(
831
+ re,
832
+ {
833
+ type: "button",
834
+ size: "sm",
835
+ intent: "ghost",
836
+ onClick: ue,
837
+ disabled: P,
838
+ children: l("notesPanel.cancelEdit", { defaultValue: "Cancel" })
839
+ }
840
+ ) : null,
841
+ /* @__PURE__ */ a(
842
+ re,
843
+ {
844
+ type: "button",
845
+ size: "sm",
846
+ onClick: xn,
847
+ disabled: !mn || Tn,
848
+ loading: P,
849
+ children: g !== null ? l("notesPanel.saveEdit", { defaultValue: "Save note" }) : dn ?? l("notesPanel.add", { defaultValue: "Add note" })
850
+ }
851
+ )
852
+ ] })
853
+ ]
854
+ }
855
+ ),
856
+ I ? /* @__PURE__ */ a(
857
+ A,
858
+ {
859
+ variant: I.unknown ? "warning" : "error",
860
+ announce: I.unknown ? "assertive" : void 0,
861
+ "data-notes-panel-add-error": "",
862
+ "data-outcome": I.unknown ? "unknown" : void 0,
863
+ children: /* @__PURE__ */ a(A.Description, { children: I.text })
864
+ }
865
+ ) : null,
866
+ sn
867
+ ]
868
+ }
869
+ ) : null,
870
+ w === "loading" && M.length === 0 ? (
871
+ /* Note-shaped placeholders, not a spinner: the reader sees where
872
+ the notes will land and how many to expect. The status text is
873
+ for assistive tech only; sighted readers get the motion. */
874
+ /* @__PURE__ */ b(
875
+ "div",
876
+ {
877
+ "data-notes-panel-loading": "",
878
+ "aria-busy": "true",
879
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
880
+ children: [
881
+ /* @__PURE__ */ a("span", { role: "status", className: "ds:sr-only", children: l("notesPanel.loading") }),
882
+ ur.map((e, t) => /* @__PURE__ */ a(Pt, { variant: "elevated", "aria-hidden": "true", children: /* @__PURE__ */ a(Pt.Body, { children: /* @__PURE__ */ b("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
883
+ /* @__PURE__ */ b("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
884
+ /* @__PURE__ */ a(
885
+ ye,
886
+ {
887
+ variant: "circular",
888
+ size: "sm",
889
+ stagger: t * 2
890
+ }
891
+ ),
892
+ /* @__PURE__ */ b("div", { className: "ds:flex ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
893
+ /* @__PURE__ */ a(
894
+ ye,
895
+ {
896
+ variant: "text",
897
+ size: "sm",
898
+ stagger: t * 2,
899
+ width: "40%"
900
+ }
901
+ ),
902
+ /* @__PURE__ */ a(
903
+ ye,
904
+ {
905
+ variant: "text",
906
+ size: "sm",
907
+ stagger: t * 2,
908
+ width: "25%"
909
+ }
910
+ )
911
+ ] })
912
+ ] }),
913
+ /* @__PURE__ */ a(
914
+ ye,
915
+ {
916
+ variant: "text",
917
+ size: "sm",
918
+ lines: e,
919
+ stagger: t * 2 + 1
920
+ }
921
+ )
922
+ ] }) }) }, t))
923
+ ]
924
+ }
925
+ )
926
+ ) : w === "error" ? /* @__PURE__ */ b(A, { variant: "error", children: [
927
+ /* @__PURE__ */ a(A.Description, { children: l("notesPanel.loadError") }),
928
+ se ? /* @__PURE__ */ a(A.Action, { children: /* @__PURE__ */ a(re, { intent: "secondary", size: "sm", onClick: se, children: l("notesPanel.retry") }) }) : null
929
+ ] }) : null,
930
+ p && pe ? /* @__PURE__ */ b(
931
+ A,
932
+ {
933
+ ref: Le,
934
+ variant: p.unknown ? "warning" : "error",
935
+ announce: p.unknown ? "assertive" : void 0,
936
+ dismissible: !0,
937
+ onOpenChange: (e) => {
938
+ e || Vn(p);
939
+ },
940
+ "data-notes-panel-write-error": p.kind,
941
+ "data-outcome": p.unknown ? "unknown" : void 0,
942
+ children: [
943
+ p.unknown ? /* @__PURE__ */ a(A.Description, { children: xe }) : /* @__PURE__ */ a(A.Title, { as: "p", children: kn(p) }),
944
+ !p.unknown && p.message ? /* @__PURE__ */ a(A.Description, { children: p.message }) : null
945
+ ]
946
+ },
947
+ p.seq
948
+ ) : null,
949
+ /* @__PURE__ */ a(
950
+ "span",
951
+ {
952
+ "aria-live": "polite",
953
+ "aria-atomic": "true",
954
+ "data-notes-panel-announcer": "",
955
+ className: "ds:sr-only",
956
+ children: Ae.text ? /* @__PURE__ */ a("span", { children: Ae.text }, Ae.seq) : null
957
+ }
958
+ ),
959
+ w === "loading" && M.length > 0 ? /* @__PURE__ */ a("span", { role: "status", className: "ds:sr-only", children: l("notesPanel.loading") }) : null,
960
+ M.length > 0 ? /* @__PURE__ */ a(
961
+ "ul",
962
+ {
963
+ ref: Rn,
964
+ "aria-busy": w === "loading" || void 0,
965
+ className: `ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0 ${hn}`.trim(),
966
+ children: M.map(({ actions: e, keptOnDelete: t, ...n }, i) => {
967
+ const s = C != null && n.id === C, r = n.id, d = r != null && g === r, h = r != null && fe.isLeaving(r), c = r ? Y.get(r) : void 0, m = !!(c != null && c.delete), x = m && !!t, k = P && d;
968
+ return /* @__PURE__ */ b(
969
+ "li",
970
+ {
971
+ ref: s ? qe : void 0,
972
+ "data-note-id": r,
973
+ tabIndex: s ? -1 : void 0,
974
+ "aria-current": s ? "true" : void 0,
975
+ "data-reflow-id": r,
976
+ "data-leaving": h ? "" : void 0,
977
+ "data-editing": d ? "" : void 0,
978
+ "aria-busy": x || void 0,
979
+ className: [
980
+ lr({
981
+ current: s,
982
+ washed: s || d
983
+ }),
984
+ cr,
985
+ Zn,
986
+ h ? dr : ""
987
+ ].filter(Boolean).join(" "),
988
+ children: [
989
+ s ? /* @__PURE__ */ a("span", { className: "ds:sr-only", children: l("notesPanel.current", {
990
+ defaultValue: "Current note"
991
+ }) }) : null,
992
+ x ? /* @__PURE__ */ a("span", { "data-notes-panel-deleting": "", className: "ds:sr-only", children: l("notesPanel.deleting") }) : null,
993
+ d ? /* @__PURE__ */ a(
994
+ "span",
995
+ {
996
+ "aria-hidden": "true",
997
+ "data-notes-panel-wash": "editing",
998
+ className: xt({ state: "editing" })
999
+ }
1000
+ ) : s ? /* @__PURE__ */ a(
1001
+ "span",
1002
+ {
1003
+ "aria-hidden": "true",
1004
+ "data-notes-panel-wash": "addressed",
1005
+ className: xt({ state: "addressed" })
1006
+ },
1007
+ `${C}:${ze ?? ""}`
1008
+ ) : null,
1009
+ /* @__PURE__ */ a(
1010
+ Bn,
1011
+ {
1012
+ surface: "elevated",
1013
+ truncate: !s,
1014
+ headerActions: /* @__PURE__ */ b(Dn, { children: [
1015
+ $e ? $e(
1016
+ { ...n, actions: e, keptOnDelete: t },
1017
+ { deleting: m }
1018
+ ) : null,
1019
+ B && r && !n.deleted && (e == null ? void 0 : e.edit) !== !1 ? /* @__PURE__ */ a(
1020
+ bt,
1021
+ {
1022
+ icon: /* @__PURE__ */ a(rr, {}),
1023
+ intent: "ghost",
1024
+ size: "sm",
1025
+ "aria-label": l("notesPanel.editNamed", {
1026
+ date: ce(n),
1027
+ defaultValue: "Edit note · {{date}}"
1028
+ }),
1029
+ tooltip: l("notesPanel.edit", {
1030
+ defaultValue: "Edit note"
1031
+ }),
1032
+ "aria-pressed": g === r,
1033
+ disabled: P || m,
1034
+ "data-notes-panel-edit": "",
1035
+ "data-note-action": "edit",
1036
+ onClick: () => g === r ? ue() : Sn(n)
1037
+ }
1038
+ ) : null,
1039
+ K && r && !n.deleted && (e == null ? void 0 : e.delete) !== !1 ? /* @__PURE__ */ a(
1040
+ bt,
1041
+ {
1042
+ icon: /* @__PURE__ */ a(sr, {}),
1043
+ intent: "ghost",
1044
+ size: "sm",
1045
+ "aria-label": l("notesPanel.deleteNamed", {
1046
+ date: ce(n),
1047
+ defaultValue: "Delete note · {{date}}"
1048
+ }),
1049
+ tooltip: l("notesPanel.delete", {
1050
+ defaultValue: "Delete note"
1051
+ }),
1052
+ "data-note-action": "delete",
1053
+ "aria-disabled": x || k || void 0,
1054
+ "aria-busy": x || void 0,
1055
+ onClick: () => An(r)
1056
+ }
1057
+ ) : null
1058
+ ] }),
1059
+ ...n,
1060
+ pinned: Re(n),
1061
+ flagged: Cn(n),
1062
+ pinPending: !!(c != null && c.pin) || m,
1063
+ flagPending: !!(c != null && c.flag) || m,
1064
+ onTogglePin: He && r && (e == null ? void 0 : e.pin) !== !1 && !n.deleted ? () => je(r, "pin") : void 0,
1065
+ onToggleFlag: We && r && (e == null ? void 0 : e.flag) !== !1 && !n.deleted ? () => je(r, "flag") : void 0
1066
+ }
1067
+ )
1068
+ ]
1069
+ },
1070
+ n.id ?? i
1071
+ );
1072
+ })
1073
+ }
1074
+ ) : w !== "ready" ? null : (
1075
+ /* Where focus lands, from script, when the last note leaves. */
1076
+ /* @__PURE__ */ a("div", { "data-notes-panel-empty": "", className: Ft, children: cn ?? /* @__PURE__ */ a("p", { className: "ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]", children: l("notesPanel.empty", { defaultValue: "No notes yet." }) }) })
1077
+ )
1078
+ ] }),
1079
+ K && Ke ? /* @__PURE__ */ a(
1080
+ L,
1081
+ {
1082
+ scope: "container",
1083
+ open: Ve,
1084
+ onOpenChange: (e) => !e && Z(null),
1085
+ children: /* @__PURE__ */ b(
1086
+ L.Content,
1087
+ {
1088
+ variant: "alert",
1089
+ size: "sm",
1090
+ onCloseAutoFocus: jn,
1091
+ children: [
1092
+ /* @__PURE__ */ a(L.Header, { children: /* @__PURE__ */ a(L.Title, { children: l("notesPanel.deleteConfirmTitle", {
1093
+ defaultValue: "Delete this note?"
1094
+ }) }) }),
1095
+ /* @__PURE__ */ a(L.Body, { children: /* @__PURE__ */ a(L.Description, { children: l("notesPanel.deleteConfirmBody", {
1096
+ defaultValue: "The note will be removed from the record."
1097
+ }) }) }),
1098
+ /* @__PURE__ */ b(L.Footer, { children: [
1099
+ /* @__PURE__ */ a(L.Close, { asChild: !0, children: /* @__PURE__ */ a(
1100
+ re,
1101
+ {
1102
+ intent: "secondary",
1103
+ size: "sm",
1104
+ onClick: () => Z(null),
1105
+ children: l("notesPanel.deleteConfirmCancel", {
1106
+ defaultValue: "Cancel"
1107
+ })
1108
+ }
1109
+ ) }),
1110
+ /* @__PURE__ */ a(
1111
+ re,
1112
+ {
1113
+ intent: "destructive",
1114
+ size: "sm",
1115
+ onClick: Fn,
1116
+ children: l("notesPanel.deleteConfirmAction", {
1117
+ defaultValue: "Delete"
1118
+ })
1119
+ }
1120
+ )
1121
+ ] })
1122
+ ]
1123
+ }
1124
+ )
1125
+ }
1126
+ ) : null
1127
+ ]
1128
+ }
1129
+ );
1130
+ }
1131
+ );
1132
+ export {
1133
+ Mr as N
1134
+ };
1135
+ //# sourceMappingURL=notes-panel-Cw06dLDm.js.map