import { useState, useEffect } from "react";
import manager from ".";
export const useAvailableLanguagesForDevice = (deviceInfo) => {
    const [availableLanguages, setAvailableLanguages] = useState([]);
    const [loaded, setLoaded] = useState(false);
    const [error, setError] = useState(null);
    useEffect(() => {
        let dead = false;
        if (deviceInfo) {
            manager.getAvailableLanguagesDevice(deviceInfo).then(languages => {
                if (dead)
                    return;
                setAvailableLanguages(languages);
                setError(null);
                setLoaded(true);
            }, error => {
                if (dead)
                    return;
                setAvailableLanguages([]);
                setError(error);
                setLoaded(true);
            });
        }
        return () => {
            dead = true;
        };
    }, [deviceInfo]);
    return { availableLanguages, loaded, error };
};
//# sourceMappingURL=useAvailableLanguagesForDevice.js.map