File: /var/www/html/wptoho/wp-content/themes/themify-ultra/themify/themify-builder/js/modules/toc.js
((t,e,l,o,c)=>{"use strict";let i=!1;const _=new IntersectionObserver((t=>{for(let l=t.length-1;l>-1;--l){let o=e.querySelectorAll('.module-toc a[href="#'+CSS.escape(encodeURI(t[l].target.id))+'"]'),c=!0===t[l].isIntersecting;for(let t=o.length-1;t>-1;--t)o[t].parentNode.classList.toggle("tb_toc_active",c)}}),{threshold:[0,1]}),n=t=>{const e=themify_vars?.breakpoints||{};let l="desktop";return t<=e.mobile?l="mobile":t<=e.tablet[1]?l="tablet":t<=e.tablet_landscape[1]&&(l="tablet_landscape"),l},r=e=>{let l=e.dataset.bp;return!(!l||"n"===l)&&(l="tl"===l?"tablet_landscape":"t"===l?"tablet":"mobile",l=themify_vars.breakpoints[l],Array.isArray(l)&&(l=l[1]),l>=t.w)},a=c=>{let i=c.target?.closest(".tf_fa,a");if(i)if("A"===i.tagName){const _=i.getAttribute("href").replace("#",""),n=e.querySelector("#"+CSS.escape(decodeURI(_))+".tb_toc_el");if(n&&(c.preventDefault(),!1===t.is_builder_active)){const c=n.closest(".module_row"),{nextElementSibling:i,previousElementSibling:r}=c,a=t.lazyDisable;t.lazyScrolling=!0,l.history.replaceState(null,null,"#"+_),r&&t.lazyScroll(t.convert(t.selectWithParent("[data-lazy]",r)).reverse(),!0),t.lazyScroll(t.convert(t.selectWithParent("[data-lazy]",c)).reverse(),!0).finally((()=>{let c=tbLocalScript.scrollHighlight||{},i=~~c.offset,_=i+~~e.tfId("wpadminbar")?.offsetHeight,r=c.speed,f=0;const s=()=>{let c=i>0?0:getComputedStyle(e.documentElement).getPropertyValue("--tf_fixed_h"),d=_;c&&(d+=parseFloat(c)),++f,t.scrollTo(n.getBoundingClientRect().top+l.scrollY-d,r,(()=>{f<4?o(s):!0===t.lazyScrolling&&(t.lazyScrolling=a)}))};o(s)})),i&&t.lazyScroll(t.convert(t.selectWithParent("[data-lazy]",i)).reverse(),!0)}}else if(i=i.closest(".tb_toc_head,.tb_toc_cic_close,.tb_toc_cic"),i){const t=i.parentNode,e=t.tfTag("ul")[0],l="0px"===getComputedStyle(e).getPropertyValue("max-height"),c=i.classList.contains("tb_toc_head")?"tb_tc_close":"tb_tc_sub_close",_=e.style;_.maxHeight="none";const n=e.clientHeight,r=l?n:0;_.maxHeight=(l?0:n)+"px",e.tfOn("transitionend",(()=>{t.classList.toggle(c,!l),r>0&&(_.maxHeight=""),_.padding=r>0?"":"0px"}),{passive:!0,once:!0}),o((()=>{_.maxHeight=r+"px",_.padding=r>0?"":"0px"}))}},f=n=>{let{tags:f,excl:s,cont:d="b",sel:u}=n.dataset;if(f){let b;if("cust"===d){if(u){u=u.trim();const t=u.slice(-1);if(","!==t&&"."!==t&&"#"!==t||(u=u.slice(0,-1)),u)try{b=e.querySelectorAll(u)}catch(t){}}}else{if("b"===d||"b_c"===d){if(b=n.closest(".themify_builder"),"b_c"===d){let t=b;while(1)if(t=t.parentNode.closest(".themify_builder"),null===t)break;null===t&&(t=b.parentNode);while(null!==t&&null===t.nextElementSibling&&null===t.previousElementSibling)t=t.parentNode;null!==t&&(b=t)}}else"r"===d||"c"===d?(b=n.closest(".module_column"),"r"===d&&(b=b.closest(".module_row"))):"doc"===d&&(b=e);b&&(b=[b])}if(b?.length>0){f=f.replace(/\|/g,",");let d="#comments,.tf_carousel,.loops-wrapper,.module-accordion,.widget-title,.module-tab,.module-toc,.module-gallery,.module-image,.nav,.module-service-menu";n.dataset.ex_m&&(d+=",.module-title");const u=new Set,m=[],h=n.tfClass("tpl_toc_ic")[0],p=n.tfClass("tpl_toc_cic")[0],g=n.tfClass("tpl_toc_cic_close")[0],w=n.dataset,y=w.min>0?~~w.min:2,v=~~w.maxh||32,x=~~w.maxt,S=(t,l)=>{const o=e.createDocumentFragment(),i=e.createElement("ul");i.className="tb_toc_lv_"+l+" tf_w tf_box",1===l&&r(n)&&(i.style.maxHeight="0",n.classList.add("tb_tc_close"));for(let i=0;i<t.length;++i){let _=e.createElement("li"),n=e.createElement("a"),r=e.createDocumentFragment(),a=t[i];n.href="#"+a.id,n.textContent=a.text,h!==c&&r.appendChild(h.content.cloneNode(!0)),r.appendChild(n),a.childs.length>0&&(++l,p!==c&&r.appendChild(p.content.cloneNode(!0)),g!==c&&r.appendChild(g.content.cloneNode(!0)),r.appendChild(S(a.childs,l))),_.appendChild(r),o.appendChild(_)}return i.appendChild(o),i};if(s){s=s.trim();const t=s.slice(-1);","!==t&&"."!==t&&"#"!==t||(s=s.slice(0,-1))}for(let l=0,o=b.length;l<o;++l){let o=b[l].querySelectorAll(f);for(let l=0,c=o.length;l<c;++l){let c=o[l];if(!(u.has(c)||c.closest(d)||s&&(c.matches(s)||c.closest(s)))&&(u.add(c),c.offsetWidth>0&&c.offsetHeight>0&&c.getClientRects().length>0)){let l=c.textContent.trim();if(l){x>0&&l.length>x&&(l=l.substr(0,x));let o=c.dataset.isSet?null:c.id,i=o||l.toLowerCase();if(i=i.replace(/(\r\n|\n|\r)/gm," ").replace(/[`’~!@#$%^&*()|+\=?;:'",.<>\{\}\[\]\\\/]/gi,"").replace(/\s\s+/gu," "),!o){if(!0===t.is_builder_active&&(c.dataset.isSet=!0),i=i.replace(/\s/gu,"-"),i.length>v){if(i=i.split("-"),i.length>1)for(let t=i.length-1;t>-1;--t)if(i.splice(t,1),1===t||i.join("-").length<=v)break;i=i.join("-"),i.length>v&&(i=i.substring(0,v))}isNaN(i[0])||(i="tb-"+i);let l=2,o=i;while(null!==e.tfId(i))i=o+"-"+l,++l}c.id=i,c.classList.add("tb_toc_el"),m.push({id:encodeURIComponent(i),text:l,h:+c.nodeName.replace("H",""),childs:[]}),!0!==t.is_builder_active&&_.observe(c)}}}}if(u.clear(),m.length>=y){if(n.classList.contains("tb_toc_tree")){let t=m.length;for(let e=1;e<t;++e)if(1!==m[e].h)if(m[e-1].h<m[e].h)m[e-1].childs.push(m[e]),m[e].delete=!0;else for(let t=e-1;t>-1;--t)if(m[t].h<m[e].h){m[t].childs.push(m[e]),m[e].delete=!0;break}for(let e=t-1;e>-1;--e)!0===m[e].delete&&m.splice(e,1)}o((()=>{const e=n.tfClass("tb_toc_lv_1")[0],o=!1===i?l.location.hash:"";i=!0,e?.remove(),n.appendChild(S(m,1)),n.tfOn("click",a).classList.remove("tf_hide"),!1===t.is_builder_active&&""!==o&&"#"!==o&&n.querySelector('a[href="#'+o.replace("#","")+'"]')?.click()}))}else o((()=>{n.classList.add("tf_hide")}))}}};let s=n(t.w);t.on("builder_load_module_partial tb_toc",((e,l)=>{if(!0!==l||e.classList.contains("module-toc"))for(let l=t.selectWithParent("module-toc",e),o=l.length-1;o>-1;--o)f(l[o])})).on("infiniteloaded",(()=>{t.trigger("tb_toc")})).on("tfsmartresize",(t=>{o((()=>{const l=n(t.w);if(l!==s){s=l;for(let t=e.tfClass("tb_toc_lv_1"),l=t.length-1;l>-1;--l){let e=t[l].parentNode,o=r(e);t[l].style.maxHeight=o?"0":"",e.classList.toggle("tb_tc_close",o)}}}))}))})(Themify,document,window,requestAnimationFrame,void 0);