"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.changeRoutesNav = void 0;
var ui_internal_1 = require("./ui-internal");
function changeRoutesNav(router, changeRouteModels) {
    var changes = (Array.isArray(changeRouteModels) ? changeRouteModels : [changeRouteModels]);
    if (changes.some(function (x) { return null == (x.href || x.name || x.route); })) {
        console.warn("One or more route changes have no href/name/route");
    }
    var anyChanged = changes.reduce(function (anyChanged, changeRouteModel) { return changeRouteNav(router, changeRouteModel) || anyChanged; }, false);
    if (anyChanged) {
        ui_internal_1.UIInternal.broadcast(ui_internal_1.UIInternal.EVT_ROUTE_CHANGE);
    }
}
exports.changeRoutesNav = changeRoutesNav;
function changeRouteNav(router, changeRouteModel) {
    var i = router.routes.findIndex(function (x) {
        return (changeRouteModel.href != null && x.href == changeRouteModel.href)
            || (changeRouteModel.name != null && x.name == changeRouteModel.name)
            || (changeRouteModel.route != null && x.route == changeRouteModel.route);
    });
    if (i >= 0) {
        router.routes[i].nav = changeRouteModel.nav;
        return true;
    }
    return false;
}

//# sourceMappingURL=router-helper.js.map
