(function(){
'use strict';
if(window.fiPasswordVisibility){return;}window.fiPasswordVisibility=true;
var script=document.currentScript;
var showLabel=script.getAttribute('data-password-show');
var hideLabel=script.getAttribute('data-password-hide');
var eye='';
var closed='';
function enhance(input){
if(input.closest('.fi-password-field')||input.hasAttribute('data-no-password-toggle'))return;
var holder=document.createElement('span');holder.className='fi-password-field';
input.parentNode.insertBefore(holder,input);holder.appendChild(input);
var button=document.createElement('button');button.type='button';button.className='fi-password-toggle';
function state(visible){input.type=visible?'text':'password';button.setAttribute('aria-label',visible?hideLabel:showLabel);button.setAttribute('title',visible?hideLabel:showLabel);button.setAttribute('aria-pressed',String(visible));button.innerHTML=visible?closed:eye;}
state(false);if(input.id)button.setAttribute('aria-controls',input.id);
button.addEventListener('mousedown',function(e){e.preventDefault();});
button.addEventListener('click',function(e){e.preventDefault();e.stopPropagation();state(input.type==='password');});
holder.appendChild(button);
if(input.form)input.form.addEventListener('reset',function(){state(false);});
}
function scan(root){if(root.nodeType!==1)return;if(root.matches('input[type="password"]'))enhance(root);root.querySelectorAll('input[type="password"]').forEach(enhance);}
function start(){scan(document.body);new MutationObserver(function(changes){changes.forEach(function(change){change.addedNodes.forEach(scan);});}).observe(document.body,{childList:true,subtree:true});}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start);else start();
})();