import '../css/app.css';
import './bootstrap';

import { createInertiaApp } from '@inertiajs/vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { createApp, h } from 'vue';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import { library } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import {
    faArrowLeft,
    faArrowRight,
    faChartLine,
    faClipboardList,
    faFolderOpen,
    faUser,
    faCar,
    faCarSide,
    faPaperclip,
    faBuilding,
    faUsers,
    faDollarSign,
    faTimes,
    faSave,
    faInfoCircle,
    faCheckCircle,
    faCloudUploadAlt,
    faSpinner,
    faPlus,
    faSearch,
    faEdit,
    faTrash,
    faEye,
    faShoppingCart,
    faEnvelope,
    faWrench,
    faFilePdf,
    faFileImage,
    faFile
} from '@fortawesome/free-solid-svg-icons';

library.add(
    faArrowLeft,
    faArrowRight,
    faChartLine,
    faClipboardList,
    faFolderOpen,
    faUser,
    faCar,
    faCarSide,
    faPaperclip,
    faBuilding,
    faUsers,
    faDollarSign,
    faTimes,
    faSave,
    faInfoCircle,
    faCheckCircle,
    faCloudUploadAlt,
    faSpinner,
    faPlus,
    faSearch,
    faEdit,
    faTrash,
    faEye,
    faShoppingCart,
    faEnvelope,
    faWrench,
    faFilePdf,
    faFileImage,
    faFile
);

const appName = import.meta.env.VITE_APP_NAME || 'Laravel';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) =>
        resolvePageComponent(
            `./Pages/${name}.vue`,
            import.meta.glob('./Pages/**/*.vue'),
        ),
    setup({ el, App, props, plugin }) {
        return createApp({ render: () => h(App, props) })
            .use(plugin)
            .use(ZiggyVue)
            .component('font-awesome-icon', FontAwesomeIcon)
            .mount(el);
    },
    progress: {
        color: '#4B5563',
    },
});
