UI.AddColorPicker("Color");

var color = UI.GetColor("MISC", "JAVASCRIPT", "Script Items", "Color");
if (color[0] === 0 && color[1] === 0 && color[2] === 0 && color[3] === 0)
    UI.SetColor("MISC", "JAVASCRIPT", "Script Items", "Color", [32, 213, 225, 255]);


const draw_outline_text = function(x, y, align, string, color, fontname) {
    Render.StringCustom(x - 1, y - 1, align, string, [0, 0, 0, 255], fontname);
    Render.StringCustom(x - 1, y, align, string, [0, 0, 0, 255], fontname);
    Render.StringCustom(x - 1, y + 1, align, string, [0, 0, 0, 255], fontname);
 
    Render.StringCustom(x, y + 1, align, string, [0, 0, 0, 255], fontname);
    Render.StringCustom(x, y - 1, align, string, [0, 0, 0, 255], fontname);
 
    Render.StringCustom(x + 1, y - 1, align, string, [0, 0, 0, 255], fontname);
    Render.StringCustom(x + 1, y, align, string, [0, 0, 0, 255], fontname);
    Render.StringCustom(x + 1, y + 1, align, string, [0, 0, 0, 255], fontname);
 
    Render.StringCustom(x, y, align, string, color, fontname);
}

const screen_size = Global.GetScreenSize();
var stored = false;
var x_offs = 0;
var y_offs = 0;
UI.AddSliderInt("binds x", 0, screen_size[0]);
UI.AddSliderInt("binds y", 0, screen_size[1]);
UI.SetEnabled("Script items", "binds x", false);
UI.SetEnabled("Script items", "binds y", false);
const in_bounds = function(vec, x, y, x2, y2) {
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}
const keybinds = function() {
    var keybinds = [];
	if (UI.IsHotkeyActive("Anti-Aim", "Fake angles", "Inverter")) {      					keybinds.push("Desync flip") };
	if (UI.IsHotkeyActive("Anti-Aim", "Legit Anti-Aim", "Direction key")) {      			keybinds.push("Desync flip") };
	if (UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction")) {            			keybinds.push("Freestand") };
    if (UI.IsHotkeyActive("Rage", "Exploits", "Double tap")) {                   			keybinds.push("Double tap") };
    if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {                   			keybinds.push("Hide shots") };
    if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {                   			keybinds.push("Fake duck") };
    if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {     			keybinds.push("Body aim") };
    if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {   			keybinds.push("Safe points") };
    if (UI.IsHotkeyActive("Script items", "min damage")) {                       			keybinds.push("Minimum damage") };
    
    const x = UI.GetValue("Script items", "binds x"),
    y = UI.GetValue("Script items", "binds y");
    const font = Render.AddFont("smallest pixel-7", 9, 600);
    const active = Render.AddFont("smallest pixel-7", 9, 500);
    const icon = Render.AddFont("untitled-font-1", 14, 100);
    
    Render.FilledRect(x, y + 17, 200, 24 + 19 * (keybinds.length-1.3), [24, 25, 27, 255]);
	Render.FilledRect(x, y, 200, 18, [39, 39, 37, 255]);
    draw_outline_text(x+5, y + 3, 0, "keybinds", [255, 255, 255, 255], font);
	Render.FilledRect(x, y+18, 200, 2, color);
	
	for (i = 0; i < keybinds.length; i++){
        Render.StringCustom(x + 3, y + 19 + 20 * i, 0, keybinds[i], [255, 255, 255, 255], active);
        Render.StringCustom(x + 157, y + 19 + 20 * i, 0, "Tonggle", [255, 255, 255, 255], active);
    }
    
    if(UI.IsMenuOpen() && Input.IsKeyPressed(0x1)){
        const mouse_pos = Global.GetCursorPosition();
        if (in_bounds(mouse_pos, x, y, x + 150, y + 40)) {
            if(!stored){
                x_offs = mouse_pos[0] - x;
                y_offs = mouse_pos[1] - y;
                stored = true;
            }
            UI.SetValue("Script items", "binds x", mouse_pos[0] - x_offs);
            UI.SetValue("Script items", "binds y", mouse_pos[1] - y_offs);
        }
    } else if(stored) stored = false;
}
Global.RegisterCallback("Draw", "keybinds");