@iann29/rastro 0.4.0 → 0.5.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 (92) hide show
  1. package/README.md +122 -17
  2. package/agent/integration.md +26 -10
  3. package/agent/manifest.json +10 -5
  4. package/agent/manifest.schema.json +14 -5
  5. package/dist/client/federation.d.ts +28 -8
  6. package/dist/client/federation.d.ts.map +1 -1
  7. package/dist/client/federation.js +12 -1
  8. package/dist/client/federation.js.map +1 -1
  9. package/dist/client/index.d.ts +262 -9
  10. package/dist/client/index.d.ts.map +1 -1
  11. package/dist/client/index.js +119 -2
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/component/_generated/api.d.ts +6 -0
  14. package/dist/component/_generated/api.d.ts.map +1 -1
  15. package/dist/component/_generated/api.js.map +1 -1
  16. package/dist/component/_generated/component.d.ts +71 -1
  17. package/dist/component/_generated/component.d.ts.map +1 -1
  18. package/dist/component/constants.d.ts +2 -0
  19. package/dist/component/constants.d.ts.map +1 -1
  20. package/dist/component/constants.js +7 -0
  21. package/dist/component/constants.js.map +1 -1
  22. package/dist/component/coverage.d.ts +1 -0
  23. package/dist/component/coverage.d.ts.map +1 -1
  24. package/dist/component/coverage.js +6 -1
  25. package/dist/component/coverage.js.map +1 -1
  26. package/dist/component/eventStore.d.ts +2 -0
  27. package/dist/component/eventStore.d.ts.map +1 -1
  28. package/dist/component/http.d.ts.map +1 -1
  29. package/dist/component/http.js +51 -1
  30. package/dist/component/http.js.map +1 -1
  31. package/dist/component/ingest.d.ts +2 -0
  32. package/dist/component/ingest.d.ts.map +1 -1
  33. package/dist/component/ingest.js +42 -3
  34. package/dist/component/ingest.js.map +1 -1
  35. package/dist/component/origin.d.ts +70 -0
  36. package/dist/component/origin.d.ts.map +1 -0
  37. package/dist/component/origin.js +230 -0
  38. package/dist/component/origin.js.map +1 -0
  39. package/dist/component/platforms.d.ts +33 -0
  40. package/dist/component/platforms.d.ts.map +1 -0
  41. package/dist/component/platforms.js +328 -0
  42. package/dist/component/platforms.js.map +1 -0
  43. package/dist/component/reports.d.ts +27 -72
  44. package/dist/component/reports.d.ts.map +1 -1
  45. package/dist/component/reports.js +51 -10
  46. package/dist/component/reports.js.map +1 -1
  47. package/dist/component/sanitize.d.ts +5 -0
  48. package/dist/component/sanitize.d.ts.map +1 -1
  49. package/dist/component/sanitize.js +33 -1
  50. package/dist/component/sanitize.js.map +1 -1
  51. package/dist/component/schema.d.ts +62 -7
  52. package/dist/component/schema.js +16 -1
  53. package/dist/component/schema.js.map +1 -1
  54. package/dist/component/trackedLinks.d.ts +91 -0
  55. package/dist/component/trackedLinks.d.ts.map +1 -0
  56. package/dist/component/trackedLinks.js +314 -0
  57. package/dist/component/trackedLinks.js.map +1 -0
  58. package/dist/component/useragent.d.ts +6 -0
  59. package/dist/component/useragent.d.ts.map +1 -1
  60. package/dist/component/useragent.js +9 -0
  61. package/dist/component/useragent.js.map +1 -1
  62. package/dist/component/validators.d.ts +51 -11
  63. package/dist/component/validators.d.ts.map +1 -1
  64. package/dist/component/validators.js +35 -1
  65. package/dist/component/validators.js.map +1 -1
  66. package/dist/tracker/generated.d.ts +6 -6
  67. package/dist/tracker/generated.d.ts.map +1 -1
  68. package/dist/tracker/generated.js +6 -6
  69. package/dist/tracker/generated.js.map +1 -1
  70. package/dist/tracker/tracker.d.ts +1 -0
  71. package/dist/tracker/tracker.d.ts.map +1 -1
  72. package/dist/tracker/tracker.js +16 -4
  73. package/dist/tracker/tracker.js.map +1 -1
  74. package/dist/tracker.min.js +1 -1
  75. package/docs/upgrading.md +152 -19
  76. package/llms.txt +6 -1
  77. package/package.json +2 -2
  78. package/src/component/_generated/api.ts +6 -0
  79. package/src/component/_generated/component.ts +152 -1
  80. package/src/component/constants.ts +7 -0
  81. package/src/component/coverage.ts +7 -1
  82. package/src/component/http.ts +56 -1
  83. package/src/component/ingest.ts +54 -1
  84. package/src/component/origin.ts +273 -0
  85. package/src/component/platforms.ts +359 -0
  86. package/src/component/reports.ts +74 -10
  87. package/src/component/sanitize.ts +39 -1
  88. package/src/component/schema.ts +18 -0
  89. package/src/component/trackedLinks.ts +384 -0
  90. package/src/component/useragent.ts +11 -0
  91. package/src/component/validators.ts +71 -0
  92. package/src/tracker/generated.ts +6 -6
@@ -0,0 +1,70 @@
1
+ import { type Channel, type Evidence } from "./validators.js";
2
+ /**
3
+ * Where a session came from, with the rule that proved it. `platform` is an
4
+ * id from platforms.ts, `unknown` for a referrer or utm_source outside the
5
+ * table (the raw value stays in the session's `source`), or `none`.
6
+ */
7
+ export type Origin = {
8
+ platform: string;
9
+ channel: Channel;
10
+ evidence: Evidence;
11
+ };
12
+ export type OriginInput = {
13
+ utmSource?: string;
14
+ utmMedium?: string;
15
+ /** Click-ID key names from the landing URL, never their values. */
16
+ clickIds?: string[];
17
+ /** An external referrer: callers drop the site's own (externalReferrer). */
18
+ referrer?: string;
19
+ /** The platform whose in-app browser opened the page (inAppPlatform). */
20
+ inApp?: string;
21
+ /** The landing carried a `ref` that resolved to an affiliate. */
22
+ affiliate?: boolean;
23
+ };
24
+ /**
25
+ * Classifies a session's first touch. One rule decides and the next only
26
+ * runs when it did not: utm_source, then click IDs, then the referrer host,
27
+ * then the in-app browser; an affiliate `ref` then sets the channel, keeping
28
+ * the platform and evidence an earlier rule found. Nothing at all is direct,
29
+ * the only way to be direct. Matching is exact, never by substring.
30
+ */
31
+ export declare function classifyOrigin(input: OriginInput): Origin;
32
+ /** The known click-ID keys of a list, deduplicated and bounded. */
33
+ export declare function knownClickIds(keys: string[]): string[] | undefined;
34
+ export declare function isPlatform(id: string): boolean;
35
+ /**
36
+ * The platform behind a stored `source` — a `utm_source` alias, a referrer
37
+ * host, or an Android package, as sessions and the overview keep them.
38
+ * `unknown` when the table has no row for it, `none` when the session had no
39
+ * source at all. Matching is `classifyOrigin`'s, never by substring, so a
40
+ * dashboard can group raw hosts the same way the classifier does.
41
+ */
42
+ export declare function platformForSource(source: string): string;
43
+ /**
44
+ * Where a platform's traffic lands when nothing says paid or organic:
45
+ * `direct` for `none`, `referral` for an id outside the table.
46
+ */
47
+ export declare function channelForPlatform(platform: string): Channel;
48
+ /**
49
+ * The value the `platform` aggregate dimension carries. A session that
50
+ * arrived by its platform's default channel keeps the bare id; one that
51
+ * deviated carries `platform@channel` (`google@paid_search` for a `gclid`,
52
+ * `unknown@email` for a newsletter nobody's table knows), so the aggregates
53
+ * hold the pair without a dimension of their own. `none` is always `none`:
54
+ * a session with no platform is the direct row, whatever its channel.
55
+ */
56
+ export declare function platformDimensionValue(origin: {
57
+ platform: string;
58
+ channel: Channel;
59
+ }): string;
60
+ /**
61
+ * The inverse: the platform and the channel behind a `platform` dimension
62
+ * value. A bare id — every session recorded before the pair was encoded
63
+ * included — reads as that platform's default channel, which is what it was
64
+ * classified with.
65
+ */
66
+ export declare function splitPlatformDimension(value: string): {
67
+ platform: string;
68
+ channel: Channel;
69
+ };
70
+ //# sourceMappingURL=origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../src/component/origin.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AA8DF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAkBzD;AAED,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,CAGlE;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG5D;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,MAAM,CAKT;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAUA"}
@@ -0,0 +1,230 @@
1
+ import { CLICK_IDS, PLATFORMS } from "./platforms.js";
2
+ import { channelValidator } from "./validators.js";
3
+ const MAX_CLICK_IDS = 8;
4
+ const DIRECT = {
5
+ platform: "none",
6
+ channel: "direct",
7
+ evidence: "none",
8
+ };
9
+ const UNKNOWN_REFERRAL = { platform: "unknown", channel: "referral" };
10
+ // Surfaces that add `fbclid` to their outbound links: a referrer or in-app
11
+ // browser naming one of them says which Meta app the click came from.
12
+ const META_FAMILY = new Set(["facebook", "instagram", "messenger", "threads"]);
13
+ const CHANNELS = new Set(channelValidator.members.map((member) => member.value));
14
+ const BY_ID = new Map(PLATFORMS.map((row) => [row.id, row]));
15
+ const BY_HOST = new Map();
16
+ const BY_ALIAS = new Map();
17
+ for (const row of PLATFORMS) {
18
+ const paid = { row, channel: paidChannel(row.channel) ?? row.channel };
19
+ for (const host of [...(row.domains ?? []), ...(row.packages ?? [])]) {
20
+ BY_HOST.set(host, { row, channel: row.channel });
21
+ }
22
+ for (const host of row.paidDomains ?? [])
23
+ BY_HOST.set(host, paid);
24
+ for (const alias of [row.id, ...(row.aliases ?? [])]) {
25
+ BY_ALIAS.set(alias, { row, channel: row.channel });
26
+ }
27
+ for (const alias of row.paidAliases ?? [])
28
+ BY_ALIAS.set(alias, paid);
29
+ }
30
+ const CLICK_ID_RANK = new Map(CLICK_IDS.map(([key], rank) => [key, rank]));
31
+ // utm_medium spellings besides the channel ids, which are accepted as they
32
+ // are (tracked links send them). "paid" and "organic" follow the platform:
33
+ // search or social, whichever it is. A Map, so no utm_medium can reach
34
+ // Object.prototype.
35
+ const MEDIUMS = new Map([
36
+ ["cpc", "paid"],
37
+ ["ppc", "paid"],
38
+ ["paid", "paid"],
39
+ ["paidsearch", "paid_search"],
40
+ ["sem", "paid_search"],
41
+ ["paidsocial", "paid_social"],
42
+ ["social", "organic_social"],
43
+ ["social-media", "organic_social"],
44
+ ["social_media", "organic_social"],
45
+ ["e-mail", "email"],
46
+ ["newsletter", "email"],
47
+ ["mail", "email"],
48
+ ["affiliates", "affiliate"],
49
+ ["partner", "affiliate"],
50
+ ["banner", "display"],
51
+ ["video", "display"],
52
+ ["cpm", "display"],
53
+ ["whatsapp", "messaging"],
54
+ ["sms", "messaging"],
55
+ ["print", "offline"],
56
+ ["qr", "offline"],
57
+ ["organic", "organic"],
58
+ ]);
59
+ /**
60
+ * Classifies a session's first touch. One rule decides and the next only
61
+ * runs when it did not: utm_source, then click IDs, then the referrer host,
62
+ * then the in-app browser; an affiliate `ref` then sets the channel, keeping
63
+ * the platform and evidence an earlier rule found. Nothing at all is direct,
64
+ * the only way to be direct. Matching is exact, never by substring.
65
+ */
66
+ export function classifyOrigin(input) {
67
+ const referred = referrerPlatform(input.referrer);
68
+ const inApp = input.inApp === undefined ? undefined : BY_ID.get(input.inApp);
69
+ const origin = fromUtm(input.utmSource, input.utmMedium) ??
70
+ fromClickIds(input.clickIds, referred?.platform, inApp?.id) ??
71
+ (referred && { ...referred, evidence: "referrer" }) ??
72
+ (inApp && {
73
+ platform: inApp.id,
74
+ channel: inApp.channel,
75
+ evidence: "inApp",
76
+ });
77
+ if (input.affiliate) {
78
+ return origin
79
+ ? { ...origin, channel: "affiliate" }
80
+ : { platform: "none", channel: "affiliate", evidence: "affiliate" };
81
+ }
82
+ return origin ?? DIRECT;
83
+ }
84
+ /** The known click-ID keys of a list, deduplicated and bounded. */
85
+ export function knownClickIds(keys) {
86
+ const known = [...new Set(keys.filter((key) => CLICK_ID_RANK.has(key)))];
87
+ return known.length > 0 ? known.slice(0, MAX_CLICK_IDS) : undefined;
88
+ }
89
+ export function isPlatform(id) {
90
+ return BY_ID.has(id);
91
+ }
92
+ /**
93
+ * The platform behind a stored `source` — a `utm_source` alias, a referrer
94
+ * host, or an Android package, as sessions and the overview keep them.
95
+ * `unknown` when the table has no row for it, `none` when the session had no
96
+ * source at all. Matching is `classifyOrigin`'s, never by substring, so a
97
+ * dashboard can group raw hosts the same way the classifier does.
98
+ */
99
+ export function platformForSource(source) {
100
+ const value = source.trim().toLowerCase();
101
+ if (!value || value === "direct" || value === "internal")
102
+ return "none";
103
+ return (BY_ALIAS.get(value) ?? hostHit(value))?.row.id ?? "unknown";
104
+ }
105
+ /**
106
+ * Where a platform's traffic lands when nothing says paid or organic:
107
+ * `direct` for `none`, `referral` for an id outside the table.
108
+ */
109
+ export function channelForPlatform(platform) {
110
+ if (platform === "none")
111
+ return DIRECT.channel;
112
+ return BY_ID.get(platform)?.channel ?? UNKNOWN_REFERRAL.channel;
113
+ }
114
+ /**
115
+ * The value the `platform` aggregate dimension carries. A session that
116
+ * arrived by its platform's default channel keeps the bare id; one that
117
+ * deviated carries `platform@channel` (`google@paid_search` for a `gclid`,
118
+ * `unknown@email` for a newsletter nobody's table knows), so the aggregates
119
+ * hold the pair without a dimension of their own. `none` is always `none`:
120
+ * a session with no platform is the direct row, whatever its channel.
121
+ */
122
+ export function platformDimensionValue(origin) {
123
+ if (origin.platform === "none")
124
+ return "none";
125
+ return origin.channel === channelForPlatform(origin.platform)
126
+ ? origin.platform
127
+ : `${origin.platform}@${origin.channel}`;
128
+ }
129
+ /**
130
+ * The inverse: the platform and the channel behind a `platform` dimension
131
+ * value. A bare id — every session recorded before the pair was encoded
132
+ * included — reads as that platform's default channel, which is what it was
133
+ * classified with.
134
+ */
135
+ export function splitPlatformDimension(value) {
136
+ const at = value.indexOf("@");
137
+ const platform = at < 0 ? value : value.slice(0, at);
138
+ const channel = at < 0 ? "" : value.slice(at + 1);
139
+ return {
140
+ platform,
141
+ channel: CHANNELS.has(channel)
142
+ ? channel
143
+ : channelForPlatform(platform),
144
+ };
145
+ }
146
+ function fromUtm(utmSource, utmMedium) {
147
+ const source = utmSource?.trim().toLowerCase();
148
+ if (!source)
149
+ return undefined;
150
+ // A host-shaped value (utm_source=chatgpt.com) matches like a referrer.
151
+ const hit = BY_ALIAS.get(source) ?? (source.includes(".") ? hostHit(source) : null);
152
+ const declared = hit?.channel ?? UNKNOWN_REFERRAL.channel;
153
+ const mediumKey = utmMedium?.trim().toLowerCase() ?? "";
154
+ const medium = CHANNELS.has(mediumKey)
155
+ ? mediumKey
156
+ : MEDIUMS.get(mediumKey);
157
+ const channel = medium === "paid"
158
+ ? (paidChannel(hit?.row.channel) ?? declared)
159
+ : medium === "organic"
160
+ ? (hit?.row.channel ?? declared)
161
+ : (medium ?? declared);
162
+ return {
163
+ platform: hit?.row.id ?? UNKNOWN_REFERRAL.platform,
164
+ channel,
165
+ evidence: "utm",
166
+ };
167
+ }
168
+ function fromClickIds(keys, referred, inApp) {
169
+ let best;
170
+ for (const key of keys ?? []) {
171
+ const rank = CLICK_ID_RANK.get(key);
172
+ if (rank !== undefined && (!best || rank < CLICK_ID_RANK.get(best[0]))) {
173
+ best = CLICK_IDS[rank];
174
+ }
175
+ }
176
+ if (!best)
177
+ return undefined;
178
+ const [, platform, channel] = best;
179
+ // The click ID names who generated the link. A Meta id defers to the Meta
180
+ // app the referrer or the in-app browser names, channel included (a
181
+ // Messenger link is messaging); an e-mail id takes the referrer's platform.
182
+ if (platform === "meta") {
183
+ const app = [referred, inApp].find((id) => id && META_FAMILY.has(id));
184
+ const row = app === undefined ? undefined : BY_ID.get(app);
185
+ return row
186
+ ? { platform: row.id, channel: row.channel, evidence: "clickId" }
187
+ : { platform, channel, evidence: "clickId" };
188
+ }
189
+ const resolved = platform === "unknown" && referred && referred !== "unknown"
190
+ ? referred
191
+ : platform;
192
+ return { platform: resolved, channel, evidence: "clickId" };
193
+ }
194
+ function referrerPlatform(referrer) {
195
+ if (!referrer)
196
+ return undefined;
197
+ let host;
198
+ try {
199
+ host = new URL(referrer).hostname.toLowerCase().replace(/\.$/, "");
200
+ }
201
+ catch {
202
+ return undefined;
203
+ }
204
+ if (!host)
205
+ return undefined;
206
+ const hit = hostHit(host);
207
+ return hit
208
+ ? { platform: hit.row.id, channel: hit.channel }
209
+ : UNKNOWN_REFERRAL;
210
+ }
211
+ /** The longest listed suffix of a host (a whole label at a time), or null. */
212
+ function hostHit(host) {
213
+ for (let suffix = host; suffix;) {
214
+ const hit = BY_HOST.get(suffix);
215
+ if (hit)
216
+ return hit;
217
+ const dot = suffix.indexOf(".");
218
+ suffix = dot < 0 ? "" : suffix.slice(dot + 1);
219
+ }
220
+ const row = PLATFORMS.find((candidate) => candidate.hostPattern?.test(host));
221
+ return row ? { row, channel: row.channel } : null;
222
+ }
223
+ function paidChannel(channel) {
224
+ if (channel === "organic_search")
225
+ return "paid_search";
226
+ if (channel === "organic_social")
227
+ return "paid_social";
228
+ return undefined;
229
+ }
230
+ //# sourceMappingURL=origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/component/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AACxE,OAAO,E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/**
3
+ * The closed table origin.ts classifies against. Bump the version whenever a
4
+ * row changes, and add a corpus case (origin.test.ts) for the change.
5
+ */
6
+ export declare const PLATFORM_TABLE_VERSION = 1;
7
+ export type PlatformRow = {
8
+ id: string;
9
+ /** Where the platform's traffic lands when nothing says paid or organic. */
10
+ channel: Channel;
11
+ /** Registrable-domain suffixes: a host equal to one or ending in "." + it. */
12
+ domains?: readonly string[];
13
+ /** Hosts matched in full, for a family with many country domains. */
14
+ hostPattern?: RegExp;
15
+ /** Hosts that only ever send the platform's ads (the paid channel). */
16
+ paidDomains?: readonly string[];
17
+ /** Android packages, as an `android-app://<package>` referrer names them. */
18
+ packages?: readonly string[];
19
+ /** The platform's in-app browser marker in the User-Agent. */
20
+ agent?: RegExp;
21
+ /** utm_source spellings, lowercase; the id itself always matches. */
22
+ aliases?: readonly string[];
23
+ /** utm_source spellings that themselves declare the paid channel. */
24
+ paidAliases?: readonly string[];
25
+ };
26
+ export declare const PLATFORMS: readonly PlatformRow[];
27
+ /**
28
+ * Click-ID keys the tracker may report by name, in priority order: the ad
29
+ * networks' own ids first, then the organic share ids, `fbclid` last because
30
+ * Meta adds it to organic clicks too. `unknown` platforms take the referrer's.
31
+ */
32
+ export declare const CLICK_IDS: ReadonlyArray<readonly [key: string, platform: string, channel: Channel]>;
33
+ //# sourceMappingURL=platforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../../src/component/platforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,qEAAqE;IACrE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC;AAOF,eAAO,MAAM,SAAS,EAAE,SAAS,WAAW,EAyS3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,aAAa,CACnC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAoB3D,CAAC"}