@everymatrix/general-footer-template 1.50.0 → 1.50.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/cjs/custom-clock.cjs.entry.js +1 -1
  2. package/dist/cjs/custom-content-section.cjs.entry.js +1497 -1417
  3. package/dist/cjs/general-footer-template.cjs.entry.js +1 -1
  4. package/dist/cjs/general-footer-template.cjs.js +2 -2
  5. package/dist/cjs/image-list.cjs.entry.js +1 -1
  6. package/dist/cjs/{index-5df9aa92.js → index-465b4ca9.js} +31 -14
  7. package/dist/cjs/link-section-list.cjs.entry.js +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +2 -2
  10. package/dist/esm/custom-clock.entry.js +1 -1
  11. package/dist/esm/custom-content-section.entry.js +1497 -1417
  12. package/dist/esm/general-footer-template.entry.js +1 -1
  13. package/dist/esm/general-footer-template.js +3 -3
  14. package/dist/esm/image-list.entry.js +1 -1
  15. package/dist/esm/{index-73d3bdf3.js → index-9775f5ee.js} +31 -14
  16. package/dist/esm/link-section-list.entry.js +1 -1
  17. package/dist/esm/loader.js +2 -2
  18. package/dist/general-footer-template/general-footer-template.esm.js +1 -1
  19. package/dist/general-footer-template/{p-bbe2c383.entry.js → p-1274900b.entry.js} +1 -1
  20. package/dist/general-footer-template/p-2fce3c9f.js +2 -0
  21. package/dist/general-footer-template/{p-5a1612c1.entry.js → p-330130cd.entry.js} +1 -1
  22. package/dist/general-footer-template/{p-516893f4.entry.js → p-5982a2ca.entry.js} +2 -2
  23. package/dist/general-footer-template/{p-12f3ff37.entry.js → p-cc02e076.entry.js} +1 -1
  24. package/dist/general-footer-template/{p-c559c8bc.entry.js → p-e19d7226.entry.js} +1 -1
  25. package/dist/types/stencil-public-runtime.d.ts +6 -0
  26. package/package.json +1 -1
  27. package/dist/general-footer-template/p-fbe51a04.js +0 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index$2 = require('./index-5df9aa92.js');
5
+ const index$2 = require('./index-465b4ca9.js');
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
8
 
@@ -4025,7 +4025,7 @@ const esm = /*#__PURE__*/Object.freeze({
4025
4025
  DomUtils: index
4026
4026
  });
4027
4027
 
4028
- const require$$0 = /*@__PURE__*/getAugmentedNamespace(esm);
4028
+ const require$$0$1 = /*@__PURE__*/getAugmentedNamespace(esm);
4029
4029
 
4030
4030
  var escapeStringRegexp$1 = string => {
4031
4031
  if (typeof string !== 'string') {
@@ -4608,37 +4608,70 @@ class CssSyntaxError$3 extends Error {
4608
4608
 
4609
4609
  let css = this.source;
4610
4610
  if (color == null) color = pico.isColorSupported;
4611
- if (terminalHighlight$1) {
4612
- if (color) css = terminalHighlight$1(css);
4613
- }
4614
-
4615
- let lines = css.split(/\r?\n/);
4616
- let start = Math.max(this.line - 3, 0);
4617
- let end = Math.min(this.line + 2, lines.length);
4618
-
4619
- let maxWidth = String(end).length;
4620
4611
 
4621
- let mark, aside;
4612
+ let aside = text => text;
4613
+ let mark = text => text;
4614
+ let highlight = text => text;
4622
4615
  if (color) {
4623
4616
  let { bold, gray, red } = pico.createColors(true);
4624
4617
  mark = text => bold(red(text));
4625
4618
  aside = text => gray(text);
4626
- } else {
4627
- mark = aside = str => str;
4619
+ if (terminalHighlight$1) {
4620
+ highlight = text => terminalHighlight$1(text);
4621
+ }
4628
4622
  }
4629
4623
 
4624
+ let lines = css.split(/\r?\n/);
4625
+ let start = Math.max(this.line - 3, 0);
4626
+ let end = Math.min(this.line + 2, lines.length);
4627
+ let maxWidth = String(end).length;
4628
+
4630
4629
  return lines
4631
4630
  .slice(start, end)
4632
4631
  .map((line, index) => {
4633
4632
  let number = start + 1 + index;
4634
4633
  let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
4635
4634
  if (number === this.line) {
4635
+ if (line.length > 160) {
4636
+ let padding = 20;
4637
+ let subLineStart = Math.max(0, this.column - padding);
4638
+ let subLineEnd = Math.max(
4639
+ this.column + padding,
4640
+ this.endColumn + padding
4641
+ );
4642
+ let subLine = line.slice(subLineStart, subLineEnd);
4643
+
4644
+ let spacing =
4645
+ aside(gutter.replace(/\d/g, ' ')) +
4646
+ line
4647
+ .slice(0, Math.min(this.column - 1, padding - 1))
4648
+ .replace(/[^\t]/g, ' ');
4649
+
4650
+ return (
4651
+ mark('>') +
4652
+ aside(gutter) +
4653
+ highlight(subLine) +
4654
+ '\n ' +
4655
+ spacing +
4656
+ mark('^')
4657
+ )
4658
+ }
4659
+
4636
4660
  let spacing =
4637
4661
  aside(gutter.replace(/\d/g, ' ')) +
4638
4662
  line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
4639
- return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
4663
+
4664
+ return (
4665
+ mark('>') +
4666
+ aside(gutter) +
4667
+ highlight(line) +
4668
+ '\n ' +
4669
+ spacing +
4670
+ mark('^')
4671
+ )
4640
4672
  }
4641
- return ' ' + aside(gutter) + line
4673
+
4674
+ return ' ' + aside(gutter) + highlight(line)
4642
4675
  })
4643
4676
  .join('\n')
4644
4677
  }
@@ -4655,12 +4688,6 @@ class CssSyntaxError$3 extends Error {
4655
4688
  var cssSyntaxError = CssSyntaxError$3;
4656
4689
  CssSyntaxError$3.default = CssSyntaxError$3;
4657
4690
 
4658
- var symbols = {};
4659
-
4660
- symbols.isClean = Symbol('isClean');
4661
-
4662
- symbols.my = Symbol('my');
4663
-
4664
4691
  const DEFAULT_RAW = {
4665
4692
  after: '\n',
4666
4693
  beforeClose: '\n',
@@ -5023,10 +5050,16 @@ function stringify$4(node, builder) {
5023
5050
  var stringify_1 = stringify$4;
5024
5051
  stringify$4.default = stringify$4;
5025
5052
 
5026
- let { isClean: isClean$2, my: my$2 } = symbols;
5053
+ var symbols = {};
5054
+
5055
+ symbols.isClean = Symbol('isClean');
5056
+
5057
+ symbols.my = Symbol('my');
5058
+
5027
5059
  let CssSyntaxError$2 = cssSyntaxError;
5028
5060
  let Stringifier = stringifier;
5029
5061
  let stringify$3 = stringify_1;
5062
+ let { isClean: isClean$2, my: my$2 } = symbols;
5030
5063
 
5031
5064
  function cloneNode(obj, parent) {
5032
5065
  let cloned = new obj.constructor();
@@ -5055,6 +5088,36 @@ function cloneNode(obj, parent) {
5055
5088
  return cloned
5056
5089
  }
5057
5090
 
5091
+ function sourceOffset(inputCSS, position) {
5092
+ // Not all custom syntaxes support `offset` in `source.start` and `source.end`
5093
+ if (
5094
+ position &&
5095
+ typeof position.offset !== 'undefined'
5096
+ ) {
5097
+ return position.offset;
5098
+ }
5099
+
5100
+ let column = 1;
5101
+ let line = 1;
5102
+ let offset = 0;
5103
+
5104
+ for (let i = 0; i < inputCSS.length; i++) {
5105
+ if (line === position.line && column === position.column) {
5106
+ offset = i;
5107
+ break
5108
+ }
5109
+
5110
+ if (inputCSS[i] === '\n') {
5111
+ column = 1;
5112
+ line += 1;
5113
+ } else {
5114
+ column += 1;
5115
+ }
5116
+ }
5117
+
5118
+ return offset
5119
+ }
5120
+
5058
5121
  class Node$4 {
5059
5122
  constructor(defaults = {}) {
5060
5123
  this.raws = {};
@@ -5176,6 +5239,11 @@ class Node$4 {
5176
5239
  }
5177
5240
  }
5178
5241
 
5242
+ /* c8 ignore next 3 */
5243
+ markClean() {
5244
+ this[isClean$2] = true;
5245
+ }
5246
+
5179
5247
  markDirty() {
5180
5248
  if (this[isClean$2]) {
5181
5249
  this[isClean$2] = false;
@@ -5192,25 +5260,29 @@ class Node$4 {
5192
5260
  return this.parent.nodes[index + 1]
5193
5261
  }
5194
5262
 
5195
- positionBy(opts, stringRepresentation) {
5263
+ positionBy(opts) {
5196
5264
  let pos = this.source.start;
5197
5265
  if (opts.index) {
5198
- pos = this.positionInside(opts.index, stringRepresentation);
5266
+ pos = this.positionInside(opts.index);
5199
5267
  } else if (opts.word) {
5200
- stringRepresentation = this.toString();
5268
+ let stringRepresentation = this.source.input.css.slice(
5269
+ sourceOffset(this.source.input.css, this.source.start),
5270
+ sourceOffset(this.source.input.css, this.source.end)
5271
+ );
5201
5272
  let index = stringRepresentation.indexOf(opts.word);
5202
- if (index !== -1) pos = this.positionInside(index, stringRepresentation);
5273
+ if (index !== -1) pos = this.positionInside(index);
5203
5274
  }
5204
5275
  return pos
5205
5276
  }
5206
5277
 
5207
- positionInside(index, stringRepresentation) {
5208
- let string = stringRepresentation || this.toString();
5278
+ positionInside(index) {
5209
5279
  let column = this.source.start.column;
5210
5280
  let line = this.source.start.line;
5281
+ let offset = sourceOffset(this.source.input.css, this.source.start);
5282
+ let end = offset + index;
5211
5283
 
5212
- for (let i = 0; i < index; i++) {
5213
- if (string[i] === '\n') {
5284
+ for (let i = offset; i < end; i++) {
5285
+ if (this.source.input.css[i] === '\n') {
5214
5286
  column = 1;
5215
5287
  line += 1;
5216
5288
  } else {
@@ -5234,20 +5306,25 @@ class Node$4 {
5234
5306
  };
5235
5307
  let end = this.source.end
5236
5308
  ? {
5237
- column: this.source.end.column + 1,
5238
- line: this.source.end.line
5239
- }
5309
+ column: this.source.end.column + 1,
5310
+ line: this.source.end.line
5311
+ }
5240
5312
  : {
5241
- column: start.column + 1,
5242
- line: start.line
5243
- };
5313
+ column: start.column + 1,
5314
+ line: start.line
5315
+ };
5244
5316
 
5245
5317
  if (opts.word) {
5246
- let stringRepresentation = this.toString();
5318
+ let stringRepresentation = this.source.input.css.slice(
5319
+ sourceOffset(this.source.input.css, this.source.start),
5320
+ sourceOffset(this.source.input.css, this.source.end)
5321
+ );
5247
5322
  let index = stringRepresentation.indexOf(opts.word);
5248
5323
  if (index !== -1) {
5249
- start = this.positionInside(index, stringRepresentation);
5250
- end = this.positionInside(index + opts.word.length, stringRepresentation);
5324
+ start = this.positionInside(index);
5325
+ end = this.positionInside(
5326
+ index + opts.word.length,
5327
+ );
5251
5328
  }
5252
5329
  } else {
5253
5330
  if (opts.start) {
@@ -5405,7 +5482,19 @@ Node$4.default = Node$4;
5405
5482
 
5406
5483
  let Node$3 = node_1;
5407
5484
 
5408
- class Declaration$4 extends Node$3 {
5485
+ class Comment$4 extends Node$3 {
5486
+ constructor(defaults) {
5487
+ super(defaults);
5488
+ this.type = 'comment';
5489
+ }
5490
+ }
5491
+
5492
+ var comment = Comment$4;
5493
+ Comment$4.default = Comment$4;
5494
+
5495
+ let Node$2 = node_1;
5496
+
5497
+ class Declaration$4 extends Node$2 {
5409
5498
  constructor(defaults) {
5410
5499
  if (
5411
5500
  defaults &&
@@ -5426,1355 +5515,1488 @@ class Declaration$4 extends Node$3 {
5426
5515
  var declaration = Declaration$4;
5427
5516
  Declaration$4.default = Declaration$4;
5428
5517
 
5429
- let urlAlphabet =
5430
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
5431
- let customAlphabet = (alphabet, defaultSize = 21) => {
5432
- return (size = defaultSize) => {
5433
- let id = '';
5434
- let i = size;
5435
- while (i--) {
5436
- id += alphabet[(Math.random() * alphabet.length) | 0];
5437
- }
5438
- return id
5439
- }
5440
- };
5441
- let nanoid$1 = (size = 21) => {
5442
- let id = '';
5443
- let i = size;
5444
- while (i--) {
5445
- id += urlAlphabet[(Math.random() * 64) | 0];
5446
- }
5447
- return id
5448
- };
5449
-
5450
- const nonSecure = /*#__PURE__*/Object.freeze({
5451
- __proto__: null,
5452
- nanoid: nanoid$1,
5453
- customAlphabet: customAlphabet
5454
- });
5518
+ let Comment$3 = comment;
5519
+ let Declaration$3 = declaration;
5520
+ let Node$1 = node_1;
5521
+ let { isClean: isClean$1, my: my$1 } = symbols;
5455
5522
 
5456
- const require$$3 = /*@__PURE__*/getAugmentedNamespace(nonSecure);
5523
+ let AtRule$4, parse$4, Root$6, Rule$4;
5457
5524
 
5458
- let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
5459
- let { existsSync, readFileSync } = require$$2;
5460
- let { dirname: dirname$1, join } = require$$2;
5525
+ function cleanSource(nodes) {
5526
+ return nodes.map(i => {
5527
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
5528
+ delete i.source;
5529
+ return i
5530
+ })
5531
+ }
5461
5532
 
5462
- function fromBase64(str) {
5463
- if (Buffer) {
5464
- return Buffer.from(str, 'base64').toString()
5465
- } else {
5466
- /* c8 ignore next 2 */
5467
- return window.atob(str)
5533
+ function markTreeDirty(node) {
5534
+ node[isClean$1] = false;
5535
+ if (node.proxyOf.nodes) {
5536
+ for (let i of node.proxyOf.nodes) {
5537
+ markTreeDirty(i);
5538
+ }
5468
5539
  }
5469
5540
  }
5470
5541
 
5471
- class PreviousMap$2 {
5472
- constructor(css, opts) {
5473
- if (opts.map === false) return
5474
- this.loadAnnotation(css);
5475
- this.inline = this.startWith(this.annotation, 'data:');
5476
-
5477
- let prev = opts.map ? opts.map.prev : undefined;
5478
- let text = this.loadMap(opts.from, prev);
5479
- if (!this.mapFile && opts.from) {
5480
- this.mapFile = opts.from;
5542
+ class Container$7 extends Node$1 {
5543
+ append(...children) {
5544
+ for (let child of children) {
5545
+ let nodes = this.normalize(child, this.last);
5546
+ for (let node of nodes) this.proxyOf.nodes.push(node);
5481
5547
  }
5482
- if (this.mapFile) this.root = dirname$1(this.mapFile);
5483
- if (text) this.text = text;
5548
+
5549
+ this.markDirty();
5550
+
5551
+ return this
5484
5552
  }
5485
5553
 
5486
- consumer() {
5487
- if (!this.consumerCache) {
5488
- this.consumerCache = new SourceMapConsumer$2(this.text);
5554
+ cleanRaws(keepBetween) {
5555
+ super.cleanRaws(keepBetween);
5556
+ if (this.nodes) {
5557
+ for (let node of this.nodes) node.cleanRaws(keepBetween);
5489
5558
  }
5490
- return this.consumerCache
5491
5559
  }
5492
5560
 
5493
- decodeInline(text) {
5494
- let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
5495
- let baseUri = /^data:application\/json;base64,/;
5496
- let charsetUri = /^data:application\/json;charset=utf-?8,/;
5497
- let uri = /^data:application\/json,/;
5561
+ each(callback) {
5562
+ if (!this.proxyOf.nodes) return undefined
5563
+ let iterator = this.getIterator();
5498
5564
 
5499
- let uriMatch = text.match(charsetUri) || text.match(uri);
5500
- if (uriMatch) {
5501
- return decodeURIComponent(text.substr(uriMatch[0].length))
5502
- }
5565
+ let index, result;
5566
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
5567
+ index = this.indexes[iterator];
5568
+ result = callback(this.proxyOf.nodes[index], index);
5569
+ if (result === false) break
5503
5570
 
5504
- let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
5505
- if (baseUriMatch) {
5506
- return fromBase64(text.substr(baseUriMatch[0].length))
5571
+ this.indexes[iterator] += 1;
5507
5572
  }
5508
5573
 
5509
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
5510
- throw new Error('Unsupported source map encoding ' + encoding)
5574
+ delete this.indexes[iterator];
5575
+ return result
5511
5576
  }
5512
5577
 
5513
- getAnnotationURL(sourceMapString) {
5514
- return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
5578
+ every(condition) {
5579
+ return this.nodes.every(condition)
5515
5580
  }
5516
5581
 
5517
- isMap(map) {
5518
- if (typeof map !== 'object') return false
5519
- return (
5520
- typeof map.mappings === 'string' ||
5521
- typeof map._mappings === 'string' ||
5522
- Array.isArray(map.sections)
5523
- )
5524
- }
5582
+ getIterator() {
5583
+ if (!this.lastEach) this.lastEach = 0;
5584
+ if (!this.indexes) this.indexes = {};
5525
5585
 
5526
- loadAnnotation(css) {
5527
- let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
5528
- if (!comments) return
5586
+ this.lastEach += 1;
5587
+ let iterator = this.lastEach;
5588
+ this.indexes[iterator] = 0;
5529
5589
 
5530
- // sourceMappingURLs from comments, strings, etc.
5531
- let start = css.lastIndexOf(comments.pop());
5532
- let end = css.indexOf('*/', start);
5590
+ return iterator
5591
+ }
5533
5592
 
5534
- if (start > -1 && end > -1) {
5535
- // Locate the last sourceMappingURL to avoid pickin
5536
- this.annotation = this.getAnnotationURL(css.substring(start, end));
5593
+ getProxyProcessor() {
5594
+ return {
5595
+ get(node, prop) {
5596
+ if (prop === 'proxyOf') {
5597
+ return node
5598
+ } else if (!node[prop]) {
5599
+ return node[prop]
5600
+ } else if (
5601
+ prop === 'each' ||
5602
+ (typeof prop === 'string' && prop.startsWith('walk'))
5603
+ ) {
5604
+ return (...args) => {
5605
+ return node[prop](
5606
+ ...args.map(i => {
5607
+ if (typeof i === 'function') {
5608
+ return (child, index) => i(child.toProxy(), index)
5609
+ } else {
5610
+ return i
5611
+ }
5612
+ })
5613
+ )
5614
+ }
5615
+ } else if (prop === 'every' || prop === 'some') {
5616
+ return cb => {
5617
+ return node[prop]((child, ...other) =>
5618
+ cb(child.toProxy(), ...other)
5619
+ )
5620
+ }
5621
+ } else if (prop === 'root') {
5622
+ return () => node.root().toProxy()
5623
+ } else if (prop === 'nodes') {
5624
+ return node.nodes.map(i => i.toProxy())
5625
+ } else if (prop === 'first' || prop === 'last') {
5626
+ return node[prop].toProxy()
5627
+ } else {
5628
+ return node[prop]
5629
+ }
5630
+ },
5631
+
5632
+ set(node, prop, value) {
5633
+ if (node[prop] === value) return true
5634
+ node[prop] = value;
5635
+ if (prop === 'name' || prop === 'params' || prop === 'selector') {
5636
+ node.markDirty();
5637
+ }
5638
+ return true
5639
+ }
5537
5640
  }
5538
5641
  }
5539
5642
 
5540
- loadFile(path) {
5541
- this.root = dirname$1(path);
5542
- if (existsSync(path)) {
5543
- this.mapFile = path;
5544
- return readFileSync(path, 'utf-8').toString().trim()
5545
- }
5643
+ index(child) {
5644
+ if (typeof child === 'number') return child
5645
+ if (child.proxyOf) child = child.proxyOf;
5646
+ return this.proxyOf.nodes.indexOf(child)
5546
5647
  }
5547
5648
 
5548
- loadMap(file, prev) {
5549
- if (prev === false) return false
5649
+ insertAfter(exist, add) {
5650
+ let existIndex = this.index(exist);
5651
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
5652
+ existIndex = this.index(exist);
5653
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
5550
5654
 
5551
- if (prev) {
5552
- if (typeof prev === 'string') {
5553
- return prev
5554
- } else if (typeof prev === 'function') {
5555
- let prevPath = prev(file);
5556
- if (prevPath) {
5557
- let map = this.loadFile(prevPath);
5558
- if (!map) {
5559
- throw new Error(
5560
- 'Unable to load previous source map: ' + prevPath.toString()
5561
- )
5562
- }
5563
- return map
5564
- }
5565
- } else if (prev instanceof SourceMapConsumer$2) {
5566
- return SourceMapGenerator$2.fromSourceMap(prev).toString()
5567
- } else if (prev instanceof SourceMapGenerator$2) {
5568
- return prev.toString()
5569
- } else if (this.isMap(prev)) {
5570
- return JSON.stringify(prev)
5571
- } else {
5572
- throw new Error(
5573
- 'Unsupported previous source map format: ' + prev.toString()
5574
- )
5655
+ let index;
5656
+ for (let id in this.indexes) {
5657
+ index = this.indexes[id];
5658
+ if (existIndex < index) {
5659
+ this.indexes[id] = index + nodes.length;
5575
5660
  }
5576
- } else if (this.inline) {
5577
- return this.decodeInline(this.annotation)
5578
- } else if (this.annotation) {
5579
- let map = this.annotation;
5580
- if (file) map = join(dirname$1(file), map);
5581
- return this.loadFile(map)
5582
5661
  }
5583
- }
5584
5662
 
5585
- startWith(string, start) {
5586
- if (!string) return false
5587
- return string.substr(0, start.length) === start
5588
- }
5663
+ this.markDirty();
5589
5664
 
5590
- withContent() {
5591
- return !!(
5592
- this.consumer().sourcesContent &&
5593
- this.consumer().sourcesContent.length > 0
5594
- )
5665
+ return this
5595
5666
  }
5596
- }
5597
-
5598
- var previousMap = PreviousMap$2;
5599
- PreviousMap$2.default = PreviousMap$2;
5600
-
5601
- let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
5602
- let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
5603
- let { isAbsolute, resolve: resolve$1 } = require$$2;
5604
- let { nanoid } = require$$3;
5605
-
5606
- let terminalHighlight = require$$2;
5607
- let CssSyntaxError$1 = cssSyntaxError;
5608
- let PreviousMap$1 = previousMap;
5609
-
5610
- let fromOffsetCache = Symbol('fromOffsetCache');
5611
5667
 
5612
- let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
5613
- let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
5668
+ insertBefore(exist, add) {
5669
+ let existIndex = this.index(exist);
5670
+ let type = existIndex === 0 ? 'prepend' : false;
5671
+ let nodes = this.normalize(
5672
+ add,
5673
+ this.proxyOf.nodes[existIndex],
5674
+ type
5675
+ ).reverse();
5676
+ existIndex = this.index(exist);
5677
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
5614
5678
 
5615
- class Input$4 {
5616
- constructor(css, opts = {}) {
5617
- if (
5618
- css === null ||
5619
- typeof css === 'undefined' ||
5620
- (typeof css === 'object' && !css.toString)
5621
- ) {
5622
- throw new Error(`PostCSS received ${css} instead of CSS string`)
5679
+ let index;
5680
+ for (let id in this.indexes) {
5681
+ index = this.indexes[id];
5682
+ if (existIndex <= index) {
5683
+ this.indexes[id] = index + nodes.length;
5684
+ }
5623
5685
  }
5624
5686
 
5625
- this.css = css.toString();
5687
+ this.markDirty();
5626
5688
 
5627
- if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
5628
- this.hasBOM = true;
5629
- this.css = this.css.slice(1);
5630
- } else {
5631
- this.hasBOM = false;
5632
- }
5689
+ return this
5690
+ }
5633
5691
 
5634
- if (opts.from) {
5635
- if (
5636
- !pathAvailable$1 ||
5637
- /^\w+:\/\//.test(opts.from) ||
5638
- isAbsolute(opts.from)
5639
- ) {
5640
- this.file = opts.from;
5641
- } else {
5642
- this.file = resolve$1(opts.from);
5692
+ normalize(nodes, sample) {
5693
+ if (typeof nodes === 'string') {
5694
+ nodes = cleanSource(parse$4(nodes).nodes);
5695
+ } else if (typeof nodes === 'undefined') {
5696
+ nodes = [];
5697
+ } else if (Array.isArray(nodes)) {
5698
+ nodes = nodes.slice(0);
5699
+ for (let i of nodes) {
5700
+ if (i.parent) i.parent.removeChild(i, 'ignore');
5701
+ }
5702
+ } else if (nodes.type === 'root' && this.type !== 'document') {
5703
+ nodes = nodes.nodes.slice(0);
5704
+ for (let i of nodes) {
5705
+ if (i.parent) i.parent.removeChild(i, 'ignore');
5706
+ }
5707
+ } else if (nodes.type) {
5708
+ nodes = [nodes];
5709
+ } else if (nodes.prop) {
5710
+ if (typeof nodes.value === 'undefined') {
5711
+ throw new Error('Value field is missed in node creation')
5712
+ } else if (typeof nodes.value !== 'string') {
5713
+ nodes.value = String(nodes.value);
5643
5714
  }
5715
+ nodes = [new Declaration$3(nodes)];
5716
+ } else if (nodes.selector || nodes.selectors) {
5717
+ nodes = [new Rule$4(nodes)];
5718
+ } else if (nodes.name) {
5719
+ nodes = [new AtRule$4(nodes)];
5720
+ } else if (nodes.text) {
5721
+ nodes = [new Comment$3(nodes)];
5722
+ } else {
5723
+ throw new Error('Unknown node type in node creation')
5644
5724
  }
5645
5725
 
5646
- if (pathAvailable$1 && sourceMapAvailable$1) {
5647
- let map = new PreviousMap$1(this.css, opts);
5648
- if (map.text) {
5649
- this.map = map;
5650
- let file = map.consumer().file;
5651
- if (!this.file && file) this.file = this.mapResolve(file);
5726
+ let processed = nodes.map(i => {
5727
+ /* c8 ignore next */
5728
+ if (!i[my$1]) Container$7.rebuild(i);
5729
+ i = i.proxyOf;
5730
+ if (i.parent) i.parent.removeChild(i);
5731
+ if (i[isClean$1]) markTreeDirty(i);
5732
+
5733
+ if (!i.raws) i.raws = {};
5734
+ if (typeof i.raws.before === 'undefined') {
5735
+ if (sample && typeof sample.raws.before !== 'undefined') {
5736
+ i.raws.before = sample.raws.before.replace(/\S/g, '');
5737
+ }
5652
5738
  }
5653
- }
5739
+ i.parent = this.proxyOf;
5740
+ return i
5741
+ });
5654
5742
 
5655
- if (!this.file) {
5656
- this.id = '<input css ' + nanoid(6) + '>';
5657
- }
5658
- if (this.map) this.map.file = this.from;
5743
+ return processed
5659
5744
  }
5660
5745
 
5661
- error(message, line, column, opts = {}) {
5662
- let result, endLine, endColumn;
5663
-
5664
- if (line && typeof line === 'object') {
5665
- let start = line;
5666
- let end = column;
5667
- if (typeof start.offset === 'number') {
5668
- let pos = this.fromOffset(start.offset);
5669
- line = pos.line;
5670
- column = pos.col;
5671
- } else {
5672
- line = start.line;
5673
- column = start.column;
5674
- }
5675
- if (typeof end.offset === 'number') {
5676
- let pos = this.fromOffset(end.offset);
5677
- endLine = pos.line;
5678
- endColumn = pos.col;
5679
- } else {
5680
- endLine = end.line;
5681
- endColumn = end.column;
5746
+ prepend(...children) {
5747
+ children = children.reverse();
5748
+ for (let child of children) {
5749
+ let nodes = this.normalize(child, this.first, 'prepend').reverse();
5750
+ for (let node of nodes) this.proxyOf.nodes.unshift(node);
5751
+ for (let id in this.indexes) {
5752
+ this.indexes[id] = this.indexes[id] + nodes.length;
5682
5753
  }
5683
- } else if (!column) {
5684
- let pos = this.fromOffset(line);
5685
- line = pos.line;
5686
- column = pos.col;
5687
5754
  }
5688
5755
 
5689
- let origin = this.origin(line, column, endLine, endColumn);
5690
- if (origin) {
5691
- result = new CssSyntaxError$1(
5692
- message,
5693
- origin.endLine === undefined
5694
- ? origin.line
5695
- : { column: origin.column, line: origin.line },
5696
- origin.endLine === undefined
5697
- ? origin.column
5698
- : { column: origin.endColumn, line: origin.endLine },
5699
- origin.source,
5700
- origin.file,
5701
- opts.plugin
5702
- );
5703
- } else {
5704
- result = new CssSyntaxError$1(
5705
- message,
5706
- endLine === undefined ? line : { column, line },
5707
- endLine === undefined ? column : { column: endColumn, line: endLine },
5708
- this.css,
5709
- this.file,
5710
- opts.plugin
5711
- );
5712
- }
5756
+ this.markDirty();
5713
5757
 
5714
- result.input = { column, endColumn, endLine, line, source: this.css };
5715
- if (this.file) {
5716
- if (pathToFileURL$1) {
5717
- result.input.url = pathToFileURL$1(this.file).toString();
5718
- }
5719
- result.input.file = this.file;
5720
- }
5758
+ return this
5759
+ }
5721
5760
 
5722
- return result
5761
+ push(child) {
5762
+ child.parent = this;
5763
+ this.proxyOf.nodes.push(child);
5764
+ return this
5723
5765
  }
5724
5766
 
5725
- fromOffset(offset) {
5726
- let lastLine, lineToIndex;
5727
- if (!this[fromOffsetCache]) {
5728
- let lines = this.css.split('\n');
5729
- lineToIndex = new Array(lines.length);
5730
- let prevIndex = 0;
5767
+ removeAll() {
5768
+ for (let node of this.proxyOf.nodes) node.parent = undefined;
5769
+ this.proxyOf.nodes = [];
5731
5770
 
5732
- for (let i = 0, l = lines.length; i < l; i++) {
5733
- lineToIndex[i] = prevIndex;
5734
- prevIndex += lines[i].length + 1;
5735
- }
5771
+ this.markDirty();
5736
5772
 
5737
- this[fromOffsetCache] = lineToIndex;
5738
- } else {
5739
- lineToIndex = this[fromOffsetCache];
5740
- }
5741
- lastLine = lineToIndex[lineToIndex.length - 1];
5773
+ return this
5774
+ }
5742
5775
 
5743
- let min = 0;
5744
- if (offset >= lastLine) {
5745
- min = lineToIndex.length - 1;
5746
- } else {
5747
- let max = lineToIndex.length - 2;
5748
- let mid;
5749
- while (min < max) {
5750
- mid = min + ((max - min) >> 1);
5751
- if (offset < lineToIndex[mid]) {
5752
- max = mid - 1;
5753
- } else if (offset >= lineToIndex[mid + 1]) {
5754
- min = mid + 1;
5755
- } else {
5756
- min = mid;
5757
- break
5758
- }
5776
+ removeChild(child) {
5777
+ child = this.index(child);
5778
+ this.proxyOf.nodes[child].parent = undefined;
5779
+ this.proxyOf.nodes.splice(child, 1);
5780
+
5781
+ let index;
5782
+ for (let id in this.indexes) {
5783
+ index = this.indexes[id];
5784
+ if (index >= child) {
5785
+ this.indexes[id] = index - 1;
5759
5786
  }
5760
5787
  }
5761
- return {
5762
- col: offset - lineToIndex[min] + 1,
5763
- line: min + 1
5764
- }
5765
- }
5766
5788
 
5767
- mapResolve(file) {
5768
- if (/^\w+:\/\//.test(file)) {
5769
- return file
5770
- }
5771
- return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
5789
+ this.markDirty();
5790
+
5791
+ return this
5772
5792
  }
5773
5793
 
5774
- origin(line, column, endLine, endColumn) {
5775
- if (!this.map) return false
5776
- let consumer = this.map.consumer();
5794
+ replaceValues(pattern, opts, callback) {
5795
+ if (!callback) {
5796
+ callback = opts;
5797
+ opts = {};
5798
+ }
5777
5799
 
5778
- let from = consumer.originalPositionFor({ column, line });
5779
- if (!from.source) return false
5800
+ this.walkDecls(decl => {
5801
+ if (opts.props && !opts.props.includes(decl.prop)) return
5802
+ if (opts.fast && !decl.value.includes(opts.fast)) return
5780
5803
 
5781
- let to;
5782
- if (typeof endLine === 'number') {
5783
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
5784
- }
5804
+ decl.value = decl.value.replace(pattern, callback);
5805
+ });
5785
5806
 
5786
- let fromUrl;
5807
+ this.markDirty();
5787
5808
 
5788
- if (isAbsolute(from.source)) {
5789
- fromUrl = pathToFileURL$1(from.source);
5790
- } else {
5791
- fromUrl = new URL(
5792
- from.source,
5793
- this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
5794
- );
5795
- }
5809
+ return this
5810
+ }
5796
5811
 
5797
- let result = {
5798
- column: from.column,
5799
- endColumn: to && to.column,
5800
- endLine: to && to.line,
5801
- line: from.line,
5802
- url: fromUrl.toString()
5803
- };
5812
+ some(condition) {
5813
+ return this.nodes.some(condition)
5814
+ }
5804
5815
 
5805
- if (fromUrl.protocol === 'file:') {
5806
- if (fileURLToPath) {
5807
- result.file = fileURLToPath(fromUrl);
5808
- } else {
5809
- /* c8 ignore next 2 */
5810
- throw new Error(`file: protocol is not available in this PostCSS build`)
5816
+ walk(callback) {
5817
+ return this.each((child, i) => {
5818
+ let result;
5819
+ try {
5820
+ result = callback(child, i);
5821
+ } catch (e) {
5822
+ throw child.addToError(e)
5823
+ }
5824
+ if (result !== false && child.walk) {
5825
+ result = child.walk(callback);
5811
5826
  }
5812
- }
5813
5827
 
5814
- let source = consumer.sourceContentFor(from.source);
5815
- if (source) result.source = source;
5828
+ return result
5829
+ })
5830
+ }
5816
5831
 
5817
- return result
5832
+ walkAtRules(name, callback) {
5833
+ if (!callback) {
5834
+ callback = name;
5835
+ return this.walk((child, i) => {
5836
+ if (child.type === 'atrule') {
5837
+ return callback(child, i)
5838
+ }
5839
+ })
5840
+ }
5841
+ if (name instanceof RegExp) {
5842
+ return this.walk((child, i) => {
5843
+ if (child.type === 'atrule' && name.test(child.name)) {
5844
+ return callback(child, i)
5845
+ }
5846
+ })
5847
+ }
5848
+ return this.walk((child, i) => {
5849
+ if (child.type === 'atrule' && child.name === name) {
5850
+ return callback(child, i)
5851
+ }
5852
+ })
5818
5853
  }
5819
5854
 
5820
- toJSON() {
5821
- let json = {};
5822
- for (let name of ['hasBOM', 'css', 'file', 'id']) {
5823
- if (this[name] != null) {
5824
- json[name] = this[name];
5855
+ walkComments(callback) {
5856
+ return this.walk((child, i) => {
5857
+ if (child.type === 'comment') {
5858
+ return callback(child, i)
5825
5859
  }
5860
+ })
5861
+ }
5862
+
5863
+ walkDecls(prop, callback) {
5864
+ if (!callback) {
5865
+ callback = prop;
5866
+ return this.walk((child, i) => {
5867
+ if (child.type === 'decl') {
5868
+ return callback(child, i)
5869
+ }
5870
+ })
5826
5871
  }
5827
- if (this.map) {
5828
- json.map = { ...this.map };
5829
- if (json.map.consumerCache) {
5830
- json.map.consumerCache = undefined;
5831
- }
5872
+ if (prop instanceof RegExp) {
5873
+ return this.walk((child, i) => {
5874
+ if (child.type === 'decl' && prop.test(child.prop)) {
5875
+ return callback(child, i)
5876
+ }
5877
+ })
5832
5878
  }
5833
- return json
5879
+ return this.walk((child, i) => {
5880
+ if (child.type === 'decl' && child.prop === prop) {
5881
+ return callback(child, i)
5882
+ }
5883
+ })
5834
5884
  }
5835
5885
 
5836
- get from() {
5837
- return this.file || this.id
5886
+ walkRules(selector, callback) {
5887
+ if (!callback) {
5888
+ callback = selector;
5889
+
5890
+ return this.walk((child, i) => {
5891
+ if (child.type === 'rule') {
5892
+ return callback(child, i)
5893
+ }
5894
+ })
5895
+ }
5896
+ if (selector instanceof RegExp) {
5897
+ return this.walk((child, i) => {
5898
+ if (child.type === 'rule' && selector.test(child.selector)) {
5899
+ return callback(child, i)
5900
+ }
5901
+ })
5902
+ }
5903
+ return this.walk((child, i) => {
5904
+ if (child.type === 'rule' && child.selector === selector) {
5905
+ return callback(child, i)
5906
+ }
5907
+ })
5838
5908
  }
5839
- }
5840
5909
 
5841
- var input = Input$4;
5842
- Input$4.default = Input$4;
5910
+ get first() {
5911
+ if (!this.proxyOf.nodes) return undefined
5912
+ return this.proxyOf.nodes[0]
5913
+ }
5843
5914
 
5844
- if (terminalHighlight && terminalHighlight.registerInput) {
5845
- terminalHighlight.registerInput(Input$4);
5915
+ get last() {
5916
+ if (!this.proxyOf.nodes) return undefined
5917
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
5918
+ }
5846
5919
  }
5847
5920
 
5848
- let { SourceMapConsumer, SourceMapGenerator } = require$$2;
5849
- let { dirname, relative, resolve, sep } = require$$2;
5850
- let { pathToFileURL } = require$$2;
5921
+ Container$7.registerParse = dependant => {
5922
+ parse$4 = dependant;
5923
+ };
5851
5924
 
5852
- let Input$3 = input;
5925
+ Container$7.registerRule = dependant => {
5926
+ Rule$4 = dependant;
5927
+ };
5853
5928
 
5854
- let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
5855
- let pathAvailable = Boolean(dirname && resolve && relative && sep);
5929
+ Container$7.registerAtRule = dependant => {
5930
+ AtRule$4 = dependant;
5931
+ };
5856
5932
 
5857
- class MapGenerator$2 {
5858
- constructor(stringify, root, opts, cssString) {
5859
- this.stringify = stringify;
5860
- this.mapOpts = opts.map || {};
5861
- this.root = root;
5862
- this.opts = opts;
5863
- this.css = cssString;
5864
- this.originalCSS = cssString;
5865
- this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
5933
+ Container$7.registerRoot = dependant => {
5934
+ Root$6 = dependant;
5935
+ };
5866
5936
 
5867
- this.memoizedFileURLs = new Map();
5868
- this.memoizedPaths = new Map();
5869
- this.memoizedURLs = new Map();
5937
+ var container = Container$7;
5938
+ Container$7.default = Container$7;
5939
+
5940
+ /* c8 ignore start */
5941
+ Container$7.rebuild = node => {
5942
+ if (node.type === 'atrule') {
5943
+ Object.setPrototypeOf(node, AtRule$4.prototype);
5944
+ } else if (node.type === 'rule') {
5945
+ Object.setPrototypeOf(node, Rule$4.prototype);
5946
+ } else if (node.type === 'decl') {
5947
+ Object.setPrototypeOf(node, Declaration$3.prototype);
5948
+ } else if (node.type === 'comment') {
5949
+ Object.setPrototypeOf(node, Comment$3.prototype);
5950
+ } else if (node.type === 'root') {
5951
+ Object.setPrototypeOf(node, Root$6.prototype);
5870
5952
  }
5871
5953
 
5872
- addAnnotation() {
5873
- let content;
5954
+ node[my$1] = true;
5874
5955
 
5875
- if (this.isInline()) {
5876
- content =
5877
- 'data:application/json;base64,' + this.toBase64(this.map.toString());
5878
- } else if (typeof this.mapOpts.annotation === 'string') {
5879
- content = this.mapOpts.annotation;
5880
- } else if (typeof this.mapOpts.annotation === 'function') {
5881
- content = this.mapOpts.annotation(this.opts.to, this.root);
5882
- } else {
5883
- content = this.outputFile() + '.map';
5884
- }
5885
- let eol = '\n';
5886
- if (this.css.includes('\r\n')) eol = '\r\n';
5956
+ if (node.nodes) {
5957
+ node.nodes.forEach(child => {
5958
+ Container$7.rebuild(child);
5959
+ });
5960
+ }
5961
+ };
5887
5962
 
5888
- this.css += eol + '/*# sourceMappingURL=' + content + ' */';
5963
+ let Container$6 = container;
5964
+
5965
+ class AtRule$3 extends Container$6 {
5966
+ constructor(defaults) {
5967
+ super(defaults);
5968
+ this.type = 'atrule';
5889
5969
  }
5890
5970
 
5891
- applyPrevMaps() {
5892
- for (let prev of this.previous()) {
5893
- let from = this.toUrl(this.path(prev.file));
5894
- let root = prev.root || dirname(prev.file);
5895
- let map;
5971
+ append(...children) {
5972
+ if (!this.proxyOf.nodes) this.nodes = [];
5973
+ return super.append(...children)
5974
+ }
5896
5975
 
5897
- if (this.mapOpts.sourcesContent === false) {
5898
- map = new SourceMapConsumer(prev.text);
5899
- if (map.sourcesContent) {
5900
- map.sourcesContent = null;
5901
- }
5902
- } else {
5903
- map = prev.consumer();
5904
- }
5976
+ prepend(...children) {
5977
+ if (!this.proxyOf.nodes) this.nodes = [];
5978
+ return super.prepend(...children)
5979
+ }
5980
+ }
5905
5981
 
5906
- this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
5982
+ var atRule = AtRule$3;
5983
+ AtRule$3.default = AtRule$3;
5984
+
5985
+ Container$6.registerAtRule(AtRule$3);
5986
+
5987
+ let Container$5 = container;
5988
+
5989
+ let LazyResult$4, Processor$3;
5990
+
5991
+ class Document$3 extends Container$5 {
5992
+ constructor(defaults) {
5993
+ // type needs to be passed to super, otherwise child roots won't be normalized correctly
5994
+ super({ type: 'document', ...defaults });
5995
+
5996
+ if (!this.nodes) {
5997
+ this.nodes = [];
5907
5998
  }
5908
5999
  }
5909
6000
 
5910
- clearAnnotation() {
5911
- if (this.mapOpts.annotation === false) return
6001
+ toResult(opts = {}) {
6002
+ let lazy = new LazyResult$4(new Processor$3(), this, opts);
5912
6003
 
5913
- if (this.root) {
5914
- let node;
5915
- for (let i = this.root.nodes.length - 1; i >= 0; i--) {
5916
- node = this.root.nodes[i];
5917
- if (node.type !== 'comment') continue
5918
- if (node.text.indexOf('# sourceMappingURL=') === 0) {
5919
- this.root.removeChild(i);
5920
- }
5921
- }
5922
- } else if (this.css) {
5923
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
6004
+ return lazy.stringify()
6005
+ }
6006
+ }
6007
+
6008
+ Document$3.registerLazyResult = dependant => {
6009
+ LazyResult$4 = dependant;
6010
+ };
6011
+
6012
+ Document$3.registerProcessor = dependant => {
6013
+ Processor$3 = dependant;
6014
+ };
6015
+
6016
+ var document = Document$3;
6017
+ Document$3.default = Document$3;
6018
+
6019
+ let urlAlphabet =
6020
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
6021
+ let customAlphabet = (alphabet, defaultSize = 21) => {
6022
+ return (size = defaultSize) => {
6023
+ let id = '';
6024
+ let i = size;
6025
+ while (i--) {
6026
+ id += alphabet[(Math.random() * alphabet.length) | 0];
5924
6027
  }
6028
+ return id
5925
6029
  }
6030
+ };
6031
+ let nanoid$1 = (size = 21) => {
6032
+ let id = '';
6033
+ let i = size;
6034
+ while (i--) {
6035
+ id += urlAlphabet[(Math.random() * 64) | 0];
6036
+ }
6037
+ return id
6038
+ };
5926
6039
 
5927
- generate() {
5928
- this.clearAnnotation();
5929
- if (pathAvailable && sourceMapAvailable && this.isMap()) {
5930
- return this.generateMap()
5931
- } else {
5932
- let result = '';
5933
- this.stringify(this.root, i => {
5934
- result += i;
5935
- });
5936
- return [result]
6040
+ const nonSecure = /*#__PURE__*/Object.freeze({
6041
+ __proto__: null,
6042
+ nanoid: nanoid$1,
6043
+ customAlphabet: customAlphabet
6044
+ });
6045
+
6046
+ const require$$0 = /*@__PURE__*/getAugmentedNamespace(nonSecure);
6047
+
6048
+ let { existsSync, readFileSync } = require$$2;
6049
+ let { dirname: dirname$1, join } = require$$2;
6050
+ let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
6051
+
6052
+ function fromBase64(str) {
6053
+ if (Buffer) {
6054
+ return Buffer.from(str, 'base64').toString()
6055
+ } else {
6056
+ /* c8 ignore next 2 */
6057
+ return window.atob(str)
6058
+ }
6059
+ }
6060
+
6061
+ class PreviousMap$2 {
6062
+ constructor(css, opts) {
6063
+ if (opts.map === false) return
6064
+ this.loadAnnotation(css);
6065
+ this.inline = this.startWith(this.annotation, 'data:');
6066
+
6067
+ let prev = opts.map ? opts.map.prev : undefined;
6068
+ let text = this.loadMap(opts.from, prev);
6069
+ if (!this.mapFile && opts.from) {
6070
+ this.mapFile = opts.from;
5937
6071
  }
6072
+ if (this.mapFile) this.root = dirname$1(this.mapFile);
6073
+ if (text) this.text = text;
5938
6074
  }
5939
6075
 
5940
- generateMap() {
5941
- if (this.root) {
5942
- this.generateString();
5943
- } else if (this.previous().length === 1) {
5944
- let prev = this.previous()[0].consumer();
5945
- prev.file = this.outputFile();
5946
- this.map = SourceMapGenerator.fromSourceMap(prev, {
5947
- ignoreInvalidMapping: true
5948
- });
5949
- } else {
5950
- this.map = new SourceMapGenerator({
5951
- file: this.outputFile(),
5952
- ignoreInvalidMapping: true
5953
- });
5954
- this.map.addMapping({
5955
- generated: { column: 0, line: 1 },
5956
- original: { column: 0, line: 1 },
5957
- source: this.opts.from
5958
- ? this.toUrl(this.path(this.opts.from))
5959
- : '<no source>'
5960
- });
6076
+ consumer() {
6077
+ if (!this.consumerCache) {
6078
+ this.consumerCache = new SourceMapConsumer$2(this.text);
5961
6079
  }
6080
+ return this.consumerCache
6081
+ }
5962
6082
 
5963
- if (this.isSourcesContent()) this.setSourcesContent();
5964
- if (this.root && this.previous().length > 0) this.applyPrevMaps();
5965
- if (this.isAnnotation()) this.addAnnotation();
6083
+ decodeInline(text) {
6084
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
6085
+ let baseUri = /^data:application\/json;base64,/;
6086
+ let charsetUri = /^data:application\/json;charset=utf-?8,/;
6087
+ let uri = /^data:application\/json,/;
5966
6088
 
5967
- if (this.isInline()) {
5968
- return [this.css]
5969
- } else {
5970
- return [this.css, this.map]
6089
+ let uriMatch = text.match(charsetUri) || text.match(uri);
6090
+ if (uriMatch) {
6091
+ return decodeURIComponent(text.substr(uriMatch[0].length))
6092
+ }
6093
+
6094
+ let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
6095
+ if (baseUriMatch) {
6096
+ return fromBase64(text.substr(baseUriMatch[0].length))
5971
6097
  }
6098
+
6099
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
6100
+ throw new Error('Unsupported source map encoding ' + encoding)
5972
6101
  }
5973
6102
 
5974
- generateString() {
5975
- this.css = '';
5976
- this.map = new SourceMapGenerator({
5977
- file: this.outputFile(),
5978
- ignoreInvalidMapping: true
5979
- });
6103
+ getAnnotationURL(sourceMapString) {
6104
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
6105
+ }
5980
6106
 
5981
- let line = 1;
5982
- let column = 1;
6107
+ isMap(map) {
6108
+ if (typeof map !== 'object') return false
6109
+ return (
6110
+ typeof map.mappings === 'string' ||
6111
+ typeof map._mappings === 'string' ||
6112
+ Array.isArray(map.sections)
6113
+ )
6114
+ }
5983
6115
 
5984
- let noSource = '<no source>';
5985
- let mapping = {
5986
- generated: { column: 0, line: 0 },
5987
- original: { column: 0, line: 0 },
5988
- source: ''
5989
- };
6116
+ loadAnnotation(css) {
6117
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
6118
+ if (!comments) return
5990
6119
 
5991
- let lines, last;
5992
- this.stringify(this.root, (str, node, type) => {
5993
- this.css += str;
6120
+ // sourceMappingURLs from comments, strings, etc.
6121
+ let start = css.lastIndexOf(comments.pop());
6122
+ let end = css.indexOf('*/', start);
5994
6123
 
5995
- if (node && type !== 'end') {
5996
- mapping.generated.line = line;
5997
- mapping.generated.column = column - 1;
5998
- if (node.source && node.source.start) {
5999
- mapping.source = this.sourcePath(node);
6000
- mapping.original.line = node.source.start.line;
6001
- mapping.original.column = node.source.start.column - 1;
6002
- this.map.addMapping(mapping);
6003
- } else {
6004
- mapping.source = noSource;
6005
- mapping.original.line = 1;
6006
- mapping.original.column = 0;
6007
- this.map.addMapping(mapping);
6008
- }
6009
- }
6124
+ if (start > -1 && end > -1) {
6125
+ // Locate the last sourceMappingURL to avoid pickin
6126
+ this.annotation = this.getAnnotationURL(css.substring(start, end));
6127
+ }
6128
+ }
6010
6129
 
6011
- lines = str.match(/\n/g);
6012
- if (lines) {
6013
- line += lines.length;
6014
- last = str.lastIndexOf('\n');
6015
- column = str.length - last;
6016
- } else {
6017
- column += str.length;
6018
- }
6130
+ loadFile(path) {
6131
+ this.root = dirname$1(path);
6132
+ if (existsSync(path)) {
6133
+ this.mapFile = path;
6134
+ return readFileSync(path, 'utf-8').toString().trim()
6135
+ }
6136
+ }
6019
6137
 
6020
- if (node && type !== 'start') {
6021
- let p = node.parent || { raws: {} };
6022
- let childless =
6023
- node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
6024
- if (!childless || node !== p.last || p.raws.semicolon) {
6025
- if (node.source && node.source.end) {
6026
- mapping.source = this.sourcePath(node);
6027
- mapping.original.line = node.source.end.line;
6028
- mapping.original.column = node.source.end.column - 1;
6029
- mapping.generated.line = line;
6030
- mapping.generated.column = column - 2;
6031
- this.map.addMapping(mapping);
6032
- } else {
6033
- mapping.source = noSource;
6034
- mapping.original.line = 1;
6035
- mapping.original.column = 0;
6036
- mapping.generated.line = line;
6037
- mapping.generated.column = column - 1;
6038
- this.map.addMapping(mapping);
6138
+ loadMap(file, prev) {
6139
+ if (prev === false) return false
6140
+
6141
+ if (prev) {
6142
+ if (typeof prev === 'string') {
6143
+ return prev
6144
+ } else if (typeof prev === 'function') {
6145
+ let prevPath = prev(file);
6146
+ if (prevPath) {
6147
+ let map = this.loadFile(prevPath);
6148
+ if (!map) {
6149
+ throw new Error(
6150
+ 'Unable to load previous source map: ' + prevPath.toString()
6151
+ )
6039
6152
  }
6153
+ return map
6040
6154
  }
6155
+ } else if (prev instanceof SourceMapConsumer$2) {
6156
+ return SourceMapGenerator$2.fromSourceMap(prev).toString()
6157
+ } else if (prev instanceof SourceMapGenerator$2) {
6158
+ return prev.toString()
6159
+ } else if (this.isMap(prev)) {
6160
+ return JSON.stringify(prev)
6161
+ } else {
6162
+ throw new Error(
6163
+ 'Unsupported previous source map format: ' + prev.toString()
6164
+ )
6041
6165
  }
6042
- });
6166
+ } else if (this.inline) {
6167
+ return this.decodeInline(this.annotation)
6168
+ } else if (this.annotation) {
6169
+ let map = this.annotation;
6170
+ if (file) map = join(dirname$1(file), map);
6171
+ return this.loadFile(map)
6172
+ }
6043
6173
  }
6044
6174
 
6045
- isAnnotation() {
6046
- if (this.isInline()) {
6047
- return true
6175
+ startWith(string, start) {
6176
+ if (!string) return false
6177
+ return string.substr(0, start.length) === start
6178
+ }
6179
+
6180
+ withContent() {
6181
+ return !!(
6182
+ this.consumer().sourcesContent &&
6183
+ this.consumer().sourcesContent.length > 0
6184
+ )
6185
+ }
6186
+ }
6187
+
6188
+ var previousMap = PreviousMap$2;
6189
+ PreviousMap$2.default = PreviousMap$2;
6190
+
6191
+ let { nanoid } = require$$0;
6192
+ let { isAbsolute, resolve: resolve$1 } = require$$2;
6193
+ let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
6194
+ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
6195
+
6196
+ let CssSyntaxError$1 = cssSyntaxError;
6197
+ let PreviousMap$1 = previousMap;
6198
+ let terminalHighlight = require$$2;
6199
+
6200
+ let fromOffsetCache = Symbol('fromOffsetCache');
6201
+
6202
+ let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
6203
+ let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
6204
+
6205
+ class Input$4 {
6206
+ constructor(css, opts = {}) {
6207
+ if (
6208
+ css === null ||
6209
+ typeof css === 'undefined' ||
6210
+ (typeof css === 'object' && !css.toString)
6211
+ ) {
6212
+ throw new Error(`PostCSS received ${css} instead of CSS string`)
6048
6213
  }
6049
- if (typeof this.mapOpts.annotation !== 'undefined') {
6050
- return this.mapOpts.annotation
6214
+
6215
+ this.css = css.toString();
6216
+
6217
+ if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
6218
+ this.hasBOM = true;
6219
+ this.css = this.css.slice(1);
6220
+ } else {
6221
+ this.hasBOM = false;
6051
6222
  }
6052
- if (this.previous().length) {
6053
- return this.previous().some(i => i.annotation)
6223
+
6224
+ if (opts.from) {
6225
+ if (
6226
+ !pathAvailable$1 ||
6227
+ /^\w+:\/\//.test(opts.from) ||
6228
+ isAbsolute(opts.from)
6229
+ ) {
6230
+ this.file = opts.from;
6231
+ } else {
6232
+ this.file = resolve$1(opts.from);
6233
+ }
6054
6234
  }
6055
- return true
6235
+
6236
+ if (pathAvailable$1 && sourceMapAvailable$1) {
6237
+ let map = new PreviousMap$1(this.css, opts);
6238
+ if (map.text) {
6239
+ this.map = map;
6240
+ let file = map.consumer().file;
6241
+ if (!this.file && file) this.file = this.mapResolve(file);
6242
+ }
6243
+ }
6244
+
6245
+ if (!this.file) {
6246
+ this.id = '<input css ' + nanoid(6) + '>';
6247
+ }
6248
+ if (this.map) this.map.file = this.from;
6056
6249
  }
6057
6250
 
6058
- isInline() {
6059
- if (typeof this.mapOpts.inline !== 'undefined') {
6060
- return this.mapOpts.inline
6251
+ error(message, line, column, opts = {}) {
6252
+ let endColumn, endLine, result;
6253
+
6254
+ if (line && typeof line === 'object') {
6255
+ let start = line;
6256
+ let end = column;
6257
+ if (typeof start.offset === 'number') {
6258
+ let pos = this.fromOffset(start.offset);
6259
+ line = pos.line;
6260
+ column = pos.col;
6261
+ } else {
6262
+ line = start.line;
6263
+ column = start.column;
6264
+ }
6265
+ if (typeof end.offset === 'number') {
6266
+ let pos = this.fromOffset(end.offset);
6267
+ endLine = pos.line;
6268
+ endColumn = pos.col;
6269
+ } else {
6270
+ endLine = end.line;
6271
+ endColumn = end.column;
6272
+ }
6273
+ } else if (!column) {
6274
+ let pos = this.fromOffset(line);
6275
+ line = pos.line;
6276
+ column = pos.col;
6277
+ }
6278
+
6279
+ let origin = this.origin(line, column, endLine, endColumn);
6280
+ if (origin) {
6281
+ result = new CssSyntaxError$1(
6282
+ message,
6283
+ origin.endLine === undefined
6284
+ ? origin.line
6285
+ : { column: origin.column, line: origin.line },
6286
+ origin.endLine === undefined
6287
+ ? origin.column
6288
+ : { column: origin.endColumn, line: origin.endLine },
6289
+ origin.source,
6290
+ origin.file,
6291
+ opts.plugin
6292
+ );
6293
+ } else {
6294
+ result = new CssSyntaxError$1(
6295
+ message,
6296
+ endLine === undefined ? line : { column, line },
6297
+ endLine === undefined ? column : { column: endColumn, line: endLine },
6298
+ this.css,
6299
+ this.file,
6300
+ opts.plugin
6301
+ );
6061
6302
  }
6062
6303
 
6063
- let annotation = this.mapOpts.annotation;
6064
- if (typeof annotation !== 'undefined' && annotation !== true) {
6065
- return false
6304
+ result.input = { column, endColumn, endLine, line, source: this.css };
6305
+ if (this.file) {
6306
+ if (pathToFileURL$1) {
6307
+ result.input.url = pathToFileURL$1(this.file).toString();
6308
+ }
6309
+ result.input.file = this.file;
6066
6310
  }
6067
6311
 
6068
- if (this.previous().length) {
6069
- return this.previous().some(i => i.inline)
6070
- }
6071
- return true
6312
+ return result
6072
6313
  }
6073
6314
 
6074
- isMap() {
6075
- if (typeof this.opts.map !== 'undefined') {
6076
- return !!this.opts.map
6315
+ fromOffset(offset) {
6316
+ let lastLine, lineToIndex;
6317
+ if (!this[fromOffsetCache]) {
6318
+ let lines = this.css.split('\n');
6319
+ lineToIndex = new Array(lines.length);
6320
+ let prevIndex = 0;
6321
+
6322
+ for (let i = 0, l = lines.length; i < l; i++) {
6323
+ lineToIndex[i] = prevIndex;
6324
+ prevIndex += lines[i].length + 1;
6325
+ }
6326
+
6327
+ this[fromOffsetCache] = lineToIndex;
6328
+ } else {
6329
+ lineToIndex = this[fromOffsetCache];
6077
6330
  }
6078
- return this.previous().length > 0
6079
- }
6331
+ lastLine = lineToIndex[lineToIndex.length - 1];
6080
6332
 
6081
- isSourcesContent() {
6082
- if (typeof this.mapOpts.sourcesContent !== 'undefined') {
6083
- return this.mapOpts.sourcesContent
6333
+ let min = 0;
6334
+ if (offset >= lastLine) {
6335
+ min = lineToIndex.length - 1;
6336
+ } else {
6337
+ let max = lineToIndex.length - 2;
6338
+ let mid;
6339
+ while (min < max) {
6340
+ mid = min + ((max - min) >> 1);
6341
+ if (offset < lineToIndex[mid]) {
6342
+ max = mid - 1;
6343
+ } else if (offset >= lineToIndex[mid + 1]) {
6344
+ min = mid + 1;
6345
+ } else {
6346
+ min = mid;
6347
+ break
6348
+ }
6349
+ }
6084
6350
  }
6085
- if (this.previous().length) {
6086
- return this.previous().some(i => i.withContent())
6351
+ return {
6352
+ col: offset - lineToIndex[min] + 1,
6353
+ line: min + 1
6087
6354
  }
6088
- return true
6089
6355
  }
6090
6356
 
6091
- outputFile() {
6092
- if (this.opts.to) {
6093
- return this.path(this.opts.to)
6094
- } else if (this.opts.from) {
6095
- return this.path(this.opts.from)
6096
- } else {
6097
- return 'to.css'
6357
+ mapResolve(file) {
6358
+ if (/^\w+:\/\//.test(file)) {
6359
+ return file
6098
6360
  }
6361
+ return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
6099
6362
  }
6100
6363
 
6101
- path(file) {
6102
- if (this.mapOpts.absolute) return file
6103
- if (file.charCodeAt(0) === 60 /* `<` */) return file
6104
- if (/^\w+:\/\//.test(file)) return file
6105
- let cached = this.memoizedPaths.get(file);
6106
- if (cached) return cached
6364
+ origin(line, column, endLine, endColumn) {
6365
+ if (!this.map) return false
6366
+ let consumer = this.map.consumer();
6107
6367
 
6108
- let from = this.opts.to ? dirname(this.opts.to) : '.';
6368
+ let from = consumer.originalPositionFor({ column, line });
6369
+ if (!from.source) return false
6109
6370
 
6110
- if (typeof this.mapOpts.annotation === 'string') {
6111
- from = dirname(resolve(from, this.mapOpts.annotation));
6371
+ let to;
6372
+ if (typeof endLine === 'number') {
6373
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
6112
6374
  }
6113
6375
 
6114
- let path = relative(from, file);
6115
- this.memoizedPaths.set(file, path);
6376
+ let fromUrl;
6116
6377
 
6117
- return path
6118
- }
6378
+ if (isAbsolute(from.source)) {
6379
+ fromUrl = pathToFileURL$1(from.source);
6380
+ } else {
6381
+ fromUrl = new URL(
6382
+ from.source,
6383
+ this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
6384
+ );
6385
+ }
6119
6386
 
6120
- previous() {
6121
- if (!this.previousMaps) {
6122
- this.previousMaps = [];
6123
- if (this.root) {
6124
- this.root.walk(node => {
6125
- if (node.source && node.source.input.map) {
6126
- let map = node.source.input.map;
6127
- if (!this.previousMaps.includes(map)) {
6128
- this.previousMaps.push(map);
6129
- }
6130
- }
6131
- });
6387
+ let result = {
6388
+ column: from.column,
6389
+ endColumn: to && to.column,
6390
+ endLine: to && to.line,
6391
+ line: from.line,
6392
+ url: fromUrl.toString()
6393
+ };
6394
+
6395
+ if (fromUrl.protocol === 'file:') {
6396
+ if (fileURLToPath) {
6397
+ result.file = fileURLToPath(fromUrl);
6132
6398
  } else {
6133
- let input = new Input$3(this.originalCSS, this.opts);
6134
- if (input.map) this.previousMaps.push(input.map);
6399
+ /* c8 ignore next 2 */
6400
+ throw new Error(`file: protocol is not available in this PostCSS build`)
6135
6401
  }
6136
6402
  }
6137
6403
 
6138
- return this.previousMaps
6139
- }
6404
+ let source = consumer.sourceContentFor(from.source);
6405
+ if (source) result.source = source;
6140
6406
 
6141
- setSourcesContent() {
6142
- let already = {};
6143
- if (this.root) {
6144
- this.root.walk(node => {
6145
- if (node.source) {
6146
- let from = node.source.input.from;
6147
- if (from && !already[from]) {
6148
- already[from] = true;
6149
- let fromUrl = this.usesFileUrls
6150
- ? this.toFileUrl(from)
6151
- : this.toUrl(this.path(from));
6152
- this.map.setSourceContent(fromUrl, node.source.input.css);
6153
- }
6154
- }
6155
- });
6156
- } else if (this.css) {
6157
- let from = this.opts.from
6158
- ? this.toUrl(this.path(this.opts.from))
6159
- : '<no source>';
6160
- this.map.setSourceContent(from, this.css);
6161
- }
6407
+ return result
6162
6408
  }
6163
6409
 
6164
- sourcePath(node) {
6165
- if (this.mapOpts.from) {
6166
- return this.toUrl(this.mapOpts.from)
6167
- } else if (this.usesFileUrls) {
6168
- return this.toFileUrl(node.source.input.from)
6169
- } else {
6170
- return this.toUrl(this.path(node.source.input.from))
6410
+ toJSON() {
6411
+ let json = {};
6412
+ for (let name of ['hasBOM', 'css', 'file', 'id']) {
6413
+ if (this[name] != null) {
6414
+ json[name] = this[name];
6415
+ }
6171
6416
  }
6172
- }
6173
-
6174
- toBase64(str) {
6175
- if (Buffer) {
6176
- return Buffer.from(str).toString('base64')
6177
- } else {
6178
- return window.btoa(unescape(encodeURIComponent(str)))
6417
+ if (this.map) {
6418
+ json.map = { ...this.map };
6419
+ if (json.map.consumerCache) {
6420
+ json.map.consumerCache = undefined;
6421
+ }
6179
6422
  }
6423
+ return json
6180
6424
  }
6181
6425
 
6182
- toFileUrl(path) {
6183
- let cached = this.memoizedFileURLs.get(path);
6184
- if (cached) return cached
6185
-
6186
- if (pathToFileURL) {
6187
- let fileURL = pathToFileURL(path).toString();
6188
- this.memoizedFileURLs.set(path, fileURL);
6189
-
6190
- return fileURL
6191
- } else {
6192
- throw new Error(
6193
- '`map.absolute` option is not available in this PostCSS build'
6194
- )
6195
- }
6426
+ get from() {
6427
+ return this.file || this.id
6196
6428
  }
6429
+ }
6197
6430
 
6198
- toUrl(path) {
6199
- let cached = this.memoizedURLs.get(path);
6200
- if (cached) return cached
6201
-
6202
- if (sep === '\\') {
6203
- path = path.replace(/\\/g, '/');
6204
- }
6205
-
6206
- let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
6207
- this.memoizedURLs.set(path, url);
6431
+ var input = Input$4;
6432
+ Input$4.default = Input$4;
6208
6433
 
6209
- return url
6210
- }
6434
+ if (terminalHighlight && terminalHighlight.registerInput) {
6435
+ terminalHighlight.registerInput(Input$4);
6211
6436
  }
6212
6437
 
6213
- var mapGenerator = MapGenerator$2;
6438
+ let Container$4 = container;
6214
6439
 
6215
- let Node$2 = node_1;
6440
+ let LazyResult$3, Processor$2;
6216
6441
 
6217
- class Comment$4 extends Node$2 {
6442
+ class Root$5 extends Container$4 {
6218
6443
  constructor(defaults) {
6219
6444
  super(defaults);
6220
- this.type = 'comment';
6445
+ this.type = 'root';
6446
+ if (!this.nodes) this.nodes = [];
6221
6447
  }
6222
- }
6223
-
6224
- var comment = Comment$4;
6225
- Comment$4.default = Comment$4;
6226
-
6227
- let { isClean: isClean$1, my: my$1 } = symbols;
6228
- let Declaration$3 = declaration;
6229
- let Comment$3 = comment;
6230
- let Node$1 = node_1;
6231
-
6232
- let parse$4, Rule$4, AtRule$4, Root$6;
6233
6448
 
6234
- function cleanSource(nodes) {
6235
- return nodes.map(i => {
6236
- if (i.nodes) i.nodes = cleanSource(i.nodes);
6237
- delete i.source;
6238
- return i
6239
- })
6240
- }
6449
+ normalize(child, sample, type) {
6450
+ let nodes = super.normalize(child);
6241
6451
 
6242
- function markTreeDirty(node) {
6243
- node[isClean$1] = false;
6244
- if (node.proxyOf.nodes) {
6245
- for (let i of node.proxyOf.nodes) {
6246
- markTreeDirty(i);
6452
+ if (sample) {
6453
+ if (type === 'prepend') {
6454
+ if (this.nodes.length > 1) {
6455
+ sample.raws.before = this.nodes[1].raws.before;
6456
+ } else {
6457
+ delete sample.raws.before;
6458
+ }
6459
+ } else if (this.first !== sample) {
6460
+ for (let node of nodes) {
6461
+ node.raws.before = sample.raws.before;
6462
+ }
6463
+ }
6247
6464
  }
6465
+
6466
+ return nodes
6248
6467
  }
6249
- }
6250
6468
 
6251
- class Container$7 extends Node$1 {
6252
- append(...children) {
6253
- for (let child of children) {
6254
- let nodes = this.normalize(child, this.last);
6255
- for (let node of nodes) this.proxyOf.nodes.push(node);
6256
- }
6469
+ removeChild(child, ignore) {
6470
+ let index = this.index(child);
6257
6471
 
6258
- this.markDirty();
6472
+ if (!ignore && index === 0 && this.nodes.length > 1) {
6473
+ this.nodes[1].raws.before = this.nodes[index].raws.before;
6474
+ }
6259
6475
 
6260
- return this
6476
+ return super.removeChild(child)
6261
6477
  }
6262
6478
 
6263
- cleanRaws(keepBetween) {
6264
- super.cleanRaws(keepBetween);
6265
- if (this.nodes) {
6266
- for (let node of this.nodes) node.cleanRaws(keepBetween);
6267
- }
6479
+ toResult(opts = {}) {
6480
+ let lazy = new LazyResult$3(new Processor$2(), this, opts);
6481
+ return lazy.stringify()
6268
6482
  }
6483
+ }
6269
6484
 
6270
- each(callback) {
6271
- if (!this.proxyOf.nodes) return undefined
6272
- let iterator = this.getIterator();
6485
+ Root$5.registerLazyResult = dependant => {
6486
+ LazyResult$3 = dependant;
6487
+ };
6273
6488
 
6274
- let index, result;
6275
- while (this.indexes[iterator] < this.proxyOf.nodes.length) {
6276
- index = this.indexes[iterator];
6277
- result = callback(this.proxyOf.nodes[index], index);
6278
- if (result === false) break
6489
+ Root$5.registerProcessor = dependant => {
6490
+ Processor$2 = dependant;
6491
+ };
6279
6492
 
6280
- this.indexes[iterator] += 1;
6281
- }
6493
+ var root = Root$5;
6494
+ Root$5.default = Root$5;
6282
6495
 
6283
- delete this.indexes[iterator];
6284
- return result
6285
- }
6496
+ Container$4.registerRoot(Root$5);
6286
6497
 
6287
- every(condition) {
6288
- return this.nodes.every(condition)
6289
- }
6498
+ let list$2 = {
6499
+ comma(string) {
6500
+ return list$2.split(string, [','], true)
6501
+ },
6290
6502
 
6291
- getIterator() {
6292
- if (!this.lastEach) this.lastEach = 0;
6293
- if (!this.indexes) this.indexes = {};
6503
+ space(string) {
6504
+ let spaces = [' ', '\n', '\t'];
6505
+ return list$2.split(string, spaces)
6506
+ },
6294
6507
 
6295
- this.lastEach += 1;
6296
- let iterator = this.lastEach;
6297
- this.indexes[iterator] = 0;
6508
+ split(string, separators, last) {
6509
+ let array = [];
6510
+ let current = '';
6511
+ let split = false;
6298
6512
 
6299
- return iterator
6300
- }
6513
+ let func = 0;
6514
+ let inQuote = false;
6515
+ let prevQuote = '';
6516
+ let escape = false;
6301
6517
 
6302
- getProxyProcessor() {
6303
- return {
6304
- get(node, prop) {
6305
- if (prop === 'proxyOf') {
6306
- return node
6307
- } else if (!node[prop]) {
6308
- return node[prop]
6309
- } else if (
6310
- prop === 'each' ||
6311
- (typeof prop === 'string' && prop.startsWith('walk'))
6312
- ) {
6313
- return (...args) => {
6314
- return node[prop](
6315
- ...args.map(i => {
6316
- if (typeof i === 'function') {
6317
- return (child, index) => i(child.toProxy(), index)
6318
- } else {
6319
- return i
6320
- }
6321
- })
6322
- )
6323
- }
6324
- } else if (prop === 'every' || prop === 'some') {
6325
- return cb => {
6326
- return node[prop]((child, ...other) =>
6327
- cb(child.toProxy(), ...other)
6328
- )
6329
- }
6330
- } else if (prop === 'root') {
6331
- return () => node.root().toProxy()
6332
- } else if (prop === 'nodes') {
6333
- return node.nodes.map(i => i.toProxy())
6334
- } else if (prop === 'first' || prop === 'last') {
6335
- return node[prop].toProxy()
6336
- } else {
6337
- return node[prop]
6518
+ for (let letter of string) {
6519
+ if (escape) {
6520
+ escape = false;
6521
+ } else if (letter === '\\') {
6522
+ escape = true;
6523
+ } else if (inQuote) {
6524
+ if (letter === prevQuote) {
6525
+ inQuote = false;
6338
6526
  }
6339
- },
6527
+ } else if (letter === '"' || letter === "'") {
6528
+ inQuote = true;
6529
+ prevQuote = letter;
6530
+ } else if (letter === '(') {
6531
+ func += 1;
6532
+ } else if (letter === ')') {
6533
+ if (func > 0) func -= 1;
6534
+ } else if (func === 0) {
6535
+ if (separators.includes(letter)) split = true;
6536
+ }
6340
6537
 
6341
- set(node, prop, value) {
6342
- if (node[prop] === value) return true
6343
- node[prop] = value;
6344
- if (prop === 'name' || prop === 'params' || prop === 'selector') {
6345
- node.markDirty();
6346
- }
6347
- return true
6538
+ if (split) {
6539
+ if (current !== '') array.push(current.trim());
6540
+ current = '';
6541
+ split = false;
6542
+ } else {
6543
+ current += letter;
6348
6544
  }
6349
6545
  }
6350
- }
6351
6546
 
6352
- index(child) {
6353
- if (typeof child === 'number') return child
6354
- if (child.proxyOf) child = child.proxyOf;
6355
- return this.proxyOf.nodes.indexOf(child)
6547
+ if (last || current !== '') array.push(current.trim());
6548
+ return array
6356
6549
  }
6550
+ };
6357
6551
 
6358
- insertAfter(exist, add) {
6359
- let existIndex = this.index(exist);
6360
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
6361
- existIndex = this.index(exist);
6362
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
6552
+ var list_1 = list$2;
6553
+ list$2.default = list$2;
6363
6554
 
6364
- let index;
6365
- for (let id in this.indexes) {
6366
- index = this.indexes[id];
6367
- if (existIndex < index) {
6368
- this.indexes[id] = index + nodes.length;
6369
- }
6370
- }
6555
+ let Container$3 = container;
6556
+ let list$1 = list_1;
6371
6557
 
6372
- this.markDirty();
6558
+ class Rule$3 extends Container$3 {
6559
+ constructor(defaults) {
6560
+ super(defaults);
6561
+ this.type = 'rule';
6562
+ if (!this.nodes) this.nodes = [];
6563
+ }
6373
6564
 
6374
- return this
6565
+ get selectors() {
6566
+ return list$1.comma(this.selector)
6375
6567
  }
6376
6568
 
6377
- insertBefore(exist, add) {
6378
- let existIndex = this.index(exist);
6379
- let type = existIndex === 0 ? 'prepend' : false;
6380
- let nodes = this.normalize(
6381
- add,
6382
- this.proxyOf.nodes[existIndex],
6383
- type
6384
- ).reverse();
6385
- existIndex = this.index(exist);
6386
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
6569
+ set selectors(values) {
6570
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
6571
+ let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
6572
+ this.selector = values.join(sep);
6573
+ }
6574
+ }
6387
6575
 
6388
- let index;
6389
- for (let id in this.indexes) {
6390
- index = this.indexes[id];
6391
- if (existIndex <= index) {
6392
- this.indexes[id] = index + nodes.length;
6393
- }
6394
- }
6576
+ var rule = Rule$3;
6577
+ Rule$3.default = Rule$3;
6395
6578
 
6396
- this.markDirty();
6579
+ Container$3.registerRule(Rule$3);
6397
6580
 
6398
- return this
6399
- }
6581
+ let AtRule$2 = atRule;
6582
+ let Comment$2 = comment;
6583
+ let Declaration$2 = declaration;
6584
+ let Input$3 = input;
6585
+ let PreviousMap = previousMap;
6586
+ let Root$4 = root;
6587
+ let Rule$2 = rule;
6400
6588
 
6401
- normalize(nodes, sample) {
6402
- if (typeof nodes === 'string') {
6403
- nodes = cleanSource(parse$4(nodes).nodes);
6404
- } else if (typeof nodes === 'undefined') {
6405
- nodes = [];
6406
- } else if (Array.isArray(nodes)) {
6407
- nodes = nodes.slice(0);
6408
- for (let i of nodes) {
6409
- if (i.parent) i.parent.removeChild(i, 'ignore');
6410
- }
6411
- } else if (nodes.type === 'root' && this.type !== 'document') {
6412
- nodes = nodes.nodes.slice(0);
6413
- for (let i of nodes) {
6414
- if (i.parent) i.parent.removeChild(i, 'ignore');
6415
- }
6416
- } else if (nodes.type) {
6417
- nodes = [nodes];
6418
- } else if (nodes.prop) {
6419
- if (typeof nodes.value === 'undefined') {
6420
- throw new Error('Value field is missed in node creation')
6421
- } else if (typeof nodes.value !== 'string') {
6422
- nodes.value = String(nodes.value);
6589
+ function fromJSON$1(json, inputs) {
6590
+ if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
6591
+
6592
+ let { inputs: ownInputs, ...defaults } = json;
6593
+ if (ownInputs) {
6594
+ inputs = [];
6595
+ for (let input of ownInputs) {
6596
+ let inputHydrated = { ...input, __proto__: Input$3.prototype };
6597
+ if (inputHydrated.map) {
6598
+ inputHydrated.map = {
6599
+ ...inputHydrated.map,
6600
+ __proto__: PreviousMap.prototype
6601
+ };
6423
6602
  }
6424
- nodes = [new Declaration$3(nodes)];
6425
- } else if (nodes.selector || nodes.selectors) {
6426
- nodes = [new Rule$4(nodes)];
6427
- } else if (nodes.name) {
6428
- nodes = [new AtRule$4(nodes)];
6429
- } else if (nodes.text) {
6430
- nodes = [new Comment$3(nodes)];
6431
- } else {
6432
- throw new Error('Unknown node type in node creation')
6603
+ inputs.push(inputHydrated);
6604
+ }
6605
+ }
6606
+ if (defaults.nodes) {
6607
+ defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
6608
+ }
6609
+ if (defaults.source) {
6610
+ let { inputId, ...source } = defaults.source;
6611
+ defaults.source = source;
6612
+ if (inputId != null) {
6613
+ defaults.source.input = inputs[inputId];
6433
6614
  }
6615
+ }
6616
+ if (defaults.type === 'root') {
6617
+ return new Root$4(defaults)
6618
+ } else if (defaults.type === 'decl') {
6619
+ return new Declaration$2(defaults)
6620
+ } else if (defaults.type === 'rule') {
6621
+ return new Rule$2(defaults)
6622
+ } else if (defaults.type === 'comment') {
6623
+ return new Comment$2(defaults)
6624
+ } else if (defaults.type === 'atrule') {
6625
+ return new AtRule$2(defaults)
6626
+ } else {
6627
+ throw new Error('Unknown node type: ' + json.type)
6628
+ }
6629
+ }
6434
6630
 
6435
- let processed = nodes.map(i => {
6436
- /* c8 ignore next */
6437
- if (!i[my$1]) Container$7.rebuild(i);
6438
- i = i.proxyOf;
6439
- if (i.parent) i.parent.removeChild(i);
6440
- if (i[isClean$1]) markTreeDirty(i);
6441
- if (typeof i.raws.before === 'undefined') {
6442
- if (sample && typeof sample.raws.before !== 'undefined') {
6443
- i.raws.before = sample.raws.before.replace(/\S/g, '');
6444
- }
6445
- }
6446
- i.parent = this.proxyOf;
6447
- return i
6448
- });
6631
+ var fromJSON_1 = fromJSON$1;
6632
+ fromJSON$1.default = fromJSON$1;
6449
6633
 
6450
- return processed
6451
- }
6634
+ let { dirname, relative, resolve, sep } = require$$2;
6635
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
6636
+ let { pathToFileURL } = require$$2;
6452
6637
 
6453
- prepend(...children) {
6454
- children = children.reverse();
6455
- for (let child of children) {
6456
- let nodes = this.normalize(child, this.first, 'prepend').reverse();
6457
- for (let node of nodes) this.proxyOf.nodes.unshift(node);
6458
- for (let id in this.indexes) {
6459
- this.indexes[id] = this.indexes[id] + nodes.length;
6460
- }
6461
- }
6638
+ let Input$2 = input;
6462
6639
 
6463
- this.markDirty();
6640
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
6641
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
6464
6642
 
6465
- return this
6466
- }
6643
+ class MapGenerator$2 {
6644
+ constructor(stringify, root, opts, cssString) {
6645
+ this.stringify = stringify;
6646
+ this.mapOpts = opts.map || {};
6647
+ this.root = root;
6648
+ this.opts = opts;
6649
+ this.css = cssString;
6650
+ this.originalCSS = cssString;
6651
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
6467
6652
 
6468
- push(child) {
6469
- child.parent = this;
6470
- this.proxyOf.nodes.push(child);
6471
- return this
6653
+ this.memoizedFileURLs = new Map();
6654
+ this.memoizedPaths = new Map();
6655
+ this.memoizedURLs = new Map();
6472
6656
  }
6473
6657
 
6474
- removeAll() {
6475
- for (let node of this.proxyOf.nodes) node.parent = undefined;
6476
- this.proxyOf.nodes = [];
6658
+ addAnnotation() {
6659
+ let content;
6477
6660
 
6478
- this.markDirty();
6661
+ if (this.isInline()) {
6662
+ content =
6663
+ 'data:application/json;base64,' + this.toBase64(this.map.toString());
6664
+ } else if (typeof this.mapOpts.annotation === 'string') {
6665
+ content = this.mapOpts.annotation;
6666
+ } else if (typeof this.mapOpts.annotation === 'function') {
6667
+ content = this.mapOpts.annotation(this.opts.to, this.root);
6668
+ } else {
6669
+ content = this.outputFile() + '.map';
6670
+ }
6671
+ let eol = '\n';
6672
+ if (this.css.includes('\r\n')) eol = '\r\n';
6479
6673
 
6480
- return this
6674
+ this.css += eol + '/*# sourceMappingURL=' + content + ' */';
6481
6675
  }
6482
6676
 
6483
- removeChild(child) {
6484
- child = this.index(child);
6485
- this.proxyOf.nodes[child].parent = undefined;
6486
- this.proxyOf.nodes.splice(child, 1);
6677
+ applyPrevMaps() {
6678
+ for (let prev of this.previous()) {
6679
+ let from = this.toUrl(this.path(prev.file));
6680
+ let root = prev.root || dirname(prev.file);
6681
+ let map;
6487
6682
 
6488
- let index;
6489
- for (let id in this.indexes) {
6490
- index = this.indexes[id];
6491
- if (index >= child) {
6492
- this.indexes[id] = index - 1;
6683
+ if (this.mapOpts.sourcesContent === false) {
6684
+ map = new SourceMapConsumer(prev.text);
6685
+ if (map.sourcesContent) {
6686
+ map.sourcesContent = null;
6687
+ }
6688
+ } else {
6689
+ map = prev.consumer();
6493
6690
  }
6691
+
6692
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
6494
6693
  }
6694
+ }
6495
6695
 
6496
- this.markDirty();
6696
+ clearAnnotation() {
6697
+ if (this.mapOpts.annotation === false) return
6497
6698
 
6498
- return this
6699
+ if (this.root) {
6700
+ let node;
6701
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
6702
+ node = this.root.nodes[i];
6703
+ if (node.type !== 'comment') continue
6704
+ if (node.text.startsWith('# sourceMappingURL=')) {
6705
+ this.root.removeChild(i);
6706
+ }
6707
+ }
6708
+ } else if (this.css) {
6709
+ this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
6710
+ }
6499
6711
  }
6500
6712
 
6501
- replaceValues(pattern, opts, callback) {
6502
- if (!callback) {
6503
- callback = opts;
6504
- opts = {};
6713
+ generate() {
6714
+ this.clearAnnotation();
6715
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
6716
+ return this.generateMap()
6717
+ } else {
6718
+ let result = '';
6719
+ this.stringify(this.root, i => {
6720
+ result += i;
6721
+ });
6722
+ return [result]
6505
6723
  }
6724
+ }
6506
6725
 
6507
- this.walkDecls(decl => {
6508
- if (opts.props && !opts.props.includes(decl.prop)) return
6509
- if (opts.fast && !decl.value.includes(opts.fast)) return
6510
-
6511
- decl.value = decl.value.replace(pattern, callback);
6512
- });
6726
+ generateMap() {
6727
+ if (this.root) {
6728
+ this.generateString();
6729
+ } else if (this.previous().length === 1) {
6730
+ let prev = this.previous()[0].consumer();
6731
+ prev.file = this.outputFile();
6732
+ this.map = SourceMapGenerator.fromSourceMap(prev, {
6733
+ ignoreInvalidMapping: true
6734
+ });
6735
+ } else {
6736
+ this.map = new SourceMapGenerator({
6737
+ file: this.outputFile(),
6738
+ ignoreInvalidMapping: true
6739
+ });
6740
+ this.map.addMapping({
6741
+ generated: { column: 0, line: 1 },
6742
+ original: { column: 0, line: 1 },
6743
+ source: this.opts.from
6744
+ ? this.toUrl(this.path(this.opts.from))
6745
+ : '<no source>'
6746
+ });
6747
+ }
6513
6748
 
6514
- this.markDirty();
6749
+ if (this.isSourcesContent()) this.setSourcesContent();
6750
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
6751
+ if (this.isAnnotation()) this.addAnnotation();
6515
6752
 
6516
- return this
6753
+ if (this.isInline()) {
6754
+ return [this.css]
6755
+ } else {
6756
+ return [this.css, this.map]
6757
+ }
6517
6758
  }
6518
6759
 
6519
- some(condition) {
6520
- return this.nodes.some(condition)
6521
- }
6760
+ generateString() {
6761
+ this.css = '';
6762
+ this.map = new SourceMapGenerator({
6763
+ file: this.outputFile(),
6764
+ ignoreInvalidMapping: true
6765
+ });
6522
6766
 
6523
- walk(callback) {
6524
- return this.each((child, i) => {
6525
- let result;
6526
- try {
6527
- result = callback(child, i);
6528
- } catch (e) {
6529
- throw child.addToError(e)
6530
- }
6531
- if (result !== false && child.walk) {
6532
- result = child.walk(callback);
6533
- }
6767
+ let line = 1;
6768
+ let column = 1;
6534
6769
 
6535
- return result
6536
- })
6537
- }
6770
+ let noSource = '<no source>';
6771
+ let mapping = {
6772
+ generated: { column: 0, line: 0 },
6773
+ original: { column: 0, line: 0 },
6774
+ source: ''
6775
+ };
6538
6776
 
6539
- walkAtRules(name, callback) {
6540
- if (!callback) {
6541
- callback = name;
6542
- return this.walk((child, i) => {
6543
- if (child.type === 'atrule') {
6544
- return callback(child, i)
6545
- }
6546
- })
6547
- }
6548
- if (name instanceof RegExp) {
6549
- return this.walk((child, i) => {
6550
- if (child.type === 'atrule' && name.test(child.name)) {
6551
- return callback(child, i)
6777
+ let last, lines;
6778
+ this.stringify(this.root, (str, node, type) => {
6779
+ this.css += str;
6780
+
6781
+ if (node && type !== 'end') {
6782
+ mapping.generated.line = line;
6783
+ mapping.generated.column = column - 1;
6784
+ if (node.source && node.source.start) {
6785
+ mapping.source = this.sourcePath(node);
6786
+ mapping.original.line = node.source.start.line;
6787
+ mapping.original.column = node.source.start.column - 1;
6788
+ this.map.addMapping(mapping);
6789
+ } else {
6790
+ mapping.source = noSource;
6791
+ mapping.original.line = 1;
6792
+ mapping.original.column = 0;
6793
+ this.map.addMapping(mapping);
6552
6794
  }
6553
- })
6554
- }
6555
- return this.walk((child, i) => {
6556
- if (child.type === 'atrule' && child.name === name) {
6557
- return callback(child, i)
6558
6795
  }
6559
- })
6560
- }
6561
6796
 
6562
- walkComments(callback) {
6563
- return this.walk((child, i) => {
6564
- if (child.type === 'comment') {
6565
- return callback(child, i)
6797
+ lines = str.match(/\n/g);
6798
+ if (lines) {
6799
+ line += lines.length;
6800
+ last = str.lastIndexOf('\n');
6801
+ column = str.length - last;
6802
+ } else {
6803
+ column += str.length;
6566
6804
  }
6567
- })
6568
- }
6569
6805
 
6570
- walkDecls(prop, callback) {
6571
- if (!callback) {
6572
- callback = prop;
6573
- return this.walk((child, i) => {
6574
- if (child.type === 'decl') {
6575
- return callback(child, i)
6576
- }
6577
- })
6578
- }
6579
- if (prop instanceof RegExp) {
6580
- return this.walk((child, i) => {
6581
- if (child.type === 'decl' && prop.test(child.prop)) {
6582
- return callback(child, i)
6806
+ if (node && type !== 'start') {
6807
+ let p = node.parent || { raws: {} };
6808
+ let childless =
6809
+ node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
6810
+ if (!childless || node !== p.last || p.raws.semicolon) {
6811
+ if (node.source && node.source.end) {
6812
+ mapping.source = this.sourcePath(node);
6813
+ mapping.original.line = node.source.end.line;
6814
+ mapping.original.column = node.source.end.column - 1;
6815
+ mapping.generated.line = line;
6816
+ mapping.generated.column = column - 2;
6817
+ this.map.addMapping(mapping);
6818
+ } else {
6819
+ mapping.source = noSource;
6820
+ mapping.original.line = 1;
6821
+ mapping.original.column = 0;
6822
+ mapping.generated.line = line;
6823
+ mapping.generated.column = column - 1;
6824
+ this.map.addMapping(mapping);
6825
+ }
6583
6826
  }
6584
- })
6585
- }
6586
- return this.walk((child, i) => {
6587
- if (child.type === 'decl' && child.prop === prop) {
6588
- return callback(child, i)
6589
6827
  }
6590
- })
6828
+ });
6591
6829
  }
6592
6830
 
6593
- walkRules(selector, callback) {
6594
- if (!callback) {
6595
- callback = selector;
6596
-
6597
- return this.walk((child, i) => {
6598
- if (child.type === 'rule') {
6599
- return callback(child, i)
6600
- }
6601
- })
6831
+ isAnnotation() {
6832
+ if (this.isInline()) {
6833
+ return true
6602
6834
  }
6603
- if (selector instanceof RegExp) {
6604
- return this.walk((child, i) => {
6605
- if (child.type === 'rule' && selector.test(child.selector)) {
6606
- return callback(child, i)
6607
- }
6608
- })
6835
+ if (typeof this.mapOpts.annotation !== 'undefined') {
6836
+ return this.mapOpts.annotation
6609
6837
  }
6610
- return this.walk((child, i) => {
6611
- if (child.type === 'rule' && child.selector === selector) {
6612
- return callback(child, i)
6613
- }
6614
- })
6615
- }
6616
-
6617
- get first() {
6618
- if (!this.proxyOf.nodes) return undefined
6619
- return this.proxyOf.nodes[0]
6620
- }
6621
-
6622
- get last() {
6623
- if (!this.proxyOf.nodes) return undefined
6624
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
6838
+ if (this.previous().length) {
6839
+ return this.previous().some(i => i.annotation)
6840
+ }
6841
+ return true
6625
6842
  }
6626
- }
6627
-
6628
- Container$7.registerParse = dependant => {
6629
- parse$4 = dependant;
6630
- };
6631
-
6632
- Container$7.registerRule = dependant => {
6633
- Rule$4 = dependant;
6634
- };
6635
-
6636
- Container$7.registerAtRule = dependant => {
6637
- AtRule$4 = dependant;
6638
- };
6639
6843
 
6640
- Container$7.registerRoot = dependant => {
6641
- Root$6 = dependant;
6642
- };
6844
+ isInline() {
6845
+ if (typeof this.mapOpts.inline !== 'undefined') {
6846
+ return this.mapOpts.inline
6847
+ }
6643
6848
 
6644
- var container = Container$7;
6645
- Container$7.default = Container$7;
6849
+ let annotation = this.mapOpts.annotation;
6850
+ if (typeof annotation !== 'undefined' && annotation !== true) {
6851
+ return false
6852
+ }
6646
6853
 
6647
- /* c8 ignore start */
6648
- Container$7.rebuild = node => {
6649
- if (node.type === 'atrule') {
6650
- Object.setPrototypeOf(node, AtRule$4.prototype);
6651
- } else if (node.type === 'rule') {
6652
- Object.setPrototypeOf(node, Rule$4.prototype);
6653
- } else if (node.type === 'decl') {
6654
- Object.setPrototypeOf(node, Declaration$3.prototype);
6655
- } else if (node.type === 'comment') {
6656
- Object.setPrototypeOf(node, Comment$3.prototype);
6657
- } else if (node.type === 'root') {
6658
- Object.setPrototypeOf(node, Root$6.prototype);
6854
+ if (this.previous().length) {
6855
+ return this.previous().some(i => i.inline)
6856
+ }
6857
+ return true
6659
6858
  }
6660
6859
 
6661
- node[my$1] = true;
6662
-
6663
- if (node.nodes) {
6664
- node.nodes.forEach(child => {
6665
- Container$7.rebuild(child);
6666
- });
6860
+ isMap() {
6861
+ if (typeof this.opts.map !== 'undefined') {
6862
+ return !!this.opts.map
6863
+ }
6864
+ return this.previous().length > 0
6667
6865
  }
6668
- };
6669
-
6670
- let Container$6 = container;
6671
-
6672
- let LazyResult$4, Processor$3;
6673
-
6674
- class Document$3 extends Container$6 {
6675
- constructor(defaults) {
6676
- // type needs to be passed to super, otherwise child roots won't be normalized correctly
6677
- super({ type: 'document', ...defaults });
6678
6866
 
6679
- if (!this.nodes) {
6680
- this.nodes = [];
6867
+ isSourcesContent() {
6868
+ if (typeof this.mapOpts.sourcesContent !== 'undefined') {
6869
+ return this.mapOpts.sourcesContent
6870
+ }
6871
+ if (this.previous().length) {
6872
+ return this.previous().some(i => i.withContent())
6681
6873
  }
6874
+ return true
6682
6875
  }
6683
6876
 
6684
- toResult(opts = {}) {
6685
- let lazy = new LazyResult$4(new Processor$3(), this, opts);
6686
-
6687
- return lazy.stringify()
6877
+ outputFile() {
6878
+ if (this.opts.to) {
6879
+ return this.path(this.opts.to)
6880
+ } else if (this.opts.from) {
6881
+ return this.path(this.opts.from)
6882
+ } else {
6883
+ return 'to.css'
6884
+ }
6688
6885
  }
6689
- }
6690
6886
 
6691
- Document$3.registerLazyResult = dependant => {
6692
- LazyResult$4 = dependant;
6693
- };
6887
+ path(file) {
6888
+ if (this.mapOpts.absolute) return file
6889
+ if (file.charCodeAt(0) === 60 /* `<` */) return file
6890
+ if (/^\w+:\/\//.test(file)) return file
6891
+ let cached = this.memoizedPaths.get(file);
6892
+ if (cached) return cached
6694
6893
 
6695
- Document$3.registerProcessor = dependant => {
6696
- Processor$3 = dependant;
6697
- };
6894
+ let from = this.opts.to ? dirname(this.opts.to) : '.';
6698
6895
 
6699
- var document = Document$3;
6700
- Document$3.default = Document$3;
6896
+ if (typeof this.mapOpts.annotation === 'string') {
6897
+ from = dirname(resolve(from, this.mapOpts.annotation));
6898
+ }
6701
6899
 
6702
- class Warning$2 {
6703
- constructor(text, opts = {}) {
6704
- this.type = 'warning';
6705
- this.text = text;
6900
+ let path = relative(from, file);
6901
+ this.memoizedPaths.set(file, path);
6706
6902
 
6707
- if (opts.node && opts.node.source) {
6708
- let range = opts.node.rangeBy(opts);
6709
- this.line = range.start.line;
6710
- this.column = range.start.column;
6711
- this.endLine = range.end.line;
6712
- this.endColumn = range.end.column;
6903
+ return path
6904
+ }
6905
+
6906
+ previous() {
6907
+ if (!this.previousMaps) {
6908
+ this.previousMaps = [];
6909
+ if (this.root) {
6910
+ this.root.walk(node => {
6911
+ if (node.source && node.source.input.map) {
6912
+ let map = node.source.input.map;
6913
+ if (!this.previousMaps.includes(map)) {
6914
+ this.previousMaps.push(map);
6915
+ }
6916
+ }
6917
+ });
6918
+ } else {
6919
+ let input = new Input$2(this.originalCSS, this.opts);
6920
+ if (input.map) this.previousMaps.push(input.map);
6921
+ }
6713
6922
  }
6714
6923
 
6715
- for (let opt in opts) this[opt] = opts[opt];
6924
+ return this.previousMaps
6716
6925
  }
6717
6926
 
6718
- toString() {
6719
- if (this.node) {
6720
- return this.node.error(this.text, {
6721
- index: this.index,
6722
- plugin: this.plugin,
6723
- word: this.word
6724
- }).message
6927
+ setSourcesContent() {
6928
+ let already = {};
6929
+ if (this.root) {
6930
+ this.root.walk(node => {
6931
+ if (node.source) {
6932
+ let from = node.source.input.from;
6933
+ if (from && !already[from]) {
6934
+ already[from] = true;
6935
+ let fromUrl = this.usesFileUrls
6936
+ ? this.toFileUrl(from)
6937
+ : this.toUrl(this.path(from));
6938
+ this.map.setSourceContent(fromUrl, node.source.input.css);
6939
+ }
6940
+ }
6941
+ });
6942
+ } else if (this.css) {
6943
+ let from = this.opts.from
6944
+ ? this.toUrl(this.path(this.opts.from))
6945
+ : '<no source>';
6946
+ this.map.setSourceContent(from, this.css);
6725
6947
  }
6948
+ }
6726
6949
 
6727
- if (this.plugin) {
6728
- return this.plugin + ': ' + this.text
6950
+ sourcePath(node) {
6951
+ if (this.mapOpts.from) {
6952
+ return this.toUrl(this.mapOpts.from)
6953
+ } else if (this.usesFileUrls) {
6954
+ return this.toFileUrl(node.source.input.from)
6955
+ } else {
6956
+ return this.toUrl(this.path(node.source.input.from))
6729
6957
  }
6958
+ }
6730
6959
 
6731
- return this.text
6960
+ toBase64(str) {
6961
+ if (Buffer) {
6962
+ return Buffer.from(str).toString('base64')
6963
+ } else {
6964
+ return window.btoa(unescape(encodeURIComponent(str)))
6965
+ }
6732
6966
  }
6733
- }
6734
6967
 
6735
- var warning = Warning$2;
6736
- Warning$2.default = Warning$2;
6968
+ toFileUrl(path) {
6969
+ let cached = this.memoizedFileURLs.get(path);
6970
+ if (cached) return cached
6737
6971
 
6738
- let Warning$1 = warning;
6972
+ if (pathToFileURL) {
6973
+ let fileURL = pathToFileURL(path).toString();
6974
+ this.memoizedFileURLs.set(path, fileURL);
6739
6975
 
6740
- class Result$3 {
6741
- constructor(processor, root, opts) {
6742
- this.processor = processor;
6743
- this.messages = [];
6744
- this.root = root;
6745
- this.opts = opts;
6746
- this.css = undefined;
6747
- this.map = undefined;
6976
+ return fileURL
6977
+ } else {
6978
+ throw new Error(
6979
+ '`map.absolute` option is not available in this PostCSS build'
6980
+ )
6981
+ }
6748
6982
  }
6749
6983
 
6750
- toString() {
6751
- return this.css
6752
- }
6984
+ toUrl(path) {
6985
+ let cached = this.memoizedURLs.get(path);
6986
+ if (cached) return cached
6753
6987
 
6754
- warn(text, opts = {}) {
6755
- if (!opts.plugin) {
6756
- if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
6757
- opts.plugin = this.lastPlugin.postcssPlugin;
6758
- }
6988
+ if (sep === '\\') {
6989
+ path = path.replace(/\\/g, '/');
6759
6990
  }
6760
6991
 
6761
- let warning = new Warning$1(text, opts);
6762
- this.messages.push(warning);
6763
-
6764
- return warning
6765
- }
6766
-
6767
- warnings() {
6768
- return this.messages.filter(i => i.type === 'warning')
6769
- }
6992
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
6993
+ this.memoizedURLs.set(path, url);
6770
6994
 
6771
- get content() {
6772
- return this.css
6995
+ return url
6773
6996
  }
6774
6997
  }
6775
6998
 
6776
- var result = Result$3;
6777
- Result$3.default = Result$3;
6999
+ var mapGenerator = MapGenerator$2;
6778
7000
 
6779
7001
  const SINGLE_QUOTE = "'".charCodeAt(0);
6780
7002
  const DOUBLE_QUOTE = '"'.charCodeAt(0);
@@ -6805,8 +7027,8 @@ var tokenize = function tokenizer(input, options = {}) {
6805
7027
  let css = input.css.valueOf();
6806
7028
  let ignore = options.ignoreErrors;
6807
7029
 
6808
- let code, next, quote, content, escape;
6809
- let escaped, escapePos, prev, n, currentToken;
7030
+ let code, content, escape, next, quote;
7031
+ let currentToken, escaped, escapePos, n, prev;
6810
7032
 
6811
7033
  let length = css.length;
6812
7034
  let pos = 0;
@@ -6983,237 +7205,70 @@ var tokenize = function tokenizer(input, options = {}) {
6983
7205
  next += 1;
6984
7206
  }
6985
7207
  if (css.charCodeAt(next + 1) === SPACE) {
6986
- next += 1;
6987
- }
6988
- }
6989
- }
6990
-
6991
- currentToken = ['word', css.slice(pos, next + 1), pos, next];
6992
-
6993
- pos = next;
6994
- break
6995
- }
6996
-
6997
- default: {
6998
- if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
6999
- next = css.indexOf('*/', pos + 2) + 1;
7000
- if (next === 0) {
7001
- if (ignore || ignoreUnclosed) {
7002
- next = css.length;
7003
- } else {
7004
- unclosed('comment');
7005
- }
7006
- }
7007
-
7008
- currentToken = ['comment', css.slice(pos, next + 1), pos, next];
7009
- pos = next;
7010
- } else {
7011
- RE_WORD_END.lastIndex = pos + 1;
7012
- RE_WORD_END.test(css);
7013
- if (RE_WORD_END.lastIndex === 0) {
7014
- next = css.length - 1;
7015
- } else {
7016
- next = RE_WORD_END.lastIndex - 2;
7017
- }
7018
-
7019
- currentToken = ['word', css.slice(pos, next + 1), pos, next];
7020
- buffer.push(currentToken);
7021
- pos = next;
7022
- }
7023
-
7024
- break
7025
- }
7026
- }
7027
-
7028
- pos++;
7029
- return currentToken
7030
- }
7031
-
7032
- function back(token) {
7033
- returned.push(token);
7034
- }
7035
-
7036
- return {
7037
- back,
7038
- endOfFile,
7039
- nextToken,
7040
- position
7041
- }
7042
- };
7043
-
7044
- let Container$5 = container;
7045
-
7046
- class AtRule$3 extends Container$5 {
7047
- constructor(defaults) {
7048
- super(defaults);
7049
- this.type = 'atrule';
7050
- }
7051
-
7052
- append(...children) {
7053
- if (!this.proxyOf.nodes) this.nodes = [];
7054
- return super.append(...children)
7055
- }
7056
-
7057
- prepend(...children) {
7058
- if (!this.proxyOf.nodes) this.nodes = [];
7059
- return super.prepend(...children)
7060
- }
7061
- }
7062
-
7063
- var atRule = AtRule$3;
7064
- AtRule$3.default = AtRule$3;
7065
-
7066
- Container$5.registerAtRule(AtRule$3);
7067
-
7068
- let Container$4 = container;
7069
-
7070
- let LazyResult$3, Processor$2;
7071
-
7072
- class Root$5 extends Container$4 {
7073
- constructor(defaults) {
7074
- super(defaults);
7075
- this.type = 'root';
7076
- if (!this.nodes) this.nodes = [];
7077
- }
7078
-
7079
- normalize(child, sample, type) {
7080
- let nodes = super.normalize(child);
7081
-
7082
- if (sample) {
7083
- if (type === 'prepend') {
7084
- if (this.nodes.length > 1) {
7085
- sample.raws.before = this.nodes[1].raws.before;
7086
- } else {
7087
- delete sample.raws.before;
7088
- }
7089
- } else if (this.first !== sample) {
7090
- for (let node of nodes) {
7091
- node.raws.before = sample.raws.before;
7092
- }
7093
- }
7094
- }
7095
-
7096
- return nodes
7097
- }
7098
-
7099
- removeChild(child, ignore) {
7100
- let index = this.index(child);
7101
-
7102
- if (!ignore && index === 0 && this.nodes.length > 1) {
7103
- this.nodes[1].raws.before = this.nodes[index].raws.before;
7104
- }
7105
-
7106
- return super.removeChild(child)
7107
- }
7108
-
7109
- toResult(opts = {}) {
7110
- let lazy = new LazyResult$3(new Processor$2(), this, opts);
7111
- return lazy.stringify()
7112
- }
7113
- }
7114
-
7115
- Root$5.registerLazyResult = dependant => {
7116
- LazyResult$3 = dependant;
7117
- };
7118
-
7119
- Root$5.registerProcessor = dependant => {
7120
- Processor$2 = dependant;
7121
- };
7122
-
7123
- var root = Root$5;
7124
- Root$5.default = Root$5;
7125
-
7126
- Container$4.registerRoot(Root$5);
7127
-
7128
- let list$2 = {
7129
- comma(string) {
7130
- return list$2.split(string, [','], true)
7131
- },
7132
-
7133
- space(string) {
7134
- let spaces = [' ', '\n', '\t'];
7135
- return list$2.split(string, spaces)
7136
- },
7137
-
7138
- split(string, separators, last) {
7139
- let array = [];
7140
- let current = '';
7141
- let split = false;
7142
-
7143
- let func = 0;
7144
- let inQuote = false;
7145
- let prevQuote = '';
7146
- let escape = false;
7147
-
7148
- for (let letter of string) {
7149
- if (escape) {
7150
- escape = false;
7151
- } else if (letter === '\\') {
7152
- escape = true;
7153
- } else if (inQuote) {
7154
- if (letter === prevQuote) {
7155
- inQuote = false;
7156
- }
7157
- } else if (letter === '"' || letter === "'") {
7158
- inQuote = true;
7159
- prevQuote = letter;
7160
- } else if (letter === '(') {
7161
- func += 1;
7162
- } else if (letter === ')') {
7163
- if (func > 0) func -= 1;
7164
- } else if (func === 0) {
7165
- if (separators.includes(letter)) split = true;
7166
- }
7208
+ next += 1;
7209
+ }
7210
+ }
7211
+ }
7167
7212
 
7168
- if (split) {
7169
- if (current !== '') array.push(current.trim());
7170
- current = '';
7171
- split = false;
7172
- } else {
7173
- current += letter;
7213
+ currentToken = ['word', css.slice(pos, next + 1), pos, next];
7214
+
7215
+ pos = next;
7216
+ break
7174
7217
  }
7175
- }
7176
7218
 
7177
- if (last || current !== '') array.push(current.trim());
7178
- return array
7179
- }
7180
- };
7219
+ default: {
7220
+ if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
7221
+ next = css.indexOf('*/', pos + 2) + 1;
7222
+ if (next === 0) {
7223
+ if (ignore || ignoreUnclosed) {
7224
+ next = css.length;
7225
+ } else {
7226
+ unclosed('comment');
7227
+ }
7228
+ }
7181
7229
 
7182
- var list_1 = list$2;
7183
- list$2.default = list$2;
7230
+ currentToken = ['comment', css.slice(pos, next + 1), pos, next];
7231
+ pos = next;
7232
+ } else {
7233
+ RE_WORD_END.lastIndex = pos + 1;
7234
+ RE_WORD_END.test(css);
7235
+ if (RE_WORD_END.lastIndex === 0) {
7236
+ next = css.length - 1;
7237
+ } else {
7238
+ next = RE_WORD_END.lastIndex - 2;
7239
+ }
7184
7240
 
7185
- let Container$3 = container;
7186
- let list$1 = list_1;
7241
+ currentToken = ['word', css.slice(pos, next + 1), pos, next];
7242
+ buffer.push(currentToken);
7243
+ pos = next;
7244
+ }
7187
7245
 
7188
- class Rule$3 extends Container$3 {
7189
- constructor(defaults) {
7190
- super(defaults);
7191
- this.type = 'rule';
7192
- if (!this.nodes) this.nodes = [];
7193
- }
7246
+ break
7247
+ }
7248
+ }
7194
7249
 
7195
- get selectors() {
7196
- return list$1.comma(this.selector)
7250
+ pos++;
7251
+ return currentToken
7197
7252
  }
7198
7253
 
7199
- set selectors(values) {
7200
- let match = this.selector ? this.selector.match(/,\s*/) : null;
7201
- let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
7202
- this.selector = values.join(sep);
7254
+ function back(token) {
7255
+ returned.push(token);
7203
7256
  }
7204
- }
7205
-
7206
- var rule = Rule$3;
7207
- Rule$3.default = Rule$3;
7208
7257
 
7209
- Container$3.registerRule(Rule$3);
7258
+ return {
7259
+ back,
7260
+ endOfFile,
7261
+ nextToken,
7262
+ position
7263
+ }
7264
+ };
7210
7265
 
7211
- let Declaration$2 = declaration;
7266
+ let AtRule$1 = atRule;
7267
+ let Comment$1 = comment;
7268
+ let Declaration$1 = declaration;
7269
+ let Root$3 = root;
7270
+ let Rule$1 = rule;
7212
7271
  let tokenizer = tokenize;
7213
- let Comment$2 = comment;
7214
- let AtRule$2 = atRule;
7215
- let Root$4 = root;
7216
- let Rule$2 = rule;
7217
7272
 
7218
7273
  const SAFE_COMMENT_NEIGHBOR = {
7219
7274
  empty: true,
@@ -7232,7 +7287,7 @@ class Parser$1 {
7232
7287
  constructor(input) {
7233
7288
  this.input = input;
7234
7289
 
7235
- this.root = new Root$4();
7290
+ this.root = new Root$3();
7236
7291
  this.current = this.root;
7237
7292
  this.spaces = '';
7238
7293
  this.semicolon = false;
@@ -7242,7 +7297,7 @@ class Parser$1 {
7242
7297
  }
7243
7298
 
7244
7299
  atrule(token) {
7245
- let node = new AtRule$2();
7300
+ let node = new AtRule$1();
7246
7301
  node.name = token[1].slice(1);
7247
7302
  if (node.name === '') {
7248
7303
  this.unnamedAtrule(node, token);
@@ -7351,7 +7406,7 @@ class Parser$1 {
7351
7406
 
7352
7407
  colon(tokens) {
7353
7408
  let brackets = 0;
7354
- let token, type, prev;
7409
+ let prev, token, type;
7355
7410
  for (let [i, element] of tokens.entries()) {
7356
7411
  token = element;
7357
7412
  type = token[0];
@@ -7378,7 +7433,7 @@ class Parser$1 {
7378
7433
  }
7379
7434
 
7380
7435
  comment(token) {
7381
- let node = new Comment$2();
7436
+ let node = new Comment$1();
7382
7437
  this.init(node, token[2]);
7383
7438
  node.source.end = this.getPosition(token[3] || token[2]);
7384
7439
  node.source.end.offset++;
@@ -7401,7 +7456,7 @@ class Parser$1 {
7401
7456
  }
7402
7457
 
7403
7458
  decl(tokens, customProperty) {
7404
- let node = new Declaration$2();
7459
+ let node = new Declaration$1();
7405
7460
  this.init(node, tokens[0][2]);
7406
7461
 
7407
7462
  let last = tokens[tokens.length - 1];
@@ -7475,12 +7530,12 @@ class Parser$1 {
7475
7530
  let str = '';
7476
7531
  for (let j = i; j > 0; j--) {
7477
7532
  let type = cache[j][0];
7478
- if (str.trim().indexOf('!') === 0 && type !== 'space') {
7533
+ if (str.trim().startsWith('!') && type !== 'space') {
7479
7534
  break
7480
7535
  }
7481
7536
  str = cache.pop()[1] + str;
7482
7537
  }
7483
- if (str.trim().indexOf('!') === 0) {
7538
+ if (str.trim().startsWith('!')) {
7484
7539
  node.important = true;
7485
7540
  node.raws.important = str;
7486
7541
  tokens = cache;
@@ -7514,7 +7569,7 @@ class Parser$1 {
7514
7569
  }
7515
7570
 
7516
7571
  emptyRule(token) {
7517
- let node = new Rule$2();
7572
+ let node = new Rule$1();
7518
7573
  this.init(node, token[2]);
7519
7574
  node.selector = '';
7520
7575
  node.raws.between = '';
@@ -7724,7 +7779,7 @@ class Parser$1 {
7724
7779
  rule(tokens) {
7725
7780
  tokens.pop();
7726
7781
 
7727
- let node = new Rule$2();
7782
+ let node = new Rule$1();
7728
7783
  this.init(node, tokens[0][2]);
7729
7784
 
7730
7785
  node.raws.between = this.spacesAndCommentsFromEnd(tokens);
@@ -7817,11 +7872,11 @@ class Parser$1 {
7817
7872
  var parser = Parser$1;
7818
7873
 
7819
7874
  let Container$2 = container;
7875
+ let Input$1 = input;
7820
7876
  let Parser = parser;
7821
- let Input$2 = input;
7822
7877
 
7823
7878
  function parse$3(css, opts) {
7824
- let input = new Input$2(css, opts);
7879
+ let input = new Input$1(css, opts);
7825
7880
  let parser = new Parser(input);
7826
7881
  try {
7827
7882
  parser.parse();
@@ -7837,14 +7892,91 @@ parse$3.default = parse$3;
7837
7892
 
7838
7893
  Container$2.registerParse(parse$3);
7839
7894
 
7840
- let { isClean, my } = symbols;
7841
- let MapGenerator$1 = mapGenerator;
7842
- let stringify$2 = stringify_1;
7895
+ class Warning$2 {
7896
+ constructor(text, opts = {}) {
7897
+ this.type = 'warning';
7898
+ this.text = text;
7899
+
7900
+ if (opts.node && opts.node.source) {
7901
+ let range = opts.node.rangeBy(opts);
7902
+ this.line = range.start.line;
7903
+ this.column = range.start.column;
7904
+ this.endLine = range.end.line;
7905
+ this.endColumn = range.end.column;
7906
+ }
7907
+
7908
+ for (let opt in opts) this[opt] = opts[opt];
7909
+ }
7910
+
7911
+ toString() {
7912
+ if (this.node) {
7913
+ return this.node.error(this.text, {
7914
+ index: this.index,
7915
+ plugin: this.plugin,
7916
+ word: this.word
7917
+ }).message
7918
+ }
7919
+
7920
+ if (this.plugin) {
7921
+ return this.plugin + ': ' + this.text
7922
+ }
7923
+
7924
+ return this.text
7925
+ }
7926
+ }
7927
+
7928
+ var warning = Warning$2;
7929
+ Warning$2.default = Warning$2;
7930
+
7931
+ let Warning$1 = warning;
7932
+
7933
+ class Result$3 {
7934
+ constructor(processor, root, opts) {
7935
+ this.processor = processor;
7936
+ this.messages = [];
7937
+ this.root = root;
7938
+ this.opts = opts;
7939
+ this.css = undefined;
7940
+ this.map = undefined;
7941
+ }
7942
+
7943
+ toString() {
7944
+ return this.css
7945
+ }
7946
+
7947
+ warn(text, opts = {}) {
7948
+ if (!opts.plugin) {
7949
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
7950
+ opts.plugin = this.lastPlugin.postcssPlugin;
7951
+ }
7952
+ }
7953
+
7954
+ let warning = new Warning$1(text, opts);
7955
+ this.messages.push(warning);
7956
+
7957
+ return warning
7958
+ }
7959
+
7960
+ warnings() {
7961
+ return this.messages.filter(i => i.type === 'warning')
7962
+ }
7963
+
7964
+ get content() {
7965
+ return this.css
7966
+ }
7967
+ }
7968
+
7969
+ var result = Result$3;
7970
+ Result$3.default = Result$3;
7971
+
7843
7972
  let Container$1 = container;
7844
7973
  let Document$2 = document;
7845
- let Result$2 = result;
7974
+ let MapGenerator$1 = mapGenerator;
7846
7975
  let parse$2 = parse_1;
7847
- let Root$3 = root;
7976
+ let Result$2 = result;
7977
+ let Root$2 = root;
7978
+ let stringify$2 = stringify_1;
7979
+ let { isClean, my } = symbols;
7848
7980
 
7849
7981
  const TYPE_TO_CLASS_NAME = {
7850
7982
  atrule: 'AtRule',
@@ -8351,13 +8483,13 @@ LazyResult$2.registerPostcss = dependant => {
8351
8483
  var lazyResult = LazyResult$2;
8352
8484
  LazyResult$2.default = LazyResult$2;
8353
8485
 
8354
- Root$3.registerLazyResult(LazyResult$2);
8486
+ Root$2.registerLazyResult(LazyResult$2);
8355
8487
  Document$2.registerLazyResult(LazyResult$2);
8356
8488
 
8357
8489
  let MapGenerator = mapGenerator;
8358
- let stringify$1 = stringify_1;
8359
8490
  let parse$1 = parse_1;
8360
8491
  const Result$1 = result;
8492
+ let stringify$1 = stringify_1;
8361
8493
 
8362
8494
  class NoWorkResult$1 {
8363
8495
  constructor(processor, css, opts) {
@@ -8481,14 +8613,14 @@ class NoWorkResult$1 {
8481
8613
  var noWorkResult = NoWorkResult$1;
8482
8614
  NoWorkResult$1.default = NoWorkResult$1;
8483
8615
 
8484
- let NoWorkResult = noWorkResult;
8485
- let LazyResult$1 = lazyResult;
8486
8616
  let Document$1 = document;
8487
- let Root$2 = root;
8617
+ let LazyResult$1 = lazyResult;
8618
+ let NoWorkResult = noWorkResult;
8619
+ let Root$1 = root;
8488
8620
 
8489
8621
  class Processor$1 {
8490
8622
  constructor(plugins = []) {
8491
- this.version = '8.4.41';
8623
+ this.version = '8.4.49';
8492
8624
  this.plugins = this.normalize(plugins);
8493
8625
  }
8494
8626
 
@@ -8536,80 +8668,27 @@ class Processor$1 {
8536
8668
  var processor = Processor$1;
8537
8669
  Processor$1.default = Processor$1;
8538
8670
 
8539
- Root$2.registerProcessor(Processor$1);
8671
+ Root$1.registerProcessor(Processor$1);
8540
8672
  Document$1.registerProcessor(Processor$1);
8541
8673
 
8542
- let Declaration$1 = declaration;
8543
- let PreviousMap = previousMap;
8544
- let Comment$1 = comment;
8545
- let AtRule$1 = atRule;
8546
- let Input$1 = input;
8547
- let Root$1 = root;
8548
- let Rule$1 = rule;
8549
-
8550
- function fromJSON$1(json, inputs) {
8551
- if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
8552
-
8553
- let { inputs: ownInputs, ...defaults } = json;
8554
- if (ownInputs) {
8555
- inputs = [];
8556
- for (let input of ownInputs) {
8557
- let inputHydrated = { ...input, __proto__: Input$1.prototype };
8558
- if (inputHydrated.map) {
8559
- inputHydrated.map = {
8560
- ...inputHydrated.map,
8561
- __proto__: PreviousMap.prototype
8562
- };
8563
- }
8564
- inputs.push(inputHydrated);
8565
- }
8566
- }
8567
- if (defaults.nodes) {
8568
- defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
8569
- }
8570
- if (defaults.source) {
8571
- let { inputId, ...source } = defaults.source;
8572
- defaults.source = source;
8573
- if (inputId != null) {
8574
- defaults.source.input = inputs[inputId];
8575
- }
8576
- }
8577
- if (defaults.type === 'root') {
8578
- return new Root$1(defaults)
8579
- } else if (defaults.type === 'decl') {
8580
- return new Declaration$1(defaults)
8581
- } else if (defaults.type === 'rule') {
8582
- return new Rule$1(defaults)
8583
- } else if (defaults.type === 'comment') {
8584
- return new Comment$1(defaults)
8585
- } else if (defaults.type === 'atrule') {
8586
- return new AtRule$1(defaults)
8587
- } else {
8588
- throw new Error('Unknown node type: ' + json.type)
8589
- }
8590
- }
8591
-
8592
- var fromJSON_1 = fromJSON$1;
8593
- fromJSON$1.default = fromJSON$1;
8594
-
8674
+ let AtRule = atRule;
8675
+ let Comment = comment;
8676
+ let Container = container;
8595
8677
  let CssSyntaxError = cssSyntaxError;
8596
8678
  let Declaration = declaration;
8597
- let LazyResult = lazyResult;
8598
- let Container = container;
8599
- let Processor = processor;
8600
- let stringify = stringify_1;
8601
- let fromJSON = fromJSON_1;
8602
8679
  let Document = document;
8603
- let Warning = warning;
8604
- let Comment = comment;
8605
- let AtRule = atRule;
8606
- let Result = result;
8680
+ let fromJSON = fromJSON_1;
8607
8681
  let Input = input;
8608
- let parse = parse_1;
8682
+ let LazyResult = lazyResult;
8609
8683
  let list = list_1;
8610
- let Rule = rule;
8611
- let Root = root;
8612
8684
  let Node = node_1;
8685
+ let parse = parse_1;
8686
+ let Processor = processor;
8687
+ let Result = result;
8688
+ let Root = root;
8689
+ let Rule = rule;
8690
+ let stringify = stringify_1;
8691
+ let Warning = warning;
8613
8692
 
8614
8693
  function postcss(...plugins) {
8615
8694
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
@@ -8692,7 +8771,7 @@ LazyResult.registerPostcss(postcss);
8692
8771
  var postcss_1 = postcss;
8693
8772
  postcss.default = postcss;
8694
8773
 
8695
- const htmlparser = require$$0;
8774
+ const htmlparser = require$$0$1;
8696
8775
  const escapeStringRegexp = escapeStringRegexp$1;
8697
8776
  const { isPlainObject } = require$$2$1;
8698
8777
  const deepmerge = cjs;
@@ -9125,12 +9204,13 @@ function sanitizeHtml(html, options, _recursing) {
9125
9204
  const allowedWildcardClasses = allowedClassesMap['*'];
9126
9205
  const allowedSpecificClassesGlob = allowedClassesGlobMap[name];
9127
9206
  const allowedSpecificClassesRegex = allowedClassesRegexMap[name];
9207
+ const allowedWildcardClassesRegex = allowedClassesRegexMap['*'];
9128
9208
  const allowedWildcardClassesGlob = allowedClassesGlobMap['*'];
9129
9209
  const allowedClassesGlobs = [
9130
9210
  allowedSpecificClassesGlob,
9131
9211
  allowedWildcardClassesGlob
9132
9212
  ]
9133
- .concat(allowedSpecificClassesRegex)
9213
+ .concat(allowedSpecificClassesRegex, allowedWildcardClassesRegex)
9134
9214
  .filter(function (t) {
9135
9215
  return t;
9136
9216
  });