const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_topologyLocale = require("../topologyLocale.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _ant_design_icons = require("@ant-design/icons");
require("./TopologyFloorMapEditToggle.less");
//#region src/plus/pisellTopology/components/TopologyFloorMapEditToggle.tsx
const I18N_EDIT = "pisell-topology.edit-map";
const I18N_DONE = "pisell-topology.edit-map-done";
const I18N_AUTO_ARRANGE = "pisell-topology.auto-arrange";
/** 左下 Dock 尾区：进入 / 退出拓扑编辑（对齐预约页「编辑平面图」） */
function TopologyFloorMapEditToggle(props) {
	var _getTopologyText, _getTopologyText2;
	const { mapEditInternal, setMapEditInternal, floorMapLayoutRef, forceEditMode, phoneLayout, onAutoArrange, autoArrangePending } = props;
	const displayLocale = require_topologyLocale.resolveTopologyDisplayLocale(require_useEngineContext.default());
	const editing = forceEditMode || mapEditInternal;
	const label = (_getTopologyText = require_topologyLocale.getTopologyText(editing ? I18N_DONE : I18N_EDIT, displayLocale)) !== null && _getTopologyText !== void 0 ? _getTopologyText : "";
	const autoArrangeLabel = (_getTopologyText2 = require_topologyLocale.getTopologyText(I18N_AUTO_ARRANGE, displayLocale)) !== null && _getTopologyText2 !== void 0 ? _getTopologyText2 : "";
	const showAutoArrange = editing && typeof onAutoArrange === "function";
	const handleClick = () => {
		if (editing) {
			var _floorMapLayoutRef$cu, _floorMapLayoutRef$cu2;
			(_floorMapLayoutRef$cu = floorMapLayoutRef.current) === null || _floorMapLayoutRef$cu === void 0 || (_floorMapLayoutRef$cu2 = _floorMapLayoutRef$cu.saveLayout) === null || _floorMapLayoutRef$cu2 === void 0 || _floorMapLayoutRef$cu2.call(_floorMapLayoutRef$cu);
			if (!forceEditMode) setMapEditInternal(false);
			return;
		}
		setMapEditInternal(true);
	};
	if (phoneLayout) return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, showAutoArrange ? /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		className: "pisell-floor-map-layout-view-controls-tool-btn",
		title: autoArrangeLabel,
		"aria-label": autoArrangeLabel,
		disabled: autoArrangePending,
		onClick: onAutoArrange
	}, /* @__PURE__ */ react.default.createElement(_ant_design_icons.ThunderboltOutlined, null)) : null, /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		className: editing ? "pisell-floor-map-layout-view-controls-tool-btn pisell-floor-map-layout-view-controls-tool-btn--active" : "pisell-floor-map-layout-view-controls-tool-btn",
		title: label,
		"aria-label": label,
		"aria-pressed": editing,
		onClick: handleClick
	}, editing ? /* @__PURE__ */ react.default.createElement(_ant_design_icons.CheckOutlined, null) : /* @__PURE__ */ react.default.createElement(_ant_design_icons.EditOutlined, null)));
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-topology-floor-map-dock-actions" }, showAutoArrange ? /* @__PURE__ */ react.default.createElement(antd.Button, {
		size: "middle",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.ThunderboltOutlined, null),
		className: "pisell-topology-floor-map-edit-btn",
		loading: autoArrangePending,
		onClick: onAutoArrange
	}, autoArrangeLabel) : null, /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "primary",
		size: "middle",
		className: "pisell-topology-floor-map-edit-btn",
		onClick: handleClick
	}, label));
}
//#endregion
exports.TopologyFloorMapEditToggle = TopologyFloorMapEditToggle;
