import { j as s } from "../../node_modules/react/jsx-runtime.mjs";
import r from "./index.module.less.mjs";
import { useState as j, useEffect as t } from "react";
import S from "../../node_modules/ahooks/es/useInterval/index.mjs";
import i from "../BitzButton/index.mjs";
import { getLastTimeStr as k } from "../../utils/time.mjs";
import v from "./Form.mjs";
import F from "../../node_modules/@ant-design/icons/es/icons/PauseCircleFilled.mjs";
import M from "../../node_modules/@ant-design/icons/es/icons/PlayCircleFilled.mjs";
import E from "../../node_modules/antd/es/space/index.mjs";
import g from "../../node_modules/@ant-design/icons/es/icons/EditOutlined.mjs";
import w from "../../node_modules/@ant-design/icons/es/icons/CheckOutlined.mjs";
import D from "../../node_modules/@ant-design/icons/es/icons/DeleteOutlined.mjs";
function O(e) {
  if (isNaN(e))
    return "00:00:00";
  const l = Math.floor(e / (1e3 * 3600 * 24));
  e %= 1e3 * 3600 * 24;
  const a = Math.floor(e / (1e3 * 3600));
  e %= 1e3 * 3600;
  const m = Math.floor(e / (1e3 * 60));
  e %= 1e3 * 60;
  const d = Math.floor(e / 1e3), c = (f) => f < 10 ? "0" + f : f;
  return l <= 0 ? `${c(a)}:${c(m)}:${c(d)}` : `${l}.${c(a)}:${c(m)}:${c(d)}`;
}
const K = ({
  option: e,
  pause: l,
  start: a,
  edit: m,
  remove: d
}) => {
  const [c, f] = j((e == null ? void 0 : e.duration) || 0), [u, h] = j(e != null && e.start ? 1e3 : void 0), [N, x] = j(!1);
  S(() => {
    f(c + 1e3);
  }, u);
  const y = () => {
    h(void 0), l == null || l(e == null ? void 0 : e.id);
  }, $ = () => {
    h(1e3), a == null || a(e == null ? void 0 : e.id);
  }, C = () => {
    x(!0), m == null || m(e == null ? void 0 : e.id);
  };
  return t(() => {
    h(e != null && e.start ? 1e3 : void 0);
  }, [e == null ? void 0 : e.start]), t(() => {
    f((e == null ? void 0 : e.duration) || 0);
  }, [e == null ? void 0 : e.duration]), t(() => {
    x((e == null ? void 0 : e.edit) || !1);
  }, [e == null ? void 0 : e.edit]), /* @__PURE__ */ s.jsxs("div", { className: r.timer, children: [
    /* @__PURE__ */ s.jsx("div", { children: u === 1e3 ? /* @__PURE__ */ s.jsx(F, { className: `${r.btn} ${r.pause}`, onClick: y }) : /* @__PURE__ */ s.jsx(M, { className: r.btn, onClick: $ }) }),
    /* @__PURE__ */ s.jsxs("div", { children: [
      /* @__PURE__ */ s.jsxs("div", { className: r.flex, children: [
        /* @__PURE__ */ s.jsx("span", { className: r.time, children: O(c) }),
        /* @__PURE__ */ s.jsxs(E, { className: r.tools, children: [
          /* @__PURE__ */ s.jsx(i, { shape: "circle", icon: /* @__PURE__ */ s.jsx(g, {}), onClick: C }),
          /* @__PURE__ */ s.jsx(i, { type: "primary", shape: "circle", icon: /* @__PURE__ */ s.jsx(w, {}) }),
          /* @__PURE__ */ s.jsx(
            i,
            {
              type: "primary",
              shape: "circle",
              danger: !0,
              icon: /* @__PURE__ */ s.jsx(D, {}),
              onClick: () => {
                d == null || d();
              }
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ s.jsxs("div", { className: r.desc, children: [
        /* @__PURE__ */ s.jsx("span", { className: r["desc-title"], children: "测试案件00001" }),
        /* @__PURE__ */ s.jsx("span", { className: r["desc-time"], children: k("normal", (/* @__PURE__ */ new Date()).toLocaleString(), !0) })
      ] }),
      N && /* @__PURE__ */ s.jsx(
        v,
        {
          finish: () => {
            x(!1);
          },
          cancel: () => {
            x(!1);
          }
        }
      )
    ] })
  ] });
};
export {
  K as Timer
};
