function variable(name, category, description, source = 'psadt') {
  return {
    id: `${source}:${name}`,
    name,
    syntax: `$${name}`,
    token: `{{${name}}}`,
    category,
    description,
    source,
    readOnly: true
  };
}

export const poshManagerVariables = [
  variable('POSHM_JOB_ID', 'POSHManager Runtime', 'Current POSHManager job id.', 'poshmanager'),
  variable('POSHM_RUNPLAN_ID', 'POSHManager Runtime', 'RunPlan id that launched the execution.', 'poshmanager'),
  variable('POSHM_SCRIPT_ID', 'POSHManager Runtime', 'Script id being executed.', 'poshmanager'),
  variable('POSHM_SCRIPT_NAME', 'POSHManager Runtime', 'Script display name being executed.', 'poshmanager'),
  variable('POSHM_HOST_ID', 'POSHManager Runtime', 'Target host id for the current execution.', 'poshmanager'),
  variable('POSHM_HOST_NAME', 'POSHManager Runtime', 'Target host display name.', 'poshmanager'),
  variable('POSHM_HOST_ADDRESS', 'POSHManager Runtime', 'Target host address used by remoting.', 'poshmanager'),
  variable('POSHM_HOST_TRANSPORT', 'POSHManager Runtime', 'Transport selected for the target host.', 'poshmanager'),
  variable('POSHM_TRIGGERED_BY', 'POSHManager Runtime', 'User id that launched the RunPlan.', 'poshmanager')
];

export const psadtVariables = [
  variable('appDeployMainScriptFriendlyName', 'PSADT Toolkit Name', 'Friendly name for the main deployment script.'),
  variable('appDeployToolkitName', 'PSADT Toolkit Name', 'PSAppDeployToolkit name.'),
  variable('appDeployMainScriptVersion', 'PSADT Script Info', 'Version of the main deployment script.'),
  variable('culture', 'PSADT Culture', 'Current culture information.'),
  variable('currentLanguage', 'PSADT Culture', 'Current language code.'),
  variable('currentUILanguage', 'PSADT Culture', 'Current UI language code.'),
  ...[
    'envAllUsersProfile', 'envAppData', 'envArchitecture', 'envCommonDesktop', 'envCommonDocuments',
    'envCommonProgramFiles', 'envCommonProgramFilesX86', 'envCommonStartMenu', 'envCommonStartMenuPrograms',
    'envCommonStartUp', 'envCommonTemplates', 'envComputerName', 'envComputerNameFQDN', 'envHomeDrive',
    'envHomePath', 'envHomeShare', 'envLocalAppData', 'envLogicalDrives', 'envProgramData', 'envProgramFiles',
    'envProgramFilesX86', 'envPublic', 'envSystem32Directory', 'envSystemDrive', 'envSystemRAM', 'envSystemRoot',
    'envTemp', 'envUserCookies', 'envUserDesktop', 'envUserFavorites', 'envUserInternetCache',
    'envUserInternetHistory', 'envUserMyDocuments', 'envUserName', 'envUserProfile', 'envUserSendTo',
    'envUserStartMenu', 'envUserStartMenuPrograms', 'envUserStartUp', 'envWinDir'
  ].map((name) => variable(name, 'PSADT Environment', 'Environment/session variable populated by PSADT.')),
  ...[
    'envLogonServer', 'envMachineADDomain', 'envMachineDNSDomain', 'envMachineWorkgroup', 'envUserDNSDomain',
    'envUserDomain', 'IsMachinePartOfDomain', 'MachineDomainController'
  ].map((name) => variable(name, 'PSADT Domain', 'Domain and directory context populated by PSADT.')),
  ...[
    'envOS', 'envOSArchitecture', 'envOSName', 'envOSProductType', 'envOSProductTypeName', 'envOSServicePack',
    'envOSVersion', 'envOSVersionBuild', 'envOSVersionMajor', 'envOSVersionMinor', 'envOSVersionRevision',
    'Is64Bit', 'IsDomainControllerOS', 'IsServerOS', 'IsWorkStationOS'
  ].map((name) => variable(name, 'PSADT Operating System', 'Operating system detail populated by PSADT.')),
  variable('Is64BitProcess', 'PSADT Process', 'Whether the active PowerShell process is 64-bit.'),
  variable('psArchitecture', 'PSADT Process', 'PowerShell process architecture.'),
  ...[
    'envCLRVersion', 'envCLRVersionBuild', 'envCLRVersionMajor', 'envCLRVersionMinor', 'envCLRVersionRevision',
    'envHost', 'envPSVersion', 'envPSVersionBuild', 'envPSVersionMajor', 'envPSVersionMinor',
    'envPSVersionRevision', 'envPSVersionTable'
  ].map((name) => variable(name, 'PSADT PowerShell', '.NET CLR, host, or PowerShell version detail populated by PSADT.')),
  ...[
    'CurrentProcessSID', 'CurrentProcessToken', 'IsAdmin', 'IsLocalServiceAccount', 'IsLocalSystemAccount',
    'IsNetworkServiceAccount', 'IsProcessUserInteractive', 'IsServiceAccount', 'LocalSystemNTAccount',
    'ProcessNTAccount', 'ProcessNTAccountSID', 'SessionZero'
  ].map((name) => variable(name, 'PSADT Permissions', 'Process identity, token, and permission context populated by PSADT.')),
  variable('MSIProductCodeRegExPattern', 'PSADT Regex', 'Regular expression pattern for MSI product codes.'),
  variable('Shell', 'PSADT COM', 'Shell COM object created by PSADT.'),
  variable('ShellApp', 'PSADT COM', 'Shell application COM object created by PSADT.'),
  ...[
    'CurrentConsoleUserSession', 'CurrentLoggedOnUserSession', 'LoggedOnUserSessions', 'RunAsActiveUser', 'UsersLoggedOn'
  ].map((name) => variable(name, 'PSADT Logged On Users', 'Logged-on user session context populated by PSADT.')),
  ...[
    'envOfficeBitness', 'envOfficeChannel', 'envOfficeVars', 'envOfficeVersion'
  ].map((name) => variable(name, 'PSADT Office', 'Microsoft Office discovery variable populated by PSADT.')),
  variable('invalidFileNameChars', 'PSADT Miscellaneous', 'Invalid file name character list.'),
  variable('LocalAdministratorsGroup', 'PSADT Miscellaneous', 'Localized local administrators group.'),
  variable('LocalUsersGroup', 'PSADT Miscellaneous', 'Localized local users group.'),
  variable('RunningTaskSequence', 'PSADT Miscellaneous', 'Whether execution is running inside a task sequence.')
];

export function fullVariableCatalog() {
  return {
    builtIns: poshManagerVariables,
    psadt: psadtVariables
  };
}
