import N, { isValidElement as C } from "react";
import { V as r, bh as b, kB as m, P as h, kC as k } from "./684d2f28.js";
import { w as g, a as P, m as w, u as x, S as A } from "./28e77e61.js";
import "react-dom";
import "./b7901950.js";
import "./55f8e851.js";
import "./d44efa59.js";
const p = "adm-badge", $ = /* @__PURE__ */ r(b, {}), B = (s) => {
  const {
    content: n,
    color: t,
    children: a
  } = s, i = n === $, l = m(p, {
    [`${p}-fixed`]: !!a,
    [`${p}-dot`]: i,
    [`${p}-bordered`]: s.bordered
  }), u = n || n === 0 ? g(s, /* @__PURE__ */ r("div", {
    className: l,
    style: {
      "--color": t
    },
    children: !i && /* @__PURE__ */ r("div", {
      className: `${p}-content`,
      children: n
    })
  })) : null;
  return a ? /* @__PURE__ */ h("div", {
    className: m(`${p}-wrapper`, s.wrapperClassName),
    style: s.wrapperStyle,
    children: [a, u]
  }) : u;
}, y = P(B, {
  dot: $
});
function E(s, n) {
  let t = 0;
  function a(i) {
    N.Children.forEach(i, (l) => {
      k.isFragment(l) ? a(l.props.children) : (n(l, t), t += 1);
    });
  }
  a(s);
}
const R = () => null, c = "adm-tab-bar", K = {
  safeArea: !1
}, D = (s) => {
  var n;
  const t = w(K, s);
  let a = null;
  const i = [];
  E(t.children, (e, o) => {
    if (!C(e))
      return;
    const f = e.key;
    typeof f == "string" && (o === 0 && (a = f), i.push(e));
  });
  const [l, u] = x({
    value: t.activeKey,
    defaultValue: (n = t.defaultActiveKey) !== null && n !== void 0 ? n : a,
    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__ */ r("div", {
      className: `${c}-wrap`,
      children: i.map((e) => {
        const o = e.key === l;
        function f() {
          const d = e.props.icon && /* @__PURE__ */ r("div", {
            className: `${c}-item-icon`,
            children: typeof e.props.icon == "function" ? e.props.icon(o) : e.props.icon
          }), v = e.props.title && /* @__PURE__ */ r("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__ */ r(y, {
              content: e.props.badge,
              className: `${c}-icon-badge`,
              children: d
            }), v]
          }) : v ? /* @__PURE__ */ r(y, {
            content: e.props.badge,
            className: `${c}-title-badge`,
            children: v
          }) : null;
        }
        return g(e.props, /* @__PURE__ */ r("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__ */ r(A, {
      position: "bottom"
    })]
  }));
};
export {
  D as TabBar,
  R as TabBarItem
};
