@ekwo-ai/core 0.30.0 → 0.32.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.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * A `Backend` over a `@supabase/supabase-js` client, signed in already.
3
+ *
4
+ * The MCP server signs a person in and hands its client here; `EkwoClient`
5
+ * does the same with the client its caller built. Both then read and write
6
+ * through the same five operations as every other surface, and both find the
7
+ * socle by its marker (decision 0090): `ekwo`, or `public` on an installation
8
+ * the socle has not moved out of yet. A call never rests on whichever schema
9
+ * the client happens to be bound to.
10
+ *
11
+ * The client is described by its shape, not imported: this package keeps no
12
+ * runtime dependency on `supabase-js`, and any client that answers the same
13
+ * builder calls works.
14
+ */
15
+ import { type AgentSession, type Row, type SocleBackend } from './backend.js';
16
+ /** What PostgREST answers, as `supabase-js` hands it over. */
17
+ export interface PostgrestAnswer {
18
+ data: unknown;
19
+ error: {
20
+ message: string;
21
+ code?: string;
22
+ details?: string | null;
23
+ hint?: string | null;
24
+ } | null;
25
+ count?: number | null;
26
+ status?: number;
27
+ }
28
+ /** A request being built — filters, order, range — which answers once awaited. */
29
+ export interface PostgrestRequestLike extends PromiseLike<PostgrestAnswer> {
30
+ eq(column: string, value: unknown): PostgrestRequestLike;
31
+ neq(column: string, value: unknown): PostgrestRequestLike;
32
+ gt(column: string, value: unknown): PostgrestRequestLike;
33
+ gte(column: string, value: unknown): PostgrestRequestLike;
34
+ lt(column: string, value: unknown): PostgrestRequestLike;
35
+ lte(column: string, value: unknown): PostgrestRequestLike;
36
+ in(column: string, values: unknown[]): PostgrestRequestLike;
37
+ ilike(column: string, pattern: string): PostgrestRequestLike;
38
+ is(column: string, value: null): PostgrestRequestLike;
39
+ order(column: string, options: {
40
+ ascending: boolean;
41
+ }): PostgrestRequestLike;
42
+ limit(count: number): PostgrestRequestLike;
43
+ range(from: number, to: number): PostgrestRequestLike;
44
+ select(columns: string): PostgrestRequestLike;
45
+ }
46
+ /** The slice of a `supabase-js` client a backend is built on. */
47
+ export interface SupabaseClientLike {
48
+ rpc(fn: string, args?: Record<string, unknown>, options?: {
49
+ count?: 'exact';
50
+ }): PostgrestRequestLike;
51
+ /** Tables. A client without it answers functions only, and a table read says so by name. */
52
+ from?(table: string): {
53
+ select(columns: string): PostgrestRequestLike;
54
+ insert(rows: Row[]): PostgrestRequestLike;
55
+ update(patch: Row): PostgrestRequestLike;
56
+ delete(): PostgrestRequestLike;
57
+ };
58
+ /**
59
+ * The same client, pointed at one schema — `Accept-Profile` and
60
+ * `Content-Profile`. A client without it is taken as bound to the socle's
61
+ * schema already, and every call goes to that one.
62
+ */
63
+ schema?(name: string): SupabaseClientLike;
64
+ auth?: {
65
+ stopAutoRefresh?(): Promise<void> | void;
66
+ };
67
+ }
68
+ export interface SupabaseBackendOptions {
69
+ /** Who the client is signed in as, when the caller knows. */
70
+ actingAs?: string | undefined;
71
+ /** Set by a surface that marks every request as an agent's. */
72
+ agent?: AgentSession | undefined;
73
+ /** Turns a message of the database into the error a surface throws. Defaults to a `BooksError` carrying its code. */
74
+ explain?: ((message: string) => Error) | undefined;
75
+ }
76
+ /**
77
+ * The backend over `client`, with the socle found by its marker and named on
78
+ * every call (`onSocle()`). The client is signed in already: what it may see
79
+ * is what row level security lets that person see.
80
+ */
81
+ export declare function supabaseBackend(client: SupabaseClientLike, options?: SupabaseBackendOptions): SocleBackend;
82
+ //# sourceMappingURL=supabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/books/supabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA2E,KAAK,YAAY,EAA6B,KAAK,GAAG,EAAoB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAIpM,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;Q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/**
2
+ * A `Backend` over a `@supabase/supabase-js` client, signed in already.
3
+ *
4
+ * The MCP server signs a person in and hands its client here; `EkwoClient`
5
+ * does the same with the client its caller built. Both then read and write
6
+ * through the same five operations as every other surface, and both find the
7
+ * socle by its marker (decision 0090): `ekwo`, or `public` on an installation
8
+ * the socle has not moved out of yet. A call never rests on whichever schema
9
+ * the client happens to be bound to.
10
+ *
11
+ * The client is described by its shape, not imported: this package keeps no
12
+ * runtime dependency on `supabase-js`, and any client that answers the same
13
+ * builder calls works.
14
+ */
15
+ import { BooksError, identifier, onSocle, socleMarkerAnswer, socleSchemaResolver } from './backend.js';
16
+ import { SOCLE_MARKER, SOCLE_SCHEMA } from './socle-names.js';
17
+ import { socleCode } from '../refusal.js';
18
+ /** The error of the database, its code read from the message. */
19
+ function plainError(message) {
20
+ const code = socleCode(message);
21
+ return new BooksError(message, code === undefined ? {} : { code });
22
+ }
23
+ /** The filter half of a request, whatever else it carries. */
24
+ function applyFilters(builder, filters) {
25
+ let out = builder;
26
+ for (const filter of filters ?? []) {
27
+ const column = identifier(filter.column);
28
+ switch (filter.op) {
29
+ case 'is':
30
+ out = out.is(column, null);
31
+ break;
32
+ case 'in':
33
+ out = out.in(column, filter.value);
34
+ break;
35
+ case 'ilike':
36
+ out = out.ilike(column, filter.value);
37
+ break;
38
+ default:
39
+ out = out[filter.op](column, filter.value);
40
+ }
41
+ }
42
+ return out;
43
+ }
44
+ /**
45
+ * The backend over `client`, with the socle found by its marker and named on
46
+ * every call (`onSocle()`). The client is signed in already: what it may see
47
+ * is what row level security lets that person see.
48
+ */
49
+ export function supabaseBackend(client, options = {}) {
50
+ const explain = options.explain ?? plainError;
51
+ /** Unwraps an answer, letting the schema's own message through. */
52
+ const unwrap = (answer, what) => {
53
+ if (answer.error !== null) {
54
+ const { message, details, hint } = answer.error;
55
+ // `details` is where Postgres puts the rest of a raise; keep it.
56
+ const full = [message, details, hint].filter((part) => typeof part === 'string' && part.length > 0).join(' — ');
57
+ throw explain(full.length > 0 ? full : `${what} failed`);
58
+ }
59
+ if (answer.data === null)
60
+ throw new BooksError(`${what}: nothing came back`);
61
+ return answer.data;
62
+ };
63
+ /**
64
+ * The client, pointed at one schema. PostgREST answers 406 for a schema the
65
+ * project does not expose, and no migration can expose one.
66
+ */
67
+ const on = (schema) => schema === undefined || client.schema === undefined ? client : client.schema(identifier(schema));
68
+ const tables = (schema, table) => {
69
+ const target = on(schema);
70
+ if (target.from === undefined) {
71
+ throw new BooksError(`client_without_tables: this client calls functions only, and reading ${table} needs a table.`);
72
+ }
73
+ return target.from(identifier(table));
74
+ };
75
+ const asRows = (data) => (Array.isArray(data) ? data : [data]);
76
+ const backend = {
77
+ mode: 'postgrest',
78
+ actingAs: options.actingAs,
79
+ agent: options.agent,
80
+ async rpc(fn, args = {}, schema) {
81
+ // A function returning one composite row comes back as an object, a
82
+ // set-returning one as an array. Callers see an array either way.
83
+ return asRows(unwrap(await on(schema).rpc(identifier(fn), args), fn));
84
+ },
85
+ // PostgREST cuts every answer at the `max_rows` of its server and says
86
+ // nothing in the body; a range with the exact count is how `readWhole()`
87
+ // reads a long ledger to its last line.
88
+ async rpcPage(fn, args, schema, page) {
89
+ const answer = await on(schema)
90
+ .rpc(identifier(fn), args, { count: 'exact' })
91
+ .range(page.offset, page.offset + page.limit - 1);
92
+ // A range past the end — rows removed since the last one — is refused
93
+ // (`PGRST103`): no rows and no count, which reads again from the start.
94
+ if (answer.error?.code === 'PGRST103')
95
+ return { rows: [], total: null };
96
+ return { rows: asRows(unwrap(answer, fn)), total: answer.count ?? null };
97
+ },
98
+ async rpcVoid(fn, args = {}, schema) {
99
+ const answer = await on(schema).rpc(identifier(fn), args);
100
+ if (answer.error !== null)
101
+ throw explain(answer.error.message);
102
+ },
103
+ async select(query) {
104
+ let builder = applyFilters(tables(query.schema, query.table).select(query.columns.join(',')), query.where);
105
+ for (const order of query.order ?? []) {
106
+ builder = builder.order(identifier(order.column), { ascending: order.ascending !== false });
107
+ }
108
+ if (query.limit !== undefined)
109
+ builder = builder.limit(query.limit);
110
+ return unwrap(await builder, `select from ${query.table}`);
111
+ },
112
+ async insert(table, rows, returning = ['*'], schema) {
113
+ const answer = await tables(schema, table).insert(rows).select(returning.join(','));
114
+ return unwrap(answer, `insert into ${table}`);
115
+ },
116
+ async update(table, patch, where, returning = ['*'], schema) {
117
+ const builder = applyFilters(tables(schema, table).update(patch), where);
118
+ return unwrap(await builder.select(returning.join(',')), `update ${table}`);
119
+ },
120
+ async remove(table, where, schema) {
121
+ const answer = await applyFilters(tables(schema, table).delete(), where);
122
+ if (answer.error !== null)
123
+ throw explain(answer.error.message);
124
+ },
125
+ async close() {
126
+ // Stops the refresh timer; there is no socket to give back.
127
+ await client.auth?.stopAutoRefresh?.();
128
+ },
129
+ };
130
+ // A client that cannot be pointed at a schema is bound to the socle's
131
+ // already — Ekwo Cloud builds it so — and there is nothing to look for.
132
+ const socle = client.schema === undefined
133
+ ? async () => SOCLE_SCHEMA
134
+ : socleSchemaResolver((schema) => socleMarkerOver(on(schema), explain));
135
+ return onSocle(backend, socle);
136
+ }
137
+ /** Whether the socle's marker answers in the schema this client is pointed at. */
138
+ async function socleMarkerOver(client, explain) {
139
+ const answer = await client.rpc(SOCLE_MARKER);
140
+ const found = socleMarkerAnswer({ ok: answer.error === null, status: answer.status, code: answer.error?.code });
141
+ if (found === undefined)
142
+ throw explain(answer.error?.message ?? `${SOCLE_MARKER} failed`);
143
+ return found;
144
+ }
145
+ //# sourceMappingURL=supabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supabase.js","sourceRoot":"","sources":["../../src/books/supabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAA+F,MAAM,cAAc,CAAC;AACpM,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAA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O,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,kFAAkF;AAClF,KAAK,UAAU,eAAe,CAAC,MAA0B,EAAE,OAAmC;IAC5F,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChH,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,GAAG,YAAY,SAAS,CAAC,CAAC;IAC1F,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/client.d.ts CHANGED
@@ -6,12 +6,20 @@
6
6
  * wrapping is the handful of functions that carry the accounting rules, and
7
7
  * the FEC export.
8
8
  *
9
- * `@supabase/supabase-js` is an optional peer dependency; only the two
10
- * methods used here are required, so any structurally compatible client
11
- * works and this package keeps zero runtime dependencies.
9
+ * Every method answers through the functions of `books/`, which the command
10
+ * line and the MCP server call too, so the three give one answer to one
11
+ * question: the same rows, the amounts as the decimal strings the ledger
12
+ * holds, the period said back. The client finds the socle by its marker
13
+ * (decision 0090) — `ekwo`, or `public` on an installation the socle has not
14
+ * moved out of yet — over the client it is given (`supabaseBackend()`).
15
+ *
16
+ * `@supabase/supabase-js` is an optional peer dependency; any structurally
17
+ * compatible client works, and so does a `Backend` of this package, and this
18
+ * package keeps zero runtime dependency on it.
12
19
  */
13
- import { type FecOptions } from '@ekwo-ai/fec';
14
- import type { AgedBalanceRow, ContactStatementRow, Entry, FinancialAnalysisRow, Instance, InstanceEdition, InstanceAdmin, IsoDate, SubledgerRow, TrialBalanceRow, Uuid, VatReturnRow } from './types.js';
20
+ import type { FecOptions, FecViolation } from '@ekwo-ai/fec';
21
+ import { BooksError, type Backend, type Row } from './books/backend.js';
22
+ import type { AgedBalanceRow, ContactStatementRow, Decimal, Entry, EntryLine, FinancialAnalysisRow, FinancialAnalysisSource, Instance, InstanceEdition, InstanceAdmin, IsoDate, SubledgerRow, TrialBalanceRow, Uuid, VatReturnRow } from './types.js';
15
23
  export interface RpcResult<T> {
16
24
  data: T | null;
17
25
  error: {
@@ -20,61 +28,163 @@ export interface RpcResult<T> {
20
28
  details?: string;
21
29
  } | null;
22
30
  }
23
- /** The slice of `@supabase/supabase-js` this client needs. */
31
+ /**
32
+ * The slice of `@supabase/supabase-js` this client needs. A real client also
33
+ * has `from()` and `schema()`, which the client uses to read tables and to
34
+ * name the socle's schema; one that has only `rpc` is taken as bound to the
35
+ * socle's schema already.
36
+ */
24
37
  export interface SupabaseLike {
25
38
  rpc<T = unknown>(fn: string, args?: Record<string, unknown>): PromiseLike<RpcResult<T>>;
26
39
  }
27
- export declare class EkwoError extends Error {
40
+ /**
41
+ * The error of every method. A `BooksError`, so `code` is the socle's refusal
42
+ * code (`period_locked`, `entry_unbalanced`…) and `hint` the sentence that
43
+ * explains it, where there is one.
44
+ */
45
+ export declare class EkwoError extends BooksError {
28
46
  name: string;
29
- readonly code: string | undefined;
30
- constructor(message: string, code?: string);
47
+ constructor(message: string, code?: string, hint?: string);
31
48
  }
32
49
  export interface PeriodRange {
33
50
  companyId: Uuid;
34
51
  from: IsoDate;
35
52
  to: IsoDate;
36
53
  }
54
+ /** The period an answer read, said back. */
55
+ export interface Period {
56
+ from: IsoDate;
57
+ to: IsoDate;
58
+ }
59
+ /**
60
+ * The rows a method always returned, with every field of the answer the
61
+ * command line and the MCP server give beside them: an array as before, and
62
+ * `period`, `totals`… readable on it.
63
+ */
64
+ export type RowsWith<R, A> = R[] & A;
65
+ export type TrialBalance = RowsWith<TrialBalanceRow, {
66
+ period: Period;
67
+ accounts: TrialBalanceRow[];
68
+ totals: {
69
+ debit: Decimal;
70
+ credit: Decimal;
71
+ };
72
+ }>;
73
+ export type VatReturn = RowsWith<VatReturnRow, {
74
+ period: Period;
75
+ report_code: string | null;
76
+ boxes: VatReturnRow[];
77
+ filing?: unknown;
78
+ note: string;
79
+ }>;
80
+ export type AgedBalance = RowsWith<AgedBalanceRow, {
81
+ at: IsoDate;
82
+ group: 'receivable' | 'payable';
83
+ rows: AgedBalanceRow[];
84
+ }>;
85
+ export type ContactStatement = RowsWith<ContactStatementRow, {
86
+ contact_id: Uuid;
87
+ period: Period;
88
+ opening_balance: Decimal | null;
89
+ closing_balance: Decimal | null;
90
+ lines: Omit<ContactStatementRow, 'row_kind'>[];
91
+ count: number;
92
+ }>;
93
+ export type FinancialAnalysis = RowsWith<FinancialAnalysisRow, {
94
+ period: Period;
95
+ source: FinancialAnalysisSource | null;
96
+ aggregates: FinancialAnalysisRow[];
97
+ note: string;
98
+ }>;
99
+ export interface FecExport {
100
+ period: Period;
101
+ /** How many lines the file holds. */
102
+ lines: number;
103
+ /** The lines that break a rule of the format; empty when the file is clean. */
104
+ violations: FecViolation[];
105
+ /** The name the file takes, or null where the company has no nine-digit SIREN. */
106
+ filename: string | null;
107
+ filename_note: string | null;
108
+ file: string;
109
+ }
110
+ export type Subledger = RowsWith<SubledgerRow, {
111
+ period: Period;
112
+ rows: SubledgerRow[];
113
+ control: unknown[];
114
+ count: number;
115
+ }>;
37
116
  export declare class EkwoClient {
38
- private readonly db;
39
- constructor(db: SupabaseLike);
40
- /** Books a document and returns the entry it produced. */
41
- postDocument(documentId: Uuid): Promise<Entry>;
117
+ /**
118
+ * The backend every method answers through, with the socle found by its
119
+ * marker. Every function of `books/` takes it, so what this class does not
120
+ * wrap is one call away: `listDocuments(ekwo.backend, { company_id })`.
121
+ */
122
+ readonly backend: Backend;
123
+ constructor(db: SupabaseLike | Backend);
124
+ /** Runs one call; an error of the books comes out as an `EkwoError` named after the call. */
125
+ private answer;
126
+ /** One row of a function of the schema. */
127
+ private one;
128
+ /** Books a document and returns the entry it produced, with its lines. */
129
+ postDocument(documentId: Uuid): Promise<Entry & {
130
+ entry_lines: EntryLine[];
131
+ }>;
42
132
  /** Numbers and posts an entry that was built by hand. */
43
133
  postEntry(entryId: Uuid): Promise<Entry>;
44
134
  /**
45
135
  * Matches a debit line against a credit line. With no amount, the smaller
46
- * of the two open amounts is used.
136
+ * of the two open amounts is used. Returns the matching.
47
137
  */
48
- reconcile(debitLineId: Uuid, creditLineId: Uuid, amount?: number): Promise<unknown>;
49
- trialBalance(range: PeriodRange): Promise<TrialBalanceRow[]>;
138
+ reconcile(debitLineId: Uuid, creditLineId: Uuid, amount?: number | Decimal): Promise<Row | null>;
139
+ /**
140
+ * Opening balance, movements and closing balance of every account over the
141
+ * period, from posted entries only — the rows — and `totals`, the debit
142
+ * and the credit added exactly.
143
+ */
144
+ trialBalance(range: PeriodRange): Promise<TrialBalance>;
50
145
  /**
51
146
  * The aggregates an analysis of the books is computed from — revenue, net
52
147
  * result, equity, total and current assets, cash, receivables, payables… —
53
148
  * as the company's pack defines them, each with the accounts that make it.
54
- * Empty for a company whose pack says nothing about an analysis.
149
+ * Empty for a company whose pack says nothing about an analysis. `source`
150
+ * and `note` say whose reading it is and how each amount is signed.
55
151
  */
56
- financialAnalysis(range: PeriodRange): Promise<FinancialAnalysisRow[]>;
57
- vatReturn(range: PeriodRange): Promise<VatReturnRow[]>;
58
- agedBalance(companyId: Uuid, at: IsoDate, group?: 'receivable' | 'payable'): Promise<AgedBalanceRow[]>;
152
+ financialAnalysis(range: PeriodRange): Promise<FinancialAnalysis>;
153
+ /** The boxes of the periodic tax return of the period, and the declaration filed for it, if any. */
154
+ vatReturn(range: PeriodRange & {
155
+ reportCode?: string | undefined;
156
+ }): Promise<VatReturn>;
157
+ /** What is still open on the receivable (or payable) accounts at `at`, by contact and by how overdue. */
158
+ agedBalance(companyId: Uuid, at: IsoDate, group?: 'receivable' | 'payable'): Promise<AgedBalance>;
59
159
  /**
60
160
  * The statement of account of a contact: the balance carried forward to
61
161
  * `from`, then every posted line of its receivable and payable accounts over
62
162
  * the period, with the running balance and how far each line is matched.
163
+ * The rows keep the opening row first; `lines`, `opening_balance` and
164
+ * `closing_balance` are the answer the other surfaces give.
63
165
  */
64
166
  contactStatement(range: PeriodRange & {
65
167
  contactId: Uuid;
66
- }): Promise<ContactStatementRow[]>;
168
+ }): Promise<ContactStatement>;
67
169
  /**
68
170
  * The subsidiary ledger: per control account and contact, the balance
69
171
  * brought forward to `from`, the debits, the credits and the closing
70
172
  * balance, the lines naming nobody in a row of their own. Every receivable
71
- * and payable account unless `accountIds` names some.
173
+ * and payable account unless `accountIds` names some. `control` ties each
174
+ * account back to the trial balance.
72
175
  */
73
176
  subledger(range: PeriodRange & {
74
177
  accountIds?: Uuid[];
75
- }): Promise<SubledgerRow[]>;
76
- /** The French FEC for a period, ready to be written to disk. */
178
+ }): Promise<Subledger>;
179
+ /** The French FEC for a period, ready to be written to disk. `fec()` adds the lines that break a rule of the format. */
77
180
  generateFec(range: PeriodRange, options?: FecOptions): Promise<string>;
181
+ /**
182
+ * The French FEC for a period, as the command line and the MCP server give
183
+ * it: the file, its count of lines, the lines that break a rule of the
184
+ * format (`violations`, empty when the file is clean) and its name, where
185
+ * the company has a nine-digit SIREN.
186
+ */
187
+ fec(range: PeriodRange, options?: FecOptions): Promise<FecExport>;
78
188
  /**
79
189
  * Records the installation. Called once, by the installer; raises if this
80
190
  * database has already been set up.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAA6B,KAAK,UAAU,EAAoB,MAAM,cAAc,CAAC;AAC5F,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,OAAO,EACP,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1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