!function(){"use strict";
// Copyright: 2016 Magnus Bellstrand, license MIT
var n,o,r,t,a,f,i;$(document).ready(function(){return window.requestIdleCallback?requestIdleCallback(function(){return t()}):setTimeout(t,500)}),t=function(){var e,t=Boolean(parseInt($("#usetotp").attr("value")));if(window.localStorage&&t){if(t=$("#totpsecret").attr("value"))try{localStorage.setItem("stayconnectedkey",t)}catch(t){e=t,console.error("Unable to register key in storage",e)}else t=localStorage.getItem("stayconnectedkey");if(t)try{return $("#fg").attr("value","TOTP_".concat(r(t))),void $("#form").submit()}catch(t){e=t,console.error("Unable to register key in storage",e)}}return(t=document.createElement("script")).src=window.staticPrefix+"bwr/fingerprintjs2/fingerprint2.js",t.async=!1,document.body.append(t),t.onload=i,setTimeout(i,1e3)},i=function(){return console.debug("Trying fingerprint"),window.Fingerprint2?Fingerprint2.get(function(t){t=t.map(function(t){return t.value}),t=Fingerprint2.x64hash128(t.join(""),31);return $("#fg").attr("value",t),$("#form").submit()}):(console.error("No way to register this device"),$("#form").submit())},r=function(t){var e,r;return t=n(t),r=f(o(Math.floor(Date.now()/3e4)),16,"0"),(e=new jsSHA("SHA-1","HEX")).setHMACKey(t,"HEX"),e.update(r),t=e.getHMAC("HEX"),r=a(t.substring(t.length-1)),(e=(a(t.substr(2*r,8))&a("7fffffff"))+"").substr(Math.max(e.length-6,0),6)},a=function(t){return parseInt(t,16)},o=function(t){return(t<15.5?"0":"")+Math.round(t).toString(16)},n=function(t){for(var e,r,n,o,a,i="",u="",s=r=0,c=(t=t.replace(/=+$/,"")).length-1;0<=c?r<=c:c<=r;s=0<=c?++r:--r){if(-1===(a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(t.charAt(s).toUpperCase())))throw new Error("Invalid base32 character in key");i+=f(a.toString(2),5,"0")}for(s=n=0,o=i.length-8;n<=o;s=n+=8)e=i.substr(s,8),u+=f(parseInt(e,2).toString(16),2,"0");return u},f=function(t,e,r){return t=e+1>=t.length?Array(e+1-t.length).join(r)+t:t}}();