<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Lua GG Script Generator</title>
    <style id="dynamic-style">
        body {
   font-family: 'Arial', sans-serif;
   padding: 20px;
   color: #f0f0f0;
   background: linear-gradient(135deg, #282828, #1c1c1c); /* Серый и угольно-черный градиент */
}
h1, h2 {
   text-align: center;
   text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.7); /* Глубокая тень */
   color: #ffaa00; /* Золотистый для заголовков */
}
.container {
   max-width: 900px;
   margin: 0 auto;
}
.functions {
   display: flex;
   flex-direction: column;
   gap: 15px;
   margin-top: 20px;
}
.function {
   display: flex;
   flex-wrap: wrap;
   align-items: center;
   gap: 10px;
   padding: 15px;
   border: 2px solid #ffaa00; /* Золотистая рамка */
   border-radius: 12px;
   background-color: #1a1a1a; /* Угольно-черный фон карточек */
   color: #fff; /* Белый текст */
   box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.6); /* Глубокая тень для объёма */
}
.code-box {
   white-space: pre-wrap;
   font-family: monospace;
   border: 1px solid #ffaa00; /* Золотистая рамка */
   padding: 20px;
   background-color: #333333; /* Тёмно-серый для области кода */
   margin: 30px 0;
   height: 300px;
   overflow-y: scroll;
   box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.4); /* Тень для области кода */
}
button {
   padding: 10px 20px; /* Размеры кнопок сохранены */
   font-size: 15px;
   font-weight: bold;
   color: #1a1a1a; /* Чёрный текст */
   background: #ffaa00; /* Золотистый фон кнопки */
   border: 2px solid #cc8400; /* Тёмно-золотистая рамка */
   border-radius: 8px;
   cursor: pointer;
   transition: all 0.3s ease-in-out;
   text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.5); /* Лёгкая тень для текста */
   margin-bottom: 12px;
}
button:hover {
   background: #cc8400; /* Тёмно-золотистый при наведении */
   color: #f0f0f0; /* Светлый текст при наведении */
   border-color: #ffaa00; /* Золотистая рамка при наведении */
   transform: scale(1.05); /* Лёгкое увеличение */
   box-shadow: 0px 5px 15px rgba(204, 132, 0, 0.8); /* Сильная золотистая тень при наведении */
}
       .menu-options {
           display: none;
           margin-top: 20px;
       }
       .menu-options.active {
           display: block;
       }
       .menu-settings {
           margin-bottom: 20px;
       }
       #emojiMenu select {
           width: 10%;
           height: auto;
       }
       #instructionBlock {
           color: #fff;
       }
    </style>
</head>
<body>

<h1 id="version-title" style="text-align: ;  text-shadow: 0 0 10px #000; border-bottom: 4px solid #64B5F6; padding-bottom: 10px;">Script Lua Builder</h1>
<h1 id="version-title" style="text-align: ; text-shadow: 0 0 10px #000; border-bottom: 4px solid #64B5F6; padding-bottom: 10px;">CreateD By - @LambaTyT</h1>


<!-- Set Style Button -->
<button onclick="toggleStyleMenu()">Set Style</button>
<div id="styleMenu" class="menu-options">
    <button onclick="setDefaultStyle()">Default Style</button>
    <button onclick="setGradientStyle()">Gradient Style</button>
    <button onclick="setGradientStyle2()">Gradient Style 2</button>
    <button onclick="setGradientStyle3()">Gradient Style 3</button>
    <button onclick="setGradientStyle4()">Gradient Style 4</button>
    <button onclick="setGradientStyle5()">Gradient Style 5</button>
    <button onclick="setGradientStyle6()">Gradient Style 6</button>
    <button onclick="setGradientStyle7()">Gradient Style 7</button>
    <button onclick="setGradientStyle8()">Gradient Style 8</button>
    <button onclick="setGradientStyle9()">Gradient Style 9</button>
    <button onclick="setGradientStyle10()">Gradient Style 10</button>
</div>
<div class="instructions-container">
    <button onclick="showInstruction()">Инструкция</button>
</div>
<!-- Скрытый блок с инструкцией -->
<div id="instructionBlock" style="display: none; margin-top: 15px; padding: 10px; border: 1px solid #ccc; background-color: #f9f9f9;">
    <h3>Пример использования `gg.getResults`:</h3>
    <p><strong>Описание:</strong> <code>gg.getResults</code> получает данные результатов (количество).</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Получить результаты поиска
gg.searchNumber("4", gg.TYPE_DWORD)
local results = gg.getResults(10) -- Получаем 10 найденных значений
gg.toast("Найдено " .. #results .. " результатов")
    </pre>
    <h3>Пример использования `gg.setVisible(false)`:</h3>
    <p><strong>Описание:</strong> <code>gg.setVisible(false)</code> делает интерфейс Game Guardian невидимым.</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Скрыть интерфейс Game Guardian
gg.setVisible(false)
-- Ваш следующий код
gg.toast("Game Guardian успешно скрыт")
    </pre>
    <h3>Пример использования `gg.setRanges`:</h3>
    <p><strong>Описание:</strong> <code>gg.setRanges</code> задает область памяти для поиска значений.</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Установить основной регион
gg.setRanges(gg.REGION_ANONYMOUS) -- Устанавливаем Анонимную память
-- Ваш следующий код
gg.toast("Регион установлен: Анонимная память")
    </pre>
    <h3>Пример использования `gg.setRanges` с кастомными регионами:</h3>
    <p><strong>Описание:</strong> <code>gg.setRanges</code> выбирает несколько областей памяти (например, C-ALLOC и C-DATA).</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Установить кастомные регионы памяти
gg.setRanges(gg.REGION_C_ALLOC | gg.REGION_C_DATA)
-- Ваш следующий код
gg.toast("Регион установлен: C-ALLOC и C-DATA")
    </pre>
    <button onclick="hideInstruction()">Закрыть инструкцию</button>
</div>
<!-- Setting Button -->
<div class="settings-container">
    <button onclick="toggleSettingsMenu()">Setting</button>
    <div id="settingsMenu" class="menu-options">
        <button onclick="toggleDesktopMode()">ПК</button>
    </div>
</div>
<div class="container">
    <!-- Ввод имени функции -->
    <input type="text" id="functionNameInput" placeholder="Введите название функции (например: myFunction)">
    <button onclick="setFunctionName()">Установить название функции</button>
    <br><br>



    <!-- Добавление главного меню -->
    <label for="mainMenuFunction">Введите название меню (УЖЕ ПОСЛЕ ОКОНЧАНИЯ):</label>
    <input type="text" id="mainMenuFunction" placeholder="Введите название меню">
    <button onclick="addMenu()">Добавить меню</button>
    <br><br>

    <!-- Кнопка настройки "Главного меню" -->
    <button onclick="setupMainMenu()">Настроить "Главное меню"</button>

    <div id="menuSettings" class="menu-options">
        <div class="menu-settings">
            <label for="menuFunctionCount">Количество функций:</label>
            <input type="number" id="menuFunctionCount" min="1" placeholder="Введите число">
        </div>

        <div class="menu-settings">
            <label for="menuAuthor">Автор меню:</label>
            <input type="text" id="menuAuthor" placeholder="Введите имя автора">

            <label for="menuText">Текст в меню:</label>
            <input type="text" id="menuText" placeholder="Введите текст для меню">
        </div>

        <div class="menu-settings">
            <label for="menuType">Тип меню:</label>
            <select id="menuType">
                <option value="choice">Обычное меню (gg.choice)</option>
                <option value="multiChoice">Мультивыбор (gg.multiChoice)</option>
            </select>
        </div>

        <div class="menu-settings">
            <label for="menuItemNames">Названия пунктов меню (через запятую):</label>
            <input type="text" id="menuItemNames" placeholder="Пример: Взлом патронов, Вода, Земля">
        </div>
        <div class="menu-settings">
            <label for="menuFunctionNames">Названия функций (через запятую):</label>
            <input type="text" id="menuFunctionNames" placeholder="Пример: F1, F2, F3">
        </div>
        <div class="menu-settings">
            <label for="menuEmojis">Эмодзи пунктов меню (через запятую):</label>
            <input type="text" id="menuEmojis" placeholder="Пример: 🔥,🌊,🌍">
        </div>

        <button onclick="generateMainMenu()">Сгенерировать главное меню</button>
    </div>
    <!-- Кнопка настройки "Главного меню" -->
    <button onclick="setupMainF()">Настроить "Меню Функций"</button>
    <div class="menu-settings">
        <div id="menuSettingss" class="menu-options">
            <div class="menu-settings">
                <label for="subMenuFunctionName">Название подменю/функции:</label>
                <input type="text" id="subMenuFunctionName" placeholder="Введите название функции подменю (например, OP)">
            </div>
            <div class="menu-settings">
                <label for="subMenuItemNames">Названия пунктов подменю (через запятую):</label>
                <input type="text" id="subMenuItemNames" placeholder="Пример: Настройка1, Настройка2">
            </div>
            <div class="menu-settings">
                <label for="subMenuFunctions">Названия вызываемых функций из подменю (через запятую):</label>
                <input type="text" id="subMenuFunctions" placeholder="Пример: SubOp1, SubOp2">
            </div>
            <div id="drawer">
                <button onclick="toggleEmojiMenu()">Емодзi для функцій</button>

                <div id="emojiMenu" style="display: none;"></div>
            </div>
            <!-- повторюйте для кожної функції -->
            <div class="menu-settings">
                <label for="menuStyle">Стиль меню:</label>
                <select id="menuStyle">
                    <option value="normal">1. Обычный</option>
                    <option value="circle">2. Круг</option>
                </select>
            </div>
            <div class="menu-settings">
                <label for="functionStyle">Стиль функций:</label>
                <select id="functionStyle">
                    <option value="default">Обычный</option>
                    <option value="brackets">『 ➱ 』</option>
                    <option value="arrow">➤</option>
                    <option value="bars">▁▂▃ (начало) ▃▂▁ (конец)</option>
                    <option value="parallel">║  ║</option>
                    <option value="cut">◤  ◥</option>
                    <option value="but">[+]</option>
                </select>
            </div>

            <button onclick="generateSubMenu()">Сгенерировать подменю/функцию</button>
        </div>
        <h2>Настройка вашей функции</h2>
        <!-- Невидимость GG -->
        <div class="functions">
            <div class="function">
                <input type="checkbox" id="hideGG">
                <label for="hideGG">Скрыть Game Guardian (gg.setVisible(false))</label>
            </div>
            <div class="function">
                <input type="checkbox" id="usePrimaryRegion">
                <label for="primaryRegion">Выберите основной регион:</label>
                <select id="primaryRegion" disabled>
                    <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
                    <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
                    <option value="gg.REGION_C_BSS">C-BSS</option>
                    <option value="gg.REGION_C_DATA">C-DATA</option>
                    <option value="gg.REGION_CODE_APP">Код приложения</option>
                    <option value="gg.REGION_CODE_SYS">Код системы</option>
                    <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
                    <option value="gg.REGION_STACK">Стек</option>
                    <option value="gg.REGION_VIDEO">Видео</option>
                    <option value="gg.REGION_OTHER">Другое</option>
                    <option value="gg.REGION_BAD">Неиспользуемая память</option>
                </select>
            </div>
            <div class="function">
                <label>Кастомные регионы (максимум 3):</label>
                <div id="customRegions">
                    <label for="customRegion1">Регион 1:</label>
                    <select id="customRegion1">
                        <option value="">Не выбран</option>
                        <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
                        <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
                        <option value="gg.REGION_C_BSS">C-BSS</option>
                        <option value="gg.REGION_C_DATA">C-DATA</option>
                        <option value="gg.REGION_CODE_APP">Код приложения</option>
                        <option value="gg.REGION_CODE_SYS">Код системы</option>
                        <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
                        <option value="gg.REGION_STACK">Стек</option>
                        <option value="gg.REGION_VIDEO">Видео</option>
                        <option value="gg.REGION_OTHER">Другое</option>
                        <option value="gg.REGION_BAD">Неиспользуемая память</option>
                    </select>

                    <label for="customRegion2">Регион 2:</label>
                    <select id="customRegion2">
                        <option value="">Не выбран</option>
                        <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
                        <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
                        <option value="gg.REGION_C_BSS">C-BSS</option>
                        <option value="gg.REGION_C_DATA">C-DATA</option>
                        <option value="gg.REGION_CODE_APP">Код приложения</option>
                        <option value="gg.REGION_CODE_SYS">Код системы</option>
                        <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
                        <option value="gg.REGION_STACK">Стек</option>
                        <option value="gg.REGION_VIDEO">Видео</option>
                        <option value="gg.REGION_OTHER">Другое</option>
                        <option value="gg.REGION_BAD">Неиспользуемая память</option>
                    </select>

                    <label for="customRegion3">Регион 3:</label>
                    <select id="customRegion3">
                        <option value="">Не выбран</option>
                        <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
                        <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
                        <option value="gg.REGION_C_BSS">C-BSS</option>
                        <option value="gg.REGION_C_DATA">C-DATA</option>
                        <option value="gg.REGION_CODE_APP">Код приложения</option>
                        <option value="gg.REGION_CODE_SYS">Код системы</option>
                        <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
                        <option value="gg.REGION_STACK">Стек</option>
                        <option value="gg.REGION_VIDEO">Видео</option>
                        <option value="gg.REGION_OTHER">Другое</option>
                        <option value="gg.REGION_BAD">Неиспользуемая память</option>
                    </select>
                </div>
                <div class="functions">
                    <!-- gg.clearResults -->
                    <div class="function">
                        <input type="checkbox" id="clearResults">
                        <label for="clearResults">gg.clearResults()</label>
                    </div>

                    <!-- gg.alert -->
                    <div class="function">
                        <input type="checkbox" id="alert">
                        <label for="alert">gg.alert()</label>
                        <input type="text" id="alertMessage" placeholder="Введите сообщение для gg.alert">
                    </div>
                    <div class="function">
                        <label for="alertPlacement">Розташування gg.alert:</label>
                        <select id="alertPlacement">
                            <option value="start">На початку</option>
                            <option value="end">У кінці</option>
                        </select>
                    </div>
                    <!-- gg.toast -->
                    <div class="function">
                        <input type="checkbox" id="toast">
                        <label for="toast">gg.toast()</label>
                        <input type="text" id="toastMessage" placeholder="Введите сообщение для gg.toast">
                    </div>

                    <div class="function">
                        <label for="toastPlacement">Розташування gg.toast:</label>
                        <select id="toastPlacement">
                            <option value="start">На початку</option>
                            <option value="end">У кінці</option>
                        </select>
                    </div>

                    <!-- gg.searchNumber -->
                    <div class="function">
                        <input type="checkbox" id="searchNumber">
                        <label for="searchNumber">gg.searchNumber()</label>
                        <input type="text" id="searchValue" placeholder="Введите значение для поиска">
                        <select id="searchType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>
                    <!-- gg.getResults -->
                    <div class="function">
                        <input type="checkbox" id="getResults">
                        <label for="getResults">gg.getResults()</label>
                        <input type="number" id="resultsCount" placeholder="Введите количество результатов" min="1">
                    </div>
                    <!-- gg.refineNumber -->
                    <div class="function">
                        <input type="checkbox" id="refineNumber">
                        <label for="refineNumber">gg.refineNumber()</label>
                        <input type="text" id="refineValue" placeholder="Введите значение для уточнения">
                        <select id="refineType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>
                    <!-- Обычная замена -->
                    <div class="function">
                        <input type="checkbox" id="editAll">
                        <label for="editAll">Обычная замена (gg.editAll)</label>
                        <input type="text" id="editValue" placeholder="Введите значение для замены">
                        <select id="editType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>

                    <!-- Замена через оффсеты -->
                    <div class="function">
                        <input type="checkbox" id="offsetReplace">
                        <label for="offsetReplace">Замена через оффсеты</label>
                        <input type="text" id="offsetAddress" placeholder="Введите адрес (0x)">
                        <input type="text" id="offsetValue" placeholder="Введите значение для замены">
                        <select id="offsetType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>
                    <!-- Замена через ввод значений -->
                    <div class="function">
                        <input type="checkbox" id="replaceInput">
                        <label for="replaceInput">Замена через ввод значений (диапазон, тип)</label>
                        <input type="text" id="rangeMin" placeholder="Минимальное значение">
                        <input type="text" id="rangeMax" placeholder="Максимальное значение">
                        <input type="text" id="defaultPromptValue" placeholder="Значение по умолчанию">
                        <select id="replaceType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>

                    <!-- Замена через колёсико -->
                    <div class="function">
                        <input type="checkbox" id="editWheel">
                        <label for="editWheel">Замена через "колёсико" (множитель, диапазон, тип)</label>
                        <input type="text" id="wheelMultiplier" placeholder="Введите множитель (например: 2)">
                        <input type="text" id="wheelMin" placeholder="Минимальное значение">
                        <input type="text" id="wheelMax" placeholder="Максимальное значение">
                        <select id="wheelType">
                            <option value="gg.TYPE_FLOAT">Float</option>
                            <option value="gg.TYPE_DWORD">Dword</option>
                        </select>
                    </div>
                    <div class="functions">
                        <!-- gg.freeze -->
                        <div class="function">
                            <input type="checkbox" id="freezeValues">
                            <label for="freezeValues">Заморозить значения</label>
                            <input type="text" id="freezeValue" placeholder="Значение для заморозки (например: 100)">
                        </div>
                        <!-- Сохранение значений -->
                        <div class="function">
                            <input type="checkbox" id="saveValues">
                            <label for="saveValues">Сохранить значения (gg.addListItems)</label>
                        </div>
                        <!-- Расширенный поиск -->

                        <div class="function">
                            <!-- Включение настройки функций -->
                            <input type="checkbox" id="customFunctionCount">
                            <label for="customFunctionCount">Указать количество функций</label>
                            <input type="text" id="functionCount" placeholder="Количество функций (например: 2)" style="display: none;">

                            <!-- Меню для настройки функций -->
                            <div id="functionSetupMenu" style="display: none;">
                                <div id="functionNamesContainer"></div>
                                <button id="generateSearchMenu" style="display: none;">Настроить поиск</button>
                            </div>

                            <!-- Меню поиска -->
                            <div id="searchMenu" style="display: none;">
                                <div id="searchInputsContainer"></div>
                            </div>
                        </div>
                        <div class="useful-functions">
                            <!-- Основная кнопка -->
                            <div class="useful-functions">
                                <!-- Основная кнопка -->
                                <button onclick="toggleUsefulFunctions()">ПОЛЕЗНЫЕ ФУНКЦИИ</button>

                                <!-- Скрытый список полезных функций -->
                                <div id="usefulFunctionsList" style="display: none; margin-top: 10px; padding: 10px; border: 1px solid #ccc; background-color: #f9f9f9;">
                                    <button onclick="generateSelectMemoryFunction()">ВЫБОР РЕГИОНОВ</button>
                                    <button onclick="generatePasswordFunction()">СОЗДАНИЕ ПАРОЛЯ</button>

                                    <!-- Контейнер для сгенерированного кода -->
                                    <div id="generatedCodeContainer" style="display: none; margin-top: 10px;">
                                        <h3>Сгенерированный код:</h3>
                                        <textarea id="generatedCodeArea" style="width: 100%; height: 150px; padding: 10px; font-family: monospace;" readonly></textarea>
                                        <button onclick="copyGeneratedCode()">Копировать код</button>
                                        <button onclick="deleteLastFunction()">Удалить последнюю добавленную функцию</button>
                                        <button onclick="restoreLastDeletedFunction()">Восстановить последнюю удалённую</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <h2>Сгенерированный Lua-код</h2>
                        <div id="output" class="code-box">// Здесь появится сгенерированный Lua-код</div>
                        <button onclick="generateScript()">Сгенерировать</button>
                        <button onclick="copyScript()">Копировать</button>
                        <button onclick="removeLastAddedFunction()">Удалить последнюю добавленную функцию</button>
                        <button onclick="restoreLastRemovedFunction()">Восстановить последнюю удалённую</button>
                        <!-- Import File Button -->
                        <input type="file" id="importFile" style="display: none;" onchange="importFile(event)">
                        <button onclick="document.getElementById('importFile').click()">Импорт файла</button>
                    </div>

                    <script>
                        let generatedFunctions = [];
                            let allFunctions = ""; // Все сгенерированные функции
                            let mainMenuName = "HM"; // По умолчанию имя главного меню
                            let functionName = "myFunction";
                            let mainMenuCode = "";
                            let allFunctionsList = []; // Список всех добавленных функций
                            let deletedFunctions = [];
                            function updateInterface() {
                                const customFunctionCount = document.getElementById("customFunctionCount");
                                const functionCountInput = document.getElementById("functionCount");
                                const functionSetupMenu = document.getElementById("functionSetupMenu");
                                const functionNamesContainer = document.getElementById("functionNamesContainer");
                                const searchMenu = document.getElementById("searchMenu");
                                const generateSearchMenu = document.getElementById("generateSearchMenu");

                                // Показать поле для ввода количества функций, если выбран чекбокс
                                if (customFunctionCount.checked) {
                                    functionCountInput.style.display = "block";
                                } else {
                                    // Скрыть всё, если чекбокс снят
                                    functionCountInput.style.display = "none";
                                    functionSetupMenu.style.display = "none";
                                    functionNamesContainer.innerHTML = "";
                                    searchMenu.style.display = "none";
                                    return;
                                }

                                // Обработка ввода количества функций
                                const functionCount = parseInt(functionCountInput.value, 10);
                                if (!isNaN(functionCount) && functionCount > 0) {
                                    functionNamesContainer.innerHTML = "";

                                    // Создаём поля для названий функций
                                    for (let i = 0; i < functionCount; i++) {
                                        const input = document.createElement("input");
                                        input.type = "text";
                                        input.placeholder = `Название функции ${i + 1}`;
                                        input.className = "functionNameInput";
                                        functionNamesContainer.appendChild(input);
                                    }

                                    functionSetupMenu.style.display = "block";
                                    generateSearchMenu.style.display = "block";
                                } else {
                                    functionSetupMenu.style.display = "none";
                                    generateSearchMenu.style.display = "none";
                                }
                            }

                            function setupSearchMenu() {
                                const functionNames = Array.from(document.getElementsByClassName("functionNameInput")).map(input => input.value.trim());
                                if (functionNames.some(name => name === "")) {
                                    alert("❌ Укажите названия для всех функций");
                                    return;
                                }
                                document.getElementById("searchMenu").style.display = "block";
                            }

                            // Обработчики событий
                            document.getElementById("customFunctionCount").addEventListener("change", updateInterface);
                            document.getElementById("functionCount").addEventListener("input", updateInterface);
                            document.getElementById("generateSearchMenu").addEventListener("click", setupSearchMenu);
                            // Функция для показа/скрытия списка "ПОЛЕЗНЫЕ ФУНКЦИИ"
                        // Показ/скрытие списка "ПОЛЕЗНЫЕ ФУНКЦИИ"
                        function importFile(event) {
                            const file = event.target.files[0];
                            if (file) {
                                const reader = new FileReader();
                                reader.onload = function(e) {
                                    importedFileContent = e.target.result;
                                    document.getElementById('output').textContent = importedFileContent;
                                    allFunctionsList.push(importedFileContent); // Add imported content to the list of functions
                                    refreshAllFunctions(); // Refresh the Lua code
                                };
                                reader.readAsText(file);
                            }
                        }
                        function toggleSettingsMenu() {
                            const settingsMenu = document.getElementById('settingsMenu');
                            settingsMenu.classList.toggle('active');
                        }

                         function toggleDesktopMode() {
            const viewport = document.querySelector("meta[name=viewport]");
            if (viewport.content.includes("width=device-width")) {
                viewport.content = "width=500";
            } else {
                viewport.content = "width=device-width, initial-scale=1.0";
            }
        }
                          function toggleStyleMenu() {
                                    const styleMenu = document.getElementById('styleMenu');
                                    styleMenu.classList.toggle('active');
                                }
                           function setDefaultStyle() {
                                    document.getElementById('dynamic-style').innerHTML = `
                                        body {
                            font-family: 'Arial', sans-serif;
                            padding: 20px;
                            color: #f0f0f0;
                            background: linear-gradient(135deg, #282828, #1c1c1c); /* Серый и угольно-черный градиент */
                        }
                        h1, h2 {
                            text-align: center;
                            text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.7); /* Глубокая тень */
                            color: #ffaa00; /* Золотистый для заголовков */
                        }
                        .container {
                            max-width: 900px;
                            margin: 0 auto;
                        }
                        .functions {
                            display: flex;
                            flex-direction: column;
                            gap: 15px;
                            margin-top: 20px;
                        }
                        .function {
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            gap: 10px;
                            padding: 15px;
                            border: 2px solid #ffaa00; /* Золотистая рамка */
                            border-radius: 12px;
                            background-color: #1a1a1a; /* Угольно-черный фон карточек */
                            color: #fff; /* Белый текст */
                            box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.6); /* Глубокая тень для объёма */
                        }
                        .code-box {
                            white-space: pre-wrap;
                            font-family: monospace;
                            border: 1px solid #ffaa00; /* Золотистая рамка */
                            padding: 20px;
                            background-color: #333333; /* Тёмно-серый для области кода */
                            margin: 30px 0;
                            height: 300px;
                            overflow-y: scroll;
                            box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.4); /* Тень для области кода */
                        }
                        button {
                            padding: 10px 20px; /* Размеры кнопок сохранены */
                            font-size: 15px;
                            font-weight: bold;
                            color: #1a1a1a; /* Чёрный текст */
                            background: #ffaa00; /* Золотистый фон кнопки */
                            border: 2px solid #cc8400; /* Тёмно-золотистая рамка */
                            border-radius: 8px;
                            cursor: pointer;
                            transition: all 0.3s ease-in-out;
                            text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.5); /* Лёгкая тень для текста */
                            margin-bottom: 12px;
                        }
                        button:hover {
                            background: #cc8400; /* Тёмно-золотистый при наведении */
                            color: #f0f0f0; /* Светлый текст при наведении */
                            border-color: #ffaa00; /* Золотистая рамка при наведении */
                            transform: scale(1.05); /* Лёгкое увеличение */
                            box-shadow: 0px 5px 15px rgba(204, 132, 0, 0.8); /* Сильная золотистая тень при наведении */
                        }
                                        .menu-options {
                                            display: none;
                                            margin-top: 20px;
                                        }
                                        .menu-options.active {
                                            display: block;
                                        }
                                        .menu-settings {
                                            margin-bottom: 20px;
                                        }
                                        #emojiMenu select {
                                            width: 10%;
                                            height: auto;
                                        }
                                        #instructionBlock {
                                            color: #fff;
                                        }
                                    `;
                                }


                           function setGradientStyle() {
                                    document.getElementById('dynamic-style').innerHTML = `
                                       body {
                                            font-family: Arial, sans-serif;
                                            padding: 20px;
                                            color: #333;
                                            background: linear-gradient(135deg, #6a11cb, #2575fc);
                                        }
                                        h1, h2 {
                                            text-align: center;
                                            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
                                            color: #66b3ff;
                                            border-bottom: 4px solid #66b3ff;
                                        }
                                        .container {
                                            max-width: 900px;
                                            margin: 0 auto;
                                        }
                                        .functions {
                                            display: flex;
                                            flex-direction: column;
                                            gap: 15px;
                                            margin-top: 20px;
                                        }
                                        .function {
                                            display: flex;
                                            flex-wrap: wrap;
                                            align-items: center;
                                            gap: 15px;
                                            padding: 15px;
                                            border: 1px solid #6a11cb;
                                            border-radius: 8px;
                                            background-color: #ffffff;
                                            color: #000;
                                            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
                                        }
                                        .code-box {
                                            white-space: pre-wrap;
                                            font-family: monospace;
                                            border: 1px solid #6a11cb;
                                            padding: 15px;
                                            background-color: #ffffff;
                                            margin: 20px 0;
                                            height: 300px;
                                            overflow-y: scroll;
                                            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
                                        }
                                        button {
                                            padding: 10px 20px;
                                            font-size: 15px;
                                            font-weight: bold;
                                            color: #fff;
                                            background: rgba(0, 0, 0, 0.2);
                                            border: 2px solid #fff;
                                            border-radius: 10px;
                                            cursor: pointer;
                                            transition: all 0.3s ease-in-out;
                                            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                                            margin-bottom: 10px;
                                        }
                                        button:hover {
                                            background: #fff;
                                            color: #6a11cb;
                                            border-color: #6a11cb;
                                            transform: scale(1.1);
                                            box-shadow: 0px 4px 15px rgba(106, 17, 203, 0.5);
                                        }
                                        .menu-options {
                                            display: none;
                                            margin-top: 20px;
                                        }
                                        .menu-options.active {
                                            display: block;
                                        }
                                        .menu-settings {
                                            margin-bottom: 20px;
                                        }
                                        #emojiMenu select {
                                            width: 10%;
                                            height: auto;
                                        }
                                        #instructionBlock {
                                            color: #000;
                                        }
                                    `;
                                }

                            function setGradientStyle2() {
                            const gradientStyle2 = `
                                 body {
                            font-family: Arial, sans-serif;
                            padding: 20px;
                            color: #333;
                            background: linear-gradient(135deg, #6a11cb, #2575fc); /* Градиент фиолетово-синий */
                            font-family: 'Arial', sans-serif;
                            color: #fff;
                        }
                        h1, h2 {
                            text-align: center;
                            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
                            color: #7000e3;
                        }
                        .container {
                            max-width: 900px;
                            margin: 0 auto;
                        }
                        .functions {
                            display: flex;
                            flex-direction: column;
                            gap: 15px;
                            margin-top: 20px;
                        }
                        .function {
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            gap: 15px;
                            padding: 10px;
                            border: 1px solid #6a11cb; /* Новый цвет рамки */
                            border-radius: 8px;
                            background-color: #ffffff; /* Белый фон */
                            color: #000; /* Черный текст */
                        }
                        .code-box {
                            white-space: pre-wrap;
                            font-family: monospace;
                            border: 1px solid #6a11cb;
                            padding: 10px;
                            background-color: #ffffff;
                            margin: 20px 0;
                            height: 300px;
                            overflow-y: scroll;
                        }
                        button {
                            padding: 10px 20px;
                            font-size: 15px;
                            font-weight: bold;
                            color: #fff;
                            background: rgba(0, 0, 0, 0.2);
                            border: 2px solid #fff;
                            border-radius: 10px;
                            cursor: pointer;
                            transition: all 0.3s ease-in-out;
                            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                            margin-bottom: 10px;
                        }
                        button:hover {
                            background: #fff;
                            color: #6a11cb; /* Новый цвет текста при наведении */
                            border-color: #6a11cb; /* Новый цвет рамки при наведении */
                            transform: scale(1.1);
                            box-shadow: 0px 4px 15px rgba(106, 17, 203, 0.5); /* Новый цвет тени */
                        }
                        .menu-options {
                            display: none;
                            margin-top: 20px;
                        }
                        .menu-options.active {
                            display: block;
                        }
                        .menu-settings {
                            margin-bottom: 20px;
                        }
                        #emojiMenu select {
                            width: 10%;
                            height: auto;
                        }
                        #instructionBlock {
                            color: #000;
                        }
                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle2;

                        }

                        function setGradientStyle3() {
                            const gradientStyle3 = `
                               body {
                                            font-family: Arial, sans-serif;
                                            padding: 20px;
                                            color: #fff;
                                            background: linear-gradient(135deg, #ff4d4d, #4d0000); /* Более светлый красно-бордовый градиент */
                                            font-family: 'Arial', sans-serif;
                                        }
                                        h1, h2 {
                                            text-align: center;
                                            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
                                            color: #ff3333; /* Светлее для контраста */
                                        }
                                        .container {
                                            max-width: 900px;
                                            margin: 0 auto;
                                        }
                                        .functions {
                                            display: flex;
                                            flex-direction: column;
                                            gap: 15px;
                                            margin-top: 20px;
                                        }
                                        .function {
                                            display: flex;
                                            flex-wrap: wrap;
                                            align-items: center;
                                            gap: 15px;
                                            padding: 15px;
                                            border: 1px solid #ff6666; /* Светлая красная рамка */
                                            border-radius: 8px;
                                            background-color: #2b2b2b; /* Тёмно-серый фон карточек */
                                            color: #fff; /* Белый текст */
                                            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3); /* Лёгкая тень */
                                        }
                                        .code-box {
                                            white-space: pre-wrap;
                                            font-family: monospace;
                                            border: 1px solid #ff6666; /* Красная рамка */
                                            padding: 15px;
                                            background-color: #3b3b3b; /* Более светлый серый для текста */
                                            margin: 20px 0;
                                            height: 300px;
                                            overflow-y: scroll;
                                            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3); /* Ещё более мягкая тень */
                                        }
                                        button {
                                            padding: 10px 20px;
                                            font-size: 15px;
                                            font-weight: bold;
                                            color: #fff;
                                            background: #ff3333; /* Светло-красный фон кнопки */
                                            border: 2px solid #4d0000; /* Бордовая рамка */
                                            border-radius: 10px;
                                            cursor: pointer;
                                            transition: all 0.3s ease-in-out;
                                            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
                                            margin-bottom: 10px;
                                        }
                                        button:hover {
                                            background: #ff6666; /* Ещё более светлый красный при наведении */
                                            color: #2b2b2b; /* Тёмно-серый текст при наведении */
                                            border-color: #ff3333; /* Светлая рамка при наведении */
                                            transform: scale(1.1);
                                            box-shadow: 0px 4px 15px rgba(255, 102, 102, 0.6); /* Мягкая тень */
                                        }
                        .menu-options {
                            display: none;
                            margin-top: 25px;
                        }
                        .menu-options.active {
                            display: block;
                        }
                        .menu-settings {
                            margin-bottom: 20px;
                        }
                        #emojiMenu select {
                            width: 12%;
                            height: auto;
                        }
                        #instructionBlock {
                            color: #f0f0f0;
                        }


                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle3;

                        }

                        function setGradientStyle4() {
                            const gradientStyle4 = `
                               body {
                            font-family: Arial, sans-serif;
                            padding: 20px;
                            color: #fff;
                            background: linear-gradient(135deg, #4d79ff, #33cc66); /* Синий и светло-зелёный градиент */
                            font-family: 'Arial', sans-serif;
                        }
                        h1, h2 {
                            text-align: center;
                            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
                            color: #66b3ff; /* Светло-синий для контраста */
                        }
                        .container {
                            max-width: 900px;
                            margin: 0 auto;
                        }
                        .functions {
                            display: flex;
                            flex-direction: column;
                            gap: 15px;
                            margin-top: 20px;
                        }
                        .function {
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            gap: 15px;
                            padding: 15px;
                            border: 1px solid #80b3ff; /* Мягкий голубой */
                            border-radius: 8px;
                            background-color: #2c3e50; /* Тёмно-синий фон карточек */
                            color: #fff; /* Белый текст */
                            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
                        }
                        .code-box {
                            white-space: pre-wrap;
                            font-family: monospace;
                            border: 1px solid #80b3ff; /* Мягкий голубой */
                            padding: 15px;
                            background-color: #34495e; /* Более тёмный синий для текста */
                            margin: 20px 0;
                            height: 300px;
                            overflow-y: scroll;
                            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
                        }
                        button {
                            padding: 10px 20px;
                            font-size: 15px;
                            font-weight: bold;
                            color: #fff;
                            background: #66b3ff; /* Светло-синий фон кнопки */
                            border: 2px solid #1f3a6d; /* Тёмно-синий бордюр */
                            border-radius: 10px;
                            cursor: pointer;
                            transition: all 0.3s ease-in-out;
                            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
                            margin-bottom: 10px;
                        }
                        button:hover {
                            background: #80b3ff; /* Светлее синий при наведении */
                            color: #2c3e50; /* Тёмно-синий текст при наведении */
                            border-color: #66b3ff; /* Светлый синий при наведении */
                            transform: scale(1.1);
                            box-shadow: 0px 4px 15px rgba(102, 179, 255, 0.6); /* Мягкая голубая тень */
                        }
                        .menu-options {
                            display: none;
                            margin-top: 20px;
                        }
                        .menu-options.active {
                            display: block;
                        }
                        .menu-settings {
                            margin-bottom: 20px;
                        }
                        #emojiMenu select {
                            width: 10%;
                            height: auto;
                        }
                        #instructionBlock {
                            color: #fff;
                        }

                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle4;

                        }

                        function setGradientStyle5() {
                            const gradientStyle5 = `
                                body {
                            font-family: 'Arial', sans-serif;
                            padding: 20px;
                            color: #e1e1e1;
                            background: linear-gradient(135deg, #2e3b4e, #1a242f); /* Тёмный градиент с синими и угольно-серыми оттенками */
                        }
                        h1, h2 {
                            text-align: center;
                            text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.6); /* Изменена тень для текста */
                            color: #0052cc; /* Тёплый оранжевый для контраста */
                        }
                        .container {
                            max-width: 900px;
                            margin: 0 auto;
                        }
                        .functions {
                            display: flex;
                            flex-direction: column;
                            gap: 15px;
                            margin-top: 20px;
                        }
                        .function {
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            gap: 15px;
                            padding: 15px;
                            border: 1px solid #4b6584; /* Темный синий для границы */
                            border-radius: 8px;
                            background-color: #1e272e; /* Глубокий тёмно-синий фон карточек */
                            color: #f0f0f0; /* Светлый текст для контраста */
                            box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.6); /* Умеренная тень */
                        }
                        .code-box {
                            white-space: pre-wrap;
                            font-family: monospace;
                            border: 1px solid #4b6584; /* Темный синий для границы */
                            padding: 15px;
                            background-color: #2f3640; /* Тёмно-серый фон для кода */
                            margin: 20px 0;
                            height: 300px;
                            overflow-y: scroll;
                            box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.4); /* Легкая тень */
                        }
                        button {
                            padding: 10px 20px;
                            font-size: 15px;
                            font-weight: bold;
                            color: #fff;
                            background: #ff6f61; /* Тёмно-красный для фона кнопки */
                            border: 2px solid #d74b3a; /* Бордюр в цвет кнопки */
                            border-radius: 10px;
                            cursor: pointer;
                            transition: all 0.3s ease-in-out;
                            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4); /* Лёгкая тень для текста кнопки */
                            margin-bottom: 10px;
                        }
                        button:hover {
                            background: #ff8f7d; /* Более светлый красный при наведении */
                            color: #2f3640; /* Тёмно-серый текст при наведении */
                            border-color: #ff6f61; /* Рамка в цвет фона при наведении */
                            transform: scale(1.05); /* Меньшее увеличение при наведении */
                            box-shadow: 0px 4px 12px rgba(255, 111, 97, 0.7); /* Мягкая тень при наведении */
                        }
                        .menu-options {
                            display: none;
                            margin-top: 20px;
                        }
                        .menu-options.active {
                            display: block;
                        }
                        .menu-settings {
                            margin-bottom: 20px;
                        }
                        #emojiMenu select {
                            width: 10%;
                            height: auto;
                        }
                        #instructionBlock {
                            color: #e1e1e1;
                        }

                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle5;

                        }

                        function setGradientStyle6() {
                            const gradientStyle6 = `
                              body {
                            font-family: 'Arial', sans-serif;
                            padding: 20px;
                            color: #fff;
                            background: linear-gradient(135deg, #00aaff, #005577); /* Ярко-синий и глубокий голубой градиент */
                        }
                        h1, h2 {
                            text-align: center;
                            text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6); /* Сильная тень для текста */
                            color: #e6b800; /* Яркий жёлтый для контраста */
                        }
                        .container {
                            max-width: 900px;
                            margin: 0 auto;
                        }
                        .functions {
                            display: flex;
                            flex-direction: column;
                            gap: 20px;
                            margin-top: 30px;
                        }
                        .function {
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            gap: 20px;
                            padding: 20px;
                            border: 2px solid #1f7e8f; /* Цвет границы в сине-зеленом стиле */
                            border-radius: 10px;
                            background-color: #004d60; /* Глубокий темно-синий фон карточек */
                            color: #fff; /* Белый текст */
                            box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.5); /* Мягкая тень для объёма */
                        }
                        .code-box {
                            white-space: pre-wrap;
                            font-family: monospace;
                            border: 1px solid #1f7e8f; /* Цвет границы в сине-зеленом стиле */
                            padding: 20px;
                            background-color: #006f8f; /* Синий фон для кода */
                            margin: 30px 0;
                            height: 300px;
                            overflow-y: scroll;
                            box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.4); /* Лёгкая тень для области кода */
                        }
                        button {
                            padding: 10px 20px; /* Размеры кнопок оставлены прежними */
                            font-size: 15px;
                            font-weight: bold;
                            color: #fff;
                            background: #ffcc00; /* Ярко-желтая кнопка */
                            border: 2px solid #ff9900; /* Оранжевая рамка */
                            border-radius: 10px;
                            cursor: pointer;
                            transition: all 0.3s ease-in-out;
                            text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.4); /* Лёгкая тень для текста кнопки */
                            margin-bottom: 12px;
                        }
                        button:hover {
                            background: #ff9900; /* Более яркий жёлтый при наведении */
                            color: #004d60; /* Тёмно-синий текст при наведении */
                            border-color: #ffcc00; /* Рамка в цвет фона при наведении */
                            transform: scale(1.05); /* Лёгкое увеличение при наведении */
                            box-shadow: 0px 5px 15px rgba(255, 204, 0, 0.8); /* Сильная тень при наведении */
                        }
                        .menu-options {
                            display: none;
                            margin-top: 25px;
                        }
                        .menu-options.active {
                            display: block;
                        }
                        .menu-settings {
                            margin-bottom: 20px;
                        }
                        #emojiMenu select {
                            width: 12%;
                            height: auto;
                        }
                        #instructionBlock {
                            color: #fff;
                        }

                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle6;

                        }
                        function setGradientStyle7() {
                            const gradientStyle7 = `
                                body {
                                    font-family: Arial, sans-serif;
                                    padding: 20px;
                                    color: #333;
                                    background: linear-gradient(135deg, #ffafbd, #ffc3a0);
                                    font-family: 'Arial', sans-serif;
                                    color: #fff;
                                }
                                h1, h2 {
                                    text-align: center;
                                    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

                                }
                                .container {
                                    max-width: 900px;
                                    margin: 0 auto;
                                }
                                .functions {
                                    display: flex;
                                    flex-direction: column;
                                    gap: 15px;
                                    margin-top: 20px;
                                }
                                .function {
                                    display: flex;
                                    flex-wrap: wrap;
                                    align-items: center;
                                    gap: 15px;
                                    padding: 10px;
                                    border: 1px solid #ccc;
                                    border-radius: 8px;
                                    background-color: white;
                                    color: #000;
                                }
                                .code-box {
                                    white-space: pre-wrap;
                                    font-family: monospace;
                                    border: 1px solid #ccc;
                                    padding: 10px;
                                    background-color: white;
                                    margin: 20px 0;
                                    height: 300px;
                                    overflow-y: scroll;
                                }
                                button {
                                    padding: 10px 20px;
                                    font-size: 15px;
                                    font-weight: bold;
                                    color: #fff;
                                    background: rgba(0, 0, 0, 0.2);
                                    border: 2px solid #fff;
                                    border-radius: 10px;
                                    cursor: pointer;
                                    transition: all 0.3s ease-in-out;
                                    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                                    margin-bottom: 10px;
                                }
                                button:hover {
                                    background: #fff;
                                    color: #ffafbd;
                                    border-color: #ffafbd;
                                    transform: scale(1.1);
                                    box-shadow: 0px 4px 15px rgba(255, 175, 189, 0.5);
                                }
                                .menu-options {
                                    display: none;
                                    margin-top: 20px;
                                }
                                .menu-options.active {
                                    display: block;
                                }
                                .menu-settings {
                                    margin-bottom: 20px;
                                }
                                #emojiMenu select {
                                    width: 10%;
                                    height: auto;
                                }
                                #instructionBlock {
                                    color: #000;
                                }
                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle7;

                        }

                        function setGradientStyle8() {
                            const gradientStyle8 = `
                                body {
                                    font-family: Arial, sans-serif;
                                    padding: 20px;
                                    color: #333;
                                    background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
                                    font-family: 'Arial', sans-serif;
                                    color: #fff;
                                }
                                h1, h2 {
                                    text-align: center;
                                    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

                                }
                                .container {
                                    max-width: 900px;
                                    margin: 0 auto;
                                }
                                .functions {
                                    display: flex;
                                    flex-direction: column;
                                    gap: 15px;
                                    margin-top: 20px;
                                }
                                .function {
                                    display: flex;
                                    flex-wrap: wrap;
                                    align-items: center;
                                    gap: 15px;
                                    padding: 10px;
                                    border: 1px solid #ccc;
                                    border-radius: 8px;
                                    background-color: white;
                                    color: #000;
                                }
                                .code-box {
                                    white-space: pre-wrap;
                                    font-family: monospace;
                                    border: 1px solid #ccc;
                                    padding: 10px;
                                    background-color: white;
                                    margin: 20px 0;
                                    height: 300px;
                                    overflow-y: scroll;
                                }
                                button {
                                    padding: 10px 20px;
                                    font-size: 15px;
                                    font-weight: bold;
                                    color: #fff;
                                    background: rgba(0, 0, 0, 0.2);
                                    border: 2px solid #fff;
                                    border-radius: 10px;
                                    cursor: pointer;
                                    transition: all 0.3s ease-in-out;
                                    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                                    margin-bottom: 10px;
                                }
                                button:hover {
                                    background: #fff;
                                    color: #a1c4fd;
                                    border-color: #a1c4fd;
                                    transform: scale(1.1);
                                    box-shadow: 0px 4px 15px rgba(161, 196, 253, 0.5);
                                }
                                .menu-options {
                                    display: none;
                                    margin-top: 20px;
                                }
                                .menu-options.active {
                                    display: block;
                                }
                                .menu-settings {
                                    margin-bottom: 20px;
                                }
                                #emojiMenu select {
                                    width: 10%;
                                    height: auto;
                                }
                                #instructionBlock {
                                    color: #000;
                                }
                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle8;

                        }

                        function setGradientStyle9() {
                            const gradientStyle9 = `
                                body {
                                    font-family: Arial, sans-serif;
                                    padding: 20px;
                                    color: #333;
                                    background: linear-gradient(135deg, #d4fc79, #96e6a1);
                                    font-family: 'Arial', sans-serif;
                                    color: #fff;
                                }
                                h1, h2 {
                                    text-align: center;
                                    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

                                }
                                .container {
                                    max-width: 900px;
                                    margin: 0 auto;
                                }
                                .functions {
                                    display: flex;
                                    flex-direction: column;
                                    gap: 15px;
                                    margin-top: 20px;
                                }
                                .function {
                                    display: flex;
                                    flex-wrap: wrap;
                                    align-items: center;
                                    gap: 15px;
                                    padding: 10px;
                                    border: 1px solid #ccc;
                                    border-radius: 8px;
                                    background-color: white;
                                    color: #000;
                                }
                                .code-box {
                                    white-space: pre-wrap;
                                    font-family: monospace;
                                    border: 1px solid #ccc;
                                    padding: 10px;
                                    background-color: white;
                                    margin: 20px 0;
                                    height: 300px;
                                    overflow-y: scroll;
                                }
                                button {
                                    padding: 10px 20px;
                                    font-size: 15px;
                                    font-weight: bold;
                                    color: #fff;
                                    background: rgba(0, 0, 0, 0.2);
                                    border: 2px solid #fff;
                                    border-radius: 10px;
                                    cursor: pointer;
                                    transition: all 0.3s ease-in-out;
                                    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                                    margin-bottom: 10px;
                                }
                                button:hover {
                                    background: #fff;
                                    color: #d4fc79;
                                    border-color: #d4fc79;
                                    transform: scale(1.1);
                                    box-shadow: 0px 4px 15px rgba(212, 252, 121, 0.5);
                                }
                                .menu-options {
                                    display: none;
                                    margin-top: 20px;
                                }
                                .menu-options.active {
                                    display: block;
                                }
                                .menu-settings {
                                    margin-bottom: 20px;
                                }
                                #emojiMenu select {
                                    width: 10%;
                                    height: auto;
                                }
                                #instructionBlock {
                                    color: #000;
                                }
                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle9;

                        }

                        function setGradientStyle10() {
                            const gradientStyle10 = `
                                body {
                                    font-family: Arial, sans-serif;
                                    padding: 20px;
                                    color: #333;
                                    background: linear-gradient(135deg, #84fab0, #8fd3f4);
                                    font-family: 'Arial', sans-serif;
                                    color: #fff;
                                }
                                h1, h2 {
                                    text-align: center;
                                    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

                                }
                                .container {
                                    max-width: 900px;
                                    margin: 0 auto;
                                }
                                .functions {
                                    display: flex;
                                    flex-direction: column;
                                    gap: 15px;
                                    margin-top: 20px;
                                }
                                .function {
                                    display: flex;
                                    flex-wrap: wrap;
                                    align-items: center;
                                    gap: 15px;
                                    padding: 10px;
                                    border: 1px solid #ccc;
                                    border-radius: 8px;
                                    background-color: white;
                                    color: #000;
                                }
                                .code-box {
                                    white-space: pre-wrap;
                                    font-family: monospace;
                                    border: 1px solid #ccc;
                                    padding: 10px;
                                    background-color: white;
                                    margin: 20px 0;
                                    height: 300px;
                                    overflow-y: scroll;
                                }
                                button {
                                    padding: 10px 20px;
                                    font-size: 15px;
                                    font-weight: bold;
                                    color: #fff;
                                    background: rgba(0, 0, 0, 0.2);
                                    border: 2px solid #fff;
                                    border-radius: 10px;
                                    cursor: pointer;
                                    transition: all 0.3s ease-in-out;
                                    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
                                    margin-bottom: 10px;
                                }
                                button:hover {
                                    background: #fff;
                                    color: #84fab0;
                                    border-color: #84fab0;
                                    transform: scale(1.1);
                                    box-shadow: 0px 4px 15px rgba(132, 250, 176, 0.5);
                                }
                                .menu-options {
                                    display: none;
                                    margin-top: 20px;
                                }
                                .menu-options.active {
                                    display: block;
                                }
                                .menu-settings {
                                    margin-bottom: 20px;
                                }
                                #emojiMenu select {
                                    width: 10%;
                                    height: auto;
                                }
                                #instructionBlock {
                                    color: #000;
                                }
                            `;
                            document.getElementById('dynamic-style').innerHTML = gradientStyle10;

                        }
                            function showInstruction() {
                                const instructionBlock = document.getElementById('instructionBlock');
                                instructionBlock.style.display = 'block'; // Показываем блок инструкции
                            }

                            function hideInstruction() {
                                const instructionBlock = document.getElementById('instructionBlock');
                                instructionBlock.style.display = 'none'; // Скрываем блок инструкции
                            }
                        function toggleUsefulFunctions() {
                            const functionsList = document.getElementById('usefulFunctionsList');
                            functionsList.style.display = (functionsList.style.display === 'none' || functionsList.style.display === '')
                                ? 'block' : 'none';
                        }

                        // Генерация функции выбора региона памяти
                        function generateSelectMemoryFunction() {
                            const functionCode = `
                        function SelectMemory()
                            local UserRanges = gg.choice({"CA", "O", "A"}, 0, "Select Memory Ranges")
                            if UserRanges == nil then
                                gg.alert("Please Select Memory Ranges")
                                SelectMemory()
                            end
                            if UserRanges == 1 then
                                gg.setRanges(gg.REGION_C_ALLOC)
                            end
                            if UserRanges == 2 then
                                gg.setRanges(gg.REGION_OTHER)
                            end
                            if UserRanges == 3 then
                                gg.setRanges(gg.REGION_ANONYMOUS)
                            end
                        end`;

                            addFunctionToContainer(functionCode);
                        }

                        // Генерация функции создания пароля
                        function generatePasswordFunction() {
                            const functionCode = `

                        -- Создать переменную для ввода пользователя
                        local password = gg.prompt({"Enter Password"}, {[1] = '0'}, {[1] = 'text'})

                        -- Проверяем введённый пароль
                        if password[1] == "1028371" then
                            gg.alert("Correct Password")
                        else
                            gg.alert("Incorrect Password")
                        end`;

                            // Додаємо згенеровану функцію до блоку з кодом
                            addFunctionToContainer(functionCode);
                            alert("Функция пароля добавлена.");
                        }
                        // Удаляем последнюю добавленную функцию
                        function deleteLastFunction() {
                            if (generatedFunctions.length === 0) {
                                alert("Нет добавленных функций для удаления.");
                                return;
                            }

                            // Удаляем последнюю функцию и сохраняем её в массив удалённых
                            const lastFunction = generatedFunctions.pop();
                            deletedFunctions.push(lastFunction);

                            updateCodeContainer();
                        }

                        // Восстановление последней удалённой функции
                        function restoreLastDeletedFunction() {
                            if (deletedFunctions.length === 0) {
                                alert("Нет удалённых функций для восстановления.");
                                return;
                            }

                            // Перемещаем функцию из удалённых в добавленные
                            const restoredFunction = deletedFunctions.pop();
                            generatedFunctions.push(restoredFunction);

                            updateCodeContainer();
                            alert("Последняя удалённая функция восстановлена.");
                        }

                        // Добавляем функцию в контейнер
                        function addFunctionToContainer(functionCode) {
                            generatedFunctions.push(functionCode);
                            updateCodeContainer();
                            alert("Функция добавлена.");
                        }

                        // Обновляем содержимое текстового поля с функциями
                        function updateCodeContainer() {
                            const codeContainer = document.getElementById('generatedCodeContainer');
                            const codeArea = document.getElementById('generatedCodeArea');

                            // Если функции нет, скрываем блок с кодом
                            if (generatedFunctions.length === 0) {
                                codeContainer.style.display = 'none';
                                codeArea.value = '';
                            } else {
                                codeContainer.style.display = 'block';
                                codeArea.value = generatedFunctions.join('\n\n');
                            }
                        }

                        // Копируем код из текстового поля
                        function copyGeneratedCode() {
                            const codeArea = document.getElementById('generatedCodeArea');
                            codeArea.select();
                            document.execCommand('copy');
                            alert("Код скопирован в буфер обмена!");
                        }
                            function showInstruction() {
                            const instructionBlock = document.getElementById('instructionBlock');
                            instructionBlock.style.display = 'block'; // Показываем блок инструкции
                        }

                        function hideInstruction() {
                            const instructionBlock = document.getElementById('instructionBlock');
                            instructionBlock.style.display = 'none'; // Скрываем блок инструкции
                        }
                            document.getElementById("usePrimaryRegion").addEventListener("change", function () {
                                // Проверка: если чекбокс включен — разблокировать, иначе — заблокировать
                                const primaryRegionSelect = document.getElementById("primaryRegion");
                                primaryRegionSelect.disabled = !this.checked;
                            });
                        document.getElementById('subMenuFunctions').addEventListener('input', function() {
                            var functions = this.value.split(',');
                            var emojiMenu = document.getElementById('emojiMenu');

                            emojiMenu.innerHTML = '';

                            functions.forEach(function(func, index) {
                                var label = document.createElement('label');
                                label.for = "functionEmojis"+(index+1);
                                label.innerHTML = "Емодзi для "+func.trim()+": ";

                                var select = document.createElement('select');
                                select.id = "functionEmojis"+(index+1);

                                var emojis = ["✅", "⚙️", "⭐", "💡", "🔑", "🔍", "👍", "⛔", "⚡", "💥", "🆘", "🆕", "🆙", "🔄","🤑", "❄️", "☄️", "🔥", "🌪️", "🌀", "🪐", "📌", "🔒", "🛡️", "📁", "🔨", "👑", "🌍"];

                                emojis.forEach(function(emoji) {
                                    var option = document.createElement('option');
                                    option.value = emoji;
                                    option.innerHTML = emoji;
                                    select.appendChild(option);
                                });

                                emojiMenu.appendChild(label);
                                emojiMenu.appendChild(select);
                            });
                        });

                        function toggleEmojiMenu() {
                            var menu = document.getElementById('emojiMenu');
                            menu.style.display = (menu.style.display === "none") ? "block" : "none";
                        }
                          function setupMainF() {
                              document.getElementById("menuSettingss").classList.toggle("active"); // Показать настройки меню
                            }

                        function generateSubMenu() {
                            const functionName = document.getElementById("subMenuFunctionName").value.trim() || "Підменю";
                            const itemNames = document.getElementById("subMenuItemNames").value.split(",").map(i => i.trim());
                            const functionCalls = document.getElementById("subMenuFunctions").value.split(",").map(f => f.trim());
                            let emojis = [];
                            for(let i = 1; i <= functionCalls.length; i++) {
                                emojis.push(document.getElementById(`functionEmojis${i}`).value);
                            }
                            const menuStyle = document.getElementById("menuStyle").value;
                            const functionStyle = document.getElementById("functionStyle").value;

                            if (itemNames.length !== functionCalls.length) {
                                alert("Помилка: Кількість пунктів та функцій повинна співпадати!");
                                return;
                            }

                            let menuCode = `-- Функція: ${functionName}\nfunction ${functionName}()\n`;
                            menuCode += "  menu = gg.choice({\n";

                            itemNames.forEach((item, index) => {
                                const emoji = emojis[index] || "";
                                let styledItem = item;

                                switch (functionStyle) {
                                    case "brackets":
                                        styledItem = `『 ➱ ${item} 』`;
                                        break;
                                    case "arrow":
                                        styledItem = `➤ ${item}`;
                                        break;
                                    case "bars":
                                        styledItem = `▁▂▃ ${item} ▃▂▁`;
                                    case "parallel":
                                    styledItem = `║ ${item} ║`;
                                    break;
                                    case "cut":
                                    styledItem = `◤ ${item} ◥`;
                                    break;
                                    case "but":
                                    styledItem = `[+] ${item}`;
                                    break;
                                    default:
                                        styledItem = `${item}`;
                                }

                                menuCode += `    "${emoji} ${styledItem}",\n`;
                            });

                            let styledBack = "Назад";
                            switch (functionStyle) {
                                case "brackets":
                                    styledBack = `『 ➱ Назад 』`;
                                    break;
                                case "arrow":
                                    styledBack = `➤ Назад`;
                                    break;
                                case "bars":
                                    styledBack = `▁▂▃ Назад ▃▂▁`;
                                    break;
                                default:
                                    styledBack = `Назад`;
                            }

                            menuCode += `    "❌ ${styledBack}"\n  })`;

                            if (menuStyle === "normal") {
                                menuCode += `, nil, "Виберіть пункт"\n`;
                            } else if (menuStyle === "circle") {
                                menuCode += `, 0, "Виберіть пункт"\n`;
                            }

                            menuCode += `  if menu == nil then return end\n`;

                            itemNames.forEach((_, index) => {
                                const funcName = functionCalls[index] || `SubFunction${index+1}`;
                                menuCode += `  if menu == ${index + 1} then ${funcName}() end\n`;
                            });

                            menuCode += `  if menu == ${itemNames.length + 1} then HM() end\n`;

                            menuCode += "end\n";

                            allFunctionsList.push(menuCode);
                            refreshAllFunctions();
                        }

                        function generateMainMenuWithFunctions() {
                            const mainMenuFunctionName = document.getElementById("mainMenuFunctionName").value.trim() || "HM"; // Название главного меню
                            const itemNames = document.getElementById("mainMenuItemNames").value.split(",").map(i => i.trim()); // Названия пунктов главного меню
                            const functionNames = document.getElementById("mainMenuFunctions").value.split(",").map(f => f.trim()); // Функции, вызываемые пунктами
                            const menuEmojis = document.getElementById("mainMenuEmojis").value.split(",").map(e => e.trim()); // Эмодзи для главного меню

                            let menuCode = `function ${mainMenuFunctionName}()\n`;
                            menuCode += "  menu = gg.choice({\n";

                            // Создаем пункты главного меню
                            for (let i = 0; i < itemNames.length; i++) {
                                const emoji = menuEmojis[i] || ""; // Если нет эмодзи для пункта, игнорируем
                                const itemName = itemNames[i] || `Пункт ${i + 1}`;
                                menuCode += `    "${emoji} ${itemName}",\n`; // Вставляем название пункта с эмодзи
                            }

                            menuCode += `  }, nil, "Выберите действие")\n`;
                            menuCode += `  if menu == nil then return end\n`;

                            // Добавляем выполнение соответствующих функций
                            for (let i = 0; i < functionNames.length; i++) {
                                const funcName = functionNames[i] || `F${i + 1}`;
                                menuCode += `  if menu == ${i + 1} then ${funcName}() end\n`;
                            }

                            menuCode += "end\\n";


                            // Добавляем готовую функцию в список
                            allFunctionsList.push(menuCode);

                            // Обновляем общий Lua-код
                            refreshAllFunctions();
                        }

                            // Установка имени функции
                            function setFunctionName() {
                                const input = document.getElementById("functionNameInput").value.trim();
                                functionName = input || "myFunction";
                                alert(`Название функции установлено: ${functionName}`);
                            }

                             // Устанавливаем название главного меню
                            function addMenu() {
                            const menuName = document.getElementById("mainMenuFunction").value.trim();
                            const mainMenuName = menuName || "HM";  // Если имя не введено, используем "HM" по умолчанию
                            const mainMenu = `\n  ${mainMenuName}()\n`;  // Формируем строку с функцией

                            // Добавляем готовую функцию в список
                            allFunctionsList.push(mainMenu);

                            // Добавляем строку в общий Lua-код
                            allFunctions += mainMenu;

                            // Обновляем отображение общего Lua-кода
                            refreshAllFunctions();
                        }


                           // Настройка главного меню
                            function setupMainMenu() {
                              document.getElementById("menuSettings").classList.toggle("active"); // Показать настройки меню
                            }
                         document.getElementById("customFunctionCount").addEventListener("change", function() {
                            const functionCountInput = document.getElementById("functionCount");
                            const functionSetupMenu = document.getElementById("functionSetupMenu");
                            functionCountInput.style.display = this.checked ? "block" : "none";
                            functionSetupMenu.style.display = this.checked ? "block" : "none";
                        });

                        document.getElementById("functionCount").addEventListener("input", function() {
                            const functionCount = parseInt(this.value, 10);
                            const functionNamesContainer = document.getElementById("functionNamesContainer");
                            const generateSearchMenuButton = document.getElementById("generateSearchMenu");
                            functionNamesContainer.innerHTML = "";
                            if (functionCount > 0) {
                                for (let i = 0; i < functionCount; i++) {
                                    const input = document.createElement("input");
                                    input.type = "text";
                                    input.className = "functionNameInput";
                                    input.placeholder = `Название функции ${i + 1}`;
                                    functionNamesContainer.appendChild(input);
                                }
                                generateSearchMenuButton.style.display = "block";
                            } else {
                                generateSearchMenuButton.style.display = "none";
                            }
                        });

                        document.getElementById("generateSearchMenu").addEventListener("click", function() {
                            const functionCount = parseInt(document.getElementById("functionCount").value, 10);
                            const searchInputsContainer = document.getElementById("searchInputsContainer");
                            searchInputsContainer.innerHTML = "";
                            if (functionCount > 0) {
                                for (let i = 0; i < functionCount; i++) {
                                    const div = document.createElement("div");
                                    div.className = "searchInputGroup";
                                    div.innerHTML = `
                                        <h3>Настройки для функции ${i + 1}</h3>
                                        <input type="text" class="searchValueInput" placeholder="Значение для поиска функции ${i + 1}">
                                        <select class="searchTypeInput">
                                            <option value="gg.TYPE_FLOAT">Float</option>
                                            <option value="gg.TYPE_DWORD">Dword</option>
                                        </select>
                                        <label>
                                            <input type="checkbox" class="dualReplaceInput"> Замена двух значений
                                        </label>
                                        <input type="text" class="editPrompt1Input" placeholder="Введите новое значение для первого числа функции ${i + 1}">
                                        <input type="text" class="editPrompt2Input" placeholder="Введите новое значение для второго числа функции ${i + 1}">
                                    `;
                                    searchInputsContainer.appendChild(div);
                                }
                                document.getElementById("searchMenu").style.display = "block";
                            }
                        });
                            // Генерация главного меню
                            function generateMainMenu() {
                            // Получаем настройки от пользователя
                            const functionCount = parseInt(document.getElementById("menuFunctionCount").value) || 1; // Количество пунктов меню
                            const author = document.getElementById("menuAuthor").value.trim() || "Автор"; // Имя автора
                            const menuText = document.getElementById("menuText").value.trim() || "By Lambo"; // Если поле пустое, используем "By Lambo"
                            const menuType = document.getElementById("menuType").value; // Тип меню (choice/multiChoice)
                            const itemNames = document.getElementById("menuItemNames").value.split(",").map(i => i.trim()); // Названия пунктов меню
                            const functionNames = document.getElementById("menuFunctionNames").value.split(",").map(f => f.trim()); // Названия функций
                            const menuEmojis = document.getElementById("menuEmojis").value.split(",").map(e => e.trim()); // Эмодзи для пунктов меню

                            // Создаём код меню
                            let menuCode = `-- Автор: ${author}\nfunction ${mainMenuName}()\n`;
                            menuCode += menuType === "multiChoice" ? "  menu = gg.multiChoice({\n" : "  menu = gg.choice({\n";

                            // Генерируем пункты меню
                            for (let i = 0; i < functionCount; i++) {
                                const emoji = menuEmojis[i] || ""; // Если нет эмодзи, оставляем пустую строку
                                const itemName = itemNames[i] || `Пункт ${i + 1}`; // Если название пункта не указано, генерируем название
                                menuCode += `    "${emoji} ${itemName}",\n`; // Формат пункта: "🔥 Название"
                            }

                            // Добавляем пункт "Выход"
                            menuCode += `    "❌ Выйти из скрипта"\n`; // Последний пункт меню

                            // Текст меню
                            const formattedMenuText = `${author} | ${menuText}`; // Комбинируем автора и дополнительный текст

                            // Завершаем создание меню
                            menuCode += `  }, nil, "${formattedMenuText}")\n`; // Название меню наверху
                            menuCode += `  if menu == nil then return end\n`; // Проверка, если пользователь ничего не выбрал

                            // Логика вызова функций
                            for (let i = 0; i < functionCount; i++) {
                                const funcName = functionNames[i] || `F${i + 1}`; // Если функция не указана, назначаем ей имя по умолчанию
                                menuCode += `  if menu == ${i + 1} then ${funcName}() end\n`; // Логика: if menu == 1 then функция()
                            }

                            // Логика для выхода из скрипта
                            menuCode += `  if menu == ${functionCount + 1} then gg.toast("Выход из скрипта") gg.exit() end\n`;

                            menuCode += "end\n"; // Конец функции меню



                            // Добавляем сгенерированное меню в общий список функций
                            allFunctionsList.push(menuCode);
                            refreshAllFunctions(); // Обновляем весь Lua-код в выводе
                        }
                            // Генерация Lua-кода
                        function generateScript(onlyReturn = false) {
                            let script = `function ${functionName}()\n`;

                            if (document.getElementById("hideGG").checked) {
                                script += `  gg.setVisible(false)\n`;
                            }
                            if (document.getElementById("clearResults").checked) {
                                script += `  gg.clearResults()\n`;
                            }
                         // Если выбрано количество функций
                         // Если выбрано количество функций
                            if (document.getElementById("customFunctionCount").checked) {
                                const functionCount = parseInt(document.getElementById("functionCount").value, 10) || 1;
                                // Получаем имена функций из полей ввода
                                const functionNames = Array.from(document.getElementsByClassName("functionNameInput"))
                                    .map(input => input.value.trim())
                                    .filter(name => name !== "");

                                // Получаем значения поиска для каждой функции
                                const searchValues = Array.from(document.getElementsByClassName("searchValueInput"))
                                    .map(input => input.value || "0");
                                const searchTypes = Array.from(document.getElementsByClassName("searchTypeInput"))
                                    .map(select => select.value);
                                const dualReplaces = Array.from(document.getElementsByClassName("dualReplaceInput"))
                                    .map(input => input.checked);
                                const editPrompt1s = Array.from(document.getElementsByClassName("editPrompt1Input"))
                                    .map(input => input.value || "0");
                                const editPrompt2s = Array.from(document.getElementsByClassName("editPrompt2Input"))
                                    .map(input => input.value || "0");

                                // Генерация скрипта
                                script += `
                        local partTypePrompt = gg.prompt({
                            "Введите тип части (1: ${functionNames.join(", 2: ")})"
                        }, {1}, {"number"})

                        if partTypePrompt == nil or partTypePrompt[1] == "" then
                            gg.toast("Отмена")
                            return
                        end

                        local partType = tonumber(partTypePrompt[1])
                        if partType < 1 or partType > ${functionCount} then
                            gg.toast("❌ Ошибка: Введите значение от 1 до ${functionCount}")
                            return
                        end

                        local searchValue, editPrompt1, editPrompt2, searchType
                        `;

                                // Генерируем условия для каждой функции с их уникальными значениями
                                for (let i = 0; i < functionCount; i++) {
                                    script += `
                        if partType == ${i + 1} then
                            searchValue = "${searchValues[i]}"
                            editPrompt1 = "Введите новое значение для числа ${functionNames[i]}:"
                            editPrompt2 = "Введите новое значение для числа ${functionNames[i]} (дополнительно):"
                            searchType = ${searchTypes[i]}
                        end
                        `;
                                }

                                script += `
                        gg.searchNumber(searchValue, searchType)
                        if gg.getResultCount() == 0 then
                            gg.toast("❌ Ошибка: Значений не найдено")
                            gg.clearResults()
                            return
                        end

                        local results = gg.getResults(gg.getResultCount())
                        local updatedResults = {}
                        local replace1 = gg.prompt({editPrompt1}, {${editPrompt1s[0]}}, {"number"})
                        local replace2 = gg.prompt({editPrompt2}, {${editPrompt2s[0]}}, {"number"})

                        if replace1 == nil or replace1[1] == "" or tonumber(replace1[1]) == nil then
                            gg.toast("❌ Ошибка: Некорректное значение для первого числа")
                            gg.clearResults()
                            return
                        end
                        if ${dualReplaces[0]} and (replace2 == nil or replace2[1] == "" or tonumber(replace2[1]) == nil) then
                            gg.toast("❌ Ошибка: Некорректное значение для второго числа")
                            gg.clearResults()
                            return
                        end

                        local newValue1 = tonumber(replace1[1])
                        local newValue2 = tonumber(replace2[1])

                        if ${dualReplaces[0]} then
                            for i = 1, #results, 2 do
                                if results[i] and results[i + 1] then
                                    results[i].value = newValue1
                                    results[i + 1].value = newValue2
                                    table.insert(updatedResults, results[i])
                                    table.insert(updatedResults, results[i + 1])
                                end
                            end
                        else
                            for i = 1, #results do
                                results[i].value = newValue1
                                table.insert(updatedResults, results[i])
                            end
                        end

                        gg.setValues(updatedResults)
                        gg.toast("✅ Значения успешно заменены")
                        gg.clearResults()
                        `;
                            }



                            // Проверка и добавление вызова gg.alert в начале
                            if (document.getElementById("alert").checked) {
                                const alertMessage = document.getElementById("alertMessage").value.trim() || "Повідомлення!";
                                const alertPlacement = document.getElementById("alertPlacement").value;

                                if (alertPlacement === "start") {
                                    script += `  gg.alert("${alertMessage}")\n`;
                                }
                            }

                            // Додаємо gg.toast або gg.alert на початку, якщо обрано
                            if (document.getElementById("toast").checked) {
                                const message = document.getElementById("toastMessage").value.trim() || "Скрипт запущен!";
                                const placement = document.getElementById("toastPlacement").value;

                                if (placement === "start") {
                                    script += `  gg.toast("${message}")\n`;
                                }
                            }

                            // Работа с основным регионом (чекбокс и выбор)
                            const usePrimaryRegion = document.getElementById("usePrimaryRegion").checked; // Проверяем, активен ли основной регион
                            if (usePrimaryRegion) {
                                const primaryRegion = document.getElementById("primaryRegion").value;
                                if (primaryRegion) {
                                    script += `  gg.setRanges(${primaryRegion})\n`;
                                    script += `  gg.toast("Основной регион установлен!")\n`;
                                }
                            }

                            // Работа с кастомными регионами
                            const customRegion1 = document.getElementById("customRegion1").value;
                            const customRegion2 = document.getElementById("customRegion2").value;
                            const customRegion3 = document.getElementById("customRegion3").value;

                            let customRegions = [];
                            if (customRegion1) customRegions.push(customRegion1);
                            if (customRegion2) customRegions.push(customRegion2);
                            if (customRegion3) customRegions.push(customRegion3);

                            if (customRegions.length > 0) {
                                const customRegionCode = customRegions.join(" | "); // Объединяем выбранные регионы через |
                                script += `  gg.setRanges(${customRegionCode})\n`;
                                script += `  gg.toast("Кастомные регионы установлены!")\n`;
                            }



                            if (document.getElementById("searchNumber").checked) {
                                const searchValue = document.getElementById("searchValue").value || "0"; // Значение для поиска
                                const searchType = document.getElementById("searchType").value; // Тип поиска: Float или Dword
                                script += `  gg.searchNumber("${searchValue}", ${searchType})\n`; // Генерация Lua-кода
                            }

                            if (document.getElementById("refineNumber").checked) {
                                const refineValue = document.getElementById("refineValue").value || "0"; // Уточняемое значение
                                const refineType = document.getElementById("refineType").value; // Выбранный тип данных (Float/Dword)
                                script += `  gg.refineNumber("${refineValue}", ${refineType})\n`; // Генерация кода
                            }
                            if (document.getElementById("getResults").checked) {
                                const resultsCount = document.getElementById("resultsCount").value || "1"; // Количество результатов по умолчанию — 1
                                script += `  local results = gg.getResults(${resultsCount})\n`; // Генерация Lua-кода для получения результатов
                                script += `  gg.toast("Получено результатов: " .. tostring(#results))\n`; // Уведомление об их количестве
                            }
                        if (document.getElementById("editAll").checked) {
                            // Получаем значение для замены
                            const editValue = document.getElementById("editValue").value.trim();
                            const editType = document.getElementById("editType").value;

                            // Проверяем, есть ли введенное значение для замены
                            if (editValue) {
                                // Выполняем замену всех значений с помощью gg.editAll
                                script += `  gg.editAll(${editValue}, ${editType})\n`;

                                // Добавляем уведомление об успешной замене
                                script += `  gg.toast("Заменены все значения на ${editValue}")\n`;
                            } else {
                                // Если значение не введено, показываем предупреждение
                                script += `  gg.toast("Введите значение для замены в gg.editAll!")\n`;
                                return;
                            }
                        }
                         if (document.getElementById("offsetReplace").checked) {
                                const offsetAddress = document.getElementById("offsetAddress").value.trim();
                                const offsetValue = document.getElementById("offsetValue").value.trim();
                                const offsetType = document.getElementById("offsetType").value;

                                if (offsetAddress && offsetValue) {
                                    script += `  for i = 1, #results do\n`;
                                    script += `    gg.setValues({\n`;
                                    script += `      [1] = {\n`;
                                    script += `        address = results[i].address + ${offsetAddress},\n`;
                                    script += `        flags = ${offsetType},\n`;
                                    script += `        value = ${offsetValue}\n`;
                                    script += `      }\n`;
                                    script += `    })\n`;
                                    script += `  end\n`;
                                    script += `  gg.toast("Значения заменены через оффсеты на ${offsetValue}")\n`;
                                } else {
                                    script += `  gg.toast("Введите адрес и значение для замены через оффсеты!")\n`;
                                    return;
                                }
                            }

                            // Замена через ввод значений (prompt)
                            if (document.getElementById("replaceInput").checked) {
                                const rangeMin = document.getElementById("rangeMin").value || "0";
                                const rangeMax = document.getElementById("rangeMax").value || "0";
                                const defaultPromptValue = document.getElementById("defaultPromptValue").value || "0";
                                const valueType = document.getElementById("replaceType").value;
                                script += `  local powerMenu = gg.prompt({"[${rangeMin};${rangeMax}]"}, {${defaultPromptValue}}, {"number"})\n`;
                                script += `  if powerMenu == nil then\n`;
                                script += `    gg.toast("Отмена")\n`;
                                script += `    return\n`;
                                script += `  end\n`;
                                script += `  gg.editAll(powerMenu[1], ${valueType})\n`;
                            }

                            if (document.getElementById("editWheel").checked) {
                                const multiplier = document.getElementById("wheelMultiplier").value || "1";
                                const rangeMin = document.getElementById("wheelMin").value || "0";
                                const rangeMax = document.getElementById("wheelMax").value || "0";
                                const valueType = document.getElementById("wheelType").value;
                                script += `  local powerMenu = gg.prompt({"[${rangeMin};${rangeMax}]"}, {"${multiplier}"}, {"number"})\n`;
                                script += `  if powerMenu == nil or powerMenu[1] == "" then\n`;
                                script += `    gg.toast("Отмена")\n`;
                                script += `    return\n`;
                                script += `  end\n`;
                                script += `  local newValue = tonumber(powerMenu[1])\n`;
                                script += `  gg.editAll(newValue, ${valueType})\n`;
                            }

                            if (document.getElementById("freezeValues").checked) {
                                const freezeValue = document.getElementById("freezeValue").value || "0";
                                script += `  for i, v in ipairs(results) do\n`;
                                script += `    results[i].value = ${freezeValue}\n`;
                                script += `    results[i].freeze = true\n`;
                                script += `  end\n`;
                                script += `  gg.setValues(results)\n`;
                                script += `  gg.addListItems(results)\n`;
                                script += `  gg.toast("Значения заморожены: ${freezeValue}")\n`;
                            }
                            if (document.getElementById("saveValues").checked) {
                                script += `  gg.addListItems(results)\n`; // Добавляем текущие результаты в список
                                script += `  gg.toast("Результаты сохранены в пользовательский список.")\n`;
                            }
                        // Додаємо gg.toast або gg.alert у кінці, якщо обрано
                            if (document.getElementById("toast").checked) {
                                const message = document.getElementById("toastMessage").value.trim() || "Скрипт завершён!";
                                const placement = document.getElementById("toastPlacement").value;

                                if (placement === "end") {
                                    script += `  gg.toast("${message}")\n`;
                                }
                            }
                            if (document.getElementById("alert").checked) {
                                const alertMessage = document.getElementById("alertMessage").value.trim() || "Повідомлення!";
                                const alertPlacement = document.getElementById("alertPlacement").value;

                                if (alertPlacement === "end") {
                                    script += `  gg.alert("${alertMessage}")\n`;
                                }
                            }
                            script += `end\n`;

                            allFunctionsList.push(script); // Обновляем список всех функций
                            refreshAllFunctions(); // Обновляем итоговый Lua-код
                            return script;
                        }
                        function refreshAllFunctions() {
                            allFunctions = allFunctionsList.join("\n"); // Соединяем все функции из списка
                            document.getElementById("output").textContent = allFunctions; // Отображаем результат
                        }

                        // Удаление последней функции
                        function removeLastAddedFunction() {
                            if (allFunctionsList.length === 0) {
                                alert("Нет функций для удаления.");
                                return;
                            }

                            // Избегать удаления главного меню
                            if (allFunctionsList.length === 0) {
                                alert("Главное меню не может быть удалено.");
                                return;
                            }

                            const lastFunction = allFunctionsList.pop();
                            deletedFunctions.push(lastFunction);

                            refreshAllFunctions();
                            alert("Последняя добавленная функция удалена.");
                        }

                        // Восстановление последней удалённой функции
                        function restoreLastRemovedFunction() {
                            if (deletedFunctions.length === 0) {
                                alert("Нет удалённых функций для восстановления.");
                                return;
                            }

                            // Берём последнюю удалённую функцию и добавляем её обратно в общий список
                            const lastRemovedFunction = deletedFunctions.pop();
                            allFunctionsList.push(lastRemovedFunction);

                            // Обновляем общий Lua-код
                            refreshAllFunctions();

                            alert("Последняя удалённая функция восстановлена.");
                        }
                            // Сброс всех полей ввода
                            function resetInputs() {
                                functionName = "myFunction";
                                document.getElementById("functionNameInput").value = "";
                                document.getElementById("clearResults").checked = false;
                                document.getElementById("alert").checked = false;
                                document.getElementById("alertMessage").value = "";
                                document.getElementById("toast").checked = false;
                                document.getElementById("toastMessage").value = "";
                                document.getElementById("searchNumber").checked = false;
                                document.getElementById("searchValue").value = "";
                                document.getElementById("editAllSimple").checked = false;
                                document.getElementById("editValue").value = "";
                                document.getElementById("replaceInput").checked = false;
                                document.getElementById("rangeMin").value = "";
                                document.getElementById("rangeMax").value = "";
                                document.getElementById("defaultPromptValue").value = "";
                                document.getElementById("editWheel").checked = false;
                                document.getElementById("wheelMultiplier").value = "";
                                document.getElementById("wheelMin").value = "";
                                document.getElementById("wheelMax").value = "";
                                document.getElementById("wheelType").value = "gg.TYPE_FLOAT";
                                document.getElementById("mainMenuFunction").value = "";
                            }


                            // Скачивание итогового Lua-кода
                           function copyScript() {
                            const textarea = document.createElement('textarea');
                            textarea.value = allFunctions;
                            document.body.appendChild(textarea);
                            textarea.select();
                            document.execCommand('copy');
                            document.body.removeChild(textarea);
                        }

                    </script>

</body>
</html>
