"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Vue = require("vue");
const shared_esmBundler = require("../../../../@vue/shared/dist/shared.esm-bundler.js");
const runtime = require("../../utils/vue/props/runtime.js");
const types = require("../../utils/types.js");
const index = require("../../../../@vueuse/shared/index.js");
const A = runtime.buildProp({
  type: runtime.definePropType(Boolean),
  default: null
}), I = runtime.buildProp({
  type: runtime.definePropType(Function)
}), V = (l) => {
  const u = `update:${l}`, c = `onUpdate:${l}`, x = [u], B = {
    [l]: A,
    [c]: I
  };
  return {
    useModelToggle: ({
      indicator: o,
      toggleReason: r,
      shouldHideWhenRouteChanges: g,
      shouldProceed: v,
      onShow: m,
      onHide: M
    }) => {
      const n = Vue.getCurrentInstance(), { emit: p } = n, t = n.props, i = Vue.computed(() => shared_esmBundler.isFunction(t[c])), T = Vue.computed(() => t[l] === null), b = (e) => {
        o.value !== true && (o.value = true, r && (r.value = e), shared_esmBundler.isFunction(m) && m(e));
      }, y = (e) => {
        o.value !== false && (o.value = false, r && (r.value = e), shared_esmBundler.isFunction(M) && M(e));
      }, E = (e) => {
        if (t.disabled === true || shared_esmBundler.isFunction(v) && !v())
          return;
        const s = i.value && index.isClient;
        s && p(u, true), (T.value || !s) && b(e);
      }, a = (e) => {
        if (t.disabled === true || !index.isClient)
          return;
        const s = i.value && index.isClient;
        s && p(u, false), (T.value || !s) && y(e);
      }, C = (e) => {
        types.isBoolean(e) && (t.disabled && e ? i.value && p(u, false) : o.value !== e && (e ? b() : y()));
      }, F = () => {
        o.value ? a() : E();
      };
      return Vue.watch(() => t[l], C), g && n.appContext.config.globalProperties.$route !== void 0 && Vue.watch(() => ({
        ...n.proxy.$route
      }), () => {
        g.value && o.value && a();
      }), Vue.onMounted(() => {
        C(t[l]);
      }), {
        hide: a,
        show: E,
        toggle: F,
        hasUpdateHandler: i
      };
    },
    useModelToggleProps: B,
    useModelToggleEmits: x
  };
};
exports.createModelToggleComposable = V;
