import { cx as e } from "../../theme/tools.js";
import { Badge as t } from "../../atomic/atoms/badge/Badge.js";
import { FormattedDate as n } from "../../atomic/atoms/formatted-date/FormattedDate.js";
import { date as r, muted as i, number as a, text as o } from "./TableCell.css.js";
import { TableCellBase as s } from "./TableCellBase.js";
import { useMemo as c } from "react";
import { jsx as l } from "react/jsx-runtime";
//#region src/components/data-table/TableCell.tsx
var u = "—", d = u, f = { maximumFractionDigits: 2 }, p = {
	dateStyle: "medium",
	timeStyle: "short"
}, m = {
	Base: s,
	Text: ({ value: t, fallback: n = d, children: r, ellipsis: i = !1, className: a }) => {
		let c = r ?? t;
		if (c == null) c = n;
		else if (typeof c == "string") {
			let e = c.trim();
			c = e.length === 0 ? n : e;
		}
		return /* @__PURE__ */ l(s, {
			ellipsis: i,
			className: e(o, a),
			children: c
		});
	},
	Number: ({ value: e, fallback: t = d, locale: n, formatOptions: r = f }) => /* @__PURE__ */ l(s, {
		align: "end",
		className: a,
		children: c(() => {
			if (e == null || Number.isNaN(Number(e))) return t;
			try {
				return new Intl.NumberFormat(n, r).format(e);
			} catch {
				return String(e);
			}
		}, [
			e,
			t,
			n,
			r
		])
	}),
	Status: ({ label: e, tone: n, isLoading: r = !1 }) => /* @__PURE__ */ l(s, { children: /* @__PURE__ */ l(t, {
		tone: n,
		loading: r,
		children: e
	}) }),
	Date: ({ value: e, fallback: t = u, locale: i, options: a = p }) => /* @__PURE__ */ l(s, {
		className: r,
		children: /* @__PURE__ */ l(n, {
			value: e,
			fallback: t,
			locale: i,
			options: a
		})
	}),
	Badge: ({ label: e, tone: n }) => /* @__PURE__ */ l(s, { children: /* @__PURE__ */ l(t, {
		tone: n,
		children: e
	}) }),
	Actions: ({ children: e, className: t }) => /* @__PURE__ */ l(s, {
		align: "end",
		className: t,
		children: e
	}),
	Muted: ({ children: e }) => /* @__PURE__ */ l("span", {
		className: i,
		children: e
	})
};
//#endregion
export { m as TableCell };

//# sourceMappingURL=TableCell.js.map