File: /var/www/html/wptoho/wp-content/themes/themify-ultra/themify/themify-icon-picker/assets/script.js
var Themify_Icons;((t,e,s)=>{"use strict";let i,o;try{o=window.top.document}catch(t){o=window.document}const n=new Map,r=t.isTouch?"pointerdown":"click",l=document.currentScript.src.replace("script.","styles.").replace(".js",".css"),c="http://www.w3.org/2000/svg",f=new Set;Themify_Icons={el:null,input:null,init(){o.tfOn(r,(t=>{const e=t.target.closest(".themify_fa_toggle");e&&(t.preventDefault(),t.stopPropagation(),this.input=e.hasAttribute("data-target")?t.currentTarget.querySelector(e.dataset.target):e.previousElementSibling,this.show(this.input.value))}))},renderForm(f){return new e(((a,h)=>{if(null===this.el){const d=o.createElement("div"),_=o.createElement("h3"),u=o.createElement("input"),p=o.createElement("button"),v=o.createElement("button"),b=o.createElement("div"),w=o.createElement("div"),y=o.createElement("div"),g=o.createElement("div"),m=o.createElement("div"),x=[];this.el=o.createElement("div"),this.el.className="lightbox tf_hide",d.className="top flex",_.className="title",_.textContent=tfIconPicker.title,u.type="text",u.className="search tf_box",u.required=!0,u.setAttribute("inputmode","search"),u.setAttribute("pattern",".*\\S.*"),u.placeholder=tfIconPicker.search,v.className="tf_close",p.type=v.type="button",p.className="clear tf_close",b.className="menu_wrap flex tf_rel",w.className="menu flex",y.className="container tf_overflow tf_scrollbar",g.className="overlay tf_abs_t tf_opacity tf_w tf_h tf_opacity tf_hide",m.id="tf_icons_root",m.style.display="none",m.attachShadow({mode:"open"}).append(this.el,g),(t=>{i||(i=new IntersectionObserver(((t,e)=>{let i=o.createDocumentFragment(),r=Themify_Icons.el.getRootNode(),l=r.querySelector("#svg"),f=[];for(let r=t.length-1;r>-1;--r)if(!0===t[r].isIntersecting){e.unobserve(t[r].target);let l=o.createElementNS(c,"use"),a=o.createElementNS(c,"svg"),h=o.createElementNS(c,"symbol"),d=o.createElementNS(c,"path"),_=t[r].target,{w:u,vw:p,vh:v,p:b,icon:w}=_.dataset,y=_.closest(".group").id,g=_.closest("section").dataset.id,m="tf-"+n.get(y).getFullIcon(w,g).replaceAll(" ","-"),x="0 0 ";x+=p!==s&&""!==p?p:"32",x+=" ",x+=v!==s&&""!==v?v:"32",h.id=m,h.setAttributeNS(null,"viewBox",x),d.setAttributeNS(null,"d",b),h.appendChild(d),i.appendChild(h),u&&f.push("."+m+"{width:"+u+"em}"),a.setAttribute("class",m),l.setAttributeNS(null,"href","#"+m),a.appendChild(l),_.append(a,o.createTextNode(w)),_.removeAttribute("data-p"),_.removeAttribute("data-w"),_.removeAttribute("data-vw")}if(f.length>0){let t=r.querySelector("#icon_style");null===t&&(t=o.createElement("style"),t.id="icon_style"),t.textContent+=f.join(""),r.prepend(t)}if(null===l){const t=o.createElementNS(c,"defs");l=o.createElementNS(c,"svg"),l.id="svg",l.appendChild(t),r.prepend(l)}l.firstChild.appendChild(i)}),{threshold:.2,root:t}))})(y);for(let[t,e]of n){let s=o.createElement("label"),i=o.createElement("input"),n=o.createElement("div");i.type="radio",i.name="icon-font-group",i.value=t,n.className="group",s.className="flex",n.id=t,n.style.display="none",f!==t&&f||(f||(f=!0),i.checked=!0,x.push(this.getGroup(t))),s.append(i,o.createTextNode(e.getTitle())),w.appendChild(s),y.appendChild(n)}y.tfOn(r,(t=>{const e=t.target.closest("button");e&&(t.stopPropagation(),e.closest(".cat_menu")?(this.clearSearch(),this.filter(e)):e.dataset.icon&&(this.setIcon(e.dataset.icon,e.closest("section").dataset.id,e.closest(".group").id),this.close()))}),{passive:!0}),v.tfOn(r,(t=>{t.stopPropagation(),this.close()}),{passive:!0}),g.tfOn(r,(t=>{t.stopPropagation(),this.close()}),{passive:!0}),p.tfOn(r,(t=>{t.stopPropagation(),this.clearSearch()}),{passive:!0}),w.tfOn("change",(t=>{t.stopPropagation(),this.getGroup(t.target.value)}),{passive:!0}),u.tfOn("input",(t=>{t.stopPropagation(),this.filter(this.el.querySelector("#"+this.el.querySelector("input:checked").value+" .cat_menu .selected")),this.search(t.currentTarget.value)}),{passive:!0}),d.append(_,v),b.append(w,u,p),this.el.append(d,b,y),x.push(t.loadCss(t.url+"css/base.min","tf_base-css",!1,this.el),t.loadCss(l,null,!1,this.el)),o.body.appendChild(m),e.all(x).then((()=>{m.style.display="",a()})).catch(h)}else f?(this.el.querySelector('[value="'+f+'"]').checked=!0,this.getGroup(f).then(a).catch(h)):a()}))},show(t){const s=null===this.el;let i;if(t)for(let[e,s]of n)if(s.isValid(t)){i=e;break}return s&&this.showLoader(),new e(((e,o)=>{this.renderForm(i).then((()=>{const o=this.el,r=o.getRootNode().querySelector(".overlay");for(let t=o.tfClass("selected"),e=t.length-1;e>-1;--e)t[e].classList.remove("selected");r.classList.remove("tf_hide"),o.classList.remove("tf_hide"),requestAnimationFrame((()=>{o.tfOn("transitionend",(()=>{if(t){let e=(t=o.querySelector("#"+i+' [data-icon="'+n.get(i).getSelectedIcon(t)+'"]')).closest(".group").tfClass("cat_menu")[0],s=10;e&&(s+=e.getBoundingClientRect().height),this.scrollTo(t,s),t.classList.add("selected")}e()}),{passive:!0,once:!0}),r.classList.remove("tf_opacity"),setTimeout((()=>{o.classList.add("show")}),10),s&&this.showLoader("done")}))})).catch(o)}))},getGroup(s){let i=e.resolve();return f.has(s)||(this.showLoader(),i=t.fetch({action:"tf_icon_get_by_type",type:s}).then((t=>{f.add(s),this.el.querySelector("#"+s).appendChild(n.get(s).createList(t))})).finally((()=>{this.showLoader("done")}))),i.then((()=>{for(let t=this.el.tfClass("group"),e=t.length-1;e>-1;--e)t[e].style.display=s===t[e].id?"":"none"})),i},close(){return new e((t=>{this.el.getRootNode().querySelector(".overlay").tfOn("transitionend",(function(){this.classList.add("tf_hide"),this.classList.remove("tf_opacity")}),{passive:!0,once:!0}).classList.add("tf_opacity"),this.el.tfOn("transitionend",(function(){this.classList.add("tf_hide"),this.input=null,t()}),{passive:!0,once:!0}).classList.remove("show")}))},filter(t){if(t){const e=t.dataset.id,s=t.classList.contains("selected");for(let i=t.closest(".group").tfTag("section"),o=0;o<i.length;++o){let t=i[o].classList;i[o].tfOn("transitionend",(function(){this.classList.toggle("tf_hide",this.classList.contains("tf_opacity"))}),{passive:!0,once:!0}),!s&&i[o].dataset.id!==e&&t.contains("tf_opacity")||(t.remove("tf_hide"),setTimeout((()=>{t.toggle("tf_opacity",!s&&i[o].dataset.id!==e)}),10))}for(let e=t.parentNode.children,i=e.length-1;i>-1;--i)e[i].classList.toggle("selected",!s&&e[i]===t)}},clearSearch(){this.el.tfClass("search")[0].value="",this.search("")},search(t){const e=t.trim(),s=this.el.tfTag("section");for(let t=0;t<s.length;++t){let i=s[t].tfTag("button"),o=!1;for(let t=0;t<i.length;++t)i[t].dataset.icon.includes(e)?(o=!0,i[t].style.display=""):i[t].style.display="none";s[t].style.display=!1===o?"none":""}},showLoader(t="show"){if("undefined"!=typeof tb_app)return tb_app.Spinner.showLoader(t);let e=o.tfClass("tf_loader")[0];e||(this.setCss(),e=o.createElement("div"),e.className="tf_loader tf_hide tf_abs_c",o.body.appendChild(e));const s=e.classList;"error"===t?s.add("tf_loader_error"):(s.remove("tf_loader_error"),s.toggle("tf_hide","show"!==t))},setCss(){let t="tf_select_icons_st",e=o.tfId(t);e||(e=o.createElement("style"),e.id=t,e.textContent=".tf_loader{width:62px;height:62px;background-color:rgba(0,0,0,.6);border-radius:50%;position:fixed;z-index:99999999;pointer-events:none;contain:strict}.tf_loader:before{border-color:transparent;border-top-color:#fff;border-width:5px}",o.body.appendChild(e))},setIcon(e,s,i,r){r??=o;let l=this.el.getRootNode(),f=r.getElementById("tf_svg"),a=n.get(i).getFullIcon(e,s).trim(),h="tf-"+a.replaceAll(" ","-"),d=r.tfClass("tb_iframe")[0];if(this.input.value=a,!f){const t=r.createElementNS(c,"defs");f=r.createElementNS(c,"svg"),f.id="tf_svg",f.appendChild(t),r.head.appendChild(f)}if(!f.querySelector("#"+h)){const t=l.querySelector("symbol#"+h).cloneNode(!0),e=l.querySelector("#icon_style");if(e){let t;for(let s=e.sheet.cssRules,i=s.length-1;i>-1;--i)if(s[i].selectorText==="."+h){t=".tf_fa"+s[i].cssText;break}if(t){let e=r.getElementById("tf_fonts_style");null===e&&(e=r.createElement("style"),e.id="tf_fonts_style",f.after(e)),e.textContent&&-1!==e.textContent.indexOf(h)||(e.textContent+=t)}}f.firstChild.appendChild(t)}d?.contentDocument&&this.setIcon(e,s,i,d.contentDocument),t.triggerEvent(this.input,"change")},scrollTo(t){t.scrollIntoView();const e=this.el.tfClass("tf_scrollbar")[0];e.scrollTop-=~~(e.offsetHeight/2)}};class a{constructor(t){n.set(t,this)}clearSearch(e){const s=e.closest(".tb_tab").tfClass("tb_layout_search")[0];s.value="",t.triggerEvent(s,"input")}getTitle(){return tfIconPicker.group[this.id]}getList(e){return e??=this.id,t.fetch({action:"tf_icon_get_by_type",type:e})}createList(t){const{cats:e,icons:n}=t,r=o.createDocumentFragment();if(n&&n.EMPTY===s){let t=0;if(e){const s=Object.keys(e);if(t=s.length,t>1){const i=o.createElement("div");for(let n=0;n<t;++n){let t=o.createElement("button"),r=o.createElement("span");t.setAttribute("data-id",s[n]),t.type="button",r.textContent=e[s[n]],t.appendChild(r),i.appendChild(t)}i.className="cat_menu flex",r.appendChild(i)}}for(let l in n){let c=o.createElement("section"),f=o.createElement("h2"),a=o.createElement("div"),h=n[l];t>1&&(c.dataset.id=l),a.className="icons",f.className="cat_title tf_textc",f.textContent=e[l];for(let t in h){let e=h[t],n=o.createElement("button");n.className="flex tf_overflow tf_box",n.type="button",n.setAttribute("data-icon",t),e.p?(n.setAttribute("data-p",e.p),""!==e.vw&&e.vw!==s&&n.setAttribute("data-vw",e.vw),""!==e.vh&&e.vh!==s&&n.setAttribute("data-vh",e.vh),e.w&&n.setAttribute("data-w",e.w)):n.setAttribute("data-p",e),i.observe(n),a.appendChild(n)}c.append(f,a),r.appendChild(c)}}else if(n){const t=o.createElement("div");t.className="empty",t.innerHTML=n.EMPTY,r.appendChild(t)}return r}isValid(t){return 0===t.indexOf(this.id+"-")}getSelectedIcon(t){return t.replace(this.id+"-","")}getFullIcon(t,e){return this.id+"-"+t}}new class extends a{constructor(){super("ti"),this.id="ti"}},new class extends a{constructor(){super("fa"),this.id="fa"}isValid(t){return 0===t.indexOf(this.id+"-")||0===t.indexOf(this.id+" ")||-1!==["fas ","far ","fab "].indexOf(t.substr(0,4))}getSelectedIcon(t){return 0===(t=t.replace("fas ","").replace("far ","").replace("fab ","")).indexOf(this.id+" ")?t.replace(this.id+" ",""):super.getSelectedIcon(t)}getFullIcon(t,e){return e+" "+t}},new class extends a{constructor(){const t="fontello";super(t),this.id=t}isValid(t){return"fontello-"===t.substr(0,9)||"icon-"===t.substr(0,5)||"tf_fontello-"===t.substr(0,12)}getSelectedIcon(t){return"fontello-"===t.substr(0,9)?t.replace("fontello-",""):"icon-"===t.substr(0,5)?t.replace("icon-",""):"fontello-"===t.substr(0,12)?t.replace("tf_fontello-",""):super.getSelectedIcon(t)}},new class extends a{constructor(){super("la"),this.id="la"}},Themify_Icons.init()})(Themify,Promise,void 0);