import type { SubjectName, ActionMap, SubjectType, AfterExpectActionType, Behaviour } from "./SelectBranches.types"; import type { InteractivesEventTypes } from "./events"; import type { EventActionTypes } from "../../../manifest"; import type { ControlEvent, ContainerEvent, ChapterEvent, ChapterContainer, Control } from "../../../manifest"; import type { InteractiveRange } from "./getInteractiveRanges"; export type { SubjectName }; type InteractivesEventTypesValues = `${InteractivesEventTypes}`; type InteractivesEventTypesValuesChapter = InteractivesEventTypes.ACTION_CHOICE | InteractivesEventTypes.ACTION_CHOICE_CANCELED | InteractivesEventTypes.ACTION_EXECUTION; type InteractivesEventTypesValuesContainer = InteractivesEventTypesValues; type InteractivesEventTypesValuesControl = InteractivesEventTypesValuesChapter | InteractivesEventTypes.VISIBILITY; type InteractiveEventType = T extends "container" ? InteractivesEventTypesValuesContainer : InteractivesEventTypesValuesControl; type TInteractiveCommon< T extends SubjectName, U extends InteractiveEventType > = { subjectId: string; subjectName: T; type: U; }; export type TInteractivesVisibility> = TInteractiveCommon & { visibility: boolean; isFirst?: boolean; }; type EventActionTypesValues = `${EventActionTypes}`; export type TInteractiveRangeEndedEvent = { type: InteractivesEventTypes.RANGE_ENDED; payload: InteractiveRange; }; type NonChapterChangeEvents = EventActionTypes.openURI | EventActionTypes.continuePlayback | EventActionTypes.expect; type TInteractivesActionExecEventPayload = T extends Exclude ? Partial<{ chapterId: string; autoSelect: boolean; behaviour: Behaviour; manifestURL: string; }> : undefined; export type TInteractivesActionExecutionEvent = TInteractiveCommon & { actionType: ActionMap[T]["type"] | AfterExpectActionType; subjectType?: SubjectType; payload?: TInteractivesActionExecEventPayload; }; type TControlPayloadExtra = { containerId: string; invokeImmediately: boolean; }; type TInteractivesActionChoiceEventPayload = T extends "chapter" ? ChapterEvent["action"]["args"] : T extends "container" ? ContainerEvent["action"]["args"] & Pick : ControlEvent["action"]["args"] & TControlPayloadExtra; type TSubjectTypeValues = T extends "chapter" ? undefined : T extends "container" ? ChapterContainer["type"] : Control["type"]; export type TInteractivesActionChoiceEvent = TInteractiveCommon & { subjectType?: TSubjectTypeValues; actionType: EventActionTypesValues; payload: TInteractivesActionChoiceEventPayload; }; export type TInteractivesContainerRemoved = TInteractiveCommon<"container", InteractivesEventTypes.CONTAINER_REMOVED>; export type TInteractivesContainerFakeRemoved = TInteractiveCommon<"container", InteractivesEventTypes.CONTAINER_FAKE_REMOVED> & { removeAllOpenURI: boolean; };