// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all

import FlatBuffers

public enum zzz_DflatGen_ModelMixingMode: Int8, Enum, Verifiable {
  public typealias T = Int8
  public static var byteSize: Int { return MemoryLayout<Int8>.size }
  public var value: Int8 { return self.rawValue }
  case weightedsum = 0
  case adddifference = 1
  case freeform = 2

  public static var max: zzz_DflatGen_ModelMixingMode { return .freeform }
  public static var min: zzz_DflatGen_ModelMixingMode { return .weightedsum }
}

public struct zzz_DflatGen_ModelMixingItem: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_22_9_29() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  public static func getRootAsModelMixingItem(bb: ByteBuffer) -> zzz_DflatGen_ModelMixingItem {
    return zzz_DflatGen_ModelMixingItem(
      Table(
        bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))
    )
  }

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case name = 4
    case weight = 6
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var name: String? {
    let o = _accessor.offset(VTOFFSET.name.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
  public var weight: Float32 {
    let o = _accessor.offset(VTOFFSET.weight.v)
    return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public static func startModelMixingItem(_ fbb: inout FlatBufferBuilder) -> UOffset {
    fbb.startTable(with: 2)
  }
  public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: name, at: VTOFFSET.name.p)
  }
  public static func add(weight: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: weight, def: 0.0, at: VTOFFSET.weight.p)
  }
  public static func endModelMixingItem(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset {
    let end = Offset(offset: fbb.endTable(at: start))
    return end
  }
  public static func createModelMixingItem(
    _ fbb: inout FlatBufferBuilder,
    nameOffset name: Offset = Offset(),
    weight: Float32 = 0.0
  ) -> Offset {
    let __start = zzz_DflatGen_ModelMixingItem.startModelMixingItem(&fbb)
    zzz_DflatGen_ModelMixingItem.add(name: name, &fbb)
    zzz_DflatGen_ModelMixingItem.add(weight: weight, &fbb)
    return zzz_DflatGen_ModelMixingItem.endModelMixingItem(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws
  where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(
      field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
    try _v.visit(field: VTOFFSET.weight.p, fieldName: "weight", required: false, type: Float32.self)
    _v.finish()
  }
}

public struct zzz_DflatGen_ModelMixingLoRA: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_22_9_29() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  public static func getRootAsModelMixingLoRA(bb: ByteBuffer) -> zzz_DflatGen_ModelMixingLoRA {
    return zzz_DflatGen_ModelMixingLoRA(
      Table(
        bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))
    )
  }

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case file = 4
    case weight = 6
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var file: String? {
    let o = _accessor.offset(VTOFFSET.file.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var fileSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.file.v) }
  public var weight: Float32 {
    let o = _accessor.offset(VTOFFSET.weight.v)
    return o == 0 ? 0.6 : _accessor.readBuffer(of: Float32.self, at: o)
  }
  public static func startModelMixingLoRA(_ fbb: inout FlatBufferBuilder) -> UOffset {
    fbb.startTable(with: 2)
  }
  public static func add(file: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: file, at: VTOFFSET.file.p)
  }
  public static func add(weight: Float32, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: weight, def: 0.6, at: VTOFFSET.weight.p)
  }
  public static func endModelMixingLoRA(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset {
    let end = Offset(offset: fbb.endTable(at: start))
    return end
  }
  public static func createModelMixingLoRA(
    _ fbb: inout FlatBufferBuilder,
    fileOffset file: Offset = Offset(),
    weight: Float32 = 0.6
  ) -> Offset {
    let __start = zzz_DflatGen_ModelMixingLoRA.startModelMixingLoRA(&fbb)
    zzz_DflatGen_ModelMixingLoRA.add(file: file, &fbb)
    zzz_DflatGen_ModelMixingLoRA.add(weight: weight, &fbb)
    return zzz_DflatGen_ModelMixingLoRA.endModelMixingLoRA(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws
  where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(
      field: VTOFFSET.file.p, fieldName: "file", required: false, type: ForwardOffset<String>.self)
    try _v.visit(field: VTOFFSET.weight.p, fieldName: "weight", required: false, type: Float32.self)
    _v.finish()
  }
}

public struct zzz_DflatGen_ModelMixingMetadata: FlatBufferObject, Verifiable {

  static func validateVersion() { FlatBuffersVersion_22_9_29() }
  public var __buffer: ByteBuffer! { return _accessor.bb }
  private var _accessor: Table

  public static func getRootAsModelMixingMetadata(bb: ByteBuffer)
    -> zzz_DflatGen_ModelMixingMetadata
  {
    return zzz_DflatGen_ModelMixingMetadata(
      Table(
        bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))
    )
  }

  private init(_ t: Table) { _accessor = t }
  public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }

  private enum VTOFFSET: VOffset {
    case name = 4
    case triggerWord = 6
    case vPrediction = 8
    case upcastAttention = 10
    case mode = 12
    case items = 14
    case note = 16
    case encoder = 18
    case decoder = 20
    case loras = 22
    var v: Int32 { Int32(self.rawValue) }
    var p: VOffset { self.rawValue }
  }

  public var name: String? {
    let o = _accessor.offset(VTOFFSET.name.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
  public var triggerWord: String? {
    let o = _accessor.offset(VTOFFSET.triggerWord.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var triggerWordSegmentArray: [UInt8]? {
    return _accessor.getVector(at: VTOFFSET.triggerWord.v)
  }
  public var vPrediction: Bool {
    let o = _accessor.offset(VTOFFSET.vPrediction.v)
    return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o)
  }
  public var upcastAttention: Bool {
    let o = _accessor.offset(VTOFFSET.upcastAttention.v)
    return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o)
  }
  public var mode: zzz_DflatGen_ModelMixingMode {
    let o = _accessor.offset(VTOFFSET.mode.v)
    return o == 0
      ? .weightedsum
      : zzz_DflatGen_ModelMixingMode(rawValue: _accessor.readBuffer(of: Int8.self, at: o))
        ?? .weightedsum
  }
  public var hasItems: Bool {
    let o = _accessor.offset(VTOFFSET.items.v)
    return o == 0 ? false : true
  }
  public var itemsCount: Int32 {
    let o = _accessor.offset(VTOFFSET.items.v)
    return o == 0 ? 0 : _accessor.vector(count: o)
  }
  public func items(at index: Int32) -> zzz_DflatGen_ModelMixingItem? {
    let o = _accessor.offset(VTOFFSET.items.v)
    return o == 0
      ? nil
      : zzz_DflatGen_ModelMixingItem(
        _accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4))
  }
  public var note: String? {
    let o = _accessor.offset(VTOFFSET.note.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var noteSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.note.v) }
  public var encoder: String? {
    let o = _accessor.offset(VTOFFSET.encoder.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var encoderSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.encoder.v) }
  public var decoder: String? {
    let o = _accessor.offset(VTOFFSET.decoder.v)
    return o == 0 ? nil : _accessor.string(at: o)
  }
  public var decoderSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.decoder.v) }
  public var hasLoras: Bool {
    let o = _accessor.offset(VTOFFSET.loras.v)
    return o == 0 ? false : true
  }
  public var lorasCount: Int32 {
    let o = _accessor.offset(VTOFFSET.loras.v)
    return o == 0 ? 0 : _accessor.vector(count: o)
  }
  public func loras(at index: Int32) -> zzz_DflatGen_ModelMixingLoRA? {
    let o = _accessor.offset(VTOFFSET.loras.v)
    return o == 0
      ? nil
      : zzz_DflatGen_ModelMixingLoRA(
        _accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4))
  }
  public static func startModelMixingMetadata(_ fbb: inout FlatBufferBuilder) -> UOffset {
    fbb.startTable(with: 10)
  }
  public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: name, at: VTOFFSET.name.p)
  }
  public static func add(triggerWord: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: triggerWord, at: VTOFFSET.triggerWord.p)
  }
  public static func add(vPrediction: Bool, _ fbb: inout FlatBufferBuilder) {
    fbb.add(
      element: vPrediction, def: false,
      at: VTOFFSET.vPrediction.p)
  }
  public static func add(upcastAttention: Bool, _ fbb: inout FlatBufferBuilder) {
    fbb.add(
      element: upcastAttention, def: false,
      at: VTOFFSET.upcastAttention.p)
  }
  public static func add(mode: zzz_DflatGen_ModelMixingMode, _ fbb: inout FlatBufferBuilder) {
    fbb.add(element: mode.rawValue, def: 0, at: VTOFFSET.mode.p)
  }
  public static func addVectorOf(items: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: items, at: VTOFFSET.items.p)
  }
  public static func add(note: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: note, at: VTOFFSET.note.p)
  }
  public static func add(encoder: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: encoder, at: VTOFFSET.encoder.p)
  }
  public static func add(decoder: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: decoder, at: VTOFFSET.decoder.p)
  }
  public static func addVectorOf(loras: Offset, _ fbb: inout FlatBufferBuilder) {
    fbb.add(offset: loras, at: VTOFFSET.loras.p)
  }
  public static func endModelMixingMetadata(_ fbb: inout FlatBufferBuilder, start: UOffset)
    -> Offset
  {
    let end = Offset(offset: fbb.endTable(at: start))
    return end
  }
  public static func createModelMixingMetadata(
    _ fbb: inout FlatBufferBuilder,
    nameOffset name: Offset = Offset(),
    triggerWordOffset triggerWord: Offset = Offset(),
    vPrediction: Bool = false,
    upcastAttention: Bool = false,
    mode: zzz_DflatGen_ModelMixingMode = .weightedsum,
    itemsVectorOffset items: Offset = Offset(),
    noteOffset note: Offset = Offset(),
    encoderOffset encoder: Offset = Offset(),
    decoderOffset decoder: Offset = Offset(),
    lorasVectorOffset loras: Offset = Offset()
  ) -> Offset {
    let __start = zzz_DflatGen_ModelMixingMetadata.startModelMixingMetadata(&fbb)
    zzz_DflatGen_ModelMixingMetadata.add(name: name, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(triggerWord: triggerWord, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(vPrediction: vPrediction, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(upcastAttention: upcastAttention, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(mode: mode, &fbb)
    zzz_DflatGen_ModelMixingMetadata.addVectorOf(items: items, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(note: note, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(encoder: encoder, &fbb)
    zzz_DflatGen_ModelMixingMetadata.add(decoder: decoder, &fbb)
    zzz_DflatGen_ModelMixingMetadata.addVectorOf(loras: loras, &fbb)
    return zzz_DflatGen_ModelMixingMetadata.endModelMixingMetadata(&fbb, start: __start)
  }

  public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws
  where T: Verifiable {
    var _v = try verifier.visitTable(at: position)
    try _v.visit(
      field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
    try _v.visit(
      field: VTOFFSET.triggerWord.p, fieldName: "triggerWord", required: false,
      type: ForwardOffset<String>.self)
    try _v.visit(
      field: VTOFFSET.vPrediction.p, fieldName: "vPrediction", required: false, type: Bool.self)
    try _v.visit(
      field: VTOFFSET.upcastAttention.p, fieldName: "upcastAttention", required: false,
      type: Bool.self)
    try _v.visit(
      field: VTOFFSET.mode.p, fieldName: "mode", required: false,
      type: zzz_DflatGen_ModelMixingMode.self)
    try _v.visit(
      field: VTOFFSET.items.p, fieldName: "items", required: false,
      type: ForwardOffset<
        Vector<ForwardOffset<zzz_DflatGen_ModelMixingItem>, zzz_DflatGen_ModelMixingItem>
      >.self)
    try _v.visit(
      field: VTOFFSET.note.p, fieldName: "note", required: false, type: ForwardOffset<String>.self)
    try _v.visit(
      field: VTOFFSET.encoder.p, fieldName: "encoder", required: false,
      type: ForwardOffset<String>.self)
    try _v.visit(
      field: VTOFFSET.decoder.p, fieldName: "decoder", required: false,
      type: ForwardOffset<String>.self)
    try _v.visit(
      field: VTOFFSET.loras.p, fieldName: "loras", required: false,
      type: ForwardOffset<
        Vector<ForwardOffset<zzz_DflatGen_ModelMixingLoRA>, zzz_DflatGen_ModelMixingLoRA>
      >.self)
    _v.finish()
  }
}
