import { hasRenderableNode } from "../_utils/vue.js";
import { Transition, computed, createVNode, defineComponent } from "vue";
import { RightOutlined } from "@antdv-next/icons";
//#region components/conversations/GroupTitle.tsx
var GroupTitle = /* @__PURE__ */ defineComponent({
	name: "XConversationsGroupTitle",
	props: {
		prefixCls: {
			type: String,
			default: "antd-conversations"
		},
		groupInfo: {
			type: Object,
			required: true
		},
		groupLabelRender: {
			type: [
				String,
				Number,
				Object,
				Array,
				Function
			],
			default: void 0
		},
		groupLabelRenderSlot: {
			type: Function,
			default: void 0
		},
		classes: {
			type: [
				String,
				Array,
				Object
			],
			default: void 0
		},
		enableCollapse: {
			type: Boolean,
			default: true
		},
		expandedKeys: {
			type: Array,
			default: () => []
		},
		onItemExpand: {
			type: Function,
			default: void 0
		},
		collapseTransition: {
			type: Object,
			default: void 0
		}
	},
	setup(props, { slots }) {
		const mergeCollapsible = computed(() => {
			return props.groupInfo.collapsible && props.enableCollapse;
		});
		const groupOpen = computed(() => {
			if (!mergeCollapsible.value) return true;
			return props.expandedKeys?.includes(props.groupInfo.name);
		});
		const labelNode = computed(() => {
			const { label, name } = props.groupInfo;
			const originNode = typeof label === "function" ? label(name, { groupInfo: props.groupInfo }) : label || name;
			const renderInfo = {
				group: name,
				groupInfo: props.groupInfo,
				originNode
			};
			if (props.groupLabelRenderSlot) return props.groupLabelRenderSlot(renderInfo);
			if (props.groupLabelRender !== void 0) return typeof props.groupLabelRender === "function" ? props.groupLabelRender(name, renderInfo) : props.groupLabelRender;
			return originNode;
		});
		return () => createVNode("li", { "class": props.classes }, [createVNode("div", {
			"class": [`${props.prefixCls}-group-title`, { [`${props.prefixCls}-group-title-collapsible`]: mergeCollapsible.value }],
			"onClick": () => {
				if (mergeCollapsible.value) props.onItemExpand?.(props.groupInfo.name);
			}
		}, [hasRenderableNode(labelNode.value) && createVNode("div", { "class": `${props.prefixCls}-group-label` }, [labelNode.value]), mergeCollapsible.value && createVNode("div", { "class": [`${props.prefixCls}-group-collapse-trigger`, `${props.prefixCls}-group-collapse-trigger-${groupOpen.value ? "open" : "close"}`] }, [createVNode(RightOutlined, null, null)])]), createVNode(Transition, props.collapseTransition ?? {}, { default: () => [mergeCollapsible.value ? groupOpen.value ? createVNode("div", null, [slots.default?.()]) : null : createVNode("div", null, [slots.default?.()])] })]);
	}
});
//#endregion
export { GroupTitle as default };
