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

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { ActiveLimit, ActiveLimitT } from '../user/active-limit.js';
import { ActiveSanction, ActiveSanctionT } from '../user/active-sanction.js';
import { EntitlementSnapshot, EntitlementSnapshotT } from '../user/entitlement-snapshot.js';


export class AccountView implements flatbuffers.IUnpackableObject<AccountViewT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):AccountView {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

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

userId():string|null
userId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
userId(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;
}

email():string|null
email(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
email(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;
}

userName():string|null
userName(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
userName(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;
}

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

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

timeZone():string|null
timeZone(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
timeZone(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;
}

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

entitlement(obj?:EntitlementSnapshot):EntitlementSnapshot|null {
  const offset = this.bb!.__offset(this.bb_pos, 18);
  return offset ? (obj || new EntitlementSnapshot()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

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

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

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

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

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

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

static startAccountView(builder:flatbuffers.Builder) {
  builder.startObject(12);
}

static addUserId(builder:flatbuffers.Builder, userIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, userIdOffset, 0);
}

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

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

static addDisplayName(builder:flatbuffers.Builder, displayNameOffset:flatbuffers.Offset) {
  builder.addFieldOffset(3, displayNameOffset, 0);
}

static addPreferredLanguage(builder:flatbuffers.Builder, preferredLanguageOffset:flatbuffers.Offset) {
  builder.addFieldOffset(4, preferredLanguageOffset, 0);
}

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

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

static addEntitlement(builder:flatbuffers.Builder, entitlementOffset:flatbuffers.Offset) {
  builder.addFieldOffset(7, entitlementOffset, 0);
}

static addActiveSanctions(builder:flatbuffers.Builder, activeSanctionsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(8, activeSanctionsOffset, 0);
}

static createActiveSanctionsVector(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 startActiveSanctionsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addActiveLimits(builder:flatbuffers.Builder, activeLimitsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(9, activeLimitsOffset, 0);
}

static createActiveLimitsVector(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 startActiveLimitsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addCreatedAtMs(builder:flatbuffers.Builder, createdAtMs:bigint) {
  builder.addFieldInt64(10, createdAtMs, BigInt('0'));
}

static addUpdatedAtMs(builder:flatbuffers.Builder, updatedAtMs:bigint) {
  builder.addFieldInt64(11, updatedAtMs, BigInt('0'));
}

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


unpack(): AccountViewT {
  return new AccountViewT(
    this.userId(),
    this.email(),
    this.userName(),
    this.displayName(),
    this.preferredLanguage(),
    this.timeZone(),
    this.declaredCountry(),
    (this.entitlement() !== null ? this.entitlement()!.unpack() : null),
    this.bb!.createObjList<ActiveSanction, ActiveSanctionT>(this.activeSanctions.bind(this), this.activeSanctionsLength()),
    this.bb!.createObjList<ActiveLimit, ActiveLimitT>(this.activeLimits.bind(this), this.activeLimitsLength()),
    this.createdAtMs(),
    this.updatedAtMs()
  );
}


unpackTo(_o: AccountViewT): void {
  _o.userId = this.userId();
  _o.email = this.email();
  _o.userName = this.userName();
  _o.displayName = this.displayName();
  _o.preferredLanguage = this.preferredLanguage();
  _o.timeZone = this.timeZone();
  _o.declaredCountry = this.declaredCountry();
  _o.entitlement = (this.entitlement() !== null ? this.entitlement()!.unpack() : null);
  _o.activeSanctions = this.bb!.createObjList<ActiveSanction, ActiveSanctionT>(this.activeSanctions.bind(this), this.activeSanctionsLength());
  _o.activeLimits = this.bb!.createObjList<ActiveLimit, ActiveLimitT>(this.activeLimits.bind(this), this.activeLimitsLength());
  _o.createdAtMs = this.createdAtMs();
  _o.updatedAtMs = this.updatedAtMs();
}
}

export class AccountViewT implements flatbuffers.IGeneratedObject {
constructor(
  public userId: string|Uint8Array|null = null,
  public email: string|Uint8Array|null = null,
  public userName: string|Uint8Array|null = null,
  public displayName: string|Uint8Array|null = null,
  public preferredLanguage: string|Uint8Array|null = null,
  public timeZone: string|Uint8Array|null = null,
  public declaredCountry: string|Uint8Array|null = null,
  public entitlement: EntitlementSnapshotT|null = null,
  public activeSanctions: (ActiveSanctionT)[] = [],
  public activeLimits: (ActiveLimitT)[] = [],
  public createdAtMs: bigint = BigInt('0'),
  public updatedAtMs: bigint = BigInt('0')
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const userId = (this.userId !== null ? builder.createString(this.userId!) : 0);
  const email = (this.email !== null ? builder.createString(this.email!) : 0);
  const userName = (this.userName !== null ? builder.createString(this.userName!) : 0);
  const displayName = (this.displayName !== null ? builder.createString(this.displayName!) : 0);
  const preferredLanguage = (this.preferredLanguage !== null ? builder.createString(this.preferredLanguage!) : 0);
  const timeZone = (this.timeZone !== null ? builder.createString(this.timeZone!) : 0);
  const declaredCountry = (this.declaredCountry !== null ? builder.createString(this.declaredCountry!) : 0);
  const entitlement = (this.entitlement !== null ? this.entitlement!.pack(builder) : 0);
  const activeSanctions = AccountView.createActiveSanctionsVector(builder, builder.createObjectOffsetList(this.activeSanctions));
  const activeLimits = AccountView.createActiveLimitsVector(builder, builder.createObjectOffsetList(this.activeLimits));

  AccountView.startAccountView(builder);
  AccountView.addUserId(builder, userId);
  AccountView.addEmail(builder, email);
  AccountView.addUserName(builder, userName);
  AccountView.addDisplayName(builder, displayName);
  AccountView.addPreferredLanguage(builder, preferredLanguage);
  AccountView.addTimeZone(builder, timeZone);
  AccountView.addDeclaredCountry(builder, declaredCountry);
  AccountView.addEntitlement(builder, entitlement);
  AccountView.addActiveSanctions(builder, activeSanctions);
  AccountView.addActiveLimits(builder, activeLimits);
  AccountView.addCreatedAtMs(builder, this.createdAtMs);
  AccountView.addUpdatedAtMs(builder, this.updatedAtMs);

  return AccountView.endAccountView(builder);
}
}
