(function () {var f={};function l(o){return new z(o)}class m{constructor(s,t){this.url=s,this.onMessage=t,this.open=!1,this.actions=[],this.socket=new WebSocket(this.url),this.socket.onopen=this.onOpen.bind(this),this.socket.onclose=this.onClose.bind(this),this.socket.onmessage=this._onMessage.bind(this)}onOpen(){for(this.open=!0;this.actions.length;){const s=this.actions.pop();this.send(s)}}onClose(){this.socket=void 0,this.open=!1}_onMessage(s){let t;try{t=JSON.parse(s.data)}catch(e){t=s.data}this.onMessage(t)}send(s){this.open?this.socket.send(JSON.stringify(s)):this.actions.push(s)}}function b(e){const t=document.querySelector(e);if(!t)throw new Error("No element found with id "+e);return t}function j(e){return document.querySelector(e).value}function n(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function e(e,t,o,$){const r=o?200:0;e.classList.add("ul-bb"),setTimeout(()=>{n(e),e.innerHTML=t,e.classList.remove("ul-bb"),e.classList.add("ul-bg"),setTimeout(()=>{e.classList.remove("ul-bg"),$()},r)},r)}function p(e){const t=document.createElement("style");t.appendChild(document.createTextNode("")),document.head.appendChild(t);const o=t.sheet;e.forEach(e=>{o.insertRule(e,o.cssRules.length)})}function c(e,t){e.addEventListener("click",t)}function i(e,t){e.removeEventListener("click",t)}function q(e,t){document.querySelector(e).onkeyup=e=>{13===(e.which||e.keyCode)&&t()}}async function r(){const t=navigator.mediaDevices;return!(!t||!t.enumerateDevices)&&(await t.enumerateDevices()).some(t=>"videoinput"===t.kind)}async function s(t){const e=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{max:1280}},audio:!1});return t.srcObject=e,t.play(),e}function u(t,e){const a=e.getContext("2d");return e.width=t.videoWidth,e.height=t.videoHeight,a.translate(e.width,0),a.scale(-1,1),a.drawImage(t,0,0,e.width,e.height),e.toDataURL("image/png")}function g(t){t.getTracks()[0].stop()}function a(e,r,o){return{required:e,type:r,fallback:o}}function v(e,r){if(void 0===e)throw new Error("You need to supply an options object");var o,t={};for(o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&void 0===r[o])throw new Error("Unrecognized option "+o);for(o in r)if(Object.prototype.hasOwnProperty.call(r,o)){var n=r[o],p=e[o];if(void 0===p){if(n.required)throw new Error("Value "+o+" must be defined and of type "+n.type);t[o]=n.fallback}else{if(typeof p!==n.type)throw new Error("Value "+o+" must be of type "+n.type);t[o]=p}}return t}function w(r){var e=r.match(/^#?([0-9a-f]{6})$/i);if(e)return("#"+e[1]).toLowerCase();if(e=r.match(/^#?([1-9a-f])([1-9a-f])([1-9a-f])$/i))return("#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]).toLowerCase();var t="[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]",$=new RegExp("^rgb\\(("+t+"), ?("+t+"), ?("+t+")\\)$");if(e=r.match($))return("#"+d(e[1])+d(e[2])+d(e[3])).toLowerCase();throw new Error("Unrecognized color "+r+". Must be either hex or rgb format")}function k(r,e){r=r.slice(1);var t=30;e||(t*=-1);var $=parseInt(r,16);return"#"+d(($>>16)+t)+d(($>>8&255)+t)+d((255&$)+t)}function d(r){(r=parseInt(r))>255&&(r=255),r<0&&(r=0);var e=r.toString(16);return 1===e.length&&(e="0"+e),e}function t(t){return 0===Object.keys(t).length}f.init=l;const h="https://unlock-app.com/",x="https://play.google.com/store/apps/details?id=com.unlockauth.unlock",y="https://apps.apple.com/ca/app/unlock-authentication/id1380362354";class z{constructor(o){const t=this,i={url:a(!0,"string"),email:a(!0,"string"),onMessage:a(!0,"function"),submitOnEnter:a(!1,"boolean",!1),whatsThis:a(!1,"boolean",!1),color:a(!1,"string","#2f81c6"),extra:a(!1,"object",{})};t.opts=v(o,i),b(t.opts.email),b("#unlock-button"),t.opts.color=w(t.opts.color),t.loading=!1,t.socket=new m(t.opts.url,o=>{t.enableButton(),t.opts.onMessage(o)}),t.unlock=t._unlock.bind(t),t.buildButton(),t.opts.submitOnEnter&&q(t.opts.email,t.unlock)}get email(){return j(this.opts.email)}_unlock(){if(""===this.email)return;this.disableButton();const o={type:"unlock",email:this.email};t(this.opts.extra)||(o.extra=this.opts.extra),this.socket.send(o)}enableButton(){const o=b("#ul-bi");i(o,this.unlock),c(o,this.unlock),o.classList.remove("ul-bc"),o.classList.add("ul-bd")}disableButton(){const o=b("#ul-bi");i(o,this.unlock),o.classList.remove("ul-bd"),o.classList.add("ul-bc")}buildButton(){const o=b("#unlock-button");if(o.querySelector("#ul-bi")){const t=o.cloneNode(!0);o.parentNode.replaceChild(t,o)}else{let t="";this.opts.whatsThis&&(t+="