@particle-academy/react-fancy 6.7.1 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-AE53RKWR.cjs → chunk-CNWTYRZC.cjs} +407 -22
- package/dist/chunk-CNWTYRZC.cjs.map +1 -0
- package/dist/{chunk-B6WTCAGY.js → chunk-PDVU2PXR.js} +97 -53
- package/dist/chunk-PDVU2PXR.js.map +1 -0
- package/dist/{chunk-RLE5WYY6.js → chunk-PIG3UTHU.js} +406 -24
- package/dist/chunk-PIG3UTHU.js.map +1 -0
- package/dist/{chunk-OUNGGQIS.cjs → chunk-VZTXUYPM.cjs} +97 -53
- package/dist/chunk-VZTXUYPM.cjs.map +1 -0
- package/dist/index.cjs +23 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/prompt-input.cjs +4 -4
- package/dist/prompt-input.js +1 -1
- package/dist/qr-code.cjs +19 -4
- package/dist/qr-code.d.cts +221 -2
- package/dist/qr-code.d.ts +221 -2
- package/dist/qr-code.js +4 -1
- package/docs/PromptInput.md +10 -2
- package/docs/QrCode.md +108 -0
- package/package.json +1 -1
- package/dist/chunk-AE53RKWR.cjs.map +0 -1
- package/dist/chunk-B6WTCAGY.js.map +0 -1
- package/dist/chunk-OUNGGQIS.cjs.map +0 -1
- package/dist/chunk-RLE5WYY6.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/PromptInput/prompt-draft.ts","../src/utils/platform.ts","../src/components/PromptInput/PromptInput.tsx"],"names":["markedIds","expandMarkers","forwardRef","PromptInput","useState","useRef","useCallback","useReducer","fileRef","useMemo","useInlinePaste","useEffect","useAcknowledgedSubmit","useLayoutEffect","useImperativeHandle","isImeComposing","jsxs","cn","jsx","Icon","Fragment","InlinePasteEditor","PastedFilesInput","Tooltip","Button","visuallyHidden"],"mappings":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,CAAA,EAAA,CAAA;AACzB,EAAA,IAAI,CAAA,GAAI,OAAO,IAAA,EAAM,OAAO,IAAI,CAAA,GAAI,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACpD,EAAA,OAAO,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACxC","file":"chunk-OUNGGQIS.cjs","sourcesContent":["import { expandMarkers, markedIds, type HeldImage } from \"../PastePills/paste-markers\";\n\n/**\n * A file in a saved draft — an attachment chip, or the image behind an image\n * pill — described by data alone, so the draft survives `JSON.stringify`.\n *\n * The bytes are deliberately NOT in here. A `File` does not survive JSON, and\n * putting base64 in the draft by default would make every saved draft as large\n * as everything attached to it: a 6 MB screenshot becomes 8 MB of string written\n * on every keystroke by a host that saves on change. Instead the host decides\n * where bytes live, through `persistAttachment` (save) and `restoreAttachment`\n * (load), and the draft carries only the host's handle for them in `ref`.\n *\n * A host that WANTS the bytes inline passes `promptFileToDataUrl` as\n * `persistAttachment`, and `ref` is then a `data:` URL.\n */\nexport interface PromptDraftFile {\n /** Stable for the life of the draft. For an image pill, the pill's own id. */\n id: string;\n name: string;\n /** MIME type, `\"\"` when the browser did not know it. */\n type: string;\n bytes: number;\n /**\n * The host's handle for the stored bytes — whatever `persistAttachment`\n * returned: a storage key, an upload URL, a `data:` URL. Absent when the host\n * keeps nothing, in which case a restored attachment has no `File`.\n */\n ref?: string;\n}\n\n/** A paste held as a pill inside the message. Its marker sits in `text`. */\nexport type PromptDraftPill =\n | {\n kind: \"text\";\n id: string;\n text: string;\n /**\n * Shown on the pill in place of `Pasted text · N characters`. Display only:\n * sending still expands the pill to the full `text`. Plain text, flattened\n * to one line and capped at 80 characters when drawn. Optional.\n */\n label?: string;\n }\n | { kind: \"image\"; id: string; label: string; file: PromptDraftFile };\n\n/**\n * Everything a PromptInput holds, as JSON. Versioned, so a draft saved by one\n * release and read by a later one is recognised or refused, never guessed at.\n *\n * `text` is the raw value: with paste pills on, each pill is a marker in it\n * (`pasteMarker(id)`), because the message itself is the record of what is\n * attached and where. Mentions and slash commands are plain text in it.\n */\nexport interface PromptDraft {\n v: 1;\n text: string;\n pills: PromptDraftPill[];\n attachments: PromptDraftFile[];\n}\n\nexport interface PromptSetDraftOptions {\n /**\n * Focus the composer after restoring, caret at the end. Default `false`:\n * restoring a draft never moves focus or anybody's caret on its own\n * (genie#1235 was exactly that).\n */\n focus?: boolean;\n /**\n * With `focus: true`: whether the browser may scroll to reveal the composer.\n * Default `true` (no scrolling): a bare `el.focus()` scrolls EVERY scrollable\n * ancestor up to the document, which scrolled a whole host window\n * (genie#1290). Pass `false` to let it scroll.\n */\n preventScroll?: boolean;\n}\n\n/** Options for `PromptInputHandle.focus()`. Mirrors the DOM's `FocusOptions`. */\nexport interface PromptFocusOptions {\n /**\n * Default `true`: focusing never scrolls the page or any ancestor\n * (genie#1290). Pass `false` to let the browser scroll the composer into view.\n */\n preventScroll?: boolean;\n}\n\n/** The imperative handle a `ref` on `PromptInput` receives. */\nexport interface PromptInputHandle {\n /** The current draft. A fresh JSON-safe copy; mutating it changes nothing. */\n getDraft(): PromptDraft;\n /**\n * Replace the whole draft. Does NOT call `onChange` / `onDraftChange` (the\n * host is the one setting it), does NOT focus unless `{ focus: true }`.\n * A draft whose `v` this release does not know is refused with a warning.\n */\n setDraft(draft: PromptDraft, options?: PromptSetDraftOptions): void;\n /**\n * Focus the composer, caret at the end. Does not scroll anything unless\n * `{ preventScroll: false }`.\n */\n focus(options?: PromptFocusOptions): void;\n}\n\nexport const EMPTY_DRAFT: PromptDraft = { v: 1, text: \"\", pills: [], attachments: [] };\n\nfunction readFile(raw: unknown, id?: string): PromptDraftFile | null {\n if (!raw || typeof raw !== \"object\") return null;\n const f = raw as Record<string, unknown>;\n const fileId = id ?? f.id;\n if (typeof fileId !== \"string\" || typeof f.name !== \"string\") return null;\n const out: PromptDraftFile = {\n id: fileId,\n name: f.name,\n type: typeof f.type === \"string\" ? f.type : \"\",\n bytes: typeof f.bytes === \"number\" && Number.isFinite(f.bytes) ? f.bytes : 0,\n };\n if (typeof f.ref === \"string\") out.ref = f.ref;\n return out;\n}\n\nfunction readPill(raw: unknown): PromptDraftPill | null {\n if (!raw || typeof raw !== \"object\") return null;\n const p = raw as Record<string, unknown>;\n if (typeof p.id !== \"string\") return null;\n if (p.kind === \"text\" && typeof p.text === \"string\") {\n return typeof p.label === \"string\"\n ? { kind: \"text\", id: p.id, text: p.text, label: p.label }\n : { kind: \"text\", id: p.id, text: p.text };\n }\n if (p.kind === \"image\" && typeof p.label === \"string\") {\n const file = readFile(p.file, p.id);\n return file ? { kind: \"image\", id: p.id, label: p.label, file } : null;\n }\n return null;\n}\n\n/**\n * Validate a draft from storage. `null` for anything that is not a v1 draft.\n *\n * `inline` is whether the composer can show pills. Without them (no\n * `pasteThreshold` / `pasteImages`) a pill would surface as raw marker\n * characters, so text pills are expanded in place and image pills become `[label]`\n * in the text plus an ordinary attachment — what the message would have sent.\n */\nexport function readPromptDraft(raw: unknown, inline: boolean): PromptDraft | null {\n if (!raw || typeof raw !== \"object\" || (raw as { v?: unknown }).v !== 1) return null;\n const d = raw as Record<string, unknown>;\n\n let text = typeof d.text === \"string\" ? d.text : \"\";\n let pills = (Array.isArray(d.pills) ? d.pills : [])\n .map(readPill)\n .filter((p): p is PromptDraftPill => p !== null);\n let attachments = (Array.isArray(d.attachments) ? d.attachments : [])\n .map((a) => readFile(a))\n .filter((a): a is PromptDraftFile => a !== null);\n\n // The message is the record: a pill the text no longer marks is not attached.\n const marked = new Set(markedIds(text));\n pills = pills.filter((p) => marked.has(p.id));\n\n if (!inline && pills.length > 0) {\n const texts = pills.flatMap((p) => (p.kind === \"text\" ? [{ id: p.id, text: p.text }] : []));\n const images = pills.flatMap((p) => (p.kind === \"image\" ? [p] : []));\n text = expandMarkers(\n text,\n texts,\n images.map((p) => ({ id: p.id, label: p.label }) as HeldImage),\n );\n attachments = [...attachments, ...images.map((p) => p.file)];\n pills = [];\n }\n\n return { v: 1, text, pills, attachments };\n}\n\n/** A deep, JSON-safe copy, so a host cannot mutate the component's state through it. */\nexport function clonePromptDraft(draft: PromptDraft): PromptDraft {\n return JSON.parse(JSON.stringify(draft)) as PromptDraft;\n}\n\n/** Every file a draft refers to: attachments, then image pills. */\nexport function promptDraftFiles(draft: PromptDraft): PromptDraftFile[] {\n return [\n ...draft.attachments,\n ...draft.pills.flatMap((p) => (p.kind === \"image\" ? [p.file] : [])),\n ];\n}\n\n/**\n * Read a File as a `data:` URL. Pass it as `persistAttachment` to keep the bytes\n * IN the draft — simple, and fine for small files; every saved draft then carries\n * every attached byte, base64-inflated by a third.\n */\nexport function promptFileToDataUrl(file: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(String(reader.result));\n reader.onerror = () => reject(reader.error);\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Turn a `data:` URL back into a File — the other half of `promptFileToDataUrl`:\n *\n * restoreAttachment={(f) => f.ref ? promptDataUrlToFile(f.ref, f.name, f.type) : undefined}\n *\n * Synchronous, so the restored draft has its Files on the first render.\n * `undefined` for anything that is not a `data:` URL.\n */\nexport function promptDataUrlToFile(dataUrl: string, name: string, type?: string): File | undefined {\n if (!dataUrl.startsWith(\"data:\")) return undefined;\n const comma = dataUrl.indexOf(\",\");\n if (comma < 0) return undefined;\n\n const meta = dataUrl.slice(5, comma);\n const body = dataUrl.slice(comma + 1);\n const mime = type || meta.split(\";\")[0] || \"application/octet-stream\";\n\n try {\n let bytes: Uint8Array<ArrayBuffer>;\n if (meta.endsWith(\";base64\")) {\n const bin = atob(body);\n bytes = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);\n } else {\n bytes = new TextEncoder().encode(decodeURIComponent(body));\n }\n return new File([bytes], name, { type: mime });\n } catch {\n return undefined;\n }\n}\n","/**\n * Which modifier key the user actually has.\n *\n * This exists because a keyboard hint is a CLAIM about the reader's hardware.\n * `⌘ + Enter to send` on Windows or Linux names a key that is not on the\n * keyboard, and a reader who cannot act on a hint learns to ignore hints — so\n * the cost is not one wrong glyph, it is the credibility of every hint beside\n * it. (Reported from a real Electron app running on Linux, where the glyph had\n * no font behind it either and rendered as tofu.)\n *\n * Two deliberate choices:\n *\n * 1. **The platform is an ARGUMENT, never a global read.** `detectPlatform`\n * takes the hints; `modifierKeyLabel` takes the verdict. Both branches are\n * therefore reachable from one machine, which is the only way a test can\n * cover the platform you are not sitting at. A function that reads\n * `navigator` internally can only ever be tested on the developer's own OS.\n * 2. **`generic` is the fallback, and that is not arbitrary.** Every Fancy\n * surface that submits on a modifier accepts `metaKey || ctrlKey`, so\n * `Ctrl` is a TRUE label on an Apple keyboard while `⌘` is a FALSE one\n * everywhere else. The honest default is the one that is pressable on all\n * of them.\n */\nexport type FancyPlatform = \"apple\" | \"generic\";\n\n/**\n * The parts of `navigator` the detection reads — nothing more, so a caller can\n * hand it a literal (a test, an Electron main process forwarding `process.platform`,\n * a server with a stored preference).\n */\nexport interface PlatformHints {\n /** `navigator.userAgentData` — the modern, non-spoofed answer where it exists. */\n userAgentData?: { platform?: string } | null;\n /** `navigator.platform` — deprecated, still the most reliable legacy signal. */\n platform?: string | null;\n /** `navigator.userAgent` — last resort. */\n userAgent?: string | null;\n}\n\n/**\n * `userAgentData.platform` is a short enumerated token (\"macOS\", \"Windows\",\n * \"Linux\", \"Android\", \"iOS\"), so it is matched exactly rather than by substring.\n */\nconst APPLE_UA_DATA_PLATFORMS = new Set([\"macos\", \"ios\", \"ipados\"]);\n\n/**\n * Legacy `platform` / `userAgent` are free text. iPadOS reports `MacIntel`, and\n * iOS user agents say \"like Mac OS X\" — both are Apple, so a Mac match is\n * correct for them too.\n */\nconst APPLE_FREE_TEXT = /\\b(mac|macintosh|iphone|ipad|ipod|darwin)/i;\n\n/** Resolve a platform from navigator-shaped hints. Unknown or absent ⇒ `generic`. */\nexport function detectPlatform(hints?: PlatformHints | null): FancyPlatform {\n if (!hints) return \"generic\";\n\n const uaData = hints.userAgentData?.platform;\n if (typeof uaData === \"string\" && uaData.length > 0) {\n // When the browser gives an enumerated answer, TRUST IT and stop. Falling\n // through to the free-text test would let a Windows UA string containing\n // the word \"Mac\" (a font name, a device model) overturn it.\n return APPLE_UA_DATA_PLATFORMS.has(uaData.trim().toLowerCase()) ? \"apple\" : \"generic\";\n }\n\n for (const value of [hints.platform, hints.userAgent]) {\n if (typeof value === \"string\" && APPLE_FREE_TEXT.test(value)) return \"apple\";\n }\n\n return \"generic\";\n}\n\n/**\n * The modifier key to NAME for a platform.\n *\n * `⌘` is emitted for `apple` and nothing else. A test enumerates the platform\n * values and counts that no other one can produce it, because a hint that names\n * the wrong key is worse than no hint.\n */\nexport function modifierKeyLabel(platform: FancyPlatform): \"⌘\" | \"Ctrl\" {\n return platform === \"apple\" ? \"⌘\" : \"Ctrl\";\n}\n\n/** SSR-safe read of the live browser hints. `null` off a browser. */\nexport function browserPlatformHints(): PlatformHints | null {\n if (typeof navigator === \"undefined\") return null;\n return navigator as PlatformHints;\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { visuallyHidden } from \"../../utils/visually-hidden\";\nimport {\n useAcknowledgedSubmit,\n type SubmitResult,\n} from \"../../hooks/use-acknowledged-submit\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Tooltip } from \"../Tooltip\";\nimport {\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n type ComposerPasteClassNames,\n type ComposerPastePreview,\n type InlinePasteEditorHandle,\n type HeldImage,\n type HeldPaste,\n} from \"../PastePills\";\nimport {\n EMPTY_DRAFT,\n clonePromptDraft,\n promptDraftFiles,\n readPromptDraft,\n type PromptDraft,\n type PromptDraftFile,\n type PromptDraftPill,\n type PromptInputHandle,\n type PromptSetDraftOptions,\n type PromptFocusOptions,\n} from \"./prompt-draft\";\n\nexport {\n promptDataUrlToFile,\n promptFileToDataUrl,\n} from \"./prompt-draft\";\nexport type { SubmitRejection, SubmitResult } from \"../../hooks/use-acknowledged-submit\";\nexport type {\n PromptDraft,\n PromptDraftFile,\n PromptDraftPill,\n PromptInputHandle,\n PromptSetDraftOptions,\n PromptFocusOptions,\n} from \"./prompt-draft\";\nimport {\n browserPlatformHints,\n detectPlatform,\n modifierKeyLabel,\n type FancyPlatform,\n} from \"../../utils/platform\";\n\n/**\n * PromptInput — the chat composer every AI app rebuilds. Auto-growing\n * multi-line input with:\n *\n * • slash-command picker (`/` triggers a filtered command palette,\n * ↑/↓ navigate, Enter inserts)\n * • mention picker (`@` triggers, filtered against `mentions`)\n * • drop-to-attach (drag files anywhere on the surface), paste-to-attach\n * (a pasted screenshot becomes an attachment) + chip bar\n * • submit on ⌘/Ctrl+Enter (plain Enter inserts a newline)\n * • live token-budget meter (green → amber → red as headroom drops)\n *\n * Wire it up:\n *\n * <PromptInput\n * budgetTokens={32000}\n * commands={[{ name: \"/rewrite\", hint: \"rewrite the selection\" }]}\n * mentions={[{ id: \"ada\", name: \"Ada\", kind: \"person\" }]}\n * onSubmit={(text, attachments) => sendToAgent(text, attachments)}\n * />\n */\nexport type PromptCmd = { name: string; hint: string };\nexport type PromptMention = {\n id: string;\n name: string;\n kind: \"agent\" | \"file\" | \"person\" | string;\n};\nexport type PromptAttachment = {\n id: string;\n name: string;\n bytes: number;\n /**\n * The file the user actually attached.\n *\n * Optional because an attachment restored from a server has no File — but for\n * anything the user dropped or picked it is always present. Without it a host\n * can render a chip and nothing else: no POST, no FormData, no send-to-model.\n */\n file?: File;\n /** MIME type. Hosts branch on this to decide whether a file can be sent as-is. */\n type?: string;\n /**\n * The host's handle for the stored bytes, from `persistAttachment`. On an\n * attachment restored from a draft WITHOUT a File, this is how the host finds\n * the bytes to send.\n */\n ref?: string;\n};\n\n/**\n * `...rest` reaches the root surface, so a consumer or a bridge can tag the\n * composer with its own `data-*` handle. The component named every prop it\n * used and had no rest spread, which means a `data-handle` put on it was\n * DROPPED — silently, since React discards unknown props and the component\n * still renders perfectly. That is issue #22 all over again, and the contract\n * calls it out: \"Each interactive element has a stable identity. Agents never\n * guess DOM.\"\n */\nexport interface PromptInputProps\n extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"onSubmit\" | \"className\" | \"onChange\" | \"defaultValue\"\n > {\n /** Extra classes on the root surface. MERGED, never replaced. */\n className?: string;\n /**\n * The text, controlled. With paste pills on it carries a marker per pill\n * (`pasteMarker(id)`), exactly as `Composer`'s `value` does. Pills and\n * attachments stay internal; use `draft` to control those too.\n */\n value?: string;\n /** The starting text, uncontrolled. Ignored when `value` or `draft` is given. */\n defaultValue?: string;\n /**\n * Called with the new text when the PERSON edits it, and with `\"\"` after a\n * send. Not called by `setDraft` or a prop change: the host made those.\n */\n onChange?: (value: string) => void;\n /**\n * The whole draft, controlled: text, paste pills and attachments, as JSON.\n * Wins over `value`. Pair with `onDraftChange`.\n */\n draft?: PromptDraft;\n /** The starting draft, uncontrolled. Wins over `defaultValue`. */\n defaultDraft?: PromptDraft;\n /**\n * Called with the whole draft whenever the person changes any part of it —\n * typing, a paste, an attach, a removal, a send (which empties it) — and when\n * `persistAttachment` resolves a `ref`. Not called by `setDraft`.\n */\n onDraftChange?: (draft: PromptDraft) => void;\n /**\n * Keep an attached file somewhere and return a handle for it (a storage key, an\n * upload URL — or a `data:` URL via `promptFileToDataUrl`). Called once per\n * attached or pasted file; the result becomes the file's `ref` in the draft.\n * May return a Promise; the draft is updated (and `onDraftChange` fires) when it\n * resolves. Omit it and a draft carries file metadata only.\n */\n persistAttachment?: (\n file: File,\n entry: PromptDraftFile,\n ) => string | undefined | Promise<string | undefined>;\n /**\n * Get a File back for a draft entry restored without one (from `setDraft`,\n * `defaultDraft` or a controlled `draft`). May return a Promise. Return\n * `undefined` when there is none: the chip or pill still shows, and the\n * attachment reaches `onSubmit` with its `ref` and no `file`.\n */\n restoreAttachment?: (\n entry: PromptDraftFile,\n ) => File | undefined | Promise<File | undefined>;\n /** Token budget for the meter. */\n budgetTokens: number;\n /** Slash-commands. Names must start with `/`. */\n commands?: PromptCmd[];\n /** @-mentions. */\n mentions?: PromptMention[];\n /** Show the keyboard hint (\"Ctrl + Enter to send\", \"⌘ + Enter\" on a Mac). */\n showHint?: boolean;\n /**\n * Which modifier the hint and the default placeholder NAME. Omit it and the\n * component reads the platform after mount, which is the right answer for an\n * ordinary web app.\n *\n * Pass it when the host knows better than `navigator` does — an Electron\n * renderer forwarding `process.platform`, a remote session where the\n * keyboard is not the one running the browser, or a test that needs the\n * branch it is not sitting on. The pressed keys are unaffected either way:\n * submit is `⌘/Ctrl+Enter` on every platform, so this only decides which\n * true key gets named.\n */\n platform?: FancyPlatform;\n /**\n * Called on ⌘/Ctrl+Enter or send button.\n *\n * **Return nothing and the draft empties at once, as it always has.**\n *\n * Return a Promise to make the send acknowledged: the text, pills and\n * attachments stay, the send button is disabled and `aria-busy`, and a second\n * send is refused until it settles. The text stays editable meanwhile.\n *\n * - Resolves (to anything but `{ ok: false }`) → the draft empties in one\n * commit, unless anything changed it while the send was in flight (the\n * person, `setDraft`, a controlled prop), even to an identical draft; the\n * newer draft is kept whole.\n * - Rejects, or resolves `{ ok: false, error? }` → the draft is kept,\n * `onSubmitError` is called and the failure is announced to screen readers.\n *\n * With a controlled `value` or `draft` the reset reaches the host through\n * `onChange(\"\")` / `onDraftChange(empty)` like any other change, and the host\n * decides whether to apply it.\n */\n onSubmit: (\n text: string,\n attachments: PromptAttachment[],\n ) => void | Promise<SubmitResult>;\n /**\n * Called when a Promise from `onSubmit` rejects (with the reason) or resolves\n * `{ ok: false }` (with its `error`, or `undefined`). The draft is kept.\n */\n onSubmitError?: (error: unknown) => void;\n /** Disables the text, attaching, dropping and the send. */\n disabled?: boolean;\n /**\n * Disables only the send: the text stays editable and attachable, and\n * ⌘/Ctrl+Enter does not send. For \"the agent is still answering, but you can\n * write the next message\".\n */\n sendDisabled?: boolean;\n /**\n * Form field name for the text. On the textarea itself; with inline pills on\n * (`pasteThreshold` / `pasteImages`), on a hidden input carrying the expanded\n * text, since a contenteditable is not a form field.\n */\n name?: string;\n /**\n * `id` of the text field (textarea or inline editor). `id` itself names the\n * root, as it always has. It is the one handle that does not change when inline\n * pills switch the field type. Without it the field is found by\n * `data-react-fancy-prompt-input-textarea` or, with inline pills,\n * `data-react-fancy-composer-input`.\n */\n inputId?: string;\n /**\n * Placeholder text. Defaults to a hint naming the modifier THIS platform\n * actually has, so leaving it unset is the better option — a hardcoded\n * placeholder is the other place a `⌘` ends up in front of a Windows user.\n */\n placeholder?: string;\n /** Rough estimator: chars-per-token. Defaults to 4. */\n charsPerToken?: number;\n /** Color → CSS chip mapping for mention kinds. */\n mentionColor?: Record<string, string>;\n /** Optional max textarea height in px. Defaults to 280. */\n maxHeight?: number;\n /**\n * Rendered INSIDE the rounded shell, ABOVE the attachments bar and\n * textarea. Use this slot for a drawer of tools/files/prompts/etc. so\n * the drawer and composer share one visual panel. See {@link ChatDrawer}.\n */\n aboveInput?: ReactNode;\n /**\n * Hold a paste of at least this many characters as a pill IN the message,\n * where it was pasted: on a line of its own, its full text put back in place\n * when clicked, and expanded where it sits when sent. Omit it and paste is\n * unchanged. Setting this (or `pasteImages`) swaps the textarea for an inline\n * editor that keeps the `/` and `@` pickers and the send key.\n */\n pasteThreshold?: number;\n /**\n * A pasted image becomes an inline `Pasted image N` pill AND reaches\n * `onSubmit`'s attachments, with its File, in message order; the text marks\n * where it sat as `[Pasted image N]`. Without it a pasted image is an\n * ordinary attachment chip, as before.\n */\n pasteImages?: boolean;\n /** Characters of a held paste shown at EACH end of its hover preview. Default 20. */\n previewChars?: number;\n /** Replace the paste pills' hover popover content. */\n renderPastePreview?: (preview: ComposerPastePreview) => ReactNode;\n /** Restyle the paste pills, their popover and the inline editor. Merged onto the defaults. */\n pasteClassNames?: ComposerPasteClassNames;\n /**\n * Submit pasted images with an enclosing `<form>`, under this field name: a\n * hidden `<input type=\"file\" multiple>` holds the images still in the message,\n * in message order. Needs `pasteImages`. They reach `onSubmit` either way.\n */\n pasteFilesName?: string;\n /** `\"icon\"`: an icon-only attach button whose tooltip says what it does. Default `\"label\"`. */\n attachButton?: \"label\" | \"icon\";\n /**\n * `\"icon\"`: a compact icon send button whose tooltip carries the shortcut —\n * replacing the inline `Ctrl + Enter to send` hint. Default `\"label\"`.\n */\n sendButton?: \"label\" | \"icon\";\n /**\n * Tokens already used — the caller's REAL value, e.g. an agent's context\n * usage. The meter shows this plus the estimate for the draft. Without it the\n * meter estimates the draft alone, as before.\n */\n usedTokens?: number;\n /**\n * `\"always\"` (default) — as before. `\"near-limit\"` — hidden until usage passes\n * `meterShowAt`, muted until `meterWarnAt`, warning colour past that.\n * `\"hidden\"` — never shown.\n */\n meter?: \"always\" | \"near-limit\" | \"hidden\";\n /** Fraction of `budgetTokens` at which a `\"near-limit\"` meter appears. Default 0.75. */\n meterShowAt?: number;\n /** Fraction of `budgetTokens` past which a `\"near-limit\"` meter takes the warning colour. Default 0.9. */\n meterWarnAt?: number;\n}\n\nconst DEFAULT_MENTION_COLOR: Record<string, string> = {\n agent: \"#a855f7\",\n file: \"#10b981\",\n person: \"#3b82f6\",\n};\n\nexport const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(function PromptInput({\n value: controlledValue,\n defaultValue,\n onChange,\n draft: controlledDraft,\n defaultDraft,\n onDraftChange,\n persistAttachment,\n restoreAttachment,\n budgetTokens,\n commands = [],\n mentions = [],\n showHint = true,\n platform,\n onSubmit,\n onSubmitError,\n disabled = false,\n sendDisabled = false,\n name,\n inputId,\n placeholder,\n charsPerToken = 4,\n mentionColor,\n maxHeight = 280,\n aboveInput,\n className,\n pasteThreshold,\n pasteImages = false,\n previewChars = 20,\n renderPastePreview,\n pasteClassNames,\n pasteFilesName,\n attachButton = \"label\",\n sendButton = \"label\",\n usedTokens,\n meter = \"always\",\n meterShowAt = 0.75,\n meterWarnAt = 0.9,\n ...rest\n}: PromptInputProps, ref) {\n /** Inline pills need an editor that can hold them; a textarea cannot. */\n const inline = pasteThreshold !== undefined || pasteImages;\n\n /*\n * ONE model for everything a draft is — text, pills, attachments — so a draft\n * read back is never a text from one moment and a list from another. Pills used\n * to live in `useInlinePaste` and attachments in their own state, which is why\n * nothing outside could read or restore them. They are now owned here and handed\n * to `useInlinePaste` controlled.\n *\n * Files cannot be JSON, so they live beside the model in `filesRef`, keyed by the\n * model's ids. `filesVersion` re-renders when a restored File arrives; that is\n * not a draft change, so nobody is told about it.\n */\n const draftControlled = controlledDraft !== undefined;\n const [innerDraft, setInnerDraft] = useState<PromptDraft>(\n () =>\n (defaultDraft && readPromptDraft(defaultDraft, inline)) || {\n ...EMPTY_DRAFT,\n text: defaultValue ?? \"\",\n },\n );\n const baseDraft = draftControlled ? controlledDraft : innerDraft;\n const model: PromptDraft =\n !draftControlled && controlledValue !== undefined && controlledValue !== baseDraft.text\n ? { ...baseDraft, text: controlledValue }\n : baseDraft;\n const modelRef = useRef(model);\n modelRef.current = model;\n const text = model.text;\n\n /*\n * The draft's REVISION: bumped by every change to what the draft says — the\n * person typing, pasting, attaching or removing; the host's `setDraft`; a\n * controlled `draft` / `value` prop that now says something different. NOT by\n * a `ref` arriving from `persistAttachment`, which is storage catching up,\n * not anybody changing the message.\n *\n * An acknowledged send clears only if the revision is still the one it sent.\n * Comparing CONTENT instead (5.70.0) threw away newer drafts that happened to\n * compare equal: an edit typed and undone, a host restoring the same draft, a\n * pill or attachment changed under the same id.\n */\n const revisionRef = useRef(0);\n const seenRef = useRef(model);\n if (seenRef.current !== model) {\n // A model this component did not commit itself: a controlled prop moved.\n if (!sameDraftContent(seenRef.current, model)) revisionRef.current += 1;\n seenRef.current = model;\n }\n\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n const onDraftChangeRef = useRef(onDraftChange);\n onDraftChangeRef.current = onDraftChange;\n const persistRef = useRef(persistAttachment);\n persistRef.current = persistAttachment;\n\n /**\n * Apply a change to the draft. `notify` is false only for `setDraft`: a host\n * restoring a draft already knows what it set, and telling it would make every\n * restore look like the person typed — a \"dirty\" flag, a typing indicator, a\n * save that overwrites what was just loaded.\n */\n const commit = useCallback(\n (update: (current: PromptDraft) => PromptDraft, notify = true, revise = true) => {\n const prev = modelRef.current;\n const next = update(prev);\n if (next === prev) return;\n if (revise) revisionRef.current += 1;\n modelRef.current = next;\n seenRef.current = next;\n setInnerDraft(next);\n if (!notify) return;\n if (next.text !== prev.text) onChangeRef.current?.(next.text);\n onDraftChangeRef.current?.(next);\n },\n [],\n );\n\n const filesRef = useRef(new Map<string, File>());\n const placeholdersRef = useRef(new Map<string, File>());\n const requestedRef = useRef(new Set<string>());\n const [filesVersion, bumpFiles] = useReducer((n: number) => n + 1, 0);\n\n /**\n * Record a ref from `persistAttachment` against whichever entry has `id`. Not\n * a new revision: a send in flight that carried this file may still clear it.\n */\n const setFileRef = useCallback(\n (id: string, fileRef: string) =>\n commit(\n (m) => {\n const withRef = (f: PromptDraftFile) => (f.id === id ? { ...f, ref: fileRef } : f);\n if (!promptDraftFiles(m).some((f) => f.id === id)) return m;\n return {\n ...m,\n attachments: m.attachments.map(withRef),\n pills: m.pills.map((p) => (p.kind === \"image\" ? { ...p, file: withRef(p.file) } : p)),\n };\n },\n true,\n false,\n ),\n [commit],\n );\n\n /**\n * Hand a newly attached file to the host's store. A synchronous handle is\n * returned so it lands in the same draft as the file; an async one updates the\n * draft when it arrives. A failing store loses the handle, never the attachment.\n */\n const persist = useCallback(\n (file: File, entry: PromptDraftFile): string | undefined => {\n const store = persistRef.current;\n if (!store) return undefined;\n let out: ReturnType<typeof store>;\n try {\n out = store(file, entry);\n } catch (error) {\n console.error(\"PromptInput: persistAttachment threw\", error);\n return undefined;\n }\n if (typeof out === \"string\") return out;\n if (out && typeof (out as Promise<unknown>).then === \"function\") {\n (out as Promise<string | undefined>).then(\n (fileRef) => {\n if (typeof fileRef === \"string\") setFileRef(entry.id, fileRef);\n },\n (error) => console.error(\"PromptInput: persistAttachment rejected\", error),\n );\n }\n return undefined;\n },\n [setFileRef],\n );\n\n const fileMeta = (id: string, file: File): PromptDraftFile => ({\n id,\n name: file.name,\n type: file.type,\n bytes: file.size,\n });\n\n /** A held image needs a File to show; a restored one without its bytes gets an empty stand-in. */\n const fileFor = useCallback((entry: PromptDraftFile): File => {\n const real = filesRef.current.get(entry.id);\n if (real) return real;\n let stand = placeholdersRef.current.get(entry.id);\n if (!stand) {\n stand = new File([], entry.name, { type: entry.type });\n placeholdersRef.current.set(entry.id, stand);\n }\n return stand;\n }, []);\n\n const heldPastes = useMemo<HeldPaste[]>(\n () =>\n model.pills.flatMap((p) =>\n p.kind === \"text\"\n ? [p.label !== undefined ? { id: p.id, text: p.text, label: p.label } : { id: p.id, text: p.text }]\n : [],\n ),\n [model.pills],\n );\n const heldImages = useMemo<HeldImage[]>(\n () =>\n model.pills.flatMap((p) =>\n p.kind === \"image\" ? [{ id: p.id, label: p.label, file: fileFor(p.file) }] : [],\n ),\n // filesVersion: a restored File arrived, so the stand-in can be swapped out.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [model.pills, fileFor, filesVersion],\n );\n\n const onHeldPastesChange = useCallback(\n (next: HeldPaste[]) =>\n commit((m) => {\n const current = m.pills.filter((p) => p.kind === \"text\");\n if (\n current.length === next.length &&\n current.every(\n (p, i) =>\n p.id === next[i]!.id &&\n p.kind === \"text\" &&\n p.text === next[i]!.text &&\n p.label === next[i]!.label,\n )\n ) {\n return m;\n }\n return {\n ...m,\n pills: [\n ...next.map(\n (p): PromptDraftPill =>\n p.label !== undefined\n ? { kind: \"text\", id: p.id, text: p.text, label: p.label }\n : { kind: \"text\", id: p.id, text: p.text },\n ),\n ...m.pills.filter((p) => p.kind === \"image\"),\n ],\n };\n }),\n [commit],\n );\n\n const onHeldImagesChange = useCallback(\n (next: HeldImage[]) =>\n commit((m) => {\n const before = new Map(\n m.pills.flatMap((p) => (p.kind === \"image\" ? [[p.id, p] as const] : [])),\n );\n if (before.size === next.length && next.every((i) => before.has(i.id))) return m;\n const images = next.map((image): PromptDraftPill => {\n const known = before.get(image.id);\n if (known && known.kind === \"image\") return known;\n // A new paste: its File is real, so keep it and offer it to the host.\n filesRef.current.set(image.id, image.file);\n const entry = fileMeta(image.id, image.file);\n const fileRef = persist(image.file, entry);\n return {\n kind: \"image\",\n id: image.id,\n label: image.label,\n file: fileRef === undefined ? entry : { ...entry, ref: fileRef },\n };\n });\n return { ...m, pills: [...m.pills.filter((p) => p.kind === \"text\"), ...images] };\n }),\n [commit, persist],\n );\n\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames: pasteClassNames,\n disabled,\n heldPastes,\n onHeldPastesChange,\n heldImages,\n onHeldImagesChange,\n editorRef,\n });\n\n const attachments = useMemo<PromptAttachment[]>(\n () =>\n model.attachments.map((a) => ({\n id: a.id,\n name: a.name,\n bytes: a.bytes,\n file: filesRef.current.get(a.id),\n type: a.type,\n ...(a.ref !== undefined ? { ref: a.ref } : {}),\n })),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [model.attachments, filesVersion],\n );\n\n /*\n * Get Files back for entries that arrived without one — a restored draft, a\n * default draft, a controlled draft from storage. Each id is asked for once.\n */\n const restoreRef = useRef(restoreAttachment);\n restoreRef.current = restoreAttachment;\n useEffect(() => {\n const restore = restoreRef.current;\n if (!restore) return;\n for (const entry of promptDraftFiles(model)) {\n if (filesRef.current.has(entry.id) || requestedRef.current.has(entry.id)) continue;\n requestedRef.current.add(entry.id);\n const accept = (file: File | undefined) => {\n if (!(file instanceof Blob)) return;\n filesRef.current.set(entry.id, file as File);\n bumpFiles();\n };\n let out: ReturnType<typeof restore>;\n try {\n out = restore(entry);\n } catch (error) {\n console.error(\"PromptInput: restoreAttachment threw\", error);\n continue;\n }\n if (out && typeof (out as Promise<unknown>).then === \"function\") {\n (out as Promise<File | undefined>).then(accept, (error) =>\n console.error(\"PromptInput: restoreAttachment rejected\", error),\n );\n } else {\n accept(out as File | undefined);\n }\n }\n }, [model]);\n\n const setText = (next: string) => commit((m) => (m.text === next ? m : { ...m, text: next }));\n const [picker, setPicker] = useState<null | {\n kind: \"cmd\" | \"mention\";\n start: number;\n query: string;\n cursor: number;\n }>(null);\n const taRef = useRef<HTMLTextAreaElement>(null);\n const fileRef = useRef<HTMLInputElement>(null);\n const [dragOver, setDragOver] = useState(false);\n\n const colors = mentionColor ?? DEFAULT_MENTION_COLOR;\n\n /**\n * Resolved AFTER mount, never during render.\n *\n * `navigator` read during render disagrees with the server's HTML and\n * hydration patches it — so the fix for a wrong label would have introduced a\n * hydration mismatch instead. The first paint names `Ctrl`, which is\n * pressable on every platform including a Mac, and an Apple client swaps to\n * `⌘` on the next tick. A prop, when given, wins outright and no detection\n * runs at all.\n */\n const [detected, setDetected] = useState<FancyPlatform>(\"generic\");\n useEffect(() => {\n if (platform) return;\n setDetected(detectPlatform(browserPlatformHints()));\n }, [platform]);\n const modKey = modifierKeyLabel(platform ?? detected);\n\n const resolvedPlaceholder =\n placeholder ??\n `Ask anything. Type / for commands, @ for mentions. ${modKey}+Enter to send.`;\n\n // Estimated from what will actually be SENT — pills expanded — so a held\n // paste counts for its text, not for the few characters of its marker.\n const draftTokens = useMemo(\n () =>\n Math.ceil((inline ? paste.expand(text) : text).length / Math.max(1, charsPerToken)),\n [text, inline, paste, charsPerToken],\n );\n const tokens = (usedTokens ?? 0) + draftTokens;\n const ratio = Math.min(1, tokens / budgetTokens);\n const meterLevel: \"ok\" | \"caution\" | \"warn\" | \"muted\" | null =\n meter === \"hidden\"\n ? null\n : meter === \"near-limit\"\n ? ratio < meterShowAt\n ? null\n : ratio >= meterWarnAt\n ? \"warn\"\n : \"muted\"\n : ratio < 0.6\n ? \"ok\"\n : ratio < 0.85\n ? \"caution\"\n : \"warn\";\n const meterColor =\n meterLevel === \"ok\"\n ? \"#10b981\"\n : meterLevel === \"caution\"\n ? \"#f59e0b\"\n : meterLevel === \"warn\"\n ? \"#ef4444\"\n : \"#a1a1aa\";\n\n const filteredCmds = useMemo(\n () =>\n picker?.kind === \"cmd\"\n ? commands.filter((c) =>\n c.name.slice(1).toLowerCase().startsWith(picker.query.toLowerCase()),\n )\n : [],\n [picker, commands],\n );\n const filteredMentions = useMemo(\n () =>\n picker?.kind === \"mention\"\n ? mentions.filter((m) =>\n m.name.toLowerCase().includes(picker.query.toLowerCase()),\n )\n : [],\n [picker, mentions],\n );\n const items: Array<PromptCmd | PromptMention> =\n picker?.kind === \"cmd\"\n ? filteredCmds\n : picker?.kind === \"mention\"\n ? filteredMentions\n : [];\n\n useEffect(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.style.height = \"auto\";\n ta.style.height = Math.min(maxHeight, ta.scrollHeight) + \"px\";\n }, [text, maxHeight]);\n\n const updateText = (next: string, caret: number) => {\n setText(next);\n let triggerIdx = -1;\n let triggerKind: \"cmd\" | \"mention\" | null = null;\n for (let i = caret - 1; i >= 0; i--) {\n const ch = next[i];\n if (ch === \"@\") {\n triggerKind = \"mention\";\n triggerIdx = i;\n break;\n }\n if (ch === \"/\" && (i === 0 || /\\s/.test(next[i - 1] ?? \"\"))) {\n triggerKind = \"cmd\";\n triggerIdx = i;\n break;\n }\n if (/\\s/.test(ch)) break;\n }\n if (triggerKind !== null && triggerIdx >= 0) {\n const query = next.slice(triggerIdx + 1, caret);\n setPicker({ kind: triggerKind, start: triggerIdx, query, cursor: 0 });\n } else {\n setPicker(null);\n }\n };\n\n const insertChoice = (i: number) => {\n if (!picker || items.length === 0) return;\n const choice = items[i] ?? items[0];\n const insert =\n picker.kind === \"cmd\"\n ? (choice as PromptCmd).name + \" \"\n : `@${(choice as PromptMention).id} `;\n const before = text.slice(0, picker.start);\n const after = text.slice(picker.start + 1 + picker.query.length);\n const next = before + insert + after;\n setText(next);\n setPicker(null);\n if (inline) {\n // The editor rebuilds from the value and puts the caret back itself.\n editorRef.current?.setValue(next, before.length + insert.length);\n return;\n }\n requestAnimationFrame(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.focus();\n const pos = before.length + insert.length;\n ta.setSelectionRange(pos, pos);\n });\n };\n\n const ack = useAcknowledgedSubmit(onSubmitError);\n const submitting = ack.status === \"submitting\";\n\n const submit = () => {\n if (disabled || sendDisabled || ack.busy()) return;\n // A message that is only a paste counts: its marker is in `text`.\n if (!text.trim() && attachments.length === 0) return;\n\n let result: ReturnType<typeof onSubmit>;\n if (inline) {\n // Every pill goes out where it sits; pasted images join the attachments\n // in message order, with their Files, so a host sends them like any other.\n // A restored image without its bytes goes out with its `ref` and no `file`,\n // never with the empty stand-in that only exists so the pill can render.\n const pastedImages: PromptAttachment[] = paste.imagesIn(text).map((image) => {\n const entry = model.pills.find((p) => p.id === image.id);\n const meta = entry?.kind === \"image\" ? entry.file : fileMeta(image.id, image.file);\n return {\n id: image.id,\n name: meta.name,\n bytes: meta.bytes,\n file: filesRef.current.get(image.id),\n type: meta.type,\n ...(meta.ref !== undefined ? { ref: meta.ref } : {}),\n };\n });\n result = onSubmit(paste.expand(text), [...attachments, ...pastedImages]);\n } else {\n result = onSubmit(text, attachments);\n }\n setPicker(null);\n const sent = revisionRef.current;\n ack.track(result, () => {\n /*\n * A void `onSubmit` reaches here synchronously, so this is the reset it\n * always was. An async one reaches here when it resolves: if anything\n * changed the draft while it was in flight — the person, the host's\n * `setDraft`, a controlled prop — that draft is newer than the send and is\n * kept, even if it reads the same. Discarding it is the one outcome\n * nobody can undo.\n */\n if (revisionRef.current !== sent) return;\n // One commit for the whole reset, so a host saving on change sees one empty\n // draft rather than three half-empty ones.\n commit(() => EMPTY_DRAFT);\n filesRef.current.clear();\n placeholdersRef.current.clear();\n requestedRef.current.clear();\n });\n };\n\n /**\n * Focus requested by `setDraft(..., { focus: true })` waits for the render that\n * shows the draft: the inline editor rebuilds its DOM from the new value, which\n * would discard a caret placed before it. Children's layout effects run first,\n * so by the time this one runs the editor already holds the draft.\n */\n const pendingFocus = useRef<PromptFocusOptions | null>(null);\n /**\n * Focus on the HOST's behalf: never scrolls unless asked. A bare `focus()`\n * scrolls every scrollable ancestor up to the document to reveal the input,\n * which scrolled Genie's whole window (genie#1290). Focus that answers the\n * person's own keypress (the picker) keeps the browser's default.\n */\n const focusInput = useCallback(\n (options?: PromptFocusOptions) => {\n const opts: FocusOptions = { preventScroll: options?.preventScroll ?? true };\n if (inline) {\n editorRef.current?.focus(opts);\n return;\n }\n const ta = taRef.current;\n if (!ta) return;\n ta.focus(opts);\n ta.setSelectionRange(ta.value.length, ta.value.length);\n },\n [inline],\n );\n useLayoutEffect(() => {\n const pending = pendingFocus.current;\n if (!pending) return;\n pendingFocus.current = null;\n focusInput(pending);\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getDraft: () => clonePromptDraft(modelRef.current),\n setDraft(next: PromptDraft, options?: PromptSetDraftOptions) {\n const read = readPromptDraft(next, inline);\n if (!read) {\n console.warn(\n \"PromptInput: setDraft ignored a draft it does not recognise (expected { v: 1, ... }).\",\n next,\n );\n return;\n }\n // Ask again for any File this draft needs that is not already held.\n for (const entry of promptDraftFiles(read)) {\n if (!filesRef.current.has(entry.id)) requestedRef.current.delete(entry.id);\n }\n setPicker(null);\n commit(() => read, false);\n // `commit` always sets state here (`read` is a new object), so a render\n // follows and the layout effect below picks the focus up.\n if (options?.focus) pendingFocus.current = { preventScroll: options.preventScroll };\n },\n focus: (options?: PromptFocusOptions) => focusInput(options),\n }),\n [inline, commit, focusInput],\n );\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n // Enter that confirms an IME composition finishes a word: it neither picks\n // from a menu nor sends.\n if (e.key === \"Enter\" && isImeComposing(e)) return;\n if (picker) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setPicker((p) =>\n p ? { ...p, cursor: Math.min(items.length - 1, p.cursor + 1) } : p,\n );\n return;\n }\n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setPicker((p) => (p ? { ...p, cursor: Math.max(0, p.cursor - 1) } : p));\n return;\n }\n // Tab completes, as Enter does: the autocomplete key people expect from a\n // shell or Claude Code. Only while a menu is open; otherwise Tab moves\n // focus as usual.\n if (((e.key === \"Enter\" && !e.metaKey && !e.ctrlKey) || (e.key === \"Tab\" && !e.shiftKey)) && items.length > 0) {\n e.preventDefault();\n insertChoice(picker.cursor);\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n setPicker(null);\n return;\n }\n }\n if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n submit();\n }\n };\n\n /**\n * Build attachments from a FileList, KEEPING the File.\n *\n * Shared by the drop handler and the picker so the two cannot drift — the\n * picker being a second, subtly different copy of this is exactly how one of\n * them would end up dropping the File again.\n */\n const attach = (list: FileList | File[] | null) => {\n const files = Array.from(list ?? []);\n if (files.length === 0 || disabled) return;\n\n const added = files.map((f) => {\n const id = crypto.randomUUID();\n filesRef.current.set(id, f);\n const entry = fileMeta(id, f);\n const fileRef = persist(f, entry);\n return fileRef === undefined ? entry : { ...entry, ref: fileRef };\n });\n commit((m) => ({ ...m, attachments: [...m.attachments, ...added] }));\n };\n\n const onDrop = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n attach(e.dataTransfer.files);\n };\n\n /**\n * Paste a screenshot, get an attachment.\n *\n * There was no paste handler at all, so a pasted image did nothing — no chip,\n * no error — and a host that had swapped its own paste-capable textarea for\n * this component lost the feature without noticing.\n *\n * Files attach only when the clipboard carries NO plain text. Word, Excel and\n * most editors put a picture of the selection beside the text; attaching that\n * would turn every pasted sentence into a screenshot of the sentence. A pure\n * image paste has nothing for the browser to insert, so the default is\n * prevented only then, and a text paste is never touched.\n */\n const onPaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n const data = e.clipboardData;\n const files = Array.from(data?.files ?? []);\n\n if (files.length === 0 || (data?.getData(\"text/plain\") ?? \"\") !== \"\") return;\n\n e.preventDefault();\n attach(files);\n };\n\n return (\n <div\n // Spread FIRST so an internal handler or data attribute cannot be\n // clobbered from outside, and so a missing one fails loudly here rather\n // than at a consumer's selector. `className` is merged below instead.\n {...rest}\n // The component had no root handle at all, so an agent reading the\n // composer had to guess at classes. The drag state is on it too: a bridge\n // that wants to know whether a drop is in flight should not have to infer\n // it from Tailwind colours.\n data-react-fancy-prompt-input=\"\"\n data-react-fancy-prompt-input-drag={dragOver ? \"over\" : \"idle\"}\n // Absent while idle; \"submitting\" while an onSubmit Promise is pending;\n // \"error\" after one was refused, until the next send.\n data-submit-state={ack.status === \"idle\" ? undefined : ack.status}\n onDragOver={(e) => {\n e.preventDefault();\n if (!disabled) setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}\n className={cn(\n \"relative rounded-md border bg-[color:var(--fancy-surface,var(--color-white))] transition dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n dragOver\n ? \"border-violet-400 bg-violet-50/50 dark:border-violet-600 dark:bg-violet-950/30\"\n : \"border-zinc-200 dark:border-zinc-800\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {aboveInput && (\n <div className=\"border-b border-zinc-200 dark:border-zinc-800\">\n {aboveInput}\n </div>\n )}\n {attachments.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800\">\n {attachments.map((a) => (\n <span\n key={a.id}\n // Stable handle per chip, so a host or agent can address one\n // attachment without guessing at markup.\n data-react-fancy-prompt-input-attachment={a.id}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] px-2 py-0.5 text-[11px] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\"\n >\n <Icon name=\"paperclip\" size=\"xs\" className=\"text-zinc-400\" />\n <span className=\"font-mono\">{a.name}</span>\n <span className=\"text-zinc-400\">{fmtSize(a.bytes)}</span>\n <button\n // A bare <button> is `submit`: inside a host's <form> this chip\n // submitted the form instead of only removing the attachment.\n type=\"button\"\n onClick={() =>\n commit((m) => ({\n ...m,\n attachments: m.attachments.filter((x) => x.id !== a.id),\n }))\n }\n disabled={disabled || undefined}\n className=\"opacity-50 hover:opacity-100\"\n aria-label=\"Remove attachment\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n )}\n\n <div className=\"relative\">\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={text}\n known={paste.known}\n onChange={(next, caret) => {\n updateText(next, caret);\n paste.prune(next);\n }}\n onSubmit={submit}\n submitKey=\"mod-enter\"\n onKeyDown={onKeyDown}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={resolvedPlaceholder}\n disabled={disabled}\n id={inputId}\n maxHeight={maxHeight}\n placeholderClassName=\"left-3 top-2.5 text-[14px] leading-relaxed\"\n className={cn(\n \"block min-h-[5.5rem] px-3 py-2.5 text-[14px] leading-relaxed\",\n pasteClassNames?.input,\n )}\n />\n {paste.portals}\n {/* A contenteditable is no form field, so `name` rides on a hidden\n one carrying what a send would carry: the expanded text. */}\n {name && <input type=\"hidden\" name={name} value={paste.expand(text)} />}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput\n name={pasteFilesName}\n files={paste\n .imagesIn(text)\n .flatMap((i) => (filesRef.current.has(i.id) ? [i.file] : []))}\n />\n )}\n </>\n ) : (\n <textarea\n ref={taRef}\n // Its own handle, NOT the inline editor's `data-react-fancy-composer-input`:\n // that one already means \"the contenteditable is on\", and a host that\n // tests for it to pick a write path must not be handed a textarea.\n data-react-fancy-prompt-input-textarea=\"\"\n id={inputId}\n name={name}\n disabled={disabled}\n value={text}\n onChange={(e) => updateText(e.target.value, e.target.selectionStart)}\n onKeyDown={onKeyDown}\n onPaste={onPaste}\n placeholder={resolvedPlaceholder}\n spellCheck={false}\n className=\"block w-full resize-none bg-transparent px-3 py-2.5 text-[14px] leading-relaxed outline-none placeholder:text-zinc-400\"\n rows={3}\n />\n )}\n\n {picker && items.length > 0 && (\n <div className=\"absolute bottom-full left-2 z-10 mb-1 w-72 overflow-hidden rounded-md border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\">\n <div className=\"border-b border-zinc-100 bg-zinc-50 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950\">\n {picker.kind === \"cmd\" ? \"Commands\" : \"Mention\"} · {items.length}\n </div>\n <ul className=\"max-h-56 overflow-y-auto\">\n {items.map((item, i) => {\n const active = i === picker.cursor;\n if (picker.kind === \"cmd\") {\n const c = item as PromptCmd;\n return (\n <li\n key={c.name}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`cursor-pointer px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <div className=\"font-mono font-medium text-violet-700 dark:text-violet-300\">\n {c.name}\n </div>\n <div className=\"text-[11px] text-zinc-500\">{c.hint}</div>\n </li>\n );\n }\n const m = item as PromptMention;\n return (\n <li\n key={m.id}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <span\n className=\"h-2 w-2 rounded-full\"\n style={{ backgroundColor: colors[m.kind] ?? \"#71717a\" }}\n />\n <span className=\"font-medium\">{m.name}</span>\n <span className=\"ml-auto text-[10px] uppercase tracking-wider text-zinc-400\">\n {m.kind}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n )}\n </div>\n\n <div className=\"flex items-center gap-2 border-t border-zinc-200 bg-zinc-50/60 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/40\">\n <Tooltip content={attachButton === \"icon\" ? \"Attach files — or drop them here\" : \"Drop files here, or click\"}>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon=\"paperclip\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-attach=\"\"\n // An icon alone has no name; the tooltip is not one a screen reader reads.\n aria-label={attachButton === \"icon\" ? \"Attach files\" : undefined}\n disabled={disabled}\n onClick={() => fileRef.current?.click()}\n >\n {attachButton === \"icon\" ? null : \"attach\"}\n </Button>\n </Tooltip>\n {/*\n The button above shipped with a no-op onClick and a tooltip reading\n \"Drop files here, or click\" — an affordance that lied. Drop-only also\n meant keyboard and touch users could not attach at all.\n\n It then shipped with a literal paperclip EMOJI as its icon, which\n needs a COLOUR\n EMOJI FONT — not merely broad coverage — so a lean container renders a\n tofu box where the affordance should be. `icon=\"paperclip\"` draws an\n SVG from the kit's own icon layer, which is the same reason the rest of\n the suite does not hand-roll iconography.\n */}\n <input\n ref={fileRef}\n type=\"file\"\n multiple\n disabled={disabled}\n className=\"hidden\"\n onChange={(e) => {\n attach(e.target.files);\n // Let the same file be picked twice in a row.\n e.target.value = \"\";\n }}\n />\n {meterLevel !== null && (\n <div\n data-react-fancy-prompt-input-meter=\"\"\n data-level={meterLevel}\n className=\"ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden\"\n >\n <div className=\"h-1.5 w-24 shrink overflow-hidden rounded-full bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\">\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${ratio * 100}%`, backgroundColor: meterColor }}\n />\n </div>\n <span className=\"font-mono text-[11px]\" style={{ color: meterColor }}>\n {fmtTokens(tokens)} / {fmtTokens(budgetTokens)}\n </span>\n </div>\n )}\n <div className=\"ml-auto flex shrink-0 items-center gap-2\">\n {/* With an icon send button the shortcut lives in its tooltip instead. */}\n {showHint && sendButton !== \"icon\" && (\n <span\n className=\"hidden text-[10px] text-zinc-500 sm:inline\"\n data-react-fancy-prompt-input-hint={modKey === \"⌘\" ? \"apple\" : \"generic\"}\n >\n <kbd className=\"rounded border border-[color:var(--fancy-border-strong,var(--color-zinc-300))] bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\">\n {modKey}\n </kbd>{\" \"}\n +{\" \"}\n <kbd className=\"rounded border border-[color:var(--fancy-border-strong,var(--color-zinc-300))] bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\">\n Enter\n </kbd>{\" \"}\n to send\n </span>\n )}\n {sendButton === \"icon\" ? (\n <Tooltip content={`Send · ${modKey}+Enter`}>\n <Button\n color=\"violet\"\n size=\"sm\"\n icon=\"arrow-up\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n aria-label=\"Send\"\n disabled={disabled || sendDisabled}\n loading={submitting}\n aria-busy={submitting || undefined}\n onClick={submit}\n />\n </Tooltip>\n ) : (\n <Button\n color=\"violet\"\n size=\"sm\"\n iconTrailing=\"arrow-right\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n disabled={disabled || sendDisabled}\n loading={submitting}\n aria-busy={submitting || undefined}\n onClick={submit}\n >\n send\n </Button>\n )}\n {ack.status === \"error\" && (\n // Mounted with its text, as `role=\"alert\"` is announced on insertion.\n // The root is positioned, so the clipped box stays inside it.\n <div\n role=\"alert\"\n data-react-fancy-prompt-input-error=\"\"\n className=\"sr-only\"\n style={visuallyHidden}\n >\n {ack.message}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n});\n\n/**\n * Whether two drafts SAY the same thing, for a controlled prop that arrives as\n * a new object: the host echoing what it was told (a spread, a clone) is not a\n * new revision. Every field counts except a file's `ref`, which is where the\n * bytes are stored rather than what the message is. Cheap in the common case:\n * an echo shares its arrays, so the full comparison only runs when they differ.\n */\nfunction sameDraftContent(a: PromptDraft, b: PromptDraft): boolean {\n if (a.text !== b.text) return false;\n if (a.pills === b.pills && a.attachments === b.attachments) return true;\n const key = (d: PromptDraft) =>\n JSON.stringify([\n d.pills.map((p) =>\n p.kind === \"text\" ? [p.kind, p.id, p.text, p.label] : [p.kind, p.id, p.label, fileKey(p.file)],\n ),\n d.attachments.map(fileKey),\n ]);\n return key(a) === key(b);\n}\n\nfunction fileKey(f: PromptDraftFile): unknown[] {\n return [f.id, f.name, f.type, f.bytes];\n}\n\nfunction fmtTokens(n: number): string {\n if (n < 1000) return `${n}`;\n return `${(n / 1000).toFixed(1)}k`;\n}\n\nfunction fmtSize(b: number): string {\n if (b < 1024) return `${b} B`;\n if (b < 1024 * 1024) return `${(b / 1024).toFixed(0)} KB`;\n return `${(b / 1024 / 1024).toFixed(1)} MB`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/QrCode/qr-tables.ts","../src/components/QrCode/qr-encode.ts","../src/components/QrCode/QrCode.tsx"],"names":["dataCodewords"],"mappings":";;;;;AAyBO,IAAM,SAAA,GAA0C,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AA2B1E,IAAM,WAAA,GAAwF;AAAA;AAAA,EAE5F,CAAC,CAAC,EAAA,EAAI,CAAA,EAAG,GAAG,E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,QAAA,EAAA;AAAA,UAAA,UAAA,KAAe,aAAA,wBACb,MAAA,EAAA,EAAK,KAAA,EAAO,QAAQ,MAAA,EAAQ,MAAA,EAAQ,MAAM,UAAA,EAAY,CAAA;AAAA,0BAEzD,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAG,IAAA,EAAM,MAAM,UAAA,EAAY;AAAA;AAAA;AAAA,KACnC;AAAA,EAEJ;AACF;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"chunk-RLE5WYY6.js","sourcesContent":["/**\n * ISO/IEC 18004 table data for the QR encoder. **Data, not logic** — kept in\n * its own module so the algorithm beside it can be read without scrolling past\n * 160 rows, and so a correction here is a diff that cannot touch behaviour.\n *\n * There is no formula for these: the block structure per version and error\n * correction level is a table in the standard. They were taken from the\n * published error-correction table at\n * <https://www.thonky.com/qr-code-tutorial/error-correction-table> rather than\n * recalled, and every row is checked by `qr-code.test.tsx` against three\n * equations that must all hold simultaneously:\n *\n * 1. `dataCodewords === g1Blocks * g1Size + g2Blocks * g2Size`\n * 2. `totalCodewords === dataCodewords + ecPerBlock * (g1Blocks + g2Blocks)`\n * 3. `totalCodewords === rawDataModules(version) / 8`, where\n * `rawDataModules` is counted from the matrix THIS code builds.\n *\n * The third is the one worth having: it ties a transcribed table to an\n * independently constructed matrix, so a mistyped row, a wrong alignment\n * pattern position and a wrong function-pattern layout cannot all agree.\n */\n\n/** Error correction level. Higher levels survive more damage and hold less. */\nexport type QrErrorCorrection = 'L' | 'M' | 'Q' | 'H';\n\nexport const EC_LEVELS: readonly QrErrorCorrection[] = ['L', 'M', 'Q', 'H'];\n\n/** The 2-bit indicator each level carries in the format information. */\nexport const EC_FORMAT_BITS: Record<QrErrorCorrection, number> = {\n L: 0b01,\n M: 0b00,\n Q: 0b11,\n H: 0b10,\n};\n\nexport interface BlockLayout {\n /** Data codewords in the whole symbol. */\n dataCodewords: number;\n /** Error correction codewords per block — the same for every block. */\n ecPerBlock: number;\n /** Blocks in group 1, and how many data codewords each holds. */\n g1Blocks: number;\n g1Size: number;\n /** Blocks in group 2 (always `g1Size + 1` each when present). */\n g2Blocks: number;\n g2Size: number;\n}\n\n/**\n * `[dataCodewords, ecPerBlock, g1Blocks, g1Size, g2Blocks, g2Size]` indexed by\n * `[version - 1]` then by EC level, in `L, M, Q, H` order.\n */\nconst BLOCK_TABLE: readonly (readonly [number, number, number, number, number, number])[][] = [\n // v1\n [[19, 7, 1, 19, 0, 0], [16, 10, 1, 16, 0, 0], [13, 13, 1, 13, 0, 0], [9, 17, 1, 9, 0, 0]],\n [[34, 10, 1, 34, 0, 0], [28, 16, 1, 28, 0, 0], [22, 22, 1, 22, 0, 0], [16, 28, 1, 16, 0, 0]],\n [[55, 15, 1, 55, 0, 0], [44, 26, 1, 44, 0, 0], [34, 18, 2, 17, 0, 0], [26, 22, 2, 13, 0, 0]],\n [[80, 20, 1, 80, 0, 0], [64, 18, 2, 32, 0, 0], [48, 26, 2, 24, 0, 0], [36, 16, 4, 9, 0, 0]],\n [[108, 26, 1, 108, 0, 0], [86, 24, 2, 43, 0, 0], [62, 18, 2, 15, 2, 16], [46, 22, 2, 11, 2, 12]],\n [[136, 18, 2, 68, 0, 0], [108, 16, 4, 27, 0, 0], [76, 24, 4, 19, 0, 0], [60, 28, 4, 15, 0, 0]],\n [[156, 20, 2, 78, 0, 0], [124, 18, 4, 31, 0, 0], [88, 18, 2, 14, 4, 15], [66, 26, 4, 13, 1, 14]],\n [[194, 24, 2, 97, 0, 0], [154, 22, 2, 38, 2, 39], [110, 22, 4, 18, 2, 19], [86, 26, 4, 14, 2, 15]],\n [[232, 30, 2, 116, 0, 0], [182, 22, 3, 36, 2, 37], [132, 20, 4, 16, 4, 17], [100, 24, 4, 12, 4, 13]],\n // v10\n [[274, 18, 2, 68, 2, 69], [216, 26, 4, 43, 1, 44], [154, 24, 6, 19, 2, 20], [122, 28, 6, 15, 2, 16]],\n [[324, 20, 4, 81, 0, 0], [254, 30, 1, 50, 4, 51], [180, 28, 4, 22, 4, 23], [140, 24, 3, 12, 8, 13]],\n [[370, 24, 2, 92, 2, 93], [290, 22, 6, 36, 2, 37], [206, 26, 4, 20, 6, 21], [158, 28, 7, 14, 4, 15]],\n [[428, 26, 4, 107, 0, 0], [334, 22, 8, 37, 1, 38], [244, 24, 8, 20, 4, 21], [180, 22, 12, 11, 4, 12]],\n [[461, 30, 3, 115, 1, 116], [365, 24, 4, 40, 5, 41], [261, 20, 11, 16, 5, 17], [197, 24, 11, 12, 5, 13]],\n [[523, 22, 5, 87, 1, 88], [415, 24, 5, 41, 5, 42], [295, 30, 5, 24, 7, 25], [223, 24, 11, 12, 7, 13]],\n [[589, 24, 5, 98, 1, 99], [453, 28, 7, 45, 3, 46], [325, 24, 15, 19, 2, 20], [253, 30, 3, 15, 13, 16]],\n [[647, 28, 1, 107, 5, 108], [507, 28, 10, 46, 1, 47], [367, 28, 1, 22, 15, 23], [283, 28, 2, 14, 17, 15]],\n [[721, 30, 5, 120, 1, 121], [563, 26, 9, 43, 4, 44], [397, 28, 17, 22, 1, 23], [313, 28, 2, 14, 19, 15]],\n [[795, 28, 3, 113, 4, 114], [627, 26, 3, 44, 11, 45], [445, 26, 17, 21, 4, 22], [341, 26, 9, 13, 16, 14]],\n // v20\n [[861, 28, 3, 107, 5, 108], [669, 26, 3, 41, 13, 42], [485, 30, 15, 24, 5, 25], [385, 28, 15, 15, 10, 16]],\n [[932, 28, 4, 116, 4, 117], [714, 26, 17, 42, 0, 0], [512, 28, 17, 22, 6, 23], [406, 30, 19, 16, 6, 17]],\n [[1006, 28, 2, 111, 7, 112], [782, 28, 17, 46, 0, 0], [568, 30, 7, 24, 16, 25], [442, 24, 34, 13, 0, 0]],\n [[1094, 30, 4, 121, 5, 122], [860, 28, 4, 47, 14, 48], [614, 30, 11, 24, 14, 25], [464, 30, 16, 15, 14, 16]],\n [[1174, 30, 6, 117, 4, 118], [914, 28, 6, 45, 14, 46], [664, 30, 11, 24, 16, 25], [514, 30, 30, 16, 2, 17]],\n [[1276, 26, 8, 106, 4, 107], [1000, 28, 8, 47, 13, 48], [718, 30, 7, 24, 22, 25], [538, 30, 22, 15, 13, 16]],\n [[1370, 28, 10, 114, 2, 115], [1062, 28, 19, 46, 4, 47], [754, 28, 28, 22, 6, 23], [596, 30, 33, 16, 4, 17]],\n [[1468, 30, 8, 122, 4, 123], [1128, 28, 22, 45, 3, 46], [808, 30, 8, 23, 26, 24], [628, 30, 12, 15, 28, 16]],\n [[1531, 30, 3, 117, 10, 118], [1193, 28, 3, 45, 23, 46], [871, 30, 4, 24, 31, 25], [661, 30, 11, 15, 31, 16]],\n [[1631, 30, 7, 116, 7, 117], [1267, 28, 21, 45, 7, 46], [911, 30, 1, 23, 37, 24], [701, 30, 19, 15, 26, 16]],\n // v30\n [[1735, 30, 5, 115, 10, 116], [1373, 28, 19, 47, 10, 48], [985, 30, 15, 24, 25, 25], [745, 30, 23, 15, 25, 16]],\n [[1843, 30, 13, 115, 3, 116], [1455, 28, 2, 46, 29, 47], [1033, 30, 42, 24, 1, 25], [793, 30, 23, 15, 28, 16]],\n [[1955, 30, 17, 115, 0, 0], [1541, 28, 10, 46, 23, 47], [1115, 30, 10, 24, 35, 25], [845, 30, 19, 15, 35, 16]],\n [[2071, 30, 17, 115, 1, 116], [1631, 28, 14, 46, 21, 47], [1171, 30, 29, 24, 19, 25], [901, 30, 11, 15, 46, 16]],\n [[2191, 30, 13, 115, 6, 116], [1725, 28, 14, 46, 23, 47], [1231, 30, 44, 24, 7, 25], [961, 30, 59, 16, 1, 17]],\n [[2306, 30, 12, 121, 7, 122], [1812, 28, 12, 47, 26, 48], [1286, 30, 39, 24, 14, 25], [986, 30, 22, 15, 41, 16]],\n [[2434, 30, 6, 121, 14, 122], [1914, 28, 6, 47, 34, 48], [1354, 30, 46, 24, 10, 25], [1054, 30, 2, 15, 64, 16]],\n [[2566, 30, 17, 122, 4, 123], [1992, 28, 29, 46, 14, 47], [1426, 30, 49, 24, 10, 25], [1096, 30, 24, 15, 46, 16]],\n [[2702, 30, 4, 122, 18, 123], [2102, 28, 13, 46, 32, 47], [1502, 30, 48, 24, 14, 25], [1142, 30, 42, 15, 32, 16]],\n [[2812, 30, 20, 117, 4, 118], [2216, 28, 40, 47, 7, 48], [1582, 30, 43, 24, 22, 25], [1222, 30, 10, 15, 67, 16]],\n // v40\n [[2956, 30, 19, 118, 6, 119], [2334, 28, 18, 47, 31, 48], [1666, 30, 34, 24, 34, 25], [1276, 30, 20, 15, 61, 16]],\n];\n\nexport const MIN_VERSION = 1;\nexport const MAX_VERSION = 40;\n\n/** Block structure for a version and error correction level. */\nexport function blockLayout(version: number, ec: QrErrorCorrection): BlockLayout {\n const row = BLOCK_TABLE[version - 1]?.[EC_LEVELS.indexOf(ec)];\n if (!row) {\n throw new RangeError(`No block layout for version ${version} level ${ec}`);\n }\n const [dataCodewords, ecPerBlock, g1Blocks, g1Size, g2Blocks, g2Size] = row;\n return { dataCodewords, ecPerBlock, g1Blocks, g1Size, g2Blocks, g2Size };\n}\n\n/**\n * The 15-bit format information for a level and mask, as published.\n *\n * These are a BCH(15,5) code XOR'd with a fixed mask, so they could be\n * computed — and the first draft did compute them. They are listed instead\n * because the computation and its verification would then share one\n * implementation: a wrong generator polynomial would produce a wrong table and\n * a test that agreed with it. A transcribed table cannot agree with a bug.\n *\n * Source: <https://www.thonky.com/qr-code-tutorial/format-version-tables>.\n * Indexed `[level][mask]`.\n */\nexport const FORMAT_BITS: Record<QrErrorCorrection, readonly number[]> = {\n L: [\n 0b111011111000100, 0b111001011110011, 0b111110110101010, 0b111100010011101,\n 0b110011000101111, 0b110001100011000, 0b110110001000001, 0b110100101110110,\n ],\n M: [\n 0b101010000010010, 0b101000100100101, 0b101111001111100, 0b101101101001011,\n 0b100010111111001, 0b100000011001110, 0b100111110010111, 0b100101010100000,\n ],\n Q: [\n 0b011010101011111, 0b011000001101000, 0b011111100110001, 0b011101000000110,\n 0b010010010110100, 0b010000110000011, 0b010111011011010, 0b010101111101101,\n ],\n H: [\n 0b001011010001001, 0b001001110111110, 0b001110011100111, 0b001100111010000,\n 0b000011101100010, 0b000001001010101, 0b000110100001100, 0b000100000111011,\n ],\n};\n\n/**\n * The 18-bit version information, present only for versions 7 and up.\n *\n * A BCH(18,6) code. Computed rather than tabled — 34 rows of 18 bits is more\n * transcription risk than the arithmetic is, and unlike the format bits there\n * are published values for versions 7, 8, 9, 10 and 40 to check it against,\n * which the test does.\n */\nexport function versionBits(version: number): number {\n let remainder = version;\n for (let i = 0; i < 12; i += 1) {\n remainder = (remainder << 1) ^ ((remainder >>> 11) * 0b1111100100101);\n }\n return ((version << 12) | remainder) >>> 0;\n}\n\n/**\n * Centre coordinates of the alignment patterns for a version.\n *\n * Derived rather than tabled, and the derivation is checked by the codeword\n * count equation in the test: a wrong position changes how many modules are\n * free for data, so the count would not match the block table.\n *\n * Version 32 is a genuine special case in the standard — its spacing does not\n * follow the rule the other versions do.\n */\nexport function alignmentPositions(version: number): number[] {\n if (version === 1) {\n return [];\n }\n const count = Math.floor(version / 7) + 2;\n const size = version * 4 + 17;\n const step = version === 32 ? 26 : Math.ceil((size - 13) / (count * 2 - 2)) * 2;\n\n const positions = [6];\n for (let pos = size - 7; positions.length < count; pos -= step) {\n positions.unshift(pos);\n }\n return positions.sort((a, b) => a - b);\n}\n","/**\n * A QR encoder, dependency-free.\n *\n * ISO/IEC 18004, versions 1–40, error correction L/M/Q/H, with numeric,\n * alphanumeric and byte modes and automatic selection between them. No\n * Kanji mode and no structured append — neither has a caller here, and an\n * untested branch in an encoder is worse than an absent one because the\n * failure is a code a phone silently refuses to read.\n *\n * Table data and its provenance live in `./qr-tables`.\n */\nimport {\n EC_FORMAT_BITS,\n FORMAT_BITS,\n MAX_VERSION,\n MIN_VERSION,\n alignmentPositions,\n blockLayout,\n versionBits,\n type QrErrorCorrection,\n} from './qr-tables';\n\nexport type { QrErrorCorrection };\n\n/** Which encoding mode a value is carried in. */\nexport type QrMode = 'numeric' | 'alphanumeric' | 'byte';\n\nconst MODE_INDICATOR: Record<QrMode, number> = { numeric: 0b0001, alphanumeric: 0b0010, byte: 0b0100 };\n\n/** The character set alphanumeric mode can carry, in its own index order. */\nconst ALPHANUMERIC = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n\nexport interface QrSymbol {\n /** `size * size` modules, row-major. `true` is dark. */\n modules: boolean[][];\n /** Modules per side, `version * 4 + 17`. */\n size: number;\n version: number;\n errorCorrection: QrErrorCorrection;\n mode: QrMode;\n /** The mask pattern chosen by penalty scoring, 0–7. */\n mask: number;\n}\n\n// --- Galois field GF(256) --------------------------------------------------\n// Reed-Solomon over the field the standard specifies: primitive polynomial\n// x^8 + x^4 + x^3 + x^2 + 1 (0x11d), generator 2.\n\nconst EXP = new Uint8Array(256);\nconst LOG = new Uint8Array(256);\n{\n let x = 1;\n for (let i = 0; i < 255; i += 1) {\n EXP[i] = x;\n LOG[x] = i;\n x <<= 1;\n if (x & 0x100) {\n x ^= 0x11d;\n }\n }\n EXP[255] = EXP[0] as number;\n}\n\nfunction gfMul(a: number, b: number): number {\n if (a === 0 || b === 0) {\n return 0;\n }\n return EXP[((LOG[a] as number) + (LOG[b] as number)) % 255] as number;\n}\n\n/** The generator polynomial for `degree` error correction codewords. */\nfunction generatorPoly(degree: number): number[] {\n let poly = [1];\n for (let i = 0; i < degree; i += 1) {\n const next = new Array<number>(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j += 1) {\n next[j] = (next[j] as number) ^ (poly[j] as number);\n next[j + 1] = (next[j + 1] as number) ^ gfMul(poly[j] as number, EXP[i] as number);\n }\n poly = next;\n }\n return poly;\n}\n\n/** Reed-Solomon remainder — the error correction codewords for one block. */\nfunction reedSolomon(data: readonly number[], degree: number): number[] {\n const generator = generatorPoly(degree);\n const remainder = new Array<number>(degree).fill(0);\n for (const byte of data) {\n const factor = byte ^ (remainder.shift() as number);\n remainder.push(0);\n for (let i = 0; i < degree; i += 1) {\n remainder[i] = (remainder[i] as number) ^ gfMul(generator[i + 1] as number, factor);\n }\n }\n return remainder;\n}\n\n// --- Mode selection and bit encoding ---------------------------------------\n\n/**\n * The narrowest mode that can carry `value`.\n *\n * Narrower is denser: numeric packs 3 digits into 10 bits where byte mode\n * would spend 24. A six-digit pairing PIN is a third of the size as numeric,\n * which is the difference between a code a phone reads across a desk and one\n * it does not.\n */\nexport function selectMode(value: string): QrMode {\n if (/^[0-9]*$/.test(value)) {\n return 'numeric';\n }\n if ([...value].every((char) => ALPHANUMERIC.includes(char))) {\n return 'alphanumeric';\n }\n return 'byte';\n}\n\n/** Bits in the character count indicator — it widens with version. */\nfunction countBits(mode: QrMode, version: number): number {\n const tier = version <= 9 ? 0 : version <= 26 ? 1 : 2;\n if (mode === 'numeric') {\n return [10, 12, 14][tier] as number;\n }\n if (mode === 'alphanumeric') {\n return [9, 11, 13][tier] as number;\n }\n return [8, 16, 16][tier] as number;\n}\n\nclass BitBuffer {\n readonly bits: number[] = [];\n\n push(value: number, length: number): void {\n for (let i = length - 1; i >= 0; i -= 1) {\n this.bits.push((value >>> i) & 1);\n }\n }\n}\n\n/** UTF-8 bytes for a string, without TextEncoder — jsdom and SSR both agree. */\nfunction utf8Bytes(value: string): number[] {\n const out: number[] = [];\n for (const char of value) {\n const code = char.codePointAt(0) as number;\n if (code < 0x80) {\n out.push(code);\n } else if (code < 0x800) {\n out.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f));\n } else if (code < 0x10000) {\n out.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));\n } else {\n out.push(\n 0xf0 | (code >> 18),\n 0x80 | ((code >> 12) & 0x3f),\n 0x80 | ((code >> 6) & 0x3f),\n 0x80 | (code & 0x3f),\n );\n }\n }\n return out;\n}\n\n/** The payload's own bits, before terminator and padding. */\nfunction encodePayload(value: string, mode: QrMode, version: number): BitBuffer {\n const buffer = new BitBuffer();\n buffer.push(MODE_INDICATOR[mode], 4);\n\n if (mode === 'numeric') {\n buffer.push(value.length, countBits(mode, version));\n for (let i = 0; i < value.length; i += 3) {\n const group = value.slice(i, i + 3);\n buffer.push(Number.parseInt(group, 10), group.length * 3 + 1);\n }\n return buffer;\n }\n\n if (mode === 'alphanumeric') {\n buffer.push(value.length, countBits(mode, version));\n for (let i = 0; i < value.length; i += 2) {\n const first = ALPHANUMERIC.indexOf(value[i] as string);\n if (i + 1 < value.length) {\n buffer.push(first * 45 + ALPHANUMERIC.indexOf(value[i + 1] as string), 11);\n } else {\n buffer.push(first, 6);\n }\n }\n return buffer;\n }\n\n const bytes = utf8Bytes(value);\n buffer.push(bytes.length, countBits(mode, version));\n for (const byte of bytes) {\n buffer.push(byte, 8);\n }\n return buffer;\n}\n\n/** How many bits the payload needs at a given version, mode included. */\nfunction payloadBits(value: string, mode: QrMode, version: number): number {\n return encodePayload(value, mode, version).bits.length;\n}\n\n/**\n * The most characters any mode can carry, at version 40 level L.\n *\n * DERIVED from the block table rather than transcribed, so it cannot disagree\n * with the capacities the encoder actually enforces. (The published figures\n * are 7089 / 4296 / 2953, and the test asserts these match them.)\n */\nexport function maxCharacters(mode: QrMode): number {\n const bits = blockLayout(MAX_VERSION, 'L').dataCodewords * 8 - 4 - countBits(mode, MAX_VERSION);\n if (mode === 'numeric') {\n return Math.floor((bits * 3) / 10);\n }\n if (mode === 'alphanumeric') {\n return Math.floor((bits * 2) / 11);\n }\n return Math.floor(bits / 8);\n}\n\n/** The largest capacity of any mode — the cheapest possible rejection. */\nconst ABSOLUTE_MAX_CHARACTERS = maxCharacters('numeric');\n\n/**\n * Reject an impossible value in O(1), before anything walks it.\n *\n * `value` is text this code did not author, and it reaches consumers two ways:\n * the package, and as VENDORED SOURCE via `fancy-cli add qr-code` — which\n * carries no manifest, so nothing watches it. So the question is what a hostile\n * caller gets out of it, and the answer used to be: a lot of work for free.\n *\n * `selectVersion` walks versions 1-40 and re-encoded the payload at each one,\n * so a value too long to fit was encoded FORTY times before being refused.\n * Measured on the built bundle: 342 ms for 100 kB, 2.0 s for 500 kB, linear —\n * so a few megabytes through `<QrCode value={userInput} />` blocks the main\n * thread for tens of seconds. The refusal was always correct; it was the COST\n * of the refusal that was the defect.\n *\n * A character count can only ever be <= the byte count, so a string longer than\n * the largest capacity cannot fit in any mode and is refused from `.length`\n * alone, touching none of it.\n */\nfunction tooLongToFit(value: string, mode: QrMode | null): boolean {\n if (value.length > ABSOLUTE_MAX_CHARACTERS) {\n return true;\n }\n return mode !== null && value.length > maxCharacters(mode);\n}\n\n/** The smallest version that fits, or `null` when nothing does. */\nfunction selectVersion(\n value: string,\n mode: QrMode,\n ec: QrErrorCorrection,\n minVersion: number,\n): number | null {\n // The payload's bit length depends on the version ONLY through the width of\n // the character-count indicator, which has three tiers. So it is computed at\n // most three times rather than once per version — which also makes the\n // legitimate path cheaper for a large value, not just the hostile one.\n const bitsForTier = new Map<number, number>();\n for (let version = Math.max(minVersion, MIN_VERSION); version <= MAX_VERSION; version += 1) {\n const width = countBits(mode, version);\n let bits = bitsForTier.get(width);\n if (bits === undefined) {\n bits = payloadBits(value, mode, version);\n bitsForTier.set(width, bits);\n }\n if (bits <= blockLayout(version, ec).dataCodewords * 8) {\n return version;\n }\n }\n return null;\n}\n\n/**\n * Data codewords: payload, terminator, pad to a byte, then alternating pad\n * bytes. Exported for the golden-vector test, which asserts these against the\n * standard's published worked example.\n */\nexport function dataCodewords(value: string, mode: QrMode, version: number, ec: QrErrorCorrection): number[] {\n const capacity = blockLayout(version, ec).dataCodewords * 8;\n const buffer = encodePayload(value, mode, version);\n\n // Terminator: up to four zero bits, truncated if capacity runs out.\n buffer.push(0, Math.min(4, capacity - buffer.bits.length));\n // Then to a byte boundary.\n buffer.push(0, (8 - (buffer.bits.length % 8)) % 8);\n\n const codewords: number[] = [];\n for (let i = 0; i < buffer.bits.length; i += 8) {\n let byte = 0;\n for (let bit = 0; bit < 8; bit += 1) {\n byte = (byte << 1) | (buffer.bits[i + bit] as number);\n }\n codewords.push(byte);\n }\n\n // Pad bytes 0b11101100 / 0b00010001, alternating, as the standard specifies.\n const target = capacity / 8;\n for (let i = 0; codewords.length < target; i += 1) {\n codewords.push(i % 2 === 0 ? 0xec : 0x11);\n }\n return codewords;\n}\n\n/**\n * Split into blocks, compute error correction, and interleave.\n *\n * Interleaving is what makes the error correction work as advertised: a blot\n * on the printed symbol damages a contiguous run of modules, and interleaving\n * spreads that run across every block so no single block exceeds its own\n * correction budget. Concatenating instead would produce a scannable code that\n * fails far sooner than its level claims — passing a round-trip test and\n * failing on paper.\n */\nexport function interleave(codewords: readonly number[], version: number, ec: QrErrorCorrection): number[] {\n const { ecPerBlock, g1Blocks, g1Size, g2Blocks, g2Size } = blockLayout(version, ec);\n\n const dataBlocks: number[][] = [];\n let offset = 0;\n for (let i = 0; i < g1Blocks; i += 1) {\n dataBlocks.push(codewords.slice(offset, offset + g1Size));\n offset += g1Size;\n }\n for (let i = 0; i < g2Blocks; i += 1) {\n dataBlocks.push(codewords.slice(offset, offset + g2Size));\n offset += g2Size;\n }\n\n const ecBlocks = dataBlocks.map((block) => reedSolomon(block, ecPerBlock));\n\n const result: number[] = [];\n const widest = Math.max(g1Size, g2Blocks > 0 ? g2Size : 0);\n for (let i = 0; i < widest; i += 1) {\n for (const block of dataBlocks) {\n if (i < block.length) {\n result.push(block[i] as number);\n }\n }\n }\n for (let i = 0; i < ecPerBlock; i += 1) {\n for (const block of ecBlocks) {\n result.push(block[i] as number);\n }\n }\n return result;\n}\n\n// --- Matrix construction ---------------------------------------------------\n\nexport type Grid = (boolean | null)[][];\n\n/**\n * A grid with every function pattern placed and data positions left `null`.\n *\n * Exported for verification. The round-trip decoder in the test needs to know\n * which modules carry data, and reconstructing that knowledge separately would\n * duplicate the layout and share its bugs. Using the same template is safe\n * here because the table-consistency check anchors it to an independent fact:\n * the number of free modules must equal the codeword count in the transcribed\n * block table, so a wrong finder, timing or alignment layout fails there.\n */\nexport function reservedModules(version: number): Grid {\n const size = version * 4 + 17;\n const grid: Grid = Array.from({ length: size }, () => new Array<boolean | null>(size).fill(null));\n\n const set = (row: number, col: number, dark: boolean): void => {\n (grid[row] as (boolean | null)[])[col] = dark;\n };\n\n // Three finder patterns with their separators.\n for (const [baseRow, baseCol] of [\n [0, 0],\n [0, size - 7],\n [size - 7, 0],\n ] as const) {\n for (let row = -1; row <= 7; row += 1) {\n for (let col = -1; col <= 7; col += 1) {\n const r = baseRow + row;\n const c = baseCol + col;\n if (r < 0 || r >= size || c < 0 || c >= size) {\n continue;\n }\n const ring = Math.max(Math.abs(row - 3), Math.abs(col - 3));\n set(r, c, ring !== 2 && ring <= 3);\n }\n }\n }\n\n // Timing patterns, row and column 6.\n for (let i = 0; i < size; i += 1) {\n if ((grid[6] as (boolean | null)[])[i] === null) {\n set(6, i, i % 2 === 0);\n }\n if ((grid[i] as (boolean | null)[])[6] === null) {\n set(i, 6, i % 2 === 0);\n }\n }\n\n // Alignment patterns, except where a finder already sits.\n const positions = alignmentPositions(version);\n for (const row of positions) {\n for (const col of positions) {\n const nearFinder =\n (row <= 8 && col <= 8) || (row <= 8 && col >= size - 9) || (row >= size - 9 && col <= 8);\n if (nearFinder) {\n continue;\n }\n for (let dr = -2; dr <= 2; dr += 1) {\n for (let dc = -2; dc <= 2; dc += 1) {\n const ring = Math.max(Math.abs(dr), Math.abs(dc));\n set(row + dr, col + dc, ring !== 1);\n }\n }\n }\n }\n\n // Format information areas, reserved now and written after masking. The\n // module at (size - 8, 8) is always dark.\n for (let i = 0; i < 9; i += 1) {\n if ((grid[8] as (boolean | null)[])[i] === null) {\n set(8, i, false);\n }\n if ((grid[i] as (boolean | null)[])[8] === null) {\n set(i, 8, false);\n }\n }\n for (let i = 0; i < 8; i += 1) {\n set(8, size - 1 - i, false);\n set(size - 1 - i, 8, false);\n }\n set(size - 8, 8, true);\n\n // Version information, versions 7 and up.\n if (version >= 7) {\n const bits = versionBits(version);\n for (let i = 0; i < 18; i += 1) {\n const bit = ((bits >>> i) & 1) === 1;\n set(Math.floor(i / 3), size - 11 + (i % 3), bit);\n set(size - 11 + (i % 3), Math.floor(i / 3), bit);\n }\n }\n\n return grid;\n}\n\n/** How many modules a version leaves free for data, counted from the grid. */\nexport function rawDataModules(version: number): number {\n const grid = reservedModules(version);\n let free = 0;\n for (const row of grid) {\n for (const cell of row) {\n if (cell === null) {\n free += 1;\n }\n }\n }\n return free;\n}\n\n/** Place the interleaved codewords in the standard's zigzag order. */\nfunction placeData(grid: Grid, codewords: readonly number[]): void {\n const size = grid.length;\n let bitIndex = 0;\n const nextBit = (): boolean => {\n const byte = codewords[bitIndex >>> 3];\n // Past the end is a remainder bit: light, per the standard.\n const bit = byte === undefined ? 0 : (byte >>> (7 - (bitIndex & 7))) & 1;\n bitIndex += 1;\n return bit === 1;\n };\n\n let upward = true;\n for (let right = size - 1; right >= 1; right -= 2) {\n // Column 6 is the vertical timing pattern; the pair of columns skips it.\n const pair = right === 6 ? [5, 4] : [right, right - 1];\n for (let step = 0; step < size; step += 1) {\n const row = upward ? size - 1 - step : step;\n for (const col of pair) {\n if ((grid[row] as (boolean | null)[])[col] === null) {\n (grid[row] as (boolean | null)[])[col] = nextBit();\n }\n }\n }\n if (right === 6) {\n right -= 1;\n }\n upward = !upward;\n }\n}\n\n/** The eight mask conditions. `true` means invert this module. */\nfunction maskCondition(mask: number, row: number, col: number): boolean {\n switch (mask) {\n case 0:\n return (row + col) % 2 === 0;\n case 1:\n return row % 2 === 0;\n case 2:\n return col % 3 === 0;\n case 3:\n return (row + col) % 3 === 0;\n case 4:\n return (Math.floor(row / 2) + Math.floor(col / 3)) % 2 === 0;\n case 5:\n return ((row * col) % 2) + ((row * col) % 3) === 0;\n case 6:\n return (((row * col) % 2) + ((row * col) % 3)) % 2 === 0;\n default:\n return (((row + col) % 2) + ((row * col) % 3)) % 2 === 0;\n }\n}\n\n/**\n * The four penalty rules, scored on a finished candidate.\n *\n * This is the step that is easy to skip and expensive to skip: the rules exist\n * because some masks leave large light or dark areas, or patterns that look\n * like a finder, and a decoder locks onto the wrong feature. A symbol with a\n * badly chosen mask still decodes in software and fails under a phone camera —\n * which is the worst possible place for it to fail, because every test here\n * would pass.\n */\nexport function penalty(modules: readonly boolean[][]): number {\n const size = modules.length;\n let score = 0;\n\n // Rule 1: runs of five or more same-coloured modules in a line.\n const scoreLine = (run: number): number => (run >= 5 ? run - 2 : 0);\n for (let i = 0; i < size; i += 1) {\n for (const horizontal of [true, false]) {\n let run = 1;\n for (let j = 1; j < size; j += 1) {\n const prev = horizontal\n ? (modules[i] as boolean[])[j - 1]\n : (modules[j - 1] as boolean[])[i];\n const cur = horizontal ? (modules[i] as boolean[])[j] : (modules[j] as boolean[])[i];\n if (cur === prev) {\n run += 1;\n } else {\n score += scoreLine(run);\n run = 1;\n }\n }\n score += scoreLine(run);\n }\n }\n\n // Rule 2: every 2x2 block of one colour.\n for (let row = 0; row < size - 1; row += 1) {\n for (let col = 0; col < size - 1; col += 1) {\n const a = (modules[row] as boolean[])[col];\n if (\n a === (modules[row] as boolean[])[col + 1] &&\n a === (modules[row + 1] as boolean[])[col] &&\n a === (modules[row + 1] as boolean[])[col + 1]\n ) {\n score += 3;\n }\n }\n }\n\n // Rule 3: the finder-like 1:1:3:1:1 pattern with four light modules either\n // side. This is the rule that protects a decoder's pattern detection.\n const finderish = [true, false, true, true, true, false, true];\n const light4 = [false, false, false, false];\n const matches = (line: readonly boolean[], at: number, pattern: readonly boolean[]): boolean =>\n pattern.every((want, i) => line[at + i] === want);\n for (let i = 0; i < size; i += 1) {\n const row = modules[i] as boolean[];\n const col = modules.map((r) => (r as boolean[])[i] as boolean);\n for (const line of [row, col]) {\n for (let j = 0; j + 7 <= size; j += 1) {\n if (!matches(line, j, finderish)) {\n continue;\n }\n // Each ELEVEN-module window counts separately, so a pattern with four\n // light modules on BOTH sides scores 80 rather than 40.\n //\n // The prose rule (\"add 40 each time the pattern appears with four\n // light modules on either side\") is ambiguous about that case, and it\n // matters: this score is what picks the mask, and the wrong mask\n // produces a symbol that decodes perfectly in software and reads badly\n // under a camera. No test here can catch that -- so the convention is\n // pinned by a test instead, and this follows the one the reference\n // implementations use rather than the reading that happened to come\n // first.\n if (j >= 4 && matches(line, j - 4, light4)) {\n score += 40;\n }\n if (j + 11 <= size && matches(line, j + 7, light4)) {\n score += 40;\n }\n }\n }\n }\n\n // Rule 4: deviation of the dark-module proportion from 50%.\n let dark = 0;\n for (const row of modules) {\n for (const cell of row) {\n if (cell) {\n dark += 1;\n }\n }\n }\n const percent = (dark * 100) / (size * size);\n score += Math.floor(Math.abs(percent - 50) / 5) * 10;\n\n return score;\n}\n\n/** Write the 15 format bits into both of their locations. */\nfunction applyFormat(modules: boolean[][], ec: QrErrorCorrection, mask: number): void {\n const size = modules.length;\n const bits = (FORMAT_BITS[ec][mask] as number) >>> 0;\n const bit = (i: number): boolean => ((bits >>> i) & 1) === 1;\n\n // Bits 0-5 up the left column, bit 6 at (8,7)... the split placement is the\n // standard's, not a simplification of it.\n for (let i = 0; i <= 5; i += 1) {\n (modules[8] as boolean[])[i] = bit(14 - i);\n }\n (modules[8] as boolean[])[7] = bit(8);\n (modules[8] as boolean[])[8] = bit(7);\n (modules[7] as boolean[])[8] = bit(6);\n for (let i = 9; i <= 14; i += 1) {\n (modules[14 - i] as boolean[])[8] = bit(14 - i);\n }\n\n // The second copy, split across the other two corners: SEVEN modules up the\n // column beside the bottom-left finder, then EIGHT along the row beside the\n // top-right one.\n //\n // The 7/8 split is not arbitrary and getting it wrong is quiet. An 8/7 split\n // puts bit 7 at (size - 8, 8) -- which is the dark module, overwritten on\n // the next line -- so the symbol still decodes from the FIRST copy and\n // carries a corrupt second one. A reader that happens to use the second copy\n // refuses the symbol, and nothing in a round-trip test notices, because a\n // decoder reading the first copy never looks.\n for (let i = 0; i <= 6; i += 1) {\n (modules[size - 1 - i] as boolean[])[8] = bit(i);\n }\n for (let i = 7; i <= 14; i += 1) {\n (modules[8] as boolean[])[size - 15 + i] = bit(i);\n }\n (modules[size - 8] as boolean[])[8] = true;\n}\n\nexport interface EncodeOptions {\n errorCorrection?: QrErrorCorrection;\n /** Force a mode instead of selecting the narrowest that fits. */\n mode?: QrMode;\n /** Force a version. Throws if the value does not fit. */\n version?: number;\n /** Force a mask instead of scoring all eight. For tests and golden vectors. */\n mask?: number;\n}\n\n/**\n * Encode a string into a QR symbol.\n *\n * @throws RangeError when the value cannot fit, or when a forced version is\n * too small for it. **Throwing is deliberate**: the alternative is returning\n * a truncated symbol, which scans cleanly and yields the wrong string — a\n * silent corruption on the one surface whose entire job is to carry a value\n * accurately.\n */\nexport function encodeQr(value: string, options: EncodeOptions = {}): QrSymbol {\n const ec = options.errorCorrection ?? 'M';\n\n // Before `selectMode`, which walks the whole string. See `tooLongToFit`:\n // this is the difference between refusing a 5 MB value instantly and\n // spending tens of seconds on the main thread to reach the same answer.\n if (tooLongToFit(value, options.mode ?? null)) {\n throw new RangeError(\n `Value is too long for a QR code (${value.length} characters; the maximum any mode can carry is ${ABSOLUTE_MAX_CHARACTERS})`,\n );\n }\n\n const mode = options.mode ?? selectMode(value);\n if (tooLongToFit(value, mode)) {\n throw new RangeError(\n `Value is too long for a QR code in ${mode} mode (${value.length} characters; the maximum is ${maxCharacters(mode)})`,\n );\n }\n\n if (mode === 'numeric' && !/^[0-9]*$/.test(value)) {\n throw new RangeError('Numeric mode accepts digits only');\n }\n if (mode === 'alphanumeric' && ![...value].every((char) => ALPHANUMERIC.includes(char))) {\n throw new RangeError('Alphanumeric mode accepts 0-9 A-Z space and $%*+-./: only');\n }\n\n let version: number;\n if (options.version !== undefined) {\n if (options.version < MIN_VERSION || options.version > MAX_VERSION) {\n throw new RangeError(`Version must be ${MIN_VERSION}-${MAX_VERSION}`);\n }\n version = options.version;\n if (payloadBits(value, mode, version) > blockLayout(version, ec).dataCodewords * 8) {\n throw new RangeError(`Value does not fit in version ${version} at level ${ec}`);\n }\n } else {\n const chosen = selectVersion(value, mode, ec, MIN_VERSION);\n if (chosen === null) {\n throw new RangeError(\n `Value is too long for a QR code at level ${ec} (${value.length} characters)`,\n );\n }\n version = chosen;\n }\n\n const codewords = interleave(dataCodewords(value, mode, version, ec), version, ec);\n const template = reservedModules(version);\n\n const candidates: { mask: number; modules: boolean[][] }[] = [];\n const masksToTry = options.mask === undefined ? [0, 1, 2, 3, 4, 5, 6, 7] : [options.mask];\n for (const mask of masksToTry) {\n const grid = template.map((row) => [...row]);\n placeData(grid, codewords);\n const modules = grid.map((row, rowIndex) =>\n row.map((cell, colIndex) => {\n const value_ = cell as boolean;\n // Only data modules are masked; function patterns never are, which is\n // why the mask is applied against the TEMPLATE's null positions rather\n // than against the finished grid.\n const isData = (template[rowIndex] as (boolean | null)[])[colIndex] === null;\n return isData && maskCondition(mask, rowIndex, colIndex) ? !value_ : value_;\n }),\n );\n applyFormat(modules, ec, mask);\n candidates.push({ mask, modules });\n }\n\n const best = candidates.reduce((a, b) => (penalty(a.modules) <= penalty(b.modules) ? a : b));\n\n return {\n modules: best.modules,\n size: version * 4 + 17,\n version,\n errorCorrection: ec,\n mode,\n mask: best.mask,\n };\n}\n","import { forwardRef, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { encodeQr } from \"./qr-encode\";\nimport type { QrCodeProps } from \"./QrCode.types\";\n\n/**\n * A QR code, as an SVG, with no dependencies.\n *\n * ## Why SVG and one path\n *\n * The symbol is drawn as a **single `<path>`** of one-unit squares on a\n * `viewBox` sized in modules, not as a grid of `<rect>` elements. A version 10\n * symbol is 57x57 — over three thousand modules — and a rect each would be\n * three thousand DOM nodes for something that never changes. One path is one\n * node, and because the viewBox is in module units the symbol is resolution\n * independent: `size` scales it with no resampling, so it stays crisp at any\n * size and prints at the printer's resolution rather than the screen's.\n *\n * This matters more than it sounds for scanning. A raster QR code scaled to a\n * non-integer multiple of its module size gets blurred module edges, and a\n * scanner reading a blurred edge guesses. Vector output cannot have that\n * problem.\n *\n * ## `value` is any string — this is not a link component\n *\n * A QR code is a byte container, and most of what belongs in one is not a web\n * address: a serial or asset number, a lot code, a ticket id, a WiFi\n * credential block, a contact card, a `tel:` or `geo:` URI, plain text. Those\n * are the cases where the format earns its place, because they need no network\n * at all — the scanner reads the value and that IS the payload.\n *\n * ## It is an image of a value, not the value\n *\n * A QR code is unreadable to anyone without a second device pointed at the\n * screen — which includes every screen-reader user and anyone whose phone is\n * the device showing it. So `label` is required, and the value should ALSO be\n * selectable text beside it. A panel that shows only a code is one some people\n * cannot use at all.\n *\n * @example\n * ```tsx\n * // Any string. A digits-only value is numeric mode and a third the size.\n * <QrCode value=\"SN-4829-13\" size={192} label=\"Asset tag for pump 14\" />\n * <QrCode value=\"482913\" size={192} label=\"Order reference\" />\n *\n * // A payload with no network in it at all.\n * <QrCode value=\"WIFI:T:WPA;S:Guest;P:hunter2;;\" label=\"Join the guest WiFi\" />\n *\n * // A link is one payload among many, not the default case.\n * <QrCode value=\"https://example.com/menu\" label=\"Today's menu\" />\n *\n * // On a dark surface, set both colours: a transparent background renders\n * // dark-on-dark and will not scan.\n * <QrCode value={serial} label=\"Asset tag\" foreground=\"#0b0b0c\" background=\"#ffffff\" />\n * ```\n */\nexport const QrCode = forwardRef<SVGSVGElement, QrCodeProps>(\n (\n {\n value,\n size = 192,\n errorCorrection = \"M\",\n label,\n quietZone = 4,\n foreground = \"currentColor\",\n background = \"transparent\",\n mode,\n version,\n className,\n ...props\n },\n ref,\n ) => {\n // Encoding a version 40 symbol is real work (Reed-Solomon over 2,956\n // codewords, then eight masks scored). Nothing about it depends on `size`\n // or the colours, so it is memoised on the inputs that actually change it\n // — otherwise a parent re-render on hover re-encodes the whole symbol.\n const symbol = useMemo(\n () => encodeQr(value, { errorCorrection, mode, version }),\n [value, errorCorrection, mode, version],\n );\n\n const extent = symbol.size + quietZone * 2;\n\n const path = useMemo(() => {\n const parts: string[] = [];\n for (let row = 0; row < symbol.size; row += 1) {\n const line = symbol.modules[row] as boolean[];\n let col = 0;\n while (col < symbol.size) {\n if (!line[col]) {\n col += 1;\n continue;\n }\n // Run-length the dark modules along the row: a horizontal run\n // becomes one rectangle rather than one per module, which roughly\n // halves the path for a typical symbol and costs nothing to read.\n let run = 1;\n while (col + run < symbol.size && line[col + run]) {\n run += 1;\n }\n parts.push(`M${col + quietZone} ${row + quietZone}h${run}v1h-${run}z`);\n col += run;\n }\n }\n return parts.join(\"\");\n }, [symbol, quietZone]);\n\n return (\n <svg\n ref={ref}\n width={size}\n height={size}\n viewBox={`0 0 ${extent} ${extent}`}\n role=\"img\"\n aria-label={label}\n // Nearest-neighbour rather than smoothing, for the rasterisers that\n // apply it anyway: a blurred module edge is a module a scanner has to\n // guess at.\n shapeRendering=\"crispEdges\"\n className={cn(\"fa-qr-code\", className)}\n {...props}\n >\n {background !== \"transparent\" && (\n <rect width={extent} height={extent} fill={background} />\n )}\n <path d={path} fill={foreground} />\n </svg>\n );\n },\n);\n\nQrCode.displayName = \"QrCode\";\n"]}
|