import './styles/global.css'
import { mount } from 'svelte'
import App from './App.svelte'

// Global error trap to catch syntax errors before app mount
window.addEventListener('error', (event) => {
    const msg = `ERROR: ${event.error?.message || event.message}`;
    console.error(msg, event.error);
    alert(msg);
}, true);

console.log("main.js is starting!");

try {
    const app = mount(App, {
        target: document.getElementById('app'),
    })
    console.log("App mounted successfully!");
} catch (e) {
    const msg = `Mount Error: ${e.message}`;
    alert(msg);
    console.error("Error mounting App:", e);
}

export default app
