import { lazy } from "react";

/**
 * Lazy-loaded heavy leaf components. Each is split into its own chunk by Vite
 * (named after the source file) so the main bundle stays small. Imports use
 * the `.then(m => ({ default: m.X }))` adapter so the original modules can
 * keep their named exports without needing a default export.
 */
export const LazyCompareDrawer = lazy(() =>
  import("./CompareDrawer").then((m) => ({ default: m.CompareDrawer })),
);

export const LazyReplayDialog = lazy(() =>
  import("./ReplayDialog").then((m) => ({ default: m.ReplayDialog })),
);

export const LazyRequestAnatomy = lazy(() =>
  import("./anatomy/RequestAnatomy").then((m) => ({ default: m.RequestAnatomy })),
);

export const LazyResponseView = lazy(() =>
  import("./ResponseView").then((m) => ({ default: m.ResponseView })),
);

export const LazyStreamingChunkSequence = lazy(() =>
  import("./StreamingChunkSequence").then((m) => ({
    default: m.StreamingChunkSequence,
  })),
);

export const LazyJsonViewer = lazy(() =>
  import("../ui/json-viewer").then((m) => ({ default: m.JsonViewer })),
);

export const LazyJsonViewerFromString = lazy(() =>
  import("../ui/json-viewer").then((m) => ({ default: m.JsonViewerFromString })),
);
