var FPF_Phone_Widget=function(){function t(t){void 0===t&&(t=""),this.elem=t,this.initialSelectHTML=this.elem.innerHTML,this.choices=null,this.countriesData=fpframework_phonenumber_widget_data.flags||[],this.init(),this.initEvents()}var e=t.prototype;return e.init=function(){var r=this;this.choices=new Choices(this.elem,{allowHTML:!0,classNames:{containerOuter:"fpf-phone-control--flag"},fuseOptions:{threshold:.3},shouldSort:!1,searchPlaceholderValue:"Search",itemSelectText:"",searchFields:["label","value"],callbackOnCreateTemplates:function(o){var s=this.config.itemSelectText,t=r.elem.closest(".fpf-phone-control").querySelector(".fpf-phone-control--skeleton");return t&&t.remove(),{item:function(t,e){t.classNames&&(t=t.classNames);var n=r.countriesData.find(function(t){return t.code.toLowerCase()===e.value.toLowerCase()}),i=n?n.name:"",a=n?n.calling_code:"";return o('\t\t\t\t\t\t\t<div\t\t\t\t\t\t\t\tclass="'+String(t.item)+" "+String(e.highlighted?t.highlightedState:t.itemSelectable)+'"\t\t\t\t\t\t\t\tdata-item\t\t\t\t\t\t\t\tdata-id="'+String(e.id)+'"\t\t\t\t\t\t\t\tdata-value="'+String(e.value)+'"\t\t\t\t\t\t\t\t'+String(e.active?'aria-selected="true"':"")+"\t\t\t\t\t\t\t\t"+String(e.disabled?'aria-disabled="true"':"")+'\t\t\t\t\t\t\t\t>\t\t\t\t\t\t\t\t\t<img width="27" height="13.5" loading="lazy" src="'+fpframework_phonenumber_widget_data.flags_url+e.value.toLowerCase()+'.png" alt="'+i+'" /> <svg class="fpf-arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" width="19"><path fill="currentColor" d="M480-333 240-573l51-51 189 189 189-189 51 51-240 240Z"/></svg><span class="fpf-flag-calling-code">+'+a+"</span>\t\t\t\t\t\t\t</div>\t\t\t\t\t\t\t")},choice:function(t,e){t.classNames&&(t=t.classNames);var n=r.countriesData.find(function(t){return t.code.toLowerCase()===e.value.toLowerCase()}),i=n?n.name:"",a=n?n.calling_code:"";return o('\t\t\t\t\t\t\t<div\t\t\t\t\t\t\t\tclass="'+String(t.item)+" "+String(t.itemChoice)+" "+String(e.disabled?t.itemDisabled:t.itemSelectable)+" "+String(e.selected?"fpf-selectjs-selected-item":"")+'"\t\t\t\t\t\t\t\tdata-select-text="'+String(s)+'"\t\t\t\t\t\t\t\tdata-choice \t\t\t\t\t\t\t\t'+String(e.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable")+'\t\t\t\t\t\t\t\tdata-id="'+String(e.id)+'"\t\t\t\t\t\t\t\tdata-value="'+String(e.value)+'"\t\t\t\t\t\t\t\t'+String(0<e.groupId?'role="treeitem"':'role="option"')+'\t\t\t\t\t\t\t\t>\t\t\t\t\t\t\t\t\t<img width="27" height="13.5" loading="lazy" src="'+fpframework_phonenumber_widget_data.flags_url+e.value.toLowerCase()+'.png" alt="'+i+'" /> <span class="fpf-phonecontrol-label" title="'+i+'">'+i+'</span><span class="fpf-phonecontrol-code">+'+a+"</span>\t\t\t\t\t\t\t</div>\t\t\t\t\t\t\t")}}}}),this.elem.phonecontrol=this},e.initEvents=function(){this.choices.passedElement.element.addEventListener("choice",function(e){setTimeout(function(){var t=e.target.closest(".fpf-phone-control").querySelector(".fpf-phone-control--number");t.focus(),t.dispatchEvent(new CustomEvent("change",{bubbles:!0}))},1)}.bind(this)),this.choices.passedElement.element.addEventListener("showDropdown",function(){var t=this.value,e=this.parentElement.parentElement.querySelector('.choices__list--dropdown [data-value="'+t+'"]');e&&(e.classList.add("fpf-selectjs-selected-item"),e.parentElement.scrollTop=e.offsetTop-e.parentElement.offsetTop)})},e.reset=function(){this.choices.destroy(),this.elem.innerHTML=this.initialSelectHTML,new t(this.elem)},t}(),FPF_Phone_Widgets=function(){function t(){this.init()}return t.prototype.init=function(){if(window.IntersectionObserver){var t=document.querySelectorAll(".fpf-phone-control--flag--selector:not(.done)");if(0!==t.length){var e=new IntersectionObserver(function(t,e){t.forEach(function(t){t.isIntersecting&&(t.target.classList.add("done"),new FPF_Phone_Widget(t.target),e.unobserve(t.target))})},{rootMargin:"0px 0px 0px 0px"});t.forEach(function(t){e.observe(t)})}}},t}();"loading"!=document.readyState?new FPF_Phone_Widgets:document.addEventListener("DOMContentLoaded",function(){new FPF_Phone_Widgets});

