const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_index = require("../PisellScrollView/index.js");
const require_useStepsState = require("./hooks/useStepsState.js");
const require_index$1 = require("./utils/index.js");
const require_useStepClick = require("./hooks/useStepClick.js");
const require_useAnchor = require("./hooks/useAnchor.js");
const require_useResponsive = require("./hooks/useResponsive.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
require("./PisellSteps.less");
//#region src/components/PisellSteps/PisellSteps.tsx
const _excluded = [
	"type",
	"current",
	"defaultCurrent",
	"direction",
	"size",
	"status",
	"initial",
	"items",
	"labelPlacement",
	"responsive",
	"onChange",
	"className",
	"style",
	"progressDot",
	"clickable",
	"allowClickFinished",
	"gridLayout",
	"gridColumns",
	"itemGap",
	"enableAnchor",
	"anchorContainer",
	"mobileMode",
	"mobileBreakpoint",
	"enableScrollMode",
	"scrollActionsConfig",
	"__designMode",
	"__id",
	"other"
];
/**
* PisellSteps 步骤条组件
*
* 基于 Ant Design Steps 组件进行二次封装和增强
* 支持多种展示样式、布局方式和丰富的交互功能
*
* @author Pisell Team
* @version 1.0.0
*/
const PisellSteps = (_ref) => {
	let { type = "default", current: controlledCurrent, defaultCurrent = 0, direction = "horizontal", size = "default", status = "process", initial = 0, items = [], labelPlacement = "horizontal", responsive = true, onChange, className, style, progressDot, clickable = false, allowClickFinished = true, gridLayout = false, gridColumns, itemGap, enableAnchor = false, anchorContainer, mobileMode = "full", mobileBreakpoint = 744, enableScrollMode = false, scrollActionsConfig, __designMode, __id, other } = _ref, restProps = require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
	const [currentStep, setCurrentStep] = require_useStepsState.useStepsState(controlledCurrent, defaultCurrent, onChange);
	const handleStepClick = require_useStepClick.useStepClick(currentStep, clickable, allowClickFinished, setCurrentStep);
	require_useAnchor.useAnchor(currentStep, enableAnchor, anchorContainer);
	const isMobile = require_useResponsive.useResponsive(mobileBreakpoint);
	const showMobileCurrentView = (0, react.useMemo)(() => {
		if (mobileMode === "current") return true;
		if (mobileMode === "auto" && isMobile) return true;
		return false;
	}, [mobileMode, isMobile]);
	const safeItems = (0, react.useMemo)(() => {
		if (!items) return [];
		if (!Array.isArray(items)) return [];
		return items;
	}, [items]);
	const currentStepItem = (0, react.useMemo)(() => {
		const visibleItems = safeItems.filter((item) => !item.hidden);
		const adjustedIndex = currentStep - initial;
		if (adjustedIndex < 0 || adjustedIndex >= visibleItems.length) return null;
		return visibleItems[adjustedIndex] || null;
	}, [
		safeItems,
		currentStep,
		initial
	]);
	const processedItems = (0, react.useMemo)(() => {
		const visibleItems = safeItems.filter((item) => !item.hidden);
		if (__designMode === "design" && visibleItems.length === 0) return [
			{
				title: "步骤一",
				description: "This is a description.",
				status: "finish"
			},
			{
				title: "步骤二",
				description: "This is a description.",
				status: "process"
			},
			{
				title: "步骤三",
				description: "This is a description.",
				status: "wait"
			}
		];
		return visibleItems.filter((item) => item != null).map((item, index) => {
			const adjustedIndex = index + initial;
			let stepStatus;
			if (item.status) stepStatus = item.status;
			else if (adjustedIndex === currentStep) stepStatus = status;
			else stepStatus = require_index$1.getStepStatus(adjustedIndex, currentStep);
			const stepClassName = require_index$1.mergeStepClassName("pisell-steps-item", stepStatus, item.className);
			const handleClick = () => {
				if (!item.disabled) {
					var _item$onClick;
					(_item$onClick = item.onClick) === null || _item$onClick === void 0 || _item$onClick.call(item);
					handleStepClick(adjustedIndex, item);
				}
			};
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
				status: stepStatus,
				className: stepClassName,
				onClick: clickable || item.onClick ? handleClick : void 0
			});
		});
	}, [
		safeItems,
		currentStep,
		initial,
		status,
		clickable,
		handleStepClick,
		__designMode
	]);
	const wrapperClassName = (0, react.useMemo)(() => {
		const classes = ["pisell-steps"];
		if (className) classes.push(className);
		if (type === "navigation") classes.push("pisell-steps-navigation");
		if (progressDot) classes.push("pisell-steps-dot");
		if (size !== "default") classes.push(`pisell-steps-${size}`);
		if (direction === "vertical") classes.push("pisell-steps-vertical");
		if (responsive) classes.push("pisell-steps-responsive");
		if (clickable) classes.push("pisell-steps-clickable");
		if (gridLayout) classes.push("pisell-steps-grid-layout");
		if (itemGap !== void 0 && itemGap !== null) classes.push("pisell-steps-has-item-gap");
		return classes.join(" ");
	}, [
		className,
		type,
		progressDot,
		size,
		direction,
		responsive,
		clickable,
		gridLayout,
		itemGap
	]);
	const wrapperStyle = (0, react.useMemo)(() => {
		const customStyle = require_objectSpread2._objectSpread2({}, style);
		if (itemGap !== void 0 && itemGap !== null) {
			customStyle["--pisell-steps-item-gap"] = `${itemGap}px`;
			customStyle["--pisell-steps-has-item-gap"] = "1";
		}
		if (gridColumns && gridLayout) customStyle["--pisell-steps-grid-columns"] = gridColumns;
		return customStyle;
	}, [
		style,
		itemGap,
		gridColumns,
		gridLayout
	]);
	const defaultScrollActionsConfig = (0, react.useMemo)(() => require_objectSpread2._objectSpread2({
		show: true,
		type: "lrArrows",
		scrollDistance: 200
	}, scrollActionsConfig), [scrollActionsConfig]);
	const renderStepsContent = (forceHorizontal = false) => /* @__PURE__ */ react.default.createElement(antd.Steps, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
		current: Math.max(0, currentStep - initial),
		direction: forceHorizontal ? "horizontal" : direction,
		size: size === "large" ? "default" : size,
		status,
		items: processedItems,
		labelPlacement,
		type,
		progressDot,
		responsive: forceHorizontal ? false : responsive
	}, restProps), other || {}));
	const renderDesktopSteps = () => {
		if (enableScrollMode) return /* @__PURE__ */ react.default.createElement(require_index.default, {
			className: "pisell-steps-scroll-view",
			overflow: "x",
			scrollbarStyle: "none",
			scrollActionsConfig: defaultScrollActionsConfig,
			snapScroll: { enabled: false }
		}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-steps-scroll-content" }, renderStepsContent(true)));
		return renderStepsContent(false);
	};
	return /* @__PURE__ */ react.default.createElement("div", {
		className: showMobileCurrentView ? `pisell-steps pisell-steps-mobile-current ${className || ""}` : wrapperClassName,
		style: showMobileCurrentView ? style : wrapperStyle,
		"data-component": "pisell-steps",
		"data-id": __id
	}, showMobileCurrentView ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-steps-mobile-current__info" }, (currentStepItem === null || currentStepItem === void 0 ? void 0 : currentStepItem.title) && /* @__PURE__ */ react.default.createElement("span", { className: "pisell-steps-mobile-current__number" }, currentStepItem.title), (currentStepItem === null || currentStepItem === void 0 ? void 0 : currentStepItem.description) && /* @__PURE__ */ react.default.createElement("span", { className: "pisell-steps-mobile-current__title" }, currentStepItem.description)) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, renderDesktopSteps()));
};
PisellSteps.displayName = "PisellSteps";
//#endregion
exports.default = PisellSteps;
