import { i as __read, y as IconButton, s as __assign, as as GeoTypeIcon, ar as Tooltip, a6 as Input } from './MapEditView-24782753.js';
import * as React from 'react';
import classNames from 'classnames';
import { useToggle } from 'react-use';

var prefixCls = 'dm-map-package-wrapper';
var PackageWrapper = React.memo(function (props) {
    var _a;
    var text = props.text, alias = props.alias, isCurrent = props.isCurrent, type = props.type, deleteTitle = props.deleteTitle, onDelete = props.onDelete, onClick = props.onClick, onChangeText = props.onChangeText, provided = props.provided, onEdit = props.onEdit;
    var _b = __read(useToggle(false), 2), inEdit = _b[0], toggle = _b[1];
    var enter = function (e) {
        var _a;
        var value = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value;
        onChangeText && onChangeText(value);
        toggle(false);
    };
    return (React.createElement("div", { style: { marginBottom: 4 }, className: classNames(prefixCls, (_a = {},
            _a["".concat(prefixCls, "-current")] = isCurrent,
            _a)) },
        React.createElement("div", { className: "".concat(prefixCls, "-main"), onClick: onClick },
            provided && (React.createElement(IconButton, __assign({ className: "".concat(prefixCls, "-drag-handle"), icon: "drag-handle", type: "only-icon" }, provided === null || provided === void 0 ? void 0 : provided.dragHandleProps))),
            React.createElement(GeoTypeIcon, { type: type, size: 12, className: "".concat(prefixCls, "-type-icon") }),
            !inEdit && (React.createElement(Tooltip, { title: text, placement: "right", mouseEnterDelay: 0, mouseLeaveDelay: 0 },
                React.createElement("div", { className: "".concat(prefixCls, "-text"), onDoubleClick: function () {
                        onChangeText && toggle(true);
                    } }, alias ? alias : text))),
            inEdit && onChangeText && (React.createElement(Input, { className: "".concat(prefixCls, "-text-input"), autoFocus: true, allowClear: false, defaultValue: alias ? alias : text, onBlur: enter, onPressEnter: enter }))),
        onEdit && React.createElement(IconButton, { icon: "edit", type: "only-icon", onClick: onEdit }),
        deleteTitle ? (React.createElement(Tooltip, { title: deleteTitle, placement: "right", mouseEnterDelay: 0, mouseLeaveDelay: 0 },
            React.createElement(IconButton, { icon: "close", type: "only-icon", onClick: onDelete }))) : (React.createElement(IconButton, { icon: "close", type: "only-icon", onClick: onDelete }))));
});
PackageWrapper.whyDidYouRender = true;
PackageWrapper.displayName = 'PackageWrapper';

export { PackageWrapper as P };
