"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ElementData_exports = {};
__export(ElementData_exports, {
  ElementData: () => ElementData
});
module.exports = __toCommonJS(ElementData_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_react2 = require("react");
var import_use_builtin_suspense = require("../hooks/use-builtin-suspense");
var import_use_component = require("../hooks/use-component");
var import_can_accept_ref = require("../utils/can-accept-ref");
var import_FallbackComponent = require("../../../components/shared/FallbackComponent");
var import_controls = require("../controls");
var import_activity_with_fallback = require("./activity-with-fallback");
const ElementData = (0, import_react2.memo)(
  (0, import_react2.forwardRef)(function ElementData2({ elementData }, ref) {
    const Component = (0, import_use_component.useComponent)(elementData.type);
    const builtinSuspense = (0, import_use_builtin_suspense.useBuiltinSuspense)(elementData.type);
    if (Component == null) {
      console.warn(`Unknown component '${elementData.type}'`, { elementData });
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FallbackComponent.FallbackComponent, { ref, text: "Component not found" });
    }
    const forwardRef2 = (0, import_can_accept_ref.canAcceptRef)(Component);
    return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
  })
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ElementData
});
//# sourceMappingURL=ElementData.js.map