(()=>{"use strict";function e(e,t){const n=e.querySelector(".flexa-toc__list");if(!n)return;const o=(e.getAttribute("data-levels")||"").split(",").map(e=>e.trim()).filter(Boolean),l=e.querySelector(".flexa-toc__empty"),r=o.length?function(e,t,n){const o=function(e){return e.closest(".wp-block-post-content, .entry-content, article, main")||document.body}(e),l=Array.from(o.querySelectorAll(t.join(","))),r=[];return l.forEach(t=>{if(e.contains(t))return;const o=(t.textContent||"").trim();if(!o)return;let l=t.id;l?n.add(l):(l=function(e,t){let n=e.toLowerCase().replace(/[^a-z0-9À-ɏḀ-ỿ]+/g,"-").replace(/^-+|-+$/g,"");n||(n="section");let o=n,l=2;for(;t.has(o);)o=`${n}-${l}`,l+=1;return t.add(o),o}(o,n),t.id=l),r.push({el:t,level:Number(t.tagName.charAt(1)),id:l,text:o})}),r}(e,o,t):[];if(!r.length)return e.classList.add("flexa-toc--empty"),void(l&&(l.hidden=!1));l&&(l.hidden=!0);const a=function(e){const t=document.createElement("ul");t.className="flexa-toc__list";const n=[{list:t,level:0}];let o=null,l=0;return e.forEach(e=>{if(o&&e.level>l){const t=document.createElement("ul");t.className="flexa-toc__list",o.appendChild(t),n.push({list:t,level:e.level})}else for(;n.length>1&&n[n.length-1].level>e.level;)n.pop();const t=document.createElement("li");t.className="flexa-toc__item";const r=document.createElement("a");r.className="flexa-toc__link",r.href=`#${e.id}`,r.textContent=e.text,t.appendChild(r),n[n.length-1].list.appendChild(t),o=t,l=e.level}),t}(r);n.replaceWith(a),e.hasAttribute("data-smooth")&&function(e,t){e.addEventListener("click",e=>{const n=e.target.closest("a.flexa-toc__link");if(!n)return;const o=decodeURIComponent((n.getAttribute("href")||"").slice(1)),l=o?document.getElementById(o):null;if(!l)return;e.preventDefault();const r=l.getBoundingClientRect().top+window.pageYOffset-t;window.scrollTo({top:r,behavior:"smooth"}),window.history&&window.history.pushState&&window.history.pushState(null,"",`#${o}`)})}(a,Number(e.getAttribute("data-offset"))||0),e.hasAttribute("data-collapsible")&&function(e){const t=e.querySelector(".flexa-toc__toggle");t&&t.addEventListener("click",()=>{const n=e.toggleAttribute("data-collapsed");t.setAttribute("aria-expanded",n?"false":"true")})}(e)}function t(e){e.classList.add("flexa-bg-loaded"),e.removeAttribute("data-flexa-lazy-bg")}function n(){const n=new Set;document.querySelectorAll("[data-flexa-toc]").forEach(t=>e(t,n));const o=document.querySelectorAll("[data-flexa-lazy-bg]");if(!o.length)return;if(void 0===window.IntersectionObserver)return void o.forEach(t);const l=new window.IntersectionObserver((e,n)=>{e.forEach(e=>{e.isIntersecting&&(t(e.target),n.unobserve(e.target))})},{rootMargin:"200px 0px"});o.forEach(e=>l.observe(e))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n()})();