nowbackup 1.0.3

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.
@@ -0,0 +1,4726 @@
1
+ import {
2
+ SerdeContextConfig,
3
+ SignatureV4,
4
+ UnionSerde
5
+ } from "./chunk-57ZU5VQ4.js";
6
+ import {
7
+ FromStringShapeDeserializer,
8
+ NormalizedSchema,
9
+ getValueFromTextNode
10
+ } from "./chunk-YMVDJI7O.js";
11
+ import {
12
+ toUtf8
13
+ } from "./chunk-APZ4HNNC.js";
14
+
15
+ // ../../node_modules/@smithy/signature-v4/dist-es/signature-v4a-container.js
16
+ var signatureV4aContainer = {
17
+ SignatureV4a: null
18
+ };
19
+
20
+ // ../../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/signature-v4-crt-container.js
21
+ var signatureV4CrtContainer = {
22
+ CrtSignerV4: null
23
+ };
24
+
25
+ // ../../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4SignWithCredentials.js
26
+ var SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
27
+ var SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
28
+ var SignatureV4SignWithCredentials = class extends SignatureV4 {
29
+ async signWithCredentials(requestToSign, credentials, options) {
30
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
31
+ requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
32
+ const privateAccess = this;
33
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
34
+ return privateAccess.signRequest(requestToSign, options ?? {});
35
+ }
36
+ async presignWithCredentials(requestToSign, credentials, options) {
37
+ const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
38
+ delete requestToSign.headers[SESSION_TOKEN_HEADER];
39
+ requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
40
+ requestToSign.query = requestToSign.query ?? {};
41
+ requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
42
+ const privateAccess = this;
43
+ setSingleOverride(privateAccess, credentialsWithoutSessionToken);
44
+ return this.presign(requestToSign, options);
45
+ }
46
+ };
47
+ function getCredentialsWithoutSessionToken(credentials) {
48
+ return {
49
+ accessKeyId: credentials.accessKeyId,
50
+ secretAccessKey: credentials.secretAccessKey,
51
+ expiration: credentials.expiration
52
+ };
53
+ }
54
+ function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
55
+ const currentCredentialProvider = privateAccess.credentialProvider;
56
+ privateAccess.credentialProvider = () => {
57
+ privateAccess.credentialProvider = currentCredentialProvider;
58
+ return Promise.resolve(credentialsWithoutSessionToken);
59
+ };
60
+ }
61
+
62
+ // ../../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4MultiRegion.js
63
+ var SignatureV4MultiRegion = class {
64
+ sigv4aSigner;
65
+ sigv4Signer;
66
+ signerOptions;
67
+ static sigv4aDependency() {
68
+ if (typeof signatureV4CrtContainer.CrtSignerV4 === "function") {
69
+ return "crt";
70
+ } else if (typeof signatureV4aContainer.SignatureV4a === "function") {
71
+ return "js";
72
+ }
73
+ return "none";
74
+ }
75
+ constructor(options) {
76
+ this.sigv4Signer = new SignatureV4SignWithCredentials(options);
77
+ this.signerOptions = options;
78
+ }
79
+ async sign(requestToSign, options = {}) {
80
+ if (options.signingRegion === "*") {
81
+ return this.getSigv4aSigner().sign(requestToSign, options);
82
+ }
83
+ return this.sigv4Signer.sign(requestToSign, options);
84
+ }
85
+ async signWithCredentials(requestToSign, credentials, options = {}) {
86
+ if (options.signingRegion === "*") {
87
+ const signer = this.getSigv4aSigner();
88
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
89
+ if (CrtSignerV4 && signer instanceof CrtSignerV4) {
90
+ return signer.signWithCredentials(requestToSign, credentials, options);
91
+ } else {
92
+ throw new Error(`signWithCredentials with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`);
93
+ }
94
+ }
95
+ return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options);
96
+ }
97
+ async presign(originalRequest, options = {}) {
98
+ if (options.signingRegion === "*") {
99
+ const signer = this.getSigv4aSigner();
100
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
101
+ if (CrtSignerV4 && signer instanceof CrtSignerV4) {
102
+ return signer.presign(originalRequest, options);
103
+ } else {
104
+ throw new Error(`presign with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`);
105
+ }
106
+ }
107
+ return this.sigv4Signer.presign(originalRequest, options);
108
+ }
109
+ async presignWithCredentials(originalRequest, credentials, options = {}) {
110
+ if (options.signingRegion === "*") {
111
+ throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");
112
+ }
113
+ return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options);
114
+ }
115
+ getSigv4aSigner() {
116
+ if (!this.sigv4aSigner) {
117
+ const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
118
+ const JsSigV4aSigner = signatureV4aContainer.SignatureV4a;
119
+ if (this.signerOptions.runtime === "node") {
120
+ if (!CrtSignerV4 && !JsSigV4aSigner) {
121
+ throw new Error("Neither CRT nor JS SigV4a implementation is available. Please load either @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");
122
+ }
123
+ if (CrtSignerV4 && typeof CrtSignerV4 === "function") {
124
+ this.sigv4aSigner = new CrtSignerV4({
125
+ ...this.signerOptions,
126
+ signingAlgorithm: 1
127
+ });
128
+ } else if (JsSigV4aSigner && typeof JsSigV4aSigner === "function") {
129
+ this.sigv4aSigner = new JsSigV4aSigner({
130
+ ...this.signerOptions
131
+ });
132
+ } else {
133
+ throw new Error("Available SigV4a implementation is not a valid constructor. Please ensure you've properly imported @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a.For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");
134
+ }
135
+ } else {
136
+ if (!JsSigV4aSigner || typeof JsSigV4aSigner !== "function") {
137
+ throw new Error("JS SigV4a implementation is not available or not a valid constructor. Please check whether you have installed the @aws-sdk/signature-v4a package explicitly. The CRT implementation is not available for browsers. You must also register the package by calling [require('@aws-sdk/signature-v4a');] or an ESM equivalent such as [import '@aws-sdk/signature-v4a';]. For more information please go to https://github.com/aws/aws-sdk-js-v3#using-javascript-non-crt-implementation-of-sigv4a");
138
+ }
139
+ this.sigv4aSigner = new JsSigV4aSigner({
140
+ ...this.signerOptions
141
+ });
142
+ }
143
+ }
144
+ return this.sigv4aSigner;
145
+ }
146
+ };
147
+
148
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js
149
+ var ATTR_ESCAPE_RE = /[&<>"]/g;
150
+ var ATTR_ESCAPE_MAP = {
151
+ "&": "&amp;",
152
+ "<": "&lt;",
153
+ ">": "&gt;",
154
+ '"': "&quot;"
155
+ };
156
+ function escapeAttribute(value) {
157
+ return value.replace(ATTR_ESCAPE_RE, (ch) => ATTR_ESCAPE_MAP[ch]);
158
+ }
159
+
160
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js
161
+ var ELEMENT_ESCAPE_RE = /[&"'<>\r\n\u0085\u2028]/g;
162
+ var ELEMENT_ESCAPE_MAP = {
163
+ "&": "&amp;",
164
+ '"': "&quot;",
165
+ "'": "&apos;",
166
+ "<": "&lt;",
167
+ ">": "&gt;",
168
+ "\r": "&#x0D;",
169
+ "\n": "&#x0A;",
170
+ "\x85": "&#x85;",
171
+ "\u2028": "&#x2028;"
172
+ };
173
+ function escapeElement(value) {
174
+ return value.replace(ELEMENT_ESCAPE_RE, (ch) => ELEMENT_ESCAPE_MAP[ch]);
175
+ }
176
+
177
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/XmlText.js
178
+ var XmlText = class {
179
+ value;
180
+ constructor(value) {
181
+ this.value = value;
182
+ }
183
+ toString() {
184
+ return escapeElement("" + this.value);
185
+ }
186
+ };
187
+
188
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/XmlNode.js
189
+ var XmlNode = class _XmlNode {
190
+ name;
191
+ children;
192
+ attributes = {};
193
+ static of(name, childText, withName) {
194
+ const node = new _XmlNode(name);
195
+ if (childText !== void 0) {
196
+ node.addChildNode(new XmlText(childText));
197
+ }
198
+ if (withName !== void 0) {
199
+ node.withName(withName);
200
+ }
201
+ return node;
202
+ }
203
+ constructor(name, children = []) {
204
+ this.name = name;
205
+ this.children = children;
206
+ }
207
+ withName(name) {
208
+ this.name = name;
209
+ return this;
210
+ }
211
+ addAttribute(name, value) {
212
+ this.attributes[name] = value;
213
+ return this;
214
+ }
215
+ addChildNode(child) {
216
+ this.children.push(child);
217
+ return this;
218
+ }
219
+ removeAttribute(name) {
220
+ delete this.attributes[name];
221
+ return this;
222
+ }
223
+ n(name) {
224
+ this.name = name;
225
+ return this;
226
+ }
227
+ c(child) {
228
+ this.children.push(child);
229
+ return this;
230
+ }
231
+ a(name, value) {
232
+ if (value != null) {
233
+ this.attributes[name] = value;
234
+ }
235
+ return this;
236
+ }
237
+ cc(input, field, withName = field) {
238
+ if (input[field] != null) {
239
+ const node = _XmlNode.of(field, input[field]).withName(withName);
240
+ this.c(node);
241
+ }
242
+ }
243
+ l(input, listName, memberName, valueProvider) {
244
+ if (input[listName] != null) {
245
+ const nodes = valueProvider();
246
+ nodes.map((node) => {
247
+ node.withName(memberName);
248
+ this.c(node);
249
+ });
250
+ }
251
+ }
252
+ lc(input, listName, memberName, valueProvider) {
253
+ if (input[listName] != null) {
254
+ const nodes = valueProvider();
255
+ const containerNode = new _XmlNode(memberName);
256
+ nodes.map((node) => {
257
+ containerNode.c(node);
258
+ });
259
+ this.c(containerNode);
260
+ }
261
+ }
262
+ toString() {
263
+ const hasChildren = Boolean(this.children.length);
264
+ let xmlText = `<${this.name}`;
265
+ const attributes = this.attributes;
266
+ for (const attributeName of Object.keys(attributes)) {
267
+ const attribute = attributes[attributeName];
268
+ if (attribute != null) {
269
+ xmlText += ` ${attributeName}="${escapeAttribute("" + attribute)}"`;
270
+ }
271
+ }
272
+ return xmlText += !hasChildren ? "/>" : `>${this.children.map((c) => c.toString()).join("")}</${this.name}>`;
273
+ }
274
+ };
275
+
276
+ // ../../node_modules/fast-xml-parser/src/util.js
277
+ var nameStartChar = ":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";
278
+ var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
279
+ var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
280
+ var regexName = new RegExp("^" + nameRegexp + "$");
281
+ function getAllMatches(string, regex) {
282
+ const matches = [];
283
+ let match = regex.exec(string);
284
+ while (match) {
285
+ const allmatches = [];
286
+ allmatches.startIndex = regex.lastIndex - match[0].length;
287
+ const len = match.length;
288
+ for (let index = 0; index < len; index++) {
289
+ allmatches.push(match[index]);
290
+ }
291
+ matches.push(allmatches);
292
+ match = regex.exec(string);
293
+ }
294
+ return matches;
295
+ }
296
+ var isName = function(string) {
297
+ const match = regexName.exec(string);
298
+ return !(match === null || typeof match === "undefined");
299
+ };
300
+ function isExist(v) {
301
+ return typeof v !== "undefined";
302
+ }
303
+ var DANGEROUS_PROPERTY_NAMES = [
304
+ // '__proto__',
305
+ // 'constructor',
306
+ // 'prototype',
307
+ "hasOwnProperty",
308
+ "toString",
309
+ "valueOf",
310
+ "__defineGetter__",
311
+ "__defineSetter__",
312
+ "__lookupGetter__",
313
+ "__lookupSetter__"
314
+ ];
315
+ var criticalProperties = ["__proto__", "constructor", "prototype"];
316
+
317
+ // ../../node_modules/fast-xml-parser/src/validator.js
318
+ var defaultOptions = {
319
+ allowBooleanAttributes: false,
320
+ //A tag can have attributes without any value
321
+ unpairedTags: []
322
+ };
323
+ function validate(xmlData, options) {
324
+ options = Object.assign({}, defaultOptions, options);
325
+ const tags = [];
326
+ let tagFound = false;
327
+ let reachedRoot = false;
328
+ if (xmlData[0] === "\uFEFF") {
329
+ xmlData = xmlData.substr(1);
330
+ }
331
+ for (let i = 0; i < xmlData.length; i++) {
332
+ if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
333
+ i += 2;
334
+ i = readPI(xmlData, i);
335
+ if (i.err) return i;
336
+ } else if (xmlData[i] === "<") {
337
+ let tagStartPos = i;
338
+ i++;
339
+ if (xmlData[i] === "!") {
340
+ i = readCommentAndCDATA(xmlData, i);
341
+ continue;
342
+ } else {
343
+ let closingTag = false;
344
+ if (xmlData[i] === "/") {
345
+ closingTag = true;
346
+ i++;
347
+ }
348
+ let tagName = "";
349
+ for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
350
+ tagName += xmlData[i];
351
+ }
352
+ tagName = tagName.trim();
353
+ if (tagName[tagName.length - 1] === "/") {
354
+ tagName = tagName.substring(0, tagName.length - 1);
355
+ i--;
356
+ }
357
+ if (!validateTagName(tagName)) {
358
+ let msg;
359
+ if (tagName.trim().length === 0) {
360
+ msg = "Invalid space after '<'.";
361
+ } else {
362
+ msg = "Tag '" + tagName + "' is an invalid name.";
363
+ }
364
+ return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
365
+ }
366
+ const result = readAttributeStr(xmlData, i);
367
+ if (result === false) {
368
+ return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
369
+ }
370
+ let attrStr = result.value;
371
+ i = result.index;
372
+ if (attrStr[attrStr.length - 1] === "/") {
373
+ const attrStrStart = i - attrStr.length;
374
+ attrStr = attrStr.substring(0, attrStr.length - 1);
375
+ const isValid = validateAttributeString(attrStr, options);
376
+ if (isValid === true) {
377
+ tagFound = true;
378
+ } else {
379
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
380
+ }
381
+ } else if (closingTag) {
382
+ if (!result.tagClosed) {
383
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
384
+ } else if (attrStr.trim().length > 0) {
385
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
386
+ } else if (tags.length === 0) {
387
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
388
+ } else {
389
+ const otg = tags.pop();
390
+ if (tagName !== otg.tagName) {
391
+ let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
392
+ return getErrorObject(
393
+ "InvalidTag",
394
+ "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
395
+ getLineNumberForPosition(xmlData, tagStartPos)
396
+ );
397
+ }
398
+ if (tags.length == 0) {
399
+ reachedRoot = true;
400
+ }
401
+ }
402
+ } else {
403
+ const isValid = validateAttributeString(attrStr, options);
404
+ if (isValid !== true) {
405
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
406
+ }
407
+ if (reachedRoot === true) {
408
+ return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
409
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) {
410
+ } else {
411
+ tags.push({ tagName, tagStartPos });
412
+ }
413
+ tagFound = true;
414
+ }
415
+ for (i++; i < xmlData.length; i++) {
416
+ if (xmlData[i] === "<") {
417
+ if (xmlData[i + 1] === "!") {
418
+ i++;
419
+ i = readCommentAndCDATA(xmlData, i);
420
+ continue;
421
+ } else if (xmlData[i + 1] === "?") {
422
+ i = readPI(xmlData, ++i);
423
+ if (i.err) return i;
424
+ } else {
425
+ break;
426
+ }
427
+ } else if (xmlData[i] === "&") {
428
+ const afterAmp = validateAmpersand(xmlData, i);
429
+ if (afterAmp == -1)
430
+ return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
431
+ i = afterAmp;
432
+ } else {
433
+ if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
434
+ return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
435
+ }
436
+ }
437
+ }
438
+ if (xmlData[i] === "<") {
439
+ i--;
440
+ }
441
+ }
442
+ } else {
443
+ if (isWhiteSpace(xmlData[i])) {
444
+ continue;
445
+ }
446
+ return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
447
+ }
448
+ }
449
+ if (!tagFound) {
450
+ return getErrorObject("InvalidXml", "Start tag expected.", 1);
451
+ } else if (tags.length == 1) {
452
+ return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
453
+ } else if (tags.length > 0) {
454
+ return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
455
+ }
456
+ return true;
457
+ }
458
+ function isWhiteSpace(char) {
459
+ return char === " " || char === " " || char === "\n" || char === "\r";
460
+ }
461
+ function readPI(xmlData, i) {
462
+ const start = i;
463
+ for (; i < xmlData.length; i++) {
464
+ if (xmlData[i] == "?" || xmlData[i] == " ") {
465
+ const tagname = xmlData.substr(start, i - start);
466
+ if (i > 5 && tagname === "xml") {
467
+ return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
468
+ } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
469
+ i++;
470
+ break;
471
+ } else {
472
+ continue;
473
+ }
474
+ }
475
+ }
476
+ return i;
477
+ }
478
+ function readCommentAndCDATA(xmlData, i) {
479
+ if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
480
+ for (i += 3; i < xmlData.length; i++) {
481
+ if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
482
+ i += 2;
483
+ break;
484
+ }
485
+ }
486
+ } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
487
+ let angleBracketsCount = 1;
488
+ for (i += 8; i < xmlData.length; i++) {
489
+ if (xmlData[i] === "<") {
490
+ angleBracketsCount++;
491
+ } else if (xmlData[i] === ">") {
492
+ angleBracketsCount--;
493
+ if (angleBracketsCount === 0) {
494
+ break;
495
+ }
496
+ }
497
+ }
498
+ } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
499
+ for (i += 8; i < xmlData.length; i++) {
500
+ if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
501
+ i += 2;
502
+ break;
503
+ }
504
+ }
505
+ }
506
+ return i;
507
+ }
508
+ var doubleQuote = '"';
509
+ var singleQuote = "'";
510
+ function readAttributeStr(xmlData, i) {
511
+ let attrStr = "";
512
+ let startChar = "";
513
+ let tagClosed = false;
514
+ for (; i < xmlData.length; i++) {
515
+ if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
516
+ if (startChar === "") {
517
+ startChar = xmlData[i];
518
+ } else if (startChar !== xmlData[i]) {
519
+ } else {
520
+ startChar = "";
521
+ }
522
+ } else if (xmlData[i] === ">") {
523
+ if (startChar === "") {
524
+ tagClosed = true;
525
+ break;
526
+ }
527
+ }
528
+ attrStr += xmlData[i];
529
+ }
530
+ if (startChar !== "") {
531
+ return false;
532
+ }
533
+ return {
534
+ value: attrStr,
535
+ index: i,
536
+ tagClosed
537
+ };
538
+ }
539
+ var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
540
+ function validateAttributeString(attrStr, options) {
541
+ const matches = getAllMatches(attrStr, validAttrStrRegxp);
542
+ const attrNames = {};
543
+ for (let i = 0; i < matches.length; i++) {
544
+ if (matches[i][1].length === 0) {
545
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
546
+ } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
547
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
548
+ } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
549
+ return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
550
+ }
551
+ const attrName = matches[i][2];
552
+ if (!validateAttrName(attrName)) {
553
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
554
+ }
555
+ if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
556
+ attrNames[attrName] = 1;
557
+ } else {
558
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
559
+ }
560
+ }
561
+ return true;
562
+ }
563
+ function validateNumberAmpersand(xmlData, i) {
564
+ let re = /\d/;
565
+ if (xmlData[i] === "x") {
566
+ i++;
567
+ re = /[\da-fA-F]/;
568
+ }
569
+ for (; i < xmlData.length; i++) {
570
+ if (xmlData[i] === ";")
571
+ return i;
572
+ if (!xmlData[i].match(re))
573
+ break;
574
+ }
575
+ return -1;
576
+ }
577
+ function validateAmpersand(xmlData, i) {
578
+ i++;
579
+ if (xmlData[i] === ";")
580
+ return -1;
581
+ if (xmlData[i] === "#") {
582
+ i++;
583
+ return validateNumberAmpersand(xmlData, i);
584
+ }
585
+ let count = 0;
586
+ for (; i < xmlData.length; i++, count++) {
587
+ if (xmlData[i].match(/\w/) && count < 20)
588
+ continue;
589
+ if (xmlData[i] === ";")
590
+ break;
591
+ return -1;
592
+ }
593
+ return i;
594
+ }
595
+ function getErrorObject(code, message, lineNumber) {
596
+ return {
597
+ err: {
598
+ code,
599
+ msg: message,
600
+ line: lineNumber.line || lineNumber,
601
+ col: lineNumber.col
602
+ }
603
+ };
604
+ }
605
+ function validateAttrName(attrName) {
606
+ return isName(attrName);
607
+ }
608
+ function validateTagName(tagname) {
609
+ return isName(tagname);
610
+ }
611
+ function getLineNumberForPosition(xmlData, index) {
612
+ const lines = xmlData.substring(0, index).split(/\r?\n/);
613
+ return {
614
+ line: lines.length,
615
+ // column number is last line's length + 1, because column numbering starts at 1:
616
+ col: lines[lines.length - 1].length + 1
617
+ };
618
+ }
619
+ function getPositionFromMatch(match) {
620
+ return match.startIndex + match[1].length;
621
+ }
622
+
623
+ // ../../node_modules/@nodable/entities/src/entities.js
624
+ var BASIC_LATIN = {
625
+ amp: "&",
626
+ AMP: "&",
627
+ lt: "<",
628
+ LT: "<",
629
+ gt: ">",
630
+ GT: ">",
631
+ quot: '"',
632
+ QUOT: '"',
633
+ apos: "'",
634
+ lsquo: "\u2018",
635
+ rsquo: "\u2019",
636
+ ldquo: "\u201C",
637
+ rdquo: "\u201D",
638
+ lsquor: "\u201A",
639
+ rsquor: "\u2019",
640
+ ldquor: "\u201E",
641
+ bdquo: "\u201E",
642
+ comma: ",",
643
+ period: ".",
644
+ colon: ":",
645
+ semi: ";",
646
+ excl: "!",
647
+ quest: "?",
648
+ num: "#",
649
+ dollar: "$",
650
+ percent: "%",
651
+ amp: "&",
652
+ ast: "*",
653
+ commat: "@",
654
+ lowbar: "_",
655
+ verbar: "|",
656
+ vert: "|",
657
+ sol: "/",
658
+ bsol: "\\",
659
+ lbrace: "{",
660
+ rbrace: "}",
661
+ lbrack: "[",
662
+ rbrack: "]",
663
+ lpar: "(",
664
+ rpar: ")",
665
+ nbsp: "\xA0",
666
+ iexcl: "\xA1",
667
+ cent: "\xA2",
668
+ pound: "\xA3",
669
+ curren: "\xA4",
670
+ yen: "\xA5",
671
+ brvbar: "\xA6",
672
+ sect: "\xA7",
673
+ uml: "\xA8",
674
+ copy: "\xA9",
675
+ COPY: "\xA9",
676
+ ordf: "\xAA",
677
+ laquo: "\xAB",
678
+ not: "\xAC",
679
+ shy: "\xAD",
680
+ reg: "\xAE",
681
+ REG: "\xAE",
682
+ macr: "\xAF",
683
+ deg: "\xB0",
684
+ plusmn: "\xB1",
685
+ sup2: "\xB2",
686
+ sup3: "\xB3",
687
+ acute: "\xB4",
688
+ micro: "\xB5",
689
+ para: "\xB6",
690
+ middot: "\xB7",
691
+ cedil: "\xB8",
692
+ sup1: "\xB9",
693
+ ordm: "\xBA",
694
+ raquo: "\xBB",
695
+ frac14: "\xBC",
696
+ frac12: "\xBD",
697
+ half: "\xBD",
698
+ frac34: "\xBE",
699
+ iquest: "\xBF",
700
+ times: "\xD7",
701
+ div: "\xF7",
702
+ divide: "\xF7"
703
+ };
704
+ var LATIN_ACCENTS = {
705
+ Agrave: "\xC0",
706
+ agrave: "\xE0",
707
+ Aacute: "\xC1",
708
+ aacute: "\xE1",
709
+ Acirc: "\xC2",
710
+ acirc: "\xE2",
711
+ Atilde: "\xC3",
712
+ atilde: "\xE3",
713
+ Auml: "\xC4",
714
+ auml: "\xE4",
715
+ Aring: "\xC5",
716
+ aring: "\xE5",
717
+ AElig: "\xC6",
718
+ aelig: "\xE6",
719
+ Ccedil: "\xC7",
720
+ ccedil: "\xE7",
721
+ Egrave: "\xC8",
722
+ egrave: "\xE8",
723
+ Eacute: "\xC9",
724
+ eacute: "\xE9",
725
+ Ecirc: "\xCA",
726
+ ecirc: "\xEA",
727
+ Euml: "\xCB",
728
+ euml: "\xEB",
729
+ Igrave: "\xCC",
730
+ igrave: "\xEC",
731
+ Iacute: "\xCD",
732
+ iacute: "\xED",
733
+ Icirc: "\xCE",
734
+ icirc: "\xEE",
735
+ Iuml: "\xCF",
736
+ iuml: "\xEF",
737
+ ETH: "\xD0",
738
+ eth: "\xF0",
739
+ Ntilde: "\xD1",
740
+ ntilde: "\xF1",
741
+ Ograve: "\xD2",
742
+ ograve: "\xF2",
743
+ Oacute: "\xD3",
744
+ oacute: "\xF3",
745
+ Ocirc: "\xD4",
746
+ ocirc: "\xF4",
747
+ Otilde: "\xD5",
748
+ otilde: "\xF5",
749
+ Ouml: "\xD6",
750
+ ouml: "\xF6",
751
+ Oslash: "\xD8",
752
+ oslash: "\xF8",
753
+ Ugrave: "\xD9",
754
+ ugrave: "\xF9",
755
+ Uacute: "\xDA",
756
+ uacute: "\xFA",
757
+ Ucirc: "\xDB",
758
+ ucirc: "\xFB",
759
+ Uuml: "\xDC",
760
+ uuml: "\xFC",
761
+ Yacute: "\xDD",
762
+ yacute: "\xFD",
763
+ THORN: "\xDE",
764
+ thorn: "\xFE",
765
+ szlig: "\xDF",
766
+ yuml: "\xFF",
767
+ Yuml: "\u0178"
768
+ };
769
+ var LATIN_EXTENDED = {
770
+ Amacr: "\u0100",
771
+ amacr: "\u0101",
772
+ Abreve: "\u0102",
773
+ abreve: "\u0103",
774
+ Aogon: "\u0104",
775
+ aogon: "\u0105",
776
+ Cacute: "\u0106",
777
+ cacute: "\u0107",
778
+ Ccirc: "\u0108",
779
+ ccirc: "\u0109",
780
+ Cdot: "\u010A",
781
+ cdot: "\u010B",
782
+ Ccaron: "\u010C",
783
+ ccaron: "\u010D",
784
+ Dcaron: "\u010E",
785
+ dcaron: "\u010F",
786
+ Dstrok: "\u0110",
787
+ dstrok: "\u0111",
788
+ Emacr: "\u0112",
789
+ emacr: "\u0113",
790
+ Ecaron: "\u011A",
791
+ ecaron: "\u011B",
792
+ Edot: "\u0116",
793
+ edot: "\u0117",
794
+ Eogon: "\u0118",
795
+ eogon: "\u0119",
796
+ Gcirc: "\u011C",
797
+ gcirc: "\u011D",
798
+ Gbreve: "\u011E",
799
+ gbreve: "\u011F",
800
+ Gdot: "\u0120",
801
+ gdot: "\u0121",
802
+ Gcedil: "\u0122",
803
+ Hcirc: "\u0124",
804
+ hcirc: "\u0125",
805
+ Hstrok: "\u0126",
806
+ hstrok: "\u0127",
807
+ Itilde: "\u0128",
808
+ itilde: "\u0129",
809
+ Imacr: "\u012A",
810
+ imacr: "\u012B",
811
+ Iogon: "\u012E",
812
+ iogon: "\u012F",
813
+ Idot: "\u0130",
814
+ IJlig: "\u0132",
815
+ ijlig: "\u0133",
816
+ Jcirc: "\u0134",
817
+ jcirc: "\u0135",
818
+ Kcedil: "\u0136",
819
+ kcedil: "\u0137",
820
+ kgreen: "\u0138",
821
+ Lacute: "\u0139",
822
+ lacute: "\u013A",
823
+ Lcedil: "\u013B",
824
+ lcedil: "\u013C",
825
+ Lcaron: "\u013D",
826
+ lcaron: "\u013E",
827
+ Lmidot: "\u013F",
828
+ lmidot: "\u0140",
829
+ Lstrok: "\u0141",
830
+ lstrok: "\u0142",
831
+ Nacute: "\u0143",
832
+ nacute: "\u0144",
833
+ Ncaron: "\u0147",
834
+ ncaron: "\u0148",
835
+ Ncedil: "\u0145",
836
+ ncedil: "\u0146",
837
+ ENG: "\u014A",
838
+ eng: "\u014B",
839
+ Omacr: "\u014C",
840
+ omacr: "\u014D",
841
+ Odblac: "\u0150",
842
+ odblac: "\u0151",
843
+ OElig: "\u0152",
844
+ oelig: "\u0153",
845
+ Racute: "\u0154",
846
+ racute: "\u0155",
847
+ Rcaron: "\u0158",
848
+ rcaron: "\u0159",
849
+ Rcedil: "\u0156",
850
+ rcedil: "\u0157",
851
+ Sacute: "\u015A",
852
+ sacute: "\u015B",
853
+ Scirc: "\u015C",
854
+ scirc: "\u015D",
855
+ Scedil: "\u015E",
856
+ scedil: "\u015F",
857
+ Scaron: "\u0160",
858
+ scaron: "\u0161",
859
+ Tcedil: "\u0162",
860
+ tcedil: "\u0163",
861
+ Tcaron: "\u0164",
862
+ tcaron: "\u0165",
863
+ Tstrok: "\u0166",
864
+ tstrok: "\u0167",
865
+ Utilde: "\u0168",
866
+ utilde: "\u0169",
867
+ Umacr: "\u016A",
868
+ umacr: "\u016B",
869
+ Ubreve: "\u016C",
870
+ ubreve: "\u016D",
871
+ Uring: "\u016E",
872
+ uring: "\u016F",
873
+ Udblac: "\u0170",
874
+ udblac: "\u0171",
875
+ Uogon: "\u0172",
876
+ uogon: "\u0173",
877
+ Wcirc: "\u0174",
878
+ wcirc: "\u0175",
879
+ Ycirc: "\u0176",
880
+ ycirc: "\u0177",
881
+ Zacute: "\u0179",
882
+ zacute: "\u017A",
883
+ Zdot: "\u017B",
884
+ zdot: "\u017C",
885
+ Zcaron: "\u017D",
886
+ zcaron: "\u017E"
887
+ };
888
+ var GREEK = {
889
+ Alpha: "\u0391",
890
+ alpha: "\u03B1",
891
+ Beta: "\u0392",
892
+ beta: "\u03B2",
893
+ Gamma: "\u0393",
894
+ gamma: "\u03B3",
895
+ Delta: "\u0394",
896
+ delta: "\u03B4",
897
+ Epsilon: "\u0395",
898
+ epsilon: "\u03B5",
899
+ epsiv: "\u03F5",
900
+ varepsilon: "\u03F5",
901
+ Zeta: "\u0396",
902
+ zeta: "\u03B6",
903
+ Eta: "\u0397",
904
+ eta: "\u03B7",
905
+ Theta: "\u0398",
906
+ theta: "\u03B8",
907
+ thetasym: "\u03D1",
908
+ vartheta: "\u03D1",
909
+ Iota: "\u0399",
910
+ iota: "\u03B9",
911
+ Kappa: "\u039A",
912
+ kappa: "\u03BA",
913
+ kappav: "\u03F0",
914
+ varkappa: "\u03F0",
915
+ Lambda: "\u039B",
916
+ lambda: "\u03BB",
917
+ Mu: "\u039C",
918
+ mu: "\u03BC",
919
+ Nu: "\u039D",
920
+ nu: "\u03BD",
921
+ Xi: "\u039E",
922
+ xi: "\u03BE",
923
+ Omicron: "\u039F",
924
+ omicron: "\u03BF",
925
+ Pi: "\u03A0",
926
+ pi: "\u03C0",
927
+ piv: "\u03D6",
928
+ varpi: "\u03D6",
929
+ Rho: "\u03A1",
930
+ rho: "\u03C1",
931
+ rhov: "\u03F1",
932
+ varrho: "\u03F1",
933
+ Sigma: "\u03A3",
934
+ sigma: "\u03C3",
935
+ sigmaf: "\u03C2",
936
+ sigmav: "\u03C2",
937
+ varsigma: "\u03C2",
938
+ Tau: "\u03A4",
939
+ tau: "\u03C4",
940
+ Upsilon: "\u03A5",
941
+ upsilon: "\u03C5",
942
+ upsi: "\u03C5",
943
+ Upsi: "\u03D2",
944
+ upsih: "\u03D2",
945
+ Phi: "\u03A6",
946
+ phi: "\u03C6",
947
+ phiv: "\u03D5",
948
+ varphi: "\u03D5",
949
+ Chi: "\u03A7",
950
+ chi: "\u03C7",
951
+ Psi: "\u03A8",
952
+ psi: "\u03C8",
953
+ Omega: "\u03A9",
954
+ omega: "\u03C9",
955
+ ohm: "\u03A9",
956
+ Gammad: "\u03DC",
957
+ gammad: "\u03DD",
958
+ digamma: "\u03DD"
959
+ };
960
+ var CYRILLIC = {
961
+ Afr: "\u{1D504}",
962
+ afr: "\u{1D51E}",
963
+ Acy: "\u0410",
964
+ acy: "\u0430",
965
+ Bcy: "\u0411",
966
+ bcy: "\u0431",
967
+ Vcy: "\u0412",
968
+ vcy: "\u0432",
969
+ Gcy: "\u0413",
970
+ gcy: "\u0433",
971
+ Dcy: "\u0414",
972
+ dcy: "\u0434",
973
+ IEcy: "\u0415",
974
+ iecy: "\u0435",
975
+ IOcy: "\u0401",
976
+ iocy: "\u0451",
977
+ ZHcy: "\u0416",
978
+ zhcy: "\u0436",
979
+ Zcy: "\u0417",
980
+ zcy: "\u0437",
981
+ Icy: "\u0418",
982
+ icy: "\u0438",
983
+ Jcy: "\u0419",
984
+ jcy: "\u0439",
985
+ Kcy: "\u041A",
986
+ kcy: "\u043A",
987
+ Lcy: "\u041B",
988
+ lcy: "\u043B",
989
+ Mcy: "\u041C",
990
+ mcy: "\u043C",
991
+ Ncy: "\u041D",
992
+ ncy: "\u043D",
993
+ Ocy: "\u041E",
994
+ ocy: "\u043E",
995
+ Pcy: "\u041F",
996
+ pcy: "\u043F",
997
+ Rcy: "\u0420",
998
+ rcy: "\u0440",
999
+ Scy: "\u0421",
1000
+ scy: "\u0441",
1001
+ Tcy: "\u0422",
1002
+ tcy: "\u0442",
1003
+ Ucy: "\u0423",
1004
+ ucy: "\u0443",
1005
+ Fcy: "\u0424",
1006
+ fcy: "\u0444",
1007
+ KHcy: "\u0425",
1008
+ khcy: "\u0445",
1009
+ TScy: "\u0426",
1010
+ tscy: "\u0446",
1011
+ CHcy: "\u0427",
1012
+ chcy: "\u0447",
1013
+ SHcy: "\u0428",
1014
+ shcy: "\u0448",
1015
+ SHCHcy: "\u0429",
1016
+ shchcy: "\u0449",
1017
+ HARDcy: "\u042A",
1018
+ hardcy: "\u044A",
1019
+ Ycy: "\u042B",
1020
+ ycy: "\u044B",
1021
+ SOFTcy: "\u042C",
1022
+ softcy: "\u044C",
1023
+ Ecy: "\u042D",
1024
+ ecy: "\u044D",
1025
+ YUcy: "\u042E",
1026
+ yucy: "\u044E",
1027
+ YAcy: "\u042F",
1028
+ yacy: "\u044F",
1029
+ DJcy: "\u0402",
1030
+ djcy: "\u0452",
1031
+ GJcy: "\u0403",
1032
+ gjcy: "\u0453",
1033
+ Jukcy: "\u0404",
1034
+ jukcy: "\u0454",
1035
+ DScy: "\u0405",
1036
+ dscy: "\u0455",
1037
+ Iukcy: "\u0406",
1038
+ iukcy: "\u0456",
1039
+ YIcy: "\u0407",
1040
+ yicy: "\u0457",
1041
+ Jsercy: "\u0408",
1042
+ jsercy: "\u0458",
1043
+ LJcy: "\u0409",
1044
+ ljcy: "\u0459",
1045
+ NJcy: "\u040A",
1046
+ njcy: "\u045A",
1047
+ TSHcy: "\u040B",
1048
+ tshcy: "\u045B",
1049
+ KJcy: "\u040C",
1050
+ kjcy: "\u045C",
1051
+ Ubrcy: "\u040E",
1052
+ ubrcy: "\u045E",
1053
+ DZcy: "\u040F",
1054
+ dzcy: "\u045F"
1055
+ };
1056
+ var MATH = {
1057
+ plus: "+",
1058
+ minus: "\u2212",
1059
+ mnplus: "\u2213",
1060
+ mp: "\u2213",
1061
+ pm: "\xB1",
1062
+ times: "\xD7",
1063
+ div: "\xF7",
1064
+ divide: "\xF7",
1065
+ sdot: "\u22C5",
1066
+ star: "\u2606",
1067
+ starf: "\u2605",
1068
+ bigstar: "\u2605",
1069
+ lowast: "\u2217",
1070
+ ast: "*",
1071
+ midast: "*",
1072
+ compfn: "\u2218",
1073
+ smallcircle: "\u2218",
1074
+ bullet: "\u2022",
1075
+ bull: "\u2022",
1076
+ nbsp: "\xA0",
1077
+ hellip: "\u2026",
1078
+ mldr: "\u2026",
1079
+ prime: "\u2032",
1080
+ Prime: "\u2033",
1081
+ tprime: "\u2034",
1082
+ bprime: "\u2035",
1083
+ backprime: "\u2035",
1084
+ minus: "\u2212",
1085
+ minusd: "\u2238",
1086
+ dotminus: "\u2238",
1087
+ plusdo: "\u2214",
1088
+ dotplus: "\u2214",
1089
+ plusmn: "\xB1",
1090
+ minusplus: "\u2213",
1091
+ mnplus: "\u2213",
1092
+ mp: "\u2213",
1093
+ setminus: "\u2216",
1094
+ smallsetminus: "\u2216",
1095
+ Backslash: "\u2216",
1096
+ setmn: "\u2216",
1097
+ ssetmn: "\u2216",
1098
+ lowbar: "_",
1099
+ verbar: "|",
1100
+ vert: "|",
1101
+ VerticalLine: "|",
1102
+ colon: ":",
1103
+ Colon: "\u2237",
1104
+ Proportion: "\u2237",
1105
+ ratio: "\u2236",
1106
+ equals: "=",
1107
+ ne: "\u2260",
1108
+ nequiv: "\u2262",
1109
+ equiv: "\u2261",
1110
+ Congruent: "\u2261",
1111
+ sim: "\u223C",
1112
+ thicksim: "\u223C",
1113
+ thksim: "\u223C",
1114
+ sime: "\u2243",
1115
+ simeq: "\u2243",
1116
+ TildeEqual: "\u2243",
1117
+ asymp: "\u2248",
1118
+ approx: "\u2248",
1119
+ thickapprox: "\u2248",
1120
+ thkap: "\u2248",
1121
+ TildeTilde: "\u2248",
1122
+ ncong: "\u2247",
1123
+ cong: "\u2245",
1124
+ TildeFullEqual: "\u2245",
1125
+ asympeq: "\u224D",
1126
+ CupCap: "\u224D",
1127
+ bump: "\u224E",
1128
+ Bumpeq: "\u224E",
1129
+ HumpDownHump: "\u224E",
1130
+ bumpe: "\u224F",
1131
+ bumpeq: "\u224F",
1132
+ HumpEqual: "\u224F",
1133
+ dotminus: "\u2238",
1134
+ minusd: "\u2238",
1135
+ plusdo: "\u2214",
1136
+ dotplus: "\u2214",
1137
+ le: "\u2264",
1138
+ LessEqual: "\u2264",
1139
+ ge: "\u2265",
1140
+ GreaterEqual: "\u2265",
1141
+ lesseqgtr: "\u22DA",
1142
+ lesseqqgtr: "\u2A8B",
1143
+ greater: ">",
1144
+ less: "<"
1145
+ };
1146
+ var MATH_ADVANCED = {
1147
+ alefsym: "\u2135",
1148
+ aleph: "\u2135",
1149
+ beth: "\u2136",
1150
+ gimel: "\u2137",
1151
+ daleth: "\u2138",
1152
+ forall: "\u2200",
1153
+ ForAll: "\u2200",
1154
+ part: "\u2202",
1155
+ PartialD: "\u2202",
1156
+ exist: "\u2203",
1157
+ Exists: "\u2203",
1158
+ nexist: "\u2204",
1159
+ nexists: "\u2204",
1160
+ empty: "\u2205",
1161
+ emptyset: "\u2205",
1162
+ emptyv: "\u2205",
1163
+ varnothing: "\u2205",
1164
+ nabla: "\u2207",
1165
+ Del: "\u2207",
1166
+ isin: "\u2208",
1167
+ isinv: "\u2208",
1168
+ in: "\u2208",
1169
+ Element: "\u2208",
1170
+ notin: "\u2209",
1171
+ notinva: "\u2209",
1172
+ ni: "\u220B",
1173
+ niv: "\u220B",
1174
+ SuchThat: "\u220B",
1175
+ ReverseElement: "\u220B",
1176
+ notni: "\u220C",
1177
+ notniva: "\u220C",
1178
+ prod: "\u220F",
1179
+ Product: "\u220F",
1180
+ coprod: "\u2210",
1181
+ Coproduct: "\u2210",
1182
+ sum: "\u2211",
1183
+ Sum: "\u2211",
1184
+ minus: "\u2212",
1185
+ mp: "\u2213",
1186
+ plusdo: "\u2214",
1187
+ dotplus: "\u2214",
1188
+ setminus: "\u2216",
1189
+ lowast: "\u2217",
1190
+ radic: "\u221A",
1191
+ Sqrt: "\u221A",
1192
+ prop: "\u221D",
1193
+ propto: "\u221D",
1194
+ Proportional: "\u221D",
1195
+ varpropto: "\u221D",
1196
+ infin: "\u221E",
1197
+ infintie: "\u29DD",
1198
+ ang: "\u2220",
1199
+ angle: "\u2220",
1200
+ angmsd: "\u2221",
1201
+ measuredangle: "\u2221",
1202
+ angsph: "\u2222",
1203
+ mid: "\u2223",
1204
+ VerticalBar: "\u2223",
1205
+ nmid: "\u2224",
1206
+ nsmid: "\u2224",
1207
+ npar: "\u2226",
1208
+ parallel: "\u2225",
1209
+ spar: "\u2225",
1210
+ nparallel: "\u2226",
1211
+ nspar: "\u2226",
1212
+ and: "\u2227",
1213
+ wedge: "\u2227",
1214
+ or: "\u2228",
1215
+ vee: "\u2228",
1216
+ cap: "\u2229",
1217
+ cup: "\u222A",
1218
+ int: "\u222B",
1219
+ Integral: "\u222B",
1220
+ conint: "\u222E",
1221
+ ContourIntegral: "\u222E",
1222
+ Conint: "\u222F",
1223
+ DoubleContourIntegral: "\u222F",
1224
+ Cconint: "\u2230",
1225
+ there4: "\u2234",
1226
+ therefore: "\u2234",
1227
+ Therefore: "\u2234",
1228
+ becaus: "\u2235",
1229
+ because: "\u2235",
1230
+ Because: "\u2235",
1231
+ ratio: "\u2236",
1232
+ Proportion: "\u2237",
1233
+ minusd: "\u2238",
1234
+ dotminus: "\u2238",
1235
+ mDDot: "\u223A",
1236
+ homtht: "\u223B",
1237
+ sim: "\u223C",
1238
+ bsimg: "\u223D",
1239
+ backsim: "\u223D",
1240
+ ac: "\u223E",
1241
+ mstpos: "\u223E",
1242
+ acd: "\u223F",
1243
+ VerticalTilde: "\u2240",
1244
+ wr: "\u2240",
1245
+ wreath: "\u2240",
1246
+ nsime: "\u2244",
1247
+ nsimeq: "\u2244",
1248
+ nsimeq: "\u2244",
1249
+ ncong: "\u2247",
1250
+ simne: "\u2246",
1251
+ ncongdot: "\u2A6D\u0338",
1252
+ ngsim: "\u2275",
1253
+ nsim: "\u2241",
1254
+ napprox: "\u2249",
1255
+ nap: "\u2249",
1256
+ ngeq: "\u2271",
1257
+ nge: "\u2271",
1258
+ nleq: "\u2270",
1259
+ nle: "\u2270",
1260
+ ngtr: "\u226F",
1261
+ ngt: "\u226F",
1262
+ nless: "\u226E",
1263
+ nlt: "\u226E",
1264
+ nprec: "\u2280",
1265
+ npr: "\u2280",
1266
+ nsucc: "\u2281",
1267
+ nsc: "\u2281"
1268
+ };
1269
+ var ARROWS = {
1270
+ larr: "\u2190",
1271
+ leftarrow: "\u2190",
1272
+ LeftArrow: "\u2190",
1273
+ uarr: "\u2191",
1274
+ uparrow: "\u2191",
1275
+ UpArrow: "\u2191",
1276
+ rarr: "\u2192",
1277
+ rightarrow: "\u2192",
1278
+ RightArrow: "\u2192",
1279
+ darr: "\u2193",
1280
+ downarrow: "\u2193",
1281
+ DownArrow: "\u2193",
1282
+ harr: "\u2194",
1283
+ leftrightarrow: "\u2194",
1284
+ LeftRightArrow: "\u2194",
1285
+ varr: "\u2195",
1286
+ updownarrow: "\u2195",
1287
+ UpDownArrow: "\u2195",
1288
+ nwarr: "\u2196",
1289
+ nwarrow: "\u2196",
1290
+ UpperLeftArrow: "\u2196",
1291
+ nearr: "\u2197",
1292
+ nearrow: "\u2197",
1293
+ UpperRightArrow: "\u2197",
1294
+ searr: "\u2198",
1295
+ searrow: "\u2198",
1296
+ LowerRightArrow: "\u2198",
1297
+ swarr: "\u2199",
1298
+ swarrow: "\u2199",
1299
+ LowerLeftArrow: "\u2199",
1300
+ lArr: "\u21D0",
1301
+ Leftarrow: "\u21D0",
1302
+ uArr: "\u21D1",
1303
+ Uparrow: "\u21D1",
1304
+ rArr: "\u21D2",
1305
+ Rightarrow: "\u21D2",
1306
+ dArr: "\u21D3",
1307
+ Downarrow: "\u21D3",
1308
+ hArr: "\u21D4",
1309
+ Leftrightarrow: "\u21D4",
1310
+ iff: "\u21D4",
1311
+ vArr: "\u21D5",
1312
+ Updownarrow: "\u21D5",
1313
+ lAarr: "\u21DA",
1314
+ Lleftarrow: "\u21DA",
1315
+ rAarr: "\u21DB",
1316
+ Rrightarrow: "\u21DB",
1317
+ lrarr: "\u21C6",
1318
+ leftrightarrows: "\u21C6",
1319
+ rlarr: "\u21C4",
1320
+ rightleftarrows: "\u21C4",
1321
+ lrhar: "\u21CB",
1322
+ leftrightharpoons: "\u21CB",
1323
+ ReverseEquilibrium: "\u21CB",
1324
+ rlhar: "\u21CC",
1325
+ rightleftharpoons: "\u21CC",
1326
+ Equilibrium: "\u21CC",
1327
+ udarr: "\u21C5",
1328
+ UpArrowDownArrow: "\u21C5",
1329
+ duarr: "\u21F5",
1330
+ DownArrowUpArrow: "\u21F5",
1331
+ llarr: "\u21C7",
1332
+ leftleftarrows: "\u21C7",
1333
+ rrarr: "\u21C9",
1334
+ rightrightarrows: "\u21C9",
1335
+ ddarr: "\u21CA",
1336
+ downdownarrows: "\u21CA",
1337
+ har: "\u21BD",
1338
+ lhard: "\u21BD",
1339
+ leftharpoondown: "\u21BD",
1340
+ lharu: "\u21BC",
1341
+ leftharpoonup: "\u21BC",
1342
+ rhard: "\u21C1",
1343
+ rightharpoondown: "\u21C1",
1344
+ rharu: "\u21C0",
1345
+ rightharpoonup: "\u21C0",
1346
+ lsh: "\u21B0",
1347
+ Lsh: "\u21B0",
1348
+ rsh: "\u21B1",
1349
+ Rsh: "\u21B1",
1350
+ ldsh: "\u21B2",
1351
+ rdsh: "\u21B3",
1352
+ hookleftarrow: "\u21A9",
1353
+ hookrightarrow: "\u21AA",
1354
+ mapstoleft: "\u21A4",
1355
+ mapstoup: "\u21A5",
1356
+ map: "\u21A6",
1357
+ mapsto: "\u21A6",
1358
+ mapstodown: "\u21A7",
1359
+ crarr: "\u21B5",
1360
+ nwarrow: "\u2196",
1361
+ nearrow: "\u2197",
1362
+ searrow: "\u2198",
1363
+ swarrow: "\u2199",
1364
+ nleftarrow: "\u219A",
1365
+ nleftrightarrow: "\u21AE",
1366
+ nrightarrow: "\u219B",
1367
+ nrarr: "\u219B",
1368
+ larrtl: "\u21A2",
1369
+ rarrtl: "\u21A3",
1370
+ leftarrowtail: "\u21A2",
1371
+ rightarrowtail: "\u21A3",
1372
+ twoheadleftarrow: "\u219E",
1373
+ twoheadrightarrow: "\u21A0",
1374
+ Larr: "\u219E",
1375
+ Rarr: "\u21A0",
1376
+ larrhk: "\u21A9",
1377
+ rarrhk: "\u21AA",
1378
+ larrlp: "\u21AB",
1379
+ looparrowleft: "\u21AB",
1380
+ rarrlp: "\u21AC",
1381
+ looparrowright: "\u21AC",
1382
+ harrw: "\u21AD",
1383
+ leftrightsquigarrow: "\u21AD",
1384
+ nrarrw: "\u219D\u0338",
1385
+ rarrw: "\u219D",
1386
+ rightsquigarrow: "\u219D",
1387
+ larrbfs: "\u291F",
1388
+ rarrbfs: "\u2920",
1389
+ nvHarr: "\u2904",
1390
+ nvlArr: "\u2902",
1391
+ nvrArr: "\u2903",
1392
+ larrfs: "\u291D",
1393
+ rarrfs: "\u291E",
1394
+ Map: "\u2905",
1395
+ larrsim: "\u2973",
1396
+ rarrsim: "\u2974",
1397
+ harrcir: "\u2948",
1398
+ Uarrocir: "\u2949",
1399
+ lurdshar: "\u294A",
1400
+ ldrdhar: "\u2967",
1401
+ ldrushar: "\u294B",
1402
+ rdldhar: "\u2969",
1403
+ lrhard: "\u296D",
1404
+ rlhar: "\u21CC",
1405
+ uharr: "\u21BE",
1406
+ uharl: "\u21BF",
1407
+ dharr: "\u21C2",
1408
+ dharl: "\u21C3",
1409
+ Uarr: "\u219F",
1410
+ Darr: "\u21A1",
1411
+ zigrarr: "\u21DD",
1412
+ nwArr: "\u21D6",
1413
+ neArr: "\u21D7",
1414
+ seArr: "\u21D8",
1415
+ swArr: "\u21D9",
1416
+ nharr: "\u21AE",
1417
+ nhArr: "\u21CE",
1418
+ nlarr: "\u219A",
1419
+ nlArr: "\u21CD",
1420
+ nrarr: "\u219B",
1421
+ nrArr: "\u21CF",
1422
+ larrb: "\u21E4",
1423
+ LeftArrowBar: "\u21E4",
1424
+ rarrb: "\u21E5",
1425
+ RightArrowBar: "\u21E5"
1426
+ };
1427
+ var SHAPES = {
1428
+ square: "\u25A1",
1429
+ Square: "\u25A1",
1430
+ squ: "\u25A1",
1431
+ squf: "\u25AA",
1432
+ squarf: "\u25AA",
1433
+ blacksquar: "\u25AA",
1434
+ blacksquare: "\u25AA",
1435
+ FilledVerySmallSquare: "\u25AA",
1436
+ blk34: "\u2593",
1437
+ blk12: "\u2592",
1438
+ blk14: "\u2591",
1439
+ block: "\u2588",
1440
+ srect: "\u25AD",
1441
+ rect: "\u25AD",
1442
+ sdot: "\u22C5",
1443
+ sdotb: "\u22A1",
1444
+ dotsquare: "\u22A1",
1445
+ triangle: "\u25B5",
1446
+ tri: "\u25B5",
1447
+ trine: "\u25B5",
1448
+ utri: "\u25B5",
1449
+ triangledown: "\u25BF",
1450
+ dtri: "\u25BF",
1451
+ tridown: "\u25BF",
1452
+ triangleleft: "\u25C3",
1453
+ ltri: "\u25C3",
1454
+ triangleright: "\u25B9",
1455
+ rtri: "\u25B9",
1456
+ blacktriangle: "\u25B4",
1457
+ utrif: "\u25B4",
1458
+ blacktriangledown: "\u25BE",
1459
+ dtrif: "\u25BE",
1460
+ blacktriangleleft: "\u25C2",
1461
+ ltrif: "\u25C2",
1462
+ blacktriangleright: "\u25B8",
1463
+ rtrif: "\u25B8",
1464
+ loz: "\u25CA",
1465
+ lozenge: "\u25CA",
1466
+ blacklozenge: "\u29EB",
1467
+ lozf: "\u29EB",
1468
+ bigcirc: "\u25EF",
1469
+ xcirc: "\u25EF",
1470
+ circ: "\u02C6",
1471
+ Circle: "\u25CB",
1472
+ cir: "\u25CB",
1473
+ o: "\u25CB",
1474
+ bullet: "\u2022",
1475
+ bull: "\u2022",
1476
+ hellip: "\u2026",
1477
+ mldr: "\u2026",
1478
+ nldr: "\u2025",
1479
+ boxh: "\u2500",
1480
+ HorizontalLine: "\u2500",
1481
+ boxv: "\u2502",
1482
+ boxdr: "\u250C",
1483
+ boxdl: "\u2510",
1484
+ boxur: "\u2514",
1485
+ boxul: "\u2518",
1486
+ boxvr: "\u251C",
1487
+ boxvl: "\u2524",
1488
+ boxhd: "\u252C",
1489
+ boxhu: "\u2534",
1490
+ boxvh: "\u253C",
1491
+ boxH: "\u2550",
1492
+ boxV: "\u2551",
1493
+ boxdR: "\u2552",
1494
+ boxDr: "\u2553",
1495
+ boxDR: "\u2554",
1496
+ boxDl: "\u2555",
1497
+ boxdL: "\u2556",
1498
+ boxDL: "\u2557",
1499
+ boxuR: "\u2558",
1500
+ boxUr: "\u2559",
1501
+ boxUR: "\u255A",
1502
+ boxUl: "\u255C",
1503
+ boxuL: "\u255B",
1504
+ boxUL: "\u255D",
1505
+ boxvR: "\u255E",
1506
+ boxVr: "\u255F",
1507
+ boxVR: "\u2560",
1508
+ boxVl: "\u2562",
1509
+ boxvL: "\u2561",
1510
+ boxVL: "\u2563",
1511
+ boxHd: "\u2564",
1512
+ boxhD: "\u2565",
1513
+ boxHD: "\u2566",
1514
+ boxHu: "\u2567",
1515
+ boxhU: "\u2568",
1516
+ boxHU: "\u2569",
1517
+ boxvH: "\u256A",
1518
+ boxVh: "\u256B",
1519
+ boxVH: "\u256C"
1520
+ };
1521
+ var PUNCTUATION = {
1522
+ excl: "!",
1523
+ iexcl: "\xA1",
1524
+ brvbar: "\xA6",
1525
+ sect: "\xA7",
1526
+ uml: "\xA8",
1527
+ copy: "\xA9",
1528
+ ordf: "\xAA",
1529
+ laquo: "\xAB",
1530
+ not: "\xAC",
1531
+ shy: "\xAD",
1532
+ reg: "\xAE",
1533
+ macr: "\xAF",
1534
+ deg: "\xB0",
1535
+ plusmn: "\xB1",
1536
+ sup2: "\xB2",
1537
+ sup3: "\xB3",
1538
+ acute: "\xB4",
1539
+ micro: "\xB5",
1540
+ para: "\xB6",
1541
+ middot: "\xB7",
1542
+ cedil: "\xB8",
1543
+ sup1: "\xB9",
1544
+ ordm: "\xBA",
1545
+ raquo: "\xBB",
1546
+ frac14: "\xBC",
1547
+ frac12: "\xBD",
1548
+ frac34: "\xBE",
1549
+ iquest: "\xBF",
1550
+ nbsp: "\xA0",
1551
+ comma: ",",
1552
+ period: ".",
1553
+ colon: ":",
1554
+ semi: ";",
1555
+ vert: "|",
1556
+ Verbar: "\u2016",
1557
+ verbar: "|",
1558
+ dblac: "\u02DD",
1559
+ circ: "\u02C6",
1560
+ caron: "\u02C7",
1561
+ breve: "\u02D8",
1562
+ dot: "\u02D9",
1563
+ ring: "\u02DA",
1564
+ ogon: "\u02DB",
1565
+ tilde: "\u02DC",
1566
+ DiacriticalGrave: "`",
1567
+ DiacriticalAcute: "\xB4",
1568
+ DiacriticalTilde: "\u02DC",
1569
+ DiacriticalDot: "\u02D9",
1570
+ DiacriticalDoubleAcute: "\u02DD",
1571
+ grave: "`",
1572
+ acute: "\xB4"
1573
+ };
1574
+ var CURRENCY = {
1575
+ cent: "\xA2",
1576
+ pound: "\xA3",
1577
+ curren: "\xA4",
1578
+ yen: "\xA5",
1579
+ euro: "\u20AC",
1580
+ dollar: "$",
1581
+ euro: "\u20AC",
1582
+ fnof: "\u0192",
1583
+ inr: "\u20B9",
1584
+ af: "\u060B",
1585
+ birr: "\u1265\u122D",
1586
+ peso: "\u20B1",
1587
+ rub: "\u20BD",
1588
+ won: "\u20A9",
1589
+ yuan: "\xA5",
1590
+ cedil: "\xB8"
1591
+ };
1592
+ var FRACTIONS = {
1593
+ frac12: "\xBD",
1594
+ half: "\xBD",
1595
+ frac13: "\u2153",
1596
+ frac14: "\xBC",
1597
+ frac15: "\u2155",
1598
+ frac16: "\u2159",
1599
+ frac18: "\u215B",
1600
+ frac23: "\u2154",
1601
+ frac25: "\u2156",
1602
+ frac34: "\xBE",
1603
+ frac35: "\u2157",
1604
+ frac38: "\u215C",
1605
+ frac45: "\u2158",
1606
+ frac56: "\u215A",
1607
+ frac58: "\u215D",
1608
+ frac78: "\u215E",
1609
+ frasl: "\u2044"
1610
+ };
1611
+ var MISC_SYMBOLS = {
1612
+ trade: "\u2122",
1613
+ TRADE: "\u2122",
1614
+ telrec: "\u2315",
1615
+ target: "\u2316",
1616
+ ulcorn: "\u231C",
1617
+ ulcorner: "\u231C",
1618
+ urcorn: "\u231D",
1619
+ urcorner: "\u231D",
1620
+ dlcorn: "\u231E",
1621
+ llcorner: "\u231E",
1622
+ drcorn: "\u231F",
1623
+ lrcorner: "\u231F",
1624
+ intercal: "\u22BA",
1625
+ intcal: "\u22BA",
1626
+ oplus: "\u2295",
1627
+ CirclePlus: "\u2295",
1628
+ ominus: "\u2296",
1629
+ CircleMinus: "\u2296",
1630
+ otimes: "\u2297",
1631
+ CircleTimes: "\u2297",
1632
+ osol: "\u2298",
1633
+ odot: "\u2299",
1634
+ CircleDot: "\u2299",
1635
+ oast: "\u229B",
1636
+ circledast: "\u229B",
1637
+ odash: "\u229D",
1638
+ circleddash: "\u229D",
1639
+ ocirc: "\u229A",
1640
+ circledcirc: "\u229A",
1641
+ boxplus: "\u229E",
1642
+ plusb: "\u229E",
1643
+ boxminus: "\u229F",
1644
+ minusb: "\u229F",
1645
+ boxtimes: "\u22A0",
1646
+ timesb: "\u22A0",
1647
+ boxdot: "\u22A1",
1648
+ sdotb: "\u22A1",
1649
+ veebar: "\u22BB",
1650
+ vee: "\u2228",
1651
+ barvee: "\u22BD",
1652
+ and: "\u2227",
1653
+ wedge: "\u2227",
1654
+ Cap: "\u22D2",
1655
+ Cup: "\u22D3",
1656
+ Fork: "\u22D4",
1657
+ pitchfork: "\u22D4",
1658
+ epar: "\u22D5",
1659
+ ltlarr: "\u2976",
1660
+ nvap: "\u224D\u20D2",
1661
+ nvsim: "\u223C\u20D2",
1662
+ nvge: "\u2265\u20D2",
1663
+ nvle: "\u2264\u20D2",
1664
+ nvlt: "<\u20D2",
1665
+ nvgt: ">\u20D2",
1666
+ nvltrie: "\u22B4\u20D2",
1667
+ nvrtrie: "\u22B5\u20D2",
1668
+ Vdash: "\u22A9",
1669
+ dashv: "\u22A3",
1670
+ vDash: "\u22A8",
1671
+ Vdash: "\u22A9",
1672
+ Vvdash: "\u22AA",
1673
+ nvdash: "\u22AC",
1674
+ nvDash: "\u22AD",
1675
+ nVdash: "\u22AE",
1676
+ nVDash: "\u22AF"
1677
+ };
1678
+ var ALL_ENTITIES = {
1679
+ ...BASIC_LATIN,
1680
+ ...LATIN_ACCENTS,
1681
+ ...LATIN_EXTENDED,
1682
+ ...GREEK,
1683
+ ...CYRILLIC,
1684
+ ...MATH,
1685
+ ...MATH_ADVANCED,
1686
+ ...ARROWS,
1687
+ ...SHAPES,
1688
+ ...PUNCTUATION,
1689
+ ...CURRENCY,
1690
+ ...FRACTIONS,
1691
+ ...MISC_SYMBOLS
1692
+ };
1693
+ var XML = {
1694
+ amp: "&",
1695
+ apos: "'",
1696
+ gt: ">",
1697
+ lt: "<",
1698
+ quot: '"'
1699
+ };
1700
+ var COMMON_HTML = {
1701
+ nbsp: "\xA0",
1702
+ copy: "\xA9",
1703
+ reg: "\xAE",
1704
+ trade: "\u2122",
1705
+ mdash: "\u2014",
1706
+ ndash: "\u2013",
1707
+ hellip: "\u2026",
1708
+ laquo: "\xAB",
1709
+ raquo: "\xBB",
1710
+ lsquo: "\u2018",
1711
+ rsquo: "\u2019",
1712
+ ldquo: "\u201C",
1713
+ rdquo: "\u201D",
1714
+ bull: "\u2022",
1715
+ para: "\xB6",
1716
+ sect: "\xA7",
1717
+ deg: "\xB0",
1718
+ frac12: "\xBD",
1719
+ frac14: "\xBC",
1720
+ frac34: "\xBE"
1721
+ };
1722
+
1723
+ // ../../node_modules/@nodable/entities/src/EntityDecoder.js
1724
+ var SPECIAL_CHARS = new Set("!?\\\\/[]$%{}^&*()<>|+");
1725
+ function validateEntityName(name) {
1726
+ if (name[0] === "#") {
1727
+ throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${name}"`);
1728
+ }
1729
+ for (const ch of name) {
1730
+ if (SPECIAL_CHARS.has(ch)) {
1731
+ throw new Error(`[EntityReplacer] Invalid character '${ch}' in entity name: "${name}"`);
1732
+ }
1733
+ }
1734
+ return name;
1735
+ }
1736
+ function mergeEntityMaps(...maps) {
1737
+ const out = /* @__PURE__ */ Object.create(null);
1738
+ for (const map of maps) {
1739
+ if (!map) continue;
1740
+ for (const key of Object.keys(map)) {
1741
+ const raw = map[key];
1742
+ if (typeof raw === "string") {
1743
+ out[key] = raw;
1744
+ } else if (raw && typeof raw === "object" && raw.val !== void 0) {
1745
+ const val = raw.val;
1746
+ if (typeof val === "string") {
1747
+ out[key] = val;
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ return out;
1753
+ }
1754
+ var LIMIT_TIER_EXTERNAL = "external";
1755
+ var LIMIT_TIER_BASE = "base";
1756
+ var LIMIT_TIER_ALL = "all";
1757
+ function parseLimitTiers(raw) {
1758
+ if (!raw || raw === LIMIT_TIER_EXTERNAL) return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL]);
1759
+ if (raw === LIMIT_TIER_ALL) return /* @__PURE__ */ new Set([LIMIT_TIER_ALL]);
1760
+ if (raw === LIMIT_TIER_BASE) return /* @__PURE__ */ new Set([LIMIT_TIER_BASE]);
1761
+ if (Array.isArray(raw)) return new Set(raw);
1762
+ return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL]);
1763
+ }
1764
+ var NCR_LEVEL = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 });
1765
+ var XML10_ALLOWED_C0 = /* @__PURE__ */ new Set([9, 10, 13]);
1766
+ function parseNCRConfig(ncr) {
1767
+ if (!ncr) {
1768
+ return { xmlVersion: 1, onLevel: NCR_LEVEL.allow, nullLevel: NCR_LEVEL.remove };
1769
+ }
1770
+ const xmlVersion = ncr.xmlVersion === 1.1 ? 1.1 : 1;
1771
+ const onLevel = NCR_LEVEL[ncr.onNCR] ?? NCR_LEVEL.allow;
1772
+ const nullLevel = NCR_LEVEL[ncr.nullNCR] ?? NCR_LEVEL.remove;
1773
+ const clampedNull = Math.max(nullLevel, NCR_LEVEL.remove);
1774
+ return { xmlVersion, onLevel, nullLevel: clampedNull };
1775
+ }
1776
+ var EntityDecoder = class {
1777
+ /**
1778
+ * @param {object} [options]
1779
+ * @param {object|null} [options.namedEntities] — extra named entities merged into base map
1780
+ * @param {object} [options.limit] — security limits
1781
+ * @param {number} [options.limit.maxTotalExpansions=0] — 0 = unlimited
1782
+ * @param {number} [options.limit.maxExpandedLength=0] — 0 = unlimited
1783
+ * @param {'external'|'base'|'all'|string[]} [options.limit.applyLimitsTo='external']
1784
+ * Which entity tiers count against the security limits:
1785
+ * - 'external' (default) — only input/runtime + persistent external entities
1786
+ * - 'base' — only DEFAULT_XML_ENTITIES + namedEntities
1787
+ * - 'all' — every entity regardless of tier
1788
+ * - string[] — explicit combination, e.g. ['external', 'base']
1789
+ * @param {((resolved: string, original: string) => string)|null} [options.postCheck=null]
1790
+ * @param {string[]} [options.remove=[]] — entity names (e.g. ['nbsp', '#13']) to delete (replace with empty string)
1791
+ * @param {string[]} [options.leave=[]] — entity names to keep as literal (unchanged in output)
1792
+ * @param {object} [options.ncr] — Numeric Character Reference controls
1793
+ * @param {1.0|1.1} [options.ncr.xmlVersion=1.0]
1794
+ * XML version governing which codepoint ranges are restricted:
1795
+ * - 1.0 — C0 controls U+0001–U+001F (except U+0009/000A/000D) are prohibited
1796
+ * - 1.1 — C0 controls are allowed when written as NCRs; C1 (U+007F–U+009F) decoded as-is
1797
+ * @param {'allow'|'leave'|'remove'|'throw'} [options.ncr.onNCR='allow']
1798
+ * Base action for numeric references. Severity order: allow < leave < remove < throw.
1799
+ * For codepoint ranges that carry a minimum level (surrogates → remove, XML 1.0 C0 → remove),
1800
+ * the effective action is max(onNCR, rangeMinimum).
1801
+ * @param {'remove'|'throw'} [options.ncr.nullNCR='remove']
1802
+ * Action for U+0000 (null). 'allow' and 'leave' are clamped to 'remove' since null is never safe.
1803
+ */
1804
+ constructor(options = {}) {
1805
+ this._limit = options.limit || {};
1806
+ this._maxTotalExpansions = this._limit.maxTotalExpansions || 0;
1807
+ this._maxExpandedLength = this._limit.maxExpandedLength || 0;
1808
+ this._postCheck = typeof options.postCheck === "function" ? options.postCheck : (r) => r;
1809
+ this._limitTiers = parseLimitTiers(this._limit.applyLimitsTo ?? LIMIT_TIER_EXTERNAL);
1810
+ this._numericAllowed = options.numericAllowed ?? true;
1811
+ this._baseMap = mergeEntityMaps(XML, options.namedEntities || null);
1812
+ this._externalMap = /* @__PURE__ */ Object.create(null);
1813
+ this._inputMap = /* @__PURE__ */ Object.create(null);
1814
+ this._totalExpansions = 0;
1815
+ this._expandedLength = 0;
1816
+ this._removeSet = new Set(options.remove && Array.isArray(options.remove) ? options.remove : []);
1817
+ this._leaveSet = new Set(options.leave && Array.isArray(options.leave) ? options.leave : []);
1818
+ const ncrCfg = parseNCRConfig(options.ncr);
1819
+ this._ncrXmlVersion = ncrCfg.xmlVersion;
1820
+ this._ncrOnLevel = ncrCfg.onLevel;
1821
+ this._ncrNullLevel = ncrCfg.nullLevel;
1822
+ }
1823
+ // -------------------------------------------------------------------------
1824
+ // Persistent external entity registration
1825
+ // -------------------------------------------------------------------------
1826
+ /**
1827
+ * Replace the full set of persistent external entities.
1828
+ * All keys are validated — throws on invalid characters.
1829
+ * @param {Record<string, string | { regex?: RegExp, val: string }>} map
1830
+ */
1831
+ setExternalEntities(map) {
1832
+ if (map) {
1833
+ for (const key of Object.keys(map)) {
1834
+ validateEntityName(key);
1835
+ }
1836
+ }
1837
+ this._externalMap = mergeEntityMaps(map);
1838
+ }
1839
+ /**
1840
+ * Add a single persistent external entity.
1841
+ * @param {string} key
1842
+ * @param {string} value
1843
+ */
1844
+ addExternalEntity(key, value) {
1845
+ validateEntityName(key);
1846
+ if (typeof value === "string" && value.indexOf("&") === -1) {
1847
+ this._externalMap[key] = value;
1848
+ }
1849
+ }
1850
+ // -------------------------------------------------------------------------
1851
+ // Input / runtime entity registration (per document)
1852
+ // -------------------------------------------------------------------------
1853
+ /**
1854
+ * Inject DOCTYPE entities for the current document.
1855
+ * Also resets per-document expansion counters.
1856
+ * @param {Record<string, string | { regx?: RegExp, regex?: RegExp, val: string }>} map
1857
+ */
1858
+ addInputEntities(map) {
1859
+ this._totalExpansions = 0;
1860
+ this._expandedLength = 0;
1861
+ this._inputMap = mergeEntityMaps(map);
1862
+ }
1863
+ // -------------------------------------------------------------------------
1864
+ // Per-document reset
1865
+ // -------------------------------------------------------------------------
1866
+ /**
1867
+ * Wipe input/runtime entities and reset counters.
1868
+ * Call this before processing each new document.
1869
+ * @returns {this}
1870
+ */
1871
+ reset() {
1872
+ this._inputMap = /* @__PURE__ */ Object.create(null);
1873
+ this._totalExpansions = 0;
1874
+ this._expandedLength = 0;
1875
+ return this;
1876
+ }
1877
+ // -------------------------------------------------------------------------
1878
+ // XML version (can be set after construction, e.g. once parser reads <?xml?>)
1879
+ // -------------------------------------------------------------------------
1880
+ /**
1881
+ * Update the XML version used for NCR classification.
1882
+ * Call this as soon as the document's `<?xml version="...">` declaration is parsed.
1883
+ * @param {1.0|1.1|number} version
1884
+ */
1885
+ setXmlVersion(version) {
1886
+ this._ncrXmlVersion = version === 1.1 ? 1.1 : 1;
1887
+ }
1888
+ // -------------------------------------------------------------------------
1889
+ // Primary API
1890
+ // -------------------------------------------------------------------------
1891
+ /**
1892
+ * Replace all entity references in `str` in a single pass.
1893
+ *
1894
+ * @param {string} str
1895
+ * @returns {string}
1896
+ */
1897
+ decode(str) {
1898
+ if (typeof str !== "string" || str.length === 0) return str;
1899
+ const original = str;
1900
+ const chunks = [];
1901
+ const len = str.length;
1902
+ let last = 0;
1903
+ let i = 0;
1904
+ const limitExpansions = this._maxTotalExpansions > 0;
1905
+ const limitLength = this._maxExpandedLength > 0;
1906
+ const checkLimits = limitExpansions || limitLength;
1907
+ while (i < len) {
1908
+ if (str.charCodeAt(i) !== 38) {
1909
+ i++;
1910
+ continue;
1911
+ }
1912
+ let j = i + 1;
1913
+ while (j < len && str.charCodeAt(j) !== 59 && j - i <= 32) j++;
1914
+ if (j >= len || str.charCodeAt(j) !== 59) {
1915
+ i++;
1916
+ continue;
1917
+ }
1918
+ const token = str.slice(i + 1, j);
1919
+ if (token.length === 0) {
1920
+ i++;
1921
+ continue;
1922
+ }
1923
+ let replacement;
1924
+ let tier;
1925
+ if (this._removeSet.has(token)) {
1926
+ replacement = "";
1927
+ if (tier === void 0) {
1928
+ tier = LIMIT_TIER_EXTERNAL;
1929
+ }
1930
+ } else if (this._leaveSet.has(token)) {
1931
+ i++;
1932
+ continue;
1933
+ } else if (token.charCodeAt(0) === 35) {
1934
+ const ncrResult = this._resolveNCR(token);
1935
+ if (ncrResult === void 0) {
1936
+ i++;
1937
+ continue;
1938
+ }
1939
+ replacement = ncrResult;
1940
+ tier = LIMIT_TIER_BASE;
1941
+ } else {
1942
+ const resolved = this._resolveName(token);
1943
+ replacement = resolved == null ? void 0 : resolved.value;
1944
+ tier = resolved == null ? void 0 : resolved.tier;
1945
+ }
1946
+ if (replacement === void 0) {
1947
+ i++;
1948
+ continue;
1949
+ }
1950
+ if (i > last) chunks.push(str.slice(last, i));
1951
+ chunks.push(replacement);
1952
+ last = j + 1;
1953
+ i = last;
1954
+ if (checkLimits && this._tierCounts(tier)) {
1955
+ if (limitExpansions) {
1956
+ this._totalExpansions++;
1957
+ if (this._totalExpansions > this._maxTotalExpansions) {
1958
+ throw new Error(
1959
+ `[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`
1960
+ );
1961
+ }
1962
+ }
1963
+ if (limitLength) {
1964
+ const delta = replacement.length - (token.length + 2);
1965
+ if (delta > 0) {
1966
+ this._expandedLength += delta;
1967
+ if (this._expandedLength > this._maxExpandedLength) {
1968
+ throw new Error(
1969
+ `[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`
1970
+ );
1971
+ }
1972
+ }
1973
+ }
1974
+ }
1975
+ }
1976
+ if (last < len) chunks.push(str.slice(last));
1977
+ const result = chunks.length === 0 ? str : chunks.join("");
1978
+ return this._postCheck(result, original);
1979
+ }
1980
+ // -------------------------------------------------------------------------
1981
+ // Private: limit tier check
1982
+ // -------------------------------------------------------------------------
1983
+ /**
1984
+ * Returns true if a resolved entity of the given tier should count
1985
+ * against the expansion/length limits.
1986
+ * @param {string} tier — LIMIT_TIER_EXTERNAL | LIMIT_TIER_BASE
1987
+ * @returns {boolean}
1988
+ */
1989
+ _tierCounts(tier) {
1990
+ if (this._limitTiers.has(LIMIT_TIER_ALL)) return true;
1991
+ return this._limitTiers.has(tier);
1992
+ }
1993
+ // -------------------------------------------------------------------------
1994
+ // Private: entity resolution
1995
+ // -------------------------------------------------------------------------
1996
+ /**
1997
+ * Resolve a named entity token (without & and ;).
1998
+ * Priority: inputMap > externalMap > baseMap
1999
+ * Returns the resolved value tagged with its limit tier.
2000
+ *
2001
+ * @param {string} name
2002
+ * @returns {{ value: string, tier: string }|undefined}
2003
+ */
2004
+ _resolveName(name) {
2005
+ if (name in this._inputMap) return { value: this._inputMap[name], tier: LIMIT_TIER_EXTERNAL };
2006
+ if (name in this._externalMap) return { value: this._externalMap[name], tier: LIMIT_TIER_EXTERNAL };
2007
+ if (name in this._baseMap) return { value: this._baseMap[name], tier: LIMIT_TIER_BASE };
2008
+ return void 0;
2009
+ }
2010
+ /**
2011
+ * Classify a codepoint and return the minimum action level that must be applied.
2012
+ * Returns -1 when no minimum is imposed (normal allow path).
2013
+ *
2014
+ * Ranges checked (in priority order):
2015
+ * 1. U+0000 — null, governed by nullNCR (always ≥ remove)
2016
+ * 2. U+D800–U+DFFF — surrogates, always prohibited (min: remove)
2017
+ * 3. U+0001–U+001F \ {0x09,0x0A,0x0D} — XML 1.0 restricted C0 (min: remove)
2018
+ * (skipped in XML 1.1 — C0 controls are allowed when written as NCRs)
2019
+ *
2020
+ * @param {number} cp — codepoint
2021
+ * @returns {number} — minimum NCR_LEVEL value, or -1 for no restriction
2022
+ */
2023
+ _classifyNCR(cp) {
2024
+ if (cp === 0) return this._ncrNullLevel;
2025
+ if (cp >= 55296 && cp <= 57343) return NCR_LEVEL.remove;
2026
+ if (this._ncrXmlVersion === 1) {
2027
+ if (cp >= 1 && cp <= 31 && !XML10_ALLOWED_C0.has(cp)) return NCR_LEVEL.remove;
2028
+ }
2029
+ return -1;
2030
+ }
2031
+ /**
2032
+ * Execute a resolved NCR action.
2033
+ *
2034
+ * @param {number} action — NCR_LEVEL value
2035
+ * @param {string} token — raw token (e.g. '#38') for error messages
2036
+ * @param {number} cp — codepoint, used only for error messages
2037
+ * @returns {string|undefined}
2038
+ * - decoded character string → 'allow'
2039
+ * - '' → 'remove'
2040
+ * - undefined → 'leave' (caller must skip past '&' only)
2041
+ * - throws Error → 'throw'
2042
+ */
2043
+ _applyNCRAction(action, token, cp) {
2044
+ switch (action) {
2045
+ case NCR_LEVEL.allow:
2046
+ return String.fromCodePoint(cp);
2047
+ case NCR_LEVEL.remove:
2048
+ return "";
2049
+ case NCR_LEVEL.leave:
2050
+ return void 0;
2051
+ // signal: keep literal
2052
+ case NCR_LEVEL.throw:
2053
+ throw new Error(
2054
+ `[EntityDecoder] Prohibited numeric character reference &${token}; (U+${cp.toString(16).toUpperCase().padStart(4, "0")})`
2055
+ );
2056
+ default:
2057
+ return String.fromCodePoint(cp);
2058
+ }
2059
+ }
2060
+ /**
2061
+ * Full NCR resolution pipeline for a numeric token.
2062
+ *
2063
+ * Steps:
2064
+ * 1. Parse the codepoint (decimal or hex).
2065
+ * 2. Validate the raw codepoint range (NaN, <0, >0x10FFFF).
2066
+ * 3. If numericAllowed is false and no minimum restriction applies → leave as-is.
2067
+ * 4. Classify the codepoint to find the minimum required action level.
2068
+ * 5. Resolve effective action = max(onNCR, minimum).
2069
+ * 6. Apply and return.
2070
+ *
2071
+ * @param {string} token — e.g. '#38', '#x26', '#X26'
2072
+ * @returns {string|undefined}
2073
+ * - string (incl. '') — replacement ('' = remove)
2074
+ * - undefined — leave original &token; as-is
2075
+ */
2076
+ _resolveNCR(token) {
2077
+ const second = token.charCodeAt(1);
2078
+ let cp;
2079
+ if (second === 120 || second === 88) {
2080
+ cp = parseInt(token.slice(2), 16);
2081
+ } else {
2082
+ cp = parseInt(token.slice(1), 10);
2083
+ }
2084
+ if (Number.isNaN(cp) || cp < 0 || cp > 1114111) return void 0;
2085
+ const minimum = this._classifyNCR(cp);
2086
+ if (!this._numericAllowed && minimum < NCR_LEVEL.remove) return void 0;
2087
+ const effective = minimum === -1 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, minimum);
2088
+ return this._applyNCRAction(effective, token, cp);
2089
+ }
2090
+ };
2091
+
2092
+ // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
2093
+ var defaultOnDangerousProperty = (name) => {
2094
+ if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
2095
+ return "__" + name;
2096
+ }
2097
+ return name;
2098
+ };
2099
+ var defaultOptions2 = {
2100
+ preserveOrder: false,
2101
+ attributeNamePrefix: "@_",
2102
+ attributesGroupName: false,
2103
+ textNodeName: "#text",
2104
+ ignoreAttributes: true,
2105
+ removeNSPrefix: false,
2106
+ // remove NS from tag name or attribute name if true
2107
+ allowBooleanAttributes: false,
2108
+ //a tag can have attributes without any value
2109
+ //ignoreRootElement : false,
2110
+ parseTagValue: true,
2111
+ parseAttributeValue: false,
2112
+ trimValues: true,
2113
+ //Trim string values of tag and attributes
2114
+ cdataPropName: false,
2115
+ numberParseOptions: {
2116
+ hex: true,
2117
+ leadingZeros: true,
2118
+ eNotation: true
2119
+ },
2120
+ tagValueProcessor: function(tagName, val) {
2121
+ return val;
2122
+ },
2123
+ attributeValueProcessor: function(attrName, val) {
2124
+ return val;
2125
+ },
2126
+ stopNodes: [],
2127
+ //nested tags will not be parsed even for errors
2128
+ alwaysCreateTextNode: false,
2129
+ isArray: () => false,
2130
+ commentPropName: false,
2131
+ unpairedTags: [],
2132
+ processEntities: true,
2133
+ htmlEntities: false,
2134
+ entityDecoder: null,
2135
+ ignoreDeclaration: false,
2136
+ ignorePiTags: false,
2137
+ transformTagName: false,
2138
+ transformAttributeName: false,
2139
+ updateTag: function(tagName, jPath, attrs) {
2140
+ return tagName;
2141
+ },
2142
+ // skipEmptyListItem: false
2143
+ captureMetaData: false,
2144
+ maxNestedTags: 100,
2145
+ strictReservedNames: true,
2146
+ jPath: true,
2147
+ // if true, pass jPath string to callbacks; if false, pass matcher instance
2148
+ onDangerousProperty: defaultOnDangerousProperty
2149
+ };
2150
+ function validatePropertyName(propertyName, optionName) {
2151
+ if (typeof propertyName !== "string") {
2152
+ return;
2153
+ }
2154
+ const normalized = propertyName.toLowerCase();
2155
+ if (DANGEROUS_PROPERTY_NAMES.some((dangerous) => normalized === dangerous.toLowerCase())) {
2156
+ throw new Error(
2157
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
2158
+ );
2159
+ }
2160
+ if (criticalProperties.some((dangerous) => normalized === dangerous.toLowerCase())) {
2161
+ throw new Error(
2162
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
2163
+ );
2164
+ }
2165
+ }
2166
+ function normalizeProcessEntities(value, htmlEntities) {
2167
+ if (typeof value === "boolean") {
2168
+ return {
2169
+ enabled: value,
2170
+ // true or false
2171
+ maxEntitySize: 1e4,
2172
+ maxExpansionDepth: 1e4,
2173
+ maxTotalExpansions: Infinity,
2174
+ maxExpandedLength: 1e5,
2175
+ maxEntityCount: 1e3,
2176
+ allowedTags: null,
2177
+ tagFilter: null,
2178
+ appliesTo: "all"
2179
+ };
2180
+ }
2181
+ if (typeof value === "object" && value !== null) {
2182
+ return {
2183
+ enabled: value.enabled !== false,
2184
+ maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
2185
+ maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 1e4),
2186
+ maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? Infinity),
2187
+ maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
2188
+ maxEntityCount: Math.max(1, value.maxEntityCount ?? 1e3),
2189
+ allowedTags: value.allowedTags ?? null,
2190
+ tagFilter: value.tagFilter ?? null,
2191
+ appliesTo: value.appliesTo ?? "all"
2192
+ };
2193
+ }
2194
+ return normalizeProcessEntities(true);
2195
+ }
2196
+ var buildOptions = function(options) {
2197
+ const built = Object.assign({}, defaultOptions2, options);
2198
+ const propertyNameOptions = [
2199
+ { value: built.attributeNamePrefix, name: "attributeNamePrefix" },
2200
+ { value: built.attributesGroupName, name: "attributesGroupName" },
2201
+ { value: built.textNodeName, name: "textNodeName" },
2202
+ { value: built.cdataPropName, name: "cdataPropName" },
2203
+ { value: built.commentPropName, name: "commentPropName" }
2204
+ ];
2205
+ for (const { value, name } of propertyNameOptions) {
2206
+ if (value) {
2207
+ validatePropertyName(value, name);
2208
+ }
2209
+ }
2210
+ if (built.onDangerousProperty === null) {
2211
+ built.onDangerousProperty = defaultOnDangerousProperty;
2212
+ }
2213
+ built.processEntities = normalizeProcessEntities(built.processEntities, built.htmlEntities);
2214
+ built.unpairedTagsSet = new Set(built.unpairedTags);
2215
+ if (built.stopNodes && Array.isArray(built.stopNodes)) {
2216
+ built.stopNodes = built.stopNodes.map((node) => {
2217
+ if (typeof node === "string" && node.startsWith("*.")) {
2218
+ return ".." + node.substring(2);
2219
+ }
2220
+ return node;
2221
+ });
2222
+ }
2223
+ return built;
2224
+ };
2225
+
2226
+ // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
2227
+ var METADATA_SYMBOL;
2228
+ if (typeof Symbol !== "function") {
2229
+ METADATA_SYMBOL = "@@xmlMetadata";
2230
+ } else {
2231
+ METADATA_SYMBOL = /* @__PURE__ */ Symbol("XML Node Metadata");
2232
+ }
2233
+ var XmlNode2 = class {
2234
+ constructor(tagname) {
2235
+ this.tagname = tagname;
2236
+ this.child = [];
2237
+ this[":@"] = /* @__PURE__ */ Object.create(null);
2238
+ }
2239
+ add(key, val) {
2240
+ if (key === "__proto__") key = "#__proto__";
2241
+ this.child.push({ [key]: val });
2242
+ }
2243
+ addChild(node, startIndex) {
2244
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
2245
+ if (node[":@"] && Object.keys(node[":@"]).length > 0) {
2246
+ this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
2247
+ } else {
2248
+ this.child.push({ [node.tagname]: node.child });
2249
+ }
2250
+ if (startIndex !== void 0) {
2251
+ this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
2252
+ }
2253
+ }
2254
+ /** symbol used for metadata */
2255
+ static getMetaDataSymbol() {
2256
+ return METADATA_SYMBOL;
2257
+ }
2258
+ };
2259
+
2260
+ // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
2261
+ var DocTypeReader = class {
2262
+ constructor(options) {
2263
+ this.suppressValidationErr = !options;
2264
+ this.options = options;
2265
+ }
2266
+ readDocType(xmlData, i) {
2267
+ const entities = /* @__PURE__ */ Object.create(null);
2268
+ let entityCount = 0;
2269
+ if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
2270
+ i = i + 9;
2271
+ let angleBracketsCount = 1;
2272
+ let hasBody = false, comment = false;
2273
+ let exp = "";
2274
+ for (; i < xmlData.length; i++) {
2275
+ if (xmlData[i] === "<" && !comment) {
2276
+ if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
2277
+ i += 7;
2278
+ let entityName, val;
2279
+ [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
2280
+ if (val.indexOf("&") === -1) {
2281
+ if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
2282
+ throw new Error(
2283
+ `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
2284
+ );
2285
+ }
2286
+ entities[entityName] = val;
2287
+ entityCount++;
2288
+ }
2289
+ } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
2290
+ i += 8;
2291
+ const { index } = this.readElementExp(xmlData, i + 1);
2292
+ i = index;
2293
+ } else if (hasBody && hasSeq(xmlData, "!ATTLIST", i)) {
2294
+ i += 8;
2295
+ } else if (hasBody && hasSeq(xmlData, "!NOTATION", i)) {
2296
+ i += 9;
2297
+ const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
2298
+ i = index;
2299
+ } else if (hasSeq(xmlData, "!--", i)) comment = true;
2300
+ else throw new Error(`Invalid DOCTYPE`);
2301
+ angleBracketsCount++;
2302
+ exp = "";
2303
+ } else if (xmlData[i] === ">") {
2304
+ if (comment) {
2305
+ if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
2306
+ comment = false;
2307
+ angleBracketsCount--;
2308
+ }
2309
+ } else {
2310
+ angleBracketsCount--;
2311
+ }
2312
+ if (angleBracketsCount === 0) {
2313
+ break;
2314
+ }
2315
+ } else if (xmlData[i] === "[") {
2316
+ hasBody = true;
2317
+ } else {
2318
+ exp += xmlData[i];
2319
+ }
2320
+ }
2321
+ if (angleBracketsCount !== 0) {
2322
+ throw new Error(`Unclosed DOCTYPE`);
2323
+ }
2324
+ } else {
2325
+ throw new Error(`Invalid Tag instead of DOCTYPE`);
2326
+ }
2327
+ return { entities, i };
2328
+ }
2329
+ readEntityExp(xmlData, i) {
2330
+ i = skipWhitespace(xmlData, i);
2331
+ const startIndex = i;
2332
+ while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
2333
+ i++;
2334
+ }
2335
+ let entityName = xmlData.substring(startIndex, i);
2336
+ validateEntityName2(entityName);
2337
+ i = skipWhitespace(xmlData, i);
2338
+ if (!this.suppressValidationErr) {
2339
+ if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
2340
+ throw new Error("External entities are not supported");
2341
+ } else if (xmlData[i] === "%") {
2342
+ throw new Error("Parameter entities are not supported");
2343
+ }
2344
+ }
2345
+ let entityValue = "";
2346
+ [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
2347
+ if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
2348
+ throw new Error(
2349
+ `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
2350
+ );
2351
+ }
2352
+ i--;
2353
+ return [entityName, entityValue, i];
2354
+ }
2355
+ readNotationExp(xmlData, i) {
2356
+ i = skipWhitespace(xmlData, i);
2357
+ const startIndex = i;
2358
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
2359
+ i++;
2360
+ }
2361
+ let notationName = xmlData.substring(startIndex, i);
2362
+ !this.suppressValidationErr && validateEntityName2(notationName);
2363
+ i = skipWhitespace(xmlData, i);
2364
+ const identifierType = xmlData.substring(i, i + 6).toUpperCase();
2365
+ if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
2366
+ throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
2367
+ }
2368
+ i += identifierType.length;
2369
+ i = skipWhitespace(xmlData, i);
2370
+ let publicIdentifier = null;
2371
+ let systemIdentifier = null;
2372
+ if (identifierType === "PUBLIC") {
2373
+ [i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
2374
+ i = skipWhitespace(xmlData, i);
2375
+ if (xmlData[i] === '"' || xmlData[i] === "'") {
2376
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
2377
+ }
2378
+ } else if (identifierType === "SYSTEM") {
2379
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
2380
+ if (!this.suppressValidationErr && !systemIdentifier) {
2381
+ throw new Error("Missing mandatory system identifier for SYSTEM notation");
2382
+ }
2383
+ }
2384
+ return { notationName, publicIdentifier, systemIdentifier, index: --i };
2385
+ }
2386
+ readIdentifierVal(xmlData, i, type) {
2387
+ let identifierVal = "";
2388
+ const startChar = xmlData[i];
2389
+ if (startChar !== '"' && startChar !== "'") {
2390
+ throw new Error(`Expected quoted string, found "${startChar}"`);
2391
+ }
2392
+ i++;
2393
+ const startIndex = i;
2394
+ while (i < xmlData.length && xmlData[i] !== startChar) {
2395
+ i++;
2396
+ }
2397
+ identifierVal = xmlData.substring(startIndex, i);
2398
+ if (xmlData[i] !== startChar) {
2399
+ throw new Error(`Unterminated ${type} value`);
2400
+ }
2401
+ i++;
2402
+ return [i, identifierVal];
2403
+ }
2404
+ readElementExp(xmlData, i) {
2405
+ i = skipWhitespace(xmlData, i);
2406
+ const startIndex = i;
2407
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
2408
+ i++;
2409
+ }
2410
+ let elementName = xmlData.substring(startIndex, i);
2411
+ if (!this.suppressValidationErr && !isName(elementName)) {
2412
+ throw new Error(`Invalid element name: "${elementName}"`);
2413
+ }
2414
+ i = skipWhitespace(xmlData, i);
2415
+ let contentModel = "";
2416
+ if (xmlData[i] === "E" && hasSeq(xmlData, "MPTY", i)) i += 4;
2417
+ else if (xmlData[i] === "A" && hasSeq(xmlData, "NY", i)) i += 2;
2418
+ else if (xmlData[i] === "(") {
2419
+ i++;
2420
+ const startIndex2 = i;
2421
+ while (i < xmlData.length && xmlData[i] !== ")") {
2422
+ i++;
2423
+ }
2424
+ contentModel = xmlData.substring(startIndex2, i);
2425
+ if (xmlData[i] !== ")") {
2426
+ throw new Error("Unterminated content model");
2427
+ }
2428
+ } else if (!this.suppressValidationErr) {
2429
+ throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
2430
+ }
2431
+ return {
2432
+ elementName,
2433
+ contentModel: contentModel.trim(),
2434
+ index: i
2435
+ };
2436
+ }
2437
+ readAttlistExp(xmlData, i) {
2438
+ i = skipWhitespace(xmlData, i);
2439
+ let startIndex = i;
2440
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
2441
+ i++;
2442
+ }
2443
+ let elementName = xmlData.substring(startIndex, i);
2444
+ validateEntityName2(elementName);
2445
+ i = skipWhitespace(xmlData, i);
2446
+ startIndex = i;
2447
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
2448
+ i++;
2449
+ }
2450
+ let attributeName = xmlData.substring(startIndex, i);
2451
+ if (!validateEntityName2(attributeName)) {
2452
+ throw new Error(`Invalid attribute name: "${attributeName}"`);
2453
+ }
2454
+ i = skipWhitespace(xmlData, i);
2455
+ let attributeType = "";
2456
+ if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
2457
+ attributeType = "NOTATION";
2458
+ i += 8;
2459
+ i = skipWhitespace(xmlData, i);
2460
+ if (xmlData[i] !== "(") {
2461
+ throw new Error(`Expected '(', found "${xmlData[i]}"`);
2462
+ }
2463
+ i++;
2464
+ let allowedNotations = [];
2465
+ while (i < xmlData.length && xmlData[i] !== ")") {
2466
+ const startIndex2 = i;
2467
+ while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
2468
+ i++;
2469
+ }
2470
+ let notation = xmlData.substring(startIndex2, i);
2471
+ notation = notation.trim();
2472
+ if (!validateEntityName2(notation)) {
2473
+ throw new Error(`Invalid notation name: "${notation}"`);
2474
+ }
2475
+ allowedNotations.push(notation);
2476
+ if (xmlData[i] === "|") {
2477
+ i++;
2478
+ i = skipWhitespace(xmlData, i);
2479
+ }
2480
+ }
2481
+ if (xmlData[i] !== ")") {
2482
+ throw new Error("Unterminated list of notations");
2483
+ }
2484
+ i++;
2485
+ attributeType += " (" + allowedNotations.join("|") + ")";
2486
+ } else {
2487
+ const startIndex2 = i;
2488
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
2489
+ i++;
2490
+ }
2491
+ attributeType += xmlData.substring(startIndex2, i);
2492
+ const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
2493
+ if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
2494
+ throw new Error(`Invalid attribute type: "${attributeType}"`);
2495
+ }
2496
+ }
2497
+ i = skipWhitespace(xmlData, i);
2498
+ let defaultValue = "";
2499
+ if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
2500
+ defaultValue = "#REQUIRED";
2501
+ i += 8;
2502
+ } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
2503
+ defaultValue = "#IMPLIED";
2504
+ i += 7;
2505
+ } else {
2506
+ [i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
2507
+ }
2508
+ return {
2509
+ elementName,
2510
+ attributeName,
2511
+ attributeType,
2512
+ defaultValue,
2513
+ index: i
2514
+ };
2515
+ }
2516
+ };
2517
+ var skipWhitespace = (data, index) => {
2518
+ while (index < data.length && /\s/.test(data[index])) {
2519
+ index++;
2520
+ }
2521
+ return index;
2522
+ };
2523
+ function hasSeq(data, seq, i) {
2524
+ for (let j = 0; j < seq.length; j++) {
2525
+ if (seq[j] !== data[i + j + 1]) return false;
2526
+ }
2527
+ return true;
2528
+ }
2529
+ function validateEntityName2(name) {
2530
+ if (isName(name))
2531
+ return name;
2532
+ else
2533
+ throw new Error(`Invalid entity name ${name}`);
2534
+ }
2535
+
2536
+ // ../../node_modules/strnum/strnum.js
2537
+ var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
2538
+ var binRegex = /^0b[01]+$/;
2539
+ var octRegex = /^0o[0-7]+$/;
2540
+ var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
2541
+ var consider = {
2542
+ hex: true,
2543
+ binary: false,
2544
+ octal: false,
2545
+ leadingZeros: true,
2546
+ decimalPoint: ".",
2547
+ eNotation: true,
2548
+ //skipLike: /regex/,
2549
+ infinity: "original"
2550
+ // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
2551
+ };
2552
+ function toNumber(str, options = {}) {
2553
+ options = Object.assign({}, consider, options);
2554
+ if (!str || typeof str !== "string") return str;
2555
+ let trimmedStr = str.trim();
2556
+ if (trimmedStr.length === 0) return str;
2557
+ else if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
2558
+ else if (trimmedStr === "0") return 0;
2559
+ else if (options.hex && hexRegex.test(trimmedStr)) {
2560
+ return parse_int(trimmedStr, 16);
2561
+ } else if (options.binary && binRegex.test(trimmedStr)) {
2562
+ return parse_int(trimmedStr, 2);
2563
+ } else if (options.octal && octRegex.test(trimmedStr)) {
2564
+ return parse_int(trimmedStr, 8);
2565
+ } else if (!isFinite(trimmedStr)) {
2566
+ return handleInfinity(str, Number(trimmedStr), options);
2567
+ } else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
2568
+ return resolveEnotation(str, trimmedStr, options);
2569
+ } else {
2570
+ const match = numRegex.exec(trimmedStr);
2571
+ if (match) {
2572
+ const sign = match[1] || "";
2573
+ const leadingZeros = match[2];
2574
+ let numTrimmedByZeros = trimZeros(match[3]);
2575
+ const decimalAdjacentToLeadingZeros = sign ? (
2576
+ // 0., -00., 000.
2577
+ str[leadingZeros.length + 1] === "."
2578
+ ) : str[leadingZeros.length] === ".";
2579
+ if (!options.leadingZeros && (leadingZeros.length > 1 || leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros)) {
2580
+ return str;
2581
+ } else {
2582
+ const num = Number(trimmedStr);
2583
+ const parsedStr = String(num);
2584
+ if (num === 0) return num;
2585
+ if (parsedStr.search(/[eE]/) !== -1) {
2586
+ if (options.eNotation) return num;
2587
+ else return str;
2588
+ } else if (trimmedStr.indexOf(".") !== -1) {
2589
+ if (parsedStr === "0") return num;
2590
+ else if (parsedStr === numTrimmedByZeros) return num;
2591
+ else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
2592
+ else return str;
2593
+ }
2594
+ let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
2595
+ if (leadingZeros) {
2596
+ return n === parsedStr || sign + n === parsedStr ? num : str;
2597
+ } else {
2598
+ return n === parsedStr || n === sign + parsedStr ? num : str;
2599
+ }
2600
+ }
2601
+ } else {
2602
+ return str;
2603
+ }
2604
+ }
2605
+ }
2606
+ var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
2607
+ function resolveEnotation(str, trimmedStr, options) {
2608
+ if (!options.eNotation) return str;
2609
+ const notation = trimmedStr.match(eNotationRegx);
2610
+ if (notation) {
2611
+ let sign = notation[1] || "";
2612
+ const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
2613
+ const leadingZeros = notation[2];
2614
+ const eAdjacentToLeadingZeros = sign ? (
2615
+ // 0E.
2616
+ str[leadingZeros.length + 1] === eChar
2617
+ ) : str[leadingZeros.length] === eChar;
2618
+ if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
2619
+ else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
2620
+ return Number(trimmedStr);
2621
+ } else if (leadingZeros.length > 0) {
2622
+ if (options.leadingZeros && !eAdjacentToLeadingZeros) {
2623
+ trimmedStr = (notation[1] || "") + notation[3];
2624
+ return Number(trimmedStr);
2625
+ } else return str;
2626
+ } else {
2627
+ return Number(trimmedStr);
2628
+ }
2629
+ } else {
2630
+ return str;
2631
+ }
2632
+ }
2633
+ function trimZeros(numStr) {
2634
+ if (numStr && numStr.indexOf(".") !== -1) {
2635
+ numStr = numStr.replace(/0+$/, "");
2636
+ if (numStr === ".") numStr = "0";
2637
+ else if (numStr[0] === ".") numStr = "0" + numStr;
2638
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
2639
+ return numStr;
2640
+ }
2641
+ return numStr;
2642
+ }
2643
+ function parse_int(numStr, base) {
2644
+ const str = numStr.trim();
2645
+ if (base === 2 || base === 8) numStr = str.substring(2);
2646
+ if (parseInt) return parseInt(numStr, base);
2647
+ else if (Number.parseInt) return Number.parseInt(numStr, base);
2648
+ else if (window && window.parseInt) return window.parseInt(numStr, base);
2649
+ else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
2650
+ }
2651
+ function handleInfinity(str, num, options) {
2652
+ const isPositive = num === Infinity;
2653
+ switch (options.infinity.toLowerCase()) {
2654
+ case "null":
2655
+ return null;
2656
+ case "infinity":
2657
+ return num;
2658
+ // Return Infinity or -Infinity
2659
+ case "string":
2660
+ return isPositive ? "Infinity" : "-Infinity";
2661
+ case "original":
2662
+ default:
2663
+ return str;
2664
+ }
2665
+ }
2666
+
2667
+ // ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
2668
+ function getIgnoreAttributesFn(ignoreAttributes) {
2669
+ if (typeof ignoreAttributes === "function") {
2670
+ return ignoreAttributes;
2671
+ }
2672
+ if (Array.isArray(ignoreAttributes)) {
2673
+ return (attrName) => {
2674
+ for (const pattern of ignoreAttributes) {
2675
+ if (typeof pattern === "string" && attrName === pattern) {
2676
+ return true;
2677
+ }
2678
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
2679
+ return true;
2680
+ }
2681
+ }
2682
+ };
2683
+ }
2684
+ return () => false;
2685
+ }
2686
+
2687
+ // ../../node_modules/path-expression-matcher/src/Expression.js
2688
+ var Expression = class {
2689
+ /**
2690
+ * Create a new Expression
2691
+ * @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
2692
+ * @param {Object} options - Configuration options
2693
+ * @param {string} options.separator - Path separator (default: '.')
2694
+ */
2695
+ constructor(pattern, options = {}, data) {
2696
+ this.pattern = pattern;
2697
+ this.separator = options.separator || ".";
2698
+ this.segments = this._parse(pattern);
2699
+ this.data = data;
2700
+ this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
2701
+ this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
2702
+ this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
2703
+ }
2704
+ /**
2705
+ * Parse pattern string into segments
2706
+ * @private
2707
+ * @param {string} pattern - Pattern to parse
2708
+ * @returns {Array} Array of segment objects
2709
+ */
2710
+ _parse(pattern) {
2711
+ const segments = [];
2712
+ let i = 0;
2713
+ let currentPart = "";
2714
+ while (i < pattern.length) {
2715
+ if (pattern[i] === this.separator) {
2716
+ if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
2717
+ if (currentPart.trim()) {
2718
+ segments.push(this._parseSegment(currentPart.trim()));
2719
+ currentPart = "";
2720
+ }
2721
+ segments.push({ type: "deep-wildcard" });
2722
+ i += 2;
2723
+ } else {
2724
+ if (currentPart.trim()) {
2725
+ segments.push(this._parseSegment(currentPart.trim()));
2726
+ }
2727
+ currentPart = "";
2728
+ i++;
2729
+ }
2730
+ } else {
2731
+ currentPart += pattern[i];
2732
+ i++;
2733
+ }
2734
+ }
2735
+ if (currentPart.trim()) {
2736
+ segments.push(this._parseSegment(currentPart.trim()));
2737
+ }
2738
+ return segments;
2739
+ }
2740
+ /**
2741
+ * Parse a single segment
2742
+ * @private
2743
+ * @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
2744
+ * @returns {Object} Segment object
2745
+ */
2746
+ _parseSegment(part) {
2747
+ const segment = { type: "tag" };
2748
+ let bracketContent = null;
2749
+ let withoutBrackets = part;
2750
+ const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
2751
+ if (bracketMatch) {
2752
+ withoutBrackets = bracketMatch[1] + bracketMatch[3];
2753
+ if (bracketMatch[2]) {
2754
+ const content = bracketMatch[2].slice(1, -1);
2755
+ if (content) {
2756
+ bracketContent = content;
2757
+ }
2758
+ }
2759
+ }
2760
+ let namespace = void 0;
2761
+ let tagAndPosition = withoutBrackets;
2762
+ if (withoutBrackets.includes("::")) {
2763
+ const nsIndex = withoutBrackets.indexOf("::");
2764
+ namespace = withoutBrackets.substring(0, nsIndex).trim();
2765
+ tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
2766
+ if (!namespace) {
2767
+ throw new Error(`Invalid namespace in pattern: ${part}`);
2768
+ }
2769
+ }
2770
+ let tag = void 0;
2771
+ let positionMatch = null;
2772
+ if (tagAndPosition.includes(":")) {
2773
+ const colonIndex = tagAndPosition.lastIndexOf(":");
2774
+ const tagPart = tagAndPosition.substring(0, colonIndex).trim();
2775
+ const posPart = tagAndPosition.substring(colonIndex + 1).trim();
2776
+ const isPositionKeyword = ["first", "last", "odd", "even"].includes(posPart) || /^nth\(\d+\)$/.test(posPart);
2777
+ if (isPositionKeyword) {
2778
+ tag = tagPart;
2779
+ positionMatch = posPart;
2780
+ } else {
2781
+ tag = tagAndPosition;
2782
+ }
2783
+ } else {
2784
+ tag = tagAndPosition;
2785
+ }
2786
+ if (!tag) {
2787
+ throw new Error(`Invalid segment pattern: ${part}`);
2788
+ }
2789
+ segment.tag = tag;
2790
+ if (namespace) {
2791
+ segment.namespace = namespace;
2792
+ }
2793
+ if (bracketContent) {
2794
+ if (bracketContent.includes("=")) {
2795
+ const eqIndex = bracketContent.indexOf("=");
2796
+ segment.attrName = bracketContent.substring(0, eqIndex).trim();
2797
+ segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
2798
+ } else {
2799
+ segment.attrName = bracketContent.trim();
2800
+ }
2801
+ }
2802
+ if (positionMatch) {
2803
+ const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
2804
+ if (nthMatch) {
2805
+ segment.position = "nth";
2806
+ segment.positionValue = parseInt(nthMatch[1], 10);
2807
+ } else {
2808
+ segment.position = positionMatch;
2809
+ }
2810
+ }
2811
+ return segment;
2812
+ }
2813
+ /**
2814
+ * Get the number of segments
2815
+ * @returns {number}
2816
+ */
2817
+ get length() {
2818
+ return this.segments.length;
2819
+ }
2820
+ /**
2821
+ * Check if expression contains deep wildcard
2822
+ * @returns {boolean}
2823
+ */
2824
+ hasDeepWildcard() {
2825
+ return this._hasDeepWildcard;
2826
+ }
2827
+ /**
2828
+ * Check if expression has attribute conditions
2829
+ * @returns {boolean}
2830
+ */
2831
+ hasAttributeCondition() {
2832
+ return this._hasAttributeCondition;
2833
+ }
2834
+ /**
2835
+ * Check if expression has position selectors
2836
+ * @returns {boolean}
2837
+ */
2838
+ hasPositionSelector() {
2839
+ return this._hasPositionSelector;
2840
+ }
2841
+ /**
2842
+ * Get string representation
2843
+ * @returns {string}
2844
+ */
2845
+ toString() {
2846
+ return this.pattern;
2847
+ }
2848
+ };
2849
+
2850
+ // ../../node_modules/path-expression-matcher/src/ExpressionSet.js
2851
+ var ExpressionSet = class {
2852
+ constructor() {
2853
+ this._byDepthAndTag = /* @__PURE__ */ new Map();
2854
+ this._wildcardByDepth = /* @__PURE__ */ new Map();
2855
+ this._deepWildcards = [];
2856
+ this._patterns = /* @__PURE__ */ new Set();
2857
+ this._sealed = false;
2858
+ }
2859
+ /**
2860
+ * Add an Expression to the set.
2861
+ * Duplicate patterns (same pattern string) are silently ignored.
2862
+ *
2863
+ * @param {import('./Expression.js').default} expression - A pre-constructed Expression instance
2864
+ * @returns {this} for chaining
2865
+ * @throws {TypeError} if called after seal()
2866
+ *
2867
+ * @example
2868
+ * set.add(new Expression('root.users.user'));
2869
+ * set.add(new Expression('..script'));
2870
+ */
2871
+ add(expression) {
2872
+ if (this._sealed) {
2873
+ throw new TypeError(
2874
+ "ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."
2875
+ );
2876
+ }
2877
+ if (this._patterns.has(expression.pattern)) return this;
2878
+ this._patterns.add(expression.pattern);
2879
+ if (expression.hasDeepWildcard()) {
2880
+ this._deepWildcards.push(expression);
2881
+ return this;
2882
+ }
2883
+ const depth = expression.length;
2884
+ const lastSeg = expression.segments[expression.segments.length - 1];
2885
+ const tag = lastSeg == null ? void 0 : lastSeg.tag;
2886
+ if (!tag || tag === "*") {
2887
+ if (!this._wildcardByDepth.has(depth)) this._wildcardByDepth.set(depth, []);
2888
+ this._wildcardByDepth.get(depth).push(expression);
2889
+ } else {
2890
+ const key = `${depth}:${tag}`;
2891
+ if (!this._byDepthAndTag.has(key)) this._byDepthAndTag.set(key, []);
2892
+ this._byDepthAndTag.get(key).push(expression);
2893
+ }
2894
+ return this;
2895
+ }
2896
+ /**
2897
+ * Add multiple expressions at once.
2898
+ *
2899
+ * @param {import('./Expression.js').default[]} expressions - Array of Expression instances
2900
+ * @returns {this} for chaining
2901
+ *
2902
+ * @example
2903
+ * set.addAll([
2904
+ * new Expression('root.users.user'),
2905
+ * new Expression('root.config.setting'),
2906
+ * ]);
2907
+ */
2908
+ addAll(expressions) {
2909
+ for (const expr of expressions) this.add(expr);
2910
+ return this;
2911
+ }
2912
+ /**
2913
+ * Check whether a pattern string is already present in the set.
2914
+ *
2915
+ * @param {import('./Expression.js').default} expression
2916
+ * @returns {boolean}
2917
+ */
2918
+ has(expression) {
2919
+ return this._patterns.has(expression.pattern);
2920
+ }
2921
+ /**
2922
+ * Number of expressions in the set.
2923
+ * @type {number}
2924
+ */
2925
+ get size() {
2926
+ return this._patterns.size;
2927
+ }
2928
+ /**
2929
+ * Seal the set against further modifications.
2930
+ * Useful to prevent accidental mutations after config is built.
2931
+ * Calling add() or addAll() on a sealed set throws a TypeError.
2932
+ *
2933
+ * @returns {this}
2934
+ */
2935
+ seal() {
2936
+ this._sealed = true;
2937
+ return this;
2938
+ }
2939
+ /**
2940
+ * Whether the set has been sealed.
2941
+ * @type {boolean}
2942
+ */
2943
+ get isSealed() {
2944
+ return this._sealed;
2945
+ }
2946
+ /**
2947
+ * Test whether the matcher's current path matches any expression in the set.
2948
+ *
2949
+ * Evaluation order (cheapest → most expensive):
2950
+ * 1. Exact depth + tag bucket — O(1) lookup, typically 0–2 expressions
2951
+ * 2. Depth-only wildcard bucket — O(1) lookup, rare
2952
+ * 3. Deep-wildcard list — always checked, but usually small
2953
+ *
2954
+ * @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
2955
+ * @returns {boolean} true if any expression matches the current path
2956
+ *
2957
+ * @example
2958
+ * if (stopNodes.matchesAny(matcher)) {
2959
+ * // handle stop node
2960
+ * }
2961
+ */
2962
+ matchesAny(matcher) {
2963
+ return this.findMatch(matcher) !== null;
2964
+ }
2965
+ /**
2966
+ * Find and return the first Expression that matches the matcher's current path.
2967
+ *
2968
+ * Uses the same evaluation order as matchesAny (cheapest → most expensive):
2969
+ * 1. Exact depth + tag bucket
2970
+ * 2. Depth-only wildcard bucket
2971
+ * 3. Deep-wildcard list
2972
+ *
2973
+ * @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
2974
+ * @returns {import('./Expression.js').default | null} the first matching Expression, or null
2975
+ *
2976
+ * @example
2977
+ * const expr = stopNodes.findMatch(matcher);
2978
+ * if (expr) {
2979
+ * // access expr.config, expr.pattern, etc.
2980
+ * }
2981
+ */
2982
+ findMatch(matcher) {
2983
+ const depth = matcher.getDepth();
2984
+ const tag = matcher.getCurrentTag();
2985
+ const exactKey = `${depth}:${tag}`;
2986
+ const exactBucket = this._byDepthAndTag.get(exactKey);
2987
+ if (exactBucket) {
2988
+ for (let i = 0; i < exactBucket.length; i++) {
2989
+ if (matcher.matches(exactBucket[i])) return exactBucket[i];
2990
+ }
2991
+ }
2992
+ const wildcardBucket = this._wildcardByDepth.get(depth);
2993
+ if (wildcardBucket) {
2994
+ for (let i = 0; i < wildcardBucket.length; i++) {
2995
+ if (matcher.matches(wildcardBucket[i])) return wildcardBucket[i];
2996
+ }
2997
+ }
2998
+ for (let i = 0; i < this._deepWildcards.length; i++) {
2999
+ if (matcher.matches(this._deepWildcards[i])) return this._deepWildcards[i];
3000
+ }
3001
+ return null;
3002
+ }
3003
+ };
3004
+
3005
+ // ../../node_modules/path-expression-matcher/src/Matcher.js
3006
+ var MatcherView = class {
3007
+ /**
3008
+ * @param {Matcher} matcher - The parent Matcher instance to read from.
3009
+ */
3010
+ constructor(matcher) {
3011
+ this._matcher = matcher;
3012
+ }
3013
+ /**
3014
+ * Get the path separator used by the parent matcher.
3015
+ * @returns {string}
3016
+ */
3017
+ get separator() {
3018
+ return this._matcher.separator;
3019
+ }
3020
+ /**
3021
+ * Get current tag name.
3022
+ * @returns {string|undefined}
3023
+ */
3024
+ getCurrentTag() {
3025
+ const path = this._matcher.path;
3026
+ return path.length > 0 ? path[path.length - 1].tag : void 0;
3027
+ }
3028
+ /**
3029
+ * Get current namespace.
3030
+ * @returns {string|undefined}
3031
+ */
3032
+ getCurrentNamespace() {
3033
+ const path = this._matcher.path;
3034
+ return path.length > 0 ? path[path.length - 1].namespace : void 0;
3035
+ }
3036
+ /**
3037
+ * Get current node's attribute value.
3038
+ * @param {string} attrName
3039
+ * @returns {*}
3040
+ */
3041
+ getAttrValue(attrName) {
3042
+ var _a;
3043
+ const path = this._matcher.path;
3044
+ if (path.length === 0) return void 0;
3045
+ return (_a = path[path.length - 1].values) == null ? void 0 : _a[attrName];
3046
+ }
3047
+ /**
3048
+ * Check if current node has an attribute.
3049
+ * @param {string} attrName
3050
+ * @returns {boolean}
3051
+ */
3052
+ hasAttr(attrName) {
3053
+ const path = this._matcher.path;
3054
+ if (path.length === 0) return false;
3055
+ const current = path[path.length - 1];
3056
+ return current.values !== void 0 && attrName in current.values;
3057
+ }
3058
+ /**
3059
+ * Get current node's sibling position (child index in parent).
3060
+ * @returns {number}
3061
+ */
3062
+ getPosition() {
3063
+ const path = this._matcher.path;
3064
+ if (path.length === 0) return -1;
3065
+ return path[path.length - 1].position ?? 0;
3066
+ }
3067
+ /**
3068
+ * Get current node's repeat counter (occurrence count of this tag name).
3069
+ * @returns {number}
3070
+ */
3071
+ getCounter() {
3072
+ const path = this._matcher.path;
3073
+ if (path.length === 0) return -1;
3074
+ return path[path.length - 1].counter ?? 0;
3075
+ }
3076
+ /**
3077
+ * Get current node's sibling index (alias for getPosition).
3078
+ * @returns {number}
3079
+ * @deprecated Use getPosition() or getCounter() instead
3080
+ */
3081
+ getIndex() {
3082
+ return this.getPosition();
3083
+ }
3084
+ /**
3085
+ * Get current path depth.
3086
+ * @returns {number}
3087
+ */
3088
+ getDepth() {
3089
+ return this._matcher.path.length;
3090
+ }
3091
+ /**
3092
+ * Get path as string.
3093
+ * @param {string} [separator] - Optional separator (uses default if not provided)
3094
+ * @param {boolean} [includeNamespace=true]
3095
+ * @returns {string}
3096
+ */
3097
+ toString(separator, includeNamespace = true) {
3098
+ return this._matcher.toString(separator, includeNamespace);
3099
+ }
3100
+ /**
3101
+ * Get path as array of tag names.
3102
+ * @returns {string[]}
3103
+ */
3104
+ toArray() {
3105
+ return this._matcher.path.map((n) => n.tag);
3106
+ }
3107
+ /**
3108
+ * Match current path against an Expression.
3109
+ * @param {Expression} expression
3110
+ * @returns {boolean}
3111
+ */
3112
+ matches(expression) {
3113
+ return this._matcher.matches(expression);
3114
+ }
3115
+ /**
3116
+ * Match any expression in the given set against the current path.
3117
+ * @param {ExpressionSet} exprSet
3118
+ * @returns {boolean}
3119
+ */
3120
+ matchesAny(exprSet) {
3121
+ return exprSet.matchesAny(this._matcher);
3122
+ }
3123
+ };
3124
+ var Matcher = class {
3125
+ /**
3126
+ * Create a new Matcher.
3127
+ * @param {Object} [options={}]
3128
+ * @param {string} [options.separator='.'] - Default path separator
3129
+ */
3130
+ constructor(options = {}) {
3131
+ this.separator = options.separator || ".";
3132
+ this.path = [];
3133
+ this.siblingStacks = [];
3134
+ this._pathStringCache = null;
3135
+ this._view = new MatcherView(this);
3136
+ }
3137
+ /**
3138
+ * Push a new tag onto the path.
3139
+ * @param {string} tagName
3140
+ * @param {Object|null} [attrValues=null]
3141
+ * @param {string|null} [namespace=null]
3142
+ */
3143
+ push(tagName, attrValues = null, namespace = null) {
3144
+ this._pathStringCache = null;
3145
+ if (this.path.length > 0) {
3146
+ this.path[this.path.length - 1].values = void 0;
3147
+ }
3148
+ const currentLevel = this.path.length;
3149
+ if (!this.siblingStacks[currentLevel]) {
3150
+ this.siblingStacks[currentLevel] = /* @__PURE__ */ new Map();
3151
+ }
3152
+ const siblings = this.siblingStacks[currentLevel];
3153
+ const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;
3154
+ const counter = siblings.get(siblingKey) || 0;
3155
+ let position = 0;
3156
+ for (const count of siblings.values()) {
3157
+ position += count;
3158
+ }
3159
+ siblings.set(siblingKey, counter + 1);
3160
+ const node = {
3161
+ tag: tagName,
3162
+ position,
3163
+ counter
3164
+ };
3165
+ if (namespace !== null && namespace !== void 0) {
3166
+ node.namespace = namespace;
3167
+ }
3168
+ if (attrValues !== null && attrValues !== void 0) {
3169
+ node.values = attrValues;
3170
+ }
3171
+ this.path.push(node);
3172
+ }
3173
+ /**
3174
+ * Pop the last tag from the path.
3175
+ * @returns {Object|undefined} The popped node
3176
+ */
3177
+ pop() {
3178
+ if (this.path.length === 0) return void 0;
3179
+ this._pathStringCache = null;
3180
+ const node = this.path.pop();
3181
+ if (this.siblingStacks.length > this.path.length + 1) {
3182
+ this.siblingStacks.length = this.path.length + 1;
3183
+ }
3184
+ return node;
3185
+ }
3186
+ /**
3187
+ * Update current node's attribute values.
3188
+ * Useful when attributes are parsed after push.
3189
+ * @param {Object} attrValues
3190
+ */
3191
+ updateCurrent(attrValues) {
3192
+ if (this.path.length > 0) {
3193
+ const current = this.path[this.path.length - 1];
3194
+ if (attrValues !== null && attrValues !== void 0) {
3195
+ current.values = attrValues;
3196
+ }
3197
+ }
3198
+ }
3199
+ /**
3200
+ * Get current tag name.
3201
+ * @returns {string|undefined}
3202
+ */
3203
+ getCurrentTag() {
3204
+ return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0;
3205
+ }
3206
+ /**
3207
+ * Get current namespace.
3208
+ * @returns {string|undefined}
3209
+ */
3210
+ getCurrentNamespace() {
3211
+ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0;
3212
+ }
3213
+ /**
3214
+ * Get current node's attribute value.
3215
+ * @param {string} attrName
3216
+ * @returns {*}
3217
+ */
3218
+ getAttrValue(attrName) {
3219
+ var _a;
3220
+ if (this.path.length === 0) return void 0;
3221
+ return (_a = this.path[this.path.length - 1].values) == null ? void 0 : _a[attrName];
3222
+ }
3223
+ /**
3224
+ * Check if current node has an attribute.
3225
+ * @param {string} attrName
3226
+ * @returns {boolean}
3227
+ */
3228
+ hasAttr(attrName) {
3229
+ if (this.path.length === 0) return false;
3230
+ const current = this.path[this.path.length - 1];
3231
+ return current.values !== void 0 && attrName in current.values;
3232
+ }
3233
+ /**
3234
+ * Get current node's sibling position (child index in parent).
3235
+ * @returns {number}
3236
+ */
3237
+ getPosition() {
3238
+ if (this.path.length === 0) return -1;
3239
+ return this.path[this.path.length - 1].position ?? 0;
3240
+ }
3241
+ /**
3242
+ * Get current node's repeat counter (occurrence count of this tag name).
3243
+ * @returns {number}
3244
+ */
3245
+ getCounter() {
3246
+ if (this.path.length === 0) return -1;
3247
+ return this.path[this.path.length - 1].counter ?? 0;
3248
+ }
3249
+ /**
3250
+ * Get current node's sibling index (alias for getPosition).
3251
+ * @returns {number}
3252
+ * @deprecated Use getPosition() or getCounter() instead
3253
+ */
3254
+ getIndex() {
3255
+ return this.getPosition();
3256
+ }
3257
+ /**
3258
+ * Get current path depth.
3259
+ * @returns {number}
3260
+ */
3261
+ getDepth() {
3262
+ return this.path.length;
3263
+ }
3264
+ /**
3265
+ * Get path as string.
3266
+ * @param {string} [separator] - Optional separator (uses default if not provided)
3267
+ * @param {boolean} [includeNamespace=true]
3268
+ * @returns {string}
3269
+ */
3270
+ toString(separator, includeNamespace = true) {
3271
+ const sep = separator || this.separator;
3272
+ const isDefault = sep === this.separator && includeNamespace === true;
3273
+ if (isDefault) {
3274
+ if (this._pathStringCache !== null) {
3275
+ return this._pathStringCache;
3276
+ }
3277
+ const result = this.path.map(
3278
+ (n) => n.namespace ? `${n.namespace}:${n.tag}` : n.tag
3279
+ ).join(sep);
3280
+ this._pathStringCache = result;
3281
+ return result;
3282
+ }
3283
+ return this.path.map(
3284
+ (n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
3285
+ ).join(sep);
3286
+ }
3287
+ /**
3288
+ * Get path as array of tag names.
3289
+ * @returns {string[]}
3290
+ */
3291
+ toArray() {
3292
+ return this.path.map((n) => n.tag);
3293
+ }
3294
+ /**
3295
+ * Reset the path to empty.
3296
+ */
3297
+ reset() {
3298
+ this._pathStringCache = null;
3299
+ this.path = [];
3300
+ this.siblingStacks = [];
3301
+ }
3302
+ /**
3303
+ * Match current path against an Expression.
3304
+ * @param {Expression} expression
3305
+ * @returns {boolean}
3306
+ */
3307
+ matches(expression) {
3308
+ const segments = expression.segments;
3309
+ if (segments.length === 0) {
3310
+ return false;
3311
+ }
3312
+ if (expression.hasDeepWildcard()) {
3313
+ return this._matchWithDeepWildcard(segments);
3314
+ }
3315
+ return this._matchSimple(segments);
3316
+ }
3317
+ /**
3318
+ * @private
3319
+ */
3320
+ _matchSimple(segments) {
3321
+ if (this.path.length !== segments.length) {
3322
+ return false;
3323
+ }
3324
+ for (let i = 0; i < segments.length; i++) {
3325
+ if (!this._matchSegment(segments[i], this.path[i], i === this.path.length - 1)) {
3326
+ return false;
3327
+ }
3328
+ }
3329
+ return true;
3330
+ }
3331
+ /**
3332
+ * @private
3333
+ */
3334
+ _matchWithDeepWildcard(segments) {
3335
+ let pathIdx = this.path.length - 1;
3336
+ let segIdx = segments.length - 1;
3337
+ while (segIdx >= 0 && pathIdx >= 0) {
3338
+ const segment = segments[segIdx];
3339
+ if (segment.type === "deep-wildcard") {
3340
+ segIdx--;
3341
+ if (segIdx < 0) {
3342
+ return true;
3343
+ }
3344
+ const nextSeg = segments[segIdx];
3345
+ let found = false;
3346
+ for (let i = pathIdx; i >= 0; i--) {
3347
+ if (this._matchSegment(nextSeg, this.path[i], i === this.path.length - 1)) {
3348
+ pathIdx = i - 1;
3349
+ segIdx--;
3350
+ found = true;
3351
+ break;
3352
+ }
3353
+ }
3354
+ if (!found) {
3355
+ return false;
3356
+ }
3357
+ } else {
3358
+ if (!this._matchSegment(segment, this.path[pathIdx], pathIdx === this.path.length - 1)) {
3359
+ return false;
3360
+ }
3361
+ pathIdx--;
3362
+ segIdx--;
3363
+ }
3364
+ }
3365
+ return segIdx < 0;
3366
+ }
3367
+ /**
3368
+ * @private
3369
+ */
3370
+ _matchSegment(segment, node, isCurrentNode) {
3371
+ if (segment.tag !== "*" && segment.tag !== node.tag) {
3372
+ return false;
3373
+ }
3374
+ if (segment.namespace !== void 0) {
3375
+ if (segment.namespace !== "*" && segment.namespace !== node.namespace) {
3376
+ return false;
3377
+ }
3378
+ }
3379
+ if (segment.attrName !== void 0) {
3380
+ if (!isCurrentNode) {
3381
+ return false;
3382
+ }
3383
+ if (!node.values || !(segment.attrName in node.values)) {
3384
+ return false;
3385
+ }
3386
+ if (segment.attrValue !== void 0) {
3387
+ if (String(node.values[segment.attrName]) !== String(segment.attrValue)) {
3388
+ return false;
3389
+ }
3390
+ }
3391
+ }
3392
+ if (segment.position !== void 0) {
3393
+ if (!isCurrentNode) {
3394
+ return false;
3395
+ }
3396
+ const counter = node.counter ?? 0;
3397
+ if (segment.position === "first" && counter !== 0) {
3398
+ return false;
3399
+ } else if (segment.position === "odd" && counter % 2 !== 1) {
3400
+ return false;
3401
+ } else if (segment.position === "even" && counter % 2 !== 0) {
3402
+ return false;
3403
+ } else if (segment.position === "nth" && counter !== segment.positionValue) {
3404
+ return false;
3405
+ }
3406
+ }
3407
+ return true;
3408
+ }
3409
+ /**
3410
+ * Match any expression in the given set against the current path.
3411
+ * @param {ExpressionSet} exprSet
3412
+ * @returns {boolean}
3413
+ */
3414
+ matchesAny(exprSet) {
3415
+ return exprSet.matchesAny(this);
3416
+ }
3417
+ /**
3418
+ * Create a snapshot of current state.
3419
+ * @returns {Object}
3420
+ */
3421
+ snapshot() {
3422
+ return {
3423
+ path: this.path.map((node) => ({ ...node })),
3424
+ siblingStacks: this.siblingStacks.map((map) => new Map(map))
3425
+ };
3426
+ }
3427
+ /**
3428
+ * Restore state from snapshot.
3429
+ * @param {Object} snapshot
3430
+ */
3431
+ restore(snapshot) {
3432
+ this._pathStringCache = null;
3433
+ this.path = snapshot.path.map((node) => ({ ...node }));
3434
+ this.siblingStacks = snapshot.siblingStacks.map((map) => new Map(map));
3435
+ }
3436
+ /**
3437
+ * Return the read-only {@link MatcherView} for this matcher.
3438
+ *
3439
+ * The same instance is returned on every call — no allocation occurs.
3440
+ * It always reflects the current parser state and is safe to pass to
3441
+ * user callbacks without risk of accidental mutation.
3442
+ *
3443
+ * @returns {MatcherView}
3444
+ *
3445
+ * @example
3446
+ * const view = matcher.readOnly();
3447
+ * // pass view to callbacks — it stays in sync automatically
3448
+ * view.matches(expr); // ✓
3449
+ * view.getCurrentTag(); // ✓
3450
+ * // view.push(...) // ✗ method does not exist — caught by TypeScript
3451
+ */
3452
+ readOnly() {
3453
+ return this._view;
3454
+ }
3455
+ };
3456
+
3457
+ // ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
3458
+ function extractRawAttributes(prefixedAttrs, options) {
3459
+ if (!prefixedAttrs) return {};
3460
+ const attrs = options.attributesGroupName ? prefixedAttrs[options.attributesGroupName] : prefixedAttrs;
3461
+ if (!attrs) return {};
3462
+ const rawAttrs = {};
3463
+ for (const key in attrs) {
3464
+ if (key.startsWith(options.attributeNamePrefix)) {
3465
+ const rawName = key.substring(options.attributeNamePrefix.length);
3466
+ rawAttrs[rawName] = attrs[key];
3467
+ } else {
3468
+ rawAttrs[key] = attrs[key];
3469
+ }
3470
+ }
3471
+ return rawAttrs;
3472
+ }
3473
+ function extractNamespace(rawTagName) {
3474
+ if (!rawTagName || typeof rawTagName !== "string") return void 0;
3475
+ const colonIndex = rawTagName.indexOf(":");
3476
+ if (colonIndex !== -1 && colonIndex > 0) {
3477
+ const ns = rawTagName.substring(0, colonIndex);
3478
+ if (ns !== "xmlns") {
3479
+ return ns;
3480
+ }
3481
+ }
3482
+ return void 0;
3483
+ }
3484
+ var OrderedObjParser = class {
3485
+ constructor(options, externalEntities) {
3486
+ this.options = options;
3487
+ this.currentNode = null;
3488
+ this.tagsNodeStack = [];
3489
+ this.parseXml = parseXml;
3490
+ this.parseTextData = parseTextData;
3491
+ this.resolveNameSpace = resolveNameSpace;
3492
+ this.buildAttributesMap = buildAttributesMap;
3493
+ this.isItStopNode = isItStopNode;
3494
+ this.replaceEntitiesValue = replaceEntitiesValue;
3495
+ this.readStopNodeData = readStopNodeData;
3496
+ this.saveTextToParentTag = saveTextToParentTag;
3497
+ this.addChild = addChild;
3498
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
3499
+ this.entityExpansionCount = 0;
3500
+ this.currentExpandedLength = 0;
3501
+ let namedEntities = { ...XML };
3502
+ if (this.options.entityDecoder) {
3503
+ this.entityDecoder = this.options.entityDecoder;
3504
+ } else {
3505
+ if (typeof this.options.htmlEntities === "object") namedEntities = this.options.htmlEntities;
3506
+ else if (this.options.htmlEntities === true) namedEntities = { ...COMMON_HTML, ...CURRENCY };
3507
+ this.entityDecoder = new EntityDecoder({
3508
+ namedEntities: { ...namedEntities, ...externalEntities },
3509
+ numericAllowed: this.options.htmlEntities,
3510
+ limit: {
3511
+ maxTotalExpansions: this.options.processEntities.maxTotalExpansions,
3512
+ maxExpandedLength: this.options.processEntities.maxExpandedLength,
3513
+ applyLimitsTo: this.options.processEntities.appliesTo
3514
+ }
3515
+ //postCheck: resolved => resolved
3516
+ });
3517
+ }
3518
+ this.matcher = new Matcher();
3519
+ this.readonlyMatcher = this.matcher.readOnly();
3520
+ this.isCurrentNodeStopNode = false;
3521
+ this.stopNodeExpressionsSet = new ExpressionSet();
3522
+ const stopNodesOpts = this.options.stopNodes;
3523
+ if (stopNodesOpts && stopNodesOpts.length > 0) {
3524
+ for (let i = 0; i < stopNodesOpts.length; i++) {
3525
+ const stopNodeExp = stopNodesOpts[i];
3526
+ if (typeof stopNodeExp === "string") {
3527
+ this.stopNodeExpressionsSet.add(new Expression(stopNodeExp));
3528
+ } else if (stopNodeExp instanceof Expression) {
3529
+ this.stopNodeExpressionsSet.add(stopNodeExp);
3530
+ }
3531
+ }
3532
+ this.stopNodeExpressionsSet.seal();
3533
+ }
3534
+ }
3535
+ };
3536
+ function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
3537
+ const options = this.options;
3538
+ if (val !== void 0) {
3539
+ if (options.trimValues && !dontTrim) {
3540
+ val = val.trim();
3541
+ }
3542
+ if (val.length > 0) {
3543
+ if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
3544
+ const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
3545
+ const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
3546
+ if (newval === null || newval === void 0) {
3547
+ return val;
3548
+ } else if (typeof newval !== typeof val || newval !== val) {
3549
+ return newval;
3550
+ } else if (options.trimValues) {
3551
+ return parseValue(val, options.parseTagValue, options.numberParseOptions);
3552
+ } else {
3553
+ const trimmedVal = val.trim();
3554
+ if (trimmedVal === val) {
3555
+ return parseValue(val, options.parseTagValue, options.numberParseOptions);
3556
+ } else {
3557
+ return val;
3558
+ }
3559
+ }
3560
+ }
3561
+ }
3562
+ }
3563
+ function resolveNameSpace(tagname) {
3564
+ if (this.options.removeNSPrefix) {
3565
+ const tags = tagname.split(":");
3566
+ const prefix = tagname.charAt(0) === "/" ? "/" : "";
3567
+ if (tags[0] === "xmlns") {
3568
+ return "";
3569
+ }
3570
+ if (tags.length === 2) {
3571
+ tagname = prefix + tags[1];
3572
+ }
3573
+ }
3574
+ return tagname;
3575
+ }
3576
+ var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
3577
+ function buildAttributesMap(attrStr, jPath, tagName, force = false) {
3578
+ const options = this.options;
3579
+ if (force === true || options.ignoreAttributes !== true && typeof attrStr === "string") {
3580
+ const matches = getAllMatches(attrStr, attrsRegx);
3581
+ const len = matches.length;
3582
+ const attrs = {};
3583
+ const processedVals = new Array(len);
3584
+ let hasRawAttrs = false;
3585
+ const rawAttrsForMatcher = {};
3586
+ for (let i = 0; i < len; i++) {
3587
+ const attrName = this.resolveNameSpace(matches[i][1]);
3588
+ const oldVal = matches[i][4];
3589
+ if (attrName.length && oldVal !== void 0) {
3590
+ let val = oldVal;
3591
+ if (options.trimValues) val = val.trim();
3592
+ val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
3593
+ processedVals[i] = val;
3594
+ rawAttrsForMatcher[attrName] = val;
3595
+ hasRawAttrs = true;
3596
+ }
3597
+ }
3598
+ if (hasRawAttrs && typeof jPath === "object" && jPath.updateCurrent) {
3599
+ jPath.updateCurrent(rawAttrsForMatcher);
3600
+ }
3601
+ const jPathStr = options.jPath ? jPath.toString() : this.readonlyMatcher;
3602
+ let hasAttrs = false;
3603
+ for (let i = 0; i < len; i++) {
3604
+ const attrName = this.resolveNameSpace(matches[i][1]);
3605
+ if (this.ignoreAttributesFn(attrName, jPathStr)) continue;
3606
+ let aName = options.attributeNamePrefix + attrName;
3607
+ if (attrName.length) {
3608
+ if (options.transformAttributeName) {
3609
+ aName = options.transformAttributeName(aName);
3610
+ }
3611
+ aName = sanitizeName(aName, options);
3612
+ if (matches[i][4] !== void 0) {
3613
+ const oldVal = processedVals[i];
3614
+ const newVal = options.attributeValueProcessor(attrName, oldVal, jPathStr);
3615
+ if (newVal === null || newVal === void 0) {
3616
+ attrs[aName] = oldVal;
3617
+ } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
3618
+ attrs[aName] = newVal;
3619
+ } else {
3620
+ attrs[aName] = parseValue(oldVal, options.parseAttributeValue, options.numberParseOptions);
3621
+ }
3622
+ hasAttrs = true;
3623
+ } else if (options.allowBooleanAttributes) {
3624
+ attrs[aName] = true;
3625
+ hasAttrs = true;
3626
+ }
3627
+ }
3628
+ }
3629
+ if (!hasAttrs) return;
3630
+ if (options.attributesGroupName && !options.preserveOrder) {
3631
+ const attrCollection = {};
3632
+ attrCollection[options.attributesGroupName] = attrs;
3633
+ return attrCollection;
3634
+ }
3635
+ return attrs;
3636
+ }
3637
+ }
3638
+ var parseXml = function(xmlData) {
3639
+ xmlData = xmlData.replace(/\r\n?/g, "\n");
3640
+ const xmlObj = new XmlNode2("!xml");
3641
+ let currentNode = xmlObj;
3642
+ let textData = "";
3643
+ this.matcher.reset();
3644
+ this.entityDecoder.reset();
3645
+ this.entityExpansionCount = 0;
3646
+ this.currentExpandedLength = 0;
3647
+ const options = this.options;
3648
+ const docTypeReader = new DocTypeReader(options.processEntities);
3649
+ const xmlLen = xmlData.length;
3650
+ for (let i = 0; i < xmlLen; i++) {
3651
+ const ch = xmlData[i];
3652
+ if (ch === "<") {
3653
+ const c1 = xmlData.charCodeAt(i + 1);
3654
+ if (c1 === 47) {
3655
+ const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
3656
+ let tagName = xmlData.substring(i + 2, closeIndex).trim();
3657
+ if (options.removeNSPrefix) {
3658
+ const colonIndex = tagName.indexOf(":");
3659
+ if (colonIndex !== -1) {
3660
+ tagName = tagName.substr(colonIndex + 1);
3661
+ }
3662
+ }
3663
+ tagName = transformTagName(options.transformTagName, tagName, "", options).tagName;
3664
+ if (currentNode) {
3665
+ textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3666
+ }
3667
+ const lastTagName = this.matcher.getCurrentTag();
3668
+ if (tagName && options.unpairedTagsSet.has(tagName)) {
3669
+ throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
3670
+ }
3671
+ if (lastTagName && options.unpairedTagsSet.has(lastTagName)) {
3672
+ this.matcher.pop();
3673
+ this.tagsNodeStack.pop();
3674
+ }
3675
+ this.matcher.pop();
3676
+ this.isCurrentNodeStopNode = false;
3677
+ currentNode = this.tagsNodeStack.pop();
3678
+ textData = "";
3679
+ i = closeIndex;
3680
+ } else if (c1 === 63) {
3681
+ let tagData = readTagExp(xmlData, i, false, "?>");
3682
+ if (!tagData) throw new Error("Pi Tag is not closed.");
3683
+ textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3684
+ const attsMap = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName, true);
3685
+ if (attsMap) {
3686
+ const ver = attsMap[this.options.attributeNamePrefix + "version"];
3687
+ this.entityDecoder.setXmlVersion(Number(ver) || 1);
3688
+ }
3689
+ if (options.ignoreDeclaration && tagData.tagName === "?xml" || options.ignorePiTags) {
3690
+ } else {
3691
+ const childNode = new XmlNode2(tagData.tagName);
3692
+ childNode.add(options.textNodeName, "");
3693
+ if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent && options.ignoreAttributes !== true) {
3694
+ childNode[":@"] = attsMap;
3695
+ }
3696
+ this.addChild(currentNode, childNode, this.readonlyMatcher, i);
3697
+ }
3698
+ i = tagData.closeIndex + 1;
3699
+ } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
3700
+ const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
3701
+ if (options.commentPropName) {
3702
+ const comment = xmlData.substring(i + 4, endIndex - 2);
3703
+ textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3704
+ currentNode.add(options.commentPropName, [{ [options.textNodeName]: comment }]);
3705
+ }
3706
+ i = endIndex;
3707
+ } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 68) {
3708
+ const result = docTypeReader.readDocType(xmlData, i);
3709
+ this.entityDecoder.addInputEntities(result.entities);
3710
+ i = result.i;
3711
+ } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
3712
+ const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
3713
+ const tagExp = xmlData.substring(i + 9, closeIndex);
3714
+ textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3715
+ let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
3716
+ if (val == void 0) val = "";
3717
+ if (options.cdataPropName) {
3718
+ currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
3719
+ } else {
3720
+ currentNode.add(options.textNodeName, val);
3721
+ }
3722
+ i = closeIndex + 2;
3723
+ } else {
3724
+ let result = readTagExp(xmlData, i, options.removeNSPrefix);
3725
+ if (!result) {
3726
+ const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlLen, i + 50));
3727
+ throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
3728
+ }
3729
+ let tagName = result.tagName;
3730
+ const rawTagName = result.rawTagName;
3731
+ let tagExp = result.tagExp;
3732
+ let attrExpPresent = result.attrExpPresent;
3733
+ let closeIndex = result.closeIndex;
3734
+ ({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
3735
+ if (options.strictReservedNames && (tagName === options.commentPropName || tagName === options.cdataPropName || tagName === options.textNodeName || tagName === options.attributesGroupName)) {
3736
+ throw new Error(`Invalid tag name: ${tagName}`);
3737
+ }
3738
+ if (currentNode && textData) {
3739
+ if (currentNode.tagname !== "!xml") {
3740
+ textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
3741
+ }
3742
+ }
3743
+ const lastTag = currentNode;
3744
+ if (lastTag && options.unpairedTagsSet.has(lastTag.tagname)) {
3745
+ currentNode = this.tagsNodeStack.pop();
3746
+ this.matcher.pop();
3747
+ }
3748
+ let isSelfClosing = false;
3749
+ if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
3750
+ isSelfClosing = true;
3751
+ if (tagName[tagName.length - 1] === "/") {
3752
+ tagName = tagName.substr(0, tagName.length - 1);
3753
+ tagExp = tagName;
3754
+ } else {
3755
+ tagExp = tagExp.substr(0, tagExp.length - 1);
3756
+ }
3757
+ attrExpPresent = tagName !== tagExp;
3758
+ }
3759
+ let prefixedAttrs = null;
3760
+ let rawAttrs = {};
3761
+ let namespace = void 0;
3762
+ namespace = extractNamespace(rawTagName);
3763
+ if (tagName !== xmlObj.tagname) {
3764
+ this.matcher.push(tagName, {}, namespace);
3765
+ }
3766
+ if (tagName !== tagExp && attrExpPresent) {
3767
+ prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
3768
+ if (prefixedAttrs) {
3769
+ rawAttrs = extractRawAttributes(prefixedAttrs, options);
3770
+ }
3771
+ }
3772
+ if (tagName !== xmlObj.tagname) {
3773
+ this.isCurrentNodeStopNode = this.isItStopNode();
3774
+ }
3775
+ const startIndex = i;
3776
+ if (this.isCurrentNodeStopNode) {
3777
+ let tagContent = "";
3778
+ if (isSelfClosing) {
3779
+ i = result.closeIndex;
3780
+ } else if (options.unpairedTagsSet.has(tagName)) {
3781
+ i = result.closeIndex;
3782
+ } else {
3783
+ const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
3784
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
3785
+ i = result2.i;
3786
+ tagContent = result2.tagContent;
3787
+ }
3788
+ const childNode = new XmlNode2(tagName);
3789
+ if (prefixedAttrs) {
3790
+ childNode[":@"] = prefixedAttrs;
3791
+ }
3792
+ childNode.add(options.textNodeName, tagContent);
3793
+ this.matcher.pop();
3794
+ this.isCurrentNodeStopNode = false;
3795
+ this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3796
+ } else {
3797
+ if (isSelfClosing) {
3798
+ ({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
3799
+ const childNode = new XmlNode2(tagName);
3800
+ if (prefixedAttrs) {
3801
+ childNode[":@"] = prefixedAttrs;
3802
+ }
3803
+ this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3804
+ this.matcher.pop();
3805
+ this.isCurrentNodeStopNode = false;
3806
+ } else if (options.unpairedTagsSet.has(tagName)) {
3807
+ const childNode = new XmlNode2(tagName);
3808
+ if (prefixedAttrs) {
3809
+ childNode[":@"] = prefixedAttrs;
3810
+ }
3811
+ this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3812
+ this.matcher.pop();
3813
+ this.isCurrentNodeStopNode = false;
3814
+ i = result.closeIndex;
3815
+ continue;
3816
+ } else {
3817
+ const childNode = new XmlNode2(tagName);
3818
+ if (this.tagsNodeStack.length > options.maxNestedTags) {
3819
+ throw new Error("Maximum nested tags exceeded");
3820
+ }
3821
+ this.tagsNodeStack.push(currentNode);
3822
+ if (prefixedAttrs) {
3823
+ childNode[":@"] = prefixedAttrs;
3824
+ }
3825
+ this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3826
+ currentNode = childNode;
3827
+ }
3828
+ textData = "";
3829
+ i = closeIndex;
3830
+ }
3831
+ }
3832
+ } else {
3833
+ textData += xmlData[i];
3834
+ }
3835
+ }
3836
+ return xmlObj.child;
3837
+ };
3838
+ function addChild(currentNode, childNode, matcher, startIndex) {
3839
+ if (!this.options.captureMetaData) startIndex = void 0;
3840
+ const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher;
3841
+ const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]);
3842
+ if (result === false) {
3843
+ } else if (typeof result === "string") {
3844
+ childNode.tagname = result;
3845
+ currentNode.addChild(childNode, startIndex);
3846
+ } else {
3847
+ currentNode.addChild(childNode, startIndex);
3848
+ }
3849
+ }
3850
+ function replaceEntitiesValue(val, tagName, jPath) {
3851
+ const entityConfig = this.options.processEntities;
3852
+ if (!entityConfig || !entityConfig.enabled) {
3853
+ return val;
3854
+ }
3855
+ if (entityConfig.allowedTags) {
3856
+ const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
3857
+ const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
3858
+ if (!allowed) {
3859
+ return val;
3860
+ }
3861
+ }
3862
+ if (entityConfig.tagFilter) {
3863
+ const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
3864
+ if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
3865
+ return val;
3866
+ }
3867
+ }
3868
+ return this.entityDecoder.decode(val);
3869
+ }
3870
+ function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
3871
+ if (textData) {
3872
+ if (isLeafNode === void 0) isLeafNode = parentNode.child.length === 0;
3873
+ textData = this.parseTextData(
3874
+ textData,
3875
+ parentNode.tagname,
3876
+ matcher,
3877
+ false,
3878
+ parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
3879
+ isLeafNode
3880
+ );
3881
+ if (textData !== void 0 && textData !== "")
3882
+ parentNode.add(this.options.textNodeName, textData);
3883
+ textData = "";
3884
+ }
3885
+ return textData;
3886
+ }
3887
+ function isItStopNode() {
3888
+ if (this.stopNodeExpressionsSet.size === 0) return false;
3889
+ return this.matcher.matchesAny(this.stopNodeExpressionsSet);
3890
+ }
3891
+ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
3892
+ let attrBoundary = 0;
3893
+ const len = xmlData.length;
3894
+ const closeCode0 = closingChar.charCodeAt(0);
3895
+ const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
3896
+ let result = "";
3897
+ let segmentStart = i;
3898
+ for (let index = i; index < len; index++) {
3899
+ const code = xmlData.charCodeAt(index);
3900
+ if (attrBoundary) {
3901
+ if (code === attrBoundary) attrBoundary = 0;
3902
+ } else if (code === 34 || code === 39) {
3903
+ attrBoundary = code;
3904
+ } else if (code === closeCode0) {
3905
+ if (closeCode1 !== -1) {
3906
+ if (xmlData.charCodeAt(index + 1) === closeCode1) {
3907
+ result += xmlData.substring(segmentStart, index);
3908
+ return { data: result, index };
3909
+ }
3910
+ } else {
3911
+ result += xmlData.substring(segmentStart, index);
3912
+ return { data: result, index };
3913
+ }
3914
+ } else if (code === 9 && !attrBoundary) {
3915
+ result += xmlData.substring(segmentStart, index) + " ";
3916
+ segmentStart = index + 1;
3917
+ }
3918
+ }
3919
+ }
3920
+ function findClosingIndex(xmlData, str, i, errMsg) {
3921
+ const closingIndex = xmlData.indexOf(str, i);
3922
+ if (closingIndex === -1) {
3923
+ throw new Error(errMsg);
3924
+ } else {
3925
+ return closingIndex + str.length - 1;
3926
+ }
3927
+ }
3928
+ function findClosingChar(xmlData, char, i, errMsg) {
3929
+ const closingIndex = xmlData.indexOf(char, i);
3930
+ if (closingIndex === -1) throw new Error(errMsg);
3931
+ return closingIndex;
3932
+ }
3933
+ function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
3934
+ const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
3935
+ if (!result) return;
3936
+ let tagExp = result.data;
3937
+ const closeIndex = result.index;
3938
+ const separatorIndex = tagExp.search(/\s/);
3939
+ let tagName = tagExp;
3940
+ let attrExpPresent = true;
3941
+ if (separatorIndex !== -1) {
3942
+ tagName = tagExp.substring(0, separatorIndex);
3943
+ tagExp = tagExp.substring(separatorIndex + 1).trimStart();
3944
+ }
3945
+ const rawTagName = tagName;
3946
+ if (removeNSPrefix) {
3947
+ const colonIndex = tagName.indexOf(":");
3948
+ if (colonIndex !== -1) {
3949
+ tagName = tagName.substr(colonIndex + 1);
3950
+ attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
3951
+ }
3952
+ }
3953
+ return {
3954
+ tagName,
3955
+ tagExp,
3956
+ closeIndex,
3957
+ attrExpPresent,
3958
+ rawTagName
3959
+ };
3960
+ }
3961
+ function readStopNodeData(xmlData, tagName, i) {
3962
+ const startIndex = i;
3963
+ let openTagCount = 1;
3964
+ const xmllen = xmlData.length;
3965
+ for (; i < xmllen; i++) {
3966
+ if (xmlData[i] === "<") {
3967
+ const c1 = xmlData.charCodeAt(i + 1);
3968
+ if (c1 === 47) {
3969
+ const closeIndex = findClosingChar(xmlData, ">", i, `${tagName} is not closed`);
3970
+ let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
3971
+ if (closeTagName === tagName) {
3972
+ openTagCount--;
3973
+ if (openTagCount === 0) {
3974
+ return {
3975
+ tagContent: xmlData.substring(startIndex, i),
3976
+ i: closeIndex
3977
+ };
3978
+ }
3979
+ }
3980
+ i = closeIndex;
3981
+ } else if (c1 === 63) {
3982
+ const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
3983
+ i = closeIndex;
3984
+ } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
3985
+ const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
3986
+ i = closeIndex;
3987
+ } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
3988
+ const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
3989
+ i = closeIndex;
3990
+ } else {
3991
+ const tagData = readTagExp(xmlData, i, false);
3992
+ if (tagData) {
3993
+ const openTagName = tagData && tagData.tagName;
3994
+ if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
3995
+ openTagCount++;
3996
+ }
3997
+ i = tagData.closeIndex;
3998
+ }
3999
+ }
4000
+ }
4001
+ }
4002
+ }
4003
+ function parseValue(val, shouldParse, options) {
4004
+ if (shouldParse && typeof val === "string") {
4005
+ const newval = val.trim();
4006
+ if (newval === "true") return true;
4007
+ else if (newval === "false") return false;
4008
+ else return toNumber(val, options);
4009
+ } else {
4010
+ if (isExist(val)) {
4011
+ return val;
4012
+ } else {
4013
+ return "";
4014
+ }
4015
+ }
4016
+ }
4017
+ function transformTagName(fn, tagName, tagExp, options) {
4018
+ if (fn) {
4019
+ const newTagName = fn(tagName);
4020
+ if (tagExp === tagName) {
4021
+ tagExp = newTagName;
4022
+ }
4023
+ tagName = newTagName;
4024
+ }
4025
+ tagName = sanitizeName(tagName, options);
4026
+ return { tagName, tagExp };
4027
+ }
4028
+ function sanitizeName(name, options) {
4029
+ if (criticalProperties.includes(name)) {
4030
+ throw new Error(`[SECURITY] Invalid name: "${name}" is a reserved JavaScript keyword that could cause prototype pollution`);
4031
+ } else if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
4032
+ return options.onDangerousProperty(name);
4033
+ }
4034
+ return name;
4035
+ }
4036
+
4037
+ // ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
4038
+ var METADATA_SYMBOL2 = XmlNode2.getMetaDataSymbol();
4039
+ function stripAttributePrefix(attrs, prefix) {
4040
+ if (!attrs || typeof attrs !== "object") return {};
4041
+ if (!prefix) return attrs;
4042
+ const rawAttrs = {};
4043
+ for (const key in attrs) {
4044
+ if (key.startsWith(prefix)) {
4045
+ const rawName = key.substring(prefix.length);
4046
+ rawAttrs[rawName] = attrs[key];
4047
+ } else {
4048
+ rawAttrs[key] = attrs[key];
4049
+ }
4050
+ }
4051
+ return rawAttrs;
4052
+ }
4053
+ function prettify(node, options, matcher, readonlyMatcher) {
4054
+ return compress(node, options, matcher, readonlyMatcher);
4055
+ }
4056
+ function compress(arr, options, matcher, readonlyMatcher) {
4057
+ let text;
4058
+ const compressedObj = {};
4059
+ for (let i = 0; i < arr.length; i++) {
4060
+ const tagObj = arr[i];
4061
+ const property = propName(tagObj);
4062
+ if (property !== void 0 && property !== options.textNodeName) {
4063
+ const rawAttrs = stripAttributePrefix(
4064
+ tagObj[":@"] || {},
4065
+ options.attributeNamePrefix
4066
+ );
4067
+ matcher.push(property, rawAttrs);
4068
+ }
4069
+ if (property === options.textNodeName) {
4070
+ if (text === void 0) text = tagObj[property];
4071
+ else text += "" + tagObj[property];
4072
+ } else if (property === void 0) {
4073
+ continue;
4074
+ } else if (tagObj[property]) {
4075
+ let val = compress(tagObj[property], options, matcher, readonlyMatcher);
4076
+ const isLeaf = isLeafTag(val, options);
4077
+ if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
4078
+ val[options.textNodeName] = "";
4079
+ }
4080
+ if (tagObj[":@"]) {
4081
+ assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
4082
+ } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
4083
+ val = val[options.textNodeName];
4084
+ } else if (Object.keys(val).length === 0) {
4085
+ if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
4086
+ else val = "";
4087
+ }
4088
+ if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
4089
+ val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
4090
+ }
4091
+ if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
4092
+ if (!Array.isArray(compressedObj[property])) {
4093
+ compressedObj[property] = [compressedObj[property]];
4094
+ }
4095
+ compressedObj[property].push(val);
4096
+ } else {
4097
+ const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
4098
+ if (options.isArray(property, jPathOrMatcher, isLeaf)) {
4099
+ compressedObj[property] = [val];
4100
+ } else {
4101
+ compressedObj[property] = val;
4102
+ }
4103
+ }
4104
+ if (property !== void 0 && property !== options.textNodeName) {
4105
+ matcher.pop();
4106
+ }
4107
+ }
4108
+ }
4109
+ if (typeof text === "string") {
4110
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
4111
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
4112
+ return compressedObj;
4113
+ }
4114
+ function propName(obj) {
4115
+ const keys = Object.keys(obj);
4116
+ for (let i = 0; i < keys.length; i++) {
4117
+ const key = keys[i];
4118
+ if (key !== ":@") return key;
4119
+ }
4120
+ }
4121
+ function assignAttributes(obj, attrMap, readonlyMatcher, options) {
4122
+ if (attrMap) {
4123
+ const keys = Object.keys(attrMap);
4124
+ const len = keys.length;
4125
+ for (let i = 0; i < len; i++) {
4126
+ const atrrName = keys[i];
4127
+ const rawAttrName = atrrName.startsWith(options.attributeNamePrefix) ? atrrName.substring(options.attributeNamePrefix.length) : atrrName;
4128
+ const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() + "." + rawAttrName : readonlyMatcher;
4129
+ if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
4130
+ obj[atrrName] = [attrMap[atrrName]];
4131
+ } else {
4132
+ obj[atrrName] = attrMap[atrrName];
4133
+ }
4134
+ }
4135
+ }
4136
+ }
4137
+ function isLeafTag(obj, options) {
4138
+ const { textNodeName } = options;
4139
+ const propCount = Object.keys(obj).length;
4140
+ if (propCount === 0) {
4141
+ return true;
4142
+ }
4143
+ if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
4144
+ return true;
4145
+ }
4146
+ return false;
4147
+ }
4148
+
4149
+ // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
4150
+ var XMLParser = class {
4151
+ constructor(options) {
4152
+ this.externalEntities = {};
4153
+ this.options = buildOptions(options);
4154
+ }
4155
+ /**
4156
+ * Parse XML dats to JS object
4157
+ * @param {string|Uint8Array} xmlData
4158
+ * @param {boolean|Object} validationOption
4159
+ */
4160
+ parse(xmlData, validationOption) {
4161
+ if (typeof xmlData !== "string" && xmlData.toString) {
4162
+ xmlData = xmlData.toString();
4163
+ } else if (typeof xmlData !== "string") {
4164
+ throw new Error("XML data is accepted in String or Bytes[] form.");
4165
+ }
4166
+ if (validationOption) {
4167
+ if (validationOption === true) validationOption = {};
4168
+ const result = validate(xmlData, validationOption);
4169
+ if (result !== true) {
4170
+ throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
4171
+ }
4172
+ }
4173
+ const orderedObjParser = new OrderedObjParser(this.options, this.externalEntities);
4174
+ const orderedResult = orderedObjParser.parseXml(xmlData);
4175
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
4176
+ else return prettify(orderedResult, this.options, orderedObjParser.matcher, orderedObjParser.readonlyMatcher);
4177
+ }
4178
+ /**
4179
+ * Add Entity which is not by default supported by this library
4180
+ * @param {string} key
4181
+ * @param {string} value
4182
+ */
4183
+ addEntity(key, value) {
4184
+ if (value.indexOf("&") !== -1) {
4185
+ throw new Error("Entity value can't have '&'");
4186
+ } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
4187
+ throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
4188
+ } else if (value === "&") {
4189
+ throw new Error("An entity with value '&' is not permitted");
4190
+ } else {
4191
+ this.externalEntities[key] = value;
4192
+ }
4193
+ }
4194
+ /**
4195
+ * Returns a Symbol that can be used to access the metadata
4196
+ * property on a node.
4197
+ *
4198
+ * If Symbol is not available in the environment, an ordinary property is used
4199
+ * and the name of the property is here returned.
4200
+ *
4201
+ * The XMLMetaData property is only present when `captureMetaData`
4202
+ * is true in the options.
4203
+ */
4204
+ static getMetaDataSymbol() {
4205
+ return XmlNode2.getMetaDataSymbol();
4206
+ }
4207
+ };
4208
+
4209
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js
4210
+ var XML2 = {
4211
+ amp: "&",
4212
+ apos: "'",
4213
+ gt: ">",
4214
+ lt: "<",
4215
+ quot: '"'
4216
+ };
4217
+ var COMMON_HTML2 = {
4218
+ nbsp: "\xA0",
4219
+ copy: "\xA9",
4220
+ reg: "\xAE",
4221
+ trade: "\u2122",
4222
+ mdash: "\u2014",
4223
+ ndash: "\u2013",
4224
+ hellip: "\u2026",
4225
+ laquo: "\xAB",
4226
+ raquo: "\xBB",
4227
+ lsquo: "\u2018",
4228
+ rsquo: "\u2019",
4229
+ ldquo: "\u201C",
4230
+ rdquo: "\u201D",
4231
+ bull: "\u2022",
4232
+ para: "\xB6",
4233
+ sect: "\xA7",
4234
+ deg: "\xB0",
4235
+ frac12: "\xBD",
4236
+ frac14: "\xBC",
4237
+ frac34: "\xBE"
4238
+ };
4239
+ var CURRENCY2 = {
4240
+ cent: "\xA2",
4241
+ pound: "\xA3",
4242
+ curren: "\xA4",
4243
+ yen: "\xA5",
4244
+ euro: "\u20AC",
4245
+ dollar: "$",
4246
+ fnof: "\u0192",
4247
+ inr: "\u20B9",
4248
+ af: "\u060B",
4249
+ birr: "\u1265\u122D",
4250
+ peso: "\u20B1",
4251
+ rub: "\u20BD",
4252
+ won: "\u20A9",
4253
+ yuan: "\xA5",
4254
+ cedil: "\xB8"
4255
+ };
4256
+ var SPECIAL_CHARS2 = new Set("!?\\/[]$%{}^&*()<>|+");
4257
+ function validateEntityName3(name) {
4258
+ if (name[0] === "#") {
4259
+ throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${name}"`);
4260
+ }
4261
+ for (const ch of name) {
4262
+ if (SPECIAL_CHARS2.has(ch)) {
4263
+ throw new Error(`[EntityReplacer] Invalid character '${ch}' in entity name: "${name}"`);
4264
+ }
4265
+ }
4266
+ return name;
4267
+ }
4268
+ function mergeEntityMaps2(...maps) {
4269
+ const out = /* @__PURE__ */ Object.create(null);
4270
+ for (const map of maps) {
4271
+ if (!map) {
4272
+ continue;
4273
+ }
4274
+ for (const key of Object.keys(map)) {
4275
+ const raw = map[key];
4276
+ if (typeof raw === "string") {
4277
+ out[key] = raw;
4278
+ } else if (raw && typeof raw === "object" && raw.val !== void 0) {
4279
+ const val = raw.val;
4280
+ if (typeof val === "string") {
4281
+ out[key] = val;
4282
+ }
4283
+ }
4284
+ }
4285
+ }
4286
+ return out;
4287
+ }
4288
+ var LIMIT_TIER_EXTERNAL2 = "external";
4289
+ var LIMIT_TIER_BASE2 = "base";
4290
+ var LIMIT_TIER_ALL2 = "all";
4291
+ function parseLimitTiers2(raw) {
4292
+ if (!raw || raw === LIMIT_TIER_EXTERNAL2) {
4293
+ return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL2]);
4294
+ }
4295
+ if (raw === LIMIT_TIER_ALL2) {
4296
+ return /* @__PURE__ */ new Set([LIMIT_TIER_ALL2]);
4297
+ }
4298
+ if (raw === LIMIT_TIER_BASE2) {
4299
+ return /* @__PURE__ */ new Set([LIMIT_TIER_BASE2]);
4300
+ }
4301
+ if (Array.isArray(raw)) {
4302
+ return new Set(raw);
4303
+ }
4304
+ return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL2]);
4305
+ }
4306
+ var NCR_LEVEL2 = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 });
4307
+ var XML10_ALLOWED_C02 = /* @__PURE__ */ new Set([9, 10, 13]);
4308
+ function parseNCRConfig2(ncr) {
4309
+ if (!ncr) {
4310
+ return { xmlVersion: 1, onLevel: NCR_LEVEL2.allow, nullLevel: NCR_LEVEL2.remove };
4311
+ }
4312
+ const xmlVersion = ncr.xmlVersion === 1.1 ? 1.1 : 1;
4313
+ const onLevel = NCR_LEVEL2[ncr.onNCR ?? "allow"] ?? NCR_LEVEL2.allow;
4314
+ const nullLevel = NCR_LEVEL2[ncr.nullNCR ?? "remove"] ?? NCR_LEVEL2.remove;
4315
+ const clampedNull = Math.max(nullLevel, NCR_LEVEL2.remove);
4316
+ return { xmlVersion, onLevel, nullLevel: clampedNull };
4317
+ }
4318
+ var EntityDecoderImpl = class EntityDecoderImpl2 {
4319
+ _limit;
4320
+ _maxTotalExpansions;
4321
+ _maxExpandedLength;
4322
+ _postCheck;
4323
+ _limitTiers;
4324
+ _numericAllowed;
4325
+ _baseMap;
4326
+ _externalMap;
4327
+ _inputMap;
4328
+ _totalExpansions;
4329
+ _expandedLength;
4330
+ _removeSet;
4331
+ _leaveSet;
4332
+ _ncrXmlVersion;
4333
+ _ncrOnLevel;
4334
+ _ncrNullLevel;
4335
+ constructor(options = {}) {
4336
+ this._limit = options.limit || {};
4337
+ this._maxTotalExpansions = this._limit.maxTotalExpansions || 0;
4338
+ this._maxExpandedLength = this._limit.maxExpandedLength || 0;
4339
+ this._postCheck = typeof options.postCheck === "function" ? options.postCheck : (r) => r;
4340
+ this._limitTiers = parseLimitTiers2(this._limit.applyLimitsTo ?? LIMIT_TIER_EXTERNAL2);
4341
+ this._numericAllowed = options.numericAllowed ?? true;
4342
+ this._baseMap = mergeEntityMaps2(XML2, options.namedEntities || null);
4343
+ this._externalMap = /* @__PURE__ */ Object.create(null);
4344
+ this._inputMap = /* @__PURE__ */ Object.create(null);
4345
+ this._totalExpansions = 0;
4346
+ this._expandedLength = 0;
4347
+ this._removeSet = new Set(options.remove && Array.isArray(options.remove) ? options.remove : []);
4348
+ this._leaveSet = new Set(options.leave && Array.isArray(options.leave) ? options.leave : []);
4349
+ const ncrCfg = parseNCRConfig2(options.ncr);
4350
+ this._ncrXmlVersion = ncrCfg.xmlVersion;
4351
+ this._ncrOnLevel = ncrCfg.onLevel;
4352
+ this._ncrNullLevel = ncrCfg.nullLevel;
4353
+ }
4354
+ setExternalEntities(map) {
4355
+ if (map) {
4356
+ for (const key of Object.keys(map)) {
4357
+ validateEntityName3(key);
4358
+ }
4359
+ }
4360
+ this._externalMap = mergeEntityMaps2(map);
4361
+ }
4362
+ addExternalEntity(key, value) {
4363
+ validateEntityName3(key);
4364
+ if (typeof value === "string" && value.indexOf("&") === -1) {
4365
+ this._externalMap[key] = value;
4366
+ }
4367
+ }
4368
+ addInputEntities(map) {
4369
+ this._totalExpansions = 0;
4370
+ this._expandedLength = 0;
4371
+ this._inputMap = mergeEntityMaps2(map);
4372
+ }
4373
+ reset() {
4374
+ this._inputMap = /* @__PURE__ */ Object.create(null);
4375
+ this._totalExpansions = 0;
4376
+ this._expandedLength = 0;
4377
+ return this;
4378
+ }
4379
+ setXmlVersion(version) {
4380
+ this._ncrXmlVersion = version === "1.1" || version === 1.1 ? 1.1 : 1;
4381
+ }
4382
+ decode(str) {
4383
+ if (typeof str !== "string" || str.length === 0) {
4384
+ return str;
4385
+ }
4386
+ const original = str;
4387
+ const chunks = [];
4388
+ const len = str.length;
4389
+ let last = 0;
4390
+ let i = 0;
4391
+ const limitExpansions = this._maxTotalExpansions > 0;
4392
+ const limitLength = this._maxExpandedLength > 0;
4393
+ const checkLimits = limitExpansions || limitLength;
4394
+ while (i < len) {
4395
+ if (str.charCodeAt(i) !== 38) {
4396
+ i++;
4397
+ continue;
4398
+ }
4399
+ let j = i + 1;
4400
+ while (j < len && str.charCodeAt(j) !== 59 && j - i <= 32) {
4401
+ j++;
4402
+ }
4403
+ if (j >= len || str.charCodeAt(j) !== 59) {
4404
+ i++;
4405
+ continue;
4406
+ }
4407
+ const token = str.slice(i + 1, j);
4408
+ if (token.length === 0) {
4409
+ i++;
4410
+ continue;
4411
+ }
4412
+ let replacement;
4413
+ let tier;
4414
+ if (this._removeSet.has(token)) {
4415
+ replacement = "";
4416
+ if (tier === void 0) {
4417
+ tier = LIMIT_TIER_EXTERNAL2;
4418
+ }
4419
+ } else if (this._leaveSet.has(token)) {
4420
+ i++;
4421
+ continue;
4422
+ } else if (token.charCodeAt(0) === 35) {
4423
+ const ncrResult = this._resolveNCR(token);
4424
+ if (ncrResult === void 0) {
4425
+ i++;
4426
+ continue;
4427
+ }
4428
+ replacement = ncrResult;
4429
+ tier = LIMIT_TIER_BASE2;
4430
+ } else {
4431
+ const resolved = this._resolveName(token);
4432
+ replacement = resolved == null ? void 0 : resolved.value;
4433
+ tier = resolved == null ? void 0 : resolved.tier;
4434
+ }
4435
+ if (replacement === void 0) {
4436
+ i++;
4437
+ continue;
4438
+ }
4439
+ if (i > last) {
4440
+ chunks.push(str.slice(last, i));
4441
+ }
4442
+ chunks.push(replacement);
4443
+ last = j + 1;
4444
+ i = last;
4445
+ if (checkLimits && this._tierCounts(tier)) {
4446
+ if (limitExpansions) {
4447
+ this._totalExpansions++;
4448
+ if (this._totalExpansions > this._maxTotalExpansions) {
4449
+ throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);
4450
+ }
4451
+ }
4452
+ if (limitLength) {
4453
+ const delta = replacement.length - (token.length + 2);
4454
+ if (delta > 0) {
4455
+ this._expandedLength += delta;
4456
+ if (this._expandedLength > this._maxExpandedLength) {
4457
+ throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`);
4458
+ }
4459
+ }
4460
+ }
4461
+ }
4462
+ }
4463
+ if (last < len) {
4464
+ chunks.push(str.slice(last));
4465
+ }
4466
+ const result = chunks.length === 0 ? str : chunks.join("");
4467
+ return this._postCheck(result, original);
4468
+ }
4469
+ _tierCounts(tier) {
4470
+ if (this._limitTiers.has(LIMIT_TIER_ALL2)) {
4471
+ return true;
4472
+ }
4473
+ return this._limitTiers.has(tier);
4474
+ }
4475
+ _resolveName(name) {
4476
+ if (name in this._inputMap) {
4477
+ return { value: this._inputMap[name], tier: LIMIT_TIER_EXTERNAL2 };
4478
+ }
4479
+ if (name in this._externalMap) {
4480
+ return { value: this._externalMap[name], tier: LIMIT_TIER_EXTERNAL2 };
4481
+ }
4482
+ if (name in this._baseMap) {
4483
+ return { value: this._baseMap[name], tier: LIMIT_TIER_BASE2 };
4484
+ }
4485
+ return void 0;
4486
+ }
4487
+ _classifyNCR(cp) {
4488
+ if (cp === 0) {
4489
+ return this._ncrNullLevel;
4490
+ }
4491
+ if (cp >= 55296 && cp <= 57343) {
4492
+ return NCR_LEVEL2.remove;
4493
+ }
4494
+ if (this._ncrXmlVersion === 1) {
4495
+ if (cp >= 1 && cp <= 31 && !XML10_ALLOWED_C02.has(cp)) {
4496
+ return NCR_LEVEL2.remove;
4497
+ }
4498
+ }
4499
+ return -1;
4500
+ }
4501
+ _applyNCRAction(action, token, cp) {
4502
+ switch (action) {
4503
+ case NCR_LEVEL2.allow:
4504
+ return String.fromCodePoint(cp);
4505
+ case NCR_LEVEL2.remove:
4506
+ return "";
4507
+ case NCR_LEVEL2.leave:
4508
+ return void 0;
4509
+ case NCR_LEVEL2.throw:
4510
+ throw new Error(`[EntityDecoder] Prohibited numeric character reference &${token}; (U+${cp.toString(16).toUpperCase().padStart(4, "0")})`);
4511
+ default:
4512
+ return String.fromCodePoint(cp);
4513
+ }
4514
+ }
4515
+ _resolveNCR(token) {
4516
+ const second = token.charCodeAt(1);
4517
+ let cp;
4518
+ if (second === 120 || second === 88) {
4519
+ cp = parseInt(token.slice(2), 16);
4520
+ } else {
4521
+ cp = parseInt(token.slice(1), 10);
4522
+ }
4523
+ if (Number.isNaN(cp) || cp < 0 || cp > 1114111) {
4524
+ return void 0;
4525
+ }
4526
+ const minimum = this._classifyNCR(cp);
4527
+ if (!this._numericAllowed && minimum < NCR_LEVEL2.remove) {
4528
+ return void 0;
4529
+ }
4530
+ const effective = minimum === -1 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, minimum);
4531
+ return this._applyNCRAction(effective, token, cp);
4532
+ }
4533
+ };
4534
+
4535
+ // ../../node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js
4536
+ var entityDecoder = new EntityDecoderImpl({
4537
+ namedEntities: { ...XML2, ...COMMON_HTML2, ...CURRENCY2 },
4538
+ numericAllowed: true,
4539
+ limit: {
4540
+ maxTotalExpansions: Infinity
4541
+ },
4542
+ ncr: {
4543
+ xmlVersion: 1.1
4544
+ }
4545
+ });
4546
+ var parser = new XMLParser({
4547
+ attributeNamePrefix: "",
4548
+ processEntities: {
4549
+ enabled: true,
4550
+ maxTotalExpansions: Infinity
4551
+ },
4552
+ htmlEntities: true,
4553
+ entityDecoder: {
4554
+ setExternalEntities: (entities) => {
4555
+ entityDecoder.setExternalEntities(entities);
4556
+ },
4557
+ addInputEntities: (entities) => {
4558
+ entityDecoder.addInputEntities(entities);
4559
+ },
4560
+ reset: () => {
4561
+ entityDecoder.reset();
4562
+ },
4563
+ decode: (text) => {
4564
+ return entityDecoder.decode(text);
4565
+ },
4566
+ setXmlVersion: (version) => void {}
4567
+ },
4568
+ ignoreAttributes: false,
4569
+ ignoreDeclaration: true,
4570
+ parseTagValue: false,
4571
+ trimValues: false,
4572
+ tagValueProcessor: (_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0,
4573
+ maxNestedTags: Infinity
4574
+ });
4575
+ function parseXML(xmlString) {
4576
+ return parser.parse(xmlString, true);
4577
+ }
4578
+
4579
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js
4580
+ var XmlShapeDeserializer = class extends SerdeContextConfig {
4581
+ settings;
4582
+ stringDeserializer;
4583
+ constructor(settings) {
4584
+ super();
4585
+ this.settings = settings;
4586
+ this.stringDeserializer = new FromStringShapeDeserializer(settings);
4587
+ }
4588
+ setSerdeContext(serdeContext) {
4589
+ this.serdeContext = serdeContext;
4590
+ this.stringDeserializer.setSerdeContext(serdeContext);
4591
+ }
4592
+ read(schema, bytes, key) {
4593
+ var _a;
4594
+ const ns = NormalizedSchema.of(schema);
4595
+ const memberSchemas = ns.getMemberSchemas();
4596
+ const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
4597
+ return !!memberNs.getMemberTraits().eventPayload;
4598
+ });
4599
+ if (isEventPayload) {
4600
+ const output = {};
4601
+ const memberName = Object.keys(memberSchemas)[0];
4602
+ const eventMemberSchema = memberSchemas[memberName];
4603
+ if (eventMemberSchema.isBlobSchema()) {
4604
+ output[memberName] = bytes;
4605
+ } else {
4606
+ output[memberName] = this.read(memberSchemas[memberName], bytes);
4607
+ }
4608
+ return output;
4609
+ }
4610
+ const xmlString = (((_a = this.serdeContext) == null ? void 0 : _a.utf8Encoder) ?? toUtf8)(bytes);
4611
+ const parsedObject = this.parseXml(xmlString);
4612
+ return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
4613
+ }
4614
+ readSchema(_schema, value) {
4615
+ const ns = NormalizedSchema.of(_schema);
4616
+ if (ns.isUnitSchema()) {
4617
+ return;
4618
+ }
4619
+ const traits = ns.getMergedTraits();
4620
+ if (ns.isListSchema() && !Array.isArray(value)) {
4621
+ return this.readSchema(ns, [value]);
4622
+ }
4623
+ if (value == null) {
4624
+ return value;
4625
+ }
4626
+ if (typeof value === "object") {
4627
+ const flat = !!traits.xmlFlattened;
4628
+ if (ns.isListSchema()) {
4629
+ const listValue = ns.getValueSchema();
4630
+ const buffer2 = [];
4631
+ const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
4632
+ const source = flat ? value : (value[0] ?? value)[sourceKey];
4633
+ if (source == null) {
4634
+ return buffer2;
4635
+ }
4636
+ const sourceArray = Array.isArray(source) ? source : [source];
4637
+ for (const v of sourceArray) {
4638
+ buffer2.push(this.readSchema(listValue, v));
4639
+ }
4640
+ return buffer2;
4641
+ }
4642
+ const buffer = {};
4643
+ if (ns.isMapSchema()) {
4644
+ const keyNs = ns.getKeySchema();
4645
+ const memberNs = ns.getValueSchema();
4646
+ let entries;
4647
+ if (flat) {
4648
+ entries = Array.isArray(value) ? value : [value];
4649
+ } else {
4650
+ entries = Array.isArray(value.entry) ? value.entry : [value.entry];
4651
+ }
4652
+ const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
4653
+ const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
4654
+ for (const entry of entries) {
4655
+ const key = entry[keyProperty];
4656
+ const value2 = entry[valueProperty];
4657
+ buffer[key] = this.readSchema(memberNs, value2);
4658
+ }
4659
+ return buffer;
4660
+ }
4661
+ if (ns.isStructSchema()) {
4662
+ const union = ns.isUnionSchema();
4663
+ let unionSerde;
4664
+ if (union) {
4665
+ unionSerde = new UnionSerde(value, buffer);
4666
+ }
4667
+ for (const [memberName, memberSchema] of ns.structIterator()) {
4668
+ const memberTraits = memberSchema.getMergedTraits();
4669
+ const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
4670
+ if (union) {
4671
+ unionSerde.mark(xmlObjectKey);
4672
+ }
4673
+ if (value[xmlObjectKey] != null) {
4674
+ buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
4675
+ }
4676
+ }
4677
+ if (union) {
4678
+ unionSerde.writeUnknown();
4679
+ }
4680
+ return buffer;
4681
+ }
4682
+ if (ns.isDocumentSchema()) {
4683
+ return value;
4684
+ }
4685
+ throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
4686
+ }
4687
+ if (ns.isListSchema()) {
4688
+ return [];
4689
+ }
4690
+ if (ns.isMapSchema() || ns.isStructSchema()) {
4691
+ return {};
4692
+ }
4693
+ return this.stringDeserializer.read(ns, value);
4694
+ }
4695
+ parseXml(xml) {
4696
+ if (xml.length) {
4697
+ let parsedObj;
4698
+ try {
4699
+ parsedObj = parseXML(xml);
4700
+ } catch (e) {
4701
+ if (e && typeof e === "object") {
4702
+ Object.defineProperty(e, "$responseBodyText", {
4703
+ value: xml
4704
+ });
4705
+ }
4706
+ throw e;
4707
+ }
4708
+ const textNodeName = "#text";
4709
+ const key = Object.keys(parsedObj)[0];
4710
+ const parsedObjToReturn = parsedObj[key];
4711
+ if (parsedObjToReturn[textNodeName]) {
4712
+ parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
4713
+ delete parsedObjToReturn[textNodeName];
4714
+ }
4715
+ return getValueFromTextNode(parsedObjToReturn);
4716
+ }
4717
+ return {};
4718
+ }
4719
+ };
4720
+
4721
+ export {
4722
+ SignatureV4MultiRegion,
4723
+ XmlText,
4724
+ XmlNode,
4725
+ XmlShapeDeserializer
4726
+ };