@salesforce-ux/eslint-plugin-slds 0.0.1

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/build/index.js ADDED
@@ -0,0 +1,3310 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('fs');
4
+ var require$$1 = require('path');
5
+
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+
8
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
9
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
10
+
11
+ function getDefaultExportFromCjs (x) {
12
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
+ }
14
+
15
+ var dist$1 = {};
16
+
17
+ var parser$1 = {};
18
+
19
+ var dist = {};
20
+
21
+ var parser = {};
22
+
23
+ var parse = {};
24
+
25
+ var treeConstructor = {};
26
+
27
+ var constructTree = {};
28
+
29
+ var constants = {};
30
+
31
+ var astTypes = {};
32
+
33
+ var hasRequiredAstTypes;
34
+
35
+ function requireAstTypes () {
36
+ if (hasRequiredAstTypes) return astTypes;
37
+ hasRequiredAstTypes = 1;
38
+ (function (exports) {
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.AstTypes = void 0;
41
+ (function (AstTypes) {
42
+ AstTypes["Document"] = "Document";
43
+ AstTypes["Tag"] = "Tag";
44
+ AstTypes["Text"] = "Text";
45
+ AstTypes["Doctype"] = "Doctype";
46
+ AstTypes["Comment"] = "Comment";
47
+ AstTypes["Script"] = "Script";
48
+ AstTypes["Style"] = "Style";
49
+ })(exports.AstTypes || (exports.AstTypes = {}));
50
+ } (astTypes));
51
+ return astTypes;
52
+ }
53
+
54
+ var tokenizerContextTypes = {};
55
+
56
+ var hasRequiredTokenizerContextTypes;
57
+
58
+ function requireTokenizerContextTypes () {
59
+ if (hasRequiredTokenizerContextTypes) return tokenizerContextTypes;
60
+ hasRequiredTokenizerContextTypes = 1;
61
+ (function (exports) {
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports.TokenizerContextTypes = void 0;
64
+ (function (TokenizerContextTypes) {
65
+ TokenizerContextTypes["Data"] = "Data";
66
+ TokenizerContextTypes["OpenTagStart"] = "OpenTagStart";
67
+ TokenizerContextTypes["CloseTag"] = "CloseTag";
68
+ TokenizerContextTypes["Attributes"] = "Attributes";
69
+ TokenizerContextTypes["OpenTagEnd"] = "OpenTagEnd";
70
+ TokenizerContextTypes["AttributeKey"] = "AttributeKey";
71
+ TokenizerContextTypes["AttributeValue"] = "AttributeValue";
72
+ TokenizerContextTypes["AttributeValueBare"] = "AttributeValueBare";
73
+ TokenizerContextTypes["AttributeValueWrapped"] = "AttributeValueWrapped";
74
+ TokenizerContextTypes["ScriptContent"] = "ScriptContent";
75
+ TokenizerContextTypes["StyleContent"] = "StyleContent";
76
+ TokenizerContextTypes["DoctypeOpen"] = "DoctypeOpen";
77
+ TokenizerContextTypes["DoctypeClose"] = "DoctypeClose";
78
+ TokenizerContextTypes["DoctypeAttributes"] = "DoctypeAttributes";
79
+ TokenizerContextTypes["DoctypeAttributeWrapped"] = "DoctypeAttributeWrapped";
80
+ TokenizerContextTypes["DoctypeAttributeBare"] = "DoctypeAttributeBare";
81
+ TokenizerContextTypes["CommentOpen"] = "CommentOpen";
82
+ TokenizerContextTypes["CommentContent"] = "CommentContent";
83
+ TokenizerContextTypes["CommentClose"] = "CommentClose";
84
+ })(exports.TokenizerContextTypes || (exports.TokenizerContextTypes = {}));
85
+ } (tokenizerContextTypes));
86
+ return tokenizerContextTypes;
87
+ }
88
+
89
+ var regex = {};
90
+
91
+ var hasRequiredRegex;
92
+
93
+ function requireRegex () {
94
+ if (hasRequiredRegex) return regex;
95
+ hasRequiredRegex = 1;
96
+ Object.defineProperty(regex, "__esModule", { value: true });
97
+ regex.CLOSE_TAG_NAME_PATTERN = regex.OPEN_TAG_NAME_PATTERN = regex.CLOSING_STYLE_TAG_PATTERN = regex.CLOSING_SCRIPT_TAG_PATTERN = regex.INCOMPLETE_CLOSING_TAG_PATTERN = void 0;
98
+ regex.INCOMPLETE_CLOSING_TAG_PATTERN = /<\/[^>]+$/;
99
+ regex.CLOSING_SCRIPT_TAG_PATTERN = /<\/script\s*>/i;
100
+ regex.CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
101
+ regex.OPEN_TAG_NAME_PATTERN = /^<(\S+)/;
102
+ regex.CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\n)*)>$/;
103
+ return regex;
104
+ }
105
+
106
+ var tokenTypes = {};
107
+
108
+ var hasRequiredTokenTypes;
109
+
110
+ function requireTokenTypes () {
111
+ if (hasRequiredTokenTypes) return tokenTypes;
112
+ hasRequiredTokenTypes = 1;
113
+ (function (exports) {
114
+ Object.defineProperty(exports, "__esModule", { value: true });
115
+ exports.TokenTypes = void 0;
116
+ (function (TokenTypes) {
117
+ TokenTypes["Text"] = "Text";
118
+ TokenTypes["OpenTagStart"] = "OpenTagStart";
119
+ TokenTypes["OpenTagEnd"] = "OpenTagEnd";
120
+ TokenTypes["CloseTag"] = "CloseTag";
121
+ TokenTypes["AttributeKey"] = "AttributeKey";
122
+ TokenTypes["AttributeAssignment"] = "AttributeAssignment";
123
+ TokenTypes["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
124
+ TokenTypes["AttributeValue"] = "AttributeValue";
125
+ TokenTypes["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
126
+ TokenTypes["DoctypeOpen"] = "DoctypeOpen";
127
+ TokenTypes["DoctypeAttributeValue"] = "DoctypeAttributeValue";
128
+ TokenTypes["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
129
+ TokenTypes["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
130
+ TokenTypes["DoctypeClose"] = "DoctypeClose";
131
+ TokenTypes["CommentOpen"] = "CommentOpen";
132
+ TokenTypes["CommentContent"] = "CommentContent";
133
+ TokenTypes["CommentClose"] = "CommentClose";
134
+ TokenTypes["OpenScriptTagStart"] = "OpenScriptTagStart";
135
+ TokenTypes["OpenScriptTagEnd"] = "OpenScriptTagEnd";
136
+ TokenTypes["ScriptTagContent"] = "ScriptTagContent";
137
+ TokenTypes["CloseScriptTag"] = "CloseScriptTag";
138
+ TokenTypes["OpenStyleTagStart"] = "OpenStyleTagStart";
139
+ TokenTypes["OpenStyleTagEnd"] = "OpenStyleTagEnd";
140
+ TokenTypes["StyleTagContent"] = "StyleTagContent";
141
+ TokenTypes["CloseStyleTag"] = "CloseStyleTag";
142
+ })(exports.TokenTypes || (exports.TokenTypes = {}));
143
+ } (tokenTypes));
144
+ return tokenTypes;
145
+ }
146
+
147
+ var nodeTypes = {};
148
+
149
+ var hasRequiredNodeTypes;
150
+
151
+ function requireNodeTypes () {
152
+ if (hasRequiredNodeTypes) return nodeTypes;
153
+ hasRequiredNodeTypes = 1;
154
+ (function (exports) {
155
+ Object.defineProperty(exports, "__esModule", { value: true });
156
+ exports.NodeTypes = void 0;
157
+ (function (NodeTypes) {
158
+ NodeTypes["Document"] = "Document";
159
+ NodeTypes["Tag"] = "Tag";
160
+ NodeTypes["Text"] = "Text";
161
+ NodeTypes["Doctype"] = "Doctype";
162
+ NodeTypes["Comment"] = "Comment";
163
+ NodeTypes["CommentOpen"] = "CommentOpen";
164
+ NodeTypes["CommentClose"] = "CommentClose";
165
+ NodeTypes["CommentContent"] = "CommentContent";
166
+ NodeTypes["Attribute"] = "Attribute";
167
+ NodeTypes["AttributeKey"] = "AttributeKey";
168
+ NodeTypes["AttributeValue"] = "AttributeValue";
169
+ NodeTypes["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
170
+ NodeTypes["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
171
+ NodeTypes["CloseTag"] = "CloseTag";
172
+ NodeTypes["OpenTagEnd"] = "OpenTagEnd";
173
+ NodeTypes["OpenTagStart"] = "OpenTagStart";
174
+ NodeTypes["DoctypeOpen"] = "DoctypeOpen";
175
+ NodeTypes["DoctypeAttribute"] = "DoctypeAttribute";
176
+ NodeTypes["DoctypeClose"] = "DoctypeClose";
177
+ NodeTypes["ScriptTag"] = "ScriptTag";
178
+ NodeTypes["OpenScriptTagStart"] = "OpenScriptTagStart";
179
+ NodeTypes["OpenScriptTagEnd"] = "OpenScriptTagEnd";
180
+ NodeTypes["ScriptTagContent"] = "ScriptTagContent";
181
+ NodeTypes["StyleTag"] = "StyleTag";
182
+ NodeTypes["OpenStyleTagStart"] = "OpenStyleTagStart";
183
+ NodeTypes["OpenStyleTagEnd"] = "OpenStyleTagEnd";
184
+ NodeTypes["StyleTagContent"] = "StyleTagContent";
185
+ NodeTypes["CloseStyleTag"] = "CloseStyleTag";
186
+ NodeTypes["CloseScriptTag"] = "CloseScriptTag";
187
+ NodeTypes["DoctypeAttributeValue"] = "DoctypeAttributeValue";
188
+ NodeTypes["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
189
+ NodeTypes["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
190
+ })(exports.NodeTypes || (exports.NodeTypes = {}));
191
+ } (nodeTypes));
192
+ return nodeTypes;
193
+ }
194
+
195
+ var constructTreeContextTypes = {};
196
+
197
+ var hasRequiredConstructTreeContextTypes;
198
+
199
+ function requireConstructTreeContextTypes () {
200
+ if (hasRequiredConstructTreeContextTypes) return constructTreeContextTypes;
201
+ hasRequiredConstructTreeContextTypes = 1;
202
+ (function (exports) {
203
+ Object.defineProperty(exports, "__esModule", { value: true });
204
+ exports.ConstructTreeContextTypes = void 0;
205
+ (function (ConstructTreeContextTypes) {
206
+ ConstructTreeContextTypes["TagContent"] = "TagContent";
207
+ ConstructTreeContextTypes["Tag"] = "Tag";
208
+ ConstructTreeContextTypes["TagName"] = "TagName";
209
+ ConstructTreeContextTypes["Attributes"] = "Attributes";
210
+ ConstructTreeContextTypes["Attribute"] = "Attribute";
211
+ ConstructTreeContextTypes["AttributeValue"] = "AttributeValue";
212
+ ConstructTreeContextTypes["Comment"] = "Comment";
213
+ ConstructTreeContextTypes["Doctype"] = "Doctype";
214
+ ConstructTreeContextTypes["DoctypeAttributes"] = "DoctypeAttributes";
215
+ ConstructTreeContextTypes["DoctypeAttribute"] = "DoctypeAttribute";
216
+ ConstructTreeContextTypes["ScriptTag"] = "ScriptTag";
217
+ ConstructTreeContextTypes["StyleTag"] = "StyleTag";
218
+ })(exports.ConstructTreeContextTypes || (exports.ConstructTreeContextTypes = {}));
219
+ } (constructTreeContextTypes));
220
+ return constructTreeContextTypes;
221
+ }
222
+
223
+ var hasRequiredConstants;
224
+
225
+ function requireConstants () {
226
+ if (hasRequiredConstants) return constants;
227
+ hasRequiredConstants = 1;
228
+ (function (exports) {
229
+ var __createBinding = (constants && constants.__createBinding) || (Object.create ? (function(o, m, k, k2) {
230
+ if (k2 === undefined) k2 = k;
231
+ var desc = Object.getOwnPropertyDescriptor(m, k);
232
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
233
+ desc = { enumerable: true, get: function() { return m[k]; } };
234
+ }
235
+ Object.defineProperty(o, k2, desc);
236
+ }) : (function(o, m, k, k2) {
237
+ if (k2 === undefined) k2 = k;
238
+ o[k2] = m[k];
239
+ }));
240
+ var __exportStar = (constants && constants.__exportStar) || function(m, exports) {
241
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
242
+ };
243
+ Object.defineProperty(exports, "__esModule", { value: true });
244
+ __exportStar(requireAstTypes(), exports);
245
+ __exportStar(requireTokenizerContextTypes(), exports);
246
+ __exportStar(requireRegex(), exports);
247
+ __exportStar(requireTokenTypes(), exports);
248
+ __exportStar(requireNodeTypes(), exports);
249
+ __exportStar(requireConstructTreeContextTypes(), exports);
250
+ } (constants));
251
+ return constants;
252
+ }
253
+
254
+ var utils = {};
255
+
256
+ var calculateTokenCharactersRange = {};
257
+
258
+ var hasRequiredCalculateTokenCharactersRange;
259
+
260
+ function requireCalculateTokenCharactersRange () {
261
+ if (hasRequiredCalculateTokenCharactersRange) return calculateTokenCharactersRange;
262
+ hasRequiredCalculateTokenCharactersRange = 1;
263
+ Object.defineProperty(calculateTokenCharactersRange, "__esModule", { value: true });
264
+ calculateTokenCharactersRange.calculateTokenCharactersRange = void 0;
265
+ function calculateTokenCharactersRange$1(state, { keepBuffer }) {
266
+ const startPosition = state.caretPosition -
267
+ (state.accumulatedContent.length - 1) -
268
+ state.decisionBuffer.length;
269
+ let endPosition;
270
+ if (!keepBuffer) {
271
+ endPosition = state.caretPosition - state.decisionBuffer.length;
272
+ }
273
+ else {
274
+ endPosition = state.caretPosition;
275
+ }
276
+ return [startPosition, endPosition + 1];
277
+ }
278
+ calculateTokenCharactersRange.calculateTokenCharactersRange = calculateTokenCharactersRange$1;
279
+ return calculateTokenCharactersRange;
280
+ }
281
+
282
+ var isWhitespace = {};
283
+
284
+ var hasRequiredIsWhitespace;
285
+
286
+ function requireIsWhitespace () {
287
+ if (hasRequiredIsWhitespace) return isWhitespace;
288
+ hasRequiredIsWhitespace = 1;
289
+ Object.defineProperty(isWhitespace, "__esModule", { value: true });
290
+ isWhitespace.isWhitespace = void 0;
291
+ function isWhitespace$1(char) {
292
+ return char === " " || char === "\n" || char === "\t" || char === "\r";
293
+ }
294
+ isWhitespace.isWhitespace = isWhitespace$1;
295
+ return isWhitespace;
296
+ }
297
+
298
+ var parseOpenTagName = {};
299
+
300
+ var hasRequiredParseOpenTagName;
301
+
302
+ function requireParseOpenTagName () {
303
+ if (hasRequiredParseOpenTagName) return parseOpenTagName;
304
+ hasRequiredParseOpenTagName = 1;
305
+ Object.defineProperty(parseOpenTagName, "__esModule", { value: true });
306
+ parseOpenTagName.parseOpenTagName = void 0;
307
+ const constants_1 = requireConstants();
308
+ function parseOpenTagName$1(openTagStartTokenContent) {
309
+ const match = openTagStartTokenContent.match(constants_1.OPEN_TAG_NAME_PATTERN);
310
+ if (match === null) {
311
+ throw new Error("Unable to parse open tag name.\n" +
312
+ `${openTagStartTokenContent} does not match pattern of opening tag.`);
313
+ }
314
+ return match[1].toLowerCase();
315
+ }
316
+ parseOpenTagName.parseOpenTagName = parseOpenTagName$1;
317
+ return parseOpenTagName;
318
+ }
319
+
320
+ var parseCloseTagName = {};
321
+
322
+ var hasRequiredParseCloseTagName;
323
+
324
+ function requireParseCloseTagName () {
325
+ if (hasRequiredParseCloseTagName) return parseCloseTagName;
326
+ hasRequiredParseCloseTagName = 1;
327
+ Object.defineProperty(parseCloseTagName, "__esModule", { value: true });
328
+ parseCloseTagName.parseCloseTagName = void 0;
329
+ const constants_1 = requireConstants();
330
+ function parseCloseTagName$1(closeTagTokenContent) {
331
+ const match = closeTagTokenContent.match(constants_1.CLOSE_TAG_NAME_PATTERN);
332
+ if (match === null) {
333
+ throw new Error("Unable to parse close tag name.\n" +
334
+ `${closeTagTokenContent} does not match pattern of closing tag.`);
335
+ }
336
+ return match[1].trim().toLowerCase();
337
+ }
338
+ parseCloseTagName.parseCloseTagName = parseCloseTagName$1;
339
+ return parseCloseTagName;
340
+ }
341
+
342
+ var clearParent = {};
343
+
344
+ var hasRequiredClearParent;
345
+
346
+ function requireClearParent () {
347
+ if (hasRequiredClearParent) return clearParent;
348
+ hasRequiredClearParent = 1;
349
+ Object.defineProperty(clearParent, "__esModule", { value: true });
350
+ clearParent.clearParent = void 0;
351
+ function clearParent$1(ast) {
352
+ const cleanAst = ast;
353
+ delete cleanAst.parentRef;
354
+ if (Array.isArray(ast.children)) {
355
+ // @ts-ignore
356
+ cleanAst.children = ast.children.map((node) => {
357
+ return clearParent$1(node);
358
+ });
359
+ }
360
+ return cleanAst;
361
+ }
362
+ clearParent.clearParent = clearParent$1;
363
+ return clearParent;
364
+ }
365
+
366
+ var calculateTokenLocation = {};
367
+
368
+ var getLineInfo = {};
369
+
370
+ var hasRequiredGetLineInfo;
371
+
372
+ function requireGetLineInfo () {
373
+ if (hasRequiredGetLineInfo) return getLineInfo;
374
+ hasRequiredGetLineInfo = 1;
375
+ //https://github.com/acornjs/acorn/blob/master/acorn/src/whitespace.js
376
+ Object.defineProperty(getLineInfo, "__esModule", { value: true });
377
+ getLineInfo.getLineInfo = void 0;
378
+ function isNewLine(code) {
379
+ return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
380
+ }
381
+ function nextLineBreak(code, from, end = code.length) {
382
+ for (let i = from; i < end; i++) {
383
+ const next = code.charCodeAt(i);
384
+ if (isNewLine(next))
385
+ return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10
386
+ ? i + 2
387
+ : i + 1;
388
+ }
389
+ return -1;
390
+ }
391
+ function getLineInfo$1(input, offset) {
392
+ for (let line = 1, cur = 0;;) {
393
+ const nextBreak = nextLineBreak(input, cur, offset);
394
+ if (nextBreak < 0)
395
+ return { line, column: offset - cur };
396
+ ++line;
397
+ cur = nextBreak;
398
+ }
399
+ }
400
+ getLineInfo.getLineInfo = getLineInfo$1;
401
+ return getLineInfo;
402
+ }
403
+
404
+ var hasRequiredCalculateTokenLocation;
405
+
406
+ function requireCalculateTokenLocation () {
407
+ if (hasRequiredCalculateTokenLocation) return calculateTokenLocation;
408
+ hasRequiredCalculateTokenLocation = 1;
409
+ Object.defineProperty(calculateTokenLocation, "__esModule", { value: true });
410
+ calculateTokenLocation.calculateTokenLocation = void 0;
411
+ const get_line_info_1 = requireGetLineInfo();
412
+ function calculateTokenLocation$1(source, range) {
413
+ return {
414
+ start: (0, get_line_info_1.getLineInfo)(source, range[0]),
415
+ end: (0, get_line_info_1.getLineInfo)(source, range[1]),
416
+ };
417
+ }
418
+ calculateTokenLocation.calculateTokenLocation = calculateTokenLocation$1;
419
+ return calculateTokenLocation;
420
+ }
421
+
422
+ var calculateTokenPosition = {};
423
+
424
+ var hasRequiredCalculateTokenPosition;
425
+
426
+ function requireCalculateTokenPosition () {
427
+ if (hasRequiredCalculateTokenPosition) return calculateTokenPosition;
428
+ hasRequiredCalculateTokenPosition = 1;
429
+ Object.defineProperty(calculateTokenPosition, "__esModule", { value: true });
430
+ calculateTokenPosition.calculateTokenPosition = void 0;
431
+ const calculate_token_characters_range_1 = requireCalculateTokenCharactersRange();
432
+ const calculate_token_location_1 = requireCalculateTokenLocation();
433
+ function calculateTokenPosition$1(state, options) {
434
+ const range = (0, calculate_token_characters_range_1.calculateTokenCharactersRange)(state, options);
435
+ const loc = (0, calculate_token_location_1.calculateTokenLocation)(state.source, range);
436
+ return {
437
+ range,
438
+ loc,
439
+ };
440
+ }
441
+ calculateTokenPosition.calculateTokenPosition = calculateTokenPosition$1;
442
+ return calculateTokenPosition;
443
+ }
444
+
445
+ var last = {};
446
+
447
+ var hasRequiredLast;
448
+
449
+ function requireLast () {
450
+ if (hasRequiredLast) return last;
451
+ hasRequiredLast = 1;
452
+ Object.defineProperty(last, "__esModule", { value: true });
453
+ last.last = void 0;
454
+ function last$1(items) {
455
+ return items[items.length - 1];
456
+ }
457
+ last.last = last$1;
458
+ return last;
459
+ }
460
+
461
+ var cloneRange = {};
462
+
463
+ var hasRequiredCloneRange;
464
+
465
+ function requireCloneRange () {
466
+ if (hasRequiredCloneRange) return cloneRange;
467
+ hasRequiredCloneRange = 1;
468
+ Object.defineProperty(cloneRange, "__esModule", { value: true });
469
+ cloneRange.cloneRange = void 0;
470
+ function cloneRange$1(range) {
471
+ return [range[0], range[1]];
472
+ }
473
+ cloneRange.cloneRange = cloneRange$1;
474
+ return cloneRange;
475
+ }
476
+
477
+ var createNodeFrom = {};
478
+
479
+ var cloneLocation = {};
480
+
481
+ var hasRequiredCloneLocation;
482
+
483
+ function requireCloneLocation () {
484
+ if (hasRequiredCloneLocation) return cloneLocation;
485
+ hasRequiredCloneLocation = 1;
486
+ Object.defineProperty(cloneLocation, "__esModule", { value: true });
487
+ cloneLocation.cloneLocation = void 0;
488
+ function cloneLocation$1(loc) {
489
+ return {
490
+ start: {
491
+ line: loc.start.line,
492
+ column: loc.start.column,
493
+ },
494
+ end: {
495
+ line: loc.end.line,
496
+ column: loc.end.column,
497
+ },
498
+ };
499
+ }
500
+ cloneLocation.cloneLocation = cloneLocation$1;
501
+ return cloneLocation;
502
+ }
503
+
504
+ var hasRequiredCreateNodeFrom;
505
+
506
+ function requireCreateNodeFrom () {
507
+ if (hasRequiredCreateNodeFrom) return createNodeFrom;
508
+ hasRequiredCreateNodeFrom = 1;
509
+ Object.defineProperty(createNodeFrom, "__esModule", { value: true });
510
+ createNodeFrom.createNodeFrom = void 0;
511
+ const clone_location_1 = requireCloneLocation();
512
+ const clone_range_1 = requireCloneRange();
513
+ function createNodeFrom$1(token) {
514
+ const loc = (0, clone_location_1.cloneLocation)(token.loc);
515
+ const range = (0, clone_range_1.cloneRange)(token.range);
516
+ return {
517
+ type: token.type,
518
+ value: token.value,
519
+ loc,
520
+ range,
521
+ };
522
+ }
523
+ createNodeFrom.createNodeFrom = createNodeFrom$1;
524
+ return createNodeFrom;
525
+ }
526
+
527
+ var updateNodeEnd = {};
528
+
529
+ var hasRequiredUpdateNodeEnd;
530
+
531
+ function requireUpdateNodeEnd () {
532
+ if (hasRequiredUpdateNodeEnd) return updateNodeEnd;
533
+ hasRequiredUpdateNodeEnd = 1;
534
+ Object.defineProperty(updateNodeEnd, "__esModule", { value: true });
535
+ updateNodeEnd.updateNodeEnd = void 0;
536
+ function updateNodeEnd$1(node, token) {
537
+ node.range[1] = token.range[1];
538
+ node.loc.end = Object.assign({}, token.loc.end);
539
+ }
540
+ updateNodeEnd.updateNodeEnd = updateNodeEnd$1;
541
+ return updateNodeEnd;
542
+ }
543
+
544
+ var first = {};
545
+
546
+ var hasRequiredFirst;
547
+
548
+ function requireFirst () {
549
+ if (hasRequiredFirst) return first;
550
+ hasRequiredFirst = 1;
551
+ Object.defineProperty(first, "__esModule", { value: true });
552
+ first.first = void 0;
553
+ function first$1(items) {
554
+ return items[0];
555
+ }
556
+ first.first = first$1;
557
+ return first;
558
+ }
559
+
560
+ var initIfNone = {};
561
+
562
+ var hasRequiredInitIfNone;
563
+
564
+ function requireInitIfNone () {
565
+ if (hasRequiredInitIfNone) return initIfNone;
566
+ hasRequiredInitIfNone = 1;
567
+ Object.defineProperty(initIfNone, "__esModule", { value: true });
568
+ initIfNone.initAttributesIfNone = initIfNone.initChildrenIfNone = void 0;
569
+ function initChildrenIfNone(node) {
570
+ /* istanbul ignore next */
571
+ if (!node.children) {
572
+ node.children = [];
573
+ }
574
+ }
575
+ initIfNone.initChildrenIfNone = initChildrenIfNone;
576
+ function initAttributesIfNone(node) {
577
+ /* istanbul ignore next */
578
+ if (!node.attributes) {
579
+ node.attributes = [];
580
+ }
581
+ }
582
+ initIfNone.initAttributesIfNone = initAttributesIfNone;
583
+ return initIfNone;
584
+ }
585
+
586
+ var hasRequiredUtils;
587
+
588
+ function requireUtils () {
589
+ if (hasRequiredUtils) return utils;
590
+ hasRequiredUtils = 1;
591
+ (function (exports) {
592
+ var __createBinding = (utils && utils.__createBinding) || (Object.create ? (function(o, m, k, k2) {
593
+ if (k2 === undefined) k2 = k;
594
+ var desc = Object.getOwnPropertyDescriptor(m, k);
595
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
596
+ desc = { enumerable: true, get: function() { return m[k]; } };
597
+ }
598
+ Object.defineProperty(o, k2, desc);
599
+ }) : (function(o, m, k, k2) {
600
+ if (k2 === undefined) k2 = k;
601
+ o[k2] = m[k];
602
+ }));
603
+ var __exportStar = (utils && utils.__exportStar) || function(m, exports) {
604
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
605
+ };
606
+ Object.defineProperty(exports, "__esModule", { value: true });
607
+ __exportStar(requireCalculateTokenCharactersRange(), exports);
608
+ __exportStar(requireIsWhitespace(), exports);
609
+ __exportStar(requireParseOpenTagName(), exports);
610
+ __exportStar(requireParseCloseTagName(), exports);
611
+ __exportStar(requireClearParent(), exports);
612
+ __exportStar(requireCalculateTokenLocation(), exports);
613
+ __exportStar(requireCalculateTokenPosition(), exports);
614
+ __exportStar(requireLast(), exports);
615
+ __exportStar(requireCloneRange(), exports);
616
+ __exportStar(requireCreateNodeFrom(), exports);
617
+ __exportStar(requireUpdateNodeEnd(), exports);
618
+ __exportStar(requireGetLineInfo(), exports);
619
+ __exportStar(requireFirst(), exports);
620
+ __exportStar(requireCloneLocation(), exports);
621
+ __exportStar(requireInitIfNone(), exports);
622
+ } (utils));
623
+ return utils;
624
+ }
625
+
626
+ var handlers$1 = {};
627
+
628
+ var attributeValue$1 = {};
629
+
630
+ var hasRequiredAttributeValue$1;
631
+
632
+ function requireAttributeValue$1 () {
633
+ if (hasRequiredAttributeValue$1) return attributeValue$1;
634
+ hasRequiredAttributeValue$1 = 1;
635
+ Object.defineProperty(attributeValue$1, "__esModule", { value: true });
636
+ attributeValue$1.construct = void 0;
637
+ const constants_1 = requireConstants();
638
+ const utils_1 = requireUtils();
639
+ const VALUE_END_TOKENS = [
640
+ constants_1.TokenTypes.OpenTagEnd,
641
+ constants_1.TokenTypes.AttributeKey,
642
+ constants_1.TokenTypes.AttributeAssignment,
643
+ constants_1.TokenTypes.OpenScriptTagEnd,
644
+ constants_1.TokenTypes.OpenStyleTagEnd,
645
+ ];
646
+ function getLastAttribute(state) {
647
+ const attributes = state.currentNode.attributes;
648
+ return attributes[attributes.length - 1];
649
+ }
650
+ function handleValueEnd(state) {
651
+ state.currentContext = state.currentContext.parentRef;
652
+ return state;
653
+ }
654
+ function handleAttributeValue(state, token) {
655
+ const attribute = getLastAttribute(state);
656
+ attribute.value = (0, utils_1.createNodeFrom)(token);
657
+ state.caretPosition++;
658
+ return state;
659
+ }
660
+ function handleAttributeValueWrapperStart(state, token) {
661
+ const attribute = getLastAttribute(state);
662
+ attribute.startWrapper = (0, utils_1.createNodeFrom)(token);
663
+ if (!attribute.key) {
664
+ attribute.range = (0, utils_1.cloneRange)(token.range);
665
+ attribute.loc = (0, utils_1.cloneLocation)(token.loc);
666
+ }
667
+ state.caretPosition++;
668
+ return state;
669
+ }
670
+ function handleAttributeValueWrapperEnd(state, token) {
671
+ const attribute = getLastAttribute(state);
672
+ attribute.endWrapper = (0, utils_1.createNodeFrom)(token);
673
+ (0, utils_1.updateNodeEnd)(attribute, token);
674
+ state.caretPosition++;
675
+ return state;
676
+ }
677
+ function construct(token, state) {
678
+ if (VALUE_END_TOKENS.indexOf(token.type) !== -1) {
679
+ return handleValueEnd(state);
680
+ }
681
+ if (token.type === constants_1.TokenTypes.AttributeValue) {
682
+ return handleAttributeValue(state, token);
683
+ }
684
+ if (token.type === constants_1.TokenTypes.AttributeValueWrapperStart) {
685
+ return handleAttributeValueWrapperStart(state, token);
686
+ }
687
+ if (token.type === constants_1.TokenTypes.AttributeValueWrapperEnd) {
688
+ return handleAttributeValueWrapperEnd(state, token);
689
+ }
690
+ state.caretPosition++;
691
+ return state;
692
+ }
693
+ attributeValue$1.construct = construct;
694
+ return attributeValue$1;
695
+ }
696
+
697
+ var attributes$1 = {};
698
+
699
+ var hasRequiredAttributes$1;
700
+
701
+ function requireAttributes$1 () {
702
+ if (hasRequiredAttributes$1) return attributes$1;
703
+ hasRequiredAttributes$1 = 1;
704
+ Object.defineProperty(attributes$1, "__esModule", { value: true });
705
+ attributes$1.construct = void 0;
706
+ const constants_1 = requireConstants();
707
+ const utils_1 = requireUtils();
708
+ const ATTRIBUTE_START_TOKENS = [
709
+ constants_1.TokenTypes.AttributeKey,
710
+ constants_1.TokenTypes.AttributeAssignment,
711
+ ];
712
+ const ATTRIBUTES_END_TOKENS = [
713
+ constants_1.TokenTypes.OpenTagEnd,
714
+ constants_1.TokenTypes.OpenStyleTagEnd,
715
+ constants_1.TokenTypes.OpenScriptTagEnd,
716
+ ];
717
+ function handlerAttributeStart(state, token) {
718
+ (0, utils_1.initAttributesIfNone)(state.currentNode);
719
+ // new empty attribute
720
+ state.currentNode.attributes.push({
721
+ type: constants_1.NodeTypes.Attribute,
722
+ range: (0, utils_1.cloneRange)(token.range),
723
+ loc: (0, utils_1.cloneLocation)(token.loc),
724
+ });
725
+ state.currentContext = {
726
+ parentRef: state.currentContext,
727
+ type: constants_1.ConstructTreeContextTypes.Attribute,
728
+ };
729
+ return state;
730
+ }
731
+ function handleOpenTagEnd(state) {
732
+ state.currentContext = state.currentContext.parentRef;
733
+ return state;
734
+ }
735
+ function construct(token, state) {
736
+ if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
737
+ return handlerAttributeStart(state, token);
738
+ }
739
+ if (ATTRIBUTES_END_TOKENS.indexOf(token.type) !== -1) {
740
+ return handleOpenTagEnd(state);
741
+ }
742
+ state.caretPosition++;
743
+ return state;
744
+ }
745
+ attributes$1.construct = construct;
746
+ return attributes$1;
747
+ }
748
+
749
+ var attribute = {};
750
+
751
+ var hasRequiredAttribute;
752
+
753
+ function requireAttribute () {
754
+ if (hasRequiredAttribute) return attribute;
755
+ hasRequiredAttribute = 1;
756
+ Object.defineProperty(attribute, "__esModule", { value: true });
757
+ attribute.construct = void 0;
758
+ const constants_1 = requireConstants();
759
+ const utils_1 = requireUtils();
760
+ const OPEN_TAG_END_TOKENS = [
761
+ constants_1.TokenTypes.OpenTagEnd,
762
+ constants_1.TokenTypes.OpenScriptTagEnd,
763
+ constants_1.TokenTypes.OpenStyleTagEnd,
764
+ ];
765
+ function getLastAttribute(state) {
766
+ const attributes = state.currentNode.attributes;
767
+ return attributes[attributes.length - 1];
768
+ }
769
+ function handleOpenTagEnd(state) {
770
+ state.currentContext = state.currentContext.parentRef;
771
+ return state;
772
+ }
773
+ function handleAttributeKey(state, token) {
774
+ const attribute = getLastAttribute(state);
775
+ if (attribute.key !== undefined || attribute.value !== undefined) {
776
+ state.currentContext = state.currentContext.parentRef;
777
+ return state;
778
+ }
779
+ attribute.key = (0, utils_1.createNodeFrom)(token);
780
+ state.caretPosition++;
781
+ return state;
782
+ }
783
+ function handleAttributeAssignment(state) {
784
+ const attribute = getLastAttribute(state);
785
+ if (attribute.value !== undefined) {
786
+ state.currentContext = state.currentContext.parentRef;
787
+ return state;
788
+ }
789
+ state.currentContext = {
790
+ parentRef: state.currentContext,
791
+ type: constants_1.ConstructTreeContextTypes.AttributeValue,
792
+ };
793
+ state.caretPosition++;
794
+ return state;
795
+ }
796
+ function construct(token, state) {
797
+ if (OPEN_TAG_END_TOKENS.indexOf(token.type) !== -1) {
798
+ return handleOpenTagEnd(state);
799
+ }
800
+ if (token.type === constants_1.TokenTypes.AttributeKey) {
801
+ return handleAttributeKey(state, token);
802
+ }
803
+ if (token.type === constants_1.TokenTypes.AttributeAssignment) {
804
+ return handleAttributeAssignment(state);
805
+ }
806
+ state.caretPosition++;
807
+ return state;
808
+ }
809
+ attribute.construct = construct;
810
+ return attribute;
811
+ }
812
+
813
+ var comment = {};
814
+
815
+ var hasRequiredComment;
816
+
817
+ function requireComment () {
818
+ if (hasRequiredComment) return comment;
819
+ hasRequiredComment = 1;
820
+ Object.defineProperty(comment, "__esModule", { value: true });
821
+ comment.construct = void 0;
822
+ const constants_1 = requireConstants();
823
+ const utils_1 = requireUtils();
824
+ function handleCommentOpen(state, token) {
825
+ state.currentNode.open = (0, utils_1.createNodeFrom)(token);
826
+ state.caretPosition++;
827
+ return state;
828
+ }
829
+ function handleCommentContent(state, token) {
830
+ state.currentNode.value = (0, utils_1.createNodeFrom)(token);
831
+ state.caretPosition++;
832
+ return state;
833
+ }
834
+ function handleCommentClose(state, token) {
835
+ state.currentNode.close = (0, utils_1.createNodeFrom)(token);
836
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
837
+ state.currentNode = state.currentNode.parentRef;
838
+ state.currentContext = state.currentContext.parentRef;
839
+ state.caretPosition++;
840
+ return state;
841
+ }
842
+ function construct(token, state) {
843
+ if (token.type === constants_1.TokenTypes.CommentOpen) {
844
+ return handleCommentOpen(state, token);
845
+ }
846
+ if (token.type === constants_1.TokenTypes.CommentContent) {
847
+ return handleCommentContent(state, token);
848
+ }
849
+ if (token.type === constants_1.TokenTypes.CommentClose) {
850
+ return handleCommentClose(state, token);
851
+ }
852
+ state.caretPosition++;
853
+ return state;
854
+ }
855
+ comment.construct = construct;
856
+ return comment;
857
+ }
858
+
859
+ var doctypeAttribute = {};
860
+
861
+ var hasRequiredDoctypeAttribute;
862
+
863
+ function requireDoctypeAttribute () {
864
+ if (hasRequiredDoctypeAttribute) return doctypeAttribute;
865
+ hasRequiredDoctypeAttribute = 1;
866
+ Object.defineProperty(doctypeAttribute, "__esModule", { value: true });
867
+ doctypeAttribute.construct = void 0;
868
+ const constants_1 = requireConstants();
869
+ const utils_1 = requireUtils();
870
+ function getLastAttribute(state) {
871
+ const attributes = state.currentNode.attributes;
872
+ return attributes[attributes.length - 1];
873
+ }
874
+ function handleDoctypeClose(state) {
875
+ state.currentContext = state.currentContext.parentRef;
876
+ return state;
877
+ }
878
+ function handleAttributeValue(state, token) {
879
+ const attribute = getLastAttribute(state);
880
+ if (attribute.value !== undefined) {
881
+ state.currentContext = state.currentContext.parentRef;
882
+ return state;
883
+ }
884
+ attribute.value = (0, utils_1.createNodeFrom)(token);
885
+ if (!attribute.startWrapper) {
886
+ attribute.range = (0, utils_1.cloneRange)(token.range);
887
+ }
888
+ state.caretPosition++;
889
+ return state;
890
+ }
891
+ function handleAttributeWrapperStart(state, token) {
892
+ const attribute = getLastAttribute(state);
893
+ if (attribute.value !== undefined) {
894
+ state.currentContext = state.currentContext.parentRef;
895
+ return state;
896
+ }
897
+ attribute.startWrapper = (0, utils_1.createNodeFrom)(token);
898
+ attribute.range = (0, utils_1.cloneRange)(token.range);
899
+ state.caretPosition++;
900
+ return state;
901
+ }
902
+ function handleAttributeWrapperEnd(state, token) {
903
+ const attribute = getLastAttribute(state);
904
+ attribute.endWrapper = (0, utils_1.createNodeFrom)(token);
905
+ (0, utils_1.updateNodeEnd)(attribute, token);
906
+ state.currentContext = state.currentContext.parentRef;
907
+ state.caretPosition++;
908
+ return state;
909
+ }
910
+ function construct(token, state) {
911
+ if (token.type === constants_1.TokenTypes.DoctypeClose) {
912
+ return handleDoctypeClose(state);
913
+ }
914
+ if (token.type === constants_1.TokenTypes.DoctypeAttributeWrapperStart) {
915
+ return handleAttributeWrapperStart(state, token);
916
+ }
917
+ if (token.type === constants_1.TokenTypes.DoctypeAttributeWrapperEnd) {
918
+ return handleAttributeWrapperEnd(state, token);
919
+ }
920
+ if (token.type === constants_1.TokenTypes.DoctypeAttributeValue) {
921
+ return handleAttributeValue(state, token);
922
+ }
923
+ state.caretPosition++;
924
+ return state;
925
+ }
926
+ doctypeAttribute.construct = construct;
927
+ return doctypeAttribute;
928
+ }
929
+
930
+ var doctypeAttributes$1 = {};
931
+
932
+ var hasRequiredDoctypeAttributes$1;
933
+
934
+ function requireDoctypeAttributes$1 () {
935
+ if (hasRequiredDoctypeAttributes$1) return doctypeAttributes$1;
936
+ hasRequiredDoctypeAttributes$1 = 1;
937
+ Object.defineProperty(doctypeAttributes$1, "__esModule", { value: true });
938
+ doctypeAttributes$1.construct = void 0;
939
+ const constants_1 = requireConstants();
940
+ const utils_1 = requireUtils();
941
+ const ATTRIBUTE_START_TOKENS = [
942
+ constants_1.TokenTypes.DoctypeAttributeWrapperStart,
943
+ constants_1.TokenTypes.DoctypeAttributeValue,
944
+ ];
945
+ function handleDoctypeClose(state) {
946
+ state.currentContext = state.currentContext.parentRef;
947
+ return state;
948
+ }
949
+ function handleAttribute(state, token) {
950
+ (0, utils_1.initAttributesIfNone)(state.currentNode);
951
+ // new empty attribute
952
+ state.currentNode.attributes.push({
953
+ type: constants_1.NodeTypes.DoctypeAttribute,
954
+ range: (0, utils_1.cloneRange)(token.range),
955
+ loc: (0, utils_1.cloneLocation)(token.loc),
956
+ });
957
+ state.currentContext = {
958
+ type: constants_1.ConstructTreeContextTypes.DoctypeAttribute,
959
+ parentRef: state.currentContext,
960
+ };
961
+ return state;
962
+ }
963
+ function construct(token, state) {
964
+ if (token.type === constants_1.TokenTypes.DoctypeClose) {
965
+ return handleDoctypeClose(state);
966
+ }
967
+ if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
968
+ return handleAttribute(state, token);
969
+ }
970
+ state.caretPosition++;
971
+ return state;
972
+ }
973
+ doctypeAttributes$1.construct = construct;
974
+ return doctypeAttributes$1;
975
+ }
976
+
977
+ var doctype = {};
978
+
979
+ var hasRequiredDoctype;
980
+
981
+ function requireDoctype () {
982
+ if (hasRequiredDoctype) return doctype;
983
+ hasRequiredDoctype = 1;
984
+ Object.defineProperty(doctype, "__esModule", { value: true });
985
+ doctype.construct = void 0;
986
+ const constants_1 = requireConstants();
987
+ const utils_1 = requireUtils();
988
+ const ATTRIBUTES_START_TOKENS = [
989
+ constants_1.TokenTypes.DoctypeAttributeWrapperStart,
990
+ constants_1.TokenTypes.DoctypeAttributeValue,
991
+ ];
992
+ function handleDoctypeOpen(state, token) {
993
+ state.currentNode.open = (0, utils_1.createNodeFrom)(token);
994
+ state.caretPosition++;
995
+ return state;
996
+ }
997
+ function handleDoctypeClose(state, token) {
998
+ state.currentNode.close = (0, utils_1.createNodeFrom)(token);
999
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1000
+ state.currentNode = state.currentNode.parentRef;
1001
+ state.currentContext = state.currentContext.parentRef;
1002
+ state.caretPosition++;
1003
+ return state;
1004
+ }
1005
+ function handleDoctypeAttributes(state) {
1006
+ state.currentContext = {
1007
+ parentRef: state.currentContext,
1008
+ type: constants_1.ConstructTreeContextTypes.DoctypeAttributes,
1009
+ };
1010
+ return state;
1011
+ }
1012
+ function construct(token, state) {
1013
+ if (token.type === constants_1.TokenTypes.DoctypeOpen) {
1014
+ return handleDoctypeOpen(state, token);
1015
+ }
1016
+ if (token.type === constants_1.TokenTypes.DoctypeClose) {
1017
+ return handleDoctypeClose(state, token);
1018
+ }
1019
+ if (ATTRIBUTES_START_TOKENS.indexOf(token.type) !== -1) {
1020
+ return handleDoctypeAttributes(state);
1021
+ }
1022
+ state.caretPosition++;
1023
+ return state;
1024
+ }
1025
+ doctype.construct = construct;
1026
+ return doctype;
1027
+ }
1028
+
1029
+ var scriptTag = {};
1030
+
1031
+ var hasRequiredScriptTag;
1032
+
1033
+ function requireScriptTag () {
1034
+ if (hasRequiredScriptTag) return scriptTag;
1035
+ hasRequiredScriptTag = 1;
1036
+ Object.defineProperty(scriptTag, "__esModule", { value: true });
1037
+ scriptTag.construct = void 0;
1038
+ const constants_1 = requireConstants();
1039
+ const utils_1 = requireUtils();
1040
+ const ATTRIBUTE_START_TOKENS = [
1041
+ constants_1.TokenTypes.AttributeKey,
1042
+ constants_1.TokenTypes.AttributeAssignment,
1043
+ ];
1044
+ function handleOpenScriptTagStart(state, token) {
1045
+ state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1046
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1047
+ state.caretPosition++;
1048
+ return state;
1049
+ }
1050
+ function handleAttributeStartScript(state) {
1051
+ state.currentContext = {
1052
+ parentRef: state.currentContext,
1053
+ type: constants_1.ConstructTreeContextTypes.Attributes,
1054
+ };
1055
+ return state;
1056
+ }
1057
+ function handleOpenScriptTagEnd(state, token) {
1058
+ state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1059
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1060
+ state.caretPosition++;
1061
+ return state;
1062
+ }
1063
+ function handleScriptContent(state, token) {
1064
+ state.currentNode.value = (0, utils_1.createNodeFrom)(token);
1065
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1066
+ state.caretPosition++;
1067
+ return state;
1068
+ }
1069
+ function handleCloseScriptTag(state, token) {
1070
+ state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1071
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1072
+ state.currentNode = state.currentNode.parentRef;
1073
+ state.currentContext = state.currentContext.parentRef;
1074
+ state.caretPosition++;
1075
+ return state;
1076
+ }
1077
+ function construct(token, state) {
1078
+ if (token.type === constants_1.TokenTypes.OpenScriptTagStart) {
1079
+ return handleOpenScriptTagStart(state, token);
1080
+ }
1081
+ if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1082
+ return handleAttributeStartScript(state);
1083
+ }
1084
+ if (token.type === constants_1.TokenTypes.OpenScriptTagEnd) {
1085
+ return handleOpenScriptTagEnd(state, token);
1086
+ }
1087
+ if (token.type === constants_1.TokenTypes.ScriptTagContent) {
1088
+ return handleScriptContent(state, token);
1089
+ }
1090
+ if (token.type === constants_1.TokenTypes.CloseScriptTag) {
1091
+ return handleCloseScriptTag(state, token);
1092
+ }
1093
+ state.caretPosition++;
1094
+ return state;
1095
+ }
1096
+ scriptTag.construct = construct;
1097
+ return scriptTag;
1098
+ }
1099
+
1100
+ var styleTag = {};
1101
+
1102
+ var hasRequiredStyleTag;
1103
+
1104
+ function requireStyleTag () {
1105
+ if (hasRequiredStyleTag) return styleTag;
1106
+ hasRequiredStyleTag = 1;
1107
+ Object.defineProperty(styleTag, "__esModule", { value: true });
1108
+ styleTag.construct = void 0;
1109
+ const constants_1 = requireConstants();
1110
+ const utils_1 = requireUtils();
1111
+ const ATTRIBUTE_START_TOKENS = [
1112
+ constants_1.TokenTypes.AttributeKey,
1113
+ constants_1.TokenTypes.AttributeAssignment,
1114
+ ];
1115
+ function handleOpenStyleTagStart(state, token) {
1116
+ state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1117
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1118
+ state.caretPosition++;
1119
+ return state;
1120
+ }
1121
+ function handleAttributeStartStyle(state) {
1122
+ state.currentContext = {
1123
+ parentRef: state.currentContext,
1124
+ type: constants_1.ConstructTreeContextTypes.Attributes,
1125
+ };
1126
+ return state;
1127
+ }
1128
+ function handleOpenStyleTagEnd(state, token) {
1129
+ state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1130
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1131
+ state.caretPosition++;
1132
+ return state;
1133
+ }
1134
+ function handleStyleContent(state, token) {
1135
+ state.currentNode.value = (0, utils_1.createNodeFrom)(token);
1136
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1137
+ state.caretPosition++;
1138
+ return state;
1139
+ }
1140
+ function handleCloseStyleTag(state, token) {
1141
+ state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1142
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1143
+ state.currentNode = state.currentNode.parentRef;
1144
+ state.currentContext = state.currentContext.parentRef;
1145
+ state.caretPosition++;
1146
+ return state;
1147
+ }
1148
+ function construct(token, state) {
1149
+ if (token.type === constants_1.TokenTypes.OpenStyleTagStart) {
1150
+ return handleOpenStyleTagStart(state, token);
1151
+ }
1152
+ if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1153
+ return handleAttributeStartStyle(state);
1154
+ }
1155
+ if (token.type === constants_1.TokenTypes.OpenStyleTagEnd) {
1156
+ return handleOpenStyleTagEnd(state, token);
1157
+ }
1158
+ if (token.type === constants_1.TokenTypes.StyleTagContent) {
1159
+ return handleStyleContent(state, token);
1160
+ }
1161
+ if (token.type === constants_1.TokenTypes.CloseStyleTag) {
1162
+ return handleCloseStyleTag(state, token);
1163
+ }
1164
+ state.caretPosition++;
1165
+ return state;
1166
+ }
1167
+ styleTag.construct = construct;
1168
+ return styleTag;
1169
+ }
1170
+
1171
+ var tagContent = {};
1172
+
1173
+ var hasRequiredTagContent;
1174
+
1175
+ function requireTagContent () {
1176
+ if (hasRequiredTagContent) return tagContent;
1177
+ hasRequiredTagContent = 1;
1178
+ Object.defineProperty(tagContent, "__esModule", { value: true });
1179
+ tagContent.construct = void 0;
1180
+ const constants_1 = requireConstants();
1181
+ const utils_1 = requireUtils();
1182
+ function handleOpenTagStart(state, token) {
1183
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1184
+ const tagNode = {
1185
+ type: constants_1.NodeTypes.Tag,
1186
+ parentRef: state.currentNode,
1187
+ range: (0, utils_1.cloneRange)(token.range),
1188
+ loc: (0, utils_1.cloneLocation)(token.loc),
1189
+ attributes: [],
1190
+ children: [],
1191
+ };
1192
+ state.currentNode.children.push(tagNode);
1193
+ state.currentNode = tagNode;
1194
+ state.currentContext = {
1195
+ parentRef: state.currentContext,
1196
+ type: constants_1.ConstructTreeContextTypes.Tag,
1197
+ };
1198
+ return state;
1199
+ }
1200
+ function handleCloseTag(state, token) {
1201
+ const closeTagName = (0, utils_1.parseCloseTagName)(token.value);
1202
+ if (closeTagName !== state.currentNode.name) {
1203
+ state.caretPosition++;
1204
+ return state;
1205
+ }
1206
+ state.currentContext = state.currentContext.parentRef;
1207
+ return state;
1208
+ }
1209
+ function handleCommentOpen(state, token) {
1210
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1211
+ const commentNode = {
1212
+ type: constants_1.NodeTypes.Comment,
1213
+ parentRef: state.currentNode,
1214
+ range: (0, utils_1.cloneRange)(token.range),
1215
+ loc: (0, utils_1.cloneLocation)(token.loc),
1216
+ };
1217
+ state.currentNode.children.push(commentNode);
1218
+ // @ts-ignore
1219
+ state.currentNode = commentNode;
1220
+ state.currentContext = {
1221
+ parentRef: state.currentContext,
1222
+ type: constants_1.ConstructTreeContextTypes.Comment,
1223
+ };
1224
+ return state;
1225
+ }
1226
+ function handleDoctypeOpen(state, token) {
1227
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1228
+ const doctypeNode = {
1229
+ type: constants_1.NodeTypes.Doctype,
1230
+ parentRef: state.currentNode,
1231
+ range: (0, utils_1.cloneRange)(token.range),
1232
+ loc: (0, utils_1.cloneLocation)(token.loc),
1233
+ attributes: [],
1234
+ };
1235
+ state.currentNode.children.push(doctypeNode);
1236
+ // @ts-ignore
1237
+ state.currentNode = doctypeNode;
1238
+ state.currentContext = {
1239
+ parentRef: state.currentContext,
1240
+ type: constants_1.ConstructTreeContextTypes.Doctype,
1241
+ };
1242
+ return state;
1243
+ }
1244
+ function handleText(state, token) {
1245
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1246
+ const textNode = (0, utils_1.createNodeFrom)(token);
1247
+ state.currentNode.children.push(textNode);
1248
+ state.caretPosition++;
1249
+ return state;
1250
+ }
1251
+ function handleOpenScriptTagStart(state, token) {
1252
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1253
+ const scriptNode = {
1254
+ type: constants_1.NodeTypes.ScriptTag,
1255
+ parentRef: state.currentNode,
1256
+ range: (0, utils_1.cloneRange)(token.range),
1257
+ loc: (0, utils_1.cloneLocation)(token.loc),
1258
+ attributes: [],
1259
+ };
1260
+ state.currentNode.children.push(scriptNode);
1261
+ // @ts-ignore
1262
+ state.currentNode = scriptNode;
1263
+ state.currentContext = {
1264
+ type: constants_1.ConstructTreeContextTypes.ScriptTag,
1265
+ parentRef: state.currentContext,
1266
+ };
1267
+ return state;
1268
+ }
1269
+ function handleOpenStyleTagStart(state, token) {
1270
+ (0, utils_1.initChildrenIfNone)(state.currentNode);
1271
+ const styleNode = {
1272
+ type: constants_1.NodeTypes.StyleTag,
1273
+ parentRef: state.currentNode,
1274
+ range: (0, utils_1.cloneRange)(token.range),
1275
+ loc: (0, utils_1.cloneLocation)(token.loc),
1276
+ attributes: [],
1277
+ };
1278
+ state.currentNode.children.push(styleNode);
1279
+ // @ts-ignore
1280
+ state.currentNode = styleNode;
1281
+ state.currentContext = {
1282
+ type: constants_1.ConstructTreeContextTypes.StyleTag,
1283
+ parentRef: state.currentContext,
1284
+ };
1285
+ return state;
1286
+ }
1287
+ function construct(token, state) {
1288
+ if (token.type === constants_1.TokenTypes.OpenScriptTagStart) {
1289
+ return handleOpenScriptTagStart(state, token);
1290
+ }
1291
+ if (token.type === constants_1.TokenTypes.OpenStyleTagStart) {
1292
+ return handleOpenStyleTagStart(state, token);
1293
+ }
1294
+ if (token.type === constants_1.TokenTypes.OpenTagStart) {
1295
+ return handleOpenTagStart(state, token);
1296
+ }
1297
+ if (token.type === constants_1.TokenTypes.Text) {
1298
+ return handleText(state, token);
1299
+ }
1300
+ if (token.type === constants_1.TokenTypes.CloseTag) {
1301
+ return handleCloseTag(state, token);
1302
+ }
1303
+ if (token.type === constants_1.TokenTypes.CommentOpen) {
1304
+ return handleCommentOpen(state, token);
1305
+ }
1306
+ if (token.type === constants_1.TokenTypes.DoctypeOpen) {
1307
+ return handleDoctypeOpen(state, token);
1308
+ }
1309
+ state.caretPosition++;
1310
+ return state;
1311
+ }
1312
+ tagContent.construct = construct;
1313
+ return tagContent;
1314
+ }
1315
+
1316
+ var tagName = {};
1317
+
1318
+ var hasRequiredTagName;
1319
+
1320
+ function requireTagName () {
1321
+ if (hasRequiredTagName) return tagName;
1322
+ hasRequiredTagName = 1;
1323
+ Object.defineProperty(tagName, "__esModule", { value: true });
1324
+ tagName.construct = void 0;
1325
+ const constants_1 = requireConstants();
1326
+ const utils_1 = requireUtils();
1327
+ function handleTagOpenStart(state, token) {
1328
+ state.currentNode.name = (0, utils_1.parseOpenTagName)(token.value);
1329
+ state.currentContext = state.currentContext.parentRef;
1330
+ return state;
1331
+ }
1332
+ function construct(token, state) {
1333
+ if (token.type === constants_1.TokenTypes.OpenTagStart) {
1334
+ handleTagOpenStart(state, token);
1335
+ }
1336
+ state.caretPosition++;
1337
+ return state;
1338
+ }
1339
+ tagName.construct = construct;
1340
+ return tagName;
1341
+ }
1342
+
1343
+ var tag = {};
1344
+
1345
+ var hasRequiredTag;
1346
+
1347
+ function requireTag () {
1348
+ if (hasRequiredTag) return tag;
1349
+ hasRequiredTag = 1;
1350
+ Object.defineProperty(tag, "__esModule", { value: true });
1351
+ tag.construct = void 0;
1352
+ const constants_1 = requireConstants();
1353
+ const utils_1 = requireUtils();
1354
+ const ATTRIBUTE_START_TOKENS = [
1355
+ constants_1.TokenTypes.AttributeKey,
1356
+ constants_1.TokenTypes.AttributeAssignment,
1357
+ ];
1358
+ const SELF_CLOSING_TAGS = [
1359
+ "area",
1360
+ "base",
1361
+ "br",
1362
+ "col",
1363
+ "embed",
1364
+ "hr",
1365
+ "img",
1366
+ "input",
1367
+ "keygen",
1368
+ "link",
1369
+ "meta",
1370
+ "param",
1371
+ "source",
1372
+ "track",
1373
+ "wbr",
1374
+ ];
1375
+ function handleOpenTagStart(state, token) {
1376
+ state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1377
+ state.currentContext = {
1378
+ parentRef: state.currentContext,
1379
+ type: constants_1.ConstructTreeContextTypes.TagName,
1380
+ };
1381
+ return state;
1382
+ }
1383
+ function handleAttributeStart(state) {
1384
+ state.currentContext = {
1385
+ parentRef: state.currentContext,
1386
+ type: constants_1.ConstructTreeContextTypes.Attributes,
1387
+ };
1388
+ return state;
1389
+ }
1390
+ function handleOpenTagEnd(state, token) {
1391
+ const tagName = state.currentNode.name;
1392
+ state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1393
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1394
+ if (SELF_CLOSING_TAGS.indexOf(tagName) !== -1 ||
1395
+ state.currentNode.openEnd.value === "/>") {
1396
+ state.currentNode.selfClosing = true;
1397
+ state.currentNode = state.currentNode.parentRef;
1398
+ state.currentContext = state.currentContext.parentRef;
1399
+ state.caretPosition++;
1400
+ return state;
1401
+ }
1402
+ state.currentNode.selfClosing = false;
1403
+ state.currentContext = {
1404
+ parentRef: state.currentContext,
1405
+ type: constants_1.ConstructTreeContextTypes.TagContent,
1406
+ };
1407
+ state.caretPosition++;
1408
+ return state;
1409
+ }
1410
+ function handleCloseTag(state, token) {
1411
+ state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1412
+ (0, utils_1.updateNodeEnd)(state.currentNode, token);
1413
+ state.currentNode = state.currentNode.parentRef;
1414
+ state.currentContext = state.currentContext.parentRef;
1415
+ state.caretPosition++;
1416
+ return state;
1417
+ }
1418
+ function construct(token, state) {
1419
+ if (token.type === constants_1.TokenTypes.OpenTagStart) {
1420
+ return handleOpenTagStart(state, token);
1421
+ }
1422
+ if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1423
+ return handleAttributeStart(state);
1424
+ }
1425
+ if (token.type === constants_1.TokenTypes.OpenTagEnd) {
1426
+ return handleOpenTagEnd(state, token);
1427
+ }
1428
+ if (token.type === constants_1.TokenTypes.CloseTag) {
1429
+ return handleCloseTag(state, token);
1430
+ }
1431
+ state.caretPosition++;
1432
+ return state;
1433
+ }
1434
+ tag.construct = construct;
1435
+ return tag;
1436
+ }
1437
+
1438
+ var hasRequiredHandlers$1;
1439
+
1440
+ function requireHandlers$1 () {
1441
+ if (hasRequiredHandlers$1) return handlers$1;
1442
+ hasRequiredHandlers$1 = 1;
1443
+ var __createBinding = (handlers$1 && handlers$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1444
+ if (k2 === undefined) k2 = k;
1445
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1446
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1447
+ desc = { enumerable: true, get: function() { return m[k]; } };
1448
+ }
1449
+ Object.defineProperty(o, k2, desc);
1450
+ }) : (function(o, m, k, k2) {
1451
+ if (k2 === undefined) k2 = k;
1452
+ o[k2] = m[k];
1453
+ }));
1454
+ var __setModuleDefault = (handlers$1 && handlers$1.__setModuleDefault) || (Object.create ? (function(o, v) {
1455
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1456
+ }) : function(o, v) {
1457
+ o["default"] = v;
1458
+ });
1459
+ var __importStar = (handlers$1 && handlers$1.__importStar) || function (mod) {
1460
+ if (mod && mod.__esModule) return mod;
1461
+ var result = {};
1462
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1463
+ __setModuleDefault(result, mod);
1464
+ return result;
1465
+ };
1466
+ Object.defineProperty(handlers$1, "__esModule", { value: true });
1467
+ handlers$1.tag = handlers$1.tagName = handlers$1.tagContent = handlers$1.styleTag = handlers$1.scriptTag = handlers$1.doctype = handlers$1.doctypeAttributes = handlers$1.doctypeAttribute = handlers$1.comment = handlers$1.attribute = handlers$1.attributes = handlers$1.attributeValue = void 0;
1468
+ handlers$1.attributeValue = __importStar(requireAttributeValue$1());
1469
+ handlers$1.attributes = __importStar(requireAttributes$1());
1470
+ handlers$1.attribute = __importStar(requireAttribute());
1471
+ handlers$1.comment = __importStar(requireComment());
1472
+ handlers$1.doctypeAttribute = __importStar(requireDoctypeAttribute());
1473
+ handlers$1.doctypeAttributes = __importStar(requireDoctypeAttributes$1());
1474
+ handlers$1.doctype = __importStar(requireDoctype());
1475
+ handlers$1.scriptTag = __importStar(requireScriptTag());
1476
+ handlers$1.styleTag = __importStar(requireStyleTag());
1477
+ handlers$1.tagContent = __importStar(requireTagContent());
1478
+ handlers$1.tagName = __importStar(requireTagName());
1479
+ handlers$1.tag = __importStar(requireTag());
1480
+ return handlers$1;
1481
+ }
1482
+
1483
+ var hasRequiredConstructTree;
1484
+
1485
+ function requireConstructTree () {
1486
+ if (hasRequiredConstructTree) return constructTree;
1487
+ hasRequiredConstructTree = 1;
1488
+ Object.defineProperty(constructTree, "__esModule", { value: true });
1489
+ constructTree.constructTree = void 0;
1490
+ const constants_1 = requireConstants();
1491
+ const utils_1 = requireUtils();
1492
+ const clone_location_1 = requireCloneLocation();
1493
+ const handlers_1 = requireHandlers$1();
1494
+ const contextHandlers = {
1495
+ [constants_1.ConstructTreeContextTypes.TagContent]: handlers_1.tagContent,
1496
+ [constants_1.ConstructTreeContextTypes.Tag]: handlers_1.tag,
1497
+ [constants_1.ConstructTreeContextTypes.TagName]: handlers_1.tagName,
1498
+ [constants_1.ConstructTreeContextTypes.Attribute]: handlers_1.attribute,
1499
+ [constants_1.ConstructTreeContextTypes.Attributes]: handlers_1.attributes,
1500
+ [constants_1.ConstructTreeContextTypes.AttributeValue]: handlers_1.attributeValue,
1501
+ [constants_1.ConstructTreeContextTypes.Comment]: handlers_1.comment,
1502
+ [constants_1.ConstructTreeContextTypes.Doctype]: handlers_1.doctype,
1503
+ [constants_1.ConstructTreeContextTypes.DoctypeAttributes]: handlers_1.doctypeAttributes,
1504
+ [constants_1.ConstructTreeContextTypes.DoctypeAttribute]: handlers_1.doctypeAttribute,
1505
+ [constants_1.ConstructTreeContextTypes.ScriptTag]: handlers_1.scriptTag,
1506
+ [constants_1.ConstructTreeContextTypes.StyleTag]: handlers_1.styleTag,
1507
+ };
1508
+ const EMPTY_RANGE = [0, 0];
1509
+ const EMPTY_LOC = {
1510
+ start: {
1511
+ line: 1,
1512
+ column: 0,
1513
+ },
1514
+ end: {
1515
+ line: 1,
1516
+ column: 0,
1517
+ },
1518
+ };
1519
+ function constructTree$1(tokens, existingState) {
1520
+ let state = existingState;
1521
+ if (existingState === undefined) {
1522
+ const rootContext = {
1523
+ type: constants_1.ConstructTreeContextTypes.TagContent,
1524
+ parentRef: undefined,
1525
+ content: [],
1526
+ };
1527
+ const lastToken = (0, utils_1.last)(tokens);
1528
+ const firstToken = (0, utils_1.first)(tokens);
1529
+ const range = lastToken ? [0, lastToken.range[1]] : EMPTY_RANGE;
1530
+ const loc = lastToken
1531
+ ? {
1532
+ start: (0, clone_location_1.cloneLocation)(firstToken.loc).start,
1533
+ end: (0, clone_location_1.cloneLocation)(lastToken.loc).end,
1534
+ }
1535
+ : EMPTY_LOC;
1536
+ loc.start.line = 1;
1537
+ const rootNode = {
1538
+ type: constants_1.NodeTypes.Document,
1539
+ range,
1540
+ children: [],
1541
+ loc,
1542
+ };
1543
+ state = {
1544
+ caretPosition: 0,
1545
+ currentContext: rootContext,
1546
+ currentNode: rootNode,
1547
+ rootNode,
1548
+ };
1549
+ }
1550
+ const positionOffset = state.caretPosition;
1551
+ processTokens(tokens, state, positionOffset);
1552
+ return { state, ast: state.rootNode };
1553
+ }
1554
+ constructTree.constructTree = constructTree$1;
1555
+ function processTokens(tokens, state, positionOffset) {
1556
+ let tokenIndex = state.caretPosition - positionOffset;
1557
+ while (tokenIndex < tokens.length) {
1558
+ const token = tokens[tokenIndex];
1559
+ const handler = contextHandlers[state.currentContext.type].construct;
1560
+ state = handler(token, state);
1561
+ tokenIndex = state.caretPosition - positionOffset;
1562
+ }
1563
+ return state;
1564
+ }
1565
+ return constructTree;
1566
+ }
1567
+
1568
+ var hasRequiredTreeConstructor;
1569
+
1570
+ function requireTreeConstructor () {
1571
+ if (hasRequiredTreeConstructor) return treeConstructor;
1572
+ hasRequiredTreeConstructor = 1;
1573
+ (function (exports) {
1574
+ Object.defineProperty(exports, "__esModule", { value: true });
1575
+ exports.constructTree = void 0;
1576
+ var construct_tree_1 = requireConstructTree();
1577
+ Object.defineProperty(exports, "constructTree", { enumerable: true, get: function () { return construct_tree_1.constructTree; } });
1578
+ } (treeConstructor));
1579
+ return treeConstructor;
1580
+ }
1581
+
1582
+ var tokenizer = {};
1583
+
1584
+ var tokenize = {};
1585
+
1586
+ var handlers = {};
1587
+
1588
+ var attributeKey = {};
1589
+
1590
+ var hasRequiredAttributeKey;
1591
+
1592
+ function requireAttributeKey () {
1593
+ if (hasRequiredAttributeKey) return attributeKey;
1594
+ hasRequiredAttributeKey = 1;
1595
+ Object.defineProperty(attributeKey, "__esModule", { value: true });
1596
+ attributeKey.parse = void 0;
1597
+ const constants_1 = requireConstants();
1598
+ const token_types_1 = requireTokenTypes();
1599
+ const utils_1 = requireUtils();
1600
+ function parse(chars, state, tokens) {
1601
+ if (isKeyBreak(chars)) {
1602
+ return parseKeyEnd(state, tokens);
1603
+ }
1604
+ state.accumulatedContent += state.decisionBuffer;
1605
+ state.decisionBuffer = "";
1606
+ state.caretPosition++;
1607
+ }
1608
+ attributeKey.parse = parse;
1609
+ function isKeyBreak(chars) {
1610
+ return chars === "=" || chars === "/" || chars === ">" || (0, utils_1.isWhitespace)(chars);
1611
+ }
1612
+ function parseKeyEnd(state, tokens) {
1613
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1614
+ tokens.push({
1615
+ type: token_types_1.TokenTypes.AttributeKey,
1616
+ value: state.accumulatedContent,
1617
+ range: position.range,
1618
+ loc: position.loc,
1619
+ });
1620
+ state.accumulatedContent = "";
1621
+ state.decisionBuffer = "";
1622
+ state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1623
+ }
1624
+ return attributeKey;
1625
+ }
1626
+
1627
+ var attributeValueBare = {};
1628
+
1629
+ var hasRequiredAttributeValueBare;
1630
+
1631
+ function requireAttributeValueBare () {
1632
+ if (hasRequiredAttributeValueBare) return attributeValueBare;
1633
+ hasRequiredAttributeValueBare = 1;
1634
+ Object.defineProperty(attributeValueBare, "__esModule", { value: true });
1635
+ attributeValueBare.parse = attributeValueBare.parseValueEnd = void 0;
1636
+ const constants_1 = requireConstants();
1637
+ const utils_1 = requireUtils();
1638
+ function parseValueEnd(state, tokens) {
1639
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1640
+ tokens.push({
1641
+ type: constants_1.TokenTypes.AttributeValue,
1642
+ value: state.accumulatedContent,
1643
+ range: position.range,
1644
+ loc: position.loc,
1645
+ });
1646
+ state.accumulatedContent = "";
1647
+ state.decisionBuffer = "";
1648
+ state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1649
+ }
1650
+ attributeValueBare.parseValueEnd = parseValueEnd;
1651
+ function parse(chars, state, tokens) {
1652
+ if ((0, utils_1.isWhitespace)(chars) || chars === ">" || chars === "/") {
1653
+ return parseValueEnd(state, tokens);
1654
+ }
1655
+ state.accumulatedContent += state.decisionBuffer;
1656
+ state.decisionBuffer = "";
1657
+ state.caretPosition++;
1658
+ }
1659
+ attributeValueBare.parse = parse;
1660
+ return attributeValueBare;
1661
+ }
1662
+
1663
+ var attributeValueWrapped = {};
1664
+
1665
+ var hasRequiredAttributeValueWrapped;
1666
+
1667
+ function requireAttributeValueWrapped () {
1668
+ if (hasRequiredAttributeValueWrapped) return attributeValueWrapped;
1669
+ hasRequiredAttributeValueWrapped = 1;
1670
+ Object.defineProperty(attributeValueWrapped, "__esModule", { value: true });
1671
+ attributeValueWrapped.parse = void 0;
1672
+ const constants_1 = requireConstants();
1673
+ const utils_1 = requireUtils();
1674
+ function parse(chars, state, tokens) {
1675
+ var _a;
1676
+ const wrapperChar = (_a = state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped]) === null || _a === void 0 ? void 0 : _a.wrapper;
1677
+ if (chars === wrapperChar) {
1678
+ return parseWrapper(state, tokens);
1679
+ }
1680
+ state.accumulatedContent += state.decisionBuffer;
1681
+ state.decisionBuffer = "";
1682
+ state.caretPosition++;
1683
+ }
1684
+ attributeValueWrapped.parse = parse;
1685
+ function parseWrapper(state, tokens) {
1686
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1687
+ const endWrapperPosition = position.range[1];
1688
+ tokens.push({
1689
+ type: constants_1.TokenTypes.AttributeValue,
1690
+ value: state.accumulatedContent,
1691
+ range: position.range,
1692
+ loc: position.loc,
1693
+ });
1694
+ const range = [endWrapperPosition, endWrapperPosition + 1];
1695
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
1696
+ tokens.push({
1697
+ type: constants_1.TokenTypes.AttributeValueWrapperEnd,
1698
+ value: state.decisionBuffer,
1699
+ range,
1700
+ loc,
1701
+ });
1702
+ state.accumulatedContent = "";
1703
+ state.decisionBuffer = "";
1704
+ state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1705
+ state.caretPosition++;
1706
+ state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped] = undefined;
1707
+ }
1708
+ return attributeValueWrapped;
1709
+ }
1710
+
1711
+ var attributeValue = {};
1712
+
1713
+ var hasRequiredAttributeValue;
1714
+
1715
+ function requireAttributeValue () {
1716
+ if (hasRequiredAttributeValue) return attributeValue;
1717
+ hasRequiredAttributeValue = 1;
1718
+ Object.defineProperty(attributeValue, "__esModule", { value: true });
1719
+ attributeValue.parse = void 0;
1720
+ const constants_1 = requireConstants();
1721
+ const utils_1 = requireUtils();
1722
+ function parse(chars, state, tokens) {
1723
+ if (chars === '"' || chars === "'") {
1724
+ return parseWrapper(state, tokens);
1725
+ }
1726
+ if (chars === ">" || chars === "/") {
1727
+ return parseTagEnd(state);
1728
+ }
1729
+ if (!(0, utils_1.isWhitespace)(chars)) {
1730
+ return parseBare(state);
1731
+ }
1732
+ state.decisionBuffer = "";
1733
+ state.caretPosition++;
1734
+ }
1735
+ attributeValue.parse = parse;
1736
+ function parseWrapper(state, tokens) {
1737
+ const wrapper = state.decisionBuffer;
1738
+ const range = [state.caretPosition, state.caretPosition + 1];
1739
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
1740
+ tokens.push({
1741
+ type: constants_1.TokenTypes.AttributeValueWrapperStart,
1742
+ value: wrapper,
1743
+ range,
1744
+ loc,
1745
+ });
1746
+ state.accumulatedContent = "";
1747
+ state.decisionBuffer = "";
1748
+ state.currentContext = constants_1.TokenizerContextTypes.AttributeValueWrapped;
1749
+ state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped] = {
1750
+ wrapper,
1751
+ };
1752
+ state.caretPosition++;
1753
+ }
1754
+ function parseBare(state) {
1755
+ state.accumulatedContent = state.decisionBuffer;
1756
+ state.decisionBuffer = "";
1757
+ state.currentContext = constants_1.TokenizerContextTypes.AttributeValueBare;
1758
+ state.caretPosition++;
1759
+ }
1760
+ function parseTagEnd(state) {
1761
+ state.accumulatedContent = "";
1762
+ state.decisionBuffer = "";
1763
+ state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1764
+ }
1765
+ return attributeValue;
1766
+ }
1767
+
1768
+ var attributes = {};
1769
+
1770
+ var hasRequiredAttributes;
1771
+
1772
+ function requireAttributes () {
1773
+ if (hasRequiredAttributes) return attributes;
1774
+ hasRequiredAttributes = 1;
1775
+ Object.defineProperty(attributes, "__esModule", { value: true });
1776
+ attributes.parse = void 0;
1777
+ const constants_1 = requireConstants();
1778
+ const utils_1 = requireUtils();
1779
+ function parse(chars, state, tokens) {
1780
+ if (chars === ">" || chars === "/") {
1781
+ return parseTagEnd(state);
1782
+ }
1783
+ if (chars === "=") {
1784
+ return parseEqual(state, tokens);
1785
+ }
1786
+ if (!(0, utils_1.isWhitespace)(chars)) {
1787
+ return parseNoneWhitespace(state);
1788
+ }
1789
+ state.decisionBuffer = "";
1790
+ state.caretPosition++;
1791
+ }
1792
+ attributes.parse = parse;
1793
+ function parseTagEnd(state) {
1794
+ var _a;
1795
+ const tagName = (_a = state.contextParams[constants_1.TokenizerContextTypes.Attributes]) === null || _a === void 0 ? void 0 : _a.tagName;
1796
+ state.accumulatedContent = "";
1797
+ state.decisionBuffer = "";
1798
+ state.currentContext = constants_1.TokenizerContextTypes.OpenTagEnd;
1799
+ state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = { tagName: tagName };
1800
+ state.contextParams[constants_1.TokenizerContextTypes.Attributes] = undefined;
1801
+ }
1802
+ function parseNoneWhitespace(state) {
1803
+ state.accumulatedContent = state.decisionBuffer;
1804
+ state.decisionBuffer = "";
1805
+ state.currentContext = constants_1.TokenizerContextTypes.AttributeKey;
1806
+ state.caretPosition++;
1807
+ }
1808
+ function parseEqual(state, tokens) {
1809
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
1810
+ tokens.push({
1811
+ type: constants_1.TokenTypes.AttributeAssignment,
1812
+ value: state.decisionBuffer,
1813
+ range: position.range,
1814
+ loc: position.loc,
1815
+ });
1816
+ state.accumulatedContent = "";
1817
+ state.decisionBuffer = "";
1818
+ state.currentContext = constants_1.TokenizerContextTypes.AttributeValue;
1819
+ state.caretPosition++;
1820
+ }
1821
+ return attributes;
1822
+ }
1823
+
1824
+ var closeTag = {};
1825
+
1826
+ var hasRequiredCloseTag;
1827
+
1828
+ function requireCloseTag () {
1829
+ if (hasRequiredCloseTag) return closeTag;
1830
+ hasRequiredCloseTag = 1;
1831
+ Object.defineProperty(closeTag, "__esModule", { value: true });
1832
+ closeTag.parse = void 0;
1833
+ const constants_1 = requireConstants();
1834
+ const utils_1 = requireUtils();
1835
+ function parse(chars, state, tokens) {
1836
+ if (chars === ">") {
1837
+ return parseClosingCornerBrace(state, tokens);
1838
+ }
1839
+ state.accumulatedContent += state.decisionBuffer;
1840
+ state.decisionBuffer = "";
1841
+ state.caretPosition++;
1842
+ }
1843
+ closeTag.parse = parse;
1844
+ function parseClosingCornerBrace(state, tokens) {
1845
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
1846
+ tokens.push({
1847
+ type: constants_1.TokenTypes.CloseTag,
1848
+ value: state.accumulatedContent + state.decisionBuffer,
1849
+ range: position.range,
1850
+ loc: position.loc,
1851
+ });
1852
+ state.accumulatedContent = "";
1853
+ state.decisionBuffer = "";
1854
+ state.currentContext = constants_1.TokenizerContextTypes.Data;
1855
+ state.caretPosition++;
1856
+ }
1857
+ return closeTag;
1858
+ }
1859
+
1860
+ var commentContent = {};
1861
+
1862
+ var hasRequiredCommentContent;
1863
+
1864
+ function requireCommentContent () {
1865
+ if (hasRequiredCommentContent) return commentContent;
1866
+ hasRequiredCommentContent = 1;
1867
+ Object.defineProperty(commentContent, "__esModule", { value: true });
1868
+ commentContent.parse = void 0;
1869
+ const constants_1 = requireConstants();
1870
+ const utils_1 = requireUtils();
1871
+ const COMMENT_END = "-->";
1872
+ function parse(chars, state, tokens) {
1873
+ if (chars === "-" || chars === "--") {
1874
+ state.caretPosition++;
1875
+ return;
1876
+ }
1877
+ if (chars === COMMENT_END) {
1878
+ return parseCommentClose(state, tokens);
1879
+ }
1880
+ state.accumulatedContent += state.decisionBuffer;
1881
+ state.decisionBuffer = "";
1882
+ state.caretPosition++;
1883
+ }
1884
+ commentContent.parse = parse;
1885
+ function parseCommentClose(state, tokens) {
1886
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1887
+ const endRange = [
1888
+ position.range[1],
1889
+ position.range[1] + COMMENT_END.length,
1890
+ ];
1891
+ const endLoc = (0, utils_1.calculateTokenLocation)(state.source, endRange);
1892
+ tokens.push({
1893
+ type: constants_1.TokenTypes.CommentContent,
1894
+ value: state.accumulatedContent,
1895
+ range: position.range,
1896
+ loc: position.loc,
1897
+ }, {
1898
+ type: constants_1.TokenTypes.CommentClose,
1899
+ value: state.decisionBuffer,
1900
+ range: endRange,
1901
+ loc: endLoc,
1902
+ });
1903
+ state.accumulatedContent = "";
1904
+ state.decisionBuffer = "";
1905
+ state.currentContext = constants_1.TokenizerContextTypes.Data;
1906
+ state.caretPosition++;
1907
+ }
1908
+ return commentContent;
1909
+ }
1910
+
1911
+ var data = {};
1912
+
1913
+ var hasRequiredData;
1914
+
1915
+ function requireData () {
1916
+ if (hasRequiredData) return data;
1917
+ hasRequiredData = 1;
1918
+ Object.defineProperty(data, "__esModule", { value: true });
1919
+ data.handleContentEnd = data.parse = void 0;
1920
+ const constants_1 = requireConstants();
1921
+ const utils_1 = requireUtils();
1922
+ const COMMENT_START = "<!--";
1923
+ const OPEN_TAG_START_PATTERN = /^<\w/;
1924
+ function parse(chars, state, tokens) {
1925
+ if (OPEN_TAG_START_PATTERN.test(chars)) {
1926
+ return parseOpeningCornerBraceWithText(state, tokens);
1927
+ }
1928
+ if (chars === "</") {
1929
+ return parseOpeningCornerBraceWithSlash(state, tokens);
1930
+ }
1931
+ if (chars === "<" || chars === "<!" || chars === "<!-") {
1932
+ state.caretPosition++;
1933
+ return;
1934
+ }
1935
+ if (chars === COMMENT_START) {
1936
+ return parseCommentOpen(state, tokens);
1937
+ }
1938
+ if (isIncompleteDoctype(chars)) {
1939
+ state.caretPosition++;
1940
+ return;
1941
+ }
1942
+ if (chars.toUpperCase() === "<!DOCTYPE") {
1943
+ return parseDoctypeOpen(state, tokens);
1944
+ }
1945
+ state.accumulatedContent += state.decisionBuffer;
1946
+ state.decisionBuffer = "";
1947
+ state.caretPosition++;
1948
+ }
1949
+ data.parse = parse;
1950
+ function handleContentEnd(state, tokens) {
1951
+ const textContent = state.accumulatedContent + state.decisionBuffer;
1952
+ if (textContent.length !== 0) {
1953
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1954
+ tokens.push({
1955
+ type: constants_1.TokenTypes.Text,
1956
+ value: textContent,
1957
+ range: position.range,
1958
+ loc: position.loc,
1959
+ });
1960
+ }
1961
+ }
1962
+ data.handleContentEnd = handleContentEnd;
1963
+ function generateTextToken(state) {
1964
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1965
+ return {
1966
+ type: constants_1.TokenTypes.Text,
1967
+ value: state.accumulatedContent,
1968
+ range: position.range,
1969
+ loc: position.loc,
1970
+ };
1971
+ }
1972
+ function parseOpeningCornerBraceWithText(state, tokens) {
1973
+ if (state.accumulatedContent.length !== 0) {
1974
+ tokens.push(generateTextToken(state));
1975
+ }
1976
+ state.accumulatedContent = state.decisionBuffer;
1977
+ state.decisionBuffer = "";
1978
+ state.currentContext = constants_1.TokenizerContextTypes.OpenTagStart;
1979
+ state.caretPosition++;
1980
+ }
1981
+ function parseOpeningCornerBraceWithSlash(state, tokens) {
1982
+ if (state.accumulatedContent.length !== 0) {
1983
+ tokens.push(generateTextToken(state));
1984
+ }
1985
+ state.accumulatedContent = state.decisionBuffer;
1986
+ state.decisionBuffer = "";
1987
+ state.currentContext = constants_1.TokenizerContextTypes.CloseTag;
1988
+ state.caretPosition++;
1989
+ }
1990
+ function isIncompleteDoctype(chars) {
1991
+ const charsUpperCase = chars.toUpperCase();
1992
+ return (charsUpperCase === "<!" ||
1993
+ charsUpperCase === "<!D" ||
1994
+ charsUpperCase === "<!DO" ||
1995
+ charsUpperCase === "<!DOC" ||
1996
+ charsUpperCase === "<!DOCT" ||
1997
+ charsUpperCase === "<!DOCTY" ||
1998
+ charsUpperCase === "<!DOCTYP");
1999
+ }
2000
+ function parseCommentOpen(state, tokens) {
2001
+ if (state.accumulatedContent.length !== 0) {
2002
+ tokens.push(generateTextToken(state));
2003
+ }
2004
+ const range = [
2005
+ state.caretPosition - (COMMENT_START.length - 1),
2006
+ state.caretPosition + 1,
2007
+ ];
2008
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
2009
+ tokens.push({
2010
+ type: constants_1.TokenTypes.CommentOpen,
2011
+ value: state.decisionBuffer,
2012
+ range: range,
2013
+ loc,
2014
+ });
2015
+ state.accumulatedContent = "";
2016
+ state.decisionBuffer = "";
2017
+ state.currentContext = constants_1.TokenizerContextTypes.CommentContent;
2018
+ state.caretPosition++;
2019
+ }
2020
+ function parseDoctypeOpen(state, tokens) {
2021
+ if (state.accumulatedContent.length !== 0) {
2022
+ tokens.push(generateTextToken(state));
2023
+ }
2024
+ state.accumulatedContent = state.decisionBuffer;
2025
+ state.decisionBuffer = "";
2026
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeOpen;
2027
+ state.caretPosition++;
2028
+ }
2029
+ return data;
2030
+ }
2031
+
2032
+ var doctypeAttributeBare = {};
2033
+
2034
+ var hasRequiredDoctypeAttributeBare;
2035
+
2036
+ function requireDoctypeAttributeBare () {
2037
+ if (hasRequiredDoctypeAttributeBare) return doctypeAttributeBare;
2038
+ hasRequiredDoctypeAttributeBare = 1;
2039
+ Object.defineProperty(doctypeAttributeBare, "__esModule", { value: true });
2040
+ doctypeAttributeBare.parse = void 0;
2041
+ const constants_1 = requireConstants();
2042
+ const utils_1 = requireUtils();
2043
+ function parse(chars, state, tokens) {
2044
+ if ((0, utils_1.isWhitespace)(chars) || chars === ">") {
2045
+ return parseAttributeEnd(state, tokens);
2046
+ }
2047
+ state.accumulatedContent += state.decisionBuffer;
2048
+ state.decisionBuffer = "";
2049
+ state.caretPosition++;
2050
+ }
2051
+ doctypeAttributeBare.parse = parse;
2052
+ function parseAttributeEnd(state, tokens) {
2053
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2054
+ tokens.push({
2055
+ type: constants_1.TokenTypes.DoctypeAttributeValue,
2056
+ value: state.accumulatedContent,
2057
+ range: position.range,
2058
+ loc: position.loc,
2059
+ });
2060
+ state.accumulatedContent = "";
2061
+ state.decisionBuffer = "";
2062
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2063
+ }
2064
+ return doctypeAttributeBare;
2065
+ }
2066
+
2067
+ var doctypeAttributeWrapped = {};
2068
+
2069
+ var hasRequiredDoctypeAttributeWrapped;
2070
+
2071
+ function requireDoctypeAttributeWrapped () {
2072
+ if (hasRequiredDoctypeAttributeWrapped) return doctypeAttributeWrapped;
2073
+ hasRequiredDoctypeAttributeWrapped = 1;
2074
+ Object.defineProperty(doctypeAttributeWrapped, "__esModule", { value: true });
2075
+ doctypeAttributeWrapped.parse = void 0;
2076
+ const constants_1 = requireConstants();
2077
+ const utils_1 = requireUtils();
2078
+ function parse(chars, state, tokens) {
2079
+ var _a;
2080
+ const wrapperChar = (_a = state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped]) === null || _a === void 0 ? void 0 : _a.wrapper;
2081
+ if (chars === wrapperChar) {
2082
+ return parseWrapper(state, tokens);
2083
+ }
2084
+ state.accumulatedContent += state.decisionBuffer;
2085
+ state.decisionBuffer = "";
2086
+ state.caretPosition++;
2087
+ }
2088
+ doctypeAttributeWrapped.parse = parse;
2089
+ function parseWrapper(state, tokens) {
2090
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2091
+ const endWrapperPosition = position.range[1];
2092
+ tokens.push({
2093
+ type: constants_1.TokenTypes.DoctypeAttributeValue,
2094
+ value: state.accumulatedContent,
2095
+ range: position.range,
2096
+ loc: position.loc,
2097
+ });
2098
+ const range = [endWrapperPosition, endWrapperPosition + 1];
2099
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
2100
+ tokens.push({
2101
+ type: constants_1.TokenTypes.DoctypeAttributeWrapperEnd,
2102
+ value: state.decisionBuffer,
2103
+ range,
2104
+ loc,
2105
+ });
2106
+ state.accumulatedContent = "";
2107
+ state.decisionBuffer = "";
2108
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2109
+ state.caretPosition++;
2110
+ state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped] =
2111
+ undefined;
2112
+ }
2113
+ return doctypeAttributeWrapped;
2114
+ }
2115
+
2116
+ var doctypeAttributes = {};
2117
+
2118
+ var hasRequiredDoctypeAttributes;
2119
+
2120
+ function requireDoctypeAttributes () {
2121
+ if (hasRequiredDoctypeAttributes) return doctypeAttributes;
2122
+ hasRequiredDoctypeAttributes = 1;
2123
+ Object.defineProperty(doctypeAttributes, "__esModule", { value: true });
2124
+ doctypeAttributes.parse = void 0;
2125
+ const constants_1 = requireConstants();
2126
+ const utils_1 = requireUtils();
2127
+ function parse(chars, state, tokens) {
2128
+ if (chars === '"' || chars === "'") {
2129
+ return parseWrapper(state, tokens);
2130
+ }
2131
+ if (chars === ">") {
2132
+ return parseClosingCornerBrace(state);
2133
+ }
2134
+ if (!(0, utils_1.isWhitespace)(chars)) {
2135
+ return parseBare(state);
2136
+ }
2137
+ state.decisionBuffer = "";
2138
+ state.caretPosition++;
2139
+ }
2140
+ doctypeAttributes.parse = parse;
2141
+ function parseWrapper(state, tokens) {
2142
+ const wrapper = state.decisionBuffer;
2143
+ const range = [
2144
+ state.caretPosition,
2145
+ state.caretPosition + wrapper.length,
2146
+ ];
2147
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
2148
+ tokens.push({
2149
+ type: constants_1.TokenTypes.DoctypeAttributeWrapperStart,
2150
+ value: wrapper,
2151
+ range,
2152
+ loc,
2153
+ });
2154
+ state.accumulatedContent = "";
2155
+ state.decisionBuffer = "";
2156
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributeWrapped;
2157
+ state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped] = {
2158
+ wrapper,
2159
+ };
2160
+ state.caretPosition++;
2161
+ }
2162
+ function parseBare(state) {
2163
+ state.accumulatedContent = state.decisionBuffer;
2164
+ state.decisionBuffer = "";
2165
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributeBare;
2166
+ state.caretPosition++;
2167
+ }
2168
+ function parseClosingCornerBrace(state) {
2169
+ state.accumulatedContent = "";
2170
+ state.decisionBuffer = "";
2171
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeClose;
2172
+ }
2173
+ return doctypeAttributes;
2174
+ }
2175
+
2176
+ var doctypeEnd = {};
2177
+
2178
+ var hasRequiredDoctypeEnd;
2179
+
2180
+ function requireDoctypeEnd () {
2181
+ if (hasRequiredDoctypeEnd) return doctypeEnd;
2182
+ hasRequiredDoctypeEnd = 1;
2183
+ Object.defineProperty(doctypeEnd, "__esModule", { value: true });
2184
+ doctypeEnd.parse = void 0;
2185
+ const constants_1 = requireConstants();
2186
+ const utils_1 = requireUtils();
2187
+ function parse(chars, state, tokens) {
2188
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
2189
+ tokens.push({
2190
+ type: constants_1.TokenTypes.DoctypeClose,
2191
+ value: state.decisionBuffer,
2192
+ range: position.range,
2193
+ loc: position.loc,
2194
+ });
2195
+ state.accumulatedContent = "";
2196
+ state.decisionBuffer = "";
2197
+ state.currentContext = constants_1.TokenizerContextTypes.Data;
2198
+ state.caretPosition++;
2199
+ }
2200
+ doctypeEnd.parse = parse;
2201
+ return doctypeEnd;
2202
+ }
2203
+
2204
+ var doctypeStart = {};
2205
+
2206
+ var hasRequiredDoctypeStart;
2207
+
2208
+ function requireDoctypeStart () {
2209
+ if (hasRequiredDoctypeStart) return doctypeStart;
2210
+ hasRequiredDoctypeStart = 1;
2211
+ Object.defineProperty(doctypeStart, "__esModule", { value: true });
2212
+ doctypeStart.parse = void 0;
2213
+ const constants_1 = requireConstants();
2214
+ const utils_1 = requireUtils();
2215
+ function parse(chars, state, tokens) {
2216
+ if ((0, utils_1.isWhitespace)(chars)) {
2217
+ return parseWhitespace(state, tokens);
2218
+ }
2219
+ if (chars === ">") {
2220
+ return parseClosingCornerBrace(state, tokens);
2221
+ }
2222
+ state.decisionBuffer = "";
2223
+ state.caretPosition++;
2224
+ }
2225
+ doctypeStart.parse = parse;
2226
+ function generateDoctypeOpenToken(state) {
2227
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2228
+ return {
2229
+ type: constants_1.TokenTypes.DoctypeOpen,
2230
+ value: state.accumulatedContent,
2231
+ range: position.range,
2232
+ loc: position.loc,
2233
+ };
2234
+ }
2235
+ function parseWhitespace(state, tokens) {
2236
+ tokens.push(generateDoctypeOpenToken(state));
2237
+ state.accumulatedContent = "";
2238
+ state.decisionBuffer = "";
2239
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2240
+ }
2241
+ function parseClosingCornerBrace(state, tokens) {
2242
+ tokens.push(generateDoctypeOpenToken(state));
2243
+ state.accumulatedContent = "";
2244
+ state.decisionBuffer = "";
2245
+ state.currentContext = constants_1.TokenizerContextTypes.DoctypeClose;
2246
+ }
2247
+ return doctypeStart;
2248
+ }
2249
+
2250
+ var openTagEnd = {};
2251
+
2252
+ var hasRequiredOpenTagEnd;
2253
+
2254
+ function requireOpenTagEnd () {
2255
+ if (hasRequiredOpenTagEnd) return openTagEnd;
2256
+ hasRequiredOpenTagEnd = 1;
2257
+ Object.defineProperty(openTagEnd, "__esModule", { value: true });
2258
+ openTagEnd.parse = void 0;
2259
+ const constants_1 = requireConstants();
2260
+ const utils_1 = requireUtils();
2261
+ const tokensMap = {
2262
+ script: constants_1.TokenTypes.OpenScriptTagEnd,
2263
+ style: constants_1.TokenTypes.OpenStyleTagEnd,
2264
+ default: constants_1.TokenTypes.OpenTagEnd,
2265
+ };
2266
+ const contextsMap = {
2267
+ script: constants_1.TokenizerContextTypes.ScriptContent,
2268
+ style: constants_1.TokenizerContextTypes.StyleContent,
2269
+ default: constants_1.TokenizerContextTypes.Data,
2270
+ };
2271
+ function parse(chars, state, tokens) {
2272
+ if (chars === ">") {
2273
+ return parseClosingCornerBrace(state, tokens);
2274
+ }
2275
+ state.accumulatedContent += state.decisionBuffer;
2276
+ state.decisionBuffer = "";
2277
+ state.caretPosition++;
2278
+ }
2279
+ openTagEnd.parse = parse;
2280
+ function parseClosingCornerBrace(state, tokens) {
2281
+ var _a;
2282
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
2283
+ const tagName = (_a = state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd]) === null || _a === void 0 ? void 0 : _a.tagName;
2284
+ tokens.push({
2285
+ type: tokensMap[tagName] || tokensMap.default,
2286
+ value: state.accumulatedContent + state.decisionBuffer,
2287
+ range: position.range,
2288
+ loc: position.loc,
2289
+ });
2290
+ state.accumulatedContent = "";
2291
+ state.decisionBuffer = "";
2292
+ state.currentContext =
2293
+ contextsMap[tagName || "default"] || contextsMap["default"];
2294
+ state.caretPosition++;
2295
+ state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = undefined;
2296
+ }
2297
+ return openTagEnd;
2298
+ }
2299
+
2300
+ var openTagStart = {};
2301
+
2302
+ var hasRequiredOpenTagStart;
2303
+
2304
+ function requireOpenTagStart () {
2305
+ if (hasRequiredOpenTagStart) return openTagStart;
2306
+ hasRequiredOpenTagStart = 1;
2307
+ Object.defineProperty(openTagStart, "__esModule", { value: true });
2308
+ openTagStart.parse = void 0;
2309
+ const constants_1 = requireConstants();
2310
+ const utils_1 = requireUtils();
2311
+ const tokensMap = {
2312
+ script: constants_1.TokenTypes.OpenScriptTagStart,
2313
+ style: constants_1.TokenTypes.OpenStyleTagStart,
2314
+ default: constants_1.TokenTypes.OpenTagStart,
2315
+ };
2316
+ function parse(chars, state, tokens) {
2317
+ if (chars === ">" || chars === "/") {
2318
+ return parseTagEnd(state, tokens);
2319
+ }
2320
+ if ((0, utils_1.isWhitespace)(chars)) {
2321
+ return parseWhitespace(state, tokens);
2322
+ }
2323
+ state.accumulatedContent += state.decisionBuffer;
2324
+ state.decisionBuffer = "";
2325
+ state.caretPosition++;
2326
+ }
2327
+ openTagStart.parse = parse;
2328
+ function parseWhitespace(state, tokens) {
2329
+ const tagName = (0, utils_1.parseOpenTagName)(state.accumulatedContent);
2330
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2331
+ tokens.push({
2332
+ type: tokensMap[tagName] || tokensMap.default,
2333
+ value: state.accumulatedContent,
2334
+ range: position.range,
2335
+ loc: position.loc,
2336
+ });
2337
+ state.accumulatedContent = "";
2338
+ state.decisionBuffer = "";
2339
+ state.currentContext = constants_1.TokenizerContextTypes.Attributes;
2340
+ state.contextParams[constants_1.TokenizerContextTypes.Attributes] = { tagName };
2341
+ state.caretPosition++;
2342
+ }
2343
+ function parseTagEnd(state, tokens) {
2344
+ const tagName = (0, utils_1.parseOpenTagName)(state.accumulatedContent);
2345
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2346
+ tokens.push({
2347
+ type: tokensMap[tagName] || tokensMap.default,
2348
+ value: state.accumulatedContent,
2349
+ range: position.range,
2350
+ loc: position.loc,
2351
+ });
2352
+ state.decisionBuffer = "";
2353
+ state.accumulatedContent = "";
2354
+ state.currentContext = constants_1.TokenizerContextTypes.OpenTagEnd;
2355
+ state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = { tagName };
2356
+ }
2357
+ return openTagStart;
2358
+ }
2359
+
2360
+ var scriptTagContent = {};
2361
+
2362
+ var hasRequiredScriptTagContent;
2363
+
2364
+ function requireScriptTagContent () {
2365
+ if (hasRequiredScriptTagContent) return scriptTagContent;
2366
+ hasRequiredScriptTagContent = 1;
2367
+ Object.defineProperty(scriptTagContent, "__esModule", { value: true });
2368
+ scriptTagContent.parse = void 0;
2369
+ const constants_1 = requireConstants();
2370
+ const utils_1 = requireUtils();
2371
+ function parse(chars, state, tokens) {
2372
+ if (chars === "<" ||
2373
+ chars === "</" ||
2374
+ constants_1.INCOMPLETE_CLOSING_TAG_PATTERN.test(chars)) {
2375
+ state.caretPosition++;
2376
+ return;
2377
+ }
2378
+ if (constants_1.CLOSING_SCRIPT_TAG_PATTERN.test(chars)) {
2379
+ return parseClosingScriptTag(state, tokens);
2380
+ }
2381
+ state.accumulatedContent += state.decisionBuffer;
2382
+ state.decisionBuffer = "";
2383
+ state.caretPosition++;
2384
+ }
2385
+ scriptTagContent.parse = parse;
2386
+ function parseClosingScriptTag(state, tokens) {
2387
+ if (state.accumulatedContent !== "") {
2388
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2389
+ tokens.push({
2390
+ type: constants_1.TokenTypes.ScriptTagContent,
2391
+ value: state.accumulatedContent,
2392
+ range: position.range,
2393
+ loc: position.loc,
2394
+ });
2395
+ }
2396
+ const range = [
2397
+ state.caretPosition - (state.decisionBuffer.length - 1),
2398
+ state.caretPosition + 1,
2399
+ ];
2400
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
2401
+ tokens.push({
2402
+ type: constants_1.TokenTypes.CloseScriptTag,
2403
+ value: state.decisionBuffer,
2404
+ range,
2405
+ loc,
2406
+ });
2407
+ state.accumulatedContent = "";
2408
+ state.decisionBuffer = "";
2409
+ state.currentContext = constants_1.TokenizerContextTypes.Data;
2410
+ state.caretPosition++;
2411
+ }
2412
+ return scriptTagContent;
2413
+ }
2414
+
2415
+ var styleTagContent = {};
2416
+
2417
+ var hasRequiredStyleTagContent;
2418
+
2419
+ function requireStyleTagContent () {
2420
+ if (hasRequiredStyleTagContent) return styleTagContent;
2421
+ hasRequiredStyleTagContent = 1;
2422
+ Object.defineProperty(styleTagContent, "__esModule", { value: true });
2423
+ styleTagContent.parse = void 0;
2424
+ const constants_1 = requireConstants();
2425
+ const utils_1 = requireUtils();
2426
+ const CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
2427
+ function parse(chars, state, tokens) {
2428
+ if (chars === "<" ||
2429
+ chars === "</" ||
2430
+ constants_1.INCOMPLETE_CLOSING_TAG_PATTERN.test(chars)) {
2431
+ state.caretPosition++;
2432
+ return;
2433
+ }
2434
+ if (CLOSING_STYLE_TAG_PATTERN.test(chars)) {
2435
+ return parseClosingStyleTag(state, tokens);
2436
+ }
2437
+ state.accumulatedContent += state.decisionBuffer;
2438
+ state.decisionBuffer = "";
2439
+ state.caretPosition++;
2440
+ }
2441
+ styleTagContent.parse = parse;
2442
+ function parseClosingStyleTag(state, tokens) {
2443
+ if (state.accumulatedContent !== "") {
2444
+ const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2445
+ tokens.push({
2446
+ type: constants_1.TokenTypes.StyleTagContent,
2447
+ value: state.accumulatedContent,
2448
+ range: position.range,
2449
+ loc: position.loc,
2450
+ });
2451
+ }
2452
+ const range = [
2453
+ state.caretPosition - (state.decisionBuffer.length - 1),
2454
+ state.caretPosition + 1,
2455
+ ];
2456
+ const loc = (0, utils_1.calculateTokenLocation)(state.source, range);
2457
+ tokens.push({
2458
+ type: constants_1.TokenTypes.CloseStyleTag,
2459
+ value: state.decisionBuffer,
2460
+ range,
2461
+ loc,
2462
+ });
2463
+ state.accumulatedContent = "";
2464
+ state.decisionBuffer = "";
2465
+ state.currentContext = constants_1.TokenizerContextTypes.Data;
2466
+ state.caretPosition++;
2467
+ }
2468
+ return styleTagContent;
2469
+ }
2470
+
2471
+ var hasRequiredHandlers;
2472
+
2473
+ function requireHandlers () {
2474
+ if (hasRequiredHandlers) return handlers;
2475
+ hasRequiredHandlers = 1;
2476
+ var __createBinding = (handlers && handlers.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2477
+ if (k2 === undefined) k2 = k;
2478
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2479
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2480
+ desc = { enumerable: true, get: function() { return m[k]; } };
2481
+ }
2482
+ Object.defineProperty(o, k2, desc);
2483
+ }) : (function(o, m, k, k2) {
2484
+ if (k2 === undefined) k2 = k;
2485
+ o[k2] = m[k];
2486
+ }));
2487
+ var __setModuleDefault = (handlers && handlers.__setModuleDefault) || (Object.create ? (function(o, v) {
2488
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2489
+ }) : function(o, v) {
2490
+ o["default"] = v;
2491
+ });
2492
+ var __importStar = (handlers && handlers.__importStar) || function (mod) {
2493
+ if (mod && mod.__esModule) return mod;
2494
+ var result = {};
2495
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2496
+ __setModuleDefault(result, mod);
2497
+ return result;
2498
+ };
2499
+ Object.defineProperty(handlers, "__esModule", { value: true });
2500
+ handlers.noop = handlers.styleTagContent = handlers.scriptTagContent = handlers.openTagStart = handlers.openTagEnd = handlers.DoctypeOpen = handlers.DoctypeClose = handlers.doctypeAttributes = handlers.doctypeAttributeWrapped = handlers.doctypeAttributeBare = handlers.data = handlers.commentContent = handlers.closeTag = handlers.attributes = handlers.attributeValue = handlers.attributeValueWrapped = handlers.attributeValueBare = handlers.attributeKey = void 0;
2501
+ handlers.attributeKey = __importStar(requireAttributeKey());
2502
+ handlers.attributeValueBare = __importStar(requireAttributeValueBare());
2503
+ handlers.attributeValueWrapped = __importStar(requireAttributeValueWrapped());
2504
+ handlers.attributeValue = __importStar(requireAttributeValue());
2505
+ handlers.attributes = __importStar(requireAttributes());
2506
+ handlers.closeTag = __importStar(requireCloseTag());
2507
+ handlers.commentContent = __importStar(requireCommentContent());
2508
+ handlers.data = __importStar(requireData());
2509
+ handlers.doctypeAttributeBare = __importStar(requireDoctypeAttributeBare());
2510
+ handlers.doctypeAttributeWrapped = __importStar(requireDoctypeAttributeWrapped());
2511
+ handlers.doctypeAttributes = __importStar(requireDoctypeAttributes());
2512
+ handlers.DoctypeClose = __importStar(requireDoctypeEnd());
2513
+ handlers.DoctypeOpen = __importStar(requireDoctypeStart());
2514
+ handlers.openTagEnd = __importStar(requireOpenTagEnd());
2515
+ handlers.openTagStart = __importStar(requireOpenTagStart());
2516
+ handlers.scriptTagContent = __importStar(requireScriptTagContent());
2517
+ handlers.styleTagContent = __importStar(requireStyleTagContent());
2518
+ handlers.noop = {
2519
+ parse: () => void 0,
2520
+ };
2521
+ return handlers;
2522
+ }
2523
+
2524
+ var hasRequiredTokenize;
2525
+
2526
+ function requireTokenize () {
2527
+ if (hasRequiredTokenize) return tokenize;
2528
+ hasRequiredTokenize = 1;
2529
+ Object.defineProperty(tokenize, "__esModule", { value: true });
2530
+ tokenize.tokenize = void 0;
2531
+ const constants_1 = requireConstants();
2532
+ const handlers_1 = requireHandlers();
2533
+ const contextHandlers = {
2534
+ [constants_1.TokenizerContextTypes.Data]: handlers_1.data,
2535
+ [constants_1.TokenizerContextTypes.OpenTagStart]: handlers_1.openTagStart,
2536
+ [constants_1.TokenizerContextTypes.CloseTag]: handlers_1.closeTag,
2537
+ [constants_1.TokenizerContextTypes.Attributes]: handlers_1.attributes,
2538
+ [constants_1.TokenizerContextTypes.OpenTagEnd]: handlers_1.openTagEnd,
2539
+ [constants_1.TokenizerContextTypes.AttributeKey]: handlers_1.attributeKey,
2540
+ [constants_1.TokenizerContextTypes.AttributeValue]: handlers_1.attributeValue,
2541
+ [constants_1.TokenizerContextTypes.AttributeValueBare]: handlers_1.attributeValueBare,
2542
+ [constants_1.TokenizerContextTypes.AttributeValueWrapped]: handlers_1.attributeValueWrapped,
2543
+ [constants_1.TokenizerContextTypes.ScriptContent]: handlers_1.scriptTagContent,
2544
+ [constants_1.TokenizerContextTypes.StyleContent]: handlers_1.styleTagContent,
2545
+ [constants_1.TokenizerContextTypes.DoctypeOpen]: handlers_1.DoctypeOpen,
2546
+ [constants_1.TokenizerContextTypes.DoctypeClose]: handlers_1.DoctypeClose,
2547
+ [constants_1.TokenizerContextTypes.DoctypeAttributes]: handlers_1.doctypeAttributes,
2548
+ [constants_1.TokenizerContextTypes.DoctypeAttributeWrapped]: handlers_1.doctypeAttributeWrapped,
2549
+ [constants_1.TokenizerContextTypes.DoctypeAttributeBare]: handlers_1.doctypeAttributeBare,
2550
+ [constants_1.TokenizerContextTypes.CommentContent]: handlers_1.commentContent,
2551
+ [constants_1.TokenizerContextTypes.CommentOpen]: handlers_1.noop,
2552
+ [constants_1.TokenizerContextTypes.CommentClose]: handlers_1.noop,
2553
+ };
2554
+ function tokenizeChars(chars, state, tokens, { isFinalChunk, positionOffset, }) {
2555
+ let charIndex = state.caretPosition - positionOffset;
2556
+ let charIndexBefore = charIndex;
2557
+ while (charIndex < chars.length) {
2558
+ const handler = contextHandlers[state.currentContext];
2559
+ state.decisionBuffer += chars[charIndex];
2560
+ if (charIndexBefore !== charIndex && chars[charIndex] === "\n") {
2561
+ state.linePosition++;
2562
+ }
2563
+ charIndexBefore = charIndex;
2564
+ handler.parse(state.decisionBuffer, state, tokens);
2565
+ charIndex = state.caretPosition - positionOffset;
2566
+ }
2567
+ if (isFinalChunk) {
2568
+ const handler = contextHandlers[state.currentContext];
2569
+ state.caretPosition--;
2570
+ if (handler.handleContentEnd !== undefined) {
2571
+ handler.handleContentEnd(state, tokens);
2572
+ }
2573
+ }
2574
+ }
2575
+ function tokenize$1(source = "", { isFinalChunk, } = {}) {
2576
+ isFinalChunk = isFinalChunk === undefined ? true : isFinalChunk;
2577
+ const state = {
2578
+ currentContext: constants_1.TokenizerContextTypes.Data,
2579
+ contextParams: {},
2580
+ decisionBuffer: "",
2581
+ accumulatedContent: "",
2582
+ caretPosition: 0,
2583
+ linePosition: 1,
2584
+ source,
2585
+ };
2586
+ const chars = state.decisionBuffer + source;
2587
+ const tokens = [];
2588
+ const positionOffset = state.caretPosition - state.decisionBuffer.length;
2589
+ tokenizeChars(chars, state, tokens, {
2590
+ isFinalChunk,
2591
+ positionOffset,
2592
+ });
2593
+ return { state, tokens };
2594
+ }
2595
+ tokenize.tokenize = tokenize$1;
2596
+ return tokenize;
2597
+ }
2598
+
2599
+ var hasRequiredTokenizer;
2600
+
2601
+ function requireTokenizer () {
2602
+ if (hasRequiredTokenizer) return tokenizer;
2603
+ hasRequiredTokenizer = 1;
2604
+ (function (exports) {
2605
+ Object.defineProperty(exports, "__esModule", { value: true });
2606
+ exports.tokenize = void 0;
2607
+ var tokenize_1 = requireTokenize();
2608
+ Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return tokenize_1.tokenize; } });
2609
+ } (tokenizer));
2610
+ return tokenizer;
2611
+ }
2612
+
2613
+ var hasRequiredParse;
2614
+
2615
+ function requireParse () {
2616
+ if (hasRequiredParse) return parse;
2617
+ hasRequiredParse = 1;
2618
+ Object.defineProperty(parse, "__esModule", { value: true });
2619
+ parse.parse = void 0;
2620
+ const tree_constructor_1 = requireTreeConstructor();
2621
+ const tokenizer_1 = requireTokenizer();
2622
+ const utils_1 = requireUtils();
2623
+ function parse$1(html) {
2624
+ const { tokens } = (0, tokenizer_1.tokenize)(html, undefined);
2625
+ const { ast } = (0, tree_constructor_1.constructTree)(tokens, undefined);
2626
+ return {
2627
+ ast: (0, utils_1.clearParent)(ast),
2628
+ tokens,
2629
+ };
2630
+ }
2631
+ parse.parse = parse$1;
2632
+ return parse;
2633
+ }
2634
+
2635
+ var hasRequiredParser$1;
2636
+
2637
+ function requireParser$1 () {
2638
+ if (hasRequiredParser$1) return parser;
2639
+ hasRequiredParser$1 = 1;
2640
+ (function (exports) {
2641
+ var __createBinding = (parser && parser.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2642
+ if (k2 === undefined) k2 = k;
2643
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2644
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2645
+ desc = { enumerable: true, get: function() { return m[k]; } };
2646
+ }
2647
+ Object.defineProperty(o, k2, desc);
2648
+ }) : (function(o, m, k, k2) {
2649
+ if (k2 === undefined) k2 = k;
2650
+ o[k2] = m[k];
2651
+ }));
2652
+ var __exportStar = (parser && parser.__exportStar) || function(m, exports) {
2653
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2654
+ };
2655
+ Object.defineProperty(exports, "__esModule", { value: true });
2656
+ __exportStar(requireParse(), exports);
2657
+ } (parser));
2658
+ return parser;
2659
+ }
2660
+
2661
+ var node$1 = {};
2662
+
2663
+ var hasRequiredNode$1;
2664
+
2665
+ function requireNode$1 () {
2666
+ if (hasRequiredNode$1) return node$1;
2667
+ hasRequiredNode$1 = 1;
2668
+ Object.defineProperty(node$1, "__esModule", { value: true });
2669
+ return node$1;
2670
+ }
2671
+
2672
+ var hasRequiredDist$1;
2673
+
2674
+ function requireDist$1 () {
2675
+ if (hasRequiredDist$1) return dist;
2676
+ hasRequiredDist$1 = 1;
2677
+ (function (exports) {
2678
+ var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2679
+ if (k2 === undefined) k2 = k;
2680
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2681
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2682
+ desc = { enumerable: true, get: function() { return m[k]; } };
2683
+ }
2684
+ Object.defineProperty(o, k2, desc);
2685
+ }) : (function(o, m, k, k2) {
2686
+ if (k2 === undefined) k2 = k;
2687
+ o[k2] = m[k];
2688
+ }));
2689
+ var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
2690
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2691
+ };
2692
+ Object.defineProperty(exports, "__esModule", { value: true });
2693
+ exports.TokenTypes = exports.NodeTypes = exports.parse = void 0;
2694
+ var parser_1 = requireParser$1();
2695
+ Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
2696
+ var constants_1 = requireConstants();
2697
+ Object.defineProperty(exports, "NodeTypes", { enumerable: true, get: function () { return constants_1.NodeTypes; } });
2698
+ Object.defineProperty(exports, "TokenTypes", { enumerable: true, get: function () { return constants_1.TokenTypes; } });
2699
+ __exportStar(requireNode$1(), exports);
2700
+ } (dist));
2701
+ return dist;
2702
+ }
2703
+
2704
+ var visitorKeys = {};
2705
+
2706
+ var hasRequiredVisitorKeys;
2707
+
2708
+ function requireVisitorKeys () {
2709
+ if (hasRequiredVisitorKeys) return visitorKeys;
2710
+ hasRequiredVisitorKeys = 1;
2711
+ Object.defineProperty(visitorKeys, "__esModule", { value: true });
2712
+ visitorKeys.visitorKeys = void 0;
2713
+ const es_html_parser_1 = requireDist$1();
2714
+ visitorKeys.visitorKeys = {
2715
+ Program: ["body"],
2716
+ [es_html_parser_1.NodeTypes.Attribute]: ["key", "startWrapper", "endWrapper", "value"],
2717
+ [es_html_parser_1.NodeTypes.AttributeKey]: [],
2718
+ [es_html_parser_1.NodeTypes.AttributeValue]: [],
2719
+ [es_html_parser_1.NodeTypes.AttributeValueWrapperEnd]: [],
2720
+ [es_html_parser_1.NodeTypes.AttributeValueWrapperStart]: [],
2721
+ [es_html_parser_1.NodeTypes.CloseScriptTag]: [],
2722
+ [es_html_parser_1.NodeTypes.CloseStyleTag]: [],
2723
+ [es_html_parser_1.NodeTypes.CloseTag]: [],
2724
+ [es_html_parser_1.NodeTypes.Comment]: ["open", "close", "value"],
2725
+ [es_html_parser_1.NodeTypes.CommentContent]: [],
2726
+ [es_html_parser_1.NodeTypes.CommentOpen]: [],
2727
+ [es_html_parser_1.NodeTypes.CommentClose]: [],
2728
+ [es_html_parser_1.NodeTypes.Doctype]: ["open", "close", "attributes"],
2729
+ [es_html_parser_1.NodeTypes.DoctypeAttribute]: ["startWrapper", "value", "endWrapper"],
2730
+ [es_html_parser_1.NodeTypes.DoctypeAttributeValue]: [],
2731
+ [es_html_parser_1.NodeTypes.DoctypeAttributeWrapperEnd]: [],
2732
+ [es_html_parser_1.NodeTypes.DoctypeAttributeWrapperStart]: [],
2733
+ [es_html_parser_1.NodeTypes.DoctypeOpen]: [],
2734
+ [es_html_parser_1.NodeTypes.DoctypeClose]: [],
2735
+ [es_html_parser_1.NodeTypes.Document]: [],
2736
+ [es_html_parser_1.NodeTypes.OpenScriptTagEnd]: [],
2737
+ [es_html_parser_1.NodeTypes.OpenScriptTagStart]: [],
2738
+ [es_html_parser_1.NodeTypes.OpenStyleTagEnd]: [],
2739
+ [es_html_parser_1.NodeTypes.OpenStyleTagStart]: [],
2740
+ [es_html_parser_1.NodeTypes.OpenTagEnd]: [],
2741
+ [es_html_parser_1.NodeTypes.OpenTagStart]: [],
2742
+ [es_html_parser_1.NodeTypes.ScriptTag]: [
2743
+ "attributes",
2744
+ "openStart",
2745
+ "openEnd",
2746
+ "close",
2747
+ "value",
2748
+ ],
2749
+ [es_html_parser_1.NodeTypes.ScriptTagContent]: [],
2750
+ [es_html_parser_1.NodeTypes.StyleTag]: [
2751
+ "attributes",
2752
+ "openStart",
2753
+ "openEnd",
2754
+ "close",
2755
+ "value",
2756
+ ],
2757
+ [es_html_parser_1.NodeTypes.StyleTagContent]: [],
2758
+ [es_html_parser_1.NodeTypes.Tag]: ["openStart", "openEnd", "close", "children", "attributes"],
2759
+ [es_html_parser_1.NodeTypes.Text]: [],
2760
+ };
2761
+
2762
+ return visitorKeys;
2763
+ }
2764
+
2765
+ var traverse = {};
2766
+
2767
+ var hasRequiredTraverse;
2768
+
2769
+ function requireTraverse () {
2770
+ if (hasRequiredTraverse) return traverse;
2771
+ hasRequiredTraverse = 1;
2772
+ Object.defineProperty(traverse, "__esModule", { value: true });
2773
+ traverse.traverse = void 0;
2774
+ const visitor_keys_1 = requireVisitorKeys();
2775
+ function traverse$1(node, visitor) {
2776
+ if (!node) {
2777
+ return;
2778
+ }
2779
+ visitor(node);
2780
+ const type = node.type;
2781
+ const keys = visitor_keys_1.visitorKeys[type];
2782
+ if (!keys || keys.length <= 0) {
2783
+ return;
2784
+ }
2785
+ keys.forEach((key) => {
2786
+ // @ts-ignore
2787
+ const value = node[key];
2788
+ if (value) {
2789
+ if (Array.isArray(value)) {
2790
+ value.forEach((n) => traverse$1(n, visitor));
2791
+ }
2792
+ else {
2793
+ traverse$1(value, visitor);
2794
+ }
2795
+ }
2796
+ });
2797
+ }
2798
+ traverse.traverse = traverse$1;
2799
+
2800
+ return traverse;
2801
+ }
2802
+
2803
+ var hasRequiredParser;
2804
+
2805
+ function requireParser () {
2806
+ if (hasRequiredParser) return parser$1;
2807
+ hasRequiredParser = 1;
2808
+ Object.defineProperty(parser$1, "__esModule", { value: true });
2809
+ parser$1.parseForESLint = void 0;
2810
+ const es_html_parser_1 = requireDist$1();
2811
+ const visitor_keys_1 = requireVisitorKeys();
2812
+ const traverse_1 = requireTraverse();
2813
+ function parseForESLint(code) {
2814
+ const { ast, tokens } = (0, es_html_parser_1.parse)(code);
2815
+ const programNode = {
2816
+ type: "Program",
2817
+ body: ast.children,
2818
+ loc: ast.loc,
2819
+ range: ast.range,
2820
+ tokens: tokens.filter((token) => token.type !== "CommentContent" &&
2821
+ token.type !== "CommentOpen" &&
2822
+ token.type !== "CommentClose"),
2823
+ comments: [],
2824
+ };
2825
+ (0, traverse_1.traverse)(programNode, (node) => {
2826
+ if (node.type === "CommentContent") {
2827
+ programNode.comments.push({
2828
+ type: node.type,
2829
+ range: node.range,
2830
+ loc: node.loc,
2831
+ value: node.value,
2832
+ });
2833
+ }
2834
+ });
2835
+ return {
2836
+ ast: programNode,
2837
+ visitorKeys: visitor_keys_1.visitorKeys,
2838
+ scopeManager: null,
2839
+ };
2840
+ }
2841
+ parser$1.parseForESLint = parseForESLint;
2842
+
2843
+ return parser$1;
2844
+ }
2845
+
2846
+ var hasRequiredDist;
2847
+
2848
+ function requireDist () {
2849
+ if (hasRequiredDist) return dist$1;
2850
+ hasRequiredDist = 1;
2851
+ (function (exports) {
2852
+ Object.defineProperty(exports, "__esModule", { value: true });
2853
+ exports.parseForESLint = void 0;
2854
+ var parser_1 = requireParser();
2855
+ Object.defineProperty(exports, "parseForESLint", { enumerable: true, get: function () { return parser_1.parseForESLint; } });
2856
+
2857
+ } (dist$1));
2858
+ return dist$1;
2859
+ }
2860
+
2861
+ var node;
2862
+ var hasRequiredNode;
2863
+
2864
+ function requireNode () {
2865
+ if (hasRequiredNode) return node;
2866
+ hasRequiredNode = 1;
2867
+ // THIS IS TAKEN FROM html-eslint
2868
+
2869
+ const { NODE_TYPES } = requireDist();
2870
+
2871
+ /**
2872
+ * @param {TagNode | ScriptTagNode | StyleTagNode} node
2873
+ * @param {string} key
2874
+ * @returns {AttributeNode | undefined}
2875
+ */
2876
+ function findAttr(node, key) {
2877
+ return node.attributes.find(
2878
+ (attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()
2879
+ );
2880
+ }
2881
+
2882
+ /**
2883
+ * Checks whether a node's attributes is empty or not.
2884
+ * @param {TagNode | ScriptTagNode | StyleTagNode} node
2885
+ * @returns {boolean}
2886
+ */
2887
+ function isAttributesEmpty(node) {
2888
+ return !node.attributes || node.attributes.length <= 0;
2889
+ }
2890
+
2891
+ /**
2892
+ * Checks whether a node's all tokens are on the same line or not.
2893
+ * @param {AnyNode} node A node to check
2894
+ * @returns {boolean} `true` if a node's tokens are on the same line, otherwise `false`.
2895
+ */
2896
+ function isNodeTokensOnSameLine(node) {
2897
+ return node.loc.start.line === node.loc.end.line;
2898
+ }
2899
+
2900
+ /**
2901
+ *
2902
+ * @param {Range} rangeA
2903
+ * @param {Range} rangeB
2904
+ * @returns {boolean}
2905
+ */
2906
+ function isRangesOverlap(rangeA, rangeB) {
2907
+ return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];
2908
+ }
2909
+
2910
+ /**
2911
+ * @param {(TextNode | CommentContentNode)['templates']} templates
2912
+ * @param {Range} range
2913
+ * @returns {boolean}
2914
+ */
2915
+ function isOverlapWithTemplates(templates, range) {
2916
+ return templates
2917
+ .filter((template) => template.isTemplate)
2918
+ .some((template) => isRangesOverlap(template.range, range));
2919
+ }
2920
+
2921
+ /**
2922
+ *
2923
+ * @param {TextNode | CommentContentNode} node
2924
+ * @returns {LineNode[]}
2925
+ */
2926
+ function splitToLineNodes(node) {
2927
+ let start = node.range[0];
2928
+ let line = node.loc.start.line;
2929
+ const startCol = node.loc.start.column;
2930
+ /**
2931
+ * @type {LineNode[]}
2932
+ */
2933
+ const lineNodes = [];
2934
+ const templates = node.templates || [];
2935
+ /**
2936
+ *
2937
+ * @param {import("../../types").Range} range
2938
+ */
2939
+ function shouldSkipIndentCheck(range) {
2940
+ const overlappedTemplates = templates.filter(
2941
+ (template) =>
2942
+ template.isTemplate && isRangesOverlap(template.range, range)
2943
+ );
2944
+
2945
+ const isLineInTemplate = overlappedTemplates.some((template) => {
2946
+ return template.range[0] <= range[0] && template.range[1] >= range[1];
2947
+ });
2948
+ if (isLineInTemplate) {
2949
+ return true;
2950
+ }
2951
+ const isLineBeforeTemplate = overlappedTemplates.some((template) => {
2952
+ return template.range[0] <= range[0] && template.range[1] <= range[1];
2953
+ });
2954
+ if (isLineBeforeTemplate) {
2955
+ return true;
2956
+ }
2957
+ const isLineAfterTemplate = overlappedTemplates.some((template) => {
2958
+ return template.range[1] <= range[0];
2959
+ });
2960
+ if (isLineAfterTemplate) {
2961
+ return true;
2962
+ }
2963
+ return false;
2964
+ }
2965
+
2966
+ node.value.split("\n").forEach((value, index) => {
2967
+ const columnStart = index === 0 ? startCol : 0;
2968
+ /**
2969
+ * @type {import("../../types").Range}
2970
+ */
2971
+ const range = [start, start + value.length];
2972
+ const loc = {
2973
+ start: {
2974
+ line,
2975
+ column: columnStart,
2976
+ },
2977
+ end: {
2978
+ line,
2979
+ column: columnStart + value.length,
2980
+ },
2981
+ };
2982
+ /**
2983
+ * @type {LineNode}
2984
+ */
2985
+ const lineNode = {
2986
+ type: "Line",
2987
+ value,
2988
+ range,
2989
+ loc,
2990
+ skipIndentCheck: shouldSkipIndentCheck(range),
2991
+ };
2992
+
2993
+ start += value.length + 1;
2994
+ line += 1;
2995
+
2996
+ lineNodes.push(lineNode);
2997
+ });
2998
+
2999
+ return lineNodes;
3000
+ }
3001
+
3002
+ /**
3003
+ * Get location between two nodes.
3004
+ * @param {BaseNode} before A node placed in before
3005
+ * @param {BaseNode} after A node placed in after
3006
+ * @returns {Location} location between two nodes.
3007
+ */
3008
+ function getLocBetween(before, after) {
3009
+ return {
3010
+ start: before.loc.end,
3011
+ end: after.loc.start,
3012
+ };
3013
+ }
3014
+
3015
+ /**
3016
+ * @param {AttributeValueNode} node
3017
+ * @return {boolean}
3018
+ */
3019
+ function isExpressionInTemplate(node) {
3020
+ if (node.type === NODE_TYPES.AttributeValue) {
3021
+ return node.value.indexOf("${") === 0;
3022
+ }
3023
+ return false;
3024
+ }
3025
+
3026
+ /**
3027
+ * @param {AnyNode} node
3028
+ * @returns {node is TagNode}
3029
+ */
3030
+ function isTag(node) {
3031
+ return node.type === NODE_TYPES.Tag;
3032
+ }
3033
+
3034
+ /**
3035
+ * @param {AnyNode} node
3036
+ * @returns {node is CommentNode}
3037
+ */
3038
+ function isComment(node) {
3039
+ return node.type === NODE_TYPES.Comment;
3040
+ }
3041
+
3042
+ /**
3043
+ * @param {AnyNode} node
3044
+ * @returns {node is TextNode}
3045
+ */
3046
+ function isText(node) {
3047
+ return node.type === NODE_TYPES.Text;
3048
+ }
3049
+
3050
+ const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
3051
+ const lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
3052
+ /**
3053
+ * @param {string} source
3054
+ * @returns {string[]}
3055
+ */
3056
+ function codeToLines(source) {
3057
+ return source.split(lineEndingPattern);
3058
+ }
3059
+
3060
+ /**
3061
+ *
3062
+ * @param {AnyToken[]} tokens
3063
+ * @returns {((CommentContentNode | TextNode)['templates'][number])[]}
3064
+ */
3065
+ function getTemplateTokens(tokens) {
3066
+ return (
3067
+ []
3068
+ .concat(
3069
+ ...tokens
3070
+ // @ts-ignore
3071
+ .map((token) => token["templates"] || [])
3072
+ )
3073
+ // @ts-ignore
3074
+ .filter((token) => token.isTemplate)
3075
+ );
3076
+ }
3077
+
3078
+ node = {
3079
+ findAttr,
3080
+ isAttributesEmpty,
3081
+ isNodeTokensOnSameLine,
3082
+ splitToLineNodes,
3083
+ getLocBetween,
3084
+ isExpressionInTemplate,
3085
+ isTag,
3086
+ isComment,
3087
+ isText,
3088
+ isOverlapWithTemplates,
3089
+ codeToLines,
3090
+ isRangesOverlap,
3091
+ getTemplateTokens,
3092
+ };
3093
+ return node;
3094
+ }
3095
+
3096
+ var noBemClass;
3097
+ var hasRequiredNoBemClass;
3098
+
3099
+ function requireNoBemClass () {
3100
+ if (hasRequiredNoBemClass) return noBemClass;
3101
+ hasRequiredNoBemClass = 1;
3102
+ const {
3103
+ findAttr,
3104
+ isAttributesEmpty
3105
+ } = requireNode();
3106
+
3107
+ noBemClass = {
3108
+ meta: {
3109
+ type: "problem", // The rule type
3110
+ docs: {
3111
+ description: "Enforce consistent class naming using BEM convention",
3112
+ category: "Stylistic Issues",
3113
+ recommended: true,
3114
+ },
3115
+ fixable: "code", // This rule can be fixed automatically
3116
+ schema: [
3117
+ {
3118
+ type: "object",
3119
+ properties: {
3120
+ pattern: { type: "string" }, // Regex pattern for BEM
3121
+ flags: { type: "string" }, // Regex flags
3122
+ },
3123
+ additionalProperties: false,
3124
+ },
3125
+ ],
3126
+ messages: {
3127
+ wrongClassName:
3128
+ "The class '{{actual}}' does not follow BEM naming convention.",
3129
+ },
3130
+ },
3131
+
3132
+ create(context) {
3133
+ const pattern =
3134
+ /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(__[a-z0-9]+(?:-[a-z0-9]+)*)?(--[a-z0-9]+(?:-[a-z0-9]+)*)?$/;
3135
+
3136
+
3137
+ const checkNaming = (name) => {
3138
+
3139
+ return pattern.test(name)
3140
+ };
3141
+
3142
+ function check(node) {
3143
+ if (isAttributesEmpty(node)) {
3144
+ return;
3145
+ }
3146
+ const classAttr = findAttr(node, "class");
3147
+ if (classAttr && classAttr.value) {
3148
+ const classNames = classAttr.value.value.split(/\s+/);
3149
+ classNames.forEach((className) => {
3150
+ if (className && !checkNaming(className)) {
3151
+
3152
+ // Find the exact location of the problematic class name
3153
+ const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= "`
3154
+ const classNameEnd = classNameStart + className.length;
3155
+
3156
+ // Use the loc property to get line and column from the class attribute
3157
+ const startLoc = {
3158
+ line: classAttr.loc.start.line,
3159
+ column: classAttr.loc.start.column + classNameStart,
3160
+ };
3161
+ const endLoc = {
3162
+ line: classAttr.loc.start.line,
3163
+ column: classAttr.loc.start.column + classNameEnd,
3164
+ };
3165
+
3166
+ context.report({
3167
+ node,
3168
+ loc: { start: startLoc, end: endLoc },
3169
+ data: {
3170
+ actual: className,
3171
+ },
3172
+ messageId: "wrongClassName",
3173
+ });
3174
+ }
3175
+ });
3176
+ }
3177
+ }
3178
+ return {
3179
+ Tag: check,
3180
+ };
3181
+ },
3182
+ };
3183
+ return noBemClass;
3184
+ }
3185
+
3186
+ var noDeprecatedSldsClasses;
3187
+ var hasRequiredNoDeprecatedSldsClasses;
3188
+
3189
+ function requireNoDeprecatedSldsClasses () {
3190
+ if (hasRequiredNoDeprecatedSldsClasses) return noDeprecatedSldsClasses;
3191
+ hasRequiredNoDeprecatedSldsClasses = 1;
3192
+ const fs = require$$0__default["default"];
3193
+ const path = require$$1__default["default"];
3194
+ const { findAttr, isAttributesEmpty } = requireNode();
3195
+
3196
+ noDeprecatedSldsClasses = {
3197
+ meta: {
3198
+ type: "problem", // The rule type
3199
+ docs: {
3200
+ description: "Disallow usage of deprecated CSS classes",
3201
+ category: "Best Practices",
3202
+ recommended: true,
3203
+ },
3204
+ schema: [], // No additional options needed
3205
+ messages: {
3206
+ deprecatedClass: "The class '{{className}}' is deprecated and should not be used.",
3207
+ },
3208
+ },
3209
+
3210
+ create(context) {
3211
+ let deprecatedClassesPath = path.resolve(
3212
+ __dirname,
3213
+ "./public/metadata/deprecatedClasses.json"
3214
+ );
3215
+ if(process.env.NODE_ENV === 'test')
3216
+ {
3217
+ // In case of testing, we grab the json from local folder.
3218
+ deprecatedClassesPath = path.resolve(
3219
+ __dirname,
3220
+ "./../../public/metadata/deprecatedClasses.json"
3221
+ );
3222
+ }
3223
+
3224
+ //console.log(`deprecatedClassesPath ${deprecatedClassesPath}`)
3225
+
3226
+ let deprecatedClasses = [];
3227
+ try {
3228
+ const fileContent = fs.readFileSync(deprecatedClassesPath, "utf8");
3229
+ deprecatedClasses = JSON.parse(fileContent);
3230
+ } catch (error) {
3231
+ console.error(`Failed to load deprecated classes JSON: ${error.message}`);
3232
+ return {}; // Exit gracefully if JSON cannot be loaded
3233
+ }
3234
+
3235
+ function check(node) {
3236
+ if (isAttributesEmpty(node)) {
3237
+ return;
3238
+ }
3239
+
3240
+ const classAttr = findAttr(node, "class");
3241
+ if (classAttr && classAttr.value) {
3242
+ const classNames = classAttr.value.value.split(/\s+/);
3243
+ classNames.forEach((className) => {
3244
+ if (className && deprecatedClasses.includes(className)) {
3245
+ // Find the exact location of the problematic class name
3246
+ const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= "`
3247
+ const classNameEnd = classNameStart + className.length;
3248
+
3249
+ // Use the loc property to get line and column from the class attribute
3250
+ const startLoc = {
3251
+ line: classAttr.loc.start.line,
3252
+ column: classAttr.loc.start.column + classNameStart,
3253
+ };
3254
+ const endLoc = {
3255
+ line: classAttr.loc.start.line,
3256
+ column: classAttr.loc.start.column + classNameEnd,
3257
+ };
3258
+
3259
+
3260
+ context.report({
3261
+ node,
3262
+ loc: { start: startLoc, end: endLoc },
3263
+ data: {
3264
+ className,
3265
+ },
3266
+ messageId: "deprecatedClass",
3267
+ });
3268
+ }
3269
+ });
3270
+ }
3271
+ }
3272
+
3273
+ return {
3274
+ Tag: check,
3275
+ };
3276
+ },
3277
+ };
3278
+ return noDeprecatedSldsClasses;
3279
+ }
3280
+
3281
+ var src;
3282
+ var hasRequiredSrc;
3283
+
3284
+ function requireSrc () {
3285
+ if (hasRequiredSrc) return src;
3286
+ hasRequiredSrc = 1;
3287
+ src = {
3288
+ rules: {
3289
+ "no-bem-class": requireNoBemClass(),
3290
+ "no-deprecated-slds-classes": requireNoDeprecatedSldsClasses()
3291
+ },
3292
+ configs: {
3293
+ recommended: {
3294
+ parser: "@html-eslint/parser", // Use HTML parser
3295
+ plugins: ["sf-sds"],
3296
+ rules: {
3297
+ "sf-sds/no-bem-class": "error",
3298
+ "sf-sds/no-deprecated-slds-classes": "error"
3299
+ },
3300
+ },
3301
+ },
3302
+ };
3303
+ return src;
3304
+ }
3305
+
3306
+ var srcExports = requireSrc();
3307
+ var index = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
3308
+
3309
+ module.exports = index;
3310
+ //# sourceMappingURL=index.js.map