@everymatrix/general-footer-template 1.56.0 → 1.56.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/custom-clock.cjs.entry.js +7 -19
  2. package/dist/cjs/custom-content-section.cjs.entry.js +1482 -1678
  3. package/dist/cjs/general-footer-template.cjs.entry.js +11 -31
  4. package/dist/cjs/general-footer-template.cjs.js +2 -2
  5. package/dist/cjs/image-list.cjs.entry.js +4 -9
  6. package/dist/cjs/{index-c1afe75b.js → index-a7f717fa.js} +91 -227
  7. package/dist/cjs/link-section-list.cjs.entry.js +4 -7
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +2 -2
  10. package/dist/collection/components/custom-clock/custom-clock.js +5 -25
  11. package/dist/collection/components/custom-content-section/custom-content-section.js +2 -14
  12. package/dist/collection/components/general-footer-template/general-footer-template.js +10 -62
  13. package/dist/collection/components/image-list/image-list.js +3 -14
  14. package/dist/collection/components/link-section-list/link-section-list.js +3 -16
  15. package/dist/esm/custom-clock.entry.js +7 -19
  16. package/dist/esm/custom-content-section.entry.js +1482 -1678
  17. package/dist/esm/general-footer-template.entry.js +11 -31
  18. package/dist/esm/general-footer-template.js +3 -3
  19. package/dist/esm/image-list.entry.js +4 -9
  20. package/dist/esm/{index-732f640c.js → index-e6e68604.js} +91 -227
  21. package/dist/esm/link-section-list.entry.js +4 -7
  22. package/dist/esm/loader.js +2 -2
  23. package/dist/general-footer-template/general-footer-template.esm.js +1 -1
  24. package/dist/general-footer-template/p-076550c8.entry.js +1 -0
  25. package/dist/general-footer-template/p-16bd4237.js +2 -0
  26. package/dist/general-footer-template/p-2879096a.entry.js +1 -0
  27. package/dist/general-footer-template/{p-a8c0f5a0.entry.js → p-5f13c34b.entry.js} +2 -2
  28. package/dist/general-footer-template/p-d7132f51.entry.js +1 -0
  29. package/dist/general-footer-template/{p-3eda45d5.entry.js → p-f12f5263.entry.js} +1 -1
  30. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/general-footer-template/.stencil/packages/stencil/general-footer-template/stencil.config.d.ts +2 -0
  31. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/general-footer-template/.stencil/packages/stencil/general-footer-template/stencil.config.dev.d.ts +2 -0
  32. package/dist/types/stencil-public-runtime.d.ts +0 -6
  33. package/package.json +1 -1
  34. package/dist/general-footer-template/p-1fc2e24a.js +0 -2
  35. package/dist/general-footer-template/p-55524eed.entry.js +0 -1
  36. package/dist/general-footer-template/p-a4b44512.entry.js +0 -1
  37. package/dist/general-footer-template/p-dd7ffd49.entry.js +0 -1
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-footer-template/.stencil/packages/stencil/general-footer-template/stencil.config.d.ts +0 -2
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-footer-template/.stencil/packages/stencil/general-footer-template/stencil.config.dev.d.ts +0 -2
  40. /package/dist/types/Users/{adrian.pripon/Documents/Work → maria.bumbar/Desktop}/widgets-monorepo/packages/stencil/general-footer-template/.stencil/tools/plugins/index.d.ts +0 -0
  41. /package/dist/types/Users/{adrian.pripon/Documents/Work → maria.bumbar/Desktop}/widgets-monorepo/packages/stencil/general-footer-template/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +0 -0
  42. /package/dist/types/Users/{adrian.pripon/Documents/Work → maria.bumbar/Desktop}/widgets-monorepo/packages/stencil/general-footer-template/.stencil/tools/plugins/vite-chunk-plugin.d.ts +0 -0
  43. /package/dist/types/Users/{adrian.pripon/Documents/Work → maria.bumbar/Desktop}/widgets-monorepo/packages/stencil/general-footer-template/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h } from './index-732f640c.js';
1
+ import { r as registerInstance, h } from './index-e6e68604.js';
2
2
  import { c as commonjsGlobal, g as getAugmentedNamespace } from './_commonjsHelpers-57e89916.js';
3
3
 
4
4
  var decode = {};
@@ -3327,7 +3327,7 @@ function filter$1(test, node, recurse = true, limit = Infinity) {
3327
3327
  function find(test, nodes, recurse, limit) {
3328
3328
  const result = [];
3329
3329
  /** Stack of the arrays we are looking at. */
3330
- const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
3330
+ const nodeStack = [nodes];
3331
3331
  /** Stack of the indices within the arrays. */
3332
3332
  const indexStack = [0];
3333
3333
  for (;;) {
@@ -3381,19 +3381,20 @@ function findOneChild(test, nodes) {
3381
3381
  * @returns The first node that passes `test`.
3382
3382
  */
3383
3383
  function findOne(test, nodes, recurse = true) {
3384
- const searchedNodes = Array.isArray(nodes) ? nodes : [nodes];
3385
- for (let i = 0; i < searchedNodes.length; i++) {
3386
- const node = searchedNodes[i];
3387
- if (isTag(node) && test(node)) {
3388
- return node;
3384
+ let elem = null;
3385
+ for (let i = 0; i < nodes.length && !elem; i++) {
3386
+ const node = nodes[i];
3387
+ if (!isTag(node)) {
3388
+ continue;
3389
+ }
3390
+ else if (test(node)) {
3391
+ elem = node;
3389
3392
  }
3390
- if (recurse && hasChildren(node) && node.children.length > 0) {
3391
- const found = findOne(test, node.children, true);
3392
- if (found)
3393
- return found;
3393
+ else if (recurse && node.children.length > 0) {
3394
+ elem = findOne(test, node.children, true);
3394
3395
  }
3395
3396
  }
3396
- return null;
3397
+ return elem;
3397
3398
  }
3398
3399
  /**
3399
3400
  * Checks if a tree of nodes contains at least one node passing a test.
@@ -3404,8 +3405,8 @@ function findOne(test, nodes, recurse = true) {
3404
3405
  * @returns Whether a tree of nodes contains at least one node passing the test.
3405
3406
  */
3406
3407
  function existsOne(test, nodes) {
3407
- return (Array.isArray(nodes) ? nodes : [nodes]).some((node) => (isTag(node) && test(node)) ||
3408
- (hasChildren(node) && existsOne(test, node.children)));
3408
+ return nodes.some((checked) => isTag(checked) &&
3409
+ (test(checked) || existsOne(test, checked.children)));
3409
3410
  }
3410
3411
  /**
3411
3412
  * Search an array of nodes and their children for elements passing a test function.
@@ -3419,7 +3420,7 @@ function existsOne(test, nodes) {
3419
3420
  */
3420
3421
  function findAll(test, nodes) {
3421
3422
  const result = [];
3422
- const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
3423
+ const nodeStack = [nodes];
3423
3424
  const indexStack = [0];
3424
3425
  for (;;) {
3425
3426
  if (indexStack[0] >= nodeStack[0].length) {
@@ -3433,9 +3434,11 @@ function findAll(test, nodes) {
3433
3434
  continue;
3434
3435
  }
3435
3436
  const elem = nodeStack[0][indexStack[0]++];
3436
- if (isTag(elem) && test(elem))
3437
+ if (!isTag(elem))
3438
+ continue;
3439
+ if (test(elem))
3437
3440
  result.push(elem);
3438
- if (hasChildren(elem) && elem.children.length > 0) {
3441
+ if (elem.children.length > 0) {
3439
3442
  indexStack.unshift(0);
3440
3443
  nodeStack.unshift(elem.children);
3441
3444
  }
@@ -3565,19 +3568,6 @@ function getElementById(id, nodes, recurse = true) {
3565
3568
  function getElementsByTagName(tagName, nodes, recurse = true, limit = Infinity) {
3566
3569
  return filter$1(Checks["tag_name"](tagName), nodes, recurse, limit);
3567
3570
  }
3568
- /**
3569
- * Returns all nodes with the supplied `className`.
3570
- *
3571
- * @category Legacy Query Functions
3572
- * @param className Class name to search for.
3573
- * @param nodes Nodes to search through.
3574
- * @param recurse Also consider child nodes.
3575
- * @param limit Maximum number of nodes to return.
3576
- * @returns All nodes with the supplied `className`.
3577
- */
3578
- function getElementsByClassName(className, nodes, recurse = true, limit = Infinity) {
3579
- return filter$1(getAttribCheck("class", className), nodes, recurse, limit);
3580
- }
3581
3571
  /**
3582
3572
  * Returns all nodes with the supplied `type`.
3583
3573
  *
@@ -3945,7 +3935,6 @@ const index = /*#__PURE__*/Object.freeze({
3945
3935
  getElements: getElements,
3946
3936
  getElementById: getElementById,
3947
3937
  getElementsByTagName: getElementsByTagName,
3948
- getElementsByClassName: getElementsByClassName,
3949
3938
  getElementsByTagType: getElementsByTagType,
3950
3939
  removeSubsets: removeSubsets,
3951
3940
  get DocumentPosition () { return DocumentPosition; },
@@ -4016,7 +4005,7 @@ const esm = /*#__PURE__*/Object.freeze({
4016
4005
  DomUtils: index
4017
4006
  });
4018
4007
 
4019
- const require$$0$1 = /*@__PURE__*/getAugmentedNamespace(esm);
4008
+ const require$$0 = /*@__PURE__*/getAugmentedNamespace(esm);
4020
4009
 
4021
4010
  var escapeStringRegexp$1 = string => {
4022
4011
  if (typeof string !== 'string') {
@@ -4599,70 +4588,37 @@ class CssSyntaxError$3 extends Error {
4599
4588
 
4600
4589
  let css = this.source;
4601
4590
  if (color == null) color = pico.isColorSupported;
4602
-
4603
- let aside = text => text;
4604
- let mark = text => text;
4605
- let highlight = text => text;
4606
- if (color) {
4607
- let { bold, gray, red } = pico.createColors(true);
4608
- mark = text => bold(red(text));
4609
- aside = text => gray(text);
4610
- if (terminalHighlight$1) {
4611
- highlight = text => terminalHighlight$1(text);
4612
- }
4591
+ if (terminalHighlight$1) {
4592
+ if (color) css = terminalHighlight$1(css);
4613
4593
  }
4614
4594
 
4615
4595
  let lines = css.split(/\r?\n/);
4616
4596
  let start = Math.max(this.line - 3, 0);
4617
4597
  let end = Math.min(this.line + 2, lines.length);
4598
+
4618
4599
  let maxWidth = String(end).length;
4619
4600
 
4601
+ let mark, aside;
4602
+ if (color) {
4603
+ let { bold, gray, red } = pico.createColors(true);
4604
+ mark = text => bold(red(text));
4605
+ aside = text => gray(text);
4606
+ } else {
4607
+ mark = aside = str => str;
4608
+ }
4609
+
4620
4610
  return lines
4621
4611
  .slice(start, end)
4622
4612
  .map((line, index) => {
4623
4613
  let number = start + 1 + index;
4624
4614
  let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
4625
4615
  if (number === this.line) {
4626
- if (line.length > 160) {
4627
- let padding = 20;
4628
- let subLineStart = Math.max(0, this.column - padding);
4629
- let subLineEnd = Math.max(
4630
- this.column + padding,
4631
- this.endColumn + padding
4632
- );
4633
- let subLine = line.slice(subLineStart, subLineEnd);
4634
-
4635
- let spacing =
4636
- aside(gutter.replace(/\d/g, ' ')) +
4637
- line
4638
- .slice(0, Math.min(this.column - 1, padding - 1))
4639
- .replace(/[^\t]/g, ' ');
4640
-
4641
- return (
4642
- mark('>') +
4643
- aside(gutter) +
4644
- highlight(subLine) +
4645
- '\n ' +
4646
- spacing +
4647
- mark('^')
4648
- )
4649
- }
4650
-
4651
4616
  let spacing =
4652
4617
  aside(gutter.replace(/\d/g, ' ')) +
4653
4618
  line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
4654
-
4655
- return (
4656
- mark('>') +
4657
- aside(gutter) +
4658
- highlight(line) +
4659
- '\n ' +
4660
- spacing +
4661
- mark('^')
4662
- )
4619
+ return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
4663
4620
  }
4664
-
4665
- return ' ' + aside(gutter) + highlight(line)
4621
+ return ' ' + aside(gutter) + line
4666
4622
  })
4667
4623
  .join('\n')
4668
4624
  }
@@ -4679,6 +4635,12 @@ class CssSyntaxError$3 extends Error {
4679
4635
  var cssSyntaxError = CssSyntaxError$3;
4680
4636
  CssSyntaxError$3.default = CssSyntaxError$3;
4681
4637
 
4638
+ var symbols = {};
4639
+
4640
+ symbols.isClean = Symbol('isClean');
4641
+
4642
+ symbols.my = Symbol('my');
4643
+
4682
4644
  const DEFAULT_RAW = {
4683
4645
  after: '\n',
4684
4646
  beforeClose: '\n',
@@ -5041,16 +5003,10 @@ function stringify$4(node, builder) {
5041
5003
  var stringify_1 = stringify$4;
5042
5004
  stringify$4.default = stringify$4;
5043
5005
 
5044
- var symbols = {};
5045
-
5046
- symbols.isClean = Symbol('isClean');
5047
-
5048
- symbols.my = Symbol('my');
5049
-
5006
+ let { isClean: isClean$2, my: my$2 } = symbols;
5050
5007
  let CssSyntaxError$2 = cssSyntaxError;
5051
5008
  let Stringifier = stringifier;
5052
5009
  let stringify$3 = stringify_1;
5053
- let { isClean: isClean$2, my: my$2 } = symbols;
5054
5010
 
5055
5011
  function cloneNode(obj, parent) {
5056
5012
  let cloned = new obj.constructor();
@@ -5079,41 +5035,7 @@ function cloneNode(obj, parent) {
5079
5035
  return cloned
5080
5036
  }
5081
5037
 
5082
- function sourceOffset(inputCSS, position) {
5083
- // Not all custom syntaxes support `offset` in `source.start` and `source.end`
5084
- if (
5085
- position &&
5086
- typeof position.offset !== 'undefined'
5087
- ) {
5088
- return position.offset;
5089
- }
5090
-
5091
- let column = 1;
5092
- let line = 1;
5093
- let offset = 0;
5094
-
5095
- for (let i = 0; i < inputCSS.length; i++) {
5096
- if (line === position.line && column === position.column) {
5097
- offset = i;
5098
- break
5099
- }
5100
-
5101
- if (inputCSS[i] === '\n') {
5102
- column = 1;
5103
- line += 1;
5104
- } else {
5105
- column += 1;
5106
- }
5107
- }
5108
-
5109
- return offset
5110
- }
5111
-
5112
5038
  class Node$4 {
5113
- get proxyOf() {
5114
- return this
5115
- }
5116
-
5117
5039
  constructor(defaults = {}) {
5118
5040
  this.raws = {};
5119
5041
  this[isClean$2] = false;
@@ -5234,11 +5156,6 @@ class Node$4 {
5234
5156
  }
5235
5157
  }
5236
5158
 
5237
- /* c8 ignore next 3 */
5238
- markClean() {
5239
- this[isClean$2] = true;
5240
- }
5241
-
5242
5159
  markDirty() {
5243
5160
  if (this[isClean$2]) {
5244
5161
  this[isClean$2] = false;
@@ -5255,35 +5172,25 @@ class Node$4 {
5255
5172
  return this.parent.nodes[index + 1]
5256
5173
  }
5257
5174
 
5258
- positionBy(opts) {
5175
+ positionBy(opts, stringRepresentation) {
5259
5176
  let pos = this.source.start;
5260
5177
  if (opts.index) {
5261
- pos = this.positionInside(opts.index);
5178
+ pos = this.positionInside(opts.index, stringRepresentation);
5262
5179
  } else if (opts.word) {
5263
- let inputString = ('document' in this.source.input)
5264
- ? this.source.input.document
5265
- : this.source.input.css;
5266
- let stringRepresentation = inputString.slice(
5267
- sourceOffset(inputString, this.source.start),
5268
- sourceOffset(inputString, this.source.end)
5269
- );
5180
+ stringRepresentation = this.toString();
5270
5181
  let index = stringRepresentation.indexOf(opts.word);
5271
- if (index !== -1) pos = this.positionInside(index);
5182
+ if (index !== -1) pos = this.positionInside(index, stringRepresentation);
5272
5183
  }
5273
5184
  return pos
5274
5185
  }
5275
5186
 
5276
- positionInside(index) {
5187
+ positionInside(index, stringRepresentation) {
5188
+ let string = stringRepresentation || this.toString();
5277
5189
  let column = this.source.start.column;
5278
5190
  let line = this.source.start.line;
5279
- let inputString = ('document' in this.source.input)
5280
- ? this.source.input.document
5281
- : this.source.input.css;
5282
- let offset = sourceOffset(inputString, this.source.start);
5283
- let end = offset + index;
5284
-
5285
- for (let i = offset; i < end; i++) {
5286
- if (inputString[i] === '\n') {
5191
+
5192
+ for (let i = 0; i < index; i++) {
5193
+ if (string[i] === '\n') {
5287
5194
  column = 1;
5288
5195
  line += 1;
5289
5196
  } else {
@@ -5307,28 +5214,20 @@ class Node$4 {
5307
5214
  };
5308
5215
  let end = this.source.end
5309
5216
  ? {
5310
- column: this.source.end.column + 1,
5311
- line: this.source.end.line
5312
- }
5217
+ column: this.source.end.column + 1,
5218
+ line: this.source.end.line
5219
+ }
5313
5220
  : {
5314
- column: start.column + 1,
5315
- line: start.line
5316
- };
5221
+ column: start.column + 1,
5222
+ line: start.line
5223
+ };
5317
5224
 
5318
5225
  if (opts.word) {
5319
- let inputString = ('document' in this.source.input)
5320
- ? this.source.input.document
5321
- : this.source.input.css;
5322
- let stringRepresentation = inputString.slice(
5323
- sourceOffset(inputString, this.source.start),
5324
- sourceOffset(inputString, this.source.end)
5325
- );
5226
+ let stringRepresentation = this.toString();
5326
5227
  let index = stringRepresentation.indexOf(opts.word);
5327
5228
  if (index !== -1) {
5328
- start = this.positionInside(index);
5329
- end = this.positionInside(
5330
- index + opts.word.length,
5331
- );
5229
+ start = this.positionInside(index, stringRepresentation);
5230
+ end = this.positionInside(index + opts.word.length, stringRepresentation);
5332
5231
  }
5333
5232
  } else {
5334
5233
  if (opts.start) {
@@ -5345,7 +5244,7 @@ class Node$4 {
5345
5244
  column: opts.end.column,
5346
5245
  line: opts.end.line
5347
5246
  };
5348
- } else if (typeof opts.endIndex === 'number') {
5247
+ } else if (opts.endIndex) {
5349
5248
  end = this.positionInside(opts.endIndex);
5350
5249
  } else if (opts.index) {
5351
5250
  end = this.positionInside(opts.index + 1);
@@ -5475,6 +5374,10 @@ class Node$4 {
5475
5374
  for (let i in opts) data[i] = opts[i];
5476
5375
  return result.warn(text, data)
5477
5376
  }
5377
+
5378
+ get proxyOf() {
5379
+ return this
5380
+ }
5478
5381
  }
5479
5382
 
5480
5383
  var node_1 = Node$4;
@@ -5482,23 +5385,7 @@ Node$4.default = Node$4;
5482
5385
 
5483
5386
  let Node$3 = node_1;
5484
5387
 
5485
- class Comment$4 extends Node$3 {
5486
- constructor(defaults) {
5487
- super(defaults);
5488
- this.type = 'comment';
5489
- }
5490
- }
5491
-
5492
- var comment = Comment$4;
5493
- Comment$4.default = Comment$4;
5494
-
5495
- let Node$2 = node_1;
5496
-
5497
- class Declaration$4 extends Node$2 {
5498
- get variable() {
5499
- return this.prop.startsWith('--') || this.prop[0] === '$'
5500
- }
5501
-
5388
+ class Declaration$4 extends Node$3 {
5502
5389
  constructor(defaults) {
5503
5390
  if (
5504
5391
  defaults &&
@@ -5510,1508 +5397,1362 @@ class Declaration$4 extends Node$2 {
5510
5397
  super(defaults);
5511
5398
  this.type = 'decl';
5512
5399
  }
5400
+
5401
+ get variable() {
5402
+ return this.prop.startsWith('--') || this.prop[0] === '$'
5403
+ }
5513
5404
  }
5514
5405
 
5515
5406
  var declaration = Declaration$4;
5516
5407
  Declaration$4.default = Declaration$4;
5517
5408
 
5518
- let Comment$3 = comment;
5519
- let Declaration$3 = declaration;
5520
- let Node$1 = node_1;
5521
- let { isClean: isClean$1, my: my$1 } = symbols;
5522
-
5523
- let AtRule$4, parse$4, Root$6, Rule$4;
5524
-
5525
- function cleanSource(nodes) {
5526
- return nodes.map(i => {
5527
- if (i.nodes) i.nodes = cleanSource(i.nodes);
5528
- delete i.source;
5529
- return i
5530
- })
5531
- }
5409
+ // This alphabet uses `A-Za-z0-9_-` symbols.
5410
+ // The order of characters is optimized for better gzip and brotli compression.
5411
+ // References to the same file (works both for gzip and brotli):
5412
+ // `'use`, `andom`, and `rict'`
5413
+ // References to the brotli default dictionary:
5414
+ // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
5415
+ let urlAlphabet =
5416
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
5532
5417
 
5533
- function markTreeDirty(node) {
5534
- node[isClean$1] = false;
5535
- if (node.proxyOf.nodes) {
5536
- for (let i of node.proxyOf.nodes) {
5537
- markTreeDirty(i);
5418
+ let customAlphabet = (alphabet, defaultSize = 21) => {
5419
+ return (size = defaultSize) => {
5420
+ let id = '';
5421
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
5422
+ let i = size | 0;
5423
+ while (i--) {
5424
+ // `| 0` is more compact and faster than `Math.floor()`.
5425
+ id += alphabet[(Math.random() * alphabet.length) | 0];
5538
5426
  }
5427
+ return id
5539
5428
  }
5540
- }
5429
+ };
5541
5430
 
5542
- class Container$7 extends Node$1 {
5543
- get first() {
5544
- if (!this.proxyOf.nodes) return undefined
5545
- return this.proxyOf.nodes[0]
5431
+ let nanoid$1 = (size = 21) => {
5432
+ let id = '';
5433
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
5434
+ let i = size | 0;
5435
+ while (i--) {
5436
+ // `| 0` is more compact and faster than `Math.floor()`.
5437
+ id += urlAlphabet[(Math.random() * 64) | 0];
5546
5438
  }
5439
+ return id
5440
+ };
5547
5441
 
5548
- get last() {
5549
- if (!this.proxyOf.nodes) return undefined
5550
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
5551
- }
5442
+ const nonSecure = /*#__PURE__*/Object.freeze({
5443
+ __proto__: null,
5444
+ nanoid: nanoid$1,
5445
+ customAlphabet: customAlphabet
5446
+ });
5552
5447
 
5553
- append(...children) {
5554
- for (let child of children) {
5555
- let nodes = this.normalize(child, this.last);
5556
- for (let node of nodes) this.proxyOf.nodes.push(node);
5557
- }
5448
+ const require$$3 = /*@__PURE__*/getAugmentedNamespace(nonSecure);
5558
5449
 
5559
- this.markDirty();
5450
+ let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
5451
+ let { existsSync, readFileSync } = require$$2;
5452
+ let { dirname: dirname$1, join } = require$$2;
5560
5453
 
5561
- return this
5454
+ function fromBase64(str) {
5455
+ if (Buffer) {
5456
+ return Buffer.from(str, 'base64').toString()
5457
+ } else {
5458
+ /* c8 ignore next 2 */
5459
+ return window.atob(str)
5562
5460
  }
5461
+ }
5563
5462
 
5564
- cleanRaws(keepBetween) {
5565
- super.cleanRaws(keepBetween);
5566
- if (this.nodes) {
5567
- for (let node of this.nodes) node.cleanRaws(keepBetween);
5463
+ class PreviousMap$2 {
5464
+ constructor(css, opts) {
5465
+ if (opts.map === false) return
5466
+ this.loadAnnotation(css);
5467
+ this.inline = this.startWith(this.annotation, 'data:');
5468
+
5469
+ let prev = opts.map ? opts.map.prev : undefined;
5470
+ let text = this.loadMap(opts.from, prev);
5471
+ if (!this.mapFile && opts.from) {
5472
+ this.mapFile = opts.from;
5568
5473
  }
5474
+ if (this.mapFile) this.root = dirname$1(this.mapFile);
5475
+ if (text) this.text = text;
5569
5476
  }
5570
5477
 
5571
- each(callback) {
5572
- if (!this.proxyOf.nodes) return undefined
5573
- let iterator = this.getIterator();
5478
+ consumer() {
5479
+ if (!this.consumerCache) {
5480
+ this.consumerCache = new SourceMapConsumer$2(this.text);
5481
+ }
5482
+ return this.consumerCache
5483
+ }
5574
5484
 
5575
- let index, result;
5576
- while (this.indexes[iterator] < this.proxyOf.nodes.length) {
5577
- index = this.indexes[iterator];
5578
- result = callback(this.proxyOf.nodes[index], index);
5579
- if (result === false) break
5485
+ decodeInline(text) {
5486
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
5487
+ let baseUri = /^data:application\/json;base64,/;
5488
+ let charsetUri = /^data:application\/json;charset=utf-?8,/;
5489
+ let uri = /^data:application\/json,/;
5580
5490
 
5581
- this.indexes[iterator] += 1;
5491
+ if (charsetUri.test(text) || uri.test(text)) {
5492
+ return decodeURIComponent(text.substr(RegExp.lastMatch.length))
5582
5493
  }
5583
5494
 
5584
- delete this.indexes[iterator];
5585
- return result
5495
+ if (baseCharsetUri.test(text) || baseUri.test(text)) {
5496
+ return fromBase64(text.substr(RegExp.lastMatch.length))
5497
+ }
5498
+
5499
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
5500
+ throw new Error('Unsupported source map encoding ' + encoding)
5586
5501
  }
5587
5502
 
5588
- every(condition) {
5589
- return this.nodes.every(condition)
5503
+ getAnnotationURL(sourceMapString) {
5504
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
5590
5505
  }
5591
5506
 
5592
- getIterator() {
5593
- if (!this.lastEach) this.lastEach = 0;
5594
- if (!this.indexes) this.indexes = {};
5507
+ isMap(map) {
5508
+ if (typeof map !== 'object') return false
5509
+ return (
5510
+ typeof map.mappings === 'string' ||
5511
+ typeof map._mappings === 'string' ||
5512
+ Array.isArray(map.sections)
5513
+ )
5514
+ }
5595
5515
 
5596
- this.lastEach += 1;
5597
- let iterator = this.lastEach;
5598
- this.indexes[iterator] = 0;
5516
+ loadAnnotation(css) {
5517
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
5518
+ if (!comments) return
5599
5519
 
5600
- return iterator
5520
+ // sourceMappingURLs from comments, strings, etc.
5521
+ let start = css.lastIndexOf(comments.pop());
5522
+ let end = css.indexOf('*/', start);
5523
+
5524
+ if (start > -1 && end > -1) {
5525
+ // Locate the last sourceMappingURL to avoid pickin
5526
+ this.annotation = this.getAnnotationURL(css.substring(start, end));
5527
+ }
5601
5528
  }
5602
5529
 
5603
- getProxyProcessor() {
5604
- return {
5605
- get(node, prop) {
5606
- if (prop === 'proxyOf') {
5607
- return node
5608
- } else if (!node[prop]) {
5609
- return node[prop]
5610
- } else if (
5611
- prop === 'each' ||
5612
- (typeof prop === 'string' && prop.startsWith('walk'))
5613
- ) {
5614
- return (...args) => {
5615
- return node[prop](
5616
- ...args.map(i => {
5617
- if (typeof i === 'function') {
5618
- return (child, index) => i(child.toProxy(), index)
5619
- } else {
5620
- return i
5621
- }
5622
- })
5623
- )
5624
- }
5625
- } else if (prop === 'every' || prop === 'some') {
5626
- return cb => {
5627
- return node[prop]((child, ...other) =>
5628
- cb(child.toProxy(), ...other)
5530
+ loadFile(path) {
5531
+ this.root = dirname$1(path);
5532
+ if (existsSync(path)) {
5533
+ this.mapFile = path;
5534
+ return readFileSync(path, 'utf-8').toString().trim()
5535
+ }
5536
+ }
5537
+
5538
+ loadMap(file, prev) {
5539
+ if (prev === false) return false
5540
+
5541
+ if (prev) {
5542
+ if (typeof prev === 'string') {
5543
+ return prev
5544
+ } else if (typeof prev === 'function') {
5545
+ let prevPath = prev(file);
5546
+ if (prevPath) {
5547
+ let map = this.loadFile(prevPath);
5548
+ if (!map) {
5549
+ throw new Error(
5550
+ 'Unable to load previous source map: ' + prevPath.toString()
5629
5551
  )
5630
5552
  }
5631
- } else if (prop === 'root') {
5632
- return () => node.root().toProxy()
5633
- } else if (prop === 'nodes') {
5634
- return node.nodes.map(i => i.toProxy())
5635
- } else if (prop === 'first' || prop === 'last') {
5636
- return node[prop].toProxy()
5637
- } else {
5638
- return node[prop]
5639
- }
5640
- },
5641
-
5642
- set(node, prop, value) {
5643
- if (node[prop] === value) return true
5644
- node[prop] = value;
5645
- if (prop === 'name' || prop === 'params' || prop === 'selector') {
5646
- node.markDirty();
5553
+ return map
5647
5554
  }
5648
- return true
5555
+ } else if (prev instanceof SourceMapConsumer$2) {
5556
+ return SourceMapGenerator$2.fromSourceMap(prev).toString()
5557
+ } else if (prev instanceof SourceMapGenerator$2) {
5558
+ return prev.toString()
5559
+ } else if (this.isMap(prev)) {
5560
+ return JSON.stringify(prev)
5561
+ } else {
5562
+ throw new Error(
5563
+ 'Unsupported previous source map format: ' + prev.toString()
5564
+ )
5649
5565
  }
5566
+ } else if (this.inline) {
5567
+ return this.decodeInline(this.annotation)
5568
+ } else if (this.annotation) {
5569
+ let map = this.annotation;
5570
+ if (file) map = join(dirname$1(file), map);
5571
+ return this.loadFile(map)
5650
5572
  }
5651
5573
  }
5652
5574
 
5653
- index(child) {
5654
- if (typeof child === 'number') return child
5655
- if (child.proxyOf) child = child.proxyOf;
5656
- return this.proxyOf.nodes.indexOf(child)
5575
+ startWith(string, start) {
5576
+ if (!string) return false
5577
+ return string.substr(0, start.length) === start
5657
5578
  }
5658
5579
 
5659
- insertAfter(exist, add) {
5660
- let existIndex = this.index(exist);
5661
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
5662
- existIndex = this.index(exist);
5663
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
5580
+ withContent() {
5581
+ return !!(
5582
+ this.consumer().sourcesContent &&
5583
+ this.consumer().sourcesContent.length > 0
5584
+ )
5585
+ }
5586
+ }
5664
5587
 
5665
- let index;
5666
- for (let id in this.indexes) {
5667
- index = this.indexes[id];
5668
- if (existIndex < index) {
5669
- this.indexes[id] = index + nodes.length;
5670
- }
5671
- }
5588
+ var previousMap = PreviousMap$2;
5589
+ PreviousMap$2.default = PreviousMap$2;
5672
5590
 
5673
- this.markDirty();
5591
+ let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
5592
+ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
5593
+ let { isAbsolute, resolve: resolve$1 } = require$$2;
5594
+ let { nanoid } = require$$3;
5674
5595
 
5675
- return this
5676
- }
5596
+ let terminalHighlight = require$$2;
5597
+ let CssSyntaxError$1 = cssSyntaxError;
5598
+ let PreviousMap$1 = previousMap;
5677
5599
 
5678
- insertBefore(exist, add) {
5679
- let existIndex = this.index(exist);
5680
- let type = existIndex === 0 ? 'prepend' : false;
5681
- let nodes = this.normalize(
5682
- add,
5683
- this.proxyOf.nodes[existIndex],
5684
- type
5685
- ).reverse();
5686
- existIndex = this.index(exist);
5687
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
5600
+ let fromOffsetCache = Symbol('fromOffsetCache');
5688
5601
 
5689
- let index;
5690
- for (let id in this.indexes) {
5691
- index = this.indexes[id];
5692
- if (existIndex <= index) {
5693
- this.indexes[id] = index + nodes.length;
5694
- }
5695
- }
5602
+ let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
5603
+ let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
5696
5604
 
5697
- this.markDirty();
5605
+ class Input$4 {
5606
+ constructor(css, opts = {}) {
5607
+ if (
5608
+ css === null ||
5609
+ typeof css === 'undefined' ||
5610
+ (typeof css === 'object' && !css.toString)
5611
+ ) {
5612
+ throw new Error(`PostCSS received ${css} instead of CSS string`)
5613
+ }
5698
5614
 
5699
- return this
5700
- }
5615
+ this.css = css.toString();
5701
5616
 
5702
- normalize(nodes, sample) {
5703
- if (typeof nodes === 'string') {
5704
- nodes = cleanSource(parse$4(nodes).nodes);
5705
- } else if (typeof nodes === 'undefined') {
5706
- nodes = [];
5707
- } else if (Array.isArray(nodes)) {
5708
- nodes = nodes.slice(0);
5709
- for (let i of nodes) {
5710
- if (i.parent) i.parent.removeChild(i, 'ignore');
5711
- }
5712
- } else if (nodes.type === 'root' && this.type !== 'document') {
5713
- nodes = nodes.nodes.slice(0);
5714
- for (let i of nodes) {
5715
- if (i.parent) i.parent.removeChild(i, 'ignore');
5716
- }
5717
- } else if (nodes.type) {
5718
- nodes = [nodes];
5719
- } else if (nodes.prop) {
5720
- if (typeof nodes.value === 'undefined') {
5721
- throw new Error('Value field is missed in node creation')
5722
- } else if (typeof nodes.value !== 'string') {
5723
- nodes.value = String(nodes.value);
5724
- }
5725
- nodes = [new Declaration$3(nodes)];
5726
- } else if (nodes.selector || nodes.selectors) {
5727
- nodes = [new Rule$4(nodes)];
5728
- } else if (nodes.name) {
5729
- nodes = [new AtRule$4(nodes)];
5730
- } else if (nodes.text) {
5731
- nodes = [new Comment$3(nodes)];
5617
+ if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
5618
+ this.hasBOM = true;
5619
+ this.css = this.css.slice(1);
5732
5620
  } else {
5733
- throw new Error('Unknown node type in node creation')
5621
+ this.hasBOM = false;
5734
5622
  }
5735
5623
 
5736
- let processed = nodes.map(i => {
5737
- /* c8 ignore next */
5738
- if (!i[my$1]) Container$7.rebuild(i);
5739
- i = i.proxyOf;
5740
- if (i.parent) i.parent.removeChild(i);
5741
- if (i[isClean$1]) markTreeDirty(i);
5742
-
5743
- if (!i.raws) i.raws = {};
5744
- if (typeof i.raws.before === 'undefined') {
5745
- if (sample && typeof sample.raws.before !== 'undefined') {
5746
- i.raws.before = sample.raws.before.replace(/\S/g, '');
5747
- }
5624
+ if (opts.from) {
5625
+ if (
5626
+ !pathAvailable$1 ||
5627
+ /^\w+:\/\//.test(opts.from) ||
5628
+ isAbsolute(opts.from)
5629
+ ) {
5630
+ this.file = opts.from;
5631
+ } else {
5632
+ this.file = resolve$1(opts.from);
5748
5633
  }
5749
- i.parent = this.proxyOf;
5750
- return i
5751
- });
5752
-
5753
- return processed
5754
- }
5634
+ }
5755
5635
 
5756
- prepend(...children) {
5757
- children = children.reverse();
5758
- for (let child of children) {
5759
- let nodes = this.normalize(child, this.first, 'prepend').reverse();
5760
- for (let node of nodes) this.proxyOf.nodes.unshift(node);
5761
- for (let id in this.indexes) {
5762
- this.indexes[id] = this.indexes[id] + nodes.length;
5636
+ if (pathAvailable$1 && sourceMapAvailable$1) {
5637
+ let map = new PreviousMap$1(this.css, opts);
5638
+ if (map.text) {
5639
+ this.map = map;
5640
+ let file = map.consumer().file;
5641
+ if (!this.file && file) this.file = this.mapResolve(file);
5763
5642
  }
5764
5643
  }
5765
5644
 
5766
- this.markDirty();
5767
-
5768
- return this
5769
- }
5770
-
5771
- push(child) {
5772
- child.parent = this;
5773
- this.proxyOf.nodes.push(child);
5774
- return this
5775
- }
5776
-
5777
- removeAll() {
5778
- for (let node of this.proxyOf.nodes) node.parent = undefined;
5779
- this.proxyOf.nodes = [];
5780
-
5781
- this.markDirty();
5782
-
5783
- return this
5645
+ if (!this.file) {
5646
+ this.id = '<input css ' + nanoid(6) + '>';
5647
+ }
5648
+ if (this.map) this.map.file = this.from;
5784
5649
  }
5785
5650
 
5786
- removeChild(child) {
5787
- child = this.index(child);
5788
- this.proxyOf.nodes[child].parent = undefined;
5789
- this.proxyOf.nodes.splice(child, 1);
5651
+ error(message, line, column, opts = {}) {
5652
+ let result, endLine, endColumn;
5790
5653
 
5791
- let index;
5792
- for (let id in this.indexes) {
5793
- index = this.indexes[id];
5794
- if (index >= child) {
5795
- this.indexes[id] = index - 1;
5654
+ if (line && typeof line === 'object') {
5655
+ let start = line;
5656
+ let end = column;
5657
+ if (typeof start.offset === 'number') {
5658
+ let pos = this.fromOffset(start.offset);
5659
+ line = pos.line;
5660
+ column = pos.col;
5661
+ } else {
5662
+ line = start.line;
5663
+ column = start.column;
5664
+ }
5665
+ if (typeof end.offset === 'number') {
5666
+ let pos = this.fromOffset(end.offset);
5667
+ endLine = pos.line;
5668
+ endColumn = pos.col;
5669
+ } else {
5670
+ endLine = end.line;
5671
+ endColumn = end.column;
5796
5672
  }
5673
+ } else if (!column) {
5674
+ let pos = this.fromOffset(line);
5675
+ line = pos.line;
5676
+ column = pos.col;
5797
5677
  }
5798
5678
 
5799
- this.markDirty();
5800
-
5801
- return this
5802
- }
5803
-
5804
- replaceValues(pattern, opts, callback) {
5805
- if (!callback) {
5806
- callback = opts;
5807
- opts = {};
5679
+ let origin = this.origin(line, column, endLine, endColumn);
5680
+ if (origin) {
5681
+ result = new CssSyntaxError$1(
5682
+ message,
5683
+ origin.endLine === undefined
5684
+ ? origin.line
5685
+ : { column: origin.column, line: origin.line },
5686
+ origin.endLine === undefined
5687
+ ? origin.column
5688
+ : { column: origin.endColumn, line: origin.endLine },
5689
+ origin.source,
5690
+ origin.file,
5691
+ opts.plugin
5692
+ );
5693
+ } else {
5694
+ result = new CssSyntaxError$1(
5695
+ message,
5696
+ endLine === undefined ? line : { column, line },
5697
+ endLine === undefined ? column : { column: endColumn, line: endLine },
5698
+ this.css,
5699
+ this.file,
5700
+ opts.plugin
5701
+ );
5808
5702
  }
5809
5703
 
5810
- this.walkDecls(decl => {
5811
- if (opts.props && !opts.props.includes(decl.prop)) return
5812
- if (opts.fast && !decl.value.includes(opts.fast)) return
5813
-
5814
- decl.value = decl.value.replace(pattern, callback);
5815
- });
5816
-
5817
- this.markDirty();
5704
+ result.input = { column, endColumn, endLine, line, source: this.css };
5705
+ if (this.file) {
5706
+ if (pathToFileURL$1) {
5707
+ result.input.url = pathToFileURL$1(this.file).toString();
5708
+ }
5709
+ result.input.file = this.file;
5710
+ }
5818
5711
 
5819
- return this
5712
+ return result
5820
5713
  }
5821
5714
 
5822
- some(condition) {
5823
- return this.nodes.some(condition)
5824
- }
5715
+ fromOffset(offset) {
5716
+ let lastLine, lineToIndex;
5717
+ if (!this[fromOffsetCache]) {
5718
+ let lines = this.css.split('\n');
5719
+ lineToIndex = new Array(lines.length);
5720
+ let prevIndex = 0;
5825
5721
 
5826
- walk(callback) {
5827
- return this.each((child, i) => {
5828
- let result;
5829
- try {
5830
- result = callback(child, i);
5831
- } catch (e) {
5832
- throw child.addToError(e)
5833
- }
5834
- if (result !== false && child.walk) {
5835
- result = child.walk(callback);
5722
+ for (let i = 0, l = lines.length; i < l; i++) {
5723
+ lineToIndex[i] = prevIndex;
5724
+ prevIndex += lines[i].length + 1;
5836
5725
  }
5837
5726
 
5838
- return result
5839
- })
5840
- }
5727
+ this[fromOffsetCache] = lineToIndex;
5728
+ } else {
5729
+ lineToIndex = this[fromOffsetCache];
5730
+ }
5731
+ lastLine = lineToIndex[lineToIndex.length - 1];
5841
5732
 
5842
- walkAtRules(name, callback) {
5843
- if (!callback) {
5844
- callback = name;
5845
- return this.walk((child, i) => {
5846
- if (child.type === 'atrule') {
5847
- return callback(child, i)
5733
+ let min = 0;
5734
+ if (offset >= lastLine) {
5735
+ min = lineToIndex.length - 1;
5736
+ } else {
5737
+ let max = lineToIndex.length - 2;
5738
+ let mid;
5739
+ while (min < max) {
5740
+ mid = min + ((max - min) >> 1);
5741
+ if (offset < lineToIndex[mid]) {
5742
+ max = mid - 1;
5743
+ } else if (offset >= lineToIndex[mid + 1]) {
5744
+ min = mid + 1;
5745
+ } else {
5746
+ min = mid;
5747
+ break
5848
5748
  }
5849
- })
5749
+ }
5850
5750
  }
5851
- if (name instanceof RegExp) {
5852
- return this.walk((child, i) => {
5853
- if (child.type === 'atrule' && name.test(child.name)) {
5854
- return callback(child, i)
5855
- }
5856
- })
5751
+ return {
5752
+ col: offset - lineToIndex[min] + 1,
5753
+ line: min + 1
5857
5754
  }
5858
- return this.walk((child, i) => {
5859
- if (child.type === 'atrule' && child.name === name) {
5860
- return callback(child, i)
5861
- }
5862
- })
5863
5755
  }
5864
5756
 
5865
- walkComments(callback) {
5866
- return this.walk((child, i) => {
5867
- if (child.type === 'comment') {
5868
- return callback(child, i)
5869
- }
5870
- })
5757
+ mapResolve(file) {
5758
+ if (/^\w+:\/\//.test(file)) {
5759
+ return file
5760
+ }
5761
+ return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
5871
5762
  }
5872
5763
 
5873
- walkDecls(prop, callback) {
5874
- if (!callback) {
5875
- callback = prop;
5876
- return this.walk((child, i) => {
5877
- if (child.type === 'decl') {
5878
- return callback(child, i)
5879
- }
5880
- })
5764
+ origin(line, column, endLine, endColumn) {
5765
+ if (!this.map) return false
5766
+ let consumer = this.map.consumer();
5767
+
5768
+ let from = consumer.originalPositionFor({ column, line });
5769
+ if (!from.source) return false
5770
+
5771
+ let to;
5772
+ if (typeof endLine === 'number') {
5773
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
5881
5774
  }
5882
- if (prop instanceof RegExp) {
5883
- return this.walk((child, i) => {
5884
- if (child.type === 'decl' && prop.test(child.prop)) {
5885
- return callback(child, i)
5886
- }
5887
- })
5775
+
5776
+ let fromUrl;
5777
+
5778
+ if (isAbsolute(from.source)) {
5779
+ fromUrl = pathToFileURL$1(from.source);
5780
+ } else {
5781
+ fromUrl = new URL(
5782
+ from.source,
5783
+ this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
5784
+ );
5888
5785
  }
5889
- return this.walk((child, i) => {
5890
- if (child.type === 'decl' && child.prop === prop) {
5891
- return callback(child, i)
5892
- }
5893
- })
5894
- }
5895
5786
 
5896
- walkRules(selector, callback) {
5897
- if (!callback) {
5898
- callback = selector;
5787
+ let result = {
5788
+ column: from.column,
5789
+ endColumn: to && to.column,
5790
+ endLine: to && to.line,
5791
+ line: from.line,
5792
+ url: fromUrl.toString()
5793
+ };
5899
5794
 
5900
- return this.walk((child, i) => {
5901
- if (child.type === 'rule') {
5902
- return callback(child, i)
5903
- }
5904
- })
5795
+ if (fromUrl.protocol === 'file:') {
5796
+ if (fileURLToPath) {
5797
+ result.file = fileURLToPath(fromUrl);
5798
+ } else {
5799
+ /* c8 ignore next 2 */
5800
+ throw new Error(`file: protocol is not available in this PostCSS build`)
5801
+ }
5905
5802
  }
5906
- if (selector instanceof RegExp) {
5907
- return this.walk((child, i) => {
5908
- if (child.type === 'rule' && selector.test(child.selector)) {
5909
- return callback(child, i)
5910
- }
5911
- })
5803
+
5804
+ let source = consumer.sourceContentFor(from.source);
5805
+ if (source) result.source = source;
5806
+
5807
+ return result
5808
+ }
5809
+
5810
+ toJSON() {
5811
+ let json = {};
5812
+ for (let name of ['hasBOM', 'css', 'file', 'id']) {
5813
+ if (this[name] != null) {
5814
+ json[name] = this[name];
5815
+ }
5912
5816
  }
5913
- return this.walk((child, i) => {
5914
- if (child.type === 'rule' && child.selector === selector) {
5915
- return callback(child, i)
5817
+ if (this.map) {
5818
+ json.map = { ...this.map };
5819
+ if (json.map.consumerCache) {
5820
+ json.map.consumerCache = undefined;
5916
5821
  }
5917
- })
5822
+ }
5823
+ return json
5824
+ }
5825
+
5826
+ get from() {
5827
+ return this.file || this.id
5918
5828
  }
5919
5829
  }
5920
5830
 
5921
- Container$7.registerParse = dependant => {
5922
- parse$4 = dependant;
5923
- };
5831
+ var input = Input$4;
5832
+ Input$4.default = Input$4;
5924
5833
 
5925
- Container$7.registerRule = dependant => {
5926
- Rule$4 = dependant;
5927
- };
5834
+ if (terminalHighlight && terminalHighlight.registerInput) {
5835
+ terminalHighlight.registerInput(Input$4);
5836
+ }
5928
5837
 
5929
- Container$7.registerAtRule = dependant => {
5930
- AtRule$4 = dependant;
5931
- };
5838
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
5839
+ let { dirname, relative, resolve, sep } = require$$2;
5840
+ let { pathToFileURL } = require$$2;
5932
5841
 
5933
- Container$7.registerRoot = dependant => {
5934
- Root$6 = dependant;
5935
- };
5842
+ let Input$3 = input;
5936
5843
 
5937
- var container = Container$7;
5938
- Container$7.default = Container$7;
5844
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
5845
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
5939
5846
 
5940
- /* c8 ignore start */
5941
- Container$7.rebuild = node => {
5942
- if (node.type === 'atrule') {
5943
- Object.setPrototypeOf(node, AtRule$4.prototype);
5944
- } else if (node.type === 'rule') {
5945
- Object.setPrototypeOf(node, Rule$4.prototype);
5946
- } else if (node.type === 'decl') {
5947
- Object.setPrototypeOf(node, Declaration$3.prototype);
5948
- } else if (node.type === 'comment') {
5949
- Object.setPrototypeOf(node, Comment$3.prototype);
5950
- } else if (node.type === 'root') {
5951
- Object.setPrototypeOf(node, Root$6.prototype);
5952
- }
5953
-
5954
- node[my$1] = true;
5847
+ class MapGenerator$2 {
5848
+ constructor(stringify, root, opts, cssString) {
5849
+ this.stringify = stringify;
5850
+ this.mapOpts = opts.map || {};
5851
+ this.root = root;
5852
+ this.opts = opts;
5853
+ this.css = cssString;
5854
+ this.originalCSS = cssString;
5855
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
5955
5856
 
5956
- if (node.nodes) {
5957
- node.nodes.forEach(child => {
5958
- Container$7.rebuild(child);
5959
- });
5857
+ this.memoizedFileURLs = new Map();
5858
+ this.memoizedPaths = new Map();
5859
+ this.memoizedURLs = new Map();
5960
5860
  }
5961
- };
5962
-
5963
- let Container$6 = container;
5964
5861
 
5965
- class AtRule$3 extends Container$6 {
5966
- constructor(defaults) {
5967
- super(defaults);
5968
- this.type = 'atrule';
5969
- }
5862
+ addAnnotation() {
5863
+ let content;
5970
5864
 
5971
- append(...children) {
5972
- if (!this.proxyOf.nodes) this.nodes = [];
5973
- return super.append(...children)
5974
- }
5865
+ if (this.isInline()) {
5866
+ content =
5867
+ 'data:application/json;base64,' + this.toBase64(this.map.toString());
5868
+ } else if (typeof this.mapOpts.annotation === 'string') {
5869
+ content = this.mapOpts.annotation;
5870
+ } else if (typeof this.mapOpts.annotation === 'function') {
5871
+ content = this.mapOpts.annotation(this.opts.to, this.root);
5872
+ } else {
5873
+ content = this.outputFile() + '.map';
5874
+ }
5875
+ let eol = '\n';
5876
+ if (this.css.includes('\r\n')) eol = '\r\n';
5975
5877
 
5976
- prepend(...children) {
5977
- if (!this.proxyOf.nodes) this.nodes = [];
5978
- return super.prepend(...children)
5878
+ this.css += eol + '/*# sourceMappingURL=' + content + ' */';
5979
5879
  }
5980
- }
5981
-
5982
- var atRule = AtRule$3;
5983
- AtRule$3.default = AtRule$3;
5984
-
5985
- Container$6.registerAtRule(AtRule$3);
5986
-
5987
- let Container$5 = container;
5988
5880
 
5989
- let LazyResult$4, Processor$3;
5881
+ applyPrevMaps() {
5882
+ for (let prev of this.previous()) {
5883
+ let from = this.toUrl(this.path(prev.file));
5884
+ let root = prev.root || dirname(prev.file);
5885
+ let map;
5990
5886
 
5991
- class Document$3 extends Container$5 {
5992
- constructor(defaults) {
5993
- // type needs to be passed to super, otherwise child roots won't be normalized correctly
5994
- super({ type: 'document', ...defaults });
5887
+ if (this.mapOpts.sourcesContent === false) {
5888
+ map = new SourceMapConsumer(prev.text);
5889
+ if (map.sourcesContent) {
5890
+ map.sourcesContent = null;
5891
+ }
5892
+ } else {
5893
+ map = prev.consumer();
5894
+ }
5995
5895
 
5996
- if (!this.nodes) {
5997
- this.nodes = [];
5896
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
5998
5897
  }
5999
5898
  }
6000
5899
 
6001
- toResult(opts = {}) {
6002
- let lazy = new LazyResult$4(new Processor$3(), this, opts);
5900
+ clearAnnotation() {
5901
+ if (this.mapOpts.annotation === false) return
6003
5902
 
6004
- return lazy.stringify()
5903
+ if (this.root) {
5904
+ let node;
5905
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
5906
+ node = this.root.nodes[i];
5907
+ if (node.type !== 'comment') continue
5908
+ if (node.text.indexOf('# sourceMappingURL=') === 0) {
5909
+ this.root.removeChild(i);
5910
+ }
5911
+ }
5912
+ } else if (this.css) {
5913
+ this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '');
5914
+ }
6005
5915
  }
6006
- }
6007
-
6008
- Document$3.registerLazyResult = dependant => {
6009
- LazyResult$4 = dependant;
6010
- };
6011
5916
 
6012
- Document$3.registerProcessor = dependant => {
6013
- Processor$3 = dependant;
6014
- };
5917
+ generate() {
5918
+ this.clearAnnotation();
5919
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
5920
+ return this.generateMap()
5921
+ } else {
5922
+ let result = '';
5923
+ this.stringify(this.root, i => {
5924
+ result += i;
5925
+ });
5926
+ return [result]
5927
+ }
5928
+ }
6015
5929
 
6016
- var document = Document$3;
6017
- Document$3.default = Document$3;
5930
+ generateMap() {
5931
+ if (this.root) {
5932
+ this.generateString();
5933
+ } else if (this.previous().length === 1) {
5934
+ let prev = this.previous()[0].consumer();
5935
+ prev.file = this.outputFile();
5936
+ this.map = SourceMapGenerator.fromSourceMap(prev);
5937
+ } else {
5938
+ this.map = new SourceMapGenerator({ file: this.outputFile() });
5939
+ this.map.addMapping({
5940
+ generated: { column: 0, line: 1 },
5941
+ original: { column: 0, line: 1 },
5942
+ source: this.opts.from
5943
+ ? this.toUrl(this.path(this.opts.from))
5944
+ : '<no source>'
5945
+ });
5946
+ }
6018
5947
 
6019
- // This alphabet uses `A-Za-z0-9_-` symbols.
6020
- // The order of characters is optimized for better gzip and brotli compression.
6021
- // References to the same file (works both for gzip and brotli):
6022
- // `'use`, `andom`, and `rict'`
6023
- // References to the brotli default dictionary:
6024
- // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
6025
- let urlAlphabet =
6026
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
5948
+ if (this.isSourcesContent()) this.setSourcesContent();
5949
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
5950
+ if (this.isAnnotation()) this.addAnnotation();
6027
5951
 
6028
- let customAlphabet = (alphabet, defaultSize = 21) => {
6029
- return (size = defaultSize) => {
6030
- let id = '';
6031
- // A compact alternative for `for (var i = 0; i < step; i++)`.
6032
- let i = size | 0;
6033
- while (i--) {
6034
- // `| 0` is more compact and faster than `Math.floor()`.
6035
- id += alphabet[(Math.random() * alphabet.length) | 0];
5952
+ if (this.isInline()) {
5953
+ return [this.css]
5954
+ } else {
5955
+ return [this.css, this.map]
6036
5956
  }
6037
- return id
6038
5957
  }
6039
- };
6040
5958
 
6041
- let nanoid$1 = (size = 21) => {
6042
- let id = '';
6043
- // A compact alternative for `for (var i = 0; i < step; i++)`.
6044
- let i = size | 0;
6045
- while (i--) {
6046
- // `| 0` is more compact and faster than `Math.floor()`.
6047
- id += urlAlphabet[(Math.random() * 64) | 0];
6048
- }
6049
- return id
6050
- };
5959
+ generateString() {
5960
+ this.css = '';
5961
+ this.map = new SourceMapGenerator({ file: this.outputFile() });
6051
5962
 
6052
- const nonSecure = /*#__PURE__*/Object.freeze({
6053
- __proto__: null,
6054
- nanoid: nanoid$1,
6055
- customAlphabet: customAlphabet
6056
- });
5963
+ let line = 1;
5964
+ let column = 1;
6057
5965
 
6058
- const require$$0 = /*@__PURE__*/getAugmentedNamespace(nonSecure);
5966
+ let noSource = '<no source>';
5967
+ let mapping = {
5968
+ generated: { column: 0, line: 0 },
5969
+ original: { column: 0, line: 0 },
5970
+ source: ''
5971
+ };
6059
5972
 
6060
- let { existsSync, readFileSync } = require$$2;
6061
- let { dirname: dirname$1, join } = require$$2;
6062
- let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
5973
+ let lines, last;
5974
+ this.stringify(this.root, (str, node, type) => {
5975
+ this.css += str;
6063
5976
 
6064
- function fromBase64(str) {
6065
- if (Buffer) {
6066
- return Buffer.from(str, 'base64').toString()
6067
- } else {
6068
- /* c8 ignore next 2 */
6069
- return window.atob(str)
6070
- }
6071
- }
5977
+ if (node && type !== 'end') {
5978
+ mapping.generated.line = line;
5979
+ mapping.generated.column = column - 1;
5980
+ if (node.source && node.source.start) {
5981
+ mapping.source = this.sourcePath(node);
5982
+ mapping.original.line = node.source.start.line;
5983
+ mapping.original.column = node.source.start.column - 1;
5984
+ this.map.addMapping(mapping);
5985
+ } else {
5986
+ mapping.source = noSource;
5987
+ mapping.original.line = 1;
5988
+ mapping.original.column = 0;
5989
+ this.map.addMapping(mapping);
5990
+ }
5991
+ }
6072
5992
 
6073
- class PreviousMap$2 {
6074
- constructor(css, opts) {
6075
- if (opts.map === false) return
6076
- this.loadAnnotation(css);
6077
- this.inline = this.startWith(this.annotation, 'data:');
5993
+ lines = str.match(/\n/g);
5994
+ if (lines) {
5995
+ line += lines.length;
5996
+ last = str.lastIndexOf('\n');
5997
+ column = str.length - last;
5998
+ } else {
5999
+ column += str.length;
6000
+ }
6078
6001
 
6079
- let prev = opts.map ? opts.map.prev : undefined;
6080
- let text = this.loadMap(opts.from, prev);
6081
- if (!this.mapFile && opts.from) {
6082
- this.mapFile = opts.from;
6083
- }
6084
- if (this.mapFile) this.root = dirname$1(this.mapFile);
6085
- if (text) this.text = text;
6002
+ if (node && type !== 'start') {
6003
+ let p = node.parent || { raws: {} };
6004
+ let childless =
6005
+ node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
6006
+ if (!childless || node !== p.last || p.raws.semicolon) {
6007
+ if (node.source && node.source.end) {
6008
+ mapping.source = this.sourcePath(node);
6009
+ mapping.original.line = node.source.end.line;
6010
+ mapping.original.column = node.source.end.column - 1;
6011
+ mapping.generated.line = line;
6012
+ mapping.generated.column = column - 2;
6013
+ this.map.addMapping(mapping);
6014
+ } else {
6015
+ mapping.source = noSource;
6016
+ mapping.original.line = 1;
6017
+ mapping.original.column = 0;
6018
+ mapping.generated.line = line;
6019
+ mapping.generated.column = column - 1;
6020
+ this.map.addMapping(mapping);
6021
+ }
6022
+ }
6023
+ }
6024
+ });
6086
6025
  }
6087
6026
 
6088
- consumer() {
6089
- if (!this.consumerCache) {
6090
- this.consumerCache = new SourceMapConsumer$2(this.text);
6027
+ isAnnotation() {
6028
+ if (this.isInline()) {
6029
+ return true
6091
6030
  }
6092
- return this.consumerCache
6031
+ if (typeof this.mapOpts.annotation !== 'undefined') {
6032
+ return this.mapOpts.annotation
6033
+ }
6034
+ if (this.previous().length) {
6035
+ return this.previous().some(i => i.annotation)
6036
+ }
6037
+ return true
6093
6038
  }
6094
6039
 
6095
- decodeInline(text) {
6096
- let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
6097
- let baseUri = /^data:application\/json;base64,/;
6098
- let charsetUri = /^data:application\/json;charset=utf-?8,/;
6099
- let uri = /^data:application\/json,/;
6040
+ isInline() {
6041
+ if (typeof this.mapOpts.inline !== 'undefined') {
6042
+ return this.mapOpts.inline
6043
+ }
6100
6044
 
6101
- let uriMatch = text.match(charsetUri) || text.match(uri);
6102
- if (uriMatch) {
6103
- return decodeURIComponent(text.substr(uriMatch[0].length))
6045
+ let annotation = this.mapOpts.annotation;
6046
+ if (typeof annotation !== 'undefined' && annotation !== true) {
6047
+ return false
6104
6048
  }
6105
6049
 
6106
- let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
6107
- if (baseUriMatch) {
6108
- return fromBase64(text.substr(baseUriMatch[0].length))
6050
+ if (this.previous().length) {
6051
+ return this.previous().some(i => i.inline)
6109
6052
  }
6053
+ return true
6054
+ }
6110
6055
 
6111
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
6112
- throw new Error('Unsupported source map encoding ' + encoding)
6056
+ isMap() {
6057
+ if (typeof this.opts.map !== 'undefined') {
6058
+ return !!this.opts.map
6059
+ }
6060
+ return this.previous().length > 0
6113
6061
  }
6114
6062
 
6115
- getAnnotationURL(sourceMapString) {
6116
- return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
6063
+ isSourcesContent() {
6064
+ if (typeof this.mapOpts.sourcesContent !== 'undefined') {
6065
+ return this.mapOpts.sourcesContent
6066
+ }
6067
+ if (this.previous().length) {
6068
+ return this.previous().some(i => i.withContent())
6069
+ }
6070
+ return true
6117
6071
  }
6118
6072
 
6119
- isMap(map) {
6120
- if (typeof map !== 'object') return false
6121
- return (
6122
- typeof map.mappings === 'string' ||
6123
- typeof map._mappings === 'string' ||
6124
- Array.isArray(map.sections)
6125
- )
6073
+ outputFile() {
6074
+ if (this.opts.to) {
6075
+ return this.path(this.opts.to)
6076
+ } else if (this.opts.from) {
6077
+ return this.path(this.opts.from)
6078
+ } else {
6079
+ return 'to.css'
6080
+ }
6126
6081
  }
6127
6082
 
6128
- loadAnnotation(css) {
6129
- let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
6130
- if (!comments) return
6083
+ path(file) {
6084
+ if (this.mapOpts.absolute) return file
6085
+ if (file.charCodeAt(0) === 60 /* `<` */) return file
6086
+ if (/^\w+:\/\//.test(file)) return file
6087
+ let cached = this.memoizedPaths.get(file);
6088
+ if (cached) return cached
6131
6089
 
6132
- // sourceMappingURLs from comments, strings, etc.
6133
- let start = css.lastIndexOf(comments.pop());
6134
- let end = css.indexOf('*/', start);
6090
+ let from = this.opts.to ? dirname(this.opts.to) : '.';
6135
6091
 
6136
- if (start > -1 && end > -1) {
6137
- // Locate the last sourceMappingURL to avoid pickin
6138
- this.annotation = this.getAnnotationURL(css.substring(start, end));
6092
+ if (typeof this.mapOpts.annotation === 'string') {
6093
+ from = dirname(resolve(from, this.mapOpts.annotation));
6139
6094
  }
6140
- }
6141
6095
 
6142
- loadFile(path) {
6143
- this.root = dirname$1(path);
6144
- if (existsSync(path)) {
6145
- this.mapFile = path;
6146
- return readFileSync(path, 'utf-8').toString().trim()
6147
- }
6148
- }
6096
+ let path = relative(from, file);
6097
+ this.memoizedPaths.set(file, path);
6149
6098
 
6150
- loadMap(file, prev) {
6151
- if (prev === false) return false
6099
+ return path
6100
+ }
6152
6101
 
6153
- if (prev) {
6154
- if (typeof prev === 'string') {
6155
- return prev
6156
- } else if (typeof prev === 'function') {
6157
- let prevPath = prev(file);
6158
- if (prevPath) {
6159
- let map = this.loadFile(prevPath);
6160
- if (!map) {
6161
- throw new Error(
6162
- 'Unable to load previous source map: ' + prevPath.toString()
6163
- )
6102
+ previous() {
6103
+ if (!this.previousMaps) {
6104
+ this.previousMaps = [];
6105
+ if (this.root) {
6106
+ this.root.walk(node => {
6107
+ if (node.source && node.source.input.map) {
6108
+ let map = node.source.input.map;
6109
+ if (!this.previousMaps.includes(map)) {
6110
+ this.previousMaps.push(map);
6111
+ }
6164
6112
  }
6165
- return map
6166
- }
6167
- } else if (prev instanceof SourceMapConsumer$2) {
6168
- return SourceMapGenerator$2.fromSourceMap(prev).toString()
6169
- } else if (prev instanceof SourceMapGenerator$2) {
6170
- return prev.toString()
6171
- } else if (this.isMap(prev)) {
6172
- return JSON.stringify(prev)
6113
+ });
6173
6114
  } else {
6174
- throw new Error(
6175
- 'Unsupported previous source map format: ' + prev.toString()
6176
- )
6115
+ let input = new Input$3(this.originalCSS, this.opts);
6116
+ if (input.map) this.previousMaps.push(input.map);
6177
6117
  }
6178
- } else if (this.inline) {
6179
- return this.decodeInline(this.annotation)
6180
- } else if (this.annotation) {
6181
- let map = this.annotation;
6182
- if (file) map = join(dirname$1(file), map);
6183
- return this.loadFile(map)
6184
6118
  }
6185
- }
6186
6119
 
6187
- startWith(string, start) {
6188
- if (!string) return false
6189
- return string.substr(0, start.length) === start
6120
+ return this.previousMaps
6190
6121
  }
6191
6122
 
6192
- withContent() {
6193
- return !!(
6194
- this.consumer().sourcesContent &&
6195
- this.consumer().sourcesContent.length > 0
6196
- )
6123
+ setSourcesContent() {
6124
+ let already = {};
6125
+ if (this.root) {
6126
+ this.root.walk(node => {
6127
+ if (node.source) {
6128
+ let from = node.source.input.from;
6129
+ if (from && !already[from]) {
6130
+ already[from] = true;
6131
+ let fromUrl = this.usesFileUrls
6132
+ ? this.toFileUrl(from)
6133
+ : this.toUrl(this.path(from));
6134
+ this.map.setSourceContent(fromUrl, node.source.input.css);
6135
+ }
6136
+ }
6137
+ });
6138
+ } else if (this.css) {
6139
+ let from = this.opts.from
6140
+ ? this.toUrl(this.path(this.opts.from))
6141
+ : '<no source>';
6142
+ this.map.setSourceContent(from, this.css);
6143
+ }
6197
6144
  }
6198
- }
6199
-
6200
- var previousMap = PreviousMap$2;
6201
- PreviousMap$2.default = PreviousMap$2;
6202
-
6203
- let { nanoid } = require$$0;
6204
- let { isAbsolute, resolve: resolve$1 } = require$$2;
6205
- let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
6206
- let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
6207
-
6208
- let CssSyntaxError$1 = cssSyntaxError;
6209
- let PreviousMap$1 = previousMap;
6210
- let terminalHighlight = require$$2;
6211
-
6212
- let fromOffsetCache = Symbol('fromOffsetCache');
6213
-
6214
- let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
6215
- let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
6216
6145
 
6217
- class Input$4 {
6218
- get from() {
6219
- return this.file || this.id
6146
+ sourcePath(node) {
6147
+ if (this.mapOpts.from) {
6148
+ return this.toUrl(this.mapOpts.from)
6149
+ } else if (this.usesFileUrls) {
6150
+ return this.toFileUrl(node.source.input.from)
6151
+ } else {
6152
+ return this.toUrl(this.path(node.source.input.from))
6153
+ }
6220
6154
  }
6221
6155
 
6222
- constructor(css, opts = {}) {
6223
- if (
6224
- css === null ||
6225
- typeof css === 'undefined' ||
6226
- (typeof css === 'object' && !css.toString)
6227
- ) {
6228
- throw new Error(`PostCSS received ${css} instead of CSS string`)
6156
+ toBase64(str) {
6157
+ if (Buffer) {
6158
+ return Buffer.from(str).toString('base64')
6159
+ } else {
6160
+ return window.btoa(unescape(encodeURIComponent(str)))
6229
6161
  }
6162
+ }
6230
6163
 
6231
- this.css = css.toString();
6164
+ toFileUrl(path) {
6165
+ let cached = this.memoizedFileURLs.get(path);
6166
+ if (cached) return cached
6232
6167
 
6233
- if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
6234
- this.hasBOM = true;
6235
- this.css = this.css.slice(1);
6168
+ if (pathToFileURL) {
6169
+ let fileURL = pathToFileURL(path).toString();
6170
+ this.memoizedFileURLs.set(path, fileURL);
6171
+
6172
+ return fileURL
6236
6173
  } else {
6237
- this.hasBOM = false;
6174
+ throw new Error(
6175
+ '`map.absolute` option is not available in this PostCSS build'
6176
+ )
6238
6177
  }
6178
+ }
6239
6179
 
6240
- this.document = this.css;
6241
- if (opts.document) this.document = opts.document.toString();
6180
+ toUrl(path) {
6181
+ let cached = this.memoizedURLs.get(path);
6182
+ if (cached) return cached
6242
6183
 
6243
- if (opts.from) {
6244
- if (
6245
- !pathAvailable$1 ||
6246
- /^\w+:\/\//.test(opts.from) ||
6247
- isAbsolute(opts.from)
6248
- ) {
6249
- this.file = opts.from;
6250
- } else {
6251
- this.file = resolve$1(opts.from);
6252
- }
6184
+ if (sep === '\\') {
6185
+ path = path.replace(/\\/g, '/');
6253
6186
  }
6254
6187
 
6255
- if (pathAvailable$1 && sourceMapAvailable$1) {
6256
- let map = new PreviousMap$1(this.css, opts);
6257
- if (map.text) {
6258
- this.map = map;
6259
- let file = map.consumer().file;
6260
- if (!this.file && file) this.file = this.mapResolve(file);
6261
- }
6262
- }
6188
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
6189
+ this.memoizedURLs.set(path, url);
6263
6190
 
6264
- if (!this.file) {
6265
- this.id = '<input css ' + nanoid(6) + '>';
6266
- }
6267
- if (this.map) this.map.file = this.from;
6191
+ return url
6268
6192
  }
6193
+ }
6269
6194
 
6270
- error(message, line, column, opts = {}) {
6271
- let endColumn, endLine, result;
6195
+ var mapGenerator = MapGenerator$2;
6272
6196
 
6273
- if (line && typeof line === 'object') {
6274
- let start = line;
6275
- let end = column;
6276
- if (typeof start.offset === 'number') {
6277
- let pos = this.fromOffset(start.offset);
6278
- line = pos.line;
6279
- column = pos.col;
6280
- } else {
6281
- line = start.line;
6282
- column = start.column;
6283
- }
6284
- if (typeof end.offset === 'number') {
6285
- let pos = this.fromOffset(end.offset);
6286
- endLine = pos.line;
6287
- endColumn = pos.col;
6288
- } else {
6289
- endLine = end.line;
6290
- endColumn = end.column;
6291
- }
6292
- } else if (!column) {
6293
- let pos = this.fromOffset(line);
6294
- line = pos.line;
6295
- column = pos.col;
6296
- }
6297
-
6298
- let origin = this.origin(line, column, endLine, endColumn);
6299
- if (origin) {
6300
- result = new CssSyntaxError$1(
6301
- message,
6302
- origin.endLine === undefined
6303
- ? origin.line
6304
- : { column: origin.column, line: origin.line },
6305
- origin.endLine === undefined
6306
- ? origin.column
6307
- : { column: origin.endColumn, line: origin.endLine },
6308
- origin.source,
6309
- origin.file,
6310
- opts.plugin
6311
- );
6312
- } else {
6313
- result = new CssSyntaxError$1(
6314
- message,
6315
- endLine === undefined ? line : { column, line },
6316
- endLine === undefined ? column : { column: endColumn, line: endLine },
6317
- this.css,
6318
- this.file,
6319
- opts.plugin
6320
- );
6321
- }
6322
-
6323
- result.input = { column, endColumn, endLine, line, source: this.css };
6324
- if (this.file) {
6325
- if (pathToFileURL$1) {
6326
- result.input.url = pathToFileURL$1(this.file).toString();
6327
- }
6328
- result.input.file = this.file;
6329
- }
6197
+ let Node$2 = node_1;
6330
6198
 
6331
- return result
6199
+ class Comment$4 extends Node$2 {
6200
+ constructor(defaults) {
6201
+ super(defaults);
6202
+ this.type = 'comment';
6332
6203
  }
6204
+ }
6333
6205
 
6334
- fromOffset(offset) {
6335
- let lastLine, lineToIndex;
6336
- if (!this[fromOffsetCache]) {
6337
- let lines = this.css.split('\n');
6338
- lineToIndex = new Array(lines.length);
6339
- let prevIndex = 0;
6206
+ var comment = Comment$4;
6207
+ Comment$4.default = Comment$4;
6340
6208
 
6341
- for (let i = 0, l = lines.length; i < l; i++) {
6342
- lineToIndex[i] = prevIndex;
6343
- prevIndex += lines[i].length + 1;
6344
- }
6209
+ let { isClean: isClean$1, my: my$1 } = symbols;
6210
+ let Declaration$3 = declaration;
6211
+ let Comment$3 = comment;
6212
+ let Node$1 = node_1;
6345
6213
 
6346
- this[fromOffsetCache] = lineToIndex;
6347
- } else {
6348
- lineToIndex = this[fromOffsetCache];
6349
- }
6350
- lastLine = lineToIndex[lineToIndex.length - 1];
6214
+ let parse$4, Rule$4, AtRule$4, Root$6;
6351
6215
 
6352
- let min = 0;
6353
- if (offset >= lastLine) {
6354
- min = lineToIndex.length - 1;
6355
- } else {
6356
- let max = lineToIndex.length - 2;
6357
- let mid;
6358
- while (min < max) {
6359
- mid = min + ((max - min) >> 1);
6360
- if (offset < lineToIndex[mid]) {
6361
- max = mid - 1;
6362
- } else if (offset >= lineToIndex[mid + 1]) {
6363
- min = mid + 1;
6364
- } else {
6365
- min = mid;
6366
- break
6367
- }
6368
- }
6369
- }
6370
- return {
6371
- col: offset - lineToIndex[min] + 1,
6372
- line: min + 1
6216
+ function cleanSource(nodes) {
6217
+ return nodes.map(i => {
6218
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
6219
+ delete i.source;
6220
+ return i
6221
+ })
6222
+ }
6223
+
6224
+ function markDirtyUp(node) {
6225
+ node[isClean$1] = false;
6226
+ if (node.proxyOf.nodes) {
6227
+ for (let i of node.proxyOf.nodes) {
6228
+ markDirtyUp(i);
6373
6229
  }
6374
6230
  }
6231
+ }
6375
6232
 
6376
- mapResolve(file) {
6377
- if (/^\w+:\/\//.test(file)) {
6378
- return file
6233
+ class Container$7 extends Node$1 {
6234
+ append(...children) {
6235
+ for (let child of children) {
6236
+ let nodes = this.normalize(child, this.last);
6237
+ for (let node of nodes) this.proxyOf.nodes.push(node);
6379
6238
  }
6380
- return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
6381
- }
6382
6239
 
6383
- origin(line, column, endLine, endColumn) {
6384
- if (!this.map) return false
6385
- let consumer = this.map.consumer();
6240
+ this.markDirty();
6386
6241
 
6387
- let from = consumer.originalPositionFor({ column, line });
6388
- if (!from.source) return false
6242
+ return this
6243
+ }
6389
6244
 
6390
- let to;
6391
- if (typeof endLine === 'number') {
6392
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
6245
+ cleanRaws(keepBetween) {
6246
+ super.cleanRaws(keepBetween);
6247
+ if (this.nodes) {
6248
+ for (let node of this.nodes) node.cleanRaws(keepBetween);
6393
6249
  }
6250
+ }
6394
6251
 
6395
- let fromUrl;
6396
-
6397
- if (isAbsolute(from.source)) {
6398
- fromUrl = pathToFileURL$1(from.source);
6399
- } else {
6400
- fromUrl = new URL(
6401
- from.source,
6402
- this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
6403
- );
6404
- }
6252
+ each(callback) {
6253
+ if (!this.proxyOf.nodes) return undefined
6254
+ let iterator = this.getIterator();
6405
6255
 
6406
- let result = {
6407
- column: from.column,
6408
- endColumn: to && to.column,
6409
- endLine: to && to.line,
6410
- line: from.line,
6411
- url: fromUrl.toString()
6412
- };
6256
+ let index, result;
6257
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
6258
+ index = this.indexes[iterator];
6259
+ result = callback(this.proxyOf.nodes[index], index);
6260
+ if (result === false) break
6413
6261
 
6414
- if (fromUrl.protocol === 'file:') {
6415
- if (fileURLToPath) {
6416
- result.file = fileURLToPath(fromUrl);
6417
- } else {
6418
- /* c8 ignore next 2 */
6419
- throw new Error(`file: protocol is not available in this PostCSS build`)
6420
- }
6262
+ this.indexes[iterator] += 1;
6421
6263
  }
6422
6264
 
6423
- let source = consumer.sourceContentFor(from.source);
6424
- if (source) result.source = source;
6425
-
6265
+ delete this.indexes[iterator];
6426
6266
  return result
6427
6267
  }
6428
6268
 
6429
- toJSON() {
6430
- let json = {};
6431
- for (let name of ['hasBOM', 'css', 'file', 'id']) {
6432
- if (this[name] != null) {
6433
- json[name] = this[name];
6434
- }
6435
- }
6436
- if (this.map) {
6437
- json.map = { ...this.map };
6438
- if (json.map.consumerCache) {
6439
- json.map.consumerCache = undefined;
6440
- }
6441
- }
6442
- return json
6269
+ every(condition) {
6270
+ return this.nodes.every(condition)
6443
6271
  }
6444
- }
6445
-
6446
- var input = Input$4;
6447
- Input$4.default = Input$4;
6448
6272
 
6449
- if (terminalHighlight && terminalHighlight.registerInput) {
6450
- terminalHighlight.registerInput(Input$4);
6451
- }
6452
-
6453
- let Container$4 = container;
6273
+ getIterator() {
6274
+ if (!this.lastEach) this.lastEach = 0;
6275
+ if (!this.indexes) this.indexes = {};
6454
6276
 
6455
- let LazyResult$3, Processor$2;
6277
+ this.lastEach += 1;
6278
+ let iterator = this.lastEach;
6279
+ this.indexes[iterator] = 0;
6456
6280
 
6457
- class Root$5 extends Container$4 {
6458
- constructor(defaults) {
6459
- super(defaults);
6460
- this.type = 'root';
6461
- if (!this.nodes) this.nodes = [];
6281
+ return iterator
6462
6282
  }
6463
6283
 
6464
- normalize(child, sample, type) {
6465
- let nodes = super.normalize(child);
6466
-
6467
- if (sample) {
6468
- if (type === 'prepend') {
6469
- if (this.nodes.length > 1) {
6470
- sample.raws.before = this.nodes[1].raws.before;
6284
+ getProxyProcessor() {
6285
+ return {
6286
+ get(node, prop) {
6287
+ if (prop === 'proxyOf') {
6288
+ return node
6289
+ } else if (!node[prop]) {
6290
+ return node[prop]
6291
+ } else if (
6292
+ prop === 'each' ||
6293
+ (typeof prop === 'string' && prop.startsWith('walk'))
6294
+ ) {
6295
+ return (...args) => {
6296
+ return node[prop](
6297
+ ...args.map(i => {
6298
+ if (typeof i === 'function') {
6299
+ return (child, index) => i(child.toProxy(), index)
6300
+ } else {
6301
+ return i
6302
+ }
6303
+ })
6304
+ )
6305
+ }
6306
+ } else if (prop === 'every' || prop === 'some') {
6307
+ return cb => {
6308
+ return node[prop]((child, ...other) =>
6309
+ cb(child.toProxy(), ...other)
6310
+ )
6311
+ }
6312
+ } else if (prop === 'root') {
6313
+ return () => node.root().toProxy()
6314
+ } else if (prop === 'nodes') {
6315
+ return node.nodes.map(i => i.toProxy())
6316
+ } else if (prop === 'first' || prop === 'last') {
6317
+ return node[prop].toProxy()
6471
6318
  } else {
6472
- delete sample.raws.before;
6319
+ return node[prop]
6473
6320
  }
6474
- } else if (this.first !== sample) {
6475
- for (let node of nodes) {
6476
- node.raws.before = sample.raws.before;
6321
+ },
6322
+
6323
+ set(node, prop, value) {
6324
+ if (node[prop] === value) return true
6325
+ node[prop] = value;
6326
+ if (prop === 'name' || prop === 'params' || prop === 'selector') {
6327
+ node.markDirty();
6477
6328
  }
6329
+ return true
6478
6330
  }
6479
6331
  }
6332
+ }
6480
6333
 
6481
- return nodes
6334
+ index(child) {
6335
+ if (typeof child === 'number') return child
6336
+ if (child.proxyOf) child = child.proxyOf;
6337
+ return this.proxyOf.nodes.indexOf(child)
6482
6338
  }
6483
6339
 
6484
- removeChild(child, ignore) {
6485
- let index = this.index(child);
6340
+ insertAfter(exist, add) {
6341
+ let existIndex = this.index(exist);
6342
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
6343
+ existIndex = this.index(exist);
6344
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
6486
6345
 
6487
- if (!ignore && index === 0 && this.nodes.length > 1) {
6488
- this.nodes[1].raws.before = this.nodes[index].raws.before;
6346
+ let index;
6347
+ for (let id in this.indexes) {
6348
+ index = this.indexes[id];
6349
+ if (existIndex < index) {
6350
+ this.indexes[id] = index + nodes.length;
6351
+ }
6489
6352
  }
6490
6353
 
6491
- return super.removeChild(child)
6492
- }
6354
+ this.markDirty();
6493
6355
 
6494
- toResult(opts = {}) {
6495
- let lazy = new LazyResult$3(new Processor$2(), this, opts);
6496
- return lazy.stringify()
6356
+ return this
6497
6357
  }
6498
- }
6499
-
6500
- Root$5.registerLazyResult = dependant => {
6501
- LazyResult$3 = dependant;
6502
- };
6503
-
6504
- Root$5.registerProcessor = dependant => {
6505
- Processor$2 = dependant;
6506
- };
6507
-
6508
- var root = Root$5;
6509
- Root$5.default = Root$5;
6510
-
6511
- Container$4.registerRoot(Root$5);
6512
6358
 
6513
- let list$2 = {
6514
- comma(string) {
6515
- return list$2.split(string, [','], true)
6516
- },
6359
+ insertBefore(exist, add) {
6360
+ let existIndex = this.index(exist);
6361
+ let type = existIndex === 0 ? 'prepend' : false;
6362
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
6363
+ existIndex = this.index(exist);
6364
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
6517
6365
 
6518
- space(string) {
6519
- let spaces = [' ', '\n', '\t'];
6520
- return list$2.split(string, spaces)
6521
- },
6366
+ let index;
6367
+ for (let id in this.indexes) {
6368
+ index = this.indexes[id];
6369
+ if (existIndex <= index) {
6370
+ this.indexes[id] = index + nodes.length;
6371
+ }
6372
+ }
6522
6373
 
6523
- split(string, separators, last) {
6524
- let array = [];
6525
- let current = '';
6526
- let split = false;
6374
+ this.markDirty();
6527
6375
 
6528
- let func = 0;
6529
- let inQuote = false;
6530
- let prevQuote = '';
6531
- let escape = false;
6376
+ return this
6377
+ }
6532
6378
 
6533
- for (let letter of string) {
6534
- if (escape) {
6535
- escape = false;
6536
- } else if (letter === '\\') {
6537
- escape = true;
6538
- } else if (inQuote) {
6539
- if (letter === prevQuote) {
6540
- inQuote = false;
6541
- }
6542
- } else if (letter === '"' || letter === "'") {
6543
- inQuote = true;
6544
- prevQuote = letter;
6545
- } else if (letter === '(') {
6546
- func += 1;
6547
- } else if (letter === ')') {
6548
- if (func > 0) func -= 1;
6549
- } else if (func === 0) {
6550
- if (separators.includes(letter)) split = true;
6379
+ normalize(nodes, sample) {
6380
+ if (typeof nodes === 'string') {
6381
+ nodes = cleanSource(parse$4(nodes).nodes);
6382
+ } else if (typeof nodes === 'undefined') {
6383
+ nodes = [];
6384
+ } else if (Array.isArray(nodes)) {
6385
+ nodes = nodes.slice(0);
6386
+ for (let i of nodes) {
6387
+ if (i.parent) i.parent.removeChild(i, 'ignore');
6551
6388
  }
6552
-
6553
- if (split) {
6554
- if (current !== '') array.push(current.trim());
6555
- current = '';
6556
- split = false;
6557
- } else {
6558
- current += letter;
6389
+ } else if (nodes.type === 'root' && this.type !== 'document') {
6390
+ nodes = nodes.nodes.slice(0);
6391
+ for (let i of nodes) {
6392
+ if (i.parent) i.parent.removeChild(i, 'ignore');
6393
+ }
6394
+ } else if (nodes.type) {
6395
+ nodes = [nodes];
6396
+ } else if (nodes.prop) {
6397
+ if (typeof nodes.value === 'undefined') {
6398
+ throw new Error('Value field is missed in node creation')
6399
+ } else if (typeof nodes.value !== 'string') {
6400
+ nodes.value = String(nodes.value);
6559
6401
  }
6402
+ nodes = [new Declaration$3(nodes)];
6403
+ } else if (nodes.selector) {
6404
+ nodes = [new Rule$4(nodes)];
6405
+ } else if (nodes.name) {
6406
+ nodes = [new AtRule$4(nodes)];
6407
+ } else if (nodes.text) {
6408
+ nodes = [new Comment$3(nodes)];
6409
+ } else {
6410
+ throw new Error('Unknown node type in node creation')
6560
6411
  }
6561
6412
 
6562
- if (last || current !== '') array.push(current.trim());
6563
- return array
6564
- }
6565
- };
6413
+ let processed = nodes.map(i => {
6414
+ /* c8 ignore next */
6415
+ if (!i[my$1]) Container$7.rebuild(i);
6416
+ i = i.proxyOf;
6417
+ if (i.parent) i.parent.removeChild(i);
6418
+ if (i[isClean$1]) markDirtyUp(i);
6419
+ if (typeof i.raws.before === 'undefined') {
6420
+ if (sample && typeof sample.raws.before !== 'undefined') {
6421
+ i.raws.before = sample.raws.before.replace(/\S/g, '');
6422
+ }
6423
+ }
6424
+ i.parent = this.proxyOf;
6425
+ return i
6426
+ });
6566
6427
 
6567
- var list_1 = list$2;
6568
- list$2.default = list$2;
6428
+ return processed
6429
+ }
6569
6430
 
6570
- let Container$3 = container;
6571
- let list$1 = list_1;
6431
+ prepend(...children) {
6432
+ children = children.reverse();
6433
+ for (let child of children) {
6434
+ let nodes = this.normalize(child, this.first, 'prepend').reverse();
6435
+ for (let node of nodes) this.proxyOf.nodes.unshift(node);
6436
+ for (let id in this.indexes) {
6437
+ this.indexes[id] = this.indexes[id] + nodes.length;
6438
+ }
6439
+ }
6572
6440
 
6573
- class Rule$3 extends Container$3 {
6574
- get selectors() {
6575
- return list$1.comma(this.selector)
6576
- }
6441
+ this.markDirty();
6577
6442
 
6578
- set selectors(values) {
6579
- let match = this.selector ? this.selector.match(/,\s*/) : null;
6580
- let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
6581
- this.selector = values.join(sep);
6443
+ return this
6582
6444
  }
6583
6445
 
6584
- constructor(defaults) {
6585
- super(defaults);
6586
- this.type = 'rule';
6587
- if (!this.nodes) this.nodes = [];
6446
+ push(child) {
6447
+ child.parent = this;
6448
+ this.proxyOf.nodes.push(child);
6449
+ return this
6588
6450
  }
6589
- }
6590
6451
 
6591
- var rule = Rule$3;
6592
- Rule$3.default = Rule$3;
6452
+ removeAll() {
6453
+ for (let node of this.proxyOf.nodes) node.parent = undefined;
6454
+ this.proxyOf.nodes = [];
6593
6455
 
6594
- Container$3.registerRule(Rule$3);
6456
+ this.markDirty();
6595
6457
 
6596
- let AtRule$2 = atRule;
6597
- let Comment$2 = comment;
6598
- let Declaration$2 = declaration;
6599
- let Input$3 = input;
6600
- let PreviousMap = previousMap;
6601
- let Root$4 = root;
6602
- let Rule$2 = rule;
6458
+ return this
6459
+ }
6603
6460
 
6604
- function fromJSON$1(json, inputs) {
6605
- if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
6461
+ removeChild(child) {
6462
+ child = this.index(child);
6463
+ this.proxyOf.nodes[child].parent = undefined;
6464
+ this.proxyOf.nodes.splice(child, 1);
6606
6465
 
6607
- let { inputs: ownInputs, ...defaults } = json;
6608
- if (ownInputs) {
6609
- inputs = [];
6610
- for (let input of ownInputs) {
6611
- let inputHydrated = { ...input, __proto__: Input$3.prototype };
6612
- if (inputHydrated.map) {
6613
- inputHydrated.map = {
6614
- ...inputHydrated.map,
6615
- __proto__: PreviousMap.prototype
6616
- };
6466
+ let index;
6467
+ for (let id in this.indexes) {
6468
+ index = this.indexes[id];
6469
+ if (index >= child) {
6470
+ this.indexes[id] = index - 1;
6617
6471
  }
6618
- inputs.push(inputHydrated);
6619
- }
6620
- }
6621
- if (defaults.nodes) {
6622
- defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
6623
- }
6624
- if (defaults.source) {
6625
- let { inputId, ...source } = defaults.source;
6626
- defaults.source = source;
6627
- if (inputId != null) {
6628
- defaults.source.input = inputs[inputId];
6629
6472
  }
6630
- }
6631
- if (defaults.type === 'root') {
6632
- return new Root$4(defaults)
6633
- } else if (defaults.type === 'decl') {
6634
- return new Declaration$2(defaults)
6635
- } else if (defaults.type === 'rule') {
6636
- return new Rule$2(defaults)
6637
- } else if (defaults.type === 'comment') {
6638
- return new Comment$2(defaults)
6639
- } else if (defaults.type === 'atrule') {
6640
- return new AtRule$2(defaults)
6641
- } else {
6642
- throw new Error('Unknown node type: ' + json.type)
6643
- }
6644
- }
6645
-
6646
- var fromJSON_1 = fromJSON$1;
6647
- fromJSON$1.default = fromJSON$1;
6648
-
6649
- let { dirname, relative, resolve, sep } = require$$2;
6650
- let { SourceMapConsumer, SourceMapGenerator } = require$$2;
6651
- let { pathToFileURL } = require$$2;
6652
6473
 
6653
- let Input$2 = input;
6474
+ this.markDirty();
6654
6475
 
6655
- let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
6656
- let pathAvailable = Boolean(dirname && resolve && relative && sep);
6476
+ return this
6477
+ }
6657
6478
 
6658
- class MapGenerator$2 {
6659
- constructor(stringify, root, opts, cssString) {
6660
- this.stringify = stringify;
6661
- this.mapOpts = opts.map || {};
6662
- this.root = root;
6663
- this.opts = opts;
6664
- this.css = cssString;
6665
- this.originalCSS = cssString;
6666
- this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
6479
+ replaceValues(pattern, opts, callback) {
6480
+ if (!callback) {
6481
+ callback = opts;
6482
+ opts = {};
6483
+ }
6667
6484
 
6668
- this.memoizedFileURLs = new Map();
6669
- this.memoizedPaths = new Map();
6670
- this.memoizedURLs = new Map();
6671
- }
6485
+ this.walkDecls(decl => {
6486
+ if (opts.props && !opts.props.includes(decl.prop)) return
6487
+ if (opts.fast && !decl.value.includes(opts.fast)) return
6672
6488
 
6673
- addAnnotation() {
6674
- let content;
6489
+ decl.value = decl.value.replace(pattern, callback);
6490
+ });
6675
6491
 
6676
- if (this.isInline()) {
6677
- content =
6678
- 'data:application/json;base64,' + this.toBase64(this.map.toString());
6679
- } else if (typeof this.mapOpts.annotation === 'string') {
6680
- content = this.mapOpts.annotation;
6681
- } else if (typeof this.mapOpts.annotation === 'function') {
6682
- content = this.mapOpts.annotation(this.opts.to, this.root);
6683
- } else {
6684
- content = this.outputFile() + '.map';
6685
- }
6686
- let eol = '\n';
6687
- if (this.css.includes('\r\n')) eol = '\r\n';
6492
+ this.markDirty();
6688
6493
 
6689
- this.css += eol + '/*# sourceMappingURL=' + content + ' */';
6494
+ return this
6690
6495
  }
6691
6496
 
6692
- applyPrevMaps() {
6693
- for (let prev of this.previous()) {
6694
- let from = this.toUrl(this.path(prev.file));
6695
- let root = prev.root || dirname(prev.file);
6696
- let map;
6497
+ some(condition) {
6498
+ return this.nodes.some(condition)
6499
+ }
6697
6500
 
6698
- if (this.mapOpts.sourcesContent === false) {
6699
- map = new SourceMapConsumer(prev.text);
6700
- if (map.sourcesContent) {
6701
- map.sourcesContent = null;
6702
- }
6703
- } else {
6704
- map = prev.consumer();
6501
+ walk(callback) {
6502
+ return this.each((child, i) => {
6503
+ let result;
6504
+ try {
6505
+ result = callback(child, i);
6506
+ } catch (e) {
6507
+ throw child.addToError(e)
6508
+ }
6509
+ if (result !== false && child.walk) {
6510
+ result = child.walk(callback);
6705
6511
  }
6706
6512
 
6707
- this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
6708
- }
6513
+ return result
6514
+ })
6709
6515
  }
6710
6516
 
6711
- clearAnnotation() {
6712
- if (this.mapOpts.annotation === false) return
6713
-
6714
- if (this.root) {
6715
- let node;
6716
- for (let i = this.root.nodes.length - 1; i >= 0; i--) {
6717
- node = this.root.nodes[i];
6718
- if (node.type !== 'comment') continue
6719
- if (node.text.startsWith('# sourceMappingURL=')) {
6720
- this.root.removeChild(i);
6517
+ walkAtRules(name, callback) {
6518
+ if (!callback) {
6519
+ callback = name;
6520
+ return this.walk((child, i) => {
6521
+ if (child.type === 'atrule') {
6522
+ return callback(child, i)
6721
6523
  }
6722
- }
6723
- } else if (this.css) {
6724
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
6524
+ })
6725
6525
  }
6526
+ if (name instanceof RegExp) {
6527
+ return this.walk((child, i) => {
6528
+ if (child.type === 'atrule' && name.test(child.name)) {
6529
+ return callback(child, i)
6530
+ }
6531
+ })
6532
+ }
6533
+ return this.walk((child, i) => {
6534
+ if (child.type === 'atrule' && child.name === name) {
6535
+ return callback(child, i)
6536
+ }
6537
+ })
6726
6538
  }
6727
6539
 
6728
- generate() {
6729
- this.clearAnnotation();
6730
- if (pathAvailable && sourceMapAvailable && this.isMap()) {
6731
- return this.generateMap()
6732
- } else {
6733
- let result = '';
6734
- this.stringify(this.root, i => {
6735
- result += i;
6736
- });
6737
- return [result]
6738
- }
6540
+ walkComments(callback) {
6541
+ return this.walk((child, i) => {
6542
+ if (child.type === 'comment') {
6543
+ return callback(child, i)
6544
+ }
6545
+ })
6739
6546
  }
6740
6547
 
6741
- generateMap() {
6742
- if (this.root) {
6743
- this.generateString();
6744
- } else if (this.previous().length === 1) {
6745
- let prev = this.previous()[0].consumer();
6746
- prev.file = this.outputFile();
6747
- this.map = SourceMapGenerator.fromSourceMap(prev, {
6748
- ignoreInvalidMapping: true
6749
- });
6750
- } else {
6751
- this.map = new SourceMapGenerator({
6752
- file: this.outputFile(),
6753
- ignoreInvalidMapping: true
6754
- });
6755
- this.map.addMapping({
6756
- generated: { column: 0, line: 1 },
6757
- original: { column: 0, line: 1 },
6758
- source: this.opts.from
6759
- ? this.toUrl(this.path(this.opts.from))
6760
- : '<no source>'
6761
- });
6548
+ walkDecls(prop, callback) {
6549
+ if (!callback) {
6550
+ callback = prop;
6551
+ return this.walk((child, i) => {
6552
+ if (child.type === 'decl') {
6553
+ return callback(child, i)
6554
+ }
6555
+ })
6762
6556
  }
6763
-
6764
- if (this.isSourcesContent()) this.setSourcesContent();
6765
- if (this.root && this.previous().length > 0) this.applyPrevMaps();
6766
- if (this.isAnnotation()) this.addAnnotation();
6767
-
6768
- if (this.isInline()) {
6769
- return [this.css]
6770
- } else {
6771
- return [this.css, this.map]
6557
+ if (prop instanceof RegExp) {
6558
+ return this.walk((child, i) => {
6559
+ if (child.type === 'decl' && prop.test(child.prop)) {
6560
+ return callback(child, i)
6561
+ }
6562
+ })
6772
6563
  }
6564
+ return this.walk((child, i) => {
6565
+ if (child.type === 'decl' && child.prop === prop) {
6566
+ return callback(child, i)
6567
+ }
6568
+ })
6773
6569
  }
6774
6570
 
6775
- generateString() {
6776
- this.css = '';
6777
- this.map = new SourceMapGenerator({
6778
- file: this.outputFile(),
6779
- ignoreInvalidMapping: true
6780
- });
6781
-
6782
- let line = 1;
6783
- let column = 1;
6784
-
6785
- let noSource = '<no source>';
6786
- let mapping = {
6787
- generated: { column: 0, line: 0 },
6788
- original: { column: 0, line: 0 },
6789
- source: ''
6790
- };
6791
-
6792
- let last, lines;
6793
- this.stringify(this.root, (str, node, type) => {
6794
- this.css += str;
6571
+ walkRules(selector, callback) {
6572
+ if (!callback) {
6573
+ callback = selector;
6795
6574
 
6796
- if (node && type !== 'end') {
6797
- mapping.generated.line = line;
6798
- mapping.generated.column = column - 1;
6799
- if (node.source && node.source.start) {
6800
- mapping.source = this.sourcePath(node);
6801
- mapping.original.line = node.source.start.line;
6802
- mapping.original.column = node.source.start.column - 1;
6803
- this.map.addMapping(mapping);
6804
- } else {
6805
- mapping.source = noSource;
6806
- mapping.original.line = 1;
6807
- mapping.original.column = 0;
6808
- this.map.addMapping(mapping);
6575
+ return this.walk((child, i) => {
6576
+ if (child.type === 'rule') {
6577
+ return callback(child, i)
6809
6578
  }
6810
- }
6811
-
6812
- lines = str.match(/\n/g);
6813
- if (lines) {
6814
- line += lines.length;
6815
- last = str.lastIndexOf('\n');
6816
- column = str.length - last;
6817
- } else {
6818
- column += str.length;
6819
- }
6820
-
6821
- if (node && type !== 'start') {
6822
- let p = node.parent || { raws: {} };
6823
- let childless =
6824
- node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
6825
- if (!childless || node !== p.last || p.raws.semicolon) {
6826
- if (node.source && node.source.end) {
6827
- mapping.source = this.sourcePath(node);
6828
- mapping.original.line = node.source.end.line;
6829
- mapping.original.column = node.source.end.column - 1;
6830
- mapping.generated.line = line;
6831
- mapping.generated.column = column - 2;
6832
- this.map.addMapping(mapping);
6833
- } else {
6834
- mapping.source = noSource;
6835
- mapping.original.line = 1;
6836
- mapping.original.column = 0;
6837
- mapping.generated.line = line;
6838
- mapping.generated.column = column - 1;
6839
- this.map.addMapping(mapping);
6840
- }
6579
+ })
6580
+ }
6581
+ if (selector instanceof RegExp) {
6582
+ return this.walk((child, i) => {
6583
+ if (child.type === 'rule' && selector.test(child.selector)) {
6584
+ return callback(child, i)
6841
6585
  }
6586
+ })
6587
+ }
6588
+ return this.walk((child, i) => {
6589
+ if (child.type === 'rule' && child.selector === selector) {
6590
+ return callback(child, i)
6842
6591
  }
6843
- });
6592
+ })
6844
6593
  }
6845
6594
 
6846
- isAnnotation() {
6847
- if (this.isInline()) {
6848
- return true
6849
- }
6850
- if (typeof this.mapOpts.annotation !== 'undefined') {
6851
- return this.mapOpts.annotation
6852
- }
6853
- if (this.previous().length) {
6854
- return this.previous().some(i => i.annotation)
6855
- }
6856
- return true
6595
+ get first() {
6596
+ if (!this.proxyOf.nodes) return undefined
6597
+ return this.proxyOf.nodes[0]
6857
6598
  }
6858
6599
 
6859
- isInline() {
6860
- if (typeof this.mapOpts.inline !== 'undefined') {
6861
- return this.mapOpts.inline
6862
- }
6600
+ get last() {
6601
+ if (!this.proxyOf.nodes) return undefined
6602
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
6603
+ }
6604
+ }
6863
6605
 
6864
- let annotation = this.mapOpts.annotation;
6865
- if (typeof annotation !== 'undefined' && annotation !== true) {
6866
- return false
6867
- }
6606
+ Container$7.registerParse = dependant => {
6607
+ parse$4 = dependant;
6608
+ };
6868
6609
 
6869
- if (this.previous().length) {
6870
- return this.previous().some(i => i.inline)
6871
- }
6872
- return true
6873
- }
6610
+ Container$7.registerRule = dependant => {
6611
+ Rule$4 = dependant;
6612
+ };
6874
6613
 
6875
- isMap() {
6876
- if (typeof this.opts.map !== 'undefined') {
6877
- return !!this.opts.map
6878
- }
6879
- return this.previous().length > 0
6880
- }
6614
+ Container$7.registerAtRule = dependant => {
6615
+ AtRule$4 = dependant;
6616
+ };
6881
6617
 
6882
- isSourcesContent() {
6883
- if (typeof this.mapOpts.sourcesContent !== 'undefined') {
6884
- return this.mapOpts.sourcesContent
6885
- }
6886
- if (this.previous().length) {
6887
- return this.previous().some(i => i.withContent())
6888
- }
6889
- return true
6618
+ Container$7.registerRoot = dependant => {
6619
+ Root$6 = dependant;
6620
+ };
6621
+
6622
+ var container = Container$7;
6623
+ Container$7.default = Container$7;
6624
+
6625
+ /* c8 ignore start */
6626
+ Container$7.rebuild = node => {
6627
+ if (node.type === 'atrule') {
6628
+ Object.setPrototypeOf(node, AtRule$4.prototype);
6629
+ } else if (node.type === 'rule') {
6630
+ Object.setPrototypeOf(node, Rule$4.prototype);
6631
+ } else if (node.type === 'decl') {
6632
+ Object.setPrototypeOf(node, Declaration$3.prototype);
6633
+ } else if (node.type === 'comment') {
6634
+ Object.setPrototypeOf(node, Comment$3.prototype);
6635
+ } else if (node.type === 'root') {
6636
+ Object.setPrototypeOf(node, Root$6.prototype);
6890
6637
  }
6891
6638
 
6892
- outputFile() {
6893
- if (this.opts.to) {
6894
- return this.path(this.opts.to)
6895
- } else if (this.opts.from) {
6896
- return this.path(this.opts.from)
6897
- } else {
6898
- return 'to.css'
6899
- }
6639
+ node[my$1] = true;
6640
+
6641
+ if (node.nodes) {
6642
+ node.nodes.forEach(child => {
6643
+ Container$7.rebuild(child);
6644
+ });
6900
6645
  }
6646
+ };
6901
6647
 
6902
- path(file) {
6903
- if (this.mapOpts.absolute) return file
6904
- if (file.charCodeAt(0) === 60 /* `<` */) return file
6905
- if (/^\w+:\/\//.test(file)) return file
6906
- let cached = this.memoizedPaths.get(file);
6907
- if (cached) return cached
6648
+ let Container$6 = container;
6908
6649
 
6909
- let from = this.opts.to ? dirname(this.opts.to) : '.';
6650
+ let LazyResult$4, Processor$3;
6910
6651
 
6911
- if (typeof this.mapOpts.annotation === 'string') {
6912
- from = dirname(resolve(from, this.mapOpts.annotation));
6652
+ class Document$3 extends Container$6 {
6653
+ constructor(defaults) {
6654
+ // type needs to be passed to super, otherwise child roots won't be normalized correctly
6655
+ super({ type: 'document', ...defaults });
6656
+
6657
+ if (!this.nodes) {
6658
+ this.nodes = [];
6913
6659
  }
6660
+ }
6914
6661
 
6915
- let path = relative(from, file);
6916
- this.memoizedPaths.set(file, path);
6662
+ toResult(opts = {}) {
6663
+ let lazy = new LazyResult$4(new Processor$3(), this, opts);
6917
6664
 
6918
- return path
6665
+ return lazy.stringify()
6919
6666
  }
6667
+ }
6920
6668
 
6921
- previous() {
6922
- if (!this.previousMaps) {
6923
- this.previousMaps = [];
6924
- if (this.root) {
6925
- this.root.walk(node => {
6926
- if (node.source && node.source.input.map) {
6927
- let map = node.source.input.map;
6928
- if (!this.previousMaps.includes(map)) {
6929
- this.previousMaps.push(map);
6930
- }
6931
- }
6932
- });
6933
- } else {
6934
- let input = new Input$2(this.originalCSS, this.opts);
6935
- if (input.map) this.previousMaps.push(input.map);
6936
- }
6937
- }
6669
+ Document$3.registerLazyResult = dependant => {
6670
+ LazyResult$4 = dependant;
6671
+ };
6938
6672
 
6939
- return this.previousMaps
6940
- }
6673
+ Document$3.registerProcessor = dependant => {
6674
+ Processor$3 = dependant;
6675
+ };
6941
6676
 
6942
- setSourcesContent() {
6943
- let already = {};
6944
- if (this.root) {
6945
- this.root.walk(node => {
6946
- if (node.source) {
6947
- let from = node.source.input.from;
6948
- if (from && !already[from]) {
6949
- already[from] = true;
6950
- let fromUrl = this.usesFileUrls
6951
- ? this.toFileUrl(from)
6952
- : this.toUrl(this.path(from));
6953
- this.map.setSourceContent(fromUrl, node.source.input.css);
6954
- }
6955
- }
6956
- });
6957
- } else if (this.css) {
6958
- let from = this.opts.from
6959
- ? this.toUrl(this.path(this.opts.from))
6960
- : '<no source>';
6961
- this.map.setSourceContent(from, this.css);
6677
+ var document = Document$3;
6678
+ Document$3.default = Document$3;
6679
+
6680
+ class Warning$2 {
6681
+ constructor(text, opts = {}) {
6682
+ this.type = 'warning';
6683
+ this.text = text;
6684
+
6685
+ if (opts.node && opts.node.source) {
6686
+ let range = opts.node.rangeBy(opts);
6687
+ this.line = range.start.line;
6688
+ this.column = range.start.column;
6689
+ this.endLine = range.end.line;
6690
+ this.endColumn = range.end.column;
6962
6691
  }
6692
+
6693
+ for (let opt in opts) this[opt] = opts[opt];
6963
6694
  }
6964
6695
 
6965
- sourcePath(node) {
6966
- if (this.mapOpts.from) {
6967
- return this.toUrl(this.mapOpts.from)
6968
- } else if (this.usesFileUrls) {
6969
- return this.toFileUrl(node.source.input.from)
6970
- } else {
6971
- return this.toUrl(this.path(node.source.input.from))
6696
+ toString() {
6697
+ if (this.node) {
6698
+ return this.node.error(this.text, {
6699
+ index: this.index,
6700
+ plugin: this.plugin,
6701
+ word: this.word
6702
+ }).message
6972
6703
  }
6973
- }
6974
6704
 
6975
- toBase64(str) {
6976
- if (Buffer) {
6977
- return Buffer.from(str).toString('base64')
6978
- } else {
6979
- return window.btoa(unescape(encodeURIComponent(str)))
6705
+ if (this.plugin) {
6706
+ return this.plugin + ': ' + this.text
6980
6707
  }
6708
+
6709
+ return this.text
6981
6710
  }
6711
+ }
6982
6712
 
6983
- toFileUrl(path) {
6984
- let cached = this.memoizedFileURLs.get(path);
6985
- if (cached) return cached
6713
+ var warning = Warning$2;
6714
+ Warning$2.default = Warning$2;
6986
6715
 
6987
- if (pathToFileURL) {
6988
- let fileURL = pathToFileURL(path).toString();
6989
- this.memoizedFileURLs.set(path, fileURL);
6716
+ let Warning$1 = warning;
6990
6717
 
6991
- return fileURL
6992
- } else {
6993
- throw new Error(
6994
- '`map.absolute` option is not available in this PostCSS build'
6995
- )
6996
- }
6718
+ class Result$3 {
6719
+ constructor(processor, root, opts) {
6720
+ this.processor = processor;
6721
+ this.messages = [];
6722
+ this.root = root;
6723
+ this.opts = opts;
6724
+ this.css = undefined;
6725
+ this.map = undefined;
6997
6726
  }
6998
6727
 
6999
- toUrl(path) {
7000
- let cached = this.memoizedURLs.get(path);
7001
- if (cached) return cached
6728
+ toString() {
6729
+ return this.css
6730
+ }
7002
6731
 
7003
- if (sep === '\\') {
7004
- path = path.replace(/\\/g, '/');
6732
+ warn(text, opts = {}) {
6733
+ if (!opts.plugin) {
6734
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
6735
+ opts.plugin = this.lastPlugin.postcssPlugin;
6736
+ }
7005
6737
  }
7006
6738
 
7007
- let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
7008
- this.memoizedURLs.set(path, url);
6739
+ let warning = new Warning$1(text, opts);
6740
+ this.messages.push(warning);
7009
6741
 
7010
- return url
6742
+ return warning
6743
+ }
6744
+
6745
+ warnings() {
6746
+ return this.messages.filter(i => i.type === 'warning')
6747
+ }
6748
+
6749
+ get content() {
6750
+ return this.css
7011
6751
  }
7012
6752
  }
7013
6753
 
7014
- var mapGenerator = MapGenerator$2;
6754
+ var result = Result$3;
6755
+ Result$3.default = Result$3;
7015
6756
 
7016
6757
  const SINGLE_QUOTE = "'".charCodeAt(0);
7017
6758
  const DOUBLE_QUOTE = '"'.charCodeAt(0);
@@ -7042,8 +6783,8 @@ var tokenize = function tokenizer(input, options = {}) {
7042
6783
  let css = input.css.valueOf();
7043
6784
  let ignore = options.ignoreErrors;
7044
6785
 
7045
- let code, content, escape, next, quote;
7046
- let currentToken, escaped, escapePos, n, prev;
6786
+ let code, next, quote, content, escape;
6787
+ let escaped, escapePos, prev, n, currentToken;
7047
6788
 
7048
6789
  let length = css.length;
7049
6790
  let pos = 0;
@@ -7278,12 +7019,179 @@ var tokenize = function tokenizer(input, options = {}) {
7278
7019
  }
7279
7020
  };
7280
7021
 
7281
- let AtRule$1 = atRule;
7282
- let Comment$1 = comment;
7283
- let Declaration$1 = declaration;
7284
- let Root$3 = root;
7285
- let Rule$1 = rule;
7022
+ let Container$5 = container;
7023
+
7024
+ class AtRule$3 extends Container$5 {
7025
+ constructor(defaults) {
7026
+ super(defaults);
7027
+ this.type = 'atrule';
7028
+ }
7029
+
7030
+ append(...children) {
7031
+ if (!this.proxyOf.nodes) this.nodes = [];
7032
+ return super.append(...children)
7033
+ }
7034
+
7035
+ prepend(...children) {
7036
+ if (!this.proxyOf.nodes) this.nodes = [];
7037
+ return super.prepend(...children)
7038
+ }
7039
+ }
7040
+
7041
+ var atRule = AtRule$3;
7042
+ AtRule$3.default = AtRule$3;
7043
+
7044
+ Container$5.registerAtRule(AtRule$3);
7045
+
7046
+ let Container$4 = container;
7047
+
7048
+ let LazyResult$3, Processor$2;
7049
+
7050
+ class Root$5 extends Container$4 {
7051
+ constructor(defaults) {
7052
+ super(defaults);
7053
+ this.type = 'root';
7054
+ if (!this.nodes) this.nodes = [];
7055
+ }
7056
+
7057
+ normalize(child, sample, type) {
7058
+ let nodes = super.normalize(child);
7059
+
7060
+ if (sample) {
7061
+ if (type === 'prepend') {
7062
+ if (this.nodes.length > 1) {
7063
+ sample.raws.before = this.nodes[1].raws.before;
7064
+ } else {
7065
+ delete sample.raws.before;
7066
+ }
7067
+ } else if (this.first !== sample) {
7068
+ for (let node of nodes) {
7069
+ node.raws.before = sample.raws.before;
7070
+ }
7071
+ }
7072
+ }
7073
+
7074
+ return nodes
7075
+ }
7076
+
7077
+ removeChild(child, ignore) {
7078
+ let index = this.index(child);
7079
+
7080
+ if (!ignore && index === 0 && this.nodes.length > 1) {
7081
+ this.nodes[1].raws.before = this.nodes[index].raws.before;
7082
+ }
7083
+
7084
+ return super.removeChild(child)
7085
+ }
7086
+
7087
+ toResult(opts = {}) {
7088
+ let lazy = new LazyResult$3(new Processor$2(), this, opts);
7089
+ return lazy.stringify()
7090
+ }
7091
+ }
7092
+
7093
+ Root$5.registerLazyResult = dependant => {
7094
+ LazyResult$3 = dependant;
7095
+ };
7096
+
7097
+ Root$5.registerProcessor = dependant => {
7098
+ Processor$2 = dependant;
7099
+ };
7100
+
7101
+ var root = Root$5;
7102
+ Root$5.default = Root$5;
7103
+
7104
+ Container$4.registerRoot(Root$5);
7105
+
7106
+ let list$2 = {
7107
+ comma(string) {
7108
+ return list$2.split(string, [','], true)
7109
+ },
7110
+
7111
+ space(string) {
7112
+ let spaces = [' ', '\n', '\t'];
7113
+ return list$2.split(string, spaces)
7114
+ },
7115
+
7116
+ split(string, separators, last) {
7117
+ let array = [];
7118
+ let current = '';
7119
+ let split = false;
7120
+
7121
+ let func = 0;
7122
+ let inQuote = false;
7123
+ let prevQuote = '';
7124
+ let escape = false;
7125
+
7126
+ for (let letter of string) {
7127
+ if (escape) {
7128
+ escape = false;
7129
+ } else if (letter === '\\') {
7130
+ escape = true;
7131
+ } else if (inQuote) {
7132
+ if (letter === prevQuote) {
7133
+ inQuote = false;
7134
+ }
7135
+ } else if (letter === '"' || letter === "'") {
7136
+ inQuote = true;
7137
+ prevQuote = letter;
7138
+ } else if (letter === '(') {
7139
+ func += 1;
7140
+ } else if (letter === ')') {
7141
+ if (func > 0) func -= 1;
7142
+ } else if (func === 0) {
7143
+ if (separators.includes(letter)) split = true;
7144
+ }
7145
+
7146
+ if (split) {
7147
+ if (current !== '') array.push(current.trim());
7148
+ current = '';
7149
+ split = false;
7150
+ } else {
7151
+ current += letter;
7152
+ }
7153
+ }
7154
+
7155
+ if (last || current !== '') array.push(current.trim());
7156
+ return array
7157
+ }
7158
+ };
7159
+
7160
+ var list_1 = list$2;
7161
+ list$2.default = list$2;
7162
+
7163
+ let Container$3 = container;
7164
+ let list$1 = list_1;
7165
+
7166
+ class Rule$3 extends Container$3 {
7167
+ constructor(defaults) {
7168
+ super(defaults);
7169
+ this.type = 'rule';
7170
+ if (!this.nodes) this.nodes = [];
7171
+ }
7172
+
7173
+ get selectors() {
7174
+ return list$1.comma(this.selector)
7175
+ }
7176
+
7177
+ set selectors(values) {
7178
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
7179
+ let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
7180
+ this.selector = values.join(sep);
7181
+ }
7182
+ }
7183
+
7184
+ var rule = Rule$3;
7185
+ Rule$3.default = Rule$3;
7186
+
7187
+ Container$3.registerRule(Rule$3);
7188
+
7189
+ let Declaration$2 = declaration;
7286
7190
  let tokenizer = tokenize;
7191
+ let Comment$2 = comment;
7192
+ let AtRule$2 = atRule;
7193
+ let Root$4 = root;
7194
+ let Rule$2 = rule;
7287
7195
 
7288
7196
  const SAFE_COMMENT_NEIGHBOR = {
7289
7197
  empty: true,
@@ -7302,7 +7210,7 @@ class Parser$1 {
7302
7210
  constructor(input) {
7303
7211
  this.input = input;
7304
7212
 
7305
- this.root = new Root$3();
7213
+ this.root = new Root$4();
7306
7214
  this.current = this.root;
7307
7215
  this.spaces = '';
7308
7216
  this.semicolon = false;
@@ -7312,7 +7220,7 @@ class Parser$1 {
7312
7220
  }
7313
7221
 
7314
7222
  atrule(token) {
7315
- let node = new AtRule$1();
7223
+ let node = new AtRule$2();
7316
7224
  node.name = token[1].slice(1);
7317
7225
  if (node.name === '') {
7318
7226
  this.unnamedAtrule(node, token);
@@ -7421,7 +7329,7 @@ class Parser$1 {
7421
7329
 
7422
7330
  colon(tokens) {
7423
7331
  let brackets = 0;
7424
- let prev, token, type;
7332
+ let token, type, prev;
7425
7333
  for (let [i, element] of tokens.entries()) {
7426
7334
  token = element;
7427
7335
  type = token[0];
@@ -7448,7 +7356,7 @@ class Parser$1 {
7448
7356
  }
7449
7357
 
7450
7358
  comment(token) {
7451
- let node = new Comment$1();
7359
+ let node = new Comment$2();
7452
7360
  this.init(node, token[2]);
7453
7361
  node.source.end = this.getPosition(token[3] || token[2]);
7454
7362
  node.source.end.offset++;
@@ -7471,7 +7379,7 @@ class Parser$1 {
7471
7379
  }
7472
7380
 
7473
7381
  decl(tokens, customProperty) {
7474
- let node = new Declaration$1();
7382
+ let node = new Declaration$2();
7475
7383
  this.init(node, tokens[0][2]);
7476
7384
 
7477
7385
  let last = tokens[tokens.length - 1];
@@ -7545,12 +7453,12 @@ class Parser$1 {
7545
7453
  let str = '';
7546
7454
  for (let j = i; j > 0; j--) {
7547
7455
  let type = cache[j][0];
7548
- if (str.trim().startsWith('!') && type !== 'space') {
7456
+ if (str.trim().indexOf('!') === 0 && type !== 'space') {
7549
7457
  break
7550
7458
  }
7551
7459
  str = cache.pop()[1] + str;
7552
7460
  }
7553
- if (str.trim().startsWith('!')) {
7461
+ if (str.trim().indexOf('!') === 0) {
7554
7462
  node.important = true;
7555
7463
  node.raws.important = str;
7556
7464
  tokens = cache;
@@ -7584,7 +7492,7 @@ class Parser$1 {
7584
7492
  }
7585
7493
 
7586
7494
  emptyRule(token) {
7587
- let node = new Rule$1();
7495
+ let node = new Rule$2();
7588
7496
  this.init(node, token[2]);
7589
7497
  node.selector = '';
7590
7498
  node.raws.between = '';
@@ -7625,8 +7533,6 @@ class Parser$1 {
7625
7533
  if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
7626
7534
  prev.raws.ownSemicolon = this.spaces;
7627
7535
  this.spaces = '';
7628
- prev.source.end = this.getPosition(token[2]);
7629
- prev.source.end.offset += prev.raws.ownSemicolon.length;
7630
7536
  }
7631
7537
  }
7632
7538
  }
@@ -7796,7 +7702,7 @@ class Parser$1 {
7796
7702
  rule(tokens) {
7797
7703
  tokens.pop();
7798
7704
 
7799
- let node = new Rule$1();
7705
+ let node = new Rule$2();
7800
7706
  this.init(node, tokens[0][2]);
7801
7707
 
7802
7708
  node.raws.between = this.spacesAndCommentsFromEnd(tokens);
@@ -7871,7 +7777,7 @@ class Parser$1 {
7871
7777
 
7872
7778
  unknownWord(tokens) {
7873
7779
  throw this.input.error(
7874
- 'Unknown word ' + tokens[0][1],
7780
+ 'Unknown word',
7875
7781
  { offset: tokens[0][2] },
7876
7782
  { offset: tokens[0][2] + tokens[0][1].length }
7877
7783
  )
@@ -7889,11 +7795,11 @@ class Parser$1 {
7889
7795
  var parser = Parser$1;
7890
7796
 
7891
7797
  let Container$2 = container;
7892
- let Input$1 = input;
7893
7798
  let Parser = parser;
7799
+ let Input$2 = input;
7894
7800
 
7895
7801
  function parse$3(css, opts) {
7896
- let input = new Input$1(css, opts);
7802
+ let input = new Input$2(css, opts);
7897
7803
  let parser = new Parser(input);
7898
7804
  try {
7899
7805
  parser.parse();
@@ -7907,93 +7813,16 @@ function parse$3(css, opts) {
7907
7813
  var parse_1 = parse$3;
7908
7814
  parse$3.default = parse$3;
7909
7815
 
7910
- Container$2.registerParse(parse$3);
7911
-
7912
- class Warning$2 {
7913
- constructor(text, opts = {}) {
7914
- this.type = 'warning';
7915
- this.text = text;
7916
-
7917
- if (opts.node && opts.node.source) {
7918
- let range = opts.node.rangeBy(opts);
7919
- this.line = range.start.line;
7920
- this.column = range.start.column;
7921
- this.endLine = range.end.line;
7922
- this.endColumn = range.end.column;
7923
- }
7924
-
7925
- for (let opt in opts) this[opt] = opts[opt];
7926
- }
7927
-
7928
- toString() {
7929
- if (this.node) {
7930
- return this.node.error(this.text, {
7931
- index: this.index,
7932
- plugin: this.plugin,
7933
- word: this.word
7934
- }).message
7935
- }
7936
-
7937
- if (this.plugin) {
7938
- return this.plugin + ': ' + this.text
7939
- }
7940
-
7941
- return this.text
7942
- }
7943
- }
7944
-
7945
- var warning = Warning$2;
7946
- Warning$2.default = Warning$2;
7947
-
7948
- let Warning$1 = warning;
7949
-
7950
- class Result$3 {
7951
- get content() {
7952
- return this.css
7953
- }
7954
-
7955
- constructor(processor, root, opts) {
7956
- this.processor = processor;
7957
- this.messages = [];
7958
- this.root = root;
7959
- this.opts = opts;
7960
- this.css = undefined;
7961
- this.map = undefined;
7962
- }
7963
-
7964
- toString() {
7965
- return this.css
7966
- }
7967
-
7968
- warn(text, opts = {}) {
7969
- if (!opts.plugin) {
7970
- if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
7971
- opts.plugin = this.lastPlugin.postcssPlugin;
7972
- }
7973
- }
7974
-
7975
- let warning = new Warning$1(text, opts);
7976
- this.messages.push(warning);
7977
-
7978
- return warning
7979
- }
7980
-
7981
- warnings() {
7982
- return this.messages.filter(i => i.type === 'warning')
7983
- }
7984
- }
7985
-
7986
- var result = Result$3;
7987
- Result$3.default = Result$3;
7816
+ Container$2.registerParse(parse$3);
7988
7817
 
7818
+ let { isClean, my } = symbols;
7819
+ let MapGenerator$1 = mapGenerator;
7820
+ let stringify$2 = stringify_1;
7989
7821
  let Container$1 = container;
7990
7822
  let Document$2 = document;
7991
- let MapGenerator$1 = mapGenerator;
7992
- let parse$2 = parse_1;
7993
7823
  let Result$2 = result;
7994
- let Root$2 = root;
7995
- let stringify$2 = stringify_1;
7996
- let { isClean, my } = symbols;
7824
+ let parse$2 = parse_1;
7825
+ let Root$3 = root;
7997
7826
 
7998
7827
  const TYPE_TO_CLASS_NAME = {
7999
7828
  atrule: 'AtRule',
@@ -8090,38 +7919,6 @@ function cleanMarks(node) {
8090
7919
  let postcss$1 = {};
8091
7920
 
8092
7921
  class LazyResult$2 {
8093
- get content() {
8094
- return this.stringify().content
8095
- }
8096
-
8097
- get css() {
8098
- return this.stringify().css
8099
- }
8100
-
8101
- get map() {
8102
- return this.stringify().map
8103
- }
8104
-
8105
- get messages() {
8106
- return this.sync().messages
8107
- }
8108
-
8109
- get opts() {
8110
- return this.result.opts
8111
- }
8112
-
8113
- get processor() {
8114
- return this.result.processor
8115
- }
8116
-
8117
- get root() {
8118
- return this.sync().root
8119
- }
8120
-
8121
- get [Symbol.toStringTag]() {
8122
- return 'LazyResult'
8123
- }
8124
-
8125
7922
  constructor(processor, css, opts) {
8126
7923
  this.stringified = false;
8127
7924
  this.processed = false;
@@ -8491,38 +8288,21 @@ class LazyResult$2 {
8491
8288
  warnings() {
8492
8289
  return this.sync().warnings()
8493
8290
  }
8494
- }
8495
-
8496
- LazyResult$2.registerPostcss = dependant => {
8497
- postcss$1 = dependant;
8498
- };
8499
-
8500
- var lazyResult = LazyResult$2;
8501
- LazyResult$2.default = LazyResult$2;
8502
-
8503
- Root$2.registerLazyResult(LazyResult$2);
8504
- Document$2.registerLazyResult(LazyResult$2);
8505
-
8506
- let MapGenerator = mapGenerator;
8507
- let parse$1 = parse_1;
8508
- const Result$1 = result;
8509
- let stringify$1 = stringify_1;
8510
8291
 
8511
- class NoWorkResult$1 {
8512
8292
  get content() {
8513
- return this.result.css
8293
+ return this.stringify().content
8514
8294
  }
8515
8295
 
8516
8296
  get css() {
8517
- return this.result.css
8297
+ return this.stringify().css
8518
8298
  }
8519
8299
 
8520
8300
  get map() {
8521
- return this.result.map
8301
+ return this.stringify().map
8522
8302
  }
8523
8303
 
8524
8304
  get messages() {
8525
- return []
8305
+ return this.sync().messages
8526
8306
  }
8527
8307
 
8528
8308
  get opts() {
@@ -8534,31 +8314,30 @@ class NoWorkResult$1 {
8534
8314
  }
8535
8315
 
8536
8316
  get root() {
8537
- if (this._root) {
8538
- return this._root
8539
- }
8540
-
8541
- let root;
8542
- let parser = parse$1;
8543
-
8544
- try {
8545
- root = parser(this._css, this._opts);
8546
- } catch (error) {
8547
- this.error = error;
8548
- }
8549
-
8550
- if (this.error) {
8551
- throw this.error
8552
- } else {
8553
- this._root = root;
8554
- return root
8555
- }
8317
+ return this.sync().root
8556
8318
  }
8557
8319
 
8558
8320
  get [Symbol.toStringTag]() {
8559
- return 'NoWorkResult'
8321
+ return 'LazyResult'
8560
8322
  }
8323
+ }
8324
+
8325
+ LazyResult$2.registerPostcss = dependant => {
8326
+ postcss$1 = dependant;
8327
+ };
8561
8328
 
8329
+ var lazyResult = LazyResult$2;
8330
+ LazyResult$2.default = LazyResult$2;
8331
+
8332
+ Root$3.registerLazyResult(LazyResult$2);
8333
+ Document$2.registerLazyResult(LazyResult$2);
8334
+
8335
+ let MapGenerator = mapGenerator;
8336
+ let stringify$1 = stringify_1;
8337
+ let parse$1 = parse_1;
8338
+ const Result$1 = result;
8339
+
8340
+ class NoWorkResult$1 {
8562
8341
  constructor(processor, css, opts) {
8563
8342
  css = css.toString();
8564
8343
  this.stringified = false;
@@ -8625,19 +8404,69 @@ class NoWorkResult$1 {
8625
8404
  warnings() {
8626
8405
  return []
8627
8406
  }
8407
+
8408
+ get content() {
8409
+ return this.result.css
8410
+ }
8411
+
8412
+ get css() {
8413
+ return this.result.css
8414
+ }
8415
+
8416
+ get map() {
8417
+ return this.result.map
8418
+ }
8419
+
8420
+ get messages() {
8421
+ return []
8422
+ }
8423
+
8424
+ get opts() {
8425
+ return this.result.opts
8426
+ }
8427
+
8428
+ get processor() {
8429
+ return this.result.processor
8430
+ }
8431
+
8432
+ get root() {
8433
+ if (this._root) {
8434
+ return this._root
8435
+ }
8436
+
8437
+ let root;
8438
+ let parser = parse$1;
8439
+
8440
+ try {
8441
+ root = parser(this._css, this._opts);
8442
+ } catch (error) {
8443
+ this.error = error;
8444
+ }
8445
+
8446
+ if (this.error) {
8447
+ throw this.error
8448
+ } else {
8449
+ this._root = root;
8450
+ return root
8451
+ }
8452
+ }
8453
+
8454
+ get [Symbol.toStringTag]() {
8455
+ return 'NoWorkResult'
8456
+ }
8628
8457
  }
8629
8458
 
8630
8459
  var noWorkResult = NoWorkResult$1;
8631
8460
  NoWorkResult$1.default = NoWorkResult$1;
8632
8461
 
8633
- let Document$1 = document;
8634
- let LazyResult$1 = lazyResult;
8635
8462
  let NoWorkResult = noWorkResult;
8636
- let Root$1 = root;
8463
+ let LazyResult$1 = lazyResult;
8464
+ let Document$1 = document;
8465
+ let Root$2 = root;
8637
8466
 
8638
8467
  class Processor$1 {
8639
8468
  constructor(plugins = []) {
8640
- this.version = '8.5.3';
8469
+ this.version = '8.4.35';
8641
8470
  this.plugins = this.normalize(plugins);
8642
8471
  }
8643
8472
 
@@ -8685,27 +8514,80 @@ class Processor$1 {
8685
8514
  var processor = Processor$1;
8686
8515
  Processor$1.default = Processor$1;
8687
8516
 
8688
- Root$1.registerProcessor(Processor$1);
8517
+ Root$2.registerProcessor(Processor$1);
8689
8518
  Document$1.registerProcessor(Processor$1);
8690
8519
 
8691
- let AtRule = atRule;
8692
- let Comment = comment;
8693
- let Container = container;
8520
+ let Declaration$1 = declaration;
8521
+ let PreviousMap = previousMap;
8522
+ let Comment$1 = comment;
8523
+ let AtRule$1 = atRule;
8524
+ let Input$1 = input;
8525
+ let Root$1 = root;
8526
+ let Rule$1 = rule;
8527
+
8528
+ function fromJSON$1(json, inputs) {
8529
+ if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
8530
+
8531
+ let { inputs: ownInputs, ...defaults } = json;
8532
+ if (ownInputs) {
8533
+ inputs = [];
8534
+ for (let input of ownInputs) {
8535
+ let inputHydrated = { ...input, __proto__: Input$1.prototype };
8536
+ if (inputHydrated.map) {
8537
+ inputHydrated.map = {
8538
+ ...inputHydrated.map,
8539
+ __proto__: PreviousMap.prototype
8540
+ };
8541
+ }
8542
+ inputs.push(inputHydrated);
8543
+ }
8544
+ }
8545
+ if (defaults.nodes) {
8546
+ defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
8547
+ }
8548
+ if (defaults.source) {
8549
+ let { inputId, ...source } = defaults.source;
8550
+ defaults.source = source;
8551
+ if (inputId != null) {
8552
+ defaults.source.input = inputs[inputId];
8553
+ }
8554
+ }
8555
+ if (defaults.type === 'root') {
8556
+ return new Root$1(defaults)
8557
+ } else if (defaults.type === 'decl') {
8558
+ return new Declaration$1(defaults)
8559
+ } else if (defaults.type === 'rule') {
8560
+ return new Rule$1(defaults)
8561
+ } else if (defaults.type === 'comment') {
8562
+ return new Comment$1(defaults)
8563
+ } else if (defaults.type === 'atrule') {
8564
+ return new AtRule$1(defaults)
8565
+ } else {
8566
+ throw new Error('Unknown node type: ' + json.type)
8567
+ }
8568
+ }
8569
+
8570
+ var fromJSON_1 = fromJSON$1;
8571
+ fromJSON$1.default = fromJSON$1;
8572
+
8694
8573
  let CssSyntaxError = cssSyntaxError;
8695
8574
  let Declaration = declaration;
8696
- let Document = document;
8697
- let fromJSON = fromJSON_1;
8698
- let Input = input;
8699
8575
  let LazyResult = lazyResult;
8700
- let list = list_1;
8701
- let Node = node_1;
8702
- let parse = parse_1;
8576
+ let Container = container;
8703
8577
  let Processor = processor;
8704
- let Result = result;
8705
- let Root = root;
8706
- let Rule = rule;
8707
8578
  let stringify = stringify_1;
8579
+ let fromJSON = fromJSON_1;
8580
+ let Document = document;
8708
8581
  let Warning = warning;
8582
+ let Comment = comment;
8583
+ let AtRule = atRule;
8584
+ let Result = result;
8585
+ let Input = input;
8586
+ let parse = parse_1;
8587
+ let list = list_1;
8588
+ let Rule = rule;
8589
+ let Root = root;
8590
+ let Node = node_1;
8709
8591
 
8710
8592
  function postcss(...plugins) {
8711
8593
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
@@ -8788,7 +8670,7 @@ LazyResult.registerPostcss(postcss);
8788
8670
  var postcss_1 = postcss;
8789
8671
  postcss.default = postcss;
8790
8672
 
8791
- const htmlparser = require$$0$1;
8673
+ const htmlparser = require$$0;
8792
8674
  const escapeStringRegexp = escapeStringRegexp$1;
8793
8675
  const { isPlainObject } = require$$2$1;
8794
8676
  const deepmerge = cjs;
@@ -8960,24 +8842,20 @@ function sanitizeHtml(html, options, _recursing) {
8960
8842
  allowedAttributesMap[tag].push('class');
8961
8843
  }
8962
8844
 
8963
- allowedClassesMap[tag] = classes;
8964
-
8965
- if (Array.isArray(classes)) {
8966
- const globRegex = [];
8967
- allowedClassesMap[tag] = [];
8968
- allowedClassesRegexMap[tag] = [];
8969
- classes.forEach(function(obj) {
8970
- if (typeof obj === 'string' && obj.indexOf('*') >= 0) {
8971
- globRegex.push(escapeStringRegexp(obj).replace(/\\\*/g, '.*'));
8972
- } else if (obj instanceof RegExp) {
8973
- allowedClassesRegexMap[tag].push(obj);
8974
- } else {
8975
- allowedClassesMap[tag].push(obj);
8976
- }
8977
- });
8978
- if (globRegex.length) {
8979
- allowedClassesGlobMap[tag] = new RegExp('^(' + globRegex.join('|') + ')$');
8845
+ allowedClassesMap[tag] = [];
8846
+ allowedClassesRegexMap[tag] = [];
8847
+ const globRegex = [];
8848
+ classes.forEach(function(obj) {
8849
+ if (typeof obj === 'string' && obj.indexOf('*') >= 0) {
8850
+ globRegex.push(escapeStringRegexp(obj).replace(/\\\*/g, '.*'));
8851
+ } else if (obj instanceof RegExp) {
8852
+ allowedClassesRegexMap[tag].push(obj);
8853
+ } else {
8854
+ allowedClassesMap[tag].push(obj);
8980
8855
  }
8856
+ });
8857
+ if (globRegex.length) {
8858
+ allowedClassesGlobMap[tag] = new RegExp('^(' + globRegex.join('|') + ')$');
8981
8859
  }
8982
8860
  });
8983
8861
 
@@ -9052,7 +8930,7 @@ function sanitizeHtml(html, options, _recursing) {
9052
8930
  if (!tagAllowed(name) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
9053
8931
  skip = true;
9054
8932
  skipMap[depth] = true;
9055
- if (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') {
8933
+ if (options.disallowedTagsMode === 'discard') {
9056
8934
  if (nonTextTagsArray.indexOf(name) !== -1) {
9057
8935
  skipText = true;
9058
8936
  skipTextDepth = 1;
@@ -9062,17 +8940,8 @@ function sanitizeHtml(html, options, _recursing) {
9062
8940
  }
9063
8941
  depth++;
9064
8942
  if (skip) {
9065
- if (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') {
8943
+ if (options.disallowedTagsMode === 'discard') {
9066
8944
  // We want the contents but not this tag
9067
- if (frame.innerText && !hasText) {
9068
- const escaped = escapeHtml(frame.innerText);
9069
- if (options.textFilter) {
9070
- result += options.textFilter(escaped, name);
9071
- } else {
9072
- result += escapeHtml(frame.innerText);
9073
- }
9074
- addedText = true;
9075
- }
9076
8945
  return;
9077
8946
  }
9078
8947
  tempResult = result;
@@ -9094,14 +8963,6 @@ function sanitizeHtml(html, options, _recursing) {
9094
8963
  delete frame.attribs[a];
9095
8964
  return;
9096
8965
  }
9097
- // If the value is empty, check if the attribute is in the allowedEmptyAttributes array.
9098
- // If it is not in the allowedEmptyAttributes array, and it is a known non-boolean attribute, delete it
9099
- // List taken from https://html.spec.whatwg.org/multipage/indices.html#attributes-3
9100
- if (value === '' && (!options.allowedEmptyAttributes.includes(a)) &&
9101
- (options.nonBooleanAttributes.includes(a) || options.nonBooleanAttributes.includes('*'))) {
9102
- delete frame.attribs[a];
9103
- return;
9104
- }
9105
8966
  // check allowedAttributesMap for the element and attribute and modify the value
9106
8967
  // as necessary if there are specific values defined.
9107
8968
  let passedAllowedAttributesMapCheck = false;
@@ -9230,13 +9091,12 @@ function sanitizeHtml(html, options, _recursing) {
9230
9091
  const allowedWildcardClasses = allowedClassesMap['*'];
9231
9092
  const allowedSpecificClassesGlob = allowedClassesGlobMap[name];
9232
9093
  const allowedSpecificClassesRegex = allowedClassesRegexMap[name];
9233
- const allowedWildcardClassesRegex = allowedClassesRegexMap['*'];
9234
9094
  const allowedWildcardClassesGlob = allowedClassesGlobMap['*'];
9235
9095
  const allowedClassesGlobs = [
9236
9096
  allowedSpecificClassesGlob,
9237
9097
  allowedWildcardClassesGlob
9238
9098
  ]
9239
- .concat(allowedSpecificClassesRegex, allowedWildcardClassesRegex)
9099
+ .concat(allowedSpecificClassesRegex)
9240
9100
  .filter(function (t) {
9241
9101
  return t;
9242
9102
  });
@@ -9253,7 +9113,7 @@ function sanitizeHtml(html, options, _recursing) {
9253
9113
  if (a === 'style') {
9254
9114
  if (options.parseStyleAttributes) {
9255
9115
  try {
9256
- const abstractSyntaxTree = postcssParse(name + ' {' + value + '}', { map: false });
9116
+ const abstractSyntaxTree = postcssParse(name + ' {' + value + '}');
9257
9117
  const filteredAST = filterCss(abstractSyntaxTree, options.allowedStyles);
9258
9118
 
9259
9119
  value = stringifyStyleAttributes(filteredAST);
@@ -9263,9 +9123,7 @@ function sanitizeHtml(html, options, _recursing) {
9263
9123
  return;
9264
9124
  }
9265
9125
  } catch (e) {
9266
- if (typeof window !== 'undefined') {
9267
- console.warn('Failed to parse "' + name + ' {' + value + '}' + '", If you\'re running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547');
9268
- }
9126
+ console.warn('Failed to parse "' + name + ' {' + value + '}' + '", If you\'re running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547');
9269
9127
  delete frame.attribs[a];
9270
9128
  return;
9271
9129
  }
@@ -9276,8 +9134,6 @@ function sanitizeHtml(html, options, _recursing) {
9276
9134
  result += ' ' + a;
9277
9135
  if (value && value.length) {
9278
9136
  result += '="' + escapeHtml(value, true) + '"';
9279
- } else if (options.allowedEmptyAttributes.includes(a)) {
9280
- result += '=""';
9281
9137
  }
9282
9138
  } else {
9283
9139
  delete frame.attribs[a];
@@ -9311,9 +9167,7 @@ function sanitizeHtml(html, options, _recursing) {
9311
9167
  text = lastFrame.innerText !== undefined ? lastFrame.innerText : text;
9312
9168
  }
9313
9169
 
9314
- if (options.disallowedTagsMode === 'completelyDiscard' && !tagAllowed(tag)) {
9315
- text = '';
9316
- } else if ((options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && ((tag === 'script') || (tag === 'style'))) {
9170
+ if (options.disallowedTagsMode === 'discard' && ((tag === 'script') || (tag === 'style'))) {
9317
9171
  // htmlparser2 gives us these as-is. Escaping them ruins the content. Allowing
9318
9172
  // script tags is, by definition, game over for XSS protection, so if that's
9319
9173
  // your concern, don't allow them. The same is essentially true for style tags
@@ -9361,7 +9215,7 @@ function sanitizeHtml(html, options, _recursing) {
9361
9215
  const skip = skipMap[depth];
9362
9216
  if (skip) {
9363
9217
  delete skipMap[depth];
9364
- if (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') {
9218
+ if (options.disallowedTagsMode === 'discard') {
9365
9219
  frame.updateParentNodeText();
9366
9220
  return;
9367
9221
  }
@@ -9632,49 +9486,6 @@ sanitizeHtml.defaults = {
9632
9486
  'caption', 'col', 'colgroup', 'table', 'tbody', 'td', 'tfoot', 'th',
9633
9487
  'thead', 'tr'
9634
9488
  ],
9635
- // Tags that cannot be boolean
9636
- nonBooleanAttributes: [
9637
- 'abbr', 'accept', 'accept-charset', 'accesskey', 'action',
9638
- 'allow', 'alt', 'as', 'autocapitalize', 'autocomplete',
9639
- 'blocking', 'charset', 'cite', 'class', 'color', 'cols',
9640
- 'colspan', 'content', 'contenteditable', 'coords', 'crossorigin',
9641
- 'data', 'datetime', 'decoding', 'dir', 'dirname', 'download',
9642
- 'draggable', 'enctype', 'enterkeyhint', 'fetchpriority', 'for',
9643
- 'form', 'formaction', 'formenctype', 'formmethod', 'formtarget',
9644
- 'headers', 'height', 'hidden', 'high', 'href', 'hreflang',
9645
- 'http-equiv', 'id', 'imagesizes', 'imagesrcset', 'inputmode',
9646
- 'integrity', 'is', 'itemid', 'itemprop', 'itemref', 'itemtype',
9647
- 'kind', 'label', 'lang', 'list', 'loading', 'low', 'max',
9648
- 'maxlength', 'media', 'method', 'min', 'minlength', 'name',
9649
- 'nonce', 'optimum', 'pattern', 'ping', 'placeholder', 'popover',
9650
- 'popovertarget', 'popovertargetaction', 'poster', 'preload',
9651
- 'referrerpolicy', 'rel', 'rows', 'rowspan', 'sandbox', 'scope',
9652
- 'shape', 'size', 'sizes', 'slot', 'span', 'spellcheck', 'src',
9653
- 'srcdoc', 'srclang', 'srcset', 'start', 'step', 'style',
9654
- 'tabindex', 'target', 'title', 'translate', 'type', 'usemap',
9655
- 'value', 'width', 'wrap',
9656
- // Event handlers
9657
- 'onauxclick', 'onafterprint', 'onbeforematch', 'onbeforeprint',
9658
- 'onbeforeunload', 'onbeforetoggle', 'onblur', 'oncancel',
9659
- 'oncanplay', 'oncanplaythrough', 'onchange', 'onclick', 'onclose',
9660
- 'oncontextlost', 'oncontextmenu', 'oncontextrestored', 'oncopy',
9661
- 'oncuechange', 'oncut', 'ondblclick', 'ondrag', 'ondragend',
9662
- 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart',
9663
- 'ondrop', 'ondurationchange', 'onemptied', 'onended',
9664
- 'onerror', 'onfocus', 'onformdata', 'onhashchange', 'oninput',
9665
- 'oninvalid', 'onkeydown', 'onkeypress', 'onkeyup',
9666
- 'onlanguagechange', 'onload', 'onloadeddata', 'onloadedmetadata',
9667
- 'onloadstart', 'onmessage', 'onmessageerror', 'onmousedown',
9668
- 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout',
9669
- 'onmouseover', 'onmouseup', 'onoffline', 'ononline', 'onpagehide',
9670
- 'onpageshow', 'onpaste', 'onpause', 'onplay', 'onplaying',
9671
- 'onpopstate', 'onprogress', 'onratechange', 'onreset', 'onresize',
9672
- 'onrejectionhandled', 'onscroll', 'onscrollend',
9673
- 'onsecuritypolicyviolation', 'onseeked', 'onseeking', 'onselect',
9674
- 'onslotchange', 'onstalled', 'onstorage', 'onsubmit', 'onsuspend',
9675
- 'ontimeupdate', 'ontoggle', 'onunhandledrejection', 'onunload',
9676
- 'onvolumechange', 'onwaiting', 'onwheel'
9677
- ],
9678
9489
  disallowedTagsMode: 'discard',
9679
9490
  allowedAttributes: {
9680
9491
  a: [ 'href', 'name', 'target' ],
@@ -9682,9 +9493,6 @@ sanitizeHtml.defaults = {
9682
9493
  // these attributes would make sense if we did.
9683
9494
  img: [ 'src', 'srcset', 'alt', 'title', 'width', 'height', 'loading' ]
9684
9495
  },
9685
- allowedEmptyAttributes: [
9686
- 'alt'
9687
- ],
9688
9496
  // Lots of these won't come up by default because we don't allow them
9689
9497
  selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],
9690
9498
  // URL schemes we permit
@@ -9725,13 +9533,9 @@ const CustomContentSectionStyle0 = customContentSectionCss;
9725
9533
  const CustomContentSection = class {
9726
9534
  constructor(hostRef) {
9727
9535
  registerInstance(this, hostRef);
9728
- /**
9729
- * If this is true it will emit an event at the moment the content with url its clicked
9730
- */
9536
+ this.customContent = undefined;
9537
+ this.repeaterContent = undefined;
9731
9538
  this.navigateViaEvent = false;
9732
- /**
9733
- * Post Message event to be sent on navigation via Event
9734
- */
9735
9539
  this.postMessageEvent = '';
9736
9540
  }
9737
9541
  render() {