opencrabs 0.5.1

The autonomous, self-improving AI agent. Single Rust binary. Every channel. Recommended: the 40MB prebuilt binary for macOS, Linux and Windows: https://github.com/adolfousier/opencrabs/releases
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
//! Built-in theme presets for the S2 theme runtime (#1364).
//!
//! Hex values are pinned to UPSTREAM specs, not third-party ports:
//! - dracula / alucard: https://draculatheme.com/spec (alucard is the
//!   official light companion, bg #FFFBEB; surface ladder is the spec's
//!   floating/bg-light/bg-dark)
//! - monokai classic: tomasr/molokai (classic variant, #272822 bg)
//! - solarized light/dark: https://ethanschoonover.com/solarized
//!   (one 16-color spec, two modes; light = bg base3 / fg base00)
//! - catppuccin mocha/latte: https://github.com/catppuccin/palette
//!
//! Roles the upstream spec does not distinguish are mapped onto the
//! spec's ladder (commented "derived"). The regression tests pin every
//! spec-listed value so silent drift fails CI.

use std::sync::OnceLock;

use ratatui::style::Color;

use super::theme::{AnsiColors, Theme, ThemeColors};

const fn rgb(hex: u32) -> Color {
    Color::Rgb(
        ((hex >> 16) & 0xFF) as u8,
        ((hex >> 8) & 0xFF) as u8,
        (hex & 0xFF) as u8,
    )
}

// ── Dracula (dark) ──────────────────────────────────────────────────────────
// Spec: bg #282A36 · fg #F8F8F2 · comment #6272A4 · current line #44475A ·
// red #FF5555 · green #50FA7B · orange #FFB86C · yellow #F1FA8C ·
// purple #BD93F9 · cyan #8BE9FD
pub static DRACULA: Theme = Theme {
    name: "dracula",
    colors: ThemeColors {
        accent: rgb(0xFFB86C),      // spec orange
        accent_teal: rgb(0x8BE9FD), // spec cyan
        accent_soft: rgb(0xF8F8F2), // spec fg
        text_primary: rgb(0xF8F8F2),
        text_secondary: rgb(0x6272A4), // spec comment (derived)
        text_muted: rgb(0x6272A4),
        text_dim: rgb(0x6272A4),
        gray: rgb(0x6272A4),     // ladder: comment (derived)
        gray_mid: rgb(0x44475A), // current line
        gray_detail: rgb(0x44475A),
        gray_dim: rgb(0x44475A),
        gray_dark: rgb(0x44475A),
        gray_base: rgb(0x282A36), // spec bg
        gray_light: rgb(0xF8F8F2),
        gray_soft: rgb(0x6272A4),
        gray_muted: rgb(0x6272A4),
        success: rgb(0x50FA7B),
        analytics_green: rgb(0x50FA7B),
        green_check: rgb(0x50FA7B),
        error: rgb(0xFF5555),
        error_soft: rgb(0xFF5555),
        error_faded: rgb(0xFF5555),
        warning: rgb(0xF1FA8C), // spec yellow
        warning_muted: rgb(0xF1FA8C),
        amber_muted: rgb(0xFFB86C),
        teal_vivid: rgb(0x8BE9FD),
        teal_bright: rgb(0x8BE9FD),
        teal_muted: rgb(0x8BE9FD),
        teal_calm: rgb(0x8BE9FD),
        blue_slate: rgb(0x6272A4),
        blue_steel: rgb(0xBD93F9), // spec purple (derived)
        blue_link: rgb(0x8BE9FD),
        blue_sky: rgb(0x8BE9FD),
        blue_soft: rgb(0x8BE9FD),
        blue_vivid: rgb(0xBD93F9),
        blue_code: rgb(0xBD93F9),
        selection_bg: rgb(0x44475A), // current line = selection
        surface_panel: rgb(0x282A36),
        surface_qr: rgb(0x282A36),
        surface_code: rgb(0x44475A),
        surface_code_alt: rgb(0x44475A),
        ink: rgb(0x282A36),
        purple_soft: rgb(0xBD93F9),
        ansi: AnsiColors {
            accent: 215,
            accent_teal: 117,
            accent_soft: 231,
            text_primary: 231,
            text_secondary: 61,
            text_muted: 61,
            text_dim: 61,
            gray: 61,
            gray_mid: 59,
            gray_detail: 59,
            gray_dim: 59,
            gray_dark: 59,
            gray_base: 17,
            gray_light: 231,
            gray_soft: 61,
            gray_muted: 61,
            success: 84,
            analytics_green: 84,
            green_check: 84,
            error: 203,
            error_soft: 203,
            error_faded: 203,
            warning: 228,
            warning_muted: 228,
            amber_muted: 215,
            teal_vivid: 117,
            teal_bright: 117,
            teal_muted: 117,
            teal_calm: 117,
            blue_slate: 61,
            blue_steel: 141,
            blue_link: 117,
            blue_sky: 117,
            blue_soft: 117,
            blue_vivid: 141,
            blue_code: 141,
            selection_bg: 59,
            surface_panel: 17,
            surface_qr: 17,
            surface_code: 59,
            surface_code_alt: 59,
            ink: 17,
            purple_soft: 141,
        },
    },
};

// ── Alucard (light) ─────────────────────────────────────────────────────────
// Official Dracula light companion. Spec: bg #FFFBEB · fg #1F1F1F ·
// comment #6C664B · red #CB3A2A · green #14710A · orange #A34D14 ·
// purple #644AC9 · surface ladder: floating #EFEDDC · bg-light #DEDCCF ·
// bg-dark #CECCC0
pub static ALUCARD: Theme = Theme {
    name: "alucard",
    colors: ThemeColors {
        accent: rgb(0xA34D14),      // spec orange
        accent_teal: rgb(0x644AC9), // spec purple (derived: no cyan in spec)
        accent_soft: rgb(0x1F1F1F),
        text_primary: rgb(0x1F1F1F),
        text_secondary: rgb(0x6C664B), // spec comment
        text_muted: rgb(0x6C664B),
        text_dim: rgb(0x6C664B),
        gray: rgb(0x6C664B),
        gray_mid: rgb(0xCECCC0), // spec bg-dark
        gray_detail: rgb(0xCECCC0),
        gray_dim: rgb(0xCECCC0),
        gray_dark: rgb(0xCECCC0),
        gray_base: rgb(0xCECCC0),
        gray_light: rgb(0x1F1F1F),
        gray_soft: rgb(0x6C664B),
        gray_muted: rgb(0x6C664B),
        success: rgb(0x14710A),
        analytics_green: rgb(0x14710A),
        green_check: rgb(0x14710A),
        error: rgb(0xCB3A2A),
        error_soft: rgb(0xCB3A2A),
        error_faded: rgb(0xCB3A2A),
        warning: rgb(0xA34D14), // derived: spec orange as amber
        warning_muted: rgb(0xA34D14),
        amber_muted: rgb(0xA34D14),
        teal_vivid: rgb(0x644AC9),
        teal_bright: rgb(0x644AC9),
        teal_muted: rgb(0x644AC9),
        teal_calm: rgb(0x644AC9),
        blue_slate: rgb(0x6C664B),
        blue_steel: rgb(0x644AC9),
        blue_link: rgb(0x644AC9),
        blue_sky: rgb(0x644AC9),
        blue_soft: rgb(0x644AC9),
        blue_vivid: rgb(0x644AC9),
        blue_code: rgb(0x644AC9),
        selection_bg: rgb(0xDEDCCF),  // spec bg-light
        surface_panel: rgb(0xFFFBEB), // spec bg
        surface_qr: rgb(0xEFEDDC),    // spec floating
        surface_code: rgb(0xDEDCCF),
        surface_code_alt: rgb(0xCECCC0),
        ink: rgb(0x1F1F1F),
        purple_soft: rgb(0x644AC9),
        ansi: AnsiColors {
            accent: 130,
            accent_teal: 62,
            accent_soft: 235,
            text_primary: 235,
            text_secondary: 59,
            text_muted: 59,
            text_dim: 59,
            gray: 59,
            gray_mid: 187,
            gray_detail: 187,
            gray_dim: 187,
            gray_dark: 187,
            gray_base: 187,
            gray_light: 235,
            gray_soft: 59,
            gray_muted: 59,
            success: 22,
            analytics_green: 22,
            green_check: 22,
            error: 166,
            error_soft: 166,
            error_faded: 166,
            warning: 130,
            warning_muted: 130,
            amber_muted: 130,
            teal_vivid: 62,
            teal_bright: 62,
            teal_muted: 62,
            teal_calm: 62,
            blue_slate: 59,
            blue_steel: 62,
            blue_link: 62,
            blue_sky: 62,
            blue_soft: 62,
            blue_vivid: 62,
            blue_code: 62,
            selection_bg: 188,
            surface_panel: 230,
            surface_qr: 230,
            surface_code: 188,
            surface_code_alt: 187,
            ink: 235,
            purple_soft: 62,
        },
    },
};

// ── Monokai classic (dark) ──────────────────────────────────────────────────
// tomasr/molokai canonical: bg #272822 · fg #F8F8F2 · pink #F92672 ·
// green #A6E22E · orange #FD971F · cyan #66D9EF · yellow #E6DB74 ·
// purple #AE81FF · comment #75715E · selection #49483E
pub static MONOKAI: Theme = Theme {
    name: "monokai",
    colors: ThemeColors {
        accent: rgb(0xFD971F),      // orange
        accent_teal: rgb(0x66D9EF), // cyan
        accent_soft: rgb(0xF8F8F2),
        text_primary: rgb(0xF8F8F2),
        text_secondary: rgb(0x75715E),
        text_muted: rgb(0x75715E),
        text_dim: rgb(0x75715E),
        gray: rgb(0x75715E),
        gray_mid: rgb(0x49483E),
        gray_detail: rgb(0x49483E),
        gray_dim: rgb(0x49483E),
        gray_dark: rgb(0x49483E),
        gray_base: rgb(0x272822),
        gray_light: rgb(0xF8F8F2),
        gray_soft: rgb(0x75715E),
        gray_muted: rgb(0x75715E),
        success: rgb(0xA6E22E),
        analytics_green: rgb(0xA6E22E),
        green_check: rgb(0xA6E22E),
        error: rgb(0xF92672), // pink
        error_soft: rgb(0xF92672),
        error_faded: rgb(0xF92672),
        warning: rgb(0xE6DB74), // yellow
        warning_muted: rgb(0xE6DB74),
        amber_muted: rgb(0xFD971F),
        teal_vivid: rgb(0x66D9EF),
        teal_bright: rgb(0x66D9EF),
        teal_muted: rgb(0x66D9EF),
        teal_calm: rgb(0x66D9EF),
        blue_slate: rgb(0x75715E),
        blue_steel: rgb(0x66D9EF),
        blue_link: rgb(0x66D9EF),
        blue_sky: rgb(0x66D9EF),
        blue_soft: rgb(0x66D9EF),
        blue_vivid: rgb(0xAE81FF), // purple
        blue_code: rgb(0xAE81FF),
        selection_bg: rgb(0x49483E),
        surface_panel: rgb(0x272822),
        surface_qr: rgb(0x272822),
        surface_code: rgb(0x3E3D32),
        surface_code_alt: rgb(0x3E3D32),
        ink: rgb(0x272822),
        purple_soft: rgb(0xAE81FF),
        ansi: AnsiColors {
            accent: 208,
            accent_teal: 81,
            accent_soft: 231,
            text_primary: 231,
            text_secondary: 95,
            text_muted: 95,
            text_dim: 95,
            gray: 95,
            gray_mid: 59,
            gray_detail: 59,
            gray_dim: 59,
            gray_dark: 59,
            gray_base: 16,
            gray_light: 231,
            gray_soft: 95,
            gray_muted: 95,
            success: 148,
            analytics_green: 148,
            green_check: 148,
            error: 197,
            error_soft: 197,
            error_faded: 197,
            warning: 186,
            warning_muted: 186,
            amber_muted: 208,
            teal_vivid: 81,
            teal_bright: 81,
            teal_muted: 81,
            teal_calm: 81,
            blue_slate: 95,
            blue_steel: 81,
            blue_link: 81,
            blue_sky: 81,
            blue_soft: 81,
            blue_vivid: 141,
            blue_code: 141,
            selection_bg: 59,
            surface_panel: 16,
            surface_qr: 16,
            surface_code: 59,
            surface_code_alt: 59,
            ink: 16,
            purple_soft: 141,
        },
    },
};

// ── Catppuccin Mocha (dark) ─────────────────────────────────────────────────
// https://github.com/catppuccin/palette — semantic roles map 1:1:
// base #1E1E2E · mantle #181825 · text #CDD6F4 · subtext0 #A6ADC8 ·
// subtext1 #BAC2DE · overlay0 #6C7086 · overlay1 #7F849C · surface0
// #313244 · surface1 #45475A · surface2 #585B70 · red #F38BA8 · green
// #A6E3A1 · yellow #F9E2AF · orange #FAB387 · mauve #CBA6F7 · blue
// #89B4FA · teal #94E2D5 · red-dim #EBA0AC
pub static CATPPUCCIN_MOCHA: Theme = Theme {
    name: "catppuccin-mocha",
    colors: ThemeColors {
        accent: rgb(0xFAB387),      // orange
        accent_teal: rgb(0x94E2D5), // teal
        accent_soft: rgb(0xCDD6F4), // text
        text_primary: rgb(0xCDD6F4),
        text_secondary: rgb(0xBAC2DE), // subtext1
        text_muted: rgb(0xA6ADC8),     // subtext0
        text_dim: rgb(0x6C7086),       // overlay0
        gray: rgb(0xA6ADC8),
        gray_mid: rgb(0x585B70), // surface2
        gray_detail: rgb(0x585B70),
        gray_dim: rgb(0x45475A),  // surface1
        gray_dark: rgb(0x313244), // surface0
        gray_base: rgb(0x181825), // mantle
        gray_light: rgb(0xCDD6F4),
        gray_soft: rgb(0x7F849C), // overlay1
        gray_muted: rgb(0x6C7086),
        success: rgb(0xA6E3A1),
        analytics_green: rgb(0xA6E3A1),
        green_check: rgb(0xA6E3A1),
        error: rgb(0xF38BA8),
        error_soft: rgb(0xF38BA8),
        error_faded: rgb(0xEBA0AC), // red-dim
        warning: rgb(0xF9E2AF),
        warning_muted: rgb(0xF9E2AF),
        amber_muted: rgb(0xFAB387),
        teal_vivid: rgb(0x94E2D5),
        teal_bright: rgb(0x94E2D5),
        teal_muted: rgb(0x94E2D5),
        teal_calm: rgb(0x94E2D5),
        blue_slate: rgb(0x6C7086),
        blue_steel: rgb(0x89B4FA),
        blue_link: rgb(0x89B4FA),
        blue_sky: rgb(0x89B4FA),
        blue_soft: rgb(0x89B4FA),
        blue_vivid: rgb(0xCBA6F7), // mauve
        blue_code: rgb(0xCBA6F7),
        selection_bg: rgb(0x45475A),  // surface1
        surface_panel: rgb(0x1E1E2E), // base
        surface_qr: rgb(0x181825),    // mantle
        surface_code: rgb(0x313244),  // surface0
        surface_code_alt: rgb(0x45475A),
        ink: rgb(0x1E1E2E),
        purple_soft: rgb(0xCBA6F7),
        ansi: AnsiColors {
            accent: 216,
            accent_teal: 116,
            accent_soft: 189,
            text_primary: 189,
            text_secondary: 146,
            text_muted: 146,
            text_dim: 60,
            gray: 146,
            gray_mid: 59,
            gray_detail: 59,
            gray_dim: 59,
            gray_dark: 59,
            gray_base: 16,
            gray_light: 189,
            gray_soft: 103,
            gray_muted: 60,
            success: 151,
            analytics_green: 151,
            green_check: 151,
            error: 211,
            error_soft: 211,
            error_faded: 181,
            warning: 223,
            warning_muted: 223,
            amber_muted: 216,
            teal_vivid: 116,
            teal_bright: 116,
            teal_muted: 116,
            teal_calm: 116,
            blue_slate: 60,
            blue_steel: 111,
            blue_link: 111,
            blue_sky: 111,
            blue_soft: 111,
            blue_vivid: 183,
            blue_code: 183,
            selection_bg: 59,
            surface_panel: 16,
            surface_qr: 16,
            surface_code: 59,
            surface_code_alt: 59,
            ink: 16,
            purple_soft: 183,
        },
    },
};

// ── Catppuccin Latte (light) ────────────────────────────────────────────────
// Same spec, light mode: base #EFF1F5 · mantle #E6E9EF · text #4C4F69 ·
// subtext0 #6C6F85 · subtext1 #5C5F77 · overlay0 #9CA0B0 · overlay1
// #8C8FA1 · surface0 #CCD0DA · surface1 #BCC0CC · surface2 #ACADE3 ·
// red #D20F39 · green #40A02B · yellow #DF8E1D · orange #FE640B · mauve
// #8839EF · blue #1E66F5 · teal #179299 · red 30% #E64553
pub static CATPPUCCIN_LATTE: Theme = Theme {
    name: "catppuccin-latte",
    colors: ThemeColors {
        accent: rgb(0xFE640B),      // orange
        accent_teal: rgb(0x179299), // teal
        accent_soft: rgb(0x4C4F69),
        text_primary: rgb(0x4C4F69),
        text_secondary: rgb(0x5C5F77), // subtext1
        text_muted: rgb(0x6C6F85),     // subtext0
        text_dim: rgb(0x9CA0B0),       // overlay0
        gray: rgb(0x6C6F85),
        gray_mid: rgb(0xACADE3), // surface2
        gray_detail: rgb(0xACADE3),
        gray_dim: rgb(0xBCC0CC),  // surface1
        gray_dark: rgb(0xCCD0DA), // surface0
        gray_base: rgb(0xE6E9EF), // mantle
        gray_light: rgb(0x4C4F69),
        gray_soft: rgb(0x8C8FA1), // overlay1
        gray_muted: rgb(0x9CA0B0),
        success: rgb(0x40A02B),
        analytics_green: rgb(0x40A02B),
        green_check: rgb(0x40A02B),
        error: rgb(0xD20F39),
        error_soft: rgb(0xD20F39),
        error_faded: rgb(0xE64553), // red 30% lightened
        warning: rgb(0xDF8E1D),
        warning_muted: rgb(0xDF8E1D),
        amber_muted: rgb(0xFE640B),
        teal_vivid: rgb(0x179299),
        teal_bright: rgb(0x179299),
        teal_muted: rgb(0x179299),
        teal_calm: rgb(0x179299),
        blue_slate: rgb(0x9CA0B0),
        blue_steel: rgb(0x1E66F5),
        blue_link: rgb(0x1E66F5),
        blue_sky: rgb(0x1E66F5),
        blue_soft: rgb(0x1E66F5),
        blue_vivid: rgb(0x8839EF), // mauve
        blue_code: rgb(0x8839EF),
        selection_bg: rgb(0xBCC0CC),  // surface1
        surface_panel: rgb(0xEFF1F5), // base
        surface_qr: rgb(0xE6E9EF),    // mantle
        surface_code: rgb(0xCCD0DA),  // surface0
        surface_code_alt: rgb(0xBCC0CC),
        ink: rgb(0x4C4F69),
        purple_soft: rgb(0x8839EF),
        ansi: AnsiColors {
            accent: 202,
            accent_teal: 30,
            accent_soft: 59,
            text_primary: 59,
            text_secondary: 60,
            text_muted: 60,
            text_dim: 145,
            gray: 60,
            gray_mid: 146,
            gray_detail: 146,
            gray_dim: 146,
            gray_dark: 188,
            gray_base: 189,
            gray_light: 59,
            gray_soft: 103,
            gray_muted: 145,
            success: 70,
            analytics_green: 70,
            green_check: 70,
            error: 161,
            error_soft: 161,
            error_faded: 167,
            warning: 172,
            warning_muted: 172,
            amber_muted: 202,
            teal_vivid: 30,
            teal_bright: 30,
            teal_muted: 30,
            teal_calm: 30,
            blue_slate: 145,
            blue_steel: 27,
            blue_link: 27,
            blue_sky: 27,
            blue_soft: 27,
            blue_vivid: 99,
            blue_code: 99,
            selection_bg: 146,
            surface_panel: 231,
            surface_qr: 189,
            surface_code: 188,
            surface_code_alt: 146,
            ink: 59,
            purple_soft: 99,
        },
    },
};

/// Built-in roster in `/theme list` order. `crab-dark` (from `theme.rs`)
/// is first because it is the default and byte-identical to pre-S2
/// colors by construction. The array is `static` so the returned slice
/// is `'static` — a literal `&[...]` would be a temporary.
/// The hand-built presets, in `/theme list` order. crab-dark (from
/// `theme.rs`) is first because it is the default.
static HAND_BUILT_INS: [&Theme; 8] = [
    &super::theme::CRAB_DARK,
    &DRACULA,
    &ALUCARD,
    &MONOKAI,
    &SOLARIZED_LIGHT,
    &SOLARIZED_DARK,
    &CATPPUCCIN_MOCHA,
    &CATPPUCCIN_LATTE,
];

/// Full built-in roster: hand-built presets first, then the embedded
/// curated pack (#1461). Pack themes are built once through the existing
/// user-theme validator; see `crate::tui::theme_catalog::theme_pack` for
/// the initialization-order invariants (the validator's collision check
/// re-enters `by_name`, so `by_name` must never force this).
pub fn built_ins() -> &'static [&'static Theme] {
    static ALL: OnceLock<Vec<&'static Theme>> = OnceLock::new();
    ALL.get_or_init(|| {
        HAND_BUILT_INS
            .iter()
            .copied()
            .chain(crate::tui::theme_catalog::theme_pack::themes().iter())
            .collect()
    })
}

/// Case-insensitive preset lookup by name (what `/theme set` feeds).
/// Scans the hand-built statics, then the embedded pack through its
/// NON-FORCING view: during pack initialization the validator's collision
/// check lands here, and forcing `built_ins()` (or `themes()`) from that
/// path would re-enter the `OnceLock` initializer.
pub fn by_name(name: &str) -> Option<&'static Theme> {
    let lowered = name.to_ascii_lowercase();
    HAND_BUILT_INS
        .iter()
        .find(|t| t.name.to_ascii_lowercase() == lowered)
        .copied()
        .or_else(|| {
            crate::tui::theme_catalog::theme_pack::themes_if_built()
                .and_then(|pack| pack.iter().find(|t| t.name.to_ascii_lowercase() == lowered))
        })
}

// ── Solarized Light / Dark ──────────────────────────────────────────────────
// One 16-color spec, two modes: light = bg base3 #FDF6E3 / fg base00
// #657B83; dark = bg base03 #002B36 / fg base0 #839496. Shared accents:
// yellow #B58900 · orange #CB4B16 · red #DC322F · green #859900 ·
// cyan #2AA198 · blue #268BD2 · violet #6C71C4. base2 #EEE8D5 ·
// base01 #586E75 · base02 #073642.
pub static SOLARIZED_LIGHT: Theme = Theme {
    name: "solarized-light",
    colors: ThemeColors {
        accent: rgb(0xCB4B16),      // orange
        accent_teal: rgb(0x2AA198), // cyan
        accent_soft: rgb(0x657B83),
        text_primary: rgb(0x657B83),   // base00
        text_secondary: rgb(0x93A1A1), // base1
        text_muted: rgb(0x93A1A1),
        text_dim: rgb(0x93A1A1),
        gray: rgb(0x93A1A1),
        gray_mid: rgb(0xEEE8D5), // base2
        gray_detail: rgb(0xEEE8D5),
        gray_dim: rgb(0xEEE8D5),
        gray_dark: rgb(0xEEE8D5),
        gray_base: rgb(0xEEE8D5),
        gray_light: rgb(0x073642), // base02: darkest text on light bg
        gray_soft: rgb(0x586E75),  // base01
        gray_muted: rgb(0x586E75),
        success: rgb(0x859900),
        analytics_green: rgb(0x859900),
        green_check: rgb(0x859900),
        error: rgb(0xDC322F),
        error_soft: rgb(0xDC322F),
        error_faded: rgb(0xDC322F),
        warning: rgb(0xB58900), // yellow
        warning_muted: rgb(0xB58900),
        amber_muted: rgb(0xB58900),
        teal_vivid: rgb(0x2AA198),
        teal_bright: rgb(0x2AA198),
        teal_muted: rgb(0x2AA198),
        teal_calm: rgb(0x2AA198),
        blue_slate: rgb(0x93A1A1),
        blue_steel: rgb(0x268BD2),
        blue_link: rgb(0x268BD2),
        blue_sky: rgb(0x2AA198),
        blue_soft: rgb(0x268BD2),
        blue_vivid: rgb(0x6C71C4), // violet
        blue_code: rgb(0x6C71C4),
        selection_bg: rgb(0xEEE8D5),  // base2
        surface_panel: rgb(0xFDF6E3), // base3
        surface_qr: rgb(0xEEE8D5),
        surface_code: rgb(0xEEE8D5),
        surface_code_alt: rgb(0xEEE8D5),
        ink: rgb(0x073642),
        purple_soft: rgb(0x6C71C4),
        ansi: AnsiColors {
            accent: 166,
            accent_teal: 36,
            accent_soft: 66,
            text_primary: 66,
            text_secondary: 109,
            text_muted: 109,
            text_dim: 109,
            gray: 109,
            gray_mid: 224,
            gray_detail: 224,
            gray_dim: 224,
            gray_dark: 224,
            gray_base: 224,
            gray_light: 23,
            gray_soft: 60,
            gray_muted: 60,
            success: 100,
            analytics_green: 100,
            green_check: 100,
            error: 166,
            error_soft: 166,
            error_faded: 166,
            warning: 136,
            warning_muted: 136,
            amber_muted: 136,
            teal_vivid: 36,
            teal_bright: 36,
            teal_muted: 36,
            teal_calm: 36,
            blue_slate: 109,
            blue_steel: 32,
            blue_link: 32,
            blue_sky: 36,
            blue_soft: 32,
            blue_vivid: 62,
            blue_code: 62,
            selection_bg: 224,
            surface_panel: 230,
            surface_qr: 224,
            surface_code: 224,
            surface_code_alt: 224,
            ink: 23,
            purple_soft: 62,
        },
    },
};

pub static SOLARIZED_DARK: Theme = Theme {
    name: "solarized-dark",
    colors: ThemeColors {
        accent: rgb(0xCB4B16),
        accent_teal: rgb(0x2AA198),
        accent_soft: rgb(0x839496),
        text_primary: rgb(0x839496),   // base0
        text_secondary: rgb(0x657B83), // base00
        text_muted: rgb(0x586E75),     // base01
        text_dim: rgb(0x586E75),
        gray: rgb(0x586E75),
        gray_mid: rgb(0x073642), // base02
        gray_detail: rgb(0x073642),
        gray_dim: rgb(0x073642),
        gray_dark: rgb(0x073642),
        gray_base: rgb(0x002B36),  // base03
        gray_light: rgb(0xEEE8D5), // base2: brightest text on dark bg
        gray_soft: rgb(0x839496),
        gray_muted: rgb(0x657B83),
        success: rgb(0x859900),
        analytics_green: rgb(0x859900),
        green_check: rgb(0x859900),
        error: rgb(0xDC322F),
        error_soft: rgb(0xDC322F),
        error_faded: rgb(0xDC322F),
        warning: rgb(0xB58900),
        warning_muted: rgb(0xB58900),
        amber_muted: rgb(0xB58900),
        teal_vivid: rgb(0x2AA198),
        teal_bright: rgb(0x2AA198),
        teal_muted: rgb(0x2AA198),
        teal_calm: rgb(0x2AA198),
        blue_slate: rgb(0x586E75),
        blue_steel: rgb(0x268BD2),
        blue_link: rgb(0x2AA198),
        blue_sky: rgb(0x2AA198),
        blue_soft: rgb(0x268BD2),
        blue_vivid: rgb(0x6C71C4),
        blue_code: rgb(0x6C71C4),
        selection_bg: rgb(0x073642),  // base02
        surface_panel: rgb(0x002B36), // base03
        surface_qr: rgb(0x002B36),
        surface_code: rgb(0x073642),
        surface_code_alt: rgb(0x073642),
        ink: rgb(0x002B36),
        purple_soft: rgb(0x6C71C4),
        ansi: AnsiColors {
            accent: 166,
            accent_teal: 36,
            accent_soft: 102,
            text_primary: 102,
            text_secondary: 66,
            text_muted: 60,
            text_dim: 60,
            gray: 60,
            gray_mid: 23,
            gray_detail: 23,
            gray_dim: 23,
            gray_dark: 23,
            gray_base: 17,
            gray_light: 224,
            gray_soft: 102,
            gray_muted: 66,
            success: 100,
            analytics_green: 100,
            green_check: 100,
            error: 166,
            error_soft: 166,
            error_faded: 166,
            warning: 136,
            warning_muted: 136,
            amber_muted: 136,
            teal_vivid: 36,
            teal_bright: 36,
            teal_muted: 36,
            teal_calm: 36,
            blue_slate: 60,
            blue_steel: 32,
            blue_link: 36,
            blue_sky: 36,
            blue_soft: 32,
            blue_vivid: 62,
            blue_code: 62,
            selection_bg: 23,
            surface_panel: 17,
            surface_qr: 17,
            surface_code: 23,
            surface_code_alt: 23,
            ink: 17,
            purple_soft: 62,
        },
    },
};