import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, onMounted, openBlock, ref, renderSlot, toDisplayString, unref, useId, withCtx } from "vue";
import { ScalarIcon } from "@scalar/components";
import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue";
//#region src/components/ViewLayout/ViewLayoutCollapse.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["aria-labelledby"];
var _hoisted_2 = { class: "text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]" };
var _hoisted_3 = ["id"];
var _hoisted_4 = {
	key: 0,
	class: "sr-only"
};
var _hoisted_5 = {
	key: 0,
	class: "bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold"
};
var _hoisted_6 = { class: "sr-only" };
var _hoisted_7 = {
	key: 0,
	class: "ui-not-open:hidden flex items-center gap-2 pr-0.75"
};
//#endregion
//#region src/components/ViewLayout/ViewLayoutCollapse.vue
var ViewLayoutCollapse_default = /* @__PURE__ */ defineComponent({
	__name: "ViewLayoutCollapse",
	props: {
		defaultOpen: {
			type: Boolean,
			default: true
		},
		itemCount: { default: 0 },
		layout: { default: "client" }
	},
	emits: ["update:modelValue"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const id = useId();
		const isOpen = ref(__props.defaultOpen);
		const toggleOpen = () => {
			isOpen.value = !isOpen.value;
			emit("update:modelValue", isOpen.value);
		};
		onMounted(() => {
			emit("update:modelValue", isOpen.value);
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(Disclosure), {
				as: "div",
				class: normalizeClass(["group/collapse focus-within:text-c-1 text-c-2 last:ui-open:border-b-0 border-b", { "last-of-type:first-of-type:border-b-0": __props.layout === "reference" }]),
				defaultOpen: __props.defaultOpen,
				static: __props.layout === "reference" ? true : void 0,
				onClick: toggleOpen
			}, {
				default: withCtx(({ open }) => [createElementVNode("section", {
					"aria-labelledby": unref(id),
					class: "contents"
				}, [createElementVNode("div", { class: normalizeClass(["bg-b-2 flex items-center", __props.layout === "reference" && "rounded-t-xl border border-b-0"]) }, [createVNode(unref(DisclosureButton), {
					class: normalizeClass(["hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2", { "!pl-3": __props.layout === "reference" }]),
					disabled: __props.layout === "reference"
				}, {
					default: withCtx(() => [__props.layout !== "reference" ? (openBlock(), createBlock(unref(ScalarIcon), {
						key: 0,
						class: normalizeClass(["text-c-3 group-hover:text-c-1 ui-open:rotate-90 ui-not-open:rotate-0 rounded-px outline-offset-2 group-focus-visible:outline"]),
						icon: "ChevronRight",
						size: "md"
					})) : createCommentVNode("", true), createElementVNode("h2", _hoisted_2, [createElementVNode("span", {
						id: unref(id),
						class: "contents"
					}, [renderSlot(_ctx.$slots, "title", { open }), !open ? (openBlock(), createElementBlock("span", _hoisted_4, " (Collapsed) ")) : createCommentVNode("", true)], 8, _hoisted_3), !open && __props.itemCount ? (openBlock(), createElementBlock("span", _hoisted_5, [createTextVNode(toDisplayString(__props.itemCount) + " ", 1), createElementVNode("span", _hoisted_6, "Item" + toDisplayString(__props.itemCount === 1 ? "" : "s"), 1)])) : createCommentVNode("", true)])]),
					_: 2
				}, 1032, ["class", "disabled"]), _ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_7, [renderSlot(_ctx.$slots, "actions", { open })])) : createCommentVNode("", true)], 2), createVNode(unref(DisclosurePanel), mergeProps(_ctx.$attrs, { class: "diclosure-panel h-full max-h-fit rounded-b" }), {
					default: withCtx(() => [renderSlot(_ctx.$slots, "default", { open })]),
					_: 2
				}, 1040)], 8, _hoisted_1)]),
				_: 3
			}, 8, [
				"class",
				"defaultOpen",
				"static"
			]);
		};
	}
});
//#endregion
export { ViewLayoutCollapse_default as t };

//# sourceMappingURL=ViewLayoutCollapse-CiTb-Uml.js.map