import { jsx as e, jsxs as k } from "@emotion/react/jsx-runtime";
import f, { isValidElement as V } from "react";
import { AdornmentStyled as S, ImageStyled as j, IconStyled as p, RootStyled as D, ContentStyled as L, LinkLikeButtonStyled as O } from "./slots/NestedFormatterSlots.js";
import { getIconColor as u } from "../../../utils/getIconColor.js";
function A(y) {
  const {
    value: w,
    defaultValue: I = "-",
    imageUrl: l,
    imageWidth: n,
    imageHeight: o,
    icon: t,
    iconColor: i,
    onLink: c,
    Component: v = f.Fragment,
    rowHeightVariant: s
  } = y, d = f.useMemo(
    () => ({
      width: n,
      height: o,
      hasDefinedSize: n !== void 0 && o !== void 0,
      cover: !1
    }),
    [n, o]
  ), a = w ?? I, C = typeof a == "object" ? JSON.stringify(a) : String(a), r = typeof l == "string" && l.length > 0, h = !r && t !== void 0 && t !== null && t !== "", x = r && !d.hasDefinedSize, b = r ? /* @__PURE__ */ e(S, { ownerState: { hasImage: !0 }, children: /* @__PURE__ */ e(
    j,
    {
      src: l,
      alt: "",
      width: n,
      height: o,
      ownerState: d,
      enableIntersectionObserver: !1
    }
  ) }) : h ? /* @__PURE__ */ e(S, { children: typeof t == "string" ? /* @__PURE__ */ e(
    p,
    {
      src: t,
      color: i !== void 0 ? u(i) : "text.secondary"
    }
  ) : V(t) ? /* @__PURE__ */ e(
    p,
    {
      icon: t,
      color: i !== void 0 ? u(i) : "text.secondary"
    }
  ) : null }) : null, m = /* @__PURE__ */ e(v, { children: C });
  return /* @__PURE__ */ k(D, { ownerState: { fillCell: x, hasIcon: h, hasImage: r }, children: [
    b,
    /* @__PURE__ */ e(L, { ownerState: { rowHeightVariant: s }, children: typeof c == "function" ? /* @__PURE__ */ e(
      O,
      {
        type: "button",
        ownerState: { rowHeightVariant: s },
        onClick: (g) => {
          g.preventDefault(), g.stopPropagation(), c();
        },
        children: m
      }
    ) : m })
  ] });
}
export {
  A as NestedFormatter
};
