import { getSize } from "../utils.js";
import { computed, createVNode, defineComponent } from "vue";
//#region components/file-card/components/File.tsx
var File = /* @__PURE__ */ defineComponent({
	name: "FileCardFile",
	props: {
		styles: {
			type: Object,
			default: () => ({})
		},
		classes: {
			type: Object,
			default: () => ({})
		},
		prefixCls: {
			type: String,
			default: "antd-file-card"
		},
		name: {
			type: String,
			default: ""
		},
		namePrefix: {
			type: String,
			default: ""
		},
		ext: {
			type: String,
			default: ""
		},
		size: {
			type: String,
			default: "default"
		},
		byte: {
			type: Number,
			default: void 0
		},
		src: {
			type: String,
			default: void 0
		},
		type: {
			type: String,
			default: void 0
		},
		description: {
			type: [
				String,
				Number,
				Object,
				Array,
				Function,
				Boolean
			],
			default: void 0
		},
		icon: {
			type: [
				String,
				Number,
				Object,
				Array,
				Function
			],
			default: void 0
		},
		iconColor: {
			type: String,
			default: void 0
		},
		onClick: {
			type: Function,
			default: void 0
		},
		mask: {
			type: [
				String,
				Number,
				Object,
				Array,
				Function,
				Boolean
			],
			default: void 0
		},
		descriptionRenderSlot: {
			type: Function,
			default: void 0
		},
		maskRenderSlot: {
			type: Function,
			default: void 0
		},
		iconSlot: {
			type: Function,
			default: void 0
		}
	},
	setup(props) {
		const compCls = computed(() => `${props.prefixCls}-file`);
		const getCardInfo = () => {
			return {
				size: typeof props.byte === "number" ? getSize(props.byte) : "",
				icon: props.icon,
				name: props.name,
				namePrefix: props.namePrefix,
				nameSuffix: props.ext,
				src: props.src,
				type: props.type
			};
		};
		const descNode = computed(() => {
			const fallback = typeof props.byte === "number" ? getSize(props.byte) : "";
			if (typeof props.description === "function") return props.description(getCardInfo());
			if (props.description === false) return null;
			return props.description ?? fallback;
		});
		const maskNode = computed(() => {
			if (typeof props.mask === "function") return props.mask(getCardInfo());
			if (props.mask === false) return null;
			return props.mask;
		});
		const iconNode = computed(() => props.icon);
		const renderWithSlot = (slotRender, originNode) => {
			if (slotRender) return slotRender({
				info: getCardInfo(),
				originNode
			});
			return originNode;
		};
		const hasDescription = computed(() => !!props.descriptionRenderSlot || descNode.value !== null && descNode.value !== void 0);
		const hasMask = computed(() => !!props.maskRenderSlot || maskNode.value !== null && maskNode.value !== void 0);
		const handleClick = (event) => {
			if (!props.onClick) return;
			props.onClick(getCardInfo(), event);
		};
		return () => createVNode("div", {
			"class": [
				compCls.value,
				props.classes.file,
				{
					[`${compCls.value}-pointer`]: !!props.onClick,
					[`${compCls.value}-small`]: props.size === "small"
				}
			],
			"style": props.styles.file,
			"onClick": handleClick
		}, [
			createVNode("div", {
				"class": [`${compCls.value}-icon`, props.classes.icon],
				"style": {
					color: props.iconColor,
					...props.styles.icon
				}
			}, [renderWithSlot(props.iconSlot, iconNode.value)]),
			createVNode("div", { "class": `${compCls.value}-content` }, [createVNode("div", {
				"class": [`${compCls.value}-name`, props.classes.name],
				"style": props.styles.name
			}, [createVNode("span", { "class": `${compCls.value}-name-prefix` }, [props.namePrefix]), createVNode("span", { "class": `${compCls.value}-name-suffix` }, [props.ext])]), hasDescription.value ? createVNode("div", {
				"class": [`${compCls.value}-description`, props.classes.description],
				"style": props.styles.description
			}, [renderWithSlot(props.descriptionRenderSlot, descNode.value)]) : null]),
			hasMask.value ? createVNode("div", { "class": `${compCls.value}-mask` }, [createVNode("div", { "class": `${compCls.value}-mask-info` }, [renderWithSlot(props.maskRenderSlot, maskNode.value)])]) : null
		]);
	}
});
//#endregion
export { File as default };
