"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const index_esm = require("../../../@vant/use/dist/index.esm.js");
const usePlaceholder = require("../composables/use-placeholder.js");
const props = require("../utils/props.js");
const create = require("../utils/create.js");
const interceptor = require("../utils/interceptor.js");
const format = require("../utils/format.js");
const constant = require("../utils/constant.js");
const [name, bem] = create.createNamespace("tabbar");
const tabbarProps = {
  route: Boolean,
  fixed: props.truthProp,
  border: props.truthProp,
  zIndex: props.numericProp,
  placeholder: Boolean,
  activeColor: String,
  beforeChange: Function,
  inactiveColor: String,
  modelValue: props.makeNumericProp(0),
  safeAreaInsetBottom: {
    type: Boolean,
    default: null
  }
};
const TABBAR_KEY = Symbol(name);
var stdin_default = Vue.defineComponent({
  name,
  props: tabbarProps,
  emits: ["change", "update:modelValue"],
  setup(props2, {
    emit,
    slots
  }) {
    const root = Vue.ref();
    const {
      linkChildren
    } = index_esm.useChildren(TABBAR_KEY);
    const renderPlaceholder = usePlaceholder.usePlaceholder(root, bem);
    const enableSafeArea = () => {
      var _a;
      return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
    };
    const renderTabbar = () => {
      var _a;
      const {
        fixed,
        zIndex,
        border
      } = props2;
      return Vue.createVNode("div", {
        "ref": root,
        "role": "tablist",
        "style": format.getZIndexStyle(zIndex),
        "class": [bem({
          fixed
        }), {
          [constant.BORDER_TOP_BOTTOM]: border,
          "van-safe-area-bottom": enableSafeArea()
        }]
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
    };
    const setActive = (active, afterChange) => {
      interceptor.callInterceptor(props2.beforeChange, {
        args: [active],
        done() {
          emit("update:modelValue", active);
          emit("change", active);
          afterChange();
        }
      });
    };
    linkChildren({
      props: props2,
      setActive
    });
    return () => {
      if (props2.fixed && props2.placeholder) {
        return renderPlaceholder(renderTabbar);
      }
      return renderTabbar();
    };
  }
});
exports.TABBAR_KEY = TABBAR_KEY;
exports.default = stdin_default;
exports.tabbarProps = tabbarProps;
