"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { o as t, r as n, t as r, u as i } from "./useRenderElement-CmuWsiNa.js";
import { t as a } from "./useStableCallback-CqEVb76s.js";
import { l as o, t as s, x as c } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as l } from "./useBaseUiId-DOm5ACje.js";
import { a as u, n as d, t as f } from "./useOpenChangeComplete-DjMFUwhi.js";
import { f as p } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { t as m } from "./useButton-AXffhTAZ.js";
import { C as h, D as g, E as _, L as v, O as y, P as b, T as x, V as S, a as C, c as w, d as T, f as E, i as D, j as O, l as k, m as A, o as j, p as M, r as N, s as P, u as F, v as I, w as L, z as R } from "./popupStateMapping-PdIQcWEz.js";
import { o as z } from "./composite-BlDfbDkL.js";
import { cn as B } from "./lib/utils.js";
import { t as V } from "./useTimeout-B1x6NSZb.js";
import { a as H, i as ee, n as te, r as U } from "./useOpenInteractionType-D-ymktmc.js";
import { n as ne, r as W, t as re } from "./safePolygon-CscU2iWL.js";
import { i as ie, n as G, r as K, t as ae } from "./usePositioner-D65mUNMo.js";
import { n as oe, r as se, t as ce } from "./store-Bdrhndby.js";
import { t as le } from "./inertValue-C36grUTu.js";
import { t as ue } from "./useTriggerFocusGuards-D1QlFlDK.js";
import { n as de, t as fe } from "./ToolbarRootContext-Dubw_915.js";
import * as q from "react";
import { jsx as J, jsxs as Y } from "react/jsx-runtime";
import * as pe from "react-dom";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/root/PopoverRootContext.js
var X = /*#__PURE__*/ q.createContext(void 0);
process.env.NODE_ENV !== "production" && (X.displayName = "PopoverRootContext");
function Z(e) {
	let t = q.useContext(X);
	if (t === void 0 && !e) throw Error(process.env.NODE_ENV === "production" ? i(47) : "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>.");
	return t;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/store/PopoverStore.js
function me() {
	return {
		...ce(),
		disabled: !1,
		modal: !1,
		focusManagerModal: !1,
		instantType: void 0,
		openMethod: null,
		openChangeReason: null,
		titleElementId: void 0,
		descriptionElementId: void 0,
		stickIfOpen: !0,
		nested: !1,
		openOnHover: !1,
		closeDelay: 0,
		hasViewport: !1
	};
}
var he = {
	...se,
	disabled: h((e) => e.disabled),
	instantType: h((e) => e.instantType),
	openMethod: h((e) => e.openMethod),
	openChangeReason: h((e) => e.openChangeReason),
	modal: h((e) => e.modal),
	focusManagerModal: h((e) => e.focusManagerModal),
	stickIfOpen: h((e) => e.stickIfOpen),
	titleElementId: h((e) => e.titleElementId),
	descriptionElementId: h((e) => e.descriptionElementId),
	openOnHover: h((e) => e.openOnHover),
	closeDelay: h((e) => e.closeDelay),
	hasViewport: h((e) => e.hasViewport)
}, ge = class e extends I {
	constructor(e, t, n = !1) {
		let r = {
			...me(),
			...e
		}, i = new j();
		r.open && e?.mounted === void 0 && (r.mounted = !0), r.floatingRootContext = oe(i, t, n), super(r, {
			popupRef: /*#__PURE__*/ q.createRef(),
			backdropRef: /*#__PURE__*/ q.createRef(),
			internalBackdropRef: /*#__PURE__*/ q.createRef(),
			onOpenChange: void 0,
			onOpenChangeComplete: void 0,
			triggerFocusTargetRef: /*#__PURE__*/ q.createRef(),
			beforeContentFocusGuardRef: /*#__PURE__*/ q.createRef(),
			stickIfOpenTimeout: new V(),
			triggerElements: i
		}, he);
	}
	setOpen = (e, t) => {
		let n = t.reason === c, r = t.reason === "trigger-press" && t.event.detail === 0, i = !e && (t.reason === "escape-key" || t.reason == null);
		t.preventUnmountOnClose = () => {
			this.set("preventUnmountingOnClose", !0);
		};
		let a = this.select("activeTriggerId");
		if (!e && t.reason === "close-press" && t.trigger == null && a != null && (t.trigger = this.context.triggerElements.getById(a) ?? this.select("activeTriggerElement") ?? void 0), this.context.onOpenChange?.(e, t), t.isCanceled) return;
		this.state.floatingRootContext.dispatchOpenChange(e, t);
		let o = () => {
			let n = {
				open: e,
				openChangeReason: t.reason
			};
			w(n, e, t.trigger), this.update(n);
		};
		n ? (this.set("stickIfOpen", !0), this.context.stickIfOpenTimeout.start(500, () => {
			this.set("stickIfOpen", !1);
		}), pe.flushSync(o)) : o(), r || i ? this.set("instantType", r ? "click" : "dismiss") : t.reason === "focus-out" ? this.set("instantType", "focus") : this.set("instantType", void 0);
	};
	static useStore(t, n) {
		let { store: r, internalStore: i } = M(t, (t, r) => new e(n, t, r));
		return q.useEffect(() => i?.disposeEffect(), [i]), r;
	}
	disposeEffect = () => this.context.stickIfOpenTimeout.disposeEffect();
};
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/root/PopoverRoot.js
function _e({ props: e }) {
	let { children: t, open: n, defaultOpen: r = !1, onOpenChange: i, onOpenChangeComplete: a, modal: c = !1, handle: l, triggerId: u, defaultTriggerId: d = null } = e, f = ge.useStore(l?.store, {
		modal: c,
		open: r,
		openProp: n,
		activeTriggerId: d,
		triggerIdProp: u
	});
	S(() => {
		n === void 0 && f.state.open === !1 && r === !0 && f.update({
			open: !0,
			activeTriggerId: d
		});
	}), f.useControlledProp("openProp", n), f.useControlledProp("triggerIdProp", u);
	let p = f.useState("open"), m = f.useState("mounted"), h = f.useState("payload"), g = y() != null;
	f.useContextCallback("onOpenChange", i), f.useContextCallback("onOpenChangeComplete", a), E(f, p), k(f);
	let { forceUnmount: _ } = F(p, f, () => {
		f.update({
			stickIfOpen: !0,
			openChangeReason: null
		});
	});
	f.useSyncedValues({
		modal: c,
		nested: g
	}), q.useEffect(() => {
		p || f.context.stickIfOpenTimeout.clear();
	}, [f, p]);
	let v = q.useCallback(() => {
		f.setOpen(!1, s(o));
	}, [f]);
	q.useImperativeHandle(e.actionsRef, () => ({
		unmount: _,
		close: v
	}), [_, v]);
	let b = p || m, x = q.useMemo(() => ({ store: f }), [f]);
	return /*#__PURE__*/ Y(X.Provider, {
		value: x,
		children: [b && /*#__PURE__*/ J(ye, {
			store: f,
			modal: c
		}), typeof t == "function" ? t({ payload: h }) : t]
	});
}
function ve(e) {
	return Z(!0) ? /*#__PURE__*/ J(_e, { props: e }) : /*#__PURE__*/ J(_, { children: /*#__PURE__*/ J(_e, { props: e }) });
}
function ye({ store: e, modal: r }) {
	let i = L(e.useState("floatingRootContext"), { outsidePressEvent: {
		mouse: r === "trap-focus" ? "sloppy" : "intentional",
		touch: "sloppy"
	} });
	return T(e, {
		activeTriggerProps: i.reference ?? t,
		inactiveTriggerProps: i.trigger ?? t,
		popupProps: q.useMemo(() => n(P, i.floating), [i.floating])
	}), null;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/trigger/PopoverTrigger.js
var be = /*#__PURE__*/ q.forwardRef(function(e, t) {
	let { render: n, className: a, style: o, disabled: s = !1, nativeButton: c = !0, handle: u, payload: d, openOnHover: f = !1, delay: p = 300, closeDelay: h = 0, id: g, ..._ } = e, v = Z(!0), y = u?.store ?? v?.store;
	if (!y) throw Error(process.env.NODE_ENV === "production" ? i(74) : "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle.");
	let x = l(g), S = y.useState("isTriggerActive", x), w = y.useState("floatingRootContext"), T = y.useState("isOpenedByTrigger", x), E = y.useState("triggerPopupId", x), O = q.useRef(null), { registerTrigger: k, isMountedByThisTrigger: j } = A(x, O, y, {
		payload: d,
		disabled: s,
		openOnHover: f,
		closeDelay: h
	}), M = y.useState("openChangeReason"), N = y.useState("stickIfOpen"), P = y.useState("openMethod"), F = y.useState("focusManagerModal"), I = ne(w, {
		enabled: w != null && f && (P !== "touch" || M !== "trigger-press"),
		mouseOnly: !0,
		move: !1,
		handleClose: re(),
		restMs: p,
		delay: { close: h },
		triggerElementRef: O,
		isActiveTrigger: S,
		isClosing: () => y.select("transitionStatus") === "ending"
	}), L = ee(w, {
		enabled: w != null,
		stickIfOpen: N
	}), z = te(() => y.select("open"), (e) => {
		y.set("openMethod", e);
	}), B = y.useState("triggerProps", j), { getButtonProps: V, buttonRef: H } = m({
		disabled: s,
		native: c
	}), U = { open(e) {
		return e && M === "trigger-press" ? D.open(e) : C.open(e);
	} }, { preFocusGuardRef: W, handlePreFocusGuardFocus: ie, handleFocusTargetFocus: G } = ue(y, O), K = r("button", e, {
		state: {
			disabled: s,
			open: T
		},
		ref: [
			H,
			t,
			k,
			O
		],
		props: [
			L.reference,
			I,
			B,
			z,
			{
				[b]: "",
				id: x,
				"aria-haspopup": "dialog",
				"aria-expanded": T,
				"aria-controls": E
			},
			_,
			V
		],
		stateAttributesMapping: U
	});
	return j && !F ? /*#__PURE__*/ Y(q.Fragment, { children: [
		/*#__PURE__*/ J(R, {
			ref: W,
			onFocus: ie
		}),
		/*#__PURE__*/ J(q.Fragment, { children: K }, x),
		/*#__PURE__*/ J(R, {
			ref: y.context.triggerFocusTargetRef,
			onFocus: G
		})
	] }) : /*#__PURE__*/ J(q.Fragment, { children: K }, x);
});
process.env.NODE_ENV !== "production" && (be.displayName = "PopoverTrigger");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/portal/PopoverPortalContext.js
var Q = /*#__PURE__*/ q.createContext(void 0);
process.env.NODE_ENV !== "production" && (Q.displayName = "PopoverPortalContext");
function xe() {
	let e = q.useContext(Q);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? i(45) : "Base UI: <Popover.Portal> is missing.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/portal/PopoverPortal.js
var Se = /*#__PURE__*/ q.forwardRef(function(e, t) {
	let { keepMounted: n = !1, ...r } = e, { store: i } = Z();
	return i.useState("mounted") || n ? /*#__PURE__*/ J(Q.Provider, {
		value: n,
		children: /*#__PURE__*/ J(O, {
			ref: t,
			...r
		})
	}) : null;
});
process.env.NODE_ENV !== "production" && (Se.displayName = "PopoverPortal");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/positioner/PopoverPositionerContext.js
var $ = /*#__PURE__*/ q.createContext(void 0);
process.env.NODE_ENV !== "production" && ($.displayName = "PopoverPositionerContext");
function Ce() {
	let e = q.useContext($);
	if (!e) throw Error(process.env.NODE_ENV === "production" ? i(46) : "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/positioner/PopoverPositioner.js
var we = /*#__PURE__*/ q.forwardRef(function(t, n) {
	let { render: r, className: i, style: a, anchor: o, positionMethod: s = "absolute", side: c = "bottom", align: l = "center", sideOffset: u = 0, alignOffset: f = 0, collisionBoundary: p = "clipping-ancestors", collisionPadding: m = 5, arrowPadding: h = 5, sticky: _ = !1, disableAnchorTracking: y = !1, collisionAvoidance: b = v, ...S } = t, { store: C } = Z(), w = xe(), T = g(), E = C.useState("floatingRootContext"), D = C.useState("mounted"), O = C.useState("open"), k = C.useState("openChangeReason"), A = C.useState("activeTriggerElement"), j = C.useState("modal"), M = C.useState("openMethod"), N = C.useState("positionerElement"), P = C.useState("instantType"), F = C.useState("transitionStatus"), I = C.useState("hasViewport"), L = q.useRef(null), R = d(N, !1, !1), z = K({
		anchor: o,
		floatingRootContext: E,
		positionMethod: s,
		mounted: D,
		side: c,
		sideOffset: u,
		align: l,
		alignOffset: f,
		arrowPadding: h,
		collisionBoundary: p,
		collisionPadding: m,
		sticky: _,
		disableAnchorTracking: y,
		keepMounted: w,
		nodeId: T,
		collisionAvoidance: b,
		adaptiveOrigin: I ? ie : void 0
	}), B = E.useState("domReferenceElement");
	e(() => {
		let e = B, t = L.current;
		if (e && (L.current = e), t && e && e !== t) {
			C.set("instantType", void 0);
			let e = new AbortController();
			return R(() => {
				C.set("instantType", "trigger-change");
			}, e.signal), () => {
				e.abort();
			};
		}
	}, [
		B,
		R,
		C
	]), de(O && j === !0 && k !== "trigger-hover", M === "touch", N, A);
	let V = q.useCallback((e) => {
		C.set("positionerElement", e);
	}, [C]), H = ae(t, {
		open: O,
		side: z.side,
		align: z.align,
		anchorHidden: z.anchorHidden,
		instant: P
	}, {
		styles: z.positionerStyles,
		transitionStatus: F,
		props: S,
		refs: [n, V],
		hidden: !D,
		inert: !O
	});
	return /*#__PURE__*/ Y($.Provider, {
		value: z,
		children: [D && j === !0 && k !== "trigger-hover" && /*#__PURE__*/ J(U, {
			ref: C.context.internalBackdropRef,
			inert: le(!O),
			cutout: A
		}), /*#__PURE__*/ J(x, {
			id: T,
			children: H
		})]
	});
});
process.env.NODE_ENV !== "production" && (we.displayName = "PopoverPositioner");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/utils/closePart.js
var Te = /*#__PURE__*/ q.createContext(void 0);
process.env.NODE_ENV !== "production" && (Te.displayName = "ClosePartContext");
function Ee() {
	let [e, t] = q.useState(0), n = a(() => (t((e) => e + 1), () => {
		t((e) => Math.max(0, e - 1));
	}));
	return {
		context: q.useMemo(() => ({ register: n }), [n]),
		hasClosePart: e > 0
	};
}
function De(e) {
	let { value: t, children: n } = e;
	return /*#__PURE__*/ J(Te.Provider, {
		value: t,
		children: n
	});
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/popup/PopoverPopup.js
var Oe = {
	...N,
	...u
}, ke = /*#__PURE__*/ q.forwardRef(function(e, t) {
	let { render: n, className: i, style: a, initialFocus: o, finalFocus: s, ...c } = e, { store: l } = Z(), u = Ce(), d = fe(!0) != null, { context: m, hasClosePart: h } = Ee(), g = l.useState("open"), _ = l.useState("openMethod"), v = l.useState("instantType"), y = l.useState("transitionStatus"), b = l.useState("popupProps"), x = l.useState("titleElementId"), S = l.useState("descriptionElementId"), C = l.useState("modal"), w = l.useState("mounted"), T = l.useState("openChangeReason"), E = l.useState("activeTriggerElement"), D = l.useState("floatingRootContext"), O = D.useState("floatingId"), k = l.useState("disabled"), A = l.useState("openOnHover"), j = l.useState("closeDelay"), M = c.id ?? O;
	f({
		open: g,
		ref: l.context.popupRef,
		onComplete() {
			g && l.context.onOpenChangeComplete?.(!0);
		}
	}), W(D, {
		enabled: A && !k,
		closeDelay: j
	});
	function N(e) {
		return e === "touch" ? l.context.popupRef.current : !0;
	}
	let F = o === void 0 ? N : o, I = C !== !1 && h;
	l.useSyncedValue("focusManagerModal", I);
	let L = q.useCallback((e) => {
		l.set("popupElement", e);
	}, [l]), R = r("div", e, {
		state: {
			open: g,
			side: u.side,
			align: u.align,
			instant: v,
			transitionStatus: y
		},
		ref: [
			t,
			l.context.popupRef,
			L
		],
		props: [
			b,
			{
				id: M,
				role: "dialog",
				...P,
				"aria-labelledby": x,
				"aria-describedby": S,
				onKeyDown(e) {
					d && z.has(e.key) && e.stopPropagation();
				}
			},
			G(y),
			c
		],
		stateAttributesMapping: Oe
	});
	return /*#__PURE__*/ J(H, {
		context: D,
		openInteractionType: _,
		modal: I,
		disabled: !w || T === "trigger-hover",
		initialFocus: F,
		returnFocus: s,
		restoreFocus: "popup",
		previousFocusableElement: p(E) ? E : void 0,
		nextFocusableElement: l.context.triggerFocusTargetRef,
		beforeContentFocusGuardRef: l.context.beforeContentFocusGuardRef,
		children: /*#__PURE__*/ J(De, {
			value: m,
			children: R
		})
	});
});
process.env.NODE_ENV !== "production" && (ke.displayName = "PopoverPopup");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/title/PopoverTitle.js
var Ae = /*#__PURE__*/ q.forwardRef(function(e, t) {
	let { render: n, className: i, style: a, ...o } = e, { store: s } = Z(), c = l(o.id);
	return s.useSyncedValueWithCleanup("titleElementId", c), r("h2", e, {
		ref: t,
		props: [{ id: c }, o]
	});
});
process.env.NODE_ENV !== "production" && (Ae.displayName = "PopoverTitle");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/popover/description/PopoverDescription.js
var je = /*#__PURE__*/ q.forwardRef(function(e, t) {
	let { render: n, className: i, style: a, ...o } = e, { store: s } = Z(), c = l(o.id);
	return s.useSyncedValueWithCleanup("descriptionElementId", c), r("p", e, {
		ref: t,
		props: [{ id: c }, o]
	});
});
process.env.NODE_ENV !== "production" && (je.displayName = "PopoverDescription");
//#endregion
//#region lib/components/ui/atoms/popover.tsx
function Me({ ...e }) {
	return /* @__PURE__ */ J(ve, {
		"data-slot": "popover",
		...e
	});
}
function Ne({ ...e }) {
	return /* @__PURE__ */ J(be, {
		"data-slot": "popover-trigger",
		...e
	});
}
function Pe({ className: e, align: t = "center", alignOffset: n = 0, side: r = "bottom", sideOffset: i = 4, ...a }) {
	return /* @__PURE__ */ J(Se, { children: /* @__PURE__ */ J(we, {
		align: t,
		alignOffset: n,
		className: "isolate z-50",
		side: r,
		sideOffset: i,
		children: /* @__PURE__ */ J(ke, {
			className: B("data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:fade-in-0 data-open:zoom-in-95 data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-popover-foreground text-sm shadow-md outline-hidden ring-1 ring-foreground/10 duration-100 data-closed:animate-out data-open:animate-in", e),
			"data-slot": "popover-content",
			...a
		})
	}) });
}
function Fe({ className: e, ...t }) {
	return /* @__PURE__ */ J("div", {
		className: B("flex flex-col gap-1 text-sm", e),
		"data-slot": "popover-header",
		...t
	});
}
function Ie({ className: e, ...t }) {
	return /* @__PURE__ */ J(Ae, {
		className: B("font-medium", e),
		"data-slot": "popover-title",
		...t
	});
}
function Le({ className: e, ...t }) {
	return /* @__PURE__ */ J(je, {
		className: B("text-muted-foreground", e),
		"data-slot": "popover-description",
		...t
	});
}
//#endregion
export { Ie as a, Fe as i, Pe as n, Ne as o, Le as r, Me as t };
