import { t as e } from "../../utils-B7XIe3qq.js";
import { t } from "../../dist-BCCeHAQm.js";
import * as n from "react";
import { jsx as r, jsxs as i } from "react/jsx-runtime";
//#region src/react/primitives/avatar.tsx
var a = t("relative inline-flex shrink-0 items-center justify-center overflow-hidden bg-glass border border-border-glass", {
	variants: {
		size: {
			xs: "size-6 text-[10px]",
			sm: "size-8 text-xs",
			md: "size-10 text-sm",
			lg: "size-12 text-base",
			xl: "size-16 text-lg"
		},
		shape: {
			circle: "rounded-full",
			square: "rounded-xl"
		}
	},
	defaultVariants: {
		size: "md",
		shape: "circle"
	}
});
function o({ className: t, size: n, shape: o, status: s, children: c, ...l }) {
	return /* @__PURE__ */ i("div", {
		"data-slot": "avatar",
		role: "img",
		className: e(a({
			size: n,
			shape: o
		}), t),
		...l,
		children: [c, s && /* @__PURE__ */ r(u, { status: s })]
	});
}
function s({ className: t, src: i, alt: a = "", onLoadingStatusChange: o, ...s }) {
	let [c, l] = n.useState("loading");
	return n.useEffect(() => {
		l("loading");
	}, [i]), c === "error" ? null : /* @__PURE__ */ r("img", {
		"data-slot": "avatar-image",
		src: i,
		alt: a,
		className: e("aspect-square size-full object-cover", t),
		onLoad: () => {
			l("loaded"), o?.("loaded");
		},
		onError: () => {
			l("error"), o?.("error");
		},
		...s
	});
}
function c({ className: t, ...n }) {
	return /* @__PURE__ */ r("span", {
		"data-slot": "avatar-fallback",
		className: e("flex size-full items-center justify-center font-semibold text-foreground-secondary", t),
		...n
	});
}
var l = {
	online: "bg-accent-emerald",
	offline: "bg-foreground-muted",
	away: "bg-accent-amber",
	busy: "bg-accent-rose"
};
function u({ status: t }) {
	return /* @__PURE__ */ r("span", {
		"aria-hidden": "true",
		className: e("absolute bottom-0 right-0 block size-2.5 rounded-full ring-2 ring-background", l[t])
	});
}
function d({ className: t, max: a, children: o, ...s }) {
	let c = n.Children.toArray(o), l = c.length, u = a !== void 0 && a < l ? a : l, d = l - u, f = c.slice(0, u);
	return /* @__PURE__ */ i("div", {
		"data-slot": "avatar-group",
		role: "group",
		"aria-label": "Avatar group",
		className: e("flex -space-x-2", t),
		...s,
		children: [f.map((e, t) => /* @__PURE__ */ r("div", {
			className: "ring-2 ring-background rounded-full",
			children: e
		}, t)), d > 0 && /* @__PURE__ */ i("span", {
			"aria-label": `${d} more`,
			className: "inline-flex size-10 items-center justify-center rounded-full border border-border-glass bg-glass text-xs font-semibold text-foreground-secondary ring-2 ring-background backdrop-blur-[20px]",
			children: ["+", d]
		})]
	});
}
//#endregion
export { o as Avatar, c as AvatarFallback, d as AvatarGroup, s as AvatarImage, a as avatarVariants };

//# sourceMappingURL=avatar.js.map