@zenstackhq/trpc 0.6.0-pre.19 → 1.0.0-alpha.100

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 (39) hide show
  1. package/README.md +3 -1
  2. package/generator.js +164 -54
  3. package/generator.js.map +1 -1
  4. package/helpers.d.ts +1 -2
  5. package/helpers.js +15 -17
  6. package/helpers.js.map +1 -1
  7. package/package.json +12 -4
  8. package/zod/generator.js +3 -10
  9. package/zod/generator.js.map +1 -1
  10. package/zod/transformer.d.ts +0 -5
  11. package/zod/transformer.js +24 -51
  12. package/zod/transformer.js.map +1 -1
  13. package/zod/helpers/aggregate-helpers.d.ts +0 -5
  14. package/zod/helpers/aggregate-helpers.js +0 -64
  15. package/zod/helpers/aggregate-helpers.js.map +0 -1
  16. package/zod/helpers/comments-helpers.d.ts +0 -6
  17. package/zod/helpers/comments-helpers.js +0 -99
  18. package/zod/helpers/comments-helpers.js.map +0 -1
  19. package/zod/helpers/helpers.d.ts +0 -8
  20. package/zod/helpers/helpers.js +0 -39
  21. package/zod/helpers/helpers.js.map +0 -1
  22. package/zod/helpers/include-helpers.d.ts +0 -2
  23. package/zod/helpers/include-helpers.js +0 -79
  24. package/zod/helpers/include-helpers.js.map +0 -1
  25. package/zod/helpers/index.d.ts +0 -4
  26. package/zod/helpers/index.js +0 -21
  27. package/zod/helpers/index.js.map +0 -1
  28. package/zod/helpers/model-helpers.d.ts +0 -6
  29. package/zod/helpers/model-helpers.js +0 -39
  30. package/zod/helpers/model-helpers.js.map +0 -1
  31. package/zod/helpers/modelArgs-helpers.d.ts +0 -2
  32. package/zod/helpers/modelArgs-helpers.js +0 -62
  33. package/zod/helpers/modelArgs-helpers.js.map +0 -1
  34. package/zod/helpers/mongodb-helpers.d.ts +0 -3
  35. package/zod/helpers/mongodb-helpers.js +0 -65
  36. package/zod/helpers/mongodb-helpers.js.map +0 -1
  37. package/zod/helpers/select-helpers.d.ts +0 -2
  38. package/zod/helpers/select-helpers.js +0 -137
  39. package/zod/helpers/select-helpers.js.map +0 -1
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./comments-helpers"), exports);
18
- __exportStar(require("./helpers"), exports);
19
- __exportStar(require("./model-helpers"), exports);
20
- __exportStar(require("./mongodb-helpers"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/zod/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC"}
@@ -1,6 +0,0 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
- export declare function checkModelHasModelRelation(model: DMMF.Model): boolean;
3
- export declare function checkModelHasManyModelRelation(model: DMMF.Model): boolean;
4
- export declare function checkIsModelRelationField(modelField: DMMF.Field): boolean;
5
- export declare function checkIsManyModelRelationField(modelField: DMMF.Field): boolean;
6
- export declare function findModelByName(models: DMMF.Model[], modelName: string): DMMF.Model | undefined;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findModelByName = exports.checkIsManyModelRelationField = exports.checkIsModelRelationField = exports.checkModelHasManyModelRelation = exports.checkModelHasModelRelation = void 0;
4
- function checkModelHasModelRelation(model) {
5
- const { fields: modelFields } = model;
6
- for (const modelField of modelFields) {
7
- const isRelationField = checkIsModelRelationField(modelField);
8
- if (isRelationField) {
9
- return true;
10
- }
11
- }
12
- return false;
13
- }
14
- exports.checkModelHasModelRelation = checkModelHasModelRelation;
15
- function checkModelHasManyModelRelation(model) {
16
- const { fields: modelFields } = model;
17
- for (const modelField of modelFields) {
18
- const isManyRelationField = checkIsManyModelRelationField(modelField);
19
- if (isManyRelationField) {
20
- return true;
21
- }
22
- }
23
- return false;
24
- }
25
- exports.checkModelHasManyModelRelation = checkModelHasManyModelRelation;
26
- function checkIsModelRelationField(modelField) {
27
- const { kind, relationName } = modelField;
28
- return kind === 'object' && !!relationName;
29
- }
30
- exports.checkIsModelRelationField = checkIsModelRelationField;
31
- function checkIsManyModelRelationField(modelField) {
32
- return checkIsModelRelationField(modelField) && modelField.isList;
33
- }
34
- exports.checkIsManyModelRelationField = checkIsManyModelRelationField;
35
- function findModelByName(models, modelName) {
36
- return models.find(({ name }) => name === modelName);
37
- }
38
- exports.findModelByName = findModelByName;
39
- //# sourceMappingURL=model-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/model-helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,0BAA0B,CAAC,KAAiB;IACxD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,eAAe,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,eAAe,EAAE;YACjB,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AATD,gEASC;AAED,SAAgB,8BAA8B,CAAC,KAAiB;IAC5D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QACtE,IAAI,mBAAmB,EAAE;YACrB,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AATD,wEASC;AAED,SAAgB,yBAAyB,CAAC,UAAsB;IAC5D,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAC1C,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,YAAY,CAAC;AAC/C,CAAC;AAHD,8DAGC;AAED,SAAgB,6BAA6B,CAAC,UAAsB;IAChE,OAAO,yBAAyB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC;AACtE,CAAC;AAFD,sEAEC;AAED,SAAgB,eAAe,CAAC,MAAoB,EAAE,SAAiB;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AACzD,CAAC;AAFD,0CAEC"}
@@ -1,2 +0,0 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
- export declare function addMissingInputObjectTypesForModelArgs(inputObjectTypes: DMMF.InputType[], models: DMMF.Model[], isGenerateSelect: boolean, isGenerateInclude: boolean): void;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addMissingInputObjectTypesForModelArgs = void 0;
4
- const model_helpers_1 = require("./model-helpers");
5
- function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
6
- const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
7
- for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
8
- inputObjectTypes.push(modelArgsInputObjectType);
9
- }
10
- }
11
- exports.addMissingInputObjectTypesForModelArgs = addMissingInputObjectTypesForModelArgs;
12
- function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
13
- const modelArgsInputObjectTypes = [];
14
- for (const model of models) {
15
- const { name: modelName } = model;
16
- const fields = [];
17
- if (isGenerateSelect) {
18
- const selectField = {
19
- name: 'select',
20
- isRequired: false,
21
- isNullable: false,
22
- inputTypes: [
23
- {
24
- isList: false,
25
- type: `${modelName}Select`,
26
- location: 'inputObjectTypes',
27
- namespace: 'prisma',
28
- },
29
- ],
30
- };
31
- fields.push(selectField);
32
- }
33
- const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
34
- if (isGenerateInclude && hasRelationToAnotherModel) {
35
- const includeField = {
36
- name: 'include',
37
- isRequired: false,
38
- isNullable: false,
39
- inputTypes: [
40
- {
41
- isList: false,
42
- type: `${modelName}Include`,
43
- location: 'inputObjectTypes',
44
- namespace: 'prisma',
45
- },
46
- ],
47
- };
48
- fields.push(includeField);
49
- }
50
- const modelArgsInputObjectType = {
51
- name: `${modelName}Args`,
52
- constraints: {
53
- maxNumFields: null,
54
- minNumFields: null,
55
- },
56
- fields,
57
- };
58
- modelArgsInputObjectTypes.push(modelArgsInputObjectType);
59
- }
60
- return modelArgsInputObjectTypes;
61
- }
62
- //# sourceMappingURL=modelArgs-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modelArgs-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/modelArgs-helpers.ts"],"names":[],"mappings":";;;AACA,mDAA6D;AAE7D,SAAgB,sCAAsC,CAClD,gBAAkC,EAClC,MAAoB,EACpB,gBAAyB,EACzB,iBAA0B;IAE1B,MAAM,yBAAyB,GAAG,iCAAiC,CAAC,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAEjH,KAAK,MAAM,wBAAwB,IAAI,yBAAyB,EAAE;QAC9D,gBAAgB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;KACnD;AACL,CAAC;AAXD,wFAWC;AACD,SAA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D;IACD,OAAO,yBAAyB,CAAC;AACrC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
- export declare function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations: DMMF.ModelMapping[], outputObjectTypes: DMMF.OutputType[], inputObjectTypes: DMMF.InputType[]): void;
3
- export declare const isMongodbRawOp: (name: string) => boolean;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isMongodbRawOp = exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = void 0;
7
- const transformer_1 = __importDefault(require("../transformer"));
8
- function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
9
- const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
10
- transformer_1.default.rawOpsMap = rawOpsMap !== null && rawOpsMap !== void 0 ? rawOpsMap : {};
11
- const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
12
- for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
13
- inputObjectTypes.push(mongoDbRawQueryInputType);
14
- }
15
- }
16
- exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = addMissingInputObjectTypesForMongoDbRawOpsAndQueries;
17
- function resolveMongoDbRawOperations(modelOperations) {
18
- const rawOpsMap = {};
19
- const rawOpsNames = [
20
- ...new Set(modelOperations.reduce((result, current) => {
21
- const keys = Object.keys(current);
22
- keys === null || keys === void 0 ? void 0 : keys.forEach((key) => {
23
- if (key.includes('Raw')) {
24
- result.push(key);
25
- }
26
- });
27
- return result;
28
- }, [])),
29
- ];
30
- const modelNames = modelOperations.map((item) => item.model);
31
- rawOpsNames.forEach((opName) => {
32
- modelNames.forEach((modelName) => {
33
- const isFind = opName === 'findRaw';
34
- const opWithModel = `${opName.replace('Raw', '')}${modelName}Raw`;
35
- rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
36
- });
37
- });
38
- return rawOpsMap;
39
- }
40
- function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
41
- const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
42
- const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
43
- name: item.name,
44
- constraints: {
45
- maxNumFields: null,
46
- minNumFields: null,
47
- },
48
- fields: item.args.map((arg) => ({
49
- name: arg.name,
50
- isRequired: arg.isRequired,
51
- isNullable: arg.isNullable,
52
- inputTypes: arg.inputTypes,
53
- })),
54
- }));
55
- return mongoDbRawQueryInputObjectTypes;
56
- }
57
- function getMongoDbRawQueries(outputObjectTypes) {
58
- var _a;
59
- const queryOutputTypes = outputObjectTypes.filter((item) => item.name === 'Query');
60
- const mongodbRawQueries = (_a = queryOutputTypes === null || queryOutputTypes === void 0 ? void 0 : queryOutputTypes[0].fields.filter((field) => field.name.includes('Raw'))) !== null && _a !== void 0 ? _a : [];
61
- return mongodbRawQueries;
62
- }
63
- const isMongodbRawOp = (name) => /find([^]*?)Raw/.test(name) || /aggregate([^]*?)Raw/.test(name);
64
- exports.isMongodbRawOp = isMongodbRawOp;
65
- //# sourceMappingURL=mongodb-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongodb-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/mongodb-helpers.ts"],"names":[],"mappings":";;;;;;AACA,iEAAyC;AAEzC,SAAgB,oDAAoD,CAChE,eAAoC,EACpC,iBAAoC,EACpC,gBAAkC;IAElC,MAAM,SAAS,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC/D,qBAAW,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;IAExC,MAAM,+BAA+B,GAAG,sCAAsC,CAAC,iBAAiB,CAAC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+0,0 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
- export declare function addMissingInputObjectTypesForSelect(inputObjectTypes: DMMF.InputType[], outputObjectTypes: DMMF.OutputType[], models: DMMF.Model[]): void;
@@ -1,137 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addMissingInputObjectTypesForSelect = void 0;
4
- const model_helpers_1 = require("./model-helpers");
5
- function addMissingInputObjectTypesForSelect(inputObjectTypes, outputObjectTypes, models) {
6
- // generate input object types necessary to support ModelSelect._count
7
- const modelCountOutputTypes = getModelCountOutputTypes(outputObjectTypes);
8
- const modelCountOutputTypeSelectInputObjectTypes = generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes);
9
- const modelCountOutputTypeArgsInputObjectTypes = generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes);
10
- const modelSelectInputObjectTypes = generateModelSelectInputObjectTypes(models);
11
- const generatedInputObjectTypes = [
12
- modelCountOutputTypeSelectInputObjectTypes,
13
- modelCountOutputTypeArgsInputObjectTypes,
14
- modelSelectInputObjectTypes,
15
- ].flat();
16
- for (const inputObjectType of generatedInputObjectTypes) {
17
- inputObjectTypes.push(inputObjectType);
18
- }
19
- }
20
- exports.addMissingInputObjectTypesForSelect = addMissingInputObjectTypesForSelect;
21
- function getModelCountOutputTypes(outputObjectTypes) {
22
- return outputObjectTypes.filter(({ name }) => name.includes('CountOutputType'));
23
- }
24
- function generateModelCountOutputTypeSelectInputObjectTypes(modelCountOutputTypes) {
25
- const modelCountOutputTypeSelectInputObjectTypes = [];
26
- for (const modelCountOutputType of modelCountOutputTypes) {
27
- const { name: modelCountOutputTypeName, fields: modelCountOutputTypeFields } = modelCountOutputType;
28
- const modelCountOutputTypeSelectInputObjectType = {
29
- name: `${modelCountOutputTypeName}Select`,
30
- constraints: {
31
- maxNumFields: null,
32
- minNumFields: null,
33
- },
34
- fields: modelCountOutputTypeFields.map(({ name }) => ({
35
- name,
36
- isRequired: false,
37
- isNullable: false,
38
- inputTypes: [
39
- {
40
- isList: false,
41
- type: `Boolean`,
42
- location: 'scalar',
43
- },
44
- ],
45
- })),
46
- };
47
- modelCountOutputTypeSelectInputObjectTypes.push(modelCountOutputTypeSelectInputObjectType);
48
- }
49
- return modelCountOutputTypeSelectInputObjectTypes;
50
- }
51
- function generateModelCountOutputTypeArgsInputObjectTypes(modelCountOutputTypes) {
52
- const modelCountOutputTypeArgsInputObjectTypes = [];
53
- for (const modelCountOutputType of modelCountOutputTypes) {
54
- const { name: modelCountOutputTypeName } = modelCountOutputType;
55
- const modelCountOutputTypeArgsInputObjectType = {
56
- name: `${modelCountOutputTypeName}Args`,
57
- constraints: {
58
- maxNumFields: null,
59
- minNumFields: null,
60
- },
61
- fields: [
62
- {
63
- name: 'select',
64
- isRequired: false,
65
- isNullable: false,
66
- inputTypes: [
67
- {
68
- isList: false,
69
- type: `${modelCountOutputTypeName}Select`,
70
- location: 'inputObjectTypes',
71
- namespace: 'prisma',
72
- },
73
- ],
74
- },
75
- ],
76
- };
77
- modelCountOutputTypeArgsInputObjectTypes.push(modelCountOutputTypeArgsInputObjectType);
78
- }
79
- return modelCountOutputTypeArgsInputObjectTypes;
80
- }
81
- function generateModelSelectInputObjectTypes(models) {
82
- const modelSelectInputObjectTypes = [];
83
- for (const model of models) {
84
- const { name: modelName, fields: modelFields } = model;
85
- const fields = [];
86
- for (const modelField of modelFields) {
87
- const { name: modelFieldName, isList, type } = modelField;
88
- const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
89
- const field = {
90
- name: modelFieldName,
91
- isRequired: false,
92
- isNullable: false,
93
- inputTypes: [{ isList: false, type: 'Boolean', location: 'scalar' }],
94
- };
95
- if (isRelationField) {
96
- const schemaArgInputType = {
97
- isList: false,
98
- type: isList ? `${type}FindManyArgs` : `${type}Args`,
99
- location: 'inputObjectTypes',
100
- namespace: 'prisma',
101
- };
102
- field.inputTypes.push(schemaArgInputType);
103
- }
104
- fields.push(field);
105
- }
106
- const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
107
- const shouldAddCountField = hasManyRelationToAnotherModel;
108
- if (shouldAddCountField) {
109
- const _countField = {
110
- name: '_count',
111
- isRequired: false,
112
- isNullable: false,
113
- inputTypes: [
114
- { isList: false, type: 'Boolean', location: 'scalar' },
115
- {
116
- isList: false,
117
- type: `${modelName}CountOutputTypeArgs`,
118
- location: 'inputObjectTypes',
119
- namespace: 'prisma',
120
- },
121
- ],
122
- };
123
- fields.push(_countField);
124
- }
125
- const modelSelectInputObjectType = {
126
- name: `${modelName}Select`,
127
- constraints: {
128
- maxNumFields: null,
129
- minNumFields: null,
130
- },
131
- fields,
132
- };
133
- modelSelectInputObjectTypes.push(modelSelectInputObjectType);
134
- }
135
- return modelSelectInputObjectTypes;
136
- }
137
- //# sourceMappingURL=select-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"select-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/select-helpers.ts"],"names":[],"mappings":";;;AACA,mDAA4F;AAE5F,SAAgB,mCAAmC,CAC/C,gBAAkC,EAClC,iBAAoC,EACpC,MAAoB;IAEpB,sEAAsE;IACtE,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;IAC1E,MAAM,0CAA0C,GAC5C,kDAAkD,CAAC,qBAAqB,CAAC,CAAC;IAC9E,MAAM,wCAAwC,GAC1C,gDAAgD,CAAC,qBAAqB,CAAC,CAAC;IAE5E,MAAM,2BAA2B,GAAG,mCAAmC,CAAC,MAAM,CAAC,CAAC;IAEhF,MAAM,yBAAyB,GAAG;QAC9B,0CAA0C;QAC1C,wCAAwC;QACxC,2BAA2B;KAC9B,CAAC,IAAI,EAAE,CAAC;IAET,KAAK,MAAM,eAAe,IAAI,yBAAyB,EAAE;QACrD,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KAC1C;AACL,CAAC;AAvBD,kFAuBC;AAED,SAAS,wBAAwB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