(function(){'use strict';document.documentElement.dataset.loginEnhancements='ready';
const password=document.getElementById('loginPassword'),toggle=document.getElementById('passwordToggle');
toggle?.addEventListener('click',()=>{const reveal=password.type==='password';password.type=reveal?'text':'password';toggle.setAttribute('aria-pressed',String(reveal));toggle.setAttribute('aria-label',reveal?'Hide password':'Show password');toggle.querySelector('i')?.classList.toggle('bi-eye',!reveal);toggle.querySelector('i')?.classList.toggle('bi-eye-slash',reveal);password.focus()});
const capsNotice=document.getElementById('capsLockNotice');function updateCaps(event){if(capsNotice)capsNotice.hidden=!event.getModifierState?.('CapsLock')}password?.addEventListener('keydown',updateCaps);password?.addEventListener('keyup',updateCaps);password?.addEventListener('blur',()=>{if(capsNotice)capsNotice.hidden=true});
const requestModal=document.getElementById('temporaryAccessModal'),useCase=document.getElementById('requestUseCase'),counter=document.getElementById('useCaseCount');
function updateCount(){if(counter&&useCase)counter.textContent=useCase.value.length+' / 1500'}
useCase?.addEventListener('input',updateCount);updateCount();
if(document.body.dataset.openRequest==='1'&&requestModal){bootstrap.Modal.getOrCreateInstance(requestModal).show()}
document.querySelectorAll('form').forEach(form=>form.addEventListener('invalid',event=>event.target.classList.add('is-invalid'),true));document.querySelectorAll('form input,form textarea').forEach(field=>field.addEventListener('input',()=>{if(field.validity.valid)field.classList.remove('is-invalid')}));
document.getElementById('temporaryAccessForm')?.addEventListener('submit',function(){const button=this.querySelector('button[type="submit"]');if(!this.checkValidity())return;if(button){button.disabled=true;button.setAttribute('aria-busy','true');button.querySelector('span').textContent='Sending…';button.querySelector('i').className='spinner-border spinner-border-sm'}});
document.getElementById('signInForm')?.addEventListener('submit',function(){const button=this.querySelector('button[type="submit"]');if(!this.checkValidity())return;if(button){button.disabled=true;button.setAttribute('aria-busy','true');button.querySelector('span').textContent='Signing in…';button.querySelector('i').className='spinner-border spinner-border-sm'}});
})();
