import "./app.scss"
import { initMobileMenu } from "./modules/mobile-menu.js"
import { initTabs } from "./modules/tabs.js"
import { registerEditor } from "./modules/editor.js"
import { initCookieConsent } from "./modules/cookie-consent.js"
import { initEventMap } from "./modules/event-map.js"
import { initCopyUrl } from "./modules/copy-url.js"
import { initSortable } from "./modules/sortable.js"
import { initBilletDesigner } from "./modules/billet-designer.js"
import { initCommissionCalculator } from "./modules/commission-calculator.js"
import { initCart } from "./modules/cart.js"
import { initStripePayment } from "./modules/stripe-payment.js"
import { initShare } from "./modules/share.js"
import { initApiEnvSwitcher } from "./modules/api-env-switcher.js"
import { initAnalytics } from "./modules/analytics.js"

document.addEventListener('DOMContentLoaded', () => {
    initMobileMenu()
    initTabs()
    registerEditor()
    initCookieConsent()
    initCopyUrl()
    initEventMap()
    initSortable()
    initBilletDesigner()
    initCommissionCalculator()
    initCart()
    initStripePayment()
    initShare()
    initApiEnvSwitcher()
    initAnalytics()

    document.querySelectorAll('[data-confirm]').forEach(form => {
        form.addEventListener('submit', (e) => {
            if (!globalThis.confirm(form.dataset.confirm)) {
                e.preventDefault()
            }
        })
    })
})
