/**
 * @file TypeScript typings for ImageVault
 *
 * The types in this file are based on the source maps of the downloaded
 * distribution at https://clientscript.imagevault.se/Installation/ImageVaultInsertMedia
 *
 * They have been clean up and amended to.
 */

export type MetaData = {
  DefinitionType?: number
  Description: string | null
  LanguageId: null
  MetadataDefinitionId: number
  Name: string
  Value: string
}

export type ImageVaultAsset = {
  id: number
  title: string
  url: string
  dimensions: {
    width: number
    height: number
    aspectRatio: number
  }
  meta: { alt: string | undefined; caption: string | undefined }
}

/**
 * The response from ImageVault when inserting an asset
 */
export declare class InsertResponse {
  /**
   * The media item id of the asset
   */
  Id: number
  /**
   * The id of the vault where the asset resides
   */
  VaultId: number
  /**
   * The name of the asset
   */
  Name: string
  /**
   * The conversion selected by the user. Is an array but will only contain one object
   */
  MediaConversions: MediaConversion[]
  /**
   * Date when the asset was added to ImageVault
   */
  DateAdded: string
  /**
   * Name of the user that added the asset to ImageVault
   */
  AddedBy: string

  Metadata?: MetaData[] | undefined
}

/**
 * Defines a media asset, original or conversion
 */
export declare class MediaConversion {
  /**
   * The url to the conversion
   */
  Url: string
  /**
   * Name of the conversion
   */
  Name: string
  /**
   * Html representing the conversion
   */
  Html: string
  /**
   * Content type of the conversion
   */
  ContentType: string
  /**
   * Width, in pixels, of the conversion
   */
  Width: number
  /**
   * Height, in pixels, of the conversion
   */
  Height: number
  /**
   * Aspect ratio of the conversion
   */
  AspectRatio: number
  /**
   * Width of the selected/requested format
   */
  FormatWidth: number
  /**
   * Height of the selected/requested format
   */
  FormatHeight: number
  /**
   * Aspect ratio of the selected/requested format
   */
  FormatAspectRatio: number
  /**
   * Name of the media format
   */
  MediaFormatName: string
  /**
   * Id of the selected media format
   */
  MediaFormatId: number
}
