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

import { _ as _defineProperty } from '../../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, computed, createVNode } from 'vue';
import props from '../props.mjs';
import { usePrefixClass } from '../../hooks/useConfig.mjs';
import { useTNodeDefault } from '../../hooks/tnode.mjs';
import { getPanels } from '../core/helper.mjs';
import { expendClickEffect, valueChangeEffect } from '../core/effect.mjs';
import Item from './Item.mjs';
import { useConfig } from '../../config-provider/useConfig.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-095107f7.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../_chunks/dep-c989dff3.mjs';
import '../../_chunks/dep-9cf86cf1.mjs';
import '../../_chunks/dep-bc1d737a.mjs';
import '../../_chunks/dep-4d7a675b.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../_chunks/dep-2e7f59b1.mjs';
import '../../_chunks/dep-855db8bc.mjs';
import '../../_chunks/dep-a87f3e4c.mjs';
import '../../_chunks/dep-1e566bb5.mjs';
import '../../_chunks/dep-1434aa15.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-b57180d0.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-e5eb9f23.mjs';
import '../../_chunks/dep-9fe2ef12.mjs';
import '../../_chunks/dep-672e7d1a.mjs';
import '../../_chunks/dep-42a19209.mjs';
import '../../_chunks/dep-9262ee2f.mjs';
import '../../_chunks/dep-334a4f6b.mjs';
import '../../_chunks/dep-8d3e9aa3.mjs';
import '../../_chunks/dep-876fb3ec.mjs';
import '../../_chunks/dep-40d69a9c.mjs';
import '../../_chunks/dep-dcc83161.mjs';
import '../../_chunks/dep-0fc02184.mjs';
import '../../_chunks/dep-f1994936.mjs';
import '../../_chunks/dep-345e1be3.mjs';
import '../../_common/js/global-config/default-config.mjs';
import '../../_common/js/global-config/locale/zh_CN.mjs';
import '../../_chunks/dep-9888611c.mjs';
import '../../_chunks/dep-697a1365.mjs';
import '../../config-provider/type.mjs';
import '../../_chunks/dep-406cd044.mjs';
import '../../_chunks/dep-42cc3015.mjs';
import '../../_chunks/dep-2bc37d52.mjs';
import '../../_chunks/dep-327559e8.mjs';
import '../../_chunks/dep-b2235f26.mjs';
import '../../_chunks/dep-8b989474.mjs';
import '../../_chunks/dep-1372b2d3.mjs';
import '../../_chunks/dep-9a85dac1.mjs';
import '../../utils/render-tnode.mjs';
import '../../_chunks/dep-888e80c4.mjs';
import '../../_chunks/dep-3f21269a.mjs';
import '../../_chunks/dep-84acf3c2.mjs';
import '../../_chunks/dep-b8d7992c.mjs';
import '@ldesign/icons-vue-next';
import '../core/className.mjs';
import '../../_chunks/dep-bf1e33c8.mjs';
import '../../checkbox/index.mjs';
import '../../utils/withInstall.mjs';
import '../../checkbox/checkbox.mjs';
import '../../hooks/useVModel.mjs';
import '../../form/hooks.mjs';
import '../../hooks/useRipple.mjs';
import '../../utils/set-style.mjs';
import '../../hooks/useKeepAnimation.mjs';
import '../../checkbox/props.mjs';
import '../../checkbox/constants.mjs';
import '../../checkbox/group.mjs';
import '../../_chunks/dep-85ed244c.mjs';
import '../../_chunks/dep-c42916c7.mjs';
import '../../_chunks/dep-78847b2e.mjs';
import '../../hooks/slot.mjs';
import '../../checkbox/checkbox-group-props.mjs';
import '../../checkbox/style/css.mjs';
import '../../checkbox/type.mjs';
import '../../loading/index.mjs';
import '../../loading/directive.mjs';
import '../../loading/plugin.mjs';
import '../../utils/dom.mjs';
import '../../utils/easing.mjs';
import '../../loading/loading.mjs';
import '../../hooks/useTeleport.mjs';
import '../../loading/props.mjs';
import '../../loading/icon/gradient.mjs';
import '../../_common/js/loading/circle-adapter.mjs';
import '../../_common/js/utils/set-style.mjs';
import '../../_common/js/utils/helper.mjs';
import '../../_chunks/dep-60fae668.mjs';
import '../../_chunks/dep-ed5ebb35.mjs';
import '../../loading/style/css.mjs';
import '../../loading/type.mjs';
import '../../hooks/useGlobalIcon.mjs';

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.mjs.map
