"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useGeography = void 0;
var react_1 = require("react");
var PageRequestsAbortingContext_1 = require("../contexts/PageRequestsAbortingContext");
var useGeography = function (geoUrl) {
    var _a = (0, react_1.useState)(null), geography = _a[0], setGeography = _a[1];
    var signal = (0, react_1.useContext)(PageRequestsAbortingContext_1.PageRequestsAbortingContext);
    (0, react_1.useEffect)(function () {
        fetch(geoUrl, { signal: signal })
            .then(function (res) {
            if (!res.ok) {
                throw Error(res.statusText);
            }
            return res.json();
        })
            .then(function (geography) {
            setGeography(geography);
        })
            .catch(function (error) {
            console.warn("Could not load map ".concat(geoUrl, " :"), error);
        });
    }, []); // eslint-disable-line
    return geography;
};
exports.useGeography = useGeography;
