@webiny/validation 5.39.0-beta.0 → 5.39.0-beta.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/validation",
3
- "version": "5.39.0-beta.0",
3
+ "version": "5.39.0-beta.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,8 +24,8 @@
24
24
  "@babel/preset-env": "7.22.7",
25
25
  "@babel/preset-typescript": "7.22.5",
26
26
  "@types/lodash": "4.14.191",
27
- "@webiny/cli": "5.39.0-beta.0",
28
- "@webiny/project-utils": "5.39.0-beta.0",
27
+ "@webiny/cli": "5.39.0-beta.2",
28
+ "@webiny/project-utils": "5.39.0-beta.2",
29
29
  "jest": "29.5.0",
30
30
  "rimraf": "3.0.2",
31
31
  "ttypescript": "1.5.15",
@@ -39,5 +39,5 @@
39
39
  "build": "yarn webiny run build",
40
40
  "watch": "yarn webiny run watch"
41
41
  },
42
- "gitHead": "df94742fba6658ed3507e1e17ab53dc77bb66330"
42
+ "gitHead": "193039382160557448f23f43685f29136f58f87a"
43
43
  }
package/validation.js CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _isString = _interopRequireDefault(require("lodash/isString"));
10
9
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
11
10
  var _trim = _interopRequireDefault(require("lodash/trim"));
@@ -37,7 +36,6 @@ class Validation {
37
36
  */
38
37
 
39
38
  constructor() {
40
- (0, _defineProperty2.default)(this, "__validators", void 0);
41
39
  this.__validators = {};
42
40
  }
43
41
 
package/validation.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_isString","_interopRequireDefault","require","_isEmpty","_trim","_validationError","entries","validators","Object","invalidRules","createdValidators","async","sync","Validation","constructor","_defineProperty2","default","__validators","setValidator","name","callable","validatorName","getValidator","ValidationError","validate","value","options","isString","isEmpty","Error","parsedValidateProperty","__parseValidateProperty","params","validator","e","validationError","message","throw","validateSync","create","createSync","split","parsedValidators","forEach","v","trim","vName","shift","_default","exports"],"sources":["validation.ts"],"sourcesContent":["import isString from \"lodash/isString\";\nimport isEmpty from \"lodash/isEmpty\";\nimport trim from \"lodash/trim\";\nimport ValidationError from \"./validationError\";\nimport { ParsedValidators, ValidateOptions, Validator } from \"./types\";\n\nconst entries = (validators: ParsedValidators): Array<[string, Array<string>]> => {\n return Object.entries(validators);\n};\n\nconst invalidRules = \"Validators must be specified as a string (eg. required,minLength:10,email).\";\n\ninterface CreatedValidators {\n async: Record<string, Validator>;\n sync: Record<string, Validator>;\n}\nconst createdValidators: CreatedValidators = {\n async: {},\n sync: {}\n};\n\n/**\n * Main class of Validation library.\n * Exported as a singleton instance, it offers methods for sync/async data validation and overwriting or adding new validators.\n *\n * @class Validation\n * @example\n * import { validation } from '@webiny/validation';\n *\n * // `validation` is a preconfigured instance of Validation class.\n * // From here you can either add new validators or use it as-is.\n */\nclass Validation {\n /**\n * Contains a list of all set validators.\n * @private\n */\n __validators: {\n [key: string]: Validator;\n };\n\n constructor() {\n this.__validators = {};\n }\n\n /**\n * Add new validator.\n * @param name Validator name.\n * @param callable Validator function which throws a ValidationError if validation fails.\n * @returns {Validation}\n */\n setValidator(name: string, callable: Validator): this {\n this.__validators[name] = callable;\n this.__validators[name].validatorName = name;\n return this;\n }\n\n /**\n * Get validator function by name.\n * @param name Validator name.\n * @returns {Validator} A validator function.\n */\n getValidator(name: string): Validator {\n if (!this.__validators[name]) {\n throw new ValidationError(\"Validator `\" + name + \"` does not exist!\", name);\n }\n return this.__validators[name];\n }\n\n /**\n * Asynchronously validates value.\n * @param value Value to validate.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @param [options] Validation options.\n * @returns {Promise<boolean | ValidationError>}\n */\n async validate(\n value: any,\n validators: string,\n options: ValidateOptions = {}\n ): Promise<boolean | ValidationError> {\n if (isString(validators) && isEmpty(validators)) {\n return true;\n }\n\n if (!isString(validators)) {\n throw new Error(invalidRules);\n }\n\n const parsedValidateProperty = this.__parseValidateProperty(validators);\n\n for (const [name, params] of entries(parsedValidateProperty)) {\n const validator = this.getValidator(name);\n try {\n await validator(value, params);\n } catch (e) {\n const validationError = new ValidationError(e.message, name, value);\n if (options.throw === false) {\n return validationError;\n }\n throw validationError;\n }\n }\n return true;\n }\n\n /**\n * Synchronously validates value.\n * @param value Value to validate.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @param [options] Validation options.\n * @returns {Promise<boolean | ValidationError>}\n */\n validateSync(\n value: any,\n validators: string,\n options: ValidateOptions = {}\n ): boolean | ValidationError {\n if (isString(validators) && isEmpty(validators)) {\n return true;\n }\n\n if (!isString(validators)) {\n throw new Error(invalidRules);\n }\n\n const parsedValidateProperty = this.__parseValidateProperty(validators);\n\n for (const [name, params] of entries(parsedValidateProperty)) {\n const validator = this.getValidator(name);\n try {\n validator(value, params);\n } catch (e) {\n const validationError = new ValidationError(e.message, name, value);\n if (options.throw === false) {\n return validationError;\n }\n throw validationError;\n }\n }\n return true;\n }\n\n create(validators: string) {\n if (createdValidators.async[validators]) {\n return createdValidators.async[validators];\n }\n\n createdValidators.async[validators] = value => this.validate(value, validators);\n return createdValidators.async[validators];\n }\n\n createSync(validators: string) {\n if (createdValidators.sync[validators]) {\n return createdValidators.sync[validators];\n }\n\n createdValidators.sync[validators] = value => this.validateSync(value, validators);\n return createdValidators.sync[validators];\n }\n\n /**\n * Parses a string of validators with parameters.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @returns {ParsedValidators}\n * @private\n */\n __parseValidateProperty(validators: string): ParsedValidators {\n const validate: Array<string> = validators.split(\",\");\n\n const parsedValidators: ParsedValidators = {};\n validate.forEach((v: string) => {\n const params = trim(v).split(\":\");\n const vName = params.shift();\n if (!vName) {\n return;\n }\n parsedValidators[vName] = params;\n });\n return parsedValidators;\n }\n}\n\nexport default Validation;\n"],"mappings":";;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAGA,MAAMI,OAAO,GAAIC,UAA4B,IAAqC;EAC9E,OAAOC,MAAM,CAACF,OAAO,CAACC,UAAU,CAAC;AACrC,CAAC;AAED,MAAME,YAAY,GAAG,6EAA6E;AAMlG,MAAMC,iBAAoC,GAAG;EACzCC,KAAK,EAAE,CAAC,CAAC;EACTC,IAAI,EAAE,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,CAAC;EACb;AACJ;AACA;AACA;;EAKIC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACV,IAAI,CAACC,YAAY,GAAG,CAAC,CAAC;EAC1B;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACIC,YAAYA,CAACC,IAAY,EAAEC,QAAmB,EAAQ;IAClD,IAAI,CAACH,YAAY,CAACE,IAAI,CAAC,GAAGC,QAAQ;IAClC,IAAI,CAACH,YAAY,CAACE,IAAI,CAAC,CAACE,aAAa,GAAGF,IAAI;IAC5C,OAAO,IAAI;EACf;;EAEA;AACJ;AACA;AACA;AACA;EACIG,YAAYA,CAACH,IAAY,EAAa;IAClC,IAAI,CAAC,IAAI,CAACF,YAAY,CAACE,IAAI,CAAC,EAAE;MAC1B,MAAM,IAAII,wBAAe,CAAC,aAAa,GAAGJ,IAAI,GAAG,mBAAmB,EAAEA,IAAI,CAAC;IAC/E;IACA,OAAO,IAAI,CAACF,YAAY,CAACE,IAAI,CAAC;EAClC;;EAEA;AACJ;AACA;AACA;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B,uBAAuBA,CAACxB,UAAkB,EAAoB;IAC1D,MAAMiB,QAAuB,GAAGjB,UAAU,CAACkC,KAAK,CAAC,GAAG,CAAC;IAErD,MAAMC,gBAAkC,GAAG,CAAC,CAAC;IAC7ClB,QAAQ,CAACmB,OAAO,CAAEC,CAAS,IAAK;MAC5B,MAAMZ,MAAM,GAAG,IAAAa,aAAI,EAACD,CAAC,CAAC,CAACH,KAAK,CAAC,GAAG,CAAC;MACjC,MAAMK,KAAK,GAAGd,MAAM,CAACe,KAAK,CAAC,CAAC;MAC5B,IAAI,CAACD,KAAK,EAAE;QACR;MACJ;MACAJ,gBAAgB,CAACI,KAAK,CAAC,GAAGd,MAAM;IACpC,CAAC,CAAC;IACF,OAAOU,gBAAgB;EAC3B;AACJ;AAAC,IAAAM,QAAA,GAEcnC,UAAU;AAAAoC,OAAA,CAAAjC,OAAA,GAAAgC,QAAA"}
1
+ {"version":3,"names":["_isString","_interopRequireDefault","require","_isEmpty","_trim","_validationError","entries","validators","Object","invalidRules","createdValidators","async","sync","Validation","constructor","__validators","setValidator","name","callable","validatorName","getValidator","ValidationError","validate","value","options","isString","isEmpty","Error","parsedValidateProperty","__parseValidateProperty","params","validator","e","validationError","message","throw","validateSync","create","createSync","split","parsedValidators","forEach","v","trim","vName","shift","_default","exports","default"],"sources":["validation.ts"],"sourcesContent":["import isString from \"lodash/isString\";\nimport isEmpty from \"lodash/isEmpty\";\nimport trim from \"lodash/trim\";\nimport ValidationError from \"./validationError\";\nimport { ParsedValidators, ValidateOptions, Validator } from \"./types\";\n\nconst entries = (validators: ParsedValidators): Array<[string, Array<string>]> => {\n return Object.entries(validators);\n};\n\nconst invalidRules = \"Validators must be specified as a string (eg. required,minLength:10,email).\";\n\ninterface CreatedValidators {\n async: Record<string, Validator>;\n sync: Record<string, Validator>;\n}\nconst createdValidators: CreatedValidators = {\n async: {},\n sync: {}\n};\n\n/**\n * Main class of Validation library.\n * Exported as a singleton instance, it offers methods for sync/async data validation and overwriting or adding new validators.\n *\n * @class Validation\n * @example\n * import { validation } from '@webiny/validation';\n *\n * // `validation` is a preconfigured instance of Validation class.\n * // From here you can either add new validators or use it as-is.\n */\nclass Validation {\n /**\n * Contains a list of all set validators.\n * @private\n */\n __validators: {\n [key: string]: Validator;\n };\n\n constructor() {\n this.__validators = {};\n }\n\n /**\n * Add new validator.\n * @param name Validator name.\n * @param callable Validator function which throws a ValidationError if validation fails.\n * @returns {Validation}\n */\n setValidator(name: string, callable: Validator): this {\n this.__validators[name] = callable;\n this.__validators[name].validatorName = name;\n return this;\n }\n\n /**\n * Get validator function by name.\n * @param name Validator name.\n * @returns {Validator} A validator function.\n */\n getValidator(name: string): Validator {\n if (!this.__validators[name]) {\n throw new ValidationError(\"Validator `\" + name + \"` does not exist!\", name);\n }\n return this.__validators[name];\n }\n\n /**\n * Asynchronously validates value.\n * @param value Value to validate.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @param [options] Validation options.\n * @returns {Promise<boolean | ValidationError>}\n */\n async validate(\n value: any,\n validators: string,\n options: ValidateOptions = {}\n ): Promise<boolean | ValidationError> {\n if (isString(validators) && isEmpty(validators)) {\n return true;\n }\n\n if (!isString(validators)) {\n throw new Error(invalidRules);\n }\n\n const parsedValidateProperty = this.__parseValidateProperty(validators);\n\n for (const [name, params] of entries(parsedValidateProperty)) {\n const validator = this.getValidator(name);\n try {\n await validator(value, params);\n } catch (e) {\n const validationError = new ValidationError(e.message, name, value);\n if (options.throw === false) {\n return validationError;\n }\n throw validationError;\n }\n }\n return true;\n }\n\n /**\n * Synchronously validates value.\n * @param value Value to validate.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @param [options] Validation options.\n * @returns {Promise<boolean | ValidationError>}\n */\n validateSync(\n value: any,\n validators: string,\n options: ValidateOptions = {}\n ): boolean | ValidationError {\n if (isString(validators) && isEmpty(validators)) {\n return true;\n }\n\n if (!isString(validators)) {\n throw new Error(invalidRules);\n }\n\n const parsedValidateProperty = this.__parseValidateProperty(validators);\n\n for (const [name, params] of entries(parsedValidateProperty)) {\n const validator = this.getValidator(name);\n try {\n validator(value, params);\n } catch (e) {\n const validationError = new ValidationError(e.message, name, value);\n if (options.throw === false) {\n return validationError;\n }\n throw validationError;\n }\n }\n return true;\n }\n\n create(validators: string) {\n if (createdValidators.async[validators]) {\n return createdValidators.async[validators];\n }\n\n createdValidators.async[validators] = value => this.validate(value, validators);\n return createdValidators.async[validators];\n }\n\n createSync(validators: string) {\n if (createdValidators.sync[validators]) {\n return createdValidators.sync[validators];\n }\n\n createdValidators.sync[validators] = value => this.validateSync(value, validators);\n return createdValidators.sync[validators];\n }\n\n /**\n * Parses a string of validators with parameters.\n * @param validators A list of comma-separated validators (eg. required,number,gt:20).\n * @returns {ParsedValidators}\n * @private\n */\n __parseValidateProperty(validators: string): ParsedValidators {\n const validate: Array<string> = validators.split(\",\");\n\n const parsedValidators: ParsedValidators = {};\n validate.forEach((v: string) => {\n const params = trim(v).split(\":\");\n const vName = params.shift();\n if (!vName) {\n return;\n }\n parsedValidators[vName] = params;\n });\n return parsedValidators;\n }\n}\n\nexport default Validation;\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAGA,MAAMI,OAAO,GAAIC,UAA4B,IAAqC;EAC9E,OAAOC,MAAM,CAACF,OAAO,CAACC,UAAU,CAAC;AACrC,CAAC;AAED,MAAME,YAAY,GAAG,6EAA6E;AAMlG,MAAMC,iBAAoC,GAAG;EACzCC,KAAK,EAAE,CAAC,CAAC;EACTC,IAAI,EAAE,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,CAAC;EACb;AACJ;AACA;AACA;;EAKIC,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
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  /**
10
8
  * This class is used by validators to throw an error when value validation fails.
11
9
  */
12
10
  class ValidationError extends Error {
13
11
  constructor(message = "", validator = null, value = null) {
14
12
  super();
15
- (0, _defineProperty2.default)(this, "message", void 0);
16
- (0, _defineProperty2.default)(this, "validator", void 0);
17
- (0, _defineProperty2.default)(this, "value", void 0);
18
13
  this.message = message;
19
14
  this.validator = validator;
20
15
  this.value = value;
@@ -1 +1 @@
1
- {"version":3,"names":["ValidationError","Error","constructor","message","validator","value","_defineProperty2","default","_default","exports"],"sources":["validationError.ts"],"sourcesContent":["/**\n * This class is used by validators to throw an error when value validation fails.\n */\nclass ValidationError extends Error {\n public override readonly message: string;\n public readonly validator: string | null;\n public readonly value: any;\n\n constructor(message = \"\", validator: string | null = null, value: string | null = null) {\n super();\n this.message = message;\n this.validator = validator;\n this.value = value;\n }\n}\n\nexport default ValidationError;\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA,MAAMA,eAAe,SAASC,KAAK,CAAC;EAKhCC,WAAWA,CAACC,OAAO,GAAG,EAAE,EAAEC,SAAwB,GAAG,IAAI,EAAEC,KAAoB,GAAG,IAAI,EAAE;IACpF,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACJ,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;EACtB;AACJ;AAAC,IAAAG,QAAA,GAEcR,eAAe;AAAAS,OAAA,CAAAF,OAAA,GAAAC,QAAA"}
1
+ {"version":3,"names":["ValidationError","Error","constructor","message","validator","value","_default","exports","default"],"sources":["validationError.ts"],"sourcesContent":["/**\n * This class is used by validators to throw an error when value validation fails.\n */\nclass ValidationError extends Error {\n public override readonly message: string;\n public readonly validator: string | null;\n public readonly value: any;\n\n constructor(message = \"\", validator: string | null = null, value: string | null = null) {\n super();\n this.message = message;\n this.validator = validator;\n this.value = value;\n }\n}\n\nexport default ValidationError;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA,MAAMA,eAAe,SAASC,KAAK,CAAC;EAKhCC,WAAWA,CAACC,OAAO,GAAG,EAAE,EAAEC,SAAwB,GAAG,IAAI,EAAEC,KAAoB,GAAG,IAAI,EAAE;IACpF,KAAK,CAAC,CAAC;IACP,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;EACtB;AACJ;AAAC,IAAAC,QAAA,GAEcN,eAAe;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -10,7 +10,7 @@ var _isnumeric = _interopRequireDefault(require("isnumeric"));
10
10
  /**
11
11
  * Package isnumeric does not have types so we ignore it.
12
12
  */
13
- // @ts-ignore
13
+ // @ts-expect-error
14
14
  /**
15
15
  * @function number
16
16
  * @description This validator checks if the given value is numeric
@@ -1 +1 @@
1
- {"version":3,"names":["_validationError","_interopRequireDefault","require","_isnumeric","_default","value","isNaN","isNumeric","ValidationError","exports","default"],"sources":["numeric.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n/**\n * Package isnumeric does not have types so we ignore it.\n */\n// @ts-ignore\nimport isNumeric from \"isnumeric\";\n\n/**\n * @function number\n * @description This validator checks if the given value is numeric\n * @param {any} value\n * @return {boolean}\n */\nexport default (value: any) => {\n // Eliminate edge cases\n if (typeof value === \"undefined\" || value === 0 || value === \"0\") {\n return;\n }\n\n if (!value && !isNaN(value)) {\n return;\n }\n\n if (isNumeric(value)) {\n return;\n }\n\n throw new ValidationError(\"Value needs to be numeric.\");\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAE,QAAA,GAMgBC,KAAU,IAAK;EAC3B;EACA,IAAI,OAAOA,KAAK,KAAK,WAAW,IAAIA,KAAK,KAAK,CAAC,IAAIA,KAAK,KAAK,GAAG,EAAE;IAC9D;EACJ;EAEA,IAAI,CAACA,KAAK,IAAI,CAACC,KAAK,CAACD,KAAK,CAAC,EAAE;IACzB;EACJ;EAEA,IAAI,IAAAE,kBAAS,EAACF,KAAK,CAAC,EAAE;IAClB;EACJ;EAEA,MAAM,IAAIG,wBAAe,CAAC,4BAA4B,CAAC;AAC3D,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAN,QAAA"}
1
+ {"version":3,"names":["_validationError","_interopRequireDefault","require","_isnumeric","_default","value","isNaN","isNumeric","ValidationError","exports","default"],"sources":["numeric.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n/**\n * Package isnumeric does not have types so we ignore it.\n */\n// @ts-expect-error\nimport isNumeric from \"isnumeric\";\n\n/**\n * @function number\n * @description This validator checks if the given value is numeric\n * @param {any} value\n * @return {boolean}\n */\nexport default (value: any) => {\n // Eliminate edge cases\n if (typeof value === \"undefined\" || value === 0 || value === \"0\") {\n return;\n }\n\n if (!value && !isNaN(value)) {\n return;\n }\n\n if (isNumeric(value)) {\n return;\n }\n\n throw new ValidationError(\"Value needs to be numeric.\");\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAE,QAAA,GAMgBC,KAAU,IAAK;EAC3B;EACA,IAAI,OAAOA,KAAK,KAAK,WAAW,IAAIA,KAAK,KAAK,CAAC,IAAIA,KAAK,KAAK,GAAG,EAAE;IAC9D;EACJ;EAEA,IAAI,CAACA,KAAK,IAAI,CAACC,KAAK,CAACD,KAAK,CAAC,EAAE;IACzB;EACJ;EAEA,IAAI,IAAAE,kBAAS,EAACF,KAAK,CAAC,EAAE;IAClB;EACJ;EAEA,MAAM,IAAIG,wBAAe,CAAC,4BAA4B,CAAC;AAC3D,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAN,QAAA"}