import { h as e } from "./chunk.BlbRoQQ3.js";
import { X as t } from "./use-page-data.Cb2SuuwJ.js";
import "./chunk-LSPN22SI.D75E3zS-.js";
import { c as n } from "./twind.BiM9xcCd.js";
import { b as r } from "./jsx-runtime.DF4K5VCp.js";
import "./chroma-js.Dcir27CH.js";
import "./color-system.Dp99zR0T.js";
import "./react.BZZIbN3T.js";
import "./iconBase.C7m0emOO.js";
import "./schema-resolver.p7B_pu36.js";
import { l as i } from "./md.Dru5DXQh.js";
import { b as a } from "./use-brick-style.DDPl-_C1.js";
import "./use-brick-manifest.Iv9SG-7-.js";
import { b as o } from "./TextContent.B1cB93wj.js";
import { b as s } from "./BrickRoot.DbISziyH.js";
import { useState as c } from "react";
var l = /* @__PURE__ */ e(r());
function u({ brick: e, editable: r }) {
	let u = a(e), { props: d } = e, f = Array.isArray(d.items) ? d.items : [], { rounding: p,...m } = u, [h, g] = c(f.findIndex((e) => !!e.defaultOpen) || null), [_, v] = c(() => f.map((e) => !!e.defaultOpen));
	return /* @__PURE__ */ (0, l.jsxs)(s, {
		brick: e,
		editable: r,
		manifest: t,
		className: n("flex flex-col overflow-hidden relative", Object.values(m)),
		children: [r && f.length === 0 && /* @__PURE__ */ (0, l.jsx)("div", {
			className: "absolute top-0 left-0 right-0 bottom-0 flex items-center justify-center text-center p-8",
			children: /* @__PURE__ */ (0, l.jsx)("div", {
				className: "text-base",
				children: "Add content to this accordion in the panel"
			})
		}), f.map((t, a) => {
			let s = d.restrictOneOpen ? h === a : _[a] || t.defaultOpen;
			return /* @__PURE__ */ (0, l.jsxs)("div", {
				className: n("flex flex-col border", p, "overflow-hidden"),
				children: [/* @__PURE__ */ (0, l.jsxs)("button", {
					type: "button",
					"aria-expanded": s,
					onClick: () => {
						d.restrictOneOpen ? g((e) => e === a ? null : a) : v((e) => {
							let t = [...e];
							return t[a] = !t[a], t;
						});
					},
					className: n("flex flex-grow shrink-0 items-center p-3 gap-1 justify-between w-full", "font-semibold cursor-pointer select-none text-left text-[110%] ", s && "rounded-b-none border-b"),
					children: [/* @__PURE__ */ (0, l.jsx)("div", {
						className: n("flex flex-grow shrink-0 flex-row items-center gap-1"),
						children: /* @__PURE__ */ (0, l.jsx)(o, {
							propPath: `items.${a}.title`,
							className: n("w-full", r && "cursor-text"),
							brickId: e.id,
							content: t.title,
							rawContent: t.title,
							editable: r,
							inline: !0
						})
					}), /* @__PURE__ */ (0, l.jsx)(i, { className: n("transition-transform", s && "rotate-90") })]
				}), /* @__PURE__ */ (0, l.jsx)("div", {
					className: n("transition-all duration-900 ease-in-out p-3 flex-1", !s && "hidden"),
					children: /* @__PURE__ */ (0, l.jsx)(o, {
						propPath: `items.${a}.content`,
						className: n("w-full", r && "cursor-text"),
						brickId: e.id,
						content: t.content,
						rawContent: t.content,
						editable: r
					})
				})]
			}, a);
		})]
	});
}
export { u as default };

//# sourceMappingURL=accordion.BXWN1TwB.js.map