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A;AAAA,EAEA,WAAA,CAAY,KAAa,QAAmB,EAAA;AAC1C,IAAA,IAAA,CAAK,GAAM,GAAA,GAAA;AACX,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA;AAAA;AAEpB;AAyBO,MAAM,aAAwC,CAAA;AAAA;AAAA;AAAA;AAAA,EAInD,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,GAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA,EAEA,WAAA,CAAY,KAAe,EAAA,GAAA,EAAa,QAAkB,EAAA;AACxD,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAA,IAAA,CAAK,GAAM,GAAA,GAAA;AACX,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA;AAAA;AAEpB","file":"media.mjs","sourcesContent":["import { IElement, Element } from '../base';\n\n/**\n * Displays a media player for audio or video content.\n */\nexport interface IMedia extends IElement {\n  type: 'Media';\n\n  /**\n   * Array of media sources to attempt to play.\n   */\n  sources: IMediaSource[];\n\n  /**\n   * URL of an image to display before playing. Supports data URI in version 1.2+. If poster is omitted, the Media element will either use a default poster (controlled by the host application) or will attempt to automatically pull the poster from the target video service when the source URL points to a video from a Web provider such as YouTube.\n   */\n  poster?: string;\n\n  /**\n   * Alternate text describing the audio or video.\n   */\n  altText?: string;\n\n  /**\n   * Array of captions sources for the media element to provide.\n   */\n  captionSources?: ICaptionSource[];\n}\n\nexport type MediaOptions = Omit<IMedia, 'type' | 'sources'>;\n\n/**\n * Displays a media player for audio or video content.\n */\nexport class Media extends Element implements IMedia {\n  type: 'Media';\n\n  /**\n   * Array of media sources to attempt to play.\n   */\n  sources: IMediaSource[];\n\n  /**\n   * URL of an image to display before playing. Supports data URI in version 1.2+. If poster is omitted, the Media element will either use a default poster (controlled by the host application) or will attempt to automatically pull the poster from the target video service when the source URL points to a video from a Web provider such as YouTube.\n   */\n  poster?: string;\n\n  /**\n   * Alternate text describing the audio or video.\n   */\n  altText?: string;\n\n  /**\n   * Array of captions sources for the media element to provide.\n   */\n  captionSources?: ICaptionSource[];\n\n  constructor(...sources: IMediaSource[]) {\n    super();\n    this.type = 'Media';\n    this.sources = sources;\n  }\n\n  static from(options: Omit<IMedia, 'type'>) {\n    const media = new Media(...options.sources);\n    Object.assign(media, options);\n    return media;\n  }\n\n  withPoster(value: string) {\n    this.poster = value;\n    return this;\n  }\n\n  withAltText(value: string) {\n    this.altText = value;\n    return this;\n  }\n\n  addSources(...value: IMediaSource[]) {\n    this.sources.push(...value);\n    return this;\n  }\n\n  addCaptionSources(...value: ICaptionSource[]) {\n    if (!this.captionSources) {\n      this.captionSources = [];\n    }\n\n    this.captionSources.push(...value);\n    return this;\n  }\n}\n\n/**\n * Defines a source for a Media element\n */\nexport interface IMediaSource {\n  /**\n   * URL to media. Supports data URI in version 1.2+\n   */\n  url: string;\n\n  /**\n   * Mime type of associated media (e.g. \"video/mp4\"). For YouTube and other Web video URLs, mimeType can be omitted.\n   */\n  mimeType?: string;\n}\n\n/**\n * Defines a source for a Media element\n */\nexport class MediaSource implements IMediaSource {\n  /**\n   * URL to media. Supports data URI in version 1.2+\n   */\n  url: string;\n\n  /**\n   * Mime type of associated media (e.g. \"video/mp4\"). For YouTube and other Web video URLs, mimeType can be omitted.\n   */\n  mimeType?: string;\n\n  constructor(url: string, mimeType?: string) {\n    this.url = url;\n    this.mimeType = mimeType;\n  }\n}\n\n/**\n * Defines a source for captions\n */\nexport interface ICaptionSource {\n  /**\n   * Label of this caption to show to the user.\n   */\n  label: string;\n\n  /**\n   * URL to captions.\n   */\n  url: string;\n\n  /**\n   * Mime type of associated caption file (e.g. \"vtt\"). For rendering in JavaScript, only \"vtt\" is supported, for rendering in UWP, \"vtt\" and \"srt\" are supported.\n   */\n  mimeType: string;\n}\n\n/**\n * Defines a source for captions\n */\nexport class CaptionSource implements ICaptionSource {\n  /**\n   * Label of this caption to show to the user.\n   */\n  label: string;\n\n  /**\n   * URL to captions.\n   */\n  url: string;\n\n  /**\n   * Mime type of associated caption file (e.g. \"vtt\"). For rendering in JavaScript, only \"vtt\" is supported, for rendering in UWP, \"vtt\" and \"srt\" are supported.\n   */\n  mimeType: string;\n\n  constructor(label: string, url: string, mimeType: string) {\n    this.label = label;\n    this.url = url;\n    this.mimeType = mimeType;\n  }\n}\n"]}