/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var hooks_useVmodel = require('../../hooks/use-vmodel.js');
var hooks_lnode = require('../../hooks/lnode.js');
var hooks_useConfig = require('../../hooks/use-config.js');
var components_collapse_props = require('./props.js');
require('lodash/kebabCase');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/camelCase');
require('../../hooks/render-lnode.js');
require('lodash');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');

var _Collapse = VueCompositionAPI.defineComponent({
  name: "LCollapse",
  props: components_collapse_props.CollapseProps,
  setup(props2) {
    const componentName = hooks_useConfig.usePrefixClass("collapse");
    const borderlessClass = hooks_useConfig.usePrefixClass("-border-less");
    const {
      value,
      expandMutex,
      borderless
    } = VueCompositionAPI.toRefs(props2);
    const [collapseValue, setCollapseValue] = hooks_useVmodel["default"](value, props2.defaultValue, props2.onChange, "change");
    const updateCollapseValue = value2 => {
      let newValue = [].concat(collapseValue.value || []);
      const index = newValue.indexOf(value2);
      if (index >= 0) newValue.splice(index, 1);else if (expandMutex.value) newValue = [value2];else newValue.push(value2);
      setCollapseValue(newValue);
    };
    const classes = VueCompositionAPI.computed(() => [componentName.value, {
      [borderlessClass.value]: !!borderless.value
    }]);
    const getUniqId = (() => {
      let index = 0;
      return () => index += 1;
    })();
    const renderTNodeJSX = hooks_lnode.useLNodeJSX();
    VueCompositionAPI.provide("collapseValue", collapseValue);
    VueCompositionAPI.provide("updateCollapseValue", updateCollapseValue);
    VueCompositionAPI.provide("collapseProps", VueCompositionAPI.toRefs(props2));
    VueCompositionAPI.provide("getUniqId", getUniqId);
    VueCompositionAPI.provide("renderParentTNode", hooks_lnode.useLNodeJSX());
    return {
      classes,
      renderTNodeJSX
    };
  },
  render() {
    const h = arguments[0];
    const nodes = this.renderTNodeJSX("default");
    return h("div", {
      "class": this.classes
    }, [nodes]);
  }
});

exports["default"] = _Collapse;
//# sourceMappingURL=collapse.js.map
