7onic 0.1.16 → 0.1.17

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 (2) hide show
  1. package/dist/index.js +644 -213
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -204,6 +204,7 @@ var require_tokenize = __commonJS({
204
204
  let pos = 0;
205
205
  let buffer = [];
206
206
  let returned = [];
207
+ let lastBadParen = -1;
207
208
  function position() {
208
209
  return pos;
209
210
  }
@@ -268,10 +269,13 @@ var require_tokenize = __commonJS({
268
269
  } while (escaped);
269
270
  currentToken = ["brackets", css.slice(pos, next + 1), pos, next];
270
271
  pos = next;
272
+ } else if (pos <= lastBadParen) {
273
+ currentToken = ["(", "(", pos];
271
274
  } else {
272
275
  next = css.indexOf(")", pos + 1);
273
276
  content = css.slice(pos, next + 1);
274
277
  if (next === -1 || RE_BAD_BRACKET.test(content)) {
278
+ lastBadParen = next === -1 ? length : next;
275
279
  currentToken = ["(", "(", pos];
276
280
  } else {
277
281
  currentToken = ["brackets", content, pos, next];
@@ -549,6 +553,7 @@ var require_stringifier = __commonJS({
549
553
  "node_modules/postcss/lib/stringifier.js"(exports2, module2) {
550
554
  "use strict";
551
555
  init_define_AI_KIT_FILES();
556
+ var AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/;
552
557
  var DEFAULT_RAW = {
553
558
  after: "\n",
554
559
  beforeClose: "\n",
@@ -566,23 +571,74 @@ var require_stringifier = __commonJS({
566
571
  function capitalize(str) {
567
572
  return str[0].toUpperCase() + str.slice(1);
568
573
  }
569
- var Stringifier = class {
574
+ function atruleStart(str, node) {
575
+ let name = "@" + node.name;
576
+ let params = node.params ? str.rawValue(node, "params") : "";
577
+ let afterName = node.raws.afterName;
578
+ if (typeof afterName === "undefined") {
579
+ afterName = params ? " " : "";
580
+ } else if (afterName === "" && params && !AT_NAME_END.test(params[0])) {
581
+ afterName = " ";
582
+ }
583
+ return name + afterName + params;
584
+ }
585
+ function isCustomProperty(node) {
586
+ if (!node.prop.startsWith("--")) return false;
587
+ let before = node.raws.before;
588
+ return typeof before === "undefined" || !/[^\s;]$/.test(before);
589
+ }
590
+ function pushBody(str, stack, node) {
591
+ let nodes = node.nodes;
592
+ let last = nodes.length - 1;
593
+ while (last > 0) {
594
+ if (nodes[last].type !== "comment") break;
595
+ last -= 1;
596
+ }
597
+ let semicolon = str.raw(node, "semicolon");
598
+ let isDocument = node.type === "document";
599
+ for (let i = nodes.length - 1; i >= 0; i--) {
600
+ let child = nodes[i];
601
+ let childSemicolon = last !== i || semicolon;
602
+ if (!childSemicolon && i < nodes.length - 1 && (child.type === "atrule" && !child.nodes || child.type === "decl" && isCustomProperty(child))) {
603
+ childSemicolon = true;
604
+ }
605
+ stack.push({
606
+ document: isDocument,
607
+ node: child,
608
+ semicolon: childSemicolon
609
+ });
610
+ }
611
+ }
612
+ function pushBlock(str, stack, node, start) {
613
+ let between = str.raw(node, "between", "beforeOpen");
614
+ str.builder(start + between + "{", node, "start");
615
+ let hasNodes = node.nodes && node.nodes.length;
616
+ let close = () => {
617
+ let after = hasNodes ? str.raw(node, "after") : str.raw(node, "after", "emptyBody");
618
+ if (after) str.builder(after);
619
+ str.builder("}", node, "end");
620
+ if (node.type === "rule" && node.raws.ownSemicolon) {
621
+ str.builder(node.raws.ownSemicolon, node, "end");
622
+ }
623
+ };
624
+ if (hasNodes) {
625
+ stack.push(close);
626
+ pushBody(str, stack, node);
627
+ } else {
628
+ close();
629
+ }
630
+ }
631
+ var Stringifier = class _Stringifier {
570
632
  constructor(builder) {
571
633
  this.builder = builder;
572
634
  }
573
635
  atrule(node, semicolon) {
574
- let name = "@" + node.name;
575
- let params = node.params ? this.rawValue(node, "params") : "";
576
- if (typeof node.raws.afterName !== "undefined") {
577
- name += node.raws.afterName;
578
- } else if (params) {
579
- name += " ";
580
- }
636
+ let start = atruleStart(this, node);
581
637
  if (node.nodes) {
582
- this.block(node, name + params);
638
+ this.block(node, start);
583
639
  } else {
584
640
  let end = (node.raws.between || "") + (semicolon ? ";" : "");
585
- this.builder(name + params + end, node);
641
+ this.builder(start + end, node);
586
642
  }
587
643
  }
588
644
  beforeAfter(node, detect) {
@@ -624,17 +680,30 @@ var require_stringifier = __commonJS({
624
680
  this.builder("}", node, "end");
625
681
  }
626
682
  body(node) {
627
- let last = node.nodes.length - 1;
628
- while (last > 0) {
629
- if (node.nodes[last].type !== "comment") break;
630
- last -= 1;
631
- }
632
- let semicolon = this.raw(node, "semicolon");
633
- for (let i = 0; i < node.nodes.length; i++) {
634
- let child = node.nodes[i];
683
+ let proto = _Stringifier.prototype;
684
+ let expandable = ["atrule", "block", "body", "rule", "stringify"].every(
685
+ (method) => this[method] === proto[method]
686
+ );
687
+ let stack = [];
688
+ pushBody(this, stack, node);
689
+ while (stack.length > 0) {
690
+ let entry = stack.pop();
691
+ if (typeof entry === "function") {
692
+ entry();
693
+ continue;
694
+ }
695
+ let child = entry.node;
635
696
  let before = this.raw(child, "before");
636
- if (before) this.builder(before);
637
- this.stringify(child, last !== i || semicolon);
697
+ if (before) {
698
+ this.builder(before);
699
+ }
700
+ if (expandable && child.type === "rule") {
701
+ pushBlock(this, stack, child, this.rawValue(child, "selector"));
702
+ } else if (expandable && child.type === "atrule" && child.nodes) {
703
+ pushBlock(this, stack, child, atruleStart(this, child));
704
+ } else {
705
+ this.stringify(child, entry.semicolon);
706
+ }
638
707
  }
639
708
  }
640
709
  comment(node) {
@@ -643,10 +712,11 @@ var require_stringifier = __commonJS({
643
712
  this.builder("/*" + left + node.text + right + "*/", node);
644
713
  }
645
714
  decl(node, semicolon) {
715
+ let raws = node.raws;
646
716
  let between = this.raw(node, "between", "colon");
647
717
  let string = node.prop + between + this.rawValue(node, "value");
648
718
  if (node.important) {
649
- string += node.raws.important || " !important";
719
+ string += raws.important || " !important";
650
720
  }
651
721
  if (semicolon) string += ";";
652
722
  this.builder(string, node);
@@ -672,9 +742,9 @@ var require_stringifier = __commonJS({
672
742
  }
673
743
  if (!parent) return DEFAULT_RAW[detect];
674
744
  let root2 = node.root();
675
- if (!root2.rawCache) root2.rawCache = {};
676
- if (typeof root2.rawCache[detect] !== "undefined") {
677
- return root2.rawCache[detect];
745
+ let cache = root2.rawCache || (root2.rawCache = {});
746
+ if (typeof cache[detect] !== "undefined") {
747
+ return cache[detect];
678
748
  }
679
749
  if (detect === "before" || detect === "after") {
680
750
  return this.beforeAfter(node, detect);
@@ -690,7 +760,7 @@ var require_stringifier = __commonJS({
690
760
  }
691
761
  }
692
762
  if (typeof value === "undefined") value = DEFAULT_RAW[detect];
693
- root2.rawCache[detect] = value;
763
+ cache[detect] = value;
694
764
  return value;
695
765
  }
696
766
  rawBeforeClose(root2) {
@@ -826,8 +896,14 @@ var require_stringifier = __commonJS({
826
896
  return value;
827
897
  }
828
898
  root(node) {
899
+ let inDocument = node.parent && node.parent.type === "document";
900
+ if (!inDocument && node.source && node.source.input.hasBOM) {
901
+ this.builder("\uFEFF", node, "start");
902
+ }
829
903
  this.body(node);
830
- if (node.raws.after) this.builder(node.raws.after);
904
+ if (node.raws.after) {
905
+ this.builder(node.raws.after);
906
+ }
831
907
  }
832
908
  rule(node) {
833
909
  this.block(node, this.rawValue(node, "selector"));
@@ -855,9 +931,78 @@ var require_stringify = __commonJS({
855
931
  "use strict";
856
932
  init_define_AI_KIT_FILES();
857
933
  var Stringifier = require_stringifier();
934
+ var STYLE_TAG = /(<)(\/?style\b)/gi;
935
+ var COMMENT_OPEN = /(<)(!--)/g;
936
+ function escapeHTMLInCSS(str) {
937
+ if (!str.includes("<")) return str;
938
+ return str.replace(STYLE_TAG, "\\3c $2").replace(COMMENT_OPEN, "\\3c $2");
939
+ }
940
+ function cutEscaped(chunks, css, escaped) {
941
+ let parts = [];
942
+ let at2 = 0;
943
+ let into = 0;
944
+ for (let i = 0; i < chunks.length; i += 3) {
945
+ let from = into;
946
+ let end = at2 + chunks[i].length;
947
+ while (at2 < end) {
948
+ if (css[at2] === escaped[into]) {
949
+ at2 += 1;
950
+ into += 1;
951
+ } else {
952
+ at2 += 1;
953
+ into += 4;
954
+ }
955
+ }
956
+ parts.push(escaped.slice(from, into));
957
+ }
958
+ return parts;
959
+ }
960
+ var SafeStringifier = class extends Stringifier {
961
+ escapeHTML(print) {
962
+ let builder = this.builder;
963
+ let chunks, css;
964
+ this.builder = (str, child, type) => {
965
+ if (chunks) {
966
+ css += str;
967
+ chunks.push(str, child, type);
968
+ } else if (str.includes("<")) {
969
+ css = str;
970
+ chunks = [str, child, type];
971
+ } else {
972
+ builder(str, child, type);
973
+ }
974
+ };
975
+ print();
976
+ this.builder = builder;
977
+ if (!chunks) return;
978
+ let escaped = escapeHTMLInCSS(css);
979
+ if (escaped === css) {
980
+ for (let i = 0; i < chunks.length; i += 3) {
981
+ builder(chunks[i], chunks[i + 1], chunks[i + 2]);
982
+ }
983
+ } else {
984
+ let parts = cutEscaped(chunks, css, escaped);
985
+ for (let i = 0; i < chunks.length; i += 3) {
986
+ builder(parts[i / 3], chunks[i + 1], chunks[i + 2]);
987
+ }
988
+ }
989
+ }
990
+ root(node) {
991
+ if (node.parent && node.parent.type === "document") {
992
+ this.escapeHTML(() => this.body(node));
993
+ if (node.raws.after) this.builder(node.raws.after);
994
+ } else {
995
+ this.escapeHTML(() => super.root(node));
996
+ }
997
+ }
998
+ };
858
999
  function stringify2(node, builder) {
859
- let str = new Stringifier(builder);
860
- str.stringify(node);
1000
+ let str = new SafeStringifier(builder);
1001
+ if (node.type === "root" || node.type === "document") {
1002
+ str.stringify(node);
1003
+ } else {
1004
+ str.escapeHTML(() => str.stringify(node));
1005
+ }
861
1006
  }
862
1007
  module2.exports = stringify2;
863
1008
  stringify2.default = stringify2;
@@ -885,22 +1030,36 @@ var require_node = __commonJS({
885
1030
  var { isClean, my } = require_symbols();
886
1031
  function cloneNode(obj, parent) {
887
1032
  let cloned = new obj.constructor();
888
- for (let i in obj) {
889
- if (!Object.prototype.hasOwnProperty.call(obj, i)) {
890
- continue;
891
- }
892
- if (i === "proxyCache") continue;
893
- let value = obj[i];
894
- let type = typeof value;
895
- if (i === "parent" && type === "object") {
896
- if (parent) cloned[i] = parent;
897
- } else if (i === "source") {
898
- cloned[i] = value;
899
- } else if (Array.isArray(value)) {
900
- cloned[i] = value.map((j2) => cloneNode(j2, cloned));
901
- } else {
902
- if (type === "object" && value !== null) value = cloneNode(value);
903
- cloned[i] = value;
1033
+ let stack = [[obj, cloned, parent]];
1034
+ while (stack.length > 0) {
1035
+ let [source, target, targetParent] = stack.pop();
1036
+ for (let i in source) {
1037
+ if (!Object.prototype.hasOwnProperty.call(source, i)) {
1038
+ continue;
1039
+ }
1040
+ if (i === "proxyCache") continue;
1041
+ let value = source[i];
1042
+ let type = typeof value;
1043
+ if (i === "parent" && type === "object") {
1044
+ if (targetParent) target[i] = targetParent;
1045
+ } else if (i === "source") {
1046
+ target[i] = value;
1047
+ } else if (Array.isArray(value)) {
1048
+ let children = [];
1049
+ target[i] = children;
1050
+ for (let j2 of value) {
1051
+ let childClone = new j2.constructor();
1052
+ children.push(childClone);
1053
+ stack.push([j2, childClone, target]);
1054
+ }
1055
+ } else {
1056
+ if (type === "object" && value !== null) {
1057
+ let valueClone = new value.constructor();
1058
+ stack.push([value, valueClone, void 0]);
1059
+ value = valueClone;
1060
+ }
1061
+ target[i] = value;
1062
+ }
904
1063
  }
905
1064
  }
906
1065
  return cloned;
@@ -926,7 +1085,7 @@ var require_node = __commonJS({
926
1085
  }
927
1086
  return offset;
928
1087
  }
929
- var Node2 = class {
1088
+ var Node2 = class _Node {
930
1089
  get proxyOf() {
931
1090
  return this;
932
1091
  }
@@ -934,11 +1093,12 @@ var require_node = __commonJS({
934
1093
  this.raws = {};
935
1094
  this[isClean] = false;
936
1095
  this[my] = true;
937
- for (let name in defaults) {
1096
+ for (let name of Object.keys(defaults)) {
1097
+ if (name === "__proto__") continue;
938
1098
  if (name === "nodes") {
939
1099
  this.nodes = [];
940
1100
  for (let node of defaults[name]) {
941
- if (typeof node.clone === "function") {
1101
+ if (typeof node.clone === "function" && node.parent) {
942
1102
  this.append(node.clone());
943
1103
  } else {
944
1104
  this.append(node);
@@ -1049,11 +1209,15 @@ var require_node = __commonJS({
1049
1209
  return this.parent.nodes[index + 1];
1050
1210
  }
1051
1211
  positionBy(opts = {}) {
1052
- let pos = this.source.start;
1212
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
1213
+ let pos = {
1214
+ column: this.source.start.column,
1215
+ line: this.source.start.line,
1216
+ offset: sourceOffset(inputString, this.source.start)
1217
+ };
1053
1218
  if (opts.index) {
1054
1219
  pos = this.positionInside(opts.index);
1055
1220
  } else if (opts.word) {
1056
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
1057
1221
  let stringRepresentation = inputString.slice(
1058
1222
  sourceOffset(inputString, this.source.start),
1059
1223
  sourceOffset(inputString, this.source.end)
@@ -1125,7 +1289,7 @@ var require_node = __commonJS({
1125
1289
  line: opts.start.line,
1126
1290
  offset: sourceOffset(inputString, opts.start)
1127
1291
  };
1128
- } else if (opts.index) {
1292
+ } else if (typeof opts.index === "number") {
1129
1293
  start = this.positionInside(opts.index);
1130
1294
  }
1131
1295
  if (opts.end) {
@@ -1136,7 +1300,7 @@ var require_node = __commonJS({
1136
1300
  };
1137
1301
  } else if (typeof opts.endIndex === "number") {
1138
1302
  end = this.positionInside(opts.endIndex);
1139
- } else if (opts.index) {
1303
+ } else if (typeof opts.index === "number") {
1140
1304
  end = this.positionInside(opts.index + 1);
1141
1305
  }
1142
1306
  }
@@ -1188,43 +1352,59 @@ var require_node = __commonJS({
1188
1352
  return result;
1189
1353
  }
1190
1354
  toJSON(_2, inputs) {
1191
- let fixed = {};
1192
1355
  let emitInputs = inputs == null;
1193
1356
  inputs = inputs || /* @__PURE__ */ new Map();
1194
- let inputsNextIndex = 0;
1195
- for (let name in this) {
1196
- if (!Object.prototype.hasOwnProperty.call(this, name)) {
1197
- continue;
1198
- }
1199
- if (name === "parent" || name === "proxyCache") continue;
1200
- let value = this[name];
1201
- if (Array.isArray(value)) {
1202
- fixed[name] = value.map((i) => {
1203
- if (typeof i === "object" && i.toJSON) {
1204
- return i.toJSON(null, inputs);
1357
+ let holderOfRoot = [];
1358
+ let queue = [[this, holderOfRoot, 0]];
1359
+ for (let step = 0; step < queue.length; step++) {
1360
+ let [node, holder, key] = queue[step];
1361
+ let fixed2 = {};
1362
+ holder[key] = fixed2;
1363
+ for (let name in node) {
1364
+ if (!Object.prototype.hasOwnProperty.call(node, name)) {
1365
+ continue;
1366
+ }
1367
+ if (name === "parent" || name === "proxyCache") continue;
1368
+ let value = node[name];
1369
+ if (Array.isArray(value)) {
1370
+ let fixedArray = [];
1371
+ fixed2[name] = fixedArray;
1372
+ for (let i = 0; i < value.length; i++) {
1373
+ let item = value[i];
1374
+ if (typeof item === "object" && item.toJSON) {
1375
+ if (item.toJSON === _Node.prototype.toJSON) {
1376
+ queue.push([item, fixedArray, i]);
1377
+ } else {
1378
+ fixedArray[i] = item.toJSON(null, inputs);
1379
+ }
1380
+ } else {
1381
+ fixedArray[i] = item;
1382
+ }
1383
+ }
1384
+ } else if (typeof value === "object" && value.toJSON) {
1385
+ if (value.toJSON === _Node.prototype.toJSON) {
1386
+ queue.push([value, fixed2, name]);
1205
1387
  } else {
1206
- return i;
1388
+ fixed2[name] = value.toJSON(null, inputs);
1207
1389
  }
1208
- });
1209
- } else if (typeof value === "object" && value.toJSON) {
1210
- fixed[name] = value.toJSON(null, inputs);
1211
- } else if (name === "source") {
1212
- if (value == null) continue;
1213
- let inputId = inputs.get(value.input);
1214
- if (inputId == null) {
1215
- inputId = inputsNextIndex;
1216
- inputs.set(value.input, inputsNextIndex);
1217
- inputsNextIndex++;
1390
+ } else if (name === "source") {
1391
+ if (value == null) continue;
1392
+ let inputId = inputs.get(value.input);
1393
+ if (inputId == null) {
1394
+ inputId = inputs.size;
1395
+ inputs.set(value.input, inputId);
1396
+ }
1397
+ fixed2[name] = {
1398
+ end: value.end,
1399
+ inputId,
1400
+ start: value.start
1401
+ };
1402
+ } else {
1403
+ fixed2[name] = value;
1218
1404
  }
1219
- fixed[name] = {
1220
- end: value.end,
1221
- inputId,
1222
- start: value.start
1223
- };
1224
- } else {
1225
- fixed[name] = value;
1226
1405
  }
1227
1406
  }
1407
+ let fixed = holderOfRoot[0];
1228
1408
  if (emitInputs) {
1229
1409
  fixed.inputs = [...inputs.keys()].map((input) => input.toJSON());
1230
1410
  }
@@ -1309,17 +1489,24 @@ var require_container = __commonJS({
1309
1489
  var Root2;
1310
1490
  var Rule2;
1311
1491
  function cleanSource(nodes) {
1312
- return nodes.map((i) => {
1313
- if (i.nodes) i.nodes = cleanSource(i.nodes);
1314
- delete i.source;
1315
- return i;
1316
- });
1492
+ let stack = nodes.slice();
1493
+ while (stack.length > 0) {
1494
+ let node = stack.pop();
1495
+ delete node.source;
1496
+ if (node.nodes) {
1497
+ node.nodes = node.nodes.slice();
1498
+ for (let i of node.nodes) stack.push(i);
1499
+ }
1500
+ }
1501
+ return nodes.slice();
1317
1502
  }
1318
1503
  function markTreeDirty(node) {
1319
- node[isClean] = false;
1320
- if (node.proxyOf.nodes) {
1321
- for (let i of node.proxyOf.nodes) {
1322
- markTreeDirty(i);
1504
+ let stack = [node];
1505
+ while (stack.length > 0) {
1506
+ let next = stack.pop();
1507
+ next[isClean] = false;
1508
+ if (next.proxyOf.nodes) {
1509
+ for (let i of next.proxyOf.nodes) stack.push(i);
1323
1510
  }
1324
1511
  }
1325
1512
  }
@@ -1341,9 +1528,17 @@ var require_container = __commonJS({
1341
1528
  return this;
1342
1529
  }
1343
1530
  cleanRaws(keepBetween) {
1344
- super.cleanRaws(keepBetween);
1345
- if (this.nodes) {
1346
- for (let node of this.nodes) node.cleanRaws(keepBetween);
1531
+ let stack = [this];
1532
+ while (stack.length > 0) {
1533
+ let node = stack.pop();
1534
+ if (node !== this && node.cleanRaws !== _Container.prototype.cleanRaws) {
1535
+ node.cleanRaws(keepBetween);
1536
+ continue;
1537
+ }
1538
+ Node2.prototype.cleanRaws.call(node, keepBetween);
1539
+ if (node.nodes) {
1540
+ for (let child of node.nodes) stack.push(child);
1541
+ }
1347
1542
  }
1348
1543
  }
1349
1544
  each(callback) {
@@ -1558,18 +1753,38 @@ var require_container = __commonJS({
1558
1753
  return this.nodes.some(condition);
1559
1754
  }
1560
1755
  walk(callback) {
1561
- return this.each((child, i) => {
1756
+ if (!this.proxyOf.nodes) return void 0;
1757
+ let stack = [{ iterator: this.getIterator(), node: this.proxyOf }];
1758
+ while (stack.length > 0) {
1759
+ let { iterator, node } = stack[stack.length - 1];
1760
+ let index = node.indexes[iterator];
1761
+ if (index >= node.proxyOf.nodes.length) {
1762
+ delete node.indexes[iterator];
1763
+ stack.pop();
1764
+ let parent = stack[stack.length - 1];
1765
+ if (parent) parent.node.indexes[parent.iterator] += 1;
1766
+ continue;
1767
+ }
1768
+ let child = node.proxyOf.nodes[index];
1562
1769
  let result;
1563
1770
  try {
1564
- result = callback(child, i);
1771
+ result = callback(child, index);
1565
1772
  } catch (e) {
1566
1773
  throw child.addToError(e);
1567
1774
  }
1568
- if (result !== false && child.walk) {
1569
- result = child.walk(callback);
1775
+ if (result === false) {
1776
+ for (let opened of stack) {
1777
+ delete opened.node.indexes[opened.iterator];
1778
+ }
1779
+ return false;
1570
1780
  }
1571
- return result;
1572
- });
1781
+ if (child.walk && child.proxyOf.nodes) {
1782
+ stack.push({ iterator: child.getIterator(), node: child });
1783
+ } else {
1784
+ node.indexes[iterator] += 1;
1785
+ }
1786
+ }
1787
+ return void 0;
1573
1788
  }
1574
1789
  walkAtRules(name, callback) {
1575
1790
  if (!callback) {
@@ -1660,22 +1875,24 @@ var require_container = __commonJS({
1660
1875
  module2.exports = Container2;
1661
1876
  Container2.default = Container2;
1662
1877
  Container2.rebuild = (node) => {
1663
- if (node.type === "atrule") {
1664
- Object.setPrototypeOf(node, AtRule2.prototype);
1665
- } else if (node.type === "rule") {
1666
- Object.setPrototypeOf(node, Rule2.prototype);
1667
- } else if (node.type === "decl") {
1668
- Object.setPrototypeOf(node, Declaration2.prototype);
1669
- } else if (node.type === "comment") {
1670
- Object.setPrototypeOf(node, Comment2.prototype);
1671
- } else if (node.type === "root") {
1672
- Object.setPrototypeOf(node, Root2.prototype);
1673
- }
1674
- node[my] = true;
1675
- if (node.nodes) {
1676
- node.nodes.forEach((child) => {
1677
- Container2.rebuild(child);
1678
- });
1878
+ let stack = [node];
1879
+ while (stack.length > 0) {
1880
+ let next = stack.pop();
1881
+ if (next.type === "atrule") {
1882
+ Object.setPrototypeOf(next, AtRule2.prototype);
1883
+ } else if (next.type === "rule") {
1884
+ Object.setPrototypeOf(next, Rule2.prototype);
1885
+ } else if (next.type === "decl") {
1886
+ Object.setPrototypeOf(next, Declaration2.prototype);
1887
+ } else if (next.type === "comment") {
1888
+ Object.setPrototypeOf(next, Comment2.prototype);
1889
+ } else if (next.type === "root") {
1890
+ Object.setPrototypeOf(next, Root2.prototype);
1891
+ }
1892
+ next[my] = true;
1893
+ if (next.nodes) {
1894
+ for (let child of next.nodes) stack.push(child);
1895
+ }
1679
1896
  }
1680
1897
  };
1681
1898
  }
@@ -1747,7 +1964,7 @@ var require_non_secure = __commonJS({
1747
1964
  return (size = defaultSize) => {
1748
1965
  let id = "";
1749
1966
  let i = size | 0;
1750
- while (i--) {
1967
+ while (i-- > 0) {
1751
1968
  id += alphabet[Math.random() * alphabet.length | 0];
1752
1969
  }
1753
1970
  return id;
@@ -1756,7 +1973,7 @@ var require_non_secure = __commonJS({
1756
1973
  var nanoid = (size = 21) => {
1757
1974
  let id = "";
1758
1975
  let i = size | 0;
1759
- while (i--) {
1976
+ while (i-- > 0) {
1760
1977
  id += urlAlphabet[Math.random() * 64 | 0];
1761
1978
  }
1762
1979
  return id;
@@ -2579,10 +2796,9 @@ var require_source_map_generator = __commonJS({
2579
2796
  next = "";
2580
2797
  if (mapping.generatedLine !== previousGeneratedLine) {
2581
2798
  previousGeneratedColumn = 0;
2582
- while (mapping.generatedLine !== previousGeneratedLine) {
2583
- next += ";";
2584
- previousGeneratedLine++;
2585
- }
2799
+ var lineDelta = mapping.generatedLine - previousGeneratedLine;
2800
+ next += lineDelta === 1 ? ";" : ";".repeat(lineDelta);
2801
+ previousGeneratedLine = mapping.generatedLine;
2586
2802
  } else {
2587
2803
  if (i > 0) {
2588
2804
  if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
@@ -2743,9 +2959,17 @@ var require_quick_sort = __commonJS({
2743
2959
  let templateFn = new Function(`return ${template}`)();
2744
2960
  return templateFn(comparator);
2745
2961
  }
2962
+ var isEvalAllowed = (function() {
2963
+ try {
2964
+ new Function("return 0")();
2965
+ return true;
2966
+ } catch {
2967
+ return false;
2968
+ }
2969
+ })();
2746
2970
  var sortCache = /* @__PURE__ */ new WeakMap();
2747
2971
  exports2.quickSort = function(ary, comparator, start = 0) {
2748
- let doQuickSort = sortCache.get(comparator);
2972
+ let doQuickSort = isEvalAllowed ? sortCache.get(comparator) : SortTemplate(comparator);
2749
2973
  if (doQuickSort === void 0) {
2750
2974
  doQuickSort = cloneSort(comparator);
2751
2975
  sortCache.set(comparator, doQuickSort);
@@ -2764,6 +2988,7 @@ var require_source_map_consumer = __commonJS({
2764
2988
  var ArraySet = require_array_set().ArraySet;
2765
2989
  var base64VLQ = require_base64_vlq();
2766
2990
  var quickSort = require_quick_sort().quickSort;
2991
+ var MAX_SECTION_OFFSET_LINE = 1e7;
2767
2992
  function SourceMapConsumer(aSourceMap, aSourceMapURL) {
2768
2993
  var sourceMap = aSourceMap;
2769
2994
  if (typeof aSourceMap === "string") {
@@ -3256,6 +3481,7 @@ var require_source_map_consumer = __commonJS({
3256
3481
  line: -1,
3257
3482
  column: 0
3258
3483
  };
3484
+ var maxOffsetLine = 0;
3259
3485
  this._sections = sections.map(function(s) {
3260
3486
  if (s.url) {
3261
3487
  throw new Error("Support for url field in sections not implemented.");
@@ -3263,10 +3489,24 @@ var require_source_map_consumer = __commonJS({
3263
3489
  var offset = util.getArg(s, "offset");
3264
3490
  var offsetLine = util.getArg(offset, "line");
3265
3491
  var offsetColumn = util.getArg(offset, "column");
3492
+ if (!isValidOffset(offsetLine) || !isValidOffset(offsetColumn)) {
3493
+ throw new Error("Section offset line and column must be non-negative integers.");
3494
+ }
3495
+ if (offsetLine > MAX_SECTION_OFFSET_LINE) {
3496
+ throw new Error("Section offset line must not exceed " + MAX_SECTION_OFFSET_LINE + ".");
3497
+ }
3266
3498
  if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
3267
3499
  throw new Error("Section offsets must be ordered and non-overlapping.");
3268
3500
  }
3269
3501
  lastOffset = offset;
3502
+ var consumer = new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL);
3503
+ var totalOffsetLine = offsetLine + (consumer._maxOffsetLine || 0);
3504
+ if (totalOffsetLine > MAX_SECTION_OFFSET_LINE) {
3505
+ throw new Error("Section offset line must not exceed " + MAX_SECTION_OFFSET_LINE + ", including offsets of nested sections.");
3506
+ }
3507
+ if (totalOffsetLine > maxOffsetLine) {
3508
+ maxOffsetLine = totalOffsetLine;
3509
+ }
3270
3510
  return {
3271
3511
  generatedOffset: {
3272
3512
  // The offset fields are 0-based, but we use 1-based indices when
@@ -3274,9 +3514,14 @@ var require_source_map_consumer = __commonJS({
3274
3514
  generatedLine: offsetLine + 1,
3275
3515
  generatedColumn: offsetColumn + 1
3276
3516
  },
3277
- consumer: new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL)
3517
+ consumer
3278
3518
  };
3279
3519
  });
3520
+ this._maxOffsetLine = maxOffsetLine;
3521
+ }
3522
+ function isValidOffset(aValue) {
3523
+ return typeof aValue === "number" && aValue >= 0 && aValue <= 9007199254740991 && // Number.MAX_SAFE_INTEGER
3524
+ Math.floor(aValue) === aValue;
3280
3525
  }
3281
3526
  IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
3282
3527
  IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
@@ -3285,8 +3530,9 @@ var require_source_map_consumer = __commonJS({
3285
3530
  get: function() {
3286
3531
  var sources = [];
3287
3532
  for (var i = 0; i < this._sections.length; i++) {
3288
- for (var j2 = 0; j2 < this._sections[i].consumer.sources.length; j2++) {
3289
- sources.push(this._sections[i].consumer.sources[j2]);
3533
+ var sectionSources = this._sections[i].consumer.sources;
3534
+ for (var j2 = 0; j2 < sectionSources.length; j2++) {
3535
+ sources.push(sectionSources[j2]);
3290
3536
  }
3291
3537
  }
3292
3538
  return sources;
@@ -3453,6 +3699,10 @@ var require_source_node = __commonJS({
3453
3699
  }
3454
3700
  }
3455
3701
  while (lastGeneratedLine < mapping.generatedLine) {
3702
+ if (remainingLinesIndex >= remainingLines.length) {
3703
+ lastGeneratedLine = mapping.generatedLine;
3704
+ break;
3705
+ }
3456
3706
  node.add(shiftNextLine());
3457
3707
  lastGeneratedLine++;
3458
3708
  }
@@ -3684,9 +3934,16 @@ var require_previous_map = __commonJS({
3684
3934
  "node_modules/postcss/lib/previous-map.js"(exports2, module2) {
3685
3935
  "use strict";
3686
3936
  init_define_AI_KIT_FILES();
3687
- var { existsSync, readFileSync } = require("fs");
3688
- var { dirname, join } = require("path");
3937
+ var { existsSync, readFileSync, realpathSync } = require("fs");
3938
+ var { dirname, isAbsolute, join, relative, sep } = require("path");
3689
3939
  var { SourceMapConsumer, SourceMapGenerator } = require_source_map();
3940
+ function realPath(path7) {
3941
+ try {
3942
+ return realpathSync(path7);
3943
+ } catch {
3944
+ return path7;
3945
+ }
3946
+ }
3690
3947
  function fromBase64(str) {
3691
3948
  if (Buffer) {
3692
3949
  return Buffer.from(str, "base64").toString();
@@ -3697,6 +3954,7 @@ var require_previous_map = __commonJS({
3697
3954
  var PreviousMap = class {
3698
3955
  constructor(css, opts) {
3699
3956
  if (opts.map === false) return;
3957
+ if (opts.unsafeMap) this.unsafeMap = true;
3700
3958
  this.loadAnnotation(css);
3701
3959
  this.inline = this.startWith(this.annotation, "data:");
3702
3960
  let prev = opts.map ? opts.map.prev : void 0;
@@ -3709,7 +3967,7 @@ var require_previous_map = __commonJS({
3709
3967
  }
3710
3968
  consumer() {
3711
3969
  if (!this.consumerCache) {
3712
- this.consumerCache = new SourceMapConsumer(this.text);
3970
+ this.consumerCache = new SourceMapConsumer(this.json || this.text);
3713
3971
  }
3714
3972
  return this.consumerCache;
3715
3973
  }
@@ -3726,7 +3984,8 @@ var require_previous_map = __commonJS({
3726
3984
  if (baseUriMatch) {
3727
3985
  return fromBase64(text.substr(baseUriMatch[0].length));
3728
3986
  }
3729
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
3987
+ let encoding = text.slice("data:application/json;".length);
3988
+ encoding = encoding.slice(0, encoding.indexOf(","));
3730
3989
  throw new Error("Unsupported source map encoding " + encoding);
3731
3990
  }
3732
3991
  getAnnotationURL(sourceMapString) {
@@ -3745,7 +4004,15 @@ var require_previous_map = __commonJS({
3745
4004
  this.annotation = this.getAnnotationURL(css.substring(start, end));
3746
4005
  }
3747
4006
  }
3748
- loadFile(path7) {
4007
+ loadFile(path7, cssFile, trusted) {
4008
+ if (!trusted && !this.unsafeMap) {
4009
+ if (!/\.map$/i.test(path7)) return void 0;
4010
+ if (!cssFile) return void 0;
4011
+ let rel = relative(realPath(dirname(cssFile)), realPath(path7));
4012
+ if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel)) {
4013
+ return void 0;
4014
+ }
4015
+ }
3749
4016
  this.root = dirname(path7);
3750
4017
  if (existsSync(path7)) {
3751
4018
  this.mapFile = path7;
@@ -3760,7 +4027,7 @@ var require_previous_map = __commonJS({
3760
4027
  } else if (typeof prev === "function") {
3761
4028
  let prevPath = prev(file);
3762
4029
  if (prevPath) {
3763
- let map = this.loadFile(prevPath);
4030
+ let map = this.loadFile(prevPath, file, true);
3764
4031
  if (!map) {
3765
4032
  throw new Error(
3766
4033
  "Unable to load previous source map: " + prevPath.toString()
@@ -3784,7 +4051,15 @@ var require_previous_map = __commonJS({
3784
4051
  } else if (this.annotation) {
3785
4052
  let map = this.annotation;
3786
4053
  if (file) map = join(dirname(file), map);
3787
- return this.loadFile(map);
4054
+ let unknown = this.loadFile(map, file, false);
4055
+ if (unknown) {
4056
+ try {
4057
+ this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ""));
4058
+ } catch {
4059
+ return void 0;
4060
+ }
4061
+ }
4062
+ return unknown;
3788
4063
  }
3789
4064
  }
3790
4065
  startWith(string, start) {
@@ -3917,7 +4192,15 @@ var require_input = __commonJS({
3917
4192
  opts.plugin
3918
4193
  );
3919
4194
  }
3920
- result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
4195
+ result.input = {
4196
+ column,
4197
+ endColumn,
4198
+ endLine,
4199
+ endOffset,
4200
+ line,
4201
+ offset,
4202
+ source: this.css
4203
+ };
3921
4204
  if (this.file) {
3922
4205
  if (pathToFileURL) {
3923
4206
  result.input.url = pathToFileURL(this.file).toString();
@@ -3966,11 +4249,15 @@ var require_input = __commonJS({
3966
4249
  origin(line, column, endLine, endColumn) {
3967
4250
  if (!this.map) return false;
3968
4251
  let consumer = this.map.consumer();
3969
- let from = consumer.originalPositionFor({ column, line });
4252
+ let from = consumer.originalPositionFor({ column: column - 1, line });
3970
4253
  if (!from.source) return false;
3971
4254
  let to;
3972
4255
  if (typeof endLine === "number") {
3973
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
4256
+ let toPosition = consumer.originalPositionFor({
4257
+ column: endColumn - 1,
4258
+ line: endLine
4259
+ });
4260
+ if (toPosition.source) to = toPosition;
3974
4261
  }
3975
4262
  let fromUrl;
3976
4263
  if (isAbsolute(from.source)) {
@@ -3982,8 +4269,8 @@ var require_input = __commonJS({
3982
4269
  );
3983
4270
  }
3984
4271
  let result = {
3985
- column: from.column,
3986
- endColumn: to && to.column,
4272
+ column: from.column + 1,
4273
+ endColumn: to && to.column + 1,
3987
4274
  endLine: to && to.line,
3988
4275
  line: from.line,
3989
4276
  url: fromUrl.toString()
@@ -4038,6 +4325,12 @@ var require_root = __commonJS({
4038
4325
  if (!this.nodes) this.nodes = [];
4039
4326
  }
4040
4327
  normalize(child, sample, type) {
4328
+ let keepBefore = /* @__PURE__ */ new Set();
4329
+ for (let node of Array.isArray(child) ? child : [child]) {
4330
+ if (node && typeof node === "object" && !node.parent && node.raws && typeof node.raws.before !== "undefined") {
4331
+ keepBefore.add(node.raws);
4332
+ }
4333
+ }
4041
4334
  let nodes = super.normalize(child);
4042
4335
  if (sample) {
4043
4336
  if (type === "prepend") {
@@ -4048,7 +4341,9 @@ var require_root = __commonJS({
4048
4341
  }
4049
4342
  } else if (this.first !== sample) {
4050
4343
  for (let node of nodes) {
4051
- node.raws.before = sample.raws.before;
4344
+ if (!keepBefore.has(node.raws)) {
4345
+ node.raws.before = sample.raws.before;
4346
+ }
4052
4347
  }
4053
4348
  }
4054
4349
  }
@@ -4092,6 +4387,7 @@ var require_list = __commonJS({
4092
4387
  return list2.split(string, spaces);
4093
4388
  },
4094
4389
  split(string, separators, last) {
4390
+ if (typeof string !== "string") return [];
4095
4391
  let array = [];
4096
4392
  let current = "";
4097
4393
  let split = false;
@@ -4099,7 +4395,18 @@ var require_list = __commonJS({
4099
4395
  let inQuote = false;
4100
4396
  let prevQuote = "";
4101
4397
  let escape = false;
4102
- for (let letter of string) {
4398
+ let inComment = false;
4399
+ for (let i = 0; i < string.length; i++) {
4400
+ let letter = string[i];
4401
+ if (inComment) {
4402
+ current += letter;
4403
+ if (letter === "*" && string[i + 1] === "/") {
4404
+ current += "/";
4405
+ i += 1;
4406
+ inComment = false;
4407
+ }
4408
+ continue;
4409
+ }
4103
4410
  if (escape) {
4104
4411
  escape = false;
4105
4412
  } else if (letter === "\\") {
@@ -4111,6 +4418,11 @@ var require_list = __commonJS({
4111
4418
  } else if (letter === '"' || letter === "'") {
4112
4419
  inQuote = true;
4113
4420
  prevQuote = letter;
4421
+ } else if (letter === "/" && string[i + 1] === "*") {
4422
+ current += "/*";
4423
+ i += 1;
4424
+ inComment = true;
4425
+ continue;
4114
4426
  } else if (letter === "(") {
4115
4427
  func += 1;
4116
4428
  } else if (letter === ")") {
@@ -4119,14 +4431,16 @@ var require_list = __commonJS({
4119
4431
  if (separators.includes(letter)) split = true;
4120
4432
  }
4121
4433
  if (split) {
4122
- if (current !== "") array.push(current.trim());
4434
+ let value2 = current.trim();
4435
+ if (last || value2 !== "") array.push(value2);
4123
4436
  current = "";
4124
4437
  split = false;
4125
4438
  } else {
4126
4439
  current += letter;
4127
4440
  }
4128
4441
  }
4129
- if (last || current !== "") array.push(current.trim());
4442
+ let value = current.trim();
4443
+ if (last || value !== "") array.push(value);
4130
4444
  return array;
4131
4445
  }
4132
4446
  };
@@ -4175,25 +4489,23 @@ var require_fromJSON = __commonJS({
4175
4489
  var PreviousMap = require_previous_map();
4176
4490
  var Root2 = require_root();
4177
4491
  var Rule2 = require_rule();
4178
- function fromJSON2(json, inputs) {
4179
- if (Array.isArray(json)) return json.map((n) => fromJSON2(n));
4180
- let { inputs: ownInputs, ...defaults } = json;
4181
- if (ownInputs) {
4182
- inputs = [];
4183
- for (let input of ownInputs) {
4184
- let inputHydrated = { ...input, __proto__: Input2.prototype };
4185
- if (inputHydrated.map) {
4186
- inputHydrated.map = {
4187
- ...inputHydrated.map,
4188
- __proto__: PreviousMap.prototype
4189
- };
4190
- }
4191
- inputs.push(inputHydrated);
4492
+ function hydrateInputs(json, inputs) {
4493
+ if (!json.inputs) return inputs;
4494
+ return json.inputs.map((input) => {
4495
+ let inputHydrated = { ...input, __proto__: Input2.prototype };
4496
+ if (inputHydrated.map) {
4497
+ inputHydrated.map = {
4498
+ ...inputHydrated.map,
4499
+ __proto__: PreviousMap.prototype
4500
+ };
4192
4501
  }
4193
- }
4194
- if (defaults.nodes) {
4195
- defaults.nodes = json.nodes.map((n) => fromJSON2(n, inputs));
4196
- }
4502
+ return inputHydrated;
4503
+ });
4504
+ }
4505
+ function constructNode(json, inputs, children) {
4506
+ let defaults = { ...json };
4507
+ delete defaults.inputs;
4508
+ delete defaults.nodes;
4197
4509
  if (defaults.source) {
4198
4510
  let { inputId, ...source } = defaults.source;
4199
4511
  defaults.source = source;
@@ -4201,19 +4513,59 @@ var require_fromJSON = __commonJS({
4201
4513
  defaults.source.input = inputs[inputId];
4202
4514
  }
4203
4515
  }
4516
+ let node;
4204
4517
  if (defaults.type === "root") {
4205
- return new Root2(defaults);
4518
+ node = new Root2(defaults);
4206
4519
  } else if (defaults.type === "decl") {
4207
- return new Declaration2(defaults);
4520
+ node = new Declaration2(defaults);
4208
4521
  } else if (defaults.type === "rule") {
4209
- return new Rule2(defaults);
4522
+ node = new Rule2(defaults);
4210
4523
  } else if (defaults.type === "comment") {
4211
- return new Comment2(defaults);
4524
+ node = new Comment2(defaults);
4212
4525
  } else if (defaults.type === "atrule") {
4213
- return new AtRule2(defaults);
4526
+ node = new AtRule2(defaults);
4214
4527
  } else {
4215
4528
  throw new Error("Unknown node type: " + json.type);
4216
4529
  }
4530
+ if (children) {
4531
+ node.nodes = children;
4532
+ for (let child of children) child.parent = node;
4533
+ }
4534
+ return node;
4535
+ }
4536
+ function fromJSON2(json, inputs) {
4537
+ if (Array.isArray(json)) return json.map((n) => fromJSON2(n));
4538
+ let result;
4539
+ let stack = [
4540
+ { childIndex: 0, children: [], inputs: hydrateInputs(json, inputs), json }
4541
+ ];
4542
+ while (stack.length > 0) {
4543
+ let frame = stack[stack.length - 1];
4544
+ let jsonNodes = frame.json.nodes;
4545
+ if (jsonNodes && frame.childIndex < jsonNodes.length) {
4546
+ let childJson = jsonNodes[frame.childIndex];
4547
+ frame.childIndex += 1;
4548
+ stack.push({
4549
+ childIndex: 0,
4550
+ children: [],
4551
+ inputs: hydrateInputs(childJson, frame.inputs),
4552
+ json: childJson
4553
+ });
4554
+ continue;
4555
+ }
4556
+ stack.pop();
4557
+ let node = constructNode(
4558
+ frame.json,
4559
+ frame.inputs,
4560
+ jsonNodes ? frame.children : void 0
4561
+ );
4562
+ if (stack.length > 0) {
4563
+ stack[stack.length - 1].children.push(node);
4564
+ } else {
4565
+ result = node;
4566
+ }
4567
+ }
4568
+ return result;
4217
4569
  }
4218
4570
  module2.exports = fromJSON2;
4219
4571
  fromJSON2.default = fromJSON2;
@@ -4287,7 +4639,20 @@ var require_map_generator = __commonJS({
4287
4639
  }
4288
4640
  }
4289
4641
  } else if (this.css) {
4290
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, "");
4642
+ let annotation = "/*# sourceMappingURL=";
4643
+ let css = "";
4644
+ let cursor = 0;
4645
+ let startIndex;
4646
+ while ((startIndex = this.css.indexOf(annotation, cursor)) !== -1) {
4647
+ let endIndex = this.css.indexOf("*/", startIndex + annotation.length);
4648
+ if (endIndex === -1) break;
4649
+ while (startIndex > cursor && this.css[startIndex - 1] === "\n") {
4650
+ startIndex--;
4651
+ }
4652
+ css += this.css.slice(cursor, startIndex);
4653
+ cursor = endIndex + 2;
4654
+ }
4655
+ if (cursor > 0) this.css = css + this.css.slice(cursor);
4291
4656
  }
4292
4657
  }
4293
4658
  generate() {
@@ -4560,6 +4925,11 @@ var require_parser = __commonJS({
4560
4925
  if (pos) return pos;
4561
4926
  }
4562
4927
  }
4928
+ function tokensToString(tokens, from, to) {
4929
+ let result = "";
4930
+ for (let i = from; i < to; i++) result += tokens[i][1];
4931
+ return result;
4932
+ }
4563
4933
  var Parser = class {
4564
4934
  constructor(input) {
4565
4935
  this.input = input;
@@ -4696,7 +5066,7 @@ var require_parser = __commonJS({
4696
5066
  node.source.end = this.getPosition(token[3] || token[2]);
4697
5067
  node.source.end.offset++;
4698
5068
  let text = token[1].slice(2, -2);
4699
- if (/^\s*$/.test(text)) {
5069
+ if (!text.trim()) {
4700
5070
  node.text = "";
4701
5071
  node.raws.left = text;
4702
5072
  node.raws.right = "";
@@ -4722,44 +5092,45 @@ var require_parser = __commonJS({
4722
5092
  last[3] || last[2] || findLastWithPosition(tokens)
4723
5093
  );
4724
5094
  node.source.end.offset++;
4725
- while (tokens[0][0] !== "word") {
4726
- if (tokens.length === 1) this.unknownWord(tokens);
4727
- node.raws.before += tokens.shift()[1];
4728
- }
4729
- node.source.start = this.getPosition(tokens[0][2]);
4730
- node.prop = "";
4731
- while (tokens.length) {
4732
- let type = tokens[0][0];
5095
+ let start = 0;
5096
+ while (tokens[start][0] !== "word") {
5097
+ if (start === tokens.length - 1) this.unknownWord([tokens[start]]);
5098
+ start++;
5099
+ }
5100
+ node.raws.before += tokensToString(tokens, 0, start);
5101
+ node.source.start = this.getPosition(tokens[start][2]);
5102
+ let propStart = start;
5103
+ while (start < tokens.length) {
5104
+ let type = tokens[start][0];
4733
5105
  if (type === ":" || type === "space" || type === "comment") {
4734
5106
  break;
4735
5107
  }
4736
- node.prop += tokens.shift()[1];
5108
+ start++;
4737
5109
  }
4738
- node.raws.between = "";
5110
+ node.prop = tokensToString(tokens, propStart, start);
5111
+ let betweenStart = start;
4739
5112
  let token;
4740
- while (tokens.length) {
4741
- token = tokens.shift();
4742
- if (token[0] === ":") {
4743
- node.raws.between += token[1];
4744
- break;
4745
- } else {
4746
- if (token[0] === "word" && /\w/.test(token[1])) {
4747
- this.unknownWord([token]);
4748
- }
4749
- node.raws.between += token[1];
5113
+ while (start < tokens.length) {
5114
+ token = tokens[start];
5115
+ start++;
5116
+ if (token[0] === ":") break;
5117
+ if (token[0] === "word" && /\w/.test(token[1])) {
5118
+ this.unknownWord([token]);
4750
5119
  }
4751
5120
  }
5121
+ node.raws.between = tokensToString(tokens, betweenStart, start);
4752
5122
  if (node.prop[0] === "_" || node.prop[0] === "*") {
4753
5123
  node.raws.before += node.prop[0];
4754
5124
  node.prop = node.prop.slice(1);
4755
5125
  }
4756
- let firstSpaces = [];
4757
- let next;
4758
- while (tokens.length) {
4759
- next = tokens[0][0];
5126
+ let firstSpacesStart = start;
5127
+ while (start < tokens.length) {
5128
+ let next = tokens[start][0];
4760
5129
  if (next !== "space" && next !== "comment") break;
4761
- firstSpaces.push(tokens.shift());
5130
+ start++;
4762
5131
  }
5132
+ let firstSpaces = tokens.slice(firstSpacesStart, start);
5133
+ tokens = tokens.slice(start);
4763
5134
  this.precheckMissedSemicolon(tokens);
4764
5135
  for (let i = tokens.length - 1; i >= 0; i--) {
4765
5136
  token = tokens[i];
@@ -4844,7 +5215,7 @@ var require_parser = __commonJS({
4844
5215
  prev.raws.ownSemicolon = this.spaces;
4845
5216
  this.spaces = "";
4846
5217
  prev.source.end = this.getPosition(token[2]);
4847
- prev.source.end.offset += prev.raws.ownSemicolon.length;
5218
+ prev.source.end.offset++;
4848
5219
  }
4849
5220
  }
4850
5221
  }
@@ -4960,6 +5331,7 @@ var require_parser = __commonJS({
4960
5331
  let token, type;
4961
5332
  let length = tokens.length;
4962
5333
  let value = "";
5334
+ let last = "";
4963
5335
  let clean = true;
4964
5336
  let next, prev;
4965
5337
  for (let i = 0; i < length; i += 1) {
@@ -4971,16 +5343,18 @@ var require_parser = __commonJS({
4971
5343
  prev = tokens[i - 1] ? tokens[i - 1][0] : "empty";
4972
5344
  next = tokens[i + 1] ? tokens[i + 1][0] : "empty";
4973
5345
  if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
4974
- if (value.slice(-1) === ",") {
5346
+ if (last === ",") {
4975
5347
  clean = false;
4976
5348
  } else {
4977
5349
  value += token[1];
5350
+ last = token[1].slice(-1);
4978
5351
  }
4979
5352
  } else {
4980
5353
  clean = false;
4981
5354
  }
4982
5355
  } else {
4983
5356
  value += token[1];
5357
+ last = token[1].slice(-1);
4984
5358
  }
4985
5359
  }
4986
5360
  if (!clean) {
@@ -5113,11 +5487,16 @@ var require_warning = __commonJS({
5113
5487
  "node_modules/postcss/lib/warning.js"(exports2, module2) {
5114
5488
  "use strict";
5115
5489
  init_define_AI_KIT_FILES();
5490
+ var Container2 = require_container();
5491
+ var { my } = require_symbols();
5116
5492
  var Warning2 = class {
5117
5493
  constructor(text, opts = {}) {
5118
5494
  this.type = "warning";
5119
5495
  this.text = text;
5120
5496
  if (opts.node && opts.node.source) {
5497
+ if (!opts.node[my]) {
5498
+ Container2.rebuild(opts.node);
5499
+ }
5121
5500
  let range = opts.node.rangeBy(opts);
5122
5501
  this.line = range.start.line;
5123
5502
  this.column = range.start.column;
@@ -5293,8 +5672,14 @@ var require_lazy_result = __commonJS({
5293
5672
  };
5294
5673
  }
5295
5674
  function cleanMarks(node) {
5296
- node[isClean] = false;
5297
- if (node.nodes) node.nodes.forEach((i) => cleanMarks(i));
5675
+ let stack = [node];
5676
+ while (stack.length > 0) {
5677
+ let next = stack.pop();
5678
+ next[isClean] = false;
5679
+ if (next.nodes) {
5680
+ for (let i of next.nodes) stack.push(i);
5681
+ }
5682
+ }
5298
5683
  return node;
5299
5684
  }
5300
5685
  var postcss2 = {};
@@ -5524,6 +5909,15 @@ var require_lazy_result = __commonJS({
5524
5909
  if (opts.syntax) str = opts.syntax.stringify;
5525
5910
  if (opts.stringifier) str = opts.stringifier;
5526
5911
  if (str.stringify) str = str.stringify;
5912
+ let rootSource = this.result.root.source;
5913
+ if (opts.map === void 0 && !(rootSource && rootSource.input && rootSource.input.map)) {
5914
+ let result = "";
5915
+ str(this.result.root, (i) => {
5916
+ result += i;
5917
+ });
5918
+ this.result.css = result;
5919
+ return this.result;
5920
+ }
5527
5921
  let map = new MapGenerator(str, this.result.root, this.result.opts);
5528
5922
  let data = map.generate();
5529
5923
  this.result.css = data[0];
@@ -5615,14 +6009,19 @@ var require_lazy_result = __commonJS({
5615
6009
  }
5616
6010
  if (visit2.iterator !== 0) {
5617
6011
  let iterator = visit2.iterator;
6012
+ if (visit2.descending) {
6013
+ visit2.descending = false;
6014
+ node.indexes[iterator] += 1;
6015
+ }
5618
6016
  let child;
5619
6017
  while (child = node.nodes[node.indexes[iterator]]) {
5620
- node.indexes[iterator] += 1;
5621
6018
  if (!child[isClean]) {
5622
6019
  child[isClean] = true;
6020
+ visit2.descending = true;
5623
6021
  stack.push(toStack(child));
5624
6022
  return;
5625
6023
  }
6024
+ node.indexes[iterator] += 1;
5626
6025
  }
5627
6026
  visit2.iterator = 0;
5628
6027
  delete node.indexes[iterator];
@@ -5646,20 +6045,53 @@ var require_lazy_result = __commonJS({
5646
6045
  }
5647
6046
  walkSync(node) {
5648
6047
  node[isClean] = true;
5649
- let events = getEvents(node);
5650
- for (let event of events) {
5651
- if (event === CHILDREN) {
5652
- if (node.nodes) {
5653
- node.each((child) => {
5654
- if (!child[isClean]) this.walkSync(child);
5655
- });
6048
+ let stack = [{ eventIndex: 0, events: getEvents(node), iterator: 0, node }];
6049
+ while (stack.length > 0) {
6050
+ let visit2 = stack[stack.length - 1];
6051
+ let visitNode = visit2.node;
6052
+ if (visit2.iterator !== 0) {
6053
+ let iterator = visit2.iterator;
6054
+ if (visit2.descending) {
6055
+ visit2.descending = false;
6056
+ visitNode.indexes[iterator] += 1;
5656
6057
  }
5657
- } else {
5658
- let visitors = this.listeners[event];
5659
- if (visitors) {
5660
- if (this.visitSync(visitors, node.toProxy())) return;
6058
+ let child;
6059
+ let descended = false;
6060
+ while (child = visitNode.nodes[visitNode.indexes[iterator]]) {
6061
+ if (!child[isClean]) {
6062
+ child[isClean] = true;
6063
+ visit2.descending = true;
6064
+ stack.push({
6065
+ eventIndex: 0,
6066
+ events: getEvents(child),
6067
+ iterator: 0,
6068
+ node: child
6069
+ });
6070
+ descended = true;
6071
+ break;
6072
+ }
6073
+ visitNode.indexes[iterator] += 1;
5661
6074
  }
6075
+ if (descended) continue;
6076
+ visit2.iterator = 0;
6077
+ delete visitNode.indexes[iterator];
5662
6078
  }
6079
+ if (visit2.eventIndex < visit2.events.length) {
6080
+ let event = visit2.events[visit2.eventIndex];
6081
+ visit2.eventIndex += 1;
6082
+ if (event === CHILDREN) {
6083
+ if (visitNode.nodes && visitNode.nodes.length) {
6084
+ visit2.iterator = visitNode.getIterator();
6085
+ }
6086
+ } else {
6087
+ let visitors = this.listeners[event];
6088
+ if (visitors) {
6089
+ if (this.visitSync(visitors, visitNode.toProxy())) stack.pop();
6090
+ }
6091
+ }
6092
+ continue;
6093
+ }
6094
+ stack.pop();
5663
6095
  }
5664
6096
  }
5665
6097
  warnings() {
@@ -5733,9 +6165,8 @@ var require_no_work_result = __commonJS({
5733
6165
  this._css = css;
5734
6166
  this._opts = opts;
5735
6167
  this._map = void 0;
5736
- let root2;
5737
6168
  let str = stringify2;
5738
- this.result = new Result2(this._processor, root2, this._opts);
6169
+ this.result = new Result2(this._processor, void 0, this._opts);
5739
6170
  this.result.css = css;
5740
6171
  let self = this;
5741
6172
  Object.defineProperty(this.result, "root", {
@@ -5743,7 +6174,7 @@ var require_no_work_result = __commonJS({
5743
6174
  return self.root;
5744
6175
  }
5745
6176
  });
5746
- let map = new MapGenerator(str, root2, this._opts, css);
6177
+ let map = new MapGenerator(str, void 0, this._opts, css);
5747
6178
  if (map.isMap()) {
5748
6179
  let [generatedCSS, generatedMap] = map.generate();
5749
6180
  if (generatedCSS) {
@@ -5804,7 +6235,7 @@ var require_processor = __commonJS({
5804
6235
  var Root2 = require_root();
5805
6236
  var Processor2 = class {
5806
6237
  constructor(plugins = []) {
5807
- this.version = "8.5.6";
6238
+ this.version = "8.5.31";
5808
6239
  this.plugins = this.normalize(plugins);
5809
6240
  }
5810
6241
  normalize(plugins) {
@@ -5889,7 +6320,7 @@ var require_postcss = __commonJS({
5889
6320
  console.warn(
5890
6321
  name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"
5891
6322
  );
5892
- if (process.env.LANG && process.env.LANG.startsWith("cn")) {
6323
+ if (process.env.LANG && process.env.LANG.startsWith("zh")) {
5893
6324
  console.warn(
5894
6325
  name + ": \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:\nhttps://www.w3ctech.com/topic/2226"
5895
6326
  );
@@ -21249,7 +21680,7 @@ function showCompanionHints(names) {
21249
21680
 
21250
21681
  // cli/src/index.ts
21251
21682
  var import_picocolors4 = __toESM(require_picocolors());
21252
- var VERSION = "0.1.16";
21683
+ var VERSION = "0.1.17";
21253
21684
  var HELP = `
21254
21685
  ${import_picocolors4.default.bold("7onic")} \u2014 Add 7onic design system components to your project
21255
21686