window.FilterCair = {
    registerNetworkHandler: function (dotnetRef) {
        window.addEventListener('online', () => dotnetRef.invokeMethodAsync('UpdateNetworkStatus', true));
        window.addEventListener('offline', () => dotnetRef.invokeMethodAsync('UpdateNetworkStatus', false));
    },

    isOnline: function () {
        return navigator.onLine;
    },

    getLocation: async function () {
        if (!navigator.geolocation) return "nicht verfügbar";

        return new Promise(resolve => {
            navigator.geolocation.getCurrentPosition(
                pos => resolve(`${pos.coords.latitude.toFixed(4)}, ${pos.coords.longitude.toFixed(4)}`),
                _ => resolve("nicht verfügbar"),
                { enableHighAccuracy: true }
            );
        });
    }
};