11import { ProviderDriverKind } from "@t3tools/contracts" ;
2- import type { CSSProperties } from "react" ;
32import { ClaudeAI , CursorIcon , GrokIcon , Icon , OpenAI , OpenCodeIcon } from "../Icons" ;
43import { PROVIDER_OPTIONS } from "../../session-logic" ;
54
@@ -11,58 +10,6 @@ export const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>
1110 [ ProviderDriverKind . make ( "grok" ) ] : GrokIcon ,
1211} ;
1312
14- type ProviderIconAverageColor = {
15- readonly light : string ;
16- readonly dark : string ;
17- } ;
18-
19- function averageHexColors ( colors : ReadonlyArray < string > ) : string {
20- const channels = colors . reduce < [ number , number , number ] > (
21- ( sum , color ) => {
22- const value = color . slice ( 1 ) ;
23- return [
24- sum [ 0 ] + Number . parseInt ( value . slice ( 0 , 2 ) , 16 ) ,
25- sum [ 1 ] + Number . parseInt ( value . slice ( 2 , 4 ) , 16 ) ,
26- sum [ 2 ] + Number . parseInt ( value . slice ( 4 , 6 ) , 16 ) ,
27- ] ;
28- } ,
29- [ 0 , 0 , 0 ] ,
30- ) ;
31- return `#${ channels
32- . map ( ( channel ) =>
33- Math . round ( channel / colors . length )
34- . toString ( 16 )
35- . padStart ( 2 , "0" ) ,
36- )
37- . join ( "" ) } `;
38- }
39-
40- /** Average of the fill colors used by each provider SVG in Icons.tsx. */
41- const PROVIDER_ICON_AVERAGE_COLOR_BY_PROVIDER : Partial <
42- Record < ProviderDriverKind , ProviderIconAverageColor >
43- > = {
44- [ ProviderDriverKind . make ( "codex" ) ] : { light : "#000000" , dark : "#ffffff" } ,
45- [ ProviderDriverKind . make ( "claudeAgent" ) ] : { light : "#d97757" , dark : "#d97757" } ,
46- [ ProviderDriverKind . make ( "cursor" ) ] : { light : "#26251e" , dark : "#edecec" } ,
47- [ ProviderDriverKind . make ( "grok" ) ] : { light : "#0f0f0f" , dark : "#f5f5f5" } ,
48- [ ProviderDriverKind . make ( "opencode" ) ] : {
49- light : averageHexColors ( [ "#cfcecd" , "#211e1e" ] ) ,
50- dark : averageHexColors ( [ "#4b4646" , "#f1ecec" ] ) ,
51- } ,
52- } ;
53-
54- export function getProviderIconAverageColorStyle (
55- driverKind : ProviderDriverKind ,
56- ) : CSSProperties | undefined {
57- const color = PROVIDER_ICON_AVERAGE_COLOR_BY_PROVIDER [ driverKind ] ;
58- return color === undefined
59- ? undefined
60- : ( {
61- "--provider-icon-average-color-light" : color . light ,
62- "--provider-icon-average-color-dark" : color . dark ,
63- } as CSSProperties ) ;
64- }
65-
6613function isAvailableProviderOption ( option : ( typeof PROVIDER_OPTIONS ) [ number ] ) : option is {
6714 value : ProviderDriverKind ;
6815 label : string ;
0 commit comments