/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache("error_adding_infraction error_adding_warning error_reversing_infraction give_infraction_ginfraction infraction_added infraction_reversed please_check_the_box_to_reverse_infraction please_specify_reason_to_reverse_infraction received_infraction received_warning warning_added".split(" "),[]);vBulletin.ensureObj("infraction");vBulletin.ensureObj("privateMessage");
(function(a,d){function F(c){const b=getSelectedMessages();0<b.length&&"0"!=pageData.userid&&d.AJAX({call:"/ajax/api/node/"+(c?"markReadMultiple":"markUnreadMultiple"),data:{nodeids:b},success(h){for(const t in b)a("[data-node-id={0}]".format(b[t]),".infractions-list").toggleClass("read",c).find(".privateMessageActionCheck").prop("checked",!1)}})}function z(c,b,h,t){if(!c&&(c=a("#private-message-toolbar .infractions-paginator .infractionsPageTo"),0==c.length))return!1;updateCounter=h||0;t=t||!1;var m=
c.closest(".infractions-paginator"),q=a("#privateMessageContainer .main-pane .pending-posts-container"),l=m.find("#maxPageNum").filter(":input[type=hidden]").val();c=parseInt(m.find(":input[type=hidden][name=pagenum]").val(),10);var f=parseInt(m.find(":input[type=hidden][name=per-page]").val(),10);b=parseInt(b,10);if(isNaN(b)||isNaN(l)||isNaN(c))return!1;if(1>b||b>l)return d.error("error","please_enter_a_valid_page_number"),!1;if(b==c&&!h)return!1;var u={};a("#infractionFilters input:checked").each(function(){u[this.name]=
this.value});u.time&&(u.time={from:u.time});var y={setCurrentPage:b,setPerPage:f,getPagingInfo:h,options:u,isAjaxTemplateRenderWithData:!0};d.AJAX({call:"/ajax/render/privatemessage_infraction_main",data:y,success:function(r){q.html(r.template);var x=r=0;b<l?(x=b+1,1<b&&(r=b-1)):r=b-1;m.find(":input[type=hidden][name=pagenum]").val(b);m.find(":input[type=hidden][name=next-page]").val(x);m.find(":input[type=hidden][name=prev-page]").val(r);m.find(".infractionsNext").toggleClass("h-disabled",!x);m.find(".infractionsPrev").toggleClass("h-disabled",
!r);m.find(".infractionsPageTo").val(b);h&&(r=a("#privateMessageContainer .main-pane .pending-posts-container .pending-posts-pageinfo"),r=parseInt(r.find(".totalpages").val(),10),m.find("#maxPageNum").filter(":input[type=hidden]").val(r),l=r,m.find(".infractionsPageCount").text(r));D&&d.privateMessage.updatePaginationLinks(G,b,l);D&&!t&&d.privateMessage.pmFilterHistory.isEnabled()&&(y.maxPage=l,r=d.privateMessage.getPrivateMessageUrl(b),d.privateMessage.pmFilterHistory.pushState({infractionFilterParams:y},
document.title,r.url))}})}var p=a("#infractions-tab"),D=d.privateMessage&&d.privateMessage.jsReady||!1,G=a("#privateMessageContainer");d.infraction.infractUser=function(c,b){var h=a(this);if(h.data("ajaxstarted"))return!1;var t=h.hasClass("js-infraction-received");if(t){c="received_infraction_form";var m="received_infraction";var q="receive-infraction-dialog"}else c="give_infraction_form",m="give_infraction_ginfraction",q="give-infraction-dialog";h.data("ajaxstarted",!0);d.AJAX({call:"/ajax/render/"+
c,data:{userid:h.data("userid"),nodeid:h.closest(".js-post-controls").data("node-id")||h.data("nodeid"),userInfraction:h.data("userinfraction"),isAjaxTemplateRenderWithData:!0},complete:function(){h.data("ajaxstarted",null)},success:function(l){a("."+q).length?a("."+q).replaceWith(l.template):a(l.template).appendTo(document.body).hide();l=a("."+q);l.dialog({title:d.phrase.get(m),autoOpen:!0,modal:!0,resizable:!1,closeOnEscape:!1,showCloseButton:!1,width:l.hasClass("error-infraction-dialog")?500:t?
600:700,dialogClass:"dialog-container infraction-dialog-container dialog-box",close:function(){var f=a(".js-editor",this);f.length&&d.ckeditor.editorExists(f)&&d.ckeditor.destroyEditor(f);a(this).dialog("destroy").remove()},open:function(){var f=this;if(t)d.ajaxForm.apply(a(".infraction-reverse-form",f),[{error_phrase:"error_reversing_infraction",success:function(e,g,k,n){d.alert("reverse_this_infraction","infraction_reversed");"function"==typeof b&&b.apply(h.get(0),[e]);a(f).dialog("close")},beforeSubmit:function(e,
g,k){if(a(".infraction-nodeid",g).is(":checked"))a.trim(a(".infraction-reason",g).val())||(n="please_specify_reason_to_reverse_infraction",v=a(".infraction-reason",g));else{var n="please_check_the_box_to_reverse_infraction";var v=a(".infraction-nodeid",g)}return n?(d.warning("reverse_this_infraction",n,function(){v.trigger("focus")}),!1):!0}}]),a(".reverse-infraction",f).on("click",function(){a(".infraction-reverse-form",f).submit()});else{var u=a(".infraction-send-pm",f);d.ajaxForm.apply(a(f),[{dataType:"json",
error_phrase:"error_adding_infraction",success:function(e,g,k,n){g=e.infractionNodeid&&!e.infractionNodeid.errors;n="warning";g?(k=e.isWarning?"warning_added":"infraction_added",n=""):k=e.isWarning?"error_adding_warning":"error_adding_infraction";d.alert("give_infraction_ginfraction",k,n);g&&("function"==typeof b&&b.apply(h.get(0),[e]),a(f).dialog("close"))},beforeSubmit:function(e,g,k){if("0"==a(".infraction-level-control option:selected",g).val()){e=function(J,K){x(a(".infraction-level",f));d.warning("give_infraction_ginfraction",
J,function(){K.trigger("focus")})};if(""==a.trim(a(".custom-reason",g).val()))return e("please_specify_custom_reason",a(".custom-reason",g)),!1;k=Number(a(".custom-points",g).val());if(isNaN(k)||0>k)return e("please_specify_custom_points",a(".custom-points",g)),!1;k=a(".custom-period option:selected",g).val();var n=Number(a(".custom-expires",g).val());if("N"!=k&&(isNaN(n)||0>=n))return e("please_specify_custom_expires",a(".custom-expires",g)),!1}e=a(".infraction-ban-reason .ban-reason",f);if(e.is(":visible")&&
!a.trim(e.val()))return x(a(".infraction-ban",f)),a(".ban-reason-desc",f).removeClass("h-hide"),e.trigger("focus"),a(".dialog-content",f).scrollTop(0).scrollTop(a(".infraction-ban-reason",f).position().top),!1;if(Number(u.data("required"))){var v=a(".js-editor",g),A=d.ckeditor.getEditor(v);g=A?A.getData():A.val();if(!a.trim(g))return d.warning("give_infraction_ginfraction","please_specify_infraction_pm",function(){x(u);A?A.focus():v.trigger("focus")}),!1}}}]);var y=function(e){r.toggleClass("h-hide",
!e).find("input, select").prop("disabled",!1).end().find(".selectBox").toggleClass("selectBox-disabled",!e)};a(".infraction-level-control",f).on("change",function(e,g,k){e=a(this.options[this.selectedIndex]);k&&1==k.length||(k=a(this).closest(".infraction-level").find(".infraction-warning-control input"));g||(e.data("allow-warning")?(k.prop("disabled",!1).val(this.value).parent().removeClass("h-hide"),y(!1)):(k.prop("disabled",!0).parent().addClass("h-hide"),"0"==this.value&&(y(!0),a(".textbox",r).first().trigger("focus"))));
var n=g=0;k.prop("checked")||"0"==this.value?"0"==this.value&&(g=Number(a(".custom-infraction-info .custom-points",f).val())||0)&&(n=1):(g=Number(e.data("points"))||0,n=1);k=a(".infraction-dashboard-stats").data();k=g&&L(Number(k.points)+g,Number(k.infractions)+n);H(k);B()});a(".infraction-warning-control input",f).on("click",function(){this.checked?H(!1):a(".infraction-level-control",f).trigger("change",[!0,this])});a(".custom-points",f).on("change",function(){a(".infraction-level-control",f).trigger("change",
[!0])});var r=a(".custom-infraction-info",f).removeClass("h-hide");a("select",f).selectBox();r.addClass("h-hide");a(".js-content-entry-panel, .js-editor",u).data("callback",function(){B()});d.ckeditor.initEditorComponents(u,!0);a(".toggle-button",f).on("click",function(e){e=a(this);var g=e.closest(".blockrow-head"),k=g.next(".blockrow-body"),n=e.hasClass("expand");k.toggle(n);g.toggleClass("collapsed",!n);B();e.toggleClass("collapse expand");g=e.attr("title");e.attr("title",e.data("toggle-title")).data("toggle-title",
g);return!1});var x=function(e){a(".toggle-button.expand",e).trigger("click")},L=function(e,g){if(0==e&&0==g)return!1;var k=!1;a(".infraction-ban-list tbody tr",f).each(function(n,v){if(v=a(this).data())if(n=Number(v.points),v=Number(v.infractions),n&&e>=n||v&&g>=v)return k=!0,!1});return k},H=function(e){var g=a(".infraction-ban-reason",f);e?(g.removeClass("h-hide"),x(a(".infraction-ban",f))):g.addClass("h-hide")},C=a(".dialog-content",f),B=function(){C[0]||(C[0]=f);var e=C[0].scrollHeight>parseFloat(C.css("max-height"));
C.toggleClass("has-scrollbar",e)};B();a(".infraction-level-control",f).trigger("change")}a(".close-infraction",f).on("click",function(){a(f).dialog("close")});a(".ckeditor-bare-box.ckeditor-load-on-focus",f).on("focus",function(){d.ckeditor.initEditor(this.id,{complete:function(e){B()},error:function(e){a("#"+e).prop("disabled",!1).removeClass("ckeditor-load-on-focus")}})})}})}})};d.infraction.loadUserInfractions=function(c){a.post(d.getAjaxBaseurl()+"/ajax/render/user_infractions",{userid:c.userid,
pagenum:c.pageNumber},function(b,h,t){c.container.html(b);a(".pagenav-form",p).length&&new d.pagination({context:p,tabParamAsQueryString:!1,allowHistory:1==p.find(".conversation-toolbar-wrapper").data("allow-history"),onPageChanged:function(m,q){d.infraction.loadUserInfractions({container:p,userid:p.data("userid"),pageNumber:m,replaceState:!0})}});"function"==typeof c.callback&&c.callback(b);if(c.pushState||c.replaceState)b=d.makePaginatedUrl(location.href,c.pageNumber),w||(E="1"==p.find(".conversation-toolbar-wrapper").data("allow-history"),
w=new d.history.instance(E)),w.isEnabled()&&(h={from:"infraction_filter",page:c.pageNumber,tab:p.data("url-path")?p.data("url-path"):"#"+p.attr("id")},w[c.pushState?"pushState":"setDefaultState"](h,document.title,b))},"json")};var w,E;d.infraction.setHistoryStateChange=function(){w||(E="1"==p.find(".conversation-toolbar-wrapper").data("allow-history"),w=new d.history.instance(E));w.isEnabled()&&w.setStateChange(function(c){var b=w.getState();if("infraction_filter"==b.data.from){w.log(b.data,b.title,
b.url);c=p.closest(".ui-tabs");var h=c.find(".ui-tabs-nav > li").filter('li:has(a[href*="#{0}"])'.format(p.attr("id")));h.hasClass("ui-tabs-active")?d.infraction.loadUserInfractions({container:p,userid:p.data("userid"),pageNumber:b.data.page,pushState:!1}):(b=h.index(),d.selectTabByIndex.call(c,b))}},"infraction_filter")};a(document).off("click",".js-post-control__infraction").on("click",".js-post-control__infraction",function(c){d.infraction.infractUser.apply(this,[c,function(b){let h=a(this),t=
h.find(".b-post-control__icon"),m=h.hasClass("js-infraction-received"),q;t.removeClass("infraction--neutral infraction--warned infraction--infracted");m?(b="give_infraction_ginfraction",q="infraction--neutral"):b.isWarning?(b="received_warning",q="infraction--warned"):(b="received_infraction",q="infraction--infracted");h.toggleClass("js-infraction-received",!m);h.attr("title",d.phrase.get(b));t.addClass(q)}])});p.off("click",".infractionCtrl").on("click",".infractionCtrl",function(c){d.infraction.infractUser.apply(this,
[c,function(b){d.infraction.loadUserInfractions({container:p,userid:a(this).data("userid"),pageNumber:1,pushState:1!=Number(a('.pagenav-form input[name="page"]',p).val())})}])});p.on("click",".view-infraction",function(c){d.infraction.infractUser.apply(this,[c,function(b){b=Number(a('.pagenav-form input[name="page"]',p).val())||1;d.infraction.loadUserInfractions({container:p,userid:a(this).data("userid"),pageNumber:b,pushState:1!=b})}])});a(document).off("click","#privateMessageContainer .js-button-group .view-infraction").on("click",
"#privateMessageContainer .js-button-group .view-infraction",function(c){d.infraction.infractUser.apply(this,[c,function(b){}])});a(".infraction-delete").off("click").on("click",function(c){$button=a(this);var b=!1;if($button.parents("#pmFloatingBarContent").hasClass("infractions-paginator"))var h=getSelectedMessages();else h=[a("#privateMessageContainer .js-conversation-starter").data("nodeId")],b=!0;0<h.length&&openConfirmDialog({title:d.phrase.get("messages_header"),message:d.phrase.get("are_you_sure_delete_infractions"),
iconType:"warning",onClickYes:function(){d.AJAX({url:d.getAjaxBaseurl()+"/ajax/api/node/deleteNodes",data:{nodeids:h,hard:0},success:function(t){b?location.href=a("#pmBtnBackToInfractions").prop("href"):location.reload()}})}})});a(".infraction-mark_as_read").offon("click",function(c){F(!0)});a(".infraction-mark_as_unread").offon("click",function(c){F(!1)});a(document).ready(function(){if(0<a("#pmBtnBackToInfractions").length){const c=a("#privateMessageContainer .conversation-list .b-post--infraction").data("nodeId");
d.markTopicAsRead(c)}});a("#infractionFilters").trigger("reset").find(".filter-options input").off("click").on("click",function(c){M.apply(this)});a(document).off("click","#privatemessagePaging .infractionsPrev").on("click","#privatemessagePaging .infractionsPrev",function(c){c.preventDefault();c=a(this).closest("#privatemessagePaging").find(':input[type=hidden][name="prev-page"]').val();z(a(this),c)});a(document).off("click","#privatemessagePaging .infractionsNext").on("click","#privatemessagePaging .infractionsNext",
function(c){c.preventDefault();c=a(this).closest("#privatemessagePaging").find(':input[type=hidden][name="next-page"]').val();z(a(this),c)});var I=function(c){var b=a("#privatemessagePaging"),h=b.find("input[name='pagenum']");c=h.val();var t=b.find("#maxPageNum");b=t.val();var m=a("#infractionFilters"),q={};d.privateMessage.updatePaginationLinks(G,c,b);d.privateMessage.getPageFiltersForUrl=function(l){m.find("input:checked").each(function(){l["filter_"+this.name]=this.value});return l};a("#infractionsFilter").length&&
a("#infractionFilters input:checked").each(function(){queryParams["filter_"+this.name]=this.value});d.privateMessage.pmFilterHistory.isEnabled()&&(q={infractionFilterParams:{setCurrentPage:c,options:{},maxPage:b}},m.find("input:checked").each(function(){q.infractionFilterParams.options[this.name]=this.value}),q.infractionFilterParams.options.time&&(q.infractionFilterParams.options.time={from:q.infractionFilterParams.options.time}),d.privateMessage.pmFilterHistory.setDefaultState(q,document.title,
window.location.href),d.privateMessage.pmFilterHistory.setStateChange(function(l){l=d.privateMessage.pmFilterHistory.getState();l.data.hasOwnProperty("infractionFilterParams")&&(l=l.data.infractionFilterParams,a.each(l.options,function(f,u){f="input[name='{0}'][value='{1}']".format(f,u);m.find(f).prop("checked",!0)}),t.val(l.maxPage),h.val(l.setCurrentPage),z(null,l.setCurrentPage,!0,!0))},"privatemessage"));D=!0};if(D)I();else a(document).one("vb-privatemessage-js-ready",I);a(document).off("keypress",
"#privatemessagePaging .infractionsPageTo").on("keypress","#privatemessagePaging .infractionsPageTo",function(c){if(13==c.keyCode){c.preventDefault();c=a(this);var b=parseInt(c.val(),10);if(isNaN(b))return d.error("error","please_enter_a_valid_page_number"),!1;z(c,b)}});var M=function(c){$paginateButton=a("#private-message-toolbar .infractions-paginator .infractionsPageTo");if($paginateButton.length)z($paginateButton,1,!0);else{var b={};a(this).closest(".filter-options-list").find("input:checked").each(function(){b[this.name]=
a(this).val()});b.time&&(b.time={from:b.time});a(this).prop("checked",!0);b.page=1;b.perpage=pmPerPage;d.AJAX({call:"/ajax/render/privatemessage_infraction_main",data:{options:b,isAjaxTemplateRenderWithData:!0},success:function(h){a("#privateMessageContainer .pending-posts-container").html(h.template);pmPageNum=1}})}}})(jQuery,vBulletin);
