import { $ as d } from "./mergeProps-B-cqsBhL.es.js";
import { $ as _ } from "./filterDOMProps-Cxz9cAAv.es.js";
import { $ as N } from "./useFormReset-Dl03QHFW.es.js";
import { $ as m } from "./usePress-UxAvyvOO.es.js";
import { $ as w } from "./useFocusable-C4Re42UX.es.js";
function B(s, a, o) {
  let { isDisabled: r = !1, isReadOnly: n = !1, value: t, name: v, form: h, children: g, "aria-label": C, "aria-labelledby": y, validationState: c = "valid", isInvalid: f, onPressStart: P, onPressEnd: b, onPressChange: p, onPress: l, onPressUp: u, onClick: $ } = s, S = (e) => {
    e.stopPropagation(), a.setSelected(e.target.checked);
  }, x = g != null, k = C != null || y != null;
  !x && !k && process.env.NODE_ENV !== "production" && console.warn("If you do not provide children, you must specify an aria-label for accessibility");
  let { pressProps: D, isPressed: E } = m({
    onPressStart: P,
    onPressEnd: b,
    onPressChange: p,
    onPress: l,
    onPressUp: u,
    onClick: $,
    isDisabled: r
  }), { pressProps: I, isPressed: L } = m({
    onPressStart: P,
    onPressEnd: b,
    onPressChange: p,
    onPressUp: u,
    onClick: $,
    onPress(e) {
      var i;
      l?.(e), a.toggle(), (i = o.current) === null || i === void 0 || i.focus();
    },
    isDisabled: r || n
  }), { focusableProps: O } = w(s, o), U = d(D, O), R = _(s, {
    labelable: !0
  });
  return N(o, a.defaultSelected, a.setSelected), {
    labelProps: d(I, {
      onClick: (e) => e.preventDefault()
    }),
    inputProps: d(R, {
      "aria-invalid": f || c === "invalid" || void 0,
      "aria-errormessage": s["aria-errormessage"],
      "aria-controls": s["aria-controls"],
      "aria-readonly": n || void 0,
      onChange: S,
      disabled: r,
      ...t == null ? {} : {
        value: t
      },
      name: v,
      form: h,
      type: "checkbox",
      ...U
    }),
    isSelected: a.isSelected,
    isPressed: E || L,
    isDisabled: r,
    isReadOnly: n,
    isInvalid: f || c === "invalid"
  };
}
export {
  B as $
};
//# sourceMappingURL=useToggle-DPaFYvr8.es.js.map
