<script>
document.addEventListener('DOMContentLoaded',function(){
 const flag=iso=>String.fromCodePoint(...iso.toUpperCase().split('').map(c=>127397+c.charCodeAt(0)));
 const C=[['PT','Portugal','+351','9999-999','^\\d{4}-\\d{3}$'],['ES','Espanha','+34','28001','^\\d{5}$'],['FR','França','+33','75001','^\\d{5}$'],['DE','Alemanha','+49','10115','^\\d{5}$'],['IT','Itália','+39','00100','^\\d{5}$'],['GB','Reino Unido','+44','SW1A 1AA','^[A-Z]{1,2}\\d[A-Z\\d]? ?\\d[A-Z]{2}$'],['IE','Irlanda','+353','D02 X285','^[A-Z0-9]{3} ?[A-Z0-9]{4}$'],['CH','Suíça','+41','8001','^\\d{4}$'],['BE','Bélgica','+32','1000','^\\d{4}$'],['NL','Países Baixos','+31','1012 AB','^\\d{4} ?[A-Z]{2}$'],['BR','Brasil','+55','01001-000','^\\d{5}-?\\d{3}$'],['AO','Angola','+244','',''],['MZ','Moçambique','+258','',''],['CV','Cabo Verde','+238','7600','^\\d{4}$'],['US','Estados Unidos','+1','10001','^\\d{5}(-\\d{4})?$'],['CA','Canadá','+1','K1A 0B1','^[A-Z]\\d[A-Z] ?\\d[A-Z]\\d$']];
 function enhance(root){
  if(!root || root.dataset.aostCountryEnhanced==='1') return;
  let country=root.querySelector('[name="regiao"]'),postal=root.querySelector('[name="zipc"]'),phone=root.querySelector('[name="telf"]'); if(!country)return;
  let old=(country.value||'').trim(), oldU=old.toUpperCase();
  if(country.tagName!=='SELECT'){
    const sel=document.createElement('select'); [...country.attributes].forEach(a=>sel.setAttribute(a.name,a.value)); sel.name='regiao'; country.replaceWith(sel); country=sel;
  }
  country.innerHTML='<option value="">Selecione o país</option>'+C.map(x=>'<option value="'+x[1]+'" data-iso="'+x[0]+'">'+flag(x[0])+'  '+x[1]+'</option>').join('');
  let hit=C.find(x=>x[1].toUpperCase()===oldU||x[0]===oldU); country.value=hit?hit[1]:'Portugal';
  // Ultimate Member pode já ter criado Select2: forçar o texto atualizado com bandeira.
  if(window.jQuery && jQuery.fn && jQuery.fn.select2){try{jQuery(country).trigger('change.select2');}catch(e){}}
  let code;
  if(phone){
    code=document.createElement('select'); code.className='aost-phone-code'; code.setAttribute('aria-label','Indicativo internacional');
    code.innerHTML=C.map(x=>'<option value="'+x[2]+'" data-iso="'+x[0]+'">'+flag(x[0])+'  '+x[2]+'</option>').join('');
    let wrap=document.createElement('div');wrap.className='aost-phone-wrap';phone.parentNode.insertBefore(wrap,phone);wrap.append(code,phone);
  }
  function x(){return C.find(y=>y[1]===country.value)}
  function sync(){let y=x();if(!y)return;if(code)code.value=y[2];if(postal){postal.placeholder=y[3]||'';postal.setCustomValidity('');if(y[4]&&postal.value.trim()&&!new RegExp(y[4],'i').test(postal.value.trim()))postal.setCustomValidity('Introduza um código postal válido para '+y[1]+'.');}}
  country.addEventListener('change',sync);postal&&postal.addEventListener('input',sync);let form=root.closest('form');form&&form.addEventListener('submit',function(){sync();if(phone&&phone.value.trim()&&!phone.value.trim().startsWith('+'))phone.value=(code.value+' '+phone.value.trim()).trim();});sync();
  root.dataset.aostCountryEnhanced='1';
 }
 function scan(){document.querySelectorAll('.um-form').forEach(enhance)}
 scan(); setTimeout(scan,400); setTimeout(scan,1200); setTimeout(scan,2500);
 new MutationObserver(scan).observe(document.body,{childList:true,subtree:true});
});
</script>
<style>.aost-phone-wrap{display:grid;grid-template-columns:135px 1fr;gap:8px}.aost-phone-wrap select{min-width:0}@media(max-width:560px){.aost-phone-wrap{grid-template-columns:120px 1fr}}</style>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://aost.pt/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://aost.pt/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-posts-elementor-hf-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-posts-shopengine-template-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-posts-astra-advanced-hook-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://aost.pt/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
