const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/pro/Selector/components/Card/index.tsx
const stopPropagation = (e) => {
	e.stopPropagation();
};
const Card = ({ variant = "outlined", layout = "horizontal", actions, actionsPosition = "right", corner, children, selected = false, disabled = false, hoverable = false, onClick, styles, selectedType = "outlined", className, style }) => {
	const styleProps = (0, react.useMemo)(() => ({
		selected,
		disabled,
		hoverable,
		variant,
		layout
	}), [
		selected,
		disabled,
		hoverable,
		variant,
		layout
	]);
	const containerStyle = (0, react.useMemo)(() => {
		if (!(styles === null || styles === void 0 ? void 0 : styles.container)) return style;
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, typeof styles.container === "function" ? styles.container(styleProps) : styles.container), style);
	}, [
		styles === null || styles === void 0 ? void 0 : styles.container,
		style,
		styleProps
	]);
	const contentStyle = (0, react.useMemo)(() => {
		if (!(styles === null || styles === void 0 ? void 0 : styles.content)) return void 0;
		return typeof styles.content === "function" ? styles.content(styleProps) : styles.content;
	}, [styles === null || styles === void 0 ? void 0 : styles.content, styleProps]);
	const actionsStyle = (0, react.useMemo)(() => {
		if (!(styles === null || styles === void 0 ? void 0 : styles.actions)) return void 0;
		return typeof styles.actions === "function" ? styles.actions(styleProps) : styles.actions;
	}, [styles === null || styles === void 0 ? void 0 : styles.actions, styleProps]);
	const cornerStyle = (0, react.useMemo)(() => {
		if (!(styles === null || styles === void 0 ? void 0 : styles.corner)) return void 0;
		return typeof styles.corner === "function" ? styles.corner(styleProps) : styles.corner;
	}, [styles === null || styles === void 0 ? void 0 : styles.corner, styleProps]);
	const renderActions = () => {
		if (!actions) return null;
		if ((Array.isArray(actions) ? actions.filter(Boolean) : [actions]).length === 0) return null;
		return /* @__PURE__ */ react.default.createElement("ul", {
			className: "pisell-pro-card_actions",
			style: actionsStyle
		}, actions.map((action, index) => /* @__PURE__ */ react.default.createElement("li", {
			key: index,
			className: "pisell-pro-card_actions-item",
			onClick: stopPropagation
		}, action)));
	};
	const renderCorner = () => {
		if (!corner || layout !== "vertical") return null;
		return /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-pro-card_corner",
			style: cornerStyle,
			onClick: stopPropagation
		}, corner);
	};
	const handleClick = (e) => {
		if (disabled) return;
		onClick === null || onClick === void 0 || onClick(e);
	};
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-pro-card", `pisell-pro-card-${variant}`, `pisell-pro-card-${layout}`, {
			"pisell-pro-card-selected": selected,
			[`pisell-pro-card-selected-${selectedType}`]: selected && selectedType !== "none",
			"pisell-pro-card-disabled": disabled,
			"pisell-pro-card-hoverable": hoverable && !disabled,
			"pisell-pro-card-clickable": onClick && !disabled,
			[`pisell-pro-card-actions-${actionsPosition}`]: layout === "horizontal" && actions
		}, className),
		style: containerStyle,
		onClick: handleClick
	}, layout === "horizontal" && actionsPosition === "left" && renderActions(), /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-pro-card_content",
		style: contentStyle
	}, children), (layout === "vertical" || actionsPosition === "right") && renderActions(), renderCorner());
};
//#endregion
exports.default = Card;
