import React from "react";
import { createRoot } from "react-dom/client";
import { ProductCard } from "./components/suggestions-primitives/ProductCard";
import { ImageDisplay } from "./components/primitives/ImageDisplay";
import { PriceDisplay } from "./components/primitives/PriceDisplay";
import { BadgeList } from "./components/primitives/BadgeList";
import { VariantSwatches } from "./components/primitives/VariantSwatches";
import { ActionButtons } from "./components/primitives/ActionButtons";
import { AddToCartButton } from "./components/primitives/AddToCartButton";
// Phase-2 chrome components (Wave 3 — SCRUM-268)
import { Facets } from "./components/Facets";
import { Pagination } from "./components/Pagination";
import { SortBy } from "./components/SortBy";
import { Stats } from "./components/Stats";
import { CurrentRefinements } from "./components/CurrentRefinements";
import { ClearRefinements } from "./components/ClearRefinements";
import { MobileFilters, MobileFiltersButton } from "./components/MobileFilters";
import { FacetDropdown } from "./components/FacetDropdown";
import { RangeInput } from "./components/RangeInput";
import { RangeSlider } from "./components/RangeSlider";
import { HierarchicalMenu } from "./components/HierarchicalMenu";
import { SearchLayout } from "./components/SearchLayout";
// Single-tree SearchProvider exports (Wave 4 — SCRUM-268)
import { SeekoraClient } from "@seekora-ai/search-sdk";
import { SearchProvider } from "./components/SearchProvider";
import { SearchStateManager } from "@seekora-ai/ui-sdk-core";
import { useSearchState } from "./hooks/useSearchState";
// Error Boundary (SCRUM-268)
import { SeekoraErrorBoundary } from "./components/ErrorBoundary";
// Storefront Layout Engine (Task 10 — SCRUM-268)
import { mountLayout } from "./layout/mount";
import { LayoutRenderer } from "./layout/LayoutRenderer";
import { registerPrimitive, listPrimitives, PRIMITIVE_REGISTRY, } from "./layout/primitive-registry";
import { validateLayoutConfig } from "./layout/validate-config";
export { React, createRoot, ProductCard, ImageDisplay, PriceDisplay, BadgeList, VariantSwatches, ActionButtons, AddToCartButton, 
// Phase-2 chrome
Facets, Pagination, SortBy, Stats, CurrentRefinements, ClearRefinements, MobileFilters, MobileFiltersButton, FacetDropdown, RangeInput, RangeSlider, HierarchicalMenu, SearchLayout, 
// Single-tree chrome (Wave 4 — SCRUM-268)
SeekoraClient, SearchProvider, SearchStateManager, useSearchState, 
// Error Boundary (SCRUM-268)
SeekoraErrorBoundary, 
// Storefront Layout Engine (Task 10 — SCRUM-268)
mountLayout, LayoutRenderer, registerPrimitive, listPrimitives, PRIMITIVE_REGISTRY, validateLayoutConfig, };
// ---------------------------------------------------------------------------
// Existing mount helper — ProductCard
// ---------------------------------------------------------------------------
// Convenience mount helper used by the storefront extension.
// Accepts the host-provided position index per call so the SDK's
// impression + click analytics buffers stamp the correct ordinal.
// Caller passes a ProductDisplayConfig shape (style/size/showBrand/
// currency/etc.) — see `suggestions/types.ts::ProductDisplayConfig`.
export function mountProductCard(el, product, config, position, onSelect) {
    const root = createRoot(el);
    // ProductCard.onSelect is () => void; caller passes (p: any) => void.
    // Wrap so the inner signature matches.
    const select = onSelect ? () => onSelect(product) : () => { };
    root.render(React.createElement(ProductCard, {
        product,
        displayConfig: config,
        position: typeof position === "number" ? position : 0,
        onSelect: select,
    }));
    return { unmount: () => root.unmount() };
}
// ---------------------------------------------------------------------------
// Phase-2 chrome mount helpers (Wave 3 — SCRUM-268)
// Each accepts (el, props) — el is the host container, props forwarded
// to the React component verbatim.  Returns { unmount } so the caller
// can tear down on re-render.
// ---------------------------------------------------------------------------
export function mountFacets(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(Facets, props));
    return { unmount: () => root.unmount() };
}
export function mountPagination(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(Pagination, props));
    return { unmount: () => root.unmount() };
}
export function mountSortBy(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(SortBy, props));
    return { unmount: () => root.unmount() };
}
export function mountStats(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(Stats, props));
    return { unmount: () => root.unmount() };
}
export function mountCurrentRefinements(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(CurrentRefinements, props));
    return { unmount: () => root.unmount() };
}
export function mountClearRefinements(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(ClearRefinements, props));
    return { unmount: () => root.unmount() };
}
export function mountMobileFilters(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(MobileFilters, props));
    return { unmount: () => root.unmount() };
}
export function mountFacetDropdown(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(FacetDropdown, props));
    return { unmount: () => root.unmount() };
}
export function mountRangeInput(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(RangeInput, props));
    return { unmount: () => root.unmount() };
}
export function mountRangeSlider(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(RangeSlider, props));
    return { unmount: () => root.unmount() };
}
export function mountHierarchicalMenu(el, props) {
    const root = createRoot(el);
    root.render(React.createElement(HierarchicalMenu, props));
    return { unmount: () => root.unmount() };
}
