import type { Action, ActionConfig, FromActionConfig } from '../actions/index.js'; import type { Equals, Keys, PrimitiveObject, SoA, UnionToIntersection } from '../libs/bemedev/globals/types'; import type { EventObject } from '../events/index.js'; import type { FromGuard, GuardConfig } from '../guards/index.js'; import type { Transitions, TransitionsConfig } from '../transitions/index.js'; import type { Identify, RecordS, ReduceArray, SingleOrArrayL } from '../types/index.js'; export type StateType = 'atomic' | 'compound' | 'parallel'; export type SNC = NodeConfig; export type ActivityMap = { guards: SingleOrArrayL; actions: SingleOrArrayL; } | ActionConfig; export type ActivityArray = SingleOrArrayL; export type ActivityConfig = Record; export type ActionsFromActivity = TS extends any ? ReduceArray extends infer TR ? TR extends { actions: SingleOrArrayL; } ? FromGuard> : FromActionConfig>> : never : never; export type GuardsFromActivity = TS extends any ? ReduceArray extends infer TR ? TR extends { guards: SingleOrArrayL; } ? FromGuard> : never : never : never; export type ExtractActionsFromActivity = T['activities'] extends infer TA extends ActivityConfig ? { [key in keyof TA]: ActionsFromActivity; }[keyof TA] : never; export type ExtractGuardsFromActivity = T['activities'] extends infer TA extends ActivityConfig ? { [key in keyof TA]: GuardsFromActivity; }[keyof TA] : never; export type ExtractDelaysFromActivity = 'activities' extends keyof T ? T['activities'] extends infer TA extends ActivityConfig ? TA extends any ? keyof TA : never : never : never; export type BaseConfig = { readonly description?: string; readonly entry?: SingleOrArrayL; readonly exit?: SingleOrArrayL; readonly tags?: SingleOrArrayL; readonly activities?: ActivityConfig; }; export type CommonNodeConfig = BaseConfig & TransitionsConfig; export type NodeConfig = CommonNodeConfig & ({ readonly type?: 'atomic'; readonly initial?: never; readonly states?: never; } | { readonly type?: 'compound'; readonly initial: I; readonly states: RecordS; } | { readonly type: 'parallel'; readonly initial?: never; readonly states: RecordS; }); export type NodeConfigAtomic = CommonNodeConfig & { readonly type?: 'atomic'; readonly initial?: never; readonly states?: never; }; export type NodeConfigCompound = CommonNodeConfig & { readonly type?: 'compound'; readonly initial: I; readonly states: RecordS; }; export type NodeConfigParallel = CommonNodeConfig & { readonly type: 'parallel'; readonly initial?: never; readonly states: RecordS; }; export type StateValue = string | StateValueMap; export interface StateValueMap { [key: string]: StateValue; } export type WorkingStatus = 'idle' | 'starting' | 'started' | 'paused' | 'working' | 'sending' | 'stopped' | 'busy'; type _ExtractTagsFromFlat = { [key in keyof Flat]: Flat[key] extends infer S extends { tags: SingleOrArrayL; } ? ReduceArray : never; }[keyof Flat]; export type ExtractTagsFromFlat = _ExtractTagsFromFlat extends infer Tags ? Equals extends true ? string : Equals extends true ? string : Tags : string; export type State = { context: Tc; status: WorkingStatus; value: StateValue; event: E; tags?: SoA; }; export type StateP = { context: Tc; status: WorkingStatus; value: StateValue; payload: E; tags?: SoA; }; export type StateExtended = { pContext: Pc; } & State; export type StatePextended = { pContext: Pc; } & StateP; type FlatMapNodeConfig = 'states' extends keyof T ? { readonly [key in keyof T['states'] as `${Remaining}${key & string}`]: withChildren extends true ? T['states'][key] : Omit; } & { [key in keyof T['states']]: T['states'][key] extends infer S extends NodeConfig & { states: RecordS; } ? FlatMapNodeConfig : {}; }[keyof T['states']] : {}; export type FlatMapN = UnionToIntersection> & { readonly '/': T; }; type AlwaysEnd = `${string}.always` | `${string}.always.[${number}]`; export type EndWithAlways = Extract; export type EndwA = EndWithAlways; export type Node = { id?: string; description?: string; type: StateType; entry: Action[]; exit: Action[]; tags: string[]; states: Identify>[]; initial?: string; } & Transitions; export {}; //# sourceMappingURL=types.d.ts.map