import { j as r } from "../../../../_virtual/jsx-runtime.js";
import { useRef as f, useEffect as n } from "react";
import { SegmentWrapper as u, SegmentLabel as p } from "./styles.js";
import { useHasFocus as b } from "../../../../hooks/useHasFocus.js";
function S({
  segment: o,
  active: i,
  size: e,
  segmentPadding: s,
  onChange: t,
  setActiveRef: a
}) {
  const l = f(null), { hasFocus: c } = b(l);
  n(() => {
    i && a(l);
  }, [i]);
  function d() {
    !o.disabled && t(o);
  }
  return /* @__PURE__ */ r.jsx(
    u,
    {
      ref: l,
      "aria-selected": i,
      role: "tab",
      isActive: i,
      size: e,
      segmentPadding: s,
      hasFocus: c,
      disabled: o.disabled,
      onClick: d,
      children: /* @__PURE__ */ r.jsxs(p, { title: o.tooltip, children: [
        o.icon,
        o.label
      ] })
    },
    o.id ?? o.label
  );
}
export {
  S as Segment
};
