local stringUtil = require("util.string")

return {
    -- scraper
    {
        key = "scraper_overwrite",
        type = "boolean",
        default = false,
        label = "Overwrite",
        group = "scraper",
        description = "When scraping in batch, 'true' will ignore existing media and overwrite it. 'false' will only scrape for missing media",
    },
    {
        key = "scraper_libretro_enabled",
        type = "boolean",
        default = true,
        label = "Libretro",
        group = "scraper",
        description = "If enabled will use `thumbnails.libretro.com` as a source for screenshot, wheel, box2d",
    },
    {
        key = "scraper_screenscraper_enabled",
        type = "boolean",
        default = true,
        label = "Screenscraper",
        group = "scraper",
        description = "If enabled will use `screenscraper.fr` as a source for screenshot, wheel, box2d, box3d",
    },
    {
        key = "scraper_screenscraper_user",
        type = "string",
        default = "",
        label = "Screenscraper User",
        group = "scraper",
        description = "Username from registered account on screenscraper.fr",
    },
    {
        key = "scraper_screenscraper_password",
        type = "string",
        default = "",
        label = "Screenscraper Password",
        group = "scraper",
        description = "Password from registered account on screenscraper.fr",
        options = { obfuscate = true },
    },
    {
        key = "scraper_screenscraper_preferred_regions",
        type = "reorder",
        default = { "wor", "us", "eu", "uk", "jp", "fr", "xx" },
        values = { "wor", "us", "eu", "uk", "jp", "fr", "xx" },
        label = "Screenscraper Regions",
        group = "scraper",
        description = "The order of regions to prefer when scraping from screenscraper.fr. Use A/B to swap order",
        options = { obfuscate = true },
    },
    {
        key = "scraper_screenscraper_preferred_languages",
        type = "reorder",
        default = { "en", "es", "it", "de", "fr", "jp" },
        values = { "en", "es", "it", "de", "fr", "jp" },
        label = "Screenscraper Languages",
        group = "scraper",
        description = "The order of languages to prefere when scraping from screenscraper.fr. Use A/B to swap order",
        options = { obfuscate = true },
    },
    {
        key = "scraper_steamgriddb_enabled",
        type = "boolean",
        default = false,
        label = "SteamGridDB",
        group = "scraper",
        description = "If enabled will use `SteamGridDB` as a source for wheel, grid1x1, grid2x3",
    },
    {
        key = "scraper_steamgriddb_api_token",
        type = "string",
        default = "",
        label = "SteamGridDB Token",
        group = "scraper",
        description = "SteamGridDB API Token (Generate one in your account section)",
        options = { obfuscate = true },
    },
    {
        key = "scraper_steamgriddb_use_thumb",
        type = "boolean",
        default = true,
        label = "SteamGridDB Thumbs",
        group = "scraper",
        description = "If enabled will use the 'thumb' url instead of the 'full' url for SteamGridDB image downloads. These files are much smaller although lower resolution/quality than the full size versions",
    },
    {
        key = "scraper_steamgriddb_search_qty",
        type = "number",
        default = 25,
        options = {
            max = 50,
            min = 1,
        },
        label = "SteamGridDB Search Qty",
        group = "scraper",
        description = "This changes the number of results returned by SteamGridDB when doing a manual scrape/search. Lowering the qty will improve speed at the cost of less results",
    },
    {
        key = "scraper_file_enabled",
        type = "boolean",
        default = false,
        label = "File Scraper",
        group = "scraper",
        description = "If enabled will use the local filesystem as a media source (useful) for roms that cant be scraped like hacks and homebrew",
    },
    {
        key = "scraper_tgdb_enabled",
        type = "boolean",
        default = false,
        label = "TGDB",
        group = "scraper",
        description = "Enables thegamesdb.net (TGDB) as a source for scraping",
    },
    {
        key = "scraper_tgdb_use_thumb",
        type = "boolean",
        default = true,
        label = "TGDB Thumbs",
        group = "scraper",
        description = "If enabled will use the 'thumb' url instead of the 'original' url for TGDB image downloads. These files are much smaller although lower resolution/quality than the full size versions",
    },
    {
        key = "scraper_priority",
        type = "reorder",
        default = { "file", "libretro", "screenscraper", "steamgriddb", "tgdb" },
        values = { "file", "libretro", "screenscraper", "steamgriddb", "tgdb" },
        label = "Scraper Priority",
        group = "scraper",
        description = "The order scrapers are called when performing an automatic scrape (if scrapers are disabled then they won't be used). Highly recommended to retain the default order",
    },
    {
        key = "scanner_max_crc32_size",
        type = "select",
        default = 33554432,
        values = { 8388608, 16777216, 33554432, 67108864, 134217728 },
        options = {
            keyTransformer = function(v)
                return stringUtil.formatBytes(v, 0)
            end,
        },
        label = "Max CRC32",
        group = "scraper",
        description = "The largest filesize that the scanner will calculate crc32 for. Larger sizes allow more roms to be verified at a cost of slower scanning. Largest values may crash the device",
    },
    {
        key = "scraper_screenscraper_burnthrough",
        type = "select",
        default = 3,
        values = { 1, 3, 6, 12, 24 },
        label = "Screenscraper Burnthrough",
        group = "scraper",
        description = "An amount of time to ration your daily scrape rate. Will calculate the scrape rate to ensure you can scrape for this amount of time. You shouldn't have to change this",
        options = {
            keyTransformer = function(v)
                return v .. " Hours"
            end,
        },
        hidden = true,
    },
    {
        key = "scraper_screenscraper_threads",
        type = "number",
        default = 1,
        options = {
            max = 10,
            min = 1,
        },
        label = "Screenscraper Threads",
        group = "scraper",
        description = "Number of threads to use. Setting this higher that the number of threads you have access to on screenscraper.fr will cause the scrape process to fail. If you dont know how many threads you have access to or how to acquire more then LEAVE this at 1.",
    },
    {
        key = "scraper_skip_offset",
        type = "number",
        default = 14,
        options = {
            max = 28,
            min = 0,
        },
        label = "Scraper Miss Skip Days",
        group = "scraper",
        description = "If the scraper hits a 404/miss for a given rom input then it wont be rechecked again for X number of days. If the rom details change then the rom will always be rechecked. Set to 0 to disable (not recommended)",
    },
    --env
    {
        key = "env_rom_path",
        type = "string",
        default = "/home/user/roms",
        label = "Rom Path",
        group = "env",
        description = "Used on desktop only, the path to your rom folder",
        hidden = true,
    },
    {
        key = "env_catalog_path",
        type = "string",
        default = "/home/user/catalog",
        label = "Catalog Path",
        group = "env",
        description = "Used on desktop only, the path to the catalog (pack/output) folder",
        hidden = true,
    },
    {
        key = "env_muos_info_core_path",
        type = "string",
        default = "/home/user/muos/info/core",
        label = "Info Core Path",
        group = "env",
        description = "Used on desktop only, the path to a valid muOS info/core folder",
        hidden = true,
    },
    {
        key = "env_muos_assign_path",
        type = "string",
        default = "/home/user/muos/info/assign.json",
        label = "Assign.json Path",
        group = "env",
        description = "Used on desktop only, the path to a valid muOs assign.json file",
        hidden = true,
    },
    {
        key = "env_debug_menu",
        type = "boolean",
        default = false,
        label = "Debug Menu",
        group = "env",
        description = "Shows the debug menu in the main navigation",
        hidden = true,
    },
    {
        key = "env_use_gamepad",
        type = "boolean",
        default = false,
        label = "Use Gamepad",
        group = "env",
        description = "If set to true then loads gamecontrollerdb.txt for gamepad use on desktop (desktop only)",
        hidden = true,
    },
    --log
    {
        key = "log_file",
        type = "boolean",
        default = true,
        label = "File Logger",
        group = "log",
        description = "Saves log messages to a file in the data folder. Requires app reload after changing",
    },
    {
        key = "log_file_level",
        type = "select",
        default = "debug",
        values = { "debug", "info", "warn", "error", "fatal" },
        label = "File Log Level",
        group = "log",
        description = "File Logger Verbosity. Requires app reload after changing",
    },
    {
        key = "log_console",
        type = "boolean",
        default = true,
        label = "Console Logger",
        group = "log",
        description = "Saves log messages to the console. Toggle the console with 'select'. Requires app reload after changing",
    },
    {
        key = "log_console_level",
        type = "select",
        default = "info",
        values = { "debug", "info", "warn", "error", "fatal" },
        label = "Console Log Level",
        group = "log",
        description = "Console Logger Verbosity. Requires app reload after changing",
    },
    {
        key = "log_print",
        type = "boolean",
        default = false,
        label = "Print Logger",
        group = "log",
        description = "Prints log messages to the console (use in dev only). Requires app reload after changing",
        hidden = true,
    },
    {
        key = "log_print_level",
        type = "select",
        default = "debug",
        values = { "debug", "info", "warn", "error", "fatal" },
        label = "Print Log Level",
        group = "log",
        description = "Print Logger Verbosity. Requires app reload after changing",
        hidden = true,
    },
    {
        key = "log_mute_channels",
        type = "reorder",
        default = {},
        values = {},
        label = "Log Mute Channels",
        group = "log",
        description = "Log channels in this table will be excluded from logging, eg `{ 'scraper', 'screenscraper', 'steamgriddb' }`",
        hidden = true,
    },
    -- media
    {
        key = "media_box2d_enabled",
        type = "boolean",
        default = true,
        label = "Enable Box2D",
        group = "media",
        description = "Should scrape for box2D?",
    },
    {
        key = "media_wheel_enabled",
        type = "boolean",
        default = true,
        label = "Enable Wheel",
        group = "media",
        description = "Should scrape for wheel (wheel is jargon for 'game logo')?",
    },
    {
        key = "media_box3d_enabled",
        type = "boolean",
        default = true,
        label = "Enable Box3D",
        group = "media",
        description = "Should scrape for box3D?",
    },
    {
        key = "media_grid1x1_enabled",
        type = "boolean",
        default = false,
        label = "Enable 1x1 Grid",
        group = "media",
        description = "Should scrape for 1x1 Grid?",
    },
    {
        key = "media_grid2x3_enabled",
        type = "boolean",
        default = false,
        label = "Enable 2x3 Grid",
        group = "media",
        description = "Should scrape for 2x3 Grid?",
    },
    -- mix
    {
        key = "mix_overwrite",
        type = "boolean",
        default = true,
        label = "Overwrite Mix",
        group = "mix",
        description = "Should existing mix images be overwritten when running the mix process?",
    },
    {
        key = "mix_header_y",
        type = "number",
        default = 42,
        options = {
            max = 100,
            min = 1,
        },
        label = "Header Height",
        group = "mix",
        description = "If `exclude header/footer` is chosen when mixing, this is the height that will be used for the header",
    },
    {
        key = "mix_footer_y",
        type = "number",
        default = 42,
        options = {
            max = 100,
            min = 1,
        },
        label = "Footer Height",
        group = "mix",
        description = "If `exclude header/footer` is chosen when mixing, this is the height that will be used for the footer",
    },
    {
        key = "mix_custom_bg_hex",
        type = "string",
        default = "BADA55",
        label = "BG Custom Hex",
        group = "mix",
        description = "6 Digit color hex to use when setting 'BG Color' to 'custom'",
    },
    -- pack
    {
        key = "pack_sd_card",
        type = "select",
        default = "auto",
        values = { "auto", "sd1", "sd2" },
        label = "SD Target",
        group = "pack",
        description = "What SD Card to pack the artwork to. 'Auto' assumes that if you have an sd2 card in the device then you want to pack assets to that card",
        order = 1,
    },
    {
        key = "pack_archive",
        type = "boolean",
        default = false,
        label = "Create Archive",
        group = "pack",
        description = "Creates a '.muxcat' catalog archive instead of moving files directly to catalog (useful to allow you to store multiple artwork sets)",
    },
    {
        key = "pack_archive_name_strategy",
        type = "select",
        default = "date",
        values = { "date", "custom" },
        label = "Archive Name Strategy",
        group = "pack",
        description = "If `archive` mode is selected then this controls how the archive is named. `date` names the archive using todays date, similar to the muos default. `custom` uses the entered value of `Archive Name` below",
    },
    {
        key = "pack_archive_name_custom",
        type = "string",
        default = "boxart_buddy_catalog",
        label = "Archive Name",
        group = "pack",
        description = "Used as the filename of the archive if `custom` name strategy selected",
    },
    -- ui
    {
        key = "ui_mute_sound",
        type = "boolean",
        default = false,
        label = "Mute Sound",
        group = "ui",
        description = "Mutes sound effects, warning etc.",
    },
    {
        key = "ui_skip_splash",
        type = "boolean",
        default = false,
        label = "Skip Splash",
        group = "ui",
        description = "Skips the splash screen when starting up the program",
    },
    {
        key = "ui_thread_pool_console",
        type = "boolean",
        default = false,
        label = "Console Thread Debug",
        group = "ui",
        description = "Show thread pool debug information in the console",
    },
    -- sys
    {
        key = "sys_full_reset",
        type = "button",
        label = "Full Reset (Deletes all data)",
        group = "sys",
        description = "Replaces the database with a clean copy and wipes the cache, removing all scraped images, mixes etc",
        options = { buttonWidth = SCREEN.wUnit(15), buttonHeight = SCREEN.hUnit(3), labelWidth = 0, align = "center" },
    },
}
