import { jsx as a } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import p from "../DataGridCell.js";
import b from "./Icon.js";
import h from "../../Link/Link.js";
import { ButtonVariant as v } from "../../Button/types.js";
import i from "classnames";
import N from "../../Button/Button.js";
import { Fragment as y } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
const _ = (t) => !!t && typeof t == "object" && "value" in t, u = (t) => !!t && typeof t == "object" && t.type === "icon", j = (t) => !!t && typeof t == "object" && t.type === "button", x = (t) => !!t && typeof t == "object" && t.type === "link", w = ({
  columns: t,
  customCells: l,
  item: r,
  rowIndex: g
}) => /* @__PURE__ */ a(y, { children: t.map(({ key: o, position: e }) => {
  if (l?.[o])
    return /* @__PURE__ */ a(p, { "aria-labelledby": String(o), column: o, position: e, children: /* @__PURE__ */ a("div", {
      style: { width: "min-content" },
      // TODO create safeguard to remove "as any" assertion
      children: l[o]({
        key: o,
        value: r[o],
        item: r,
        rowIndex: g
      })
    }) }, o);
  const n = r[o], { value: c, type: s } = _(n) ? n : { value: n, type: "text" }, f = u(n) ? { url: n?.config?.src, alt: n?.config?.alt !== void 0 && n?.config?.alt !== null ? n?.config?.alt : n.value } : void 0, d = j(n) ? (m) => {
    m.stopPropagation(), n?.config?.action();
  } : void 0;
  return /* @__PURE__ */ a(p, { "aria-labelledby": String(o), column: o, position: e, children: /* @__PURE__ */ a("div", { className: "adyen-pe-data-grid__cell-value", children: [
    u(n) && n.config && f?.url && /* @__PURE__ */ a("div", { className: i("adyen-pe-data-grid__icon-cell", n?.config?.className), children: [
      /* @__PURE__ */ a(b, { ...f }),
      c.trim() && /* @__PURE__ */ a("span", { children: c })
    ] }),
    s === "text" && /* @__PURE__ */ a("span", { className: i(n?.config?.className), children: c }),
    s === "button" && n.config && d && /* @__PURE__ */ a(N, { className: i(n.config?.className), onClick: d, variant: v.SECONDARY, children: c }),
    x(n) && n.config && /* @__PURE__ */ a(
      h,
      {
        classNames: n.config.className ? [n.config.className] : [],
        href: n.config.href,
        target: n.config.target,
        children: c
      }
    )
  ] }) }, o);
}) });
export {
  w as TableCells,
  _ as isCustomDataObject
};
