import { DerivedFieldState, FormDefinition, Registry, ScriptContext, ScriptEvent, ScriptEventDetail, ScriptMessage } from '../types.js'; /** Script-set per-field overrides (only the keys a script touched). */ export type ScriptFieldState = Partial>; /** Where a ScriptContext writes. Each method is called synchronously from a script. */ export interface ScriptSink { getData(): Record; setValue(key: string, value: unknown): void; setState(key: string, patch: ScriptFieldState): void; resetState(key?: string): void; setFieldMessage(key: string, message: ScriptMessage | null): void; addFormMessage(message: ScriptMessage): void; clearFormMessages(): void; } /** Bounds a setValue ping-pong between change scripts (like the engine's MAX_PASSES). */ export declare const MAX_SCRIPT_DEPTH = 20; export declare function createScriptContext(form: FormDefinition, sink: ScriptSink): ScriptContext; export interface RunScriptsOptions { form: FormDefinition; registry: Registry; g: ScriptContext; on: ScriptEvent; /** `change` only: which field's scripts run. */ key?: string; detail: Omit; } /** * Run every `scripts[]` entry matching `on` (and `key` for change) in array * order. Unknown handler names warn once and are skipped; a throwing handler * is logged and the rest still run. Returns false when a `submit` handler * returned `false` (block), else true. */ export declare function runScripts(opts: RunScriptsOptions): boolean; /** True when the form declares at least one script of this kind (cheap pre-check). */ export declare function hasScripts(form: FormDefinition | undefined, on: ScriptEvent, key?: string): boolean;