// Centralized Page Visibility Matrix
// Controls which pages each user group can access.
// Empty array = visible to all authenticated users.
// Non-empty array = visible only to listed groups.

export const PAGE_VISIBILITY = {
  home:               [],
  triage:             ['Admin', 'Standard_User', 'Leadership'],
  compliance:         ['Admin', 'Standard_User', 'Leadership'],
  'ccp-metrics':      ['Admin', 'Leadership'],
  'knowledge-base':   [],
  exports:            ['Admin', 'Standard_User', 'Leadership'],
  jira:               ['Admin', 'Standard_User'],
  'archer-templates': ['Admin', 'Standard_User'],
  admin:              ['Admin'],
};

/**
 * Check if a user group can access a page.
 * @param {string} pageId - Page identifier
 * @param {string} userGroup - User's group
 * @returns {boolean}
 */
export function canAccessPage(pageId, userGroup) {
  const allowed = PAGE_VISIBILITY[pageId];
  if (!allowed || allowed.length === 0) return true;
  return allowed.includes(userGroup);
}

/**
 * Get all page IDs accessible to a given group.
 * @param {string} userGroup - User's group
 * @returns {string[]}
 */
export function getAccessiblePages(userGroup) {
  return Object.keys(PAGE_VISIBILITY).filter(pageId => canAccessPage(pageId, userGroup));
}
