import { t as e } from "../../utils-B7XIe3qq.js";
import { t } from "../../chevron-down-C_008JAH.js";
import { t as n } from "../../chevron-up-BY5jyuW2.js";
import { createContext as r, useContext as i, useState as a } from "react";
import { jsx as o } from "react/jsx-runtime";
//#region src/react/primitives/collapsible.tsx
var s = r(null);
function c() {
	let e = i(s);
	if (!e) throw Error("Collapsible components must be used within a Collapsible");
	return e;
}
function l({ children: e, defaultOpen: t = !0, open: n, onOpenChange: r, className: i }) {
	let [c, l] = a(t), u = n !== void 0, d = u ? n : c;
	return /* @__PURE__ */ o(s.Provider, {
		value: {
			isOpen: d,
			toggle: () => {
				u ? r?.(!n) : l((e) => !e);
			}
		},
		children: /* @__PURE__ */ o("div", {
			className: i,
			children: e
		})
	});
}
function u({ children: r, className: i, showIcon: a = !0 }) {
	let { isOpen: s, toggle: l } = c();
	return /* @__PURE__ */ o("button", {
		type: "button",
		onClick: l,
		className: e("text-foreground-muted hover:bg-accent hover:text-foreground-secondary rounded-lg p-1.5 transition-colors", i),
		"aria-expanded": s,
		children: r || a && o(s ? n : t, { className: "h-4 w-4" })
	});
}
function d({ children: t, className: n }) {
	let { isOpen: r } = c();
	return /* @__PURE__ */ o("div", {
		className: e("grid transition-[grid-template-rows] duration-300 ease-out", r ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
		children: /* @__PURE__ */ o("div", {
			className: e("overflow-hidden", n),
			children: t
		})
	});
}
//#endregion
export { l as Collapsible, d as CollapsibleContent, u as CollapsibleTrigger };

//# sourceMappingURL=collapsible.js.map