UNPKG

@npkg/vue-router

Version:

> This is `vue-router3.0` Extended version which works only with `Vue 2.0`. For the `Vue3.0` router see the [npm-pkg/vue-router@next](https://github.com/npm-pkg/vue-router). > The extension supports automatic jump to external link

11 lines 28.3 kB
/*! * vue-router v3.5.3 * (c) 2022 Evan You * @license MIT */ /*! * vue-router v3.5.3 * (c) 2022 Evan You * @license MIT */ function t(t,e){for(const n in e)t[n]=e[n];return t}const e=/[!'()*]/g,n=t=>"%"+t.charCodeAt(0).toString(16),r=/%2C/g,o=t=>encodeURIComponent(t).replace(e,n).replace(r,",");function i(t){try{return decodeURIComponent(t)}catch(t){}return t}const s=t=>null==t||"object"==typeof t?t:String(t);function a(t){const e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(t=>{const n=t.replace(/\+/g," ").split("="),r=i(n.shift()),o=n.length>0?i(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]}),e):e}function c(t){const e=t?Object.keys(t).map(e=>{const n=t[e];if(void 0===n)return"";if(null===n)return o(e);if(Array.isArray(n)){const t=[];return n.forEach(n=>{void 0!==n&&(null===n?t.push(o(e)):t.push(o(e)+"="+o(n)))}),t.join("&")}return o(e)+"="+o(n)}).filter(t=>t.length>0).join("&"):null;return e?"?"+e:""}const h=/\/?$/;function u(t,e,n,r){const o=r&&r.options.stringifyQuery;let i=e.query||{};try{i=p(i)}catch(t){}const s={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:i,params:e.params||{},fullPath:d(e,o),matched:t?f(t):[]};return n&&(s.redirectedFrom=d(n,o)),Object.freeze(s)}function p(t){if(Array.isArray(t))return t.map(p);if(t&&"object"==typeof t){const e={};for(const n in t)e[n]=p(t[n]);return e}return t}const l=u(null,{path:"/"});function f(t){const e=[];for(;t;)e.unshift(t),t=t.parent;return e}function d({path:t,query:e={},hash:n=""},r){return(t||"/")+(r||c)(e)+n}function y(t,e,n){return e===l?t===e:!!e&&(t.path&&e.path?t.path.replace(h,"")===e.path.replace(h,"")&&(n||t.hash===e.hash&&m(t.query,e.query)):!(!t.name||!e.name)&&(t.name===e.name&&(n||t.hash===e.hash&&m(t.query,e.query)&&m(t.params,e.params))))}function m(t={},e={}){if(!t||!e)return t===e;const n=Object.keys(t).sort(),r=Object.keys(e).sort();return n.length===r.length&&n.every((n,o)=>{const i=t[n];if(r[o]!==n)return!1;const s=e[n];return null==i||null==s?i===s:"object"==typeof i&&"object"==typeof s?m(i,s):String(i)===String(s)})}function g(t){for(let e=0;e<t.matched.length;e++){const n=t.matched[e];for(const t in n.instances){const e=n.instances[t],r=n.enteredCbs[t];if(e&&r){delete n.enteredCbs[t];for(let t=0;t<r.length;t++)e._isBeingDestroyed||r[t](e)}}}}var w={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"}},render(e,{props:n,children:r,parent:o,data:i}){i.routerView=!0;const s=o.$createElement,a=n.name,c=o.$route,h=o._routerViewCache||(o._routerViewCache={});let u=0,p=!1;for(;o&&o._routerRoot!==o;){const t=o.$vnode?o.$vnode.data:{};t.routerView&&u++,t.keepAlive&&o._directInactive&&o._inactive&&(p=!0),o=o.$parent}if(i.routerViewDepth=u,p){const t=h[a],e=t&&t.component;return e?(t.configProps&&v(e,i,t.route,t.configProps),s(e,i,r)):s()}const l=c.matched[u],f=l&&l.components[a];if(!l||!f)return h[a]=null,s();h[a]={component:f},i.registerRouteInstance=(t,e)=>{const n=l.instances[a];(e&&n!==t||!e&&n===t)&&(l.instances[a]=e)},(i.hook||(i.hook={})).prepatch=(t,e)=>{l.instances[a]=e.componentInstance},i.hook.init=t=>{t.data.keepAlive&&t.componentInstance&&t.componentInstance!==l.instances[a]&&(l.instances[a]=t.componentInstance),g(c)};const d=l.props&&l.props[a];return d&&(t(h[a],{route:c,configProps:d}),v(f,i,c,d)),s(f,i,r)}};function v(e,n,r,o){let i=n.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}(r,o);if(i){i=n.props=t({},i);const r=n.attrs=n.attrs||{};for(const t in i)e.props&&t in e.props||(r[t]=i[t],delete i[t])}}function b(t,e,n){const r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return e+t;const o=e.split("/");n&&o[o.length-1]||o.pop();const i=t.replace(/^\//,"").split("/");for(let t=0;t<i.length;t++){const e=i[t];".."===e?o.pop():"."!==e&&o.push(e)}return""!==o[0]&&o.unshift(""),o.join("/")}function x(t){return t.replace(/\/+/g,"/")}var R=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},k=I,E=O,C=function(t,e){return L(O(t,e),e)},A=L,$=U,j=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function O(t,e){for(var n,r=[],o=0,i=0,s="",a=e&&e.delimiter||"/";null!=(n=j.exec(t));){var c=n[0],h=n[1],u=n.index;if(s+=t.slice(i,u),i=u+c.length,h)s+=h[1];else{var p=t[i],l=n[2],f=n[3],d=n[4],y=n[5],m=n[6],g=n[7];s&&(r.push(s),s="");var w=null!=l&&null!=p&&p!==l,v="+"===m||"*"===m,b="?"===m||"*"===m,x=n[2]||a,R=d||y;r.push({name:f||o++,prefix:l||"",delimiter:x,optional:b,repeat:v,partial:w,asterisk:!!g,pattern:R?T(R):g?".*":"[^"+S(x)+"]+?"})}}return i<t.length&&(s+=t.substr(i)),s&&r.push(s),r}function _(t){return encodeURI(t).replace(/[\/?#]/g,(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}))}function L(t,e){for(var n=new Array(t.length),r=0;r<t.length;r++)"object"==typeof t[r]&&(n[r]=new RegExp("^(?:"+t[r].pattern+")$",q(e)));return function(e,r){for(var o="",i=e||{},s=(r||{}).pretty?_:encodeURIComponent,a=0;a<t.length;a++){var c=t[a];if("string"!=typeof c){var h,u=i[c.name];if(null==u){if(c.optional){c.partial&&(o+=c.prefix);continue}throw new TypeError('Expected "'+c.name+'" to be defined')}if(R(u)){if(!c.repeat)throw new TypeError('Expected "'+c.name+'" to not repeat, but received `'+JSON.stringify(u)+"`");if(0===u.length){if(c.optional)continue;throw new TypeError('Expected "'+c.name+'" to not be empty')}for(var p=0;p<u.length;p++){if(h=s(u[p]),!n[a].test(h))throw new TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'", but received `'+JSON.stringify(h)+"`");o+=(0===p?c.prefix:c.delimiter)+h}}else{if(h=c.asterisk?encodeURI(u).replace(/[?#]/g,(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})):s(u),!n[a].test(h))throw new TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but received "'+h+'"');o+=c.prefix+h}}else o+=c}return o}}function S(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function T(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function P(t,e){return t.keys=e,t}function q(t){return t&&t.sensitive?"":"i"}function U(t,e,n){R(e)||(n=e||n,e=[]);for(var r=(n=n||{}).strict,o=!1!==n.end,i="",s=0;s<t.length;s++){var a=t[s];if("string"==typeof a)i+=S(a);else{var c=S(a.prefix),h="(?:"+a.pattern+")";e.push(a),a.repeat&&(h+="(?:"+c+h+")*"),i+=h=a.optional?a.partial?c+"("+h+")?":"(?:"+c+"("+h+"))?":c+"("+h+")"}}var u=S(n.delimiter||"/"),p=i.slice(-u.length)===u;return r||(i=(p?i.slice(0,-u.length):i)+"(?:"+u+"(?=$))?"),i+=o?"$":r&&p?"":"(?="+u+"|$)",P(new RegExp("^"+i,q(n)),e)}function I(t,e,n){return R(e)||(n=e||n,e=[]),n=n||{},t instanceof RegExp?function(t,e){var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return P(t,e)}(t,e):R(t)?function(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(I(t[o],e,n).source);return P(new RegExp("(?:"+r.join("|")+")",q(n)),e)}(t,e,n):function(t,e,n){return U(O(t,n),e,n)}(t,e,n)}k.parse=E,k.compile=C,k.tokensToFunction=A,k.tokensToRegExp=$;const B=Object.create(null);function M(t,e,n){e=e||{};try{const n=B[t]||(B[t]=k.compile(t));return"string"==typeof e.pathMatch&&(e[0]=e.pathMatch),n(e,{pretty:!0})}catch(t){return""}finally{delete e[0]}}function V(e,n,r,o){let i="string"==typeof e?{path:e}:e;if(i._normalized)return i;if(i.name){i=t({},e);const n=i.params;return n&&"object"==typeof n&&(i.params=t({},n)),i}if(!i.path&&i.params&&n){i=t({},i),i._normalized=!0;const e=t(t({},n.params),i.params);if(n.name)i.name=n.name,i.params=e;else if(n.matched.length){const t=n.matched[n.matched.length-1].path;i.path=M(t,e,n.path)}return i}const c=function(t){let e="",n="";const r=t.indexOf("#");r>=0&&(e=t.slice(r),t=t.slice(0,r));const o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}(i.path||""),h=n&&n.path||"/",u=c.path?b(c.path,h,r||i.append):h,p=function(t,e={},n){const r=n||a;let o;try{o=r(t||"")}catch(t){o={}}for(const t in e){const n=e[t];o[t]=Array.isArray(n)?n.map(s):s(n)}return o}(c.query,i.query,o&&o.options.parseQuery);let l=i.hash||c.hash;return l&&"#"!==l.charAt(0)&&(l="#"+l),{_normalized:!0,path:u,query:p,hash:l}}const H=()=>{};function N(t){if("string"==typeof t&&t.startsWith("http"))return{isExternalLink:!0,_href:t,isJavascript:!1};if("string"==typeof t&&t.startsWith("javascript:")||"string"==typeof t.path&&t.path.startsWith("javascript:"))return{isExternalLink:!1,_href:t,isJavascript:!0};if("object"==typeof t&&"string"==typeof t.path&&t.path.startsWith("http")){return{isExternalLink:!0,_href:("object"==typeof t.params?function(t){const{path:e,params:n}=t,r=Object.keys(n).reduce((t,e)=>(t[e]=n[e],t),{});return""+e.replace(/\:(\w+)/g,(t,e)=>{const n=r[e];return null==n?":"+e:Array.isArray(n)?n.map(t=>encodeURIComponent(t)).join("/"):encodeURIComponent(n)})}(t):t.path)+("object"==typeof t.query?(e=t.query,"?"+Object.keys(e).map(t=>{const n=e[t];return null==n?"":Array.isArray(n)?n.map(e=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"):`${encodeURIComponent(t)}=${encodeURIComponent(n)}`}).filter(Boolean).join("&")):"")+(t.hash?t.hash:""),isJavascript:!1}}var e;return{isExternalLink:!1,_href:"",isJavascript:!1}}var F={name:"RouterLink",props:{to:{type:[String,Object],required:!0},tag:{type:String,default:"a"},custom:Boolean,exact:Boolean,exactPath:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,ariaCurrentValue:{type:String,default:"page"},event:{type:[String,Array],default:"click"}},render(e){const n=this.$router,r=this.$route;const{isExternalLink:o,_href:i,isJavascript:s}=N(this.to);if(o||s)return e(this.tag,{attrs:{href:i,target:this.target?this.target:s?"_self":"_blank"}},this.$slots.default);const{location:a,route:c,href:p}=n.resolve(this.to,r,this.append),l={},f=n.options.linkActiveClass,d=n.options.linkExactActiveClass,m=null==f?"router-link-active":f,g=null==d?"router-link-exact-active":d,w=null==this.activeClass?m:this.activeClass,v=null==this.exactActiveClass?g:this.exactActiveClass,b=c.redirectedFrom?u(null,V(c.redirectedFrom),null,n):c;l[v]=y(r,b,this.exactPath),l[w]=this.exact||this.exactPath?l[v]:function(t,e){return 0===t.path.replace(h,"/").indexOf(e.path.replace(h,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(const n in e)if(!(n in t))return!1;return!0}(t.query,e.query)}(r,b);const x=l[v]?this.ariaCurrentValue:null,R=t=>{z(t)&&(this.replace?n.replace(a,H):n.push(a,H))},k={click:z};Array.isArray(this.event)?this.event.forEach(t=>{k[t]=R}):k[this.event]=R;const E={class:l},C=!this.$scopedSlots.$hasNormal&&this.$scopedSlots.default&&this.$scopedSlots.default({href:p,route:c,navigate:R,isActive:l[w],isExactActive:l[v]});if(C){if(1===C.length)return C[0];if(C.length>1||!C.length)return 0===C.length?e():e("span",{},C)}if("a"===this.tag)E.on=k,E.attrs={href:p,"aria-current":x};else{const e=function t(e){if(e){let n;for(let r=0;r<e.length;r++){if(n=e[r],"a"===n.tag)return n;if(n.children&&(n=t(n.children)))return n}}}(this.$slots.default);if(e){e.isStatic=!1;const n=e.data=t({},e.data);n.on=n.on||{};for(const t in n.on){const e=n.on[t];t in k&&(n.on[t]=Array.isArray(e)?e:[e])}for(const t in k)t in n.on?n.on[t].push(k[t]):n.on[t]=R;const r=e.data.attrs=t({},e.data.attrs);r.href=p,r["aria-current"]=x}else E.on=k}return e(this.tag,E,this.$slots.default)}};function z(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}let J;const D="undefined"!=typeof window;function W(t,e,n,r,o){const i=e||[],s=n||Object.create(null),a=r||Object.create(null);t.forEach(t=>{!function t(e,n,r,o,i,s){const{path:a,name:c}=o,h=o.pathToRegexpOptions||{},u=function(t,e,n){n||(t=t.replace(/\/$/,""));return"/"===t[0]||null==e?t:x(`${e.path}/${t}`)}(a,i,h.strict);"boolean"==typeof o.caseSensitive&&(h.sensitive=o.caseSensitive);const p={path:u,regex:K(u,h),components:o.components||{default:o.component},alias:o.alias?"string"==typeof o.alias?[o.alias]:o.alias:[],instances:{},enteredCbs:{},name:c,parent:i,matchAs:s,redirect:o.redirect,beforeEnter:o.beforeEnter,meta:o.meta||{},props:null==o.props?{}:o.components?o.props:{default:o.props}};o.children&&o.children.forEach(o=>{const i=s?x(`${s}/${o.path}`):void 0;t(e,n,r,o,p,i)});n[p.path]||(e.push(p.path),n[p.path]=p);if(void 0!==o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(let a=0;a<s.length;++a){const c={path:s[a],children:o.children};t(e,n,r,c,i,p.path||"/")}}c&&(r[c]||(r[c]=p))}(i,s,a,t,o)});for(let t=0,e=i.length;t<e;t++)"*"===i[t]&&(i.push(i.splice(t,1)[0]),e--,t--);return{pathList:i,pathMap:s,nameMap:a}}function K(t,e){return k(t,[],e)}function Q(t,e){const{pathList:n,pathMap:r,nameMap:o}=W(t);function i(t,i,s){const c=V(t,i,!1,e),{name:h}=c;if(h){const t=o[h];if(!t)return a(null,c);const e=t.regex.keys.filter(t=>!t.optional).map(t=>t.name);if("object"!=typeof c.params&&(c.params={}),i&&"object"==typeof i.params)for(const t in i.params)!(t in c.params)&&e.indexOf(t)>-1&&(c.params[t]=i.params[t]);return c.path=M(t.path,c.params),a(t,c,s)}if(c.path){c.params={};for(let t=0;t<n.length;t++){const e=n[t],o=r[e];if(X(o.regex,c.path,c.params))return a(o,c,s)}}return a(null,c)}function s(t,n){const r=t.redirect;let s="function"==typeof r?r(u(t,n,null,e)):r;if("string"==typeof s&&(s={path:s}),!s||"object"!=typeof s)return a(null,n);const c=s,{name:h,path:p}=c;let{query:l,hash:f,params:d}=n;if(l=c.hasOwnProperty("query")?c.query:l,f=c.hasOwnProperty("hash")?c.hash:f,d=c.hasOwnProperty("params")?c.params:d,h)return o[h],i({_normalized:!0,name:h,query:l,hash:f,params:d},void 0,n);if(p){return i({_normalized:!0,path:M(function(t,e){return b(t,e.parent?e.parent.path:"/",!0)}(p,t),d),query:l,hash:f},void 0,n)}return a(null,n)}function a(t,n,r){return t&&t.redirect?s(t,r||n):t&&t.matchAs?function(t,e,n){const r=i({_normalized:!0,path:M(n,e.params)});if(r){const t=r.matched,n=t[t.length-1];return e.params=r.params,a(n,e)}return a(null,e)}(0,n,t.matchAs):u(t,n,r,e)}return{match:i,addRoute:function(t,e){const i="object"!=typeof t?o[t]:void 0;W([e||t],n,r,o,i),i&&i.alias.length&&W(i.alias.map(t=>({path:t,children:[e]})),n,r,o,i)},getRoutes:function(){return n.map(t=>r[t])},addRoutes:function(t){W(t,n,r,o)}}}function X(t,e,n){const r=e.match(t);if(!r)return!1;if(!n)return!0;for(let e=1,o=r.length;e<o;++e){const o=t.keys[e-1];o&&(n[o.name||"pathMatch"]="string"==typeof r[e]?i(r[e]):r[e])}return!0}const Y=D&&window.performance&&window.performance.now?window.performance:Date;function G(){return Y.now().toFixed(3)}let Z=G();function tt(){return Z}function et(t){return Z=t}const nt=Object.create(null);function rt(){"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual");const e=window.location.protocol+"//"+window.location.host,n=window.location.href.replace(e,""),r=t({},window.history.state);return r.key=tt(),window.history.replaceState(r,"",n),window.addEventListener("popstate",st),()=>{window.removeEventListener("popstate",st)}}function ot(t,e,n,r){if(!t.app)return;const o=t.options.scrollBehavior;o&&t.app.$nextTick(()=>{const i=function(){const t=tt();if(t)return nt[t]}(),s=o.call(t,e,n,r?i:null);s&&("function"==typeof s.then?s.then(t=>{pt(t,i)}).catch(t=>{}):pt(s,i))})}function it(){const t=tt();t&&(nt[t]={x:window.pageXOffset,y:window.pageYOffset})}function st(t){it(),t.state&&t.state.key&&et(t.state.key)}function at(t){return ht(t.x)||ht(t.y)}function ct(t){return{x:ht(t.x)?t.x:window.pageXOffset,y:ht(t.y)?t.y:window.pageYOffset}}function ht(t){return"number"==typeof t}const ut=/^#\d/;function pt(t,e){const n="object"==typeof t;if(n&&"string"==typeof t.selector){const n=ut.test(t.selector)?document.getElementById(t.selector.slice(1)):document.querySelector(t.selector);if(n){let o=t.offset&&"object"==typeof t.offset?t.offset:{};o={x:ht((r=o).x)?r.x:0,y:ht(r.y)?r.y:0},e=function(t,e){const n=document.documentElement.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left-e.x,y:r.top-n.top-e.y}}(n,o)}else at(t)&&(e=ct(t))}else n&&at(t)&&(e=ct(t));var r;e&&("scrollBehavior"in document.documentElement.style?window.scrollTo({left:e.x,top:e.y,behavior:t.behavior}):window.scrollTo(e.x,e.y))}const lt=D&&function(){const t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"function"==typeof window.history.pushState)}();function ft(e,n){it();const r=window.history;try{if(n){const n=t({},r.state);n.key=tt(),r.replaceState(n,"",e)}else r.pushState({key:et(G())},"",e)}catch(t){window.location[n?"replace":"assign"](e)}}function dt(t){ft(t,!0)}function yt(t,e,n){const r=o=>{o>=t.length?n():t[o]?e(t[o],()=>{r(o+1)}):r(o+1)};r(0)}const mt={redirected:2,aborted:4,cancelled:8,duplicated:16};function gt(t,e){return vt(t,e,mt.redirected,`Redirected when going from "${t.fullPath}" to "${function(t){if("string"==typeof t)return t;if("path"in t)return t.path;const e={};return bt.forEach(n=>{n in t&&(e[n]=t[n])}),JSON.stringify(e,null,2)}(e)}" via a navigation guard.`)}function wt(t,e){return vt(t,e,mt.cancelled,`Navigation cancelled from "${t.fullPath}" to "${e.fullPath}" with a new navigation.`)}function vt(t,e,n,r){const o=new Error(r);return o._isRouter=!0,o.from=t,o.to=e,o.type=n,o}const bt=["params","query","hash"];function xt(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function Rt(t,e){return xt(t)&&t._isRouter&&(null==e||t.type===e)}function kt(t){return(e,n,r)=>{let o=!1,i=0,s=null;Et(t,(t,e,n,a)=>{if("function"==typeof t&&void 0===t.cid){o=!0,i++;const e=$t(e=>{var o;((o=e).__esModule||At&&"Module"===o[Symbol.toStringTag])&&(e=e.default),t.resolved="function"==typeof e?e:J.extend(e),n.components[a]=e,i--,i<=0&&r()}),c=$t(t=>{const e=`Failed to resolve async component ${a}: ${t}`;s||(s=xt(t)?t:new Error(e),r(s))});let h;try{h=t(e,c)}catch(t){c(t)}if(h)if("function"==typeof h.then)h.then(e,c);else{const t=h.component;t&&"function"==typeof t.then&&t.then(e,c)}}}),o||r()}}function Et(t,e){return Ct(t.map(t=>Object.keys(t.components).map(n=>e(t.components[n],t.instances[n],t,n))))}function Ct(t){return Array.prototype.concat.apply([],t)}const At="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function $t(t){let e=!1;return function(...n){if(!e)return e=!0,t.apply(this,n)}}class jt{constructor(t,e){this.router=t,this.base=function(t){if(!t)if(D){const e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=l,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[],this.listeners=[]}listen(t){this.cb=t}onReady(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))}onError(t){this.errorCbs.push(t)}transitionTo(t,e,n){let r;try{r=this.router.match(t,this.current)}catch(t){throw this.errorCbs.forEach(e=>{e(t)}),t}const o=this.current;this.confirmTransition(r,()=>{this.updateRoute(r),e&&e(r),this.ensureURL(),this.router.afterHooks.forEach(t=>{t&&t(r,o)}),this.ready||(this.ready=!0,this.readyCbs.forEach(t=>{t(r)}))},t=>{n&&n(t),t&&!this.ready&&(Rt(t,mt.redirected)&&o===l||(this.ready=!0,this.readyErrorCbs.forEach(e=>{e(t)})))})}confirmTransition(t,e,n){const r=this.current;this.pending=t;const o=t=>{!Rt(t)&&xt(t)&&(this.errorCbs.length?this.errorCbs.forEach(e=>{e(t)}):console.error(t)),n&&n(t)},i=t.matched.length-1,s=r.matched.length-1;if(y(t,r)&&i===s&&t.matched[i]===r.matched[s])return this.ensureURL(),t.hash&&ot(this.router,r,t,!1),o(function(t,e){const n=vt(t,e,mt.duplicated,`Avoided redundant navigation to current location: "${t.fullPath}".`);return n.name="NavigationDuplicated",n}(r,t));const{updated:a,deactivated:c,activated:h}=function(t,e){let n;const r=Math.max(t.length,e.length);for(n=0;n<r&&t[n]===e[n];n++);return{updated:e.slice(0,n),activated:e.slice(n),deactivated:t.slice(n)}}(this.current.matched,t.matched),u=[].concat(function(t){return Ot(t,"beforeRouteLeave",_t,!0)}(c),this.router.beforeHooks,function(t){return Ot(t,"beforeRouteUpdate",_t)}(a),h.map(t=>t.beforeEnter),kt(h)),p=(e,n)=>{if(this.pending!==t)return o(wt(r,t));try{e(t,r,e=>{!1===e?(this.ensureURL(!0),o(function(t,e){return vt(t,e,mt.aborted,`Navigation aborted from "${t.fullPath}" to "${e.fullPath}" via a navigation guard.`)}(r,t))):xt(e)?(this.ensureURL(!0),o(e)):"string"==typeof e||"object"==typeof e&&("string"==typeof e.path||"string"==typeof e.name)?(o(gt(r,t)),"object"==typeof e&&e.replace?this.replace(e):this.push(e)):n(e)})}catch(t){o(t)}};yt(u,p,()=>{yt(function(t){return Ot(t,"beforeRouteEnter",(t,e,n,r)=>function(t,e,n){return function(r,o,i){return t(r,o,t=>{"function"==typeof t&&(e.enteredCbs[n]||(e.enteredCbs[n]=[]),e.enteredCbs[n].push(t)),i(t)})}}(t,n,r))}(h).concat(this.router.resolveHooks),p,()=>{if(this.pending!==t)return o(wt(r,t));this.pending=null,e(t),this.router.app&&this.router.app.$nextTick(()=>{g(t)})})})}updateRoute(t){this.current=t,this.cb&&this.cb(t)}setupListeners(){}teardown(){this.listeners.forEach(t=>{t()}),this.listeners=[],this.current=l,this.pending=null}}function Ot(t,e,n,r){const o=Et(t,(t,r,o,i)=>{const s=function(t,e){"function"!=typeof t&&(t=J.extend(t));return t.options[e]}(t,e);if(s)return Array.isArray(s)?s.map(t=>n(t,r,o,i)):n(s,r,o,i)});return Ct(r?o.reverse():o)}function _t(t,e){if(e)return function(){return t.apply(e,arguments)}}class Lt extends jt{constructor(t,e){super(t,e),this._startLocation=St(this.base)}setupListeners(){if(this.listeners.length>0)return;const t=this.router,e=t.options.scrollBehavior,n=lt&&e;n&&this.listeners.push(rt());const r=()=>{const e=this.current,r=St(this.base);this.current===l&&r===this._startLocation||this.transitionTo(r,r=>{n&&ot(t,r,e,!0)})};window.addEventListener("popstate",r),this.listeners.push(()=>{window.removeEventListener("popstate",r)})}go(t){window.history.go(t)}push(t,e,n){const{current:r}=this;this.transitionTo(t,t=>{ft(x(this.base+t.fullPath)),ot(this.router,t,r,!1),e&&e(t)},n)}replace(t,e,n){const{current:r}=this;this.transitionTo(t,t=>{dt(x(this.base+t.fullPath)),ot(this.router,t,r,!1),e&&e(t)},n)}ensureURL(t){if(St(this.base)!==this.current.fullPath){const e=x(this.base+this.current.fullPath);t?ft(e):dt(e)}}getCurrentLocation(){return St(this.base)}}function St(t){let e=window.location.pathname;const n=e.toLowerCase(),r=t.toLowerCase();return!t||n!==r&&0!==n.indexOf(x(r+"/"))||(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}class Tt extends jt{constructor(t,e,n){super(t,e),n&&function(t){const e=St(t);if(!/^\/#/.test(e))return window.location.replace(x(t+"/#"+e)),!0}(this.base)||Pt()}setupListeners(){if(this.listeners.length>0)return;const t=this.router.options.scrollBehavior,e=lt&&t;e&&this.listeners.push(rt());const n=()=>{const t=this.current;Pt()&&this.transitionTo(qt(),n=>{e&&ot(this.router,n,t,!0),lt||Bt(n.fullPath)})},r=lt?"popstate":"hashchange";window.addEventListener(r,n),this.listeners.push(()=>{window.removeEventListener(r,n)})}push(t,e,n){const{current:r}=this;this.transitionTo(t,t=>{It(t.fullPath),ot(this.router,t,r,!1),e&&e(t)},n)}replace(t,e,n){const{current:r}=this;this.transitionTo(t,t=>{Bt(t.fullPath),ot(this.router,t,r,!1),e&&e(t)},n)}go(t){window.history.go(t)}ensureURL(t){const e=this.current.fullPath;qt()!==e&&(t?It(e):Bt(e))}getCurrentLocation(){return qt()}}function Pt(){const t=qt();return"/"===t.charAt(0)||(Bt("/"+t),!1)}function qt(){let t=window.location.href;const e=t.indexOf("#");return e<0?"":(t=t.slice(e+1),t)}function Ut(t){const e=window.location.href,n=e.indexOf("#");return`${n>=0?e.slice(0,n):e}#${t}`}function It(t){lt?ft(Ut(t)):window.location.hash=t}function Bt(t){lt?dt(Ut(t)):window.location.replace(Ut(t))}class Mt extends jt{constructor(t,e){super(t,e),this.stack=[],this.index=-1}push(t,e,n){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index+1).concat(t),this.index++,e&&e(t)},n)}replace(t,e,n){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index).concat(t),e&&e(t)},n)}go(t){const e=this.index+t;if(e<0||e>=this.stack.length)return;const n=this.stack[e];this.confirmTransition(n,()=>{const t=this.current;this.index=e,this.updateRoute(n),this.router.afterHooks.forEach(e=>{e&&e(n,t)})},t=>{Rt(t,mt.duplicated)&&(this.index=e)})}getCurrentLocation(){const t=this.stack[this.stack.length-1];return t?t.fullPath:"/"}ensureURL(){}}class Vt{constructor(t={}){this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=Q(t.routes||[],this);let e=t.mode||"hash";switch(this.fallback="history"===e&&!lt&&!1!==t.fallback,this.fallback&&(e="hash"),D||(e="abstract"),this.mode=e,e){case"history":this.history=new Lt(this,t.base);break;case"hash":this.history=new Tt(this,t.base,this.fallback);break;case"abstract":this.history=new Mt(this,t.base)}}match(t,e,n){return this.matcher.match(t,e,n)}get currentRoute(){return this.history&&this.history.current}init(t){if(this.apps.push(t),t.$once("hook:destroyed",()=>{const e=this.apps.indexOf(t);e>-1&&this.apps.splice(e,1),this.app===t&&(this.app=this.apps[0]||null),this.app||this.history.teardown()}),this.app)return;this.app=t;const e=this.history;if(e instanceof Lt||e instanceof Tt){const t=t=>{const n=e.current,r=this.options.scrollBehavior;lt&&r&&"fullPath"in t&&ot(this,t,n,!1)},n=n=>{e.setupListeners(),t(n)};e.transitionTo(e.getCurrentLocation(),n,n)}e.listen(t=>{this.apps.forEach(e=>{e._route=t})})}beforeEach(t){return Ht(this.beforeHooks,t)}beforeResolve(t){return Ht(this.resolveHooks,t)}afterEach(t){return Ht(this.afterHooks,t)}onReady(t,e){this.history.onReady(t,e)}onError(t){this.history.onError(t)}push(t,e,n){if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((e,n)=>{this.history.push(t,e,n)});this.history.push(t,e,n)}replace(t,e,n){if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((e,n)=>{this.history.replace(t,e,n)});this.history.replace(t,e,n)}go(t){this.history.go(t)}back(){this.go(-1)}forward(){this.go(1)}getMatchedComponents(t){const e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(t=>Object.keys(t.components).map(e=>t.components[e]))):[]}resolve(t,e,n){const r=V(t,e=e||this.history.current,n,this),o=this.match(r,e),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:function(t,e,n){var r="hash"===n?"#"+e:e;return t?x(t+"/"+r):r}(this.history.base,i,this.mode),normalizedTo:r,resolved:o}}getRoutes(){return this.matcher.getRoutes()}addRoute(t,e){this.matcher.addRoute(t,e),this.history.current!==l&&this.history.transitionTo(this.history.getCurrentLocation())}addRoutes(t){this.matcher.addRoutes(t),this.history.current!==l&&this.history.transitionTo(this.history.getCurrentLocation())}}function Ht(t,e){return t.push(e),()=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)}}Vt.install=function t(e){if(t.installed&&J===e)return;t.installed=!0,J=e;const n=t=>void 0!==t,r=(t,e)=>{let r=t.$options._parentVnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(t,e)};e.mixin({beforeCreate(){n(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),e.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,r(this,this)},destroyed(){r(this)}}),Object.defineProperty(e.prototype,"$router",{get(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$route",{get(){return this._routerRoot._route}}),e.component("RouterView",w),e.component("RouterLink",F);const o=e.config.optionMergeStrategies;o.beforeRouteEnter=o.beforeRouteLeave=o.beforeRouteUpdate=o.created},Vt.version="3.5.3",Vt.isNavigationFailure=Rt,Vt.NavigationFailureType=mt,Vt.START_LOCATION=l,D&&window.Vue&&window.Vue.use(Vt);export default Vt;