import $ from "react";
import { j as a, F as b, c as m, a as h, r as C } from "./13339559.js";
import { w as g, a as w, m as x, u as P, S as k } from "./554cd359.js";
import "react-dom";
const p = "adm-badge", N = /* @__PURE__ */ a(b, {}), A = (s) => {
  const {
    content: n,
    color: t,
    children: r
  } = s, l = n === N, i = m(p, !!r && `${p}-fixed`, l && `${p}-dot`, s.bordered && `${p}-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 = w(A, {
  dot: N
});
function B(s, n) {
  let t = 0;
  function r(l) {
    $.Children.forEach(l, (i) => {
      C.isFragment(i) ? r(i.props.children) : (n(i, t), t += 1);
    });
  }
  r(s);
}
const F = () => null, c = "adm-tab-bar", E = {
  safeArea: !1
}, T = (s) => {
  var n;
  const t = x(E, s);
  let r = null;
  const l = [];
  B(t.children, (e, o) => {
    if (!$.isValidElement(e))
      return;
    const f = e.key;
    typeof f == "string" && (o === 0 && (r = f), l.push(e));
  });
  const [i, u] = P({
    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(b, {
            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(k, {
      position: "bottom"
    })]
  }));
};
export {
  T as TabBar,
  F as TabBarItem
};
