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 || ''
}

export function resolveKnowledgeFolderIcon(folder, activeFolder = '') {
  const folderName = String(folder?.name || folder || '').trim()
  const normalizedActiveFolder = String(activeFolder || '').trim()

  return folderName && folderName === normalizedActiveFolder
    ? 'mdi mdi-folder-open'
    : 'mdi mdi-folder'
}
