let showAPI = false;
const apis = [
  { name: 'Xxxtreme Lightning Roulette', file: 'spin_50_xxxtreme_roulette.php' },
  { name: 'Lightning Roulette', file: 'spin_50_lightening_roulette.php' },
  { name: 'Auto Roulette', file: 'spin_50_auto_roulette.php' },
  { name: 'Immersive Roulette', file: 'spin_50_immersive_roulette.php' },
];

	const list = [
		{ name: 'Xxxtreme Lightning Roulette', file: 'spin_xxxtreme_roulette.php' },
		{ name: 'Lightning Roulette', file: 'spin_lightening_roulette.php' },
		{ name: 'Auto Roulette', file: 'spin_auto_roulette.php' },
		{ name: 'Immersive Roulette', file: 'spin_immersive_roulette.php' },
		// Add more options here if needed
		{ name: 'Use Random Number', file: null }
	];

let wheelnumbers = [0, 26, 3, 35, 12, 28, 7, 29, 18, 22, 9, 31, 14, 20, 1, 33, 16, 24, 5, 10, 23, 8, 30, 11, 36, 13, 27, 6, 34, 17, 25, 2, 21, 4, 19, 15, 32];


// Roulette wheel attributes
const rouletteAttributes = {
    red: [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36],
    black: [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35],
    columns: [
        [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34], // Column 1
        [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35], // Column 2
        [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]  // Column 3
    ],
    dozens: [
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], // Dozen 1
        [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], // Dozen 2
        [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36] // Dozen 3
    ]
};

let numRed = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36];
let numBlack = [26, 35, 28, 29, 22, 31, 20, 33, 24, 10, 8, 11, 13, 6, 17, 2, 4, 15];

let numbers = [];
let numberHistory = [];

var chart;

let triggerCode = "";

let production = true;
let rebetMultiplier = 2;
let oldUserBets = new Map();
let userBets = new Map();
let previousBankValue = 0;

let showRebetButton = true;
let bankValue = 1000;
let currentBet = 0;
let wager = 5;
let lastWager = 0;

let lastBets = []; 
let bet = [];
let oldBet = [];

let PreviousBet = [];
let numbersBet = [];
let previousNumbers = [];
let historyBankValue = [];
let historyCurrentBet = [];
let historyWager = [];
let historyLastWager = [];
let historBet = [];
let historyNumbersBet = [];
let historyPreviousNumbers = [];
historyBankValue.push(bankValue);
historyCurrentBet.push(currentBet);
historyWager.push(wager);
historyLastWager.push(lastWager);
historBet.push(bet);
historyNumbersBet.push(numbersBet);
historyPreviousNumbers.push(previousNumbers);



let triggerGroups = [];
let triggerListLoss = [];
let triggerListItem = [];
let triggerListText = [];
let triggerListWinLoss = [];

let alertCounter = [];
let alertItem = [];
let alertItemDetail = [];
let alertHighLightStack = [];
let alertId = [];
let alertWinLoss = [];

let watch_id = [];
let watch_count = [];
let watch_loss = [];
let watchCounter = [];
let watchItem = [];
let watchItemDetail = [];
let watch_highlight_stack = [];
let watchWinLoss = [];

let rebet_lastThis = [];
let rebet_amount = [];
let rebet_target = [];
let rebet_odds = [];
let rebet_wager = [];

let redo_lastThis = [];
let redo_amount = [];
let redo_target = [];
let redo_odds = [];
let redo_wager = [];

let detailFunctionsSelected = [];
let detailValueSelected = [];

let triggerDropDown = [
    { value: 'AllOut', text: 'Outside Bets' },
    { value: 'All', text: 'All No Straights' },
    { value: 'Even', text: 'Even' },
    { value: 'Odd', text: 'Odd' },
    { value: 'Red', text: 'Red' },
    { value: 'Black', text: 'Black' },
    { value: 'High', text: 'High' },
    { value: 'Low', text: 'Low' },
    { value: 'Dozen1', text: 'Dozen 1 (1-12)' },
    { value: 'Dozen2', text: 'Dozen 2 (13-24)' },
    { value: 'Dozen3', text: 'Dozen 3 (25-36)' },
    { value: 'Row1', text: 'Row 1' },
    { value: 'Row2', text: 'Row 2' },
    { value: 'Row3', text: 'Row 3' },
    { value: 'Quads', text: 'Quads' },
    { value: 'Splits', text: 'Splits' },
    { value: 'Streets', text: 'Streets' },
    { value: 'DoubleStreet', text: 'Lines' },
    { value: 'StraightNumbers', text: 'Straight Numbers' },
];

// Track whether dragging is enabled
let isDraggingEnabled = false;

// Store original positions
let originalPositions = {};



let panelTriggers = document.createElement('div');

var chart;

var dotTopIncrement = 67.75;
var dotTopIncrementStreet = 67.75;
var dotTopIncrementLine= 135.50;

const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const dpi = window.devicePixelRatio;


// Reference height where the number is 68
const referenceHeight = 1366;

// Current window height
const currentHeight = window.innerHeight;

// Calculate the scaled number
const scaledIncrementTop = 68 * (currentHeight / referenceHeight);

console.log("Scaled Number Top:", scaledIncrementTop);


console.log("Window Width:", windowWidth, "Window Height:", windowHeight);
console.log("DPI:", dpi);


let clientCellHeight = 0;

const backgroundColorRed = '#eb3838';
const backgroundColorBlack = '#2e2c2b';
const numberColor = 'rgb(255, 255, 255';

const redNumbers = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36];
const blackNumbers = [26, 35, 28, 29, 22, 31, 20, 33, 24, 10, 8, 11, 13, 6, 17, 2, 4, 15];

