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