create-bc-app 1.0.9 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/index.mjs +9 -9
  2. package/package.json +37 -32
  3. package/template-docs-vitepress/.vitepress/cache/deps/@theme_index.js +259 -0
  4. package/template-docs-vitepress/.vitepress/cache/deps/@theme_index.js.map +7 -0
  5. package/template-docs-vitepress/.vitepress/cache/deps/_metadata.json +40 -0
  6. package/template-docs-vitepress/.vitepress/cache/deps/chunk-2MKPR7PC.js +9172 -0
  7. package/template-docs-vitepress/.vitepress/cache/deps/chunk-2MKPR7PC.js.map +7 -0
  8. package/template-docs-vitepress/.vitepress/cache/deps/chunk-ZXJI2PUM.js +11482 -0
  9. package/template-docs-vitepress/.vitepress/cache/deps/chunk-ZXJI2PUM.js.map +7 -0
  10. package/template-docs-vitepress/.vitepress/cache/deps/package.json +3 -0
  11. package/template-docs-vitepress/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4347 -0
  12. package/template-docs-vitepress/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  13. package/template-docs-vitepress/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
  14. package/template-docs-vitepress/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  15. package/template-docs-vitepress/.vitepress/cache/deps/vue.js +323 -0
  16. package/template-docs-vitepress/.vitepress/cache/deps/vue.js.map +7 -0
  17. package/template-docs-vitepress/.vitepress/config.mts +28 -0
  18. package/template-docs-vitepress/api-examples.md +49 -0
  19. package/template-docs-vitepress/index.md +25 -0
  20. package/template-docs-vitepress/markdown-examples.md +85 -0
  21. package/template-docs-vitepress/package-lock.json +1742 -0
  22. package/template-docs-vitepress/package.json +10 -0
  23. package/template-docs-vuepress/docs/.vuepress/.cache/deps/@vue_devtools-api.js +11 -0
  24. package/template-docs-vuepress/docs/.vuepress/.cache/deps/@vue_devtools-api.js.map +7 -0
  25. package/template-docs-vuepress/docs/.vuepress/.cache/deps/@vuepress_shared.js +136 -0
  26. package/template-docs-vuepress/docs/.vuepress/.cache/deps/@vuepress_shared.js.map +7 -0
  27. package/template-docs-vuepress/docs/.vuepress/.cache/deps/_metadata.json +40 -0
  28. package/template-docs-vuepress/docs/.vuepress/.cache/deps/chunk-5K23BRP6.js +11482 -0
  29. package/template-docs-vuepress/docs/.vuepress/.cache/deps/chunk-5K23BRP6.js.map +7 -0
  30. package/template-docs-vuepress/docs/.vuepress/.cache/deps/chunk-UKCZNIRO.js +164 -0
  31. package/template-docs-vuepress/docs/.vuepress/.cache/deps/chunk-UKCZNIRO.js.map +7 -0
  32. package/template-docs-vuepress/docs/.vuepress/.cache/deps/package.json +3 -0
  33. package/template-docs-vuepress/docs/.vuepress/.cache/deps/vue-router.js +2744 -0
  34. package/template-docs-vuepress/docs/.vuepress/.cache/deps/vue-router.js.map +7 -0
  35. package/template-docs-vuepress/docs/.vuepress/.cache/deps/vue.js +323 -0
  36. package/template-docs-vuepress/docs/.vuepress/.cache/deps/vue.js.map +7 -0
  37. package/template-docs-vuepress/docs/.vuepress/.temp/internal/clientConfigs.js +19 -0
  38. package/template-docs-vuepress/docs/.vuepress/.temp/internal/routes.js +24 -0
  39. package/template-docs-vuepress/docs/.vuepress/.temp/internal/siteData.js +14 -0
  40. package/template-docs-vuepress/docs/.vuepress/.temp/internal/themeData.js +14 -0
  41. package/template-docs-vuepress/docs/.vuepress/.temp/pages/404.html.js +16 -0
  42. package/template-docs-vuepress/docs/.vuepress/.temp/pages/404.html.vue +4 -0
  43. package/template-docs-vuepress/docs/.vuepress/.temp/pages/get-started.html.js +16 -0
  44. package/template-docs-vuepress/docs/.vuepress/.temp/pages/get-started.html.vue +23 -0
  45. package/template-docs-vuepress/docs/.vuepress/.temp/pages/index.html.js +16 -0
  46. package/template-docs-vuepress/docs/.vuepress/.temp/pages/index.html.vue +4 -0
  47. package/template-docs-vuepress/docs/.vuepress/.temp/prismjs/config.js +3 -0
  48. package/template-docs-vuepress/docs/.vuepress/.temp/styles/index.scss +0 -0
  49. package/template-docs-vuepress/docs/.vuepress/.temp/styles/palette.scss +0 -0
  50. package/template-docs-vuepress/docs/.vuepress/.temp/vite-root/index.html +13 -0
  51. package/template-docs-vuepress/docs/.vuepress/config.js +18 -0
  52. package/template-docs-vuepress/docs/README.md +33 -0
  53. package/template-docs-vuepress/docs/get-started.md +46 -0
  54. package/template-docs-vuepress/package-lock.json +3380 -0
  55. package/template-docs-vuepress/package.json +19 -0
  56. package/template-protocut-2d/.eslintrc.cjs +203 -0
  57. package/template-protocut-2d/.gitignore +24 -0
  58. package/template-protocut-2d/.gitlab-ci.yml +41 -0
  59. package/template-protocut-2d/README.md +17 -0
  60. package/template-protocut-2d/image.png +0 -0
  61. package/template-protocut-2d/index.html +13 -0
  62. package/template-protocut-2d/package-lock.json +4917 -0
  63. package/template-protocut-2d/package.json +41 -0
  64. package/template-protocut-2d/public/vite.svg +1 -0
  65. package/template-protocut-2d/src/App.vue +12 -0
  66. package/template-protocut-2d/src/assets/vue.svg +1 -0
  67. package/template-protocut-2d/src/components/Example.vue +36 -0
  68. package/template-protocut-2d/src/main.ts +43 -0
  69. package/template-protocut-2d/src/style.css +5 -0
  70. package/template-protocut-2d/src/utils/plugins/watchNodeModules.js +24 -0
  71. package/template-protocut-2d/src/views/Home.vue +143 -0
  72. package/template-protocut-2d/src/vite-env.d.ts +1 -0
  73. package/template-protocut-2d/test/App.test.ts +16 -0
  74. package/template-protocut-2d/test/Example.test.ts +21 -0
  75. package/template-protocut-2d/tsconfig.app.json +27 -0
  76. package/template-protocut-2d/tsconfig.json +33 -0
  77. package/template-protocut-2d/tsconfig.node.json +11 -0
  78. package/template-protocut-2d/vite-env.d.ts +15 -0
  79. package/template-protocut-2d/vite.config.ts +55 -0
  80. package/template-protocut-2d/window.d.ts +6 -0
@@ -0,0 +1,2744 @@
1
+ import {
2
+ setupDevtoolsPlugin
3
+ } from "./chunk-UKCZNIRO.js";
4
+ import {
5
+ computed,
6
+ defineComponent,
7
+ getCurrentInstance,
8
+ h,
9
+ inject,
10
+ nextTick,
11
+ onActivated,
12
+ onDeactivated,
13
+ onUnmounted,
14
+ provide,
15
+ reactive,
16
+ ref,
17
+ shallowReactive,
18
+ shallowRef,
19
+ unref,
20
+ watch,
21
+ watchEffect
22
+ } from "./chunk-5K23BRP6.js";
23
+
24
+ // node_modules/vue-router/dist/vue-router.mjs
25
+ var isBrowser = typeof document !== "undefined";
26
+ function isESModule(obj) {
27
+ return obj.__esModule || obj[Symbol.toStringTag] === "Module";
28
+ }
29
+ var assign = Object.assign;
30
+ function applyToParams(fn, params) {
31
+ const newParams = {};
32
+ for (const key in params) {
33
+ const value = params[key];
34
+ newParams[key] = isArray(value) ? value.map(fn) : fn(value);
35
+ }
36
+ return newParams;
37
+ }
38
+ var noop = () => {
39
+ };
40
+ var isArray = Array.isArray;
41
+ function warn(msg) {
42
+ const args = Array.from(arguments).slice(1);
43
+ console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
44
+ }
45
+ var HASH_RE = /#/g;
46
+ var AMPERSAND_RE = /&/g;
47
+ var SLASH_RE = /\//g;
48
+ var EQUAL_RE = /=/g;
49
+ var IM_RE = /\?/g;
50
+ var PLUS_RE = /\+/g;
51
+ var ENC_BRACKET_OPEN_RE = /%5B/g;
52
+ var ENC_BRACKET_CLOSE_RE = /%5D/g;
53
+ var ENC_CARET_RE = /%5E/g;
54
+ var ENC_BACKTICK_RE = /%60/g;
55
+ var ENC_CURLY_OPEN_RE = /%7B/g;
56
+ var ENC_PIPE_RE = /%7C/g;
57
+ var ENC_CURLY_CLOSE_RE = /%7D/g;
58
+ var ENC_SPACE_RE = /%20/g;
59
+ function commonEncode(text) {
60
+ return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
61
+ }
62
+ function encodeHash(text) {
63
+ return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
64
+ }
65
+ function encodeQueryValue(text) {
66
+ 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, "^");
67
+ }
68
+ function encodeQueryKey(text) {
69
+ return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
70
+ }
71
+ function encodePath(text) {
72
+ return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
73
+ }
74
+ function encodeParam(text) {
75
+ return text == null ? "" : encodePath(text).replace(SLASH_RE, "%2F");
76
+ }
77
+ function decode(text) {
78
+ try {
79
+ return decodeURIComponent("" + text);
80
+ } catch (err) {
81
+ warn(`Error decoding "${text}". Using original value`);
82
+ }
83
+ return "" + text;
84
+ }
85
+ var TRAILING_SLASH_RE = /\/$/;
86
+ var removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
87
+ function parseURL(parseQuery2, location2, currentLocation = "/") {
88
+ let path, query = {}, searchString = "", hash = "";
89
+ const hashPos = location2.indexOf("#");
90
+ let searchPos = location2.indexOf("?");
91
+ if (hashPos < searchPos && hashPos >= 0) {
92
+ searchPos = -1;
93
+ }
94
+ if (searchPos > -1) {
95
+ path = location2.slice(0, searchPos);
96
+ searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
97
+ query = parseQuery2(searchString);
98
+ }
99
+ if (hashPos > -1) {
100
+ path = path || location2.slice(0, hashPos);
101
+ hash = location2.slice(hashPos, location2.length);
102
+ }
103
+ path = resolveRelativePath(path != null ? path : location2, currentLocation);
104
+ return {
105
+ fullPath: path + (searchString && "?") + searchString + hash,
106
+ path,
107
+ query,
108
+ hash: decode(hash)
109
+ };
110
+ }
111
+ function stringifyURL(stringifyQuery2, location2) {
112
+ const query = location2.query ? stringifyQuery2(location2.query) : "";
113
+ return location2.path + (query && "?") + query + (location2.hash || "");
114
+ }
115
+ function stripBase(pathname, base) {
116
+ if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
117
+ return pathname;
118
+ return pathname.slice(base.length) || "/";
119
+ }
120
+ function isSameRouteLocation(stringifyQuery2, a, b) {
121
+ const aLastIndex = a.matched.length - 1;
122
+ const bLastIndex = b.matched.length - 1;
123
+ return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery2(a.query) === stringifyQuery2(b.query) && a.hash === b.hash;
124
+ }
125
+ function isSameRouteRecord(a, b) {
126
+ return (a.aliasOf || a) === (b.aliasOf || b);
127
+ }
128
+ function isSameRouteLocationParams(a, b) {
129
+ if (Object.keys(a).length !== Object.keys(b).length)
130
+ return false;
131
+ for (const key in a) {
132
+ if (!isSameRouteLocationParamsValue(a[key], b[key]))
133
+ return false;
134
+ }
135
+ return true;
136
+ }
137
+ function isSameRouteLocationParamsValue(a, b) {
138
+ return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a === b;
139
+ }
140
+ function isEquivalentArray(a, b) {
141
+ return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
142
+ }
143
+ function resolveRelativePath(to, from) {
144
+ if (to.startsWith("/"))
145
+ return to;
146
+ if (!from.startsWith("/")) {
147
+ warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to}" from "${from}". It should look like "/${from}".`);
148
+ return to;
149
+ }
150
+ if (!to)
151
+ return from;
152
+ const fromSegments = from.split("/");
153
+ const toSegments = to.split("/");
154
+ const lastToSegment = toSegments[toSegments.length - 1];
155
+ if (lastToSegment === ".." || lastToSegment === ".") {
156
+ toSegments.push("");
157
+ }
158
+ let position = fromSegments.length - 1;
159
+ let toPosition;
160
+ let segment;
161
+ for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
162
+ segment = toSegments[toPosition];
163
+ if (segment === ".")
164
+ continue;
165
+ if (segment === "..") {
166
+ if (position > 1)
167
+ position--;
168
+ } else
169
+ break;
170
+ }
171
+ return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
172
+ }
173
+ var START_LOCATION_NORMALIZED = {
174
+ path: "/",
175
+ // TODO: could we use a symbol in the future?
176
+ name: void 0,
177
+ params: {},
178
+ query: {},
179
+ hash: "",
180
+ fullPath: "/",
181
+ matched: [],
182
+ meta: {},
183
+ redirectedFrom: void 0
184
+ };
185
+ var NavigationType;
186
+ (function(NavigationType2) {
187
+ NavigationType2["pop"] = "pop";
188
+ NavigationType2["push"] = "push";
189
+ })(NavigationType || (NavigationType = {}));
190
+ var NavigationDirection;
191
+ (function(NavigationDirection2) {
192
+ NavigationDirection2["back"] = "back";
193
+ NavigationDirection2["forward"] = "forward";
194
+ NavigationDirection2["unknown"] = "";
195
+ })(NavigationDirection || (NavigationDirection = {}));
196
+ var START = "";
197
+ function normalizeBase(base) {
198
+ if (!base) {
199
+ if (isBrowser) {
200
+ const baseEl = document.querySelector("base");
201
+ base = baseEl && baseEl.getAttribute("href") || "/";
202
+ base = base.replace(/^\w+:\/\/[^\/]+/, "");
203
+ } else {
204
+ base = "/";
205
+ }
206
+ }
207
+ if (base[0] !== "/" && base[0] !== "#")
208
+ base = "/" + base;
209
+ return removeTrailingSlash(base);
210
+ }
211
+ var BEFORE_HASH_RE = /^[^#]+#/;
212
+ function createHref(base, location2) {
213
+ return base.replace(BEFORE_HASH_RE, "#") + location2;
214
+ }
215
+ function getElementPosition(el, offset) {
216
+ const docRect = document.documentElement.getBoundingClientRect();
217
+ const elRect = el.getBoundingClientRect();
218
+ return {
219
+ behavior: offset.behavior,
220
+ left: elRect.left - docRect.left - (offset.left || 0),
221
+ top: elRect.top - docRect.top - (offset.top || 0)
222
+ };
223
+ }
224
+ var computeScrollPosition = () => ({
225
+ left: window.scrollX,
226
+ top: window.scrollY
227
+ });
228
+ function scrollToPosition(position) {
229
+ let scrollToOptions;
230
+ if ("el" in position) {
231
+ const positionEl = position.el;
232
+ const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
233
+ if (typeof position.el === "string") {
234
+ if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
235
+ try {
236
+ const foundEl = document.querySelector(position.el);
237
+ if (isIdSelector && foundEl) {
238
+ warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
239
+ return;
240
+ }
241
+ } catch (err) {
242
+ 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).`);
243
+ return;
244
+ }
245
+ }
246
+ }
247
+ const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
248
+ if (!el) {
249
+ warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
250
+ return;
251
+ }
252
+ scrollToOptions = getElementPosition(el, position);
253
+ } else {
254
+ scrollToOptions = position;
255
+ }
256
+ if ("scrollBehavior" in document.documentElement.style)
257
+ window.scrollTo(scrollToOptions);
258
+ else {
259
+ window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
260
+ }
261
+ }
262
+ function getScrollKey(path, delta) {
263
+ const position = history.state ? history.state.position - delta : -1;
264
+ return position + path;
265
+ }
266
+ var scrollPositions = /* @__PURE__ */ new Map();
267
+ function saveScrollPosition(key, scrollPosition) {
268
+ scrollPositions.set(key, scrollPosition);
269
+ }
270
+ function getSavedScrollPosition(key) {
271
+ const scroll = scrollPositions.get(key);
272
+ scrollPositions.delete(key);
273
+ return scroll;
274
+ }
275
+ var createBaseLocation = () => location.protocol + "//" + location.host;
276
+ function createCurrentLocation(base, location2) {
277
+ const { pathname, search, hash } = location2;
278
+ const hashPos = base.indexOf("#");
279
+ if (hashPos > -1) {
280
+ let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
281
+ let pathFromHash = hash.slice(slicePos);
282
+ if (pathFromHash[0] !== "/")
283
+ pathFromHash = "/" + pathFromHash;
284
+ return stripBase(pathFromHash, "");
285
+ }
286
+ const path = stripBase(pathname, base);
287
+ return path + search + hash;
288
+ }
289
+ function useHistoryListeners(base, historyState, currentLocation, replace) {
290
+ let listeners = [];
291
+ let teardowns = [];
292
+ let pauseState = null;
293
+ const popStateHandler = ({ state }) => {
294
+ const to = createCurrentLocation(base, location);
295
+ const from = currentLocation.value;
296
+ const fromState = historyState.value;
297
+ let delta = 0;
298
+ if (state) {
299
+ currentLocation.value = to;
300
+ historyState.value = state;
301
+ if (pauseState && pauseState === from) {
302
+ pauseState = null;
303
+ return;
304
+ }
305
+ delta = fromState ? state.position - fromState.position : 0;
306
+ } else {
307
+ replace(to);
308
+ }
309
+ listeners.forEach((listener) => {
310
+ listener(currentLocation.value, from, {
311
+ delta,
312
+ type: NavigationType.pop,
313
+ direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
314
+ });
315
+ });
316
+ };
317
+ function pauseListeners() {
318
+ pauseState = currentLocation.value;
319
+ }
320
+ function listen(callback) {
321
+ listeners.push(callback);
322
+ const teardown = () => {
323
+ const index = listeners.indexOf(callback);
324
+ if (index > -1)
325
+ listeners.splice(index, 1);
326
+ };
327
+ teardowns.push(teardown);
328
+ return teardown;
329
+ }
330
+ function beforeUnloadListener() {
331
+ const { history: history2 } = window;
332
+ if (!history2.state)
333
+ return;
334
+ history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
335
+ }
336
+ function destroy() {
337
+ for (const teardown of teardowns)
338
+ teardown();
339
+ teardowns = [];
340
+ window.removeEventListener("popstate", popStateHandler);
341
+ window.removeEventListener("beforeunload", beforeUnloadListener);
342
+ }
343
+ window.addEventListener("popstate", popStateHandler);
344
+ window.addEventListener("beforeunload", beforeUnloadListener, {
345
+ passive: true
346
+ });
347
+ return {
348
+ pauseListeners,
349
+ listen,
350
+ destroy
351
+ };
352
+ }
353
+ function buildState(back, current, forward, replaced = false, computeScroll = false) {
354
+ return {
355
+ back,
356
+ current,
357
+ forward,
358
+ replaced,
359
+ position: window.history.length,
360
+ scroll: computeScroll ? computeScrollPosition() : null
361
+ };
362
+ }
363
+ function useHistoryStateNavigation(base) {
364
+ const { history: history2, location: location2 } = window;
365
+ const currentLocation = {
366
+ value: createCurrentLocation(base, location2)
367
+ };
368
+ const historyState = { value: history2.state };
369
+ if (!historyState.value) {
370
+ changeLocation(currentLocation.value, {
371
+ back: null,
372
+ current: currentLocation.value,
373
+ forward: null,
374
+ // the length is off by one, we need to decrease it
375
+ position: history2.length - 1,
376
+ replaced: true,
377
+ // don't add a scroll as the user may have an anchor, and we want
378
+ // scrollBehavior to be triggered without a saved position
379
+ scroll: null
380
+ }, true);
381
+ }
382
+ function changeLocation(to, state, replace2) {
383
+ const hashIndex = base.indexOf("#");
384
+ const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
385
+ try {
386
+ history2[replace2 ? "replaceState" : "pushState"](state, "", url);
387
+ historyState.value = state;
388
+ } catch (err) {
389
+ if (true) {
390
+ warn("Error with push/replace State", err);
391
+ } else {
392
+ console.error(err);
393
+ }
394
+ location2[replace2 ? "replace" : "assign"](url);
395
+ }
396
+ }
397
+ function replace(to, data) {
398
+ const state = assign({}, history2.state, buildState(
399
+ historyState.value.back,
400
+ // keep back and forward entries but override current position
401
+ to,
402
+ historyState.value.forward,
403
+ true
404
+ ), data, { position: historyState.value.position });
405
+ changeLocation(to, state, true);
406
+ currentLocation.value = to;
407
+ }
408
+ function push(to, data) {
409
+ const currentState = assign(
410
+ {},
411
+ // use current history state to gracefully handle a wrong call to
412
+ // history.replaceState
413
+ // https://github.com/vuejs/router/issues/366
414
+ historyState.value,
415
+ history2.state,
416
+ {
417
+ forward: to,
418
+ scroll: computeScrollPosition()
419
+ }
420
+ );
421
+ if (!history2.state) {
422
+ 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:
423
+
424
+ history.replaceState(history.state, '', url)
425
+
426
+ You can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state`);
427
+ }
428
+ changeLocation(currentState.current, currentState, true);
429
+ const state = assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
430
+ changeLocation(to, state, false);
431
+ currentLocation.value = to;
432
+ }
433
+ return {
434
+ location: currentLocation,
435
+ state: historyState,
436
+ push,
437
+ replace
438
+ };
439
+ }
440
+ function createWebHistory(base) {
441
+ base = normalizeBase(base);
442
+ const historyNavigation = useHistoryStateNavigation(base);
443
+ const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
444
+ function go(delta, triggerListeners = true) {
445
+ if (!triggerListeners)
446
+ historyListeners.pauseListeners();
447
+ history.go(delta);
448
+ }
449
+ const routerHistory = assign({
450
+ // it's overridden right after
451
+ location: "",
452
+ base,
453
+ go,
454
+ createHref: createHref.bind(null, base)
455
+ }, historyNavigation, historyListeners);
456
+ Object.defineProperty(routerHistory, "location", {
457
+ enumerable: true,
458
+ get: () => historyNavigation.location.value
459
+ });
460
+ Object.defineProperty(routerHistory, "state", {
461
+ enumerable: true,
462
+ get: () => historyNavigation.state.value
463
+ });
464
+ return routerHistory;
465
+ }
466
+ function createMemoryHistory(base = "") {
467
+ let listeners = [];
468
+ let queue = [START];
469
+ let position = 0;
470
+ base = normalizeBase(base);
471
+ function setLocation(location2) {
472
+ position++;
473
+ if (position !== queue.length) {
474
+ queue.splice(position);
475
+ }
476
+ queue.push(location2);
477
+ }
478
+ function triggerListeners(to, from, { direction, delta }) {
479
+ const info = {
480
+ direction,
481
+ delta,
482
+ type: NavigationType.pop
483
+ };
484
+ for (const callback of listeners) {
485
+ callback(to, from, info);
486
+ }
487
+ }
488
+ const routerHistory = {
489
+ // rewritten by Object.defineProperty
490
+ location: START,
491
+ // TODO: should be kept in queue
492
+ state: {},
493
+ base,
494
+ createHref: createHref.bind(null, base),
495
+ replace(to) {
496
+ queue.splice(position--, 1);
497
+ setLocation(to);
498
+ },
499
+ push(to, data) {
500
+ setLocation(to);
501
+ },
502
+ listen(callback) {
503
+ listeners.push(callback);
504
+ return () => {
505
+ const index = listeners.indexOf(callback);
506
+ if (index > -1)
507
+ listeners.splice(index, 1);
508
+ };
509
+ },
510
+ destroy() {
511
+ listeners = [];
512
+ queue = [START];
513
+ position = 0;
514
+ },
515
+ go(delta, shouldTrigger = true) {
516
+ const from = this.location;
517
+ const direction = (
518
+ // we are considering delta === 0 going forward, but in abstract mode
519
+ // using 0 for the delta doesn't make sense like it does in html5 where
520
+ // it reloads the page
521
+ delta < 0 ? NavigationDirection.back : NavigationDirection.forward
522
+ );
523
+ position = Math.max(0, Math.min(position + delta, queue.length - 1));
524
+ if (shouldTrigger) {
525
+ triggerListeners(this.location, from, {
526
+ direction,
527
+ delta
528
+ });
529
+ }
530
+ }
531
+ };
532
+ Object.defineProperty(routerHistory, "location", {
533
+ enumerable: true,
534
+ get: () => queue[position]
535
+ });
536
+ return routerHistory;
537
+ }
538
+ function createWebHashHistory(base) {
539
+ base = location.host ? base || location.pathname + location.search : "";
540
+ if (!base.includes("#"))
541
+ base += "#";
542
+ if (!base.endsWith("#/") && !base.endsWith("#")) {
543
+ warn(`A hash base must end with a "#":
544
+ "${base}" should be "${base.replace(/#.*$/, "#")}".`);
545
+ }
546
+ return createWebHistory(base);
547
+ }
548
+ function isRouteLocation(route) {
549
+ return typeof route === "string" || route && typeof route === "object";
550
+ }
551
+ function isRouteName(name) {
552
+ return typeof name === "string" || typeof name === "symbol";
553
+ }
554
+ var NavigationFailureSymbol = Symbol(true ? "navigation failure" : "");
555
+ var NavigationFailureType;
556
+ (function(NavigationFailureType2) {
557
+ NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
558
+ NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
559
+ NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
560
+ })(NavigationFailureType || (NavigationFailureType = {}));
561
+ var ErrorTypeMessages = {
562
+ [
563
+ 1
564
+ /* ErrorTypes.MATCHER_NOT_FOUND */
565
+ ]({ location: location2, currentLocation }) {
566
+ return `No match for
567
+ ${JSON.stringify(location2)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
568
+ },
569
+ [
570
+ 2
571
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
572
+ ]({ from, to }) {
573
+ return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
574
+ },
575
+ [
576
+ 4
577
+ /* ErrorTypes.NAVIGATION_ABORTED */
578
+ ]({ from, to }) {
579
+ return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
580
+ },
581
+ [
582
+ 8
583
+ /* ErrorTypes.NAVIGATION_CANCELLED */
584
+ ]({ from, to }) {
585
+ return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
586
+ },
587
+ [
588
+ 16
589
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
590
+ ]({ from, to }) {
591
+ return `Avoided redundant navigation to current location: "${from.fullPath}".`;
592
+ }
593
+ };
594
+ function createRouterError(type, params) {
595
+ if (true) {
596
+ return assign(new Error(ErrorTypeMessages[type](params)), {
597
+ type,
598
+ [NavigationFailureSymbol]: true
599
+ }, params);
600
+ } else {
601
+ return assign(new Error(), {
602
+ type,
603
+ [NavigationFailureSymbol]: true
604
+ }, params);
605
+ }
606
+ }
607
+ function isNavigationFailure(error, type) {
608
+ return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
609
+ }
610
+ var propertiesToLog = ["params", "query", "hash"];
611
+ function stringifyRoute(to) {
612
+ if (typeof to === "string")
613
+ return to;
614
+ if (to.path != null)
615
+ return to.path;
616
+ const location2 = {};
617
+ for (const key of propertiesToLog) {
618
+ if (key in to)
619
+ location2[key] = to[key];
620
+ }
621
+ return JSON.stringify(location2, null, 2);
622
+ }
623
+ var BASE_PARAM_PATTERN = "[^/]+?";
624
+ var BASE_PATH_PARSER_OPTIONS = {
625
+ sensitive: false,
626
+ strict: false,
627
+ start: true,
628
+ end: true
629
+ };
630
+ var REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
631
+ function tokensToParser(segments, extraOptions) {
632
+ const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
633
+ const score = [];
634
+ let pattern = options.start ? "^" : "";
635
+ const keys = [];
636
+ for (const segment of segments) {
637
+ const segmentScores = segment.length ? [] : [
638
+ 90
639
+ /* PathScore.Root */
640
+ ];
641
+ if (options.strict && !segment.length)
642
+ pattern += "/";
643
+ for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
644
+ const token = segment[tokenIndex];
645
+ let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
646
+ if (token.type === 0) {
647
+ if (!tokenIndex)
648
+ pattern += "/";
649
+ pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
650
+ subSegmentScore += 40;
651
+ } else if (token.type === 1) {
652
+ const { value, repeatable, optional, regexp } = token;
653
+ keys.push({
654
+ name: value,
655
+ repeatable,
656
+ optional
657
+ });
658
+ const re2 = regexp ? regexp : BASE_PARAM_PATTERN;
659
+ if (re2 !== BASE_PARAM_PATTERN) {
660
+ subSegmentScore += 10;
661
+ try {
662
+ new RegExp(`(${re2})`);
663
+ } catch (err) {
664
+ throw new Error(`Invalid custom RegExp for param "${value}" (${re2}): ` + err.message);
665
+ }
666
+ }
667
+ let subPattern = repeatable ? `((?:${re2})(?:/(?:${re2}))*)` : `(${re2})`;
668
+ if (!tokenIndex)
669
+ subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
670
+ // or /:p?-:p2
671
+ optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
672
+ if (optional)
673
+ subPattern += "?";
674
+ pattern += subPattern;
675
+ subSegmentScore += 20;
676
+ if (optional)
677
+ subSegmentScore += -8;
678
+ if (repeatable)
679
+ subSegmentScore += -20;
680
+ if (re2 === ".*")
681
+ subSegmentScore += -50;
682
+ }
683
+ segmentScores.push(subSegmentScore);
684
+ }
685
+ score.push(segmentScores);
686
+ }
687
+ if (options.strict && options.end) {
688
+ const i = score.length - 1;
689
+ score[i][score[i].length - 1] += 0.7000000000000001;
690
+ }
691
+ if (!options.strict)
692
+ pattern += "/?";
693
+ if (options.end)
694
+ pattern += "$";
695
+ else if (options.strict)
696
+ pattern += "(?:/|$)";
697
+ const re = new RegExp(pattern, options.sensitive ? "" : "i");
698
+ function parse(path) {
699
+ const match = path.match(re);
700
+ const params = {};
701
+ if (!match)
702
+ return null;
703
+ for (let i = 1; i < match.length; i++) {
704
+ const value = match[i] || "";
705
+ const key = keys[i - 1];
706
+ params[key.name] = value && key.repeatable ? value.split("/") : value;
707
+ }
708
+ return params;
709
+ }
710
+ function stringify(params) {
711
+ let path = "";
712
+ let avoidDuplicatedSlash = false;
713
+ for (const segment of segments) {
714
+ if (!avoidDuplicatedSlash || !path.endsWith("/"))
715
+ path += "/";
716
+ avoidDuplicatedSlash = false;
717
+ for (const token of segment) {
718
+ if (token.type === 0) {
719
+ path += token.value;
720
+ } else if (token.type === 1) {
721
+ const { value, repeatable, optional } = token;
722
+ const param = value in params ? params[value] : "";
723
+ if (isArray(param) && !repeatable) {
724
+ throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
725
+ }
726
+ const text = isArray(param) ? param.join("/") : param;
727
+ if (!text) {
728
+ if (optional) {
729
+ if (segment.length < 2) {
730
+ if (path.endsWith("/"))
731
+ path = path.slice(0, -1);
732
+ else
733
+ avoidDuplicatedSlash = true;
734
+ }
735
+ } else
736
+ throw new Error(`Missing required param "${value}"`);
737
+ }
738
+ path += text;
739
+ }
740
+ }
741
+ }
742
+ return path || "/";
743
+ }
744
+ return {
745
+ re,
746
+ score,
747
+ keys,
748
+ parse,
749
+ stringify
750
+ };
751
+ }
752
+ function compareScoreArray(a, b) {
753
+ let i = 0;
754
+ while (i < a.length && i < b.length) {
755
+ const diff = b[i] - a[i];
756
+ if (diff)
757
+ return diff;
758
+ i++;
759
+ }
760
+ if (a.length < b.length) {
761
+ return a.length === 1 && a[0] === 40 + 40 ? -1 : 1;
762
+ } else if (a.length > b.length) {
763
+ return b.length === 1 && b[0] === 40 + 40 ? 1 : -1;
764
+ }
765
+ return 0;
766
+ }
767
+ function comparePathParserScore(a, b) {
768
+ let i = 0;
769
+ const aScore = a.score;
770
+ const bScore = b.score;
771
+ while (i < aScore.length && i < bScore.length) {
772
+ const comp = compareScoreArray(aScore[i], bScore[i]);
773
+ if (comp)
774
+ return comp;
775
+ i++;
776
+ }
777
+ if (Math.abs(bScore.length - aScore.length) === 1) {
778
+ if (isLastScoreNegative(aScore))
779
+ return 1;
780
+ if (isLastScoreNegative(bScore))
781
+ return -1;
782
+ }
783
+ return bScore.length - aScore.length;
784
+ }
785
+ function isLastScoreNegative(score) {
786
+ const last = score[score.length - 1];
787
+ return score.length > 0 && last[last.length - 1] < 0;
788
+ }
789
+ var ROOT_TOKEN = {
790
+ type: 0,
791
+ value: ""
792
+ };
793
+ var VALID_PARAM_RE = /[a-zA-Z0-9_]/;
794
+ function tokenizePath(path) {
795
+ if (!path)
796
+ return [[]];
797
+ if (path === "/")
798
+ return [[ROOT_TOKEN]];
799
+ if (!path.startsWith("/")) {
800
+ throw new Error(true ? `Route paths should start with a "/": "${path}" should be "/${path}".` : `Invalid path "${path}"`);
801
+ }
802
+ function crash(message) {
803
+ throw new Error(`ERR (${state})/"${buffer}": ${message}`);
804
+ }
805
+ let state = 0;
806
+ let previousState = state;
807
+ const tokens = [];
808
+ let segment;
809
+ function finalizeSegment() {
810
+ if (segment)
811
+ tokens.push(segment);
812
+ segment = [];
813
+ }
814
+ let i = 0;
815
+ let char;
816
+ let buffer = "";
817
+ let customRe = "";
818
+ function consumeBuffer() {
819
+ if (!buffer)
820
+ return;
821
+ if (state === 0) {
822
+ segment.push({
823
+ type: 0,
824
+ value: buffer
825
+ });
826
+ } else if (state === 1 || state === 2 || state === 3) {
827
+ if (segment.length > 1 && (char === "*" || char === "+"))
828
+ crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
829
+ segment.push({
830
+ type: 1,
831
+ value: buffer,
832
+ regexp: customRe,
833
+ repeatable: char === "*" || char === "+",
834
+ optional: char === "*" || char === "?"
835
+ });
836
+ } else {
837
+ crash("Invalid state to consume buffer");
838
+ }
839
+ buffer = "";
840
+ }
841
+ function addCharToBuffer() {
842
+ buffer += char;
843
+ }
844
+ while (i < path.length) {
845
+ char = path[i++];
846
+ if (char === "\\" && state !== 2) {
847
+ previousState = state;
848
+ state = 4;
849
+ continue;
850
+ }
851
+ switch (state) {
852
+ case 0:
853
+ if (char === "/") {
854
+ if (buffer) {
855
+ consumeBuffer();
856
+ }
857
+ finalizeSegment();
858
+ } else if (char === ":") {
859
+ consumeBuffer();
860
+ state = 1;
861
+ } else {
862
+ addCharToBuffer();
863
+ }
864
+ break;
865
+ case 4:
866
+ addCharToBuffer();
867
+ state = previousState;
868
+ break;
869
+ case 1:
870
+ if (char === "(") {
871
+ state = 2;
872
+ } else if (VALID_PARAM_RE.test(char)) {
873
+ addCharToBuffer();
874
+ } else {
875
+ consumeBuffer();
876
+ state = 0;
877
+ if (char !== "*" && char !== "?" && char !== "+")
878
+ i--;
879
+ }
880
+ break;
881
+ case 2:
882
+ if (char === ")") {
883
+ if (customRe[customRe.length - 1] == "\\")
884
+ customRe = customRe.slice(0, -1) + char;
885
+ else
886
+ state = 3;
887
+ } else {
888
+ customRe += char;
889
+ }
890
+ break;
891
+ case 3:
892
+ consumeBuffer();
893
+ state = 0;
894
+ if (char !== "*" && char !== "?" && char !== "+")
895
+ i--;
896
+ customRe = "";
897
+ break;
898
+ default:
899
+ crash("Unknown state");
900
+ break;
901
+ }
902
+ }
903
+ if (state === 2)
904
+ crash(`Unfinished custom RegExp for param "${buffer}"`);
905
+ consumeBuffer();
906
+ finalizeSegment();
907
+ return tokens;
908
+ }
909
+ function createRouteRecordMatcher(record, parent, options) {
910
+ const parser = tokensToParser(tokenizePath(record.path), options);
911
+ if (true) {
912
+ const existingKeys = /* @__PURE__ */ new Set();
913
+ for (const key of parser.keys) {
914
+ if (existingKeys.has(key.name))
915
+ warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
916
+ existingKeys.add(key.name);
917
+ }
918
+ }
919
+ const matcher = assign(parser, {
920
+ record,
921
+ parent,
922
+ // these needs to be populated by the parent
923
+ children: [],
924
+ alias: []
925
+ });
926
+ if (parent) {
927
+ if (!matcher.record.aliasOf === !parent.record.aliasOf)
928
+ parent.children.push(matcher);
929
+ }
930
+ return matcher;
931
+ }
932
+ function createRouterMatcher(routes, globalOptions) {
933
+ const matchers = [];
934
+ const matcherMap = /* @__PURE__ */ new Map();
935
+ globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
936
+ function getRecordMatcher(name) {
937
+ return matcherMap.get(name);
938
+ }
939
+ function addRoute(record, parent, originalRecord) {
940
+ const isRootAdd = !originalRecord;
941
+ const mainNormalizedRecord = normalizeRouteRecord(record);
942
+ if (true) {
943
+ checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
944
+ }
945
+ mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
946
+ const options = mergeOptions(globalOptions, record);
947
+ const normalizedRecords = [
948
+ mainNormalizedRecord
949
+ ];
950
+ if ("alias" in record) {
951
+ const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
952
+ for (const alias of aliases) {
953
+ normalizedRecords.push(assign({}, mainNormalizedRecord, {
954
+ // this allows us to hold a copy of the `components` option
955
+ // so that async components cache is hold on the original record
956
+ components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
957
+ path: alias,
958
+ // we might be the child of an alias
959
+ aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
960
+ // the aliases are always of the same kind as the original since they
961
+ // are defined on the same record
962
+ }));
963
+ }
964
+ }
965
+ let matcher;
966
+ let originalMatcher;
967
+ for (const normalizedRecord of normalizedRecords) {
968
+ const { path } = normalizedRecord;
969
+ if (parent && path[0] !== "/") {
970
+ const parentPath = parent.record.path;
971
+ const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
972
+ normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
973
+ }
974
+ if (normalizedRecord.path === "*") {
975
+ 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.');
976
+ }
977
+ matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
978
+ if (parent && path[0] === "/")
979
+ checkMissingParamsInAbsolutePath(matcher, parent);
980
+ if (originalRecord) {
981
+ originalRecord.alias.push(matcher);
982
+ if (true) {
983
+ checkSameParams(originalRecord, matcher);
984
+ }
985
+ } else {
986
+ originalMatcher = originalMatcher || matcher;
987
+ if (originalMatcher !== matcher)
988
+ originalMatcher.alias.push(matcher);
989
+ if (isRootAdd && record.name && !isAliasRecord(matcher))
990
+ removeRoute(record.name);
991
+ }
992
+ if (isMatchable(matcher)) {
993
+ insertMatcher(matcher);
994
+ }
995
+ if (mainNormalizedRecord.children) {
996
+ const children = mainNormalizedRecord.children;
997
+ for (let i = 0; i < children.length; i++) {
998
+ addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
999
+ }
1000
+ }
1001
+ originalRecord = originalRecord || matcher;
1002
+ }
1003
+ return originalMatcher ? () => {
1004
+ removeRoute(originalMatcher);
1005
+ } : noop;
1006
+ }
1007
+ function removeRoute(matcherRef) {
1008
+ if (isRouteName(matcherRef)) {
1009
+ const matcher = matcherMap.get(matcherRef);
1010
+ if (matcher) {
1011
+ matcherMap.delete(matcherRef);
1012
+ matchers.splice(matchers.indexOf(matcher), 1);
1013
+ matcher.children.forEach(removeRoute);
1014
+ matcher.alias.forEach(removeRoute);
1015
+ }
1016
+ } else {
1017
+ const index = matchers.indexOf(matcherRef);
1018
+ if (index > -1) {
1019
+ matchers.splice(index, 1);
1020
+ if (matcherRef.record.name)
1021
+ matcherMap.delete(matcherRef.record.name);
1022
+ matcherRef.children.forEach(removeRoute);
1023
+ matcherRef.alias.forEach(removeRoute);
1024
+ }
1025
+ }
1026
+ }
1027
+ function getRoutes() {
1028
+ return matchers;
1029
+ }
1030
+ function insertMatcher(matcher) {
1031
+ const index = findInsertionIndex(matcher, matchers);
1032
+ matchers.splice(index, 0, matcher);
1033
+ if (matcher.record.name && !isAliasRecord(matcher))
1034
+ matcherMap.set(matcher.record.name, matcher);
1035
+ }
1036
+ function resolve(location2, currentLocation) {
1037
+ let matcher;
1038
+ let params = {};
1039
+ let path;
1040
+ let name;
1041
+ if ("name" in location2 && location2.name) {
1042
+ matcher = matcherMap.get(location2.name);
1043
+ if (!matcher)
1044
+ throw createRouterError(1, {
1045
+ location: location2
1046
+ });
1047
+ if (true) {
1048
+ const invalidParams = Object.keys(location2.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
1049
+ if (invalidParams.length) {
1050
+ 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.`);
1051
+ }
1052
+ }
1053
+ name = matcher.record.name;
1054
+ params = assign(
1055
+ // paramsFromLocation is a new object
1056
+ paramsFromLocation(
1057
+ currentLocation.params,
1058
+ // only keep params that exist in the resolved location
1059
+ // only keep optional params coming from a parent record
1060
+ matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)
1061
+ ),
1062
+ // discard any existing params in the current location that do not exist here
1063
+ // #1497 this ensures better active/exact matching
1064
+ location2.params && paramsFromLocation(location2.params, matcher.keys.map((k) => k.name))
1065
+ );
1066
+ path = matcher.stringify(params);
1067
+ } else if (location2.path != null) {
1068
+ path = location2.path;
1069
+ if (!path.startsWith("/")) {
1070
+ 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.`);
1071
+ }
1072
+ matcher = matchers.find((m) => m.re.test(path));
1073
+ if (matcher) {
1074
+ params = matcher.parse(path);
1075
+ name = matcher.record.name;
1076
+ }
1077
+ } else {
1078
+ matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
1079
+ if (!matcher)
1080
+ throw createRouterError(1, {
1081
+ location: location2,
1082
+ currentLocation
1083
+ });
1084
+ name = matcher.record.name;
1085
+ params = assign({}, currentLocation.params, location2.params);
1086
+ path = matcher.stringify(params);
1087
+ }
1088
+ const matched = [];
1089
+ let parentMatcher = matcher;
1090
+ while (parentMatcher) {
1091
+ matched.unshift(parentMatcher.record);
1092
+ parentMatcher = parentMatcher.parent;
1093
+ }
1094
+ return {
1095
+ name,
1096
+ path,
1097
+ params,
1098
+ matched,
1099
+ meta: mergeMetaFields(matched)
1100
+ };
1101
+ }
1102
+ routes.forEach((route) => addRoute(route));
1103
+ function clearRoutes() {
1104
+ matchers.length = 0;
1105
+ matcherMap.clear();
1106
+ }
1107
+ return {
1108
+ addRoute,
1109
+ resolve,
1110
+ removeRoute,
1111
+ clearRoutes,
1112
+ getRoutes,
1113
+ getRecordMatcher
1114
+ };
1115
+ }
1116
+ function paramsFromLocation(params, keys) {
1117
+ const newParams = {};
1118
+ for (const key of keys) {
1119
+ if (key in params)
1120
+ newParams[key] = params[key];
1121
+ }
1122
+ return newParams;
1123
+ }
1124
+ function normalizeRouteRecord(record) {
1125
+ return {
1126
+ path: record.path,
1127
+ redirect: record.redirect,
1128
+ name: record.name,
1129
+ meta: record.meta || {},
1130
+ aliasOf: void 0,
1131
+ beforeEnter: record.beforeEnter,
1132
+ props: normalizeRecordProps(record),
1133
+ children: record.children || [],
1134
+ instances: {},
1135
+ leaveGuards: /* @__PURE__ */ new Set(),
1136
+ updateGuards: /* @__PURE__ */ new Set(),
1137
+ enterCallbacks: {},
1138
+ components: "components" in record ? record.components || null : record.component && { default: record.component }
1139
+ };
1140
+ }
1141
+ function normalizeRecordProps(record) {
1142
+ const propsObject = {};
1143
+ const props = record.props || false;
1144
+ if ("component" in record) {
1145
+ propsObject.default = props;
1146
+ } else {
1147
+ for (const name in record.components)
1148
+ propsObject[name] = typeof props === "object" ? props[name] : props;
1149
+ }
1150
+ return propsObject;
1151
+ }
1152
+ function isAliasRecord(record) {
1153
+ while (record) {
1154
+ if (record.record.aliasOf)
1155
+ return true;
1156
+ record = record.parent;
1157
+ }
1158
+ return false;
1159
+ }
1160
+ function mergeMetaFields(matched) {
1161
+ return matched.reduce((meta, record) => assign(meta, record.meta), {});
1162
+ }
1163
+ function mergeOptions(defaults, partialOptions) {
1164
+ const options = {};
1165
+ for (const key in defaults) {
1166
+ options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
1167
+ }
1168
+ return options;
1169
+ }
1170
+ function isSameParam(a, b) {
1171
+ return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
1172
+ }
1173
+ function checkSameParams(a, b) {
1174
+ for (const key of a.keys) {
1175
+ if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
1176
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1177
+ }
1178
+ for (const key of b.keys) {
1179
+ if (!key.optional && !a.keys.find(isSameParam.bind(null, key)))
1180
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1181
+ }
1182
+ }
1183
+ function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
1184
+ if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) {
1185
+ 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.`);
1186
+ }
1187
+ }
1188
+ function checkMissingParamsInAbsolutePath(record, parent) {
1189
+ for (const key of parent.keys) {
1190
+ if (!record.keys.find(isSameParam.bind(null, key)))
1191
+ return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
1192
+ }
1193
+ }
1194
+ function findInsertionIndex(matcher, matchers) {
1195
+ let lower = 0;
1196
+ let upper = matchers.length;
1197
+ while (lower !== upper) {
1198
+ const mid = lower + upper >> 1;
1199
+ const sortOrder = comparePathParserScore(matcher, matchers[mid]);
1200
+ if (sortOrder < 0) {
1201
+ upper = mid;
1202
+ } else {
1203
+ lower = mid + 1;
1204
+ }
1205
+ }
1206
+ const insertionAncestor = getInsertionAncestor(matcher);
1207
+ if (insertionAncestor) {
1208
+ upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
1209
+ if (upper < 0) {
1210
+ warn(`Finding ancestor route "${insertionAncestor.record.path}" failed for "${matcher.record.path}"`);
1211
+ }
1212
+ }
1213
+ return upper;
1214
+ }
1215
+ function getInsertionAncestor(matcher) {
1216
+ let ancestor = matcher;
1217
+ while (ancestor = ancestor.parent) {
1218
+ if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) {
1219
+ return ancestor;
1220
+ }
1221
+ }
1222
+ return;
1223
+ }
1224
+ function isMatchable({ record }) {
1225
+ return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
1226
+ }
1227
+ function parseQuery(search) {
1228
+ const query = {};
1229
+ if (search === "" || search === "?")
1230
+ return query;
1231
+ const hasLeadingIM = search[0] === "?";
1232
+ const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
1233
+ for (let i = 0; i < searchParams.length; ++i) {
1234
+ const searchParam = searchParams[i].replace(PLUS_RE, " ");
1235
+ const eqPos = searchParam.indexOf("=");
1236
+ const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
1237
+ const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
1238
+ if (key in query) {
1239
+ let currentValue = query[key];
1240
+ if (!isArray(currentValue)) {
1241
+ currentValue = query[key] = [currentValue];
1242
+ }
1243
+ currentValue.push(value);
1244
+ } else {
1245
+ query[key] = value;
1246
+ }
1247
+ }
1248
+ return query;
1249
+ }
1250
+ function stringifyQuery(query) {
1251
+ let search = "";
1252
+ for (let key in query) {
1253
+ const value = query[key];
1254
+ key = encodeQueryKey(key);
1255
+ if (value == null) {
1256
+ if (value !== void 0) {
1257
+ search += (search.length ? "&" : "") + key;
1258
+ }
1259
+ continue;
1260
+ }
1261
+ const values = isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)];
1262
+ values.forEach((value2) => {
1263
+ if (value2 !== void 0) {
1264
+ search += (search.length ? "&" : "") + key;
1265
+ if (value2 != null)
1266
+ search += "=" + value2;
1267
+ }
1268
+ });
1269
+ }
1270
+ return search;
1271
+ }
1272
+ function normalizeQuery(query) {
1273
+ const normalizedQuery = {};
1274
+ for (const key in query) {
1275
+ const value = query[key];
1276
+ if (value !== void 0) {
1277
+ normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
1278
+ }
1279
+ }
1280
+ return normalizedQuery;
1281
+ }
1282
+ var matchedRouteKey = Symbol(true ? "router view location matched" : "");
1283
+ var viewDepthKey = Symbol(true ? "router view depth" : "");
1284
+ var routerKey = Symbol(true ? "router" : "");
1285
+ var routeLocationKey = Symbol(true ? "route location" : "");
1286
+ var routerViewLocationKey = Symbol(true ? "router view location" : "");
1287
+ function useCallbacks() {
1288
+ let handlers = [];
1289
+ function add(handler) {
1290
+ handlers.push(handler);
1291
+ return () => {
1292
+ const i = handlers.indexOf(handler);
1293
+ if (i > -1)
1294
+ handlers.splice(i, 1);
1295
+ };
1296
+ }
1297
+ function reset() {
1298
+ handlers = [];
1299
+ }
1300
+ return {
1301
+ add,
1302
+ list: () => handlers.slice(),
1303
+ reset
1304
+ };
1305
+ }
1306
+ function registerGuard(record, name, guard) {
1307
+ const removeFromList = () => {
1308
+ record[name].delete(guard);
1309
+ };
1310
+ onUnmounted(removeFromList);
1311
+ onDeactivated(removeFromList);
1312
+ onActivated(() => {
1313
+ record[name].add(guard);
1314
+ });
1315
+ record[name].add(guard);
1316
+ }
1317
+ function onBeforeRouteLeave(leaveGuard) {
1318
+ if (!getCurrentInstance()) {
1319
+ warn("getCurrentInstance() returned null. onBeforeRouteLeave() must be called at the top of a setup function");
1320
+ return;
1321
+ }
1322
+ const activeRecord = inject(
1323
+ matchedRouteKey,
1324
+ // to avoid warning
1325
+ {}
1326
+ ).value;
1327
+ if (!activeRecord) {
1328
+ 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?");
1329
+ return;
1330
+ }
1331
+ registerGuard(activeRecord, "leaveGuards", leaveGuard);
1332
+ }
1333
+ function onBeforeRouteUpdate(updateGuard) {
1334
+ if (!getCurrentInstance()) {
1335
+ warn("getCurrentInstance() returned null. onBeforeRouteUpdate() must be called at the top of a setup function");
1336
+ return;
1337
+ }
1338
+ const activeRecord = inject(
1339
+ matchedRouteKey,
1340
+ // to avoid warning
1341
+ {}
1342
+ ).value;
1343
+ if (!activeRecord) {
1344
+ 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?");
1345
+ return;
1346
+ }
1347
+ registerGuard(activeRecord, "updateGuards", updateGuard);
1348
+ }
1349
+ function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
1350
+ const enterCallbackArray = record && // name is defined if record is because of the function overload
1351
+ (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
1352
+ return () => new Promise((resolve, reject) => {
1353
+ const next = (valid) => {
1354
+ if (valid === false) {
1355
+ reject(createRouterError(4, {
1356
+ from,
1357
+ to
1358
+ }));
1359
+ } else if (valid instanceof Error) {
1360
+ reject(valid);
1361
+ } else if (isRouteLocation(valid)) {
1362
+ reject(createRouterError(2, {
1363
+ from: to,
1364
+ to: valid
1365
+ }));
1366
+ } else {
1367
+ if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
1368
+ record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
1369
+ enterCallbackArray.push(valid);
1370
+ }
1371
+ resolve();
1372
+ }
1373
+ };
1374
+ const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, true ? canOnlyBeCalledOnce(next, to, from) : next));
1375
+ let guardCall = Promise.resolve(guardReturn);
1376
+ if (guard.length < 3)
1377
+ guardCall = guardCall.then(next);
1378
+ if (guard.length > 2) {
1379
+ const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ""}:
1380
+ ${guard.toString()}
1381
+ . If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
1382
+ if (typeof guardReturn === "object" && "then" in guardReturn) {
1383
+ guardCall = guardCall.then((resolvedValue) => {
1384
+ if (!next._called) {
1385
+ warn(message);
1386
+ return Promise.reject(new Error("Invalid navigation guard"));
1387
+ }
1388
+ return resolvedValue;
1389
+ });
1390
+ } else if (guardReturn !== void 0) {
1391
+ if (!next._called) {
1392
+ warn(message);
1393
+ reject(new Error("Invalid navigation guard"));
1394
+ return;
1395
+ }
1396
+ }
1397
+ }
1398
+ guardCall.catch((err) => reject(err));
1399
+ });
1400
+ }
1401
+ function canOnlyBeCalledOnce(next, to, from) {
1402
+ let called = 0;
1403
+ return function() {
1404
+ if (called++ === 1)
1405
+ 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.`);
1406
+ next._called = true;
1407
+ if (called === 1)
1408
+ next.apply(null, arguments);
1409
+ };
1410
+ }
1411
+ function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
1412
+ const guards = [];
1413
+ for (const record of matched) {
1414
+ if (!record.components && !record.children.length) {
1415
+ warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
1416
+ }
1417
+ for (const name in record.components) {
1418
+ let rawComponent = record.components[name];
1419
+ if (true) {
1420
+ if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
1421
+ warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
1422
+ throw new Error("Invalid route component");
1423
+ } else if ("then" in rawComponent) {
1424
+ 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.`);
1425
+ const promise = rawComponent;
1426
+ rawComponent = () => promise;
1427
+ } else if (rawComponent.__asyncLoader && // warn only once per component
1428
+ !rawComponent.__warnedDefineAsync) {
1429
+ rawComponent.__warnedDefineAsync = true;
1430
+ warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
1431
+ }
1432
+ }
1433
+ if (guardType !== "beforeRouteEnter" && !record.instances[name])
1434
+ continue;
1435
+ if (isRouteComponent(rawComponent)) {
1436
+ const options = rawComponent.__vccOpts || rawComponent;
1437
+ const guard = options[guardType];
1438
+ guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
1439
+ } else {
1440
+ let componentPromise = rawComponent();
1441
+ if (!("catch" in componentPromise)) {
1442
+ 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.`);
1443
+ componentPromise = Promise.resolve(componentPromise);
1444
+ }
1445
+ guards.push(() => componentPromise.then((resolved) => {
1446
+ if (!resolved)
1447
+ return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
1448
+ const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1449
+ record.components[name] = resolvedComponent;
1450
+ const options = resolvedComponent.__vccOpts || resolvedComponent;
1451
+ const guard = options[guardType];
1452
+ return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
1453
+ }));
1454
+ }
1455
+ }
1456
+ }
1457
+ return guards;
1458
+ }
1459
+ function isRouteComponent(component) {
1460
+ return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
1461
+ }
1462
+ function loadRouteLocation(route) {
1463
+ return route.matched.every((record) => record.redirect) ? Promise.reject(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) => {
1464
+ const rawComponent = record.components[name];
1465
+ if (typeof rawComponent === "function" && !("displayName" in rawComponent)) {
1466
+ promises.push(rawComponent().then((resolved) => {
1467
+ if (!resolved)
1468
+ return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
1469
+ const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1470
+ record.components[name] = resolvedComponent;
1471
+ return;
1472
+ }));
1473
+ }
1474
+ return promises;
1475
+ }, [])))).then(() => route);
1476
+ }
1477
+ function useLink(props) {
1478
+ const router = inject(routerKey);
1479
+ const currentRoute = inject(routeLocationKey);
1480
+ let hasPrevious = false;
1481
+ let previousTo = null;
1482
+ const route = computed(() => {
1483
+ const to = unref(props.to);
1484
+ if (!hasPrevious || to !== previousTo) {
1485
+ if (!isRouteLocation(to)) {
1486
+ if (hasPrevious) {
1487
+ warn(`Invalid value for prop "to" in useLink()
1488
+ - to:`, to, `
1489
+ - previous to:`, previousTo, `
1490
+ - props:`, props);
1491
+ } else {
1492
+ warn(`Invalid value for prop "to" in useLink()
1493
+ - to:`, to, `
1494
+ - props:`, props);
1495
+ }
1496
+ }
1497
+ previousTo = to;
1498
+ hasPrevious = true;
1499
+ }
1500
+ return router.resolve(to);
1501
+ });
1502
+ const activeRecordIndex = computed(() => {
1503
+ const { matched } = route.value;
1504
+ const { length } = matched;
1505
+ const routeMatched = matched[length - 1];
1506
+ const currentMatched = currentRoute.matched;
1507
+ if (!routeMatched || !currentMatched.length)
1508
+ return -1;
1509
+ const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
1510
+ if (index > -1)
1511
+ return index;
1512
+ const parentRecordPath = getOriginalPath(matched[length - 2]);
1513
+ return (
1514
+ // we are dealing with nested routes
1515
+ length > 1 && // if the parent and matched route have the same path, this link is
1516
+ // referring to the empty child. Or we currently are on a different
1517
+ // child of the same parent
1518
+ getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
1519
+ currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index
1520
+ );
1521
+ });
1522
+ const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
1523
+ const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
1524
+ function navigate(e = {}) {
1525
+ if (guardEvent(e)) {
1526
+ return router[unref(props.replace) ? "replace" : "push"](
1527
+ unref(props.to)
1528
+ // avoid uncaught errors are they are logged anyway
1529
+ ).catch(noop);
1530
+ }
1531
+ return Promise.resolve();
1532
+ }
1533
+ if (isBrowser) {
1534
+ const instance = getCurrentInstance();
1535
+ if (instance) {
1536
+ const linkContextDevtools = {
1537
+ route: route.value,
1538
+ isActive: isActive.value,
1539
+ isExactActive: isExactActive.value,
1540
+ error: null
1541
+ };
1542
+ instance.__vrl_devtools = instance.__vrl_devtools || [];
1543
+ instance.__vrl_devtools.push(linkContextDevtools);
1544
+ watchEffect(() => {
1545
+ linkContextDevtools.route = route.value;
1546
+ linkContextDevtools.isActive = isActive.value;
1547
+ linkContextDevtools.isExactActive = isExactActive.value;
1548
+ linkContextDevtools.error = isRouteLocation(unref(props.to)) ? null : 'Invalid "to" value';
1549
+ }, { flush: "post" });
1550
+ }
1551
+ }
1552
+ return {
1553
+ route,
1554
+ href: computed(() => route.value.href),
1555
+ isActive,
1556
+ isExactActive,
1557
+ navigate
1558
+ };
1559
+ }
1560
+ var RouterLinkImpl = defineComponent({
1561
+ name: "RouterLink",
1562
+ compatConfig: { MODE: 3 },
1563
+ props: {
1564
+ to: {
1565
+ type: [String, Object],
1566
+ required: true
1567
+ },
1568
+ replace: Boolean,
1569
+ activeClass: String,
1570
+ // inactiveClass: String,
1571
+ exactActiveClass: String,
1572
+ custom: Boolean,
1573
+ ariaCurrentValue: {
1574
+ type: String,
1575
+ default: "page"
1576
+ }
1577
+ },
1578
+ useLink,
1579
+ setup(props, { slots }) {
1580
+ const link = reactive(useLink(props));
1581
+ const { options } = inject(routerKey);
1582
+ const elClass = computed(() => ({
1583
+ [getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
1584
+ // [getLinkClass(
1585
+ // props.inactiveClass,
1586
+ // options.linkInactiveClass,
1587
+ // 'router-link-inactive'
1588
+ // )]: !link.isExactActive,
1589
+ [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
1590
+ }));
1591
+ return () => {
1592
+ const children = slots.default && slots.default(link);
1593
+ return props.custom ? children : h("a", {
1594
+ "aria-current": link.isExactActive ? props.ariaCurrentValue : null,
1595
+ href: link.href,
1596
+ // this would override user added attrs but Vue will still add
1597
+ // the listener, so we end up triggering both
1598
+ onClick: link.navigate,
1599
+ class: elClass.value
1600
+ }, children);
1601
+ };
1602
+ }
1603
+ });
1604
+ var RouterLink = RouterLinkImpl;
1605
+ function guardEvent(e) {
1606
+ if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
1607
+ return;
1608
+ if (e.defaultPrevented)
1609
+ return;
1610
+ if (e.button !== void 0 && e.button !== 0)
1611
+ return;
1612
+ if (e.currentTarget && e.currentTarget.getAttribute) {
1613
+ const target = e.currentTarget.getAttribute("target");
1614
+ if (/\b_blank\b/i.test(target))
1615
+ return;
1616
+ }
1617
+ if (e.preventDefault)
1618
+ e.preventDefault();
1619
+ return true;
1620
+ }
1621
+ function includesParams(outer, inner) {
1622
+ for (const key in inner) {
1623
+ const innerValue = inner[key];
1624
+ const outerValue = outer[key];
1625
+ if (typeof innerValue === "string") {
1626
+ if (innerValue !== outerValue)
1627
+ return false;
1628
+ } else {
1629
+ if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i]))
1630
+ return false;
1631
+ }
1632
+ }
1633
+ return true;
1634
+ }
1635
+ function getOriginalPath(record) {
1636
+ return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
1637
+ }
1638
+ var getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
1639
+ var RouterViewImpl = defineComponent({
1640
+ name: "RouterView",
1641
+ // #674 we manually inherit them
1642
+ inheritAttrs: false,
1643
+ props: {
1644
+ name: {
1645
+ type: String,
1646
+ default: "default"
1647
+ },
1648
+ route: Object
1649
+ },
1650
+ // Better compat for @vue/compat users
1651
+ // https://github.com/vuejs/router/issues/1315
1652
+ compatConfig: { MODE: 3 },
1653
+ setup(props, { attrs, slots }) {
1654
+ warnDeprecatedUsage();
1655
+ const injectedRoute = inject(routerViewLocationKey);
1656
+ const routeToDisplay = computed(() => props.route || injectedRoute.value);
1657
+ const injectedDepth = inject(viewDepthKey, 0);
1658
+ const depth = computed(() => {
1659
+ let initialDepth = unref(injectedDepth);
1660
+ const { matched } = routeToDisplay.value;
1661
+ let matchedRoute;
1662
+ while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
1663
+ initialDepth++;
1664
+ }
1665
+ return initialDepth;
1666
+ });
1667
+ const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
1668
+ provide(viewDepthKey, computed(() => depth.value + 1));
1669
+ provide(matchedRouteKey, matchedRouteRef);
1670
+ provide(routerViewLocationKey, routeToDisplay);
1671
+ const viewRef = ref();
1672
+ watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
1673
+ if (to) {
1674
+ to.instances[name] = instance;
1675
+ if (from && from !== to && instance && instance === oldInstance) {
1676
+ if (!to.leaveGuards.size) {
1677
+ to.leaveGuards = from.leaveGuards;
1678
+ }
1679
+ if (!to.updateGuards.size) {
1680
+ to.updateGuards = from.updateGuards;
1681
+ }
1682
+ }
1683
+ }
1684
+ if (instance && to && // if there is no instance but to and from are the same this might be
1685
+ // the first visit
1686
+ (!from || !isSameRouteRecord(to, from) || !oldInstance)) {
1687
+ (to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
1688
+ }
1689
+ }, { flush: "post" });
1690
+ return () => {
1691
+ const route = routeToDisplay.value;
1692
+ const currentName = props.name;
1693
+ const matchedRoute = matchedRouteRef.value;
1694
+ const ViewComponent = matchedRoute && matchedRoute.components[currentName];
1695
+ if (!ViewComponent) {
1696
+ return normalizeSlot(slots.default, { Component: ViewComponent, route });
1697
+ }
1698
+ const routePropsOption = matchedRoute.props[currentName];
1699
+ const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
1700
+ const onVnodeUnmounted = (vnode) => {
1701
+ if (vnode.component.isUnmounted) {
1702
+ matchedRoute.instances[currentName] = null;
1703
+ }
1704
+ };
1705
+ const component = h(ViewComponent, assign({}, routeProps, attrs, {
1706
+ onVnodeUnmounted,
1707
+ ref: viewRef
1708
+ }));
1709
+ if (isBrowser && component.ref) {
1710
+ const info = {
1711
+ depth: depth.value,
1712
+ name: matchedRoute.name,
1713
+ path: matchedRoute.path,
1714
+ meta: matchedRoute.meta
1715
+ };
1716
+ const internalInstances = isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i];
1717
+ internalInstances.forEach((instance) => {
1718
+ instance.__vrv_devtools = info;
1719
+ });
1720
+ }
1721
+ return (
1722
+ // pass the vnode to the slot as a prop.
1723
+ // h and <component :is="..."> both accept vnodes
1724
+ normalizeSlot(slots.default, { Component: component, route }) || component
1725
+ );
1726
+ };
1727
+ }
1728
+ });
1729
+ function normalizeSlot(slot, data) {
1730
+ if (!slot)
1731
+ return null;
1732
+ const slotContent = slot(data);
1733
+ return slotContent.length === 1 ? slotContent[0] : slotContent;
1734
+ }
1735
+ var RouterView = RouterViewImpl;
1736
+ function warnDeprecatedUsage() {
1737
+ const instance = getCurrentInstance();
1738
+ const parentName = instance.parent && instance.parent.type.name;
1739
+ const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
1740
+ if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
1741
+ const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
1742
+ warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
1743
+ Use slot props instead:
1744
+
1745
+ <router-view v-slot="{ Component }">
1746
+ <${comp}>
1747
+ <component :is="Component" />
1748
+ </${comp}>
1749
+ </router-view>`);
1750
+ }
1751
+ }
1752
+ function formatRouteLocation(routeLocation, tooltip) {
1753
+ const copy = assign({}, routeLocation, {
1754
+ // remove variables that can contain vue instances
1755
+ matched: routeLocation.matched.map((matched) => omit(matched, ["instances", "children", "aliasOf"]))
1756
+ });
1757
+ return {
1758
+ _custom: {
1759
+ type: null,
1760
+ readOnly: true,
1761
+ display: routeLocation.fullPath,
1762
+ tooltip,
1763
+ value: copy
1764
+ }
1765
+ };
1766
+ }
1767
+ function formatDisplay(display) {
1768
+ return {
1769
+ _custom: {
1770
+ display
1771
+ }
1772
+ };
1773
+ }
1774
+ var routerId = 0;
1775
+ function addDevtools(app, router, matcher) {
1776
+ if (router.__hasDevtools)
1777
+ return;
1778
+ router.__hasDevtools = true;
1779
+ const id = routerId++;
1780
+ setupDevtoolsPlugin({
1781
+ id: "org.vuejs.router" + (id ? "." + id : ""),
1782
+ label: "Vue Router",
1783
+ packageName: "vue-router",
1784
+ homepage: "https://router.vuejs.org",
1785
+ logo: "https://router.vuejs.org/logo.png",
1786
+ componentStateTypes: ["Routing"],
1787
+ app
1788
+ }, (api) => {
1789
+ if (typeof api.now !== "function") {
1790
+ console.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.");
1791
+ }
1792
+ api.on.inspectComponent((payload, ctx) => {
1793
+ if (payload.instanceData) {
1794
+ payload.instanceData.state.push({
1795
+ type: "Routing",
1796
+ key: "$route",
1797
+ editable: false,
1798
+ value: formatRouteLocation(router.currentRoute.value, "Current Route")
1799
+ });
1800
+ }
1801
+ });
1802
+ api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
1803
+ if (componentInstance.__vrv_devtools) {
1804
+ const info = componentInstance.__vrv_devtools;
1805
+ node.tags.push({
1806
+ label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
1807
+ textColor: 0,
1808
+ tooltip: "This component is rendered by &lt;router-view&gt;",
1809
+ backgroundColor: PINK_500
1810
+ });
1811
+ }
1812
+ if (isArray(componentInstance.__vrl_devtools)) {
1813
+ componentInstance.__devtoolsApi = api;
1814
+ componentInstance.__vrl_devtools.forEach((devtoolsData) => {
1815
+ let label = devtoolsData.route.path;
1816
+ let backgroundColor = ORANGE_400;
1817
+ let tooltip = "";
1818
+ let textColor = 0;
1819
+ if (devtoolsData.error) {
1820
+ label = devtoolsData.error;
1821
+ backgroundColor = RED_100;
1822
+ textColor = RED_700;
1823
+ } else if (devtoolsData.isExactActive) {
1824
+ backgroundColor = LIME_500;
1825
+ tooltip = "This is exactly active";
1826
+ } else if (devtoolsData.isActive) {
1827
+ backgroundColor = BLUE_600;
1828
+ tooltip = "This link is active";
1829
+ }
1830
+ node.tags.push({
1831
+ label,
1832
+ textColor,
1833
+ tooltip,
1834
+ backgroundColor
1835
+ });
1836
+ });
1837
+ }
1838
+ });
1839
+ watch(router.currentRoute, () => {
1840
+ refreshRoutesView();
1841
+ api.notifyComponentUpdate();
1842
+ api.sendInspectorTree(routerInspectorId);
1843
+ api.sendInspectorState(routerInspectorId);
1844
+ });
1845
+ const navigationsLayerId = "router:navigations:" + id;
1846
+ api.addTimelineLayer({
1847
+ id: navigationsLayerId,
1848
+ label: `Router${id ? " " + id : ""} Navigations`,
1849
+ color: 4237508
1850
+ });
1851
+ router.onError((error, to) => {
1852
+ api.addTimelineEvent({
1853
+ layerId: navigationsLayerId,
1854
+ event: {
1855
+ title: "Error during Navigation",
1856
+ subtitle: to.fullPath,
1857
+ logType: "error",
1858
+ time: api.now(),
1859
+ data: { error },
1860
+ groupId: to.meta.__navigationId
1861
+ }
1862
+ });
1863
+ });
1864
+ let navigationId = 0;
1865
+ router.beforeEach((to, from) => {
1866
+ const data = {
1867
+ guard: formatDisplay("beforeEach"),
1868
+ from: formatRouteLocation(from, "Current Location during this navigation"),
1869
+ to: formatRouteLocation(to, "Target location")
1870
+ };
1871
+ Object.defineProperty(to.meta, "__navigationId", {
1872
+ value: navigationId++
1873
+ });
1874
+ api.addTimelineEvent({
1875
+ layerId: navigationsLayerId,
1876
+ event: {
1877
+ time: api.now(),
1878
+ title: "Start of navigation",
1879
+ subtitle: to.fullPath,
1880
+ data,
1881
+ groupId: to.meta.__navigationId
1882
+ }
1883
+ });
1884
+ });
1885
+ router.afterEach((to, from, failure) => {
1886
+ const data = {
1887
+ guard: formatDisplay("afterEach")
1888
+ };
1889
+ if (failure) {
1890
+ data.failure = {
1891
+ _custom: {
1892
+ type: Error,
1893
+ readOnly: true,
1894
+ display: failure ? failure.message : "",
1895
+ tooltip: "Navigation Failure",
1896
+ value: failure
1897
+ }
1898
+ };
1899
+ data.status = formatDisplay("❌");
1900
+ } else {
1901
+ data.status = formatDisplay("✅");
1902
+ }
1903
+ data.from = formatRouteLocation(from, "Current Location during this navigation");
1904
+ data.to = formatRouteLocation(to, "Target location");
1905
+ api.addTimelineEvent({
1906
+ layerId: navigationsLayerId,
1907
+ event: {
1908
+ title: "End of navigation",
1909
+ subtitle: to.fullPath,
1910
+ time: api.now(),
1911
+ data,
1912
+ logType: failure ? "warning" : "default",
1913
+ groupId: to.meta.__navigationId
1914
+ }
1915
+ });
1916
+ });
1917
+ const routerInspectorId = "router-inspector:" + id;
1918
+ api.addInspector({
1919
+ id: routerInspectorId,
1920
+ label: "Routes" + (id ? " " + id : ""),
1921
+ icon: "book",
1922
+ treeFilterPlaceholder: "Search routes"
1923
+ });
1924
+ function refreshRoutesView() {
1925
+ if (!activeRoutesPayload)
1926
+ return;
1927
+ const payload = activeRoutesPayload;
1928
+ let routes = matcher.getRoutes().filter((route) => !route.parent || // these routes have a parent with no component which will not appear in the view
1929
+ // therefore we still need to include them
1930
+ !route.parent.record.components);
1931
+ routes.forEach(resetMatchStateOnRouteRecord);
1932
+ if (payload.filter) {
1933
+ routes = routes.filter((route) => (
1934
+ // save matches state based on the payload
1935
+ isRouteMatching(route, payload.filter.toLowerCase())
1936
+ ));
1937
+ }
1938
+ routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
1939
+ payload.rootNodes = routes.map(formatRouteRecordForInspector);
1940
+ }
1941
+ let activeRoutesPayload;
1942
+ api.on.getInspectorTree((payload) => {
1943
+ activeRoutesPayload = payload;
1944
+ if (payload.app === app && payload.inspectorId === routerInspectorId) {
1945
+ refreshRoutesView();
1946
+ }
1947
+ });
1948
+ api.on.getInspectorState((payload) => {
1949
+ if (payload.app === app && payload.inspectorId === routerInspectorId) {
1950
+ const routes = matcher.getRoutes();
1951
+ const route = routes.find((route2) => route2.record.__vd_id === payload.nodeId);
1952
+ if (route) {
1953
+ payload.state = {
1954
+ options: formatRouteRecordMatcherForStateInspector(route)
1955
+ };
1956
+ }
1957
+ }
1958
+ });
1959
+ api.sendInspectorTree(routerInspectorId);
1960
+ api.sendInspectorState(routerInspectorId);
1961
+ });
1962
+ }
1963
+ function modifierForKey(key) {
1964
+ if (key.optional) {
1965
+ return key.repeatable ? "*" : "?";
1966
+ } else {
1967
+ return key.repeatable ? "+" : "";
1968
+ }
1969
+ }
1970
+ function formatRouteRecordMatcherForStateInspector(route) {
1971
+ const { record } = route;
1972
+ const fields = [
1973
+ { editable: false, key: "path", value: record.path }
1974
+ ];
1975
+ if (record.name != null) {
1976
+ fields.push({
1977
+ editable: false,
1978
+ key: "name",
1979
+ value: record.name
1980
+ });
1981
+ }
1982
+ fields.push({ editable: false, key: "regexp", value: route.re });
1983
+ if (route.keys.length) {
1984
+ fields.push({
1985
+ editable: false,
1986
+ key: "keys",
1987
+ value: {
1988
+ _custom: {
1989
+ type: null,
1990
+ readOnly: true,
1991
+ display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
1992
+ tooltip: "Param keys",
1993
+ value: route.keys
1994
+ }
1995
+ }
1996
+ });
1997
+ }
1998
+ if (record.redirect != null) {
1999
+ fields.push({
2000
+ editable: false,
2001
+ key: "redirect",
2002
+ value: record.redirect
2003
+ });
2004
+ }
2005
+ if (route.alias.length) {
2006
+ fields.push({
2007
+ editable: false,
2008
+ key: "aliases",
2009
+ value: route.alias.map((alias) => alias.record.path)
2010
+ });
2011
+ }
2012
+ if (Object.keys(route.record.meta).length) {
2013
+ fields.push({
2014
+ editable: false,
2015
+ key: "meta",
2016
+ value: route.record.meta
2017
+ });
2018
+ }
2019
+ fields.push({
2020
+ key: "score",
2021
+ editable: false,
2022
+ value: {
2023
+ _custom: {
2024
+ type: null,
2025
+ readOnly: true,
2026
+ display: route.score.map((score) => score.join(", ")).join(" | "),
2027
+ tooltip: "Score used to sort routes",
2028
+ value: route.score
2029
+ }
2030
+ }
2031
+ });
2032
+ return fields;
2033
+ }
2034
+ var PINK_500 = 15485081;
2035
+ var BLUE_600 = 2450411;
2036
+ var LIME_500 = 8702998;
2037
+ var CYAN_400 = 2282478;
2038
+ var ORANGE_400 = 16486972;
2039
+ var DARK = 6710886;
2040
+ var RED_100 = 16704226;
2041
+ var RED_700 = 12131356;
2042
+ function formatRouteRecordForInspector(route) {
2043
+ const tags = [];
2044
+ const { record } = route;
2045
+ if (record.name != null) {
2046
+ tags.push({
2047
+ label: String(record.name),
2048
+ textColor: 0,
2049
+ backgroundColor: CYAN_400
2050
+ });
2051
+ }
2052
+ if (record.aliasOf) {
2053
+ tags.push({
2054
+ label: "alias",
2055
+ textColor: 0,
2056
+ backgroundColor: ORANGE_400
2057
+ });
2058
+ }
2059
+ if (route.__vd_match) {
2060
+ tags.push({
2061
+ label: "matches",
2062
+ textColor: 0,
2063
+ backgroundColor: PINK_500
2064
+ });
2065
+ }
2066
+ if (route.__vd_exactActive) {
2067
+ tags.push({
2068
+ label: "exact",
2069
+ textColor: 0,
2070
+ backgroundColor: LIME_500
2071
+ });
2072
+ }
2073
+ if (route.__vd_active) {
2074
+ tags.push({
2075
+ label: "active",
2076
+ textColor: 0,
2077
+ backgroundColor: BLUE_600
2078
+ });
2079
+ }
2080
+ if (record.redirect) {
2081
+ tags.push({
2082
+ label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
2083
+ textColor: 16777215,
2084
+ backgroundColor: DARK
2085
+ });
2086
+ }
2087
+ let id = record.__vd_id;
2088
+ if (id == null) {
2089
+ id = String(routeRecordId++);
2090
+ record.__vd_id = id;
2091
+ }
2092
+ return {
2093
+ id,
2094
+ label: record.path,
2095
+ tags,
2096
+ children: route.children.map(formatRouteRecordForInspector)
2097
+ };
2098
+ }
2099
+ var routeRecordId = 0;
2100
+ var EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
2101
+ function markRouteRecordActive(route, currentRoute) {
2102
+ const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
2103
+ route.__vd_exactActive = route.__vd_active = isExactActive;
2104
+ if (!isExactActive) {
2105
+ route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
2106
+ }
2107
+ route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
2108
+ }
2109
+ function resetMatchStateOnRouteRecord(route) {
2110
+ route.__vd_match = false;
2111
+ route.children.forEach(resetMatchStateOnRouteRecord);
2112
+ }
2113
+ function isRouteMatching(route, filter) {
2114
+ const found = String(route.re).match(EXTRACT_REGEXP_RE);
2115
+ route.__vd_match = false;
2116
+ if (!found || found.length < 3) {
2117
+ return false;
2118
+ }
2119
+ const nonEndingRE = new RegExp(found[1].replace(/\$$/, ""), found[2]);
2120
+ if (nonEndingRE.test(filter)) {
2121
+ route.children.forEach((child) => isRouteMatching(child, filter));
2122
+ if (route.record.path !== "/" || filter === "/") {
2123
+ route.__vd_match = route.re.test(filter);
2124
+ return true;
2125
+ }
2126
+ return false;
2127
+ }
2128
+ const path = route.record.path.toLowerCase();
2129
+ const decodedPath = decode(path);
2130
+ if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter)))
2131
+ return true;
2132
+ if (decodedPath.startsWith(filter) || path.startsWith(filter))
2133
+ return true;
2134
+ if (route.record.name && String(route.record.name).includes(filter))
2135
+ return true;
2136
+ return route.children.some((child) => isRouteMatching(child, filter));
2137
+ }
2138
+ function omit(obj, keys) {
2139
+ const ret = {};
2140
+ for (const key in obj) {
2141
+ if (!keys.includes(key)) {
2142
+ ret[key] = obj[key];
2143
+ }
2144
+ }
2145
+ return ret;
2146
+ }
2147
+ function createRouter(options) {
2148
+ const matcher = createRouterMatcher(options.routes, options);
2149
+ const parseQuery$1 = options.parseQuery || parseQuery;
2150
+ const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
2151
+ const routerHistory = options.history;
2152
+ if (!routerHistory)
2153
+ throw new Error('Provide the "history" option when calling "createRouter()": https://router.vuejs.org/api/interfaces/RouterOptions.html#history');
2154
+ const beforeGuards = useCallbacks();
2155
+ const beforeResolveGuards = useCallbacks();
2156
+ const afterGuards = useCallbacks();
2157
+ const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
2158
+ let pendingLocation = START_LOCATION_NORMALIZED;
2159
+ if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
2160
+ history.scrollRestoration = "manual";
2161
+ }
2162
+ const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
2163
+ const encodeParams = applyToParams.bind(null, encodeParam);
2164
+ const decodeParams = (
2165
+ // @ts-expect-error: intentionally avoid the type check
2166
+ applyToParams.bind(null, decode)
2167
+ );
2168
+ function addRoute(parentOrRoute, route) {
2169
+ let parent;
2170
+ let record;
2171
+ if (isRouteName(parentOrRoute)) {
2172
+ parent = matcher.getRecordMatcher(parentOrRoute);
2173
+ if (!parent) {
2174
+ warn(`Parent route "${String(parentOrRoute)}" not found when adding child route`, route);
2175
+ }
2176
+ record = route;
2177
+ } else {
2178
+ record = parentOrRoute;
2179
+ }
2180
+ return matcher.addRoute(record, parent);
2181
+ }
2182
+ function removeRoute(name) {
2183
+ const recordMatcher = matcher.getRecordMatcher(name);
2184
+ if (recordMatcher) {
2185
+ matcher.removeRoute(recordMatcher);
2186
+ } else if (true) {
2187
+ warn(`Cannot remove non-existent route "${String(name)}"`);
2188
+ }
2189
+ }
2190
+ function getRoutes() {
2191
+ return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
2192
+ }
2193
+ function hasRoute(name) {
2194
+ return !!matcher.getRecordMatcher(name);
2195
+ }
2196
+ function resolve(rawLocation, currentLocation) {
2197
+ currentLocation = assign({}, currentLocation || currentRoute.value);
2198
+ if (typeof rawLocation === "string") {
2199
+ const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
2200
+ const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
2201
+ const href2 = routerHistory.createHref(locationNormalized.fullPath);
2202
+ if (true) {
2203
+ if (href2.startsWith("//"))
2204
+ warn(`Location "${rawLocation}" resolved to "${href2}". A resolved location cannot start with multiple slashes.`);
2205
+ else if (!matchedRoute2.matched.length) {
2206
+ warn(`No match found for location with path "${rawLocation}"`);
2207
+ }
2208
+ }
2209
+ return assign(locationNormalized, matchedRoute2, {
2210
+ params: decodeParams(matchedRoute2.params),
2211
+ hash: decode(locationNormalized.hash),
2212
+ redirectedFrom: void 0,
2213
+ href: href2
2214
+ });
2215
+ }
2216
+ if (!isRouteLocation(rawLocation)) {
2217
+ warn(`router.resolve() was passed an invalid location. This will fail in production.
2218
+ - Location:`, rawLocation);
2219
+ return resolve({});
2220
+ }
2221
+ let matcherLocation;
2222
+ if (rawLocation.path != null) {
2223
+ if ("params" in rawLocation && !("name" in rawLocation) && // @ts-expect-error: the type is never
2224
+ Object.keys(rawLocation.params).length) {
2225
+ warn(`Path "${rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
2226
+ }
2227
+ matcherLocation = assign({}, rawLocation, {
2228
+ path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
2229
+ });
2230
+ } else {
2231
+ const targetParams = assign({}, rawLocation.params);
2232
+ for (const key in targetParams) {
2233
+ if (targetParams[key] == null) {
2234
+ delete targetParams[key];
2235
+ }
2236
+ }
2237
+ matcherLocation = assign({}, rawLocation, {
2238
+ params: encodeParams(targetParams)
2239
+ });
2240
+ currentLocation.params = encodeParams(currentLocation.params);
2241
+ }
2242
+ const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
2243
+ const hash = rawLocation.hash || "";
2244
+ if (hash && !hash.startsWith("#")) {
2245
+ warn(`A \`hash\` should always start with the character "#". Replace "${hash}" with "#${hash}".`);
2246
+ }
2247
+ matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
2248
+ const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
2249
+ hash: encodeHash(hash),
2250
+ path: matchedRoute.path
2251
+ }));
2252
+ const href = routerHistory.createHref(fullPath);
2253
+ if (true) {
2254
+ if (href.startsWith("//")) {
2255
+ warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
2256
+ } else if (!matchedRoute.matched.length) {
2257
+ warn(`No match found for location with path "${rawLocation.path != null ? rawLocation.path : rawLocation}"`);
2258
+ }
2259
+ }
2260
+ return assign({
2261
+ fullPath,
2262
+ // keep the hash encoded so fullPath is effectively path + encodedQuery +
2263
+ // hash
2264
+ hash,
2265
+ query: (
2266
+ // if the user is using a custom query lib like qs, we might have
2267
+ // nested objects, so we keep the query as is, meaning it can contain
2268
+ // numbers at `$route.query`, but at the point, the user will have to
2269
+ // use their own type anyway.
2270
+ // https://github.com/vuejs/router/issues/328#issuecomment-649481567
2271
+ stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
2272
+ )
2273
+ }, matchedRoute, {
2274
+ redirectedFrom: void 0,
2275
+ href
2276
+ });
2277
+ }
2278
+ function locationAsObject(to) {
2279
+ return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
2280
+ }
2281
+ function checkCanceledNavigation(to, from) {
2282
+ if (pendingLocation !== to) {
2283
+ return createRouterError(8, {
2284
+ from,
2285
+ to
2286
+ });
2287
+ }
2288
+ }
2289
+ function push(to) {
2290
+ return pushWithRedirect(to);
2291
+ }
2292
+ function replace(to) {
2293
+ return push(assign(locationAsObject(to), { replace: true }));
2294
+ }
2295
+ function handleRedirectRecord(to) {
2296
+ const lastMatched = to.matched[to.matched.length - 1];
2297
+ if (lastMatched && lastMatched.redirect) {
2298
+ const { redirect } = lastMatched;
2299
+ let newTargetLocation = typeof redirect === "function" ? redirect(to) : redirect;
2300
+ if (typeof newTargetLocation === "string") {
2301
+ newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
2302
+ // force empty params
2303
+ { path: newTargetLocation }
2304
+ );
2305
+ newTargetLocation.params = {};
2306
+ }
2307
+ if (newTargetLocation.path == null && !("name" in newTargetLocation)) {
2308
+ warn(`Invalid redirect found:
2309
+ ${JSON.stringify(newTargetLocation, null, 2)}
2310
+ when navigating to "${to.fullPath}". A redirect must contain a name or path. This will break in production.`);
2311
+ throw new Error("Invalid redirect");
2312
+ }
2313
+ return assign({
2314
+ query: to.query,
2315
+ hash: to.hash,
2316
+ // avoid transferring params if the redirect has a path
2317
+ params: newTargetLocation.path != null ? {} : to.params
2318
+ }, newTargetLocation);
2319
+ }
2320
+ }
2321
+ function pushWithRedirect(to, redirectedFrom) {
2322
+ const targetLocation = pendingLocation = resolve(to);
2323
+ const from = currentRoute.value;
2324
+ const data = to.state;
2325
+ const force = to.force;
2326
+ const replace2 = to.replace === true;
2327
+ const shouldRedirect = handleRedirectRecord(targetLocation);
2328
+ if (shouldRedirect)
2329
+ return pushWithRedirect(
2330
+ assign(locationAsObject(shouldRedirect), {
2331
+ state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
2332
+ force,
2333
+ replace: replace2
2334
+ }),
2335
+ // keep original redirectedFrom if it exists
2336
+ redirectedFrom || targetLocation
2337
+ );
2338
+ const toLocation = targetLocation;
2339
+ toLocation.redirectedFrom = redirectedFrom;
2340
+ let failure;
2341
+ if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
2342
+ failure = createRouterError(16, { to: toLocation, from });
2343
+ handleScroll(
2344
+ from,
2345
+ from,
2346
+ // this is a push, the only way for it to be triggered from a
2347
+ // history.listen is with a redirect, which makes it become a push
2348
+ true,
2349
+ // This cannot be the first navigation because the initial location
2350
+ // cannot be manually navigated to
2351
+ false
2352
+ );
2353
+ }
2354
+ return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? (
2355
+ // navigation redirects still mark the router as ready
2356
+ isNavigationFailure(
2357
+ error,
2358
+ 2
2359
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2360
+ ) ? error : markAsReady(error)
2361
+ ) : (
2362
+ // reject any unknown error
2363
+ triggerError(error, toLocation, from)
2364
+ )).then((failure2) => {
2365
+ if (failure2) {
2366
+ if (isNavigationFailure(
2367
+ failure2,
2368
+ 2
2369
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2370
+ )) {
2371
+ if (// we are redirecting to the same location we were already at
2372
+ isSameRouteLocation(stringifyQuery$1, resolve(failure2.to), toLocation) && // and we have done it a couple of times
2373
+ redirectedFrom && // @ts-expect-error: added only in dev
2374
+ (redirectedFrom._count = redirectedFrom._count ? (
2375
+ // @ts-expect-error
2376
+ redirectedFrom._count + 1
2377
+ ) : 1) > 30) {
2378
+ warn(`Detected a possibly infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow.
2379
+ 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.`);
2380
+ return Promise.reject(new Error("Infinite redirect in navigation guard"));
2381
+ }
2382
+ return pushWithRedirect(
2383
+ // keep options
2384
+ assign({
2385
+ // preserve an existing replacement but allow the redirect to override it
2386
+ replace: replace2
2387
+ }, locationAsObject(failure2.to), {
2388
+ state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
2389
+ force
2390
+ }),
2391
+ // preserve the original redirectedFrom if any
2392
+ redirectedFrom || toLocation
2393
+ );
2394
+ }
2395
+ } else {
2396
+ failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
2397
+ }
2398
+ triggerAfterEach(toLocation, from, failure2);
2399
+ return failure2;
2400
+ });
2401
+ }
2402
+ function checkCanceledNavigationAndReject(to, from) {
2403
+ const error = checkCanceledNavigation(to, from);
2404
+ return error ? Promise.reject(error) : Promise.resolve();
2405
+ }
2406
+ function runWithContext(fn) {
2407
+ const app = installedApps.values().next().value;
2408
+ return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
2409
+ }
2410
+ function navigate(to, from) {
2411
+ let guards;
2412
+ const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
2413
+ guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
2414
+ for (const record of leavingRecords) {
2415
+ record.leaveGuards.forEach((guard) => {
2416
+ guards.push(guardToPromiseFn(guard, to, from));
2417
+ });
2418
+ }
2419
+ const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
2420
+ guards.push(canceledNavigationCheck);
2421
+ return runGuardQueue(guards).then(() => {
2422
+ guards = [];
2423
+ for (const guard of beforeGuards.list()) {
2424
+ guards.push(guardToPromiseFn(guard, to, from));
2425
+ }
2426
+ guards.push(canceledNavigationCheck);
2427
+ return runGuardQueue(guards);
2428
+ }).then(() => {
2429
+ guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
2430
+ for (const record of updatingRecords) {
2431
+ record.updateGuards.forEach((guard) => {
2432
+ guards.push(guardToPromiseFn(guard, to, from));
2433
+ });
2434
+ }
2435
+ guards.push(canceledNavigationCheck);
2436
+ return runGuardQueue(guards);
2437
+ }).then(() => {
2438
+ guards = [];
2439
+ for (const record of enteringRecords) {
2440
+ if (record.beforeEnter) {
2441
+ if (isArray(record.beforeEnter)) {
2442
+ for (const beforeEnter of record.beforeEnter)
2443
+ guards.push(guardToPromiseFn(beforeEnter, to, from));
2444
+ } else {
2445
+ guards.push(guardToPromiseFn(record.beforeEnter, to, from));
2446
+ }
2447
+ }
2448
+ }
2449
+ guards.push(canceledNavigationCheck);
2450
+ return runGuardQueue(guards);
2451
+ }).then(() => {
2452
+ to.matched.forEach((record) => record.enterCallbacks = {});
2453
+ guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
2454
+ guards.push(canceledNavigationCheck);
2455
+ return runGuardQueue(guards);
2456
+ }).then(() => {
2457
+ guards = [];
2458
+ for (const guard of beforeResolveGuards.list()) {
2459
+ guards.push(guardToPromiseFn(guard, to, from));
2460
+ }
2461
+ guards.push(canceledNavigationCheck);
2462
+ return runGuardQueue(guards);
2463
+ }).catch((err) => isNavigationFailure(
2464
+ err,
2465
+ 8
2466
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2467
+ ) ? err : Promise.reject(err));
2468
+ }
2469
+ function triggerAfterEach(to, from, failure) {
2470
+ afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
2471
+ }
2472
+ function finalizeNavigation(toLocation, from, isPush, replace2, data) {
2473
+ const error = checkCanceledNavigation(toLocation, from);
2474
+ if (error)
2475
+ return error;
2476
+ const isFirstNavigation = from === START_LOCATION_NORMALIZED;
2477
+ const state = !isBrowser ? {} : history.state;
2478
+ if (isPush) {
2479
+ if (replace2 || isFirstNavigation)
2480
+ routerHistory.replace(toLocation.fullPath, assign({
2481
+ scroll: isFirstNavigation && state && state.scroll
2482
+ }, data));
2483
+ else
2484
+ routerHistory.push(toLocation.fullPath, data);
2485
+ }
2486
+ currentRoute.value = toLocation;
2487
+ handleScroll(toLocation, from, isPush, isFirstNavigation);
2488
+ markAsReady();
2489
+ }
2490
+ let removeHistoryListener;
2491
+ function setupListeners() {
2492
+ if (removeHistoryListener)
2493
+ return;
2494
+ removeHistoryListener = routerHistory.listen((to, _from, info) => {
2495
+ if (!router.listening)
2496
+ return;
2497
+ const toLocation = resolve(to);
2498
+ const shouldRedirect = handleRedirectRecord(toLocation);
2499
+ if (shouldRedirect) {
2500
+ pushWithRedirect(assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
2501
+ return;
2502
+ }
2503
+ pendingLocation = toLocation;
2504
+ const from = currentRoute.value;
2505
+ if (isBrowser) {
2506
+ saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
2507
+ }
2508
+ navigate(toLocation, from).catch((error) => {
2509
+ if (isNavigationFailure(
2510
+ error,
2511
+ 4 | 8
2512
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2513
+ )) {
2514
+ return error;
2515
+ }
2516
+ if (isNavigationFailure(
2517
+ error,
2518
+ 2
2519
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2520
+ )) {
2521
+ pushWithRedirect(
2522
+ error.to,
2523
+ toLocation
2524
+ // avoid an uncaught rejection, let push call triggerError
2525
+ ).then((failure) => {
2526
+ if (isNavigationFailure(
2527
+ failure,
2528
+ 4 | 16
2529
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
2530
+ ) && !info.delta && info.type === NavigationType.pop) {
2531
+ routerHistory.go(-1, false);
2532
+ }
2533
+ }).catch(noop);
2534
+ return Promise.reject();
2535
+ }
2536
+ if (info.delta) {
2537
+ routerHistory.go(-info.delta, false);
2538
+ }
2539
+ return triggerError(error, toLocation, from);
2540
+ }).then((failure) => {
2541
+ failure = failure || finalizeNavigation(
2542
+ // after navigation, all matched components are resolved
2543
+ toLocation,
2544
+ from,
2545
+ false
2546
+ );
2547
+ if (failure) {
2548
+ if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
2549
+ // entry while a different route is displayed
2550
+ !isNavigationFailure(
2551
+ failure,
2552
+ 8
2553
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2554
+ )) {
2555
+ routerHistory.go(-info.delta, false);
2556
+ } else if (info.type === NavigationType.pop && isNavigationFailure(
2557
+ failure,
2558
+ 4 | 16
2559
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
2560
+ )) {
2561
+ routerHistory.go(-1, false);
2562
+ }
2563
+ }
2564
+ triggerAfterEach(toLocation, from, failure);
2565
+ }).catch(noop);
2566
+ });
2567
+ }
2568
+ let readyHandlers = useCallbacks();
2569
+ let errorListeners = useCallbacks();
2570
+ let ready;
2571
+ function triggerError(error, to, from) {
2572
+ markAsReady(error);
2573
+ const list = errorListeners.list();
2574
+ if (list.length) {
2575
+ list.forEach((handler) => handler(error, to, from));
2576
+ } else {
2577
+ if (true) {
2578
+ warn("uncaught error during route navigation:");
2579
+ }
2580
+ console.error(error);
2581
+ }
2582
+ return Promise.reject(error);
2583
+ }
2584
+ function isReady() {
2585
+ if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
2586
+ return Promise.resolve();
2587
+ return new Promise((resolve2, reject) => {
2588
+ readyHandlers.add([resolve2, reject]);
2589
+ });
2590
+ }
2591
+ function markAsReady(err) {
2592
+ if (!ready) {
2593
+ ready = !err;
2594
+ setupListeners();
2595
+ readyHandlers.list().forEach(([resolve2, reject]) => err ? reject(err) : resolve2());
2596
+ readyHandlers.reset();
2597
+ }
2598
+ return err;
2599
+ }
2600
+ function handleScroll(to, from, isPush, isFirstNavigation) {
2601
+ const { scrollBehavior } = options;
2602
+ if (!isBrowser || !scrollBehavior)
2603
+ return Promise.resolve();
2604
+ const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
2605
+ return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
2606
+ }
2607
+ const go = (delta) => routerHistory.go(delta);
2608
+ let started;
2609
+ const installedApps = /* @__PURE__ */ new Set();
2610
+ const router = {
2611
+ currentRoute,
2612
+ listening: true,
2613
+ addRoute,
2614
+ removeRoute,
2615
+ clearRoutes: matcher.clearRoutes,
2616
+ hasRoute,
2617
+ getRoutes,
2618
+ resolve,
2619
+ options,
2620
+ push,
2621
+ replace,
2622
+ go,
2623
+ back: () => go(-1),
2624
+ forward: () => go(1),
2625
+ beforeEach: beforeGuards.add,
2626
+ beforeResolve: beforeResolveGuards.add,
2627
+ afterEach: afterGuards.add,
2628
+ onError: errorListeners.add,
2629
+ isReady,
2630
+ install(app) {
2631
+ const router2 = this;
2632
+ app.component("RouterLink", RouterLink);
2633
+ app.component("RouterView", RouterView);
2634
+ app.config.globalProperties.$router = router2;
2635
+ Object.defineProperty(app.config.globalProperties, "$route", {
2636
+ enumerable: true,
2637
+ get: () => unref(currentRoute)
2638
+ });
2639
+ if (isBrowser && // used for the initial navigation client side to avoid pushing
2640
+ // multiple times when the router is used in multiple apps
2641
+ !started && currentRoute.value === START_LOCATION_NORMALIZED) {
2642
+ started = true;
2643
+ push(routerHistory.location).catch((err) => {
2644
+ if (true)
2645
+ warn("Unexpected error when starting the router:", err);
2646
+ });
2647
+ }
2648
+ const reactiveRoute = {};
2649
+ for (const key in START_LOCATION_NORMALIZED) {
2650
+ Object.defineProperty(reactiveRoute, key, {
2651
+ get: () => currentRoute.value[key],
2652
+ enumerable: true
2653
+ });
2654
+ }
2655
+ app.provide(routerKey, router2);
2656
+ app.provide(routeLocationKey, shallowReactive(reactiveRoute));
2657
+ app.provide(routerViewLocationKey, currentRoute);
2658
+ const unmountApp = app.unmount;
2659
+ installedApps.add(app);
2660
+ app.unmount = function() {
2661
+ installedApps.delete(app);
2662
+ if (installedApps.size < 1) {
2663
+ pendingLocation = START_LOCATION_NORMALIZED;
2664
+ removeHistoryListener && removeHistoryListener();
2665
+ removeHistoryListener = null;
2666
+ currentRoute.value = START_LOCATION_NORMALIZED;
2667
+ started = false;
2668
+ ready = false;
2669
+ }
2670
+ unmountApp();
2671
+ };
2672
+ if (isBrowser) {
2673
+ addDevtools(app, router2, matcher);
2674
+ }
2675
+ }
2676
+ };
2677
+ function runGuardQueue(guards) {
2678
+ return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
2679
+ }
2680
+ return router;
2681
+ }
2682
+ function extractChangingRecords(to, from) {
2683
+ const leavingRecords = [];
2684
+ const updatingRecords = [];
2685
+ const enteringRecords = [];
2686
+ const len = Math.max(from.matched.length, to.matched.length);
2687
+ for (let i = 0; i < len; i++) {
2688
+ const recordFrom = from.matched[i];
2689
+ if (recordFrom) {
2690
+ if (to.matched.find((record) => isSameRouteRecord(record, recordFrom)))
2691
+ updatingRecords.push(recordFrom);
2692
+ else
2693
+ leavingRecords.push(recordFrom);
2694
+ }
2695
+ const recordTo = to.matched[i];
2696
+ if (recordTo) {
2697
+ if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
2698
+ enteringRecords.push(recordTo);
2699
+ }
2700
+ }
2701
+ }
2702
+ return [leavingRecords, updatingRecords, enteringRecords];
2703
+ }
2704
+ function useRouter() {
2705
+ return inject(routerKey);
2706
+ }
2707
+ function useRoute(_name) {
2708
+ return inject(routeLocationKey);
2709
+ }
2710
+ export {
2711
+ NavigationFailureType,
2712
+ RouterLink,
2713
+ RouterView,
2714
+ START_LOCATION_NORMALIZED as START_LOCATION,
2715
+ createMemoryHistory,
2716
+ createRouter,
2717
+ createRouterMatcher,
2718
+ createWebHashHistory,
2719
+ createWebHistory,
2720
+ isNavigationFailure,
2721
+ loadRouteLocation,
2722
+ matchedRouteKey,
2723
+ onBeforeRouteLeave,
2724
+ onBeforeRouteUpdate,
2725
+ parseQuery,
2726
+ routeLocationKey,
2727
+ routerKey,
2728
+ routerViewLocationKey,
2729
+ stringifyQuery,
2730
+ useLink,
2731
+ useRoute,
2732
+ useRouter,
2733
+ viewDepthKey
2734
+ };
2735
+ /*! Bundled license information:
2736
+
2737
+ vue-router/dist/vue-router.mjs:
2738
+ (*!
2739
+ * vue-router v4.4.3
2740
+ * (c) 2024 Eduardo San Martin Morote
2741
+ * @license MIT
2742
+ *)
2743
+ */
2744
+ //# sourceMappingURL=vue-router.js.map