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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed, createVNode } from 'vue';
import props from '../props.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { useTNodeDefault } from '../../hooks/tnode.js';
import { getPanels } from '../core/helper.js';
import { expendClickEffect, valueChangeEffect } from '../core/effect.js';
import Item from './Item.js';
import { useConfig } from '../../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
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-512eb181.js';
import 'dayjs';
import '../../_chunks/dep-ac28b67c.js';
import '../../config-provider/type.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isObject';
import 'lodash/isNumber';
import '@babel/runtime/helpers/slicedToArray';
import '@ldesign/icons-vue-next';
import '../core/className.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../checkbox/index.js';
import '../../utils/withInstall.js';
import '../../checkbox/checkbox.js';
import '../../hooks/useVModel.js';
import '../../form/hooks.js';
import '../../hooks/useRipple.js';
import '../../utils/set-style.js';
import '../../hooks/useKeepAnimation.js';
import '../../checkbox/props.js';
import '../../checkbox/constants.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import 'lodash/isUndefined';
import '../../hooks/slot.js';
import '../../checkbox/checkbox-group-props.js';
import '../../checkbox/style';
import '../../checkbox/type.js';
import '../../loading/index.js';
import '../../loading/directive.js';
import '../../loading/plugin.js';
import '../../utils/dom.js';
import '../../utils/easing.js';
import '../../loading/loading.js';
import '../../hooks/useTeleport.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import '../../loading/style';
import '../../loading/type.js';
import '../../hooks/useGlobalIcon.js';

var Panel = defineComponent({
  name: "TCascaderSubPanel",
  props: {
    empty: props.empty,
    trigger: props.trigger,
    onChange: props.onChange,
    loading: props.loading,
    loadingText: props.loadingText,
    cascaderContext: {
      type: Object
    }
  },
  setup: function setup(props) {
    var renderTNodeJSXDefault = useTNodeDefault();
    var COMPONENT_NAME = usePrefixClass("cascader");
    var _useConfig = useConfig("cascader"),
      globalConfig = _useConfig.globalConfig;
    var panels = computed(function () {
      return getPanels(props.cascaderContext.treeNodes);
    });
    var handleExpand = function handleExpand(node, trigger) {
      var propsTrigger = props.trigger,
        cascaderContext = props.cascaderContext;
      expendClickEffect(propsTrigger, trigger, node, cascaderContext);
    };
    var renderItem = function renderItem(node) {
      return createVNode(Item, {
        "key": node.value,
        "node": node,
        "cascaderContext": props.cascaderContext,
        "onClick": function onClick() {
          handleExpand(node, "click");
        },
        "onMouseenter": function onMouseenter() {
          handleExpand(node, "hover");
        },
        "onChange": function onChange() {
          valueChangeEffect(node, props.cascaderContext);
        }
      }, null);
    };
    var renderList = function renderList(treeNodes) {
      var _ref;
      var isFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var segment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "1";
      return createVNode("ul", {
        "class": ["".concat(COMPONENT_NAME.value, "__menu"), "narrow-scrollbar", (_ref = {}, _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "__menu--segment"), segment), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "__menu--filter"), isFilter), _ref)],
        "key": key
      }, [treeNodes.map(function (node) {
        return renderItem(node);
      })]);
    };
    var renderPanels = function renderPanels() {
      var _props$cascaderContex = props.cascaderContext,
        inputVal = _props$cascaderContex.inputVal,
        treeNodes = _props$cascaderContex.treeNodes;
      return inputVal ? renderList(treeNodes, true) : panels.value.map(function (treeNodes2, index) {
        return renderList(treeNodes2, false, index !== panels.value.length - 1, "".concat(COMPONENT_NAME.value, "__menu").concat(index));
      });
    };
    return function () {
      var content;
      if (props.loading) {
        content = renderTNodeJSXDefault("loadingText", createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.loadingText]));
      } else {
        content = panels.value.length ? renderPanels() : renderTNodeJSXDefault("empty", createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.empty]));
      }
      return createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__panel"), _defineProperty({}, "".concat(COMPONENT_NAME.value, "--normal"), panels.value.length && !props.loading)]
      }, [content]);
    };
  }
});

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