"use strict";var e=require("../../../../common/vendor.js");var t=(new class{constructor(){this.config={type:"navigateTo",url:"",delta:1,params:{},animationType:"pop-in",animationDuration:300,intercept:!1},this.route=this.route.bind(this)}addRootPath(e){return"/"===e[0]?e:`/${e}`}mixinParam(t,i){t=t&&this.addRootPath(t);let a="";return/.*\/.*\?.*=.*/.test(t)?(a=e.index.$u.queryParams(i,!1),t+`&${a}`):(a=e.index.$u.queryParams(i),t+a)}async route(t={},i={}){let a={};if("string"==typeof t?(a.url=this.mixinParam(t,i),a.type="navigateTo"):(a=e.index.$u.deepMerge(this.config,t),a.url=this.mixinParam(t.url,t.params)),a.url!==e.index.$u.page())if(i.intercept&&(this.config.intercept=i.intercept),a.params=i,a=e.index.$u.deepMerge(this.config,a),"function"==typeof e.index.$u.routeIntercept){await new Promise(((t,i)=>{e.index.$u.routeIntercept(a,t)}))&&this.openPage(a)}else this.openPage(a)}openPage(t){const{url:i,type:a,delta:n,animationType:r,animationDuration:o}=t;"navigateTo"!=t.type&&"to"!=t.type||e.index.navigateTo({url:i,animationType:r,animationDuration:o}),"redirectTo"!=t.type&&"redirect"!=t.type||e.index.redirectTo({url:i}),"switchTab"!=t.type&&"tab"!=t.type||e.index.switchTab({url:i}),"reLaunch"!=t.type&&"launch"!=t.type||e.index.reLaunch({url:i}),"navigateBack"!=t.type&&"back"!=t.type||e.index.navigateBack({delta:n})}}).route;exports.route=t;
