<% name_html = capture do %><% template.name.split(/(_)/).each do |item| %><%= item %><% end %><% end %>

<% if turbo_native_app? && !template.archived_at? && can?(:update, template) %> <%= form_for template, url: template_path(template), method: :put, html: { class: 'hidden', id: nil } do |f| %> <%= f.label :name, t('name'), for: name_input_id = SecureRandom.uuid %> <%= f.hidden_field :name, id: name_input_id %> <% end %> <%= name_html %> <% else %> <%= name_html %> <% end %> <% if template.archived_at? %> <% end %>

<%= render 'templates/access_icon', template: @template %>
<% if template.archived_at? %>
<%= t('archived') %>
<% end %> <% if @template.account_id == current_account.id %> <% else %> <% end %>
<% if !template.archived_at? %>
<% if can?(:update, template) && !turbo_native_app? %> <% end %> <%= link_to template_share_link_path(template), class: 'btn btn-xs md:btn-sm whitespace-nowrap btn-neutral text-white px-2', aria: { label: t('share_link') }, data: { turbo_frame: :modal, native_modal: :medium } do %> <%= svg_icon('link', class: 'w-4 h-4 md:w-6 md:h-6') %> <%= t('link') %> <% end %>
<% end %>
<% if turbo_native_app? %> <% unless template.archived_at? %> <% if can?(:create, Submission) %> <% end %> <% end %> <% if !template.archived_at? && can?(:update, template) %> <% end %> <% if can?(:create, current_account.templates.new(author: current_user)) %> <% end %> <% if template.archived_at? || (!can?(:update, template) && can?(:read, template)) %> <% end %> <% if local_assigns[:with_export] %> <% end %> <% if !template.archived_at? && can?(:update, template) && @template.account_id == current_account.id %> <% end %> <% if can?(:destroy, template) %> <% if template.archived_at? %> <%= button_to '', template_restore_index_path(template) %> <%= button_to '', template_path(template), method: :delete, params: { permanently: true }, data: { turbo_confirm: t('template_deletion_is_irreversible_and_will_permanently_remove_all_associated_signed_documents_with_it_are_you_sure_') } %> <% else %> <%= button_to '', template_path(template), method: :delete %> <% end %> <% end %> <% else %>
<% if can?(:destroy, template) %> <% if template.archived_at? %> <%= button_to button_title(title: t('restore'), disabled_with: t('restoring')[..-4], icon: svg_icon('rotate', class: 'w-6 h-6')), template_restore_index_path(template), class: 'btn btn-outline btn-sm w-full', form_class: 'flex-1' %> <% else %> <%= button_to button_title(title: t('archive'), disabled_with: t('archiving')[..-4], title_class: 'inline', icon: svg_icon('archive', class: 'w-6 h-6')), template_path(template), class: 'btn btn-outline btn-sm w-full', form_class: 'flex-1', method: :delete %> <% end %> <% end %> <% if can?(:create, current_account.templates.new(author: current_user)) %>
<%= link_to new_template_clone_path(template), class: 'btn btn-outline btn-sm w-full', data: { turbo_frame: :modal, native_modal: :medium } do %> <%= svg_icon('copy', class: 'w-6 h-6') %> <%= t('clone') %> <% end %>
<% end %> <% if !template.archived_at? %> <% if can?(:update, template) %>
<%= link_to edit_template_path(template), class: 'btn btn-outline btn-sm w-full' do %> <%= svg_icon('pencil', class: 'w-6 h-6') %> <%= t('edit') %> <% end %>
<% elsif can?(:read, template) && !template.archived_at? %>
<%= link_to template_preview_path(template), class: 'btn btn-outline btn-sm w-full' do %> <%= svg_icon('file_text', class: 'w-6 h-6') %> <%= t('preview') %> <% end %>
<% end %> <% end %> <% if template.archived_at? %>
<%= link_to template_preview_path(template), class: 'btn btn-outline btn-sm w-full' do %> <%= svg_icon('file_text', class: 'w-6 h-6') %> <%= t('preview') %> <% end %>
<% end %>
<% end %>