package com.seven.ikar.kotlin.core.model

import java.util.UUID

object ClientMessageIds {
    const val LocalPrefix = "local-"

    fun newClientId(): String = UUID.randomUUID().toString()

    fun localId(clientMessageId: String): String = "$LocalPrefix$clientMessageId"

    fun clientIdFromLocalId(localMessageId: String): String? =
        localMessageId.takeIf { it.startsWith(LocalPrefix) }
            ?.removePrefix(LocalPrefix)
            ?.takeIf(String::isNotBlank)
}
