import type { ApiManager } from '../../../framework-types/api-manager/ApiManager';
import type { EmptyObject } from '../../../framework-types/BaseTypes';
import type { LogLevel } from '../../../framework-types/effects/LoggerEffect';
import type { ContextHaving } from '../../../framework-types/execution-context/Types';
import type { BundleExportNames, PlayerConfig } from '../../bundles/Types';
import type { Constants, LoadControl } from '../core/Constants';
import type { MapStateAtom } from '../core/state/MapStateAtom';
import type { CoreEffects, CoreExportNames, CoreStateAtoms } from '../core/Types';
import type { CoreUtils } from '../core/utils/Types';
import type { createEventBus, extendEventBusTypes } from '../event-bus/EventBus';
import type { EventBus, EventBusExportNames } from '../event-bus/Types';
import type { PlayerApiExportNames } from '../player-api/Types';
import type { SourceConfig } from '../source/atoms/SourceConfigAtom';
import type { CreateSourceStateAtom, SourceOptions } from '../source/atoms/SourceStateAtom';
import type { createSourceReference } from '../source/SourceReference';
import type { SourceExportNames, SourceReference, SourceReferences } from '../source/Types';
import type { StreamDataStructurePackageExports } from '../stream-data-structure/Types';
import type { StreamingPackageExports } from '../streaming/Types';
import type { ContextWithState } from '../Types';
import type { SourceRemovedError } from './SourceRemovedError';
import type VideoElementUtils from './VideoElementUtils';
export interface SourcesApiObject<SourceApi extends EmptyObject> {
    list(): SourceApi[];
    add(config: SourceConfig, options?: SourceOptionsWithAttach, insertAt?: number): SourceApi;
    remove(source: SourceApi): void;
    attachVideo(source: SourceApi, options?: AttachOptions): void;
    detachVideo(source: SourceApi): void;
}
export type SourceOptionsWithAttach = Partial<SourceOptions> & {
    attach?: boolean | AttachOptions;
};
export interface AttachOptions {
        video?: HTMLVideoElement;
        container?: HTMLElement;
}
export declare enum SourcesApiEvent {
    SourceAdded = "source-added",
    SourceRemoved = "source-removed",
    VideoAttached = "video-attached",
    VideoDetached = "video-detached",
    SourceError = "source-error"
}
export type SourcesApiEventMap = {
    [SourcesApiEvent.SourceAdded]: SourceAddedEvent;
    [SourcesApiEvent.SourceRemoved]: SourceRemovedEvent;
    [SourcesApiEvent.VideoAttached]: VideoAttachedEvent;
    [SourcesApiEvent.VideoDetached]: VideoDetachedEvent;
    [SourcesApiEvent.SourceError]: SourceErrorEvent;
};
export type SourceApiComponents = {
    apiManager: ApiManager<SourceApiBase>;
    eventBus: EventBus<EmptyObject>;
};
export type SourceApiComponentMap = MapStateAtom<SourceReference, SourceApiComponents>;
export type SourcesApiContext = ContextHaving<SourcesApiDependencies, SourcesApiExports, ContextWithState>;
export type VideoAttachedEvent = {
    videoElement: HTMLVideoElement;
    sourceId: string;
};
export type VideoDetachedEvent = {
    videoElement: HTMLVideoElement;
    sourceId: string;
};
export type SourceAddedEvent = {
    sourceId: string;
    sourceConfig: SourceConfig;
    sourceOptions?: Partial<SourceOptions>;
};
export type SourceRemovedEvent = {
    sourceId: string;
    sourceConfig: SourceConfig;
};
export type SourceErrorEvent = {
    sourceId: string;
    sourceConfig: SourceConfig;
    error: Error;
};
export type SourcesApi<SourceApi extends EmptyObject> = {
    events: EventBus<SourcesApiEventMap, typeof SourcesApiEvent>;
    sources: SourcesApiObject<SourceApi>;
};
export interface SourceApiBase {
    logLevel: LogLevel;
    loadControl: LoadControl;
    readonly id: string;
    readonly events: EventBus<EmptyObject>;
    readonly video: HTMLVideoElement | undefined;
    readonly container: HTMLElement | undefined;
    readonly attached: boolean;
}
export type SourcesApiDependencies = {
    [CoreExportNames.Utils]: CoreUtils;
    [CoreExportNames.CoreEffects]: CoreEffects;
    [CoreExportNames.CoreStateAtoms]: CoreStateAtoms;
    [CoreExportNames.Constants]: Constants;
    [BundleExportNames.PlayerConfig]: PlayerConfig;
    [SourceExportNames.CreateSourceStateAtom]: CreateSourceStateAtom;
    [SourceExportNames.CreateSourceReference]: typeof createSourceReference;
    [SourceExportNames.SourceReferences]: SourceReferences;
    [EventBusExportNames.CreateEventBus]: typeof createEventBus;
    [EventBusExportNames.ExtendEventBusTypes]: typeof extendEventBusTypes;
    [PlayerApiExportNames.PlayerEventBus]: EventBus<SourcesApiEventMap>;
} & StreamDataStructurePackageExports & StreamingPackageExports;
export declare enum SourcesApiExportNames {
    SourceApiManager = "source-api-manager",
    VideoElementUtils = "video-element-utils",
    SourceEventBus = "source-event-bus",
    SourceApiComponentMap = "source-api-component-map",
    SourceRemovedError = "source-removed-error"
}
export type SourcesApiExports = {
    [SourcesApiExportNames.SourceApiManager]: ApiManager<SourceApiBase>;
    [SourcesApiExportNames.VideoElementUtils]: typeof VideoElementUtils;
    [SourcesApiExportNames.SourceEventBus]: EventBus<EmptyObject>;
    [SourcesApiExportNames.SourceApiComponentMap]: SourceApiComponentMap;
    [SourcesApiExportNames.SourceRemovedError]: typeof SourceRemovedError;
};
