{% load i18n %}
{% load content_filters %}
{% load poi_filters %}
{% get_current_language as LANGUAGE_CODE %}
{% get_language LANGUAGE_CODE as current_language %}
{% if poi_query and request.region %}
    {% if poi_query_result|length > 0 %}
        <label class="secondary">
            {% translate "Select existing location" %}
        </label>
        <select size="{% if poi_query_result|length > 5 %}5{% elif poi_query_result|length == 1 %}2{% else %}{{ poi_query_result|length }}{% endif %}"
                class="block w-full bg-none bg-white text-gray-800 border border-gray-500 mb-2 py-2 px-2 {% if poi_query_result|length == 1 %}h-12{% endif %}">
            {% for poi in poi_query_result %}
                <option class="option-existing-poi hover:bg-gray-200 cursor-pointer"
                        title="{{ poi.address }}, {{ poi.postcode }} {{ poi.city }}"
                        data-poi-title="{{ poi|poi_translation_title:current_language }}"
                        data-poi-id="{{ poi.id }}"
                        data-poi-address="{{ poi.address }}"
                        data-poi-postcode="{{ poi.postcode }}"
                        data-poi-city="{{ poi.city }}"
                        data-poi-country="{{ poi.country }}">
                    {{ poi|poi_translation_title:current_language }}
                </option>
            {% endfor %}
        </select>
    {% endif %}
    {% if create_poi_option %}
        <button id="show-poi-form-button"
                class="btn w-full option-new-poi mb-2"
                data-poi-title="{{ poi_query }}"
                data-url="{% url 'show_poi_form_ajax' region_slug=request.region.slug language_slug=request.region.default_language.slug poi_title=poi_query %}">
            <i icon-name="map-pin"></i>
            {% blocktranslate trimmed %}
                Create location "{{ poi_query }}"
            {% endblocktranslate %}
        </button>
    {% endif %}
{% endif %}
