UNPKG

history-navigation-vue

Version:
6 lines 25 kB
/*! * history-navigation-vue v1.5.0 * (c) 2021 hezedu * @license MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.historyNavigationVue=e():t.historyNavigationVue=e()}(self,(function(){return function(){"use strict";var t={d:function(e,a){for(var i in a)t.o(a,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:a[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{plugin:function(){return Q},version:function(){return Z}});var a="_h_nav_page_show",i="_h_nav_page_hide",n="h-nav-page-",s="h-nav-page-not-found",o="_h_n_key",r="_h_n_modal_key",h="_H_NAV_BAE_MODAL_";function l(t,e,a,i,n,s,o,r){var h,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=a,l._compiled=!0),i&&(l.functional=!0),s&&(l._scopeId="data-v-"+s),o?(h=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},l._ssrRegister=h):n&&(h=r?function(){n.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:n),h)if(l.functional){l._injectStyles=h;var c=l.render;l.render=function(t,e){return h.call(e),c(t,e)}}else{var u=l.beforeCreate;l.beforeCreate=u?[].concat(u,h):[h]}return{exports:t,options:l}}var c,u,p,_=l({name:"HistoryNavigationPage",provide:function(){return{$page:this}},props:{path:{type:String},title:String,isHome:Boolean,isTab:{type:Boolean,required:!0},tabIndex:Number,stateKey:Number,route:{type:Object,required:!0},isFirstLoad:{type:Boolean,required:!0},isActive:{type:Boolean,required:!0}},data:function(){return{isLoad:this.isFirstLoad}},watch:{isActive:function(){this._handleShowHide()}},methods:{_handleShowHide:function(){this.isActive?this._uniteEmit(a):this._uniteEmit(i)},_uniteEmit:function(t){this.$emit(t)},_uniteBeforeDestory:function(){this.isLoad&&(this.$options._tmp_is_before_destroy=!0,this.isActive&&this._uniteEmit(i),this.isLoad=!1)}},beforeCreate:function(){},mounted:function(){var t=this;this.isLoad?this._uniteEmit(a):setTimeout((function(){t.$options._tmp_is_before_destroy||(t.isLoad=!0,t.$nextTick((function(){t._uniteEmit(a)})))}))},beforeDestroy:function(){this._uniteBeforeDestory()},beforeUnmount:function(){this._uniteBeforeDestory()}},(function(){var t=this,e=t.$createElement;return(t._self._c||e)("div",{staticClass:"h-nav-page-main"},[t._t("default")],2)}),[],!1,null,null,null),d=l({name:"HistoryNavigationPageWrap",components:{PageMain:_.exports},props:{transitionName:{type:String,default:"h-nav-page"},v:{type:Object,required:!0},isActive:{type:Boolean,required:!0},isFirstLoad:{type:Boolean,required:!0},globalPageStyle:void 0}},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("transition",{attrs:{name:t.transitionName,appear:!0}},[a("div",{directives:[{name:"show",rawName:"v-show",value:t.isActive,expression:"isActive"}],class:t.transitionName,style:{zIndex:t.v.stateKey}},[a("PageMain",{class:t.v.className,style:[t.globalPageStyle,t.v.style],attrs:{path:t.v.path,title:t.v.title,isHome:t.v.isHome,isTab:t.v.isTab,tabIndex:t.v.tabIndex,stateKey:t.v.stateKey,route:t.v.route,isFirstLoad:t.isFirstLoad,isActive:t.isActive}},[a(t.v.cmptKey,{tag:"component"})],1),t._v(" "),t._l(t.v.modalList,(function(t){return a("div",{directives:[{name:"show",rawName:"v-show",value:!t.isBAE,expression:"!modal.isBAE"}],key:t.key,staticClass:"h-nav-modal",style:{zIndex:t.key}},[a("div",{attrs:{id:"h_nav_modal_"+t.uid}})])}))],2)])}),[],!1,null,null,null),v=d.exports,f=l({props:{list:{type:Array,required:!0},currentIndex:{type:Number,required:!0}},name:"HistoryNavigationTabBar"},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"h-nav-tabbar"},t._l(t.list,(function(e,i){return a("Navigator",{key:e.pagePath,staticClass:"h-nav-tab",attrs:{isActive:t.currentIndex===i,url:e.pagePath,type:"switchTab"}},[e.icon?a("div",{staticClass:"h-nav-tab-icon",class:e.icon}):t._e(),t._v(" "),a("div",{staticClass:"h-nav-tab-text"},[t._v(t._s(e.text))])])})),1)}),[],!1,null,null,null),b=l({name:"HistoryNavigationTabBarController",components:{Page:v,TabBar:f.exports},props:{currTabPage:{type:Object,required:!0},isActive:{type:Boolean,required:!0},isFirstLoad:{type:Boolean,required:!0},traClassName:{type:String},globalPageStyle:void 0,tabList:Array,tabStackMap:Object},data:function(){return{tabBehavior:"_inherit",tabBehaviorDistance:0}},watch:{"currTabPage.tabIndex":function(t,e){var a=t-e,i=a>0?"increase":"reduce";this.tabBehaviorDistance=a,this.tabBehavior=i},isActive:function(){this.tabBehavior="_inherit"}},created:function(){}},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("transition",{attrs:{name:"h-nav-page",appear:!0}},[a("div",{directives:[{name:"show",rawName:"v-show",value:t.isActive,expression:"isActive"}],staticClass:"h-nav-tabs-ctrler h-nav-tabs-wrap"},[a("transition-group",{staticClass:"h-nav-tab-pages-wrap",class:"h-nav-tab-behavior-"+t.tabBehavior,style:{"--h-nav-tab-distance":t.tabBehaviorDistance},attrs:{tag:"div","enter-class":"","leave-class":"","enter-to-class":"","leave-to-class":"","enter-active-class":"h-nav-tab_page_load","leave-active-class":"h-nav-tab_page_unload"}},t._l(t.tabStackMap,(function(e){return a("div",{key:e.tabIndex,staticClass:"h-nav-tab-page-handle",class:t.traClassName,style:e.isClean?"transition: none!important; animation: none!important;":""},[a("Page",{attrs:{transitionName:"h-nav-tab-page",v:e,isActive:t.isActive&&t.currTabPage.tabIndex===e.tabIndex,isFirstLoad:t.isFirstLoad,globalPageStyle:t.globalPageStyle}})],1)})),0),t._v(" "),a("TabBar",{attrs:{list:t.tabList,currentIndex:t.currTabPage.tabIndex}})],1)])}),[],!1,null,null,null),y=l({components:{Page:v,TabCtrler:b.exports},name:"HistoryNavigationController",props:{entryPagePath:{type:String}},data:function(){var t=this.$navigator._h;return{isErr:!1,isFirstLoad:!0,stackMap:t.stackMap,behavior:t.behavior,currentPage:t.currentPage,globalPageStyle:this.$navigator.GLOBAL_CONFIG.pageStyle,transition:t._tra,tabStackMap:t.tabStackMap,tabList:t.tabList}},methods:{_uniteDestroy:function(){this.$navigator._h.destroy()}},created:function(){var t=this,e=this.$navigator._h;e.checkCompatibility()?(e._load(this.entryPagePath),this.$nextTick((function(){t.isFirstLoad=!1}))):this.isErr=!0},destroyed:function(){this._uniteDestroy()},unmounted:function(){this._uniteDestroy()}},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("transition-group",{staticClass:"h-nav-ctrler",class:"h-nav-behavior-"+t.behavior.type,style:{"--h-nav-distance":t.behavior.distance},attrs:{tag:"div","enter-class":"","leave-class":"","enter-to-class":"","leave-to-class":"","enter-active-class":"h-nav--page_load","leave-active-class":"h-nav--page_unload"}},[t._l(t.stackMap,(function(e){return a("div",{key:e.stackId,staticClass:"h-nav-page-handle",class:t.transition.className,style:e.isClean?"transition: none!important; animation: none!important;":""},[e.isTab?a("TabCtrler",{key:e.stackId,style:[{zIndex:e.stateKey}],attrs:{tabStackMap:t.tabStackMap,tabList:t.tabList,traClassName:t.transition.className,currTabPage:e,isActive:e.stackId===t.currentPage.stackId,isFirstLoad:t.isFirstLoad,globalPageStyle:t.globalPageStyle}}):a("Page",{key:e.stackId,attrs:{transitionName:"h-nav-page",v:e,isActive:e.stackId===t.currentPage.stackId,isFirstLoad:t.isFirstLoad,globalPageStyle:t.globalPageStyle}})],1)})),t._v(" "),t.isErr?a("div",{key:"not_support",staticClass:"h-nav-not-support"},[t._t("default",[a("h1",[t._v("history-navigation-vue")]),t._v(" "),a("p",[t._v("Sorry, Your browser doesn't support HTML history API.")])])],2):t._e()],2)}),[],!1,null,null,null).exports,g=l({data:function(){return{homePagePath:this.$navigator.GLOBAL_CONFIG.homePagePath}}},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{"padding-top":"8%","text-align":"center"}},[a("h1",[t._v("History Navigation Vue")]),t._v(" "),a("h2",[t._v("Page Not Found")]),t._v(" "),a("br"),t._v(" "),t.$page.stateKey>1?a("navigator",{staticStyle:{"text-decoration":"underline"},attrs:{type:"back"}},[t._v("Back")]):t._e(),t._v(" "),a("br"),t._v(" "),a("br"),t._v(" "),a("navigator",{staticStyle:{"text-decoration":"underline"},attrs:{type:"relaunch",url:t.homePagePath}},[t._v("Take me home")])],1)}),[],!1,null,null,null).exports,m=Object.assign(Object.create(null),{push:!0,replace:!0,relaunch:!0,switchTab:!0}),k=l({name:"HistoryNavigator",props:{url:{type:String},type:{type:String,default:"push"},steps:{type:Number,default:1},transition:{type:String},isActive:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},event:{type:String}},computed:{href:function(){return this.url?this.$navigator.URL.toLocationUrl(this.url):void 0}},methods:{handleEvent:function(t){if(t.preventDefault(),!this.isActive&&!this.disabled)if("back"===this.type)this.$navigator.back(this.steps,this.transition);else m[this.type]?this.$navigator[this.type]({url:this.url,transition:this.transition}):console.error("history-navigation-vue navigator not support type: "+this.type)}},mounted:function(){var t=this.event||this.$navigator.GLOBAL_CONFIG.navigatorTriggerEvent;this.$el.addEventListener(t,this.handleEvent)}},(function(){var t=this,e=t.$createElement;return(t._self._c||e)("a",{class:{"h-nav-active":t.isActive,"h-nav-disabled":t.disabled},attrs:{href:t.href}},[t._t("default")],2)}),[],!1,null,null,null).exports;function P(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function T(t){var e=t.isHashMode,a=void 0===e||e,i=t.base,n=void 0===i?"":i;this.isHashMode=a,this._location=p,a?this.hashBase=this._location.pathname+this._location.search+"#":this.base=n}function A(t){var e,a,i=t.indexOf("?");return-1!==i?(e=t.substr(0,i),a=t.substr(i+1)):(e=t,a=""),{path:e,query:S(a)}}function B(t){var e,a,i;return"string"==typeof t?(e=A(t),a=t):a=M(e=C(t)),i=I(e.path),Object.assign({fullPath:a,trimedPath:i},e)}function C(t){if(-1===t.path.indexOf("?"))return t;var e=A(t.path);return Object.assign(e.query,t.query),e}function M(t){var e=function(t){if(!t)return"";var e=[];return Object.keys(t).forEach((function(a){e.push(a+"="+encodeURIComponent(t[a]))})),e.join("&")}(t.query);return e&&(e="?"+e),t.path+e}function S(t){var e=Object.create(null);if(!t||"string"==typeof t&&0===t.length)return e;for(var a,i=t.split("&"),n=0,s=i.length;n<s;n++)e[(a=(a=i[n]).split("="))[0]]=decodeURIComponent(a[1]);return e}function I(t){var e=t.split("/");return(e=e.filter((function(t){return""!==t}))).join("/")}"undefined"!=typeof window&&(c=window,u=window.history,p=window.location),T.prototype.getHashUrlByLocation=function(){var t=this._location.hash;return t.length>0&&(t=t.substr(1)),t},T.prototype.getUrlByLocation=function(){if(this.isHashMode)return this.getHashUrlByLocation();var t=this._location.pathname;return 0===t.indexOf(this.base)&&(t=t.substr(this.base.length)),t+this._location.search},T.prototype.getRouteByLocation=function(){return A(this.getUrlByLocation())},T.prototype.toLocationUrl=function(t){return this.isHashMode?this.hashBase+t:this.base+t};var w=T;function L(){var t=u.state;return t&&"number"==typeof t._h_n_key?t._h_n_key:1}function E(){var t=u.state;return t&&"number"==typeof t._h_n_modal_key?t._h_n_modal_key:0}function x(){return{key:L(),modalKey:E()}}var O=x();function N(){return Object.assign({},O)}function $(){var t;t=x(),O=Object.assign({},t)}function j(){}function R(t,e,a,i){var n=e[a];t[a]=void 0===n?i:n}function H(t){throw new Error("history-navigation-vue: ".concat(t))}function F(t,e,a){var i=function(t,e,a){var i=U(t,e.key),n=U(t,a.key),s=0,o=t[i];for(o&&o[0]===e.key&&(s=t[i][1]-e.modalKey),s+=a.modalKey,i+=1;i<n;i++)s+=t[i][1];return s}(t,e,a);return i+(a.key-e.key)}function U(t,e){for(var a=0,i=t.length;a<i&&!(t[a][0]>=e);a++);return a}var K={init:function(){this._modal_crumbs=null,this._initModalCrumbs()},proto:{modal:function(t){var e,a=this,i=t.component,n=t.propsData,s=t.parent,l=t.success,c=arguments[0]===h;c||this._autoBAE();var u=L(),p=this.stackMap[u],_=E();_+=1,this._history.pushState((P(e={},o,u),P(e,r,_),e),""),this._setModalCrumbsWhenChange(),$();var d={key:_,uid:q()};if(p.modalList.push(d),!c){var v="h_nav_modal_"+d.uid;return i&&this.uniteVue.nextTick((function(){if(!d._isDestroy){var t=a.uniteVue.newComponent(i,{el:"#"+v,parent:s,propsData:n});d._destoryCmpt=function(){a.uniteVue.destroy(t)},l&&l(t)}})),v}d.isBAE=!0},removeModal:function(){var t,e=this,a=L(),i=E(),n=this.stackMap[a];n&&(t=n.modalList.splice(i)).forEach((function(t){t._isDestroy=!0,t._destoryCmpt&&t._destoryCmpt()})),0===i&&this._isNeedBAE()&&(t&&t.length>1?this._autoBAE():(this.BAE.onFirstTrigger(),setTimeout((function(){e._autoBAE()}),this.BAE.maxInterval)))},_autoRemoveModal:function(){var t=L(),e=this.stackMap[t],a=E();e&&e.modalList.length>a&&this.removeModal()},_setModalCrumbsWhenChange:function(){var t=L(),e=E();this._setModalCrumbs(t,e)},_initModalCrumbs:function(){var t=this._history,e=Object.assign({},t.state),a=e._h_n_crumbs;if(a)delete e._h_n_crumbs,this._history.replaceState(e,""),this._modal_crumbs=function(t){for(var e,a=t.split(";"),i=[],n=0,s=a.length;n<s;n++)e=a[n].split(":"),i.push([Number(e[0]),Number(e[1])]);return i}(a);else{var i=E();this._modal_crumbs=i?[[L(),i]]:[]}},_setModalCrumbs:function(t,e){!function(t,e,a){for(var i=0,n=t.length;i<n&&!(t[i][0]>=e);i++);t.splice(i,t.length),a&&t.push([e,a])}(this._modal_crumbs,t,e)},_saveModalCrumbs:function(){if(this._modal_crumbs.length){var t=this._history.state||{};t._h_n_crumbs=this._modal_crumbs.map((function(t){return t.join(":")})).join(";"),this._history.replaceState(t,"")}},getLastModalKeyByCrumbs:function(t){var e=this._modal_crumbs,a=e[e.length-1];return a&&a[0]===t?a[1]:0}}};var V=0;function q(){return V+=1}var D={proto:{_isBAEPage:function(){if(this.BAE){var t=L(),e=this.stackMap[t];if(1===t&&e&&(e.isHome||e.isTab))return!0}return!1},_isBAEPageByTK:function(t){if(this.BAE){var e=L(),a=this.pageMap[t];if(1===e&&a&&(a.isHome||a.isTab))return!0}return!1},_isNeedBAE:function(){if(this._isBAEPage()){var t=this._history.state;if(t&&!t._h_n_modal_key)return!0}return!1},_autoBAE:function(){this._isNeedBAE()&&this.modal(h)}}},W={init:function(){this._whenPopTra=null,this._whenPopInfo=null,this._whenBackPopInfo=null},proto:{_getStepsTotal:function(t){var e=x(),a=e.key,i=e.modalKey,n=t.key,s=t.modalKey,o=a-n;if(0===o)return i-s;var r,h,l=o>0;l?(r=t,h=e):(r=e,h=t);var c=F(this._modal_crumbs,r,h);return l||(c=-c),c},_backGetTo1Count:function(){return this._getStepsTotal({key:1,modalKey:0})},back:function(t,e){var a=t||1;a<1||(this._whenPopTra=e,a&&this._history.go(-a))},backToPage:function(t,e){var a=this._modal_crumbs;if(a.length){for(var i,n=L()-t,s=0,o=0,r=a.length;s<r&&(i=a[s])[0]>n;s++)o+=i[1];this.back(t+o,e)}else this.back(t,e)},_backAndApply:function(t,e,a,i){t<1||(this._whenBackPopInfo={method:e,args:a},this.back(t,i))},_backToStartAndReplace:function(t,e,a){var i=this._backGetTo1Count();i>0?this._backAndApply(i,"_replace",[t,e],a):0===i?(this._setTra(a),this._replace(t,e)):console.error("_backToStartAndReplace not back",i)}}},G=!1;function z(t){G&&H("Only one instance can be generated."),G=!0,this._global=t.global,this._window=c,this._history=u,this._location=p,this._isOmitForwardEvent=!1,this.BAE=t.BAE,this._tra={className:this._global.transition},this.uniteVue=t.uniteVue,this.pageMap=t.pageMap,this.notFoundPage=t.notFoundPage,t.tabBar&&(this.tabMap=t.tabBar.map,this.tabList=t.tabBar.list,this.tabStackMap=Object.create(null)),this.stackMap=Object.create(null),this._stackItemId=1,this.tabCtrlerStackId=1,this.onRouted=t.onRouted||j,this.URL=new w({isHashMode:t.urlIsHashMode,base:t.urlBase}),this.behavior={type:"",distance:0,isPop:!1},this.currentPage={path:null,title:null,className:void 0,isHome:!1,isTab:!1,tabIndex:null,cmptKey:null,stackId:null,stateKey:null,modalList:[],isClean:!1,route:{}},W.init.apply(this),K.init.apply(this)}z.prototype.checkCompatibility=function(){return!(!this._history||!this._history.pushState)},z.prototype._bind=function(){var t=this;this._popstateHandle=function(){t.handlePop()},this._window.addEventListener("popstate",this._popstateHandle),this._handleWinUnload=function(){t.handleWinUnload()},this._window.addEventListener("beforeunload",this._handleWinUnload)},z.prototype._onRouted=function(){var t=this.currentPage;this.onRouted({title:t.title,routeFullPath:t.route.fullPath}),this._autoBAE(t.route.trimedPath)},z.prototype._genStackItemId=function(){return this._stackItemId=this._stackItemId+1,"stack_"+this._stackItemId},z.prototype._isTabRoute=function(t){return!!this.tabMap&&!!this.tabMap[t]},z.prototype._forMatInputArg=function(t){var e,a;return"string"==typeof t?e=B(t):(e=B({path:t.url,query:t.query}),a=t.transition),{fullParse:e,tra:a}},z.prototype._load=function(t){this._bind();var e=B(void 0===t?this.URL.getUrlByLocation():t);1!==L()&&this._isTabRoute(e.trimedPath)?this._backToStartAndReplace(e,"loaded"):this._replaceCurrPage(e,"loaded")},z.prototype._replaceCurrPage=function(){var t=E();t?this._backAndApply(t,"_replace",arguments):this._replace.apply(this,arguments)},z.prototype._setTra=function(t){this._tra.className=t||this._global.transition},z.prototype.push=function(t){var e=this._forMatInputArg(t),a=e.fullParse,i=e.tra;this._isTabRoute(a.trimedPath)?console.error("Cannot push the tab url, please use switchTab"):(this._setTra(i),this._push(a,i))},z.prototype.replace=function(t){var e=this._forMatInputArg(t),a=e.fullParse,i=e.tra;this._isTabRoute(a.trimedPath)?console.error("Cannot replace the tab url, please use switchTab"):(this._setTra(i),this._replaceCurrPage(a))},z.prototype.switchTab=function(t){var e=this._forMatInputArg(t),a=e.fullParse,i=e.tra;this._isTabRoute(a.trimedPath)?this._backToStartAndReplace(a,"switchtab",i):console.error(a," is not tab url")},z.prototype.relaunch=function(t){var e=this._forMatInputArg(t),a=e.fullParse,i=e.tra;this.tabCtrlerStackId=this.tabCtrlerStackId+1,this._backToStartAndReplace(a,"relaunch",i)},z.prototype._setMapItem=function(t,e){var a=this.pageMap[e.trimedPath]||this.notFoundPage,i={path:a.path,title:a.title,tabIndex:a.tabIndex,route:e,cmptKey:a.cmptKey,isHome:a.isHome,isTab:a.isTab,stateKey:t,className:a.className,style:a.style,modalList:[],isClean:!1};i.isTab?(i.stackId="tab_stack_"+this.tabCtrlerStackId,this.uniteVue.set(this.tabStackMap,a.tabIndex,i)):i.stackId=this._genStackItemId(),this.uniteVue.set(this.stackMap,t,i),Object.assign(this.currentPage,i)},z.prototype._getBackTra=function(){var t=this._history;if(t.state)return t.state._h_n_b_tra},z.prototype._push=function(t,e){if(this._autoBAE(),e!==this._getBackTra()){var a=Object.assign({},this._history.state);e?a._h_n_b_tra=e:delete a._h_n_b_tra,this._history.replaceState(a,"")}var i=L()+1;this._setModalCrumbsWhenChange(),this._history.pushState(P({},o,i),"",this.URL.toLocationUrl(t.fullPath)),$();Object.assign(this.behavior,{type:"push",distance:1,isPop:!1}),this._setMapItem(i,t),this._onRouted()},z.prototype._replace=function(t,e){var a=this,i=N().key,n=L(),s=n-i,o={type:e||"replace",distance:s,isPop:!1};Object.assign(this.behavior,o),("switchtab"!==this.behavior.type||s)&&(this.currentPage.stackId="unactive_"+this.currentPage.stackId);var r=this.URL.toLocationUrl(t.fullPath),h=this._history.state;h&&h._h_n_key||((h=Object.assign({},history.state))._h_n_key=n),this._history.replaceState(h,"",r),$(),this.uniteVue.nextTick((function(){if("relaunch"===o.type){a._setAllCleaned();var e=n-s;a.stackMap[e].isClean=!1,a.uniteVue.nextTick((function(){a._clearAll(),a._setMapItem(n,t),a._onRouted()}))}else a._clearAfter(),a._setMapItem(n,t),a._onRouted()}))},z.prototype._setMapCleaned=function(t){for(var e in t)t[e].isClean=!0},z.prototype._setAllCleaned=function(){this.tabStackMap&&this._setMapCleaned(this.tabStackMap),this._setMapCleaned(this.stackMap)},z.prototype._clearAfter=function(){var t,e,a=this,i=L(),n=this.stackMap,s=[];for(t in n)(e=n[t]).stateKey>i&&(e.isClean=!0,s.push(e));var o=s.length;if(o){var r=s.pop();r.isClean=!1,this.uniteVue.delete(n,r.stateKey),(o=s.length)&&this.uniteVue.nextTick((function(){for(t=0;t<o;t++)e=s[t],a.uniteVue.delete(n,e.stateKey)}))}},z.prototype._clearMap=function(t){var e;for(e in t)this.uniteVue.delete(t,e)},z.prototype._clearAll=function(){this.tabStackMap&&this._clearMap(this.tabStackMap),this._clearMap(this.stackMap)},z.prototype.handlePop=function(){var t=this;if(this._isOmitForwardEvent)this._isOmitForwardEvent=!1;else{var e=this._whenBackPopInfo;if(e)return this[e.method].apply(this,e.args),void(this._whenBackPopInfo=null);var a=N(),i=a.key;if(!this._history.state){var n=i+1;return this._history.replaceState(P({},o,n),""),$(),this._setTra(""),this._replace(B(this.URL.getUrlByLocation()),"_popPush"),void this._setModalCrumbsWhenChange()}var s=this._getStepsTotal(a);if(s>0)return console.error("Forward is disabled by history-navigation-vue"),this._isOmitForwardEvent=!0,void this.back(s);var r=x(),h=r.key,l=this.stackMap[h];if(l||!r.modalKey){if(this._autoRemoveModal(),$(),i!==h){var c=h-i,u=this._whenPopTra;u||-1!==c||(u=this._getBackTra()),this._setTra(u),this._whenPopTra=null;var p={type:"back",distance:c,isPop:!0};Object.assign(this.behavior,p),l?Object.assign(this.currentPage,l):this._setMapItem(h,B(this.URL.getUrlByLocation())),this.uniteVue.nextTick((function(){t._clearAfter(),t._onRouted()}))}}else this.back(r.modalKey)}},z.prototype.destroy=function(){G&&(this._popstateHandle&&this._window.removeEventListener("popstate",this._popstateHandle),this._handleWinUnload&&this._window.removeEventListener("_handleWinUnload",this._handleWinUnload),G=!1)},z.prototype.handleWinUnload=function(){this._saveModalCrumbs()},Object.assign(z.prototype,K.proto),Object.assign(z.prototype,D.proto),Object.assign(z.prototype,W.proto);var X=z;function Y(t){return P({inject:{$page:{default:null}},created:function(){(this.$options.onShow||this.$options.onHide)&&this.$page&&function(t){var e,n=t.$options;n.__tmp_h_nav_show_hide_has=!0,n.onShow&&(e=n.__tmp_h_nav_page_show_hanlde=function(){n.onShow.call(t)},t.$page.$on(a,e));n.onHide&&(e=n.__tmp_h_nav_page_hide_hanlde=function(){n.onHide.call(t)},t.$page.$on(i,e))}(this)}},t?"unmounted":"destroyed",(function(){this.$options.__tmp_h_nav_show_hide_has&&function(t){var e=t.$options,n=e.__tmp_h_nav_page_show_hanlde;n&&t.$page.$off(a,n);(n=e.__tmp_h_nav_page_hide_hanlde)&&t.$page.$off(i,n)}(this)}))}var J={title:"Not Found",component:g};var Q={install:function(t,e){var a,i=function(t){var e=t.version;return e=e.substr(0,e.indexOf(".")),Number(e)}(t);2===i?a=function(t){return{proto:t.prototype,nextTick:t.nextTick,newComponent:function(e,a){return new(t.extend(e))(a)},destroy:function(t){t.$destroy()},set:t.set,delete:t.delete}}(t):H("Unsupported version of Vue "+i),Array.isArray(e.pages)||H("config.pages is not Array.");var o,r=function(t){for(var e,a,i,s=Object.create(null),o=0,r=t.length;o<r;o++)s[a=I((e=t[o]).path)]&&H("pageMap key: ".concat(a," is same as ").concat(e.path)),i=Object.assign({},e),Object.assign(i,{trimedPath:a,isTab:!1,isHome:!1,cmptKey:n+o}),s[a]=i;return s}(e.pages);e.tabBar&&(o=function(t,e){var a=t.list,i=a.length;i<2&&H("tabBar list length must >= 2");for(var n,s,o=0,r=Object.create(null),h=[];o<i;o++){var l=e[n=I((s=a[o]).pagePath)];l&&l.path===s.pagePath||H("tabBar pagePath: ".concat(o," is not found in pages")),r[n]&&H("tabBar pagePath: ".concat(n," is same as ").concat(o)),l.isTab=!0,l.tabIndex=o,r[n]=!0,h.push(Object.assign({},s))}return{map:r,list:h}}(e.tabBar,r));var h,l,c=e.notFoundPage||J;for(h in t.component(s,c.component),c={path:null,title:c.title,cmptKey:s,isTab:!1,trimedPath:null},r)l=r[h],t.component(l.cmptKey,l.component);t.component("NavigationController",y),t.component("Navigator",k);var u=Object.create(null);R(u,e,"navigatorTriggerEvent","click"),R(u,e,"transition","h-nav-transition"),R(u,e,"pageStyle",undefined),R(u,e,"homePagePath",e.pages[0].path);var p=r[I(u.homePagePath)];p||H("Home page not found"),p.isHome=!0;var _=null;e.backAgainToExit&&(R(_=Object.create(null),e.backAgainToExit,"maxInterval",2e3),R(_,e.backAgainToExit,"onFirstTrigger",j));var d,v,f={global:u,BAE:_,uniteVue:a,pageMap:r,cmptPageSuffix:n,notFoundPage:c,tabBar:o,onRouted:e.onRouted};R(f,e,"urlBase",""),R(f,e,"urlIsHashMode",true),a.proto.$navigator=(d=new X(f),v={_h:d,URL:d.URL,GLOBAL_CONFIG:d._global},["push","back","backToPage","replace","relaunch","switchTab","modal"].forEach((function(t){!function(t,e,a){t[e]=function(){a[e].apply(a,arguments)}}(v,t,d)})),v),t.mixin(Y(a.is3))}},Z="1.5.0";return e}()}));