ips.templates.set('moderatorPermissions.checkUncheckAll',"	<li class='ipsFieldRow'>		<div class='ipsFieldRow__label'>		</div>		<div class='ipsFieldRow__content'>			<ul class='ipsList ipsList--inline i-font-weight_500'>				<li><button type='button' data-role='checkAll'>{{#lang}}check_all{{/lang}}</button></li>				<li><button type='button' data-role='uncheckAll'>{{#lang}}uncheck_all{{/lang}}</button></li>			</ul>		</div>	</li>");;
;(function($){"use strict";ips.controller.register('core.admin.members.listFlagSpammer',{initialize:function(){this.on('click',this.toggleFlagSpammer);},toggleFlagSpammer:function(e){e.preventDefault();var elem=$(e.currentTarget);var icon=elem.find('.fa-flag');var textLabel=elem.find('span');ips.ui.alert.show({'type':'confirm','icon':'warn','message':icon.hasClass('i-color_warning')?ips.getString('confirmUnFlagAsSpammer'):ips.getString('confirmFlagAsSpammer'),'subText':icon.hasClass('i-color_warning')?ips.getString('confirmUnFlagAsSpammerDesc'):'',callbacks:{ok:function(){ips.getAjax()(elem.attr('href'),{dataType:'json'}).done(function(response){ips.ui.flashMsg.show(response);icon.toggleClass('i-color_warning');var newStatus=ips.utils.url.getParam('status',elem.attr('href'))==1?0:1;var newUrl=ips.utils.url.removeParam('status',elem.attr('href'));elem.attr('href',newUrl+'&status='+newStatus);elem.attr('_title',newStatus?ips.getString('flagAsSpammer'):ips.getString('unflagAsSpammer'));elem.attr('aria-label',newStatus?ips.getString('flagAsSpammer'):ips.getString('unflagAsSpammer'));textLabel.text(newStatus?ips.getString('flagAsSpammer'):ips.getString('unflagAsSpammer'));}).fail(function(jqXHR){if(Debug.isEnabled()){Debug.error(jqXHR.responseText);}else{window.location=elem.attr('href');}});}}});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.restrictions',{initialize:function(){this.on('click','.acpRestrictions_subHeader h3',this.toggleSubHeader);this.on('change','.acpRestrictions_header input[type="checkbox"]',this.toggleHeader);this.on('change','.acpAppRestrictions_header input[type="checkbox"]',this.toggleAppHeader);this.on('click','[data-action="checkAll"]',this.checkAll);this.on('click','[data-action="checkNone"]',this.checkNone);this.on('click','[data-action="expandAll"], [data-action="collapseAll"]',this.toggleDisplay);this.setup();},toggleDisplay:function(e){e.preventDefault();var row=$(e.currentTarget).closest('.acpRestrictions_header');var subHeaders=row.next().find('.acpRestrictions_subHeader');var self=this;var action=($(e.currentTarget).attr('data-action')=='expandAll')?'expand':'collapse';subHeaders.each(function(){if(action=='expand'){self._expandSection($(this));}else{self._collapseSection($(this));}});},toggleAppHeader:function(e){var check=$(e.currentTarget);var row=check.closest('.acpAppRestrictions_header');if(!check.is(':checked')){row.siblings('.acpAppRestrictions_panel').find('.acpRestrictions_header input[type="checkbox"]').each(function(){$(this).prop('disabled',true).attr('data-originalState',$(this).is(':checked')).prop('checked',false).trigger('change');});}else{row.siblings('.acpAppRestrictions_panel').find('input[type="checkbox"]').each(function(){var thisCheck=$(this);thisCheck.prop('disabled',false);if(thisCheck.attr('data-originalState')=='true'){thisCheck.prop('checked',true).trigger('change');}});row.siblings('.acpAppRestrictions_panel').find('.acpRestrictions_panel input[type="checkbox"]').each(function(){var thisCheck=$(this);var checked=thisCheck.closest('.acpRestrictions_panel').siblings('.acpRestrictions_header').find('input[type="checkbox"]').is(':checked');if(!checked){thisCheck.prop('disabled',true);}else{thisCheck.prop('disabled',false);}
if(thisCheck.attr('data-originalState')=='true'){thisCheck.prop('checked',true).trigger('change');}});}},toggleHeader:function(e){var check=$(e.currentTarget);var row=check.closest('.acpRestrictions_header');var unChecked=!check.is(':checked');row.next().find('input[type="checkbox"]').each(function(){var thisCheck=$(this);if(unChecked){thisCheck.attr('data-originalState',thisCheck.is(':checked')).prop('checked',false);}else if((thisCheck.attr('data-originalState')=='true')){thisCheck.prop('checked',true);}
thisCheck.prop('disabled',unChecked).trigger('change');});},toggleSubHeader:function(e){var header=$(e.currentTarget).parent();if(header.hasClass('acpRestrictions_open')){this._collapseSection(header);}else{this._expandSection(header);}},_expandSection:function(section){var next=section.next('ul');section.addClass('acpRestrictions_open').removeClass('acpRestrictions_closed');ips.utils.anim.go('fadeInDown fast',next);},_collapseSection:function(section){section.removeClass('acpRestrictions_open').addClass('acpRestrictions_closed');},checkAll:function(e){e.preventDefault();var self=this;var header=$(e.currentTarget).parents('.acpRestrictions_subHeader');var next=header.next('ul');if(!next.is(':visible')){next.animationComplete(function(){self._togglePermissions(true,next);});this._expandSection(header);}else{this._togglePermissions(true,next);}},checkNone:function(e){e.preventDefault();var self=this;var header=$(e.currentTarget).parents('.acpRestrictions_subHeader');var next=header.next('ul');if(!next.is(':visible')){next.animationComplete(function(){self._togglePermissions(false,next);});this._expandSection(header);}else{this._togglePermissions(false,next);}},_togglePermissions:function(state,container){container.find('input[type="checkbox"]:not( [disabled] )').prop('checked',state).trigger('change');},setup:function(){this.scope.find('.acpRestrictions_open').removeClass('acpRestrictions_open').addClass('acpRestrictions_closed');}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.moderatorPermissions',{initialize:function(){this.on('change','#ipsTabs_form_modperms__core_Content_panel input[type="checkbox"]',this.toggle);this.on('click','[data-role="checkAll"]',this.checkAll);this.on('click','[data-role="uncheckAll"]',this.checkAll);this.setup();},setup:function(){var mainPanel=this.scope.find('#ipsTabs_form_modperms__core_Content_panel');var self=this;mainPanel.find('input[type="checkbox"]').each(function(){self._toggleChanged($(this));});$(this.scope).find('.ipsTabs__panel').each(function(){var controls=$(ips.templates.render('moderatorPermissions.checkUncheckAll'));controls.find('button').attr('data-scope',$(this).attr('id'));$(this).children('ul').prepend(controls);});this._checkEachTab();},checkAll:function(e){e.preventDefault();var check=$(e.currentTarget).attr('data-role')=='checkAll';if($(e.currentTarget).attr('data-scope')){var scope=$('#'+$(e.currentTarget).attr('data-scope'));}else{var scope=$(this.scope);}
if(check&&!$(e.currentTarget).attr('data-scope')){$('input[name="mod_use_restrictions"][value="no"]').prop('checked',true).trigger('change');}
var self=this;scope.find('input[type="checkbox"]').each(function(){if(check&&!$(this).is(':checked')){$(this).prop('checked',true).trigger('change');}else if(!check&&$(this).is(':checked')){$(this).prop('checked',false).trigger('change');}});},toggle:function(e){this._toggleChanged($(e.currentTarget));this._checkEachTab();},_toggleChanged:function(thisToggle){var id=thisToggle.closest('.ipsFieldRow').attr('id').replace('_content','');var panels=this.scope.find('.ipsTabs__panel:not( #ipsTabs_form_modperms__core_Content_panel )');var otherToggles=panels.find('.ipsFieldRow[id^="'+id+'"]').not(thisToggle.closest('.ipsFieldRow'));if(thisToggle.is(':checked')){otherToggles.hide();otherToggles.find('input[type="checkbox"]').prop('disabled',true);}else{otherToggles.show();otherToggles.find('input[type="checkbox"]').prop('disabled',false);}},_checkEachTab:function(){var self=this;var panels=this.scope.find('.ipsTabs__panel:not( #ipsTabs_form_modperms__core_Content_panel )');panels.each(function(){var count=$(this).find('input[type="checkbox"]:enabled:not( [data-role="zeroVal"] )').length;var id=$(this).attr('id').replace('ipsTabs_tabs_form_','').replace('_panel','');if(!count){self.scope.find('#'+id).closest('li').hide();}else{self.scope.find('#'+id).closest('li').show();}});}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.lazyLoadingProfileBlock',{initialize:function(){var scope=$(this.scope);ips.getAjax()(scope.attr('data-url')).done(function(response){const doc=(new DOMParser()).parseFromString(response,'text/html');scope.html(doc.body.innerHTML);let headInserts="";doc.head.querySelectorAll('script').forEach(script=>{if(!script.hasAttribute('src')||!document.querySelector(`script[src="${script.getAttribute('src')}"]`)){headInserts+=script.outerHTML+'\n';}});doc.head.querySelectorAll('link[href]').forEach(link=>{if(!document.querySelector(`link[href="${link.getAttribute('href')}"]`)){headInserts+=link.outerHTML+'\n';}});if(headInserts){document.head.insertAdjacentHTML('beforeend',headInserts);}
$(document).trigger('contentChange',[scope]);});},});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.history',{initialize:function(){this.on('menuItemSelected',this.filterSelected);},filterSelected:function(e,data=e.detail){if(data.originalEvent){data.originalEvent.preventDefault();}
if(data.triggerID=='memberHistoryFilters'){$(this.scope).find('[data-role="historyTitle"]').text($(data.menuElem).find('[data-ipsMenuValue="'+data.selectedItemID+'"]').text());$(this.scope).find('[data-role="historyDisplay"]').addClass('ipsLoading').html('');ips.getAjax()($(data.menuElem).find('[data-ipsMenuValue="'+data.selectedItemID+'"]').attr('href')).done(function(response){$(this.scope).find('[data-role="historyDisplay"]').html(response).removeClass('ipsLoading');$(document).trigger('contentChange',[this.scope]);}.bind(this));}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.form',{initialize:function(){this.on('submit',this.submitForm);},submitForm:function(e){if($(e.currentTarget).attr('data-bypassValidation')){return true;}
e.preventDefault();e.stopPropagation();var isInAdminGroup=false;var mainGroup=this.scope.find('select[name=group]').val();var secondaryGroups=(this.scope.find('select[name="secondary_groups[]"]').val()||[]).map(val=>parseInt(val));var adminGroups=JSON.parse(this.scope.attr('data-adminGroups'));if(adminGroups.length){for(var i=0;i<adminGroups.length;i++){var testId=adminGroups[i];if(secondaryGroups!=null&&secondaryGroups.length&&secondaryGroups.indexOf(testId)!==-1){isInAdminGroup=true;}
if(testId==mainGroup){isInAdminGroup=true;}
if($("input#elCheckbox_secondary_groups_"+testId+":checked").length){isInAdminGroup=true;}}}
if(isInAdminGroup){ips.ui.alert.show({type:'confirm',message:ips.getString('member_edit_is_admin'),icon:'fa-solid fa-triangle-exclamation',buttons:{ok:ips.getString('member_edit_ok'),cancel:ips.getString('member_edit_cancel')},callbacks:{ok:function(){$(e.currentTarget).attr('data-bypassValidation',true);$(e.currentTarget).trigger('submit');},cancel:function(){return false;}}});}else{$(e.currentTarget).attr('data-bypassValidation',true);$(e.currentTarget).trigger('submit');}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.allowedCharacters',{initialize:function(){this.on('click','[data-action="easy"]',this.showEasy);this.on('click','[data-action="regex"]',this.showRegex);this.setup();},showEasy:function(e){if(e){e.preventDefault();}
this.scope.find('[data-role="easy"]').show();this.scope.find('[data-role="regex"]').hide();this.scope.find('[data-role="easyInput"]').val('1');},showRegex:function(e){if(e){e.preventDefault();}
this.scope.find('[data-role="regex"]').show();this.scope.find('[data-role="easy"]').hide();this.scope.find('[data-role="easyInput"]').val('0');},setup:function(){this.scope.find('[data-action="easy"]').show();this.scope.find('[data-action="regex"]').show();if(this.scope.attr('data-easy')==1){this.showEasy();}}});}(jQuery));;
;(function($){"use strict";ips.controller.register('core.admin.members.achievementRuleForm',{initialize(){this.on('click','[data-action="filterReveal"]',this.showFilter);this.on('click','[data-action="filterCollapse"]',this.hideFilter);this.on('change keyup','input[type="number"]',this.changeNumber);},showFilter(e){const ruleWrap=e.currentTarget.closest('[data-role="ruleWrap"]');const toggleWrap=e.currentTarget.closest('[data-role="toggleFilter"]');const check=toggleWrap.querySelector('input[type="checkbox"]');const conditionButtons=toggleWrap.closest('[data-role="conditionButtons"]');check.checked=true;check.dispatchEvent(new Event('change',{bubbles:true}));toggleWrap.ipsHide();if(conditionButtons?.querySelector('[data-role="toggleFilter"] input[data-filter]:not(:checked)')){conditionButtons?.ipsShow();}else{conditionButtons?.ipsHide();}
const filterName=check.dataset.filter;if(filterName){ruleWrap.querySelectorAll(`#${filterName}`).ipsShow();}
ruleWrap.querySelectorAll('input[type="number"]').forEach(el=>this._pluralizeNumber(el));},hideFilter(e){e.preventDefault();const filter=e.currentTarget.closest('[data-role="filterField"]');const filterName=filter.id;const check=filter.closest('[data-role="ruleWrap"]').querySelector(`#${filterName}Checkbox`);const toggleWrap=check.closest('[data-role="toggleFilter"]');check.checked=false;check.dispatchEvent(new Event('change',{bubbles:true}));toggleWrap.ipsShow()
toggleWrap.closest('[data-role="conditionButtons"]')?.ipsShow();filter.ipsHide();},changeNumber(e){this._pluralizeNumber(e.currentTarget);},_pluralizeNumber(input){const span=input.nextElementSibling;if(span?.matches('[data-role="th"]')){span.innerText=ips.pluralize(ips.getString('numberSuffix'),input.value);}}});}(jQuery));;