import { useBaseConfig, useComponentBaseConfig } from "../config-provider/context.js";
import { pureAttrs, useMergeSemantic, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
import { getSlotPropsFnRun, toPropsRefs } from "../_util/tools.js";
import useCSSVarCls_default from "../config-provider/hooks/useCSSVarCls.js";
import style_default, { PurePanelStyle } from "./style/index.js";
import isNonNullable_default from "../_util/isNonNullable.js";
import useClosable, { pickClosable } from "../_util/hooks/useClosable.js";
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps } from "vue";
import { clsx } from "@v-c/util";
import { CheckCircleFilled, CloseCircleFilled, CloseOutlined, ExclamationCircleFilled, InfoCircleFilled } from "@antdv-next/icons";
import { omit } from "es-toolkit";
import { Notification } from "@v-c/notification";

//#region src/notification/PurePanel.tsx
function getCloseIcon(prefixCls, closeIcon) {
	if (closeIcon === null || closeIcon === false) return null;
	return closeIcon || createVNode(CloseOutlined, { "class": `${prefixCls}-close-icon` }, null);
}
const TypeIcon = {
	success: CheckCircleFilled,
	info: InfoCircleFilled,
	error: CloseCircleFilled,
	warning: ExclamationCircleFilled
};
const typeToIcon = TypeIcon;
function resolveIconNode(icon, type) {
	if (icon) return icon;
	if (type && typeToIcon[type]) return createVNode(typeToIcon[type]);
	return null;
}
function getIconWrapperClassName(prefixCls, type) {
	return type ? `${prefixCls}-icon-${type}` : "";
}
const defaults = { role: "alert" };
const PureContent = /* @__PURE__ */ defineComponent((props) => {
	return () => {
		const { prefixCls, icon, type, title, description, actions, role = "alert", styles, classes: pureContentCls } = props;
		let iconNode;
		if (icon) iconNode = createVNode("span", {
			"class": clsx(`${prefixCls}-icon`, pureContentCls.icon),
			"style": styles.icon
		}, [icon]);
		else if (type) if (typeToIcon[type]) iconNode = createVNode(typeToIcon[type], {
			class: clsx(`${prefixCls}-icon`, pureContentCls.icon, `${prefixCls}-icon-${type}`),
			style: styles.icon
		});
		else iconNode = null;
		const hasTitle = isNonNullable_default(title) && title !== false && title !== "";
		return createVNode("div", {
			"class": clsx({ [`${prefixCls}-with-icon`]: iconNode }),
			"role": role
		}, [
			iconNode,
			hasTitle && createVNode("div", {
				"class": clsx(`${prefixCls}-title`, pureContentCls.title),
				"style": styles.title
			}, [title]),
			description && createVNode("div", {
				"class": clsx(`${prefixCls}-description`, pureContentCls.description),
				"style": styles.description
			}, [description]),
			actions && createVNode("div", {
				"class": clsx(`${prefixCls}-actions`, pureContentCls.actions),
				"style": styles.actions
			}, [actions])
		]);
	};
}, {
	props: /* @__PURE__ */ mergeDefaults({
		prefixCls: {
			type: String,
			required: true
		},
		icon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		title: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		description: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		actions: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		type: {
			type: String,
			required: false
		},
		role: {
			type: String,
			required: false
		},
		classes: {
			type: Object,
			required: true
		},
		styles: {
			type: Object,
			required: true
		}
	}, defaults),
	name: "NoticePureContent",
	inheritAttrs: false
});
const omitKeys = [
	"prefixCls",
	"icon",
	"type",
	"message",
	"title",
	"description",
	"btn",
	"actions",
	"closeIcon",
	"className",
	"style",
	"styles",
	"classNames",
	"closable"
];
/** @private Internal Component. Do not use in your production. */
const PurePanel = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
	const { classes: notificationClassNames, styles } = toPropsRefs(props, "classes", "styles");
	const { getPrefixCls, class: contextClassName, style: contextStyle, classes: contextClassNames, styles: contextStyles } = useComponentBaseConfig("notification", props);
	const { notification: notificationContext } = useBaseConfig("notification", props);
	const prefixCls = computed(() => props.prefixCls ?? getPrefixCls("notification"));
	const mergedProps = computed(() => props);
	const rootCls = useCSSVarCls_default(prefixCls);
	const [hashId, cssVarCls] = style_default(prefixCls, rootCls);
	const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClassNames, notificationClassNames), useToArr(contextStyles, styles), useToProps(mergedProps));
	const closeableInfo = useClosable(pickClosable(computed(() => props)), pickClosable(notificationContext), computed(() => {
		return {
			closable: true,
			closeIcon: createVNode(CloseOutlined, { "class": `${prefixCls.value}-close-icon` }, null),
			closeIconRender: (icon) => getCloseIcon(prefixCls.value, icon)
		};
	}));
	const rawClosable = computed(() => closeableInfo.value?.[0]);
	const mergedCloseIcon = computed(() => closeableInfo.value?.[1]);
	const ariaProps = computed(() => closeableInfo.value?.[3] || {});
	const mergedClosable = computed(() => {
		const { closable } = props;
		return rawClosable.value ? {
			onClose: closable && typeof closable === "object" ? closable?.onClose : void 0,
			closeIcon: mergedCloseIcon.value,
			...ariaProps.value
		} : false;
	});
	return () => {
		const noticePrefixCls = `${prefixCls.value}-notice`;
		const notificationClassName = attrs.class;
		const style = attrs.style;
		const restProps = omit(props, omitKeys);
		const actions = getSlotPropsFnRun(slots, props, "actions");
		const titleNode = getSlotPropsFnRun(slots, props, "title");
		const descriptionNode = getSlotPropsFnRun(slots, props, "description");
		const slotIcon = getSlotPropsFnRun(slots, props, "icon");
		const mergedNcs = mergedClassNames.value;
		const mergedNss = mergedStyles.value;
		const iconNode = resolveIconNode(slotIcon ?? props.icon, props.type);
		const iconWrapperClass = clsx(getIconWrapperClassName(noticePrefixCls, props.type), mergedNcs?.icon);
		return createVNode("div", {
			"class": clsx(`${noticePrefixCls}-pure-panel`, hashId.value, notificationClassName, cssVarCls.value, rootCls.value, mergedClassNames.value?.root),
			"style": mergedStyles.value.root
		}, [createVNode(PurePanelStyle, { "prefixCls": prefixCls.value }, null), createVNode(Notification, mergeProps({ "style": {
			...contextStyle.value,
			...style
		} }, pureAttrs(attrs), restProps, {
			"prefixCls": prefixCls.value,
			"duration": null,
			"closable": mergedClosable.value,
			"role": props.role,
			"class": clsx(notificationClassName, contextClassName.value, { [`${noticePrefixCls}-with-icon`]: !!iconNode }),
			"icon": iconNode,
			"title": titleNode,
			"description": descriptionNode,
			"actions": actions,
			"classNames": {
				icon: iconWrapperClass,
				title: mergedNcs?.title,
				description: mergedNcs?.description,
				actions: mergedNcs?.actions
			},
			"styles": {
				icon: mergedNss?.icon,
				title: mergedNss?.title,
				description: mergedNss?.description,
				actions: mergedNss?.actions
			}
		}), null)]);
	};
}, {
	props: {
		content: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		duration: {
			type: [
				Number,
				Boolean,
				null
			],
			required: false,
			default: void 0
		},
		showProgress: {
			type: Boolean,
			required: false,
			default: void 0
		},
		pauseOnHover: {
			type: Boolean,
			required: false,
			default: void 0
		},
		closable: {
			type: [Boolean, Object],
			required: false,
			default: void 0
		},
		prefixCls: {
			type: String,
			required: false
		},
		classes: {
			type: [Object, Function],
			required: false
		},
		styles: {
			type: [Object, Function],
			required: false
		},
		closeIcon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		props: {
			type: Object,
			required: false
		},
		onClose: { required: false },
		onClick: {
			type: Function,
			required: false
		},
		icon: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		title: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		description: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		actions: {
			type: [
				Function,
				String,
				Number,
				null,
				Object,
				Boolean
			],
			required: false,
			default: void 0
		},
		type: {
			type: String,
			required: false
		},
		role: {
			type: String,
			required: false
		}
	},
	name: "NoticePurePanel",
	inheritAttrs: false
});
var PurePanel_default = PurePanel;

//#endregion
export { PureContent, TypeIcon, PurePanel_default as default, getCloseIcon, getIconWrapperClassName, resolveIconNode };