// Gupaxx - GUI Uniting P2Pool And XMRig
//
// Copyright (c) 2022-2023 hinto-janai
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

pub const GUPAX_VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION")); // e.g: v1.0.0
pub const P2POOL_VERSION: &str = "v3.10";
pub const XMRIG_VERSION: &str = "v6.21.1";
pub const COMMIT: &str = env!("COMMIT"); // set in build.rs
                                         // e.g: Gupax_v1_0_0
                                         // Would have been [Gupax_v1.0.0] but P2Pool truncates everything after [.]
pub const GUPAX_VERSION_UNDERSCORE: &str = concat!(
    "Gupaxx_v",
    env!("CARGO_PKG_VERSION_MAJOR"),
    "_",
    env!("CARGO_PKG_VERSION_MINOR"),
    "_",
    env!("CARGO_PKG_VERSION_PATCH"),
);

// App frame resolution, [4:3] aspect ratio, [1.33:1]
pub const APP_MIN_WIDTH: f32 = 640.0;
pub const APP_MIN_HEIGHT: f32 = 480.0;
pub const APP_MAX_WIDTH: f32 = 3840.0;
pub const APP_MAX_HEIGHT: f32 = 2160.0;
// Default, 1280x960
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
pub const APP_DEFAULT_HEIGHT: f32 = 960.0;
// App resolution scaling
pub const APP_MIN_SCALE: f32 = 0.1;
pub const APP_MAX_SCALE: f32 = 2.0;
pub const APP_DEFAULT_SCALE: f32 = 1.0;

// Constants specific for Linux distro packaging of Gupax
#[cfg(feature = "distro")]
pub const DISTRO_NO_UPDATE: &str = r#"This [Gupaxx] was compiled for use as a Linux distro package. Built-in updates are disabled. The below settings [Update-via-Tor] & [Auto-Update] will not do anything. Please use your package manager to update [Gupaxx/P2Pool/XMRig]."#;

// Use macOS shaped icon for macOS
#[cfg(target_os = "macos")]
pub const BYTES_ICON: &[u8] = include_bytes!("../../assets/images/icons/icon@2x.png");
#[cfg(not(target_os = "macos"))]
pub const BYTES_ICON: &[u8] = include_bytes!("../../assets/images/icons/icon.png");
pub const BYTES_XVB: &[u8] = include_bytes!("../../assets/images/xvb.png");
pub const BYTES_BANNER: &[u8] = include_bytes!("../../assets/images/banner.png");
pub const HORIZONTAL: &str = "--------------------------------------------";
pub const HORI_CONSOLE: &str = "---------------------------------------------------------------------------------------------------------------------------";

// Keyboard shortcuts
pub const KEYBOARD_SHORTCUTS: &str = r#"*---------------------------------------*
|             Key shortcuts             |
|---------------------------------------|
|             F11 | Fullscreen          |
|          Escape | Quit screen         |
|              Up | Start/Restart       |
|            Down | Stop                |
|               Z | Left Tab            |
|               X | Right Tab           |
|               C | Left Submenu        |
|               V | Right Submenu       |
|               S | Save                |
|               R | Reset               |
*---------------------------------------*"#;
// P2Pool & XMRig default API stuff
#[cfg(target_os = "windows")]
pub const P2POOL_API_PATH_LOCAL: &str = r"local\stratum";
#[cfg(target_os = "windows")]
pub const P2POOL_API_PATH_NETWORK: &str = r"network\stats";
#[cfg(target_os = "windows")]
pub const P2POOL_API_PATH_POOL: &str = r"pool\stats";
#[cfg(target_family = "unix")]
pub const P2POOL_API_PATH_LOCAL: &str = "local/stratum";
#[cfg(target_family = "unix")]
pub const P2POOL_API_PATH_NETWORK: &str = "network/stats";
#[cfg(target_family = "unix")]
pub const P2POOL_API_PATH_POOL: &str = "pool/stats";
pub const XMRIG_API_URI: &str = "1/summary"; // The default relative URI of XMRig's API
pub const XMRIG_CONFIG_URI: &str = "http://127.0.0.1:18088/1/config"; // The default relative URI of XMRig's API config

// Process state tooltips (online, offline, etc)
pub const P2POOL_ALIVE: &str = "P2Pool is online and fully synchronized";
pub const P2POOL_DEAD: &str = "P2Pool is offline";
pub const P2POOL_FAILED: &str = "P2Pool is offline and failed when exiting";
pub const P2POOL_MIDDLE: &str = "P2Pool is in the middle of (re)starting/stopping";
pub const P2POOL_SYNCING: &str =
    "P2Pool is still syncing. This indicator will turn GREEN when P2Pool is ready";

pub const XMRIG_ALIVE: &str = "XMRig is online and mining";
pub const XMRIG_DEAD: &str = "XMRig is offline";
pub const XMRIG_FAILED: &str = "XMRig is offline and failed when exiting";
pub const XMRIG_MIDDLE: &str = "XMRig is in the middle of (re)starting/stopping";
pub const XMRIG_NOT_MINING: &str = "XMRig is online, but not mining to any pool";

pub const XVB_ALIVE: &str =
    "XvB process is configured and distributing hashrate, XvB node is online";
pub const XVB_DEAD: &str = "XvB process is offline";
pub const XVB_FAILED: &str = "XvB process is misconfigured or the XvB node is offline";
pub const XVB_MIDDLE: &str = "XvB is in the middle of (re)starting/stopping";
pub const XVB_NOT_CONFIGURED: &str = "You need to insert an existent token before starting XvB";
pub const XVB_PUBLIC_ONLY: &str = "XvB process is started only to get public stats.";

// This is the typical space added when using
// [ui.separator()] or [ui.group()]
// Used for subtracting the width/height so
// things actually line up.
pub const SPACE: f32 = 10.0;

// Some colors
pub const RED: egui::Color32 = egui::Color32::from_rgb(230, 50, 50);
pub const GREEN: egui::Color32 = egui::Color32::from_rgb(100, 230, 100);
// pub const BLUE: egui::Color32 = egui::Color32::from_rgb(100, 175, 255);
pub const ORANGE: egui::Color32 = egui::Color32::from_rgb(255, 120, 40);
pub const YELLOW: egui::Color32 = egui::Color32::from_rgb(230, 230, 100);
pub const BRIGHT_YELLOW: egui::Color32 = egui::Color32::from_rgb(250, 250, 100);
pub const BONE: egui::Color32 = egui::Color32::from_rgb(190, 190, 190); // In between LIGHT_GRAY <-> GRAY
pub const GRAY: egui::Color32 = egui::Color32::GRAY;
pub const LIGHT_GRAY: egui::Color32 = egui::Color32::LIGHT_GRAY;
pub const BLACK: egui::Color32 = egui::Color32::BLACK;
pub const DARK_GRAY: egui::Color32 = egui::Color32::from_gray(13);

// [Duration] constants
pub const SECOND: std::time::Duration = std::time::Duration::from_secs(1);

// The explanation given to the user on why XMRig needs sudo.
pub const XMRIG_ADMIN_REASON: &str = r#"The large hashrate difference between XMRig and other miners like Monero and P2Pool's built-in miners is mostly due to XMRig configuring CPU MSRs and setting up hugepages. Other miners like Monero or P2Pool's built-in miner do not do this. It can be done manually but it isn't recommended since XMRig does this for you automatically, but only if it has the proper admin privileges."#;
// Password buttons
pub const PASSWORD_TEXT: &str = "Enter sudo/admin password...";
pub const PASSWORD_LEAVE: &str = "Return to the previous screen";
pub const PASSWORD_ENTER: &str = "Attempt with the current password";
pub const PASSWORD_HIDE: &str = "Toggle hiding/showing the password";

// OS specific
#[cfg(target_os = "windows")]
pub const OS: &str = " Windows";
#[cfg(target_os = "windows")]
pub const OS_NAME: &str = "Windows";
#[cfg(target_os = "windows")]
pub const WINDOWS_NOT_ADMIN: &str = "XMRig will most likely mine slower than normal without Administrator permissions. Please consider restarting Gupaxx as an Administrator.";

#[cfg(target_os = "macos")]
pub const OS: &str = " macOS";
#[cfg(target_os = "macos")]
pub const OS_NAME: &str = "macOS";

#[cfg(target_os = "linux")]
pub const OS: &str = "🐧 Linux";
#[cfg(target_os = "linux")]
pub const OS_NAME: &str = "Linux";

// Tooltips
// Status
pub const STATUS_GUPAX_UPTIME: &str = "How long Gupaxx has been online";
pub const STATUS_GUPAX_CPU_USAGE: &str =
    "How much CPU Gupaxx is currently using. This accounts for all your threads (it is out of 100%)";
pub const STATUS_GUPAX_MEMORY_USAGE: &str =
    "How much memory Gupaxx is currently using in Megabytes";
pub const STATUS_GUPAX_SYSTEM_CPU_USAGE: &str = "How much CPU your entire system is currently using. This accounts for all your threads (it is out of 100%)";
pub const STATUS_GUPAX_SYSTEM_MEMORY: &str =
    "How much memory your entire system has (including swap) and is currently using in Gigabytes";
pub const STATUS_GUPAX_SYSTEM_CPU_MODEL: &str =
    "The detected model of your system's CPU and its current frequency";
//--
pub const STATUS_P2POOL_UPTIME: &str = "How long P2Pool has been online";
pub const STATUS_P2POOL_PAYOUTS:     &str = "The total amount of payouts received in this instance of P2Pool and an extrapolated estimate of how many you will receive. Warning: these stats will be quite inaccurate if your P2Pool hasn't been running for a long time!";
pub const STATUS_P2POOL_XMR:         &str = "The total amount of XMR mined in this instance of P2Pool and an extrapolated estimate of how many you will mine in the future. Warning: these stats will be quite inaccurate if your P2Pool hasn't been running for a long time!";
pub const STATUS_P2POOL_HASHRATE:    &str = "The total amount of hashrate your P2Pool has pointed at it in 15 minute, 1 hour, and 24 hour averages";
pub const STATUS_P2POOL_SHARES: &str = "The total amount of shares found on P2Pool";
pub const STATUS_P2POOL_CURRENT_SHARES: &str =
    "Current shares valid in the PPLNS Window for your address";
pub const STATUS_P2POOL_EFFORT: &str =
    "The average amount of effort needed to find a share, and the current effort";
pub const STATUS_P2POOL_CONNECTIONS: &str = "The total amount of miner connections on this P2Pool";
pub const STATUS_P2POOL_MONERO_NODE: &str = "The Monero node being used by P2Pool";
pub const STATUS_P2POOL_POOL: &str = "The P2Pool sidechain you're currently connected to";
pub const STATUS_P2POOL_ADDRESS: &str = "The Monero address P2Pool will send payouts to";
//--
pub const STATUS_XMRIG_UPTIME: &str = "How long XMRig has been online";
pub const STATUS_XMRIG_CPU:         &str = "The average CPU load of XMRig. [1.0] represents 1 thread is maxed out, e.g: If you have 8 threads, [4.0] means half your threads are maxed out.";
pub const STATUS_XMRIG_HASHRATE: &str = "The average hashrate of XMRig";
pub const STATUS_XMRIG_DIFFICULTY: &str = "The current difficulty of the job XMRig is working on";
pub const STATUS_XMRIG_SHARES: &str = "The amount of accepted and rejected shares";
pub const STATUS_XMRIG_POOL: &str = "The pool XMRig is currently mining to";
pub const STATUS_XMRIG_THREADS: &str = "The amount of threads XMRig is currently using";
//--
pub const STATUS_XVB_TIME_REMAIN: &str = "Minutes left before end of round";
pub const STATUS_XVB_ROUND_TYPE: &str = "The current round type";
pub const STATUS_XVB_PLAYERS: &str =
    "Numbers of registered players and currently playing in the round";
pub const STATUS_XVB_DONATED_HR: &str = "Hashrate donated to the raffle";
pub const STATUS_XVB_WINNER: &str = "Current Raffle Winner";
pub const STATUS_XVB_SHARE: &str = "Share effort";
pub const STATUS_XVB_BLOCK_REWARD: &str = "Block reward";
pub const STATUS_XVB_YEARLY: &str = "Estimated Reward (Yearly)";
// Status Submenus
pub const STATUS_SUBMENU_PROCESSES: &str =
    "View the status of process related data for [Gupaxx|P2Pool|XMRig]";
pub const STATUS_SUBMENU_P2POOL: &str = "View P2Pool specific data";
pub const STATUS_SUBMENU_HASHRATE: &str = "Compare your CPU hashrate with others";
//-- P2Pool
pub const STATUS_SUBMENU_PAYOUT:    &str = "The total amount of payouts received via P2Pool across all time. This includes all payouts you have ever received using Gupaxx and P2Pool.";
pub const STATUS_SUBMENU_XMR:       &str = "The total of XMR mined via P2Pool across all time. This includes all the XMR you have ever mined using Gupaxx and P2Pool.";
pub const STATUS_SUBMENU_LATEST: &str = "Sort the payouts from latest to oldest";
pub const STATUS_SUBMENU_OLDEST: &str = "Sort the payouts from oldest to latest";
pub const STATUS_SUBMENU_BIGGEST: &str = "Sort the payouts from biggest to smallest";
pub const STATUS_SUBMENU_SMALLEST: &str = "Sort the payouts from smallest to biggest";
pub const STATUS_SUBMENU_AUTOMATIC: &str =
    "Automatically calculate share/block time with your current P2Pool 1 hour average hashrate";
pub const STATUS_SUBMENU_MANUAL:    &str = "Manually input a hashrate to calculate share/block time with current P2Pool/Monero network stats";
pub const STATUS_SUBMENU_HASH: &str = "Use [Hash] as the hashrate metric";
pub const STATUS_SUBMENU_KILO: &str = "Use [Kilo] as the hashrate metric (1,000x hash)";
pub const STATUS_SUBMENU_MEGA: &str = "Use [Mega] as the hashrate metric (1,000,000x hash)";
pub const STATUS_SUBMENU_GIGA: &str = "Use [Giga] as the hashrate metric (1,000,000,000x hash)";
pub const STATUS_SUBMENU_P2POOL_BLOCK_MEAN: &str =
    "The average time it takes for P2Pool to find a block";
pub const STATUS_SUBMENU_YOUR_P2POOL_HASHRATE: &str = "Your 1 hour average hashrate on P2Pool";
pub const STATUS_SUBMENU_P2POOL_SHARE_MEAN: &str =
    "The average time it takes for your hashrate to find a share on P2Pool";
pub const STATUS_SUBMENU_SOLO_BLOCK_MEAN: &str =
    "The average time it would take for your hashrate to find a block solo mining Monero";
pub const STATUS_SUBMENU_MONERO_DIFFICULTY:     &str = "The current Monero network's difficulty (how many hashes it will take on average to find a block)";
pub const STATUS_SUBMENU_MONERO_HASHRATE: &str = "The current Monero network's hashrate";
pub const STATUS_SUBMENU_P2POOL_DIFFICULTY:     &str = "The current P2Pool network's difficulty (how many hashes it will take on average to find a share)";
pub const STATUS_SUBMENU_P2POOL_HASHRATE: &str = "The current P2Pool network's hashrate";
pub const STATUS_SUBMENU_P2POOL_MINERS: &str = "The current amount of miners on P2Pool";
pub const STATUS_SUBMENU_P2POOL_DOMINANCE: &str =
    "The percent of hashrate P2Pool accounts for in the entire Monero network";
pub const STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE: &str =
    "The percent of hashrate you account for in P2Pool";
pub const STATUS_SUBMENU_YOUR_MONERO_DOMINANCE: &str =
    "The percent of hashrate you account for in the entire Monero network";
pub const STATUS_SUBMENU_PROGRESS_BAR:          &str = "The next time Gupaxx will update P2Pool stats. Each [*] is 900ms (updates roughly every 54 seconds)";
//-- Benchmarks
pub const STATUS_SUBMENU_YOUR_CPU: &str = "The CPU detected by Gupaxx";
pub const STATUS_SUBMENU_YOUR_BENCHMARKS: &str =
    "How many benchmarks your CPU has had uploaded to [https://xmrig.com/benchmark] ";
pub const STATUS_SUBMENU_YOUR_RANK: &str =
    "Your CPU's rank out of all CPUs listed on [https://xmrig.com/benchmark] (higher is better)";
pub const STATUS_SUBMENU_YOUR_HIGH: &str =
    "The highest hashrate recorded for your CPU on [https://xmrig.com/benchmark]";
pub const STATUS_SUBMENU_YOUR_AVERAGE: &str =
    "The average hashrate of your CPU based off the data at [https://xmrig.com/benchmark]";
pub const STATUS_SUBMENU_YOUR_LOW: &str =
    "The lowest hashrate recorded for your CPU on [https://xmrig.com/benchmark]";
pub const STATUS_SUBMENU_OTHER_CPUS:       &str = "A list of ALL the recorded CPU benchmarks. The CPUs most similar to yours are listed first. All this data is taken from [https://xmrig.com/benchmark].";
pub const STATUS_SUBMENU_OTHER_CPU: &str = "The CPU name";
pub const STATUS_SUBMENU_OTHER_RELATIVE:   &str = "The relative hashrate power compared to the fastest recorded CPU, which is current: [AMD EPYC 7T83 64-Core Processor]";
pub const STATUS_SUBMENU_OTHER_HIGH: &str = "Highest hashrate record";
pub const STATUS_SUBMENU_OTHER_AVERAGE: &str = "Average hashrate";
pub const STATUS_SUBMENU_OTHER_LOW: &str = "Lowest hashrate record";
pub const STATUS_SUBMENU_OTHER_RANK: &str = "The rank of this CPU out of [1567] (lower is better)";
pub const STATUS_SUBMENU_OTHER_BENCHMARKS: &str =
    "How many benchmarks this CPU has had posted to [https://xmrig.com/benchmark]";

// Gupaxx
pub const GUPAX_UPDATE: &str =
    "Check for updates on Gupaxx, P2Pool, and XMRig via GitHub's API and upgrade automatically";
pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup";
pub const GUPAX_SHOULD_RESTART: &str =
    "Gupaxx was updated. A restart is recommended but not required";
// #[cfg(not(target_os = "macos"))]
// pub const GUPAX_UPDATE_VIA_TOR:   &str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
// #[cfg(target_os = "macos")] // Arti library has issues on macOS
// pub const GUPAX_UPDATE_VIA_TOR:   &str = "WARNING: This option is unstable on macOS. Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
pub const GUPAX_ASK_BEFORE_QUIT: &str = "Ask before quitting Gupaxx";
pub const GUPAX_SAVE_BEFORE_QUIT: &str = "Automatically save any changed settings before quitting";
pub const GUPAX_AUTO_P2POOL:      &str = "Automatically start P2Pool on Gupaxx startup. If you are using [P2Pool Simple], this will NOT wait for your [Auto-Ping] to finish, it will start P2Pool on the pool you already have selected. This option will fail if your P2Pool settings aren't valid!";
pub const GUPAX_AUTO_XMRIG:       &str = "Automatically start XMRig on Gupaxx startup. This option will fail if your XMRig settings aren't valid!";
pub const GUPAX_AUTO_XVB:       &str = "Automatically start XvB on Gupaxx startup. This option will fail if your XvB settings aren't valid!";
pub const GUPAX_ADJUST: &str = "Adjust and set the width/height of the Gupaxx window";
pub const GUPAX_WIDTH: &str = "Set the width of the Gupaxx window";
pub const GUPAX_HEIGHT: &str = "Set the height of the Gupaxx window";
pub const GUPAX_SCALE: &str =
    "Set the resolution scaling of the Gupaxx window (resize window to re-apply scaling)";
pub const GUPAX_LOCK_WIDTH: &str =
    "Automatically match the HEIGHT against the WIDTH in a 4:3 ratio";
pub const GUPAX_LOCK_HEIGHT: &str =
    "Automatically match the WIDTH against the HEIGHT in a 4:3 ratio";
pub const GUPAX_NO_LOCK: &str = "Allow individual selection of width and height";
pub const GUPAX_SET: &str = "Set the width/height of the Gupaxx window to the current values";
pub const GUPAX_TAB: &str = "Set the default tab Gupaxx starts on";
pub const GUPAX_TAB_ABOUT: &str = "Set the tab Gupaxx starts on to: About";
pub const GUPAX_TAB_STATUS: &str = "Set the tab Gupaxx starts on to: Status";
pub const GUPAX_TAB_GUPAX: &str = "Set the tab Gupaxx starts on to: Gupaxx";
pub const GUPAX_TAB_P2POOL: &str = "Set the tab Gupaxx starts on to: P2Pool";
pub const GUPAX_TAB_XMRIG: &str = "Set the tab Gupaxx starts on to: XMRig";
pub const GUPAX_TAB_XVB: &str = "Set the tab Gupaxx starts on to: XvB";

pub const GUPAX_SIMPLE: &str = r#"Use simple Gupaxx settings:
  - Update button
  - Basic toggles"#;
pub const GUPAX_ADVANCED: &str = r#"Use advanced Gupaxx settings:
  - Update button
  - Basic toggles
  - P2Pool/XMRig binary path selector
  - Gupaxx resolution sliders
  - Gupaxx start-up tab selector"#;
pub const GUPAX_SELECT: &str = "Open a file explorer to select a file";
pub const GUPAX_PATH_P2POOL: &str = "The location of the P2Pool binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";
pub const GUPAX_PATH_XMRIG: &str = "The location of the XMRig binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";

// P2Pool
pub const P2POOL_MAIN:                   &str = "Use the P2Pool main-chain. This P2Pool finds blocks faster, but has a higher difficulty. Suitable for miners with more than 50kH/s";
pub const P2POOL_MINI:                   &str = "Use the P2Pool mini-chain. This P2Pool finds blocks slower, but has a lower difficulty. Suitable for miners with less than 50kH/s";
pub const P2POOL_OUT: &str = "How many out-bound peers to connect to? (you connecting to others)";
pub const P2POOL_IN: &str = "How many in-bound peers to allow? (others connecting to you)";
pub const P2POOL_LOG: &str = "Verbosity of the console log";
pub const P2POOL_AUTO_NODE: &str = "Automatically ping the remote Monero nodes at Gupaxx startup";
pub const P2POOL_AUTO_SELECT: &str =
    "Automatically select the fastest remote Monero node after pinging";
pub const P2POOL_BACKUP_HOST_SIMPLE: &str = r#"Automatically switch to the other nodes listed if the current one is down.

Note: you must ping the remote nodes or this feature will default to only using the currently selected node."#;
pub const P2POOL_BACKUP_HOST_ADVANCED: &str =
    "Automatically switch to the other nodes in your list if the current one is down.";
pub const P2POOL_SELECT_FASTEST: &str = "Select the fastest remote Monero node";
pub const P2POOL_SELECT_RANDOM: &str = "Select a random remote Monero node";
pub const P2POOL_SELECT_LAST: &str = "Select the previous remote Monero node";
pub const P2POOL_SELECT_NEXT: &str = "Select the next remote Monero node";
pub const P2POOL_PING: &str = "Ping the built-in remote Monero nodes";
pub const P2POOL_ADDRESS:                &str = "You must use a primary Monero address to mine on P2Pool (starts with a 4). It is highly recommended to create a new wallet since addresses are public on P2Pool!";
pub const P2POOL_COMMUNITY_NODE_WARNING: &str = r#"TL;DR: Run & use your own Monero Node.

Using a Remote Monero Node is convenient but comes at the cost of privacy and reliability.

You may encounter connection issues with remote nodes which may cause mining performance loss! Late info from laggy nodes will cause your mining jobs to start later than they should.

Running and using your own local Monero node improves privacy and ensures your connection is as stable as your own internet connection. This comes at the cost of downloading and syncing Monero's blockchain yourself (currently 170GB). If you have the disk space, consider using the [Advanced] tab and connecting to your own Monero node.

For a simple guide, see the [Running a Local Monero Node] section on Gupaxx s GitHub by clicking this message."#;

pub const P2POOL_INPUT: &str = "Send a command to P2Pool";
pub const P2POOL_ARGUMENTS: &str = r#"WARNING: Use [--no-color] and make sure to set [--data-api <PATH>] & [--local-api] so that the [Status] tab can work!

Start P2Pool with these arguments and override all below settings"#;
pub const P2POOL_SIMPLE: &str = r#"Use simple P2Pool settings:
  - Remote remote Monero node
  - Default P2Pool settings + Mini
  - Backup host setting"#;
pub const P2POOL_ADVANCED: &str = r#"Use advanced P2Pool settings:
  - Terminal input
  - Overriding command arguments
  - Manual node list
  - P2Pool Main/Mini selection
  - Out/In peer setting
  - Log level setting
  - Backup host setting"#;
pub const P2POOL_NAME: &str = "Add a unique name to identify this node; Only [A-Za-z0-9-_.] and spaces allowed; Max length = 30 characters";
pub const P2POOL_NODE_IP: &str = "Specify the Monero Node IP to connect to with P2Pool; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
pub const P2POOL_RPC_PORT: &str = "Specify the RPC port of the Monero node; [1-65535]";
pub const P2POOL_ZMQ_PORT: &str = "Specify the ZMQ port of the Monero node; [1-65535]";
pub const P2POOL_PATH_NOT_FILE: &str = "P2Pool binary not found at the given PATH in the Gupaxx tab! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where P2Pool is located.";
pub const P2POOL_PATH_NOT_VALID: &str = "P2Pool binary at the given PATH in the Gupaxx tab doesn't look like P2Pool! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where P2Pool is located.";
pub const P2POOL_PATH_OK: &str = "P2Pool was found at the given PATH";
pub const P2POOL_PATH_EMPTY: &str = "P2Pool PATH is empty! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where P2Pool is located.";

// Node/Pool list
pub const LIST_ADD: &str = "Add the current values to the list";
pub const LIST_SAVE: &str = "Save the current values to the already existing entry";
pub const LIST_DELETE: &str = "Delete the currently selected entry";
pub const LIST_CLEAR: &str = "Clear all current values";

// XMRig
pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings:
  - Mine to local P2Pool (localhost:3333)
  - CPU thread slider
  - HTTP API @ localhost:18088"#;
pub const XMRIG_ADVANCED: &str = r#"Use advanced XMRig settings:
  - Terminal input
  - Overriding command arguments
  - Custom payout address
  - CPU thread slider
  - Manual pool list
  - Custom HTTP API IP/Port
  - TLS setting
  - Keepalive setting"#;
pub const XMRIG_INPUT: &str = "Send a command to XMRig";
pub const XMRIG_ARGUMENTS: &str = r#"WARNING: Use [--no-color] and make sure to set [--http-host <IP>] & [--http-port <PORT>] so that the [Status] tab can work!

Start XMRig with these arguments and override all below settings"#;
pub const XMRIG_ADDRESS:        &str = "Specify which Monero address to payout to. This does nothing if mining to P2Pool since the address being paid out to will be the one P2Pool started with. This doubles as a rig identifier for P2Pool and some pools.";
pub const XMRIG_NAME:           &str = "Add a unique name to identify this pool; Only [A-Za-z0-9-_.] and spaces allowed; Max length = 30 characters";
pub const XMRIG_IP:             &str = "Specify the pool IP to connect to with XMRig; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
pub const XMRIG_PORT: &str = "Specify the port of the pool; [1-65535]";
pub const XMRIG_RIG:            &str = "Add an optional rig ID. This will be the name shown on the pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
#[cfg(not(target_os = "linux"))]
pub const XMRIG_PAUSE: &str =
    "THIS SETTING IS DISABLED IF SET TO [0]. Pause mining if user is active, resume after";
pub const XMRIG_API_IP: &str =
    "Specify which IP to bind to for XMRig's HTTP API; If empty: [localhost/127.0.0.1]";
pub const XMRIG_API_PORT: &str =
    "Specify which port to bind to for XMRig's HTTP API; If empty: [18088]";
pub const XMRIG_TLS: &str = "Enable SSL/TLS connections (needs pool support)";
pub const XMRIG_KEEPALIVE: &str = "Send keepalive packets to prevent timeout (needs pool support)";
pub const XMRIG_THREADS: &str = "Number of CPU threads to use for mining";
pub const XMRIG_PATH_NOT_FILE:  &str = "XMRig binary not found at the given PATH in the Gupaxxtab! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where XMRig is located.";
pub const XMRIG_PATH_NOT_VALID: &str = "XMRig binary at the given PATH in the Gupaxxtab doesn't look like XMRig! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where XMRig is located.";
pub const XMRIG_PATH_OK: &str = "XMRig was found at the given PATH";
pub const XMRIG_PATH_EMPTY:     &str = "XMRig PATH is empty! To fix: goto the [GupaxxAdvanced] tab, select [Open] and specify where XMRig is located.";

// XvB
pub const XVB_HELP: &str = "You need to register an account by clicking on the link above to get your token with the same p2pool XMR address you use for payment.";
pub const XVB_URL: &str = "https://xmrvsbeast.com";

pub const XVB_URL_PUBLIC_API: &str = "https://xmrvsbeast.com/p2pool/stats";
pub const XVB_NODE_PORT: &str = "4247";
pub const XVB_NODE_EU: &str = "eu.xmrvsbeast.com";
pub const XVB_NODE_NA: &str = "na.xmrvsbeast.com";
pub const XVB_NODE_RPC: &str = "18089";
pub const XVB_URL_RULES: &str = "https://xmrvsbeast.com/p2pool/rules.html";
// buffer in percentage of HR to have plus the requirement.
pub const XVB_SIDE_MARGIN_1H: f32 = 1.20;
pub const XVB_BUFFER: f32 = 1.05;
pub const XVB_TIME_ALGO: u32 = 600;
pub const XVB_TOKEN_LEN: usize = 9;
pub const XVB_HERO_SELECT: &str =
    "This mode will donate all available hashrate while keeping a share in the  p2pool PPLNS window.\nWhen modified, the algorithm will use the new choice at the next decision.";
pub const XVB_TOKEN_FIELD: &str = "Token";
pub const XVB_FAILURE_FIELD: &str = "Failures";
pub const XVB_DONATED_1H_FIELD: &str = "Donated last hour";
pub const XVB_DONATED_24H_FIELD: &str = "Donated last 24 hours";
pub const XVB_ROUND_TYPE_FIELD: &str = "Round";
pub const XVB_WINNER_FIELD: &str = "Win";
pub const XVB_MINING_ON_FIELD: &str = "Currently Mining on";

pub const XVB_ROUND_DONOR_MIN_HR: u32 = 1000;
pub const XVB_ROUND_DONOR_VIP_MIN_HR: u32 = 10000;
pub const XVB_ROUND_DONOR_WHALE_MIN_HR: u32 = 100000;
pub const XVB_ROUND_DONOR_MEGA_MIN_HR: u32 = 1000000;

// CLI argument messages
pub const ARG_HELP: &str = r#"USAGE: ./gupaxx [--flag]

    --help            Print this help message
    --version         Print version and build info
    --state           Print Gupaxxstate
    --nodes           Print the manual node list
    --payouts         Print the P2Pool payout log, payout count, and total XMR mined
    --no-startup      Disable all auto-startup settings for this instance (auto-update, auto-ping, etc)
    --reset-state     Reset all Gupaxxstate (your settings)
    --reset-nodes     Reset the manual node list in the [P2Pool] tab
    --reset-pools     Reset the manual pool list in the [XMRig] tab
    --reset-payouts   Reset the permanent P2Pool stats that appear in the [Status] tab
    --reset-all       Reset the state, manual node list, manual pool list, and P2Pool stats

To view more detailed console debug information, start Gupaxxwith
the environment variable [RUST_LOG] set to a log level like so:
    RUST_LOG=(trace|debug|info|warn|error) ./gupaxx"#;
pub const ARG_COPYRIGHT: &str = r#"Gupaxxis licensed under GPLv3.
For more information, see link below:
<https://github.com/Cyrix126/gupaxx>"#;

// Unknown Data, replace HumanNumlber::unknown()
pub const UNKNOWN_DATA: &str = "???";
// Time PPLNS WINDOW in seconds
// it is an estimation based on number of block in a pplns window and block time (10s). The difficulty of the network should adapt to get close to this value.
pub const BLOCK_PPLNS_WINDOW_MINI: u64 = 2160;
pub const BLOCK_PPLNS_WINDOW_MAIN: u64 = 363;
pub const SECOND_PER_BLOCK_P2POOL: u64 = 10;
// pub const TIME_PPLNS_WINDOW_MINI: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MINI * SECOND_PER_BLOCK_P2POOL);
// pub const TIME_PPLNS_WINDOW_MAIN: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MAIN * SECOND_PER_BLOCK_P2POOL);

//---------------------------------------------------------------------------------------------------- Visuals
use egui::epaint::{Rounding, Shadow, Stroke};

use egui::{Color32, Visuals};

use egui::style::{Selection, WidgetVisuals, Widgets};
use once_cell::sync::Lazy;

pub const ACCENT_COLOR: Color32 = Color32::from_rgb(200, 100, 100);
pub const BG: Color32 = Color32::from_gray(20);

// This is based off [`Visuals::dark()`].
pub static VISUALS: Lazy<Visuals> = Lazy::new(|| {
    let selection = Selection {
        bg_fill: ACCENT_COLOR,
        stroke: Stroke::new(1.0, Color32::from_gray(255)),
    };

    // Based off default dark() mode.
    // https://docs.rs/egui/0.24.1/src/egui/style.rs.html#1210
    let widgets = Widgets {
        noninteractive: WidgetVisuals {
            bg_fill: BG,
            bg_stroke: Stroke::new(1.0, Color32::from_gray(60)), // separators, indentation lines
            fg_stroke: Stroke::new(1.0, Color32::from_gray(140)), // normal text color
            rounding: Rounding::same(10.0),
            expansion: 0.0,
            weak_bg_fill: BG,
        },
        inactive: WidgetVisuals {
            bg_fill: Color32::from_gray(50),
            bg_stroke: Default::default(),
            fg_stroke: Stroke::new(1.0, Color32::from_gray(180)), // button text
            rounding: Rounding::same(10.0),
            expansion: 0.0,
            weak_bg_fill: Color32::from_gray(50),
        },
        hovered: WidgetVisuals {
            bg_fill: Color32::from_gray(80),
            bg_stroke: Stroke::new(1.0, Color32::from_gray(150)), // e.g. hover over window edge or button
            fg_stroke: Stroke::new(1.5, Color32::from_gray(240)),
            rounding: Rounding::same(10.0),
            expansion: 1.0,
            weak_bg_fill: Color32::from_gray(80),
        },
        active: WidgetVisuals {
            bg_fill: Color32::from_gray(55),
            bg_stroke: Stroke::new(1.0, Color32::WHITE),
            fg_stroke: Stroke::new(2.0, Color32::WHITE),
            rounding: Rounding::same(10.0),
            expansion: 1.0,
            weak_bg_fill: Color32::from_gray(120),
        },
        open: WidgetVisuals {
            bg_fill: Color32::from_gray(27),
            bg_stroke: Stroke::new(1.0, Color32::from_gray(60)),
            fg_stroke: Stroke::new(1.0, Color32::from_gray(210)),
            rounding: Rounding::same(10.0),
            expansion: 0.0,
            weak_bg_fill: Color32::from_gray(120),
        },
    };

    // https://docs.rs/egui/0.24.1/src/egui/style.rs.html#1113
    Visuals {
        widgets,
        selection,
        hyperlink_color: Color32::from_rgb(90, 170, 255),
        faint_bg_color: Color32::from_additive_luminance(5), // visible, but barely so
        extreme_bg_color: Color32::from_gray(10),            // e.g. TextEdit background
        code_bg_color: Color32::from_gray(64),
        warn_fg_color: Color32::from_rgb(255, 143, 0), // orange
        error_fg_color: Color32::from_rgb(255, 0, 0),  // red
        window_rounding: Rounding::same(6.0),
        window_shadow: Shadow::NONE,
        popup_shadow: Shadow::NONE,
        ..Visuals::dark()
    }
});
//---------------------------------------------------------------------------------------------------- CONSTANTS
#[cfg(test)]
mod test {
    #[test]
    fn gupax_version_is_semver() {
        assert_eq!(crate::GUPAX_VERSION.len(), 6);
    }

    #[test]
    fn default_app_ratio_is_4_by_3() {
        assert_eq!(
            format!("{:.3}", crate::APP_MIN_WIDTH / crate::APP_MIN_HEIGHT),
            "1.333"
        );
        assert_eq!(
            format!(
                "{:.3}",
                crate::APP_DEFAULT_WIDTH / crate::APP_DEFAULT_HEIGHT
            ),
            "1.333"
        );
    }

    #[test]
    fn git_commit_eq_or_gt_40_chars() {
        assert!(crate::COMMIT.len() >= 40);
    }
}
