import _extends from "@babel/runtime/helpers/esm/extends";
import Info from "../info";
import Icon from "../icon";
import create from "../utils/create";
import { route } from "../utils/router";
import { isObj } from "../utils";
import { ChildrenMixin } from "../mixins/relation";
import { routeProps } from "../utils/router";
export default create({
  render: function render() {
    var _vm = this;

    var _h = _vm.$createElement;

    var _c = _vm._self._c || _h;

    return _c('div', {
      class: _vm.b({
        active: _vm.myActive
      }),
      style: {
        color: _vm.color
      },
      on: {
        "click": _vm.onClick
      }
    }, [_c('div', {
      class: _vm.b('icon')
    }, [_vm._t("icon", [_vm.icon ? _c('Icon', {
      attrs: {
        "name": _vm.icon,
        "classPrefix": _vm.iconPrefix
      }
    }) : _vm._e()], {
      "active": _vm.myActive
    }), _c('Info', {
      attrs: {
        "dot": _vm.dot,
        "info": _vm.info || _vm.badge
      }
    })], 2), _c('div', {
      class: _vm.b('text')
    }, [_vm._t("default", null, {
      "active": _vm.myActive
    })], 2)]);
  },
  name: "tabbar-item",
  components: {
    Info: Info,
    Icon: Icon
  },
  mixins: [ChildrenMixin("vmTabbar")],
  props: _extends({}, routeProps, {
    dot: Boolean,
    icon: String,
    name: [Number, String],
    info: [Number, String],
    badge: [Number, String],
    iconPrefix: String
  }),
  data: function data() {
    return {
      active: false
    };
  },
  computed: {
    routeActive: function routeActive() {
      var to = this.to,
          $route = this.$route;

      if (to && $route) {
        var config = isObj(to) ? to : {
          path: to
        };
        var pathMatched = config.path === $route.path;
        var nameMatched = isObj(config.name) && config.name === $route.name;
        return pathMatched || nameMatched;
      }
    },
    color: function color() {
      return this.parents[this.myActive ? "activeColor" : "inactiveColor"];
    },
    myActive: function myActive() {
      return this.parents.route ? this.routeActive : this.active;
    }
  },
  methods: {
    onClick: function onClick(event) {
      this.parents.onChange(this.name || this.index);
      this.$emit("click", event);
      route(this.$router, this);
    }
  }
});