import type { JSONSupport } from "../../../core/JSONSupport.js";
import type { ExifInfo } from "../../../layers/support/types.js";
import type { ObjectId } from "../../../views/types.js";

export interface AttachmentInfoProperties extends Partial<Pick<AttachmentInfo, "contentType" | "exifInfo" | "globalId" | "id" | "keywords" | "name" | "parentGlobalId" | "parentObjectId" | "size" | "url">> {}

/**
 * An object containing properties specific to the orientation of an image attachment.
 * This information is stored within the attachment's [exifInfo](https://developers.arcgis.com/javascript/latest/references/core/rest/query/support/AttachmentInfo/#exifInfo).
 * In order to read this, you must first set the attachment query's [AttachmentQuery.returnMetadata](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttachmentQuery/#returnMetadata)
 * to `true` to get the `exif` info associated with the attachment.
 */
export interface OrientationInfo {
  /** The identifier for the orientation info. */
  id: number;
  /** The rotation value for the attached image. */
  rotation: number;
  /** Indicates whether the image displays mirrored. */
  mirrored: boolean;
}

/**
 * The `AttachmentInfo` class returns information about attachments associated with a
 * feature. The contents of the attachment are streamed to the client.
 * Attachments are available if the [FeatureLayer.capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities)
 * is `true`.
 *
 * ![popuptemplate-attachments-element-list](https://developers.arcgis.com/javascript/latest/assets/references/core/widgets/popup/popuptemplate-attachments-element-list.png)
 *
 * @since 4.19
 * @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/)
 * @see [AttachmentsContent](https://developers.arcgis.com/javascript/latest/references/core/popup/content/AttachmentsContent/)
 * @see [Sample - Multiple popup elements](https://developers.arcgis.com/javascript/latest/sample-code/popup-multipleelements/)
 */
export default class AttachmentInfo extends JSONSupport {
  constructor(properties?: AttachmentInfoProperties);
  /**
   * The content type of the attachment. For example, `'image/jpeg'`.
   * See the [ArcGIS REST API documentation](https://developers.arcgis.com/rest/services-reference/query-attachments-feature-service-layer-.htm)
   * for more information on supported attachment types.
   */
  accessor contentType: string;
  /** An array of [ExifInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/support/types/#ExifInfo) for the attachment. */
  accessor exifInfo: ExifInfo[] | null | undefined;
  /** The global identifier for the attachment. */
  accessor globalId: string;
  /** The identifier for the attachment. */
  accessor id: number;
  /** Keywords used for the attachments. */
  accessor keywords: string;
  /** String value indicating the name of the file attachment. */
  accessor name: string;
  /**
   * The [OrientationInfo](https://developers.arcgis.com/javascript/latest/references/core/rest/query/support/AttachmentInfo/#OrientationInfo) for the attachment.
   * This is derived from the [exifInfo](https://developers.arcgis.com/javascript/latest/references/core/rest/query/support/AttachmentInfo/#exifInfo).
   * In order to read this, you must first set the attachment query's [AttachmentQuery.returnMetadata](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttachmentQuery/#returnMetadata)
   * to `true` to get the `exif` info associated with the attachment.
   */
  get orientationInfo(): OrientationInfo;
  /** The parent or the feature global id of the attachment. */
  accessor parentGlobalId: string | null | undefined;
  /** The parent or the feature object id of the attachment. */
  accessor parentObjectId: ObjectId | null | undefined;
  /** The file size of the attachment. This is specified in bytes. */
  accessor size: number;
  /** The URL of the attachment. */
  accessor url: string | null | undefined;
  /**
   * Creates a deep clone of the AttachmentInfo class.
   *
   * @returns A deep clone of the AttachmentInfo instance.
   */
  clone(): AttachmentInfo;
}