const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../../../../classicLayout/index.js");
const require_index$1 = require("./components/Cover/index.js");
const require_index$2 = require("./components/Title/index.js");
const require_index$3 = require("./components/RenderFields/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/table/Gallery/components/GalleryItem/index.tsx
const prefix = "pisell-lowcode-";
const GalleryItem = (props) => {
	const { record, gallery, columnsMap, index, gallerySetting, columns, onClick } = props;
	const { coverField, coverObjectFit, compactMode, isShowLabel: propsIsShowLabel } = gallerySetting || {};
	const { cover, title, header, content, footer } = gallery;
	const { fields: headerFields, slot } = header || {};
	const { fields: contentFields, showLabel: contentShowLabel } = content || {};
	const { render, height } = footer || {};
	const coverDom = (0, react.useMemo)(() => {
		return cover.show && coverField !== "noCover" && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
			record,
			cover,
			coverField,
			coverObjectFit
		});
	}, [
		record,
		cover,
		coverField,
		coverObjectFit
	]);
	const titleDom = (0, react.useMemo)(() => {
		return /* @__PURE__ */ react.default.createElement(require_index$2.default, require_objectSpread2._objectSpread2({
			columnsMap,
			record
		}, title));
	}, [
		record,
		title,
		columnsMap
	]);
	const Header = (0, react.useMemo)(() => {
		return /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}header-wrap` }, coverDom, titleDom, headerFields.show && /* @__PURE__ */ react.default.createElement(require_index$3.default, {
			record,
			showMode: "block",
			columnsMap,
			fields: headerFields.list,
			isShowLabel: true
		}), slot && slot(record, index));
	}, [
		coverDom,
		columnsMap,
		record,
		cover,
		title,
		headerFields.show,
		headerFields.list,
		slot,
		index
	]);
	const { fixedHeader, fixedFooter } = (0, react.useMemo)(() => {
		if (gallery.fixedHeight) return {
			fixedHeader: gallery.fixedHeader,
			fixedFooter: gallery.fixedFooter
		};
		return {
			fixedHeader: false,
			fixedFooter: false
		};
	}, [
		gallery.fixedHeight,
		gallery.fixedHeader,
		gallery.fixedFooter
	]);
	const contentIsShowLabel = (0, react.useMemo)(() => {
		if (typeof contentShowLabel === "boolean") return contentShowLabel;
		return true;
	}, [contentShowLabel]);
	const { showMode, isShowLabel } = (0, react.useMemo)(() => {
		if (compactMode === "compact") return {
			showMode: "inline",
			isShowLabel: false
		};
		else if (compactMode === "default") return {
			showMode: "block",
			isShowLabel: contentIsShowLabel ? propsIsShowLabel : contentIsShowLabel
		};
		return {
			showMode: "block",
			isShowLabel: propsIsShowLabel
		};
	}, [
		compactMode,
		propsIsShowLabel,
		contentIsShowLabel
	]);
	const Content = (0, react.useMemo)(() => {
		const showFieldList = [];
		columns.forEach((item) => {
			if (item.isShow) showFieldList.push(item.key);
		});
		return /* @__PURE__ */ react.default.createElement(require_index$3.default, {
			record,
			showMode,
			columnsMap,
			fields: showFieldList,
			isShowLabel
		});
	}, [
		contentFields,
		record,
		columnsMap,
		showMode,
		isShowLabel,
		columns
	]);
	const Footer = (0, react.useMemo)(() => {
		return render && render(record, index);
	}, [record, index]);
	return /* @__PURE__ */ react.default.createElement("div", {
		className: `${prefix}gallery-item-wrap`,
		onClick
	}, /* @__PURE__ */ react.default.createElement(require_index.default, {
		fixedHeader,
		fixedFooter,
		header: Header,
		content: Content,
		footer: Footer,
		footerStyle: { height: (0, _pisell_utils.isFunction)(render) ? height : 0 }
	}));
};
//#endregion
exports.default = GalleryItem;
