<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
    <head>
        <th:block th:insert="~{fragments/header}"></th:block>
        <link rel="stylesheet" href="/static/css/util.css">
        <link rel="stylesheet" href="/static/css/panel.css">
    </head>
    <body class="bg-body-tertiary">
        <div th:replace="~{fragments/floating_button}"></div>
        <main>
            <nav class="navbar navbar-expand-lg navbar-dark bg-dark" aria-label="Navbar">
                <div class="container-fluid">
                    <a class="navbar-brand" href="#">[[${title} ? ${title} : 'Bunker']]</a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar2" aria-controls="offcanvasNavbar2">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasNavbar2" aria-labelledby="offcanvasNavbar2Label">
                        <div class="offcanvas-header">
                            <h5 class="offcanvas-title" id="offcanvasNavbar2Label">[[${title} ? ${title} : 'Bunker']]</h5>
                            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
                        </div>
                        <div class="offcanvas-body">
                            <ul class="navbar-nav justify-content-start flex-grow-1 pe-3">
                                <li class="nav-item">
                                </li>
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" th:text="#{pplay}" role="button" data-bs-toggle="dropdown" aria-expanded="false">

                                    </a>
                                    <ul class="dropdown-menu">
                                        <li><a class="dropdown-item" th:text="#{lugg}" href="/panel?section=lugg"></a></li>
                                        <li><a class="dropdown-item" th:text="#{heeal}" href="/panel?section=heal"></a></li>
                                        <li><a class="dropdown-item" th:text="#{pprof}" href="/panel?section=prof"></a></li>
                                        <li><a class="dropdown-item" th:text="#{hhobb}" href="/panel?section=hobb"></a></li>
                                        <li><a class="dropdown-item" th:text="#{aggend}" href="/panel?section=agge"></a></li>
                                    </ul>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/panel?section=diss" th:text="#{diss}"></a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/panel?section=stats" th:text="#{stats}"></a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="/panel?section=actions" th:text="#{actions}"></a>
                                </li>
                            </ul>
                            <ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-globe-americas" viewBox="0 0 16 16">
                                            <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0ZM2.04 4.326c.325 1.329 2.532 2.54 3.717 3.19.48.263.793.434.743.484-.08.08-.162.158-.242.234-.416.396-.787.749-.758 1.266.035.634.618.824 1.214 1.017.577.188 1.168.38 1.286.983.082.417-.075.988-.22 1.52-.215.782-.406 1.48.22 1.48 1.5-.5 3.798-3.186 4-5 .138-1.243-2-2-3.5-2.5-.478-.16-.755.081-.99.284-.172.15-.322.279-.51.216-.445-.148-2.5-2-1.5-2.5.78-.39.952-.171 1.227.182.078.099.163.208.273.318.609.304.662-.132.723-.633.039-.322.081-.671.277-.867.434-.434 1.265-.791 2.028-1.12.712-.306 1.365-.587 1.579-.88A7 7 0 1 1 2.04 4.327Z"></path>
                                        </svg>
                                        [[#{langl}]]
                                    </a>
                                    <ul class="dropdown-menu">
                                        <li><a class="dropdown-item" href="/?lang=en" th:text="#{elang}"></a></li>
                                        <li><a class="dropdown-item" href="/?lang=ru" th:text="#{rlang}"></a></li>
                                    </ul>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" th:href="@{/logout}" th:text="#{logote}"></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </nav>
            <th:block th:if="${is_mobile}">
                <div class="d-flex justify-content-center text-center">
                    <div class="row h-50">
                        <div class="card mt-2">
                            <div class="card-body">
                                <button type="button" data-bs-toggle="modal" onclick="add_entry_modal()" data-bs-target="#modal" class="btn btn-success" th:text="#{adddbtn}"></button>
                            </div>
                        </div>
                        <th:block th:each="cc: ${cards}">
                            <div class="card mt-2">
                                <div class="card-body">
                                    <h5 class="card-title" th:text="${cc.title}"></h5>
                                    <p class="card-text">
                                        <ul th:each="ll: ${cc.body}">
                                            <li th:text="${ll}"></li>
                                        </ul>
                                    </p>
                                    <a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="" class="btn btn-primary" th:text="#{eddittsynn}"></a>
                                    <a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
                                    <a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
                                </div>
                            </div>
                        </th:block>
                        <th:block th:if="${section == 'stats'}">
                            <p>stats!!!!</p>
                        </th:block>
                    </div>
                </div>
            </th:block>
            <th:block th:unless="${is_mobile}">
                <div class="d-flex justify-content-start text-center">
                    <div class="col">
                        <div class="card mt-2">
                            <div class="card-body">
                                <button type="button" data-bs-toggle="modal" onclick="add_entry_modal()" data-bs-target="#modal" class="btn btn-success" th:text="#{adddbtn}"></button>
                            </div>
                        </div>
                    </div>
                    <th:block th:each="cc: ${cards}">
                        <div class="col">
                            <div class="card mt-2">
                                <div class="card-body">
                                    <h5 class="card-title" th:text="${cc.title}"></h5>
                                    <p class="card-text">
                                        <ul th:each="ll: ${cc.body}">
                                            <li th:text="${ll}"></li>
                                        </ul>
                                    </p>
                                    <a th:unless="${section == 'actions'}" href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="show_synergies_modal(this)" class="btn btn-primary" th:text="#{eddittsynn}"></a>
                                    <a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
                                    <a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
                                </div>
                            </div>
                        </div>
                    </th:block>
                </div>
            </th:block>
            <div class="modal fade" id="modal_syn" tabindex="-1" aria-labelledby="ModalLabelSyn" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h1 class="modal-title fs-5" id="ModalLabelSyn" th:text="#{aedentry}"></h1>
                        </div>
                        <div class="modal-body">
                            <form id="synergyForm">
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th th:text="#{firentname}"></th>
                                            <th th:text="#{firenttype}"></th>
                                            <th th:text="#{secentname}"></th>
                                            <th th:text="#{secenttype}"></th>
                                            <th th:text="#{probbval}"></th>
                                            <th th:text="#{actionbtn}"></th>
                                        </tr>
                                    </thead>
                                    <tbody id="table_body_modal">
                                        <tr>
                                            <td>-</td>
                                            <td>-</td>
                                            <td><select id="second_select_vals"></select></td>
                                            <td><select id="second_select_types" name="second_types" onchange="secondTypeChange(this)"><option value="lugg" th:text="#{lugg}"></option><option value="heal" th:text="#{heeal}"></option><option value="hobb" th:text="#{hhobb}"></option><option value="agge" th:text="#{aggend}">Gender</option><option value="prof" th:text="#{pprof}">Profession</option></select></td>
                                            <td><input id="synergy_prob_input" type="number" value="0.0" min="-1" max="1" step="0.1"/></td>
                                            <td><button type="button" data-id="0" id="add_synergy_button" class="btn btn-primary" onclick="add_synergy(this)" th:text="#{adddbtn}"></button></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-dismiss="modal" th:text="#{cancbt}"></button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="modal" tabindex="-1" data-bs-backdrop="static" aria-labelledby="ModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h1 class="modal-title fs-5" id="ModalLabel" th:text="#{aedentry}"></h1>
                        </div>
                        <div class="modal-body">
                            <form id="entryForm">
                                <th:block th:switch="${section}">
                                    <th:block th:case="agge">
                                        <div class="mb-3">
                                            <label class="form-check-label" th:text="#{inlcandie}" for="canDie"></label>
                                            <input class="form-check-input" type="checkbox" value="" id="canDie" name="canDie" checked>
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-check-label" for="ismale" th:text="#{inlismal}"></label>
                                            <input class="form-check-input" type="checkbox" value="" id="ismale" name="ismale">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-check-label" for="isfemale" th:text="#{inlisfem}"></label>
                                            <input class="form-check-input" type="checkbox" value="" id="isfemale" name="isfemale" checked>
                                        </div>
                                        <div class="mb-3">
                                            <label for="gender_text" class="col-form-label" th:text="#{inlgente}"></label>
                                            <input type="text" class="form-control" id="gender_text" name="gender_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="hobb">
                                        <div class="mb-3">
                                            <label for="foodRange" class="form-label" th:text="#{inlfood}"></label>
                                            <input type="range" class="form-range" id="foodRange" min="0" max="1" step="0.1" name="foodRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="healRange" class="form-label" th:text="#{inlheal}"></label>
                                            <input type="range" class="form-range" id="healRange" min="0" max="1" step="0.1" name="healRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="powerRange" class="form-label" th:text="#{inlpower}"></label>
                                            <input type="range" class="form-range" id="powerRange" min="0" max="1" step="0.1" name="powerRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="violenceRange" class="form-label" th:text="#{inlviol}"></label>
                                            <input type="range" class="form-range" id="violenceRange" min="0" max="1" step="0.1" name="violenceRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="hobby_text" class="col-form-label" th:text="#{hobblab}"></label>
                                            <input type="text" class="form-control" id="hobby_text" name="hobby_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="lugg">
                                        <div class="mb-3">
                                            <label for="foodRange" class="form-label" th:text="#{inlfood}"></label>
                                            <input type="range" class="form-range" id="foodRange" min="0" max="1" step="0.1" name="foodRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="healRange" class="form-label" th:text="#{inlheal}"></label>
                                            <input type="range" class="form-range" id="healRange" min="0" max="1" step="0.1" name="healRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="powerRange" class="form-label" th:text="#{inlpower}"></label>
                                            <input type="range" class="form-range" id="powerRange" min="0" max="1" step="0.1" name="powerRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="violenceRange" class="form-label" th:text="#{inlviol}"></label>
                                            <input type="range" class="form-range" id="violenceRange" min="0" max="1" step="0.1" name="violenceRange">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-check-label" for="isgarbage" th:text="#{inlgarb}"></label>
                                            <input class="form-check-input" type="checkbox" value="" id="isgarbage" name="isgarbage">
                                        </div>
                                        <div class="mb-3">
                                            <label for="luggage_name_text" class="col-form-label" th:text="#{inlaname}"></label>
                                            <input type="text" class="form-control" id="luggage_name_text" name="luggage_name_text">
                                        </div>
                                        <div class="mb-3">
                                            <label for="luggage_desc_text" class="col-form-label" th:text="#{inladesc}"></label>
                                            <input type="text" class="form-control" id="luggage_desc_text" name="luggage_desc_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="heal">
                                        <div class="mb-3">
                                            <label for="health_index" class="form-label" th:text="#{inlhin}"></label>
                                            <input type="range" class="form-range" id="health_index" min="0" max="1" step="0.1" name="health_index">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-check-label" for="childFree" th:text="#{inlcfr}"></label>
                                            <input class="form-check-input" type="checkbox" value="" id="childFree" name="childFree">
                                        </div>
                                        <div class="mb-3">
                                            <label for="heal_name_text" class="col-form-label" th:text="#{inlaname}"></label>
                                            <input type="text" class="form-control" id="heal_name_text" name="heal_name_text">
                                        </div>
                                        <div class="mb-3">
                                            <label for="heal_desc_text" class="col-form-label" th:text="#{inladesc}"></label>
                                            <input type="text" class="form-control" id="heal_desc_text" name="heal_desc_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="prof">
                                        <div class="mb-3">
                                            <label for="foodRange" class="form-label" th:text="#{inlfood}"></label>
                                            <input type="range" class="form-range" id="foodRange" min="0" max="1" step="0.1" name="foodRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="healRange" class="form-label" th:text="#{inlheal}"></label>
                                            <input type="range" class="form-range" id="healRange" min="0" max="1" step="0.1" name="healRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="powerRange" class="form-label" th:text="#{inlpower}"></label>
                                            <input type="range" class="form-range" id="powerRange" min="0" max="1" step="0.1" name="powerRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="violenceRange" class="form-label" th:text="#{inlviol}"></label>
                                            <input type="range" class="form-range" id="violenceRange" min="0" max="1" step="0.1" name="violenceRange">
                                        </div>
                                        <div class="mb-3">
                                            <label for="work_name_text" class="col-form-label" th:text="#{inlaname}"></label>
                                            <input type="text" class="form-control" id="work_name_text" name="work_name_text">
                                        </div>
                                        <div class="mb-3">
                                            <label for="work_desc_text" class="col-form-label" th:text="#{inladesc}"></label>
                                            <input type="text" class="form-control" id="work_desc_text" name="work_desc_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="actions">
                                        <div class="mb-3">
                                            <label for="script_editor" class="form-label" th:text="#{inlaction}"></label>
                                            <div class="form-control" id="script_editor" style="height: 50vh;"></div>
                                            <!-- <textarea  id="action_body_text" name="action_body_text" rows="3"></textarea> -->
                                        </div>
                                        <div class="mb-3">
                                            <label for="action_name_text" class="col-form-label" th:text="#{inlaname}"></label>
                                            <input type="text" class="form-control" id="action_name_text" name="action_name_text">
                                        </div>
                                        <div class="mb-3">
                                            <label for="action_desc_text" class="col-form-label" th:text="#{inladesc}"></label>
                                            <input type="text" class="form-control" id="action_desc_text" name="action_desc_text">
                                        </div>
                                    </th:block>
                                    <th:block th:case="diss">
                                        <div class="mb-3">
                                            <label for="diss_name_text" class="col-form-label" th:text="#{inlaname}"></label>
                                            <input type="text" class="form-control" id="diss_name_text" name="diss_name_text">
                                        </div>
                                        <div class="mb-3">
                                            <label for="diss_desc_text" class="col-form-label" th:text="#{inladesc}"></label>
                                            <input type="text" class="form-control" id="diss_desc_text" name="diss_desc_text">
                                        </div>
                                    </th:block>
                                </th:block>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" th:text="#{cancbt}"></button>
                            <button type="button" id="modal_submit_add" onclick="add_entry()" class="btn btn-success" th:text="#{adddbtn}"></button>
                            <button type="button" data-entry-id="0" style="display: none;" id="modal_submit_edit" onclick="edit_submit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></button>
                        </div>
                    </div>
                </div>
            </div>
            <script src="/static/javascript/base32.js" type="text/javascript"></script>
            <script src="/static/javascript/panel-script.js" type="text/javascript"></script>
            <script src="/static/javascript/ace/ace.js" type="text/javascript" charset="utf-8"></script>
            <script>
                var editor = ace.edit("script_editor");
                editor.setTheme("ace/theme/monokai");
                editor.session.setMode("ace/mode/lua");
            </script>
        </main>
        <div th:replace="~{fragments/footer :: div}"></div>
    </body>
</html>