@authhero/saml 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/saml.mjs CHANGED
@@ -1,81 +1,81 @@
1
- var Q = Object.defineProperty;
2
- var W = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var A = (e, t, n) => W(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { z as s } from "@hono/zod-openapi";
5
- const b = s.object({ "#text": s.string() }), z = s.object({
6
- "#text": s.string(),
7
- "@_xmlns:saml": s.string().optional()
8
- }), D = s.object({
9
- "samlp:AuthnRequest": s.object({
10
- "saml:Issuer": z,
11
- "@_xmlns:samlp": s.string(),
12
- "@_xmlns:saml": s.string().optional(),
13
- "@_ForceAuthn": s.string().transform((e) => e.toLowerCase() === "true").optional(),
14
- "@_ID": s.string(),
15
- "@_IssueInstant": s.string().datetime(),
16
- "@_Destination": s.string().url(),
17
- "@_AssertionConsumerServiceURL": s.string().url().optional(),
18
- "@_ProtocolBinding": s.string().optional(),
19
- "@_Version": s.string()
1
+ var oe = Object.defineProperty;
2
+ var ae = (t, e, n) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var A = (t, e, n) => ae(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { z as i } from "@hono/zod-openapi";
5
+ const N = i.object({ "#text": i.string() }), le = i.object({
6
+ "#text": i.string(),
7
+ "@_xmlns:saml": i.string().optional()
8
+ }), ue = i.object({
9
+ "samlp:AuthnRequest": i.object({
10
+ "saml:Issuer": le,
11
+ "@_xmlns:samlp": i.string(),
12
+ "@_xmlns:saml": i.string().optional(),
13
+ "@_ForceAuthn": i.string().transform((t) => t.toLowerCase() === "true").optional(),
14
+ "@_ID": i.string(),
15
+ "@_IssueInstant": i.string().datetime(),
16
+ "@_Destination": i.string().url(),
17
+ "@_AssertionConsumerServiceURL": i.string().url().optional(),
18
+ "@_ProtocolBinding": i.string().optional(),
19
+ "@_Version": i.string()
20
20
  })
21
- }), Tt = s.array(
22
- s.object({
23
- ":@": s.object({
24
- "@_xmlns": s.string(),
25
- "@_entityID": s.string()
21
+ }), Mt = i.array(
22
+ i.object({
23
+ ":@": i.object({
24
+ "@_xmlns": i.string(),
25
+ "@_entityID": i.string()
26
26
  }),
27
- EntityDescriptor: s.array(
28
- s.object({
29
- ":@": s.object({
30
- "@_protocolSupportEnumeration": s.string()
27
+ EntityDescriptor: i.array(
28
+ i.object({
29
+ ":@": i.object({
30
+ "@_protocolSupportEnumeration": i.string()
31
31
  }),
32
- IDPSSODescriptor: s.array(
33
- s.union([
34
- s.object({
35
- KeyDescriptor: s.array(
36
- s.object({
37
- KeyInfo: s.array(
38
- s.object({
39
- X509Data: s.array(
40
- s.object({
41
- X509Certificate: s.array(b)
32
+ IDPSSODescriptor: i.array(
33
+ i.union([
34
+ i.object({
35
+ KeyDescriptor: i.array(
36
+ i.object({
37
+ KeyInfo: i.array(
38
+ i.object({
39
+ X509Data: i.array(
40
+ i.object({
41
+ X509Certificate: i.array(N)
42
42
  })
43
43
  )
44
44
  })
45
45
  ),
46
- ":@": s.object({
47
- "@_xmlns": s.string()
46
+ ":@": i.object({
47
+ "@_xmlns": i.string()
48
48
  })
49
49
  })
50
50
  ),
51
- ":@": s.object({
52
- "@_use": s.string()
51
+ ":@": i.object({
52
+ "@_use": i.string()
53
53
  })
54
54
  }),
55
- s.object({
56
- SingleLogoutService: s.array(s.object({})),
57
- ":@": s.object({
58
- "@_Binding": s.string(),
59
- "@_Location": s.string()
55
+ i.object({
56
+ SingleLogoutService: i.array(i.object({})),
57
+ ":@": i.object({
58
+ "@_Binding": i.string(),
59
+ "@_Location": i.string()
60
60
  })
61
61
  }),
62
- s.object({
63
- NameIDFormat: s.array(b)
62
+ i.object({
63
+ NameIDFormat: i.array(N)
64
64
  }),
65
- s.object({
66
- SingleSignOnService: s.array(s.object({})),
67
- ":@": s.object({
68
- "@_Binding": s.string(),
69
- "@_Location": s.string()
65
+ i.object({
66
+ SingleSignOnService: i.array(i.object({})),
67
+ ":@": i.object({
68
+ "@_Binding": i.string(),
69
+ "@_Location": i.string()
70
70
  })
71
71
  }),
72
- s.object({
73
- Attribute: s.array(s.object({})),
74
- ":@": s.object({
75
- "@_Name": s.string(),
76
- "@_NameFormat": s.string(),
77
- "@_FriendlyName": s.string(),
78
- "@_xmlns": s.string()
72
+ i.object({
73
+ Attribute: i.array(i.object({})),
74
+ ":@": i.object({
75
+ "@_Name": i.string(),
76
+ "@_NameFormat": i.string(),
77
+ "@_FriendlyName": i.string(),
78
+ "@_xmlns": i.string()
79
79
  })
80
80
  })
81
81
  ])
@@ -83,128 +83,128 @@ const b = s.object({ "#text": s.string() }), z = s.object({
83
83
  })
84
84
  )
85
85
  })
86
- ), ee = s.object({
87
- "saml:Attribute": s.array(
88
- s.object({
89
- "saml:AttributeValue": s.array(
90
- s.object({
91
- "#text": s.string()
86
+ ), ce = i.object({
87
+ "saml:Attribute": i.array(
88
+ i.object({
89
+ "saml:AttributeValue": i.array(
90
+ i.object({
91
+ "#text": i.string()
92
92
  })
93
93
  ),
94
- ":@": s.object({
95
- "@_xmlns:xs": s.string().optional(),
96
- "@_xmlns:xsi": s.string(),
97
- "@_xsi:type": s.string()
94
+ ":@": i.object({
95
+ "@_xmlns:xs": i.string().optional(),
96
+ "@_xmlns:xsi": i.string(),
97
+ "@_xsi:type": i.string()
98
98
  }).optional()
99
99
  })
100
100
  ),
101
- ":@": s.object({
102
- "@_Name": s.string(),
103
- "@_NameFormat": s.string(),
104
- "@_FriendlyName": s.string().optional()
101
+ ":@": i.object({
102
+ "@_Name": i.string(),
103
+ "@_NameFormat": i.string(),
104
+ "@_FriendlyName": i.string().optional()
105
105
  })
106
- }), te = s.object({
107
- "ds:Transform": s.array(s.any()),
108
- ":@": s.object({
109
- "@_Algorithm": s.string()
106
+ }), de = i.object({
107
+ "ds:Transform": i.array(i.any()),
108
+ ":@": i.object({
109
+ "@_Algorithm": i.string()
110
110
  })
111
- }), v = s.object({
112
- "ds:Signature": s.array(
113
- s.union([
114
- s.object({
115
- "ds:SignedInfo": s.array(
116
- s.union([
117
- s.object({
118
- "ds:CanonicalizationMethod": s.array(
119
- s.object({
120
- ":@": s.object({
121
- "@_Algorithm": s.string()
111
+ }), X = i.object({
112
+ "ds:Signature": i.array(
113
+ i.union([
114
+ i.object({
115
+ "ds:SignedInfo": i.array(
116
+ i.union([
117
+ i.object({
118
+ "ds:CanonicalizationMethod": i.array(
119
+ i.object({
120
+ ":@": i.object({
121
+ "@_Algorithm": i.string()
122
122
  })
123
123
  })
124
124
  )
125
125
  }),
126
- s.object({
127
- "ds:SignatureMethod": s.array(
128
- s.object({
129
- ":@": s.object({
130
- "@_Algorithm": s.string()
126
+ i.object({
127
+ "ds:SignatureMethod": i.array(
128
+ i.object({
129
+ ":@": i.object({
130
+ "@_Algorithm": i.string()
131
131
  })
132
132
  })
133
133
  )
134
134
  }),
135
- s.object({
136
- "ds:Reference": s.array(
137
- s.union([
138
- s.object({
139
- "ds:Transforms": s.array(te)
135
+ i.object({
136
+ "ds:Reference": i.array(
137
+ i.union([
138
+ i.object({
139
+ "ds:Transforms": i.array(de)
140
140
  }),
141
- s.object({
142
- "ds:DigestMethod": s.array(
143
- s.object({
144
- ":@": s.object({
145
- "@_Algorithm": s.string()
141
+ i.object({
142
+ "ds:DigestMethod": i.array(
143
+ i.object({
144
+ ":@": i.object({
145
+ "@_Algorithm": i.string()
146
146
  })
147
147
  })
148
148
  )
149
149
  }),
150
- s.object({ "ds:DigestValue": s.array(b) })
150
+ i.object({ "ds:DigestValue": i.array(N) })
151
151
  ])
152
152
  ),
153
- ":@": s.object({
154
- "@_URI": s.string().optional()
153
+ ":@": i.object({
154
+ "@_URI": i.string().optional()
155
155
  }).optional()
156
156
  })
157
157
  ])
158
158
  )
159
159
  }),
160
- s.object({
161
- "ds:SignatureValue": s.array(b)
160
+ i.object({
161
+ "ds:SignatureValue": i.array(N)
162
162
  }),
163
- s.object({
164
- "ds:KeyInfo": s.array(
165
- s.union([
166
- s.object({
167
- "ds:KeyValue": s.array(
168
- s.object({
169
- "ds:RSAKeyValue": s.array(
170
- s.union([
171
- s.object({
172
- "ds:Modulus": s.array(b)
163
+ i.object({
164
+ "ds:KeyInfo": i.array(
165
+ i.union([
166
+ i.object({
167
+ "ds:KeyValue": i.array(
168
+ i.object({
169
+ "ds:RSAKeyValue": i.array(
170
+ i.union([
171
+ i.object({
172
+ "ds:Modulus": i.array(N)
173
173
  }),
174
- s.object({
175
- "ds:Exponent": s.array(b)
174
+ i.object({
175
+ "ds:Exponent": i.array(N)
176
176
  })
177
177
  ])
178
178
  )
179
179
  })
180
180
  )
181
181
  }),
182
- s.object({
183
- "ds:X509Data": s.array(
184
- s.object({
185
- "ds:X509Certificate": s.array(b)
182
+ i.object({
183
+ "ds:X509Data": i.array(
184
+ i.object({
185
+ "ds:X509Certificate": i.array(N)
186
186
  })
187
187
  )
188
188
  }),
189
189
  // Support KeyInfo with both KeyValue and X509Data
190
- s.object({
191
- "ds:KeyValue": s.array(
192
- s.object({
193
- "ds:RSAKeyValue": s.array(
194
- s.union([
195
- s.object({
196
- "ds:Modulus": s.array(b)
190
+ i.object({
191
+ "ds:KeyValue": i.array(
192
+ i.object({
193
+ "ds:RSAKeyValue": i.array(
194
+ i.union([
195
+ i.object({
196
+ "ds:Modulus": i.array(N)
197
197
  }),
198
- s.object({
199
- "ds:Exponent": s.array(b)
198
+ i.object({
199
+ "ds:Exponent": i.array(N)
200
200
  })
201
201
  ])
202
202
  )
203
203
  })
204
204
  ),
205
- "ds:X509Data": s.array(
206
- s.object({
207
- "ds:X509Certificate": s.array(b)
205
+ "ds:X509Data": i.array(
206
+ i.object({
207
+ "ds:X509Certificate": i.array(N)
208
208
  })
209
209
  )
210
210
  })
@@ -213,381 +213,394 @@ const b = s.object({ "#text": s.string() }), z = s.object({
213
213
  })
214
214
  ])
215
215
  ),
216
- ":@": s.object({
217
- "@_xmlns:ds": s.string().optional()
216
+ ":@": i.object({
217
+ "@_xmlns:ds": i.string().optional()
218
218
  }).optional()
219
- }), Ot = s.array(
220
- s.object({
221
- "samlp:Response": s.array(
222
- s.union([
223
- s.object({
224
- "saml:Issuer": s.array(b)
219
+ }), jt = i.array(
220
+ i.object({
221
+ "samlp:Response": i.array(
222
+ i.union([
223
+ i.object({
224
+ "saml:Issuer": i.array(N)
225
225
  }),
226
- v,
227
- s.object({
228
- "samlp:Status": s.array(
229
- s.object({
230
- "samlp:StatusCode": s.array(b),
231
- ":@": s.object({
232
- "@_Value": s.string()
226
+ X,
227
+ i.object({
228
+ "samlp:Status": i.array(
229
+ i.object({
230
+ "samlp:StatusCode": i.array(N),
231
+ ":@": i.object({
232
+ "@_Value": i.string()
233
233
  })
234
234
  })
235
235
  )
236
236
  }),
237
- s.object({
238
- "saml:Assertion": s.array(
239
- s.union([
240
- s.object({
241
- "saml:Issuer": s.array(b)
237
+ i.object({
238
+ "saml:Assertion": i.array(
239
+ i.union([
240
+ i.object({
241
+ "saml:Issuer": i.array(N)
242
242
  }),
243
- v,
244
- s.object({
245
- "saml:Subject": s.array(
246
- s.union([
247
- s.object({
248
- "saml:NameID": s.array(b),
249
- ":@": s.object({
250
- "@_Format": s.string()
243
+ X,
244
+ i.object({
245
+ "saml:Subject": i.array(
246
+ i.union([
247
+ i.object({
248
+ "saml:NameID": i.array(N),
249
+ ":@": i.object({
250
+ "@_Format": i.string()
251
251
  })
252
252
  }),
253
- s.object({
254
- "saml:SubjectConfirmation": s.array(
255
- s.object({
256
- "saml:SubjectConfirmationData": s.array(s.any()),
257
- ":@": s.object({
258
- "@_InResponseTo": s.string(),
259
- "@_NotOnOrAfter": s.string(),
260
- "@_Recipient": s.string()
253
+ i.object({
254
+ "saml:SubjectConfirmation": i.array(
255
+ i.object({
256
+ "saml:SubjectConfirmationData": i.array(i.any()),
257
+ ":@": i.object({
258
+ "@_InResponseTo": i.string(),
259
+ "@_NotOnOrAfter": i.string(),
260
+ "@_Recipient": i.string()
261
261
  })
262
262
  })
263
263
  ),
264
- ":@": s.object({
265
- "@_Method": s.string()
264
+ ":@": i.object({
265
+ "@_Method": i.string()
266
266
  })
267
267
  })
268
268
  ])
269
269
  )
270
270
  }),
271
- s.object({
272
- "saml:Conditions": s.array(
273
- s.object({
274
- "saml:AudienceRestriction": s.array(
275
- s.object({
276
- "saml:Audience": s.array(b)
271
+ i.object({
272
+ "saml:Conditions": i.array(
273
+ i.object({
274
+ "saml:AudienceRestriction": i.array(
275
+ i.object({
276
+ "saml:Audience": i.array(N)
277
277
  })
278
278
  )
279
279
  })
280
280
  ),
281
- ":@": s.object({
282
- "@_NotBefore": s.string(),
283
- "@_NotOnOrAfter": s.string()
281
+ ":@": i.object({
282
+ "@_NotBefore": i.string(),
283
+ "@_NotOnOrAfter": i.string()
284
284
  })
285
285
  }),
286
- s.object({
287
- "saml:AuthnStatement": s.array(
288
- s.object({
289
- "saml:AuthnContext": s.array(
290
- s.object({
291
- "saml:AuthnContextClassRef": s.array(b)
286
+ i.object({
287
+ "saml:AuthnStatement": i.array(
288
+ i.object({
289
+ "saml:AuthnContext": i.array(
290
+ i.object({
291
+ "saml:AuthnContextClassRef": i.array(N)
292
292
  })
293
293
  )
294
294
  })
295
295
  ),
296
- ":@": s.object({
297
- "@_AuthnInstant": s.string(),
298
- "@_SessionIndex": s.string(),
299
- "@_SessionNotOnOrAfter": s.string()
296
+ ":@": i.object({
297
+ "@_AuthnInstant": i.string(),
298
+ "@_SessionIndex": i.string(),
299
+ "@_SessionNotOnOrAfter": i.string()
300
300
  })
301
301
  }),
302
- s.object({
303
- "saml:AttributeStatement": s.array(ee)
302
+ i.object({
303
+ "saml:AttributeStatement": i.array(ce)
304
304
  })
305
305
  ])
306
306
  ),
307
- ":@": s.object({
308
- "@_xmlns": s.string(),
309
- "@_ID": s.string(),
310
- "@_IssueInstant": s.string(),
311
- "@_Version": s.string()
307
+ ":@": i.object({
308
+ "@_xmlns": i.string(),
309
+ "@_ID": i.string(),
310
+ "@_IssueInstant": i.string(),
311
+ "@_Version": i.string()
312
312
  })
313
313
  })
314
314
  ])
315
315
  ),
316
- ":@": s.object({
317
- "@_xmlns:samlp": s.string(),
318
- "@_xmlns:saml": s.string(),
319
- "@_Destination": s.string(),
320
- "@_ID": s.string(),
321
- "@_InResponseTo": s.string(),
322
- "@_IssueInstant": s.string(),
323
- "@_Version": s.string()
316
+ ":@": i.object({
317
+ "@_xmlns:samlp": i.string(),
318
+ "@_xmlns:saml": i.string(),
319
+ "@_Destination": i.string(),
320
+ "@_ID": i.string(),
321
+ "@_InResponseTo": i.string(),
322
+ "@_IssueInstant": i.string(),
323
+ "@_Version": i.string()
324
324
  })
325
325
  })
326
326
  );
327
- var C = {}, I = {};
328
- (function(e) {
329
- const t = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = t + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", o = "[" + t + "][" + n + "]*", i = new RegExp("^" + o + "$"), r = function(u, a) {
330
- const f = [];
331
- let c = a.exec(u);
332
- for (; c; ) {
333
- const d = [];
334
- d.startIndex = a.lastIndex - c[0].length;
335
- const g = c.length;
336
- for (let m = 0; m < g; m++)
337
- d.push(c[m]);
338
- f.push(d), c = a.exec(u);
327
+ var Z = {}, P = {};
328
+ (function(t) {
329
+ const e = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", s = "[" + e + "][" + n + "]*", r = new RegExp("^" + s + "$"), o = function(u, f) {
330
+ const d = [];
331
+ let h = f.exec(u);
332
+ for (; h; ) {
333
+ const m = [];
334
+ m.startIndex = f.lastIndex - h[0].length;
335
+ const b = h.length;
336
+ for (let y = 0; y < b; y++)
337
+ m.push(h[y]);
338
+ d.push(m), h = f.exec(u);
339
339
  }
340
- return f;
341
- }, l = function(u) {
342
- const a = i.exec(u);
343
- return !(a === null || typeof a > "u");
340
+ return d;
341
+ }, a = function(u) {
342
+ const f = r.exec(u);
343
+ return !(f === null || typeof f > "u");
344
344
  };
345
- e.isExist = function(u) {
345
+ t.isExist = function(u) {
346
346
  return typeof u < "u";
347
- }, e.isEmptyObject = function(u) {
347
+ }, t.isEmptyObject = function(u) {
348
348
  return Object.keys(u).length === 0;
349
- }, e.merge = function(u, a, f) {
350
- if (a) {
351
- const c = Object.keys(a), d = c.length;
352
- for (let g = 0; g < d; g++)
353
- f === "strict" ? u[c[g]] = [a[c[g]]] : u[c[g]] = a[c[g]];
349
+ }, t.merge = function(u, f, d) {
350
+ if (f) {
351
+ const h = Object.keys(f), m = h.length;
352
+ for (let b = 0; b < m; b++)
353
+ d === "strict" ? u[h[b]] = [f[h[b]]] : u[h[b]] = f[h[b]];
354
354
  }
355
- }, e.getValue = function(u) {
356
- return e.isExist(u) ? u : "";
357
- }, e.isName = l, e.getAllMatches = r, e.nameRegexp = o;
358
- })(I);
359
- const L = I, ne = {
355
+ }, t.getValue = function(u) {
356
+ return t.isExist(u) ? u : "";
357
+ };
358
+ const c = [
359
+ // '__proto__',
360
+ // 'constructor',
361
+ // 'prototype',
362
+ "hasOwnProperty",
363
+ "toString",
364
+ "valueOf",
365
+ "__defineGetter__",
366
+ "__defineSetter__",
367
+ "__lookupGetter__",
368
+ "__lookupSetter__"
369
+ ], l = ["__proto__", "constructor", "prototype"];
370
+ t.isName = a, t.getAllMatches = o, t.nameRegexp = s, t.DANGEROUS_PROPERTY_NAMES = c, t.criticalProperties = l;
371
+ })(P);
372
+ const V = P, fe = {
360
373
  allowBooleanAttributes: !1,
361
374
  //A tag can have attributes without any value
362
375
  unpairedTags: []
363
376
  };
364
- C.validate = function(e, t) {
365
- t = Object.assign({}, ne, t);
377
+ Z.validate = function(t, e) {
378
+ e = Object.assign({}, fe, e);
366
379
  const n = [];
367
- let o = !1, i = !1;
368
- e[0] === "\uFEFF" && (e = e.substr(1));
369
- for (let r = 0; r < e.length; r++)
370
- if (e[r] === "<" && e[r + 1] === "?") {
371
- if (r += 2, r = F(e, r), r.err) return r;
372
- } else if (e[r] === "<") {
373
- let l = r;
374
- if (r++, e[r] === "!") {
375
- r = V(e, r);
380
+ let s = !1, r = !1;
381
+ t[0] === "\uFEFF" && (t = t.substr(1));
382
+ for (let o = 0; o < t.length; o++)
383
+ if (t[o] === "<" && t[o + 1] === "?") {
384
+ if (o += 2, o = U(t, o), o.err) return o;
385
+ } else if (t[o] === "<") {
386
+ let a = o;
387
+ if (o++, t[o] === "!") {
388
+ o = k(t, o);
376
389
  continue;
377
390
  } else {
378
- let u = !1;
379
- e[r] === "/" && (u = !0, r++);
380
- let a = "";
381
- for (; r < e.length && e[r] !== ">" && e[r] !== " " && e[r] !== " " && e[r] !== `
382
- ` && e[r] !== "\r"; r++)
383
- a += e[r];
384
- if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), r--), !ce(a)) {
391
+ let c = !1;
392
+ t[o] === "/" && (c = !0, o++);
393
+ let l = "";
394
+ for (; o < t.length && t[o] !== ">" && t[o] !== " " && t[o] !== " " && t[o] !== `
395
+ ` && t[o] !== "\r"; o++)
396
+ l += t[o];
397
+ if (l = l.trim(), l[l.length - 1] === "/" && (l = l.substring(0, l.length - 1), o--), !Ee(l)) {
385
398
  let d;
386
- return a.trim().length === 0 ? d = "Invalid space after '<'." : d = "Tag '" + a + "' is an invalid name.", h("InvalidTag", d, N(e, r));
399
+ return l.trim().length === 0 ? d = "Invalid space after '<'." : d = "Tag '" + l + "' is an invalid name.", p("InvalidTag", d, w(t, o));
387
400
  }
388
- const f = ie(e, r);
389
- if (f === !1)
390
- return h("InvalidAttr", "Attributes for '" + a + "' have open quote.", N(e, r));
391
- let c = f.value;
392
- if (r = f.index, c[c.length - 1] === "/") {
393
- const d = r - c.length;
394
- c = c.substring(0, c.length - 1);
395
- const g = X(c, t);
396
- if (g === !0)
397
- o = !0;
401
+ const u = pe(t, o);
402
+ if (u === !1)
403
+ return p("InvalidAttr", "Attributes for '" + l + "' have open quote.", w(t, o));
404
+ let f = u.value;
405
+ if (o = u.index, f[f.length - 1] === "/") {
406
+ const d = o - f.length;
407
+ f = f.substring(0, f.length - 1);
408
+ const h = G(f, e);
409
+ if (h === !0)
410
+ s = !0;
398
411
  else
399
- return h(g.err.code, g.err.msg, N(e, d + g.err.line));
400
- } else if (u)
401
- if (f.tagClosed) {
402
- if (c.trim().length > 0)
403
- return h("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", N(e, l));
412
+ return p(h.err.code, h.err.msg, w(t, d + h.err.line));
413
+ } else if (c)
414
+ if (u.tagClosed) {
415
+ if (f.trim().length > 0)
416
+ return p("InvalidTag", "Closing tag '" + l + "' can't have attributes or invalid starting.", w(t, a));
404
417
  if (n.length === 0)
405
- return h("InvalidTag", "Closing tag '" + a + "' has not been opened.", N(e, l));
418
+ return p("InvalidTag", "Closing tag '" + l + "' has not been opened.", w(t, a));
406
419
  {
407
420
  const d = n.pop();
408
- if (a !== d.tagName) {
409
- let g = N(e, d.tagStartPos);
410
- return h(
421
+ if (l !== d.tagName) {
422
+ let h = w(t, d.tagStartPos);
423
+ return p(
411
424
  "InvalidTag",
412
- "Expected closing tag '" + d.tagName + "' (opened in line " + g.line + ", col " + g.col + ") instead of closing tag '" + a + "'.",
413
- N(e, l)
425
+ "Expected closing tag '" + d.tagName + "' (opened in line " + h.line + ", col " + h.col + ") instead of closing tag '" + l + "'.",
426
+ w(t, a)
414
427
  );
415
428
  }
416
- n.length == 0 && (i = !0);
429
+ n.length == 0 && (r = !0);
417
430
  }
418
- } else return h("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", N(e, r));
431
+ } else return p("InvalidTag", "Closing tag '" + l + "' doesn't have proper closing.", w(t, o));
419
432
  else {
420
- const d = X(c, t);
433
+ const d = G(f, e);
421
434
  if (d !== !0)
422
- return h(d.err.code, d.err.msg, N(e, r - c.length + d.err.line));
423
- if (i === !0)
424
- return h("InvalidXml", "Multiple possible root nodes found.", N(e, r));
425
- t.unpairedTags.indexOf(a) !== -1 || n.push({ tagName: a, tagStartPos: l }), o = !0;
435
+ return p(d.err.code, d.err.msg, w(t, o - f.length + d.err.line));
436
+ if (r === !0)
437
+ return p("InvalidXml", "Multiple possible root nodes found.", w(t, o));
438
+ e.unpairedTags.indexOf(l) !== -1 || n.push({ tagName: l, tagStartPos: a }), s = !0;
426
439
  }
427
- for (r++; r < e.length; r++)
428
- if (e[r] === "<")
429
- if (e[r + 1] === "!") {
430
- r++, r = V(e, r);
440
+ for (o++; o < t.length; o++)
441
+ if (t[o] === "<")
442
+ if (t[o + 1] === "!") {
443
+ o++, o = k(t, o);
431
444
  continue;
432
- } else if (e[r + 1] === "?") {
433
- if (r = F(e, ++r), r.err) return r;
445
+ } else if (t[o + 1] === "?") {
446
+ if (o = U(t, ++o), o.err) return o;
434
447
  } else
435
448
  break;
436
- else if (e[r] === "&") {
437
- const d = ue(e, r);
449
+ else if (t[o] === "&") {
450
+ const d = Ne(t, o);
438
451
  if (d == -1)
439
- return h("InvalidChar", "char '&' is not expected.", N(e, r));
440
- r = d;
441
- } else if (i === !0 && !P(e[r]))
442
- return h("InvalidXml", "Extra text at the end", N(e, r));
443
- e[r] === "<" && r--;
452
+ return p("InvalidChar", "char '&' is not expected.", w(t, o));
453
+ o = d;
454
+ } else if (r === !0 && !B(t[o]))
455
+ return p("InvalidXml", "Extra text at the end", w(t, o));
456
+ t[o] === "<" && o--;
444
457
  }
445
458
  } else {
446
- if (P(e[r]))
459
+ if (B(t[o]))
447
460
  continue;
448
- return h("InvalidChar", "char '" + e[r] + "' is not expected.", N(e, r));
461
+ return p("InvalidChar", "char '" + t[o] + "' is not expected.", w(t, o));
449
462
  }
450
- if (o) {
463
+ if (s) {
451
464
  if (n.length == 1)
452
- return h("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", N(e, n[0].tagStartPos));
465
+ return p("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", w(t, n[0].tagStartPos));
453
466
  if (n.length > 0)
454
- return h("InvalidXml", "Invalid '" + JSON.stringify(n.map((r) => r.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
455
- } else return h("InvalidXml", "Start tag expected.", 1);
467
+ return p("InvalidXml", "Invalid '" + JSON.stringify(n.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
468
+ } else return p("InvalidXml", "Start tag expected.", 1);
456
469
  return !0;
457
470
  };
458
- function P(e) {
459
- return e === " " || e === " " || e === `
460
- ` || e === "\r";
471
+ function B(t) {
472
+ return t === " " || t === " " || t === `
473
+ ` || t === "\r";
461
474
  }
462
- function F(e, t) {
463
- const n = t;
464
- for (; t < e.length; t++)
465
- if (e[t] == "?" || e[t] == " ") {
466
- const o = e.substr(n, t - n);
467
- if (t > 5 && o === "xml")
468
- return h("InvalidXml", "XML declaration allowed only at the start of the document.", N(e, t));
469
- if (e[t] == "?" && e[t + 1] == ">") {
470
- t++;
475
+ function U(t, e) {
476
+ const n = e;
477
+ for (; e < t.length; e++)
478
+ if (t[e] == "?" || t[e] == " ") {
479
+ const s = t.substr(n, e - n);
480
+ if (e > 5 && s === "xml")
481
+ return p("InvalidXml", "XML declaration allowed only at the start of the document.", w(t, e));
482
+ if (t[e] == "?" && t[e + 1] == ">") {
483
+ e++;
471
484
  break;
472
485
  } else
473
486
  continue;
474
487
  }
475
- return t;
488
+ return e;
476
489
  }
477
- function V(e, t) {
478
- if (e.length > t + 5 && e[t + 1] === "-" && e[t + 2] === "-") {
479
- for (t += 3; t < e.length; t++)
480
- if (e[t] === "-" && e[t + 1] === "-" && e[t + 2] === ">") {
481
- t += 2;
490
+ function k(t, e) {
491
+ if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") {
492
+ for (e += 3; e < t.length; e++)
493
+ if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") {
494
+ e += 2;
482
495
  break;
483
496
  }
484
- } else if (e.length > t + 8 && e[t + 1] === "D" && e[t + 2] === "O" && e[t + 3] === "C" && e[t + 4] === "T" && e[t + 5] === "Y" && e[t + 6] === "P" && e[t + 7] === "E") {
497
+ } else if (t.length > e + 8 && t[e + 1] === "D" && t[e + 2] === "O" && t[e + 3] === "C" && t[e + 4] === "T" && t[e + 5] === "Y" && t[e + 6] === "P" && t[e + 7] === "E") {
485
498
  let n = 1;
486
- for (t += 8; t < e.length; t++)
487
- if (e[t] === "<")
499
+ for (e += 8; e < t.length; e++)
500
+ if (t[e] === "<")
488
501
  n++;
489
- else if (e[t] === ">" && (n--, n === 0))
502
+ else if (t[e] === ">" && (n--, n === 0))
490
503
  break;
491
- } else if (e.length > t + 9 && e[t + 1] === "[" && e[t + 2] === "C" && e[t + 3] === "D" && e[t + 4] === "A" && e[t + 5] === "T" && e[t + 6] === "A" && e[t + 7] === "[") {
492
- for (t += 8; t < e.length; t++)
493
- if (e[t] === "]" && e[t + 1] === "]" && e[t + 2] === ">") {
494
- t += 2;
504
+ } else if (t.length > e + 9 && t[e + 1] === "[" && t[e + 2] === "C" && t[e + 3] === "D" && t[e + 4] === "A" && t[e + 5] === "T" && t[e + 6] === "A" && t[e + 7] === "[") {
505
+ for (e += 8; e < t.length; e++)
506
+ if (t[e] === "]" && t[e + 1] === "]" && t[e + 2] === ">") {
507
+ e += 2;
495
508
  break;
496
509
  }
497
510
  }
498
- return t;
511
+ return e;
499
512
  }
500
- const se = '"', re = "'";
501
- function ie(e, t) {
502
- let n = "", o = "", i = !1;
503
- for (; t < e.length; t++) {
504
- if (e[t] === se || e[t] === re)
505
- o === "" ? o = e[t] : o !== e[t] || (o = "");
506
- else if (e[t] === ">" && o === "") {
507
- i = !0;
513
+ const he = '"', ge = "'";
514
+ function pe(t, e) {
515
+ let n = "", s = "", r = !1;
516
+ for (; e < t.length; e++) {
517
+ if (t[e] === he || t[e] === ge)
518
+ s === "" ? s = t[e] : s !== t[e] || (s = "");
519
+ else if (t[e] === ">" && s === "") {
520
+ r = !0;
508
521
  break;
509
522
  }
510
- n += e[t];
523
+ n += t[e];
511
524
  }
512
- return o !== "" ? !1 : {
525
+ return s !== "" ? !1 : {
513
526
  value: n,
514
- index: t,
515
- tagClosed: i
527
+ index: e,
528
+ tagClosed: r
516
529
  };
517
530
  }
518
- const oe = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
519
- function X(e, t) {
520
- const n = L.getAllMatches(e, oe), o = {};
521
- for (let i = 0; i < n.length; i++) {
522
- if (n[i][1].length === 0)
523
- return h("InvalidAttr", "Attribute '" + n[i][2] + "' has no space in starting.", S(n[i]));
524
- if (n[i][3] !== void 0 && n[i][4] === void 0)
525
- return h("InvalidAttr", "Attribute '" + n[i][2] + "' is without value.", S(n[i]));
526
- if (n[i][3] === void 0 && !t.allowBooleanAttributes)
527
- return h("InvalidAttr", "boolean attribute '" + n[i][2] + "' is not allowed.", S(n[i]));
528
- const r = n[i][2];
529
- if (!le(r))
530
- return h("InvalidAttr", "Attribute '" + r + "' is an invalid name.", S(n[i]));
531
- if (!o.hasOwnProperty(r))
532
- o[r] = 1;
531
+ const me = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
532
+ function G(t, e) {
533
+ const n = V.getAllMatches(t, me), s = {};
534
+ for (let r = 0; r < n.length; r++) {
535
+ if (n[r][1].length === 0)
536
+ return p("InvalidAttr", "Attribute '" + n[r][2] + "' has no space in starting.", C(n[r]));
537
+ if (n[r][3] !== void 0 && n[r][4] === void 0)
538
+ return p("InvalidAttr", "Attribute '" + n[r][2] + "' is without value.", C(n[r]));
539
+ if (n[r][3] === void 0 && !e.allowBooleanAttributes)
540
+ return p("InvalidAttr", "boolean attribute '" + n[r][2] + "' is not allowed.", C(n[r]));
541
+ const o = n[r][2];
542
+ if (!we(o))
543
+ return p("InvalidAttr", "Attribute '" + o + "' is an invalid name.", C(n[r]));
544
+ if (!s.hasOwnProperty(o))
545
+ s[o] = 1;
533
546
  else
534
- return h("InvalidAttr", "Attribute '" + r + "' is repeated.", S(n[i]));
547
+ return p("InvalidAttr", "Attribute '" + o + "' is repeated.", C(n[r]));
535
548
  }
536
549
  return !0;
537
550
  }
538
- function ae(e, t) {
551
+ function be(t, e) {
539
552
  let n = /\d/;
540
- for (e[t] === "x" && (t++, n = /[\da-fA-F]/); t < e.length; t++) {
541
- if (e[t] === ";")
542
- return t;
543
- if (!e[t].match(n))
553
+ for (t[e] === "x" && (e++, n = /[\da-fA-F]/); e < t.length; e++) {
554
+ if (t[e] === ";")
555
+ return e;
556
+ if (!t[e].match(n))
544
557
  break;
545
558
  }
546
559
  return -1;
547
560
  }
548
- function ue(e, t) {
549
- if (t++, e[t] === ";")
561
+ function Ne(t, e) {
562
+ if (e++, t[e] === ";")
550
563
  return -1;
551
- if (e[t] === "#")
552
- return t++, ae(e, t);
564
+ if (t[e] === "#")
565
+ return e++, be(t, e);
553
566
  let n = 0;
554
- for (; t < e.length; t++, n++)
555
- if (!(e[t].match(/\w/) && n < 20)) {
556
- if (e[t] === ";")
567
+ for (; e < t.length; e++, n++)
568
+ if (!(t[e].match(/\w/) && n < 20)) {
569
+ if (t[e] === ";")
557
570
  break;
558
571
  return -1;
559
572
  }
560
- return t;
573
+ return e;
561
574
  }
562
- function h(e, t, n) {
575
+ function p(t, e, n) {
563
576
  return {
564
577
  err: {
565
- code: e,
566
- msg: t,
578
+ code: t,
579
+ msg: e,
567
580
  line: n.line || n,
568
581
  col: n.col
569
582
  }
570
583
  };
571
584
  }
572
- function le(e) {
573
- return L.isName(e);
585
+ function we(t) {
586
+ return V.isName(t);
574
587
  }
575
- function ce(e) {
576
- return L.isName(e);
588
+ function Ee(t) {
589
+ return V.isName(t);
577
590
  }
578
- function N(e, t) {
579
- const n = e.substring(0, t).split(/\r?\n/);
591
+ function w(t, e) {
592
+ const n = t.substring(0, e).split(/\r?\n/);
580
593
  return {
581
594
  line: n.length,
582
595
  // column number is last line's length + 1, because column numbering starts at 1:
583
596
  col: n[n.length - 1].length + 1
584
597
  };
585
598
  }
586
- function S(e) {
587
- return e.startIndex + e[1].length;
599
+ function C(t) {
600
+ return t.startIndex + t[1].length;
588
601
  }
589
- var M = {};
590
- const k = {
602
+ var F = {};
603
+ const { DANGEROUS_PROPERTY_NAMES: q, criticalProperties: ye } = P, W = (t) => q.includes(t) ? "__" + t : t, H = {
591
604
  preserveOrder: !1,
592
605
  attributeNamePrefix: "@_",
593
606
  attributesGroupName: !1,
@@ -608,11 +621,11 @@ const k = {
608
621
  leadingZeros: !0,
609
622
  eNotation: !0
610
623
  },
611
- tagValueProcessor: function(e, t) {
612
- return t;
624
+ tagValueProcessor: function(t, e) {
625
+ return e;
613
626
  },
614
- attributeValueProcessor: function(e, t) {
615
- return t;
627
+ attributeValueProcessor: function(t, e) {
628
+ return e;
616
629
  },
617
630
  stopNodes: [],
618
631
  //nested tags will not be parsed even for errors
@@ -626,138 +639,324 @@ const k = {
626
639
  ignorePiTags: !1,
627
640
  transformTagName: !1,
628
641
  transformAttributeName: !1,
629
- updateTag: function(e, t, n) {
630
- return e;
631
- }
642
+ updateTag: function(t, e, n) {
643
+ return t;
644
+ },
632
645
  // skipEmptyListItem: false
633
- }, fe = function(e) {
634
- return Object.assign({}, k, e);
646
+ captureMetaData: !1,
647
+ maxNestedTags: 100,
648
+ strictReservedNames: !0,
649
+ onDangerousProperty: W
650
+ };
651
+ function xe(t, e) {
652
+ if (typeof t != "string")
653
+ return;
654
+ const n = t.toLowerCase();
655
+ if (q.some((s) => n === s.toLowerCase()))
656
+ throw new Error(
657
+ `[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`
658
+ );
659
+ if (ye.some((s) => n === s.toLowerCase()))
660
+ throw new Error(
661
+ `[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`
662
+ );
663
+ }
664
+ function Q(t) {
665
+ return typeof t == "boolean" ? {
666
+ enabled: t,
667
+ // true or false
668
+ maxEntitySize: 1e4,
669
+ maxExpansionDepth: 10,
670
+ maxTotalExpansions: 1e3,
671
+ maxExpandedLength: 1e5,
672
+ allowedTags: null,
673
+ tagFilter: null
674
+ } : typeof t == "object" && t !== null ? {
675
+ enabled: t.enabled !== !1,
676
+ maxEntitySize: Math.max(1, t.maxEntitySize ?? 1e4),
677
+ maxExpansionDepth: Math.max(1, t.maxExpansionDepth ?? 1e4),
678
+ maxTotalExpansions: Math.max(1, t.maxTotalExpansions ?? 1 / 0),
679
+ maxExpandedLength: Math.max(1, t.maxExpandedLength ?? 1e5),
680
+ maxEntityCount: Math.max(1, t.maxEntityCount ?? 1e3),
681
+ allowedTags: t.allowedTags ?? null,
682
+ tagFilter: t.tagFilter ?? null
683
+ } : Q(!0);
684
+ }
685
+ const Ae = function(t) {
686
+ const e = Object.assign({}, H, t), n = [
687
+ { value: e.attributeNamePrefix, name: "attributeNamePrefix" },
688
+ { value: e.attributesGroupName, name: "attributesGroupName" },
689
+ { value: e.textNodeName, name: "textNodeName" },
690
+ { value: e.cdataPropName, name: "cdataPropName" },
691
+ { value: e.commentPropName, name: "commentPropName" }
692
+ ];
693
+ for (const { value: s, name: r } of n)
694
+ s && xe(s, r);
695
+ return e.onDangerousProperty === null && (e.onDangerousProperty = W), e.processEntities = Q(e.processEntities), e;
635
696
  };
636
- M.buildOptions = fe;
637
- M.defaultOptions = k;
638
- class de {
639
- constructor(t) {
640
- this.tagname = t, this.child = [], this[":@"] = {};
697
+ F.buildOptions = Ae;
698
+ F.defaultOptions = H;
699
+ class _e {
700
+ constructor(e) {
701
+ this.tagname = e, this.child = [], this[":@"] = {};
641
702
  }
642
- add(t, n) {
643
- t === "__proto__" && (t = "#__proto__"), this.child.push({ [t]: n });
703
+ add(e, n) {
704
+ e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: n });
644
705
  }
645
- addChild(t) {
646
- t.tagname === "__proto__" && (t.tagname = "#__proto__"), t[":@"] && Object.keys(t[":@"]).length > 0 ? this.child.push({ [t.tagname]: t.child, ":@": t[":@"] }) : this.child.push({ [t.tagname]: t.child });
706
+ addChild(e) {
707
+ e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({ [e.tagname]: e.child, ":@": e[":@"] }) : this.child.push({ [e.tagname]: e.child });
647
708
  }
648
709
  }
649
- var ge = de;
650
- const he = I;
651
- function pe(e, t) {
652
- const n = {};
653
- if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
654
- t = t + 9;
655
- let o = 1, i = !1, r = !1, l = "";
656
- for (; t < e.length; t++)
657
- if (e[t] === "<" && !r) {
658
- if (i && Ne(e, t)) {
659
- t += 7;
660
- let u, a;
661
- [u, a, t] = me(e, t + 1), a.indexOf("&") === -1 && (n[_e(u)] = {
662
- regx: RegExp(`&${u};`, "g"),
663
- val: a
664
- });
665
- } else if (i && we(e, t)) t += 8;
666
- else if (i && ye(e, t)) t += 8;
667
- else if (i && Ae(e, t)) t += 9;
668
- else if (be) r = !0;
669
- else throw new Error("Invalid DOCTYPE");
670
- o++, l = "";
671
- } else if (e[t] === ">") {
672
- if (r ? e[t - 1] === "-" && e[t - 2] === "-" && (r = !1, o--) : o--, o === 0)
673
- break;
674
- } else e[t] === "[" ? i = !0 : l += e[t];
675
- if (o !== 0)
676
- throw new Error("Unclosed DOCTYPE");
677
- } else
678
- throw new Error("Invalid Tag instead of DOCTYPE");
679
- return { entities: n, i: t };
680
- }
681
- function me(e, t) {
682
- let n = "";
683
- for (; t < e.length && e[t] !== "'" && e[t] !== '"'; t++)
684
- n += e[t];
685
- if (n = n.trim(), n.indexOf(" ") !== -1) throw new Error("External entites are not supported");
686
- const o = e[t++];
687
- let i = "";
688
- for (; t < e.length && e[t] !== o; t++)
689
- i += e[t];
690
- return [n, i, t];
691
- }
692
- function be(e, t) {
693
- return e[t + 1] === "!" && e[t + 2] === "-" && e[t + 3] === "-";
694
- }
695
- function Ne(e, t) {
696
- return e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "N" && e[t + 4] === "T" && e[t + 5] === "I" && e[t + 6] === "T" && e[t + 7] === "Y";
697
- }
698
- function we(e, t) {
699
- return e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "L" && e[t + 4] === "E" && e[t + 5] === "M" && e[t + 6] === "E" && e[t + 7] === "N" && e[t + 8] === "T";
700
- }
701
- function ye(e, t) {
702
- return e[t + 1] === "!" && e[t + 2] === "A" && e[t + 3] === "T" && e[t + 4] === "T" && e[t + 5] === "L" && e[t + 6] === "I" && e[t + 7] === "S" && e[t + 8] === "T";
703
- }
704
- function Ae(e, t) {
705
- return e[t + 1] === "!" && e[t + 2] === "N" && e[t + 3] === "O" && e[t + 4] === "T" && e[t + 5] === "A" && e[t + 6] === "T" && e[t + 7] === "I" && e[t + 8] === "O" && e[t + 9] === "N";
710
+ var Se = _e;
711
+ const D = P;
712
+ let Te = class {
713
+ constructor(e) {
714
+ this.suppressValidationErr = !e, this.options = e || {};
715
+ }
716
+ readDocType(e, n) {
717
+ const s = /* @__PURE__ */ Object.create(null);
718
+ let r = 0;
719
+ if (e[n + 3] === "O" && e[n + 4] === "C" && e[n + 5] === "T" && e[n + 6] === "Y" && e[n + 7] === "P" && e[n + 8] === "E") {
720
+ n = n + 9;
721
+ let o = 1, a = !1, c = !1, l = "";
722
+ for (; n < e.length; n++)
723
+ if (e[n] === "<" && !c) {
724
+ if (a && _(e, "!ENTITY", n)) {
725
+ n += 7;
726
+ let u, f;
727
+ if ([u, f, n] = this.readEntityExp(e, n + 1, this.suppressValidationErr), f.indexOf("&") === -1) {
728
+ if (this.options.enabled !== !1 && this.options.maxEntityCount != null && r >= this.options.maxEntityCount)
729
+ throw new Error(
730
+ `Entity count (${r + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
731
+ );
732
+ const d = u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
733
+ s[u] = {
734
+ regx: RegExp(`&${d};`, "g"),
735
+ val: f
736
+ }, r++;
737
+ }
738
+ } else if (a && _(e, "!ELEMENT", n)) {
739
+ n += 8;
740
+ const { index: u } = this.readElementExp(e, n + 1);
741
+ n = u;
742
+ } else if (a && _(e, "!ATTLIST", n))
743
+ n += 8;
744
+ else if (a && _(e, "!NOTATION", n)) {
745
+ n += 9;
746
+ const { index: u } = this.readNotationExp(e, n + 1, this.suppressValidationErr);
747
+ n = u;
748
+ } else if (_(e, "!--", n))
749
+ c = !0;
750
+ else
751
+ throw new Error("Invalid DOCTYPE");
752
+ o++, l = "";
753
+ } else if (e[n] === ">") {
754
+ if (c ? e[n - 1] === "-" && e[n - 2] === "-" && (c = !1, o--) : o--, o === 0)
755
+ break;
756
+ } else e[n] === "[" ? a = !0 : l += e[n];
757
+ if (o !== 0)
758
+ throw new Error("Unclosed DOCTYPE");
759
+ } else
760
+ throw new Error("Invalid Tag instead of DOCTYPE");
761
+ return { entities: s, i: n };
762
+ }
763
+ readEntityExp(e, n) {
764
+ n = E(e, n);
765
+ let s = "";
766
+ for (; n < e.length && !/\s/.test(e[n]) && e[n] !== '"' && e[n] !== "'"; )
767
+ s += e[n], n++;
768
+ if (O(s), n = E(e, n), !this.suppressValidationErr) {
769
+ if (e.substring(n, n + 6).toUpperCase() === "SYSTEM")
770
+ throw new Error("External entities are not supported");
771
+ if (e[n] === "%")
772
+ throw new Error("Parameter entities are not supported");
773
+ }
774
+ let r = "";
775
+ if ([n, r] = this.readIdentifierVal(e, n, "entity"), this.options.enabled !== !1 && this.options.maxEntitySize != null && r.length > this.options.maxEntitySize)
776
+ throw new Error(
777
+ `Entity "${s}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
778
+ );
779
+ return n--, [s, r, n];
780
+ }
781
+ readNotationExp(e, n) {
782
+ n = E(e, n);
783
+ let s = "";
784
+ for (; n < e.length && !/\s/.test(e[n]); )
785
+ s += e[n], n++;
786
+ !this.suppressValidationErr && O(s), n = E(e, n);
787
+ const r = e.substring(n, n + 6).toUpperCase();
788
+ if (!this.suppressValidationErr && r !== "SYSTEM" && r !== "PUBLIC")
789
+ throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);
790
+ n += r.length, n = E(e, n);
791
+ let o = null, a = null;
792
+ if (r === "PUBLIC")
793
+ [n, o] = this.readIdentifierVal(e, n, "publicIdentifier"), n = E(e, n), (e[n] === '"' || e[n] === "'") && ([n, a] = this.readIdentifierVal(e, n, "systemIdentifier"));
794
+ else if (r === "SYSTEM" && ([n, a] = this.readIdentifierVal(e, n, "systemIdentifier"), !this.suppressValidationErr && !a))
795
+ throw new Error("Missing mandatory system identifier for SYSTEM notation");
796
+ return { notationName: s, publicIdentifier: o, systemIdentifier: a, index: --n };
797
+ }
798
+ readIdentifierVal(e, n, s) {
799
+ let r = "";
800
+ const o = e[n];
801
+ if (o !== '"' && o !== "'")
802
+ throw new Error(`Expected quoted string, found "${o}"`);
803
+ for (n++; n < e.length && e[n] !== o; )
804
+ r += e[n], n++;
805
+ if (e[n] !== o)
806
+ throw new Error(`Unterminated ${s} value`);
807
+ return n++, [n, r];
808
+ }
809
+ readElementExp(e, n) {
810
+ n = E(e, n);
811
+ let s = "";
812
+ for (; n < e.length && !/\s/.test(e[n]); )
813
+ s += e[n], n++;
814
+ if (!this.suppressValidationErr && !D.isName(s))
815
+ throw new Error(`Invalid element name: "${s}"`);
816
+ n = E(e, n);
817
+ let r = "";
818
+ if (e[n] === "E" && _(e, "MPTY", n))
819
+ n += 4;
820
+ else if (e[n] === "A" && _(e, "NY", n))
821
+ n += 2;
822
+ else if (e[n] === "(") {
823
+ for (n++; n < e.length && e[n] !== ")"; )
824
+ r += e[n], n++;
825
+ if (e[n] !== ")")
826
+ throw new Error("Unterminated content model");
827
+ } else if (!this.suppressValidationErr)
828
+ throw new Error(`Invalid Element Expression, found "${e[n]}"`);
829
+ return {
830
+ elementName: s,
831
+ contentModel: r.trim(),
832
+ index: n
833
+ };
834
+ }
835
+ readAttlistExp(e, n) {
836
+ n = E(e, n);
837
+ let s = "";
838
+ for (; n < e.length && !/\s/.test(e[n]); )
839
+ s += e[n], n++;
840
+ O(s), n = E(e, n);
841
+ let r = "";
842
+ for (; n < e.length && !/\s/.test(e[n]); )
843
+ r += e[n], n++;
844
+ if (!O(r))
845
+ throw new Error(`Invalid attribute name: "${r}"`);
846
+ n = E(e, n);
847
+ let o = "";
848
+ if (e.substring(n, n + 8).toUpperCase() === "NOTATION") {
849
+ if (o = "NOTATION", n += 8, n = E(e, n), e[n] !== "(")
850
+ throw new Error(`Expected '(', found "${e[n]}"`);
851
+ n++;
852
+ let c = [];
853
+ for (; n < e.length && e[n] !== ")"; ) {
854
+ let l = "";
855
+ for (; n < e.length && e[n] !== "|" && e[n] !== ")"; )
856
+ l += e[n], n++;
857
+ if (l = l.trim(), !O(l))
858
+ throw new Error(`Invalid notation name: "${l}"`);
859
+ c.push(l), e[n] === "|" && (n++, n = E(e, n));
860
+ }
861
+ if (e[n] !== ")")
862
+ throw new Error("Unterminated list of notations");
863
+ n++, o += " (" + c.join("|") + ")";
864
+ } else {
865
+ for (; n < e.length && !/\s/.test(e[n]); )
866
+ o += e[n], n++;
867
+ const c = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
868
+ if (!this.suppressValidationErr && !c.includes(o.toUpperCase()))
869
+ throw new Error(`Invalid attribute type: "${o}"`);
870
+ }
871
+ n = E(e, n);
872
+ let a = "";
873
+ return e.substring(n, n + 8).toUpperCase() === "#REQUIRED" ? (a = "#REQUIRED", n += 8) : e.substring(n, n + 7).toUpperCase() === "#IMPLIED" ? (a = "#IMPLIED", n += 7) : [n, a] = this.readIdentifierVal(e, n, "ATTLIST"), {
874
+ elementName: s,
875
+ attributeName: r,
876
+ attributeType: o,
877
+ defaultValue: a,
878
+ index: n
879
+ };
880
+ }
881
+ };
882
+ const E = (t, e) => {
883
+ for (; e < t.length && /\s/.test(t[e]); )
884
+ e++;
885
+ return e;
886
+ };
887
+ function _(t, e, n) {
888
+ for (let s = 0; s < e.length; s++)
889
+ if (e[s] !== t[n + s + 1]) return !1;
890
+ return !0;
706
891
  }
707
- function _e(e) {
708
- if (he.isName(e))
709
- return e;
710
- throw new Error(`Invalid entity name ${e}`);
892
+ function O(t) {
893
+ if (D.isName(t))
894
+ return t;
895
+ throw new Error(`Invalid entity name ${t}`);
711
896
  }
712
- var xe = pe;
713
- const Se = /^[-+]?0x[a-fA-F0-9]+$/, Ee = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
714
- !Number.parseInt && window.parseInt && (Number.parseInt = window.parseInt);
715
- !Number.parseFloat && window.parseFloat && (Number.parseFloat = window.parseFloat);
716
- const Ie = {
897
+ var Ie = Te;
898
+ const Ce = /^[-+]?0x[a-fA-F0-9]+$/, Oe = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, Pe = {
717
899
  hex: !0,
900
+ // oct: false,
718
901
  leadingZeros: !0,
719
902
  decimalPoint: ".",
720
903
  eNotation: !0
721
904
  //skipLike: /regex/
722
905
  };
723
- function Te(e, t = {}) {
724
- if (t = Object.assign({}, Ie, t), !e || typeof e != "string") return e;
725
- let n = e.trim();
726
- if (t.skipLike !== void 0 && t.skipLike.test(n)) return e;
727
- if (t.hex && Se.test(n))
728
- return Number.parseInt(n, 16);
729
- {
730
- const o = Ee.exec(n);
731
- if (o) {
732
- const i = o[1], r = o[2];
733
- let l = Oe(o[3]);
734
- const u = o[4] || o[6];
735
- if (!t.leadingZeros && r.length > 0 && i && n[2] !== ".") return e;
736
- if (!t.leadingZeros && r.length > 0 && !i && n[1] !== ".") return e;
906
+ function Le(t, e = {}) {
907
+ if (e = Object.assign({}, Pe, e), !t || typeof t != "string") return t;
908
+ let n = t.trim();
909
+ if (e.skipLike !== void 0 && e.skipLike.test(n)) return t;
910
+ if (t === "0") return 0;
911
+ if (e.hex && Ce.test(n))
912
+ return je(n, 16);
913
+ if (n.search(/[eE]/) !== -1) {
914
+ const s = n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);
915
+ if (s) {
916
+ if (e.leadingZeros)
917
+ n = (s[1] || "") + s[3];
918
+ else if (!(s[2] === "0" && s[3][0] === ".")) return t;
919
+ return e.eNotation ? Number(n) : t;
920
+ } else
921
+ return t;
922
+ } else {
923
+ const s = Oe.exec(n);
924
+ if (s) {
925
+ const r = s[1], o = s[2];
926
+ let a = Me(s[3]);
927
+ if (!e.leadingZeros && o.length > 0 && r && n[2] !== ".") return t;
928
+ if (!e.leadingZeros && o.length > 0 && !r && n[1] !== ".") return t;
929
+ if (e.leadingZeros && o === t) return 0;
737
930
  {
738
- const a = Number(n), f = "" + a;
739
- return f.search(/[eE]/) !== -1 || u ? t.eNotation ? a : e : n.indexOf(".") !== -1 ? f === "0" && l === "" || f === l || i && f === "-" + l ? a : e : r ? l === f || i + l === f ? a : e : n === f || n === i + f ? a : e;
931
+ const c = Number(n), l = "" + c;
932
+ return l.search(/[eE]/) !== -1 ? e.eNotation ? c : t : n.indexOf(".") !== -1 ? l === "0" && a === "" || l === a || r && l === "-" + a ? c : t : o ? a === l || r + a === l ? c : t : n === l || n === r + l ? c : t;
740
933
  }
741
934
  } else
742
- return e;
935
+ return t;
743
936
  }
744
937
  }
745
- function Oe(e) {
746
- return e && e.indexOf(".") !== -1 && (e = e.replace(/0+$/, ""), e === "." ? e = "0" : e[0] === "." ? e = "0" + e : e[e.length - 1] === "." && (e = e.substr(0, e.length - 1))), e;
938
+ function Me(t) {
939
+ return t && t.indexOf(".") !== -1 && (t = t.replace(/0+$/, ""), t === "." ? t = "0" : t[0] === "." ? t = "0" + t : t[t.length - 1] === "." && (t = t.substr(0, t.length - 1))), t;
940
+ }
941
+ function je(t, e) {
942
+ if (parseInt) return parseInt(t, e);
943
+ if (Number.parseInt) return Number.parseInt(t, e);
944
+ if (window && window.parseInt) return window.parseInt(t, e);
945
+ throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
747
946
  }
748
- var Ce = Te;
749
- function Le(e) {
750
- return typeof e == "function" ? e : Array.isArray(e) ? (t) => {
751
- for (const n of e)
752
- if (typeof n == "string" && t === n || n instanceof RegExp && n.test(t))
947
+ var ve = Le;
948
+ function $e(t) {
949
+ return typeof t == "function" ? t : Array.isArray(t) ? (e) => {
950
+ for (const n of t)
951
+ if (typeof n == "string" && e === n || n instanceof RegExp && n.test(e))
753
952
  return !0;
754
953
  } : () => !1;
755
954
  }
756
- var U = Le;
757
- const G = I, E = ge, Me = xe, je = Ce, ve = U;
758
- let Pe = class {
759
- constructor(t) {
760
- this.options = t, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
955
+ var ee = $e;
956
+ const L = P, I = Se, Ve = Ie, Fe = ve, Re = ee;
957
+ let Xe = class {
958
+ constructor(e) {
959
+ if (this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
761
960
  apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
762
961
  gt: { regex: /&(gt|#62|#x3E);/g, val: ">" },
763
962
  lt: { regex: /&(lt|#60|#x3C);/g, val: "<" },
@@ -776,423 +975,482 @@ let Pe = class {
776
975
  copyright: { regex: /&(copy|#169);/g, val: "©" },
777
976
  reg: { regex: /&(reg|#174);/g, val: "®" },
778
977
  inr: { regex: /&(inr|#8377);/g, val: "₹" },
779
- num_dec: { regex: /&#([0-9]{1,7});/g, val: (n, o) => String.fromCharCode(Number.parseInt(o, 10)) },
780
- num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (n, o) => String.fromCharCode(Number.parseInt(o, 16)) }
781
- }, this.addExternalEntities = Fe, this.parseXml = Be, this.parseTextData = Ve, this.resolveNameSpace = Xe, this.buildAttributesMap = Re, this.isItStopNode = Ke, this.replaceEntitiesValue = Ue, this.readStopNodeData = qe, this.saveTextToParentTag = Ge, this.addChild = ke, this.ignoreAttributesFn = ve(this.options.ignoreAttributes);
978
+ num_dec: { regex: /&#([0-9]{1,7});/g, val: (n, s) => Y(s, 10, "&#") },
979
+ num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (n, s) => Y(s, 16, "&#x") }
980
+ }, this.addExternalEntities = Be, this.parseXml = Ke, this.parseTextData = Ue, this.resolveNameSpace = ke, this.buildAttributesMap = Ye, this.isItStopNode = qe, this.replaceEntitiesValue = Je, this.readStopNodeData = He, this.saveTextToParentTag = Ze, this.addChild = ze, this.ignoreAttributesFn = Re(this.options.ignoreAttributes), this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
981
+ this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
982
+ for (let n = 0; n < this.options.stopNodes.length; n++) {
983
+ const s = this.options.stopNodes[n];
984
+ typeof s == "string" && (s.startsWith("*.") ? this.stopNodesWildcard.add(s.substring(2)) : this.stopNodesExact.add(s));
985
+ }
986
+ }
782
987
  }
783
988
  };
784
- function Fe(e) {
785
- const t = Object.keys(e);
786
- for (let n = 0; n < t.length; n++) {
787
- const o = t[n];
788
- this.lastEntities[o] = {
789
- regex: new RegExp("&" + o + ";", "g"),
790
- val: e[o]
989
+ function Be(t) {
990
+ const e = Object.keys(t);
991
+ for (let n = 0; n < e.length; n++) {
992
+ const s = e[n], r = s.replace(/[.\-+*:]/g, "\\.");
993
+ this.lastEntities[s] = {
994
+ regex: new RegExp("&" + r + ";", "g"),
995
+ val: t[s]
791
996
  };
792
997
  }
793
998
  }
794
- function Ve(e, t, n, o, i, r, l) {
795
- if (e !== void 0 && (this.options.trimValues && !o && (e = e.trim()), e.length > 0)) {
796
- l || (e = this.replaceEntitiesValue(e));
797
- const u = this.options.tagValueProcessor(t, e, n, i, r);
798
- return u == null ? e : typeof u != typeof e || u !== e ? u : this.options.trimValues ? O(e, this.options.parseTagValue, this.options.numberParseOptions) : e.trim() === e ? O(e, this.options.parseTagValue, this.options.numberParseOptions) : e;
999
+ function Ue(t, e, n, s, r, o, a) {
1000
+ if (t !== void 0 && (this.options.trimValues && !s && (t = t.trim()), t.length > 0)) {
1001
+ a || (t = this.replaceEntitiesValue(t, e, n));
1002
+ const c = this.options.tagValueProcessor(e, t, n, r, o);
1003
+ return c == null ? t : typeof c != typeof t || c !== t ? c : this.options.trimValues ? v(t, this.options.parseTagValue, this.options.numberParseOptions) : t.trim() === t ? v(t, this.options.parseTagValue, this.options.numberParseOptions) : t;
799
1004
  }
800
1005
  }
801
- function Xe(e) {
1006
+ function ke(t) {
802
1007
  if (this.options.removeNSPrefix) {
803
- const t = e.split(":"), n = e.charAt(0) === "/" ? "/" : "";
804
- if (t[0] === "xmlns")
1008
+ const e = t.split(":"), n = t.charAt(0) === "/" ? "/" : "";
1009
+ if (e[0] === "xmlns")
805
1010
  return "";
806
- t.length === 2 && (e = n + t[1]);
1011
+ e.length === 2 && (t = n + e[1]);
807
1012
  }
808
- return e;
1013
+ return t;
809
1014
  }
810
- const $e = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
811
- function Re(e, t, n) {
812
- if (this.options.ignoreAttributes !== !0 && typeof e == "string") {
813
- const o = G.getAllMatches(e, $e), i = o.length, r = {};
814
- for (let l = 0; l < i; l++) {
815
- const u = this.resolveNameSpace(o[l][1]);
816
- if (this.ignoreAttributesFn(u, t))
1015
+ const Ge = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1016
+ function Ye(t, e, n) {
1017
+ if (this.options.ignoreAttributes !== !0 && typeof t == "string") {
1018
+ const s = L.getAllMatches(t, Ge), r = s.length, o = {};
1019
+ for (let a = 0; a < r; a++) {
1020
+ const c = this.resolveNameSpace(s[a][1]);
1021
+ if (this.ignoreAttributesFn(c, e))
817
1022
  continue;
818
- let a = o[l][4], f = this.options.attributeNamePrefix + u;
819
- if (u.length)
820
- if (this.options.transformAttributeName && (f = this.options.transformAttributeName(f)), f === "__proto__" && (f = "#__proto__"), a !== void 0) {
821
- this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a);
822
- const c = this.options.attributeValueProcessor(u, a, t);
823
- c == null ? r[f] = a : typeof c != typeof a || c !== a ? r[f] = c : r[f] = O(
824
- a,
1023
+ let l = s[a][4], u = this.options.attributeNamePrefix + c;
1024
+ if (c.length)
1025
+ if (this.options.transformAttributeName && (u = this.options.transformAttributeName(u)), u = Qe(u, this.options), l !== void 0) {
1026
+ this.options.trimValues && (l = l.trim()), l = this.replaceEntitiesValue(l, n, e);
1027
+ const f = this.options.attributeValueProcessor(c, l, e);
1028
+ f == null ? o[u] = l : typeof f != typeof l || f !== l ? o[u] = f : o[u] = v(
1029
+ l,
825
1030
  this.options.parseAttributeValue,
826
1031
  this.options.numberParseOptions
827
1032
  );
828
- } else this.options.allowBooleanAttributes && (r[f] = !0);
1033
+ } else this.options.allowBooleanAttributes && (o[u] = !0);
829
1034
  }
830
- if (!Object.keys(r).length)
1035
+ if (!Object.keys(o).length)
831
1036
  return;
832
1037
  if (this.options.attributesGroupName) {
833
- const l = {};
834
- return l[this.options.attributesGroupName] = r, l;
1038
+ const a = {};
1039
+ return a[this.options.attributesGroupName] = o, a;
835
1040
  }
836
- return r;
1041
+ return o;
837
1042
  }
838
1043
  }
839
- const Be = function(e) {
840
- e = e.replace(/\r\n?/g, `
1044
+ const Ke = function(t) {
1045
+ t = t.replace(/\r\n?/g, `
841
1046
  `);
842
- const t = new E("!xml");
843
- let n = t, o = "", i = "";
844
- for (let r = 0; r < e.length; r++)
845
- if (e[r] === "<")
846
- if (e[r + 1] === "/") {
847
- const u = _(e, ">", r, "Closing Tag is not closed.");
848
- let a = e.substring(r + 2, u).trim();
1047
+ const e = new I("!xml");
1048
+ let n = e, s = "", r = "";
1049
+ this.entityExpansionCount = 0, this.currentExpandedLength = 0;
1050
+ const o = new Ve(this.options.processEntities);
1051
+ for (let a = 0; a < t.length; a++)
1052
+ if (t[a] === "<")
1053
+ if (t[a + 1] === "/") {
1054
+ const l = S(t, ">", a, "Closing Tag is not closed.");
1055
+ let u = t.substring(a + 2, l).trim();
849
1056
  if (this.options.removeNSPrefix) {
850
- const d = a.indexOf(":");
851
- d !== -1 && (a = a.substr(d + 1));
1057
+ const h = u.indexOf(":");
1058
+ h !== -1 && (u = u.substr(h + 1));
852
1059
  }
853
- this.options.transformTagName && (a = this.options.transformTagName(a)), n && (o = this.saveTextToParentTag(o, n, i));
854
- const f = i.substring(i.lastIndexOf(".") + 1);
855
- if (a && this.options.unpairedTags.indexOf(a) !== -1)
856
- throw new Error(`Unpaired tag can not be used as closing tag: </${a}>`);
857
- let c = 0;
858
- f && this.options.unpairedTags.indexOf(f) !== -1 ? (c = i.lastIndexOf(".", i.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : c = i.lastIndexOf("."), i = i.substring(0, c), n = this.tagsNodeStack.pop(), o = "", r = u;
859
- } else if (e[r + 1] === "?") {
860
- let u = T(e, r, !1, "?>");
861
- if (!u) throw new Error("Pi Tag is not closed.");
862
- if (o = this.saveTextToParentTag(o, n, i), !(this.options.ignoreDeclaration && u.tagName === "?xml" || this.options.ignorePiTags)) {
863
- const a = new E(u.tagName);
864
- a.add(this.options.textNodeName, ""), u.tagName !== u.tagExp && u.attrExpPresent && (a[":@"] = this.buildAttributesMap(u.tagExp, i, u.tagName)), this.addChild(n, a, i);
1060
+ this.options.transformTagName && (u = this.options.transformTagName(u)), n && (s = this.saveTextToParentTag(s, n, r));
1061
+ const f = r.substring(r.lastIndexOf(".") + 1);
1062
+ if (u && this.options.unpairedTags.indexOf(u) !== -1)
1063
+ throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);
1064
+ let d = 0;
1065
+ f && this.options.unpairedTags.indexOf(f) !== -1 ? (d = r.lastIndexOf(".", r.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : d = r.lastIndexOf("."), r = r.substring(0, d), n = this.tagsNodeStack.pop(), s = "", a = l;
1066
+ } else if (t[a + 1] === "?") {
1067
+ let l = j(t, a, !1, "?>");
1068
+ if (!l) throw new Error("Pi Tag is not closed.");
1069
+ if (s = this.saveTextToParentTag(s, n, r), !(this.options.ignoreDeclaration && l.tagName === "?xml" || this.options.ignorePiTags)) {
1070
+ const u = new I(l.tagName);
1071
+ u.add(this.options.textNodeName, ""), l.tagName !== l.tagExp && l.attrExpPresent && (u[":@"] = this.buildAttributesMap(l.tagExp, r, l.tagName)), this.addChild(n, u, r, a);
865
1072
  }
866
- r = u.closeIndex + 1;
867
- } else if (e.substr(r + 1, 3) === "!--") {
868
- const u = _(e, "-->", r + 4, "Comment is not closed.");
1073
+ a = l.closeIndex + 1;
1074
+ } else if (t.substr(a + 1, 3) === "!--") {
1075
+ const l = S(t, "-->", a + 4, "Comment is not closed.");
869
1076
  if (this.options.commentPropName) {
870
- const a = e.substring(r + 4, u - 2);
871
- o = this.saveTextToParentTag(o, n, i), n.add(this.options.commentPropName, [{ [this.options.textNodeName]: a }]);
1077
+ const u = t.substring(a + 4, l - 2);
1078
+ s = this.saveTextToParentTag(s, n, r), n.add(this.options.commentPropName, [{ [this.options.textNodeName]: u }]);
872
1079
  }
873
- r = u;
874
- } else if (e.substr(r + 1, 2) === "!D") {
875
- const u = Me(e, r);
876
- this.docTypeEntities = u.entities, r = u.i;
877
- } else if (e.substr(r + 1, 2) === "![") {
878
- const u = _(e, "]]>", r, "CDATA is not closed.") - 2, a = e.substring(r + 9, u);
879
- o = this.saveTextToParentTag(o, n, i);
880
- let f = this.parseTextData(a, n.tagname, i, !0, !1, !0, !0);
881
- f == null && (f = ""), this.options.cdataPropName ? n.add(this.options.cdataPropName, [{ [this.options.textNodeName]: a }]) : n.add(this.options.textNodeName, f), r = u + 2;
1080
+ a = l;
1081
+ } else if (t.substr(a + 1, 2) === "!D") {
1082
+ const l = o.readDocType(t, a);
1083
+ this.docTypeEntities = l.entities, a = l.i;
1084
+ } else if (t.substr(a + 1, 2) === "![") {
1085
+ const l = S(t, "]]>", a, "CDATA is not closed.") - 2, u = t.substring(a + 9, l);
1086
+ s = this.saveTextToParentTag(s, n, r);
1087
+ let f = this.parseTextData(u, n.tagname, r, !0, !1, !0, !0);
1088
+ f == null && (f = ""), this.options.cdataPropName ? n.add(this.options.cdataPropName, [{ [this.options.textNodeName]: u }]) : n.add(this.options.textNodeName, f), a = l + 2;
882
1089
  } else {
883
- let u = T(e, r, this.options.removeNSPrefix), a = u.tagName;
884
- const f = u.rawTagName;
885
- let c = u.tagExp, d = u.attrExpPresent, g = u.closeIndex;
886
- this.options.transformTagName && (a = this.options.transformTagName(a)), n && o && n.tagname !== "!xml" && (o = this.saveTextToParentTag(o, n, i, !1));
887
- const m = n;
888
- if (m && this.options.unpairedTags.indexOf(m.tagname) !== -1 && (n = this.tagsNodeStack.pop(), i = i.substring(0, i.lastIndexOf("."))), a !== t.tagname && (i += i ? "." + a : a), this.isItStopNode(this.options.stopNodes, i, a)) {
889
- let p = "";
890
- if (c.length > 0 && c.lastIndexOf("/") === c.length - 1)
891
- a[a.length - 1] === "/" ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), c = a) : c = c.substr(0, c.length - 1), r = u.closeIndex;
892
- else if (this.options.unpairedTags.indexOf(a) !== -1)
893
- r = u.closeIndex;
1090
+ let l = j(t, a, this.options.removeNSPrefix), u = l.tagName;
1091
+ const f = l.rawTagName;
1092
+ let d = l.tagExp, h = l.attrExpPresent, m = l.closeIndex;
1093
+ if (this.options.transformTagName) {
1094
+ const g = this.options.transformTagName(u);
1095
+ d === u && (d = g), u = g;
1096
+ }
1097
+ if (this.options.strictReservedNames && (u === this.options.commentPropName || u === this.options.cdataPropName || u === this.options.textNodeName || u === this.options.attributesGroupName))
1098
+ throw new Error(`Invalid tag name: ${u}`);
1099
+ n && s && n.tagname !== "!xml" && (s = this.saveTextToParentTag(s, n, r, !1));
1100
+ const b = n;
1101
+ b && this.options.unpairedTags.indexOf(b.tagname) !== -1 && (n = this.tagsNodeStack.pop(), r = r.substring(0, r.lastIndexOf("."))), u !== e.tagname && (r += r ? "." + u : u);
1102
+ const y = a;
1103
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, r, u)) {
1104
+ let g = "";
1105
+ if (d.length > 0 && d.lastIndexOf("/") === d.length - 1)
1106
+ u[u.length - 1] === "/" ? (u = u.substr(0, u.length - 1), r = r.substr(0, r.length - 1), d = u) : d = d.substr(0, d.length - 1), a = l.closeIndex;
1107
+ else if (this.options.unpairedTags.indexOf(u) !== -1)
1108
+ a = l.closeIndex;
894
1109
  else {
895
- const w = this.readStopNodeData(e, f, g + 1);
896
- if (!w) throw new Error(`Unexpected end of ${f}`);
897
- r = w.i, p = w.tagContent;
1110
+ const M = this.readStopNodeData(t, f, m + 1);
1111
+ if (!M) throw new Error(`Unexpected end of ${f}`);
1112
+ a = M.i, g = M.tagContent;
898
1113
  }
899
- const x = new E(a);
900
- a !== c && d && (x[":@"] = this.buildAttributesMap(c, i, a)), p && (p = this.parseTextData(p, a, i, !0, d, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), x.add(this.options.textNodeName, p), this.addChild(n, x, i);
1114
+ const T = new I(u);
1115
+ u !== d && h && (T[":@"] = this.buildAttributesMap(d, r, u)), g && (g = this.parseTextData(g, u, r, !0, h, !0, !0)), r = r.substr(0, r.lastIndexOf(".")), T.add(this.options.textNodeName, g), this.addChild(n, T, r, y);
901
1116
  } else {
902
- if (c.length > 0 && c.lastIndexOf("/") === c.length - 1) {
903
- a[a.length - 1] === "/" ? (a = a.substr(0, a.length - 1), i = i.substr(0, i.length - 1), c = a) : c = c.substr(0, c.length - 1), this.options.transformTagName && (a = this.options.transformTagName(a));
904
- const p = new E(a);
905
- a !== c && d && (p[":@"] = this.buildAttributesMap(c, i, a)), this.addChild(n, p, i), i = i.substr(0, i.lastIndexOf("."));
1117
+ if (d.length > 0 && d.lastIndexOf("/") === d.length - 1) {
1118
+ if (u[u.length - 1] === "/" ? (u = u.substr(0, u.length - 1), r = r.substr(0, r.length - 1), d = u) : d = d.substr(0, d.length - 1), this.options.transformTagName) {
1119
+ const T = this.options.transformTagName(u);
1120
+ d === u && (d = T), u = T;
1121
+ }
1122
+ const g = new I(u);
1123
+ u !== d && h && (g[":@"] = this.buildAttributesMap(d, r, u)), this.addChild(n, g, r, y), r = r.substr(0, r.lastIndexOf("."));
1124
+ } else if (this.options.unpairedTags.indexOf(u) !== -1) {
1125
+ const g = new I(u);
1126
+ u !== d && h && (g[":@"] = this.buildAttributesMap(d, r)), this.addChild(n, g, r, y), r = r.substr(0, r.lastIndexOf(".")), a = l.closeIndex;
1127
+ continue;
906
1128
  } else {
907
- const p = new E(a);
908
- this.tagsNodeStack.push(n), a !== c && d && (p[":@"] = this.buildAttributesMap(c, i, a)), this.addChild(n, p, i), n = p;
1129
+ const g = new I(u);
1130
+ if (this.tagsNodeStack.length > this.options.maxNestedTags)
1131
+ throw new Error("Maximum nested tags exceeded");
1132
+ this.tagsNodeStack.push(n), u !== d && h && (g[":@"] = this.buildAttributesMap(d, r, u)), this.addChild(n, g, r), n = g;
909
1133
  }
910
- o = "", r = g;
1134
+ s = "", a = m;
911
1135
  }
912
1136
  }
913
1137
  else
914
- o += e[r];
915
- return t.child;
1138
+ s += t[a];
1139
+ return e.child;
916
1140
  };
917
- function ke(e, t, n) {
918
- const o = this.options.updateTag(t.tagname, n, t[":@"]);
919
- o === !1 || (typeof o == "string" && (t.tagname = o), e.addChild(t));
1141
+ function ze(t, e, n, s) {
1142
+ this.options.captureMetaData || (s = void 0);
1143
+ const r = this.options.updateTag(e.tagname, n, e[":@"]);
1144
+ r === !1 || (typeof r == "string" && (e.tagname = r), t.addChild(e, s));
920
1145
  }
921
- const Ue = function(e) {
922
- if (this.options.processEntities) {
923
- for (let t in this.docTypeEntities) {
924
- const n = this.docTypeEntities[t];
925
- e = e.replace(n.regx, n.val);
926
- }
927
- for (let t in this.lastEntities) {
928
- const n = this.lastEntities[t];
929
- e = e.replace(n.regex, n.val);
1146
+ const Je = function(t, e, n) {
1147
+ if (t.indexOf("&") === -1)
1148
+ return t;
1149
+ const s = this.options.processEntities;
1150
+ if (!s.enabled || s.allowedTags && !s.allowedTags.includes(e) || s.tagFilter && !s.tagFilter(e, n))
1151
+ return t;
1152
+ for (let r in this.docTypeEntities) {
1153
+ const o = this.docTypeEntities[r], a = t.match(o.regx);
1154
+ if (a) {
1155
+ if (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions)
1156
+ throw new Error(
1157
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1158
+ );
1159
+ const c = t.length;
1160
+ if (t = t.replace(o.regx, o.val), s.maxExpandedLength && (this.currentExpandedLength += t.length - c, this.currentExpandedLength > s.maxExpandedLength))
1161
+ throw new Error(
1162
+ `Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`
1163
+ );
930
1164
  }
931
- if (this.options.htmlEntities)
932
- for (let t in this.htmlEntities) {
933
- const n = this.htmlEntities[t];
934
- e = e.replace(n.regex, n.val);
935
- }
936
- e = e.replace(this.ampEntity.regex, this.ampEntity.val);
937
1165
  }
938
- return e;
1166
+ if (t.indexOf("&") === -1) return t;
1167
+ for (const r of Object.keys(this.lastEntities)) {
1168
+ const o = this.lastEntities[r], a = t.match(o.regex);
1169
+ if (a && (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions))
1170
+ throw new Error(
1171
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1172
+ );
1173
+ t = t.replace(o.regex, o.val);
1174
+ }
1175
+ if (t.indexOf("&") === -1) return t;
1176
+ if (this.options.htmlEntities)
1177
+ for (const r of Object.keys(this.htmlEntities)) {
1178
+ const o = this.htmlEntities[r], a = t.match(o.regex);
1179
+ if (a && (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions))
1180
+ throw new Error(
1181
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1182
+ );
1183
+ t = t.replace(o.regex, o.val);
1184
+ }
1185
+ return t = t.replace(this.ampEntity.regex, this.ampEntity.val), t;
939
1186
  };
940
- function Ge(e, t, n, o) {
941
- return e && (o === void 0 && (o = Object.keys(t.child).length === 0), e = this.parseTextData(
942
- e,
943
- t.tagname,
1187
+ function Ze(t, e, n, s) {
1188
+ return t && (s === void 0 && (s = e.child.length === 0), t = this.parseTextData(
1189
+ t,
1190
+ e.tagname,
944
1191
  n,
945
1192
  !1,
946
- t[":@"] ? Object.keys(t[":@"]).length !== 0 : !1,
947
- o
948
- ), e !== void 0 && e !== "" && t.add(this.options.textNodeName, e), e = ""), e;
1193
+ e[":@"] ? Object.keys(e[":@"]).length !== 0 : !1,
1194
+ s
1195
+ ), t !== void 0 && t !== "" && e.add(this.options.textNodeName, t), t = ""), t;
949
1196
  }
950
- function Ke(e, t, n) {
951
- const o = "*." + n;
952
- for (const i in e) {
953
- const r = e[i];
954
- if (o === r || t === r) return !0;
955
- }
956
- return !1;
1197
+ function qe(t, e, n, s) {
1198
+ return !!(e && e.has(s) || t && t.has(n));
957
1199
  }
958
- function Je(e, t, n = ">") {
959
- let o, i = "";
960
- for (let r = t; r < e.length; r++) {
961
- let l = e[r];
962
- if (o)
963
- l === o && (o = "");
964
- else if (l === '"' || l === "'")
965
- o = l;
966
- else if (l === n[0])
1200
+ function We(t, e, n = ">") {
1201
+ let s, r = "";
1202
+ for (let o = e; o < t.length; o++) {
1203
+ let a = t[o];
1204
+ if (s)
1205
+ a === s && (s = "");
1206
+ else if (a === '"' || a === "'")
1207
+ s = a;
1208
+ else if (a === n[0])
967
1209
  if (n[1]) {
968
- if (e[r + 1] === n[1])
1210
+ if (t[o + 1] === n[1])
969
1211
  return {
970
- data: i,
971
- index: r
1212
+ data: r,
1213
+ index: o
972
1214
  };
973
1215
  } else
974
1216
  return {
975
- data: i,
976
- index: r
1217
+ data: r,
1218
+ index: o
977
1219
  };
978
- else l === " " && (l = " ");
979
- i += l;
1220
+ else a === " " && (a = " ");
1221
+ r += a;
980
1222
  }
981
1223
  }
982
- function _(e, t, n, o) {
983
- const i = e.indexOf(t, n);
984
- if (i === -1)
985
- throw new Error(o);
986
- return i + t.length - 1;
1224
+ function S(t, e, n, s) {
1225
+ const r = t.indexOf(e, n);
1226
+ if (r === -1)
1227
+ throw new Error(s);
1228
+ return r + e.length - 1;
987
1229
  }
988
- function T(e, t, n, o = ">") {
989
- const i = Je(e, t + 1, o);
990
- if (!i) return;
991
- let r = i.data;
992
- const l = i.index, u = r.search(/\s/);
993
- let a = r, f = !0;
994
- u !== -1 && (a = r.substring(0, u), r = r.substring(u + 1).trimStart());
995
- const c = a;
1230
+ function j(t, e, n, s = ">") {
1231
+ const r = We(t, e + 1, s);
1232
+ if (!r) return;
1233
+ let o = r.data;
1234
+ const a = r.index, c = o.search(/\s/);
1235
+ let l = o, u = !0;
1236
+ c !== -1 && (l = o.substring(0, c), o = o.substring(c + 1).trimStart());
1237
+ const f = l;
996
1238
  if (n) {
997
- const d = a.indexOf(":");
998
- d !== -1 && (a = a.substr(d + 1), f = a !== i.data.substr(d + 1));
1239
+ const d = l.indexOf(":");
1240
+ d !== -1 && (l = l.substr(d + 1), u = l !== r.data.substr(d + 1));
999
1241
  }
1000
1242
  return {
1001
- tagName: a,
1002
- tagExp: r,
1003
- closeIndex: l,
1004
- attrExpPresent: f,
1005
- rawTagName: c
1243
+ tagName: l,
1244
+ tagExp: o,
1245
+ closeIndex: a,
1246
+ attrExpPresent: u,
1247
+ rawTagName: f
1006
1248
  };
1007
1249
  }
1008
- function qe(e, t, n) {
1009
- const o = n;
1010
- let i = 1;
1011
- for (; n < e.length; n++)
1012
- if (e[n] === "<")
1013
- if (e[n + 1] === "/") {
1014
- const r = _(e, ">", n, `${t} is not closed`);
1015
- if (e.substring(n + 2, r).trim() === t && (i--, i === 0))
1250
+ function He(t, e, n) {
1251
+ const s = n;
1252
+ let r = 1;
1253
+ for (; n < t.length; n++)
1254
+ if (t[n] === "<")
1255
+ if (t[n + 1] === "/") {
1256
+ const o = S(t, ">", n, `${e} is not closed`);
1257
+ if (t.substring(n + 2, o).trim() === e && (r--, r === 0))
1016
1258
  return {
1017
- tagContent: e.substring(o, n),
1018
- i: r
1259
+ tagContent: t.substring(s, n),
1260
+ i: o
1019
1261
  };
1020
- n = r;
1021
- } else if (e[n + 1] === "?")
1022
- n = _(e, "?>", n + 1, "StopNode is not closed.");
1023
- else if (e.substr(n + 1, 3) === "!--")
1024
- n = _(e, "-->", n + 3, "StopNode is not closed.");
1025
- else if (e.substr(n + 1, 2) === "![")
1026
- n = _(e, "]]>", n, "StopNode is not closed.") - 2;
1262
+ n = o;
1263
+ } else if (t[n + 1] === "?")
1264
+ n = S(t, "?>", n + 1, "StopNode is not closed.");
1265
+ else if (t.substr(n + 1, 3) === "!--")
1266
+ n = S(t, "-->", n + 3, "StopNode is not closed.");
1267
+ else if (t.substr(n + 1, 2) === "![")
1268
+ n = S(t, "]]>", n, "StopNode is not closed.") - 2;
1027
1269
  else {
1028
- const r = T(e, n, ">");
1029
- r && ((r && r.tagName) === t && r.tagExp[r.tagExp.length - 1] !== "/" && i++, n = r.closeIndex);
1270
+ const o = j(t, n, ">");
1271
+ o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && r++, n = o.closeIndex);
1030
1272
  }
1031
1273
  }
1032
- function O(e, t, n) {
1033
- if (t && typeof e == "string") {
1034
- const o = e.trim();
1035
- return o === "true" ? !0 : o === "false" ? !1 : je(e, n);
1274
+ function v(t, e, n) {
1275
+ if (e && typeof t == "string") {
1276
+ const s = t.trim();
1277
+ return s === "true" ? !0 : s === "false" ? !1 : Fe(t, n);
1036
1278
  } else
1037
- return G.isExist(e) ? e : "";
1279
+ return L.isExist(t) ? t : "";
1038
1280
  }
1039
- var Ze = Pe, K = {};
1040
- function He(e, t) {
1041
- return J(e, t);
1281
+ function Y(t, e, n) {
1282
+ const s = Number.parseInt(t, e);
1283
+ return s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : n + t + ";";
1042
1284
  }
1043
- function J(e, t, n) {
1044
- let o;
1045
- const i = {};
1046
- for (let r = 0; r < e.length; r++) {
1047
- const l = e[r], u = Ye(l);
1048
- let a = "";
1049
- if (n === void 0 ? a = u : a = n + "." + u, u === t.textNodeName)
1050
- o === void 0 ? o = l[u] : o += "" + l[u];
1285
+ function Qe(t, e) {
1286
+ if (L.criticalProperties.includes(t))
1287
+ throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);
1288
+ return L.DANGEROUS_PROPERTY_NAMES.includes(t) ? e.onDangerousProperty(t) : t;
1289
+ }
1290
+ var De = Xe, te = {};
1291
+ function et(t, e) {
1292
+ return ne(t, e);
1293
+ }
1294
+ function ne(t, e, n) {
1295
+ let s;
1296
+ const r = {};
1297
+ for (let o = 0; o < t.length; o++) {
1298
+ const a = t[o], c = tt(a);
1299
+ let l = "";
1300
+ if (n === void 0 ? l = c : l = n + "." + c, c === e.textNodeName)
1301
+ s === void 0 ? s = a[c] : s += "" + a[c];
1051
1302
  else {
1052
- if (u === void 0)
1303
+ if (c === void 0)
1053
1304
  continue;
1054
- if (l[u]) {
1055
- let f = J(l[u], t, a);
1056
- const c = We(f, t);
1057
- l[":@"] ? Qe(f, l[":@"], a, t) : Object.keys(f).length === 1 && f[t.textNodeName] !== void 0 && !t.alwaysCreateTextNode ? f = f[t.textNodeName] : Object.keys(f).length === 0 && (t.alwaysCreateTextNode ? f[t.textNodeName] = "" : f = ""), i[u] !== void 0 && i.hasOwnProperty(u) ? (Array.isArray(i[u]) || (i[u] = [i[u]]), i[u].push(f)) : t.isArray(u, a, c) ? i[u] = [f] : i[u] = f;
1305
+ if (a[c]) {
1306
+ let u = ne(a[c], e, l);
1307
+ const f = st(u, e);
1308
+ a[":@"] ? nt(u, a[":@"], l, e) : Object.keys(u).length === 1 && u[e.textNodeName] !== void 0 && !e.alwaysCreateTextNode ? u = u[e.textNodeName] : Object.keys(u).length === 0 && (e.alwaysCreateTextNode ? u[e.textNodeName] = "" : u = ""), r[c] !== void 0 && r.hasOwnProperty(c) ? (Array.isArray(r[c]) || (r[c] = [r[c]]), r[c].push(u)) : e.isArray(c, l, f) ? r[c] = [u] : r[c] = u;
1058
1309
  }
1059
1310
  }
1060
1311
  }
1061
- return typeof o == "string" ? o.length > 0 && (i[t.textNodeName] = o) : o !== void 0 && (i[t.textNodeName] = o), i;
1312
+ return typeof s == "string" ? s.length > 0 && (r[e.textNodeName] = s) : s !== void 0 && (r[e.textNodeName] = s), r;
1062
1313
  }
1063
- function Ye(e) {
1064
- const t = Object.keys(e);
1065
- for (let n = 0; n < t.length; n++) {
1066
- const o = t[n];
1067
- if (o !== ":@") return o;
1314
+ function tt(t) {
1315
+ const e = Object.keys(t);
1316
+ for (let n = 0; n < e.length; n++) {
1317
+ const s = e[n];
1318
+ if (s !== ":@") return s;
1068
1319
  }
1069
1320
  }
1070
- function Qe(e, t, n, o) {
1071
- if (t) {
1072
- const i = Object.keys(t), r = i.length;
1073
- for (let l = 0; l < r; l++) {
1074
- const u = i[l];
1075
- o.isArray(u, n + "." + u, !0, !0) ? e[u] = [t[u]] : e[u] = t[u];
1321
+ function nt(t, e, n, s) {
1322
+ if (e) {
1323
+ const r = Object.keys(e), o = r.length;
1324
+ for (let a = 0; a < o; a++) {
1325
+ const c = r[a];
1326
+ s.isArray(c, n + "." + c, !0, !0) ? t[c] = [e[c]] : t[c] = e[c];
1076
1327
  }
1077
1328
  }
1078
1329
  }
1079
- function We(e, t) {
1080
- const { textNodeName: n } = t, o = Object.keys(e).length;
1081
- return !!(o === 0 || o === 1 && (e[n] || typeof e[n] == "boolean" || e[n] === 0));
1330
+ function st(t, e) {
1331
+ const { textNodeName: n } = e, s = Object.keys(t).length;
1332
+ return !!(s === 0 || s === 1 && (t[n] || typeof t[n] == "boolean" || t[n] === 0));
1082
1333
  }
1083
- K.prettify = He;
1084
- const { buildOptions: ze } = M, De = Ze, { prettify: et } = K, tt = C;
1085
- let nt = class {
1086
- constructor(t) {
1087
- this.externalEntities = {}, this.options = ze(t);
1334
+ te.prettify = et;
1335
+ const { buildOptions: rt } = F, it = De, { prettify: ot } = te, at = Z;
1336
+ let lt = class {
1337
+ constructor(e) {
1338
+ this.externalEntities = {}, this.options = rt(e);
1088
1339
  }
1089
1340
  /**
1090
1341
  * Parse XML dats to JS object
1091
1342
  * @param {string|Buffer} xmlData
1092
1343
  * @param {boolean|Object} validationOption
1093
1344
  */
1094
- parse(t, n) {
1095
- if (typeof t != "string") if (t.toString)
1096
- t = t.toString();
1345
+ parse(e, n) {
1346
+ if (typeof e != "string") if (e.toString)
1347
+ e = e.toString();
1097
1348
  else
1098
1349
  throw new Error("XML data is accepted in String or Bytes[] form.");
1099
1350
  if (n) {
1100
1351
  n === !0 && (n = {});
1101
- const r = tt.validate(t, n);
1102
- if (r !== !0)
1103
- throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`);
1352
+ const o = at.validate(e, n);
1353
+ if (o !== !0)
1354
+ throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
1104
1355
  }
1105
- const o = new De(this.options);
1106
- o.addExternalEntities(this.externalEntities);
1107
- const i = o.parseXml(t);
1108
- return this.options.preserveOrder || i === void 0 ? i : et(i, this.options);
1356
+ const s = new it(this.options);
1357
+ s.addExternalEntities(this.externalEntities);
1358
+ const r = s.parseXml(e);
1359
+ return this.options.preserveOrder || r === void 0 ? r : ot(r, this.options);
1109
1360
  }
1110
1361
  /**
1111
1362
  * Add Entity which is not by default supported by this library
1112
1363
  * @param {string} key
1113
1364
  * @param {string} value
1114
1365
  */
1115
- addEntity(t, n) {
1366
+ addEntity(e, n) {
1116
1367
  if (n.indexOf("&") !== -1)
1117
1368
  throw new Error("Entity value can't have '&'");
1118
- if (t.indexOf("&") !== -1 || t.indexOf(";") !== -1)
1369
+ if (e.indexOf("&") !== -1 || e.indexOf(";") !== -1)
1119
1370
  throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1120
1371
  if (n === "&")
1121
1372
  throw new Error("An entity with value '&' is not permitted");
1122
- this.externalEntities[t] = n;
1373
+ this.externalEntities[e] = n;
1123
1374
  }
1124
1375
  };
1125
- var st = nt;
1126
- const rt = `
1376
+ var ut = lt;
1377
+ const ct = `
1127
1378
  `;
1128
- function it(e, t) {
1379
+ function dt(t, e) {
1129
1380
  let n = "";
1130
- return t.format && t.indentBy.length > 0 && (n = rt), q(e, t, "", n);
1381
+ return e.format && e.indentBy.length > 0 && (n = ct), se(t, e, "", n);
1131
1382
  }
1132
- function q(e, t, n, o) {
1133
- let i = "", r = !1;
1134
- for (let l = 0; l < e.length; l++) {
1135
- const u = e[l], a = ot(u);
1136
- if (a === void 0) continue;
1137
- let f = "";
1138
- if (n.length === 0 ? f = a : f = `${n}.${a}`, a === t.textNodeName) {
1139
- let p = u[a];
1140
- at(f, t) || (p = t.tagValueProcessor(a, p), p = Z(p, t)), r && (i += o), i += p, r = !1;
1383
+ function se(t, e, n, s) {
1384
+ let r = "", o = !1;
1385
+ if (!Array.isArray(t)) {
1386
+ if (t != null) {
1387
+ let a = t.toString();
1388
+ return a = $(a, e), a;
1389
+ }
1390
+ return "";
1391
+ }
1392
+ for (let a = 0; a < t.length; a++) {
1393
+ const c = t[a], l = ft(c);
1394
+ if (l === void 0) continue;
1395
+ let u = "";
1396
+ if (n.length === 0 ? u = l : u = `${n}.${l}`, l === e.textNodeName) {
1397
+ let b = c[l];
1398
+ ht(u, e) || (b = e.tagValueProcessor(l, b), b = $(b, e)), o && (r += s), r += b, o = !1;
1141
1399
  continue;
1142
- } else if (a === t.cdataPropName) {
1143
- r && (i += o), i += `<![CDATA[${u[a][0][t.textNodeName]}]]>`, r = !1;
1400
+ } else if (l === e.cdataPropName) {
1401
+ o && (r += s), r += `<![CDATA[${c[l][0][e.textNodeName]}]]>`, o = !1;
1144
1402
  continue;
1145
- } else if (a === t.commentPropName) {
1146
- i += o + `<!--${u[a][0][t.textNodeName]}-->`, r = !0;
1403
+ } else if (l === e.commentPropName) {
1404
+ r += s + `<!--${c[l][0][e.textNodeName]}-->`, o = !0;
1147
1405
  continue;
1148
- } else if (a[0] === "?") {
1149
- const p = $(u[":@"], t), x = a === "?xml" ? "" : o;
1150
- let w = u[a][0][t.textNodeName];
1151
- w = w.length !== 0 ? " " + w : "", i += x + `<${a}${w}${p}?>`, r = !0;
1406
+ } else if (l[0] === "?") {
1407
+ const b = K(c[":@"], e), y = l === "?xml" ? "" : s;
1408
+ let g = c[l][0][e.textNodeName];
1409
+ g = g.length !== 0 ? " " + g : "", r += y + `<${l}${g}${b}?>`, o = !0;
1152
1410
  continue;
1153
1411
  }
1154
- let c = o;
1155
- c !== "" && (c += t.indentBy);
1156
- const d = $(u[":@"], t), g = o + `<${a}${d}`, m = q(u[a], t, f, c);
1157
- t.unpairedTags.indexOf(a) !== -1 ? t.suppressUnpairedNode ? i += g + ">" : i += g + "/>" : (!m || m.length === 0) && t.suppressEmptyNode ? i += g + "/>" : m && m.endsWith(">") ? i += g + `>${m}${o}</${a}>` : (i += g + ">", m && o !== "" && (m.includes("/>") || m.includes("</")) ? i += o + t.indentBy + m + o : i += m, i += `</${a}>`), r = !0;
1412
+ let f = s;
1413
+ f !== "" && (f += e.indentBy);
1414
+ const d = K(c[":@"], e), h = s + `<${l}${d}`, m = se(c[l], e, u, f);
1415
+ e.unpairedTags.indexOf(l) !== -1 ? e.suppressUnpairedNode ? r += h + ">" : r += h + "/>" : (!m || m.length === 0) && e.suppressEmptyNode ? r += h + "/>" : m && m.endsWith(">") ? r += h + `>${m}${s}</${l}>` : (r += h + ">", m && s !== "" && (m.includes("/>") || m.includes("</")) ? r += s + e.indentBy + m + s : r += m, r += `</${l}>`), o = !0;
1158
1416
  }
1159
- return i;
1417
+ return r;
1160
1418
  }
1161
- function ot(e) {
1162
- const t = Object.keys(e);
1163
- for (let n = 0; n < t.length; n++) {
1164
- const o = t[n];
1165
- if (e.hasOwnProperty(o) && o !== ":@")
1166
- return o;
1419
+ function ft(t) {
1420
+ const e = Object.keys(t);
1421
+ for (let n = 0; n < e.length; n++) {
1422
+ const s = e[n];
1423
+ if (Object.prototype.hasOwnProperty.call(t, s) && s !== ":@")
1424
+ return s;
1167
1425
  }
1168
1426
  }
1169
- function $(e, t) {
1427
+ function K(t, e) {
1170
1428
  let n = "";
1171
- if (e && !t.ignoreAttributes)
1172
- for (let o in e) {
1173
- if (!e.hasOwnProperty(o)) continue;
1174
- let i = t.attributeValueProcessor(o, e[o]);
1175
- i = Z(i, t), i === !0 && t.suppressBooleanAttributes ? n += ` ${o.substr(t.attributeNamePrefix.length)}` : n += ` ${o.substr(t.attributeNamePrefix.length)}="${i}"`;
1429
+ if (t && !e.ignoreAttributes)
1430
+ for (let s in t) {
1431
+ if (!Object.prototype.hasOwnProperty.call(t, s)) continue;
1432
+ let r = e.attributeValueProcessor(s, t[s]);
1433
+ r = $(r, e), r === !0 && e.suppressBooleanAttributes ? n += ` ${s.substr(e.attributeNamePrefix.length)}` : n += ` ${s.substr(e.attributeNamePrefix.length)}="${r}"`;
1176
1434
  }
1177
1435
  return n;
1178
1436
  }
1179
- function at(e, t) {
1180
- e = e.substr(0, e.length - t.textNodeName.length - 1);
1181
- let n = e.substr(e.lastIndexOf(".") + 1);
1182
- for (let o in t.stopNodes)
1183
- if (t.stopNodes[o] === e || t.stopNodes[o] === "*." + n) return !0;
1437
+ function ht(t, e) {
1438
+ t = t.substr(0, t.length - e.textNodeName.length - 1);
1439
+ let n = t.substr(t.lastIndexOf(".") + 1);
1440
+ for (let s in e.stopNodes)
1441
+ if (e.stopNodes[s] === t || e.stopNodes[s] === "*." + n) return !0;
1184
1442
  return !1;
1185
1443
  }
1186
- function Z(e, t) {
1187
- if (e && e.length > 0 && t.processEntities)
1188
- for (let n = 0; n < t.entities.length; n++) {
1189
- const o = t.entities[n];
1190
- e = e.replace(o.regex, o.val);
1444
+ function $(t, e) {
1445
+ if (t && t.length > 0 && e.processEntities)
1446
+ for (let n = 0; n < e.entities.length; n++) {
1447
+ const s = e.entities[n];
1448
+ t = t.replace(s.regex, s.val);
1191
1449
  }
1192
- return e;
1450
+ return t;
1193
1451
  }
1194
- var ut = it;
1195
- const lt = ut, ct = U, ft = {
1452
+ var gt = dt;
1453
+ const pt = gt, mt = ee, bt = {
1196
1454
  attributeNamePrefix: "@_",
1197
1455
  attributesGroupName: !1,
1198
1456
  textNodeName: "#text",
@@ -1203,11 +1461,11 @@ const lt = ut, ct = U, ft = {
1203
1461
  suppressEmptyNode: !1,
1204
1462
  suppressUnpairedNode: !0,
1205
1463
  suppressBooleanAttributes: !0,
1206
- tagValueProcessor: function(e, t) {
1207
- return t;
1464
+ tagValueProcessor: function(t, e) {
1465
+ return e;
1208
1466
  },
1209
- attributeValueProcessor: function(e, t) {
1210
- return t;
1467
+ attributeValueProcessor: function(t, e) {
1468
+ return e;
1211
1469
  },
1212
1470
  preserveOrder: !1,
1213
1471
  commentPropName: !1,
@@ -1226,303 +1484,301 @@ const lt = ut, ct = U, ft = {
1226
1484
  // transformAttributeName: false,
1227
1485
  oneListGroup: !1
1228
1486
  };
1229
- function y(e) {
1230
- this.options = Object.assign({}, ft, e), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
1487
+ function x(t) {
1488
+ this.options = Object.assign({}, bt, t), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
1231
1489
  return !1;
1232
- } : (this.ignoreAttributesFn = ct(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ht), this.processTextOrObjNode = dt, this.options.format ? (this.indentate = gt, this.tagEndChar = `>
1490
+ } : (this.ignoreAttributesFn = mt(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Et), this.processTextOrObjNode = Nt, this.options.format ? (this.indentate = wt, this.tagEndChar = `>
1233
1491
  `, this.newLine = `
1234
1492
  `) : (this.indentate = function() {
1235
1493
  return "";
1236
1494
  }, this.tagEndChar = ">", this.newLine = "");
1237
1495
  }
1238
- y.prototype.build = function(e) {
1239
- return this.options.preserveOrder ? lt(e, this.options) : (Array.isArray(e) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (e = {
1240
- [this.options.arrayNodeName]: e
1241
- }), this.j2x(e, 0, []).val);
1496
+ x.prototype.build = function(t) {
1497
+ return this.options.preserveOrder ? pt(t, this.options) : (Array.isArray(t) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t = {
1498
+ [this.options.arrayNodeName]: t
1499
+ }), this.j2x(t, 0, []).val);
1242
1500
  };
1243
- y.prototype.j2x = function(e, t, n) {
1244
- let o = "", i = "";
1245
- const r = n.join(".");
1246
- for (let l in e)
1247
- if (Object.prototype.hasOwnProperty.call(e, l))
1248
- if (typeof e[l] > "u")
1249
- this.isAttribute(l) && (i += "");
1250
- else if (e[l] === null)
1251
- this.isAttribute(l) ? i += "" : l[0] === "?" ? i += this.indentate(t) + "<" + l + "?" + this.tagEndChar : i += this.indentate(t) + "<" + l + "/" + this.tagEndChar;
1252
- else if (e[l] instanceof Date)
1253
- i += this.buildTextValNode(e[l], l, "", t);
1254
- else if (typeof e[l] != "object") {
1255
- const u = this.isAttribute(l);
1256
- if (u && !this.ignoreAttributesFn(u, r))
1257
- o += this.buildAttrPairStr(u, "" + e[l]);
1258
- else if (!u)
1259
- if (l === this.options.textNodeName) {
1260
- let a = this.options.tagValueProcessor(l, "" + e[l]);
1261
- i += this.replaceEntitiesValue(a);
1501
+ x.prototype.j2x = function(t, e, n) {
1502
+ let s = "", r = "";
1503
+ const o = n.join(".");
1504
+ for (let a in t)
1505
+ if (Object.prototype.hasOwnProperty.call(t, a))
1506
+ if (typeof t[a] > "u")
1507
+ this.isAttribute(a) && (r += "");
1508
+ else if (t[a] === null)
1509
+ this.isAttribute(a) || a === this.options.cdataPropName ? r += "" : a[0] === "?" ? r += this.indentate(e) + "<" + a + "?" + this.tagEndChar : r += this.indentate(e) + "<" + a + "/" + this.tagEndChar;
1510
+ else if (t[a] instanceof Date)
1511
+ r += this.buildTextValNode(t[a], a, "", e);
1512
+ else if (typeof t[a] != "object") {
1513
+ const c = this.isAttribute(a);
1514
+ if (c && !this.ignoreAttributesFn(c, o))
1515
+ s += this.buildAttrPairStr(c, "" + t[a]);
1516
+ else if (!c)
1517
+ if (a === this.options.textNodeName) {
1518
+ let l = this.options.tagValueProcessor(a, "" + t[a]);
1519
+ r += this.replaceEntitiesValue(l);
1262
1520
  } else
1263
- i += this.buildTextValNode(e[l], l, "", t);
1264
- } else if (Array.isArray(e[l])) {
1265
- const u = e[l].length;
1266
- let a = "", f = "";
1267
- for (let c = 0; c < u; c++) {
1268
- const d = e[l][c];
1521
+ r += this.buildTextValNode(t[a], a, "", e);
1522
+ } else if (Array.isArray(t[a])) {
1523
+ const c = t[a].length;
1524
+ let l = "", u = "";
1525
+ for (let f = 0; f < c; f++) {
1526
+ const d = t[a][f];
1269
1527
  if (!(typeof d > "u")) if (d === null)
1270
- l[0] === "?" ? i += this.indentate(t) + "<" + l + "?" + this.tagEndChar : i += this.indentate(t) + "<" + l + "/" + this.tagEndChar;
1528
+ a[0] === "?" ? r += this.indentate(e) + "<" + a + "?" + this.tagEndChar : r += this.indentate(e) + "<" + a + "/" + this.tagEndChar;
1271
1529
  else if (typeof d == "object")
1272
1530
  if (this.options.oneListGroup) {
1273
- const g = this.j2x(d, t + 1, n.concat(l));
1274
- a += g.val, this.options.attributesGroupName && d.hasOwnProperty(this.options.attributesGroupName) && (f += g.attrStr);
1531
+ const h = this.j2x(d, e + 1, n.concat(a));
1532
+ l += h.val, this.options.attributesGroupName && d.hasOwnProperty(this.options.attributesGroupName) && (u += h.attrStr);
1275
1533
  } else
1276
- a += this.processTextOrObjNode(d, l, t, n);
1534
+ l += this.processTextOrObjNode(d, a, e, n);
1277
1535
  else if (this.options.oneListGroup) {
1278
- let g = this.options.tagValueProcessor(l, d);
1279
- g = this.replaceEntitiesValue(g), a += g;
1536
+ let h = this.options.tagValueProcessor(a, d);
1537
+ h = this.replaceEntitiesValue(h), l += h;
1280
1538
  } else
1281
- a += this.buildTextValNode(d, l, "", t);
1539
+ l += this.buildTextValNode(d, a, "", e);
1282
1540
  }
1283
- this.options.oneListGroup && (a = this.buildObjectNode(a, l, f, t)), i += a;
1284
- } else if (this.options.attributesGroupName && l === this.options.attributesGroupName) {
1285
- const u = Object.keys(e[l]), a = u.length;
1286
- for (let f = 0; f < a; f++)
1287
- o += this.buildAttrPairStr(u[f], "" + e[l][u[f]]);
1541
+ this.options.oneListGroup && (l = this.buildObjectNode(l, a, u, e)), r += l;
1542
+ } else if (this.options.attributesGroupName && a === this.options.attributesGroupName) {
1543
+ const c = Object.keys(t[a]), l = c.length;
1544
+ for (let u = 0; u < l; u++)
1545
+ s += this.buildAttrPairStr(c[u], "" + t[a][c[u]]);
1288
1546
  } else
1289
- i += this.processTextOrObjNode(e[l], l, t, n);
1290
- return { attrStr: o, val: i };
1547
+ r += this.processTextOrObjNode(t[a], a, e, n);
1548
+ return { attrStr: s, val: r };
1291
1549
  };
1292
- y.prototype.buildAttrPairStr = function(e, t) {
1293
- return t = this.options.attributeValueProcessor(e, "" + t), t = this.replaceEntitiesValue(t), this.options.suppressBooleanAttributes && t === "true" ? " " + e : " " + e + '="' + t + '"';
1550
+ x.prototype.buildAttrPairStr = function(t, e) {
1551
+ return e = this.options.attributeValueProcessor(t, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + t : " " + t + '="' + e + '"';
1294
1552
  };
1295
- function dt(e, t, n, o) {
1296
- const i = this.j2x(e, n + 1, o.concat(t));
1297
- return e[this.options.textNodeName] !== void 0 && Object.keys(e).length === 1 ? this.buildTextValNode(e[this.options.textNodeName], t, i.attrStr, n) : this.buildObjectNode(i.val, t, i.attrStr, n);
1553
+ function Nt(t, e, n, s) {
1554
+ const r = this.j2x(t, n + 1, s.concat(e));
1555
+ return t[this.options.textNodeName] !== void 0 && Object.keys(t).length === 1 ? this.buildTextValNode(t[this.options.textNodeName], e, r.attrStr, n) : this.buildObjectNode(r.val, e, r.attrStr, n);
1298
1556
  }
1299
- y.prototype.buildObjectNode = function(e, t, n, o) {
1300
- if (e === "")
1301
- return t[0] === "?" ? this.indentate(o) + "<" + t + n + "?" + this.tagEndChar : this.indentate(o) + "<" + t + n + this.closeTag(t) + this.tagEndChar;
1557
+ x.prototype.buildObjectNode = function(t, e, n, s) {
1558
+ if (t === "")
1559
+ return e[0] === "?" ? this.indentate(s) + "<" + e + n + "?" + this.tagEndChar : this.indentate(s) + "<" + e + n + this.closeTag(e) + this.tagEndChar;
1302
1560
  {
1303
- let i = "</" + t + this.tagEndChar, r = "";
1304
- return t[0] === "?" && (r = "?", i = ""), (n || n === "") && e.indexOf("<") === -1 ? this.indentate(o) + "<" + t + n + r + ">" + e + i : this.options.commentPropName !== !1 && t === this.options.commentPropName && r.length === 0 ? this.indentate(o) + `<!--${e}-->` + this.newLine : this.indentate(o) + "<" + t + n + r + this.tagEndChar + e + this.indentate(o) + i;
1561
+ let r = "</" + e + this.tagEndChar, o = "";
1562
+ return e[0] === "?" && (o = "?", r = ""), (n || n === "") && t.indexOf("<") === -1 ? this.indentate(s) + "<" + e + n + o + ">" + t + r : this.options.commentPropName !== !1 && e === this.options.commentPropName && o.length === 0 ? this.indentate(s) + `<!--${t}-->` + this.newLine : this.indentate(s) + "<" + e + n + o + this.tagEndChar + t + this.indentate(s) + r;
1305
1563
  }
1306
1564
  };
1307
- y.prototype.closeTag = function(e) {
1308
- let t = "";
1309
- return this.options.unpairedTags.indexOf(e) !== -1 ? this.options.suppressUnpairedNode || (t = "/") : this.options.suppressEmptyNode ? t = "/" : t = `></${e}`, t;
1565
+ x.prototype.closeTag = function(t) {
1566
+ let e = "";
1567
+ return this.options.unpairedTags.indexOf(t) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${t}`, e;
1310
1568
  };
1311
- y.prototype.buildTextValNode = function(e, t, n, o) {
1312
- if (this.options.cdataPropName !== !1 && t === this.options.cdataPropName)
1313
- return this.indentate(o) + `<![CDATA[${e}]]>` + this.newLine;
1314
- if (this.options.commentPropName !== !1 && t === this.options.commentPropName)
1315
- return this.indentate(o) + `<!--${e}-->` + this.newLine;
1316
- if (t[0] === "?")
1317
- return this.indentate(o) + "<" + t + n + "?" + this.tagEndChar;
1569
+ x.prototype.buildTextValNode = function(t, e, n, s) {
1570
+ if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
1571
+ return this.indentate(s) + `<![CDATA[${t}]]>` + this.newLine;
1572
+ if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
1573
+ return this.indentate(s) + `<!--${t}-->` + this.newLine;
1574
+ if (e[0] === "?")
1575
+ return this.indentate(s) + "<" + e + n + "?" + this.tagEndChar;
1318
1576
  {
1319
- let i = this.options.tagValueProcessor(t, e);
1320
- return i = this.replaceEntitiesValue(i), i === "" ? this.indentate(o) + "<" + t + n + this.closeTag(t) + this.tagEndChar : this.indentate(o) + "<" + t + n + ">" + i + "</" + t + this.tagEndChar;
1577
+ let r = this.options.tagValueProcessor(e, t);
1578
+ return r = this.replaceEntitiesValue(r), r === "" ? this.indentate(s) + "<" + e + n + this.closeTag(e) + this.tagEndChar : this.indentate(s) + "<" + e + n + ">" + r + "</" + e + this.tagEndChar;
1321
1579
  }
1322
1580
  };
1323
- y.prototype.replaceEntitiesValue = function(e) {
1324
- if (e && e.length > 0 && this.options.processEntities)
1325
- for (let t = 0; t < this.options.entities.length; t++) {
1326
- const n = this.options.entities[t];
1327
- e = e.replace(n.regex, n.val);
1581
+ x.prototype.replaceEntitiesValue = function(t) {
1582
+ if (t && t.length > 0 && this.options.processEntities)
1583
+ for (let e = 0; e < this.options.entities.length; e++) {
1584
+ const n = this.options.entities[e];
1585
+ t = t.replace(n.regex, n.val);
1328
1586
  }
1329
- return e;
1587
+ return t;
1330
1588
  };
1331
- function gt(e) {
1332
- return this.options.indentBy.repeat(e);
1589
+ function wt(t) {
1590
+ return this.options.indentBy.repeat(t);
1333
1591
  }
1334
- function ht(e) {
1335
- return e.startsWith(this.options.attributeNamePrefix) && e !== this.options.textNodeName ? e.substr(this.attrPrefixLen) : !1;
1592
+ function Et(t) {
1593
+ return t.startsWith(this.options.attributeNamePrefix) && t !== this.options.textNodeName ? t.substr(this.attrPrefixLen) : !1;
1336
1594
  }
1337
- var pt = y;
1338
- const mt = C, bt = st, Nt = pt;
1339
- var j = {
1340
- XMLParser: bt,
1341
- XMLValidator: mt,
1342
- XMLBuilder: Nt
1595
+ var yt = x;
1596
+ const xt = ut, At = yt;
1597
+ var R = {
1598
+ XMLParser: xt,
1599
+ XMLBuilder: At
1343
1600
  };
1344
- class H {
1345
- constructor(t, n) {
1601
+ class re {
1602
+ constructor(e, n) {
1346
1603
  A(this, "alphabet");
1347
1604
  A(this, "padding");
1348
1605
  A(this, "decodeMap", /* @__PURE__ */ new Map());
1349
- if (t.length !== 32)
1606
+ if (e.length !== 32)
1350
1607
  throw new Error("Invalid alphabet");
1351
- if (this.alphabet = t, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1608
+ if (this.alphabet = e, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1352
1609
  throw new Error("Invalid padding");
1353
- for (let o = 0; o < t.length; o++)
1354
- this.decodeMap.set(t[o], o);
1610
+ for (let s = 0; s < e.length; s++)
1611
+ this.decodeMap.set(e[s], s);
1355
1612
  }
1356
- encode(t, n) {
1357
- let o = "", i = 0, r = 0;
1358
- for (let u = 0; u < t.length; u++)
1359
- for (i = i << 8 | t[u], r += 8; r >= 5; )
1360
- r -= 5, o += this.alphabet[i >> r & 31];
1361
- if (r > 0 && (o += this.alphabet[i << 5 - r & 31]), (n == null ? void 0 : n.includePadding) ?? !0) {
1362
- const u = (8 - o.length % 8) % 8;
1363
- for (let a = 0; a < u; a++)
1364
- o += "=";
1613
+ encode(e, n) {
1614
+ let s = "", r = 0, o = 0;
1615
+ for (let c = 0; c < e.length; c++)
1616
+ for (r = r << 8 | e[c], o += 8; o >= 5; )
1617
+ o -= 5, s += this.alphabet[r >> o & 31];
1618
+ if (o > 0 && (s += this.alphabet[r << 5 - o & 31]), (n == null ? void 0 : n.includePadding) ?? !0) {
1619
+ const c = (8 - s.length % 8) % 8;
1620
+ for (let l = 0; l < c; l++)
1621
+ s += "=";
1365
1622
  }
1366
- return o;
1623
+ return s;
1367
1624
  }
1368
- decode(t, n) {
1369
- const o = (n == null ? void 0 : n.strict) ?? !0, i = Math.ceil(t.length / 8), r = [];
1370
- for (let l = 0; l < i; l++) {
1371
- let u = 0;
1372
- const a = [];
1373
- for (let c = 0; c < 8; c++) {
1374
- const d = t[l * 8 + c];
1625
+ decode(e, n) {
1626
+ const s = (n == null ? void 0 : n.strict) ?? !0, r = Math.ceil(e.length / 8), o = [];
1627
+ for (let a = 0; a < r; a++) {
1628
+ let c = 0;
1629
+ const l = [];
1630
+ for (let f = 0; f < 8; f++) {
1631
+ const d = e[a * 8 + f];
1375
1632
  if (d === "=") {
1376
- if (l + 1 !== i)
1633
+ if (a + 1 !== r)
1377
1634
  throw new Error(`Invalid character: ${d}`);
1378
- u += 1;
1635
+ c += 1;
1379
1636
  continue;
1380
1637
  }
1381
1638
  if (d === void 0) {
1382
- if (o)
1639
+ if (s)
1383
1640
  throw new Error("Invalid data");
1384
- u += 1;
1641
+ c += 1;
1385
1642
  continue;
1386
1643
  }
1387
- const g = this.decodeMap.get(d) ?? null;
1388
- if (g === null)
1644
+ const h = this.decodeMap.get(d) ?? null;
1645
+ if (h === null)
1389
1646
  throw new Error(`Invalid character: ${d}`);
1390
- a.push(g);
1647
+ l.push(h);
1391
1648
  }
1392
- if (u === 8 || u === 7 || u === 5 || u === 2)
1649
+ if (c === 8 || c === 7 || c === 5 || c === 2)
1393
1650
  throw new Error("Invalid padding");
1394
- const f = (a[0] << 3) + (a[1] >> 2);
1395
- if (r.push(f), u < 6) {
1396
- const c = ((a[1] & 3) << 6) + (a[2] << 1) + (a[3] >> 4);
1397
- r.push(c);
1651
+ const u = (l[0] << 3) + (l[1] >> 2);
1652
+ if (o.push(u), c < 6) {
1653
+ const f = ((l[1] & 3) << 6) + (l[2] << 1) + (l[3] >> 4);
1654
+ o.push(f);
1398
1655
  }
1399
- if (u < 4) {
1400
- const c = ((a[3] & 255) << 4) + (a[4] >> 1);
1401
- r.push(c);
1656
+ if (c < 4) {
1657
+ const f = ((l[3] & 255) << 4) + (l[4] >> 1);
1658
+ o.push(f);
1402
1659
  }
1403
- if (u < 3) {
1404
- const c = ((a[4] & 1) << 7) + (a[5] << 2) + (a[6] >> 3);
1405
- r.push(c);
1660
+ if (c < 3) {
1661
+ const f = ((l[4] & 1) << 7) + (l[5] << 2) + (l[6] >> 3);
1662
+ o.push(f);
1406
1663
  }
1407
- if (u < 1) {
1408
- const c = ((a[6] & 7) << 5) + a[7];
1409
- r.push(c);
1664
+ if (c < 1) {
1665
+ const f = ((l[6] & 7) << 5) + l[7];
1666
+ o.push(f);
1410
1667
  }
1411
1668
  }
1412
- return Uint8Array.from(r);
1669
+ return Uint8Array.from(o);
1413
1670
  }
1414
1671
  }
1415
- new H("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
1416
- new H("0123456789ABCDEFGHIJKLMNOPQRSTUV");
1417
- class Y {
1418
- constructor(t, n) {
1672
+ new re("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
1673
+ new re("0123456789ABCDEFGHIJKLMNOPQRSTUV");
1674
+ class ie {
1675
+ constructor(e, n) {
1419
1676
  A(this, "alphabet");
1420
1677
  A(this, "padding");
1421
1678
  A(this, "decodeMap", /* @__PURE__ */ new Map());
1422
- if (t.length !== 64)
1679
+ if (e.length !== 64)
1423
1680
  throw new Error("Invalid alphabet");
1424
- if (this.alphabet = t, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1681
+ if (this.alphabet = e, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1425
1682
  throw new Error("Invalid padding");
1426
- for (let o = 0; o < t.length; o++)
1427
- this.decodeMap.set(t[o], o);
1683
+ for (let s = 0; s < e.length; s++)
1684
+ this.decodeMap.set(e[s], s);
1428
1685
  }
1429
- encode(t, n) {
1430
- let o = "", i = 0, r = 0;
1431
- for (let u = 0; u < t.length; u++)
1432
- for (i = i << 8 | t[u], r += 8; r >= 6; )
1433
- r += -6, o += this.alphabet[i >> r & 63];
1434
- if (r > 0 && (o += this.alphabet[i << 6 - r & 63]), (n == null ? void 0 : n.includePadding) ?? !0) {
1435
- const u = (4 - o.length % 4) % 4;
1436
- for (let a = 0; a < u; a++)
1437
- o += "=";
1686
+ encode(e, n) {
1687
+ let s = "", r = 0, o = 0;
1688
+ for (let c = 0; c < e.length; c++)
1689
+ for (r = r << 8 | e[c], o += 8; o >= 6; )
1690
+ o += -6, s += this.alphabet[r >> o & 63];
1691
+ if (o > 0 && (s += this.alphabet[r << 6 - o & 63]), (n == null ? void 0 : n.includePadding) ?? !0) {
1692
+ const c = (4 - s.length % 4) % 4;
1693
+ for (let l = 0; l < c; l++)
1694
+ s += "=";
1438
1695
  }
1439
- return o;
1696
+ return s;
1440
1697
  }
1441
- decode(t, n) {
1442
- const o = (n == null ? void 0 : n.strict) ?? !0, i = Math.ceil(t.length / 4), r = [];
1443
- for (let l = 0; l < i; l++) {
1444
- let u = 0, a = 0;
1445
- for (let f = 0; f < 4; f++) {
1446
- const c = t[l * 4 + f];
1447
- if (c === "=") {
1448
- if (l + 1 !== i)
1449
- throw new Error(`Invalid character: ${c}`);
1450
- u += 1;
1698
+ decode(e, n) {
1699
+ const s = (n == null ? void 0 : n.strict) ?? !0, r = Math.ceil(e.length / 4), o = [];
1700
+ for (let a = 0; a < r; a++) {
1701
+ let c = 0, l = 0;
1702
+ for (let u = 0; u < 4; u++) {
1703
+ const f = e[a * 4 + u];
1704
+ if (f === "=") {
1705
+ if (a + 1 !== r)
1706
+ throw new Error(`Invalid character: ${f}`);
1707
+ c += 1;
1451
1708
  continue;
1452
1709
  }
1453
- if (c === void 0) {
1454
- if (o)
1710
+ if (f === void 0) {
1711
+ if (s)
1455
1712
  throw new Error("Invalid data");
1456
- u += 1;
1713
+ c += 1;
1457
1714
  continue;
1458
1715
  }
1459
- const d = this.decodeMap.get(c) ?? null;
1716
+ const d = this.decodeMap.get(f) ?? null;
1460
1717
  if (d === null)
1461
- throw new Error(`Invalid character: ${c}`);
1462
- a += d << 6 * (3 - f);
1718
+ throw new Error(`Invalid character: ${f}`);
1719
+ l += d << 6 * (3 - u);
1463
1720
  }
1464
- r.push(a >> 16 & 255), u < 2 && r.push(a >> 8 & 255), u < 1 && r.push(a & 255);
1721
+ o.push(l >> 16 & 255), c < 2 && o.push(l >> 8 & 255), c < 1 && o.push(l & 255);
1465
1722
  }
1466
- return Uint8Array.from(r);
1723
+ return Uint8Array.from(o);
1467
1724
  }
1468
1725
  }
1469
- const wt = new Y("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
1470
- new Y("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
1471
- const yt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1472
- let R = (e = 21) => {
1473
- let t = "", n = crypto.getRandomValues(new Uint8Array(e));
1474
- for (; e--; )
1475
- t += yt[n[e] & 63];
1476
- return t;
1726
+ const _t = new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
1727
+ new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
1728
+ let St = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", z = (t = 21) => {
1729
+ let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
1730
+ for (; t--; )
1731
+ e += St[n[t] & 63];
1732
+ return e;
1477
1733
  };
1478
- async function At(e) {
1479
- const t = new DecompressionStream("deflate-raw"), n = new Uint8Array(e), o = new Blob([n]).stream().pipeThrough(t);
1480
- return new Uint8Array(await new Response(o).arrayBuffer());
1734
+ async function Tt(t) {
1735
+ const e = new DecompressionStream("deflate-raw"), n = new Uint8Array(t), s = new Blob([n]).stream().pipeThrough(e);
1736
+ return new Uint8Array(await new Response(s).arrayBuffer());
1481
1737
  }
1482
- async function _t(e) {
1483
- const t = await wt.decode(e.replace(/ /g, "+"));
1738
+ async function It(t) {
1739
+ const e = await _t.decode(t.replace(/ /g, "+"));
1484
1740
  try {
1485
- const n = await At(t);
1741
+ const n = await Tt(e);
1486
1742
  return new TextDecoder().decode(n);
1487
1743
  } catch (n) {
1488
1744
  return console.warn(
1489
1745
  "Decompression failed, assuming data is not compressed:",
1490
1746
  n
1491
- ), new TextDecoder().decode(t);
1747
+ ), new TextDecoder().decode(e);
1492
1748
  }
1493
1749
  }
1494
- async function Mt(e) {
1495
- const t = await _t(e), o = new j.XMLParser({
1750
+ async function Ft(t) {
1751
+ const e = await It(t), s = new R.XMLParser({
1496
1752
  attributeNamePrefix: "@_",
1497
1753
  alwaysCreateTextNode: !0,
1498
1754
  ignoreAttributes: !1
1499
- }).parse(t);
1500
- return D.parse(o);
1755
+ }).parse(e);
1756
+ return ue.parse(s);
1501
1757
  }
1502
- function jt(e) {
1503
- const t = e.certificates.map((i) => ({
1758
+ function Rt(t) {
1759
+ const e = t.certificates.map((r) => ({
1504
1760
  "@_use": "signing",
1505
1761
  KeyInfo: {
1506
1762
  "@_xmlns": "http://www.w3.org/2000/09/xmldsig#",
1507
1763
  X509Data: {
1508
- X509Certificate: i
1764
+ X509Certificate: r
1509
1765
  }
1510
1766
  }
1511
1767
  })), n = {
1512
1768
  EntityDescriptor: {
1513
- "@_entityID": e.entityId,
1769
+ "@_entityID": t.entityId,
1514
1770
  "@_xmlns": "urn:oasis:names:tc:SAML:2.0:metadata",
1515
1771
  IDPSSODescriptor: {
1516
1772
  "@_protocolSupportEnumeration": "urn:oasis:names:tc:SAML:2.0:protocol",
1517
- KeyDescriptor: t,
1773
+ KeyDescriptor: e,
1518
1774
  SingleLogoutService: [
1519
1775
  {
1520
1776
  "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1521
- "@_Location": e.singleLogoutServiceUrl
1777
+ "@_Location": t.singleLogoutServiceUrl
1522
1778
  },
1523
1779
  {
1524
1780
  "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1525
- "@_Location": e.singleLogoutServiceUrl
1781
+ "@_Location": t.singleLogoutServiceUrl
1526
1782
  }
1527
1783
  ],
1528
1784
  NameIDFormat: [
@@ -1533,11 +1789,11 @@ function jt(e) {
1533
1789
  SingleSignOnService: [
1534
1790
  {
1535
1791
  "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1536
- "@_Location": e.assertionConsumerServiceUrl
1792
+ "@_Location": t.assertionConsumerServiceUrl
1537
1793
  },
1538
1794
  {
1539
1795
  "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1540
- "@_Location": e.assertionConsumerServiceUrl
1796
+ "@_Location": t.assertionConsumerServiceUrl
1541
1797
  }
1542
1798
  ],
1543
1799
  Attribute: [
@@ -1575,7 +1831,7 @@ function jt(e) {
1575
1831
  }
1576
1832
  }
1577
1833
  };
1578
- return new j.XMLBuilder({
1834
+ return new R.XMLBuilder({
1579
1835
  ignoreAttributes: !1,
1580
1836
  suppressEmptyNode: !0,
1581
1837
  preserveOrder: !1,
@@ -1583,12 +1839,12 @@ function jt(e) {
1583
1839
  attributeNamePrefix: "@_"
1584
1840
  }).build(n);
1585
1841
  }
1586
- async function vt(e, t) {
1587
- const n = e.notBefore || (/* @__PURE__ */ new Date()).toISOString(), o = e.notAfter || new Date(new Date(n).getTime() + 10 * 60 * 1e3).toISOString(), i = e.issueInstant || n, r = e.sessionNotOnOrAfter || o, l = e.responseId || `_${R()}`, u = e.assertionId || `_${R()}`, a = [
1842
+ async function Xt(t, e) {
1843
+ const n = t.notBefore || (/* @__PURE__ */ new Date()).toISOString(), s = t.notAfter || new Date(new Date(n).getTime() + 10 * 60 * 1e3).toISOString(), r = t.issueInstant || n, o = t.sessionNotOnOrAfter || s, a = t.responseId || `_${z()}`, c = t.assertionId || `_${z()}`, l = [
1588
1844
  {
1589
1845
  "samlp:Response": [
1590
1846
  {
1591
- "saml:Issuer": [{ "#text": e.issuer }]
1847
+ "saml:Issuer": [{ "#text": t.issuer }]
1592
1848
  },
1593
1849
  {
1594
1850
  "samlp:Status": [
@@ -1603,14 +1859,14 @@ async function vt(e, t) {
1603
1859
  {
1604
1860
  "saml:Issuer": [
1605
1861
  {
1606
- "#text": e.issuer
1862
+ "#text": t.issuer
1607
1863
  }
1608
1864
  ]
1609
1865
  },
1610
1866
  {
1611
1867
  "saml:Subject": [
1612
1868
  {
1613
- "saml:NameID": [{ "#text": e.email }],
1869
+ "saml:NameID": [{ "#text": t.email }],
1614
1870
  ":@": {
1615
1871
  "@_Format": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
1616
1872
  }
@@ -1620,9 +1876,9 @@ async function vt(e, t) {
1620
1876
  {
1621
1877
  "saml:SubjectConfirmationData": [],
1622
1878
  ":@": {
1623
- "@_InResponseTo": e.inResponseTo,
1624
- "@_NotOnOrAfter": o,
1625
- "@_Recipient": e.destination
1879
+ "@_InResponseTo": t.inResponseTo,
1880
+ "@_NotOnOrAfter": s,
1881
+ "@_Recipient": t.destination
1626
1882
  }
1627
1883
  }
1628
1884
  ],
@@ -1637,7 +1893,7 @@ async function vt(e, t) {
1637
1893
  {
1638
1894
  "saml:Audience": [
1639
1895
  {
1640
- "#text": e.audience
1896
+ "#text": t.audience
1641
1897
  }
1642
1898
  ]
1643
1899
  }
@@ -1646,7 +1902,7 @@ async function vt(e, t) {
1646
1902
  ],
1647
1903
  ":@": {
1648
1904
  "@_NotBefore": n,
1649
- "@_NotOnOrAfter": o
1905
+ "@_NotOnOrAfter": s
1650
1906
  }
1651
1907
  },
1652
1908
  {
@@ -1664,9 +1920,9 @@ async function vt(e, t) {
1664
1920
  }
1665
1921
  ],
1666
1922
  ":@": {
1667
- "@_AuthnInstant": i,
1668
- "@_SessionIndex": e.sessionIndex,
1669
- "@_SessionNotOnOrAfter": r
1923
+ "@_AuthnInstant": r,
1924
+ "@_SessionIndex": t.sessionIndex,
1925
+ "@_SessionNotOnOrAfter": o
1670
1926
  }
1671
1927
  },
1672
1928
  {
@@ -1676,7 +1932,7 @@ async function vt(e, t) {
1676
1932
  {
1677
1933
  "saml:AttributeValue": [
1678
1934
  {
1679
- "#text": e.userId
1935
+ "#text": t.userId
1680
1936
  }
1681
1937
  ],
1682
1938
  ":@": {
@@ -1697,7 +1953,7 @@ async function vt(e, t) {
1697
1953
  {
1698
1954
  "saml:AttributeValue": [
1699
1955
  {
1700
- "#text": e.email
1956
+ "#text": t.email
1701
1957
  }
1702
1958
  ],
1703
1959
  ":@": {
@@ -1837,8 +2093,8 @@ async function vt(e, t) {
1837
2093
  ],
1838
2094
  ":@": {
1839
2095
  "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion",
1840
- "@_ID": u,
1841
- "@_IssueInstant": i,
2096
+ "@_ID": c,
2097
+ "@_IssueInstant": r,
1842
2098
  "@_Version": "2.0"
1843
2099
  }
1844
2100
  }
@@ -1846,46 +2102,46 @@ async function vt(e, t) {
1846
2102
  ":@": {
1847
2103
  "@_xmlns:samlp": "urn:oasis:names:tc:SAML:2.0:protocol",
1848
2104
  "@_xmlns:saml": "urn:oasis:names:tc:SAML:2.0:assertion",
1849
- "@_Destination": e.destination,
1850
- "@_ID": l,
1851
- "@_InResponseTo": e.inResponseTo,
1852
- "@_IssueInstant": i,
2105
+ "@_Destination": t.destination,
2106
+ "@_ID": a,
2107
+ "@_InResponseTo": t.inResponseTo,
2108
+ "@_IssueInstant": r,
1853
2109
  "@_Version": "2.0"
1854
2110
  }
1855
2111
  }
1856
2112
  ];
1857
- let c = new j.XMLBuilder({
2113
+ let f = new R.XMLBuilder({
1858
2114
  ignoreAttributes: !1,
1859
2115
  suppressEmptyNode: !0,
1860
2116
  preserveOrder: !0
1861
- }).build(a);
1862
- return e.signature && t && (c = await t.signSAML(
1863
- c,
1864
- e.signature.privateKeyPem,
1865
- e.signature.cert
1866
- )), e.encode === !1 ? c : btoa(c);
2117
+ }).build(l);
2118
+ return t.signature && e && (f = await e.signSAML(
2119
+ f,
2120
+ t.signature.privateKeyPem,
2121
+ t.signature.cert
2122
+ )), t.encode === !1 ? f : btoa(f);
1867
2123
  }
1868
- const xt = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", St = "http://www.w3.org/2001/04/xmlenc#sha256", B = "http://www.w3.org/2001/10/xml-exc-c14n#";
1869
- class Pt {
1870
- async signSAML(t, n, o) {
1871
- var i;
2124
+ const Ct = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", Ot = "http://www.w3.org/2001/04/xmlenc#sha256", J = "http://www.w3.org/2001/10/xml-exc-c14n#";
2125
+ class Bt {
2126
+ async signSAML(e, n, s) {
2127
+ var r;
1872
2128
  try {
1873
- const r = await import("xml-crypto"), l = r.SignedXml || ((i = r.default) == null ? void 0 : i.SignedXml);
1874
- if (!l)
2129
+ const o = await import("xml-crypto"), a = o.SignedXml || ((r = o.default) == null ? void 0 : r.SignedXml);
2130
+ if (!a)
1875
2131
  throw new Error("SignedXml not found in xml-crypto module");
1876
- const u = new l({ privateKey: n, publicCert: o });
1877
- u.canonicalizationAlgorithm = B, u.addReference({
2132
+ const c = new a({ privateKey: n, publicCert: s });
2133
+ c.canonicalizationAlgorithm = J, c.addReference({
1878
2134
  xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
1879
- digestAlgorithm: St,
2135
+ digestAlgorithm: Ot,
1880
2136
  transforms: [
1881
2137
  "http://www.w3.org/2000/09/xmldsig#enveloped-signature",
1882
- B
2138
+ J
1883
2139
  ]
1884
- }), u.signatureAlgorithm = xt;
1885
- const a = o.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
1886
- return u.keyInfoProvider = {
1887
- getKeyInfo: () => `<X509Data><X509Certificate>${a}</X509Certificate></X509Data>`
1888
- }, u.computeSignature(t, {
2140
+ }), c.signatureAlgorithm = Ct;
2141
+ const l = s.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
2142
+ return c.keyInfoProvider = {
2143
+ getKeyInfo: () => `<X509Data><X509Certificate>${l}</X509Certificate></X509Data>`
2144
+ }, c.computeSignature(e, {
1889
2145
  // according to:
1890
2146
  // https://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd
1891
2147
  // Assertion's ds:Signature must be after Assertion/Issuer
@@ -1893,48 +2149,48 @@ class Pt {
1893
2149
  reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
1894
2150
  action: "after"
1895
2151
  }
1896
- }), u.getSignedXml();
1897
- } catch (r) {
2152
+ }), c.getSignedXml();
2153
+ } catch (o) {
1898
2154
  throw new Error(
1899
- `Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${r}`
2155
+ `Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${o}`
1900
2156
  );
1901
2157
  }
1902
2158
  }
1903
2159
  }
1904
- class Ft {
1905
- constructor(t) {
1906
- this.signUrl = t;
2160
+ class Ut {
2161
+ constructor(e) {
2162
+ this.signUrl = e;
1907
2163
  }
1908
- async signSAML(t, n, o) {
1909
- const i = await fetch(this.signUrl, {
2164
+ async signSAML(e, n, s) {
2165
+ const r = await fetch(this.signUrl, {
1910
2166
  method: "POST",
1911
2167
  headers: {
1912
2168
  "Content-Type": "application/json"
1913
2169
  },
1914
2170
  body: JSON.stringify({
1915
- xmlContent: t,
2171
+ xmlContent: e,
1916
2172
  privateKey: n,
1917
- publicCert: o
2173
+ publicCert: s
1918
2174
  })
1919
2175
  });
1920
- if (!i.ok)
2176
+ if (!r.ok)
1921
2177
  throw new Error(
1922
- `Failed to sign SAML via HTTP: ${i.status} ${i.statusText}`
2178
+ `Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`
1923
2179
  );
1924
- return await i.text();
2180
+ return await r.text();
1925
2181
  }
1926
2182
  }
1927
2183
  export {
1928
- Ft as HttpSamlSigner,
1929
- Pt as LocalSamlSigner,
1930
- jt as createSamlMetadata,
1931
- vt as createSamlResponse,
1932
- v as dsSignatureSchema,
1933
- _t as inflateDecompress,
1934
- At as inflateRaw,
1935
- Mt as parseSamlRequestQuery,
1936
- z as samlIssuerSchema,
1937
- Tt as samlMetadataResponseSchema,
1938
- D as samlRequestSchema,
1939
- Ot as samlResponseJsonSchema
2184
+ Ut as HttpSamlSigner,
2185
+ Bt as LocalSamlSigner,
2186
+ Rt as createSamlMetadata,
2187
+ Xt as createSamlResponse,
2188
+ X as dsSignatureSchema,
2189
+ It as inflateDecompress,
2190
+ Tt as inflateRaw,
2191
+ Ft as parseSamlRequestQuery,
2192
+ le as samlIssuerSchema,
2193
+ Mt as samlMetadataResponseSchema,
2194
+ ue as samlRequestSchema,
2195
+ jt as samlResponseJsonSchema
1940
2196
  };