aberdeen 1.18.2 → 1.19.0

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 (152) hide show
  1. package/README.md +9 -0
  2. package/dist/src/aberdeen.d.ts +27 -0
  3. package/{dist-docs/assets/aberdeen/aberdeen.js → dist/src/aberdeen.dev.js} +776 -15
  4. package/dist/src/aberdeen.dev.js.map +12 -0
  5. package/dist/src/aberdeen.js +59 -13
  6. package/dist/src/aberdeen.js.map +3 -3
  7. package/dist/src/devtools.d.ts +26 -0
  8. package/html-to-aberdeen +9 -5
  9. package/package.json +17 -10
  10. package/skill/A.md +127 -0
  11. package/skill/Dispatcher.md +51 -0
  12. package/skill/OPAQUE.md +15 -0
  13. package/skill/PromiseProxy.md +25 -0
  14. package/skill/Route.md +50 -0
  15. package/skill/SKILL.md +272 -156
  16. package/skill/applyCanon.md +20 -0
  17. package/skill/applyPrediction.md +15 -0
  18. package/skill/back.md +11 -0
  19. package/skill/clean.md +43 -0
  20. package/skill/clone.md +15 -0
  21. package/skill/copy.md +40 -0
  22. package/skill/count.md +32 -0
  23. package/skill/cssVars.md +15 -0
  24. package/skill/darkMode.md +26 -0
  25. package/skill/derive.md +56 -0
  26. package/skill/developer-tools.md +23 -0
  27. package/skill/disableCreateDestroy.md +11 -0
  28. package/skill/dump.md +37 -0
  29. package/skill/freeze.md +20 -0
  30. package/skill/full-example-multi-page-app.md +146 -0
  31. package/skill/go.md +25 -0
  32. package/skill/grow.md +13 -0
  33. package/skill/html-to-aberdeen.md +9 -0
  34. package/skill/insertCss.md +79 -0
  35. package/skill/insertGlobalCss.md +68 -0
  36. package/skill/interceptLinks.md +19 -0
  37. package/skill/invertString.md +32 -0
  38. package/skill/isEmpty.md +38 -0
  39. package/skill/map.md +16 -0
  40. package/skill/matchCurrent.md +27 -0
  41. package/skill/merge.md +27 -0
  42. package/skill/mount.md +48 -0
  43. package/skill/multiMap.md +15 -0
  44. package/skill/onEach.md +14 -0
  45. package/skill/partition.md +15 -0
  46. package/skill/peek.md +36 -0
  47. package/skill/persistScroll.md +13 -0
  48. package/skill/proxy.md +11 -0
  49. package/skill/push.md +13 -0
  50. package/skill/ref.md +39 -0
  51. package/skill/runQueue.md +34 -0
  52. package/skill/setErrorHandler.md +48 -0
  53. package/skill/setLog.md +9 -0
  54. package/skill/setSpacingCssVars.md +31 -0
  55. package/skill/shrink.md +13 -0
  56. package/skill/unmountAll.md +9 -0
  57. package/skill/unproxy.md +43 -0
  58. package/skill/up.md +13 -0
  59. package/src/aberdeen.ts +194 -73
  60. package/src/devtools.ts +685 -0
  61. package/dist-docs/.nojekyll +0 -1
  62. package/dist-docs/Tutorial/index.html +0 -305
  63. package/dist-docs/aberdeen/A/index.html +0 -116
  64. package/dist-docs/aberdeen/CUSTOM_DUMP/index.html +0 -7
  65. package/dist-docs/aberdeen/NO_COPY/index.html +0 -2
  66. package/dist-docs/aberdeen/OPAQUE/index.html +0 -12
  67. package/dist-docs/aberdeen/PromiseProxy/index.html +0 -8
  68. package/dist-docs/aberdeen/clean/index.html +0 -11
  69. package/dist-docs/aberdeen/clone/index.html +0 -5
  70. package/dist-docs/aberdeen/copy/index.html +0 -22
  71. package/dist-docs/aberdeen/count/index.html +0 -7
  72. package/dist-docs/aberdeen/cssVars/index.html +0 -11
  73. package/dist-docs/aberdeen/darkMode/index.html +0 -9
  74. package/dist-docs/aberdeen/default/index.html +0 -342
  75. package/dist-docs/aberdeen/derive/index.html +0 -18
  76. package/dist-docs/aberdeen/disableCreateDestroy/index.html +0 -6
  77. package/dist-docs/aberdeen/dump/index.html +0 -11
  78. package/dist-docs/aberdeen/index.html +0 -54
  79. package/dist-docs/aberdeen/insertCss/index.html +0 -30
  80. package/dist-docs/aberdeen/insertGlobalCss/index.html +0 -19
  81. package/dist-docs/aberdeen/invertString/index.html +0 -13
  82. package/dist-docs/aberdeen/isEmpty/index.html +0 -12
  83. package/dist-docs/aberdeen/map/index.html +0 -26
  84. package/dist-docs/aberdeen/merge/index.html +0 -11
  85. package/dist-docs/aberdeen/mount/index.html +0 -17
  86. package/dist-docs/aberdeen/multiMap/index.html +0 -28
  87. package/dist-docs/aberdeen/onEach/index.html +0 -19
  88. package/dist-docs/aberdeen/partition/index.html +0 -36
  89. package/dist-docs/aberdeen/peek/index.html +0 -40
  90. package/dist-docs/aberdeen/proxy/index.html +0 -35
  91. package/dist-docs/aberdeen/ref/index.html +0 -13
  92. package/dist-docs/aberdeen/runQueue/index.html +0 -13
  93. package/dist-docs/aberdeen/setErrorHandler/index.html +0 -16
  94. package/dist-docs/aberdeen/setSpacingCssVars/index.html +0 -8
  95. package/dist-docs/aberdeen/unmountAll/index.html +0 -5
  96. package/dist-docs/aberdeen/unproxy/index.html +0 -11
  97. package/dist-docs/assets/aberdeen/aberdeen.d.ts +0 -963
  98. package/dist-docs/assets/aberdeen/aberdeen.js.map +0 -11
  99. package/dist-docs/assets/aberdeen/dispatcher.d.ts +0 -57
  100. package/dist-docs/assets/aberdeen/dispatcher.js +0 -66
  101. package/dist-docs/assets/aberdeen/dispatcher.js.map +0 -10
  102. package/dist-docs/assets/aberdeen/helpers/reverseSortedSet.d.ts +0 -96
  103. package/dist-docs/assets/aberdeen/prediction.d.ts +0 -33
  104. package/dist-docs/assets/aberdeen/prediction.js +0 -112
  105. package/dist-docs/assets/aberdeen/prediction.js.map +0 -10
  106. package/dist-docs/assets/aberdeen/route.d.ts +0 -137
  107. package/dist-docs/assets/aberdeen/route.js +0 -287
  108. package/dist-docs/assets/aberdeen/route.js.map +0 -10
  109. package/dist-docs/assets/aberdeen/transitions.d.ts +0 -18
  110. package/dist-docs/assets/aberdeen/transitions.js +0 -47
  111. package/dist-docs/assets/aberdeen/transitions.js.map +0 -10
  112. package/dist-docs/assets/custom.js +0 -573
  113. package/dist-docs/assets/favicon.png +0 -0
  114. package/dist-docs/assets/hierarchy.js +0 -1
  115. package/dist-docs/assets/highlight.css +0 -134
  116. package/dist-docs/assets/icons.js +0 -18
  117. package/dist-docs/assets/icons.svg +0 -1
  118. package/dist-docs/assets/main.js +0 -60
  119. package/dist-docs/assets/navigation.js +0 -1
  120. package/dist-docs/assets/search.js +0 -1
  121. package/dist-docs/assets/style.css +0 -1640
  122. package/dist-docs/dispatcher/Dispatcher/index.html +0 -21
  123. package/dist-docs/dispatcher/MATCH_FAILED/index.html +0 -2
  124. package/dist-docs/dispatcher/MATCH_REST/index.html +0 -2
  125. package/dist-docs/dispatcher/index.html +0 -4
  126. package/dist-docs/hierarchy.html +0 -1
  127. package/dist-docs/index.html +0 -61
  128. package/dist-docs/media/CHANGELOG.md +0 -266
  129. package/dist-docs/modules.html +0 -1
  130. package/dist-docs/prediction/applyCanon/index.html +0 -13
  131. package/dist-docs/prediction/applyPrediction/index.html +0 -8
  132. package/dist-docs/prediction/index.html +0 -9
  133. package/dist-docs/route/Route/index.html +0 -23
  134. package/dist-docs/route/back/index.html +0 -4
  135. package/dist-docs/route/current/index.html +0 -2
  136. package/dist-docs/route/go/index.html +0 -14
  137. package/dist-docs/route/index.html +0 -15
  138. package/dist-docs/route/interceptLinks/index.html +0 -8
  139. package/dist-docs/route/matchCurrent/index.html +0 -10
  140. package/dist-docs/route/persistScroll/index.html +0 -6
  141. package/dist-docs/route/push/index.html +0 -6
  142. package/dist-docs/route/setLog/index.html +0 -3
  143. package/dist-docs/route/up/index.html +0 -5
  144. package/dist-docs/sitemap.xml +0 -239
  145. package/dist-docs/transitions/grow/index.html +0 -6
  146. package/dist-docs/transitions/index.html +0 -5
  147. package/dist-docs/transitions/shrink/index.html +0 -6
  148. package/skill/aberdeen.md +0 -4586
  149. package/skill/dispatcher.md +0 -129
  150. package/skill/prediction.md +0 -73
  151. package/skill/route.md +0 -322
  152. package/skill/transitions.md +0 -59
@@ -1,287 +0,0 @@
1
- // src/route.ts
2
- import A, { leakScope } from "./aberdeen.js";
3
- var log = () => {};
4
- function setLog(value) {
5
- if (value === true) {
6
- log = console.log.bind(console, "aberdeen router");
7
- } else if (value === false) {
8
- log = () => {};
9
- } else {
10
- log = value;
11
- }
12
- }
13
- var windowE = typeof ABERDEEN_FAKE_WINDOW !== "undefined" ? ABERDEEN_FAKE_WINDOW : window;
14
- var locationE = windowE.location;
15
- var historyE = windowE.history;
16
- function getRouteFromBrowser() {
17
- return toCanonRoute({
18
- path: locationE.pathname,
19
- hash: locationE.hash,
20
- search: Object.fromEntries(new URLSearchParams(locationE.search)),
21
- state: historyE.state?.state || {}
22
- }, "load", (historyE.state?.stack?.length || 0) + 1);
23
- }
24
- function equal(a, b, partial) {
25
- if (a === b)
26
- return true;
27
- if (typeof a !== "object" || !a || typeof b !== "object" || !b)
28
- return false;
29
- if (a.constructor !== b.constructor)
30
- return false;
31
- if (b instanceof Array) {
32
- if (a.length !== b.length)
33
- return false;
34
- for (let i = 0;i < b.length; i++) {
35
- if (!equal(a[i], b[i], partial))
36
- return false;
37
- }
38
- } else {
39
- for (const k of Object.keys(b)) {
40
- if (!equal(a[k], b[k], partial))
41
- return false;
42
- }
43
- if (!partial) {
44
- for (const k of Object.keys(a)) {
45
- if (!b.hasOwnProperty(k))
46
- return false;
47
- }
48
- }
49
- }
50
- return true;
51
- }
52
- function getUrl(target) {
53
- const search = new URLSearchParams(target.search).toString();
54
- return (search ? `${target.path}?${search}` : target.path) + target.hash;
55
- }
56
- function toCanonRoute(target, nav, depth) {
57
- let path = target.path || (target.p || []).join("/") || "/";
58
- path = ("" + path).replace(/\/+$/, "");
59
- if (!path.startsWith("/"))
60
- path = `/${path}`;
61
- return {
62
- path,
63
- hash: target.hash && target.hash !== "#" ? target.hash.startsWith("#") ? target.hash : "#" + target.hash : "",
64
- p: path.length > 1 ? path.slice(1).replace(/\/+$/, "").split("/") : [],
65
- nav,
66
- search: typeof target.search === "object" && target.search ? A.clone(target.search) : {},
67
- state: typeof target.state === "object" && target.state ? A.clone(target.state) : {},
68
- depth
69
- };
70
- }
71
- function targetToPartial(target, undefinedOnExternal = false) {
72
- if (typeof target === "string") {
73
- const url = new URL(target, locationE.href);
74
- if (url.host !== locationE.host) {
75
- if (undefinedOnExternal)
76
- return;
77
- throw new Error(`Unexpected external URL: ${url.host} != ${locationE.host}`);
78
- }
79
- target = {
80
- path: url.pathname,
81
- search: Object.fromEntries(url.searchParams),
82
- hash: url.hash
83
- };
84
- } else if (target instanceof Array) {
85
- target = { p: target };
86
- }
87
- if (target.p) {
88
- target.p = target.p.map(String);
89
- }
90
- if (target.search) {
91
- for (const key of Object.keys(target.search)) {
92
- target.search[key] = String(target.search[key]);
93
- }
94
- }
95
- return target;
96
- }
97
- function go(target, nav = "go") {
98
- pendingGoOffset = 0;
99
- const stack = historyE.state?.stack || [];
100
- prevStack = stack.concat(JSON.stringify(A.unproxy(current)));
101
- const newRoute = toCanonRoute(targetToPartial(target), nav, prevStack.length + 1);
102
- A.copy(current, newRoute);
103
- log(nav, newRoute);
104
- historyE.pushState({ state: newRoute.state, stack: prevStack }, "", getUrl(newRoute));
105
- A.runQueue();
106
- }
107
- function matchCurrent(target) {
108
- const partial = targetToPartial(target, true);
109
- if (!partial)
110
- return false;
111
- if (partial.path != null || partial.p != null) {
112
- let path = partial.path || (partial.p || []).join("/") || "/";
113
- path = ("" + path).replace(/\/+$/, "");
114
- if (!path.startsWith("/"))
115
- path = `/${path}`;
116
- if (!currentRouteParts[path])
117
- return false;
118
- }
119
- if (partial.search) {
120
- for (const [k, v] of Object.entries(partial.search)) {
121
- if (!currentRouteParts[`${k}=${v}`])
122
- return false;
123
- }
124
- }
125
- return true;
126
- }
127
- function push(target, nav) {
128
- const c = A.clone(A.unproxy(current));
129
- A.merge(c, targetToPartial(target));
130
- go(c, nav || c.nav);
131
- }
132
- function back(target = {}) {
133
- const partial = targetToPartial(target);
134
- const stack = historyE.state?.stack || [];
135
- const effectiveLen = stack.length + pendingGoOffset;
136
- for (let i = effectiveLen - 1;i >= 0; i--) {
137
- const histRoute = JSON.parse(stack[i]);
138
- if (equal(histRoute, partial, true)) {
139
- const pages = i - effectiveLen;
140
- log(`back`, pages, histRoute);
141
- scheduleHistoryGo(pages);
142
- return;
143
- }
144
- }
145
- const newRoute = toCanonRoute(partial, "back", effectiveLen + 1);
146
- log(`back not found, replacing`, partial);
147
- A.copy(current, newRoute);
148
- }
149
- function up(stripCount = 1) {
150
- const currentP = A.unproxy(current).p;
151
- const stack = historyE.state?.stack || [];
152
- const effectiveLen = stack.length + pendingGoOffset;
153
- for (let i = effectiveLen - 1;i >= 0; i--) {
154
- const histRoute = JSON.parse(stack[i]);
155
- if (histRoute.p.length < currentP.length && equal(histRoute.p, currentP.slice(0, histRoute.p.length), false)) {
156
- log(`up to ${i + 1} / ${effectiveLen}`, histRoute);
157
- scheduleHistoryGo(i - effectiveLen);
158
- return;
159
- }
160
- }
161
- const newRoute = toCanonRoute({ p: currentP.slice(0, currentP.length - stripCount) }, "back", effectiveLen + 1);
162
- log(`up not found, replacing`, newRoute);
163
- A.copy(current, newRoute);
164
- }
165
- var prevStack;
166
- var pendingGoOffset = 0;
167
- function scheduleHistoryGo(delta) {
168
- pendingGoOffset += delta;
169
- setTimeout(() => {
170
- if (pendingGoOffset) {
171
- const offset = pendingGoOffset;
172
- pendingGoOffset = 0;
173
- historyE.go(offset);
174
- }
175
- }, 0);
176
- }
177
- var current = A.proxy({});
178
- var currentRouteParts = A.proxy({});
179
- function reset() {
180
- prevStack = historyE.state?.stack || [];
181
- const initRoute = getRouteFromBrowser();
182
- log("initial", initRoute);
183
- A.copy(A.unproxy(current), initRoute);
184
- }
185
- reset();
186
- windowE.addEventListener("popstate", function(event) {
187
- pendingGoOffset = 0;
188
- const newRoute = getRouteFromBrowser();
189
- const stack = historyE.state?.stack || [];
190
- if (stack.length !== prevStack.length) {
191
- const maxIndex = Math.min(prevStack.length, stack.length) - 1;
192
- if (maxIndex < 0 || stack[maxIndex] === prevStack[maxIndex]) {
193
- newRoute.nav = stack.length < prevStack.length ? "back" : "forward";
194
- }
195
- }
196
- prevStack = stack;
197
- log("popstate", newRoute);
198
- A.copy(current, newRoute);
199
- A.runQueue();
200
- });
201
- leakScope(() => {
202
- A(() => {
203
- current.path = "/" + Array.from(current.p).join("/");
204
- });
205
- A(() => {
206
- const stack = historyE.state?.stack || [];
207
- const newRoute = toCanonRoute(current, A.unproxy(current).nav, stack.length + 1);
208
- A.copy(current, newRoute);
209
- const state = { state: newRoute.state, stack };
210
- const url = getUrl(newRoute);
211
- if (url !== locationE.pathname + locationE.search + locationE.hash || !equal(historyE.state, state, false)) {
212
- log("replaceState", newRoute, state, url);
213
- historyE.replaceState(state, "", url);
214
- }
215
- });
216
- A(() => {
217
- const n = {};
218
- n[current.path] = true;
219
- for (const [k, v] of Object.entries(current.search)) {
220
- n[`${k}=${v}`] = true;
221
- }
222
- A.copy(currentRouteParts, n);
223
- });
224
- });
225
- function persistScroll(name = "main") {
226
- const el = A();
227
- A("scroll=", onScroll);
228
- const restore = A.unproxy(current).state.scroll?.[name];
229
- if (restore) {
230
- log("restoring scroll", name, restore);
231
- Object.assign(el, restore);
232
- }
233
- function onScroll() {
234
- (current.state.scroll ||= {})[name] = {
235
- scrollTop: el.scrollTop,
236
- scrollLeft: el.scrollLeft
237
- };
238
- }
239
- }
240
- function interceptLinks() {
241
- A({
242
- click: handleEvent,
243
- keydown: handleKeyEvent
244
- });
245
- function handleKeyEvent(e) {
246
- if (e.key === "Enter") {
247
- handleEvent(e);
248
- }
249
- }
250
- function handleEvent(e) {
251
- let target = e.target;
252
- while (target && target.tagName?.toUpperCase() !== "A") {
253
- target = target.parentElement;
254
- }
255
- if (!target)
256
- return;
257
- const anchor = target;
258
- const href = anchor.getAttribute("href");
259
- if (!href)
260
- return;
261
- if (href.startsWith("#"))
262
- return;
263
- if (href.startsWith("//") || /^[^/?#]+:/.test(href))
264
- return;
265
- if (anchor.getAttribute("target") || anchor.getAttribute("download"))
266
- return;
267
- if (typeof MouseEvent !== "undefined" && e instanceof MouseEvent && (e.ctrlKey || e.metaKey || e.shiftKey))
268
- return;
269
- e.preventDefault();
270
- go(href);
271
- }
272
- }
273
- export {
274
- up,
275
- setLog,
276
- reset,
277
- push,
278
- persistScroll,
279
- matchCurrent,
280
- interceptLinks,
281
- go,
282
- current,
283
- back
284
- };
285
-
286
- //# debugId=E926F5C48B21197864756E2164756E21
287
- //# sourceMappingURL=route.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/route.ts"],
4
- "sourcesContent": [
5
- "import A, {leakScope} from \"./aberdeen.js\";\n\ntype NavType = \"load\" | \"back\" | \"forward\" | \"go\" | \"push\";\n\n/**\n* The class for the global `route` object.\n*/\nexport interface Route {\n\t/** The current path of the URL as a string. For instance `\"/\"` or `\"/users/123/feed\"`. Paths are normalized to always start with a `/` and never end with a `/` (unless it's the root path). */\n\tpath: string;\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', '123', 'feed']` (for `\"/users/123/feed\"`). */\n\tp: string[];\n\t/** The hash fragment including the leading `#`, or an empty string. For instance `\"#my_section\"` or `\"\"`. */\n\thash: string;\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\"}`. */\n\tsearch: Record<string, string>;\n\t/** An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible. */\n\tstate: Record<string, any>;\n\t/** The navigation depth of the current session. Starts at 1. Writing to this property has no effect. */\n\tdepth: number;\n\t/** The navigation action that got us to this page. Writing to this property has no effect.\n\t- `\"load\"`: An initial page load.\n\t- `\"back\"` or `\"forward\"`: When we navigated backwards or forwards in the stack.\n\t- `\"go\"`: When we added a new page on top of the stack.\n\t- `\"push\"`: When we added a new page on top of the stack, merging with the current page.\n\tMostly useful for page transition animations. Writing to this property has no effect.\n\t*/\n\tnav: NavType;\n}\n\nlet log: (...args: any) => void = () => {};\n\n/**\n * Configure logging on route changes.\n * @param value `true` to enable logging to console, `false` to disable logging, or a custom logging function. Defaults to `false`.\n */\nexport function setLog(value: boolean | ((...args: any[]) => void)) {\n\tif (value === true) {\n\t\tlog = console.log.bind(console, 'aberdeen router');\n\t} else if (value === false) {\n\t\tlog = () => {};\n\t} else {\n\t\tlog = value;\n\t}\n}\n\ndeclare const ABERDEEN_FAKE_WINDOW: Window | undefined;\nconst windowE = typeof ABERDEEN_FAKE_WINDOW !== 'undefined'? ABERDEEN_FAKE_WINDOW : window;\nconst locationE = windowE.location;\nconst historyE = windowE.history;\n\nfunction getRouteFromBrowser(): Route {\n\treturn toCanonRoute({\n\t\tpath: locationE.pathname,\n\t\thash: locationE.hash,\n\t\tsearch: Object.fromEntries(new URLSearchParams(locationE.search)),\n\t\tstate: \thistoryE.state?.state || {},\n\t}, \"load\", (historyE.state?.stack?.length || 0) + 1);\n}\n\n/**\n* Deep compare `a` and `b`. If `partial` is true, objects contained in `b` may be a subset\n* of their counterparts in `a` and still be considered equal.\n*/\nfunction equal(a: any, b: any, partial: boolean): boolean {\n\tif (a===b) return true;\n\tif (typeof a !== \"object\" || !a || typeof b !== \"object\" || !b) return false; // otherwise they would have been equal\n\tif (a.constructor !== b.constructor) return false;\n\tif (b instanceof Array) {\n\t\tif (a.length !== b.length) return false;\n\t\tfor(let i = 0; i < b.length; i++) {\n\t\t\tif (!equal(a[i], b[i], partial)) return false;\n\t\t}\n\t} else {\n\t\tfor(const k of Object.keys(b)) {\n\t\t\tif (!equal(a[k], b[k], partial)) return false;\n\t\t}\n\t\tif (!partial) {\n\t\t\tfor(const k of Object.keys(a)) {\n\t\t\t\tif (!b.hasOwnProperty(k)) return false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction getUrl(target: Route) {\n\tconst search = new URLSearchParams(target.search).toString();\n\treturn (search ? `${target.path}?${search}` : target.path) + target.hash;\n}\n\nfunction toCanonRoute(target: Partial<Route>, nav: NavType, depth: number): Route {\n\tlet path = target.path || (target.p || []).join(\"/\") || \"/\";\n\tpath = (\"\"+path).replace(/\\/+$/, \"\");\n\tif (!path.startsWith(\"/\")) path = `/${path}`;\n\t\n\treturn {\n\t\tpath,\n\t\thash: target.hash && target.hash !==\"#\" ? (target.hash.startsWith(\"#\") ? target.hash : \"#\" + target.hash) : \"\",\n\t\tp: path.length > 1 ? path.slice(1).replace(/\\/+$/, \"\").split(\"/\") : [],\n\t\tnav,\n\t\tsearch: typeof target.search === 'object' && target.search ? A.clone(target.search) : {},\n\t\tstate: typeof target.state === 'object' && target.state ? A.clone(target.state) : {},\n\t\tdepth,\n\t};\n}\n\n\ntype RouteTarget = string | (string|number)[] | Partial<Omit<Omit<Route,\"p\">,\"search\"> & {\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', 123, 'feed']` (for `\"/users/123/feed\"`). Values may be integers but will be converted to strings.*/\n\tp: (string|number)[],\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\", c: 42}`. Values may be integers but will be converted to strings. */\n\tsearch: Record<string,string|number>,\n}>;\n\nfunction targetToPartial(target: RouteTarget, undefinedOnExternal: true): Partial<Route> | undefined;\nfunction targetToPartial(target: RouteTarget): Partial<Route>;\n\n\nfunction targetToPartial(target: RouteTarget, undefinedOnExternal: boolean=false) {\n\t// Convert shortcut values to objects\n\tif (typeof target === 'string') {\n\t\t// Parse using URL to handle both absolute and relative paths correctly\t\t\n\t\tconst url = new URL(target, locationE.href);\n\t\tif (url.host !== locationE.host) {\n\t\t\tif (undefinedOnExternal) return;\n\t\t\tthrow new Error(`Unexpected external URL: ${url.host} != ${locationE.host}`);\n\t\t}\n\t\ttarget = {\n\t\t\tpath: url.pathname,\n\t\t\tsearch: Object.fromEntries(url.searchParams),\n\t\t\thash: url.hash,\n\t\t};\n\t} else if (target instanceof Array) {\n\t\ttarget = {p: target};\n\t}\n\t// Convert numbers in p and search to strings\n\tif (target.p) {\n\t\ttarget.p = target.p.map(String);\n\t}\n\tif (target.search) {\n\t\tfor(const key of Object.keys(target.search)) {\n\t\t\ttarget.search[key] = String(target.search[key]);\n\t\t}\n\t}\n\treturn target as Partial<Route>;\n}\n\n\n/**\n* Navigate to a new URL by pushing a new history entry.\n* \n* Note that this happens synchronously, immediately updating `route` and processing any reactive updates based on that.\n* \n* @param target A subset of the {@link Route} properties to navigate to. If neither `p` nor `path` is given, the current path is used. For other properties, an empty/default value is assumed if not given. For convenience:\n* - You may pass a string instead of an object, which is interpreted as the `path`.\n* - You may pass an array instead of an object, which is interpreted as the `p` array.\n* - If you pass `p`, it may contain numbers, which will be converted to strings.\n* - If you pass `search`, its values may be numbers, which will be converted to strings.\n* \n* Examples:\n* ```js\n* // Navigate to /users/123\n* route.go(\"/users/123\");\n* \n* // Navigate to /users/123?tab=feed#top\n* route.go({p: [\"users\", 123], search: {tab: \"feed\"}, hash: \"top\"});\n* ```\n*/\nexport function go(target: RouteTarget, nav: NavType = \"go\"): void {\n\tpendingGoOffset = 0;\n\tconst stack: string[] = historyE.state?.stack || [];\n\n\tprevStack = stack.concat(JSON.stringify(A.unproxy(current)));\n\t\n\tconst newRoute: Route = toCanonRoute(targetToPartial(target), nav, prevStack.length + 1);\n\tA.copy(current, newRoute);\n\t\n\tlog(nav, newRoute);\n\thistoryE.pushState({state: newRoute.state, stack: prevStack}, \"\", getUrl(newRoute));\n\t\n\tA.runQueue();\n}\n\n/**\n * Returns `true` if the current route matches `target`.\n *\n * Path must match exactly. Any search params specified in `target` must be present\n * in the current URL, but extra params in the current URL are allowed.\n *\n * Reactive: only reevaluates when the path changes to/from the target path, and\n * when target k/v search pairs are (un)set.\n * \n * Primary usage: 'active' status for menu items.\n *\n * @example\n * ```js\n * // This example assumes interceptLinks() has been called\n * A('a.my-button text=Users href=/users .is-active=', route.matchCurrent('/users'));\n * \n * // Alternatively a route object can be given\n * route.matchCurrent({path: '/users', search: {tab: 'profile'}});\n * ```\n */\nexport function matchCurrent(target: RouteTarget): boolean {\n\tconst partial = targetToPartial(target, true);\n\tif (!partial) return false; // External link\n\n\tif (partial.path != null || partial.p != null) {\n\t\tlet path = partial.path || (partial.p || []).join(\"/\") || \"/\";\n\t\tpath = (\"\"+path).replace(/\\/+$/, \"\");\n\t\tif (!path.startsWith(\"/\")) path = `/${path}`;\n\t\tif (!currentRouteParts[path]) return false;\n\t}\n\n\tif (partial.search) {\n\t\tfor(const [k,v] of Object.entries(partial.search)) {\n\t\t\tif (!currentRouteParts[`${k}=${v}`]) return false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Modify the current route by merging `target` into it (using {@link aberdeen.merge | A.merge}), pushing a new history entry.\n * \n * This is useful for things like opening modals or side panels, where you want a browser back action to return to the previous state.\n * \n * @param target Same as for {@link go}, but merged into the current route instead deleting all state.\n * @param nav The navigation type to use. Defaults to `undefined`, meaning the navigation type is unchanged from the current route,\n * preventing unwanted page transition animations.\n */\nexport function push(target: RouteTarget, nav?: NavType): void {\n\tconst c = A.clone(A.unproxy(current));\n\tA.merge(c, targetToPartial(target));\n\tgo(c, nav || c.nav);\n}\n\n/**\n * Try to go back in history to the first entry that matches the given target. If none is found, the given state will replace the current page. This is useful for \"cancel\" or \"close\" actions that should return to the previous page if possible, but create a new page if not (for instance when arriving at the current page through a direct link).\n * \n * Consider using {@link up} to go up in the path hierarchy.\n * \n * @param target The target route to go back to. May be a subset of {@link Route}, or a string (for `path`), or an array of strings (for `p`).\n */\nexport function back(target: RouteTarget = {}): void {\n\tconst partial = targetToPartial(target);\n\tconst stack: string[] = historyE.state?.stack || [];\n\tconst effectiveLen = stack.length + pendingGoOffset;\n\tfor(let i = effectiveLen - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (equal(histRoute, partial, true)) {\n\t\t\tconst pages = i - effectiveLen;\n\t\t\tlog(`back`, pages, histRoute);\n\t\t\tscheduleHistoryGo(pages);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst newRoute = toCanonRoute(partial, \"back\", effectiveLen + 1);\n\tlog(`back not found, replacing`, partial);\n\tA.copy(current, newRoute);\n}\n\n/**\n* Navigate up in the path hierarchy, by going back to the first history entry\n* that has a shorter path than the current one. If there's none, we just shorten\n* the current path.\n* \n* Note that going back in browser history happens asynchronously, so `route` will not be updated immediately.\n*/\nexport function up(stripCount: number = 1): void {\n\tconst currentP = A.unproxy(current).p;\n\tconst stack: string[] = historyE.state?.stack || [];\n\tconst effectiveLen = stack.length + pendingGoOffset;\n\tfor(let i = effectiveLen - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (histRoute.p.length < currentP.length && equal(histRoute.p, currentP.slice(0, histRoute.p.length), false)) {\n\t\t\t// This route is shorter and matches the start of the current path\n\t\t\tlog(`up to ${i+1} / ${effectiveLen}`, histRoute);\n\t\t\tscheduleHistoryGo(i - effectiveLen);\n\t\t\treturn;\n\t\t}\n\t}\n\t// Replace current route with /\n\tconst newRoute = toCanonRoute({p: currentP.slice(0, currentP.length - stripCount)}, \"back\", effectiveLen + 1);\n\tlog(`up not found, replacing`, newRoute);\n\tA.copy(current, newRoute);\n}\n\n\nlet prevStack: string[];\n\n// Track pending historyE.go() offset. Multiple back()/up() calls before the event loop\n// processes them are batched into a single historyE.go() via queueMicrotask.\nlet pendingGoOffset = 0;\n\nfunction scheduleHistoryGo(delta: number) {\n\tpendingGoOffset += delta;\n\tsetTimeout(() => {\n\t\tif (pendingGoOffset) {\n\t\t\tconst offset = pendingGoOffset;\n\t\t\tpendingGoOffset = 0;\n\t\t\thistoryE.go(offset);\n\t\t}\n\t}, 0);\n}\n\n/**\n* The global {@link Route} object reflecting the current URL and browser history state. Changes you make to this affect the current browser history item (modifying the URL if needed).\n*/\nexport const current: Route = A.proxy({}) as Route;\n\n// Proxied object with keys for the current path and \"k=v\" search pairs.\n// Used by matchCurrent to subscribe only to relevant route changes.\nconst currentRouteParts = A.proxy({} as Record<string,true>);\n\n/**\n * Reset the router to its initial state, based on the current browser state. Intended for testing purposes only.\n * @internal\n * */\nexport function reset() {\n\tprevStack = historyE.state?.stack || [];\n\tconst initRoute = getRouteFromBrowser();\n\tlog('initial', initRoute);\n\tA.copy(A.unproxy(current), initRoute);\n}\nreset();\n\n// Handle browser history back and forward\nwindowE.addEventListener(\"popstate\", function(event: PopStateEvent) {\n\tpendingGoOffset = 0;\n\tconst newRoute = getRouteFromBrowser();\n\t\n\t// If the stack length changes, and at least the top-most shared entry is the same,\n\t// we'll interpret this as a \"back\" or \"forward\" navigation.\n\tconst stack: string[] = historyE.state?.stack || [];\n\tif (stack.length !== prevStack.length) {\n\t\tconst maxIndex = Math.min(prevStack.length, stack.length) - 1;\n\t\tif (maxIndex < 0 || stack[maxIndex] === prevStack[maxIndex]) {\n\t\t\tnewRoute.nav = stack.length < prevStack.length ? \"back\" : \"forward\";\n\t\t}\n\t}\n\t// else nav will be \"load\"\n\t\n\tprevStack = stack;\n\tlog('popstate', newRoute);\n\tA.copy(current, newRoute);\n\t\n\tA.runQueue();\n});\n\n// Make sure these observers are never cleaned up, not even by `unmountAll`.\nleakScope(() => {\n\t// Sync `p` to `path`. We need to do this in a separate, higher-priority observer,\n\t// so that setting `route.p` will not be immediately overruled by the pre-existing `route.path`.\n\tA(() => {\n\t\tcurrent.path = \"/\" + Array.from(current.p).join(\"/\");\n\t});\n\n\t// Do a replaceState based on changes to A.proxy\n\tA(() => {\n\t\t// First normalize `route`\n\t\tconst stack = historyE.state?.stack || [];\n\t\tconst newRoute = toCanonRoute(current, A.unproxy(current).nav, stack.length + 1);\n\t\tA.copy(current, newRoute);\n\t\t\n\t\t// Then replace the current browser state if something actually changed\n\t\tconst state = {state: newRoute.state, stack};\n\t\tconst url = getUrl(newRoute);\n\t\tif (url !== locationE.pathname + locationE.search + locationE.hash || !equal(historyE.state, state, false)) {\n\t\t\tlog('replaceState', newRoute, state, url);\n\t\t\thistoryE.replaceState(state, \"\", url);\n\t\t}\n\t});\n\n\t// Keep currentRouteParts in sync with the current path and search params.\n\tA(() => {\n\t\tconst n = {} as Record<string,true>;\n\t\tn[current.path] = true;\n\t\tfor(const [k,v] of Object.entries(current.search)) {\n\t\t\tn[`${k}=${v}`] = true;\n\t\t}\n\t\tA.copy(currentRouteParts, n);\n\t});\n});\n\n\n/**\n* Restore and store the vertical and horizontal scroll position for\n* the parent element to the page state.\n*\n* @param {string} name - A unique (within this page) name for this\n* scrollable element. Defaults to 'main'.\n*\n* The scroll position will be persisted in `route.aux.scroll.<name>`.\n*/\nexport function persistScroll(name = \"main\") {\n\tconst el = A()!;\n\tA('scroll=', onScroll);\n\t\n\tconst restore = A.unproxy(current).state.scroll?.[name];\n\tif (restore) {\n\t\tlog(\"restoring scroll\", name, restore);\n\t\tObject.assign(el, restore);\n\t}\n\t\n\tfunction onScroll() {\n\t\t(current.state.scroll ||= {})[name] = {\n\t\t\tscrollTop: el.scrollTop,\n\t\t\tscrollLeft: el.scrollLeft,\n\t\t};\n\t}\n}\n\n/**\n * Intercept clicks and Enter key presses on links (`<a>` tags) and use Aberdeen routing\n * instead of browser navigation for local paths (paths without a protocol or host).\n * \n * This allows you to use regular HTML anchor tags for navigation without needing to\n * manually attach click handlers to each link.\n * \n * @example\n * ```js\n * // In your root component:\n * route.interceptLinks();\n * \n * // Now you can use regular anchor tags:\n * A('a text=About href=/corporate/about');\n * ```\n */\nexport function interceptLinks() {\n\tA({\n\t\tclick: handleEvent,\n\t\tkeydown: handleKeyEvent,\n\t});\n\t\n\tfunction handleKeyEvent(e: KeyboardEvent) {\n\t\tif (e.key === \"Enter\") {\n\t\t\thandleEvent(e);\n\t\t}\n\t}\n\t\n\tfunction handleEvent(e: Event) {\n\t\t// Find the closest <a> tag\n\t\tlet target = e.target as HTMLElement | null;\n\t\twhile (target && target.tagName?.toUpperCase() !== \"A\") {\n\t\t\ttarget = target.parentElement;\n\t\t}\n\t\t\n\t\tif (!target) return;\n\t\t\n\t\tconst anchor = target as HTMLAnchorElement;\n\t\tconst href = anchor.getAttribute(\"href\");\n\t\t\n\t\tif (!href) return;\n\t\t\n\t\t// Skip hash-only links\n\t\tif (href.startsWith(\"#\")) return;\n\t\t\n\t\t// Skip if it has a protocol or is protocol-relative (// or contains : before any / ? #)\n\t\tif (href.startsWith(\"//\") || /^[^/?#]+:/.test(href)) return;\n\t\t\n\t\t// Skip if the link has target or download attribute\n\t\tif (anchor.getAttribute(\"target\") || anchor.getAttribute(\"download\")) return;\n\t\t\n\t\t// Skip if modifier keys are pressed (Ctrl/Cmd click to open in new tab)\n\t\tif (typeof MouseEvent !== 'undefined' && e instanceof MouseEvent && (e.ctrlKey || e.metaKey || e.shiftKey)) return;\n\t\t\n\t\te.preventDefault();\n\t\tgo(href);\n\t}\n}\n"
6
- ],
7
- "mappings": ";AAAA;AA8BA,IAAI,MAA8B,MAAM;AAMjC,SAAS,MAAM,CAAC,OAA6C;AAAA,EACnE,IAAI,UAAU,MAAM;AAAA,IACnB,MAAM,QAAQ,IAAI,KAAK,SAAS,iBAAiB;AAAA,EAClD,EAAO,SAAI,UAAU,OAAO;AAAA,IAC3B,MAAM,MAAM;AAAA,EACb,EAAO;AAAA,IACN,MAAM;AAAA;AAAA;AAKR,IAAM,UAAU,OAAO,yBAAyB,cAAa,uBAAuB;AACpF,IAAM,YAAY,QAAQ;AAC1B,IAAM,WAAW,QAAQ;AAEzB,SAAS,mBAAmB,GAAU;AAAA,EACrC,OAAO,aAAa;AAAA,IACnB,MAAM,UAAU;AAAA,IAChB,MAAM,UAAU;AAAA,IAChB,QAAQ,OAAO,YAAY,IAAI,gBAAgB,UAAU,MAAM,CAAC;AAAA,IAChE,OAAQ,SAAS,OAAO,SAAS,CAAC;AAAA,EACnC,GAAG,SAAS,SAAS,OAAO,OAAO,UAAU,KAAK,CAAC;AAAA;AAOpD,SAAS,KAAK,CAAC,GAAQ,GAAQ,SAA2B;AAAA,EACzD,IAAI,MAAI;AAAA,IAAG,OAAO;AAAA,EAClB,IAAI,OAAO,MAAM,YAAY,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAAA,IAAG,OAAO;AAAA,EACvE,IAAI,EAAE,gBAAgB,EAAE;AAAA,IAAa,OAAO;AAAA,EAC5C,IAAI,aAAa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;AAAA,EAGD,SAAS,WAAW,CAAC,GAAU;AAAA,IAE9B,IAAI,SAAS,EAAE;AAAA,IACf,OAAO,UAAU,OAAO,SAAS,YAAY,MAAM,KAAK;AAAA,MACvD,SAAS,OAAO;AAAA,IACjB;AAAA,IAEA,IAAI,CAAC;AAAA,MAAQ;AAAA,IAEb,MAAM,SAAS;AAAA,IACf,MAAM,OAAO,OAAO,aAAa,MAAM;AAAA,IAEvC,IAAI,CAAC;AAAA,MAAM;AAAA,IAGX,IAAI,KAAK,WAAW,GAAG;AAAA,MAAG;AAAA,IAG1B,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,KAAK,IAAI;AAAA,MAAG;AAAA,IAGrD,IAAI,OAAO,aAAa,QAAQ,KAAK,OAAO,aAAa,UAAU;AAAA,MAAG;AAAA,IAGtE,IAAI,OAAO,eAAe,eAAe,aAAa,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE;AAAA,MAAW;AAAA,IAE5G,EAAE,eAAe;AAAA,IACjB,GAAG,IAAI;AAAA;AAAA;",
8
- "debugId": "E926F5C48B21197864756E2164756E21",
9
- "names": []
10
- }
@@ -1,18 +0,0 @@
1
- /** Do a grow transition for the given element. This is meant to be used as a
2
- * handler for the `create` property.
3
- *
4
- * @param el The element to transition.
5
- *
6
- * The transition doesn't look great for table elements, and may have problems
7
- * for other specific cases as well.
8
- */
9
- export declare function grow(el: HTMLElement): Promise<void>;
10
- /** Do a shrink transition for the given element, and remove it from the DOM
11
- * afterwards. This is meant to be used as a handler for the `destroy` property.
12
- *
13
- * @param el The element to transition and remove.
14
- *
15
- * The transition doesn't look great for table elements, and may have problems
16
- * for other specific cases as well.
17
- */
18
- export declare function shrink(el: HTMLElement): Promise<void>;
@@ -1,47 +0,0 @@
1
- // src/transitions.ts
2
- var FADE_TIME = 400;
3
- var GROW_SHRINK_TRANSITION = `margin ${FADE_TIME}ms ease-out, transform ${FADE_TIME}ms ease-out`;
4
- function getGrowShrinkProps(el) {
5
- if (el.parentElement) {
6
- const parentStyle = getComputedStyle(el.parentElement);
7
- const isHorizontal = parentStyle.display === "flex" && (parentStyle.flexDirection || "").startsWith("row");
8
- if (isHorizontal) {
9
- return {
10
- marginLeft: `-${el.offsetWidth / 2}px`,
11
- marginRight: `-${el.offsetWidth / 2}px`,
12
- transform: "scaleX(0)"
13
- };
14
- }
15
- }
16
- return {
17
- marginBottom: `-${el.offsetHeight / 2}px`,
18
- marginTop: `-${el.offsetHeight / 2}px`,
19
- transform: "scaleY(0)"
20
- };
21
- }
22
- async function grow(el) {
23
- const props = getGrowShrinkProps(el);
24
- Object.assign(el.style, props);
25
- el.offsetHeight;
26
- el.style.transition = GROW_SHRINK_TRANSITION;
27
- for (const prop in props)
28
- el.style[prop] = "";
29
- setTimeout(() => {
30
- el.style.transition = "";
31
- }, FADE_TIME);
32
- }
33
- async function shrink(el) {
34
- const props = getGrowShrinkProps(el);
35
- el.style.transition = GROW_SHRINK_TRANSITION;
36
- Object.assign(el.style, props);
37
- setTimeout(() => {
38
- el.remove();
39
- }, FADE_TIME);
40
- }
41
- export {
42
- shrink,
43
- grow
44
- };
45
-
46
- //# debugId=ACD770C0365651E664756E2164756E21
47
- //# sourceMappingURL=transitions.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/transitions.ts"],
4
- "sourcesContent": [
5
- "const FADE_TIME = 400;\nconst GROW_SHRINK_TRANSITION = `margin ${FADE_TIME}ms ease-out, transform ${FADE_TIME}ms ease-out`;\n\nfunction getGrowShrinkProps(el: HTMLElement): Partial<CSSStyleDeclaration> {\n\tif (el.parentElement) {\n\t\tconst parentStyle = getComputedStyle(el.parentElement);\n\t\tconst isHorizontal =\n\t\t\tparentStyle.display === \"flex\" &&\n\t\t\t(parentStyle.flexDirection || \"\").startsWith(\"row\");\n\t\tif (isHorizontal) {\n\t\t\treturn {\n\t\t\t\tmarginLeft: `-${el.offsetWidth / 2}px`,\n\t\t\t\tmarginRight: `-${el.offsetWidth / 2}px`,\n\t\t\t\ttransform: \"scaleX(0)\",\n\t\t\t};\n\t\t}\n\t}\n\treturn {\n\t\tmarginBottom: `-${el.offsetHeight / 2}px`,\n\t\tmarginTop: `-${el.offsetHeight / 2}px`,\n\t\ttransform: \"scaleY(0)\",\n\t};\n}\n\n/** Do a grow transition for the given element. This is meant to be used as a\n * handler for the `create` property.\n *\n * @param el The element to transition.\n *\n * The transition doesn't look great for table elements, and may have problems\n * for other specific cases as well.\n */\nexport async function grow(el: HTMLElement) {\n\tconst props = getGrowShrinkProps(el);\n\tObject.assign(el.style, props);\n\n\t// Make sure the layouting has been performed, to cause transitions to trigger\n\tel.offsetHeight;\n\n\tel.style.transition = GROW_SHRINK_TRANSITION;\n\tfor (const prop in props) el.style[prop] = \"\";\n\tsetTimeout(() => {\n\t\t// Disable transitions.\n\t\tel.style.transition = \"\";\n\t}, FADE_TIME);\n}\n\n/** Do a shrink transition for the given element, and remove it from the DOM\n * afterwards. This is meant to be used as a handler for the `destroy` property.\n *\n * @param el The element to transition and remove.\n *\n * The transition doesn't look great for table elements, and may have problems\n * for other specific cases as well.\n */\nexport async function shrink(el: HTMLElement) {\n\t// Get original layout info\n\tconst props = getGrowShrinkProps(el);\n\n\t// Batch starting transitions in the write phase.\n\tel.style.transition = GROW_SHRINK_TRANSITION;\n\tObject.assign(el.style, props);\n\n\t// Remove the element after the transition is done.\n\tsetTimeout(() => {\n\t\tel.remove();\n\t}, FADE_TIME);\n}\n"
6
- ],
7
- "mappings": ";AAAA,IAAM,YAAY;AAClB,IAAM,yBAAyB,UAAU,mCAAmC;AAE5E,SAAS,kBAAkB,CAAC,IAA+C;AAAA,EAC1E,IAAI,GAAG,eAAe;AAAA,IACrB,MAAM,cAAc,iBAAiB,GAAG,aAAa;AAAA,IACrD,MAAM,eACL,YAAY,YAAY,WACvB,YAAY,iBAAiB,IAAI,WAAW,KAAK;AAAA,IACnD,IAAI,cAAc;AAAA,MACjB,OAAO;AAAA,QACN,YAAY,IAAI,GAAG,cAAc;AAAA,QACjC,aAAa,IAAI,GAAG,cAAc;AAAA,QAClC,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,cAAc,IAAI,GAAG,eAAe;AAAA,IACpC,WAAW,IAAI,GAAG,eAAe;AAAA,IACjC,WAAW;AAAA,EACZ;AAAA;AAWD,eAAsB,IAAI,CAAC,IAAiB;AAAA,EAC3C,MAAM,QAAQ,mBAAmB,EAAE;AAAA,EACnC,OAAO,OAAO,GAAG,OAAO,KAAK;AAAA,EAG7B,GAAG;AAAA,EAEH,GAAG,MAAM,aAAa;AAAA,EACtB,WAAW,QAAQ;AAAA,IAAO,GAAG,MAAM,QAAQ;AAAA,EAC3C,WAAW,MAAM;AAAA,IAEhB,GAAG,MAAM,aAAa;AAAA,KACpB,SAAS;AAAA;AAWb,eAAsB,MAAM,CAAC,IAAiB;AAAA,EAE7C,MAAM,QAAQ,mBAAmB,EAAE;AAAA,EAGnC,GAAG,MAAM,aAAa;AAAA,EACtB,OAAO,OAAO,GAAG,OAAO,KAAK;AAAA,EAG7B,WAAW,MAAM;AAAA,IAChB,GAAG,OAAO;AAAA,KACR,SAAS;AAAA;",
8
- "debugId": "ACD770C0365651E664756E2164756E21",
9
- "names": []
10
- }