ipx 3.1.1 → 4.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,836 @@
1
+ import { __commonJSMin as e, __require as t } from "../rolldown-runtime.mjs";
2
+ var n = e(((e) => {
3
+ (function(e) {
4
+ e.parser = function(e, t) {
5
+ return new r(e, t);
6
+ }, e.SAXParser = r, e.SAXStream = d, e.createStream = l, e.MAX_BUFFER_LENGTH = 64 * 1024;
7
+ var n = [
8
+ `comment`,
9
+ `sgmlDecl`,
10
+ `textNode`,
11
+ `tagName`,
12
+ `doctype`,
13
+ `procInstName`,
14
+ `procInstBody`,
15
+ `entity`,
16
+ `attribName`,
17
+ `attribValue`,
18
+ `cdata`,
19
+ `script`
20
+ ];
21
+ e.EVENTS = [
22
+ `text`,
23
+ `processinginstruction`,
24
+ `sgmldeclaration`,
25
+ `doctype`,
26
+ `comment`,
27
+ `opentagstart`,
28
+ `attribute`,
29
+ `opentag`,
30
+ `closetag`,
31
+ `opencdata`,
32
+ `cdata`,
33
+ `closecdata`,
34
+ `error`,
35
+ `end`,
36
+ `ready`,
37
+ `script`,
38
+ `opennamespace`,
39
+ `closenamespace`
40
+ ];
41
+ function r(t, n) {
42
+ if (!(this instanceof r)) return new r(t, n);
43
+ var i = this;
44
+ a(i), i.q = i.c = ``, i.bufferCheckPosition = e.MAX_BUFFER_LENGTH, i.encoding = null, i.opt = n || {}, i.opt.lowercase = i.opt.lowercase || i.opt.lowercasetags, i.looseCase = i.opt.lowercase ? `toLowerCase` : `toUpperCase`, i.opt.maxEntityCount = i.opt.maxEntityCount || 512, i.opt.maxEntityDepth = i.opt.maxEntityDepth || 4, i.entityCount = i.entityDepth = 0, i.tags = [], i.closed = i.closedRoot = i.sawRoot = !1, i.tag = i.error = null, i.strict = !!t, i.noscript = !!(t || i.opt.noscript), i.state = E.BEGIN, i.strictEntities = i.opt.strictEntities, i.ENTITIES = i.strictEntities ? Object.create(e.XML_ENTITIES) : Object.create(e.ENTITIES), i.attribList = [], i.opt.xmlns && (i.ns = Object.create(g)), i.opt.unquotedAttributeValues === void 0 && (i.opt.unquotedAttributeValues = !t), i.trackPosition = i.opt.position !== !1, i.trackPosition && (i.position = i.line = i.column = 0), O(i, `onready`);
45
+ }
46
+ Object.create || (Object.create = function(e) {
47
+ function t() {}
48
+ return t.prototype = e, new t();
49
+ }), Object.keys || (Object.keys = function(e) {
50
+ var t = [];
51
+ for (var n in e) e.hasOwnProperty(n) && t.push(n);
52
+ return t;
53
+ });
54
+ function i(t) {
55
+ for (var r = Math.max(e.MAX_BUFFER_LENGTH, 10), i = 0, a = 0, o = n.length; a < o; a++) {
56
+ var s = t[n[a]].length;
57
+ if (s > r) switch (n[a]) {
58
+ case `textNode`:
59
+ P(t);
60
+ break;
61
+ case `cdata`:
62
+ N(t, `oncdata`, t.cdata), t.cdata = ``;
63
+ break;
64
+ case `script`:
65
+ N(t, `onscript`, t.script), t.script = ``;
66
+ break;
67
+ default: I(t, `Max buffer length exceeded: ` + n[a]);
68
+ }
69
+ i = Math.max(i, s);
70
+ }
71
+ t.bufferCheckPosition = e.MAX_BUFFER_LENGTH - i + t.position;
72
+ }
73
+ function a(e) {
74
+ for (var t = 0, r = n.length; t < r; t++) e[n[t]] = ``;
75
+ }
76
+ function o(e) {
77
+ P(e), e.cdata !== `` && (N(e, `oncdata`, e.cdata), e.cdata = ``), e.script !== `` && (N(e, `onscript`, e.script), e.script = ``);
78
+ }
79
+ r.prototype = {
80
+ end: function() {
81
+ L(this);
82
+ },
83
+ write: q,
84
+ resume: function() {
85
+ return this.error = null, this;
86
+ },
87
+ close: function() {
88
+ return this.write(null);
89
+ },
90
+ flush: function() {
91
+ o(this);
92
+ }
93
+ };
94
+ var s;
95
+ try {
96
+ s = t(`stream`).Stream;
97
+ } catch {
98
+ s = function() {};
99
+ }
100
+ s ||= function() {};
101
+ var c = e.EVENTS.filter(function(e) {
102
+ return e !== `error` && e !== `end`;
103
+ });
104
+ function l(e, t) {
105
+ return new d(e, t);
106
+ }
107
+ function u(e, t) {
108
+ if (e.length >= 2) {
109
+ if (e[0] === 255 && e[1] === 254) return `utf-16le`;
110
+ if (e[0] === 254 && e[1] === 255) return `utf-16be`;
111
+ }
112
+ return e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191 ? `utf8` : e.length >= 4 ? e[0] === 60 && e[1] === 0 && e[2] === 63 && e[3] === 0 ? `utf-16le` : e[0] === 0 && e[1] === 60 && e[2] === 0 && e[3] === 63 ? `utf-16be` : `utf8` : t ? `utf8` : null;
113
+ }
114
+ function d(e, t) {
115
+ if (!(this instanceof d)) return new d(e, t);
116
+ s.apply(this), this._parser = new r(e, t), this.writable = !0, this.readable = !0;
117
+ var n = this;
118
+ this._parser.onend = function() {
119
+ n.emit(`end`);
120
+ }, this._parser.onerror = function(e) {
121
+ n.emit(`error`, e), n._parser.error = null;
122
+ }, this._decoder = null, this._decoderBuffer = null, c.forEach(function(e) {
123
+ Object.defineProperty(n, `on` + e, {
124
+ get: function() {
125
+ return n._parser[`on` + e];
126
+ },
127
+ set: function(t) {
128
+ if (!t) return n.removeAllListeners(e), n._parser[`on` + e] = t, t;
129
+ n.on(e, t);
130
+ },
131
+ enumerable: !0,
132
+ configurable: !1
133
+ });
134
+ });
135
+ }
136
+ d.prototype = Object.create(s.prototype, { constructor: { value: d } }), d.prototype._decodeBuffer = function(e, t) {
137
+ if (this._decoderBuffer &&= (e = Buffer.concat([this._decoderBuffer, e]), null), !this._decoder) {
138
+ var n = u(e, t);
139
+ if (!n) return this._decoderBuffer = e, ``;
140
+ this._parser.encoding = n, this._decoder = new TextDecoder(n);
141
+ }
142
+ return this._decoder.decode(e, { stream: !t });
143
+ }, d.prototype.write = function(e) {
144
+ if (typeof Buffer == `function` && typeof Buffer.isBuffer == `function` && Buffer.isBuffer(e)) e = this._decodeBuffer(e, !1);
145
+ else if (this._decoderBuffer) {
146
+ var t = this._decodeBuffer(Buffer.alloc(0), !0);
147
+ t && (this._parser.write(t), this.emit(`data`, t));
148
+ }
149
+ return this._parser.write(e.toString()), this.emit(`data`, e), !0;
150
+ }, d.prototype.end = function(e) {
151
+ if (e && e.length && this.write(e), this._decoderBuffer) {
152
+ var t = this._decodeBuffer(Buffer.alloc(0), !0);
153
+ t && (this._parser.write(t), this.emit(`data`, t));
154
+ } else if (this._decoder) {
155
+ var n = this._decoder.decode();
156
+ n && (this._parser.write(n), this.emit(`data`, n));
157
+ }
158
+ return this._parser.end(), !0;
159
+ }, d.prototype.on = function(e, t) {
160
+ var n = this;
161
+ return !n._parser[`on` + e] && c.indexOf(e) !== -1 && (n._parser[`on` + e] = function() {
162
+ var t = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
163
+ t.splice(0, 0, e), n.emit.apply(n, t);
164
+ }), s.prototype.on.call(n, e, t);
165
+ };
166
+ var f = `[CDATA[`, p = `DOCTYPE`, m = `http://www.w3.org/XML/1998/namespace`, h = `http://www.w3.org/2000/xmlns/`, g = {
167
+ xml: m,
168
+ xmlns: h
169
+ }, _ = /[:_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]/, v = /[:_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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/, y = /[#:_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]/, b = /[#:_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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
170
+ function x(e) {
171
+ return e === ` ` || e === `
172
+ ` || e === `\r` || e === ` `;
173
+ }
174
+ function S(e) {
175
+ return e === `"` || e === `'`;
176
+ }
177
+ function C(e) {
178
+ return e === `>` || x(e);
179
+ }
180
+ function w(e, t) {
181
+ return e.test(t);
182
+ }
183
+ function T(e, t) {
184
+ return !w(e, t);
185
+ }
186
+ var E = 0;
187
+ for (var D in e.STATE = {
188
+ BEGIN: E++,
189
+ BEGIN_WHITESPACE: E++,
190
+ TEXT: E++,
191
+ TEXT_ENTITY: E++,
192
+ OPEN_WAKA: E++,
193
+ SGML_DECL: E++,
194
+ SGML_DECL_QUOTED: E++,
195
+ DOCTYPE: E++,
196
+ DOCTYPE_QUOTED: E++,
197
+ DOCTYPE_DTD: E++,
198
+ DOCTYPE_DTD_QUOTED: E++,
199
+ COMMENT_STARTING: E++,
200
+ COMMENT: E++,
201
+ COMMENT_ENDING: E++,
202
+ COMMENT_ENDED: E++,
203
+ CDATA: E++,
204
+ CDATA_ENDING: E++,
205
+ CDATA_ENDING_2: E++,
206
+ PROC_INST: E++,
207
+ PROC_INST_BODY: E++,
208
+ PROC_INST_ENDING: E++,
209
+ OPEN_TAG: E++,
210
+ OPEN_TAG_SLASH: E++,
211
+ ATTRIB: E++,
212
+ ATTRIB_NAME: E++,
213
+ ATTRIB_NAME_SAW_WHITE: E++,
214
+ ATTRIB_VALUE: E++,
215
+ ATTRIB_VALUE_QUOTED: E++,
216
+ ATTRIB_VALUE_CLOSED: E++,
217
+ ATTRIB_VALUE_UNQUOTED: E++,
218
+ ATTRIB_VALUE_ENTITY_Q: E++,
219
+ ATTRIB_VALUE_ENTITY_U: E++,
220
+ CLOSE_TAG: E++,
221
+ CLOSE_TAG_SAW_WHITE: E++,
222
+ SCRIPT: E++,
223
+ SCRIPT_ENDING: E++
224
+ }, e.XML_ENTITIES = {
225
+ amp: `&`,
226
+ gt: `>`,
227
+ lt: `<`,
228
+ quot: `"`,
229
+ apos: `'`
230
+ }, e.ENTITIES = {
231
+ amp: `&`,
232
+ gt: `>`,
233
+ lt: `<`,
234
+ quot: `"`,
235
+ apos: `'`,
236
+ AElig: 198,
237
+ Aacute: 193,
238
+ Acirc: 194,
239
+ Agrave: 192,
240
+ Aring: 197,
241
+ Atilde: 195,
242
+ Auml: 196,
243
+ Ccedil: 199,
244
+ ETH: 208,
245
+ Eacute: 201,
246
+ Ecirc: 202,
247
+ Egrave: 200,
248
+ Euml: 203,
249
+ Iacute: 205,
250
+ Icirc: 206,
251
+ Igrave: 204,
252
+ Iuml: 207,
253
+ Ntilde: 209,
254
+ Oacute: 211,
255
+ Ocirc: 212,
256
+ Ograve: 210,
257
+ Oslash: 216,
258
+ Otilde: 213,
259
+ Ouml: 214,
260
+ THORN: 222,
261
+ Uacute: 218,
262
+ Ucirc: 219,
263
+ Ugrave: 217,
264
+ Uuml: 220,
265
+ Yacute: 221,
266
+ aacute: 225,
267
+ acirc: 226,
268
+ aelig: 230,
269
+ agrave: 224,
270
+ aring: 229,
271
+ atilde: 227,
272
+ auml: 228,
273
+ ccedil: 231,
274
+ eacute: 233,
275
+ ecirc: 234,
276
+ egrave: 232,
277
+ eth: 240,
278
+ euml: 235,
279
+ iacute: 237,
280
+ icirc: 238,
281
+ igrave: 236,
282
+ iuml: 239,
283
+ ntilde: 241,
284
+ oacute: 243,
285
+ ocirc: 244,
286
+ ograve: 242,
287
+ oslash: 248,
288
+ otilde: 245,
289
+ ouml: 246,
290
+ szlig: 223,
291
+ thorn: 254,
292
+ uacute: 250,
293
+ ucirc: 251,
294
+ ugrave: 249,
295
+ uuml: 252,
296
+ yacute: 253,
297
+ yuml: 255,
298
+ copy: 169,
299
+ reg: 174,
300
+ nbsp: 160,
301
+ iexcl: 161,
302
+ cent: 162,
303
+ pound: 163,
304
+ curren: 164,
305
+ yen: 165,
306
+ brvbar: 166,
307
+ sect: 167,
308
+ uml: 168,
309
+ ordf: 170,
310
+ laquo: 171,
311
+ not: 172,
312
+ shy: 173,
313
+ macr: 175,
314
+ deg: 176,
315
+ plusmn: 177,
316
+ sup1: 185,
317
+ sup2: 178,
318
+ sup3: 179,
319
+ acute: 180,
320
+ micro: 181,
321
+ para: 182,
322
+ middot: 183,
323
+ cedil: 184,
324
+ ordm: 186,
325
+ raquo: 187,
326
+ frac14: 188,
327
+ frac12: 189,
328
+ frac34: 190,
329
+ iquest: 191,
330
+ times: 215,
331
+ divide: 247,
332
+ OElig: 338,
333
+ oelig: 339,
334
+ Scaron: 352,
335
+ scaron: 353,
336
+ Yuml: 376,
337
+ fnof: 402,
338
+ circ: 710,
339
+ tilde: 732,
340
+ Alpha: 913,
341
+ Beta: 914,
342
+ Gamma: 915,
343
+ Delta: 916,
344
+ Epsilon: 917,
345
+ Zeta: 918,
346
+ Eta: 919,
347
+ Theta: 920,
348
+ Iota: 921,
349
+ Kappa: 922,
350
+ Lambda: 923,
351
+ Mu: 924,
352
+ Nu: 925,
353
+ Xi: 926,
354
+ Omicron: 927,
355
+ Pi: 928,
356
+ Rho: 929,
357
+ Sigma: 931,
358
+ Tau: 932,
359
+ Upsilon: 933,
360
+ Phi: 934,
361
+ Chi: 935,
362
+ Psi: 936,
363
+ Omega: 937,
364
+ alpha: 945,
365
+ beta: 946,
366
+ gamma: 947,
367
+ delta: 948,
368
+ epsilon: 949,
369
+ zeta: 950,
370
+ eta: 951,
371
+ theta: 952,
372
+ iota: 953,
373
+ kappa: 954,
374
+ lambda: 955,
375
+ mu: 956,
376
+ nu: 957,
377
+ xi: 958,
378
+ omicron: 959,
379
+ pi: 960,
380
+ rho: 961,
381
+ sigmaf: 962,
382
+ sigma: 963,
383
+ tau: 964,
384
+ upsilon: 965,
385
+ phi: 966,
386
+ chi: 967,
387
+ psi: 968,
388
+ omega: 969,
389
+ thetasym: 977,
390
+ upsih: 978,
391
+ piv: 982,
392
+ ensp: 8194,
393
+ emsp: 8195,
394
+ thinsp: 8201,
395
+ zwnj: 8204,
396
+ zwj: 8205,
397
+ lrm: 8206,
398
+ rlm: 8207,
399
+ ndash: 8211,
400
+ mdash: 8212,
401
+ lsquo: 8216,
402
+ rsquo: 8217,
403
+ sbquo: 8218,
404
+ ldquo: 8220,
405
+ rdquo: 8221,
406
+ bdquo: 8222,
407
+ dagger: 8224,
408
+ Dagger: 8225,
409
+ bull: 8226,
410
+ hellip: 8230,
411
+ permil: 8240,
412
+ prime: 8242,
413
+ Prime: 8243,
414
+ lsaquo: 8249,
415
+ rsaquo: 8250,
416
+ oline: 8254,
417
+ frasl: 8260,
418
+ euro: 8364,
419
+ image: 8465,
420
+ weierp: 8472,
421
+ real: 8476,
422
+ trade: 8482,
423
+ alefsym: 8501,
424
+ larr: 8592,
425
+ uarr: 8593,
426
+ rarr: 8594,
427
+ darr: 8595,
428
+ harr: 8596,
429
+ crarr: 8629,
430
+ lArr: 8656,
431
+ uArr: 8657,
432
+ rArr: 8658,
433
+ dArr: 8659,
434
+ hArr: 8660,
435
+ forall: 8704,
436
+ part: 8706,
437
+ exist: 8707,
438
+ empty: 8709,
439
+ nabla: 8711,
440
+ isin: 8712,
441
+ notin: 8713,
442
+ ni: 8715,
443
+ prod: 8719,
444
+ sum: 8721,
445
+ minus: 8722,
446
+ lowast: 8727,
447
+ radic: 8730,
448
+ prop: 8733,
449
+ infin: 8734,
450
+ ang: 8736,
451
+ and: 8743,
452
+ or: 8744,
453
+ cap: 8745,
454
+ cup: 8746,
455
+ int: 8747,
456
+ there4: 8756,
457
+ sim: 8764,
458
+ cong: 8773,
459
+ asymp: 8776,
460
+ ne: 8800,
461
+ equiv: 8801,
462
+ le: 8804,
463
+ ge: 8805,
464
+ sub: 8834,
465
+ sup: 8835,
466
+ nsub: 8836,
467
+ sube: 8838,
468
+ supe: 8839,
469
+ oplus: 8853,
470
+ otimes: 8855,
471
+ perp: 8869,
472
+ sdot: 8901,
473
+ lceil: 8968,
474
+ rceil: 8969,
475
+ lfloor: 8970,
476
+ rfloor: 8971,
477
+ lang: 9001,
478
+ rang: 9002,
479
+ loz: 9674,
480
+ spades: 9824,
481
+ clubs: 9827,
482
+ hearts: 9829,
483
+ diams: 9830
484
+ }, Object.keys(e.ENTITIES).forEach(function(t) {
485
+ var n = e.ENTITIES[t], r = typeof n == `number` ? String.fromCharCode(n) : n;
486
+ e.ENTITIES[t] = r;
487
+ }), e.STATE) e.STATE[e.STATE[D]] = D;
488
+ E = e.STATE;
489
+ function O(e, t, n) {
490
+ e[t] && e[t](n);
491
+ }
492
+ function k(e) {
493
+ var t = e && e.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);
494
+ return t ? t[2] : null;
495
+ }
496
+ function A(e) {
497
+ return e ? e.toLowerCase().replace(/[^a-z0-9]/g, ``) : null;
498
+ }
499
+ function j(e, t) {
500
+ let n = A(e), r = A(t);
501
+ return !n || !r ? !0 : r === `utf16` ? n === `utf16le` || n === `utf16be` : n === r;
502
+ }
503
+ function M(e, t) {
504
+ if (!(!e.strict || !e.encoding || !t || t.name !== `xml`)) {
505
+ var n = k(t.body);
506
+ n && !j(e.encoding, n) && R(e, `XML declaration encoding ` + n + ` does not match detected stream encoding ` + e.encoding.toUpperCase());
507
+ }
508
+ }
509
+ function N(e, t, n) {
510
+ e.textNode && P(e), O(e, t, n);
511
+ }
512
+ function P(e) {
513
+ e.textNode = F(e.opt, e.textNode), e.textNode && O(e, `ontext`, e.textNode), e.textNode = ``;
514
+ }
515
+ function F(e, t) {
516
+ return e.trim && (t = t.trim()), e.normalize && (t = t.replace(/\s+/g, ` `)), t;
517
+ }
518
+ function I(e, t) {
519
+ return P(e), e.trackPosition && (t += `
520
+ Line: ` + e.line + `
521
+ Column: ` + e.column + `
522
+ Char: ` + e.c), t = Error(t), e.error = t, O(e, `onerror`, t), e;
523
+ }
524
+ function L(e) {
525
+ return e.sawRoot && !e.closedRoot && R(e, `Unclosed root tag`), e.state !== E.BEGIN && e.state !== E.BEGIN_WHITESPACE && e.state !== E.TEXT && I(e, `Unexpected end`), P(e), e.c = ``, e.closed = !0, O(e, `onend`), r.call(e, e.strict, e.opt), e;
526
+ }
527
+ function R(e, t) {
528
+ if (typeof e != `object` || !(e instanceof r)) throw Error(`bad call to strictFail`);
529
+ e.strict && I(e, t);
530
+ }
531
+ function z(e) {
532
+ e.strict || (e.tagName = e.tagName[e.looseCase]());
533
+ var t = e.tags[e.tags.length - 1] || e, n = e.tag = {
534
+ name: e.tagName,
535
+ attributes: {}
536
+ };
537
+ e.opt.xmlns && (n.ns = t.ns), e.attribList.length = 0, N(e, `onopentagstart`, n);
538
+ }
539
+ function B(e, t) {
540
+ var n = e.indexOf(`:`) < 0 ? [``, e] : e.split(`:`), r = n[0], i = n[1];
541
+ return t && e === `xmlns` && (r = `xmlns`, i = ``), {
542
+ prefix: r,
543
+ local: i
544
+ };
545
+ }
546
+ function V(e) {
547
+ if (e.strict || (e.attribName = e.attribName[e.looseCase]()), e.attribList.indexOf(e.attribName) !== -1 || e.tag.attributes.hasOwnProperty(e.attribName)) {
548
+ e.attribName = e.attribValue = ``;
549
+ return;
550
+ }
551
+ if (e.opt.xmlns) {
552
+ var t = B(e.attribName, !0), n = t.prefix, r = t.local;
553
+ if (n === `xmlns`) if (r === `xml` && e.attribValue !== m) R(e, `xml: prefix must be bound to ` + m + `
554
+ Actual: ` + e.attribValue);
555
+ else if (r === `xmlns` && e.attribValue !== h) R(e, `xmlns: prefix must be bound to ` + h + `
556
+ Actual: ` + e.attribValue);
557
+ else {
558
+ var i = e.tag, a = e.tags[e.tags.length - 1] || e;
559
+ i.ns === a.ns && (i.ns = Object.create(a.ns)), i.ns[r] = e.attribValue;
560
+ }
561
+ e.attribList.push([e.attribName, e.attribValue]);
562
+ } else e.tag.attributes[e.attribName] = e.attribValue, N(e, `onattribute`, {
563
+ name: e.attribName,
564
+ value: e.attribValue
565
+ });
566
+ e.attribName = e.attribValue = ``;
567
+ }
568
+ function H(e, t) {
569
+ if (e.opt.xmlns) {
570
+ var n = e.tag, r = B(e.tagName);
571
+ n.prefix = r.prefix, n.local = r.local, n.uri = n.ns[r.prefix] || ``, n.prefix && !n.uri && (R(e, `Unbound namespace prefix: ` + JSON.stringify(e.tagName)), n.uri = r.prefix);
572
+ var i = e.tags[e.tags.length - 1] || e;
573
+ n.ns && i.ns !== n.ns && Object.keys(n.ns).forEach(function(t) {
574
+ N(e, `onopennamespace`, {
575
+ prefix: t,
576
+ uri: n.ns[t]
577
+ });
578
+ });
579
+ for (var a = 0, o = e.attribList.length; a < o; a++) {
580
+ var s = e.attribList[a], c = s[0], l = s[1], u = B(c, !0), d = u.prefix, f = u.local, p = d === `` ? `` : n.ns[d] || ``, m = {
581
+ name: c,
582
+ value: l,
583
+ prefix: d,
584
+ local: f,
585
+ uri: p
586
+ };
587
+ d && d !== `xmlns` && !p && (R(e, `Unbound namespace prefix: ` + JSON.stringify(d)), m.uri = d), e.tag.attributes[c] = m, N(e, `onattribute`, m);
588
+ }
589
+ e.attribList.length = 0;
590
+ }
591
+ e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), N(e, `onopentag`, e.tag), t || (!e.noscript && e.tagName.toLowerCase() === `script` ? e.state = E.SCRIPT : e.state = E.TEXT, e.tag = null, e.tagName = ``), e.attribName = e.attribValue = ``, e.attribList.length = 0;
592
+ }
593
+ function U(e) {
594
+ if (!e.tagName) {
595
+ R(e, `Weird empty close tag.`), e.textNode += `</>`, e.state = E.TEXT;
596
+ return;
597
+ }
598
+ if (e.script) {
599
+ if (e.tagName !== `script`) {
600
+ e.script += `</` + e.tagName + `>`, e.tagName = ``, e.state = E.SCRIPT;
601
+ return;
602
+ }
603
+ N(e, `onscript`, e.script), e.script = ``;
604
+ }
605
+ var t = e.tags.length, n = e.tagName;
606
+ e.strict || (n = n[e.looseCase]());
607
+ for (var r = n; t-- && e.tags[t].name !== r;) R(e, `Unexpected close tag`);
608
+ if (t < 0) {
609
+ R(e, `Unmatched closing tag: ` + e.tagName), e.textNode += `</` + e.tagName + `>`, e.state = E.TEXT;
610
+ return;
611
+ }
612
+ e.tagName = n;
613
+ for (var i = e.tags.length; i-- > t;) {
614
+ var a = e.tag = e.tags.pop();
615
+ e.tagName = e.tag.name, N(e, `onclosetag`, e.tagName);
616
+ var o = {};
617
+ for (var s in a.ns) o[s] = a.ns[s];
618
+ var c = e.tags[e.tags.length - 1] || e;
619
+ e.opt.xmlns && a.ns !== c.ns && Object.keys(a.ns).forEach(function(t) {
620
+ var n = a.ns[t];
621
+ N(e, `onclosenamespace`, {
622
+ prefix: t,
623
+ uri: n
624
+ });
625
+ });
626
+ }
627
+ t === 0 && (e.closedRoot = !0), e.tagName = e.attribValue = e.attribName = ``, e.attribList.length = 0, e.state = E.TEXT;
628
+ }
629
+ function W(e) {
630
+ var t = e.entity, n = t.toLowerCase(), r, i = ``;
631
+ return e.ENTITIES[t] ? e.ENTITIES[t] : e.ENTITIES[n] ? e.ENTITIES[n] : (t = n, t.charAt(0) === `#` && (t.charAt(1) === `x` ? (t = t.slice(2), r = parseInt(t, 16), i = r.toString(16)) : (t = t.slice(1), r = parseInt(t, 10), i = r.toString(10))), t = t.replace(/^0+/, ``), isNaN(r) || i.toLowerCase() !== t || r < 0 || r > 1114111 ? (R(e, `Invalid character entity`), `&` + e.entity + `;`) : String.fromCodePoint(r));
632
+ }
633
+ function G(e, t) {
634
+ t === `<` ? (e.state = E.OPEN_WAKA, e.startTagPosition = e.position) : x(t) || (R(e, `Non-whitespace before first tag.`), e.textNode = t, e.state = E.TEXT);
635
+ }
636
+ function K(e, t) {
637
+ var n = ``;
638
+ return t < e.length && (n = e.charAt(t)), n;
639
+ }
640
+ function q(t) {
641
+ var n = this;
642
+ if (this.error) throw this.error;
643
+ if (n.closed) return I(n, `Cannot write after close. Assign an onready handler.`);
644
+ if (t === null) return L(n);
645
+ typeof t == `object` && (t = t.toString());
646
+ for (var r = 0, a = ``; a = K(t, r++), n.c = a, a;) switch (n.trackPosition && (n.position++, a === `
647
+ ` ? (n.line++, n.column = 0) : n.column++), n.state) {
648
+ case E.BEGIN:
649
+ if (n.state = E.BEGIN_WHITESPACE, a === ``) continue;
650
+ G(n, a);
651
+ continue;
652
+ case E.BEGIN_WHITESPACE:
653
+ G(n, a);
654
+ continue;
655
+ case E.TEXT:
656
+ if (n.sawRoot && !n.closedRoot) {
657
+ for (var o = r - 1; a && a !== `<` && a !== `&`;) a = K(t, r++), a && n.trackPosition && (n.position++, a === `
658
+ ` ? (n.line++, n.column = 0) : n.column++);
659
+ n.textNode += t.substring(o, r - 1);
660
+ }
661
+ a === `<` && !(n.sawRoot && n.closedRoot && !n.strict) ? (n.state = E.OPEN_WAKA, n.startTagPosition = n.position) : (!x(a) && (!n.sawRoot || n.closedRoot) && R(n, `Text data outside of root node.`), a === `&` ? n.state = E.TEXT_ENTITY : n.textNode += a);
662
+ continue;
663
+ case E.SCRIPT:
664
+ a === `<` ? n.state = E.SCRIPT_ENDING : n.script += a;
665
+ continue;
666
+ case E.SCRIPT_ENDING:
667
+ a === `/` ? n.state = E.CLOSE_TAG : (n.script += `<` + a, n.state = E.SCRIPT);
668
+ continue;
669
+ case E.OPEN_WAKA:
670
+ if (a === `!`) n.state = E.SGML_DECL, n.sgmlDecl = ``;
671
+ else if (!x(a)) if (w(_, a)) n.state = E.OPEN_TAG, n.tagName = a;
672
+ else if (a === `/`) n.state = E.CLOSE_TAG, n.tagName = ``;
673
+ else if (a === `?`) n.state = E.PROC_INST, n.procInstName = n.procInstBody = ``;
674
+ else {
675
+ if (R(n, `Unencoded <`), n.startTagPosition + 1 < n.position) {
676
+ var s = n.position - n.startTagPosition;
677
+ a = Array(s).join(` `) + a;
678
+ }
679
+ n.textNode += `<` + a, n.state = E.TEXT;
680
+ }
681
+ continue;
682
+ case E.SGML_DECL:
683
+ if (n.sgmlDecl + a === `--`) {
684
+ n.state = E.COMMENT, n.comment = ``, n.sgmlDecl = ``;
685
+ continue;
686
+ }
687
+ n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = E.DOCTYPE_DTD, n.doctype += `<!` + n.sgmlDecl + a, n.sgmlDecl = ``) : (n.sgmlDecl + a).toUpperCase() === f ? (N(n, `onopencdata`), n.state = E.CDATA, n.sgmlDecl = ``, n.cdata = ``) : (n.sgmlDecl + a).toUpperCase() === p ? (n.state = E.DOCTYPE, (n.doctype || n.sawRoot) && R(n, `Inappropriately located doctype declaration`), n.doctype = ``, n.sgmlDecl = ``) : a === `>` ? (N(n, `onsgmldeclaration`, n.sgmlDecl), n.sgmlDecl = ``, n.state = E.TEXT) : (S(a) && (n.state = E.SGML_DECL_QUOTED), n.sgmlDecl += a);
688
+ continue;
689
+ case E.SGML_DECL_QUOTED:
690
+ a === n.q && (n.state = E.SGML_DECL, n.q = ``), n.sgmlDecl += a;
691
+ continue;
692
+ case E.DOCTYPE:
693
+ a === `>` ? (n.state = E.TEXT, N(n, `ondoctype`, n.doctype), n.doctype = !0) : (n.doctype += a, a === `[` ? n.state = E.DOCTYPE_DTD : S(a) && (n.state = E.DOCTYPE_QUOTED, n.q = a));
694
+ continue;
695
+ case E.DOCTYPE_QUOTED:
696
+ n.doctype += a, a === n.q && (n.q = ``, n.state = E.DOCTYPE);
697
+ continue;
698
+ case E.DOCTYPE_DTD:
699
+ a === `]` ? (n.doctype += a, n.state = E.DOCTYPE) : a === `<` ? (n.state = E.OPEN_WAKA, n.startTagPosition = n.position) : S(a) ? (n.doctype += a, n.state = E.DOCTYPE_DTD_QUOTED, n.q = a) : n.doctype += a;
700
+ continue;
701
+ case E.DOCTYPE_DTD_QUOTED:
702
+ n.doctype += a, a === n.q && (n.state = E.DOCTYPE_DTD, n.q = ``);
703
+ continue;
704
+ case E.COMMENT:
705
+ a === `-` ? n.state = E.COMMENT_ENDING : n.comment += a;
706
+ continue;
707
+ case E.COMMENT_ENDING:
708
+ a === `-` ? (n.state = E.COMMENT_ENDED, n.comment = F(n.opt, n.comment), n.comment && N(n, `oncomment`, n.comment), n.comment = ``) : (n.comment += `-` + a, n.state = E.COMMENT);
709
+ continue;
710
+ case E.COMMENT_ENDED:
711
+ a === `>` ? n.doctype && n.doctype !== !0 ? n.state = E.DOCTYPE_DTD : n.state = E.TEXT : (R(n, `Malformed comment`), n.comment += `--` + a, n.state = E.COMMENT);
712
+ continue;
713
+ case E.CDATA:
714
+ for (var o = r - 1; a && a !== `]`;) a = K(t, r++), a && n.trackPosition && (n.position++, a === `
715
+ ` ? (n.line++, n.column = 0) : n.column++);
716
+ n.cdata += t.substring(o, r - 1), a === `]` && (n.state = E.CDATA_ENDING);
717
+ continue;
718
+ case E.CDATA_ENDING:
719
+ a === `]` ? n.state = E.CDATA_ENDING_2 : (n.cdata += `]` + a, n.state = E.CDATA);
720
+ continue;
721
+ case E.CDATA_ENDING_2:
722
+ a === `>` ? (n.cdata && N(n, `oncdata`, n.cdata), N(n, `onclosecdata`), n.cdata = ``, n.state = E.TEXT) : a === `]` ? n.cdata += `]` : (n.cdata += `]]` + a, n.state = E.CDATA);
723
+ continue;
724
+ case E.PROC_INST:
725
+ a === `?` ? n.state = E.PROC_INST_ENDING : x(a) ? n.state = E.PROC_INST_BODY : n.procInstName += a;
726
+ continue;
727
+ case E.PROC_INST_BODY:
728
+ if (!n.procInstBody && x(a)) continue;
729
+ a === `?` ? n.state = E.PROC_INST_ENDING : n.procInstBody += a;
730
+ continue;
731
+ case E.PROC_INST_ENDING:
732
+ if (a === `>`) {
733
+ let e = {
734
+ name: n.procInstName,
735
+ body: n.procInstBody
736
+ };
737
+ M(n, e), N(n, `onprocessinginstruction`, e), n.procInstName = n.procInstBody = ``, n.state = E.TEXT;
738
+ } else n.procInstBody += `?` + a, n.state = E.PROC_INST_BODY;
739
+ continue;
740
+ case E.OPEN_TAG:
741
+ w(v, a) ? n.tagName += a : (z(n), a === `>` ? H(n) : a === `/` ? n.state = E.OPEN_TAG_SLASH : (x(a) || R(n, `Invalid character in tag name`), n.state = E.ATTRIB));
742
+ continue;
743
+ case E.OPEN_TAG_SLASH:
744
+ a === `>` ? (H(n, !0), U(n)) : (R(n, `Forward-slash in opening tag not followed by >`), n.state = E.ATTRIB);
745
+ continue;
746
+ case E.ATTRIB:
747
+ if (x(a)) continue;
748
+ a === `>` ? H(n) : a === `/` ? n.state = E.OPEN_TAG_SLASH : w(_, a) ? (n.attribName = a, n.attribValue = ``, n.state = E.ATTRIB_NAME) : R(n, `Invalid attribute name`);
749
+ continue;
750
+ case E.ATTRIB_NAME:
751
+ a === `=` ? n.state = E.ATTRIB_VALUE : a === `>` ? (R(n, `Attribute without value`), n.attribValue = n.attribName, V(n), H(n)) : x(a) ? n.state = E.ATTRIB_NAME_SAW_WHITE : w(v, a) ? n.attribName += a : R(n, `Invalid attribute name`);
752
+ continue;
753
+ case E.ATTRIB_NAME_SAW_WHITE:
754
+ if (a === `=`) n.state = E.ATTRIB_VALUE;
755
+ else if (x(a)) continue;
756
+ else R(n, `Attribute without value`), n.tag.attributes[n.attribName] = ``, n.attribValue = ``, N(n, `onattribute`, {
757
+ name: n.attribName,
758
+ value: ``
759
+ }), n.attribName = ``, a === `>` ? H(n) : w(_, a) ? (n.attribName = a, n.state = E.ATTRIB_NAME) : (R(n, `Invalid attribute name`), n.state = E.ATTRIB);
760
+ continue;
761
+ case E.ATTRIB_VALUE:
762
+ if (x(a)) continue;
763
+ S(a) ? (n.q = a, n.state = E.ATTRIB_VALUE_QUOTED) : (n.opt.unquotedAttributeValues || I(n, `Unquoted attribute value`), n.state = E.ATTRIB_VALUE_UNQUOTED, n.attribValue = a);
764
+ continue;
765
+ case E.ATTRIB_VALUE_QUOTED:
766
+ if (a !== n.q) {
767
+ a === `&` ? n.state = E.ATTRIB_VALUE_ENTITY_Q : n.attribValue += a;
768
+ continue;
769
+ }
770
+ V(n), n.q = ``, n.state = E.ATTRIB_VALUE_CLOSED;
771
+ continue;
772
+ case E.ATTRIB_VALUE_CLOSED:
773
+ x(a) ? n.state = E.ATTRIB : a === `>` ? H(n) : a === `/` ? n.state = E.OPEN_TAG_SLASH : w(_, a) ? (R(n, `No whitespace between attributes`), n.attribName = a, n.attribValue = ``, n.state = E.ATTRIB_NAME) : R(n, `Invalid attribute name`);
774
+ continue;
775
+ case E.ATTRIB_VALUE_UNQUOTED:
776
+ if (!C(a)) {
777
+ a === `&` ? n.state = E.ATTRIB_VALUE_ENTITY_U : n.attribValue += a;
778
+ continue;
779
+ }
780
+ V(n), a === `>` ? H(n) : n.state = E.ATTRIB;
781
+ continue;
782
+ case E.CLOSE_TAG:
783
+ if (n.tagName) a === `>` ? U(n) : w(v, a) ? n.tagName += a : n.script ? (n.script += `</` + n.tagName + a, n.tagName = ``, n.state = E.SCRIPT) : (x(a) || R(n, `Invalid tagname in closing tag`), n.state = E.CLOSE_TAG_SAW_WHITE);
784
+ else {
785
+ if (x(a)) continue;
786
+ T(_, a) ? n.script ? (n.script += `</` + a, n.state = E.SCRIPT) : R(n, `Invalid tagname in closing tag.`) : n.tagName = a;
787
+ }
788
+ continue;
789
+ case E.CLOSE_TAG_SAW_WHITE:
790
+ if (x(a)) continue;
791
+ a === `>` ? U(n) : R(n, `Invalid characters in closing tag`);
792
+ continue;
793
+ case E.TEXT_ENTITY:
794
+ case E.ATTRIB_VALUE_ENTITY_Q:
795
+ case E.ATTRIB_VALUE_ENTITY_U:
796
+ var c, l;
797
+ switch (n.state) {
798
+ case E.TEXT_ENTITY:
799
+ c = E.TEXT, l = `textNode`;
800
+ break;
801
+ case E.ATTRIB_VALUE_ENTITY_Q:
802
+ c = E.ATTRIB_VALUE_QUOTED, l = `attribValue`;
803
+ break;
804
+ case E.ATTRIB_VALUE_ENTITY_U:
805
+ c = E.ATTRIB_VALUE_UNQUOTED, l = `attribValue`;
806
+ break;
807
+ }
808
+ if (a === `;`) {
809
+ var u = W(n);
810
+ n.opt.unparsedEntities && !Object.values(e.XML_ENTITIES).includes(u) ? ((n.entityCount += 1) > n.opt.maxEntityCount && I(n, `Parsed entity count exceeds max entity count`), (n.entityDepth += 1) > n.opt.maxEntityDepth && I(n, `Parsed entity depth exceeds max entity depth`), n.entity = ``, n.state = c, n.write(u), --n.entityDepth) : (n[l] += u, n.entity = ``, n.state = c);
811
+ } else w(n.entity.length ? b : y, a) ? n.entity += a : (R(n, `Invalid character in entity name`), n[l] += `&` + n.entity + a, n.entity = ``, n.state = c);
812
+ continue;
813
+ default: throw Error(n, `Unknown state: ` + n.state);
814
+ }
815
+ return n.position >= n.bufferCheckPosition && i(n), n;
816
+ }
817
+ String.fromCodePoint || (function() {
818
+ var e = String.fromCharCode, t = Math.floor, n = function() {
819
+ var n = 16384, r = [], i, a, o = -1, s = arguments.length;
820
+ if (!s) return ``;
821
+ for (var c = ``; ++o < s;) {
822
+ var l = Number(arguments[o]);
823
+ if (!isFinite(l) || l < 0 || l > 1114111 || t(l) !== l) throw RangeError(`Invalid code point: ` + l);
824
+ l <= 65535 ? r.push(l) : (l -= 65536, i = (l >> 10) + 55296, a = l % 1024 + 56320, r.push(i, a)), (o + 1 === s || r.length > n) && (c += e.apply(null, r), r.length = 0);
825
+ }
826
+ return c;
827
+ };
828
+ Object.defineProperty ? Object.defineProperty(String, "fromCodePoint", {
829
+ value: n,
830
+ configurable: !0,
831
+ writable: !0
832
+ }) : String.fromCodePoint = n;
833
+ })();
834
+ })(e === void 0 ? e.sax = {} : e);
835
+ }));
836
+ export { n as require_sax };