import { jsx as b, jsxs as G, Fragment as J } from "react/jsx-runtime";
import u, { useMemo as S, useRef as Q, useEffect as X, useContext as x, useState as Y, forwardRef as C, createContext as V } from "react";
import { a as T, $ as Z, e as O, c as ee } from "./utils-CrjF8U_E.es.js";
import { g as te, e as ie, h as H, j as ae, k as le } from "./SelectionManager-GNsyMc-q.es.js";
import { a as se, $ as ne } from "./SelectionIndicator-B27AsfqE.es.js";
import { $ as oe, g as z, f as re, a as de } from "./CollectionBuilder-CTjJUDzO.es.js";
import { $ as ce } from "./Hidden-X9vuhkMZ.es.js";
import { $ as v, a as fe } from "./mergeProps-B-cqsBhL.es.js";
import { $ as g } from "./filterDOMProps-Cxz9cAAv.es.js";
import { $ as F } from "./useObjectRef-CaJ5pgjX.es.js";
import { a as ue, b as M } from "./useListState-BxWOm_-s.es.js";
import { $ as be, a as $e } from "./animation-BfmkkMe7.es.js";
import { f as pe } from "./openLink-m90p5mer.es.js";
import { $ as he } from "./useFocusable-C4Re42UX.es.js";
import { $ as A } from "./useLabels-BOBP8-HM.es.js";
import { $ as ye } from "./useHasTabbableChild-BKDz3bMI.es.js";
import { $ as ve } from "./context-BfHy4NgG.es.js";
import { $ as w } from "./useFocusRing-CZQUsztf.es.js";
import { $ as me } from "./useHover-BiPYlZr_.es.js";
import { $ as Pe } from "./useControlledState-3TGZUXux.es.js";
import { createSlotRecipeContext as xe } from "@chakra-ui/react";
import { e as j } from "./extract-style-props-CMyV-es-.es.js";
import { useChakraContext as ge, useSlotRecipe as Ke } from "@chakra-ui/react/styled-system";
const B = /* @__PURE__ */ new WeakMap();
function K(i, e, t) {
  if (!i)
    return "";
  typeof e == "string" && (e = e.replace(/\s+/g, ""));
  let a = B.get(i);
  return process.env.NODE_ENV !== "production" && !a && console.error("There is no tab id, please check if you have rendered the tab panel before the tab list."), `${a}-${t}-${e}`;
}
function Se(i, e, t) {
  let { key: a, isDisabled: l, shouldSelectOnPressUp: s } = i, { selectionManager: o, selectedKey: d } = e, n = a === d, r = l || e.isDisabled || e.selectionManager.isDisabled(a), { itemProps: c, isPressed: f } = te({
    selectionManager: o,
    key: a,
    ref: t,
    isDisabled: r,
    shouldSelectOnPressUp: s,
    linkBehavior: "selection"
  }), p = K(e, a, "tab"), h = K(e, a, "tabpanel"), { tabIndex: y } = c, $ = e.collection.getItem(a), P = g($?.props, {
    labelable: !0
  });
  delete P.id;
  let _ = pe($?.props), { focusableProps: q } = he({
    isDisabled: r
  }, t);
  return {
    tabProps: v(P, q, _, c, {
      id: p,
      "aria-selected": n,
      "aria-disabled": r || void 0,
      "aria-controls": n ? h : void 0,
      tabIndex: r ? void 0 : y,
      role: "tab"
    }),
    isSelected: n,
    isDisabled: r,
    isPressed: f
  };
}
function Te(i, e, t) {
  let a = ye(t) ? void 0 : 0;
  var l;
  const s = K(e, (l = i.id) !== null && l !== void 0 ? l : e?.selectedKey, "tabpanel"), o = A({
    ...i,
    id: s,
    "aria-labelledby": K(e, e?.selectedKey, "tab")
  });
  return {
    tabPanelProps: v(o, {
      tabIndex: a,
      role: "tabpanel",
      "aria-describedby": i["aria-describedby"],
      "aria-details": i["aria-details"]
    })
  };
}
class De {
  getKeyLeftOf(e) {
    return this.flipDirection ? this.getNextKey(e) : this.getPreviousKey(e);
  }
  getKeyRightOf(e) {
    return this.flipDirection ? this.getPreviousKey(e) : this.getNextKey(e);
  }
  isDisabled(e) {
    var t, a;
    return this.disabledKeys.has(e) || !!(!((a = this.collection.getItem(e)) === null || a === void 0 || (t = a.props) === null || t === void 0) && t.isDisabled);
  }
  getFirstKey() {
    let e = this.collection.getFirstKey();
    return e != null && this.isDisabled(e) && (e = this.getNextKey(e)), e;
  }
  getLastKey() {
    let e = this.collection.getLastKey();
    return e != null && this.isDisabled(e) && (e = this.getPreviousKey(e)), e;
  }
  getKeyAbove(e) {
    return this.tabDirection ? null : this.getPreviousKey(e);
  }
  getKeyBelow(e) {
    return this.tabDirection ? null : this.getNextKey(e);
  }
  getNextKey(e) {
    let t = e;
    do
      t = this.collection.getKeyAfter(t), t == null && (t = this.collection.getFirstKey());
    while (t != null && this.isDisabled(t));
    return t;
  }
  getPreviousKey(e) {
    let t = e;
    do
      t = this.collection.getKeyBefore(t), t == null && (t = this.collection.getLastKey());
    while (t != null && this.isDisabled(t));
    return t;
  }
  constructor(e, t, a, l = /* @__PURE__ */ new Set()) {
    this.collection = e, this.flipDirection = t === "rtl" && a === "horizontal", this.disabledKeys = l, this.tabDirection = a === "horizontal";
  }
}
function Ee(i, e, t) {
  let { orientation: a = "horizontal", keyboardActivation: l = "automatic" } = i, { collection: s, selectionManager: o, disabledKeys: d } = e, { direction: n } = ve(), r = S(() => new De(s, n, a, d), [
    s,
    d,
    a,
    n
  ]), { collectionProps: c } = ie({
    ref: t,
    selectionManager: o,
    keyboardDelegate: r,
    selectOnFocus: l === "automatic",
    disallowEmptySelection: !0,
    scrollRef: t,
    linkBehavior: "selection"
  }), f = fe();
  B.set(e, f);
  let p = A({
    ...i,
    id: f
  });
  return {
    tabListProps: {
      ...v(c, p),
      role: "tablist",
      "aria-orientation": a,
      tabIndex: void 0
    }
  };
}
function Ce(i) {
  var e;
  let [t, a] = Pe(i.selectedKey, (e = i.defaultSelectedKey) !== null && e !== void 0 ? e : null, i.onSelectionChange), l = S(() => t != null ? [
    t
  ] : [], [
    t
  ]), { collection: s, disabledKeys: o, selectionManager: d } = ue({
    ...i,
    selectionMode: "single",
    disallowEmptySelection: !0,
    allowDuplicateSelectionEvents: !0,
    selectedKeys: l,
    onSelectionChange: (r) => {
      if (r === "all") return;
      var c;
      let f = (c = r.values().next().value) !== null && c !== void 0 ? c : null;
      f === t && i.onSelectionChange && i.onSelectionChange(f), a(f);
    }
  }), n = t != null ? s.getItem(t) : null;
  return {
    collection: s,
    disabledKeys: o,
    selectionManager: d,
    selectedKey: t,
    setSelectedKey: a,
    selectedItem: n
  };
}
function Fe(i) {
  var e, t;
  let a = Ce({
    ...i,
    onSelectionChange: i.onSelectionChange ? (n) => {
      var r;
      n != null && ((r = i.onSelectionChange) === null || r === void 0 || r.call(i, n));
    } : void 0,
    suppressTextValueWarning: !0,
    defaultSelectedKey: (t = (e = i.defaultSelectedKey) !== null && e !== void 0 ? e : N(i.collection, i.disabledKeys ? new Set(i.disabledKeys) : /* @__PURE__ */ new Set())) !== null && t !== void 0 ? t : void 0
  }), { selectionManager: l, collection: s, selectedKey: o } = a, d = Q(o);
  return X(() => {
    let n = o;
    i.selectedKey == null && (l.isEmpty || n == null || !s.getItem(n)) && (n = N(s, a.disabledKeys), n != null && l.setSelectedKeys([
      n
    ])), (n != null && l.focusedKey == null || !l.isFocused && n !== d.current) && l.setFocusedKey(n), d.current = n;
  }), {
    ...a,
    isDisabled: i.isDisabled || !1
  };
}
function N(i, e) {
  let t = null;
  if (i) {
    var a, l, s, o;
    for (t = i.getFirstKey(); t != null && (e.has(t) || !((l = i.getItem(t)) === null || l === void 0 || (a = l.props) === null || a === void 0) && a.isDisabled) && t !== i.getLastKey(); ) t = i.getKeyAfter(t);
    t != null && (e.has(t) || !((o = i.getItem(t)) === null || o === void 0 || (s = o.props) === null || s === void 0) && s.isDisabled) && t === i.getLastKey() && (t = i.getFirstKey());
  }
  return t;
}
const D = /* @__PURE__ */ V(null), m = /* @__PURE__ */ V(null), we = /* @__PURE__ */ C(function(e, t) {
  [e, t] = Z(e, t, D);
  let { children: a, orientation: l = "horizontal" } = e;
  return a = S(() => typeof a == "function" ? a({
    orientation: l,
    defaultChildren: null
  }) : a, [
    a,
    l
  ]), /* @__PURE__ */ u.createElement(re, {
    content: a
  }, (s) => /* @__PURE__ */ u.createElement(Ie, {
    props: e,
    collection: s,
    tabsRef: t
  }));
});
function Ie({ props: i, tabsRef: e, collection: t }) {
  let { orientation: a = "horizontal" } = i, l = Fe({
    ...i,
    collection: t,
    children: void 0
  }), { focusProps: s, isFocused: o, isFocusVisible: d } = w({
    within: !0
  }), n = S(() => ({
    orientation: a,
    isFocusWithin: o,
    isFocusVisible: d
  }), [
    a,
    o,
    d
  ]), r = T({
    ...i,
    defaultClassName: "react-aria-Tabs",
    values: n
  }), c = g(i, {
    global: !0
  });
  return /* @__PURE__ */ u.createElement("div", {
    ...v(c, r, s),
    ref: e,
    slot: i.slot || void 0,
    "data-focused": o || void 0,
    "data-orientation": a,
    "data-focus-visible": d || void 0,
    "data-disabled": l.isDisabled || void 0
  }, /* @__PURE__ */ u.createElement(O, {
    values: [
      [
        D,
        i
      ],
      [
        m,
        l
      ]
    ]
  }, r.children));
}
const Re = /* @__PURE__ */ C(function(e, t) {
  return x(m) ? /* @__PURE__ */ u.createElement(Le, {
    props: e,
    forwardedRef: t
  }) : /* @__PURE__ */ u.createElement(z, e);
});
function Le({ props: i, forwardedRef: e }) {
  let t = x(m), { CollectionRoot: a } = x(H), { orientation: l = "horizontal", keyboardActivation: s = "automatic" } = ee(D), o = F(e), { tabListProps: d } = Ee({
    ...i,
    orientation: l,
    keyboardActivation: s
  }, t, o), n = T({
    ...i,
    children: null,
    defaultClassName: "react-aria-TabList",
    values: {
      orientation: l,
      state: t
    }
  }), r = g(i, {
    global: !0
  });
  return delete r.id, /* @__PURE__ */ u.createElement("div", {
    ...v(r, n, d),
    ref: o,
    "data-orientation": l || void 0
  }, /* @__PURE__ */ u.createElement(ne, null, /* @__PURE__ */ u.createElement(a, {
    collection: t.collection,
    persistedKeys: le(t.selectionManager.focusedKey)
  })));
}
class U extends de {
}
U.type = "item";
const ke = /* @__PURE__ */ oe(U, (i, e, t) => {
  let a = x(m), l = F(e), { tabProps: s, isSelected: o, isDisabled: d, isPressed: n } = Se({
    key: t.key,
    ...i
  }, a, l), { focusProps: r, isFocused: c, isFocusVisible: f } = w(), { hoverProps: p, isHovered: h } = me({
    isDisabled: d,
    onHoverStart: i.onHoverStart,
    onHoverEnd: i.onHoverEnd,
    onHoverChange: i.onHoverChange
  }), y = T({
    ...i,
    id: void 0,
    children: t.rendered,
    defaultClassName: "react-aria-Tab",
    values: {
      isSelected: o,
      isDisabled: d,
      isFocused: c,
      isFocusVisible: f,
      isPressed: n,
      isHovered: h
    }
  }), $ = t.props.href ? "a" : "div", P = g(i, {
    global: !0
  });
  return delete P.id, delete P.onClick, /* @__PURE__ */ u.createElement($, {
    ...v(P, y, s, r, p),
    ref: l,
    "data-selected": o || void 0,
    "data-disabled": d || void 0,
    "data-focused": c || void 0,
    "data-focus-visible": f || void 0,
    "data-pressed": n || void 0,
    "data-hovered": h || void 0
  }, /* @__PURE__ */ u.createElement(se.Provider, {
    value: {
      isSelected: o
    }
  }, y.children));
}), Me = /* @__PURE__ */ ce(function(e, t) {
  const a = x(m);
  let l = F(t), s = a.selectedKey === e.id, [o, d] = Y(a.selectedKey != null ? s : null);
  o == null && a.selectedKey != null ? d(s) : !s && o && d(!1);
  let n = be(l, s);
  return !s && !e.shouldForceMount && !n ? null : /* @__PURE__ */ u.createElement(Ne, {
    ...e,
    tabPanelRef: l,
    isInitiallySelected: o || !1,
    isExiting: n
  });
});
function Ne(i) {
  let e = x(m), { id: t, tabPanelRef: a, isInitiallySelected: l, isExiting: s, ...o } = i, { tabPanelProps: d } = Te(i, e, a), { focusProps: n, isFocused: r, isFocusVisible: c } = w(), f = e.selectedKey === i.id, p = $e(a) && !l, h = T({
    ...i,
    defaultClassName: "react-aria-TabPanel",
    values: {
      isFocused: r,
      isFocusVisible: c,
      // @ts-ignore - compatibility with React < 19
      isInert: M(!f),
      isEntering: p,
      isExiting: s,
      state: e
    }
  }), y = g(o, {
    global: !0
  });
  delete y.id;
  let $ = f ? v(y, d, n, h) : v(y, h);
  return /* @__PURE__ */ u.createElement("div", {
    ...$,
    ref: a,
    "data-focused": r || void 0,
    "data-focus-visible": c || void 0,
    // @ts-ignore
    inert: M(!f || i.inert),
    "data-inert": f ? void 0 : "true",
    "data-entering": p || void 0,
    "data-exiting": s || void 0
  }, /* @__PURE__ */ u.createElement(O, {
    values: [
      [
        D,
        null
      ],
      [
        m,
        null
      ]
    ]
  }, /* @__PURE__ */ u.createElement(H.Provider, {
    value: ae
  }, h.children)));
}
const { withProvider: Ve, withContext: E } = /* @__PURE__ */ xe({
  key: "nimbusTabs"
}), Oe = /* @__PURE__ */ Ve(
  "div",
  "root"
), He = /* @__PURE__ */ E(
  "div",
  "list"
), ze = /* @__PURE__ */ E(
  "button",
  "tab"
), Ae = /* @__PURE__ */ E("div", "panels"), je = /* @__PURE__ */ E("div", "panel"), I = ({ children: i, isDisabled: e, ...t }) => /* @__PURE__ */ b(ze, { asChild: !0, ...t, children: /* @__PURE__ */ b(ke, { isDisabled: e, children: i }) });
I.displayName = "Tabs.Tab";
const R = ({ tabs: i, children: e, ...t }) => {
  const [a, l] = j(t);
  if (!i && !e)
    throw new Error(
      'Tabs.List: Either provide "tabs" prop or "children" must be provided'
    );
  return /* @__PURE__ */ b(He, { ...a, asChild: !0, children: /* @__PURE__ */ b(Re, { items: i, ...l, children: i ? (s) => /* @__PURE__ */ b(I, { id: s.id, isDisabled: s.isDisabled, children: s.tabLabel }, s.id) : e }) });
};
R.displayName = "Tabs.List";
const L = /* @__PURE__ */ C(
  ({ children: i, ...e }, t) => {
    if (!i)
      throw new Error("Tabs.Panel: children prop is required");
    return /* @__PURE__ */ b(je, { asChild: !0, ref: t, ...e, children: /* @__PURE__ */ b(Me, { children: i }) });
  }
);
L.displayName = "Tabs.Panel";
const k = ({ tabs: i, children: e, ...t }) => {
  if (!i && !e)
    throw new Error(
      'Tabs.Panels: Either provide "items" prop or "children" must be provided'
    );
  return /* @__PURE__ */ b(Ae, { ...t, children: i ? /* @__PURE__ */ b(z, { items: i, children: (a) => /* @__PURE__ */ b(L, { id: a.id, children: a.panelContent }, a.id) }) : e });
};
k.displayName = "Tabs.Panels";
const W = ({
  children: i,
  tabs: e,
  tabListAriaLabel: t,
  ...a
}) => {
  const l = ge(), s = Ke({ key: "nimbusTabs" }), [o, d] = s.splitVariantProps(a), [n, r] = j(d), c = l.normalizeValue(o.orientation);
  return /* @__PURE__ */ b(Oe, { asChild: !0, ...o, ...n, children: /* @__PURE__ */ b(we, { ...r, orientation: c, children: i || /* @__PURE__ */ G(J, { children: [
    /* @__PURE__ */ b(R, { tabs: e, "aria-label": t }),
    /* @__PURE__ */ b(k, { tabs: e })
  ] }) }) });
};
W.displayName = "Tabs.Root";
const ut = {
  /**
   * # Tabs.Root
   *
   * The root component that provides context and state management for the tabs.
   * Must wrap all tabs parts (List, Tab, Panels, Panel) to coordinate their behavior.
   *
   * @example
   * ```tsx
   * <Tabs.Root orientation="horizontal" size="md">
   *   <Tabs.List>
   *     <Tabs.Tab id="tab1">Tab 1</Tabs.Tab>
   *   </Tabs.List>
   *   <Tabs.Panels>
   *     <Tabs.Panel id="tab1">Content</Tabs.Panel>
   *   </Tabs.Panels>
   * </Tabs.Root>
   * ```
   */
  Root: W,
  /**
   * # Tabs.List
   *
   * The container for tab buttons that allows users to navigate between panels.
   * Handles keyboard navigation and manages the active tab state.
   *
   * @example
   * ```tsx
   * <Tabs.List>
   *   <Tabs.Tab id="tab1">First Tab</Tabs.Tab>
   *   <Tabs.Tab id="tab2">Second Tab</Tabs.Tab>
   * </Tabs.List>
   * ```
   */
  List: R,
  /**
   * # Tabs.Tab
   *
   * An individual tab button that activates its corresponding panel when selected.
   * Supports keyboard navigation, disabled states, and custom content.
   *
   * @example
   * ```tsx
   * <Tabs.Tab id="settings" isDisabled={false}>
   *   <Icon name="settings" />
   *   Settings
   * </Tabs.Tab>
   * ```
   */
  Tab: I,
  /**
   * # Tabs.Panels
   *
   * The container for all tab panels that displays the content for the active tab.
   * Manages visibility and accessibility of panel content.
   *
   * @example
   * ```tsx
   * <Tabs.Panels>
   *   <Tabs.Panel id="tab1">First panel content</Tabs.Panel>
   *   <Tabs.Panel id="tab2">Second panel content</Tabs.Panel>
   * </Tabs.Panels>
   * ```
   */
  Panels: k,
  /**
   * # Tabs.Panel
   *
   * An individual panel that displays content when its corresponding tab is active.
   * Automatically manages focus and accessibility attributes.
   *
   * @example
   * ```tsx
   * <Tabs.Panel id="profile">
   *   <h3>Profile Settings</h3>
   *   <p>Manage your profile information here.</p>
   * </Tabs.Panel>
   * ```
   */
  Panel: L
};
export {
  ut as T,
  R as a,
  L as b,
  k as c,
  W as d,
  I as e
};
//# sourceMappingURL=tabs-D9Q3mypg.es.js.map
