const nodeMap = /* @__PURE__ */ new Map();
const vClickOutside = {
  mounted(el, binding) {
    const listenerFunction = (event) => {
      if (el.contains(event.target)) {
        return;
      }
      if (binding.value && typeof binding.value === "function") {
        binding.value(event);
      }
    };
    if (!nodeMap.has(el)) {
      nodeMap.set(el, []);
    }
    const nodeCallbackList = nodeMap.get(el);
    nodeCallbackList.push(listenerFunction);
    document.addEventListener("click", listenerFunction);
    document.addEventListener("touchend", listenerFunction);
  },
  unmounted(el) {
    const nodeCallbackList = nodeMap.get(el);
    nodeCallbackList.forEach((callback) => {
      document.removeEventListener("click", callback);
      document.addEventListener("touchend", callback);
    });
  }
};
export {
  vClickOutside as default
};
