(()=>{var e;(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}var t;window.ThriveComments=window.ThriveComments||{},ThriveComments.util=ThriveComments.util||{},_.templateSettings={evaluate:/<#([\s\S]+?)#>/g,interpolate:/<#=([\s\S]+?)#>/g,escape:/<#-([\s\S]+?)#>/g},t=jQuery,ThriveComments.util.tpl=function(e,n){var i=t("script#"+e.replace(/\//g,"-")).html()||"";return n?_.template(i)(n):_.template(i)},ThriveComments.util.nested=function(e,t){var n=this;return e instanceof Backbone.Model?this.nested(e.attributes,t):_.each(t,(function(t){t.children&&(e[t.name]=n.nested(e[t.name],t.children)),_.isArray(e)?_.each(e,(function(e){e[t.name]=new t.obj(e[t.name])})):e[t.name]=new t.obj(e[t.name])})),e},ThriveComments.util.validateInput=function(e,n,i){var o=(e=e instanceof jQuery?e:t(e)).val(),s=!0;return""==(o=o.trim())?(n||(n=ThriveComments.util.render_label("isRequired")),s=!1,e.removeClass("tcm-valid"),e.addClass("tcm-invalid"),e.prev(".tcm-error-message").show().html(n)):(e.removeClass("tcm-invalid"),e.prev(".tcm-error-message").hide(n)),s},ThriveComments.util.validateInputUrl=function(e,n,i){var o=(e=e instanceof jQuery?e:t(e)).val(),s=!0;return null!=o&&0==this.isValidUrl(this.addHttp(o))?(n||(n=ThriveComments.util.render_label("isRequired")),s=!1,e.removeClass("tcm-valid"),e.addClass("tcm-invalid"),e.prev(".tcm-error-message").show().html(n)):(e.removeClass("tcm-invalid"),e.prev(".tcm-error-message").hide(n)),s},ThriveComments.util.validateStoringConsent=function(e,n){var i=(e=e instanceof jQuery?e:t(e)).is(":checked"),o=e.siblings(".tcm-consent-text"),s=ThriveComments.util.get_cookie("tcm_cookie_user_name"),r=!0;return""===ThriveComments.settings.storing_consent||0===ThriveComments.settings.storing_consent||(i||""!==s?(o.removeClass("tcm-not-selected"),e.prev(".tcm-error-message").hide(n)):(n||(n=ThriveComments.util.render_label("isRequired")),r=!1,o.removeClass("tcm-not-selected"),o.addClass("tcm-not-selected"),e.prev(".tcm-error-message").show().html(n))),r},ThriveComments.util.validateEmail=function(e,n){var i=(e=e instanceof jQuery?e:t(e)).val();return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(i)?(e.removeClass("tcm-invalid"),e.prev(".tcm-error-message").hide(),!0):(e.removeClass("tcm-valid"),e.addClass("tcm-invalid"),e.prev(".tcm-error-message").show().html(n),!1)},ThriveComments.util.valuesToArray=function(e){return Object.keys(e).map((function(t){return e[t]}))},ThriveComments.util.set_avatar_url=function(e){e.length&&e.attr("data-src")===ThriveComments.default_author_picture_url&&this.checkGravatar(e.attr("data-email-hash")).done((function(t){e.css("background-image",'url("'+t+'")')}))},ThriveComments.util.previousUser=function(){return""!==ThriveComments.util.get_cookie("social-login")||!!ThriveComments.current_user.ID||void 0},ThriveComments.util.set_cookie=function(t,n,i,o){o=o||"/",i=i||2592e3;var s,r=new Date;i=parseInt(i),r.setTime(r.getTime()+1e3*i),s=r.toUTCString(),"object"===e(n)&&(n=JSON.stringify(n)),document.cookie=encodeURIComponent(t)+"="+n+";expires="+s+";path="+o},ThriveComments.util.get_cookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),i=0;i<n.length;i++){for(var o=n[i];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""},ThriveComments.util.search_comment=function(e,t){return void 0!==e.models&&this.search_recursive(e.models,t)},ThriveComments.util.search_recursive=function(e,t){for(var n=0,i=0;!n&&i<e.length;i++)e[i].get("comment_ID")==t?n=e[i]:e[i].get("children")&&e[i].get("children").length&&(n=n||this.search_recursive(e[i].get("children"),t));return n},ThriveComments.util.elem_viewport=function(e){var n=e.offset(),i=n?n.top:0,o=i+e.outerHeight(),s=t(window).scrollTop(),r=s+t(window).height();return o>s&&i<r},ThriveComments.util.focusElement=function(e){var n,i=e.offset().top,o=e.height(),s=t(window).height();n=o<s?i-(s/2-o/2):i,t("html, body").animate({scrollTop:n},300,"easeOutQuint")},ThriveComments.util.save_setting_model=function(e,t,n,i){if(!e)return!1;(i=i||{}).success||(i.success=ThriveComments.translations.settings_saved_success_toast),i.fail||(i.fail=ThriveComments.translations.settings_saved_fail_toast),new ThriveComments.models.Settings({name:e,value:t}).save().done((function(o){"NoMessage"!==i.success&&TVE_Dash.success(i.success),-1!==ThriveComments.tcm_sync_settings.indexOf(e)&&n.where({name:e}).shift().set("value",t)})).fail((function(e){TVE_Dash.err(i.fail)}))},ThriveComments.util.render_label=function(e,t,n){var i,o,s,r,m,a;if(t||(t=""),!(i=window.parent.ThriveComments?void 0===window.parent.ThriveComments.objects.Settings?ThriveComments.tcm_customize_labels:window.parent.ThriveComments.objects.Settings.get(ThriveComments.tcm_labels_key).get("value"):ThriveComments.tcm_customize_labels)||!i.hasOwnProperty(e))return"";if(-1===(m=i[e].text).indexOf("{"))return m;switch(s=m.indexOf("{"),r=m.indexOf("}"),n){case"before":a=m.substr(0,s);break;case"after":a=m.substr(r+1,m.length-1);break;default:o=m.substring(s,r+1),a=m.replace(o,t)}return a},ThriveComments.util.showCommentsNumber=function(e){var n=t(".tcm-comments-number");n.length&&n.html(n.html().replace("comment_count",e)).show()},ThriveComments.util.tcm_show_loader=function(){t(".tcm-dot-loader").show()},ThriveComments.util.tcm_hide_loader=function(){t(".tcm-dot-loader").hide(),t(".thrive-comments-content").show()},ThriveComments.util.tcm_hide_textareas=function(e){var n=t(e.currentTarget).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-id");t("textarea[name=tcm-post-content]").each((function(){var e=t(this).closest(".tcm-comment-wrapper"),i=t(this).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-id"),o=e.find(".tcm-create-post-container").attr("data-position");void 0!==n&&t(this).closest(".comment-id-0").find(".tcm-comment-additional-fields").hide(),""!=o&&"top"===o||n==i||(t(this).closest(".tcm-comment-wrapper").slideUp(),t(this).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-clicked",0))}))},ThriveComments.util.after_ajax_login_actions=function(){t(".tcm-lazy-comments").empty(),t.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},cache:!1,url:ThriveComments.routes.generate_nonce,dataType:"JSON",data:{action:"refresh_nonce"},type:"GET"}).done((function(e){var n=window.parent.ThriveComments.util.commentId,i=n?"comments/"+n:"";ThriveComments.current_user=e.current_user,ThriveComments.nonce=e.nonce,Backbone.history.loadUrl(i),t(".tcm-comment-item").each((function(){var e=t(this);e.find(".tcm-comment-wrapper").hide(),e.find(".tcm-error-heading").hide()}))}))},ThriveComments.util.focusAfterLogin=function(){if(this.commentId&&parseInt(this.commentId)===this.commentId){var e=t("div[data-comment-id="+this.commentId+"]");e.find(".tcm-reply-btn").click(),e.find("#tcm-post-content").val(this.content).focus()}if("bottom"===this.position){var n=t(".add-comment");n.click(),n.closest(".tcm-lazy-comments").find("textarea#tcm-post-content").val(this.content).focus()}"top"===this.position&&t("textarea#tcm-post-content").focus(),this.position=null},ThriveComments.util.scrollToElement=function(e){e.length&&t("body, html").animate({scrollTop:e.offset().top-t(window).height()/2+30},{duration:500,complete:function(){var t=e.parent();t.addClass("tcm-highlight-item"),setTimeout((function(){return t.removeClass("tcm-highlight-item")}),800)}})},ThriveComments.util.showCommentConversion=function(e){var t=new ThriveComments.views.CommentConversion({commentView:e});t.handleAfterShowAction(),e.$el.prepend(t.$el)},ThriveComments.util.isValidUrl=function(e){return!(null===e.match(/(http(s)?:\/\/.)(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g))},ThriveComments.util.addHttp=function(e){return(e=t.trim(e))&&!/^(?:f|ht)tps?\:\/\//.test(e)&&(e="http://"+e),e},ThriveComments.util.err=function(e,n,i){t(".tvd-toast").remove(),Toasts.init(e,n||3e3,"tvd-toast tvd-red",i,"bottom"),t(".tvd-toast").parent().addClass("tcm-frontend-toast")},ThriveComments.util.getDropDownItems=function(e){var t;if(e.meta_query.tcm_delegate)t={approve:1,unapprove:1,no_reply_needed:1,featured:1,delegate:1,spam:1,trash:1};else if(e.meta_query.tcm_featured)t={stop_featured:1,no_reply_needed:1,delegate:1};else switch(e.status){case"all":case"hold":case"tcm_unreplied":t={approve:1,unapprove:1,no_reply_needed:1,featured:1,delegate:1,spam:1,trash:1};break;case"featured":t={no_reply_needed:1,stop_featured:1,delegate:1};break;case"spam":t={not_spam:1,delete:1};break;case"trash":t={spam:1,restore:1,delete:1}}return t},ThriveComments.util.dynamicSortByProperty=function(e){var t=1;return"-"===e[0]&&(t=-1,e=e.substr(1)),function(n,i){return(n[e]<i[e]?-1:n[e]>i[e]?1:0)*t}},ThriveComments.util.insertAtCaret=function(e,t){if(e.length){var n=e[0],i=n.scrollTop,o=0,s=n.selectionStart||"0"==n.selectionStart?"ff":!!document.selection&&"ie";if("ie"==s){n.focus();var r=document.selection.createRange();r.moveStart("character",-n.value.length),o=r.text.length}else"ff"==s&&(o=n.selectionStart);var m=n.value.substring(0,o),a=n.value.substring(o,n.value.length);if(n.value=m+t+a,o+=t.length,"ie"==s){n.focus();var c=document.selection.createRange();c.moveStart("character",-n.value.length),c.moveStart("character",o),c.moveEnd("character",0),c.select()}else"ff"==s&&(n.selectionStart=o,n.selectionEnd=o,n.focus());n.scrollTop=i}},ThriveComments.util.ajaxurl=function(e){var t=-1!==ajaxurl.indexOf("?")?"&":"?";return e&&e.length?(e=e.replace(/^(\?|&)/,""),e+="&_nonce="+ThriveComments.admin_nonce,ajaxurl+t+e):ajaxurl+t+"_nonce="+ThriveComments.admin_nonce},ThriveComments.util.toCamelCase=function(e){return(e=e.replace(/_/g," ")).toLowerCase().replace(/(?:(^.))/g,(function(e){return e.charAt(e.length-1).toUpperCase()}))},ThriveComments.util.formatSelection=function(e){var t,n,i,o=e instanceof jQuery?e[0]:document.getElementById(e);return void 0!==document.selection?(o.focus(),t=document.selection.createRange().text):void 0!==o.selectionStart&&(n=o.selectionStart,i=o.selectionEnd,t=o.value.substring(n,i)),{selectedText:t,startPos:n,endPos:i}},ThriveComments.util.set_subscriber_cookies=function(e){var t=ThriveComments.util.get_cookie("subscribed_posts");if(""!==t&&(t=JSON.parse(t)),0===e){var n=t.indexOf(ThriveComments.post.ID);n>-1&&(t.splice(n,1),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(t),31104e3))}else""===t?t=[ThriveComments.post.ID]:t.push(ThriveComments.post.ID),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(t),31104e3)},ThriveComments.util.checkGravatar=function(e){var n=this,i=t.Deferred();if(this.gravatarCache=this.gravatarCache||{},this.gravatarCache[e])this.gravatarCache[e].success?i.resolve(this.gravatarCache[e].url):i.reject();else{var o="https://www.gravatar.com/avatar/"+e+"?s=512";t.ajax({type:"HEAD",url:o+"&d=404"}).done((function(t){n.gravatarCache[e]={url:o,success:!0},i.resolve(o)})).fail((function(){n.gravatarCache[e]={url:"",success:!1},i.reject()}))}return i}})(),window.ThriveComments=window.ThriveComments||{},ThriveComments.models=ThriveComments.models||{},ThriveComments.collections=ThriveComments.collections||{},jQuery,ThriveComments.models.Base=Backbone.Model.extend({idAttribute:"comment_ID",sync:function(e,t,n){var i;return(n=n||{}).cache=!1,_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(i=n.beforeSend,n.beforeSend=function(e){if(e.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),i)return i.apply(this,arguments)}),Backbone.sync(e,t,n)}}),ThriveComments.collections.Base=Backbone.Collection.extend({sync:function(e,t,n){var i;return(n=n||{}).cache=!1,n.url=this.url(),_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(i=n.beforeSend,n.beforeSend=function(e){if(e.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),i)return i.apply(this,arguments)}),Backbone.sync(e,t,n)}}),ThriveComments.models.Comment=ThriveComments.models.Base.extend({getCommentStatus:function(){var e="";switch(1===parseInt(this.get("tcm_featured"))&&(e="featured"),this.get("comment_approved").toString()){case"1":case"approved":e="approved";break;case"0":case"hold":e="unapproved";break;case"spam":e="spam";break;case"trash":e="trash";break;default:0===parseInt(this.get("tcm_featured"))&&(e="stop_featuring")}return e},setCommentApproved:function(){if(void 0!==this.get("status")){var e=this.get("status")===ThriveComments.const.moderation.unapprove?0:1;this.set("comment_approved",e)}},url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},isPostAuthor:function(){return this.attributes.user_id===ThriveComments.post.post_author},parse:function(e){return delete e.author,void 0===e.replace_keyword||!1===e.replace_keyword||(ThriveComments.settings.tcm_keywords&&ThriveComments.settings.tcm_keywords.sort(ThriveComments.util.dynamicSortByProperty("-name")),_.each(ThriveComments.settings.tcm_keywords,(function(t){var n=t.name.split(", ");_.each(n,(function(n){var i,o='<a href="'+t.value+'"';t.new_tab&&(o+=' target="_blank"'),t.no_follow&&(o+=' rel="nofollow"'),n=n.trim(),o+=">"+n+"</a>";var s=new RegExp("\\b"+n+"\\b(?![^<]*?<\\/a>)","gi"),r=n.length,m=(i=e.comment_content).match(s);_.each(m,(function(e){var t=i.search(s),m=o,a=o.search(">"+n+"<")+1;m=[m.slice(0,a),e,m.slice(a+r)].join(""),i=[i.slice(0,t),m,i.slice(t+r)].join("")})),e.comment_content=i}))}))),e}}),ThriveComments.collections.Comments=ThriveComments.collections.Base.extend({model:ThriveComments.models.Comment,compField:ThriveComments.sorting.sort_field,compOrder:ThriveComments.sorting.order,tcm_secret:"",commentCount:0,awaiting_moderation:0,userCommentCount:0,minCompField:null,url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},comparator:function(e){return 1===parseInt(e.get("tcm_featured"))?-1*Number.MAX_SAFE_INTEGER+this.compOrder*e.get(this.compField):this.compOrder*e.get(this.compField)},nested:function(e){var t=this;return e.children&&_.each(e.children,(function(n,i){t.nested(n),e.children[i]=new ThriveComments.models.Comment(n,{parse:!0})})),e},parse:function(e){var t=this;return this.commentCount=e.count,this.userCommentCount=e.user_comment_count,e=e.comments,_.each(e,(function(n,i){n.children&&n.children.length&&(e[i]=t.nested(n))})),e},insertComment:function(e,t){var n=this;_.each(e,(function(i,o){if(i.get("comment_ID")===parseInt(t.get("comment_parent"))){var s=e[o].get("children");s||(s=[]),s.push(t),e[o].set("children",s)}else i.get("children")&&i.get("children").length&&n.insertComment(i.get("children"),t)}))},push:function(e){this.commentCount++,0==e.get("comment_parent")?(this.models.push(e),this.length=this.length+1):this.insertComment(this.models,e)},countFeaturedComments:function(){return this.where({tcm_featured:"1"}).length}}),window.ThriveComments=window.ThriveComments||{},ThriveComments.views=ThriveComments.views||{},ThriveComments.objects=ThriveComments.objects||{},e=jQuery,ThriveComments.views.CreateComment=Backbone.View.extend({template:ThriveComments.util.tpl("comments/create"),events:{"focus #tcm-post-content":"showMainCreateFields","click .tcm-save-btn":"saveComment","click .tcm-show-login":"showLogin","keydown .form-input":"keyAction","input textarea":"textareaSizing","click #tcm-fb-logo":"facebookLogin","click .tcm-logout-label":"logout"},keyAction:function(e){13===e.keyCode&&(this.saveComment(e),e.stopPropagation())},initialize:function(e){e&&(this.viewList=e.viewList),this.comments_media_query()},comments_media_query:function(){var e=this.$el.parents("#comments");e.width()<600&&e.addClass("tcm-small")},textareaSizing:function(t){var n=t.currentTarget;e(n).css("height",1).css("height",n.scrollHeight+2)},showMainCreateFields:function(e){if(ThriveComments.util.tcm_hide_textareas(e),this.viewList.showPreviousClickedReplys(),this.$(".tcm-comment-additional-fields").slideDown(),!ThriveComments.current_user.ID){var t=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_name")).slice(1,-1).replace(/\+/g," "),n=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email")).slice(1,-1),i=JSON.parse('{ "link": "'+decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_website")).slice(1,-1)+'" }');t&&""===this.$("#tcm-guest-name").val()&&(this.$("#tcm-guest-name").val(t),this.$("#tcm-guest-email").val(n),this.$("#tcm-author-url").val(i.link),this.$("span.checkmark").click())}ThriveComments.currentOpenView=this},render:function(t){var n=this.$("#tcm-post-content").val(),i=ThriveComments.util.get_cookie("social-login");return""!==i&&(ThriveComments.social_user=JSON.parse(i)),t=e.extend({},t,{gravatarActive:ThriveComments.settings.gravatar_active,share_individual_comments:ThriveComments.settings.share_individual_comments,comment_registration:ThriveComments.settings.comment_registration,current_user_id:void 0!==ThriveComments.current_user.ID?ThriveComments.current_user.ID:0,comment_content:void 0!==n?n:"",close_comments:ThriveComments.close_comments}),this.$el.html(this.template(t)),this.afterRender(t),this},afterRender:function(t){if(new ClipboardJS("#tcm-click-to-copy").on("success",(function(t){var n=e(t.trigger),i=n.text();n.text(ThriveComments.util.render_label("copy_input")),setTimeout((function(){n.text(i)}),1e3),t.clearSelection()})),1===ThriveComments.settings.tcm_api_status.google_api&&ThriveComments.settings.tcm_enable_social_signin)var n=setInterval((function(){window.google&&window.google.accounts&&(window.google.accounts.id.renderButton(document.getElementById("tcm-google-sign-in-".concat(t.id)),{type:"icon",shape:"pill"}),clearInterval(n))}),1e3)},saveComment:function(t){var n=this;if(!this.validateComment())return!1;this.$("#tcm-submit-comment").text(ThriveComments.util.render_label("comment_sending"));var i=this.prepareCommentForSave();(i=new ThriveComments.models.Comment(i)).save().done((function(i){var o=new ThriveComments.models.Comment(i),s=n.$("textarea");e(".tcm-post-input-container textarea").val(""),n.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment")),"trash"!==o.get("comment_approved")&&n.addNewCommentToList(t.currentTarget,o,0),n.removeCreateForm(),s.css("height",1),n.replyAndApprove(i,o),e(".tcm-reply-btn").attr("data-clicked",0),n.viewList.showPreviousClickedReplys()})).fail((function(e){var t=n.handleError(e);ThriveComments.util.err(t)})).always((function(){n.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment"))}))},prepareCommentForSave:function(){var e,t,n,i=ThriveComments.util.get_cookie("social-login"),o=this.$("#tcm-author-url").val(),s="",r={};return""!==i?(t=(e=JSON.parse(i)).name,n=e.email,s=e.picture):(t=ThriveComments.util.previousUser()?ThriveComments.current_user.display_name:this.$("input[name='name']").val(),n=ThriveComments.util.previousUser()?ThriveComments.current_user.user_email:this.$("input[name='email']").val()),this.$(".tcm-extra-fields input").each((function(){this.checked&&(r[this.getAttribute("name")]=this.value)})),{children:[],comment_content:this.$("#tcm-post-content").val().trim(),comment_author:t,comment_author_email:n,comment_author_url:void 0!==o&&ThriveComments.util.isValidUrl(ThriveComments.util.addHttp(o))?o:"",comment_author_picture:s,comment_parent:this.$(".tcm-save-btn").attr("data-parent"),level:this.$(".tcm-save-btn").attr("data-parent")>0?Math.min(parseInt(this.$(".tcm-save-btn").attr("data-level"))+1,3):0,secret_spam:ThriveComments.secret_spam,comment_post_ID:ThriveComments.post.ID,tva_term:void 0!==ThriveComments.tva_term&&ThriveComments.tva_term,tcm_receive_notifications:this.$("#tcm_receive_notifications").prop("checked"),tcm_remember_me:this.$("#tcm_remember_me").prop("checked"),tcm_storing_consent:this.$("#tcm_storing_consent").prop("checked"),tcm_extra_fields:r}},handleError:function(e){var t="";switch(e.status){case 409:t=ThriveComments.util.render_label("comment_duplicate");break;case 429:t=ThriveComments.util.render_label("comment_flood");break;default:""===(t=ThriveComments.util.render_label(e.responseJSON.code))&&(t=e.responseJSON.code+". "+e.responseJSON.message)}return t},replyAndApprove:function(e,t){var n=t.get("comment_parent"),i=null;if(n&&t.get("is_moderator")&&(i=ThriveComments.util.search_comment(ThriveComments.objects.Comments,n))){var o={id:i.get("comment_ID")};i.set("comment_approved",1),i.set("status",1),i.save(o,{error:this.handleError})}},removeCreateForm:function(){var e=this.$(".mainInput");e.parents("div.tcm-lazy-comments").length&&this.$(".tcm-create-post-container").hide(),e.length?(e.val(""),this.$(".tcm-comment-additional-fields").hide()):this.$el.remove()},addNewCommentToList:function(t,n,i){var o,s=jQuery(t).closest(".tcm-comment-item");return!!this.$el.siblings(".tcm-comments-list").first().find("div[data-comment-id="+n.get("comment_ID")+"]").length||(ThriveComments.objects.Comments.push(n),this.updateCommentCountLabel(n),(o=this.insertCommentIntoPosition(t,n,s,i))&&ThriveComments.util.showCommentConversion(o),e(window).trigger("scroll"),this)},insertCommentIntoPosition:function(t,n,i,o){var s,r=new ThriveComments.views.CommentsItem({model:n,commentsList:this.viewList});if(s=r.render().$el,!i.length){var m=e(t).closest(".tcm-create-post-container").attr("data-position");return s.addClass("tcm-main-parent"),"top"===m&&-1===ThriveComments.objects.Comments.compOrder?(this.$el.next().prepend(s),r):"bottom"!==m||1!==ThriveComments.objects.Comments.compOrder||jQuery(".tcm-loader").is(":visible")?o?(jQuery(".tcm-loader").is(":visible")&&-1!==ThriveComments.objects.Comments.compOrder||this.$el.next().prepend(s),r):(this.viewList.close(),this.viewList.pushCommentsCreated({comment_id:n.get("comment_ID"),comment_after_save:n.get("show_after_save")}),this.viewList.initDisplayComments(n.get("comment_ID")),!1):(this.$el.parent().prev().append(s),r)}return n.get("level")>2&&s.addClass("stop-nesting"),i.append(s),r},updateCommentCountLabel:function(t){"1"===t.get("comment_approved")&&e(".tcm-comments-number").text((function(e,t){return t.replace(/(\d+)/,ThriveComments.objects.Comments.commentCount)}))},validateComment:function(){var e=!0;return ThriveComments.util.get_cookie("social-login"),ThriveComments.util.previousUser()||(ThriveComments.util.validateInput(this.$("input[name='name']"),ThriveComments.util.render_label("author_name_required"),!0)||(e=!1),ThriveComments.util.validateEmail(this.$("input[name='email']"),ThriveComments.util.render_label("isRequired"),!0)||(e=!1),""!==this.$("#tcm-author-url").val()&&(ThriveComments.util.validateInputUrl(this.$("#tcm-author-url"),ThriveComments.util.render_label("invalid_website_url"),!0)||(e=!1)),ThriveComments.util.validateStoringConsent(this.$("#tcm_storing_consent"),ThriveComments.util.render_label("accept_privacy_checkbox"))||(e=!1)),ThriveComments.util.validateInput(this.$("#tcm-post-content"),ThriveComments.util.render_label("comment_content_missing"),!0)||(e=!1),e},showLogin:function(t){var n,i=e("#wp-auth-check"),o=e("#wp-auth-check-form"),s=e("#wp-auth-check-wrap"),r=s.find(".wp-auth-fallback-expired"),m=this,a=!1,c=jQuery(t.currentTarget).closest(".tcm-create-post-container");if(ThriveComments.util.position=c.data("position"),ThriveComments.util.content=c.find("textarea#tcm-post-content").val(),ThriveComments.util.afterLogin=1,ThriveComments.util.commentId=c.data("comment-id"),o.length){e(window).on("beforeunload.wp-auth-check",(function(e){e.originalEvent.returnValue=window.authcheckL10n.beforeunload}));var l=o.attr("data-src").replace("members/login/","wp-login.php");o.attr("data-src",l),(n=e('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",r.text())).on("load",(function(){var t,n;a=!0,o.removeClass("loading");try{t=(n=e(this).contents().find("body")).height()}catch(e){return s.addClass("fallback"),i.css("max-height",""),o.remove(),void r.focus()}t?n&&n.hasClass("interim-login-success")?m.hideLogin():i.css("max-height",t+40+"px"):n&&n.length||(s.addClass("fallback"),i.css("max-height",""),o.remove(),r.focus())})).attr("src",l).ready((function(){s.find(".wp-auth-check-close").on("click",(function(){m.hideLogin()}))})),o.append(n)}e("body").addClass("modal-open"),s.removeClass("hidden"),n?(n.focus(),setTimeout((function(){a||(s.addClass("fallback"),o.remove(),r.focus())}),1e4)):r.focus()},hideLogin:function(){var t=e("#wp-auth-check-wrap");e(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(e(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),t.fadeOut(200,(function(){t.addClass("hidden").css("display",""),e("#wp-auth-check-frame").remove(),e("body").removeClass("modal-open")}))},checkConversion:function(e){("first_time"==e.show_after_save&&"tcm_redirect"==ThriveComments.settings.tcm_conversion.first_time.active||"second_time"==e.show_after_save&&"tcm_redirect"==ThriveComments.settings.tcm_conversion.second_time.active)&&this.redirectURL(e)},redirectURL:function(e){"first_time"==e.show_after_save?window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect.first_time.redirect_url):"second_time"==e.show_after_save&&window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect.second_time.redirect_url)},facebookLogin:function(e){var t=this;FB.login((function(e){e.authResponse&&FB.api("/me?fields=name,email",(function(e){var n={name:e.name,email:e.email,picture:location.protocol+"//graph.facebook.com/"+e.id+"/picture?width=200"};ThriveComments.util.set_cookie("social-login",n),ThriveComments.social_user=n,t.reloadView()}))}),{scope:"email"})},logout:function(e){ThriveComments.util.set_cookie("social-login","",-1),delete ThriveComments.social_user,this.reloadView()},reloadView:function(){var t=this.$(".tcm-create-post-container"),n=t.data("comment-id"),i=n?"comments/"+n:"";ThriveComments.util.position=t.data("position"),ThriveComments.util.content=t.find("textarea#tcm-post-content").val(),ThriveComments.util.afterLogin=1,ThriveComments.util.commentId=n,Backbone.history.loadUrl(i),e(".tcm-comment-item").each((function(){var t=e(this);t.find(".tcm-comment-wrapper").hide(),t.find(".tcm-error-heading").hide()}))}}),ThriveComments.views.SortComments=Backbone.View.extend({template:ThriveComments.util.tpl("comments/sort"),sortBy:ThriveComments.sorting.sort_name,events:{"click #tcm-sort-by":"mouseEnterShare","click .tcm-dropdown-element":"sortComments","mouseenter #tcm-sort-by":"mouseEnterShare","mouseleave #tcm-sort-by":"mouseLeaveShare"},initialize:function(e){this.viewList=e.viewList,this.render()},render:function(){this.$el.empty(),this.$el.append(this.template({sortBy:this.sortBy}))},sortComments:function(e){var t=e.currentTarget.getAttribute("data-value");jQuery(e.currentTarget).parent().siblings(".current-sorting").html(e.currentTarget.innerHTML.trim()),this.sortBy=t,this.viewList.sortComments(t),jQuery("#tcm-sort-by").removeClass("tcm-share-dropdown-hover")},mouseEnterShare:function(e){return"click"===e.type&&e.stopPropagation(),!e.target.classList.contains("tcm-sort-by")&&e.currentTarget.classList.add("tcm-share-dropdown-hover"),!1},mouseLeaveShare:function(e){return jQuery(e.currentTarget).removeClass("tcm-share-dropdown-hover"),!1}}),ThriveComments.views.Comments=Backbone.View.extend({template:ThriveComments.util.tpl("comments/list"),events:{"change #tcm-sort-by":"sortComments"},viewLazy:null,viewSort:null,comments_rendered:0,commentsCreated:[],lazyFlag:1,clickedRplyButtons:[],initialize:function(t){var n,i,o,s,r;this.viewLazy=t.viewLazy,this.viewSort=t.viewSort,"undefined"==typeof FB&&1===ThriveComments.settings.tcm_api_status.facebook&&1===ThriveComments.settings.tcm_api_status.facebook_api&&ThriveComments.settings.tcm_enable_social_signin&&(window.fbAsyncInit=function(){FB.init({appId:ThriveComments.tcm_social_apis.facebook.app_id,autoLogAppEvents:!0,status:!0,xfbml:!0,version:"v2.9"})},i="script",o="facebook-jssdk",r=(n=document).getElementsByTagName(i)[0],n.getElementById(o)||((s=n.createElement(i)).id=o,s.src="//connect.facebook.net/en_US/sdk.js",r.parentNode.insertBefore(s,r))),1===ThriveComments.settings.tcm_api_status.google_api&&ThriveComments.settings.tcm_enable_social_signin&&(window.onGoogleLibraryLoad=function(){window.google.accounts.id.initialize({client_id:ThriveComments.tcm_social_apis.google.client_id,context:"use",ux_mode:"popup",auto_prompt:!1,callback:function(e){var t,n,i=(t=e.credential.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(window.atob(t).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")),JSON.parse(n)),o={name:i.name,email:i.email,picture:i.picture};ThriveComments.util.set_cookie("social-login",o),ThriveComments.social_user=o,void 0!==ThriveComments.currentOpenView&&"function"==typeof ThriveComments.currentOpenView.reloadView&&ThriveComments.currentOpenView.reloadView()}})},e.getScript("https://accounts.google.com/gsi/client"))},close:function(){this.$el.empty(),this.unbind()},startLazy:function(e){var t=this;if(!e&&ThriveComments.settings.lazy_load){var n=jQuery("#thrive-comments");(this.lazyFlag&&ThriveComments.util.elem_viewport(n)||ThriveComments.util.elem_viewport(this.viewLazy.$el)||ThriveComments.util.afterLogin)&&(t.initDisplayComments(e),t.lazyFlag=0),jQuery(window).scroll((function(){t.lazyFlag&&ThriveComments.util.elem_viewport(n)&&(t.initDisplayComments(e),t.lazyFlag=0)}))}else t.initDisplayComments(e);this.lazy_avatar()},initDisplayComments:function(t){var n=this;if(ThriveComments.util.tcm_show_loader(),"static"===this.viewLazy.type){var i={};ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(i.tva_term=ThriveComments.tva_term),this.collection.fetch({data:e.param(i),success:function(){n.displayComments(t)},error:function(e,t){ThriveComments.util.err(ThriveComments.util.render_label("tcm_get_comments_error"))}})}else this.displayComments(t)},lazy_avatar:function(){var t=this;e(window).on("scroll",(function(){t.show_images()}))},show_images:function(){e("div.no-image").each((function(){var t=e(this);if(!0===t.data("social-avatar"))return t.removeClass("no-image"),!1;ThriveComments.util.elem_viewport(t)&&(ThriveComments.util.set_avatar_url(t),t.removeClass("no-image"))}))},displayComments:function(e){this.viewLazy.view=this,this.viewLazy.changePage(null,{id:e,page:1,sortBy:ThriveComments.sorting.sort_field})},sortComments:function(e){switch(e){case"desc":this.collection.compField="comment_ID",this.collection.compOrder=-1;break;case"asc":this.collection.compField="comment_ID",this.collection.compOrder=1;break;case"top-rated":this.collection.compField="comment_karma",this.collection.compOrder=-1}var t=1==this.collection.compOrder?"ASC":"DESC";this.comments_rendered=0,this.viewLazy.changePage(null,{page:1,resetContent:1,sortBy:this.collection.compField,order:t})},render:function(e){var t=this;return ThriveComments.util.showCommentsNumber(this.collection.commentCount),e.forEach((function(e){var n,i=new ThriveComments.views.CommentsItem({model:e,commentsList:t}),o=i.render().$el;o.addClass("tcm-main-parent"),t.$el.append(o),(n=t.searchInCommentsCreated(e.get("comment_ID")))&&(i.model.set("show_after_save",n.comment_after_save),ThriveComments.util.showCommentConversion(i))})),ThriveComments.util.tcm_hide_loader(),this},pushCommentsCreated:function(e){this.commentsCreated.push(e)},searchInCommentsCreated:function(t){if(!this.commentsCreated.length)return!1;var n=e.grep(this.commentsCreated,(function(e){return parseInt(e.comment_id)===t}));return 0!==n.length&&n[0]},addClickedReplyButton:function(e){return this.clickedRplyButtons.push(e),this},showPreviousClickedReplys:function(){return this.clickedRplyButtons.forEach((function(e){1!==parseInt(e.getAttribute("data-clicked"))&&(e.style.display="block")})),this}}),ThriveComments.views.FrontendModeration=Backbone.View.extend({template:ThriveComments.util.tpl("comments/moderation"),actions:{},events:{"click .tcm-dropdown-moderate-element":"updateComment"},initialize:function(e){this.commentView=e.commentView?e.commentView:null,this.setActions(),this.render(),this.initClipboard()},render:function(){var e=this.model.getCommentStatus(),t=this.getActions(e);this.$el.html(this.template({actions:t}))},initClipboard:function(){var t=this.$("[data-value=copyLink]");if(t.length){var n=new ClipboardJS(t[0]),i=ThriveComments.const.post_url+"#comments/"+this.$el.closest(".tcm-comment-content").attr("data-comment-id");t.attr("data-clipboard-text",i),n.on("success",(function(t){var n=e(t.trigger),i=n.text();n.text(ThriveComments.util.render_label("copy_input")),setTimeout((function(){n.text(i)}),1e3),t.clearSelection()}))}},updateComment:function(e){var t=e.currentTarget.getAttribute("data-fn"),n=e.currentTarget.getAttribute("data-value");"function"==typeof this[t]&&this[t](n)},changeApprove:function(e){var t={id:this.model.get("comment_ID")};ThriveComments.const.moderation.unapprove===e&&"0"!==this.model.get("tcm_featured")&&(this.model.set("tcm_featured",0),t.update_meta="tcm_featured"),this.model.set("comment_approved",e),this.model.set("status",e),this.model.save(t,{error:this.errorAtSave})},changeFeature:function(e){var t={id:this.model.get("comment_ID"),update_meta:"tcm_featured"};return ThriveComments.const.moderation.featured===parseInt(e)&&this.model.get("comment_approved")!==ThriveComments.const.moderation.approve&&(this.model.set("status",ThriveComments.const.moderation.approve),this.model.set("comment_approved",1)),this.model.set("tcm_featured",parseInt(e)),this.model.save(t,{error:this.errorAtSave}),this},changeSpam:function(e){var t={id:this.model.get("comment_ID")};this.model.set("comment_approved",e),this.model.set("status",e).save(t,{error:this.errorAtSave})},changeTrash:function(e){var t={id:this.model.get("comment_ID")};this.model.set("status",e).save(t,{error:this.errorAtSave})},undoDelete:function(){var e="trash"===this.model.get("status")?"untrash":"unspam",t={id:this.model.get("comment_ID")};return this.model.set("status",e),this.model.save(t,{error:this.errorAtSave}),!1},errorAtSave:function(e,t,n){var i="";if(t.responseJSON.message)i=t.responseJSON.message;else if(t.responseText)try{i="parsererror"===n?"Could not parse response: "+t.responseText:JSON.parse(t.responseText).message}catch(e){}i||(i=(t.statusText||n)+(t.status?" ("+t.status+")":"")),ThriveComments.util.err(i)},setActions:function(){var e={unapproved:{approve:{text:ThriveComments.util.render_label("approve_text"),fn:"changeApprove",value:1},feature:{text:ThriveComments.util.render_label("feature_text"),fn:"changeFeature",value:ThriveComments.const.moderation.featured},copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"},spam:{text:ThriveComments.util.render_label("spam_text"),fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.util.render_label("trash_text"),fn:"changeTrash",value:ThriveComments.const.moderation.trash}},approved:{unapprove:{text:ThriveComments.util.render_label("unapprove_text"),fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},feature:{text:ThriveComments.util.render_label("feature_text"),fn:"changeFeature",value:ThriveComments.const.moderation.featured},copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"},spam:{text:ThriveComments.util.render_label("spam_text"),fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.util.render_label("trash_text"),fn:"changeTrash",value:ThriveComments.const.moderation.trash}},featured:{unapprove:{text:ThriveComments.util.render_label("unapprove_text"),fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},stop_featuring:{text:ThriveComments.util.render_label("stop_feature_text"),fn:"changeFeature",value:ThriveComments.const.moderation.not_featured},spam:{text:ThriveComments.util.render_label("spam_text"),fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.util.render_label("trash_text"),fn:"changeTrash",value:ThriveComments.const.moderation.trash}},stop_featuring:{unapprove:{text:ThriveComments.util.render_label("unapprove_text"),fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},feature:{text:ThriveComments.util.render_label("feature_text"),fn:"changeFeature",value:ThriveComments.const.moderation.featured},spam:{text:ThriveComments.util.render_label("spam_text"),fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.util.render_label("trash_text"),fn:"changeTrash",value:ThriveComments.const.moderation.trash}}},t={approved:{copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"}}};this.actions=ThriveComments.current_user.is_moderator?e:t},getActions:function(e){return""!==e?this.actions[e]:{}}}),ThriveComments.views.DeletedItem=Backbone.View.extend({template:ThriveComments.util.tpl("comments/deleted"),events:{"click .undo-action":"undoAction"},initialize:function(e){this.commentView=e.commentView?e.commentView:null,this.moderationView=e.moderationView?e.moderationView:null},render:function(){return this.$el.html(this.template({comment:this.model})),this.commentView.$(".tcm-comment-content").hide(),this.commentView.$(".tcm-comment-item").hide(),this.commentView.$el.removeClass("tcm-featured-class"),this},undoAction:function(){return this.moderationView.undoDelete(),!1}}),ThriveComments.views.CommentsItem=Backbone.View.extend({className:"tcm-comment-item",template:ThriveComments.util.tpl("comments/item"),voteRoute:ThriveComments.routes.comments+"/vote",events:{"click .tcm-reply-btn":"showCreateFields","click .tcm-share-btn":"showShareButtons","mouseenter .tcm-share-dropdown":"mouseEnterShare","mouseleave .tcm-share-dropdown":"mouseLeaveShare","click .tcm-share-twitter":"shareTwitter","click .tcm-share-facebook":"shareFacebook","click .tcm-voting-input":"vote"},initialize:function(e){this.commentsList=e.commentsList?e.commentsList:null,this.listenTo(this.model,"sync",this.commentSync)},showCreateFields:function(t){var n=new ThriveComments.views.CreateComment({viewList:this.commentsList}),i=t.currentTarget,o=i.getAttribute("data-id"),s=i.getAttribute("data-level");"1"!==i.getAttribute("data-clicked")&&(ThriveComments.util.tcm_hide_textareas(t),this.commentsList.showPreviousClickedReplys(),e(".add-comment").show(),jQuery(i).siblings(".tcm-create-comment-fields").html("").append(n.render({mainInput:0,id:o,level:s,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"",close_comments:ThriveComments.close_comments}).$el).css("display","none").slideDown(),i.setAttribute("data-clicked",1),i.style.display="none",this.commentsList.addClickedReplyButton(i),t.stopPropagation(),jQuery(window).trigger("scroll"))},commentSync:function(){return this.render(),"spam"!==this.model.get("status")&&"trash"!==this.model.get("status")||this.deletedState(),jQuery(window).trigger("scroll"),this},render:function(){var e=ThriveComments.util.get_cookie("vote-comment-"+this.model.id);return this.model.setCommentApproved(),this.$el.html(this.template({comment:this.model,gravatarActive:ThriveComments.settings.gravatar_active,close_comments:ThriveComments.close_comments,share_individual_comments:ThriveComments.settings.share_individual_comments,lazy_load_avatar:ThriveComments.settings.lazy_load_avatar,last_vote:e})),this.afterRender(),this.initCommentModeration(),this.model.get("children")&&this.model.get("children").length&&(this.$el.addClass("tcm-has-children"),this.renderChildren(this.model.get("comment_ID"),this.model.get("children"),this.$el)),this.commentsList.comments_rendered++,this},renderChildren:function(e,t,n){var i=this;t&&t.forEach((function(t){if(0!==parseInt(t.get("comment_parent"))&&parseInt(t.get("comment_parent"))===e){var o,s=new ThriveComments.views.CommentsItem({model:t,commentsList:i.commentsList}),r=s.render().$el;n.append(r),(o=i.commentsList.searchInCommentsCreated(t.get("comment_ID")))&&(s.model.set("show_after_save",o.comment_after_save),ThriveComments.util.showCommentConversion(s),s.handleAfterShowAction())}}))},afterRender:function(){return this.model.get("user_id")===ThriveComments.post.post_author&&(this.$el.addClass("tcm-post-author"),this.$("strong").addClass("tcm-color-ac")),this.model.get("level")>=3&&this.$el.addClass("stop-nesting"),this.model.get("children")&&this.model.get("children").length&&this.$el.addClass("tcm-has-children"),1===parseInt(this.model.get("tcm_featured"))?this.$el.addClass("tcm-featured-class"):this.$el.removeClass("tcm-featured-class"),this},initCommentModeration:function(){this.moderationView=new ThriveComments.views.FrontendModeration({el:this.$("#tcm-moderate-front"),model:this.model,commentView:this})},showShareButtons:function(){this.$(".tcm-share-btns-container").show()},mouseEnterShare:function(e){return jQuery(e.currentTarget).addClass("tcm-share-dropdown-hover"),!1},mouseLeaveShare:function(e){var t=jQuery(e.currentTarget);return t.removeClass("tcm-share-dropdown-hover"),t.find(".tcm-copy-input-content").removeClass("hover"),!1},shareTwitter:function(e){var t,n=this.$(".tcm-comment-text-content").html().trim(),i=e.currentTarget.getAttribute("data-url"),o=this.$(".tcm-comment-author-name strong").text().replace(/\s\s+/g," ");for(n=n.replace(/<(?:.|\n)*?>/gm,"");o.length>20;)o=o.split(" ").slice(0,-1).join(" ");return(n=n.replace(/<br\s*[\/]?>/gi," ")).length>90&&(n=(n=n.substring(0,90)).split(" ").slice(0,-1).join(" ")),n=n+"... -"+o+" "+i,t=this.$("a.tcm-share-twitter").attr("href")+"?text="+encodeURIComponent(n),window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},shareFacebook:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"",i=this.$(".tcm-comment-author-img").css("background-image").replace("url(","").replace(")","").replace(/\"/gi,""),o=this.$(".tcm-comment-text-content").html().trim(),s=encodeURIComponent(e.currentTarget.getAttribute("data-url"));return o=(o=o.replace(/<(?:.|\n)*?>/gm,"")).replace(/<br\s*[\/]?>/gi,""),t=this.$("a.tcm-share-facebook").attr("href")+"?u="+s+"&title="+n+"&description="+o+"&picture="+encodeURIComponent(i),window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},vote:function(e){var t=this,n=this.model.id,i=e.currentTarget.dataset.type,o=this.$(".tcm-comment-content:first .tcm-voting-input"),s=o.filter(".tcm-upvote").find(".tcm-votes-count").text(),r=o.filter(".tcm-downvote").find(".tcm-votes-count").text(),m=o.filter(".tcm-upvote").attr("class"),a=o.filter(".tcm-downvote").attr("class"),c=function(){o.filter(".tcm-upvote").attr("class",m).find(".tcm-votes-count").text(s),o.filter(".tcm-downvote").attr("class",a).find(".tcm-votes-count").text(r)};if(this.doingVote)return!1;function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";jQuery.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},url:t.voteRoute,type:"POST",data:{comment_id:n,vote_type:i,secret_spam:ThriveComments.secret_spam,g_recaptcha_response:e}}).done((function(e){t.doingVote=!1})).fail((function(e){ThriveComments.util.err(e.responseJSON.message),c()})).always((function(){}))}return this.doingVote=!0,e.currentTarget.classList.contains("active")?(e.currentTarget.classList.remove("active"),e.currentTarget.classList.contains("tcm-upvote")?o.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(s)-1):o.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(r)-1)):(e.currentTarget.classList.contains("tcm-upvote")?(o.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(s)+1),o.filter(".tcm-downvote").hasClass("active")&&o.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(r)-1)):(o.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(r)+1),o.filter(".tcm-upvote").hasClass("active")&&o.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(s)-1)),o.removeClass("active"),e.currentTarget.classList.add("active")),ThriveComments.recaptcha_enabled&&void 0!==window.grecaptcha?grecaptcha.ready((function(){grecaptcha.execute(ThriveComments.recaptcha.site_key,{action:"submit"}).then((function(e){l(e)}))})):l(),!1},deletedState:function(){this.childView=new ThriveComments.views.DeletedItem({el:this.$(".deleted-state").first(),model:this.model,commentView:this,moderationView:this.moderationView}),this.childView.render(),e(window).trigger("scroll")}}),ThriveComments.views.LazyLoad=Backbone.View.extend({template:ThriveComments.util.tpl("comments/lazy-loading"),events:{"click .tcm-loader":"changePage","click .add-comment":"addCommentBottom","click .tcm-link-subscribe":"showSubscribeForm","click .tcm-link-unsubscribe":"unSubscribe","click .submit-subscribe-post":"subscribePost","click .submit-unsubscribe-post":"unSubscribePost"},currentPage:1,itemsPerPage:parseInt(ThriveComments.settings.comments_per_page),collection:null,params:null,type:"",view:null,order:"",sortBy:"",initialize:function(e){this.collection=e.collection,this.view=e.view,this.type=e.type,this.order=1===ThriveComments.sorting.order?"ASC":"DESC"},changePage:function(t,n){e(".tcm-lazy-comments .tcm-dot-loader").removeClass("done"),this.$(".add-comment").hide();var i=this,o={itemsPerPage:this.itemsPerPage};if(n&&void 0!==n.page?o.page=parseInt(n.page):o.page=this.currentPage,o.page<1&&(o.page=1),n&&void 0!==n.resetContent&&this.view.$el.empty(),n&&n.id&&(o.go_to_id=n.id),"dynamic"==this.type)n&&void 0!==n.sortBy?o.sortBy=n.sortBy:o.sortBy=this.sortBy,n&&void 0!==n.order?o.order=n.order:o.order=this.order,ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(o.tva_term=ThriveComments.tva_term),this.collection.fetch({reset:!0,data:e.param(o),success:function(e,t){i.$el.show(),null!=t.nextPage?i.updateParams(t.nextPage,o.sortBy,o.order):i.updateParams(o.page+1,o.sortBy,o.order),i.view.render(e),i.render(),ThriveComments.util.scrollToElement(i.view.$("div[data-comment-id="+o.go_to_id+"]"))}});else if("static"===this.type&&void 0!==this.view&&null!==this.view){var s,r=(o.page-1)*this.itemsPerPage,m=o.page,a=0,c=this.collection.sort();if(ThriveComments.settings.page_comments){if(n&&n.id){do{s=c.chain().rest(r).first(this.itemsPerPage).value(),a=ThriveComments.util.search_recursive(s,n.id),this.view.render(s),r=((m+=1)-1)*this.itemsPerPage,this.updateParams(m,"","")}while(!a&&0!==s.length);ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+n.id+"]")),a?ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+n.id+"]")):(r=(o.page-1)*this.itemsPerPage,this.view.$el.empty(),this.updateParams(o.page+1,"",""),s=c.chain().rest(r).first(this.itemsPerPage).value(),this.view.render(s))}else{this.updateParams(o.page+1,"","");var l=c.countFeaturedComments(),h=this.itemsPerPage;l>0&&(o.page>1?r+=l:h=l+h),s=c.chain().rest(r).first(h).value(),this.view.render(s)}if(0===s.length)return ThriveComments.util.showCommentsNumber(0),ThriveComments.util.tcm_hide_loader(),void this.$(".tcm-loader").hide()}else this.view.render(c),ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+n.id+"]"));i.render()}return!1},updateParams:function(e,t,n){this.currentPage=e,this.sortBy=t,this.order=n},render:function(){this.$el.html(this.template({commentsLength:this.collection.commentCount,comments_rendered:this.view.comments_rendered,showPoweredBy:ThriveComments.settings.powered_by,pageComments:ThriveComments.settings.page_comments,type:this.type})),e(".level-0").length>=parseInt(this.collection.userCommentCount)?this.$(".tcm-loader").hide():this.$(".tcm-loader").show(),ThriveComments.util.focusAfterLogin(),jQuery(window).trigger("scroll");var t=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email"));return""!==ThriveComments.util.get_cookie("subscribed_posts")&&t&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&void 0!==ThriveComments.current_user.ID?(this.$(".tcm-link-subscribe").hide(),this.$(".tcm-link-unsubscribe").show(),!1):this},addCommentBottom:function(t){ThriveComments.util.tcm_hide_textareas(t);var n=new ThriveComments.views.CreateComment({viewList:this.viewList}),i=this.$(".tcm-powered-by"),o=n.render({mainInput:1,id:0,level:0,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"bottom",close_comments:ThriveComments.close_comments}).$el;e(t.currentTarget).hide(),i.length?i.before(o):this.$el.append(o)},showSubscribeForm:function(){return ThriveComments.current_user.ID?this.addPostSubscriber(ThriveComments.current_user.user_email,1):(this.$(".tcm-link-subscribe").hide(),this.$("#tcm-subscribe-form").show()),!1},unSubscribe:function(e){var t=ThriveComments.current_user.user_email;this.$(".tcm-link-unsubscribe").hide(),this.$("#tcm-unsubscribe-form").hide(),this.$(".tcm-link-subscribe").show(),e.stopPropagation(),void 0===ThriveComments.current_user.user_email&&(t=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email"))),this.addPostSubscriber(t,0)},subscribePost:function(){var e=this.$(".tcm-subscriber-email");if(ThriveComments.util.validateEmail(e,ThriveComments.util.render_label("isRequired"))){if(""!==ThriveComments.util.get_cookie("subscribed_posts")&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&ThriveComments.util.validateEmail(e,ThriveComments.util.render_label("isRequired")))return this.$("#tcm-subscribe-form").hide(),this.$(".tcm-already-subscribed").show(),!1;this.addPostSubscriber(e.val(),1)}},unSubscribePost:function(){var e=this.$(".tcm-unsubscriber-email");return""!==ThriveComments.util.get_cookie("subscribed_posts")&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&ThriveComments.util.validateEmail(e,ThriveComments.util.render_label("isRequired"))&&this.addPostSubscriber(e.val(),0),!1},addPostSubscriber:function(t,n){var i=this.$(".tcm-link-subscribe"),o=ThriveComments.util.render_label("subscribe"),s=this.$("#tcm-subscribe-form"),r=this.$(".tcm-link-unsubscribe"),m=this.$("#tcm-unsubscribe-form"),a={email:t,post_id:ThriveComments.post.ID,subscribe:n};ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(a.tva_term=ThriveComments.tva_term),i.text(ThriveComments.util.render_label("comment_pending")),s.hide(),ThriveComments.current_user.ID?i.show():i.hide(),e.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},type:"POST",url:ThriveComments.routes.update_post_subscriber,data:a}).done((function(){ThriveComments.util.set_subscriber_cookies(n),0===n?(i.text(o),ThriveComments.current_user.ID?i.show():(i.hide(),m.hide(),s.show())):1===n&&ThriveComments.current_user.ID?(i.hide(),r.show()):(s.hide(),i.hide(),m.show())})).fail((function(e){m.show(),i.text(o),ThriveComments.util.err(e.responseJSON.message)}))}}),ThriveComments.views.CommentConversion=Backbone.View.extend({className:"tcm-conversion-container",template:ThriveComments.util.tpl("comments-conversion"),events:{"click .fb-button":"conv_facebook","click .x-button":"conv_twitter","click .in-button":"conv_linkedin","click .pt-button":"conv_pinterest","click .gm-button":"conv_google","click .xi-button":"conv_xing"},commentView:null,initialize:function(e){this.commentView=e.commentView,this.conversionSettings=this.commentView.model.get("conversion_settings")},render:function(e){return this.$el.html(this.template(e)),this},handleAfterShowAction:function(e){var t=this.commentView.model.get("show_after_save"),n=this.commentView.model.get("commenter_first");if(!t)return!1;if("live_update"===t)return this.handleLiveUpdate(t,n,"tcm_live_update"),!0;switch(this.conversionSettings[t].active){case"tcm_redirect":this.redirectURL(t);break;case"tcm_live_update":this.handleLiveUpdate(t,n,"tcm_live_update");break;case"tcm_related_posts":this.handleRelatedPosts(t,"tcm_related_posts");break;case"tcm_thrivebox":this.handleThrivebox(t);break;case"tcm_social_share":this.handleSocialShare(t,"tcm_social_share")}},handleSocialShare:function(e,t){var n,i="live_update"===e?this.conversionSettings.tcm_live_update[e]:this.conversionSettings.tcm_social_share[e];n=i.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),this.render({html_switch:t,custom_message:n,share_btns:i.social_sharing_buttons})},handleRelatedPosts:function(e,t){var n,i,o="live_update"===e?this.conversionSettings.tcm_live_update[e]:this.conversionSettings.tcm_related_posts[e];""!==o.custom_message&&(n=o.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),i=o.show_featured_image,this.render({html_switch:t,custom_message:n,show_featured_image:i}))},redirectURL:function(e){""==ThriveComments.settings.tcm_conversion.tcm_redirect[e].redirect_url||ThriveComments.settings.tcm_conversion.tcm_redirect[e].flag||window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect[e].redirect_url)},handleLiveUpdate:function(e,t,n){var i,o=1===parseInt(t)?"first_time":"second_time",s="live_update"===e?this.conversionSettings.tcm_live_update[o]:this.conversionSettings.tcm_live_update[e];""!==s.custom_message&&(i=s.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),this.render({html_switch:n,custom_message:i}))},handleThrivebox:function(t){var n,i=this.conversionSettings.tcm_thrivebox[t].thrivebox_id,o=this;if(!i||"undefined"==typeof TL_Const||"0"===i)return n="first_time"===t?1:2,this.handleLiveUpdate(t,n,"tcm_live_update"),!1;var s={tcb_js:"undefined"!=typeof TCB_Front?1:0,two_step_ids:[i.toString()],action:"tve_leads_ajax_load_forms",security:TL_Const.security,display_options:TL_Const.display_options,current_screen:TL_Const.current_screen,tve_flat_included:e("#tve_style_family_tve_flt-css").length};ThriveGlobal.$j.each(TL_Const.custom_post_data,(function(e,t){s[e]=t})),window.TVE_Dash&&!TVE_Dash.ajax_sent?ThriveGlobal.$j(document).on("tve-dash.load",(function(e){TVE_Dash.add_load_item("tl_lazy_load",s,TL_Front.ajax_load_callback)})):ThriveGlobal.$j.ajax({url:TL_Const.ajax_url,type:"post",dataType:"json",data:s,xhrFields:{withCredentials:!0}}).done((function(e){TL_Front.ajax_load_callback(e);var t=jQuery(".tl-2step-trigger-"+i);if(t.length){var n,s=jQuery('[data-tl-type="two_step_'+i+'"]');s.length&&((n=jQuery(s[0])).find('input[name="email"]').val(o.commentView.model.get("comment_author_email")),n.find('input[name="name"]').val(o.commentView.model.get("comment_author"))),setTimeout((function(){t.click()}),0)}}))},conv_facebook:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"",i=ThriveComments.post.featured_image?ThriveComments.post.featured_image:"",o=encodeURIComponent(ThriveComments.post.permalink);return t=e.currentTarget.getAttribute("data-href")+"?u="+o+"&title="+n+"&image_url="+encodeURIComponent(i),window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},conv_twitter:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"";return n.length>90&&(n=(n=n.substring(0,90)).split(" ").slice(0,-1).join(" ")),n=n+" "+ThriveComments.post.permalink,t=e.currentTarget.getAttribute("data-href")+"?text="+n,window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_linkedin:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"";return t=e.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&summary="+n+"&title="+n,window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_pinterest:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"",i=ThriveComments.post.featured_image?ThriveComments.post.featured_image:"";return t=e.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&description="+n+"&media="+i,window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_google:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"";return t=e.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&text="+n,window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_xing:function(e){var t,n=ThriveComments.post?ThriveComments.post.post_title:"";return t=e.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&title="+n,window.open(t,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1}}),ThriveComments.views.LiveUpdate=Backbone.View.extend({template:"",events:"",initialize:function(e){this.commentsView=e.commentsView,this.viewCreate=e.viewCreate,this.collection=e.collection,this.updateInterval=1e3*parseInt(ThriveComments.settings.tcm_live_update_refresh_rate),this.updateComments()},updateComments:function(){var e=this;!ThriveComments.settings.tcm_live_update||tve_frontend_options&&tve_frontend_options.is_editor_page||setTimeout((function(){e.startTimeout(jQuery(".tcm-comments-list")),e.updateComments()}),this.updateInterval)},startTimeout:function(t){var n=this;e.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},cache:!1,url:ThriveComments.routes.live_update,dataType:"JSON",type:"GET",data:{post_id:ThriveComments.post.ID,update_interval:this.updateInterval}}).done((function(e){e.comment_found?(_.each(e.comments,(function(e){var i=null,o=null,s=null;t&&(o=t.find("button[data-id="+e.top_parent_id+"]"),i=t.find("button[data-id="+e.comment_parent+"]"),s=new ThriveComments.models.Comment(e,{parse:!0}),0==e.comment_parent||i.length&&o.length?n.viewCreate.addNewCommentToList(i,s,1):ThriveComments.util.search_comment(n.collection,e.comment_ID)||ThriveComments.objects.Comments.push(s))})),n.updateInterval=1e3*parseInt(ThriveComments.settings.tcm_live_update_refresh_rate)):n.updateInterval=n.updateInterval+100}))}}),window.ThriveComments=window.ThriveComments||{},ThriveComments.objects=ThriveComments.objects||{},Backbone.emulateHTTP=!0,function(e){ThriveComments.objects.TCRouter=Backbone.Router.extend({view:null,routes:{"":"comments",comments:"comments","comments/:id":"comments","comments-:id":"comments","*n":"comments"},params:{},initialize:function(t){e.extend(!0,this,t),window.TVE_Dash&&!TVE_Dash.ajax_sent&&TVE_Dash.add_load_item("tcm_dash_data",ThriveComments.const.ajax_dash,this.dashResponse),this.facebook_init()},dashResponse:function(e){ThriveComments.secret_spam=e.secret,ThriveComments.has_plugin_cache&&(ThriveComments.nonce=e.nonce,Backbone.history.start({hashchange:!0}),Backbone.history.fragment||ThriveComments.router.navigate("",{trigger:!0}))},route:function(e,t,n){var i=this;return n||(n=this[t]),Backbone.Router.prototype.route.call(this,e,t,(function(){n.apply(i,arguments)}))},comments:function(t){var n,i,o;t=e.isNumeric(t)?t:null,ThriveComments.objects.Comments||(ThriveComments.objects.Comments=new ThriveComments.collections.Comments),i=this.get_me_a_view("LazyLoad",{collection:ThriveComments.objects.Comments,el:this.$el.find(".tcm-lazy-comments"),type:ThriveComments.settings.is_dynamic?"dynamic":"static"}),o=this.get_me_a_view("Comments",{collection:ThriveComments.objects.Comments,el:this.$el.find(".tcm-comments-list"),viewLazy:i}),i.viewList=o,this.get_me_a_view("SortComments",{el:this.$el.find(".tcm-comments-filter"),viewList:o}),o.close(),o.startLazy(t),(n=this.get_me_a_view("CreateComment",{el:this.$el.find(".tcm-comments-create"),viewList:o})).render({mainInput:1,id:0,level:0,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"top",close_comments:ThriveComments.close_comments}),this.get_me_a_view("LiveUpdate",{commentsView:o,id:t,viewCreate:n,collection:ThriveComments.objects.Comments})},get_me_a_view:function(e,t){var n="view"+e;return this[n]||(this[n]=new ThriveComments.views[e](t)),this[n]},facebook_init:function(){var e,t,n,i,o;"undefined"==typeof FB&&1===ThriveComments.settings.tcm_api_status.facebook&&1===ThriveComments.settings.tcm_api_status.facebook_api&&ThriveComments.settings.tcm_enable_social_signin&&(window.fbAsyncInit=function(){FB.init({appId:ThriveComments.tcm_social_apis.facebook.app_id,autoLogAppEvents:!0,status:!0,xfbml:!0,version:"v2.9"})},t="script",n="facebook-jssdk",o=(e=document).getElementsByTagName(t)[0],e.getElementById(n)||((i=e.createElement(t)).id=n,i.src="//connect.facebook.net/en_US/sdk.js",o.parentNode.insertBefore(i,o)))}}),e((function(){0!==e("#thrive-comments").length&&(ThriveComments.router=new ThriveComments.objects.TCRouter({$el:e("#thrive-comments")}),ThriveComments.has_plugin_cache||(Backbone.history.start({hashchange:!0}),Backbone.history.fragment||ThriveComments.router.navigate("",{trigger:!0})))}))}(jQuery)})();