@chatwarden/core 0.1.1 → 0.1.3

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 (71) hide show
  1. package/README.md +128 -4
  2. package/dist/src/audit.d.ts +27 -5
  3. package/dist/src/audit.d.ts.map +1 -1
  4. package/dist/src/audit.js +57 -6
  5. package/dist/src/audit.js.map +1 -1
  6. package/dist/src/chatwarden.d.ts +183 -11
  7. package/dist/src/chatwarden.d.ts.map +1 -1
  8. package/dist/src/chatwarden.js +65 -10
  9. package/dist/src/chatwarden.js.map +1 -1
  10. package/dist/src/documents.d.ts +12 -2
  11. package/dist/src/documents.d.ts.map +1 -1
  12. package/dist/src/documents.js +56 -34
  13. package/dist/src/documents.js.map +1 -1
  14. package/dist/src/events.d.ts +3 -0
  15. package/dist/src/events.d.ts.map +1 -1
  16. package/dist/src/events.js.map +1 -1
  17. package/dist/src/index.d.ts +20 -11
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +11 -6
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/ladder.d.ts +2 -0
  22. package/dist/src/ladder.d.ts.map +1 -1
  23. package/dist/src/ladder.js +1 -1
  24. package/dist/src/ladder.js.map +1 -1
  25. package/dist/src/policy.d.ts +129 -0
  26. package/dist/src/policy.d.ts.map +1 -0
  27. package/dist/src/policy.js +242 -0
  28. package/dist/src/policy.js.map +1 -0
  29. package/dist/src/profile.d.ts +120 -7
  30. package/dist/src/profile.d.ts.map +1 -1
  31. package/dist/src/profile.js +295 -7
  32. package/dist/src/profile.js.map +1 -1
  33. package/dist/src/reporting.d.ts +127 -0
  34. package/dist/src/reporting.d.ts.map +1 -0
  35. package/dist/src/reporting.js +172 -0
  36. package/dist/src/reporting.js.map +1 -0
  37. package/dist/src/reports.d.ts +80 -4
  38. package/dist/src/reports.d.ts.map +1 -1
  39. package/dist/src/reports.js +120 -6
  40. package/dist/src/reports.js.map +1 -1
  41. package/dist/src/staffReports.d.ts +17 -5
  42. package/dist/src/staffReports.d.ts.map +1 -1
  43. package/dist/src/staffReports.js +22 -5
  44. package/dist/src/staffReports.js.map +1 -1
  45. package/dist/src/staffViews.d.ts +138 -0
  46. package/dist/src/staffViews.d.ts.map +1 -0
  47. package/dist/src/staffViews.js +205 -0
  48. package/dist/src/staffViews.js.map +1 -0
  49. package/dist/src/team.d.ts +149 -0
  50. package/dist/src/team.d.ts.map +1 -0
  51. package/dist/src/team.js +385 -0
  52. package/dist/src/team.js.map +1 -0
  53. package/dist/src/types.d.ts +245 -4
  54. package/dist/src/types.d.ts.map +1 -1
  55. package/dist/src/types.js +5 -0
  56. package/dist/src/types.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/audit.ts +71 -7
  59. package/src/chatwarden.ts +245 -20
  60. package/src/documents.ts +70 -43
  61. package/src/events.ts +10 -1
  62. package/src/index.ts +109 -4
  63. package/src/ladder.ts +1 -1
  64. package/src/policy.ts +288 -0
  65. package/src/profile.ts +369 -14
  66. package/src/reporting.ts +251 -0
  67. package/src/reports.ts +163 -10
  68. package/src/staffReports.ts +33 -7
  69. package/src/staffViews.ts +325 -0
  70. package/src/team.ts +422 -0
  71. package/src/types.ts +257 -4
@@ -0,0 +1,205 @@
1
+ import { HISTORY_LOOKBACK_MS } from './ladder.js';
2
+ import { reporterSuspendedUntil } from './reports.js';
3
+ import { findReason } from './reporting.js';
4
+ import { parseRuleRef } from './rules.js';
5
+ import { SANCTION_SOURCES } from './sanctions.js';
6
+ import { b64urlDecode, b64urlEncode } from './staffReports.js';
7
+ // The staff READ views behind the moderator hub: sanction groups, a reporter's record and the blocked-message list. Pure
8
+ // functions over the store; nothing here writes. Every shape lists its fields by name, so a column added to a row can
9
+ // never leak into a response. They carry subject ids and raw chat lines: staff channels only, never send to a player.
10
+ const DAY_MS = 24 * 3_600_000;
11
+ /** The page size when `limit` is missing or not a number. */
12
+ export const SANCTION_PAGE_DEFAULT = 50;
13
+ /** The largest page; a bigger `limit` is clamped to this. */
14
+ export const SANCTION_PAGE_MAX = 200;
15
+ /** The most sanction groups `cw.sanctions.forPerson` returns (the newest). */
16
+ export const PERSON_SANCTIONS_MAX = 200;
17
+ /** A sanction list query that cannot be answered: a cursor that is not one we issued, or an unknown source. The message never echoes the input. */
18
+ export class SanctionQueryError extends Error {
19
+ field;
20
+ constructor(field) {
21
+ super(`sanctions.list: invalid ${field}`);
22
+ this.name = 'SanctionQueryError';
23
+ this.field = field;
24
+ }
25
+ }
26
+ /**
27
+ * Is this sanction in force at `now`? A revoked row never is, nor is one that has not started (`startsAt` after `now`). A restriction (chat, area, ban) applies strictly before its
28
+ * `endsAt` and, with no end, until it is revoked. A warning or note restricts nothing and has no end, so it counts for as
29
+ * long as the escalation ladder counts it: 90 days from its `startsAt` (`HISTORY_LOOKBACK_MS`, inclusive). A row without
30
+ * `revokedAt` (a load that does not carry it) reads as not revoked.
31
+ */
32
+ export function isSanctionActive(row, now) {
33
+ if (row.revokedAt !== undefined && row.revokedAt !== null)
34
+ return false;
35
+ if (row.startsAt > now)
36
+ return false;
37
+ if (isRecordKind(row.kind))
38
+ return row.startsAt >= now - HISTORY_LOOKBACK_MS;
39
+ return row.endsAt === null || row.endsAt > now;
40
+ }
41
+ const isRecordKind = (kind) => kind === 'warning' || kind === 'note';
42
+ /** The rule text a row stores, as a RuleRef; null when there is none or it cannot be read. */
43
+ function ruleOf(text) {
44
+ if (text === null)
45
+ return null;
46
+ try {
47
+ return parseRuleRef(text);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ /** The staff view of one subject row. Lists each field by name. */
54
+ export function sanctionGroupView(row, now) {
55
+ return {
56
+ groupId: row.groupId,
57
+ refCode: row.refCode,
58
+ kind: row.kind,
59
+ rule: ruleOf(row.rule),
60
+ startsAt: row.startsAt,
61
+ endsAt: isRecordKind(row.kind) ? null : row.endsAt,
62
+ reason: row.reason,
63
+ actor: row.actor,
64
+ source: row.source,
65
+ automated: row.automated,
66
+ active: isSanctionActive(row, now),
67
+ pending: row.pending,
68
+ revokedAt: row.revokedAt ?? null,
69
+ revokedBy: row.revokedBy ?? null,
70
+ revokeReason: row.revokeReason ?? null,
71
+ };
72
+ }
73
+ /**
74
+ * A person's sanctions, newest first: the last 90 days (the escalation window, by `startsAt`) plus every permanent one
75
+ * that has not been revoked, across every alias merged into them. Every group still in force (not revoked, no end or an
76
+ * end in the future, of any age) is always included; the rest of the window fills what is left of
77
+ * {@link PERSON_SANCTIONS_MAX}, newest first.
78
+ */
79
+ export function sanctionsOfPerson(store, subjects, person, now) {
80
+ const aliases = subjects.aliasesOf(person);
81
+ const inForce = store.listSubjectSanctions({ subjects: aliases, activeAt: now, limit: PERSON_SANCTIONS_MAX });
82
+ const taken = new Set(inForce.map((r) => r.id));
83
+ const window = store.listSubjectSanctions({
84
+ subjects: aliases,
85
+ since: now - HISTORY_LOOKBACK_MS,
86
+ alsoPermanent: true,
87
+ limit: PERSON_SANCTIONS_MAX,
88
+ });
89
+ const room = Math.max(0, PERSON_SANCTIONS_MAX - inForce.length);
90
+ const rest = window.filter((r) => !taken.has(r.id)).slice(0, room);
91
+ return [...inForce, ...rest]
92
+ .sort((a, b) => b.startsAt - a.startsAt || (a.id < b.id ? 1 : a.id > b.id ? -1 : 0))
93
+ .map((r) => sanctionGroupView(r, now));
94
+ }
95
+ const clampPage = (limit) => {
96
+ if (typeof limit !== 'number' || Number.isNaN(limit))
97
+ return SANCTION_PAGE_DEFAULT;
98
+ return Math.min(SANCTION_PAGE_MAX, Math.max(1, Math.floor(limit)));
99
+ };
100
+ /** The opaque cursor for "older than this row": base64url of `startsAt:id`. */
101
+ function encodeSanctionCursor(startsAt, id) {
102
+ return b64urlEncode(`${startsAt}:${id}`);
103
+ }
104
+ function decodeSanctionCursor(cursor) {
105
+ const text = typeof cursor === 'string' ? b64urlDecode(cursor) : null;
106
+ const at = text === null ? -1 : text.indexOf(':');
107
+ if (text === null || at < 1 || at === text.length - 1)
108
+ throw new SanctionQueryError('cursor');
109
+ const time = text.slice(0, at);
110
+ const startsAt = Number(time);
111
+ if (!/^\d{1,16}$/.test(time) || !Number.isSafeInteger(startsAt))
112
+ throw new SanctionQueryError('cursor');
113
+ return { startsAt, id: text.slice(at + 1) };
114
+ }
115
+ /**
116
+ * Every person's sanctions, newest first, one page at a time. Not windowed. Throws {@link SanctionQueryError} for an
117
+ * unknown `source` or a cursor that is not one of ours. As with reports, a full page always carries a cursor, so the page
118
+ * after an exactly-full last one is empty with `next` null.
119
+ */
120
+ export function listSanctionGroups(store, subjects, q, now) {
121
+ const input = typeof q === 'object' && q !== null ? q : {};
122
+ if (input.source !== undefined && !SANCTION_SOURCES.includes(input.source)) {
123
+ throw new SanctionQueryError('source');
124
+ }
125
+ const cursor = input.cursor === undefined || input.cursor === null ? null : decodeSanctionCursor(input.cursor);
126
+ const limit = clampPage(input.limit);
127
+ const rows = store.listSubjectSanctions({
128
+ ...(input.source === undefined ? {} : { source: input.source }),
129
+ ...(cursor === null ? {} : { before: cursor.startsAt, beforeId: cursor.id }),
130
+ limit,
131
+ });
132
+ const last = rows[rows.length - 1];
133
+ return {
134
+ items: rows.map((r) => ({ ...sanctionGroupView(r, now), person: subjects.canonical(r.value) })),
135
+ next: rows.length === limit && last !== undefined ? encodeSanctionCursor(last.startsAt, last.id) : null,
136
+ };
137
+ }
138
+ export function reporterRecord(store, subjects, limits, person, now, reasons = []) {
139
+ const root = subjects.canonical(person);
140
+ const aliases = subjects.aliasesOf(root);
141
+ const tally = store.reporterTally(aliases);
142
+ let reasonDecided = 0;
143
+ let reasonMatched = 0;
144
+ for (const d of store.loadReporterDecisions?.(aliases) ?? []) {
145
+ const reason = findReason(reasons, d.reason);
146
+ // A reason that is gone, or one with no rules (`other`, say), cannot be judged: it is left out of both counts.
147
+ if (reason === undefined || reason.rules.length === 0)
148
+ continue;
149
+ reasonDecided++;
150
+ const target = subjects.canonical(d.target);
151
+ if (d.actions.some((a) => typeof a.rule === 'number' && subjects.canonical(a.subject) === target && reason.rules.includes(a.rule))) {
152
+ reasonMatched++;
153
+ }
154
+ }
155
+ const marks = [];
156
+ for (const m of store.loadBadFaithMarks(now - limits.suspendWindowMs)) {
157
+ if (subjects.canonical(m.reporter) === root)
158
+ marks.push(m.actionedAt);
159
+ }
160
+ return {
161
+ reports: tally.open + tally.actioned + tally.dismissed,
162
+ open: tally.open,
163
+ actioned: tally.actioned,
164
+ dismissed: tally.dismissed,
165
+ badFaith: tally.badFaith,
166
+ suspendedUntil: reporterSuspendedUntil(marks, limits),
167
+ reasonMatched,
168
+ reasonDecided,
169
+ };
170
+ }
171
+ // ---------------------------------------------------------------------------
172
+ // Blocked messages
173
+ // ---------------------------------------------------------------------------
174
+ /** The most blocked messages one call lists. */
175
+ export const BLOCKED_MAX = 500;
176
+ /** The look-back windows of the blocked list, in days. */
177
+ export const BLOCKED_DAYS = [1, 7, 30];
178
+ function sinceOf(days, now) {
179
+ if (!BLOCKED_DAYS.includes(days))
180
+ throw new RangeError('blocked: days must be 1, 7 or 30');
181
+ return now - days * DAY_MS;
182
+ }
183
+ /** The blocked lines of the last `days` days (1, 7 or 30; `RangeError` otherwise), newest first, at most {@link BLOCKED_MAX}. */
184
+ export function blockedItems(store, subjects, days, now) {
185
+ return store.listStrikes(sinceOf(days, now), BLOCKED_MAX).map((s) => ({
186
+ id: s.id,
187
+ at: s.at,
188
+ roomId: s.roomId,
189
+ termId: s.termId,
190
+ person: subjects.canonical(s.subject),
191
+ text: s.rawLine,
192
+ }));
193
+ }
194
+ /**
195
+ * How many strikes each term earned in the last `days` days (1, 7 or 30; `RangeError` otherwise). Terms with none are
196
+ * absent. The record has no prototype: read it with `counts[id]` or `Object.hasOwn`, never `counts.hasOwnProperty`.
197
+ */
198
+ export function blockedCountsByTerm(store, days, now) {
199
+ // A null-prototype record, so a term id such as `__proto__` is an ordinary key and reads back as one.
200
+ const out = Object.create(null);
201
+ for (const r of store.countStrikesByTerm(sinceOf(days, now)))
202
+ out[r.termId] = r.count;
203
+ return out;
204
+ }
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2
+ import type { SubjectIndex } from './subjects.js';
3
+ import type { Clock, ReasonRow, ReportCategory, Store, SubjectId } from './types.js';
4
+ /** How long a viewing beat counts: 30 seconds. */
5
+ export declare const VIEWING_TTL_MS = 30000;
6
+ /** The longest saved-reason label, in characters (code points), after trimming. */
7
+ export declare const REASON_LABEL_MAX = 40;
8
+ /** The longest saved-reason text, in characters (code points), after trimming. */
9
+ export declare const REASON_TEXT_MAX = 500;
10
+ /** The most saved reasons the kit keeps. */
11
+ export declare const REASONS_MAX = 200;
12
+ /** The most cases one actor keeps open at once for viewing; a newer beat drops their oldest. */
13
+ export declare const VIEWING_PER_ACTOR_MAX = 20;
14
+ /** How many times a claim is attempted when another process wins the database lock race in between (SQLITE_BUSY). */
15
+ export declare const CLAIM_BUSY_TRIES = 3;
16
+ /** A claim as staff see it. Staff only: `by` is a staff actor. */
17
+ export interface CaseClaim {
18
+ by: string;
19
+ /** Epoch ms the holder took the case (kept across heartbeats). */
20
+ since: number;
21
+ /** Epoch ms it lapses without another beat; the case is held strictly before it. */
22
+ until: number;
23
+ }
24
+ /**
25
+ * What `cases.claim` answers: the claim now in force (`tookOverFrom` names the actor whose live claim a take over
26
+ * replaced, else null), or why not: the person has no open case, or somebody else holds it (their live claim comes back).
27
+ */
28
+ export type ClaimOutcome = {
29
+ ok: true;
30
+ claim: CaseClaim;
31
+ tookOverFrom: string | null;
32
+ } | {
33
+ ok: false;
34
+ error: 'no_case';
35
+ } | {
36
+ ok: false;
37
+ error: 'claimed';
38
+ claim: CaseClaim;
39
+ };
40
+ /** The case take next claimed: the person, their newest open report, and the claim just taken. */
41
+ export interface NextCase {
42
+ person: SubjectId;
43
+ reportId: string;
44
+ claim: CaseClaim;
45
+ }
46
+ /** A saved reason that cannot be stored: a label or text outside its limits, a bad id, or the list is full. Fixed message. */
47
+ export declare class ReasonError extends Error {
48
+ readonly field: 'label' | 'text' | 'id' | 'active' | 'input' | 'limit';
49
+ constructor(field: ReasonError['field']);
50
+ }
51
+ /**
52
+ * Run a store transaction that reads then writes, again when it lost a lock race: the retry starts a fresh read, so the
53
+ * loser of a race for a case sees the winner's claim and answers the normal "claimed", not an error. Bounded by
54
+ * {@link CLAIM_BUSY_TRIES}; any other error, and the last busy one, is thrown.
55
+ */
56
+ export declare function retryBusy<T>(run: () => T): T;
57
+ /** Who has a case open, per person, each beat lasting {@link VIEWING_TTL_MS}. In memory, per process, never stored. */
58
+ export declare class ViewingPresence {
59
+ private readonly clock;
60
+ /** person -> actor -> the instant the beat stops counting. */
61
+ private readonly seen;
62
+ /** actor -> the people they have open, oldest beat first (refreshing a beat moves it last). */
63
+ private readonly byActor;
64
+ /** When the last sweep of expired beats ran; a sweep runs at most once per beat lifetime. */
65
+ private lastSweep;
66
+ constructor(clock: Clock);
67
+ /** Record that `actor` has `person`'s case open now. */
68
+ touch(person: SubjectId, actor: string): void;
69
+ private forget;
70
+ /** The actors whose beat still counts for `person`, sorted, leaving `except` out. */
71
+ viewers(person: SubjectId, except?: string): string[];
72
+ private sweep;
73
+ }
74
+ export interface TeamDeps {
75
+ store: Store;
76
+ subjects: SubjectIndex;
77
+ clock: Clock;
78
+ /** The reporting reasons in force, so an old id (`disruption`) finds the reason that replaced it. Default: none. */
79
+ reasons?: () => readonly ReportReason[];
80
+ }
81
+ /** Claims, take next and viewing. The facade exposes it as `cw.cases`. */
82
+ export declare class CaseDesk {
83
+ private readonly store;
84
+ private readonly subjects;
85
+ private readonly clock;
86
+ private readonly reasons;
87
+ private readonly presence;
88
+ constructor(deps: TeamDeps);
89
+ /** The live claim on a person's case, or null. */
90
+ holder(person: SubjectId): CaseClaim | null;
91
+ /** The live claims among these people (one store read), keyed by canonical person. People nobody holds are absent. */
92
+ holders(people: readonly SubjectId[]): Map<SubjectId, CaseClaim>;
93
+ /**
94
+ * Claim a person's case for `actor`, or beat the claim they already hold. Needs at least one OPEN report against the
95
+ * person (else `no_case`). `takeOver` moves a live claim of someone else to `actor`; the caller decides who may use it.
96
+ * One atomic conditional write in the store: of two moderators racing, exactly one wins.
97
+ */
98
+ claim(person: SubjectId, actor: string, opts?: {
99
+ takeOver?: boolean;
100
+ }): ClaimOutcome;
101
+ /** Release `actor`'s claim on the person. True only when it ended a live claim of theirs. */
102
+ release(person: SubjectId, actor: string): boolean;
103
+ /**
104
+ * After a decision: end `actor`'s own claim on the person only when the person has no open report left (any alias counts).
105
+ * While another report about them is open the claim is kept untouched, so its heartbeat and its 10 minutes go on as normal and
106
+ * nobody else can take the case from under the moderator who is working through it. True only when it ended a live claim.
107
+ * The check and the release are one transaction.
108
+ */
109
+ releaseWhenDone(person: SubjectId, actor: string): boolean;
110
+ /**
111
+ * Claim and return the oldest open case nobody holds (`category` limits it to cases with an open report of that
112
+ * category, `reason` to cases with an open report that gave that reason id, or none at all for `null`; both may be given), or null. A case is a person, ranked by their OLDEST open report; it opens on their NEWEST. A case
113
+ * `actor` already holds is skipped. Each candidate is one atomic conditional claim, so two moderators racing never
114
+ * get the same case.
115
+ */
116
+ next(actor: string, filter?: {
117
+ category?: ReportCategory;
118
+ reason?: string | null;
119
+ }): NextCase | null;
120
+ /**
121
+ * `actor` has the person's case open now (a beat; it counts for 30 seconds). Never stored, never blocks anyone. Only a
122
+ * person with an open report is tracked (false otherwise, nothing recorded), and one actor keeps at most
123
+ * {@link VIEWING_PER_ACTOR_MAX} cases open: a newer beat drops their oldest. True when the beat was recorded.
124
+ */
125
+ view(person: SubjectId, actor: string): boolean;
126
+ /** Who has the person's case open now, sorted, leaving `except` out. */
127
+ viewers(person: SubjectId, except?: string): string[];
128
+ /** {@link viewers} for several people at once; people nobody is viewing are absent. */
129
+ viewersOf(people: readonly SubjectId[], except?: string): Map<SubjectId, string[]>;
130
+ }
131
+ /** Saved decision reasons. The facade exposes it as `cw.reasons`. */
132
+ export declare class ReasonBook {
133
+ private readonly store;
134
+ constructor(store: Store);
135
+ list(): ReasonRow[];
136
+ add(input: {
137
+ label: string;
138
+ text: string;
139
+ }): ReasonRow;
140
+ /** Change the label and/or text. Null for an unknown id. At least one of the two is required. */
141
+ update(id: string, patch: {
142
+ label?: string;
143
+ text?: string;
144
+ }): ReasonRow | null;
145
+ /** Switch a reason on or off. Null for an unknown id. */
146
+ setActive(id: string, active: boolean): ReasonRow | null;
147
+ private find;
148
+ }
149
+ //# sourceMappingURL=team.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.d.ts","sourceRoot":"","sources":["../../src/team.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMrF,kDAAkD;AAClD,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,kFAAkF;AAClF,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,4CAA4C;AAC5C,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,qHAAqH;AACrH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AASlC,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC3D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC/B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,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