'use strict';

var core = require('@linaria/core');
var index = require('../Link/index.js');
var index$2 = require('../Token/index.js');
var index$3 = require('../../coreX/OverflowTooltip/index.js');
var useParrotTranslation = require('../../hooks/useParrotTranslation.js');
var antd5 = require('antd5');
var cs = require('classnames');
var React = require('react');
var index$1 = require('../Typo/index.js');
var cascader_style = require('./cascader.style.js');
var SearchInput = require('../SearchInput/SearchInput.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var cs__default = /*#__PURE__*/_interopDefault(cs);
var React__default = /*#__PURE__*/_interopDefault(React);

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const NotDataContent = ({ content }) => {
  return /* @__PURE__ */ React__default.default.createElement("div", { className: cs__default.default(cascader_style.CascaderNotData) }, content);
};
const PresetCascaderHeader = ({ defaultContent, searchProps }) => {
  const { t } = useParrotTranslation();
  const [selectedAll, setSelectedAll] = React.useState(false);
  const onClick = (e) => {
    var _a;
    setSelectedAll(!selectedAll);
    (_a = defaultContent == null ? void 0 : defaultContent.onClickAll) == null ? void 0 : _a.call(defaultContent, selectedAll);
  };
  return /* @__PURE__ */ React__default.default.createElement(antd5.Flex, { vertical: true, className: cascader_style.CascaderDefaultHeaderContainer }, searchProps ? /* @__PURE__ */ React__default.default.createElement(
    SearchInput.SearchInput,
    __spreadProps(__spreadValues({}, searchProps), {
      className: cs__default.default(searchProps.className, cascader_style.CascaderDefaultHeaderSearch),
      style: {
        width: "unset"
      }
    })
  ) : /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null), (defaultContent == null ? void 0 : defaultContent.hide) ? /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null) : /* @__PURE__ */ React__default.default.createElement("div", { className: cs__default.default(cascader_style.CascaderDefaultHeader) }, defaultContent == null ? void 0 : defaultContent.label, /* @__PURE__ */ React__default.default.createElement(index, { size: "small", onClick }, selectedAll ? t("components.unselect_all") : t("components.select_all"))));
};
const PresetCascaderRender = ({
  menus,
  header,
  footer,
  presetHeaderProps
}) => {
  return /* @__PURE__ */ React__default.default.createElement("div", null, header ? header : /* @__PURE__ */ React__default.default.createElement(PresetCascaderHeader, __spreadValues({}, presetHeaderProps)), menus, footer);
};
const CascaderDoubleRowOption = ({ leftTop, leftBottom, rightTop, rightBottom, rootClassName }) => {
  return /* @__PURE__ */ React__default.default.createElement(
    antd5.Flex,
    {
      vertical: true,
      className: core.cx(cascader_style.DoubleRowOptionStyleWrapper, rootClassName),
      gap: 6
    },
    /* @__PURE__ */ React__default.default.createElement(
      antd5.Flex,
      {
        justify: "space-between",
        className: !leftTop && !rightTop ? cascader_style.Hide : "",
        gap: 8
      },
      /* @__PURE__ */ React__default.default.createElement("div", { className: cs__default.default(index$1.Typo.Label.l2_medium, "top", "left") }, leftTop),
      /* @__PURE__ */ React__default.default.createElement("div", null, rightTop)
    ),
    /* @__PURE__ */ React__default.default.createElement(
      antd5.Flex,
      {
        justify: "space-between",
        className: cs__default.default(index$1.Typo.Label.l4_regular, {
          [cascader_style.Hide]: !leftBottom && !rightBottom
        }),
        gap: 8
      },
      /* @__PURE__ */ React__default.default.createElement("div", { className: cs__default.default(index$1.Typo.Label.l4_regular, "bottom", "left") }, leftBottom),
      /* @__PURE__ */ React__default.default.createElement("div", { className: cs__default.default(index$1.Typo.Label.l4_regular, "bottom") }, rightBottom)
    )
  );
};
const CascaderOptionWithCount = ({ label, count }) => {
  return /* @__PURE__ */ React__default.default.createElement("div", { className: cascader_style.CascaderDefaultOptionLabel }, label, count ? /* @__PURE__ */ React__default.default.createElement("span", { className: "label" }, count.selected, "/", count.total) : /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null));
};
const defaultTagRender = (props) => {
  return /* @__PURE__ */ React__default.default.createElement(index$2.default, __spreadValues({ size: "medium", color: "blue", key: props.value }, props), /* @__PURE__ */ React__default.default.createElement(index$3, { content: props.label, tooltip: props.label }));
};

exports.CascaderDoubleRowOption = CascaderDoubleRowOption;
exports.CascaderOptionWithCount = CascaderOptionWithCount;
exports.NotDataContent = NotDataContent;
exports.PresetCascaderHeader = PresetCascaderHeader;
exports.PresetCascaderRender = PresetCascaderRender;
exports.defaultTagRender = defaultTagRender;
