"use client";
import p from "react";
import { createContextScope as S } from "../../../../../@radix-ui_react-context@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-context/dist/index.js";
import { Primitive as G } from "../../../../../@radix-ui_react-primitive@2.0.2_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@19_i7clg2yux7aeir464mbcqjzvuu/node_modules/@radix-ui/react-primitive/dist/index.js";
import { createRovingFocusGroupScope as P, Item as V, Root as A } from "../../../../../@radix-ui_react-roving-focus@1.1.2_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react_c5sgnoslw4cq7lccfrz42zoj24/node_modules/@radix-ui/react-roving-focus/dist/index.js";
import { Toggle as F } from "../../../../../@radix-ui_react-toggle@1.1.2_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@19.0._4uujergfrh54edgp2iove32ibi/node_modules/@radix-ui/react-toggle/dist/index.js";
import { useControllableState as _ } from "../../../../../@radix-ui_react-use-controllable-state@1.1.0_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
import { useDirection as M } from "../../../../../@radix-ui_react-direction@1.1.0_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-direction/dist/index.js";
import { jsx as l } from "react/jsx-runtime";
var v = "ToggleGroup", [C, z] = S(v, [
  P
]), I = P(), f = p.forwardRef((e, r) => {
  const { type: a, ...t } = e;
  if (a === "single")
    return /* @__PURE__ */ l(w, { ...t, ref: r });
  if (a === "multiple")
    return /* @__PURE__ */ l(D, { ...t, ref: r });
  throw new Error(`Missing prop \`type\` expected on \`${v}\``);
});
f.displayName = v;
var [h, x] = C(v), w = p.forwardRef((e, r) => {
  const {
    value: a,
    defaultValue: t,
    onValueChange: u = () => {
    },
    ...n
  } = e, [s, o] = _({
    prop: a,
    defaultProp: t,
    onChange: u
  });
  return /* @__PURE__ */ l(
    h,
    {
      scope: e.__scopeToggleGroup,
      type: "single",
      value: s ? [s] : [],
      onItemActivate: o,
      onItemDeactivate: p.useCallback(() => o(""), [o]),
      children: /* @__PURE__ */ l(R, { ...n, ref: r })
    }
  );
}), D = p.forwardRef((e, r) => {
  const {
    value: a,
    defaultValue: t,
    onValueChange: u = () => {
    },
    ...n
  } = e, [s = [], o] = _({
    prop: a,
    defaultProp: t,
    onChange: u
  }), i = p.useCallback(
    (c) => o((g = []) => [...g, c]),
    [o]
  ), d = p.useCallback(
    (c) => o((g = []) => g.filter((y) => y !== c)),
    [o]
  );
  return /* @__PURE__ */ l(
    h,
    {
      scope: e.__scopeToggleGroup,
      type: "multiple",
      value: s,
      onItemActivate: i,
      onItemDeactivate: d,
      children: /* @__PURE__ */ l(R, { ...n, ref: r })
    }
  );
});
f.displayName = v;
var [E, N] = C(v), R = p.forwardRef(
  (e, r) => {
    const {
      __scopeToggleGroup: a,
      disabled: t = !1,
      rovingFocus: u = !0,
      orientation: n,
      dir: s,
      loop: o = !0,
      ...i
    } = e, d = I(a), c = M(s), g = { role: "group", dir: c, ...i };
    return /* @__PURE__ */ l(E, { scope: a, rovingFocus: u, disabled: t, children: u ? /* @__PURE__ */ l(
      A,
      {
        asChild: !0,
        ...d,
        orientation: n,
        dir: c,
        loop: o,
        children: /* @__PURE__ */ l(G.div, { ...g, ref: r })
      }
    ) : /* @__PURE__ */ l(G.div, { ...g, ref: r }) });
  }
), m = "ToggleGroupItem", b = p.forwardRef(
  (e, r) => {
    const a = x(m, e.__scopeToggleGroup), t = N(m, e.__scopeToggleGroup), u = I(e.__scopeToggleGroup), n = a.value.includes(e.value), s = t.disabled || e.disabled, o = { ...e, pressed: n, disabled: s }, i = p.useRef(null);
    return t.rovingFocus ? /* @__PURE__ */ l(
      V,
      {
        asChild: !0,
        ...u,
        focusable: !s,
        active: n,
        ref: i,
        children: /* @__PURE__ */ l(T, { ...o, ref: r })
      }
    ) : /* @__PURE__ */ l(T, { ...o, ref: r });
  }
);
b.displayName = m;
var T = p.forwardRef(
  (e, r) => {
    const { __scopeToggleGroup: a, value: t, ...u } = e, n = x(m, a), s = { role: "radio", "aria-checked": e.pressed, "aria-pressed": void 0 }, o = n.type === "single" ? s : void 0;
    return /* @__PURE__ */ l(
      F,
      {
        ...o,
        ...u,
        ref: r,
        onPressedChange: (i) => {
          i ? n.onItemActivate(t) : n.onItemDeactivate(t);
        }
      }
    );
  }
), H = f, J = b;
export {
  J as Item,
  H as Root,
  f as ToggleGroup,
  b as ToggleGroupItem,
  z as createToggleGroupScope
};
//# sourceMappingURL=index.js.map
