@metriport/shared 0.1.5 → 0.1.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ const retry_1 = require("../retry");
5
5
  describe("executeWithRetries", () => {
6
6
  it("returns the first successful execution", async () => {
7
7
  const fn = jest.fn();
8
- await (0, retry_1.executeWithRetries)(fn, undefined, 1);
8
+ await (0, retry_1.executeWithRetriesOrFail)(fn, undefined, 1);
9
9
  expect(fn).toHaveBeenCalledTimes(1);
10
10
  });
11
11
  it("keeps trying on error and returns the first successful execution", async () => {
@@ -14,7 +14,7 @@ describe("executeWithRetries", () => {
14
14
  fn.mockImplementationOnce(() => {
15
15
  throw new Error("test error");
16
16
  });
17
- const resp = await (0, retry_1.executeWithRetries)(fn, undefined, 1);
17
+ const resp = await (0, retry_1.executeWithRetriesOrFail)(fn, undefined, 1);
18
18
  expect(resp).toBeTruthy();
19
19
  expect(resp).toEqual(expectedResponse);
20
20
  expect(fn).toHaveBeenCalledTimes(2);
@@ -25,7 +25,7 @@ describe("executeWithRetries", () => {
25
25
  fn.mockImplementation(() => {
26
26
  throw new Error(errorMsg);
27
27
  });
28
- await expect((0, retry_1.executeWithRetries)(fn, undefined, 1)).rejects.toThrow(errorMsg);
28
+ await expect((0, retry_1.executeWithRetriesOrFail)(fn, undefined, 1)).rejects.toThrow(errorMsg);
29
29
  });
30
30
  });
31
31
  //# sourceMappingURL=retry.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.test.js","sourceRoot":"","sources":["../../../src/common/__tests__/retry.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,oCAA8C;AAE9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACrB,MAAM,IAAA,0BAAkB,EAAC,EAAE,E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,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAA,gCAAwB,EAAS,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type ErrorToStringOptions = {
2
+ detailed: boolean;
3
+ };
4
+ export declare function errorToString(err: unknown, options?: ErrorToStringOptions): string;
5
+ export declare function genericErrorToString(err: unknown): string;
6
+ export declare function detailedErrorToString(error: any): string;
7
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/common/error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,oBAAyC,GACjD,MAAM,CAKR;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEzD;AAGD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAUxD"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detailedErrorToString = exports.genericErrorToString = exports.errorToString = void 0;
4
+ function errorToString(err, options = { detailed: true }) {
5
+ if (options.detailed) {
6
+ return detailedErrorToString(err);
7
+ }
8
+ return genericErrorToString(err);
9
+ }
10
+ exports.errorToString = errorToString;
11
+ function genericErrorToString(err) {
12
+ return err["message"] ?? String(err); // eslint-disable-line @typescript-eslint/no-explicit-any
13
+ }
14
+ exports.genericErrorToString = genericErrorToString;
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ function detailedErrorToString(error) {
17
+ if (!error)
18
+ return "undefined";
19
+ const thisErrorMessage = error.message ? error.message : error.toString();
20
+ const additionalInfo = error.additionalInfo ? JSON.stringify(error.additionalInfo) : undefined;
21
+ const causeMessage = error.cause ? detailedErrorToString(error.cause) : undefined;
22
+ return (`${thisErrorMessage}` +
23
+ `${additionalInfo ? ` (${additionalInfo})` : ""}` +
24
+ `${causeMessage ? `; caused by ${causeMessage}` : ""}`);
25
+ }
26
+ exports.detailedErrorToString = detailedErrorToString;
27
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/common/error.ts"],"names":[],"mappings":";;;AAEA,SAAgB,aAAa,CAC3B,GAAY,EACZ,UAAgC,EAAE,QAAQ,EAAE,IAAI,EAAE;IAElD,IAAI,OAAO,CAAC,QAAQ,EAAE;QACpB,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;KACnC;IACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AARD,sCAQC;AAED,SAAgB,oBAAoB,CAAC,GAAY;IAC/C,OAAQ,GAAW,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,yDAAyD;AAC1G,CAAC;AAFD,oDAEC;AAED,8DAA8D;AAC9D,SAAgB,qBAAqB,CAAC,KAAU;IAC9C,IAAI,CAAC,KAAK;QAAE,OAAO,WAAW,CAAC;IAC/B,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1E,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,OAAO,CACL,GAAG,gBAAgB,EAAE;QACrB,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACjD,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACvD,CAAC;AACJ,CAAC;AAVD,sDAUC"}
@@ -8,12 +8,30 @@
8
8
  * @param maxRetries the maximum number of retries, defaults to 3
9
9
  * @param waitTime the time to wait between retries, defaults to 3000ms
10
10
  * @param log the logger to use, defaults to console.log
11
- * @returns
11
+ * @returns the result of calling the `fn` function
12
12
  */
13
- export declare function executeWithRetries<K>(fn: () => Promise<K>, maxRetries?: number, waitTime?: number, log?: {
13
+ export declare function executeWithRetriesOrFail<K>(fn: () => Promise<K>, maxRetries?: number, waitTime?: number, log?: {
14
14
  (...data: any[]): void;
15
15
  (message?: any, ...optionalParams: any[]): void;
16
16
  (message?: any, ...optionalParams: any[]): void;
17
17
  (message?: any, ...optionalParams: any[]): void;
18
18
  }): Promise<K>;
19
+ /**
20
+ * Executes a function with retries. If the function throws an error, it will retry
21
+ * up to maxRetries times, waiting waitTime between each retry.
22
+ * If the function throws an error on the last retry, it will return undefined.
23
+ * If the function succeeds, it will return the result.
24
+ *
25
+ * @param fn the function to be executed
26
+ * @param maxRetries the maximum number of retries, defaults to 3
27
+ * @param waitTime the time to wait between retries, defaults to 3000ms
28
+ * @param log the logger to use, defaults to console.log
29
+ * @returns the result of calling the `fn` function, or undefined if it fails
30
+ */
31
+ export declare function executeWithRetries<K>(fn: () => Promise<K>, maxRetries?: number, waitTime?: number, log?: {
32
+ (...data: any[]): void;
33
+ (message?: any, ...optionalParams: any[]): void;
34
+ (message?: any, ...optionalParams: any[]): void;
35
+ (message?: any, ...optionalParams: any[]): void;
36
+ }): Promise<K | undefined>;
19
37
  //# sourceMappingURL=retry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/common/retry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,SAAI,EACd,QAAQ,SAAO,EACf,GAAG;;;;;CAAc,GAChB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/common/retry.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,SAAI,EACd,QAAQ,SAAO,EACf,GAAG;;;;;CAAc,GAChB,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,SAAI,EACd,QAAQ,SAAO,EACf,GAAG;;;;;CAAc,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeWithRetries = void 0;
3
+ exports.executeWithRetries = exports.executeWithRetriesOrFail = void 0;
4
+ const error_1 = require("./error");
4
5
  const sleep_1 = require("./sleep");
5
6
  /**
6
7
  * Executes a function with retries. If the function throws an error, it will retry
@@ -12,16 +13,16 @@ const sleep_1 = require("./sleep");
12
13
  * @param maxRetries the maximum number of retries, defaults to 3
13
14
  * @param waitTime the time to wait between retries, defaults to 3000ms
14
15
  * @param log the logger to use, defaults to console.log
15
- * @returns
16
+ * @returns the result of calling the `fn` function
16
17
  */
17
- async function executeWithRetries(fn, maxRetries = 3, waitTime = 3000, log = console.log) {
18
+ async function executeWithRetriesOrFail(fn, maxRetries = 3, waitTime = 3000, log = console.log) {
18
19
  let count = 0;
19
20
  while (count <= maxRetries) {
20
21
  try {
21
22
  return await fn();
22
23
  }
23
24
  catch (e) {
24
- const msg = `Error on executeWithRetries: ${e}, re`;
25
+ const msg = `Error on executeWithRetriesOrFail: ${e}, re`;
25
26
  if (count++ < maxRetries) {
26
27
  log(`${msg}, retrying...`);
27
28
  await (0, sleep_1.sleep)(waitTime);
@@ -33,5 +34,27 @@ async function executeWithRetries(fn, maxRetries = 3, waitTime = 3000, log = con
33
34
  }
34
35
  throw new Error(`Should never get here`);
35
36
  }
37
+ exports.executeWithRetriesOrFail = executeWithRetriesOrFail;
38
+ /**
39
+ * Executes a function with retries. If the function throws an error, it will retry
40
+ * up to maxRetries times, waiting waitTime between each retry.
41
+ * If the function throws an error on the last retry, it will return undefined.
42
+ * If the function succeeds, it will return the result.
43
+ *
44
+ * @param fn the function to be executed
45
+ * @param maxRetries the maximum number of retries, defaults to 3
46
+ * @param waitTime the time to wait between retries, defaults to 3000ms
47
+ * @param log the logger to use, defaults to console.log
48
+ * @returns the result of calling the `fn` function, or undefined if it fails
49
+ */
50
+ async function executeWithRetries(fn, maxRetries = 3, waitTime = 3000, log = console.log) {
51
+ try {
52
+ return await executeWithRetriesOrFail(fn, maxRetries, waitTime, log);
53
+ }
54
+ catch (e) {
55
+ log(`Error calling executeWithRetriesOrFail, returning undefined: ${(0, error_1.errorToString)(e)}`);
56
+ return undefined;
57
+ }
58
+ }
36
59
  exports.executeWithRetries = executeWithRetries;
37
60
  //# sourceMappingURL=retry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/common/retry.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,kBAAkB,CACtC,EAAoB,EACpB,UAAU,GAAG,CAAC,EACd,QAAQ,GAA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,CAAC,CAAC;SACT;KACF;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC;AAtBD,4DAsBC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,kBAAkB,CACtC,EAAoB,EACpB,UAAU,GAAG,CAAC,EACd,QAAQ,GAAG,IAAI,EACf,GAAG,GAAG,OAAO,CAAC,GAAG;IAEjB,IAAI;QACF,OAAO,MAAM,wBAAwB,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;KACtE;IAAC,OAAO,CAAC,EAAE;QACV,GAAG,CAAC,gEAAgE,IAAA,qBAAa,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxF,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAZD,gDAYC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { optionalDateSchema } from "./common/date";
2
2
  export { emptyFunction } from "./common/general";
3
3
  export { normalizeOid } from "./common/normalize-oid";
4
- export { executeWithRetries } from "./common/retry";
4
+ export { executeWithRetries, executeWithRetriesOrFail } from "./common/retry";
5
5
  export { sleep } from "./common/sleep";
6
6
  export { validateNPI } from "./common/validate-npi";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateNPI = exports.sleep = exports.executeWithRetries = exports.normalizeOid = exports.emptyFunction = exports.optionalDateSchema = void 0;
3
+ exports.validateNPI = exports.sleep = exports.executeWithRetriesOrFail = exports.executeWithRetries = exports.normalizeOid = exports.emptyFunction = exports.optionalDateSchema = void 0;
4
4
  var date_1 = require("./common/date");
5
5
  Object.defineProperty(exports, "optionalDateSchema", { enumerable: true, get: function () { return date_1.optionalDateSchema; } });
6
6
  var general_1 = require("./common/general");
@@ -9,6 +9,7 @@ var normalize_oid_1 = require("./common/normalize-oid");
9
9
  Object.defineProperty(exports, "normalizeOid", { enumerable: true, get: function () { return normalize_oid_1.normalizeOid; } });
10
10
  var retry_1 = require("./common/retry");
11
11
  Object.defineProperty(exports, "executeWithRetries", { enumerable: true, get: function () { return retry_1.executeWithRetries; } });
12
+ Object.defineProperty(exports, "executeWithRetriesOrFail", { enumerable: true, get: function () { return retry_1.executeWithRetriesOrFail; } });
12
13
  var sleep_1 = require("./common/sleep");
13
14
  Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return sleep_1.sleep; } });
14
15
  var validate_npi_1 = require("./common/validate-npi");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAA1C,0GAAA,kBAAkB,OAAA;AAC3B,4CAAiD;AAAxC,wGAAA,aAAa,OAAA;AACtB,wDAAsD;AAA7C,6GAAA,YAAY,OAAA;AACrB,wCAAoD;AAA3C,2GAAA,kBAAkB,OAAA;AAC3B,wCAAuC;AAA9B,8FAAA,KAAK,OAAA;AACd,sDAAoD;AAA3C,2GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAA1C,0GAAA,kBAAkB,OAAA;AAC3B,4CAAiD;AAAxC,wGAAA,aAAa,OAAA;AACtB,wDAAsD;AAA7C,6GAAA,YAAY,OAAA;AACrB,wCAA8E;AAArE,2GAAA,kBAAkB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AACrD,wCAAuC;AAA9B,8FAAA,KAAK,OAAA;AACd,sDAAoD;AAA3C,2GAAA,WAAW,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metriport/shared",
3
- "version": "0.1.5",
3
+ "version": "0.1.7-alpha.0",
4
4
  "description": "Common code shared across packages - by Metriport Inc.",
5
5
  "author": "Metriport Inc. <contact@metriport.com>",
6
6
  "homepage": "https://metriport.com/",
@@ -51,5 +51,5 @@
51
51
  "test": "jest --runInBand --detectOpenHandles --passWithNoTests",
52
52
  "test:e2e": "E2E=true jest --runInBand --detectOpenHandles --passWithNoTests"
53
53
  },
54
- "gitHead": "64411bc50344cdd7a760e7e9b479aeeee0aa3d00"
54
+ "gitHead": "016d7b58ff83d1851e388ce3a153f0cc6e2cb164"
55
55
  }
@@ -1,5 +0,0 @@
1
- import { z } from "zod";
2
- export declare const ISO_DATE = "YYYY-MM-DD";
3
- export declare function isValidISODate(date: string): boolean;
4
- export declare const optionalDateSchema: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | null | undefined, string | null | undefined>;
5
- //# sourceMappingURL=date.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/common/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAKD,eAAO,MAAM,kBAAkB,+GAImC,CAAC"}
@@ -1,20 +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.optionalDateSchema = exports.isValidISODate = exports.ISO_DATE = void 0;
7
- const zod_1 = require("zod");
8
- const dayjs_1 = __importDefault(require("dayjs"));
9
- exports.ISO_DATE = "YYYY-MM-DD";
10
- function isValidISODate(date) {
11
- return (0, dayjs_1.default)(date, exports.ISO_DATE, true).isValid();
12
- }
13
- exports.isValidISODate = isValidISODate;
14
- const isValidISODateOptional = (date) => date ? isValidISODate(date) : true;
15
- exports.optionalDateSchema = zod_1.z
16
- .string()
17
- .trim()
18
- .nullish()
19
- .refine(isValidISODateOptional, { message: "Invalid ISO date" });
20
- //# sourceMappingURL=date.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/common/date.ts"],"names":[],"mappings":";;;;;;AAAA,6BAAwB;AACxB,kDAA0B;AAEb,QAAA,QAAQ,GAAG,YAAY,CAAC;AAErC,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,IAAA,eAAK,EAAC,IAAI,EAAE,gBAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED,MAAM,sBAAsB,GAAG,CAAC,IAA+B,EAAW,EAAE,CAC1E,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAExB,QAAA,kBAAkB,GAAG,OAAC;KAChC,MAAM,EAAE;KACR,IAAI,EAAE;KACN,OAAO,EAAE;KACT,MAAM,CAAC,sBAAsB,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC"}