@spine-event-engine/storage 2.0.0-snapshot.22 → 2.0.0-snapshot.24

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 (127) hide show
  1. package/README.md +7 -0
  2. package/REFERENCE.md +131 -7
  3. package/dist/entity/agent-execution-record-spec.d.ts +87 -0
  4. package/dist/entity/agent-execution-record-spec.d.ts.map +1 -0
  5. package/dist/entity/agent-execution-record-spec.js +230 -0
  6. package/dist/entity/agent-execution-record-spec.js.map +1 -0
  7. package/dist/entity/agent-execution-sizes.d.ts +30 -0
  8. package/dist/entity/agent-execution-sizes.d.ts.map +1 -0
  9. package/dist/entity/agent-execution-sizes.js +51 -0
  10. package/dist/entity/agent-execution-sizes.js.map +1 -0
  11. package/dist/entity/agent-execution-transitions.d.ts +72 -0
  12. package/dist/entity/agent-execution-transitions.d.ts.map +1 -0
  13. package/dist/entity/agent-execution-transitions.js +165 -0
  14. package/dist/entity/agent-execution-transitions.js.map +1 -0
  15. package/dist/entity/agent-execution-values.d.ts +143 -0
  16. package/dist/entity/agent-execution-values.d.ts.map +1 -0
  17. package/dist/entity/agent-execution-values.js +251 -0
  18. package/dist/entity/agent-execution-values.js.map +1 -0
  19. package/dist/entity/agent-execution.d.ts +235 -0
  20. package/dist/entity/agent-execution.d.ts.map +1 -0
  21. package/dist/entity/agent-execution.js +15 -0
  22. package/dist/entity/agent-execution.js.map +1 -0
  23. package/dist/entity/agent-history-conformance.d.ts +78 -0
  24. package/dist/entity/agent-history-conformance.d.ts.map +1 -0
  25. package/dist/entity/agent-history-conformance.js +493 -0
  26. package/dist/entity/agent-history-conformance.js.map +1 -0
  27. package/dist/entity/agent-history-provider-page.d.ts +39 -0
  28. package/dist/entity/agent-history-provider-page.d.ts.map +1 -0
  29. package/dist/entity/agent-history-provider-page.js +82 -0
  30. package/dist/entity/agent-history-provider-page.js.map +1 -0
  31. package/dist/entity/agent-history-record-spec.d.ts +79 -0
  32. package/dist/entity/agent-history-record-spec.d.ts.map +1 -0
  33. package/dist/entity/agent-history-record-spec.js +147 -0
  34. package/dist/entity/agent-history-record-spec.js.map +1 -0
  35. package/dist/entity/agent-history.d.ts +196 -0
  36. package/dist/entity/agent-history.d.ts.map +1 -0
  37. package/dist/entity/agent-history.js +136 -0
  38. package/dist/entity/agent-history.js.map +1 -0
  39. package/dist/event/event-store.d.ts +41 -35
  40. package/dist/event/event-store.d.ts.map +1 -1
  41. package/dist/event/event-store.js +149 -144
  42. package/dist/event/event-store.js.map +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/internal/agent-execution.d.ts +51 -0
  48. package/dist/internal/agent-execution.d.ts.map +1 -0
  49. package/dist/internal/agent-execution.js +53 -0
  50. package/dist/internal/agent-execution.js.map +1 -0
  51. package/dist/internal/agent-history.d.ts +48 -0
  52. package/dist/internal/agent-history.d.ts.map +1 -0
  53. package/dist/internal/agent-history.js +52 -0
  54. package/dist/internal/agent-history.js.map +1 -0
  55. package/dist/internal/entity-commit.d.ts +30 -11
  56. package/dist/internal/entity-commit.d.ts.map +1 -1
  57. package/dist/internal/entity-commit.js +45 -2
  58. package/dist/internal/entity-commit.js.map +1 -1
  59. package/dist/internal/entity-history.d.ts +11 -0
  60. package/dist/internal/entity-history.d.ts.map +1 -1
  61. package/dist/internal/entity-history.js +10 -0
  62. package/dist/internal/entity-history.js.map +1 -1
  63. package/dist/internal/event-store.d.ts +1 -1
  64. package/dist/internal/event-store.d.ts.map +1 -1
  65. package/dist/internal/event-store.js +1 -1
  66. package/dist/internal/event-store.js.map +1 -1
  67. package/dist/internal/tenancy.d.ts +87 -1
  68. package/dist/internal/tenancy.d.ts.map +1 -1
  69. package/dist/internal/tenancy.js +39 -0
  70. package/dist/internal/tenancy.js.map +1 -1
  71. package/dist/memory/agent-execution-head-index.d.ts +52 -0
  72. package/dist/memory/agent-execution-head-index.d.ts.map +1 -0
  73. package/dist/memory/agent-execution-head-index.js +91 -0
  74. package/dist/memory/agent-execution-head-index.js.map +1 -0
  75. package/dist/memory/agent-history-index.d.ts +49 -0
  76. package/dist/memory/agent-history-index.d.ts.map +1 -0
  77. package/dist/memory/agent-history-index.js +239 -0
  78. package/dist/memory/agent-history-index.js.map +1 -0
  79. package/dist/memory/agent-history-mutation-queue.d.ts +17 -0
  80. package/dist/memory/agent-history-mutation-queue.d.ts.map +1 -0
  81. package/dist/memory/agent-history-mutation-queue.js +31 -0
  82. package/dist/memory/agent-history-mutation-queue.js.map +1 -0
  83. package/dist/memory/in-memory-agent-execution.d.ts +21 -0
  84. package/dist/memory/in-memory-agent-execution.d.ts.map +1 -0
  85. package/dist/memory/in-memory-agent-execution.js +587 -0
  86. package/dist/memory/in-memory-agent-execution.js.map +1 -0
  87. package/dist/memory/in-memory-agent-history.d.ts +21 -0
  88. package/dist/memory/in-memory-agent-history.d.ts.map +1 -0
  89. package/dist/memory/in-memory-agent-history.js +133 -0
  90. package/dist/memory/in-memory-agent-history.js.map +1 -0
  91. package/dist/memory/in-memory-entity-commit.d.ts +107 -28
  92. package/dist/memory/in-memory-entity-commit.d.ts.map +1 -1
  93. package/dist/memory/in-memory-entity-commit.js +198 -286
  94. package/dist/memory/in-memory-entity-commit.js.map +1 -1
  95. package/dist/memory/in-memory-entity-history.d.ts +1 -1
  96. package/dist/memory/in-memory-entity-history.d.ts.map +1 -1
  97. package/dist/memory/in-memory-entity-history.js.map +1 -1
  98. package/dist/memory/in-memory-storage-backend.d.ts +18 -0
  99. package/dist/memory/in-memory-storage-backend.d.ts.map +1 -1
  100. package/dist/memory/in-memory-storage-backend.js +71 -0
  101. package/dist/memory/in-memory-storage-backend.js.map +1 -1
  102. package/dist/memory/in-memory-storage-factory.d.ts +38 -3
  103. package/dist/memory/in-memory-storage-factory.d.ts.map +1 -1
  104. package/dist/memory/in-memory-storage-factory.js +146 -10
  105. package/dist/memory/in-memory-storage-factory.js.map +1 -1
  106. package/dist/memory/tenant-records.d.ts +1 -1
  107. package/dist/memory/tenant-records.d.ts.map +1 -1
  108. package/dist/memory/tenant-records.js +3 -2
  109. package/dist/memory/tenant-records.js.map +1 -1
  110. package/dist/provider.d.ts +0 -1
  111. package/dist/provider.d.ts.map +1 -1
  112. package/dist/provider.js +0 -1
  113. package/dist/provider.js.map +1 -1
  114. package/dist/record/record-query.d.ts +10 -2
  115. package/dist/record/record-query.d.ts.map +1 -1
  116. package/dist/record/record-query.js +9 -0
  117. package/dist/record/record-query.js.map +1 -1
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +3 -2
  120. package/dist/internal/delivery-cleanup.d.ts +0 -99
  121. package/dist/internal/delivery-cleanup.d.ts.map +0 -1
  122. package/dist/internal/delivery-cleanup.js +0 -38
  123. package/dist/internal/delivery-cleanup.js.map +0 -1
  124. package/dist/memory/memory-delivery-cleanup.d.ts +0 -32
  125. package/dist/memory/memory-delivery-cleanup.d.ts.map +0 -1
  126. package/dist/memory/memory-delivery-cleanup.js +0 -61
  127. package/dist/memory/memory-delivery-cleanup.js.map +0 -1
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { TenantBoundary } from "../internal/tenancy.js";
15
+ import { AgentHistoryIndex } from "./agent-history-index.js";
16
+ import { AgentHistoryMutationQueue } from "./agent-history-mutation-queue.js";
17
+ import { InMemoryStorageBackend } from "./in-memory-storage-backend.js";
18
+ /**
19
+ * Opens indexed Agent history against one in-memory backend.
20
+ */
21
+ export const MemoryAgentHistory = Object.freeze({
22
+ /**
23
+ * Opens an independent handle for the Agent state type and tenant boundary.
24
+ *
25
+ * @typeParam Id Typed Agent identifier.
26
+ * @param backend Shared in-memory backend.
27
+ * @param input State type, tenant, and ID codec.
28
+ * @returns Independently closeable indexed history handle.
29
+ */
30
+ open(backend, input) {
31
+ if (input.stateType.trim().length === 0)
32
+ throw new TypeError("Agent state type is required.");
33
+ const records = InMemoryStorageBackend.bind(backend, "entity", TenantBoundary.of(input.context), `agent-history:${input.stateType}`, () => new Map());
34
+ return new MemoryAgentHistoryHandle(input.id.key, records, AgentHistoryMutationQueue.bind(backend, TenantBoundary.of(input.context)));
35
+ },
36
+ });
37
+ /**
38
+ * Provides indexed append-only history for one memory repository scope.
39
+ *
40
+ * @typeParam Id Typed Agent identifier.
41
+ */
42
+ class MemoryAgentHistoryHandle {
43
+ #idKey;
44
+ #records;
45
+ #queue;
46
+ #open = true;
47
+ /**
48
+ * Binds one typed ID codec to the retained per-Agent indexes.
49
+ *
50
+ * @param idKey Canonical Entity ID conversion.
51
+ * @param records Retained indexes in the provider backend.
52
+ * @param queue Serializes standalone append with fenced execution writes.
53
+ */
54
+ constructor(idKey, records, queue) {
55
+ this.#idKey = idKey;
56
+ this.#records = records;
57
+ this.#queue = queue;
58
+ }
59
+ /**
60
+ * Adds an immutable entry to the typed Agent's indexes.
61
+ *
62
+ * @param entityId Typed Agent identifier.
63
+ * @param entry Complete Proto history entry.
64
+ * @returns Resolves after the entry is indexed.
65
+ */
66
+ append(entityId, entry) {
67
+ const key = this.#key(entityId);
68
+ return this.#queue.run(key, () => {
69
+ this.#requireOpen();
70
+ let index = this.#records.get(key);
71
+ if (index === undefined) {
72
+ index = new AgentHistoryIndex();
73
+ this.#records.set(key, index);
74
+ }
75
+ index.append(entry);
76
+ });
77
+ }
78
+ /**
79
+ * Reads one bounded indexed view of a typed Agent.
80
+ *
81
+ * @param request Entity ID, view, complete boundary, and response bounds.
82
+ * @returns Independent Proto entries and continuation status.
83
+ */
84
+ read(request) {
85
+ return Promise.resolve().then(() => {
86
+ this.#requireOpen();
87
+ this.#validateRead(request);
88
+ const index = this.#records.get(this.#key(request.entityId)) ?? new AgentHistoryIndex();
89
+ return index.read(request.view, request.after, request.count, request.maxBytes);
90
+ });
91
+ }
92
+ /**
93
+ * Closes this handle while retaining backend history for a later handle.
94
+ */
95
+ close() {
96
+ this.#open = false;
97
+ }
98
+ /**
99
+ * Validates positive finite page bounds and a category-compatible boundary.
100
+ *
101
+ * @param request History read bounds and view.
102
+ */
103
+ #validateRead(request) {
104
+ if (!Number.isSafeInteger(request.count) || request.count <= 0)
105
+ throw new RangeError("Agent history count must be a positive safe integer.");
106
+ if (request.maxBytes !== undefined &&
107
+ (!Number.isSafeInteger(request.maxBytes) || request.maxBytes <= 0))
108
+ throw new RangeError("Agent history maxBytes must be a positive safe integer.");
109
+ const category = request.view.kind;
110
+ if (request.after !== undefined && category !== "full" && request.after.category !== category)
111
+ throw new TypeError("Agent history boundary category does not match the view.");
112
+ }
113
+ /**
114
+ * Maps a typed Agent ID to its canonical storage key.
115
+ *
116
+ * @param entityId Typed Agent identifier.
117
+ * @returns Canonical storage key.
118
+ */
119
+ #key(entityId) {
120
+ const key = this.#idKey(entityId);
121
+ if (key.length === 0)
122
+ throw new TypeError("Agent history Entity ID is required.");
123
+ return key;
124
+ }
125
+ /**
126
+ * Rejects use after this independent handle closes.
127
+ */
128
+ #requireOpen() {
129
+ if (!this.#open)
130
+ throw new Error("Agent history storage handle is closed.");
131
+ }
132
+ }
133
+ //# sourceMappingURL=in-memory-agent-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-agent-history.js","sourceRoot":"","sources":["../../src/memory/in-memory-agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,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AAsD,CAAC,CAAC;QAC/E,IACE,OAAO,CAAC,QAAQ,KAAK,SAAS;YAC9B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;YAElE,MAAM,IAAI,UAAU,CAAC,yDAAyD,CAAC,CAAC;QAClF,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ;YAC3F,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAC;IACpF,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,QAAY;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAClF,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACH,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -1,67 +1,146 @@
1
1
  import { type Message } from "@bufbuild/protobuf";
2
- import type { EntityCommitInput, EntityCommitStorage } from "../internal/entity-commit.js";
2
+ import { type EntityCommitInput, type EntityCommitStorage } from "../internal/entity-commit.js";
3
3
  import type { RecordSpec } from "../record/record-spec.js";
4
4
  import type { StorageGroup } from "../record/storage-group.js";
5
5
  import type { StorageContext } from "../storage/storage.js";
6
- import type { StorageFactory } from "../storage/storage-factory.js";
7
6
  import { MemoryEntityStorageFactory, type EntityStorageInput } from "./in-memory-entity-history.js";
8
7
  import { TenantRecords } from "./tenant-records.js";
9
8
  /**
10
- * Opens the in-memory tenant slice for a generated record family.
9
+ * Opens one tenant slice for a generated record family.
10
+ *
11
11
  * @typeParam I Record identifier type.
12
- * @typeParam R Record message type.
13
- * @param context Supplies the storage and tenant context.
14
- * @param spec Supplies the materialized record layout.
15
- * @param group Selects a grouped history family when present.
16
- * @returns The tenant record slice.
12
+ * @typeParam R Stored message type.
17
13
  */
18
14
  type OpenRecords = <I, R extends Message>(context: StorageContext, spec: RecordSpec<I, R>, group?: StorageGroup) => TenantRecords<I, R>;
19
15
  /**
20
- * Implements provider Entity commits for one shared in-memory backend.
16
+ * Writes in-memory Entity records in order and retains a completed prefix.
21
17
  */
22
18
  export declare class MemoryEntityCommitStorage implements EntityCommitStorage {
23
19
  #private;
20
+ private readonly entities;
21
+ private readonly openRecords;
22
+ private readonly input;
24
23
  /**
25
- * Creates a commit handle bound to one Entity source type.
24
+ * Creates one source- and tenant-bound commit handle.
26
25
  *
27
- * @param entities Opens the matching current Entity storage.
28
- * @param factory Provides the Event Store coordination lock.
29
- * @param openRecords Opens exact generic-record backing slices.
30
- * @param input Defines the Entity storage source type.
26
+ * @param entities Opens current Entity storage.
27
+ * @param openRecords Opens generated history and Event record slices.
28
+ * @param input Captures the Entity source and tenant boundary.
31
29
  */
32
- constructor(entities: MemoryEntityStorageFactory, factory: StorageFactory, openRecords: OpenRecords, input: EntityStorageInput<unknown, Message>);
30
+ constructor(entities: MemoryEntityStorageFactory, openRecords: OpenRecords, input: EntityStorageInput<unknown, Message>);
33
31
  /**
34
- * Applies one fully preflighted in-memory Entity commit.
32
+ * Writes history, diagnostics, delivery Events, then current state.
35
33
  *
36
34
  * @typeParam I Entity identifier type.
37
35
  * @typeParam S Entity state type.
38
- * @param input Defines the current record, retained histories, and delivery events.
39
- * @returns Completion after the in-memory commit.
36
+ * @param input Supplies the proposed mutation.
37
+ * @returns Completion after every record has been stored.
40
38
  */
41
39
  commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<void>;
42
40
  /**
43
- * Closes this commit handle without closing sibling handles.
41
+ * Commits one Agent transition under the Entity scope queue and Version fence.
42
+ *
43
+ * @typeParam I Entity identifier type.
44
+ * @typeParam S Entity state type.
45
+ * @param entity Configured Entity storage layout.
46
+ * @param entityId Typed Agent Entity identifier.
47
+ * @param expectedVersion Version read before the Agent handler ran.
48
+ * @param input Optional changed Entity state and history.
49
+ * @param extra Applies or restores the Agent execution record with the Entity state.
50
+ * @returns Completion after the fenced transition is stored.
51
+ */
52
+ commitAgentConditional<I, S extends Message>(entity: EntityStorageInput<I, S>, entityId: I, expectedVersion: number, input: EntityCommitInput<I, S> | undefined, extra: {
53
+ apply(): void;
54
+ restore(): void;
55
+ }): Promise<void>;
56
+ /**
57
+ * Applies one prepared Agent transition and restores affected rows on failure.
58
+ *
59
+ * @typeParam I Entity identifier type.
60
+ * @typeParam S Entity state type.
61
+ * @param entity Configured Entity storage layout.
62
+ * @param backend Shared current records for this Entity scope.
63
+ * @param key Canonical Entity ID key.
64
+ * @param expectedVersion Version read before handler execution.
65
+ * @param snapshot Optional captured Entity state transition.
66
+ * @param extra Applies or restores the Agent execution record.
67
+ * @returns Completion after the transition is stored.
68
+ */
69
+ private applyAgentConditional;
70
+ /**
71
+ * Writes immutable Agent state history after checking each Version slot.
72
+ *
73
+ * @param states State-history records when that family is configured.
74
+ * @param prepared Materialized state rows from the captured transition.
75
+ */
76
+ private writeAgentStates;
77
+ /**
78
+ * Closes this handle to new commits.
44
79
  */
45
80
  close(): void;
46
81
  /**
47
- * Opens only record families used by one commit.
82
+ * Applies one captured mutation without cross-record compensation.
83
+ *
84
+ * @typeParam I Entity identifier type.
85
+ * @typeParam S Entity state type.
86
+ * @param input Supplies immutable record snapshots.
87
+ * @returns Completion after every requested record write.
88
+ */
89
+ private apply;
90
+ /**
91
+ * Opens the record families needed by one captured mutation.
48
92
  *
49
93
  * @typeParam I Entity identifier type.
50
94
  * @typeParam S Entity state type.
51
- * @param input Supplies configured histories and delivery Events.
52
- * @returns Live affected record families and their layouts.
95
+ * @param input Supplies requested history and delivery records.
96
+ * @returns Entity and record handles to close after the mutation.
53
97
  */
54
- private live;
98
+ private openCommit;
55
99
  /**
56
- * Captures affected rows and creates isolated adapters for preparation.
100
+ * Writes one immutable delivery Event or accepts an identical retry.
101
+ *
102
+ * @param storage Supplies atomic single-record insertion.
103
+ * @param id Identifies the delivery Event.
104
+ * @param event Supplies the captured Event.
105
+ * @returns Completion after an identical Event is stored.
106
+ */
107
+ private appendEvent;
108
+ /**
109
+ * Compares two stored Protobuf byte sequences.
110
+ *
111
+ * @param left First byte sequence.
112
+ * @param right Second byte sequence.
113
+ * @returns Whether every byte matches.
114
+ */
115
+ private sameBytes;
116
+ /**
117
+ * Validates current identity and duplicate delivery IDs before writes.
118
+ *
119
+ * @typeParam I Entity identifier type.
120
+ * @typeParam S Entity state type.
121
+ * @param input Supplies the captured mutation.
122
+ */
123
+ private validateRows;
124
+ /**
125
+ * Rejects disabled history families.
57
126
  *
58
127
  * @typeParam I Entity identifier type.
59
128
  * @typeParam S Entity state type.
60
- * @param input Supplies the proposed record changes.
61
- * @param backend Supplies the live current-record map.
62
- * @returns The prepared affected-record workspace.
129
+ * @param input Supplies the proposed histories.
130
+ */
131
+ private requireEnabledHistories;
132
+ /**
133
+ * Checks the tenant and source captured by this handle.
134
+ *
135
+ * @typeParam I Entity identifier type.
136
+ * @typeParam S Entity state type.
137
+ * @param input Supplies the requested scope.
138
+ */
139
+ private requireCompatible;
140
+ /**
141
+ * Rejects commits after this handle closes.
63
142
  */
64
- private stage;
143
+ private requireOpen;
65
144
  }
66
145
  export {};
67
146
  //# sourceMappingURL=in-memory-entity-commit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-entity-commit.d.ts","sourceRoot":"","sources":["../../src/memory/in-memory-entity-commit.ts"],"names":[],"mappings":"AAcA,OAAO,EAAS,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAOzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;A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