package com.pixelized.desktop.lwa.ui.screen.admin.map.list

import com.pixelized.desktop.lwa.utils.extention.unAccent
import java.text.Collator
import com.pixelized.shared.lwa.model.map.Map as MiniMap

class GMMapFactory() {
    fun filterItem(
        items: Collection<MiniMap>,
        unAccentFilter: String,
    ): List<MiniMap> {
        return items.filter {
            it.name.unAccent().contains(
                other = unAccentFilter,
                ignoreCase = true
            )
        }
    }

    fun convertToGMMapUio(
        items: List<MiniMap>,
    ): List<GMMapItemUio> {
        return items
            .map { item ->
                GMMapItemUio(
                    mapId = item.id,
                    label = item.name,
                )
            }
            .sortedWith(compareBy(Collator.getInstance()) { it.label })
    }
}