import { jsxs as s, jsx as f } from "@emotion/react/jsx-runtime";
import { DividerNode as c } from "../../subcomponents/DividerNode/index.js";
import { SectionNode as l } from "../../subcomponents/SectionNode/index.js";
import { TextBoxNode as y } from "../../subcomponents/TextBoxNode/index.js";
import { HeaderNode as N } from "../../subcomponents/HeaderNode/index.js";
import { ImageNode as g } from "../../subcomponents/ImageNode/index.js";
import { BodyNode as h } from "../../subcomponents/BodyNode/index.js";
import { FooterNode as u } from "../../subcomponents/FooterNode/index.js";
import { PaperNode as _ } from "../../subcomponents/PaperNode/index.js";
import { PropertyValueNode as x } from "../../subcomponents/PropertyValueNode/index.js";
import { GridNode as j } from "../../subcomponents/GridNode/index.js";
import { ChartNode as B } from "../../subcomponents/ChartNode/index.js";
import { PagerNode as P } from "../../subcomponents/Pager/index.js";
import { QRImageNode as b } from "../../subcomponents/QRImageNode/index.js";
import { useBase as v, evaluateWithContext as w } from "@m4l/core";
const C = (i) => {
  const { data: m } = i, e = m || {}, r = e.children, d = e.key, n = Object.fromEntries(
    Object.entries(e).filter(([o]) => o !== "key" && o !== "children")
  ), { sourceData: a } = v(), t = {
    section: l,
    textBox: y,
    divider: c,
    image: g,
    header: N,
    body: h,
    footer: u,
    paper: _,
    propertyValue: x,
    grid: j,
    chart: B,
    pager: P,
    qrImage: b,
    __default__: () => {
      throw new Error("Type no defined");
    }
  }, p = t[e.type] ?? t.__default__;
  return /* @__PURE__ */ s(p, { ...n, children: [
    Array.isArray(r) && r.length > 0 ? r.map((o, I) => /* @__PURE__ */ f(
      C,
      {
        data: o
      },
      `${o.key}-${Math.random().toString(36).substring(7)}`
    )) : null,
    typeof r == "string" ? w(a, r) : null
  ] }, d);
};
export {
  C as FactoryRender
};
