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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var cascader_props = require('../props.js');
var hooks_useConfig = require('../../hooks/useConfig.js');
var hooks_tnode = require('../../hooks/tnode.js');
var cascader_core_helper = require('../core/helper.js');
var cascader_core_effect = require('../core/effect.js');
var cascader_components_Item = require('./Item.js');
var configProvider_useConfig = require('../../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('lodash/isString');
require('../../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../../_common/js/global-config/default-config.js');
require('../../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../../_chunks/dep-7f0559c3.js');
require('dayjs');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('lodash/isNumber');
require('@babel/runtime/helpers/slicedToArray');
require('@ldesign/icons-vue-next');
require('../core/className.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../../checkbox/index.js');
require('../../utils/withInstall.js');
require('../../checkbox/checkbox.js');
require('../../hooks/useVModel.js');
require('../../form/hooks.js');
require('../../hooks/useRipple.js');
require('../../utils/set-style.js');
require('../../hooks/useKeepAnimation.js');
require('../../checkbox/props.js');
require('../../checkbox/constants.js');
require('../../checkbox/group.js');
require('lodash/intersection');
require('lodash/isUndefined');
require('../../hooks/slot.js');
require('../../checkbox/checkbox-group-props.js');
require('../../loading/index.js');
require('../../loading/directive.js');
require('../../loading/plugin.js');
require('../../utils/dom.js');
require('../../utils/easing.js');
require('../../loading/loading.js');
require('../../hooks/useTeleport.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('../../hooks/useGlobalIcon.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

var Panel = vue.defineComponent({
  name: "TCascaderSubPanel",
  props: {
    empty: cascader_props["default"].empty,
    trigger: cascader_props["default"].trigger,
    onChange: cascader_props["default"].onChange,
    loading: cascader_props["default"].loading,
    loadingText: cascader_props["default"].loadingText,
    cascaderContext: {
      type: Object
    }
  },
  setup: function setup(props) {
    var renderTNodeJSXDefault = hooks_tnode.useTNodeDefault();
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("cascader");
    var _useConfig = configProvider_useConfig.useConfig("cascader"),
      globalConfig = _useConfig.globalConfig;
    var panels = vue.computed(function () {
      return cascader_core_helper.getPanels(props.cascaderContext.treeNodes);
    });
    var handleExpand = function handleExpand(node, trigger) {
      var propsTrigger = props.trigger,
        cascaderContext = props.cascaderContext;
      cascader_core_effect.expendClickEffect(propsTrigger, trigger, node, cascaderContext);
    };
    var renderItem = function renderItem(node) {
      return vue.createVNode(cascader_components_Item["default"], {
        "key": node.value,
        "node": node,
        "cascaderContext": props.cascaderContext,
        "onClick": function onClick() {
          handleExpand(node, "click");
        },
        "onMouseenter": function onMouseenter() {
          handleExpand(node, "hover");
        },
        "onChange": function onChange() {
          cascader_core_effect.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 vue.createVNode("ul", {
        "class": ["".concat(COMPONENT_NAME.value, "__menu"), "narrow-scrollbar", (_ref = {}, _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "__menu--segment"), segment), _defineProperty__default["default"](_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", vue.createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.loadingText]));
      } else {
        content = panels.value.length ? renderPanels() : renderTNodeJSXDefault("empty", vue.createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.empty]));
      }
      return vue.createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__panel"), _defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "--normal"), panels.value.length && !props.loading)]
      }, [content]);
    };
  }
});

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