微信公众号前端模版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 lines
22 KiB

var VueRouter=function(e,M){"use strict";const l="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,t=e=>l?Symbol(e):"_vr_"+e,r=t("rvlm"),n=t("rvd"),_=t("r"),T=t("rl"),B=t("rvl"),G="undefined"!=typeof window,F=Object.assign;function I(e,t){const r={};for(const n in t){const o=t[n];r[n]=Array.isArray(o)?o.map(e):e(o)}return r}let K=()=>{};const o=/\/$/;function U(e,t,r="/"){let n,o={},a="",i="";var c=t.indexOf("?"),l=t.indexOf("#",-1<c?c:0);return-1<c&&(n=t.slice(0,c),a=t.slice(c+1,-1<l?l:t.length),o=e(a)),-1<l&&(n=n||t.slice(0,l),i=t.slice(l,t.length)),n=function(e,t){if(e.startsWith("/"))return e;if(!e)return t;const r=t.split("/"),n=e.split("/");let o,a,i=r.length-1;for(o=0;o<n.length;o++)if(a=n[o],1!==i&&"."!==a){if(".."!==a)break;i--}return r.slice(0,i).join("/")+"/"+n.slice(o-(o===n.length?1:0)).join("/")}(null!=n?n:t,r),{fullPath:n+(a&&"?")+a+i,path:n,query:o,hash:i}}function i(e,t){return t&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length)||"/":e}function V(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function H(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(n=e[r],r=t[r],!(Array.isArray(n)?a(n,r):Array.isArray(r)?a(r,n):n===r))return!1;var n;return!0}function a(e,r){return Array.isArray(r)?e.length===r.length&&e.every((e,t)=>e===r[t]):1===e.length&&e[0]===r}var W,f,c;(c=W=W||{}).pop="pop",c.push="push",(c=f=f||{}).back="back",c.forward="forward",c.unknown="";const s=/^[^#]+#/;function u(e,t){return e.replace(s,"#")+t}const D=()=>({left:window.pageXOffset,top:window.pageYOffset});function N(e,t){return(history.state?history.state.position-t:-1)+e}const z=new Map;function p(r,e){const{pathname:t,search:n,hash:o}=e,a=r.indexOf("#");if(-1<a){let e=o.includes(r.slice(a))?r.slice(a).length:1,t=o.slice(e);return"/"!==t[0]&&(t="/"+t),i(t,"")}return i(t,r)+n+o}function h(e,t,r,n=!1,o=!1){return{back:e,current:t,forward:r,replaced:n,position:window.history.length,scroll:o?D():null}}function d(e){const t=function(o){const{history:a,location:i}=window;let n={value:p(o,i)},c={value:a.state};function l(t,e,r){var n=o.indexOf("#"),t=-1<n?(i.host&&document.querySelector("base")?o:o.slice(n))+t:location.protocol+"//"+location.host+o+t;try{a[r?"replaceState":"pushState"](e,"",t),c.value=e}catch(e){console.error(e),i[r?"replace":"assign"](t)}}return c.value||l(n.value,{back:null,current:n.value,forward:null,position:a.length-1,replaced:!0,scroll:null},!0),{location:n,state:c,push:function(e,t){var r=F({},c.value,a.state,{forward:e,scroll:D()});l(r.current,r,!0),l(e,F({},h(n.value,e,null),{position:r.position+1},t),!1),n.value=e},replace:function(e,t){l(e,F({},a.state,h(c.value.back,e,c.value.forward,!0),t,{position:c.value.position}),!0),n.value=e}}}(e=function(e){if(!e)if(G){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return(e="/"!==e[0]&&"#"!==e[0]?"/"+e:e).replace(o,"")}(e)),r=function(a,i,c,l){let s=[],r=[],u=null;const t=({state:e})=>{const t=p(a,location),r=c.value,n=i.value;let o=0;if(e){if(c.value=t,i.value=e,u&&u===r)return void(u=null);o=n?e.position-n.position:0}else l(t);s.forEach(e=>{e(c.value,r,{delta:o,type:W.pop,direction:o?0<o?f.forward:f.back:f.unknown})})};function n(){const{history:e}=window;e.state&&e.replaceState(F({},e.state,{scroll:D()}),"")}return window.addEventListener("popstate",t),window.addEventListener("beforeunload",n),{pauseListeners:function(){u=c.value},listen:function(t){s.push(t);var e=()=>{var e=s.indexOf(t);-1<e&&s.splice(e,1)};return r.push(e),e},destroy:function(){for(const e of r)e();r=[],window.removeEventListener("popstate",t),window.removeEventListener("beforeunload",n)}}}(e,t.state,t.location,t.replace);e=F({location:"",base:e,go:function(e,t=!0){t||r.pauseListeners(),history.go(e)},createHref:u.bind(null,e)},t,r);return Object.defineProperty(e,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(e,"state",{enumerable:!0,get:()=>t.state.value}),e}function Q(e){return"string"==typeof e||"symbol"==typeof e}const X={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},v=t("nf");function Y(e,t){return F(new Error,{type:e,[v]:!0},t)}function Z(e,t){return e instanceof Error&&v in e&&(null==t||!!(e.type&t))}e.NavigationFailureType=void 0,(c=e.NavigationFailureType||(e.NavigationFailureType={}))[c.aborted=4]="aborted",c[c.cancelled=8]="cancelled",c[c.duplicated=16]="duplicated";const b="[^/]+?",w={sensitive:!1,strict:!1,start:!0,end:!0},E=/[.+*?^${}()[\]/\\]/g;function R(e,t){let r=0;for(var n=e.score,o=t.score;r<n.length&&r<o.length;){const e=function(e,t){let r=0;for(;r<e.length&&r<t.length;){var n=t[r]-e[r];if(n)return n;r++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}(n[r],o[r]);if(e)return e;r++}return o.length-n.length}const A={type:0,value:""},k=/[a-zA-Z0-9_]/;function J(e,d){const v=[],m=new Map;function g(e,t,r){let n=!r,o={path:(a=e).path,redirect:a.redirect,name:a.name,meta:a.meta||{},aliasOf:void 0,beforeEnter:a.beforeEnter,props:function(e){const t={},r=e.props||!1;if("component"in e)t.default=r;else for(var n in e.components)t[n]="boolean"==typeof r?r:r[n];return t}(a),children:a.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in a?a.components||{}:{default:a.component}};var a;o.aliasOf=r&&r.record;const i=P(d,e),c=[o];if("alias"in e){const d="string"==typeof e.alias?[e.alias]:e.alias;for(const e of d)c.push(F({},o,{components:(r?r.record:o).components,path:e,aliasOf:r?r.record:o}))}let l,s;for(const d of c){var u,f,{path:p}=d;if(t&&"/"!==p[0]&&(f="/"===(u=t.record.path)[u.length-1]?"":"/",d.path=t.record.path+(p&&f+p)),u=d,f=t,p=i,p=function(s,n){const o=F({},w,n);let e=[],a=o.start?"^":"";const i=[];for(const n of s){const s=n.length?[]:[90];o.strict&&!n.length&&(a+="/");for(let r=0;r<n.length;r++){const c=n[r];let t=40+(o.sensitive?.25:0);if(0===c.type)r||(a+="/"),a+=c.value.replace(E,"\\$&"),t+=40;else if(1===c.type){const{value:s,repeatable:o,optional:l,regexp:u}=c;i.push({name:s,repeatable:o,optional:l});const F=u||b;if(F!==b){t+=10;try{new RegExp(`(${F})`)}catch(n){throw new Error(`Invalid custom RegExp for param "${s}" (${F}): `+n.message)}}let e=o?`((?:${F})(?:/(?:${F}))*)`:`(${F})`;r||(e=l&&n.length<2?`(?:/${e})`:"/"+e),l&&(e+="?"),a+=e,t+=20,l&&(t+=-8),o&&(t+=-20),".*"===F&&(t+=-50)}s.push(t)}e.push(s)}if(o.strict&&o.end){const s=e.length-1;e[s][e[s].length-1]+=.7000000000000001}o.strict||(a+="/?"),o.end?a+="$":o.strict&&(a+="(?:/|$)");const c=new RegExp(a,o.sensitive?"":"i");return{re:c,score:e,keys:i,parse:function(e){const t=e.match(c),r={};if(!t)return null;for(let e=1;e<t.length;e++){const n=t[e]||"",o=i[e-1];r[o.name]=n&&o.repeatable?n.split("/"):n}return r},stringify:function(e){let t="",r=!1;for(const o of s){r&&t.endsWith("/")||(t+="/"),r=!1;for(const s of o)if(0===s.type)t+=s.value;else if(1===s.type){const{value:a,repeatable:i,optional:c}=s,l=a in e?e[a]:"";if(Array.isArray(l)&&!i)throw new Error(`Provided param "${a}" is an array but it is not repeatable (* or + modifiers)`);var n=Array.isArray(l)?l.join("/"):l;if(!n){if(!c)throw new Error(`Missing required param "${a}"`);o.length<2&&(t.endsWith("/")?t=t.slice(0,-1):r=!0)}t+=n}}return t}}}(function(e){if(!e)return[[]];if("/"===e)return[[A]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(e){throw new Error(`ERR (${r})/"${s}": ${e}`)}let r=0,n=r;const o=[];let a;function i(){a&&o.push(a),a=[]}let c,l=0,s="",u="";function f(){s&&(0===r?a.push({type:0,value:s}):1===r||2===r||3===r?(1<a.length&&("*"===c||"+"===c)&&t(`A repeatable param (${s}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:s,regexp:u,repeatable:"*"===c||"+"===c,optional:"*"===c||"?"===c})):t("Invalid state to consume buffer"),s="")}function p(){s+=c}for(;l<e.length;)if(c=e[l++],"\\"!==c||2===r)switch(r){case 0:"/"===c?(s&&f(),i()):":"===c?(f(),r=1):p();break;case 4:p(),r=n;break;case 1:"("===c?r=2:k.test(c)?p():(f(),r=0,"*"!==c&&"?"!==c&&"+"!==c&&l--);break;case 2:")"===c?"\\"==u[u.length-1]?u=u.slice(0,-1)+c:r=3:u+=c;break;case 3:f(),r=0,"*"!==c&&"?"!==c&&"+"!==c&&l--,u="";break;default:t("Unknown state")}else n=r,r=4;return 2===r&&t(`Unfinished custom RegExp for param "${s}"`),f(),i(),o}(u.path),p),u=F(p,{record:u,parent:f,children:[],alias:[]}),f&&!u.record.aliasOf==!f.record.aliasOf&&f.children.push(u),l=u,r?r.alias.push(l):(s=s||l,s!==l&&s.alias.push(l),n&&e.name&&!O(l)&&y(e.name)),"children"in o){var h=o.children;for(let e=0;e<h.length;e++)g(h[e],l,r&&r.children[e])}r=r||l,function(e){let t=0;for(;t<v.length&&0<=R(e,v[t]);)t++;v.splice(t,0,e),e.record.name&&!O(e)&&m.set(e.record.name,e)}(l)}return s?()=>{y(s)}:K}function y(e){if(Q(e)){const r=m.get(e);r&&(m.delete(e),v.splice(v.indexOf(r),1),r.children.forEach(y),r.alias.forEach(y))}else{var t=v.indexOf(e);-1<t&&(v.splice(t,1),e.record.name&&m.delete(e.record.name),e.children.forEach(y),e.alias.forEach(y))}}return d=P({strict:!1,end:!0,sensitive:!1},d),e.forEach(e=>g(e)),{addRoute:g,resolve:function(e,t){let n,r,o,a={};if("name"in e&&e.name){if(n=m.get(e.name),!n)throw Y(1,{location:e});o=n.record.name,a=F(function(e){let t={};for(var r of n.keys.filter(e=>!e.optional).map(e=>e.name))r in e&&(t[r]=e[r]);return t}(t.params),e.params),r=n.stringify(a)}else if("path"in e)r=e.path,n=v.find(e=>e.re.test(r)),n&&(a=n.parse(r),o=n.record.name);else{if(n=t.name?m.get(t.name):v.find(e=>e.re.test(t.path)),!n)throw Y(1,{location:e,currentLocation:t});o=n.record.name,a=F({},t.params,e.params),r=n.stringify(a)}const i=[];let c=n;for(;c;)i.unshift(c.record),c=c.parent;return{name:o,path:r,params:a,matched:i,meta:i.reduce((e,t)=>F(e,t.meta),{})}},removeRoute:y,getRoutes:function(){return v},getRecordMatcher:function(e){return m.get(e)}}}function O(e){for(;e;){if(e.record.aliasOf)return 1;e=e.parent}}function P(e,t){let r={};for(var n in e)r[n]=(n in t?t:e)[n];return r}const m=/#/g,g=/&/g,y=/\//g,j=/=/g,x=/\?/g,C=/\+/g,$=/%5B/g,S=/%5D/g,ee=/%5E/g,L=/%60/g,te=/%7B/g,q=/%7C/g,re=/%7D/g,ne=/%20/g;function oe(e){return encodeURI(""+e).replace(q,"|").replace($,"[").replace(S,"]")}function ae(e){return oe(e).replace(C,"%2B").replace(ne,"+").replace(m,"%23").replace(g,"%26").replace(L,"`").replace(te,"{").replace(re,"}").replace(ee,"^")}function ie(e){return oe(e).replace(m,"%23").replace(x,"%3F").replace(y,"%2F")}function ce(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}function le(e){const t={};if(""===e||"?"===e)return t;const r=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<r.length;++e){const a=r[e].replace(C," ");var n=a.indexOf("="),o=ce(n<0?a:a.slice(0,n)),n=n<0?null:ce(a.slice(n+1));if(o in t){let e=t[o];Array.isArray(e)||(e=t[o]=[e]),e.push(n)}else t[o]=n}return t}function se(e){let r="";for(let t in e){const n=e[t];(t=ae(t).replace(j,"%3D"),null!=n)?(Array.isArray(n)?n.map(e=>e&&ae(e)):[n&&ae(n)]).forEach(e=>{void 0!==e&&(r+=(r.length?"&":"")+t,null!=e&&(r+="="+e))}):void 0!==n&&(r+=(r.length?"&":"")+t)}return r}function ue(){let r=[];return{add:function(t){return r.push(t),()=>{var e=r.indexOf(t);-1<e&&r.splice(e,1)}},list:()=>r,reset:function(){r=[]}}}function fe(e,t,r){var n=()=>{e[t].delete(r)};M.onUnmounted(n),M.onDeactivated(n),M.onActivated(()=>{e[t].add(r)}),e[t].add(r)}function pe(a,i,c,l,s){const u=l&&(l.enterCallbacks[s]=l.enterCallbacks[s]||[]);return()=>new Promise((t,r)=>{var e=e=>{!1===e?r(Y(4,{from:c,to:i})):e instanceof Error?r(e):"string"==typeof e||e&&"object"==typeof e?r(Y(2,{from:i,to:e})):(u&&l.enterCallbacks[s]===u&&"function"==typeof e&&u.push(e),t())},n=a.call(l&&l.instances[s],i,c,e);let o=Promise.resolve(n);a.length<3&&(o=o.then(e)),o.catch(e=>r(e))})}function he(r,n,o,a){const i=[];for(const c of r)for(const r in c.components){let t=c.components[r];if("beforeRouteEnter"===n||c.instances[r])if("object"==typeof(e=t)||"displayName"in e||"props"in e||"__vccOpts"in e){const l=(t.__vccOpts||t)[n];l&&i.push(pe(l,o,a,c,r))}else{let e=t();i.push(()=>e.then(e=>{if(!e)return Promise.reject(new Error(`Couldn't resolve component "${r}" at "${c.path}"`));var t,e=(t=e).__esModule||l&&"Module"===t[Symbol.toStringTag]?e.default:e,e=((c.components[r]=e).__vccOpts||e)[n];return e&&pe(e,o,a,c,r)()}))}}var e;return i}function de(t){const r=M.inject(_),i=M.inject(T),c=M.computed(()=>r.resolve(M.unref(t.to))),e=M.computed(()=>{var{matched:e}=c.value,{length:t}=e,r=e[t-1];let n=i.matched;if(!r||!n.length)return-1;var o=n.findIndex(V.bind(null,r));if(-1<o)return o;var a=me(e[t-2]);return 1<t&&me(r)===a&&n[n.length-1].path!==a?n.findIndex(V.bind(null,e[t-2])):o}),n=M.computed(()=>-1<e.value&&function(t,n){for(var o in n){let e=n[o],r=t[o];if("string"==typeof e){if(e!==r)return!1}else if(!Array.isArray(r)||r.length!==e.length||e.some((e,t)=>e!==r[t]))return!1}return!0}(i.params,c.value.params)),o=M.computed(()=>-1<e.value&&e.value===i.matched.length-1&&H(i.params,c.value.params));return{route:c,href:M.computed(()=>c.value.href),isActive:n,isExactActive:o,navigate:function(e={}){return function(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){var t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),1}}(e)?r[M.unref(t.replace)?"replace":"push"](M.unref(t.to)).catch(K):Promise.resolve()}}}const ve=M.defineComponent({name:"RouterLink",props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:de,setup(t,{slots:r}){const n=M.reactive(de(t)),{options:e}=M.inject(_),o=M.computed(()=>({[ge(t.activeClass,e.linkActiveClass,"router-link-active")]:n.isActive,[ge(t.exactActiveClass,e.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{var e=r.default&&r.default(n);return t.custom?e:M.h("a",{"aria-current":n.isExactActive?t.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:o.value},e)}}});function me(e){return e?(e.aliasOf||e).path:""}const ge=(e,t,r)=>null!=e?e:null!=t?t:r;function ye(e,t){if(!e)return null;t=e(t);return 1===t.length?t[0]:t}const be=M.defineComponent({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},setup(c,{attrs:l,slots:s}){const e=M.inject(B),u=M.computed(()=>c.route||e.value),t=M.inject(n,0),f=M.computed(()=>u.value.matched[t]);M.provide(n,t+1),M.provide(r,f),M.provide(B,u);const p=M.ref();return M.watch(()=>[p.value,f.value,c.name],([t,e,r],[n,o])=>{e&&(e.instances[r]=t,o&&o!==e&&t&&t===n&&(e.leaveGuards.size||(e.leaveGuards=o.leaveGuards),e.updateGuards.size||(e.updateGuards=o.updateGuards))),!t||!e||o&&V(e,o)&&n||(e.enterCallbacks[r]||[]).forEach(e=>e(t))},{flush:"post"}),()=>{const e=u.value,t=f.value,r=t&&t.components[c.name],n=c.name;if(!r)return ye(s.default,{Component:r,route:e});const o=t.props[c.name],a=o?!0===o?e.params:"function"==typeof o?o(e):o:null,i=M.h(r,F({},a,l,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(t.instances[n]=null)},ref:p}));return ye(s.default,{Component:i,route:e})||i}}});function we(e){return e.reduce((e,t)=>e.then(()=>t()),Promise.resolve())}return e.RouterLink=ve,e.RouterView=be,e.START_LOCATION=X,e.createMemoryHistory=function(e=""){let i=[],o=[""],a=0;function r(e){a++,a===o.length||o.splice(a),o.push(e)}e={location:"",state:{},base:e,createHref:u.bind(null,e),replace(e){o.splice(a--,1),r(e)},push(e,t){r(e)},listen:t=>(i.push(t),()=>{var e=i.indexOf(t);-1<e&&i.splice(e,1)}),destroy(){i=[],o=[""],a=0},go(e,t=!0){var r=this.location,n=e<0?f.back:f.forward;a=Math.max(0,Math.min(a+e,o.length-1)),t&&function(e,t,{direction:r,delta:n}){var o,a={direction:r,delta:n,type:W.pop};for(o of i)o(e,t,a)}(this.location,r,{direction:n,delta:e})}};return Object.defineProperty(e,"location",{enumerable:!0,get:()=>o[a]}),e},e.createRouter=function(l){const c=J(l.routes,l);let s=l.parseQuery||le,d=l.stringifyQuery||se,u=l.history;const f=ue(),p=ue(),o=ue(),v=M.shallowRef(X);let m=X;G&&l.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const h=I.bind(null,e=>""+e),g=I.bind(null,ie),y=I.bind(null,ce);function b(e,t){if(t=F({},t||v.value),"string"==typeof e){var r=U(s,e,t.path),n=c.resolve({path:r.path},t),o=u.createHref(r.fullPath);return F(r,n,{params:y(n.params),hash:ce(r.hash),redirectedFrom:void 0,href:o})}let a;"path"in e?a=F({},e,{path:U(s,e.path,t.path).path}):(a=F({},e,{params:g(e.params)}),t.params=g(t.params));let i=c.resolve(a,t);r=e.hash||"";i.params=h(y(i.params));o=function(e,t){e=t.query?e(t.query):"";return t.path+(e&&"?")+e+(t.hash||"")}(d,F({},e,{hash:oe(r).replace(te,"{").replace(re,"}").replace(ee,"^"),path:i.path})),t=u.createHref(o);return F({fullPath:o,hash:r,query:d===se?function(t){const r={};for(var n in t){let e=t[n];void 0!==e&&(r[n]=Array.isArray(e)?e.map(e=>null==e?null:""+e):null==e?e:""+e)}return r}(e.query):e.query},i,{redirectedFrom:void 0,href:t})}function w(e){return"string"==typeof e?U(s,e,v.value.path):F({},e)}function E(e,t){if(m!==e)return Y(8,{from:t,to:e})}function n(e){return A(e)}function R(t){var r=t.matched[t.matched.length-1];if(r&&r.redirect){const{redirect:n}=r;let e="function"==typeof n?n(t):n;return"string"==typeof e&&(e=e.includes("?")||e.includes("#")?e=w(e):{path:e},e.params={}),F({query:t.query,hash:t.hash,params:t.params},e)}}function A(e,t){const r=m=b(e),n=v.value,o=e.state,a=e.force,i=!0===e.replace,c=R(r);if(c)return A(F(w(c),{state:o,force:a,replace:i}),t||r);const l=r;let s;return l.redirectedFrom=t,!a&&(u=d,f=n,p=r,h=f.matched.length-1,e=p.matched.length-1,-1<h&&h==e&&V(f.matched[h],p.matched[e])&&H(f.params,p.params)&&u(f.query)===u(p.query)&&f.hash===p.hash)&&(s=Y(16,{to:l,from:n}),S(n,n,!0,!1)),(s?Promise.resolve(s):k(l,n)).catch(e=>Z(e)?e:C(e,l,n)).then(e=>{if(e){if(Z(e,2))return A(F(w(e.to),{state:o,force:a,replace:i}),t||l)}else e=P(l,n,!0,i,o);return O(l,n,e),e});var u,f,p,h}function k(r,n){let o;const[e,t,a]=function(t,r){const n=[],o=[],a=[],i=Math.max(r.matched.length,t.matched.length);for(let e=0;e<i;e++){const i=r.matched[e];i&&(t.matched.find(e=>V(e,i))?o:n).push(i);const c=t.matched[e];c&&(r.matched.find(e=>V(e,c))||a.push(c))}return[n,o,a]}(r,n);o=he(e.reverse(),"beforeRouteLeave",r,n);for(const t of e)t.leaveGuards.forEach(e=>{o.push(pe(e,r,n))});const i=function(e,t){return(t=E(e,t))?Promise.reject(t):Promise.resolve()}.bind(null,r,n);return o.push(i),we(o).then(()=>{o=[];for(const e of f.list())o.push(pe(e,r,n));return o.push(i),we(o)}).then(()=>{o=he(t,"beforeRouteUpdate",r,n);for(const e of t)e.updateGuards.forEach(e=>{o.push(pe(e,r,n))});return o.push(i),we(o)}).then(()=>{o=[];for(const e of r.matched)if(e.beforeEnter&&!n.matched.includes(e))if(Array.isArray(e.beforeEnter))for(const t of e.beforeEnter)o.push(pe(t,r,n));else o.push(pe(e.beforeEnter,r,n));return o.push(i),we(o)}).then(()=>(r.matched.forEach(e=>e.enterCallbacks={}),o=he(a,"beforeRouteEnter",r,n),o.push(i),we(o))).then(()=>{o=[];for(const e of p.list())o.push(pe(e,r,n));return o.push(i),we(o)}).catch(e=>Z(e,8)?e:Promise.reject(e))}function O(e,t,r){for(const n of o.list())n(e,t,r)}function P(e,t,r,n,o){var a=E(e,t);if(a)return a;var i=t===X,a=G?history.state:{};r&&(n||i?u.replace(e.fullPath,F({scroll:i&&a&&a.scroll},o)):u.push(e.fullPath,o)),S(v.value=e,t,r,i),$()}let a;let i,j=ue(),x=ue();function C(t,r,n){$(t);const e=x.list();return e.length?e.forEach(e=>e(t,r,n)):console.error(t),Promise.reject(t)}function $(r){i||(i=!0,a=u.listen((e,t,r)=>{let n=b(e);var o=R(n);if(o)A(F(o,{replace:!0}),n).catch(K);else{m=n;const a=v.value;G&&(e=N(a.fullPath,r.delta),o=D(),z.set(e,o)),k(n,a).catch(e=>Z(e,12)?e:Z(e,2)?(A(e.to,n).then(e=>{Z(e,20)&&!r.delta&&r.type===W.pop&&u.go(-1,!1)}).catch(K),Promise.reject()):(r.delta&&u.go(-r.delta,!1),C(e,n,a))).then(e=>{(e=e||P(n,a,!1))&&(r.delta?u.go(-r.delta,!1):r.type===W.pop&&Z(e,20)&&u.go(-1,!1)),O(n,a,e)}).catch(K)}}),j.list().forEach(([e,t])=>r?t(r):e()),j.reset())}function S(t,r,e,n){const{scrollBehavior:o}=l;if(!G||!o)return Promise.resolve();let a=!e&&(i=N(t.fullPath,0),c=z.get(i),z.delete(i),c)||(n||!e)&&history.state&&history.state.scroll||null;var i,c;return M.nextTick().then(()=>o(t,r,a)).then(e=>e&&function(t){let r;if("el"in t){let e=t.el;var n="string"==typeof e&&e.startsWith("#"),o="string"==typeof e?n?document.getElementById(e.slice(1)):document.querySelector(e):e;if(!o)return;r=(a=o,n=t,o=document.documentElement.getBoundingClientRect(),a=a.getBoundingClientRect(),{behavior:n.behavior,left:a.left-o.left-(n.left||0),top:a.top-o.top-(n.top||0)})}else r=t;var a;"scrollBehavior"in document.documentElement.style?window.scrollTo(r):window.scrollTo(null!=r.left?r.left:window.pageXOffset,null!=r.top?r.top:window.pageYOffset)}(e)).catch(e=>C(e,t,r))}const e=e=>u.go(e);let L;const q=new Set;return{currentRoute:v,addRoute:function(e,t){let r,n;return n=Q(e)?(r=c.getRecordMatcher(e),t):e,c.addRoute(n,r)},removeRoute:function(e){e=c.getRecordMatcher(e);e&&c.removeRoute(e)},hasRoute:function(e){return!!c.getRecordMatcher(e)},getRoutes:function(){return c.getRoutes().map(e=>e.record)},resolve:b,options:l,push:n,replace:function(e){return n(F(w(e),{replace:!0}))},go:e,back:()=>e(-1),forward:()=>e(1),beforeEach:f.add,beforeResolve:p.add,afterEach:o.add,onError:x.add,isReady:function(){return i&&v.value!==X?Promise.resolve():new Promise((e,t)=>{j.add([e,t])})},install(e){e.component("RouterLink",ve),e.component("RouterView",be),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{enumerable:!0,get:()=>M.unref(v)}),G&&!L&&v.value===X&&(L=!0,n(u.location).catch(e=>{}));const t={};for(let e in X)t[e]=M.computed(()=>v.value[e]);e.provide(_,this),e.provide(T,M.reactive(t)),e.provide(B,v);let r=e.unmount;q.add(e),e.unmount=function(){q.delete(e),q.size<1&&(a(),v.value=X,L=!1,i=!1),r()}}}},e.createRouterMatcher=J,e.createWebHashHistory=function(e){return(e=location.host?e||location.pathname+location.search:"").includes("#")||(e+="#"),d(e)},e.createWebHistory=d,e.isNavigationFailure=Z,e.matchedRouteKey=r,e.onBeforeRouteLeave=function(e){var t=M.inject(r,{}).value;t&&fe(t,"leaveGuards",e)},e.onBeforeRouteUpdate=function(e){var t=M.inject(r,{}).value;t&&fe(t,"updateGuards",e)},e.parseQuery=le,e.routeLocationKey=T,e.routerKey=_,e.routerViewLocationKey=B,e.stringifyQuery=se,e.useLink=de,e.useRoute=function(){return M.inject(T)},e.useRouter=function(){return M.inject(_)},e.viewDepthKey=n,Object.defineProperty(e,"__esModule",{value:!0}),e}({},Vue);