@abaplint/transpiler-cli 2.13.47 → 2.13.49

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 (2) hide show
  1. package/build/bundle.js +1016 -245
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -214,6 +214,23 @@ exports.FileOperations = FileOperations;
214
214
 
215
215
  /***/ },
216
216
 
217
+ /***/ "./build/git_clone.js"
218
+ /*!****************************!*\
219
+ !*** ./build/git_clone.js ***!
220
+ \****************************/
221
+ (__unused_webpack_module, exports) {
222
+
223
+ "use strict";
224
+
225
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
226
+ exports.buildGitCloneArguments = buildGitCloneArguments;
227
+ function buildGitCloneArguments(url) {
228
+ return ["clone", "--quiet", "--depth", "1", "--", url, "."];
229
+ }
230
+ //# sourceMappingURL=git_clone.js.map
231
+
232
+ /***/ },
233
+
217
234
  /***/ "./build/index.js"
218
235
  /*!************************!*\
219
236
  !*** ./build/index.js ***!
@@ -270,6 +287,7 @@ const Transpiler = __importStar(__webpack_require__(/*! @abaplint/transpiler */
270
287
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
271
288
  const config_1 = __webpack_require__(/*! ./config */ "./build/config.js");
272
289
  const file_operations_1 = __webpack_require__(/*! ./file_operations */ "./build/file_operations.js");
290
+ const git_clone_1 = __webpack_require__(/*! ./git_clone */ "./build/git_clone.js");
273
291
  class Progress {
274
292
  bar;
275
293
  set(total, _text) {
@@ -290,9 +308,13 @@ async function loadLib(config) {
290
308
  dir = process.cwd() + lib.folder;
291
309
  }
292
310
  else {
311
+ if (lib.url === undefined || lib.url === "") {
312
+ throw new Error("Library must define a non-empty url or an existing folder");
313
+ }
293
314
  console.log("Clone: " + lib.url);
294
315
  dir = fs.mkdtempSync(path.join(os.tmpdir(), "abap_transpile-"));
295
- childProcess.execSync("git clone --quiet --depth 1 " + lib.url + " .", { cwd: dir, stdio: "inherit" });
316
+ const args = (0, git_clone_1.buildGitCloneArguments)(lib.url);
317
+ childProcess.execFileSync("git", args, { cwd: dir, stdio: "inherit" });
296
318
  cleanupFolder = true;
297
319
  }
298
320
  let patterns = ["/src/**"];
@@ -4244,7 +4266,7 @@ class Compare extends combi_1.Expression {
4244
4266
  const inn = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "IN", (0, combi_1.altPrio)(_1.Source, list));
4245
4267
  const sopt = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Release.v750, (0, combi_1.seq)("INSTANCE OF", _1.ClassName), { also: combi_1.AlsoIn.OpenABAP }), "REQUESTED", "INITIAL"));
4246
4268
  const between = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "BETWEEN", _1.Source, "AND", _1.Source);
4247
- // https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abennews-740_sp08-expressions.htm
4269
+ // https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abennews-740_sp08-expressions.html
4248
4270
  // but also seems to work in v740sp05, blah
4249
4271
  const predicate = (0, combi_1.ver)(version_1.Release.v740sp08, _1.MethodCallChain, { also: combi_1.AlsoIn.OpenABAP });
4250
4272
  const rett = (0, combi_1.seq)(_1.Source, (0, combi_1.altPrio)((0, combi_1.seq)(_1.CompareOperator, _1.Source), inn, between, sopt));
@@ -5192,7 +5214,7 @@ class FieldChain extends combi_1.Expression {
5192
5214
  getRunnable() {
5193
5215
  const attr = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.InstanceArrow), _1.AttributeName);
5194
5216
  const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), (0, combi_1.optPrio)(_1.ComponentName));
5195
- const chain = (0, combi_1.star)((0, combi_1.altPrio)(_1.Dereference, (0, _dynamic_access_1.dynAttr)(), attr, (0, _dynamic_access_1.dynComp)((0, combi_1.optPrio)(_1.FieldOffset), (0, combi_1.optPrio)(_1.FieldLength)), comp, _1.TableExpression));
5217
+ const chain = (0, combi_1.star)((0, combi_1.altPrio)(_1.Dereference, (0, _dynamic_access_1.dynAttr)(), attr, (0, _dynamic_access_1.dynComp)((0, combi_1.optPrio)(_1.FieldOffset), (0, combi_1.optPrio)(_1.FieldLength)), comp, (0, combi_1.tok)(tokens_1.AssociationName), _1.TableExpression));
5196
5218
  const clas = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow), _1.AttributeName);
5197
5219
  const start = (0, combi_1.altPrio)(clas, _1.SourceField, _1.SourceFieldSymbol);
5198
5220
  const after = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.DashW), (0, combi_1.seq)((0, combi_1.optPrio)(_1.TableBody), (0, combi_1.optPrio)(_1.FieldOffset), (0, combi_1.optPrio)(_1.FieldLength)));
@@ -5396,7 +5418,7 @@ class For extends combi_1.Expression {
5396
5418
  const itera = (0, combi_1.seq)(_1.InlineFieldDefinition, (0, combi_1.opt)(then), whil);
5397
5419
  const groupBy = (0, combi_1.seq)("GROUP BY", (0, combi_1.alt)(field_chain_1.FieldChain, (0, combi_1.seq)("(", (0, combi_1.plus)(_1.LoopGroupByComponent), ")")), (0, combi_1.opt)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.opt)("AS TEXT"))), (0, combi_1.opt)("WITHOUT MEMBERS"));
5398
5420
  const t = (0, combi_1.alt)(_1.TargetField, _1.TargetFieldSymbol);
5399
- const groups = (0, combi_1.ver)(version_1.Release.v740sp08, (0, combi_1.seq)("GROUPS", t, "OF", t, "IN", _1.Source, (0, combi_1.optPrio)(groupBy)));
5421
+ const groups = (0, combi_1.ver)(version_1.Release.v740sp08, (0, combi_1.seq)("GROUPS", t, "OF", t, "IN", _1.Source, (0, combi_1.optPrio)(groupBy)), { also: combi_1.AlsoIn.OpenABAP });
5400
5422
  const f = (0, combi_1.seq)("FOR", (0, combi_1.alt)(itera, inn, groups), (0, combi_1.optPrio)(_1.Let));
5401
5423
  return (0, combi_1.ver)(version_1.Release.v740sp05, f, { also: combi_1.AlsoIn.OpenABAP });
5402
5424
  }
@@ -6079,7 +6101,8 @@ const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/co
6079
6101
  const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
6080
6102
  class InlineFieldDefinition extends combi_1.Expression {
6081
6103
  getRunnable() {
6082
- return (0, combi_1.altPrio)((0, combi_1.seq)(_1.Field, "=", _1.Source), (0, combi_1.seq)(_1.Field, "TYPE", _1.TypeName));
6104
+ const field = (0, combi_1.altPrio)(_1.Field, _1.FieldSymbol);
6105
+ return (0, combi_1.altPrio)((0, combi_1.seq)(field, "=", _1.Source), (0, combi_1.seq)(_1.Field, "TYPE", _1.TypeName));
6083
6106
  }
6084
6107
  }
6085
6108
  exports.InlineFieldDefinition = InlineFieldDefinition;
@@ -7441,10 +7464,10 @@ exports.PerformTables = PerformTables;
7441
7464
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7442
7465
  exports.PerformUsing = void 0;
7443
7466
  const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
7444
- const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/source.js");
7467
+ const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/simple_source3.js");
7445
7468
  class PerformUsing extends combi_1.Expression {
7446
7469
  getRunnable() {
7447
- const using = (0, combi_1.seq)("USING", (0, combi_1.plus)(source_1.Source));
7470
+ const using = (0, combi_1.seq)("USING", (0, combi_1.plus)(simple_source3_1.SimpleSource3));
7448
7471
  return using;
7449
7472
  }
7450
7473
  }
@@ -7633,7 +7656,7 @@ const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules
7633
7656
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
7634
7657
  class ReduceNext extends combi_1.Expression {
7635
7658
  getRunnable() {
7636
- const calcAssign = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WPlus), "="), (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WDash), "="), "/=", "*=", "&&="));
7659
+ const calcAssign = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WPlus), "="), (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WDash), "="), "/=", "*=", "&&="), { also: combi_1.AlsoIn.OpenABAP });
7637
7660
  const fields = (0, combi_1.seq)(_1.SimpleTarget, (0, combi_1.altPrio)("=", calcAssign), _1.Source);
7638
7661
  return (0, combi_1.seq)("NEXT", (0, combi_1.plus)(fields));
7639
7662
  }
@@ -10770,7 +10793,7 @@ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@a
10770
10793
  const dynamic_1 = __webpack_require__(/*! ./dynamic */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/dynamic.js");
10771
10794
  class StringTemplateFormatting extends combi_1.Expression {
10772
10795
  getRunnable() {
10773
- // https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapcompute_string_format_options.htm
10796
+ // https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapcompute_string_format_options.html
10774
10797
  const alphaOptions = (0, combi_1.altPrio)("OUT", "RAW", "IN", _1.Source);
10775
10798
  const alignOptions = (0, combi_1.altPrio)("LEFT", "RIGHT", "CENTER", _1.Source, dynamic_1.Dynamic);
10776
10799
  const dateTimeOptions = (0, combi_1.altPrio)("RAW", "ISO", "USER", "ENVIRONMENT", _1.Source, dynamic_1.Dynamic);
@@ -10911,7 +10934,7 @@ class TableExpression extends combi_1.Expression {
10911
10934
  const fields = (0, combi_1.plus)((0, combi_1.seq)((0, combi_1.altPrio)(_1.ComponentChainSimple, _1.Dynamic), "=", _1.Source));
10912
10935
  const key = (0, combi_1.seq)("KEY", _1.SimpleName);
10913
10936
  const index = (0, combi_1.seq)("INDEX", _1.Source);
10914
- const ret = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.BracketLeftW), (0, combi_1.alt)(_1.Source, (0, combi_1.seq)((0, combi_1.optPrio)(key), (0, combi_1.opt)("COMPONENTS"), (0, combi_1.altPrio)(fields, index))), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WBracketRight), (0, combi_1.tok)(tokens_1.WBracketRightW)));
10937
+ const ret = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.BracketLeftW), (0, combi_1.alt)((0, combi_1.seq)(_1.Source, fields), _1.Source, (0, combi_1.seq)((0, combi_1.optPrio)(key), (0, combi_1.opt)("COMPONENTS"), (0, combi_1.altPrio)(fields, index))), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WBracketRight), (0, combi_1.tok)(tokens_1.WBracketRightW)));
10915
10938
  return (0, combi_1.ver)(version_1.Release.v740sp02, ret, { also: combi_1.AlsoIn.OpenABAP });
10916
10939
  }
10917
10940
  }
@@ -18179,7 +18202,8 @@ class ReadEntities {
18179
18202
  const result = (0, combi_1.seq)("RESULT", expressions_1.Target);
18180
18203
  const failed = (0, combi_1.seq)("FAILED", expressions_1.Target);
18181
18204
  const reported = (0, combi_1.seq)("REPORTED", expressions_1.Target);
18182
- const foo = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.seq)("BY", expressions_1.EMLEntityPath)), (0, combi_1.alt)(fields, from, all), (0, combi_1.optPrio)(result));
18205
+ const execute = (0, combi_1.seq)("EXECUTE", expressions_1.SimpleName, from);
18206
+ const foo = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.seq)("BY", expressions_1.EMLEntityPath)), (0, combi_1.alt)(fields, from, all, execute), (0, combi_1.optPrio)(result));
18183
18207
  const entity = (0, combi_1.seq)("ENTITY", expressions_1.NamespaceSimpleName, (0, combi_1.plus)(foo));
18184
18208
  const s = (0, combi_1.seq)("ENTITIES OF", expressions_1.NamespaceSimpleName, (0, combi_1.opt)("IN LOCAL MODE"), (0, combi_1.plus)(entity), (0, combi_1.optPrio)((0, combi_1.seq)("LINK", expressions_1.Target)), (0, combi_1.optPrio)((0, combi_1.per)(failed, reported)));
18185
18209
  const byall = (0, combi_1.seq)("BY", expressions_1.EMLEntityPath, all);
@@ -18603,7 +18627,7 @@ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@a
18603
18627
  class RollbackEntities {
18604
18628
  getMatcher() {
18605
18629
  const s = "ROLLBACK ENTITIES";
18606
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.ver)(version_1.Release.v754, s));
18630
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.ver)(version_1.Release.v754, s, { also: combi_1.AlsoIn.OpenABAP }));
18607
18631
  }
18608
18632
  }
18609
18633
  exports.RollbackEntities = RollbackEntities;
@@ -24970,7 +24994,8 @@ class ABAPFileInformationParser {
24970
24994
  return ret;
24971
24995
  }
24972
24996
  parseConstants(node, visibility) {
24973
- var _a, _b;
24997
+ var _a;
24998
+ var _b;
24974
24999
  if (node === undefined) {
24975
25000
  return [];
24976
25001
  }
@@ -25523,7 +25548,7 @@ class BuiltIn {
25523
25548
  const sy = new _typed_identifier_1.TypedIdentifier(id1, BuiltIn.filename, type, ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */]);
25524
25549
  const id2 = new tokens_1.Identifier(new position_1.Position(this.row++, 1), "syst");
25525
25550
  const syst = new _typed_identifier_1.TypedIdentifier(id2, BuiltIn.filename, type, ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */]);
25526
- // https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abennews-610-system.htm
25551
+ // https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abennews-610-system.html
25527
25552
  const id3 = new tokens_1.Identifier(new position_1.Position(this.row++, 1), "sy-repid");
25528
25553
  const syrepid = new _typed_identifier_1.TypedIdentifier(id3, BuiltIn.filename, new basic_1.CharacterType(40, { qualifiedName: "sy-repid" }), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */]);
25529
25554
  const id4 = new tokens_1.Identifier(new position_1.Position(this.row++, 1), "syst-repid");
@@ -25825,7 +25850,7 @@ BuiltIn.methods = {
25825
25850
  counter: BuiltIn.counter++,
25826
25851
  mandatory: {
25827
25852
  "val": basic_1.CLikeType.get(),
25828
- "format": basic_1.CLikeType.get(),
25853
+ "format": basic_1.SimpleType.get(),
25829
25854
  },
25830
25855
  return: basic_1.StringType.get(),
25831
25856
  release: version_1.Release.v702,
@@ -26017,17 +26042,17 @@ BuiltIn.methods = {
26017
26042
  "NMAX": {
26018
26043
  counter: BuiltIn.counter++,
26019
26044
  mandatory: {
26020
- "val1": basic_1.CLikeType.get(),
26021
- "val2": basic_1.CLikeType.get(),
26045
+ "val1": basic_1.SimpleType.get(),
26046
+ "val2": basic_1.SimpleType.get(),
26022
26047
  },
26023
26048
  optional: {
26024
- "val3": basic_1.CLikeType.get(),
26025
- "val4": basic_1.CLikeType.get(),
26026
- "val5": basic_1.CLikeType.get(),
26027
- "val6": basic_1.CLikeType.get(),
26028
- "val7": basic_1.CLikeType.get(),
26029
- "val8": basic_1.CLikeType.get(),
26030
- "val9": basic_1.CLikeType.get(),
26049
+ "val3": basic_1.SimpleType.get(),
26050
+ "val4": basic_1.SimpleType.get(),
26051
+ "val5": basic_1.SimpleType.get(),
26052
+ "val6": basic_1.SimpleType.get(),
26053
+ "val7": basic_1.SimpleType.get(),
26054
+ "val8": basic_1.SimpleType.get(),
26055
+ "val9": basic_1.SimpleType.get(),
26031
26056
  },
26032
26057
  return: basic_1.IntegerType.get(),
26033
26058
  release: version_1.Release.v702,
@@ -26035,17 +26060,17 @@ BuiltIn.methods = {
26035
26060
  "NMIN": {
26036
26061
  counter: BuiltIn.counter++,
26037
26062
  mandatory: {
26038
- "val1": basic_1.CLikeType.get(),
26039
- "val2": basic_1.CLikeType.get(),
26063
+ "val1": basic_1.SimpleType.get(),
26064
+ "val2": basic_1.SimpleType.get(),
26040
26065
  },
26041
26066
  optional: {
26042
- "val3": basic_1.CLikeType.get(),
26043
- "val4": basic_1.CLikeType.get(),
26044
- "val5": basic_1.CLikeType.get(),
26045
- "val6": basic_1.CLikeType.get(),
26046
- "val7": basic_1.CLikeType.get(),
26047
- "val8": basic_1.CLikeType.get(),
26048
- "val9": basic_1.CLikeType.get(),
26067
+ "val3": basic_1.SimpleType.get(),
26068
+ "val4": basic_1.SimpleType.get(),
26069
+ "val5": basic_1.SimpleType.get(),
26070
+ "val6": basic_1.SimpleType.get(),
26071
+ "val7": basic_1.SimpleType.get(),
26072
+ "val8": basic_1.SimpleType.get(),
26073
+ "val9": basic_1.SimpleType.get(),
26049
26074
  },
26050
26075
  return: basic_1.IntegerType.get(),
26051
26076
  release: version_1.Release.v702,
@@ -26061,7 +26086,7 @@ BuiltIn.methods = {
26061
26086
  counter: BuiltIn.counter++,
26062
26087
  mandatory: {
26063
26088
  "val": basic_1.CLikeType.get(),
26064
- "occ": basic_1.CLikeType.get(),
26089
+ "occ": basic_1.SimpleType.get(),
26065
26090
  },
26066
26091
  return: basic_1.StringType.get(),
26067
26092
  release: version_1.Release.v702,
@@ -27779,6 +27804,21 @@ class TypeUtils {
27779
27804
  }
27780
27805
  return false;
27781
27806
  }
27807
+ isCharLikeField(type) {
27808
+ if (type instanceof basic_1.StructureType
27809
+ || (type instanceof basic_1.TableType && type.isWithHeader())) {
27810
+ return this.isCharLikeStrict(type);
27811
+ }
27812
+ return type instanceof basic_1.CharacterType
27813
+ || type instanceof basic_1.NumericType
27814
+ || type instanceof basic_1.DateType
27815
+ || type instanceof basic_1.TimeType
27816
+ || type instanceof cgeneric_type_1.CGenericType
27817
+ || type instanceof basic_1.CLikeType
27818
+ || type instanceof basic_1.AnyType
27819
+ || type instanceof basic_1.UnknownType
27820
+ || type instanceof basic_1.VoidType;
27821
+ }
27782
27822
  isCharLike(type) {
27783
27823
  if (type === undefined) {
27784
27824
  return false;
@@ -27815,6 +27855,7 @@ class TypeUtils {
27815
27855
  || type instanceof basic_1.DataType
27816
27856
  || type instanceof basic_1.CLikeType
27817
27857
  || type instanceof basic_1.PackedType
27858
+ || type instanceof basic_1.PGenericType
27818
27859
  || type instanceof basic_1.TimeType
27819
27860
  || type instanceof enum_type_1.EnumType) {
27820
27861
  return true;
@@ -28016,7 +28057,7 @@ class TypeUtils {
28016
28057
  return this.isAssignable(source, target);
28017
28058
  }
28018
28059
  isAssignableStrict(source, target, node) {
28019
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
28060
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
28020
28061
  const calculated = node ? this.isCalculated(node) : false;
28021
28062
  /*
28022
28063
  console.dir(source);
@@ -28027,30 +28068,52 @@ class TypeUtils {
28027
28068
  && (target instanceof basic_1.XStringType || target instanceof basic_1.XSequenceType)) {
28028
28069
  return false;
28029
28070
  }
28071
+ if (target instanceof basic_1.NumericType
28072
+ && (source instanceof basic_1.CharacterType || source instanceof basic_1.StringType)
28073
+ && ((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
28074
+ const constant = node === null || node === void 0 ? void 0 : node.concatTokens();
28075
+ if (constant !== undefined
28076
+ && ((constant.startsWith("'") && constant.endsWith("'"))
28077
+ || (constant.startsWith("`") && constant.endsWith("`")))
28078
+ && /^\d*$/.test(constant.substring(1, constant.length - 1)) === false) {
28079
+ return false;
28080
+ }
28081
+ }
28030
28082
  if (calculated) {
28031
28083
  return this.isAssignable(source, target);
28032
28084
  }
28085
+ if (target instanceof basic_1.CLikeType) {
28086
+ return this.isCharLikeStrict(source);
28087
+ }
28088
+ if (target instanceof basic_1.PGenericType) {
28089
+ return source instanceof basic_1.PackedType
28090
+ || source instanceof basic_1.PGenericType
28091
+ || source instanceof basic_1.VoidType
28092
+ || source instanceof basic_1.AnyType
28093
+ || source instanceof basic_1.DataType
28094
+ || source instanceof basic_1.UnknownType;
28095
+ }
28033
28096
  if (source instanceof basic_1.CharacterType) {
28034
28097
  if (target instanceof basic_1.CharacterType) {
28035
- if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
28098
+ if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
28036
28099
  return source.getLength() <= target.getLength();
28037
28100
  }
28038
28101
  return source.getLength() === target.getLength();
28039
28102
  }
28040
28103
  else if (target instanceof basic_1.IntegerType) {
28041
- if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
28104
+ if (((_c = source.getAbstractTypeData()) === null || _c === void 0 ? void 0 : _c.derivedFromConstant) === true) {
28042
28105
  return true;
28043
28106
  }
28044
28107
  return false;
28045
28108
  }
28046
28109
  else if (target instanceof basic_1.XStringType) {
28047
- if (((_c = source.getAbstractTypeData()) === null || _c === void 0 ? void 0 : _c.derivedFromConstant) === true) {
28110
+ if (((_d = source.getAbstractTypeData()) === null || _d === void 0 ? void 0 : _d.derivedFromConstant) === true) {
28048
28111
  return (node === null || node === void 0 ? void 0 : node.concatTokens()) !== "''";
28049
28112
  }
28050
28113
  return false;
28051
28114
  }
28052
28115
  else if (target instanceof basic_1.StringType) {
28053
- if (((_d = source.getAbstractTypeData()) === null || _d === void 0 ? void 0 : _d.derivedFromConstant) === true) {
28116
+ if (((_e = source.getAbstractTypeData()) === null || _e === void 0 ? void 0 : _e.derivedFromConstant) === true) {
28054
28117
  return true;
28055
28118
  }
28056
28119
  return false;
@@ -28058,7 +28121,7 @@ class TypeUtils {
28058
28121
  }
28059
28122
  else if (source instanceof basic_1.HexType) {
28060
28123
  if (target instanceof basic_1.HexType) {
28061
- if (((_e = source.getAbstractTypeData()) === null || _e === void 0 ? void 0 : _e.derivedFromConstant) === true) {
28124
+ if (((_f = source.getAbstractTypeData()) === null || _f === void 0 ? void 0 : _f.derivedFromConstant) === true) {
28062
28125
  return source.getLength() <= target.getLength();
28063
28126
  }
28064
28127
  return source.getLength() === target.getLength();
@@ -28067,7 +28130,7 @@ class TypeUtils {
28067
28130
  return false;
28068
28131
  }
28069
28132
  else if (target instanceof basic_1.IntegerType || target instanceof basic_1.Integer8Type) {
28070
- if (((_f = source.getAbstractTypeData()) === null || _f === void 0 ? void 0 : _f.derivedFromConstant) === true) {
28133
+ if (((_g = source.getAbstractTypeData()) === null || _g === void 0 ? void 0 : _g.derivedFromConstant) === true) {
28071
28134
  return true;
28072
28135
  }
28073
28136
  return false;
@@ -28078,13 +28141,13 @@ class TypeUtils {
28078
28141
  return false;
28079
28142
  }
28080
28143
  else if (target instanceof basic_1.CharacterType) {
28081
- if (((_g = source.getAbstractTypeData()) === null || _g === void 0 ? void 0 : _g.derivedFromConstant) === true) {
28144
+ if (((_h = source.getAbstractTypeData()) === null || _h === void 0 ? void 0 : _h.derivedFromConstant) === true) {
28082
28145
  return true;
28083
28146
  }
28084
28147
  return false;
28085
28148
  }
28086
28149
  else if (target instanceof basic_1.IntegerType) {
28087
- if (((_h = source.getAbstractTypeData()) === null || _h === void 0 ? void 0 : _h.derivedFromConstant) === true) {
28150
+ if (((_j = source.getAbstractTypeData()) === null || _j === void 0 ? void 0 : _j.derivedFromConstant) === true) {
28088
28151
  return true;
28089
28152
  }
28090
28153
  return false;
@@ -28094,7 +28157,7 @@ class TypeUtils {
28094
28157
  return false;
28095
28158
  }
28096
28159
  else if (target instanceof basic_1.XSequenceType || target instanceof basic_1.XStringType) {
28097
- if (((_j = source.getAbstractTypeData()) === null || _j === void 0 ? void 0 : _j.derivedFromConstant) === true) {
28160
+ if (((_k = source.getAbstractTypeData()) === null || _k === void 0 ? void 0 : _k.derivedFromConstant) === true) {
28098
28161
  return true;
28099
28162
  }
28100
28163
  return false;
@@ -28134,16 +28197,20 @@ class TypeUtils {
28134
28197
  }
28135
28198
  }
28136
28199
  else if (source instanceof basic_1.IntegerType) {
28137
- if (target instanceof basic_1.StringType) {
28200
+ if (target instanceof basic_1.StringType || target instanceof basic_1.DateType) {
28138
28201
  return false;
28139
28202
  }
28140
28203
  else if (target instanceof basic_1.Integer8Type || target instanceof basic_1.PackedType) {
28141
- if (((_k = source.getAbstractTypeData()) === null || _k === void 0 ? void 0 : _k.derivedFromConstant) === true) {
28204
+ if (((_l = source.getAbstractTypeData()) === null || _l === void 0 ? void 0 : _l.derivedFromConstant) === true) {
28142
28205
  return true;
28143
28206
  }
28144
28207
  return false;
28145
28208
  }
28146
28209
  }
28210
+ else if (source instanceof basic_1.PackedType && target instanceof basic_1.PackedType) {
28211
+ return source.getLength() === target.getLength()
28212
+ && source.getDecimals() === target.getDecimals();
28213
+ }
28147
28214
  else if (source instanceof basic_1.FloatType) {
28148
28215
  if (target instanceof basic_1.IntegerType) {
28149
28216
  return false;
@@ -29418,7 +29485,7 @@ class BasicTypes {
29418
29485
  }
29419
29486
  }
29420
29487
  if (val === undefined) {
29421
- return 1;
29488
+ return undefined;
29422
29489
  }
29423
29490
  const intExpr = val.findFirstExpression(Expressions.Integer);
29424
29491
  if (intExpr) {
@@ -30057,18 +30124,30 @@ exports.ComponentCompare = void 0;
30057
30124
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
30058
30125
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
30059
30126
  const component_chain_1 = __webpack_require__(/*! ./component_chain */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_chain.js");
30127
+ const component_name_1 = __webpack_require__(/*! ./component_name */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_name.js");
30060
30128
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
30061
30129
  class ComponentCompare {
30062
- static runSyntax(node, input, type) {
30130
+ static runSyntax(node, input, leftType, rightType) {
30063
30131
  const chain = node.findDirectExpression(Expressions.ComponentChainSimple);
30064
30132
  if (chain === undefined) {
30065
30133
  const message = "ComponentCompare, chain not found";
30066
30134
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
30067
30135
  return;
30068
30136
  }
30069
- const fieldType = component_chain_1.ComponentChain.runSyntax(type, chain, input);
30137
+ const fieldType = component_chain_1.ComponentChain.runSyntax(leftType, chain, input);
30070
30138
  for (const s of node.findDirectExpressions(Expressions.Source)) {
30071
- source_1.Source.runSyntax(s, input, fieldType);
30139
+ const fieldChain = s.findDirectExpression(Expressions.FieldChain);
30140
+ const first = fieldChain === null || fieldChain === void 0 ? void 0 : fieldChain.getFirstChild();
30141
+ if (rightType && fieldChain && first) {
30142
+ let sourceType = rightType;
30143
+ if (first.concatTokens().toUpperCase() !== "TABLE_LINE") {
30144
+ sourceType = component_name_1.ComponentName.runSyntax(sourceType, first, input);
30145
+ }
30146
+ component_chain_1.ComponentChain.runSyntax(sourceType, fieldChain, input);
30147
+ }
30148
+ else {
30149
+ source_1.Source.runSyntax(s, input, fieldType);
30150
+ }
30072
30151
  }
30073
30152
  }
30074
30153
  }
@@ -30207,15 +30286,15 @@ exports.ComponentCond = void 0;
30207
30286
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
30208
30287
  const component_compare_1 = __webpack_require__(/*! ./component_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_compare.js");
30209
30288
  class ComponentCond {
30210
- static runSyntax(node, input, type) {
30289
+ static runSyntax(node, input, leftType, rightType) {
30211
30290
  for (const t of node.findDirectExpressions(Expressions.ComponentCondSub)) {
30212
30291
  const c = t.findDirectExpression(Expressions.ComponentCond);
30213
30292
  if (c) {
30214
- ComponentCond.runSyntax(c, input, type);
30293
+ ComponentCond.runSyntax(c, input, leftType, rightType);
30215
30294
  }
30216
30295
  }
30217
30296
  for (const t of node.findDirectExpressions(Expressions.ComponentCompare)) {
30218
- component_compare_1.ComponentCompare.runSyntax(t, input, type);
30297
+ component_compare_1.ComponentCompare.runSyntax(t, input, leftType, rightType);
30219
30298
  }
30220
30299
  }
30221
30300
  }
@@ -31433,21 +31512,14 @@ class FilterBody {
31433
31512
  if (node === undefined) {
31434
31513
  return targetType;
31435
31514
  }
31436
- let type = undefined;
31515
+ const types = [];
31437
31516
  for (const s of node.findDirectExpressions(Expressions.Source)) {
31438
- if (type === undefined) {
31439
- type = source_1.Source.runSyntax(s, input);
31440
- }
31441
- else {
31442
- source_1.Source.runSyntax(s, input);
31443
- }
31444
- }
31445
- // todo
31446
- if (node.findDirectTokenByText("EXCEPT") === undefined) {
31447
- const rowType = type instanceof basic_1.TableType ? type.getRowType() : undefined;
31448
- component_cond_1.ComponentCond.runSyntax(node.findDirectExpression(Expressions.ComponentCond), input, rowType);
31517
+ types.push(source_1.Source.runSyntax(s, input));
31449
31518
  }
31450
- return type ? type : targetType;
31519
+ const inputRowType = types[0] instanceof basic_1.TableType ? types[0].getRowType() : undefined;
31520
+ const filterRowType = types[1] instanceof basic_1.TableType ? types[1].getRowType() : undefined;
31521
+ component_cond_1.ComponentCond.runSyntax(node.findDirectExpression(Expressions.ComponentCond), input, inputRowType, filterRowType);
31522
+ return types[0] ? types[0] : targetType;
31451
31523
  }
31452
31524
  }
31453
31525
  exports.FilterBody = FilterBody;
@@ -31938,7 +32010,8 @@ class InlineFieldDefinition {
31938
32010
  static runSyntax(node, input, targetType) {
31939
32011
  var _a;
31940
32012
  let type = undefined;
31941
- const field = (_a = node.findDirectExpression(Expressions.Field)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
32013
+ const field = (_a = (node.findDirectExpression(Expressions.Field)
32014
+ || node.findDirectExpression(Expressions.FieldSymbol))) === null || _a === void 0 ? void 0 : _a.getFirstToken();
31942
32015
  if (field === undefined) {
31943
32016
  return undefined;
31944
32017
  }
@@ -32928,6 +33001,9 @@ class MethodParam {
32928
33001
  else if (concat === "TYPE X" || concat.startsWith("TYPE X ")) {
32929
33002
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, basic_1.XGenericType.get(), meta);
32930
33003
  }
33004
+ else if (concat === "TYPE P" || concat.startsWith("TYPE P ")) {
33005
+ return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, basic_1.PGenericType.get(), meta);
33006
+ }
32931
33007
  const found = new basic_types_1.BasicTypes(input).parseType(type);
32932
33008
  if (found) {
32933
33009
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, found, meta);
@@ -35803,9 +35879,11 @@ class Target {
35803
35879
  else if (context instanceof basic_1.TableType && context.isWithHeader() && context.getRowType() instanceof unknown_type_1.UnknownType) {
35804
35880
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
35805
35881
  }
35882
+ else if (context instanceof basic_1.TableType && context.isWithHeader() && context.getRowType() instanceof basic_1.VoidType) {
35883
+ return context.getRowType();
35884
+ }
35806
35885
  else if (!(context instanceof basic_1.StructureType)
35807
35886
  && !(context instanceof basic_1.TableType && context.isWithHeader() && context.getRowType() instanceof basic_1.StructureType)
35808
- && !(context instanceof basic_1.TableType && context.isWithHeader() && context.getRowType() instanceof basic_1.VoidType)
35809
35887
  && !(context instanceof basic_1.VoidType)) {
35810
35888
  const message = "Not a structure, target, " + (context === null || context === void 0 ? void 0 : context.constructor.name) + ", " + current.concatTokens();
35811
35889
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -36205,7 +36283,11 @@ class ValueBody {
36205
36283
  field_assignment_1.FieldAssignment.runSyntax(s, input, rowType);
36206
36284
  }
36207
36285
  for (const s of foo.findDirectExpressions(Expressions.Source)) {
36208
- source_1.Source.runSyntax(s, input, rowType);
36286
+ const sourceType = source_1.Source.runSyntax(s, input, rowType);
36287
+ if (rowType instanceof basic_1.StringType && sourceType instanceof basic_1.CharacterType) {
36288
+ const message = "VALUE, source type CharacterType not compatible with StringType";
36289
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
36290
+ }
36209
36291
  }
36210
36292
  }
36211
36293
  if (letScoped === true) {
@@ -41918,9 +42000,13 @@ class InsertInternal {
41918
42000
  && node.findDirectTokenByText("LINES") === undefined) {
41919
42001
  targetType = targetType.getRowType();
41920
42002
  }
41921
- let source = node.findDirectExpression(Expressions.SimpleSource4);
41922
- if (source === undefined) {
41923
- source = node.findDirectExpression(Expressions.Source);
42003
+ const initial = node.findDirectTokenByText("INITIAL") !== undefined;
42004
+ let source;
42005
+ if (initial === false) {
42006
+ source = node.findDirectExpression(Expressions.SimpleSource4);
42007
+ if (source === undefined) {
42008
+ source = node.findDirectExpression(Expressions.Source);
42009
+ }
41924
42010
  }
41925
42011
  const sourceType = source ? source_1.Source.runSyntax(source, input, targetType) : targetType;
41926
42012
  if (targetType === undefined
@@ -41942,7 +42028,7 @@ class InsertInternal {
41942
42028
  fstarget_1.FSTarget.runSyntax(afterAssigning, input, sourceType);
41943
42029
  }
41944
42030
  }
41945
- if (node.findDirectTokenByText("INITIAL") === undefined) {
42031
+ if (initial === false) {
41946
42032
  let error = false;
41947
42033
  if (sourceType instanceof basic_1.IntegerType && targetType instanceof basic_1.Integer8Type) {
41948
42034
  error = true;
@@ -43025,6 +43111,7 @@ const inline_data_1 = __webpack_require__(/*! ../expressions/inline_data */ "./n
43025
43111
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
43026
43112
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
43027
43113
  const dereference_1 = __webpack_require__(/*! ../expressions/dereference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dereference.js");
43114
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
43028
43115
  class Move {
43029
43116
  runSyntax(node, input) {
43030
43117
  const targets = node.findDirectExpressions(Expressions.Target);
@@ -43060,6 +43147,9 @@ class Move {
43060
43147
  sourceType = dereference_1.Dereference.runSyntax(node, sourceType, input);
43061
43148
  }
43062
43149
  if (inline) {
43150
+ if (sourceType instanceof basic_1.PackedType && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.ArithOperator))) {
43151
+ sourceType = new basic_1.PackedType(8, 0);
43152
+ }
43063
43153
  inline_data_1.InlineData.runSyntax(inline, input, sourceType);
43064
43154
  targetType = sourceType;
43065
43155
  }
@@ -43560,7 +43650,7 @@ class Perform {
43560
43650
  }
43561
43651
  }
43562
43652
  for (const u of node.findDirectExpressions(Expressions.PerformUsing)) {
43563
- for (const s of u.findDirectExpressions(Expressions.Source)) {
43653
+ for (const s of u.findDirectExpressions(Expressions.SimpleSource3)) {
43564
43654
  source_1.Source.runSyntax(s, input);
43565
43655
  }
43566
43656
  }
@@ -43845,10 +43935,15 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
43845
43935
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
43846
43936
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
43847
43937
  const basic_types_1 = __webpack_require__(/*! ../basic_types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js");
43938
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
43848
43939
  const assert_error_1 = __webpack_require__(/*! ../assert_error */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/assert_error.js");
43849
43940
  class Ranges {
43850
43941
  runSyntax(node, input) {
43851
43942
  var _a;
43943
+ if (input.scope.isAnyOO()) {
43944
+ const message = "RANGES is not allowed within classes";
43945
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
43946
+ }
43852
43947
  const nameToken = (_a = node.findFirstExpression(Expressions.DefinitionName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
43853
43948
  const typeExpression = node.findFirstExpression(Expressions.SimpleFieldChain2);
43854
43949
  if (typeExpression === undefined) {
@@ -46327,7 +46422,7 @@ class Type {
46327
46422
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
46328
46423
  return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
46329
46424
  }
46330
- if (input.scope.isGlobalOO() && found.getType() instanceof basic_1.PackedType) {
46425
+ if (input.scope.isAnyOO() && found.getType() instanceof basic_1.PackedType) {
46331
46426
  const concat = node.concatTokens().toUpperCase();
46332
46427
  if ((concat.includes(" TYPE P ") || concat.includes(" TYPE P."))
46333
46428
  && concat.includes(" DECIMALS ") === false) {
@@ -47028,7 +47123,11 @@ class Write {
47028
47123
  }
47029
47124
  const target = node.findDirectExpression(Expressions.Target);
47030
47125
  if (target) {
47031
- target_1.Target.runSyntax(target, input);
47126
+ const targetType = target_1.Target.runSyntax(target, input);
47127
+ if (new _type_utils_1.TypeUtils(input.scope).isCharLikeField(targetType) === false) {
47128
+ const message = `"${target.concatTokens()}" must be a character-like field (data type C, N, D, or T, got "${targetType === null || targetType === void 0 ? void 0 : targetType.constructor.name}")`;
47129
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, target.getFirstToken(), message));
47130
+ }
47032
47131
  }
47033
47132
  }
47034
47133
  }
@@ -47082,6 +47181,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
47082
47181
  exports.ClassData = void 0;
47083
47182
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
47084
47183
  const Statements = __importStar(__webpack_require__(/*! ../../2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
47184
+ const Structures = __importStar(__webpack_require__(/*! ../../3_structures/structures */ "./node_modules/@abaplint/core/build/src/abap/3_structures/structures/index.js"));
47085
47185
  const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
47086
47186
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
47087
47187
  const Basic = __importStar(__webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js"));
@@ -47100,7 +47200,14 @@ class ClassData {
47100
47200
  values[found.getName()] = found.getValue();
47101
47201
  }
47102
47202
  }
47103
- // todo, nested structures and INCLUDES
47203
+ else if (c instanceof nodes_1.StructureNode && ctyp instanceof Structures.ClassData) {
47204
+ const found = new ClassData().runSyntax(c, input);
47205
+ if (found) {
47206
+ components.push({ name: found.getName(), type: found.getType() });
47207
+ values[found.getName()] = found.getValue();
47208
+ }
47209
+ }
47210
+ // todo, INCLUDES
47104
47211
  }
47105
47212
  return new _typed_identifier_1.TypedIdentifier(name, input.filename, new Basic.StructureType(components), ["static" /* IdentifierMeta.Static */], values);
47106
47213
  }
@@ -47630,6 +47737,117 @@ exports.TypeEnum = TypeEnum;
47630
47737
 
47631
47738
  /***/ },
47632
47739
 
47740
+ /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_mesh.js"
47741
+ /*!*************************************************************************************!*\
47742
+ !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_mesh.js ***!
47743
+ \*************************************************************************************/
47744
+ (__unused_webpack_module, exports, __webpack_require__) {
47745
+
47746
+ "use strict";
47747
+
47748
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
47749
+ if (k2 === undefined) k2 = k;
47750
+ var desc = Object.getOwnPropertyDescriptor(m, k);
47751
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
47752
+ desc = { enumerable: true, get: function() { return m[k]; } };
47753
+ }
47754
+ Object.defineProperty(o, k2, desc);
47755
+ }) : (function(o, m, k, k2) {
47756
+ if (k2 === undefined) k2 = k;
47757
+ o[k2] = m[k];
47758
+ }));
47759
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
47760
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
47761
+ }) : function(o, v) {
47762
+ o["default"] = v;
47763
+ });
47764
+ var __importStar = (this && this.__importStar) || (function () {
47765
+ var ownKeys = function(o) {
47766
+ ownKeys = Object.getOwnPropertyNames || function (o) {
47767
+ var ar = [];
47768
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47769
+ return ar;
47770
+ };
47771
+ return ownKeys(o);
47772
+ };
47773
+ return function (mod) {
47774
+ if (mod && mod.__esModule) return mod;
47775
+ var result = {};
47776
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47777
+ __setModuleDefault(result, mod);
47778
+ return result;
47779
+ };
47780
+ })();
47781
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
47782
+ exports.TypeMesh = void 0;
47783
+ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
47784
+ const Statements = __importStar(__webpack_require__(/*! ../../2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
47785
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
47786
+ const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
47787
+ const Basic = __importStar(__webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js"));
47788
+ const basic_types_1 = __webpack_require__(/*! ../basic_types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js");
47789
+ const type_1 = __webpack_require__(/*! ../statements/type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/type.js");
47790
+ const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
47791
+ class TypeMesh {
47792
+ runSyntax(node, input) {
47793
+ var _a;
47794
+ const begin = node.findDirectStatement(Statements.TypeMeshBegin);
47795
+ if (begin === undefined) {
47796
+ return undefined;
47797
+ }
47798
+ const name = (_a = begin.findFirstExpression(Expressions.NamespaceSimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
47799
+ if (name === undefined) {
47800
+ return undefined;
47801
+ }
47802
+ const components = [];
47803
+ for (const c of node.getChildren()) {
47804
+ if (!(c instanceof nodes_1.StatementNode)) {
47805
+ continue;
47806
+ }
47807
+ const ctyp = c.get();
47808
+ if (ctyp instanceof Statements.Type) {
47809
+ const found = new type_1.Type().runSyntax(c, input, name.getStr() + "-");
47810
+ if (found) {
47811
+ components.push({ name: found.getName(), type: found.getType() });
47812
+ }
47813
+ }
47814
+ else if (ctyp instanceof Statements.TypeMesh) {
47815
+ const found = this.runMeshNode(c, input);
47816
+ if (found) {
47817
+ components.push({ name: found.getName(), type: found.getType() });
47818
+ }
47819
+ }
47820
+ }
47821
+ let qualifiedName = name.getStr();
47822
+ if (input.scope.getType() === _scope_type_1.ScopeType.ClassDefinition
47823
+ || input.scope.getType() === _scope_type_1.ScopeType.Interface) {
47824
+ qualifiedName = input.scope.getName() + "=>" + qualifiedName;
47825
+ }
47826
+ return new _typed_identifier_1.TypedIdentifier(name, input.filename, new Basic.StructureType(components, qualifiedName));
47827
+ }
47828
+ ////////////////////
47829
+ runMeshNode(node, input) {
47830
+ var _a;
47831
+ const nameToken = (_a = node.findFirstExpression(Expressions.NamespaceSimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
47832
+ if (nameToken === undefined) {
47833
+ return undefined;
47834
+ }
47835
+ const typeName = node.findFirstExpression(Expressions.TypeName);
47836
+ let type = new basic_types_1.BasicTypes(input).resolveTypeName(typeName);
47837
+ if (type === undefined) {
47838
+ type = new Basic.UnknownType("Mesh node, unknown type " + (typeName === null || typeName === void 0 ? void 0 : typeName.concatTokens()));
47839
+ }
47840
+ else if (node.concatTokens().toUpperCase().includes(" TYPE REF TO ")) {
47841
+ type = new Basic.DataReference(type);
47842
+ }
47843
+ return new _typed_identifier_1.TypedIdentifier(nameToken, input.filename, type);
47844
+ }
47845
+ }
47846
+ exports.TypeMesh = TypeMesh;
47847
+ //# sourceMappingURL=type_mesh.js.map
47848
+
47849
+ /***/ },
47850
+
47633
47851
  /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/types.js"
47634
47852
  /*!*********************************************************************************!*\
47635
47853
  !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/types.js ***!
@@ -47791,6 +48009,7 @@ const objects_1 = __webpack_require__(/*! ../../objects */ "./node_modules/@abap
47791
48009
  const position_1 = __webpack_require__(/*! ../../position */ "./node_modules/@abaplint/core/build/src/position.js");
47792
48010
  const data_1 = __webpack_require__(/*! ./structures/data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/data.js");
47793
48011
  const type_enum_1 = __webpack_require__(/*! ./structures/type_enum */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_enum.js");
48012
+ const type_mesh_1 = __webpack_require__(/*! ./structures/type_mesh */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_mesh.js");
47794
48013
  const types_1 = __webpack_require__(/*! ./structures/types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/types.js");
47795
48014
  const statics_1 = __webpack_require__(/*! ./structures/statics */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/statics.js");
47796
48015
  const constants_1 = __webpack_require__(/*! ./structures/constants */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/constants.js");
@@ -48225,6 +48444,13 @@ class SyntaxLogic {
48225
48444
  this.scope.addIdentifier(new statics_1.Statics().runSyntax(node, input));
48226
48445
  return true;
48227
48446
  }
48447
+ else if (stru instanceof Structures.TypeMesh) {
48448
+ const found = new type_mesh_1.TypeMesh().runSyntax(node, input);
48449
+ if (found) {
48450
+ this.scope.addType(found);
48451
+ }
48452
+ return true;
48453
+ }
48228
48454
  else if (stru instanceof Structures.TypeEnum) {
48229
48455
  const values = new type_enum_1.TypeEnum().runSyntax(node, input).values;
48230
48456
  this.scope.addList(values);
@@ -50494,6 +50720,7 @@ __exportStar(__webpack_require__(/*! ./numeric_generic_type */ "./node_modules/@
50494
50720
  __exportStar(__webpack_require__(/*! ./numeric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/numeric_type.js"), exports);
50495
50721
  __exportStar(__webpack_require__(/*! ./object_reference_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/object_reference_type.js"), exports);
50496
50722
  __exportStar(__webpack_require__(/*! ./packed_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/packed_type.js"), exports);
50723
+ __exportStar(__webpack_require__(/*! ./pgeneric_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/pgeneric_type.js"), exports);
50497
50724
  __exportStar(__webpack_require__(/*! ./simple_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/simple_type.js"), exports);
50498
50725
  __exportStar(__webpack_require__(/*! ./string_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/string_type.js"), exports);
50499
50726
  __exportStar(__webpack_require__(/*! ./structure_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/structure_type.js"), exports);
@@ -50767,6 +50994,46 @@ exports.PackedType = PackedType;
50767
50994
 
50768
50995
  /***/ },
50769
50996
 
50997
+ /***/ "./node_modules/@abaplint/core/build/src/abap/types/basic/pgeneric_type.js"
50998
+ /*!*********************************************************************************!*\
50999
+ !*** ./node_modules/@abaplint/core/build/src/abap/types/basic/pgeneric_type.js ***!
51000
+ \*********************************************************************************/
51001
+ (__unused_webpack_module, exports, __webpack_require__) {
51002
+
51003
+ "use strict";
51004
+
51005
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
51006
+ exports.PGenericType = void 0;
51007
+ const _abstract_type_1 = __webpack_require__(/*! ./_abstract_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/_abstract_type.js");
51008
+ class PGenericType extends _abstract_type_1.AbstractType {
51009
+ static get() {
51010
+ return this.singleton;
51011
+ }
51012
+ constructor() {
51013
+ super();
51014
+ }
51015
+ toText() {
51016
+ return "```p```";
51017
+ }
51018
+ isGeneric() {
51019
+ return true;
51020
+ }
51021
+ toABAP() {
51022
+ throw new Error("p, generic");
51023
+ }
51024
+ containsVoid() {
51025
+ return false;
51026
+ }
51027
+ toCDS() {
51028
+ return "abap.TODO_PGENERIC";
51029
+ }
51030
+ }
51031
+ exports.PGenericType = PGenericType;
51032
+ PGenericType.singleton = new PGenericType();
51033
+ //# sourceMappingURL=pgeneric_type.js.map
51034
+
51035
+ /***/ },
51036
+
50770
51037
  /***/ "./node_modules/@abaplint/core/build/src/abap/types/basic/simple_type.js"
50771
51038
  /*!*******************************************************************************!*\
50772
51039
  !*** ./node_modules/@abaplint/core/build/src/abap/types/basic/simple_type.js ***!
@@ -50779,6 +51046,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
50779
51046
  exports.SimpleType = void 0;
50780
51047
  const _abstract_type_1 = __webpack_require__(/*! ./_abstract_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/_abstract_type.js");
50781
51048
  class SimpleType extends _abstract_type_1.AbstractType {
51049
+ static get() {
51050
+ return this.singleton;
51051
+ }
51052
+ constructor() {
51053
+ super();
51054
+ }
50782
51055
  toText() {
50783
51056
  return "```simple```";
50784
51057
  }
@@ -50796,6 +51069,7 @@ class SimpleType extends _abstract_type_1.AbstractType {
50796
51069
  }
50797
51070
  }
50798
51071
  exports.SimpleType = SimpleType;
51072
+ SimpleType.singleton = new SimpleType();
50799
51073
  //# sourceMappingURL=simple_type.js.map
50800
51074
 
50801
51075
  /***/ },
@@ -51363,6 +51637,7 @@ const data_1 = __webpack_require__(/*! ../5_syntax/statements/data */ "./node_mo
51363
51637
  const constant_1 = __webpack_require__(/*! ../5_syntax/statements/constant */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/constant.js");
51364
51638
  const data_2 = __webpack_require__(/*! ../5_syntax/structures/data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/data.js");
51365
51639
  const type_enum_1 = __webpack_require__(/*! ../5_syntax/structures/type_enum */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_enum.js");
51640
+ const type_mesh_1 = __webpack_require__(/*! ../5_syntax/structures/type_mesh */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/type_mesh.js");
51366
51641
  const constants_1 = __webpack_require__(/*! ../5_syntax/structures/constants */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/constants.js");
51367
51642
  const type_definitions_1 = __webpack_require__(/*! ./type_definitions */ "./node_modules/@abaplint/core/build/src/abap/types/type_definitions.js");
51368
51643
  const types_1 = __webpack_require__(/*! ../5_syntax/structures/types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/structures/types.js");
@@ -51523,6 +51798,13 @@ class Attributes {
51523
51798
  // scope.addIdentifier(attr);
51524
51799
  }
51525
51800
  }
51801
+ else if (ctyp instanceof Structures.TypeMesh) {
51802
+ const res = new type_mesh_1.TypeMesh().runSyntax(c, input);
51803
+ if (res) {
51804
+ input.scope.addType(res);
51805
+ this.tlist.push({ type: res, visibility });
51806
+ }
51807
+ }
51526
51808
  else if (ctyp instanceof Structures.Types) {
51527
51809
  const res = new types_1.Types().runSyntax(c, input);
51528
51810
  if (res) {
@@ -51745,6 +52027,7 @@ class ClassDefinition extends _identifier_1.Identifier {
51745
52027
  // perform checks after everything has been initialized
51746
52028
  this.checkInterfaceVisibility(input, node);
51747
52029
  this.checkMethodsFromSuperClasses(input);
52030
+ this.checkClassNameLength(input);
51748
52031
  this.checkMethodNameLength(input);
51749
52032
  this.checkClassConstructorStatic(input);
51750
52033
  }
@@ -51795,6 +52078,12 @@ class ClassDefinition extends _identifier_1.Identifier {
51795
52078
  }
51796
52079
  */
51797
52080
  ///////////////////
52081
+ checkClassNameLength(input) {
52082
+ if (this.getName().length > 30) {
52083
+ const message = `Class name "${this.getName()}" is too long, maximum length is 30 characters`;
52084
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, this.getToken(), message));
52085
+ }
52086
+ }
51798
52087
  findSuper(def, input) {
51799
52088
  var _a;
51800
52089
  const token = (_a = def === null || def === void 0 ? void 0 : def.findDirectExpression(expressions_1.SuperClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
@@ -55610,7 +55899,7 @@ class DDIC {
55610
55899
  case "ANY":
55611
55900
  return Types.AnyType.get({ qualifiedName: qualifiedName });
55612
55901
  case "SIMPLE":
55613
- return new Types.SimpleType({ qualifiedName: qualifiedName });
55902
+ return Types.SimpleType.get();
55614
55903
  case "%_C_POINTER":
55615
55904
  return new Types.HexType(8, qualifiedName);
55616
55905
  case "TABLE":
@@ -55648,7 +55937,7 @@ class DDIC {
55648
55937
  return new Types.PackedType(length, 0, { qualifiedName: qualifiedName });
55649
55938
  }
55650
55939
  else {
55651
- return new Types.PackedType(1, 0, { qualifiedName: qualifiedName });
55940
+ return new Types.PackedType(8, 0, { qualifiedName: qualifiedName });
55652
55941
  }
55653
55942
  case "C":
55654
55943
  if (length) {
@@ -55876,14 +56165,14 @@ class DDIC {
55876
56165
  case "DF16_DEC": // 1 <= len <= 31
55877
56166
  case "DF34_DEC": // 1 <= len <= 31
55878
56167
  case "CURR": // 1 <= len <= 31
55879
- case "QUAN": // 1 <= len <= 31
56168
+ case "QUAN": { // 1 <= len <= 31
55880
56169
  if (input.length === undefined) {
55881
56170
  return new Types.UnknownType(input.text + " unknown length, " + input.infoText, input.infoText);
55882
56171
  }
55883
- else if (input.decimals === undefined) {
55884
- return new Types.PackedType(parseInt(input.length, 10), 0, extra);
55885
- }
55886
- return new Types.PackedType(parseInt(input.length, 10), parseInt(input.decimals, 10), extra);
56172
+ const packedLength = Math.ceil((parseInt(input.length, 10) + 1) / 2);
56173
+ const decimals = input.decimals === undefined ? 0 : parseInt(input.decimals, 10);
56174
+ return new Types.PackedType(packedLength, decimals, extra);
56175
+ }
55887
56176
  case "ACCP":
55888
56177
  return new Types.CharacterType(6, extra); // YYYYMM
55889
56178
  case "LANG":
@@ -56271,7 +56560,7 @@ exports.DDLAspect = DDLAspect;
56271
56560
  "use strict";
56272
56561
 
56273
56562
  Object.defineProperty(exports, "__esModule", ({ value: true }));
56274
- exports.DDLValueHelp = exports.DDLForeignKey = exports.DDLForeignKeyTarget = void 0;
56563
+ exports.DDLReference = exports.DDLValueHelp = exports.DDLForeignKey = exports.DDLForeignKeyTarget = void 0;
56275
56564
  const combi_1 = __webpack_require__(/*! ../../abap/2_statements/combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
56276
56565
  const ddl_literal_1 = __webpack_require__(/*! ./ddl_literal */ "./node_modules/@abaplint/core/build/src/ddl/expressions/ddl_literal.js");
56277
56566
  const ddl_name_1 = __webpack_require__(/*! ./ddl_name */ "./node_modules/@abaplint/core/build/src/ddl/expressions/ddl_name.js");
@@ -56295,6 +56584,12 @@ class DDLValueHelp extends combi_1.Expression {
56295
56584
  }
56296
56585
  }
56297
56586
  exports.DDLValueHelp = DDLValueHelp;
56587
+ class DDLReference extends combi_1.Expression {
56588
+ getRunnable() {
56589
+ return (0, combi_1.seq)("WITH", "REFERENCE", "TABLE", ddl_name_1.DDLName, "AND", "REFERENCE", "FIELD", ddl_name_1.DDLName);
56590
+ }
56591
+ }
56592
+ exports.DDLReference = DDLReference;
56298
56593
  //# sourceMappingURL=ddl_clauses.js.map
56299
56594
 
56300
56595
  /***/ },
@@ -56570,7 +56865,7 @@ const ddl_name_1 = __webpack_require__(/*! ./ddl_name */ "./node_modules/@abapli
56570
56865
  const ddl_type_1 = __webpack_require__(/*! ./ddl_type */ "./node_modules/@abaplint/core/build/src/ddl/expressions/ddl_type.js");
56571
56866
  class DDLTableField extends combi_1.Expression {
56572
56867
  getRunnable() {
56573
- const trailingClause = (0, combi_1.alt)(ddl_clauses_1.DDLForeignKey, ddl_clauses_1.DDLValueHelp);
56868
+ const trailingClause = (0, combi_1.alt)(ddl_clauses_1.DDLForeignKey, ddl_clauses_1.DDLReference, ddl_clauses_1.DDLValueHelp);
56574
56869
  return (0, combi_1.seq)((0, combi_1.star)(expressions_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"), ddl_name_1.DDLName, ":", ddl_type_1.DDLType, (0, combi_1.optPrio)("NOT NULL"), (0, combi_1.star)(trailingClause), ";");
56575
56870
  }
56576
56871
  }
@@ -60205,7 +60500,8 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
60205
60500
  return this.textsTranslations;
60206
60501
  }
60207
60502
  findTexts(parsed) {
60208
- var _a, _b, _c, _d, _e, _f, _g;
60503
+ var _a, _b, _c, _d, _e, _f;
60504
+ var _g;
60209
60505
  this.texts = {};
60210
60506
  if (((_d = (_c = (_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]) === null || _c === void 0 ? void 0 : _c.TPOOL) === null || _d === void 0 ? void 0 : _d.item) === undefined) {
60211
60507
  return;
@@ -60218,7 +60514,7 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
60218
60514
  if (id !== "R" && t.KEY === undefined) {
60219
60515
  continue;
60220
60516
  }
60221
- const key = (_g = ((_f = t.KEY) !== null && _f !== void 0 ? _f : t.ID)) === null || _g === void 0 ? void 0 : _g.toUpperCase();
60517
+ const key = (_f = ((_g = t.KEY) !== null && _g !== void 0 ? _g : t.ID)) === null || _f === void 0 ? void 0 : _f.toUpperCase();
60222
60518
  if (key === undefined) {
60223
60519
  continue;
60224
60520
  }
@@ -60229,7 +60525,8 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
60229
60525
  }
60230
60526
  }
60231
60527
  findTextsTranslations(parsed) {
60232
- var _a, _b, _c, _d, _e, _f, _g;
60528
+ var _a, _b, _c, _d, _e, _f;
60529
+ var _g;
60233
60530
  this.textsTranslations = [];
60234
60531
  const values = (_d = (_c = (_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]) === null || _c === void 0 ? void 0 : _c.I18N_TPOOL) === null || _d === void 0 ? void 0 : _d.item;
60235
60532
  if (values === undefined) {
@@ -60238,7 +60535,7 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
60238
60535
  for (const langItem of (0, xml_utils_1.xmlToArray)(values)) {
60239
60536
  const textElements = {};
60240
60537
  for (const item of (0, xml_utils_1.xmlToArray)((_e = langItem.TEXTPOOL) === null || _e === void 0 ? void 0 : _e.item)) {
60241
- const key = (_g = ((_f = item.KEY) !== null && _f !== void 0 ? _f : item.ID)) === null || _g === void 0 ? void 0 : _g.toUpperCase();
60538
+ const key = (_f = ((_g = item.KEY) !== null && _g !== void 0 ? _g : item.ID)) === null || _f === void 0 ? void 0 : _f.toUpperCase();
60242
60539
  if (key !== undefined) {
60243
60540
  textElements[key] = { entry: (0, xml_utils_1.unescape)(item.ENTRY), maxLength: parseInt(item.LENGTH, 10) };
60244
60541
  }
@@ -62796,11 +63093,13 @@ class Domain extends _abstract_object_1.AbstractObject {
62796
63093
  return { updated: true, runtime: end - start };
62797
63094
  }
62798
63095
  getFixedValues() {
62799
- var _a, _b;
63096
+ var _a;
63097
+ var _b;
62800
63098
  return (_b = (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
62801
63099
  }
62802
63100
  getFixedValuesTranslations() {
62803
- var _a, _b;
63101
+ var _a;
63102
+ var _b;
62804
63103
  return (_b = (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.valuesTranslations) !== null && _b !== void 0 ? _b : [];
62805
63104
  }
62806
63105
  }
@@ -66574,7 +66873,8 @@ class RenameICFService {
66574
66873
  this.reg = reg;
66575
66874
  }
66576
66875
  buildEdits(obj, oldName, newName) {
66577
- var _a, _b, _c, _d;
66876
+ var _a, _b;
66877
+ var _c, _d;
66578
66878
  if (!(obj instanceof __1.ICFService)) {
66579
66879
  throw new Error("RenameICFService, not a ICF Service");
66580
66880
  }
@@ -66599,8 +66899,8 @@ class RenameICFService {
66599
66899
  }
66600
66900
  return newName;
66601
66901
  })();
66602
- const cleanOldName = (_b = (_a = oldName.match(/^[^ ]+/)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : oldName;
66603
- const cleanNewName = (_d = (_c = newName.match(/^[^ ]+/)) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : newName;
66902
+ const cleanOldName = (_c = (_a = oldName.match(/^[^ ]+/)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _c !== void 0 ? _c : oldName;
66903
+ const cleanNewName = (_d = (_b = newName.match(/^[^ ]+/)) === null || _b === void 0 ? void 0 : _b[0]) !== null && _d !== void 0 ? _d : newName;
66604
66904
  let changes = [];
66605
66905
  const helper = new renamer_helper_1.RenamerHelper(this.reg);
66606
66906
  changes = changes.concat(helper.buildURLFileEdits(obj, cleanOldName, cleanNewName));
@@ -67787,6 +68087,13 @@ class Table extends _abstract_object_1.AbstractObject {
67787
68087
  }
67788
68088
  return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.secondaryIndexes;
67789
68089
  }
68090
+ getFields() {
68091
+ var _a;
68092
+ if (this.parsedData === undefined) {
68093
+ this.parseXML();
68094
+ }
68095
+ return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.fields;
68096
+ }
67790
68097
  getAllowedNaming() {
67791
68098
  let length = 30;
67792
68099
  const regex = /^((\/[A-Z_\d]{3,8}\/)|[a-zA-Z0-9]{3}|CI_)\w+$/;
@@ -67839,9 +68146,13 @@ class Table extends _abstract_object_1.AbstractObject {
67839
68146
  && this.parsedData.dataClass === "USER3") {
67840
68147
  return new Types.UnknownType("Data class = USER3 not allowed in cloud");
67841
68148
  }
67842
- if (this.getTableCategory() === TableCategory.Transparent
67843
- && this.listKeys(reg).length === 0) {
67844
- return new Types.UnknownType("Table " + this.getName() + " has no key fields");
68149
+ if (this.getTableCategory() === TableCategory.Transparent) {
68150
+ if (this.listKeys(reg).length === 0) {
68151
+ return new Types.UnknownType("Table " + this.getName() + " has no key fields");
68152
+ }
68153
+ else if (this.keyFieldsNotFirst()) {
68154
+ return new Types.UnknownType("Table " + this.getName() + " key fields must be first");
68155
+ }
67845
68156
  }
67846
68157
  if (this.parsedType) {
67847
68158
  return this.parsedType;
@@ -68017,6 +68328,21 @@ class Table extends _abstract_object_1.AbstractObject {
68017
68328
  return this.parsedData.enhancementCategory;
68018
68329
  }
68019
68330
  ///////////////
68331
+ keyFieldsNotFirst() {
68332
+ var _a;
68333
+ let seenNonKey = false;
68334
+ for (const field of ((_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.fields) || []) {
68335
+ if (field.KEYFLAG === "X") {
68336
+ if (seenNonKey === true) {
68337
+ return true;
68338
+ }
68339
+ }
68340
+ else {
68341
+ seenNonKey = true;
68342
+ }
68343
+ }
68344
+ return false;
68345
+ }
68020
68346
  parseXML() {
68021
68347
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
68022
68348
  const parsed = super.parseRaw2();
@@ -68053,6 +68379,8 @@ class Table extends _abstract_object_1.AbstractObject {
68053
68379
  KEYFLAG: field.KEYFLAG,
68054
68380
  GROUPNAME: field.GROUPNAME,
68055
68381
  CHECKTABLE: field.CHECKTABLE,
68382
+ REFTABLE: field.REFTABLE,
68383
+ REFFIELD: field.REFFIELD,
68056
68384
  REFTYPE: field.REFTYPE,
68057
68385
  DDTEXT: field.DDTEXT,
68058
68386
  });
@@ -68959,7 +69287,8 @@ class WebMIME extends _abstract_object_1.AbstractObject {
68959
69287
  return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.params[name.toLowerCase()];
68960
69288
  }
68961
69289
  getParameters() {
68962
- var _a, _b;
69290
+ var _a;
69291
+ var _b;
68963
69292
  this.parse();
68964
69293
  return (_b = (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
68965
69294
  }
@@ -69590,7 +69919,7 @@ class Registry {
69590
69919
  }
69591
69920
  static abaplintVersion() {
69592
69921
  // magic, see build script "version.js"
69593
- return "2.120.6";
69922
+ return "2.120.18";
69594
69923
  }
69595
69924
  getDDICReferences() {
69596
69925
  return this.ddicReferences;
@@ -69934,7 +70263,7 @@ class SevenBitAscii {
69934
70263
  shortDescription: `Only allow characters from the 7bit ASCII set.`,
69935
70264
  extendedInformation: `https://docs.abapopenchecks.org/checks/05/
69936
70265
 
69937
- https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_guidl.htm
70266
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abencharacter_set_guidl.html
69938
70267
 
69939
70268
  Checkes files with extensions ".abap" and ".asddls"`,
69940
70269
  tags: [_irule_1.RuleTag.SingleFile],
@@ -71552,7 +71881,7 @@ class AvoidUse extends _abap_rule_1.ABAPRule {
71552
71881
  shortDescription: `Detects usage of certain statements.`,
71553
71882
  extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
71554
71883
 
71555
- Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
71884
+ Macros: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.html
71556
71885
 
71557
71886
  STATICS: use CLASS-DATA instead
71558
71887
 
@@ -72286,7 +72615,7 @@ class CDSCommentStyle {
72286
72615
 
72287
72616
  Comments starting with "--" are considered obsolete
72288
72617
 
72289
- https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abencds_general_syntax_rules.htm`,
72618
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abencds_general_syntax_rules.html`,
72290
72619
  tags: [_irule_1.RuleTag.SingleFile],
72291
72620
  badExample: "-- this is a comment",
72292
72621
  goodExample: "// this is a comment",
@@ -72815,7 +73144,7 @@ class ChainMainlyDeclarations extends _abap_rule_1.ABAPRule {
72815
73144
  extendedInformation: `
72816
73145
  https://docs.abapopenchecks.org/checks/23/
72817
73146
 
72818
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
73147
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenchained_statements_guidl.html
72819
73148
  `,
72820
73149
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
72821
73150
  badExample: `CALL METHOD: bar.`,
@@ -74339,7 +74668,7 @@ before reading it, so a leftover value is not accidentally used.
74339
74668
 
74340
74669
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#clear-or-overwrite-exporting-reference-parameters
74341
74670
 
74342
- https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenref_transf_output_param_guidl.htm
74671
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenref_transf_output_param_guidl.html
74343
74672
 
74344
74673
  Note: EXPORTING parameters passed by VALUE are always initialized and are therefore not reported.
74345
74674
  Reading and writing the parameter in the same statement (e.g. "ev_result = ev_result + 1") is reported,
@@ -75038,7 +75367,7 @@ class ConstructorVisibilityPublic {
75038
75367
  This only applies to global classes.
75039
75368
 
75040
75369
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#if-your-global-class-is-create-private-leave-the-constructor-public
75041
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abeninstance_constructor_guidl.htm`,
75370
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abeninstance_constructor_guidl.html`,
75042
75371
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
75043
75372
  badExample: `CLASS zcl_foo DEFINITION PUBLIC CREATE PRIVATE.
75044
75373
  PRIVATE SECTION.
@@ -80073,8 +80402,8 @@ class ExitOrCheck extends _abap_rule_1.ABAPRule {
80073
80402
  title: "Find EXIT or CHECK outside loops",
80074
80403
  shortDescription: `Detects usages of EXIT or CHECK statements outside of loops.
80075
80404
  Use RETURN to leave procesing blocks instead.`,
80076
- extendedInformation: `https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenleave_processing_blocks.htm
80077
- https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapcheck_processing_blocks.htm
80405
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenleave_processing_blocks.html
80406
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapcheck_processing_blocks.html
80078
80407
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#check-vs-return`,
80079
80408
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
80080
80409
  badExample: `CHECK is_valid = abap_true.
@@ -80164,7 +80493,7 @@ class ExpandMacros extends _abap_rule_1.ABAPRule {
80164
80493
  key: "expand_macros",
80165
80494
  title: "Expand Macros",
80166
80495
  shortDescription: `Allows expanding macro calls with quick fixes`,
80167
- extendedInformation: `Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
80496
+ extendedInformation: `Macros: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.html
80168
80497
 
80169
80498
  Note that macros/DEFINE cannot be used in the ABAP Cloud programming model`,
80170
80499
  badExample: `DEFINE _hello.
@@ -80378,7 +80707,7 @@ class FMGlobalParametersObsolete {
80378
80707
  key: "fm_global_parameters_obsolete",
80379
80708
  title: "FM Global Parameters Obsolete",
80380
80709
  shortDescription: `Check for function modules with global parameters`,
80381
- extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenglobal_parameters_obsolete.htm`,
80710
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenglobal_parameters_obsolete.html`,
80382
80711
  tags: [],
80383
80712
  };
80384
80713
  }
@@ -80863,7 +81192,7 @@ class FormTablesObsolete extends _abap_rule_1.ABAPRule {
80863
81192
  key: "form_tables_obsolete",
80864
81193
  title: "TABLES parameters are obsolete",
80865
81194
  shortDescription: `Checks for TABLES parameters in forms.`,
80866
- extendedInformation: `https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapform_tables.htm`,
81195
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapform_tables.html`,
80867
81196
  tags: [_irule_1.RuleTag.SingleFile],
80868
81197
  badExample: `FORM update_items TABLES items.
80869
81198
  ENDFORM.`,
@@ -82824,7 +83153,7 @@ class ImplicitStartOfSelection extends _abap_rule_1.ABAPRule {
82824
83153
  shortDescription: `Add explicit selection screen event handling`,
82825
83154
  extendedInformation: `Only runs for executable programs
82826
83155
 
82827
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapstart-of-selection.htm`,
83156
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapstart-of-selection.html`,
82828
83157
  tags: [_irule_1.RuleTag.SingleFile],
82829
83158
  badExample: `REPORT zfoo.
82830
83159
  WRITE 'hello'.`,
@@ -83390,6 +83719,7 @@ __exportStar(__webpack_require__(/*! ./no_comments_between_methods */ "./node_mo
83390
83719
  __exportStar(__webpack_require__(/*! ./no_external_form_calls */ "./node_modules/@abaplint/core/build/src/rules/no_external_form_calls.js"), exports);
83391
83720
  __exportStar(__webpack_require__(/*! ./no_inline_in_optional_branches */ "./node_modules/@abaplint/core/build/src/rules/no_inline_in_optional_branches.js"), exports);
83392
83721
  __exportStar(__webpack_require__(/*! ./no_macros */ "./node_modules/@abaplint/core/build/src/rules/no_macros.js"), exports);
83722
+ __exportStar(__webpack_require__(/*! ./no_mandt_in_database_operations */ "./node_modules/@abaplint/core/build/src/rules/no_mandt_in_database_operations.js"), exports);
83393
83723
  __exportStar(__webpack_require__(/*! ./no_prefixes */ "./node_modules/@abaplint/core/build/src/rules/no_prefixes.js"), exports);
83394
83724
  __exportStar(__webpack_require__(/*! ./no_public_attributes */ "./node_modules/@abaplint/core/build/src/rules/no_public_attributes.js"), exports);
83395
83725
  __exportStar(__webpack_require__(/*! ./no_yoda_conditions */ "./node_modules/@abaplint/core/build/src/rules/no_yoda_conditions.js"), exports);
@@ -86265,7 +86595,7 @@ class MethodOverwritesBuiltIn extends _abap_rule_1.ABAPRule {
86265
86595
  key: "method_overwrites_builtin",
86266
86596
  title: "Method name overwrites builtin function",
86267
86597
  shortDescription: `Checks Method names that overwrite builtin SAP functions`,
86268
- extendedInformation: `https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abenbuilt_in_functions_overview.htm
86598
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abenbuilt_in_functions_overview.html
86269
86599
 
86270
86600
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obscuring-built-in-functions
86271
86601
 
@@ -86507,7 +86837,7 @@ class MixReturning extends _abap_rule_1.ABAPRule {
86507
86837
  shortDescription: `Checks that methods don't have a mixture of returning and exporting/changing parameters`,
86508
86838
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-either-returning-or-exporting-or-changing-but-not-a-combination
86509
86839
 
86510
- This syntax is not allowed on versions earlier than 740sp02, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abennews-740-abap_objects.htm#!ABAP_MODIFICATION_1@1@`,
86840
+ This syntax is not allowed on versions earlier than 740sp02, https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abennews-740-abap_objects.html#!ABAP_MODIFICATION_1@1@`,
86511
86841
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax],
86512
86842
  badExample: `CLASS lcl DEFINITION.
86513
86843
  PUBLIC SECTION.
@@ -87838,7 +88168,7 @@ class NoMacros extends _abap_rule_1.ABAPRule {
87838
88168
  shortDescription: `Checks that macros are not used`,
87839
88169
  extendedInformation: `Macros reduce readability and are difficult to debug, use methods or form routines instead.
87840
88170
 
87841
- https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.htm`,
88171
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.html`,
87842
88172
  tags: [_irule_1.RuleTag.SingleFile],
87843
88173
  badExample: `DEFINE _macro.
87844
88174
  WRITE 'hello'.
@@ -87867,6 +88197,153 @@ exports.NoMacros = NoMacros;
87867
88197
 
87868
88198
  /***/ },
87869
88199
 
88200
+ /***/ "./node_modules/@abaplint/core/build/src/rules/no_mandt_in_database_operations.js"
88201
+ /*!****************************************************************************************!*\
88202
+ !*** ./node_modules/@abaplint/core/build/src/rules/no_mandt_in_database_operations.js ***!
88203
+ \****************************************************************************************/
88204
+ (__unused_webpack_module, exports, __webpack_require__) {
88205
+
88206
+ "use strict";
88207
+
88208
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
88209
+ if (k2 === undefined) k2 = k;
88210
+ var desc = Object.getOwnPropertyDescriptor(m, k);
88211
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
88212
+ desc = { enumerable: true, get: function() { return m[k]; } };
88213
+ }
88214
+ Object.defineProperty(o, k2, desc);
88215
+ }) : (function(o, m, k, k2) {
88216
+ if (k2 === undefined) k2 = k;
88217
+ o[k2] = m[k];
88218
+ }));
88219
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
88220
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
88221
+ }) : function(o, v) {
88222
+ o["default"] = v;
88223
+ });
88224
+ var __importStar = (this && this.__importStar) || (function () {
88225
+ var ownKeys = function(o) {
88226
+ ownKeys = Object.getOwnPropertyNames || function (o) {
88227
+ var ar = [];
88228
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
88229
+ return ar;
88230
+ };
88231
+ return ownKeys(o);
88232
+ };
88233
+ return function (mod) {
88234
+ if (mod && mod.__esModule) return mod;
88235
+ var result = {};
88236
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
88237
+ __setModuleDefault(result, mod);
88238
+ return result;
88239
+ };
88240
+ })();
88241
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
88242
+ exports.NoMandtInDatabaseOperations = exports.NoMandtInDatabaseOperationsConf = void 0;
88243
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
88244
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js"));
88245
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
88246
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
88247
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
88248
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
88249
+ class NoMandtInDatabaseOperationsConf extends _basic_rule_config_1.BasicRuleConfig {
88250
+ }
88251
+ exports.NoMandtInDatabaseOperationsConf = NoMandtInDatabaseOperationsConf;
88252
+ class NoMandtInDatabaseOperations extends _abap_rule_1.ABAPRule {
88253
+ constructor() {
88254
+ super(...arguments);
88255
+ this.conf = new NoMandtInDatabaseOperationsConf();
88256
+ }
88257
+ getMetadata() {
88258
+ return {
88259
+ key: "no_mandt_in_database_operations",
88260
+ title: "No MANDT in database operations",
88261
+ shortDescription: "Do not specify the client in database operations; the ABAP runtime handles it automatically.",
88262
+ extendedInformation: "Only check for the name MANDT, not for the field type. The rule does not check for dynamic SQL.",
88263
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax],
88264
+ badExample: `SELECT * FROM zcustomers
88265
+ CLIENT SPECIFIED
88266
+ WHERE mandt = @sy-mandt
88267
+ INTO TABLE @DATA(customers).`,
88268
+ goodExample: `SELECT * FROM zcustomers
88269
+ INTO TABLE @DATA(customers).`,
88270
+ };
88271
+ }
88272
+ getConfig() {
88273
+ return this.conf;
88274
+ }
88275
+ setConfig(conf) {
88276
+ this.conf = conf;
88277
+ }
88278
+ runParsed(file) {
88279
+ const issues = [];
88280
+ for (const statement of file.getStatements()) {
88281
+ if (this.isDatabaseOperation(statement) === false) {
88282
+ continue;
88283
+ }
88284
+ const mandt = this.findMandtInCondition(statement);
88285
+ if (mandt !== undefined) {
88286
+ const issue = issue_1.Issue.atToken(file, mandt.getFirstToken(), this.getMetadata().title, this.getMetadata().key, this.conf.severity);
88287
+ issues.push(issue);
88288
+ continue;
88289
+ }
88290
+ const explicitClient = this.findExplicitClient(statement);
88291
+ if (explicitClient !== undefined) {
88292
+ const issue = issue_1.Issue.atToken(file, explicitClient, this.getMetadata().title, this.getMetadata().key, this.conf.severity);
88293
+ issues.push(issue);
88294
+ }
88295
+ }
88296
+ return issues;
88297
+ }
88298
+ isDatabaseOperation(statement) {
88299
+ const type = statement.get();
88300
+ return type instanceof Statements.DeleteDatabase
88301
+ || type instanceof Statements.InsertDatabase
88302
+ || type instanceof Statements.MergeDatabase
88303
+ || type instanceof Statements.ModifyDatabase
88304
+ || type instanceof Statements.OpenCursor
88305
+ || type instanceof Statements.Select
88306
+ || type instanceof Statements.SelectLoop
88307
+ || type instanceof Statements.UpdateDatabase
88308
+ || type instanceof Statements.With
88309
+ || type instanceof Statements.WithLoop;
88310
+ }
88311
+ findMandtInCondition(statement) {
88312
+ for (const condition of statement.findAllExpressions(Expressions.SQLCond)) {
88313
+ const fields = condition.findAllExpressionsMulti([
88314
+ Expressions.SQLFieldName,
88315
+ Expressions.SQLAliasField,
88316
+ ]);
88317
+ for (const field of fields) {
88318
+ const name = field.concatTokens().toUpperCase();
88319
+ if (name === "MANDT" || name.endsWith("~MANDT")) {
88320
+ return field;
88321
+ }
88322
+ }
88323
+ }
88324
+ return undefined;
88325
+ }
88326
+ findExplicitClient(statement) {
88327
+ var _a, _b;
88328
+ const tokens = statement.getTokens();
88329
+ for (let index = 0; index < tokens.length; index++) {
88330
+ const current = tokens[index].getStr().toUpperCase();
88331
+ const next = (_a = tokens[index + 1]) === null || _a === void 0 ? void 0 : _a.getStr().toUpperCase();
88332
+ const afterNext = (_b = tokens[index + 2]) === null || _b === void 0 ? void 0 : _b.getStr().toUpperCase();
88333
+ if ((current === "CLIENT" && next === "SPECIFIED")
88334
+ || (current === "USING" && (next === "CLIENT" || next === "CLIENTS"))
88335
+ || (current === "USING" && next === "ALL" && afterNext === "CLIENTS")) {
88336
+ return current === "CLIENT" ? tokens[index] : tokens[index + (next === "ALL" ? 2 : 1)];
88337
+ }
88338
+ }
88339
+ return undefined;
88340
+ }
88341
+ }
88342
+ exports.NoMandtInDatabaseOperations = NoMandtInDatabaseOperations;
88343
+ //# sourceMappingURL=no_mandt_in_database_operations.js.map
88344
+
88345
+ /***/ },
88346
+
87870
88347
  /***/ "./node_modules/@abaplint/core/build/src/rules/no_prefixes.js"
87871
88348
  /*!********************************************************************!*\
87872
88349
  !*** ./node_modules/@abaplint/core/build/src/rules/no_prefixes.js ***!
@@ -88096,13 +88573,13 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/sub-sections/AvoidEncodi
88096
88573
  return ret;
88097
88574
  }
88098
88575
  checkMethodParameters(topNode, regex, file) {
88099
- var _a, _b;
88576
+ var _a, _b, _c;
88100
88577
  const ret = [];
88101
88578
  for (const method of topNode.findAllStatements(Statements.MethodDef)) {
88102
88579
  for (const param of method.findAllExpressionsMulti([Expressions.MethodDefReturning, Expressions.MethodParam])) {
88103
88580
  const nameToken = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.MethodParamName);
88104
- const type = (_b = (_a = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.TypeParam)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
88105
- if (this.getConfig().allowIsPrefixBoolean === true && (type === null || type === void 0 ? void 0 : type.endsWith("TYPE ABAP_BOOL"))) {
88581
+ const typeName = (_c = (_b = (_a = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.TypeParam)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(Expressions.TypeNameOrInfer)) === null || _b === void 0 ? void 0 : _b.concatTokens()) === null || _c === void 0 ? void 0 : _c.toUpperCase();
88582
+ if (this.getConfig().allowIsPrefixBoolean === true && typeName === "ABAP_BOOL") {
88106
88583
  continue;
88107
88584
  }
88108
88585
  const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.concatTokens();
@@ -88762,44 +89239,44 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-func
88762
89239
 
88763
89240
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obsolete-language-elements
88764
89241
 
88765
- SET EXTENDED CHECK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapset_extended_check.htm
89242
+ SET EXTENDED CHECK: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapset_extended_check.html
88766
89243
 
88767
- IS REQUESTED: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenlogexp_requested.htm
89244
+ IS REQUESTED: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenlogexp_requested.html
88768
89245
 
88769
- WITH HEADER LINE: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapdata_header_line.htm
89246
+ WITH HEADER LINE: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapdata_header_line.html
88770
89247
 
88771
- FIELD-SYMBOLS STRUCTURE: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapfield-symbols_obsolete_typing.htm
89248
+ FIELD-SYMBOLS STRUCTURE: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapfield-symbols_obsolete_typing.html
88772
89249
 
88773
- TYPE-POOLS: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
89250
+ TYPE-POOLS: from 702, https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abennews-71-program_load.html
88774
89251
 
88775
- LOAD addition: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
89252
+ LOAD addition: from 702, https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abennews-71-program_load.html
88776
89253
 
88777
- COMMUICATION: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapcommunication.htm
89254
+ COMMUICATION: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapcommunication.html
88778
89255
 
88779
- OCCURS: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapdata_occurs.htm
89256
+ OCCURS: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapdata_occurs.html
88780
89257
 
88781
- PARAMETER: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapparameter.htm
89258
+ PARAMETER: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapparameter.html
88782
89259
 
88783
- RANGES: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapranges.htm
89260
+ RANGES: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapranges.html
88784
89261
 
88785
- PACK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abappack.htm
89262
+ PACK: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abappack.html
88786
89263
 
88787
- MOVE: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapmove_obs.htm
89264
+ MOVE: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapmove_obs.html
88788
89265
 
88789
- SELECT without INTO: https://help.sap.com/doc/abapdocu_731_index_htm/7.31/en-US/abapselect_obsolete.htm
89266
+ SELECT without INTO: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapselect_obsolete.html
88790
89267
  SELECT COUNT(*) is considered okay
88791
89268
 
88792
- FREE MEMORY: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapfree_mem_id_obsolete.htm
89269
+ FREE MEMORY: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abapfree_mem_id_obsolete.html
88793
89270
 
88794
- SORT BY FS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_itab_obsolete.htm
89271
+ SORT BY FS: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapsort_itab_obsolete.html
88795
89272
 
88796
- CALL TRANSFORMATION OBJECTS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_transformation_objects.htm
89273
+ CALL TRANSFORMATION OBJECTS: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapcall_transformation_objects.html
88797
89274
 
88798
- POSIX REGEX: https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.htm
89275
+ POSIX REGEX: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/ABENREGEX_MIGRATING_POSIX.html
88799
89276
 
88800
89277
  OCCURENCES: check for OCCURENCES vs OCCURRENCES
88801
89278
 
88802
- CLIENT SPECIFIED, from 754: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapselect_client_obsolete.htm`,
89279
+ CLIENT SPECIFIED, from 754: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapselect_client_obsolete.html`,
88803
89280
  badExample: `REFRESH itab.
88804
89281
 
88805
89282
  COMPUTE foo = 2 + 2.
@@ -90248,7 +90725,7 @@ class PragmaStyle extends _abap_rule_1.ABAPRule {
90248
90725
  title: "Pragma Style",
90249
90726
  shortDescription: `Check pragmas placement and case`,
90250
90727
  tags: [_irule_1.RuleTag.SingleFile],
90251
- extendedInformation: `https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abenpragma.htm`,
90728
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/ABENPRAGMA.html`,
90252
90729
  badExample: `DATA field ##NO_TEXT TYPE i.`,
90253
90730
  goodExample: `DATA field TYPE i ##NO_TEXT.`,
90254
90731
  };
@@ -92486,7 +92963,7 @@ class RFCErrorHandling extends _abap_rule_1.ABAPRule {
92486
92963
  title: "RFC error handling",
92487
92964
  tags: [_irule_1.RuleTag.SingleFile],
92488
92965
  shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
92489
- extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenrfc_exception.htm`,
92966
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenrfc_exception.html`,
92490
92967
  badExample: `CALL FUNCTION 'ZRFC'
92491
92968
  DESTINATION lv_rfc.`,
92492
92969
  goodExample: `CALL FUNCTION 'ZRFC'
@@ -94480,9 +94957,9 @@ class StrictSQL extends _abap_rule_1.ABAPRule {
94480
94957
  key: "strict_sql",
94481
94958
  title: "Strict SQL",
94482
94959
  shortDescription: `Strict SQL`,
94483
- extendedInformation: `https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapinto_clause.htm
94960
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapinto_clause.html
94484
94961
 
94485
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abenopensql_strict_mode_750.htm
94962
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/ABENABAP_SQL_STRICT_MODES.html
94486
94963
 
94487
94964
  Also see separate rule sql_escape_host_variables
94488
94965
 
@@ -94870,7 +95347,7 @@ class SyModification extends _abap_rule_1.ABAPRule {
94870
95347
  key: "sy_modification",
94871
95348
  title: "Modification of SY fields",
94872
95349
  shortDescription: `Finds modification of sy fields`,
94873
- extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abensystem_fields.htm
95350
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abensystem_fields.html
94874
95351
 
94875
95352
  Changes to SY-TVAR* fields are not reported
94876
95353
 
@@ -95198,7 +95675,7 @@ class TablesDeclaredLocally extends _abap_rule_1.ABAPRule {
95198
95675
  key: "tables_declared_locally",
95199
95676
  title: "Check for locally declared TABLES",
95200
95677
  shortDescription: `TABLES are always global, so declare them globally`,
95201
- extendedInformation: `https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abaptables.htm`,
95678
+ extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abaptables.html`,
95202
95679
  tags: [_irule_1.RuleTag.SingleFile],
95203
95680
  badExample: `FORM foo.
95204
95681
  TABLES t100.
@@ -98607,6 +99084,7 @@ class XMLConsistency {
98607
99084
  extendedInformation: `Checks:
98608
99085
  * XML is well-formed and parseable
98609
99086
  * Naming for CLAS and INTF objects
99087
+ * QUAN fields in TABL objects have reference table and field values
98610
99088
  * Texts and translations do not exceed maximum allowed length.`,
98611
99089
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.Syntax],
98612
99090
  };
@@ -98621,6 +99099,7 @@ class XMLConsistency {
98621
99099
  return this;
98622
99100
  }
98623
99101
  run(obj) {
99102
+ var _a;
98624
99103
  const issues = [];
98625
99104
  const file = obj.getXMLFile();
98626
99105
  if (file === undefined) {
@@ -98632,6 +99111,14 @@ class XMLConsistency {
98632
99111
  if (res !== true) {
98633
99112
  issues.push(issue_1.Issue.atRow(file, 1, "XML parser error: " + res.err.msg, this.getMetadata().key, this.conf.severity));
98634
99113
  }
99114
+ else {
99115
+ for (const attribute of ["version", "serializer_version"]) {
99116
+ const value = (_a = xml.match(new RegExp(`<abapGit\\b[^>]*\\b${attribute}="([^"]+)"`))) === null || _a === void 0 ? void 0 : _a[1];
99117
+ if (value !== undefined && value.match(/^v\d\.\d\.\d$/) === null) {
99118
+ issues.push(issue_1.Issue.atRow(file, 1, `Unexpected abapGit ${attribute} "${value}"`, this.getMetadata().key, this.conf.severity));
99119
+ }
99120
+ }
99121
+ }
98635
99122
  }
98636
99123
  // todo, have some XML validation in each object?
98637
99124
  if (obj instanceof Objects.Class) {
@@ -98652,6 +99139,9 @@ class XMLConsistency {
98652
99139
  else if (obj instanceof Objects.MessageClass) {
98653
99140
  issues.push(...this.runMessageClass(obj, file));
98654
99141
  }
99142
+ else if (obj instanceof Objects.Table) {
99143
+ issues.push(...this.runTable(obj, file));
99144
+ }
98655
99145
  if (obj instanceof _abap_object_1.ABAPObject) {
98656
99146
  issues.push(...this.runTextPool(obj, file));
98657
99147
  }
@@ -98795,6 +99285,18 @@ class XMLConsistency {
98795
99285
  }
98796
99286
  return issues;
98797
99287
  }
99288
+ runTable(obj, file) {
99289
+ var _a, _b;
99290
+ var _c;
99291
+ const issues = [];
99292
+ for (const field of (_c = obj.getFields()) !== null && _c !== void 0 ? _c : []) {
99293
+ if (field.DATATYPE === "QUAN" && (!((_a = field.REFTABLE) === null || _a === void 0 ? void 0 : _a.trim()) || !((_b = field.REFFIELD) === null || _b === void 0 ? void 0 : _b.trim()))) {
99294
+ const message = `QUAN field ${field.FIELDNAME} must have REFTABLE and REFFIELD set`;
99295
+ issues.push(issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity));
99296
+ }
99297
+ }
99298
+ return issues;
99299
+ }
98798
99300
  }
98799
99301
  exports.XMLConsistency = XMLConsistency;
98800
99302
  //# sourceMappingURL=xml_consistency.js.map
@@ -102796,39 +103298,151 @@ exports.FieldSymbolTranspiler = FieldSymbolTranspiler;
102796
103298
  Object.defineProperty(exports, "__esModule", ({ value: true }));
102797
103299
  exports.FilterBodyTranspiler = void 0;
102798
103300
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
103301
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
102799
103302
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
102800
103303
  const type_name_or_infer_1 = __webpack_require__(/*! ./type_name_or_infer */ "./node_modules/@abaplint/transpiler/build/src/expressions/type_name_or_infer.js");
102801
103304
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
102802
103305
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
103306
+ const component_chain_simple_1 = __webpack_require__(/*! ./component_chain_simple */ "./node_modules/@abaplint/transpiler/build/src/expressions/component_chain_simple.js");
102803
103307
  class FilterBodyTranspiler {
102804
103308
  transpile(typ, body, traversal) {
102805
103309
  if (!(typ.get() instanceof core_1.Expressions.TypeNameOrInfer)) {
102806
103310
  throw new Error("FilterBodyTranspiler, Expected TypeNameOrInfer");
102807
103311
  }
102808
- else if (body.findDirectTokenByText("EXCEPT")) {
102809
- return new chunk_1.Chunk(`(() => { throw new Error("FilterBodyTranspiler EXCEPT in, not supported, transpiler"); })()`);
103312
+ const sources = body.findDirectExpressions(core_1.Expressions.Source);
103313
+ if (sources.length === 0) {
103314
+ throw new Error("FilterBodyTranspiler, source not found");
102810
103315
  }
102811
- const source = traversal.traverse(body.findDirectExpression(core_1.Expressions.Source)).getCode();
103316
+ const source = traversal.traverse(sources[0]).getCode();
102812
103317
  const type = new type_name_or_infer_1.TypeNameOrInfer().findType(typ, traversal);
102813
103318
  const target = transpile_types_1.TranspileTypes.toType(type);
102814
- const ret = new chunk_1.Chunk();
102815
- ret.appendString("(await (async () => {\n");
102816
- let loopWhere = "";
102817
103319
  const whereNode = body.findDirectExpression(core_1.Expressions.ComponentCond);
102818
- if (whereNode) {
102819
- const where = traversal.traverse(whereNode).getCode();
102820
- loopWhere = `, {"where": async ` + where + `}`;
103320
+ if (whereNode === undefined) {
103321
+ throw new Error("FilterBodyTranspiler, WHERE not found");
102821
103322
  }
102822
- const id = unique_identifier_1.UniqueIdentifier.get();
102823
- const loop = unique_identifier_1.UniqueIdentifier.get();
102824
- ret.appendString(`const ${id} = ${target};\n`);
102825
- ret.appendString(`for await (const ${loop} of abap.statements.loop(${source}${loopWhere})) {\n`);
102826
- ret.appendString(`abap.statements.insertInternal({"table": ${id}, "data": ${loop}});\n`);
102827
- ret.appendString(`}\n`);
102828
- ret.appendString(`return ${id};\n`);
103323
+ if (sources.length > 1) {
103324
+ return this.transpileIn(target, source, traversal.traverse(sources[1]).getCode(), whereNode, body.findDirectTokenByText("EXCEPT") !== undefined, body, traversal);
103325
+ }
103326
+ return this.transpileSingle(target, source, whereNode, body.findDirectTokenByText("EXCEPT") !== undefined, body, traversal);
103327
+ }
103328
+ transpileSingle(target, source, whereNode, except, body, traversal) {
103329
+ const result = unique_identifier_1.UniqueIdentifier.get();
103330
+ const row = unique_identifier_1.UniqueIdentifier.get();
103331
+ const where = traversal.traverse(whereNode).getCode();
103332
+ const options = [];
103333
+ options.push(except ? `where: async (I) => !((${where})(I))` : `where: async ${where}`);
103334
+ const key = body.findDirectExpression(core_1.Expressions.SimpleName);
103335
+ if (key) {
103336
+ options.push(`usingKey: "${key.concatTokens().toLowerCase()}"`);
103337
+ }
103338
+ const ret = new chunk_1.Chunk();
103339
+ ret.appendString("(await (async () => {\n");
103340
+ ret.appendString(`const ${result} = ${target};\n`);
103341
+ ret.appendString(`for await (const ${row} of abap.statements.loop(${source}, {${options.join(", ")}})) {\n`);
103342
+ ret.appendString(`abap.statements.insertInternal({"table": ${result}, "data": ${row}});\n`);
103343
+ ret.appendString("}\n");
103344
+ ret.appendString(`return ${result};\n`);
103345
+ ret.appendString("})())");
103346
+ return ret;
103347
+ }
103348
+ transpileIn(target, source, filterSource, whereNode, except, body, traversal) {
103349
+ const result = unique_identifier_1.UniqueIdentifier.get();
103350
+ const sourceRow = unique_identifier_1.UniqueIdentifier.get();
103351
+ const filterRow = unique_identifier_1.UniqueIdentifier.get();
103352
+ const matched = unique_identifier_1.UniqueIdentifier.get();
103353
+ const condition = this.transpileInCondition(whereNode, traversal, sourceRow, filterRow);
103354
+ const key = body.findDirectExpression(core_1.Expressions.SimpleName);
103355
+ const filterOptions = key ? `, {usingKey: "${key.concatTokens().toLowerCase()}"}` : "";
103356
+ const selection = except ? `!${matched}` : matched;
103357
+ const ret = new chunk_1.Chunk();
103358
+ ret.appendString("(await (async () => {\n");
103359
+ ret.appendString(`const ${result} = ${target};\n`);
103360
+ ret.appendString(`for await (const ${sourceRow} of abap.statements.loop(${source})) {\n`);
103361
+ ret.appendString(`let ${matched} = false;\n`);
103362
+ ret.appendString(`for await (const ${filterRow} of abap.statements.loop(${filterSource}${filterOptions})) {\n`);
103363
+ ret.appendString(`if (${condition}) {\n`);
103364
+ ret.appendString(`${matched} = true;\n`);
103365
+ ret.appendString("break;\n}\n}\n");
103366
+ ret.appendString(`if (${selection}) {\n`);
103367
+ ret.appendString(`abap.statements.insertInternal({"table": ${result}, "data": ${sourceRow}});\n`);
103368
+ ret.appendString("}\n}\n");
103369
+ ret.appendString(`return ${result};\n`);
102829
103370
  ret.appendString("})())");
102830
103371
  return ret;
102831
103372
  }
103373
+ transpileInCondition(node, traversal, sourceRow, filterRow) {
103374
+ if (node.get() instanceof core_1.Expressions.ComponentCompare) {
103375
+ return this.transpileInCompare(node, traversal, sourceRow, filterRow);
103376
+ }
103377
+ let ret = "";
103378
+ for (const child of node.getChildren()) {
103379
+ if (child instanceof core_1.Nodes.ExpressionNode) {
103380
+ ret += this.transpileInCondition(child, traversal, sourceRow, filterRow);
103381
+ }
103382
+ else {
103383
+ switch (child.concatTokens().toUpperCase()) {
103384
+ case "AND":
103385
+ ret += " && ";
103386
+ break;
103387
+ case "OR":
103388
+ ret += " || ";
103389
+ break;
103390
+ case "NOT":
103391
+ ret += "!";
103392
+ break;
103393
+ case "(":
103394
+ ret += "(";
103395
+ break;
103396
+ case ")":
103397
+ ret += ")";
103398
+ break;
103399
+ default: throw new Error("FilterBodyTranspiler, unexpected condition token " + child.concatTokens());
103400
+ }
103401
+ }
103402
+ }
103403
+ return ret;
103404
+ }
103405
+ transpileInCompare(node, traversal, sourceRow, filterRow) {
103406
+ const leftNode = node.findDirectExpression(core_1.Expressions.ComponentChainSimple);
103407
+ if (leftNode === undefined) {
103408
+ throw new Error("FilterBodyTranspiler, comparison component not found");
103409
+ }
103410
+ const left = new component_chain_simple_1.ComponentChainSimpleTranspiler(`${sourceRow}.get().`).transpile(leftNode, traversal).getCode();
103411
+ const sources = node.findDirectExpressions(core_1.Expressions.Source);
103412
+ const concat = node.concatTokens().toUpperCase();
103413
+ const negate = concat.startsWith("NOT ") ? "!" : "";
103414
+ const operator = node.findDirectExpression(core_1.Expressions.CompareOperator);
103415
+ if (operator && sources[0]) {
103416
+ const compare = traversal.traverse(operator).getCode();
103417
+ return `${negate}abap.compare.${compare}(${left}, ${this.filterOperand(sources[0], traversal, filterRow)})`;
103418
+ }
103419
+ if (concat.includes(" BETWEEN ") && sources.length === 2) {
103420
+ const between = `abap.compare.ge(${left}, ${this.filterOperand(sources[0], traversal, filterRow)}) && `
103421
+ + `abap.compare.le(${left}, ${this.filterOperand(sources[1], traversal, filterRow)})`;
103422
+ return concat.includes(" NOT BETWEEN ") ? `!(${between})` : `(${between})`;
103423
+ }
103424
+ if (concat.endsWith("IS INITIAL")) {
103425
+ return `${negate}abap.compare.initial(${left})`;
103426
+ }
103427
+ else if (concat.endsWith("IS NOT INITIAL")) {
103428
+ return `!abap.compare.initial(${left})`;
103429
+ }
103430
+ throw new Error("FilterBodyTranspiler, unsupported IN comparison " + node.concatTokens());
103431
+ }
103432
+ filterOperand(source, traversal, filterRow) {
103433
+ const code = traversal.traverse(source).getCode();
103434
+ const sourceField = source.findFirstExpression(core_1.Expressions.SourceField);
103435
+ const name = sourceField?.findDirectExpression(core_1.Expressions.Field)?.concatTokens();
103436
+ if (name === undefined) {
103437
+ return code;
103438
+ }
103439
+ const escaped = traversal_1.Traversal.escapeNamespace(name)?.replace("~", "$").toLowerCase();
103440
+ const variable = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(name));
103441
+ if (escaped === undefined || code.startsWith(variable) === false) {
103442
+ return code;
103443
+ }
103444
+ return `${filterRow}.get().${escaped}` + code.substring(variable.length);
103445
+ }
102832
103446
  }
102833
103447
  exports.FilterBodyTranspiler = FilterBodyTranspiler;
102834
103448
  //# sourceMappingURL=filter_body.js.map
@@ -103896,141 +104510,278 @@ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@aba
103896
104510
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
103897
104511
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
103898
104512
  const target_1 = __webpack_require__(/*! ./target */ "./node_modules/@abaplint/transpiler/build/src/expressions/target.js");
104513
+ const let_1 = __webpack_require__(/*! ./let */ "./node_modules/@abaplint/transpiler/build/src/expressions/let.js");
104514
+ const statements_1 = __webpack_require__(/*! ../statements */ "./node_modules/@abaplint/transpiler/build/src/statements/index.js");
104515
+ const source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ "./node_modules/@abaplint/transpiler/build/src/expressions/source_field_symbol.js");
104516
+ const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
103899
104517
  class ReduceBodyTranspiler {
103900
104518
  transpile(typ, body, traversal) {
103901
104519
  if (!(typ.get() instanceof core_1.Expressions.TypeNameOrInfer)) {
103902
104520
  throw new Error("ReduceBodyTranspiler, Expected TypeNameOrInfer");
103903
104521
  }
103904
- else if (body.findDirectExpression(core_1.Expressions.Let) !== undefined) {
103905
- return new chunk_1.Chunk(`(() => { throw new Error("ReduceBodyTranspiler LET, not supported, transpiler"); })()`);
103906
- }
103907
104522
  const forExpressions = body.findDirectExpressions(core_1.Expressions.For);
103908
- const forExpression = forExpressions[0];
103909
104523
  if (forExpressions.length === 0) {
103910
104524
  throw new Error("ReduceBodyTranspiler, expected FOR");
103911
104525
  }
103912
- else if (forExpressions.length > 1) {
103913
- throw new Error("ReduceBodyTranspiler, multiple FOR not supported, " + body.concatTokens());
103914
- }
103915
- const loopExpression = forExpression.findDirectExpression(core_1.Expressions.InlineLoopDefinition);
103916
- if (loopExpression === undefined) {
103917
- // index based FOR, eg. "FOR i = 1 WHILE i <= 5"
103918
- return this.transpileIndex(body, forExpression, traversal);
103919
- }
103920
- else if (["THEN", "UNTIL", "WHILE", "FROM", "TO", "GROUPS"].some(token => forExpression.findDirectTokenByText(token))) {
103921
- throw new Error("ValueBody FOR todo, " + body.concatTokens());
103922
- }
103923
- const loopSource = traversal.traverse(loopExpression?.findDirectExpression(core_1.Expressions.Source)).getCode();
103924
- const loopVariable = traversal.traverse(loopExpression?.findDirectExpression(core_1.Expressions.TargetField)
103925
- || loopExpression?.findDirectExpression(core_1.Expressions.TargetFieldSymbol)).getCode();
103926
- // const type = new TypeNameOrInfer().findType(typ, traversal);
103927
- // const target = TranspileTypes.toType(type);
103928
104526
  const ret = new chunk_1.Chunk();
103929
104527
  ret.appendString("(await (async () => {\n");
103930
- let loopWhere = "";
103931
- const whereNode = forExpression?.findDirectExpression(core_1.Expressions.ComponentCond);
103932
- if (whereNode) {
103933
- const where = traversal.traverse(whereNode).getCode();
103934
- loopWhere = `, {"where": async ` + where + `}`;
104528
+ const outerLet = body.findDirectExpression(core_1.Expressions.Let);
104529
+ if (outerLet) {
104530
+ ret.appendString(new let_1.LetTranspiler().transpile(outerLet, traversal).getCode() + "\n");
103935
104531
  }
103936
- /*
103937
- const returnId = UniqueIdentifier.get();
103938
- ret.appendString(`const ${returnId} = ${target};\n`);
103939
- */
103940
104532
  const returnField = this.declareInit(body, traversal, ret);
103941
- ret.appendString(`for await (const ${loopVariable} of abap.statements.loop(${loopSource}${loopWhere})) {\n`);
103942
- ret.appendString(this.transpileNext(body, traversal));
103943
- ret.appendString(`}\n`);
104533
+ const declarations = [];
104534
+ const descriptors = forExpressions.map(forExpression => this.describeFor(forExpression, body, traversal, declarations));
104535
+ for (const declaration of declarations) {
104536
+ ret.appendString(declaration + "\n");
104537
+ }
104538
+ let indent = "";
104539
+ const levelIndents = [];
104540
+ for (const descriptor of descriptors) {
104541
+ this.appendBlocks(ret, descriptor.beforeLoop, indent);
104542
+ ret.appendString(indent + descriptor.open + "\n");
104543
+ indent += " ";
104544
+ levelIndents.push(indent);
104545
+ this.appendBlocks(ret, descriptor.preBody, indent);
104546
+ }
104547
+ this.appendBlock(ret, this.transpileNext(body, traversal), indent);
104548
+ for (let i = descriptors.length - 1; i >= 0; i--) {
104549
+ const descriptor = descriptors[i];
104550
+ const currentIndent = levelIndents[i];
104551
+ this.appendBlocks(ret, descriptor.postBody, currentIndent);
104552
+ indent = currentIndent.substring(0, Math.max(0, currentIndent.length - 2));
104553
+ ret.appendString(indent + descriptor.close + "\n");
104554
+ }
103944
104555
  ret.appendString(`return ${returnField};\n`);
103945
104556
  ret.appendString("})())");
103946
104557
  return ret;
103947
104558
  }
103948
- transpileIndex(body, forExpression, traversal) {
103949
- if (["FROM", "TO", "GROUPS"].some(token => forExpression.findDirectTokenByText(token))) {
103950
- throw new Error("ValueBody FOR todo, " + body.concatTokens());
104559
+ describeFor(forExpression, body, traversal, declarations) {
104560
+ if (forExpression.findDirectTokenByText("GROUPS")) {
104561
+ return this.describeGroupsFor(forExpression, body, traversal);
103951
104562
  }
103952
- const counter = forExpression.findDirectExpression(core_1.Expressions.InlineFieldDefinition);
103953
- if (counter === undefined) {
103954
- throw new Error("ValueBody FOR todo, " + body.concatTokens());
104563
+ const loopExpression = forExpression.findDirectExpression(core_1.Expressions.InlineLoopDefinition);
104564
+ if (loopExpression === undefined) {
104565
+ return this.describeIndexFor(forExpression, body, traversal);
104566
+ }
104567
+ const sourceNode = loopExpression.findDirectExpression(core_1.Expressions.Source);
104568
+ if (sourceNode === undefined) {
104569
+ throw new Error("ReduceBodyTranspiler FOR missing source, " + body.concatTokens());
104570
+ }
104571
+ const loopSource = traversal.traverse(sourceNode).getCode();
104572
+ const options = [];
104573
+ const whereNode = forExpression.findDirectExpression(core_1.Expressions.ComponentCond);
104574
+ if (whereNode) {
104575
+ options.push("where: async " + traversal.traverse(whereNode).getCode());
104576
+ }
104577
+ const fromNode = forExpression.findExpressionAfterToken("FROM");
104578
+ if (fromNode && fromNode instanceof core_1.Nodes.ExpressionNode) {
104579
+ options.push("from: " + traversal.traverse(fromNode).getCode());
104580
+ }
104581
+ const toNode = forExpression.findExpressionAfterToken("TO");
104582
+ if (toNode && toNode instanceof core_1.Nodes.ExpressionNode) {
104583
+ options.push("to: " + traversal.traverse(toNode).getCode());
104584
+ }
104585
+ const keyNode = loopExpression.findExpressionAfterToken("KEY");
104586
+ if (keyNode) {
104587
+ options.push(`usingKey: "${keyNode.concatTokens().toLowerCase()}"`);
104588
+ }
104589
+ const unique = unique_identifier_1.UniqueIdentifier.get();
104590
+ const preBody = [];
104591
+ const postBody = [];
104592
+ const fieldSymbol = loopExpression.findDirectExpression(core_1.Expressions.TargetFieldSymbol);
104593
+ if (fieldSymbol) {
104594
+ declarations.push(new statements_1.FieldSymbolTranspiler().transpile(fieldSymbol, traversal).getCode());
104595
+ const target = new source_field_symbol_1.SourceFieldSymbolTranspiler().transpile(fieldSymbol, traversal).getCode();
104596
+ preBody.push(`${target}.assign(${unique});`);
104597
+ postBody.push(`${target}.unassign();`);
104598
+ }
104599
+ else {
104600
+ const field = loopExpression.findDirectExpression(core_1.Expressions.TargetField);
104601
+ if (field === undefined) {
104602
+ throw new Error("ReduceBodyTranspiler FOR missing target, " + body.concatTokens());
104603
+ }
104604
+ preBody.push(`const ${traversal.traverse(field).getCode()} = ${unique}.clone();`);
104605
+ }
104606
+ const indexTarget = loopExpression.findExpressionAfterToken("INTO");
104607
+ const beforeLoop = [];
104608
+ if (indexTarget && indexTarget instanceof core_1.Nodes.ExpressionNode) {
104609
+ const indexName = unique_identifier_1.UniqueIdentifier.get();
104610
+ const indexCode = traversal.traverse(indexTarget).getCode();
104611
+ beforeLoop.push(`let ${indexName} = 1;`);
104612
+ preBody.push(`const ${indexCode} = new abap.types.Integer().set(${indexName});`);
104613
+ postBody.push(`${indexName}++;`);
104614
+ }
104615
+ const letNode = forExpression.findDirectExpression(core_1.Expressions.Let);
104616
+ if (letNode) {
104617
+ preBody.push(new let_1.LetTranspiler().transpile(letNode, traversal).getCode());
103955
104618
  }
104619
+ const opts = options.length === 0 ? "" : `, {${options.join(", ")}}`;
104620
+ return {
104621
+ beforeLoop,
104622
+ open: `for await (const ${unique} of abap.statements.loop(${loopSource}${opts})) {`,
104623
+ preBody,
104624
+ postBody,
104625
+ close: "}",
104626
+ };
104627
+ }
104628
+ describeGroupsFor(forExpression, body, traversal) {
104629
+ const targets = forExpression.findDirectExpressions(core_1.Expressions.TargetField);
104630
+ const source = forExpression.findDirectExpression(core_1.Expressions.Source);
104631
+ const groupBy = forExpression.findDirectExpression(core_1.Expressions.FieldChain);
104632
+ if (targets.length !== 2 || source === undefined || groupBy === undefined) {
104633
+ throw new Error("ReduceBodyTranspiler invalid GROUPS FOR, " + body.concatTokens());
104634
+ }
104635
+ const groupTarget = traversal.traverse(targets[0]).getCode();
104636
+ const memberTarget = traversal.traverse(targets[1]).getCode();
104637
+ const sourceCode = traversal.traverse(source).getCode();
104638
+ const groupByCode = traversal.traverse(groupBy).getCode();
104639
+ const groups = unique_identifier_1.UniqueIdentifier.get();
104640
+ const row = unique_identifier_1.UniqueIdentifier.get();
104641
+ const key = unique_identifier_1.UniqueIdentifier.get();
104642
+ const rawKey = unique_identifier_1.UniqueIdentifier.get();
104643
+ const entry = unique_identifier_1.UniqueIdentifier.get();
104644
+ const generator = `(async function*() {\n`
104645
+ + `const ${groups} = new Map();\n`
104646
+ + `for await (const ${row} of abap.statements.loop(${sourceCode})) {\n`
104647
+ + `const ${memberTarget} = ${row}.clone();\n`
104648
+ + `const ${key} = ${groupByCode};\n`
104649
+ + `const ${rawKey} = ${key}.get();\n`
104650
+ + `let ${entry} = ${groups}.get(${rawKey});\n`
104651
+ + `if (${entry} === undefined) {\n`
104652
+ + `${entry} = {key: ${key}.clone(), members: []};\n`
104653
+ + `${groups}.set(${rawKey}, ${entry});\n`
104654
+ + `}\n`
104655
+ + `${entry}.members.push(${row});\n`
104656
+ + `}\n`
104657
+ + `for (const value of ${groups}.values()) { yield value; }\n`
104658
+ + `})()`;
104659
+ const loopEntry = unique_identifier_1.UniqueIdentifier.get();
104660
+ return {
104661
+ beforeLoop: [],
104662
+ open: `for await (const ${loopEntry} of ${generator}) {`,
104663
+ preBody: [
104664
+ `const ${groupTarget} = ${loopEntry}.key.clone();`,
104665
+ `const ${memberTarget} = ${loopEntry}.members[0].clone();`,
104666
+ ],
104667
+ postBody: [],
104668
+ close: "}",
104669
+ };
104670
+ }
104671
+ describeIndexFor(forExpression, body, traversal) {
104672
+ const counter = forExpression.findDirectExpression(core_1.Expressions.InlineFieldDefinition);
103956
104673
  const cond = forExpression.findDirectExpression(core_1.Expressions.Cond);
103957
- if (cond === undefined) {
103958
- throw new Error("ValueBody FOR missing condition, " + body.concatTokens());
104674
+ if (counter === undefined || cond === undefined) {
104675
+ throw new Error("ReduceBodyTranspiler invalid index FOR, " + body.concatTokens());
103959
104676
  }
103960
104677
  const hasUntil = forExpression.findDirectTokenByText("UNTIL") !== undefined;
103961
104678
  const hasWhile = forExpression.findDirectTokenByText("WHILE") !== undefined;
103962
104679
  if ((hasUntil ? 1 : 0) + (hasWhile ? 1 : 0) !== 1) {
103963
- throw new Error("ValueBody FOR todo, condition, " + body.concatTokens());
104680
+ throw new Error("ReduceBodyTranspiler index FOR requires WHILE or UNTIL, " + body.concatTokens());
103964
104681
  }
103965
104682
  const fieldName = counter.findDirectExpression(core_1.Expressions.Field)?.concatTokens().toLowerCase();
103966
- if (fieldName === undefined) {
103967
- throw new Error("ValueBody FOR todo, inline field, " + body.concatTokens());
104683
+ const source = counter.findDirectExpression(core_1.Expressions.Source);
104684
+ if (fieldName === undefined || source === undefined) {
104685
+ throw new Error("ReduceBodyTranspiler invalid index definition, " + body.concatTokens());
103968
104686
  }
103969
- const scope = traversal.findCurrentScopeByToken(counter.getFirstToken());
103970
- const variable = scope?.findVariable(fieldName);
104687
+ const variable = traversal.findCurrentScopeByToken(counter.getFirstToken())?.findVariable(fieldName);
103971
104688
  if (variable === undefined) {
103972
- throw new Error("ValueBody FOR todo, variable, " + body.concatTokens());
104689
+ throw new Error(`ReduceBodyTranspiler: variable ${fieldName} not found`);
103973
104690
  }
103974
104691
  const counterName = traversal_1.Traversal.prefixVariable(fieldName);
103975
- const startSource = counter.findDirectExpression(core_1.Expressions.Source);
103976
- if (startSource === undefined) {
103977
- throw new Error("ValueBody FOR missing initial value, " + body.concatTokens());
103978
- }
103979
- const start = traversal.traverse(startSource).getCode();
103980
104692
  const thenExpr = forExpression.findExpressionAfterToken("THEN");
103981
- let incrementExpression = "";
103982
- if (thenExpr && thenExpr instanceof core_1.Nodes.ExpressionNode) {
103983
- incrementExpression = traversal.traverse(thenExpr).getCode();
103984
- }
103985
- else {
103986
- incrementExpression = `abap.operators.add(${counterName}, new abap.types.Integer().set(1))`;
103987
- }
104693
+ const increment = thenExpr && thenExpr instanceof core_1.Nodes.ExpressionNode
104694
+ ? traversal.traverse(thenExpr).getCode()
104695
+ : `abap.operators.add(${counterName}, new abap.types.Integer().set(1))`;
103988
104696
  const condCode = traversal.traverse(cond).getCode();
103989
- const ret = new chunk_1.Chunk();
103990
- ret.appendString("(await (async () => {\n");
103991
- const returnField = this.declareInit(body, traversal, ret);
103992
- ret.appendString(transpile_types_1.TranspileTypes.declare(variable) + `\n`);
103993
- ret.appendString(`${counterName}.set(${start});\n`);
103994
- ret.appendString(`while (true) {\n`);
104697
+ const preBody = [];
104698
+ const postBody = [`${counterName}.set(${increment});`];
103995
104699
  if (hasWhile) {
103996
- ret.appendString(`if (!(${condCode})) {\nbreak;\n}\n`);
104700
+ preBody.push(`if (!(${condCode})) {\nbreak;\n}`);
104701
+ }
104702
+ const letNode = forExpression.findDirectExpression(core_1.Expressions.Let);
104703
+ if (letNode) {
104704
+ preBody.push(new let_1.LetTranspiler().transpile(letNode, traversal).getCode());
103997
104705
  }
103998
- ret.appendString(this.transpileNext(body, traversal));
103999
- ret.appendString(`${counterName}.set(${incrementExpression});\n`);
104000
104706
  if (hasUntil) {
104001
- ret.appendString(`if (${condCode}) {\nbreak;\n}\n`);
104707
+ postBody.push(`if (${condCode}) {\nbreak;\n}`);
104002
104708
  }
104003
- ret.appendString(`}\n`);
104004
- ret.appendString(`return ${returnField};\n`);
104005
- ret.appendString("})())");
104006
- return ret;
104709
+ return {
104710
+ beforeLoop: [transpile_types_1.TranspileTypes.declare(variable), `${counterName}.set(${traversal.traverse(source).getCode()});`],
104711
+ open: "while (true) {",
104712
+ preBody,
104713
+ postBody,
104714
+ close: "}",
104715
+ };
104007
104716
  }
104008
104717
  declareInit(body, traversal, ret) {
104009
104718
  let returnField = "";
104010
104719
  for (const init of body.findDirectExpressions(core_1.Expressions.InlineFieldDefinition)) {
104011
- const fieldName = init.findDirectExpression(core_1.Expressions.Field).concatTokens().toLowerCase();
104012
- returnField = fieldName;
104013
- const scope = traversal.findCurrentScopeByToken(init.getFirstToken());
104014
- const variable = scope?.findVariable(fieldName);
104720
+ const fieldName = init.findDirectExpression(core_1.Expressions.Field)?.concatTokens().toLowerCase();
104721
+ if (fieldName === undefined) {
104722
+ throw new Error("ReduceBodyTranspiler INIT missing field");
104723
+ }
104724
+ if (returnField === "") {
104725
+ returnField = traversal_1.Traversal.prefixVariable(fieldName);
104726
+ }
104727
+ const variable = traversal.findCurrentScopeByToken(init.getFirstToken())?.findVariable(fieldName);
104015
104728
  if (variable === undefined) {
104016
104729
  throw new Error(`ReduceBodyTranspiler: variable ${fieldName} not found`);
104017
104730
  }
104018
- ret.appendString(transpile_types_1.TranspileTypes.declare(variable) + `\n`);
104731
+ const target = traversal_1.Traversal.prefixVariable(fieldName);
104732
+ ret.appendString(transpile_types_1.TranspileTypes.declare(variable) + "\n");
104733
+ const source = init.findDirectExpression(core_1.Expressions.Source);
104734
+ if (source) {
104735
+ ret.appendString(`${target}.set(${traversal.traverse(source).getCode()});\n`);
104736
+ }
104737
+ }
104738
+ if (returnField === "") {
104739
+ throw new Error("ReduceBodyTranspiler INIT missing");
104019
104740
  }
104020
104741
  return returnField;
104021
104742
  }
104022
104743
  transpileNext(body, traversal) {
104023
104744
  let ret = "";
104024
- for (const nextChild of body.findDirectExpression(core_1.Expressions.ReduceNext)?.getChildren() || []) {
104025
- if (nextChild.get() instanceof core_1.Expressions.SimpleTarget && nextChild instanceof core_1.Nodes.ExpressionNode) {
104026
- ret += new target_1.TargetTranspiler().transpile(nextChild, traversal).getCode() + ".set(";
104027
- }
104028
- else if (nextChild.get() instanceof core_1.Expressions.Source && nextChild instanceof core_1.Nodes.ExpressionNode) {
104029
- ret += traversal.traverse(nextChild).getCode() + ");\n";
104745
+ const children = body.findDirectExpression(core_1.Expressions.ReduceNext)?.getChildren() || [];
104746
+ for (let i = 0; i < children.length; i++) {
104747
+ const child = children[i];
104748
+ if (!(child instanceof core_1.Nodes.ExpressionNode) || !(child.get() instanceof core_1.Expressions.SimpleTarget)) {
104749
+ continue;
104030
104750
  }
104751
+ const source = children.slice(i + 1).find(candidate => candidate instanceof core_1.Nodes.ExpressionNode && candidate.get() instanceof core_1.Expressions.Source);
104752
+ if (!(source instanceof core_1.Nodes.ExpressionNode)) {
104753
+ throw new Error("ReduceBodyTranspiler NEXT missing source");
104754
+ }
104755
+ const target = new target_1.TargetTranspiler().transpile(child, traversal).getCode();
104756
+ const value = traversal.traverse(source).getCode();
104757
+ const between = children.slice(i + 1, children.indexOf(source)).map(candidate => candidate.concatTokens()).join("");
104758
+ const operators = {
104759
+ "+=": "add",
104760
+ "-=": "minus",
104761
+ "*=": "multiply",
104762
+ "/=": "divide",
104763
+ "&&=": "concat",
104764
+ };
104765
+ const operator = operators[between];
104766
+ ret += operator
104767
+ ? `${target}.set(abap.operators.${operator}(${target}, ${value}));\n`
104768
+ : `${target}.set(${value});\n`;
104769
+ i = children.indexOf(source);
104031
104770
  }
104032
104771
  return ret;
104033
104772
  }
104773
+ appendBlocks(ret, blocks, indent) {
104774
+ for (const block of blocks) {
104775
+ this.appendBlock(ret, block, indent);
104776
+ }
104777
+ }
104778
+ appendBlock(ret, block, indent) {
104779
+ for (const line of block.split("\n")) {
104780
+ if (line.trim() !== "") {
104781
+ ret.appendString(indent + line.replace(/\r/g, "") + "\n");
104782
+ }
104783
+ }
104784
+ }
104034
104785
  }
104035
104786
  exports.ReduceBodyTranspiler = ReduceBodyTranspiler;
104036
104787
  //# sourceMappingURL=reduce_body.js.map
@@ -104679,14 +105430,34 @@ class SQLCondTranspiler {
104679
105430
  return sourceWithComponents;
104680
105431
  }
104681
105432
  let ret = "";
105433
+ let hostExpression = false;
104682
105434
  for (const child of node.getChildren()) {
105435
+ if (!(child instanceof abaplint.Nodes.ExpressionNode) && child.getFirstToken().getStr() === "@") {
105436
+ hostExpression = true;
105437
+ continue;
105438
+ }
104683
105439
  if (ret !== "") {
104684
105440
  ret += " ";
104685
105441
  }
104686
- if ((child.get() instanceof abaplint.Expressions.SQLFieldName
105442
+ if (hostExpression
105443
+ && child instanceof abaplint.Nodes.ExpressionNode
105444
+ && child.get() instanceof abaplint.Expressions.SimpleSource3) {
105445
+ const code = new simple_source3_1.SimpleSource3Transpiler(true).transpile(child, traversal).getCode();
105446
+ ret += `'" + ${code} + "'`;
105447
+ hostExpression = false;
105448
+ }
105449
+ else if ((child.get() instanceof abaplint.Expressions.SQLFieldName
104687
105450
  || child.get() instanceof abaplint.Expressions.SQLAliasField)
104688
105451
  && child instanceof abaplint.Nodes.ExpressionNode) {
104689
- ret += new sql_field_name_1.SQLFieldNameTranspiler().transpile(child, traversal).getCode();
105452
+ if (hostExpression) {
105453
+ let name = traversal.prefixAndName(child.getFirstToken(), filename).replace("~", "$");
105454
+ name = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(name));
105455
+ ret += `'" + ${name}.get() + "'`;
105456
+ hostExpression = false;
105457
+ }
105458
+ else {
105459
+ ret += new sql_field_name_1.SQLFieldNameTranspiler().transpile(child, traversal).getCode();
105460
+ }
104690
105461
  }
104691
105462
  else if (child.get() instanceof abaplint.Expressions.SQLSource
104692
105463
  && child instanceof abaplint.Nodes.ExpressionNode) {
@@ -114260,7 +115031,7 @@ class PerformTranspiler {
114260
115031
  index++;
114261
115032
  }
114262
115033
  index = 0;
114263
- for (const u of node.findDirectExpression(abaplint.Expressions.PerformUsing)?.findDirectExpressions(abaplint.Expressions.Source) || []) {
115034
+ for (const u of node.findDirectExpression(abaplint.Expressions.PerformUsing)?.findDirectExpressions(abaplint.Expressions.SimpleSource3) || []) {
114264
115035
  const name = def?.getUsingParameters()[index].getName().toLowerCase();
114265
115036
  if (name === undefined) {
114266
115037
  continue;
@@ -128033,7 +128804,7 @@ module.exports = require("util");
128033
128804
  \**************************************************/
128034
128805
  (module) {
128035
128806
 
128036
- (()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>xe,XMLParser:()=>Jt,XMLValidator:()=>be});const i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=new RegExp("^["+i+"]["+i+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function r(t,e){const i=[];let n=e.exec(t);for(;n;){const r=[];r.startIndex=e.lastIndex-n[0].length;const s=n.length;for(let t=0;t<s;t++)r.push(n[t]);i.push(r),n=e.exec(t)}return i}const s=function(t){return!(null==n.exec(t))},o=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],a=["__proto__","constructor","prototype"],l={allowBooleanAttributes:!1,unpairedTags:[]};function p(t,e){e=Object.assign({},l,e);const i=[];let n=!1,r=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let s=0;s<t.length;s++)if("<"===t[s]&&"?"===t[s+1]){if(s+=2,s=h(t,s),s.err)return s}else{if("<"!==t[s]){if(c(t[s]))continue;return y("InvalidChar","char '"+t[s]+"' is not expected.",w(t,s))}{let o=s;if(s++,"!"===t[s]){s=d(t,s);continue}{let a=!1;"/"===t[s]&&(a=!0,s++);let l="";for(;s<t.length&&">"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)l+=t[s];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),s--),!E(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",y("InvalidTag",e,w(t,s))}const p=g(t,s);if(!1===p)return y("InvalidAttr","Attributes for '"+l+"' have open quote.",w(t,s));let u=p.value;if(s=p.index,"/"===u[u.length-1]){const i=s-u.length;u=u.substring(0,u.length-1);const r=x(u,e);if(!0!==r)return y(r.err.code,r.err.msg,w(t,i+r.err.line));n=!0}else if(a){if(!p.tagClosed)return y("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",w(t,s));if(u.trim().length>0)return y("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",w(t,o));if(0===i.length)return y("InvalidTag","Closing tag '"+l+"' has not been opened.",w(t,o));{const e=i.pop();if(l!==e.tagName){let i=w(t,e.tagStartPos);return y("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+i.line+", col "+i.col+") instead of closing tag '"+l+"'.",w(t,o))}0==i.length&&(r=!0)}}else{const a=x(u,e);if(!0!==a)return y(a.err.code,a.err.msg,w(t,s-u.length+a.err.line));if(!0===r)return y("InvalidXml","Multiple possible root nodes found.",w(t,s));-1!==e.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:o}),n=!0}for(s++;s<t.length;s++)if("<"===t[s]){if("!"===t[s+1]){s++,s=d(t,s);continue}if("?"!==t[s+1])break;if(s=h(t,++s),s.err)return s}else if("&"===t[s]){const e=b(t,s);if(-1==e)return y("InvalidChar","char '&' is not expected.",w(t,s));s=e}else if(!0===r&&!c(t[s]))return y("InvalidXml","Extra text at the end",w(t,s));"<"===t[s]&&s--}}}return n?1==i.length?y("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",w(t,i[0].tagStartPos)):!(i.length>0)||y("InvalidXml","Invalid '"+JSON.stringify(i.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):y("InvalidXml","Start tag expected.",1)}function c(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function h(t,e){const i=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const n=t.substr(i,e-i);if(e>5&&"xml"===n)return y("InvalidXml","XML declaration allowed only at the start of the document.",w(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let i=1;for(e+=8;e<t.length;e++)if("<"===t[e])i++;else if(">"===t[e]&&(i--,0===i))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const u='"',f="'";function g(t,e){let i="",n="",r=!1;for(;e<t.length;e++){if(t[e]===u||t[e]===f)""===n?n=t[e]:n!==t[e]||(n="");else if(">"===t[e]&&""===n){r=!0;break}i+=t[e]}return""===n&&{value:i,index:e,tagClosed:r}}const m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function x(t,e){const i=r(t,m),n={};for(let t=0;t<i.length;t++){if(0===i[t][1].length)return y("InvalidAttr","Attribute '"+i[t][2]+"' has no space in starting.",v(i[t]));if(void 0!==i[t][3]&&void 0===i[t][4])return y("InvalidAttr","Attribute '"+i[t][2]+"' is without value.",v(i[t]));if(void 0===i[t][3]&&!e.allowBooleanAttributes)return y("InvalidAttr","boolean attribute '"+i[t][2]+"' is not allowed.",v(i[t]));const r=i[t][2];if(!N(r))return y("InvalidAttr","Attribute '"+r+"' is an invalid name.",v(i[t]));if(Object.prototype.hasOwnProperty.call(n,r))return y("InvalidAttr","Attribute '"+r+"' is repeated.",v(i[t]));n[r]=1}return!0}function b(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let i=/\d/;for("x"===t[e]&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(i))break}return-1}(t,++e);let i=0;for(;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(";"===t[e])break;return-1}return e}function y(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function N(t){return s(t)}function E(t){return s(t)}function w(t,e){const i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function v(t){return t.startIndex+t[1].length}const S=t=>o.includes(t)?"__"+t:t,A={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,i){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:S};function T(t,e){if("string"!=typeof t)return;const i=t.toLowerCase();if(o.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(a.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function _(t,e){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null,appliesTo:t.appliesTo??"all"}:_(!0)}const C=function(t){const e=Object.assign({},A,t),i=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:t,name:e}of i)t&&T(t,e);return null===e.onDangerousProperty&&(e.onDangerousProperty=S),e.processEntities=_(e.processEntities,e.htmlEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),e};let $;$="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class O{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][$]={startIndex:e})}static getMetaDataSymbol(){return $}}const P=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",j=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",I=j+"\\-\\.\\d·̀-ͯ҇‿-⁀",k=(t,e,i="")=>{const n=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${n}$`,i),qName:new RegExp(`^${n}(?::${n})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},L=k(P,P+"\\-\\.\\d·̀-ͯ‿-⁀"),D=k(j,I,"u"),R=(t,{xmlVersion:e="1.0"}={})=>((t="1.0")=>"1.1"===t?D:L)(e).qName.test(t);class M{constructor(t,e){this.suppressValidationErr=!t,this.options=t,this.xmlVersion=e||1}setXmlVersion(t=1){this.xmlVersion=t}readDocType(t,e){const i=Object.create(null);let n=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,s=!1,o=!1,a="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?s=!0:a+=t[e];else{if(s&&q(t,"!ENTITY",e)){let r,s;if(e+=7,[r,s,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===s.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[r]=s,n++}}else if(s&&q(t,"!ELEMENT",e)){e+=8;const{index:i}=this.readElementExp(t,e+1);e=i}else if(s&&q(t,"!ATTLIST",e))e+=8;else if(s&&q(t,"!NOTATION",e)){e+=9;const{index:i}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=i}else{if(!q(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,a=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}}readEntityExp(t,e){const i=e=V(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let n=t.substring(i,e);if(F(n,{xmlVersion:this.xmlVersion}),e=V(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}let r="";if([e,r]=this.readIdentifierVal(t,e,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[n,r,--e]}readNotationExp(t,e){const i=e=V(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);!this.suppressValidationErr&&F(n,{xmlVersion:this.xmlVersion}),e=V(t,e);const r=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);e+=r.length,e=V(t,e);let s=null,o=null;if("PUBLIC"===r)[e,s]=this.readIdentifierVal(t,e,"publicIdentifier"),'"'!==t[e=V(t,e)]&&"'"!==t[e]||([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"));else if("SYSTEM"===r&&([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:s,systemIdentifier:o,index:--e}}readIdentifierVal(t,e,i){let n="";const r=t[e];if('"'!==r&&"'"!==r)throw new Error(`Expected quoted string, found "${r}"`);const s=++e;for(;e<t.length&&t[e]!==r;)e++;if(n=t.substring(s,e),t[e]!==r)throw new Error(`Unterminated ${i} value`);return[++e,n]}readElementExp(t,e){const i=e=V(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);if(!this.suppressValidationErr&&!R(n,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${n}"`);let r="";if("E"===t[e=V(t,e)]&&q(t,"MPTY",e))e+=4;else if("A"===t[e]&&q(t,"NY",e))e+=2;else if("("===t[e]){const i=++e;for(;e<t.length&&")"!==t[e];)e++;if(r=t.substring(i,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[e]}"`);return{elementName:n,contentModel:r.trim(),index:e}}readAttlistExp(t,e){let i=e=V(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);for(F(n,{xmlVersion:this.xmlVersion}),i=e=V(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let r=t.substring(i,e);if(!F(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${r}"`);e=V(t,e);let s="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(s="NOTATION","("!==t[e=V(t,e+=8)])throw new Error(`Expected '(', found "${t[e]}"`);e++;let i=[];for(;e<t.length&&")"!==t[e];){const n=e;for(;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;let r=t.substring(n,e);if(r=r.trim(),!F(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${r}"`);i.push(r),"|"===t[e]&&(e++,e=V(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,s+=" ("+i.join("|")+")"}else{const i=e;for(;e<t.length&&!/\s/.test(t[e]);)e++;s+=t.substring(i,e);const n=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!n.includes(s.toUpperCase()))throw new Error(`Invalid attribute type: "${s}"`)}e=V(t,e);let o="";return"#REQUIRED"===t.substring(e,e+8).toUpperCase()?(o="#REQUIRED",e+=8):"#IMPLIED"===t.substring(e,e+7).toUpperCase()?(o="#IMPLIED",e+=7):[e,o]=this.readIdentifierVal(t,e,"ATTLIST"),{elementName:n,attributeName:r,attributeType:s,defaultValue:o,index:e}}}const V=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function q(t,e,i){for(let n=0;n<e.length;n++)if(e[n]!==t[i+n+1])return!1;return!0}function F(t,e){if(R(t,{xmlVersion:e}))return t;throw new Error(`Invalid entity name ${t}`)}const U=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],G=new Map,B=1632,W=new Uint8Array(63904).fill(255);for(const t of U)for(let e=0;e<10;e++){const i=t+e;i<=65535?W[i-B]=e:G.set(i,e)}const X=new Set([8722,65293,65123]),Y=/^[-+]?0x[a-fA-F0-9]+$/,z=/^0b[01]+$/,H=/^0o[0-7]+$/,Q=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,J={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function Z(t,e={}){if(e=Object.assign({},J,e),!t||"string"!=typeof t)return t;let i=t.trim();if(0===i.length)return t;if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===i)return 0;if(e.unicode&&(i=function(t){if("string"!=typeof t)return t;const e=t.length;if(0===e)return t;let i=-1;for(let n=0;n<e;n++){const r=t.charCodeAt(n);if(!(r>=48&&r<=57||45===r))if(r<B){if(X.has(r)){i=n;break}}else if(r>=55296&&r<=56319){if(n+1<e){const e=t.charCodeAt(n+1);if(e>=56320&&e<=57343){const t=65536+(r-55296<<10)+(e-56320);if(G.has(t)){i=n;break}}}}else if(255!==W[r-B]||X.has(r)){i=n;break}}if(-1===i)return t;const n=[];i>0&&n.push(t.slice(0,i));for(let r=i;r<e;r++){const i=t.charCodeAt(r);if(i>=48&&i<=57||45===i){n.push(t[r]);continue}if(i<B){n.push(X.has(i)?"-":t[r]);continue}if(i>=55296&&i<=56319){if(r+1<e){const e=t.charCodeAt(r+1);if(e>=56320&&e<=57343){const t=65536+(i-55296<<10)+(e-56320),s=G.get(t);if(void 0!==s){n.push(String.fromCharCode(s+48)),r++;continue}}}n.push(t[r]);continue}if(X.has(i)){n.push("-");continue}const s=W[i-B];n.push(255!==s?String.fromCharCode(s+48):t[r])}return n.join("")}(i),"0"===i))return 0;if(e.hex&&Y.test(i))return tt(i,16);if(e.binary&&z.test(i))return tt(i,2);if(e.octal&&H.test(i))return tt(i,8);if(isFinite(i)){if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const n=e.match(K);if(n){let r=n[1]||"";const s=-1===n[3].indexOf("e")?"E":"e",o=n[2],a=r?t[o.length+1]===s:t[o.length]===s;return o.length>1&&a?t:(1!==o.length||!n[3].startsWith(`.${s}`)&&n[3][0]!==s)&&o.length>0?i.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,i,e);{const r=Q.exec(i);if(r){const s=r[1]||"",o=r[2];let a=(n=r[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const l=s?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!l))return t;{const n=Number(i),r=String(n);if(0===n)return n;if(-1!==r.search(/[eE]/))return e.eNotation?n:t;if(-1!==i.indexOf("."))return"0"===r||r===a||r===`${s}${a}`?n:t;let l=o?a:i;return o?l===r||s+l===r?n:t:l===r||l===s+r?n:t}}return t}}var n;return function(t,e,i){const n=e===1/0;switch(i.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";default:return t}}(t,Number(i),e)}const K=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function tt(t,e){const i=t.trim();if(2!==e&&8!==e||(t=i.substring(2)),parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}class et{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class it{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new et(this)}push(t,e=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);const r=this.siblingStacks[n],s=i?`${i}:${t}`:t,o=r.get(s)||0;let a=0;for(const t of r.values())a+=t;r.set(s,o+1);const l={tag:t,position:a,counter:o};null!=i&&(l.namespace=i),null!=e&&(l.values=e),this.path.push(l)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const n=t[i];if("deep-wildcard"===n.type){if(i--,i<0)return!0;const n=t[i];let r=!1;for(let t=e;t>=0;t--)if(this._matchSegment(n,this.path[t],t===this.path.length-1)){e=t-1,i--,r=!0;break}if(!r)return!1}else{if(!this._matchSegment(n,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!i)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class nt{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,n="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(n.trim()&&(e.push(this._parseSegment(n.trim())),n=""),e.push({type:"deep-wildcard"}),i+=2):(n.trim()&&e.push(this._parseSegment(n.trim())),n="",i++):(n+=t[i],i++);return n.trim()&&e.push(this._parseSegment(n.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,n=t;const r=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(n=r[1]+r[3],r[2])){const t=r[2].slice(1,-1);t&&(i=t)}let s,o,a=n;if(n.includes("::")){const e=n.indexOf("::");if(s=n.substring(0,e).trim(),a=n.substring(e+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${t}`)}let l=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),i=a.substring(t+1).trim();["first","last","odd","even"].includes(i)||/^nth\(\d+\)$/.test(i)?(o=e,l=i):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,s&&(e.namespace=s),i)if(i.includes("=")){const t=i.indexOf("=");e.attrName=i.substring(0,t).trim(),e.attrValue=i.substring(t+1).trim()}else e.attrName=i.trim();if(l){const t=l.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=l}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class rt{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,i=t.segments[t.segments.length-1],n=i?.tag;if(n&&"*"!==n){const i=`${e}:${n}`;this._byDepthAndTag.has(i)||this._byDepthAndTag.set(i,[]),this._byDepthAndTag.get(i).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),i=`${e}:${t.getCurrentTag()}`,n=this._byDepthAndTag.get(i);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];const r=this._wildcardByDepth.get(e);if(r)for(let e=0;e<r.length;e++)if(t.matches(r[e]))return r[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const st={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},ot={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},at={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},lt=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),pt=new Set("!?\\\\/[]$%{}^&*()<>|+");function ct(t){if("#"===t[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t}"`);for(const e of t)if(pt.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${t}"`);return t}function ht(...t){const e=Object.create(null);for(const i of t)if(i)for(const t of Object.keys(i)){const n=i[t];if("string"==typeof n)e[t]=n;else if(n&&"object"==typeof n&&void 0!==n.val){const i=n.val;"string"==typeof i&&(e[t]=i)}}return e}const dt="external",ut="base",ft="all",gt=Object.freeze({allow:0,leave:1,remove:2,throw:3}),mt=new Set([9,10,13]);class xt{constructor(t={}){var e;this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:t=>t,this._limitTiers=(e=this._limit.applyLimitsTo??dt)&&e!==dt?e===ft?new Set([ft]):e===ut?new Set([ut]):Array.isArray(e)?new Set(e):new Set([dt]):new Set([dt]),this._numericAllowed=t.numericAllowed??!0,this._baseMap=ht(ot,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const i=function(t){if(!t)return{xmlVersion:1,onLevel:gt.allow,nullLevel:gt.remove};const e=1.1===t.xmlVersion?1.1:1,i=gt[t.onNCR]??gt.allow,n=gt[t.nullNCR]??gt.remove;return{xmlVersion:e,onLevel:i,nullLevel:Math.max(n,gt.remove)}}(t.ncr);this._ncrXmlVersion=i.xmlVersion,this._ncrOnLevel=i.onLevel,this._ncrNullLevel=i.nullLevel,this._onExternalEntity="function"==typeof t.onExternalEntity?t.onExternalEntity:null,this._onInputEntity="function"==typeof t.onInputEntity?t.onInputEntity:null}_applyRegistrationHook(t,e,i,n){if(!t)return!0;const r=t(e,i);if(r===lt.BLOCK)return!1;if(r===lt.THROW)throw new Error(`[EntityDecoder] Registration of ${n} entity "&${e};" was rejected by hook`);return!0}setExternalEntities(t){if(t)for(const e of Object.keys(t))ct(e);if(!this._onExternalEntity)return void(this._externalMap=ht(t));const e=ht(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onExternalEntity,t,n,"external")&&(i[t]=n);this._externalMap=i}addExternalEntity(t,e){ct(t),"string"==typeof e&&-1===e.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,t,e,"external")&&(this._externalMap[t]=e)}addInputEntities(t){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=ht(t));const e=ht(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onInputEntity,t,n,"input")&&(i[t]=n);this._inputMap=i}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;if(-1===t.indexOf("&"))return t;const e=t,i=[],n=t.length;let r=0,s=0;const o=this._maxTotalExpansions>0,a=this._maxExpandedLength>0,l=o||a;for(;s<n;){if(38!==t.charCodeAt(s)){s++;continue}let e=s+1;for(;e<n&&59!==t.charCodeAt(e)&&e-s<=32;)e++;if(e>=n||59!==t.charCodeAt(e)){s++;continue}const p=t.slice(s+1,e);if(0===p.length){s++;continue}let c,h;if(this._removeSet.has(p))c="",void 0===h&&(h=dt);else{if(this._leaveSet.has(p)){s++;continue}if(35===p.charCodeAt(0)){const t=this._resolveNCR(p);if(void 0===t){s++;continue}c=t,h=ut}else{const t=this._resolveName(p);c=t?.value,h=t?.tier}}if(void 0!==c){if(s>r&&i.push(t.slice(r,s)),i.push(c),r=e+1,s=r,l&&this._tierCounts(h)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(a){const t=c.length-(p.length+2);if(t>0&&(this._expandedLength+=t,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else s++}r<n&&i.push(t.slice(r));const p=0===i.length?t:i.join("");return this._postCheck(p,e)}_tierCounts(t){return!!this._limitTiers.has(ft)||this._limitTiers.has(t)}_resolveName(t){return t in this._inputMap?{value:this._inputMap[t],tier:dt}:t in this._externalMap?{value:this._externalMap[t],tier:dt}:t in this._baseMap?{value:this._baseMap[t],tier:ut}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!mt.has(t)?gt.remove:-1}_applyNCRAction(t,e,i){switch(t){case gt.allow:return String.fromCodePoint(i);case gt.remove:return"";case gt.leave:return;case gt.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const n=this._classifyNCR(i);if(!this._numericAllowed&&n<gt.remove)return;const r=-1===n?this._ncrOnLevel:Math.max(this._ncrOnLevel,n);return this._applyNCRAction(r,t,i)}}const bt=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ — unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT — most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE — destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE — destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO — data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM — data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET — data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ — MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:'Classic string tautology: \' OR \'1\'=\'1 or " OR "1"="1"',pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function — used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA — reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],yt="[\"'\\s]*:",Nt={HTML:[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() — IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= — can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" — can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes — embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag — can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],XML:[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content — can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword — used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword — used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration — defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection — can redefine namespaces to confuse parsers",pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"\x3c!-- comment injection — can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--\x3e closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],SVG:[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: — classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG — can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" — can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." — sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= — filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],SQL:bt,"SQL-STRICT":[...bt,{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],SHELL:[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ — climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ — climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 — truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r — can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? — can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags — can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],REDOS:[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern — triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} — repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches — polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],NOSQL:[{id:"nosql-where-operator",description:"$where — executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${yt}`,"i")},{id:"nosql-ne-operator",description:'$ne — "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${yt}`,"i")},{id:"nosql-gt-operator",description:'$gt — "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${yt}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte — "less than" bypass variants',pattern:new RegExp(`\\$lte?${yt}`,"i")},{id:"nosql-regex-operator",description:"$regex — can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${yt}`,"i")},{id:"nosql-or-operator",description:"$or — logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${yt}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and — logical AND operator injection",pattern:new RegExp(`\\$and${yt}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor — logical NOR operator injection",pattern:new RegExp(`\\$nor${yt}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists — can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${yt}`,"i")},{id:"nosql-in-operator",description:"$in — matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${yt}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr — allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${yt}`,"i")},{id:"nosql-function-operator",description:"$function — executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${yt}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator — custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${yt}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ — prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] — bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],LOG:[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}]},Et=Nt,wt=Object.freeze(Object.fromEntries(Object.keys(Nt).map(t=>[t,t])));function vt(t,e){const i=Et[e];for(const n of i)if(n.pattern.test(t))return{context:e,id:n.id,description:n.description,pattern:n.pattern};return null}function St(t,e){if(function(t){if("string"!=typeof t)throw new TypeError("is-unsafe: first argument must be a string, got "+typeof t)}(t),function(t){if(!(t instanceof RegExp))if("string"!=typeof t){if(!Array.isArray(t))throw new TypeError("is-unsafe: second argument must be a context string, array of context strings, or RegExp. Got: "+typeof t);if(0===t.length)throw new TypeError("is-unsafe: context array must not be empty");for(const e of t)if("string"!=typeof e||!Et[e])throw new TypeError(`is-unsafe: unknown context "${e}" in array. Valid contexts: ${Object.keys(wt).join(", ")}`)}else if(!Et[t])throw new TypeError(`is-unsafe: unknown context "${t}". Valid contexts: ${Object.keys(wt).join(", ")}`)}(e),e instanceof RegExp)return e.test(t);if("string"==typeof e)return null!==vt(t,e);for(const i of e)if(null!==vt(t,i))return!0;return!1}function At(t,e){if(!t)return{};const i=e.attributesGroupName?t[e.attributesGroupName]:t;if(!i)return{};const n={};for(const t in i)t.startsWith(e.attributeNamePrefix)?n[t.substring(e.attributeNamePrefix.length)]=i[t]:n[t]=i[t];return n}function Tt(t){if(!t||"string"!=typeof t)return;const e=t.indexOf(":");if(-1!==e&&e>0){const i=t.substring(0,e);if("xmlns"!==i)return i}}class _t{constructor(t,e){var i;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=jt,this.parseTextData=Ct,this.resolveNameSpace=$t,this.buildAttributesMap=Pt,this.isItStopNode=Dt,this.replaceEntitiesValue=kt,this.readStopNodeData=qt,this.saveTextToParentTag=Lt,this.addChild=It,this.ignoreAttributesFn="function"==typeof(i=this.options.ignoreAttributes)?i:Array.isArray(i)?t=>{for(const e of i){if("string"==typeof e&&t===e)return!0;if(e instanceof RegExp&&e.test(t))return!0}}:()=>!1,this.entityExpansionCount=0,this.currentExpandedLength=0;let n={...ot};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?n=this.options.htmlEntities:!0===this.options.htmlEntities&&(n={...at,...st}),this.entityDecoder=new xt({namedEntities:{...n,...e},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(t,e)=>St(e,[wt.HTML,wt.XML])?lt.BLOCK:lt.ALLOW})),this.matcher=new it,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new rt;const r=this.options.stopNodes;if(r&&r.length>0){for(let t=0;t<r.length;t++){const e=r[t];"string"==typeof e?this.stopNodeExpressionsSet.add(new nt(e)):e instanceof nt&&this.stopNodeExpressionsSet.add(e)}this.stopNodeExpressionsSet.seal()}}}function Ct(t,e,i,n,r,s,o){const a=this.options;if(void 0!==t&&(a.trimValues&&!n&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t,e,i));const n=a.jPath?i.toString():i,l=a.tagValueProcessor(e,t,n,r,s);return null==l?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?Ft(t,a.parseTagValue,a.numberParseOptions):t}}function $t(t){if(this.options.removeNSPrefix){const e=t.split(":"),i="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=i+e[1])}return t}const Ot=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Pt(t,e,i,n=!1){const s=this.options;if(!0===n||!0!==s.ignoreAttributes&&"string"==typeof t){const n=r(t,Ot),o=n.length,a={},l=new Array(o);let p=!1;const c={};for(let t=0;t<o;t++){const e=this.resolveNameSpace(n[t][1]),r=n[t][4];if(e.length&&void 0!==r){let n=r;s.trimValues&&(n=n.trim()),n=this.replaceEntitiesValue(n,i,this.readonlyMatcher),l[t]=n,c[e]=n,p=!0}}p&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(c);const h=s.jPath?e.toString():this.readonlyMatcher;let d=!1;for(let t=0;t<o;t++){const e=this.resolveNameSpace(n[t][1]);if(this.ignoreAttributesFn(e,h))continue;let i=s.attributeNamePrefix+e;if(e.length)if(s.transformAttributeName&&(i=s.transformAttributeName(i)),i=Gt(i,s),void 0!==n[t][4]){const n=l[t],r=s.attributeValueProcessor(e,n,h);a[i]=null==r?n:typeof r!=typeof n||r!==n?r:Ft(n,s.parseAttributeValue,s.numberParseOptions),d=!0}else s.allowBooleanAttributes&&(a[i]=!0,d=!0)}if(!d)return;if(s.attributesGroupName&&!s.preserveOrder){const t={};return t[s.attributesGroupName]=a,t}return a}}const jt=function(t){t=t.replace(/\r\n?/g,"\n");const e=new O("!xml");let i=e,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const r=this.options,s=new M(r.processEntities),o=t.length;for(let a=0;a<o;a++)if("<"===t[a]){const l=t.charCodeAt(a+1);if(47===l){const e=Rt(t,">",a,"Closing Tag is not closed.");let s=t.substring(a+2,e).trim();if(r.removeNSPrefix){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}s=Ut(r.transformTagName,s,"",r).tagName,i&&(n=this.saveTextToParentTag(n,i,this.readonlyMatcher));const o=this.matcher.getCurrentTag();if(s&&r.unpairedTagsSet.has(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);o&&r.unpairedTagsSet.has(o)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop(),n="",a=e}else if(63===l){let e=Vt(t,a,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");n=this.saveTextToParentTag(n,i,this.readonlyMatcher);const o=this.buildAttributesMap(e.tagExp,this.matcher,e.tagName,!0);if(o){const t=o[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(t)||1),s.setXmlVersion(Number(t)||1)}if(r.ignoreDeclaration&&"?xml"===e.tagName||r.ignorePiTags);else{const t=new O(e.tagName);t.add(r.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&!0!==r.ignoreAttributes&&(t[":@"]=o),this.addChild(i,t,this.readonlyMatcher,a)}a=e.closeIndex+1}else if(33===l&&45===t.charCodeAt(a+2)&&45===t.charCodeAt(a+3)){const e=Rt(t,"--\x3e",a+4,"Comment is not closed.");if(r.commentPropName){const s=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,i,this.readonlyMatcher),i.add(r.commentPropName,[{[r.textNodeName]:s}])}a=e}else if(33===l&&68===t.charCodeAt(a+2)){const e=s.readDocType(t,a);this.entityDecoder.addInputEntities(e.entities),a=e.i}else if(33===l&&91===t.charCodeAt(a+2)){const e=Rt(t,"]]>",a,"CDATA is not closed.")-2,s=t.substring(a+9,e);n=this.saveTextToParentTag(n,i,this.readonlyMatcher);let o=this.parseTextData(s,i.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==o&&(o=""),r.cdataPropName?i.add(r.cdataPropName,[{[r.textNodeName]:s}]):i.add(r.textNodeName,o),a=e+2}else{let s=Vt(t,a,r.removeNSPrefix);if(!s){const e=t.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${e}"`)}let l=s.tagName;const p=s.rawTagName;let c=s.tagExp,h=s.attrExpPresent,d=s.closeIndex;if(({tagName:l,tagExp:c}=Ut(r.transformTagName,l,c,r)),r.strictReservedNames&&(l===r.commentPropName||l===r.cdataPropName||l===r.textNodeName||l===r.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);i&&n&&"!xml"!==i.tagname&&(n=this.saveTextToParentTag(n,i,this.readonlyMatcher,!1));const u=i;u&&r.unpairedTagsSet.has(u.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());let f=!1;c.length>0&&c.lastIndexOf("/")===c.length-1&&(f=!0,"/"===l[l.length-1]?(l=l.substr(0,l.length-1),c=l):c=c.substr(0,c.length-1),h=l!==c);let g,m=null,x={};g=Tt(p),l!==e.tagname&&this.matcher.push(l,{},g),l!==c&&h&&(m=this.buildAttributesMap(c,this.matcher,l),m&&(x=At(m,r))),l!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const b=a;if(this.isCurrentNodeStopNode){let e="";if(f)a=s.closeIndex;else if(r.unpairedTagsSet.has(l))a=s.closeIndex;else{const i=this.readStopNodeData(t,p,d+1);if(!i)throw new Error(`Unexpected end of ${p}`);a=i.i,e=i.tagContent}const n=new O(l);m&&(n[":@"]=m),n.add(r.textNodeName,e),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,n,this.readonlyMatcher,b)}else{if(f){({tagName:l,tagExp:c}=Ut(r.transformTagName,l,c,r));const t=new O(l);m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(r.unpairedTagsSet.has(l)){const t=new O(l);m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=s.closeIndex;continue}{const t=new O(l);if(this.tagsNodeStack.length>r.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),i=t}}n="",a=d}}}else n+=t[a];return e.child};function It(t,e,i,n){this.options.captureMetaData||(n=void 0);const r=this.options.jPath?i.toString():i,s=this.options.updateTag(e.tagname,r,e[":@"]);!1===s||("string"==typeof s?(e.tagname=s,t.addChild(e,n)):t.addChild(e,n))}function kt(t,e,i){const n=this.options.processEntities;if(!n||!n.enabled)return t;if(n.allowedTags){const r=this.options.jPath?i.toString():i;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(e):n.allowedTags(e,r)))return t}if(n.tagFilter){const r=this.options.jPath?i.toString():i;if(!n.tagFilter(e,r))return t}return this.entityDecoder.decode(t)}function Lt(t,e,i,n){return t&&(void 0===n&&(n=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,i,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,n))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function Dt(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Rt(t,e,i,n){const r=t.indexOf(e,i);if(-1===r)throw new Error(n);return r+e.length-1}function Mt(t,e,i,n){const r=t.indexOf(e,i);if(-1===r)throw new Error(n);return r}function Vt(t,e,i,n=">"){const r=function(t,e,i=">"){let n=0;const r=t.length,s=i.charCodeAt(0),o=i.length>1?i.charCodeAt(1):-1;let a="",l=e;for(let i=e;i<r;i++){const e=t.charCodeAt(i);if(n)e===n&&(n=0);else if(34===e||39===e)n=e;else if(e===s){if(-1===o)return a+=t.substring(l,i),{data:a,index:i};if(t.charCodeAt(i+1)===o)return a+=t.substring(l,i),{data:a,index:i}}else 9!==e||n||(a+=t.substring(l,i)+" ",l=i+1)}}(t,e+1,n);if(!r)return;let s=r.data;const o=r.index,a=s.search(/\s/);let l=s,p=!0;-1!==a&&(l=s.substring(0,a),s=s.substring(a+1).trimStart());const c=l;if(i){const t=l.indexOf(":");-1!==t&&(l=l.substr(t+1),p=l!==r.data.substr(t+1))}return{tagName:l,tagExp:s,closeIndex:o,attrExpPresent:p,rawTagName:c}}function qt(t,e,i){const n=i;let r=1;const s=t.length;for(;i<s;i++)if("<"===t[i]){const s=t.charCodeAt(i+1);if(47===s){const s=Mt(t,">",i,`${e} is not closed`);if(t.substring(i+2,s).trim()===e&&(r--,0===r))return{tagContent:t.substring(n,i),i:s};i=s}else if(63===s)i=Rt(t,"?>",i+1,"StopNode is not closed.");else if(33===s&&45===t.charCodeAt(i+2)&&45===t.charCodeAt(i+3))i=Rt(t,"--\x3e",i+3,"StopNode is not closed.");else if(33===s&&91===t.charCodeAt(i+2))i=Rt(t,"]]>",i,"StopNode is not closed.")-2;else{const n=Vt(t,i,!1);n&&((n&&n.tagName)===e&&"/"!==n.tagExp[n.tagExp.length-1]&&r++,i=n.closeIndex)}}}function Ft(t,e,i){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&Z(t,i)}return void 0!==t?t:""}function Ut(t,e,i,n){if(t){const n=t(e);i===e&&(i=n),e=n}return{tagName:e=Gt(e,n),tagExp:i}}function Gt(t,e){if(a.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return o.includes(t)?e.onDangerousProperty(t):t}const Bt=O.getMetaDataSymbol();function Wt(t,e){if(!t||"object"!=typeof t)return{};if(!e)return t;const i={};for(const n in t)n.startsWith(e)?i[n.substring(e.length)]=t[n]:i[n]=t[n];return i}function Xt(t,e,i,n){return Yt(t,e,i,n)}function Yt(t,e,i,n){let r;const s={};for(let o=0;o<t.length;o++){const a=t[o],l=zt(a);if(void 0!==l&&l!==e.textNodeName){const t=Wt(a[":@"]||{},e.attributeNamePrefix);i.push(l,t)}if(l===e.textNodeName)void 0===r?r=a[l]:r+=""+a[l];else{if(void 0===l)continue;if(a[l]){let t=Yt(a[l],e,i,n);const r=Qt(t,e);if(0===Object.keys(t).length&&e.alwaysCreateTextNode&&(t[e.textNodeName]=""),a[":@"]?Ht(t,a[":@"],n,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==a[Bt]&&"object"==typeof t&&null!==t&&(t[Bt]=a[Bt]),void 0!==s[l]&&Object.prototype.hasOwnProperty.call(s,l))Array.isArray(s[l])||(s[l]=[s[l]]),s[l].push(t);else{const i=e.jPath?n.toString():n;e.isArray(l,i,r)?s[l]=[t]:s[l]=t}void 0!==l&&l!==e.textNodeName&&i.pop()}}}return"string"==typeof r?r.length>0&&(s[e.textNodeName]=r):void 0!==r&&(s[e.textNodeName]=r),s}function zt(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function Ht(t,e,i,n){if(e){const r=Object.keys(e),s=r.length;for(let o=0;o<s;o++){const s=r[o],a=s.startsWith(n.attributeNamePrefix)?s.substring(n.attributeNamePrefix.length):s,l=n.jPath?i.toString()+"."+a:i;n.isArray(s,l,!0,!0)?t[s]=[e[s]]:t[s]=e[s]}}}function Qt(t,e){const{textNodeName:i}=e,n=Object.keys(t).length;return 0===n||!(1!==n||!t[i]&&"boolean"!=typeof t[i]&&0!==t[i])}class Jt{constructor(t){this.externalEntities={},this.options=C(t)}parse(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});const i=p(t,e);if(!0!==i)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}const i=new _t(this.options,this.externalEntities),n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:Xt(n,this.options,i.matcher,i.readonlyMatcher)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return O.getMetaDataSymbol()}}function Zt(t){return String(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function Kt(t){return String(t).replace(/\]\]>/g,"]]]]><![CDATA[>")}function te(t){return String(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function ee(t,e,i,n,r){return i.sanitizeName?R(t,{xmlVersion:r})?t:i.sanitizeName(t,{isAttribute:e,matcher:n.readOnly()}):t}function ie(t,e){let i="";e.format&&(i="\n");const n=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const i=e.stopNodes[t];"string"==typeof i?n.push(new nt(i)):i instanceof nt&&n.push(i)}const r=function(t,e){if(!Array.isArray(t)||0===t.length)return"1.0";const i=t[0];if("?xml"===ae(i)){const t=i[":@"];if(t){const i=e.attributeNamePrefix+"version";if(t[i])return t[i]}}return"1.0"}(t,e);return ne(t,e,i,new it,n,r)}function ne(t,e,i,n,r,s){let o="",a=!1;if(e.maxNestedTags&&n.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=ce(i,e),i}return""}for(let l=0;l<t.length;l++){const p=t[l],c=ae(p);if(void 0===c)continue;const h=c===e.textNodeName||c===e.cdataPropName||c===e.commentPropName||"?"===c[0]?c:ee(c,!1,e,n,s),d=re(p[":@"],e);n.push(h,d);const u=pe(n,r);if(h===e.textNodeName){let t=p[c];u||(t=e.tagValueProcessor(h,t),t=ce(t,e)),a&&(o+=i),o+=t,a=!1,n.pop();continue}if(h===e.cdataPropName){a&&(o+=i),o+=`<![CDATA[${Kt(p[c][0][e.textNodeName])}]]>`,a=!1,n.pop();continue}if(h===e.commentPropName){o+=i+`\x3c!--${Zt(p[c][0][e.textNodeName])}--\x3e`,a=!0,n.pop();continue}if("?"===h[0]){o+=("?xml"===h?"":i)+`<${h}${le(p[":@"],e,u,n,s)}?>`,a=!0,n.pop();continue}let f=i;""!==f&&(f+=e.indentBy);const g=i+`<${h}${le(p[":@"],e,u,n,s)}`;let m;m=u?se(p[c],e):ne(p[c],e,f,n,r,s),-1!==e.unpairedTags.indexOf(h)?e.suppressUnpairedNode?o+=g+">":o+=g+"/>":m&&0!==m.length||!e.suppressEmptyNode?m&&m.endsWith(">")?o+=g+`>${m}${i}</${h}>`:(o+=g+">",m&&""!==i&&(m.includes("/>")||m.includes("</"))?o+=i+e.indentBy+m+i:o+=m,o+=`</${h}>`):o+=g+"/>",a=!0,n.pop()}return o}function re(t,e){if(!t||e.ignoreAttributes)return null;const i={};let n=!1;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r.startsWith(e.attributeNamePrefix)?r.substr(e.attributeNamePrefix.length):r]=te(t[r]),n=!0);return n?i:null}function se(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let i="";for(let n=0;n<t.length;n++){const r=t[n],s=ae(r);if(s===e.textNodeName)i+=r[s];else if(s===e.cdataPropName)i+=r[s][0][e.textNodeName];else if(s===e.commentPropName)i+=r[s][0][e.textNodeName];else{if(s&&"?"===s[0])continue;if(s){const t=oe(r[":@"],e),n=se(r[s],e);n&&0!==n.length?i+=`<${s}${t}>${n}</${s}>`:i+=`<${s}${t}/>`}}}return i}function oe(t,e){let i="";if(t&&!e.ignoreAttributes)for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let r=t[n];!0===r&&e.suppressBooleanAttributes?i+=` ${n.substr(e.attributeNamePrefix.length)}`:i+=` ${n.substr(e.attributeNamePrefix.length)}="${te(r)}"`}return i}function ae(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const n=e[i];if(Object.prototype.hasOwnProperty.call(t,n)&&":@"!==n)return n}}function le(t,e,i,n,r){let s="";if(t&&!e.ignoreAttributes)for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const a=o.substr(e.attributeNamePrefix.length),l=i?a:ee(a,!0,e,n,r);let p;i?p=t[o]:(p=e.attributeValueProcessor(o,t[o]),p=ce(p,e)),!0===p&&e.suppressBooleanAttributes?s+=` ${l}`:s+=` ${l}="${te(p)}"`}return s}function pe(t,e){if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t.matches(e[i]))return!0;return!1}function ce(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const n=e.entities[i];t=t.replace(n.regex,n.val)}return t}const he={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function de(t){if(this.options=Object.assign({},he,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new nt(e)):e instanceof nt&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=me),this.processTextOrObjNode=fe,this.options.format?(this.indentate=ge,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ue(t,e,i,n,r){return i.sanitizeName?R(t,{xmlVersion:r})?t:i.sanitizeName(t,{isAttribute:e,matcher:n.readOnly()}):t}function fe(t,e,i,n,r){const s=this.extractAttributes(t);if(n.push(e,s),this.checkStopNode(n)){const r=this.buildRawContent(t),s=this.buildAttributesForStopNode(t);return n.pop(),this.buildObjectNode(r,e,s,i)}const o=this.j2x(t,i+1,n,r);return n.pop(),"?"===e[0]?this.buildTextValNode("",e,o.attrStr,i,n):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,o.attrStr,i,n):this.buildObjectNode(o.val,e,o.attrStr,i)}function ge(t){return this.options.indentBy.repeat(t)}function me(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}de.prototype.build=function(t){if(this.options.preserveOrder)return ie(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new it,i=function(t,e){const i=t["?xml"];if(i&&"object"==typeof i){if(e.attributesGroupName&&i[e.attributesGroupName]){const t=i[e.attributesGroupName][e.attributeNamePrefix+"version"];if(t)return t}const t=i[e.attributeNamePrefix+"version"];if(t)return t}return"1.0"}(t,this.options);return this.j2x(t,0,e,i).val}},de.prototype.j2x=function(t,e,i,n){let r="",s="";if(this.options.maxNestedTags&&i.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const o=this.options.jPath?i.toString():i,a=this.checkStopNode(i);for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l))continue;const p=l===this.options.textNodeName||l===this.options.cdataPropName||l===this.options.commentPropName||this.options.attributesGroupName&&l===this.options.attributesGroupName||this.isAttribute(l)||"?"===l[0]?l:ue(l,!1,this.options,i,n);if(void 0===t[l])this.isAttribute(l)&&(s+="");else if(null===t[l])this.isAttribute(l)||p===this.options.cdataPropName||p===this.options.commentPropName?s+="":"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if(t[l]instanceof Date)s+=this.buildTextValNode(t[l],p,"",e,i);else if("object"!=typeof t[l]){const c=this.isAttribute(l);if(c&&!this.ignoreAttributesFn(c,o)){const e=ue(c,!0,this.options,i,n);r+=this.buildAttrPairStr(e,""+t[l],a)}else if(!c)if(l===this.options.textNodeName){let e=this.options.tagValueProcessor(l,""+t[l]);s+=this.replaceEntitiesValue(e)}else{i.push(p);const n=this.checkStopNode(i);if(i.pop(),n){const i=""+t[l];s+=""===i?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+i+"</"+p+this.tagEndChar}else s+=this.buildTextValNode(t[l],p,"",e,i)}}else if(Array.isArray(t[l])){const r=t[l].length;let o="",a="";for(let c=0;c<r;c++){const r=t[l][c];if(void 0===r);else if(null===r)"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if("object"==typeof r)if(this.options.oneListGroup){i.push(p);const t=this.j2x(r,e+1,i,n);i.pop(),o+=t.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else o+=this.processTextOrObjNode(r,p,e,i,n);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(p,r);t=this.replaceEntitiesValue(t),o+=t}else{i.push(p);const t=this.checkStopNode(i);if(i.pop(),t){const t=""+r;o+=""===t?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+t+"</"+p+this.tagEndChar}else o+=this.buildTextValNode(r,p,"",e,i)}}this.options.oneListGroup&&(o=this.buildObjectNode(o,p,a,e)),s+=o}else if(this.options.attributesGroupName&&l===this.options.attributesGroupName){const e=Object.keys(t[l]),s=e.length;for(let o=0;o<s;o++){const s=ue(e[o],!0,this.options,i,n);r+=this.buildAttrPairStr(s,""+t[l][e[o]],a)}}else s+=this.processTextOrObjNode(t[l],p,e,i,n)}return{attrStr:r,val:s}},de.prototype.buildAttrPairStr=function(t,e,i){return i||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+te(e)+'"'},de.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let i=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const n=t[this.options.attributesGroupName];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=te(n[t]),i=!0)}else for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=this.isAttribute(n);r&&(e[r]=te(t[n]),i=!0)}return i?e:null},de.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(this.isAttribute(i))continue;if(this.options.attributesGroupName&&i===this.options.attributesGroupName)continue;const n=t[i];if(i===this.options.textNodeName)e+=n;else if(Array.isArray(n)){for(let t of n)if("string"==typeof t||"number"==typeof t)e+=`<${i}>${t}</${i}>`;else if("object"==typeof t&&null!==t){const n=this.buildRawContent(t),r=this.buildAttributesForStopNode(t);e+=""===n?`<${i}${r}/>`:`<${i}${r}>${n}</${i}>`}}else if("object"==typeof n&&null!==n){const t=this.buildRawContent(n),r=this.buildAttributesForStopNode(n);e+=""===t?`<${i}${r}/>`:`<${i}${r}>${t}</${i}>`}else e+=`<${i}>${n}</${i}>`}return e},de.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const i=t[this.options.attributesGroupName];for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;const n=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,r=i[t];!0===r&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+r+'"'}}else for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=this.isAttribute(i);if(n){const r=t[i];!0===r&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+r+'"'}}return e},de.prototype.buildObjectNode=function(t,e,i,n){if(""===t)return"?"===e[0]?this.indentate(n)+"<"+e+i+"?"+this.tagEndChar:this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(n)+"<"+e+i+"?"+this.tagEndChar;{let r="</"+e+this.tagEndChar,s="";return"?"===e[0]&&(s="?",r=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(n)+"<"+e+i+s+this.tagEndChar+t+this.indentate(n)+r:this.indentate(n)+"<"+e+i+s+">"+t+r}},de.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},de.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},de.prototype.buildTextValNode=function(t,e,i,n,r){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName){const e=Kt(t);return this.indentate(n)+`<![CDATA[${e}]]>`+this.newLine}if(!1!==this.options.commentPropName&&e===this.options.commentPropName){const e=Zt(t);return this.indentate(n)+`\x3c!--${e}--\x3e`+this.newLine}if("?"===e[0])return this.indentate(n)+"<"+e+i+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),""===r?this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(n)+"<"+e+i+">"+r+"</"+e+this.tagEndChar}},de.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};const xe=de,be={validate:p};module.exports=e})();
128807
+ (()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>Oe,XMLParser:()=>re,XMLValidator:()=>je});const i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=new RegExp("^["+i+"]["+i+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function r(t,e){const i=[];let n=e.exec(t);for(;n;){const r=[];r.startIndex=e.lastIndex-n[0].length;const s=n.length;for(let t=0;t<s;t++)r.push(n[t]);i.push(r),n=e.exec(t)}return i}const s=function(t){return!(null==n.exec(t))},o=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],a=["__proto__","constructor","prototype"],l={allowBooleanAttributes:!1,unpairedTags:[]};function p(t,e){e=Object.assign({},l,e);const i=[];let n=!1,r=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let s=0;s<t.length;s++)if("<"===t[s]&&"?"===t[s+1]){if(s+=2,s=h(t,s),s.err)return s}else{if("<"!==t[s]){if(c(t[s]))continue;return y("InvalidChar","char '"+t[s]+"' is not expected.",w(t,s))}{let o=s;if(s++,"!"===t[s]){s=d(t,s);continue}{let a=!1;"/"===t[s]&&(a=!0,s++);let l="";for(;s<t.length&&">"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)l+=t[s];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),s--),!E(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",y("InvalidTag",e,w(t,s))}const p=g(t,s);if(!1===p)return y("InvalidAttr","Attributes for '"+l+"' have open quote.",w(t,s));let u=p.value;if(s=p.index,"/"===u[u.length-1]){const i=s-u.length;u=u.substring(0,u.length-1);const r=x(u,e);if(!0!==r)return y(r.err.code,r.err.msg,w(t,i+r.err.line));n=!0}else if(a){if(!p.tagClosed)return y("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",w(t,s));if(u.trim().length>0)return y("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",w(t,o));if(0===i.length)return y("InvalidTag","Closing tag '"+l+"' has not been opened.",w(t,o));{const e=i.pop();if(l!==e.tagName){let i=w(t,e.tagStartPos);return y("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+i.line+", col "+i.col+") instead of closing tag '"+l+"'.",w(t,o))}0==i.length&&(r=!0)}}else{const a=x(u,e);if(!0!==a)return y(a.err.code,a.err.msg,w(t,s-u.length+a.err.line));if(!0===r)return y("InvalidXml","Multiple possible root nodes found.",w(t,s));-1!==e.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:o}),n=!0}for(s++;s<t.length;s++)if("<"===t[s]){if("!"===t[s+1]){s++,s=d(t,s);continue}if("?"!==t[s+1])break;if(s=h(t,++s),s.err)return s}else if("&"===t[s]){const e=b(t,s);if(-1==e)return y("InvalidChar","char '&' is not expected.",w(t,s));s=e}else if(!0===r&&!c(t[s]))return y("InvalidXml","Extra text at the end",w(t,s));"<"===t[s]&&s--}}}return n?1==i.length?y("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",w(t,i[0].tagStartPos)):!(i.length>0)||y("InvalidXml","Invalid '"+JSON.stringify(i.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):y("InvalidXml","Start tag expected.",1)}function c(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function h(t,e){const i=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const n=t.substr(i,e-i);if(e>5&&"xml"===n)return y("InvalidXml","XML declaration allowed only at the start of the document.",w(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let i=1;for(e+=8;e<t.length;e++)if("<"===t[e])i++;else if(">"===t[e]&&(i--,0===i))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const u='"',f="'";function g(t,e){let i="",n="",r=!1;for(;e<t.length;e++){if(t[e]===u||t[e]===f)""===n?n=t[e]:n!==t[e]||(n="");else if(">"===t[e]&&""===n){r=!0;break}i+=t[e]}return""===n&&{value:i,index:e,tagClosed:r}}const m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function x(t,e){const i=r(t,m),n={};for(let t=0;t<i.length;t++){if(0===i[t][1].length)return y("InvalidAttr","Attribute '"+i[t][2]+"' has no space in starting.",v(i[t]));if(void 0!==i[t][3]&&void 0===i[t][4])return y("InvalidAttr","Attribute '"+i[t][2]+"' is without value.",v(i[t]));if(void 0===i[t][3]&&!e.allowBooleanAttributes)return y("InvalidAttr","boolean attribute '"+i[t][2]+"' is not allowed.",v(i[t]));const r=i[t][2];if(!N(r))return y("InvalidAttr","Attribute '"+r+"' is an invalid name.",v(i[t]));if(Object.prototype.hasOwnProperty.call(n,r))return y("InvalidAttr","Attribute '"+r+"' is repeated.",v(i[t]));n[r]=1}return!0}function b(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let i=/\d/;for("x"===t[e]&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(i))break}return-1}(t,++e);let i=0;for(;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(";"===t[e])break;return-1}return e}function y(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function N(t){return s(t)}function E(t){return s(t)}function w(t,e){const i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function v(t){return t.startIndex+t[1].length}const S=t=>o.includes(t)?"__"+t:t,A={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,i){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:S};function T(t,e){if("string"!=typeof t)return;const i=t.toLowerCase();if(o.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(a.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function _(t,e){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null,appliesTo:t.appliesTo??"all"}:_(!0)}const C=function(t){const e=Object.assign({},A,t),i=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:t,name:e}of i)t&&T(t,e);return null===e.onDangerousProperty&&(e.onDangerousProperty=S),e.processEntities=_(e.processEntities,e.htmlEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),e};let $;$="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class P{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][$]={startIndex:e})}static getMetaDataSymbol(){return $}}const O=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",j=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",I=j+"\\-\\.\\d·̀-ͯ҇‿-⁀",k=(t,e,i="")=>{const n=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${n}$`,i),qName:new RegExp(`^${n}(?::${n})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},L=k(O,O+"\\-\\.\\d·̀-ͯ‿-⁀"),D=k(j,I,"u"),R=":A-Za-z_",M=k(R,R+"\\-\\.\\d"),V=(t,{xmlVersion:e="1.0",asciiOnly:i=!1}={})=>((t="1.0",e=!1)=>e?M:"1.1"===t?D:L)(e,i).qName.test(t);class q{constructor(t,e){this.suppressValidationErr=!t,this.options=t,this.xmlVersion=e||1}setXmlVersion(t=1){this.xmlVersion=t}readDocType(t,e){const i=Object.create(null);let n=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,s=!1,o=!1,a="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?s=!0:a+=t[e];else{if(s&&U(t,"!ENTITY",e)){let r,s;if(e+=7,[r,s,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===s.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[r]=s,n++}}else if(s&&U(t,"!ELEMENT",e)){e+=8;const{index:i}=this.readElementExp(t,e+1);e=i}else if(s&&U(t,"!ATTLIST",e))e+=8;else if(s&&U(t,"!NOTATION",e)){e+=9;const{index:i}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=i}else{if(!U(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,a=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}}readEntityExp(t,e){const i=e=F(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let n=t.substring(i,e);if(B(n,{xmlVersion:this.xmlVersion}),e=F(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}let r="";if([e,r]=this.readIdentifierVal(t,e,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[n,r,--e]}readNotationExp(t,e){const i=e=F(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);!this.suppressValidationErr&&B(n,{xmlVersion:this.xmlVersion}),e=F(t,e);const r=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);e+=r.length,e=F(t,e);let s=null,o=null;if("PUBLIC"===r)[e,s]=this.readIdentifierVal(t,e,"publicIdentifier"),'"'!==t[e=F(t,e)]&&"'"!==t[e]||([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"));else if("SYSTEM"===r&&([e,o]=this.readIdentifierVal(t,e,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:s,systemIdentifier:o,index:--e}}readIdentifierVal(t,e,i){let n="";const r=t[e];if('"'!==r&&"'"!==r)throw new Error(`Expected quoted string, found "${r}"`);const s=++e;for(;e<t.length&&t[e]!==r;)e++;if(n=t.substring(s,e),t[e]!==r)throw new Error(`Unterminated ${i} value`);return[++e,n]}readElementExp(t,e){const i=e=F(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);if(!this.suppressValidationErr&&!V(n,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${n}"`);let r="";if("E"===t[e=F(t,e)]&&U(t,"MPTY",e))e+=4;else if("A"===t[e]&&U(t,"NY",e))e+=2;else if("("===t[e]){const i=++e;for(;e<t.length&&")"!==t[e];)e++;if(r=t.substring(i,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[e]}"`);return{elementName:n,contentModel:r.trim(),index:e}}readAttlistExp(t,e){let i=e=F(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);for(B(n,{xmlVersion:this.xmlVersion}),i=e=F(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let r=t.substring(i,e);if(!B(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${r}"`);e=F(t,e);let s="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(s="NOTATION","("!==t[e=F(t,e+=8)])throw new Error(`Expected '(', found "${t[e]}"`);e++;let i=[];for(;e<t.length&&")"!==t[e];){const n=e;for(;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;let r=t.substring(n,e);if(r=r.trim(),!B(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${r}"`);i.push(r),"|"===t[e]&&(e++,e=F(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,s+=" ("+i.join("|")+")"}else{const i=e;for(;e<t.length&&!/\s/.test(t[e]);)e++;s+=t.substring(i,e);const n=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!n.includes(s.toUpperCase()))throw new Error(`Invalid attribute type: "${s}"`)}e=F(t,e);let o="";return"#REQUIRED"===t.substring(e,e+8).toUpperCase()?(o="#REQUIRED",e+=8):"#IMPLIED"===t.substring(e,e+7).toUpperCase()?(o="#IMPLIED",e+=7):[e,o]=this.readIdentifierVal(t,e,"ATTLIST"),{elementName:n,attributeName:r,attributeType:s,defaultValue:o,index:e}}}const F=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function U(t,e,i){for(let n=0;n<e.length;n++)if(e[n]!==t[i+n+1])return!1;return!0}function B(t,e){if(V(t,{xmlVersion:e}))return t;throw new Error(`Invalid entity name ${t}`)}const G=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],X=new Map,W=1632,z=new Uint8Array(63904).fill(255);for(const t of G)for(let e=0;e<10;e++){const i=t+e;i<=65535?z[i-W]=e:X.set(i,e)}const Y=new Set([8722,65293,65123]),H=/^[-+]?0x[a-fA-F0-9]+$/,Q=/^0b[01]+$/,J=/^0o[0-7]+$/,Z=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,K={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function tt(t,e={}){if(e=Object.assign({},K,e),!t||"string"!=typeof t)return t;let i=t.trim();if(0===i.length)return t;if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===i)return 0;if(e.unicode&&(i=function(t){if("string"!=typeof t)return t;const e=t.length;if(0===e)return t;let i=-1;for(let n=0;n<e;n++){const r=t.charCodeAt(n);if(!(r>=48&&r<=57||45===r))if(r<W){if(Y.has(r)){i=n;break}}else if(r>=55296&&r<=56319){if(n+1<e){const e=t.charCodeAt(n+1);if(e>=56320&&e<=57343){const t=65536+(r-55296<<10)+(e-56320);if(X.has(t)){i=n;break}}}}else if(255!==z[r-W]||Y.has(r)){i=n;break}}if(-1===i)return t;const n=[];i>0&&n.push(t.slice(0,i));for(let r=i;r<e;r++){const i=t.charCodeAt(r);if(i>=48&&i<=57||45===i){n.push(t[r]);continue}if(i<W){n.push(Y.has(i)?"-":t[r]);continue}if(i>=55296&&i<=56319){if(r+1<e){const e=t.charCodeAt(r+1);if(e>=56320&&e<=57343){const t=65536+(i-55296<<10)+(e-56320),s=X.get(t);if(void 0!==s){n.push(String.fromCharCode(s+48)),r++;continue}}}n.push(t[r]);continue}if(Y.has(i)){n.push("-");continue}const s=z[i-W];n.push(255!==s?String.fromCharCode(s+48):t[r])}return n.join("")}(i),"0"===i))return 0;if(e.hex&&H.test(i))return it(i,16);if(e.binary&&Q.test(i))return it(i,2);if(e.octal&&J.test(i))return it(i,8);if(isFinite(i)){if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const n=e.match(et);if(n){let r=n[1]||"";const s=-1===n[3].indexOf("e")?"E":"e",o=n[2],a=r?t[o.length+1]===s:t[o.length]===s;return o.length>1&&a?t:(1!==o.length||!n[3].startsWith(`.${s}`)&&n[3][0]!==s)&&o.length>0?i.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,i,e);{const r=Z.exec(i);if(r){const s=r[1]||"",o=r[2];let a=(n=r[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const l=s?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!l))return t;{const n=Number(i),r=String(n);if(0===n)return n;if(-1!==r.search(/[eE]/))return e.eNotation?n:t;if(-1!==i.indexOf("."))return"0"===r||r===a||r===`${s}${a}`?n:t;let l=o?a:i;return o?l===r||s+l===r?n:t:l===r||l===s+r?n:t}}return t}}var n;return function(t,e,i){const n=e===1/0;switch(i.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";default:return t}}(t,Number(i),e)}const et=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function it(t,e){const i=t.trim();if(2!==e&&8!==e||(t=i.substring(2)),parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}class nt{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getAnyParentAttr(t){return this._matcher.getAnyParentAttr(t)}hasAnyParentAttr(t){return this._matcher.hasAnyParentAttr(t)}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class rt{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new nt(this),this._keptAttrs=[]}push(t,e=null,i=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const r=this.path.length;let s=this.siblingStacks[r];s||(s={counts:new Map,total:0},this.siblingStacks[r]=s);const o=i?`${i}:${t}`:t,a=s.counts.get(o)||0,l=s.total;s.counts.set(o,a+1),s.total++;const p={tag:t,position:l,counter:a};null!=i&&(p.namespace=i),null!=e&&(p.values=e),this.path.push(p);const c=this.path.length,h=null!==n?n.keep:null;if(null!=h&&h.length>0&&e)for(let t=0;t<h.length;t++){const i=h[t];void 0!==e[i]&&this._keptAttrs.push({depth:c,name:i,value:e[i]})}}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);const e=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=e;)this._keptAttrs.pop();return t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return e[i].value}hasAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return!0;return!1}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const n=t[i];if("deep-wildcard"===n.type){if(i--,i<0)return!0;const n=t[i];let r=!1;for(let t=e;t>=0;t--)if(this._matchSegment(n,this.path[t],t===this.path.length-1)){e=t-1,i--,r=!0;break}if(!r)return!1}else{if(!this._matchSegment(n,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!i)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),keptAttrs:this._keptAttrs.map(t=>({...t}))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),this._keptAttrs=(t.keptAttrs||[]).map(t=>({...t}))}readOnly(){return this._view}}class st{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,n="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(n.trim()&&(e.push(this._parseSegment(n.trim())),n=""),e.push({type:"deep-wildcard"}),i+=2):(n.trim()&&e.push(this._parseSegment(n.trim())),n="",i++):(n+=t[i],i++);return n.trim()&&e.push(this._parseSegment(n.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,n=t;const r=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(n=r[1]+r[3],r[2])){const t=r[2].slice(1,-1);t&&(i=t)}let s,o,a=n;if(n.includes("::")){const e=n.indexOf("::");if(s=n.substring(0,e).trim(),a=n.substring(e+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${t}`)}let l=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),i=a.substring(t+1).trim();["first","last","odd","even"].includes(i)||/^nth\(\d+\)$/.test(i)?(o=e,l=i):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,s&&(e.namespace=s),i)if(i.includes("=")){const t=i.indexOf("=");e.attrName=i.substring(0,t).trim(),e.attrValue=i.substring(t+1).trim()}else e.attrName=i.trim();if(l){const t=l.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=l}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class ot{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard()){const e=t.segments[t.segments.length-1];if(e&&"deep-wildcard"!==e.type&&"*"!==e.tag){const i=e.tag;this._deepByTerminalTag.has(i)||this._deepByTerminalTag.set(i,[]),this._deepByTerminalTag.get(i).push(t)}else this._deepWildcards.push(t);return this}const e=t.length,i=t.segments[t.segments.length-1],n=i?.tag;if(n&&"*"!==n){const i=`${e}:${n}`;this._byDepthAndTag.has(i)||this._byDepthAndTag.set(i,[]),this._byDepthAndTag.get(i).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),i=t.getCurrentTag(),n=`${e}:${i}`,r=this._byDepthAndTag.get(n);if(r)for(let e=0;e<r.length;e++)if(t.matches(r[e]))return r[e];const s=this._wildcardByDepth.get(e);if(s)for(let e=0;e<s.length;e++)if(t.matches(s[e]))return s[e];const o=this._deepByTerminalTag.get(i);if(o)for(let e=0;e<o.length;e++)if(t.matches(o[e]))return o[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const at={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},lt={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},pt={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},ct=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),ht=new Set("!?\\\\/[]$%{}^&*()<>|+");function dt(t){if("#"===t[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t}"`);for(const e of t)if(ht.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${t}"`);return t}function ut(...t){const e=Object.create(null);for(const i of t)if(i)for(const t of Object.keys(i)){const n=i[t];if("string"==typeof n)e[t]=n;else if(n&&"object"==typeof n&&void 0!==n.val){const i=n.val;"string"==typeof i&&(e[t]=i)}}return e}const ft="external",gt="base",mt="all",xt=Object.freeze({allow:0,leave:1,remove:2,throw:3}),bt=new Set([9,10,13]);class yt{constructor(t={}){var e;this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:t=>t,this._limitTiers=(e=this._limit.applyLimitsTo??ft)&&e!==ft?e===mt?new Set([mt]):e===gt?new Set([gt]):Array.isArray(e)?new Set(e):new Set([ft]):new Set([ft]),this._numericAllowed=t.numericAllowed??!0,this._baseMap=ut(lt,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const i=function(t){if(!t)return{xmlVersion:1,onLevel:xt.allow,nullLevel:xt.remove};const e=1.1===t.xmlVersion?1.1:1,i=xt[t.onNCR]??xt.allow,n=xt[t.nullNCR]??xt.remove;return{xmlVersion:e,onLevel:i,nullLevel:Math.max(n,xt.remove)}}(t.ncr);this._ncrXmlVersion=i.xmlVersion,this._ncrOnLevel=i.onLevel,this._ncrNullLevel=i.nullLevel,this._onExternalEntity="function"==typeof t.onExternalEntity?t.onExternalEntity:null,this._onInputEntity="function"==typeof t.onInputEntity?t.onInputEntity:null}_applyRegistrationHook(t,e,i,n){if(!t)return!0;const r=t(e,i);if(r===ct.BLOCK)return!1;if(r===ct.THROW)throw new Error(`[EntityDecoder] Registration of ${n} entity "&${e};" was rejected by hook`);return!0}setExternalEntities(t){if(t)for(const e of Object.keys(t))dt(e);if(!this._onExternalEntity)return void(this._externalMap=ut(t));const e=ut(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onExternalEntity,t,n,"external")&&(i[t]=n);this._externalMap=i}addExternalEntity(t,e){dt(t),"string"==typeof e&&-1===e.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,t,e,"external")&&(this._externalMap[t]=e)}addInputEntities(t){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=ut(t));const e=ut(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onInputEntity,t,n,"input")&&(i[t]=n);this._inputMap=i}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;if(-1===t.indexOf("&"))return t;const e=t,i=[],n=t.length;let r=0,s=0;const o=this._maxTotalExpansions>0,a=this._maxExpandedLength>0,l=o||a;for(;s<n;){if(38!==t.charCodeAt(s)){s++;continue}let e=s+1;for(;e<n&&59!==t.charCodeAt(e)&&e-s<=32;)e++;if(e>=n||59!==t.charCodeAt(e)){s++;continue}const p=t.slice(s+1,e);if(0===p.length){s++;continue}let c,h;if(this._removeSet.has(p))c="",void 0===h&&(h=ft);else{if(this._leaveSet.has(p)){s++;continue}if(35===p.charCodeAt(0)){const t=this._resolveNCR(p);if(void 0===t){s++;continue}c=t,h=gt}else{const t=this._resolveName(p);c=t?.value,h=t?.tier}}if(void 0!==c){if(s>r&&i.push(t.slice(r,s)),i.push(c),r=e+1,s=r,l&&this._tierCounts(h)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(a){const t=c.length-(p.length+2);if(t>0&&(this._expandedLength+=t,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else s++}r<n&&i.push(t.slice(r));const p=0===i.length?t:i.join("");return this._postCheck(p,e)}_tierCounts(t){return!!this._limitTiers.has(mt)||this._limitTiers.has(t)}_resolveName(t){return t in this._inputMap?{value:this._inputMap[t],tier:ft}:t in this._externalMap?{value:this._externalMap[t],tier:ft}:t in this._baseMap?{value:this._baseMap[t],tier:gt}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!bt.has(t)?xt.remove:-1}_applyNCRAction(t,e,i){switch(t){case xt.allow:return String.fromCodePoint(i);case xt.remove:return"";case xt.leave:return;case xt.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const n=this._classifyNCR(i);if(!this._numericAllowed&&n<xt.remove)return;const r=-1===n?this._ncrOnLevel:Math.max(this._ncrOnLevel,n);return this._applyNCRAction(r,t,i)}}const Nt=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ — unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT — most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE — destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE — destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO — data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM — data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET — data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ — MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:'Classic string tautology: \' OR \'1\'=\'1 or " OR "1"="1"',pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function — used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA — reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],Et=[...Nt,{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],wt=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() — IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= — can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" — can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes — embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag — can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],vt=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content — can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword — used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword — used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration — defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection — can redefine namespaces to confuse parsers",pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"\x3c!-- comment injection — can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--\x3e closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],St=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: — classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG — can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" — can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." — sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= — filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],At=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ — climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ — climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 — truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r — can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? — can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags — can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],Tt=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern — triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} — repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches — polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],_t="[\"'\\s]*:",Ct=[{id:"nosql-where-operator",description:"$where — executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${_t}`,"i")},{id:"nosql-ne-operator",description:'$ne — "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${_t}`,"i")},{id:"nosql-gt-operator",description:'$gt — "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${_t}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte — "less than" bypass variants',pattern:new RegExp(`\\$lte?${_t}`,"i")},{id:"nosql-regex-operator",description:"$regex — can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${_t}`,"i")},{id:"nosql-or-operator",description:"$or — logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${_t}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and — logical AND operator injection",pattern:new RegExp(`\\$and${_t}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor — logical NOR operator injection",pattern:new RegExp(`\\$nor${_t}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists — can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${_t}`,"i")},{id:"nosql-in-operator",description:"$in — matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${_t}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr — allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${_t}`,"i")},{id:"nosql-function-operator",description:"$function — executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${_t}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator — custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${_t}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ — prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] — bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],$t=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}];function Pt(t,e){const i=e.label??"CUSTOM";for(const n of e)if(n.pattern.test(t))return{context:i,id:n.id,description:n.description,pattern:n.pattern};return null}function Ot(t,e){(function(t){if("string"!=typeof t)throw new TypeError("is-unsafe: first argument must be a string, got "+typeof t)})(t),function(t){if(!(t instanceof RegExp)){if(!Array.isArray(t))throw new TypeError("is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: "+typeof t);if(0===t.length)throw new TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(t[0]))for(const e of t)if(!Array.isArray(e)||0===e.length)throw new TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}}(e);const{lists:i,regex:n}=function(t){return t instanceof RegExp?{lists:null,regex:t}:Array.isArray(t[0])?{lists:t,regex:null}:{lists:[t],regex:null}}(e);if(n)return n.test(t);for(const e of i)if(null!==Pt(t,e))return!0;return!1}function jt(t,e){if(!t)return{};const i=e.attributesGroupName?t[e.attributesGroupName]:t;if(!i)return{};const n={};for(const t in i)t.startsWith(e.attributeNamePrefix)?n[t.substring(e.attributeNamePrefix.length)]=i[t]:n[t]=i[t];return n}function It(t){if(!t||"string"!=typeof t)return;const e=t.indexOf(":");if(-1!==e&&e>0){const i=t.substring(0,e);if("xmlns"!==i)return i}}wt.label="HTML",vt.label="XML",St.label="SVG",Nt.label="SQL",Et.label="SQL-STRICT",At.label="SHELL",Tt.label="REDOS",Ct.label="NOSQL",$t.label="LOG",Object.freeze({HTML:wt,XML:vt,SVG:St,SQL:Nt,"SQL-STRICT":Et,SHELL:At,REDOS:Tt,NOSQL:Ct,LOG:$t});class kt{constructor(t,e){var i;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Vt,this.parseTextData=Lt,this.resolveNameSpace=Dt,this.buildAttributesMap=Mt,this.isItStopNode=Bt,this.replaceEntitiesValue=Ft,this.readStopNodeData=zt,this.saveTextToParentTag=Ut,this.addChild=qt,this.ignoreAttributesFn="function"==typeof(i=this.options.ignoreAttributes)?i:Array.isArray(i)?t=>{for(const e of i){if("string"==typeof e&&t===e)return!0;if(e instanceof RegExp&&e.test(t))return!0}}:()=>!1,this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let n={...lt};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?n=this.options.htmlEntities:!0===this.options.htmlEntities&&(n={...pt,...at}),this.entityDecoder=new yt({namedEntities:{...n,...e},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:(t,e)=>Ot(e,[wt,vt])?ct.BLOCK:ct.ALLOW})),this.matcher=new rt,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ot;const r=this.options.stopNodes;if(r&&r.length>0){for(let t=0;t<r.length;t++){const e=r[t];"string"==typeof e?this.stopNodeExpressionsSet.add(new st(e)):e instanceof st&&this.stopNodeExpressionsSet.add(e)}this.stopNodeExpressionsSet.seal()}}}function Lt(t,e,i,n,r,s,o){const a=this.options;if(void 0!==t&&(a.trimValues&&!n&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t,e,i));const n=a.jPath?i.toString():i,l=a.tagValueProcessor(e,t,n,r,s);return null==l?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?Yt(t,a.parseTagValue,a.numberParseOptions):t}}function Dt(t){if(this.options.removeNSPrefix){const e=t.split(":"),i="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=i+e[1])}return t}const Rt=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Mt(t,e,i,n=!1){const s=this.options;if(!0===n||!0!==s.ignoreAttributes&&"string"==typeof t){const n=r(t,Rt),o=n.length,a={},l=new Array(o);let p=!1;const c={};for(let t=0;t<o;t++){const e=this.resolveNameSpace(n[t][1]),r=n[t][4];if(e.length&&void 0!==r){let n=r;s.trimValues&&(n=n.trim()),n=this.replaceEntitiesValue(n,i,this.readonlyMatcher),l[t]=n,c[e]=n,p=!0}}p&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(c);const h=s.jPath?e.toString():this.readonlyMatcher;let d=!1;for(let t=0;t<o;t++){const e=this.resolveNameSpace(n[t][1]);if(this.ignoreAttributesFn(e,h))continue;let i=s.attributeNamePrefix+e;if(e.length)if(s.transformAttributeName&&(i=s.transformAttributeName(i)),i=Qt(i,s),void 0!==n[t][4]){const n=l[t],r=s.attributeValueProcessor(e,n,h);a[i]=null==r?n:typeof r!=typeof n||r!==n?r:Yt(n,s.parseAttributeValue,s.numberParseOptions),d=!0}else s.allowBooleanAttributes&&(a[i]=!0,d=!0)}if(!d)return;if(s.attributesGroupName&&!s.preserveOrder){const t={};return t[s.attributesGroupName]=a,t}return a}}const Vt=function(t){t=t.replace(/\r\n?/g,"\n");const e=new P("!xml");let i=e,n="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;const r=this.options,s=new q(r.processEntities),o=t.length;for(let a=0;a<o;a++)if("<"===t[a]){const l=t.charCodeAt(a+1);if(47===l){const e=Gt(t,">",a,"Closing Tag is not closed.");let s=t.substring(a+2,e).trim();if(r.removeNSPrefix){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}s=Ht(r.transformTagName,s,"",r).tagName,i&&(n=this.saveTextToParentTag(n,i,this.readonlyMatcher));const o=this.matcher.getCurrentTag();if(s&&r.unpairedTagsSet.has(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);o&&r.unpairedTagsSet.has(o)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop(),n="",a=e}else if(63===l){let e=Wt(t,a,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");n=this.saveTextToParentTag(n,i,this.readonlyMatcher);const o=this.buildAttributesMap(e.tagExp,this.matcher,e.tagName,!0);if(o){const t=o[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(t)||1),s.setXmlVersion(Number(t)||1)}if(r.ignoreDeclaration&&"?xml"===e.tagName||r.ignorePiTags);else{const t=new P(e.tagName);t.add(r.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&!0!==r.ignoreAttributes&&(t[":@"]=o),this.addChild(i,t,this.readonlyMatcher,a)}a=e.closeIndex+1}else if(33===l&&45===t.charCodeAt(a+2)&&45===t.charCodeAt(a+3)){const e=Gt(t,"--\x3e",a+4,"Comment is not closed.");if(r.commentPropName){const s=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,i,this.readonlyMatcher),i.add(r.commentPropName,[{[r.textNodeName]:s}])}a=e}else if(33===l&&68===t.charCodeAt(a+2)){if(this.doctypefound)throw new Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;const e=s.readDocType(t,a);this.entityDecoder.addInputEntities(e.entities),a=e.i}else if(33===l&&91===t.charCodeAt(a+2)){const e=Gt(t,"]]>",a,"CDATA is not closed.")-2,s=t.substring(a+9,e);n=this.saveTextToParentTag(n,i,this.readonlyMatcher);let o=this.parseTextData(s,i.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==o&&(o=""),r.cdataPropName?i.add(r.cdataPropName,[{[r.textNodeName]:s}]):i.add(r.textNodeName,o),a=e+2}else{let s=Wt(t,a,r.removeNSPrefix);if(!s){const e=t.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${e}"`)}let l=s.tagName;const p=s.rawTagName;let c=s.tagExp,h=s.attrExpPresent,d=s.closeIndex;if(({tagName:l,tagExp:c}=Ht(r.transformTagName,l,c,r)),r.strictReservedNames&&(l===r.commentPropName||l===r.cdataPropName||l===r.textNodeName||l===r.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);i&&n&&"!xml"!==i.tagname&&(n=this.saveTextToParentTag(n,i,this.readonlyMatcher,!1));const u=i;u&&r.unpairedTagsSet.has(u.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());let f=!1;c.length>0&&c.lastIndexOf("/")===c.length-1&&(f=!0,"/"===l[l.length-1]?(l=l.substr(0,l.length-1),c=l):c=c.substr(0,c.length-1),h=l!==c);let g,m=null,x={};g=It(p),l!==e.tagname&&this.matcher.push(l,{},g),l!==c&&h&&(m=this.buildAttributesMap(c,this.matcher,l),m&&(x=jt(m,r))),l!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const b=a;if(this.isCurrentNodeStopNode){let e="";if(f)a=s.closeIndex;else if(r.unpairedTagsSet.has(l))a=s.closeIndex;else{const i=this.readStopNodeData(t,p,d+1);if(!i)throw new Error(`Unexpected end of ${p}`);a=i.i,e=i.tagContent}const n=new P(l);m&&(n[":@"]=m),n.add(r.textNodeName,e),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,n,this.readonlyMatcher,b)}else{if(f){({tagName:l,tagExp:c}=Ht(r.transformTagName,l,c,r));const t=new P(l);m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(r.unpairedTagsSet.has(l)){const t=new P(l);m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=s.closeIndex;continue}{const t=new P(l);if(this.tagsNodeStack.length>r.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),m&&(t[":@"]=m),this.addChild(i,t,this.readonlyMatcher,b),i=t}}n="",a=d}}}else n+=t[a];return e.child};function qt(t,e,i,n){this.options.captureMetaData||(n=void 0);const r=this.options.jPath?i.toString():i,s=this.options.updateTag(e.tagname,r,e[":@"]);!1===s||("string"==typeof s?(e.tagname=s,t.addChild(e,n)):t.addChild(e,n))}function Ft(t,e,i){const n=this.options.processEntities;if(!n||!n.enabled)return t;if(n.allowedTags){const r=this.options.jPath?i.toString():i;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(e):n.allowedTags(e,r)))return t}if(n.tagFilter){const r=this.options.jPath?i.toString():i;if(!n.tagFilter(e,r))return t}return this.entityDecoder.decode(t)}function Ut(t,e,i,n){return t&&(void 0===n&&(n=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,i,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,n))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function Bt(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Gt(t,e,i,n){const r=t.indexOf(e,i);if(-1===r)throw new Error(n);return r+e.length-1}function Xt(t,e,i,n){const r=t.indexOf(e,i);if(-1===r)throw new Error(n);return r}function Wt(t,e,i,n=">"){const r=function(t,e,i=">"){let n=0;const r=t.length,s=i.charCodeAt(0),o=i.length>1?i.charCodeAt(1):-1;let a="",l=e;for(let i=e;i<r;i++){const e=t.charCodeAt(i);if(n)e===n&&(n=0);else if(34===e||39===e)n=e;else if(e===s){if(-1===o)return a+=t.substring(l,i),{data:a,index:i};if(t.charCodeAt(i+1)===o)return a+=t.substring(l,i),{data:a,index:i}}else 9!==e||n||(a+=t.substring(l,i)+" ",l=i+1)}}(t,e+1,n);if(!r)return;let s=r.data;const o=r.index,a=s.search(/\s/);let l=s,p=!0;-1!==a&&(l=s.substring(0,a),s=s.substring(a+1).trimStart());const c=l;if(i){const t=l.indexOf(":");-1!==t&&(l=l.substr(t+1),p=l!==r.data.substr(t+1))}return{tagName:l,tagExp:s,closeIndex:o,attrExpPresent:p,rawTagName:c}}function zt(t,e,i){const n=i;let r=1;const s=t.length;for(;i<s;i++)if("<"===t[i]){const s=t.charCodeAt(i+1);if(47===s){const s=Xt(t,">",i,`${e} is not closed`);if(t.substring(i+2,s).trim()===e&&(r--,0===r))return{tagContent:t.substring(n,i),i:s};i=s}else if(63===s)i=Gt(t,"?>",i+1,"StopNode is not closed.");else if(33===s&&45===t.charCodeAt(i+2)&&45===t.charCodeAt(i+3))i=Gt(t,"--\x3e",i+3,"StopNode is not closed.");else if(33===s&&91===t.charCodeAt(i+2))i=Gt(t,"]]>",i,"StopNode is not closed.")-2;else{const n=Wt(t,i,!1);n&&((n&&n.tagName)===e&&"/"!==n.tagExp[n.tagExp.length-1]&&r++,i=n.closeIndex)}}}function Yt(t,e,i){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&tt(t,i)}return void 0!==t?t:""}function Ht(t,e,i,n){if(t){const n=t(e);i===e&&(i=n),e=n}return{tagName:e=Qt(e,n),tagExp:i}}function Qt(t,e){if(a.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return o.includes(t)?e.onDangerousProperty(t):t}const Jt=P.getMetaDataSymbol();function Zt(t,e){if(!t||"object"!=typeof t)return{};if(!e)return t;const i={};for(const n in t)n.startsWith(e)?i[n.substring(e.length)]=t[n]:i[n]=t[n];return i}function Kt(t,e,i,n){return te(t,e,i,n)}function te(t,e,i,n){let r;const s={};for(let o=0;o<t.length;o++){const a=t[o],l=ee(a);if(void 0!==l&&l!==e.textNodeName){const t=Zt(a[":@"]||{},e.attributeNamePrefix);i.push(l,t)}if(l===e.textNodeName)void 0===r?r=a[l]:r+=""+a[l];else{if(void 0===l)continue;if(a[l]){let t=te(a[l],e,i,n);const r=ne(t,e);if(0===Object.keys(t).length&&e.alwaysCreateTextNode&&(t[e.textNodeName]=""),a[":@"]?ie(t,a[":@"],n,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==a[Jt]&&"object"==typeof t&&null!==t&&(t[Jt]=a[Jt]),void 0!==s[l]&&Object.prototype.hasOwnProperty.call(s,l))Array.isArray(s[l])||(s[l]=[s[l]]),s[l].push(t);else{const i=e.jPath?n.toString():n;e.isArray(l,i,r)?s[l]=[t]:s[l]=t}void 0!==l&&l!==e.textNodeName&&i.pop()}}}return"string"==typeof r?r.length>0&&(s[e.textNodeName]=r):void 0!==r&&(s[e.textNodeName]=r),s}function ee(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function ie(t,e,i,n){if(e){const r=Object.keys(e),s=r.length;for(let o=0;o<s;o++){const s=r[o],a=s.startsWith(n.attributeNamePrefix)?s.substring(n.attributeNamePrefix.length):s,l=n.jPath?i.toString()+"."+a:i;n.isArray(s,l,!0,!0)?t[s]=[e[s]]:t[s]=e[s]}}}function ne(t,e){const{textNodeName:i}=e,n=Object.keys(t).length;return 0===n||!(1!==n||!t[i]&&"boolean"!=typeof t[i]&&0!==t[i])}class re{constructor(t){this.externalEntities={},this.options=C(t)}parse(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});const i=p(t,e);if(!0!==i)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}const i=new kt(this.options,this.externalEntities),n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:Kt(n,this.options,i.matcher,i.readonlyMatcher)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return P.getMetaDataSymbol()}}function se(t){return String(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function oe(t){return String(t).replace(/\]\]>/g,"]]]]><![CDATA[>")}function ae(t){return String(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const le=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",pe=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",ce=pe+"\\-\\.\\d·̀-ͯ҇‿-⁀",he=(t,e,i="")=>{const n=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${n}$`,i),qName:new RegExp(`^${n}(?::${n})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},de=he(le,le+"\\-\\.\\d·̀-ͯ‿-⁀"),ue=he(pe,ce,"u"),fe=(t,{xmlVersion:e="1.0"}={})=>((t="1.0")=>"1.1"===t?ue:de)(e).qName.test(t);function ge(t,e,i,n,r){return i.sanitizeName?fe(t,{xmlVersion:r})?t:i.sanitizeName(t,{isAttribute:e,matcher:n.readOnly()}):t}function me(t,e){let i="";e.format&&(i="\n");const n=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const i=e.stopNodes[t];"string"==typeof i?n.push(new st(i)):i instanceof st&&n.push(i)}const r=function(t,e){if(!Array.isArray(t)||0===t.length)return"1.0";const i=t[0];if("?xml"===Ee(i)){const t=i[":@"];if(t){const i=e.attributeNamePrefix+"version";if(t[i])return t[i]}}return"1.0"}(t,e);return xe(t,e,i,new rt,n,r)}function xe(t,e,i,n,r,s){let o="",a=!1;if(e.maxNestedTags&&n.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=Se(i,e),i}return""}for(let l=0;l<t.length;l++){const p=t[l],c=Ee(p);if(void 0===c)continue;const h=c===e.textNodeName||c===e.cdataPropName||c===e.commentPropName||"?"===c[0]?c:ge(c,!1,e,n,s),d=be(p[":@"],e);n.push(h,d);const u=ve(n,r);if(h===e.textNodeName){let t=p[c];u||(t=e.tagValueProcessor(h,t),t=Se(t,e)),a&&(o+=i),o+=t,a=!1,n.pop();continue}if(h===e.cdataPropName){a&&(o+=i),o+=`<![CDATA[${oe(p[c][0][e.textNodeName])}]]>`,a=!1,n.pop();continue}if(h===e.commentPropName){o+=i+`\x3c!--${se(p[c][0][e.textNodeName])}--\x3e`,a=!0,n.pop();continue}if("?"===h[0]){o+=("?xml"===h?"":i)+`<${h}${we(p[":@"],e,u,n,s)}?>`,a=!0,n.pop();continue}let f=i;""!==f&&(f+=e.indentBy);const g=i+`<${h}${we(p[":@"],e,u,n,s)}`;let m;m=u?ye(p[c],e):xe(p[c],e,f,n,r,s),-1!==e.unpairedTags.indexOf(h)?e.suppressUnpairedNode?o+=g+">":o+=g+"/>":m&&0!==m.length||!e.suppressEmptyNode?m&&m.endsWith(">")?o+=g+`>${m}${i}</${h}>`:(o+=g+">",m&&""!==i&&(m.includes("/>")||m.includes("</"))?o+=i+e.indentBy+m+i:o+=m,o+=`</${h}>`):o+=g+"/>",a=!0,n.pop()}return o}function be(t,e){if(!t||e.ignoreAttributes)return null;const i={};let n=!1;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r.startsWith(e.attributeNamePrefix)?r.substr(e.attributeNamePrefix.length):r]=ae(t[r]),n=!0);return n?i:null}function ye(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let i="";for(let n=0;n<t.length;n++){const r=t[n],s=Ee(r);if(s===e.textNodeName)i+=r[s];else if(s===e.cdataPropName)i+=r[s][0][e.textNodeName];else if(s===e.commentPropName)i+=r[s][0][e.textNodeName];else{if(s&&"?"===s[0])continue;if(s){const t=Ne(r[":@"],e),n=ye(r[s],e);n&&0!==n.length?i+=`<${s}${t}>${n}</${s}>`:i+=`<${s}${t}/>`}}}return i}function Ne(t,e){let i="";if(t&&!e.ignoreAttributes)for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let r=t[n];!0===r&&e.suppressBooleanAttributes?i+=` ${n.substr(e.attributeNamePrefix.length)}`:i+=` ${n.substr(e.attributeNamePrefix.length)}="${ae(r)}"`}return i}function Ee(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const n=e[i];if(Object.prototype.hasOwnProperty.call(t,n)&&":@"!==n)return n}}function we(t,e,i,n,r){let s="";if(t&&!e.ignoreAttributes)for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const a=o.substr(e.attributeNamePrefix.length),l=i?a:ge(a,!0,e,n,r);let p;i?p=t[o]:(p=e.attributeValueProcessor(o,t[o]),p=Se(p,e)),!0===p&&e.suppressBooleanAttributes?s+=` ${l}`:s+=` ${l}="${ae(p)}"`}return s}function ve(t,e){if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t.matches(e[i]))return!0;return!1}function Se(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const n=e.entities[i];t=t.replace(n.regex,n.val)}return t}const Ae={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function Te(t){if(this.options=Object.assign({},Ae,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new st(e)):e instanceof st&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Pe),this.processTextOrObjNode=Ce,this.options.format?(this.indentate=$e,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function _e(t,e,i,n,r){return i.sanitizeName?fe(t,{xmlVersion:r})?t:i.sanitizeName(t,{isAttribute:e,matcher:n.readOnly()}):t}function Ce(t,e,i,n,r){const s=this.extractAttributes(t);if(n.push(e,s),this.checkStopNode(n)){const r=this.buildRawContent(t),s=this.buildAttributesForStopNode(t);return n.pop(),this.buildObjectNode(r,e,s,i)}const o=this.j2x(t,i+1,n,r);return n.pop(),"?"===e[0]?this.buildTextValNode("",e,o.attrStr,i,n):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,o.attrStr,i,n):this.buildObjectNode(o.val,e,o.attrStr,i)}function $e(t){return this.options.indentBy.repeat(t)}function Pe(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}Te.prototype.build=function(t){if(this.options.preserveOrder)return me(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new rt,i=function(t,e){const i=t["?xml"];if(i&&"object"==typeof i){if(e.attributesGroupName&&i[e.attributesGroupName]){const t=i[e.attributesGroupName][e.attributeNamePrefix+"version"];if(t)return t}const t=i[e.attributeNamePrefix+"version"];if(t)return t}return"1.0"}(t,this.options);return this.j2x(t,0,e,i).val}},Te.prototype.j2x=function(t,e,i,n){let r="",s="";if(this.options.maxNestedTags&&i.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const o=this.options.jPath?i.toString():i,a=this.checkStopNode(i);for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l))continue;const p=l===this.options.textNodeName||l===this.options.cdataPropName||l===this.options.commentPropName||this.options.attributesGroupName&&l===this.options.attributesGroupName||this.isAttribute(l)||"?"===l[0]?l:_e(l,!1,this.options,i,n);if(void 0===t[l])this.isAttribute(l)&&(s+="");else if(null===t[l])this.isAttribute(l)||p===this.options.cdataPropName||p===this.options.commentPropName?s+="":"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if(t[l]instanceof Date)s+=this.buildTextValNode(t[l],p,"",e,i);else if("object"!=typeof t[l]){const c=this.isAttribute(l);if(c&&!this.ignoreAttributesFn(c,o)){const e=_e(c,!0,this.options,i,n);r+=this.buildAttrPairStr(e,""+t[l],a)}else if(!c)if(l===this.options.textNodeName){let e=this.options.tagValueProcessor(l,""+t[l]);s+=this.replaceEntitiesValue(e)}else{i.push(p);const n=this.checkStopNode(i);if(i.pop(),n){const i=""+t[l];s+=""===i?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+i+"</"+p+this.tagEndChar}else s+=this.buildTextValNode(t[l],p,"",e,i)}}else if(Array.isArray(t[l])){const r=t[l].length;let o="",a="";for(let c=0;c<r;c++){const r=t[l][c];if(void 0===r);else if(null===r)"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if("object"==typeof r)if(this.options.oneListGroup){i.push(p);const t=this.j2x(r,e+1,i,n);i.pop(),o+=t.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else o+=this.processTextOrObjNode(r,p,e,i,n);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(p,r);t=this.replaceEntitiesValue(t),o+=t}else{i.push(p);const t=this.checkStopNode(i);if(i.pop(),t){const t=""+r;o+=""===t?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+t+"</"+p+this.tagEndChar}else o+=this.buildTextValNode(r,p,"",e,i)}}this.options.oneListGroup&&(o=this.buildObjectNode(o,p,a,e)),s+=o}else if(this.options.attributesGroupName&&l===this.options.attributesGroupName){const e=Object.keys(t[l]),s=e.length;for(let o=0;o<s;o++){const s=_e(e[o],!0,this.options,i,n);r+=this.buildAttrPairStr(s,""+t[l][e[o]],a)}}else s+=this.processTextOrObjNode(t[l],p,e,i,n)}return{attrStr:r,val:s}},Te.prototype.buildAttrPairStr=function(t,e,i){return i||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+ae(e)+'"'},Te.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let i=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const n=t[this.options.attributesGroupName];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=ae(n[t]),i=!0)}else for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=this.isAttribute(n);r&&(e[r]=ae(t[n]),i=!0)}return i?e:null},Te.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(this.isAttribute(i))continue;if(this.options.attributesGroupName&&i===this.options.attributesGroupName)continue;const n=t[i];if(i===this.options.textNodeName)e+=n;else if(Array.isArray(n)){for(let t of n)if("string"==typeof t||"number"==typeof t)e+=`<${i}>${t}</${i}>`;else if("object"==typeof t&&null!==t){const n=this.buildRawContent(t),r=this.buildAttributesForStopNode(t);e+=""===n?`<${i}${r}/>`:`<${i}${r}>${n}</${i}>`}}else if("object"==typeof n&&null!==n){const t=this.buildRawContent(n),r=this.buildAttributesForStopNode(n);e+=""===t?`<${i}${r}/>`:`<${i}${r}>${t}</${i}>`}else e+=`<${i}>${n}</${i}>`}return e},Te.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const i=t[this.options.attributesGroupName];for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;const n=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,r=i[t];!0===r&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+r+'"'}}else for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=this.isAttribute(i);if(n){const r=t[i];!0===r&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+r+'"'}}return e},Te.prototype.buildObjectNode=function(t,e,i,n){if(""===t)return"?"===e[0]?this.indentate(n)+"<"+e+i+"?"+this.tagEndChar:this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(n)+"<"+e+i+"?"+this.tagEndChar;{let r="</"+e+this.tagEndChar,s="";return"?"===e[0]&&(s="?",r=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(n)+"<"+e+i+s+this.tagEndChar+t+this.indentate(n)+r:this.indentate(n)+"<"+e+i+s+">"+t+r}},Te.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},Te.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},Te.prototype.buildTextValNode=function(t,e,i,n,r){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName){const e=oe(t);return this.indentate(n)+`<![CDATA[${e}]]>`+this.newLine}if(!1!==this.options.commentPropName&&e===this.options.commentPropName){const e=se(t);return this.indentate(n)+`\x3c!--${e}--\x3e`+this.newLine}if("?"===e[0])return this.indentate(n)+"<"+e+i+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),""===r?this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(n)+"<"+e+i+">"+r+"</"+e+this.tagEndChar}},Te.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};const Oe=Te,je={validate:p};module.exports=e})();
128037
128808
 
128038
128809
  /***/ },
128039
128810