@fintekkers/ledger-models 0.1.59 → 0.1.61

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 (57) hide show
  1. package/babel.config.js +3 -1
  2. package/index.js +1 -13
  3. package/index.js.map +1 -1
  4. package/index.ts +1 -18
  5. package/jest.config.js +4 -0
  6. package/node/fintekkers/models/security/security_pb.test.js +29 -30
  7. package/node/fintekkers/models/security/security_pb.test.js.map +1 -0
  8. package/node/fintekkers/models/security/security_pb.test.ts +33 -0
  9. package/node/wrappers/models/security/security.js +21 -18
  10. package/node/wrappers/models/security/security.js.map +1 -1
  11. package/node/wrappers/models/security/security.ts +22 -18
  12. package/node/wrappers/models/transaction/transaction.js +111 -0
  13. package/node/wrappers/models/transaction/transaction.js.map +1 -0
  14. package/node/wrappers/models/transaction/transaction.test.js +26 -0
  15. package/node/wrappers/models/transaction/transaction.test.js.map +1 -0
  16. package/node/wrappers/models/transaction/transaction.test.ts +37 -0
  17. package/node/wrappers/models/transaction/transaction.ts +139 -0
  18. package/node/wrappers/models/transaction/transaction_type.js +45 -0
  19. package/node/wrappers/models/transaction/transaction_type.js.map +1 -0
  20. package/node/wrappers/models/transaction/transaction_type.ts +47 -0
  21. package/node/wrappers/models/utils/date.js +25 -0
  22. package/node/wrappers/models/utils/date.js.map +1 -0
  23. package/node/wrappers/models/utils/date.ts +31 -0
  24. package/node/wrappers/models/utils/datetime.js +4 -4
  25. package/node/wrappers/models/utils/datetime.js.map +1 -1
  26. package/node/wrappers/models/utils/datetime.ts +4 -4
  27. package/node/wrappers/models/utils/serialization.test.js +14 -54
  28. package/node/wrappers/models/utils/serialization.test.js.map +1 -1
  29. package/node/wrappers/models/utils/serialization.test.ts +11 -7
  30. package/node/wrappers/services/portfolio-service/PortfolioService.js +6 -7
  31. package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
  32. package/node/wrappers/services/portfolio-service/PortfolioService.ts +8 -8
  33. package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +10 -9
  34. package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
  35. package/node/wrappers/{portfolio.test.ts → services/portfolio-service/portfolio.test.ts} +15 -11
  36. package/node/wrappers/services/position-service/PositionService.js +2 -5
  37. package/node/wrappers/services/position-service/PositionService.js.map +1 -1
  38. package/node/wrappers/services/position-service/PositionService.ts +4 -7
  39. package/node/wrappers/{position.test.js → services/position-service/position.test.js} +17 -20
  40. package/node/wrappers/services/position-service/position.test.js.map +1 -0
  41. package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +21 -28
  42. package/node/wrappers/services/security-service/SecurityService.js +2 -5
  43. package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
  44. package/node/wrappers/services/security-service/SecurityService.ts +2 -5
  45. package/node/wrappers/{security.test.js → services/security-service/security.test.js} +15 -16
  46. package/node/wrappers/services/security-service/security.test.js.map +1 -0
  47. package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +19 -17
  48. package/node/wrappers/services/transaction-service/TransactionService.js +143 -0
  49. package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -0
  50. package/node/wrappers/services/transaction-service/TransactionService.ts +96 -0
  51. package/node/wrappers/services/transaction-service/transaction.test.js +116 -0
  52. package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
  53. package/node/wrappers/services/transaction-service/transaction.test.ts +87 -0
  54. package/package.json +4 -2
  55. package/node/wrappers/portfolio.test.js.map +0 -1
  56. package/node/wrappers/position.test.js.map +0 -1
  57. package/node/wrappers/security.test.js.map +0 -1
@@ -0,0 +1,96 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { promisify } from 'util';
3
+
4
+ // Models
5
+ import Transaction from '../../models/transaction/transaction';
6
+ import { createFieldMapEntry } from '../../models/utils/util';
7
+ import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
8
+ import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
9
+
10
+ // Model Utils
11
+ import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
12
+ import { FieldProto } from '../../../fintekkers/models/position/field_pb';
13
+
14
+ // Requests & Services
15
+ import { TransactionClient } from '../../../fintekkers/services/transaction-service/transaction_service_grpc_pb';
16
+ import { CreateTransactionRequestProto } from '../../../fintekkers/requests/transaction/create_transaction_request_pb';
17
+ import { CreateTransactionResponseProto } from '../../../fintekkers/requests/transaction/create_transaction_response_pb';
18
+ import { QueryTransactionRequestProto } from '../../../fintekkers/requests/transaction/query_transaction_request_pb';
19
+ import { QueryTransactionResponseProto } from '../../../fintekkers/requests/transaction/query_transaction_response_pb';
20
+
21
+
22
+ class TransactionService {
23
+ private client: TransactionClient;
24
+
25
+ constructor() {
26
+ this.client = new TransactionClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
27
+ // this.client = new TransactionClient('localhost:8082', grpc.credentials.createInsecure());
28
+ }
29
+
30
+ async validateCreateTransaction(transaction: Transaction): Promise<SummaryProto> {
31
+ const createRequest = new CreateTransactionRequestProto();
32
+ createRequest.setObjectClass('TransactionRequest');
33
+ createRequest.setVersion('0.0.1');
34
+ createRequest.setCreateTransactionInput(transaction.proto);
35
+
36
+ const validateCreateOrUpdateAsync = promisify(this.client.validateCreateOrUpdate.bind(this.client));
37
+ const response = await validateCreateOrUpdateAsync(createRequest);
38
+ return response;
39
+ }
40
+
41
+ async createTransaction(transaction: Transaction): Promise<CreateTransactionResponseProto> {
42
+ const createRequest = new CreateTransactionRequestProto();
43
+ createRequest.setObjectClass('TransactionRequest');
44
+ createRequest.setVersion('0.0.1');
45
+ createRequest.setCreateTransactionInput(transaction.proto);
46
+
47
+ const createSecurityAsync = promisify(this.client.createOrUpdate.bind(this.client));
48
+ const response = await createSecurityAsync(createRequest);
49
+ return response;
50
+ }
51
+
52
+ async searchTransaction(asOf: LocalTimestampProto, fieldProto: FieldProto, fieldValue: string): Promise<Transaction[]> {
53
+ const searchRequest = new QueryTransactionRequestProto();
54
+ searchRequest.setObjectClass('SecurityRequest');
55
+ searchRequest.setVersion('0.0.1');
56
+ searchRequest.setAsOf(asOf);
57
+
58
+ const positionFilter = new PositionFilterProto();
59
+ positionFilter.setObjectClass('PositionFilter');
60
+ positionFilter.setVersion('0.0.1');
61
+
62
+ const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
63
+ positionFilter.setFiltersList([fieldMapEntry]);
64
+
65
+ searchRequest.setSearchTransactionInput(positionFilter);
66
+
67
+ const tmpClient = this.client;
68
+
69
+ const listTransactions: Transaction[] = [];
70
+
71
+ async function processStreamSynchronously(): Promise<Transaction[]> {
72
+ const stream2 = tmpClient.search(searchRequest);
73
+
74
+ return new Promise<Transaction[]>((resolve, reject) => {
75
+ stream2.on('data', (response:QueryTransactionResponseProto) => {
76
+ response.getTransactionResponseList().forEach((transaction) => {
77
+ listTransactions.push(new Transaction(transaction));
78
+ });
79
+ });
80
+
81
+ stream2.on('end', () => {
82
+ resolve(listTransactions);
83
+ });
84
+
85
+ stream2.on('error', (err) => {
86
+ console.error('Error in the stream:', err);
87
+ reject(err);
88
+ });
89
+ });
90
+ }
91
+
92
+ return await processStreamSynchronously();
93
+ }
94
+ }
95
+
96
+ export { TransactionService };
@@ -0,0 +1,116 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ // Models
40
+ var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
41
+ var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
42
+ // Model Utils
43
+ var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
44
+ var uuid = require("../../models/utils/uuid");
45
+ var dt = require("../../models/utils/datetime");
46
+ var SecurityService_1 = require("../security-service/SecurityService");
47
+ var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
48
+ var transaction_pb_1 = require("../../../fintekkers/models/transaction/transaction_pb");
49
+ var price_pb_1 = require("../../../fintekkers/models/price/price_pb");
50
+ var PortfolioService_1 = require("../portfolio-service/PortfolioService");
51
+ var TransactionService_1 = require("./TransactionService");
52
+ var transaction_1 = require("../../models/transaction/transaction");
53
+ test('test creating a transaction against the api.fintekkers.org portfolio service', function () {
54
+ var isTrue = testTransaction();
55
+ expect(isTrue).resolves.toBe(true);
56
+ }, 30000);
57
+ function testTransaction() {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ var id_proto, now, today, securityService, portfolioService, transactionService, fixedIncomeSecurities, security, portfolios, portfolio, transaction, createTransactionResponse, searchResults;
60
+ return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0:
63
+ id_proto = uuid.UUID.random().toUUIDProto();
64
+ now = dt.ZonedDateTime.now();
65
+ today = new local_date_pb_1.LocalDateProto().setDay(1).setMonth(1).setYear(2021);
66
+ securityService = new SecurityService_1.SecurityService();
67
+ portfolioService = new PortfolioService_1.PortfolioService();
68
+ transactionService = new TransactionService_1.TransactionService();
69
+ return [4 /*yield*/, securityService
70
+ .searchSecurity(now.to_date_proto(), field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income')
71
+ .then(function (fixedIncomeSecurities) {
72
+ return fixedIncomeSecurities;
73
+ })];
74
+ case 1:
75
+ fixedIncomeSecurities = _a.sent();
76
+ security = fixedIncomeSecurities[0];
77
+ return [4 /*yield*/, portfolioService.searchPortfolio(now.to_date_proto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'TEST PORTFOLIO')];
78
+ case 2:
79
+ portfolios = _a.sent();
80
+ if (portfolios === undefined) {
81
+ throw new Error('No portfolios found');
82
+ }
83
+ portfolio = portfolios[0];
84
+ if (portfolio.getPortfolioName().includes('Federal')) {
85
+ throw new Error('Portfolio is not a test portfolio! Abandoning test');
86
+ }
87
+ transaction = new transaction_pb_1.TransactionProto();
88
+ transaction.setObjectClass('Transaction');
89
+ transaction.setVersion('0.0.1');
90
+ transaction.setUuid(uuid.UUID.random().toUUIDProto());
91
+ transaction.setAsOf(now.to_date_proto());
92
+ transaction.setTradeDate(today);
93
+ transaction.setSettlementDate(today); //Same day settlement
94
+ transaction.setTransactionType(transaction_type_pb_1.TransactionTypeProto.BUY);
95
+ transaction.setPrice(new price_pb_1.PriceProto()
96
+ .setObjectClass('Price')
97
+ .setAsOf(now.to_date_proto())
98
+ .setVersion('0.0.1')
99
+ .setSecurity(security.proto)
100
+ .setUuid(uuid.UUID.random().toUUIDProto())
101
+ .setPrice(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('100.00')));
102
+ transaction.setQuantity(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('10000.00'));
103
+ transaction.setPortfolio(portfolio);
104
+ transaction.setSecurity(security.proto);
105
+ return [4 /*yield*/, transactionService.createTransaction(new transaction_1.default(transaction))];
106
+ case 3:
107
+ createTransactionResponse = _a.sent();
108
+ return [4 /*yield*/, transactionService.searchTransaction(now.to_date_proto(), field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income')];
109
+ case 4:
110
+ searchResults = _a.sent();
111
+ return [2 /*return*/, true];
112
+ }
113
+ });
114
+ });
115
+ }
116
+ //# sourceMappingURL=transaction.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,qFAAqF;AACrF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAElD,uEAAsE;AACtE,kGAAkG;AAClG,wFAAyF;AACzF,sEAAuE;AACvE,0EAAyE;AACzE,2DAA0D;AAC1D,oEAA+D;AAG/D,IAAI,CAAC,8EAA8E,EAAE;IACnF,IAAM,MAAM,GAAG,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oBAAnI,yBAAyB,GAAkC,SAAwE;oBAEnH,qBAAM,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,cAAc,CAAC,EAAA;;oBAAvH,aAAa,GAAG,SAAuG;oBAE3H,sBAAO,IAAI,EAAC;;;;CACb"}
@@ -0,0 +1,87 @@
1
+ // Models
2
+ import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
3
+ import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
4
+
5
+ // Model Utils
6
+ import { FieldProto } from '../../../fintekkers/models/position/field_pb';
7
+
8
+ import * as uuid from '../../models/utils/uuid';
9
+ import * as dt from '../../models/utils/datetime';
10
+
11
+ import { SecurityService } from '../security-service/SecurityService';
12
+ import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
13
+ import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
14
+ import { PriceProto } from '../../../fintekkers/models/price/price_pb';
15
+ import { PortfolioService } from '../portfolio-service/PortfolioService';
16
+ import { TransactionService } from './TransactionService';
17
+ import Transaction from '../../models/transaction/transaction';
18
+ import { CreateTransactionResponseProto } from '../../../fintekkers/requests/transaction/create_transaction_response_pb';
19
+
20
+ test('test creating a transaction against the api.fintekkers.org portfolio service', () => {
21
+ const isTrue = testTransaction();
22
+ expect(isTrue).resolves.toBe(true);
23
+ }, 30000);
24
+
25
+
26
+ async function testTransaction(): Promise<boolean> {
27
+ const id_proto = uuid.UUID.random().toUUIDProto();
28
+ const now = dt.ZonedDateTime.now();
29
+ const today = new LocalDateProto().setDay(1).setMonth(1).setYear(2021);
30
+
31
+ const securityService = new SecurityService();
32
+ const portfolioService = new PortfolioService();
33
+ const transactionService = new TransactionService();
34
+
35
+ let fixedIncomeSecurities = await securityService
36
+ .searchSecurity(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Fixed Income')
37
+ .then((fixedIncomeSecurities) => {
38
+ return fixedIncomeSecurities;
39
+ });
40
+
41
+ let security = fixedIncomeSecurities[0];
42
+
43
+ let portfolios = await portfolioService.searchPortfolio(
44
+ now.to_date_proto(),
45
+ FieldProto.PORTFOLIO_NAME,
46
+ 'TEST PORTFOLIO');
47
+
48
+ if(portfolios === undefined) {
49
+ throw new Error('No portfolios found');
50
+ }
51
+
52
+ const portfolio = portfolios[0];
53
+
54
+ if(portfolio.getPortfolioName().includes('Federal')){
55
+ throw new Error('Portfolio is not a test portfolio! Abandoning test');
56
+ }
57
+
58
+ const transaction = new TransactionProto();
59
+ transaction.setObjectClass('Transaction');
60
+ transaction.setVersion('0.0.1');
61
+ transaction.setUuid(uuid.UUID.random().toUUIDProto());
62
+ transaction.setAsOf(now.to_date_proto());
63
+ transaction.setTradeDate(today);
64
+ transaction.setSettlementDate(today); //Same day settlement
65
+ transaction.setTransactionType(TransactionTypeProto.BUY);
66
+ transaction.setPrice(
67
+ new PriceProto()
68
+ .setObjectClass('Price')
69
+ .setAsOf(now.to_date_proto())
70
+ .setVersion('0.0.1')
71
+ .setSecurity(security.proto)
72
+ .setUuid(uuid.UUID.random().toUUIDProto())
73
+ .setPrice(new DecimalValueProto().setArbitraryPrecisionValue('100.00'))
74
+ );
75
+ transaction.setQuantity(new DecimalValueProto().setArbitraryPrecisionValue('10000.00'));
76
+ transaction.setPortfolio(portfolio);
77
+ transaction.setSecurity(security.proto);
78
+
79
+ // var validationSummary = await transactionService.validateCreateTransaction(new Transaction(transaction));
80
+ // console.log(validationSummary);
81
+
82
+ var createTransactionResponse:CreateTransactionResponseProto = await transactionService.createTransaction(new Transaction(transaction));
83
+
84
+ var searchResults = await transactionService.searchTransaction(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Fixed Income');
85
+
86
+ return true;
87
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fintekkers/ledger-models",
3
3
  "todo": "Replace the version with build script version number",
4
- "version": "0.1.59",
4
+ "version": "0.1.61",
5
5
  "description": "ledger model protos ",
6
6
  "authors": [
7
7
  "David Doherty",
@@ -28,11 +28,13 @@
28
28
  "@types/jest": "^29.5.3",
29
29
  "grpc_tools_node_protoc_ts": "^5.3.3",
30
30
  "jest": "^29.6.1",
31
- "jsdom": "^22.1.0"
31
+ "jsdom": "^22.1.0",
32
+ "ts-jest": "^29.1.1"
32
33
  },
33
34
  "dependencies": {
34
35
  "@grpc/grpc-js": "^1.8.18",
35
36
  "bytebuffer": "^5.0.1",
37
+ "decimal.js": "^10.4.3",
36
38
  "luxon": "^3.3.0",
37
39
  "uuid": "^9.0.0"
38
40
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"portfolio.test.js","sourceRoot":"","sources":["portfolio.test.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAET,cAAc;AACd,mEAAoE;AACpE,0CAA4C;AAC5C,4CAA8C;AAE9C,qBAAqB;AACrB,kFAAiF;AACjF,4EAA6E;AAG7E,SAAe,aAAa;;;;;;oBACpB,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;oBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;oBAE7B,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;oBAE1C,SAAS,GAAG,IAAI,6BAAc,EAAE,CAAC;oBACvC,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;oBACtC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC9B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAC5B,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;oBAC7C,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;oBAEf,qBAAM,gBAAgB,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAA;;oBAA7E,iBAAiB,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