// Advisory migration classification only. Never grants, removes or changes permissions. import {STAFF_DEPARTMENTS,STAFF_LEVELS} from './staff-bureau-policy.mjs'; const CANDIDATES=Object.freeze({ owners:{level:'owner',department:null,review:'verify-owner'}, official_account:{level:null,department:null,review:'service-identity'}, web_net_owner:{level:'owner',department:null,review:'owner-approval'}, web_net_admin:{level:'director',department:null,review:'director-approval'}, network_admin:{level:'director',department:null,review:'director-approval'}, web_network:{level:'director',department:null,review:'director-approval'}, corestaff:{level:'senior',department:null,review:'assign-department-and-level'}, staff:{level:'staff',department:null,review:'assign-department'}, web_dev:{level:'staff',department:'development',review:'verify-scope'}, web_support:{level:'staff',department:'community_moderation',review:'verify-scope'}, web_forum:{level:'staff',department:'community_moderation',review:'verify-scope'}, web_appeal:{level:'staff',department:'community_moderation',review:'verify-scope'}, game_mod:{level:'staff',department:'community_moderation',review:'verify-scope'}, game_support:{level:'staff',department:'community_moderation',review:'verify-scope'}, game_appeal:{level:'staff',department:'community_moderation',review:'verify-scope'}, web_news:{level:'staff',department:'administration',review:'verify-scope'}, web_sales:{level:'staff',department:'administration',review:'verify-scope'}, web_legal:{level:'staff',department:'administration',review:'verify-scope'}, game_admin:{level:'staff',department:'operations',review:'verify-elevated-access'}, game_restoration:{level:'staff',department:'operations',review:'verify-elevated-access'}, game_quests:{level:'staff',department:null,review:'choose-operations-or-community'} }); export const LEGACY_STAFF_ROLE_CANDIDATES=CANDIDATES; export function previewStaffMigration(account){ const ranks=[...new Set([account?.role,account?.rank,...(Array.isArray(account?.ranks)?account.ranks:[])].filter(v=>typeof v==='string'&&v.length).map(v=>v.toLowerCase()))]; const matches=ranks.filter(r=>Object.hasOwn(CANDIDATES,r)).map(role=>({role,...CANDIDATES[role]})); const service=matches.some(x=>x.review==='service-identity'); const departments=[...new Set(matches.map(x=>x.department).filter(Boolean))]; const levels=[...new Set(matches.map(x=>x.level).filter(Boolean))]; const ambiguous=service||departments.length!==1&&levels.some(l=>!['owner','director'].includes(l))||levels.length>1||matches.length===0; const candidate=ambiguous?null:matches[0]; return {accountId:account?.id??null,legacyRoles:ranks,matches,candidate: candidate?{department:candidate.department,level:candidate.level}:null,requiresOwnerReview:true,ambiguous,mode:'shadow',applied:false}; }