///
/// HybridImageSpec.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

import NitroModules

/// See ``HybridImageSpec``
public protocol HybridImageSpec_protocol: HybridObject {
  // Properties
  var width: Double { get }
  var height: Double { get }

  // Methods
  func toRawPixelData(allowGpu: Bool?) throws -> RawPixelData
  func toRawPixelDataAsync(allowGpu: Bool?) throws -> Promise<RawPixelData>
  func toEncodedImageData(format: ImageFormat, quality: Double?) throws -> EncodedImageData
  func toEncodedImageDataAsync(format: ImageFormat, quality: Double?) throws -> Promise<EncodedImageData>
  func resize(width: Double, height: Double) throws -> (any HybridImageSpec)
  func resizeAsync(width: Double, height: Double) throws -> Promise<(any HybridImageSpec)>
  func rotate(degrees: Double, allowFastFlagRotation: Bool?) throws -> (any HybridImageSpec)
  func rotateAsync(degrees: Double, allowFastFlagRotation: Bool?) throws -> Promise<(any HybridImageSpec)>
  func crop(startX: Double, startY: Double, endX: Double, endY: Double) throws -> (any HybridImageSpec)
  func cropAsync(startX: Double, startY: Double, endX: Double, endY: Double) throws -> Promise<(any HybridImageSpec)>
  func mirrorHorizontally() throws -> (any HybridImageSpec)
  func mirrorHorizontallyAsync() throws -> Promise<(any HybridImageSpec)>
  func saveToFileAsync(path: String, format: ImageFormat, quality: Double?) throws -> Promise<Void>
  func saveToTemporaryFileAsync(format: ImageFormat, quality: Double?) throws -> Promise<String>
  func toThumbHash() throws -> ArrayBuffer
  func toThumbHashAsync() throws -> Promise<ArrayBuffer>
  func renderInto(image: (any HybridImageSpec), x: Double, y: Double, width: Double, height: Double) throws -> (any HybridImageSpec)
  func renderIntoAsync(image: (any HybridImageSpec), x: Double, y: Double, width: Double, height: Double) throws -> Promise<(any HybridImageSpec)>
}

public extension HybridImageSpec_protocol {
  /// Default implementation of ``HybridObject.toString``
  func toString() -> String {
    return "[HybridObject Image]"
  }
}

/// See ``HybridImageSpec``
open class HybridImageSpec_base {
  private weak var cxxWrapper: HybridImageSpec_cxx? = nil
  public init() { }
  public func getCxxWrapper() -> HybridImageSpec_cxx {
  #if DEBUG
    guard self is any HybridImageSpec else {
      fatalError("`self` is not a `HybridImageSpec`! Did you accidentally inherit from `HybridImageSpec_base` instead of `HybridImageSpec`?")
    }
  #endif
    if let cxxWrapper = self.cxxWrapper {
      return cxxWrapper
    } else {
      let cxxWrapper = HybridImageSpec_cxx(self as! any HybridImageSpec)
      self.cxxWrapper = cxxWrapper
      return cxxWrapper
    }
  }
}

/**
 * A Swift base-protocol representing the Image HybridObject.
 * Implement this protocol to create Swift-based instances of Image.
 * ```swift
 * class HybridImage : HybridImageSpec {
 *   // ...
 * }
 * ```
 */
public typealias HybridImageSpec = HybridImageSpec_protocol & HybridImageSpec_base
