@pikacss/core 0.0.45 → 0.0.47

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 (3) hide show
  1. package/dist/index.d.mts +819 -725
  2. package/dist/index.mjs +1421 -197
  3. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -1,6 +1,840 @@
1
- //#region src/internal/constants.ts
2
- const ATOMIC_STYLE_ID_PLACEHOLDER = "%";
3
- const ATOMIC_STYLE_ID_PLACEHOLDER_RE_GLOBAL = /%/g;
1
+ //#region src/internal/generated-shorthand-map.ts
2
+ const PROPERTY_EFFECTS = {
3
+ "accent-color": ["accent-color"],
4
+ "align-content": ["align-content"],
5
+ "align-items": ["align-items"],
6
+ "align-self": ["align-self"],
7
+ "align-tracks": ["align-tracks"],
8
+ "alignment-baseline": ["alignment-baseline"],
9
+ "all": ["all"],
10
+ "anchor-name": ["anchor-name"],
11
+ "anchor-scope": ["anchor-scope"],
12
+ "animation": [
13
+ "animation-delay",
14
+ "animation-direction",
15
+ "animation-duration",
16
+ "animation-fill-mode",
17
+ "animation-iteration-count",
18
+ "animation-name",
19
+ "animation-play-state",
20
+ "animation-timeline",
21
+ "animation-timing-function"
22
+ ],
23
+ "animation-composition": ["animation-composition"],
24
+ "animation-delay": ["animation-delay"],
25
+ "animation-direction": ["animation-direction"],
26
+ "animation-duration": ["animation-duration"],
27
+ "animation-fill-mode": ["animation-fill-mode"],
28
+ "animation-iteration-count": ["animation-iteration-count"],
29
+ "animation-name": ["animation-name"],
30
+ "animation-play-state": ["animation-play-state"],
31
+ "animation-range": ["animation-range-end", "animation-range-start"],
32
+ "animation-range-end": ["animation-range-end"],
33
+ "animation-range-start": ["animation-range-start"],
34
+ "animation-timeline": ["animation-timeline"],
35
+ "animation-timing-function": ["animation-timing-function"],
36
+ "animation-trigger": ["animation-trigger"],
37
+ "appearance": ["appearance"],
38
+ "aspect-ratio": ["aspect-ratio"],
39
+ "backdrop-filter": ["backdrop-filter"],
40
+ "backface-visibility": ["backface-visibility"],
41
+ "background": [
42
+ "background-attachment",
43
+ "background-clip",
44
+ "background-color",
45
+ "background-image",
46
+ "background-origin",
47
+ "background-position-x",
48
+ "background-position-y",
49
+ "background-repeat",
50
+ "background-size"
51
+ ],
52
+ "background-attachment": ["background-attachment"],
53
+ "background-blend-mode": ["background-blend-mode"],
54
+ "background-clip": ["background-clip"],
55
+ "background-color": ["background-color"],
56
+ "background-image": ["background-image"],
57
+ "background-origin": ["background-origin"],
58
+ "background-position": ["background-position-x", "background-position-y"],
59
+ "background-position-x": ["background-position-x"],
60
+ "background-position-y": ["background-position-y"],
61
+ "background-repeat": ["background-repeat"],
62
+ "background-size": ["background-size"],
63
+ "baseline-shift": ["baseline-shift"],
64
+ "baseline-source": ["baseline-source"],
65
+ "block-size": ["block-size"],
66
+ "border": [
67
+ "border-bottom-color",
68
+ "border-left-color",
69
+ "border-right-color",
70
+ "border-top-color",
71
+ "border-bottom-style",
72
+ "border-left-style",
73
+ "border-right-style",
74
+ "border-top-style",
75
+ "border-bottom-width",
76
+ "border-left-width",
77
+ "border-right-width",
78
+ "border-top-width"
79
+ ],
80
+ "border-block": [
81
+ "border-block-end-color",
82
+ "border-block-start-color",
83
+ "border-block-end-style",
84
+ "border-block-start-style",
85
+ "border-block-end-width",
86
+ "border-block-start-width"
87
+ ],
88
+ "border-block-color": ["border-block-end-color", "border-block-start-color"],
89
+ "border-block-end": [
90
+ "border-block-end-color",
91
+ "border-block-end-style",
92
+ "border-block-end-width"
93
+ ],
94
+ "border-block-end-color": ["border-block-end-color"],
95
+ "border-block-end-style": ["border-block-end-style"],
96
+ "border-block-end-width": ["border-block-end-width"],
97
+ "border-block-start": [
98
+ "border-block-start-color",
99
+ "border-block-start-style",
100
+ "border-block-start-width"
101
+ ],
102
+ "border-block-start-color": ["border-block-start-color"],
103
+ "border-block-start-style": ["border-block-start-style"],
104
+ "border-block-start-width": ["border-block-start-width"],
105
+ "border-block-style": ["border-block-end-style", "border-block-start-style"],
106
+ "border-block-width": ["border-block-end-width", "border-block-start-width"],
107
+ "border-bottom": [
108
+ "border-bottom-color",
109
+ "border-bottom-style",
110
+ "border-bottom-width"
111
+ ],
112
+ "border-bottom-color": ["border-bottom-color"],
113
+ "border-bottom-left-radius": ["border-bottom-left-radius"],
114
+ "border-bottom-right-radius": ["border-bottom-right-radius"],
115
+ "border-bottom-style": ["border-bottom-style"],
116
+ "border-bottom-width": ["border-bottom-width"],
117
+ "border-collapse": ["border-collapse"],
118
+ "border-color": [
119
+ "border-bottom-color",
120
+ "border-left-color",
121
+ "border-right-color",
122
+ "border-top-color"
123
+ ],
124
+ "border-end-end-radius": ["border-end-end-radius"],
125
+ "border-end-start-radius": ["border-end-start-radius"],
126
+ "border-image": [
127
+ "border-image-outset",
128
+ "border-image-repeat",
129
+ "border-image-slice",
130
+ "border-image-source",
131
+ "border-image-width"
132
+ ],
133
+ "border-image-outset": ["border-image-outset"],
134
+ "border-image-repeat": ["border-image-repeat"],
135
+ "border-image-slice": ["border-image-slice"],
136
+ "border-image-source": ["border-image-source"],
137
+ "border-image-width": ["border-image-width"],
138
+ "border-inline": [
139
+ "border-inline-end-color",
140
+ "border-inline-start-color",
141
+ "border-inline-end-style",
142
+ "border-inline-start-style",
143
+ "border-inline-end-width",
144
+ "border-inline-start-width"
145
+ ],
146
+ "border-inline-color": ["border-inline-end-color", "border-inline-start-color"],
147
+ "border-inline-end": [
148
+ "border-inline-end-color",
149
+ "border-inline-end-style",
150
+ "border-inline-end-width"
151
+ ],
152
+ "border-inline-end-color": ["border-inline-end-color"],
153
+ "border-inline-end-style": ["border-inline-end-style"],
154
+ "border-inline-end-width": ["border-inline-end-width"],
155
+ "border-inline-start": [
156
+ "border-inline-start-color",
157
+ "border-inline-start-style",
158
+ "border-inline-start-width"
159
+ ],
160
+ "border-inline-start-color": ["border-inline-start-color"],
161
+ "border-inline-start-style": ["border-inline-start-style"],
162
+ "border-inline-start-width": ["border-inline-start-width"],
163
+ "border-inline-style": ["border-inline-end-style", "border-inline-start-style"],
164
+ "border-inline-width": ["border-inline-end-width", "border-inline-start-width"],
165
+ "border-left": [
166
+ "border-left-color",
167
+ "border-left-style",
168
+ "border-left-width"
169
+ ],
170
+ "border-left-color": ["border-left-color"],
171
+ "border-left-style": ["border-left-style"],
172
+ "border-left-width": ["border-left-width"],
173
+ "border-radius": [
174
+ "border-bottom-left-radius",
175
+ "border-bottom-right-radius",
176
+ "border-top-left-radius",
177
+ "border-top-right-radius"
178
+ ],
179
+ "border-right": [
180
+ "border-right-color",
181
+ "border-right-style",
182
+ "border-right-width"
183
+ ],
184
+ "border-right-color": ["border-right-color"],
185
+ "border-right-style": ["border-right-style"],
186
+ "border-right-width": ["border-right-width"],
187
+ "border-spacing": ["border-spacing"],
188
+ "border-start-end-radius": ["border-start-end-radius"],
189
+ "border-start-start-radius": ["border-start-start-radius"],
190
+ "border-style": [
191
+ "border-bottom-style",
192
+ "border-left-style",
193
+ "border-right-style",
194
+ "border-top-style"
195
+ ],
196
+ "border-top": [
197
+ "border-top-color",
198
+ "border-top-style",
199
+ "border-top-width"
200
+ ],
201
+ "border-top-color": ["border-top-color"],
202
+ "border-top-left-radius": ["border-top-left-radius"],
203
+ "border-top-right-radius": ["border-top-right-radius"],
204
+ "border-top-style": ["border-top-style"],
205
+ "border-top-width": ["border-top-width"],
206
+ "border-width": [
207
+ "border-bottom-width",
208
+ "border-left-width",
209
+ "border-right-width",
210
+ "border-top-width"
211
+ ],
212
+ "bottom": ["bottom"],
213
+ "box-align": ["box-align"],
214
+ "box-decoration-break": ["box-decoration-break"],
215
+ "box-direction": ["box-direction"],
216
+ "box-flex": ["box-flex"],
217
+ "box-flex-group": ["box-flex-group"],
218
+ "box-lines": ["box-lines"],
219
+ "box-ordinal-group": ["box-ordinal-group"],
220
+ "box-orient": ["box-orient"],
221
+ "box-pack": ["box-pack"],
222
+ "box-shadow": ["box-shadow"],
223
+ "box-sizing": ["box-sizing"],
224
+ "break-after": ["break-after"],
225
+ "break-before": ["break-before"],
226
+ "break-inside": ["break-inside"],
227
+ "caption-side": ["caption-side"],
228
+ "caret": [
229
+ "caret-animation",
230
+ "caret-color",
231
+ "caret-shape"
232
+ ],
233
+ "caret-animation": ["caret-animation"],
234
+ "caret-color": ["caret-color"],
235
+ "caret-shape": ["caret-shape"],
236
+ "clear": ["clear"],
237
+ "clip": ["clip"],
238
+ "clip-path": ["clip-path"],
239
+ "clip-rule": ["clip-rule"],
240
+ "color": ["color"],
241
+ "color-interpolation-filters": ["color-interpolation-filters"],
242
+ "color-scheme": ["color-scheme"],
243
+ "column-count": ["column-count"],
244
+ "column-fill": ["column-fill"],
245
+ "column-gap": ["column-gap"],
246
+ "column-height": ["column-height"],
247
+ "column-rule": [
248
+ "column-rule-color",
249
+ "column-rule-style",
250
+ "column-rule-width"
251
+ ],
252
+ "column-rule-color": ["column-rule-color"],
253
+ "column-rule-style": ["column-rule-style"],
254
+ "column-rule-width": ["column-rule-width"],
255
+ "column-span": ["column-span"],
256
+ "column-width": ["column-width"],
257
+ "column-wrap": ["column-wrap"],
258
+ "columns": [
259
+ "column-count",
260
+ "column-height",
261
+ "column-width"
262
+ ],
263
+ "contain": ["contain"],
264
+ "contain-intrinsic-block-size": ["contain-intrinsic-block-size"],
265
+ "contain-intrinsic-height": ["contain-intrinsic-height"],
266
+ "contain-intrinsic-inline-size": ["contain-intrinsic-inline-size"],
267
+ "contain-intrinsic-size": ["contain-intrinsic-height", "contain-intrinsic-width"],
268
+ "contain-intrinsic-width": ["contain-intrinsic-width"],
269
+ "container": ["container-name", "container-type"],
270
+ "container-name": ["container-name"],
271
+ "container-type": ["container-type"],
272
+ "content": ["content"],
273
+ "content-visibility": ["content-visibility"],
274
+ "corner-block-end-shape": ["corner-end-end-shape", "corner-end-start-shape"],
275
+ "corner-block-start-shape": ["corner-start-end-shape", "corner-start-start-shape"],
276
+ "corner-bottom-left-shape": ["corner-bottom-left-shape"],
277
+ "corner-bottom-right-shape": ["corner-bottom-right-shape"],
278
+ "corner-bottom-shape": ["corner-bottom-left-shape", "corner-bottom-right-shape"],
279
+ "corner-end-end-shape": ["corner-end-end-shape"],
280
+ "corner-end-start-shape": ["corner-end-start-shape"],
281
+ "corner-inline-end-shape": ["corner-end-end-shape", "corner-start-end-shape"],
282
+ "corner-inline-start-shape": ["corner-start-end-shape", "corner-start-start-shape"],
283
+ "corner-left-shape": ["corner-bottom-left-shape", "corner-top-left-shape"],
284
+ "corner-right-shape": ["corner-bottom-right-shape", "corner-top-right-shape"],
285
+ "corner-shape": [
286
+ "corner-bottom-left-shape",
287
+ "corner-bottom-right-shape",
288
+ "corner-top-left-shape",
289
+ "corner-top-right-shape"
290
+ ],
291
+ "corner-start-end-shape": ["corner-start-end-shape"],
292
+ "corner-start-start-shape": ["corner-start-start-shape"],
293
+ "corner-top-left-shape": ["corner-top-left-shape"],
294
+ "corner-top-right-shape": ["corner-top-right-shape"],
295
+ "corner-top-shape": ["corner-top-left-shape", "corner-top-right-shape"],
296
+ "counter-increment": ["counter-increment"],
297
+ "counter-reset": ["counter-reset"],
298
+ "counter-set": ["counter-set"],
299
+ "cursor": ["cursor"],
300
+ "cx": ["cx"],
301
+ "cy": ["cy"],
302
+ "d": ["d"],
303
+ "direction": ["direction"],
304
+ "display": ["display"],
305
+ "dominant-baseline": ["dominant-baseline"],
306
+ "dynamic-range-limit": ["dynamic-range-limit"],
307
+ "empty-cells": ["empty-cells"],
308
+ "field-sizing": ["field-sizing"],
309
+ "fill": ["fill"],
310
+ "fill-opacity": ["fill-opacity"],
311
+ "fill-rule": ["fill-rule"],
312
+ "filter": ["filter"],
313
+ "flex": [
314
+ "flex-basis",
315
+ "flex-grow",
316
+ "flex-shrink"
317
+ ],
318
+ "flex-basis": ["flex-basis"],
319
+ "flex-direction": ["flex-direction"],
320
+ "flex-flow": ["flex-direction", "flex-wrap"],
321
+ "flex-grow": ["flex-grow"],
322
+ "flex-shrink": ["flex-shrink"],
323
+ "flex-wrap": ["flex-wrap"],
324
+ "float": ["float"],
325
+ "flood-color": ["flood-color"],
326
+ "flood-opacity": ["flood-opacity"],
327
+ "font": [
328
+ "font-family",
329
+ "font-size",
330
+ "font-stretch",
331
+ "font-style",
332
+ "font-variant-alternates",
333
+ "font-variant-caps",
334
+ "font-variant-east-asian",
335
+ "font-variant-emoji",
336
+ "font-variant-ligatures",
337
+ "font-variant-numeric",
338
+ "font-variant-position",
339
+ "font-weight",
340
+ "line-height"
341
+ ],
342
+ "font-family": ["font-family"],
343
+ "font-feature-settings": ["font-feature-settings"],
344
+ "font-kerning": ["font-kerning"],
345
+ "font-language-override": ["font-language-override"],
346
+ "font-optical-sizing": ["font-optical-sizing"],
347
+ "font-palette": ["font-palette"],
348
+ "font-size": ["font-size"],
349
+ "font-size-adjust": ["font-size-adjust"],
350
+ "font-smooth": ["font-smooth"],
351
+ "font-stretch": ["font-stretch"],
352
+ "font-style": ["font-style"],
353
+ "font-synthesis": [
354
+ "font-synthesis-position",
355
+ "font-synthesis-small-caps",
356
+ "font-synthesis-style",
357
+ "font-synthesis-weight"
358
+ ],
359
+ "font-synthesis-position": ["font-synthesis-position"],
360
+ "font-synthesis-small-caps": ["font-synthesis-small-caps"],
361
+ "font-synthesis-style": ["font-synthesis-style"],
362
+ "font-synthesis-weight": ["font-synthesis-weight"],
363
+ "font-variant": [
364
+ "font-variant-alternates",
365
+ "font-variant-caps",
366
+ "font-variant-east-asian",
367
+ "font-variant-emoji",
368
+ "font-variant-ligatures",
369
+ "font-variant-numeric",
370
+ "font-variant-position"
371
+ ],
372
+ "font-variant-alternates": ["font-variant-alternates"],
373
+ "font-variant-caps": ["font-variant-caps"],
374
+ "font-variant-east-asian": ["font-variant-east-asian"],
375
+ "font-variant-emoji": ["font-variant-emoji"],
376
+ "font-variant-ligatures": ["font-variant-ligatures"],
377
+ "font-variant-numeric": ["font-variant-numeric"],
378
+ "font-variant-position": ["font-variant-position"],
379
+ "font-variation-settings": ["font-variation-settings"],
380
+ "font-weight": ["font-weight"],
381
+ "font-width": ["font-width"],
382
+ "forced-color-adjust": ["forced-color-adjust"],
383
+ "gap": ["column-gap", "row-gap"],
384
+ "grid": [
385
+ "column-gap",
386
+ "grid-auto-columns",
387
+ "grid-auto-flow",
388
+ "grid-auto-rows",
389
+ "grid-column-gap",
390
+ "grid-row-gap",
391
+ "grid-template-areas",
392
+ "grid-template-columns",
393
+ "grid-template-rows",
394
+ "row-gap"
395
+ ],
396
+ "grid-area": [
397
+ "grid-column-end",
398
+ "grid-column-start",
399
+ "grid-row-end",
400
+ "grid-row-start"
401
+ ],
402
+ "grid-auto-columns": ["grid-auto-columns"],
403
+ "grid-auto-flow": ["grid-auto-flow"],
404
+ "grid-auto-rows": ["grid-auto-rows"],
405
+ "grid-column": ["grid-column-end", "grid-column-start"],
406
+ "grid-column-end": ["grid-column-end"],
407
+ "grid-column-gap": ["grid-column-gap"],
408
+ "grid-column-start": ["grid-column-start"],
409
+ "grid-gap": ["grid-column-gap", "grid-row-gap"],
410
+ "grid-row": ["grid-row-end", "grid-row-start"],
411
+ "grid-row-end": ["grid-row-end"],
412
+ "grid-row-gap": ["grid-row-gap"],
413
+ "grid-row-start": ["grid-row-start"],
414
+ "grid-template": [
415
+ "grid-template-areas",
416
+ "grid-template-columns",
417
+ "grid-template-rows"
418
+ ],
419
+ "grid-template-areas": ["grid-template-areas"],
420
+ "grid-template-columns": ["grid-template-columns"],
421
+ "grid-template-rows": ["grid-template-rows"],
422
+ "hanging-punctuation": ["hanging-punctuation"],
423
+ "height": ["height"],
424
+ "hyphenate-character": ["hyphenate-character"],
425
+ "hyphenate-limit-chars": ["hyphenate-limit-chars"],
426
+ "hyphens": ["hyphens"],
427
+ "image-orientation": ["image-orientation"],
428
+ "image-rendering": ["image-rendering"],
429
+ "image-resolution": ["image-resolution"],
430
+ "ime-mode": ["ime-mode"],
431
+ "initial-letter": ["initial-letter"],
432
+ "initial-letter-align": ["initial-letter-align"],
433
+ "inline-size": ["inline-size"],
434
+ "inset": [
435
+ "bottom",
436
+ "left",
437
+ "right",
438
+ "top"
439
+ ],
440
+ "inset-block": ["inset-block-end", "inset-block-start"],
441
+ "inset-block-end": ["inset-block-end"],
442
+ "inset-block-start": ["inset-block-start"],
443
+ "inset-inline": ["inset-inline-end", "inset-inline-start"],
444
+ "inset-inline-end": ["inset-inline-end"],
445
+ "inset-inline-start": ["inset-inline-start"],
446
+ "interactivity": ["interactivity"],
447
+ "interest-delay": ["interest-delay-end", "interest-delay-start"],
448
+ "interest-delay-end": ["interest-delay-end"],
449
+ "interest-delay-start": ["interest-delay-start"],
450
+ "interpolate-size": ["interpolate-size"],
451
+ "isolation": ["isolation"],
452
+ "justify-content": ["justify-content"],
453
+ "justify-items": ["justify-items"],
454
+ "justify-self": ["justify-self"],
455
+ "justify-tracks": ["justify-tracks"],
456
+ "left": ["left"],
457
+ "letter-spacing": ["letter-spacing"],
458
+ "lighting-color": ["lighting-color"],
459
+ "line-break": ["line-break"],
460
+ "line-clamp": ["line-clamp"],
461
+ "line-height": ["line-height"],
462
+ "line-height-step": ["line-height-step"],
463
+ "list-style": [
464
+ "list-style-image",
465
+ "list-style-position",
466
+ "list-style-type"
467
+ ],
468
+ "list-style-image": ["list-style-image"],
469
+ "list-style-position": ["list-style-position"],
470
+ "list-style-type": ["list-style-type"],
471
+ "margin": [
472
+ "margin-bottom",
473
+ "margin-left",
474
+ "margin-right",
475
+ "margin-top"
476
+ ],
477
+ "margin-block": ["margin-block-end", "margin-block-start"],
478
+ "margin-block-end": ["margin-block-end"],
479
+ "margin-block-start": ["margin-block-start"],
480
+ "margin-bottom": ["margin-bottom"],
481
+ "margin-inline": ["margin-inline-end", "margin-inline-start"],
482
+ "margin-inline-end": ["margin-inline-end"],
483
+ "margin-inline-start": ["margin-inline-start"],
484
+ "margin-left": ["margin-left"],
485
+ "margin-right": ["margin-right"],
486
+ "margin-top": ["margin-top"],
487
+ "margin-trim": ["margin-trim"],
488
+ "marker": [
489
+ "marker-end",
490
+ "marker-mid",
491
+ "marker-start"
492
+ ],
493
+ "marker-end": ["marker-end"],
494
+ "marker-mid": ["marker-mid"],
495
+ "marker-start": ["marker-start"],
496
+ "mask": [
497
+ "mask-clip",
498
+ "mask-composite",
499
+ "mask-image",
500
+ "mask-mode",
501
+ "mask-origin",
502
+ "mask-position",
503
+ "mask-repeat",
504
+ "mask-size"
505
+ ],
506
+ "mask-border": [
507
+ "mask-border-mode",
508
+ "mask-border-outset",
509
+ "mask-border-repeat",
510
+ "mask-border-slice",
511
+ "mask-border-source",
512
+ "mask-border-width"
513
+ ],
514
+ "mask-border-mode": ["mask-border-mode"],
515
+ "mask-border-outset": ["mask-border-outset"],
516
+ "mask-border-repeat": ["mask-border-repeat"],
517
+ "mask-border-slice": ["mask-border-slice"],
518
+ "mask-border-source": ["mask-border-source"],
519
+ "mask-border-width": ["mask-border-width"],
520
+ "mask-clip": ["mask-clip"],
521
+ "mask-composite": ["mask-composite"],
522
+ "mask-image": ["mask-image"],
523
+ "mask-mode": ["mask-mode"],
524
+ "mask-origin": ["mask-origin"],
525
+ "mask-position": ["mask-position"],
526
+ "mask-repeat": ["mask-repeat"],
527
+ "mask-size": ["mask-size"],
528
+ "mask-type": ["mask-type"],
529
+ "masonry-auto-flow": ["masonry-auto-flow"],
530
+ "math-depth": ["math-depth"],
531
+ "math-shift": ["math-shift"],
532
+ "math-style": ["math-style"],
533
+ "max-block-size": ["max-block-size"],
534
+ "max-height": ["max-height"],
535
+ "max-inline-size": ["max-inline-size"],
536
+ "max-lines": ["max-lines"],
537
+ "max-width": ["max-width"],
538
+ "min-block-size": ["min-block-size"],
539
+ "min-height": ["min-height"],
540
+ "min-inline-size": ["min-inline-size"],
541
+ "min-width": ["min-width"],
542
+ "mix-blend-mode": ["mix-blend-mode"],
543
+ "object-fit": ["object-fit"],
544
+ "object-position": ["object-position"],
545
+ "object-view-box": ["object-view-box"],
546
+ "offset": [
547
+ "offset-anchor",
548
+ "offset-distance",
549
+ "offset-path",
550
+ "offset-position",
551
+ "offset-rotate"
552
+ ],
553
+ "offset-anchor": ["offset-anchor"],
554
+ "offset-distance": ["offset-distance"],
555
+ "offset-path": ["offset-path"],
556
+ "offset-position": ["offset-position"],
557
+ "offset-rotate": ["offset-rotate"],
558
+ "opacity": ["opacity"],
559
+ "order": ["order"],
560
+ "orphans": ["orphans"],
561
+ "outline": [
562
+ "outline-color",
563
+ "outline-style",
564
+ "outline-width"
565
+ ],
566
+ "outline-color": ["outline-color"],
567
+ "outline-offset": ["outline-offset"],
568
+ "outline-style": ["outline-style"],
569
+ "outline-width": ["outline-width"],
570
+ "overflow": ["overflow-x", "overflow-y"],
571
+ "overflow-anchor": ["overflow-anchor"],
572
+ "overflow-block": ["overflow-block"],
573
+ "overflow-clip-box": ["overflow-clip-box"],
574
+ "overflow-clip-margin": ["overflow-clip-margin"],
575
+ "overflow-inline": ["overflow-inline"],
576
+ "overflow-wrap": ["overflow-wrap"],
577
+ "overflow-x": ["overflow-x"],
578
+ "overflow-y": ["overflow-y"],
579
+ "overlay": ["overlay"],
580
+ "overscroll-behavior": ["overscroll-behavior-x", "overscroll-behavior-y"],
581
+ "overscroll-behavior-block": ["overscroll-behavior-block"],
582
+ "overscroll-behavior-inline": ["overscroll-behavior-inline"],
583
+ "overscroll-behavior-x": ["overscroll-behavior-x"],
584
+ "overscroll-behavior-y": ["overscroll-behavior-y"],
585
+ "padding": [
586
+ "padding-bottom",
587
+ "padding-left",
588
+ "padding-right",
589
+ "padding-top"
590
+ ],
591
+ "padding-block": ["padding-block-end", "padding-block-start"],
592
+ "padding-block-end": ["padding-block-end"],
593
+ "padding-block-start": ["padding-block-start"],
594
+ "padding-bottom": ["padding-bottom"],
595
+ "padding-inline": ["padding-inline-end", "padding-inline-start"],
596
+ "padding-inline-end": ["padding-inline-end"],
597
+ "padding-inline-start": ["padding-inline-start"],
598
+ "padding-left": ["padding-left"],
599
+ "padding-right": ["padding-right"],
600
+ "padding-top": ["padding-top"],
601
+ "page": ["page"],
602
+ "page-break-after": ["page-break-after"],
603
+ "page-break-before": ["page-break-before"],
604
+ "page-break-inside": ["page-break-inside"],
605
+ "paint-order": ["paint-order"],
606
+ "perspective": ["perspective"],
607
+ "perspective-origin": ["perspective-origin"],
608
+ "place-content": ["align-content", "justify-content"],
609
+ "place-items": ["align-items", "justify-items"],
610
+ "place-self": ["align-self", "justify-self"],
611
+ "pointer-events": ["pointer-events"],
612
+ "position": ["position"],
613
+ "position-anchor": ["position-anchor"],
614
+ "position-area": ["position-area"],
615
+ "position-try": ["position-try-fallbacks", "position-try-order"],
616
+ "position-try-fallbacks": ["position-try-fallbacks"],
617
+ "position-try-order": ["position-try-order"],
618
+ "position-visibility": ["position-visibility"],
619
+ "print-color-adjust": ["print-color-adjust"],
620
+ "quotes": ["quotes"],
621
+ "r": ["r"],
622
+ "reading-flow": ["reading-flow"],
623
+ "reading-order": ["reading-order"],
624
+ "resize": ["resize"],
625
+ "right": ["right"],
626
+ "rotate": ["rotate"],
627
+ "row-gap": ["row-gap"],
628
+ "ruby-align": ["ruby-align"],
629
+ "ruby-merge": ["ruby-merge"],
630
+ "ruby-overhang": ["ruby-overhang"],
631
+ "ruby-position": ["ruby-position"],
632
+ "rx": ["rx"],
633
+ "ry": ["ry"],
634
+ "scale": ["scale"],
635
+ "scroll-behavior": ["scroll-behavior"],
636
+ "scroll-initial-target": ["scroll-initial-target"],
637
+ "scroll-margin": [
638
+ "scroll-margin-bottom",
639
+ "scroll-margin-left",
640
+ "scroll-margin-right",
641
+ "scroll-margin-top"
642
+ ],
643
+ "scroll-margin-block": ["scroll-margin-block-end", "scroll-margin-block-start"],
644
+ "scroll-margin-block-end": ["scroll-margin-block-end"],
645
+ "scroll-margin-block-start": ["scroll-margin-block-start"],
646
+ "scroll-margin-bottom": ["scroll-margin-bottom"],
647
+ "scroll-margin-inline": ["scroll-margin-inline-end", "scroll-margin-inline-start"],
648
+ "scroll-margin-inline-end": ["scroll-margin-inline-end"],
649
+ "scroll-margin-inline-start": ["scroll-margin-inline-start"],
650
+ "scroll-margin-left": ["scroll-margin-left"],
651
+ "scroll-margin-right": ["scroll-margin-right"],
652
+ "scroll-margin-top": ["scroll-margin-top"],
653
+ "scroll-marker-group": ["scroll-marker-group"],
654
+ "scroll-padding": [
655
+ "scroll-padding-bottom",
656
+ "scroll-padding-left",
657
+ "scroll-padding-right",
658
+ "scroll-padding-top"
659
+ ],
660
+ "scroll-padding-block": ["scroll-padding-block-end", "scroll-padding-block-start"],
661
+ "scroll-padding-block-end": ["scroll-padding-block-end"],
662
+ "scroll-padding-block-start": ["scroll-padding-block-start"],
663
+ "scroll-padding-bottom": ["scroll-padding-bottom"],
664
+ "scroll-padding-inline": ["scroll-padding-inline-end", "scroll-padding-inline-start"],
665
+ "scroll-padding-inline-end": ["scroll-padding-inline-end"],
666
+ "scroll-padding-inline-start": ["scroll-padding-inline-start"],
667
+ "scroll-padding-left": ["scroll-padding-left"],
668
+ "scroll-padding-right": ["scroll-padding-right"],
669
+ "scroll-padding-top": ["scroll-padding-top"],
670
+ "scroll-snap-align": ["scroll-snap-align"],
671
+ "scroll-snap-coordinate": ["scroll-snap-coordinate"],
672
+ "scroll-snap-destination": ["scroll-snap-destination"],
673
+ "scroll-snap-points-x": ["scroll-snap-points-x"],
674
+ "scroll-snap-points-y": ["scroll-snap-points-y"],
675
+ "scroll-snap-stop": ["scroll-snap-stop"],
676
+ "scroll-snap-type": ["scroll-snap-type"],
677
+ "scroll-snap-type-x": ["scroll-snap-type-x"],
678
+ "scroll-snap-type-y": ["scroll-snap-type-y"],
679
+ "scroll-target-group": ["scroll-target-group"],
680
+ "scroll-timeline": ["scroll-timeline-axis", "scroll-timeline-name"],
681
+ "scroll-timeline-axis": ["scroll-timeline-axis"],
682
+ "scroll-timeline-name": ["scroll-timeline-name"],
683
+ "scrollbar-color": ["scrollbar-color"],
684
+ "scrollbar-gutter": ["scrollbar-gutter"],
685
+ "scrollbar-width": ["scrollbar-width"],
686
+ "shape-image-threshold": ["shape-image-threshold"],
687
+ "shape-margin": ["shape-margin"],
688
+ "shape-outside": ["shape-outside"],
689
+ "shape-rendering": ["shape-rendering"],
690
+ "speak-as": ["speak-as"],
691
+ "stop-color": ["stop-color"],
692
+ "stop-opacity": ["stop-opacity"],
693
+ "stroke": [
694
+ "stroke-dasharray",
695
+ "stroke-dashoffset",
696
+ "stroke-linecap",
697
+ "stroke-linejoin",
698
+ "stroke-miterlimit",
699
+ "stroke-opacity",
700
+ "stroke-width"
701
+ ],
702
+ "stroke-color": ["stroke-color"],
703
+ "stroke-dasharray": ["stroke-dasharray"],
704
+ "stroke-dashoffset": ["stroke-dashoffset"],
705
+ "stroke-linecap": ["stroke-linecap"],
706
+ "stroke-linejoin": ["stroke-linejoin"],
707
+ "stroke-miterlimit": ["stroke-miterlimit"],
708
+ "stroke-opacity": ["stroke-opacity"],
709
+ "stroke-width": ["stroke-width"],
710
+ "tab-size": ["tab-size"],
711
+ "table-layout": ["table-layout"],
712
+ "text-align": ["text-align"],
713
+ "text-align-last": ["text-align-last"],
714
+ "text-anchor": ["text-anchor"],
715
+ "text-autospace": ["text-autospace"],
716
+ "text-box": ["text-box-edge", "text-box-trim"],
717
+ "text-box-edge": ["text-box-edge"],
718
+ "text-box-trim": ["text-box-trim"],
719
+ "text-combine-upright": ["text-combine-upright"],
720
+ "text-decoration": [
721
+ "text-decoration-color",
722
+ "text-decoration-line",
723
+ "text-decoration-style",
724
+ "text-decoration-thickness"
725
+ ],
726
+ "text-decoration-color": ["text-decoration-color"],
727
+ "text-decoration-inset": ["text-decoration-inset"],
728
+ "text-decoration-line": ["text-decoration-line"],
729
+ "text-decoration-skip": ["text-decoration-skip"],
730
+ "text-decoration-skip-ink": ["text-decoration-skip-ink"],
731
+ "text-decoration-style": ["text-decoration-style"],
732
+ "text-decoration-thickness": ["text-decoration-thickness"],
733
+ "text-emphasis": ["text-emphasis-color", "text-emphasis-style"],
734
+ "text-emphasis-color": ["text-emphasis-color"],
735
+ "text-emphasis-position": ["text-emphasis-position"],
736
+ "text-emphasis-style": ["text-emphasis-style"],
737
+ "text-indent": ["text-indent"],
738
+ "text-justify": ["text-justify"],
739
+ "text-orientation": ["text-orientation"],
740
+ "text-overflow": ["text-overflow"],
741
+ "text-rendering": ["text-rendering"],
742
+ "text-shadow": ["text-shadow"],
743
+ "text-size-adjust": ["text-size-adjust"],
744
+ "text-spacing-trim": ["text-spacing-trim"],
745
+ "text-transform": ["text-transform"],
746
+ "text-underline-offset": ["text-underline-offset"],
747
+ "text-underline-position": ["text-underline-position"],
748
+ "text-wrap": ["text-wrap-mode", "text-wrap-style"],
749
+ "text-wrap-mode": ["text-wrap-mode"],
750
+ "text-wrap-style": ["text-wrap-style"],
751
+ "timeline-scope": ["timeline-scope"],
752
+ "timeline-trigger": [
753
+ "timeline-trigger-exit-range-end",
754
+ "timeline-trigger-exit-range-start",
755
+ "timeline-trigger-name",
756
+ "timeline-trigger-range-end",
757
+ "timeline-trigger-range-start",
758
+ "timeline-trigger-source"
759
+ ],
760
+ "timeline-trigger-exit-range": ["timeline-trigger-exit-range-end", "timeline-trigger-exit-range-start"],
761
+ "timeline-trigger-exit-range-end": ["timeline-trigger-exit-range-end"],
762
+ "timeline-trigger-exit-range-start": ["timeline-trigger-exit-range-start"],
763
+ "timeline-trigger-name": ["timeline-trigger-name"],
764
+ "timeline-trigger-range": ["timeline-trigger-range-end", "timeline-trigger-range-start"],
765
+ "timeline-trigger-range-end": ["timeline-trigger-range-end"],
766
+ "timeline-trigger-range-start": ["timeline-trigger-range-start"],
767
+ "timeline-trigger-source": ["timeline-trigger-source"],
768
+ "top": ["top"],
769
+ "touch-action": ["touch-action"],
770
+ "transform": ["transform"],
771
+ "transform-box": ["transform-box"],
772
+ "transform-origin": ["transform-origin"],
773
+ "transform-style": ["transform-style"],
774
+ "transition": [
775
+ "transition-behavior",
776
+ "transition-delay",
777
+ "transition-duration",
778
+ "transition-property",
779
+ "transition-timing-function"
780
+ ],
781
+ "transition-behavior": ["transition-behavior"],
782
+ "transition-delay": ["transition-delay"],
783
+ "transition-duration": ["transition-duration"],
784
+ "transition-property": ["transition-property"],
785
+ "transition-timing-function": ["transition-timing-function"],
786
+ "translate": ["translate"],
787
+ "trigger-scope": ["trigger-scope"],
788
+ "unicode-bidi": ["unicode-bidi"],
789
+ "user-select": ["user-select"],
790
+ "vector-effect": ["vector-effect"],
791
+ "vertical-align": ["vertical-align"],
792
+ "view-timeline": ["view-timeline-axis", "view-timeline-name"],
793
+ "view-timeline-axis": ["view-timeline-axis"],
794
+ "view-timeline-inset": ["view-timeline-inset"],
795
+ "view-timeline-name": ["view-timeline-name"],
796
+ "view-transition-class": ["view-transition-class"],
797
+ "view-transition-name": ["view-transition-name"],
798
+ "visibility": ["visibility"],
799
+ "white-space": ["text-wrap-mode", "white-space-collapse"],
800
+ "white-space-collapse": ["white-space-collapse"],
801
+ "widows": ["widows"],
802
+ "width": ["width"],
803
+ "will-change": ["will-change"],
804
+ "word-break": ["word-break"],
805
+ "word-spacing": ["word-spacing"],
806
+ "word-wrap": ["word-wrap"],
807
+ "writing-mode": ["writing-mode"],
808
+ "x": ["x"],
809
+ "y": ["y"],
810
+ "z-index": ["z-index"],
811
+ "zoom": ["zoom"]
812
+ };
813
+
814
+ //#endregion
815
+ //#region src/internal/property-effects.ts
816
+ const UNIVERSAL_EFFECT = "*";
817
+ const propertyEffectsLookup = PROPERTY_EFFECTS;
818
+ function isCustomProperty(property) {
819
+ return property.startsWith("--");
820
+ }
821
+ function isVendorPrefixedProperty(property) {
822
+ return property.startsWith("-") && property.startsWith("--") === false;
823
+ }
824
+ function getPropertyEffects(property) {
825
+ if (property === "all") return [UNIVERSAL_EFFECT];
826
+ if (isCustomProperty(property) || isVendorPrefixedProperty(property)) return [property];
827
+ return propertyEffectsLookup[property] || [property];
828
+ }
829
+ function hasPropertyEffectOverlap(left, right) {
830
+ if (left === right) return true;
831
+ if (isCustomProperty(left) || isCustomProperty(right)) return false;
832
+ const leftEffects = getPropertyEffects(left);
833
+ const rightEffects = getPropertyEffects(right);
834
+ if (leftEffects.includes(UNIVERSAL_EFFECT) || rightEffects.includes(UNIVERSAL_EFFECT)) return true;
835
+ const rightEffectSet = new Set(rightEffects);
836
+ return leftEffects.some((effect) => rightEffectSet.has(effect));
837
+ }
4
838
 
5
839
  //#endregion
6
840
  //#region src/internal/utils.ts
@@ -79,27 +913,44 @@ function serialize(value) {
79
913
  return JSON.stringify(value);
80
914
  }
81
915
  function addToSet(set, ...values) {
916
+ const before = set.size;
82
917
  values.forEach((value) => set.add(value));
918
+ return set.size !== before;
83
919
  }
84
- function appendAutocompleteSelectors(config, ...selectors) {
85
- addToSet(config.autocomplete.selectors, ...selectors);
86
- }
87
- function appendAutocompleteStyleItemStrings(config, ...styleItemStrings) {
88
- addToSet(config.autocomplete.styleItemStrings, ...styleItemStrings);
89
- }
90
- function appendAutocompleteExtraProperties(config, ...properties) {
91
- addToSet(config.autocomplete.extraProperties, ...properties);
920
+ function appendAutocompleteEntries(set, values) {
921
+ if (values == null) return false;
922
+ return addToSet(set, ...[values].flat());
92
923
  }
93
- function appendAutocompleteExtraCssProperties(config, ...properties) {
94
- addToSet(config.autocomplete.extraCssProperties, ...properties);
924
+ function appendAutocompleteRecordEntries(map, entries) {
925
+ if (entries == null) return false;
926
+ let changed = false;
927
+ for (const [key, value] of Object.entries(entries)) {
928
+ const nextValues = [value].flat();
929
+ if (nextValues.length === 0) continue;
930
+ const current = map.get(key) || [];
931
+ map.set(key, [...current, ...nextValues]);
932
+ changed = true;
933
+ }
934
+ return changed;
95
935
  }
96
- function appendAutocompletePropertyValues(config, property, ...tsTypes) {
97
- const current = config.autocomplete.properties.get(property) || [];
98
- config.autocomplete.properties.set(property, [...current, ...tsTypes]);
936
+ function normalizeAutocompleteRecordEntries(entries) {
937
+ if (entries == null) return void 0;
938
+ return Array.isArray(entries) ? Object.fromEntries(entries) : entries;
99
939
  }
100
- function appendAutocompleteCssPropertyValues(config, property, ...values) {
101
- const current = config.autocomplete.cssProperties.get(property) || [];
102
- config.autocomplete.cssProperties.set(property, [...current, ...values]);
940
+ function appendAutocomplete(config, contribution) {
941
+ const { patterns, properties, cssProperties, ...literals } = contribution;
942
+ return [
943
+ appendAutocompleteEntries(config.autocomplete.selectors, literals.selectors),
944
+ appendAutocompleteEntries(config.autocomplete.styleItemStrings, literals.styleItemStrings),
945
+ appendAutocompleteEntries(config.autocomplete.extraProperties, literals.extraProperties),
946
+ appendAutocompleteEntries(config.autocomplete.extraCssProperties, literals.extraCssProperties),
947
+ appendAutocompleteRecordEntries(config.autocomplete.properties, normalizeAutocompleteRecordEntries(properties)),
948
+ appendAutocompleteRecordEntries(config.autocomplete.cssProperties, normalizeAutocompleteRecordEntries(cssProperties)),
949
+ appendAutocompleteEntries(config.autocomplete.patterns.selectors, patterns?.selectors),
950
+ appendAutocompleteEntries(config.autocomplete.patterns.styleItemStrings, patterns?.styleItemStrings),
951
+ appendAutocompleteRecordEntries(config.autocomplete.patterns.properties, patterns?.properties),
952
+ appendAutocompleteRecordEntries(config.autocomplete.patterns.cssProperties, patterns?.cssProperties)
953
+ ].some(Boolean);
103
954
  }
104
955
  function renderCSSStyleBlocks(blocks, isFormatted, depth = 0) {
105
956
  const blockIndent = isFormatted ? " ".repeat(depth) : "";
@@ -120,6 +971,148 @@ function renderCSSStyleBlocks(blocks, isFormatted, depth = 0) {
120
971
  return lines.join(lineEnd);
121
972
  }
122
973
 
974
+ //#endregion
975
+ //#region src/internal/atomic-style.ts
976
+ function createEngineStore() {
977
+ return {
978
+ atomicStyleIds: /* @__PURE__ */ new Map(),
979
+ atomicStyles: /* @__PURE__ */ new Map(),
980
+ atomicStyleIdsByBaseKey: /* @__PURE__ */ new Map(),
981
+ atomicStyleOrder: /* @__PURE__ */ new Map()
982
+ };
983
+ }
984
+ function getAtomicStyleId({ content, prefix, stored }) {
985
+ const baseKey = getAtomicStyleBaseKey(content);
986
+ if (isOrderSensitiveContent(content) === false) {
987
+ const cached = stored.get(baseKey);
988
+ if (cached != null) {
989
+ log.debug(`Atomic style cached: ${cached}`);
990
+ return cached;
991
+ }
992
+ }
993
+ const num = stored.size;
994
+ const id = `${prefix}${numberToChars(num)}`;
995
+ const key = getAtomicStyleStoredKey({
996
+ content,
997
+ baseKey,
998
+ num
999
+ });
1000
+ stored.set(key, id);
1001
+ log.debug(`Generated new atomic style ID: ${id}`);
1002
+ return id;
1003
+ }
1004
+ function resolveAtomicStyle({ content, prefix, store, resolvedIdsByBaseKey }) {
1005
+ const reusableId = findReusableOrderSensitiveAtomicStyleId({
1006
+ content,
1007
+ store,
1008
+ resolvedIdsByBaseKey
1009
+ });
1010
+ if (reusableId != null) {
1011
+ log.debug(`Order-sensitive atomic style reused: ${reusableId}`);
1012
+ return { id: reusableId };
1013
+ }
1014
+ const id = getAtomicStyleId({
1015
+ content,
1016
+ prefix,
1017
+ stored: store.atomicStyleIds
1018
+ });
1019
+ if (store.atomicStyles.has(id)) return { id };
1020
+ const atomicStyle = {
1021
+ id,
1022
+ content
1023
+ };
1024
+ registerAtomicStyle(store, atomicStyle);
1025
+ return {
1026
+ id,
1027
+ atomicStyle
1028
+ };
1029
+ }
1030
+ function optimizeAtomicStyleContents(list) {
1031
+ const map = /* @__PURE__ */ new Map();
1032
+ const scopedEntries = /* @__PURE__ */ new Map();
1033
+ list.forEach((content) => {
1034
+ const scopeKey = serialize(content.selector);
1035
+ const key = serialize([content.selector, content.property]);
1036
+ const scoped = scopedEntries.get(scopeKey) || /* @__PURE__ */ new Map();
1037
+ scopedEntries.set(scopeKey, scoped);
1038
+ map.delete(key);
1039
+ scoped.delete(key);
1040
+ if (content.value == null) return;
1041
+ const { selector, property, value } = content;
1042
+ const nextContent = {
1043
+ selector,
1044
+ property,
1045
+ value
1046
+ };
1047
+ const dependencyKeys = getOrderSensitiveDependencyKeys(scoped, property);
1048
+ if (dependencyKeys.length > 0) nextContent.orderSensitiveTo = dependencyKeys;
1049
+ map.set(key, nextContent);
1050
+ scoped.set(key, nextContent);
1051
+ });
1052
+ return [...map.values()];
1053
+ }
1054
+ function getAtomicStyleBaseKey(content) {
1055
+ return serialize([
1056
+ content.selector,
1057
+ content.property,
1058
+ content.value
1059
+ ]);
1060
+ }
1061
+ function getAtomicStyleStoredKey({ content, baseKey, num }) {
1062
+ return isOrderSensitiveContent(content) ? serialize([
1063
+ baseKey,
1064
+ "order-sensitive",
1065
+ num
1066
+ ]) : baseKey;
1067
+ }
1068
+ function isOrderSensitiveContent(content) {
1069
+ return (content.orderSensitiveTo?.length ?? 0) > 0;
1070
+ }
1071
+ function registerAtomicStyle(store, atomicStyle) {
1072
+ const { id, content } = atomicStyle;
1073
+ const baseKey = getAtomicStyleBaseKey(content);
1074
+ store.atomicStyleOrder.set(id, store.atomicStyles.size);
1075
+ store.atomicStyles.set(id, atomicStyle);
1076
+ const ids = store.atomicStyleIdsByBaseKey.get(baseKey);
1077
+ if (ids == null) store.atomicStyleIdsByBaseKey.set(baseKey, [id]);
1078
+ else ids.push(id);
1079
+ }
1080
+ function getRequiredAtomicStyleOrder({ dependencyKeys, store, resolvedIdsByBaseKey }) {
1081
+ let requiredOrder = -1;
1082
+ for (const dependencyKey of dependencyKeys) {
1083
+ const dependencyId = resolvedIdsByBaseKey.get(dependencyKey) ?? store.atomicStyleIds.get(dependencyKey);
1084
+ if (dependencyId == null) continue;
1085
+ const dependencyOrder = store.atomicStyleOrder.get(dependencyId);
1086
+ if (dependencyOrder != null) requiredOrder = Math.max(requiredOrder, dependencyOrder);
1087
+ }
1088
+ return requiredOrder;
1089
+ }
1090
+ function findReusableOrderSensitiveAtomicStyleId({ content, store, resolvedIdsByBaseKey }) {
1091
+ if (isOrderSensitiveContent(content) === false) return void 0;
1092
+ const baseKey = getAtomicStyleBaseKey(content);
1093
+ const requiredOrder = getRequiredAtomicStyleOrder({
1094
+ dependencyKeys: content.orderSensitiveTo ?? [],
1095
+ store,
1096
+ resolvedIdsByBaseKey
1097
+ });
1098
+ return (store.atomicStyleIdsByBaseKey.get(baseKey) ?? []).find((candidateId) => {
1099
+ const candidateOrder = store.atomicStyleOrder.get(candidateId);
1100
+ return candidateOrder != null && candidateOrder > requiredOrder;
1101
+ });
1102
+ }
1103
+ function getOrderSensitiveDependencyKeys(scoped, property) {
1104
+ const dependencyKeys = [];
1105
+ for (const existing of scoped.values()) if (hasPropertyEffectOverlap(existing.property, property)) dependencyKeys.push(getAtomicStyleBaseKey(existing));
1106
+ return dependencyKeys;
1107
+ }
1108
+
1109
+ //#endregion
1110
+ //#region src/internal/constants.ts
1111
+ const LAYER_SELECTOR_PREFIX = "@layer ";
1112
+ const DEFAULT_ATOMIC_STYLE_ID_PREFIX = "pk-";
1113
+ const ATOMIC_STYLE_ID_PLACEHOLDER = "%";
1114
+ const ATOMIC_STYLE_ID_PLACEHOLDER_RE_GLOBAL = /%/g;
1115
+
123
1116
  //#endregion
124
1117
  //#region src/internal/extractor.ts
125
1118
  function replaceBySplitAndJoin(str, split, mapFn, join) {
@@ -197,42 +1190,60 @@ function createExtractFn(options) {
197
1190
 
198
1191
  //#endregion
199
1192
  //#region src/internal/plugin.ts
1193
+ function getPluginHook(plugin, hook) {
1194
+ const hookFn = plugin[hook];
1195
+ return typeof hookFn === "function" ? hookFn : null;
1196
+ }
1197
+ function applyHookPayload(current, next) {
1198
+ return next != null ? next : current;
1199
+ }
1200
+ function logHookStart(kind, hook) {
1201
+ log.debug(`Executing ${kind.toLowerCase()} hook: ${hook}`);
1202
+ }
1203
+ function logHookEnd(kind, hook) {
1204
+ log.debug(`${kind} hook "${hook}" completed`);
1205
+ }
1206
+ function logPluginHookStart(plugin, hook) {
1207
+ log.debug(` - Plugin "${plugin.name}" executing ${hook}`);
1208
+ }
1209
+ function logPluginHookEnd(plugin, hook) {
1210
+ log.debug(` - Plugin "${plugin.name}" completed ${hook}`);
1211
+ }
1212
+ function logPluginHookError(plugin, hook, error) {
1213
+ log.error(`Plugin "${plugin.name}" failed to execute hook "${hook}": ${error instanceof Error ? error.message : error}`, error);
1214
+ }
200
1215
  async function execAsyncHook(plugins, hook, payload) {
201
- log.debug(`Executing async hook: ${hook}`);
1216
+ logHookStart("Async", hook);
202
1217
  let current = payload;
203
1218
  for (const plugin of plugins) {
204
- const pluginRecord = plugin;
205
- if (pluginRecord[hook] == null) continue;
1219
+ const hookFn = getPluginHook(plugin, hook);
1220
+ if (hookFn == null) continue;
206
1221
  try {
207
- log.debug(` - Plugin "${plugin.name}" executing ${hook}`);
208
- const hookFn = pluginRecord[hook];
209
- const newPayload = await hookFn(current);
210
- if (newPayload != null) current = newPayload;
211
- log.debug(` - Plugin "${plugin.name}" completed ${hook}`);
1222
+ logPluginHookStart(plugin, hook);
1223
+ current = applyHookPayload(current, await hookFn(current));
1224
+ logPluginHookEnd(plugin, hook);
212
1225
  } catch (error) {
213
- log.error(`Plugin "${plugin.name}" failed to execute hook "${hook}": ${error instanceof Error ? error.message : error}`, error);
1226
+ logPluginHookError(plugin, hook, error);
214
1227
  }
215
1228
  }
216
- log.debug(`Async hook "${hook}" completed`);
1229
+ logHookEnd("Async", hook);
217
1230
  return current;
218
1231
  }
219
1232
  function execSyncHook(plugins, hook, payload) {
220
- log.debug(`Executing sync hook: ${hook}`);
1233
+ logHookStart("Sync", hook);
221
1234
  let current = payload;
222
1235
  for (const plugin of plugins) {
223
- const pluginRecord = plugin;
224
- if (pluginRecord[hook] == null) continue;
1236
+ const hookFn = getPluginHook(plugin, hook);
1237
+ if (hookFn == null) continue;
225
1238
  try {
226
- log.debug(` - Plugin "${plugin.name}" executing ${hook}`);
227
- const hookFn = pluginRecord[hook];
228
- const newPayload = hookFn(current);
229
- if (newPayload != null) current = newPayload;
230
- log.debug(` - Plugin "${plugin.name}" completed ${hook}`);
1239
+ logPluginHookStart(plugin, hook);
1240
+ current = applyHookPayload(current, hookFn(current));
1241
+ logPluginHookEnd(plugin, hook);
231
1242
  } catch (error) {
232
- log.error(`Plugin "${plugin.name}" failed to execute hook "${hook}": ${error instanceof Error ? error.message : error}`, error);
1243
+ logPluginHookError(plugin, hook, error);
233
1244
  }
234
1245
  }
235
- log.debug(`Sync hook "${hook}" completed`);
1246
+ logHookEnd("Sync", hook);
236
1247
  return current;
237
1248
  }
238
1249
  const hooks = {
@@ -279,8 +1290,10 @@ function important() {
279
1290
  defaultValue = config.important?.default ?? false;
280
1291
  },
281
1292
  configureEngine(engine) {
282
- engine.appendAutocompleteExtraProperties("__important");
283
- engine.appendAutocompletePropertyValues("__important", "boolean");
1293
+ engine.appendAutocomplete({
1294
+ extraProperties: "__important",
1295
+ properties: { __important: "boolean" }
1296
+ });
284
1297
  },
285
1298
  transformStyleDefinitions(styleDefinitions) {
286
1299
  return styleDefinitions.map((styleDefinition) => {
@@ -315,9 +1328,10 @@ function keyframes() {
315
1328
  const resolved = resolveKeyframesConfig(config);
316
1329
  const { name, frames, autocomplete: autocompleteAnimation } = resolved;
317
1330
  if (frames != null) engine.keyframes.store.set(name, resolved);
318
- engine.appendAutocompleteCssPropertyValues("animationName", name);
319
- engine.appendAutocompleteCssPropertyValues("animation", `${name} `);
320
- if (autocompleteAnimation != null) engine.appendAutocompleteCssPropertyValues("animation", ...autocompleteAnimation);
1331
+ engine.appendAutocomplete({ cssProperties: {
1332
+ animationName: name,
1333
+ animation: autocompleteAnimation != null ? [`${name} `, ...autocompleteAnimation] : `${name} `
1334
+ } });
321
1335
  });
322
1336
  engine.notifyPreflightUpdated();
323
1337
  }
@@ -558,18 +1572,18 @@ function selectors() {
558
1572
  const resolved = resolveSelectorConfig(config);
559
1573
  if (resolved == null) return;
560
1574
  if (typeof resolved === "string") {
561
- engine.appendAutocompleteSelectors(resolved);
1575
+ engine.appendAutocomplete({ selectors: resolved });
562
1576
  return;
563
1577
  }
564
1578
  if (resolved.type === "static") engine.selectors.resolver.addStaticRule(resolved.rule);
565
1579
  else if (resolved.type === "dynamic") engine.selectors.resolver.addDynamicRule(resolved.rule);
566
- engine.appendAutocompleteSelectors(...resolved.autocomplete);
1580
+ engine.appendAutocomplete({ selectors: resolved.autocomplete });
567
1581
  });
568
1582
  }
569
1583
  };
570
1584
  engine.selectors.add(...configList);
571
1585
  engine.selectors.resolver.onResolved = (string, type) => {
572
- if (type === "dynamic") engine.appendAutocompleteSelectors(string);
1586
+ if (type === "dynamic") engine.appendAutocomplete({ selectors: string });
573
1587
  };
574
1588
  },
575
1589
  async transformSelectors(selectors) {
@@ -603,22 +1617,24 @@ function shortcuts() {
603
1617
  const resolved = resolveShortcutConfig(config);
604
1618
  if (resolved == null) return;
605
1619
  if (typeof resolved === "string") {
606
- engine.appendAutocompleteStyleItemStrings(resolved);
1620
+ engine.appendAutocomplete({ styleItemStrings: resolved });
607
1621
  return;
608
1622
  }
609
1623
  if (resolved.type === "static") engine.shortcuts.resolver.addStaticRule(resolved.rule);
610
1624
  else if (resolved.type === "dynamic") engine.shortcuts.resolver.addDynamicRule(resolved.rule);
611
- engine.appendAutocompleteStyleItemStrings(...resolved.autocomplete);
1625
+ engine.appendAutocomplete({ styleItemStrings: resolved.autocomplete });
612
1626
  });
613
1627
  }
614
1628
  };
615
1629
  engine.shortcuts.add(...configList);
616
1630
  engine.shortcuts.resolver.onResolved = (string, type) => {
617
- if (type === "dynamic") engine.appendAutocompleteStyleItemStrings(string);
1631
+ if (type === "dynamic") engine.appendAutocomplete({ styleItemStrings: string });
618
1632
  };
619
- engine.appendAutocompleteExtraProperties("__shortcut");
620
1633
  const unionType = ["(string & {})", "Autocomplete['StyleItemString']"].join(" | ");
621
- engine.appendAutocompletePropertyValues("__shortcut", unionType, `(${unionType})[]`);
1634
+ engine.appendAutocomplete({
1635
+ extraProperties: "__shortcut",
1636
+ properties: { __shortcut: [unionType, `(${unionType})[]`] }
1637
+ });
622
1638
  },
623
1639
  async transformStyleItems(styleItems) {
624
1640
  const result = [];
@@ -651,8 +1667,102 @@ function resolveShortcutConfig(config) {
651
1667
  return resolveRuleConfig(config, "shortcut");
652
1668
  }
653
1669
 
1670
+ //#endregion
1671
+ //#region src/internal/generated-property-semantics.ts
1672
+ const VARIABLE_SEMANTIC_FAMILIES = [
1673
+ "color",
1674
+ "length",
1675
+ "time",
1676
+ "number",
1677
+ "percentage",
1678
+ "angle",
1679
+ "image",
1680
+ "url",
1681
+ "position",
1682
+ "easing",
1683
+ "font-family"
1684
+ ];
1685
+ const VARIABLE_SEMANTIC_FAMILY_PROPERTIES = {
1686
+ "angle": [],
1687
+ "color": [
1688
+ "accent-color",
1689
+ "background-color",
1690
+ "border-block-color",
1691
+ "border-block-end-color",
1692
+ "border-block-start-color",
1693
+ "border-bottom-color",
1694
+ "border-inline-color",
1695
+ "border-inline-end-color",
1696
+ "border-inline-start-color",
1697
+ "border-left-color",
1698
+ "border-right-color",
1699
+ "border-top-color",
1700
+ "caret-color",
1701
+ "color",
1702
+ "column-rule-color",
1703
+ "flood-color",
1704
+ "lighting-color",
1705
+ "outline-color",
1706
+ "stop-color",
1707
+ "stroke-color",
1708
+ "text-decoration-color",
1709
+ "text-emphasis-color"
1710
+ ],
1711
+ "easing": ["animation-timing-function", "transition-timing-function"],
1712
+ "font-family": ["font-family"],
1713
+ "image": [],
1714
+ "length": [
1715
+ "block-size",
1716
+ "border-bottom-width",
1717
+ "border-left-width",
1718
+ "border-right-width",
1719
+ "border-spacing",
1720
+ "border-top-width",
1721
+ "bottom",
1722
+ "font-size",
1723
+ "height",
1724
+ "inline-size",
1725
+ "inset-block-end",
1726
+ "inset-block-start",
1727
+ "inset-inline-end",
1728
+ "inset-inline-start",
1729
+ "left",
1730
+ "letter-spacing",
1731
+ "max-height",
1732
+ "max-width",
1733
+ "min-height",
1734
+ "min-width",
1735
+ "outline-offset",
1736
+ "right",
1737
+ "top",
1738
+ "width"
1739
+ ],
1740
+ "number": [
1741
+ "fill-opacity",
1742
+ "flex-grow",
1743
+ "flex-shrink",
1744
+ "flood-opacity",
1745
+ "opacity",
1746
+ "order",
1747
+ "orphans",
1748
+ "stop-opacity",
1749
+ "stroke-opacity",
1750
+ "widows"
1751
+ ],
1752
+ "percentage": [],
1753
+ "position": [],
1754
+ "time": [
1755
+ "animation-delay",
1756
+ "animation-duration",
1757
+ "transition-delay",
1758
+ "transition-duration"
1759
+ ],
1760
+ "url": []
1761
+ };
1762
+
654
1763
  //#endregion
655
1764
  //#region src/internal/plugins/variables.ts
1765
+ const KNOWN_VARIABLE_SEMANTIC_FAMILIES = new Set(VARIABLE_SEMANTIC_FAMILIES);
656
1766
  function variables() {
657
1767
  let resolveVariables;
658
1768
  let rawVariables;
@@ -670,10 +1780,11 @@ function variables() {
670
1780
  add: (variables) => {
671
1781
  resolveVariables(variables).forEach((resolved) => {
672
1782
  const { name, value, autocomplete: { asValueOf, asProperty } } = resolved;
673
- asValueOf.forEach((p) => {
674
- if (p !== "-") engine.appendAutocompleteCssPropertyValues(p, `var(${name})`);
1783
+ const cssProperties = Object.fromEntries(asValueOf.filter((p) => p !== "-").map((p) => [p, `var(${name})`]));
1784
+ engine.appendAutocomplete({
1785
+ cssProperties,
1786
+ extraCssProperties: asProperty ? name : void 0
675
1787
  });
676
- if (asProperty) engine.appendAutocompleteExtraCssProperties(name);
677
1788
  if (value != null) {
678
1789
  const list = engine.variables.store.get(name) ?? [];
679
1790
  list.push(resolved);
@@ -684,48 +1795,104 @@ function variables() {
684
1795
  }
685
1796
  };
686
1797
  rawVariables.forEach((variables) => engine.variables.add(variables));
687
- engine.addPreflight(async (engine) => {
688
- const used = /* @__PURE__ */ new Set();
689
- engine.store.atomicStyles.forEach(({ content: { value } }) => {
690
- value.flatMap(extractUsedVarNames).forEach((name) => used.add(normalizeVariableName(name)));
691
- });
692
- const usedVariables = Array.from(engine.variables.store.values()).flat().filter(({ name, pruneUnused, value }) => (safeSet.has(name) || pruneUnused === false || used.has(name)) && value != null);
693
- const preflightDefinition = {};
694
- for (const { name, value, selector: _selector } of usedVariables) {
695
- const selector = await engine.pluginHooks.transformSelectors(engine.config.plugins, _selector);
696
- let current = preflightDefinition;
697
- selector.forEach((s) => {
698
- current[s] ||= {};
699
- current = current[s];
1798
+ engine.addPreflight({
1799
+ id: "core:variables",
1800
+ preflight: async (engine) => {
1801
+ const used = /* @__PURE__ */ new Set();
1802
+ engine.store.atomicStyles.forEach(({ content: { value } }) => {
1803
+ value.flatMap(extractUsedVarNames).forEach((name) => used.add(normalizeVariableName(name)));
700
1804
  });
701
- Object.assign(current, { [name]: value });
1805
+ const otherPreflights = engine.config.preflights.filter((p) => p.id !== "core:variables");
1806
+ (await Promise.all(otherPreflights.map(({ fn }) => Promise.resolve(fn(engine, false)).catch(() => null)))).forEach((result) => {
1807
+ if (result == null) return;
1808
+ extractUsedVarNamesFromPreflightResult(result).forEach((name) => used.add(name));
1809
+ });
1810
+ const varMap = /* @__PURE__ */ new Map();
1811
+ for (const [name, list] of engine.variables.store.entries()) varMap.set(name, list);
1812
+ const queue = Array.from(used);
1813
+ while (queue.length > 0) {
1814
+ const name = queue.pop();
1815
+ const entries = varMap.get(name);
1816
+ if (!entries) continue;
1817
+ for (const { value } of entries) {
1818
+ if (value == null) continue;
1819
+ for (const refName of extractUsedVarNames(String(value)).map(normalizeVariableName)) if (!used.has(refName)) {
1820
+ used.add(refName);
1821
+ queue.push(refName);
1822
+ }
1823
+ }
1824
+ }
1825
+ const usedVariables = Array.from(engine.variables.store.values()).flat().filter(({ name, pruneUnused, value }) => (safeSet.has(name) || pruneUnused === false || used.has(name)) && value != null);
1826
+ const preflightDefinition = {};
1827
+ for (const { name, value, selector: _selector } of usedVariables) {
1828
+ const selector = await engine.pluginHooks.transformSelectors(engine.config.plugins, _selector);
1829
+ let current = preflightDefinition;
1830
+ selector.forEach((s) => {
1831
+ current[s] ||= {};
1832
+ current = current[s];
1833
+ });
1834
+ Object.assign(current, { [name]: value });
1835
+ }
1836
+ return preflightDefinition;
702
1837
  }
703
- return preflightDefinition;
704
1838
  });
705
1839
  }
706
1840
  });
707
1841
  }
708
1842
  function createResolveVariablesFn({ pruneUnused: defaultPruneUnused = true } = {}) {
1843
+ function isVariableScopeObject(value) {
1844
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1845
+ }
709
1846
  function _resolveVariables(variables, levels, result) {
710
1847
  for (const [key, value] of Object.entries(variables)) if (key.startsWith("--")) {
711
- const { value: varValue, autocomplete = {}, pruneUnused = defaultPruneUnused } = typeof value === "object" && value !== null && !Array.isArray(value) ? value : { value };
1848
+ const { value: varValue, semanticType, autocomplete = {}, pruneUnused = defaultPruneUnused } = typeof value === "object" && value !== null && !Array.isArray(value) ? value : { value };
712
1849
  result.push({
713
1850
  name: key,
714
1851
  value: varValue,
715
1852
  selector: levels.length > 0 ? levels : [":root"],
716
1853
  autocomplete: {
717
- asValueOf: autocomplete.asValueOf ? [autocomplete.asValueOf].flat() : ["*"],
1854
+ asValueOf: resolveAutocompleteValueTargets({
1855
+ name: key,
1856
+ asValueOf: autocomplete.asValueOf,
1857
+ semanticType
1858
+ }),
718
1859
  asProperty: autocomplete.asProperty ?? true
719
1860
  },
720
1861
  pruneUnused
721
1862
  });
722
- } else _resolveVariables(value, [...levels, key], result);
1863
+ } else {
1864
+ if (!isVariableScopeObject(value)) {
1865
+ log.warn(`Invalid variables scope for selector "${key}". Expected a nested object, received ${typeof value}. Skipping.`);
1866
+ continue;
1867
+ }
1868
+ _resolveVariables(value, [...levels, key], result);
1869
+ }
723
1870
  return result;
724
1871
  }
725
1872
  return function resolveVariables(variables) {
726
1873
  return _resolveVariables(variables, [], []);
727
1874
  };
728
1875
  }
1876
+ function resolveAutocompleteValueTargets({ name, asValueOf, semanticType }) {
1877
+ const explicitTargets = asValueOf == null ? [] : [asValueOf].flat().map((value) => String(value));
1878
+ const semanticTypes = semanticType == null ? [] : [semanticType].flat().map((value) => String(value));
1879
+ if (explicitTargets.includes("-")) return [];
1880
+ const targets = /* @__PURE__ */ new Set();
1881
+ if (asValueOf == null && semanticTypes.length === 0) targets.add("*");
1882
+ explicitTargets.forEach((target) => {
1883
+ if (target !== "-") targets.add(target);
1884
+ });
1885
+ semanticTypes.forEach((family) => {
1886
+ const properties = VARIABLE_SEMANTIC_FAMILY_PROPERTIES[family];
1887
+ if (properties != null) {
1888
+ properties.forEach((property) => targets.add(property));
1889
+ return;
1890
+ }
1891
+ if (KNOWN_VARIABLE_SEMANTIC_FAMILIES.has(family) === false) log.warn(`Unknown semanticType "${family}" for variable "${name}". Skipping semantic autocomplete expansion.`);
1892
+ });
1893
+ if (targets.has("*")) return ["*"];
1894
+ return [...targets];
1895
+ }
729
1896
  const VAR_NAME_RE = /var\((--[\w-]+)/g;
730
1897
  function extractUsedVarNames(input) {
731
1898
  return Array.from(input.matchAll(VAR_NAME_RE), (m) => m[1]);
@@ -734,6 +1901,20 @@ function normalizeVariableName(name) {
734
1901
  if (name.startsWith("--")) return name;
735
1902
  return `--${name}`;
736
1903
  }
1904
+ /**
1905
+ * Recursively extract all CSS variable names referenced inside a preflight
1906
+ * result (either a plain CSS string or a `PreflightDefinition` object).
1907
+ */
1908
+ function extractUsedVarNamesFromPreflightResult(result) {
1909
+ if (typeof result === "string") return extractUsedVarNames(result).map(normalizeVariableName);
1910
+ const names = [];
1911
+ for (const value of Object.values(result)) {
1912
+ if (value == null) continue;
1913
+ if (typeof value === "string" || typeof value === "number") extractUsedVarNames(String(value)).forEach((n) => names.push(normalizeVariableName(n)));
1914
+ else if (typeof value === "object") extractUsedVarNamesFromPreflightResult(value).forEach((n) => names.push(n));
1915
+ }
1916
+ return names;
1917
+ }
737
1918
 
738
1919
  //#endregion
739
1920
  //#region src/internal/engine.ts
@@ -765,8 +1946,10 @@ async function createEngine(config = {}) {
765
1946
  log.debug("Engine config resolved with prefix:", resolvedConfig.prefix);
766
1947
  resolvedConfig = await hooks.configureResolvedConfig(resolvedConfig.plugins, resolvedConfig);
767
1948
  let engine = new Engine(resolvedConfig);
768
- engine.appendAutocompleteExtraProperties("__layer");
769
- engine.appendAutocompletePropertyValues("__layer", "Autocomplete['Layer']");
1949
+ engine.appendAutocomplete({
1950
+ extraProperties: "__layer",
1951
+ properties: { __layer: "Autocomplete['Layer']" }
1952
+ });
770
1953
  log.debug("Engine instance created");
771
1954
  engine = await hooks.configureEngine(engine.config.plugins, engine);
772
1955
  log.debug("Engine initialized successfully");
@@ -776,10 +1959,7 @@ var Engine = class {
776
1959
  config;
777
1960
  pluginHooks = hooks;
778
1961
  extract;
779
- store = {
780
- atomicStyleIds: /* @__PURE__ */ new Map(),
781
- atomicStyles: /* @__PURE__ */ new Map()
782
- };
1962
+ store = createEngineStore();
783
1963
  constructor(config) {
784
1964
  this.config = config;
785
1965
  this.extract = createExtractFn({
@@ -798,29 +1978,14 @@ var Engine = class {
798
1978
  notifyAutocompleteConfigUpdated() {
799
1979
  hooks.autocompleteConfigUpdated(this.config.plugins);
800
1980
  }
801
- appendAutocompleteSelectors(...selectors) {
802
- appendAutocompleteSelectors(this.config, ...selectors);
803
- this.notifyAutocompleteConfigUpdated();
1981
+ appendAutocomplete(contribution) {
1982
+ if (appendAutocomplete(this.config, contribution)) this.notifyAutocompleteConfigUpdated();
804
1983
  }
805
- appendAutocompleteStyleItemStrings(...styleItemStrings) {
806
- appendAutocompleteStyleItemStrings(this.config, ...styleItemStrings);
807
- this.notifyAutocompleteConfigUpdated();
808
- }
809
- appendAutocompleteExtraProperties(...properties) {
810
- appendAutocompleteExtraProperties(this.config, ...properties);
811
- this.notifyAutocompleteConfigUpdated();
812
- }
813
- appendAutocompleteExtraCssProperties(...properties) {
814
- appendAutocompleteExtraCssProperties(this.config, ...properties);
815
- this.notifyAutocompleteConfigUpdated();
816
- }
817
- appendAutocompletePropertyValues(property, ...tsTypes) {
818
- appendAutocompletePropertyValues(this.config, property, ...tsTypes);
819
- this.notifyAutocompleteConfigUpdated();
820
- }
821
- appendAutocompleteCssPropertyValues(property, ...values) {
822
- appendAutocompleteCssPropertyValues(this.config, property, ...values);
823
- this.notifyAutocompleteConfigUpdated();
1984
+ appendCssImport(cssImport) {
1985
+ const normalized = normalizeCssImport(cssImport);
1986
+ if (normalized == null || this.config.cssImports.includes(normalized)) return;
1987
+ this.config.cssImports.push(normalized);
1988
+ this.notifyPreflightUpdated();
824
1989
  }
825
1990
  addPreflight(preflight) {
826
1991
  log.debug("Adding preflight");
@@ -836,61 +2001,58 @@ var Engine = class {
836
2001
  extractStyleDefinition: (styleDefinition) => this.extract(styleDefinition)
837
2002
  });
838
2003
  const resolvedIds = [];
839
- contents.forEach((content) => {
840
- const id = getAtomicStyleId({
2004
+ const resolvedIdsByBaseKey = /* @__PURE__ */ new Map();
2005
+ for (const content of contents) {
2006
+ const { id, atomicStyle } = resolveAtomicStyle({
841
2007
  content,
842
2008
  prefix: this.config.prefix,
843
- stored: this.store.atomicStyleIds
2009
+ store: this.store,
2010
+ resolvedIdsByBaseKey
844
2011
  });
845
2012
  resolvedIds.push(id);
846
- if (!this.store.atomicStyles.has(id)) {
847
- const atomicStyle = {
848
- id,
849
- content
850
- };
851
- this.store.atomicStyles.set(id, atomicStyle);
2013
+ resolvedIdsByBaseKey.set(getAtomicStyleBaseKey(content), id);
2014
+ if (atomicStyle != null) {
852
2015
  log.debug(`Atomic style added: ${id}`);
853
2016
  this.notifyAtomicStyleAdded(atomicStyle);
854
2017
  }
855
- });
2018
+ }
856
2019
  log.debug(`Resolved ${resolvedIds.length} atomic styles, ${unknown.size} unknown items`);
857
2020
  return [...unknown, ...resolvedIds];
858
2021
  }
859
2022
  async renderPreflights(isFormatted) {
860
2023
  log.debug("Rendering preflights...");
861
2024
  const lineEnd = isFormatted ? "\n" : "";
862
- const rendered = await Promise.all(this.config.preflights.map(async ({ layer, fn }) => {
2025
+ const rendered = (await Promise.all(this.config.preflights.map(async ({ layer, fn }) => {
863
2026
  const result = await fn(this, isFormatted);
864
2027
  return {
865
2028
  layer,
866
- css: typeof result === "string" ? result : await renderPreflightDefinition({
2029
+ css: (typeof result === "string" ? result : await renderPreflightDefinition({
867
2030
  engine: this,
868
2031
  preflightDefinition: result,
869
2032
  isFormatted
870
- })
2033
+ })).trim()
871
2034
  };
872
- }));
2035
+ }))).filter((r) => r.css);
873
2036
  log.debug(`Rendered ${rendered.length} preflights`);
874
- const unlayeredParts = [];
875
- const layerGroups = /* @__PURE__ */ new Map();
876
- for (const { layer, css } of rendered) if (layer == null) unlayeredParts.push(css);
877
- else {
878
- if (!layerGroups.has(layer)) layerGroups.set(layer, []);
879
- layerGroups.get(layer).push(css);
880
- }
2037
+ const { unlayeredParts, layerGroups } = groupRenderedPreflightsByLayer(rendered);
881
2038
  const outputParts = [];
2039
+ if (this.config.cssImports.length > 0) outputParts.push(...this.config.cssImports);
882
2040
  if (unlayeredParts.length > 0) {
883
- const unlayeredContent = unlayeredParts.join(lineEnd);
884
2041
  const { defaultPreflightsLayer } = this.config;
885
- if (defaultPreflightsLayer in this.config.layers) outputParts.push(`@layer ${defaultPreflightsLayer} {${lineEnd}${unlayeredContent}${lineEnd}}`);
886
- else outputParts.push(unlayeredContent);
887
- }
888
- const configLayerOrder = sortLayerNames(this.config.layers);
889
- const orderedLayerNames = [...configLayerOrder.filter((name) => layerGroups.has(name)), ...[...layerGroups.keys()].filter((name) => !configLayerOrder.includes(name))];
890
- for (const layerName of orderedLayerNames) {
891
- const content = layerGroups.get(layerName).join(lineEnd);
892
- outputParts.push(`@layer ${layerName} {${lineEnd}${content}${lineEnd}}`);
2042
+ if (defaultPreflightsLayer in this.config.layers) {
2043
+ const unlayeredContent = unlayeredParts.map((part) => part.trim().split("\n").map((line) => ` ${line}`).join(lineEnd)).join(lineEnd);
2044
+ outputParts.push(`@layer ${defaultPreflightsLayer} {${lineEnd}${unlayeredContent}${lineEnd}}`);
2045
+ } else {
2046
+ const unlayeredContent = unlayeredParts.join(lineEnd);
2047
+ outputParts.push(unlayeredContent);
2048
+ }
893
2049
  }
2050
+ outputParts.push(...renderLayerBlocks({
2051
+ layerGroups,
2052
+ layerOrder: sortLayerNames(this.config.layers),
2053
+ isFormatted,
2054
+ render: (cssList) => cssList.join(lineEnd)
2055
+ }));
894
2056
  return outputParts.join(lineEnd);
895
2057
  }
896
2058
  async renderAtomicStyles(isFormatted, options = {}) {
@@ -914,30 +2076,121 @@ var Engine = class {
914
2076
  }
915
2077
  };
916
2078
  function calcAtomicStyleRenderingWeight(style, defaultSelector) {
917
- const { selector } = style.content;
2079
+ const { selector } = splitLayerSelector(style.content.selector);
918
2080
  return selector.length === 1 && selector[0] === defaultSelector ? 0 : selector.length;
919
2081
  }
920
2082
  function sortLayerNames(layers) {
921
2083
  return Object.entries(layers).sort((a, b) => a[1] - b[1] || a[0].localeCompare(b[0])).map(([name]) => name);
922
2084
  }
2085
+ function appendLayerGroupItem(layerGroups, layer, item) {
2086
+ if (!layerGroups.has(layer)) layerGroups.set(layer, []);
2087
+ layerGroups.get(layer).push(item);
2088
+ }
2089
+ function getOrderedLayerNamesForGroups(layerGroups, layerOrder) {
2090
+ return [...layerOrder.filter((name) => (layerGroups.get(name)?.length ?? 0) > 0), ...[...layerGroups.keys()].filter((name) => !layerOrder.includes(name) && (layerGroups.get(name)?.length ?? 0) > 0)];
2091
+ }
2092
+ function renderLayerBlocks({ layerGroups, layerOrder, isFormatted, render }) {
2093
+ const lineEnd = isFormatted ? "\n" : "";
2094
+ return getOrderedLayerNamesForGroups(layerGroups, layerOrder).map((layerName) => {
2095
+ const items = layerGroups.get(layerName);
2096
+ return `@layer ${layerName} {${lineEnd}${isFormatted ? render(items).trim().split("\n").map((line) => ` ${line}`).join("\n") : render(items)}${lineEnd}}`;
2097
+ });
2098
+ }
2099
+ function normalizeCssImport(cssImport) {
2100
+ const normalized = cssImport.trim();
2101
+ if (normalized.length === 0) return null;
2102
+ return normalized.endsWith(";") ? normalized : `${normalized};`;
2103
+ }
2104
+ function groupRenderedPreflightsByLayer(rendered) {
2105
+ const unlayeredParts = [];
2106
+ const layerGroups = /* @__PURE__ */ new Map();
2107
+ for (const { layer, css } of rendered) {
2108
+ if (layer == null) {
2109
+ unlayeredParts.push(css);
2110
+ continue;
2111
+ }
2112
+ appendLayerGroupItem(layerGroups, layer, css);
2113
+ }
2114
+ return {
2115
+ unlayeredParts,
2116
+ layerGroups
2117
+ };
2118
+ }
2119
+ function splitLayerSelector(selector) {
2120
+ const [first, ...rest] = selector;
2121
+ if (first == null || first.startsWith(LAYER_SELECTOR_PREFIX) === false) return {
2122
+ layer: void 0,
2123
+ selector
2124
+ };
2125
+ const layer = first.slice(LAYER_SELECTOR_PREFIX.length).trim();
2126
+ if (layer.length === 0) return {
2127
+ layer: void 0,
2128
+ selector
2129
+ };
2130
+ return {
2131
+ layer,
2132
+ selector: rest
2133
+ };
2134
+ }
2135
+ function prependLayerSelector(selector, layer) {
2136
+ return [`${LAYER_SELECTOR_PREFIX}${layer}`, ...selector];
2137
+ }
2138
+ function groupAtomicStylesByLayer({ styles, layerOrder, defaultUtilitiesLayer }) {
2139
+ const unlayeredStyles = [];
2140
+ const layerGroups = new Map(layerOrder.map((name) => [name, []]));
2141
+ const candidateDefaultLayer = defaultUtilitiesLayer ?? layerOrder[layerOrder.length - 1];
2142
+ const defaultLayer = candidateDefaultLayer != null && layerGroups.has(candidateDefaultLayer) ? candidateDefaultLayer : layerOrder[layerOrder.length - 1];
2143
+ for (const style of styles) {
2144
+ const { layer } = splitLayerSelector(style.content.selector);
2145
+ if (layer != null && layerGroups.has(layer)) {
2146
+ layerGroups.get(layer).push(style);
2147
+ continue;
2148
+ }
2149
+ if (layer != null) {
2150
+ log.warn(`Unknown layer "${layer}" encountered in atomic style; falling back to unlayered output.`);
2151
+ unlayeredStyles.push(style);
2152
+ continue;
2153
+ }
2154
+ if (defaultLayer != null) {
2155
+ layerGroups.get(defaultLayer).push(style);
2156
+ continue;
2157
+ }
2158
+ unlayeredStyles.push(style);
2159
+ }
2160
+ return {
2161
+ unlayeredStyles,
2162
+ layerGroups
2163
+ };
2164
+ }
923
2165
  function isWithLayer(p) {
924
2166
  if (typeof p !== "object" || p === null) return false;
925
2167
  const record = p;
926
2168
  return typeof record.layer === "string" && record.preflight !== void 0;
927
2169
  }
2170
+ function isWithId(p) {
2171
+ if (typeof p !== "object" || p === null) return false;
2172
+ const record = p;
2173
+ return typeof record.id === "string" && record.preflight !== void 0;
2174
+ }
928
2175
  function resolvePreflight(preflight) {
2176
+ let layer;
2177
+ let id;
929
2178
  if (isWithLayer(preflight)) {
930
- const inner = preflight.preflight;
931
- const fn = typeof inner === "function" ? inner : () => inner;
932
- return {
933
- layer: preflight.layer,
934
- fn
935
- };
2179
+ layer = preflight.layer;
2180
+ preflight = preflight.preflight;
2181
+ }
2182
+ if (isWithId(preflight)) {
2183
+ id = preflight.id;
2184
+ preflight = preflight.preflight;
936
2185
  }
937
- return { fn: typeof preflight === "function" ? preflight : () => preflight };
2186
+ return {
2187
+ layer,
2188
+ id,
2189
+ fn: typeof preflight === "function" ? preflight : () => preflight
2190
+ };
938
2191
  }
939
2192
  async function resolveEngineConfig(config) {
940
- const { prefix = "", defaultSelector = `.${ATOMIC_STYLE_ID_PLACEHOLDER}`, plugins = [], preflights = [] } = config;
2193
+ const { prefix = DEFAULT_ATOMIC_STYLE_ID_PREFIX, defaultSelector = `.${ATOMIC_STYLE_ID_PLACEHOLDER}`, plugins = [], cssImports = [], preflights = [] } = config;
941
2194
  const layers = Object.assign({}, DEFAULT_LAYERS, config.layers);
942
2195
  const defaultPreflightsLayer = config.defaultPreflightsLayer ?? DEFAULT_PREFLIGHTS_LAYER;
943
2196
  const defaultUtilitiesLayer = config.defaultUtilitiesLayer ?? DEFAULT_UTILITIES_LAYER;
@@ -948,6 +2201,7 @@ async function resolveEngineConfig(config) {
948
2201
  prefix,
949
2202
  defaultSelector,
950
2203
  preflights: [],
2204
+ cssImports: [...new Set(cssImports.map(normalizeCssImport).filter(isNotNullish))],
951
2205
  layers,
952
2206
  defaultPreflightsLayer,
953
2207
  defaultUtilitiesLayer,
@@ -957,46 +2211,21 @@ async function resolveEngineConfig(config) {
957
2211
  extraProperties: /* @__PURE__ */ new Set(),
958
2212
  extraCssProperties: /* @__PURE__ */ new Set(),
959
2213
  properties: /* @__PURE__ */ new Map(),
960
- cssProperties: /* @__PURE__ */ new Map()
2214
+ cssProperties: /* @__PURE__ */ new Map(),
2215
+ patterns: {
2216
+ selectors: /* @__PURE__ */ new Set(),
2217
+ styleItemStrings: /* @__PURE__ */ new Set(),
2218
+ properties: /* @__PURE__ */ new Map(),
2219
+ cssProperties: /* @__PURE__ */ new Map()
2220
+ }
961
2221
  }
962
2222
  };
2223
+ appendAutocomplete(resolvedConfig, config.autocomplete ?? {});
963
2224
  const resolvedPreflights = preflights.map(resolvePreflight);
964
2225
  resolvedConfig.preflights.push(...resolvedPreflights);
965
2226
  log.debug(`Engine config resolved: ${resolvedPreflights.length} preflights processed`);
966
2227
  return resolvedConfig;
967
2228
  }
968
- function getAtomicStyleId({ content, prefix, stored }) {
969
- const key = serialize([
970
- content.selector,
971
- content.property,
972
- content.value,
973
- content.layer
974
- ]);
975
- const cached = stored.get(key);
976
- if (cached != null) {
977
- log.debug(`Atomic style cached: ${cached}`);
978
- return cached;
979
- }
980
- const num = stored.size;
981
- const id = `${prefix}${numberToChars(num)}`;
982
- stored.set(key, id);
983
- log.debug(`Generated new atomic style ID: ${id}`);
984
- return id;
985
- }
986
- function optimizeAtomicStyleContents(list) {
987
- const map = /* @__PURE__ */ new Map();
988
- list.forEach((content) => {
989
- const key = serialize([
990
- content.selector,
991
- content.property,
992
- content.layer
993
- ]);
994
- map.delete(key);
995
- if (content.value == null) return;
996
- map.set(key, { ...content });
997
- });
998
- return [...map.values()];
999
- }
1000
2229
  function extractLayerFromStyleItem(item) {
1001
2230
  const record = item;
1002
2231
  const layer = typeof record.__layer === "string" ? record.__layer : void 0;
@@ -1017,8 +2246,10 @@ async function resolveStyleItemList({ itemList, transformStyleItems, extractStyl
1017
2246
  else {
1018
2247
  const { layer, definition } = extractLayerFromStyleItem(styleItem);
1019
2248
  const extracted = await extractStyleDefinition(definition);
1020
- if (layer != null) extracted.forEach((c) => c.layer = layer);
1021
- list.push(...extracted);
2249
+ list.push(...layer == null ? extracted : extracted.map((content) => ({
2250
+ ...content,
2251
+ selector: prependLayerSelector(content.selector, layer)
2252
+ })));
1022
2253
  }
1023
2254
  return {
1024
2255
  unknown,
@@ -1030,7 +2261,8 @@ function sortAtomicStyles(styles, defaultSelector) {
1030
2261
  }
1031
2262
  function renderAtomicStylesCss({ atomicStyles, isPreview, isFormatted }) {
1032
2263
  const blocks = /* @__PURE__ */ new Map();
1033
- atomicStyles.forEach(({ id, content: { selector, property, value } }) => {
2264
+ atomicStyles.forEach(({ id, content: { selector: rawSelector, property, value } }) => {
2265
+ const { selector } = splitLayerSelector(rawSelector);
1034
2266
  if (selector.some((s) => s.includes(ATOMIC_STYLE_ID_PLACEHOLDER)) === false || value == null) return;
1035
2267
  const renderObject = {
1036
2268
  selector: isPreview ? selector : selector.map((s) => s.replace(ATOMIC_STYLE_ID_PLACEHOLDER_RE_GLOBAL, id)),
@@ -1062,35 +2294,27 @@ function renderAtomicStyles(payload) {
1062
2294
  });
1063
2295
  const layerOrder = sortLayerNames(layers);
1064
2296
  const lineEnd = isFormatted ? "\n" : "";
1065
- const unlayeredStyles = [];
1066
- const layerGroups = new Map(layerOrder.map((name) => [name, []]));
1067
- const candidateDefaultLayer = defaultUtilitiesLayer ?? layerOrder[layerOrder.length - 1];
1068
- const defaultLayer = candidateDefaultLayer != null && layerGroups.has(candidateDefaultLayer) ? candidateDefaultLayer : layerOrder[layerOrder.length - 1];
1069
- for (const style of sortedStyles) {
1070
- const layer = style.content.layer;
1071
- if (layer != null && layerGroups.has(layer)) layerGroups.get(layer).push(style);
1072
- else if (layer != null) {
1073
- log.warn(`Unknown layer "${layer}" encountered in atomic style; falling back to unlayered output.`);
1074
- unlayeredStyles.push(style);
1075
- } else if (defaultLayer != null) layerGroups.get(defaultLayer).push(style);
1076
- else unlayeredStyles.push(style);
1077
- }
2297
+ const { unlayeredStyles, layerGroups } = groupAtomicStylesByLayer({
2298
+ styles: sortedStyles,
2299
+ layerOrder,
2300
+ defaultUtilitiesLayer
2301
+ });
1078
2302
  const parts = [];
1079
2303
  if (unlayeredStyles.length > 0) parts.push(renderAtomicStylesCss({
1080
2304
  atomicStyles: unlayeredStyles,
1081
2305
  isPreview,
1082
2306
  isFormatted
1083
2307
  }));
1084
- for (const layerName of layerOrder) {
1085
- const styles = layerGroups.get(layerName);
1086
- if (styles.length === 0) continue;
1087
- const innerCss = renderAtomicStylesCss({
2308
+ parts.push(...renderLayerBlocks({
2309
+ layerGroups,
2310
+ layerOrder,
2311
+ isFormatted,
2312
+ render: (styles) => renderAtomicStylesCss({
1088
2313
  atomicStyles: styles,
1089
2314
  isPreview,
1090
2315
  isFormatted
1091
- });
1092
- parts.push(`@layer ${layerName} {${lineEnd}${innerCss}${lineEnd}}`);
1093
- }
2316
+ })
2317
+ }));
1094
2318
  return parts.join(lineEnd);
1095
2319
  }
1096
2320
  async function _renderPreflightDefinition({ engine, preflightDefinition, blocks = /* @__PURE__ */ new Map() }) {
@@ -1165,4 +2389,4 @@ function defineVariables(variables) {
1165
2389
  /* c8 ignore end */
1166
2390
 
1167
2391
  //#endregion
1168
- export { appendAutocompleteCssPropertyValues, appendAutocompleteExtraCssProperties, appendAutocompleteExtraProperties, appendAutocompletePropertyValues, appendAutocompleteSelectors, appendAutocompleteStyleItemStrings, createEngine, createLogger, defineEngineConfig, defineEnginePlugin, defineKeyframes, definePreflight, defineSelector, defineShortcut, defineStyleDefinition, defineVariables, log, renderCSSStyleBlocks, sortLayerNames };
2392
+ export { appendAutocomplete, createEngine, createLogger, defineEngineConfig, defineEnginePlugin, defineKeyframes, definePreflight, defineSelector, defineShortcut, defineStyleDefinition, defineVariables, log, renderCSSStyleBlocks, sortLayerNames };