sk-css 0.5.0

Skathi's stylesheets: parsing, the cascade and per-state refinements onto gpui styles
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
//! What CSS Skathi supports, property by property: the one list `CSS.supports`, `@supports` and the
//! docs answer from. Each entry's sample values run through the mapper in the tests below, so an entry
//! that disagrees with what the mapper does fails the build.

use crate::mapper::{accepts_declaration, verdict, Verdict};

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Status {
    /// Applied, every sample value.
    Supported,
    /// Applied, with the limitation in the note; `refused` lists values that are not.
    Partial,
    /// Accepted without an advisory and without effect, which is right for this engine.
    Ignored,
    /// Not applied; a declaration prints an advisory.
    Unsupported,
    /// A vendor-prefixed spelling dropped without an advisory, as Chromium drops one it does not know.
    Dropped,
}

impl Status {
    pub fn as_str(self) -> &'static str {
        match self {
            Status::Supported => "supported",
            Status::Partial => "partial",
            Status::Ignored => "ignored",
            Status::Unsupported => "unsupported",
            Status::Dropped => "dropped",
        }
    }
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Platform {
    Windows,
    MacOs,
    Linux,
}

#[derive(Debug)]
pub struct Entry {
    pub name: &'static str,
    pub status: Status,
    /// Values the engine applies.
    pub applied: &'static [&'static str],
    /// Values it parses and does not honour; `CSS.supports` answers false for each.
    pub refused: &'static [&'static str],
    pub note: &'static str,
    /// Where it works, when not on every platform.
    pub platforms: &'static [Platform],
}

const fn e(
    name: &'static str,
    status: Status,
    applied: &'static [&'static str],
    refused: &'static [&'static str],
    note: &'static str,
) -> Entry {
    Entry {
        name,
        status,
        applied,
        refused,
        note,
        platforms: &[],
    }
}

use Status::*;

const SIZING_KEYWORDS: &[&str] = &["min-content", "max-content", "fit-content", "stretch"];
const SIZING_NOTE: &str = "Intrinsic sizing keywords are ignored; use flex or grid sizing";

#[rustfmt::skip]
pub const CATALOG: &[Entry] = &[
    e("accent-color", Supported, &["auto", "red"], &[], ""),
    e("align-content", Partial, &["center", "space-between"], &["normal", "baseline"], "`normal` and baseline alignment are not mapped"),
    e("align-items", Partial, &["center", "baseline"], &["normal"], "`normal` is not mapped; `stretch` is the default"),
    e("align-self", Partial, &["center", "stretch"], &["auto", "normal"], "`auto` and `normal` cannot undo an earlier value"),
    e("anchor-name", Unsupported, &[], &["--a"], ""),
    e("animation", Supported, &["spin 1s linear infinite", "none"], &[], ""),
    e("animation-composition", Unsupported, &[], &["add"], ""),
    e("animation-delay", Supported, &["1s", "-1s"], &[], ""),
    e("animation-direction", Supported, &["normal", "alternate"], &[], ""),
    e("animation-duration", Supported, &["1s"], &[], ""),
    e("animation-fill-mode", Supported, &["none", "both"], &[], ""),
    e("animation-iteration-count", Supported, &["1", "infinite"], &[], ""),
    e("animation-name", Supported, &["none", "spin"], &[], ""),
    e("animation-play-state", Supported, &["running", "paused"], &[], ""),
    e("animation-range", Unsupported, &[], &["normal"], ""),
    e("animation-range-end", Unsupported, &[], &["normal"], ""),
    e("animation-range-start", Unsupported, &[], &["normal"], ""),
    e("animation-timeline", Unsupported, &[], &["none"], ""),
    e("animation-timing-function", Partial, &["ease", "cubic-bezier(0.34, 1.56, 0.64, 1)"], &[], "`linear()` easing is not parsed"),
    e("app-region", Supported, &["drag", "no-drag"], &[], "A window drag region, as in Electron"),
    e("appearance", Supported, &["none", "auto"], &[], ""),
    e("aspect-ratio", Supported, &["1 / 1", "1.5", "auto", "auto 16 / 9"], &[], ""),
    e("backdrop-filter", Partial, &["none", "blur(2px)"], &["grayscale(1)", "saturate(180%)", "brightness(2)", "contrast(2)", "sepia(1)", "hue-rotate(10deg)", "invert(1)", "opacity(0.5)", "drop-shadow(0 0 1px red)"], "Only `blur()`"),
    e("backface-visibility", Unsupported, &[], &["hidden"], ""),
    e("background", Supported, &["red", "linear-gradient(red, blue)"], &[], ""),
    e("background-attachment", Ignored, &["scroll", "fixed"], &[], "A background scrolls with its element"),
    e("background-blend-mode", Unsupported, &[], &["multiply"], ""),
    e("background-clip", Partial, &["text"], &["border-box", "content-box"], "Only `text`; the background fills the padding box"),
    e("background-color", Supported, &["red", "transparent"], &[], ""),
    e("background-image", Supported, &["none", "url(a.png)"], &[], ""),
    e("background-origin", Ignored, &["border-box", "content-box"], &[], ""),
    e("background-position", Supported, &["center", "10px 20%"], &[], ""),
    e("background-position-x", Supported, &["center", "10px"], &[], ""),
    e("background-position-y", Supported, &["center", "10px"], &[], ""),
    e("background-repeat", Supported, &["repeat", "no-repeat"], &[], ""),
    e("background-size", Supported, &["cover", "10px 20px"], &[], ""),
    e("block-size", Partial, &["auto", "10px", "calc-size(auto, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("border", Supported, &["1px solid red", "none"], &[], ""),
    e("border-block", Unsupported, &[], &["1px solid red"], ""),
    e("border-block-color", Unsupported, &[], &["red"], ""),
    e("border-block-end", Unsupported, &[], &["1px solid red"], ""),
    e("border-block-end-color", Unsupported, &[], &["red"], ""),
    e("border-block-end-style", Unsupported, &[], &["solid"], ""),
    e("border-block-end-width", Unsupported, &[], &["1px"], ""),
    e("border-block-start", Unsupported, &[], &["1px solid red"], ""),
    e("border-block-start-color", Unsupported, &[], &["red"], ""),
    e("border-block-start-style", Unsupported, &[], &["solid"], ""),
    e("border-block-start-width", Unsupported, &[], &["1px"], ""),
    e("border-block-style", Unsupported, &[], &["solid"], ""),
    e("border-block-width", Unsupported, &[], &["1px"], ""),
    e("border-bottom", Supported, &["1px solid red", "none"], &[], ""),
    e("border-bottom-color", Supported, &["red", "transparent"], &[], ""),
    e("border-bottom-left-radius", Supported, &["4px", "50%"], &[], ""),
    e("border-bottom-right-radius", Supported, &["4px", "50%"], &[], ""),
    e("border-bottom-style", Supported, &["none", "solid"], &[], ""),
    e("border-bottom-width", Supported, &["0", "2px"], &[], ""),
    e("border-collapse", Unsupported, &[], &["collapse"], "Tables lay out as blocks"),
    e("border-color", Supported, &["red", "transparent"], &[], ""),
    e("border-end-end-radius", Unsupported, &[], &["4px"], ""),
    e("border-end-start-radius", Unsupported, &[], &["4px"], ""),
    e("border-image", Unsupported, &[], &["url(a.png) 10"], ""),
    e("border-image-outset", Unsupported, &[], &["1px"], ""),
    e("border-image-repeat", Unsupported, &[], &["stretch"], ""),
    e("border-image-slice", Unsupported, &[], &["10"], ""),
    e("border-image-source", Unsupported, &[], &["url(a.png)"], ""),
    e("border-image-width", Unsupported, &[], &["1px"], ""),
    e("border-inline", Unsupported, &[], &["1px solid red"], ""),
    e("border-inline-color", Unsupported, &[], &["red"], ""),
    e("border-inline-end", Unsupported, &[], &["1px solid red"], ""),
    e("border-inline-end-color", Unsupported, &[], &["red"], ""),
    e("border-inline-end-style", Unsupported, &[], &["solid"], ""),
    e("border-inline-end-width", Unsupported, &[], &["1px"], ""),
    e("border-inline-start", Unsupported, &[], &["1px solid red"], ""),
    e("border-inline-start-color", Unsupported, &[], &["red"], ""),
    e("border-inline-start-style", Unsupported, &[], &["solid"], ""),
    e("border-inline-start-width", Unsupported, &[], &["1px"], ""),
    e("border-inline-style", Unsupported, &[], &["solid"], ""),
    e("border-inline-width", Unsupported, &[], &["1px"], ""),
    e("border-left", Supported, &["1px solid red", "none"], &[], ""),
    e("border-left-color", Supported, &["red", "transparent"], &[], ""),
    e("border-left-style", Supported, &["none", "solid"], &[], ""),
    e("border-left-width", Supported, &["0", "2px"], &[], ""),
    e("border-radius", Supported, &["4px", "50%"], &[], ""),
    e("border-right", Supported, &["1px solid red", "none"], &[], ""),
    e("border-right-color", Supported, &["red", "transparent"], &[], ""),
    e("border-right-style", Supported, &["none", "solid"], &[], ""),
    e("border-right-width", Supported, &["0", "2px"], &[], ""),
    e("border-spacing", Unsupported, &[], &["2px"], "Tables lay out as blocks"),
    e("border-start-end-radius", Unsupported, &[], &["4px"], ""),
    e("border-start-start-radius", Unsupported, &[], &["4px"], ""),
    e("border-style", Supported, &["none", "solid"], &[], ""),
    e("border-top", Supported, &["1px solid red", "none"], &[], ""),
    e("border-top-color", Supported, &["red", "transparent"], &[], ""),
    e("border-top-left-radius", Supported, &["4px", "50%"], &[], ""),
    e("border-top-right-radius", Supported, &["4px", "50%"], &[], ""),
    e("border-top-style", Supported, &["none", "solid"], &[], ""),
    e("border-top-width", Supported, &["0", "2px"], &[], ""),
    e("border-width", Supported, &["0", "2px"], &[], ""),
    e("bottom", Supported, &["auto", "10px"], &[], ""),
    e("box-align", Unsupported, &[], &["center"], ""),
    e("box-decoration-break", Unsupported, &[], &["clone"], ""),
    e("box-direction", Unsupported, &[], &["normal"], ""),
    e("box-flex", Unsupported, &[], &["1"], ""),
    e("box-flex-group", Unsupported, &[], &["1"], ""),
    e("box-lines", Unsupported, &[], &["single"], ""),
    e("box-ordinal-group", Unsupported, &[], &["1"], ""),
    e("box-orient", Unsupported, &[], &["vertical"], ""),
    e("box-pack", Unsupported, &[], &["center"], ""),
    e("box-shadow", Partial, &["none", "0 2px 4px red"], &["1px 2px"], "A shadow coloured `currentColor` or a system colour is dropped"),
    e("box-sizing", Partial, &["border-box"], &["content-box"], "Every box is `border-box`"),
    e("caption-side", Unsupported, &[], &["bottom"], "Tables lay out as blocks"),
    e("caret", Unsupported, &[], &["auto"], ""),
    e("caret-color", Unsupported, &[], &["red"], ""),
    e("caret-shape", Unsupported, &[], &["block"], ""),
    e("clear", Unsupported, &[], &["both"], "Use flex or grid"),
    e("clip", Partial, &["rect(0, 0, 0, 0)"], &["rect(0, 10px, 10px, 0)"], "Only the empty rect of the visually-hidden idiom"),
    e("clip-path", Partial, &["circle(50%)", "path(\"M0 0L10 10\")"], &["url(#c)"], "Basic shapes and `path()`; `url()` is not applied"),
    e("clip-rule", Unsupported, &[], &["nonzero"], ""),
    e("color", Supported, &["red", "oklch(70% 0.1 200)", "light-dark(black, white)"], &[], ""),
    e("color-interpolation", Unsupported, &[], &["auto"], ""),
    e("color-interpolation-filters", Unsupported, &[], &["auto"], ""),
    e("color-rendering", Unsupported, &[], &["auto"], ""),
    e("color-scheme", Supported, &["normal", "light dark", "only dark"], &[], ""),
    e("column-count", Unsupported, &[], &["2"], ""),
    e("column-gap", Supported, &["0", "10px"], &[], ""),
    e("column-rule", Unsupported, &[], &["1px solid red"], ""),
    e("column-width", Unsupported, &[], &["100px"], ""),
    e("column-span", Unsupported, &[], &["all"], ""),
    e("columns", Unsupported, &[], &["2"], ""),
    e("contain", Supported, &["none", "paint", "size", "inline-size", "strict"], &[], ""),
    e("contain-intrinsic-size", Unsupported, &[], &["100px"], ""),
    e("container", Supported, &["card / inline-size", "none"], &[], ""),
    e("container-name", Supported, &["card", "card sidebar", "none"], &[], ""),
    e("container-type", Partial, &["normal", "inline-size", "size"], &["scroll-state"], "Scroll-state container queries are not supported"),
    e("content", Partial, &["none", "\"a\""], &["counter(n)", "attr(data-x)"], "A literal string; counters and `attr()` generate nothing"),
    e("content-visibility", Unsupported, &[], &["auto"], ""),
    e("corner", Unsupported, &[], &["8px bevel"], "Use `border-radius` and `corner-shape`"),
    e("corner-block-end-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-block-start-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-bottom-left", Unsupported, &[], &["8px bevel"], "Use `border-bottom-left-radius` and `corner-bottom-left-shape`"),
    e("corner-bottom-left-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
    e("corner-bottom-right", Unsupported, &[], &["8px bevel"], "Use `border-bottom-right-radius` and `corner-bottom-right-shape`"),
    e("corner-bottom-right-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
    e("corner-bottom-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-end-end-shape", Supported, &["bevel", "squircle"], &[], ""),
    e("corner-end-start-shape", Supported, &["bevel", "squircle"], &[], ""),
    e("corner-inline-end-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-inline-start-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-left-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-right-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("corner-shape", Supported, &["round", "squircle", "bevel scoop", "notch square round superellipse(0.5)", "superellipse(infinity)"], &[], ""),
    e("corner-start-end-shape", Supported, &["bevel", "squircle"], &[], ""),
    e("corner-start-start-shape", Supported, &["bevel", "squircle"], &[], ""),
    e("corner-top-left", Unsupported, &[], &["8px bevel"], "Use `border-top-left-radius` and `corner-top-left-shape`"),
    e("corner-top-left-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
    e("corner-top-right", Unsupported, &[], &["8px bevel"], "Use `border-top-right-radius` and `corner-top-right-shape`"),
    e("corner-top-right-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
    e("corner-top-shape", Supported, &["bevel", "round scoop"], &[], ""),
    e("counter-increment", Unsupported, &[], &["n"], ""),
    e("counter-reset", Unsupported, &[], &["n"], ""),
    e("counter-set", Unsupported, &[], &["n 1"], ""),
    e("cursor", Partial, &["pointer", "text", "wait", "none", "url(hand.png) 4 4, pointer"], &[], "A `url()` image is not loaded: the fallback keyword shows. A keyword the OS has no cursor for shows the arrow"),
    e("cx", Unsupported, &[], &["10px"], ""),
    e("cy", Unsupported, &[], &["10px"], ""),
    e("d", Unsupported, &[], &["path(\"M0 0L10 10\")"], ""),
    e("direction", Unsupported, &[], &["rtl"], "Left-to-right text only"),
    e("display", Partial, &["flex", "grid"], &[], "No line boxes; `contents` and the table values lay out as `block`"),
    e("dominant-baseline", Unsupported, &[], &["middle"], ""),
    e("dynamic-range-limit", Partial, &["standard", "no-limit", "dynamic-range-limit-mix(standard 30%, no-limit 70%)"], &[], "Computed and inherited, and reported to `<sk-surface>` producers; windows draw SDR, so nothing on screen is limited yet"),
    e("empty-cells", Unsupported, &[], &["hide"], "Tables lay out as blocks"),
    e("field-sizing", Unsupported, &[], &["content"], ""),
    e("fill", Supported, &["none", "red"], &[], ""),
    e("fill-opacity", Supported, &["0.5"], &[], ""),
    e("fill-rule", Supported, &["nonzero", "evenodd"], &[], ""),
    e("filter", Partial, &["blur(2px)", "url(#f)"], &["grayscale(1)", "url(a.svg#f)", "sepia(1)", "brightness(2)", "contrast(2)", "saturate(2)", "hue-rotate(10deg)", "invert(1)", "opacity(0.5)"], "One `blur()`, one `drop-shadow()` and one same-document SVG `url(#id)`; the colour functions are not applied"),
    e("flex", Supported, &["1", "none"], &[], ""),
    e("flex-align", Unsupported, &[], &["center"], ""),
    e("flex-basis", Supported, &["auto", "10px", "calc-size(content, size * 2)"], &[], ""),
    e("flex-direction", Supported, &["row", "column"], &[], ""),
    e("flex-flow", Supported, &["row wrap", "column", "wrap-reverse"], &[], ""),
    e("flex-grow", Supported, &["0", "1"], &[], ""),
    e("flex-item-align", Unsupported, &[], &["center"], ""),
    e("flex-line-pack", Unsupported, &[], &["center"], ""),
    e("flex-negative", Unsupported, &[], &["1"], ""),
    e("flex-order", Unsupported, &[], &["1"], ""),
    e("flex-pack", Unsupported, &[], &["center"], ""),
    e("flex-positive", Unsupported, &[], &["1"], ""),
    e("flex-preferred-size", Unsupported, &[], &["auto"], ""),
    e("flex-shrink", Supported, &["0", "1"], &[], ""),
    e("flex-wrap", Supported, &["wrap", "nowrap"], &[], ""),
    e("float", Unsupported, &[], &["left"], "Use flex or grid"),
    e("flood-color", Unsupported, &[], &["red"], ""),
    e("font", Unsupported, &[], &["12px serif"], "Use the longhands"),
    e("font-family", Supported, &["serif", "\"Segoe UI\", sans-serif"], &[], ""),
    e("font-feature-settings", Supported, &["\"tnum\"", "normal"], &[], ""),
    e("font-kerning", Supported, &["none", "auto"], &[], ""),
    e("font-optical-sizing", Partial, &["auto"], &["none"], "Always `auto`"),
    e("font-palette", Unsupported, &[], &["--p"], ""),
    e("font-size", Supported, &["12px", "larger"], &[], ""),
    e("font-size-adjust", Unsupported, &[], &["0.5"], ""),
    e("font-stretch", Unsupported, &[], &["condensed"], ""),
    e("font-style", Supported, &["normal", "italic"], &[], ""),
    e("font-synthesis", Unsupported, &[], &["none"], ""),
    e("font-variant", Unsupported, &[], &["small-caps"], "`font-feature-settings: \"smcp\"` where the font has it"),
    e("font-variant-caps", Unsupported, &[], &["small-caps"], "`font-feature-settings: \"smcp\"` where the font has it"),
    e("font-variant-east-asian", Unsupported, &[], &["ruby"], ""),
    e("font-variant-ligatures", Supported, &["none", "normal"], &[], ""),
    e("font-variant-numeric", Supported, &["tabular-nums", "normal"], &[], ""),
    e("font-variation-settings", Partial, &["normal"], &["\"wght\" 400"], "`font-weight` and `font-style` reach the matching axes"),
    e("font-weight", Supported, &["bold", "450"], &[], ""),
    e("font-width", Unsupported, &[], &["condensed"], ""),
    e("forced-color-adjust", Unsupported, &[], &["none"], ""),
    e("gap", Supported, &["0", "10px 20px"], &[], ""),
    e("grid", Unsupported, &[], &["auto / 1fr 1fr"], "Use the longhands"),
    e("grid-area", Partial, &["auto", "1 / 2"], &["a"], "Named areas are not mapped"),
    e("grid-auto-columns", Supported, &["auto", "1fr"], &[], ""),
    e("grid-auto-flow", Supported, &["row", "column"], &[], ""),
    e("grid-auto-rows", Supported, &["auto", "1fr"], &[], ""),
    e("grid-column", Partial, &["auto", "1 / 3"], &["a"], "Named lines are not mapped"),
    e("grid-column-end", Partial, &["auto", "span 2"], &["a"], "Named lines are not mapped"),
    e("grid-column-start", Partial, &["auto", "2"], &["a"], "Named lines are not mapped"),
    e("grid-row", Partial, &["auto", "1 / 3"], &["a"], "Named lines are not mapped"),
    e("grid-row-end", Partial, &["auto", "span 2"], &["a"], "Named lines are not mapped"),
    e("grid-row-start", Partial, &["auto", "2"], &["a"], "Named lines are not mapped"),
    e("grid-template", Unsupported, &[], &["none"], "Use `grid-template-columns` / `-rows`"),
    e("grid-template-areas", Unsupported, &[], &["\"a b\""], "Place items by line number"),
    e("grid-template-columns", Partial, &["1fr 1fr", "repeat(3, 10px)"], &["none"], "`none` cannot undo an earlier track list"),
    e("grid-template-rows", Partial, &["1fr 1fr", "repeat(3, 10px)"], &["none"], "`none` cannot undo an earlier track list"),
    e("height", Partial, &["auto", "10px", "calc-size(auto, size + 10px)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("hyphenate-character", Unsupported, &[], &["\"-\""], ""),
    e("hyphens", Partial, &["none", "manual"], &["auto"], "`auto` breaks only at soft hyphens"),
    e("image-orientation", Unsupported, &[], &["from-image"], ""),
    e("image-rendering", Unsupported, &[], &["auto"], ""),
    e("initial-letter", Unsupported, &[], &["2"], ""),
    e("inline-size", Partial, &["auto", "10px", "calc-size(fit-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("inset", Supported, &["auto", "0"], &[], ""),
    e("inset-block", Supported, &["auto", "0"], &[], ""),
    e("inset-block-end", Supported, &["auto", "0"], &[], ""),
    e("inset-block-start", Supported, &["auto", "0"], &[], ""),
    e("inset-inline", Supported, &["auto", "0"], &[], ""),
    e("inset-inline-end", Supported, &["auto", "0"], &[], ""),
    e("inset-inline-start", Supported, &["auto", "0"], &[], ""),
    e("interactivity", Unsupported, &[], &["inert"], ""),
    e("interpolate-size", Supported, &["numeric-only", "allow-keywords"], &[], ""),
    e("isolation", Supported, &["auto", "isolate"], &[], ""),
    e("justify-content", Partial, &["center", "space-between"], &["normal", "left"], "`normal`, `left` and `right` are not mapped"),
    e("justify-items", Supported, &["normal", "center"], &[], ""),
    e("justify-self", Supported, &["auto", "center"], &[], ""),
    e("left", Supported, &["auto", "10px"], &[], ""),
    e("letter-spacing", Supported, &["normal", "1px"], &[], ""),
    e("lighting-color", Unsupported, &[], &["red"], ""),
    e("line-break", Unsupported, &[], &["strict"], ""),
    e("line-clamp", Partial, &["2"], &["none"], "`none` cannot undo an earlier clamp"),
    e("line-height", Supported, &["normal", "1.5"], &[], ""),
    e("list-style", Supported, &["none", "disc inside"], &[], ""),
    e("list-style-image", Partial, &["none"], &["url(a.png)"], "Marker images are not drawn"),
    e("list-style-position", Supported, &["inside", "outside"], &[], ""),
    e("list-style-type", Partial, &["disc", "decimal"], &["hebrew"], "disc, circle, square, decimal, decimal-leading-zero, the alpha and roman styles"),
    e("margin", Supported, &["auto", "10px 20px"], &[], ""),
    e("margin-block", Supported, &["auto", "10px"], &[], ""),
    e("margin-block-end", Supported, &["auto", "10px"], &[], ""),
    e("margin-block-start", Supported, &["auto", "10px"], &[], ""),
    e("margin-bottom", Supported, &["auto", "10px"], &[], ""),
    e("margin-inline", Supported, &["auto", "10px"], &[], ""),
    e("margin-inline-end", Supported, &["auto", "10px"], &[], ""),
    e("margin-inline-start", Supported, &["auto", "10px"], &[], ""),
    e("margin-left", Supported, &["auto", "10px"], &[], ""),
    e("margin-right", Supported, &["auto", "10px"], &[], ""),
    e("margin-top", Supported, &["auto", "10px"], &[], ""),
    e("marker", Unsupported, &[], &["none"], ""),
    e("marker-end", Unsupported, &[], &["none"], ""),
    e("marker-mid", Unsupported, &[], &["none"], ""),
    e("marker-side", Unsupported, &[], &["match-self"], ""),
    e("marker-start", Unsupported, &[], &["none"], ""),
    e("mask", Partial, &["none", "url(a.png) center / contain no-repeat"], &[], "`url(#id)` references to an SVG `<mask>` are not applied; fixed-position descendants escape the mask"),
    e("mask-border", Unsupported, &[], &["none"], ""),
    e("mask-border-mode", Unsupported, &[], &["luminance"], ""),
    e("mask-border-outset", Unsupported, &[], &["0"], ""),
    e("mask-border-repeat", Unsupported, &[], &["stretch"], ""),
    e("mask-border-slice", Unsupported, &[], &["0"], ""),
    e("mask-border-source", Unsupported, &[], &["none"], ""),
    e("mask-border-width", Unsupported, &[], &["auto"], ""),
    e("mask-box-image", Unsupported, &[], &["none"], ""),
    e("mask-box-image-outset", Unsupported, &[], &["none"], ""),
    e("mask-box-image-repeat", Unsupported, &[], &["none"], ""),
    e("mask-box-image-slice", Unsupported, &[], &["none"], ""),
    e("mask-box-image-source", Unsupported, &[], &["none"], ""),
    e("mask-box-image-width", Unsupported, &[], &["none"], ""),
    e("mask-clip", Partial, &["border-box"], &["content-box"], "Only `border-box`"),
    e("mask-composite", Supported, &["add"], &[], ""),
    e("mask-image", Partial, &["none", "url(a.png)", "linear-gradient(#000, transparent)"], &[], "`url(#id)` references to an SVG `<mask>` are not applied"),
    e("mask-mode", Partial, &["alpha", "luminance"], &[], "`match-source` is treated as `alpha`; one mode for all layers"),
    e("mask-origin", Partial, &["border-box"], &["content-box"], "Only `border-box`"),
    e("mask-position", Supported, &["center", "10px 20%"], &[], ""),
    e("mask-position-x", Supported, &["center", "10px"], &[], ""),
    e("mask-position-y", Supported, &["center", "20%"], &[], ""),
    e("mask-repeat", Supported, &["repeat", "no-repeat"], &[], ""),
    e("mask-size", Supported, &["auto", "contain", "16px 16px"], &[], ""),
    e("mask-source-type", Unsupported, &[], &["none"], ""),
    e("mask-type", Unsupported, &[], &["luminance"], ""),
    e("max-block-size", Partial, &["none", "10px", "calc-size(fit-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("max-height", Partial, &["none", "10px", "calc-size(fit-content, size * .5)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("max-inline-size", Partial, &["none", "10px", "calc-size(max-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("max-width", Partial, &["none", "10px", "calc-size(max-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("min-block-size", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("min-height", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("min-inline-size", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("min-width", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("mix-blend-mode", Unsupported, &[], &["multiply"], ""),
    e("-moz-osx-font-smoothing", Dropped, &[], &["grayscale"], ""),
    e("object-fit", Supported, &["cover", "contain"], &[], ""),
    e("object-position", Supported, &["center", "10px 20%"], &[], ""),
    e("offset-path", Unsupported, &[], &["none"], ""),
    e("opacity", Supported, &["0.5", "50%"], &[], ""),
    e("order", Supported, &["0", "-1"], &[], ""),
    e("outline", Supported, &["none", "2px solid red"], &[], ""),
    e("outline-color", Supported, &["red", "transparent"], &[], ""),
    e("outline-offset", Supported, &["0", "2px"], &[], ""),
    e("outline-style", Supported, &["none", "solid"], &[], ""),
    e("outline-width", Supported, &["0", "2px"], &[], ""),
    e("overflow", Supported, &["auto", "hidden"], &[], ""),
    e("overflow-clip-margin", Unsupported, &[], &["10px"], ""),
    e("overflow-wrap", Supported, &["normal", "break-word"], &[], ""),
    e("overflow-x", Supported, &["auto", "hidden"], &[], ""),
    e("overflow-y", Supported, &["auto", "hidden"], &[], ""),
    e("overscroll-behavior", Supported, &["none", "contain"], &[], ""),
    e("overscroll-behavior-block", Supported, &["none", "auto"], &[], ""),
    e("overscroll-behavior-inline", Supported, &["none", "auto"], &[], ""),
    e("overscroll-behavior-x", Supported, &["none", "auto"], &[], ""),
    e("overscroll-behavior-y", Supported, &["none", "auto"], &[], ""),
    e("padding", Supported, &["0", "10px 20px"], &[], ""),
    e("padding-block", Supported, &["0", "10px"], &[], ""),
    e("padding-block-end", Supported, &["0", "10px"], &[], ""),
    e("padding-block-start", Supported, &["0", "10px"], &[], ""),
    e("padding-bottom", Supported, &["0", "10px"], &[], ""),
    e("padding-inline", Supported, &["0", "10px"], &[], ""),
    e("padding-inline-end", Supported, &["0", "10px"], &[], ""),
    e("padding-inline-start", Supported, &["0", "10px"], &[], ""),
    e("padding-left", Supported, &["0", "10px"], &[], ""),
    e("padding-right", Supported, &["0", "10px"], &[], ""),
    e("padding-top", Supported, &["0", "10px"], &[], ""),
    e("paint-order", Unsupported, &[], &["stroke"], ""),
    e("perspective", Unsupported, &[], &["100px"], ""),
    e("perspective-origin", Unsupported, &[], &["center"], ""),
    e("place-content", Unsupported, &[], &["center"], "Use the `align-*` / `justify-*` longhands"),
    e("place-items", Supported, &["center", "start end"], &[], ""),
    e("place-self", Unsupported, &[], &["center"], "Use the `align-*` / `justify-*` longhands"),
    e("pointer-events", Partial, &["none", "auto"], &["visiblePainted"], "Only `none` and `auto`"),
    e("position", Supported, &["absolute", "sticky"], &[], ""),
    e("position-anchor", Unsupported, &[], &["--a"], ""),
    e("print-color-adjust", Unsupported, &[], &["exact"], ""),
    e("quotes", Unsupported, &[], &["none"], ""),
    e("r", Unsupported, &[], &["5px"], ""),
    e("resize", Partial, &["none"], &["both"], "There is no user-resize affordance"),
    e("right", Supported, &["auto", "10px"], &[], ""),
    e("rotate", Unsupported, &[], &["45deg"], "Use `transform`"),
    e("row-gap", Supported, &["0", "10px"], &[], ""),
    e("rx", Unsupported, &[], &["5px"], ""),
    e("ry", Unsupported, &[], &["5px"], ""),
    e("scale", Unsupported, &[], &["2"], "Use `transform`"),
    e("scroll-behavior", Supported, &["auto", "smooth"], &[], ""),
    e("scroll-margin", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-block", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-block-end", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-block-start", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-bottom", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-inline", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-inline-end", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-inline-start", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-left", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-right", Supported, &["0", "10px"], &[], ""),
    e("scroll-margin-top", Supported, &["0", "10px"], &[], ""),
    e("scroll-padding", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-block", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-block-end", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-block-start", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-bottom", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-inline", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-inline-end", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-inline-start", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-left", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-right", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-padding-top", Supported, &["auto", "10px", "10%"], &[], ""),
    e("scroll-snap-align", Supported, &["start", "none", "start end"], &[], ""),
    e("scroll-snap-stop", Supported, &["normal", "always"], &[], ""),
    e("scroll-snap-type", Supported, &["none", "x mandatory", "both proximity"], &[], ""),
    e("scrollbar-color", Supported, &["auto", "red blue"], &[], ""),
    e("scrollbar-gutter", Unsupported, &[], &["stable"], ""),
    e("scrollbar-width", Supported, &["none", "thin"], &[], ""),
    e("shape-rendering", Supported, &["auto", "crispEdges"], &[], ""),
    e("stop-color", Unsupported, &[], &["red"], ""),
    e("stop-opacity", Unsupported, &[], &["0.5"], ""),
    e("stroke", Supported, &["none", "red"], &[], ""),
    e("stroke-dasharray", Supported, &["none", "4 2"], &[], ""),
    e("stroke-dashoffset", Supported, &["0", "2"], &[], ""),
    e("stroke-linecap", Supported, &["round", "butt"], &[], ""),
    e("stroke-linejoin", Supported, &["round", "bevel"], &[], ""),
    e("stroke-miterlimit", Supported, &["4"], &[], ""),
    e("stroke-opacity", Supported, &["0.5"], &[], ""),
    e("stroke-width", Supported, &["0", "2"], &[], ""),
    e("tab-size", Ignored, &["4"], &[], "Whitespace is collapsed, so a tab is one space"),
    e("table-layout", Unsupported, &[], &["fixed"], "Tables lay out as blocks"),
    e("text-align", Supported, &["center", "start"], &[], ""),
    e("text-align-last", Unsupported, &[], &["center"], ""),
    e("text-anchor", Unsupported, &[], &["middle"], ""),
    e("text-decoration", Partial, &["underline", "line-through red"], &["none"], "`none` cannot undo an earlier line; use `text-decoration-line: none`"),
    e("text-decoration-color", Supported, &["red", "transparent"], &[], ""),
    e("text-decoration-line", Supported, &["none", "underline"], &[], ""),
    e("text-decoration-skip-ink", Partial, &["none"], &["auto"], "The underline is one unbroken line"),
    e("text-decoration-style", Supported, &["solid", "wavy"], &[], ""),
    e("text-decoration-thickness", Supported, &["1px", "2px"], &[], ""),
    e("text-emphasis", Unsupported, &[], &["dot"], ""),
    e("text-emphasis-color", Unsupported, &[], &["red"], ""),
    e("text-emphasis-position", Unsupported, &[], &["under"], ""),
    e("text-emphasis-style", Unsupported, &[], &["dot"], ""),
    e("text-indent", Partial, &["0"], &["10px"], "There is no first line to indent; use `padding-left`"),
    e("text-justify", Unsupported, &[], &["inter-word"], ""),
    e("text-orientation", Unsupported, &[], &["upright"], ""),
    e("text-overflow", Partial, &["ellipsis"], &["clip"], "`clip` cannot undo an earlier ellipsis"),
    e("text-rendering", Unsupported, &[], &["optimizeLegibility"], ""),
    e("text-shadow", Supported, &["none", "1px 1px 2px red"], &[], ""),
    e("text-size-adjust", Ignored, &["none", "100%"], &[], ""),
    e("text-transform", Supported, &["none", "uppercase"], &[], ""),
    e("text-underline-offset", Supported, &["auto", "2px"], &[], ""),
    e("text-underline-position", Unsupported, &[], &["under"], "The underline is one unbroken line"),
    e("text-wrap", Unsupported, &[], &["balance"], ""),
    e("text-wrap-mode", Unsupported, &[], &["nowrap"], ""),
    e("text-wrap-style", Unsupported, &[], &["balance"], ""),
    e("top", Supported, &["auto", "10px"], &[], ""),
    e("touch-action", Ignored, &["none", "manipulation"], &[], ""),
    e("transform", Partial, &["none", "translate(1px) rotate(10deg)"], &["rotateX(10deg)", "rotateY(10deg)", "translateZ(1px)", "perspective(100px)", "rotate3d(1, 1, 0, 45deg)", "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)"], "2D only: rotation about the X or Y axis, depth and `perspective()` are not applied"),
    e("transform-box", Unsupported, &[], &["border-box"], ""),
    e("transform-origin", Supported, &["center", "0 0"], &[], ""),
    e("transition", Partial, &["opacity 1s ease", "none"], &[], "`linear()` easing is not parsed"),
    e("transition-behavior", Unsupported, &[], &["allow-discrete"], ""),
    e("transition-delay", Supported, &["1s", "-1s"], &[], ""),
    e("transition-duration", Supported, &["1s"], &[], ""),
    e("transition-property", Supported, &["none", "opacity"], &[], ""),
    e("transition-timing-function", Partial, &["ease", "linear"], &[], "`linear()` easing is not parsed"),
    e("translate", Unsupported, &[], &["10px"], "Use `transform`"),
    e("unicode-bidi", Unsupported, &[], &["isolate"], "Left-to-right text only"),
    e("user-select", Partial, &["none", "text"], &["contain"], "`contain` selects like `text`"),
    e("vector-effect", Unsupported, &[], &["non-scaling-stroke"], ""),
    e("vertical-align", Partial, &["baseline"], &["middle"], "Use `align-items` / `align-self` on a flex parent"),
    e("view-transition-class", Supported, &["card", "a b"], &[], ""),
    e("view-transition-group", Unsupported, &[], &["normal"], ""),
    e("view-transition-name", Supported, &["card", "none"], &[], ""),
    e("visibility", Supported, &["hidden", "visible"], &[], ""),
    e("-webkit-app-region", Supported, &["drag", "no-drag"], &[], ""),
    e("-webkit-box-reflect", Unsupported, &[], &["below"], ""),
    e("-webkit-font-smoothing", Dropped, &[], &["antialiased"], ""),
    e("-webkit-line-clamp", Partial, &["2"], &["none"], "`none` cannot undo an earlier clamp"),
    e("-webkit-mask-composite", Supported, &["source-over"], &[], ""),
    e("-webkit-tap-highlight-color", Dropped, &[], &["transparent"], ""),
    e("-webkit-text-fill-color", Supported, &["red", "transparent"], &[], ""),
    e("-webkit-text-stroke", Unsupported, &[], &["1px red"], ""),
    e("-webkit-text-stroke-color", Unsupported, &[], &["red"], ""),
    e("-webkit-text-stroke-width", Unsupported, &[], &["1px"], ""),
    e("-webkit-touch-callout", Dropped, &[], &["none"], ""),
    e("white-space", Supported, &["normal", "nowrap"], &[], ""),
    e("white-space-collapse", Unsupported, &[], &["preserve"], ""),
    e("width", Partial, &["auto", "10px", "calc-size(fit-content, size + 2em)"], SIZING_KEYWORDS, SIZING_NOTE),
    e("will-change", Ignored, &["transform", "auto"], &[], ""),
    e("window-drag", Supported, &["drag", "no-drag"], &[], ""),
    e("word-break", Supported, &["normal", "break-all"], &[], ""),
    e("word-spacing", Supported, &["normal", "2px"], &[], ""),
    e("word-wrap", Supported, &["normal", "break-word"], &[], ""),
    e("writing-mode", Unsupported, &[], &["vertical-rl"], "Horizontal text only"),
    e("x", Unsupported, &[], &["10px"], ""),
    e("y", Unsupported, &[], &["10px"], ""),
    e("z-index", Supported, &["auto", "10"], &[], ""),
    e("zoom", Unsupported, &[], &["1.5"], ""),
];

pub fn entry(name: &str) -> Option<&'static Entry> {
    let name = name.trim();
    CATALOG.iter().find(|e| e.name.eq_ignore_ascii_case(name))
}

/// `CSS.supports(property, value)`: the mapper applies the declaration, and the catalog does not list
/// the value as one it ignores (`width: fit-content` is accepted and changes nothing).
pub fn supports(name: &str, value: &str) -> bool {
    if !accepts_declaration(name, value) {
        return false;
    }
    let name = name.trim();
    let name = name
        .strip_prefix("-webkit-")
        .filter(|base| {
            crate::prefix::WEBKIT_APPLIED
                .iter()
                .any(|n| n.eq_ignore_ascii_case(base))
        })
        .unwrap_or(name);
    let value = value.split_whitespace().collect::<Vec<_>>().join(" ");
    entry(name).is_none_or(|e| !e.refused.iter().any(|r| r.eq_ignore_ascii_case(&value)))
}

/// Is the `-webkit-` spelling read as this property?
pub fn webkit_applied(name: &str) -> bool {
    crate::prefix::WEBKIT_APPLIED
        .iter()
        .any(|n| n.eq_ignore_ascii_case(name))
}

fn json_string(out: &mut String, s: &str) {
    out.push('"');
    for c in s.chars() {
        match c {
            '"' => out.push_str("\\\""),
            '\\' => out.push_str("\\\\"),
            '\n' => out.push_str("\\n"),
            c if (c as u32) < 0x20 => out.push_str(&format!("\\u{:04x}", c as u32)),
            c => out.push(c),
        }
    }
    out.push('"');
}

fn json_list(out: &mut String, items: impl IntoIterator<Item = impl AsRef<str>>) {
    out.push('[');
    for (i, s) in items.into_iter().enumerate() {
        if i > 0 {
            out.push_str(", ");
        }
        json_string(out, s.as_ref());
    }
    out.push(']');
}

/// The catalog as JSON, one object per property, with the advisory the engine prints for the first
/// refused value.
pub fn to_json() -> String {
    let mut out = String::from("[\n");
    for (i, e) in CATALOG.iter().enumerate() {
        out.push_str("  {\"name\": ");
        json_string(&mut out, e.name);
        out.push_str(", \"status\": ");
        json_string(&mut out, e.status.as_str());
        out.push_str(", \"note\": ");
        json_string(&mut out, e.note);
        out.push_str(", \"applied\": ");
        json_list(&mut out, e.applied);
        out.push_str(", \"refused\": ");
        json_list(&mut out, e.refused);
        out.push_str(", \"webkit\": ");
        out.push_str(if webkit_applied(e.name) {
            "true"
        } else {
            "false"
        });
        out.push_str(", \"platforms\": ");
        json_list(
            &mut out,
            e.platforms.iter().map(|p| match p {
                Platform::Windows => "windows",
                Platform::MacOs => "macos",
                Platform::Linux => "linux",
            }),
        );
        out.push_str(", \"advisory\": ");
        match e.refused.first().map(|v| verdict(e.name, v)) {
            Some(Verdict::Rejected(msg)) => json_string(&mut out, &msg),
            _ => out.push_str("null"),
        }
        out.push('}');
        if i + 1 < CATALOG.len() {
            out.push(',');
        }
        out.push('\n');
    }
    out.push(']');
    out
}

#[cfg(test)]
mod tests {
    use super::*;

    /// The anti-drift guard: every entry's samples get the verdict its status promises.
    #[test]
    fn the_catalog_agrees_with_the_mapper() {
        let mut wrong = Vec::new();
        for e in CATALOG {
            let mut check = |value: &str, ok: bool, want: &str| {
                if !ok {
                    wrong.push(format!(
                        "{}: {value} is {:?}, the catalog says {want} ({:?})",
                        e.name,
                        verdict(e.name, value),
                        e.status
                    ));
                }
            };
            for v in e.applied {
                let got = verdict(e.name, v);
                match e.status {
                    Supported | Partial => check(
                        v,
                        matches!(got, Verdict::Applied | Verdict::Inert) && supports(e.name, v),
                        "applied",
                    ),
                    Ignored => check(v, got == Verdict::Inert && supports(e.name, v), "inert"),
                    Unsupported | Dropped => check(v, false, "nothing applied"),
                }
            }
            for v in e.refused {
                let got = verdict(e.name, v);
                match e.status {
                    Partial => check(
                        v,
                        matches!(got, Verdict::Rejected(_) | Verdict::Inert)
                            && !supports(e.name, v),
                        "refused",
                    ),
                    Unsupported => check(v, matches!(got, Verdict::Rejected(_)), "rejected"),
                    Dropped => check(v, got == Verdict::Dropped, "dropped"),
                    Supported | Ignored => check(v, false, "no refused values"),
                }
            }
            let shape = match e.status {
                Supported => {
                    !e.applied.is_empty()
                        && e.applied
                            .iter()
                            .any(|v| verdict(e.name, v) == Verdict::Applied)
                }
                Partial => !e.applied.is_empty() && !e.note.is_empty(),
                Ignored => !e.applied.is_empty(),
                Unsupported | Dropped => e.applied.is_empty() && !e.refused.is_empty(),
            };
            if !shape {
                wrong.push(format!("{}: samples do not fit {:?}", e.name, e.status));
            }
        }
        assert!(wrong.is_empty(), "\n{}", wrong.join("\n"));
    }

    #[test]
    fn every_property_the_mapper_names_is_catalogued() {
        let src = include_str!("mapper.rs");
        let mut missing = Vec::new();
        for (at, _) in src.match_indices("CustomPropertyName::Unknown(name)") {
            let guard = &src[at..];
            let guard = &guard[..guard.find("=>").unwrap_or(0)];
            for literal in guard.split('"').skip(1).step_by(2) {
                if entry(literal).is_none() {
                    missing.push(literal.to_string());
                }
            }
        }
        for name in crate::prefix::WEBKIT_APPLIED {
            let known = lightningcss::properties::PropertyId::from(*name);
            let unknown = matches!(known, lightningcss::properties::PropertyId::Custom(_));
            if entry(name).is_none() && entry(&format!("-webkit-{name}")).is_none() && unknown {
                missing.push(format!("-webkit-{name}"));
            }
        }
        let mut names: Vec<_> = CATALOG.iter().map(|e| e.name).collect();
        names.sort_unstable();
        names.dedup();
        assert_eq!(names.len(), CATALOG.len(), "a property is listed twice");
        assert!(missing.is_empty(), "not in the catalog: {missing:?}");
    }

    #[test]
    fn supports_answers_what_the_engine_applies() {
        assert!(supports("order", "2"));
        assert!(supports("object-position", "center top"));
        assert!(supports("contain", "paint"));
        assert!(supports("scroll-behavior", "smooth"));
        assert!(supports("filter", "blur(4px)"));
        assert!(supports("box-shadow", "none"));
        assert!(supports("clip-path", "path(\"M0 0L10 10Z\")"));
        assert!(supports("width", "var(--w)"));
        assert!(supports("--anything", "at all"));
        assert!(supports("-webkit-user-select", "none"));
        assert!(!supports("width", "fit-content"));
        assert!(!supports("WIDTH", " Fit-Content "));
        assert!(!supports("animation-timing-function", "linear(0, 1)"));
        assert!(!supports("transition", "opacity 1s linear(0, 1)"));
        assert!(!supports("float", "left"));
        assert!(!supports("width", "red"));
        assert!(!supports("-moz-appearance", "none"));
        assert!(!supports("display", "flex; color: red"));
    }

    #[test]
    fn condition_text_is_evaluated_as_at_supports_is() {
        use crate::supports_condition_text as cond;
        assert!(cond("order: 2"));
        assert!(cond("(display: flex) and (not (float: left))"));
        assert!(cond(
            "(-webkit-backdrop-filter: blur(2px)) or (backdrop-filter: blur(2px))"
        ));
        assert!(!cond("(width: fit-content)"));
        assert!(!cond("(-moz-appearance: none)"));
        assert!(!cond("display: flex; color: red"));
        assert!(!cond(""));
    }

    /// `sk check` reads this copy; regenerate it with
    /// `cargo run -p sk-css --example css-catalog > packages/cli/check/css-catalog.json`.
    #[test]
    fn the_cli_copy_of_the_catalog_is_current() {
        let path = concat!(
            env!("CARGO_MANIFEST_DIR"),
            "/../../packages/cli/check/css-catalog.json"
        );
        let Ok(copy) = std::fs::read_to_string(path) else {
            return;
        };
        assert!(
            copy.replace("\r\n", "\n").trim_end() == to_json(),
            "packages/cli/check/css-catalog.json is stale: cargo run -p sk-css --example css-catalog > packages/cli/check/css-catalog.json"
        );
    }

    #[test]
    fn the_json_dump_is_one_object_per_property() {
        let parsed: serde_json::Value = serde_json::from_str(&to_json()).expect("valid JSON");
        let list = parsed.as_array().unwrap();
        assert_eq!(list.len(), CATALOG.len());
        let width = list.iter().find(|p| p["name"] == "width").unwrap();
        assert_eq!(width["status"], "partial");
        assert_eq!(width["refused"][0], "min-content");
        let float = list.iter().find(|p| p["name"] == "float").unwrap();
        assert!(float["advisory"].as_str().is_some_and(|a| !a.is_empty()));
    }
}