import N, { isValidElement as C } from "react";
import { H as a, I as $, mu as m, ad as h, mv as w } from "./56c67d3b.js";
import { w as g, a as x, m as P, u as k, S as A } from "./b99ea6b6.js";
import "react-dom";
const p = "adm-badge", b = /* @__PURE__ */ a($, {}), B = (s) => {
  const {
    content: n,
    color: t,
    children: r
  } = s, l = n === b, i = m(p, {
    [`${p}-fixed`]: !!r,
    [`${p}-dot`]: l,
    [`${p}-bordered`]: s.bordered
  }), u = n || n === 0 ? g(s, /* @__PURE__ */ a("div", {
    className: i,
    style: {
      "--color": t
    },
    children: !l && /* @__PURE__ */ a("div", {
      className: `${p}-content`,
      children: n
    })
  })) : null;
  return r ? /* @__PURE__ */ h("div", {
    className: m(`${p}-wrapper`, s.wrapperClassName),
    style: s.wrapperStyle,
    children: [r, u]
  }) : u;
}, y = x(B, {
  dot: b
});
function E(s, n) {
  let t = 0;
  function r(l) {
    N.Children.forEach(l, (i) => {
      w.isFragment(i) ? r(i.props.children) : (n(i, t), t += 1);
    });
  }
  r(s);
}
const V = () => null, c = "adm-tab-bar", K = {
  safeArea: !1
}, j = (s) => {
  var n;
  const t = P(K, s);
  let r = null;
  const l = [];
  E(t.children, (e, o) => {
    if (!C(e))
      return;
    const f = e.key;
    typeof f == "string" && (o === 0 && (r = f), l.push(e));
  });
  const [i, u] = k({
    value: t.activeKey,
    defaultValue: (n = t.defaultActiveKey) !== null && n !== void 0 ? n : r,
    onChange: (e) => {
      var o;
      e !== null && ((o = t.onChange) === null || o === void 0 || o.call(t, e));
    }
  });
  return g(t, /* @__PURE__ */ h("div", {
    className: c,
    children: [/* @__PURE__ */ a("div", {
      className: `${c}-wrap`,
      children: l.map((e) => {
        const o = e.key === i;
        function f() {
          const d = e.props.icon && /* @__PURE__ */ a("div", {
            className: `${c}-item-icon`,
            children: typeof e.props.icon == "function" ? e.props.icon(o) : e.props.icon
          }), v = e.props.title && /* @__PURE__ */ a("div", {
            className: m(`${c}-item-title`, !!d && `${c}-item-title-with-icon`),
            children: typeof e.props.title == "function" ? e.props.title(o) : e.props.title
          });
          return d ? /* @__PURE__ */ h($, {
            children: [/* @__PURE__ */ a(y, {
              content: e.props.badge,
              className: `${c}-icon-badge`,
              children: d
            }), v]
          }) : v ? /* @__PURE__ */ a(y, {
            content: e.props.badge,
            className: `${c}-title-badge`,
            children: v
          }) : null;
        }
        return g(e.props, /* @__PURE__ */ a("div", {
          onClick: () => {
            const {
              key: d
            } = e;
            d != null && u(d.toString());
          },
          className: m(`${c}-item`, {
            [`${c}-item-active`]: o
          }),
          children: f()
        }, e.key));
      })
    }), t.safeArea && /* @__PURE__ */ a(A, {
      position: "bottom"
    })]
  }));
};
export {
  j as TabBar,
  V as TabBarItem
};
