import * as React from "react";
import { getPrimitive } from "./primitive-registry";
import { DrawerContext, ThemeHarvestContext, applyContextWiredProps, } from "./context-wired-props";
export function SlotRenderer({ specs }) {
    const drawer = React.useContext(DrawerContext);
    const themeHarvest = React.useContext(ThemeHarvestContext);
    return (React.createElement(React.Fragment, null, specs.map((spec, idx) => {
        const Component = getPrimitive(spec.component);
        if (!Component) {
            if (typeof process !== "undefined" &&
                process.env.NODE_ENV !== "production") {
                return (React.createElement("div", { key: `err-${idx}`, className: "seekora-layout__error", "data-component": spec.component },
                    "Unknown component: ",
                    spec.component));
            }
            return null;
        }
        const props = applyContextWiredProps(spec.component, spec.props ?? {}, drawer, themeHarvest);
        return React.createElement(Component, { key: `${spec.component}-${idx}`, ...props });
    })));
}
