/// Indicates a format's color space.
///
/// #### The following colorspaces are available on iOS:
/// * `srgb`: The sGRB color space.
/// * `p3d65`: The P3 D65 wide color space which uses Illuminant D65 as the white point
/// * `hlgBt2020`: The BT2020 wide color space which uses Illuminant D65 as the white point and Hybrid Log-Gamma as the transfer function
///
/// > See ["AVCaptureColorSpace"](https://developer.apple.com/documentation/avfoundation/avcapturecolorspace) for more information.
///
/// #### The following colorspaces are available on Android:
/// * `yuv`: The Multi-plane Android YCbCr color space. (YUV 420_888, 422_888 or 444_888)
/// * `jpeg`: The compressed JPEG color space.
/// * `jpegDepth`: The compressed JPEG color space including depth data.
/// * `raw`: The Camera's RAW sensor color space. (Single-channel Bayer-mosaic image, usually 16 bit)
/// * `heic`: The compressed HEIC color space.
/// * `private`: The Android private opaque image format. (The choices of the actual format and pixel data layout are entirely up to the device-specific and framework internal implementations, and may vary depending on use cases even for the same device. These buffers are not directly accessible to the application)
/// * `depth16`: The Android dense depth image format (16 bit)
/// * `unknown`: Placeholder for an unknown image/pixel format. [Edit this file](https://github.com/mrousavy/react-native-vision-camera/edit/main/android/src/main/java/com/mrousavy/camera/parsers/ImageFormat+String.kt) to add a name for the unknown format.
///
/// > See ["Android Color Formats"](https://jbit.net/Android_Colors/) for more information.
enum ColorSpace {
  // ios
  hlgBt2020,
  p3d65,
  srgb,
  // android
  yuv,
  jpeg,
  jpegDepth,
  raw,
  heic,
  private,
  depth16,
  unknown
}

ColorSpace colorSpaceFromString(String? string) {
  if (string == null) {
    return ColorSpace.unknown;
  }
  switch (string) {
    // ios
    case 'hlg-bt2020':
      return ColorSpace.hlgBt2020;
    case 'p3-d65':
      return ColorSpace.p3d65;
    case 'srgb':
      return ColorSpace.srgb;
    // android
    case 'yuv':
      return ColorSpace.yuv;
    case 'jpeg':
      return ColorSpace.jpeg;
    case 'jpeg-depth':
      return ColorSpace.jpegDepth;
    case 'raw':
      return ColorSpace.raw;
    case 'heic':
      return ColorSpace.heic;
    case 'private':
      return ColorSpace.private;
    case 'depth-16':
      return ColorSpace.depth16;
    case 'unknown':
    default:
      return ColorSpace.unknown;
  }
}
