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C,cAAc,IAAI,CAAA;AAElF,IAAA,IAAI,GAAK,EAAA;AACP,MAAM,MAAA,GAAA;AAAA;AACR;AAEJ","file":"media.mjs","sourcesContent":["import { ClientError } from '../client-error';\nimport { File } from '../types';\nimport { WindowClient } from '../window-client';\n\n/**\n * The modes in which camera can be launched in select Media API\n */\nexport enum CameraStartMode {\n  /** Photo mode. */\n  Photo = 1,\n\n  /** Document mode. */\n  Document = 2,\n\n  /** Whiteboard mode. */\n  Whiteboard = 3,\n\n  /** Business card mode. */\n  BusinessCard = 4,\n}\n\n/**\n * Specifies the image source\n */\nexport enum Source {\n  /** Image source is camera. */\n  Camera = 1,\n\n  /** Image source is gallery. */\n  Gallery = 2,\n}\n\n/**\n * Specifies the type of Media\n */\nexport enum MediaType {\n  /** Media type photo or image */\n  Image = 1,\n\n  /** Media type video. */\n  Video = 2,\n\n  /** Media type video and image. */\n  VideoAndImage = 3,\n\n  /** Media type audio. */\n  Audio = 4,\n}\n\n/**\n * Specifies the image output formats.\n */\nexport enum ImageOutputFormats {\n  /** Outputs image.  */\n  IMAGE = 1,\n\n  /** Outputs pdf. */\n  PDF = 2,\n}\n\n/**\n * Input for view images API\n */\nexport interface ImageUri {\n  /** Image location */\n  value: string;\n\n  /** Image Uri type */\n  type: ImageUriType;\n}\n\n/**\n * ID contains a mapping for content uri on platform's side, URL is generic\n */\nexport enum ImageUriType {\n  /** Image Id. */\n  ID = 1,\n\n  /** Image URL. */\n  URL = 2,\n}\n\n/**\n * Input parameter supplied to the select Media API\n */\nexport interface MediaInputs {\n  /**\n   * Only one media type can be selected at a time\n   */\n  mediaType: MediaType;\n\n  /**\n   * max limit of media allowed to be selected in one go, current max limit is 10 set by office lens.\n   */\n  maxMediaCount: number;\n\n  /**\n   * Additional properties for customization of select media - Image in mobile devices\n   */\n  imageProps?: ImageProps;\n\n  /**\n   * Additional properties for customization of select media - Video in mobile devices\n   */\n  videoProps?: VideoProps;\n\n  /**\n   * Additional properties for customization of select media - VideoAndImage in mobile devices\n   */\n  videoAndImageProps?: VideoAndImageProps;\n\n  /**\n   * Additional properties for audio capture flows.\n   */\n  audioProps?: AudioProps;\n}\n\n/**\n * @hidden\n * Hide from docs\n * --------\n * All properties common to Image and Video Props\n */\ninterface MediaProps {\n  /**\n   * Optional; Lets the developer specify the media source, more than one can be specified.\n   * Default value is both camera and gallery\n   */\n  sources?: Source[];\n\n  /**\n   * Optional; Specify in which mode the camera will be opened.\n   * Default value is Photo\n   */\n  startMode?: CameraStartMode;\n\n  /**\n   * Optional; indicate if user is allowed to move between front and back camera\n   * Default value is true\n   */\n  cameraSwitcher?: boolean;\n}\n\n/**\n *  All properties in ImageProps are optional and have default values in the platform\n */\nexport interface ImageProps extends MediaProps {\n  /**\n   * Optional; indicate if inking on the selected Image is allowed or not\n   * Default value is true\n   */\n  ink?: boolean;\n\n  /**\n   * Optional; indicate if putting text stickers on the selected Image is allowed or not\n   * Default value is true\n   */\n  textSticker?: boolean;\n\n  /**\n   * Optional; indicate if image filtering mode is enabled on the selected image\n   * Default value is false\n   */\n  enableFilter?: boolean;\n\n  /**\n   * Optional; Lets the developer specify the image output formats, more than one can be specified.\n   * Default value is Image.\n   */\n  imageOutputFormats?: ImageOutputFormats[];\n}\n\n/**\n * All properties in VideoProps are optional and have default values in the platform\n */\nexport interface VideoProps extends MediaProps {\n  /**\n   * Optional; the maximum duration in seconds after which the recording should terminate automatically.\n   * Default value is defined by the platform serving the API.\n   */\n  maxDuration?: number;\n\n  /**\n   * Optional; to determine if the video capturing flow needs to be launched\n   * in Full Screen Mode (Lens implementation) or PictureInPicture Mode (Native implementation).\n   * Default value is true, indicating video will always launch in Full Screen Mode via lens.\n   */\n  isFullScreenMode?: boolean;\n\n  /**\n   * Optional; controls the visibility of stop button in PictureInPicture Mode.\n   * Default value is true, indicating the user will be able to stop the video.\n   */\n  isStopButtonVisible?: boolean;\n}\n\n/**\n * All properties in VideoAndImageProps are optional and have default values in the platform\n */\nexport interface VideoAndImageProps extends ImageProps, VideoProps {}\n\n/**\n *  All properties in AudioProps are optional and have default values in the platform\n */\nexport interface AudioProps {\n  /**\n   * Optional; the maximum duration in minutes after which the recording should terminate automatically\n   * Default value is defined by the platform serving the API.\n   */\n  maxDuration?: number;\n}\n\nexport class MediaClient {\n  readonly window: WindowClient;\n\n  constructor(client: WindowClient) {\n    this.window = client;\n  }\n\n  async get(localUriId: string) {\n    const [err, res] = await this.window.send<[ClientError | undefined, blob: Blob]>(\n      'getMedia',\n      localUriId\n    );\n\n    if (err) {\n      throw err;\n    }\n\n    return res;\n  }\n\n  async select(inputs: MediaInputs) {\n    const [err, res] = await this.window.send<[ClientError | undefined, Array<File>]>(\n      'selectMedia',\n      inputs\n    );\n\n    if (err) {\n      throw err;\n    }\n\n    return res;\n  }\n\n  async captureImage() {\n    await this.window.send('media.captureImage');\n  }\n\n  async viewImages(uris: ImageUri[]) {\n    const [err] = await this.window.send<[ClientError | undefined]>('viewImages', uris);\n\n    if (err) {\n      throw err;\n    }\n  }\n}\n"]}