// HACK: Suppress Chromium passive event listener warnings caused by Vuetify 3 internals.
// This forces passive: true on touch/wheel events. If scroll-prevention breaks in dialogs
// or menus, this is the likely culprit. See CLAUDE.md for details.
const _origAEL = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (type, listener, options) {
  if (type === "touchstart" || type === "touchmove" || type === "wheel" || type === "mousewheel") {
    // Respect explicit passive: false (e.g. zoom ctrl+wheel needs preventDefault)
    if (typeof options === "object" && options.passive === false) {
      return _origAEL.call(this, type, listener, options);
    }
    const opts = typeof options === "object" ? { ...options, passive: true } : { capture: !!options, passive: true };
    return _origAEL.call(this, type, listener, opts);
  }
  return _origAEL.call(this, type, listener, options);
};

import { createApp } from "vue";
import App from "@renderer/App.vue";

import router from "@renderer/router.js";
import { shared } from "@renderer/shared.js";
import i18n from "./i18n";
import vuetify from "@renderer/plugins/vuetify";

import "roboto-fontface/css/roboto/roboto-fontface.css";
import "@mdi/font/css/materialdesignicons.css";

// Re-export eventBus for backward compatibility with existing imports
export { eventBus } from "@renderer/eventBus.js";

// Create Vue 3 app
const app = createApp(App);

// Global properties (replaces Vue.prototype)
app.config.globalProperties.$shared = shared;

// Use plugins
app.use(router);
app.use(i18n);
app.use(vuetify);

// Mount app
app.mount("#app");
