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