"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }



var _chunkIT5ICP43js = require('./chunk-IT5ICP43.js');


var _chunkHOY77YBFjs = require('./chunk-HOY77YBF.js');


var _chunkEGTDJ4PLjs = require('./chunk-EGTDJ4PL.js');

// src/rendering/components/Block.tsx
var _jsxruntime = require('react/jsx-runtime');
async function Block({
  blockKind,
  blockId,
  content,
  theme,
  siteId,
  pageId,
  previewStage,
  client,
  usePlaceholders: _usePlaceholders = false,
  override: OverrideComponent
}) {
  const definition = _chunkEGTDJ4PLjs.getBlockDefinition.call(void 0, blockKind);
  if (!definition && !OverrideComponent) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border border-red-300 bg-red-50 rounded", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-red-800 font-semibold", children: [
      "Unknown block type: ",
      blockKind
    ] }) });
  }
  const themeRuntime = _chunkIT5ICP43js.buildThemeRuntime.call(void 0, theme);
  let resolvedData;
  if (client && blockId && definition) {
    const pageOutline = {
      name: "Single Block",
      path: "/block",
      purpose: "Block preview",
      blocks: [{
        id: blockId,
        kind: blockKind,
        purpose: "preview"
      }]
    };
    const allResolvedData = await _chunkHOY77YBFjs.prefetchBlockData.call(void 0, 
      pageOutline,
      { siteId, pageId, previewStage },
      client
    );
    resolvedData = allResolvedData[blockId];
  }
  if (OverrideComponent) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      OverrideComponent,
      {
        content,
        theme: themeRuntime.tokens,
        themeConfig: theme,
        data: resolvedData,
        blockId: _nullishCoalesce(blockId, () => ( null)),
        blockKind
      }
    );
  }
  if (!definition) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border border-red-300 bg-red-50 rounded", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-red-800 font-semibold", children: [
      "Unknown block type: ",
      blockKind
    ] }) });
  }
  const BlockComponent = _chunkIT5ICP43js.makeDefaultBlockComponent.call(void 0, { manifest: definition.manifest });
  const registry = _chunkIT5ICP43js.getDefaultComponentRegistry.call(void 0, );
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    BlockComponent,
    {
      blockId: _nullishCoalesce(blockId, () => ( void 0)),
      blockKind,
      theme: themeRuntime.tokens,
      themeConfig: theme,
      content,
      data: resolvedData,
      registry
    }
  );
}



exports.Block = Block;
//# sourceMappingURL=chunk-BUCJWG6G.js.map