// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { CatalogAtom } from '../scrabblefb/catalog-atom.js';


export class CatalogProduct {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):CatalogProduct {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsCatalogProduct(bb:flatbuffers.ByteBuffer, obj?:CatalogProduct):CatalogProduct {
  return (obj || new CatalogProduct()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsCatalogProduct(bb:flatbuffers.ByteBuffer, obj?:CatalogProduct):CatalogProduct {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new CatalogProduct()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

kind():string|null
kind(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
kind(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

productId():string|null
productId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
productId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

title():string|null
title(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
title(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

chips():number {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

moneyAmount():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

moneyCurrency():string|null
moneyCurrency(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
moneyCurrency(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

atoms(index: number, obj?:CatalogAtom):CatalogAtom|null {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? (obj || new CatalogAtom()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

atomsLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

static startCatalogProduct(builder:flatbuffers.Builder) {
  builder.startObject(7);
}

static addKind(builder:flatbuffers.Builder, kindOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, kindOffset, 0);
}

static addProductId(builder:flatbuffers.Builder, productIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, productIdOffset, 0);
}

static addTitle(builder:flatbuffers.Builder, titleOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, titleOffset, 0);
}

static addChips(builder:flatbuffers.Builder, chips:number) {
  builder.addFieldInt32(3, chips, 0);
}

static addMoneyAmount(builder:flatbuffers.Builder, moneyAmount:bigint) {
  builder.addFieldInt64(4, moneyAmount, BigInt('0'));
}

static addMoneyCurrency(builder:flatbuffers.Builder, moneyCurrencyOffset:flatbuffers.Offset) {
  builder.addFieldOffset(5, moneyCurrencyOffset, 0);
}

static addAtoms(builder:flatbuffers.Builder, atomsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(6, atomsOffset, 0);
}

static createAtomsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startAtomsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static endCatalogProduct(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createCatalogProduct(builder:flatbuffers.Builder, kindOffset:flatbuffers.Offset, productIdOffset:flatbuffers.Offset, titleOffset:flatbuffers.Offset, chips:number, moneyAmount:bigint, moneyCurrencyOffset:flatbuffers.Offset, atomsOffset:flatbuffers.Offset):flatbuffers.Offset {
  CatalogProduct.startCatalogProduct(builder);
  CatalogProduct.addKind(builder, kindOffset);
  CatalogProduct.addProductId(builder, productIdOffset);
  CatalogProduct.addTitle(builder, titleOffset);
  CatalogProduct.addChips(builder, chips);
  CatalogProduct.addMoneyAmount(builder, moneyAmount);
  CatalogProduct.addMoneyCurrency(builder, moneyCurrencyOffset);
  CatalogProduct.addAtoms(builder, atomsOffset);
  return CatalogProduct.endCatalogProduct(builder);
}
}
