Joomla=window.Joomla||{};((a,r)=>{r.addEventListener("DOMContentLoaded",function(){r.addEventListener("change",function(e){if(e.target.name==="jform[shipping_country]"||e.target.name==="jform[billing_country]"){const n=e.target.name==="jform[shipping_country]"?"jform_shipping_state":"jform_billing_state";const s=e.target.value;const i=a.getOptions("countriesList",false);const o=i.find(e=>e.numeric_code===s);const c=r.getElementById(n).closest("joomla-field-fancy-select");c.choicesInstance.setChoices([{id:"",text:""}],"id","text",false);c.choicesInstance.setChoiceByValue("");var t=r.createEvent("HTMLEvents");t.initEvent("change",true,false);r.getElementById(n).dispatchEvent(t);c.choicesInstance.clearChoices();if(o.states){o.states.forEach(e=>{const t={};t.innerText=e.name;t.id=e.id;c.choicesInstance.setChoices([t],"id","innerText",false)})}}})})})(Joomla,document);