import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { useMemo } from "react";
//#region src/pro/Selector/hooks/usePresetProps.ts
const VARIANT_MAP = {
	["default"]: [
		"1",
		"2",
		"3",
		"4"
	],
	["select"]: ["1"],
	["card"]: [
		"1",
		"2",
		"3",
		"4",
		"5"
	],
	["media"]: ["1", "2"]
};
const EMPTY_CONFIG = {};
/**
* 预设响应式配置
* 使用 ResizeObserver 实现容器级响应式布局
*/
const RESPONSIVE_PRESETS = {
	responsive210: { breakpoints: {
		0: {
			columns: 1,
			gap: 16
		},
		420: {
			columns: 2,
			gap: 16
		},
		630: {
			columns: 3,
			gap: 16
		},
		841: {
			columns: 4,
			gap: 16
		},
		1367: {
			columns: 5,
			gap: 16
		}
	} },
	responsive330: { breakpoints: {
		0: {
			columns: 1,
			gap: 16
		},
		660: {
			columns: 2,
			gap: 16
		},
		995: {
			columns: 3,
			gap: 16
		},
		1367: {
			columns: 4,
			gap: 16
		}
	} }
};
/**
* 预设布局配置库
* 定义所有可用的布局模式，配置更加语义化和集中化
* selector 默认使用竖向flex
*/
const PRESET_LAYOUTS = {
	autoFlex: { className: "pisell-pro-selector_layout-auto-flex" },
	responsive210: { responsive: RESPONSIVE_PRESETS.responsive210 },
	responsive330: { responsive: RESPONSIVE_PRESETS.responsive330 }
};
const VARIANT_PRESET_MAP = {
	default: {
		"1": "column",
		"2": "autoFlex",
		"3": "column",
		"4": "autoFlex"
	},
	card: {
		"1": "responsive210",
		"2": "responsive210",
		"3": "column",
		"4": "responsive330",
		"5": "column"
	},
	media: {
		"1": "autoFlex",
		"2": "autoFlex"
	}
};
/**
* 根据预设配置生成 layout 和 indicatorProps
* Layout 规则：
* - 根据 variant 和 preset.variant 计算布局样式
* IndicatorProps 规则：
* 1. 当 variant='card' 且 preset.variant='2' 时，indicator 默认 variant='filled'
* 2. 当 variant='media' 时，indicator 默认 variant='filled'
* 3. 外部传入的 indicatorProps 优先级更高（会合并到预设配置中）
*/
const usePresetProps = ({ layout, mode = "single", preset, itemLayout = "horizontal", variant = "default", indicatorProps }) => {
	return useMemo(() => {
		let layoutConfig = null;
		if (variant === "select" || !(preset === null || preset === void 0 ? void 0 : preset.variant)) layoutConfig = layout || null;
		else {
			let baseLayoutConfig = null;
			let presetVariant = (VARIANT_MAP[variant] || []).includes(preset === null || preset === void 0 ? void 0 : preset.variant) ? preset === null || preset === void 0 ? void 0 : preset.variant : "1";
			const presetLayoutInfo = VARIANT_PRESET_MAP[variant];
			if (presetLayoutInfo) {
				const layoutType = presetLayoutInfo[presetVariant];
				if (layoutType) {
					const _config = PRESET_LAYOUTS[layoutType];
					if (_config) baseLayoutConfig = _config;
					else baseLayoutConfig = EMPTY_CONFIG;
				} else baseLayoutConfig = EMPTY_CONFIG;
			} else baseLayoutConfig = EMPTY_CONFIG;
			if (layout) layoutConfig = _objectSpread2(_objectSpread2({}, baseLayoutConfig), layout);
			else layoutConfig = baseLayoutConfig;
		}
		let computedIndicatorProps = {};
		if (variant === "media" || variant === "card" && (preset === null || preset === void 0 ? void 0 : preset.variant) === "2") computedIndicatorProps = {
			variant: "filled",
			size: "small"
		};
		if (indicatorProps) computedIndicatorProps = _objectSpread2(_objectSpread2({}, computedIndicatorProps), indicatorProps);
		console.log("layoutConfig", layoutConfig);
		return {
			layout: layoutConfig,
			indicatorProps: computedIndicatorProps
		};
	}, [
		JSON.stringify(preset),
		itemLayout,
		variant,
		layout,
		mode,
		JSON.stringify(indicatorProps)
	]);
};
//#endregion
export { usePresetProps as default };
