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

import { defineComponent, toRefs, computed, provide } from '@vue/composition-api';
import useVModel from '../../hooks/use-vmodel.js';
import { useLNodeJSX } from '../../hooks/lnode.js';
import { usePrefixClass } from '../../hooks/use-config.js';
import { CollapseProps } from './props.js';
import 'lodash/kebabCase';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/camelCase';
import '../../hooks/render-lnode.js';
import 'lodash';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';

var _Collapse = defineComponent({
  name: "LCollapse",
  props: CollapseProps,
  setup(props2) {
    const componentName = usePrefixClass("collapse");
    const borderlessClass = usePrefixClass("-border-less");
    const {
      value,
      expandMutex,
      borderless
    } = toRefs(props2);
    const [collapseValue, setCollapseValue] = useVModel(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 = computed(() => [componentName.value, {
      [borderlessClass.value]: !!borderless.value
    }]);
    const getUniqId = (() => {
      let index = 0;
      return () => index += 1;
    })();
    const renderTNodeJSX = useLNodeJSX();
    provide("collapseValue", collapseValue);
    provide("updateCollapseValue", updateCollapseValue);
    provide("collapseProps", toRefs(props2));
    provide("getUniqId", getUniqId);
    provide("renderParentTNode", useLNodeJSX());
    return {
      classes,
      renderTNodeJSX
    };
  },
  render() {
    const h = arguments[0];
    const nodes = this.renderTNodeJSX("default");
    return h("div", {
      "class": this.classes
    }, [nodes]);
  }
});

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