<% align = field.dig('preferences', 'align') %> <% valign = field.dig('preferences', 'valign') %> <% color = field.dig('preferences', 'color') %> <% font = field.dig('preferences', 'font') %> <% font_type = field.dig('preferences', 'font_type') %> <% font_size_px = (field.dig('preferences', 'font_size').presence || Submissions::GenerateResultAttachments::FONT_SIZE).to_i * local_assigns.fetch(:font_scale) { 1000.0 / PdfUtils::US_LETTER_W } %> width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; font-size: <%= fs = "clamp(1pt, #{font_size_px / 10}vw, #{font_size_px}px)" %>; line-height: calc(<%= fs %> * 1.3); font-size: <%= fs = "#{font_size_px / 10}cqmin" %>; line-height: calc(<%= fs %> * 1.3)"> <% if field['type'] == 'signature' %> <% is_narrow = area['h']&.positive? && (area['w'].to_f / area['h']) > 6 %>
<% if (local_assigns[:with_signature_id] || field.dig('preferences', 'reason_field_uuid').present?) && attachment = attachments_index[value] %>
ID: <%= attachment.uuid %>
<% if local_assigns[:with_signature_id_reason] != false %>
<% reason_value = submitter.values[field.dig('preferences', 'reason_field_uuid')].presence %> <% if reason_value %><%= t('reason') %>: <% end %><%= reason_value || t('digitally_signed_by') %> <%= submitter.name %> <% if submitter.email %> <<%= submitter.email %>> <% end %>
<% end %>
<% timezone = local_assigns[:with_submitter_timezone] ? (submitter.timezone || local_assigns[:timezone]) : local_assigns[:timezone] %> <%= l(attachment.created_at.in_time_zone(timezone), format: :long, locale: local_assigns[:locale]) %> <%= TimeUtils.timezone_abbr(timezone, attachment.created_at) %>
<% end %>
<% elsif field['type'].in?(['image', 'initials', 'stamp']) && attachments_index[value].image? %> <% elsif field['type'].in?(['file', 'payment', 'image']) %>
<% Array.wrap(value).each do |val| %> <%= svg_icon('paperclip', class: 'inline w-[1.6vw] h-[1.6vw] lg:w-4 lg:h-4') %> <%= attachments_index[val].filename %> <% end %>
<% elsif field['type'] == 'checkbox' %>
<%= svg_icon('check', class: "aspect-square #{area['w'] > area['h'] ? '!w-auto !h-full' : '!w-full !h-auto'}") %>
<% elsif field['type'].in?(%w[multiple radio]) && area['option_uuid'] %> <% option = field['options']&.find { |o| o['uuid'] == area['option_uuid'] } %> <% option_name = option['value'].presence || "Option #{field['options'].index(option) + 1}" %> <% if option && Array.wrap(value).include?(option_name) %>
<%= svg_icon('check', class: "aspect-square #{area['w'] > area['h'] ? '!w-auto !h-full' : '!w-full !h-auto'}") %>
<% end %> <% elsif field['type'] == 'cells' && area['cell_w'].to_f > 0.0 %> <% cell_width = area['cell_w'] / area['w'] * 100 %>
<% (0..(area['w'] / area['cell_w']).ceil).each do |index| %> <% if value[index] %>
<%= value[index] %>
<% end %> <% end %>
<% elsif field['type'] == 'date' %>
<% value = Time.current.in_time_zone(local_assigns[:timezone]).to_date.to_s if value == '{{date}}' %>
<%= TimeUtils.format_date_string(value, field.dig('preferences', 'format'), local_assigns[:locale]) %>
<% elsif field['type'] == 'number' %>
<%= NumberUtils.format_number(value, field.dig('preferences', 'format')) %>
<% elsif field['type'] == 'strikethrough' %>
<% if (((1000.0 / local_assigns[:page_width]) * local_assigns[:page_height]) * area['h']) < 40 %> <% else %> <% end %>
<% else %>
<%= Array.wrap(value).join(', ') %>
<% end %>