import { jsx } from "react/jsx-runtime";
import { createElement } from "react";
import { forwardRef, memo } from "react";
import { useBuiltinSuspense } from "../hooks/use-builtin-suspense";
import { useComponent } from "../hooks/use-component";
import { canAcceptRef } from "../utils/can-accept-ref";
import { FallbackComponent } from "../../../components/shared/FallbackComponent";
import { ResolveProps } from "../controls";
import { ActivityOrFallback } from "./activity-with-fallback";
const ElementData = memo(
  forwardRef(function ElementData2({ elementData }, ref) {
    const Component = useComponent(elementData.type);
    const builtinSuspense = useBuiltinSuspense(elementData.type);
    if (Component == null) {
      console.warn(`Unknown component '${elementData.type}'`, { elementData });
      return /* @__PURE__ */ jsx(FallbackComponent, { ref, text: "Component not found" });
    }
    const forwardRef2 = canAcceptRef(Component);
    return /* @__PURE__ */ jsx(ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ jsx(ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key }) }) });
  })
);
export {
  ElementData
};
//# sourceMappingURL=ElementData.js.map