import { createApp } from "vue";
import LoadScript from "vue-plugin-load-script";
import Maska from "maska";
import App from "./App.vue";
import router from "./router";
import store from "@/store";
import baseMixin from "@/mixins/base-mixin.js";
import analyticsMixin from "@/mixins/analytics-mixin.js";
import experimentMixin from "@/mixins/experiment-mixin.js";
import "../node_modules/bootstrap/dist/js/bootstrap.js";
import "../node_modules/jquery-ui/dist/jquery-ui.min.js";

// Make jQuery avaialble globally
window.$ = window.jQuery = require("jquery");

import Logger from "@/helpers/logger";
// Instantiate global logging object
global.$logger = new Logger();

// Vue App Setup
const vueApp = createApp(App);

vueApp.use(router);
vueApp.use(store);
vueApp.use(LoadScript);
vueApp.use(Maska);
vueApp.mixin(baseMixin);
vueApp.mixin(analyticsMixin);
vueApp.mixin(experimentMixin);

// Vue Error Handling
vueApp.config.errorHandler = (err, vm, info) => {
    global.$logger.logError(
        `Page Name - ${vm.getPageName()} - ${info}: ${err.message}\n${err.stack}`
    );
};

vueApp.mount("#app");
