
{%- assign flag_currency = true -%}
{%- if settings.currency_type == "1" -%}
  <hdt-popover class="hdt-popover-currencies hdt-popover hdt-dropdown hdt-hidden hdt-text-start hdt-current-scrollbar hdt-flag-size-sm" id="popover-currencies" placement="bottom" color-scheme="{{ settings.color_scheme_dialog }}" config='{ "closeRichlistSelect": true }'>
    {%- assign formID = 'localization_form_currencies_' | append: id -%}
    {%- form 'localization', id: formID -%}
      {%- if localization.available_countries.size > 9 -%}
        <country-filter>
          <input type="search" class="hdt-country_filter hdt-input" value placeholder="Search" name="country_filter">
        </country-filter>
      {%- endif -%}
      <hdt-richlist role="listbox" selected="{{ localization.country.iso_code }}">
        {%- for country in localization.available_countries -%}
          <button type="submit" name="country_code" role="option" value="{{ country.iso_code }}" data-name="{{ country.name }}" aria-selected="{% if country.iso_code == localization.country.iso_code %}true{% else %}false{% endif %}">
            {%- if flag_currency %}{{ country | image_url: width: 32 | image_tag: loading: 'lazy', class: 'hdt-flag hdt-relative' }}{%- endif -%}
            <span>{{- country.currency.iso_code }} {{ country.currency.symbol }} | {{ country.name }}</span>
          </button>
        {%- endfor -%}
      </hdt-richlist>
    {%- endform -%}
  </hdt-popover>
{%- else -%}
  {%- assign supported_codes = settings.supported_currencies | newline_to_br | split: '<br />' -%}
  {%- capture dropdown -%}
    {%- for code in supported_codes -%}
      {%- liquid
        assign array_money = code | split: '-'
        assign data_currency = array_money | first | upcase | strip | remove: ' '
        assign name_money = array_money | last | strip
      -%}
      {%- if settings.auto_currency and forloop.first -%}
        <button class="hdt-item-auto wait" name="country_code" data-name="{{ data_currency }}" role="option" value="{{ data_currency }}" aria-selected="">
          {%- if flag_currency %}<img width="30" height="22.5" class="hdt-flag hdt-relative" src="//cdn.shopify.com/static/images/flags/{{ name_money | slice: 0, 2 | downcase }}.svg" alt="{{ name_money }}" loading="lazy">{%- endif -%}
          <span>{{ name_money }}</span>
        </button>
      {%- endif -%}
      <button role="option" name="country_code" data-name="{{ data_currency }}" value="{{ data_currency }}" aria-selected="{% if data_currency == cart.currency.iso_code %}true{% else %}false{% endif %}">
        {%- if flag_currency %}<img width="30" height="22.5" class="hdt-flag hdt-relative" src="//cdn.shopify.com/static/images/flags/{{ name_money | slice: 0, 2 | downcase }}.svg" alt="{{ name_money }}" loading="lazy">{%- endif -%}
        <span>{{ name_money }}</span>
      </button>
    {%- endfor -%}
  {%- endcapture -%}
  <hdt-popover class="hdt-popover-currencies hdt-popover hdt-dropdown hdt-hidden hdt-text-start hdt-current-scrollbar hdt-flag-size-sm" id="popover-currencies" placement="bottom" color-scheme="{{ settings.color_scheme_dialog }}" config='{ "closeRichlistSelect": true }'>
    {%- if supported_codes.size > 9 -%}
    <country-filter>
      <input type="search" class="hdt-country_filter hdt-input" value placeholder="Search" name="country_filter">
    </country-filter>
  {%- endif -%}
    <hdt-richlist role="listbox" selected="">
      {{- dropdown -}}
    </hdt-richlist>
  </hdt-popover>
{%- endif -%}
{% comment %} end popover currencies {% endcomment %}