@mcurcio/patchbay 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +11 -2
  2. package/dist/composites.css +1 -1
  3. package/dist/composites.js +399 -254
  4. package/dist/composites.js.map +1 -1
  5. package/dist/graph.css +1 -1
  6. package/dist/graph.js +575 -273
  7. package/dist/graph.js.map +1 -1
  8. package/dist/hooks.js.map +1 -1
  9. package/dist/primitives.css +1 -1
  10. package/dist/primitives.js +123 -113
  11. package/dist/primitives.js.map +1 -1
  12. package/dist/shell.css +1 -1
  13. package/dist/shell.js +89 -71
  14. package/dist/shell.js.map +1 -1
  15. package/dist/types/composites/banner/Banner.d.ts +2 -2
  16. package/dist/types/composites/change-list/ChangeList.d.ts +44 -0
  17. package/dist/types/composites/change-list/index.d.ts +2 -0
  18. package/dist/types/composites/diagnostic-list/DiagnosticList.d.ts +23 -0
  19. package/dist/types/composites/diagnostic-list/index.d.ts +2 -0
  20. package/dist/types/composites/index.d.ts +2 -0
  21. package/dist/types/composites/status-words/StatusWords.d.ts +1 -1
  22. package/dist/types/graph/canvas-tools/CanvasTools.d.ts +7 -2
  23. package/dist/types/graph/connect-hints/connectTargets.d.ts +22 -0
  24. package/dist/types/graph/connect-hints/index.d.ts +3 -1
  25. package/dist/types/graph/connect-hints/useConnectHints.d.ts +9 -0
  26. package/dist/types/graph/connect-status/ConnectStatus.d.ts +30 -0
  27. package/dist/types/graph/connect-status/index.d.ts +2 -0
  28. package/dist/types/graph/context-at/index.d.ts +2 -0
  29. package/dist/types/graph/context-at/useContextAt.d.ts +43 -0
  30. package/dist/types/graph/empty-canvas-hint/EmptyCanvasHint.d.ts +33 -0
  31. package/dist/types/graph/empty-canvas-hint/index.d.ts +2 -0
  32. package/dist/types/graph/ghost-node/GhostNode.d.ts +32 -0
  33. package/dist/types/graph/ghost-node/index.d.ts +2 -0
  34. package/dist/types/graph/ghost-wire/GhostWire.d.ts +1 -1
  35. package/dist/types/graph/index.d.ts +4 -0
  36. package/dist/types/graph/meter/Meter.d.ts +8 -1
  37. package/dist/types/graph/meter/index.d.ts +1 -1
  38. package/dist/types/graph/wire/Wire.d.ts +4 -4
  39. package/dist/types/hooks/use-toasts/toastQueue.d.ts +1 -1
  40. package/dist/types/primitives/glyph/Glyph.d.ts +14 -0
  41. package/dist/types/primitives/glyph/index.d.ts +2 -0
  42. package/dist/types/primitives/icon-button/index.d.ts +1 -0
  43. package/dist/types/primitives/index.d.ts +1 -0
  44. package/dist/types/primitives/key-value/KeyValue.d.ts +3 -3
  45. package/dist/types/primitives/spinner/Spinner.d.ts +1 -1
  46. package/package.json +1 -1
  47. /package/dist/types/primitives/{dialog → icon-button}/CloseGlyph.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"composites.js","names":["Fragment","_Fragment","Fragment$1","defaultBannerLabels","Banner","rest","words","labels","tone","className","actions","onDismiss","IconButton","CodeRuns","runs","run","index","shownText","text","lineStarts","starts","at","shown","caretAt","offset","line","offsetAt","start","end","column","markLevel","severity","rank","worse","a","b","markRange","diagnostic","lineStart","lineEnd","codeRuns","classes","classAt","span","spans","name","levels","markAt","diagnostics","level","from","mark","gutterRows","count","rows","row","knoblyLoad","knoblyReady","loadKnobly","module","error","useHighlighter","wantsKnobly","highlight","language","loaded","setLoaded","useState","useEffect","live","found","defaultCodeEditorLabels","code","message","none","outdentOf","indent","width","spaces","tabEdit","multiLine","out","caret","last","to","lines","changed","insert","delta","browserEdit","CodeEditor","describedBy","area","useRef","layer","gutter","escaped","pending","lastCaret","said","useId","highlighter","value","useMemo","follow","box","reportCaret","onCaret","key","wanted","edit","change","next","onChange","onKeyDown","event","wasEscaped","readOnly","goTo","description","describedByAll","id","digits","lineNumbers","element","ref","onBlur","onScroll","onSelect","CodeText","wordStart","before","here","fold","lower","unit","startBonus","wordBonus","nextBonus","gapCost","gapCostMost","lateCost","matchSubsequence","squeezed","query","n","m","bonus","best","j","back","letter","i","own","previous","k","joined","score","indices","rankCommands","groups","match","command","group","order","byScore","sorted","items","markRuns","marked","label","isMarked","defaultCommandPaletteLabels","PALETTE_WIDTH","PALETTE_HEIGHT","PALETTE_GUTTER","placePalette","window","height","clamp","room","size","fallbackPage","useWindowSize","read","setSize","watch","onResize","OpenPalette","ids","listId","setQuery","commands","flat","item","enabled","chosen","setChosen","queried","setQueried","active","optionId","field","list","onCloseRef","onClose","useLayoutEffect","owned","now","option","pageSize","modified","move","windowSize","placed","anchored","body","headingId","keys","selected","ariaKeyShortcuts","platform","part","keyLabel","one","CommandPalette","open","createPortal","diffLineKind","baseName","path","all","DiffBody","DiffView","base","ownCollapsed","setOwnCollapsed","folded","collapsed","Heading","toggle","was","other","onToggle","files","diff","file","bodyId","defaultShortcutSheetLabels","groupShortcuts","shortcuts","ShortcutSheet","Dialog","children","StatusWords","defaultToasterLabels","more","placements","heardLimit","Toaster","drawn","placement","top","ordered","toasts","empty","heard","sequence","setSaid","news","toast","fresh","kept","shownIds","say","alert","regions","hovered","setHovered","focused","setFocused","held","latestHold","onHold","cameFrom","focusNext","dismiss","moreLine","Fragment","onPointerEnter","onPointerLeave","textId","Button"],"sources":["../src/composites/banner/Banner.tsx","../src/composites/code-editor/CodeRuns.tsx","../src/composites/code-editor/highlight.ts","../src/composites/code-editor/CodeEditor.tsx","../src/composites/code-editor/CodeText.tsx","../src/composites/command-palette/rank.ts","../src/composites/command-palette/CommandPalette.tsx","../src/composites/diff-view/DiffView.tsx","../src/composites/shortcut-sheet/ShortcutSheet.tsx","../src/composites/status-words/StatusWords.tsx","../src/composites/toaster/Toaster.tsx"],"sourcesContent":["// A banner: a line of news across the top of a pane or page (a conflict, a lost connection, a refused edit), drawn in\n// its tone, with the app's actions at its end and, if the app lets it go, a close button. An error is an alert, so a\n// screen reader reads it at once; every other tone is a status, read when the reader is free. A tone it does not know\n// is drawn neutrally.\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { IconButton } from \"../../primitives\";\nimport \"./Banner.css\";\n\n/** The tones a banner draws; any other string is drawn neutrally. */\nexport type BannerTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\n/** The banner's own words, each replaceable. */\nexport interface BannerLabels {\n /** The close button's name: \"Dismiss\". */\n dismiss: string;\n}\n\nexport const defaultBannerLabels: BannerLabels = {\n dismiss: \"Dismiss\",\n};\n\nexport type BannerProps = Omit<ComponentPropsWithRef<\"div\">, \"role\"> & {\n /** What the news is, by colour: the stripe's, and the surface's for warn and err. */\n tone: BannerTone;\n /** The news, in words. */\n children: ReactNode;\n /** A slot at the end: the buttons that act on the news. */\n actions?: ReactNode;\n /** Shows a close button, which asks the app to take the banner away. */\n onDismiss?: () => void;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<BannerLabels>;\n};\n\nexport function Banner({ tone, children, actions, onDismiss, labels, className, ...rest }: BannerProps) {\n const words = { ...defaultBannerLabels, ...labels };\n return (\n <div\n {...rest}\n role={tone === \"err\" ? \"alert\" : \"status\"}\n className={className === undefined ? \"pb-banner\" : `pb-banner ${className}`}\n data-tone={tone}\n >\n <div className=\"pb-banner-text\">{children}</div>\n {actions !== undefined && <div className=\"pb-banner-actions\">{actions}</div>}\n {onDismiss !== undefined && (\n <IconButton className=\"pb-banner-dismiss\" size=\"sm\" label={words.dismiss} onClick={onDismiss}>\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" />\n </svg>\n </IconButton>\n )}\n </div>\n );\n}\n","// The runs of highlighted text both code views draw: a span per run with a class or a mark, plain text otherwise.\n// Internal to the code views; not exported from the layer.\nimport type { CodeRun } from \"./highlight\";\nimport \"./CodeRuns.css\";\n\nexport function CodeRuns({ runs }: { runs: readonly CodeRun[] }) {\n return runs.map((run, index) =>\n run.class === \"\" && run.mark === undefined ? (\n run.text\n ) : (\n <span key={index} className=\"pb-code-run\" data-class={run.class || undefined} data-mark={run.mark}>\n {run.text}\n </span>\n ),\n );\n}\n","// The code views' text, pure: the text as a textarea shows it, cut into runs by a highlighter's spans and the\n// diagnostics' marks, the gutter's rows, and lines and columns to offsets and back. It also loads knobly's highlighter,\n// the one language built in, from the optional knobly peer, only when a view asks for it.\nimport { useEffect, useState } from \"react\";\n\n/** A highlighter's span: offsets into the shown text (`end` exclusive) and its class. */\nexport type CodeSpan = {\n readonly start: number;\n readonly end: number;\n /**\n * How it is drawn: \"directive\", \"keyword\", \"word\", \"variable\", \"number\", \"string\", \"comment\", \"punctuation\" or\n * \"error\" have a colour each; \"space\", \"\" and any other class are drawn as plain text.\n */\n readonly class: string;\n};\n\n/** A highlighter: the text, as shown (LF line breaks), to its spans. Pure and total. */\nexport type Highlighter = (text: string) => readonly CodeSpan[];\n\n/** A language built in: \"knobly\"; any other is drawn as plain text unless a highlighter is given. */\nexport type CodeLanguage = \"knobly\" | (string & {});\n\n/** How bad a diagnostic is: \"error\" and \"warning\" have their own mark; any other is drawn neutrally. */\nexport type CodeSeverity = \"error\" | \"warning\" | (string & {});\n\n/** Something the app found in the text: a line (from 1) and an optional column (from 1, in UTF-16 code units). */\nexport type CodeDiagnostic = {\n line: number;\n column?: number;\n severity: CodeSeverity;\n message: string;\n /** The app's own code for it, read with the message. */\n code?: string;\n};\n\n/** Where the caret is: a line and a column, both from 1, and its offset into the shown text. */\nexport type CodeCaret = { line: number; column: number; offset: number };\n\n/** The mark a severity draws. */\nexport type CodeMarkLevel = \"error\" | \"warning\" | \"other\";\n\n/** One run of shown text, drawn in one class with at most one mark. */\nexport type CodeRun = { text: string; class: string; mark?: CodeMarkLevel };\n\n/** One gutter row per shown line, with its diagnostics in the order given. */\nexport type CodeGutterRow = {\n line: number;\n mark?: CodeMarkLevel;\n /** Where a press on its mark puts the caret: the first diagnostic's column, else 1. */\n column: number;\n diagnostics: CodeDiagnostic[];\n};\n\n/**\n * The text as a textarea shows it: a textarea holds LF line breaks only, so CRLF and a lone CR are drawn as LF. The\n * value itself is never changed.\n */\nexport function shownText(text: string): string {\n return text.replace(/\\r\\n?/g, \"\\n\");\n}\n\n/** Where each line of shown text starts. \"\" is one line, and a last newline starts an empty one after it. */\nexport function lineStarts(shown: string): number[] {\n const starts = [0];\n for (let at = shown.indexOf(\"\\n\"); at !== -1; at = shown.indexOf(\"\\n\", at + 1)) starts.push(at + 1);\n return starts;\n}\n\n/** The caret at an offset into the shown text, clamped to the text. */\nexport function caretAt(shown: string, offset: number): CodeCaret {\n const at = Math.min(shown.length, Math.max(0, Math.trunc(offset)));\n const starts = lineStarts(shown);\n let line = 0;\n while (line + 1 < starts.length && (starts[line + 1] ?? Infinity) <= at) line += 1;\n return { line: line + 1, column: at - (starts[line] ?? 0) + 1, offset: at };\n}\n\n/** The offset of a line and column (both from 1) into the shown text, each clamped to the text. */\nexport function offsetAt(shown: string, line: number, column = 1): number {\n const starts = lineStarts(shown);\n const index = Math.min(starts.length, Math.max(1, Math.trunc(line))) - 1;\n const start = starts[index] ?? 0;\n const end = index + 1 < starts.length ? (starts[index + 1] ?? 0) - 1 : shown.length;\n return Math.min(end, start + Math.max(1, Math.trunc(column)) - 1);\n}\n\n/** The mark a severity draws: error, warning, or a neutral one for any other. */\nexport function markLevel(severity: string): CodeMarkLevel {\n return severity === \"error\" ? \"error\" : severity === \"warning\" ? \"warning\" : \"other\";\n}\n\nconst rank: Record<CodeMarkLevel, number> = { other: 1, warning: 2, error: 3 };\n\nfunction worse(a: CodeMarkLevel | undefined, b: CodeMarkLevel): CodeMarkLevel {\n return a !== undefined && rank[a] >= rank[b] ? a : b;\n}\n\n/** A diagnostic's mark in the shown text: from its column to the word's end, or the line's text without a column. */\nexport function markRange(shown: string, diagnostic: CodeDiagnostic): { start: number; end: number } {\n const starts = lineStarts(shown);\n const index = Math.min(starts.length, Math.max(1, Math.trunc(diagnostic.line))) - 1;\n const lineStart = starts[index] ?? 0;\n const lineEnd = index + 1 < starts.length ? (starts[index + 1] ?? 0) - 1 : shown.length;\n if (diagnostic.column === undefined) {\n let start = lineStart;\n let end = lineEnd;\n while (start < end && /\\s/.test(shown[start] ?? \"\")) start += 1;\n while (end > start && /\\s/.test(shown[end - 1] ?? \"\")) end -= 1;\n return { start, end };\n }\n const start = offsetAt(shown, index + 1, diagnostic.column);\n let end = start;\n while (end < lineEnd && !/\\s/.test(shown[end] ?? \"\")) end += 1;\n // A column on white space marks that one character; one past the line's end marks nothing.\n if (end === start && start < lineEnd) end = start + 1;\n return { start, end };\n}\n\n/**\n * The shown text cut into runs by the spans (clipped to the text, empty ones ignored; where two overlap, the later\n * one wins) and the diagnostics' marks (where two overlap, error over warning over any other). Joined, the runs are\n * the shown text exactly.\n */\nexport function codeRuns(\n shown: string,\n spans: readonly CodeSpan[] = [],\n diagnostics: readonly CodeDiagnostic[] = [],\n): CodeRun[] {\n const classes = [\"\"];\n const classAt = new Uint16Array(shown.length);\n for (const span of spans) {\n const start = Math.max(0, Math.trunc(span.start));\n const end = Math.min(shown.length, Math.trunc(span.end));\n if (!(end > start)) continue;\n const name = span.class === \"space\" ? \"\" : span.class;\n let index = classes.indexOf(name);\n if (index === -1) index = classes.push(name) - 1;\n classAt.fill(index, start, end);\n }\n const levels: (CodeMarkLevel | undefined)[] = [undefined, \"other\", \"warning\", \"error\"];\n const markAt = new Uint8Array(shown.length);\n for (const diagnostic of diagnostics) {\n const { start, end } = markRange(shown, diagnostic);\n const level = rank[markLevel(diagnostic.severity)];\n for (let at = start; at < end; at += 1) markAt[at] = Math.max(markAt[at] ?? 0, level);\n }\n const runs: CodeRun[] = [];\n let from = 0;\n for (let at = 1; at <= shown.length; at += 1) {\n if (at < shown.length && classAt[at] === classAt[from] && markAt[at] === markAt[from]) continue;\n const mark = levels[markAt[from] ?? 0];\n const run: CodeRun = { text: shown.slice(from, at), class: classes[classAt[from] ?? 0] ?? \"\" };\n if (mark !== undefined) run.mark = mark;\n runs.push(run);\n from = at;\n }\n return runs;\n}\n\n/** One row per shown line; a diagnostic's line is clamped to the text, so one past the end marks the last line. */\nexport function gutterRows(shown: string, diagnostics: readonly CodeDiagnostic[] = []): CodeGutterRow[] {\n const count = lineStarts(shown).length;\n const rows = Array.from({ length: count }, (_, index): CodeGutterRow => ({\n line: index + 1,\n column: 1,\n diagnostics: [],\n }));\n for (const diagnostic of diagnostics) {\n const row = rows[Math.min(count, Math.max(1, Math.trunc(diagnostic.line))) - 1];\n if (row === undefined) continue;\n if (row.diagnostics.length === 0) row.column = diagnostic.column ?? 1;\n row.diagnostics.push(diagnostic);\n row.mark = worse(row.mark, markLevel(diagnostic.severity));\n }\n return rows;\n}\n\nlet knoblyLoad: Promise<Highlighter | null> | undefined;\nlet knoblyReady: Highlighter | null | undefined;\n\n/**\n * Loads knobly's highlighter from the optional knobly peer, once for the page; null when knobly is not installed (the\n * view then draws plain text, and says so once on the console).\n */\nexport function loadKnobly(): Promise<Highlighter | null> {\n knoblyLoad ??= import(\"knobly/highlight\").then(\n (module): Highlighter => (knoblyReady = module.highlight),\n (error: unknown) => {\n console.warn('patchbay: language \"knobly\" needs the knobly package; drawing plain text.', error);\n knoblyReady = null;\n return null;\n },\n );\n return knoblyLoad;\n}\n\n/**\n * The highlighter a view draws with: the app's `highlight` when given, else knobly's for language \"knobly\" (once\n * loaded; plain text until then), else none.\n */\nexport function useHighlighter(language: CodeLanguage | undefined, highlight: Highlighter | undefined) {\n const wantsKnobly = highlight === undefined && language === \"knobly\";\n // Kept in a box: React would call a function given to useState or its setter.\n const [loaded, setLoaded] = useState<{ highlight: Highlighter | null } | undefined>(undefined);\n useEffect(() => {\n if (!wantsKnobly || knoblyReady !== undefined) return;\n let live = true;\n void loadKnobly().then((found) => {\n if (live) setLoaded({ highlight: found });\n });\n return () => {\n live = false;\n };\n }, [wantsKnobly]);\n if (highlight !== undefined) return highlight;\n return wantsKnobly ? (knoblyReady ?? loaded?.highlight ?? undefined) : undefined;\n}\n","// A text editor for configuration text: a native textarea holds the text, the caret, the selection and every edit; a\n// highlighted copy of what it shows is drawn behind it (its glyphs transparent over the copy's) and follows its scroll.\n// A gutter beside the box numbers the lines and marks those a diagnostic names; a press on a mark puts the caret\n// there. Tab indents and Shift+Tab outdents; Escape, then Tab or Shift+Tab, moves the focus on as usual, so the\n// keyboard can always leave. The diagnostics, and how to leave, are read as the textarea's description.\nimport {\n type ComponentPropsWithRef,\n type CSSProperties,\n type KeyboardEvent,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { CodeRuns } from \"./CodeRuns\";\nimport {\n type CodeCaret,\n type CodeDiagnostic,\n type CodeLanguage,\n caretAt,\n codeRuns,\n gutterRows,\n type Highlighter,\n offsetAt,\n shownText,\n useHighlighter,\n} from \"./highlight\";\nimport \"./CodeEditor.css\";\n\n/** The editor's own words, each replaceable. */\nexport interface CodeEditorLabels {\n /** How a diagnostic is read, and shown over its gutter mark: \"Line 3, column 5: error E1: message\". */\n diagnostic: (diagnostic: CodeDiagnostic) => string;\n /** Read after the editor's name while it can be edited: how Tab works and how to leave. */\n tabKey: string;\n}\n\nexport const defaultCodeEditorLabels: CodeEditorLabels = {\n diagnostic: ({ line, column, severity, code, message }) =>\n `Line ${String(line)}${column === undefined ? \"\" : `, column ${String(column)}`}: ${severity}${\n code === undefined || code === \"\" ? \"\" : ` ${code}`\n }: ${message}`,\n tabKey: \"Tab indents. Press Escape, then Tab, to move on.\",\n};\n\nexport type CodeEditorProps = Omit<ComponentPropsWithRef<\"textarea\">, \"value\" | \"defaultValue\" | \"onChange\"> & {\n /** The text. CRLF and a lone CR are shown as LF, and an edit gives the text back with LF. */\n value: string;\n /** The person changed the text: the textarea's whole new value. */\n onChange?: (value: string) => void;\n /** A language built in (\"knobly\"); any other draws plain text. `highlight` wins over it. */\n language?: CodeLanguage;\n /** The app's highlighter, from the shown text to its spans. */\n highlight?: Highlighter;\n /** What the app found in the text, marked in the gutter and under the text, and read with the editor. */\n diagnostics?: readonly CodeDiagnostic[];\n /** The caret moved (by a key, a press, an edit or a gutter mark): its line, column and offset. */\n onCaret?: (caret: CodeCaret) => void;\n /** Show the line-number gutter (true by default). */\n lineNumbers?: boolean;\n /** What Tab inserts, and Shift+Tab takes away from a line's start: a tab by default. */\n indent?: string;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<CodeEditorLabels>;\n};\n\nconst none: readonly CodeDiagnostic[] = [];\n\ntype Pending = { value: string; start: number; end: number };\n\n/** How many leading characters of a line one outdent takes away. */\nfunction outdentOf(line: string, indent: string): number {\n if (indent !== \"\" && line.startsWith(indent)) return indent.length;\n if (line.startsWith(\"\\t\")) return 1;\n const width = indent === \"\\t\" || indent === \"\" ? 4 : indent.length;\n let spaces = 0;\n while (spaces < width && line[spaces] === \" \") spaces += 1;\n return spaces;\n}\n\n/**\n * What Tab (or Shift+Tab, `out`) does to a text and its selection: the range it replaces, with what, and the\n * selection after. Tab in one line replaces the selection with the indent; across lines, and Shift+Tab always, it\n * indents or outdents each line the selection touches (empty lines are left alone when indenting). Undefined when\n * nothing would change.\n */\nexport function tabEdit(\n text: string,\n start: number,\n end: number,\n indent: string,\n out: boolean,\n): { from: number; to: number; insert: string; start: number; end: number } | undefined {\n const multiLine = text.slice(start, end).includes(\"\\n\");\n if (!out && !multiLine) {\n if (indent === \"\") return undefined;\n const caret = start + indent.length;\n return { from: start, to: end, insert: indent, start: caret, end: caret };\n }\n const from = text.lastIndexOf(\"\\n\", start - 1) + 1;\n // A selection that ends at a line's start does not take that line.\n const last = end > start && text[end - 1] === \"\\n\" ? end - 1 : end;\n const lineEnd = text.indexOf(\"\\n\", last);\n const to = lineEnd === -1 ? text.length : lineEnd;\n const lines = text.slice(from, to).split(\"\\n\");\n const changed = lines.map((line) => (out ? line.slice(outdentOf(line, indent)) : line === \"\" ? line : indent + line));\n const insert = changed.join(\"\\n\");\n if (insert === text.slice(from, to)) return undefined;\n if (start === end) {\n // A caret moves with its line's text, never before the line's start.\n const delta = (changed[0] ?? \"\").length - (lines[0] ?? \"\").length;\n const caret = Math.max(from, start + delta);\n return { from, to, insert, start: caret, end: caret };\n }\n return { from, to, insert, start: from, end: from + insert.length };\n}\n\n/**\n * Replaces a textarea's selection through the browser's own editing, which keeps its undo history, so Ctrl+Z takes an\n * indent back as it does a typed character. execCommand is deprecated, but no other API edits a textarea within its\n * undo history; false where the browser has none (or refuses), and the edit is then made by value.\n */\nfunction browserEdit(insert: string): boolean {\n const run = (document as { execCommand?: (command: string, ui: boolean, value?: string) => boolean }).execCommand;\n if (typeof run !== \"function\") return false;\n return insert === \"\" ? run.call(document, \"delete\", false) : run.call(document, \"insertText\", false, insert);\n}\n\nexport function CodeEditor({\n value,\n onChange,\n language,\n highlight,\n diagnostics = none,\n onCaret,\n lineNumbers = true,\n indent = \"\\t\",\n labels,\n readOnly = false,\n className,\n style,\n ref,\n onKeyDown,\n onBlur,\n onScroll,\n onSelect,\n \"aria-describedby\": describedBy,\n ...rest\n}: CodeEditorProps) {\n const words = { ...defaultCodeEditorLabels, ...labels };\n const area = useRef<HTMLTextAreaElement | null>(null);\n const layer = useRef<HTMLPreElement>(null);\n const gutter = useRef<HTMLPreElement>(null);\n const escaped = useRef(false);\n const pending = useRef<Pending | null>(null);\n const lastCaret = useRef<string>(\"\");\n const said = useId();\n const highlighter = useHighlighter(language, highlight);\n\n const shown = shownText(value);\n const runs = useMemo(() => codeRuns(shown, highlighter?.(shown), diagnostics), [shown, highlighter, diagnostics]);\n const rows = useMemo(() => gutterRows(shown, diagnostics), [shown, diagnostics]);\n\n const follow = () => {\n const box = area.current;\n if (box === null) return;\n if (layer.current !== null) {\n layer.current.scrollTop = box.scrollTop;\n layer.current.scrollLeft = box.scrollLeft;\n }\n if (gutter.current !== null) gutter.current.scrollTop = box.scrollTop;\n };\n\n const reportCaret = () => {\n const box = area.current;\n if (box === null || onCaret === undefined) return;\n const offset = box.selectionDirection === \"backward\" ? box.selectionStart : box.selectionEnd;\n const caret = caretAt(box.value, offset);\n const key = `${String(caret.line)}:${String(caret.column)}:${String(caret.offset)}`;\n if (key === lastCaret.current) return;\n lastCaret.current = key;\n onCaret(caret);\n };\n\n // After a render (an edit, a new text), put the copy and the gutter where the textarea is scrolled, and the\n // selection where an edit made without the browser's own editing left it.\n useLayoutEffect(() => {\n const box = area.current;\n const wanted = pending.current;\n pending.current = null;\n if (box !== null && wanted !== null && box.value === wanted.value) {\n box.setSelectionRange(wanted.start, wanted.end);\n reportCaret();\n }\n follow();\n });\n\n const edit = (box: HTMLTextAreaElement, change: NonNullable<ReturnType<typeof tabEdit>>) => {\n box.setSelectionRange(change.from, change.to);\n const done = browserEdit(change.insert);\n if (done) {\n box.setSelectionRange(change.start, change.end);\n reportCaret();\n return;\n }\n const next = box.value.slice(0, change.from) + change.insert + box.value.slice(change.to);\n pending.current = { value: next, start: change.start, end: change.end };\n onChange?.(next);\n };\n\n const key = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\") {\n escaped.current = true;\n return;\n }\n if (event.key !== \"Tab\") {\n if (event.key !== \"Shift\") escaped.current = false;\n return;\n }\n const wasEscaped = escaped.current;\n escaped.current = false;\n if (wasEscaped || readOnly || event.ctrlKey || event.altKey || event.metaKey || event.nativeEvent.isComposing) {\n return;\n }\n event.preventDefault();\n const box = event.currentTarget;\n const change = tabEdit(box.value, box.selectionStart, box.selectionEnd, indent, event.shiftKey);\n if (change !== undefined) edit(box, change);\n };\n\n const goTo = (line: number, column: number) => {\n const box = area.current;\n if (box === null) return;\n const offset = offsetAt(box.value, line, column);\n box.focus();\n box.setSelectionRange(offset, offset);\n reportCaret();\n };\n\n const description = [\n ...(readOnly ? [] : [words.tabKey]),\n ...diagnostics.map((diagnostic) => words.diagnostic(diagnostic)),\n ];\n const describedByAll =\n [describedBy, description.length > 0 ? said : undefined].filter((id) => id !== undefined && id !== \"\").join(\" \") ||\n undefined;\n const digits = String(rows.length).length;\n\n return (\n <div\n className={className === undefined ? \"pb-code-editor\" : `pb-code-editor ${className}`}\n style={style}\n data-readonly={readOnly || undefined}\n >\n {lineNumbers ? (\n <pre\n ref={gutter}\n className=\"pb-code-gutter\"\n aria-hidden=\"true\"\n style={{ \"--pb-code-gutter-digits\": digits } as CSSProperties}\n >\n <code className=\"pb-code-gutter-code\">\n {rows.map((row) => (\n <span key={row.line} className=\"pb-code-gutter-row\">\n {row.line}\n <span\n className=\"pb-code-gutter-mark\"\n data-mark={row.mark}\n title={\n row.diagnostics.length === 0\n ? undefined\n : row.diagnostics.map((diagnostic) => words.diagnostic(diagnostic)).join(\"\\n\")\n }\n onClick={\n row.mark === undefined\n ? undefined\n : () => {\n goTo(row.line, row.column);\n }\n }\n />\n {\"\\n\"}\n </span>\n ))}\n </code>\n </pre>\n ) : null}\n <div className=\"pb-code-box\">\n <pre ref={layer} className=\"pb-code-layer\" aria-hidden=\"true\">\n <code className=\"pb-code-layer-code\">\n <CodeRuns runs={runs} />\n {/* A last empty line keeps its height, as the textarea gives it. */}\n {\"\\n\"}\n </code>\n </pre>\n <textarea\n spellCheck={false}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n wrap=\"off\"\n {...rest}\n ref={(element) => {\n area.current = element;\n if (typeof ref === \"function\") return ref(element);\n if (ref) ref.current = element;\n return undefined;\n }}\n className=\"pb-code-input\"\n value={value}\n readOnly={readOnly}\n aria-describedby={describedByAll}\n onChange={(event) => onChange?.(event.target.value)}\n onKeyDown={key}\n onBlur={(event) => {\n escaped.current = false;\n onBlur?.(event);\n }}\n onScroll={(event) => {\n follow();\n onScroll?.(event);\n }}\n onSelect={(event) => {\n reportCaret();\n onSelect?.(event);\n }}\n />\n </div>\n {description.length > 0 ? (\n <div id={said} hidden>\n {description.map((line, index) => (\n <p key={index}>{line}</p>\n ))}\n </div>\n ) : null}\n </div>\n );\n}\n","// Read-only highlighted code: the text in code type on the read-only code surface, highlighted by knobly's highlighter\n// (language \"knobly\", loaded from the optional knobly peer) or the app's own. Long lines scroll sideways; the box is a\n// tab stop, so it scrolls from the keyboard too.\nimport { type ComponentPropsWithRef, useMemo } from \"react\";\nimport { CodeRuns } from \"./CodeRuns\";\nimport { type CodeLanguage, codeRuns, type Highlighter, shownText, useHighlighter } from \"./highlight\";\nimport \"./CodeText.css\";\n\nexport type CodeTextProps = Omit<ComponentPropsWithRef<\"pre\">, \"children\"> & {\n /** The text; CRLF and a lone CR are drawn as LF. */\n value: string;\n /** A language built in (\"knobly\"); any other draws plain text. `highlight` wins over it. */\n language?: CodeLanguage;\n /** The app's highlighter, from the shown text to its spans. */\n highlight?: Highlighter;\n};\n\nexport function CodeText({ value, language, highlight, className, ...rest }: CodeTextProps) {\n const highlighter = useHighlighter(language, highlight);\n const runs = useMemo(() => {\n const shown = shownText(value);\n return codeRuns(shown, highlighter?.(shown));\n }, [value, highlighter]);\n return (\n <pre tabIndex={0} {...rest} className={className === undefined ? \"pb-code-text\" : `pb-code-text ${className}`}>\n <code className=\"pb-code-text-code\">\n <CodeRuns runs={runs} />\n </code>\n </pre>\n );\n}\n","// The command palette's ranking (docs/components.md#commands-and-keys): a query matches a label when its letters appear\n// in the label in order, in any case, not necessarily together (\"adn\" matches \"Add a node\"). Of the ways the letters\n// can be found, the best is kept: letters at the start of a word and letters next to each other score more, gaps and\n// a late start score less. Pure, so the palette and an app's tests share it.\n\n/** Where a query's letters fell in a label, and how good the match is. */\nexport type SubsequenceMatch = {\n /** The indices (UTF-16 code units) of the label's matched characters, ascending. */\n indices: number[];\n /** Higher is better; an empty query scores 0. */\n score: number;\n};\n\n/** A word starts at the label's start, after a character that is not a letter or digit, or at a capital after a small letter. */\nfunction wordStart(text: string, at: number): boolean {\n if (at === 0) return true;\n const before = text.charAt(at - 1);\n const here = text.charAt(at);\n if (!/[\\p{L}\\p{N}]/u.test(before)) return true;\n return before !== before.toUpperCase() && here !== here.toLowerCase() && here === here.toUpperCase();\n}\n\n/** A code unit in lower case, unless lowering it makes more than one (\"İ\"), which is then compared as it is. */\nfunction fold(unit: string): string {\n const lower = unit.toLowerCase();\n return lower.length === 1 ? lower : unit;\n}\n\nconst startBonus = 3;\nconst wordBonus = 2;\nconst nextBonus = 2;\nconst gapCost = 0.1;\nconst gapCostMost = 1;\nconst lateCost = 0.02;\n\n/**\n * Finds the query's letters in the text, in order and in any case (white space in the query is ignored), the best\n * way it can; undefined when they are not all there.\n */\nexport function matchSubsequence(text: string, query: string): SubsequenceMatch | undefined {\n const squeezed = query.replace(/\\s+/g, \"\");\n if (squeezed === \"\") return { indices: [], score: 0 };\n // Compared one UTF-16 code unit at a time, each folded the same way, so an index is a place in the label.\n const wanted = Array.from({ length: squeezed.length }, (_, at) => fold(squeezed.charAt(at)));\n const lower = Array.from({ length: text.length }, (_, at) => fold(text.charAt(at)));\n const n = text.length;\n const m = wanted.length;\n if (m > n) return undefined;\n const bonus = lower.map((_, at) => (at === 0 ? startBonus : wordStart(text, at) ? wordBonus : 0));\n // best[j][i]: the best score with the query's letter j at the text's index i; from[j][i]: where letter j-1 was.\n const best: number[][] = [];\n const from: number[][] = [];\n for (let j = 0; j < m; j += 1) {\n const row = new Array<number>(n).fill(-Infinity);\n const back = new Array<number>(n).fill(-1);\n const letter = wanted[j];\n for (let i = j; i < n; i += 1) {\n if (lower[i] !== letter) continue;\n const own = 1 + (bonus[i] ?? 0);\n if (j === 0) {\n row[i] = own - i * lateCost;\n continue;\n }\n const previous = best[j - 1] ?? [];\n for (let k = j - 1; k < i; k += 1) {\n const before = previous[k] ?? -Infinity;\n if (before === -Infinity) continue;\n const joined = k === i - 1 ? nextBonus : -Math.min((i - k - 1) * gapCost, gapCostMost);\n const score = before + own + joined;\n if (score > (row[i] ?? -Infinity)) {\n row[i] = score;\n back[i] = k;\n }\n }\n }\n best.push(row);\n from.push(back);\n }\n const last = best[m - 1] ?? [];\n let end = -1;\n for (let i = 0; i < n; i += 1) if ((last[i] ?? -Infinity) > (end < 0 ? -Infinity : (last[end] ?? -Infinity))) end = i;\n if (end < 0 || last[end] === -Infinity) return undefined;\n const indices: number[] = [];\n for (let j = m - 1, at = end; j >= 0; j -= 1) {\n indices.unshift(at);\n at = from[j]?.[at] ?? -1;\n }\n return { indices, score: last[end] ?? 0 };\n}\n\n/** What ranking needs of a command. */\nexport type Rankable = { label: string; group: string };\n\n/** A command that matched, with where its letters fell. */\nexport type RankedCommand<C extends Rankable> = { command: C; indices: number[]; score: number };\n\n/** One group's matching commands. */\nexport type RankedGroup<C extends Rankable> = { group: string; items: RankedCommand<C>[] };\n\n/**\n * The commands whose labels match the query, in groups. With an empty query every command is kept, in the order given\n * and its groups in the order they first appear; with one, each group's commands go best first and the groups by\n * their best command, ties kept in the order given. Groups with no match are left out.\n */\nexport function rankCommands<C extends Rankable>(commands: readonly C[], query: string): RankedGroup<C>[] {\n const groups = new Map<string, { first: number; items: (RankedCommand<C> & { order: number })[] }>();\n commands.forEach((command, order) => {\n const match = matchSubsequence(command.label, query);\n if (match === undefined) return;\n let group = groups.get(command.group);\n if (group === undefined) {\n group = { first: order, items: [] };\n groups.set(command.group, group);\n }\n group.items.push({ command, indices: match.indices, score: match.score, order });\n });\n const byScore = (a: { score: number; order: number }, b: { score: number; order: number }) =>\n b.score - a.score || a.order - b.order;\n return [...groups.entries()]\n .map(([group, { first, items }]) => {\n const sorted = [...items].sort(byScore);\n return { group, first, items: sorted, top: sorted[0]?.score ?? 0 };\n })\n .sort((a, b) => b.top - a.top || a.first - b.first)\n .map(({ group, items }) => ({\n group,\n items: items.map(({ command, indices, score }) => ({ command, indices, score })),\n }));\n}\n\n/** The label cut into runs, each marked or not, so the matched letters can be drawn in <mark>. */\nexport function markRuns(label: string, indices: readonly number[]): { text: string; marked: boolean }[] {\n const marked = new Set(indices);\n const runs: { text: string; marked: boolean }[] = [];\n for (let at = 0; at < label.length; at += 1) {\n const isMarked = marked.has(at);\n const last = runs[runs.length - 1];\n if (last !== undefined && last.marked === isMarked) last.text += label.charAt(at);\n else runs.push({ text: label.charAt(at), marked: isMarked });\n }\n return runs;\n}\n","// A command palette (docs/components.md#commands-and-keys): a search field over a list of the app's commands, drawn in a\n// portal on <body>, centred near the top of the window or anchored at a point and kept inside it. Typing ranks the\n// commands by their labels (rank.ts), the matched letters in <mark>; the arrows, Page Up and Page Down, Home and End\n// move the active command and Enter runs it. The field is a combobox and the list a listbox, so the focus stays in the\n// field the whole time. Escape, Tab, a press outside and the focus leaving ask the app to close it; closing gives the\n// focus back to what had it before.\nimport {\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { markRuns, rankCommands } from \"./rank\";\nimport \"./CommandPalette.css\";\n\n/** One command in the palette. */\nexport type Command = {\n /** Unique among the commands; the active command is kept by it while the list changes. */\n id: string;\n /** What the command is called; the query is matched against it. */\n label: string;\n /** The heading it is listed under; groups are shown in the order they first appear. */\n group: string;\n /** Its key string, or several, shown through keyLabel (\"Mod+K\"); the palette does not bind them. */\n keys?: string | readonly string[];\n /** A second, quieter line: what it does, or what it acts on. Not matched. */\n hint?: string;\n /** Runs the command; the palette asks to close first. */\n run: () => void;\n /** Shown but skipped by the keys, and does nothing when pressed. */\n disabled?: boolean;\n};\n\n/** A point in the window's coordinates (client px), such as where a press happened. */\nexport type PalettePoint = { x: number; y: number };\n\nexport type CommandPaletteProps = {\n /** Whether the palette is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, Tab, a press outside, the focus leaving, and before a command runs. */\n onClose: () => void;\n commands: readonly Command[];\n /** Anchors the palette's top-left corner at this point, kept inside the window; centred near the top without it. */\n at?: PalettePoint;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<CommandPaletteLabels>;\n /** A class added to the palette's box. */\n className?: string;\n};\n\n/** The palette's own words, each replaceable. */\nexport interface CommandPaletteLabels {\n /** The palette's name for screen readers: \"Commands\". */\n palette: string;\n /** The field's placeholder: \"Type a command\". */\n placeholder: string;\n /** Shown when there are no commands at all: \"No commands\". */\n empty: ReactNode;\n /** Shown when the query matches none: \"No command matches “query”\". */\n noMatch: (query: string) => ReactNode;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"); none by default, keyLabel's own. */\n keyNames: Readonly<Record<string, string>>;\n}\n\nexport const defaultCommandPaletteLabels: CommandPaletteLabels = {\n palette: \"Commands\",\n placeholder: \"Type a command\",\n empty: \"No commands\",\n noMatch: (query) => `No command matches “${query}”`,\n keyNames: {},\n};\n\n/** The anchored palette's size, held inside the window less the gutter. */\nexport const PALETTE_WIDTH = 320;\nexport const PALETTE_HEIGHT = 360;\n/** How far the anchored palette stays from the window's edges. */\nexport const PALETTE_GUTTER = 8;\n\n/**\n * Where an anchored palette goes: its top-left corner at the point, moved back inside the window (less the gutter)\n * where it would cross an edge, and made smaller when the window is smaller than the palette. The height is the\n * most it may take; a short list takes less.\n */\nexport function placePalette(\n at: PalettePoint,\n window: { width: number; height: number },\n): { left: number; top: number; width: number; height: number } {\n const width = Math.max(0, Math.min(PALETTE_WIDTH, window.width - 2 * PALETTE_GUTTER));\n const height = Math.max(0, Math.min(PALETTE_HEIGHT, window.height - 2 * PALETTE_GUTTER));\n const clamp = (value: number, size: number, room: number) =>\n Math.min(Math.max(value, PALETTE_GUTTER), Math.max(PALETTE_GUTTER, room - size - PALETTE_GUTTER));\n return { left: clamp(at.x, width, window.width), top: clamp(at.y, height, window.height), width, height };\n}\n\n/** How many rows Page Up and Page Down move when the list's rows cannot be measured. */\nconst fallbackPage = 8;\n\nfunction useWindowSize(watch: boolean) {\n const read = () => ({ width: window.innerWidth, height: window.innerHeight });\n const [size, setSize] = useState(read);\n useEffect(() => {\n if (!watch) return undefined;\n const onResize = () => {\n setSize(read());\n };\n window.addEventListener(\"resize\", onResize);\n return () => {\n window.removeEventListener(\"resize\", onResize);\n };\n }, [watch]);\n return size;\n}\n\nfunction OpenPalette({ onClose, commands, at, platform, labels, className }: Omit<CommandPaletteProps, \"open\">) {\n const words = { ...defaultCommandPaletteLabels, ...labels };\n const ids = useId();\n const listId = `${ids}-list`;\n const [query, setQuery] = useState(\"\");\n const groups = useMemo(() => rankCommands(commands, query), [commands, query]);\n const flat = useMemo(() => groups.flatMap((group) => group.items.map((item) => item.command)), [groups]);\n const enabled = useMemo(() => flat.filter((command) => command.disabled !== true), [flat]);\n\n // The active command, by id; when it is gone (filtered out, disabled) the first enabled one takes its place.\n const [chosen, setChosen] = useState<string | undefined>(undefined);\n const [queried, setQueried] = useState(query);\n if (queried !== query) {\n setQueried(query);\n setChosen(undefined);\n }\n const active = enabled.find((command) => command.id === chosen) ?? enabled[0];\n const optionId = (command: Command) => `${ids}-option-${flat.indexOf(command)}`;\n\n const box = useRef<HTMLDivElement>(null);\n const field = useRef<HTMLInputElement>(null);\n const list = useRef<HTMLDivElement>(null);\n const onCloseRef = useRef(onClose);\n useLayoutEffect(() => {\n onCloseRef.current = onClose;\n });\n\n // Focus the field on opening; give the focus back on closing, unless it already went somewhere else on purpose.\n useLayoutEffect(() => {\n const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n field.current?.focus();\n const owned = box.current;\n return () => {\n const now = document.activeElement;\n const lost = now === null || now === document.body || (owned?.contains(now) ?? false) || !now.isConnected;\n if (lost && before?.isConnected === true) before.focus();\n };\n }, []);\n\n useEffect(() => {\n if (active === undefined) return;\n const option = document.getElementById(optionId(active));\n // jsdom has no scrollIntoView.\n if (typeof option?.scrollIntoView === \"function\") option.scrollIntoView({ block: \"nearest\" });\n // optionId reads the list, which changes with active.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active]);\n\n const run = (command: Command) => {\n if (command.disabled === true) return;\n onCloseRef.current();\n command.run();\n };\n\n const pageSize = () => {\n const option = list.current?.querySelector<HTMLElement>('[role=\"option\"]');\n const rows =\n option && option.offsetHeight > 0 ? Math.floor((list.current?.clientHeight ?? 0) / option.offsetHeight) : 0;\n return Math.max(1, rows || fallbackPage);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n const modified = event.altKey || event.ctrlKey || event.metaKey;\n const at = active === undefined ? -1 : enabled.indexOf(active);\n const last = enabled.length - 1;\n const move = (to: number) => {\n event.preventDefault();\n const next = enabled[Math.min(Math.max(to, 0), last)];\n if (next !== undefined) setChosen(next.id);\n };\n switch (event.key) {\n case \"Escape\":\n event.preventDefault();\n event.stopPropagation();\n onCloseRef.current();\n return;\n case \"Tab\":\n // A combobox's popup closes on Tab; the focus goes back to where it came from.\n event.preventDefault();\n onCloseRef.current();\n return;\n case \"Enter\":\n if (modified) return;\n event.preventDefault();\n if (active !== undefined) run(active);\n return;\n case \"ArrowDown\":\n if (modified) return;\n move(at >= last ? 0 : at + 1);\n return;\n case \"ArrowUp\":\n if (modified) return;\n move(at <= 0 ? last : at - 1);\n return;\n case \"PageDown\":\n if (modified) return;\n move(at + pageSize());\n return;\n case \"PageUp\":\n if (modified) return;\n move(at - pageSize());\n return;\n case \"Home\":\n // Shift+Home and Shift+End stay with the field, to select its text.\n if (modified || event.shiftKey) return;\n move(0);\n return;\n case \"End\":\n if (modified || event.shiftKey) return;\n move(last);\n return;\n default:\n return;\n }\n };\n\n const windowSize = useWindowSize(at !== undefined);\n const placed = at === undefined ? undefined : placePalette(at, windowSize);\n const anchored = placed !== undefined;\n\n let body: ReactNode;\n if (commands.length === 0) body = words.empty;\n else if (flat.length === 0) body = words.noMatch(query.trim());\n\n return (\n <div\n className=\"pb-palette-layer\"\n data-anchored={anchored ? \"\" : undefined}\n onMouseDown={(event) => {\n // Only a press that starts outside the palette.\n if (event.target === event.currentTarget) onCloseRef.current();\n }}\n >\n <div\n ref={box}\n className={className === undefined ? \"pb-palette\" : `pb-palette ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={words.palette}\n style={\n placed === undefined\n ? undefined\n : { position: \"fixed\", left: placed.left, top: placed.top, width: placed.width, maxHeight: placed.height }\n }\n onBlur={(event) => {\n const to = event.relatedTarget;\n if (to instanceof Node && !event.currentTarget.contains(to)) onCloseRef.current();\n }}\n >\n <input\n ref={field}\n className=\"pb-palette-field\"\n type=\"text\"\n role=\"combobox\"\n aria-label={words.palette}\n aria-expanded=\"true\"\n aria-controls={listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={active === undefined ? undefined : optionId(active)}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n placeholder={words.placeholder}\n value={query}\n onChange={(event) => {\n setQuery(event.target.value);\n }}\n onKeyDown={onKeyDown}\n />\n <div\n ref={list}\n className=\"pb-palette-list\"\n id={listId}\n role=\"listbox\"\n aria-label={words.palette}\n hidden={flat.length === 0}\n >\n {groups.map((group, index) => {\n const headingId = `${ids}-group-${index}`;\n return (\n <div key={group.group} role=\"group\" aria-labelledby={headingId} className=\"pb-palette-group\">\n <div id={headingId} className=\"pb-palette-heading\" role=\"presentation\">\n {group.group}\n </div>\n {group.items.map(({ command, indices }) => {\n const id = optionId(command);\n const keys =\n command.keys === undefined ? [] : typeof command.keys === \"string\" ? [command.keys] : command.keys;\n const selected = command === active;\n return (\n <div\n key={command.id}\n id={id}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={command.disabled === true ? true : undefined}\n aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}\n className=\"pb-palette-option\"\n data-command-id={command.id}\n onMouseDown={(event) => {\n // Keep the focus in the field.\n event.preventDefault();\n }}\n onPointerMove={() => {\n if (command.disabled !== true && !selected) setChosen(command.id);\n }}\n onClick={() => {\n run(command);\n }}\n >\n <span className=\"pb-palette-text\">\n <span className=\"pb-palette-label\">\n {markRuns(command.label, indices).map((part, at) =>\n part.marked ? <mark key={at}>{part.text}</mark> : part.text,\n )}\n </span>\n {command.hint !== undefined && <span className=\"pb-palette-hint\">{command.hint}</span>}\n </span>\n {keys.length > 0 && (\n <span className=\"pb-palette-keys\">\n {keys.map((one) => (\n <kbd key={one}>{keyLabel(one, { platform, names: words.keyNames })}</kbd>\n ))}\n </span>\n )}\n </div>\n );\n })}\n </div>\n );\n })}\n </div>\n {/* There from the start, so a screen reader hears the words when the list empties. */}\n <p className=\"pb-palette-empty\" role=\"status\">\n {body}\n </p>\n </div>\n </div>\n );\n}\n\nexport function CommandPalette({ open, ...rest }: CommandPaletteProps) {\n if (!open) return null;\n return createPortal(<OpenPalette {...rest} />, document.body);\n}\n","// A diff: unified diff text drawn line by line, added lines in the added tone and removed ones in the removed tone,\n// each keeping its \"+\" or \"-\" so the change never rests on colour alone. Given files, each is a section of its own\n// under a heading, labelled by its file name with its whole path on hover, that the person can fold away.\nimport { useId, useState, type ComponentPropsWithRef } from \"react\";\nimport \"./DiffView.css\";\n\nexport type DiffFile = {\n /** The file's path; the section is labelled by its last part. Unique among the files. */\n path: string;\n /** The file's unified diff text. */\n diff: string;\n};\n\n/** What a line of unified diff text is, by its start. */\nexport type DiffLineKind = \"add\" | \"del\" | \"hunk\" | \"meta\" | \"note\" | \"context\";\n\ntype DiffSource =\n | {\n /** One unified diff, drawn whole without a heading. */\n diff: string;\n files?: never;\n }\n | {\n /** One section per file, in this order. */\n files: readonly DiffFile[];\n diff?: never;\n };\n\nexport type DiffViewProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onToggle\"> &\n DiffSource & {\n /** The files' headings' level, h2 to h6 (h3 by default). */\n level?: 2 | 3 | 4 | 5 | 6;\n /**\n * The paths of the files folded away. Given, the app holds them and onToggle asks it to change them; left out,\n * the view keeps its own, every file open at first.\n */\n collapsed?: readonly string[];\n /** Called when the person opens (true) or folds (false) a file's section. */\n onToggle?: (path: string, open: boolean) => void;\n };\n\n/** The kind of one line of unified diff text. */\nexport function diffLineKind(line: string): DiffLineKind {\n if (line.startsWith(\"+++ \") || line.startsWith(\"--- \")) return \"meta\";\n if (line.startsWith(\"@@\")) return \"hunk\";\n if (line.startsWith(\"+\")) return \"add\";\n if (line.startsWith(\"-\")) return \"del\";\n if (line.startsWith(\"\\\\\")) return \"note\";\n if (line === \"\" || line.startsWith(\" \")) return \"context\";\n // A git header line: diff --git, index, new file mode, rename from, similarity index and the like.\n return \"meta\";\n}\n\n/** A path's last part: \"src/app/main.ts\" is \"main.ts\". */\nexport function baseName(path: string): string {\n const parts = path.split(\"/\").filter((part) => part !== \"\");\n return parts.at(-1) ?? path;\n}\n\nfunction lines(text: string): string[] {\n const all = text.split(/\\r?\\n/);\n // A diff ends with a newline, which starts no line of its own.\n if (all.length > 0 && all.at(-1) === \"\") all.pop();\n return all;\n}\n\nfunction DiffBody({ text, id, hidden }: { text: string; id?: string; hidden?: boolean }) {\n return (\n // Focusable, so a wide diff can be scrolled sideways from the keyboard.\n <pre className=\"pb-diff-body\" id={id} hidden={hidden} tabIndex={0}>\n <code className=\"pb-diff-code\">\n {lines(text).map((line, index) => (\n <span key={index} className=\"pb-diff-line\" data-kind={diffLineKind(line)}>\n {line === \"\" ? \" \" : line}\n </span>\n ))}\n </code>\n </pre>\n );\n}\n\nexport function DiffView({ diff, files, level = 3, collapsed, onToggle, className, ...rest }: DiffViewProps) {\n const base = useId();\n const [ownCollapsed, setOwnCollapsed] = useState<readonly string[]>([]);\n const folded = collapsed ?? ownCollapsed;\n const Heading = `h${String(level)}` as \"h3\";\n const toggle = (path: string, open: boolean) => {\n if (collapsed === undefined) {\n setOwnCollapsed((was) => (open ? was.filter((other) => other !== path) : [...was, path]));\n }\n onToggle?.(path, open);\n };\n return (\n <div {...rest} className={className === undefined ? \"pb-diff\" : `pb-diff ${className}`}>\n {files === undefined ? (\n <DiffBody text={diff} />\n ) : (\n files.map((file, index) => {\n const open = !folded.includes(file.path);\n const bodyId = `${base}-${String(index)}`;\n return (\n <div key={file.path} className=\"pb-diff-file\" data-open={open || undefined}>\n <Heading className=\"pb-diff-file-title\">\n <button\n type=\"button\"\n className=\"pb-diff-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n title={file.path}\n onClick={() => {\n toggle(file.path, !open);\n }}\n >\n <svg className=\"pb-diff-chevron\" viewBox=\"0 0 16 16\" width=\"10\" height=\"10\" aria-hidden=\"true\">\n <path d=\"M5 3l5 5-5 5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" />\n </svg>\n {baseName(file.path)}\n </button>\n </Heading>\n <DiffBody text={file.diff} id={bodyId} hidden={!open} />\n </div>\n );\n })\n )}\n </div>\n );\n}\n","// The keys an app binds, listed in a Dialog (docs/components.md#commands-and-keys): one section per group, in the order\n// the groups first appear, each a list of what a key does and the key as people read it (keyLabel). The sheet draws\n// the list it is given and binds nothing; the app's useShortcuts table is usually where the list comes from.\nimport { type ReactNode, Fragment, useId } from \"react\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { Dialog } from \"../../primitives\";\nimport \"./ShortcutSheet.css\";\n\n/** One line of the sheet. */\nexport type ShortcutLine = {\n /** The key string, or several that do the same (\"Mod+K\", [\"Delete\", \"Backspace\"]). */\n keys: string | readonly string[];\n /** What the key does. */\n label: string;\n /** The heading it is listed under. */\n group: string;\n};\n\nexport type ShortcutSheetProps = {\n /** Whether the sheet is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, the close button and a press on the scrim. */\n onClose: () => void;\n shortcuts: readonly ShortcutLine[];\n /** A note under the lists (where the keys do not act, say). */\n children?: ReactNode;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ShortcutSheetLabels>;\n /** A class added to the dialog's box. */\n className?: string;\n};\n\n/** The sheet's own words, each replaceable. */\nexport interface ShortcutSheetLabels {\n /** The dialog's title, which also names it: \"Keyboard shortcuts\". */\n title: ReactNode;\n /** Between two keys that do the same: \"or\". */\n or: string;\n /** Shown when there are no shortcuts: \"No shortcuts\". */\n empty: ReactNode;\n /** The close button's name: \"Close\". */\n close: string;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"); none by default, keyLabel's own. */\n keyNames: Readonly<Record<string, string>>;\n}\n\nexport const defaultShortcutSheetLabels: ShortcutSheetLabels = {\n title: \"Keyboard shortcuts\",\n or: \"or\",\n empty: \"No shortcuts\",\n close: \"Close\",\n keyNames: {},\n};\n\n/** The lines in groups, the groups in the order they first appear and each group's lines in the order given. */\nexport function groupShortcuts(shortcuts: readonly ShortcutLine[]): { group: string; lines: ShortcutLine[] }[] {\n const groups = new Map<string, ShortcutLine[]>();\n for (const line of shortcuts) {\n const lines = groups.get(line.group);\n if (lines === undefined) groups.set(line.group, [line]);\n else lines.push(line);\n }\n return [...groups.entries()].map(([group, lines]) => ({ group, lines }));\n}\n\nexport function ShortcutSheet({ open, onClose, shortcuts, children, platform, labels, className }: ShortcutSheetProps) {\n const words = { ...defaultShortcutSheetLabels, ...labels };\n const ids = useId();\n const groups = groupShortcuts(shortcuts);\n return (\n <Dialog\n open={open}\n onClose={onClose}\n title={words.title}\n labels={{ close: words.close }}\n className={className === undefined ? \"pb-shortcut-sheet\" : `pb-shortcut-sheet ${className}`}\n >\n {groups.length === 0 && <p className=\"pb-shortcut-sheet-empty\">{words.empty}</p>}\n {groups.map(({ group, lines }, index) => {\n const headingId = `${ids}-${index}`;\n return (\n <section key={group} className=\"pb-shortcut-sheet-group\" aria-labelledby={headingId}>\n <h3 id={headingId} className=\"pb-shortcut-sheet-heading\">\n {group}\n </h3>\n <dl className=\"pb-shortcut-sheet-list\">\n {lines.map((line, at) => {\n const keys = typeof line.keys === \"string\" ? [line.keys] : line.keys;\n return (\n <div key={`${line.label}-${at}`} className=\"pb-shortcut-sheet-line\">\n <dt>{line.label}</dt>\n <dd aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}>\n {keys.map((one, n) => (\n <Fragment key={one}>\n {n > 0 && <span className=\"pb-shortcut-sheet-or\"> {words.or} </span>}\n <kbd>{keyLabel(one, { platform, names: words.keyNames })}</kbd>\n </Fragment>\n ))}\n </dd>\n </div>\n );\n })}\n </dl>\n </section>\n );\n })}\n {children !== undefined && <div className=\"pb-shortcut-sheet-note\">{children}</div>}\n </Dialog>\n );\n}\n","// Status words: a short row of states, each a word in its tone (a pane's \"3 errors · 1 warning · saved\"), in the order\n// the app gives, which is most urgent first. The row is one polite live region, so a screen reader reads a change\n// when it is free. A tone it does not know is drawn neutrally.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./StatusWords.css\";\n\n/** The tones a word draws; any other string is drawn neutrally. */\nexport type StatusWordTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type StatusWord = {\n tone: StatusWordTone;\n /** The state in words. */\n label: string;\n /** Shown on hover: what the state means or why it is so. */\n title?: string;\n};\n\nexport type StatusWordsProps = Omit<ComponentPropsWithRef<\"ul\">, \"children\"> & {\n /** The states, most urgent first; drawn in this order. */\n items: readonly StatusWord[];\n};\n\nexport function StatusWords({ items, className, ...rest }: StatusWordsProps) {\n return (\n <ul\n aria-live=\"polite\"\n {...rest}\n className={className === undefined ? \"pb-status-words\" : `pb-status-words ${className}`}\n >\n {items.map((item, index) => (\n <li key={`${String(index)}:${item.label}`} className=\"pb-status-word\" data-tone={item.tone} title={item.title}>\n {item.label}\n </li>\n ))}\n </ul>\n );\n}\n","// A stack of toasts: short news that comes and goes (a refused edit, a lost connection, a saved file), each in its\n// tone, with an optional action and a Dismiss button. The queue is the app's (useToasts holds one): the toaster draws\n// the toasts it is given and says when the person dismisses one or holds the stack by hovering over or focusing in it.\n// Its news is said through two live regions that are there before any toast is (a region added with its words is not\n// reliably read): a toast's words, and its count, are put into the alert region for an err toast and the status\n// region for every other when it first shows and when its count goes up, without its buttons; the toasts themselves\n// are not live, so nothing is read twice. Escape on a focused toast dismisses it, and the focus moves to the toast\n// beside it, or back to where it came from when none is left.\nimport { type ComponentPropsWithRef, type ReactNode, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ToastAction, ToastTone } from \"../../hooks\";\nimport { Button } from \"../../primitives\";\nimport \"./Toaster.css\";\n\n/** Where the stack sits; any other string is drawn inline. */\nexport type ToasterPlacement =\n \"top-start\" | \"top\" | \"top-end\" | \"bottom-start\" | \"bottom\" | \"bottom-end\" | \"inline\" | (string & {});\n\n/** A toast as the toaster draws it; useToasts' toasts are these. */\nexport type ToasterToast = {\n id: number;\n tone: ToastTone;\n text: ReactNode;\n /** How many times it was shown, coalesced; above 1 it shows \"×n\". */\n count?: number;\n action?: ToastAction;\n};\n\nexport type ToasterProps = Omit<ComponentPropsWithRef<\"section\">, \"children\"> & {\n /** The toasts shown, oldest first. */\n toasts: readonly ToasterToast[];\n /** How many older toasts are folded away, shown as \"and n more\". */\n more?: number;\n /** The person dismissed a toast (its button, its action, or Escape on it). */\n onDismiss: (id: number) => void;\n /** True while the person hovers over or is focused in the toasts, so the app holds their expiry. */\n onHold?: (held: boolean) => void;\n /**\n * A corner or edge of the nearest positioned container (\"bottom-end\" by default; start and end follow the text's\n * direction), or \"inline\": in the flow, where the app put it (in a canvas's own panel).\n */\n placement?: ToasterPlacement;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ToasterLabels>;\n};\n\n/** The toaster's own words, each replaceable. */\nexport interface ToasterLabels {\n /** The stack's region name: \"Notifications\". An `aria-label` the app gives wins. */\n region: string;\n /** The words on each Dismiss button: \"Dismiss\". */\n dismiss: string;\n /** The words for the folded toasts: \"and n more\". */\n more: (more: number) => ReactNode;\n /** What a screen reader reads for a count in place of \"×n\": \"n times\". */\n count: (count: number) => string;\n}\n\nexport const defaultToasterLabels: ToasterLabels = {\n region: \"Notifications\",\n dismiss: \"Dismiss\",\n more: (more) => `and ${more} more`,\n count: (count) => `${count} times`,\n};\n\nconst placements = new Set([\"top-start\", \"top\", \"top-end\", \"bottom-start\", \"bottom\", \"bottom-end\", \"inline\"]);\n\n/** News put into a live region: a toast's words, and its count, when it first shows or its count goes up. */\ntype Said = { seq: number; id: number; alert: boolean; text: ReactNode; count: number };\n\n/** How many ids the toaster remembers having said, beyond those shown, before it forgets the rest. */\nconst heardLimit = 256;\n\nexport function Toaster({\n toasts,\n more = 0,\n onDismiss,\n onHold,\n placement = \"bottom-end\",\n labels,\n className,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...rest\n}: ToasterProps) {\n const words = { ...defaultToasterLabels, ...labels };\n const ids = useId();\n const drawn = placements.has(placement) ? placement : \"inline\";\n const top = drawn.startsWith(\"top\");\n // Nearest the edge is newest: at the top the newest comes first, in the reading order as on screen.\n const ordered = top ? [...toasts].reverse() : toasts;\n const empty = toasts.length === 0 && more <= 0;\n\n // What has been said, by id and count, so a toast is said once when it shows and again only when its count goes up\n // (not when it unfolds from \"and n more\" or the list is drawn again).\n const heard = useRef(new Map<number, number>());\n const sequence = useRef(0);\n const [said, setSaid] = useState<readonly Said[]>([]);\n useEffect(() => {\n const news: Said[] = [];\n for (const toast of toasts) {\n const count = toast.count ?? 1;\n const before = heard.current.get(toast.id);\n if (before !== undefined && count <= before) continue;\n heard.current.set(toast.id, count);\n sequence.current += 1;\n news.push({ seq: sequence.current, id: toast.id, alert: toast.tone === \"err\", text: toast.text, count });\n }\n const shown = new Set(toasts.map((toast) => toast.id));\n if (heard.current.size > heardLimit) {\n for (const id of heard.current.keys()) if (!shown.has(id)) heard.current.delete(id);\n }\n // A toast gone is no longer news: its words go (taking words away is not read), so a toast that comes back from\n // \"and n more\" is not said again. Set from an effect on purpose: the words must reach the regions in a commit\n // after the regions are there, or a toaster mounted with a toast would add a region with its words at once.\n const fresh = new Set(news.map((one) => one.id));\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setSaid((all) => {\n const kept = all.filter((one) => shown.has(one.id) && !fresh.has(one.id));\n return news.length === 0 && kept.length === all.length ? all : [...kept, ...news];\n });\n }, [toasts]);\n // Filtered here too, so a dismissed toast's words go in the same render as the toast.\n const shownIds = new Set(toasts.map((toast) => toast.id));\n const say = (alert: boolean) =>\n said\n .filter((one) => shownIds.has(one.id))\n .filter((one) => one.alert === alert)\n .map((one) => (\n <p key={one.seq}>\n {one.text}\n {one.count > 1 && `, ${words.count(one.count)}`}\n </p>\n ));\n const regions = (\n <div className=\"pb-toaster-announce\">\n <div role=\"status\">{say(false)}</div>\n <div role=\"alert\">{say(true)}</div>\n </div>\n );\n\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n // A toast taken away under the pointer or the focus fires no leave or blur; with none left, the hold is let go.\n if (empty && (hovered || focused)) {\n setHovered(false);\n setFocused(false);\n }\n const held = hovered || focused;\n const latestHold = useRef(onHold);\n useLayoutEffect(() => {\n latestHold.current = onHold;\n });\n useLayoutEffect(() => {\n latestHold.current?.(held);\n }, [held]);\n useLayoutEffect(\n () => () => {\n latestHold.current?.(false);\n },\n [],\n );\n\n const list = useRef<HTMLOListElement>(null);\n // Where the focus came from into the toasts, so it goes back there when the last focused toast is dismissed.\n const cameFrom = useRef<HTMLElement | null>(null);\n // After a dismissal that held the focus: the toast to focus next, or null to send it back.\n const focusNext = useRef<number | null | undefined>(undefined);\n useLayoutEffect(() => {\n const next = focusNext.current;\n if (next === undefined) return;\n focusNext.current = undefined;\n // The toast beside the dismissed one, else any still shown (one unfolded from \"and n more\"), else back.\n const item =\n (next === null ? null : list.current?.querySelector<HTMLElement>(`[data-toast-id=\"${next}\"]`)) ??\n list.current?.querySelector<HTMLElement>(\".pb-toast\");\n if (item !== null && item !== undefined) {\n item.focus();\n return;\n }\n const back = cameFrom.current;\n cameFrom.current = null;\n if (back?.isConnected === true) back.focus();\n });\n\n const dismiss = (id: number) => {\n if (list.current?.contains(document.activeElement) === true) {\n const at = ordered.findIndex((toast) => toast.id === id);\n focusNext.current = (ordered[at + 1] ?? ordered[at - 1])?.id ?? null;\n }\n onDismiss(id);\n };\n\n if (empty) return regions;\n\n const moreLine = more > 0 && <p className=\"pb-toaster-more\">{words.more(more)}</p>;\n return (\n <>\n {regions}\n <section\n {...rest}\n aria-label={rest[\"aria-label\"] ?? words.region}\n className={className === undefined ? \"pb-toaster\" : `pb-toaster ${className}`}\n data-placement={drawn}\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n if (event.pointerType !== \"touch\") setHovered(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n const from = event.relatedTarget;\n if (!focused && from instanceof HTMLElement && !event.currentTarget.contains(from)) cameFrom.current = from;\n setFocused(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n }}\n >\n {!top && moreLine}\n <ol className=\"pb-toaster-list\" ref={list}>\n {ordered.map((toast) => {\n const textId = `${ids}-${toast.id}`;\n const count = toast.count ?? 1;\n return (\n <li\n key={toast.id}\n className=\"pb-toast\"\n data-tone={toast.tone}\n data-toast-id={toast.id}\n tabIndex={-1}\n onKeyDown={(event) => {\n // Escape here is the toast's alone, so a sheet or dialog behind it does not also close.\n if (event.key !== \"Escape\" || event.defaultPrevented) return;\n event.preventDefault();\n event.stopPropagation();\n dismiss(toast.id);\n }}\n >\n <div className=\"pb-toast-text\" id={textId}>\n {toast.text}\n {count > 1 && (\n <span className=\"pb-toast-count\">\n <span aria-hidden=\"true\"> ×{count}</span>\n <span className=\"pb-toast-hidden\">, {words.count(count)}</span>\n </span>\n )}\n </div>\n <div className=\"pb-toast-actions\">\n {toast.action !== undefined && (\n <Button\n size=\"sm\"\n onClick={() => {\n toast.action?.run();\n dismiss(toast.id);\n }}\n >\n {toast.action.label}\n </Button>\n )}\n <Button\n size=\"sm\"\n aria-describedby={textId}\n onClick={() => {\n dismiss(toast.id);\n }}\n >\n {words.dismiss}\n </Button>\n </div>\n </li>\n );\n })}\n </ol>\n {top && moreLine}\n </section>\n </>\n );\n}\n"],"mappings":";;;;;;AAiBA,IAAaG,IAAoC,EAC/C,SAAS,UACX;AAeA,SAAgBC,EAAO,EAAE,SAAM,aAAU,YAAS,cAA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C;GACC,CAAA;GACHR,KAAOyB;EACD;CACT,CAAA,CAAA,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"composites.js","names":["Fragment","_Fragment","Fragment$1","defaultBannerLabels","Banner","rest","words","labels","mounted","setMounted","useState","alert","tone","className","children","actions","onDismiss","IconButton","CloseGlyph","defaultChangeListLabels","count","reason","changeWord","change","Row","wordsId","useId","Badge","onDrop","Button","ChangeList","countId","changes","CodeRuns","runs","run","index","shownText","text","lineStarts","starts","at","shown","caretAt","offset","line","offsetAt","start","end","column","markLevel","severity","rank","worse","a","b","markRange","diagnostic","lineStart","lineEnd","codeRuns","classes","classAt","span","spans","name","levels","markAt","diagnostics","level","from","mark","gutterRows","rows","row","knoblyLoad","knoblyReady","loadKnobly","module","error","useHighlighter","wantsKnobly","highlight","language","loaded","setLoaded","useEffect","live","found","defaultCodeEditorLabels","code","message","none","outdentOf","indent","width","spaces","tabEdit","multiLine","out","caret","last","to","lines","changed","insert","delta","browserEdit","CodeEditor","describedBy","area","useRef","layer","gutter","escaped","pending","lastCaret","said","highlighter","value","useMemo","follow","box","reportCaret","onCaret","key","report","useLayoutEffect","onMoved","wanted","edit","next","onChange","onKeyDown","event","wasEscaped","readOnly","goTo","description","describedByAll","id","digits","lineNumbers","element","ref","onBlur","onScroll","onSelect","CodeText","wordStart","before","here","fold","lower","unit","startBonus","wordBonus","nextBonus","gapCost","gapCostMost","lateCost","matchSubsequence","squeezed","query","n","m","bonus","best","j","back","letter","i","own","previous","k","joined","score","indices","rankCommands","groups","match","command","group","order","byScore","sorted","items","markRuns","marked","label","isMarked","defaultCommandPaletteLabels","PALETTE_WIDTH","PALETTE_HEIGHT","PALETTE_GUTTER","placePalette","window","height","clamp","room","size","fallbackPage","useWindowSize","read","setSize","watch","onResize","OpenPalette","ids","listId","setQuery","commands","flat","item","enabled","chosen","setChosen","queried","setQueried","active","optionId","field","list","onCloseRef","onClose","owned","now","option","pageSize","modified","move","windowSize","placed","anchored","body","headingId","keys","selected","ariaKeyShortcuts","platform","part","keyLabel","one","CommandPalette","open","createPortal","defaultDiagnosticListLabels","DiagnosticList","editor","onGo","diffLineKind","baseName","path","all","DiffBody","DiffView","base","ownCollapsed","setOwnCollapsed","folded","collapsed","Heading","toggle","was","other","onToggle","files","diff","file","bodyId","Glyph","defaultShortcutSheetLabels","groupShortcuts","shortcuts","ShortcutSheet","Dialog","StatusWords","defaultToasterLabels","more","placements","heardLimit","Toaster","drawn","placement","top","ordered","toasts","empty","heard","sequence","setSaid","news","toast","fresh","kept","shownIds","say","regions","hovered","setHovered","focused","setFocused","held","latestHold","onHold","cameFrom","focusNext","dismiss","moreLine","Fragment","onPointerEnter","onPointerLeave","textId"],"sources":["../src/composites/banner/Banner.tsx","../src/composites/change-list/ChangeList.tsx","../src/composites/code-editor/CodeRuns.tsx","../src/composites/code-editor/highlight.ts","../src/composites/code-editor/CodeEditor.tsx","../src/composites/code-editor/CodeText.tsx","../src/composites/command-palette/rank.ts","../src/composites/command-palette/CommandPalette.tsx","../src/composites/diagnostic-list/DiagnosticList.tsx","../src/composites/diff-view/DiffView.tsx","../src/composites/shortcut-sheet/ShortcutSheet.tsx","../src/composites/status-words/StatusWords.tsx","../src/composites/toaster/Toaster.tsx"],"sourcesContent":["// A banner: a line of news across the top of a pane or page (a conflict, a lost connection, a refused edit), drawn in\n// its tone, with the app's actions at its end and, if the app lets it go, a close button. Its words are read through\n// two hidden live regions inside it, there before the words (docs/ux-rules.md#feedback, U42): an error's in the alert,\n// read at once, every other tone's in the status, read when the reader is free. A tone it does not know is drawn\n// neutrally.\nimport { type ComponentPropsWithRef, type ReactNode, useEffect, useState } from \"react\";\nimport { CloseGlyph, IconButton } from \"../../primitives\";\nimport \"./Banner.css\";\n\n/** The tones a banner draws; any other string is drawn neutrally. */\nexport type BannerTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | \"accent\" | \"muted\" | (string & {});\n\n/** The banner's own words, each replaceable. */\nexport interface BannerLabels {\n /** The close button's name: \"Dismiss\". */\n dismiss: string;\n}\n\nexport const defaultBannerLabels: BannerLabels = {\n dismiss: \"Dismiss\",\n};\n\nexport type BannerProps = Omit<ComponentPropsWithRef<\"div\">, \"role\"> & {\n /** What the news is, by colour: the stripe's, and the surface's for warn and err. */\n tone: BannerTone;\n /** The news, in words. */\n children: ReactNode;\n /** A slot at the end: the buttons that act on the news. */\n actions?: ReactNode;\n /** Shows a close button, which asks the app to take the banner away. */\n onDismiss?: () => void;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<BannerLabels>;\n};\n\nexport function Banner({ tone, children, actions, onDismiss, labels, className, ...rest }: BannerProps) {\n const words = { ...defaultBannerLabels, ...labels };\n // The regions are drawn empty in the banner's first commit and take its words in the next, so a banner mounted with\n // its words is read; after that its words follow its children and its tone (a tone that turns to err moves them to\n // the alert, which reads them at once).\n const [mounted, setMounted] = useState(false);\n useEffect(() => {\n // Set from an effect on purpose: the words must reach the regions in a commit after the regions are there.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setMounted(true);\n }, []);\n const alert = tone === \"err\";\n return (\n <div {...rest} className={className === undefined ? \"pb-banner\" : `pb-banner ${className}`} data-tone={tone}>\n <div className=\"pb-banner-announce\">\n <div role=\"status\">{mounted && !alert && children}</div>\n <div role=\"alert\">{mounted && alert && children}</div>\n </div>\n <div className=\"pb-banner-text\">{children}</div>\n {actions !== undefined && <div className=\"pb-banner-actions\">{actions}</div>}\n {onDismiss !== undefined && (\n <IconButton className=\"pb-banner-dismiss\" size=\"sm\" label={words.dismiss} onClick={onDismiss}>\n <CloseGlyph />\n </IconButton>\n )}\n </div>\n );\n}\n","// The queued changes in words (docs/components.md#queued-changes): a count in a status line there from the start, a slot\n// for the app's Check, Save and Discard, and one row per change, its change Badge, its words, the reason when a check\n// refused it, and a Drop button (docs/ux-rules.md#confirmation-and-undo, U50). The queue, and keeping only its net\n// change, are the app's: the list draws the changes it is given, in order, and asks to drop one.\nimport { type ComponentPropsWithRef, type ReactNode, useId } from \"react\";\nimport { Badge, Button } from \"../../primitives\";\nimport \"./ChangeList.css\";\n\n/** What a queued change does; any other word is drawn neutrally, by itself. */\nexport type ChangeKind = \"added\" | \"removed\" | \"renamed\" | \"changed\" | (string & {});\n\n/** One queued change. */\nexport type QueuedChange = {\n /** The app's id for the change, passed to `onDrop`. */\n id: string;\n /** What it does: its Badge's tone and word. */\n change: ChangeKind;\n /** What it changes, in the app's words (\"mix-2\", \"Tone 1: left → mix-2: in\"). */\n label: ReactNode;\n /** A second, quieter line: what changes (\"gain 0.8 → 1.2\", \"was tone 1\"). */\n detail?: ReactNode;\n /** Why a check refused it, in words; the row is marked until the queue changes. */\n refused?: string;\n};\n\n/** The list's own words, each replaceable. */\nexport interface ChangeListLabels {\n /** The Badge's word for each change it knows: \"added\", \"removed\", \"renamed\", \"changed\". */\n added: string;\n removed: string;\n renamed: string;\n changed: string;\n /** The count: \"No changes\", \"1 change\", \"3 changes\". */\n count: (count: number) => string;\n /** Each row's drop button: \"Drop\". It is described by the row's words, so several read apart. */\n drop: string;\n /** A refused row's reason: \"Refused: \" and the reason. */\n refused: (reason: string) => string;\n}\n\nexport const defaultChangeListLabels: ChangeListLabels = {\n added: \"added\",\n removed: \"removed\",\n renamed: \"renamed\",\n changed: \"changed\",\n count: (count) => (count === 0 ? \"No changes\" : count === 1 ? \"1 change\" : `${String(count)} changes`),\n drop: \"Drop\",\n refused: (reason) => `Refused: ${reason}`,\n};\n\nexport type ChangeListProps = Omit<ComponentPropsWithRef<\"section\">, \"children\"> & {\n /** The queued changes, in the order the app holds them (the newest last). */\n changes: readonly QueuedChange[];\n /** Asked for by a row's drop button, with its change's id. Without it, the rows have no drop button. */\n onDrop?: (id: string) => void;\n /** Slot at the header's far end: the app's Check, Save and Discard. */\n actions?: ReactNode;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ChangeListLabels>;\n};\n\n/** The Badge's word: the list's own for a change it knows, and the change itself for one it does not. */\nfunction changeWord(change: ChangeKind, words: ChangeListLabels): string {\n switch (change) {\n case \"added\":\n return words.added;\n case \"removed\":\n return words.removed;\n case \"renamed\":\n return words.renamed;\n case \"changed\":\n return words.changed;\n default:\n return change;\n }\n}\n\nfunction Row({\n change,\n onDrop,\n words,\n}: {\n change: QueuedChange;\n onDrop: ((id: string) => void) | undefined;\n words: ChangeListLabels;\n}) {\n const wordsId = useId();\n return (\n <li\n className=\"pb-change-row\"\n data-change={change.change}\n data-refused={change.refused === undefined ? undefined : \"\"}\n >\n <Badge tone={change.change}>{changeWord(change.change, words)}</Badge>\n <div className=\"pb-change-words\" id={wordsId}>\n <div className=\"pb-change-label\">{change.label}</div>\n {change.detail !== undefined && change.detail !== null && (\n <div className=\"pb-change-detail\">{change.detail}</div>\n )}\n {change.refused !== undefined && <div className=\"pb-change-refused\">{words.refused(change.refused)}</div>}\n </div>\n {onDrop !== undefined && (\n <Button\n size=\"sm\"\n className=\"pb-change-drop\"\n aria-describedby={wordsId}\n onClick={() => {\n onDrop(change.id);\n }}\n >\n {words.drop}\n </Button>\n )}\n </li>\n );\n}\n\n/** Lists the queued changes in words, each with its Badge and a drop button, under their count and the app's actions. */\nexport function ChangeList({ changes, onDrop, actions, labels, className, ...rest }: ChangeListProps) {\n const words = { ...defaultChangeListLabels, ...labels };\n const countId = useId();\n return (\n <section\n {...rest}\n aria-labelledby={rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] === undefined ? countId : undefined)}\n className={className === undefined ? \"pb-change-list\" : `pb-change-list ${className}`}\n data-empty={changes.length === 0 ? \"\" : undefined}\n >\n <div className=\"pb-change-head\">\n <p className=\"pb-change-count\" id={countId} role=\"status\">\n {words.count(changes.length)}\n </p>\n {actions !== undefined && <div className=\"pb-change-actions\">{actions}</div>}\n </div>\n {changes.length > 0 && (\n <ul className=\"pb-change-rows\">\n {changes.map((change) => (\n <Row key={change.id} change={change} onDrop={onDrop} words={words} />\n ))}\n </ul>\n )}\n </section>\n );\n}\n","// The runs of highlighted text both code views draw: a span per run with a class or a mark, plain text otherwise.\n// Internal to the code views; not exported from the layer.\nimport type { CodeRun } from \"./highlight\";\nimport \"./CodeRuns.css\";\n\nexport function CodeRuns({ runs }: { runs: readonly CodeRun[] }) {\n return runs.map((run, index) =>\n run.class === \"\" && run.mark === undefined ? (\n run.text\n ) : (\n <span key={index} className=\"pb-code-run\" data-class={run.class || undefined} data-mark={run.mark}>\n {run.text}\n </span>\n ),\n );\n}\n","// The code views' text, pure: the text as a textarea shows it, cut into runs by a highlighter's spans and the\n// diagnostics' marks, the gutter's rows, and lines and columns to offsets and back. It also loads knobly's highlighter,\n// the one language built in, from the optional knobly peer, only when a view asks for it.\nimport { useEffect, useState } from \"react\";\n\n/** A highlighter's span: offsets into the shown text (`end` exclusive) and its class. */\nexport type CodeSpan = {\n readonly start: number;\n readonly end: number;\n /**\n * How it is drawn: \"directive\", \"keyword\", \"word\", \"variable\", \"number\", \"string\", \"comment\", \"punctuation\" or\n * \"error\" have a colour each; \"space\", \"\" and any other class are drawn as plain text.\n */\n readonly class: string;\n};\n\n/** A highlighter: the text, as shown (LF line breaks), to its spans. Pure and total. */\nexport type Highlighter = (text: string) => readonly CodeSpan[];\n\n/** A language built in: \"knobly\"; any other is drawn as plain text unless a highlighter is given. */\nexport type CodeLanguage = \"knobly\" | (string & {});\n\n/** How bad a diagnostic is: \"error\" and \"warning\" have their own mark; any other is drawn neutrally. */\nexport type CodeSeverity = \"error\" | \"warning\" | (string & {});\n\n/** Something the app found in the text: a line (from 1) and an optional column (from 1, in UTF-16 code units). */\nexport type CodeDiagnostic = {\n line: number;\n column?: number;\n severity: CodeSeverity;\n message: string;\n /** The app's own code for it, read with the message. */\n code?: string;\n};\n\n/** Where the caret is: a line and a column, both from 1, and its offset into the shown text. */\nexport type CodeCaret = { line: number; column: number; offset: number };\n\n/** The mark a severity draws. */\nexport type CodeMarkLevel = \"error\" | \"warning\" | \"other\";\n\n/** One run of shown text, drawn in one class with at most one mark. */\nexport type CodeRun = { text: string; class: string; mark?: CodeMarkLevel };\n\n/** One gutter row per shown line, with its diagnostics in the order given. */\nexport type CodeGutterRow = {\n line: number;\n mark?: CodeMarkLevel;\n /** Where a press on its mark puts the caret: the first diagnostic's column, else 1. */\n column: number;\n diagnostics: CodeDiagnostic[];\n};\n\n/**\n * The text as a textarea shows it: a textarea holds LF line breaks only, so CRLF and a lone CR are drawn as LF. The\n * value itself is never changed.\n */\nexport function shownText(text: string): string {\n return text.replace(/\\r\\n?/g, \"\\n\");\n}\n\n/** Where each line of shown text starts. \"\" is one line, and a last newline starts an empty one after it. */\nexport function lineStarts(shown: string): number[] {\n const starts = [0];\n for (let at = shown.indexOf(\"\\n\"); at !== -1; at = shown.indexOf(\"\\n\", at + 1)) starts.push(at + 1);\n return starts;\n}\n\n/** The caret at an offset into the shown text, clamped to the text. */\nexport function caretAt(shown: string, offset: number): CodeCaret {\n const at = Math.min(shown.length, Math.max(0, Math.trunc(offset)));\n const starts = lineStarts(shown);\n let line = 0;\n while (line + 1 < starts.length && (starts[line + 1] ?? Infinity) <= at) line += 1;\n return { line: line + 1, column: at - (starts[line] ?? 0) + 1, offset: at };\n}\n\n/** The offset of a line and column (both from 1) into the shown text, each clamped to the text. */\nexport function offsetAt(shown: string, line: number, column = 1): number {\n const starts = lineStarts(shown);\n const index = Math.min(starts.length, Math.max(1, Math.trunc(line))) - 1;\n const start = starts[index] ?? 0;\n const end = index + 1 < starts.length ? (starts[index + 1] ?? 0) - 1 : shown.length;\n return Math.min(end, start + Math.max(1, Math.trunc(column)) - 1);\n}\n\n/** The mark a severity draws: error, warning, or a neutral one for any other. */\nexport function markLevel(severity: string): CodeMarkLevel {\n return severity === \"error\" ? \"error\" : severity === \"warning\" ? \"warning\" : \"other\";\n}\n\nconst rank: Record<CodeMarkLevel, number> = { other: 1, warning: 2, error: 3 };\n\nfunction worse(a: CodeMarkLevel | undefined, b: CodeMarkLevel): CodeMarkLevel {\n return a !== undefined && rank[a] >= rank[b] ? a : b;\n}\n\n/** A diagnostic's mark in the shown text: from its column to the word's end, or the line's text without a column. */\nexport function markRange(shown: string, diagnostic: CodeDiagnostic): { start: number; end: number } {\n const starts = lineStarts(shown);\n const index = Math.min(starts.length, Math.max(1, Math.trunc(diagnostic.line))) - 1;\n const lineStart = starts[index] ?? 0;\n const lineEnd = index + 1 < starts.length ? (starts[index + 1] ?? 0) - 1 : shown.length;\n if (diagnostic.column === undefined) {\n let start = lineStart;\n let end = lineEnd;\n while (start < end && /\\s/.test(shown[start] ?? \"\")) start += 1;\n while (end > start && /\\s/.test(shown[end - 1] ?? \"\")) end -= 1;\n return { start, end };\n }\n const start = offsetAt(shown, index + 1, diagnostic.column);\n let end = start;\n while (end < lineEnd && !/\\s/.test(shown[end] ?? \"\")) end += 1;\n // A column on white space marks that one character; one past the line's end marks nothing.\n if (end === start && start < lineEnd) end = start + 1;\n return { start, end };\n}\n\n/**\n * The shown text cut into runs by the spans (clipped to the text, empty ones ignored; where two overlap, the later\n * one wins) and the diagnostics' marks (where two overlap, error over warning over any other). Joined, the runs are\n * the shown text exactly.\n */\nexport function codeRuns(\n shown: string,\n spans: readonly CodeSpan[] = [],\n diagnostics: readonly CodeDiagnostic[] = [],\n): CodeRun[] {\n const classes = [\"\"];\n const classAt = new Uint16Array(shown.length);\n for (const span of spans) {\n const start = Math.max(0, Math.trunc(span.start));\n const end = Math.min(shown.length, Math.trunc(span.end));\n if (!(end > start)) continue;\n const name = span.class === \"space\" ? \"\" : span.class;\n let index = classes.indexOf(name);\n if (index === -1) index = classes.push(name) - 1;\n classAt.fill(index, start, end);\n }\n const levels: (CodeMarkLevel | undefined)[] = [undefined, \"other\", \"warning\", \"error\"];\n const markAt = new Uint8Array(shown.length);\n for (const diagnostic of diagnostics) {\n const { start, end } = markRange(shown, diagnostic);\n const level = rank[markLevel(diagnostic.severity)];\n for (let at = start; at < end; at += 1) markAt[at] = Math.max(markAt[at] ?? 0, level);\n }\n const runs: CodeRun[] = [];\n let from = 0;\n for (let at = 1; at <= shown.length; at += 1) {\n if (at < shown.length && classAt[at] === classAt[from] && markAt[at] === markAt[from]) continue;\n const mark = levels[markAt[from] ?? 0];\n const run: CodeRun = { text: shown.slice(from, at), class: classes[classAt[from] ?? 0] ?? \"\" };\n if (mark !== undefined) run.mark = mark;\n runs.push(run);\n from = at;\n }\n return runs;\n}\n\n/** One row per shown line; a diagnostic's line is clamped to the text, so one past the end marks the last line. */\nexport function gutterRows(shown: string, diagnostics: readonly CodeDiagnostic[] = []): CodeGutterRow[] {\n const count = lineStarts(shown).length;\n const rows = Array.from({ length: count }, (_, index): CodeGutterRow => ({\n line: index + 1,\n column: 1,\n diagnostics: [],\n }));\n for (const diagnostic of diagnostics) {\n const row = rows[Math.min(count, Math.max(1, Math.trunc(diagnostic.line))) - 1];\n if (row === undefined) continue;\n if (row.diagnostics.length === 0) row.column = diagnostic.column ?? 1;\n row.diagnostics.push(diagnostic);\n row.mark = worse(row.mark, markLevel(diagnostic.severity));\n }\n return rows;\n}\n\nlet knoblyLoad: Promise<Highlighter | null> | undefined;\nlet knoblyReady: Highlighter | null | undefined;\n\n/**\n * Loads knobly's highlighter from the optional knobly peer, once for the page; null when knobly is not installed (the\n * view then draws plain text, and says so once on the console).\n */\nexport function loadKnobly(): Promise<Highlighter | null> {\n knoblyLoad ??= import(\"knobly/highlight\").then(\n (module): Highlighter => (knoblyReady = module.highlight),\n (error: unknown) => {\n console.warn('patchbay: language \"knobly\" needs the knobly package; drawing plain text.', error);\n knoblyReady = null;\n return null;\n },\n );\n return knoblyLoad;\n}\n\n/**\n * The highlighter a view draws with: the app's `highlight` when given, else knobly's for language \"knobly\" (once\n * loaded; plain text until then), else none.\n */\nexport function useHighlighter(language: CodeLanguage | undefined, highlight: Highlighter | undefined) {\n const wantsKnobly = highlight === undefined && language === \"knobly\";\n // Kept in a box: React would call a function given to useState or its setter.\n const [loaded, setLoaded] = useState<{ highlight: Highlighter | null } | undefined>(undefined);\n useEffect(() => {\n if (!wantsKnobly || knoblyReady !== undefined) return;\n let live = true;\n void loadKnobly().then((found) => {\n if (live) setLoaded({ highlight: found });\n });\n return () => {\n live = false;\n };\n }, [wantsKnobly]);\n if (highlight !== undefined) return highlight;\n return wantsKnobly ? (knoblyReady ?? loaded?.highlight ?? undefined) : undefined;\n}\n","// A text editor for configuration text: a native textarea holds the text, the caret, the selection and every edit; a\n// highlighted copy of what it shows is drawn behind it (its glyphs transparent over the copy's) and follows its scroll.\n// A gutter beside the box numbers the lines and marks those a diagnostic names; a press on a mark puts the caret\n// there. Tab indents and Shift+Tab outdents; Escape, then Tab or Shift+Tab, moves the focus on as usual, so the\n// keyboard can always leave. The diagnostics, and how to leave, are read as the textarea's description.\nimport {\n type ComponentPropsWithRef,\n type CSSProperties,\n type KeyboardEvent,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { CodeRuns } from \"./CodeRuns\";\nimport {\n type CodeCaret,\n type CodeDiagnostic,\n type CodeLanguage,\n caretAt,\n codeRuns,\n gutterRows,\n type Highlighter,\n offsetAt,\n shownText,\n useHighlighter,\n} from \"./highlight\";\nimport \"./CodeEditor.css\";\n\n/** The editor's own words, each replaceable. */\nexport interface CodeEditorLabels {\n /** How a diagnostic is read, and shown over its gutter mark: \"Line 3, column 5: error E1: message\". */\n diagnostic: (diagnostic: CodeDiagnostic) => string;\n /** Read after the editor's name while it can be edited: how Tab works and how to leave. */\n tabKey: string;\n}\n\nexport const defaultCodeEditorLabels: CodeEditorLabels = {\n diagnostic: ({ line, column, severity, code, message }) =>\n `Line ${String(line)}${column === undefined ? \"\" : `, column ${String(column)}`}: ${severity}${\n code === undefined || code === \"\" ? \"\" : ` ${code}`\n }: ${message}`,\n tabKey: \"Tab indents. Press Escape, then Tab, to move on.\",\n};\n\nexport type CodeEditorProps = Omit<ComponentPropsWithRef<\"textarea\">, \"value\" | \"defaultValue\" | \"onChange\"> & {\n /** The text. CRLF and a lone CR are shown as LF, and an edit gives the text back with LF. */\n value: string;\n /** The person changed the text: the textarea's whole new value. */\n onChange?: (value: string) => void;\n /** A language built in (\"knobly\"); any other draws plain text. `highlight` wins over it. */\n language?: CodeLanguage;\n /** The app's highlighter, from the shown text to its spans. */\n highlight?: Highlighter;\n /** What the app found in the text, marked in the gutter and under the text, and read with the editor. */\n diagnostics?: readonly CodeDiagnostic[];\n /** The caret moved (by a key, a press, an edit or a gutter mark): its line, column and offset. */\n onCaret?: (caret: CodeCaret) => void;\n /** Show the line-number gutter (true by default). */\n lineNumbers?: boolean;\n /** What Tab inserts, and Shift+Tab takes away from a line's start: a tab by default. */\n indent?: string;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<CodeEditorLabels>;\n};\n\nconst none: readonly CodeDiagnostic[] = [];\n\ntype Pending = { value: string; start: number; end: number };\n\n/** How many leading characters of a line one outdent takes away. */\nfunction outdentOf(line: string, indent: string): number {\n if (indent !== \"\" && line.startsWith(indent)) return indent.length;\n if (line.startsWith(\"\\t\")) return 1;\n const width = indent === \"\\t\" || indent === \"\" ? 4 : indent.length;\n let spaces = 0;\n while (spaces < width && line[spaces] === \" \") spaces += 1;\n return spaces;\n}\n\n/**\n * What Tab (or Shift+Tab, `out`) does to a text and its selection: the range it replaces, with what, and the\n * selection after. Tab in one line replaces the selection with the indent; across lines, and Shift+Tab always, it\n * indents or outdents each line the selection touches (empty lines are left alone when indenting). Undefined when\n * nothing would change.\n */\nexport function tabEdit(\n text: string,\n start: number,\n end: number,\n indent: string,\n out: boolean,\n): { from: number; to: number; insert: string; start: number; end: number } | undefined {\n const multiLine = text.slice(start, end).includes(\"\\n\");\n if (!out && !multiLine) {\n if (indent === \"\") return undefined;\n const caret = start + indent.length;\n return { from: start, to: end, insert: indent, start: caret, end: caret };\n }\n const from = text.lastIndexOf(\"\\n\", start - 1) + 1;\n // A selection that ends at a line's start does not take that line.\n const last = end > start && text[end - 1] === \"\\n\" ? end - 1 : end;\n const lineEnd = text.indexOf(\"\\n\", last);\n const to = lineEnd === -1 ? text.length : lineEnd;\n const lines = text.slice(from, to).split(\"\\n\");\n const changed = lines.map((line) => (out ? line.slice(outdentOf(line, indent)) : line === \"\" ? line : indent + line));\n const insert = changed.join(\"\\n\");\n if (insert === text.slice(from, to)) return undefined;\n if (start === end) {\n // A caret moves with its line's text, never before the line's start.\n const delta = (changed[0] ?? \"\").length - (lines[0] ?? \"\").length;\n const caret = Math.max(from, start + delta);\n return { from, to, insert, start: caret, end: caret };\n }\n return { from, to, insert, start: from, end: from + insert.length };\n}\n\n/**\n * Replaces a textarea's selection through the browser's own editing, which keeps its undo history, so Ctrl+Z takes an\n * indent back as it does a typed character. execCommand is deprecated, but no other API edits a textarea within its\n * undo history; false where the browser has none (or refuses), and the edit is then made by value.\n */\nfunction browserEdit(insert: string): boolean {\n const run = (document as { execCommand?: (command: string, ui: boolean, value?: string) => boolean }).execCommand;\n if (typeof run !== \"function\") return false;\n return insert === \"\" ? run.call(document, \"delete\", false) : run.call(document, \"insertText\", false, insert);\n}\n\nexport function CodeEditor({\n value,\n onChange,\n language,\n highlight,\n diagnostics = none,\n onCaret,\n lineNumbers = true,\n indent = \"\\t\",\n labels,\n readOnly = false,\n className,\n style,\n ref,\n onKeyDown,\n onBlur,\n onScroll,\n onSelect,\n \"aria-describedby\": describedBy,\n ...rest\n}: CodeEditorProps) {\n const words = { ...defaultCodeEditorLabels, ...labels };\n const area = useRef<HTMLTextAreaElement | null>(null);\n const layer = useRef<HTMLPreElement>(null);\n const gutter = useRef<HTMLPreElement>(null);\n const escaped = useRef(false);\n const pending = useRef<Pending | null>(null);\n const lastCaret = useRef<string>(\"\");\n const said = useId();\n const highlighter = useHighlighter(language, highlight);\n\n const shown = shownText(value);\n const runs = useMemo(() => codeRuns(shown, highlighter?.(shown), diagnostics), [shown, highlighter, diagnostics]);\n const rows = useMemo(() => gutterRows(shown, diagnostics), [shown, diagnostics]);\n\n const follow = () => {\n const box = area.current;\n if (box === null) return;\n if (layer.current !== null) {\n layer.current.scrollTop = box.scrollTop;\n layer.current.scrollLeft = box.scrollLeft;\n }\n if (gutter.current !== null) gutter.current.scrollTop = box.scrollTop;\n };\n\n const reportCaret = () => {\n const box = area.current;\n if (box === null || onCaret === undefined) return;\n const offset = box.selectionDirection === \"backward\" ? box.selectionStart : box.selectionEnd;\n const caret = caretAt(box.value, offset);\n const key = `${String(caret.line)}:${String(caret.column)}:${String(caret.offset)}`;\n if (key === lastCaret.current) return;\n lastCaret.current = key;\n onCaret(caret);\n };\n\n // A caret moved by code with no key or press of the person's (a DiagnosticList row, the app's own setSelectionRange)\n // reaches React's onSelect in no browser alike, so the textarea's own selectionchange, and the select event that\n // setSelectionRange queues, report it too; a place already reported is not reported again.\n const report = useRef(reportCaret);\n useLayoutEffect(() => {\n report.current = reportCaret;\n });\n useEffect(() => {\n const box = area.current;\n if (box === null) return;\n const onMoved = () => {\n if (document.activeElement === box) report.current();\n };\n box.addEventListener(\"selectionchange\", onMoved);\n box.addEventListener(\"select\", onMoved);\n return () => {\n box.removeEventListener(\"selectionchange\", onMoved);\n box.removeEventListener(\"select\", onMoved);\n };\n }, []);\n\n // After a render (an edit, a new text), put the copy and the gutter where the textarea is scrolled, and the\n // selection where an edit made without the browser's own editing left it.\n useLayoutEffect(() => {\n const box = area.current;\n const wanted = pending.current;\n pending.current = null;\n if (box !== null && wanted !== null && box.value === wanted.value) {\n box.setSelectionRange(wanted.start, wanted.end);\n reportCaret();\n }\n follow();\n });\n\n const edit = (box: HTMLTextAreaElement, change: NonNullable<ReturnType<typeof tabEdit>>) => {\n box.setSelectionRange(change.from, change.to);\n const done = browserEdit(change.insert);\n if (done) {\n box.setSelectionRange(change.start, change.end);\n reportCaret();\n return;\n }\n const next = box.value.slice(0, change.from) + change.insert + box.value.slice(change.to);\n pending.current = { value: next, start: change.start, end: change.end };\n onChange?.(next);\n };\n\n const key = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\") {\n escaped.current = true;\n return;\n }\n if (event.key !== \"Tab\") {\n if (event.key !== \"Shift\") escaped.current = false;\n return;\n }\n const wasEscaped = escaped.current;\n escaped.current = false;\n if (wasEscaped || readOnly || event.ctrlKey || event.altKey || event.metaKey || event.nativeEvent.isComposing) {\n return;\n }\n event.preventDefault();\n const box = event.currentTarget;\n const change = tabEdit(box.value, box.selectionStart, box.selectionEnd, indent, event.shiftKey);\n if (change !== undefined) edit(box, change);\n };\n\n const goTo = (line: number, column: number) => {\n const box = area.current;\n if (box === null) return;\n const offset = offsetAt(box.value, line, column);\n box.focus();\n box.setSelectionRange(offset, offset);\n reportCaret();\n };\n\n const description = [\n ...(readOnly ? [] : [words.tabKey]),\n ...diagnostics.map((diagnostic) => words.diagnostic(diagnostic)),\n ];\n const describedByAll =\n [describedBy, description.length > 0 ? said : undefined].filter((id) => id !== undefined && id !== \"\").join(\" \") ||\n undefined;\n const digits = String(rows.length).length;\n\n return (\n <div\n className={className === undefined ? \"pb-code-editor\" : `pb-code-editor ${className}`}\n style={style}\n data-readonly={readOnly || undefined}\n >\n {lineNumbers ? (\n <pre\n ref={gutter}\n className=\"pb-code-gutter\"\n aria-hidden=\"true\"\n style={{ \"--pb-code-gutter-digits\": digits } as CSSProperties}\n >\n <code className=\"pb-code-gutter-code\">\n {rows.map((row) => (\n <span key={row.line} className=\"pb-code-gutter-row\">\n {row.line}\n <span\n className=\"pb-code-gutter-mark\"\n data-mark={row.mark}\n title={\n row.diagnostics.length === 0\n ? undefined\n : row.diagnostics.map((diagnostic) => words.diagnostic(diagnostic)).join(\"\\n\")\n }\n onClick={\n row.mark === undefined\n ? undefined\n : () => {\n goTo(row.line, row.column);\n }\n }\n />\n {\"\\n\"}\n </span>\n ))}\n </code>\n </pre>\n ) : null}\n <div className=\"pb-code-box\">\n <pre ref={layer} className=\"pb-code-layer\" aria-hidden=\"true\">\n <code className=\"pb-code-layer-code\">\n <CodeRuns runs={runs} />\n {/* A last empty line keeps its height, as the textarea gives it. */}\n {\"\\n\"}\n </code>\n </pre>\n <textarea\n spellCheck={false}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n wrap=\"off\"\n {...rest}\n ref={(element) => {\n area.current = element;\n if (typeof ref === \"function\") return ref(element);\n if (ref) ref.current = element;\n return undefined;\n }}\n className=\"pb-code-input\"\n value={value}\n readOnly={readOnly}\n aria-describedby={describedByAll}\n onChange={(event) => onChange?.(event.target.value)}\n onKeyDown={key}\n onBlur={(event) => {\n escaped.current = false;\n onBlur?.(event);\n }}\n onScroll={(event) => {\n follow();\n onScroll?.(event);\n }}\n onSelect={(event) => {\n reportCaret();\n onSelect?.(event);\n }}\n />\n </div>\n {description.length > 0 ? (\n <div id={said} hidden>\n {description.map((line, index) => (\n <p key={index}>{line}</p>\n ))}\n </div>\n ) : null}\n </div>\n );\n}\n","// Read-only highlighted code: the text in code type on the read-only code surface, highlighted by knobly's highlighter\n// (language \"knobly\", loaded from the optional knobly peer) or the app's own. Long lines scroll sideways; the box is a\n// tab stop, so it scrolls from the keyboard too.\nimport { type ComponentPropsWithRef, useMemo } from \"react\";\nimport { CodeRuns } from \"./CodeRuns\";\nimport { type CodeLanguage, codeRuns, type Highlighter, shownText, useHighlighter } from \"./highlight\";\nimport \"./CodeText.css\";\n\nexport type CodeTextProps = Omit<ComponentPropsWithRef<\"pre\">, \"children\"> & {\n /** The text; CRLF and a lone CR are drawn as LF. */\n value: string;\n /** A language built in (\"knobly\"); any other draws plain text. `highlight` wins over it. */\n language?: CodeLanguage;\n /** The app's highlighter, from the shown text to its spans. */\n highlight?: Highlighter;\n};\n\nexport function CodeText({ value, language, highlight, className, ...rest }: CodeTextProps) {\n const highlighter = useHighlighter(language, highlight);\n const runs = useMemo(() => {\n const shown = shownText(value);\n return codeRuns(shown, highlighter?.(shown));\n }, [value, highlighter]);\n return (\n <pre tabIndex={0} {...rest} className={className === undefined ? \"pb-code-text\" : `pb-code-text ${className}`}>\n <code className=\"pb-code-text-code\">\n <CodeRuns runs={runs} />\n </code>\n </pre>\n );\n}\n","// The command palette's ranking (docs/components.md#commands-and-keys): a query matches a label when its letters appear\n// in the label in order, in any case, not necessarily together (\"adn\" matches \"Add a node\"). Of the ways the letters\n// can be found, the best is kept: letters at the start of a word and letters next to each other score more, gaps and\n// a late start score less. Pure, so the palette and an app's tests share it.\n\n/** Where a query's letters fell in a label, and how good the match is. */\nexport type SubsequenceMatch = {\n /** The indices (UTF-16 code units) of the label's matched characters, ascending. */\n indices: number[];\n /** Higher is better; an empty query scores 0. */\n score: number;\n};\n\n/** A word starts at the label's start, after a character that is not a letter or digit, or at a capital after a small letter. */\nfunction wordStart(text: string, at: number): boolean {\n if (at === 0) return true;\n const before = text.charAt(at - 1);\n const here = text.charAt(at);\n if (!/[\\p{L}\\p{N}]/u.test(before)) return true;\n return before !== before.toUpperCase() && here !== here.toLowerCase() && here === here.toUpperCase();\n}\n\n/** A code unit in lower case, unless lowering it makes more than one (\"İ\"), which is then compared as it is. */\nfunction fold(unit: string): string {\n const lower = unit.toLowerCase();\n return lower.length === 1 ? lower : unit;\n}\n\nconst startBonus = 3;\nconst wordBonus = 2;\nconst nextBonus = 2;\nconst gapCost = 0.1;\nconst gapCostMost = 1;\nconst lateCost = 0.02;\n\n/**\n * Finds the query's letters in the text, in order and in any case (white space in the query is ignored), the best\n * way it can; undefined when they are not all there.\n */\nexport function matchSubsequence(text: string, query: string): SubsequenceMatch | undefined {\n const squeezed = query.replace(/\\s+/g, \"\");\n if (squeezed === \"\") return { indices: [], score: 0 };\n // Compared one UTF-16 code unit at a time, each folded the same way, so an index is a place in the label.\n const wanted = Array.from({ length: squeezed.length }, (_, at) => fold(squeezed.charAt(at)));\n const lower = Array.from({ length: text.length }, (_, at) => fold(text.charAt(at)));\n const n = text.length;\n const m = wanted.length;\n if (m > n) return undefined;\n const bonus = lower.map((_, at) => (at === 0 ? startBonus : wordStart(text, at) ? wordBonus : 0));\n // best[j][i]: the best score with the query's letter j at the text's index i; from[j][i]: where letter j-1 was.\n const best: number[][] = [];\n const from: number[][] = [];\n for (let j = 0; j < m; j += 1) {\n const row = new Array<number>(n).fill(-Infinity);\n const back = new Array<number>(n).fill(-1);\n const letter = wanted[j];\n for (let i = j; i < n; i += 1) {\n if (lower[i] !== letter) continue;\n const own = 1 + (bonus[i] ?? 0);\n if (j === 0) {\n row[i] = own - i * lateCost;\n continue;\n }\n const previous = best[j - 1] ?? [];\n for (let k = j - 1; k < i; k += 1) {\n const before = previous[k] ?? -Infinity;\n if (before === -Infinity) continue;\n const joined = k === i - 1 ? nextBonus : -Math.min((i - k - 1) * gapCost, gapCostMost);\n const score = before + own + joined;\n if (score > (row[i] ?? -Infinity)) {\n row[i] = score;\n back[i] = k;\n }\n }\n }\n best.push(row);\n from.push(back);\n }\n const last = best[m - 1] ?? [];\n let end = -1;\n for (let i = 0; i < n; i += 1) if ((last[i] ?? -Infinity) > (end < 0 ? -Infinity : (last[end] ?? -Infinity))) end = i;\n if (end < 0 || last[end] === -Infinity) return undefined;\n const indices: number[] = [];\n for (let j = m - 1, at = end; j >= 0; j -= 1) {\n indices.unshift(at);\n at = from[j]?.[at] ?? -1;\n }\n return { indices, score: last[end] ?? 0 };\n}\n\n/** What ranking needs of a command. */\nexport type Rankable = { label: string; group: string };\n\n/** A command that matched, with where its letters fell. */\nexport type RankedCommand<C extends Rankable> = { command: C; indices: number[]; score: number };\n\n/** One group's matching commands. */\nexport type RankedGroup<C extends Rankable> = { group: string; items: RankedCommand<C>[] };\n\n/**\n * The commands whose labels match the query, in groups. With an empty query every command is kept, in the order given\n * and its groups in the order they first appear; with one, each group's commands go best first and the groups by\n * their best command, ties kept in the order given. Groups with no match are left out.\n */\nexport function rankCommands<C extends Rankable>(commands: readonly C[], query: string): RankedGroup<C>[] {\n const groups = new Map<string, { first: number; items: (RankedCommand<C> & { order: number })[] }>();\n commands.forEach((command, order) => {\n const match = matchSubsequence(command.label, query);\n if (match === undefined) return;\n let group = groups.get(command.group);\n if (group === undefined) {\n group = { first: order, items: [] };\n groups.set(command.group, group);\n }\n group.items.push({ command, indices: match.indices, score: match.score, order });\n });\n const byScore = (a: { score: number; order: number }, b: { score: number; order: number }) =>\n b.score - a.score || a.order - b.order;\n return [...groups.entries()]\n .map(([group, { first, items }]) => {\n const sorted = [...items].sort(byScore);\n return { group, first, items: sorted, top: sorted[0]?.score ?? 0 };\n })\n .sort((a, b) => b.top - a.top || a.first - b.first)\n .map(({ group, items }) => ({\n group,\n items: items.map(({ command, indices, score }) => ({ command, indices, score })),\n }));\n}\n\n/** The label cut into runs, each marked or not, so the matched letters can be drawn in <mark>. */\nexport function markRuns(label: string, indices: readonly number[]): { text: string; marked: boolean }[] {\n const marked = new Set(indices);\n const runs: { text: string; marked: boolean }[] = [];\n for (let at = 0; at < label.length; at += 1) {\n const isMarked = marked.has(at);\n const last = runs[runs.length - 1];\n if (last !== undefined && last.marked === isMarked) last.text += label.charAt(at);\n else runs.push({ text: label.charAt(at), marked: isMarked });\n }\n return runs;\n}\n","// A command palette (docs/components.md#commands-and-keys): a search field over a list of the app's commands, drawn in a\n// portal on <body>, centred near the top of the window or anchored at a point and kept inside it. Typing ranks the\n// commands by their labels (rank.ts), the matched letters in <mark>; the arrows, Page Up and Page Down, Home and End\n// move the active command and Enter runs it. The field is a combobox and the list a listbox, so the focus stays in the\n// field the whole time. Escape, Tab, a press outside and the focus leaving ask the app to close it; closing gives the\n// focus back to what had it before.\nimport {\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { markRuns, rankCommands } from \"./rank\";\nimport \"./CommandPalette.css\";\n\n/** One command in the palette. */\nexport type Command = {\n /** Unique among the commands; the active command is kept by it while the list changes. */\n id: string;\n /** What the command is called; the query is matched against it. */\n label: string;\n /** The heading it is listed under; groups are shown in the order they first appear. */\n group: string;\n /** Its key string, or several, shown through keyLabel (\"Mod+K\"); the palette does not bind them. */\n keys?: string | readonly string[];\n /** A second, quieter line: what it does, or what it acts on. Not matched. */\n hint?: string;\n /** Runs the command; the palette asks to close first. */\n run: () => void;\n /** Shown but skipped by the keys, and does nothing when pressed. */\n disabled?: boolean;\n};\n\n/** A point in the window's coordinates (client px), such as where a press happened. */\nexport type PalettePoint = { x: number; y: number };\n\nexport type CommandPaletteProps = {\n /** Whether the palette is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, Tab, a press outside, the focus leaving, and before a command runs. */\n onClose: () => void;\n commands: readonly Command[];\n /** Anchors the palette's top-left corner at this point, kept inside the window; centred near the top without it. */\n at?: PalettePoint;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<CommandPaletteLabels>;\n /** A class added to the palette's box. */\n className?: string;\n};\n\n/** The palette's own words, each replaceable. */\nexport interface CommandPaletteLabels {\n /** The palette's name for screen readers: \"Commands\". */\n palette: string;\n /** The field's placeholder: \"Type a command\". */\n placeholder: string;\n /** Shown when there are no commands at all: \"No commands\". */\n empty: ReactNode;\n /** Shown when the query matches none: \"No command matches “query”\". */\n noMatch: (query: string) => ReactNode;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"); none by default, keyLabel's own. */\n keyNames: Readonly<Record<string, string>>;\n}\n\nexport const defaultCommandPaletteLabels: CommandPaletteLabels = {\n palette: \"Commands\",\n placeholder: \"Type a command\",\n empty: \"No commands\",\n noMatch: (query) => `No command matches “${query}”`,\n keyNames: {},\n};\n\n/** The anchored palette's size, held inside the window less the gutter. */\nexport const PALETTE_WIDTH = 320;\nexport const PALETTE_HEIGHT = 360;\n/** How far the anchored palette stays from the window's edges. */\nexport const PALETTE_GUTTER = 8;\n\n/**\n * Where an anchored palette goes: its top-left corner at the point, moved back inside the window (less the gutter)\n * where it would cross an edge, and made smaller when the window is smaller than the palette. The height is the\n * most it may take; a short list takes less.\n */\nexport function placePalette(\n at: PalettePoint,\n window: { width: number; height: number },\n): { left: number; top: number; width: number; height: number } {\n const width = Math.max(0, Math.min(PALETTE_WIDTH, window.width - 2 * PALETTE_GUTTER));\n const height = Math.max(0, Math.min(PALETTE_HEIGHT, window.height - 2 * PALETTE_GUTTER));\n const clamp = (value: number, size: number, room: number) =>\n Math.min(Math.max(value, PALETTE_GUTTER), Math.max(PALETTE_GUTTER, room - size - PALETTE_GUTTER));\n return { left: clamp(at.x, width, window.width), top: clamp(at.y, height, window.height), width, height };\n}\n\n/** How many rows Page Up and Page Down move when the list's rows cannot be measured. */\nconst fallbackPage = 8;\n\nfunction useWindowSize(watch: boolean) {\n const read = () => ({ width: window.innerWidth, height: window.innerHeight });\n const [size, setSize] = useState(read);\n useEffect(() => {\n if (!watch) return undefined;\n const onResize = () => {\n setSize(read());\n };\n window.addEventListener(\"resize\", onResize);\n return () => {\n window.removeEventListener(\"resize\", onResize);\n };\n }, [watch]);\n return size;\n}\n\nfunction OpenPalette({ onClose, commands, at, platform, labels, className }: Omit<CommandPaletteProps, \"open\">) {\n const words = { ...defaultCommandPaletteLabels, ...labels };\n const ids = useId();\n const listId = `${ids}-list`;\n const [query, setQuery] = useState(\"\");\n const groups = useMemo(() => rankCommands(commands, query), [commands, query]);\n const flat = useMemo(() => groups.flatMap((group) => group.items.map((item) => item.command)), [groups]);\n const enabled = useMemo(() => flat.filter((command) => command.disabled !== true), [flat]);\n\n // The active command, by id; when it is gone (filtered out, disabled) the first enabled one takes its place.\n const [chosen, setChosen] = useState<string | undefined>(undefined);\n const [queried, setQueried] = useState(query);\n if (queried !== query) {\n setQueried(query);\n setChosen(undefined);\n }\n const active = enabled.find((command) => command.id === chosen) ?? enabled[0];\n const optionId = (command: Command) => `${ids}-option-${flat.indexOf(command)}`;\n\n const box = useRef<HTMLDivElement>(null);\n const field = useRef<HTMLInputElement>(null);\n const list = useRef<HTMLDivElement>(null);\n const onCloseRef = useRef(onClose);\n useLayoutEffect(() => {\n onCloseRef.current = onClose;\n });\n\n // Focus the field on opening; give the focus back on closing, unless it already went somewhere else on purpose.\n useLayoutEffect(() => {\n const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n field.current?.focus();\n const owned = box.current;\n return () => {\n const now = document.activeElement;\n const lost = now === null || now === document.body || (owned?.contains(now) ?? false) || !now.isConnected;\n if (lost && before?.isConnected === true) before.focus();\n };\n }, []);\n\n useEffect(() => {\n if (active === undefined) return;\n const option = document.getElementById(optionId(active));\n // jsdom has no scrollIntoView.\n if (typeof option?.scrollIntoView === \"function\") option.scrollIntoView({ block: \"nearest\" });\n // optionId reads the list, which changes with active.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active]);\n\n const run = (command: Command) => {\n if (command.disabled === true) return;\n onCloseRef.current();\n command.run();\n };\n\n const pageSize = () => {\n // A resting row: the active one is written out whole, so it may be taller.\n const option =\n list.current?.querySelector<HTMLElement>('[role=\"option\"]:not([aria-selected=\"true\"])') ??\n list.current?.querySelector<HTMLElement>('[role=\"option\"]');\n const rows =\n option && option.offsetHeight > 0 ? Math.floor((list.current?.clientHeight ?? 0) / option.offsetHeight) : 0;\n return Math.max(1, rows || fallbackPage);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n const modified = event.altKey || event.ctrlKey || event.metaKey;\n const at = active === undefined ? -1 : enabled.indexOf(active);\n const last = enabled.length - 1;\n const move = (to: number) => {\n event.preventDefault();\n const next = enabled[Math.min(Math.max(to, 0), last)];\n if (next !== undefined) setChosen(next.id);\n };\n switch (event.key) {\n case \"Escape\":\n event.preventDefault();\n event.stopPropagation();\n onCloseRef.current();\n return;\n case \"Tab\":\n // A combobox's popup closes on Tab; the focus goes back to where it came from.\n event.preventDefault();\n onCloseRef.current();\n return;\n case \"Enter\":\n if (modified) return;\n event.preventDefault();\n if (active !== undefined) run(active);\n return;\n case \"ArrowDown\":\n if (modified) return;\n move(at >= last ? 0 : at + 1);\n return;\n case \"ArrowUp\":\n if (modified) return;\n move(at <= 0 ? last : at - 1);\n return;\n case \"PageDown\":\n if (modified) return;\n move(at + pageSize());\n return;\n case \"PageUp\":\n if (modified) return;\n move(at - pageSize());\n return;\n case \"Home\":\n // Shift+Home and Shift+End stay with the field, to select its text.\n if (modified || event.shiftKey) return;\n move(0);\n return;\n case \"End\":\n if (modified || event.shiftKey) return;\n move(last);\n return;\n default:\n return;\n }\n };\n\n const windowSize = useWindowSize(at !== undefined);\n const placed = at === undefined ? undefined : placePalette(at, windowSize);\n const anchored = placed !== undefined;\n\n let body: ReactNode;\n if (commands.length === 0) body = words.empty;\n else if (flat.length === 0) body = words.noMatch(query.trim());\n\n return (\n <div\n className=\"pb-palette-layer\"\n data-anchored={anchored ? \"\" : undefined}\n onMouseDown={(event) => {\n // Only a press that starts outside the palette.\n if (event.target === event.currentTarget) onCloseRef.current();\n }}\n >\n <div\n ref={box}\n className={className === undefined ? \"pb-palette\" : `pb-palette ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={words.palette}\n style={\n placed === undefined\n ? undefined\n : { position: \"fixed\", left: placed.left, top: placed.top, width: placed.width, maxHeight: placed.height }\n }\n onBlur={(event) => {\n const to = event.relatedTarget;\n if (to instanceof Node && !event.currentTarget.contains(to)) onCloseRef.current();\n }}\n >\n <input\n ref={field}\n className=\"pb-palette-field\"\n type=\"text\"\n role=\"combobox\"\n aria-label={words.palette}\n aria-expanded=\"true\"\n aria-controls={listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={active === undefined ? undefined : optionId(active)}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n placeholder={words.placeholder}\n value={query}\n onChange={(event) => {\n setQuery(event.target.value);\n }}\n onKeyDown={onKeyDown}\n />\n <div\n ref={list}\n className=\"pb-palette-list\"\n id={listId}\n role=\"listbox\"\n aria-label={words.palette}\n hidden={flat.length === 0}\n >\n {groups.map((group, index) => {\n const headingId = `${ids}-group-${index}`;\n return (\n <div key={group.group} role=\"group\" aria-labelledby={headingId} className=\"pb-palette-group\">\n <div id={headingId} className=\"pb-palette-heading\" role=\"presentation\">\n {group.group}\n </div>\n {group.items.map(({ command, indices }) => {\n const id = optionId(command);\n const keys =\n command.keys === undefined ? [] : typeof command.keys === \"string\" ? [command.keys] : command.keys;\n const selected = command === active;\n return (\n <div\n key={command.id}\n id={id}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={command.disabled === true ? true : undefined}\n aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}\n className=\"pb-palette-option\"\n data-command-id={command.id}\n onMouseDown={(event) => {\n // Keep the focus in the field.\n event.preventDefault();\n }}\n onPointerMove={() => {\n if (command.disabled !== true && !selected) setChosen(command.id);\n }}\n onClick={() => {\n run(command);\n }}\n >\n <span className=\"pb-palette-text\">\n <span className=\"pb-palette-label\">\n {markRuns(command.label, indices).map((part, at) =>\n part.marked ? <mark key={at}>{part.text}</mark> : part.text,\n )}\n </span>\n {command.hint !== undefined && <span className=\"pb-palette-hint\">{command.hint}</span>}\n </span>\n {keys.length > 0 && (\n <span className=\"pb-palette-keys\">\n {keys.map((one) => (\n <kbd key={one}>{keyLabel(one, { platform, names: words.keyNames })}</kbd>\n ))}\n </span>\n )}\n </div>\n );\n })}\n </div>\n );\n })}\n </div>\n {/* There from the start, so a screen reader hears the words when the list empties. */}\n <p className=\"pb-palette-empty\" role=\"status\">\n {body}\n </p>\n </div>\n </div>\n );\n}\n\nexport function CommandPalette({ open, ...rest }: CommandPaletteProps) {\n if (!open) return null;\n return createPortal(<OpenPalette {...rest} />, document.body);\n}\n","// The diagnostics of a CodeEditor listed in words under it (docs/components.md#code, DiagnosticList): each row a\n// button that puts the editor's caret at the diagnostic's place, so what a gutter mark's tooltip says is also written\n// out where touch and the keyboard reach it (docs/ux-rules.md#feedback, U47). It shares CodeEditor's diagnostic type\n// and its words for one (labels.diagnostic), and marks each row by its severity as the gutter does. A count, in a\n// status line there from the start, says how many there are. Where it sits beside the editor is the app's layout.\nimport { type ComponentPropsWithRef, type RefObject, useId } from \"react\";\nimport { type CodeDiagnostic, defaultCodeEditorLabels, markLevel, offsetAt } from \"../code-editor\";\nimport \"./DiagnosticList.css\";\n\n/** The list's own words, each replaceable. */\nexport interface DiagnosticListLabels {\n /** How a diagnostic is shown and read, CodeEditor's own: \"Line 3, column 5: error E1: message\". */\n diagnostic: (diagnostic: CodeDiagnostic) => string;\n /** The count in the status line: \"No problems\", \"1 problem\", \"3 problems\". */\n count: (count: number) => string;\n}\n\nexport const defaultDiagnosticListLabels: DiagnosticListLabels = {\n diagnostic: defaultCodeEditorLabels.diagnostic,\n count: (count) => (count === 0 ? \"No problems\" : count === 1 ? \"1 problem\" : `${String(count)} problems`),\n};\n\nexport type DiagnosticListProps = Omit<ComponentPropsWithRef<\"div\">, \"children\"> & {\n /** What the app found in the text, as it gives `CodeEditor`, listed in the order given. */\n diagnostics: readonly CodeDiagnostic[];\n /** The editor's textarea (the `ref` given to `CodeEditor`): a row's press focuses it and puts the caret there. */\n editor?: RefObject<HTMLTextAreaElement | null>;\n /** Called after a row's press with its diagnostic, as when the app must first show the editor. */\n onGo?: (diagnostic: CodeDiagnostic) => void;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<DiagnosticListLabels>;\n};\n\n/** Puts the textarea's caret at a diagnostic's line and column, focused, as a press on its gutter mark does. */\nfunction goTo(box: HTMLTextAreaElement, { line, column }: CodeDiagnostic) {\n const offset = offsetAt(box.value, line, column);\n box.focus();\n box.setSelectionRange(offset, offset);\n}\n\n/** Lists an editor's diagnostics in words, each a button to its place, under a count. */\nexport function DiagnosticList({ diagnostics, editor, onGo, labels, className, ...rest }: DiagnosticListProps) {\n const words = { ...defaultDiagnosticListLabels, ...labels };\n const countId = useId();\n return (\n <div\n {...rest}\n className={className === undefined ? \"pb-diagnostic-list\" : `pb-diagnostic-list ${className}`}\n data-empty={diagnostics.length === 0 ? \"\" : undefined}\n >\n <p className=\"pb-diagnostic-count\" id={countId} role=\"status\">\n {words.count(diagnostics.length)}\n </p>\n {diagnostics.length > 0 && (\n <ul className=\"pb-diagnostic-rows\" aria-labelledby={countId}>\n {diagnostics.map((diagnostic, index) => (\n <li key={index} className=\"pb-diagnostic-row\">\n <button\n type=\"button\"\n className=\"pb-diagnostic-go\"\n onClick={() => {\n const box = editor?.current;\n if (box !== null && box !== undefined) goTo(box, diagnostic);\n onGo?.(diagnostic);\n }}\n >\n <span className=\"pb-diagnostic-mark\" data-mark={markLevel(diagnostic.severity)} aria-hidden=\"true\" />\n <span className=\"pb-diagnostic-words\">{words.diagnostic(diagnostic)}</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n","// A diff: unified diff text drawn line by line, added lines in the added tone and removed ones in the removed tone,\n// each keeping its \"+\" or \"-\" so the change never rests on colour alone. Given files, each is a section of its own\n// under a heading, labelled by its file name with its whole path on hover, that the person can fold away.\nimport { useId, useState, type ComponentPropsWithRef } from \"react\";\nimport { Glyph } from \"../../primitives\";\nimport \"./DiffView.css\";\n\nexport type DiffFile = {\n /** The file's path; the section is labelled by its last part. Unique among the files. */\n path: string;\n /** The file's unified diff text. */\n diff: string;\n};\n\n/** What a line of unified diff text is, by its start. */\nexport type DiffLineKind = \"add\" | \"del\" | \"hunk\" | \"meta\" | \"note\" | \"context\";\n\ntype DiffSource =\n | {\n /** One unified diff, drawn whole without a heading. */\n diff: string;\n files?: never;\n }\n | {\n /** One section per file, in this order. */\n files: readonly DiffFile[];\n diff?: never;\n };\n\nexport type DiffViewProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onToggle\"> &\n DiffSource & {\n /** The files' headings' level, h2 to h6 (h3 by default). */\n level?: 2 | 3 | 4 | 5 | 6;\n /**\n * The paths of the files folded away. Given, the app holds them and onToggle asks it to change them; left out,\n * the view keeps its own, every file open at first.\n */\n collapsed?: readonly string[];\n /** Called when the person opens (true) or folds (false) a file's section. */\n onToggle?: (path: string, open: boolean) => void;\n };\n\n/** The kind of one line of unified diff text. */\nexport function diffLineKind(line: string): DiffLineKind {\n if (line.startsWith(\"+++ \") || line.startsWith(\"--- \")) return \"meta\";\n if (line.startsWith(\"@@\")) return \"hunk\";\n if (line.startsWith(\"+\")) return \"add\";\n if (line.startsWith(\"-\")) return \"del\";\n if (line.startsWith(\"\\\\\")) return \"note\";\n if (line === \"\" || line.startsWith(\" \")) return \"context\";\n // A git header line: diff --git, index, new file mode, rename from, similarity index and the like.\n return \"meta\";\n}\n\n/** A path's last part: \"src/app/main.ts\" is \"main.ts\". */\nexport function baseName(path: string): string {\n const parts = path.split(\"/\").filter((part) => part !== \"\");\n return parts.at(-1) ?? path;\n}\n\nfunction lines(text: string): string[] {\n const all = text.split(/\\r?\\n/);\n // A diff ends with a newline, which starts no line of its own.\n if (all.length > 0 && all.at(-1) === \"\") all.pop();\n return all;\n}\n\nfunction DiffBody({ text, id, hidden }: { text: string; id?: string; hidden?: boolean }) {\n return (\n // Focusable, so a wide diff can be scrolled sideways from the keyboard.\n <pre className=\"pb-diff-body\" id={id} hidden={hidden} tabIndex={0}>\n <code className=\"pb-diff-code\">\n {lines(text).map((line, index) => (\n <span key={index} className=\"pb-diff-line\" data-kind={diffLineKind(line)}>\n {line === \"\" ? \" \" : line}\n </span>\n ))}\n </code>\n </pre>\n );\n}\n\nexport function DiffView({ diff, files, level = 3, collapsed, onToggle, className, ...rest }: DiffViewProps) {\n const base = useId();\n const [ownCollapsed, setOwnCollapsed] = useState<readonly string[]>([]);\n const folded = collapsed ?? ownCollapsed;\n const Heading = `h${String(level)}` as \"h3\";\n const toggle = (path: string, open: boolean) => {\n if (collapsed === undefined) {\n setOwnCollapsed((was) => (open ? was.filter((other) => other !== path) : [...was, path]));\n }\n onToggle?.(path, open);\n };\n return (\n <div {...rest} className={className === undefined ? \"pb-diff\" : `pb-diff ${className}`}>\n {files === undefined ? (\n <DiffBody text={diff} />\n ) : (\n files.map((file, index) => {\n const open = !folded.includes(file.path);\n const bodyId = `${base}-${String(index)}`;\n return (\n <div key={file.path} className=\"pb-diff-file\" data-open={open || undefined}>\n <Heading className=\"pb-diff-file-title\">\n <button\n type=\"button\"\n className=\"pb-diff-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n title={file.path}\n onClick={() => {\n toggle(file.path, !open);\n }}\n >\n <Glyph className=\"pb-diff-chevron\">\n <path d=\"M6.5 4.5l3.5 3.5-3.5 3.5\" />\n </Glyph>\n {baseName(file.path)}\n </button>\n </Heading>\n <DiffBody text={file.diff} id={bodyId} hidden={!open} />\n </div>\n );\n })\n )}\n </div>\n );\n}\n","// The keys an app binds, listed in a Dialog (docs/components.md#commands-and-keys): one section per group, in the order\n// the groups first appear, each a list of what a key does and the key as people read it (keyLabel). The sheet draws\n// the list it is given and binds nothing; the app's useShortcuts table is usually where the list comes from.\nimport { type ReactNode, Fragment, useId } from \"react\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { Dialog } from \"../../primitives\";\nimport \"./ShortcutSheet.css\";\n\n/** One line of the sheet. */\nexport type ShortcutLine = {\n /** The key string, or several that do the same (\"Mod+K\", [\"Delete\", \"Backspace\"]). */\n keys: string | readonly string[];\n /** What the key does. */\n label: string;\n /** The heading it is listed under. */\n group: string;\n};\n\nexport type ShortcutSheetProps = {\n /** Whether the sheet is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, the close button and a press on the scrim. */\n onClose: () => void;\n shortcuts: readonly ShortcutLine[];\n /** A note under the lists (where the keys do not act, say). */\n children?: ReactNode;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ShortcutSheetLabels>;\n /** A class added to the dialog's box. */\n className?: string;\n};\n\n/** The sheet's own words, each replaceable. */\nexport interface ShortcutSheetLabels {\n /** The dialog's title, which also names it: \"Keyboard shortcuts\". */\n title: ReactNode;\n /** Between two keys that do the same: \"or\". */\n or: string;\n /** Shown when there are no shortcuts: \"No shortcuts\". */\n empty: ReactNode;\n /** The close button's name: \"Close\". */\n close: string;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"); none by default, keyLabel's own. */\n keyNames: Readonly<Record<string, string>>;\n}\n\nexport const defaultShortcutSheetLabels: ShortcutSheetLabels = {\n title: \"Keyboard shortcuts\",\n or: \"or\",\n empty: \"No shortcuts\",\n close: \"Close\",\n keyNames: {},\n};\n\n/** The lines in groups, the groups in the order they first appear and each group's lines in the order given. */\nexport function groupShortcuts(shortcuts: readonly ShortcutLine[]): { group: string; lines: ShortcutLine[] }[] {\n const groups = new Map<string, ShortcutLine[]>();\n for (const line of shortcuts) {\n const lines = groups.get(line.group);\n if (lines === undefined) groups.set(line.group, [line]);\n else lines.push(line);\n }\n return [...groups.entries()].map(([group, lines]) => ({ group, lines }));\n}\n\nexport function ShortcutSheet({ open, onClose, shortcuts, children, platform, labels, className }: ShortcutSheetProps) {\n const words = { ...defaultShortcutSheetLabels, ...labels };\n const ids = useId();\n const groups = groupShortcuts(shortcuts);\n return (\n <Dialog\n open={open}\n onClose={onClose}\n title={words.title}\n labels={{ close: words.close }}\n className={className === undefined ? \"pb-shortcut-sheet\" : `pb-shortcut-sheet ${className}`}\n >\n {groups.length === 0 && <p className=\"pb-shortcut-sheet-empty\">{words.empty}</p>}\n {groups.map(({ group, lines }, index) => {\n const headingId = `${ids}-${index}`;\n return (\n <section key={group} className=\"pb-shortcut-sheet-group\" aria-labelledby={headingId}>\n <h3 id={headingId} className=\"pb-shortcut-sheet-heading\">\n {group}\n </h3>\n <dl className=\"pb-shortcut-sheet-list\">\n {lines.map((line, at) => {\n const keys = typeof line.keys === \"string\" ? [line.keys] : line.keys;\n return (\n <div key={`${line.label}-${at}`} className=\"pb-shortcut-sheet-line\">\n <dt>{line.label}</dt>\n <dd aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}>\n {keys.map((one, n) => (\n <Fragment key={one}>\n {n > 0 && <span className=\"pb-shortcut-sheet-or\"> {words.or} </span>}\n <kbd>{keyLabel(one, { platform, names: words.keyNames })}</kbd>\n </Fragment>\n ))}\n </dd>\n </div>\n );\n })}\n </dl>\n </section>\n );\n })}\n {children !== undefined && <div className=\"pb-shortcut-sheet-note\">{children}</div>}\n </Dialog>\n );\n}\n","// Status words: a short row of states, each a word in its tone (a pane's \"3 errors · 1 warning · saved\"), in the order\n// the app gives, which is most urgent first. The row is one polite live region, so a screen reader reads a change\n// when it is free. A tone it does not know is drawn neutrally.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./StatusWords.css\";\n\n/** The tones a word draws; any other string is drawn neutrally. */\nexport type StatusWordTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | \"accent\" | \"muted\" | (string & {});\n\nexport type StatusWord = {\n tone: StatusWordTone;\n /** The state in words. */\n label: string;\n /** Shown on hover: what the state means or why it is so. */\n title?: string;\n};\n\nexport type StatusWordsProps = Omit<ComponentPropsWithRef<\"ul\">, \"children\"> & {\n /** The states, most urgent first; drawn in this order. */\n items: readonly StatusWord[];\n};\n\nexport function StatusWords({ items, className, ...rest }: StatusWordsProps) {\n return (\n <ul\n aria-live=\"polite\"\n {...rest}\n className={className === undefined ? \"pb-status-words\" : `pb-status-words ${className}`}\n >\n {items.map((item, index) => (\n <li key={`${String(index)}:${item.label}`} className=\"pb-status-word\" data-tone={item.tone} title={item.title}>\n {item.label}\n </li>\n ))}\n </ul>\n );\n}\n","// A stack of toasts: short news that comes and goes (a refused edit, a lost connection, a saved file), each in its\n// tone, with an optional action and a Dismiss button. The queue is the app's (useToasts holds one): the toaster draws\n// the toasts it is given and says when the person dismisses one or holds the stack by hovering over or focusing in it.\n// Its news is said through two live regions that are there before any toast is (a region added with its words is not\n// reliably read): a toast's words, and its count, are put into the alert region for an err toast and the status\n// region for every other when it first shows and when its count goes up, without its buttons; the toasts themselves\n// are not live, so nothing is read twice. Escape on a focused toast dismisses it, and the focus moves to the toast\n// beside it, or back to where it came from when none is left.\nimport { type ComponentPropsWithRef, type ReactNode, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ToastAction, ToastTone } from \"../../hooks\";\nimport { Button, CloseGlyph, IconButton } from \"../../primitives\";\nimport \"./Toaster.css\";\n\n/** Where the stack sits; any other string is drawn inline. */\nexport type ToasterPlacement =\n \"top-start\" | \"top\" | \"top-end\" | \"bottom-start\" | \"bottom\" | \"bottom-end\" | \"inline\" | (string & {});\n\n/** A toast as the toaster draws it; useToasts' toasts are these. */\nexport type ToasterToast = {\n id: number;\n tone: ToastTone;\n text: ReactNode;\n /** How many times it was shown, coalesced; above 1 it shows \"×n\". */\n count?: number;\n action?: ToastAction;\n};\n\nexport type ToasterProps = Omit<ComponentPropsWithRef<\"section\">, \"children\"> & {\n /** The toasts shown, oldest first. */\n toasts: readonly ToasterToast[];\n /** How many older toasts are folded away, shown as \"and n more\". */\n more?: number;\n /** The person dismissed a toast (its button, its action, or Escape on it). */\n onDismiss: (id: number) => void;\n /** True while the person hovers over or is focused in the toasts, so the app holds their expiry. */\n onHold?: (held: boolean) => void;\n /**\n * A corner or edge of the nearest positioned container (\"bottom-end\" by default; start and end follow the text's\n * direction), or \"inline\": in the flow, where the app put it (in a canvas's own panel).\n */\n placement?: ToasterPlacement;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ToasterLabels>;\n};\n\n/** The toaster's own words, each replaceable. */\nexport interface ToasterLabels {\n /** The stack's region name: \"Notifications\". An `aria-label` the app gives wins. */\n region: string;\n /** The words on each Dismiss button: \"Dismiss\". */\n dismiss: string;\n /** The words for the folded toasts: \"and n more\". */\n more: (more: number) => ReactNode;\n /** What a screen reader reads for a count in place of \"×n\": \"n times\". */\n count: (count: number) => string;\n}\n\nexport const defaultToasterLabels: ToasterLabels = {\n region: \"Notifications\",\n dismiss: \"Dismiss\",\n more: (more) => `and ${more} more`,\n count: (count) => `${count} times`,\n};\n\nconst placements = new Set([\"top-start\", \"top\", \"top-end\", \"bottom-start\", \"bottom\", \"bottom-end\", \"inline\"]);\n\n/** News put into a live region: a toast's words, and its count, when it first shows or its count goes up. */\ntype Said = { seq: number; id: number; alert: boolean; text: ReactNode; count: number };\n\n/** How many ids the toaster remembers having said, beyond those shown, before it forgets the rest. */\nconst heardLimit = 256;\n\nexport function Toaster({\n toasts,\n more = 0,\n onDismiss,\n onHold,\n placement = \"bottom-end\",\n labels,\n className,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...rest\n}: ToasterProps) {\n const words = { ...defaultToasterLabels, ...labels };\n const ids = useId();\n const drawn = placements.has(placement) ? placement : \"inline\";\n const top = drawn.startsWith(\"top\");\n // Nearest the edge is newest: at the top the newest comes first, in the reading order as on screen.\n const ordered = top ? [...toasts].reverse() : toasts;\n const empty = toasts.length === 0 && more <= 0;\n\n // What has been said, by id and count, so a toast is said once when it shows and again only when its count goes up\n // (not when it unfolds from \"and n more\" or the list is drawn again).\n const heard = useRef(new Map<number, number>());\n const sequence = useRef(0);\n const [said, setSaid] = useState<readonly Said[]>([]);\n useEffect(() => {\n const news: Said[] = [];\n for (const toast of toasts) {\n const count = toast.count ?? 1;\n const before = heard.current.get(toast.id);\n if (before !== undefined && count <= before) continue;\n heard.current.set(toast.id, count);\n sequence.current += 1;\n news.push({ seq: sequence.current, id: toast.id, alert: toast.tone === \"err\", text: toast.text, count });\n }\n const shown = new Set(toasts.map((toast) => toast.id));\n if (heard.current.size > heardLimit) {\n for (const id of heard.current.keys()) if (!shown.has(id)) heard.current.delete(id);\n }\n // A toast gone is no longer news: its words go (taking words away is not read), so a toast that comes back from\n // \"and n more\" is not said again. Set from an effect on purpose: the words must reach the regions in a commit\n // after the regions are there, or a toaster mounted with a toast would add a region with its words at once.\n const fresh = new Set(news.map((one) => one.id));\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setSaid((all) => {\n const kept = all.filter((one) => shown.has(one.id) && !fresh.has(one.id));\n return news.length === 0 && kept.length === all.length ? all : [...kept, ...news];\n });\n }, [toasts]);\n // Filtered here too, so a dismissed toast's words go in the same render as the toast.\n const shownIds = new Set(toasts.map((toast) => toast.id));\n const say = (alert: boolean) =>\n said\n .filter((one) => shownIds.has(one.id))\n .filter((one) => one.alert === alert)\n .map((one) => (\n <p key={one.seq}>\n {one.text}\n {one.count > 1 && `, ${words.count(one.count)}`}\n </p>\n ));\n const regions = (\n <div className=\"pb-toaster-announce\">\n <div role=\"status\">{say(false)}</div>\n <div role=\"alert\">{say(true)}</div>\n </div>\n );\n\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n // A toast taken away under the pointer or the focus fires no leave or blur; with none left, the hold is let go.\n if (empty && (hovered || focused)) {\n setHovered(false);\n setFocused(false);\n }\n const held = hovered || focused;\n const latestHold = useRef(onHold);\n useLayoutEffect(() => {\n latestHold.current = onHold;\n });\n useLayoutEffect(() => {\n latestHold.current?.(held);\n }, [held]);\n useLayoutEffect(\n () => () => {\n latestHold.current?.(false);\n },\n [],\n );\n\n const list = useRef<HTMLOListElement>(null);\n // Where the focus came from into the toasts, so it goes back there when the last focused toast is dismissed.\n const cameFrom = useRef<HTMLElement | null>(null);\n // After a dismissal that held the focus: the toast to focus next, or null to send it back.\n const focusNext = useRef<number | null | undefined>(undefined);\n useLayoutEffect(() => {\n const next = focusNext.current;\n if (next === undefined) return;\n focusNext.current = undefined;\n // The toast beside the dismissed one, else any still shown (one unfolded from \"and n more\"), else back.\n const item =\n (next === null ? null : list.current?.querySelector<HTMLElement>(`[data-toast-id=\"${next}\"]`)) ??\n list.current?.querySelector<HTMLElement>(\".pb-toast\");\n if (item !== null && item !== undefined) {\n item.focus();\n return;\n }\n const back = cameFrom.current;\n cameFrom.current = null;\n if (back?.isConnected === true) back.focus();\n });\n\n const dismiss = (id: number) => {\n if (list.current?.contains(document.activeElement) === true) {\n const at = ordered.findIndex((toast) => toast.id === id);\n focusNext.current = (ordered[at + 1] ?? ordered[at - 1])?.id ?? null;\n }\n onDismiss(id);\n };\n\n if (empty) return regions;\n\n const moreLine = more > 0 && <p className=\"pb-toaster-more\">{words.more(more)}</p>;\n return (\n <>\n {regions}\n <section\n {...rest}\n aria-label={rest[\"aria-label\"] ?? words.region}\n className={className === undefined ? \"pb-toaster\" : `pb-toaster ${className}`}\n data-placement={drawn}\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n if (event.pointerType !== \"touch\") setHovered(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n const from = event.relatedTarget;\n if (!focused && from instanceof HTMLElement && !event.currentTarget.contains(from)) cameFrom.current = from;\n setFocused(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n }}\n >\n {!top && moreLine}\n <ol className=\"pb-toaster-list\" ref={list}>\n {ordered.map((toast) => {\n const textId = `${ids}-${toast.id}`;\n const count = toast.count ?? 1;\n return (\n <li\n key={toast.id}\n className=\"pb-toast\"\n data-tone={toast.tone}\n data-toast-id={toast.id}\n tabIndex={-1}\n onKeyDown={(event) => {\n // Escape here is the toast's alone, so a sheet or dialog behind it does not also close.\n // Not a press already handled, nor one inside an input method's composition (U14).\n if (event.key !== \"Escape\" || event.defaultPrevented || event.nativeEvent.isComposing) return;\n event.preventDefault();\n event.stopPropagation();\n dismiss(toast.id);\n }}\n >\n <div className=\"pb-toast-text\" id={textId}>\n {toast.text}\n {count > 1 && (\n <span className=\"pb-toast-count\">\n <span aria-hidden=\"true\"> ×{count}</span>\n <span className=\"pb-toast-hidden\">, {words.count(count)}</span>\n </span>\n )}\n </div>\n <div className=\"pb-toast-actions\">\n {toast.action !== undefined && (\n <Button\n size=\"sm\"\n onClick={() => {\n toast.action?.run();\n dismiss(toast.id);\n }}\n >\n {toast.action.label}\n </Button>\n )}\n <IconButton\n className=\"pb-toast-dismiss\"\n size=\"sm\"\n label={words.dismiss}\n aria-describedby={textId}\n onClick={() => {\n dismiss(toast.id);\n }}\n >\n <CloseGlyph />\n </I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