import _ConfigProvider from 'antd/lib/config-provider';
import _TreeSelect from 'antd/lib/tree-select';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { forwardRef } from 'react';
import classnames from 'classnames';
import Down from '@bigbinary/neeto-icons/Down';
import { useTranslation } from 'react-i18next';
import { a as getLocale, A as ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES } from './index-QWVp_Xt6.js';
import { ANTD_LOCALE } from './constants.js';
import Label from './Label.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import '@babel/runtime/helpers/slicedToArray';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'qs';
import 'ramda';
import './en-Dmu3B4Vs.js';
import './index-DyUNP5G9.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'i18next';
import 'antd/locale/de_DE';
import 'antd/locale/en_US';
import 'antd/locale/es_ES';
import 'antd/locale/fr_FR';
import 'antd/locale/nl_NL';
import 'antd/locale/pl_PL';
import 'antd/locale/pt_PT';
import '@bigbinary/neeto-icons/Help';
import './Button.js';
import 'react-router-dom';
import './Spinner.js';
import './Tooltip.js';
import '@tippyjs/react';
import 'tippy.js';
import '@bigbinary/neeto-hotkeys';
import './overlayManager.js';
import './usePrefersReducedMotion-n4ZJtExQ.js';
import './Popover.js';
import './Typography.js';

var _excluded = ["allowClear", "className", "disabled", "error", "fieldNames", "label", "onChange", "placeholder", "required", "showSearch", "size", "suffixIcon", "switcherIcon", "treeData", "treeDataSimpleMode", "value", "popupClassName"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var TreeSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var _fieldNames$label;
  var allowClear = _ref.allowClear,
    className = _ref.className,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    error = _ref.error,
    fieldNames = _ref.fieldNames,
    _ref$label = _ref.label,
    label = _ref$label === void 0 ? "" : _ref$label,
    onChange = _ref.onChange,
    _ref$placeholder = _ref.placeholder,
    placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
    _ref$required = _ref.required,
    required = _ref$required === void 0 ? false : _ref$required,
    _ref$showSearch = _ref.showSearch,
    showSearch = _ref$showSearch === void 0 ? false : _ref$showSearch,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? "middle" : _ref$size,
    suffixIcon = _ref.suffixIcon,
    switcherIcon = _ref.switcherIcon,
    treeData = _ref.treeData,
    _ref$treeDataSimpleMo = _ref.treeDataSimpleMode,
    treeDataSimpleMode = _ref$treeDataSimpleMo === void 0 ? true : _ref$treeDataSimpleMo,
    value = _ref.value,
    popupClassName = _ref.popupClassName,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  var _useTranslation = useTranslation(),
    t = _useTranslation.t,
    i18n = _useTranslation.i18n;
  var SuffixIcon = suffixIcon !== null && suffixIcon !== void 0 ? suffixIcon : Down;
  var SwitcherIcon = switcherIcon !== null && switcherIcon !== void 0 ? switcherIcon : Down;
  return /*#__PURE__*/jsx(_ConfigProvider, {
    locale: ANTD_LOCALE[i18n.language || "en"],
    theme: {
      token: _objectSpread({}, ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
      components: {
        TreeSelect: {
          nodeHoverBg: "rgb(var(--neeto-ui-gray-100))",
          nodeSelectedBg: "rgb(var(--neeto-ui-primary-500))",
          // Global overrides
          colorBgElevated: "rgb(var(--neeto-ui-white))"
        }
      }
    },
    children: /*#__PURE__*/jsxs("div", {
      className: "neeto-ui-input__wrapper",
      children: [label && /*#__PURE__*/jsx(Label, {
        required: required,
        "data-testid": "treeselect-label",
        children: label
      }), /*#__PURE__*/jsx(_TreeSelect, _objectSpread({
        allowClear: allowClear,
        disabled: disabled,
        fieldNames: fieldNames,
        onChange: onChange,
        placeholder: placeholder,
        ref: ref,
        showSearch: showSearch,
        size: size,
        treeData: treeData,
        treeDataSimpleMode: treeDataSimpleMode,
        "data-testid": "neeto-ui-tree-select-wrapper",
        dropdownStyle: {
          zIndex: 100000
        },
        suffixIcon: /*#__PURE__*/jsx(SuffixIcon, {}),
        treeNodeFilterProp: (_fieldNames$label = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) !== null && _fieldNames$label !== void 0 ? _fieldNames$label : "label",
        value: value || undefined,
        className: classnames("neeto-ui-tree-select__wrapper", className, {
          "neeto-ui-tree-select__error": error
        }),
        notFoundContent:
        /*#__PURE__*/
        // eslint-disable-next-line @bigbinary/neeto/hard-coded-strings-should-be-localized
        jsx("div", {
          className: "neeto-ui-text-center neeto-ui-p-1",
          children: getLocale(i18n, t, "neetoui.treeSelect.noOptions")
        }),
        popupClassName: classnames("neeto-ui-tree-select-dropdown", popupClassName),
        switcherIcon: function switcherIcon(_ref2) {
          var className = _ref2.className,
            style = _ref2.style,
            onMouseMove = _ref2.onMouseMove,
            id = _ref2.id,
            title = _ref2.title;
          return /*#__PURE__*/jsx("div", {
            className: className,
            id: id,
            onMouseMove: onMouseMove,
            style: style,
            title: title,
            children: /*#__PURE__*/jsx(SwitcherIcon, {})
          });
        }
      }, otherProps)), error && /*#__PURE__*/jsx("p", {
        className: "neeto-ui-input__error",
        "data-testid": "treeselect-error",
        children: error
      })]
    })
  });
});
TreeSelect.displayName = "TreeSelect";

export { TreeSelect as default };
//# sourceMappingURL=TreeSelect.js.map
