/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, computed, ref, onMounted, nextTick, watch, createVNode } from 'vue';
import { firstUpperCase } from '../utils/helper.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import props from './props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/camelCase';
import 'lodash/isUndefined';
import 'lodash/isNull';
import 'lodash/isArray';
import 'lodash/isNumber';
import 'lodash/isString';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-2e5d8948.js';
import 'dayjs';
import '../_chunks/dep-4580aabe.js';
import '../config-provider/type.js';

var TTabNavBar = defineComponent({
  props: {
    navs: {
      type: Array
    },
    placement: props.placement,
    value: props.value
  },
  setup: function setup(props) {
    var COMPONENT_NAME = usePrefixClass("tabs");
    var classPrefix = usePrefixClass();
    var navBarClass = computed(function () {
      return ["".concat(COMPONENT_NAME.value, "__bar"), "".concat(classPrefix.value, "-is-").concat(props.placement)];
    });
    var navBarStyle = ref(null);
    var getStyle = function getStyle() {
      var _props$navs$i$el2, _ref3;
      var isVertical = ["left", "right"].includes(props.placement.toLowerCase());
      var _ref = isVertical ? ["height", "top"] : ["width", "left"],
        _ref2 = _slicedToArray(_ref, 2),
        sizePropName = _ref2[0],
        offsetPropName = _ref2[1];
      var offset = 0;
      var i = 0;
      for (; i < props.navs.length; i++) {
        var _props$navs$i, _props$navs$i$el;
        if (props.navs[i].props.value === props.value) break;
        offset += ((_props$navs$i = props.navs[i]) === null || _props$navs$i === void 0 ? void 0 : (_props$navs$i$el = _props$navs$i.el) === null || _props$navs$i$el === void 0 ? void 0 : _props$navs$i$el["client".concat(firstUpperCase(sizePropName))]) || 0;
      }
      if (!props.navs[i]) return {};
      return _ref3 = {}, _defineProperty(_ref3, offsetPropName, "".concat(offset, "px")), _defineProperty(_ref3, sizePropName, "".concat(((_props$navs$i$el2 = props.navs[i].el) === null || _props$navs$i$el2 === void 0 ? void 0 : _props$navs$i$el2["client".concat(firstUpperCase(sizePropName))]) || 0, "px")), _ref3;
    };
    onMounted(function () {
      nextTick(function () {
        navBarStyle.value = getStyle();
      });
    });
    watch([function () {
      return props.navs;
    }, function () {
      return props.value;
    }, function () {
      return props.placement;
    }], function () {
      nextTick(function () {
        navBarStyle.value = getStyle();
      });
    });
    return function () {
      return createVNode("div", {
        "class": navBarClass.value,
        "style": navBarStyle.value
      }, null);
    };
  }
});

export { TTabNavBar as default };
//# sourceMappingURL=tab-nav-bar.js.map
