"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = void 0;
exports.getReclaimEventAccountDiscriminatorBytes = getReclaimEventAccountDiscriminatorBytes;
exports.getReclaimEventAccountInstructionDataEncoder = getReclaimEventAccountInstructionDataEncoder;
exports.getReclaimEventAccountInstructionDataDecoder = getReclaimEventAccountInstructionDataDecoder;
exports.getReclaimEventAccountInstructionDataCodec = getReclaimEventAccountInstructionDataCodec;
exports.getReclaimEventAccountInstruction = getReclaimEventAccountInstruction;
exports.parseReclaimEventAccountInstruction = parseReclaimEventAccountInstruction;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
var programs_1 = require("../programs");
var shared_1 = require("../shared");
exports.RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    94, 198, 180, 159, 131, 236, 15, 174,
]);
function getReclaimEventAccountDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR);
}
function getReclaimEventAccountInstructionDataEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ["attestation", (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)())],
    ]), function (value) { return (tslib_1.__assign(tslib_1.__assign({}, value), { discriminator: exports.RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR })); });
}
function getReclaimEventAccountInstructionDataDecoder() {
    return (0, kit_1.getStructDecoder)([
        ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ["attestation", (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)())],
    ]);
}
function getReclaimEventAccountInstructionDataCodec() {
    return (0, kit_1.combineCodec)(getReclaimEventAccountInstructionDataEncoder(), getReclaimEventAccountInstructionDataDecoder());
}
function getReclaimEventAccountInstruction(input, config) {
    var _a, _b, _c, _d;
    var programAddress = (_a = config === null || config === void 0 ? void 0 : config.programAddress) !== null && _a !== void 0 ? _a : programs_1.MESSAGE_TRANSMITTER_PROGRAM_ADDRESS;
    var originalAccounts = {
        payee: { value: (_b = input.payee) !== null && _b !== void 0 ? _b : null, isWritable: true },
        messageTransmitter: {
            value: (_c = input.messageTransmitter) !== null && _c !== void 0 ? _c : null,
            isWritable: true,
        },
        messageSentEventData: {
            value: (_d = input.messageSentEventData) !== null && _d !== void 0 ? _d : null,
            isWritable: true,
        },
    };
    var accounts = originalAccounts;
    var args = tslib_1.__assign({}, input);
    var getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
    return Object.freeze({
        accounts: [
            getAccountMeta(accounts.payee),
            getAccountMeta(accounts.messageTransmitter),
            getAccountMeta(accounts.messageSentEventData),
        ],
        data: getReclaimEventAccountInstructionDataEncoder().encode(args),
        programAddress: programAddress,
    });
}
function parseReclaimEventAccountInstruction(instruction) {
    if (instruction.accounts.length < 3) {
        throw new Error("Not enough accounts");
    }
    var accountIndex = 0;
    var getNextAccount = function () {
        var accountMeta = instruction.accounts[accountIndex];
        accountIndex += 1;
        return accountMeta;
    };
    return {
        programAddress: instruction.programAddress,
        accounts: {
            payee: getNextAccount(),
            messageTransmitter: getNextAccount(),
            messageSentEventData: getNextAccount(),
        },
        data: getReclaimEventAccountInstructionDataDecoder().decode(instruction.data),
    };
}
//# sourceMappingURL=reclaimEventAccount.js.map