"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 render_element_exports = {};
__export(render_element_exports, {
  RichTextV2Element: () => RichTextV2Element
});
module.exports = __toCommonJS(render_element_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_control = require("../../control");
function RichTextV2Element({ definition, plugins, ...props }) {
  function initialRenderElement(props2) {
    return props2.children;
  }
  const renderElement = plugins.reduce(
    (renderFn, plugin) => (props2) => {
      const { control, renderElement: renderElement2 } = plugin;
      if (renderElement2 == null)
        return renderFn(props2);
      if (control == null || control.getElementValue == null)
        return renderElement2(renderFn, void 0)(props2);
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control.ControlValue, { definition: control.definition, data: control.getElementValue(props2.element), children: (value) => renderElement2(renderFn, value)(props2) });
    },
    initialRenderElement
  );
  return renderElement(props);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RichTextV2Element
});
//# sourceMappingURL=render-element.js.map