@pixerate/editor 0.26.1 → 0.28.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/README.md +32 -3
- package/dist/agent/index.cjs +56 -6
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +6 -4
- package/dist/agent/index.d.ts +6 -4
- package/dist/agent/index.js +51 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/animation/index.cjs +62 -0
- package/dist/animation/index.cjs.map +1 -0
- package/dist/animation/index.d.cts +296 -0
- package/dist/animation/index.d.ts +296 -0
- package/dist/animation/index.js +62 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/{builtins-Chj6zv_O.d.ts → builtins-haN82vjT.d.ts} +33 -3
- package/dist/{builtins-CdPcLwwF.d.cts → builtins-nMXh9sT3.d.cts} +33 -3
- package/dist/canvas/index.cjs +535 -737
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +74 -291
- package/dist/canvas/index.d.ts +74 -291
- package/dist/canvas/index.js +417 -619
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-X7HXL2SB.js → chunk-3RPOW4CS.js} +342 -16
- package/dist/chunk-3RPOW4CS.js.map +1 -0
- package/dist/{chunk-UBCFIABU.js → chunk-5H2OPMXZ.js} +183 -6
- package/dist/chunk-5H2OPMXZ.js.map +1 -0
- package/dist/chunk-A6PHCAGX.cjs +87 -0
- package/dist/chunk-A6PHCAGX.cjs.map +1 -0
- package/dist/{chunk-HRMEDT2L.js → chunk-D6AVOTSD.js} +6 -85
- package/dist/chunk-D6AVOTSD.js.map +1 -0
- package/dist/chunk-HXDMZQTD.cjs +497 -0
- package/dist/chunk-HXDMZQTD.cjs.map +1 -0
- package/dist/chunk-IB3ZHQAX.js +497 -0
- package/dist/chunk-IB3ZHQAX.js.map +1 -0
- package/dist/{chunk-4BVP64JJ.cjs → chunk-K2UYKJ6M.cjs} +24 -103
- package/dist/chunk-K2UYKJ6M.cjs.map +1 -0
- package/dist/{chunk-HDYMLS3X.cjs → chunk-MC2LQN5S.cjs} +196 -19
- package/dist/chunk-MC2LQN5S.cjs.map +1 -0
- package/dist/{chunk-XQFHLT53.js → chunk-MXZJ4PKN.js} +24 -10
- package/dist/chunk-MXZJ4PKN.js.map +1 -0
- package/dist/{chunk-LN2POBHT.cjs → chunk-OYEFRO3D.cjs} +28 -14
- package/dist/chunk-OYEFRO3D.cjs.map +1 -0
- package/dist/chunk-PWJARCI4.js +637 -0
- package/dist/chunk-PWJARCI4.js.map +1 -0
- package/dist/chunk-TGD52FEZ.js +87 -0
- package/dist/chunk-TGD52FEZ.js.map +1 -0
- package/dist/chunk-TTYCN6ZH.cjs +637 -0
- package/dist/chunk-TTYCN6ZH.cjs.map +1 -0
- package/dist/{chunk-NQF32I6Z.cjs → chunk-U7VGDSNY.cjs} +463 -137
- package/dist/chunk-U7VGDSNY.cjs.map +1 -0
- package/dist/commands/index.cjs +30 -410
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +17 -397
- package/dist/commands/index.js.map +1 -1
- package/dist/{controller-CxXGOEmy.d.ts → controller-w6eRTjF8.d.cts} +67 -2
- package/dist/{controller-CxXGOEmy.d.cts → controller-w6eRTjF8.d.ts} +67 -2
- package/dist/extensions/index.cjs +25 -7
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +32 -14
- package/dist/generation/index.cjs +3 -3
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.js +3 -3
- package/dist/{index-jcJwmBYt.d.cts → index-C6gaQRH0.d.cts} +53 -4
- package/dist/{index-B273Zllk.d.ts → index-DXAv_R08.d.ts} +53 -4
- package/dist/index.cjs +57 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +132 -94
- package/dist/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +23 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +76 -3
- package/dist/spreadsheet/index.d.ts +76 -3
- package/dist/spreadsheet/index.js +28 -8
- package/dist/tokens/index.cjs +4 -2
- package/dist/tokens/index.cjs.map +1 -1
- package/dist/tokens/index.js +6 -4
- package/package.json +6 -1
- package/dist/chunk-4BVP64JJ.cjs.map +0 -1
- package/dist/chunk-HDYMLS3X.cjs.map +0 -1
- package/dist/chunk-HRMEDT2L.js.map +0 -1
- package/dist/chunk-LN2POBHT.cjs.map +0 -1
- package/dist/chunk-NQF32I6Z.cjs.map +0 -1
- package/dist/chunk-UBCFIABU.js.map +0 -1
- package/dist/chunk-X7HXL2SB.js.map +0 -1
- package/dist/chunk-XQFHLT53.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/registry.ts","../../src/commands/palette.ts","../../src/commands/paletteController.ts","../../src/commands/agentTools.ts","../../src/commands/builtins.ts","../../src/commands/animation.ts"],"sourcesContent":["// Portions ported from filmcraft-main/crates/engine/src/commands.rs and crates/engine/src/lib.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\nimport { validateJsonSchema, type JsonSchema, type SchemaValidationError } from '../agent/schema.js';\nimport type { KeyboardEventLike, Platform } from './chords.js';\nimport {\n\tShortcutMap,\n\ttoShortcutBindings,\n\ttype ShortcutInput,\n\ttype ShortcutMapOptions,\n\ttype ShortcutResolveOptions\n} from './shortcuts.js';\n\n/** Object JSON Schema describing a command's parameters. */\nexport type CommandParamsSchema = JsonSchema & { type: 'object' };\n\n/**\n * Metadata and implementation of one command. Menus, shortcuts, the palette and agent\n * tools all run commands by id, so every entry point shares enablement and validation.\n */\nexport interface CommandSpec<TContext = any, TParams = any, TResult = unknown> {\n\t/** Unique id, e.g. `history.undo` or `canvas.alignLeft`. */\n\tid: string;\n\tlabel: string;\n\t/** Group / menu name shown next to the label, e.g. `Edit` or `Arrange`. */\n\tgroup?: string;\n\t/** Extra search terms for the palette. */\n\tkeywords?: readonly string[];\n\tdescription?: string;\n\t/** Object JSON Schema for `params`. Unknown keys are rejected unless `additionalProperties` allows them. */\n\tparams?: CommandParamsSchema;\n\t/** Default shortcut(s): platform-neutral chord text such as `Mod+Shift+Z`. */\n\tshortcut?: ShortcutInput;\n\t/** Scope the command (and its shortcuts) belong to, e.g. `canvas`. Omit for global commands. */\n\tscope?: string;\n\t/**\n\t * Whether the command can run: `true` (or `undefined`), `false`, or a reason string\n\t * (\"Nothing to undo\"). Receives the params a caller named, so a command acting on the\n\t * selection can still run on targets passed explicitly (`params` is `undefined` for menus).\n\t */\n\tenabled?: (context: TContext, params: TParams | undefined) => boolean | string | undefined;\n\trun: (context: TContext, params: TParams) => TResult;\n\t/**\n\t * Runs inside the registry's `history.batch(label, …)`, so all history entries the\n\t * command records become one undo step and a throw rolls back its partial changes.\n\t */\n\tundoable?: boolean;\n\t/** The command only reads state (agent tools mark it read-only). */\n\treadOnly?: boolean;\n\t/** Hide from the palette and `list()` unless `includeHidden` (still runnable by id). */\n\thidden?: boolean;\n}\n\nexport type CommandErrorCode = 'unknown_command' | 'disabled' | 'invalid_params' | 'failed';\n\nexport type CommandResult<T = unknown> =\n\t| { ok: true; id: string; result: T }\n\t| { ok: false; id: string; code: CommandErrorCode; message: string; details?: SchemaValidationError[] };\n\n/** A command as listed for menus, palettes and agents. */\nexport interface CommandEntry {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\tkeywords?: readonly string[];\n\tdescription?: string;\n\tparams?: CommandParamsSchema;\n\tscope?: string;\n\t/** Canonical chord text bound on the registry's platform (first = primary). */\n\tshortcuts: string[];\n\tenabled: boolean;\n\t/** Why the command is disabled (only when `enabled` is false). */\n\tdisabledReason?: string;\n\tundoable: boolean;\n\treadOnly: boolean;\n}\n\nexport interface CommandListOptions<TContext = any> {\n\t/** Only global commands plus commands of these scopes. */\n\tscope?: string | readonly string[];\n\tenabledOnly?: boolean;\n\tincludeHidden?: boolean;\n\t/** Context for the enablement check (default: the registry's context). */\n\tcontext?: TContext;\n}\n\n/** Minimal history surface (`HistoryManager` satisfies it). */\nexport interface CommandHistoryTarget {\n\tbatch(name: string, fn: () => void): void;\n}\n\nexport interface CommandRegistryOptions<TContext = any> {\n\t/** Default context passed to `enabled` / `run` (a value or a getter). */\n\tcontext?: TContext | (() => TContext);\n\t/** Wraps `undoable` commands in one history step (see `CommandSpec.undoable`). */\n\thistory?: CommandHistoryTarget;\n\t/** Options for the registry's `ShortcutMap`. */\n\tshortcuts?: ShortcutMapOptions;\n}\n\nexport class CommandRegistryError extends Error {\n\treadonly code: 'duplicate_command' | 'invalid_command';\n\n\tconstructor(code: CommandRegistryError['code'], message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'CommandRegistryError';\n\t\tthis.code = code;\n\t}\n}\n\nconst COMMAND_ID_REGEX = /^[A-Za-z0-9_.:-]{1,128}$/;\n\ninterface Registered {\n\tspec: CommandSpec;\n\tunbind: () => void;\n}\n\nfunction enablement(result: boolean | string | undefined): { enabled: boolean; reason?: string } {\n\tif (result === undefined || result === true) return { enabled: true };\n\tif (result === false) return { enabled: false, reason: 'This command is not available right now.' };\n\treturn { enabled: false, reason: String(result) };\n}\n\n/** Errors for params the command does not accept, naming the accepted keys. */\nfunction unknownParams(spec: CommandSpec, params: Record<string, unknown>): string | null {\n\tconst keys = Object.keys(params).filter((k) => params[k] !== undefined);\n\tif (keys.length === 0) return null;\n\tconst schema = spec.params;\n\tif (schema && schema.additionalProperties !== undefined && schema.additionalProperties !== false) return null;\n\tconst accepted = Object.keys(schema?.properties ?? {});\n\tconst bad = keys.find((k) => !accepted.includes(k));\n\tif (!bad) return null;\n\treturn `Unknown parameter \"${bad}\" for command \"${spec.id}\"; expected ${\n\t\taccepted.length ? accepted.map((k) => `\"${k}\"`).join(', ') : 'no parameters'\n\t}.`;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n\t!!value && (typeof value === 'object' || typeof value === 'function') && typeof (value as any).then === 'function';\n\n/**\n * Registry of commands: one id per action, shared by shortcuts (`shortcuts`), the\n * command palette (`list` + `rankCommands`) and agent tools (`createCommandToolProvider`).\n */\nexport class CommandRegistry<TContext = any> {\n\t/** Shortcut bindings of the registered commands (plus any user overrides). */\n\treadonly shortcuts: ShortcutMap;\n\n\tprivate readonly commands = new Map<string, Registered>();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly options: CommandRegistryOptions<TContext>;\n\tprivate version = 0;\n\t// Set while register/unregister change the shortcut map, so they notify once.\n\tprivate muted = false;\n\n\tconstructor(options: CommandRegistryOptions<TContext> = {}) {\n\t\tthis.options = options;\n\t\tthis.shortcuts = new ShortcutMap([], options.shortcuts);\n\t\tthis.shortcuts.subscribe(() => {\n\t\t\tif (!this.muted) this.notify();\n\t\t});\n\t}\n\n\t/** Monotonic counter bumped on every change (useful as a snapshot key). */\n\tgetVersion(): number {\n\t\treturn this.version;\n\t}\n\n\t/** The default context. */\n\tget context(): TContext {\n\t\tconst ctx = this.options.context;\n\t\treturn (typeof ctx === 'function' ? (ctx as () => TContext)() : ctx) as TContext;\n\t}\n\n\t/**\n\t * Registers a command (or several) and returns a function that unregisters it.\n\t * Throws a `CommandRegistryError` for a duplicate or invalid id, or invalid chord text.\n\t */\n\tregister(spec: CommandSpec<TContext> | readonly CommandSpec<TContext>[]): () => void {\n\t\tconst specs = (Array.isArray(spec) ? spec : [spec]) as CommandSpec<TContext>[];\n\t\tconst seen = new Set<string>();\n\t\tfor (const s of specs) {\n\t\t\tif (!s || typeof s.id !== 'string' || !COMMAND_ID_REGEX.test(s.id)) {\n\t\t\t\tthrow new CommandRegistryError('invalid_command', `Invalid command id \"${s?.id}\".`);\n\t\t\t}\n\t\t\tif (typeof s.run !== 'function') {\n\t\t\t\tthrow new CommandRegistryError('invalid_command', `Command \"${s.id}\" has no run function.`);\n\t\t\t}\n\t\t\tif (this.commands.has(s.id) || seen.has(s.id)) {\n\t\t\t\tthrow new CommandRegistryError('duplicate_command', `Command \"${s.id}\" is already registered.`);\n\t\t\t}\n\t\t\tseen.add(s.id);\n\t\t}\n\t\t// Parse every chord before registering anything, so a bad shortcut registers nothing.\n\t\tconst bindings = specs.map((s) => toShortcutBindings(s.id, s.shortcut, s.scope));\n\t\tconst unbinds: Array<() => void> = [];\n\t\tthis.muted = true;\n\t\ttry {\n\t\t\tfor (const b of bindings) unbinds.push(this.shortcuts.bind(b));\n\t\t} catch (error) {\n\t\t\tunbinds.forEach((u) => u());\n\t\t\tthrow new CommandRegistryError('invalid_command', error instanceof Error ? error.message : String(error));\n\t\t} finally {\n\t\t\tthis.muted = false;\n\t\t}\n\t\tspecs.forEach((s, i) => this.commands.set(s.id, { spec: s, unbind: unbinds[i] }));\n\t\tthis.notify();\n\t\tlet registered = true;\n\t\treturn () => {\n\t\t\tif (!registered) return;\n\t\t\tregistered = false;\n\t\t\tlet changed = false;\n\t\t\tfor (const s of specs) {\n\t\t\t\tconst entry = this.commands.get(s.id);\n\t\t\t\tif (entry && entry.spec === s) {\n\t\t\t\t\tthis.commands.delete(s.id);\n\t\t\t\t\tthis.unbindQuietly(entry);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (changed) this.notify();\n\t\t};\n\t}\n\n\t/** Removes a command by id. Returns whether it was registered. */\n\tunregister(id: string): boolean {\n\t\tconst entry = this.commands.get(id);\n\t\tif (!entry) return false;\n\t\tthis.commands.delete(id);\n\t\tthis.unbindQuietly(entry);\n\t\tthis.notify();\n\t\treturn true;\n\t}\n\n\tprivate unbindQuietly(entry: Registered) {\n\t\tthis.muted = true;\n\t\ttry {\n\t\t\tentry.unbind();\n\t\t} finally {\n\t\t\tthis.muted = false;\n\t\t}\n\t}\n\n\thas(id: string): boolean {\n\t\treturn this.commands.has(id);\n\t}\n\n\tget(id: string): CommandSpec<TContext> | undefined {\n\t\treturn this.commands.get(id)?.spec;\n\t}\n\n\t/** Registered ids in registration order. */\n\tids(): string[] {\n\t\treturn [...this.commands.keys()];\n\t}\n\n\t/** Whether `id` can run now (`{ enabled, reason }`); `params` are the targets a caller named. */\n\tisEnabled(id: string, params?: unknown, context: TContext = this.context): { enabled: boolean; reason?: string } {\n\t\tconst spec = this.get(id);\n\t\tif (!spec) return { enabled: false, reason: `Unknown command \"${id}\".` };\n\t\tif (!spec.enabled) return { enabled: true };\n\t\ttry {\n\t\t\treturn enablement(spec.enabled(context, params as any));\n\t\t} catch (error) {\n\t\t\treturn { enabled: false, reason: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/** Commands for menus, palettes and agents, with their current enablement. */\n\tlist(options: CommandListOptions<TContext> = {}): CommandEntry[] {\n\t\tconst scopes = options.scope === undefined ? null : typeof options.scope === 'string' ? [options.scope] : options.scope;\n\t\tconst context = 'context' in options ? (options.context as TContext) : this.context;\n\t\tconst platform = this.shortcuts.platform;\n\t\tconst out: CommandEntry[] = [];\n\t\tfor (const { spec } of this.commands.values()) {\n\t\t\tif (spec.hidden && !options.includeHidden) continue;\n\t\t\tif (scopes && spec.scope !== undefined && !scopes.includes(spec.scope)) continue;\n\t\t\tconst { enabled, reason } = this.isEnabled(spec.id, undefined, context);\n\t\t\tif (options.enabledOnly && !enabled) continue;\n\t\t\tout.push({\n\t\t\t\tid: spec.id,\n\t\t\t\tlabel: spec.label,\n\t\t\t\t...(spec.group !== undefined ? { group: spec.group } : {}),\n\t\t\t\t...(spec.keywords ? { keywords: spec.keywords } : {}),\n\t\t\t\t...(spec.description !== undefined ? { description: spec.description } : {}),\n\t\t\t\t...(spec.params ? { params: spec.params } : {}),\n\t\t\t\t...(spec.scope !== undefined ? { scope: spec.scope } : {}),\n\t\t\t\tshortcuts: this.shortcuts.forCommand(spec.id, platform),\n\t\t\t\tenabled,\n\t\t\t\t...(enabled ? {} : { disabledReason: reason }),\n\t\t\t\tundoable: !!spec.undoable,\n\t\t\t\treadOnly: !!spec.readOnly\n\t\t\t});\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate check(id: string, params: unknown, context: TContext): CommandResult<never> | { spec: CommandSpec<TContext>; params: any } {\n\t\tconst spec = this.get(id);\n\t\tif (!spec) return { ok: false, id, code: 'unknown_command', message: `Unknown command \"${id}\".` };\n\t\tconst input = params ?? {};\n\t\tif (typeof input !== 'object' || Array.isArray(input)) {\n\t\t\treturn { ok: false, id, code: 'invalid_params', message: `Parameters for command \"${id}\" must be an object.` };\n\t\t}\n\t\tconst unknown = unknownParams(spec, input as Record<string, unknown>);\n\t\tif (unknown) return { ok: false, id, code: 'invalid_params', message: unknown };\n\t\tif (spec.params) {\n\t\t\tconst details = validateJsonSchema(input, spec.params);\n\t\t\tif (details.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tid,\n\t\t\t\t\tcode: 'invalid_params',\n\t\t\t\t\tmessage: `Invalid parameters for command \"${id}\": ${details.map((d) => `${d.path} ${d.message}`).join('; ')}`,\n\t\t\t\t\tdetails\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tconst { enabled, reason } = this.isEnabled(id, params === undefined ? undefined : input, context);\n\t\tif (!enabled) return { ok: false, id, code: 'disabled', message: reason ?? 'Disabled.' };\n\t\treturn { spec, params: input };\n\t}\n\n\tprivate invoke(spec: CommandSpec<TContext>, params: any, context: TContext): unknown {\n\t\tconst history = this.options.history;\n\t\tif (!spec.undoable || !history) return spec.run(context, params);\n\t\tlet value: unknown;\n\t\t// `batch` rolls back already-recorded steps and rethrows when `run` throws.\n\t\thistory.batch(spec.label, () => {\n\t\t\tvalue = spec.run(context, params);\n\t\t});\n\t\treturn value;\n\t}\n\n\t/**\n\t * Runs a command synchronously and returns a structured result; never throws.\n\t * A command whose `run` returns a promise yields `{ ok: true, result: promise }`\n\t * (use `executeAsync` to await it and catch its rejection).\n\t */\n\texecute<T = unknown>(id: string, params?: unknown, context: TContext = this.context): CommandResult<T> {\n\t\tconst checked = this.check(id, params, context);\n\t\tif ('ok' in checked) return checked;\n\t\ttry {\n\t\t\tconst result = this.invoke(checked.spec, checked.params, context);\n\t\t\tthis.notify();\n\t\t\treturn { ok: true, id, result: result as T };\n\t\t} catch (error) {\n\t\t\tthis.notify();\n\t\t\treturn { ok: false, id, code: 'failed', message: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/** Like `execute`, but awaits async commands (rejections become `failed` results). */\n\tasync executeAsync<T = unknown>(id: string, params?: unknown, context: TContext = this.context): Promise<CommandResult<T>> {\n\t\tconst outcome = this.execute<T>(id, params, context);\n\t\tif (!outcome.ok || !isThenable(outcome.result)) return outcome;\n\t\ttry {\n\t\t\tconst result = await outcome.result;\n\t\t\tthis.notify();\n\t\t\treturn { ok: true, id, result: result as T };\n\t\t} catch (error) {\n\t\t\tthis.notify();\n\t\t\treturn { ok: false, id, code: 'failed', message: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/**\n\t * Resolves a keydown event to a command (see `ShortcutMap.resolve`) and runs it when\n\t * enabled, calling `preventDefault()`. Disabled commands leave the event alone, so the\n\t * browser or a focused editor can still handle it. Returns the result, or `null`.\n\t */\n\thandleKeyDown(\n\t\tevent: KeyboardEventLike,\n\t\toptions: ShortcutResolveOptions & { context?: TContext } = {}\n\t): CommandResult | null {\n\t\tif (event.defaultPrevented) return null;\n\t\tconst match = this.shortcuts.resolve(event, options);\n\t\tif (!match) return null;\n\t\tconst context = 'context' in options ? (options.context as TContext) : this.context;\n\t\tif (!this.isEnabled(match.command, undefined, context).enabled) return null;\n\t\tevent.preventDefault?.();\n\t\treturn this.execute(match.command, undefined, context);\n\t}\n\n\t/** Display-ready primary shortcut of a command (`⇧⌘Z` / `Ctrl+Shift+Z`), or `undefined`. */\n\tshortcutFor(id: string, platform: Platform = this.shortcuts.platform): string | undefined {\n\t\treturn this.shortcuts.forCommand(id, platform)[0];\n\t}\n\n\t/**\n\t * Subscribes to changes: commands registered or removed, shortcut overrides, executed\n\t * commands and `invalidate()` calls (e.g. when enablement inputs change).\n\t */\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Tells subscribers that enablement may have changed (e.g. the selection changed). */\n\tinvalidate(): void {\n\t\tthis.notify();\n\t}\n\n\tprivate notify(): void {\n\t\tthis.version++;\n\t\tfor (const listener of Array.from(this.listeners)) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[CommandRegistry] Error in listener:', error);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function createCommandRegistry<TContext = any>(options?: CommandRegistryOptions<TContext>): CommandRegistry<TContext> {\n\treturn new CommandRegistry<TContext>(options);\n}\n\n/** Identity helper that types a command spec. */\nexport function defineCommand<TContext = any, TParams = any, TResult = unknown>(\n\tspec: CommandSpec<TContext, TParams, TResult>\n): CommandSpec<TContext, TParams, TResult> {\n\treturn spec;\n}\n","// Portions ported from photocraft-main/crates/ui-egui/src/palette.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/** The fields `rankCommands` searches (a `CommandEntry` satisfies it). */\nexport interface RankableCommand {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\tkeywords?: readonly string[];\n\tenabled?: boolean;\n}\n\nexport interface FuzzyMatch {\n\tscore: number;\n\t/** Indices of the matched characters in the text (for highlighting). */\n\tindices: number[];\n}\n\nconst WORD_SEPARATORS = new Set([' ', '-', '_', '.', '/', ':', '›', '(']);\n\n/**\n * Subsequence fuzzy match: every query character must appear in order. Consecutive\n * matches score 8, others 1; a match at a word start adds 5; longer texts lose\n * `length / 8`. Case-insensitive. Returns `null` when the query does not match.\n */\nexport function fuzzyMatch(query: string, text: string): FuzzyMatch | null {\n\tconst q = query.trim().toLowerCase();\n\tif (!q) return { score: 0, indices: [] };\n\tconst t = text.toLowerCase();\n\tlet score = 0;\n\tlet ti = 0;\n\tlet last = -2;\n\tconst indices: number[] = [];\n\tfor (const qc of q) {\n\t\tif (qc === ' ') continue;\n\t\tlet found = false;\n\t\twhile (ti < t.length) {\n\t\t\tif (t[ti] === qc) {\n\t\t\t\tscore += last === ti - 1 ? 8 : 1;\n\t\t\t\tif (ti === 0 || WORD_SEPARATORS.has(t[ti - 1])) score += 5;\n\t\t\t\tlast = ti;\n\t\t\t\tindices.push(ti);\n\t\t\t\tti++;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tti++;\n\t\t}\n\t\tif (!found) return null;\n\t}\n\treturn { score: score - Math.floor(t.length / 8), indices };\n}\n\n/** `fuzzyMatch(query, text)?.score ?? null`. */\nexport function fuzzyScore(query: string, text: string): number | null {\n\treturn fuzzyMatch(query, text)?.score ?? null;\n}\n\n/**\n * Bonus that puts a command whose name is exactly the query ahead of every fuzzy match\n * (\"undo\" finds Undo before \"Undo Selection Change\"). Trailing ellipses are ignored.\n */\nexport function exactBonus(query: string, names: readonly string[]): number {\n\tconst q = query.trim().toLowerCase();\n\tif (!q) return 0;\n\treturn names.some((n) => n.replace(/(…|\\.\\.\\.)$/, '').trim().toLowerCase() === q) ? 1000 : 0;\n}\n\n/** Default number of recently run commands a palette remembers. */\nexport const DEFAULT_RECENT_LIMIT = 8;\n\n/** Moves `id` to the front of `list` (deduplicated, newest first, at most `cap`). Returns a new array. */\nexport function pushRecent(list: readonly string[], id: string, cap: number = DEFAULT_RECENT_LIMIT): string[] {\n\treturn [id, ...list.filter((x) => x !== id)].slice(0, Math.max(0, cap));\n}\n\nexport interface RankedCommand<T extends RankableCommand = RankableCommand> {\n\tentry: T;\n\tscore: number;\n\t/** Matched character indices in `entry.label` (empty when another field matched). */\n\tlabelIndices: number[];\n\t/** The entry was shown because it was run recently (empty query). */\n\trecent: boolean;\n}\n\nexport interface RankCommandsOptions {\n\t/** Recently run ids, newest first. Shown first for an empty query and boosted slightly otherwise. */\n\trecents?: readonly string[];\n\t/** Maximum number of recents shown for an empty query (default 8). */\n\trecentLimit?: number;\n\t/** Maximum number of results. */\n\tlimit?: number;\n\t/** Sort disabled commands after enabled ones (default `true`). */\n\tdisabledLast?: boolean;\n\t/** With an empty query: `all` (default) lists recents then every other command; `recents` lists only recents. */\n\temptyQuery?: 'all' | 'recents';\n}\n\n/**\n * Ranks commands for a palette query. Searches the label, `group label`, keywords and id;\n * an exact label or keyword match always wins. An empty query lists recent commands\n * first (deduplicated and capped), then the rest in their original order.\n */\nexport function rankCommands<T extends RankableCommand>(\n\tquery: string,\n\tentries: readonly T[],\n\toptions: RankCommandsOptions = {}\n): RankedCommand<T>[] {\n\tconst recents = options.recents ?? [];\n\tconst disabledLast = options.disabledLast ?? true;\n\tconst q = query.trim();\n\tlet ranked: Array<RankedCommand<T> & { order: number }>;\n\n\tif (!q) {\n\t\tconst byId = new Map(entries.map((e) => [e.id, e]));\n\t\tconst recentIds = [...new Set(recents)].filter((id) => byId.has(id)).slice(0, options.recentLimit ?? DEFAULT_RECENT_LIMIT);\n\t\tconst recentSet = new Set(recentIds);\n\t\tranked = recentIds.map((id, i) => ({ entry: byId.get(id)!, score: 1000 - i, labelIndices: [], recent: true, order: i }));\n\t\tif ((options.emptyQuery ?? 'all') === 'all') {\n\t\t\tentries.forEach((entry, i) => {\n\t\t\t\tif (!recentSet.has(entry.id)) ranked.push({ entry, score: 0, labelIndices: [], recent: false, order: recentIds.length + i });\n\t\t\t});\n\t\t}\n\t} else {\n\t\tranked = [];\n\t\tentries.forEach((entry, order) => {\n\t\t\tconst label = fuzzyMatch(q, entry.label);\n\t\t\tconst candidates: number[] = [];\n\t\t\tif (label) candidates.push(label.score);\n\t\t\tif (entry.group) {\n\t\t\t\tconst grouped = fuzzyScore(q, `${entry.group} ${entry.label}`);\n\t\t\t\tif (grouped !== null) candidates.push(grouped - 1);\n\t\t\t}\n\t\t\tfor (const keyword of entry.keywords ?? []) {\n\t\t\t\tconst s = fuzzyScore(q, keyword);\n\t\t\t\tif (s !== null) candidates.push(s - 2);\n\t\t\t}\n\t\t\tconst byId = fuzzyScore(q, entry.id);\n\t\t\tif (byId !== null) candidates.push(byId - 3);\n\t\t\tif (candidates.length === 0) return;\n\t\t\tconst recentIndex = recents.indexOf(entry.id);\n\t\t\tconst score =\n\t\t\t\tMath.max(...candidates) +\n\t\t\t\texactBonus(q, [entry.label, ...(entry.keywords ?? [])]) +\n\t\t\t\t(recentIndex >= 0 ? Math.max(1, 4 - recentIndex) : 0);\n\t\t\tranked.push({ entry, score, labelIndices: label?.indices ?? [], recent: false, order });\n\t\t});\n\t\tranked.sort((a, b) => b.score - a.score || a.entry.label.length - b.entry.label.length || a.order - b.order);\n\t}\n\n\tif (disabledLast) {\n\t\t// Stable partition: enabled first, keeping the ranking within each half.\n\t\tranked = [...ranked.filter((r) => r.entry.enabled !== false), ...ranked.filter((r) => r.entry.enabled === false)];\n\t}\n\tconst out = ranked.map(({ order: _order, ...rest }) => rest);\n\treturn options.limit !== undefined ? out.slice(0, options.limit) : out;\n}\n","import { formatShortcut, type KeyboardEventLike, type Platform } from './chords.js';\nimport { DEFAULT_RECENT_LIMIT, pushRecent, rankCommands, type RankedCommand } from './palette.js';\nimport type { CommandEntry, CommandRegistry, CommandResult } from './registry.js';\nimport { ShortcutMap } from './shortcuts.js';\n\n/** One palette row. */\nexport interface CommandPaletteItem extends RankedCommand<CommandEntry> {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\t/** Display-ready primary shortcut (`⇧⌘Z` / `Ctrl+Shift+Z`). */\n\tshortcut?: string;\n\tenabled: boolean;\n\tdisabledReason?: string;\n}\n\nexport interface CommandPaletteState {\n\topen: boolean;\n\tquery: string;\n\tactiveIndex: number;\n\titems: CommandPaletteItem[];\n\trecents: string[];\n\t/** Result of the last command the palette ran. */\n\tlastResult: CommandResult | null;\n}\n\nexport interface CommandPaletteOptions<TContext = any> {\n\t/** Context for enablement and runs (default: the registry's). */\n\tcontext?: TContext | (() => TContext);\n\t/** Only global commands plus these scopes. */\n\tscope?: string | readonly string[] | (() => string | readonly string[] | undefined);\n\t/** Initial recently run ids (newest first), e.g. restored from storage. */\n\trecents?: readonly string[];\n\t/** Called whenever the recents change, e.g. to persist them. */\n\tonRecentsChange?: (recents: string[]) => void;\n\trecentLimit?: number;\n\t/** Maximum rows (default 50). */\n\tlimit?: number;\n\t/** Platform for shortcut display (default: detected). */\n\tplatform?: Platform;\n\t/** Called after a command ran from the palette. */\n\tonRun?: (result: CommandResult) => void;\n}\n\n/**\n * Framework-agnostic command palette state (open, query, ranked rows, active row and\n * recents) over a `CommandRegistry`. The React hook and Svelte rune wrap it.\n */\nexport function createCommandPaletteController<TContext = any>(\n\tregistry: CommandRegistry<TContext>,\n\toptions: CommandPaletteOptions<TContext> = {}\n) {\n\tconst listeners = new Set<(state: CommandPaletteState) => void>();\n\tlet open = false;\n\tlet query = '';\n\tlet activeIndex = 0;\n\tlet recents = [...(options.recents ?? [])];\n\tlet lastResult: CommandResult | null = null;\n\tlet state: CommandPaletteState;\n\n\tconst context = (): TContext => {\n\t\tconst c = options.context;\n\t\tif (c === undefined) return registry.context;\n\t\treturn (typeof c === 'function' ? (c as () => TContext)() : c) as TContext;\n\t};\n\tconst scope = () => (typeof options.scope === 'function' ? options.scope() : options.scope);\n\n\tfunction computeItems(): CommandPaletteItem[] {\n\t\tif (!open) return [];\n\t\tconst entries = registry.list({ scope: scope(), context: context() });\n\t\tconst platform = options.platform ?? registry.shortcuts.platform;\n\t\treturn rankCommands(query, entries, {\n\t\t\trecents,\n\t\t\trecentLimit: options.recentLimit,\n\t\t\tlimit: options.limit ?? 50\n\t\t}).map((ranked) => ({\n\t\t\t...ranked,\n\t\t\tid: ranked.entry.id,\n\t\t\tlabel: ranked.entry.label,\n\t\t\t...(ranked.entry.group !== undefined ? { group: ranked.entry.group } : {}),\n\t\t\t...(ranked.entry.shortcuts[0] ? { shortcut: formatShortcut(ranked.entry.shortcuts[0], platform) } : {}),\n\t\t\tenabled: ranked.entry.enabled,\n\t\t\t...(ranked.entry.disabledReason ? { disabledReason: ranked.entry.disabledReason } : {})\n\t\t}));\n\t}\n\n\tfunction update() {\n\t\tconst items = computeItems();\n\t\tactiveIndex = items.length === 0 ? 0 : Math.min(Math.max(activeIndex, 0), items.length - 1);\n\t\tstate = { open, query, activeIndex, items, recents, lastResult };\n\t\tfor (const listener of Array.from(listeners)) listener(state);\n\t}\n\n\tstate = { open, query, activeIndex, items: [], recents, lastResult };\n\t// Follow registry changes only while someone listens (safe with React StrictMode remounts).\n\tlet unsubscribeRegistry: (() => void) | null = null;\n\tconst onRegistryChange = () => {\n\t\tif (open) update();\n\t};\n\n\tconst controller = {\n\t\tgetState: () => state,\n\t\tsubscribe(listener: (state: CommandPaletteState) => void): () => void {\n\t\t\tlisteners.add(listener);\n\t\t\tunsubscribeRegistry ??= registry.subscribe(onRegistryChange);\n\t\t\tif (open) update(); // catch up with changes made while nobody listened\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t\tif (listeners.size === 0) {\n\t\t\t\t\tunsubscribeRegistry?.();\n\t\t\t\t\tunsubscribeRegistry = null;\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tsetOpen(next: boolean) {\n\t\t\tif (next === open) return;\n\t\t\topen = next;\n\t\t\tquery = '';\n\t\t\tactiveIndex = 0;\n\t\t\tupdate();\n\t\t},\n\t\ttoggle() {\n\t\t\tcontroller.setOpen(!open);\n\t\t},\n\t\tsetQuery(next: string) {\n\t\t\tif (next === query) return;\n\t\t\tquery = next;\n\t\t\tactiveIndex = 0;\n\t\t\tupdate();\n\t\t},\n\t\tsetActiveIndex(index: number) {\n\t\t\tactiveIndex = index;\n\t\t\tupdate();\n\t\t},\n\t\t/** Moves the active row by `delta`, wrapping around. */\n\t\tmove(delta: number) {\n\t\t\tconst n = state.items.length;\n\t\t\tif (n === 0) return;\n\t\t\tactiveIndex = (((activeIndex + delta) % n) + n) % n;\n\t\t\tupdate();\n\t\t},\n\t\t/** Runs a command by id, closes the palette and records it as recent. Disabled commands do nothing. */\n\t\trun(id: string): CommandResult | null {\n\t\t\tif (!registry.isEnabled(id, undefined, context()).enabled) return null;\n\t\t\topen = false;\n\t\t\tquery = '';\n\t\t\tactiveIndex = 0;\n\t\t\trecents = pushRecent(recents, id, options.recentLimit ?? DEFAULT_RECENT_LIMIT);\n\t\t\toptions.onRecentsChange?.(recents);\n\t\t\tconst result = registry.execute(id, undefined, context());\n\t\t\tlastResult = result;\n\t\t\tupdate();\n\t\t\toptions.onRun?.(result);\n\t\t\treturn result;\n\t\t},\n\t\trunActive(): CommandResult | null {\n\t\t\tconst item = state.items[state.activeIndex];\n\t\t\treturn item ? controller.run(item.id) : null;\n\t\t},\n\t\t/**\n\t\t * Keyboard handling for the palette input: ArrowUp/ArrowDown (wrap), Home/End,\n\t\t * Enter (run the active row) and Escape (close). Returns whether it handled the key.\n\t\t */\n\t\thandleKeyDown(event: KeyboardEventLike): boolean {\n\t\t\tif (!open) return false;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcontroller.move(1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tcontroller.move(-1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tcontroller.setActiveIndex(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tcontroller.setActiveIndex(state.items.length - 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Enter':\n\t\t\t\t\tcontroller.runActive();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tcontroller.setOpen(false);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\tevent.preventDefault?.();\n\t\t\treturn true;\n\t\t},\n\t\t/** Re-reads commands and enablement. */\n\t\trefresh() {\n\t\t\tupdate();\n\t\t},\n\t\tdestroy() {\n\t\t\tunsubscribeRegistry?.();\n\t\t\tunsubscribeRegistry = null;\n\t\t\tlisteners.clear();\n\t\t}\n\t};\n\treturn controller;\n}\n\nexport type CommandPaletteController = ReturnType<typeof createCommandPaletteController>;\n\n/**\n * Matches a global \"open palette\" hotkey (e.g. `Mod+K`), also while typing in inputs.\n * Returns `true` when `event` is the hotkey.\n */\nexport function matchPaletteHotkey(event: KeyboardEventLike, hotkey: string, platform?: Platform): boolean {\n\tconst map = new ShortcutMap([{ command: 'palette', chord: hotkey, allowInEditable: true }], platform ? { platform } : {});\n\treturn map.resolve(event) !== null;\n}\n","// Portions ported from filmcraft-main/crates/automation/src/server.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\nimport type { AgentTool, AgentToolProvider, McpToolResult } from '../agent/registry.js';\nimport { rankCommands } from './palette.js';\nimport type { CommandRegistry, CommandResult } from './registry.js';\n\nexport interface CommandToolProviderOptions<TContext = any> {\n\t/** Provider id (default `commands`). */\n\tid?: string;\n\t/** Always prefix the tool names with `<namespace>__`. */\n\tnamespace?: string;\n\t/** Context for enablement and runs (default: the registry's). */\n\tcontext?: TContext | (() => TContext);\n\t/** Only expose global commands plus these scopes. */\n\tscope?: string | readonly string[];\n\t/** Commands agents may not see or run (e.g. ones that open dialogs). */\n\texclude?: (id: string) => boolean;\n}\n\nconst toJson = (value: unknown): unknown => {\n\tif (value === undefined) return null;\n\ttry {\n\t\treturn JSON.parse(JSON.stringify(value));\n\t} catch {\n\t\treturn String(value);\n\t}\n};\n\nfunction errorResult(result: Extract<CommandResult, { ok: false }>): McpToolResult {\n\treturn {\n\t\tisError: true,\n\t\tcontent: [{ type: 'text', text: `${result.code}: ${result.message}` }],\n\t\tstructuredContent: {\n\t\t\terror: { code: result.code, message: result.message, command: result.id, ...(result.details ? { details: result.details } : {}) }\n\t\t}\n\t};\n}\n\n/**\n * Exposes a `CommandRegistry` to agents through a `ToolRegistry`:\n *\n * - `list_commands {query?, enabledOnly?}`: ids, labels, params schemas, shortcuts and\n * enablement (with the reason a command is disabled).\n * - `run_command {id, params?}`: runs one command; disabled commands, unknown params and\n * failures come back as `isError` results with a `{code, message}` error.\n * - `run_commands {steps: [{id, params?}], stopOnError?}`: runs steps **in order**, each as\n * its own command (and undo step). It is not atomic: steps that succeeded before a failure\n * stay applied. For all-or-nothing behaviour, register a command that runs the steps\n * inside `HistoryManager.batch` (or mark it `undoable` on a registry with `history`).\n *\n * The id enum in `run_command`'s schema follows the registered commands, so the\n * `ToolRegistry` announces `listChanged` when commands are added or removed.\n */\nexport function createCommandToolProvider<TContext = any>(\n\tregistry: CommandRegistry<TContext>,\n\toptions: CommandToolProviderOptions<TContext> = {}\n): AgentToolProvider {\n\tconst context = (): TContext => {\n\t\tconst c = options.context;\n\t\tif (c === undefined) return registry.context;\n\t\treturn (typeof c === 'function' ? (c as () => TContext)() : c) as TContext;\n\t};\n\tconst visible = () =>\n\t\tregistry.list({ scope: options.scope, context: context() }).filter((e) => !options.exclude?.(e.id));\n\tconst allowed = (id: string) => registry.has(id) && !options.exclude?.(id) && visible().some((e) => e.id === id);\n\n\tasync function runOne(id: string, params: unknown): Promise<CommandResult> {\n\t\tif (!allowed(id)) return { ok: false, id, code: 'unknown_command', message: `Unknown command \"${id}\".` };\n\t\treturn registry.executeAsync(id, params ?? {}, context());\n\t}\n\n\tconst listCommands: AgentTool = {\n\t\tname: 'list_commands',\n\t\ttitle: 'List commands',\n\t\tdescription:\n\t\t\t'Lists the commands you can run with run_command: id, label, group, params (JSON Schema), shortcuts, and whether each is enabled now (with the reason when it is not).',\n\t\tinputSchema: {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tquery: { type: 'string', description: 'Fuzzy filter on label, keywords, group and id.' },\n\t\t\t\tenabledOnly: { type: 'boolean', description: 'Only commands that can run now (default false).' }\n\t\t\t},\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tannotations: { title: 'List commands', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },\n\t\thandler: ({ query = '', enabledOnly = false }) => {\n\t\t\tlet entries = visible();\n\t\t\tif (enabledOnly) entries = entries.filter((e) => e.enabled);\n\t\t\tif (String(query).trim()) entries = rankCommands(String(query), entries, { disabledLast: false }).map((r) => r.entry);\n\t\t\treturn {\n\t\t\t\tcommands: entries.map((e) => ({\n\t\t\t\t\tid: e.id,\n\t\t\t\t\tlabel: e.label,\n\t\t\t\t\t...(e.group ? { group: e.group } : {}),\n\t\t\t\t\t...(e.description ? { description: e.description } : {}),\n\t\t\t\t\t...(e.params ? { params: e.params } : {}),\n\t\t\t\t\t...(e.shortcuts.length ? { shortcuts: e.shortcuts } : {}),\n\t\t\t\t\tenabled: e.enabled,\n\t\t\t\t\t...(e.disabledReason ? { disabledReason: e.disabledReason } : {}),\n\t\t\t\t\treadOnly: e.readOnly\n\t\t\t\t}))\n\t\t\t};\n\t\t}\n\t};\n\n\tconst runCommandTool = (): AgentTool => {\n\t\tconst ids = visible().map((e) => e.id);\n\t\treturn {\n\t\t\tname: 'run_command',\n\t\t\ttitle: 'Run a command',\n\t\t\tdescription:\n\t\t\t\t'Runs one command by id with optional params (see list_commands for each command\\'s params schema). Unknown params are rejected.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: { type: 'string', description: 'Command id from list_commands.', ...(ids.length ? { enum: ids } : {}) },\n\t\t\t\t\tparams: { type: 'object', description: 'Command parameters.' }\n\t\t\t\t},\n\t\t\t\trequired: ['id'],\n\t\t\t\tadditionalProperties: false\n\t\t\t},\n\t\t\tannotations: { title: 'Run a command', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },\n\t\t\thandler: async ({ id, params }) => {\n\t\t\t\tconst result = await runOne(String(id), params);\n\t\t\t\treturn result.ok ? { id: result.id, ok: true, result: toJson(result.result) } : errorResult(result);\n\t\t\t}\n\t\t};\n\t};\n\n\tconst runCommands: AgentTool = {\n\t\tname: 'run_commands',\n\t\ttitle: 'Run several commands',\n\t\tdescription:\n\t\t\t'Runs several commands in order: {steps: [{id, params?}], stopOnError?: true}. Each step is its own command and undo step; the batch is NOT atomic (steps before a failure stay applied). Returns {completed, failed, results: [{id, ok, result | code, message}]}.',\n\t\tinputSchema: {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tsteps: {\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tminItems: 1,\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tid: { type: 'string', description: 'Command id.' },\n\t\t\t\t\t\t\tparams: { type: 'object', description: 'Command parameters.' }\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: ['id'],\n\t\t\t\t\t\tadditionalProperties: false\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tstopOnError: { type: 'boolean', description: 'Stop at the first failing step (default true).' }\n\t\t\t},\n\t\t\trequired: ['steps'],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tannotations: {\n\t\t\ttitle: 'Run several commands',\n\t\t\treadOnlyHint: false,\n\t\t\tdestructiveHint: true,\n\t\t\tidempotentHint: false,\n\t\t\topenWorldHint: false\n\t\t},\n\t\thandler: async ({ steps, stopOnError = true }) => {\n\t\t\tlet completed = 0;\n\t\t\tlet failed = 0;\n\t\t\tconst results: Array<Record<string, unknown>> = [];\n\t\t\tfor (const step of steps as Array<{ id: string; params?: unknown }>) {\n\t\t\t\tconst result = await runOne(step.id, step.params);\n\t\t\t\tif (result.ok) {\n\t\t\t\t\tcompleted++;\n\t\t\t\t\tresults.push({ id: result.id, ok: true, result: toJson(result.result) });\n\t\t\t\t} else {\n\t\t\t\t\tfailed++;\n\t\t\t\t\tresults.push({ id: result.id, ok: false, code: result.code, message: result.message });\n\t\t\t\t\tif (stopOnError) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst summary = { completed, failed, skipped: steps.length - completed - failed, results };\n\t\t\treturn failed > 0\n\t\t\t\t? { isError: true, content: [{ type: 'text', text: JSON.stringify(summary) }], structuredContent: summary }\n\t\t\t\t: summary;\n\t\t}\n\t};\n\n\treturn {\n\t\tid: options.id ?? 'commands',\n\t\tnamespace: options.namespace,\n\t\ttools: () => [listCommands, runCommandTool(), runCommands],\n\t\tsubscribe: (notify) => registry.subscribe(notify)\n\t};\n}\n","import type { HistoryState } from '../history/types.js';\nimport type { CanvasArrangeAction } from '../canvas/arrangeShortcuts.js';\nimport type { AlignEdge, DistributeAxis, DistributeMode, ZOrderOperation } from '../canvas/arrange.js';\nimport { DEFAULT_ARRANGE_SHORTCUTS } from '../canvas/arrangeShortcuts.js';\nimport type { CommandParamsSchema, CommandSpec } from './registry.js';\nimport { ShortcutMap, type ShortcutBinding } from './shortcuts.js';\nimport type { KeyboardEventLike, Platform } from './chords.js';\n\n// ---------------------------------------------------------------------------\n// History\n// ---------------------------------------------------------------------------\n\n/** Minimal history surface (`HistoryManager` satisfies it). */\nexport interface HistoryCommandTarget {\n\tundo(): boolean | void;\n\tredo(): boolean | void;\n\tgetState(): Pick<HistoryState, 'canUndo' | 'canRedo'> & Partial<Pick<HistoryState, 'undoName' | 'redoName'>>;\n}\n\n/** Default history bindings: `Mod+Z` undo; `Mod+Shift+Z` redo, plus `Mod+Y` off macOS. */\nexport const DEFAULT_HISTORY_SHORTCUTS: readonly ShortcutBinding[] = [\n\t{ command: 'undo', chord: 'Mod+Z' },\n\t{ command: 'redo', chord: 'Mod+Shift+Z' },\n\t{ command: 'redo', chord: 'Mod+Y', platforms: ['windows', 'linux'] }\n];\n\nexport interface HistoryCommandOptions {\n\t/** Id prefix (default `history.`). */\n\tprefix?: string;\n\tgroup?: string;\n\tscope?: string;\n}\n\n/** `history.undo` / `history.redo` commands for a `HistoryManager` (disabled with a reason when empty). */\nexport function createHistoryCommands(history: HistoryCommandTarget, options: HistoryCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'history.';\n\tconst group = options.group ?? 'Edit';\n\tconst shortcutsOf = (command: 'undo' | 'redo') =>\n\t\tDEFAULT_HISTORY_SHORTCUTS.filter((b) => b.command === command).map(({ command: _c, ...rest }) => rest);\n\treturn [\n\t\t{\n\t\t\tid: `${prefix}undo`,\n\t\t\tlabel: 'Undo',\n\t\t\tgroup,\n\t\t\tkeywords: ['revert', 'back'],\n\t\t\tdescription: 'Reverts the last change.',\n\t\t\tshortcut: shortcutsOf('undo'),\n\t\t\t...(options.scope ? { scope: options.scope } : {}),\n\t\t\tenabled: () => (history.getState().canUndo ? true : 'Nothing to undo.'),\n\t\t\trun: () => {\n\t\t\t\thistory.undo();\n\t\t\t\treturn { undone: true, state: history.getState() };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: `${prefix}redo`,\n\t\t\tlabel: 'Redo',\n\t\t\tgroup,\n\t\t\tkeywords: ['repeat', 'forward'],\n\t\t\tdescription: 'Re-applies the last undone change.',\n\t\t\tshortcut: shortcutsOf('redo'),\n\t\t\t...(options.scope ? { scope: options.scope } : {}),\n\t\t\tenabled: () => (history.getState().canRedo ? true : 'Nothing to redo.'),\n\t\t\trun: () => {\n\t\t\t\thistory.redo();\n\t\t\t\treturn { redone: true, state: history.getState() };\n\t\t\t}\n\t\t}\n\t];\n}\n\nlet historyShortcutMap: ShortcutMap | null = null;\n\n/**\n * Resolves a keydown event to `undo` / `redo` with the default history bindings\n * (`Mod` is ⌘ on macOS and Ctrl elsewhere). Events from text inputs and\n * contenteditable elements are ignored unless `allowInEditable`.\n */\nexport function matchHistoryShortcut(\n\tevent: KeyboardEventLike,\n\toptions: { platform?: Platform; allowInEditable?: boolean } = {}\n): 'undo' | 'redo' | null {\n\thistoryShortcutMap ??= new ShortcutMap(DEFAULT_HISTORY_SHORTCUTS);\n\treturn (historyShortcutMap.resolve(event, options)?.command as 'undo' | 'redo' | undefined) ?? null;\n}\n\n// ---------------------------------------------------------------------------\n// Canvas arrange\n// ---------------------------------------------------------------------------\n\n/** Minimal arrange controller surface (`createCanvasArrangeController` satisfies it). */\nexport interface ArrangeCommandTarget {\n\talign(edge: AlignEdge, ids?: Iterable<string>): unknown;\n\tdistribute(axis: DistributeAxis, mode?: DistributeMode, ids?: Iterable<string>): unknown;\n\treorder(operation: ZOrderOperation, ids?: Iterable<string>): unknown;\n\tlock(ids?: Iterable<string>): unknown;\n\tunlock(ids?: Iterable<string>): unknown;\n}\n\nexport interface ArrangeCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope of the commands and their shortcuts (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n\t/** Current selection, used for enablement (\"Select at least two nodes\"). */\n\tgetSelectedIds?: () => string[];\n\t/** Scene navigation (`nextScene` / `previousScene`); those commands are only added when given. */\n\tscenes?: { next(): unknown; previous(): unknown };\n\t/** Use these bindings instead of `DEFAULT_ARRANGE_SHORTCUTS`. */\n\tbindings?: readonly { action: CanvasArrangeAction; label: string }[];\n}\n\nconst ARRANGE_LABELS: Record<CanvasArrangeAction, string> = {\n\talignLeft: 'Align Left',\n\talignCenter: 'Align Horizontal Centers',\n\talignRight: 'Align Right',\n\talignTop: 'Align Top',\n\talignMiddle: 'Align Vertical Centers',\n\talignBottom: 'Align Bottom',\n\tdistributeHorizontal: 'Distribute Horizontally',\n\tdistributeVertical: 'Distribute Vertically',\n\tlock: 'Lock',\n\tunlock: 'Unlock',\n\tbringForward: 'Bring Forward',\n\tsendBackward: 'Send Backward',\n\tbringToFront: 'Bring to Front',\n\tsendToBack: 'Send to Back',\n\tnextScene: 'Next Scene',\n\tpreviousScene: 'Previous Scene'\n};\n\nconst IDS_PARAMS: CommandParamsSchema = {\n\ttype: 'object',\n\tproperties: {\n\t\tids: {\n\t\t\ttype: 'array',\n\t\t\titems: { type: 'string' },\n\t\t\tdescription: 'Node ids to act on (default: the selection).'\n\t\t}\n\t}\n};\n\n/**\n * Commands for the canvas arrange actions (`canvas.alignLeft`, `canvas.bringToFront`, …)\n * with the default arrange shortcuts. Each accepts `{ ids? }`; enablement checks the\n * named ids, or the selection when none are named.\n */\nexport function createArrangeCommands(controller: ArrangeCommandTarget, options: ArrangeCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Arrange';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst bindings = options.bindings ?? DEFAULT_ARRANGE_SHORTCUTS;\n\tconst count = (params?: { ids?: string[] }) => params?.ids?.length ?? options.getSelectedIds?.().length;\n\tconst needs = (min: number, what: string) => (_: unknown, params?: { ids?: string[] }) => {\n\t\tconst n = count(params);\n\t\tif (n === undefined || n >= min) return true;\n\t\treturn min === 1 ? `Select a ${what} first.` : `Select at least ${min} ${what}s.`;\n\t};\n\n\tconst run: Record<CanvasArrangeAction, (ids?: string[]) => unknown> = {\n\t\talignLeft: (ids) => controller.align('left', ids),\n\t\talignCenter: (ids) => controller.align('center', ids),\n\t\talignRight: (ids) => controller.align('right', ids),\n\t\talignTop: (ids) => controller.align('top', ids),\n\t\talignMiddle: (ids) => controller.align('middle', ids),\n\t\talignBottom: (ids) => controller.align('bottom', ids),\n\t\tdistributeHorizontal: (ids) => controller.distribute('horizontal', 'gaps', ids),\n\t\tdistributeVertical: (ids) => controller.distribute('vertical', 'gaps', ids),\n\t\tlock: (ids) => controller.lock(ids),\n\t\tunlock: (ids) => controller.unlock(ids),\n\t\tbringForward: (ids) => controller.reorder('bringForward', ids),\n\t\tsendBackward: (ids) => controller.reorder('sendBackward', ids),\n\t\tbringToFront: (ids) => controller.reorder('bringToFront', ids),\n\t\tsendToBack: (ids) => controller.reorder('sendToBack', ids),\n\t\tnextScene: () => options.scenes?.next(),\n\t\tpreviousScene: () => options.scenes?.previous()\n\t};\n\n\tconst actions = Object.keys(ARRANGE_LABELS) as CanvasArrangeAction[];\n\treturn actions\n\t\t.filter((action) => options.scenes || (action !== 'nextScene' && action !== 'previousScene'))\n\t\t.map((action): CommandSpec => {\n\t\t\tconst isScene = action === 'nextScene' || action === 'previousScene';\n\t\t\tconst enabled = isScene\n\t\t\t\t? undefined\n\t\t\t\t: action.startsWith('align')\n\t\t\t\t\t? needs(2, 'node')\n\t\t\t\t\t: action.startsWith('distribute')\n\t\t\t\t\t\t? needs(3, 'node')\n\t\t\t\t\t\t: needs(1, 'node');\n\t\t\treturn {\n\t\t\t\tid: `${prefix}${action}`,\n\t\t\t\tlabel: ARRANGE_LABELS[action],\n\t\t\t\tgroup: isScene ? 'Scenes' : group,\n\t\t\t\tkeywords: isScene ? ['scene', 'slide', 'page'] : action.startsWith('align') ? ['align'] : ['arrange', 'layer', 'order'],\n\t\t\t\t...(scope ? { scope } : {}),\n\t\t\t\tshortcut: bindings.filter((b) => b.action === action).map((b) => b.label),\n\t\t\t\t...(isScene ? {} : { params: IDS_PARAMS }),\n\t\t\t\t...(enabled ? { enabled } : {}),\n\t\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => run[action](params?.ids)\n\t\t\t};\n\t\t});\n}\n\n// ---------------------------------------------------------------------------\n// Canvas shape operations\n// ---------------------------------------------------------------------------\n\n/** Shape operations surface of the arrange controller (`createCanvasArrangeController` satisfies it). */\nexport interface ShapeCommandTarget {\n\tcombineShapes(operation: 'unite' | 'intersect' | 'subtract' | 'exclude' | 'divide', ids?: Iterable<string>): unknown;\n\tcanCombineShapes(ids?: Iterable<string>): boolean;\n\toffsetShapes(distance: number, ids?: Iterable<string>, options?: { join?: 'miter' | 'round' | 'bevel'; miterLimit?: number }): unknown;\n\tcanOffsetShapes(ids?: Iterable<string>): boolean;\n\toutlineStroke(\n\t\tids?: Iterable<string>,\n\t\toptions?: { join?: 'miter' | 'round' | 'bevel'; cap?: 'butt' | 'round' | 'square'; miterLimit?: number }\n\t): unknown;\n\tcanOutlineStroke(ids?: Iterable<string>): boolean;\n}\n\nexport interface ShapeCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n\t/** Offset distance used when `canvas.offsetPath` is run without one (default 10). */\n\tdefaultOffset?: number;\n}\n\nconst SHAPE_COMMANDS = [\n\t{ op: 'unite', label: 'Unite Shapes', keywords: ['union', 'merge', 'boolean', 'combine'] },\n\t{ op: 'intersect', label: 'Intersect Shapes', keywords: ['intersection', 'boolean', 'combine'] },\n\t{ op: 'subtract', label: 'Subtract Shapes', keywords: ['difference', 'minus front', 'boolean', 'combine'] },\n\t{ op: 'exclude', label: 'Exclude Shapes', keywords: ['xor', 'boolean', 'combine'] },\n\t{ op: 'divide', label: 'Divide Shapes', keywords: ['split', 'pathfinder', 'boolean'] }\n] as const;\n\nconst JOIN_PARAM = { type: 'string', enum: ['miter', 'round', 'bevel'], description: 'Corner style (default miter).' } as const;\n\n/**\n * Palette / context-menu / agent commands for the shape operations: `canvas.unite`,\n * `canvas.intersect`, `canvas.subtract`, `canvas.exclude`, `canvas.divide`,\n * `canvas.offsetPath` (`{ distance, join?, miterLimit?, ids? }`) and `canvas.outlineStroke`\n * (`{ join?, cap?, miterLimit?, ids? }`). Each is one undoable step when the controller has a\n * history; enablement explains why a command cannot run.\n */\nexport function createShapeCommands(controller: ShapeCommandTarget, options: ShapeCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Shape';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst combine = SHAPE_COMMANDS.map(\n\t\t({ op, label, keywords }): CommandSpec => ({\n\t\t\t...base,\n\t\t\tid: `${prefix}${op}`,\n\t\t\tlabel,\n\t\t\tkeywords: [...keywords],\n\t\t\tdescription: `${label.split(' ')[0]}s the selected shapes into a new path (curves are kept).`,\n\t\t\tparams: IDS_PARAMS,\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canCombineShapes(params?.ids) ? true : 'Select at least two unlocked shapes.',\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => controller.combineShapes(op, params?.ids)\n\t\t})\n\t);\n\treturn [\n\t\t...combine,\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}offsetPath`,\n\t\t\tlabel: 'Offset Path…',\n\t\t\tkeywords: ['inset', 'outset', 'grow', 'shrink', 'expand', 'contract'],\n\t\t\tdescription: 'Grows (positive distance) or shrinks (negative) the selected shapes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tdistance: { type: 'number', description: `Offset in canvas units (default ${options.defaultOffset ?? 10}).` },\n\t\t\t\t\tjoin: JOIN_PARAM,\n\t\t\t\t\tmiterLimit: { type: 'number', description: 'Miter limit (default 4).' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canOffsetShapes(params?.ids) ? true : 'Select an unlocked shape.',\n\t\t\trun: (_ctx: unknown, params: { distance?: number; join?: 'miter' | 'round' | 'bevel'; miterLimit?: number; ids?: string[] }) =>\n\t\t\t\tcontroller.offsetShapes(params?.distance ?? options.defaultOffset ?? 10, params?.ids, {\n\t\t\t\t\t...(params?.join ? { join: params.join } : {}),\n\t\t\t\t\t...(params?.miterLimit !== undefined ? { miterLimit: params.miterLimit } : {})\n\t\t\t\t})\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}outlineStroke`,\n\t\t\tlabel: 'Outline Stroke',\n\t\t\tkeywords: ['expand stroke', 'stroke to path', 'convert stroke'],\n\t\t\tdescription: 'Converts the strokes of the selected shapes to filled shapes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tjoin: JOIN_PARAM,\n\t\t\t\t\tcap: { type: 'string', enum: ['butt', 'round', 'square'], description: 'Line cap (default butt).' },\n\t\t\t\t\tmiterLimit: { type: 'number', description: 'Miter limit (default 4).' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) =>\n\t\t\t\tcontroller.canOutlineStroke(params?.ids) ? true : 'Select an unlocked shape with a stroke.',\n\t\t\trun: (\n\t\t\t\t_ctx: unknown,\n\t\t\t\tparams: { join?: 'miter' | 'round' | 'bevel'; cap?: 'butt' | 'round' | 'square'; miterLimit?: number; ids?: string[] }\n\t\t\t) =>\n\t\t\t\tcontroller.outlineStroke(params?.ids, {\n\t\t\t\t\t...(params?.join ? { join: params.join } : {}),\n\t\t\t\t\t...(params?.cap ? { cap: params.cap } : {}),\n\t\t\t\t\t...(params?.miterLimit !== undefined ? { miterLimit: params.miterLimit } : {})\n\t\t\t\t})\n\t\t}\n\t];\n}\n\n// ---------------------------------------------------------------------------\n// Canvas components and instances\n// ---------------------------------------------------------------------------\n\ntype ComponentActionResult = { ok: true; ids: string[] } | { ok: false; reason: string };\n\n/** Components surface of the components controller (`createCanvasComponentsController` satisfies it). */\nexport interface ComponentCommandTarget {\n\tcreateComponent(ids?: Iterable<string>): ComponentActionResult;\n\tcanCreateComponent(ids?: Iterable<string>): true | string;\n\tcombineAsVariants(ids?: Iterable<string>): ComponentActionResult;\n\tcanCombineAsVariants(ids?: Iterable<string>): true | string;\n\tcreateInstance(componentId: string, options?: { parentId?: string; position?: { x: number; y: number }; properties?: Record<string, boolean | string> }): ComponentActionResult;\n\tcanCreateInstance(componentId?: string, parentId?: string): true | string;\n\tdetachInstance(ids?: Iterable<string>): ComponentActionResult;\n\tcanDetachInstance(ids?: Iterable<string>): true | string;\n\tresetOverrides(id?: string, group?: string): ComponentActionResult;\n\tcanResetOverrides(id?: string): true | string;\n\tpushOverrides(id?: string): ComponentActionResult;\n\tcanPushOverrides(id?: string): true | string;\n\tswapInstance(componentId: string, ids?: Iterable<string>): ComponentActionResult;\n\tcanSwapInstance(componentId?: string, ids?: Iterable<string>): true | string;\n\tsetInstanceProperties(properties: Record<string, unknown>, ids?: Iterable<string>): ComponentActionResult;\n\tcanSetInstanceProperties(ids?: Iterable<string>): true | string;\n\trestoreMainComponent(id?: string): ComponentActionResult;\n\tcanRestoreMainComponent(id?: string): true | string;\n\tgoToMainComponent(id?: string): string | undefined;\n\tcanGoToMainComponent(id?: string): true | string;\n\tlist(): unknown;\n\tinspect(id?: string): unknown;\n}\n\nexport interface ComponentCommandOptions {\n\t/** Id prefix (default `canvas.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\nconst outcome = (result: ComponentActionResult) => {\n\tif (!result.ok) throw new Error(result.reason);\n\treturn { ids: result.ids };\n};\n\nconst ID_PARAM = { type: 'string', description: 'Instance (or layer inside one) to act on (default: the first selected node).' } as const;\n\n/**\n * Palette / context-menu / agent commands for components and instances:\n * `canvas.createComponent`, `canvas.combineAsVariants`, `canvas.createInstance`\n * (`{ componentId, parentId?, x?, y?, properties? }`), `canvas.detachInstance`,\n * `canvas.resetOverrides` (`{ id?, group? }`), `canvas.pushOverrides`, `canvas.goToMainComponent`,\n * `canvas.swapInstance` (`{ componentId, ids? }`), `canvas.setInstanceProperties`\n * (`{ properties, ids? }`: variant and component property values), `canvas.restoreMainComponent`\n * and the read-only `canvas.listComponents` / `canvas.inspectInstance`. Each action is one\n * undoable step when the controller has a history; enablement explains why it cannot run.\n */\nexport function createComponentCommands(controller: ComponentCommandTarget, options: ComponentCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.';\n\tconst group = options.group ?? 'Components';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst idParams: CommandParamsSchema = { type: 'object', properties: { id: ID_PARAM } };\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}createComponent`,\n\t\t\tlabel: 'Create Component',\n\t\t\tkeywords: ['component', 'symbol', 'main component', 'reusable'],\n\t\t\tdescription: 'Turns the selected frame into a main component, or wraps the selection in one.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tshortcut: 'Mod+Alt+K',\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canCreateComponent(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.createComponent(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}combineAsVariants`,\n\t\t\tlabel: 'Combine as Variants',\n\t\t\tkeywords: ['component set', 'variant', 'variants'],\n\t\t\tdescription: 'Wraps the selected components in a component set.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canCombineAsVariants(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.combineAsVariants(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}createInstance`,\n\t\t\tlabel: 'Create Instance',\n\t\t\tkeywords: ['instance', 'insert component', 'use component'],\n\t\t\tdescription: 'Places an instance of a component (or a component set’s default variant).',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tcomponentId: { type: 'string', description: 'Component or component set id.' },\n\t\t\t\t\tparentId: { type: 'string', description: 'Frame to place it in (default: the canvas).' },\n\t\t\t\t\tx: { type: 'number', description: 'X in the parent’s space (default: next to the main).' },\n\t\t\t\t\ty: { type: 'number', description: 'Y in the parent’s space.' },\n\t\t\t\t\tproperties: { type: 'object', description: 'Variant and component property values.', additionalProperties: true }\n\t\t\t\t},\n\t\t\t\trequired: ['componentId']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { componentId?: string; parentId?: string }) =>\n\t\t\t\tparams?.componentId === undefined ? true : controller.canCreateInstance(params.componentId, params.parentId),\n\t\t\trun: (_ctx: unknown, params: { componentId: string; parentId?: string; x?: number; y?: number; properties?: Record<string, boolean | string> }) =>\n\t\t\t\toutcome(\n\t\t\t\t\tcontroller.createInstance(params.componentId, {\n\t\t\t\t\t\t...(params.parentId !== undefined ? { parentId: params.parentId } : {}),\n\t\t\t\t\t\t...(params.x !== undefined || params.y !== undefined ? { position: { x: params.x ?? 0, y: params.y ?? 0 } } : {}),\n\t\t\t\t\t\t...(params.properties ? { properties: params.properties } : {})\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}detachInstance`,\n\t\t\tlabel: 'Detach Instance',\n\t\t\tkeywords: ['unlink', 'break instance'],\n\t\t\tdescription: 'Turns the selected instances into plain frames that keep their look.',\n\t\t\tparams: IDS_PARAMS,\n\t\t\tshortcut: 'Mod+Alt+B',\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canDetachInstance(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { ids?: string[] }) => outcome(controller.detachInstance(params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}resetOverrides`,\n\t\t\tlabel: 'Reset All Changes',\n\t\t\tkeywords: ['reset instance', 'reset overrides', 'revert'],\n\t\t\tdescription: 'Resets the overrides of an instance (or of a layer, or one override group) to its main.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: ID_PARAM,\n\t\t\t\t\tgroup: { type: 'string', description: 'One override group to reset, e.g. \"data.label\" or \"shape.fill\" (default: all).' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canResetOverrides(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string; group?: string }) => outcome(controller.resetOverrides(params?.id, params?.group))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}pushOverrides`,\n\t\t\tlabel: 'Push Changes to Main Component',\n\t\t\tkeywords: ['push overrides', 'update main component'],\n\t\t\tdescription: 'Copies the instance’s overrides to its main component and every other instance.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canPushOverrides(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => outcome(controller.pushOverrides(params?.id))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}goToMainComponent`,\n\t\t\tlabel: 'Go to Main Component',\n\t\t\tkeywords: ['main component', 'find main', 'reveal'],\n\t\t\tdescription: 'Selects the main component of the selected instance.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canGoToMainComponent(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => {\n\t\t\t\tconst main = controller.goToMainComponent(params?.id);\n\t\t\t\tif (!main) throw new Error('The main component was not found.');\n\t\t\t\treturn { id: main };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}swapInstance`,\n\t\t\tlabel: 'Swap Instance…',\n\t\t\tkeywords: ['replace instance', 'swap component'],\n\t\t\tdescription: 'Makes the selected instances show another component, keeping matching overrides.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tcomponentId: { type: 'string', description: 'Component or component set to swap to.' },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t},\n\t\t\t\trequired: ['componentId']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { componentId?: string; ids?: string[] }) => controller.canSwapInstance(params?.componentId, params?.ids),\n\t\t\trun: (_ctx: unknown, params: { componentId: string; ids?: string[] }) => outcome(controller.swapInstance(params.componentId, params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}setInstanceProperties`,\n\t\t\tlabel: 'Set Instance Properties…',\n\t\t\tkeywords: ['variant', 'switch variant', 'component property', 'toggle'],\n\t\t\tdescription: 'Sets variant properties (switching variants) and component property values of the selected instances.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tproperties: { type: 'object', description: 'Property name → value (variant value, boolean, text or component id).', additionalProperties: true },\n\t\t\t\t\tids: IDS_PARAMS.properties!.ids\n\t\t\t\t},\n\t\t\t\trequired: ['properties']\n\t\t\t},\n\t\t\tenabled: (_ctx: unknown, params?: { ids?: string[] }) => controller.canSetInstanceProperties(params?.ids),\n\t\t\trun: (_ctx: unknown, params: { properties: Record<string, unknown>; ids?: string[] }) =>\n\t\t\t\toutcome(controller.setInstanceProperties(params.properties, params?.ids))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}restoreMainComponent`,\n\t\t\tlabel: 'Restore Main Component',\n\t\t\tkeywords: ['missing main', 'recover component'],\n\t\t\tdescription: 'Turns an instance whose main was deleted back into the main component.',\n\t\t\tparams: idParams,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => controller.canRestoreMainComponent(params?.id),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => outcome(controller.restoreMainComponent(params?.id))\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}listComponents`,\n\t\t\tlabel: 'List Components',\n\t\t\tkeywords: ['components', 'variants', 'assets'],\n\t\t\tdescription: 'Lists the components and component sets (with their variant options).',\n\t\t\treadOnly: true,\n\t\t\trun: () => controller.list()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}inspectInstance`,\n\t\t\tlabel: 'Inspect Instance',\n\t\t\tkeywords: ['instance', 'overrides', 'properties'],\n\t\t\tdescription: 'Describes an instance: its main, variant, property values and overrides.',\n\t\t\tparams: idParams,\n\t\t\treadOnly: true,\n\t\t\tenabled: (_ctx: unknown, params?: { id?: string }) => (controller.inspect(params?.id) ? true : 'Select an instance.'),\n\t\t\trun: (_ctx: unknown, params: { id?: string }) => controller.inspect(params?.id) ?? null\n\t\t}\n\t];\n}\n\n// ---------------------------------------------------------------------------\n// Spreadsheet table actions\n// ---------------------------------------------------------------------------\n\n/** Spreadsheet controller surface used by `createSpreadsheetCommands`. */\nexport interface SpreadsheetCommandTarget {\n\tselectedRange: unknown;\n\tgetFilterState(): { enabled: boolean; rules: readonly unknown[] };\n\ttoggleFilters(): void;\n\tclearFilters(): void;\n\tunhideAll(): void;\n\tmergeCells(): boolean;\n\tunmergeCells(): boolean;\n\ttransposeRange(): boolean;\n}\n\nexport interface SpreadsheetCommandOptions {\n\t/** Id prefix (default `spreadsheet.`). */\n\tprefix?: string;\n\t/** Scope (default `spreadsheet`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\n/** Palette / agent commands for common spreadsheet table actions (no default shortcuts). */\nexport function createSpreadsheetCommands(\n\tcontroller: SpreadsheetCommandTarget,\n\toptions: SpreadsheetCommandOptions = {}\n): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'spreadsheet.';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'spreadsheet';\n\tconst hasRange = () => (controller.selectedRange ? true : 'Select a range first.');\n\tconst base = { group: 'Table', ...(scope ? { scope } : {}) };\n\treturn [\n\t\t{ ...base, id: `${prefix}toggleFilters`, label: 'Toggle Filters', keywords: ['filter'], run: () => controller.toggleFilters() },\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}clearFilters`,\n\t\t\tlabel: 'Clear Filters',\n\t\t\tkeywords: ['filter', 'reset'],\n\t\t\tenabled: () => (controller.getFilterState().rules.length > 0 ? true : 'No filters to clear.'),\n\t\t\trun: () => controller.clearFilters()\n\t\t},\n\t\t{ ...base, id: `${prefix}unhideAll`, label: 'Unhide All Rows and Columns', keywords: ['show', 'hidden'], run: () => controller.unhideAll() },\n\t\t{ ...base, id: `${prefix}mergeCells`, label: 'Merge Cells', keywords: ['combine'], enabled: hasRange, run: () => controller.mergeCells() },\n\t\t{ ...base, id: `${prefix}unmergeCells`, label: 'Unmerge Cells', keywords: ['split'], enabled: hasRange, run: () => controller.unmergeCells() },\n\t\t{ ...base, id: `${prefix}transposeRange`, label: 'Transpose Range', keywords: ['rotate', 'swap rows columns'], enabled: hasRange, run: () => controller.transposeRange() }\n\t];\n}\n","import type { CommandSpec } from './registry.js';\n\n/**\n * Animation controller surface used by `createCanvasAnimationCommands`\n * (`createCanvasAnimationController`, `useCanvasAnimation` and `createCanvasAnimation` satisfy it).\n */\nexport interface AnimationCommandTarget {\n\tgetState(): { playing: boolean; recording: boolean; time: number; duration: number; selection: readonly unknown[] };\n\tplay(): void;\n\tpause(): void;\n\ttoggle(): void;\n\tstop(): void;\n\tseek(time: number): void;\n\ttoggleRecording(): void;\n\taddKeyframe(ids?: Iterable<string>, keys?: readonly string[], time?: number): unknown;\n\tdeleteKeyframes(): unknown;\n\tsetEasing(easing: any, refs?: readonly any[]): unknown;\n\tnextKeyframe(): unknown;\n\tpreviousKeyframe(): unknown;\n\tanimateNode(nodeId: string, options: any): unknown;\n\texportCss(nodeId: string, options?: any): { css: string; exact: boolean };\n}\n\nexport interface AnimationCommandOptions {\n\t/** Id prefix (default `canvas.animation.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\nconst EASING_DESCRIPTION =\n\t'Easing preset (linear, ease, ease-in, ease-out, ease-in-out, ease-in-back, ease-out-back, spring, hold) or a CSS cubic-bezier(x1, y1, x2, y2).';\n\nconst VALUES = {\n\ttype: 'object',\n\tdescription: 'Property → value, e.g. {\"x\": 200, \"opacity\": 0.5, \"fill\": \"#ff0000\"}. Properties: x, y, width, height, rotation (degrees), scale, opacity (0–1), fill, stroke, strokeWidth, cornerRadius, motionPath (0–1).',\n\tadditionalProperties: { type: ['number', 'string'] }\n} as const;\n\n/**\n * Palette / shortcut / agent commands for canvas animation: play / pause, seek, add keyframe at\n * the playhead, delete keyframes, set easing, record toggle, keyframe navigation, \"animate\n * node from A to B over T\" and CSS export. Edits are undoable when the controller has a history.\n */\nexport function createCanvasAnimationCommands(controller: AnimationCommandTarget, options: AnimationCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.animation.';\n\tconst group = options.group ?? 'Animation';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst hasSelection = () => (controller.getState().selection.length > 0 ? true : 'Select keyframes first.');\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}togglePlay`,\n\t\t\tlabel: 'Play / Pause Animation',\n\t\t\tkeywords: ['play', 'pause', 'preview', 'timeline'],\n\t\t\tdescription: 'Plays or pauses the canvas animation from the playhead.',\n\t\t\trun: () => {\n\t\t\t\tcontroller.toggle();\n\t\t\t\treturn { playing: controller.getState().playing, time: controller.getState().time };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}play`,\n\t\t\tlabel: 'Play Animation',\n\t\t\tkeywords: ['preview', 'timeline'],\n\t\t\tenabled: () => (controller.getState().playing ? 'Already playing.' : true),\n\t\t\trun: () => controller.play()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}pause`,\n\t\t\tlabel: 'Pause Animation',\n\t\t\tenabled: () => (controller.getState().playing ? true : 'Not playing.'),\n\t\t\trun: () => controller.pause()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}stop`,\n\t\t\tlabel: 'Stop Animation',\n\t\t\tkeywords: ['rewind', 'reset'],\n\t\t\tdescription: 'Stops playback and returns to the start.',\n\t\t\trun: () => controller.stop()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}seek`,\n\t\t\tlabel: 'Go to Time…',\n\t\t\tkeywords: ['playhead', 'scrub', 'time'],\n\t\t\tdescription: 'Moves the playhead.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { time: { type: 'number', minimum: 0, description: 'Time in milliseconds.' } },\n\t\t\t\trequired: ['time']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { time: number }) => {\n\t\t\t\tcontroller.seek(params.time);\n\t\t\t\treturn { time: controller.getState().time };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}addKeyframe`,\n\t\t\tlabel: 'Add Keyframe at Playhead',\n\t\t\tkeywords: ['key', 'animate', 'record'],\n\t\t\tdescription: 'Keys the selected nodes (or `ids`) at the playhead (or `time`): their animated properties, `properties`, or position.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tids: { type: 'array', items: { type: 'string' }, description: 'Node ids (default: selected nodes).' },\n\t\t\t\t\tproperties: { type: 'array', items: { type: 'string' }, description: 'Properties to key (default: animated ones, or x and y).' },\n\t\t\t\t\ttime: { type: 'number', minimum: 0, description: 'Time in ms (default: the playhead).' }\n\t\t\t\t}\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { ids?: string[]; properties?: string[]; time?: number }) =>\n\t\t\t\tcontroller.addKeyframe(params?.ids, params?.properties, params?.time)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}deleteKeyframes`,\n\t\t\tlabel: 'Delete Keyframes',\n\t\t\tkeywords: ['remove', 'clear'],\n\t\t\tenabled: hasSelection,\n\t\t\trun: () => controller.deleteKeyframes()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}setEasing`,\n\t\t\tlabel: 'Set Keyframe Easing…',\n\t\t\tkeywords: ['interpolation', 'ease', 'bezier', 'spring', 'hold', 'curve'],\n\t\t\tdescription: 'Sets the easing of the segments leaving the selected keyframes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { easing: { type: 'string', description: EASING_DESCRIPTION } },\n\t\t\t\trequired: ['easing']\n\t\t\t},\n\t\t\tenabled: hasSelection,\n\t\t\trun: (_ctx: unknown, params: { easing: string }) => controller.setEasing(params.easing)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}toggleRecord`,\n\t\t\tlabel: 'Toggle Record Mode',\n\t\t\tkeywords: ['auto key', 'record', 'keyframe'],\n\t\t\tdescription: 'In record mode, changing a property at the playhead keys it.',\n\t\t\trun: () => {\n\t\t\t\tcontroller.toggleRecording();\n\t\t\t\treturn { recording: controller.getState().recording };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}nextKeyframe`,\n\t\t\tlabel: 'Next Keyframe',\n\t\t\tkeywords: ['jump', 'navigate'],\n\t\t\trun: () => controller.nextKeyframe()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}previousKeyframe`,\n\t\t\tlabel: 'Previous Keyframe',\n\t\t\tkeywords: ['jump', 'navigate'],\n\t\t\trun: () => controller.previousKeyframe()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}animateNode`,\n\t\t\tlabel: 'Animate Node…',\n\t\t\tkeywords: ['tween', 'transition', 'move', 'fade'],\n\t\t\tdescription: 'Animates a node from `from` (default: its current values) to `to` over `duration` ms, starting at `delay` ms.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tnodeId: { type: 'string', description: 'Node to animate.' },\n\t\t\t\t\tto: VALUES,\n\t\t\t\t\tfrom: VALUES,\n\t\t\t\t\tduration: { type: 'number', exclusiveMinimum: 0, description: 'Duration in ms (default 1000).' },\n\t\t\t\t\tdelay: { type: 'number', minimum: 0, description: 'Start time in ms (default 0).' },\n\t\t\t\t\teasing: { type: 'string', description: EASING_DESCRIPTION }\n\t\t\t\t},\n\t\t\t\trequired: ['nodeId', 'to']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { nodeId: string; to: Record<string, number | string>; from?: Record<string, number | string>; duration?: number; delay?: number; easing?: string }) =>\n\t\t\t\tcontroller.animateNode(params.nodeId, {\n\t\t\t\t\tto: params.to,\n\t\t\t\t\t...(params.from ? { from: params.from } : {}),\n\t\t\t\t\t...(params.duration !== undefined ? { duration: params.duration } : {}),\n\t\t\t\t\t...(params.delay !== undefined ? { delay: params.delay } : {}),\n\t\t\t\t\t...(params.easing !== undefined ? { easing: params.easing } : {})\n\t\t\t\t})\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}exportCss`,\n\t\t\tlabel: 'Export Animation as CSS',\n\t\t\tkeywords: ['keyframes', 'css', 'web animations'],\n\t\t\tdescription: 'Returns CSS @keyframes for a node\\'s animation.',\n\t\t\treadOnly: true,\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { nodeId: { type: 'string' } },\n\t\t\t\trequired: ['nodeId']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { nodeId: string }) => controller.exportCss(params.nodeId)\n\t\t}\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkGO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACtC;AAAA,EAET,YAAY,MAAoC,SAAiB;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACb;AACD;AAEA,IAAM,mBAAmB;AAOzB,SAAS,WAAW,QAA6E;AAChG,MAAI,WAAW,UAAa,WAAW,KAAM,QAAO,EAAE,SAAS,KAAK;AACpE,MAAI,WAAW,MAAO,QAAO,EAAE,SAAS,OAAO,QAAQ,2CAA2C;AAClG,SAAO,EAAE,SAAS,OAAO,QAAQ,OAAO,MAAM,EAAE;AACjD;AAGA,SAAS,cAAc,MAAmB,QAAgD;AACzF,QAAM,OAAO,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,MAAM,MAAS;AACtE,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAM,SAAS,KAAK;AACpB,MAAI,UAAU,OAAO,yBAAyB,UAAa,OAAO,yBAAyB,MAAO,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,UAAU,OAAO,MAAM;AAAA,IACvF;AAAA,EACD;AACD;","names":["outcome"]}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/registry.ts","../../src/commands/palette.ts","../../src/commands/paletteController.ts","../../src/commands/agentTools.ts","../../src/commands/animation.ts"],"sourcesContent":["// Portions ported from filmcraft-main/crates/engine/src/commands.rs and crates/engine/src/lib.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\nimport { validateJsonSchema, type JsonSchema, type SchemaValidationError } from '../agent/schema.js';\nimport type { KeyboardEventLike, Platform } from './chords.js';\nimport {\n\tShortcutMap,\n\ttoShortcutBindings,\n\ttype ShortcutInput,\n\ttype ShortcutMapOptions,\n\ttype ShortcutResolveOptions\n} from './shortcuts.js';\n\n/** Object JSON Schema describing a command's parameters. */\nexport type CommandParamsSchema = JsonSchema & { type: 'object' };\n\n/**\n * Metadata and implementation of one command. Menus, shortcuts, the palette and agent\n * tools all run commands by id, so every entry point shares enablement and validation.\n */\nexport interface CommandSpec<TContext = any, TParams = any, TResult = unknown> {\n\t/** Unique id, e.g. `history.undo` or `canvas.alignLeft`. */\n\tid: string;\n\tlabel: string;\n\t/** Group / menu name shown next to the label, e.g. `Edit` or `Arrange`. */\n\tgroup?: string;\n\t/** Extra search terms for the palette. */\n\tkeywords?: readonly string[];\n\tdescription?: string;\n\t/** Object JSON Schema for `params`. Unknown keys are rejected unless `additionalProperties` allows them. */\n\tparams?: CommandParamsSchema;\n\t/** Default shortcut(s): platform-neutral chord text such as `Mod+Shift+Z`. */\n\tshortcut?: ShortcutInput;\n\t/** Scope the command (and its shortcuts) belong to, e.g. `canvas`. Omit for global commands. */\n\tscope?: string;\n\t/**\n\t * Whether the command can run: `true` (or `undefined`), `false`, or a reason string\n\t * (\"Nothing to undo\"). Receives the params a caller named, so a command acting on the\n\t * selection can still run on targets passed explicitly (`params` is `undefined` for menus).\n\t */\n\tenabled?: (context: TContext, params: TParams | undefined) => boolean | string | undefined;\n\trun: (context: TContext, params: TParams) => TResult;\n\t/**\n\t * Runs inside the registry's `history.batch(label, …)`, so all history entries the\n\t * command records become one undo step and a throw rolls back its partial changes.\n\t */\n\tundoable?: boolean;\n\t/** The command only reads state (agent tools mark it read-only). */\n\treadOnly?: boolean;\n\t/** Hide from the palette and `list()` unless `includeHidden` (still runnable by id). */\n\thidden?: boolean;\n}\n\nexport type CommandErrorCode = 'unknown_command' | 'disabled' | 'invalid_params' | 'failed';\n\nexport type CommandResult<T = unknown> =\n\t| { ok: true; id: string; result: T }\n\t| { ok: false; id: string; code: CommandErrorCode; message: string; details?: SchemaValidationError[] };\n\n/** A command as listed for menus, palettes and agents. */\nexport interface CommandEntry {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\tkeywords?: readonly string[];\n\tdescription?: string;\n\tparams?: CommandParamsSchema;\n\tscope?: string;\n\t/** Canonical chord text bound on the registry's platform (first = primary). */\n\tshortcuts: string[];\n\tenabled: boolean;\n\t/** Why the command is disabled (only when `enabled` is false). */\n\tdisabledReason?: string;\n\tundoable: boolean;\n\treadOnly: boolean;\n}\n\nexport interface CommandListOptions<TContext = any> {\n\t/** Only global commands plus commands of these scopes. */\n\tscope?: string | readonly string[];\n\tenabledOnly?: boolean;\n\tincludeHidden?: boolean;\n\t/** Context for the enablement check (default: the registry's context). */\n\tcontext?: TContext;\n}\n\n/** Minimal history surface (`HistoryManager` satisfies it). */\nexport interface CommandHistoryTarget {\n\tbatch(name: string, fn: () => void): void;\n}\n\nexport interface CommandRegistryOptions<TContext = any> {\n\t/** Default context passed to `enabled` / `run` (a value or a getter). */\n\tcontext?: TContext | (() => TContext);\n\t/** Wraps `undoable` commands in one history step (see `CommandSpec.undoable`). */\n\thistory?: CommandHistoryTarget;\n\t/** Options for the registry's `ShortcutMap`. */\n\tshortcuts?: ShortcutMapOptions;\n}\n\nexport class CommandRegistryError extends Error {\n\treadonly code: 'duplicate_command' | 'invalid_command';\n\n\tconstructor(code: CommandRegistryError['code'], message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'CommandRegistryError';\n\t\tthis.code = code;\n\t}\n}\n\nconst COMMAND_ID_REGEX = /^[A-Za-z0-9_.:-]{1,128}$/;\n\ninterface Registered {\n\tspec: CommandSpec;\n\tunbind: () => void;\n}\n\nfunction enablement(result: boolean | string | undefined): { enabled: boolean; reason?: string } {\n\tif (result === undefined || result === true) return { enabled: true };\n\tif (result === false) return { enabled: false, reason: 'This command is not available right now.' };\n\treturn { enabled: false, reason: String(result) };\n}\n\n/** Errors for params the command does not accept, naming the accepted keys. */\nfunction unknownParams(spec: CommandSpec, params: Record<string, unknown>): string | null {\n\tconst keys = Object.keys(params).filter((k) => params[k] !== undefined);\n\tif (keys.length === 0) return null;\n\tconst schema = spec.params;\n\tif (schema && schema.additionalProperties !== undefined && schema.additionalProperties !== false) return null;\n\tconst accepted = Object.keys(schema?.properties ?? {});\n\tconst bad = keys.find((k) => !accepted.includes(k));\n\tif (!bad) return null;\n\treturn `Unknown parameter \"${bad}\" for command \"${spec.id}\"; expected ${\n\t\taccepted.length ? accepted.map((k) => `\"${k}\"`).join(', ') : 'no parameters'\n\t}.`;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n\t!!value && (typeof value === 'object' || typeof value === 'function') && typeof (value as any).then === 'function';\n\n/**\n * Registry of commands: one id per action, shared by shortcuts (`shortcuts`), the\n * command palette (`list` + `rankCommands`) and agent tools (`createCommandToolProvider`).\n */\nexport class CommandRegistry<TContext = any> {\n\t/** Shortcut bindings of the registered commands (plus any user overrides). */\n\treadonly shortcuts: ShortcutMap;\n\n\tprivate readonly commands = new Map<string, Registered>();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly options: CommandRegistryOptions<TContext>;\n\tprivate version = 0;\n\t// Set while register/unregister change the shortcut map, so they notify once.\n\tprivate muted = false;\n\n\tconstructor(options: CommandRegistryOptions<TContext> = {}) {\n\t\tthis.options = options;\n\t\tthis.shortcuts = new ShortcutMap([], options.shortcuts);\n\t\tthis.shortcuts.subscribe(() => {\n\t\t\tif (!this.muted) this.notify();\n\t\t});\n\t}\n\n\t/** Monotonic counter bumped on every change (useful as a snapshot key). */\n\tgetVersion(): number {\n\t\treturn this.version;\n\t}\n\n\t/** The default context. */\n\tget context(): TContext {\n\t\tconst ctx = this.options.context;\n\t\treturn (typeof ctx === 'function' ? (ctx as () => TContext)() : ctx) as TContext;\n\t}\n\n\t/**\n\t * Registers a command (or several) and returns a function that unregisters it.\n\t * Throws a `CommandRegistryError` for a duplicate or invalid id, or invalid chord text.\n\t */\n\tregister(spec: CommandSpec<TContext> | readonly CommandSpec<TContext>[]): () => void {\n\t\tconst specs = (Array.isArray(spec) ? spec : [spec]) as CommandSpec<TContext>[];\n\t\tconst seen = new Set<string>();\n\t\tfor (const s of specs) {\n\t\t\tif (!s || typeof s.id !== 'string' || !COMMAND_ID_REGEX.test(s.id)) {\n\t\t\t\tthrow new CommandRegistryError('invalid_command', `Invalid command id \"${s?.id}\".`);\n\t\t\t}\n\t\t\tif (typeof s.run !== 'function') {\n\t\t\t\tthrow new CommandRegistryError('invalid_command', `Command \"${s.id}\" has no run function.`);\n\t\t\t}\n\t\t\tif (this.commands.has(s.id) || seen.has(s.id)) {\n\t\t\t\tthrow new CommandRegistryError('duplicate_command', `Command \"${s.id}\" is already registered.`);\n\t\t\t}\n\t\t\tseen.add(s.id);\n\t\t}\n\t\t// Parse every chord before registering anything, so a bad shortcut registers nothing.\n\t\tconst bindings = specs.map((s) => toShortcutBindings(s.id, s.shortcut, s.scope));\n\t\tconst unbinds: Array<() => void> = [];\n\t\tthis.muted = true;\n\t\ttry {\n\t\t\tfor (const b of bindings) unbinds.push(this.shortcuts.bind(b));\n\t\t} catch (error) {\n\t\t\tunbinds.forEach((u) => u());\n\t\t\tthrow new CommandRegistryError('invalid_command', error instanceof Error ? error.message : String(error));\n\t\t} finally {\n\t\t\tthis.muted = false;\n\t\t}\n\t\tspecs.forEach((s, i) => this.commands.set(s.id, { spec: s, unbind: unbinds[i] }));\n\t\tthis.notify();\n\t\tlet registered = true;\n\t\treturn () => {\n\t\t\tif (!registered) return;\n\t\t\tregistered = false;\n\t\t\tlet changed = false;\n\t\t\tfor (const s of specs) {\n\t\t\t\tconst entry = this.commands.get(s.id);\n\t\t\t\tif (entry && entry.spec === s) {\n\t\t\t\t\tthis.commands.delete(s.id);\n\t\t\t\t\tthis.unbindQuietly(entry);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (changed) this.notify();\n\t\t};\n\t}\n\n\t/** Removes a command by id. Returns whether it was registered. */\n\tunregister(id: string): boolean {\n\t\tconst entry = this.commands.get(id);\n\t\tif (!entry) return false;\n\t\tthis.commands.delete(id);\n\t\tthis.unbindQuietly(entry);\n\t\tthis.notify();\n\t\treturn true;\n\t}\n\n\tprivate unbindQuietly(entry: Registered) {\n\t\tthis.muted = true;\n\t\ttry {\n\t\t\tentry.unbind();\n\t\t} finally {\n\t\t\tthis.muted = false;\n\t\t}\n\t}\n\n\thas(id: string): boolean {\n\t\treturn this.commands.has(id);\n\t}\n\n\tget(id: string): CommandSpec<TContext> | undefined {\n\t\treturn this.commands.get(id)?.spec;\n\t}\n\n\t/** Registered ids in registration order. */\n\tids(): string[] {\n\t\treturn [...this.commands.keys()];\n\t}\n\n\t/** Whether `id` can run now (`{ enabled, reason }`); `params` are the targets a caller named. */\n\tisEnabled(id: string, params?: unknown, context: TContext = this.context): { enabled: boolean; reason?: string } {\n\t\tconst spec = this.get(id);\n\t\tif (!spec) return { enabled: false, reason: `Unknown command \"${id}\".` };\n\t\tif (!spec.enabled) return { enabled: true };\n\t\ttry {\n\t\t\treturn enablement(spec.enabled(context, params as any));\n\t\t} catch (error) {\n\t\t\treturn { enabled: false, reason: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/** Commands for menus, palettes and agents, with their current enablement. */\n\tlist(options: CommandListOptions<TContext> = {}): CommandEntry[] {\n\t\tconst scopes = options.scope === undefined ? null : typeof options.scope === 'string' ? [options.scope] : options.scope;\n\t\tconst context = 'context' in options ? (options.context as TContext) : this.context;\n\t\tconst platform = this.shortcuts.platform;\n\t\tconst out: CommandEntry[] = [];\n\t\tfor (const { spec } of this.commands.values()) {\n\t\t\tif (spec.hidden && !options.includeHidden) continue;\n\t\t\tif (scopes && spec.scope !== undefined && !scopes.includes(spec.scope)) continue;\n\t\t\tconst { enabled, reason } = this.isEnabled(spec.id, undefined, context);\n\t\t\tif (options.enabledOnly && !enabled) continue;\n\t\t\tout.push({\n\t\t\t\tid: spec.id,\n\t\t\t\tlabel: spec.label,\n\t\t\t\t...(spec.group !== undefined ? { group: spec.group } : {}),\n\t\t\t\t...(spec.keywords ? { keywords: spec.keywords } : {}),\n\t\t\t\t...(spec.description !== undefined ? { description: spec.description } : {}),\n\t\t\t\t...(spec.params ? { params: spec.params } : {}),\n\t\t\t\t...(spec.scope !== undefined ? { scope: spec.scope } : {}),\n\t\t\t\tshortcuts: this.shortcuts.forCommand(spec.id, platform),\n\t\t\t\tenabled,\n\t\t\t\t...(enabled ? {} : { disabledReason: reason }),\n\t\t\t\tundoable: !!spec.undoable,\n\t\t\t\treadOnly: !!spec.readOnly\n\t\t\t});\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate check(id: string, params: unknown, context: TContext): CommandResult<never> | { spec: CommandSpec<TContext>; params: any } {\n\t\tconst spec = this.get(id);\n\t\tif (!spec) return { ok: false, id, code: 'unknown_command', message: `Unknown command \"${id}\".` };\n\t\tconst input = params ?? {};\n\t\tif (typeof input !== 'object' || Array.isArray(input)) {\n\t\t\treturn { ok: false, id, code: 'invalid_params', message: `Parameters for command \"${id}\" must be an object.` };\n\t\t}\n\t\tconst unknown = unknownParams(spec, input as Record<string, unknown>);\n\t\tif (unknown) return { ok: false, id, code: 'invalid_params', message: unknown };\n\t\tif (spec.params) {\n\t\t\tconst details = validateJsonSchema(input, spec.params);\n\t\t\tif (details.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tid,\n\t\t\t\t\tcode: 'invalid_params',\n\t\t\t\t\tmessage: `Invalid parameters for command \"${id}\": ${details.map((d) => `${d.path} ${d.message}`).join('; ')}`,\n\t\t\t\t\tdetails\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tconst { enabled, reason } = this.isEnabled(id, params === undefined ? undefined : input, context);\n\t\tif (!enabled) return { ok: false, id, code: 'disabled', message: reason ?? 'Disabled.' };\n\t\treturn { spec, params: input };\n\t}\n\n\tprivate invoke(spec: CommandSpec<TContext>, params: any, context: TContext): unknown {\n\t\tconst history = this.options.history;\n\t\tif (!spec.undoable || !history) return spec.run(context, params);\n\t\tlet value: unknown;\n\t\t// `batch` rolls back already-recorded steps and rethrows when `run` throws.\n\t\thistory.batch(spec.label, () => {\n\t\t\tvalue = spec.run(context, params);\n\t\t});\n\t\treturn value;\n\t}\n\n\t/**\n\t * Runs a command synchronously and returns a structured result; never throws.\n\t * A command whose `run` returns a promise yields `{ ok: true, result: promise }`\n\t * (use `executeAsync` to await it and catch its rejection).\n\t */\n\texecute<T = unknown>(id: string, params?: unknown, context: TContext = this.context): CommandResult<T> {\n\t\tconst checked = this.check(id, params, context);\n\t\tif ('ok' in checked) return checked;\n\t\ttry {\n\t\t\tconst result = this.invoke(checked.spec, checked.params, context);\n\t\t\tthis.notify();\n\t\t\treturn { ok: true, id, result: result as T };\n\t\t} catch (error) {\n\t\t\tthis.notify();\n\t\t\treturn { ok: false, id, code: 'failed', message: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/** Like `execute`, but awaits async commands (rejections become `failed` results). */\n\tasync executeAsync<T = unknown>(id: string, params?: unknown, context: TContext = this.context): Promise<CommandResult<T>> {\n\t\tconst outcome = this.execute<T>(id, params, context);\n\t\tif (!outcome.ok || !isThenable(outcome.result)) return outcome;\n\t\ttry {\n\t\t\tconst result = await outcome.result;\n\t\t\tthis.notify();\n\t\t\treturn { ok: true, id, result: result as T };\n\t\t} catch (error) {\n\t\t\tthis.notify();\n\t\t\treturn { ok: false, id, code: 'failed', message: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t}\n\n\t/**\n\t * Resolves a keydown event to a command (see `ShortcutMap.resolve`) and runs it when\n\t * enabled, calling `preventDefault()`. Disabled commands leave the event alone, so the\n\t * browser or a focused editor can still handle it. Returns the result, or `null`.\n\t */\n\thandleKeyDown(\n\t\tevent: KeyboardEventLike,\n\t\toptions: ShortcutResolveOptions & { context?: TContext } = {}\n\t): CommandResult | null {\n\t\tif (event.defaultPrevented) return null;\n\t\tconst match = this.shortcuts.resolve(event, options);\n\t\tif (!match) return null;\n\t\tconst context = 'context' in options ? (options.context as TContext) : this.context;\n\t\tif (!this.isEnabled(match.command, undefined, context).enabled) return null;\n\t\tevent.preventDefault?.();\n\t\treturn this.execute(match.command, undefined, context);\n\t}\n\n\t/** Display-ready primary shortcut of a command (`⇧⌘Z` / `Ctrl+Shift+Z`), or `undefined`. */\n\tshortcutFor(id: string, platform: Platform = this.shortcuts.platform): string | undefined {\n\t\treturn this.shortcuts.forCommand(id, platform)[0];\n\t}\n\n\t/**\n\t * Subscribes to changes: commands registered or removed, shortcut overrides, executed\n\t * commands and `invalidate()` calls (e.g. when enablement inputs change).\n\t */\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Tells subscribers that enablement may have changed (e.g. the selection changed). */\n\tinvalidate(): void {\n\t\tthis.notify();\n\t}\n\n\tprivate notify(): void {\n\t\tthis.version++;\n\t\tfor (const listener of Array.from(this.listeners)) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[CommandRegistry] Error in listener:', error);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function createCommandRegistry<TContext = any>(options?: CommandRegistryOptions<TContext>): CommandRegistry<TContext> {\n\treturn new CommandRegistry<TContext>(options);\n}\n\n/** Identity helper that types a command spec. */\nexport function defineCommand<TContext = any, TParams = any, TResult = unknown>(\n\tspec: CommandSpec<TContext, TParams, TResult>\n): CommandSpec<TContext, TParams, TResult> {\n\treturn spec;\n}\n","// Portions ported from photocraft-main/crates/ui-egui/src/palette.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/** The fields `rankCommands` searches (a `CommandEntry` satisfies it). */\nexport interface RankableCommand {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\tkeywords?: readonly string[];\n\tenabled?: boolean;\n}\n\nexport interface FuzzyMatch {\n\tscore: number;\n\t/** Indices of the matched characters in the text (for highlighting). */\n\tindices: number[];\n}\n\nconst WORD_SEPARATORS = new Set([' ', '-', '_', '.', '/', ':', '›', '(']);\n\n/**\n * Subsequence fuzzy match: every query character must appear in order. Consecutive\n * matches score 8, others 1; a match at a word start adds 5; longer texts lose\n * `length / 8`. Case-insensitive. Returns `null` when the query does not match.\n */\nexport function fuzzyMatch(query: string, text: string): FuzzyMatch | null {\n\tconst q = query.trim().toLowerCase();\n\tif (!q) return { score: 0, indices: [] };\n\tconst t = text.toLowerCase();\n\tlet score = 0;\n\tlet ti = 0;\n\tlet last = -2;\n\tconst indices: number[] = [];\n\tfor (const qc of q) {\n\t\tif (qc === ' ') continue;\n\t\tlet found = false;\n\t\twhile (ti < t.length) {\n\t\t\tif (t[ti] === qc) {\n\t\t\t\tscore += last === ti - 1 ? 8 : 1;\n\t\t\t\tif (ti === 0 || WORD_SEPARATORS.has(t[ti - 1])) score += 5;\n\t\t\t\tlast = ti;\n\t\t\t\tindices.push(ti);\n\t\t\t\tti++;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tti++;\n\t\t}\n\t\tif (!found) return null;\n\t}\n\treturn { score: score - Math.floor(t.length / 8), indices };\n}\n\n/** `fuzzyMatch(query, text)?.score ?? null`. */\nexport function fuzzyScore(query: string, text: string): number | null {\n\treturn fuzzyMatch(query, text)?.score ?? null;\n}\n\n/**\n * Bonus that puts a command whose name is exactly the query ahead of every fuzzy match\n * (\"undo\" finds Undo before \"Undo Selection Change\"). Trailing ellipses are ignored.\n */\nexport function exactBonus(query: string, names: readonly string[]): number {\n\tconst q = query.trim().toLowerCase();\n\tif (!q) return 0;\n\treturn names.some((n) => n.replace(/(…|\\.\\.\\.)$/, '').trim().toLowerCase() === q) ? 1000 : 0;\n}\n\n/** Default number of recently run commands a palette remembers. */\nexport const DEFAULT_RECENT_LIMIT = 8;\n\n/** Moves `id` to the front of `list` (deduplicated, newest first, at most `cap`). Returns a new array. */\nexport function pushRecent(list: readonly string[], id: string, cap: number = DEFAULT_RECENT_LIMIT): string[] {\n\treturn [id, ...list.filter((x) => x !== id)].slice(0, Math.max(0, cap));\n}\n\nexport interface RankedCommand<T extends RankableCommand = RankableCommand> {\n\tentry: T;\n\tscore: number;\n\t/** Matched character indices in `entry.label` (empty when another field matched). */\n\tlabelIndices: number[];\n\t/** The entry was shown because it was run recently (empty query). */\n\trecent: boolean;\n}\n\nexport interface RankCommandsOptions {\n\t/** Recently run ids, newest first. Shown first for an empty query and boosted slightly otherwise. */\n\trecents?: readonly string[];\n\t/** Maximum number of recents shown for an empty query (default 8). */\n\trecentLimit?: number;\n\t/** Maximum number of results. */\n\tlimit?: number;\n\t/** Sort disabled commands after enabled ones (default `true`). */\n\tdisabledLast?: boolean;\n\t/** With an empty query: `all` (default) lists recents then every other command; `recents` lists only recents. */\n\temptyQuery?: 'all' | 'recents';\n}\n\n/**\n * Ranks commands for a palette query. Searches the label, `group label`, keywords and id;\n * an exact label or keyword match always wins. An empty query lists recent commands\n * first (deduplicated and capped), then the rest in their original order.\n */\nexport function rankCommands<T extends RankableCommand>(\n\tquery: string,\n\tentries: readonly T[],\n\toptions: RankCommandsOptions = {}\n): RankedCommand<T>[] {\n\tconst recents = options.recents ?? [];\n\tconst disabledLast = options.disabledLast ?? true;\n\tconst q = query.trim();\n\tlet ranked: Array<RankedCommand<T> & { order: number }>;\n\n\tif (!q) {\n\t\tconst byId = new Map(entries.map((e) => [e.id, e]));\n\t\tconst recentIds = [...new Set(recents)].filter((id) => byId.has(id)).slice(0, options.recentLimit ?? DEFAULT_RECENT_LIMIT);\n\t\tconst recentSet = new Set(recentIds);\n\t\tranked = recentIds.map((id, i) => ({ entry: byId.get(id)!, score: 1000 - i, labelIndices: [], recent: true, order: i }));\n\t\tif ((options.emptyQuery ?? 'all') === 'all') {\n\t\t\tentries.forEach((entry, i) => {\n\t\t\t\tif (!recentSet.has(entry.id)) ranked.push({ entry, score: 0, labelIndices: [], recent: false, order: recentIds.length + i });\n\t\t\t});\n\t\t}\n\t} else {\n\t\tranked = [];\n\t\tentries.forEach((entry, order) => {\n\t\t\tconst label = fuzzyMatch(q, entry.label);\n\t\t\tconst candidates: number[] = [];\n\t\t\tif (label) candidates.push(label.score);\n\t\t\tif (entry.group) {\n\t\t\t\tconst grouped = fuzzyScore(q, `${entry.group} ${entry.label}`);\n\t\t\t\tif (grouped !== null) candidates.push(grouped - 1);\n\t\t\t}\n\t\t\tfor (const keyword of entry.keywords ?? []) {\n\t\t\t\tconst s = fuzzyScore(q, keyword);\n\t\t\t\tif (s !== null) candidates.push(s - 2);\n\t\t\t}\n\t\t\tconst byId = fuzzyScore(q, entry.id);\n\t\t\tif (byId !== null) candidates.push(byId - 3);\n\t\t\tif (candidates.length === 0) return;\n\t\t\tconst recentIndex = recents.indexOf(entry.id);\n\t\t\tconst score =\n\t\t\t\tMath.max(...candidates) +\n\t\t\t\texactBonus(q, [entry.label, ...(entry.keywords ?? [])]) +\n\t\t\t\t(recentIndex >= 0 ? Math.max(1, 4 - recentIndex) : 0);\n\t\t\tranked.push({ entry, score, labelIndices: label?.indices ?? [], recent: false, order });\n\t\t});\n\t\tranked.sort((a, b) => b.score - a.score || a.entry.label.length - b.entry.label.length || a.order - b.order);\n\t}\n\n\tif (disabledLast) {\n\t\t// Stable partition: enabled first, keeping the ranking within each half.\n\t\tranked = [...ranked.filter((r) => r.entry.enabled !== false), ...ranked.filter((r) => r.entry.enabled === false)];\n\t}\n\tconst out = ranked.map(({ order: _order, ...rest }) => rest);\n\treturn options.limit !== undefined ? out.slice(0, options.limit) : out;\n}\n","import { formatShortcut, type KeyboardEventLike, type Platform } from './chords.js';\nimport { DEFAULT_RECENT_LIMIT, pushRecent, rankCommands, type RankedCommand } from './palette.js';\nimport type { CommandEntry, CommandRegistry, CommandResult } from './registry.js';\nimport { ShortcutMap } from './shortcuts.js';\n\n/** One palette row. */\nexport interface CommandPaletteItem extends RankedCommand<CommandEntry> {\n\tid: string;\n\tlabel: string;\n\tgroup?: string;\n\t/** Display-ready primary shortcut (`⇧⌘Z` / `Ctrl+Shift+Z`). */\n\tshortcut?: string;\n\tenabled: boolean;\n\tdisabledReason?: string;\n}\n\nexport interface CommandPaletteState {\n\topen: boolean;\n\tquery: string;\n\tactiveIndex: number;\n\titems: CommandPaletteItem[];\n\trecents: string[];\n\t/** Result of the last command the palette ran. */\n\tlastResult: CommandResult | null;\n}\n\nexport interface CommandPaletteOptions<TContext = any> {\n\t/** Context for enablement and runs (default: the registry's). */\n\tcontext?: TContext | (() => TContext);\n\t/** Only global commands plus these scopes. */\n\tscope?: string | readonly string[] | (() => string | readonly string[] | undefined);\n\t/** Initial recently run ids (newest first), e.g. restored from storage. */\n\trecents?: readonly string[];\n\t/** Called whenever the recents change, e.g. to persist them. */\n\tonRecentsChange?: (recents: string[]) => void;\n\trecentLimit?: number;\n\t/** Maximum rows (default 50). */\n\tlimit?: number;\n\t/** Platform for shortcut display (default: detected). */\n\tplatform?: Platform;\n\t/** Called after a command ran from the palette. */\n\tonRun?: (result: CommandResult) => void;\n}\n\n/**\n * Framework-agnostic command palette state (open, query, ranked rows, active row and\n * recents) over a `CommandRegistry`. The React hook and Svelte rune wrap it.\n */\nexport function createCommandPaletteController<TContext = any>(\n\tregistry: CommandRegistry<TContext>,\n\toptions: CommandPaletteOptions<TContext> = {}\n) {\n\tconst listeners = new Set<(state: CommandPaletteState) => void>();\n\tlet open = false;\n\tlet query = '';\n\tlet activeIndex = 0;\n\tlet recents = [...(options.recents ?? [])];\n\tlet lastResult: CommandResult | null = null;\n\tlet state: CommandPaletteState;\n\n\tconst context = (): TContext => {\n\t\tconst c = options.context;\n\t\tif (c === undefined) return registry.context;\n\t\treturn (typeof c === 'function' ? (c as () => TContext)() : c) as TContext;\n\t};\n\tconst scope = () => (typeof options.scope === 'function' ? options.scope() : options.scope);\n\n\tfunction computeItems(): CommandPaletteItem[] {\n\t\tif (!open) return [];\n\t\tconst entries = registry.list({ scope: scope(), context: context() });\n\t\tconst platform = options.platform ?? registry.shortcuts.platform;\n\t\treturn rankCommands(query, entries, {\n\t\t\trecents,\n\t\t\trecentLimit: options.recentLimit,\n\t\t\tlimit: options.limit ?? 50\n\t\t}).map((ranked) => ({\n\t\t\t...ranked,\n\t\t\tid: ranked.entry.id,\n\t\t\tlabel: ranked.entry.label,\n\t\t\t...(ranked.entry.group !== undefined ? { group: ranked.entry.group } : {}),\n\t\t\t...(ranked.entry.shortcuts[0] ? { shortcut: formatShortcut(ranked.entry.shortcuts[0], platform) } : {}),\n\t\t\tenabled: ranked.entry.enabled,\n\t\t\t...(ranked.entry.disabledReason ? { disabledReason: ranked.entry.disabledReason } : {})\n\t\t}));\n\t}\n\n\tfunction update() {\n\t\tconst items = computeItems();\n\t\tactiveIndex = items.length === 0 ? 0 : Math.min(Math.max(activeIndex, 0), items.length - 1);\n\t\tstate = { open, query, activeIndex, items, recents, lastResult };\n\t\tfor (const listener of Array.from(listeners)) listener(state);\n\t}\n\n\tstate = { open, query, activeIndex, items: [], recents, lastResult };\n\t// Follow registry changes only while someone listens (safe with React StrictMode remounts).\n\tlet unsubscribeRegistry: (() => void) | null = null;\n\tconst onRegistryChange = () => {\n\t\tif (open) update();\n\t};\n\n\tconst controller = {\n\t\tgetState: () => state,\n\t\tsubscribe(listener: (state: CommandPaletteState) => void): () => void {\n\t\t\tlisteners.add(listener);\n\t\t\tunsubscribeRegistry ??= registry.subscribe(onRegistryChange);\n\t\t\tif (open) update(); // catch up with changes made while nobody listened\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t\tif (listeners.size === 0) {\n\t\t\t\t\tunsubscribeRegistry?.();\n\t\t\t\t\tunsubscribeRegistry = null;\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tsetOpen(next: boolean) {\n\t\t\tif (next === open) return;\n\t\t\topen = next;\n\t\t\tquery = '';\n\t\t\tactiveIndex = 0;\n\t\t\tupdate();\n\t\t},\n\t\ttoggle() {\n\t\t\tcontroller.setOpen(!open);\n\t\t},\n\t\tsetQuery(next: string) {\n\t\t\tif (next === query) return;\n\t\t\tquery = next;\n\t\t\tactiveIndex = 0;\n\t\t\tupdate();\n\t\t},\n\t\tsetActiveIndex(index: number) {\n\t\t\tactiveIndex = index;\n\t\t\tupdate();\n\t\t},\n\t\t/** Moves the active row by `delta`, wrapping around. */\n\t\tmove(delta: number) {\n\t\t\tconst n = state.items.length;\n\t\t\tif (n === 0) return;\n\t\t\tactiveIndex = (((activeIndex + delta) % n) + n) % n;\n\t\t\tupdate();\n\t\t},\n\t\t/** Runs a command by id, closes the palette and records it as recent. Disabled commands do nothing. */\n\t\trun(id: string): CommandResult | null {\n\t\t\tif (!registry.isEnabled(id, undefined, context()).enabled) return null;\n\t\t\topen = false;\n\t\t\tquery = '';\n\t\t\tactiveIndex = 0;\n\t\t\trecents = pushRecent(recents, id, options.recentLimit ?? DEFAULT_RECENT_LIMIT);\n\t\t\toptions.onRecentsChange?.(recents);\n\t\t\tconst result = registry.execute(id, undefined, context());\n\t\t\tlastResult = result;\n\t\t\tupdate();\n\t\t\toptions.onRun?.(result);\n\t\t\treturn result;\n\t\t},\n\t\trunActive(): CommandResult | null {\n\t\t\tconst item = state.items[state.activeIndex];\n\t\t\treturn item ? controller.run(item.id) : null;\n\t\t},\n\t\t/**\n\t\t * Keyboard handling for the palette input: ArrowUp/ArrowDown (wrap), Home/End,\n\t\t * Enter (run the active row) and Escape (close). Returns whether it handled the key.\n\t\t */\n\t\thandleKeyDown(event: KeyboardEventLike): boolean {\n\t\t\tif (!open) return false;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcontroller.move(1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tcontroller.move(-1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tcontroller.setActiveIndex(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tcontroller.setActiveIndex(state.items.length - 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Enter':\n\t\t\t\t\tcontroller.runActive();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tcontroller.setOpen(false);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\tevent.preventDefault?.();\n\t\t\treturn true;\n\t\t},\n\t\t/** Re-reads commands and enablement. */\n\t\trefresh() {\n\t\t\tupdate();\n\t\t},\n\t\tdestroy() {\n\t\t\tunsubscribeRegistry?.();\n\t\t\tunsubscribeRegistry = null;\n\t\t\tlisteners.clear();\n\t\t}\n\t};\n\treturn controller;\n}\n\nexport type CommandPaletteController = ReturnType<typeof createCommandPaletteController>;\n\n/**\n * Matches a global \"open palette\" hotkey (e.g. `Mod+K`), also while typing in inputs.\n * Returns `true` when `event` is the hotkey.\n */\nexport function matchPaletteHotkey(event: KeyboardEventLike, hotkey: string, platform?: Platform): boolean {\n\tconst map = new ShortcutMap([{ command: 'palette', chord: hotkey, allowInEditable: true }], platform ? { platform } : {});\n\treturn map.resolve(event) !== null;\n}\n","// Portions ported from filmcraft-main/crates/automation/src/server.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\nimport type { AgentTool, AgentToolProvider, McpToolResult } from '../agent/registry.js';\nimport { rankCommands } from './palette.js';\nimport type { CommandRegistry, CommandResult } from './registry.js';\n\nexport interface CommandToolProviderOptions<TContext = any> {\n\t/** Provider id (default `commands`). */\n\tid?: string;\n\t/** Always prefix the tool names with `<namespace>__`. */\n\tnamespace?: string;\n\t/** Context for enablement and runs (default: the registry's). */\n\tcontext?: TContext | (() => TContext);\n\t/** Only expose global commands plus these scopes. */\n\tscope?: string | readonly string[];\n\t/** Commands agents may not see or run (e.g. ones that open dialogs). */\n\texclude?: (id: string) => boolean;\n}\n\nconst toJson = (value: unknown): unknown => {\n\tif (value === undefined) return null;\n\ttry {\n\t\treturn JSON.parse(JSON.stringify(value));\n\t} catch {\n\t\treturn String(value);\n\t}\n};\n\nfunction errorResult(result: Extract<CommandResult, { ok: false }>): McpToolResult {\n\treturn {\n\t\tisError: true,\n\t\tcontent: [{ type: 'text', text: `${result.code}: ${result.message}` }],\n\t\tstructuredContent: {\n\t\t\terror: { code: result.code, message: result.message, command: result.id, ...(result.details ? { details: result.details } : {}) }\n\t\t}\n\t};\n}\n\n/**\n * Exposes a `CommandRegistry` to agents through a `ToolRegistry`:\n *\n * - `list_commands {query?, enabledOnly?}`: ids, labels, params schemas, shortcuts and\n * enablement (with the reason a command is disabled).\n * - `run_command {id, params?}`: runs one command; disabled commands, unknown params and\n * failures come back as `isError` results with a `{code, message}` error.\n * - `run_commands {steps: [{id, params?}], stopOnError?}`: runs steps **in order**, each as\n * its own command (and undo step). It is not atomic: steps that succeeded before a failure\n * stay applied. For all-or-nothing behaviour, register a command that runs the steps\n * inside `HistoryManager.batch` (or mark it `undoable` on a registry with `history`).\n *\n * The id enum in `run_command`'s schema follows the registered commands, so the\n * `ToolRegistry` announces `listChanged` when commands are added or removed.\n */\nexport function createCommandToolProvider<TContext = any>(\n\tregistry: CommandRegistry<TContext>,\n\toptions: CommandToolProviderOptions<TContext> = {}\n): AgentToolProvider {\n\tconst context = (): TContext => {\n\t\tconst c = options.context;\n\t\tif (c === undefined) return registry.context;\n\t\treturn (typeof c === 'function' ? (c as () => TContext)() : c) as TContext;\n\t};\n\tconst visible = () =>\n\t\tregistry.list({ scope: options.scope, context: context() }).filter((e) => !options.exclude?.(e.id));\n\tconst allowed = (id: string) => registry.has(id) && !options.exclude?.(id) && visible().some((e) => e.id === id);\n\n\tasync function runOne(id: string, params: unknown): Promise<CommandResult> {\n\t\tif (!allowed(id)) return { ok: false, id, code: 'unknown_command', message: `Unknown command \"${id}\".` };\n\t\treturn registry.executeAsync(id, params ?? {}, context());\n\t}\n\n\tconst listCommands: AgentTool = {\n\t\tname: 'list_commands',\n\t\ttitle: 'List commands',\n\t\tdescription:\n\t\t\t'Lists the commands you can run with run_command: id, label, group, params (JSON Schema), shortcuts, and whether each is enabled now (with the reason when it is not).',\n\t\tinputSchema: {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tquery: { type: 'string', description: 'Fuzzy filter on label, keywords, group and id.' },\n\t\t\t\tenabledOnly: { type: 'boolean', description: 'Only commands that can run now (default false).' }\n\t\t\t},\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tannotations: { title: 'List commands', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },\n\t\thandler: ({ query = '', enabledOnly = false }) => {\n\t\t\tlet entries = visible();\n\t\t\tif (enabledOnly) entries = entries.filter((e) => e.enabled);\n\t\t\tif (String(query).trim()) entries = rankCommands(String(query), entries, { disabledLast: false }).map((r) => r.entry);\n\t\t\treturn {\n\t\t\t\tcommands: entries.map((e) => ({\n\t\t\t\t\tid: e.id,\n\t\t\t\t\tlabel: e.label,\n\t\t\t\t\t...(e.group ? { group: e.group } : {}),\n\t\t\t\t\t...(e.description ? { description: e.description } : {}),\n\t\t\t\t\t...(e.params ? { params: e.params } : {}),\n\t\t\t\t\t...(e.shortcuts.length ? { shortcuts: e.shortcuts } : {}),\n\t\t\t\t\tenabled: e.enabled,\n\t\t\t\t\t...(e.disabledReason ? { disabledReason: e.disabledReason } : {}),\n\t\t\t\t\treadOnly: e.readOnly\n\t\t\t\t}))\n\t\t\t};\n\t\t}\n\t};\n\n\tconst runCommandTool = (): AgentTool => {\n\t\tconst ids = visible().map((e) => e.id);\n\t\treturn {\n\t\t\tname: 'run_command',\n\t\t\ttitle: 'Run a command',\n\t\t\tdescription:\n\t\t\t\t'Runs one command by id with optional params (see list_commands for each command\\'s params schema). Unknown params are rejected.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: { type: 'string', description: 'Command id from list_commands.', ...(ids.length ? { enum: ids } : {}) },\n\t\t\t\t\tparams: { type: 'object', description: 'Command parameters.' }\n\t\t\t\t},\n\t\t\t\trequired: ['id'],\n\t\t\t\tadditionalProperties: false\n\t\t\t},\n\t\t\tannotations: { title: 'Run a command', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },\n\t\t\thandler: async ({ id, params }) => {\n\t\t\t\tconst result = await runOne(String(id), params);\n\t\t\t\treturn result.ok ? { id: result.id, ok: true, result: toJson(result.result) } : errorResult(result);\n\t\t\t}\n\t\t};\n\t};\n\n\tconst runCommands: AgentTool = {\n\t\tname: 'run_commands',\n\t\ttitle: 'Run several commands',\n\t\tdescription:\n\t\t\t'Runs several commands in order: {steps: [{id, params?}], stopOnError?: true}. Each step is its own command and undo step; the batch is NOT atomic (steps before a failure stay applied). Returns {completed, failed, results: [{id, ok, result | code, message}]}.',\n\t\tinputSchema: {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tsteps: {\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tminItems: 1,\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tid: { type: 'string', description: 'Command id.' },\n\t\t\t\t\t\t\tparams: { type: 'object', description: 'Command parameters.' }\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: ['id'],\n\t\t\t\t\t\tadditionalProperties: false\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tstopOnError: { type: 'boolean', description: 'Stop at the first failing step (default true).' }\n\t\t\t},\n\t\t\trequired: ['steps'],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tannotations: {\n\t\t\ttitle: 'Run several commands',\n\t\t\treadOnlyHint: false,\n\t\t\tdestructiveHint: true,\n\t\t\tidempotentHint: false,\n\t\t\topenWorldHint: false\n\t\t},\n\t\thandler: async ({ steps, stopOnError = true }) => {\n\t\t\tlet completed = 0;\n\t\t\tlet failed = 0;\n\t\t\tconst results: Array<Record<string, unknown>> = [];\n\t\t\tfor (const step of steps as Array<{ id: string; params?: unknown }>) {\n\t\t\t\tconst result = await runOne(step.id, step.params);\n\t\t\t\tif (result.ok) {\n\t\t\t\t\tcompleted++;\n\t\t\t\t\tresults.push({ id: result.id, ok: true, result: toJson(result.result) });\n\t\t\t\t} else {\n\t\t\t\t\tfailed++;\n\t\t\t\t\tresults.push({ id: result.id, ok: false, code: result.code, message: result.message });\n\t\t\t\t\tif (stopOnError) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst summary = { completed, failed, skipped: steps.length - completed - failed, results };\n\t\t\treturn failed > 0\n\t\t\t\t? { isError: true, content: [{ type: 'text', text: JSON.stringify(summary) }], structuredContent: summary }\n\t\t\t\t: summary;\n\t\t}\n\t};\n\n\treturn {\n\t\tid: options.id ?? 'commands',\n\t\tnamespace: options.namespace,\n\t\ttools: () => [listCommands, runCommandTool(), runCommands],\n\t\tsubscribe: (notify) => registry.subscribe(notify)\n\t};\n}\n","import type { CommandSpec } from './registry.js';\n\n/**\n * Animation controller surface used by `createCanvasAnimationCommands`\n * (`createCanvasAnimationController`, `useCanvasAnimation` and `createCanvasAnimation` satisfy it).\n */\nexport interface AnimationCommandTarget {\n\tgetState(): { playing: boolean; recording: boolean; time: number; duration: number; selection: readonly unknown[] };\n\tplay(): void;\n\tpause(): void;\n\ttoggle(): void;\n\tstop(): void;\n\tseek(time: number): void;\n\ttoggleRecording(): void;\n\taddKeyframe(ids?: Iterable<string>, keys?: readonly string[], time?: number): unknown;\n\tdeleteKeyframes(): unknown;\n\tsetEasing(easing: any, refs?: readonly any[]): unknown;\n\tnextKeyframe(): unknown;\n\tpreviousKeyframe(): unknown;\n\tanimateNode(nodeId: string, options: any): unknown;\n\texportCss(nodeId: string, options?: any): { css: string; exact: boolean };\n}\n\nexport interface AnimationCommandOptions {\n\t/** Id prefix (default `canvas.animation.`). */\n\tprefix?: string;\n\tgroup?: string;\n\t/** Scope (default `canvas`). Pass `null` for global. */\n\tscope?: string | null;\n}\n\nconst EASING_DESCRIPTION =\n\t'Easing preset (linear, ease, ease-in, ease-out, ease-in-out, ease-in-back, ease-out-back, spring, hold) or a CSS cubic-bezier(x1, y1, x2, y2).';\n\nconst VALUES = {\n\ttype: 'object',\n\tdescription: 'Property → value, e.g. {\"x\": 200, \"opacity\": 0.5, \"fill\": \"#ff0000\"}. Properties: x, y, width, height, rotation (degrees), scale, opacity (0–1), fill, stroke, strokeWidth, cornerRadius, motionPath (0–1).',\n\tadditionalProperties: { type: ['number', 'string'] }\n} as const;\n\n/**\n * Palette / shortcut / agent commands for canvas animation: play / pause, seek, add keyframe at\n * the playhead, delete keyframes, set easing, record toggle, keyframe navigation, \"animate\n * node from A to B over T\" and CSS export. Edits are undoable when the controller has a history.\n */\nexport function createCanvasAnimationCommands(controller: AnimationCommandTarget, options: AnimationCommandOptions = {}): CommandSpec[] {\n\tconst prefix = options.prefix ?? 'canvas.animation.';\n\tconst group = options.group ?? 'Animation';\n\tconst scope = options.scope === null ? undefined : options.scope ?? 'canvas';\n\tconst base = { group, ...(scope ? { scope } : {}) };\n\tconst hasSelection = () => (controller.getState().selection.length > 0 ? true : 'Select keyframes first.');\n\treturn [\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}togglePlay`,\n\t\t\tlabel: 'Play / Pause Animation',\n\t\t\tkeywords: ['play', 'pause', 'preview', 'timeline'],\n\t\t\tdescription: 'Plays or pauses the canvas animation from the playhead.',\n\t\t\trun: () => {\n\t\t\t\tcontroller.toggle();\n\t\t\t\treturn { playing: controller.getState().playing, time: controller.getState().time };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}play`,\n\t\t\tlabel: 'Play Animation',\n\t\t\tkeywords: ['preview', 'timeline'],\n\t\t\tenabled: () => (controller.getState().playing ? 'Already playing.' : true),\n\t\t\trun: () => controller.play()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}pause`,\n\t\t\tlabel: 'Pause Animation',\n\t\t\tenabled: () => (controller.getState().playing ? true : 'Not playing.'),\n\t\t\trun: () => controller.pause()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}stop`,\n\t\t\tlabel: 'Stop Animation',\n\t\t\tkeywords: ['rewind', 'reset'],\n\t\t\tdescription: 'Stops playback and returns to the start.',\n\t\t\trun: () => controller.stop()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}seek`,\n\t\t\tlabel: 'Go to Time…',\n\t\t\tkeywords: ['playhead', 'scrub', 'time'],\n\t\t\tdescription: 'Moves the playhead.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { time: { type: 'number', minimum: 0, description: 'Time in milliseconds.' } },\n\t\t\t\trequired: ['time']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { time: number }) => {\n\t\t\t\tcontroller.seek(params.time);\n\t\t\t\treturn { time: controller.getState().time };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}addKeyframe`,\n\t\t\tlabel: 'Add Keyframe at Playhead',\n\t\t\tkeywords: ['key', 'animate', 'record'],\n\t\t\tdescription: 'Keys the selected nodes (or `ids`) at the playhead (or `time`): their animated properties, `properties`, or position.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tids: { type: 'array', items: { type: 'string' }, description: 'Node ids (default: selected nodes).' },\n\t\t\t\t\tproperties: { type: 'array', items: { type: 'string' }, description: 'Properties to key (default: animated ones, or x and y).' },\n\t\t\t\t\ttime: { type: 'number', minimum: 0, description: 'Time in ms (default: the playhead).' }\n\t\t\t\t}\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { ids?: string[]; properties?: string[]; time?: number }) =>\n\t\t\t\tcontroller.addKeyframe(params?.ids, params?.properties, params?.time)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}deleteKeyframes`,\n\t\t\tlabel: 'Delete Keyframes',\n\t\t\tkeywords: ['remove', 'clear'],\n\t\t\tenabled: hasSelection,\n\t\t\trun: () => controller.deleteKeyframes()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}setEasing`,\n\t\t\tlabel: 'Set Keyframe Easing…',\n\t\t\tkeywords: ['interpolation', 'ease', 'bezier', 'spring', 'hold', 'curve'],\n\t\t\tdescription: 'Sets the easing of the segments leaving the selected keyframes.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { easing: { type: 'string', description: EASING_DESCRIPTION } },\n\t\t\t\trequired: ['easing']\n\t\t\t},\n\t\t\tenabled: hasSelection,\n\t\t\trun: (_ctx: unknown, params: { easing: string }) => controller.setEasing(params.easing)\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}toggleRecord`,\n\t\t\tlabel: 'Toggle Record Mode',\n\t\t\tkeywords: ['auto key', 'record', 'keyframe'],\n\t\t\tdescription: 'In record mode, changing a property at the playhead keys it.',\n\t\t\trun: () => {\n\t\t\t\tcontroller.toggleRecording();\n\t\t\t\treturn { recording: controller.getState().recording };\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}nextKeyframe`,\n\t\t\tlabel: 'Next Keyframe',\n\t\t\tkeywords: ['jump', 'navigate'],\n\t\t\trun: () => controller.nextKeyframe()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}previousKeyframe`,\n\t\t\tlabel: 'Previous Keyframe',\n\t\t\tkeywords: ['jump', 'navigate'],\n\t\t\trun: () => controller.previousKeyframe()\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}animateNode`,\n\t\t\tlabel: 'Animate Node…',\n\t\t\tkeywords: ['tween', 'transition', 'move', 'fade'],\n\t\t\tdescription: 'Animates a node from `from` (default: its current values) to `to` over `duration` ms, starting at `delay` ms.',\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\tnodeId: { type: 'string', description: 'Node to animate.' },\n\t\t\t\t\tto: VALUES,\n\t\t\t\t\tfrom: VALUES,\n\t\t\t\t\tduration: { type: 'number', exclusiveMinimum: 0, description: 'Duration in ms (default 1000).' },\n\t\t\t\t\tdelay: { type: 'number', minimum: 0, description: 'Start time in ms (default 0).' },\n\t\t\t\t\teasing: { type: 'string', description: EASING_DESCRIPTION }\n\t\t\t\t},\n\t\t\t\trequired: ['nodeId', 'to']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { nodeId: string; to: Record<string, number | string>; from?: Record<string, number | string>; duration?: number; delay?: number; easing?: string }) =>\n\t\t\t\tcontroller.animateNode(params.nodeId, {\n\t\t\t\t\tto: params.to,\n\t\t\t\t\t...(params.from ? { from: params.from } : {}),\n\t\t\t\t\t...(params.duration !== undefined ? { duration: params.duration } : {}),\n\t\t\t\t\t...(params.delay !== undefined ? { delay: params.delay } : {}),\n\t\t\t\t\t...(params.easing !== undefined ? { easing: params.easing } : {})\n\t\t\t\t})\n\t\t},\n\t\t{\n\t\t\t...base,\n\t\t\tid: `${prefix}exportCss`,\n\t\t\tlabel: 'Export Animation as CSS',\n\t\t\tkeywords: ['keyframes', 'css', 'web animations'],\n\t\t\tdescription: 'Returns CSS @keyframes for a node\\'s animation.',\n\t\t\treadOnly: true,\n\t\t\tparams: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { nodeId: { type: 'string' } },\n\t\t\t\trequired: ['nodeId']\n\t\t\t},\n\t\t\trun: (_ctx: unknown, params: { nodeId: string }) => controller.exportCss(params.nodeId)\n\t\t}\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACtC;AAAA,EAET,YAAY,MAAoC,SAAiB;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACb;AACD;AAEA,IAAM,mBAAmB;AAOzB,SAAS,WAAW,QAA6E;AAChG,MAAI,WAAW,UAAa,WAAW,KAAM,QAAO,EAAE,SAAS,KAAK;AACpE,MAAI,WAAW,MAAO,QAAO,EAAE,SAAS,OAAO,QAAQ,2CAA2C;AAClG,SAAO,EAAE,SAAS,OAAO,QAAQ,OAAO,MAAM,EAAE;AACjD;AAGA,SAAS,cAAc,MAAmB,QAAgD;AACzF,QAAM,OAAO,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,MAAM,MAAS;AACtE,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAM,SAAS,KAAK;AACpB,MAAI,UAAU,OAAO,yBAAyB,UAAa,OAAO,yBAAyB,MAAO,QAAO;AACzG,QAAM,WAAW,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC;AACrD,QAAM,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,SAAS,SAAS,CAAC,CAAC;AAClD,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,sBAAsB,GAAG,kBAAkB,KAAK,EAAE,eACxD,SAAS,SAAS,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,IAAI,eAC9D;AACD;AAEA,IAAM,aAAa,CAAC,UACnB,CAAC,CAAC,UAAU,OAAO,UAAU,YAAY,OAAO,UAAU,eAAe,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;AAAA,MACA,KAAK,CAAC,MAAe,WACpB,WAAW,YAAY,OAAO,QAAQ;AAAA,QACrC,IAAI,OAAO;AAAA,QACX,GAAI,OAAO,OAAO,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,QAC3C,GAAI,OAAO,aAAa,SAAY,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;AAAA,QACrE,GAAI,OAAO,UAAU,SAAY,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,QAC5D,GAAI,OAAO,WAAW,SAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,IACA;AAAA,MACC,GAAG;AAAA,MACH,IAAI,GAAG,MAAM;AAAA,MACb,OAAO;AAAA,MACP,UAAU,CAAC,aAAa,OAAO,gBAAgB;AAAA,MAC/C,aAAa;AAAA,MACb,UAAU;AAAA,MACV,QAAQ;AAAA,QACP,MAAM;AAAA,QACN,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,EAAE;AAAA,QACzC,UAAU,CAAC,QAAQ;AAAA,MACpB;AAAA,MACA,KAAK,CAAC,MAAe,WAA+B,WAAW,UAAU,OAAO,MAAM;AAAA,IACvF;AAAA,EACD;AACD;","names":[]}
|
|
@@ -369,6 +369,19 @@ interface SpreadsheetDocument {
|
|
|
369
369
|
createdAt?: number;
|
|
370
370
|
updatedAt?: number;
|
|
371
371
|
table?: SpreadsheetTableSettings;
|
|
372
|
+
/**
|
|
373
|
+
* The defined names formulas on this sheet can use, so a document saved on
|
|
374
|
+
* its own (from `onDocumentChange`) reloads with them: every
|
|
375
|
+
* workbook-scoped name (no `sheetId`) plus this sheet's own sheet-scoped
|
|
376
|
+
* names (`sheetId` set). Written by `SpreadsheetController` on every
|
|
377
|
+
* change; read by `new SpreadsheetController({ document })`,
|
|
378
|
+
* `loadDocument`, `addSheet({ document })` and, for `workbook.sheets`,
|
|
379
|
+
* `loadWorkbook` (where `workbook.names` wins). Any `sheetId` in a
|
|
380
|
+
* document's names means "this sheet", whatever its value. Absent when
|
|
381
|
+
* there are no names. `getWorkbook()` leaves it out of its sheets, because
|
|
382
|
+
* `workbook.names` holds them all.
|
|
383
|
+
*/
|
|
384
|
+
names?: SpreadsheetDefinedName[];
|
|
372
385
|
}
|
|
373
386
|
type SortDirection = 'asc' | 'desc';
|
|
374
387
|
interface SortKey {
|
|
@@ -462,6 +475,11 @@ interface SpreadsheetWorkbook {
|
|
|
462
475
|
sheets: SpreadsheetDocument[];
|
|
463
476
|
/** Id of the sheet shown (default: the first). */
|
|
464
477
|
activeSheetId?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Every defined name. When loading, these win over the same names found in
|
|
480
|
+
* `sheets[*].names`; names found only in a sheet's `names` are added too
|
|
481
|
+
* (first sheet in tab order wins for workbook-scoped duplicates).
|
|
482
|
+
*/
|
|
465
483
|
names?: SpreadsheetDefinedName[];
|
|
466
484
|
}
|
|
467
485
|
/** A sheet tab: what sheet-tab bars render. */
|
|
@@ -1090,6 +1108,23 @@ interface CellPosition {
|
|
|
1090
1108
|
* otherwise it is kept, since it still covers the same rows and columns.
|
|
1091
1109
|
*/
|
|
1092
1110
|
declare function remapFormulaReferences(formula: string, moveCell: (position: CellPosition) => CellPosition | null, options?: FormulaReferenceFilter): string;
|
|
1111
|
+
/**
|
|
1112
|
+
* Transposes a formula that is written relative to `anchor` (a rule formula:
|
|
1113
|
+
* conditional formatting or data validation) for a block transposed in
|
|
1114
|
+
* place around its top-left cell (`block.startRow`, `block.startCol`). The
|
|
1115
|
+
* result is written for the transposed anchor. Relative offsets swap axes
|
|
1116
|
+
* (a reference one column to the right becomes one row below) and `$`
|
|
1117
|
+
* parts inside the block follow the cell they point at, so the `$` flags
|
|
1118
|
+
* swap axes too (`$B2` → `C$2`). References with a `$` part outside the
|
|
1119
|
+
* block (or on another sheet), whole columns and other sheets' absolute
|
|
1120
|
+
* references keep their text.
|
|
1121
|
+
*/
|
|
1122
|
+
declare function transposeFormulaReferences(formula: string, anchor: CellPosition, block: {
|
|
1123
|
+
startRow: number;
|
|
1124
|
+
startCol: number;
|
|
1125
|
+
endRow: number;
|
|
1126
|
+
endCol: number;
|
|
1127
|
+
}): string;
|
|
1093
1128
|
/**
|
|
1094
1129
|
* Whether a sheet name must be quoted in a formula (`'My Sheet'!A1`): names
|
|
1095
1130
|
* with spaces or punctuation, starting with a digit, or that look like a
|
|
@@ -1338,6 +1373,11 @@ interface SpreadsheetControllerOptions {
|
|
|
1338
1373
|
document?: Partial<SpreadsheetDocument>;
|
|
1339
1374
|
dataSources?: SpreadsheetDataSource[];
|
|
1340
1375
|
primaryDataSourceId?: string;
|
|
1376
|
+
/**
|
|
1377
|
+
* Called after any change with the active sheet's document. Its `names`
|
|
1378
|
+
* holds the defined names that sheet uses (workbook names and its own), so
|
|
1379
|
+
* saving this document and passing it back as `document` restores them.
|
|
1380
|
+
*/
|
|
1341
1381
|
onDocumentChange?: (doc: SpreadsheetDocument) => void;
|
|
1342
1382
|
onSelectionChange?: (activeCell: CellCoordinate | null, range: CellRange | null) => void;
|
|
1343
1383
|
onCellCommit?: (rowId: string, colId: string, raw: string, value: any) => void;
|
|
@@ -1453,10 +1493,28 @@ declare class SpreadsheetController {
|
|
|
1453
1493
|
* name, made unique). Clears undo history.
|
|
1454
1494
|
*/
|
|
1455
1495
|
loadDocument(document: SpreadsheetDocument): void;
|
|
1456
|
-
/**
|
|
1496
|
+
/**
|
|
1497
|
+
* Installs the names saved in a document loaded into sheet `sheetId`: they
|
|
1498
|
+
* replace that sheet's own names and, when it is the only sheet, the
|
|
1499
|
+
* workbook names; with other sheets, its workbook names are added (or
|
|
1500
|
+
* replace the same name) and the others are kept.
|
|
1501
|
+
*/
|
|
1502
|
+
private loadDocumentNames;
|
|
1503
|
+
/**
|
|
1504
|
+
* Writes every sheet's current names into its document (`doc.names`), so
|
|
1505
|
+
* documents passed to `onDocumentChange` or read from `document` carry them.
|
|
1506
|
+
*/
|
|
1507
|
+
private syncDocumentNames;
|
|
1508
|
+
/**
|
|
1509
|
+
* A deep copy of the workbook: every sheet, the active sheet and the
|
|
1510
|
+
* defined names. The names are in `names` only (not repeated in each
|
|
1511
|
+
* sheet's `names`).
|
|
1512
|
+
*/
|
|
1457
1513
|
getWorkbook(): SpreadsheetWorkbook;
|
|
1458
1514
|
/** Replaces the whole workbook (sheets, names, active sheet). Clears undo history. */
|
|
1459
1515
|
loadWorkbook(workbook: SpreadsheetWorkbook): void;
|
|
1516
|
+
/** The workbook as undo data; sheets leave out their copies of the names. */
|
|
1517
|
+
private serializeWorkbookSnapshot;
|
|
1460
1518
|
private workbookSnapshot;
|
|
1461
1519
|
/**
|
|
1462
1520
|
* Installs a workbook's sheets and names (taking ownership of the objects).
|
|
@@ -1965,6 +2023,13 @@ declare class SpreadsheetController {
|
|
|
1965
2023
|
private generateRuleId;
|
|
1966
2024
|
/** Moves rule ranges and rule formulas with inserted / deleted rows and columns. */
|
|
1967
2025
|
private adjustRulesForStructuralChange;
|
|
2026
|
+
/**
|
|
2027
|
+
* Moves conditional formats and validations with sorted rows: per-row
|
|
2028
|
+
* parts follow their rows, parts spanning every sorted row stay (Excel).
|
|
2029
|
+
*/
|
|
2030
|
+
private moveRulesForSort;
|
|
2031
|
+
/** Moves conditional formats and validations of a transposed block with its cells. */
|
|
2032
|
+
private moveRulesForTranspose;
|
|
1968
2033
|
/** Conditional formats of the sheet, highest priority first. */
|
|
1969
2034
|
getConditionalFormats(): ConditionalFormatRule[];
|
|
1970
2035
|
/**
|
|
@@ -2035,4 +2100,4 @@ declare class SpreadsheetController {
|
|
|
2035
2100
|
isInvalidDataCircled(row: number, col: number): boolean;
|
|
2036
2101
|
}
|
|
2037
2102
|
|
|
2038
|
-
export { type GroupAggregate as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type DataValidationResult as E, type DataValidationRule as F, type DataValidationSheet as G, type DataValidationType as H, DependencyGraph as I, type DependencyIndexStats as J, type EvaluationContext as K, FORMULA_ERRORS as L, type FilterOperator as M, type FilterRule as N, type FormulaDiagnostic as O, type FormulaErrorCode as P, type FormulaEvaluationResult as Q, FormulaEvaluator as R, SpreadsheetController as S, type FormulaNameDefinition as T, FormulaParser as U, type FormulaRange as V, type FormulaReferenceFilter as W, type FormulaReferenceInfo as X, type FormulaToken as Y, type FormulaTokenType as Z, type FunctionCallNode as _, type CellData as a, extractCellDependencies as a$, type GroupSummary as a0, IntervalIndex as a1, type InvokeNode as a2, type LiteralNode as a3, MAX_FORMULA_ARRAY_SIZE as a4, type MissingNode as a5, type NameDep as a6, type NameNode as a7, type NewConditionalFormatRule as a8, type NewDataValidationRule as a9, type SpreadsheetNameInfo as aA, type SpreadsheetNameScope as aB, type SpreadsheetRecalculationStats as aC, type SpreadsheetRow as aD, type SpreadsheetRowGroup as aE, type SpreadsheetRowSection as aF, type SpreadsheetSheetInfo as aG, type SpreadsheetSpill as aH, type SpreadsheetTableSettings as aI, type SpreadsheetValidationAction as aJ, type SpreadsheetValidationPrompt as aK, type SpreadsheetViewColumn as aL, type SpreadsheetViewModel as aM, type SpreadsheetViewRow as aN, type SpreadsheetWorkbook as aO, type StructuralChange as aP, type UnaryOpNode as aQ, WHOLE_COLUMN_END_ROW as aR, buildSpreadsheetView as aS, colNameToIndex as aT, columnDependencyKey as aU, compareNumbers as aV, compareValues as aW, computeRowGroups as aX, createSpreadsheetClipboardData as aY, deleteSheetInFormula as aZ, describeFormulaError as a_, type NewFilterRule as aa, type ParsedSpreadsheetClipboard as ab, type PropertyRefNode as ac, type RangeNode as ad, type RangeResolveOptions as ae, type ReferenceDep as af, type RowType as ag, SPREADSHEET_CLIPBOARD_MIME as ah, type SheetQualifier as ai, type SortDirection as aj, type SortKey as ak, type SpillRefNode as al, type SpreadsheetCellSpan as am, type SpreadsheetClipboardCell as an, type SpreadsheetClipboardData as ao, type SpreadsheetClipboardPayload as ap, type SpreadsheetClipboardSource as aq, type SpreadsheetColumn as ar, type SpreadsheetCommitResult as as, type SpreadsheetControllerOptions as at, type SpreadsheetDataSource as au, type SpreadsheetDataSourceField as av, type SpreadsheetDefinedName as aw, type SpreadsheetDocument as ax, type SpreadsheetFilterState as ay, type SpreadsheetGrouping as az, type CellDep as b, extractNameDependencies as b0, extractReferenceDependencies as b1, formatSheetPrefix as b2, formulaIdentifiers as b3, getRowSection as b4, getTableSections as b5, indexToColName as b6, isFormulaError as b7, mapFormulaReferences as b8, numberToText as b9, offsetFormulaReferences as ba, parseCellReference as bb, parseFormula as bc, parseHtmlTable as bd, parseRange as be, quoteSheetName as bf, rangeDependencyKey as bg, readSpreadsheetClipboard as bh, rebaseClipboardRows as bi, remapFormulaReferences as bj, renameNameInFormula as bk, renameSheetInFormula as bl, rowPassesFilters as bm, serializeHtmlTable as bn, sheetNameNeedsQuotes as bo, shiftFormulaReferences as bp, sortCompareValues as bq, tokenizeFormula as br, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type ConditionalCellFormat as j, type ConditionalFormatCondition as k, type ConditionalFormatIconSet as l, type ConditionalFormatOperator as m, type ConditionalFormatOverlay as n, type ConditionalFormatRule as o, type ConditionalFormatSheet as p, type ConditionalFormatStyle as q, type ConditionalFormatTimePeriod as r, type ConditionalFormatType as s, type ConditionalFormatValue as t, type CsvExportOptions as u, type CsvImportOptions as v, DEFAULT_ROW_HEIGHT as w, DataSourceBinder as x, type DataValidationErrorStyle as y, type DataValidationOperator as z };
|
|
2103
|
+
export { type GroupAggregate as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type DataValidationResult as E, type DataValidationRule as F, type DataValidationSheet as G, type DataValidationType as H, DependencyGraph as I, type DependencyIndexStats as J, type EvaluationContext as K, FORMULA_ERRORS as L, type FilterOperator as M, type FilterRule as N, type FormulaDiagnostic as O, type FormulaErrorCode as P, type FormulaEvaluationResult as Q, FormulaEvaluator as R, SpreadsheetController as S, type FormulaNameDefinition as T, FormulaParser as U, type FormulaRange as V, type FormulaReferenceFilter as W, type FormulaReferenceInfo as X, type FormulaToken as Y, type FormulaTokenType as Z, type FunctionCallNode as _, type CellData as a, extractCellDependencies as a$, type GroupSummary as a0, IntervalIndex as a1, type InvokeNode as a2, type LiteralNode as a3, MAX_FORMULA_ARRAY_SIZE as a4, type MissingNode as a5, type NameDep as a6, type NameNode as a7, type NewConditionalFormatRule as a8, type NewDataValidationRule as a9, type SpreadsheetNameInfo as aA, type SpreadsheetNameScope as aB, type SpreadsheetRecalculationStats as aC, type SpreadsheetRow as aD, type SpreadsheetRowGroup as aE, type SpreadsheetRowSection as aF, type SpreadsheetSheetInfo as aG, type SpreadsheetSpill as aH, type SpreadsheetTableSettings as aI, type SpreadsheetValidationAction as aJ, type SpreadsheetValidationPrompt as aK, type SpreadsheetViewColumn as aL, type SpreadsheetViewModel as aM, type SpreadsheetViewRow as aN, type SpreadsheetWorkbook as aO, type StructuralChange as aP, type UnaryOpNode as aQ, WHOLE_COLUMN_END_ROW as aR, buildSpreadsheetView as aS, colNameToIndex as aT, columnDependencyKey as aU, compareNumbers as aV, compareValues as aW, computeRowGroups as aX, createSpreadsheetClipboardData as aY, deleteSheetInFormula as aZ, describeFormulaError as a_, type NewFilterRule as aa, type ParsedSpreadsheetClipboard as ab, type PropertyRefNode as ac, type RangeNode as ad, type RangeResolveOptions as ae, type ReferenceDep as af, type RowType as ag, SPREADSHEET_CLIPBOARD_MIME as ah, type SheetQualifier as ai, type SortDirection as aj, type SortKey as ak, type SpillRefNode as al, type SpreadsheetCellSpan as am, type SpreadsheetClipboardCell as an, type SpreadsheetClipboardData as ao, type SpreadsheetClipboardPayload as ap, type SpreadsheetClipboardSource as aq, type SpreadsheetColumn as ar, type SpreadsheetCommitResult as as, type SpreadsheetControllerOptions as at, type SpreadsheetDataSource as au, type SpreadsheetDataSourceField as av, type SpreadsheetDefinedName as aw, type SpreadsheetDocument as ax, type SpreadsheetFilterState as ay, type SpreadsheetGrouping as az, type CellDep as b, extractNameDependencies as b0, extractReferenceDependencies as b1, formatSheetPrefix as b2, formulaIdentifiers as b3, getRowSection as b4, getTableSections as b5, indexToColName as b6, isFormulaError as b7, mapFormulaReferences as b8, numberToText as b9, offsetFormulaReferences as ba, parseCellReference as bb, parseFormula as bc, parseHtmlTable as bd, parseRange as be, quoteSheetName as bf, rangeDependencyKey as bg, readSpreadsheetClipboard as bh, rebaseClipboardRows as bi, remapFormulaReferences as bj, renameNameInFormula as bk, renameSheetInFormula as bl, rowPassesFilters as bm, serializeHtmlTable as bn, sheetNameNeedsQuotes as bo, shiftFormulaReferences as bp, sortCompareValues as bq, tokenizeFormula as br, transposeFormulaReferences as bs, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type ConditionalCellFormat as j, type ConditionalFormatCondition as k, type ConditionalFormatIconSet as l, type ConditionalFormatOperator as m, type ConditionalFormatOverlay as n, type ConditionalFormatRule as o, type ConditionalFormatSheet as p, type ConditionalFormatStyle as q, type ConditionalFormatTimePeriod as r, type ConditionalFormatType as s, type ConditionalFormatValue as t, type CsvExportOptions as u, type CsvImportOptions as v, DEFAULT_ROW_HEIGHT as w, DataSourceBinder as x, type DataValidationErrorStyle as y, type DataValidationOperator as z };
|