'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var normalizeComponent = require('./normalize-component-6fa50395.js');
var ThemeMixin = require('./ThemeMixin-37dd1318.js');
var VTabContent = require('./VTabContent.js');

var script = {
  name: 'VTabs',
  provide: function provide() {
    return {
      addTab: this.addTab,
      removeTab: this.removeTab,
      setActive: this.setActive
    };
  },
  data: function data() {
    return {
      activeTabIdx: 0,
      tabs: []
    };
  },
  computed: {
    vTabsCssClass: function vTabsCssClass() {
      return ThemeMixin._objectSpread2({}, this.themeCssClass, {
        'v-tabs': true
      });
    },
    tabsLabels: function tabsLabels() {
      return this.$slots.default.filter(function ($el) {
        return !!$el.tag;
      });
    },
    isTabsExists: function isTabsExists() {
      return this.$slots.default.length > 0;
    },
    activeContent: function activeContent() {
      var child = this.tabs[this.activeTabIdx];

      if (!child) {
        return null;
      }

      return child.$slots.default;
    }
  },
  methods: {
    getChildLabel: function getChildLabel(child) {
      var props = child.componentOptions.propsData || {};
      return props.label;
    },
    addTab: function addTab(tab) {
      this.tabs = this.tabs.concat(tab);
    },
    setActive: function setActive(tab) {
      var tabIdx = this.tabs.indexOf(tab);
      if (tabIdx === -1) return;
      this.activeTabIdx = tabIdx;
    },
    removeTab: function removeTab(tab) {
      var tabIdx = this.tabs.indexOf(tab);
      if (tabIdx === -1) return;
      this.tabs.splice(tabIdx, 1);
    },
    onTabClick: function onTabClick(ev, index) {
      if (this.activeTabIdx === index) return;
      this.activeTabIdx = index;
      var child = this.tabs[index];

      if (child) {
        child.$emit('click', ev);
      }
    }
  },
  mixins: [ThemeMixin.ThemeMixin],
  components: {
    VTabContent: VTabContent.default
  }
};

/* script */
const __vue_script__ = script;

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.vTabsCssClass},[_vm._t("default"),_vm._v(" "),(_vm.isTabsExists)?_c('section',{staticClass:"v-tabs-controls-list"},_vm._l((_vm.tabsLabels),function(child,index){return _c('button',_vm._b({key:index,class:{
        'v-tabs-control': true,
        'is-active': _vm.activeTabIdx === index,
      },on:{"click":function($event){return _vm.onTabClick($event, index)}}},'button',child.data.attrs,false),[_vm._v("\n      "+_vm._s(_vm.getChildLabel(child))+"\n    ")])}),0):_vm._e(),_vm._v(" "),(_vm.activeContent)?_c('section',{staticClass:"v-tabs-content"},[_c('v-tab-content',_vm._b({},'v-tab-content',{ content: _vm.activeContent },false))],1):_vm._e()],2)};
var __vue_staticRenderFns__ = [];

  /* style */
  const __vue_inject_styles__ = undefined;
  /* scoped */
  const __vue_scope_id__ = undefined;
  /* module identifier */
  const __vue_module_identifier__ = undefined;
  /* functional template */
  const __vue_is_functional_template__ = false;
  /* style inject */
  
  /* style inject SSR */
  

  
  var VTabs = normalizeComponent.__vue_normalize__(
    { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

exports.default = VTabs;
