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("../badge/index.js");
const require_warning = require("../../utils/warning.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/tabs/index.tsx
const _excluded = ["tab"];
const prefix = "pisell-lowcode-";
var Tabs = class extends react.Component {
	constructor(..._args) {
		var _this$props$activeKey;
		super(..._args);
		this.state = { activeKey: (_this$props$activeKey = this.props.activeKey) !== null && _this$props$activeKey !== void 0 ? _this$props$activeKey : this.props.defaultActiveKey };
		this._handleChange = (key) => {
			this.setActiveKey(key);
		};
		this.setActiveKey = (key) => {
			const { onChange = () => {} } = this.props;
			this.setState({ activeKey: key });
			onChange(key);
		};
		this.getActiveKey = () => {
			return this.state.activeKey;
		};
		this.renderIconLabelTabBar = (props, DefaultTabBar) => {
			var _this$props;
			const { items, sidebarWidth } = this.props;
			let wrapStyle = { gap: props.tabBarGutter };
			if (["left", "right"].includes(props.tabPosition)) wrapStyle = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, wrapStyle), {}, { width: sidebarWidth || 130 });
			return /* @__PURE__ */ react.default.createElement("div", {
				className: (0, classnames.default)("pisell-lowcode-tabs-nav", `${prefix}tab-bar-wrap`, `${prefix}tab-bar-wrap-${props.tabPosition}`, (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.className),
				style: wrapStyle
			}, this.filterHiddenTabs(items).map((item) => {
				return /* @__PURE__ */ react.default.createElement("div", {
					className: (0, classnames.default)(`${prefix}tab-bar-item`, { [`${prefix}tab-bar-item-active`]: item.key === props.activeKey }),
					key: item.key,
					onClick: (e) => props.onTabClick(item.key, e)
				}, /* @__PURE__ */ react.default.createElement(require_index.default, {
					count: item.badge,
					offset: [0, 6]
				}, /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}tab-bar-icon-wrap` }, item.icon)), /* @__PURE__ */ react.default.createElement("span", { className: `${prefix}tab-bar-label` }, item.label));
			}), props.extra);
		};
		this.filterHiddenTabs = (tabs) => {
			return tabs.filter((item) => !item.hidden);
		};
	}
	componentDidMount() {
		document.body.id = "body";
	}
	componentDidUpdate(prevProps) {
		if (prevProps.activeKey !== this.props.activeKey) this.setState({ activeKey: this.props.activeKey });
	}
	render() {
		const { props } = this;
		const { activeKey } = this.state;
		const { children, type } = props;
		let items = props.items;
		let otherProps = {};
		if (!props.items && Array.isArray(children) && children.length > 0) {
			require_warning.warning("Tabs.TabPane is deprecated. Please use `items` directly.");
			items = children.map((node) => {
				if (react.default.isValidElement(node)) {
					const { key, props } = node;
					const _ref = props || {}, { tab } = _ref, restProps = require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
					return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ key: String(key) }, restProps), {}, { label: tab });
				}
				return null;
			}).filter(Boolean);
		}
		items = this.filterHiddenTabs(items);
		if (type === "icon-label") otherProps = {
			renderTabBar: this.renderIconLabelTabBar,
			type: "line"
		};
		if (type === "line") items = items.map((item) => {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { label: /* @__PURE__ */ react.default.createElement("div", { style: { margin: "0 9px" } }, /* @__PURE__ */ react.default.createElement(require_index.default, {
				styleType: "default",
				count: item.badge,
				offset: [18, 10]
			}, /* @__PURE__ */ react.default.createElement("span", { className: `${prefix}tab-bar-label` }, item.label))) });
		});
		return /* @__PURE__ */ react.default.createElement(antd.Tabs, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), otherProps), {}, {
			items,
			activeKey,
			onChange: this._handleChange
		}));
	}
};
Tabs.TabPane = antd.Tabs.TabPane;
//#endregion
exports.default = Tabs;
