var d = Object.defineProperty;
var l = Object.getOwnPropertySymbols;
var C = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
var a = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, u = (r, t) => {
  for (var e in t || (t = {}))
    C.call(t, e) && a(r, e, t[e]);
  if (l)
    for (var e of l(t))
      h.call(t, e) && a(r, e, t[e]);
  return r;
};
import { jsx as o } from "react/jsx-runtime";
import { useState as k, useEffect as y } from "react";
import s from "antd/es/button";
import g from "antd/es/popconfirm";
const j = (r) => {
  const {
    name: t,
    type: e,
    style: x,
    className: i,
    children: c,
    onConfirm: m
  } = r, [f, n] = k(null);
  return y(() => {
    if (!r.confirm) {
      n(null);
      return;
    }
    if (r.confirm === !0) {
      n({
        text: `确认${t}吗？`
      });
      return;
    }
    n(r.confirm);
  }, [r.confirm]), f ? /* @__PURE__ */ o(g, {
    rootClassName: "track-map-popconfirm",
    okText: "确定",
    cancelText: "取消",
    title: f.text,
    trigger: "click",
    onConfirm: m,
    children: /* @__PURE__ */ o(s, {
      className: i,
      type: e,
      style: u({}, x),
      children: c || t
    })
  }) : /* @__PURE__ */ o(s, {
    className: i,
    type: e,
    onClick: m,
    children: c || t
  });
};
export {
  j as default
};
