import { j as e } from "../../node_modules/react/jsx-runtime.mjs";
import { memo as C, useMemo as s } from "react";
import b, { CalendarTypeEnum as a } from "./BitzFuiCalendarStore.mjs";
import h from "../../node_modules/dayjs/dayjs.min.mjs";
import c from "../../node_modules/antd/es/space/index.mjs";
import d from "../../node_modules/antd/es/button/button.mjs";
import w from "../../node_modules/@ant-design/icons/es/icons/AppstoreOutlined.mjs";
import g from "../../node_modules/@ant-design/icons/es/icons/LeftOutlined.mjs";
import T from "../../node_modules/@ant-design/icons/es/icons/RightOutlined.mjs";
import v from "../../node_modules/antd/es/date-picker/index.mjs";
import _ from "../../node_modules/antd/es/dropdown/index.mjs";
import D from "../../node_modules/@ant-design/icons/es/icons/DownOutlined.mjs";
const z = () => {
  const {
    CalendarType: n,
    currentDay: o,
    toggleCalendarType: u,
    setCurrentDay: l
  } = b((r) => r), i = [
    {
      key: a.day,
      label: "日"
    },
    {
      key: a.workWeek,
      label: "工作周"
      // icon: <SmileOutlined />,
    },
    {
      key: a.week,
      label: "周"
    },
    {
      key: a.agendum,
      label: "议程"
    }
  ], m = s(() => {
    var r;
    return ((r = i.find((t) => (t == null ? void 0 : t.key) === n)) == null ? void 0 : r.label) ?? "";
  }, [n]), k = (r) => {
    u(r.key);
  }, f = s(() => {
    switch (n) {
      case a.day:
        return "date";
      case a.workWeek:
        return "week";
      case a.week:
        return "week";
      case a.agendum:
        return "date";
      default:
        return "date";
    }
  }, [n]), p = (r, t) => {
    r && l(r);
  }, y = () => {
    [a.day, a.agendum].includes(n) && l(o.add(-1, "day")), [a.workWeek, a.week].includes(n) && l(o.add(-7, "day"));
  }, x = () => {
    [a.day, a.agendum].includes(n) && l(o.add(1, "day")), [a.workWeek, a.week].includes(n) && l(o.add(7, "day"));
  }, j = () => {
    l(h().startOf("date"));
  };
  return /* @__PURE__ */ e.jsxs("div", { className: "bitzFuiCalendarToolbar", children: [
    /* @__PURE__ */ e.jsx("div", { className: "bitzFuiCalendarToolbar__left", children: /* @__PURE__ */ e.jsxs(c, { children: [
      /* @__PURE__ */ e.jsx("div", { className: "bitzFuiCalendarToolbar__today", children: /* @__PURE__ */ e.jsx(d, { onClick: j, type: "text", icon: /* @__PURE__ */ e.jsx(w, {}), children: "今天" }) }),
      /* @__PURE__ */ e.jsx(d, { onClick: y, icon: /* @__PURE__ */ e.jsx(g, {}) }),
      /* @__PURE__ */ e.jsx(d, { onClick: x, icon: /* @__PURE__ */ e.jsx(T, {}) }),
      /* @__PURE__ */ e.jsx(
        v,
        {
          onChange: p,
          format: "YYYY月MM月",
          allowClear: !1,
          picker: f,
          value: o,
          bordered: !1
        }
      )
    ] }) }),
    /* @__PURE__ */ e.jsx("div", { className: "bitzFuiCalendarToolbar__right", children: /* @__PURE__ */ e.jsx("div", { className: "bitzFuiCalendarToolbar__right_dropdown", children: /* @__PURE__ */ e.jsx(
      _,
      {
        menu: {
          items: i,
          selectable: !0,
          defaultSelectedKeys: [n],
          onClick: k
        },
        children: /* @__PURE__ */ e.jsx("a", { onClick: (r) => r.preventDefault(), children: /* @__PURE__ */ e.jsxs(c, { children: [
          /* @__PURE__ */ e.jsx("div", { children: m }),
          /* @__PURE__ */ e.jsx(D, {})
        ] }) })
      }
    ) }) })
  ] });
}, K = C(z);
export {
  K as default
};
