import type { PromiseDef, SAS, SingleOrArray, SoA } from './core'; export type SimpleGuard = string; export type GuardUnion = GuardAnd | GuardOr | SimpleGuard; export type GuardAnd = { and: GuardUnion[]; }; export type GuardOr = { or: GuardUnion[]; }; export type Guards = SingleOrArray; export type TransitionObj = { target?: S; cond?: Guards; actions?: SAS; description?: string; }; export type Transition = S | TransitionObj; export type BaseState = { entry?: SAS; description?: string; }; export type TransitionArray = readonly [ ...{ target?: S; cond: Guards; actions?: SAS; description?: string; }[], Transition ]; export type SimpleState = BaseState & { exit?: SAS; always?: Transition | TransitionArray; }; export type SRC = { src: S; then: Transition | TransitionArray; catch: Transition | TransitionArray; finally?: SAS; }; export type PromiseState = BaseState & { invoke: SoA>; }; export type FinalState = BaseState & { data: string; }; export type State = SimpleState | FinalState | PromiseState; export type Config = { data: string; states: Record; initial: string; }; export type ConfigTypes = { context: any; events: any; data: any; } & (C['states'][keyof C['states']] extends infer P extends PromiseState ? { promises: { [K in GetPromiseKeysFromPromise

]: PromiseDef; }; } : unknown); export type ConfigDef = { states: string; initial: string; }; export type NoExtraKeysConfigDef = T & { [K in Exclude]: never; }; export type TransformConfigDef = { initial: T['initial']; states: { [K in T['states'] | T['initial']]: T['states'] extends infer S1 extends string ? State : State; }; }; export type NoExtraKeysState = T & { [K in Exclude]: never; }; export type NoExtraKeysConfig = T & { [K in Exclude]: never; } & { states: { [K in keyof T['states']]: NoExtraKeysState; }; }; type _isAsyncConfig = C extends { states: Record; } ? A extends PromiseState ? true : false : never; export type IsAsyncConfig = _isAsyncConfig extends false ? false : true; export type ExtractSOA = unknown extends T ? never : T extends undefined ? never : T extends ReadonlyArray ? T[number] : T; export type GetEntryActions> = GetEntryActionKeysFromState; export type GetEntryActionKeysFromState = ExtractSOA; export type GetTransitionsActions = T extends string ? never : T extends TransitionObj ? ExtractSOA : T extends TransitionArray ? GetTransitionsActions : never; export type GetExitActionsFromSimpleState = ExtractSOA; export type GetActionKeysFromSimpleState = GetTransitionsActions> | GetEntryActionKeysFromState | GetExitActionsFromSimpleState; export type GetPromiseKeysFromPromise = ExtractSOA extends infer U extends SRC ? U['src'] : never; export type GetPromiseKeysFromConfig = Extract extends infer P extends PromiseState ? GetPromiseKeysFromPromise

: never; export type GetKeysFromGuard = T extends undefined ? never : T extends string ? T : T extends string[] ? T[number] : T extends readonly GuardUnion[] ? GetKeysFromGuard : T extends GuardOr ? GetKeysFromGuard : T extends GuardAnd ? GetKeysFromGuard : never; export type GetGuardKeysFromTransition = T extends string ? never : T extends TransitionObj ? GetKeysFromGuard : T extends TransitionArray ? GetGuardKeysFromTransition : never; type _ExtractDataKeysFromConfig = (C extends { data: infer D; } ? D : never) | { [K in keyof C['states']]: C['states'][K] extends infer Ck extends FinalState ? Ck['data'] : never; }[keyof C['states']]; export type ExtractDataKeysFromConfig = _ExtractDataKeysFromConfig extends infer T extends string ? T : never; export {}; //# sourceMappingURL=json.d.ts.map