<main class="max-w-md mx-auto px-2 mt-12 mb-4">
  <div class="space-y-6 mx-auto">
    <div class="space-y-6">
      <div class="flex items-center justify-center">
        <%= render 'start_form/banner' %>
      </div>
      <div class="flex items-center bg-base-200 rounded-xl p-4 mb-4">
        <div class="flex items-center">
          <div class="mr-3">
            <%= svg_icon('writing_sign', class: 'w-10 h-10') %>
          </div>
          <div>
            <p dir="auto" class="text-lg font-bold mb-1"><%= @submitter.submission.name || @submitter.submission.template&.name %></p>
            <p dir="auto" class="text-sm">
              <%= t(@submitter.with_signature_fields? ? 'signed_on_time' : 'completed_on_time', time: l(@submitter.completed_at.to_date, format: :long)) %>
            </p>
          </div>
        </div>
      </div>
    </div>
    <div>
      <% if (Docuseal.multitenant? || Accounts.can_send_emails?(@submitter.account)) && @submitter.email.present? %>
        <toggle-submit>
          <%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, class: 'white-button w-full' %>
        </toggle-submit>
        <% if Templates.filter_undefined_submitters(@submitter.submission.template_submitters).size != 1 %>
          <div class="divider uppercase"><%= t('or') %></div>
        <% else %>
          <div class="py-2"></div>
        <% end %>
      <% end %>
      <% if @submitter.completed_at > 30.minutes.ago || (current_user && current_user.account.submitters.exists?(id: @submitter.id)) %>
        <download-button role="button" tabindex="0" aria-label="<%= t('download_documents') %>" data-src="<%= submit_form_documents_path(@submitter.slug) %>" class="base-button w-full">
          <span class="flex items-center justify-center space-x-2" data-target="download-button.defaultButton">
            <%= svg_icon('download', class: 'w-6 h-6') %>
            <span><%= t('download_documents') %></span>
          </span>
          <span class="flex items-center justify-center space-x-2 hidden" data-target="download-button.loadingButton">
            <%= svg_icon('loader', class: 'w-6 h-6 animate-spin') %>
            <span><%= t('downloading') %></span>
          </span>
        </download-button>
      <% end %>
    </div>
    <% undefined_submitters = Templates.filter_undefined_submitters(@submitter.submission.template_submitters) %>
    <% if undefined_submitters.size == 1 && undefined_submitters.first['uuid'] == @submitter.uuid && @submitter.completed_at? && @submitter.completed_at > 14.days.ago && %w[api embed mcp].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && @submitter.template && !@submitter.template.archived_at? %>
      <div class="divider uppercase"><%= t('or') %></div>
      <toggle-submit class="block">
        <%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), resubmit_form_path, params: { resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
      </toggle-submit>
    <% end %>
  </div>
</main>
<%= render 'shared/attribution', link_path: '/start', account: @submitter.account %>
