import { j as e } from "../../node_modules/react/jsx-runtime.mjs";
import t from "./index.module.less.mjs";
import { useRef as N, useEffect as g } from "react";
import { useImmer as C } from "../../node_modules/use-immer/dist/use-immer.module.mjs";
import { Timer as w } from "./Timer.mjs";
import L from "../BitzEmpty/index.mjs";
import T from "../../node_modules/antd/es/app/index.mjs";
import y from "../../node_modules/antd/es/alert/index.mjs";
import p from "../../node_modules/antd/es/select/index.mjs";
import O from "../../node_modules/antd/es/tag/index.mjs";
import R from "../../node_modules/@ant-design/icons/es/icons/ExclamationCircleOutlined.mjs";
import S from "../../node_modules/@ant-design/icons/es/icons/PlusCircleFilled.mjs";
import k from "../../node_modules/@ant-design/icons/es/icons/ExclamationCircleFilled.mjs";
import A from "../../node_modules/@ant-design/icons/es/icons/CloseOutlined.mjs";
const { Option: d } = p, Q = ({ show: m = !0, hide: n = () => {
} }) => {
  const { modal: h } = T.useApp(), { confirm: u } = h, c = N(null), [l, i] = C([
    {
      id: 1,
      start: !0,
      edit: !1
    },
    {
      id: 2,
      start: !1,
      edit: !1
    },
    {
      id: 3,
      start: !1,
      edit: !1
    }
  ]);
  g(() => {
    m ? x() : f();
  }, [m]);
  const x = () => {
    var s;
    (s = c.current) == null || s.classList.add(t.show);
  }, f = () => {
    var s;
    (s = c.current) == null || s.classList.remove(t.show), n == null || n();
  }, j = (s) => {
    l.forEach((r, a) => {
      s === r.id ? i((o) => {
        o[a].start = !0;
      }) : i((o) => {
        o[a].start = !1;
      });
    });
  }, v = (s) => {
    l.forEach((r, a) => {
      s === r.id ? i((o) => {
        o[a].edit = !0;
      }) : i((o) => {
        o[a].edit = !1;
      });
    });
  }, E = (s) => {
    u({
      title: "温馨提醒",
      icon: /* @__PURE__ */ e.jsx(k, {}),
      content: "确定要删除吗？",
      onOk() {
        i((r) => {
          r.splice(s, 1);
        });
      }
    });
  };
  return /* @__PURE__ */ e.jsxs("div", { className: `${t.container} ${m ? t.show : ""}`, ref: c, children: [
    /* @__PURE__ */ e.jsxs("div", { className: t.header, children: [
      /* @__PURE__ */ e.jsx("h3", { children: "工作日志计时器" }),
      /* @__PURE__ */ e.jsx(A, { className: t.close, onClick: f })
    ] }),
    /* @__PURE__ */ e.jsx(y, { className: t.alert, message: "单计时器时长超出24小时部分无法计入日志！", type: "warning" }),
    /* @__PURE__ */ e.jsxs(p, { showSearch: !0, placeholder: "任务检索关键字：通过任务穿件计时器", className: t.select, children: [
      /* @__PURE__ */ e.jsx(d, { value: "male", children: "male" }),
      /* @__PURE__ */ e.jsx(d, { value: "female", children: "female" }),
      /* @__PURE__ */ e.jsx(d, { value: "other", children: "other" })
    ] }),
    /* @__PURE__ */ e.jsxs("h4", { children: [
      /* @__PURE__ */ e.jsx("span", { children: "运行中的计时器" }),
      /* @__PURE__ */ e.jsx(O, { icon: /* @__PURE__ */ e.jsx(R, {}), color: "warning", className: t.tag, children: "只允许单个计时器开启计时" })
    ] }),
    /* @__PURE__ */ e.jsx("div", { className: t.timerList, children: l.length ? l.map((s, r) => /* @__PURE__ */ e.jsx(w, { option: s, start: j, edit: v, remove: () => E(r) }, s.id)) : /* @__PURE__ */ e.jsx(L, { style: { marginTop: 50 } }) }),
    /* @__PURE__ */ e.jsx(
      S,
      {
        className: t.addbtn,
        onClick: () => {
          i((s) => {
            s.unshift({
              id: Math.random(),
              start: !1,
              edit: !1
            });
          });
        }
      }
    )
  ] });
};
export {
  Q as BitzTimer,
  Q as default
};
