!function(){"use strict";class e{generateCallbackFunction(){return`jsonp_${Date.now()}_${Math.ceil(1e5*Math.random())}`}httpRequest(){return new XMLHttpRequest}jsonp(e,t){const o=this.generateCallbackFunction();window[o]=e=>{t(e)};const n=`${e}${-1!==e.indexOf("?")?"&":"?"}callback=${o}`,s=document.createElement("script");s.type="text/javascript";s.async=!0;s.src=n;document.getElementsByTagName("head")[0].appendChild(s)}send(e,t,o){const n=this.httpRequest();n.open(o,e);n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status)try{const e=JSON.parse(n.responseText);t(e)}catch(e){console.log(`${e.message} in ${n.responseText}`);return}};n.send()}get(e,t){this.send(e,t,"GET")}}var t=new e;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);Element.prototype.closest||(Element.prototype.closest=function(e){let t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null});const o=()=>Array.prototype.slice.call(document.querySelectorAll(".comment-reply-to"));class n{constructor(){this.oneQuarterOfASecondMS=250;this.successRegexp=/[?|&]success=true/;this.replyingTo="";this.disableContactPromotion=!1;this.onFormReady=this.onFormReady.bind(this);this.onFormSubmitted=this.onFormSubmitted.bind(this);this.handleSuccess=this.handleSuccess.bind(this);this.handlePostResponse=this.handlePostResponse.bind(this);this.scrollToComment=this.scrollToComment.bind(this);this.renderComment=this.renderComment.bind(this);this.hsPopulateCommentsFeed=this.hsPopulateCommentsFeed.bind(this);this.getExtraMetaDataBeforeSubmit=this.getExtraMetaDataBeforeSubmit.bind(this);this.setUpThreading=this.setUpThreading.bind(this)}scrollToTarget(e){setTimeout((()=>{const t=document.documentElement||document.body,o=document.querySelector(e);if(o){t.style.transition=`all ${this.oneQuarterOfASecondMS}`;t.scrollTop=o.offsetTop}}),0)}getExtraMetaDataBeforeSubmit(){return{disableContactPromotion:this.disableContactPromotion,replyingTo:this.replyingTo}}onFormSubmitted(){const e="success=true";window.location.search?this.successRegexp.exec(window.location.search)?window.location.reload():window.location.search+=`&${e}`:window.location.search=e}handleSuccess(e,t){const o=document.querySelector(e);if(!(o&&o.querySelector("form").length>0))return setTimeout((()=>this.handleSuccess(e,t)),this.oneQuarterOfASecondMS);o.insertAdjacentHTML("afterbegin",`
${t}
`);return this.scrollToTarget(e)}handlePostResponse({successMessage:e,target:t}){this.successRegexp.exec(window.location.search)&&this.handleSuccess(t,e)}onFormReady({successMessage:e,target:t}={}){return this.handlePostResponse({successMessage:e,target:t})}isThreadId(e){const t=e.split(".");for(let e=0;e9999)return!1}return!0}scrollToComment(e){const t=location.hash.replace("#","");if(t&&this.isThreadId(t)){const o=`${e} [id='c${t}']`;document.querySelector(o).length>0&&this.scrollToTarget(o)}}getDepth(e){const t=e.split(".");let o=-1;for(let e=0;e{this.replyingTo=e};o().forEach((s=>{s.addEventListener("click",(function(){const s=this.closest(".comment");if(!s)return;n(s.dataset.threadid);const r=document.querySelector(t);if(!r)return;o().forEach((e=>{e.style.display="block"}));const i=r.querySelector("input[name=replyingTo]");i&&(i.style.display="none");r.style.display="none";r.classList.add("replying");const c=this.querySelector("em").innerHTML,a=e.replyingTo?e.replyingTo.replace("{{user}}",c):`Replying to ${c}`,l=r.querySelector(".replying-to");l?l.innerText=a:r.insertAdjacentHTML("afterbegin",`${a}`);s.parentNode&&s.parentNode.insertBefore(r,s.nextSibling);r.style.display="block";this.style.display="none";this.scrollToTarget(t);r.querySelector(".hs_comment .hs-input").focus()}))}))}highlightCode(e){const{hljs:t}=window;if(!t||!t.highlightBlock)return;t.configure&&t.configure({useBR:!0});const o=document.querySelector(e);Array.prototype.slice.call(o.querySelectorAll("pre code")).forEach((e=>t.highlightBlock(e)))}renderComment(e,t={}){const{commentText:o,created:n,threadInfo:s,user:r,userUri:i}=e,{maxThreadDepth:c,showForm:a,replyTo:l}=t,h=this.getDepth(s),m=h"),u=new Date(n).toLocaleString();let p=`\n
\n
\n

\n `;if(i){p+=`${r}`}else p+=r;p+=`\n

\n
\n
${u}
\n

${d}

\n `;if(m){p+=``}p+="
";return p}hsPopulateCommentsFeed(e={}){t.jsonp(e.commentsUrl,(t=>{this.disableContactPromotion=e.disableContactPromotion;const o=e.commentsSelector||"#comments-listing",n=document.querySelector(o);if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);t.objects.length>0&&n.setAttribute("data-has-comments",!0);const s=t.objects.map((t=>this.renderComment(t,e))).join("");n.insertAdjacentHTML("beforeend",s);this.setUpThreading(e);this.highlightCode(o);this.scrollToComment(o);"function"==typeof hsPostCommentsComplete&&window.hsPostCommentsComplete(n)}))}}window.hsCommentListing=new n;window.hsPopulateCommentsFeed=window.hsCommentListing.hsPopulateCommentsFeed;window.hsPopulateCommentFormOnFormReady=window.hsCommentListing.onFormReady;window.hsPopulateCommentFormOnFormSubmitted=window.hsCommentListing.onFormSubmitted;window.hsPopulateCommentFormGetExtraMetaDataBeforeSubmit=window.hsCommentListing.getExtraMetaDataBeforeSubmit}();