flowquery 1.0.69 → 1.0.71

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 (147) hide show
  1. package/README.md +682 -86
  2. package/dist/compute/provenance.d.ts +201 -0
  3. package/dist/compute/provenance.d.ts.map +1 -0
  4. package/dist/compute/provenance.js +216 -0
  5. package/dist/compute/provenance.js.map +1 -0
  6. package/dist/compute/runner.d.ts +202 -3
  7. package/dist/compute/runner.d.ts.map +1 -1
  8. package/dist/compute/runner.js +309 -2
  9. package/dist/compute/runner.js.map +1 -1
  10. package/dist/flowquery.min.js +1 -1
  11. package/dist/graph/bindings.d.ts +78 -0
  12. package/dist/graph/bindings.d.ts.map +1 -0
  13. package/dist/graph/bindings.js +224 -0
  14. package/dist/graph/bindings.js.map +1 -0
  15. package/dist/graph/data_cache.d.ts +4 -0
  16. package/dist/graph/data_cache.d.ts.map +1 -1
  17. package/dist/graph/data_cache.js +15 -3
  18. package/dist/graph/data_cache.js.map +1 -1
  19. package/dist/graph/data_resolver.d.ts.map +1 -1
  20. package/dist/graph/data_resolver.js +23 -4
  21. package/dist/graph/data_resolver.js.map +1 -1
  22. package/dist/graph/database.d.ts +4 -2
  23. package/dist/graph/database.d.ts.map +1 -1
  24. package/dist/graph/database.js +45 -9
  25. package/dist/graph/database.js.map +1 -1
  26. package/dist/graph/physical_node.d.ts +7 -2
  27. package/dist/graph/physical_node.d.ts.map +1 -1
  28. package/dist/graph/physical_node.js +22 -26
  29. package/dist/graph/physical_node.js.map +1 -1
  30. package/dist/graph/physical_relationship.d.ts +7 -2
  31. package/dist/graph/physical_relationship.d.ts.map +1 -1
  32. package/dist/graph/physical_relationship.js +22 -26
  33. package/dist/graph/physical_relationship.js.map +1 -1
  34. package/dist/graph/relationship_match_collector.d.ts.map +1 -1
  35. package/dist/graph/relationship_match_collector.js +9 -0
  36. package/dist/graph/relationship_match_collector.js.map +1 -1
  37. package/dist/graph/virtual_sources.d.ts +8 -0
  38. package/dist/graph/virtual_sources.d.ts.map +1 -0
  39. package/dist/graph/virtual_sources.js +31 -0
  40. package/dist/graph/virtual_sources.js.map +1 -0
  41. package/dist/graph/virtual_statement.d.ts +41 -0
  42. package/dist/graph/virtual_statement.d.ts.map +1 -0
  43. package/dist/graph/virtual_statement.js +143 -0
  44. package/dist/graph/virtual_statement.js.map +1 -0
  45. package/dist/index.browser.d.ts +3 -3
  46. package/dist/index.browser.d.ts.map +1 -1
  47. package/dist/index.browser.js.map +1 -1
  48. package/dist/index.node.d.ts +3 -3
  49. package/dist/index.node.d.ts.map +1 -1
  50. package/dist/index.node.js.map +1 -1
  51. package/dist/parsing/ast_node.d.ts +9 -0
  52. package/dist/parsing/ast_node.d.ts.map +1 -1
  53. package/dist/parsing/ast_node.js +21 -4
  54. package/dist/parsing/ast_node.js.map +1 -1
  55. package/dist/parsing/expressions/binding_reference.d.ts +16 -0
  56. package/dist/parsing/expressions/binding_reference.d.ts.map +1 -0
  57. package/dist/parsing/expressions/binding_reference.js +34 -0
  58. package/dist/parsing/expressions/binding_reference.js.map +1 -0
  59. package/dist/parsing/operations/aggregated_return.d.ts +10 -0
  60. package/dist/parsing/operations/aggregated_return.d.ts.map +1 -1
  61. package/dist/parsing/operations/aggregated_return.js +56 -3
  62. package/dist/parsing/operations/aggregated_return.js.map +1 -1
  63. package/dist/parsing/operations/aggregated_with.d.ts +20 -0
  64. package/dist/parsing/operations/aggregated_with.d.ts.map +1 -1
  65. package/dist/parsing/operations/aggregated_with.js +33 -1
  66. package/dist/parsing/operations/aggregated_with.js.map +1 -1
  67. package/dist/parsing/operations/create_node.d.ts +5 -1
  68. package/dist/parsing/operations/create_node.d.ts.map +1 -1
  69. package/dist/parsing/operations/create_node.js +12 -2
  70. package/dist/parsing/operations/create_node.js.map +1 -1
  71. package/dist/parsing/operations/create_relationship.d.ts +5 -1
  72. package/dist/parsing/operations/create_relationship.d.ts.map +1 -1
  73. package/dist/parsing/operations/create_relationship.js +12 -2
  74. package/dist/parsing/operations/create_relationship.js.map +1 -1
  75. package/dist/parsing/operations/drop_binding.d.ts +15 -0
  76. package/dist/parsing/operations/drop_binding.d.ts.map +1 -0
  77. package/dist/parsing/operations/drop_binding.js +42 -0
  78. package/dist/parsing/operations/drop_binding.js.map +1 -0
  79. package/dist/parsing/operations/group_by.d.ts +32 -0
  80. package/dist/parsing/operations/group_by.d.ts.map +1 -1
  81. package/dist/parsing/operations/group_by.js +103 -0
  82. package/dist/parsing/operations/group_by.js.map +1 -1
  83. package/dist/parsing/operations/let.d.ts +36 -0
  84. package/dist/parsing/operations/let.d.ts.map +1 -0
  85. package/dist/parsing/operations/let.js +154 -0
  86. package/dist/parsing/operations/let.js.map +1 -0
  87. package/dist/parsing/operations/load.d.ts +31 -0
  88. package/dist/parsing/operations/load.d.ts.map +1 -1
  89. package/dist/parsing/operations/load.js +102 -2
  90. package/dist/parsing/operations/load.js.map +1 -1
  91. package/dist/parsing/operations/merge.d.ts +158 -0
  92. package/dist/parsing/operations/merge.d.ts.map +1 -0
  93. package/dist/parsing/operations/merge.js +338 -0
  94. package/dist/parsing/operations/merge.js.map +1 -0
  95. package/dist/parsing/operations/order_by.d.ts +6 -0
  96. package/dist/parsing/operations/order_by.d.ts.map +1 -1
  97. package/dist/parsing/operations/order_by.js +10 -1
  98. package/dist/parsing/operations/order_by.js.map +1 -1
  99. package/dist/parsing/operations/refresh_binding.d.ts +15 -0
  100. package/dist/parsing/operations/refresh_binding.d.ts.map +1 -0
  101. package/dist/parsing/operations/refresh_binding.js +42 -0
  102. package/dist/parsing/operations/refresh_binding.js.map +1 -0
  103. package/dist/parsing/operations/refresh_node.d.ts +11 -0
  104. package/dist/parsing/operations/refresh_node.d.ts.map +1 -0
  105. package/dist/parsing/operations/refresh_node.js +46 -0
  106. package/dist/parsing/operations/refresh_node.js.map +1 -0
  107. package/dist/parsing/operations/refresh_relationship.d.ts +11 -0
  108. package/dist/parsing/operations/refresh_relationship.d.ts.map +1 -0
  109. package/dist/parsing/operations/refresh_relationship.js +46 -0
  110. package/dist/parsing/operations/refresh_relationship.js.map +1 -0
  111. package/dist/parsing/operations/return.d.ts +34 -0
  112. package/dist/parsing/operations/return.d.ts.map +1 -1
  113. package/dist/parsing/operations/return.js +102 -3
  114. package/dist/parsing/operations/return.js.map +1 -1
  115. package/dist/parsing/operations/union.d.ts +19 -2
  116. package/dist/parsing/operations/union.d.ts.map +1 -1
  117. package/dist/parsing/operations/union.js +47 -11
  118. package/dist/parsing/operations/union.js.map +1 -1
  119. package/dist/parsing/operations/union_all.d.ts +5 -1
  120. package/dist/parsing/operations/union_all.d.ts.map +1 -1
  121. package/dist/parsing/operations/union_all.js +8 -2
  122. package/dist/parsing/operations/union_all.js.map +1 -1
  123. package/dist/parsing/operations/update.d.ts +27 -0
  124. package/dist/parsing/operations/update.d.ts.map +1 -0
  125. package/dist/parsing/operations/update.js +88 -0
  126. package/dist/parsing/operations/update.js.map +1 -0
  127. package/dist/parsing/operations/update_delete.d.ts +43 -0
  128. package/dist/parsing/operations/update_delete.d.ts.map +1 -0
  129. package/dist/parsing/operations/update_delete.js +105 -0
  130. package/dist/parsing/operations/update_delete.js.map +1 -0
  131. package/dist/parsing/parser.d.ts +70 -1
  132. package/dist/parsing/parser.d.ts.map +1 -1
  133. package/dist/parsing/parser.js +704 -10
  134. package/dist/parsing/parser.js.map +1 -1
  135. package/dist/parsing/statement_info_crawler.d.ts +106 -0
  136. package/dist/parsing/statement_info_crawler.d.ts.map +1 -1
  137. package/dist/parsing/statement_info_crawler.js +231 -12
  138. package/dist/parsing/statement_info_crawler.js.map +1 -1
  139. package/dist/tokenization/keyword.d.ts +21 -1
  140. package/dist/tokenization/keyword.d.ts.map +1 -1
  141. package/dist/tokenization/keyword.js +20 -0
  142. package/dist/tokenization/keyword.js.map +1 -1
  143. package/dist/tokenization/token.d.ts +24 -0
  144. package/dist/tokenization/token.d.ts.map +1 -1
  145. package/dist/tokenization/token.js +73 -0
  146. package/dist/tokenization/token.js.map +1 -1
  147. package/package.json +1 -1
@@ -0,0 +1,158 @@
1
+ import ASTNode from "../ast_node";
2
+ import Expression from "../expressions/expression";
3
+ import Operation from "./operation";
4
+ /**
5
+ * One item in the `WHEN MATCHED THEN UPDATE SET` list.
6
+ *
7
+ * `field` is the name of the field on the matched target row to
8
+ * overwrite; `expression` is the value to assign. When `expression`
9
+ * is `null`, the default is `source.<field>` — i.e. the value of the
10
+ * same-named field on the current incoming row. This makes the
11
+ * partial-merge case (`SET .name, .email`) ergonomic without having to
12
+ * write `SET .name = source.name, .email = source.email`.
13
+ */
14
+ export interface MergeSetItem {
15
+ field: string;
16
+ expression: Expression | null;
17
+ }
18
+ /**
19
+ * The action taken when an incoming source row matches an existing
20
+ * target row. Either rewrite specific fields (`update`) or remove
21
+ * the matched target row (`delete`).
22
+ */
23
+ export type MergeMatchedAction = {
24
+ type: "update";
25
+ setItems: MergeSetItem[];
26
+ } | {
27
+ type: "delete";
28
+ };
29
+ /**
30
+ * The action taken when an incoming source row matches no existing
31
+ * target row. Inserts the row produced by `expression`, or the bare
32
+ * source row if `expression` is `null` (the implicit-insert default).
33
+ */
34
+ export interface MergeNotMatchedAction {
35
+ type: "insert";
36
+ expression: Expression | null;
37
+ }
38
+ /**
39
+ * The `ON` clause: either a short-form list of key fields (matched
40
+ * positionally against the source row by name) or an arbitrary
41
+ * predicate evaluated per (target, source) pair.
42
+ */
43
+ export type MergeOnClause = {
44
+ type: "keys";
45
+ keys: string[];
46
+ } | {
47
+ type: "predicate";
48
+ predicate: Expression;
49
+ };
50
+ /**
51
+ * `MERGE INTO <name> [AS <target>] USING <source-rhs> [AS <source>]
52
+ * ON ( <key> | (<k1>, <k2>, …) | <predicate> )
53
+ * [ WHEN MATCHED THEN UPDATE SET <set-list> ]
54
+ * [ WHEN MATCHED THEN DELETE ]
55
+ * [ WHEN NOT MATCHED THEN INSERT [<expr>] ]`
56
+ *
57
+ * SQL-MERGE-style upsert into an existing list-binding. The source
58
+ * may be any expression, sub-query, or bare binding name; both the
59
+ * `target` and `source` aliases are in scope inside the `ON`
60
+ * predicate and any `SET .field = <expr>` / `INSERT <expr>`
61
+ * expressions, allowing per-pair computation across both sides.
62
+ *
63
+ * Execution semantics:
64
+ *
65
+ * - The source RHS is evaluated once to produce a list of rows.
66
+ * - For each source row, the target list is scanned for a matching
67
+ * row using the `ON` clause.
68
+ * - If a match is found and a `WHEN MATCHED` branch is present, that
69
+ * branch is applied (rewriting the matched target row in place, or
70
+ * removing it). Without a `WHEN MATCHED` branch, the source row is
71
+ * silently ignored.
72
+ * - If no match is found and a `WHEN NOT MATCHED THEN INSERT` branch
73
+ * is present, the row is appended to the target list. Without the
74
+ * branch, the source row is silently ignored.
75
+ *
76
+ * The target binding must already exist (use `LET` to create it).
77
+ */
78
+ /**
79
+ * Proxy AST node used by the parser to register the `target` /
80
+ * `source` alias in the variable scope while parsing the ON
81
+ * predicate and SET / INSERT expressions. Resolves to the row
82
+ * currently exposed by the owning Merge instance.
83
+ */
84
+ export declare class MergeTargetAlias extends ASTNode {
85
+ private _merge;
86
+ constructor(merge: Merge);
87
+ value(): any;
88
+ }
89
+ export declare class MergeSourceAlias extends ASTNode {
90
+ private _merge;
91
+ constructor(merge: Merge);
92
+ value(): any;
93
+ }
94
+ declare class Merge extends Operation {
95
+ private _name;
96
+ private _targetAlias;
97
+ private _sourceAlias;
98
+ private _onClause;
99
+ private _matched;
100
+ private _notMatched;
101
+ private _sourceExpression;
102
+ private _sourceSubQuery;
103
+ /**
104
+ * The target row currently in scope (during ON / SET / INSERT
105
+ * evaluation). `undefined` for `WHEN NOT MATCHED` rows.
106
+ */
107
+ private _currentTarget;
108
+ /**
109
+ * The source row currently in scope (during ON / SET / INSERT
110
+ * evaluation).
111
+ */
112
+ private _currentSource;
113
+ /** The last value written back to the binding (for `results`). */
114
+ private _value;
115
+ constructor(name: string, targetAlias: string | null, sourceAlias: string | null, sourceExpression: Expression | null, sourceSubQuery: ASTNode | null, onClause: MergeOnClause, matched: MergeMatchedAction | null, notMatched: MergeNotMatchedAction | null);
116
+ /**
117
+ * Replaces the placeholder ON clause and matched / not-matched
118
+ * actions with their parsed counterparts (used by the parser,
119
+ * which must register the operation in its variable scope before
120
+ * parsing those expressions so that the target / source aliases
121
+ * resolve to this node).
122
+ */
123
+ setClauses(onClause: MergeOnClause, matched: MergeMatchedAction | null, notMatched: MergeNotMatchedAction | null): void;
124
+ get name(): string;
125
+ get targetAlias(): string | null;
126
+ get sourceAlias(): string | null;
127
+ get sourceExpression(): Expression | null;
128
+ get sourceSubQuery(): ASTNode | null;
129
+ get onClause(): MergeOnClause;
130
+ get matched(): MergeMatchedAction | null;
131
+ get notMatched(): MergeNotMatchedAction | null;
132
+ /**
133
+ * Returns the row currently in scope for the given alias. This is
134
+ * what {@link Reference}.value() resolves to when the target /
135
+ * source alias is referenced inside the ON predicate or in a
136
+ * SET / INSERT expression. The parser stamps an aliasContext on
137
+ * the proxy AST nodes it registers in the variable scope so we
138
+ * can disambiguate without name comparison.
139
+ */
140
+ targetValue(): any;
141
+ sourceValue(): any;
142
+ run(): Promise<void>;
143
+ /**
144
+ * Finds the first index in `target` (skipping tombstones) for
145
+ * which the ON clause holds against the current source row. The
146
+ * source row is already exposed via {@link sourceValue}.
147
+ */
148
+ private findMatch;
149
+ /**
150
+ * Builds the next value for a matched target row by applying the
151
+ * `SET <set-list>` items. Items without an explicit expression
152
+ * default to `source.<field>`.
153
+ */
154
+ private applySet;
155
+ get results(): Record<string, any>[];
156
+ }
157
+ export default Merge;
158
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/merge.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM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AClE,OAAO,CAAC,MAAM,CAAa;gBAGvB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,gBAAgB,EAAE,UAAU,GAAG,IAAI,EACnC,cAAc,EAAE,OAAO,GAAG,IAAI,EAC9B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,kBAAkB,GAAG,IAAI,EAClC,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAgC5C;;;;;;OAMG;IACI,UAAU,CACb,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,kBAAkB,GAAG,IAAI,EAClC,UAAU,EAAE,qBAAqB,GAAG,IAAI,GACzC,IAAI;IAmBP,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,WAAW,IAAI,MAAM,GAAG,IAAI,CAEtC;IAED,IAAW,WAAW,IAAI,MAAM,GAAG,IAAI,CAEtC;IAED,IAAW,gBAAgB,IAAI,UAAU,GAAG,IAAI,CAE/C;IAED,IAAW,cAAc,IAAI,OAAO,GAAG,IAAI,CAE1C;IAED,IAAW,QAAQ,IAAI,aAAa,CAEnC;IAED,IAAW,OAAO,IAAI,kBAAkB,GAAG,IAAI,CAE9C;IAED,IAAW,UAAU,IAAI,qBAAqB,GAAG,IAAI,CAEpD;IAED;;;;;;;OAOG;IACI,WAAW,IAAI,GAAG;IAIlB,WAAW,IAAI,GAAG;IAIZ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAgFjC;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAkDjB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAoBhB,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,338 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MergeSourceAlias = exports.MergeTargetAlias = void 0;
16
+ const bindings_1 = __importDefault(require("../../graph/bindings"));
17
+ const ast_node_1 = __importDefault(require("../ast_node"));
18
+ const operation_1 = __importDefault(require("./operation"));
19
+ /**
20
+ * `MERGE INTO <name> [AS <target>] USING <source-rhs> [AS <source>]
21
+ * ON ( <key> | (<k1>, <k2>, …) | <predicate> )
22
+ * [ WHEN MATCHED THEN UPDATE SET <set-list> ]
23
+ * [ WHEN MATCHED THEN DELETE ]
24
+ * [ WHEN NOT MATCHED THEN INSERT [<expr>] ]`
25
+ *
26
+ * SQL-MERGE-style upsert into an existing list-binding. The source
27
+ * may be any expression, sub-query, or bare binding name; both the
28
+ * `target` and `source` aliases are in scope inside the `ON`
29
+ * predicate and any `SET .field = <expr>` / `INSERT <expr>`
30
+ * expressions, allowing per-pair computation across both sides.
31
+ *
32
+ * Execution semantics:
33
+ *
34
+ * - The source RHS is evaluated once to produce a list of rows.
35
+ * - For each source row, the target list is scanned for a matching
36
+ * row using the `ON` clause.
37
+ * - If a match is found and a `WHEN MATCHED` branch is present, that
38
+ * branch is applied (rewriting the matched target row in place, or
39
+ * removing it). Without a `WHEN MATCHED` branch, the source row is
40
+ * silently ignored.
41
+ * - If no match is found and a `WHEN NOT MATCHED THEN INSERT` branch
42
+ * is present, the row is appended to the target list. Without the
43
+ * branch, the source row is silently ignored.
44
+ *
45
+ * The target binding must already exist (use `LET` to create it).
46
+ */
47
+ /**
48
+ * Proxy AST node used by the parser to register the `target` /
49
+ * `source` alias in the variable scope while parsing the ON
50
+ * predicate and SET / INSERT expressions. Resolves to the row
51
+ * currently exposed by the owning Merge instance.
52
+ */
53
+ class MergeTargetAlias extends ast_node_1.default {
54
+ constructor(merge) {
55
+ super();
56
+ this._merge = merge;
57
+ }
58
+ value() {
59
+ return this._merge.targetValue();
60
+ }
61
+ }
62
+ exports.MergeTargetAlias = MergeTargetAlias;
63
+ class MergeSourceAlias extends ast_node_1.default {
64
+ constructor(merge) {
65
+ super();
66
+ this._merge = merge;
67
+ }
68
+ value() {
69
+ return this._merge.sourceValue();
70
+ }
71
+ }
72
+ exports.MergeSourceAlias = MergeSourceAlias;
73
+ class Merge extends operation_1.default {
74
+ constructor(name, targetAlias, sourceAlias, sourceExpression, sourceSubQuery, onClause, matched, notMatched) {
75
+ super();
76
+ /**
77
+ * The target row currently in scope (during ON / SET / INSERT
78
+ * evaluation). `undefined` for `WHEN NOT MATCHED` rows.
79
+ */
80
+ this._currentTarget = undefined;
81
+ /**
82
+ * The source row currently in scope (during ON / SET / INSERT
83
+ * evaluation).
84
+ */
85
+ this._currentSource = undefined;
86
+ /** The last value written back to the binding (for `results`). */
87
+ this._value = [];
88
+ this._name = name;
89
+ this._targetAlias = targetAlias;
90
+ this._sourceAlias = sourceAlias;
91
+ this._sourceExpression = sourceExpression;
92
+ this._sourceSubQuery = sourceSubQuery;
93
+ this._onClause = onClause;
94
+ this._matched = matched;
95
+ this._notMatched = notMatched;
96
+ if (sourceExpression !== null) {
97
+ this.addChild(sourceExpression);
98
+ }
99
+ if (sourceSubQuery !== null) {
100
+ this.addChild(sourceSubQuery);
101
+ }
102
+ if (onClause.type === "predicate") {
103
+ this.addChild(onClause.predicate);
104
+ }
105
+ if (matched !== null && matched.type === "update") {
106
+ for (const item of matched.setItems) {
107
+ if (item.expression !== null) {
108
+ this.addChild(item.expression);
109
+ }
110
+ }
111
+ }
112
+ if (notMatched !== null && notMatched.expression !== null) {
113
+ this.addChild(notMatched.expression);
114
+ }
115
+ }
116
+ /**
117
+ * Replaces the placeholder ON clause and matched / not-matched
118
+ * actions with their parsed counterparts (used by the parser,
119
+ * which must register the operation in its variable scope before
120
+ * parsing those expressions so that the target / source aliases
121
+ * resolve to this node).
122
+ */
123
+ setClauses(onClause, matched, notMatched) {
124
+ this._onClause = onClause;
125
+ this._matched = matched;
126
+ this._notMatched = notMatched;
127
+ if (onClause.type === "predicate") {
128
+ this.addChild(onClause.predicate);
129
+ }
130
+ if (matched !== null && matched.type === "update") {
131
+ for (const item of matched.setItems) {
132
+ if (item.expression !== null) {
133
+ this.addChild(item.expression);
134
+ }
135
+ }
136
+ }
137
+ if (notMatched !== null && notMatched.expression !== null) {
138
+ this.addChild(notMatched.expression);
139
+ }
140
+ }
141
+ get name() {
142
+ return this._name;
143
+ }
144
+ get targetAlias() {
145
+ return this._targetAlias;
146
+ }
147
+ get sourceAlias() {
148
+ return this._sourceAlias;
149
+ }
150
+ get sourceExpression() {
151
+ return this._sourceExpression;
152
+ }
153
+ get sourceSubQuery() {
154
+ return this._sourceSubQuery;
155
+ }
156
+ get onClause() {
157
+ return this._onClause;
158
+ }
159
+ get matched() {
160
+ return this._matched;
161
+ }
162
+ get notMatched() {
163
+ return this._notMatched;
164
+ }
165
+ /**
166
+ * Returns the row currently in scope for the given alias. This is
167
+ * what {@link Reference}.value() resolves to when the target /
168
+ * source alias is referenced inside the ON predicate or in a
169
+ * SET / INSERT expression. The parser stamps an aliasContext on
170
+ * the proxy AST nodes it registers in the variable scope so we
171
+ * can disambiguate without name comparison.
172
+ */
173
+ targetValue() {
174
+ return this._currentTarget;
175
+ }
176
+ sourceValue() {
177
+ return this._currentSource;
178
+ }
179
+ run() {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ var _a;
182
+ const bindings = bindings_1.default.getInstance();
183
+ if (!bindings.has(this._name)) {
184
+ throw new Error(`Binding '${this._name}' is not defined; use LET to create it`);
185
+ }
186
+ if (bindings.isRefreshable(this._name)) {
187
+ throw new Error(`Binding '${this._name}' is refreshable; use REFRESH BINDING ${this._name} to re-evaluate or DROP BINDING ${this._name} first`);
188
+ }
189
+ const existing = bindings.get(this._name);
190
+ if (!Array.isArray(existing)) {
191
+ throw new Error(`MERGE INTO ${this._name} requires '${this._name}' to be a list`);
192
+ }
193
+ // Evaluate source once.
194
+ let source;
195
+ if (this._sourceSubQuery !== null) {
196
+ const first = this._sourceSubQuery.firstChild();
197
+ const last = this._sourceSubQuery.lastChild();
198
+ yield first.initialize();
199
+ yield first.run();
200
+ yield first.finish();
201
+ source = last.results;
202
+ }
203
+ else if (this._sourceExpression !== null) {
204
+ source = this._sourceExpression.value();
205
+ }
206
+ else {
207
+ source = null;
208
+ }
209
+ if (!Array.isArray(source)) {
210
+ throw new Error(`MERGE INTO ${this._name} USING … requires the source to evaluate to a list of rows`);
211
+ }
212
+ // Working copy of the target list; mutations are applied in
213
+ // place and a final assignment writes it back to the binding.
214
+ const result = existing.slice();
215
+ // Tombstone marker for delete actions; we sweep at the end so
216
+ // that intra-merge index lookups remain stable.
217
+ const tombstones = new Set();
218
+ for (const sourceRow of source) {
219
+ this._currentSource = sourceRow;
220
+ const matchedIndex = this.findMatch(result, tombstones, sourceRow);
221
+ if (matchedIndex !== -1) {
222
+ this._currentTarget = result[matchedIndex];
223
+ if (this._matched !== null) {
224
+ if (this._matched.type === "delete") {
225
+ tombstones.add(matchedIndex);
226
+ }
227
+ else {
228
+ result[matchedIndex] = this.applySet(result[matchedIndex], this._matched.setItems);
229
+ }
230
+ }
231
+ this._currentTarget = undefined;
232
+ }
233
+ else {
234
+ if (this._notMatched !== null) {
235
+ const inserted = this._notMatched.expression !== null
236
+ ? this._notMatched.expression.value()
237
+ : sourceRow;
238
+ result.push(inserted);
239
+ }
240
+ }
241
+ }
242
+ this._currentSource = undefined;
243
+ const swept = [];
244
+ for (let i = 0; i < result.length; i++) {
245
+ if (!tombstones.has(i)) {
246
+ swept.push(result[i]);
247
+ }
248
+ }
249
+ bindings.set(this._name, swept);
250
+ this._value = swept;
251
+ yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.run());
252
+ });
253
+ }
254
+ /**
255
+ * Finds the first index in `target` (skipping tombstones) for
256
+ * which the ON clause holds against the current source row. The
257
+ * source row is already exposed via {@link sourceValue}.
258
+ */
259
+ findMatch(target, tombstones, sourceRow) {
260
+ if (this._onClause.type === "keys") {
261
+ const keys = this._onClause.keys;
262
+ // Source row must be an object with all keys defined; if not,
263
+ // it cannot match anything and falls through to NOT MATCHED.
264
+ if (sourceRow === null || typeof sourceRow !== "object") {
265
+ return -1;
266
+ }
267
+ for (const k of keys) {
268
+ if (!(k in sourceRow)) {
269
+ return -1;
270
+ }
271
+ }
272
+ for (let i = 0; i < target.length; i++) {
273
+ if (tombstones.has(i)) {
274
+ continue;
275
+ }
276
+ const t = target[i];
277
+ if (t === null || typeof t !== "object") {
278
+ continue;
279
+ }
280
+ let matches = true;
281
+ for (const k of keys) {
282
+ if (!(k in t) || t[k] !== sourceRow[k]) {
283
+ matches = false;
284
+ break;
285
+ }
286
+ }
287
+ if (matches) {
288
+ return i;
289
+ }
290
+ }
291
+ return -1;
292
+ }
293
+ // Predicate ON — evaluate per (target, source) pair.
294
+ for (let i = 0; i < target.length; i++) {
295
+ if (tombstones.has(i)) {
296
+ continue;
297
+ }
298
+ this._currentTarget = target[i];
299
+ const ok = this._onClause.predicate.value();
300
+ if (ok) {
301
+ this._currentTarget = undefined;
302
+ return i;
303
+ }
304
+ }
305
+ this._currentTarget = undefined;
306
+ return -1;
307
+ }
308
+ /**
309
+ * Builds the next value for a matched target row by applying the
310
+ * `SET <set-list>` items. Items without an explicit expression
311
+ * default to `source.<field>`.
312
+ */
313
+ applySet(targetRow, setItems) {
314
+ const base = targetRow !== null && typeof targetRow === "object" ? Object.assign({}, targetRow) : {};
315
+ for (const item of setItems) {
316
+ if (item.expression !== null) {
317
+ base[item.field] = item.expression.value();
318
+ }
319
+ else {
320
+ // Default: copy source.<field> if present, otherwise
321
+ // leave the existing field untouched. This makes
322
+ // `SET .name, .email` behave like the old partial-merge
323
+ // form (only listed fields overwrite; missing ones
324
+ // preserve the target's value).
325
+ const src = this._currentSource;
326
+ if (src !== null && typeof src === "object" && item.field in src) {
327
+ base[item.field] = src[item.field];
328
+ }
329
+ }
330
+ }
331
+ return base;
332
+ }
333
+ get results() {
334
+ return this._value;
335
+ }
336
+ }
337
+ exports.default = Merge;
338
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/parsing/operations/merge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAA4C;AAC5C,2DAAkC;AAElC,4DAAoC;AA2CpC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;GAKG;AACH,MAAa,gBAAiB,SAAQ,kBAAO;IAEzC,YAAY,KAAY;QACpB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACM,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC;CACJ;AATD,4CASC;AAED,MAAa,gBAAiB,SAAQ,kBAAO;IAEzC,YAAY,KAAY;QACpB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACM,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC;CACJ;AATD,4CASC;AAED,MAAM,KAAM,SAAQ,mBAAS;IAwBzB,YACI,IAAY,EACZ,WAA0B,EAC1B,WAA0B,EAC1B,gBAAmC,EACnC,cAA8B,EAC9B,QAAuB,EACvB,OAAkC,EAClC,UAAwC;QAExC,KAAK,EAAE,CAAC;QAxBZ;;;WAGG;QACK,mBAAc,GAAQ,SAAS,CAAC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iers in each record.
44
44
  */
45
45
  sort(records: Record<string, any>[]): Record<string, any>[];
46
+ /**
47
+ * Returns the permutation that {@link sort} applies, without
48
+ * materialising the sorted records. Used by callers that need to
49
+ * permute a parallel array (e.g. row-level provenance) in lockstep.
50
+ */
51
+ sortIndices(records: Record<string, any>[]): number[];
46
52
  /**
47
53
  * When used as a standalone operation (after non-aggregate WITH),
48
54
  * accumulates records to sort later.
@@ -1 +1 @@
1
- {"version":3,"file":"order_by.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/order_by.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,2BAA2B,CAAC;AAEnD,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,SAAS;IACtB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,UAAU,EAAE,UAAU,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,cAAM,OAAQ,SAAQ,SAAS;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAA6B;IAC7C;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAe;gBAEpB,MAAM,EAAE,SAAS,EAAE;IAK/B,IAAW,MAAM,IAAI,SAAS,EAAE,CAE/B;IAED;;;;OAIG;IACI,eAAe,IAAI,IAAI;IAI9B;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IA6ClE;;;OAGG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAOpB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMxC,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"order_by.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/order_by.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,2BAA2B,CAAC;AAEnD,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,SAAS;IACtB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,UAAU,EAAE,UAAU,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,cAAM,OAAQ,SAAQ,SAAS;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAA6B;IAC7C;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAe;gBAEpB,MAAM,EAAE,SAAS,EAAE;IAK/B,IAAW,MAAM,IAAI,SAAS,EAAE,CAE/B;IAED;;;;OAIG;IACI,eAAe,IAAI,IAAI;IAI9B;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAKlE;;;;OAIG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE;IA6C5D;;;OAGG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAOpB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMxC,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,OAAO,CAAC"}
@@ -58,6 +58,15 @@ class OrderBy extends operation_1.default {
58
58
  * identifiers in each record.
59
59
  */
60
60
  sort(records) {
61
+ const indices = this.sortIndices(records);
62
+ return indices.map((i) => records[i]);
63
+ }
64
+ /**
65
+ * Returns the permutation that {@link sort} applies, without
66
+ * materialising the sorted records. Used by callers that need to
67
+ * permute a parallel array (e.g. row-level provenance) in lockstep.
68
+ */
69
+ sortIndices(records) {
61
70
  const useKeys = this._sortKeys.length === records.length;
62
71
  // Build an index array so we can sort records and keys together.
63
72
  const indices = records.map((_, i) => i);
@@ -104,7 +113,7 @@ class OrderBy extends operation_1.default {
104
113
  }
105
114
  return 0;
106
115
  });
107
- return indices.map((i) => records[i]);
116
+ return indices;
108
117
  }
109
118
  /**
110
119
  * When used as a standalone operation (after non-aggregate WITH),
@@ -1 +1 @@
1
- {"version":3,"file":"order_by.js","sourceRoot":"","sources":["../../../src/parsing/operations/order_by.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,yEAAiD;AACjD,4DAAoC;AAQpC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAQ,SAAQ,mBAAS;IAU3B,YAAY,MAAmB;QAC3B,KAAK,EAAE,CAAC;QATJ,aAAQ,GAA0B,EAAE,CAAC;QAC7C;;;;WAIG;QACK,cAAS,GAAY,EAAE,CAAC;QAI5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,eAAe;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAC,OAA8B;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;QACzD,iEAAiE;QACjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAE5B,6DAA6D;QAC7D,8DAA8D;QAC9D,gEAAgE;QAChE,MAAM,cAAc,GAAsB,IAAI,CAAC,O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O,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC7D,CAAC;YACL,CAAC;YACD,OAAO,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;OAGG;IACU,GAAG;;;YACZ,MAAM,MAAM,GAAwB,EAAE,CAAC;YACvC,mDAAmD;YACnD,8DAA8D;YAC9D,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,GAAG,EAAE,CAAA,CAAC;QAC3B,CAAC;KAAA;IAEY,UAAU;;;YACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,UAAU,EAAE,CAAA,CAAC;QAClC,CAAC;KAAA;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAED,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,15 @@
1
+ import Operation from "./operation";
2
+ /**
3
+ * `REFRESH BINDING name`: clear the cached value of a refreshable
4
+ * binding so the next read re-executes the backing sub-query. No-op
5
+ * for plain bindings.
6
+ */
7
+ declare class RefreshBinding extends Operation {
8
+ private _name;
9
+ constructor(name: string);
10
+ get name(): string;
11
+ run(): Promise<void>;
12
+ get results(): Record<string, any>[];
13
+ }
14
+ export default RefreshBinding;
15
+ //# sourceMappingURL=refresh_binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh_binding.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/refresh_binding.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC;;;;GAIG;AACH,cAAM,cAAe,SAAQ,SAAS;IAClC,OAAO,CAAC,KAAK,CAAS;gBAEV,IAAI,EAAE,MAAM;IAKxB,IAAW,IAAI,IAAI,MAAM,CAExB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const bindings_1 = __importDefault(require("../../graph/bindings"));
16
+ const operation_1 = __importDefault(require("./operation"));
17
+ /**
18
+ * `REFRESH BINDING name`: clear the cached value of a refreshable
19
+ * binding so the next read re-executes the backing sub-query. No-op
20
+ * for plain bindings.
21
+ */
22
+ class RefreshBinding extends operation_1.default {
23
+ constructor(name) {
24
+ super();
25
+ this._name = name;
26
+ }
27
+ get name() {
28
+ return this._name;
29
+ }
30
+ run() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ var _a;
33
+ bindings_1.default.getInstance().invalidate(this._name);
34
+ yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.run());
35
+ });
36
+ }
37
+ get results() {
38
+ return [];
39
+ }
40
+ }
41
+ exports.default = RefreshBinding;
42
+ //# sourceMappingURL=refresh_binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh_binding.js","sourceRoot":"","sources":["../../../src/parsing/operations/refresh_binding.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oEAA4C;AAC5C,4DAAoC;AAEpC;;;;GAIG;AACH,MAAM,cAAe,SAAQ,mBAAS;IAGlC,YAAY,IAAY;QACpB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEY,GAAG;;;YACZ,kBAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9C,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,GAAG,EAAE,CAAA,CAAC;QAC3B,CAAC;KAAA;IAED,IAAW,OAAO;QACd,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAED,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ import Node from "../../graph/node";
2
+ import Operation from "./operation";
3
+ declare class RefreshNode extends Operation {
4
+ private _node;
5
+ constructor(node: Node);
6
+ get node(): Node | null;
7
+ run(): Promise<void>;
8
+ get results(): Record<string, any>[];
9
+ }
10
+ export default RefreshNode;
11
+ //# sourceMappingURL=refresh_node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh_node.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/refresh_node.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,cAAM,WAAY,SAAQ,SAAS;IAC/B,OAAO,CAAC,KAAK,CAAqB;gBACtB,IAAI,EAAE,IAAI;IAItB,IAAW,IAAI,IAAI,IAAI,GAAG,IAAI,CAE7B;IACM,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3B,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,WAAW,CAAC"}