import getConfig from "next/config";
import React from "react";
import { useIFrameWindow } from "../../../FrameContext";
const { publicRuntimeConfig } = getConfig();
export function useGeocoder(config) {
    const frame = useIFrameWindow();
    const [geocoder, setGeoCoder] = React.useState(null);
    React.useEffect(() => {
        const frameWindow = frame.window || window;
        if (!frameWindow.mapboxgl || !frameWindow.MapboxGeocoder)
            return;
        setGeoCoder(new frameWindow.MapboxGeocoder(Object.assign({ accessToken: publicRuntimeConfig.mapboxToken, mapboxgl: frameWindow.mapboxgl }, config)));
    }, []);
    return { geocoder };
}
//# sourceMappingURL=useGeocoder.js.map