!function(){"use strict";function e(){document.querySelectorAll(".fb-post-comment-form-block").forEach(e=>{if(e.hasAttribute("data-initialized"))return;e.setAttribute("data-initialized","true");const t=e.querySelectorAll(".comment-reply-link"),n=e.querySelector(".fb-cancel-reply"),o=e.querySelector(".fb-comment-form"),l=e.querySelector("#comment"),i=e.querySelector(".fb-reply-title"),c=e.querySelector("#comment_parent");let r="";i&&(r=i.textContent.trim(),i.setAttribute("data-original-title",r)),"undefined"!=typeof addComment?console.log("WordPress comment script loaded"):console.log("Using custom reply functionality"),t.forEach(e=>{e.addEventListener("click",function(e){e.preventDefault();let t=this.getAttribute("data-commentid");if(!t){const e=this.getAttribute("href");if(e&&e.includes("comment-"))t=e.split("comment-")[1];else{const e=this.closest(".fb-comment");e&&e.id&&(t=e.id.replace("comment-",""))}}if(t){if(console.log("Replying to comment:",t),n&&(n.style.display="inline"),i){const e=this.closest(".fb-comment").querySelector(".fb-comment-author"),t=i.getAttribute("data-original-title")||r||"Leave a Reply";i.textContent=e?t+" to "+e.textContent:t}c&&(c.value=t,console.log("Set comment_parent to:",t)),o&&o.scrollIntoView({behavior:"smooth",block:"start"}),l&&setTimeout(()=>{l.focus()},300)}else console.log("Could not find comment ID")})}),n&&n.addEventListener("click",function(e){if(e.preventDefault(),console.log("Cancel reply clicked"),this.style.display="none",i){const e=i.getAttribute("data-original-title")||r||"Leave a Reply";i.textContent=e}c&&(c.value="0",console.log("Reset comment_parent to 0"))});const a=e.querySelector("#cancel-comment-reply-link");a&&n&&(a.style.display="none",a.addEventListener("click",function(){if(n.style.display="none",i){const e=i.getAttribute("data-original-title")||r||"Leave a Reply";i.textContent=e}}));const s=e.querySelector(".fb-comment-form-element");s&&s.addEventListener("submit",function(){setTimeout(()=>{if(n&&(n.style.display="none"),i){const e=i.getAttribute("data-original-title")||r||"Leave a Reply";i.textContent=e}c&&(c.value="0")},100)}),window.addEventListener("beforeunload",function(){i&&r&&i.setAttribute("data-original-title",r)})})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e(),window.reinitPostCommentFormBlocks=e;let t=setInterval(()=>{"undefined"!=typeof addComment&&(clearInterval(t),e())},100)}(jQuery);