@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-me-write-templates-GUeEn3Ff.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 in the\n * RichTextEditor.\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). Templates are an AI action of the editor itself, next to\n * spelling and auto-format: a Templates segment in the AI pill and in the\n * selection bubble (`aiTemplates`). Picking one rewrites the selection, else\n * the whole note, then this pattern offers Undo. The editor keeps the\n * patient AI-consent gate and resume-after-grant for all of it.\n *\n * Parts, usable on their own or wired together by `useHelpMeWriteTemplates`:\n * - `HelpMeWriteTemplatesBar` — the Help-me-write bar (`renderHelpMeWrite`):\n * a free prompt with an optional mic, the draft and Insert.\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 * an AI call rejects with `AiCreditsExhaustedError`, from the bar or the pill.\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 DragEvent,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\nimport {\n ArrowLeft,\n Astroid,\n GripVertical,\n Mic,\n Pencil,\n Plus,\n RotateCcw,\n Send,\n Square,\n Trash2,\n TrendingUp,\n X,\n} from 'lucide-react';\n\nimport { Alert } from '../../components/alert';\nimport { Button, IconButton } from '../../components/button';\nimport { Dialog } from '../../components/dialog';\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 {\n HelpMeWriteRenderContext,\n RichTextEditorAiApplied,\n RichTextEditorAiTemplates,\n} from '../../components/rich-text-editor';\nimport { Spinner } from '../../components/spinner';\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 /**\n * @deprecated The list order is the menu order: the first template is the\n * one most people use. Ignored; reorder with `onReorderTemplates`.\n */\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 /**\n * The context, as plain text. For a template, the text it rewrites. For\n * the free prompt, what the draft is about. From the AI pill it is the\n * whole note; from the selection bubble, the selected text.\n */\n sourceText: string;\n /** Where `sourceText` came from. */\n scope?: 'document' | 'selection';\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 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\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\n// Default template first, then the rest in their saved order.\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 /**\n * @deprecated Templates run from the editor's AI pill (`aiTemplates`),\n * not from this bar. Ignored.\n */\n templates?: AiTemplate[];\n /** The AI call. Reject with `AiCreditsExhaustedError` when out of credits. */\n onGenerate: (request: HelpMeWriteRequest) => Promise<string>;\n /** @deprecated The manager opens from the pill's Templates menu. Ignored. */\n onManageTemplates?: (mode: 'list' | 'create') => void;\n /** After a draft lands. */\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\n/**\n * The Help-me-write bar, docked in the editor's AI slot: a free prompt with\n * an optional mic, then the draft and Insert. It also shows the\n * out-of-credits notice, including when a pill action ran out.\n */\nexport function HelpMeWriteTemplatesBar({\n context,\n onGenerate,\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 draftId = useId();\n const errorId = useId();\n const [prompt, setPrompt] = useState('');\n const [loading, setLoading] = useState(false);\n const [errored, setErrored] = useState(false);\n const [outOfCredits, setOutOfCredits] = useState(false);\n const [draft, setDraft] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(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.\n useEffect(() => {\n if (open) {\n setPrompt('');\n setLoading(false);\n setErrored(false);\n // Opened because an AI call ran out of credits: start on the notice.\n setOutOfCredits(context.creditsExhausted);\n setDraft(null);\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 if (loading || !prompt.trim()) return;\n stopDictation();\n abortRef.current?.abort();\n const controller = new AbortController();\n abortRef.current = controller;\n setErrored(false);\n setLoading(true);\n const onSelection = context.scope === 'selection';\n onGenerate({\n prompt: prompt.trim(),\n sourceText: onSelection ? context.selectionText : context.getText(),\n scope: onSelection ? 'selection' : 'document',\n signal: controller.signal,\n })\n .then((result) => {\n if (controller.signal.aborted) return;\n setDraft(result);\n setLoading(false);\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 setLoading(false);\n });\n // `context` is a fresh object every editor render; read it at call time.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [loading, prompt, onGenerate, stopDictation]);\n\n const { onClose: contextClose } = context;\n const close = useCallback(() => {\n if (suspendClose) return;\n contextClose();\n }, [suspendClose, contextClose]);\n\n const insert = () => {\n if (draft === null) return;\n const previousHtml = context.getHTML();\n context.insertAtSelection(draft);\n context.onClose();\n const { setContent } = context;\n onApplied?.({\n mode: context.scope === 'selection' ? 'replace' : 'insert',\n previousHtml,\n undo: () => setContent(previousHtml),\n });\n };\n\n let body: ReactNode;\n if (outOfCredits) {\n body = (\n <AiCreditsExhaustedNotice\n credits={credits}\n onBack={() => setOutOfCredits(false)}\n />\n );\n } else if (draft !== null) {\n body = (\n <>\n <section\n aria-labelledby={draftId}\n className=\"ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]\"\n >\n <h2 id={draftId} className={eyebrowClass}>\n {t('helpMeWriteTemplates.bar.after')}\n </h2>\n <SafeHtml\n html={draft}\n profile=\"rich-text\"\n className={previewClass}\n tabIndex={0}\n />\n </section>\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 setDraft(null);\n run();\n }}\n >\n {t('helpMeWriteTemplates.bar.retry')}\n </Button>\n <span className=\"ds:flex-1\" aria-hidden=\"true\" />\n <Button intent=\"primary\" onClick={insert}>\n {context.scope === 'selection'\n ? t('helpMeWriteTemplates.bar.replace')\n : t('helpMeWriteTemplates.bar.insert')}\n </Button>\n </div>\n </>\n );\n } else {\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 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('editor.ai.promptPlaceholder')}\n aria-label={t('editor.ai.promptLabel')}\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 <IconButton\n size=\"md\"\n intent=\"primary\"\n className={BRAND_ACTION}\n icon={loading ? <Spinner size=\"sm\" variant=\"pulse\" /> : <Send />}\n disabled={loading || !prompt.trim()}\n aria-busy={loading || undefined}\n aria-label={t('helpMeWriteTemplates.bar.write')}\n onClick={run}\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 className={metaClass}>\n {context.scope === 'selection'\n ? t('helpMeWriteTemplates.bar.contextSelection')\n : t('helpMeWriteTemplates.bar.contextDocument')}{' '}\n {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\n/* The kit's list-reorder idiom (Sidebar favourites, anamnesis): HTML5 drag\n on the row, a grip handle that also moves with Alt+Arrow / Alt+Home /\n Alt+End, and a polite announcement of every move. Rows are keyed, so the\n moved row's handle keeps focus. */\nconst reorderRowClass = cva('', {\n variants: {\n dragging: { true: 'ds:opacity-60', false: '' },\n dropTarget: {\n true: 'ds:outline-[length:var(--focus-ring-width)] ds:outline-dashed ds:outline-[var(--primary)] ds:outline-offset-[-2px]',\n false: '',\n },\n },\n defaultVariants: { dragging: false, dropTarget: false },\n});\n\nfunction useReorder(\n templates: AiTemplate[],\n onReorder: ((orderedIds: string[]) => void | Promise<void>) | undefined,\n) {\n const { t } = useTranslation();\n const [dragSource, setDragSource] = useState<number | null>(null);\n const [dropTarget, setDropTarget] = useState<number | null>(null);\n const [message, setMessage] = useState('');\n // Toggle an invisible suffix so a repeated move is announced again.\n const toggle = useRef(false);\n\n const move = (from: number, to: number): void => {\n const target = Math.max(0, Math.min(templates.length - 1, to));\n if (!onReorder || target === from) return;\n const ids = templates.map((tpl) => tpl.id);\n const [moved] = ids.splice(from, 1);\n ids.splice(target, 0, moved);\n void onReorder(ids);\n toggle.current = !toggle.current;\n const text = t('helpMeWriteTemplates.manager.reorderAnnounce', {\n label: templates[from].name,\n to: target + 1,\n total: templates.length,\n });\n setMessage(toggle.current ? text : `${text}\\u200b`);\n };\n\n const rowProps = (index: number) =>\n onReorder\n ? {\n draggable: true as const,\n onDragStart: (event: DragEvent<HTMLElement>) => {\n setDragSource(index);\n event.dataTransfer.effectAllowed = 'move';\n // Firefox needs data to start a drag.\n event.dataTransfer.setData('text/plain', String(index));\n },\n onDragEnd: () => {\n setDragSource(null);\n setDropTarget(null);\n },\n onDragOver: (event: DragEvent<HTMLElement>) => {\n if (dragSource === null) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'move';\n setDropTarget(index);\n },\n onDragLeave: () => setDropTarget(null),\n onDrop: (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n const source = dragSource;\n setDragSource(null);\n setDropTarget(null);\n if (source !== null) move(source, index);\n },\n }\n : {};\n\n const rowClass = (index: number): string =>\n reorderRowClass({\n dragging: dragSource === index,\n dropTarget: dropTarget === index && dragSource !== index,\n });\n\n const handle = (index: number, name: string): ReactNode => (\n <IconButton\n size=\"sm\"\n intent=\"ghost\"\n icon={<GripVertical aria-hidden=\"true\" />}\n aria-label={t('helpMeWriteTemplates.manager.reorderHandle', {\n label: name,\n })}\n className=\"ds:cursor-grab ds:active:cursor-grabbing\"\n onKeyDown={(event: KeyboardEvent<HTMLButtonElement>) => {\n if (!event.altKey) return;\n const to =\n event.key === 'ArrowUp'\n ? index - 1\n : event.key === 'ArrowDown'\n ? index + 1\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? templates.length - 1\n : null;\n if (to === null) return;\n event.preventDefault();\n move(index, to);\n }}\n />\n );\n\n const liveRegion = (\n <span role=\"status\" aria-live=\"polite\" className=\"ds:sr-only\">\n {message}\n </span>\n );\n\n return { rowProps, rowClass, handle, liveRegion };\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 * Persist a new order (every template id, first to last): the order of\n * the Templates menu. Omit to hide the drag handles.\n */\n onReorderTemplates?: (orderedIds: string[]) => void | Promise<void>;\n}\n\ninterface FormState {\n id?: string;\n name: string;\n description: string;\n prompt: string;\n submitted: boolean;\n}\n\nconst EMPTY_FORM: FormState = {\n name: '',\n description: '',\n prompt: '',\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 onReorderTemplates,\n}: AiTemplateManagerProps): React.JSX.Element {\n const { t } = useTranslation();\n const reorder = useReorder(templates, onReorderTemplates);\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(initialMode === 'create' ? { ...EMPTY_FORM } : null);\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 });\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 </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 }),\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 {templates.map((tpl, index) => (\n <li\n key={tpl.id}\n {...reorder.rowProps(index)}\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)] ${reorder.rowClass(index)}`}\n >\n {onReorderTemplates\n ? reorder.handle(index, tpl.name)\n : null}\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 </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 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 {reorder.liveRegion}\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 /** The AI call, for both templates (from the pill) and the free prompt. */\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 /** Enables drag-and-drop reordering in the manager (the menu order). */\n onReorderTemplates?: AiTemplateManagerProps['onReorderTemplates'];\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\n/** The `RichTextEditor` props the hook drives; spread them on the editor. */\nexport interface HelpMeWriteTemplatesEditorProps {\n renderHelpMeWrite: (context: HelpMeWriteRenderContext) => ReactNode;\n aiTemplates: RichTextEditorAiTemplates;\n onAiApplied: (applied: RichTextEditorAiApplied) => void;\n}\n\nexport interface UseHelpMeWriteTemplatesResult extends HelpMeWriteTemplatesEditorProps {\n /** All three editor props at once: `<RichTextEditor {...hmw.editorProps} />`. */\n editorProps: HelpMeWriteTemplatesEditorProps;\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 templates, the Help-me-write bar, the manager and Undo into the\n * editor. Templates run from the editor's AI pill and selection bubble;\n * the bar is the free prompt. Usage:\n *\n * const hmw = useHelpMeWriteTemplates({ templates, onGenerate, onSaveTemplate });\n * {hmw.undoNotice}\n * <RichTextEditor {...hmw.editorProps} … />\n * {hmw.manager}\n */\nexport function useHelpMeWriteTemplates({\n templates,\n onGenerate,\n onSaveTemplate,\n onDeleteTemplate,\n onReorderTemplates,\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 <HelpMeWriteTemplatesBar\n context={context}\n onGenerate={onGenerate}\n credits={credits}\n enableDictation={enableDictation}\n suspendClose={manager.open}\n onApplied={onApplied}\n />\n ),\n [onGenerate, credits, enableDictation, manager.open, onApplied],\n );\n\n // The editor runs templates; the host's full template (with its prompt)\n // goes to `onGenerate`, looked up by id.\n const aiTemplates = useMemo<RichTextEditorAiTemplates>(() => {\n const byId = new Map(templates.map((tpl) => [tpl.id, tpl]));\n return {\n templates,\n onRun: ({ template, text, scope, signal }): Promise<string> => {\n const full = byId.get(template.id);\n if (!full) return Promise.reject(new Error('Unknown template'));\n return onGenerate({\n template: full,\n prompt: '',\n sourceText: text,\n scope,\n signal,\n });\n },\n onManage: onSaveTemplate ? openManager : undefined,\n };\n }, [templates, onGenerate, onSaveTemplate, openManager]);\n\n const onAiApplied = useCallback(\n (event: RichTextEditorAiApplied): void => {\n if (event.action !== 'template' || !event.template) return;\n const template = templates.find((tpl) => tpl.id === event.template?.id);\n const change: HelpMeWriteApplied = {\n mode: 'replace',\n template,\n previousHtml: event.previousHtml,\n undo: event.undo,\n };\n setApplied(template ? change : null);\n onApplied?.(change);\n },\n [templates, onApplied],\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 onReorderTemplates={onReorderTemplates}\n />\n ) : null,\n [manager, templates, onSaveTemplate, onDeleteTemplate, onReorderTemplates],\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 const editorProps = useMemo<HelpMeWriteTemplatesEditorProps>(\n () => ({ renderHelpMeWrite, aiTemplates, onAiApplied }),\n [renderHelpMeWrite, aiTemplates, onAiApplied],\n );\n\n return {\n ...editorProps,\n editorProps,\n manager: managerNode,\n undoNotice,\n openManager,\n };\n}\n"],"names":["AiCreditsExhaustedError","message","ACTION_SIZE","BRAND_ACTION","RECORDING_MIC","metaClass","eyebrowClass","previewClass","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","onApplied","enableDictation","suspendClose","open","draftId","useId","errorId","prompt","setPrompt","useState","loading","setLoading","errored","setErrored","outOfCredits","setOutOfCredits","draft","setDraft","abortRef","useRef","onDictate","isDictating","setIsDictating","interim","setInterim","announcement","setAnnouncement","dictateAbortRef","stopDictation","useCallback","_a","toggleDictation","controller","text","trimmed","p","useEffect","_b","run","onSelection","result","contextClose","close","insert","previousHtml","setContent","body","Fragment","SafeHtml","X","RotateCcw","fieldValue","IconButton","TextArea","event","Square","Mic","Spinner","Send","EditorOverlay","reorderRowClass","cva","useReorder","templates","onReorder","dragSource","setDragSource","dropTarget","setDropTarget","setMessage","toggle","move","from","to","target","ids","tpl","moved","index","source","name","GripVertical","EMPTY_FORM","AiTemplateManager","onOpenChange","initialMode","onSaveTemplate","onDeleteTemplate","onReorderTemplates","reorder","form","setForm","saving","setSaving","saveFailed","setSaveFailed","pendingDelete","setPendingDelete","deleting","setDeleting","deleteFailed","setDeleteFailed","confirmDelete","nameTaken","id","nameError","promptError","save","next","title","Dialog","FormField","TextInput","EmptyState","Pencil","Trash2","Plus","HelpMeWriteUndoNotice","applied","onUndo","onDismiss","undoRef","isOpen","useHelpMeWriteTemplates","manager","setManager","setApplied","openManager","mode","renderHelpMeWrite","aiTemplates","useMemo","byId","template","scope","signal","full","onAiApplied","change","managerNode","m","undoNotice","editorProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHO,MAAMA,WAAgC,MAAM;AAAA,EACjD,YAAYC,IAAU,wBAAwB;AAC5C,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACd;AACF;AAkCA,MAAMC,IAAc,qCACdC,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ACTQ,EAAW,IAAI;AAAA,MACjB;AAAA,MACA,WAAW,MAAMA,EAAW,IAAI;AAAA,IAAA;AAAA,EAAA,GAI9BgB,IAAcX;AAAA,IAClB,OAAO,EAAE,mBAAAF,GAAmB,aAAAC,GAAa,aAAAO;IACzC,CAACR,GAAmBC,GAAaO,CAAW;AAAA,EAAA;AAG9C,SAAO;AAAA,IACL,GAAGK;AAAA,IACH,aAAAA;AAAA,IACA,SAASH;AAAA,IACT,YAAAE;AAAA,IACA,aAAAd;AAAA,EAAA;AAEJ;"}
|
package/dist/_chunks/{marketplace-app-shell-D_g9BaDI.js → marketplace-app-shell-DdwPj03y.js}
RENAMED
|
@@ -7,11 +7,11 @@ import { A as S } from "./avatar-CkDeQOSI.js";
|
|
|
7
7
|
import { A as F } from "./alert-CiQ5Pa3Q.js";
|
|
8
8
|
import { C as w } from "./card-DPmk26CL.js";
|
|
9
9
|
import { D as m } from "./dropdown-menu-DU-Hrf33.js";
|
|
10
|
-
import { T as q } from "./tab-bar-
|
|
10
|
+
import { T as q } from "./tab-bar-Cw9UK18Z.js";
|
|
11
11
|
import { a as A, H as G, g as J, f as z, e as K, c as Q, d as U } from "./header-3o9o9v_T.js";
|
|
12
12
|
import { H as X } from "./header-settings-CTe45iDy.js";
|
|
13
13
|
import { S as Y } from "./sign-in-with-alfadocs-button-DWwBJtyE.js";
|
|
14
|
-
import { S as Z, g as _, b as aa, a as ea, j as sa, k as ta, i as ra, h as I } from "./sidebar-
|
|
14
|
+
import { S as Z, g as _, b as aa, a as ea, j as sa, k as ta, i as ra, h as I } from "./sidebar-DbZXLl8h.js";
|
|
15
15
|
import { T as na } from "./theme-root-BOO73p5t.js";
|
|
16
16
|
import { a as da } from "./tooltip-Cp-PLePW.js";
|
|
17
17
|
import { u as ia } from "./use-theme-CAuo6EYT.js";
|
|
@@ -529,4 +529,4 @@ export {
|
|
|
529
529
|
ka as M,
|
|
530
530
|
g as P
|
|
531
531
|
};
|
|
532
|
-
//# sourceMappingURL=marketplace-app-shell-
|
|
532
|
+
//# sourceMappingURL=marketplace-app-shell-DdwPj03y.js.map
|
package/dist/_chunks/{marketplace-app-shell-D_g9BaDI.js.map → marketplace-app-shell-DdwPj03y.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace-app-shell-D_g9BaDI.js","sources":["../../src/brand/product-lockup/product-lockup.tsx","../../src/patterns/marketplace-app-shell/marketplace-app-shell.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { Logo } from '../../components/logo/logo';\nimport { AlfadocsLogoMark, AlfadocsLogoNeg } from '../logo-asset';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\n// Outer lockup row. ~4px logical gap between the wordmark and the product\n// name (`--spacing-xs`), centre-aligned so the name's cap height sits\n// against the wordmark's letterforms.\nconst lockup = cva('ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]');\n\n// The product name. Marketing serif (Fraunces, `--font-serif`) — permitted\n// here because this file lives under `src/brand/`, never in `src/components/`\n// or `src/patterns/` (constraint 10). Sized to ~95% of the wordmark height so\n// its cap height matches the logo letterforms across every size and theme\n// (the `--logo-size-*` tokens shift up in the accessible themes; the calc\n// keeps the name proportional for free).\nconst productName = cva(\n [\n 'ds:[font-family:var(--font-serif)]',\n 'ds:font-semibold',\n 'ds:leading-none',\n 'ds:tracking-[0.01em]',\n 'ds:whitespace-nowrap',\n // Forced-colors: drop the transparent text-fill and paint the label\n // as solid CanvasText so it never disappears under Windows HCM —\n // a gradient/transparent fill has no meaning there.\n 'ds:forced-colors:text-[CanvasText]',\n 'ds:forced-colors:[-webkit-text-fill-color:CanvasText]',\n ],\n {\n variants: {\n size: {\n sm: 'ds:text-[calc(var(--logo-size-sm)*0.95)]',\n md: 'ds:text-[calc(var(--logo-size-md)*0.95)]',\n lg: 'ds:text-[calc(var(--logo-size-lg)*0.95)]',\n xl: 'ds:text-[calc(var(--logo-size-xl)*0.95)]',\n },\n tone: {\n // Brand gradient filled into the glyphs via background-clip:text.\n // `--gradient-wordmark` rides the theme aliases, so it stays\n // AA-safe and adapts per theme on its own (and flattens to a solid\n // ink in the accessible / forced-colors blocks — see tokens).\n gradient: [\n 'ds:italic',\n 'ds:bg-[image:var(--gradient-wordmark)]',\n 'ds:bg-clip-text',\n 'ds:text-transparent',\n 'ds:[-webkit-text-fill-color:transparent]',\n ],\n // Monochrome: solid currentColor ink, upright, no gradient — for\n // print, single-colour work, and coloured chrome (e.g. app-shell\n // headers) where the lockup must ride the surrounding ink.\n solid: 'ds:text-current',\n },\n },\n defaultVariants: { size: 'md', tone: 'gradient' },\n },\n);\n\n// Maker lockup root. Sets a single `--lockup-unit` custom property to the\n// matching `--logo-size-*` token; every maker sub-element (mark, name, the\n// \"by Alfadocs\" tag) sizes off `var(--lockup-unit)`, so there's one per-size\n// source of truth that shifts up with the accessible themes for free.\n// `whitespace-nowrap` keeps \"[mark] Name by Alfadocs\" on one line.\nconst makerRoot = cva('ds:whitespace-nowrap', {\n variants: {\n size: {\n sm: 'ds:[--lockup-unit:var(--logo-size-sm)]',\n md: 'ds:[--lockup-unit:var(--logo-size-md)]',\n lg: 'ds:[--lockup-unit:var(--logo-size-lg)]',\n xl: 'ds:[--lockup-unit:var(--logo-size-xl)]',\n },\n },\n defaultVariants: { size: 'md' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\ntype LockupSize = NonNullable<VariantProps<typeof productName>['size']>;\n\nexport type ProductLockupProps = {\n /**\n * The product name. Passed verbatim (product names are not translated).\n *\n * - `variant=\"standard\"` (default): renders as \"Alfadocs <name>\" with the\n * wordmark; accessible name is `Alfadocs <name>`.\n * - `variant=\"maker\"`: renders as \"[mark] <name> by Alfadocs\"; accessible\n * name is `<name> by Alfadocs`.\n */\n name: string;\n /**\n * Which lockup composition to use.\n *\n * - `'standard'` (default) — Alfadocs wordmark + product name (\"Alfadocs\n * Builders\"). Use for **internal** Alfadocs products (Alfadocs Builders,\n * Alfadocs API) where the product is part of the Alfadocs family.\n * - `'maker'` — \"<name> by Alfadocs\" with the four-pillar mark and the name\n * as the prominent element. Use for **external** marketplace extensions\n * (\"Scribe by Alfadocs\") where the extension's own name leads and\n * \"by Alfadocs\" is the maker attribution.\n */\n variant?: 'standard' | 'maker';\n /**\n * Render the name as a solid `--foreground` ink, upright (no gradient, no\n * italic), and pair it with the monochrome wordmark. Use for print,\n * single-colour reproductions, or any constrained context where the\n * gradient/serif treatment is inappropriate.\n */\n monochrome?: boolean;\n /**\n * Ink resolution. `'auto'` (default) uses the lockup's intended ink\n * (`--foreground` for monochrome). `'inherit'` makes the whole lockup ride\n * `currentColor` — use it with `monochrome` on a coloured brand surface (a\n * tinted header or split-login panel) so the wordmark + name both take the\n * surface's text colour rather than clashing with a fixed `--foreground`.\n */\n tone?: 'auto' | 'inherit';\n /** Lockup size. Drives both the wordmark and the name's cap height. */\n size?: LockupSize;\n className?: string;\n} & Omit<\n ComponentPropsWithoutRef<'span'>,\n 'role' | 'aria-label' | 'aria-hidden' | 'children' | 'className'\n>;\n\n/* ------------------------------------------------------------------ */\n/* ProductLockup */\n/* ------------------------------------------------------------------ */\n\n/**\n * Pairs a product name with the Alfadocs brand. Two compositions:\n *\n * - `variant=\"standard\"` (default) — the Alfadocs wordmark + product name\n * (\"Alfadocs Builders\"). For internal Alfadocs products. Exposed to\n * assistive tech as a single `img` named `Alfadocs <name>`.\n * - `variant=\"maker\"` — \"[mark] <name> by Alfadocs\". For external marketplace\n * extensions where the extension's name leads. Exposed as a single `img`\n * named `<name> by Alfadocs`.\n *\n * In both cases the inner wordmark/mark and the visible name are decorative so\n * the brand isn't announced twice. Every marketplace app should use this\n * rather than hand-rolling a wordmark + typed span.\n */\nexport const ProductLockup = forwardRef<HTMLSpanElement, ProductLockupProps>(\n (\n {\n name,\n variant = 'standard',\n monochrome = false,\n tone = 'auto',\n size = 'md',\n className,\n ...props\n },\n ref,\n ) => {\n if (import.meta.env.DEV && !name.trim()) {\n console.warn(\n '[ProductLockup] `name` is empty — the lockup will render the bare wordmark with no product name. Pass the product name (e.g. \"Builders\").',\n );\n }\n\n if (variant === 'maker') {\n // Ink matrix mirrors the standard variant's tone/monochrome model:\n // - tone=\"inherit\": every element rides currentColor (no explicit ink),\n // for coloured surfaces.\n // - monochrome (tone auto): foreground ink, with the attribution muted.\n // - default (colour, tone auto): the name + mark take --primary; the\n // wordmark lettering stays --foreground; the attribution is muted.\n const inherit = tone === 'inherit';\n const markInk = inherit\n ? ''\n : monochrome\n ? 'ds:text-[color:var(--foreground)]'\n : 'ds:text-[color:var(--primary)]';\n const nameInk = inherit\n ? ''\n : monochrome\n ? 'ds:text-[color:var(--foreground)]'\n : 'ds:text-[color:var(--primary)]';\n const byInk = inherit ? '' : 'ds:text-[color:var(--muted-foreground)]';\n const letteringInk = inherit ? '' : 'ds:text-[color:var(--foreground)]';\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={`${name} by Alfadocs`.trim()}\n className={makerRoot({ size, className })}\n data-component=\"product-lockup\"\n {...props}\n >\n {/* Pillar mark sized close to the app name (≈0.88 of the serif em),\n vertically centred on it. Inline (not flex) so the maker tag can\n use vertical-align. */}\n <AlfadocsLogoMark\n aria-hidden\n className={`ds:inline-block ds:align-middle ds:me-[var(--spacing-sm)] ds:h-[calc(var(--lockup-unit)*0.88)] ds:w-auto ds:forced-colors:text-[CanvasText] ${markInk}`}\n />\n <span\n aria-hidden\n className={`ds:align-middle ds:[font-family:var(--font-serif)] ds:font-semibold ds:italic ds:leading-none ds:tracking-[0.01em] ${nameInk} ds:text-[calc(var(--lockup-unit)*0.95)]`}\n >\n {name}\n </span>\n {/* Maker tag — superscript style, its top aligned to the app name's\n cap-height via vertical-align: text-top. */}\n <span\n aria-hidden\n className={`ds:align-text-top ds:ms-[var(--spacing-sm)] ds:inline-flex ds:items-baseline ds:gap-[var(--spacing-2xs)] ${byInk}`}\n >\n <span className=\"ds:text-[calc(var(--lockup-unit)*0.4)] ds:leading-none\">\n by\n </span>\n {/* Real Alfadocs wordmark SVG. The Neg SVG's first <g> is the\n \"Alfadocs\" lettering; the second <g> is the four-pillar mark\n (x≈3–146). viewBox=\"168 0 637 125\" windows to the lettering\n only — no mark, no hand-typed wordmark. */}\n <AlfadocsLogoNeg\n aria-hidden\n viewBox=\"168 0 637 125\"\n className={`ds:h-[calc(var(--lockup-unit)*0.45)] ds:w-auto ds:forced-colors:text-[CanvasText] ${letteringInk}`}\n />\n </span>\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={`Alfadocs ${name}`.trim()}\n className={lockup({ className })}\n data-component=\"product-lockup\"\n {...props}\n >\n <Logo\n variant={monochrome ? 'monochrome' : 'wordmark'}\n tone={tone}\n size={size}\n decorative\n />\n <span\n aria-hidden\n className={productName({\n size,\n tone: monochrome ? 'solid' : 'gradient',\n })}\n >\n {name}\n </span>\n </span>\n );\n },\n);\nProductLockup.displayName = 'ProductLockup';\n","/**\n * Marketplace App Shell — the standard chrome for an app built on top of\n * AlfaDocs (the kind a partner scaffolds with Claude Code, Lovable, etc.).\n *\n * It is a thin, opinionated composition of kit primitives: an `AppFrame` with\n * a branded `Header` (the maker `ProductLockup` — \"<Product> by Alfadocs\" —\n * rendered `monochrome` so it rides the header's ink; maker is the lockup\n * style for external marketplace extensions), a `Sidebar` for app\n * navigation, `HeaderSettings` (theme/locale/accessibility), and a bare-avatar\n * account menu (fullscreen + sign-out) matching the main app shell.\n * `ConnectWithAlfadocs` is the matching pre-auth screen, with the full-colour\n * maker lockup and `SignInWithAlfadocsButton`.\n *\n * Like `AliaSidebar`, this pattern ships a RUNTIME component (surfaced via\n * `src/patterns/index.ts` and the library bundle) because consuming apps mount\n * it in production rather than copying the source.\n *\n * Auth is intentionally decoupled: the shell takes the signed-in `user` and an\n * `onSignOut` callback as props, and `ConnectWithAlfadocs` takes a `status` +\n * `onConnect`. Wire them to `@alfadocs/auth/react`'s `useAlfadocsAuth()` in the\n * consuming app — the kit never touches OAuth or secrets (those live in the\n * server-side `@alfadocs/auth` BFF).\n *\n * All user-visible copy is consumer-provided (props) so each app localises in\n * its own i18n; the only kit-owned strings reuse existing translated `ui.*`\n * keys (sidebar label, skip link, menu button).\n */\nimport { forwardRef, useState, type MouseEvent, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\nimport { LogOut, Maximize2 } from 'lucide-react';\n\nimport { AppFrame } from '../../components/app-frame';\nimport { Avatar } from '../../components/avatar';\nimport { Alert } from '../../components/alert';\nimport { Card } from '../../components/card';\nimport { DropdownMenu } from '../../components/dropdown-menu';\nimport { TabBar } from '../../components/tab-bar';\nimport {\n Header,\n HeaderBrand,\n HeaderCenter,\n HeaderEnd,\n HeaderMenuButton,\n HeaderSkipLink,\n HeaderStart,\n} from '../../components/header';\nimport { HeaderSettings } from '../../components/header-settings';\nimport { ProductLockup } from '../../brand/product-lockup';\nimport { SignInWithAlfadocsButton } from '../../components/sign-in-with-alfadocs-button';\nimport {\n Sidebar,\n SidebarBody,\n SidebarCollapseTrigger,\n SidebarHeader,\n SidebarItem,\n SidebarItemBadge,\n SidebarItemIcon,\n SidebarItemLabel,\n type SidebarMode,\n} from '../../components/sidebar';\nimport { ThemeRoot } from '../../components/theme-root';\nimport { TooltipProvider } from '../../components/tooltip';\nimport { useTheme } from '../../hooks/use-theme';\n\n/* ------------------------------------------------------------------ */\n/* Public API */\n/* ------------------------------------------------------------------ */\n\nexport interface MarketplaceNavItem {\n id: string;\n /** Pre-translated label — apps localise their own nav copy. */\n label: string;\n href: string;\n /** Optional leading icon (a lucide-react element or equivalent). */\n icon?: ReactNode;\n /** Optional unseen-item count rendered as a pill badge. */\n badgeCount?: number;\n /** Mark the item as the current page (`aria-current='page'`). */\n isActive?: boolean;\n /**\n * Optional click handler threaded onto the nav link's `<a>`. The lightweight\n * alternative to `renderLink`: intercept a same-origin click (call\n * `event.preventDefault()`) and route client-side without a full page load —\n * no router `<Link>` needed. Applies to both the standalone sidebar item and\n * the embedded tab. When `renderLink` is supplied it's handed through to the\n * consumer's link element instead.\n */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n}\n\n/**\n * Props the shell hands to `renderLink` for each nav item. The consumer returns\n * their router's `<Link to={href}>` carrying the same `className` (the kit's\n * active styling) and `aria-current` (`'page'` on the active item) so a tab /\n * sidebar-item click is a client-side route change, not a full page reload.\n */\nexport interface MarketplaceRenderLinkProps {\n /** The item's destination — feed it to your router's `to` / `href`. */\n href: string;\n /** The kit's classes — apply verbatim to the link element. */\n className?: string;\n /** Icon + label + badge — render as the link's children. */\n children: ReactNode;\n /** `'page'` on the active item, otherwise omitted — forward to the link. */\n 'aria-current'?: 'page';\n /**\n * The item's stable id, as the agent / automation DOM hook. Spread it onto\n * your router link so the item stays addressable by `[data-tab-id]` — see\n * PRS §26 §6. Only supplied on the bottom-tab-bar path.\n */\n 'data-tab-id'?: string;\n}\n\n/**\n * Render a nav item through the consumer's router instead of the kit's own\n * `<a>`. Returned by the consumer; the shell forwards `href`, the kit's\n * `className`, the item children, and `aria-current` so the active styling and\n * the `aria-current=\"page\"` marker survive a client-side route change.\n */\nexport type MarketplaceRenderLink = (\n props: MarketplaceRenderLinkProps,\n) => ReactNode;\n\nexport interface MarketplaceAppUser {\n /** Display name — drives the avatar initials + the account-menu header. */\n name: string;\n /** Optional email shown under the name in the account menu. */\n email?: string;\n /** Optional avatar image URL. */\n avatarSrc?: string;\n}\n\nexport interface MarketplaceAppShellLabels {\n /** Accessible name for the account-menu trigger, e.g. \"Account menu\". */\n accountMenu: string;\n /** The sign-out menu item, e.g. \"Sign out\". */\n signOut: string;\n /**\n * Optional fullscreen menu item label, e.g. \"Toggle fullscreen\". The item\n * renders whenever `onToggleFullscreen` is supplied; when this label is\n * omitted it falls back to the translated `ui.*` \"Toggle fullscreen\" string.\n */\n fullscreen?: string;\n}\n\nexport interface MarketplaceAppShellProps {\n /** Extension name — renders as the maker lockup \"<productName> by Alfadocs\". */\n productName: string;\n /** Link target for the brand lockup. Default `'/'`. */\n productHref?: string;\n /** Sidebar nav items, in order. */\n nav: MarketplaceNavItem[];\n /**\n * Render nav items (and the brand lockup) through the consumer's router so a\n * tab / item click is a client-side route change with **no full-page reload\n * or session flash**. Wire it to your router's `<Link>`:\n *\n * ```tsx\n * import { Link } from '@tanstack/react-router';\n * <MarketplaceAppShell\n * nav={nav}\n * renderLink={({ href, className, children, ...rest }) => (\n * <Link to={href} className={className} {...rest}>{children}</Link>\n * )}\n * />\n * ```\n *\n * Threaded to the standalone sidebar items, the embedded top tab strip, and\n * the brand lockup. The kit forwards the same `className` + `aria-current` so\n * the active styling and the `aria-current=\"page\"` marker survive in both\n * modes. Omit it to render the plain `<a href>` exactly as before — non-routed\n * consumers are byte-for-byte unaffected. A per-item `onClick` (a\n * click-interceptor shim) is the lighter alternative when you don't want to\n * thread a router `<Link>`.\n */\n renderLink?: MarketplaceRenderLink;\n /** The signed-in user shown in the account menu. */\n user: MarketplaceAppUser;\n /** Consumer-localised chrome labels owned by the shell. */\n labels: MarketplaceAppShellLabels;\n /** Fires when the user picks \"Sign out\". Wire to `useAlfadocsAuth().signOut`. */\n onSignOut?: () => void;\n /** Fires when the user toggles fullscreen. Omit to hide the fullscreen item. */\n onToggleFullscreen?: () => void;\n /**\n * Force the sidebar into a specific mode. Apps typically flip to `'overlay'`\n * on narrow viewports and leave this undefined elsewhere (defaults to\n * `'expanded'`).\n */\n sidebarState?: SidebarMode;\n /**\n * Render a collapse/expand toggle in the sidebar header, letting the user\n * shrink the standalone sidebar to an icon rail. The chosen mode persists\n * per-user (the underlying `Sidebar` stores it) and survives reloads. Opt-in\n * so existing consumers are unaffected; ignored when `sidebarState` forces a\n * mode or in the `'embedded'` variant (no sidebar). @default false\n */\n collapsibleSidebar?: boolean;\n /** Override the accessible name of the `<main>` landmark. */\n mainAriaLabel?: string;\n /**\n * Chrome variant. `'standalone'` (default) renders the full shell — branded\n * Header, Sidebar, and account menu. `'embedded'` is for apps running INSIDE\n * the AlfaDocs platform iframe (consumers detect this with\n * `window !== window.top`): it drops the Header, Sidebar, account menu, and\n * product lockup — the platform already brands and identifies the session\n * around the iframe — and renders the `nav` items as a single slim top tab\n * strip. `onSignOut`, `onToggleFullscreen`, `productName`, `productHref`, and\n * `sidebarState` are ignored in `'embedded'`; the `<main>` landmark,\n * `mainAriaLabel`, and the skip link are kept.\n */\n variant?: 'standalone' | 'embedded';\n /** Children render inside the main content region. */\n children: ReactNode;\n}\n\n/* ------------------------------------------------------------------ */\n/* Internals */\n/* ------------------------------------------------------------------ */\n\nfunction formatBadgeCount(count: number): string {\n return count > 99 ? '99+' : String(count);\n}\n\nfunction AccountMenu({\n user,\n labels,\n onSignOut,\n onToggleFullscreen,\n}: {\n user: MarketplaceAppUser;\n labels: MarketplaceAppShellLabels;\n onSignOut?: () => void;\n onToggleFullscreen?: () => void;\n}) {\n const { t } = useTranslation();\n // Default to the translated `ui.*` label so a consumer that wires\n // `onToggleFullscreen` but omits the label still gets a localised item.\n const fullscreenLabel =\n labels.fullscreen ?? t('marketplaceAppShell.settings.fullscreen');\n return (\n // Non-modal: an account menu shouldn't inert/aria-hide the whole shell\n // behind it (which leaves the still-focusable chrome inside an\n // aria-hidden region — an `aria-hidden-focus` violation).\n <DropdownMenu.Root modal={false}>\n <DropdownMenu.Trigger asChild>\n {/* Bare avatar circle — matches the main app shell's account\n trigger. The name lives inside the menu, not beside the avatar. */}\n <button\n type=\"button\"\n aria-label={labels.accountMenu}\n data-testid=\"marketplace-account-trigger\"\n className=\"ds:inline-flex ds:items-center ds:justify-center ds:shrink-0 ds:size-10 ds:rounded-[var(--radius-full)] ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)] ds:forced-colors:focus-visible:outline-[CanvasText]\"\n >\n <span aria-hidden=\"true\">\n <Avatar name={user.name} src={user.avatarSrc} size=\"md\" />\n </span>\n </button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" collisionPadding={16}>\n {/* GitHub-style identity header — small avatar + name + secondary\n line, matching the main app shell's account menu. */}\n <DropdownMenu.Label>\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span aria-hidden=\"true\">\n <Avatar name={user.name} src={user.avatarSrc} size=\"sm\" />\n </span>\n <span className=\"ds:flex ds:flex-col ds:min-w-0\">\n <span className=\"type-label ds:text-[color:var(--foreground)] ds:truncate\">\n {user.name}\n </span>\n {user.email ? (\n <span className=\"type-meta ds:truncate\">{user.email}</span>\n ) : null}\n </span>\n </span>\n </DropdownMenu.Label>\n {onToggleFullscreen ? (\n <>\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n startIcon={<Maximize2 aria-hidden />}\n onSelect={onToggleFullscreen}\n data-testid=\"marketplace-fullscreen\"\n >\n {fullscreenLabel}\n </DropdownMenu.Item>\n </>\n ) : null}\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n startIcon={<LogOut aria-hidden />}\n onSelect={onSignOut}\n data-testid=\"marketplace-sign-out\"\n >\n {labels.signOut}\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nfunction MarketplaceSidebarNav({\n nav,\n renderLink,\n}: {\n nav: MarketplaceNavItem[];\n renderLink?: MarketplaceRenderLink;\n}) {\n return (\n <SidebarBody>\n {nav.map((item) => {\n const badge =\n typeof item.badgeCount === 'number' && item.badgeCount > 0\n ? item.badgeCount\n : undefined;\n const inner = (\n <>\n {item.icon ? <SidebarItemIcon>{item.icon}</SidebarItemIcon> : null}\n <SidebarItemLabel>{item.label}</SidebarItemLabel>\n {badge !== undefined ? (\n <SidebarItemBadge>{formatBadgeCount(badge)}</SidebarItemBadge>\n ) : null}\n </>\n );\n\n // Consumer-router mode: render the item through Radix `Slot`\n // (`SidebarItem asChild`) so the consumer's `<Link>` takes over the\n // anchor while keeping the kit's item styling + `aria-current=\"page\"`.\n // Clicking routes client-side — no full-page reload.\n if (renderLink) {\n return (\n <SidebarItem key={item.id} asChild isActive={item.isActive}>\n {renderLink({\n href: item.href,\n children: inner,\n 'aria-current': item.isActive ? 'page' : undefined,\n })}\n </SidebarItem>\n );\n }\n\n // Default: plain anchor — byte-identical to before when no per-item\n // `onClick` is supplied (it's omitted entirely, not passed as\n // undefined, so the rendered `<a>` is unchanged).\n return (\n <SidebarItem\n key={item.id}\n href={item.href}\n aria-label={item.label}\n isActive={item.isActive}\n {...(item.onClick ? { onClick: item.onClick } : {})}\n >\n {inner}\n </SidebarItem>\n );\n })}\n </SidebarBody>\n );\n}\n\n/* CVA for the chrome variant — drives the `<main>` surface; the structural\n header/sidebar-vs-tab-strip difference is conditional in the render.\n\n The `standalone` `<main>` gets its content inset from AppFrame's own\n `mainVariants({ padded: true })` (`--spacing-md` on every logical side), so\n this variant only carries the canvas colour there. The `embedded` `<main>`\n is a plain element (no AppFrame), so it has to supply its own inset:\n `--spacing-md` inline + block-end to match the standalone inset, and a\n larger `--spacing-lg` block-start so content clears the floating tab strip's\n pill instead of butting up against it. All logical — RTL mirrors for free. */\nconst shellMainVariants = cva('ds:bg-[color:var(--app-shell-background)]', {\n variants: {\n variant: {\n standalone: '',\n embedded: [\n 'ds:flex-1',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-lg)] ds:pb-[var(--spacing-md)]',\n ].join(' '),\n },\n },\n defaultVariants: { variant: 'standalone' },\n});\n\n/**\n * Embedded chrome: the slim floating tab strip (no Header / Sidebar / account\n * menu) for apps running inside the AlfaDocs platform iframe. It's the shared\n * {@link TabBar} fed the shell's nav items — the platform brands and identifies\n * the session around the iframe, so the strip is the only chrome. The\n * `MarketplaceNavItem` shape is structurally a `TabBarItem`, so the nav passes\n * straight through.\n */\nfunction EmbeddedTabStrip({\n nav,\n ariaLabel,\n renderLink,\n}: {\n nav: MarketplaceNavItem[];\n ariaLabel: string;\n renderLink?: MarketplaceRenderLink;\n}) {\n // Adapt the shell's `renderLink` to TabBar's `renderLink` signature — TabBar\n // also offers the per-item `onClick`, but in consumer-router mode the\n // `<Link>` owns navigation (matching the standalone sidebar), so we forward\n // only `href` / `className` / `children` / `aria-current`. With `renderLink`\n // omitted, TabBar renders its own plain `<a href>` exactly as before, and a\n // per-item `onClick` rides through `nav` → `TabBarItem` untouched.\n const tabRenderLink = renderLink\n ? ({\n href,\n className,\n children,\n 'aria-current': ariaCurrent,\n 'data-tab-id': tabId,\n }: {\n href: string;\n className: string;\n children: ReactNode;\n 'aria-current'?: 'page';\n 'data-tab-id'?: string;\n }) =>\n renderLink({\n href,\n className,\n children,\n 'aria-current': ariaCurrent,\n // Forward the agent DOM hook — without it a consumer-router tab is\n // invisible to `[data-tab-id]` lookups (PRS §26 §6).\n 'data-tab-id': tabId,\n })\n : undefined;\n\n return (\n <TabBar\n items={nav}\n ariaLabel={ariaLabel}\n {...(tabRenderLink ? { renderLink: tabRenderLink } : {})}\n />\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* MarketplaceAppShell */\n/* ------------------------------------------------------------------ */\n\nexport const MarketplaceAppShell = forwardRef<\n HTMLDivElement,\n MarketplaceAppShellProps\n>(\n (\n {\n productName,\n productHref = '/',\n nav,\n renderLink,\n user,\n labels,\n onSignOut,\n onToggleFullscreen,\n sidebarState,\n collapsibleSidebar = false,\n mainAriaLabel,\n variant = 'standalone',\n children,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n // The brand lockup as a consumer-router link: when `renderLink` is\n // supplied, the brand anchor routes client-side too (no session flash when\n // jumping home). The maker lockup's \"<productName> by Alfadocs\" supplies\n // the link's accessible name, matching the default `HeaderBrand` anchor.\n const headerBrand = renderLink ? (\n <HeaderBrand asChild>\n {renderLink({\n href: productHref,\n children: (\n <ProductLockup\n name={productName}\n size=\"md\"\n monochrome\n variant=\"maker\"\n />\n ),\n })}\n </HeaderBrand>\n ) : (\n <HeaderBrand\n href={productHref}\n logo={\n <ProductLockup\n name={productName}\n size=\"md\"\n monochrome\n variant=\"maker\"\n />\n }\n />\n );\n\n // Only wrap in a nested ThemeRoot when the user has an\n // explicit theme/accessibility override, so we don't clobber the consuming\n // app's (or Storybook's) outer theme cascade.\n const { theme: themePref, accessibility, resolvedTheme } = useTheme();\n const hasExplicitOverride =\n themePref !== 'system' || accessibility !== 'system';\n const themeBase = resolvedTheme.startsWith('dark') ? 'dark' : 'light';\n const themeAccessible = resolvedTheme.endsWith('-accessible');\n\n // Narrow-viewport overlay: HeaderMenuButton only renders below `md`.\n const [sidebarOpen, setSidebarOpen] = useState(false);\n\n const shell = (\n <TooltipProvider>\n <AppFrame\n mainAriaLabel={mainAriaLabel}\n mainClassName={shellMainVariants({ variant: 'standalone' })}\n header={\n <Header>\n <HeaderStart>\n <HeaderSkipLink href=\"#main-content\" />\n <HeaderMenuButton onMenuOpen={() => setSidebarOpen(true)} />\n {headerBrand}\n </HeaderStart>\n <HeaderCenter />\n <HeaderEnd>\n <HeaderSettings size=\"sm\" />\n <AccountMenu\n user={user}\n labels={labels}\n onSignOut={onSignOut}\n onToggleFullscreen={onToggleFullscreen}\n />\n </HeaderEnd>\n </Header>\n }\n sidebar={\n <Sidebar\n {...(sidebarState !== undefined\n ? { state: sidebarState }\n : { defaultState: 'expanded' as const })}\n open={sidebarOpen}\n onOpenChange={setSidebarOpen}\n aria-label={t('navigation.sidebar.label')}\n data-testid=\"marketplace-app-shell-sidebar\"\n >\n {collapsibleSidebar && sidebarState === undefined ? (\n // No justify override: SidebarHeader centres its child in the\n // icon rail (`justify-center`) and left-aligns it when expanded,\n // matching the nav icons below. `justify-end` here would win over\n // the icon-mode centring and offset the toggle in the rail.\n <SidebarHeader>\n <SidebarCollapseTrigger />\n </SidebarHeader>\n ) : null}\n <MarketplaceSidebarNav nav={nav} renderLink={renderLink} />\n </Sidebar>\n }\n >\n {children}\n </AppFrame>\n </TooltipProvider>\n );\n\n const embedded = (\n // The shell owns the warm-grey canvas; TabBar's strip is transparent and\n // floats its pill on it, and `<main>` continues the same surface.\n <div className=\"ds:flex ds:min-h-dvh ds:flex-col ds:bg-[color:var(--app-shell-background)]\">\n <HeaderSkipLink href=\"#main-content\" />\n <EmbeddedTabStrip\n nav={nav}\n ariaLabel={t('navigation.sidebar.label')}\n renderLink={renderLink}\n />\n <main\n id=\"main-content\"\n tabIndex={-1}\n aria-label={\n mainAriaLabel ?? t('navigation.main.label', 'Main content')\n }\n className={shellMainVariants({ variant: 'embedded' })}\n >\n {children}\n </main>\n </div>\n );\n\n const content = variant === 'embedded' ? embedded : shell;\n\n if (!hasExplicitOverride) {\n return (\n <div\n ref={ref}\n className=\"ds:contents\"\n data-component=\"marketplace-app-shell\"\n >\n {content}\n </div>\n );\n }\n\n return (\n <ThemeRoot\n ref={ref}\n theme={themeBase}\n accessible={themeAccessible}\n className=\"ds:contents\"\n data-component=\"marketplace-app-shell\"\n >\n {content}\n </ThemeRoot>\n );\n },\n);\n\nMarketplaceAppShell.displayName = 'MarketplaceAppShell';\n\n/* ------------------------------------------------------------------ */\n/* ConnectWithAlfadocs */\n/* ------------------------------------------------------------------ */\n\nexport type ConnectStatus = 'idle' | 'connecting' | 'error';\n\nexport interface ConnectWithAlfadocsProps {\n /** Product name shown next to the wordmark at the top of the card. */\n productName: string;\n /** Heading, e.g. \"Connect your AlfaDocs account\". */\n title: string;\n /** Supporting copy below the heading. */\n description: ReactNode;\n /** The connect button label, e.g. \"Connect with AlfaDocs\". */\n connectLabel: string;\n /** Connection lifecycle. `connecting` shows a loading button; `error` shows the alert. */\n status?: ConnectStatus;\n /** Error message shown (as an alert) when `status === 'error'`. */\n error?: ReactNode;\n /** Fires when the connect button is pressed. Wire to `useAlfadocsAuth().connect`. */\n onConnect?: () => void;\n /** Optional footer content below the button (e.g. a \"what's this?\" link). */\n footer?: ReactNode;\n /**\n * Visual layout. `'card'` (default) is the centred card on the warm-grey\n * canvas — unchanged. `'split'` adds, at `lg:` and up, a two-panel desktop\n * layout: a brand panel on the inline-start and the connect card on the\n * inline-end. Below `lg:`, `'split'` collapses to exactly the card layout —\n * so it falls back gracefully inside iframes / embeds that never reach\n * desktop width. Use `'split'` for full-page desktop logins.\n */\n layout?: 'card' | 'split';\n /**\n * Optional content shown under the lockup in the `'split'` brand panel (a\n * tagline, value props, an illustration). Ignored in `'card'` and below `lg:`.\n */\n brandPanel?: ReactNode;\n className?: string;\n}\n\n/* Split-layout CVAs (lg+ two-panel; collapses to the centred card below lg). */\nconst connectRootVariants = cva(\n 'ds:flex ds:min-h-dvh ds:bg-[color:var(--app-shell-background)]',\n {\n variants: {\n layout: {\n card: '',\n split: 'ds:flex-col ds:lg:flex-row',\n },\n },\n defaultVariants: { layout: 'card' },\n },\n);\n\nconst connectCardWidthVariants = cva('ds:w-full', {\n variants: {\n layout: {\n card: 'ds:max-w-[400px]',\n split: 'ds:max-w-[400px] ds:lg:max-w-[480px]',\n },\n },\n defaultVariants: { layout: 'card' },\n});\n\n// The card's own lockup hides at lg+ in `split` (the brand panel shows it there).\nconst connectCardLockupVariants = cva('', {\n variants: {\n layout: { card: '', split: 'ds:lg:hidden' },\n },\n defaultVariants: { layout: 'card' },\n});\n\n/**\n * The pre-auth \"Connect with AlfaDocs\" screen. Centred white card on the\n * warm-grey canvas with the AlfaDocs wordmark + product name, copy, an error\n * slot, and the primary connect CTA. An opt-in `layout=\"split\"` adds a desktop\n * two-panel brand layout (lg+). Presentational — `onConnect` should call\n * `useAlfadocsAuth().connect()`, which redirects the browser to the server-side\n * BFF that runs the real OAuth2 + PKCE flow.\n */\nexport const ConnectWithAlfadocs = forwardRef<\n HTMLDivElement,\n ConnectWithAlfadocsProps\n>(\n (\n {\n productName,\n title,\n description,\n connectLabel,\n status = 'idle',\n error,\n onConnect,\n footer,\n layout = 'card',\n brandPanel,\n className,\n },\n ref,\n ) => {\n return (\n <div\n ref={ref}\n data-component=\"connect-with-alfadocs\"\n className={`${connectRootVariants({ layout })} ${className ?? ''}`}\n >\n {layout === 'split' ? (\n // Desktop brand panel (lg+ only): a bold `--primary` surface with the\n // monochrome lockup riding the `--primary-foreground` ink, plus an\n // optional `brandPanel` slot. Decorative — the card carries the real\n // heading + CTA, and shows its own lockup below `lg:`.\n <div className=\"ds:hidden ds:lg:flex ds:lg:w-[55%] ds:flex-col ds:items-center ds:justify-center ds:gap-[var(--spacing-lg)] ds:bg-[color:var(--primary)] ds:text-[color:var(--primary-foreground)] ds:ps-[var(--spacing-2xl)] ds:pe-[var(--spacing-2xl)] ds:pt-[var(--spacing-2xl)] ds:pb-[var(--spacing-2xl)] ds:text-start\">\n <ProductLockup\n name={productName}\n size=\"lg\"\n monochrome\n tone=\"inherit\"\n variant=\"maker\"\n />\n {brandPanel ? (\n <div className=\"type-body ds:max-w-[28rem] ds:text-start\">\n {brandPanel}\n </div>\n ) : null}\n </div>\n ) : null}\n <div className=\"ds:flex ds:flex-1 ds:items-center ds:justify-center ds:p-[var(--spacing-lg)]\">\n <Card className={connectCardWidthVariants({ layout })}>\n <Card.Body className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-lg)] ds:text-center\">\n <ProductLockup\n name={productName}\n size=\"lg\"\n variant=\"maker\"\n className={connectCardLockupVariants({ layout })}\n />\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <h1 className=\"type-title-card\">{title}</h1>\n <p className=\"type-body-sm ds:text-[color:var(--muted-foreground)]\">\n {description}\n </p>\n </div>\n {status === 'error' && error ? (\n <Alert variant=\"error\" className=\"ds:w-full ds:text-start\">\n {error}\n </Alert>\n ) : null}\n <SignInWithAlfadocsButton\n intent=\"primary\"\n className=\"ds:w-full\"\n loading={status === 'connecting'}\n onClick={onConnect}\n label={connectLabel}\n data-testid=\"connect-with-alfadocs-button\"\n />\n {footer ? (\n <div className=\"type-meta ds:text-[color:var(--muted-foreground)]\">\n {footer}\n </div>\n ) : null}\n </Card.Body>\n </Card>\n </div>\n </div>\n );\n },\n);\n\nConnectWithAlfadocs.displayName = 'ConnectWithAlfadocs';\n"],"names":["lockup","cva","productName","makerRoot","ProductLockup","forwardRef","name","variant","monochrome","tone","size","className","props","ref","inherit","markInk","nameInk","byInk","letteringInk","jsxs","jsx","AlfadocsLogoMark","AlfadocsLogoNeg","Logo","formatBadgeCount","count","AccountMenu","user","labels","onSignOut","onToggleFullscreen","t","useTranslation","fullscreenLabel","DropdownMenu","Avatar","Fragment","Maximize2","LogOut","MarketplaceSidebarNav","nav","renderLink","SidebarBody","item","badge","inner","SidebarItemIcon","SidebarItemLabel","SidebarItemBadge","SidebarItem","shellMainVariants","EmbeddedTabStrip","ariaLabel","tabRenderLink","href","children","ariaCurrent","tabId","TabBar","MarketplaceAppShell","productHref","sidebarState","collapsibleSidebar","mainAriaLabel","headerBrand","HeaderBrand","themePref","accessibility","resolvedTheme","useTheme","hasExplicitOverride","themeBase","themeAccessible","sidebarOpen","setSidebarOpen","useState","shell","TooltipProvider","AppFrame","Header","HeaderStart","HeaderSkipLink","HeaderMenuButton","HeaderCenter","HeaderEnd","HeaderSettings","Sidebar","SidebarHeader","SidebarCollapseTrigger","embedded","content","ThemeRoot","connectRootVariants","connectCardWidthVariants","connectCardLockupVariants","ConnectWithAlfadocs","title","description","connectLabel","status","error","onConnect","footer","layout","brandPanel","Card","Alert","SignInWithAlfadocsButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,KAASC,EAAI,2DAA2D,GAQxEC,KAAcD;AAAA,EAClB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,MAEN,MAAM;AAAA;AAAA;AAAA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,MAAA,EAAG,WAAU,mBAAmB,UAAA4E,GAAM;AAAA,YACvC,gBAAA5E,EAAC,KAAA,EAAE,WAAU,wDACV,UAAA6E,EAAA,CACH;AAAA,UAAA,GACF;AAAA,UACCE,MAAW,WAAWC,IACrB,gBAAAhF,EAACsF,GAAA,EAAM,SAAQ,SAAQ,WAAU,2BAC9B,UAAAN,EAAA,CACH,IACE;AAAA,UACJ,gBAAAhF;AAAA,YAACuF;AAAA,YAAA;AAAA,cACC,QAAO;AAAA,cACP,WAAU;AAAA,cACV,SAASR,MAAW;AAAA,cACpB,SAASE;AAAA,cACT,OAAOH;AAAA,cACP,eAAY;AAAA,YAAA;AAAA,UAAA;AAAA,UAEbI,IACC,gBAAAlF,EAAC,OAAA,EAAI,WAAU,qDACZ,aACH,IACE;AAAA,QAAA,EAAA,CACN,GACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA2E,GAAoB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"marketplace-app-shell-DdwPj03y.js","sources":["../../src/brand/product-lockup/product-lockup.tsx","../../src/patterns/marketplace-app-shell/marketplace-app-shell.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { Logo } from '../../components/logo/logo';\nimport { AlfadocsLogoMark, AlfadocsLogoNeg } from '../logo-asset';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\n// Outer lockup row. ~4px logical gap between the wordmark and the product\n// name (`--spacing-xs`), centre-aligned so the name's cap height sits\n// against the wordmark's letterforms.\nconst lockup = cva('ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]');\n\n// The product name. Marketing serif (Fraunces, `--font-serif`) — permitted\n// here because this file lives under `src/brand/`, never in `src/components/`\n// or `src/patterns/` (constraint 10). Sized to ~95% of the wordmark height so\n// its cap height matches the logo letterforms across every size and theme\n// (the `--logo-size-*` tokens shift up in the accessible themes; the calc\n// keeps the name proportional for free).\nconst productName = cva(\n [\n 'ds:[font-family:var(--font-serif)]',\n 'ds:font-semibold',\n 'ds:leading-none',\n 'ds:tracking-[0.01em]',\n 'ds:whitespace-nowrap',\n // Forced-colors: drop the transparent text-fill and paint the label\n // as solid CanvasText so it never disappears under Windows HCM —\n // a gradient/transparent fill has no meaning there.\n 'ds:forced-colors:text-[CanvasText]',\n 'ds:forced-colors:[-webkit-text-fill-color:CanvasText]',\n ],\n {\n variants: {\n size: {\n sm: 'ds:text-[calc(var(--logo-size-sm)*0.95)]',\n md: 'ds:text-[calc(var(--logo-size-md)*0.95)]',\n lg: 'ds:text-[calc(var(--logo-size-lg)*0.95)]',\n xl: 'ds:text-[calc(var(--logo-size-xl)*0.95)]',\n },\n tone: {\n // Brand gradient filled into the glyphs via background-clip:text.\n // `--gradient-wordmark` rides the theme aliases, so it stays\n // AA-safe and adapts per theme on its own (and flattens to a solid\n // ink in the accessible / forced-colors blocks — see tokens).\n gradient: [\n 'ds:italic',\n 'ds:bg-[image:var(--gradient-wordmark)]',\n 'ds:bg-clip-text',\n 'ds:text-transparent',\n 'ds:[-webkit-text-fill-color:transparent]',\n ],\n // Monochrome: solid currentColor ink, upright, no gradient — for\n // print, single-colour work, and coloured chrome (e.g. app-shell\n // headers) where the lockup must ride the surrounding ink.\n solid: 'ds:text-current',\n },\n },\n defaultVariants: { size: 'md', tone: 'gradient' },\n },\n);\n\n// Maker lockup root. Sets a single `--lockup-unit` custom property to the\n// matching `--logo-size-*` token; every maker sub-element (mark, name, the\n// \"by Alfadocs\" tag) sizes off `var(--lockup-unit)`, so there's one per-size\n// source of truth that shifts up with the accessible themes for free.\n// `whitespace-nowrap` keeps \"[mark] Name by Alfadocs\" on one line.\nconst makerRoot = cva('ds:whitespace-nowrap', {\n variants: {\n size: {\n sm: 'ds:[--lockup-unit:var(--logo-size-sm)]',\n md: 'ds:[--lockup-unit:var(--logo-size-md)]',\n lg: 'ds:[--lockup-unit:var(--logo-size-lg)]',\n xl: 'ds:[--lockup-unit:var(--logo-size-xl)]',\n },\n },\n defaultVariants: { size: 'md' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\ntype LockupSize = NonNullable<VariantProps<typeof productName>['size']>;\n\nexport type ProductLockupProps = {\n /**\n * The product name. Passed verbatim (product names are not translated).\n *\n * - `variant=\"standard\"` (default): renders as \"Alfadocs <name>\" with the\n * wordmark; accessible name is `Alfadocs <name>`.\n * - `variant=\"maker\"`: renders as \"[mark] <name> by Alfadocs\"; accessible\n * name is `<name> by Alfadocs`.\n */\n name: string;\n /**\n * Which lockup composition to use.\n *\n * - `'standard'` (default) — Alfadocs wordmark + product name (\"Alfadocs\n * Builders\"). Use for **internal** Alfadocs products (Alfadocs Builders,\n * Alfadocs API) where the product is part of the Alfadocs family.\n * - `'maker'` — \"<name> by Alfadocs\" with the four-pillar mark and the name\n * as the prominent element. Use for **external** marketplace extensions\n * (\"Scribe by Alfadocs\") where the extension's own name leads and\n * \"by Alfadocs\" is the maker attribution.\n */\n variant?: 'standard' | 'maker';\n /**\n * Render the name as a solid `--foreground` ink, upright (no gradient, no\n * italic), and pair it with the monochrome wordmark. Use for print,\n * single-colour reproductions, or any constrained context where the\n * gradient/serif treatment is inappropriate.\n */\n monochrome?: boolean;\n /**\n * Ink resolution. `'auto'` (default) uses the lockup's intended ink\n * (`--foreground` for monochrome). `'inherit'` makes the whole lockup ride\n * `currentColor` — use it with `monochrome` on a coloured brand surface (a\n * tinted header or split-login panel) so the wordmark + name both take the\n * surface's text colour rather than clashing with a fixed `--foreground`.\n */\n tone?: 'auto' | 'inherit';\n /** Lockup size. Drives both the wordmark and the name's cap height. */\n size?: LockupSize;\n className?: string;\n} & Omit<\n ComponentPropsWithoutRef<'span'>,\n 'role' | 'aria-label' | 'aria-hidden' | 'children' | 'className'\n>;\n\n/* ------------------------------------------------------------------ */\n/* ProductLockup */\n/* ------------------------------------------------------------------ */\n\n/**\n * Pairs a product name with the Alfadocs brand. Two compositions:\n *\n * - `variant=\"standard\"` (default) — the Alfadocs wordmark + product name\n * (\"Alfadocs Builders\"). For internal Alfadocs products. Exposed to\n * assistive tech as a single `img` named `Alfadocs <name>`.\n * - `variant=\"maker\"` — \"[mark] <name> by Alfadocs\". For external marketplace\n * extensions where the extension's name leads. Exposed as a single `img`\n * named `<name> by Alfadocs`.\n *\n * In both cases the inner wordmark/mark and the visible name are decorative so\n * the brand isn't announced twice. Every marketplace app should use this\n * rather than hand-rolling a wordmark + typed span.\n */\nexport const ProductLockup = forwardRef<HTMLSpanElement, ProductLockupProps>(\n (\n {\n name,\n variant = 'standard',\n monochrome = false,\n tone = 'auto',\n size = 'md',\n className,\n ...props\n },\n ref,\n ) => {\n if (import.meta.env.DEV && !name.trim()) {\n console.warn(\n '[ProductLockup] `name` is empty — the lockup will render the bare wordmark with no product name. Pass the product name (e.g. \"Builders\").',\n );\n }\n\n if (variant === 'maker') {\n // Ink matrix mirrors the standard variant's tone/monochrome model:\n // - tone=\"inherit\": every element rides currentColor (no explicit ink),\n // for coloured surfaces.\n // - monochrome (tone auto): foreground ink, with the attribution muted.\n // - default (colour, tone auto): the name + mark take --primary; the\n // wordmark lettering stays --foreground; the attribution is muted.\n const inherit = tone === 'inherit';\n const markInk = inherit\n ? ''\n : monochrome\n ? 'ds:text-[color:var(--foreground)]'\n : 'ds:text-[color:var(--primary)]';\n const nameInk = inherit\n ? ''\n : monochrome\n ? 'ds:text-[color:var(--foreground)]'\n : 'ds:text-[color:var(--primary)]';\n const byInk = inherit ? '' : 'ds:text-[color:var(--muted-foreground)]';\n const letteringInk = inherit ? '' : 'ds:text-[color:var(--foreground)]';\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={`${name} by Alfadocs`.trim()}\n className={makerRoot({ size, className })}\n data-component=\"product-lockup\"\n {...props}\n >\n {/* Pillar mark sized close to the app name (≈0.88 of the serif em),\n vertically centred on it. Inline (not flex) so the maker tag can\n use vertical-align. */}\n <AlfadocsLogoMark\n aria-hidden\n className={`ds:inline-block ds:align-middle ds:me-[var(--spacing-sm)] ds:h-[calc(var(--lockup-unit)*0.88)] ds:w-auto ds:forced-colors:text-[CanvasText] ${markInk}`}\n />\n <span\n aria-hidden\n className={`ds:align-middle ds:[font-family:var(--font-serif)] ds:font-semibold ds:italic ds:leading-none ds:tracking-[0.01em] ${nameInk} ds:text-[calc(var(--lockup-unit)*0.95)]`}\n >\n {name}\n </span>\n {/* Maker tag — superscript style, its top aligned to the app name's\n cap-height via vertical-align: text-top. */}\n <span\n aria-hidden\n className={`ds:align-text-top ds:ms-[var(--spacing-sm)] ds:inline-flex ds:items-baseline ds:gap-[var(--spacing-2xs)] ${byInk}`}\n >\n <span className=\"ds:text-[calc(var(--lockup-unit)*0.4)] ds:leading-none\">\n by\n </span>\n {/* Real Alfadocs wordmark SVG. The Neg SVG's first <g> is the\n \"Alfadocs\" lettering; the second <g> is the four-pillar mark\n (x≈3–146). viewBox=\"168 0 637 125\" windows to the lettering\n only — no mark, no hand-typed wordmark. */}\n <AlfadocsLogoNeg\n aria-hidden\n viewBox=\"168 0 637 125\"\n className={`ds:h-[calc(var(--lockup-unit)*0.45)] ds:w-auto ds:forced-colors:text-[CanvasText] ${letteringInk}`}\n />\n </span>\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={`Alfadocs ${name}`.trim()}\n className={lockup({ className })}\n data-component=\"product-lockup\"\n {...props}\n >\n <Logo\n variant={monochrome ? 'monochrome' : 'wordmark'}\n tone={tone}\n size={size}\n decorative\n />\n <span\n aria-hidden\n className={productName({\n size,\n tone: monochrome ? 'solid' : 'gradient',\n })}\n >\n {name}\n </span>\n </span>\n );\n },\n);\nProductLockup.displayName = 'ProductLockup';\n","/**\n * Marketplace App Shell — the standard chrome for an app built on top of\n * AlfaDocs (the kind a partner scaffolds with Claude Code, Lovable, etc.).\n *\n * It is a thin, opinionated composition of kit primitives: an `AppFrame` with\n * a branded `Header` (the maker `ProductLockup` — \"<Product> by Alfadocs\" —\n * rendered `monochrome` so it rides the header's ink; maker is the lockup\n * style for external marketplace extensions), a `Sidebar` for app\n * navigation, `HeaderSettings` (theme/locale/accessibility), and a bare-avatar\n * account menu (fullscreen + sign-out) matching the main app shell.\n * `ConnectWithAlfadocs` is the matching pre-auth screen, with the full-colour\n * maker lockup and `SignInWithAlfadocsButton`.\n *\n * Like `AliaSidebar`, this pattern ships a RUNTIME component (surfaced via\n * `src/patterns/index.ts` and the library bundle) because consuming apps mount\n * it in production rather than copying the source.\n *\n * Auth is intentionally decoupled: the shell takes the signed-in `user` and an\n * `onSignOut` callback as props, and `ConnectWithAlfadocs` takes a `status` +\n * `onConnect`. Wire them to `@alfadocs/auth/react`'s `useAlfadocsAuth()` in the\n * consuming app — the kit never touches OAuth or secrets (those live in the\n * server-side `@alfadocs/auth` BFF).\n *\n * All user-visible copy is consumer-provided (props) so each app localises in\n * its own i18n; the only kit-owned strings reuse existing translated `ui.*`\n * keys (sidebar label, skip link, menu button).\n */\nimport { forwardRef, useState, type MouseEvent, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\nimport { LogOut, Maximize2 } from 'lucide-react';\n\nimport { AppFrame } from '../../components/app-frame';\nimport { Avatar } from '../../components/avatar';\nimport { Alert } from '../../components/alert';\nimport { Card } from '../../components/card';\nimport { DropdownMenu } from '../../components/dropdown-menu';\nimport { TabBar } from '../../components/tab-bar';\nimport {\n Header,\n HeaderBrand,\n HeaderCenter,\n HeaderEnd,\n HeaderMenuButton,\n HeaderSkipLink,\n HeaderStart,\n} from '../../components/header';\nimport { HeaderSettings } from '../../components/header-settings';\nimport { ProductLockup } from '../../brand/product-lockup';\nimport { SignInWithAlfadocsButton } from '../../components/sign-in-with-alfadocs-button';\nimport {\n Sidebar,\n SidebarBody,\n SidebarCollapseTrigger,\n SidebarHeader,\n SidebarItem,\n SidebarItemBadge,\n SidebarItemIcon,\n SidebarItemLabel,\n type SidebarMode,\n} from '../../components/sidebar';\nimport { ThemeRoot } from '../../components/theme-root';\nimport { TooltipProvider } from '../../components/tooltip';\nimport { useTheme } from '../../hooks/use-theme';\n\n/* ------------------------------------------------------------------ */\n/* Public API */\n/* ------------------------------------------------------------------ */\n\nexport interface MarketplaceNavItem {\n id: string;\n /** Pre-translated label — apps localise their own nav copy. */\n label: string;\n href: string;\n /** Optional leading icon (a lucide-react element or equivalent). */\n icon?: ReactNode;\n /** Optional unseen-item count rendered as a pill badge. */\n badgeCount?: number;\n /** Mark the item as the current page (`aria-current='page'`). */\n isActive?: boolean;\n /**\n * Optional click handler threaded onto the nav link's `<a>`. The lightweight\n * alternative to `renderLink`: intercept a same-origin click (call\n * `event.preventDefault()`) and route client-side without a full page load —\n * no router `<Link>` needed. Applies to both the standalone sidebar item and\n * the embedded tab. When `renderLink` is supplied it's handed through to the\n * consumer's link element instead.\n */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n}\n\n/**\n * Props the shell hands to `renderLink` for each nav item. The consumer returns\n * their router's `<Link to={href}>` carrying the same `className` (the kit's\n * active styling) and `aria-current` (`'page'` on the active item) so a tab /\n * sidebar-item click is a client-side route change, not a full page reload.\n */\nexport interface MarketplaceRenderLinkProps {\n /** The item's destination — feed it to your router's `to` / `href`. */\n href: string;\n /** The kit's classes — apply verbatim to the link element. */\n className?: string;\n /** Icon + label + badge — render as the link's children. */\n children: ReactNode;\n /** `'page'` on the active item, otherwise omitted — forward to the link. */\n 'aria-current'?: 'page';\n /**\n * The item's stable id, as the agent / automation DOM hook. Spread it onto\n * your router link so the item stays addressable by `[data-tab-id]` — see\n * PRS §26 §6. Only supplied on the bottom-tab-bar path.\n */\n 'data-tab-id'?: string;\n}\n\n/**\n * Render a nav item through the consumer's router instead of the kit's own\n * `<a>`. Returned by the consumer; the shell forwards `href`, the kit's\n * `className`, the item children, and `aria-current` so the active styling and\n * the `aria-current=\"page\"` marker survive a client-side route change.\n */\nexport type MarketplaceRenderLink = (\n props: MarketplaceRenderLinkProps,\n) => ReactNode;\n\nexport interface MarketplaceAppUser {\n /** Display name — drives the avatar initials + the account-menu header. */\n name: string;\n /** Optional email shown under the name in the account menu. */\n email?: string;\n /** Optional avatar image URL. */\n avatarSrc?: string;\n}\n\nexport interface MarketplaceAppShellLabels {\n /** Accessible name for the account-menu trigger, e.g. \"Account menu\". */\n accountMenu: string;\n /** The sign-out menu item, e.g. \"Sign out\". */\n signOut: string;\n /**\n * Optional fullscreen menu item label, e.g. \"Toggle fullscreen\". The item\n * renders whenever `onToggleFullscreen` is supplied; when this label is\n * omitted it falls back to the translated `ui.*` \"Toggle fullscreen\" string.\n */\n fullscreen?: string;\n}\n\nexport interface MarketplaceAppShellProps {\n /** Extension name — renders as the maker lockup \"<productName> by Alfadocs\". */\n productName: string;\n /** Link target for the brand lockup. Default `'/'`. */\n productHref?: string;\n /** Sidebar nav items, in order. */\n nav: MarketplaceNavItem[];\n /**\n * Render nav items (and the brand lockup) through the consumer's router so a\n * tab / item click is a client-side route change with **no full-page reload\n * or session flash**. Wire it to your router's `<Link>`:\n *\n * ```tsx\n * import { Link } from '@tanstack/react-router';\n * <MarketplaceAppShell\n * nav={nav}\n * renderLink={({ href, className, children, ...rest }) => (\n * <Link to={href} className={className} {...rest}>{children}</Link>\n * )}\n * />\n * ```\n *\n * Threaded to the standalone sidebar items, the embedded top tab strip, and\n * the brand lockup. The kit forwards the same `className` + `aria-current` so\n * the active styling and the `aria-current=\"page\"` marker survive in both\n * modes. Omit it to render the plain `<a href>` exactly as before — non-routed\n * consumers are byte-for-byte unaffected. A per-item `onClick` (a\n * click-interceptor shim) is the lighter alternative when you don't want to\n * thread a router `<Link>`.\n */\n renderLink?: MarketplaceRenderLink;\n /** The signed-in user shown in the account menu. */\n user: MarketplaceAppUser;\n /** Consumer-localised chrome labels owned by the shell. */\n labels: MarketplaceAppShellLabels;\n /** Fires when the user picks \"Sign out\". Wire to `useAlfadocsAuth().signOut`. */\n onSignOut?: () => void;\n /** Fires when the user toggles fullscreen. Omit to hide the fullscreen item. */\n onToggleFullscreen?: () => void;\n /**\n * Force the sidebar into a specific mode. Apps typically flip to `'overlay'`\n * on narrow viewports and leave this undefined elsewhere (defaults to\n * `'expanded'`).\n */\n sidebarState?: SidebarMode;\n /**\n * Render a collapse/expand toggle in the sidebar header, letting the user\n * shrink the standalone sidebar to an icon rail. The chosen mode persists\n * per-user (the underlying `Sidebar` stores it) and survives reloads. Opt-in\n * so existing consumers are unaffected; ignored when `sidebarState` forces a\n * mode or in the `'embedded'` variant (no sidebar). @default false\n */\n collapsibleSidebar?: boolean;\n /** Override the accessible name of the `<main>` landmark. */\n mainAriaLabel?: string;\n /**\n * Chrome variant. `'standalone'` (default) renders the full shell — branded\n * Header, Sidebar, and account menu. `'embedded'` is for apps running INSIDE\n * the AlfaDocs platform iframe (consumers detect this with\n * `window !== window.top`): it drops the Header, Sidebar, account menu, and\n * product lockup — the platform already brands and identifies the session\n * around the iframe — and renders the `nav` items as a single slim top tab\n * strip. `onSignOut`, `onToggleFullscreen`, `productName`, `productHref`, and\n * `sidebarState` are ignored in `'embedded'`; the `<main>` landmark,\n * `mainAriaLabel`, and the skip link are kept.\n */\n variant?: 'standalone' | 'embedded';\n /** Children render inside the main content region. */\n children: ReactNode;\n}\n\n/* ------------------------------------------------------------------ */\n/* Internals */\n/* ------------------------------------------------------------------ */\n\nfunction formatBadgeCount(count: number): string {\n return count > 99 ? '99+' : String(count);\n}\n\nfunction AccountMenu({\n user,\n labels,\n onSignOut,\n onToggleFullscreen,\n}: {\n user: MarketplaceAppUser;\n labels: MarketplaceAppShellLabels;\n onSignOut?: () => void;\n onToggleFullscreen?: () => void;\n}) {\n const { t } = useTranslation();\n // Default to the translated `ui.*` label so a consumer that wires\n // `onToggleFullscreen` but omits the label still gets a localised item.\n const fullscreenLabel =\n labels.fullscreen ?? t('marketplaceAppShell.settings.fullscreen');\n return (\n // Non-modal: an account menu shouldn't inert/aria-hide the whole shell\n // behind it (which leaves the still-focusable chrome inside an\n // aria-hidden region — an `aria-hidden-focus` violation).\n <DropdownMenu.Root modal={false}>\n <DropdownMenu.Trigger asChild>\n {/* Bare avatar circle — matches the main app shell's account\n trigger. The name lives inside the menu, not beside the avatar. */}\n <button\n type=\"button\"\n aria-label={labels.accountMenu}\n data-testid=\"marketplace-account-trigger\"\n className=\"ds:inline-flex ds:items-center ds:justify-center ds:shrink-0 ds:size-10 ds:rounded-[var(--radius-full)] ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)] ds:forced-colors:focus-visible:outline-[CanvasText]\"\n >\n <span aria-hidden=\"true\">\n <Avatar name={user.name} src={user.avatarSrc} size=\"md\" />\n </span>\n </button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" collisionPadding={16}>\n {/* GitHub-style identity header — small avatar + name + secondary\n line, matching the main app shell's account menu. */}\n <DropdownMenu.Label>\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span aria-hidden=\"true\">\n <Avatar name={user.name} src={user.avatarSrc} size=\"sm\" />\n </span>\n <span className=\"ds:flex ds:flex-col ds:min-w-0\">\n <span className=\"type-label ds:text-[color:var(--foreground)] ds:truncate\">\n {user.name}\n </span>\n {user.email ? (\n <span className=\"type-meta ds:truncate\">{user.email}</span>\n ) : null}\n </span>\n </span>\n </DropdownMenu.Label>\n {onToggleFullscreen ? (\n <>\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n startIcon={<Maximize2 aria-hidden />}\n onSelect={onToggleFullscreen}\n data-testid=\"marketplace-fullscreen\"\n >\n {fullscreenLabel}\n </DropdownMenu.Item>\n </>\n ) : null}\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n startIcon={<LogOut aria-hidden />}\n onSelect={onSignOut}\n data-testid=\"marketplace-sign-out\"\n >\n {labels.signOut}\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nfunction MarketplaceSidebarNav({\n nav,\n renderLink,\n}: {\n nav: MarketplaceNavItem[];\n renderLink?: MarketplaceRenderLink;\n}) {\n return (\n <SidebarBody>\n {nav.map((item) => {\n const badge =\n typeof item.badgeCount === 'number' && item.badgeCount > 0\n ? item.badgeCount\n : undefined;\n const inner = (\n <>\n {item.icon ? <SidebarItemIcon>{item.icon}</SidebarItemIcon> : null}\n <SidebarItemLabel>{item.label}</SidebarItemLabel>\n {badge !== undefined ? (\n <SidebarItemBadge>{formatBadgeCount(badge)}</SidebarItemBadge>\n ) : null}\n </>\n );\n\n // Consumer-router mode: render the item through Radix `Slot`\n // (`SidebarItem asChild`) so the consumer's `<Link>` takes over the\n // anchor while keeping the kit's item styling + `aria-current=\"page\"`.\n // Clicking routes client-side — no full-page reload.\n if (renderLink) {\n return (\n <SidebarItem key={item.id} asChild isActive={item.isActive}>\n {renderLink({\n href: item.href,\n children: inner,\n 'aria-current': item.isActive ? 'page' : undefined,\n })}\n </SidebarItem>\n );\n }\n\n // Default: plain anchor — byte-identical to before when no per-item\n // `onClick` is supplied (it's omitted entirely, not passed as\n // undefined, so the rendered `<a>` is unchanged).\n return (\n <SidebarItem\n key={item.id}\n href={item.href}\n aria-label={item.label}\n isActive={item.isActive}\n {...(item.onClick ? { onClick: item.onClick } : {})}\n >\n {inner}\n </SidebarItem>\n );\n })}\n </SidebarBody>\n );\n}\n\n/* CVA for the chrome variant — drives the `<main>` surface; the structural\n header/sidebar-vs-tab-strip difference is conditional in the render.\n\n The `standalone` `<main>` gets its content inset from AppFrame's own\n `mainVariants({ padded: true })` (`--spacing-md` on every logical side), so\n this variant only carries the canvas colour there. The `embedded` `<main>`\n is a plain element (no AppFrame), so it has to supply its own inset:\n `--spacing-md` inline + block-end to match the standalone inset, and a\n larger `--spacing-lg` block-start so content clears the floating tab strip's\n pill instead of butting up against it. All logical — RTL mirrors for free. */\nconst shellMainVariants = cva('ds:bg-[color:var(--app-shell-background)]', {\n variants: {\n variant: {\n standalone: '',\n embedded: [\n 'ds:flex-1',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-lg)] ds:pb-[var(--spacing-md)]',\n ].join(' '),\n },\n },\n defaultVariants: { variant: 'standalone' },\n});\n\n/**\n * Embedded chrome: the slim floating tab strip (no Header / Sidebar / account\n * menu) for apps running inside the AlfaDocs platform iframe. It's the shared\n * {@link TabBar} fed the shell's nav items — the platform brands and identifies\n * the session around the iframe, so the strip is the only chrome. The\n * `MarketplaceNavItem` shape is structurally a `TabBarItem`, so the nav passes\n * straight through.\n */\nfunction EmbeddedTabStrip({\n nav,\n ariaLabel,\n renderLink,\n}: {\n nav: MarketplaceNavItem[];\n ariaLabel: string;\n renderLink?: MarketplaceRenderLink;\n}) {\n // Adapt the shell's `renderLink` to TabBar's `renderLink` signature — TabBar\n // also offers the per-item `onClick`, but in consumer-router mode the\n // `<Link>` owns navigation (matching the standalone sidebar), so we forward\n // only `href` / `className` / `children` / `aria-current`. With `renderLink`\n // omitted, TabBar renders its own plain `<a href>` exactly as before, and a\n // per-item `onClick` rides through `nav` → `TabBarItem` untouched.\n const tabRenderLink = renderLink\n ? ({\n href,\n className,\n children,\n 'aria-current': ariaCurrent,\n 'data-tab-id': tabId,\n }: {\n href: string;\n className: string;\n children: ReactNode;\n 'aria-current'?: 'page';\n 'data-tab-id'?: string;\n }) =>\n renderLink({\n href,\n className,\n children,\n 'aria-current': ariaCurrent,\n // Forward the agent DOM hook — without it a consumer-router tab is\n // invisible to `[data-tab-id]` lookups (PRS §26 §6).\n 'data-tab-id': tabId,\n })\n : undefined;\n\n return (\n <TabBar\n items={nav}\n ariaLabel={ariaLabel}\n {...(tabRenderLink ? { renderLink: tabRenderLink } : {})}\n />\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* MarketplaceAppShell */\n/* ------------------------------------------------------------------ */\n\nexport const MarketplaceAppShell = forwardRef<\n HTMLDivElement,\n MarketplaceAppShellProps\n>(\n (\n {\n productName,\n productHref = '/',\n nav,\n renderLink,\n user,\n labels,\n onSignOut,\n onToggleFullscreen,\n sidebarState,\n collapsibleSidebar = false,\n mainAriaLabel,\n variant = 'standalone',\n children,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n // The brand lockup as a consumer-router link: when `renderLink` is\n // supplied, the brand anchor routes client-side too (no session flash when\n // jumping home). The maker lockup's \"<productName> by Alfadocs\" supplies\n // the link's accessible name, matching the default `HeaderBrand` anchor.\n const headerBrand = renderLink ? (\n <HeaderBrand asChild>\n {renderLink({\n href: productHref,\n children: (\n <ProductLockup\n name={productName}\n size=\"md\"\n monochrome\n variant=\"maker\"\n />\n ),\n })}\n </HeaderBrand>\n ) : (\n <HeaderBrand\n href={productHref}\n logo={\n <ProductLockup\n name={productName}\n size=\"md\"\n monochrome\n variant=\"maker\"\n />\n }\n />\n );\n\n // Only wrap in a nested ThemeRoot when the user has an\n // explicit theme/accessibility override, so we don't clobber the consuming\n // app's (or Storybook's) outer theme cascade.\n const { theme: themePref, accessibility, resolvedTheme } = useTheme();\n const hasExplicitOverride =\n themePref !== 'system' || accessibility !== 'system';\n const themeBase = resolvedTheme.startsWith('dark') ? 'dark' : 'light';\n const themeAccessible = resolvedTheme.endsWith('-accessible');\n\n // Narrow-viewport overlay: HeaderMenuButton only renders below `md`.\n const [sidebarOpen, setSidebarOpen] = useState(false);\n\n const shell = (\n <TooltipProvider>\n <AppFrame\n mainAriaLabel={mainAriaLabel}\n mainClassName={shellMainVariants({ variant: 'standalone' })}\n header={\n <Header>\n <HeaderStart>\n <HeaderSkipLink href=\"#main-content\" />\n <HeaderMenuButton onMenuOpen={() => setSidebarOpen(true)} />\n {headerBrand}\n </HeaderStart>\n <HeaderCenter />\n <HeaderEnd>\n <HeaderSettings size=\"sm\" />\n <AccountMenu\n user={user}\n labels={labels}\n onSignOut={onSignOut}\n onToggleFullscreen={onToggleFullscreen}\n />\n </HeaderEnd>\n </Header>\n }\n sidebar={\n <Sidebar\n {...(sidebarState !== undefined\n ? { state: sidebarState }\n : { defaultState: 'expanded' as const })}\n open={sidebarOpen}\n onOpenChange={setSidebarOpen}\n aria-label={t('navigation.sidebar.label')}\n data-testid=\"marketplace-app-shell-sidebar\"\n >\n {collapsibleSidebar && sidebarState === undefined ? (\n // No justify override: SidebarHeader centres its child in the\n // icon rail (`justify-center`) and left-aligns it when expanded,\n // matching the nav icons below. `justify-end` here would win over\n // the icon-mode centring and offset the toggle in the rail.\n <SidebarHeader>\n <SidebarCollapseTrigger />\n </SidebarHeader>\n ) : null}\n <MarketplaceSidebarNav nav={nav} renderLink={renderLink} />\n </Sidebar>\n }\n >\n {children}\n </AppFrame>\n </TooltipProvider>\n );\n\n const embedded = (\n // The shell owns the warm-grey canvas; TabBar's strip is transparent and\n // floats its pill on it, and `<main>` continues the same surface.\n <div className=\"ds:flex ds:min-h-dvh ds:flex-col ds:bg-[color:var(--app-shell-background)]\">\n <HeaderSkipLink href=\"#main-content\" />\n <EmbeddedTabStrip\n nav={nav}\n ariaLabel={t('navigation.sidebar.label')}\n renderLink={renderLink}\n />\n <main\n id=\"main-content\"\n tabIndex={-1}\n aria-label={\n mainAriaLabel ?? t('navigation.main.label', 'Main content')\n }\n className={shellMainVariants({ variant: 'embedded' })}\n >\n {children}\n </main>\n </div>\n );\n\n const content = variant === 'embedded' ? embedded : shell;\n\n if (!hasExplicitOverride) {\n return (\n <div\n ref={ref}\n className=\"ds:contents\"\n data-component=\"marketplace-app-shell\"\n >\n {content}\n </div>\n );\n }\n\n return (\n <ThemeRoot\n ref={ref}\n theme={themeBase}\n accessible={themeAccessible}\n className=\"ds:contents\"\n data-component=\"marketplace-app-shell\"\n >\n {content}\n </ThemeRoot>\n );\n },\n);\n\nMarketplaceAppShell.displayName = 'MarketplaceAppShell';\n\n/* ------------------------------------------------------------------ */\n/* ConnectWithAlfadocs */\n/* ------------------------------------------------------------------ */\n\nexport type ConnectStatus = 'idle' | 'connecting' | 'error';\n\nexport interface ConnectWithAlfadocsProps {\n /** Product name shown next to the wordmark at the top of the card. */\n productName: string;\n /** Heading, e.g. \"Connect your AlfaDocs account\". */\n title: string;\n /** Supporting copy below the heading. */\n description: ReactNode;\n /** The connect button label, e.g. \"Connect with AlfaDocs\". */\n connectLabel: string;\n /** Connection lifecycle. `connecting` shows a loading button; `error` shows the alert. */\n status?: ConnectStatus;\n /** Error message shown (as an alert) when `status === 'error'`. */\n error?: ReactNode;\n /** Fires when the connect button is pressed. Wire to `useAlfadocsAuth().connect`. */\n onConnect?: () => void;\n /** Optional footer content below the button (e.g. a \"what's this?\" link). */\n footer?: ReactNode;\n /**\n * Visual layout. `'card'` (default) is the centred card on the warm-grey\n * canvas — unchanged. `'split'` adds, at `lg:` and up, a two-panel desktop\n * layout: a brand panel on the inline-start and the connect card on the\n * inline-end. Below `lg:`, `'split'` collapses to exactly the card layout —\n * so it falls back gracefully inside iframes / embeds that never reach\n * desktop width. Use `'split'` for full-page desktop logins.\n */\n layout?: 'card' | 'split';\n /**\n * Optional content shown under the lockup in the `'split'` brand panel (a\n * tagline, value props, an illustration). Ignored in `'card'` and below `lg:`.\n */\n brandPanel?: ReactNode;\n className?: string;\n}\n\n/* Split-layout CVAs (lg+ two-panel; collapses to the centred card below lg). */\nconst connectRootVariants = cva(\n 'ds:flex ds:min-h-dvh ds:bg-[color:var(--app-shell-background)]',\n {\n variants: {\n layout: {\n card: '',\n split: 'ds:flex-col ds:lg:flex-row',\n },\n },\n defaultVariants: { layout: 'card' },\n },\n);\n\nconst connectCardWidthVariants = cva('ds:w-full', {\n variants: {\n layout: {\n card: 'ds:max-w-[400px]',\n split: 'ds:max-w-[400px] ds:lg:max-w-[480px]',\n },\n },\n defaultVariants: { layout: 'card' },\n});\n\n// The card's own lockup hides at lg+ in `split` (the brand panel shows it there).\nconst connectCardLockupVariants = cva('', {\n variants: {\n layout: { card: '', split: 'ds:lg:hidden' },\n },\n defaultVariants: { layout: 'card' },\n});\n\n/**\n * The pre-auth \"Connect with AlfaDocs\" screen. Centred white card on the\n * warm-grey canvas with the AlfaDocs wordmark + product name, copy, an error\n * slot, and the primary connect CTA. An opt-in `layout=\"split\"` adds a desktop\n * two-panel brand layout (lg+). Presentational — `onConnect` should call\n * `useAlfadocsAuth().connect()`, which redirects the browser to the server-side\n * BFF that runs the real OAuth2 + PKCE flow.\n */\nexport const ConnectWithAlfadocs = forwardRef<\n HTMLDivElement,\n ConnectWithAlfadocsProps\n>(\n (\n {\n productName,\n title,\n description,\n connectLabel,\n status = 'idle',\n error,\n onConnect,\n footer,\n layout = 'card',\n brandPanel,\n className,\n },\n ref,\n ) => {\n return (\n <div\n ref={ref}\n data-component=\"connect-with-alfadocs\"\n className={`${connectRootVariants({ layout })} ${className ?? ''}`}\n >\n {layout === 'split' ? (\n // Desktop brand panel (lg+ only): a bold `--primary` surface with the\n // monochrome lockup riding the `--primary-foreground` ink, plus an\n // optional `brandPanel` slot. Decorative — the card carries the real\n // heading + CTA, and shows its own lockup below `lg:`.\n <div className=\"ds:hidden ds:lg:flex ds:lg:w-[55%] ds:flex-col ds:items-center ds:justify-center ds:gap-[var(--spacing-lg)] ds:bg-[color:var(--primary)] ds:text-[color:var(--primary-foreground)] ds:ps-[var(--spacing-2xl)] ds:pe-[var(--spacing-2xl)] ds:pt-[var(--spacing-2xl)] ds:pb-[var(--spacing-2xl)] ds:text-start\">\n <ProductLockup\n name={productName}\n size=\"lg\"\n monochrome\n tone=\"inherit\"\n variant=\"maker\"\n />\n {brandPanel ? (\n <div className=\"type-body ds:max-w-[28rem] ds:text-start\">\n {brandPanel}\n </div>\n ) : null}\n </div>\n ) : null}\n <div className=\"ds:flex ds:flex-1 ds:items-center ds:justify-center ds:p-[var(--spacing-lg)]\">\n <Card className={connectCardWidthVariants({ layout })}>\n <Card.Body className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-lg)] ds:text-center\">\n <ProductLockup\n name={productName}\n size=\"lg\"\n variant=\"maker\"\n className={connectCardLockupVariants({ layout })}\n />\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <h1 className=\"type-title-card\">{title}</h1>\n <p className=\"type-body-sm ds:text-[color:var(--muted-foreground)]\">\n {description}\n </p>\n </div>\n {status === 'error' && error ? (\n <Alert variant=\"error\" className=\"ds:w-full ds:text-start\">\n {error}\n </Alert>\n ) : null}\n <SignInWithAlfadocsButton\n intent=\"primary\"\n className=\"ds:w-full\"\n loading={status === 'connecting'}\n onClick={onConnect}\n label={connectLabel}\n data-testid=\"connect-with-alfadocs-button\"\n />\n {footer ? (\n <div className=\"type-meta ds:text-[color:var(--muted-foreground)]\">\n {footer}\n </div>\n ) : null}\n </Card.Body>\n </Card>\n </div>\n </div>\n );\n },\n);\n\nConnectWithAlfadocs.displayName = 'ConnectWithAlfadocs';\n"],"names":["lockup","cva","productName","makerRoot","ProductLockup","forwardRef","name","variant","monochrome","tone","size","className","props","ref","inherit","markInk","nameInk","byInk","letteringInk","jsxs","jsx","AlfadocsLogoMark","AlfadocsLogoNeg","Logo","formatBadgeCount","count","AccountMenu","user","labels","onSignOut","onToggleFullscreen","t","useTranslation","fullscreenLabel","DropdownMenu","Avatar","Fragment","Maximize2","LogOut","MarketplaceSidebarNav","nav","renderLink","SidebarBody","item","badge","inner","SidebarItemIcon","SidebarItemLabel","SidebarItemBadge","SidebarItem","shellMainVariants","EmbeddedTabStrip","ariaLabel","tabRenderLink","href","children","ariaCurrent","tabId","TabBar","MarketplaceAppShell","productHref","sidebarState","collapsibleSidebar","mainAriaLabel","headerBrand","HeaderBrand","themePref","accessibility","resolvedTheme","useTheme","hasExplicitOverride","themeBase","themeAccessible","sidebarOpen","setSidebarOpen","useState","shell","TooltipProvider","AppFrame","Header","HeaderStart","HeaderSkipLink","HeaderMenuButton","HeaderCenter","HeaderEnd","HeaderSettings","Sidebar","SidebarHeader","SidebarCollapseTrigger","embedded","content","ThemeRoot","connectRootVariants","connectCardWidthVariants","connectCardLockupVariants","ConnectWithAlfadocs","title","description","connectLabel","status","error","onConnect","footer","layout","brandPanel","Card","Alert","SignInWithAlfadocsButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,KAASC,EAAI,2DAA2D,GAQxEC,KAAcD;AAAA,EAClB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,MAEN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,QAKJ,UAAU;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA;AAAA;AAAA;AAAA,QAKF,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,iBAAiB,EAAE,MAAM,MAAM,MAAM,WAAA;AAAA,EAAW;AAEpD,GAOME,KAAYF,EAAI,wBAAwB;AAAA,EAC5C,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,iBAAiB,EAAE,MAAM,KAAA;AAC3B,CAAC,GAuEYG,IAAgBC;AAAA,EAC3B,CACE;AAAA,IACE,MAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,YAAAC,IAAa;AAAA,IACb,MAAAC,IAAO;AAAA,IACP,MAAAC,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AAOH,QAAIN,MAAY,SAAS;AAOvB,YAAMO,IAAUL,MAAS,WACnBM,IAAUD,IACZ,KACAN,IACE,sCACA,kCACAQ,IAAUF,IACZ,KACAN,IACE,sCACA,kCACAS,IAAQH,IAAU,KAAK,2CAC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