vue-router.global.js 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040
  1. /*!
  2. * vue-router v4.6.3
  3. * (c) 2025 Eduardo San Martin Morote
  4. * @license MIT
  5. */
  6. var VueRouter = (function(exports, vue) {
  7. //#region rolldown:runtime
  8. var __create = Object.create;
  9. var __defProp = Object.defineProperty;
  10. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  11. var __getOwnPropNames = Object.getOwnPropertyNames;
  12. var __getProtoOf = Object.getPrototypeOf;
  13. var __hasOwnProp = Object.prototype.hasOwnProperty;
  14. var __commonJS = (cb, mod) => function() {
  15. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  16. };
  17. var __copyProps = (to, from, except, desc) => {
  18. if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
  19. key = keys[i];
  20. if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
  21. get: ((k) => from[k]).bind(null, key),
  22. enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
  23. });
  24. }
  25. return to;
  26. };
  27. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
  28. value: mod,
  29. enumerable: true
  30. }) : target, mod));
  31. //#endregion
  32. vue = __toESM(vue);
  33. //#region src/utils/env.ts
  34. const isBrowser = typeof document !== "undefined";
  35. //#endregion
  36. //#region src/utils/index.ts
  37. /**
  38. * Allows differentiating lazy components from functional components and vue-class-component
  39. * @internal
  40. *
  41. * @param component
  42. */
  43. function isRouteComponent(component) {
  44. return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
  45. }
  46. function isESModule(obj) {
  47. return obj.__esModule || obj[Symbol.toStringTag] === "Module" || obj.default && isRouteComponent(obj.default);
  48. }
  49. const assign = Object.assign;
  50. function applyToParams(fn, params) {
  51. const newParams = {};
  52. for (const key in params) {
  53. const value = params[key];
  54. newParams[key] = isArray(value) ? value.map(fn) : fn(value);
  55. }
  56. return newParams;
  57. }
  58. const noop = () => {};
  59. /**
  60. * Typesafe alternative to Array.isArray
  61. * https://github.com/microsoft/TypeScript/pull/48228
  62. */
  63. const isArray = Array.isArray;
  64. function mergeOptions(defaults, partialOptions) {
  65. const options = {};
  66. for (const key in defaults) options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
  67. return options;
  68. }
  69. //#endregion
  70. //#region src/warning.ts
  71. function warn(msg) {
  72. const args = Array.from(arguments).slice(1);
  73. console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
  74. }
  75. //#endregion
  76. //#region src/encoding.ts
  77. /**
  78. * Encoding Rules (␣ = Space)
  79. * - Path: ␣ " < > # ? { }
  80. * - Query: ␣ " < > # & =
  81. * - Hash: ␣ " < > `
  82. *
  83. * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
  84. * defines some extra characters to be encoded. Most browsers do not encode them
  85. * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
  86. * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
  87. * plus `-._~`. This extra safety should be applied to query by patching the
  88. * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
  89. * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
  90. * into a `/` if directly typed in. The _backtick_ (`````) should also be
  91. * encoded everywhere because some browsers like FF encode it when directly
  92. * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
  93. */
  94. const HASH_RE = /#/g;
  95. const AMPERSAND_RE = /&/g;
  96. const SLASH_RE = /\//g;
  97. const EQUAL_RE = /=/g;
  98. const IM_RE = /\?/g;
  99. const PLUS_RE = /\+/g;
  100. /**
  101. * NOTE: It's not clear to me if we should encode the + symbol in queries, it
  102. * seems to be less flexible than not doing so and I can't find out the legacy
  103. * systems requiring this for regular requests like text/html. In the standard,
  104. * the encoding of the plus character is only mentioned for
  105. * application/x-www-form-urlencoded
  106. * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
  107. * leave the plus character as is in queries. To be more flexible, we allow the
  108. * plus character on the query, but it can also be manually encoded by the user.
  109. *
  110. * Resources:
  111. * - https://url.spec.whatwg.org/#urlencoded-parsing
  112. * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
  113. */
  114. const ENC_BRACKET_OPEN_RE = /%5B/g;
  115. const ENC_BRACKET_CLOSE_RE = /%5D/g;
  116. const ENC_CARET_RE = /%5E/g;
  117. const ENC_BACKTICK_RE = /%60/g;
  118. const ENC_CURLY_OPEN_RE = /%7B/g;
  119. const ENC_PIPE_RE = /%7C/g;
  120. const ENC_CURLY_CLOSE_RE = /%7D/g;
  121. const ENC_SPACE_RE = /%20/g;
  122. /**
  123. * Encode characters that need to be encoded on the path, search and hash
  124. * sections of the URL.
  125. *
  126. * @internal
  127. * @param text - string to encode
  128. * @returns encoded string
  129. */
  130. function commonEncode(text) {
  131. return text == null ? "" : encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
  132. }
  133. /**
  134. * Encode characters that need to be encoded on the hash section of the URL.
  135. *
  136. * @param text - string to encode
  137. * @returns encoded string
  138. */
  139. function encodeHash(text) {
  140. return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
  141. }
  142. /**
  143. * Encode characters that need to be encoded query values on the query
  144. * section of the URL.
  145. *
  146. * @param text - string to encode
  147. * @returns encoded string
  148. */
  149. function encodeQueryValue(text) {
  150. return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
  151. }
  152. /**
  153. * Like `encodeQueryValue` but also encodes the `=` character.
  154. *
  155. * @param text - string to encode
  156. */
  157. function encodeQueryKey(text) {
  158. return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
  159. }
  160. /**
  161. * Encode characters that need to be encoded on the path section of the URL.
  162. *
  163. * @param text - string to encode
  164. * @returns encoded string
  165. */
  166. function encodePath(text) {
  167. return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
  168. }
  169. /**
  170. * Encode characters that need to be encoded on the path section of the URL as a
  171. * param. This function encodes everything {@link encodePath} does plus the
  172. * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
  173. * string instead.
  174. *
  175. * @param text - string to encode
  176. * @returns encoded string
  177. */
  178. function encodeParam(text) {
  179. return encodePath(text).replace(SLASH_RE, "%2F");
  180. }
  181. function decode(text) {
  182. if (text == null) return null;
  183. try {
  184. return decodeURIComponent("" + text);
  185. } catch (err) {
  186. warn(`Error decoding "${text}". Using original value`);
  187. }
  188. return "" + text;
  189. }
  190. //#endregion
  191. //#region src/location.ts
  192. const TRAILING_SLASH_RE = /\/$/;
  193. const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
  194. /**
  195. * Transforms a URI into a normalized history location
  196. *
  197. * @param parseQuery
  198. * @param location - URI to normalize
  199. * @param currentLocation - current absolute location. Allows resolving relative
  200. * paths. Must start with `/`. Defaults to `/`
  201. * @returns a normalized history location
  202. */
  203. function parseURL(parseQuery$1, location$1, currentLocation = "/") {
  204. let path, query = {}, searchString = "", hash = "";
  205. const hashPos = location$1.indexOf("#");
  206. let searchPos = location$1.indexOf("?");
  207. searchPos = hashPos >= 0 && searchPos > hashPos ? -1 : searchPos;
  208. if (searchPos >= 0) {
  209. path = location$1.slice(0, searchPos);
  210. searchString = location$1.slice(searchPos, hashPos > 0 ? hashPos : location$1.length);
  211. query = parseQuery$1(searchString.slice(1));
  212. }
  213. if (hashPos >= 0) {
  214. path = path || location$1.slice(0, hashPos);
  215. hash = location$1.slice(hashPos, location$1.length);
  216. }
  217. path = resolveRelativePath(path != null ? path : location$1, currentLocation);
  218. return {
  219. fullPath: path + searchString + hash,
  220. path,
  221. query,
  222. hash: decode(hash)
  223. };
  224. }
  225. /**
  226. * Stringifies a URL object
  227. *
  228. * @param stringifyQuery
  229. * @param location
  230. */
  231. function stringifyURL(stringifyQuery$1, location$1) {
  232. const query = location$1.query ? stringifyQuery$1(location$1.query) : "";
  233. return location$1.path + (query && "?") + query + (location$1.hash || "");
  234. }
  235. /**
  236. * Strips off the base from the beginning of a location.pathname in a non-case-sensitive way.
  237. *
  238. * @param pathname - location.pathname
  239. * @param base - base to strip off
  240. */
  241. function stripBase(pathname, base) {
  242. if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase())) return pathname;
  243. return pathname.slice(base.length) || "/";
  244. }
  245. /**
  246. * Checks if two RouteLocation are equal. This means that both locations are
  247. * pointing towards the same {@link RouteRecord} and that all `params`, `query`
  248. * parameters and `hash` are the same
  249. *
  250. * @param stringifyQuery - A function that takes a query object of type LocationQueryRaw and returns a string representation of it.
  251. * @param a - first {@link RouteLocation}
  252. * @param b - second {@link RouteLocation}
  253. */
  254. function isSameRouteLocation(stringifyQuery$1, a, b) {
  255. const aLastIndex = a.matched.length - 1;
  256. const bLastIndex = b.matched.length - 1;
  257. return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery$1(a.query) === stringifyQuery$1(b.query) && a.hash === b.hash;
  258. }
  259. /**
  260. * Check if two `RouteRecords` are equal. Takes into account aliases: they are
  261. * considered equal to the `RouteRecord` they are aliasing.
  262. *
  263. * @param a - first {@link RouteRecord}
  264. * @param b - second {@link RouteRecord}
  265. */
  266. function isSameRouteRecord(a, b) {
  267. return (a.aliasOf || a) === (b.aliasOf || b);
  268. }
  269. function isSameRouteLocationParams(a, b) {
  270. if (Object.keys(a).length !== Object.keys(b).length) return false;
  271. for (const key in a) if (!isSameRouteLocationParamsValue(a[key], b[key])) return false;
  272. return true;
  273. }
  274. function isSameRouteLocationParamsValue(a, b) {
  275. return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a === b;
  276. }
  277. /**
  278. * Check if two arrays are the same or if an array with one single entry is the
  279. * same as another primitive value. Used to check query and parameters
  280. *
  281. * @param a - array of values
  282. * @param b - array of values or a single value
  283. */
  284. function isEquivalentArray(a, b) {
  285. return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
  286. }
  287. /**
  288. * Resolves a relative path that starts with `.`.
  289. *
  290. * @param to - path location we are resolving
  291. * @param from - currentLocation.path, should start with `/`
  292. */
  293. function resolveRelativePath(to, from) {
  294. if (to.startsWith("/")) return to;
  295. if (!from.startsWith("/")) {
  296. warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to}" from "${from}". It should look like "/${from}".`);
  297. return to;
  298. }
  299. if (!to) return from;
  300. const fromSegments = from.split("/");
  301. const toSegments = to.split("/");
  302. const lastToSegment = toSegments[toSegments.length - 1];
  303. if (lastToSegment === ".." || lastToSegment === ".") toSegments.push("");
  304. let position = fromSegments.length - 1;
  305. let toPosition;
  306. let segment;
  307. for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
  308. segment = toSegments[toPosition];
  309. if (segment === ".") continue;
  310. if (segment === "..") {
  311. if (position > 1) position--;
  312. } else break;
  313. }
  314. return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
  315. }
  316. /**
  317. * Initial route location where the router is. Can be used in navigation guards
  318. * to differentiate the initial navigation.
  319. *
  320. * @example
  321. * ```js
  322. * import { START_LOCATION } from 'vue-router'
  323. *
  324. * router.beforeEach((to, from) => {
  325. * if (from === START_LOCATION) {
  326. * // initial navigation
  327. * }
  328. * })
  329. * ```
  330. */
  331. const START_LOCATION_NORMALIZED = {
  332. path: "/",
  333. name: void 0,
  334. params: {},
  335. query: {},
  336. hash: "",
  337. fullPath: "/",
  338. matched: [],
  339. meta: {},
  340. redirectedFrom: void 0
  341. };
  342. //#endregion
  343. //#region src/history/common.ts
  344. let NavigationType = /* @__PURE__ */ function(NavigationType$1) {
  345. NavigationType$1["pop"] = "pop";
  346. NavigationType$1["push"] = "push";
  347. return NavigationType$1;
  348. }({});
  349. let NavigationDirection = /* @__PURE__ */ function(NavigationDirection$1) {
  350. NavigationDirection$1["back"] = "back";
  351. NavigationDirection$1["forward"] = "forward";
  352. NavigationDirection$1["unknown"] = "";
  353. return NavigationDirection$1;
  354. }({});
  355. /**
  356. * Starting location for Histories
  357. */
  358. const START = "";
  359. /**
  360. * Normalizes a base by removing any trailing slash and reading the base tag if
  361. * present.
  362. *
  363. * @param base - base to normalize
  364. */
  365. function normalizeBase(base) {
  366. if (!base) if (isBrowser) {
  367. const baseEl = document.querySelector("base");
  368. base = baseEl && baseEl.getAttribute("href") || "/";
  369. base = base.replace(/^\w+:\/\/[^\/]+/, "");
  370. } else base = "/";
  371. if (base[0] !== "/" && base[0] !== "#") base = "/" + base;
  372. return removeTrailingSlash(base);
  373. }
  374. const BEFORE_HASH_RE = /^[^#]+#/;
  375. function createHref(base, location$1) {
  376. return base.replace(BEFORE_HASH_RE, "#") + location$1;
  377. }
  378. //#endregion
  379. //#region src/scrollBehavior.ts
  380. function getElementPosition(el, offset) {
  381. const docRect = document.documentElement.getBoundingClientRect();
  382. const elRect = el.getBoundingClientRect();
  383. return {
  384. behavior: offset.behavior,
  385. left: elRect.left - docRect.left - (offset.left || 0),
  386. top: elRect.top - docRect.top - (offset.top || 0)
  387. };
  388. }
  389. const computeScrollPosition = () => ({
  390. left: window.scrollX,
  391. top: window.scrollY
  392. });
  393. function scrollToPosition(position) {
  394. let scrollToOptions;
  395. if ("el" in position) {
  396. const positionEl = position.el;
  397. const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
  398. /**
  399. * `id`s can accept pretty much any characters, including CSS combinators
  400. * like `>` or `~`. It's still possible to retrieve elements using
  401. * `document.getElementById('~')` but it needs to be escaped when using
  402. * `document.querySelector('#\\~')` for it to be valid. The only
  403. * requirements for `id`s are them to be unique on the page and to not be
  404. * empty (`id=""`). Because of that, when passing an id selector, it should
  405. * be properly escaped for it to work with `querySelector`. We could check
  406. * for the id selector to be simple (no CSS combinators `+ >~`) but that
  407. * would make things inconsistent since they are valid characters for an
  408. * `id` but would need to be escaped when using `querySelector`, breaking
  409. * their usage and ending up in no selector returned. Selectors need to be
  410. * escaped:
  411. *
  412. * - `#1-thing` becomes `#\31 -thing`
  413. * - `#with~symbols` becomes `#with\\~symbols`
  414. *
  415. * - More information about the topic can be found at
  416. * https://mathiasbynens.be/notes/html5-id-class.
  417. * - Practical example: https://mathiasbynens.be/demo/html5-id
  418. */
  419. if (typeof position.el === "string") {
  420. if (!isIdSelector || !document.getElementById(position.el.slice(1))) try {
  421. const foundEl = document.querySelector(position.el);
  422. if (isIdSelector && foundEl) {
  423. warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
  424. return;
  425. }
  426. } catch (err) {
  427. warn(`The selector "${position.el}" is invalid. If you are using an id selector, make sure to escape it. You can find more information about escaping characters in selectors at https://mathiasbynens.be/notes/css-escapes or use CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape).`);
  428. return;
  429. }
  430. }
  431. const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
  432. if (!el) {
  433. warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
  434. return;
  435. }
  436. scrollToOptions = getElementPosition(el, position);
  437. } else scrollToOptions = position;
  438. if ("scrollBehavior" in document.documentElement.style) window.scrollTo(scrollToOptions);
  439. else window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
  440. }
  441. function getScrollKey(path, delta) {
  442. return (history.state ? history.state.position - delta : -1) + path;
  443. }
  444. const scrollPositions = /* @__PURE__ */ new Map();
  445. function saveScrollPosition(key, scrollPosition) {
  446. scrollPositions.set(key, scrollPosition);
  447. }
  448. function getSavedScrollPosition(key) {
  449. const scroll = scrollPositions.get(key);
  450. scrollPositions.delete(key);
  451. return scroll;
  452. }
  453. /**
  454. * ScrollBehavior instance used by the router to compute and restore the scroll
  455. * position when navigating.
  456. */
  457. //#endregion
  458. //#region src/history/html5.ts
  459. let createBaseLocation = () => location.protocol + "//" + location.host;
  460. /**
  461. * Creates a normalized history location from a window.location object
  462. * @param base - The base path
  463. * @param location - The window.location object
  464. */
  465. function createCurrentLocation(base, location$1) {
  466. const { pathname, search, hash } = location$1;
  467. const hashPos = base.indexOf("#");
  468. if (hashPos > -1) {
  469. let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
  470. let pathFromHash = hash.slice(slicePos);
  471. if (pathFromHash[0] !== "/") pathFromHash = "/" + pathFromHash;
  472. return stripBase(pathFromHash, "");
  473. }
  474. return stripBase(pathname, base) + search + hash;
  475. }
  476. function useHistoryListeners(base, historyState, currentLocation, replace) {
  477. let listeners = [];
  478. let teardowns = [];
  479. let pauseState = null;
  480. const popStateHandler = ({ state }) => {
  481. const to = createCurrentLocation(base, location);
  482. const from = currentLocation.value;
  483. const fromState = historyState.value;
  484. let delta = 0;
  485. if (state) {
  486. currentLocation.value = to;
  487. historyState.value = state;
  488. if (pauseState && pauseState === from) {
  489. pauseState = null;
  490. return;
  491. }
  492. delta = fromState ? state.position - fromState.position : 0;
  493. } else replace(to);
  494. listeners.forEach((listener) => {
  495. listener(currentLocation.value, from, {
  496. delta,
  497. type: NavigationType.pop,
  498. direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
  499. });
  500. });
  501. };
  502. function pauseListeners() {
  503. pauseState = currentLocation.value;
  504. }
  505. function listen(callback) {
  506. listeners.push(callback);
  507. const teardown = () => {
  508. const index = listeners.indexOf(callback);
  509. if (index > -1) listeners.splice(index, 1);
  510. };
  511. teardowns.push(teardown);
  512. return teardown;
  513. }
  514. function beforeUnloadListener() {
  515. if (document.visibilityState === "hidden") {
  516. const { history: history$1 } = window;
  517. if (!history$1.state) return;
  518. history$1.replaceState(assign({}, history$1.state, { scroll: computeScrollPosition() }), "");
  519. }
  520. }
  521. function destroy() {
  522. for (const teardown of teardowns) teardown();
  523. teardowns = [];
  524. window.removeEventListener("popstate", popStateHandler);
  525. window.removeEventListener("pagehide", beforeUnloadListener);
  526. document.removeEventListener("visibilitychange", beforeUnloadListener);
  527. }
  528. window.addEventListener("popstate", popStateHandler);
  529. window.addEventListener("pagehide", beforeUnloadListener);
  530. document.addEventListener("visibilitychange", beforeUnloadListener);
  531. return {
  532. pauseListeners,
  533. listen,
  534. destroy
  535. };
  536. }
  537. /**
  538. * Creates a state object
  539. */
  540. function buildState(back, current, forward, replaced = false, computeScroll = false) {
  541. return {
  542. back,
  543. current,
  544. forward,
  545. replaced,
  546. position: window.history.length,
  547. scroll: computeScroll ? computeScrollPosition() : null
  548. };
  549. }
  550. function useHistoryStateNavigation(base) {
  551. const { history: history$1, location: location$1 } = window;
  552. const currentLocation = { value: createCurrentLocation(base, location$1) };
  553. const historyState = { value: history$1.state };
  554. if (!historyState.value) changeLocation(currentLocation.value, {
  555. back: null,
  556. current: currentLocation.value,
  557. forward: null,
  558. position: history$1.length - 1,
  559. replaced: true,
  560. scroll: null
  561. }, true);
  562. function changeLocation(to, state, replace$1) {
  563. /**
  564. * if a base tag is provided, and we are on a normal domain, we have to
  565. * respect the provided `base` attribute because pushState() will use it and
  566. * potentially erase anything before the `#` like at
  567. * https://github.com/vuejs/router/issues/685 where a base of
  568. * `/folder/#` but a base of `/` would erase the `/folder/` section. If
  569. * there is no host, the `<base>` tag makes no sense and if there isn't a
  570. * base tag we can just use everything after the `#`.
  571. */
  572. const hashIndex = base.indexOf("#");
  573. const url = hashIndex > -1 ? (location$1.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
  574. try {
  575. history$1[replace$1 ? "replaceState" : "pushState"](state, "", url);
  576. historyState.value = state;
  577. } catch (err) {
  578. warn("Error with push/replace State", err);
  579. location$1[replace$1 ? "replace" : "assign"](url);
  580. }
  581. }
  582. function replace(to, data) {
  583. changeLocation(to, assign({}, history$1.state, buildState(historyState.value.back, to, historyState.value.forward, true), data, { position: historyState.value.position }), true);
  584. currentLocation.value = to;
  585. }
  586. function push(to, data) {
  587. const currentState = assign({}, historyState.value, history$1.state, {
  588. forward: to,
  589. scroll: computeScrollPosition()
  590. });
  591. if (!history$1.state) warn("history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:\n\nhistory.replaceState(history.state, '', url)\n\nYou can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state");
  592. changeLocation(currentState.current, currentState, true);
  593. changeLocation(to, assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data), false);
  594. currentLocation.value = to;
  595. }
  596. return {
  597. location: currentLocation,
  598. state: historyState,
  599. push,
  600. replace
  601. };
  602. }
  603. /**
  604. * Creates an HTML5 history. Most common history for single page applications.
  605. *
  606. * @param base -
  607. */
  608. function createWebHistory(base) {
  609. base = normalizeBase(base);
  610. const historyNavigation = useHistoryStateNavigation(base);
  611. const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
  612. function go(delta, triggerListeners = true) {
  613. if (!triggerListeners) historyListeners.pauseListeners();
  614. history.go(delta);
  615. }
  616. const routerHistory = assign({
  617. location: "",
  618. base,
  619. go,
  620. createHref: createHref.bind(null, base)
  621. }, historyNavigation, historyListeners);
  622. Object.defineProperty(routerHistory, "location", {
  623. enumerable: true,
  624. get: () => historyNavigation.location.value
  625. });
  626. Object.defineProperty(routerHistory, "state", {
  627. enumerable: true,
  628. get: () => historyNavigation.state.value
  629. });
  630. return routerHistory;
  631. }
  632. //#endregion
  633. //#region src/history/memory.ts
  634. /**
  635. * Creates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere.
  636. * It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`.
  637. *
  638. * @param base - Base applied to all urls, defaults to '/'
  639. * @returns a history object that can be passed to the router constructor
  640. */
  641. function createMemoryHistory(base = "") {
  642. let listeners = [];
  643. let queue = [[START, {}]];
  644. let position = 0;
  645. base = normalizeBase(base);
  646. function setLocation(location$1, state = {}) {
  647. position++;
  648. if (position !== queue.length) queue.splice(position);
  649. queue.push([location$1, state]);
  650. }
  651. function triggerListeners(to, from, { direction, delta }) {
  652. const info = {
  653. direction,
  654. delta,
  655. type: NavigationType.pop
  656. };
  657. for (const callback of listeners) callback(to, from, info);
  658. }
  659. const routerHistory = {
  660. location: START,
  661. state: {},
  662. base,
  663. createHref: createHref.bind(null, base),
  664. replace(to, state) {
  665. queue.splice(position--, 1);
  666. setLocation(to, state);
  667. },
  668. push(to, state) {
  669. setLocation(to, state);
  670. },
  671. listen(callback) {
  672. listeners.push(callback);
  673. return () => {
  674. const index = listeners.indexOf(callback);
  675. if (index > -1) listeners.splice(index, 1);
  676. };
  677. },
  678. destroy() {
  679. listeners = [];
  680. queue = [[START, {}]];
  681. position = 0;
  682. },
  683. go(delta, shouldTrigger = true) {
  684. const from = this.location;
  685. const direction = delta < 0 ? NavigationDirection.back : NavigationDirection.forward;
  686. position = Math.max(0, Math.min(position + delta, queue.length - 1));
  687. if (shouldTrigger) triggerListeners(this.location, from, {
  688. direction,
  689. delta
  690. });
  691. }
  692. };
  693. Object.defineProperty(routerHistory, "location", {
  694. enumerable: true,
  695. get: () => queue[position][0]
  696. });
  697. Object.defineProperty(routerHistory, "state", {
  698. enumerable: true,
  699. get: () => queue[position][1]
  700. });
  701. return routerHistory;
  702. }
  703. //#endregion
  704. //#region src/history/hash.ts
  705. /**
  706. * Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
  707. * handle any URL is not possible.
  708. *
  709. * @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
  710. * in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
  711. * calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
  712. * after the `#`).
  713. *
  714. * @example
  715. * ```js
  716. * // at https://example.com/folder
  717. * createWebHashHistory() // gives a url of `https://example.com/folder#`
  718. * createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
  719. * // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
  720. * createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
  721. * // you should avoid doing this because it changes the original url and breaks copying urls
  722. * createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
  723. *
  724. * // at file:///usr/etc/folder/index.html
  725. * // for locations with no `host`, the base is ignored
  726. * createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
  727. * ```
  728. */
  729. function createWebHashHistory(base) {
  730. base = location.host ? base || location.pathname + location.search : "";
  731. if (!base.includes("#")) base += "#";
  732. if (!base.endsWith("#/") && !base.endsWith("#")) warn(`A hash base must end with a "#":\n"${base}" should be "${base.replace(/#.*$/, "#")}".`);
  733. return createWebHistory(base);
  734. }
  735. //#endregion
  736. //#region src/types/typeGuards.ts
  737. function isRouteLocation(route) {
  738. return typeof route === "string" || route && typeof route === "object";
  739. }
  740. function isRouteName(name) {
  741. return typeof name === "string" || typeof name === "symbol";
  742. }
  743. //#endregion
  744. //#region src/errors.ts
  745. /**
  746. * Flags so we can combine them when checking for multiple errors. This is the internal version of
  747. * {@link NavigationFailureType}.
  748. *
  749. * @internal
  750. */
  751. let ErrorTypes = /* @__PURE__ */ function(ErrorTypes$1) {
  752. ErrorTypes$1[ErrorTypes$1["MATCHER_NOT_FOUND"] = 1] = "MATCHER_NOT_FOUND";
  753. ErrorTypes$1[ErrorTypes$1["NAVIGATION_GUARD_REDIRECT"] = 2] = "NAVIGATION_GUARD_REDIRECT";
  754. ErrorTypes$1[ErrorTypes$1["NAVIGATION_ABORTED"] = 4] = "NAVIGATION_ABORTED";
  755. ErrorTypes$1[ErrorTypes$1["NAVIGATION_CANCELLED"] = 8] = "NAVIGATION_CANCELLED";
  756. ErrorTypes$1[ErrorTypes$1["NAVIGATION_DUPLICATED"] = 16] = "NAVIGATION_DUPLICATED";
  757. return ErrorTypes$1;
  758. }({});
  759. const NavigationFailureSymbol = Symbol("navigation failure");
  760. /**
  761. * Enumeration with all possible types for navigation failures. Can be passed to
  762. * {@link isNavigationFailure} to check for specific failures.
  763. */
  764. let NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType$1) {
  765. /**
  766. * An aborted navigation is a navigation that failed because a navigation
  767. * guard returned `false` or called `next(false)`
  768. */
  769. NavigationFailureType$1[NavigationFailureType$1["aborted"] = 4] = "aborted";
  770. /**
  771. * A cancelled navigation is a navigation that failed because a more recent
  772. * navigation finished started (not necessarily finished).
  773. */
  774. NavigationFailureType$1[NavigationFailureType$1["cancelled"] = 8] = "cancelled";
  775. /**
  776. * A duplicated navigation is a navigation that failed because it was
  777. * initiated while already being at the exact same location.
  778. */
  779. NavigationFailureType$1[NavigationFailureType$1["duplicated"] = 16] = "duplicated";
  780. return NavigationFailureType$1;
  781. }({});
  782. const ErrorTypeMessages = {
  783. [ErrorTypes.MATCHER_NOT_FOUND]({ location: location$1, currentLocation }) {
  784. return `No match for\n ${JSON.stringify(location$1)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
  785. },
  786. [ErrorTypes.NAVIGATION_GUARD_REDIRECT]({ from, to }) {
  787. return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
  788. },
  789. [ErrorTypes.NAVIGATION_ABORTED]({ from, to }) {
  790. return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
  791. },
  792. [ErrorTypes.NAVIGATION_CANCELLED]({ from, to }) {
  793. return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
  794. },
  795. [ErrorTypes.NAVIGATION_DUPLICATED]({ from, to }) {
  796. return `Avoided redundant navigation to current location: "${from.fullPath}".`;
  797. }
  798. };
  799. /**
  800. * Creates a typed NavigationFailure object.
  801. * @internal
  802. * @param type - NavigationFailureType
  803. * @param params - { from, to }
  804. */
  805. function createRouterError(type, params) {
  806. return assign(new Error(ErrorTypeMessages[type](params)), {
  807. type,
  808. [NavigationFailureSymbol]: true
  809. }, params);
  810. }
  811. function isNavigationFailure(error, type) {
  812. return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
  813. }
  814. const propertiesToLog = [
  815. "params",
  816. "query",
  817. "hash"
  818. ];
  819. function stringifyRoute(to) {
  820. if (typeof to === "string") return to;
  821. if (to.path != null) return to.path;
  822. const location$1 = {};
  823. for (const key of propertiesToLog) if (key in to) location$1[key] = to[key];
  824. return JSON.stringify(location$1, null, 2);
  825. }
  826. //#endregion
  827. //#region src/matcher/pathTokenizer.ts
  828. let TokenType = /* @__PURE__ */ function(TokenType$1) {
  829. TokenType$1[TokenType$1["Static"] = 0] = "Static";
  830. TokenType$1[TokenType$1["Param"] = 1] = "Param";
  831. TokenType$1[TokenType$1["Group"] = 2] = "Group";
  832. return TokenType$1;
  833. }({});
  834. var TokenizerState = /* @__PURE__ */ function(TokenizerState$1) {
  835. TokenizerState$1[TokenizerState$1["Static"] = 0] = "Static";
  836. TokenizerState$1[TokenizerState$1["Param"] = 1] = "Param";
  837. TokenizerState$1[TokenizerState$1["ParamRegExp"] = 2] = "ParamRegExp";
  838. TokenizerState$1[TokenizerState$1["ParamRegExpEnd"] = 3] = "ParamRegExpEnd";
  839. TokenizerState$1[TokenizerState$1["EscapeNext"] = 4] = "EscapeNext";
  840. return TokenizerState$1;
  841. }(TokenizerState || {});
  842. const ROOT_TOKEN = {
  843. type: TokenType.Static,
  844. value: ""
  845. };
  846. const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
  847. function tokenizePath(path) {
  848. if (!path) return [[]];
  849. if (path === "/") return [[ROOT_TOKEN]];
  850. if (!path.startsWith("/")) throw new Error(`Route paths should start with a "/": "${path}" should be "/${path}".`);
  851. function crash(message) {
  852. throw new Error(`ERR (${state})/"${buffer}": ${message}`);
  853. }
  854. let state = TokenizerState.Static;
  855. let previousState = state;
  856. const tokens = [];
  857. let segment;
  858. function finalizeSegment() {
  859. if (segment) tokens.push(segment);
  860. segment = [];
  861. }
  862. let i = 0;
  863. let char;
  864. let buffer = "";
  865. let customRe = "";
  866. function consumeBuffer() {
  867. if (!buffer) return;
  868. if (state === TokenizerState.Static) segment.push({
  869. type: TokenType.Static,
  870. value: buffer
  871. });
  872. else if (state === TokenizerState.Param || state === TokenizerState.ParamRegExp || state === TokenizerState.ParamRegExpEnd) {
  873. if (segment.length > 1 && (char === "*" || char === "+")) crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
  874. segment.push({
  875. type: TokenType.Param,
  876. value: buffer,
  877. regexp: customRe,
  878. repeatable: char === "*" || char === "+",
  879. optional: char === "*" || char === "?"
  880. });
  881. } else crash("Invalid state to consume buffer");
  882. buffer = "";
  883. }
  884. function addCharToBuffer() {
  885. buffer += char;
  886. }
  887. while (i < path.length) {
  888. char = path[i++];
  889. if (char === "\\" && state !== TokenizerState.ParamRegExp) {
  890. previousState = state;
  891. state = TokenizerState.EscapeNext;
  892. continue;
  893. }
  894. switch (state) {
  895. case TokenizerState.Static:
  896. if (char === "/") {
  897. if (buffer) consumeBuffer();
  898. finalizeSegment();
  899. } else if (char === ":") {
  900. consumeBuffer();
  901. state = TokenizerState.Param;
  902. } else addCharToBuffer();
  903. break;
  904. case TokenizerState.EscapeNext:
  905. addCharToBuffer();
  906. state = previousState;
  907. break;
  908. case TokenizerState.Param:
  909. if (char === "(") state = TokenizerState.ParamRegExp;
  910. else if (VALID_PARAM_RE.test(char)) addCharToBuffer();
  911. else {
  912. consumeBuffer();
  913. state = TokenizerState.Static;
  914. if (char !== "*" && char !== "?" && char !== "+") i--;
  915. }
  916. break;
  917. case TokenizerState.ParamRegExp:
  918. if (char === ")") if (customRe[customRe.length - 1] == "\\") customRe = customRe.slice(0, -1) + char;
  919. else state = TokenizerState.ParamRegExpEnd;
  920. else customRe += char;
  921. break;
  922. case TokenizerState.ParamRegExpEnd:
  923. consumeBuffer();
  924. state = TokenizerState.Static;
  925. if (char !== "*" && char !== "?" && char !== "+") i--;
  926. customRe = "";
  927. break;
  928. default:
  929. crash("Unknown state");
  930. break;
  931. }
  932. }
  933. if (state === TokenizerState.ParamRegExp) crash(`Unfinished custom RegExp for param "${buffer}"`);
  934. consumeBuffer();
  935. finalizeSegment();
  936. return tokens;
  937. }
  938. //#endregion
  939. //#region src/matcher/pathParserRanker.ts
  940. const BASE_PARAM_PATTERN = "[^/]+?";
  941. const BASE_PATH_PARSER_OPTIONS = {
  942. sensitive: false,
  943. strict: false,
  944. start: true,
  945. end: true
  946. };
  947. var PathScore = /* @__PURE__ */ function(PathScore$1) {
  948. PathScore$1[PathScore$1["_multiplier"] = 10] = "_multiplier";
  949. PathScore$1[PathScore$1["Root"] = 90] = "Root";
  950. PathScore$1[PathScore$1["Segment"] = 40] = "Segment";
  951. PathScore$1[PathScore$1["SubSegment"] = 30] = "SubSegment";
  952. PathScore$1[PathScore$1["Static"] = 40] = "Static";
  953. PathScore$1[PathScore$1["Dynamic"] = 20] = "Dynamic";
  954. PathScore$1[PathScore$1["BonusCustomRegExp"] = 10] = "BonusCustomRegExp";
  955. PathScore$1[PathScore$1["BonusWildcard"] = -50] = "BonusWildcard";
  956. PathScore$1[PathScore$1["BonusRepeatable"] = -20] = "BonusRepeatable";
  957. PathScore$1[PathScore$1["BonusOptional"] = -8] = "BonusOptional";
  958. PathScore$1[PathScore$1["BonusStrict"] = .7000000000000001] = "BonusStrict";
  959. PathScore$1[PathScore$1["BonusCaseSensitive"] = .25] = "BonusCaseSensitive";
  960. return PathScore$1;
  961. }(PathScore || {});
  962. const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
  963. /**
  964. * Creates a path parser from an array of Segments (a segment is an array of Tokens)
  965. *
  966. * @param segments - array of segments returned by tokenizePath
  967. * @param extraOptions - optional options for the regexp
  968. * @returns a PathParser
  969. */
  970. function tokensToParser(segments, extraOptions) {
  971. const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
  972. const score = [];
  973. let pattern = options.start ? "^" : "";
  974. const keys = [];
  975. for (const segment of segments) {
  976. const segmentScores = segment.length ? [] : [PathScore.Root];
  977. if (options.strict && !segment.length) pattern += "/";
  978. for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
  979. const token = segment[tokenIndex];
  980. let subSegmentScore = PathScore.Segment + (options.sensitive ? PathScore.BonusCaseSensitive : 0);
  981. if (token.type === TokenType.Static) {
  982. if (!tokenIndex) pattern += "/";
  983. pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
  984. subSegmentScore += PathScore.Static;
  985. } else if (token.type === TokenType.Param) {
  986. const { value, repeatable, optional, regexp } = token;
  987. keys.push({
  988. name: value,
  989. repeatable,
  990. optional
  991. });
  992. const re$1 = regexp ? regexp : BASE_PARAM_PATTERN;
  993. if (re$1 !== BASE_PARAM_PATTERN) {
  994. subSegmentScore += PathScore.BonusCustomRegExp;
  995. try {
  996. `${re$1}`;
  997. } catch (err) {
  998. throw new Error(`Invalid custom RegExp for param "${value}" (${re$1}): ` + err.message);
  999. }
  1000. }
  1001. let subPattern = repeatable ? `((?:${re$1})(?:/(?:${re$1}))*)` : `(${re$1})`;
  1002. if (!tokenIndex) subPattern = optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
  1003. if (optional) subPattern += "?";
  1004. pattern += subPattern;
  1005. subSegmentScore += PathScore.Dynamic;
  1006. if (optional) subSegmentScore += PathScore.BonusOptional;
  1007. if (repeatable) subSegmentScore += PathScore.BonusRepeatable;
  1008. if (re$1 === ".*") subSegmentScore += PathScore.BonusWildcard;
  1009. }
  1010. segmentScores.push(subSegmentScore);
  1011. }
  1012. score.push(segmentScores);
  1013. }
  1014. if (options.strict && options.end) {
  1015. const i = score.length - 1;
  1016. score[i][score[i].length - 1] += PathScore.BonusStrict;
  1017. }
  1018. if (!options.strict) pattern += "/?";
  1019. if (options.end) pattern += "$";
  1020. else if (options.strict && !pattern.endsWith("/")) pattern += "(?:/|$)";
  1021. const re = new RegExp(pattern, options.sensitive ? "" : "i");
  1022. function parse(path) {
  1023. const match = path.match(re);
  1024. const params = {};
  1025. if (!match) return null;
  1026. for (let i = 1; i < match.length; i++) {
  1027. const value = match[i] || "";
  1028. const key = keys[i - 1];
  1029. params[key.name] = value && key.repeatable ? value.split("/") : value;
  1030. }
  1031. return params;
  1032. }
  1033. function stringify(params) {
  1034. let path = "";
  1035. let avoidDuplicatedSlash = false;
  1036. for (const segment of segments) {
  1037. if (!avoidDuplicatedSlash || !path.endsWith("/")) path += "/";
  1038. avoidDuplicatedSlash = false;
  1039. for (const token of segment) if (token.type === TokenType.Static) path += token.value;
  1040. else if (token.type === TokenType.Param) {
  1041. const { value, repeatable, optional } = token;
  1042. const param = value in params ? params[value] : "";
  1043. if (isArray(param) && !repeatable) throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
  1044. const text = isArray(param) ? param.join("/") : param;
  1045. if (!text) if (optional) {
  1046. if (segment.length < 2) if (path.endsWith("/")) path = path.slice(0, -1);
  1047. else avoidDuplicatedSlash = true;
  1048. } else throw new Error(`Missing required param "${value}"`);
  1049. path += text;
  1050. }
  1051. }
  1052. return path || "/";
  1053. }
  1054. return {
  1055. re,
  1056. score,
  1057. keys,
  1058. parse,
  1059. stringify
  1060. };
  1061. }
  1062. /**
  1063. * Compares an array of numbers as used in PathParser.score and returns a
  1064. * number. This function can be used to `sort` an array
  1065. *
  1066. * @param a - first array of numbers
  1067. * @param b - second array of numbers
  1068. * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
  1069. * should be sorted first
  1070. */
  1071. function compareScoreArray(a, b) {
  1072. let i = 0;
  1073. while (i < a.length && i < b.length) {
  1074. const diff = b[i] - a[i];
  1075. if (diff) return diff;
  1076. i++;
  1077. }
  1078. if (a.length < b.length) return a.length === 1 && a[0] === PathScore.Static + PathScore.Segment ? -1 : 1;
  1079. else if (a.length > b.length) return b.length === 1 && b[0] === PathScore.Static + PathScore.Segment ? 1 : -1;
  1080. return 0;
  1081. }
  1082. /**
  1083. * Compare function that can be used with `sort` to sort an array of PathParser
  1084. *
  1085. * @param a - first PathParser
  1086. * @param b - second PathParser
  1087. * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
  1088. */
  1089. function comparePathParserScore(a, b) {
  1090. let i = 0;
  1091. const aScore = a.score;
  1092. const bScore = b.score;
  1093. while (i < aScore.length && i < bScore.length) {
  1094. const comp = compareScoreArray(aScore[i], bScore[i]);
  1095. if (comp) return comp;
  1096. i++;
  1097. }
  1098. if (Math.abs(bScore.length - aScore.length) === 1) {
  1099. if (isLastScoreNegative(aScore)) return 1;
  1100. if (isLastScoreNegative(bScore)) return -1;
  1101. }
  1102. return bScore.length - aScore.length;
  1103. }
  1104. /**
  1105. * This allows detecting splats at the end of a path: /home/:id(.*)*
  1106. *
  1107. * @param score - score to check
  1108. * @returns true if the last entry is negative
  1109. */
  1110. function isLastScoreNegative(score) {
  1111. const last = score[score.length - 1];
  1112. return score.length > 0 && last[last.length - 1] < 0;
  1113. }
  1114. const PATH_PARSER_OPTIONS_DEFAULTS = {
  1115. strict: false,
  1116. end: true,
  1117. sensitive: false
  1118. };
  1119. //#endregion
  1120. //#region src/matcher/pathMatcher.ts
  1121. function createRouteRecordMatcher(record, parent, options) {
  1122. const parser = tokensToParser(tokenizePath(record.path), options);
  1123. {
  1124. const existingKeys = /* @__PURE__ */ new Set();
  1125. for (const key of parser.keys) {
  1126. if (existingKeys.has(key.name)) warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
  1127. existingKeys.add(key.name);
  1128. }
  1129. }
  1130. const matcher = assign(parser, {
  1131. record,
  1132. parent,
  1133. children: [],
  1134. alias: []
  1135. });
  1136. if (parent) {
  1137. if (!matcher.record.aliasOf === !parent.record.aliasOf) parent.children.push(matcher);
  1138. }
  1139. return matcher;
  1140. }
  1141. //#endregion
  1142. //#region src/matcher/index.ts
  1143. /**
  1144. * Creates a Router Matcher.
  1145. *
  1146. * @internal
  1147. * @param routes - array of initial routes
  1148. * @param globalOptions - global route options
  1149. */
  1150. function createRouterMatcher(routes, globalOptions) {
  1151. const matchers = [];
  1152. const matcherMap = /* @__PURE__ */ new Map();
  1153. globalOptions = mergeOptions(PATH_PARSER_OPTIONS_DEFAULTS, globalOptions);
  1154. function getRecordMatcher(name) {
  1155. return matcherMap.get(name);
  1156. }
  1157. function addRoute(record, parent, originalRecord) {
  1158. const isRootAdd = !originalRecord;
  1159. const mainNormalizedRecord = normalizeRouteRecord(record);
  1160. checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
  1161. mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
  1162. const options = mergeOptions(globalOptions, record);
  1163. const normalizedRecords = [mainNormalizedRecord];
  1164. if ("alias" in record) {
  1165. const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
  1166. for (const alias of aliases) normalizedRecords.push(normalizeRouteRecord(assign({}, mainNormalizedRecord, {
  1167. components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
  1168. path: alias,
  1169. aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
  1170. })));
  1171. }
  1172. let matcher;
  1173. let originalMatcher;
  1174. for (const normalizedRecord of normalizedRecords) {
  1175. const { path } = normalizedRecord;
  1176. if (parent && path[0] !== "/") {
  1177. const parentPath = parent.record.path;
  1178. const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
  1179. normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
  1180. }
  1181. if (normalizedRecord.path === "*") throw new Error("Catch all routes (\"*\") must now be defined using a param with a custom regexp.\nSee more at https://router.vuejs.org/guide/migration/#Removed-star-or-catch-all-routes.");
  1182. matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
  1183. if (parent && path[0] === "/") checkMissingParamsInAbsolutePath(matcher, parent);
  1184. if (originalRecord) {
  1185. originalRecord.alias.push(matcher);
  1186. checkSameParams(originalRecord, matcher);
  1187. } else {
  1188. originalMatcher = originalMatcher || matcher;
  1189. if (originalMatcher !== matcher) originalMatcher.alias.push(matcher);
  1190. if (isRootAdd && record.name && !isAliasRecord(matcher)) {
  1191. checkSameNameAsAncestor(record, parent);
  1192. removeRoute(record.name);
  1193. }
  1194. }
  1195. if (isMatchable(matcher)) insertMatcher(matcher);
  1196. if (mainNormalizedRecord.children) {
  1197. const children = mainNormalizedRecord.children;
  1198. for (let i = 0; i < children.length; i++) addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
  1199. }
  1200. originalRecord = originalRecord || matcher;
  1201. }
  1202. return originalMatcher ? () => {
  1203. removeRoute(originalMatcher);
  1204. } : noop;
  1205. }
  1206. function removeRoute(matcherRef) {
  1207. if (isRouteName(matcherRef)) {
  1208. const matcher = matcherMap.get(matcherRef);
  1209. if (matcher) {
  1210. matcherMap.delete(matcherRef);
  1211. matchers.splice(matchers.indexOf(matcher), 1);
  1212. matcher.children.forEach(removeRoute);
  1213. matcher.alias.forEach(removeRoute);
  1214. }
  1215. } else {
  1216. const index = matchers.indexOf(matcherRef);
  1217. if (index > -1) {
  1218. matchers.splice(index, 1);
  1219. if (matcherRef.record.name) matcherMap.delete(matcherRef.record.name);
  1220. matcherRef.children.forEach(removeRoute);
  1221. matcherRef.alias.forEach(removeRoute);
  1222. }
  1223. }
  1224. }
  1225. function getRoutes() {
  1226. return matchers;
  1227. }
  1228. function insertMatcher(matcher) {
  1229. const index = findInsertionIndex(matcher, matchers);
  1230. matchers.splice(index, 0, matcher);
  1231. if (matcher.record.name && !isAliasRecord(matcher)) matcherMap.set(matcher.record.name, matcher);
  1232. }
  1233. function resolve(location$1, currentLocation) {
  1234. let matcher;
  1235. let params = {};
  1236. let path;
  1237. let name;
  1238. if ("name" in location$1 && location$1.name) {
  1239. matcher = matcherMap.get(location$1.name);
  1240. if (!matcher) throw createRouterError(ErrorTypes.MATCHER_NOT_FOUND, { location: location$1 });
  1241. {
  1242. const invalidParams = Object.keys(location$1.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
  1243. if (invalidParams.length) warn(`Discarded invalid param(s) "${invalidParams.join("\", \"")}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
  1244. }
  1245. name = matcher.record.name;
  1246. params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location$1.params && pickParams(location$1.params, matcher.keys.map((k) => k.name)));
  1247. path = matcher.stringify(params);
  1248. } else if (location$1.path != null) {
  1249. path = location$1.path;
  1250. if (!path.startsWith("/")) warn(`The Matcher cannot resolve relative paths but received "${path}". Unless you directly called \`matcher.resolve("${path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`);
  1251. matcher = matchers.find((m) => m.re.test(path));
  1252. if (matcher) {
  1253. params = matcher.parse(path);
  1254. name = matcher.record.name;
  1255. }
  1256. } else {
  1257. matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
  1258. if (!matcher) throw createRouterError(ErrorTypes.MATCHER_NOT_FOUND, {
  1259. location: location$1,
  1260. currentLocation
  1261. });
  1262. name = matcher.record.name;
  1263. params = assign({}, currentLocation.params, location$1.params);
  1264. path = matcher.stringify(params);
  1265. }
  1266. const matched = [];
  1267. let parentMatcher = matcher;
  1268. while (parentMatcher) {
  1269. matched.unshift(parentMatcher.record);
  1270. parentMatcher = parentMatcher.parent;
  1271. }
  1272. return {
  1273. name,
  1274. path,
  1275. params,
  1276. matched,
  1277. meta: mergeMetaFields(matched)
  1278. };
  1279. }
  1280. routes.forEach((route) => addRoute(route));
  1281. function clearRoutes() {
  1282. matchers.length = 0;
  1283. matcherMap.clear();
  1284. }
  1285. return {
  1286. addRoute,
  1287. resolve,
  1288. removeRoute,
  1289. clearRoutes,
  1290. getRoutes,
  1291. getRecordMatcher
  1292. };
  1293. }
  1294. /**
  1295. * Picks an object param to contain only specified keys.
  1296. *
  1297. * @param params - params object to pick from
  1298. * @param keys - keys to pick
  1299. */
  1300. function pickParams(params, keys) {
  1301. const newParams = {};
  1302. for (const key of keys) if (key in params) newParams[key] = params[key];
  1303. return newParams;
  1304. }
  1305. /**
  1306. * Normalizes a RouteRecordRaw. Creates a copy
  1307. *
  1308. * @param record
  1309. * @returns the normalized version
  1310. */
  1311. function normalizeRouteRecord(record) {
  1312. const normalized = {
  1313. path: record.path,
  1314. redirect: record.redirect,
  1315. name: record.name,
  1316. meta: record.meta || {},
  1317. aliasOf: record.aliasOf,
  1318. beforeEnter: record.beforeEnter,
  1319. props: normalizeRecordProps(record),
  1320. children: record.children || [],
  1321. instances: {},
  1322. leaveGuards: /* @__PURE__ */ new Set(),
  1323. updateGuards: /* @__PURE__ */ new Set(),
  1324. enterCallbacks: {},
  1325. components: "components" in record ? record.components || null : record.component && { default: record.component }
  1326. };
  1327. Object.defineProperty(normalized, "mods", { value: {} });
  1328. return normalized;
  1329. }
  1330. /**
  1331. * Normalize the optional `props` in a record to always be an object similar to
  1332. * components. Also accept a boolean for components.
  1333. * @param record
  1334. */
  1335. function normalizeRecordProps(record) {
  1336. const propsObject = {};
  1337. const props = record.props || false;
  1338. if ("component" in record) propsObject.default = props;
  1339. else for (const name in record.components) propsObject[name] = typeof props === "object" ? props[name] : props;
  1340. return propsObject;
  1341. }
  1342. /**
  1343. * Checks if a record or any of its parent is an alias
  1344. * @param record
  1345. */
  1346. function isAliasRecord(record) {
  1347. while (record) {
  1348. if (record.record.aliasOf) return true;
  1349. record = record.parent;
  1350. }
  1351. return false;
  1352. }
  1353. /**
  1354. * Merge meta fields of an array of records
  1355. *
  1356. * @param matched - array of matched records
  1357. */
  1358. function mergeMetaFields(matched) {
  1359. return matched.reduce((meta, record) => assign(meta, record.meta), {});
  1360. }
  1361. function isSameParam(a, b) {
  1362. return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
  1363. }
  1364. /**
  1365. * Check if a path and its alias have the same required params
  1366. *
  1367. * @param a - original record
  1368. * @param b - alias record
  1369. */
  1370. function checkSameParams(a, b) {
  1371. for (const key of a.keys) if (!key.optional && !b.keys.find(isSameParam.bind(null, key))) return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
  1372. for (const key of b.keys) if (!key.optional && !a.keys.find(isSameParam.bind(null, key))) return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
  1373. }
  1374. /**
  1375. * A route with a name and a child with an empty path without a name should warn when adding the route
  1376. *
  1377. * @param mainNormalizedRecord - RouteRecordNormalized
  1378. * @param parent - RouteRecordMatcher
  1379. */
  1380. function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
  1381. if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
  1382. }
  1383. function checkSameNameAsAncestor(record, parent) {
  1384. for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor.record.name === record.name) throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? "child" : "descendant"} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
  1385. }
  1386. function checkMissingParamsInAbsolutePath(record, parent) {
  1387. for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key))) return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
  1388. }
  1389. /**
  1390. * Performs a binary search to find the correct insertion index for a new matcher.
  1391. *
  1392. * Matchers are primarily sorted by their score. If scores are tied then we also consider parent/child relationships,
  1393. * with descendants coming before ancestors. If there's still a tie, new routes are inserted after existing routes.
  1394. *
  1395. * @param matcher - new matcher to be inserted
  1396. * @param matchers - existing matchers
  1397. */
  1398. function findInsertionIndex(matcher, matchers) {
  1399. let lower = 0;
  1400. let upper = matchers.length;
  1401. while (lower !== upper) {
  1402. const mid = lower + upper >> 1;
  1403. if (comparePathParserScore(matcher, matchers[mid]) < 0) upper = mid;
  1404. else lower = mid + 1;
  1405. }
  1406. const insertionAncestor = getInsertionAncestor(matcher);
  1407. if (insertionAncestor) {
  1408. upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
  1409. if (upper < 0) warn(`Finding ancestor route "${insertionAncestor.record.path}" failed for "${matcher.record.path}"`);
  1410. }
  1411. return upper;
  1412. }
  1413. function getInsertionAncestor(matcher) {
  1414. let ancestor = matcher;
  1415. while (ancestor = ancestor.parent) if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) return ancestor;
  1416. }
  1417. /**
  1418. * Checks if a matcher can be reachable. This means if it's possible to reach it as a route. For example, routes without
  1419. * a component, or name, or redirect, are just used to group other routes.
  1420. * @param matcher
  1421. * @param matcher.record record of the matcher
  1422. * @returns
  1423. */
  1424. function isMatchable({ record }) {
  1425. return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
  1426. }
  1427. //#endregion
  1428. //#region src/query.ts
  1429. /**
  1430. * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
  1431. * version with the leading `?` and without Should work as URLSearchParams
  1432. * @internal
  1433. *
  1434. * @param search - search string to parse
  1435. * @returns a query object
  1436. */
  1437. function parseQuery(search) {
  1438. const query = {};
  1439. if (search === "" || search === "?") return query;
  1440. const searchParams = (search[0] === "?" ? search.slice(1) : search).split("&");
  1441. for (let i = 0; i < searchParams.length; ++i) {
  1442. const searchParam = searchParams[i].replace(PLUS_RE, " ");
  1443. const eqPos = searchParam.indexOf("=");
  1444. const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
  1445. const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
  1446. if (key in query) {
  1447. let currentValue = query[key];
  1448. if (!isArray(currentValue)) currentValue = query[key] = [currentValue];
  1449. currentValue.push(value);
  1450. } else query[key] = value;
  1451. }
  1452. return query;
  1453. }
  1454. /**
  1455. * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
  1456. * doesn't prepend a `?`
  1457. *
  1458. * @internal
  1459. *
  1460. * @param query - query object to stringify
  1461. * @returns string version of the query without the leading `?`
  1462. */
  1463. function stringifyQuery(query) {
  1464. let search = "";
  1465. for (let key in query) {
  1466. const value = query[key];
  1467. key = encodeQueryKey(key);
  1468. if (value == null) {
  1469. if (value !== void 0) search += (search.length ? "&" : "") + key;
  1470. continue;
  1471. }
  1472. (isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)]).forEach((value$1) => {
  1473. if (value$1 !== void 0) {
  1474. search += (search.length ? "&" : "") + key;
  1475. if (value$1 != null) search += "=" + value$1;
  1476. }
  1477. });
  1478. }
  1479. return search;
  1480. }
  1481. /**
  1482. * Transforms a {@link LocationQueryRaw} into a {@link LocationQuery} by casting
  1483. * numbers into strings, removing keys with an undefined value and replacing
  1484. * undefined with null in arrays
  1485. *
  1486. * @param query - query object to normalize
  1487. * @returns a normalized query object
  1488. */
  1489. function normalizeQuery(query) {
  1490. const normalizedQuery = {};
  1491. for (const key in query) {
  1492. const value = query[key];
  1493. if (value !== void 0) normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
  1494. }
  1495. return normalizedQuery;
  1496. }
  1497. //#endregion
  1498. //#region src/injectionSymbols.ts
  1499. /**
  1500. * RouteRecord being rendered by the closest ancestor Router View. Used for
  1501. * `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
  1502. * Location Matched
  1503. *
  1504. * @internal
  1505. */
  1506. const matchedRouteKey = Symbol("router view location matched");
  1507. /**
  1508. * Allows overriding the router view depth to control which component in
  1509. * `matched` is rendered. rvd stands for Router View Depth
  1510. *
  1511. * @internal
  1512. */
  1513. const viewDepthKey = Symbol("router view depth");
  1514. /**
  1515. * Allows overriding the router instance returned by `useRouter` in tests. r
  1516. * stands for router
  1517. *
  1518. * @internal
  1519. */
  1520. const routerKey = Symbol("router");
  1521. /**
  1522. * Allows overriding the current route returned by `useRoute` in tests. rl
  1523. * stands for route location
  1524. *
  1525. * @internal
  1526. */
  1527. const routeLocationKey = Symbol("route location");
  1528. /**
  1529. * Allows overriding the current route used by router-view. Internally this is
  1530. * used when the `route` prop is passed.
  1531. *
  1532. * @internal
  1533. */
  1534. const routerViewLocationKey = Symbol("router view location");
  1535. //#endregion
  1536. //#region src/utils/callbacks.ts
  1537. /**
  1538. * Create a list of callbacks that can be reset. Used to create before and after navigation guards list
  1539. */
  1540. function useCallbacks() {
  1541. let handlers = [];
  1542. function add(handler) {
  1543. handlers.push(handler);
  1544. return () => {
  1545. const i = handlers.indexOf(handler);
  1546. if (i > -1) handlers.splice(i, 1);
  1547. };
  1548. }
  1549. function reset() {
  1550. handlers = [];
  1551. }
  1552. return {
  1553. add,
  1554. list: () => handlers.slice(),
  1555. reset
  1556. };
  1557. }
  1558. //#endregion
  1559. //#region src/navigationGuards.ts
  1560. function registerGuard(record, name, guard) {
  1561. const removeFromList = () => {
  1562. record[name].delete(guard);
  1563. };
  1564. (0, vue.onUnmounted)(removeFromList);
  1565. (0, vue.onDeactivated)(removeFromList);
  1566. (0, vue.onActivated)(() => {
  1567. record[name].add(guard);
  1568. });
  1569. record[name].add(guard);
  1570. }
  1571. /**
  1572. * Add a navigation guard that triggers whenever the component for the current
  1573. * location is about to be left. Similar to {@link beforeRouteLeave} but can be
  1574. * used in any component. The guard is removed when the component is unmounted.
  1575. *
  1576. * @param leaveGuard - {@link NavigationGuard}
  1577. */
  1578. function onBeforeRouteLeave(leaveGuard) {
  1579. if (!(0, vue.getCurrentInstance)()) {
  1580. warn("getCurrentInstance() returned null. onBeforeRouteLeave() must be called at the top of a setup function");
  1581. return;
  1582. }
  1583. const activeRecord = (0, vue.inject)(matchedRouteKey, {}).value;
  1584. if (!activeRecord) {
  1585. warn("No active route record was found when calling `onBeforeRouteLeave()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
  1586. return;
  1587. }
  1588. registerGuard(activeRecord, "leaveGuards", leaveGuard);
  1589. }
  1590. /**
  1591. * Add a navigation guard that triggers whenever the current location is about
  1592. * to be updated. Similar to {@link beforeRouteUpdate} but can be used in any
  1593. * component. The guard is removed when the component is unmounted.
  1594. *
  1595. * @param updateGuard - {@link NavigationGuard}
  1596. */
  1597. function onBeforeRouteUpdate(updateGuard) {
  1598. if (!(0, vue.getCurrentInstance)()) {
  1599. warn("getCurrentInstance() returned null. onBeforeRouteUpdate() must be called at the top of a setup function");
  1600. return;
  1601. }
  1602. const activeRecord = (0, vue.inject)(matchedRouteKey, {}).value;
  1603. if (!activeRecord) {
  1604. warn("No active route record was found when calling `onBeforeRouteUpdate()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
  1605. return;
  1606. }
  1607. registerGuard(activeRecord, "updateGuards", updateGuard);
  1608. }
  1609. function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
  1610. const enterCallbackArray = record && (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
  1611. return () => new Promise((resolve, reject) => {
  1612. const next = (valid) => {
  1613. if (valid === false) reject(createRouterError(ErrorTypes.NAVIGATION_ABORTED, {
  1614. from,
  1615. to
  1616. }));
  1617. else if (valid instanceof Error) reject(valid);
  1618. else if (isRouteLocation(valid)) reject(createRouterError(ErrorTypes.NAVIGATION_GUARD_REDIRECT, {
  1619. from: to,
  1620. to: valid
  1621. }));
  1622. else {
  1623. if (enterCallbackArray && record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") enterCallbackArray.push(valid);
  1624. resolve();
  1625. }
  1626. };
  1627. const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, canOnlyBeCalledOnce(next, to, from)));
  1628. let guardCall = Promise.resolve(guardReturn);
  1629. if (guard.length < 3) guardCall = guardCall.then(next);
  1630. if (guard.length > 2) {
  1631. const message = `The "next" callback was never called inside of ${guard.name ? "\"" + guard.name + "\"" : ""}:\n${guard.toString()}\n. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
  1632. if (typeof guardReturn === "object" && "then" in guardReturn) guardCall = guardCall.then((resolvedValue) => {
  1633. if (!next._called) {
  1634. warn(message);
  1635. return Promise.reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
  1636. }
  1637. return resolvedValue;
  1638. });
  1639. else if (guardReturn !== void 0) {
  1640. if (!next._called) {
  1641. warn(message);
  1642. reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
  1643. return;
  1644. }
  1645. }
  1646. }
  1647. guardCall.catch((err) => reject(err));
  1648. });
  1649. }
  1650. function canOnlyBeCalledOnce(next, to, from) {
  1651. let called = 0;
  1652. return function() {
  1653. if (called++ === 1) warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
  1654. next._called = true;
  1655. if (called === 1) next.apply(null, arguments);
  1656. };
  1657. }
  1658. function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
  1659. const guards = [];
  1660. for (const record of matched) {
  1661. if (!record.components && record.children && !record.children.length) warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
  1662. for (const name in record.components) {
  1663. let rawComponent = record.components[name];
  1664. if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
  1665. warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
  1666. throw new Error("Invalid route component");
  1667. } else if ("then" in rawComponent) {
  1668. warn(`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.`);
  1669. const promise = rawComponent;
  1670. rawComponent = () => promise;
  1671. } else if (rawComponent.__asyncLoader && !rawComponent.__warnedDefineAsync) {
  1672. rawComponent.__warnedDefineAsync = true;
  1673. warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
  1674. }
  1675. if (guardType !== "beforeRouteEnter" && !record.instances[name]) continue;
  1676. if (isRouteComponent(rawComponent)) {
  1677. const guard = (rawComponent.__vccOpts || rawComponent)[guardType];
  1678. guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
  1679. } else {
  1680. let componentPromise = rawComponent();
  1681. if (!("catch" in componentPromise)) {
  1682. warn(`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`);
  1683. componentPromise = Promise.resolve(componentPromise);
  1684. }
  1685. guards.push(() => componentPromise.then((resolved) => {
  1686. if (!resolved) throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
  1687. const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
  1688. record.mods[name] = resolved;
  1689. record.components[name] = resolvedComponent;
  1690. const guard = (resolvedComponent.__vccOpts || resolvedComponent)[guardType];
  1691. return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
  1692. }));
  1693. }
  1694. }
  1695. }
  1696. return guards;
  1697. }
  1698. /**
  1699. * Ensures a route is loaded, so it can be passed as o prop to `<RouterView>`.
  1700. *
  1701. * @param route - resolved route to load
  1702. */
  1703. function loadRouteLocation(route) {
  1704. return route.matched.every((record) => record.redirect) ? Promise.reject(/* @__PURE__ */ new Error("Cannot load a route that redirects.")) : Promise.all(route.matched.map((record) => record.components && Promise.all(Object.keys(record.components).reduce((promises, name) => {
  1705. const rawComponent = record.components[name];
  1706. if (typeof rawComponent === "function" && !("displayName" in rawComponent)) promises.push(rawComponent().then((resolved) => {
  1707. if (!resolved) return Promise.reject(/* @__PURE__ */ new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
  1708. const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
  1709. record.mods[name] = resolved;
  1710. record.components[name] = resolvedComponent;
  1711. }));
  1712. return promises;
  1713. }, [])))).then(() => route);
  1714. }
  1715. /**
  1716. * Split the leaving, updating, and entering records.
  1717. * @internal
  1718. *
  1719. * @param to - Location we are navigating to
  1720. * @param from - Location we are navigating from
  1721. */
  1722. function extractChangingRecords(to, from) {
  1723. const leavingRecords = [];
  1724. const updatingRecords = [];
  1725. const enteringRecords = [];
  1726. const len = Math.max(from.matched.length, to.matched.length);
  1727. for (let i = 0; i < len; i++) {
  1728. const recordFrom = from.matched[i];
  1729. if (recordFrom) if (to.matched.find((record) => isSameRouteRecord(record, recordFrom))) updatingRecords.push(recordFrom);
  1730. else leavingRecords.push(recordFrom);
  1731. const recordTo = to.matched[i];
  1732. if (recordTo) {
  1733. if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) enteringRecords.push(recordTo);
  1734. }
  1735. }
  1736. return [
  1737. leavingRecords,
  1738. updatingRecords,
  1739. enteringRecords
  1740. ];
  1741. }
  1742. //#endregion
  1743. //#region src/RouterLink.ts
  1744. /**
  1745. * Returns the internal behavior of a {@link RouterLink} without the rendering part.
  1746. *
  1747. * @param props - a `to` location and an optional `replace` flag
  1748. */
  1749. function useLink(props) {
  1750. const router = (0, vue.inject)(routerKey);
  1751. const currentRoute = (0, vue.inject)(routeLocationKey);
  1752. let hasPrevious = false;
  1753. let previousTo = null;
  1754. const route = (0, vue.computed)(() => {
  1755. const to = (0, vue.unref)(props.to);
  1756. if (!hasPrevious || to !== previousTo) {
  1757. if (!isRouteLocation(to)) if (hasPrevious) warn(`Invalid value for prop "to" in useLink()\n- to:`, to, `\n- previous to:`, previousTo, `\n- props:`, props);
  1758. else warn(`Invalid value for prop "to" in useLink()\n- to:`, to, `\n- props:`, props);
  1759. previousTo = to;
  1760. hasPrevious = true;
  1761. }
  1762. return router.resolve(to);
  1763. });
  1764. const activeRecordIndex = (0, vue.computed)(() => {
  1765. const { matched } = route.value;
  1766. const { length } = matched;
  1767. const routeMatched = matched[length - 1];
  1768. const currentMatched = currentRoute.matched;
  1769. if (!routeMatched || !currentMatched.length) return -1;
  1770. const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
  1771. if (index > -1) return index;
  1772. const parentRecordPath = getOriginalPath(matched[length - 2]);
  1773. return length > 1 && getOriginalPath(routeMatched) === parentRecordPath && currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index;
  1774. });
  1775. const isActive = (0, vue.computed)(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
  1776. const isExactActive = (0, vue.computed)(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
  1777. function navigate(e = {}) {
  1778. if (guardEvent(e)) {
  1779. const p = router[(0, vue.unref)(props.replace) ? "replace" : "push"]((0, vue.unref)(props.to)).catch(noop);
  1780. if (props.viewTransition && typeof document !== "undefined" && "startViewTransition" in document) document.startViewTransition(() => p);
  1781. return p;
  1782. }
  1783. return Promise.resolve();
  1784. }
  1785. if (isBrowser) {
  1786. const instance = (0, vue.getCurrentInstance)();
  1787. if (instance) {
  1788. const linkContextDevtools = {
  1789. route: route.value,
  1790. isActive: isActive.value,
  1791. isExactActive: isExactActive.value,
  1792. error: null
  1793. };
  1794. instance.__vrl_devtools = instance.__vrl_devtools || [];
  1795. instance.__vrl_devtools.push(linkContextDevtools);
  1796. (0, vue.watchEffect)(() => {
  1797. linkContextDevtools.route = route.value;
  1798. linkContextDevtools.isActive = isActive.value;
  1799. linkContextDevtools.isExactActive = isExactActive.value;
  1800. linkContextDevtools.error = isRouteLocation((0, vue.unref)(props.to)) ? null : "Invalid \"to\" value";
  1801. }, { flush: "post" });
  1802. }
  1803. }
  1804. /**
  1805. * NOTE: update {@link _RouterLinkI}'s `$slots` type when updating this
  1806. */
  1807. return {
  1808. route,
  1809. href: (0, vue.computed)(() => route.value.href),
  1810. isActive,
  1811. isExactActive,
  1812. navigate
  1813. };
  1814. }
  1815. function preferSingleVNode(vnodes) {
  1816. return vnodes.length === 1 ? vnodes[0] : vnodes;
  1817. }
  1818. const RouterLinkImpl = /* @__PURE__ */ (0, vue.defineComponent)({
  1819. name: "RouterLink",
  1820. compatConfig: { MODE: 3 },
  1821. props: {
  1822. to: {
  1823. type: [String, Object],
  1824. required: true
  1825. },
  1826. replace: Boolean,
  1827. activeClass: String,
  1828. exactActiveClass: String,
  1829. custom: Boolean,
  1830. ariaCurrentValue: {
  1831. type: String,
  1832. default: "page"
  1833. },
  1834. viewTransition: Boolean
  1835. },
  1836. useLink,
  1837. setup(props, { slots }) {
  1838. const link = (0, vue.reactive)(useLink(props));
  1839. const { options } = (0, vue.inject)(routerKey);
  1840. const elClass = (0, vue.computed)(() => ({
  1841. [getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
  1842. [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
  1843. }));
  1844. return () => {
  1845. const children = slots.default && preferSingleVNode(slots.default(link));
  1846. return props.custom ? children : (0, vue.h)("a", {
  1847. "aria-current": link.isExactActive ? props.ariaCurrentValue : null,
  1848. href: link.href,
  1849. onClick: link.navigate,
  1850. class: elClass.value
  1851. }, children);
  1852. };
  1853. }
  1854. });
  1855. /**
  1856. * Component to render a link that triggers a navigation on click.
  1857. */
  1858. const RouterLink = RouterLinkImpl;
  1859. function guardEvent(e) {
  1860. if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
  1861. if (e.defaultPrevented) return;
  1862. if (e.button !== void 0 && e.button !== 0) return;
  1863. if (e.currentTarget && e.currentTarget.getAttribute) {
  1864. const target = e.currentTarget.getAttribute("target");
  1865. if (/\b_blank\b/i.test(target)) return;
  1866. }
  1867. if (e.preventDefault) e.preventDefault();
  1868. return true;
  1869. }
  1870. function includesParams(outer, inner) {
  1871. for (const key in inner) {
  1872. const innerValue = inner[key];
  1873. const outerValue = outer[key];
  1874. if (typeof innerValue === "string") {
  1875. if (innerValue !== outerValue) return false;
  1876. } else if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i])) return false;
  1877. }
  1878. return true;
  1879. }
  1880. /**
  1881. * Get the original path value of a record by following its aliasOf
  1882. * @param record
  1883. */
  1884. function getOriginalPath(record) {
  1885. return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
  1886. }
  1887. /**
  1888. * Utility class to get the active class based on defaults.
  1889. * @param propClass
  1890. * @param globalClass
  1891. * @param defaultClass
  1892. */
  1893. const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
  1894. //#endregion
  1895. //#region src/RouterView.ts
  1896. const RouterViewImpl = /* @__PURE__ */ (0, vue.defineComponent)({
  1897. name: "RouterView",
  1898. inheritAttrs: false,
  1899. props: {
  1900. name: {
  1901. type: String,
  1902. default: "default"
  1903. },
  1904. route: Object
  1905. },
  1906. compatConfig: { MODE: 3 },
  1907. setup(props, { attrs, slots }) {
  1908. warnDeprecatedUsage();
  1909. const injectedRoute = (0, vue.inject)(routerViewLocationKey);
  1910. const routeToDisplay = (0, vue.computed)(() => props.route || injectedRoute.value);
  1911. const injectedDepth = (0, vue.inject)(viewDepthKey, 0);
  1912. const depth = (0, vue.computed)(() => {
  1913. let initialDepth = (0, vue.unref)(injectedDepth);
  1914. const { matched } = routeToDisplay.value;
  1915. let matchedRoute;
  1916. while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) initialDepth++;
  1917. return initialDepth;
  1918. });
  1919. const matchedRouteRef = (0, vue.computed)(() => routeToDisplay.value.matched[depth.value]);
  1920. (0, vue.provide)(viewDepthKey, (0, vue.computed)(() => depth.value + 1));
  1921. (0, vue.provide)(matchedRouteKey, matchedRouteRef);
  1922. (0, vue.provide)(routerViewLocationKey, routeToDisplay);
  1923. const viewRef = (0, vue.ref)();
  1924. (0, vue.watch)(() => [
  1925. viewRef.value,
  1926. matchedRouteRef.value,
  1927. props.name
  1928. ], ([instance, to, name], [oldInstance, from, oldName]) => {
  1929. if (to) {
  1930. to.instances[name] = instance;
  1931. if (from && from !== to && instance && instance === oldInstance) {
  1932. if (!to.leaveGuards.size) to.leaveGuards = from.leaveGuards;
  1933. if (!to.updateGuards.size) to.updateGuards = from.updateGuards;
  1934. }
  1935. }
  1936. if (instance && to && (!from || !isSameRouteRecord(to, from) || !oldInstance)) (to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
  1937. }, { flush: "post" });
  1938. return () => {
  1939. const route = routeToDisplay.value;
  1940. const currentName = props.name;
  1941. const matchedRoute = matchedRouteRef.value;
  1942. const ViewComponent = matchedRoute && matchedRoute.components[currentName];
  1943. if (!ViewComponent) return normalizeSlot(slots.default, {
  1944. Component: ViewComponent,
  1945. route
  1946. });
  1947. const routePropsOption = matchedRoute.props[currentName];
  1948. const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
  1949. const onVnodeUnmounted = (vnode) => {
  1950. if (vnode.component.isUnmounted) matchedRoute.instances[currentName] = null;
  1951. };
  1952. const component = (0, vue.h)(ViewComponent, assign({}, routeProps, attrs, {
  1953. onVnodeUnmounted,
  1954. ref: viewRef
  1955. }));
  1956. if (isBrowser && component.ref) {
  1957. const info = {
  1958. depth: depth.value,
  1959. name: matchedRoute.name,
  1960. path: matchedRoute.path,
  1961. meta: matchedRoute.meta
  1962. };
  1963. (isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i]).forEach((instance) => {
  1964. instance.__vrv_devtools = info;
  1965. });
  1966. }
  1967. return normalizeSlot(slots.default, {
  1968. Component: component,
  1969. route
  1970. }) || component;
  1971. };
  1972. }
  1973. });
  1974. function normalizeSlot(slot, data) {
  1975. if (!slot) return null;
  1976. const slotContent = slot(data);
  1977. return slotContent.length === 1 ? slotContent[0] : slotContent;
  1978. }
  1979. /**
  1980. * Component to display the current route the user is at.
  1981. */
  1982. const RouterView = RouterViewImpl;
  1983. function warnDeprecatedUsage() {
  1984. const instance = (0, vue.getCurrentInstance)();
  1985. const parentName = instance.parent && instance.parent.type.name;
  1986. const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
  1987. if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
  1988. const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
  1989. warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
  1990. Use slot props instead:
  1991. <router-view v-slot="{ Component }">
  1992. <${comp}>\n <component :is="Component" />\n </${comp}>\n</router-view>`);
  1993. }
  1994. }
  1995. //#endregion
  1996. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/env.js
  1997. var require_env = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/env.js": ((exports) => {
  1998. Object.defineProperty(exports, "__esModule", { value: true });
  1999. function getDevtoolsGlobalHook() {
  2000. return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
  2001. }
  2002. exports.getDevtoolsGlobalHook = getDevtoolsGlobalHook;
  2003. function getTarget() {
  2004. return typeof navigator !== "undefined" && typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : {};
  2005. }
  2006. exports.getTarget = getTarget;
  2007. exports.isProxyAvailable = typeof Proxy === "function";
  2008. }) });
  2009. //#endregion
  2010. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/const.js
  2011. var require_const = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/const.js": ((exports) => {
  2012. Object.defineProperty(exports, "__esModule", { value: true });
  2013. exports.HOOK_SETUP = "devtools-plugin:setup";
  2014. exports.HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";
  2015. }) });
  2016. //#endregion
  2017. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/time.js
  2018. var require_time = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/time.js": ((exports) => {
  2019. Object.defineProperty(exports, "__esModule", { value: true });
  2020. let supported;
  2021. let perf;
  2022. function isPerformanceSupported() {
  2023. var _a;
  2024. if (supported !== void 0) return supported;
  2025. if (typeof window !== "undefined" && window.performance) {
  2026. supported = true;
  2027. perf = window.performance;
  2028. } else if (typeof globalThis !== "undefined" && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
  2029. supported = true;
  2030. perf = globalThis.perf_hooks.performance;
  2031. } else supported = false;
  2032. return supported;
  2033. }
  2034. exports.isPerformanceSupported = isPerformanceSupported;
  2035. function now() {
  2036. return isPerformanceSupported() ? perf.now() : Date.now();
  2037. }
  2038. exports.now = now;
  2039. }) });
  2040. //#endregion
  2041. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/proxy.js
  2042. var require_proxy = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/proxy.js": ((exports) => {
  2043. Object.defineProperty(exports, "__esModule", { value: true });
  2044. const const_js_1$1 = require_const();
  2045. const time_js_1 = require_time();
  2046. var ApiProxy = class {
  2047. constructor(plugin, hook) {
  2048. this.target = null;
  2049. this.targetQueue = [];
  2050. this.onQueue = [];
  2051. this.plugin = plugin;
  2052. this.hook = hook;
  2053. const defaultSettings = {};
  2054. if (plugin.settings) for (const id in plugin.settings) defaultSettings[id] = plugin.settings[id].defaultValue;
  2055. const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
  2056. let currentSettings = Object.assign({}, defaultSettings);
  2057. try {
  2058. const raw = localStorage.getItem(localSettingsSaveId);
  2059. const data = JSON.parse(raw);
  2060. Object.assign(currentSettings, data);
  2061. } catch (e) {}
  2062. this.fallbacks = {
  2063. getSettings() {
  2064. return currentSettings;
  2065. },
  2066. setSettings(value) {
  2067. try {
  2068. localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
  2069. } catch (e) {}
  2070. currentSettings = value;
  2071. },
  2072. now() {
  2073. return (0, time_js_1.now)();
  2074. }
  2075. };
  2076. if (hook) hook.on(const_js_1$1.HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
  2077. if (pluginId === this.plugin.id) this.fallbacks.setSettings(value);
  2078. });
  2079. this.proxiedOn = new Proxy({}, { get: (_target, prop) => {
  2080. if (this.target) return this.target.on[prop];
  2081. else return (...args) => {
  2082. this.onQueue.push({
  2083. method: prop,
  2084. args
  2085. });
  2086. };
  2087. } });
  2088. this.proxiedTarget = new Proxy({}, { get: (_target, prop) => {
  2089. if (this.target) return this.target[prop];
  2090. else if (prop === "on") return this.proxiedOn;
  2091. else if (Object.keys(this.fallbacks).includes(prop)) return (...args) => {
  2092. this.targetQueue.push({
  2093. method: prop,
  2094. args,
  2095. resolve: () => {}
  2096. });
  2097. return this.fallbacks[prop](...args);
  2098. };
  2099. else return (...args) => {
  2100. return new Promise((resolve) => {
  2101. this.targetQueue.push({
  2102. method: prop,
  2103. args,
  2104. resolve
  2105. });
  2106. });
  2107. };
  2108. } });
  2109. }
  2110. async setRealTarget(target) {
  2111. this.target = target;
  2112. for (const item of this.onQueue) this.target.on[item.method](...item.args);
  2113. for (const item of this.targetQueue) item.resolve(await this.target[item.method](...item.args));
  2114. }
  2115. };
  2116. exports.ApiProxy = ApiProxy;
  2117. }) });
  2118. //#endregion
  2119. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/api.js
  2120. var require_api$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/api.js": ((exports) => {
  2121. Object.defineProperty(exports, "__esModule", { value: true });
  2122. }) });
  2123. //#endregion
  2124. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/app.js
  2125. var require_app = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/app.js": ((exports) => {
  2126. Object.defineProperty(exports, "__esModule", { value: true });
  2127. }) });
  2128. //#endregion
  2129. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/component.js
  2130. var require_component = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/component.js": ((exports) => {
  2131. Object.defineProperty(exports, "__esModule", { value: true });
  2132. }) });
  2133. //#endregion
  2134. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/context.js
  2135. var require_context = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/context.js": ((exports) => {
  2136. Object.defineProperty(exports, "__esModule", { value: true });
  2137. }) });
  2138. //#endregion
  2139. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js
  2140. var require_hooks = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js": ((exports) => {
  2141. Object.defineProperty(exports, "__esModule", { value: true });
  2142. }) });
  2143. //#endregion
  2144. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/util.js
  2145. var require_util = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/util.js": ((exports) => {
  2146. Object.defineProperty(exports, "__esModule", { value: true });
  2147. }) });
  2148. //#endregion
  2149. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/index.js
  2150. var require_api = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/api/index.js": ((exports) => {
  2151. var __createBinding$1 = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
  2152. if (k2 === void 0) k2 = k;
  2153. var desc = Object.getOwnPropertyDescriptor(m, k);
  2154. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
  2155. enumerable: true,
  2156. get: function() {
  2157. return m[k];
  2158. }
  2159. };
  2160. Object.defineProperty(o, k2, desc);
  2161. }) : (function(o, m, k, k2) {
  2162. if (k2 === void 0) k2 = k;
  2163. o[k2] = m[k];
  2164. }));
  2165. var __exportStar$1 = exports && exports.__exportStar || function(m, exports$1) {
  2166. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding$1(exports$1, m, p);
  2167. };
  2168. Object.defineProperty(exports, "__esModule", { value: true });
  2169. __exportStar$1(require_api$1(), exports);
  2170. __exportStar$1(require_app(), exports);
  2171. __exportStar$1(require_component(), exports);
  2172. __exportStar$1(require_context(), exports);
  2173. __exportStar$1(require_hooks(), exports);
  2174. __exportStar$1(require_util(), exports);
  2175. }) });
  2176. //#endregion
  2177. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/plugin.js
  2178. var require_plugin = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/plugin.js": ((exports) => {
  2179. Object.defineProperty(exports, "__esModule", { value: true });
  2180. }) });
  2181. //#endregion
  2182. //#region ../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/index.js
  2183. var require_cjs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@vue+devtools-api@6.6.4/node_modules/@vue/devtools-api/lib/cjs/index.js": ((exports) => {
  2184. var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
  2185. if (k2 === void 0) k2 = k;
  2186. var desc = Object.getOwnPropertyDescriptor(m, k);
  2187. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
  2188. enumerable: true,
  2189. get: function() {
  2190. return m[k];
  2191. }
  2192. };
  2193. Object.defineProperty(o, k2, desc);
  2194. }) : (function(o, m, k, k2) {
  2195. if (k2 === void 0) k2 = k;
  2196. o[k2] = m[k];
  2197. }));
  2198. var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
  2199. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
  2200. };
  2201. Object.defineProperty(exports, "__esModule", { value: true });
  2202. exports.setupDevtoolsPlugin = void 0;
  2203. const env_js_1 = require_env();
  2204. const const_js_1 = require_const();
  2205. const proxy_js_1 = require_proxy();
  2206. __exportStar(require_api(), exports);
  2207. __exportStar(require_plugin(), exports);
  2208. __exportStar(require_time(), exports);
  2209. function setupDevtoolsPlugin$1(pluginDescriptor, setupFn) {
  2210. const descriptor = pluginDescriptor;
  2211. const target = (0, env_js_1.getTarget)();
  2212. const hook = (0, env_js_1.getDevtoolsGlobalHook)();
  2213. const enableProxy = env_js_1.isProxyAvailable && descriptor.enableEarlyProxy;
  2214. if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) hook.emit(const_js_1.HOOK_SETUP, pluginDescriptor, setupFn);
  2215. else {
  2216. const proxy = enableProxy ? new proxy_js_1.ApiProxy(descriptor, hook) : null;
  2217. (target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []).push({
  2218. pluginDescriptor: descriptor,
  2219. setupFn,
  2220. proxy
  2221. });
  2222. if (proxy) setupFn(proxy.proxiedTarget);
  2223. }
  2224. }
  2225. exports.setupDevtoolsPlugin = setupDevtoolsPlugin$1;
  2226. }) });
  2227. //#endregion
  2228. //#region src/devtools.ts
  2229. var import_cjs = /* @__PURE__ */ __toESM(require_cjs());
  2230. /**
  2231. * Copies a route location and removes any problematic properties that cannot be shown in devtools (e.g. Vue instances).
  2232. *
  2233. * @param routeLocation - routeLocation to format
  2234. * @param tooltip - optional tooltip
  2235. * @returns a copy of the routeLocation
  2236. */
  2237. function formatRouteLocation(routeLocation, tooltip) {
  2238. const copy = assign({}, routeLocation, { matched: routeLocation.matched.map((matched) => omit(matched, [
  2239. "instances",
  2240. "children",
  2241. "aliasOf"
  2242. ])) });
  2243. return { _custom: {
  2244. type: null,
  2245. readOnly: true,
  2246. display: routeLocation.fullPath,
  2247. tooltip,
  2248. value: copy
  2249. } };
  2250. }
  2251. function formatDisplay(display) {
  2252. return { _custom: { display } };
  2253. }
  2254. let routerId = 0;
  2255. function addDevtools(app, router, matcher) {
  2256. if (router.__hasDevtools) return;
  2257. router.__hasDevtools = true;
  2258. const id = routerId++;
  2259. (0, import_cjs.setupDevtoolsPlugin)({
  2260. id: "org.vuejs.router" + (id ? "." + id : ""),
  2261. label: "Vue Router",
  2262. packageName: "vue-router",
  2263. homepage: "https://router.vuejs.org",
  2264. logo: "https://router.vuejs.org/logo.png",
  2265. componentStateTypes: ["Routing"],
  2266. app
  2267. }, (api) => {
  2268. if (typeof api.now !== "function") warn("[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
  2269. api.on.inspectComponent((payload, ctx) => {
  2270. if (payload.instanceData) payload.instanceData.state.push({
  2271. type: "Routing",
  2272. key: "$route",
  2273. editable: false,
  2274. value: formatRouteLocation(router.currentRoute.value, "Current Route")
  2275. });
  2276. });
  2277. api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
  2278. if (componentInstance.__vrv_devtools) {
  2279. const info = componentInstance.__vrv_devtools;
  2280. node.tags.push({
  2281. label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
  2282. textColor: 0,
  2283. tooltip: "This component is rendered by &lt;router-view&gt;",
  2284. backgroundColor: PINK_500
  2285. });
  2286. }
  2287. if (isArray(componentInstance.__vrl_devtools)) {
  2288. componentInstance.__devtoolsApi = api;
  2289. componentInstance.__vrl_devtools.forEach((devtoolsData) => {
  2290. let label = devtoolsData.route.path;
  2291. let backgroundColor = ORANGE_400;
  2292. let tooltip = "";
  2293. let textColor = 0;
  2294. if (devtoolsData.error) {
  2295. label = devtoolsData.error;
  2296. backgroundColor = RED_100;
  2297. textColor = RED_700;
  2298. } else if (devtoolsData.isExactActive) {
  2299. backgroundColor = LIME_500;
  2300. tooltip = "This is exactly active";
  2301. } else if (devtoolsData.isActive) {
  2302. backgroundColor = BLUE_600;
  2303. tooltip = "This link is active";
  2304. }
  2305. node.tags.push({
  2306. label,
  2307. textColor,
  2308. tooltip,
  2309. backgroundColor
  2310. });
  2311. });
  2312. }
  2313. });
  2314. (0, vue.watch)(router.currentRoute, () => {
  2315. refreshRoutesView();
  2316. api.notifyComponentUpdate();
  2317. api.sendInspectorTree(routerInspectorId);
  2318. api.sendInspectorState(routerInspectorId);
  2319. });
  2320. const navigationsLayerId = "router:navigations:" + id;
  2321. api.addTimelineLayer({
  2322. id: navigationsLayerId,
  2323. label: `Router${id ? " " + id : ""} Navigations`,
  2324. color: 4237508
  2325. });
  2326. router.onError((error, to) => {
  2327. api.addTimelineEvent({
  2328. layerId: navigationsLayerId,
  2329. event: {
  2330. title: "Error during Navigation",
  2331. subtitle: to.fullPath,
  2332. logType: "error",
  2333. time: api.now(),
  2334. data: { error },
  2335. groupId: to.meta.__navigationId
  2336. }
  2337. });
  2338. });
  2339. let navigationId = 0;
  2340. router.beforeEach((to, from) => {
  2341. const data = {
  2342. guard: formatDisplay("beforeEach"),
  2343. from: formatRouteLocation(from, "Current Location during this navigation"),
  2344. to: formatRouteLocation(to, "Target location")
  2345. };
  2346. Object.defineProperty(to.meta, "__navigationId", { value: navigationId++ });
  2347. api.addTimelineEvent({
  2348. layerId: navigationsLayerId,
  2349. event: {
  2350. time: api.now(),
  2351. title: "Start of navigation",
  2352. subtitle: to.fullPath,
  2353. data,
  2354. groupId: to.meta.__navigationId
  2355. }
  2356. });
  2357. });
  2358. router.afterEach((to, from, failure) => {
  2359. const data = { guard: formatDisplay("afterEach") };
  2360. if (failure) {
  2361. data.failure = { _custom: {
  2362. type: Error,
  2363. readOnly: true,
  2364. display: failure ? failure.message : "",
  2365. tooltip: "Navigation Failure",
  2366. value: failure
  2367. } };
  2368. data.status = formatDisplay("❌");
  2369. } else data.status = formatDisplay("✅");
  2370. data.from = formatRouteLocation(from, "Current Location during this navigation");
  2371. data.to = formatRouteLocation(to, "Target location");
  2372. api.addTimelineEvent({
  2373. layerId: navigationsLayerId,
  2374. event: {
  2375. title: "End of navigation",
  2376. subtitle: to.fullPath,
  2377. time: api.now(),
  2378. data,
  2379. logType: failure ? "warning" : "default",
  2380. groupId: to.meta.__navigationId
  2381. }
  2382. });
  2383. });
  2384. /**
  2385. * Inspector of Existing routes
  2386. */
  2387. const routerInspectorId = "router-inspector:" + id;
  2388. api.addInspector({
  2389. id: routerInspectorId,
  2390. label: "Routes" + (id ? " " + id : ""),
  2391. icon: "book",
  2392. treeFilterPlaceholder: "Search routes"
  2393. });
  2394. function refreshRoutesView() {
  2395. if (!activeRoutesPayload) return;
  2396. const payload = activeRoutesPayload;
  2397. let routes = matcher.getRoutes().filter((route) => !route.parent || !route.parent.record.components);
  2398. routes.forEach(resetMatchStateOnRouteRecord);
  2399. if (payload.filter) routes = routes.filter((route) => isRouteMatching(route, payload.filter.toLowerCase()));
  2400. routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
  2401. payload.rootNodes = routes.map(formatRouteRecordForInspector);
  2402. }
  2403. let activeRoutesPayload;
  2404. api.on.getInspectorTree((payload) => {
  2405. activeRoutesPayload = payload;
  2406. if (payload.app === app && payload.inspectorId === routerInspectorId) refreshRoutesView();
  2407. });
  2408. /**
  2409. * Display information about the currently selected route record
  2410. */
  2411. api.on.getInspectorState((payload) => {
  2412. if (payload.app === app && payload.inspectorId === routerInspectorId) {
  2413. const route = matcher.getRoutes().find((route$1) => route$1.record.__vd_id === payload.nodeId);
  2414. if (route) payload.state = { options: formatRouteRecordMatcherForStateInspector(route) };
  2415. }
  2416. });
  2417. api.sendInspectorTree(routerInspectorId);
  2418. api.sendInspectorState(routerInspectorId);
  2419. });
  2420. }
  2421. function modifierForKey(key) {
  2422. if (key.optional) return key.repeatable ? "*" : "?";
  2423. else return key.repeatable ? "+" : "";
  2424. }
  2425. function formatRouteRecordMatcherForStateInspector(route) {
  2426. const { record } = route;
  2427. const fields = [{
  2428. editable: false,
  2429. key: "path",
  2430. value: record.path
  2431. }];
  2432. if (record.name != null) fields.push({
  2433. editable: false,
  2434. key: "name",
  2435. value: record.name
  2436. });
  2437. fields.push({
  2438. editable: false,
  2439. key: "regexp",
  2440. value: route.re
  2441. });
  2442. if (route.keys.length) fields.push({
  2443. editable: false,
  2444. key: "keys",
  2445. value: { _custom: {
  2446. type: null,
  2447. readOnly: true,
  2448. display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
  2449. tooltip: "Param keys",
  2450. value: route.keys
  2451. } }
  2452. });
  2453. if (record.redirect != null) fields.push({
  2454. editable: false,
  2455. key: "redirect",
  2456. value: record.redirect
  2457. });
  2458. if (route.alias.length) fields.push({
  2459. editable: false,
  2460. key: "aliases",
  2461. value: route.alias.map((alias) => alias.record.path)
  2462. });
  2463. if (Object.keys(route.record.meta).length) fields.push({
  2464. editable: false,
  2465. key: "meta",
  2466. value: route.record.meta
  2467. });
  2468. fields.push({
  2469. key: "score",
  2470. editable: false,
  2471. value: { _custom: {
  2472. type: null,
  2473. readOnly: true,
  2474. display: route.score.map((score) => score.join(", ")).join(" | "),
  2475. tooltip: "Score used to sort routes",
  2476. value: route.score
  2477. } }
  2478. });
  2479. return fields;
  2480. }
  2481. /**
  2482. * Extracted from tailwind palette
  2483. */
  2484. const PINK_500 = 15485081;
  2485. const BLUE_600 = 2450411;
  2486. const LIME_500 = 8702998;
  2487. const CYAN_400 = 2282478;
  2488. const ORANGE_400 = 16486972;
  2489. const DARK = 6710886;
  2490. const RED_100 = 16704226;
  2491. const RED_700 = 12131356;
  2492. function formatRouteRecordForInspector(route) {
  2493. const tags = [];
  2494. const { record } = route;
  2495. if (record.name != null) tags.push({
  2496. label: String(record.name),
  2497. textColor: 0,
  2498. backgroundColor: CYAN_400
  2499. });
  2500. if (record.aliasOf) tags.push({
  2501. label: "alias",
  2502. textColor: 0,
  2503. backgroundColor: ORANGE_400
  2504. });
  2505. if (route.__vd_match) tags.push({
  2506. label: "matches",
  2507. textColor: 0,
  2508. backgroundColor: PINK_500
  2509. });
  2510. if (route.__vd_exactActive) tags.push({
  2511. label: "exact",
  2512. textColor: 0,
  2513. backgroundColor: LIME_500
  2514. });
  2515. if (route.__vd_active) tags.push({
  2516. label: "active",
  2517. textColor: 0,
  2518. backgroundColor: BLUE_600
  2519. });
  2520. if (record.redirect) tags.push({
  2521. label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
  2522. textColor: 16777215,
  2523. backgroundColor: DARK
  2524. });
  2525. let id = record.__vd_id;
  2526. if (id == null) {
  2527. id = String(routeRecordId++);
  2528. record.__vd_id = id;
  2529. }
  2530. return {
  2531. id,
  2532. label: record.path,
  2533. tags,
  2534. children: route.children.map(formatRouteRecordForInspector)
  2535. };
  2536. }
  2537. let routeRecordId = 0;
  2538. const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
  2539. function markRouteRecordActive(route, currentRoute) {
  2540. const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
  2541. route.__vd_exactActive = route.__vd_active = isExactActive;
  2542. if (!isExactActive) route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
  2543. route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
  2544. }
  2545. function resetMatchStateOnRouteRecord(route) {
  2546. route.__vd_match = false;
  2547. route.children.forEach(resetMatchStateOnRouteRecord);
  2548. }
  2549. function isRouteMatching(route, filter) {
  2550. const found = String(route.re).match(EXTRACT_REGEXP_RE);
  2551. route.__vd_match = false;
  2552. if (!found || found.length < 3) return false;
  2553. if (new RegExp(found[1].replace(/\$$/, ""), found[2]).test(filter)) {
  2554. route.children.forEach((child) => isRouteMatching(child, filter));
  2555. if (route.record.path !== "/" || filter === "/") {
  2556. route.__vd_match = route.re.test(filter);
  2557. return true;
  2558. }
  2559. return false;
  2560. }
  2561. const path = route.record.path.toLowerCase();
  2562. const decodedPath = decode(path);
  2563. if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter))) return true;
  2564. if (decodedPath.startsWith(filter) || path.startsWith(filter)) return true;
  2565. if (route.record.name && String(route.record.name).includes(filter)) return true;
  2566. return route.children.some((child) => isRouteMatching(child, filter));
  2567. }
  2568. function omit(obj, keys) {
  2569. const ret = {};
  2570. for (const key in obj) if (!keys.includes(key)) ret[key] = obj[key];
  2571. return ret;
  2572. }
  2573. //#endregion
  2574. //#region src/router.ts
  2575. /**
  2576. * Creates a Router instance that can be used by a Vue app.
  2577. *
  2578. * @param options - {@link RouterOptions}
  2579. */
  2580. function createRouter(options) {
  2581. const matcher = createRouterMatcher(options.routes, options);
  2582. const parseQuery$1 = options.parseQuery || parseQuery;
  2583. const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
  2584. const routerHistory = options.history;
  2585. if (!routerHistory) throw new Error("Provide the \"history\" option when calling \"createRouter()\": https://router.vuejs.org/api/interfaces/RouterOptions.html#history");
  2586. const beforeGuards = useCallbacks();
  2587. const beforeResolveGuards = useCallbacks();
  2588. const afterGuards = useCallbacks();
  2589. const currentRoute = (0, vue.shallowRef)(START_LOCATION_NORMALIZED);
  2590. let pendingLocation = START_LOCATION_NORMALIZED;
  2591. if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) history.scrollRestoration = "manual";
  2592. const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
  2593. const encodeParams = applyToParams.bind(null, encodeParam);
  2594. const decodeParams = applyToParams.bind(null, decode);
  2595. function addRoute(parentOrRoute, route) {
  2596. let parent;
  2597. let record;
  2598. if (isRouteName(parentOrRoute)) {
  2599. parent = matcher.getRecordMatcher(parentOrRoute);
  2600. if (!parent) warn(`Parent route "${String(parentOrRoute)}" not found when adding child route`, route);
  2601. record = route;
  2602. } else record = parentOrRoute;
  2603. return matcher.addRoute(record, parent);
  2604. }
  2605. function removeRoute(name) {
  2606. const recordMatcher = matcher.getRecordMatcher(name);
  2607. if (recordMatcher) matcher.removeRoute(recordMatcher);
  2608. else warn(`Cannot remove non-existent route "${String(name)}"`);
  2609. }
  2610. function getRoutes() {
  2611. return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
  2612. }
  2613. function hasRoute(name) {
  2614. return !!matcher.getRecordMatcher(name);
  2615. }
  2616. function resolve(rawLocation, currentLocation) {
  2617. currentLocation = assign({}, currentLocation || currentRoute.value);
  2618. if (typeof rawLocation === "string") {
  2619. const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
  2620. const matchedRoute$1 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
  2621. const href$1 = routerHistory.createHref(locationNormalized.fullPath);
  2622. if (href$1.startsWith("//")) warn(`Location "${rawLocation}" resolved to "${href$1}". A resolved location cannot start with multiple slashes.`);
  2623. else if (!matchedRoute$1.matched.length) warn(`No match found for location with path "${rawLocation}"`);
  2624. return assign(locationNormalized, matchedRoute$1, {
  2625. params: decodeParams(matchedRoute$1.params),
  2626. hash: decode(locationNormalized.hash),
  2627. redirectedFrom: void 0,
  2628. href: href$1
  2629. });
  2630. }
  2631. if (!isRouteLocation(rawLocation)) {
  2632. warn(`router.resolve() was passed an invalid location. This will fail in production.\n- Location:`, rawLocation);
  2633. return resolve({});
  2634. }
  2635. let matcherLocation;
  2636. if (rawLocation.path != null) {
  2637. if ("params" in rawLocation && !("name" in rawLocation) && Object.keys(rawLocation.params).length) warn(`Path "${rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
  2638. matcherLocation = assign({}, rawLocation, { path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path });
  2639. } else {
  2640. const targetParams = assign({}, rawLocation.params);
  2641. for (const key in targetParams) if (targetParams[key] == null) delete targetParams[key];
  2642. matcherLocation = assign({}, rawLocation, { params: encodeParams(targetParams) });
  2643. currentLocation.params = encodeParams(currentLocation.params);
  2644. }
  2645. const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
  2646. const hash = rawLocation.hash || "";
  2647. if (hash && !hash.startsWith("#")) warn(`A \`hash\` should always start with the character "#". Replace "${hash}" with "#${hash}".`);
  2648. matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
  2649. const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
  2650. hash: encodeHash(hash),
  2651. path: matchedRoute.path
  2652. }));
  2653. const href = routerHistory.createHref(fullPath);
  2654. if (href.startsWith("//")) warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
  2655. else if (!matchedRoute.matched.length) warn(`No match found for location with path "${rawLocation.path != null ? rawLocation.path : rawLocation}"`);
  2656. return assign({
  2657. fullPath,
  2658. hash,
  2659. query: stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
  2660. }, matchedRoute, {
  2661. redirectedFrom: void 0,
  2662. href
  2663. });
  2664. }
  2665. function locationAsObject(to) {
  2666. return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
  2667. }
  2668. function checkCanceledNavigation(to, from) {
  2669. if (pendingLocation !== to) return createRouterError(ErrorTypes.NAVIGATION_CANCELLED, {
  2670. from,
  2671. to
  2672. });
  2673. }
  2674. function push(to) {
  2675. return pushWithRedirect(to);
  2676. }
  2677. function replace(to) {
  2678. return push(assign(locationAsObject(to), { replace: true }));
  2679. }
  2680. function handleRedirectRecord(to, from) {
  2681. const lastMatched = to.matched[to.matched.length - 1];
  2682. if (lastMatched && lastMatched.redirect) {
  2683. const { redirect } = lastMatched;
  2684. let newTargetLocation = typeof redirect === "function" ? redirect(to, from) : redirect;
  2685. if (typeof newTargetLocation === "string") {
  2686. newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : { path: newTargetLocation };
  2687. newTargetLocation.params = {};
  2688. }
  2689. if (newTargetLocation.path == null && !("name" in newTargetLocation)) {
  2690. warn(`Invalid redirect found:\n${JSON.stringify(newTargetLocation, null, 2)}\n when navigating to "${to.fullPath}". A redirect must contain a name or path. This will break in production.`);
  2691. throw new Error("Invalid redirect");
  2692. }
  2693. return assign({
  2694. query: to.query,
  2695. hash: to.hash,
  2696. params: newTargetLocation.path != null ? {} : to.params
  2697. }, newTargetLocation);
  2698. }
  2699. }
  2700. function pushWithRedirect(to, redirectedFrom) {
  2701. const targetLocation = pendingLocation = resolve(to);
  2702. const from = currentRoute.value;
  2703. const data = to.state;
  2704. const force = to.force;
  2705. const replace$1 = to.replace === true;
  2706. const shouldRedirect = handleRedirectRecord(targetLocation, from);
  2707. if (shouldRedirect) return pushWithRedirect(assign(locationAsObject(shouldRedirect), {
  2708. state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
  2709. force,
  2710. replace: replace$1
  2711. }), redirectedFrom || targetLocation);
  2712. const toLocation = targetLocation;
  2713. toLocation.redirectedFrom = redirectedFrom;
  2714. let failure;
  2715. if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
  2716. failure = createRouterError(ErrorTypes.NAVIGATION_DUPLICATED, {
  2717. to: toLocation,
  2718. from
  2719. });
  2720. handleScroll(from, from, true, false);
  2721. }
  2722. return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? isNavigationFailure(error, ErrorTypes.NAVIGATION_GUARD_REDIRECT) ? error : markAsReady(error) : triggerError(error, toLocation, from)).then((failure$1) => {
  2723. if (failure$1) {
  2724. if (isNavigationFailure(failure$1, ErrorTypes.NAVIGATION_GUARD_REDIRECT)) {
  2725. if (isSameRouteLocation(stringifyQuery$1, resolve(failure$1.to), toLocation) && redirectedFrom && (redirectedFrom._count = redirectedFrom._count ? redirectedFrom._count + 1 : 1) > 30) {
  2726. warn(`Detected a possibly infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow.\n Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.`);
  2727. return Promise.reject(/* @__PURE__ */ new Error("Infinite redirect in navigation guard"));
  2728. }
  2729. return pushWithRedirect(assign({ replace: replace$1 }, locationAsObject(failure$1.to), {
  2730. state: typeof failure$1.to === "object" ? assign({}, data, failure$1.to.state) : data,
  2731. force
  2732. }), redirectedFrom || toLocation);
  2733. }
  2734. } else failure$1 = finalizeNavigation(toLocation, from, true, replace$1, data);
  2735. triggerAfterEach(toLocation, from, failure$1);
  2736. return failure$1;
  2737. });
  2738. }
  2739. /**
  2740. * Helper to reject and skip all navigation guards if a new navigation happened
  2741. * @param to
  2742. * @param from
  2743. */
  2744. function checkCanceledNavigationAndReject(to, from) {
  2745. const error = checkCanceledNavigation(to, from);
  2746. return error ? Promise.reject(error) : Promise.resolve();
  2747. }
  2748. function runWithContext(fn) {
  2749. const app = installedApps.values().next().value;
  2750. return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
  2751. }
  2752. function navigate(to, from) {
  2753. let guards;
  2754. const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
  2755. guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
  2756. for (const record of leavingRecords) record.leaveGuards.forEach((guard) => {
  2757. guards.push(guardToPromiseFn(guard, to, from));
  2758. });
  2759. const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
  2760. guards.push(canceledNavigationCheck);
  2761. return runGuardQueue(guards).then(() => {
  2762. guards = [];
  2763. for (const guard of beforeGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
  2764. guards.push(canceledNavigationCheck);
  2765. return runGuardQueue(guards);
  2766. }).then(() => {
  2767. guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
  2768. for (const record of updatingRecords) record.updateGuards.forEach((guard) => {
  2769. guards.push(guardToPromiseFn(guard, to, from));
  2770. });
  2771. guards.push(canceledNavigationCheck);
  2772. return runGuardQueue(guards);
  2773. }).then(() => {
  2774. guards = [];
  2775. for (const record of enteringRecords) if (record.beforeEnter) if (isArray(record.beforeEnter)) for (const beforeEnter of record.beforeEnter) guards.push(guardToPromiseFn(beforeEnter, to, from));
  2776. else guards.push(guardToPromiseFn(record.beforeEnter, to, from));
  2777. guards.push(canceledNavigationCheck);
  2778. return runGuardQueue(guards);
  2779. }).then(() => {
  2780. to.matched.forEach((record) => record.enterCallbacks = {});
  2781. guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
  2782. guards.push(canceledNavigationCheck);
  2783. return runGuardQueue(guards);
  2784. }).then(() => {
  2785. guards = [];
  2786. for (const guard of beforeResolveGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
  2787. guards.push(canceledNavigationCheck);
  2788. return runGuardQueue(guards);
  2789. }).catch((err) => isNavigationFailure(err, ErrorTypes.NAVIGATION_CANCELLED) ? err : Promise.reject(err));
  2790. }
  2791. function triggerAfterEach(to, from, failure) {
  2792. afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
  2793. }
  2794. /**
  2795. * - Cleans up any navigation guards
  2796. * - Changes the url if necessary
  2797. * - Calls the scrollBehavior
  2798. */
  2799. function finalizeNavigation(toLocation, from, isPush, replace$1, data) {
  2800. const error = checkCanceledNavigation(toLocation, from);
  2801. if (error) return error;
  2802. const isFirstNavigation = from === START_LOCATION_NORMALIZED;
  2803. const state = !isBrowser ? {} : history.state;
  2804. if (isPush) if (replace$1 || isFirstNavigation) routerHistory.replace(toLocation.fullPath, assign({ scroll: isFirstNavigation && state && state.scroll }, data));
  2805. else routerHistory.push(toLocation.fullPath, data);
  2806. currentRoute.value = toLocation;
  2807. handleScroll(toLocation, from, isPush, isFirstNavigation);
  2808. markAsReady();
  2809. }
  2810. let removeHistoryListener;
  2811. function setupListeners() {
  2812. if (removeHistoryListener) return;
  2813. removeHistoryListener = routerHistory.listen((to, _from, info) => {
  2814. if (!router.listening) return;
  2815. const toLocation = resolve(to);
  2816. const shouldRedirect = handleRedirectRecord(toLocation, router.currentRoute.value);
  2817. if (shouldRedirect) {
  2818. pushWithRedirect(assign(shouldRedirect, {
  2819. replace: true,
  2820. force: true
  2821. }), toLocation).catch(noop);
  2822. return;
  2823. }
  2824. pendingLocation = toLocation;
  2825. const from = currentRoute.value;
  2826. if (isBrowser) saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
  2827. navigate(toLocation, from).catch((error) => {
  2828. if (isNavigationFailure(error, ErrorTypes.NAVIGATION_ABORTED | ErrorTypes.NAVIGATION_CANCELLED)) return error;
  2829. if (isNavigationFailure(error, ErrorTypes.NAVIGATION_GUARD_REDIRECT)) {
  2830. pushWithRedirect(assign(locationAsObject(error.to), { force: true }), toLocation).then((failure) => {
  2831. if (isNavigationFailure(failure, ErrorTypes.NAVIGATION_ABORTED | ErrorTypes.NAVIGATION_DUPLICATED) && !info.delta && info.type === NavigationType.pop) routerHistory.go(-1, false);
  2832. }).catch(noop);
  2833. return Promise.reject();
  2834. }
  2835. if (info.delta) routerHistory.go(-info.delta, false);
  2836. return triggerError(error, toLocation, from);
  2837. }).then((failure) => {
  2838. failure = failure || finalizeNavigation(toLocation, from, false);
  2839. if (failure) {
  2840. if (info.delta && !isNavigationFailure(failure, ErrorTypes.NAVIGATION_CANCELLED)) routerHistory.go(-info.delta, false);
  2841. else if (info.type === NavigationType.pop && isNavigationFailure(failure, ErrorTypes.NAVIGATION_ABORTED | ErrorTypes.NAVIGATION_DUPLICATED)) routerHistory.go(-1, false);
  2842. }
  2843. triggerAfterEach(toLocation, from, failure);
  2844. }).catch(noop);
  2845. });
  2846. }
  2847. let readyHandlers = useCallbacks();
  2848. let errorListeners = useCallbacks();
  2849. let ready;
  2850. /**
  2851. * Trigger errorListeners added via onError and throws the error as well
  2852. *
  2853. * @param error - error to throw
  2854. * @param to - location we were navigating to when the error happened
  2855. * @param from - location we were navigating from when the error happened
  2856. * @returns the error as a rejected promise
  2857. */
  2858. function triggerError(error, to, from) {
  2859. markAsReady(error);
  2860. const list = errorListeners.list();
  2861. if (list.length) list.forEach((handler) => handler(error, to, from));
  2862. else {
  2863. warn("uncaught error during route navigation:");
  2864. console.error(error);
  2865. }
  2866. return Promise.reject(error);
  2867. }
  2868. function isReady() {
  2869. if (ready && currentRoute.value !== START_LOCATION_NORMALIZED) return Promise.resolve();
  2870. return new Promise((resolve$1, reject) => {
  2871. readyHandlers.add([resolve$1, reject]);
  2872. });
  2873. }
  2874. function markAsReady(err) {
  2875. if (!ready) {
  2876. ready = !err;
  2877. setupListeners();
  2878. readyHandlers.list().forEach(([resolve$1, reject]) => err ? reject(err) : resolve$1());
  2879. readyHandlers.reset();
  2880. }
  2881. return err;
  2882. }
  2883. function handleScroll(to, from, isPush, isFirstNavigation) {
  2884. const { scrollBehavior } = options;
  2885. if (!isBrowser || !scrollBehavior) return Promise.resolve();
  2886. const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
  2887. return (0, vue.nextTick)().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
  2888. }
  2889. const go = (delta) => routerHistory.go(delta);
  2890. let started;
  2891. const installedApps = /* @__PURE__ */ new Set();
  2892. const router = {
  2893. currentRoute,
  2894. listening: true,
  2895. addRoute,
  2896. removeRoute,
  2897. clearRoutes: matcher.clearRoutes,
  2898. hasRoute,
  2899. getRoutes,
  2900. resolve,
  2901. options,
  2902. push,
  2903. replace,
  2904. go,
  2905. back: () => go(-1),
  2906. forward: () => go(1),
  2907. beforeEach: beforeGuards.add,
  2908. beforeResolve: beforeResolveGuards.add,
  2909. afterEach: afterGuards.add,
  2910. onError: errorListeners.add,
  2911. isReady,
  2912. install(app) {
  2913. app.component("RouterLink", RouterLink);
  2914. app.component("RouterView", RouterView);
  2915. app.config.globalProperties.$router = router;
  2916. Object.defineProperty(app.config.globalProperties, "$route", {
  2917. enumerable: true,
  2918. get: () => (0, vue.unref)(currentRoute)
  2919. });
  2920. if (isBrowser && !started && currentRoute.value === START_LOCATION_NORMALIZED) {
  2921. started = true;
  2922. push(routerHistory.location).catch((err) => {
  2923. warn("Unexpected error when starting the router:", err);
  2924. });
  2925. }
  2926. const reactiveRoute = {};
  2927. for (const key in START_LOCATION_NORMALIZED) Object.defineProperty(reactiveRoute, key, {
  2928. get: () => currentRoute.value[key],
  2929. enumerable: true
  2930. });
  2931. app.provide(routerKey, router);
  2932. app.provide(routeLocationKey, (0, vue.shallowReactive)(reactiveRoute));
  2933. app.provide(routerViewLocationKey, currentRoute);
  2934. const unmountApp = app.unmount;
  2935. installedApps.add(app);
  2936. app.unmount = function() {
  2937. installedApps.delete(app);
  2938. if (installedApps.size < 1) {
  2939. pendingLocation = START_LOCATION_NORMALIZED;
  2940. removeHistoryListener && removeHistoryListener();
  2941. removeHistoryListener = null;
  2942. currentRoute.value = START_LOCATION_NORMALIZED;
  2943. started = false;
  2944. ready = false;
  2945. }
  2946. unmountApp();
  2947. };
  2948. if (isBrowser) addDevtools(app, router, matcher);
  2949. }
  2950. };
  2951. function runGuardQueue(guards) {
  2952. return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
  2953. }
  2954. return router;
  2955. }
  2956. //#endregion
  2957. //#region src/useApi.ts
  2958. /**
  2959. * Returns the router instance. Equivalent to using `$router` inside
  2960. * templates.
  2961. */
  2962. function useRouter() {
  2963. return (0, vue.inject)(routerKey);
  2964. }
  2965. /**
  2966. * Returns the current route location. Equivalent to using `$route` inside
  2967. * templates.
  2968. */
  2969. function useRoute(_name) {
  2970. return (0, vue.inject)(routeLocationKey);
  2971. }
  2972. //#endregion
  2973. exports.NavigationFailureType = NavigationFailureType;
  2974. exports.RouterLink = RouterLink;
  2975. exports.RouterView = RouterView;
  2976. exports.START_LOCATION = START_LOCATION_NORMALIZED;
  2977. exports.createMemoryHistory = createMemoryHistory;
  2978. exports.createRouter = createRouter;
  2979. exports.createRouterMatcher = createRouterMatcher;
  2980. exports.createWebHashHistory = createWebHashHistory;
  2981. exports.createWebHistory = createWebHistory;
  2982. exports.isNavigationFailure = isNavigationFailure;
  2983. exports.loadRouteLocation = loadRouteLocation;
  2984. exports.matchedRouteKey = matchedRouteKey;
  2985. exports.onBeforeRouteLeave = onBeforeRouteLeave;
  2986. exports.onBeforeRouteUpdate = onBeforeRouteUpdate;
  2987. exports.parseQuery = parseQuery;
  2988. exports.routeLocationKey = routeLocationKey;
  2989. exports.routerKey = routerKey;
  2990. exports.routerViewLocationKey = routerViewLocationKey;
  2991. exports.stringifyQuery = stringifyQuery;
  2992. exports.useLink = useLink;
  2993. exports.useRoute = useRoute;
  2994. exports.useRouter = useRouter;
  2995. exports.viewDepthKey = viewDepthKey;
  2996. return exports;
  2997. })({}, Vue);