package com.korancrew.brizzi.hce

/**
 * Koleksi constant dan helper response APDU.
 * Semua status/proses response mengikuti format Brizzi/ISO-like yang dipakai reader.
 */
object BrizziResponse {
    val isoSuccess: ByteArray = "9100".hexToBytes()
    val iso7816Success: ByteArray = "9000".hexToBytes()
    val nativeSuccess: ByteArray = "00".hexToBytes()
    val fileNotFound: ByteArray = "6A82".hexToBytes()
    val wrongLength: ByteArray = "6700".hexToBytes()
    val conditionsNotSatisfied: ByteArray = "6985".hexToBytes()
    val unsupportedInstruction: ByteArray = "6D00".hexToBytes()
    val securityStatusNotSatisfied: ByteArray = "6982".hexToBytes()
    val rateLimitExceeded: ByteArray = "6FFF".hexToBytes()

    fun iso(payloadHex: String = ""): ByteArray = (payloadHex + "9100").hexToBytes()

    fun iso7816(payloadHex: String = ""): ByteArray = (payloadHex + "9000").hexToBytes()

    fun isoAdditionalFrame(payloadHex: String = ""): ByteArray =
        (payloadHex + "91AF").hexToBytes()

    fun isoNoLog(): ByteArray = "91BE".hexToBytes()

    fun native(payloadHex: String = ""): ByteArray =
        if (payloadHex.isEmpty()) {
            "9100".hexToBytes()
        } else {
            (payloadHex + "9100").hexToBytes()
        }

    fun nativeNoLog(): ByteArray = "BE".hexToBytes()
}
