import * as react_jsx_runtime from 'react/jsx-runtime';
import * as React from 'react';
import { Q as ListerSearchPayload, U as ListerId, W as ListerDefinition, X as ListerOption, Y as PresetMap, Z as ListerApi, _ as ListerStoreState, $ as ListerSessionId, a0 as ListerSearchTarget, a1 as ListerSearchMode, a2 as ListerFilterCtx, a3 as ListerDetails, a4 as ListerProviderHost, a5 as ListerRuntimeState, a6 as ShadcnJsonEditorProps, a7 as JsonEditorIndexHandle } from './core-Cg8uXa6v.js';
export { ad as ListerChangeEvent, am as ListerFilterApply, al as ListerFilterApplyMode, an as ListerFilterBindKey, ap as ListerFilterGroupOption, ao as ListerFilterInput, ar as ListerFilterInputOption, as as ListerFilterOption, at as ListerFilterSpec, aq as ListerFilterValueOption, af as ListerLogCode, ag as ListerLogEntry, ae as ListerLogLevel, ai as ListerMapping, a8 as ListerMode, ax as ListerOpenOptions, a9 as ListerOpenReason, ay as ListerOpenResult, aw as ListerOptionsForMode, ah as ListerPermissionCtx, av as ListerRawForMode, ak as ListerSearchSpec, aD as ListerSessionState, aj as ListerSource, au as ListerValueForMode, ac as OpenAnchor, aB as PresetFilters, aC as PresetMeta, az as PresetRaw, aA as PresetValue, ab as Resolver, aa as Selector } from './core-Cg8uXa6v.js';
import 'zod';
import './adapter-CvjXO9Gi.js';
import '@inertiajs/core';
import 'axios';
import 'react-day-picker';
import 'class-variance-authority/types';
import 'class-variance-authority';
import '@radix-ui/react-switch';

type HttpMethod = "GET" | "POST";
type HttpReq = {
    endpoint: string;
    method?: HttpMethod;
    params?: any;
    body?: any;
    headers?: Record<string, string>;
    signal?: AbortSignal;
    requestId?: string;
};
type ListerHttpClient = (req: HttpReq) => Promise<any>;

type ListerFetchOpts<TCtx = any> = {
    query?: string;
    search?: ListerSearchPayload;
    cursor?: string | null;
    /** request control */
    signal?: AbortSignal;
    requestId?: string;
    /** mapping context override */
    ctx?: TCtx;
};
declare function fetchListerList<TRaw, TValue extends ListerId, TFilters, TMeta, TCtx>(args: {
    def: ListerDefinition<TRaw, TValue, TFilters, TMeta, TCtx>;
    http: ListerHttpClient;
    filters?: TFilters;
    opts?: ListerFetchOpts<TCtx>;
}): Promise<{
    rawList: TRaw[];
    optionsList: Array<ListerOption<TRaw, TValue, TMeta>>;
    responseBody: any;
    requestId?: string;
}>;

type ListerEngine = {
    http: ListerHttpClient;
    fetch: <TRaw, TValue extends ListerId, TFilters, TMeta, TCtx>(args: {
        def: ListerDefinition<TRaw, TValue, TFilters, TMeta, TCtx>;
        filters?: TFilters;
        opts?: ListerFetchOpts<TCtx> & {
            search?: ListerSearchPayload;
        };
    }) => ReturnType<typeof fetchListerList<TRaw, TValue, TFilters, TMeta, TCtx>>;
};

type CreateListerRuntimeOptions<P extends PresetMap> = {
    host: ListerProviderHost;
    /** Provide your own engine (for tests / custom http). */
    engine?: ListerEngine;
    /** Initial preset map (kind => definition). */
    presets?: P;
    /** Debounce used when searchMode is remote/hybrid and query changes. */
    remoteDebounceMs?: number;
    now?: () => number;
    makeSessionId?: () => string;
};
type ListerRuntime<P extends PresetMap> = {
    engine: ListerEngine;
    api: ListerApi<P>;
    getState(): ListerStoreState;
    subscribe(fn: () => void): () => void;
    actions: {
        focus(sessionId: ListerSessionId): void;
        close(sessionId: ListerSessionId): void;
        cancel(sessionId: ListerSessionId): void;
        apply(sessionId: ListerSessionId): void;
        clear(sessionId: ListerSessionId): void;
        toggle(sessionId: ListerSessionId, value: any): void;
        select(sessionId: ListerSessionId, value: any): void;
        deselect(sessionId: ListerSessionId, value: any): void;
        setQuery(sessionId: ListerSessionId, query: string): void;
        setSearchTarget(sessionId: ListerSessionId, target?: ListerSearchTarget): void;
        setSearchMode(sessionId: ListerSessionId, mode: ListerSearchMode): void;
        setFiltersPatch(sessionId: ListerSessionId, patch: any): void;
        mergeFiltersPatch(sessionId: ListerSessionId, patch: any): void;
        getFilterCtx<TFilters>(id: ListerSessionId): ListerFilterCtx<TFilters>;
        applyFilterOption(id: ListerSessionId, optionId: string | number): void;
        refresh(sessionId: ListerSessionId): void;
    };
    selectors: {
        effectiveFilters(sessionId: ListerSessionId): any;
        visibleOptions(sessionId: ListerSessionId): any[];
        detailsPayload(sessionId: ListerSessionId, action: ListerDetails<any, any, any, any>["action"]): any;
    };
};

/**
 * Context for Lister runtime bridge.
 */
declare const ListerContext: React.Context<ListerRuntime<any> | null>;
type ListerProviderProps<P extends PresetMap> = React.PropsWithChildren<CreateListerRuntimeOptions<P>>;
/**
 * ListerProvider — creates a singleton runtime and exposes it via React context.
 *
 * Responsibilities:
 * - instantiate `createListerRuntime` once per provider
 * - subscribe to runtime store (if needed by descendants)
 * - expose `api`, `actions`, `selectors`, and `state`
 */
declare function ListerProvider<P extends PresetMap>({ children, ...opts }: ListerProviderProps<P>): react_jsx_runtime.JSX.Element;
/**
 * Helper: get current runtime or throw
 */
declare function useListerRuntime<P extends PresetMap>(): ListerRuntime<P>;

declare function ListerUI(): React.ReactPortal | null;

/**
 * useLister — stable hook returning { api, store/state, actions, selectors }.
 *
 * It directly mirrors the current runtime, with stable reference equality
 * for top-level properties (api/actions/selectors), while `state` updates on
 * store changes.
 */
declare function useLister<P extends PresetMap>(): {
    api: ListerApi<P>;
    actions: {
        focus(sessionId: ListerSessionId): void;
        close(sessionId: ListerSessionId): void;
        cancel(sessionId: ListerSessionId): void;
        apply(sessionId: ListerSessionId): void;
        clear(sessionId: ListerSessionId): void;
        toggle(sessionId: ListerSessionId, value: any): void;
        select(sessionId: ListerSessionId, value: any): void;
        deselect(sessionId: ListerSessionId, value: any): void;
        setQuery(sessionId: ListerSessionId, query: string): void;
        setSearchTarget(sessionId: ListerSessionId, target?: ListerSearchTarget): void;
        setSearchMode(sessionId: ListerSessionId, mode: ListerSearchMode): void;
        setFiltersPatch(sessionId: ListerSessionId, patch: any): void;
        mergeFiltersPatch(sessionId: ListerSessionId, patch: any): void;
        getFilterCtx<TFilters>(id: ListerSessionId): ListerFilterCtx<TFilters>;
        applyFilterOption(id: ListerSessionId, optionId: string | number): void;
        refresh(sessionId: ListerSessionId): void;
    };
    selectors: {
        effectiveFilters(sessionId: ListerSessionId): any;
        visibleOptions(sessionId: ListerSessionId): any[];
        detailsPayload(sessionId: ListerSessionId, action: ListerDetails<any, any, any, any>["action"]): any;
    };
    state: ListerStoreState;
    store: ListerStoreState;
};
/**
 * useListerSession — convenience hook for one active session.
 * Example: UI overlays or modals can call this to get the current session.
 */
declare function useListerSession<P extends PresetMap>(sessionId?: ListerSessionId): {
    session: ListerRuntimeState<any, any, any, any, any> | undefined;
    activeId: string | undefined;
};

/**
 * Minimal selector contract (matches extractArray contract used by lister)
 * - function: (body) => array
 * - string: path selector
 */
type DataSelector<T> = ((body: any) => T[]) | string;
type DataSearchConfig = {
    default?: string;
};
type DataBuildRequestCtx<TFilters> = {
    filters?: TFilters;
    query: string;
    cursor: any;
};
type DataBuildRequestResult = {
    params?: any;
    body?: any;
    headers?: any;
};
type DataKey = string | number;
type DataSelectionMode = "none" | "single" | "multiple";
type DataSelectionKey<TItem> = keyof TItem | string | ((item: TItem) => DataKey | null | undefined);
type DataSelectionConfig<TItem> = {
    mode?: Exclude<DataSelectionMode, "none">;
    /**
     * How to resolve the ID for an item.
     * - string/ keyof: item[key]
     * - function: (item) => id
     * Defaults to: item.id ?? item.value
     */
    key?: DataSelectionKey<TItem>;
    /**
     * If "missing", selection IDs that don't exist in the *latest fetched list* are removed.
     * Default: "never" (recommended; avoids wiping selection on remote searches).
     */
    prune?: "never" | "missing";
};
type UseDataOptions<TItem = any, TFilters = Record<string, any>> = {
    id?: string;
    endpoint: string;
    method?: "GET" | "POST";
    selector?: DataSelector<TItem>;
    /**
     * Passed through into request builder (same signature shape as legacy provider)
     */
    buildRequest?: (ctx: DataBuildRequestCtx<TFilters>) => DataBuildRequestResult;
    /**
     * Minimal search config (default subject column).
     */
    search?: DataSearchConfig;
    /**
     * Raw filters object
     */
    filters?: TFilters;
    initial?: TItem[];
    enabled?: boolean;
    fetchOnMount?: boolean;
    searchMode?: ListerSearchMode;
    debounceMs?: number;
    autoFetchOnFilterChange?: boolean;
    /**
     * Optional selection support (by stable item key)
     */
    selection?: DataSelectionConfig<TItem>;
    /**
     * Optional override: custom http client (otherwise uses global axios / axios import)
     */
    http?: ListerHttpClient;
};
type UseDataResult<TItem = any, TFilters = Record<string, any>> = {
    id?: string;
    data: TItem[];
    visible: TItem[];
    res?: any;
    loading: boolean;
    error: any;
    query: string;
    setQuery: (q: string) => void;
    searchMode: ListerSearchMode;
    setSearchMode: (m: ListerSearchMode) => void;
    searchTarget?: ListerSearchTarget;
    setSearchTarget: (t: ListerSearchTarget) => void;
    filters?: TFilters;
    setFilters: (next: TFilters | undefined) => void;
    patchFilters: (patch: Partial<TFilters>) => void;
    clearFilters: () => void;
    selectionMode: DataSelectionMode;
    selectedIds: DataKey | DataKey[] | null;
    selected: TItem | TItem[] | null;
    select: (id: DataKey | DataKey[]) => void;
    deselect: (id: DataKey | DataKey[]) => void;
    toggle: (id: DataKey) => void;
    clearSelection: () => void;
    isSelected: (id: DataKey) => boolean;
    getSelection: () => TItem | TItem[] | null;
    refresh: () => Promise<TItem[]>;
    override(data: TItem[]): void;
    fetch: (override?: {
        query?: string;
        filters?: TFilters;
        searchTarget?: ListerSearchTarget;
        search?: ListerSearchPayload;
    }) => Promise<TItem[]>;
};
declare function useData<TItem = any, TFilters = Record<string, any>>(opts: UseDataOptions<TItem, TFilters>, deps?: any[]): UseDataResult<TItem, TFilters>;

declare const ShadcnJsonEditorVariant: React.ForwardRefExoticComponent<ShadcnJsonEditorProps & React.RefAttributes<JsonEditorIndexHandle>>;

export { type DataBuildRequestCtx, type DataBuildRequestResult, type DataKey, type DataSearchConfig, type DataSelectionConfig, type DataSelectionKey, type DataSelectionMode, type DataSelector, ShadcnJsonEditorVariant as JsonEditor, ListerApi, ListerContext, ListerDefinition, ListerDetails, ListerFilterCtx, ListerId, ListerOption, ListerProvider, ListerProviderHost, type ListerProviderProps, ListerRuntimeState, ListerSearchMode, ListerSearchPayload, ListerSearchTarget, ListerSessionId, ListerStoreState, ListerUI, PresetMap, type UseDataOptions, type UseDataResult, useData, useLister, useListerRuntime, useListerSession };
