"use client";
import { jsx } from "react/jsx-runtime";
import { memo, useMemo } from "react";
import {
  componentDocumentToRootEmbeddedDocument
} from "../../../client";
import { getRootElement } from "../../../state/react-page";
import { useCacheData } from "../hooks/use-cache-data";
import { useRegisterDocument } from "../hooks/use-register-document";
import { useBuiltinSuspense } from "../hooks/use-builtin-suspense";
import { ActivityOrFallback } from "./activity-with-fallback";
import { DocumentRoot } from "./DocumentRoot";
const MakeswiftComponent = memo(({ snapshot, label, type, description }) => {
  useCacheData(snapshot.cacheData);
  const rootDocument = useMemo(
    () => componentDocumentToRootEmbeddedDocument({
      document: snapshot.document,
      documentKey: snapshot.key,
      name: label,
      type,
      description,
      meta: snapshot.meta
    }),
    [snapshot, label, type, description]
  );
  useRegisterDocument(rootDocument);
  const builtinSuspense = useBuiltinSuspense(getRootElement(rootDocument).type);
  return /* @__PURE__ */ jsx(ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ jsx(DocumentRoot, { rootDocument }) });
});
export {
  MakeswiftComponent
};
//# sourceMappingURL=MakeswiftComponent.js.map