import * as react from 'react';
import { ReactNode } from 'react';
import { ReadOpts, Product, CatalogFilter, Page } from '@platform-modules/commerce-catalog';
export { CatalogFilter, Money, Page, Product, ReadOpts, Variant, VariantPrice, isImmutableFieldError, isNoPriceForCurrencyError, isProductValidationError } from '@platform-modules/commerce-catalog';

/**
 * Injected, DB-free data seam for browser-side catalog reads (§1).
 * The host wires each method to an API route it owns (the route enforces the
 * audience/visibility floor). The one production transport is HTTP; an
 * in-process core wrapper and a mock are test doubles, not production adapters.
 * `db` is bound host-side and never appears here.
 */
interface CatalogClient {
    getProductBySlug(slug: string, opts: ReadOpts): Promise<Product | null>;
    getProductById(id: string, opts: ReadOpts): Promise<Product | null>;
    listProducts(filter: CatalogFilter): Promise<Page<Product>>;
}

/** Pure client-injection context (§2) — no shared mount-state, no mount fetch. */
declare function CatalogProvider({ client, children }: {
    client: CatalogClient;
    children: ReactNode;
}): react.JSX.Element;

declare function useProductBySlug(slug: string, opts?: Partial<ReadOpts>, seed?: {
    initialData?: Product | null;
}): {
    product: Product | null;
    loading: boolean;
    error: Error | null;
    reload: () => void;
};

declare function useProductById(id: string, opts?: Partial<ReadOpts>, seed?: {
    initialData?: Product | null;
}): {
    product: Product | null;
    loading: boolean;
    error: Error | null;
    reload: () => void;
};

declare function useProductList(filter: CatalogFilter, seed?: {
    initialData?: Page<Product>;
}): {
    page: Page<Product> | null;
    loading: boolean;
    error: Error | null;
    reload: () => void;
};

/** Thrown when a catalog hook is used outside <CatalogProvider> (§2). */
declare class CatalogProviderError extends Error {
    readonly name = "CatalogProviderError";
    constructor(hook: string);
}
declare function isCatalogProviderError(e: unknown): e is CatalogProviderError;
/** Thrown by reviveProduct/reviveProductPage on malformed serialized wire input (§5). */
declare class ProductWireError extends Error {
    readonly name = "ProductWireError";
    constructor(message: string);
}
declare function isProductWireError(e: unknown): e is ProductWireError;

/** Wire JSON → typed Product (deep). Reconstructs bigint amounts + the four Date fields. §5 */
declare function reviveProduct(raw: unknown): Product;
/** Wire JSON → typed Page<Product>, revival mapped over items. §5 */
declare function reviveProductPage(raw: unknown): Page<Product>;

export { type CatalogClient, CatalogProvider, CatalogProviderError, ProductWireError, isCatalogProviderError, isProductWireError, reviveProduct, reviveProductPage, useProductById, useProductBySlug, useProductList };
