(()=>{"use strict";var t={338(t,e,n){var o=n(795);e.H=o.createRoot,o.hydrateRoot},723(t){t.exports=window.wp.i18n},727(t,e,n){n.d(e,{PU:()=>i,p4:()=>m,vB:()=>a});const o=window.wp.apiFetch;var r=n.n(o),s=n(723),c=n(790);function a(t){return JSON.parse(t||"{}")}async function m(t,e){const n=function(t){const e={number:t.number||5,offset:t.offset||0,order:t.order||"asc",orderby:t.orderby||"comment_author_email",...t.post_id&&{post_id:t.post_id},...t.post__in&&{post__in:t.post__in},...t.post__not_in&&{post__not_in:t.post__not_in},...t.post_type&&{post_type:t.post_type},...t.taxonomy&&{taxonomy:t.taxonomy},...t.terms&&{terms:t.terms},...t.term_ids&&{term_ids:t.term_ids},...t.exclude_post_author&&{exclude_post_author:t.exclude_post_author},...t.pingback&&{pingback:t.pingback},...t.trackback&&{trackback:t.trackback},...t.avatar_size&&{avatar_size:t.avatar_size}};return new URLSearchParams(e)}(t);return await r()({path:`decent-comments/v1/comments?${n.toString()}`,method:"GET",headers:{"X-WP-Nonce":e}})}const i=({comments:t,attributes:e})=>(0,c.jsxs)("div",{className:"decent-comments",children:[e.title?.length>0&&(0,c.jsx)("div",{className:"decent-comments-heading gamma widget-title",children:e.title}),(0,c.jsx)("ul",{className:"decent-comments-list",children:0===t.length?(0,c.jsx)("li",{className:"comment no-comment",children:(0,s.__)("No comments","decent-comments")}):t.filter(t=>!e.exclude_post_author||t.author_email!==t.post_author).map(t=>(0,c.jsx)(d,{comment:t,attributes:e},t.id))})]}),d=({comment:t,attributes:e})=>{const n=e.show_author?e.link_authors&&t.author_url?(0,c.jsx)("a",{href:l(t.author_url),className:"comment-author-link",children:t.author}):t.author:null,o=e.show_date?`${t.date} ${(0,s.__)("at","decent-comments")} ${t.time}`:null;let r="",a="";t.author_url&&(r='<a href="'+t.author_url+'" rel="external">',a="</a>");const m=e.show_avatar&&t.avatar?(0,c.jsx)("div",{className:"comment-avatar",dangerouslySetInnerHTML:{__html:r+t.avatar+a}}):null,i=e.show_comment?function(t,e){let n=e.show_excerpt?t:"";if(e.strip_tags&&(n=n.replace(/(<([^>]+)>)/gi,"")),e.max_excerpt_words>0){const t=n.split(" ");n=t.slice(0,e.max_excerpt_words).join(" ")+(t.length>e.max_excerpt_words?e.ellipsis:"")}return e.max_excerpt_characters>0&&(n=n.substring(0,e.max_excerpt_characters)+(n.length>e.max_excerpt_characters?e.ellipsis:"")),n}(t.content,e):"",d=e.show_link&&t.comment_link?(0,c.jsxs)("div",{className:"comment-link",children:[(0,s.__)("on","decent-comments")," ",(0,c.jsx)("a",{href:l(t.comment_link),className:"comment-post-title",children:t.post_title||""})]}):null;return(0,c.jsx)("li",{className:"comment-entry",children:(0,c.jsxs)("div",{className:"comment-content",children:[m,n&&(0,c.jsxs)("div",{className:"comment-author",children:[n," "]}),o&&(0,c.jsxs)("div",{className:"comment-date",children:[o," "]}),d," ",i&&(0,c.jsx)("div",{className:"comment-excerpt",children:i})]})},t.id)};function l(t){try{const e=new URL(t);return["http:","https:"].includes(e.protocol)?encodeURI(t):"#"}catch{return"#"}}},790(t){t.exports=window.ReactJSXRuntime},795(t){t.exports=window.ReactDOM}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o=n(338),r=n(723),s=n(727),c=n(790);let a=null,m=null;window.decentCommentsView&&(window.decentCommentsView.current_post_id&&(a=window.decentCommentsView.current_post_id),window.decentCommentsView.current_term_id&&(m=window.decentCommentsView.current_term_id)),document.addEventListener("DOMContentLoaded",async()=>{const t=document.querySelectorAll(".wp-block-itthinx-decent-comments");for(const e of t){e._decentCommentsRoot||(e._decentCommentsRoot=(0,o.H)(e));const t=e._decentCommentsRoot;try{const n=(0,s.vB)(e.dataset.attributes);"[current]"!==n.post_id&&"{current}"!==n.post_id||a&&(n.post_id=a),"[current]"!==n.terms&&"{current}"!==n.terms||m&&(n.term_ids=m);const o=window.decentCommentsView?.nonce||"",r=await(0,s.p4)(n,o);t.render((0,c.jsx)(s.PU,{comments:r.comments||[],attributes:n}))}catch(e){t.render((0,c.jsx)("p",{className:"text-red-500",children:(0,r.__)("Error loading comments","decent-comments")})),console.error("Decent Comments Error:",e)}}})})();