import { getText } from "../../../../locales/index.js";
import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import Sort from "../../../sort/index.js";
import Toolbar from "../../../pisellGridPro/ToolBar/index.js";
import { deriveFilterFromColumns, deriveSortFromColumns } from "../../utils/recordBoardColumns.js";
import { useRecordBoardContext } from "../../hooks/useRecordBoardContext.js";
import { PisellFind } from "../../../pisellFind/index.js";
import PisellFilter from "../../../pisellFilter/index.js";
import ToolBarReset from "../ToolBarReset/index.js";
import ToolBarQuickFilter from "../ToolBarQuickFilter/index.js";
import RecordBoardColumnSetting from "../ColumnSetting/index.js";
import { useRecordBoardShellBodyMeta } from "../ShellBodyMetaContext.js";
import { DEFAULT_RESOURCE_WALL_STATUS_SORT_FIELD_KEYS, matchesResourceWallStatusSortField } from "../ResourceWall/venueWallUtils.js";
import { DEFAULT_SEARCH_FIELD, FILTER_PARAMS_FIELD, RESOURCE_WALL_QUICK_FILTER_KEY, SORT_PARAMS_FIELD } from "./recordBoardToolBarConstants.js";
import { buildResourceWallStatusSortFallbackItem, getDefaultFilterValue, getSortButtonText, getViewCalendarLabel, getViewFloorMapLabel, getViewGridLabel, getViewResourceWallLabel } from "./recordBoardToolBarI18n.js";
import React, { useCallback, useMemo } from "react";
import { Button, Popover, Segmented, Space } from "antd";
import { SearchOutlined, SettingOutlined } from "@ant-design/icons";
import classNames from "classnames";
import SwitchVertical01 from "@pisell/icon/es/SwitchVertical01";
import "./ToolBarFilter.less";
import "./recordBoardToolbar.less";
//#region src/components/pisellRecordBoard/shellFrame/ToolBar/index.tsx
const _excluded = [
	"trigger",
	"triggerType",
	"displayType",
	"triggerText",
	"triggerIcon",
	"buttonText"
], _excluded2 = ["resourceWallSortFieldKeys", "list"];
/**
* RecordBoard 下的工具栏：使用 PisellToolBar。
* 左侧默认 PisellFind（inline）；右侧默认 PisellFilter。通过 childComponentProps.toolBar.search / toolBar.filter 为对象时透传对应组件 props，为 false 时不渲染。
* 可透传 topLeft、topRight、bottomLeft、bottomRight、tabs。
*/
const RecordBoardToolBar = (props) => {
	var _ctx$resourceWallProp, _ctx$resourceWallProp2, _shellMeta$hasGridCon, _shellMeta$hasFloorMa, _shellMeta$hasCalenda, _shellMeta$hasResourc, _shellMeta$effectiveF, _ctx$childComponentPr, _ctx$childComponentPr2, _slots$toolbarDensity, _searchParams$DEFAULT, _ctx$childComponentPr3, _formFiltersPrefix, _filterResetKey, _slots$topRight;
	const ctx = useRecordBoardContext({ displayName: "toolBar" });
	const shellMeta = useRecordBoardShellBodyMeta();
	const { searchParams, onSearch, bodyView, setBodyView } = ctx;
	const resourceWallFilterFieldKey = (_ctx$resourceWallProp = (_ctx$resourceWallProp2 = ctx.resourceWallProps) === null || _ctx$resourceWallProp2 === void 0 ? void 0 : _ctx$resourceWallProp2.filterFieldKey) !== null && _ctx$resourceWallProp !== void 0 ? _ctx$resourceWallProp : RESOURCE_WALL_QUICK_FILTER_KEY;
	/** ShellFrame 内解析：多子视图（表格 / 平面图 / 日历）时渲染 Segmented */
	const hasGridInShell = (_shellMeta$hasGridCon = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasGridContent) !== null && _shellMeta$hasGridCon !== void 0 ? _shellMeta$hasGridCon : true;
	const hasFloorInShell = (_shellMeta$hasFloorMa = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasFloorMapSlot) !== null && _shellMeta$hasFloorMa !== void 0 ? _shellMeta$hasFloorMa : ctx.floorMapProps != null;
	const hasCalendarInShell = (_shellMeta$hasCalenda = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasCalendarSlot) !== null && _shellMeta$hasCalenda !== void 0 ? _shellMeta$hasCalenda : ctx.calendarProps != null;
	const hasResourceWallInShell = (_shellMeta$hasResourc = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasResourceWallSlot) !== null && _shellMeta$hasResourc !== void 0 ? _shellMeta$hasResourc : ctx.resourceWallProps != null;
	const floorForToggle = (_shellMeta$effectiveF = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.effectiveFloorMapProps) !== null && _shellMeta$effectiveF !== void 0 ? _shellMeta$effectiveF : ctx.floorMapProps;
	const canFloor = hasFloorInShell && floorForToggle != null;
	const canCalendar = hasCalendarInShell;
	const canResourceWall = hasResourceWallInShell;
	const canGrid = hasGridInShell;
	/** 至少两种主区时出现切换器（兼容原「仅表格+平面图」） */
	const showTableFloorToggle = (canGrid ? 1 : 0) + (canFloor ? 1 : 0) + (canCalendar ? 1 : 0) + (canResourceWall ? 1 : 0) >= 2;
	/** 业务可关闭多视图切换（如场控仅平面图），此时不渲染 Segmented */
	const allowBodyViewToggle = showTableFloorToggle && ctx.bodyViewSwitchable !== false;
	const slots = (_ctx$childComponentPr = (_ctx$childComponentPr2 = ctx.childComponentProps) === null || _ctx$childComponentPr2 === void 0 ? void 0 : _ctx$childComponentPr2.toolBar) !== null && _ctx$childComponentPr !== void 0 ? _ctx$childComponentPr : {};
	const toolbarDensity = (_slots$toolbarDensity = slots.toolbarDensity) !== null && _slots$toolbarDensity !== void 0 ? _slots$toolbarDensity : "default";
	const isCompactNarrow = toolbarDensity === "compact-narrow";
	/**
	* compact 用 middle：比 50px Figma 略紧凑，又比 small 更易点按；与下方 Less 中 ~38px 工具栏样式一致。
	* compact-narrow 进一步缩到 small：极窄抽屉内顶栏右侧为 search 图标 + 齿轮（列/排序/筛选/重置在齿轮内）。
	*/
	const barSize = isCompactNarrow ? "small" : toolbarDensity === "compact" ? "middle" : "large";
	const filterConfig = slots.filter;
	/** 与 PisellFilter 一致：用于顶栏快筛内 FilterItem（如手机端 orderDate 换 antd-mobile） */
	const filterPhoneLayout = typeof filterConfig === "object" && filterConfig !== null && "phoneLayout" in filterConfig ? Boolean(filterConfig.phoneLayout) : isCompactNarrow;
	const keyword = (_searchParams$DEFAULT = searchParams === null || searchParams === void 0 ? void 0 : searchParams["keyword"]) !== null && _searchParams$DEFAULT !== void 0 ? _searchParams$DEFAULT : "";
	const handleSearch = useCallback((value) => {
		onSearch(_objectSpread2(_objectSpread2({}, searchParams), {}, { [DEFAULT_SEARCH_FIELD]: value || void 0 }));
	}, [onSearch, searchParams]);
	const gridColumns = (_ctx$childComponentPr3 = ctx.childComponentProps) === null || _ctx$childComponentPr3 === void 0 || (_ctx$childComponentPr3 = _ctx$childComponentPr3.grid) === null || _ctx$childComponentPr3 === void 0 ? void 0 : _ctx$childComponentPr3.columns;
	const derivedFilterFromColumns = useMemo(() => Array.isArray(gridColumns) && gridColumns.length > 0 ? deriveFilterFromColumns(gridColumns) : null, [gridColumns]);
	const derivedSortFromColumnsList = useMemo(() => Array.isArray(gridColumns) && gridColumns.length > 0 ? deriveSortFromColumns(gridColumns) : [], [gridColumns]);
	const searchConfig = slots.search;
	const hideSearch = searchConfig === false;
	/**
	* - 默认：inline 模式（triggerType="input" + displayType="inline"），常驻输入框
	* - compact-narrow：仅图标触发器（无 Find 文案），放在顶栏右侧与齿轮并排；
	*   Reset 收入齿轮 Popover。传 `trigger={<Button .../>}` 由 PisellLookup 注入 onClick。
	*/
	const searchButtonText = getText("pisell2.recordBoard.toolbar.find") || "Find";
	/**
	* compact-narrow：业务侧 `toolBar.search` 常带 `triggerType=input` / `displayType=inline`，
	* 整对象 spread 在 `triggerType=icon` 之后会把它覆盖回输入框；这里剔除会劫持展示形态的字段。
	*/
	const compactNarrowSearchRest = typeof searchConfig === "object" && searchConfig !== null ? (() => {
		const _ref = searchConfig, { trigger: _tr, triggerType: _tt, displayType: _dt, triggerText: _tx, triggerIcon: _ti, buttonText: _btn } = _ref;
		return _objectWithoutProperties(_ref, _excluded);
	})() : {};
	const searchNode = hideSearch ? null : isCompactNarrow ? /* @__PURE__ */ React.createElement(PisellFind, _objectSpread2(_objectSpread2({}, compactNarrowSearchRest), {}, {
		value: keyword,
		onChange: (v) => handleSearch(v),
		onSearch: handleSearch,
		size: barSize,
		triggerType: "icon",
		className: "record-board-toolbar-find-icon",
		triggerIcon: /* @__PURE__ */ React.createElement(SearchOutlined, { "aria-label": searchButtonText })
	})) : /* @__PURE__ */ React.createElement(PisellFind, _objectSpread2(_objectSpread2({
		triggerType: "input",
		displayType: "inline",
		showConfirmButton: typeof searchConfig === "object" && searchConfig !== null && "showConfirmButton" in searchConfig ? searchConfig.showConfirmButton : true,
		value: keyword,
		onChange: (v) => handleSearch(v),
		onSearch: handleSearch
	}, typeof searchConfig === "object" && searchConfig !== null ? searchConfig : {}), {}, { size: toolbarDensity === "compact" ? barSize : typeof searchConfig === "object" && searchConfig !== null && "size" in searchConfig && searchConfig.size != null ? searchConfig.size : barSize }));
	const quickFilterConfig = slots.quickFilter;
	const quickFilterList = useMemo(() => {
		var _ref2;
		if (quickFilterConfig === false) return [];
		const fromConfig = typeof quickFilterConfig === "object" && quickFilterConfig !== null && Array.isArray(quickFilterConfig.filterList) ? quickFilterConfig.filterList : null;
		let list = (_ref2 = fromConfig !== null && fromConfig !== void 0 ? fromConfig : derivedFilterFromColumns === null || derivedFilterFromColumns === void 0 ? void 0 : derivedFilterFromColumns.quickFilter) !== null && _ref2 !== void 0 ? _ref2 : [];
		const hideNames = typeof quickFilterConfig === "object" && quickFilterConfig !== null && Array.isArray(quickFilterConfig.hideFilterNamesOnFloorMap) ? quickFilterConfig.hideFilterNamesOnFloorMap : null;
		if ((bodyView === "floorMap" || bodyView === "calendar" || bodyView === "resourceWall") && showTableFloorToggle && hideNames != null && hideNames.length > 0) {
			const hideSet = new Set(hideNames.map(String));
			list = list.filter((item) => {
				var _item$name;
				const n = (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.key;
				return n == null || !hideSet.has(String(n));
			});
		}
		return list;
	}, [
		quickFilterConfig,
		derivedFilterFromColumns === null || derivedFilterFromColumns === void 0 ? void 0 : derivedFilterFromColumns.quickFilter,
		bodyView,
		showTableFloorToggle
	]);
	/**
	* 资源墙专用快筛不占用顶栏；resourceWall 时顶栏快筛整行收起（改走右侧 Filter）。
	* 资源墙顶栏仅保留 Sort + Filter（Find / Reset 隐藏）。
	* 其它视图从顶栏剔除该字段，避免与表格/平面图等共用 toolBar.quickFilter 时误展示。
	*/
	const leftBarQuickFilterList = useMemo(() => {
		const withoutWall = quickFilterList.filter((item) => {
			var _ref3, _item$key;
			return ((_ref3 = (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : item.name) !== null && _ref3 !== void 0 ? _ref3 : "") !== resourceWallFilterFieldKey;
		});
		if (bodyView === "resourceWall") return [];
		return withoutWall;
	}, [
		bodyView,
		quickFilterList,
		resourceWallFilterFieldKey
	]);
	const showQuickFilterLeft = leftBarQuickFilterList.length > 0;
	const quickFilterNode = showQuickFilterLeft ? /* @__PURE__ */ React.createElement(ToolBarQuickFilter, {
		filterList: leftBarQuickFilterList,
		formFiltersPrefix: typeof quickFilterConfig === "object" && quickFilterConfig !== null ? (_formFiltersPrefix = quickFilterConfig.formFiltersPrefix) !== null && _formFiltersPrefix !== void 0 ? _formFiltersPrefix : "" : "",
		size: typeof quickFilterConfig === "object" && quickFilterConfig !== null ? quickFilterConfig.size : void 0,
		phoneLayout: filterPhoneLayout
	}) : null;
	const bodyViewSegmentedOptions = useMemo(() => {
		const opts = [];
		if (canFloor) opts.push({
			label: getViewFloorMapLabel(),
			value: "floorMap"
		});
		if (canCalendar) opts.push({
			label: getViewCalendarLabel(),
			value: "calendar"
		});
		if (canResourceWall) opts.push({
			label: getViewResourceWallLabel(),
			value: "resourceWall"
		});
		if (canGrid) opts.push({
			label: getViewGridLabel(),
			value: "grid"
		});
		return opts;
	}, [
		canFloor,
		canCalendar,
		canResourceWall,
		canGrid
	]);
	const bodyViewToggle = allowBodyViewToggle ? /* @__PURE__ */ React.createElement(Segmented, {
		className: "record-board-toolbar-body-view-segmented",
		size: barSize,
		value: bodyView,
		onChange: (v) => setBodyView(v),
		options: bodyViewSegmentedOptions,
		style: { marginRight: 8 }
	}) : null;
	/** 平面图 / 日历模式：第二行工具（搜索/筛选等）收起；切换器在业务方 tabs 内（如预约 ScheduleBand） */
	const compactFloorMapToolbar = (bodyView === "floorMap" || bodyView === "calendar") && showTableFloorToggle;
	/**
	* 仅非表格且 tabs 内含 ScheduleBand（平面图 / 日历）时隐藏顶行切换器；表格 / 资源墙 tabs 无 ScheduleBand，
	* 切换器回到 Find 左侧（与 PisellReservation 表格态一致）。
	*/
	const hideBodyViewToggleInToolbarRow = slots.hideBodyViewToggle === true || allowBodyViewToggle && Boolean(slots.tabs) && (bodyView === "floorMap" || bodyView === "calendar");
	const sortConfig = slots.sort;
	const hideSort = sortConfig === false;
	const sortValue = searchParams === null || searchParams === void 0 ? void 0 : searchParams[SORT_PARAMS_FIELD];
	const handleSortChange = useCallback((val) => {
		onSearch(_objectSpread2(_objectSpread2({}, searchParams), {}, { [SORT_PARAMS_FIELD]: val || void 0 }));
	}, [onSearch, searchParams]);
	const sortList = useMemo(() => {
		/** `list: []` 若为 `??` 左值会得到空数组，无法回落到列派生；此处显式在非空时使用配置项 */
		const configuredList = typeof sortConfig === "object" && sortConfig !== null && Array.isArray(sortConfig.list) ? sortConfig.list : null;
		const base = configuredList != null && configuredList.length > 0 ? configuredList : derivedSortFromColumnsList;
		if (bodyView !== "resourceWall") return base;
		const extraWallKeys = typeof sortConfig === "object" && sortConfig !== null && Array.isArray(sortConfig.resourceWallSortFieldKeys) ? sortConfig.resourceWallSortFieldKeys.map(String) : [];
		const allowedKeys = [...DEFAULT_RESOURCE_WALL_STATUS_SORT_FIELD_KEYS.map(String), ...extraWallKeys];
		const filtered = base.filter((item) => item.name != null && matchesResourceWallStatusSortField(String(item.name), allowedKeys));
		if (filtered.length > 0) return filtered;
		return [buildResourceWallStatusSortFallbackItem(sortConfig)];
	}, [
		sortConfig,
		derivedSortFromColumnsList,
		bodyView
	]);
	const sortSpreadRest = typeof sortConfig === "object" && sortConfig !== null ? (() => {
		const _ref4 = sortConfig, { resourceWallSortFieldKeys: _w, list: _omitList } = _ref4;
		return _objectWithoutProperties(_ref4, _excluded2);
	})() : {};
	const sortNode = hideSort ? null : /* @__PURE__ */ React.createElement(Sort, _objectSpread2(_objectSpread2({}, sortSpreadRest), {}, {
		list: sortList,
		value: sortValue,
		onChange: handleSortChange,
		placement: "bottomLeft",
		button: /* @__PURE__ */ React.createElement(Button, {
			className: "record-board-toolbar-filter-btn",
			icon: /* @__PURE__ */ React.createElement(SwitchVertical01, null),
			size: barSize
		}, getSortButtonText())
	}));
	const hideFilter = filterConfig === false;
	const filterValue = searchParams === null || searchParams === void 0 ? void 0 : searchParams[FILTER_PARAMS_FIELD];
	const hasFilterList = Array.isArray(filterValue === null || filterValue === void 0 ? void 0 : filterValue.quickFilter) && filterValue.quickFilter.length > 0 || Array.isArray(filterValue === null || filterValue === void 0 ? void 0 : filterValue.otherFilter) && filterValue.otherFilter.length > 0;
	const hasFilterValues = typeof (filterValue === null || filterValue === void 0 ? void 0 : filterValue.values) === "object" && filterValue.values !== null && Object.keys(filterValue.values).length > 0;
	const hasFilterItems = hasFilterList || hasFilterValues;
	const defaultFilterFromConfig = typeof filterConfig === "object" && filterConfig !== null && filterConfig.defaultFilterValue ? filterConfig.defaultFilterValue : null;
	const effectiveFilterValue = useMemo(() => {
		var _defaultFilterFromCon, _defaultFilterFromCon2, _base$values;
		const base = filterValue != null && hasFilterItems ? filterValue : defaultFilterFromConfig ? defaultFilterFromConfig : derivedFilterFromColumns && (derivedFilterFromColumns.quickFilter.length > 0 || derivedFilterFromColumns.otherFilter.length > 0) ? derivedFilterFromColumns : getDefaultFilterValue();
		const quickFilter = Array.isArray(base.quickFilter) && base.quickFilter.length > 0 ? base.quickFilter : (_defaultFilterFromCon = defaultFilterFromConfig === null || defaultFilterFromConfig === void 0 ? void 0 : defaultFilterFromConfig.quickFilter) !== null && _defaultFilterFromCon !== void 0 ? _defaultFilterFromCon : [];
		let otherFilter = Array.isArray(base.otherFilter) && base.otherFilter.length > 0 ? base.otherFilter : (_defaultFilterFromCon2 = defaultFilterFromConfig === null || defaultFilterFromConfig === void 0 ? void 0 : defaultFilterFromConfig.otherFilter) !== null && _defaultFilterFromCon2 !== void 0 ? _defaultFilterFromCon2 : [];
		if (otherFilter === base.otherFilter && Array.isArray(defaultFilterFromConfig === null || defaultFilterFromConfig === void 0 ? void 0 : defaultFilterFromConfig.otherFilter) && defaultFilterFromConfig.otherFilter.length > 0) {
			const configMap = new Map(defaultFilterFromConfig.otherFilter.map((c) => {
				var _ref5, _c$key;
				return [(_ref5 = (_c$key = c.key) !== null && _c$key !== void 0 ? _c$key : c.name) !== null && _ref5 !== void 0 ? _ref5 : "", c];
			}));
			otherFilter = otherFilter.map((item) => {
				var _ref6, _item$key2, _configItem$label, _configItem$other$pla, _configItem$other, _item$other;
				const key = (_ref6 = (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : item.name) !== null && _ref6 !== void 0 ? _ref6 : "";
				const configItem = configMap.get(key);
				if (!configItem) return item;
				return _objectSpread2(_objectSpread2(_objectSpread2({}, configItem), item), {}, {
					label: (_configItem$label = configItem.label) !== null && _configItem$label !== void 0 ? _configItem$label : item.label,
					other: _objectSpread2(_objectSpread2(_objectSpread2({}, configItem === null || configItem === void 0 ? void 0 : configItem.other), item === null || item === void 0 ? void 0 : item.other), {}, { placeholder: (_configItem$other$pla = configItem === null || configItem === void 0 || (_configItem$other = configItem.other) === null || _configItem$other === void 0 ? void 0 : _configItem$other.placeholder) !== null && _configItem$other$pla !== void 0 ? _configItem$other$pla : item === null || item === void 0 || (_item$other = item.other) === null || _item$other === void 0 ? void 0 : _item$other.placeholder })
				});
			});
		}
		let outQuick = quickFilter;
		let outOther = otherFilter;
		/**
		* 资源墙：Filter 弹层只保留「大屏资源多选」一项（与顶栏 quickFilter.filterList 中
		* `resource_wall_resource_ids` 对应），不混入日期快筛 / 业务 otherFilter。
		*/
		if (bodyView === "resourceWall") {
			outQuick = [];
			outOther = quickFilterList.filter((item) => {
				var _ref7, _item$key3;
				return ((_ref7 = (_item$key3 = item.key) !== null && _item$key3 !== void 0 ? _item$key3 : item.name) !== null && _ref7 !== void 0 ? _ref7 : "") === resourceWallFilterFieldKey;
			}).map((item) => _objectSpread2({}, item));
		}
		return _objectSpread2(_objectSpread2({}, base), {}, {
			quickFilter: outQuick,
			otherFilter: outOther,
			values: (_base$values = base.values) !== null && _base$values !== void 0 ? _base$values : {}
		});
	}, [
		filterValue,
		hasFilterItems,
		defaultFilterFromConfig,
		derivedFilterFromColumns,
		bodyView,
		quickFilterList
	]);
	const filterValueForPisellFilter = useMemo(() => _objectSpread2(_objectSpread2({}, effectiveFilterValue), {}, { quickFilter: [] }), [effectiveFilterValue]);
	const handleFilterChange = useCallback((value) => {
		var _currentFilter$values, _value$values;
		const currentFilter = searchParams === null || searchParams === void 0 ? void 0 : searchParams[FILTER_PARAMS_FIELD];
		const currentValues = (_currentFilter$values = currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.values) !== null && _currentFilter$values !== void 0 ? _currentFilter$values : {};
		const incomingValues = (_value$values = value === null || value === void 0 ? void 0 : value.values) !== null && _value$values !== void 0 ? _value$values : {};
		const nextFilter = _objectSpread2(_objectSpread2({}, value), {}, { values: _objectSpread2(_objectSpread2({}, currentValues), incomingValues) });
		onSearch(_objectSpread2(_objectSpread2({}, searchParams), {}, { [FILTER_PARAMS_FIELD]: nextFilter }));
	}, [onSearch, searchParams]);
	const filterResetKey = (_filterResetKey = ctx.filterResetKey) !== null && _filterResetKey !== void 0 ? _filterResetKey : 0;
	const filterNode = hideFilter ? null : /* @__PURE__ */ React.createElement(PisellFilter, _objectSpread2(_objectSpread2({
		key: `record-board-filter-${filterResetKey}`,
		value: filterValueForPisellFilter,
		onChange: handleFilterChange,
		hasForm: true,
		quickFilterMaxLength: 100,
		formFiltersPrefix: "",
		hiddenQuickFilter: true,
		placement: "bottomLeft"
	}, typeof filterConfig === "object" && filterConfig !== null ? filterConfig : {}), {}, {
		phoneLayout: filterPhoneLayout,
		size: barSize,
		buttonClassName: "record-board-toolbar-filter-btn"
	}));
	const showColumnSetting = slots.columnSetting !== false && bodyView !== "resourceWall" && Array.isArray(gridColumns) && gridColumns.length > 0;
	/**
	* compact-narrow：列显示 / 排序 / 筛选 / 重置 收入齿轮 Popover；顶栏右侧仅保留搜索图标 + 齿轮。
	*/
	const settingsGearPopoverContent = isCompactNarrow ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-settings-gear-popover" }, showColumnSetting ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-settings-gear-row" }, /* @__PURE__ */ React.createElement(RecordBoardColumnSetting, null)) : null, sortNode ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-settings-gear-row" }, sortNode) : null, filterNode ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-settings-gear-row" }, filterNode) : null, bodyView !== "resourceWall" ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-settings-gear-row" }, /* @__PURE__ */ React.createElement(ToolBarReset, { size: barSize })) : null) : null;
	const settingsGearTrigger = settingsGearPopoverContent != null ? /* @__PURE__ */ React.createElement(Popover, {
		content: settingsGearPopoverContent,
		trigger: "click",
		placement: "bottomRight",
		arrow: false,
		overlayClassName: classNames("record-board-toolbar-settings-gear-overlay", isCompactNarrow && "record-board-toolbar-settings-gear-overlay--compact-narrow")
	}, /* @__PURE__ */ React.createElement(Button, {
		className: "record-board-toolbar-settings-gear-btn",
		icon: /* @__PURE__ */ React.createElement(SettingOutlined, null),
		size: barSize,
		type: "text",
		"aria-label": getText("pisell2.recordBoard.toolbar.moreSettings") || "More settings"
	})) : null;
	const mergeQuickFilterWithCompactTrailing = isCompactNarrow && slots.mergeCompactNarrowTrailingWithQuickFilterRow === true && showQuickFilterLeft;
	const compactNarrowTrailingCluster = isCompactNarrow ? /* @__PURE__ */ React.createElement(Space, {
		className: classNames("record-board-toolbar-right-actions", mergeQuickFilterWithCompactTrailing && "record-board-toolbar-hud-trailing-cluster"),
		size: 4
	}, bodyView !== "resourceWall" && searchNode ? searchNode : null, settingsGearTrigger) : null;
	const topLeft = compactFloorMapToolbar ? null : /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-top-left" }, !hideBodyViewToggleInToolbarRow ? bodyViewToggle : null, mergeQuickFilterWithCompactTrailing && quickFilterNode ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-hud-unified-quick-filter-row" }, /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-quick-filter-slot" }, quickFilterNode), compactNarrowTrailingCluster) : quickFilterNode ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-quick-filter-slot" }, quickFilterNode) : null, searchNode && bodyView !== "resourceWall" && !isCompactNarrow ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-find-wrap" }, searchNode) : null, slots.topLeft ? /* @__PURE__ */ React.createElement("div", { className: "record-board-toolbar-extra-top-left" }, slots.topLeft) : null);
	const topRight = compactFloorMapToolbar ? null : isCompactNarrow ? mergeQuickFilterWithCompactTrailing ? (_slots$topRight = slots.topRight) !== null && _slots$topRight !== void 0 ? _slots$topRight : null : /* @__PURE__ */ React.createElement(Space, {
		className: "record-board-toolbar-right-actions",
		size: 4
	}, bodyView !== "resourceWall" && searchNode ? searchNode : null, settingsGearTrigger, slots.topRight) : /* @__PURE__ */ React.createElement(Space, { className: "record-board-toolbar-right-actions" }, showColumnSetting ? /* @__PURE__ */ React.createElement(RecordBoardColumnSetting, null) : null, sortNode, filterNode, bodyView !== "resourceWall" ? /* @__PURE__ */ React.createElement(ToolBarReset, { size: barSize }) : null, slots.topRight);
	return /* @__PURE__ */ React.createElement(Toolbar, {
		className: classNames(bodyView === "floorMap" && "pisell-record-board-toolbar--floor-map", bodyView === "calendar" && "pisell-record-board-toolbar--calendar", bodyView === "resourceWall" && "pisell-record-board-toolbar--resource-wall", bodyView === "grid" && "pisell-record-board-toolbar--grid", toolbarDensity === "compact" && "pisell-record-board-toolbar--compact", isCompactNarrow && "pisell-record-board-toolbar--compact pisell-record-board-toolbar--compact-narrow", slots.className),
		style: slots.style,
		tabs: slots.tabs,
		topLeft,
		topRight,
		bottomLeft: compactFloorMapToolbar ? null : slots.bottomLeft,
		bottomRight: compactFloorMapToolbar ? null : slots.bottomRight
	});
};
RecordBoardToolBar.displayName = "RecordBoard.ToolBar";
//#endregion
export { RecordBoardToolBar as default };
