import { jsx as m, Fragment as s } from "react/jsx-runtime";
import { useStreamContext as l } from "../../providers/Stream.es.js";
import { useCustomComponents as f } from "../../providers/CustomComponentProvider.es.js";
import { LoadExternalComponent as C } from "@langchain/langgraph-sdk/react-ui";
import d from "react";
import { logger as i } from "../../utils/logger.es.js";
function c({
  message: o,
  thread: a
}) {
  const { values: e } = l(), { components: n } = f(), r = d.useMemo(() => e.ui?.filter(
    (t) => t?.metadata?.id === o.id || t?.metadata?.message_id === o.id || t?.id === o.id
  ), [e.ui, o.id]);
  return i.debug("CustomComponentRender - customComponents:", o), i.debug("CustomComponentRender - available components:", e), r?.length ? /* @__PURE__ */ m(s, { children: r?.filter((t) => !!n?.[t.name]).map((t, p) => {
    const u = t.props || {};
    return /* @__PURE__ */ m(
      C,
      {
        stream: a,
        message: t,
        components: n,
        meta: { ...u, ui: t }
      },
      t._key || `${o.id}-${t.id || p}`
    );
  }) }) : null;
}
const h = d.memo(c);
export {
  h as default
};
//# sourceMappingURL=CustomComponentRender.es.js.map
