!function(){"use strict";function e(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var r,t,n,o;o=function(e,r){return $("#msg").attr("trspan",e),$("#msg").html(window.translate(e)),$("#color").removeClass("message-positive message-warning alert-success alert-warning alert-danger"),$("#color").addClass("message-".concat(r)),"positive"===r&&(r="success"),$("#color").addClass("alert-".concat(r)),$("#color").attr("role","status")},t=function(e,r,t){var n;if(console.error("Error",t),(n=JSON.parse(e.responseText))&&n.error)return n=n.error.replace(/.* /,""),console.error("Returned error",n),n.match(/module/)?o("notAuthorized","warning"):"csrfToken"===n?(o(n,"danger"),setTimeout(function(){return window.location=window.location.href.split("?")[0]},2e3)):o(n,"warning")},r=function(r,n,a){return a||(a="UBK"===r?"yubikey":"TOTP"===r?"totp":"WebAuthn"===r?"webauthn":r.toLowerCase()),$.ajax(e({type:"POST",url:"".concat(scriptname,"2fregisters/").concat(a,"/delete"),data:{epoch:n},headers:{"X-CSRF-Check":"1"},dataType:"json",error:t,success:function(e){var t;return e.error?e.error.match(/notAuthorized/)?o("notAuthorized","warning"):o("unknownAction","warning"):e.result?($("#delete-".concat(n)).hide(),t=jQuery.Event("mfaDeleted"),$(document).trigger(t,[{type:r,epoch:n}]),t.isDefaultPrevented()||o("yourKeyIsUnregistered","positive"),setTimeout(function(){return window.location=window.location.href.split("?")[0]},2e3)):void 0}},"error",t))},n=function(e,r,n,a,i){if(a!=i)return $.ajax({type:"POST",url:"".concat(scriptname,"2fregisters/").concat(n,"/modify"),data:{epoch:r,label:a},headers:{"X-CSRF-Check":"1"},dataType:"json",error:t,success:function(t){var n;if(t.error)return t.error.match(/bad(Code|Name)/)?o(t.error,"warning"):o(t.error,"danger");$("span.update2f[device=".concat(e,"][epoch=").concat(r,"]")).attr("oldlabel",a),n=jQuery.Event("mfaUpdated"),$(document).trigger(n,[{type:e,epoch:r,label:a}]),n.isDefaultPrevented()||o("yourKeyIsUpdated","positive")}});o("yourKeyIsUnchanged","warning")},$(document).ready(function(){return $("body").on("click",".remove2f",function(){return r($(this).attr("device"),$(this).attr("epoch"),$(this).attr("prefix"))}),$("body").on("click",".update2f",function(){return n($(this).attr("device"),$(this).attr("epoch"),$(this).attr("prefix"),$("#input-".concat($(this).attr("epoch"))).val(),$(this).attr("oldlabel"))}),$("#goback").attr("href",portal),$(".data-epoch").each(function(){var e;return e=new Date(1e3*$(this).text()),$(this).text(e.toLocaleString())})})}();