package com.laseroptek.raman.utils.ext

import com.laseroptek.raman.data.model.SerialNumber

fun SerialNumber.toStringRepresentation(): String {
    return listOf(char1, char2, char3, char4, char5, char6).joinToString("")
}

fun SerialNumber.toDashedStringRepresentation(): String {
    return listOf(char1, char2, '-', char3, char4, char5, '-', char6).joinToString("")
}

fun SerialNumber.toFullStringRepresentation(): String {
    return "LO" + "-" + "3ND" + "-" + listOf(char1, char2, '-', char3, char4, char5, '-', char6).joinToString("")
}

fun List<String>.toFullStringRepresentation(): String {
    // Safety check to ensure the list has enough elements to prevent a crash
    if (this.size < 6) {
        return "LO-3ND-IN-VAL-ID" // Return a default or error string
    }

    // Use the elements from the list to construct the dashed representation
    val dashedPart = listOf(
        this[0], this[1], '-',
        this[2], this[3], this[4], '-',
        this[5]
    ).joinToString("")

    // Combine with the prefix
    return "LO-3ND-$dashedPart"
}