<!DOCTYPE html>
<html th:lang="${#locale.language}" th:dir="#{language.direction}" th:data-language="${#locale.toString()}" xmlns:th="https://www.thymeleaf.org">
  <head>
    <th:block th:insert="~{fragments/common :: head(title=#{crop.title}, header=#{crop.header})}"></th:block>
  </head>

  <body>
    <div id="page-container">
      <div id="content-wrap">
        <th:block th:insert="~{fragments/navbar.html :: navbar}"></th:block>
        <br><br>
        <div class="container">
          <div class="row justify-content-center">
            <div class="col-md-6 bg-card">
              <div class="tool-header">
                <span class="material-symbols-rounded tool-header-icon organize">crop</span>
                <span class="tool-header-text" th:text="#{crop.header}"></span>
              </div>
              <form id="cropForm" th:action="@{'/api/v1/general/crop'}" method="post" enctype="multipart/form-data">
                <div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}"></div>
                <input id="x" type="hidden" name="x">
                <input id="y" type="hidden" name="y">
                <input id="width" type="hidden" name="width">
                <input id="height" type="hidden" name="height">
                
                <button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{crop.submit}"></button>
              </form>
              <div id="canvasesContainer" style="position: relative; margin: 20px 0; width: auto;">
                <canvas id="cropPdfCanvas" style="width: 100%"></canvas>
                <canvas id="overlayCanvas" style="position: absolute; top: 0; left: 0; z-index: 2; width: 100%"></canvas>
              </div>

            </div>
          </div>
          <script type="module" th:src="@{'/pdfjs-legacy/pdf.mjs'}"></script>
          <script type="module" th:src="@{'/js/pages/crop.js'}"></script>
        </div>
      </div>
      <th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
    </div>
  </body>
</html>
