"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _ui = require("../../ui");
var _dom = require("../../ui/src/dom");
var _utils = require("../../ui/src/utils");
var _util = require("../../tree/src/util");
var _log = require("../../ui/src/log");
var _input = _interopRequireDefault(require("../../input/src/input"));
var _button = _interopRequireDefault(require("../../button/src/button"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function getOptUniqueId() {
  return _xeUtils.default.uniqueId('node_');
}
function createInternalData() {
  return {
    // hpTimeout: undefined,
    fullOptionList: [],
    fullNodeMaps: {}
  };
}
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeCascader',
  mixins: [_ui.globalMixins.sizeMixin],
  model: {
    prop: 'value',
    event: 'modelValue'
  },
  props: {
    value: [String, Number, Array],
    clearable: Boolean,
    placeholder: {
      type: String,
      default: function _default() {
        return _xeUtils.default.eqNull((0, _ui.getConfig)().cascader.placeholder) ? (0, _ui.getI18n)('vxe.base.pleaseSelect') : (0, _ui.getConfig)().cascader.placeholder;
      }
    },
    readonly: {
      type: Boolean,
      default: null
    },
    loading: Boolean,
    disabled: {
      type: Boolean,
      default: null
    },
    filterable: Boolean,
    filterConfig: Object,
    multiple: Boolean,
    className: [String, Function],
    prefixIcon: String,
    placement: String,
    transform: Boolean,
    lazyOptions: Array,
    options: Array,
    optionProps: Object,
    zIndex: Number,
    size: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().cascader.size || (0, _ui.getConfig)().size;
      }
    },
    remote: Boolean,
    remoteConfig: Function,
    popupConfig: Object,
    treeConfig: Object,
    autoClose: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().cascader.autoClose;
      }
    },
    showTotalButoon: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().cascader.showTotalButoon;
      }
    },
    showCheckedButoon: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().cascader.showCheckedButoon;
      }
    },
    showClearButton: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().cascader.showClearButton;
      }
    },
    transfer: {
      type: Boolean,
      default: null
    },
    /**
     * 已废弃，被 remote-config.queryMethod 替换
     * @deprecated
     */
    remoteMethod: Function
  },
  inject: {
    $xeModal: {
      default: null
    },
    $xeDrawer: {
      default: null
    },
    $xeTable: {
      default: null
    },
    $xeForm: {
      default: null
    },
    formItemInfo: {
      from: 'xeFormItemInfo',
      default: null
    }
  },
  provide: function provide() {
    var $xeCascader = this;
    return {
      $xeCascader: $xeCascader
    };
  },
  data: function data() {
    var xID = _xeUtils.default.uniqueId();
    var reactData = {
      initialized: false,
      searchValue: '',
      searchLoading: false,
      panelIndex: 0,
      panelStyle: {},
      panelPlacement: null,
      triggerFocusPanel: false,
      visiblePanel: false,
      isAniVisible: false,
      isActivated: false
    };
    var internalData = createInternalData();
    return {
      xID: xID,
      reactData: reactData,
      internalData: internalData
    };
  },
  computed: Object.assign(Object.assign({}, {}), {
    computeFormReadonly: function computeFormReadonly() {
      var $xeCascader = this;
      var props = $xeCascader;
      var $xeForm = $xeCascader.$xeForm;
      var readonly = props.readonly;
      if (readonly === null) {
        if ($xeForm) {
          return $xeForm.readonly;
        }
        return false;
      }
      return readonly;
    },
    computeIsDisabled: function computeIsDisabled() {
      var $xeCascader = this;
      var props = $xeCascader;
      var $xeForm = $xeCascader.$xeForm;
      var disabled = props.disabled;
      if (disabled === null) {
        if ($xeForm) {
          return $xeForm.disabled;
        }
        return false;
      }
      return disabled;
    },
    computeBtnTransfer: function computeBtnTransfer() {
      var $xeCascader = this;
      var props = $xeCascader;
      var $xeTable = $xeCascader.$xeTable;
      var $xeModal = $xeCascader.$xeModal;
      var $xeDrawer = $xeCascader.$xeDrawer;
      var $xeForm = $xeCascader.$xeForm;
      var transfer = props.transfer;
      if (transfer === null) {
        var globalTransfer = (0, _ui.getConfig)().cascader.transfer;
        if (_xeUtils.default.isBoolean(globalTransfer)) {
          return globalTransfer;
        }
        if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
          return true;
        }
      }
      return transfer;
    },
    computePopupOpts: function computePopupOpts() {
      var $xeCascader = this;
      var props = $xeCascader;
      return Object.assign({}, (0, _ui.getConfig)().cascader.popupConfig, props.popupConfig);
    },
    computeTreeOpts: function computeTreeOpts() {
      var $xeCascader = this;
      var props = $xeCascader;
      return Object.assign({}, (0, _ui.getConfig)().cascader.treeConfig, props.treeConfig);
    },
    computeTreeNodeOpts: function computeTreeNodeOpts() {
      var $xeCascader = this;
      var treeOpts = $xeCascader.computeTreeOpts;
      return Object.assign({
        isHover: true
      }, treeOpts.nodeConfig);
    },
    computeTreeCheckboxOpts: function computeTreeCheckboxOpts() {
      var $xeCascader = this;
      var treeOpts = $xeCascader.computeTreeOpts;
      return Object.assign({
        showIcon: !!treeOpts.showCheckbox
      }, treeOpts.checkboxConfig, {
        trigger: 'node'
      });
    },
    computeTreeRadioOpts: function computeTreeRadioOpts() {
      var $xeCascader = this;
      var treeOpts = $xeCascader.computeTreeOpts;
      return Object.assign({
        showIcon: !!treeOpts.showRadio
      }, treeOpts.radioConfig, {
        trigger: 'node'
      });
    },
    computePropsOpts: function computePropsOpts() {
      var $xeCascader = this;
      var props = $xeCascader;
      return Object.assign({}, props.optionProps);
    },
    computeNodeKeyField: function computeNodeKeyField() {
      var $xeCascader = this;
      var valueField = $xeCascader.computeValueField;
      return valueField;
    },
    computeLabelField: function computeLabelField() {
      var $xeCascader = this;
      var propsOpts = $xeCascader.computePropsOpts;
      return propsOpts.label || 'label';
    },
    computeValueField: function computeValueField() {
      var $xeCascader = this;
      var propsOpts = $xeCascader.computePropsOpts;
      return propsOpts.value || 'value';
    },
    computeChildrenField: function computeChildrenField() {
      var $xeCascader = this;
      var propsOpts = $xeCascader.computePropsOpts;
      return propsOpts.children || 'children';
    },
    computeParentField: function computeParentField() {
      var $xeCascader = this;
      var propsOpts = $xeCascader.computePropsOpts;
      return propsOpts.parent || 'parentField';
    },
    computeHasChildField: function computeHasChildField() {
      var $xeCascader = this;
      var propsOpts = $xeCascader.computePropsOpts;
      return propsOpts.hasChild || 'hasChild';
    },
    computeRemoteOpts: function computeRemoteOpts() {
      var $xeCascader = this;
      var props = $xeCascader;
      return Object.assign({}, (0, _ui.getConfig)().cascader.remoteConfig, props.remoteConfig);
    },
    computeFilterOpts: function computeFilterOpts() {
      var $xeCascader = this;
      var props = $xeCascader;
      var treeOpts = $xeCascader.computeTreeOpts;
      return Object.assign({}, treeOpts.filterConfig, props.filterConfig);
    },
    computeSelectLabel: function computeSelectLabel() {
      var $xeCascader = this;
      var props = $xeCascader;
      var internalData = $xeCascader.internalData;
      var modelValue = props.value,
        lazyOptions = props.lazyOptions;
      var fullNodeMaps = internalData.fullNodeMaps;
      var valueField = $xeCascader.computeValueField;
      var labelField = $xeCascader.computeLabelField;
      var selectVals = _xeUtils.default.eqNull(modelValue) ? [] : _xeUtils.default.isArray(modelValue) ? modelValue : [modelValue];
      return selectVals.map(function (val) {
        var cacheItem = fullNodeMaps[val];
        if (cacheItem) {
          return cacheItem.item[labelField];
        }
        if (lazyOptions) {
          var lazyItem = lazyOptions.find(function (item) {
            return item[valueField] === val;
          });
          if (lazyItem) {
            return lazyItem[labelField];
          }
        }
        return val;
      }).join(', ');
    },
    computePopupWrapperStyle: function computePopupWrapperStyle() {
      var $xeCascader = this;
      var popupOpts = $xeCascader.computePopupOpts;
      var height = popupOpts.height,
        width = popupOpts.width;
      var stys = {};
      if (width) {
        stys.width = (0, _dom.toCssUnit)(width);
      }
      if (height) {
        stys.height = (0, _dom.toCssUnit)(height);
        stys.maxHeight = (0, _dom.toCssUnit)(height);
      }
      return stys;
    }
  }),
  methods: {
    //
    // Method
    //
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeCascader = this;
      $xeCascader.$emit(type, (0, _ui.createEvent)(evnt, {
        $cascader: $xeCascader
      }, params));
    },
    emitModel: function emitModel(value) {
      var $xeCascader = this;
      var _events = $xeCascader._events;
      if (_events && _events.modelValue) {
        $xeCascader.$emit('modelValue', value);
      } else {
        $xeCascader.$emit('model-value', value);
      }
    },
    getNodeid: function getNodeid(option) {
      var $xeCascader = this;
      var nodeKeyField = $xeCascader.computeNodeKeyField;
      var nodeid = option[nodeKeyField];
      return nodeid ? encodeURIComponent(nodeid) : '';
    },
    cacheDataMap: function cacheDataMap() {
      var $xeCascader = this;
      var props = $xeCascader;
      var internalData = $xeCascader.internalData;
      var options = props.options;
      var nodeKeyField = $xeCascader.computeNodeKeyField;
      var childrenField = $xeCascader.computeChildrenField;
      var valueField = $xeCascader.computeValueField;
      var nodeMaps = {};
      var keyMaps = {};
      _xeUtils.default.eachTree(options, function (item, index, items, path, parent, nodes) {
        var nodeid = $xeCascader.getNodeid(item);
        if (!nodeid) {
          nodeid = getOptUniqueId();
        }
        if (keyMaps[nodeid]) {
          (0, _log.errLog)('vxe.error.repeatKey', ["[tree-select] ".concat(nodeKeyField), nodeid]);
        }
        keyMaps[nodeid] = true;
        var value = item[valueField];
        if (nodeMaps[value]) {
          (0, _log.errLog)('vxe.error.repeatKey', ["[tree-select] ".concat(valueField), value]);
        }
        nodeMaps[value] = {
          item: item,
          index: index,
          items: items,
          parent: parent,
          nodes: nodes
        };
      }, {
        children: childrenField
      });
      internalData.fullOptionList = options || [];
      internalData.fullNodeMaps = nodeMaps;
    },
    updateZindex: function updateZindex() {
      var $xeCascader = this;
      var props = $xeCascader;
      var reactData = $xeCascader.reactData;
      var zIndex = props.zIndex;
      if (zIndex) {
        reactData.panelIndex = zIndex;
      } else if (reactData.panelIndex < (0, _utils.getLastZIndex)()) {
        reactData.panelIndex = (0, _utils.nextZIndex)();
      }
    },
    updatePlacement: function updatePlacement() {
      var $xeCascader = this;
      var props = $xeCascader;
      var reactData = $xeCascader.reactData;
      var placement = props.placement;
      var panelIndex = reactData.panelIndex;
      var targetElem = $xeCascader.$refs.refElem;
      var panelElem = $xeCascader.$refs.refOptionPanel;
      var btnTransfer = $xeCascader.computeBtnTransfer;
      var popupOpts = $xeCascader.computePopupOpts;
      var handleStyle = function handleStyle() {
        var ppObj = (0, _dom.updatePanelPlacement)(targetElem, panelElem, {
          placement: popupOpts.placement || placement,
          defaultPlacement: popupOpts.defaultPlacement,
          teleportTo: btnTransfer
        });
        var panelStyle = Object.assign(ppObj.style, {
          zIndex: panelIndex
        });
        reactData.panelStyle = panelStyle;
        reactData.panelPlacement = ppObj.placement;
      };
      handleStyle();
      return $xeCascader.$nextTick().then(handleStyle);
    },
    showOptionPanel: function showOptionPanel() {
      var $xeCascader = this;
      var props = $xeCascader;
      var reactData = $xeCascader.reactData;
      var internalData = $xeCascader.internalData;
      var loading = props.loading,
        remote = props.remote,
        filterable = props.filterable;
      var fullOptionList = internalData.fullOptionList;
      var isDisabled = $xeCascader.computeIsDisabled;
      var remoteOpts = $xeCascader.computeRemoteOpts;
      if (!loading && !isDisabled) {
        if (internalData.hpTimeout) {
          clearTimeout(internalData.hpTimeout);
        }
        if (!reactData.initialized) {
          reactData.initialized = true;
          var btnTransfer = $xeCascader.computeBtnTransfer;
          var panelElem = $xeCascader.$refs.refOptionPanel;
          if (btnTransfer) {
            if (panelElem) {
              document.body.appendChild(panelElem);
            }
          }
        }
        reactData.isActivated = true;
        reactData.isAniVisible = true;
        if (filterable) {
          if (remote && remoteOpts.enabled && remoteOpts.autoLoad && !fullOptionList.length) {
            $xeCascader.handleSearchEvent();
          }
        }
        setTimeout(function () {
          reactData.visiblePanel = true;
          $xeCascader.handleFocusSearch();
        }, 10);
        $xeCascader.updateZindex();
        $xeCascader.updatePlacement();
      }
    },
    hideOptionPanel: function hideOptionPanel() {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var internalData = $xeCascader.internalData;
      reactData.visiblePanel = false;
      internalData.hpTimeout = setTimeout(function () {
        reactData.isAniVisible = false;
      }, 350);
    },
    changeEvent: function changeEvent(evnt, selectValue, node) {
      var $xeCascader = this;
      var props = $xeCascader;
      var $xeForm = $xeCascader.$xeForm;
      var formItemInfo = $xeCascader.formItemInfo;
      var value = _xeUtils.default.isArray(selectValue) ? selectValue.map(_util.deNodeValue) : (0, _util.deNodeValue)(selectValue);
      $xeCascader.emitModel(value);
      if (value !== props.value) {
        $xeCascader.dispatchEvent('change', {
          value: value,
          node: node,
          option: node
        }, evnt);
        // 自动更新校验状态
        if ($xeForm && formItemInfo) {
          $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
        }
      }
    },
    clearValueEvent: function clearValueEvent(evnt, selectValue) {
      var $xeCascader = this;
      $xeCascader.changeEvent(evnt, selectValue, null);
      $xeCascader.dispatchEvent('clear', {
        value: selectValue
      }, evnt);
    },
    clearEvent: function clearEvent(params, evnt) {
      var $xeCascader = this;
      $xeCascader.clearValueEvent(evnt, null);
      $xeCascader.hideOptionPanel();
    },
    allCheckedPanelEvent: function allCheckedPanelEvent(params) {
      var $xeCascader = this;
      var props = $xeCascader;
      var $event = params.$event;
      var multiple = props.multiple,
        autoClose = props.autoClose;
      var $tree = $xeCascader.$refs.refTree;
      if (multiple) {
        if ($tree) {
          $tree.setAllCheckboxNode(true).then(function (_ref) {
            var checkNodeKeys = _ref.checkNodeKeys,
              checkNodes = _ref.checkNodes;
            $xeCascader.changeEvent($event, checkNodeKeys, checkNodes[0]);
            $xeCascader.dispatchEvent('all-change', {
              value: checkNodeKeys
            }, $event);
            if (autoClose) {
              $xeCascader.hideOptionPanel();
            }
          });
        }
      }
    },
    clearCheckedPanelEvent: function clearCheckedPanelEvent(params) {
      var $xeCascader = this;
      var props = $xeCascader;
      var $event = params.$event;
      var multiple = props.multiple,
        autoClose = props.autoClose;
      var $tree = $xeCascader.$refs.refTree;
      if ($tree) {
        var value = multiple ? [] : null;
        $tree.clearCheckboxNode().then(function () {
          if (autoClose) {
            $xeCascader.hideOptionPanel();
          }
        });
        $xeCascader.changeEvent($event, value, null);
        $xeCascader.dispatchEvent('clear', {
          value: value
        }, $event);
      }
    },
    allExpandPanelEvent: function allExpandPanelEvent() {
      var $xeCascader = this;
      var $tree = $xeCascader.$refs.refTree;
      if ($tree) {
        $tree.setAllExpandNode(true);
      }
    },
    clearExpandPanelEvent: function clearExpandPanelEvent() {
      var $xeCascader = this;
      var $tree = $xeCascader.$refs.refTree;
      if ($tree) {
        $tree.clearAllExpandNode();
      }
    },
    handleGlobalMousewheelEvent: function handleGlobalMousewheelEvent(evnt) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var visiblePanel = reactData.visiblePanel;
      var isDisabled = $xeCascader.computeIsDisabled;
      if (!isDisabled) {
        if (visiblePanel) {
          var panelElem = $xeCascader.$refs.refOptionPanel;
          if ((0, _dom.getEventTargetNode)(evnt, panelElem).flag) {
            $xeCascader.updatePlacement();
          } else {
            $xeCascader.hideOptionPanel();
          }
        }
      }
    },
    handleGlobalMousedownEvent: function handleGlobalMousedownEvent(evnt) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var visiblePanel = reactData.visiblePanel;
      var isDisabled = $xeCascader.computeIsDisabled;
      if (!isDisabled) {
        var el = $xeCascader.$refs.refElem;
        var panelElem = $xeCascader.$refs.refOptionPanel;
        reactData.isActivated = (0, _dom.getEventTargetNode)(evnt, el).flag || (0, _dom.getEventTargetNode)(evnt, panelElem).flag;
        if (visiblePanel && !reactData.isActivated) {
          $xeCascader.hideOptionPanel();
        }
      }
    },
    handleGlobalBlurEvent: function handleGlobalBlurEvent() {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var visiblePanel = reactData.visiblePanel,
        isActivated = reactData.isActivated;
      if (visiblePanel) {
        $xeCascader.hideOptionPanel();
      }
      if (isActivated) {
        reactData.isActivated = false;
      }
      if (visiblePanel || isActivated) {
        var $input = $xeCascader.$refs.refInput;
        if ($input) {
          $input.blur();
        }
      }
    },
    handleGlobalResizeEvent: function handleGlobalResizeEvent() {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var visiblePanel = reactData.visiblePanel;
      if (visiblePanel) {
        $xeCascader.updatePlacement();
      }
    },
    handleFocusSearch: function handleFocusSearch() {
      var $xeSelect = this;
      var props = $xeSelect;
      if (props.filterable) {
        $xeSelect.$nextTick(function () {
          var inpSearch = $xeSelect.$refs.refInpSearch;
          if (inpSearch) {
            inpSearch.focus();
          }
        });
      }
    },
    focusEvent: function focusEvent(evnt) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var isDisabled = $xeCascader.computeIsDisabled;
      if (!isDisabled) {
        if (!reactData.visiblePanel) {
          reactData.triggerFocusPanel = true;
          $xeCascader.showOptionPanel();
          setTimeout(function () {
            reactData.triggerFocusPanel = false;
          }, 150);
        }
      }
      $xeCascader.dispatchEvent('focus', {}, evnt);
    },
    clickEvent: function clickEvent(evnt) {
      var $xeCascader = this;
      $xeCascader.togglePanelEvent(evnt);
      $xeCascader.dispatchEvent('click', {}, evnt);
    },
    blurEvent: function blurEvent(evnt) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      reactData.isActivated = false;
      $xeCascader.dispatchEvent('blur', {}, evnt);
    },
    modelSearchEvent: function modelSearchEvent(value) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      reactData.searchValue = value;
    },
    handleSearchEvent: function handleSearchEvent() {
      var $xeCascader = this;
      var props = $xeCascader;
      var reactData = $xeCascader.reactData;
      var modelValue = props.value,
        remote = props.remote,
        remoteMethod = props.remoteMethod;
      var searchValue = reactData.searchValue;
      var remoteOpts = $xeCascader.computeRemoteOpts;
      var queryMethod = remoteOpts.queryMethod || remoteMethod;
      if (remote && queryMethod && remoteOpts.enabled) {
        reactData.searchLoading = true;
        Promise.resolve(queryMethod({
          $cascader: $xeCascader,
          searchValue: searchValue,
          value: modelValue
        })).then(function () {
          return $xeCascader.$nextTick();
        }).catch(function () {
          return $xeCascader.$nextTick();
        }).finally(function () {
          reactData.searchLoading = false;
        });
      }
    },
    togglePanelEvent: function togglePanelEvent(params) {
      var $xeCascader = this;
      var reactData = $xeCascader.reactData;
      var $event = params.$event;
      $event.preventDefault();
      if (reactData.triggerFocusPanel) {
        reactData.triggerFocusPanel = false;
      } else {
        if (reactData.visiblePanel) {
          $xeCascader.hideOptionPanel();
        } else {
          $xeCascader.showOptionPanel();
        }
      }
    },
    nodeClickEvent: function nodeClickEvent(params) {
      var $xeCascader = this;
      var $event = params.$event;
      $xeCascader.dispatchEvent('node-click', params, $event);
    },
    radioChangeEvent: function radioChangeEvent(params) {
      var $xeCascader = this;
      var value = params.value,
        $event = params.$event,
        node = params.node;
      $xeCascader.changeEvent($event, value, node);
      $xeCascader.hideOptionPanel();
    },
    checkboxChangeEvent: function checkboxChangeEvent(params) {
      var $xeCascader = this;
      var value = params.value,
        $event = params.$event,
        node = params.node;
      $xeCascader.changeEvent($event, value, node);
    },
    loadSuccessEvent: function loadSuccessEvent() {
      var $xeCascader = this;
      $xeCascader.cacheDataMap();
    },
    //
    // Render
    //
    renderVN: function renderVN(h) {
      var $xeCascader = this;
      var props = $xeCascader;
      var slots = $xeCascader.$scopedSlots;
      var reactData = $xeCascader.reactData;
      var className = props.className,
        modelValue = props.value,
        multiple = props.multiple,
        loading = props.loading,
        filterable = props.filterable,
        showTotalButoon = props.showTotalButoon,
        showCheckedButoon = props.showCheckedButoon,
        showClearButton = props.showClearButton;
      var initialized = reactData.initialized,
        isActivated = reactData.isActivated,
        isAniVisible = reactData.isAniVisible,
        visiblePanel = reactData.visiblePanel,
        searchValue = reactData.searchValue;
      var vSize = $xeCascader.computeSize;
      var isDisabled = $xeCascader.computeIsDisabled;
      var selectLabel = $xeCascader.computeSelectLabel;
      var btnTransfer = $xeCascader.computeBtnTransfer;
      var formReadonly = $xeCascader.computeFormReadonly;
      var popupWrapperStyle = $xeCascader.computePopupWrapperStyle;
      var headerSlot = slots.header;
      var footerSlot = slots.footer;
      var prefixSlot = slots.prefix;
      var popupOpts = $xeCascader.computePopupOpts;
      var popupClassName = popupOpts.className;
      if (formReadonly) {
        return h('div', {
          ref: 'refElem',
          class: ['vxe-cascader--readonly', className]
        }, [h('span', {
          class: 'vxe-cascader-label'
        }, selectLabel)]);
      }
      var selectVals = _xeUtils.default.eqNull(modelValue) ? [] : _xeUtils.default.isArray(modelValue) ? modelValue : [modelValue];
      return h('div', {
        ref: 'refElem',
        class: ['vxe-cascader', className ? _xeUtils.default.isFunction(className) ? className({
          $cascader: $xeCascader
        }) : className : '', _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "size--".concat(vSize), vSize), 'is--filterable', filterable), 'is--visible', visiblePanel), 'is--disabled', isDisabled), 'is--loading', loading), 'is--active', isActivated)]
      }, [h(_input.default, {
        ref: 'refInput',
        props: {
          clearable: props.clearable,
          placeholder: props.placeholder,
          editable: false,
          disabled: isDisabled,
          type: 'text',
          prefixIcon: props.prefixIcon,
          suffixIcon: loading ? (0, _ui.getIcon)().TREE_SELECT_LOADED : visiblePanel ? (0, _ui.getIcon)().TREE_SELECT_OPEN : (0, _ui.getIcon)().TREE_SELECT_CLOSE,
          value: loading ? (0, _ui.getI18n)('vxe.select.loadingText') : selectLabel,
          title: selectLabel
        },
        on: {
          clear: $xeCascader.clearEvent,
          click: $xeCascader.clickEvent,
          focus: $xeCascader.focusEvent,
          blur: $xeCascader.blurEvent,
          'suffix-click': $xeCascader.togglePanelEvent
        },
        scopedSlots: prefixSlot ? {
          prefix: function prefix() {
            return prefixSlot({});
          }
        } : {}
      }), h('div', {
        ref: 'refOptionPanel',
        class: ['vxe-table--ignore-clear vxe-cascader--panel', popupClassName ? _xeUtils.default.isFunction(popupClassName) ? popupClassName({
          $cascader: $xeCascader
        }) : popupClassName : '', _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "size--".concat(vSize), vSize), 'is--transfer', btnTransfer), 'ani--leave', !loading && isAniVisible), 'ani--enter', !loading && visiblePanel)],
        attrs: {
          placement: reactData.panelPlacement
        },
        style: reactData.panelStyle
      }, initialized ? [h('div', {
        class: 'vxe-cascader--panel-wrapper'
      }, [filterable ? h('div', {
        class: 'vxe-cascader--panel-search'
      }, [h(_input.default, {
        ref: 'refInpSearch',
        class: 'vxe-cascader-search--input',
        props: {
          value: searchValue,
          title: selectLabel,
          clearable: true,
          disabled: false,
          readonly: false,
          placeholder: (0, _ui.getI18n)('vxe.cascader.search'),
          prefixIcon: (0, _ui.getIcon)().INPUT_SEARCH
        },
        on: {
          'model-value': $xeCascader.modelSearchEvent
        }
      })]) : (0, _ui.renderEmptyElement)($xeCascader), showTotalButoon || showCheckedButoon && multiple || showClearButton || headerSlot ? h('div', {
        class: 'vxe-cascader--panel-header'
      }, headerSlot ? headerSlot({}) : [h('div', {
        class: 'vxe-cascader--header-button'
      }, [showTotalButoon ? h('div', {
        class: 'vxe-cascader--header-total'
      }, (0, _ui.getI18n)('vxe.cascader.total', [selectVals.length])) : (0, _ui.renderEmptyElement)($xeCascader), h('div', {
        class: 'vxe-cascader--header-btns'
      }, [showCheckedButoon && multiple ? h(_button.default, {
        props: {
          content: (0, _ui.getI18n)('vxe.cascader.allChecked'),
          mode: 'text'
        },
        on: {
          click: $xeCascader.allCheckedPanelEvent
        }
      }) : (0, _ui.renderEmptyElement)($xeCascader), showClearButton ? h(_button.default, {
        props: {
          content: (0, _ui.getI18n)('vxe.cascader.clearChecked'),
          mode: 'text'
        },
        on: {
          click: $xeCascader.clearCheckedPanelEvent
        }
      }) : (0, _ui.renderEmptyElement)($xeCascader)])])]) : (0, _ui.renderEmptyElement)($xeCascader), h('div', {
        class: 'vxe-cascader--panel-body'
      }, [h('div', {
        ref: 'refTreeWrapper',
        class: 'vxe-cascader-tree--wrapper',
        style: popupWrapperStyle
      }, [])]), footerSlot ? h('div', {
        class: 'vxe-cascader--panel-footer'
      }, footerSlot({})) : (0, _ui.renderEmptyElement)($xeCascader)])] : [])]);
    }
  },
  watch: {
    options: function options() {
      var $xeCascader = this;
      $xeCascader.cacheDataMap();
    }
  },
  created: function created() {
    var $xeCascader = this;
    $xeCascader.cacheDataMap();
  },
  mounted: function mounted() {
    var $xeCascader = this;
    _ui.globalEvents.on($xeCascader, 'mousewheel', $xeCascader.handleGlobalMousewheelEvent);
    _ui.globalEvents.on($xeCascader, 'mousedown', $xeCascader.handleGlobalMousedownEvent);
    _ui.globalEvents.on($xeCascader, 'blur', $xeCascader.handleGlobalBlurEvent);
    _ui.globalEvents.on($xeCascader, 'resize', $xeCascader.handleGlobalResizeEvent);
  },
  beforeDestroy: function beforeDestroy() {
    var $xeCascader = this;
    var panelElem = $xeCascader.$refs.refOptionPanel;
    if (panelElem && panelElem.parentNode) {
      panelElem.parentNode.removeChild(panelElem);
    }
    _ui.globalEvents.off($xeCascader, 'mousewheel');
    _ui.globalEvents.off($xeCascader, 'mousedown');
    _ui.globalEvents.off($xeCascader, 'blur');
    _ui.globalEvents.off($xeCascader, 'resize');
  },
  destroyed: function destroyed() {
    var $xeCascader = this;
    var internalData = $xeCascader.internalData;
    _xeUtils.default.assign(internalData, createInternalData());
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */