"use strict";
exports.__esModule = true;
exports.changeParam = exports.getParam = exports.getFileParam = exports.useRouteChanged = exports.history = void 0;
var history_1 = require("history");
var react_1 = require("react");
exports.history = history_1.createBrowserHistory();
window['VITRO_HISTORY'] = exports.history;
var useRouteChanged = function (callback) {
    react_1.useEffect(function () {
        var unlisten = exports.history.listen(function () {
            callback();
        });
        return function () { return unlisten(); };
    }, []);
};
exports.useRouteChanged = useRouteChanged;
function getFileParam(url) {
    return getParam(url, 'file');
}
exports.getFileParam = getFileParam;
function getParam(url, name) {
    var search = new URL(url, window.location.origin).search;
    var params = new URLSearchParams(search);
    var fileParam = params.get(name);
    return fileParam;
}
exports.getParam = getParam;
function changeParam(name, value) {
    var url = new URL(window.location.href);
    url.searchParams.set(name, value);
    exports.history.push(url.toString());
}
exports.changeParam = changeParam;
//# sourceMappingURL=history.js.map