import { d as __rest, s as IconButton, kB as ExpandDirect, ls as GEO_TYPE_ICON_MAP, am as Tooltip, I as Icon, r as Popconfirm } from './MapEditView-f6381866.js';
import React__default from 'react';
import { observer } from 'mobx-react';
import classNames from 'classnames';
import { M as MyDataTableContext, p as prefixCls } from './index-0b8bebb4.js';
import 'maptalks';
import 'lodash';
import 'uuid';
import 'mobx';
import 'lz-string';
import 'dayjs';
import 'react-dom';
import 'react-is';
import '@loadable/component';
import 'js-beautify';
import 'axios';
import 'superstruct';
import '@tanem/react-nprogress';
import 'jquery';
import 'chroma-js';
import 'js-cookie';
import 'is-email';
import 'is-uuid';
import 'is-url';
import 'anymatch';
import '@syncpoint/wkx';
import 'buffer';
import '@turf/turf';
import '@mapbox/polylabel';
import 'turf-multipolygon';
import 'turf-polygon';
import 'gcoord';
import 'eventemitter2';
import 'geobuf';
import 'localforage';
import 'rc-menu';
import 'perfect-scrollbar';
import 'ahooks';
import 'jszip';
import 'file-saver';
import 'screenfull';
import 'sql-formatter-fork';
import 'array-move';
import 'turf-multilinestring';
import 'copy-to-clipboard';
import 'maptalks.three';
import 'ajv';
import 'spark-md5';
import 'react-draggable';
import 'react-virtualized';
import 'turf-point';
import 'decamelize';
import 'rbush';
import 'qs';
import 'maptalks.snap';
import 'react-use';
import 'react-rnd';
import 'react-beautiful-dnd';
import 'react-contextmenu';
import 'coordtransform';
import './compact-f89fbdd0.js';
import './useDataValue-6bd3790f.js';
import 'react-dnd-html5-backend';
import 'ali-react-table-fork';
import './Transfer-b219601e.js';
import 'ismobilejs';

const DataTableHeader = observer(({ expand, expandRight }) => {
    const { store, delPackage, tabPopupConfirm } = React__default.useContext(MyDataTableContext);
    const _a = tabPopupConfirm || {}, { showPopup, tabIndex: showPopupIndex, message } = _a, otherPopupProps = __rest(_a, ["showPopup", "tabIndex", "message"]);
    const { packages, tableIndex, changeTab, showFullScreen } = store;
    const _showPopupIndex = showPopupIndex !== null && showPopupIndex !== void 0 ? showPopupIndex : tableIndex;
    const expandNode = React__default.useMemo(() => {
        return (showFullScreen && (React__default.createElement("div", { className: `${prefixCls}-header-expand` },
            React__default.createElement(IconButton, { icon: (expand.direction === ExpandDirect.Right && expand.expanded) ||
                    (expand.direction === ExpandDirect.Left && !expand.expanded && packages.length > 0)
                    ? 'minimize'
                    : 'maximize', onClick: expandRight, ghost: true }))));
    }, [expand.direction, expand.expanded, expandRight, packages.length, showFullScreen]);
    return (React__default.createElement("div", { className: `${prefixCls}-header` },
        React__default.createElement("div", { className: `${prefixCls}-tabs` }, packages.map((pack, index) => {
            var _a;
            const tabCls = classNames(`${prefixCls}-tab`, {
                [`${prefixCls}-tab-active`]: tableIndex === index,
            });
            const tabName = React__default.createElement("div", { className: `${prefixCls}-tab-name` }, pack.name);
            const icon = (_a = GEO_TYPE_ICON_MAP[pack.geometryType]) !== null && _a !== void 0 ? _a : 'file';
            return (React__default.createElement("div", { className: tabCls, onClick: () => changeTab(index), key: index },
                React__default.createElement(Tooltip, { title: pack.name },
                    React__default.createElement("div", { className: `${prefixCls}-tab-left` },
                        React__default.createElement(Icon, { icon: icon, className: `${prefixCls}-tab-icon-package` }),
                        showPopup && _showPopupIndex === index ? (React__default.createElement(Popconfirm, Object.assign({ message: message, defaultVisible: true }, otherPopupProps), tabName)) : (tabName))),
                React__default.createElement(IconButton, { type: "only-icon", icon: "close", onClick: (e) => {
                        e.stopPropagation();
                        const { packageUuid } = pack;
                        delPackage && delPackage(packageUuid, e);
                    }, className: `${prefixCls}-tab-icon-close` })));
        })),
        expandNode));
});

export { DataTableHeader as default };
