export function resolveInitialKnowledgeFolder(folders, currentFolder = '') {
  const normalizedCurrentFolder = String(currentFolder || '').trim()
  const normalizedFolders = Array.isArray(folders) ? folders : []

  if (normalizedCurrentFolder && normalizedFolders.some((folder) => folder?.name === normalizedCurrentFolder)) {
    return normalizedCurrentFolder
  }

  return normalizedFolders[0]?.name || ''
}
