import { jsx as C } from "react/jsx-runtime";
import { useRef as L } from "react";
import { createRecipeContext as R, mergeRefs as h } from "@chakra-ui/react";
import { $ as y } from "./useObjectRef-CaJ5pgjX.es.js";
import { $ } from "./mergeProps-B-cqsBhL.es.js";
import { $ as v } from "./filterDOMProps-Cxz9cAAv.es.js";
import { e as D, f as E, g as S } from "./openLink-m90p5mer.es.js";
import { $ as T } from "./usePress-UxAvyvOO.es.js";
import { $ as g } from "./useFocusable-C4Re42UX.es.js";
function w(e, o) {
  let { elementType: s = "a", onPress: n, onPressStart: i, onPressEnd: t, onClick: c, isDisabled: r, ...d } = e, a = {};
  s !== "a" && (a = {
    role: "link",
    tabIndex: r ? void 0 : 0
  });
  let { focusableProps: p } = g(e, o), { pressProps: f, isPressed: m } = T({
    onPress: n,
    onPressStart: i,
    onPressEnd: t,
    onClick: c,
    isDisabled: r,
    ref: o
  }), P = v(d, {
    labelable: !0
  }), u = $(p, f), k = D(), x = E(e);
  return {
    isPressed: m,
    linkProps: $(P, x, {
      ...u,
      ...a,
      "aria-disabled": r || void 0,
      "aria-current": e["aria-current"],
      onClick: (b) => {
        var l;
        (l = f.onClick) === null || l === void 0 || l.call(f, b), S(b, k, e.href, e.routerOptions);
      }
    })
  };
}
const { withContext: _ } = /* @__PURE__ */ R({ key: "nimbusLink" }), j = /* @__PURE__ */ _("a"), H = (e) => {
  const { as: o, asChild: s, children: n, ref: i, ...t } = e, c = L(null), r = y(h(c, i)), d = o || (s ? "span" : "a"), { linkProps: a } = w({ ...t, elementType: d }, r);
  return /* @__PURE__ */ C(j, { ...$(t, a, { as: o, asChild: s, ref: r }), children: n });
};
H.displayName = "Link";
export {
  H as L
};
//# sourceMappingURL=link-BGMgyeHe.es.js.map
