import { $ as l } from "./focusSafely-Cwb0Tyy6.es.js";
import { $ as b } from "./useFocus-CrgTusM3.es.js";
import { $ as s } from "./mergeProps-Dsl8k3Ig.es.js";
import { $ as p } from "./useObjectRef-CaJ5pgjX.es.js";
import { $ as P } from "./useSyncRef-BpLviItW.es.js";
import c, { useRef as x, useEffect as v, useContext as m } from "react";
function d(e) {
  if (!e) return;
  let t = !0;
  return (r) => {
    let o = {
      ...r,
      preventDefault() {
        r.preventDefault();
      },
      isDefaultPrevented() {
        return r.isDefaultPrevented();
      },
      stopPropagation() {
        t && process.env.NODE_ENV !== "production" ? console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.") : t = !0;
      },
      continuePropagation() {
        t = !1;
      },
      isPropagationStopped() {
        return t;
      }
    };
    e(o), t && r.stopPropagation();
  };
}
function D(e) {
  return {
    keyboardProps: e.isDisabled ? {} : {
      onKeyDown: d(e.onKeyDown),
      onKeyUp: d(e.onKeyUp)
    }
  };
}
let $ = /* @__PURE__ */ c.createContext(null);
function h(e) {
  let t = m($) || {};
  P(t, e);
  let { ref: r, ...o } = t;
  return o;
}
const S = /* @__PURE__ */ c.forwardRef(function(t, r) {
  let { children: o, ...a } = t, n = p(r), f = {
    ...a,
    ref: n
  };
  return /* @__PURE__ */ c.createElement($.Provider, {
    value: f
  }, o);
});
function _(e, t) {
  let { focusProps: r } = b(e), { keyboardProps: o } = D(e), a = s(r, o), n = h(t), f = e.isDisabled ? {} : n, i = x(e.autoFocus);
  v(() => {
    i.current && t.current && l(t.current), i.current = !1;
  }, [
    t
  ]);
  let u = e.excludeFromTabOrder ? -1 : 0;
  return e.isDisabled && (u = void 0), {
    focusableProps: s({
      ...a,
      tabIndex: u
    }, f)
  };
}
export {
  _ as $,
  S as a,
  $ as b,
  D as c
};
//# sourceMappingURL=useFocusable-Cs6i58WP.es.js.map
