@tbela99/css-parser 1.6.3 → 1.6.5

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 (46) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +112 -8
  3. package/dist/{lib/data → data}/properties.json.js +296 -29
  4. package/dist/{lib/data → data}/validation.json.js +6 -0
  5. package/dist/index-umd-web.js +962 -744
  6. package/dist/index.cjs +961 -744
  7. package/dist/index.d.ts +24 -6
  8. package/dist/lib/ast/expand.js +1 -1
  9. package/dist/lib/ast/features/calc.js +16 -4
  10. package/dist/lib/ast/features/if.js +2 -2
  11. package/dist/lib/ast/features/inlinecssvariables.js +3 -3
  12. package/dist/lib/ast/features/prefix.js +2 -2
  13. package/dist/lib/ast/features/shorthand.js +8 -6
  14. package/dist/lib/ast/features/transform.js +2 -2
  15. package/dist/lib/ast/math/expression.js +24 -1
  16. package/dist/lib/ast/minify.js +3 -2
  17. package/dist/lib/ast/transform/utils.js +2 -2
  18. package/dist/lib/ast/walk.js +108 -90
  19. package/dist/lib/parser/declaration/list.js +29 -26
  20. package/dist/lib/parser/declaration/map.js +186 -54
  21. package/dist/lib/parser/parse.js +11 -9
  22. package/dist/lib/parser/source.js +2 -2
  23. package/dist/lib/parser/tokenize.js +99 -124
  24. package/dist/lib/parser/utils/config.js +1 -1
  25. package/dist/lib/parser/utils/declaration.js +0 -18
  26. package/dist/lib/parser/utils/hash.js +10 -5
  27. package/dist/lib/parser/utils/selector.js +1 -1
  28. package/dist/lib/{renderer → printer}/render.js +29 -53
  29. package/dist/lib/syntax/color/a98rgb.js +1 -1
  30. package/dist/lib/syntax/color/alpha.js +19 -20
  31. package/dist/lib/syntax/color/color-mix.js +15 -14
  32. package/dist/lib/syntax/color/hex.js +4 -1
  33. package/dist/lib/syntax/color/lch.js +0 -1
  34. package/dist/lib/syntax/color/oklch.js +0 -1
  35. package/dist/lib/syntax/color/relative-color.js +11 -11
  36. package/dist/lib/syntax/color/utils/components.js +0 -20
  37. package/dist/lib/syntax/color/xyzd50.js +0 -17
  38. package/dist/lib/syntax/constants.js +6 -1
  39. package/dist/lib/syntax/syntax.js +2 -2
  40. package/dist/lib/validation/config.js +5 -33
  41. package/dist/lib/validation/match.js +52 -181
  42. package/dist/node.js +3 -3
  43. package/dist/web.js +4 -3
  44. package/package.json +6 -5
  45. /package/dist/lib/{renderer → printer}/sourcemap/lib/codec.js +0 -0
  46. /package/dist/lib/{renderer → printer}/sourcemap/sourcemap.js +0 -0
@@ -2574,6 +2574,9 @@
2574
2574
  scale: {
2575
2575
  syntax: "none | [ <number> | <percentage> ]{1,3}"
2576
2576
  },
2577
+ "scroll-axis-lock": {
2578
+ syntax: "auto | none"
2579
+ },
2577
2580
  "scroll-behavior": {
2578
2581
  syntax: "auto | smooth"
2579
2582
  },
@@ -2979,6 +2982,9 @@
2979
2982
  "will-change": {
2980
2983
  syntax: "auto | <animateable-feature>#"
2981
2984
  },
2985
+ "window-drag": {
2986
+ syntax: "none | move"
2987
+ },
2982
2988
  "word-break": {
2983
2989
  syntax: "normal | break-all | keep-all | break-word | auto-phrase"
2984
2990
  },
@@ -6423,6 +6429,11 @@
6423
6429
  * Color range definitions
6424
6430
  */
6425
6431
  const colorRange = {
6432
+ rgb: {
6433
+ r: [0, 255],
6434
+ g: [0, 255],
6435
+ b: [0, 255],
6436
+ },
6426
6437
  lab: {
6427
6438
  l: [0, 100],
6428
6439
  a: [-125, 125],
@@ -6892,13 +6903,6 @@
6892
6903
  }
6893
6904
 
6894
6905
  function getColorComponents(token) {
6895
- // if (token.typ === EnumToken.IdenTokenType) {
6896
- // if (isColor(token)) {
6897
- // parseColor(token);
6898
- // } else {
6899
- // return null;
6900
- // }
6901
- // }
6902
6906
  if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
6903
6907
  if (equalsIgnoreCase("currentcolor", token.val)) {
6904
6908
  return null;
@@ -6922,25 +6926,12 @@
6922
6926
  ].includes(child.typ)) {
6923
6927
  continue;
6924
6928
  }
6925
- // if (child.typ === EnumToken.IdenTokenType && isColor(child)) {
6926
- // parseColor(child);
6927
- // }
6928
6929
  if (child.typ === exports.EnumToken.FunctionTokenType ||
6929
6930
  child.typ === exports.EnumToken.WildCardFunctionTokenType ||
6930
6931
  child.typ === exports.EnumToken.MathFunctionTokenType) {
6931
6932
  if ("var" == child.val.toLowerCase()) {
6932
6933
  return null;
6933
6934
  }
6934
- // else {
6935
- // for (const { value } of walkValues((child as FunctionToken).chi)) {
6936
- // if (
6937
- // value.typ == EnumToken.WildCardFunctionTokenDefType &&
6938
- // "var" === (value as FunctionToken).val.toLowerCase()
6939
- // ) {
6940
- // return null;
6941
- // }
6942
- // }
6943
- // }
6944
6935
  }
6945
6936
  if (child.typ == exports.EnumToken.ColorTokenType && equalsIgnoreCase("currentcolor", child.val)) {
6946
6937
  return null;
@@ -7050,7 +7041,6 @@
7050
7041
  return lchToken(values);
7051
7042
  }
7052
7043
  function lchToken(values) {
7053
- values[2] = values[2];
7054
7044
  const chi = [
7055
7045
  { typ: exports.EnumToken.NumberTokenType, val: values[0] },
7056
7046
  { typ: exports.EnumToken.NumberTokenType, val: values[1] },
@@ -7174,23 +7164,6 @@
7174
7164
  return alpha == null ? [l, c, h] : [l, c, h, alpha];
7175
7165
  }
7176
7166
 
7177
- // export function srgb2xyzd50values(r: number, g: number, b: number, alpha: number | null = null): number[] {
7178
- // [r, g, b] = srgb2lsrgbvalues(r, g, b);
7179
- //
7180
- // const rgb: number[] = [
7181
- // 0.436065742824811 * r + 0.3851514688337912 * g + 0.14307845442264197 * b,
7182
- //
7183
- // 0.22249319175623702 * r + 0.7168870538238823 * g + 0.06061979053616537 * b,
7184
- //
7185
- // 0.013923904500943465 * r + 0.09708128566574634 * g + 0.7140993584005155 * b,
7186
- // ];
7187
- //
7188
- // if (alpha != null && alpha != 1) {
7189
- // rgb.push(alpha);
7190
- // }
7191
- //
7192
- // return rgb;
7193
- // }
7194
7167
  /*
7195
7168
  */
7196
7169
  function xyzd502lch(x, y, z, alpha) {
@@ -7337,7 +7310,6 @@
7337
7310
  return oklchToken(srgb2oklch(values[0], values[1], values[2], values[3]));
7338
7311
  }
7339
7312
  function oklchToken(values) {
7340
- values[2] = values[2];
7341
7313
  const chi = [
7342
7314
  { typ: exports.EnumToken.NumberTokenType, val: values[0] },
7343
7315
  { typ: exports.EnumToken.NumberTokenType, val: values[1] },
@@ -8255,7 +8227,10 @@
8255
8227
  if (value == null) {
8256
8228
  return null;
8257
8229
  }
8258
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
8230
+ return hexToken(value.reduce((acc, curr) => acc +
8231
+ srgb2rgb(curr + Number.EPSILON)
8232
+ .toString(16)
8233
+ .padStart(2, "0"), "#"));
8259
8234
  }
8260
8235
  function oklab2HexToken(token) {
8261
8236
  let value = oklab2srgbvalues(token);
@@ -9104,7 +9079,7 @@
9104
9079
  // convert an array of linear-light a98-rgb in the range 0.0-1.0
9105
9080
  // to gamma corrected form
9106
9081
  // negative values are also now accepted
9107
- return [r, b, g]
9082
+ return [r, g, b]
9108
9083
  .map(function (val) {
9109
9084
  let sign = val < 0 ? -1 : 1;
9110
9085
  let abs = Math.abs(val);
@@ -9240,6 +9215,9 @@
9240
9215
  if (values == null) {
9241
9216
  return null;
9242
9217
  }
9218
+ if (colorSpace == "hwb") {
9219
+ colorSpace = "srgb";
9220
+ }
9243
9221
  switch (colorSpace) {
9244
9222
  case "srgb":
9245
9223
  break;
@@ -9269,17 +9247,17 @@
9269
9247
  values = srgb2xyz_d65(values[0], values[1], values[2], values[3]);
9270
9248
  values = XYZ_D65_to_D50(values[0], values[1], values[2], values[3]);
9271
9249
  break;
9272
- case "rgb":
9273
- for (let j = 0; j < values.length; j++) {
9274
- values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9275
- }
9276
- break;
9250
+ // case "rgb":
9251
+ // for (let j = 0; j < values.length; j++) {
9252
+ // values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9253
+ // }
9254
+ // break;
9277
9255
  case "hsl":
9278
9256
  values = srgb2hslvalues(values[0], values[1], values[2], values[3]);
9279
9257
  break;
9280
- case "hwb":
9281
- values = srgb2hwb(values[0], values[1], values[2], values[3]);
9282
- break;
9258
+ // case "hwb":
9259
+ // values = srgb2hwb(values[0], values[1], values[2], values[3]);
9260
+ // break;
9283
9261
  case "lab":
9284
9262
  values = srgb2labvalues(values[0], values[1], values[2], values[3]);
9285
9263
  break;
@@ -9478,14 +9456,14 @@
9478
9456
  kin: exports.ColorType.COLOR,
9479
9457
  cal: "col",
9480
9458
  };
9481
- case "rgb":
9459
+ // case "rgb":
9482
9460
  case "hsl":
9483
- case "hwb":
9461
+ // case "hwb":
9484
9462
  case "lab":
9485
9463
  case "lch":
9486
9464
  case "oklab":
9487
9465
  case "oklch":
9488
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9466
+ if (colorSpace == "hsl") {
9489
9467
  // @ts-ignore
9490
9468
  if (values[2] < 0) {
9491
9469
  // @ts-ignore
@@ -9515,7 +9493,7 @@
9515
9493
  }),
9516
9494
  kin: exports.ColorType[colorSpace.toUpperCase().replaceAll("-", "_")],
9517
9495
  };
9518
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9496
+ if (colorSpace == "hsl") {
9519
9497
  // @ts-ignore
9520
9498
  result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
9521
9499
  // @ts-ignore
@@ -9642,20 +9620,34 @@
9642
9620
  function* walk(node, filter, reverse) {
9643
9621
  const parents = [node];
9644
9622
  const root = node;
9645
- const map = new Map();
9646
9623
  let options = filter;
9647
9624
  let isNumeric = false;
9648
- let includeValues = false;
9625
+ let children = true;
9626
+ let attributes = false;
9649
9627
  let i = 0;
9650
9628
  if (options != null && typeof options == "object") {
9651
9629
  filter = options.filter;
9652
9630
  reverse = options.reverse;
9653
- includeValues = options.inludeValues;
9631
+ attributes = options.attributes;
9632
+ children = options.children ?? true;
9654
9633
  }
9634
+ // @ts-expect-error
9635
+ const result = {
9636
+ node: null,
9637
+ parent: null,
9638
+ root,
9639
+ parents: function* () {
9640
+ let parent = node[PARENT];
9641
+ while (parent != null) {
9642
+ yield parent;
9643
+ parent = parent[PARENT];
9644
+ }
9645
+ },
9646
+ };
9655
9647
  while ((node = parents[i++])) {
9656
9648
  let option = null;
9657
9649
  if (filter != null) {
9658
- // @ts-ignore
9650
+ // @ts-expect-error
9659
9651
  option = filter(node);
9660
9652
  isNumeric = typeof option == "number";
9661
9653
  if (isNumeric) {
@@ -9668,38 +9660,43 @@
9668
9660
  }
9669
9661
  }
9670
9662
  if (!isNumeric || (option & exports.WalkerOptionEnum.Children) === 0) {
9671
- // @ts-ignore
9672
- yield {
9673
- node,
9674
- parent: map.get(node),
9675
- root,
9676
- // @ts-expect-error
9677
- parents: function* () {
9678
- let parent = map.get(node);
9679
- while (parent != null) {
9680
- yield parent;
9681
- parent = map.get(parent);
9682
- }
9683
- },
9684
- };
9663
+ result.node = node;
9664
+ // @ts-expect-error
9665
+ result.parent = node[PARENT];
9666
+ yield result;
9685
9667
  }
9686
- if (includeValues) {
9668
+ if (attributes) {
9687
9669
  if (node[TOKENS] != null) {
9688
- // @ts-ignore
9670
+ // @ts-expect-error
9689
9671
  parents.splice(i, 0, ...(reverse ? node[TOKENS].toReversed() : node[TOKENS]));
9690
- // @ts-ignore
9672
+ for (const child of node[TOKENS]) {
9673
+ if (child[PARENT] != node) {
9674
+ child[PARENT] = node;
9675
+ }
9676
+ }
9677
+ // @ts-expect-error
9691
9678
  }
9692
9679
  else if (Array.isArray(node.val)) {
9693
- // @ts-ignore
9680
+ // @ts-expect-error
9681
+ for (const val of node.val) {
9682
+ if (val[PARENT] != node) {
9683
+ val[PARENT] = node;
9684
+ }
9685
+ }
9686
+ // @ts-expect-error
9694
9687
  parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
9695
9688
  }
9696
9689
  }
9697
- // @ts-ignore
9698
- if (node["chi"] != null && (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
9699
- // @ts-ignore
9690
+ if (children &&
9691
+ // @ts-expect-error
9692
+ node["chi"] != null &&
9693
+ (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
9694
+ // @ts-expect-error
9700
9695
  parents.splice(i, 0, ...(reverse ? node.chi.toReversed() : node.chi));
9701
9696
  for (const child of node.chi) {
9702
- map.set(child, node);
9697
+ if (child[PARENT] != node) {
9698
+ child[PARENT] = node;
9699
+ }
9703
9700
  }
9704
9701
  }
9705
9702
  }
@@ -9753,8 +9750,6 @@
9753
9750
  */
9754
9751
  function* walkValues(values, root = null, filter, reverse) {
9755
9752
  const stack = values.slice();
9756
- const map = new Map();
9757
- const used = new Set();
9758
9753
  let previous = null;
9759
9754
  if (filter != null && typeof filter == "function") {
9760
9755
  filter = {
@@ -9771,31 +9766,43 @@
9771
9766
  let value;
9772
9767
  let option;
9773
9768
  let node;
9774
- // const parents: Token[] = [];
9769
+ let i = -1;
9775
9770
  const eventType = filter.event ?? exports.WalkerEvent.Enter;
9776
- while (stack.length > 0) {
9777
- value = reverse ? stack.pop() : stack.shift();
9771
+ // @ts-ignore
9772
+ const result = {
9773
+ value: null,
9774
+ parent: null,
9775
+ previousValue: null,
9776
+ nextValue: null,
9777
+ //
9778
+ root: root ?? null,
9779
+ parents: function* () {
9780
+ // @ts-ignore
9781
+ let result = root;
9782
+ while (result != null) {
9783
+ yield result;
9784
+ result = result[PARENT] ?? null;
9785
+ }
9786
+ },
9787
+ };
9788
+ while (++i < stack.length) {
9789
+ value = stack[i];
9778
9790
  option = null;
9779
- node = map.get(value) ?? null;
9780
- if (used.has(value)) {
9781
- continue;
9782
- }
9783
- used.add(value);
9784
9791
  if (filter.fn != null && eventType & exports.WalkerEvent.Enter) {
9785
9792
  const isValid = filter.type == null ||
9786
9793
  value.typ == filter.type ||
9787
9794
  (Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
9788
9795
  (typeof filter.type == "function" && filter.type(value));
9789
9796
  if (isValid) {
9790
- // @ts-ignore
9791
- option = filter.fn(value, map.get(value) ?? root, exports.WalkerEvent.Enter,
9797
+ // @ts-expect-error
9798
+ option = filter.fn(value, value[PARENT] ?? root, exports.WalkerEvent.Enter,
9792
9799
  // @ts-expect-error
9793
9800
  function* () {
9794
9801
  // @ts-expect-error
9795
- let parent = map.get(node);
9802
+ let parent = node[PARENT];
9796
9803
  while (parent != null) {
9797
9804
  yield parent;
9798
- parent = map.get(parent);
9805
+ parent = parent[PARENT] ?? null;
9799
9806
  }
9800
9807
  });
9801
9808
  isNumeric = typeof option == "number";
@@ -9805,48 +9812,30 @@
9805
9812
  if (isNumeric && option & exports.WalkerOptionEnum.Ignore) {
9806
9813
  continue;
9807
9814
  }
9808
- // @ts-ignore
9815
+ //
9809
9816
  if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
9810
9817
  const op = Array.isArray(option) ? option : [option];
9818
+ stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
9811
9819
  for (const o of op) {
9812
- map.set(o, map.get(value) ?? root);
9813
- if (reverse) {
9814
- stack.unshift(o);
9815
- }
9816
- else {
9817
- stack.push(o);
9820
+ if (o[PARENT] != value) {
9821
+ o[PARENT] = value;
9818
9822
  }
9819
9823
  }
9820
9824
  }
9821
9825
  }
9822
9826
  }
9823
- yield {
9824
- value,
9825
- parent: map.get(value) ?? root,
9826
- previousValue: previous,
9827
- nextValue: stack[0] ?? null,
9828
- // @ts-ignore
9829
- root: root ?? null,
9830
- // @ts-expect-error
9831
- parents: function* () {
9832
- // @ts-expect-error
9833
- let result = map.get(node) ?? root;
9834
- let next;
9835
- do {
9836
- yield result;
9837
- next = map.get(result) ?? root;
9838
- if (next == result) {
9839
- break;
9840
- }
9841
- result = next;
9842
- } while (result != null);
9843
- },
9844
- };
9827
+ result.value = value;
9828
+ result.parent = value[PARENT] ?? root;
9829
+ result.previousValue = previous;
9830
+ result.nextValue = stack[0] ?? null;
9831
+ yield result;
9845
9832
  if (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0) {
9846
9833
  if ("chi" in value) {
9847
9834
  const sliced = value.chi.slice();
9848
9835
  for (const child of sliced) {
9849
- map.set(child, value);
9836
+ if (child[PARENT] != value) {
9837
+ child[PARENT] = value;
9838
+ }
9850
9839
  if (reverse) {
9851
9840
  stack.unshift(child);
9852
9841
  }
@@ -9858,31 +9847,41 @@
9858
9847
  else {
9859
9848
  const values = [];
9860
9849
  if ("l" in value && value.l != null) {
9861
- // @ts-ignore
9850
+ // @ts-expect-error
9862
9851
  values.push(value.l);
9863
- // @ts-ignore
9864
- map.set(value.l, value);
9852
+ // @ts-expect-error
9853
+ if (value.l[PARENT] != value) {
9854
+ // @ts-expect-error
9855
+ value.l[PARENT] = value;
9856
+ }
9865
9857
  }
9866
9858
  if ("op" in value && typeof value.op == "object") {
9867
- // @ts-ignore
9859
+ // @ts-expect-error
9868
9860
  values.push(value.op);
9869
- // @ts-ignore
9870
- map.set(value.op, value);
9861
+ // @ts-expect-error
9862
+ if (value.op[PARENT] != value) {
9863
+ // @ts-expect-error
9864
+ value.op[PARENT] = value;
9865
+ }
9871
9866
  }
9872
9867
  if ("r" in value && value.r != null) {
9873
9868
  if (Array.isArray(value.r)) {
9874
9869
  for (const r of value.r) {
9875
- // @ts-ignore
9870
+ //
9876
9871
  values.push(r);
9877
- // @ts-ignore
9878
- map.set(r, value);
9872
+ if (r[PARENT] != value) {
9873
+ //
9874
+ r[PARENT] = value;
9875
+ }
9879
9876
  }
9880
9877
  }
9881
9878
  else {
9882
- // @ts-ignore
9879
+ //
9883
9880
  values.push(value.r);
9884
- // @ts-ignore
9885
- map.set(value.r, value);
9881
+ if (value.r[PARENT] != value) {
9882
+ //
9883
+ value.r[PARENT] = value;
9884
+ }
9886
9885
  }
9887
9886
  }
9888
9887
  if (values.length > 0) {
@@ -9904,17 +9903,14 @@
9904
9903
  (typeof filter.type == "function" && filter.type(value));
9905
9904
  if (isValid) {
9906
9905
  // @ts-ignore
9907
- option = filter.fn(value, map.get(value), exports.WalkerEvent.Leave);
9906
+ option = filter.fn(value, value[PARENT], exports.WalkerEvent.Leave);
9908
9907
  // @ts-ignore
9909
9908
  if (option != null && ("typ" in option || Array.isArray(option))) {
9910
9909
  const op = Array.isArray(option) ? option : [option];
9910
+ stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
9911
9911
  for (const o of op) {
9912
- map.set(o, map.get(value) ?? root);
9913
- if (reverse) {
9914
- stack.unshift(o);
9915
- }
9916
- else {
9917
- stack.push(o);
9912
+ if (o[PARENT] != value) {
9913
+ o[PARENT] = value;
9918
9914
  }
9919
9915
  }
9920
9916
  }
@@ -10092,6 +10088,7 @@
10092
10088
  [LOCSRCID]: nodes[0][LOCSRCID],
10093
10089
  [LOCSTA]: nodes[0][LOCSTA],
10094
10090
  [LOCEND]: nodes[0][LOCEND],
10091
+ [PARENT]: nodes[0][PARENT],
10095
10092
  },
10096
10093
  ];
10097
10094
  }
@@ -10114,6 +10111,7 @@
10114
10111
  [LOCSRCID]: nodes[i][LOCSRCID],
10115
10112
  [LOCSTA]: nodes[i][LOCSTA],
10116
10113
  [LOCEND]: nodes[i + 1][LOCEND],
10114
+ [PARENT]: nodes[i + 1][PARENT],
10117
10115
  };
10118
10116
  }
10119
10117
  else {
@@ -10123,6 +10121,7 @@
10123
10121
  [LOCSRCID]: nodes[i + 1][LOCSRCID],
10124
10122
  [LOCSTA]: nodes[i + 1][LOCSTA],
10125
10123
  [LOCEND]: nodes[i + 1][LOCEND],
10124
+ [PARENT]: nodes[i + 1][PARENT],
10126
10125
  }, exports.EnumToken.Mul);
10127
10126
  }
10128
10127
  i++;
@@ -10143,12 +10142,14 @@
10143
10142
  [LOCSRCID]: token[LOCSRCID],
10144
10143
  [LOCSTA]: token[LOCSTA],
10145
10144
  [LOCEND]: token[LOCEND],
10145
+ [PARENT]: token[PARENT],
10146
10146
  }, {
10147
10147
  ...token,
10148
10148
  val: -token.val,
10149
10149
  [LOCSRCID]: token[LOCSRCID],
10150
10150
  [LOCSTA]: token[LOCSTA],
10151
10151
  [LOCEND]: token[LOCEND],
10152
+ [PARENT]: token[PARENT],
10152
10153
  });
10153
10154
  return acc;
10154
10155
  }
@@ -10159,6 +10160,7 @@
10159
10160
  [LOCSRCID]: token[LOCSRCID],
10160
10161
  [LOCSTA]: token[LOCSTA],
10161
10162
  [LOCEND]: token[LOCEND],
10163
+ [PARENT]: token[PARENT],
10162
10164
  });
10163
10165
  }
10164
10166
  acc.push(token);
@@ -10180,6 +10182,7 @@
10180
10182
  [LOCSRCID]: l[LOCSRCID],
10181
10183
  [LOCSTA]: l[LOCSTA],
10182
10184
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10185
+ [PARENT]: l[PARENT],
10183
10186
  };
10184
10187
  if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
10185
10188
  return defaultReturn;
@@ -10252,6 +10255,7 @@
10252
10255
  [LOCSRCID]: l[LOCSRCID],
10253
10256
  [LOCSTA]: l[LOCSTA],
10254
10257
  [LOCEND]: l[LOCEND],
10258
+ [PARENT]: l[PARENT],
10255
10259
  },
10256
10260
  r: {
10257
10261
  typ: exports.EnumToken.NumberTokenType,
@@ -10259,6 +10263,7 @@
10259
10263
  [LOCSRCID]: r[LOCSRCID],
10260
10264
  [LOCSTA]: r[LOCSTA],
10261
10265
  [LOCEND]: r[LOCEND],
10266
+ [PARENT]: r[PARENT],
10262
10267
  },
10263
10268
  };
10264
10269
  }
@@ -10271,6 +10276,7 @@
10271
10276
  [LOCSRCID]: l[LOCSRCID],
10272
10277
  [LOCSTA]: l[LOCSTA],
10273
10278
  [LOCEND]: l[LOCEND],
10279
+ [PARENT]: l[PARENT],
10274
10280
  },
10275
10281
  r: {
10276
10282
  typ: exports.EnumToken.NumberTokenType,
@@ -10278,6 +10284,7 @@
10278
10284
  [LOCSRCID]: r[LOCSRCID],
10279
10285
  [LOCSTA]: r[LOCSTA],
10280
10286
  [LOCEND]: r[LOCEND],
10287
+ [PARENT]: r[PARENT],
10281
10288
  },
10282
10289
  };
10283
10290
  }
@@ -10304,6 +10311,7 @@
10304
10311
  [LOCSRCID]: l[LOCSRCID],
10305
10312
  [LOCSTA]: l[LOCSTA],
10306
10313
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10314
+ [PARENT]: l[PARENT],
10307
10315
  };
10308
10316
  if (token.typ == exports.EnumToken.IdenTokenType) {
10309
10317
  // @ts-ignore
@@ -10484,6 +10492,7 @@
10484
10492
  [LOCSRCID]: value[0][LOCSRCID],
10485
10493
  [LOCSTA]: value[0][LOCSTA],
10486
10494
  [LOCEND]: value[0][LOCEND],
10495
+ [PARENT]: value[0][PARENT],
10487
10496
  }
10488
10497
  : {
10489
10498
  typ: token.val == "sign" ? exports.EnumToken.NumberTokenType : value[0].typ,
@@ -10491,6 +10500,7 @@
10491
10500
  [LOCSRCID]: value[0][LOCSRCID],
10492
10501
  [LOCSTA]: value[0][LOCSTA],
10493
10502
  [LOCEND]: value[0][LOCEND],
10503
+ [PARENT]: value[0][PARENT],
10494
10504
  },
10495
10505
  ];
10496
10506
  }
@@ -10513,6 +10523,7 @@
10513
10523
  [LOCSRCID]: token[LOCSRCID],
10514
10524
  [LOCSTA]: token[LOCSTA],
10515
10525
  [LOCEND]: token[LOCEND],
10526
+ [PARENT]: token[PARENT],
10516
10527
  },
10517
10528
  ];
10518
10529
  }
@@ -10586,6 +10597,7 @@
10586
10597
  [LOCSRCID]: token[LOCSRCID],
10587
10598
  [LOCSTA]: token[LOCSTA],
10588
10599
  [LOCEND]: token[LOCEND],
10600
+ [PARENT]: token[PARENT],
10589
10601
  },
10590
10602
  ];
10591
10603
  }
@@ -10600,6 +10612,7 @@
10600
10612
  [LOCSRCID]: token[LOCSRCID],
10601
10613
  [LOCSTA]: token[LOCSTA],
10602
10614
  [LOCEND]: token[LOCEND],
10615
+ [PARENT]: token[PARENT],
10603
10616
  },
10604
10617
  ];
10605
10618
  }
@@ -10610,6 +10623,7 @@
10610
10623
  [LOCSRCID]: token[LOCSRCID],
10611
10624
  [LOCSTA]: token[LOCSTA],
10612
10625
  [LOCEND]: token[LOCEND],
10626
+ [PARENT]: token[PARENT],
10613
10627
  },
10614
10628
  ];
10615
10629
  }
@@ -10649,6 +10663,7 @@
10649
10663
  [LOCSRCID]: token[LOCSRCID],
10650
10664
  [LOCSTA]: token[LOCSTA],
10651
10665
  [LOCEND]: token[LOCEND],
10666
+ [PARENT]: token[PARENT],
10652
10667
  },
10653
10668
  ];
10654
10669
  }
@@ -10691,6 +10706,7 @@
10691
10706
  [LOCSRCID]: token[LOCSRCID],
10692
10707
  [LOCSTA]: token[LOCSTA],
10693
10708
  [LOCEND]: token[LOCEND],
10709
+ [PARENT]: token[PARENT],
10694
10710
  },
10695
10711
  ];
10696
10712
  }
@@ -10718,6 +10734,7 @@
10718
10734
  [LOCSRCID]: token[LOCSRCID],
10719
10735
  [LOCSTA]: token[LOCSTA],
10720
10736
  [LOCEND]: token[LOCEND],
10737
+ [PARENT]: token[PARENT],
10721
10738
  });
10722
10739
  for (const child of inlineExpression$1(token.r)) {
10723
10740
  result.push(child);
@@ -10797,6 +10814,7 @@
10797
10814
  [LOCSRCID]: token[LOCSRCID],
10798
10815
  [LOCSTA]: token[LOCSTA],
10799
10816
  [LOCEND]: token[LOCEND],
10817
+ [PARENT]: token[PARENT],
10800
10818
  };
10801
10819
  // @ts-ignore
10802
10820
  delete token.val;
@@ -10838,6 +10856,7 @@
10838
10856
  [LOCSRCID]: tokens[i - 1][LOCSRCID],
10839
10857
  [LOCSTA]: tokens[i - 1][LOCSTA],
10840
10858
  [LOCEND]: tokens[i + 1][LOCEND],
10859
+ [PARENT]: tokens[i + 1][PARENT],
10841
10860
  });
10842
10861
  i--;
10843
10862
  }
@@ -10883,20 +10902,20 @@
10883
10902
  continue;
10884
10903
  }
10885
10904
  if (component.typ == exports.EnumToken.IdenTokenType) {
10886
- val = component.val.toLowerCase();
10905
+ val = component.val;
10887
10906
  if (
10888
10907
  // @ts-expect-error
10889
10908
  typeof Math[val.toUpperCase()] !== "number" &&
10890
- val != "in" &&
10891
- val != "hue" &&
10892
- val != "from" &&
10893
- val != "alpha" &&
10894
- val != "none" &&
10895
- val != "shorter" &&
10896
- val != "longer" &&
10897
- val != "increasing" &&
10898
- val != "decreasing" &&
10899
- !colorsFunc.includes(val) &&
10909
+ !equalsIgnoreCase(val, "in") &&
10910
+ !equalsIgnoreCase(val, "hue") &&
10911
+ !equalsIgnoreCase(val, "from") &&
10912
+ !equalsIgnoreCase(val, "alpha") &&
10913
+ !equalsIgnoreCase(val, "none") &&
10914
+ !equalsIgnoreCase(val, "shorter") &&
10915
+ !equalsIgnoreCase(val, "longer") &&
10916
+ !equalsIgnoreCase(val, "increasing") &&
10917
+ !equalsIgnoreCase(val, "decreasing") &&
10918
+ !colorsFunc.some((t) => equalsIgnoreCase(t, val)) &&
10900
10919
  !colorFuncColorSpace.includes(val) &&
10901
10920
  !validKeys.includes(val)) {
10902
10921
  return null;
@@ -12039,52 +12058,24 @@
12039
12058
  // @ts-expect-error
12040
12059
  return config$4;
12041
12060
  }
12042
- // export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
12043
- // // @ts-expect-error
12044
- // let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
12045
- //
12046
- // const keys: string[] = Array.isArray(key) ? key : [key];
12047
- //
12048
- // for (let i = 0; i < keys.length; i++) {
12049
- // key = keys[i];
12050
- //
12051
- // if (!(key in obj)) {
12052
- // if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
12053
- // const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
12054
- //
12055
- // if (matches != null) {
12056
- // key = matches[1] + matches[3];
12057
- // }
12058
- // }
12059
- // }
12060
- //
12061
- // // @ts-expect-error
12062
- // obj = obj[key];
12063
- // }
12064
- //
12065
- // // @ts-expect-error
12066
- // return obj?.syntax ?? null;
12067
- // }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
12068
12061
  function findNode(group, key) {
12069
12062
  // @ts-expect-error
12070
12063
  let obj = config$4[group];
12071
- // const keys: string[] = Array.isArray(key) ? key : [key];
12072
- // for (let i = 0; i < keys.length; i++) {
12073
- // key = keys[i];
12074
- if (!(key in obj)) {
12064
+ // @ts-expect-error
12065
+ if (obj[key] == null) {
12075
12066
  if (key.charAt(0) == "@" || key.charAt(0) == "-") {
12076
12067
  const matches = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/);
12077
12068
  if (matches != null) {
12078
12069
  key = matches[1] + matches[3];
12079
12070
  }
12080
12071
  }
12081
- if (!(key in obj)) {
12072
+ // @ts-expect-error
12073
+ if (obj[key] == null) {
12082
12074
  return null;
12083
12075
  }
12084
12076
  }
12085
12077
  // @ts-expect-error
12086
12078
  obj = obj[key];
12087
- // }
12088
12079
  return obj;
12089
12080
  }
12090
12081
  const getParsedSyntax = memoize((group, key) => {
@@ -12195,6 +12186,20 @@
12195
12186
  const config$3 = getSyntaxConfig();
12196
12187
  // @ts-expect-error
12197
12188
  const allValues = config$3.declarations.all.syntax.split(/[\s|]+/g);
12189
+ const selectorNodeTypes = [
12190
+ exports.EnumToken.CommaTokenType,
12191
+ exports.EnumToken.ColumnCombinatorTokenType,
12192
+ exports.EnumToken.ChildCombinatorTokenType,
12193
+ exports.EnumToken.NextSiblingCombinatorTokenType,
12194
+ exports.EnumToken.SubsequentSiblingCombinatorTokenType,
12195
+ ];
12196
+ const trimWhitespaceBefore = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
12197
+ const trimWhitespaceAfter = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
12198
+ const selectorEnumMap = new Map([
12199
+ [exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
12200
+ [exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
12201
+ ]);
12202
+ const propertyKeywordValues = new Map();
12198
12203
  /**
12199
12204
  * @type {Array.<EnumToken>}
12200
12205
  */
@@ -12418,24 +12423,6 @@
12418
12423
  getRemainingTokens() {
12419
12424
  return this.tokens.slice(this.index + 1);
12420
12425
  },
12421
- // last() {
12422
- // let index: number = this.tokens.length - 1;
12423
- // let token: Token = this.tokens[index];
12424
- // while (
12425
- // (this.index >= 0 && token?.typ === EnumToken.WhitespaceTokenType) ||
12426
- // token?.typ === EnumToken.CommentTokenType ||
12427
- // token?.typ === EnumToken.CDOCOMMTokenType ||
12428
- // token?.typ === EnumToken.InvalidCommentTokenType ||
12429
- // token?.typ === EnumToken.BadCommentTokenType ||
12430
- // token?.typ === EnumToken.BadStringTokenType
12431
- // ) {
12432
- // token = this.tokens[--index];
12433
- // if (token == null) {
12434
- // break;
12435
- // }
12436
- // }
12437
- // return token;
12438
- // },
12439
12426
  end() {
12440
12427
  this.index = this.tokens.length + 1;
12441
12428
  return this;
@@ -12495,19 +12482,6 @@
12495
12482
  function matchSelectorSyntax(stream, errors, options, nested = true) {
12496
12483
  const stack = [];
12497
12484
  const tokens = [];
12498
- const nodes = [
12499
- exports.EnumToken.CommaTokenType,
12500
- exports.EnumToken.ColumnCombinatorTokenType,
12501
- exports.EnumToken.ChildCombinatorTokenType,
12502
- exports.EnumToken.NextSiblingCombinatorTokenType,
12503
- exports.EnumToken.SubsequentSiblingCombinatorTokenType,
12504
- ];
12505
- const trimWhitespaceBefore = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
12506
- const trimWhitespaceAfter = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
12507
- const enumMap = new Map([
12508
- [exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
12509
- [exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
12510
- ]);
12511
12485
  let token;
12512
12486
  let i = 0;
12513
12487
  let success = true;
@@ -12547,15 +12521,15 @@
12547
12521
  }
12548
12522
  tokens.push(token);
12549
12523
  if (tokensfuncDefMap.has(token.typ)) {
12550
- if (stack.length > 0 && nodes.includes(stack.at(-1).typ)) {
12524
+ if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1).typ)) {
12551
12525
  stack.pop();
12552
12526
  }
12553
12527
  stack.push(token);
12554
12528
  continue;
12555
12529
  }
12556
12530
  if (stack.length > 0 &&
12557
- nodes.includes(stack.at(-1).typ) &&
12558
- !nodes.includes(token.typ) &&
12531
+ selectorNodeTypes.includes(stack.at(-1).typ) &&
12532
+ !selectorNodeTypes.includes(token.typ) &&
12559
12533
  token.typ !== exports.EnumToken.WhitespaceTokenType &&
12560
12534
  token.typ !== exports.EnumToken.CommentTokenType &&
12561
12535
  token.typ !== exports.EnumToken.CDOCOMMTokenType) {
@@ -12601,7 +12575,7 @@
12601
12575
  break;
12602
12576
  case exports.EnumToken.Tilda:
12603
12577
  case exports.EnumToken.GtTokenType:
12604
- Object.assign(token, { typ: enumMap.get(token.typ) });
12578
+ Object.assign(token, { typ: selectorEnumMap.get(token.typ) });
12605
12579
  case exports.EnumToken.ColumnCombinatorTokenType:
12606
12580
  case exports.EnumToken.ChildCombinatorTokenType:
12607
12581
  case exports.EnumToken.UniversalSelectorTokenType:
@@ -12614,7 +12588,7 @@
12614
12588
  if (stack.length > 0 && stack.at(-1)?.typ === exports.EnumToken.UniversalSelectorTokenType) {
12615
12589
  stack.pop();
12616
12590
  }
12617
- if (stack.length > 0 && nodes.includes(stack.at(-1)?.typ)) {
12591
+ if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1)?.typ)) {
12618
12592
  return {
12619
12593
  success: false,
12620
12594
  errors: [
@@ -12724,106 +12698,10 @@
12724
12698
  };
12725
12699
  }
12726
12700
  slice.shift();
12727
- // if (slice.length > 0) {
12728
- // return {
12729
- // success: false,
12730
- // errors: [
12731
- // {
12732
- // action: "drop",
12733
- // message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOCSTA].lin}:${
12734
- // slice[0][LOCSTA].col
12735
- // }`,
12736
- // node: slice[0],
12737
- // location: slice[0][LOC],
12738
- // },
12739
- // ],
12740
- // };
12741
- // }
12742
12701
  stack.pop();
12743
12702
  break;
12744
12703
  }
12745
- // case EnumToken.ColonTokenType:
12746
- // if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
12747
- // Object.assign(token, {
12748
- // typ:
12749
- // (stream[i + 1] as IdentToken).val === "page"
12750
- // ? EnumToken.PseudoPageTokenType
12751
- // : pseudoElements.includes((token as PseudoElementToken).val)
12752
- // ? EnumToken.PseudoElementTokenType
12753
- // : EnumToken.PseudoClassTokenType,
12754
- // val: ":" + (stream[i + 1] as IdentToken).val,
12755
- // });
12756
- // token[LOC]!.end = stream[++i][LOC]!.end;
12757
- // break;
12758
- // } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
12759
- // Object.assign(token, {
12760
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12761
- // val: ":" + (stream[i + 1] as IdentToken).val,
12762
- // });
12763
- // token[LOC]!.end = stream[++i][LOC]!.end;
12764
- // stack.push(token);
12765
- // break;
12766
- // }
12767
- // return {
12768
- // success: false,
12769
- // errors: [
12770
- // {
12771
- // action: "drop",
12772
- // message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
12773
- // token[LOCSTA].col
12774
- // }`,
12775
- // node: token,
12776
- // location: token[LOC],
12777
- // },
12778
- // ],
12779
- // };
12780
- // case EnumToken.DoubleColonTokenType:
12781
- // if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
12782
- // Object.assign(token, {
12783
- // typ:
12784
- // (stream[i + 1] as IdentToken).val === "page"
12785
- // ? EnumToken.PseudoPageTokenType
12786
- // : EnumToken.PseudoElementTokenType,
12787
- // val: "::" + (stream[i + 1] as IdentToken).val,
12788
- // });
12789
- // token[LOC]!.end = stream[++i][LOC]!.end;
12790
- // break;
12791
- // } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
12792
- // Object.assign(token, {
12793
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12794
- // val: "::" + (stream[i + 1] as IdentToken).val,
12795
- // });
12796
- // token[LOC]!.end = stream[++i][LOC]!.end;
12797
- // stack.push(token);
12798
- // break;
12799
- // }
12800
- // return {
12801
- // success: false,
12802
- // errors: [
12803
- // {
12804
- // action: "drop",
12805
- // message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
12806
- // token[LOCSTA].col
12807
- // }`,
12808
- // node: token,
12809
- // location: token[LOC],
12810
- // },
12811
- // ],
12812
- // };
12813
12704
  case exports.EnumToken.StartParensTokenType:
12814
- // if (
12815
- // tokens.at(-2)?.typ === EnumToken.PseudoClassTokenType ||
12816
- // tokens.at(-2)?.typ === EnumToken.PseudoElementTokenType
12817
- // ) {
12818
- // stack.push(
12819
- // Object.assign(tokens.at(-2) as Token, {
12820
- // typ: EnumToken.PseudoClassFunctionTokenDefType,
12821
- // chi: [],
12822
- // }),
12823
- // );
12824
- // // tokens.pop();
12825
- // break;
12826
- // }
12827
12705
  return {
12828
12706
  success: false,
12829
12707
  errors: [
@@ -12843,19 +12721,6 @@
12843
12721
  if (stack.at(-1)?.typ === exports.EnumToken.PseudoClassFunctionTokenDefType ||
12844
12722
  stack.at(-1)?.typ === exports.EnumToken.PseudoElementTokenType) {
12845
12723
  const token = stack.at(-1);
12846
- // if (!((stack.at(-1) as PseudoClassFunctionToken).val + "()" in config.selectors)) {
12847
- // return {
12848
- // errors: [
12849
- // {
12850
- // action: "drop",
12851
- // message: `Unknown class element ${(token as PseudoElementToken).val}`,
12852
- // node: token,
12853
- // location: token[LOC]!,
12854
- // },
12855
- // ],
12856
- // success: false,
12857
- // };
12858
- // }
12859
12724
  const index = tokens.indexOf(token);
12860
12725
  const result = matchAllSyntaxes(getParsedSyntax(ValidationSyntaxGroupEnum.Selectors, token.val + "()")?.[0]?.chi ?? [], createValidationContext(tokens.slice(index + 1, tokens.length - 1)), options);
12861
12726
  if (!result.success) {
@@ -12954,7 +12819,8 @@
12954
12819
  for (let i = index; i < syntaxes.length; i++) {
12955
12820
  if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
12956
12821
  syntaxes[i].isOptional ||
12957
- syntaxes[i].isRepeatable) {
12822
+ syntaxes[i].isRepeatable ||
12823
+ syntaxes[i].match?.min?.val === 0) {
12958
12824
  continue;
12959
12825
  }
12960
12826
  return {
@@ -12995,6 +12861,7 @@
12995
12861
  let tmpResult;
12996
12862
  let count = 0;
12997
12863
  let range;
12864
+ let done = false;
12998
12865
  success = false;
12999
12866
  do {
13000
12867
  range = context.peekRange(exports.EnumToken.CommaTokenType, exports.EnumToken.CommaTokenType, 1);
@@ -13010,12 +12877,9 @@
13010
12877
  else {
13011
12878
  context.update(range.at(-1));
13012
12879
  }
13013
- if (context.done()) {
13014
- // context.end();
13015
- break;
13016
- }
12880
+ done = context.done();
13017
12881
  }
13018
- } while (tmpResult.success && !context.done());
12882
+ } while (tmpResult.success && !done);
13019
12883
  return result == null
13020
12884
  ? {
13021
12885
  success: false,
@@ -13053,6 +12917,9 @@
13053
12917
  context.end();
13054
12918
  break;
13055
12919
  }
12920
+ if (tmpResult.context.index === context.index) {
12921
+ break;
12922
+ }
13056
12923
  context.update(tmpResult.context.current());
13057
12924
  if (match?.max?.val != null && Number.isFinite(match?.max?.val) && count === match.max.val) {
13058
12925
  break;
@@ -13098,7 +12965,6 @@
13098
12965
  errors: [],
13099
12966
  };
13100
12967
  }
13101
- syntaxes = syntaxes.slice();
13102
12968
  let i = -1;
13103
12969
  let success = false;
13104
12970
  let token = null;
@@ -13430,21 +13296,19 @@
13430
13296
  case ValidationTokenEnum.PipeToken:
13431
13297
  {
13432
13298
  result = null;
13433
- const results = [];
13434
13299
  let tmp = null;
13435
13300
  for (const syntax of syntaxes[i].chi) {
13436
13301
  tmp = matchSyntax(syntax, context.slice(), options);
13437
13302
  if (tmp.success) {
13438
- results.push(tmp);
13303
+ if (result == null || tmp.context.index >= result.context.index) {
13304
+ result = tmp;
13305
+ }
13439
13306
  if (tmp.context.done()) {
13440
13307
  context.end();
13441
13308
  return { ...tmp, context, syntaxToken: syntaxes[i + 1] };
13442
13309
  }
13443
13310
  }
13444
13311
  }
13445
- if (results.length > 0) {
13446
- result = results.reduce((a, b) => (a.context.index > b.context.index ? a : b));
13447
- }
13448
13312
  if (result?.success) {
13449
13313
  success = true;
13450
13314
  options.visited.get(token).delete(syntaxes[i]);
@@ -13806,7 +13670,8 @@
13806
13670
  */
13807
13671
  function matchProperty(property, context, options) {
13808
13672
  let success = false;
13809
- let t = context.peek()?.typ;
13673
+ const token = context.peek();
13674
+ let t = token?.typ;
13810
13675
  let checkCalc = (t == exports.EnumToken.MathFunctionTokenDefType || t == exports.EnumToken.MathFunctionTokenType) &&
13811
13676
  [
13812
13677
  "number",
@@ -13821,19 +13686,19 @@
13821
13686
  "calc-product",
13822
13687
  ].includes(property.val);
13823
13688
  if (checkCalc && !["number", "zero", "integer", "percentage", "length-percentage"].includes(property.val)) {
13824
- checkCalc = context.peek().val === "calc";
13689
+ checkCalc = token.val === "calc";
13825
13690
  }
13826
13691
  if (checkCalc) {
13827
13692
  let result;
13828
- const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, context.peek().val + "()")?.[0]?.chi;
13693
+ const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, token.val + "()")?.[0]?.chi;
13829
13694
  if (t === exports.EnumToken.MathFunctionTokenType) {
13830
- result = matchSyntax(syntax, createValidationContext(context.peek().chi), options);
13695
+ result = matchSyntax(syntax, createValidationContext(token.chi), options);
13831
13696
  if (result.success && result.context.done()) {
13832
13697
  context.next();
13833
13698
  return {
13834
13699
  success: true,
13835
13700
  valid: true,
13836
- token: context.peek(),
13701
+ token: token,
13837
13702
  context,
13838
13703
  syntaxToken: null,
13839
13704
  errors: [],
@@ -14007,13 +13872,16 @@
14007
13872
  case "display-outside":
14008
13873
  case "display-legacy":
14009
13874
  case "content-position":
14010
- success =
14011
- context.peek()?.typ == exports.EnumToken.IdenTokenType &&
14012
- // @ts-expect-error
14013
- config$3.syntaxes[property.val].syntax
14014
- .split(/[\s|]+/)
14015
- .includes(context.peek().val.toLowerCase());
14016
- break;
13875
+ {
13876
+ let values = propertyKeywordValues.get(property.val);
13877
+ if (values == null) {
13878
+ values = new Set(config$3.syntaxes[property.val].syntax.split(/[\s|]+/));
13879
+ propertyKeywordValues.set(property.val, values);
13880
+ }
13881
+ success =
13882
+ token?.typ == exports.EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
13883
+ break;
13884
+ }
14017
13885
  case "mf-name":
14018
13886
  {
14019
13887
  const token = context.peek();
@@ -14034,9 +13902,9 @@
14034
13902
  case "counter-name":
14035
13903
  case "counter-style-name":
14036
13904
  success =
14037
- context.peek()?.typ == exports.EnumToken.IdenTokenType || context.peek()?.typ == exports.EnumToken.DashedIdenTokenType;
14038
- if (success && context.peek()?.typ === exports.EnumToken.IdenTokenType) {
14039
- const val = context.peek().val.toLowerCase();
13905
+ token?.typ == exports.EnumToken.IdenTokenType || token?.typ == exports.EnumToken.DashedIdenTokenType;
13906
+ if (success && token?.typ === exports.EnumToken.IdenTokenType) {
13907
+ const val = token.val.toLowerCase();
14040
13908
  success = "none" !== val && !allValues.includes(val);
14041
13909
  }
14042
13910
  break;
@@ -14550,7 +14418,6 @@
14550
14418
  let result = null;
14551
14419
  let tmpResult;
14552
14420
  let success = !!isRepeatable;
14553
- // let index: number = context.index;
14554
14421
  do {
14555
14422
  tmpResult = matchSyntax([rest], context.slice(), options);
14556
14423
  if (tmpResult.success) {
@@ -14560,15 +14427,10 @@
14560
14427
  context.end();
14561
14428
  break;
14562
14429
  }
14563
- // if (context.current() === tmpResult.context.current()) {
14564
- // context.next();
14565
- // } else {
14430
+ if (tmpResult.context.index === context.index) {
14431
+ break;
14432
+ }
14566
14433
  context.update(result.context.current());
14567
- // }
14568
- // if (index === context.index) {
14569
- // break;
14570
- // }
14571
- // index = context.index;
14572
14434
  }
14573
14435
  } while (tmpResult.success && !context.done());
14574
14436
  return {
@@ -14663,7 +14525,6 @@
14663
14525
  }
14664
14526
  let components = getColorComponents(color);
14665
14527
  if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
14666
- const originalAlpha = cloneNode(alpha, true);
14667
14528
  for (const { value } of walkValues(alpha.chi, alpha)) {
14668
14529
  if (value.typ === exports.EnumToken.IdenTokenType) {
14669
14530
  if (equalsIgnoreCase(value.val, "alpha")) {
@@ -14675,22 +14536,22 @@
14675
14536
  });
14676
14537
  // continue;
14677
14538
  }
14678
- else if (equalsIgnoreCase(value.val, "none")) {
14679
- Object.assign(value, {
14680
- typ: exports.EnumToken.NumberTokenType,
14681
- val: 0,
14682
- });
14683
- }
14539
+ // else if (equalsIgnoreCase((value as IdentToken).val, "none")) {
14540
+ // Object.assign(value, {
14541
+ // typ: EnumToken.NumberTokenType,
14542
+ // val: 0,
14543
+ // });
14544
+ // }
14684
14545
  }
14685
14546
  }
14686
14547
  const result = evaluate([alpha]);
14687
14548
  if (result.length == 1) {
14688
14549
  alpha = result[0];
14689
14550
  }
14690
- else {
14691
- // @ts-expect-error
14692
- alpha = originalAlpha;
14693
- }
14551
+ // else {
14552
+ // // @ts-expect-error
14553
+ // alpha = originalAlpha;
14554
+ // }
14694
14555
  }
14695
14556
  // console.error({ alpha });
14696
14557
  if (alpha.typ !== exports.EnumToken.IdenTokenType &&
@@ -14716,17 +14577,17 @@
14716
14577
  return null;
14717
14578
  }
14718
14579
  if (alpha?.typ === exports.EnumToken.IdenTokenType) {
14719
- if (equalsIgnoreCase(alpha.val, "alpha")) {
14720
- alpha = components[3] ?? {
14721
- typ: exports.EnumToken.NumberTokenType,
14722
- val: 1,
14723
- };
14724
- }
14725
- else if (equalsIgnoreCase(alpha.val, "node")) {
14726
- alpha = {
14580
+ // if (equalsIgnoreCase((alpha as IdentToken).val, "alpha")) {
14581
+ // alpha = components[3] ?? {
14582
+ // typ: EnumToken.NumberTokenType,
14583
+ // val: 1,
14584
+ // };
14585
+ // } else
14586
+ if (equalsIgnoreCase(alpha.val, "none")) {
14587
+ Object.assign(alpha, {
14727
14588
  typ: exports.EnumToken.NumberTokenType,
14728
14589
  val: 0,
14729
- };
14590
+ });
14730
14591
  }
14731
14592
  }
14732
14593
  return makeColor(color.kin, components, alpha);
@@ -15447,12 +15308,12 @@
15447
15308
  // '\\'
15448
15309
  const REVERSE_SOLIDUS = 0x5c;
15449
15310
  const flexUnits = ["fr"];
15450
- const frequencyUnits = ["hz", "khz"];
15311
+ const frequencyUnits = ["Hz", "kHz"];
15451
15312
  const timeUnits = ["ms", "s"];
15452
15313
  const angleUnits = ["rad", "turn", "deg", "grad"];
15453
15314
  const resolutionUnits = ["dpi", "dpcm", "dppx", "x"];
15454
15315
  const dimensionUnits = [
15455
- "q",
15316
+ "Q",
15456
15317
  "cap",
15457
15318
  "ch",
15458
15319
  "cm",
@@ -17136,7 +16997,7 @@
17136
16997
  }
17137
16998
  class ComputePrefixFeature {
17138
16999
  get ordering() {
17139
- return 2;
17000
+ return 0;
17140
17001
  }
17141
17002
  get processMode() {
17142
17003
  return exports.FeatureWalkMode.Pre;
@@ -17580,10 +17441,10 @@
17580
17441
  class InlineCssVariablesFeature {
17581
17442
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
17582
17443
  get ordering() {
17583
- return 0;
17444
+ return 2;
17584
17445
  }
17585
17446
  get processMode() {
17586
- return exports.FeatureWalkMode.Pre;
17447
+ return exports.FeatureWalkMode.Post;
17587
17448
  }
17588
17449
  static register(options) {
17589
17450
  if (options.inlineCssVariables) {
@@ -18177,35 +18038,6 @@
18177
18038
  "border-left-color": {
18178
18039
  map: "border",
18179
18040
  shorthand: "border-color"
18180
- },
18181
- "grid-row": {
18182
- shorthand: "grid-row",
18183
- properties: [
18184
- "grid-row-start",
18185
- "grid-row-end"
18186
- ],
18187
- types: [
18188
- "Iden",
18189
- "Number"
18190
- ],
18191
- multiple: true,
18192
- valueSeparator: {
18193
- typ: "Literal",
18194
- val: "/"
18195
- },
18196
- "default": [
18197
- "auto"
18198
- ],
18199
- keywords: [
18200
- "auto",
18201
- "span"
18202
- ]
18203
- },
18204
- "grid-row-start": {
18205
- shorthand: "grid-row"
18206
- },
18207
- "grid-row-end": {
18208
- shorthand: "grid-row"
18209
18041
  }
18210
18042
  };
18211
18043
  var map = {
@@ -19471,29 +19303,325 @@
19471
19303
  },
19472
19304
  "background-size": {
19473
19305
  shorthand: "background"
19474
- }
19475
- };
19476
- var property = {
19477
- "transform-origin": {
19478
- pattern: [
19479
- [
19480
- "left|center|right",
19481
- "top|center|bottom",
19482
- "<length>"
19483
- ],
19484
- [
19485
- "left|center|right",
19486
- "top|center|bottom"
19487
- ],
19488
- [
19489
- "center|left|right|center|top|bottom|<length>"
19490
- ]
19306
+ },
19307
+ "grid-area": {
19308
+ shorthand: "grid-area",
19309
+ pattern: "grid-row-start grid-column-start grid-row-end grid-column-end",
19310
+ keywords: [
19311
+ "auto"
19491
19312
  ],
19313
+ "default": [
19314
+ "auto"
19315
+ ],
19316
+ multiple: false,
19317
+ expandShorthands: true,
19318
+ separator: {
19319
+ typ: "Literal",
19320
+ val: "/"
19321
+ },
19492
19322
  mapping: {
19493
- center: {
19494
- typ: "Perc",
19495
- val: 50
19496
- },
19323
+ "auto/auto": "auto",
19324
+ "auto/auto/auto": "auto",
19325
+ "auto/auto/auto/auto": "auto"
19326
+ },
19327
+ expandedProperties: {
19328
+ "grid-row": [
19329
+ "grid-row-start",
19330
+ "grid-row-end"
19331
+ ],
19332
+ "grid-column": [
19333
+ "grid-column-start",
19334
+ "grid-column-end"
19335
+ ]
19336
+ },
19337
+ properties: {
19338
+ "grid-row-start": {
19339
+ map: "grid-area",
19340
+ shorthand: "grid-row",
19341
+ types: [
19342
+ "Iden",
19343
+ "Number"
19344
+ ],
19345
+ "default": [
19346
+ "auto"
19347
+ ],
19348
+ keywords: [
19349
+ "auto"
19350
+ ]
19351
+ },
19352
+ "grid-column-start": {
19353
+ map: "grid-area",
19354
+ shorthand: "grid-column",
19355
+ types: [
19356
+ "Iden",
19357
+ "Number"
19358
+ ],
19359
+ prefix: {
19360
+ typ: "Literal",
19361
+ val: "/"
19362
+ },
19363
+ "default": [
19364
+ "auto"
19365
+ ],
19366
+ keywords: [
19367
+ "auto"
19368
+ ]
19369
+ },
19370
+ "grid-row-end": {
19371
+ map: "grid-area",
19372
+ shorthand: "grid-row",
19373
+ types: [
19374
+ "Iden",
19375
+ "Number"
19376
+ ],
19377
+ prefix: {
19378
+ typ: "Literal",
19379
+ val: "/"
19380
+ },
19381
+ "default": [
19382
+ "auto"
19383
+ ],
19384
+ keywords: [
19385
+ "auto"
19386
+ ]
19387
+ },
19388
+ "grid-column-end": {
19389
+ map: "grid-area",
19390
+ shorthand: "grid-column",
19391
+ types: [
19392
+ "Iden",
19393
+ "Number"
19394
+ ],
19395
+ prefix: {
19396
+ typ: "Literal",
19397
+ val: "/"
19398
+ },
19399
+ "default": [
19400
+ "auto"
19401
+ ],
19402
+ keywords: [
19403
+ "auto"
19404
+ ]
19405
+ }
19406
+ }
19407
+ },
19408
+ "grid-row-start": {
19409
+ shorthand: "grid-row"
19410
+ },
19411
+ "grid-column-start": {
19412
+ shorthand: "grid-column"
19413
+ },
19414
+ "grid-row-end": {
19415
+ shorthand: "grid-row"
19416
+ },
19417
+ "grid-column-end": {
19418
+ shorthand: "grid-column"
19419
+ },
19420
+ "grid-row": {
19421
+ shorthand: "grid-row",
19422
+ map: "grid-area",
19423
+ pattern: "grid-row-start grid-row-end",
19424
+ types: [
19425
+ "Iden",
19426
+ "Number"
19427
+ ],
19428
+ keywords: [
19429
+ "auto"
19430
+ ],
19431
+ "default": [
19432
+ "auto"
19433
+ ],
19434
+ multiple: false,
19435
+ mapping: {
19436
+ "auto auto": "auto",
19437
+ "auto/auto": "auto"
19438
+ },
19439
+ properties: {
19440
+ "grid-row-start": {
19441
+ map: "grid-area",
19442
+ types: [
19443
+ "Iden",
19444
+ "Number"
19445
+ ],
19446
+ "default": [
19447
+ "auto"
19448
+ ],
19449
+ multiple: true,
19450
+ keywords: [
19451
+ "auto"
19452
+ ]
19453
+ },
19454
+ "grid-row-end": {
19455
+ map: "grid-area",
19456
+ types: [
19457
+ "Iden",
19458
+ "Number"
19459
+ ],
19460
+ "default": [
19461
+ "auto"
19462
+ ],
19463
+ prefix: {
19464
+ typ: "Literal",
19465
+ val: "/"
19466
+ },
19467
+ multiple: true,
19468
+ keywords: [
19469
+ "auto"
19470
+ ]
19471
+ }
19472
+ }
19473
+ },
19474
+ "grid-column": {
19475
+ shorthand: "grid-column",
19476
+ map: "grid-area",
19477
+ pattern: "grid-column-start grid-column-end",
19478
+ types: [
19479
+ "Iden",
19480
+ "Number"
19481
+ ],
19482
+ keywords: [
19483
+ "auto"
19484
+ ],
19485
+ "default": [
19486
+ "auto"
19487
+ ],
19488
+ multiple: false,
19489
+ mapping: {
19490
+ "auto/auto": "auto"
19491
+ },
19492
+ properties: {
19493
+ "grid-column-start": {
19494
+ map: "grid-area",
19495
+ types: [
19496
+ "Iden",
19497
+ "Number"
19498
+ ],
19499
+ "default": [
19500
+ "auto"
19501
+ ],
19502
+ multiple: true,
19503
+ keywords: [
19504
+ "auto"
19505
+ ]
19506
+ },
19507
+ "grid-column-end": {
19508
+ map: "grid-area",
19509
+ types: [
19510
+ "Iden",
19511
+ "Number"
19512
+ ],
19513
+ "default": [
19514
+ "auto"
19515
+ ],
19516
+ multiple: true,
19517
+ prefix: {
19518
+ typ: "Literal",
19519
+ val: "/"
19520
+ },
19521
+ keywords: [
19522
+ "auto"
19523
+ ]
19524
+ }
19525
+ }
19526
+ },
19527
+ "grid-template": {
19528
+ shorthand: "grid-template",
19529
+ pattern: "grid-template-areas grid-template-rows grid-template-columns",
19530
+ keywords: [
19531
+ "none"
19532
+ ],
19533
+ "default": [
19534
+ "none"
19535
+ ],
19536
+ multiple: false,
19537
+ mapping: {
19538
+ "none none": "none",
19539
+ "none/none": "none",
19540
+ "none none/none": "none"
19541
+ },
19542
+ properties: {
19543
+ "grid-template-areas": {
19544
+ types: [
19545
+ "String"
19546
+ ],
19547
+ "default": [
19548
+ "none"
19549
+ ],
19550
+ multiple: true,
19551
+ keywords: [
19552
+ "none",
19553
+ "auto"
19554
+ ],
19555
+ mapping: {
19556
+ }
19557
+ },
19558
+ "grid-template-rows": {
19559
+ types: [
19560
+ "Perc",
19561
+ "Iden",
19562
+ "Length",
19563
+ "Flex"
19564
+ ],
19565
+ "default": [
19566
+ "none"
19567
+ ],
19568
+ multiple: true,
19569
+ keywords: [
19570
+ "none"
19571
+ ]
19572
+ },
19573
+ "grid-template-columns": {
19574
+ types: [
19575
+ "Perc",
19576
+ "Iden",
19577
+ "Length",
19578
+ "Flex"
19579
+ ],
19580
+ "default": [
19581
+ "none"
19582
+ ],
19583
+ prefix: {
19584
+ typ: "Literal",
19585
+ val: "/"
19586
+ },
19587
+ multiple: true,
19588
+ keywords: [
19589
+ "none"
19590
+ ]
19591
+ }
19592
+ }
19593
+ },
19594
+ "grid-template-areas": {
19595
+ shorthand: "grid-template"
19596
+ },
19597
+ "grid-template-rows": {
19598
+ shorthand: "grid-template"
19599
+ },
19600
+ "grid-template-columns": {
19601
+ shorthand: "grid-template"
19602
+ }
19603
+ };
19604
+ var property = {
19605
+ "transform-origin": {
19606
+ pattern: [
19607
+ [
19608
+ "left|center|right",
19609
+ "top|center|bottom",
19610
+ "<length>"
19611
+ ],
19612
+ [
19613
+ "left|center|right",
19614
+ "top|center|bottom"
19615
+ ],
19616
+ [
19617
+ "center|left|right|center|top|bottom|<length>"
19618
+ ]
19619
+ ],
19620
+ mapping: {
19621
+ center: {
19622
+ typ: "Perc",
19623
+ val: 50
19624
+ },
19497
19625
  left: {
19498
19626
  typ: "Perc",
19499
19627
  val: 0
@@ -19566,8 +19694,8 @@
19566
19694
 
19567
19695
  const propertiesConfig = getConfig();
19568
19696
  class PropertyMap {
19569
- config;
19570
19697
  declarations;
19698
+ config;
19571
19699
  requiredCount;
19572
19700
  pattern;
19573
19701
  constructor(config) {
@@ -19581,7 +19709,7 @@
19581
19709
  }
19582
19710
  add(declaration) {
19583
19711
  if (declaration.nam == this.config.shorthand) {
19584
- this.declarations = new Map();
19712
+ this.declarations.clear();
19585
19713
  this.declarations.set(declaration.nam, declaration);
19586
19714
  this.matchTypes(declaration);
19587
19715
  }
@@ -19597,23 +19725,17 @@
19597
19725
  if (this.declarations.has(this.config.shorthand)) {
19598
19726
  const tokens = {};
19599
19727
  const values = [];
19600
- // @ts-ignore
19601
- this.declarations
19602
- .get(this.config.shorthand)
19603
- // @ts-ignore
19604
- .val.slice()
19605
- .reduce((acc, curr) => {
19728
+ const val = [[]];
19729
+ for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
19606
19730
  // @ts-ignore
19607
19731
  if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
19608
- acc.push([]);
19609
- return acc;
19732
+ val.push([]);
19733
+ continue;
19610
19734
  }
19611
19735
  // @ts-ignore
19612
- acc.at(-1).push(curr);
19613
- return acc;
19614
- }, [[]])
19615
- // @ts-ignore
19616
- .reduce((acc, list, current) => {
19736
+ val.at(-1).push(curr);
19737
+ }
19738
+ for (let current = 0; current < val.length; current++) {
19617
19739
  values.push(...this.pattern.reduce((acc, property) => {
19618
19740
  // let current: number = 0;
19619
19741
  const props = this.config.properties[property];
@@ -19628,9 +19750,7 @@
19628
19750
  // @ts-ignore
19629
19751
  acc[i][PROPERTYNAME] == property ||
19630
19752
  matchType(acc[i], props)) {
19631
- if ("prefix" in props &&
19632
- props.previous != null &&
19633
- !(props.previous in tokens)) {
19753
+ if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
19634
19754
  return acc;
19635
19755
  }
19636
19756
  if (!(property in tokens)) {
@@ -19695,9 +19815,8 @@
19695
19815
  }
19696
19816
  }
19697
19817
  return acc;
19698
- }, list));
19699
- return values;
19700
- }, []);
19818
+ }, val[current]));
19819
+ }
19701
19820
  if (values.length == 0) {
19702
19821
  this.declarations = Object.entries(tokens).reduce((acc, curr) => {
19703
19822
  acc.set(curr[0], {
@@ -19741,18 +19860,73 @@
19741
19860
  return this;
19742
19861
  }
19743
19862
  [Symbol.iterator]() {
19863
+ const propertiesMapping = { ...this.config.properties };
19864
+ const patterns = this.config.pattern.split(" ");
19865
+ let hasMapping = false;
19744
19866
  let iterable;
19745
19867
  let requiredCount = 0;
19746
19868
  let property;
19747
19869
  let isShorthand = true;
19748
- for (property of Object.keys(this.config.properties)) {
19749
- if (this.config.properties[property].required) {
19750
- if (!this.declarations.has(property)) {
19870
+ let declarations = this.declarations;
19871
+ for (const key of declarations.keys()) {
19872
+ if (declarations.has(key) && declarations.get(key) instanceof PropertyMap) {
19873
+ hasMapping = true;
19874
+ break;
19875
+ }
19876
+ }
19877
+ if (hasMapping) {
19878
+ const mapped = {};
19879
+ let key;
19880
+ for (const value of declarations.values()) {
19881
+ key = value.nam;
19882
+ if (value instanceof PropertyMap) {
19883
+ for (const [k, v] of value.declarations) {
19884
+ if (k == value.config.shorthand) {
19885
+ for (const [key, val] of Object.entries(value.config.properties)) {
19886
+ mapped[key] = cloneNode(v);
19887
+ for (let i = 0; i < v.val.length; i++) {
19888
+ // @ts-ignore
19889
+ if (key == v.val[i][PROPERTYNAME]) {
19890
+ if (mapped[key].val.length > 0) {
19891
+ mapped[key].val.push({
19892
+ typ: exports.EnumToken.WhitespaceTokenType,
19893
+ });
19894
+ }
19895
+ mapped[key].val.push(v.val[i]);
19896
+ }
19897
+ }
19898
+ if (mapped[key].val.length == 0) {
19899
+ mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
19900
+ }
19901
+ }
19902
+ }
19903
+ else {
19904
+ mapped[k] = v;
19905
+ }
19906
+ }
19907
+ }
19908
+ else {
19909
+ mapped[key] = value;
19910
+ }
19911
+ }
19912
+ // console.error(mapped);
19913
+ if (patterns.length === Object.keys(mapped).length) {
19914
+ declarations = new Map();
19915
+ for (const key of patterns) {
19916
+ if (mapped[key] != null) {
19917
+ declarations.set(key, mapped[key]);
19918
+ }
19919
+ }
19920
+ }
19921
+ }
19922
+ for (property of Object.keys(propertiesMapping)) {
19923
+ if (propertiesMapping[property].required) {
19924
+ if (!declarations.has(property)) {
19751
19925
  isShorthand = false;
19752
19926
  break;
19753
19927
  }
19754
19928
  else {
19755
- const val = (this.declarations.get(property));
19929
+ const val = declarations.get(property);
19756
19930
  if (val instanceof PropertySet && !val.isShortHand()) {
19757
19931
  isShorthand = false;
19758
19932
  break;
@@ -19764,10 +19938,10 @@
19764
19938
  }
19765
19939
  }
19766
19940
  if (requiredCount === 0) {
19767
- requiredCount = this.declarations.size;
19941
+ requiredCount = declarations.size;
19768
19942
  }
19769
19943
  if (!isShorthand || requiredCount < this.requiredCount) {
19770
- if (isShorthand && this.declarations.has(this.config.shorthand)) {
19944
+ if (isShorthand && declarations.has(this.config.shorthand)) {
19771
19945
  const cache = new Map();
19772
19946
  const removeDefaults = (declaration) => {
19773
19947
  let i;
@@ -19842,8 +20016,8 @@
19842
20016
  }
19843
20017
  return declaration;
19844
20018
  };
19845
- const values = [...this.declarations.values()].reduce((acc, curr) => {
19846
- if (curr instanceof PropertySet) {
20019
+ const values = [...declarations.values()].reduce((acc, curr) => {
20020
+ if (curr instanceof PropertySet || curr instanceof PropertyMap) {
19847
20021
  for (const declaration of curr) {
19848
20022
  acc.push(declaration);
19849
20023
  }
@@ -19883,13 +20057,13 @@
19883
20057
  }
19884
20058
  return (filtered.length > 0 ? filtered : values)[Symbol.iterator]();
19885
20059
  }
19886
- for (const declaration of this.declarations.values()) {
19887
- if (declaration instanceof PropertySet) {
20060
+ for (const declaration of declarations.values()) {
20061
+ if (declaration instanceof PropertySet || declaration instanceof PropertyMap) {
19888
20062
  continue;
19889
20063
  }
19890
20064
  const config = declaration.nam == this.config.shorthand
19891
20065
  ? this.config
19892
- : (this.config.properties[declaration.nam] ?? this.config);
20066
+ : (propertiesMapping[declaration.nam] ?? this.config);
19893
20067
  if (!("mapping" in config)) {
19894
20068
  continue;
19895
20069
  }
@@ -19906,7 +20080,7 @@
19906
20080
  }
19907
20081
  }
19908
20082
  // @ts-ignore
19909
- iterable = this.declarations.values();
20083
+ iterable = declarations.values();
19910
20084
  }
19911
20085
  else {
19912
20086
  let count = 0;
@@ -19920,19 +20094,19 @@
19920
20094
  : null;
19921
20095
  const tokens = {};
19922
20096
  // @ts-ignore
19923
- Object.entries(this.config.properties).reduce((acc, curr) => {
19924
- if (!this.declarations.has(curr[0])) {
20097
+ Object.entries(propertiesMapping).reduce((acc, curr) => {
20098
+ if (!declarations.has(curr[0])) {
19925
20099
  if (curr[1].required) {
19926
20100
  acc.push(curr[0]);
19927
20101
  }
19928
20102
  return acc;
19929
20103
  }
19930
20104
  let current = 0;
19931
- const props = this.config.properties[curr[0]];
19932
- const properties = (this.declarations.get(curr[0]));
19933
- for (const declaration of [
19934
- properties instanceof PropertySet ? [...properties][0] : properties,
19935
- ]) {
20105
+ const props = propertiesMapping[curr[0]];
20106
+ const properties = (declarations.get(curr[0]));
20107
+ for (const declaration of properties instanceof PropertySet || properties instanceof PropertyMap
20108
+ ? [...properties].flat()
20109
+ : [properties]) {
19936
20110
  // @ts-ignore
19937
20111
  for (const val of declaration.val) {
19938
20112
  // @ts-ignore
@@ -19979,9 +20153,45 @@
19979
20153
  }
19980
20154
  return acc;
19981
20155
  }, []);
20156
+ // grid-template
20157
+ if (this.config.shorthand == "grid-template" && patterns.length == Object.keys(tokens).length) {
20158
+ const k = tokens[patterns[0]][0].length;
20159
+ const l = tokens[patterns[1]][0].length;
20160
+ const j = k < l ? k : l;
20161
+ const result = [];
20162
+ let i;
20163
+ for (i = 0; i < j; i++) {
20164
+ if (i < k) {
20165
+ result.push(tokens[patterns[0]][0][i]);
20166
+ }
20167
+ if (i < l) {
20168
+ result.push(tokens[patterns[1]][0][i]);
20169
+ }
20170
+ }
20171
+ if (j < k) {
20172
+ result.push(...tokens[patterns[0]][0].slice(j));
20173
+ }
20174
+ if (j < l) {
20175
+ result.push(...tokens[patterns[1]][0].slice(j));
20176
+ }
20177
+ const separator = this.config.properties[patterns[2]]?.prefix;
20178
+ result.push(
20179
+ // @ts-ignore
20180
+ { ...separator, typ: exports.EnumToken[separator.typ] }, ...tokens[patterns[2]][0].reduce((acc, curr) => {
20181
+ if (acc.length > 0) {
20182
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20183
+ }
20184
+ acc.push(curr);
20185
+ return acc;
20186
+ }, []));
20187
+ const declaration = cloneNode(declarations.get(patterns[0]));
20188
+ declaration.nam = this.config.shorthand;
20189
+ declaration.val = result;
20190
+ return [declaration][Symbol.iterator]();
20191
+ }
19982
20192
  count++;
19983
20193
  if (!isShorthand ||
19984
- Object.entries(this.config.properties).some((entry) => {
20194
+ Object.entries(propertiesMapping).some((entry) => {
19985
20195
  // missing required property
19986
20196
  return entry[1].required && !(entry[0] in tokens);
19987
20197
  }) ||
@@ -19990,27 +20200,74 @@
19990
20200
  // @ts-expect-error
19991
20201
  v.filter((t) => t.typ != exports.EnumToken.CommentTokenType).length === count)) {
19992
20202
  // @ts-ignore
19993
- iterable = this.declarations.values();
20203
+ iterable = declarations.values();
20204
+ }
20205
+ else if (hasMapping) {
20206
+ if (patterns.length == Object.keys(tokens).length) {
20207
+ const declaration = cloneNode(declarations.get(patterns[0]));
20208
+ declaration.nam = this.config.shorthand;
20209
+ for (let i = 0; i < patterns.length; i++) {
20210
+ if (declaration.val.length > 0) {
20211
+ declaration.val.push(
20212
+ // @ts-ignore
20213
+ this.config.separator != null
20214
+ ? {
20215
+ ...this.config.separator,
20216
+ typ: exports.EnumToken[this.config.separator.typ],
20217
+ }
20218
+ : { typ: exports.EnumToken.WhitespaceTokenType });
20219
+ }
20220
+ declaration.val.push(...tokens[patterns[i]].reduce((acc, curr) => {
20221
+ if (acc.length > 0) {
20222
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20223
+ }
20224
+ acc.push(...curr.reduce((acc, curr) => {
20225
+ if (acc.length > 0) {
20226
+ acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20227
+ }
20228
+ acc.push(curr);
20229
+ return acc;
20230
+ }, []));
20231
+ return acc;
20232
+ }, []));
20233
+ }
20234
+ return [declaration][Symbol.iterator]();
20235
+ }
20236
+ iterable = declarations.values();
19994
20237
  }
19995
20238
  else {
19996
20239
  let values = Object.entries(tokens)
19997
20240
  .reduce((acc, curr) => {
19998
- const props = this.config.properties[curr[0]];
20241
+ const props = propertiesMapping[curr[0]];
19999
20242
  for (let i = 0; i < curr[1].length; i++) {
20000
20243
  if (acc.length == i) {
20001
20244
  acc.push([]);
20002
20245
  }
20003
- let values = curr[1][i].reduce((acc, curr) => {
20004
- if (acc.length > 0) {
20005
- acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
20006
- }
20007
- acc.push(curr);
20008
- return acc;
20009
- }, []);
20246
+ // if (acc[acc.length - 1].length > 0) {
20247
+ // acc[acc.length - 1].push(
20248
+ // // @ts-ignore
20249
+ // this.config.separator != null ?
20250
+ // {
20251
+ // ...this.config.separator,
20252
+ // typ: EnumToken[this.config.separator.typ as keyof typeof EnumToken],
20253
+ // } : <Token>{ typ: EnumToken.WhitespaceTokenType },
20254
+ // )
20255
+ // }
20256
+ let values = curr[1][i];
20257
+ // .reduce(
20258
+ // (acc, curr) => {
20259
+ // // if (acc.length > 0) {
20260
+ // // acc.push(<Token>{ typ: EnumToken.WhitespaceTokenType });
20261
+ // // }
20262
+ // acc.push(curr);
20263
+ // return acc;
20264
+ // },
20265
+ // <Token[]>[],
20266
+ // );
20010
20267
  if (props.default.includes(curr[1][i]
20011
20268
  .reduce((acc, curr) => acc + renderValue(curr) + " ", "")
20012
20269
  .trimEnd())) {
20013
- if (!this.config.properties[curr[0]].required) {
20270
+ if (!propertiesMapping[curr[0]].required) {
20014
20271
  continue;
20015
20272
  }
20016
20273
  }
@@ -20024,7 +20281,7 @@
20024
20281
  exports.EnumToken.IdenTokenType,
20025
20282
  ].includes(v.typ) ||
20026
20283
  (v.typ == exports.EnumToken.IdenTokenType &&
20027
- !this.config.properties[curr[0]].default.includes(v.val))) {
20284
+ !propertiesMapping[curr[0]].default.includes(v.val))) {
20028
20285
  doFilterDefault = false;
20029
20286
  break;
20030
20287
  }
@@ -20041,7 +20298,7 @@
20041
20298
  props.default.includes(val.val)));
20042
20299
  });
20043
20300
  if (filtered.length > 0 ||
20044
- !(this.requiredCount == requiredCount && this.config.properties[curr[0]].required)) {
20301
+ !(this.requiredCount == requiredCount && propertiesMapping[curr[0]].required)) {
20045
20302
  values = filtered;
20046
20303
  }
20047
20304
  if (values.length > 0) {
@@ -20066,6 +20323,7 @@
20066
20323
  acc[i].push({ ...props.prefix, typ: exports.EnumToken[props.prefix.typ] });
20067
20324
  }
20068
20325
  else if (acc[i].length > 0) {
20326
+ // @ts-ignore
20069
20327
  acc[i].push({ typ: exports.EnumToken.WhitespaceTokenType });
20070
20328
  }
20071
20329
  for (const v of values.reduce((acc, curr) => {
@@ -20143,6 +20401,7 @@
20143
20401
  }
20144
20402
  }
20145
20403
  const iterators = [];
20404
+ // @ts-ignore
20146
20405
  return {
20147
20406
  // @ts-ignore
20148
20407
  next() {
@@ -20299,12 +20558,17 @@
20299
20558
  return String(input);
20300
20559
  }
20301
20560
  if (Array.isArray(input)) {
20302
- return JSON.stringify(input.map(toSortedString));
20561
+ const result = new Array(input.length);
20562
+ for (const value of input) {
20563
+ result.push(toSortedString(value));
20564
+ }
20565
+ return JSON.stringify(result);
20566
+ }
20567
+ const keys = Object.keys(input).sort();
20568
+ for (let i = 0; i < keys.length; i++) {
20569
+ keys[i] = `${keys[i]}:${toSortedString(input[keys[i]])}`;
20303
20570
  }
20304
- return `{${Object.keys(input)
20305
- .sort()
20306
- .map((k) => `${k}:${toSortedString(input[k])}`)
20307
- .join(",")}}`;
20571
+ return `{${keys.join(",")}}`;
20308
20572
  }
20309
20573
  /**
20310
20574
  * Object hash
@@ -20390,6 +20654,9 @@
20390
20654
  }
20391
20655
 
20392
20656
  const config = getConfig();
20657
+ /**
20658
+ * Represents a list of property declarations, compute shorthand and remove duplicate declarations.
20659
+ */
20393
20660
  class PropertyList {
20394
20661
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
20395
20662
  declarations;
@@ -20397,14 +20664,7 @@
20397
20664
  this.options = options;
20398
20665
  this.declarations = new Map();
20399
20666
  }
20400
- // set(nam: string, value: string | Token[]) {
20401
- // return this.add({
20402
- // typ: EnumToken.DeclarationNodeType,
20403
- // nam,
20404
- // val: Array.isArray(value) ? value : parseString(String(value)),
20405
- // });
20406
- // }
20407
- add(...declarations) {
20667
+ add(declarations) {
20408
20668
  let name;
20409
20669
  let syntaxRules = null;
20410
20670
  let result;
@@ -20442,22 +20702,8 @@
20442
20702
  }
20443
20703
  // do not compute shorthand for invalid declarations
20444
20704
  if (declaration[STATE] !== exports.EnumAstNodeStatus.Validated) {
20445
- // const key = objectHash(declaration);
20446
- // if (!this.ketsey.has(key)) {
20447
- // this.ketsey.set(key, [declaration.nam]);
20448
- // console.error(
20449
- // `Adding declaration : ${(<AstDeclaration>declaration).nam} with key : ${key}`
20450
- // )
20451
- // }
20452
- // else {
20453
- // console.error(
20454
- // `Duplicate declaration found: ${(<AstDeclaration>declaration).nam} with key : [ ${key} => ${this.ketsey.get(key)} ]`
20455
- // )
20456
- // console.error(JSON.stringify(toSortedString(declaration)))
20457
- // this.ketsey.get(key).push(declaration.nam);
20458
- // }
20459
20705
  this.declarations.set(objectHash(declaration), declaration);
20460
- return this;
20706
+ continue;
20461
20707
  }
20462
20708
  let propertyName = declaration.nam;
20463
20709
  let shortHandType;
@@ -20487,13 +20733,33 @@
20487
20733
  }
20488
20734
  // @ts-ignore
20489
20735
  if (shortHandType == "map") {
20736
+ let owner = this;
20737
+ const mapName =
20490
20738
  // @ts-ignore
20491
- if (!this.declarations.has(shorthand)) {
20739
+ config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
20740
+ if (typeof mapName === "string") {
20741
+ if (!this.declarations.has(mapName)) {
20742
+ // @ts-ignore
20743
+ this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
20744
+ }
20745
+ owner = this.declarations.get(mapName);
20746
+ }
20747
+ else if (!this.declarations.has(shorthand)) {
20492
20748
  // @ts-ignore
20493
20749
  this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20494
20750
  }
20495
- // @ts-ignore
20496
- this.declarations.get(shorthand).add(declaration);
20751
+ if (owner == this) {
20752
+ // @ts-ignore
20753
+ owner.declarations.get(shorthand).add(declaration);
20754
+ }
20755
+ else {
20756
+ if (!owner.declarations.has(shorthand)) {
20757
+ // @ts-ignore
20758
+ owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20759
+ }
20760
+ // @ts-ignore
20761
+ owner.declarations.get(shorthand).add(declaration);
20762
+ }
20497
20763
  }
20498
20764
  // @ts-ignore
20499
20765
  else if (shortHandType == "set") {
@@ -20580,6 +20846,7 @@
20580
20846
  [Symbol.iterator]() {
20581
20847
  let iterator = this.declarations.values();
20582
20848
  const iterators = [];
20849
+ // @ts-ignore
20583
20850
  return {
20584
20851
  next() {
20585
20852
  let value = iterator.next();
@@ -20610,7 +20877,7 @@
20610
20877
  exports.EnumToken.KeyframesRuleNodeType,
20611
20878
  ]);
20612
20879
  get ordering() {
20613
- return 10;
20880
+ return 5;
20614
20881
  }
20615
20882
  get processMode() {
20616
20883
  return exports.FeatureWalkMode.Post;
@@ -20629,8 +20896,8 @@
20629
20896
  const j = ast.chi.length;
20630
20897
  let k = 0;
20631
20898
  let l;
20632
- let properties = new PropertyList(options);
20633
20899
  const rules = [];
20900
+ const declarations = [];
20634
20901
  // @ts-ignore
20635
20902
  for (; k < j; k++) {
20636
20903
  l = k;
@@ -20648,7 +20915,7 @@
20648
20915
  const node = ast.chi[l];
20649
20916
  if (node.typ == exports.EnumToken.DeclarationNodeType) {
20650
20917
  for (let m = k; m <= l; m++) {
20651
- properties.add(ast.chi[m]);
20918
+ declarations.push(ast.chi[m]);
20652
20919
  }
20653
20920
  }
20654
20921
  else {
@@ -20658,9 +20925,11 @@
20658
20925
  }
20659
20926
  k = l;
20660
20927
  }
20661
- ast.chi.length = 0;
20662
- // @ts-expect-error
20663
- ast.chi.push(...properties, ...rules);
20928
+ if (declarations.length > 0) {
20929
+ ast.chi.length = 0;
20930
+ // @ts-expect-error
20931
+ ast.chi.push(...new PropertyList(options).add(declarations), ...rules);
20932
+ }
20664
20933
  return ast;
20665
20934
  }
20666
20935
  }
@@ -20766,7 +21035,7 @@
20766
21035
  class ComputeCalcExpressionFeature {
20767
21036
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
20768
21037
  get ordering() {
20769
- return 1;
21038
+ return 3;
20770
21039
  }
20771
21040
  get processMode() {
20772
21041
  return exports.FeatureWalkMode.Post;
@@ -20791,8 +21060,20 @@
20791
21060
  continue;
20792
21061
  }
20793
21062
  if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
20794
- // @ts-ignore
20795
- replaceNodeOrValue(parent, value, evaluate([value]));
21063
+ const result = evaluate([value]);
21064
+ try {
21065
+ // @ts-ignore
21066
+ replaceNodeOrValue(parent, value, result);
21067
+ }
21068
+ catch (e) {
21069
+ // @ts-ignore
21070
+ if (Array.isArray(parent.chi)) {
21071
+ // @ts-ignore
21072
+ parent.chi.length = 0;
21073
+ // @ts-ignore
21074
+ parent.chi.push(...result);
21075
+ }
21076
+ }
20796
21077
  continue;
20797
21078
  }
20798
21079
  if (value != null && tokensfuncSet.has(value.typ)) {
@@ -20810,7 +21091,7 @@
20810
21091
  ? value.val
20811
21092
  : value.chi;
20812
21093
  const values = evaluate(cp);
20813
- // fix a + -b to a - b
21094
+ // fix a + -b into a - b
20814
21095
  for (const { value, parent: p } of walkValues(values)) {
20815
21096
  if (value.typ === exports.EnumToken.BinaryExpressionTokenType) {
20816
21097
  if (value.op === exports.EnumToken.Add &&
@@ -20875,7 +21156,7 @@
20875
21156
  }
20876
21157
  }
20877
21158
 
20878
- const identityMatrix = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
21159
+ const identityMatrix = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
20879
21160
  function identity() {
20880
21161
  return identityMatrix.slice();
20881
21162
  }
@@ -20891,7 +21172,7 @@
20891
21172
  return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
20892
21173
  }
20893
21174
  function multiply(matrixA, matrixB) {
20894
- const result = new Float32Array(16);
21175
+ const result = new Float64Array(16);
20895
21176
  result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
20896
21177
  result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
20897
21178
  result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
@@ -22076,7 +22357,7 @@
22076
22357
  exports.EnumToken.KeyframesRuleNodeType,
22077
22358
  ]);
22078
22359
  get ordering() {
22079
- return 3;
22360
+ return 4;
22080
22361
  }
22081
22362
  get processMode() {
22082
22363
  return exports.FeatureWalkMode.Post;
@@ -22479,7 +22760,7 @@
22479
22760
  class ExpandIfFeature {
22480
22761
  accept = new Set([exports.EnumToken.DeclarationNodeType]);
22481
22762
  get ordering() {
22482
- return 4;
22763
+ return 1;
22483
22764
  }
22484
22765
  get processMode() {
22485
22766
  return exports.FeatureWalkMode.Pre;
@@ -23281,7 +23562,8 @@
23281
23562
  previous = node;
23282
23563
  nodeIndex = i;
23283
23564
  }
23284
- if (recursive && node != null && "chi" in node) {
23565
+ // @ts-ignore
23566
+ if (recursive && node != null && node.chi != null) {
23285
23567
  if (node.typ == exports.EnumToken.KeyframesAtRuleNodeType ||
23286
23568
  !node.chi.some((n) => n.typ == exports.EnumToken.DeclarationNodeType)) {
23287
23569
  if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != "font-face")) {
@@ -24979,7 +25261,6 @@
24979
25261
  * Source file helper class
24980
25262
  */
24981
25263
  class SourceFile {
24982
- inputSourceMap = null;
24983
25264
  /**
24984
25265
  * Source file ID
24985
25266
  */
@@ -24996,6 +25277,7 @@
24996
25277
  * Source file content
24997
25278
  */
24998
25279
  content;
25280
+ inputSourceMap = null;
24999
25281
  /**
25000
25282
  * Constructor
25001
25283
  * @param content
@@ -25114,6 +25396,7 @@
25114
25396
  removeEmpty: false,
25115
25397
  removeComments: false,
25116
25398
  }),
25399
+ minifyValues: true,
25117
25400
  sourcemap: false,
25118
25401
  convertColor: true,
25119
25402
  expandNestingRules: false,
@@ -25177,7 +25460,7 @@
25177
25460
  }
25178
25461
  return acc + curr.val;
25179
25462
  }
25180
- return acc + renderValue(curr, options, cache, reducer, errors);
25463
+ return acc + renderValue(curr, options, cache, reducer);
25181
25464
  }, cache),
25182
25465
  errors,
25183
25466
  stats: {
@@ -25353,7 +25636,7 @@
25353
25636
  const indentSub = indents[level + 1];
25354
25637
  switch (data.typ) {
25355
25638
  case exports.EnumToken.DeclarationNodeType:
25356
- return `${data.nam}:${options.indent}${(options.minify
25639
+ return `${data.nam}:${options.indent}${(options.minifyValues
25357
25640
  ? filterValues(data.val)
25358
25641
  : data.val).reduce(reducer, "")}`;
25359
25642
  case exports.EnumToken.CommentNodeType:
@@ -25408,7 +25691,7 @@
25408
25691
  : node.val;
25409
25692
  }
25410
25693
  else if (node.typ == exports.EnumToken.DeclarationNodeType) {
25411
- str = `${node.nam}:${options.indent}${(options.minify
25694
+ str = `${node.nam}:${options.indent}${(options.minifyValues
25412
25695
  ? filterValues(node.val)
25413
25696
  : node.val)
25414
25697
  .reduce(reducer, "")
@@ -25476,9 +25759,10 @@
25476
25759
  function renderValue(token, options = {}, cache = Object.create(null), reducer, errors) {
25477
25760
  if (token.typ === exports.EnumToken.WhenElseFunctionTokenType &&
25478
25761
  equalsIgnoreCase(token.val, "supports")) {
25479
- options = { ...options, minify: false, convertColor: false };
25762
+ options = { ...options, minifyValues: false, minify: false, convertColor: false };
25480
25763
  reducer = null;
25481
25764
  }
25765
+ options.minifyValues ??= options.minify;
25482
25766
  if (reducer == null) {
25483
25767
  reducer = function (acc, curr) {
25484
25768
  if (curr.typ == exports.EnumToken.CommentTokenType && options.removeComments) {
@@ -25487,7 +25771,7 @@
25487
25771
  }
25488
25772
  return acc + curr.val;
25489
25773
  }
25490
- return acc + renderValue(curr, options, cache, reducer, errors);
25774
+ return acc + renderValue(curr, options, cache, reducer);
25491
25775
  };
25492
25776
  }
25493
25777
  switch (token.typ) {
@@ -25635,7 +25919,7 @@
25635
25919
  ")");
25636
25920
  }
25637
25921
  case exports.EnumToken.UrlFunctionTokenType:
25638
- if (options.minify && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25922
+ if (options.minifyValues && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25639
25923
  if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
25640
25924
  return "url()";
25641
25925
  }
@@ -25656,7 +25940,7 @@
25656
25940
  case exports.EnumToken.FunctionTokenType:
25657
25941
  case exports.EnumToken.MathFunctionTokenType:
25658
25942
  case exports.EnumToken.ImageFunctionTokenType:
25659
- if (options.minify && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25943
+ if (options.minifyValues && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25660
25944
  const slice = token.chi.slice();
25661
25945
  switch (token.val) {
25662
25946
  case "linear-gradient":
@@ -26142,37 +26426,7 @@
26142
26426
  renderValue(curr, token.typ == exports.EnumToken.FunctionTokenType ? { minify: false } : options, cache, reducer), "") +
26143
26427
  ")");
26144
26428
  }
26145
- return (
26146
- /* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/ (token.val ?? "") +
26147
- "(" +
26148
- token.chi.reduce(reducer, "") +
26149
- ")");
26150
- // case EnumToken.MatchExpressionTokenType:
26151
- // return (
26152
- // renderValue((token as MatchExpressionToken).l as Token, options, cache, reducer, errors) +
26153
- // renderValue((token as MatchExpressionToken).op, options, cache, reducer, errors) +
26154
- // renderValue((token as MatchExpressionToken).r, options, cache, reducer, errors) +
26155
- // ((token as MatchExpressionToken).attr ? " " + (token as MatchExpressionToken).attr : "")
26156
- // );
26157
- // case EnumToken.NameSpaceAttributeTokenType:
26158
- // return (
26159
- // ((token as NameSpaceAttributeToken).l == null
26160
- // ? ""
26161
- // : renderValue((token as NameSpaceAttributeToken).l as Token, options, cache, reducer, errors)) +
26162
- // "|" +
26163
- // renderValue((token as NameSpaceAttributeToken).r, options, cache, reducer, errors)
26164
- // );
26165
- // case EnumToken.ComposesSelectorNodeType:
26166
- // return (
26167
- // (token as ComposesSelectorToken).l.reduce(
26168
- // (acc: string, curr: Token) => acc + renderValue(curr, options, cache),
26169
- // "",
26170
- // ) +
26171
- // ((token as ComposesSelectorToken).r == null
26172
- // ? ""
26173
- // : " from " +
26174
- // renderValue((token as ComposesSelectorToken).r as Token, options, cache, reducer, errors))
26175
- // );
26429
+ return (token.val ?? "") + "(" + token.chi.reduce(reducer, "") + ")";
26176
26430
  case exports.EnumToken.BlockStartTokenType:
26177
26431
  return "{";
26178
26432
  case exports.EnumToken.BlockEndTokenType:
@@ -26321,7 +26575,11 @@
26321
26575
  const perc = token.val.typ == exports.EnumToken.FractionTokenType
26322
26576
  ? renderValue(token.val, options, cache)
26323
26577
  : minifyNumber(token.val);
26324
- return options.minify && perc == "0" ? "0" : perc.includes("/") ? perc.replace("/", uni + "/") : perc + uni;
26578
+ return options.minifyValues && perc == "0"
26579
+ ? "0"
26580
+ : perc.includes("/")
26581
+ ? perc.replace("/", uni + "/")
26582
+ : perc + uni;
26325
26583
  case exports.EnumToken.NumberTokenType:
26326
26584
  return token.val.typ == exports.EnumToken.FractionTokenType
26327
26585
  ? renderValue(token.val, options, cache)
@@ -26365,30 +26623,30 @@
26365
26623
  return token.val;
26366
26624
  case exports.EnumToken.SupportsQueryUnaryConditionTokenType:
26367
26625
  case exports.EnumToken.WhenElseUnaryConditionTokenType:
26368
- return (renderValue(token.l, options, cache, reducer, errors) +
26626
+ return (renderValue(token.l, options, cache, reducer) +
26369
26627
  " " +
26370
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), ""));
26628
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
26371
26629
  case exports.EnumToken.SupportsQueryConditionTokenType:
26372
26630
  case exports.EnumToken.WhenElseQueryConditionTokenType:
26373
- return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26631
+ return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26374
26632
  " " +
26375
- renderValue(token.op, options, cache, reducer, errors) +
26633
+ renderValue(token.op, options, cache, reducer) +
26376
26634
  " " +
26377
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), ""));
26635
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
26378
26636
  case exports.EnumToken.IfConditionTokenType:
26379
26637
  return token.l.length == 0
26380
26638
  ? ""
26381
- : token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26639
+ : token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26382
26640
  ":" +
26383
- token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "");
26641
+ token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "");
26384
26642
  case exports.EnumToken.IfElseConditionTokenType:
26385
26643
  return renderValue(token.l) + renderValue(token.r);
26386
26644
  case exports.EnumToken.DeclarationNodeType:
26387
26645
  return (token.nam +
26388
26646
  ":" +
26389
- (options.minify ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26647
+ (options.minifyValues ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26390
26648
  case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
26391
- return (renderValue(token.l, options, cache, reducer, errors) +
26649
+ return (renderValue(token.l, options, cache, reducer) +
26392
26650
  " " +
26393
26651
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26394
26652
  case exports.EnumToken.MediaQueryConditionTokenType: {
@@ -26400,16 +26658,16 @@
26400
26658
  token.op.typ == exports.EnumToken.GteTokenType
26401
26659
  ? ""
26402
26660
  : " ";
26403
- return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26661
+ return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26404
26662
  indent +
26405
- renderValue(token.op, options, cache, reducer, errors) +
26663
+ renderValue(token.op, options, cache, reducer) +
26406
26664
  indent +
26407
26665
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26408
26666
  }
26409
26667
  case exports.EnumToken.MediaRangeQueryTokenType:
26410
26668
  return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache), "") +
26411
26669
  renderValue(token.op1) +
26412
- token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer, errors), "") +
26670
+ token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
26413
26671
  renderValue(token.op2) +
26414
26672
  token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26415
26673
  case exports.EnumToken.MediaFeatureTokenType:
@@ -26434,8 +26692,8 @@
26434
26692
  console.debug({ token });
26435
26693
  throw new Error(`Unsupported token type for ${exports.EnumToken[token.typ]}`);
26436
26694
  }
26437
- errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
26438
- return "";
26695
+ // errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
26696
+ // return "";
26439
26697
  }
26440
26698
  /**
26441
26699
  * Remove whitespace tokens that are not needed
@@ -26460,6 +26718,7 @@
26460
26718
  }
26461
26719
 
26462
26720
  const SymbolsMapTokens = Object.create(null);
26721
+ const SymbolsMapTokensLower = Object.create(null);
26463
26722
  // Regex for escape sequence decoding - compile once, reuse many times
26464
26723
  const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
26465
26724
  function decodeEscapeSequences(value) {
@@ -26488,7 +26747,9 @@
26488
26747
  }
26489
26748
  function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
26490
26749
  for (const entry of entries) {
26491
- SymbolsMapTokens[(lowercase ? entry.toLowerCase() : entry) + suffix] = tokenType;
26750
+ const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
26751
+ SymbolsMapTokens[key] = tokenType;
26752
+ SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
26492
26753
  }
26493
26754
  }
26494
26755
  SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
@@ -26588,20 +26849,24 @@
26588
26849
  })(TokenMap || (TokenMap = {}));
26589
26850
  function getSymbolHint(parseInfo, start, end) {
26590
26851
  const len = end - start;
26591
- const keysLength = SymbolsMapTokensKeys.length;
26592
- // Early exit for impossible lengths
26593
- if (len < 0)
26852
+ if (len <= 0)
26594
26853
  return null;
26854
+ const value = parseInfo.stream.slice(start, end);
26855
+ // Direct lookup handles the hottest punctuation and keyword cases without
26856
+ // scanning the entire symbol table on every token.
26857
+ const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
26858
+ if (match != null) {
26859
+ return match;
26860
+ }
26861
+ const keysLength = SymbolsMapTokensKeys.length;
26595
26862
  for (let i = 0; i < keysLength; i++) {
26596
26863
  const key = SymbolsMapTokensKeys[i];
26597
26864
  if (key.length !== len)
26598
26865
  continue;
26599
- // Match character by character
26600
26866
  let match = true;
26601
26867
  for (let j = 0; j < len; j++) {
26602
26868
  let ca = key.charCodeAt(j);
26603
- let cb = parseInfo.stream.charCodeAt(start + j);
26604
- // Normalize A-Z to a-z
26869
+ let cb = value.charCodeAt(j);
26605
26870
  if (ca >= 65 && ca <= 90)
26606
26871
  ca += 32;
26607
26872
  if (cb >= 65 && cb <= 90)
@@ -26619,32 +26884,29 @@
26619
26884
  }
26620
26885
  function searchArray(array, parseInfo, start, end) {
26621
26886
  const len = end - start;
26622
- // Early exit for impossible lengths
26623
- if (len < 0)
26887
+ if (len <= 0)
26624
26888
  return null;
26625
- // Use a simple linear search optimized with length pre-filtering
26626
- let i = array.length;
26627
- while (i--) {
26628
- if (array[i].length !== len)
26889
+ let match;
26890
+ let item;
26891
+ for (let i = 0; i < array.length; i++) {
26892
+ item = array[i];
26893
+ if (item.length !== len)
26629
26894
  continue;
26630
- // Match character by character
26631
- let match = true;
26632
- const arrayItem = array[i];
26895
+ match = true;
26633
26896
  for (let j = 0; j < len; j++) {
26634
- let ca = arrayItem.charCodeAt(j);
26635
- let cb = parseInfo.stream.charCodeAt(start + j);
26636
- // Normalize A-Z to a-z
26897
+ let ca = parseInfo.stream.charCodeAt(start + j);
26898
+ let cb = item.charCodeAt(j);
26637
26899
  if (ca >= 65 && ca <= 90)
26638
26900
  ca += 32;
26639
26901
  if (cb >= 65 && cb <= 90)
26640
26902
  cb += 32;
26641
- if (ca != cb) {
26903
+ if (ca !== cb) {
26642
26904
  match = false;
26643
26905
  break;
26644
26906
  }
26645
26907
  }
26646
26908
  if (match) {
26647
- return arrayItem;
26909
+ return item;
26648
26910
  }
26649
26911
  }
26650
26912
  return null;
@@ -27582,23 +27844,6 @@
27582
27844
  }
27583
27845
  return true;
27584
27846
  }
27585
- /**
27586
- *
27587
- * @param parseInfo
27588
- * @returns
27589
- */
27590
- // isPseudo(parseInfo: ParseInfo): boolean {
27591
- // let position: number = parseInfo.currentPosition - parseInfo.offset;
27592
- // let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
27593
- // return (parseInfo.stream.charAt(position) == ":" &&
27594
- // parseInfo.stream.charAt(endPosition - 1) == "(" &&
27595
- // (parseInfo.stream.charAt(position + 1) == ":"
27596
- // ? this.isIdentToken(parseInfo, 2, -1)
27597
- // : this.isIdentToken(parseInfo, 1, -1))) ||
27598
- // parseInfo.stream.charAt(position + 1) == ":"
27599
- // ? this.isIdentToken(parseInfo, 2)
27600
- // : this.isIdentToken(parseInfo, 1);
27601
- // }
27602
27847
  /**
27603
27848
  *
27604
27849
  * @param parseInfo
@@ -27729,28 +27974,28 @@
27729
27974
  // EOF
27730
27975
  switch (charCode) {
27731
27976
  case 61 /* TokenMap.EQUALS */:
27732
- if (parseInfo.position < parseInfo.currentPosition) {
27733
- return this.makeToken(parseInfo);
27734
- }
27977
+ // if (parseInfo.position < parseInfo.currentPosition) {
27978
+ // return this.makeToken(parseInfo);
27979
+ // }
27735
27980
  this.advance(parseInfo);
27736
27981
  return this.makeToken(parseInfo, exports.EnumToken.DelimTokenType);
27737
27982
  // '+' or '-'
27738
27983
  case 43 /* TokenMap.PLUS */:
27739
- if (parseInfo.position < parseInfo.currentPosition) {
27740
- return this.makeToken(parseInfo);
27741
- }
27984
+ // if (parseInfo.position < parseInfo.currentPosition) {
27985
+ // return this.makeToken(parseInfo);
27986
+ // }
27742
27987
  this.advance(parseInfo);
27743
27988
  charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
27744
- if (isDigit(charCode)) {
27745
- tokensCount = this.consumeNumericToken(parseInfo);
27746
- if (tokensCount > 0) {
27747
- this.advance(parseInfo, tokensCount);
27748
- return this.makeToken(parseInfo, this.hint ?? exports.EnumToken.NumberTokenType, {
27749
- slice: this.slice,
27750
- sign: "+",
27751
- });
27752
- }
27753
- }
27989
+ // if (isDigit(charCode)) {
27990
+ // tokensCount = this.consumeNumericToken(parseInfo);
27991
+ // if (tokensCount > 0) {
27992
+ // this.advance(parseInfo, tokensCount);
27993
+ // return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
27994
+ // slice: this.slice,
27995
+ // sign: "+",
27996
+ // });
27997
+ // }
27998
+ // }
27754
27999
  return this.makeToken(parseInfo, exports.EnumToken.Plus);
27755
28000
  case 45 /* TokenMap.MINUS */:
27756
28001
  if (parseInfo.position == parseInfo.currentPosition) {
@@ -27760,15 +28005,17 @@
27760
28005
  this.advance(parseInfo);
27761
28006
  return this.makeToken(parseInfo, exports.EnumToken.Sub);
27762
28007
  }
27763
- if (charCode == 45 /* TokenMap.MINUS */ &&
27764
- (nextCharCode == 45 /* TokenMap.MINUS */ || isIdentStart(nextCharCode))) {
27765
- this.advance(parseInfo);
27766
- tokensCount = this.consumeIdentToken(parseInfo);
27767
- if (tokensCount > 0) {
27768
- this.advance(parseInfo, tokensCount);
27769
- return this.makeToken(parseInfo, exports.EnumToken.IdenTokenType);
27770
- }
27771
- }
28008
+ // if (
28009
+ // charCode == TokenMap.MINUS &&
28010
+ // (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
28011
+ // ) {
28012
+ // this.advance(parseInfo);
28013
+ // tokensCount = this.consumeIdentToken(parseInfo);
28014
+ // if (tokensCount > 0) {
28015
+ // this.advance(parseInfo, tokensCount);
28016
+ // return this.makeToken(parseInfo, EnumToken.IdenTokenType);
28017
+ // }
28018
+ // }
27772
28019
  }
27773
28020
  this.advance(parseInfo);
27774
28021
  break;
@@ -27821,28 +28068,28 @@
27821
28068
  return this.makeToken(parseInfo, exports.EnumToken.EndParensTokenType);
27822
28069
  // '['
27823
28070
  case 91 /* TokenMap.LEFT_BRACKETS */:
27824
- if (parseInfo.position < parseInfo.currentPosition) {
27825
- return this.makeToken(parseInfo);
27826
- }
28071
+ // if (parseInfo.position < parseInfo.currentPosition) {
28072
+ // return this.makeToken(parseInfo);
28073
+ // }
27827
28074
  this.advance(parseInfo);
27828
28075
  return this.makeToken(parseInfo, exports.EnumToken.AttrStartTokenType);
27829
28076
  // ']'
27830
28077
  case 93 /* TokenMap.RIGHT_BRACKETS */:
27831
- if (parseInfo.position < parseInfo.currentPosition) {
27832
- return this.makeToken(parseInfo);
27833
- }
28078
+ // if (parseInfo.position < parseInfo.currentPosition) {
28079
+ // return this.makeToken(parseInfo);
28080
+ // }
27834
28081
  this.advance(parseInfo);
27835
28082
  return this.makeToken(parseInfo, exports.EnumToken.AttrEndTokenType);
27836
28083
  case 59 /* TokenMap.SEMICOLON */:
27837
- if (parseInfo.position < parseInfo.currentPosition) {
27838
- return this.makeToken(parseInfo);
27839
- }
28084
+ // if (parseInfo.position < parseInfo.currentPosition) {
28085
+ // return this.makeToken(parseInfo);
28086
+ // }
27840
28087
  this.advance(parseInfo);
27841
28088
  return this.makeToken(parseInfo, exports.EnumToken.SemiColonTokenType);
27842
28089
  case 58 /* TokenMap.COLON */:
27843
- if (parseInfo.position < parseInfo.currentPosition) {
27844
- return this.makeToken(parseInfo);
27845
- }
28090
+ // if (parseInfo.position < parseInfo.currentPosition) {
28091
+ // return this.makeToken(parseInfo);
28092
+ // }
27846
28093
  this.advance(parseInfo);
27847
28094
  if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
27848
28095
  this.advance(parseInfo);
@@ -27874,15 +28121,15 @@
27874
28121
  }
27875
28122
  return this.makeToken(parseInfo, exports.EnumToken.WhitespaceTokenType);
27876
28123
  case 44 /* TokenMap.COMMA */:
27877
- if (parseInfo.position < parseInfo.currentPosition) {
27878
- return this.makeToken(parseInfo);
27879
- }
28124
+ // if (parseInfo.position < parseInfo.currentPosition) {
28125
+ // return this.makeToken(parseInfo);
28126
+ // }
27880
28127
  this.advance(parseInfo);
27881
28128
  return this.makeToken(parseInfo, exports.EnumToken.CommaTokenType);
27882
28129
  case 36 /* TokenMap.DOLLAR */:
27883
- if (parseInfo.position < parseInfo.currentPosition) {
27884
- return this.makeToken(parseInfo);
27885
- }
28130
+ // if (parseInfo.position < parseInfo.currentPosition) {
28131
+ // return this.makeToken(parseInfo);
28132
+ // }
27886
28133
  if (this.match(parseInfo, "$=")) {
27887
28134
  this.advance(parseInfo, 2);
27888
28135
  return this.makeToken(parseInfo, exports.EnumToken.EndMatchTokenType);
@@ -27890,9 +28137,9 @@
27890
28137
  this.advance(parseInfo);
27891
28138
  break;
27892
28139
  case 126 /* TokenMap.TILDA */:
27893
- if (parseInfo.position < parseInfo.currentPosition) {
27894
- return this.makeToken(parseInfo);
27895
- }
28140
+ // if (parseInfo.position < parseInfo.currentPosition) {
28141
+ // return this.makeToken(parseInfo);
28142
+ // }
27896
28143
  if (this.match(parseInfo, "~=")) {
27897
28144
  this.advance(parseInfo, 2);
27898
28145
  return this.makeToken(parseInfo, exports.EnumToken.IncludeMatchTokenType);
@@ -27901,9 +28148,9 @@
27901
28148
  return this.makeToken(parseInfo, exports.EnumToken.Tilda);
27902
28149
  // case '^':
27903
28150
  case 94 /* TokenMap.CARET */:
27904
- if (parseInfo.position < parseInfo.currentPosition) {
27905
- return this.makeToken(parseInfo);
27906
- }
28151
+ // if (parseInfo.position < parseInfo.currentPosition) {
28152
+ // return this.makeToken(parseInfo);
28153
+ // }
27907
28154
  if (this.match(parseInfo, "^=")) {
27908
28155
  this.advance(parseInfo, 2);
27909
28156
  return this.makeToken(parseInfo, exports.EnumToken.StartMatchTokenType);
@@ -27911,9 +28158,9 @@
27911
28158
  this.advance(parseInfo);
27912
28159
  break;
27913
28160
  case 42 /* TokenMap.STAR */:
27914
- if (parseInfo.position < parseInfo.currentPosition) {
27915
- return this.makeToken(parseInfo);
27916
- }
28161
+ // if (parseInfo.position < parseInfo.currentPosition) {
28162
+ // return this.makeToken(parseInfo);
28163
+ // }
27917
28164
  if (this.match(parseInfo, "*=")) {
27918
28165
  this.advance(parseInfo, 2);
27919
28166
  return this.makeToken(parseInfo, exports.EnumToken.ContainMatchTokenType);
@@ -27927,9 +28174,9 @@
27927
28174
  this.advance(parseInfo);
27928
28175
  return this.makeToken(parseInfo, exports.EnumToken.NestingSelectorTokenType);
27929
28176
  case 124 /* TokenMap.PIPE */:
27930
- if (parseInfo.position < parseInfo.currentPosition) {
27931
- return this.makeToken(parseInfo);
27932
- }
28177
+ // if (parseInfo.position < parseInfo.currentPosition) {
28178
+ // return this.makeToken(parseInfo);
28179
+ // }
27933
28180
  // '||'
27934
28181
  if (this.match(parseInfo, "||")) {
27935
28182
  this.advance(parseInfo, 2);
@@ -27952,9 +28199,9 @@
27952
28199
  this.advance(parseInfo);
27953
28200
  break;
27954
28201
  case 47 /* TokenMap.SLASH */:
27955
- if (parseInfo.position < parseInfo.currentPosition) {
27956
- return this.makeToken(parseInfo);
27957
- }
28202
+ // if (parseInfo.position < parseInfo.currentPosition) {
28203
+ // return this.makeToken(parseInfo);
28204
+ // }
27958
28205
  if (!this.match(parseInfo, "/*")) {
27959
28206
  this.advance(parseInfo);
27960
28207
  return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
@@ -27973,9 +28220,9 @@
27973
28220
  }
27974
28221
  break;
27975
28222
  case 62 /* TokenMap.GREATERTHAN */:
27976
- if (parseInfo.position < parseInfo.currentPosition) {
27977
- return this.makeToken(parseInfo);
27978
- }
28223
+ // if (parseInfo.position < parseInfo.currentPosition) {
28224
+ // return this.makeToken(parseInfo);
28225
+ // }
27979
28226
  if (this.match(parseInfo, ">=")) {
27980
28227
  this.advance(parseInfo, 2);
27981
28228
  return this.makeToken(parseInfo, exports.EnumToken.GteTokenType);
@@ -28014,20 +28261,11 @@
28014
28261
  this.advance(parseInfo);
28015
28262
  break;
28016
28263
  case 92 /* TokenMap.REVERSE_SOLIDUS */:
28017
- // if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
28018
- // break;
28019
- // }
28020
28264
  this.advance(parseInfo);
28021
28265
  // EOF
28022
- if (!this.peek(parseInfo)) {
28023
- // if (!yieldEOFToken) {
28024
- // break;
28025
- // }
28026
- // end of stream ignore \\
28027
- if (parseInfo.position < parseInfo.currentPosition) {
28028
- return this.makeToken(parseInfo);
28029
- }
28030
- break;
28266
+ // end of stream ignore \\
28267
+ if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
28268
+ return this.makeToken(parseInfo);
28031
28269
  }
28032
28270
  this.advance(parseInfo);
28033
28271
  break;
@@ -28040,9 +28278,9 @@
28040
28278
  case 46 /* TokenMap.DOT */:
28041
28279
  const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
28042
28280
  if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
28043
- if (parseInfo.position < parseInfo.currentPosition) {
28044
- return this.makeToken(parseInfo);
28045
- }
28281
+ // if (parseInfo.position < parseInfo.currentPosition) {
28282
+ // return this.makeToken(parseInfo);
28283
+ // }
28046
28284
  this.advance(parseInfo);
28047
28285
  let tokensCount = this.consumeIdentToken(parseInfo);
28048
28286
  if (tokensCount > 0) {
@@ -28050,27 +28288,22 @@
28050
28288
  return this.makeToken(parseInfo, exports.EnumToken.ClassSelectorTokenType);
28051
28289
  }
28052
28290
  }
28053
- if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28054
- this.makeToken(parseInfo);
28055
- this.advance(parseInfo, 2);
28056
- return this;
28057
- }
28291
+ // if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28292
+ // this.makeToken(parseInfo);
28293
+ // this.advance(parseInfo, 2);
28294
+ // return this;
28295
+ // }
28058
28296
  this.advance(parseInfo);
28059
28297
  break;
28060
28298
  default:
28061
28299
  this.advance(parseInfo);
28062
28300
  break;
28063
28301
  }
28064
- // if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
28065
- // break;
28066
- // }
28067
28302
  }
28068
- // if (yieldEOFToken) {
28069
28303
  if (parseInfo.position < parseInfo.currentPosition) {
28070
28304
  return this.makeToken(parseInfo);
28071
28305
  }
28072
28306
  return this.makeToken(parseInfo, exports.EnumToken.EOFTokenType);
28073
- // }
28074
28307
  }
28075
28308
  /**
28076
28309
  * tokenize readable stream
@@ -28879,24 +29112,6 @@
28879
29112
  if (tokens[index].chi[l].typ === exports.EnumToken.StringTokenType) {
28880
29113
  break;
28881
29114
  }
28882
- // else if ((tokens[index] as FunctionToken).chi[l].typ === EnumToken.IdenTokenType) {
28883
- // let m: number = l + 1;
28884
- // while (
28885
- // (tokens[index] as FunctionToken).chi[m]?.typ === EnumToken.ClassSelectorTokenType
28886
- // ) {
28887
- // Object.assign((tokens[index] as FunctionToken).chi[l], {
28888
- // typ: EnumToken.UrlTokenTokenType,
28889
- // val:
28890
- // ((tokens[index] as FunctionToken).chi[l] as IdentToken | UrlToken).val +
28891
- // ((tokens[index] as FunctionToken).chi[m] as ClassSelectorToken).val,
28892
- // });
28893
- // (tokens[index] as FunctionToken).chi[l][LOCEND] = (
28894
- // tokens[index] as FunctionToken
28895
- // ).chi[m][LOCEND];
28896
- // (tokens[index] as FunctionToken).chi.splice(m, 1);
28897
- // }
28898
- // break;
28899
- // }
28900
29115
  }
28901
29116
  if (tokens[index].chi[l]?.typ === exports.EnumToken.StringTokenType &&
28902
29117
  /^[a-zA-Z0-0/_.-]+$/.test(tokens[index].chi[l].val.slice(1, -1))) {
@@ -30862,6 +31077,7 @@
30862
31077
  if (options.expandNestingRules) {
30863
31078
  options.nestingRules = false;
30864
31079
  }
31080
+ options.minifyAST ??= options.minify;
30865
31081
  const startTime = performance.now();
30866
31082
  const errors = [];
30867
31083
  const stack = [];
@@ -31241,7 +31457,7 @@
31241
31457
  }
31242
31458
  }
31243
31459
  }
31244
- if (options.minify) {
31460
+ if (options.minifyAST) {
31245
31461
  if (ast.chi.length > 0) {
31246
31462
  let passes = options.pass ?? 1;
31247
31463
  while (passes--) {
@@ -31781,6 +31997,7 @@
31781
31997
  lenient: true,
31782
31998
  ...options,
31783
31999
  };
32000
+ options.minifyAST ??= options.minify;
31784
32001
  if (typeof options.validation !== "boolean") {
31785
32002
  options.validation = !!options.validation;
31786
32003
  }
@@ -32235,7 +32452,7 @@
32235
32452
  }
32236
32453
  }
32237
32454
  }
32238
- if (options.minify) {
32455
+ if (options.minifyAST) {
32239
32456
  if (ast.chi.length > 0) {
32240
32457
  let passes = options.pass ?? 1;
32241
32458
  while (passes--) {
@@ -33147,7 +33364,7 @@
33147
33364
  atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
33148
33365
  // @ts-expect-error
33149
33366
  return Object.assign(atRule, {
33150
- typ: success ? exports.EnumToken.AtRuleNodeType : exports.EnumToken.InvalidRuleNodeType,
33367
+ typ: exports.EnumToken.AtRuleNodeType,
33151
33368
  val: renderTokens(trimArray(stream), options),
33152
33369
  });
33153
33370
  }
@@ -33155,12 +33372,12 @@
33155
33372
  return null;
33156
33373
  }
33157
33374
  atRule[TOKENS] = stream;
33158
- atRule[STATE] = exports.EnumAstNodeStatus.Validated;
33375
+ atRule[STATE] = success ? exports.EnumAstNodeStatus.Validated : exports.EnumAstNodeStatus.Invalid;
33159
33376
  atRule[ERRORS] = [];
33160
33377
  atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
33161
33378
  // @ts-expect-error
33162
33379
  return Object.assign(atRule, {
33163
- typ: success ? exports.EnumToken.AtRuleNodeType : exports.EnumToken.InvalidRuleNodeType,
33380
+ typ: exports.EnumToken.AtRuleNodeType,
33164
33381
  val: renderTokens(trimArray(stream), options),
33165
33382
  });
33166
33383
  }
@@ -33718,9 +33935,9 @@
33718
33935
  let result = null;
33719
33936
  if (syntax == null) {
33720
33937
  // check matching '(' and ')'
33721
- // check commas , or ,,
33722
- // check colon :
33723
- // check or and and
33938
+ // check commas ',' or ',,'
33939
+ // check colon ':'
33940
+ // check 'or' and 'and'
33724
33941
  result = matchGenericSyntax(stream, options);
33725
33942
  if (result.errors.length > 0) {
33726
33943
  for (const error of result.errors) {
@@ -34625,6 +34842,7 @@
34625
34842
  });
34626
34843
  }
34627
34844
 
34845
+ exports.PropertyList = PropertyList;
34628
34846
  exports.SourceMap = SourceMap;
34629
34847
  exports.cloneNode = cloneNode;
34630
34848
  exports.convertColor = convertColor;