"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const types = require("../../utils/types.js");
const runtime = require("../../utils/vue/props/runtime.js");
const index = require("../use-timeout/index.js");
const Vue = require("vue");
const useDelayedToggleProps = runtime.buildProps({
  showAfter: {
    type: Number,
    default: 0
  },
  hideAfter: {
    type: Number,
    default: 200
  },
  autoClose: {
    type: Number,
    default: 0
  }
});
const useDelayedToggle = ({ showAfter, hideAfter, autoClose, open, close }) => {
  const { registerTimeout } = index.useTimeout();
  const { registerTimeout: registerTimeoutForAutoClose, cancelTimeout: cancelTimeoutForAutoClose } = index.useTimeout();
  const onOpen = (event, delay = Vue.unref(showAfter)) => {
    registerTimeout(() => {
      open(event);
      const _autoClose = Vue.unref(autoClose);
      if (types.isNumber(_autoClose) && _autoClose > 0) registerTimeoutForAutoClose(() => {
        close(event);
      }, _autoClose);
    }, delay);
  };
  const onClose = (event, delay = Vue.unref(hideAfter)) => {
    cancelTimeoutForAutoClose();
    registerTimeout(() => {
      close(event);
    }, delay);
  };
  return {
    onOpen,
    onClose
  };
};
exports.useDelayedToggle = useDelayedToggle;
exports.useDelayedToggleProps = useDelayedToggleProps;
