"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { s as t, t as n, u as r } from "./useRenderElement-CmuWsiNa.js";
import { t as i } from "./useStableCallback-CqEVb76s.js";
import { a, o, t as s } from "./useOpenChangeComplete-DjMFUwhi.js";
import { cn as c } from "./lib/utils.js";
import { n as l } from "./useTimeout-B1x6NSZb.js";
import * as u from "react";
import { jsx as d } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/avatar/root/AvatarRootContext.js
var f = /*#__PURE__*/ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (f.displayName = "AvatarRootContext");
function p() {
	let e = u.useContext(f);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? r(13) : "Base UI: AvatarRootContext is missing. Avatar parts must be placed within <Avatar.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/avatar/root/stateAttributesMapping.js
var m = { imageLoadingStatus: () => null }, h = /*#__PURE__*/ u.forwardRef(function(e, t) {
	let { className: r, render: i, style: a, ...o } = e, [s, c] = u.useState("idle"), l = { imageLoadingStatus: s }, p = u.useMemo(() => ({
		imageLoadingStatus: s,
		setImageLoadingStatus: c
	}), [s, c]), h = n("span", e, {
		state: l,
		ref: t,
		props: o,
		stateAttributesMapping: m
	});
	return /*#__PURE__*/ d(f.Provider, {
		value: p,
		children: h
	});
});
process.env.NODE_ENV !== "production" && (h.displayName = "AvatarRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/avatar/image/useImageLoadingStatus.js
function g(n, { referrerPolicy: r, crossOrigin: i }) {
	let [a, o] = u.useState("idle");
	return e(() => {
		if (!n) return o("error"), t;
		let e = !0, a = new window.Image(), s = (t) => () => {
			e && o(t);
		};
		return o("loading"), a.onload = s("loaded"), a.onerror = s("error"), r && (a.referrerPolicy = r), a.crossOrigin = i ?? null, a.src = n, a.complete && o(a.naturalWidth > 0 ? "loaded" : "error"), () => {
			e = !1;
		};
	}, [
		n,
		i,
		r
	]), a;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/avatar/image/AvatarImage.js
var _ = {
	...m,
	...a
}, v = /*#__PURE__*/ u.forwardRef(function(t, r) {
	let { className: a, render: c, onLoadingStatusChange: l, referrerPolicy: d, crossOrigin: f, style: m, ...h } = t, v = p(), y = g(t.src, {
		referrerPolicy: d,
		crossOrigin: f
	}), b = y === "loaded", { mounted: x, transitionStatus: S, setMounted: C } = o(b), w = u.useRef(null), T = i((e) => {
		l?.(e), v.setImageLoadingStatus(e);
	});
	e(() => {
		y !== "idle" && T(y);
	}, [y, T]), s({
		open: b,
		ref: w,
		onComplete() {
			b || C(!1);
		}
	});
	let E = n("img", t, {
		state: {
			imageLoadingStatus: y,
			transitionStatus: S
		},
		ref: [r, w],
		props: h,
		stateAttributesMapping: _,
		enabled: x
	});
	return x ? E : null;
});
process.env.NODE_ENV !== "production" && (v.displayName = "AvatarImage");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/avatar/fallback/AvatarFallback.js
var y = /*#__PURE__*/ u.forwardRef(function(e, t) {
	let { className: r, render: i, delay: a, style: o, ...s } = e, { imageLoadingStatus: c } = p(), [d, f] = u.useState(a === void 0), h = l();
	return u.useEffect(() => (a !== void 0 && h.start(a, () => f(!0)), h.clear), [h, a]), n("span", e, {
		state: { imageLoadingStatus: c },
		ref: t,
		props: s,
		stateAttributesMapping: m,
		enabled: c !== "loaded" && d
	});
});
process.env.NODE_ENV !== "production" && (y.displayName = "AvatarFallback");
//#endregion
//#region lib/components/ui/atoms/avatar.tsx
function b({ className: e, size: t = "default", ...n }) {
	return /* @__PURE__ */ d(h, {
		className: c("group/avatar relative flex size-8 shrink-0 select-none rounded-full after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten", e),
		"data-size": t,
		"data-slot": "avatar",
		...n
	});
}
function x({ className: e, ...t }) {
	return /* @__PURE__ */ d(v, {
		className: c("aspect-square size-full rounded-full object-cover", e),
		"data-slot": "avatar-image",
		...t
	});
}
function S({ className: e, ...t }) {
	return /* @__PURE__ */ d(y, {
		className: c("flex size-full items-center justify-center rounded-full bg-muted text-muted-foreground text-sm group-data-[size=sm]/avatar:text-xs", e),
		"data-slot": "avatar-fallback",
		...t
	});
}
function C({ className: e, ...t }) {
	return /* @__PURE__ */ d("span", {
		className: c("absolute right-0 bottom-0 z-10 inline-flex select-none items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background", "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden", "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", e),
		"data-slot": "avatar-badge",
		...t
	});
}
function w({ className: e, ...t }) {
	return /* @__PURE__ */ d("div", {
		className: c("group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background", e),
		"data-slot": "avatar-group",
		...t
	});
}
function T({ className: e, ...t }) {
	return /* @__PURE__ */ d("div", {
		className: c("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground text-sm ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", e),
		"data-slot": "avatar-group-count",
		...t
	});
}
//#endregion
export { T as a, w as i, C as n, x as o, S as r, b as t };
