import * as React from 'react';
import React__default, { useCallback, useState, useMemo, useEffect } from 'react';
import { i as __read, a5 as get, a3 as Input, aq as Icon, v as i18n$2, h as __spreadArray, ar as Checkbox, ap as GeoTypeIcon, w as appContext, s as __assign$1, y as IconButton, an as Button, J as Scrollbar, as as Drawer, aj as LazyLoad, at as userInfo, au as queryDataPkgs, av as apiDataPkgFunc, aw as GEO_TYPES_LABEL_MAP, ax as getTheme, ay as FormItem, az as Select, t as toastApi, aA as jsxRuntimeExports, I as Icon$1, b as __awaiter, c as __generator, aB as getMap, aC as getMapStyle, a9 as Spin, aD as apiMapFunc, aE as updateMap, aF as drawerApi, n as iconsUtil, z as useStaticCallback, aG as ModuleRouteEnum, aH as UpdateDataType, a7 as Menu, a8 as MenuItem, M as MapTypeSet, aI as Dropdown, ao as Tooltip, aJ as Authorized, aK as Previleges, aL as NavButton, x as Popconfirm } from './MapEditView-67426f04.js';
import { observer, useLocalStore } from 'mobx-react';
import classNames from 'classnames';
import 'perfect-scrollbar';
import { uniq, filter, map, get as get$1, size, find, uniqBy, findIndex } from 'lodash';
import { P as PromptPlaceholder } from './index-257db356.js';
import { T as Transfer, a as TransferMode } from './Transfer-20410a61.js';
import { useMount as useMount$1, useClickAway } from 'react-use';
import { useSetState, useRequest, useMount, useDebounceEffect } from 'ahooks';
import 'maptalks';
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 'perf-request';
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 '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-rnd';
import 'react-beautiful-dnd';

var prefixCls$5 = 'dm-rename';
var Rename = React__default.memo(function (_a) {
    var value = _a.value, classname = _a.classname, onChangeValue = _a.onChangeValue, placeholder = _a.placeholder, disabled = _a.disabled;
    var prevValue = React__default.useRef(value);
    var _b = __read(React__default.useState(function () { return value; }), 2), unControlVal = _b[0], setUnControlVal = _b[1];
    var inputRef = React__default.useRef({});
    var onChange = React__default.useCallback(function (e) { return setUnControlVal(e.target.value); }, []);
    var updateVal = React__default.useCallback(function (e) {
        var currentVal = get(e, 'target.value');
        if (!currentVal) {
            setUnControlVal(prevValue.current);
            onChangeValue(prevValue.current);
            return;
        }
        if (!!currentVal && currentVal !== value) {
            setUnControlVal(currentVal);
            onChangeValue(currentVal);
        }
    }, [onChangeValue, value]);
    var onPressEnter = React__default.useCallback(function () {
        var _a;
        // updateVal(e);
        (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
    }, []);
    React__default.useEffect(function () {
        if (prevValue.current !== value) {
            setUnControlVal(value);
            prevValue.current = value;
        }
    }, [value]);
    var renameCls = classNames(prefixCls$5, classname);
    return (React__default.createElement("div", { className: renameCls },
        React__default.createElement(Input, { value: unControlVal, onChange: onChange, size: "compact", onBlur: updateVal, block: true, allowClear: false, placeholder: placeholder || '', className: "".concat(prefixCls$5, "-edit-input"), onPressEnter: onPressEnter, ref: inputRef, "data-test": 'rename-input', disabled: disabled }),
        React__default.createElement(Icon, { icon: "edit", size: 16, className: "".concat(prefixCls$5, "-edit-icon") })));
});

var prefixCls$4 = 'dm-map-package-item';
var i18n$1 = i18n$2.mapEdit;
var PackageItem = React.memo(function _PackageItem(props) {
    var _a;
    var id = props.id, text = props.text, isCurrent = props.isCurrent, type = props.type, onClick = props.onClick, checkedIds = props.checkedIds, handleCheckChange = props.handleCheckChange;
    var handleCheckboxChange = useCallback(function (v) {
        if (v) {
            handleCheckChange(uniq(__spreadArray(__spreadArray([], __read(checkedIds), false), [id], false)));
        }
        else {
            handleCheckChange(filter(checkedIds, function (checkedId) { return checkedId !== id; }));
        }
    }, [checkedIds, handleCheckChange, id]);
    return (React.createElement("div", { style: { marginBottom: 6 }, className: classNames(prefixCls$4, (_a = {},
            _a["".concat(prefixCls$4, "-current")] = isCurrent,
            _a)), onClick: onClick },
        React.createElement(Checkbox, { defaultChecked: true, onChange: handleCheckboxChange, checked: checkedIds.includes(id) }),
        React.createElement(GeoTypeIcon, { type: type, size: 12, className: "".concat(prefixCls$4, "-type-icon") }),
        React.createElement("div", { className: "".concat(prefixCls$4, "-content") }, text),
        React.createElement("div", { className: "".concat(prefixCls$4, "-btn-preview") }, i18n$1.preview)));
});

var prefixCls$3 = 'dm-map-search-settings';
var i18n = i18n$2.mapEdit;
var MapSearchSettingsContent = observer(function _MapSearchSettings() {
    var _a;
    var routeStore = React.useContext(appContext.getContext()).routeStore;
    var MapSettingStore = routeStore.MapSettingStore, SuppFiltersStore = routeStore.SuppFiltersStore, GeoFiltersStore = routeStore.GeoFiltersStore;
    var currentSuppFilter = SuppFiltersStore.currentSuppFilter, setCurrentSuppFilter = SuppFiltersStore.setCurrentSuppFilter, getSuppCol = SuppFiltersStore.getCol, getSuppColList = SuppFiltersStore.getColList, getSuppColUuid = SuppFiltersStore.getColUuid, getSuppColClassification = SuppFiltersStore.getColClassification;
    var currentGeoFilter = GeoFiltersStore.currentGeoFilter, setCurrentGeoFilter = GeoFiltersStore.setCurrentGeoFilter, getGeoCol = GeoFiltersStore.getCol, getGeoColList = GeoFiltersStore.getColList, getGeoColUuid = GeoFiltersStore.getColUuid, getGeoColClassification = GeoFiltersStore.getColClassification;
    // const [init, setInit] = useState(true);
    var _b = __read(useState(currentSuppFilter ? 'supp' : 'geo'), 2), packageType = _b[0], setPackageType = _b[1];
    var suppFilters = SuppFiltersStore.suppFilters.slice();
    var geoFilters = GeoFiltersStore.geoFilters.slice();
    var setShowSearchSettings = MapSettingStore.setShowSearchSettings, searchItemDisplayFields = MapSettingStore.searchItemDisplayFields, setSearchItemDisplayFields = MapSettingStore.setSearchItemDisplayFields, searchSettingEnabledPackagesUuids = MapSettingStore.searchSettingEnabledPackagesUuids, setSearchSettingEnabledPackagesUuids = MapSettingStore.setSearchSettingEnabledPackagesUuids;
    var _c = __read(useState(searchItemDisplayFields), 2), _searchItemDisplayFields = _c[0], _setSearchItemDisplayFields = _c[1];
    var _d = __read(useState(searchSettingEnabledPackagesUuids), 2), _searchSettingEnabledPackagesUuids = _d[0], _setSearchSettingEnabledPackagesUuids = _d[1];
    var curPkg = useMemo(function () { return (packageType === 'supp' ? currentSuppFilter : currentGeoFilter); }, [currentGeoFilter, currentSuppFilter, packageType]);
    var _e = __read(useState(curPkg), 2), currentSelectUuid = _e[0], setCurrentSelectUuid = _e[1];
    // 用于界面上的操作数据，仅在提交时更新数据
    useEffect(function () {
        _setSearchItemDisplayFields(searchItemDisplayFields);
    }, [searchItemDisplayFields]);
    useEffect(function () {
        _setSearchSettingEnabledPackagesUuids(searchSettingEnabledPackagesUuids);
    }, [searchSettingEnabledPackagesUuids]);
    // 默认选中第一个分析数据包
    useEffect(function () {
        var _a, _b;
        if ((suppFilters.length || geoFilters.length) && !currentSelectUuid) {
            setCurrentSelectUuid(((_a = suppFilters[0]) === null || _a === void 0 ? void 0 : _a.uuid) || ((_b = geoFilters[0]) === null || _b === void 0 ? void 0 : _b.uuid));
            setPackageType(suppFilters.length ? 'supp' : 'geo');
        }
    }, [currentSelectUuid, geoFilters, geoFilters.length, suppFilters, suppFilters.length]);
    // const currentSuppColumns = useMemo(() => {
    //   return getSuppColList({ uuid: currentSuppFilter })?.map((i) => ({
    //     // label: i,
    //     label: i,
    //     value: i,
    //     type: getSuppColClassification({ uuid: currentSuppFilter, col: i }),
    //   }));
    // }, [currentSuppFilter, getSuppColClassification, getSuppColList]);
    var handleCancel = useCallback(function () {
        setShowSearchSettings(false);
        _setSearchItemDisplayFields(searchItemDisplayFields);
        _setSearchSettingEnabledPackagesUuids(searchSettingEnabledPackagesUuids);
    }, [setShowSearchSettings, searchItemDisplayFields, searchSettingEnabledPackagesUuids]);
    var handleOk = useCallback(function () {
        setSearchItemDisplayFields(_searchItemDisplayFields);
        setSearchSettingEnabledPackagesUuids(_searchSettingEnabledPackagesUuids);
        setShowSearchSettings(false);
    }, [
        setSearchItemDisplayFields,
        _searchItemDisplayFields,
        setSearchSettingEnabledPackagesUuids,
        _searchSettingEnabledPackagesUuids,
        setShowSearchSettings,
    ]);
    // 渲染左侧数据包
    var RenderPackageItem = useCallback(function (_a) {
        var _b;
        var items = _a.items, type = _a.type;
        return (React.createElement(React.Fragment, null, (_b = items === null || items === void 0 ? void 0 : items.map) === null || _b === void 0 ? void 0 : _b.call(items, function (item, index) {
            var _a = item, geometryType = _a.geometryType, objectType = _a.objectType, uuid = _a.uuid;
            var _onClick = function () {
                if (packageType !== type) {
                    setPackageType(type);
                }
                type === 'supp' ? setCurrentSuppFilter(uuid) : setCurrentGeoFilter(uuid);
                setCurrentSelectUuid(uuid);
            };
            return (React.createElement("div", { key: index },
                React.createElement(PackageItem, { id: uuid, isCurrent: uuid === currentSelectUuid, key: index, type: geometryType, text: objectType, onClick: _onClick, checkedIds: _searchSettingEnabledPackagesUuids, handleCheckChange: _setSearchSettingEnabledPackagesUuids })));
        })));
    }, [
        currentSelectUuid,
        _searchSettingEnabledPackagesUuids,
        packageType,
        setCurrentSuppFilter,
        setCurrentGeoFilter,
    ]);
    var currentCheckListValues = useMemo(function () {
        return map(_searchItemDisplayFields[curPkg], function (uuid) {
            return packageType === 'supp'
                ? getSuppCol({ uuid: curPkg, fieldId: uuid })
                : getGeoCol({ uuid: curPkg, fieldId: uuid });
        });
    }, [_searchItemDisplayFields, curPkg, packageType, getSuppCol, getGeoCol]);
    var handleSelectedColumnsChange = useCallback(function (selected) {
        var _a;
        // 至少有一个显示字段
        if (selected.length === 0) {
            return;
        }
        _setSearchItemDisplayFields(__assign$1(__assign$1({}, _searchItemDisplayFields), (_a = {}, _a[curPkg] = selected === null || selected === void 0 ? void 0 : selected.map(function (i) {
            return packageType === 'supp'
                ? getSuppColUuid({ uuid: curPkg, col: i })
                : getGeoColUuid({ uuid: curPkg, col: i });
        }), _a)));
    }, [_searchItemDisplayFields, curPkg, packageType, getSuppColUuid, getGeoColUuid]);
    // 更改数据包下显示字段顺序
    var handleChangeSearchItemDisplayFieldsOrder = useCallback(function (items) {
        var _a;
        // 至少有一个显示字段
        if (items.length === 0) {
            return;
        }
        _setSearchItemDisplayFields(__assign$1(__assign$1({}, _searchItemDisplayFields), (_a = {}, _a[curPkg] = items === null || items === void 0 ? void 0 : items.map(function (i) {
            return packageType === 'supp'
                ? getSuppColUuid({ uuid: curPkg, col: i })
                : getGeoColUuid({ uuid: curPkg, col: i });
        }), _a)));
    }, [_searchItemDisplayFields, curPkg, packageType, getSuppColUuid, getGeoColUuid]);
    // TODO 需优化 由于首次加载 allColumns 数据为历史数据，即使 drawer DOM 未挂载
    // memo 已经缓存了旧数据
    var checklistItems;
    if (packageType === 'supp') {
        var _f = (getSuppColList({ uuid: curPkg }) || {}).list, list = _f === void 0 ? [] : _f;
        checklistItems = list.map(function (i) { return ({
            title: i,
            key: i,
            type: getSuppColClassification({ uuid: curPkg, col: i }),
        }); });
    }
    else if (packageType === 'geo') {
        checklistItems = (_a = getGeoColList({ uuid: curPkg })) === null || _a === void 0 ? void 0 : _a.map(function (i) { return ({
            title: i,
            key: i,
            type: getGeoColClassification({ uuid: curPkg, col: i }),
        }); });
    }
    return (React.createElement("div", { className: prefixCls$3 },
        React.createElement("div", { className: "".concat(prefixCls$3, "-header") },
            React.createElement("div", { className: "".concat(prefixCls$3, "-header-title") },
                React.createElement(IconButton, { icon: "close", type: "only-icon", onClick: handleCancel }),
                React.createElement("span", null, i18n.searchSettings)),
            React.createElement("div", null,
                React.createElement(Button, { className: "".concat(prefixCls$3, "-header-cancel-button"), onClick: handleCancel }, i18n.cancelText),
                React.createElement(Button, { type: "primary", onClick: handleOk }, i18n.okText))),
        suppFilters.length || geoFilters.length ? (React.createElement("div", { className: "".concat(prefixCls$3, "-body") },
            React.createElement("div", { className: "".concat(prefixCls$3, "-body-item") },
                React.createElement(Scrollbar, null,
                    React.createElement("div", { className: "".concat(prefixCls$3, "-body-item-title") }, i18n.packageConfig.dataTitle),
                    React.createElement("div", { className: "".concat(prefixCls$3, "-body-item-sub-title") }, i18n.packageConfig.dataSubTitle),
                    React.createElement(RenderPackageItem, { items: suppFilters, type: "supp" }),
                    React.createElement("div", { className: "".concat(prefixCls$3, "-body-item-title") }, i18n.packageConfig.fenceTitle),
                    React.createElement("div", { className: "".concat(prefixCls$3, "-body-item-sub-title") }, i18n.packageConfig.fenceSubTitle),
                    React.createElement(RenderPackageItem, { items: geoFilters, type: "geo" }))),
            React.createElement(Transfer, { height: "100%", showCount: false, 
                // allowClear
                mode: TransferMode.plain, value: currentCheckListValues, options: checklistItems, sortable: true, checkListDescriptionText: i18n$2.mapEdit.selectedFieldsToDisplayInSearching, onChange: handleSelectedColumnsChange, onRemove: handleChangeSearchItemDisplayFieldsOrder, checkListDynamicRowHeight: true }))) : (React.createElement(PromptPlaceholder, { imgType: "no-content", description: i18n.noSearchSettingData }))));
});
var MapSearchSettings = observer(function () {
    var routeStore = React.useContext(appContext.getContext()).routeStore;
    var MapSettingStore = routeStore.MapSettingStore;
    var showSearchSettings = MapSettingStore.showSearchSettings, setShowSearchSettings = MapSettingStore.setShowSearchSettings;
    var handleClose = useCallback(function () {
        setShowSearchSettings(false);
    }, [setShowSearchSettings]);
    return (React.createElement(Drawer, { level: null, handler: false, open: showSearchSettings, onClose: handleClose, width: 766, className: "map-drawer", maskClosable: false }, showSearchSettings && React.createElement(MapSearchSettingsContent, null)));
});

// 登录页面路由
// ailab 列表路由
var AILABLIST_PATH = '/ailab-list';
// ailab 编辑路由
var AILABEDIT_PATH = '/ailab/:type/:id';
// 我的项目路由
var MY_PROJECT_PATH = '/my-project';
// 我的数据路由
var MY_DATA_PATH = '/my-data';
// // 新版我的数据路由
// export const MY_DATA_NEW_PATH = '/my-data-new';
// 数据中心路由
var DATA_CENTER_PATH = '/data-center';
// 工作组路由
var WORK_GROUP_PATH = '/work-group';
// 工作台路由
var WORKBENCH_PATH = '/workbench';
// 工作台编辑
var WORKBENCH_EDIT_PATH = '/workbench/:page_type/:type/:id';
// Host路由
var HOST_PATH = '/host';
// qe路由
var QE_EDIT_PATH = '/qe-edit/:type/:id';
// map-edit 路由
var MAPEDIT_PATH = '/mapv/:type/:id';
// 脚本列表路由
var SCRIPT_LIST_PATH = '/script-list/';
// 脚本编辑路由
var SCRIPT_EDIT_PATH = '/script-edit/:type/:id';
// data-lake路由
var DATA_LAKE_EDIT_PATH = '/data-lake-edit/:type/:id';
// app管理路由
var APP_MANAGER_PATH = '/app-manager';
//低码路由
var SLIGHT_CODE = '/slight-code/:type/:id';
// 单个卡片预览
var PREVIEW_PATH = '/preview/:id';
//多个卡片预览 侧栏预览
var ASIDE_PREVIEW_PATH = '/aside-preview/:id';

var _a;
var dataLayerPageView = function (type, behavior, time, name) {
    if (window.dataLayer) {
        window.dataLayer.push({
            event: 'page_view',
            type: type,
            behavior: behavior || '-',
            name: name || '-',
            time: time || 0,
        });
    }
};
(_a = {},
    _a[MY_DATA_PATH] = 'mydata',
    _a[DATA_CENTER_PATH] = 'datacenter',
    _a[WORK_GROUP_PATH] = 'team',
    _a[MY_PROJECT_PATH] = 'myproject',
    _a[AILABLIST_PATH] = 'lab',
    _a[AILABEDIT_PATH] = 'lab',
    _a[WORKBENCH_PATH] = 'page',
    _a[WORKBENCH_EDIT_PATH] = 'page',
    _a[HOST_PATH] = '/host',
    _a[QE_EDIT_PATH] = 'chart',
    _a[MAPEDIT_PATH] = 'map',
    _a[SCRIPT_LIST_PATH] = 'script',
    _a[SCRIPT_EDIT_PATH] = 'script',
    _a[DATA_LAKE_EDIT_PATH] = 'chart',
    _a[APP_MANAGER_PATH] = 'app-manager',
    _a[SLIGHT_CODE] = 'chart',
    _a[PREVIEW_PATH] = 'page',
    _a[ASIDE_PREVIEW_PATH] = 'page',
    _a);
// (function () {
//   let start = new Date().getTime();
//   let text = '';
//   if ((window.location.hash.split('#/')[1] || '').startsWith('my-project')) {
//     let dataVal = '';
//     let timer = -1;
//     let allNav = document.querySelectorAll('.dmc-side-nav-item');
//     const pageModule = () => {
//       const event = function () {
//         const now = new Date().getTime();
//         dataLayerPageView(PageTypeMap[dataVal], '-', now - start, '-');
//         start = now;
//         dataVal = (this as HTMLDivElement).getAttribute('data-value') || '';
//       };
//       const curNav = document.querySelector('.dmc-side-nav-item-actived') as HTMLDivElement;
//       if (curNav) {
//         dataVal = curNav.getAttribute('data-value') || '';
//       }
//       (allNav || []).forEach((nav) => {
//         nav.removeEventListener('click', event);
//         nav.addEventListener('click', event);
//       });
//     };
//     timer = window.setInterval(() => {
//       allNav = document.querySelectorAll('.dmc-side-nav-item');
//       if (allNav.length > 0) {
//         clearInterval(timer);
//         pageModule();
//       }
//     }, 300);
//     if (allNav.length === 0) return;
//   }
//   //headMenu
//   let headMenus = document.querySelectorAll('dm-app-header-menu-item');
//   if (!headMenus.length) {
//     let headMenuTimer = -1;
//     const headMenusModule = () => {
//       const event = function () {
//         const now = new Date().getTime();
//         // dataLayerPageView(PageTypeMap[dataVal], '-', now - start, '-');
//         start = now;
//         // @ts-ignore
//         dataVal = (this as HTMLDivElement).getAttribute('data-value') || '';
//       };
//       const headMenus = document.querySelectorAll('dm-app-header-menu-item');
//       (headMenus || []).forEach((menu) => {
//         menu.removeEventListener('click', event);
//         menu.addEventListener('click', event);
//       });
//     };
//     headMenuTimer = window.setInterval(() => {
//       headMenus = document.querySelectorAll('dm-app-header-menu-item');
//       if (headMenus.length > 0) {
//         clearInterval(headMenuTimer);
//         headMenusModule();
//       }
//     }, 300);
//   }
// })();
var sendPage = function (type, behavior, title, time) {
    var now = new Date().getTime();
    if (time) {
        var dis = now - time;
        dataLayerPageView(type, behavior, dis, title || '');
    }
    return now;
};

var MapSettings = LazyLoad(function () {
    return import('./index-414f7d63.js');
});
var prefixCls$2 = 'dm-map-menu-setting';
var MenuSettings = observer(function () {
    return (React.createElement("div", { className: prefixCls$2 },
        React.createElement(MapSettings, null)));
});

var ReplacePackage = function (props) {
    var _a = props.originState, originState = _a === void 0 ? {} : _a, _b = props.originPackage, originPackage = _b === void 0 ? {} : _b, changeRef = props.changeRef;
    console.log(props);
    // if (!originPackage) return null;
    var _c = originPackage; _c.objectType; var packageUuid = _c.packageUuid; _c.geometryType; var _d = _c.useColumns, useColumns = _d === void 0 ? [] : _d;
    var _e = __read(useSetState({
        searchText: '',
        searchList: [],
        datapkgId: originState.selectedPackageUuid || '',
        objectType: originState.selectedObjectType || '',
        geometryType: originState.selectedGeometryType || '',
        columns: [],
        selectColumns: originState.selectedColumns || {},
    }), 2), state = _e[0], setState = _e[1];
    console.log(originState, 'originState');
    console.log(state, 'state');
    var _f = useRequest(function () {
        var params = {
            dataPkgsQuery: {
                privilege: 'read',
            },
            apps: userInfo.getAllAppIds(),
            pageSize: 50,
            pageNum: 0,
        };
        if (state.searchText) {
            // @ts-ignore
            params.dataPkgsQuery.name = state.searchText;
        }
        return queryDataPkgs(params);
    }, {
        cacheKey: 'package-cache-key' + packageUuid,
        refreshDeps: [state.searchText],
        // staleTime: 30000,
        debounceWait: 300,
        // manual: true,
    }), packageResp = _f.data, packageLoading = _f.loading;
    var _g = useRequest(function () {
        return apiDataPkgFunc().getDataPkgColumns({
            datapkgId: state.datapkgId,
        });
    }, {
        cacheKey: 'package-cache-column' + packageUuid,
        refreshDeps: [state.datapkgId],
        ready: !!state.datapkgId,
    }), columnsResp = _g.data; _g.runAsync;
    useMount(function () {
        console.log('ReplacePackage====', originState);
        setState({
            datapkgId: originState.selectedPackageUuid || '',
            objectType: originState.selectedObjectType || '',
            geometryType: originState.selectedGeometryType || '',
            selectColumns: originState.selectedColumns || {},
        });
    });
    React__default.useEffect(function () {
        var _a;
        console.log(columnsResp);
        var columns = map(((_a = columnsResp === null || columnsResp === void 0 ? void 0 : columnsResp.data) === null || _a === void 0 ? void 0 : _a.result) || [], function (column) {
            return __assign$1({ key: column.id, label: column.name, value: column.name }, column);
        });
        columns.unshift({
            key: i18n$2.mapEdit.replacePackage.empty,
            label: i18n$2.mapEdit.replacePackage.empty,
            value: i18n$2.mapEdit.replacePackage.empty,
        });
        setState({
            columns: columns,
        });
    }, [columnsResp, setState]);
    React__default.useEffect(function () {
        var data = packageResp;
        var result = map(get$1(data, 'data.result') || [], function (item) {
            console.log(item, 'item');
            var geometryType = item.geometry_type;
            var name = GEO_TYPES_LABEL_MAP[geometryType];
            return __assign$1({ key: item.id, label: name + '-' + item.name, value: item.id }, item);
        });
        if (size(result) > 0) {
            result.unshift({
                key: i18n$2.mapEdit.replacePackage.empty,
                label: i18n$2.mapEdit.replacePackage.empty,
                value: i18n$2.mapEdit.replacePackage.empty,
            });
        }
        var searchList = (size(result) > 0
            ? result
            : [
                {
                    key: i18n$2.mapEdit.replacePackage.none,
                    label: i18n$2.mapEdit.replacePackage.none,
                    value: i18n$2.mapEdit.replacePackage.none,
                },
            ]);
        setState({
            searchList: searchList,
        });
    }, [packageResp, setState]);
    var _onSearch = function (value) {
        setState({
            searchText: value,
        });
    };
    var _onSelectPackage = function (value) {
        var isNone = value === i18n$2.mapEdit.replacePackage.empty;
        if (isNone) {
            setState({
                datapkgId: '',
                geometryType: '',
                objectType: '',
                columns: [],
                selectColumns: {},
            });
        }
        else {
            var pkg = find(get$1(packageResp, 'data.result'), { id: value });
            setState({
                datapkgId: value,
                geometryType: (pkg === null || pkg === void 0 ? void 0 : pkg.geometry_type) || '',
                objectType: (pkg === null || pkg === void 0 ? void 0 : pkg.name) || '',
            });
        }
    };
    var _onSelectColumn = function (originColumn, column) {
        var isNone = column === i18n$2.mapEdit.replacePackage.empty;
        var selectColumns = state.selectColumns;
        if (isNone) {
            delete selectColumns[originColumn];
        }
        else {
            selectColumns[originColumn] = column;
        }
        var values = Object.values(selectColumns);
        var lenOrigin = values === null || values === void 0 ? void 0 : values.length;
        var len = __spreadArray([], __read(new Set(values)), false).length;
        if (lenOrigin !== len) {
            toastApi.warning('重复选择列:' + column);
        }
        console.log(state.columns, 'columns');
        console.log(selectColumns, 'selectColumns');
        setState({
            selectColumns: selectColumns,
        });
    };
    // React.useImperativeHandle(ref, () => {
    //   return {
    //     originPackageUuid: packageUuid,
    //     selectedPackageUuid: state.datapkgId,
    //     selectedObjectType: state.objectType,
    //     selectedGeometryType: state.geometryType,
    //     selectedColumns: state.selectColumns,
    //   };
    // });
    useDebounceEffect(function () {
        console.log('state change');
        // TODO modify father comp state
        var data = {
            originPackageUuid: packageUuid,
            selectedPackageUuid: state.datapkgId,
            selectedObjectType: state.objectType,
            selectedGeometryType: state.geometryType,
            selectedColumns: state.selectColumns,
        };
        changeRef === null || changeRef === void 0 ? void 0 : changeRef(data);
    }, [state.datapkgId, state.objectType, state.geometryType, state.selectColumns], {
        wait: 200,
    });
    return (React__default.createElement("div", { className: "dmc-replace-package", "data-theme": getTheme() },
        React__default.createElement("div", { className: "dmc-replace-package-content" },
            React__default.createElement(FormItem, { label: "\u66FF\u6362\u6570\u636E\u5305", required: true, direction: "column" },
                React__default.createElement(Select, { placeholder: i18n$2.mapEdit.replacePackage.placeholderPkg, showSearch: true, value: state.objectType, options: state.searchList, onSearch: _onSearch, onSelect: _onSelectPackage, loading: packageLoading, className: "mb16" }))),
        size(useColumns) > 0 && (React__default.createElement(FormItem, { label: "\u66FF\u6362\u5B57\u6BB5", required: true, direction: "column" },
            React__default.createElement("div", { className: "dmc-replace-package-column-content" }, map(useColumns, function (column, index) {
                var _a;
                return (React__default.createElement("div", { className: "mt4", style: { display: 'flex', alignItems: 'center' }, key: index },
                    React__default.createElement("div", { style: { flex: 1 } },
                        React__default.createElement("div", { className: "dmc-replace-package-origin-package small" }, column.column)),
                    React__default.createElement("div", { className: "dmc-replace-package-content-equal" }, "="),
                    React__default.createElement("div", { style: { flex: 1 } },
                        React__default.createElement(Select, { placeholder: i18n$2.mapEdit.replacePackage.placeholderCol, showSearch: true, value: (_a = state.selectColumns) === null || _a === void 0 ? void 0 : _a[column.column], 
                            // @ts-ignore
                            options: state.columns, onSearch: _onSearch, onSelect: function (value) { return _onSelectColumn(column.column, value); } }))));
            }))))));
};

var __assign = undefined && undefined.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

var __rest = undefined && undefined.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};
var prefixCls$1 = 'dmc-page-header';

var PageHeader = function PageHeader(props) {
  var className = props.className,
      style = props.style,
      children = props.children,
      restProps = __rest(props, ["className", "style", "children"]);

  return jsxRuntimeExports.jsx("div", __assign({}, restProps, {
    className: classNames(prefixCls$1, className),
    style: style
  }, {
    children: children
  }), void 0);
};

PageHeader.displayName = 'PageHeader';
var PageHeaderMemo = /*#__PURE__*/React.memo(PageHeader);
PageHeaderMemo.displayName = 'PageHeaderMemo';

var GeoIcon = function (props) {
    var geoType = (props || {}).geoType;
    if (geoType === 'polygon') {
        return React__default.createElement(Icon$1, { icon: "layer", size: 14 });
    }
    else if (geoType === 'line') {
        return React__default.createElement(Icon$1, { icon: "line", size: 14 });
    }
    else if (geoType === 'point') {
        return React__default.createElement(Icon$1, { icon: "location", size: 14 });
    }
    else {
        return React__default.createElement(Icon$1, { icon: "help", size: 14 });
    }
};
var OriginPackageButton = function (props) {
    var onClick = props.onClick, className = props.className, geometryType = props.geometryType, objectType = props.objectType, packageUuid = props.packageUuid;
    return (React__default.createElement("div", { className: classNames(['dmc-replace-package-origin-package', className], {}), onClick: onClick },
        React__default.createElement(GeoIcon, { geoType: geometryType }),
        objectType || packageUuid));
};

var GeoType = 'geo';
var SuppType = 'supp';
var ReplacePackageDialogContent = function (props) {
    var mapUid = props.mapUid, mapStyleUid = props.mapStyleUid, onClose = props.onClose, onOk = props.onOk, projectOption = props.projectOption;
    var _a = useRequest(function () { return __awaiter(void 0, void 0, void 0, function () {
        var resp;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, getMap({
                        id: mapUid,
                        versionId: projectOption === null || projectOption === void 0 ? void 0 : projectOption.version,
                    })];
                case 1:
                    resp = _a.sent();
                    resp = get$1(resp, 'data.result');
                    return [2 /*return*/, resp];
            }
        });
    }); }, {
        cacheKey: 'mapUid',
        refreshDeps: [mapUid],
    }), mapData = _a.data, mapDataLoading = _a.loading;
    var _b = useRequest(function () { return __awaiter(void 0, void 0, void 0, function () {
        var resp;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, getMapStyle({
                        id: mapStyleUid,
                        versionId: projectOption === null || projectOption === void 0 ? void 0 : projectOption.version,
                    })];
                case 1:
                    resp = _a.sent();
                    resp = get$1(resp, 'data.result');
                    return [2 /*return*/, resp];
            }
        });
    }); }, {
        cacheKey: 'mapStyleUid',
        refreshDeps: [mapStyleUid],
    }), mapStyleData = _b.data, mapStyleDataLoading = _b.loading;
    var _c = __read(useSetState({
        suppFilters: [],
        geoFilters: [],
        selectedType: SuppType,
        selectedIndex: 0,
    }), 2), state = _c[0], setState = _c[1];
    React__default.useEffect(function () {
        // @ts-ignore
        var _a = (mapData || {}).dbInfo, dbInfo = _a === void 0 ? {} : _a;
        var suppFilters = map(dbInfo.suppFilters, function (f) {
            return f;
        });
        var geoFilters = map(dbInfo.geoFilters, function (f) {
            return f;
        });
        setState({
            suppFilters: suppFilters,
            geoFilters: geoFilters,
        });
    }, [mapData, setState]);
    var suppRefs = React__default.useRef([]);
    var geoRefs = React__default.useRef([]);
    var _onOk = function () { return __awaiter(void 0, void 0, void 0, function () {
        var changeFilter, isRepeat, suppFilters, geoFilters, dbInfo, updateResp, cards;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    if (mapStyleDataLoading || mapDataLoading) {
                        return [2 /*return*/];
                    }
                    if (!mapStyleData || !mapData) {
                        toastApi.warning('need map data; please refresh and try again.');
                        return [2 /*return*/];
                    }
                    // TODO dialog confirm
                    console.log(suppRefs, 'suppRefs');
                    changeFilter = function (f, ref) {
                        if (!ref) {
                            return f;
                        }
                        if (ref.selectedPackageUuid)
                            f.packageUuid = ref.selectedPackageUuid;
                        if (ref.selectedGeometryType)
                            f.geometryType = ref.selectedGeometryType;
                        if (ref.selectedObjectType)
                            f.objectType = ref.selectedObjectType;
                        if (size(ref.selectedColumns) > 0 && f.useColumns) {
                            for (var key in ref.selectedColumns) {
                                var index = findIndex(f.useColumns, { column: key });
                                if (index > -1) {
                                    f.useColumns[index].column = ref.selectedColumns[key];
                                }
                            }
                        }
                        return f;
                    };
                    isRepeat = false;
                    suppFilters = map(state.suppFilters, function (f, index) {
                        var ref = suppRefs.current[index];
                        var _f = changeFilter(f, ref);
                        var len = size(_f.useColumns);
                        var lenUniq = size(uniqBy(_f.useColumns, 'column'));
                        if (len !== lenUniq) {
                            isRepeat = true;
                        }
                        return _f;
                    });
                    geoFilters = map(state.geoFilters, function (f, index) {
                        var ref = geoRefs.current[index];
                        var _f = changeFilter(f, ref);
                        var len = size(_f.useColumns);
                        var lenUniq = size(uniqBy(_f.useColumns, 'column'));
                        if (len !== lenUniq) {
                            isRepeat = true;
                        }
                        return _f;
                    });
                    dbInfo = { suppFilters: suppFilters, geoFilters: geoFilters };
                    console.log(dbInfo, 'dbInfo');
                    if (isRepeat) {
                        toastApi.warning(i18n$2.mapEdit.replacePackage.errorMessage);
                        return [2 /*return*/];
                    }
                    return [4 /*yield*/, updateMap({
                            id: mapUid,
                            // @ts-ignore
                            revision: mapData.update_time,
                            map1: {
                                // @ts-ignore
                                dbInfo: dbInfo,
                            },
                            versionId: projectOption === null || projectOption === void 0 ? void 0 : projectOption.version,
                        })];
                case 1:
                    updateResp = _a.sent();
                    console.log(mapStyleData, 'mapStyleData');
                    cards = map(get$1(mapStyleData, 'cards') || [], function (card) {
                        card.name = '';
                        return card;
                    });
                    return [4 /*yield*/, apiMapFunc().patchSingleMapStyle({
                            id: mapStyleUid,
                            // @ts-ignore
                            revision: mapStyleData.update_time,
                            mapStyle1: {
                                cards: cards,
                            },
                            versionId: projectOption === null || projectOption === void 0 ? void 0 : projectOption.version,
                        })];
                case 2:
                    _a.sent();
                    console.log(updateResp, 'updateResp');
                    if (get$1(updateResp, 'data.rc') === 0) {
                        toastApi.success('替换成功');
                    }
                    onOk === null || onOk === void 0 ? void 0 : onOk();
                    onClose === null || onClose === void 0 ? void 0 : onClose();
                    return [2 /*return*/];
            }
        });
    }); };
    var selectedFilters = state.selectedType === SuppType ? state.suppFilters : state.geoFilters;
    console.log(suppRefs, 'suppRefs');
    console.log(geoRefs, 'geoRefs');
    var replaceRefs = state.selectedType === SuppType ? suppRefs : geoRefs;
    return (React__default.createElement("div", { className: "dmc-map-replace-package-dialog-content" },
        React__default.createElement(PageHeader, null,
            React__default.createElement("div", { className: "dmc-map-replace-package-header" },
                React__default.createElement(Icon$1, { style: { marginRight: 12, cursor: 'pointer' }, icon: "close", size: 16, onClick: onClose }),
                React__default.createElement("div", null, "\u66FF\u6362\u6570\u636E"),
                React__default.createElement("div", { style: { flex: 1 } }),
                React__default.createElement(Button, { onClick: onClose, className: "mr8" }, i18n$2.mapEdit.cancelText),
                React__default.createElement(Button, { type: "primary", onClick: _onOk, disabled: mapDataLoading || mapStyleDataLoading }, i18n$2.mapEdit.okText))),
        (mapDataLoading || mapStyleDataLoading) && (React__default.createElement("div", { className: 'dmc-map-replace-package-dialog-loading' },
            React__default.createElement(Spin, null))),
        !mapDataLoading && !mapStyleDataLoading && (React__default.createElement("div", { className: "dmc-map-replace-package-content" },
            React__default.createElement("div", { className: "dmc-map-replace-package-content-left" },
                size(state.suppFilters) > 0 && (React__default.createElement("div", null, i18n$2.mapEdit.packageConfig.dataTitle)),
                map(state.suppFilters, function (f, index) {
                    var className;
                    if (state.selectedType === SuppType && state.selectedIndex === index) {
                        className = 'selected';
                    }
                    return (React__default.createElement(OriginPackageButton, { key: index, className: className, geometryType: f.geometryType || '', packageUuid: f.packageUuid, objectType: f.objectType, onClick: function () {
                            setState({
                                selectedIndex: index,
                                selectedType: SuppType,
                            });
                        } }));
                }),
                size(state.geoFilters) > 0 && (React__default.createElement("div", { className: "mt20" }, i18n$2.mapEdit.packageConfig.fenceTitle)),
                map(state.geoFilters, function (f, index) {
                    var className;
                    if (state.selectedType === GeoType && state.selectedIndex === index) {
                        className = 'selected';
                    }
                    return (React__default.createElement(OriginPackageButton, { key: index, className: className, geometryType: f.geometryType || '', packageUuid: f.packageUuid, objectType: f.objectType, onClick: function () {
                            setState({
                                selectedIndex: index,
                                selectedType: GeoType,
                            });
                        } }));
                })),
            React__default.createElement("div", { className: "dmc-map-replace-package-content-right" },
                React__default.createElement(ReplacePackage, { key: state.selectedType + state.selectedIndex, originState: replaceRefs.current[state.selectedIndex], originPackage: selectedFilters[state.selectedIndex], changeRef: function (f) {
                        replaceRefs.current[state.selectedIndex] = f;
                    } }))))));
};

var openReplacePackage = function (props) { return __awaiter(void 0, void 0, void 0, function () {
    return __generator(this, function (_a) {
        drawerApi.open(function (onClose) {
            var mapUid = props.mapUid, mapStyleUid = props.mapStyleUid, onOk = props.onOk, projectOption = props.projectOption;
            return (React__default.createElement(ReplacePackageDialogContent, { mapUid: mapUid, mapStyleUid: mapStyleUid, onClose: onClose, projectOption: projectOption, onOk: onOk }));
        }, {
            width: '900px',
        });
        return [2 /*return*/];
    });
}); };

var toggleShowCustomIconSetting = iconsUtil.toggleShowCustomIconSetting;
var prefixCls = 'dm-map-edit-header';
var EditHeader = observer(function () {
    var _a = React.useContext(appContext.getContext()), routeStore = _a.routeStore, appStore = _a.appStore, _onSave = _a._onSave, _onClose = _a._onClose;
    var MapSettingStore = routeStore.MapSettingStore, SaveStore = routeStore.SaveStore, mapName = routeStore.mapName, changeMapName = routeStore.changeMapName, clearSearch = routeStore.SearchStore.clearSearch, noData = routeStore.noData, dataReady = routeStore.dataReady, type = routeStore.type, projectOption = routeStore.projectOption, mapUid = routeStore.mapUid, mapStyleUid = routeStore.mapStyleUid, resetMapStyle = routeStore.EmitStore.resetMapStyle;
    var setShowSearchSettings = MapSettingStore.setShowSearchSettings, changeShowMapSettings = MapSettingStore.changeShowMapSettings, setShowMapSettings = MapSettingStore.setShowMapSettings, changePackageConfigShow = MapSettingStore.changePackageConfigShow, setPackageConfigShow = MapSettingStore.setPackageConfigShow, showMapSettings = MapSettingStore.showMapSettings, packageConfigShow = MapSettingStore.packageConfigShow, changeCurrentDataList = MapSettingStore.changeCurrentDataList, can3D = MapSettingStore.can3D;
    var saveMap = SaveStore.saveMap, loading = SaveStore.loading;
    var store = useLocalStore(function () {
        return {
            showPackageModelList: false,
            showMoreSettings: false,
        };
    });
    var showMoreSettings = store.showMoreSettings, showPackageModelList = store.showPackageModelList;
    var toggleShowPackageModelList = useCallback(function () {
        store['showPackageModelList'] = !store['showPackageModelList'];
    }, [store]);
    var toggleShowMoreSettings = useCallback(function () {
        store['showMoreSettings'] = !store['showMoreSettings'];
    }, [store]);
    var dataLayerRef = React.useRef({
        time: 0,
    });
    useMount$1(function () {
        dataLayerRef.current = {
            time: new Date().getTime(),
        };
    });
    // const history = useHistory();
    var ref = React.useRef(null);
    var refList = React.useRef(null);
    var wrapperRef = React.useRef(null);
    var handleShowCustomIconSetting = useCallback(function () {
        toggleShowCustomIconSetting(undefined, function (show) {
            if (show && packageConfigShow) {
                changePackageConfigShow();
            }
        });
    }, [changePackageConfigShow, packageConfigShow]);
    var back = useStaticCallback(function () {
        if (dataLayerRef.current && dataLayerRef.current.time) {
            var now = sendPage('map', 'edit', mapName || '', dataLayerRef.current.time);
            dataLayerRef.current.time = now;
        }
        if (_onClose) {
            _onClose && _onClose();
            return;
        }
        var route = appStore.getTypeRoute(ModuleRouteEnum.MyProject);
        if (projectOption === null || projectOption === void 0 ? void 0 : projectOption.id) {
            route = appStore.getTypeRoute(ModuleRouteEnum.Projects) + "?projectid=".concat(projectOption.id);
            // route = route.replace(':id', projectOption.id);
        }
        appStore.goToRoute(route);
    });
    var replacetoEditRoute = useStaticCallback(function (id) {
        if (!id)
            return;
        var route = appStore.getTypeRoute(ModuleRouteEnum.MapEdit);
        route = route.replace(':type', UpdateDataType.edit).replace(':id', id);
        if (projectOption === null || projectOption === void 0 ? void 0 : projectOption.version) {
            route += "?projectid=".concat(projectOption.id, "&versionid=").concat(projectOption.version);
        }
        appStore.goToRoute(route);
    });
    var _saveAndLeaveMap = useStaticCallback(function () {
        if (_onSave) {
            saveMap(function (uuid, preview) {
                _onSave(uuid, preview);
                back();
            });
            return;
        }
        saveMap(back);
    });
    var _saveMap = useStaticCallback(function () {
        var cb = _onSave ? undefined : replacetoEditRoute;
        saveMap(cb);
    });
    var handleAddPackage = useStaticCallback(function () {
        changePackageConfigShow();
        clearSearch();
    });
    var renderMoreSettings = useMemo(function () {
        var handleClick = function () {
            setShowSearchSettings(true);
            toggleShowMoreSettings();
            setPackageConfigShow(false);
            setShowMapSettings(false);
        };
        return (React.createElement(Menu, null,
            React.createElement(MenuItem, { onMouseLeave: toggleShowMoreSettings, key: i18n$2.mapEdit.searchSettings, title: i18n$2.mapEdit.searchSettings, onClick: handleClick }, i18n$2.mapEdit.searchSettings)));
    }, [setShowSearchSettings, setPackageConfigShow, toggleShowMoreSettings, setShowMapSettings]);
    useClickAway(refList, function (e) {
        var _a;
        var clickInsideWrap = !!((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target));
        if (!clickInsideWrap) {
            store.showPackageModelList = false;
        }
    });
    var renderMoreList = useMemo(function () {
        return (React.createElement("div", { ref: wrapperRef },
            React.createElement(Menu, null,
                React.createElement(MenuItem, { key: i18n$2.mapEdit.package, title: i18n$2.mapEdit.package, onClick: function () {
                        changeCurrentDataList('package');
                        store.showPackageModelList = false;
                    } }, i18n$2.mapEdit.package),
                React.createElement(MenuItem, { key: i18n$2.mapEdit.model, title: i18n$2.mapEdit.model, onClick: function () {
                        if (!can3D) {
                            toastApi.warning(i18n$2.mapEdit.setMapViewWarning);
                            return;
                        }
                        changeCurrentDataList('model');
                        store.showPackageModelList = false;
                    } }, i18n$2.mapEdit.model))));
    }, [can3D, changeCurrentDataList, store]);
    var cantSave;
    if (MapTypeSet.add === type) {
        cantSave = loading;
    }
    else {
        cantSave = loading || !dataReady;
    }
    return (React.createElement("div", { className: prefixCls, ref: ref },
        React.createElement("div", { className: "".concat(prefixCls, "-name") },
            React.createElement("div", { className: "".concat(prefixCls, "-name-icon") },
                React.createElement(IconButton, { icon: "map-outlined" })),
            React.createElement(Rename, { value: mapName, placeholder: i18n$2.mapEdit.untitledMap, classname: "".concat(prefixCls, "-rename"), onChangeValue: changeMapName }),
            React.createElement("div", null,
                React.createElement(Button, { size: "compact", onClick: handleAddPackage, "data-test": "map-package-config-button" }, packageConfigShow ? (React.createElement(React.Fragment, null,
                    React.createElement(Icon$1, { icon: "fold-left", className: "mr8", size: 16 }),
                    i18n$2.mapEdit.collapsePanel)) : (React.createElement(React.Fragment, null,
                    React.createElement(Icon$1, { icon: "add", className: "mr8", size: 16 }),
                    i18n$2.mapEdit.addPackage)))),
            React.createElement(Dropdown, { trigger: "click", visible: showPackageModelList, overlay: renderMoreList, placement: "bottomLeft" },
                React.createElement("div", { ref: refList },
                    React.createElement(Button, { size: "compact", className: "".concat(prefixCls, "-icon-button ml6"), onClick: toggleShowPackageModelList },
                        React.createElement(Icon$1, { icon: "arrow-down", size: 16 })))),
            React.createElement(Dropdown, { trigger: "click", visible: showMoreSettings, overlay: renderMoreSettings, placement: "bottomLeft" },
                React.createElement(Button, { size: "compact", onClick: toggleShowMoreSettings, className: "ml6", "data-test": "map-header-show-more-settings" },
                    React.createElement(Icon$1, { icon: "more-horizontal" })))),
        React.createElement(Dropdown, { destroyPopupOnHide: true, overlayClassName: "map-drawer", trigger: "click", visible: showMapSettings, overlay: React.createElement(MenuSettings, null), placement: "bottomLeft" },
            React.createElement("div", { className: "".concat(prefixCls, "-setting") },
                type === MapTypeSet.edit && (React.createElement(Tooltip, { title: i18n$2.mapEdit.replacePackage.replaceData },
                    React.createElement(Button, { leftIcon: "swap-horiz", size: "compact", onClick: function () {
                            openReplacePackage({
                                projectOption: projectOption,
                                mapStyleUid: mapStyleUid,
                                mapUid: mapUid || '',
                                onOk: resetMapStyle,
                            });
                        }, className: "mr4" }, "\u6570\u636E\u66FF\u6362"))),
                React.createElement(Authorized, { authority: Previleges.updateAppPreference },
                    React.createElement(Tooltip, { title: i18n$2.mapEdit.customIcon },
                        React.createElement(Button, { onlyIcon: "location-3", size: "compact", onClick: handleShowCustomIconSetting, className: "mr4" }))),
                React.createElement(Tooltip, { title: i18n$2.mapEdit.mapSettings.mapSettings },
                    React.createElement(Button, { onlyIcon: "setting", size: "compact", onClick: changeShowMapSettings, "data-test": "map-settings-btn" })))),
        React.createElement(MapSearchSettings, null),
        React.createElement("div", { className: "".concat(prefixCls, "-btns") },
            React.createElement(NavButton, { onClick: _saveMap, disabled: cantSave }, i18n$2.mapEdit.save),
            React.createElement("div", { className: "".concat(prefixCls, "-btns-line") }),
            noData ? (React.createElement(NavButton, { type: "danger", className: 'mr8', onClick: back }, i18n$2.mapEdit.giveUp)) : (React.createElement(Popconfirm, { destroyTooltipOnHide: true, overlayClassName: "".concat(prefixCls, "-pop"), placement: "bottomRight", okText: i18n$2.mapEdit.okText, cancelText: i18n$2.mapEdit.cancelText, message: "".concat(i18n$2.mapEdit.confirmGiveUp).concat(i18n$2.mapEdit.questionMark), trigger: "click", emotion: 'help-2', onConfirm: back },
                React.createElement(NavButton, { type: "danger", className: 'mr8' }, i18n$2.mapEdit.giveUp))),
            React.createElement(NavButton, { type: "success", onClick: _saveAndLeaveMap, disabled: cantSave }, i18n$2.mapEdit.finish))));
});
EditHeader.whyDidYouRender = true;
EditHeader.displayName = 'EditHeader';
var EditHeader$1 = EditHeader;

export { EditHeader$1 as default };
