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

import NitroModules

/**
 * Represents an instance of `NativeVideoConfig`, backed by a C++ struct.
 */
public typealias NativeVideoConfig = margelo.nitro.video.NativeVideoConfig

public extension NativeVideoConfig {
  private typealias bridge = margelo.nitro.video.bridge.swift

  /**
   * Create a new instance of `NativeVideoConfig`.
   */
  init(uri: String, externalSubtitles: [NativeExternalSubtitle]?, drm: NativeDrmParams?, headers: Dictionary<String, String>?, bufferConfig: BufferConfig?, initializeOnCreation: Bool?) {
    self.init(std.string(uri), { () -> bridge.std__optional_std__vector_NativeExternalSubtitle__ in
      if let __unwrappedValue = externalSubtitles {
        return bridge.create_std__optional_std__vector_NativeExternalSubtitle__({ () -> bridge.std__vector_NativeExternalSubtitle_ in
          var __vector = bridge.create_std__vector_NativeExternalSubtitle_(__unwrappedValue.count)
          for __item in __unwrappedValue {
            __vector.push_back(__item)
          }
          return __vector
        }())
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_NativeDrmParams_ in
      if let __unwrappedValue = drm {
        return bridge.create_std__optional_NativeDrmParams_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_std__unordered_map_std__string__std__string__ in
      if let __unwrappedValue = headers {
        return bridge.create_std__optional_std__unordered_map_std__string__std__string__({ () -> bridge.std__unordered_map_std__string__std__string_ in
          var __map = bridge.create_std__unordered_map_std__string__std__string_(__unwrappedValue.count)
          for (__k, __v) in __unwrappedValue {
            bridge.emplace_std__unordered_map_std__string__std__string_(&__map, std.string(__k), std.string(__v))
          }
          return __map
        }())
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_BufferConfig_ in
      if let __unwrappedValue = bufferConfig {
        return bridge.create_std__optional_BufferConfig_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_bool_ in
      if let __unwrappedValue = initializeOnCreation {
        return bridge.create_std__optional_bool_(__unwrappedValue)
      } else {
        return .init()
      }
    }())
  }

  var uri: String {
    @inline(__always)
    get {
      return String(self.__uri)
    }
    @inline(__always)
    set {
      self.__uri = std.string(newValue)
    }
  }
  
  var externalSubtitles: [NativeExternalSubtitle]? {
    @inline(__always)
    get {
      return { () -> [NativeExternalSubtitle]? in
        if let __unwrapped = self.__externalSubtitles.value {
          return __unwrapped.map({ __item in __item })
        } else {
          return nil
        }
      }()
    }
    @inline(__always)
    set {
      self.__externalSubtitles = { () -> bridge.std__optional_std__vector_NativeExternalSubtitle__ in
        if let __unwrappedValue = newValue {
          return bridge.create_std__optional_std__vector_NativeExternalSubtitle__({ () -> bridge.std__vector_NativeExternalSubtitle_ in
            var __vector = bridge.create_std__vector_NativeExternalSubtitle_(__unwrappedValue.count)
            for __item in __unwrappedValue {
              __vector.push_back(__item)
            }
            return __vector
          }())
        } else {
          return .init()
        }
      }()
    }
  }
  
  var drm: NativeDrmParams? {
    @inline(__always)
    get {
      return { () -> NativeDrmParams? in
        if let __unwrapped = self.__drm.value {
          return __unwrapped
        } else {
          return nil
        }
      }()
    }
    @inline(__always)
    set {
      self.__drm = { () -> bridge.std__optional_NativeDrmParams_ in
        if let __unwrappedValue = newValue {
          return bridge.create_std__optional_NativeDrmParams_(__unwrappedValue)
        } else {
          return .init()
        }
      }()
    }
  }
  
  var headers: Dictionary<String, String>? {
    @inline(__always)
    get {
      return { () -> Dictionary<String, String>? in
        if let __unwrapped = self.__headers.value {
          return { () -> Dictionary<String, String> in
            var __dictionary = Dictionary<String, String>(minimumCapacity: __unwrapped.size())
            let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(__unwrapped)
            for __key in __keys {
              let __value = bridge.get_std__unordered_map_std__string__std__string__value(__unwrapped, __key)
              __dictionary[String(__key)] = String(__value)
            }
            return __dictionary
          }()
        } else {
          return nil
        }
      }()
    }
    @inline(__always)
    set {
      self.__headers = { () -> bridge.std__optional_std__unordered_map_std__string__std__string__ in
        if let __unwrappedValue = newValue {
          return bridge.create_std__optional_std__unordered_map_std__string__std__string__({ () -> bridge.std__unordered_map_std__string__std__string_ in
            var __map = bridge.create_std__unordered_map_std__string__std__string_(__unwrappedValue.count)
            for (__k, __v) in __unwrappedValue {
              bridge.emplace_std__unordered_map_std__string__std__string_(&__map, std.string(__k), std.string(__v))
            }
            return __map
          }())
        } else {
          return .init()
        }
      }()
    }
  }
  
  var bufferConfig: BufferConfig? {
    @inline(__always)
    get {
      return { () -> BufferConfig? in
        if let __unwrapped = self.__bufferConfig.value {
          return __unwrapped
        } else {
          return nil
        }
      }()
    }
    @inline(__always)
    set {
      self.__bufferConfig = { () -> bridge.std__optional_BufferConfig_ in
        if let __unwrappedValue = newValue {
          return bridge.create_std__optional_BufferConfig_(__unwrappedValue)
        } else {
          return .init()
        }
      }()
    }
  }
  
  var initializeOnCreation: Bool? {
    @inline(__always)
    get {
      return self.__initializeOnCreation.value
    }
    @inline(__always)
    set {
      self.__initializeOnCreation = { () -> bridge.std__optional_bool_ in
        if let __unwrappedValue = newValue {
          return bridge.create_std__optional_bool_(__unwrappedValue)
        } else {
          return .init()
        }
      }()
    }
  }
}
