import { jsxs as w, Fragment as A, jsx as d } from "react/jsx-runtime";
import { useState as x, useMemo as L, useCallback as G, createElement as p } from "react";
import { c as H, s as J, a as Q } from "../tools/tools.js";
import { N as O } from "./nav-item.js";
import { N as f } from "./nav-link.js";
import { N as I } from "./nav-tab-content.js";
import { N as K } from "./nav-tab-pane.js";
const o = function(S) {
  const {
    as: g = "ul",
    className: v,
    contentProps: z,
    dropOldClass: u,
    fill: k,
    horizontal: l,
    justified: N,
    onChange: t,
    options: B,
    pills: b,
    skipItem: E,
    style: m,
    tabs: y,
    underline: C,
    variables: h,
    vertical: P,
    ...F
  } = S, M = (B ?? []).map((a, s) => ({
    ...a,
    id: a.id ?? s
  })), [i, R] = x(M), [n, V] = x(null), r = L(() => i.some((a) => a.pane), [i]), _ = L(() => {
    const a = H(
      !u && "nav",
      l && `justify-content-${l}`,
      P && "flex-column",
      y && "nav-tabs",
      b && "nav-pills",
      C && "nav-underline",
      k && "nav-fill",
      N && "nav-justified",
      v
    ), s = J((e, c) => ({ tKey: Q(c) }), h, m);
    return {
      className: a,
      style: s
    };
  }, [v, u, k, l, N, b, m, y, C, h, P]), T = G(
    (a, s, e) => {
      if (r) {
        if ((n == null ? void 0 : n.id) === a.id)
          return;
        R((c) => {
          const j = c.map(($, q) => ({
            ...$,
            active: q === s
          }));
          return V(j[s]), j;
        });
      }
      t == null || t(a.id, e);
    },
    [n == null ? void 0 : n.id, r, t]
  );
  return /* @__PURE__ */ w(A, { children: [
    /* @__PURE__ */ d(g, { ...F, ..._, children: i.map((a, s) => E ? /* @__PURE__ */ p(
      f,
      {
        active: a.active,
        disabled: a.disabled,
        href: a.href,
        ...a.linkProps,
        key: a.id,
        onClick: (e) => T(a, s, e)
      },
      a.link
    ) : /* @__PURE__ */ p(O, { ...a.itemProps, key: a.id }, /* @__PURE__ */ d(
      f,
      {
        active: a.active,
        disabled: a.disabled,
        href: a.href,
        ...a.linkProps,
        onClick: (e) => T(a, s, e),
        children: a.link
      }
    ), a.item && a.item)) }),
    r && /* @__PURE__ */ d(I, { ...z, children: i.map((a) => /* @__PURE__ */ p(K, { active: a.active, fade: a.fade, ...a.paneProps, key: a.id }, a.pane)) })
  ] });
};
o.Item = O;
o.Link = f;
o.TabContent = I;
o.TabPane = K;
o.displayName = "BRL.Nav";
export {
  o as N
};
//# sourceMappingURL=nav.js.map
