/** 按车型 key 查找已保存的动作白名单（兼容 fullTypeName / shortTypeName / 后缀匹配）。 */
export function lookupCarActionKeys(
  map: Record<string, string[] | undefined> | null | undefined,
  typeKey: string,
  shortTypeName: string
): string[] {
  if (!map) return []
  const direct = map[typeKey] ?? map[shortTypeName]
  if (direct?.length) return [...direct]
  for (const [k, v] of Object.entries(map)) {
    if (!v?.length) continue
    if (k === typeKey || k === shortTypeName) return [...v]
    if (typeKey.endsWith('.' + k) || k.endsWith('.' + shortTypeName)) return [...v]
    if (typeKey.endsWith('.' + shortTypeName) && (k === shortTypeName || k.endsWith('.' + shortTypeName))) {
      return [...v]
    }
  }
  return []
}
