import type * as CSS from 'csstype'; export type CSSValue = string | number; export type CustomValue = string | number | boolean; export type Value = CustomValue | readonly CustomValue[]; export type PropertyValueDefinition = T | { [condition: string]: PropertyValueDefinition; }; export type PropertyValueMap = { [name in T]: PropertyValueDefinition; }; export type CustomProperty = `--${string}`; export type CSSProperties = CSS.Properties & { [k: CustomProperty]: CSSValue; }; export type PropertyFunction = (value: T, property: string) => PropertyValueDefinition<[CSSProperties, string]>; export interface Theme { properties: { [name: string]: PropertyValueMap | PropertyFunction | string[]; }; conditions: { [name: string]: string; }; shorthands: { [name: string]: string[]; }; } type PropertyValue = T extends PropertyFunction ? P : T extends PropertyValueMap ? P : T extends string[] ? T[number] : never; type PropertyValue2 = PropertyValue | CustomProperty | `[${string}]`; type Merge = T extends any ? T : never; export type ThemeProperties = Merge<{ [K in keyof T['properties'] | keyof T['shorthands']]: K extends keyof T['properties'] ? Merge> : Merge>; }>; type Style, C extends string, R extends RenderProps> = StaticProperties & CustomProperties; type StaticProperties, C extends string, R extends RenderProps> = { [Name in keyof T]?: StyleValue; }; type CustomProperties, C extends string, R extends RenderProps> = { [key: CustomProperty]: CustomPropertyValue; }; type CustomPropertyValue, P extends keyof T, C extends string, R extends RenderProps> = P extends any ? { type: P; value: StyleValue; } : never; export type RenderProps = { [key in K]: any; }; export type StyleValue> = V | Conditional; export type Condition = 'default' | Extract; type Conditional> = CSSConditions & RuntimeConditions; type ArbitraryCondition = `:${string}` | `@${string}`; type CSSConditions> = { [name in C]?: StyleValue; }; type RuntimeConditions> = [ R ] extends [never] ? UnknownConditions : RenderPropConditions; type UnknownConditions = { [name: string]: StyleValue | VariantMap; }; type BooleanConditionName = `is${Capitalize}` | `allows${Capitalize}`; type RenderPropConditions> = { [K in keyof R]?: K extends BooleanConditionName ? StyleValue : VariantMap; }; type Values = { [k in K]: T[k]; }[K]; export type VariantMap> = { [k in K]?: StyleValue; }; type ExtractConditionalValue = V extends Value ? never : RuntimeConditionObject, boolean> | Variants> | ExtractConditionalValue> | Values>>>; type RuntimeConditionObject = K extends keyof any ? { [P in K]?: V; } : never; type Variants = K extends any ? { [k in K]?: keyof T[k]; } : never; type InferCustomPropertyValue = T extends { value: infer V; } ? V : never; type KeysOfUnion = T extends T ? keyof T : never; type KeyValue> = T extends { [k in K]?: any; } ? T[K] : never; type MergeUnion = { [K in KeysOfUnion]: KeyValue; }; type RuntimeConditionsObject> = MergeUnion> | InferCustomPropertyValue>>>>; type IncludedProperties = Merge<{ [K in keyof S]: unknown; }>; type Keys = [R] extends [never] ? never : keyof R; export type RuntimeStyleFunction = Keys extends never ? () => string & S : (props: R) => string & S; type InferProps> = [R] extends [never] ? AllowOthers> : R; type AllowOthers = Keys extends never ? never : R | { [x: string]: any; }; export type StyleFunction, C extends string> = = never, S extends Style = Style>(style: S) => RuntimeStyleFunction, InferProps>; type LimitTheme = Merge<{ [K in keyof T]?: K extends P ? unknown : never; }>; export type CSSProp = S extends StyleFunction ? string & LimitTheme : never; export {};