(function(){ var $=function(id){return document.getElementById(id)}; var q=new URLSearchParams(location.search);var u=q.get('u');var r=q.get('r'); if(!u||!/^bitcoin:/i.test(u))return; var body=u.slice(8);var addr=body.split('?')[0];var params=new URLSearchParams(body.split('?')[1]||''); var btc=parseFloat(params.get('amount')||'');var label=params.get('label'); $('p-none').hidden=true;$('p-req').hidden=false; $('p-for').textContent=(label?label+' · ':'')+'To '+addr.slice(0,10)+'…'+addr.slice(-6); $('p-open').href=u; $('p-usd').textContent=btc?'Loading amount…':'Any amount'; if(btc){$('p-btc').textContent=btc.toFixed(8)+' BTC'; fetch('/api/rate/price').then(function(x){return x.json()}).then(function(j){if(j.usd)$('p-usd').textContent='$'+(btc*j.usd).toLocaleString('en-US',{minimumFractionDigits:2,maximumFractionDigits:2});else $('p-usd').textContent=btc.toFixed(8)+' BTC';}).catch(function(){$('p-usd').textContent=btc.toFixed(8)+' BTC';});} $('p-copy').addEventListener('click',function(){try{navigator.clipboard.writeText(addr);this.textContent='Copied';}catch(e){}}); if(r&&/^https:\/\/paywell\.ai\//.test(r)){$('p-rate').hidden=false;$('p-rate-a').href=r;} })();