/*
 * Copyright (C) 2026 Fluxer Contributors
 *
 * This file is part of Fluxer.
 *
 * Fluxer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fluxer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
 */

export const API_CODE_VERSION = 1;

export const APIErrorCodes = {
	GENERAL_ERROR: 'GENERAL_ERROR',
	UNKNOWN_CHANNEL: 'UNKNOWN_CHANNEL',
	UNKNOWN_GUILD: 'UNKNOWN_GUILD',
	UNKNOWN_INVITE: 'UNKNOWN_INVITE',
	UNKNOWN_MEMBER: 'UNKNOWN_MEMBER',
	UNKNOWN_MESSAGE: 'UNKNOWN_MESSAGE',
	UNKNOWN_ROLE: 'UNKNOWN_ROLE',
	UNKNOWN_USER: 'UNKNOWN_USER',
	UNKNOWN_EMOJI: 'UNKNOWN_EMOJI',
	UNKNOWN_PACK: 'UNKNOWN_PACK',
	UNKNOWN_STICKER: 'UNKNOWN_STICKER',
	UNKNOWN_WEBHOOK: 'UNKNOWN_WEBHOOK',
	UNKNOWN_BETA_CODE: 'UNKNOWN_BETA_CODE',
	UNKNOWN_FAVORITE_MEME: 'UNKNOWN_FAVORITE_MEME',
	EXPLICIT_CONTENT_CANNOT_BE_SENT: 'EXPLICIT_CONTENT_CANNOT_BE_SENT',
	MAX_GUILDS: 'MAX_GUILDS',
	MAX_FRIENDS: 'MAX_FRIENDS',
	MAX_PINS_PER_CHANNEL: 'MAX_PINS_PER_CHANNEL',
	MAX_GUILD_ROLES: 'MAX_GUILD_ROLES',
	MAX_WEBHOOKS: 'MAX_WEBHOOKS',
	MAX_EMOJIS: 'MAX_EMOJIS',
	MAX_STICKERS: 'MAX_STICKERS',
	MAX_PACKS: 'MAX_PACKS',
	MAX_REACTIONS: 'MAX_REACTIONS',
	MAX_GUILD_CHANNELS: 'MAX_GUILD_CHANNELS',
	MAX_CATEGORY_CHANNELS: 'MAX_CATEGORY_CHANNELS',
	MAX_INVITES: 'MAX_INVITES',
	MAX_ANIMATED_EMOJIS: 'MAX_ANIMATED_EMOJIS',
	MAX_GUILD_MEMBERS: 'MAX_GUILD_MEMBERS',
	MAX_WEBHOOKS_PER_GUILD: 'MAX_WEBHOOKS_PER_GUILD',
	MAX_BETA_CODES_REACHED: 'MAX_BETA_CODES_REACHED',
	RATE_LIMITED: 'RATE_LIMITED',
	SLOWMODE_RATE_LIMITED: 'SLOWMODE_RATE_LIMITED',
	CAPTCHA_REQUIRED: 'CAPTCHA_REQUIRED',
	INVALID_CAPTCHA: 'INVALID_CAPTCHA',
	UNAUTHORIZED: 'UNAUTHORIZED',
	USER_BANNED_FROM_GUILD: 'USER_BANNED_FROM_GUILD',
	USER_IP_BANNED_FROM_GUILD: 'USER_IP_BANNED_FROM_GUILD',
	MISSING_ACCESS: 'MISSING_ACCESS',
	CANNOT_EXECUTE_ON_DM: 'CANNOT_EXECUTE_ON_DM',
	CANNOT_EDIT_OTHER_USER_MESSAGE: 'CANNOT_EDIT_OTHER_USER_MESSAGE',
	CANNOT_SEND_EMPTY_MESSAGE: 'CANNOT_SEND_EMPTY_MESSAGE',
	CANNOT_SEND_MESSAGES_TO_USER: 'CANNOT_SEND_MESSAGES_TO_USER',
	CANNOT_SEND_MESSAGES_IN_NON_TEXT_CHANNEL: 'CANNOT_SEND_MESSAGES_IN_NON_TEXT_CHANNEL',
	COMMUNICATION_DISABLED: 'COMMUNICATION_DISABLED',
	MISSING_PERMISSIONS: 'MISSING_PERMISSIONS',
	INVALID_FORM_BODY: 'INVALID_FORM_BODY',
	CANNOT_MODIFY_SYSTEM_WEBHOOK: 'CANNOT_MODIFY_SYSTEM_WEBHOOK',
	TWO_FACTOR_REQUIRED: 'TWO_FACTOR_REQUIRED',
	FRIEND_REQUEST_BLOCKED: 'FRIEND_REQUEST_BLOCKED',
	CANNOT_SEND_FRIEND_REQUEST_TO_BLOCKED_USER: 'CANNOT_SEND_FRIEND_REQUEST_TO_BLOCKED_USER',
	BOTS_CANNOT_HAVE_FRIENDS: 'BOTS_CANNOT_HAVE_FRIENDS',
	CANNOT_SEND_FRIEND_REQUEST_TO_SELF: 'CANNOT_SEND_FRIEND_REQUEST_TO_SELF',
	NO_USERS_WITH_FLUXERTAG_EXIST: 'NO_USERS_WITH_FLUXERTAG_EXIST',
	ALREADY_FRIENDS: 'ALREADY_FRIENDS',
	DISCRIMINATOR_REQUIRED: 'DISCRIMINATOR_REQUIRED',
	TWO_FA_NOT_ENABLED: 'TWO_FA_NOT_ENABLED',
	MISSING_ACL: 'MISSING_ACL',
	IP_BANNED: 'IP_BANNED',
	IP_AUTHORIZATION_REQUIRED: 'IP_AUTHORIZATION_REQUIRED',
	USER_NOT_IN_VOICE: 'USER_NOT_IN_VOICE',
	CANNOT_MODIFY_VOICE_STATE: 'CANNOT_MODIFY_VOICE_STATE',
	VOICE_CHANNEL_FULL: 'VOICE_CHANNEL_FULL',
	ACCOUNT_DISABLED: 'ACCOUNT_DISABLED',
	ACCOUNT_SCHEDULED_FOR_DELETION: 'ACCOUNT_SCHEDULED_FOR_DELETION',
	TAG_ALREADY_TAKEN: 'TAG_ALREADY_TAKEN',
	INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
	PHONE_ALREADY_USED: 'PHONE_ALREADY_USED',
	PHONE_VERIFICATION_REQUIRED: 'PHONE_VERIFICATION_REQUIRED',
	INVALID_PHONE_VERIFICATION_CODE: 'INVALID_PHONE_VERIFICATION_CODE',
	PHONE_RATE_LIMIT_EXCEEDED: 'PHONE_RATE_LIMIT_EXCEEDED',
	SMS_MFA_NOT_ENABLED: 'SMS_MFA_NOT_ENABLED',
	SMS_MFA_REQUIRES_TOTP: 'SMS_MFA_REQUIRES_TOTP',
	PHONE_REQUIRED_FOR_SMS_MFA: 'PHONE_REQUIRED_FOR_SMS_MFA',
	INVALID_WEBAUTHN_CREDENTIAL: 'INVALID_WEBAUTHN_CREDENTIAL',
	WEBAUTHN_CREDENTIAL_LIMIT_REACHED: 'WEBAUTHN_CREDENTIAL_LIMIT_REACHED',
	UNKNOWN_WEBAUTHN_CREDENTIAL: 'UNKNOWN_WEBAUTHN_CREDENTIAL',
	PASSKEY_AUTHENTICATION_FAILED: 'PASSKEY_AUTHENTICATION_FAILED',
	PASSKEYS_DISABLED: 'PASSKEYS_DISABLED',
	GUILD_VERIFICATION_REQUIRED: 'GUILD_VERIFICATION_REQUIRED',
	ACCOUNT_SUSPICIOUS_ACTIVITY: 'ACCOUNT_SUSPICIOUS_ACTIVITY',
	PREMIUM_PURCHASE_BLOCKED: 'PREMIUM_PURCHASE_BLOCKED',
	PREMIUM_REQUIRED: 'PREMIUM_REQUIRED',
	HARVEST_ON_COOLDOWN: 'HARVEST_ON_COOLDOWN',
	HARVEST_EXPIRED: 'HARVEST_EXPIRED',
	HARVEST_FAILED: 'HARVEST_FAILED',
	HARVEST_NOT_READY: 'HARVEST_NOT_READY',
	UNKNOWN_HARVEST: 'UNKNOWN_HARVEST',
	CHANNEL_INDEXING: 'CHANNEL_INDEXING',
	AUDIT_LOG_INDEXING: 'AUDIT_LOG_INDEXING',
	UNKNOWN_GIFT_CODE: 'UNKNOWN_GIFT_CODE',
	GIFT_CODE_ALREADY_REDEEMED: 'GIFT_CODE_ALREADY_REDEEMED',
	STRIPE_ERROR: 'STRIPE_ERROR',
	STRIPE_WEBHOOK_SIGNATURE_MISSING: 'STRIPE_WEBHOOK_SIGNATURE_MISSING',
	STRIPE_WEBHOOK_SIGNATURE_INVALID: 'STRIPE_WEBHOOK_SIGNATURE_INVALID',
	USER_OWNS_GUILDS: 'USER_OWNS_GUILDS',
	FEATURE_TEMPORARILY_DISABLED: 'FEATURE_TEMPORARILY_DISABLED',
	INVITES_DISABLED: 'INVITES_DISABLED',
	GUILD_DISALLOWS_UNCLAIMED_ACCOUNTS: 'GUILD_DISALLOWS_UNCLAIMED_ACCOUNTS',
	TEMPORARY_INVITE_REQUIRES_PRESENCE: 'TEMPORARY_INVITE_REQUIRES_PRESENCE',
	MAX_GROUP_DM_RECIPIENTS: 'MAX_GROUP_DM_RECIPIENTS',
	MAX_GROUP_DMS: 'MAX_GROUP_DMS',
	NOT_FRIENDS_WITH_USER: 'NOT_FRIENDS_WITH_USER',
	INVALID_CHANNEL_TYPE: 'INVALID_CHANNEL_TYPE',
	NSFW_CONTENT_AGE_RESTRICTED: 'NSFW_CONTENT_AGE_RESTRICTED',
	FILE_SIZE_TOO_LARGE: 'FILE_SIZE_TOO_LARGE',
	CANNOT_REPORT_OWN_MESSAGE: 'CANNOT_REPORT_OWN_MESSAGE',
	CANNOT_REPORT_YOURSELF: 'CANNOT_REPORT_YOURSELF',
	CANNOT_REPORT_OWN_GUILD: 'CANNOT_REPORT_OWN_GUILD',
	REPORT_BANNED: 'REPORT_BANNED',
	MAX_BOOKMARKS: 'MAX_BOOKMARKS',
	MAX_PACK_EXPRESSIONS: 'MAX_PACK_EXPRESSIONS',
	MAX_FAVORITE_MEMES: 'MAX_FAVORITE_MEMES',
	CANNOT_REDEEM_PLUTONIUM_WITH_VISIONARY: 'CANNOT_REDEEM_PLUTONIUM_WITH_VISIONARY',
	NO_VISIONARY_SLOTS_AVAILABLE: 'NO_VISIONARY_SLOTS_AVAILABLE',
	CANNOT_SHRINK_RESERVED_SLOTS: 'CANNOT_SHRINK_RESERVED_SLOTS',
	MEDIA_METADATA_ERROR: 'MEDIA_METADATA_ERROR',
	NO_ACTIVE_CALL: 'NO_ACTIVE_CALL',
	CALL_ALREADY_EXISTS: 'CALL_ALREADY_EXISTS',
	INVALID_CHANNEL_TYPE_FOR_CALL: 'INVALID_CHANNEL_TYPE_FOR_CALL',
	UNCLAIMED_ACCOUNT_RESTRICTED: 'UNCLAIMED_ACCOUNT_RESTRICTED',

	INVALID_CLIENT: 'INVALID_CLIENT',
	INVALID_REQUEST: 'INVALID_REQUEST',
	INVALID_SCOPE: 'INVALID_SCOPE',
	UNSUPPORTED_RESPONSE_TYPE: 'UNSUPPORTED_RESPONSE_TYPE',
	INVALID_GRANT: 'INVALID_GRANT',
	ACCESS_DENIED: 'ACCESS_DENIED',
	INVALID_TOKEN: 'INVALID_TOKEN',

	SUDO_MODE_REQUIRED: 'SUDO_MODE_REQUIRED',
	INVALID_SUDO_TOKEN: 'INVALID_SUDO_TOKEN',

	INSTANCE_VERSION_MISMATCH: 'INSTANCE_VERSION_MISMATCH',

	INVALID_HANDOFF_CODE: 'INVALID_HANDOFF_CODE',
	HANDOFF_CODE_EXPIRED: 'HANDOFF_CODE_EXPIRED',

	NO_ACTIVE_SUBSCRIPTION: 'NO_ACTIVE_SUBSCRIPTION',
	UNKNOWN_VOICE_REGION: 'UNKNOWN_VOICE_REGION',
	UNKNOWN_VOICE_SERVER: 'UNKNOWN_VOICE_SERVER',
	UNKNOWN_REPORT: 'UNKNOWN_REPORT',
	REPORT_ALREADY_RESOLVED: 'REPORT_ALREADY_RESOLVED',

	TEST_HARNESS_DISABLED: 'TEST_HARNESS_DISABLED',
	TEST_HARNESS_FORBIDDEN: 'TEST_HARNESS_FORBIDDEN',
	EMAIL_SERVICE_NOT_TESTABLE: 'EMAIL_SERVICE_NOT_TESTABLE',
	INVALID_FLAGS_FORMAT: 'INVALID_FLAGS_FORMAT',
	INVALID_ACLS_FORMAT: 'INVALID_ACLS_FORMAT',
	ACLS_MUST_BE_NON_EMPTY: 'ACLS_MUST_BE_NON_EMPTY',
	UNKNOWN_USER_FLAG: 'UNKNOWN_USER_FLAG',
	UNKNOWN_SUSPICIOUS_FLAG: 'UNKNOWN_SUSPICIOUS_FLAG',
	INVALID_SUSPICIOUS_FLAGS_FORMAT: 'INVALID_SUSPICIOUS_FLAGS_FORMAT',
	NO_PENDING_DELETION: 'NO_PENDING_DELETION',
	INVALID_TIMESTAMP: 'INVALID_TIMESTAMP',
	INVALID_BOT_FLAG: 'INVALID_BOT_FLAG',
	INVALID_SYSTEM_FLAG: 'INVALID_SYSTEM_FLAG',
	MISSING_OAUTH_FIELDS: 'MISSING_OAUTH_FIELDS',
	DELETION_FAILED: 'DELETION_FAILED',
	PROCESSING_FAILED: 'PROCESSING_FAILED',
	UPDATE_FAILED: 'UPDATE_FAILED',
	CREATION_FAILED: 'CREATION_FAILED',

	INVALID_DSA_REPORT_TARGET: 'INVALID_DSA_REPORT_TARGET',
	INVALID_DSA_TICKET: 'INVALID_DSA_TICKET',
	INVALID_DSA_VERIFICATION_CODE: 'INVALID_DSA_VERIFICATION_CODE',
	PACK_ACCESS_DENIED: 'PACK_ACCESS_DENIED',
	INVALID_PACK_TYPE: 'INVALID_PACK_TYPE',
} as const;

export const AdminACLs = {
	WILDCARD: '*',

	AUTHENTICATE: 'admin:authenticate',

	GATEWAY_MEMORY_STATS: 'gateway:memory_stats',
	GATEWAY_RELOAD_ALL: 'gateway:reload_all',

	USER_LOOKUP: 'user:lookup',
	USER_LIST_SESSIONS: 'user:list:sessions',
	USER_LIST_GUILDS: 'user:list:guilds',
	USER_TERMINATE_SESSIONS: 'user:terminate:sessions',
	USER_UPDATE_MFA: 'user:update:mfa',
	USER_UPDATE_AVATAR: 'user:update:avatar',
	USER_UPDATE_BANNER: 'user:update:banner',
	USER_UPDATE_PROFILE: 'user:update:profile',
	USER_UPDATE_BOT_STATUS: 'user:update:bot_status',
	USER_UPDATE_EMAIL: 'user:update:email',
	USER_UPDATE_PHONE: 'user:update:phone',
	USER_UPDATE_DOB: 'user:update:dob',
	USER_UPDATE_USERNAME: 'user:update:username',
	USER_UPDATE_FLAGS: 'user:update:flags',
	USER_UPDATE_SUSPICIOUS_ACTIVITY: 'user:update:suspicious_activity',
	USER_TEMP_BAN: 'user:temp_ban',
	USER_DISABLE_SUSPICIOUS: 'user:disable:suspicious',
	USER_DELETE: 'user:delete',
	USER_CANCEL_BULK_MESSAGE_DELETION: 'user:cancel:bulk_message_deletion',
	PENDING_VERIFICATION_VIEW: 'pending_verification:view',
	PENDING_VERIFICATION_REVIEW: 'pending_verification:review',
	BETA_CODES_GENERATE: 'beta_codes:generate',
	GIFT_CODES_GENERATE: 'gift_codes:generate',

	GUILD_LOOKUP: 'guild:lookup',
	GUILD_LIST_MEMBERS: 'guild:list:members',
	GUILD_RELOAD: 'guild:reload',
	GUILD_SHUTDOWN: 'guild:shutdown',
	GUILD_DELETE: 'guild:delete',
	GUILD_UPDATE_NAME: 'guild:update:name',
	GUILD_UPDATE_ICON: 'guild:update:icon',
	GUILD_UPDATE_BANNER: 'guild:update:banner',
	GUILD_UPDATE_SPLASH: 'guild:update:splash',
	GUILD_UPDATE_VANITY: 'guild:update:vanity',
	GUILD_UPDATE_FEATURES: 'guild:update:features',
	GUILD_UPDATE_SETTINGS: 'guild:update:settings',
	GUILD_TRANSFER_OWNERSHIP: 'guild:transfer_ownership',
	GUILD_FORCE_ADD_MEMBER: 'guild:force_add_member',
	ASSET_PURGE: 'asset:purge',

	MESSAGE_LOOKUP: 'message:lookup',
	MESSAGE_DELETE: 'message:delete',
	MESSAGE_SHRED: 'message:shred',
	MESSAGE_DELETE_ALL: 'message:delete_all',

	BAN_IP_CHECK: 'ban:ip:check',
	BAN_IP_ADD: 'ban:ip:add',
	BAN_IP_REMOVE: 'ban:ip:remove',
	BAN_EMAIL_CHECK: 'ban:email:check',
	BAN_EMAIL_ADD: 'ban:email:add',
	BAN_EMAIL_REMOVE: 'ban:email:remove',
	BAN_PHONE_CHECK: 'ban:phone:check',
	BAN_PHONE_ADD: 'ban:phone:add',
	BAN_PHONE_REMOVE: 'ban:phone:remove',

	BULK_UPDATE_USER_FLAGS: 'bulk:update:user_flags',
	BULK_UPDATE_GUILD_FEATURES: 'bulk:update:guild_features',
	BULK_ADD_GUILD_MEMBERS: 'bulk:add:guild_members',
	ARCHIVE_VIEW_ALL: 'archive:view_all',
	ARCHIVE_TRIGGER_USER: 'archive:trigger:user',
	ARCHIVE_TRIGGER_GUILD: 'archive:trigger:guild',
	BULK_DELETE_USERS: 'bulk:delete:users',

	AUDIT_LOG_VIEW: 'audit_log:view',

	REPORT_VIEW: 'report:view',
	REPORT_RESOLVE: 'report:resolve',

	VOICE_REGION_LIST: 'voice:region:list',
	VOICE_REGION_CREATE: 'voice:region:create',
	VOICE_REGION_UPDATE: 'voice:region:update',
	VOICE_REGION_DELETE: 'voice:region:delete',
	VOICE_SERVER_LIST: 'voice:server:list',
	VOICE_SERVER_CREATE: 'voice:server:create',
	VOICE_SERVER_UPDATE: 'voice:server:update',
	VOICE_SERVER_DELETE: 'voice:server:delete',

	ACL_SET_USER: 'acl:set:user',

	INSTANCE_CONFIG_VIEW: 'instance:config:view',
	INSTANCE_CONFIG_UPDATE: 'instance:config:update',

	METRICS_VIEW: 'metrics:view',

	FEATURE_FLAG_VIEW: 'feature_flag:view',
	FEATURE_FLAG_MANAGE: 'feature_flag:manage',
} as const;
