import { cx } from '@linaria/core';
import Link from '../Link/index.js';
import Token from '../Token/index.js';
import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
import { Flex } from 'antd5';
import cs from 'classnames';
import React__default, { useState } from 'react';
import SearchInput from '../SearchInput/index.js';
import { Typo } from '../Typo/index.js';
import { CascaderNotData, CascaderDefaultHeaderContainer, CascaderDefaultHeaderSearch, CascaderDefaultHeader, DoubleRowOptionStyleWrapper, Hide, CascaderDefaultOptionLabel } from './cascader.style.js';

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.createElement("div", { className: cs(CascaderNotData) }, content);
};
const PresetCascaderHeader = ({ defaultContent, searchProps }) => {
  const { t } = useParrotTranslation();
  const [selectedAll, setSelectedAll] = 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.createElement(Flex, { vertical: true, className: CascaderDefaultHeaderContainer }, searchProps ? /* @__PURE__ */ React__default.createElement(
    SearchInput,
    __spreadProps(__spreadValues({}, searchProps), {
      className: cs(searchProps.className, CascaderDefaultHeaderSearch),
      style: {
        width: "unset"
      }
    })
  ) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), (defaultContent == null ? void 0 : defaultContent.hide) ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null) : /* @__PURE__ */ React__default.createElement("div", { className: cs(CascaderDefaultHeader) }, defaultContent == null ? void 0 : defaultContent.label, /* @__PURE__ */ React__default.createElement(Link, { size: "small", onClick }, selectedAll ? t("components.unselect_all") : t("components.select_all"))));
};
const PresetCascaderRender = ({
  menus,
  header,
  footer,
  presetHeaderProps
}) => {
  return /* @__PURE__ */ React__default.createElement("div", null, header ? header : /* @__PURE__ */ React__default.createElement(PresetCascaderHeader, __spreadValues({}, presetHeaderProps)), menus, footer);
};
const CascaderDoubleRowOption = ({ leftTop, leftBottom, rightTop, rightBottom, rootClassName }) => {
  return /* @__PURE__ */ React__default.createElement(
    Flex,
    {
      vertical: true,
      className: cx(DoubleRowOptionStyleWrapper, rootClassName),
      gap: 6
    },
    /* @__PURE__ */ React__default.createElement(
      Flex,
      {
        justify: "space-between",
        className: !leftTop && !rightTop ? Hide : "",
        gap: 8
      },
      /* @__PURE__ */ React__default.createElement("div", { className: cs(Typo.Label.l2_medium, "top", "left") }, leftTop),
      /* @__PURE__ */ React__default.createElement("div", null, rightTop)
    ),
    /* @__PURE__ */ React__default.createElement(
      Flex,
      {
        justify: "space-between",
        className: cs(Typo.Label.l4_regular, {
          [Hide]: !leftBottom && !rightBottom
        }),
        gap: 8
      },
      /* @__PURE__ */ React__default.createElement("div", { className: cs(Typo.Label.l4_regular, "bottom", "left") }, leftBottom),
      /* @__PURE__ */ React__default.createElement("div", { className: cs(Typo.Label.l4_regular, "bottom") }, rightBottom)
    )
  );
};
const CascaderOptionWithCount = ({ label, count }) => {
  return /* @__PURE__ */ React__default.createElement("div", { className: CascaderDefaultOptionLabel }, label, count ? /* @__PURE__ */ React__default.createElement("span", { className: "label" }, count.selected, "/", count.total) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null));
};
const defaultTagRender = (props) => {
  return /* @__PURE__ */ React__default.createElement(Token, __spreadValues({ size: "medium", color: "blue", key: props.value }, props), /* @__PURE__ */ React__default.createElement(OverflowTooltip, { content: props.label, tooltip: props.label }));
};

export { CascaderDoubleRowOption, CascaderOptionWithCount, NotDataContent, PresetCascaderHeader, PresetCascaderRender, defaultTagRender };
