import { getAddressDecoder } from '@solana/kit';
import { assert } from '@hyperlane-xyz/utils';
import { decodeAccountData } from '../codecs/account-data.js';
import { ByteCursor } from '../codecs/binary.js';
import { decodeDomainedValidatorsAndThreshold, decodeValidatorsAndThreshold, } from '../codecs/shared.js';
// Could be migrated to struct codecs; left manual here to keep parity with adjacent account decoders.
const addressDecoder = getAddressDecoder();
export function decodeMultisigIsmAccessControlAccount(raw) {
    const wrapped = decodeAccountData(raw, (cursor) => {
        const bumpSeed = cursor.readU8();
        const ownerTag = cursor.readU8();
        assert(ownerTag === 0 || ownerTag === 1, `Invalid option tag for owner: ${ownerTag}`);
        const owner = ownerTag === 1 ? addressDecoder.decode(cursor.readBytes(32)) : null;
        return { bumpSeed, owner };
    });
    return wrapped.data;
}
export function decodeMultisigIsmDomainDataAccount(raw) {
    const wrapped = decodeAccountData(raw, (cursor) => {
        const bumpSeed = cursor.readU8();
        const validatorsAndThreshold = decodeValidatorsAndThreshold(cursor);
        return {
            bumpSeed,
            validatorsAndThreshold,
        };
    });
    return wrapped.data;
}
export function decodeSetValidatorsAndThresholdPayload(payload) {
    return decodeDomainedValidatorsAndThreshold(new ByteCursor(payload));
}
//# sourceMappingURL=multisig-ism-message-id.js.map