import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
import * as _btst_yar from '@btst/yar';
import React__default, { ComponentType } from 'react';
import { QueryClient } from '@tanstack/react-query';
import { c as UIBuilderClientHooks } from '../../../shared/stack.ASwEoINr.js';
import { a as ComponentRegistry, b as FieldConfigFunction, C as ComponentLayer, F as FunctionRegistry } from '../../../shared/stack.BK9Z2dcL.js';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { A as AutoFormInputComponentProps, F as FieldConfigItem } from '../../../shared/stack.fdi94T4S.js';
export { PageBuilderPage, PageListPage, PageRenderer, PageRendererProps, SuspensePageRenderer } from './components/index.js';
export { CreateUIBuilderPageInput, UpdateUIBuilderPageInput, UseUIBuilderPagesOptions, UseUIBuilderPagesResult, useCreateUIBuilderPage, useDeleteUIBuilderPage, useSuspenseUIBuilderPage, useSuspenseUIBuilderPageBySlug, useSuspenseUIBuilderPages, useUIBuilderPage, useUIBuilderPageBySlug, useUIBuilderPages, useUpdateUIBuilderPage } from './hooks/index.js';
import 'zod';
import 'react-hook-form';

/**
 * Configuration for UI Builder client plugin
 */
interface UIBuilderClientConfig {
    /** Base URL for API calls (e.g., "http://localhost:3000") */
    apiBaseURL: string;
    /** Path where the API is mounted (e.g., "/api/data") */
    apiBasePath: string;
    /** Base URL of your site */
    siteBaseURL: string;
    /** Path where pages are mounted (e.g., "/pages") */
    siteBasePath: string;
    /** React Query client instance for caching */
    queryClient: QueryClient;
    /** Optional headers for SSR (e.g., forwarding cookies) */
    headers?: Headers;
    /** Optional hooks for customizing behavior (authorization, redirects, etc.) */
    hooks?: UIBuilderClientHooks;
    /** Component registry to use for the UI Builder */
    componentRegistry?: ComponentRegistry;
    /**
     * Optional page component overrides.
     * Replace any plugin page with a custom React component.
     * The built-in component is used as the fallback when not provided.
     */
    pageComponents?: {
        /** Replaces the page list page */
        pageList?: ComponentType;
        /** Replaces the new page builder page */
        newPage?: ComponentType;
        /** Replaces the edit page builder page */
        editPage?: ComponentType<{
            id: string;
        }>;
    };
}
/**
 * UI Builder client plugin
 * Provides routes and components for the UI Builder admin interface
 *
 * @example
 * ```typescript
 * import { uiBuilderClientPlugin } from "@btst/stack/plugins/ui-builder/client"
 *
 * "ui-builder": uiBuilderClientPlugin({
 *   apiBaseURL: baseURL,
 *   apiBasePath: "/api/data",
 *   siteBaseURL: baseURL,
 *   siteBasePath: "/pages",
 *   queryClient,
 *   hooks: {
 *     beforeLoadPageList: async (ctx) => {
 *       const session = await getSession(ctx.headers)
 *       if (!session?.user?.isAdmin) throw new Error("Admin access required")
 *     },
 *     beforeLoadPageBuilder: async (pageId, ctx) => {
 *       const session = await getSession(ctx.headers)
 *       if (!session?.user?.isAdmin) throw new Error("Admin access required")
 *     },
 *     onLoadError: () => redirect("/auth/sign-in"),
 *   },
 * })
 * ```
 */
declare const uiBuilderClientPlugin: (config: UIBuilderClientConfig) => _btst_stack_plugins_client.ClientPlugin<Record<string, never>, {
    pageList: {
        (inputCtx_0?: _btst_yar.InputContext<"/ui-builder", _btst_yar.RouteOptions> | undefined): {
            PageComponent?: ComponentType<{}> | undefined;
            LoadingComponent?: ComponentType<{}> | undefined;
            ErrorComponent?: ComponentType<{}> | undefined;
            loader?: (() => Promise<void>) | undefined;
            meta?: (() => ({
                title: string;
                name?: undefined;
                content?: undefined;
            } | {
                name: string;
                content: string;
                title?: undefined;
            })[]) | undefined;
            extra?: (() => any) | undefined;
        };
        options: _btst_yar.RouteOptions | undefined;
        path: "/ui-builder";
        meta: _btst_yar.RouteMeta | undefined;
    };
    newPage: {
        (inputCtx_0?: _btst_yar.InputContext<"/ui-builder/new", _btst_yar.RouteOptions> | undefined): {
            PageComponent?: ComponentType<{}> | undefined;
            LoadingComponent?: ComponentType<{}> | undefined;
            ErrorComponent?: ComponentType<{}> | undefined;
            loader?: (() => Promise<void>) | undefined;
            meta?: (() => ({
                title: string;
                name?: undefined;
                content?: undefined;
            } | {
                name: string;
                content: string;
                title?: undefined;
            })[]) | undefined;
            extra?: (() => any) | undefined;
        };
        options: _btst_yar.RouteOptions | undefined;
        path: "/ui-builder/new";
        meta: _btst_yar.RouteMeta | undefined;
    };
    editPage: {
        (inputCtx_0: _btst_yar.InputContext<"/ui-builder/:id/edit", _btst_yar.RouteOptions>): {
            PageComponent?: ComponentType<unknown> | undefined;
            LoadingComponent?: ComponentType<unknown> | undefined;
            ErrorComponent?: ComponentType<unknown> | undefined;
            loader?: (() => Promise<void>) | undefined;
            meta?: (() => ({
                title: string;
                name?: undefined;
                content?: undefined;
            } | {
                name: string;
                content: string;
                title?: undefined;
            })[]) | undefined;
            extra?: (() => any) | undefined;
        };
        options: _btst_yar.RouteOptions | undefined;
        path: "/ui-builder/:id/edit";
        meta: _btst_yar.RouteMeta | undefined;
    };
}>;

/**
 * Primitive HTML component definitions
 * These are simple HTML elements that can be used in the UI builder
 */
declare const primitiveComponentDefinitions: ComponentRegistry;
/**
 * Complex component definitions (shadcn/ui and custom components)
 * These components have React implementations and more complex schemas
 */
declare const complexComponentDefinitions: ComponentRegistry;
/**
 * Default component registry for the UI Builder
 *
 * Includes:
 * - Primitive HTML elements (div, span, h1-h6, p, a, img, iframe)
 * - Layout components (Flexbox, Grid)
 * - Content components (Markdown, Icon, CodePanel)
 * - shadcn/ui components (Button, Badge, Card, Accordion, Separator)
 *
 * @example
 * ```typescript
 * import { defaultComponentRegistry } from "@btst/stack/plugins/ui-builder/client"
 *
 * // Use as-is
 * uiBuilderClientPlugin({
 *   componentRegistry: defaultComponentRegistry,
 *   // ...
 * })
 *
 * // Or extend with custom components
 * import { createComponentRegistry } from "@btst/stack/plugins/ui-builder/client"
 *
 * const customRegistry = createComponentRegistry({
 *   ...defaultComponentRegistry,
 *   MyComponent: {
 *     component: MyComponent,
 *     schema: myComponentSchema,
 *   },
 * })
 * ```
 */
declare const defaultComponentRegistry: ComponentRegistry;
/**
 * Helper to create a custom component registry
 *
 * This is a simple passthrough function that provides type safety
 * when creating or extending component registries.
 *
 * @example
 * ```typescript
 * // Extend the default registry
 * const customRegistry = createComponentRegistry({
 *   ...defaultComponentRegistry,
 *   CustomButton: {
 *     component: CustomButton,
 *     schema: z.object({
 *       label: z.string(),
 *       variant: z.enum(['primary', 'secondary']),
 *     }),
 *   },
 * })
 *
 * // Create a minimal registry
 * const minimalRegistry = createComponentRegistry({
 *   div: primitiveComponentDefinitions.div,
 *   span: primitiveComponentDefinitions.span,
 *   Button: complexComponentDefinitions.Button,
 * })
 * ```
 */
declare function createComponentRegistry(components: ComponentRegistry): ComponentRegistry;

declare const classNameFieldOverrides: FieldConfigFunction;
declare const childrenFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
    renderParent: (({ children }: {
        children: React__default.ReactNode;
    }) => react_jsx_runtime.JSX.Element) | undefined;
    fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
};
declare const iconNameFieldOverrides: FieldConfigFunction;
declare const childrenAsTextareaFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
    renderParent: (({ children }: {
        children: React__default.ReactNode;
    }) => react_jsx_runtime.JSX.Element) | undefined;
    fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
};
declare const childrenAsTipTapFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
    renderParent: (({ children }: {
        children: React__default.ReactNode;
    }) => react_jsx_runtime.JSX.Element) | undefined;
    fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
};
declare const commonFieldOverrides: (allowBinding?: boolean) => Record<string, (layer: ComponentLayer) => ReturnType<FieldConfigFunction>> | {
    className: (layer: ComponentLayer) => FieldConfigItem;
    children: (layer: ComponentLayer) => {
        renderParent: (({ children }: {
            children: React__default.ReactNode;
        }) => react_jsx_runtime.JSX.Element) | undefined;
        fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
    };
};

/**
 * UI Builder plugin localization strings
 */
declare const uiBuilderLocalization: {
    readonly pageList: {
        readonly title: "UI Builder Pages";
        readonly description: "Create and manage visual pages with the drag-and-drop builder";
        readonly createButton: "Create Page";
        readonly emptyState: {
            readonly title: "No pages yet";
            readonly description: "Create your first page with the visual builder";
        };
        readonly columns: {
            readonly name: "Name";
            readonly slug: "Slug";
            readonly status: "Status";
            readonly updatedAt: "Updated";
            readonly actions: "Actions";
        };
        readonly actions: {
            readonly edit: "Edit";
            readonly delete: "Delete";
        };
        readonly deleteDialog: {
            readonly title: "Delete Page";
            readonly description: "Are you sure you want to delete this page? This action cannot be undone.";
            readonly cancel: "Cancel";
            readonly confirm: "Delete";
        };
    };
    readonly pageBuilder: {
        readonly newPage: "New Page";
        readonly editPage: "Edit Page";
        readonly backToList: "Back to Pages";
        readonly save: "Save";
        readonly saving: "Saving...";
        readonly saved: "Saved";
        readonly saveError: "Failed to save";
        readonly slugLabel: "Page Slug";
        readonly slugPlaceholder: "my-page-slug";
        readonly slugDescription: "URL-friendly identifier for this page";
        readonly statusLabel: "Status";
        readonly statusOptions: {
            readonly draft: "Draft";
            readonly published: "Published";
            readonly archived: "Archived";
        };
        readonly validation: {
            readonly slugRequired: "Slug is required";
            readonly slugFormat: "Slug must contain only lowercase letters, numbers, and hyphens";
            readonly layersRequired: "Page must have at least one component";
        };
    };
    readonly pageRenderer: {
        readonly loading: "Loading page...";
        readonly notFound: "Page not found";
        readonly error: "Failed to load page";
    };
};
type UIBuilderLocalization = typeof uiBuilderLocalization;

/**
 * Context passed to lifecycle hooks
 */
interface RouteContext {
    /** Current route path */
    path: string;
    /** Route parameters (e.g., { id: "123" }) */
    params?: Record<string, string>;
    /** Whether rendering on server (true) or client (false) */
    isSSR: boolean;
    /** Additional context properties */
    [key: string]: unknown;
}
/**
 * Plugin overrides interface for UI Builder
 *
 * External consumers can provide their own implementations of these
 * to customize the behavior for their framework (Next.js, React Router, etc.)
 */
interface UIBuilderPluginOverrides {
    /**
     * Link component for navigation
     */
    Link?: ComponentType<React.ComponentProps<"a"> & Record<string, unknown>>;
    /**
     * Navigation function for programmatic navigation
     */
    navigate?: (path: string) => void | Promise<void>;
    /**
     * Refresh function to invalidate server-side cache (e.g., Next.js router.refresh())
     */
    refresh?: () => void | Promise<void>;
    /**
     * API base URL
     */
    apiBaseURL: string;
    /**
     * API base path
     */
    apiBasePath: string;
    /**
     * Optional headers to pass with API requests (e.g., for SSR auth)
     */
    headers?: HeadersInit;
    /**
     * Whether to show the attribution
     */
    showAttribution?: boolean;
    /**
     * Component registry for the UI Builder
     */
    componentRegistry?: ComponentRegistry;
    /**
     * Function registry for resolving bindable event handlers (onClick, onSubmit, etc.)
     * in the preview modal and layer renderer.
     */
    functionRegistry?: FunctionRegistry;
    /**
     * Base path for UI Builder admin pages (default: /pages/ui-builder)
     */
    siteBasePath?: string;
    /**
     * SSR authorization hooks
     */
    hooks?: UIBuilderClientHooks;
    /**
     * Called when a route is rendered
     * @param routeName - Name of the route (e.g., 'pageList', 'pageBuilder')
     * @param context - Route context with path, params, etc.
     */
    onRouteRender?: (routeName: string, context: RouteContext) => void | Promise<void>;
    /**
     * Called when a route encounters an error
     * @param routeName - Name of the route
     * @param error - The error that occurred
     * @param context - Route context
     */
    onRouteError?: (routeName: string, error: Error, context: RouteContext) => void | Promise<void>;
}

export { childrenAsTextareaFieldOverrides, childrenAsTipTapFieldOverrides, childrenFieldOverrides, classNameFieldOverrides, commonFieldOverrides, complexComponentDefinitions, createComponentRegistry, defaultComponentRegistry, iconNameFieldOverrides, primitiveComponentDefinitions, uiBuilderClientPlugin, uiBuilderLocalization };
export type { UIBuilderClientConfig, UIBuilderLocalization, UIBuilderPluginOverrides };
