/*! * vue-router v3.1.3 * (c) 2019 Evan You * @license MIT */(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory():typeof define==='function'&&define.amd?define(factory):(global=global||self,global.VueRouter=factory());}(this,function(){'use strict';function assert(condition,message){if(!condition){throw new Error(("[vue-router] "+message))}} function warn(condition,message){if(!condition){typeof console!=='undefined'&&console.warn(("[vue-router] "+message));}} function isError(err){return Object.prototype.toString.call(err).indexOf('Error')>-1} function isExtendedError(constructor,err){return(err instanceof constructor||(err&&(err.name===constructor.name||err._name===constructor._name)))} function extend(a,b){for(var key in b){a[key]=b[key];} return a} var View={name:'RouterView',functional:true,props:{name:{type:String,default:'default'}},render:function render(_,ref){var props=ref.props;var children=ref.children;var parent=ref.parent;var data=ref.data;data.routerView=true;var h=parent.$createElement;var name=props.name;var route=parent.$route;var cache=parent._routerViewCache||(parent._routerViewCache={});var depth=0;var inactive=false;while(parent&&parent._routerRoot!==parent){var vnodeData=parent.$vnode&&parent.$vnode.data;if(vnodeData){if(vnodeData.routerView){depth++;} if(vnodeData.keepAlive&&parent._inactive){inactive=true;}} parent=parent.$parent;} data.routerViewDepth=depth;if(inactive){return h(cache[name],data,children)} var matched=route.matched[depth];if(!matched){cache[name]=null;return h()} var component=cache[name]=matched.components[name];data.registerRouteInstance=function(vm,val){var current=matched.instances[name];if((val&¤t!==vm)||(!val&¤t===vm)){matched.instances[name]=val;}};(data.hook||(data.hook={})).prepatch=function(_,vnode){matched.instances[name]=vnode.componentInstance;};data.hook.init=function(vnode){if(vnode.data.keepAlive&&vnode.componentInstance&&vnode.componentInstance!==matched.instances[name]){matched.instances[name]=vnode.componentInstance;}};var propsToPass=data.props=resolveProps(route,matched.props&&matched.props[name]);if(propsToPass){propsToPass=data.props=extend({},propsToPass);var attrs=data.attrs=data.attrs||{};for(var key in propsToPass){if(!component.props||!(key in component.props)){attrs[key]=propsToPass[key];delete propsToPass[key];}}} return h(component,data,children)}};function resolveProps(route,config){switch(typeof config){case 'undefined':return case 'object':return config case 'function':return config(route) case 'boolean':return config?route.params:undefined default:{warn(false,"props in \""+(route.path)+"\" is a "+(typeof config)+", "+ "expecting an object, function or boolean.");}}} var encodeReserveRE=/[!'()*]/g;var encodeReserveReplacer=function(c){return '%'+c.charCodeAt(0).toString(16);};var commaRE=/%2C/g;var encode=function(str){return encodeURIComponent(str).replace(encodeReserveRE,encodeReserveReplacer).replace(commaRE,',');};var decode=decodeURIComponent;function resolveQuery(query,extraQuery,_parseQuery){if(extraQuery===void 0)extraQuery={};var parse=_parseQuery||parseQuery;var parsedQuery;try{parsedQuery=parse(query||'');}catch(e){warn(false,e.message);parsedQuery={};} for(var key in extraQuery){parsedQuery[key]=extraQuery[key];} return parsedQuery} function parseQuery(query){var res={};query=query.trim().replace(/^(\?|#|&)/,'');if(!query){return res} query.split('&').forEach(function(param){var parts=param.replace(/\+/g,' ').split('=');var key=decode(parts.shift());var val=parts.length>0?decode(parts.join('=')):null;if(res[key]===undefined){res[key]=val;}else if(Array.isArray(res[key])){res[key].push(val);}else{res[key]=[res[key],val];}});return res} function stringifyQuery(obj){var res=obj?Object.keys(obj).map(function(key){var val=obj[key];if(val===undefined){return ''} if(val===null){return encode(key)} if(Array.isArray(val)){var result=[];val.forEach(function(val2){if(val2===undefined){return} if(val2===null){result.push(encode(key));}else{result.push(encode(key)+'='+encode(val2));}});return result.join('&')} return encode(key)+'='+encode(val)}).filter(function(x){return x.length>0;}).join('&'):null;return res?("?"+res):''} var trailingSlashRE=/\/?$/;function createRoute(record,location,redirectedFrom,router){var stringifyQuery=router&&router.options.stringifyQuery;var query=location.query||{};try{query=clone(query);}catch(e){} var route={name:location.name||(record&&record.name),meta:(record&&record.meta)||{},path:location.path||'/',hash:location.hash||'',query:query,params:location.params||{},fullPath:getFullPath(location,stringifyQuery),matched:record?formatMatch(record):[]};if(redirectedFrom){route.redirectedFrom=getFullPath(redirectedFrom,stringifyQuery);} return Object.freeze(route)} function clone(value){if(Array.isArray(value)){return value.map(clone)}else if(value&&typeof value==='object'){var res={};for(var key in value){res[key]=clone(value[key]);} return res}else{return value}} var START=createRoute(null,{path:'/'});function formatMatch(record){var res=[];while(record){res.unshift(record);record=record.parent;} return res} function getFullPath(ref,_stringifyQuery){var path=ref.path;var query=ref.query;if(query===void 0)query={};var hash=ref.hash;if(hash===void 0)hash='';var stringify=_stringifyQuery||stringifyQuery;return(path||'/')+stringify(query)+hash} function isSameRoute(a,b){if(b===START){return a===b}else if(!b){return false}else if(a.path&&b.path){return(a.path.replace(trailingSlashRE,'')===b.path.replace(trailingSlashRE,'')&&a.hash===b.hash&&isObjectEqual(a.query,b.query))}else if(a.name&&b.name){return(a.name===b.name&&a.hash===b.hash&&isObjectEqual(a.query,b.query)&&isObjectEqual(a.params,b.params))}else{return false}} function isObjectEqual(a,b){if(a===void 0)a={};if(b===void 0)b={};if(!a||!b){return a===b} var aKeys=Object.keys(a);var bKeys=Object.keys(b);if(aKeys.length!==bKeys.length){return false} return aKeys.every(function(key){var aVal=a[key];var bVal=b[key];if(typeof aVal==='object'&&typeof bVal==='object'){return isObjectEqual(aVal,bVal)} return String(aVal)===String(bVal)})} function isIncludedRoute(current,target){return(current.path.replace(trailingSlashRE,'/').indexOf(target.path.replace(trailingSlashRE,'/'))===0&&(!target.hash||current.hash===target.hash)&&queryIncludes(current.query,target.query))} function queryIncludes(current,target){for(var key in target){if(!(key in current)){return false}} return true} function resolvePath(relative,base,append){var firstChar=relative.charAt(0);if(firstChar==='/'){return relative} if(firstChar==='?'||firstChar==='#'){return base+relative} var stack=base.split('/');if(!append||!stack[stack.length-1]){stack.pop();} var segments=relative.replace(/^\//,'').split('/');for(var i=0;i=0){hash=path.slice(hashIndex);path=path.slice(0,hashIndex);} var queryIndex=path.indexOf('?');if(queryIndex>=0){query=path.slice(queryIndex+1);path=path.slice(0,queryIndex);} return{path:path,query:query,hash:hash}} function cleanPath(path){return path.replace(/\/\//g,'/')} var isarray=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=='[object Array]';};var pathToRegexp_1=pathToRegexp;var parse_1=parse;var compile_1=compile;var tokensToFunction_1=tokensToFunction;var tokensToRegExp_1=tokensToRegExp;var PATH_REGEXP=new RegExp(['(\\\\.)','([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'].join('|'),'g');function parse(str,options){var tokens=[];var key=0;var index=0;var path='';var defaultDelimiter=options&&options.delimiter||'/';var res;while((res=PATH_REGEXP.exec(str))!=null){var m=res[0];var escaped=res[1];var offset=res.index;path+=str.slice(index,offset);index=offset+m.length;if(escaped){path+=escaped[1];continue} var next=str[index];var prefix=res[2];var name=res[3];var capture=res[4];var group=res[5];var modifier=res[6];var asterisk=res[7];if(path){tokens.push(path);path='';} var partial=prefix!=null&&next!=null&&next!==prefix;var repeat=modifier==='+'||modifier==='*';var optional=modifier==='?'||modifier==='*';var delimiter=res[2]||defaultDelimiter;var pattern=capture||group;tokens.push({name:name||key++,prefix:prefix||'',delimiter:delimiter,optional:optional,repeat:repeat,partial:partial,asterisk:!!asterisk,pattern:pattern?escapeGroup(pattern):(asterisk?'.*':'[^'+escapeString(delimiter)+']+?')});} if(index1||!scopedSlot.length){{warn(false,("RouterLink with to=\""+(this.props.to)+"\" is trying to use a scoped slot but it didn't provide exactly one child."));} return scopedSlot.length===0?h():h('span',{},scopedSlot)}} if(this.tag==='a'){data.on=on;data.attrs={href:href};}else{var a=findAnchor(this.$slots.default);if(a){a.isStatic=false;var aData=(a.data=extend({},a.data));aData.on=aData.on||{};for(var event in aData.on){var handler$1=aData.on[event];if(event in on){aData.on[event]=Array.isArray(handler$1)?handler$1:[handler$1];}} for(var event$1 in on){if(event$1 in aData.on){aData.on[event$1].push(on[event$1]);}else{aData.on[event$1]=handler;}} var aAttrs=(a.data.attrs=extend({},a.data.attrs));aAttrs.href=href;}else{data.on=on;}} return h(this.tag,data,this.$slots.default)}};function guardEvent(e){if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey){return} if(e.defaultPrevented){return} if(e.button!==undefined&&e.button!==0){return} if(e.currentTarget&&e.currentTarget.getAttribute){var target=e.currentTarget.getAttribute('target');if(/\b_blank\b/i.test(target)){return}} if(e.preventDefault){e.preventDefault();} return true} function findAnchor(children){if(children){var child;for(var i=0;i0){var pathNames=found.map(function(path){return("- "+path);}).join('\n');warn(false,("Non-nested routes must include a leading slash character. Fix the following routes: \n"+pathNames));}} return{pathList:pathList,pathMap:pathMap,nameMap:nameMap}} function addRouteRecord(pathList,pathMap,nameMap,route,parent,matchAs){var path=route.path;var name=route.name;{assert(path!=null,"\"path\" is required in a route configuration.");assert(typeof route.component!=='string',"route config \"component\" for path: "+(String(path||name))+" cannot be a "+"string id. Use an actual component instead.");} var pathToRegexpOptions=route.pathToRegexpOptions||{};var normalizedPath=normalizePath(path,parent,pathToRegexpOptions.strict);if(typeof route.caseSensitive==='boolean'){pathToRegexpOptions.sensitive=route.caseSensitive;} var record={path:normalizedPath,regex:compileRouteRegex(normalizedPath,pathToRegexpOptions),components:route.components||{default:route.component},instances:{},name:name,parent:parent,matchAs:matchAs,redirect:route.redirect,beforeEnter:route.beforeEnter,meta:route.meta||{},props:route.props==null?{}:route.components?route.props:{default:route.props}};if(route.children){{if(route.name&&!route.redirect&&route.children.some(function(child){return /^\/?$/.test(child.path);})){warn(false,"Named Route '"+(route.name)+"' has a default child route. "+ "When navigating to this named route (:to=\"{name: '"+(route.name)+"'\"), "+ "the default child route will not be rendered. Remove the name from "+ "this route and use the name of the default child route for named "+ "links instead.");}} route.children.forEach(function(child){var childMatchAs=matchAs?cleanPath((matchAs+"/"+(child.path))):undefined;addRouteRecord(pathList,pathMap,nameMap,child,record,childMatchAs);});} if(!pathMap[record.path]){pathList.push(record.path);pathMap[record.path]=record;} if(route.alias!==undefined){var aliases=Array.isArray(route.alias)?route.alias:[route.alias];for(var i=0;i-1){location.params[key]=currentRoute.params[key];}}} location.path=fillParams(record.path,location.params,("named route \""+name+"\""));return _createRoute(record,location,redirectedFrom)}else if(location.path){location.params={};for(var i=0;i=queue.length){cb();}else{if(queue[index]){fn(queue[index],function(){step(index+1);});}else{step(index+1);}}};step(0);} function resolveAsyncComponents(matched){return function(to,from,next){var hasAsync=false;var pending=0;var error=null;flatMapComponents(matched,function(def,_,match,key){if(typeof def==='function'&&def.cid===undefined){hasAsync=true;pending++;var resolve=once(function(resolvedDef){if(isESModule(resolvedDef)){resolvedDef=resolvedDef.default;} def.resolved=typeof resolvedDef==='function'?resolvedDef:_Vue.extend(resolvedDef);match.components[key]=resolvedDef;pending--;if(pending<=0){next();}});var reject=once(function(reason){var msg="Failed to resolve async component "+key+": "+reason;warn(false,msg);if(!error){error=isError(reason)?reason:new Error(msg);next(error);}});var res;try{res=def(resolve,reject);}catch(e){reject(e);} if(res){if(typeof res.then==='function'){res.then(resolve,reject);}else{var comp=res.component;if(comp&&typeof comp.then==='function'){comp.then(resolve,reject);}}}}});if(!hasAsync){next();}}} function flatMapComponents(matched,fn){return flatten(matched.map(function(m){return Object.keys(m.components).map(function(key){return fn(m.components[key],m.instances[key],m,key);})}))} function flatten(arr){return Array.prototype.concat.apply([],arr)} var hasSymbol=typeof Symbol==='function'&&typeof Symbol.toStringTag==='symbol';function isESModule(obj){return obj.__esModule||(hasSymbol&&obj[Symbol.toStringTag]==='Module')} function once(fn){var called=false;return function(){var args=[],len=arguments.length;while(len--)args[len]=arguments[len];if(called){return} called=true;return fn.apply(this,args)}} var NavigationDuplicated=(function(Error){function NavigationDuplicated(normalizedLocation){Error.call(this);this.name=this._name='NavigationDuplicated';this.message="Navigating to current location (\""+(normalizedLocation.fullPath)+"\") is not allowed";Object.defineProperty(this,'stack',{value:new Error().stack,writable:true,configurable:true});} if(Error)NavigationDuplicated.__proto__=Error;NavigationDuplicated.prototype=Object.create(Error&&Error.prototype);NavigationDuplicated.prototype.constructor=NavigationDuplicated;return NavigationDuplicated;}(Error));NavigationDuplicated._name='NavigationDuplicated';var History=function History(router,base){this.router=router;this.base=normalizeBase(base);this.current=START;this.pending=null;this.ready=false;this.readyCbs=[];this.readyErrorCbs=[];this.errorCbs=[];};History.prototype.listen=function listen(cb){this.cb=cb;};History.prototype.onReady=function onReady(cb,errorCb){if(this.ready){cb();}else{this.readyCbs.push(cb);if(errorCb){this.readyErrorCbs.push(errorCb);}}};History.prototype.onError=function onError(errorCb){this.errorCbs.push(errorCb);};History.prototype.transitionTo=function transitionTo(location,onComplete,onAbort){var this$1=this;var route=this.router.match(location,this.current);this.confirmTransition(route,function(){this$1.updateRoute(route);onComplete&&onComplete(route);this$1.ensureURL();if(!this$1.ready){this$1.ready=true;this$1.readyCbs.forEach(function(cb){cb(route);});}},function(err){if(onAbort){onAbort(err);} if(err&&!this$1.ready){this$1.ready=true;this$1.readyErrorCbs.forEach(function(cb){cb(err);});}});};History.prototype.confirmTransition=function confirmTransition(route,onComplete,onAbort){var this$1=this;var current=this.current;var abort=function(err){if(!isExtendedError(NavigationDuplicated,err)&&isError(err)){if(this$1.errorCbs.length){this$1.errorCbs.forEach(function(cb){cb(err);});}else{warn(false,'uncaught error during route navigation:');console.error(err);}} onAbort&&onAbort(err);};if(isSameRoute(route,current)&&route.matched.length===current.matched.length){this.ensureURL();return abort(new NavigationDuplicated(route))} var ref=resolveQueue(this.current.matched,route.matched);var updated=ref.updated;var deactivated=ref.deactivated;var activated=ref.activated;var queue=[].concat(extractLeaveGuards(deactivated),this.router.beforeHooks,extractUpdateHooks(updated),activated.map(function(m){return m.beforeEnter;}),resolveAsyncComponents(activated));this.pending=route;var iterator=function(hook,next){if(this$1.pending!==route){return abort()} try{hook(route,current,function(to){if(to===false||isError(to)){this$1.ensureURL(true);abort(to);}else if(typeof to==='string'||(typeof to==='object'&&(typeof to.path==='string'||typeof to.name==='string'))){abort();if(typeof to==='object'&&to.replace){this$1.replace(to);}else{this$1.push(to);}}else{next(to);}});}catch(e){abort(e);}};runQueue(queue,iterator,function(){var postEnterCbs=[];var isValid=function(){return this$1.current===route;};var enterGuards=extractEnterGuards(activated,postEnterCbs,isValid);var queue=enterGuards.concat(this$1.router.resolveHooks);runQueue(queue,iterator,function(){if(this$1.pending!==route){return abort()} this$1.pending=null;onComplete(route);if(this$1.router.app){this$1.router.app.$nextTick(function(){postEnterCbs.forEach(function(cb){cb();});});}});});};History.prototype.updateRoute=function updateRoute(route){var prev=this.current;this.current=route;this.cb&&this.cb(route);this.router.afterHooks.forEach(function(hook){hook&&hook(route,prev);});};function normalizeBase(base){if(!base){if(inBrowser){var baseEl=document.querySelector('base');base=(baseEl&&baseEl.getAttribute('href'))||'/';base=base.replace(/^https?:\/\/[^\/]+/,'');}else{base='/';}} if(base.charAt(0)!=='/'){base='/'+base;} return base.replace(/\/$/,'')} function resolveQueue(current,next){var i;var max=Math.max(current.length,next.length);for(i=0;i-1){href=decodeURI(href.slice(0,hashIndex))+href.slice(hashIndex);}else{href=decodeURI(href);}}else{if(searchIndex>-1){href=decodeURI(href.slice(0,searchIndex))+href.slice(searchIndex);}} return href} function getUrl(path){var href=window.location.href;var i=href.indexOf('#');var base=i>=0?href.slice(0,i):href;return(base+"#"+path)} function pushHash(path){if(supportsPushState){pushState(getUrl(path));}else{window.location.hash=path;}} function replaceHash(path){if(supportsPushState){replaceState(getUrl(path));}else{window.location.replace(getUrl(path));}} var AbstractHistory=(function(History){function AbstractHistory(router,base){History.call(this,router,base);this.stack=[];this.index=-1;} if(History)AbstractHistory.__proto__=History;AbstractHistory.prototype=Object.create(History&&History.prototype);AbstractHistory.prototype.constructor=AbstractHistory;AbstractHistory.prototype.push=function push(location,onComplete,onAbort){var this$1=this;this.transitionTo(location,function(route){this$1.stack=this$1.stack.slice(0,this$1.index+1).concat(route);this$1.index++;onComplete&&onComplete(route);},onAbort);};AbstractHistory.prototype.replace=function replace(location,onComplete,onAbort){var this$1=this;this.transitionTo(location,function(route){this$1.stack=this$1.stack.slice(0,this$1.index).concat(route);onComplete&&onComplete(route);},onAbort);};AbstractHistory.prototype.go=function go(n){var this$1=this;var targetIndex=this.index+n;if(targetIndex<0||targetIndex>=this.stack.length){return} var route=this.stack[targetIndex];this.confirmTransition(route,function(){this$1.index=targetIndex;this$1.updateRoute(route);},function(err){if(isExtendedError(NavigationDuplicated,err)){this$1.index=targetIndex;}});};AbstractHistory.prototype.getCurrentLocation=function getCurrentLocation(){var current=this.stack[this.stack.length-1];return current?current.fullPath:'/'};AbstractHistory.prototype.ensureURL=function ensureURL(){};return AbstractHistory;}(History));var VueRouter=function VueRouter(options){if(options===void 0)options={};this.app=null;this.apps=[];this.options=options;this.beforeHooks=[];this.resolveHooks=[];this.afterHooks=[];this.matcher=createMatcher(options.routes||[],this);var mode=options.mode||'hash';this.fallback=mode==='history'&&!supportsPushState&&options.fallback!==false;if(this.fallback){mode='hash';} if(!inBrowser){mode='abstract';} this.mode=mode;switch(mode){case 'history':this.history=new HTML5History(this,options.base);break case 'hash':this.history=new HashHistory(this,options.base,this.fallback);break case 'abstract':this.history=new AbstractHistory(this,options.base);break default:{assert(false,("invalid mode: "+mode));}}};var prototypeAccessors={currentRoute:{configurable:true}};VueRouter.prototype.match=function match(raw,current,redirectedFrom){return this.matcher.match(raw,current,redirectedFrom)};prototypeAccessors.currentRoute.get=function(){return this.history&&this.history.current};VueRouter.prototype.init=function init(app){var this$1=this;assert(install.installed,"not installed. Make sure to call `Vue.use(VueRouter)` "+ "before creating root instance.");this.apps.push(app);app.$once('hook:destroyed',function(){var index=this$1.apps.indexOf(app);if(index>-1){this$1.apps.splice(index,1);} if(this$1.app===app){this$1.app=this$1.apps[0]||null;}});if(this.app){return} this.app=app;var history=this.history;if(history instanceof HTML5History){history.transitionTo(history.getCurrentLocation());}else if(history instanceof HashHistory){var setupHashListener=function(){history.setupListeners();};history.transitionTo(history.getCurrentLocation(),setupHashListener,setupHashListener);} history.listen(function(route){this$1.apps.forEach(function(app){app._route=route;});});};VueRouter.prototype.beforeEach=function beforeEach(fn){return registerHook(this.beforeHooks,fn)};VueRouter.prototype.beforeResolve=function beforeResolve(fn){return registerHook(this.resolveHooks,fn)};VueRouter.prototype.afterEach=function afterEach(fn){return registerHook(this.afterHooks,fn)};VueRouter.prototype.onReady=function onReady(cb,errorCb){this.history.onReady(cb,errorCb);};VueRouter.prototype.onError=function onError(errorCb){this.history.onError(errorCb);};VueRouter.prototype.push=function push(location,onComplete,onAbort){var this$1=this;if(!onComplete&&!onAbort&&typeof Promise!=='undefined'){return new Promise(function(resolve,reject){this$1.history.push(location,resolve,reject);})}else{this.history.push(location,onComplete,onAbort);}};VueRouter.prototype.replace=function replace(location,onComplete,onAbort){var this$1=this;if(!onComplete&&!onAbort&&typeof Promise!=='undefined'){return new Promise(function(resolve,reject){this$1.history.replace(location,resolve,reject);})}else{this.history.replace(location,onComplete,onAbort);}};VueRouter.prototype.go=function go(n){this.history.go(n);};VueRouter.prototype.back=function back(){this.go(-1);};VueRouter.prototype.forward=function forward(){this.go(1);};VueRouter.prototype.getMatchedComponents=function getMatchedComponents(to){var route=to?to.matched?to:this.resolve(to).route:this.currentRoute;if(!route){return[]} return[].concat.apply([],route.matched.map(function(m){return Object.keys(m.components).map(function(key){return m.components[key]})}))};VueRouter.prototype.resolve=function resolve(to,current,append){current=current||this.history.current;var location=normalizeLocation(to,current,append,this);var route=this.match(location,current);var fullPath=route.redirectedFrom||route.fullPath;var base=this.history.base;var href=createHref(base,fullPath,this.mode);return{location:location,route:route,href:href,normalizedTo:location,resolved:route}};VueRouter.prototype.addRoutes=function addRoutes(routes){this.matcher.addRoutes(routes);if(this.history.current!==START){this.history.transitionTo(this.history.getCurrentLocation());}};Object.defineProperties(VueRouter.prototype,prototypeAccessors);function registerHook(list,fn){list.push(fn);return function(){var i=list.indexOf(fn);if(i>-1){list.splice(i,1);}}} function createHref(base,fullPath,mode){var path=mode==='hash'?'#'+fullPath:fullPath;return base?cleanPath(base+'/'+path):path} VueRouter.install=install;VueRouter.version='3.1.3';if(inBrowser&&window.Vue){window.Vue.use(VueRouter);} return VueRouter;}));