import { jsxs as m, jsx as c } from "react/jsx-runtime";
import { useRef as u } from "react";
import { createSlotRecipeContext as S, mergeRefs as P } from "@chakra-ui/react";
import { useSlotRecipe as w } from "@chakra-ui/react/styled-system";
import { e as x } from "./extract-style-props-CMyV-es-.es.js";
import { e as R } from "./index-N3Xxo-X9.es.js";
import { $ as y } from "./useObjectRef-CaJ5pgjX.es.js";
import { $ as k } from "./mergeProps-B-cqsBhL.es.js";
import { $ as v } from "./useToggleState-DWm4nWJh.es.js";
import { $ as D } from "./useToggle-DPaFYvr8.es.js";
import { $ as O } from "./useFocusRing-CZQUsztf.es.js";
import { V } from "./visually-hidden-DVHn3y3w.es.js";
function j(t, e, s) {
  let { labelProps: o, inputProps: a, isSelected: i, isPressed: l, isDisabled: d, isReadOnly: n } = D(t, e, s);
  return {
    labelProps: o,
    inputProps: {
      ...a,
      role: "switch",
      checked: i
    },
    isSelected: i,
    isPressed: l,
    isDisabled: d,
    isReadOnly: n
  };
}
const { withProvider: C, withContext: p } = /* @__PURE__ */ S({
  key: "nimbusSwitch"
}), L = /* @__PURE__ */ C("label", "root"), T = /* @__PURE__ */ p("span", "label"), g = /* @__PURE__ */ p("span", "track"), F = /* @__PURE__ */ p("span", "thumb"), H = ({ ref: t, ...e }) => {
  const s = u(null), o = y(
    t ? P(s, t) : s
  ), a = w({ recipe: R }), [i, l] = a.splitVariantProps(e), [d, n] = x(l), f = v(e), { inputProps: b } = j(n, f, o), { isFocused: $, focusProps: h } = O(), r = {
    "data-selected": f.isSelected,
    "data-invalid": e.isInvalid,
    "data-disabled": e.isDisabled,
    "data-focus": $ || void 0
  };
  return /* @__PURE__ */ m(
    L,
    {
      "data-slot": "root",
      ...i,
      ...r,
      ...d,
      children: [
        /* @__PURE__ */ m(g, { "data-slot": "track", ...r, children: [
          /* @__PURE__ */ c(F, { "data-slot": "thumb", ...r }),
          /* @__PURE__ */ c(V, { as: "span", children: /* @__PURE__ */ c(
            "input",
            {
              "data-slot": "input",
              ...k(b, h),
              ref: o
            }
          ) })
        ] }),
        e.children && /* @__PURE__ */ c(T, { "data-slot": "label", ...r, children: e.children })
      ]
    }
  );
};
H.displayName = "Switch";
export {
  H as S
};
//# sourceMappingURL=switch-CgLZJ152.es.js.map
