"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.DtlsStateChangeNotificationT = exports.DtlsStateChangeNotification = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
const flatbuffers = require("flatbuffers");
const dtls_state_1 = require("../../fbs/web-rtc-transport/dtls-state");
class DtlsStateChangeNotification {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsDtlsStateChangeNotification(bb, obj) {
        return (obj || new DtlsStateChangeNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsDtlsStateChangeNotification(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new DtlsStateChangeNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    dtlsState() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : dtls_state_1.DtlsState.NEW;
    }
    remoteCert(optionalEncoding) {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
    }
    static startDtlsStateChangeNotification(builder) {
        builder.startObject(2);
    }
    static addDtlsState(builder, dtlsState) {
        builder.addFieldInt8(0, dtlsState, dtls_state_1.DtlsState.NEW);
    }
    static addRemoteCert(builder, remoteCertOffset) {
        builder.addFieldOffset(1, remoteCertOffset, 0);
    }
    static endDtlsStateChangeNotification(builder) {
        const offset = builder.endObject();
        return offset;
    }
    static createDtlsStateChangeNotification(builder, dtlsState, remoteCertOffset) {
        DtlsStateChangeNotification.startDtlsStateChangeNotification(builder);
        DtlsStateChangeNotification.addDtlsState(builder, dtlsState);
        DtlsStateChangeNotification.addRemoteCert(builder, remoteCertOffset);
        return DtlsStateChangeNotification.endDtlsStateChangeNotification(builder);
    }
    unpack() {
        return new DtlsStateChangeNotificationT(this.dtlsState(), this.remoteCert());
    }
    unpackTo(_o) {
        _o.dtlsState = this.dtlsState();
        _o.remoteCert = this.remoteCert();
    }
}
exports.DtlsStateChangeNotification = DtlsStateChangeNotification;
class DtlsStateChangeNotificationT {
    dtlsState;
    remoteCert;
    constructor(dtlsState = dtls_state_1.DtlsState.NEW, remoteCert = null) {
        this.dtlsState = dtlsState;
        this.remoteCert = remoteCert;
    }
    pack(builder) {
        const remoteCert = (this.remoteCert !== null ? builder.createString(this.remoteCert) : 0);
        return DtlsStateChangeNotification.createDtlsStateChangeNotification(builder, this.dtlsState, remoteCert);
    }
}
exports.DtlsStateChangeNotificationT = DtlsStateChangeNotificationT;
