;(function($,_,undefined){"use strict";ips.controller.register('ccauth0.emailVerify.modal',{initialize:function(){this.on('click','[data-ccemailverify]',this.emailVerifyModal);this.on('click','a[href*="cruisecritic"][href*="/settings/password/"]',this.password);this.on('click','a[href*="#replyForm"]',(e=>{if(ips.getSetting('memberID')){this.emailVerifyModal(e);}else{this.registerModal(e);}}).bind(this));if(!_.isUndefined($('#setting_password'))){$('#setting_password').closest('li').remove();}
this.setup();},setup:function(){const queryParams=Object.fromEntries(window.location.search.replace(/^\?/,'').split('&').map(elem=>elem.split('=')));if(('modal'in queryParams)&&queryParams.modal in this.buttonsMap){this.launchModal(queryParams.modal);}},password:function(e){return this.launchModal('password',e);},emailVerifyModal:function(e){return this.launchModal('verify',e);},registerModal:function(e){if(ips.getSetting('memberID'))
return;return this.launchModal('login',e);},loginModal:function(e){return this.launchModal('login',e);},buttonsMap:{login:{yes:ips.getString('modal_goto_login'),cancel:ips.getString('cancel')},verify:{yes:ips.getString('modal_send_verification'),cancel:ips.getString('cancel')},verify_complete:{ok:ips.getString('modal_verify_complete_button')},password:{yes:ips.getString('modal_goto_reset_password'),cancel:ips.getString('cancel')},change_password_complete:{ok:ips.getString('modal_change_password_complete_button')}},alertTypeMap:{login:'verify',password:'verify',verify:'verify'},callbacksMap:{login:{yes:()=>{let redirectURL=new URL(ipsSettings.loginLink);if(redirectURL.origin!==window.location.origin)
return;window.location.assign(ipsSettings.loginLink);}},password:{yes:()=>{if(!ipsSettings.ccPasswordResetLink){Debug.log('Cannot redirect the user to the password reset since the password reset link is unknown');return;}
let redirectURL=new URL(ipsSettings.ccPasswordResetLink);if(redirectURL.origin!==window.location.origin)
return;window.location.href=redirectURL.toString();}},verify:{yes:()=>{ips.getAjax()(ipsSettings.baseURL+"?app=ccauth0&module=ajax&controller=resendVerification",{showLoading:false}).then(Debug.log,Debug.warn);}}},launchModal:function(type,event={}){if(type==='login'&&ipsSettings.memberID){return;}
if(type==='login'&&$(event.target)&&($(event.target).attr('id')==='elSigninButton_mobile'||$(event.target).attr('id')==='elRegisterButton_mobile')){this.callbacksMap.login.ok();return;}
if(!(type in this.buttonsMap)){Debug.log(`Cannot show modal of type '${type}' since it is not recognized`);return;}
if(!ipsSettings.memberIsValidating&&type==='verify'){return;}
event.preventDefault?event.preventDefault():null;event.stopPropagation?event.stopPropagation():null;let options={type:this.alertTypeMap[type]||"alert",message:ips.getString(`modal_${type}_message`),buttons:this.buttonsMap[type],showIcon:0,callbacks:this.callbacksMap[type]||{}}
ips.ui.alert.show(options);Debug.log('launching a modal');}});}(jQuery,_));;;