/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, toRefs, computed, provide } from '@vue/composition-api';
import props from './props.js';
import useVModel from '../hooks/useVModel.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import '../config-provider/index.js';
import { usePrefixClass } from '../config-provider/useConfig.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../hooks/render-tnode.js';
import 'lodash/isString';
import 'lodash/isObject';
import '../utils/withInstall.js';
import 'vue';
import 'lodash/capitalize';
import '../config-provider/config-provider.js';
import '../config-provider/type.js';
import 'lodash/cloneDeep';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';

var _Collapse = defineComponent({
  name: "TCollapse",
  props: props,
  setup: function setup(props2) {
    var componentName = usePrefixClass("collapse");
    var borderlessClass = usePrefixClass("-border-less");

    var _toRefs = toRefs(props2),
        value = _toRefs.value,
        expandMutex = _toRefs.expandMutex,
        borderless = _toRefs.borderless;

    var _useVModel = useVModel(value, props2.defaultValue, props2.onChange, "change"),
        _useVModel2 = _slicedToArray(_useVModel, 2),
        collapseValue = _useVModel2[0],
        setCollapseValue = _useVModel2[1];

    var updateCollapseValue = function updateCollapseValue(value2) {
      var newValue = [].concat(collapseValue.value || []);
      var index = newValue.indexOf(value2);

      if (index >= 0) {
        newValue.splice(index, 1);
      } else if (expandMutex.value) {
        newValue = [value2];
      } else {
        newValue.push(value2);
      }

      setCollapseValue(newValue);
    };

    var classes = computed(function () {
      return [componentName.value, _defineProperty({}, borderlessClass.value, !!borderless.value)];
    });

    var getUniqId = function () {
      var index = 0;
      return function () {
        return index += 1;
      };
    }();

    provide("collapseValue", collapseValue);
    provide("updateCollapseValue", updateCollapseValue);
    provide("collapseProps", toRefs(props2));
    provide("getUniqId", getUniqId);
    return {
      classes: classes
    };
  },
  render: function render() {
    var h = arguments[0];
    var renderTNodeJSX = useTNodeJSX();
    var nodes = renderTNodeJSX("default");
    return h("div", {
      "class": this.classes
    }, [nodes]);
  }
});

export { _Collapse as default };
//# sourceMappingURL=collapse.js.map
