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