// plugins/my-directive.ts
export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.directive("focus", {
    // called before bound element's attributes
    // or event listeners are applied
    created(el, binding, vnode) {
      // see below for details on arguments

      el.focus();
    },
    // called right before the element is inserted into the DOM.
    beforeMount(el, binding, vnode) {},
    // called when the bound element's parent component
    // and all its children are mounted.
    mounted(el, binding, vnode) {},
    // called before the parent component is updated
    beforeUpdate(el, binding, vnode, prevVnode) {},
    // called after the parent component and
    // all of its children have updated
    updated(el, binding, vnode, prevVnode) {
      var value = binding.value;
      if (value) {
        // Vue.nextTick(function() {
        el.focus();
        // });
      }
    },
    // called before the parent component is unmounted
    beforeUnmount(el, binding, vnode) {},
    // called when the parent component is unmounted
    unmounted(el, binding, vnode) {},

    getSSRProps(binding, vnode) {
      // You can provide SSR-specific props here
      return {};
    },
  });
});
