import { jsx as e, jsxs as V } from "react/jsx-runtime";
import { useMemo as f } from "react";
import { c as g } from "./index.CfM2L_w0.js";
import { D as H } from "./DataTableHeader.BcCzSX7d.js";
import { D as h } from "./DataTableRow.CDjpDi9g.js";
import { n as T } from "./index.B0wX8xO7.js";
import { l as y } from "./index.C1ZfizMq.js";
import { L as _ } from "./LoadingState.BcrOPPws.js";
import { a as N } from "./index.CfQlFjZU.js";
const C = "creator_dataTableContainer_mFZ3M", w = "creator_empty_4zm8i", p = "creator_dataTable_MKdhe", b = { dataTableContainer: C, empty: w, dataTable: p }, x = "data:image/svg+xml,%3csvg%20width='120'%20height='104'%20viewBox='0%200%20120%20104'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='56'%20y='8'%20width='64'%20height='64'%20rx='4'%20fill='%23E3F331'/%3e%3cpath%20d='M52%2024.0001H89.3333V18.6667H52V24.0001ZM52%2034.6667H89.3333V29.3334H52V34.6667ZM52%2045.3334H89.3333V40.0001H52V45.3334ZM94.6667%2045.3334H100V40.0001H94.6667V45.3334ZM94.6667%2018.6667V24.0001H100V18.6667H94.6667ZM94.6667%2034.6667H100V29.3334H94.6667V34.6667Z'%20fill='%23323134'/%3e%3crect%20x='16'%20y='40'%20width='64'%20height='64'%20rx='4'%20fill='%23E3F331'/%3e%3cpath%20d='M52%2048H12C9.06667%2048%206.66667%2050.4%206.66667%2053.3333V90.6667C6.66667%2093.6%209.06667%2096%2012%2096H52C54.9333%2096%2057.3333%2093.6%2057.3333%2090.6667V53.3333C57.3333%2050.4%2054.9333%2048%2052%2048ZM52%2053.3333V61.3333H12V53.3333H52ZM38.6667%2090.6667H25.3333V66.6667H38.6667V90.6667ZM12%2066.6667H20V90.6667H12V66.6667ZM44%2090.6667V66.6667H52V90.6667H44Z'%20fill='%23323134'/%3e%3c/svg%3e", M = "creator_emptyTableContainer_H-r7u", v = "creator_content_-chch", Z = "creator_image_xu-Ut", D = "creator_text_I8bCe", I = "creator_title_lQBzV", E = "creator_description_jUWfI", m = { emptyTableContainer: M, content: v, image: Z, text: D, title: I, description: E }, F = (t) => ({
  content: t.content,
  containerClassName: m.emptyTableContainer,
  contentClassName: m.content,
  titleClassName: m.title,
  descriptionClassName: m.description,
  imageClassName: m.image,
  textClassName: m.text,
  ...t,
  imageSrc: t.imageSrc || x,
  title: t.title || "No data to show",
  description: t.description || ""
}), j = ({
  content: t,
  imageSrc: d,
  title: c,
  description: s,
  containerClassName: r,
  contentClassName: l,
  textClassName: a,
  imageClassName: n,
  titleClassName: i,
  descriptionClassName: o
}) => /* @__PURE__ */ e("div", { className: r, children: /* @__PURE__ */ V("div", { className: l, children: [
  /* @__PURE__ */ e("img", { src: d, className: n }),
  t || /* @__PURE__ */ V("div", { className: a, children: [
    /* @__PURE__ */ e("span", { className: i, children: c }),
    /* @__PURE__ */ e("span", { className: o, children: s })
  ] })
] }) }), z = N(j, F), B = Array.from({ length: 10 });
function L(t) {
  const d = f(() => {
    const { data: c } = t, s = (l) => l instanceof Function ? (a, n) => /* @__PURE__ */ e(h, { cells: l(a, n, c) }, n) : (a, n) => /* @__PURE__ */ e(h, { cells: a }, n);
    if ("type" in t) {
      const { type: l, rows: a } = t;
      return {
        layouts: Object.keys(a).reduce(
          (i, o) => (i[o] = s(a[o]), i),
          {}
        ),
        type: l,
        values: c
      };
    }
    const r = s(t.row);
    return {
      values: c,
      layout: r
    };
  }, [t]);
  return {
    tableClassName: g(b.dataTable, {
      [b.empty]: !t.isLoading && !t.data.length
    }),
    tableContainerClassName: b.dataTableContainer,
    each: d,
    ...t
  };
}
function S({
  isLoading: t = !1,
  columns: d,
  head: c,
  footer: s,
  tableClassName: r,
  tableContainerClassName: l,
  each: a,
  data: n,
  emptyTableContent: i
}) {
  return !t && !n.length ? /* @__PURE__ */ e("div", { className: l, children: /* @__PURE__ */ e("table", { className: r, "data-testId": "dataTable", children: /* @__PURE__ */ e(z, { ...i }) }) }) : /* @__PURE__ */ e("div", { className: l, children: /* @__PURE__ */ V("table", { className: r, "data-testId": "dataTable", children: [
    /* @__PURE__ */ e("colgroup", { children: d?.map((o, u) => /* @__PURE__ */ e("col", { ...o }, u)) }),
    /* @__PURE__ */ e(H, { headers: c }),
    /* @__PURE__ */ e("tbody", { "data-testId": "dataTableBody", children: /* @__PURE__ */ e(
      T,
      {
        value: t,
        then: /* @__PURE__ */ e(
          y,
          {
            values: B,
            layout: (o, u) => /* @__PURE__ */ e(
              h,
              {
                cells: [...Array(c.length)].fill(
                  /* @__PURE__ */ e(
                    _,
                    {
                      type: "skeleton",
                      size: "medium",
                      "data-testId": "loading"
                    }
                  )
                )
              },
              u
            )
          }
        ),
        otherwise: /* @__PURE__ */ e(y, { ...a })
      }
    ) }),
    s && /* @__PURE__ */ e("tfoot", { "data-testId": "dataTableFooter", children: /* @__PURE__ */ e(h, { cells: s }) })
  ] }) });
}
function q(t) {
  return S(L(t));
}
export {
  q as D
};
