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

import { defineComponent, computed } from '@vue/composition-api';
import props from '../props.js';
import { usePrefixClass } from '../../../hooks/use-config.js';
import { useLNodeDefault } from '../../../hooks/lnode.js';
import { getPanels } from '../utils/helper.js';
import { expendClickEffect, valueChangeEffect } from '../utils/effect.js';
import Item from './Item.js';
import { useConfig } from '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash';
import '../../../chunks/zh_CN.js';
import '../../config-provider/type.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../../hooks/render-lnode.js';
import 'lodash/isNumber';
import 'lodash/cloneDeep';
import '../../../chunks/helper.js';
import '../../../chunks/_commonjsHelpers.js';
import '@ldesign/icons-vue';
import '../utils/className.js';
import '../../checkbox/index.js';
import '../../../utils/map-props.js';
import 'vue';
import '../../../utils/with-install.js';
import '../../../config.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../../chunks/index.js';
import '../../../chunks/log.js';
import '../../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../../utils/event.js';
import '../../../utils/helper.js';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../../utils/mixins.js';
import '../../checkbox/checkbox.js';
import '../../../utils/render-node.js';
import '../../checkbox/props.js';
import '../../checkbox/style/css.js';
import '../../checkbox/type.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../../utils/easing.js';
import '../../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../../chunks/defineProperty-838e4192.js';
import '../../../chunks/set-style.js';
import '../../../chunks/helper2.js';
import '../../loading/style/css.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../../hooks/use-global-icon.js';
import '../../../utils/ripple.js';

var Panel = defineComponent({
  name: "LCascaderSubPanel",
  props: {
    empty: props.empty,
    trigger: props.trigger,
    onChange: props.onChange,
    cascaderContext: {
      type: Object
    }
  },
  setup(props, _ref) {
    let {
      emit
    } = _ref;
    const renderTNodeJSXDefault = useLNodeDefault();
    const COMPONENT_NAME = usePrefixClass("cascader");
    const {
      global
    } = useConfig("cascader");
    const panels = computed(() => getPanels(props.cascaderContext.treeNodes));
    const handleExpand = (node, trigger) => {
      const {
        trigger: propsTrigger,
        cascaderContext
      } = props;
      expendClickEffect(propsTrigger, trigger, node, cascaderContext);
    };
    return {
      global,
      panels,
      handleExpand,
      renderTNodeJSXDefault,
      COMPONENT_NAME,
      emit
    };
  },
  render() {
    const h = arguments[0];
    const {
      global,
      COMPONENT_NAME,
      handleExpand,
      renderTNodeJSXDefault,
      cascaderContext,
      panels,
      emit
    } = this;
    const renderItem = node => h(Item, {
      "key": node.value,
      "attrs": {
        "node": node,
        "cascaderContext": cascaderContext
      },
      "props": {
        ...{
          node,
          cascaderContext,
          onClick: () => {
            emit("click", node.value, node);
            handleExpand(node, "click");
          },
          onMouseenter: () => {
            handleExpand(node, "hover");
          },
          onChange: () => {
            valueChangeEffect(node, cascaderContext);
          }
        }
      }
    });
    const renderList = function (treeNodes) {
      let isFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let segment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "1";
      return h("ul", {
        "class": [`${COMPONENT_NAME}__menu`, "narrow-scrollbar", {
          [`${COMPONENT_NAME}__menu--segment`]: segment,
          [`${COMPONENT_NAME}__menu--filter`]: isFilter
        }],
        "key": key
      }, [treeNodes.map(node => renderItem(node))]);
    };
    const renderPanels = () => {
      const {
        inputVal,
        treeNodes
      } = cascaderContext;
      return inputVal ? renderList(treeNodes, true) : panels.map((treeNodes2, index) => renderList(treeNodes2, false, index !== panels.length - 1, `${COMPONENT_NAME}__menu${index}`));
    };
    let content;
    if (this.loading) {
      content = renderTNodeJSXDefault("loadingText", h("div", {
        "class": `${COMPONENT_NAME}__panel--empty`
      }, [global.loadingText]));
    } else {
      content = panels.length ? renderPanels() : renderTNodeJSXDefault("empty", h("div", {
        "class": `${COMPONENT_NAME}__panel--empty`
      }, [global.empty]));
    }
    return h("div", {
      "class": [`${COMPONENT_NAME}__panel`, {
        [`${COMPONENT_NAME}--normal`]: panels.length && !this.loading
      }]
    }, [content]);
  }
});

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