/**
 * Reactive form state for controlling when field errors appear and focusing invalid fields.
 *
 * Tracks per-field `touched` state (set on blur via delegated `focusout`) and form-level
 * `attempted` state (set on submit attempt). Errors show after a field is blurred or
 * after a submit attempt, avoiding premature validation while the user is still typing.
 *
 * The `FormState.form` attachment also handles Enter key advancing
 * between focusable elements.
 *
 * All trackable inputs must have a `name` attribute — an error is thrown in dev
 * if an input without `name` loses focus.
 *
 * @example
 * ```svelte
 * <script>
 *   const form_state = new FormState();
 *   let username = $state.raw('');
 *   const username_valid = $derived(Username.safeParse(username).success);
 *   const can_submit = $derived(username.trim() && username_valid);
 *
 *   const handle_submit = async () => {
 *     form_state.attempt();
 *     if (!can_submit) {
 *       if (!username.trim() || !username_valid) form_state.focus('username');
 *       return;
 *     }
 *     // submit...
 *   };
 * </script>
 *
 * <form {@attach form_state.form()} onsubmit={(e) => { e.preventDefault(); void handle_submit(); }}>
 *   <input name="username" bind:value={username} />
 *   {#if form_state.show('username') && username && !username_valid}
 *     <p>error message</p>
 *   {/if}
 *   <PendingButton onclick={handle_submit}>submit</PendingButton>
 * </form>
 * ```
 *
 * @module
 */
import type { Attachment } from 'svelte/attachments';
export declare class FormState {
    #private;
    /**
     * Whether a submit attempt has been made.
     */
    get attempted(): boolean;
    /**
     * Creates a form attachment that handles Enter key advancing between
     * focusable elements and tracks field touched state via delegated `focusout`.
     *
     * Fields are identified by their `name` attribute.
     *
     * @throws Error in DEV when called while already attached, or when an
     *   input loses focus without a `name` attribute
     */
    form(): Attachment<HTMLFormElement>;
    /**
     * Whether a field has been blurred at least once.
     */
    is_touched(field: string): boolean;
    /**
     * Whether to show validation errors for a field.
     * Returns `true` if the field has been blurred or a submit attempt was made.
     */
    show(field: string): boolean;
    /**
     * Programmatically marks a field as touched without requiring a blur event.
     *
     * @mutates `this`
     */
    touch(field: string): void;
    /**
     * Focuses the named input within the form.
     */
    focus(field: string): void;
    /**
     * Marks the form as having been submitted, causing all field errors to show.
     *
     * @mutates `this`
     */
    attempt(): void;
    /**
     * Resets all touched and attempted state.
     *
     * @mutates `this`
     */
    reset(): void;
}
//# sourceMappingURL=form_state.svelte.d.ts.map