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