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

'use strict';

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

var hooks_useConfig = require('../../hooks/useConfig.js');
require('@vue/composition-api');
require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
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-7c884501.js');
require('dayjs');

function useItemEvents(props, context) {
  var node = props.node;
  var classPrefix = hooks_useConfig.usePrefixClass().value;
  var handleChange = function handleChange(_, ctx) {
    var event = new Event("change");
    var state = {
      event: event,
      node: node
    };
    context.emit("change", state, ctx);
  };
  var clicked = false;
  var handleClick = function handleClick(evt) {
    var _srcTarget$className, _srcTarget$className$;
    var expandOnClickNode = props.expandOnClickNode;
    var srcTarget = evt.target;
    var isBranchTrigger = node.children && expandOnClickNode && (srcTarget.className === "".concat(classPrefix, "-checkbox__input") || srcTarget.tagName.toLowerCase() === "input");
    if (clicked || isBranchTrigger) return;
    clicked = true;
    setTimeout(function () {
      clicked = false;
    });
    if (expandOnClickNode && node.children && ((_srcTarget$className = srcTarget.className) === null || _srcTarget$className === void 0 ? void 0 : (_srcTarget$className$ = _srcTarget$className.indexOf) === null || _srcTarget$className$ === void 0 ? void 0 : _srcTarget$className$.call(_srcTarget$className, "".concat(classPrefix, "-tree__label"))) !== -1) evt.preventDefault();
    var state = {
      mouseEvent: evt,
      event: evt,
      node: node,
      path: node.getPath()
    };
    context.emit("click", state);
  };
  return {
    handleChange: handleChange,
    handleClick: handleClick
  };
}

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