import { ZodObject, ZodSchema, ZodTuple } from 'zod';
import { ReactNode, ComponentType } from 'react';
import { F as FieldConfigItem } from './stack.fdi94T4S.js';

type PropValue = ReactNode | VariableReference | Record<string, any> | any[] | string | number | boolean | null | undefined;
type ComponentProps<TProps extends Record<string, PropValue> = Record<string, PropValue>> = TProps;
interface ComponentLayer<TProps extends Record<string, PropValue> = Record<string, PropValue>> {
    id: string;
    name?: string;
    type: string;
    props: ComponentProps<TProps>;
    children: ComponentLayer[] | string | VariableReference;
}
type VariableValueType = 'string' | 'number' | 'boolean' | 'function';
type VariableValue<T extends VariableValueType> = T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'function' ? string : never;
interface Variable<T extends VariableValueType = VariableValueType> {
    id: string;
    name: string;
    type: T;
    defaultValue: VariableValue<T>;
}
interface VariableReference {
    __variableRef: string;
}
interface DefaultVariableBinding {
    propName: string;
    variableId: string;
    immutable?: boolean;
}
interface RegistryEntry<T extends ComponentType<any>> {
    component?: T;
    schema: ZodObject<any> | ZodSchema<any>;
    from?: string;
    isFromDefaultExport?: boolean;
    defaultChildren?: ComponentLayer[] | string | VariableReference;
    defaultVariableBindings?: DefaultVariableBinding[];
    fieldOverrides?: Record<string, FieldConfigFunction>;
    /**
     * If defined, this component can only be added as a child of the specified parent types.
     * Used to filter component options in the add popover and validate drag-and-drop.
     * Example: TabsTrigger has childOf: ["TabsList"]
     */
    childOf?: string[];
}
type FieldConfigFunction = (layer: ComponentLayer, allowVariableBinding?: boolean) => FieldConfigItem;
type ComponentRegistry = Record<string, RegistryEntry<ComponentType<any>>>;
/**
 * Function definition for the function registry.
 * Describes a function that can be bound to component event handlers.
 */
interface FunctionDefinition {
    /** Human-readable name for the function */
    name: string;
    /** Zod schema describing the function parameters (use z.tuple for ordered args, z.object for named params) */
    schema: ZodTuple<any, any> | ZodObject<any> | ZodSchema<any>;
    /** The actual function to call at runtime */
    fn: (...args: any[]) => any;
    /** Optional description shown in the UI */
    description?: string;
    /**
     * Optional TypeScript type signature for code generation.
     * Use this when the Zod schema uses z.custom<T>() or other types
     * that can't be automatically inferred at runtime.
     * @example "(e: React.FormEvent<HTMLFormElement>) => void"
     * @example "(data: { name: string; email: string }) => Promise<void>"
     */
    typeSignature?: string;
}
/**
 * Function registry type - a record of function ID to function definition.
 * Used to provide callable functions that can be bound to component event handlers.
 */
type FunctionRegistry = Record<string, FunctionDefinition>;

export type { ComponentLayer as C, FunctionRegistry as F, PropValue as P, RegistryEntry as R, Variable as V, ComponentRegistry as a, FieldConfigFunction as b };
