@alfadocs/ui-kit-debug 1.42.0 → 1.44.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.
- package/dist/_chunks/{calendar-ChJQzRw-.js → calendar-U6N0F99w.js} +383 -359
- package/dist/_chunks/calendar-U6N0F99w.js.map +1 -0
- package/dist/_chunks/calendar-workspace-DBYAtdyd.js +12161 -0
- package/dist/_chunks/calendar-workspace-DBYAtdyd.js.map +1 -0
- package/dist/_chunks/control-room-rail-Cv7GpMqX.js +354 -0
- package/dist/_chunks/control-room-rail-Cv7GpMqX.js.map +1 -0
- package/dist/_chunks/{face-scheme-Dg6ZyLKb.js → face-scheme-Bm6pe7R8.js} +265 -275
- package/dist/_chunks/face-scheme-Bm6pe7R8.js.map +1 -0
- package/dist/_chunks/help-me-write-templates-GUeEn3Ff.js +741 -0
- package/dist/_chunks/help-me-write-templates-GUeEn3Ff.js.map +1 -0
- package/dist/_chunks/{marketplace-app-shell-D_g9BaDI.js → marketplace-app-shell-DdwPj03y.js} +3 -3
- package/dist/_chunks/{marketplace-app-shell-D_g9BaDI.js.map → marketplace-app-shell-DdwPj03y.js.map} +1 -1
- package/dist/_chunks/{notes-panel-CRAovkjx.js → notes-panel-CY4KmDo-.js} +159 -152
- package/dist/_chunks/notes-panel-CY4KmDo-.js.map +1 -0
- package/dist/_chunks/{panel-subview-PMBRPFOa.js → panel-subview-CYnuX-KR.js} +61 -40
- package/dist/_chunks/panel-subview-CYnuX-KR.js.map +1 -0
- package/dist/_chunks/rich-text-editor-BYE6kK4u.js +3839 -0
- package/dist/_chunks/rich-text-editor-BYE6kK4u.js.map +1 -0
- package/dist/_chunks/{sidebar-ClTY9lLI.js → sidebar-DbZXLl8h.js} +2 -2
- package/dist/_chunks/{sidebar-ClTY9lLI.js.map → sidebar-DbZXLl8h.js.map} +1 -1
- package/dist/_chunks/tab-bar-Cw9UK18Z.js +228 -0
- package/dist/_chunks/tab-bar-Cw9UK18Z.js.map +1 -0
- package/dist/_chunks/{tool-rail-D89USYE6.js → tool-rail-CCFqDfAn.js} +282 -276
- package/dist/_chunks/tool-rail-CCFqDfAn.js.map +1 -0
- package/dist/_chunks/undo-2-CYNAzclj.js +26 -0
- package/dist/_chunks/undo-2-CYNAzclj.js.map +1 -0
- package/dist/_chunks/use-edge-resize-BHesP0kg.js +149 -0
- package/dist/_chunks/use-edge-resize-BHesP0kg.js.map +1 -0
- package/dist/_chunks/use-scroll-overflow-UbLrUfBo.js +72 -0
- package/dist/_chunks/use-scroll-overflow-UbLrUfBo.js.map +1 -0
- package/dist/_chunks/variables-menu-vXUaSBj4.js +401 -0
- package/dist/_chunks/variables-menu-vXUaSBj4.js.map +1 -0
- package/dist/agent-catalog.json +84 -3
- package/dist/agent-i18n/en.json +14 -3
- package/dist/components/calendar/calendar.d.ts +6 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.js +1 -1
- package/dist/components/control-room-rail/control-room-rail.d.ts +9 -0
- package/dist/components/control-room-rail/control-room-rail.d.ts.map +1 -1
- package/dist/components/control-room-rail/index.js +1 -1
- package/dist/components/face-scheme/index.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/notes-panel/notes-panel.d.ts +4 -0
- package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
- package/dist/components/panel-subview/index.js +1 -1
- package/dist/components/panel-subview/panel-subview.d.ts +6 -0
- package/dist/components/panel-subview/panel-subview.d.ts.map +1 -1
- package/dist/components/rich-text-editor/editor-toolbar.d.ts +35 -3
- package/dist/components/rich-text-editor/editor-toolbar.d.ts.map +1 -1
- package/dist/components/rich-text-editor/index.d.ts +1 -1
- package/dist/components/rich-text-editor/index.d.ts.map +1 -1
- package/dist/components/rich-text-editor/index.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.agent.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.d.ts +98 -15
- package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
- package/dist/components/sidebar/index.js +1 -1
- package/dist/components/tab-bar/index.js +1 -1
- package/dist/components/tool-rail/index.js +1 -1
- package/dist/components/tool-rail/tool-rail.d.ts +16 -0
- package/dist/components/tool-rail/tool-rail.d.ts.map +1 -1
- package/dist/components/variables-menu/index.d.ts +4 -0
- package/dist/components/variables-menu/index.d.ts.map +1 -0
- package/dist/components/variables-menu/index.js +6 -0
- package/dist/components/variables-menu/index.js.map +1 -0
- package/dist/components/variables-menu/variables-menu.agent.d.ts +10 -0
- package/dist/components/variables-menu/variables-menu.agent.d.ts.map +1 -0
- package/dist/components/variables-menu/variables-menu.d.ts +53 -0
- package/dist/components/variables-menu/variables-menu.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +35 -32
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-edge-resize.d.ts +13 -1
- package/dist/hooks/use-edge-resize.d.ts.map +1 -1
- package/dist/host-compat.css +5 -5
- package/dist/i18n/locales/ar.d.ts +77 -6
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +78 -7
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +77 -6
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +78 -7
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +77 -6
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +78 -7
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +77 -6
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +85 -7
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +77 -6
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +78 -7
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +77 -6
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +78 -7
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +77 -6
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +78 -7
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +77 -6
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +78 -7
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +77 -6
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +78 -7
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +77 -6
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +78 -7
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +77 -6
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +78 -7
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +77 -6
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +78 -7
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +77 -6
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +78 -7
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +77 -6
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +78 -7
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +77 -6
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +78 -7
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +77 -6
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +78 -7
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +77 -6
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +78 -7
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +77 -6
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +78 -7
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +916 -913
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +78 -7
- package/dist/locales/de.json +78 -7
- package/dist/locales/el.json +78 -7
- package/dist/locales/en.json +78 -7
- package/dist/locales/es.json +78 -7
- package/dist/locales/fr.json +78 -7
- package/dist/locales/hi.json +78 -7
- package/dist/locales/it.json +78 -7
- package/dist/locales/ja.json +78 -7
- package/dist/locales/nl.json +78 -7
- package/dist/locales/pl.json +78 -7
- package/dist/locales/pt.json +78 -7
- package/dist/locales/ro.json +78 -7
- package/dist/locales/ru.json +78 -7
- package/dist/locales/sq.json +78 -7
- package/dist/locales/sv.json +78 -7
- package/dist/locales/tr.json +78 -7
- package/dist/locales/zh.json +78 -7
- package/dist/patterns/calendar/calendar-bookings-panel.d.ts +8 -3
- package/dist/patterns/calendar/calendar-bookings-panel.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar-care-rules.d.ts +49 -0
- package/dist/patterns/calendar/calendar-care-rules.d.ts.map +1 -0
- package/dist/patterns/calendar/calendar-task-editor.d.ts +31 -0
- package/dist/patterns/calendar/calendar-task-editor.d.ts.map +1 -0
- package/dist/patterns/calendar/calendar-waiting-list-panel.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar-workspace.d.ts +8 -1
- package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar-workspace.model.d.ts +39 -12
- package/dist/patterns/calendar/calendar-workspace.model.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.data.d.ts +9 -0
- package/dist/patterns/calendar/calendar.data.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.journey.d.ts +35 -3
- package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.model.d.ts +23 -1
- package/dist/patterns/calendar/calendar.model.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.sheets.d.ts +21 -3
- package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.surface.d.ts +6 -1
- package/dist/patterns/calendar/calendar.surface.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.types.d.ts +32 -1
- package/dist/patterns/calendar/calendar.types.d.ts.map +1 -1
- package/dist/patterns/calendar/index.js +1 -1
- package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +58 -26
- package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts.map +1 -1
- package/dist/patterns/help-me-write-templates/index.d.ts +1 -1
- package/dist/patterns/help-me-write-templates/index.d.ts.map +1 -1
- package/dist/patterns/help-me-write-templates/index.js +1 -1
- package/dist/patterns/marketplace-app-shell/index.js +1 -1
- package/dist/tokens.css +6 -6
- package/package.json +5 -1
- package/dist/_chunks/calendar-ChJQzRw-.js.map +0 -1
- package/dist/_chunks/calendar-workspace-qlxrxCqm.js +0 -11392
- package/dist/_chunks/calendar-workspace-qlxrxCqm.js.map +0 -1
- package/dist/_chunks/control-room-rail-CnNZusR5.js +0 -337
- package/dist/_chunks/control-room-rail-CnNZusR5.js.map +0 -1
- package/dist/_chunks/face-scheme-Dg6ZyLKb.js.map +0 -1
- package/dist/_chunks/help-me-write-templates-B-m7zgJa.js +0 -775
- package/dist/_chunks/help-me-write-templates-B-m7zgJa.js.map +0 -1
- package/dist/_chunks/highlighter-DSkckT2Q.js +0 -15
- package/dist/_chunks/highlighter-DSkckT2Q.js.map +0 -1
- package/dist/_chunks/notes-panel-CRAovkjx.js.map +0 -1
- package/dist/_chunks/panel-subview-PMBRPFOa.js.map +0 -1
- package/dist/_chunks/rich-text-editor-DUMeifwc.js +0 -3176
- package/dist/_chunks/rich-text-editor-DUMeifwc.js.map +0 -1
- package/dist/_chunks/tab-bar-rDkLiaA6.js +0 -268
- package/dist/_chunks/tab-bar-rDkLiaA6.js.map +0 -1
- package/dist/_chunks/tool-rail-D89USYE6.js.map +0 -1
- package/dist/_chunks/use-edge-resize-ZnGG7gyO.js +0 -139
- package/dist/_chunks/use-edge-resize-ZnGG7gyO.js.map +0 -1
- package/dist/_chunks/use-overflow-collapse-BIOzKbni.js +0 -32
- package/dist/_chunks/use-overflow-collapse-BIOzKbni.js.map +0 -1
- package/dist/_chunks/wand-sparkles-DAjKyhz7.js +0 -27
- package/dist/_chunks/wand-sparkles-DAjKyhz7.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help-me-write-templates-B-m7zgJa.js","sources":["../../src/patterns/help-me-write-templates/help-me-write-templates.tsx"],"sourcesContent":["/**\n * Help me write templates (HTP-6383) — practice-shared AI templates inside the\n * RichTextEditor's \"Help me write\".\n *\n * Runtime pattern: real consuming apps mount this in production (surfaced via\n * `src/patterns/index.ts` and the `./patterns/help-me-write-templates`\n * subpath). It plugs into the editor through `renderHelpMeWrite`, so the kit\n * editor keeps its own AI pill, the patient AI-consent gate and the\n * resume-after-grant; this pattern supplies the bar that opens from it.\n *\n * Parts, usable on their own or wired together by `useHelpMeWriteTemplates`:\n * - `HelpMeWriteTemplatesBar` — the docked bar: free prompt with an optional\n * mic, a Templates menu, a side-by-side compare, Replace / Insert below.\n * - `AiTemplateManager` — the dialog to list, create, edit and delete\n * templates and pick the default.\n * - `AiCreditsExhaustedNotice` — the out-of-credits state the bar shows when\n * `onGenerate` rejects with `AiCreditsExhaustedError`.\n * - `HelpMeWriteUndoNotice` — the success notice with Undo after a template\n * rewrote the note.\n *\n * The host owns the templates (list + persistence) and the AI call. The kit\n * never talks to a backend.\n */\nimport {\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n ArrowLeft,\n Astroid,\n ChevronDown,\n Mic,\n Pencil,\n Plus,\n RotateCcw,\n Send,\n Settings,\n Square,\n Trash2,\n TrendingUp,\n WandSparkles,\n X,\n} from 'lucide-react';\n\nimport { Alert } from '../../components/alert';\nimport { Badge } from '../../components/badge';\nimport { Button, IconButton } from '../../components/button';\nimport { Dialog } from '../../components/dialog';\nimport { DropdownMenu } from '../../components/dropdown-menu';\nimport { EditorOverlay } from '../../components/editor-overlay';\nimport { EmptyState } from '../../components/empty-state';\nimport { FormField } from '../../components/form-field';\nimport { Progress } from '../../components/progress';\nimport type { HelpMeWriteRenderContext } from '../../components/rich-text-editor';\nimport { Spinner } from '../../components/spinner';\nimport { Switch } from '../../components/switch';\nimport { TextArea } from '../../components/text-area';\nimport { TextInput } from '../../components/text-input';\nimport { SafeHtml } from '../../components/_shared/safe-html';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\n/** A practice-shared AI template. */\nexport interface AiTemplate {\n id: string;\n /** Up to 100 characters, unique within the practice. */\n name: string;\n /** One line under the name in the Templates menu. */\n description?: string;\n /** The instructions sent to the AI, up to 4000 characters. */\n prompt: string;\n /** At most one per practice; listed first with a Default badge. */\n isDefault: boolean;\n}\n\n/** What the manager hands `onSaveTemplate`: `id` is absent for a new one. */\nexport type AiTemplateDraft = Omit<AiTemplate, 'id'> & { id?: string };\n\n/** One Help-me-write request. `template` is absent for a free prompt. */\nexport interface HelpMeWriteRequest {\n template?: AiTemplate;\n /** The free prompt, or extra instructions for a template. May be ''. */\n prompt: string;\n /** Plain text the template rewrites: the selection, else the whole note. */\n sourceText: string;\n signal: AbortSignal;\n}\n\n/**\n * Throw (or reject with) this from `onGenerate` when the practice is out of\n * AI credits (the platform endpoint's 402), and the bar shows the\n * out-of-credits notice instead of a generic error.\n */\nexport class AiCreditsExhaustedError extends Error {\n constructor(message = 'AI credits exhausted') {\n super(message);\n this.name = 'AiCreditsExhaustedError';\n }\n}\n\n/** The practice's allowance, for the out-of-credits notice. All optional. */\nexport interface AiCreditsInfo {\n remaining?: number;\n limit?: number;\n /** When the monthly allowance returns. */\n resetsOn?: Date;\n /**\n * Shows a \"Buy AI credits\" button and \"add credits\" wording. Omit while\n * credits cannot be bought: the notice then only says when AI returns.\n */\n onBuyCredits?: () => void;\n /** Shows a \"See what each action costs\" link. */\n onSeeCosts?: () => void;\n}\n\nexport type HelpMeWriteApplyMode = 'replace' | 'below' | 'insert';\n\n/** Fired after a draft lands in the editor. */\nexport interface HelpMeWriteApplied {\n mode: HelpMeWriteApplyMode;\n template?: AiTemplate;\n /** The editor's HTML before the change. */\n previousHtml: string;\n /** Puts `previousHtml` back in the editor (what Undo does). */\n undo: () => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Shared classes */\n/* ------------------------------------------------------------------ */\n\n// Match the composer's input height (--min-target-size), like the kit bar.\nconst ACTION_SIZE = 'ds:!size-[var(--min-target-size)]';\nconst MENU_TRIGGER = 'ds:!h-[var(--min-target-size)] ds:shrink-0';\nconst BRAND_ACTION = `${ACTION_SIZE} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`;\n// The recording mic goes solid destructive, as in the kit's own bar.\nconst RECORDING_MIC =\n 'ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]';\nconst metaClass =\n 'ds:m-0 ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]';\nconst eyebrowClass =\n 'type-eyebrow ds:m-0 ds:text-[color:var(--muted-foreground)]';\nconst previewClass = [\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]',\n 'ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]',\n 'ds:p-[var(--spacing-sm)] ds:[max-block-size:14rem] ds:overflow-y-auto',\n 'ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]',\n 'ds:[&_ul]:list-disc ds:[&_ul]:ps-[var(--spacing-md)]',\n 'ds:[&_h3]:font-medium ds:[&_h3]:[margin-block-start:var(--spacing-xs)]',\n 'ds:[&_p]:[margin-block-end:var(--spacing-xs)]',\n 'ds:[&>:first-child]:[margin-block-start:0]',\n].join(' ');\n// Side by side, both boxes take the same fixed height (each scrolls), so the\n// note and the draft line up whatever their length.\nconst compareBoxClass = 'ds:[block-size:14rem]';\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\n// Default template first, then the rest in their saved order.\nfunction orderTemplates(templates: AiTemplate[]): AiTemplate[] {\n return [...templates].sort(\n (a, b) => Number(b.isDefault) - Number(a.isDefault),\n );\n}\n\n// Join dictated text onto the prompt with a single space.\nfunction joinWith(base: string, extra: string): string {\n if (!extra) return base;\n if (!base) return extra;\n return /\\s$/.test(base) ? `${base}${extra}` : `${base} ${extra}`;\n}\n\nfunction isAbort(err: unknown): boolean {\n return (\n typeof err === 'object' &&\n err !== null &&\n 'name' in err &&\n (err as { name?: string }).name === 'AbortError'\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* AiCreditsExhaustedNotice */\n/* ------------------------------------------------------------------ */\n\nexport interface AiCreditsExhaustedNoticeProps {\n credits?: AiCreditsInfo;\n /** Shows a Back button (the bar uses it to return to the prompt). */\n onBack?: () => void;\n}\n\n/** The out-of-credits state: what happened, the allowance, and the ways on. */\nexport function AiCreditsExhaustedNotice({\n credits,\n onBack,\n}: AiCreditsExhaustedNoticeProps): React.JSX.Element {\n const { t, i18n } = useTranslation();\n const limit = credits?.limit;\n const remaining = credits?.remaining ?? 0;\n const remainingText =\n limit !== undefined\n ? t('helpMeWriteTemplates.credits.remaining', { remaining, limit })\n : undefined;\n const resetsOn = credits?.resetsOn\n ? new Intl.DateTimeFormat(i18n.language, {\n day: 'numeric',\n month: 'long',\n }).format(credits.resetsOn)\n : undefined;\n return (\n <div\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n data-component=\"ai-credits-exhausted-notice\"\n >\n <Alert variant=\"promo\" icon={<Astroid aria-hidden=\"true\" />}>\n <Alert.Title as=\"h2\">\n {t('helpMeWriteTemplates.credits.title')}\n </Alert.Title>\n <Alert.Description>\n {/* Without a way to buy credits, only say when AI comes back. */}\n {credits?.onBuyCredits\n ? resetsOn\n ? t('helpMeWriteTemplates.credits.bodyResets', { date: resetsOn })\n : t('helpMeWriteTemplates.credits.body')\n : resetsOn\n ? t('helpMeWriteTemplates.credits.bodyWaitResets', {\n date: resetsOn,\n })\n : t('helpMeWriteTemplates.credits.bodyWait')}\n </Alert.Description>\n {limit !== undefined && remainingText ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)] ds:[margin-block-start:var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label\">\n {t('helpMeWriteTemplates.credits.meterLabel')}\n </span>\n <span className=\"type-label ds:ms-auto ds:tabular-nums\">\n {remainingText}\n </span>\n </div>\n <Progress\n value={Math.max(0, limit - remaining)}\n max={limit}\n size=\"sm\"\n ariaLabel={t('helpMeWriteTemplates.credits.meterLabel')}\n ariaValueText={remainingText}\n />\n </div>\n ) : null}\n {credits?.onBuyCredits || credits?.onSeeCosts ? (\n <Alert.Action>\n {credits.onBuyCredits ? (\n <Button\n intent=\"tonal\"\n size=\"sm\"\n startIcon={<TrendingUp aria-hidden=\"true\" />}\n onClick={credits.onBuyCredits}\n >\n {t('helpMeWriteTemplates.credits.cta')}\n </Button>\n ) : null}\n {credits.onSeeCosts ? (\n <Button intent=\"link\" size=\"sm\" onClick={credits.onSeeCosts}>\n {t('helpMeWriteTemplates.credits.secondary')}\n </Button>\n ) : null}\n </Alert.Action>\n ) : null}\n </Alert>\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]\">\n {onBack ? (\n <Button intent=\"ghost\" startIcon={<ArrowLeft />} onClick={onBack}>\n {t('helpMeWriteTemplates.credits.back')}\n </Button>\n ) : null}\n <p className={metaClass}>{t('helpMeWriteTemplates.credits.kept')}</p>\n </div>\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* HelpMeWriteTemplatesBar */\n/* ------------------------------------------------------------------ */\n\nexport interface HelpMeWriteTemplatesBarProps {\n /** What `RichTextEditor`'s `renderHelpMeWrite` hands its host. */\n context: HelpMeWriteRenderContext;\n templates: AiTemplate[];\n /** The AI call. Reject with `AiCreditsExhaustedError` when out of credits. */\n onGenerate: (request: HelpMeWriteRequest) => Promise<string>;\n /**\n * Opens the template manager. Omit to hide \"Manage templates\" and\n * \"Create your first template\" (e.g. for readers who may not manage).\n */\n onManageTemplates?: (mode: 'list' | 'create') => void;\n /** After a draft lands; the hook uses it for Undo. */\n onApplied?: (applied: HelpMeWriteApplied) => void;\n /** Shown in the out-of-credits notice. */\n credits?: AiCreditsInfo;\n /** Show the mic in the prompt when the editor has `onDictate`. Default true. */\n enableDictation?: boolean;\n /** Ignore Escape (e.g. while the manager dialog above it is open). */\n suspendClose?: boolean;\n}\n\ninterface SourceInfo {\n kind: 'selection' | 'document';\n words: number;\n text: string;\n}\n\n/** The Help-me-write bar with templates, docked in the editor's AI slot. */\nexport function HelpMeWriteTemplatesBar({\n context,\n templates,\n onGenerate,\n onManageTemplates,\n onApplied,\n credits,\n enableDictation = true,\n suspendClose = false,\n}: HelpMeWriteTemplatesBarProps): React.JSX.Element {\n const { t } = useTranslation();\n const { open } = context;\n const sourceId = useId();\n const errorId = useId();\n const [prompt, setPrompt] = useState('');\n // `undefined` = free prompt running; a template = that template is running.\n const [running, setRunning] = useState<AiTemplate | undefined | null>(null);\n const [errored, setErrored] = useState(false);\n const [outOfCredits, setOutOfCredits] = useState(false);\n const [result, setResult] = useState<{\n draft: string;\n template?: AiTemplate;\n } | null>(null);\n const [source, setSource] = useState<SourceInfo>({\n kind: 'document',\n words: 0,\n text: '',\n });\n const abortRef = useRef<AbortController | null>(null);\n const loading = running !== null;\n const onDictate = enableDictation ? context.onDictate : undefined;\n\n /* ---- Mic in the prompt (the editor's own dictation seam) ---- */\n const [isDictating, setIsDictating] = useState(false);\n const [interim, setInterim] = useState('');\n const [announcement, setAnnouncement] = useState('');\n const dictateAbortRef = useRef<AbortController | null>(null);\n const stopDictation = useCallback(() => dictateAbortRef.current?.abort(), []);\n const toggleDictation = useCallback(() => {\n if (isDictating) {\n stopDictation();\n return;\n }\n if (!onDictate) return;\n const controller = new AbortController();\n dictateAbortRef.current = controller;\n setIsDictating(true);\n setAnnouncement(t('helpMeWriteTemplates.bar.listening'));\n onDictate({\n signal: controller.signal,\n onPartialTranscript: (text) => {\n if (!controller.signal.aborted) setInterim(text);\n },\n onFinalTranscript: (text) => {\n if (controller.signal.aborted) return;\n setInterim('');\n const trimmed = text.trim();\n if (trimmed) {\n setPrompt((p) => joinWith(p, trimmed));\n setAnnouncement(trimmed);\n }\n },\n })\n .catch((err: unknown) => {\n // Out of credits shows the notice; other dictation errors are\n // non-fatal (the user can type instead).\n if (err instanceof AiCreditsExhaustedError) setOutOfCredits(true);\n })\n .finally(() => {\n setInterim('');\n if (dictateAbortRef.current === controller) {\n dictateAbortRef.current = null;\n setIsDictating(false);\n setAnnouncement('');\n }\n });\n }, [isDictating, onDictate, stopDictation, t]);\n\n // Each open starts fresh and reads what a template would rewrite.\n useEffect(() => {\n if (open) {\n setPrompt('');\n setRunning(null);\n setErrored(false);\n // Opened by a dictation that ran out of credits: start on the notice.\n setOutOfCredits(context.creditsExhausted);\n setResult(null);\n const selection = context.selectionText.trim();\n const text = selection || context.getText();\n setSource({\n kind: selection ? 'selection' : 'document',\n words: text.split(/\\s+/).filter(Boolean).length,\n text,\n });\n } else {\n abortRef.current?.abort();\n dictateAbortRef.current?.abort();\n }\n // Only on open/close; `context` is a fresh object every editor render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n useEffect(\n () => () => {\n abortRef.current?.abort();\n dictateAbortRef.current?.abort();\n },\n [],\n );\n\n const run = useCallback(\n (template: AiTemplate | undefined) => {\n if (loading) return;\n if (template ? source.words === 0 : !prompt.trim()) return;\n stopDictation();\n abortRef.current?.abort();\n const controller = new AbortController();\n abortRef.current = controller;\n setErrored(false);\n setRunning(template);\n onGenerate({\n template,\n prompt: prompt.trim(),\n sourceText: template ? source.text : '',\n signal: controller.signal,\n })\n .then((draft) => {\n if (controller.signal.aborted) return;\n setResult({ draft, template });\n setRunning(null);\n })\n .catch((err: unknown) => {\n if (controller.signal.aborted || isAbort(err)) return;\n if (err instanceof AiCreditsExhaustedError) setOutOfCredits(true);\n else setErrored(true);\n setRunning(null);\n });\n },\n [loading, source, prompt, onGenerate, stopDictation],\n );\n\n const { onClose: contextClose } = context;\n const close = useCallback(() => {\n if (suspendClose) return;\n contextClose();\n }, [suspendClose, contextClose]);\n\n const apply = (mode: HelpMeWriteApplyMode) => {\n if (!result) return;\n const { draft, template } = result;\n const previousHtml = context.getHTML();\n const selected = source.kind === 'selection';\n if (mode === 'insert') {\n context.insertAtSelection(draft);\n } else if (mode === 'replace') {\n if (selected) context.insertAtSelection(draft);\n else context.setContent(draft);\n } else if (selected) {\n context.insertAfterSelection(draft);\n } else {\n context.setContent(`${previousHtml}${draft}`);\n }\n context.onClose();\n const { setContent } = context;\n onApplied?.({\n mode,\n template,\n previousHtml,\n undo: () => setContent(previousHtml),\n });\n };\n\n const sourceLine =\n source.words === 0\n ? t('helpMeWriteTemplates.bar.sourceEmpty')\n : source.kind === 'selection'\n ? t('helpMeWriteTemplates.bar.sourceSelection')\n : t('helpMeWriteTemplates.bar.sourceDocument');\n\n let body: ReactNode;\n if (outOfCredits) {\n body = (\n <AiCreditsExhaustedNotice\n credits={credits}\n onBack={() => setOutOfCredits(false)}\n />\n );\n } else if (result) {\n const compare = Boolean(result.template);\n body = (\n <>\n <div\n className={\n compare\n ? 'ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:lg:grid-cols-2'\n : 'ds:grid ds:grid-cols-1'\n }\n >\n {compare ? (\n <section\n aria-labelledby={`${sourceId}-before`}\n className=\"ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]\"\n >\n <h2 id={`${sourceId}-before`} className={eyebrowClass}>\n {source.kind === 'selection'\n ? t('helpMeWriteTemplates.bar.beforeSelection')\n : t('helpMeWriteTemplates.bar.beforeDocument')}\n </h2>\n <p\n className={`${previewClass} ${compareBoxClass} ds:text-[color:var(--muted-foreground)]`}\n // Focusable so a keyboard user can scroll a long note.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n >\n {source.text}\n </p>\n </section>\n ) : null}\n <section\n aria-labelledby={`${sourceId}-after`}\n className=\"ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]\"\n >\n <h2 id={`${sourceId}-after`} className={eyebrowClass}>\n {result.template\n ? `${t('helpMeWriteTemplates.bar.after')} · ${result.template.name}`\n : t('helpMeWriteTemplates.bar.after')}\n </h2>\n <SafeHtml\n html={result.draft}\n profile=\"rich-text\"\n className={\n compare ? `${previewClass} ${compareBoxClass}` : previewClass\n }\n tabIndex={0}\n />\n </section>\n </div>\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]\">\n <Button intent=\"ghost\" startIcon={<X />} onClick={context.onClose}>\n {t('helpMeWriteTemplates.bar.discard')}\n </Button>\n <Button\n intent=\"ghost\"\n startIcon={<RotateCcw />}\n onClick={() => {\n setResult(null);\n run(result.template);\n }}\n >\n {t('helpMeWriteTemplates.bar.retry')}\n </Button>\n <span className=\"ds:flex-1\" aria-hidden=\"true\" />\n {compare ? (\n <>\n <Button intent=\"outline\" onClick={() => apply('below')}>\n {t('helpMeWriteTemplates.bar.insertBelow')}\n </Button>\n <Button intent=\"primary\" onClick={() => apply('replace')}>\n {t('helpMeWriteTemplates.bar.replace')}\n </Button>\n </>\n ) : (\n <Button intent=\"primary\" onClick={() => apply('insert')}>\n {t('helpMeWriteTemplates.bar.insert')}\n </Button>\n )}\n </div>\n </>\n );\n } else {\n const ordered = orderTemplates(templates);\n // While dictating the field shows the committed prompt plus live interim\n // text, read-only so the stream is not fought over by typing.\n const fieldValue = isDictating ? joinWith(prompt, interim) : prompt;\n const showTemplatesMenu = templates.length > 0 || onManageTemplates;\n body = (\n <>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <IconButton\n size=\"md\"\n intent=\"outline\"\n className={ACTION_SIZE}\n icon={<X />}\n aria-label={t('helpMeWriteTemplates.bar.close')}\n onClick={context.onClose}\n />\n <div className=\"ds:min-w-0 ds:flex-1\">\n <TextArea\n size=\"md\"\n value={fieldValue}\n onChange={(event) => setPrompt(event.target.value)}\n placeholder={t('helpMeWriteTemplates.bar.prompt')}\n aria-label={t('helpMeWriteTemplates.bar.prompt')}\n autoResize\n minRows={1}\n maxRows={3}\n readOnly={loading || isDictating}\n tone={errored ? 'error' : 'default'}\n aria-describedby={errored ? errorId : undefined}\n />\n </div>\n {onDictate ? (\n <IconButton\n size=\"md\"\n intent=\"outline\"\n className={\n isDictating ? `${ACTION_SIZE} ${RECORDING_MIC}` : ACTION_SIZE\n }\n icon={\n isDictating ? <Square className=\"ds:fill-current\" /> : <Mic />\n }\n aria-pressed={isDictating}\n aria-label={\n isDictating\n ? t('helpMeWriteTemplates.bar.dictateStop')\n : t('helpMeWriteTemplates.bar.dictateStart')\n }\n disabled={loading}\n onClick={toggleDictation}\n />\n ) : null}\n {showTemplatesMenu ? (\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <Button\n intent=\"outline\"\n size=\"md\"\n className={MENU_TRIGGER}\n startIcon={\n running ? (\n <Spinner size=\"sm\" variant=\"pulse\" />\n ) : (\n <WandSparkles aria-hidden=\"true\" />\n )\n }\n endIcon={<ChevronDown aria-hidden=\"true\" />}\n aria-haspopup=\"menu\"\n aria-busy={running ? true : undefined}\n disabled={loading}\n aria-describedby={sourceId}\n >\n {t('helpMeWriteTemplates.bar.templatesMenu')}\n </Button>\n </DropdownMenu.Trigger>\n {/* The bar is docked at the editor's bottom edge, so the menu opens upward. */}\n <DropdownMenu.Content side=\"top\" align=\"end\" sideOffset={8}>\n <DropdownMenu.Label>\n {t('helpMeWriteTemplates.bar.templatesGroup')}\n </DropdownMenu.Label>\n {ordered.map((tpl) => (\n <DropdownMenu.Item\n key={tpl.id}\n startIcon={<WandSparkles />}\n description={tpl.description || undefined}\n // Only the run items disable on an empty note; the\n // library itself stays readable.\n disabled={loading || source.words === 0}\n onSelect={() => run(tpl)}\n >\n {/* The badge sits in the label, not `endIcon`: that slot\n is a 16px aria-hidden box, which would clip the badge\n and hide \"Default\" from screen readers. */}\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n {tpl.name}\n {tpl.isDefault ? (\n <Badge variant=\"brand\" size=\"sm\">\n {t('helpMeWriteTemplates.bar.defaultBadge')}\n </Badge>\n ) : null}\n </span>\n </DropdownMenu.Item>\n ))}\n {onManageTemplates && templates.length === 0 ? (\n <DropdownMenu.Item\n startIcon={<Plus />}\n onSelect={() => onManageTemplates('create')}\n >\n {t('helpMeWriteTemplates.bar.createFirst')}\n </DropdownMenu.Item>\n ) : null}\n {onManageTemplates && templates.length > 0 ? (\n <>\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n startIcon={<Settings />}\n onSelect={() => onManageTemplates('list')}\n >\n {t('helpMeWriteTemplates.bar.manage')}\n </DropdownMenu.Item>\n </>\n ) : null}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n ) : null}\n <IconButton\n size=\"md\"\n intent=\"primary\"\n className={BRAND_ACTION}\n icon={\n running === undefined ? (\n <Spinner size=\"sm\" variant=\"pulse\" />\n ) : (\n <Send />\n )\n }\n disabled={loading || !prompt.trim()}\n aria-busy={running === undefined || undefined}\n aria-label={t('helpMeWriteTemplates.bar.write')}\n onClick={() => run(undefined)}\n />\n </div>\n {onDictate ? (\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {announcement}\n </p>\n ) : null}\n {errored ? (\n <p id={errorId} role=\"alert\" className={metaClass}>\n {t('helpMeWriteTemplates.bar.error')}\n </p>\n ) : null}\n <p id={sourceId} className={metaClass}>\n {sourceLine} {context.privacyNotice}\n </p>\n </>\n );\n }\n\n return (\n <EditorOverlay\n open={open}\n onClose={close}\n ariaLabel={t('editor.ai.helpMeWrite')}\n >\n <div className=\"ds:contents\" data-component=\"help-me-write-templates-bar\">\n {body}\n </div>\n </EditorOverlay>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* AiTemplateManager */\n/* ------------------------------------------------------------------ */\n\nexport interface AiTemplateManagerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Open on the list (default) or straight on a new-template form. */\n initialMode?: 'list' | 'create';\n templates: AiTemplate[];\n /** Persist a new (no `id`) or edited template. A rejection keeps the form open. */\n onSaveTemplate: (draft: AiTemplateDraft) => void | Promise<void>;\n /** Omit to hide Delete. */\n onDeleteTemplate?: (id: string) => void | Promise<void>;\n}\n\ninterface FormState {\n id?: string;\n name: string;\n description: string;\n prompt: string;\n isDefault: boolean;\n submitted: boolean;\n}\n\nconst EMPTY_FORM: FormState = {\n name: '',\n description: '',\n prompt: '',\n isDefault: false,\n submitted: false,\n};\n\n/** List, create, edit and delete the practice's templates. */\nexport function AiTemplateManager({\n open,\n onOpenChange,\n initialMode = 'list',\n templates,\n onSaveTemplate,\n onDeleteTemplate,\n}: AiTemplateManagerProps): React.JSX.Element {\n const { t } = useTranslation();\n const [form, setForm] = useState<FormState | null>(null);\n const [saving, setSaving] = useState(false);\n const [saveFailed, setSaveFailed] = useState(false);\n const [pendingDelete, setPendingDelete] = useState<AiTemplate | null>(null);\n const [deleting, setDeleting] = useState(false);\n const [deleteFailed, setDeleteFailed] = useState(false);\n\n // Wait for the host: the confirmation stays open (busy) until the delete\n // settles, and shows an error if it fails.\n const confirmDelete = async () => {\n if (!pendingDelete || deleting) return;\n setDeleting(true);\n setDeleteFailed(false);\n try {\n await onDeleteTemplate?.(pendingDelete.id);\n setPendingDelete(null);\n } catch {\n setDeleteFailed(true);\n } finally {\n setDeleting(false);\n }\n };\n\n useEffect(() => {\n if (open) {\n setSaveFailed(false);\n setForm(\n initialMode === 'create'\n ? { ...EMPTY_FORM, isDefault: templates.length === 0 }\n : null,\n );\n }\n // Only when it opens; `templates` changing mid-edit keeps the form.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const nameTaken = (name: string, id?: string): boolean =>\n templates.some(\n (tpl) => tpl.id !== id && tpl.name.toLowerCase() === name.toLowerCase(),\n );\n\n const nameError = (() => {\n if (!form?.submitted) return undefined;\n const name = form.name.trim();\n if (!name) return t('helpMeWriteTemplates.manager.nameRequired');\n return nameTaken(name, form.id)\n ? t('helpMeWriteTemplates.manager.nameTaken')\n : undefined;\n })();\n const promptError =\n form?.submitted && !form.prompt.trim()\n ? t('helpMeWriteTemplates.manager.promptRequired')\n : undefined;\n\n const save = async () => {\n if (!form || saving) return;\n const next = { ...form, submitted: true };\n setForm(next);\n const name = next.name.trim();\n const prompt = next.prompt.trim();\n if (!name || !prompt || nameTaken(name, next.id)) return;\n setSaving(true);\n setSaveFailed(false);\n try {\n await onSaveTemplate({\n id: next.id,\n name,\n description: next.description.trim() || undefined,\n prompt,\n isDefault: next.isDefault,\n });\n setForm(null);\n } catch {\n setSaveFailed(true);\n } finally {\n setSaving(false);\n }\n };\n\n const title = form\n ? form.id\n ? t('helpMeWriteTemplates.manager.formEdit')\n : t('helpMeWriteTemplates.manager.formNew')\n : t('helpMeWriteTemplates.manager.title');\n\n return (\n <>\n <Dialog open={open} onOpenChange={onOpenChange}>\n <Dialog.Content size=\"lg\">\n <div className=\"ds:contents\" data-component=\"ai-template-manager\">\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n <Dialog.Description>\n {t('helpMeWriteTemplates.manager.description')}\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {form ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n {saveFailed ? (\n <Alert variant=\"error\">\n {t('helpMeWriteTemplates.manager.saveError')}\n </Alert>\n ) : null}\n <FormField\n label={t('helpMeWriteTemplates.manager.name')}\n error={nameError}\n required\n >\n <TextInput\n value={form.name}\n maxLength={100}\n placeholder={t(\n 'helpMeWriteTemplates.manager.namePlaceholder',\n )}\n onChange={(event) =>\n setForm({ ...form, name: event.target.value })\n }\n />\n </FormField>\n <FormField\n label={t('helpMeWriteTemplates.manager.descLabel')}\n description={t('helpMeWriteTemplates.manager.descHint')}\n optional\n >\n <TextInput\n value={form.description}\n maxLength={120}\n onChange={(event) =>\n setForm({ ...form, description: event.target.value })\n }\n />\n </FormField>\n <FormField\n label={t('helpMeWriteTemplates.manager.prompt')}\n description={t(\n 'helpMeWriteTemplates.manager.promptDescription',\n )}\n error={promptError}\n required\n >\n <TextArea\n value={form.prompt}\n maxLength={4000}\n autoResize\n minRows={4}\n maxRows={10}\n onChange={(event) =>\n setForm({ ...form, prompt: event.target.value })\n }\n />\n </FormField>\n <Switch\n label={t('helpMeWriteTemplates.manager.isDefault')}\n checked={form.isDefault}\n onCheckedChange={(checked) =>\n setForm({ ...form, isDefault: checked })\n }\n />\n </div>\n ) : templates.length === 0 ? (\n <EmptyState\n variant=\"first-use\"\n size=\"sm\"\n title={t('helpMeWriteTemplates.manager.emptyTitle')}\n description={t(\n 'helpMeWriteTemplates.manager.emptyDescription',\n )}\n primaryAction={{\n label: t('helpMeWriteTemplates.manager.new'),\n onClick: () => setForm({ ...EMPTY_FORM, isDefault: true }),\n }}\n />\n ) : (\n <ul\n aria-label={t('helpMeWriteTemplates.manager.listLabel')}\n className=\"ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0\"\n >\n {orderTemplates(templates).map((tpl) => (\n <li\n key={tpl.id}\n className=\"ds:flex ds:items-start ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)] ds:p-[var(--spacing-sm)]\"\n >\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]\">\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-title-item ds:text-[color:var(--foreground)]\">\n {tpl.name}\n </span>\n {tpl.isDefault ? (\n <Badge variant=\"brand\" size=\"sm\">\n {t('helpMeWriteTemplates.bar.defaultBadge')}\n </Badge>\n ) : null}\n </div>\n <p className={`${metaClass} ds:line-clamp-2`}>\n {tpl.description || tpl.prompt}\n </p>\n </div>\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={<Pencil />}\n aria-label={t('helpMeWriteTemplates.manager.edit', {\n name: tpl.name,\n })}\n onClick={() =>\n setForm({\n id: tpl.id,\n name: tpl.name,\n description: tpl.description ?? '',\n prompt: tpl.prompt,\n isDefault: tpl.isDefault,\n submitted: false,\n })\n }\n />\n {onDeleteTemplate ? (\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={<Trash2 />}\n aria-label={t('helpMeWriteTemplates.manager.delete', {\n name: tpl.name,\n })}\n onClick={() => setPendingDelete(tpl)}\n />\n ) : null}\n </li>\n ))}\n </ul>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n {form ? (\n <>\n <Button intent=\"secondary\" onClick={() => setForm(null)}>\n {t('helpMeWriteTemplates.manager.cancel')}\n </Button>\n <Button\n intent=\"primary\"\n loading={saving}\n onClick={() => void save()}\n >\n {t('helpMeWriteTemplates.manager.save')}\n </Button>\n </>\n ) : (\n <>\n {templates.length > 0 ? (\n <Button\n intent=\"outline\"\n startIcon={<Plus />}\n onClick={() => setForm({ ...EMPTY_FORM })}\n >\n {t('helpMeWriteTemplates.manager.new')}\n </Button>\n ) : null}\n <Dialog.Close asChild>\n <Button intent=\"primary\">\n {t('helpMeWriteTemplates.manager.done')}\n </Button>\n </Dialog.Close>\n </>\n )}\n </Dialog.Footer>\n </div>\n </Dialog.Content>\n </Dialog>\n <Dialog\n open={pendingDelete != null}\n onOpenChange={(next) => {\n if (!next && !deleting) {\n setPendingDelete(null);\n setDeleteFailed(false);\n }\n }}\n >\n <Dialog.Content size=\"sm\" variant=\"alert\">\n <Dialog.Header>\n <Dialog.Title>\n {t('helpMeWriteTemplates.manager.deleteTitle', {\n name: pendingDelete?.name ?? '',\n })}\n </Dialog.Title>\n <Dialog.Description>\n {t('helpMeWriteTemplates.manager.deleteDescription')}\n </Dialog.Description>\n </Dialog.Header>\n {deleteFailed ? (\n <Dialog.Body>\n <Alert variant=\"error\">\n {t('helpMeWriteTemplates.manager.deleteError')}\n </Alert>\n </Dialog.Body>\n ) : null}\n <Dialog.Footer>\n <Dialog.Close asChild>\n <Button intent=\"secondary\" disabled={deleting}>\n {t('helpMeWriteTemplates.manager.cancel')}\n </Button>\n </Dialog.Close>\n <Button\n intent=\"destructive\"\n loading={deleting}\n onClick={() => void confirmDelete()}\n >\n {t('helpMeWriteTemplates.manager.deleteConfirm')}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* HelpMeWriteUndoNotice */\n/* ------------------------------------------------------------------ */\n\nexport interface HelpMeWriteUndoNoticeProps {\n /** The change to offer Undo for; `null` hides the notice. */\n applied: HelpMeWriteApplied | null;\n onUndo: () => void;\n onDismiss: () => void;\n}\n\n/** \"Note rewritten with …\" plus Undo; takes focus when it appears. */\nexport function HelpMeWriteUndoNotice({\n applied,\n onUndo,\n onDismiss,\n}: HelpMeWriteUndoNoticeProps): React.JSX.Element | null {\n const { t } = useTranslation();\n const undoRef = useRef<HTMLButtonElement>(null);\n useEffect(() => {\n if (applied) undoRef.current?.focus();\n }, [applied]);\n if (!applied?.template) return null;\n const name = applied.template.name;\n return (\n <Alert\n variant=\"success\"\n dismissible\n onOpenChange={(isOpen) => {\n if (!isOpen) onDismiss();\n }}\n data-component=\"help-me-write-undo-notice\"\n >\n <div className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span>\n {applied.mode === 'below'\n ? t('helpMeWriteTemplates.undo.addedBelow', { name })\n : t('helpMeWriteTemplates.undo.replaced', { name })}\n </span>\n <Button ref={undoRef} intent=\"outline\" size=\"sm\" onClick={onUndo}>\n {t('helpMeWriteTemplates.undo.undo')}\n </Button>\n </div>\n </Alert>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* useHelpMeWriteTemplates — the whole thing in one call */\n/* ------------------------------------------------------------------ */\n\nexport interface UseHelpMeWriteTemplatesOptions {\n templates: AiTemplate[];\n onGenerate: HelpMeWriteTemplatesBarProps['onGenerate'];\n /** Enables the manager (create / edit). Omit for read-only template users. */\n onSaveTemplate?: AiTemplateManagerProps['onSaveTemplate'];\n /** Enables Delete in the manager. */\n onDeleteTemplate?: AiTemplateManagerProps['onDeleteTemplate'];\n credits?: AiCreditsInfo;\n /** Mic in the bar's prompt when the editor has `onDictate`. Default true. */\n enableDictation?: boolean;\n /** Also told about every applied draft (e.g. for analytics). */\n onApplied?: (applied: HelpMeWriteApplied) => void;\n}\n\nexport interface UseHelpMeWriteTemplatesResult {\n /** Pass to `RichTextEditor`'s `renderHelpMeWrite`. */\n renderHelpMeWrite: (context: HelpMeWriteRenderContext) => ReactNode;\n /** Mount once, anywhere (a portalled dialog); `null` without `onSaveTemplate`. */\n manager: ReactNode;\n /** Place where the Undo notice should show, e.g. above the editor. */\n undoNotice: ReactNode;\n openManager: (mode?: 'list' | 'create') => void;\n}\n\n/**\n * Wires the bar, the manager and Undo together. Usage:\n *\n * const hmw = useHelpMeWriteTemplates({ templates, onGenerate, onSaveTemplate });\n * {hmw.undoNotice}\n * <RichTextEditor renderHelpMeWrite={hmw.renderHelpMeWrite} … />\n * {hmw.manager}\n */\nexport function useHelpMeWriteTemplates({\n templates,\n onGenerate,\n onSaveTemplate,\n onDeleteTemplate,\n credits,\n enableDictation,\n onApplied,\n}: UseHelpMeWriteTemplatesOptions): UseHelpMeWriteTemplatesResult {\n const [manager, setManager] = useState<{\n open: boolean;\n mode: 'list' | 'create';\n }>({ open: false, mode: 'list' });\n const [applied, setApplied] = useState<HelpMeWriteApplied | null>(null);\n const openManager = useCallback(\n (mode: 'list' | 'create' = 'list') => setManager({ open: true, mode }),\n [],\n );\n\n const renderHelpMeWrite = useCallback(\n (context: HelpMeWriteRenderContext): ReactNode => {\n return (\n <HelpMeWriteTemplatesBar\n context={context}\n templates={templates}\n onGenerate={onGenerate}\n onManageTemplates={onSaveTemplate ? openManager : undefined}\n credits={credits}\n enableDictation={enableDictation}\n suspendClose={manager.open}\n onApplied={(event) => {\n setApplied(event.template ? event : null);\n onApplied?.(event);\n }}\n />\n );\n },\n [\n templates,\n onGenerate,\n onSaveTemplate,\n openManager,\n credits,\n enableDictation,\n manager.open,\n onApplied,\n ],\n );\n\n const managerNode = useMemo(\n () =>\n onSaveTemplate ? (\n <AiTemplateManager\n open={manager.open}\n initialMode={manager.mode}\n onOpenChange={(isOpen) => setManager((m) => ({ ...m, open: isOpen }))}\n templates={templates}\n onSaveTemplate={onSaveTemplate}\n onDeleteTemplate={onDeleteTemplate}\n />\n ) : null,\n [manager, templates, onSaveTemplate, onDeleteTemplate],\n );\n\n const undoNotice = (\n <HelpMeWriteUndoNotice\n applied={applied}\n onUndo={() => {\n applied?.undo();\n setApplied(null);\n }}\n onDismiss={() => setApplied(null)}\n />\n );\n\n return {\n renderHelpMeWrite,\n manager: managerNode,\n undoNotice,\n openManager,\n };\n}\n"],"names":["AiCreditsExhaustedError","message","ACTION_SIZE","MENU_TRIGGER","BRAND_ACTION","RECORDING_MIC","metaClass","eyebrowClass","previewClass","compareBoxClass","orderTemplates","templates","a","b","joinWith","base","extra","isAbort","err","AiCreditsExhaustedNotice","credits","onBack","t","i18n","useTranslation","limit","remaining","remainingText","resetsOn","jsxs","Alert","Astroid","jsx","Progress","Button","TrendingUp","ArrowLeft","HelpMeWriteTemplatesBar","context","onGenerate","onManageTemplates","onApplied","enableDictation","suspendClose","open","sourceId","useId","errorId","prompt","setPrompt","useState","running","setRunning","errored","setErrored","outOfCredits","setOutOfCredits","result","setResult","source","setSource","abortRef","useRef","loading","onDictate","isDictating","setIsDictating","interim","setInterim","announcement","setAnnouncement","dictateAbortRef","stopDictation","useCallback","_a","toggleDictation","controller","text","trimmed","p","useEffect","selection","_b","run","template","draft","contextClose","close","apply","mode","previousHtml","selected","setContent","sourceLine","body","compare","Fragment","SafeHtml","X","RotateCcw","ordered","fieldValue","showTemplatesMenu","IconButton","TextArea","event","Square","Mic","DropdownMenu","Spinner","WandSparkles","ChevronDown","tpl","Badge","Plus","Settings","Send","EditorOverlay","EMPTY_FORM","AiTemplateManager","onOpenChange","initialMode","onSaveTemplate","onDeleteTemplate","form","setForm","saving","setSaving","saveFailed","setSaveFailed","pendingDelete","setPendingDelete","deleting","setDeleting","deleteFailed","setDeleteFailed","confirmDelete","nameTaken","name","id","nameError","promptError","save","next","title","Dialog","FormField","TextInput","Switch","checked","EmptyState","Pencil","Trash2","HelpMeWriteUndoNotice","applied","onUndo","onDismiss","undoRef","isOpen","useHelpMeWriteTemplates","manager","setManager","setApplied","openManager","renderHelpMeWrite","managerNode","useMemo","m"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGO,MAAMA,WAAgC,MAAM;AAAA,EACjD,YAAYC,IAAU,wBAAwB;AAC5C,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACd;AACF;AAkCA,MAAMC,IAAc,qCACdC,KAAe,8CACfC,KAAe,GAAGF,CAAW,wDAE7BG,KACJ,kGACIC,IACJ,uFACIC,KACJ,+DACIC,KAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAC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AAYgE;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,IAIN;AAAA,MACE9F;AAAA,MACA4B;AAAA,MACAmF;AAAA,MACAyC;AAAA,MACA/I;AAAA,MACAsB;AAAA,MACAsH,EAAQ;AAAA,MACRvH;AAAA,IAAA;AAAA,EACF,GAGI4H,IAAcC;AAAA,IAClB,MACE5C,IACE,gBAAA1F;AAAA,MAACuF;AAAA,MAAA;AAAA,QACC,MAAMyC,EAAQ;AAAA,QACd,aAAaA,EAAQ;AAAA,QACrB,cAAc,CAACF,MAAWG,EAAW,CAACM,OAAO,EAAE,GAAGA,GAAG,MAAMT,EAAA,EAAS;AAAA,QACpE,WAAAnJ;AAAA,QACA,gBAAA+G;AAAA,QACA,kBAAAC;AAAA,MAAA;AAAA,IAAA,IAEA;AAAA,IACN,CAACqC,GAASrJ,GAAW+G,GAAgBC,CAAgB;AAAA,EAAA;AAcvD,SAAO;AAAA,IACL,mBAAAyC;AAAA,IACA,SAASC;AAAA,IACT,YAbA,gBAAArI;AAAA,MAACyH;AAAA,MAAA;AAAA,QACC,SAAAC;AAAA,QACA,QAAQ,MAAM;AACZ,UAAAA,KAAA,QAAAA,EAAS,QACTQ,EAAW,IAAI;AAAA,QACjB;AAAA,QACA,WAAW,MAAMA,EAAW,IAAI;AAAA,MAAA;AAAA,IAAA;AAAA,IAQlC,aAAAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { c as a } from "./createLucideIcon-DhHxpK9K.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license lucide-react v1.22.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
const e = [
|
|
9
|
-
["path", { d: "m9 11-6 6v3h9l3-3", key: "1a3l36" }],
|
|
10
|
-
["path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4", key: "14a9rk" }]
|
|
11
|
-
], h = a("highlighter", e);
|
|
12
|
-
export {
|
|
13
|
-
h as H
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=highlighter-DSkckT2Q.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"highlighter-DSkckT2Q.js","sources":["../../node_modules/lucide-react/dist/esm/icons/highlighter.mjs"],"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: \"m9 11-6 6v3h9l3-3\", key: \"1a3l36\" }],\n [\"path\", { d: \"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4\", key: \"14a9rk\" }]\n];\nconst Highlighter = createLucideIcon(\"highlighter\", __iconNode);\n\nexport { __iconNode, Highlighter as default };\n//# sourceMappingURL=highlighter.mjs.map\n"],"names":["__iconNode","Highlighter","createLucideIcon"],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,qBAAqB,KAAK,SAAQ,CAAE;AAAA,EAClD,CAAC,QAAQ,EAAE,GAAG,gEAAgE,KAAK,SAAQ,CAAE;AAC/F,GACMC,IAAcC,EAAiB,eAAeF,CAAU;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notes-panel-CRAovkjx.js","sources":["../../src/components/_shared/get-error-message.ts","../../src/components/notes-panel/notes-panel.agent.ts","../../src/components/notes-panel/notes-panel.tsx"],"sourcesContent":["/** Read host error messages without relying on the host's JavaScript realm. */\nexport function getErrorMessage(error: unknown, fallback: string): string {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'message' in error &&\n typeof error.message === 'string' &&\n error.message.trim()\n ) {\n return error.message;\n }\n return fallback;\n}\n","/* -------------------------------------------------------------------- */\n/* Agent adapter — NotesPanel. */\n/* */\n/* The Notes tool: a composer over a note timeline. The agent reads the */\n/* timeline STRUCTURE (note ids + pinned / flagged / clinical flags — */\n/* never the note body or author, both PHI), composes and commits a new */\n/* note, and toggles a note's pinned / flagged state. `add_note` carries */\n/* the `phi` safety class: a note body is patient-identifiable clinical */\n/* content, so the host gates it behind the same confirm-before-act as a */\n/* destructive write and never auto-confirms. A clinical submission also */\n/* requires the host's `practice_add_clinical_note` permission (the */\n/* handle drops it when the gate is closed). Host-owned per-note */\n/* `noteActions` (edit, delete…) sit outside this handle — an agent */\n/* reaches them through the host's own adapters. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { NotesPanelHandle } from './notes-panel';\n\nexport const notesPanelAgent: AgentAdapter<NotesPanelHandle> = {\n id: 'notes-panel',\n // 'submit' backs add_note (compose + commit a note). pin / flag are toggles\n // with no dedicated capability in the closed vocabulary.\n capabilities: ['submit'],\n state: {\n notes: {\n type: 'Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean }>',\n descriptionKey: 'ui.agent.notesPanel.state.notes',\n description:\n 'Timeline note ids + pinned / flagged / clinical flags. Never the note body or author (both PHI).',\n read: (handle) => handle.getNotes(),\n },\n canAddClinical: {\n type: 'boolean',\n descriptionKey: 'ui.agent.notesPanel.state.canAddClinical',\n description:\n 'Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).',\n read: (handle) => handle.canAddClinical(),\n },\n currentNoteId: {\n type: 'string | null',\n descriptionKey: 'ui.agent.notesPanel.state.currentNoteId',\n description:\n '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.',\n read: (handle) => handle.getCurrentNoteId(),\n },\n },\n actions: {\n add_note: {\n // Writes a clinical/admin note body — patient-identifiable content. PHI.\n safety: 'phi',\n argsType: '{ content: string; clinical: boolean }',\n argsSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description:\n 'Note body. Rich HTML for the rich composer, else plain text.',\n },\n clinical: {\n type: 'boolean',\n description:\n 'Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed.',\n },\n },\n required: ['content', 'clinical'],\n },\n openWorld: true,\n descriptionKey: 'ui.agent.notesPanel.actions.addNote',\n description:\n 'Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).',\n examples: [\n {\n args: { content: 'Patient reported improvement.', clinical: true },\n note: 'Add a clinical note.',\n },\n ],\n invoke: (handle, args: { content: string; clinical: boolean }) => {\n return handle.addNote(args);\n },\n },\n toggle_pin: {\n // Re-orders the timeline (pinned notes lead) — reversible view write.\n safety: 'write',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: false,\n descriptionKey: 'ui.agent.notesPanel.actions.togglePin',\n description:\n 'Toggle the pinned state of the note with the given id. Refused for a deleted note or one whose actions.pin is false.',\n invoke: (handle, args: { id: string }) => {\n handle.togglePin(args.id);\n },\n },\n toggle_flag: {\n safety: 'write',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: false,\n descriptionKey: 'ui.agent.notesPanel.actions.toggleFlag',\n description: 'Toggle the flagged state of the note with the given id.',\n invoke: (handle, args: { id: string }) => {\n handle.toggleFlag(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'notes-panel',\n description: 'Marks the NotesPanel region.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Required to address a specific notes panel from the agent.',\n },\n },\n};\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\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 { getErrorMessage } from '../_shared/get-error-message';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { notesPanelAgent } from './notes-panel.agent';\nimport { ClinicalNoteCard } from '../clinical-note-card';\nimport type { ClinicalNoteCardProps } from '../clinical-note-card';\nimport { RichTextEditor } from '../rich-text-editor';\nimport type {\n RichTextEditorHandle,\n RichTextEditorProps,\n RichTextEditorToolbar,\n RedactorFactory,\n AiConsentGate,\n} from '../rich-text-editor';\nimport { TextArea } from '../text-area';\nimport { Alert } from '../alert';\nimport { Button, IconButton } from '../button';\nimport { Checkbox } from '../checkbox';\nimport { Card } from '../card/card';\nimport { CONTENT_ENTER_CLASS, Skeleton } from '../skeleton/skeleton';\nimport { Dialog } from '../dialog';\nimport { NotebookPen, Pencil, Trash2 } from 'lucide-react';\nimport { PanelHeader } from '../panel-header';\nimport { REFLOW_ROW_CLASS, useListReflow } from '../../hooks/use-list-reflow';\nimport { useExitTransition } from '../../hooks/use-exit-transition';\nimport { useTheme } from '../../hooks/use-theme';\n\n/* ------------------------------------------------------------------ */\n/* NotesPanel — the Notes tool for the Control Room rail. */\n/* */\n/* A composer over an elevated ClinicalNoteCard timeline. Drops */\n/* into a ControlRoomRail tool `panel`, the patient profile, or the */\n/* care-plan editor — anywhere notes about the open entity belong. */\n/* The composer is the kit RichTextEditor by default (degrades to a */\n/* textarea where Redactor is absent), carries a permission-gated */\n/* \"clinical note\" toggle, and forwards the editor's AI affordances. */\n/* The note attaches to whatever entity the host is showing — the */\n/* host owns the attachment; the panel only emits content + clinical. */\n/* Pinned notes lead; pin / flag are inline per-note toggles. */\n/* ------------------------------------------------------------------ */\n\n/**\n * One note in the panel — the data subset of `ClinicalNoteCard`.\n *\n * `aria-label` names the card for assistive tech. Set it whenever a row is not\n * a clinical note: the card's fallback name is \"Clinical note\", so an entry\n * that is something else (a dated event, an import) is announced as one.\n */\nexport type NotesPanelNote = Pick<\n ClinicalNoteCardProps,\n | 'id'\n | 'dateIso'\n | 'createdAtIso'\n | 'author'\n | 'clinical'\n | 'attachedTo'\n | 'content'\n | 'contentFormat'\n | 'pinned'\n | 'flagged'\n | 'aria-label'\n | 'deleted'\n | 'operatorName'\n> & {\n /** What the host lets the reader do with this note. */\n actions?: NotesPanelNoteActions;\n};\n\n/** Per-note write permissions; an absent key means allowed. The panel hides\n * the pin toggle on `pin: false` and on a deleted note. */\nexport type NotesPanelNoteActions = {\n edit?: boolean;\n delete?: boolean;\n pin?: boolean;\n};\n\n/**\n * Curated agent handle for NotesPanel. Reads the note timeline's STRUCTURE\n * (ids + pinned / flagged / clinical flags — never the note body or author,\n * both PHI) and drives the composer + per-note toggles. See\n * `notes-panel.agent.ts`.\n */\nexport interface NotesPanelHandle {\n /** Timeline snapshot — ids + flags only, never note content (PHI). */\n getNotes: () => Array<{\n id?: string;\n pinned: boolean;\n flagged: boolean;\n clinical: boolean;\n }>;\n /** Whether the composer is mounted (onAddNote is wired). */\n canAddNote: () => boolean;\n /** Whether clinical notes may be written (the permission gate). */\n canAddClinical: () => boolean;\n /** Id of the note the host has addressed, or null when none is. */\n getCurrentNoteId: () => string | null;\n /** Commit a new note with explicit content (mirrors the composer's submit). */\n addNote: (submission: NotesPanelSubmission) => void | Promise<void>;\n /** Toggle a note's pinned state (mirrors onTogglePin, with its gate). */\n togglePin: (id: string) => void;\n /** Toggle a note's flagged state (mirrors onToggleFlag). */\n toggleFlag: (id: string) => void;\n}\n\n/** Payload handed to `onAddNote` when the composer commits. */\nexport interface NotesPanelSubmission {\n /** The note body — rich HTML (`composer='rich'`) or plain text. */\n content: string;\n /** Whether the \"clinical note\" toggle was set. */\n clinical: boolean;\n}\n\nexport interface NotesPanelProps extends Omit<\n HTMLAttributes<HTMLElement>,\n 'title' | 'children'\n> {\n /**\n * Stable instance id. Surfaced on the root as `data-component-id` so an\n * agent / MCP UI bridge can address this specific notes panel.\n */\n id?: string;\n /** Notes to render, newest-first by convention. Pinned notes lead. */\n notes: NotesPanelNote[];\n /**\n * Commit a new note. Omit to hide the composer (read-only timeline). Return\n * a promise to keep the draft until the host has saved it: the draft clears\n * when it resolves, and a rejection keeps it and shows the error's message.\n */\n onAddNote?: (submission: NotesPanelSubmission) => void | Promise<void>;\n /** The host's notes read. `'loading'` and `'error'` never show the empty\n * text; notes already held still render. Default `'ready'`. */\n status?: 'ready' | 'loading' | 'error';\n /** Retry a failed read. Renders a retry button in the error state. */\n onRetry?: () => void;\n /**\n * The note the reader ASKED for, addressed by id from somewhere else in the\n * record — a marker in a chart, a row in a grid, an agent. The panel marks\n * it, scrolls it to the middle of its own scroll region and moves focus to\n * it, and renders it unclamped so the thing that was asked for is readable\n * in full without a second click.\n *\n * Opening a panel is not the same as answering a question: a rail's\n * `setActiveTool` moves no focus and announces nothing, so a control whose\n * name promises \"in the notes panel\" produces no perceivable change for a\n * keyboard or screen-reader reader unless the panel lands them on the note.\n * That is what this prop is for; without it, a host has to reach into the\n * panel's DOM to do the same job.\n *\n * Marked on three channels, never colour alone (WCAG 1.4.1): an accent\n * wash that fades in and out over the card (steady where motion is off),\n * the focus outline on the row, and `aria-current` plus a visually-hidden\n * sentence naming the mark. Nothing is left on the row once the wash ends.\n *\n * Ids that match no note are ignored. To address the SAME note twice — the\n * reader pressing the same marker again after scrolling away — bump\n * `currentNoteKey` alongside it; this prop alone is a value, not a request.\n */\n currentNoteId?: string;\n /**\n * Bump on every address to re-scroll and re-focus the note in `currentNoteId`\n * and replay its wash, even when the id has not changed.\n *\n * Addressing is a request, not a value: a reader who presses the same marker\n * a second time (having scrolled away, or having moved focus off the note) is\n * asking to be taken back, and a control whose name promises the notes panel\n * must do something perceivable every time it is pressed. Without this the\n * second press is inert — the panel is already showing that note, so nothing\n * re-runs. Hosts increment a counter in the same handler that opens the tool.\n */\n currentNoteKey?: string | number;\n\n /* ----- Composer ----- */\n /**\n * `'rich'` (default) mounts the kit `RichTextEditor` (Redactor; degrades to a\n * textarea where Redactor is absent). `'plain'` keeps a simple `TextArea` for\n * lightweight surfaces / deterministic tests.\n */\n composer?: 'rich' | 'plain';\n /** Toolbar preset for the rich composer. Defaults to `'standard'`. */\n editorToolbar?: RichTextEditorToolbar;\n /** Inject the Redactor factory for the rich composer (else `window.$R`). */\n redactor?: RedactorFactory;\n /** Consumer image-upload endpoint for the rich composer. */\n imageUploadUrl?: string;\n\n /* ----- Clinical flag (permission-gated) ----- */\n /** Show the \"clinical note\" toggle in the composer. Default `true`. */\n showClinicalToggle?: boolean;\n /**\n * Permission gate — when `false` the clinical toggle is disabled and shows\n * `clinicalGatedReason` on hover/focus. Mirrors platform's\n * `practice_add_clinical_note` permission. Default `true`.\n */\n canAddClinicalNote?: boolean;\n /** Tooltip shown when the clinical toggle is gated off. */\n clinicalGatedReason?: string;\n /** Initial state of the clinical toggle. Default `false`. */\n defaultClinical?: boolean;\n\n /* ----- AI assistance (forwarded to RichTextEditor) ----- */\n onRequestAiDraft?: RichTextEditorProps['onRequestAiDraft'];\n aiDraftFormat?: RichTextEditorProps['aiDraftFormat'];\n aiPrivacyNotice?: RichTextEditorProps['aiPrivacyNotice'];\n onDictate?: RichTextEditorProps['onDictate'];\n onProofread?: RichTextEditorProps['onProofread'];\n onAutoFormat?: RichTextEditorProps['onAutoFormat'];\n /**\n * Patient AI-consent gate for Help-me-write + both mics, forwarded\n * straight to the rich composer. See `AiConsentGate`. Omit for today's\n * ungated behaviour. Ignored by the `'plain'` composer (it offers\n * neither affordance).\n */\n aiConsent?: AiConsentGate;\n /**\n * Template variables for the rich composer's \"Insert variable\" menu and\n * `[[TOKEN]]` chip rendering. Forwarded straight to `RichTextEditor`.\n * Ignored by the `'plain'` composer.\n */\n variables?: RichTextEditorProps['variables'];\n /** Decide whether a `[[TOKEN]]` is valid. See `RichTextEditor`. */\n validateVariable?: RichTextEditorProps['validateVariable'];\n /** The invalid `[[TOKEN]]`s in the draft, reported by the rich composer. */\n onVariableValidityChange?: RichTextEditorProps['onVariableValidityChange'];\n /**\n * Bring your own Help-me-write surface (e.g. practice templates) into the\n * composer, forwarded straight to `RichTextEditor`. See\n * `RichTextEditorProps['renderHelpMeWrite']`.\n */\n renderHelpMeWrite?: RichTextEditorProps['renderHelpMeWrite'];\n /** Upload an image yourself and resolve its URL. See `RichTextEditor`. */\n onUploadImage?: RichTextEditorProps['onUploadImage'];\n /** An AI call ran out of credits. See `RichTextEditor`. */\n onAiCreditsExhausted?: RichTextEditorProps['onAiCreditsExhausted'];\n /**\n * Rendered just above the composer — e.g. the Help-me-write templates\n * pattern's `undoNotice`. Renders in both add and edit mode, whenever the\n * composer itself is mounted.\n */\n composerBefore?: ReactNode;\n /**\n * Rendered just after the composer — e.g. the Help-me-write templates\n * pattern's `manager` dialog. Renders in both add and edit mode, whenever\n * the composer itself is mounted.\n */\n composerAfter?: ReactNode;\n\n /* ----- Per-note actions ----- */\n /** Toggle a note's pinned state — renders an inline pin button per note. */\n onTogglePin?: (id: string) => void;\n /** Toggle a note's flagged state — renders an inline flag button per note. */\n onToggleFlag?: (id: string) => void;\n /**\n * Host-owned actions for each note (edit, delete, share…), rendered by\n * the note card beside its pin and flag,\n * aligned to the inline end. The host supplies labelled controls and owns\n * what they do — the panel stays a timeline and never edits a note itself.\n */\n noteActions?: (note: NotesPanelNote) => ReactNode;\n /**\n * Save an edit to an existing note. When provided, each note the reader may\n * edit gets a pencil; it loads the note into the SAME composer that writes\n * new notes, in place, so a rich note is edited as rich text and keeps its\n * formatting. Return a promise to hold the pending state; a rejection keeps\n * the draft. Hidden on `actions.edit: false` and on a deleted note.\n */\n onEditNote?: (\n id: string,\n submission: NotesPanelSubmission,\n ) => void | Promise<void>;\n /**\n * Let an edit change a note's clinical flag. Default `false`: the \"Clinical\n * note\" toggle is hidden while editing and the submission carries the\n * note's existing flag. Most hosts save a note's content only, and a live\n * toggle that changes nothing is a lie. Set `true` only when the host\n * persists `submission.clinical` on edit.\n */\n editClinical?: boolean;\n /**\n * Request the host to delete a note. When provided, the panel holds the\n * row on screen long enough to fade it out before calling this, so the\n * removal reads as a removal rather than a vanish. Omit to let the host\n * own the timing entirely (the reflow animation still closes the gap).\n */\n onDeleteNote?: (id: string) => void;\n /**\n * Show a confirmation dialog before calling `onDeleteNote`. When `true`\n * (the default when `onDeleteNote` is provided), the built-in delete\n * button opens an alert dialog first; the exit fade only starts after\n * the user confirms. Pass `false` to delete immediately on click.\n */\n confirmDelete?: boolean;\n\n /* ----- Labels / chrome ----- */\n /** Panel heading. Defaults to the localised \"Notes\". */\n title?: string;\n /** Composer placeholder. */\n composerPlaceholder?: string;\n /** Save-button label. */\n addNoteLabel?: string;\n /** Rendered when there are no notes. */\n emptyState?: ReactNode;\n /** Accessible name for the panel region (defaults to `title`). */\n 'aria-label'?: string;\n}\n\n/* Lifts the card's content above the wash layer, so the wash tints the card\n surface only: note text and badges keep their own colours and contrast. */\nconst NOTE_CONTENT_ABOVE_WASH =\n 'ds:isolate ds:[&_[data-component=card]>*]:relative ds:[&_[data-component=card]>*]:z-[1]';\n\n/* The timeline row. The addressed row takes the keyboard focus outline; its\n visual mark is the wash layer below, so no row carries a border stripe. */\nconst noteItemVariants = cva(\n 'ds:relative ds:flex ds:flex-col ds:rounded-[var(--radius-lg)]',\n {\n variants: {\n current: {\n 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)]',\n false: '',\n },\n washed: { true: NOTE_CONTENT_ABOVE_WASH, false: '' },\n },\n defaultVariants: { current: false, washed: false },\n },\n);\n\n/* The accent wash on a row's card surface. `addressed` arrives, holds and\n leaves no mark; `editing` is steady for as long as the edit lasts. With\n motion off (OS setting, accessible theme) `addressed` holds steady too. */\nconst noteWashVariants = cva(\n 'ds:pointer-events-none ds:absolute ds:inset-0 ds:rounded-[var(--radius-lg)] ds:bg-[color:var(--accent)]',\n {\n variants: {\n state: {\n addressed: [\n 'ds:opacity-0',\n 'ds:animate-[note-addressed_calc(var(--animation-duration)*9)_var(--ease-in-out)]',\n 'ds:motion-reduce:animate-none ds:motion-reduce:opacity-[var(--opacity-12)]',\n 'ds:[.theme-accessible_&]:animate-none ds:[.theme-accessible_&]:opacity-[var(--opacity-12)]',\n ].join(' '),\n editing: 'ds:opacity-[var(--opacity-12)]',\n },\n },\n },\n);\n\n/* A row on its way out fades in place; the reflow hook then slides the\n rows below up to close the gap. Declared at rest so the transition has\n a value to animate from the moment the leaving class lands. */\nconst noteLeavingClass = 'ds:opacity-0';\nconst noteElevationClass = [\n 'ds:transition-opacity ds:duration-[var(--animation-duration)]',\n 'ds:ease-[var(--ease-out)] ds:motion-reduce:transition-none',\n].join(' ');\n\n/* Body lines per placeholder note. Uneven, so three cards do not read as one\n repeated stamp. */\nconst NOTE_SKELETON_LINES = [3, 2, 3] as const;\n\n/** Strip tags / entities to test whether a rich draft holds real content. */\nfunction hasRichContent(html: string): boolean {\n if (!html) return false;\n if (/<img\\b/i.test(html)) return true;\n return (\n html\n .replace(/<[^>]*>/g, '')\n .replace(/ /gi, ' ')\n .trim().length > 0\n );\n}\n\nexport const NotesPanel = forwardRef<HTMLElement, NotesPanelProps>(\n function NotesPanel(\n {\n id,\n notes,\n onAddNote,\n status = 'ready',\n onRetry,\n currentNoteId,\n currentNoteKey,\n composer = 'rich',\n editorToolbar = 'standard',\n redactor,\n imageUploadUrl,\n showClinicalToggle = true,\n canAddClinicalNote = true,\n clinicalGatedReason,\n defaultClinical = false,\n onRequestAiDraft,\n aiDraftFormat,\n aiPrivacyNotice,\n onDictate,\n onProofread,\n onAutoFormat,\n aiConsent,\n variables,\n validateVariable,\n onVariableValidityChange,\n renderHelpMeWrite,\n onUploadImage,\n onAiCreditsExhausted,\n composerBefore,\n composerAfter,\n onTogglePin,\n onToggleFlag,\n noteActions,\n onEditNote,\n editClinical = false,\n onDeleteNote,\n confirmDelete = true,\n title,\n composerPlaceholder,\n addNoteLabel,\n emptyState,\n className,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref,\n ) {\n const { t, i18n } = useTranslation();\n const editorRef = useRef<RichTextEditorHandle>(null);\n const [draft, setDraft] = useState('');\n const [clinical, setClinical] = useState(defaultClinical);\n const [pending, setPending] = useState(false);\n const [addError, setAddError] = useState<string | null>(null);\n // The note loaded into the composer for editing, or null when composing.\n const [editingId, setEditingId] = useState<string | null>(null);\n /* Settle in only when this content REPLACES a skeleton. Content that was\n simply there from the start must not fade: it would read as invisible\n for one animation to any test or reader that looks at once. */\n const followedLoading = useRef(false);\n if (status === 'loading') followedLoading.current = true;\n const enterClass = followedLoading.current ? CONTENT_ENTER_CLASS : '';\n\n const heading = title ?? t('notesPanel.title', { defaultValue: 'Notes' });\n const headingId = useId();\n const placeholder =\n composerPlaceholder ??\n t('notesPanel.placeholder', { defaultValue: 'Add a note…' });\n const composerLabel =\n editingId !== null\n ? t('notesPanel.edit', { defaultValue: 'Edit note' })\n : t('notesPanel.composerLabel', { defaultValue: 'New note' });\n\n // Live content check: plain reads the draft directly; rich strips the draft\n // (debounced) for the disabled state but commits from the editor handle.\n const hasContent =\n composer === 'rich' ? hasRichContent(draft) : draft.trim().length > 0;\n\n const commit = useCallback(() => {\n const save = editingId !== null ? onEditNote : onAddNote;\n if (!save || pending) return;\n const rich = composer === 'rich';\n const content = rich\n ? (editorRef.current?.getHTML() ?? draft)\n : draft.trim();\n if (rich ? !hasRichContent(content) : !content) return;\n const reset = () => {\n if (rich) editorRef.current?.clear();\n setDraft('');\n setClinical(defaultClinical);\n setEditingId(null);\n };\n setAddError(null);\n let result: void | Promise<void>;\n try {\n result =\n editingId !== null && onEditNote\n ? onEditNote(editingId, { content, clinical })\n : onAddNote?.({ content, clinical });\n } catch (error: unknown) {\n setAddError(getErrorMessage(error, t('notesPanel.addFailed')));\n return;\n }\n if (!result || typeof result.then !== 'function') return reset();\n // A failed save keeps the draft, so nothing typed is lost.\n setPending(true);\n Promise.resolve(result)\n .then(reset, (error: unknown) =>\n setAddError(getErrorMessage(error, t('notesPanel.addFailed'))),\n )\n .finally(() => setPending(false));\n }, [\n composer,\n draft,\n clinical,\n defaultClinical,\n editingId,\n onAddNote,\n onEditNote,\n pending,\n t,\n ]);\n\n const clinicalToggleShown =\n showClinicalToggle && (editingId === null || editClinical);\n\n /* Every row carries the SAME action words, so each accessible name adds\n the note's own date: otherwise a screen reader hears a list of\n identical \"Edit note\" buttons. The tooltip keeps the short words. */\n const noteStamp = useCallback(\n (note: NotesPanelNote): string => {\n try {\n return new Intl.DateTimeFormat(i18n.language, {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n }).format(new Date(note.dateIso));\n } catch {\n return note.dateIso;\n }\n },\n [i18n.language],\n );\n\n /* ----- Edit in place: the composer takes the note, and gives it back ----- */\n const startEdit = useCallback(\n (note: NotesPanelNote) => {\n if (!note.id || pending) return;\n const content = note.content ?? '';\n setAddError(null);\n setEditingId(note.id);\n setClinical(note.clinical ?? false);\n setDraft(content);\n if (composer === 'rich') {\n editorRef.current?.clear();\n editorRef.current?.insertAtCursor(content, { asHtml: true });\n }\n editorRef.current?.focus();\n },\n [composer, pending],\n );\n const cancelEdit = useCallback(() => {\n if (composer === 'rich') editorRef.current?.clear();\n setDraft('');\n setClinical(defaultClinical);\n setAddError(null);\n setEditingId(null);\n }, [composer, defaultClinical]);\n // The note being edited went away (deleted, or another patient's notes\n // arrived): its draft must not be saved against whatever comes next.\n const editingStillThere =\n editingId === null ||\n notes.some((note) => note.id === editingId && !note.deleted);\n useEffect(() => {\n if (!editingStillThere) cancelEdit();\n }, [editingStillThere, cancelEdit]);\n\n // Pinned notes lead; order within each group is preserved.\n const ordered = [...notes].sort(\n (a, b) => Number(b.pinned ?? false) - Number(a.pinned ?? false),\n );\n\n /* The accessible theme zeroes `--animation-duration`, so its CSS plays\n nothing — the JS must agree, or a row would sit still for the delay\n and then vanish anyway. `undefined` leaves the media query in charge. */\n const { resolvedTheme } = useTheme();\n const reduceMotion = resolvedTheme.endsWith('-accessible') || undefined;\n\n /* Closing the gap a removed row leaves: the rows below slide up rather\n than jumping, so the eye keeps its place in the list. Fires on add,\n delete, and re-order (pinning) — any change to the visible id\n sequence. */\n const { containerRef: reflowRef } = useListReflow<HTMLUListElement>({\n key: ordered.map((n) => n.id).join(),\n reduceMotion,\n });\n\n /* A note leaving the list fades out before the host drops it, so the\n removal reads as a removal rather than a vanish. The reflow hook\n then slides the rows below up to close the gap. */\n const deleteExit = useExitTransition({ reduceMotion });\n const [pendingDelete, setPendingDelete] = useState<string | null>(null);\n const handleDeleteNote = useCallback(\n (noteId: string) => {\n if (!onDeleteNote) return;\n if (confirmDelete) {\n setPendingDelete(noteId);\n } else {\n deleteExit.leave(noteId, () => onDeleteNote(noteId));\n }\n },\n [confirmDelete, deleteExit, onDeleteNote],\n );\n const confirmDeleteNote = useCallback(() => {\n if (!pendingDelete || !onDeleteNote) return;\n const noteId = pendingDelete;\n setPendingDelete(null);\n deleteExit.leave(noteId, () => onDeleteNote(noteId));\n }, [pendingDelete, onDeleteNote, deleteExit]);\n\n /* ----- The addressed note (see `currentNoteId`) ----- */\n const currentItemRef = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (!currentNoteId) return;\n // `center`, not `nearest`: nearest parks the note flush against the edge\n // of the scroll region, which is the least readable place to land.\n currentItemRef.current?.scrollIntoView({ block: 'center' });\n currentItemRef.current?.focus();\n // `currentNoteKey` is in the deps so a REPEAT address of the same note\n // re-runs — see the prop doc. Addressing is a request, not a value.\n }, [currentNoteId, currentNoteKey]);\n\n /* ----- Agent handle (structural reads + composer / toggles) ----- */\n const notesRef = useRef(notes);\n notesRef.current = notes;\n const onAddNoteRef = useRef(onAddNote);\n onAddNoteRef.current = onAddNote;\n const onTogglePinRef = useRef(onTogglePin);\n onTogglePinRef.current = onTogglePin;\n const onToggleFlagRef = useRef(onToggleFlag);\n onToggleFlagRef.current = onToggleFlag;\n const canAddClinicalRef = useRef(canAddClinicalNote);\n canAddClinicalRef.current = canAddClinicalNote;\n const currentNoteIdRef = useRef(currentNoteId);\n currentNoteIdRef.current = currentNoteId;\n\n const rootRef = useRef<HTMLElement>(null);\n useImperativeHandle(ref, () => rootRef.current as HTMLElement, []);\n\n const handle = useMemo<NotesPanelHandle>(\n () => ({\n // Ids + flags only — never the note body or author (both PHI).\n getNotes: () =>\n notesRef.current.map((n) => ({\n id: n.id,\n pinned: !!n.pinned,\n flagged: !!n.flagged,\n clinical: !!n.clinical,\n })),\n canAddNote: () => !!onAddNoteRef.current,\n canAddClinical: () => canAddClinicalRef.current,\n getCurrentNoteId: () => currentNoteIdRef.current ?? null,\n addNote: (submission) => {\n // A clinical submission requires the permission gate to be open.\n if (submission.clinical && !canAddClinicalRef.current) return;\n return onAddNoteRef.current?.(submission);\n },\n togglePin: (noteId) => {\n const note = notesRef.current.find((n) => n.id === noteId);\n if (note && (note.deleted || note.actions?.pin === false)) return;\n onTogglePinRef.current?.(noteId);\n },\n toggleFlag: (noteId) => onToggleFlagRef.current?.(noteId),\n }),\n [],\n );\n useAgentRegistration(notesPanelAgent, handle, id);\n\n return (\n <section\n ref={rootRef}\n data-component=\"notes-panel\"\n data-component-id={id}\n aria-labelledby={ariaLabel ? undefined : headingId}\n aria-label={ariaLabel}\n className={['ds:flex ds:flex-col', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {/* Shared rail header — pins to the top of the panel's scroll region\n while the composer + note timeline scroll beneath it. The rail\n injects the favourite / close actions via PanelHeaderActionsProvider. */}\n <PanelHeader\n title={heading}\n icon={<NotebookPen aria-hidden=\"true\" />}\n headingId={ariaLabel ? undefined : headingId}\n sticky\n divider\n />\n\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]\">\n {onAddNote || editingId !== null ? (\n <div\n data-notes-panel-composer={editingId !== null ? 'edit' : 'add'}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n {composerBefore}\n {composer === 'rich' ? (\n <RichTextEditor\n ref={editorRef}\n ariaLabel={composerLabel}\n placeholder={placeholder}\n toolbar={editorToolbar}\n minHeight=\"fill\"\n redactor={redactor}\n imageUploadUrl={imageUploadUrl}\n readOnly={pending}\n onChange={({ html }) => setDraft(html)}\n onRequestAiDraft={onRequestAiDraft}\n aiDraftFormat={aiDraftFormat}\n aiPrivacyNotice={aiPrivacyNotice}\n onDictate={onDictate}\n onProofread={onProofread}\n onAutoFormat={onAutoFormat}\n aiConsent={aiConsent}\n variables={variables}\n validateVariable={validateVariable}\n onVariableValidityChange={onVariableValidityChange}\n renderHelpMeWrite={renderHelpMeWrite}\n onUploadImage={onUploadImage}\n onAiCreditsExhausted={onAiCreditsExhausted}\n // The panel's own title is an h2 (PanelHeader below); the\n // gate's banner nests one level under it so the h2 → h3\n // sequence stays valid (axe heading-order) instead of\n // jumping straight to the banner's own h5 default.\n aiConsentHeadingLevel={3}\n />\n ) : (\n <TextArea\n value={draft}\n readOnly={pending}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={placeholder}\n autoResize\n minRows={2}\n maxRows={6}\n aria-label={composerLabel}\n />\n )}\n <div\n className={[\n 'ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]',\n clinicalToggleShown ? 'ds:justify-between' : 'ds:justify-end',\n ].join(' ')}\n >\n {clinicalToggleShown ? (\n <Checkbox\n size=\"sm\"\n label={t('notesPanel.clinicalToggle', {\n defaultValue: 'Clinical note',\n })}\n checked={clinical}\n onCheckedChange={(next) => setClinical(next === true)}\n disabled={pending || !canAddClinicalNote}\n disabledReason={\n canAddClinicalNote\n ? undefined\n : (clinicalGatedReason ??\n t('notesPanel.clinicalGated', {\n defaultValue:\n 'You do not have permission to write clinical notes.',\n }))\n }\n />\n ) : null}\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n {editingId !== null ? (\n <Button\n type=\"button\"\n size=\"sm\"\n intent=\"ghost\"\n onClick={cancelEdit}\n disabled={pending}\n >\n {t('notesPanel.cancelEdit', { defaultValue: 'Cancel' })}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={commit}\n disabled={!hasContent}\n loading={pending}\n >\n {editingId !== null\n ? t('notesPanel.saveEdit', { defaultValue: 'Save note' })\n : (addNoteLabel ??\n t('notesPanel.add', { defaultValue: 'Add note' }))}\n </Button>\n </span>\n </div>\n {addError ? (\n <Alert variant=\"error\">\n <Alert.Description>{addError}</Alert.Description>\n </Alert>\n ) : null}\n {composerAfter}\n </div>\n ) : null}\n\n {status === 'loading' && ordered.length === 0 ? (\n /* Note-shaped placeholders, not a spinner: the reader sees where\n the notes will land and how many to expect. The status text is\n for assistive tech only; sighted readers get the motion. */\n <div\n data-notes-panel-loading=\"\"\n aria-busy=\"true\"\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n <span role=\"status\" className=\"ds:sr-only\">\n {t('notesPanel.loading')}\n </span>\n {NOTE_SKELETON_LINES.map((lines, index) => (\n <Card key={index} variant=\"elevated\" aria-hidden=\"true\">\n <Card.Body>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <Skeleton\n variant=\"circular\"\n size=\"sm\"\n stagger={index * 2}\n />\n <div className=\"ds:flex ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <Skeleton\n variant=\"text\"\n size=\"sm\"\n stagger={index * 2}\n width=\"40%\"\n />\n <Skeleton\n variant=\"text\"\n size=\"sm\"\n stagger={index * 2}\n width=\"25%\"\n />\n </div>\n </div>\n <Skeleton\n variant=\"text\"\n size=\"sm\"\n lines={lines}\n stagger={index * 2 + 1}\n />\n </div>\n </Card.Body>\n </Card>\n ))}\n </div>\n ) : status === 'error' ? (\n <Alert variant=\"error\">\n <Alert.Description>{t('notesPanel.loadError')}</Alert.Description>\n {onRetry ? (\n <Alert.Action>\n <Button intent=\"secondary\" size=\"sm\" onClick={onRetry}>\n {t('notesPanel.retry')}\n </Button>\n </Alert.Action>\n ) : null}\n </Alert>\n ) : null}\n\n {/* A refresh keeps the notes it has: real notes never give way to\n placeholders. The list is marked busy and says so to a reader. */}\n {status === 'loading' && ordered.length > 0 ? (\n <span role=\"status\" className=\"ds:sr-only\">\n {t('notesPanel.loading')}\n </span>\n ) : null}\n {ordered.length > 0 ? (\n <ul\n ref={reflowRef}\n aria-busy={status === 'loading' || undefined}\n className={`ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0 ${enterClass}`.trim()}\n >\n {ordered.map(({ actions, ...note }, index) => {\n const isCurrent =\n currentNoteId != null && note.id === currentNoteId;\n const noteId = note.id as string | undefined;\n const isEditing = noteId != null && editingId === noteId;\n const leaving = noteId != null && deleteExit.isLeaving(noteId);\n return (\n <li\n key={note.id ?? index}\n ref={isCurrent ? currentItemRef : undefined}\n // Focus lands on the row, not inside the card, so the\n // sentence below and `aria-current` are read out before the\n // note — and the rail's own Escape still bubbles.\n tabIndex={isCurrent ? -1 : undefined}\n aria-current={isCurrent ? 'true' : undefined}\n data-reflow-id={noteId}\n data-leaving={leaving ? '' : undefined}\n data-editing={isEditing ? '' : undefined}\n className={[\n noteItemVariants({\n current: isCurrent,\n washed: isCurrent || isEditing,\n }),\n noteElevationClass,\n REFLOW_ROW_CLASS,\n leaving ? noteLeavingClass : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {isCurrent ? (\n <span className=\"ds:sr-only\">\n {t('notesPanel.current', {\n defaultValue: 'Current note',\n })}\n </span>\n ) : null}\n {/* Elevated card per note; the list gap (not a separator)\n spaces them. Bodies clamp to five lines with read-more —\n except the addressed one, which is what the reader came\n for and opens in full. */}\n {/* Keyed on the address, so a repeat address of the same\n note remounts the layer and the wash plays again. Editing\n wins: a steady state must not pulse. */}\n {isEditing ? (\n <span\n aria-hidden=\"true\"\n data-notes-panel-wash=\"editing\"\n className={noteWashVariants({ state: 'editing' })}\n />\n ) : isCurrent ? (\n <span\n key={`${currentNoteId}:${currentNoteKey ?? ''}`}\n aria-hidden=\"true\"\n data-notes-panel-wash=\"addressed\"\n className={noteWashVariants({ state: 'addressed' })}\n />\n ) : null}\n <ClinicalNoteCard\n surface=\"elevated\"\n truncate={!isCurrent}\n headerActions={\n <>\n {noteActions\n ? noteActions({ ...note, actions })\n : null}\n {onEditNote &&\n noteId &&\n !note.deleted &&\n actions?.edit !== false ? (\n <IconButton\n icon={<Pencil />}\n intent=\"ghost\"\n size=\"sm\"\n aria-label={t('notesPanel.editNamed', {\n date: noteStamp(note),\n defaultValue: 'Edit note · {{date}}',\n })}\n tooltip={t('notesPanel.edit', {\n defaultValue: 'Edit note',\n })}\n aria-pressed={editingId === noteId}\n disabled={pending}\n data-notes-panel-edit=\"\"\n onClick={() =>\n editingId === noteId\n ? cancelEdit()\n : startEdit(note)\n }\n />\n ) : null}\n {onDeleteNote && noteId && !note.deleted ? (\n <IconButton\n icon={<Trash2 />}\n intent=\"ghost\"\n size=\"sm\"\n aria-label={t('notesPanel.deleteNamed', {\n date: noteStamp(note),\n defaultValue: 'Delete note · {{date}}',\n })}\n tooltip={t('notesPanel.delete', {\n defaultValue: 'Delete note',\n })}\n onClick={() => handleDeleteNote(noteId)}\n />\n ) : null}\n </>\n }\n {...note}\n onTogglePin={\n onTogglePin &&\n note.id &&\n actions?.pin !== false &&\n !note.deleted\n ? () => onTogglePin(note.id as string)\n : undefined\n }\n onToggleFlag={\n onToggleFlag && note.id\n ? () => onToggleFlag(note.id as string)\n : undefined\n }\n />\n </li>\n );\n })}\n </ul>\n ) : status !== 'ready' ? null : (\n (emptyState ?? (\n <p className=\"ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]\">\n {t('notesPanel.empty', { defaultValue: 'No notes yet.' })}\n </p>\n ))\n )}\n </div>\n\n {onDeleteNote && confirmDelete ? (\n <Dialog\n open={pendingDelete !== null}\n onOpenChange={(next) => !next && setPendingDelete(null)}\n >\n <Dialog.Content variant=\"alert\" size=\"sm\">\n <Dialog.Header>\n <Dialog.Title>\n {t('notesPanel.deleteConfirmTitle', {\n defaultValue: 'Delete this note?',\n })}\n </Dialog.Title>\n </Dialog.Header>\n <Dialog.Body>\n <Dialog.Description>\n {t('notesPanel.deleteConfirmBody', {\n defaultValue: 'The note will be removed from the record.',\n })}\n </Dialog.Description>\n </Dialog.Body>\n <Dialog.Footer>\n <Dialog.Close asChild>\n <Button\n intent=\"secondary\"\n size=\"sm\"\n onClick={() => setPendingDelete(null)}\n >\n {t('notesPanel.deleteConfirmCancel', {\n defaultValue: 'Cancel',\n })}\n </Button>\n </Dialog.Close>\n <Button\n intent=\"destructive\"\n size=\"sm\"\n onClick={confirmDeleteNote}\n >\n {t('notesPanel.deleteConfirmAction', {\n defaultValue: 'Delete',\n })}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n ) : null}\n </section>\n );\n },\n);\n"],"names":["getErrorMessage","error","fallback","notesPanelAgent","handle","args","NOTE_CONTENT_ABOVE_WASH","noteItemVariants","cva","noteWashVariants","noteLeavingClass","noteElevationClass","NOTE_SKELETON_LINES","hasRichContent","html","NotesPanel","forwardRef","id","notes","onAddNote","status","onRetry","currentNoteId","currentNoteKey","composer","editorToolbar","redactor","imageUploadUrl","showClinicalToggle","canAddClinicalNote","clinicalGatedReason","defaultClinical","onRequestAiDraft","aiDraftFormat","aiPrivacyNotice","onDictate","onProofread","onAutoFormat","aiConsent","variables","validateVariable","onVariableValidityChange","renderHelpMeWrite","onUploadImage","onAiCreditsExhausted","composerBefore","composerAfter","onTogglePin","onToggleFlag","noteActions","onEditNote","editClinical","onDeleteNote","confirmDelete","title","composerPlaceholder","addNoteLabel","emptyState","className","ariaLabel","rest","ref","t","i18n","useTranslation","editorRef","useRef","draft","setDraft","useState","clinical","setClinical","pending","setPending","addError","setAddError","editingId","setEditingId","followedLoading","enterClass","CONTENT_ENTER_CLASS","heading","headingId","useId","placeholder","composerLabel","hasContent","commit","useCallback","rich","content","_a","reset","result","clinicalToggleShown","noteStamp","note","startEdit","_b","_c","cancelEdit","editingStillThere","useEffect","ordered","a","b","resolvedTheme","useTheme","reduceMotion","reflowRef","useListReflow","n","deleteExit","useExitTransition","pendingDelete","setPendingDelete","handleDeleteNote","noteId","confirmDeleteNote","currentItemRef","notesRef","onAddNoteRef","onTogglePinRef","onToggleFlagRef","canAddClinicalRef","currentNoteIdRef","rootRef","useImperativeHandle","useMemo","submission","useAgentRegistration","jsxs","jsx","PanelHeader","NotebookPen","RichTextEditor","TextArea","event","Checkbox","next","Button","Alert","lines","index","Card","Skeleton","actions","isCurrent","isEditing","leaving","REFLOW_ROW_CLASS","ClinicalNoteCard","Fragment","IconButton","Pencil","Trash2","Dialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACO,SAASA,GAAgBC,GAAgBC,GAA0B;AACxE,SACE,OAAOD,KAAU,YACjBA,MAAU,QACV,aAAaA,KACb,OAAOA,EAAM,WAAY,YACzBA,EAAM,QAAQ,SAEPA,EAAM,UAERC;AACT;ACOO,MAAMC,KAAkD;AAAA,EAC7D,IAAI;AAAA;AAAA;AAAA,EAGJ,cAAc,CAAC,QAAQ;AAAA,EACvB,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACC,MAAWA,EAAO,SAAA;AAAA,IAAS;AAAA,IAEpC,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACA,MAAWA,EAAO,eAAA;AAAA,IAAe;AAAA,IAE1C,eAAe;AAAA,MACb,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACA,MAAWA,EAAO,iBAAA;AAAA,IAAiB;AAAA,EAC5C;AAAA,EAEF,SAAS;AAAA,IACP,UAAU;AAAA;AAAA,MAER,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,SAAS;AAAA,YACP,MAAM;AAAA,YACN,aACE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K;AAAA,sBACL,SAAS,MAAMzB,EAAiB,IAAI;AAAA,sBAEnC,YAAE,kCAAkC;AAAA,wBACnC,cAAc;AAAA,sBAAA,CACf;AAAA,oBAAA;AAAA,kBAAA,GAEL;AAAA,kBACA,gBAAAiB;AAAA,oBAACQ;AAAA,oBAAA;AAAA,sBACC,QAAO;AAAA,sBACP,MAAK;AAAA,sBACL,SAAStB;AAAA,sBAER,YAAE,kCAAkC;AAAA,wBACnC,cAAc;AAAA,sBAAA,CACf;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACH,EAAA,CACF;AAAA,cAAA,EAAA,CACF;AAAA,YAAA;AAAA,UAAA,IAEA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"panel-subview-PMBRPFOa.js","sources":["../../src/components/panel-subview/panel-subview.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { ArrowLeft } from 'lucide-react';\nimport { IconButton } from '../button/icon-button';\nimport { PanelHeader } from '../panel-header/panel-header';\nimport { ScrollArea } from '../scroll-area/scroll-area';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\nimport { usePresenceTransition } from '../../hooks/use-presence-transition';\n\n/* -------------------------------------------------------------------- */\n/* PanelSubview */\n/* */\n/* A panel inside a panel: a second view that slides over a rail panel's */\n/* own body and hands it back. An edit form, a history, a detail drilled */\n/* into from a list. The panel underneath stays mounted, so its scroll */\n/* position and state are there when the reader comes back. */\n/* */\n/* Use it instead of a Dialog when the task belongs to the panel. A modal */\n/* blanks out the calendar the rail sits beside, and the list the item */\n/* came from; a subview covers only the panel. */\n/* */\n/* It exists because the shape was being hand-built per tool: a view */\n/* flag, a PanelHeader with a back arrow, a scroll body, a pinned footer, */\n/* and focus moved by hand. Hand-built, none of them animated and each */\n/* forgot a different part of the focus contract. */\n/* */\n/* The host must be a positioned, clipped box. Wrap the panel in */\n/* `PanelSubview.Host` and render the subview as its LAST child. */\n/* -------------------------------------------------------------------- */\n\nconst hostVariants = cva(\n 'ds:relative ds:flex ds:h-full ds:min-h-0 ds:flex-col ds:overflow-hidden',\n);\n\nconst subviewVariants = cva(\n [\n 'ds:absolute ds:inset-0 ds:z-[2] ds:flex ds:min-h-0 ds:flex-col',\n 'ds:bg-[var(--background)] ds:focus-visible:outline-none',\n // Slides in from the inline end, and back out the same way. Declared at\n // rest so both directions have a value to move from.\n 'ds:transition-[opacity,translate] ds:duration-[var(--animation-duration)]',\n 'ds:ease-[var(--ease-out)] ds:motion-reduce:transition-none',\n 'ds:data-[presence=entering]:opacity-0 ds:data-[presence=leaving]:opacity-0',\n 'ds:data-[presence=entering]:translate-x-full ds:data-[presence=leaving]:translate-x-full',\n 'ds:rtl:data-[presence=entering]:-translate-x-full ds:rtl:data-[presence=leaving]:-translate-x-full',\n 'ds:data-[presence=leaving]:pointer-events-none',\n ].join(' '),\n);\n\n/* A control inside the subview whose popup is showing right now. */\nconst OPEN_POPUP =\n '[role=\"combobox\"][aria-expanded=\"true\"], [aria-haspopup][aria-expanded=\"true\"]';\n\nconst footerVariants = cva(\n [\n 'ds:flex ds:shrink-0 ds:items-center ds:justify-end',\n 'ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]',\n 'ds:border-t ds:border-[color:var(--border)]',\n ].join(' '),\n);\n\n/* -------------------------------------------------------------------- */\n/* Host */\n/* -------------------------------------------------------------------- */\n\nexport type PanelSubviewHostProps = HTMLAttributes<HTMLDivElement>;\n\n/** The positioned, clipped box a subview slides inside. Fills its parent. */\nconst PanelSubviewHost = forwardRef<HTMLDivElement, PanelSubviewHostProps>(\n ({ className, children, ...rest }, ref) => (\n <div\n ref={ref}\n data-component=\"panel-subview-host\"\n className={[hostVariants(), className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nPanelSubviewHost.displayName = 'PanelSubview.Host';\n\n/* -------------------------------------------------------------------- */\n/* Subview */\n/* -------------------------------------------------------------------- */\n\nexport interface PanelSubviewProps extends Omit<\n HTMLAttributes<HTMLElement>,\n 'title'\n> {\n /** Whether the subview is showing. It animates in and out around this. */\n open: boolean;\n /** Fires from the back button and from Escape. Set `open` false in reply. */\n onBack: () => void;\n /** The subview's heading. Already translated upstream. */\n title: ReactNode;\n /** Accessible name and tooltip of the back button. Already translated. */\n backLabel: string;\n /** Optional leading glyph for the heading. */\n icon?: ReactNode;\n /** Heading level. Default `2`; pass `3` to read as subordinate to the host. */\n headingLevel?: 2 | 3;\n /** Extra header actions, rendered after the back button. */\n headerActions?: ReactNode;\n /** Pinned below the scroll body: the form's cancel and save, typically. */\n footer?: ReactNode;\n /** Fires once the exit has played and the subview has unmounted. */\n onExited?: () => void;\n /**\n * Focus this on open instead of the subview itself: a form's first field,\n * say. The subview is still announced through its heading.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n children: ReactNode;\n}\n\nconst PanelSubviewRoot = forwardRef<HTMLElement, PanelSubviewProps>(\n (\n {\n open,\n onBack,\n title,\n backLabel,\n icon,\n headingLevel,\n headerActions,\n footer,\n onExited,\n initialFocusRef,\n className,\n children,\n ...rest\n },\n ref,\n ) => {\n const headingId = useId();\n const presence = usePresenceTransition<HTMLElement>(open, { onExited });\n const nodeRef = useRef<HTMLElement | null>(null);\n const returnFocusRef = useRef<HTMLElement | null>(null);\n const onBackRef = useRef(onBack);\n onBackRef.current = onBack;\n\n const { ref: presenceRef } = presence;\n const setNode = useCallback(\n (node: HTMLElement | null) => {\n nodeRef.current = node;\n presenceRef(node);\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [presenceRef, ref],\n );\n\n // Remember where focus was BEFORE the subview takes it, during render of\n // the opening pass, so the trigger is still the active element.\n const wasOpenRef = useRef(open);\n if (open && !wasOpenRef.current && typeof document !== 'undefined') {\n returnFocusRef.current =\n document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n }\n wasOpenRef.current = open;\n\n /* The panel underneath is covered, so it leaves the tab order and the\n accessibility tree for as long as the subview is open. */\n useIsomorphicLayoutEffect(() => {\n const node = nodeRef.current;\n const parent = node?.parentElement;\n if (!open || !node || !parent) return undefined;\n const covered = Array.from(parent.children).filter(\n (child) => child !== node && !child.hasAttribute('inert'),\n );\n covered.forEach((child) => child.setAttribute('inert', ''));\n // `preventScroll`: the subview is still off to the side at this point,\n // and a clipped Host would otherwise scroll sideways to reveal it.\n (initialFocusRef?.current ?? node).focus({ preventScroll: true });\n return () => {\n covered.forEach((child) => child.removeAttribute('inert'));\n };\n }, [open, presence.mounted, initialFocusRef]);\n\n /* A leaving subview is already closed to the user: `aria-hidden` alone\n would leave its controls focusable, so it goes `inert` while it fades.\n Set on the node, not as a prop: React 18 has no boolean for it. */\n const leaving = !open;\n useIsomorphicLayoutEffect(() => {\n const node = nodeRef.current;\n if (!node) return;\n // Blur first: nothing focused may sit inside a hidden subtree, even for\n // the moment before the passive effect below hands focus back.\n const active = document.activeElement;\n if (leaving && active instanceof HTMLElement && node.contains(active)) {\n active.blur();\n }\n node.toggleAttribute('inert', leaving);\n }, [leaving, presence.mounted]);\n\n /* Hand focus back to whatever opened the subview. A PASSIVE effect: React\n restores the pre-commit focus at the end of a commit, so a return made\n from a layout cleanup is overwritten by the closing subview itself. */\n useEffect(() => {\n if (!open) return undefined;\n return () => {\n const target = returnFocusRef.current;\n returnFocusRef.current = null;\n if (target?.isConnected) target.focus();\n };\n }, [open]);\n\n /* Escape goes back one level. A NATIVE listener: the rail collapses on\n Escape through its own native listener further up, and only a native\n stopPropagation here keeps one key press from doing both. */\n useEffect(() => {\n const node = nodeRef.current;\n if (!open || !node) return undefined;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n // Spent here either way: a key pressed inside never collapses the rail.\n event.stopPropagation();\n /* An OPEN popup inside took the key to close itself. A closed,\n force-mounted one (Combobox) prevents default too, so ask the DOM. */\n if (event.defaultPrevented && node.querySelector(OPEN_POPUP)) return;\n event.preventDefault();\n onBackRef.current();\n };\n node.addEventListener('keydown', onKeyDown);\n return () => node.removeEventListener('keydown', onKeyDown);\n }, [open, presence.mounted]);\n\n if (!presence.mounted) return null;\n\n return (\n <section\n {...rest}\n ref={setNode}\n tabIndex={-1}\n aria-labelledby={headingId}\n aria-hidden={leaving || undefined}\n data-component=\"panel-subview\"\n data-presence={presence.phase}\n className={[subviewVariants(), className].filter(Boolean).join(' ')}\n >\n <PanelHeader\n icon={icon}\n title={title}\n headingId={headingId}\n headingLevel={headingLevel}\n sticky\n divider\n actions={\n <>\n <IconButton\n icon={<ArrowLeft aria-hidden=\"true\" />}\n intent=\"ghost\"\n size=\"sm\"\n flipIconInRtl\n aria-label={backLabel}\n tooltip={backLabel}\n data-panel-subview-back=\"\"\n onClick={onBack}\n />\n {headerActions}\n </>\n }\n />\n <ScrollArea orientation=\"vertical\" className=\"ds:min-h-0 ds:flex-1\">\n {children}\n </ScrollArea>\n {footer ? (\n <div data-panel-subview-footer=\"\" className={footerVariants()}>\n {footer}\n </div>\n ) : null}\n </section>\n );\n },\n);\nPanelSubviewRoot.displayName = 'PanelSubview';\n\nexport const PanelSubview = Object.assign(PanelSubviewRoot, {\n Host: PanelSubviewHost,\n});\n"],"names":["hostVariants","cva","subviewVariants","OPEN_POPUP","footerVariants","PanelSubviewHost","forwardRef","className","children","rest","ref","jsx","PanelSubviewRoot","open","onBack","title","backLabel","icon","headingLevel","headerActions","footer","onExited","initialFocusRef","headingId","useId","presence","usePresenceTransition","nodeRef","useRef","returnFocusRef","onBackRef","presenceRef","setNode","useCallback","node","wasOpenRef","useIsomorphicLayoutEffect","parent","covered","child","leaving","active","useEffect","target","onKeyDown","event","jsxs","PanelHeader","Fragment","IconButton","ArrowLeft","ScrollArea","PanelSubview"],"mappings":";;;;;;;;;AAuCA,MAAMA,IAAeC;AAAA,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