import { $ as F, a as h } from "./utils-CrjF8U_E.es.js";
import { $ as V } from "./ProgressBar-DByVsgd2.es.js";
import { $ as x } from "./LiveAnnouncer-CsPyaceH.es.js";
import { $ as B } from "./Hidden-X9vuhkMZ.es.js";
import { a as v, $ as C } from "./mergeProps-B-cqsBhL.es.js";
import { $ as E } from "./filterDOMProps-Cxz9cAAv.es.js";
import g, { useRef as H, useEffect as I, createContext as k } from "react";
import { $ as R } from "./useButton-C0YxSZ4p.es.js";
import { $ as _ } from "./useFocusRing-CZQUsztf.es.js";
import { $ as w } from "./useHover-BiPYlZr_.es.js";
const L = /* @__PURE__ */ k({}), K = /* @__PURE__ */ B(function(a, d) {
  [a, d] = F(a, d, L);
  let n = a, { isPending: e } = n, { buttonProps: t, isPressed: p } = R(a, d);
  t = M(t, e);
  let { focusProps: y, isFocused: r, isFocusVisible: c } = _(a), { hoverProps: D, isHovered: $ } = w({
    ...a,
    isDisabled: a.isDisabled || e
  }), b = {
    isHovered: $,
    isPressed: (n.isPressed || p) && !e,
    isFocused: r,
    isFocusVisible: c,
    isDisabled: a.isDisabled || !1,
    isPending: e ?? !1
  }, u = h({
    ...a,
    values: b,
    defaultClassName: "react-aria-Button"
  }), o = v(t.id), f = v(), i = t["aria-labelledby"];
  e && (i ? i = `${i} ${f}` : t["aria-label"] && (i = `${o} ${f}`));
  let l = H(e);
  I(() => {
    let P = {
      "aria-labelledby": i || o
    };
    !l.current && r && e ? x(P, "assertive") : l.current && r && !e && x(P, "assertive"), l.current = e;
  }, [
    e,
    r,
    i,
    o
  ]);
  let m = E(a, {
    global: !0
  });
  return delete m.onClick, /* @__PURE__ */ g.createElement("button", {
    ...C(m, u, t, y, D),
    // When the button is in a pending state, we want to stop implicit form submission (ie. when the user presses enter on a text input).
    // We do this by changing the button's type to button.
    type: t.type === "submit" && e ? "button" : t.type,
    id: o,
    ref: d,
    "aria-labelledby": i,
    slot: a.slot || void 0,
    "aria-disabled": e ? "true" : t["aria-disabled"],
    "data-disabled": a.isDisabled || void 0,
    "data-pressed": b.isPressed || void 0,
    "data-hovered": $ || void 0,
    "data-focused": r || void 0,
    "data-pending": e || void 0,
    "data-focus-visible": c || void 0
  }, /* @__PURE__ */ g.createElement(V.Provider, {
    value: {
      id: f
    }
  }, u.children));
});
function M(s, a) {
  if (a) {
    for (const d in s) d.startsWith("on") && !(d.includes("Focus") || d.includes("Blur")) && (s[d] = void 0);
    s.href = void 0, s.target = void 0;
  }
  return s;
}
export {
  L as $,
  K as a
};
//# sourceMappingURL=Button-C9AKe3Kt.es.js.map
