!function(){"use strict";const t={currentsearch:"",init:function(){const e=document.getElementById("search_query"),n=document.getElementById("cityCountryInput"),o=document.getElementById("resultsDropdown");n.addEventListener("input",(async function(){const t=n.value.trim();if(t.length<3)return o.innerHTML="",void o.classList.remove("show");const e=`https://geocoder.moviao.com/api/?q=${t}&limit=10&layer=city&layer=district&layer=country&lang=en`;try{const t=await fetch(e),n=await t.json();let a=null,c=null;const r=n.features.filter((t=>{const{osm_value:e,name:n,city:o,country:r,countrycode:i}=t.properties;return a=t.geometry.coordinates[1],c=t.geometry.coordinates[0],(n||o||r||i||a||c||e)&&("town"===e||"city"===e||"village"===e||"district"===e||"country"===e)})).map((t=>t.properties));o.innerHTML=r.map((t=>`\n
\n \n \n `)).join(""),o.classList.add("show")}catch(t){}})),o.addEventListener("click",(function(t){if("BUTTON"===t.target.tagName){const a=t.target.dataset.geoLat,c=t.target.dataset.geoLng,r=t.target.dataset.geoType,i=t.target.dataset.geoCnt;n.value=t.target.textContent.trim(),o.classList.remove("show"),window.location.href="/find?q="+e.value+"&location="+n.value+"&source=E&lat="+a+"&lng="+c+"&type="+r+"&cnt="+i}})),document.addEventListener("click",(function(e){o.contains(e.target)||e.target===n?cityCountryInput.value.trim().length>0&&(t.currentsearch=cityCountryInput.value.trim(),e.target.value=""):(o.classList.remove("show"),0===cityCountryInput.value.trim().length&&(cityCountryInput.value=t.currentsearch))})),document.getElementById("clear_search_query").addEventListener("click",(function(){document.getElementById("search_query").value=""}))}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(function(){t.init()})):t.init()}();