import BrawlhallaApi from "brawl.js";
// This is here so I dont have to define the api key in every file
// Also its so long cause cause i made a fix for when it creates
// a new instance of the api
const globalAny:any = global;
let bh:{
      /**
   * @returns An object of the player's stats
   * @param id the `brawlhalla_id` of the player
   * @example
   * ```js
   * // Get player's stats
   * let player = await bh.getPlayerStats(1).catch((err) => console.log("Player does not exist!"))
   * console.log(player)
   * // {
   * // "brawlhalla_id": 1,
   * // ...}
   * ```
   */
  getPlayerStats: (id: number | string) => {}
  /**
   * @returns An object of the player's ranked stats if it exists
   * @param id the `brawlhalla_id` of the player
   * @example
   * ```js
   * // Get player's ranked stats
   * let player = await bh.getPlayerRankedStats(1).catch((err) => console.log("Player does not exist!"))
   * console.log(player)
   * // {
   * // "brawlhalla_id": 1,
   * // ...}
   * ```
   */
getPlayerRankedStats: (id: number | string) => {}
  /**
   * @returns An Array of all matched usernames
   * @param name
   * @param region Optional, defaults to `all`, change the region if you wanna get the leaderboard from a different region,
   * @param page Optional, defaults to 1
   * @param exact default: `false`. If this value is true, it will return only exact matches, if it is false, it will return partial matches.
   * @param exactCharCase default: `false`. If this value is true, it will return only exact character case matches, if it is false, it will not check for character case, needs `exact` to be true.
   * @example
   * ```js
   * // Get all players with the name "ChdML"
   * let players = await bh.getByName("ChdML").catch((err) => console.log("Player does not exist!"))
   * console.log(players)
   * // [
   * // {name: "ChdML", ...},
   * // {name: "ChdML2"},
   * // ...]
   * ```
   */
  getRankedByName: (
    name: string,
    exact: boolean,
    exactCharCase: boolean,
    page: number,
    region: string
  ) => {}
  /**
   * @returns An Array of all the top 1v1 players
   * @param page default: `1`
   * @param region default: `all`, change the region if you wanna get the leaderboard from a different region
   * @example
   * ```js
   * // Get page 1 of the leaderboard, if no page was provided it would automatically fetch page 1
   * let onevoneLeaderboard = await bh.get1v1Rankings().catch((err) => console.log("Error occurred!", err))
   * console.log(onevoneLeaderboard)
   * // [
   * // {rank: 1, ...},
   * // {rank: 2},
   * // ...]
   * ```
   * @example
   * ```js
   * // get page 2
   * let onevoneLeaderboard2 = await bh.get1v1Rankings(2).catch((err) => console.log("Error occurred!", err))
   * console.log(onevoneLeaderboard2)
   * // [
   * // {rank: 50, ...},
   * // {rank: 51},
   * // ...]
   * ```
   */
get1v1Rankings: (
    page: number,
    region: string
  ) => {}
  /**
   * @returns An Array of all the top players
   * @param mode Required, there's `1v1`, `2v2`, and special rank modes, enter the mode you want to get the leaderboard from.
   * @param page default: `1`
   * @param region default: `all`, change the region if you wanna get the leaderboard from a different region
   * @example
   * ```js
   * // Get page 1 of the leaderboard, if no page was provided it would automatically fetch page 1
   * let kungfootLeaderboard = await bh.getRankings("kungfoot").catch((err) => console.log("Error occurred!", err))
   * console.log(kungfootLeaderboard)
   * // [
   * // {rank: 1, ...},
   * // {rank: 2},
   * // ...]
   * ```
   * @example
   * ```js
   * // get page 2
   * let kungfootLeaderboard2 = await bh.getRankings("kungfoot").catch((err) => console.log("Error occurred!", err))
   * console.log(kungfootLeaderboard2)
   * // [
   * // {rank: 50, ...},
   * // {rank: 51},
   * // ...]
   * ```
   */
getRankings: (
    mode: string,
    page: number,
    region: string
  ) => {}
  /**
   * @returns An Array of all the top 2v2 players
   * @param page default: `1`
   * @param region default: `all`, change the region if you wanna get the leaderboard from a different region
   * @example
   * ```js
   * // Get page 1 of the leaderboard, if no page was provided it would automatically fetch page 1
   * let onevoneLeaderboard = await bh.get2v2Rankings().catch((err) => console.log("Error occurred!", err))
   * console.log(onevoneLeaderboard)
   * // [
   * // {rank: 1, ...},
   * // {rank: 2},
   * // ...]
   * ```
   * @example
   * ```js
   * // get page 2
   * let onevoneLeaderboard2 = await bh.get2v2Rankings(2).catch((err) => console.log("Error occurred!", err))
   * console.log(onevoneLeaderboard2)
   * // [
   * // {rank: 50, ...},
   * // {rank: 51},
   * // ...]
   * ```
   */
  get2v2Rankings: (
    page: number,
    region: string
  ) => {}
  /**
   * @returns An array of the player's `brawlhalla_id` and `name`
   * @param id
   * @example
   * ```js
   * let player = await bh.getPlayerBySteam64ID(76561197996943884)
   * console.log(player)
   * // {
   * // "brawlhalla_id": ...,
   * // "name": ...
   * // }
   * ```
   */
  getPlayerBySteam64ID: (id: number | string) => {}
  /**
   * @param id
   * @example
   * ```js
   * let clan = await bh.getClan(1)
   * console.log(clan)
   * // {
   * // "clan_id": 1,
   * // ...
   * // }
   * ```
   * @returns An object of the clan info
   */
  getClan: (id: number) => {}
  /**
   * @returns An array of all legends
   * @example
   * ```js
   * // Get all legends
   * let legends = await bh.getLegends()
   * console.log(legends)
   * // [{...}, {...}, ...]
   * ```
   */
  getLegends: () => {}
  /**
   * @returns An object of a legend from the provided id
   * @param id
   * @example
   * ```js
   * let cassidy = await bh.getLegendById(4)
   * console.log(cassidy)
   * // {
   * // "legend_id": 4,
   * // ...
   * // }
   * ```
   */
  getLegendById: (id: number | string) => {}

    /**
   * @returns a decoded string/object
   * @param res the response object from the request
   * @example
   * ```js
   * let decodedRes = await bh.decode({...})
   * console.log(decodedRes)
   * // {
   * // ...
   * // }
   * ```
   */
    decode: (res: any) => {}
    /**
   Searches for a legend with the provided name, not really recommended if you know the legend id
 * @returns An object of a legend from the provided name
 * @param name
 * @example
 * ```js
 * let cassidy = await bh.getLegendByName("cassidy")
 * console.log(cassidy)
 * // {
 * // "legend_name_key": "cassidy",
 * // ...
 * // }
 * ```
 */
getLegendByName: (name: string) => {}
  /**
   Get the elo reset value
 * @returns Estimate value of elo on season reset
 * @param elo
 * @example
 * ```js
 * let newElo = bh.getEloResetValue(2000)
 * console.log(newElo)
 * // 1742
 * ```
 */
  getEloReset: (elo: number) => {}
  /**
   Get the team/legend elo reset value
 * @returns Estimate value of elo on season reset
 * @param elo
 * @example
 * ```js
 * let newTeamElo = bh.getTeamEloReset(2000)
 * console.log(newTeamElo)
 * // 1583
 * @example
 * ```js
 * let newLegendElo = bh.getTeamEloReset(2000)
 * console.log(newLegendElo)
 * // 1583
 * ```
 */
  getTeamEloReset: (elo: number) => {}
  /**
   Get the glory from wins
 * @returns Estimate value of glory from wins on season reset
 * @param wins
 * @example
 * ```js
 * let gloryFromWins = bh.getGloryFromWins(67)
 * console.log(gloryFromWins)
 * // 1340
 * ```
 */
  getGloryFromWins: (wins: number, has_played_10_games: Boolean) => {}
  /**
   Get the glory from best rating
 * @returns Estimate value of glory from wins on season reset
 * @param best_rating
 * @example
 * ```js
 * let gloryFromRating = bh.getGloryFromBestRating(1900)
 * console.log(gloryFromRating)
 * // 3941
 * ```
 */
  getGloryFromBestRating: (best_rating: number) => {}
  /**
   Get the wins, best rating, and total glory
 * @returns Estimate value of glory from wins on season reset
 * @param best_rating
 * @param wins
 * @param has_played_10_games
 * @example
 * ```js
 * let gloryFromRating = bh.getGlory(1900, 100)
 * console.log(gloryFromRating)
 * // {
 * // wins: 2000,
 * // rating: 3941,
 * // total: 5941,
 * // }
 * ```
 */
  getGlory: (
    best_rating: number,
    wins: number,
    has_played_10_games: Boolean
  ) => {}
  /**
   Fetch a path using the `https://api.brawlhalla.com` url
 * @returns The result of the fetch request
 * @param path the path to fetch, example: `/legend/all`
 * @example
 * ```js
 * let legends = await bh.get("/legend/all")
 * console.log(legends)
 * // {
 * // ...
 * // }
 * 
 * ```
 */
  get: (path: string) => {}

};
if(process.env.NODE_ENV === "production") {
  // @ts-ignore 
  bh = new BrawlhallaApi(process.env.API_KEY)
} else {
    if(!globalAny.bh) {
      // @ts-ignore
        globalAny.bh = new BrawlhallaApi(process.env.API_KEY)
    }
    bh = globalAny.bh
}
export default bh