import type { Player, PlayerOptions } from '@glomex/vast-ima-player'
import type FirePlayer from 'fireplayer'

declare global {
  interface Window {
    fireplayerPluginVast?: typeof fireplayerPluginVast
  }
}

type PlayUrlFn = (url: string, config?: any) => void
type PlayResFn = (res: string, config?: any) => void

interface VastPluginContext {
  fire: FirePlayer
  ima: any
  imaPlayer: Player | null
  playUrl: PlayUrlFn
  playRes: PlayResFn
  init: () => Player
  adsRenderingSettings: any
  playerOptions: PlayerOptions
  container: HTMLDivElement | null
}

export type FirePlayerPluginVastOption = (params: VastPluginContext) => void | Promise<void>

export interface FirePlayerPluginVastInstance {
  name: 'fireplayerPluginVast'
  destroy?: () => void
}

declare function fireplayerPluginVast(
  option: FirePlayerPluginVastOption,
): (fire: FirePlayer) => FirePlayerPluginVastInstance

export default fireplayerPluginVast
