!function(){"use strict";function t(t,i){for(var e=0;e<i.length;e++){var s=i[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var i=function(){function i(t){if(function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,i),"core:logout-iframe"===t)this.populateData(),0===Object.keys(this.sps).length&&this.btncontinue.click(),this.btnall.addEventListener("click",this.initLogout.bind(this)),window.addEventListener("message",this.clearAssociation.bind(this),!1);else if("IFrameLogoutHandler"===t){var e=document.querySelector('i[id="data"]'),s={spId:e.getAttribute("data-spid")};e.hasAttribute("data-error")&&(s.error=e.getAttribute("data-error")),window.parent.postMessage(JSON.stringify(s),i.getOrigin())}}var e,s,n;return e=i,n=[{key:"getOrigin",value:function(){var t=window.location.origin;return t||(t=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")),t}}],(s=[{key:"clearAssociation",value:function(t){if(t.origin===i.getOrigin()){var e=JSON.parse(t.data);void 0===e.error?this.completed(e.spId):this.failed(e.spId,e.error),0===Object.keys(this.sps).length&&0===this.nfailed&&this.btncontinue.click()}}},{key:"completed",value:function(t){void 0!==this.sps[t]&&(this.sps[t].icon.classList.remove("fa-spin"),this.sps[t].icon.classList.remove("fa-circle-o-notch"),this.sps[t].icon.classList.add("fa-check-circle"),this.sps[t].element.style.display="none",delete this.sps[t],this.finish())}},{key:"failed",value:function(t,i){void 0!==this.sps[t]&&(this.sps[t].element.classList.add("error"),this.sps[t].icon.classList.remove("fa-spin","fa-circle-o-notch"),this.sps[t].icon.classList.add("fa-exclamation-circle"),this.errmsg.classList.remove("hidden"),this.errfrm.classList.remove("hidden"),delete this.sps[t],this.nfailed++,this.finish())}},{key:"finish",value:function(){Object.keys(this.sps).length>0||(void 0!==this.timeout&&clearTimeout(this.timeout),this.nfailed>0?(this.errmsg.classList.remove("hidden"),this.errfrm.classList.remove("hidden"),this.actions.classList.add("hidden")):this.btncontinue.click())}},{key:"initLogout",value:function(t){t.preventDefault(),this.btnall.disabled=!0,this.btncancel.disabled=!0,Object.keys(this.sps).forEach(function(t){this.sps[t].status="inprogress",this.sps[t].startTime=(new Date).getTime(),this.sps[t].iframe.setAttribute("src",this.sps[t].iframe.getAttribute("data-url")),this.sps[t].icon.classList.add("fa-spin")}.bind(this)),this.initTimeout()}},{key:"initTimeout",value:function(){var t=10;for(var i in this.sps)if(void 0!==i&&this.sps.hasOwnProperty(i)&&"inprogress"===this.sps[i].status){var e=((new Date).getTime()-this.sps[i].startTime)/1e3;this.sps[i].timeout<=e?this.failed(i,"Timed out",window.document):this.sps[i].timeout-e<t&&(t=this.sps[i].timeout-e)}Object.keys(this.sps).length>0?this.timeout=setTimeout(this.initTimeout.bind(this),1e3*t):this.finish()}},{key:"populateData",value:function(){this.sps={},this.btnall=document.querySelector('button[id="btn-all"]'),this.btncancel=document.querySelector('button[id="btn-cancel"]'),this.btncontinue=document.querySelector('button[id="btn-continue"]'),this.actions=document.querySelector('div[id="original-actions"]'),this.errmsg=document.querySelector('div[id="error-message"]'),this.errfrm=document.querySelector('form[id="error-form"]'),this.nfailed=0;var t=this;document.querySelectorAll('li[id^="sp-"]').forEach((function(i,e,s){var n=i.getAttribute("data-id"),o=document.querySelector('iframe[id="iframe-'+n+'"]'),r=i.getAttribute("data-status");switch(r){case"failed":t.nfailed++;case"completed":return}t.sps[n]={status:r,timeout:i.getAttribute("data-timeout"),element:i,iframe:o,icon:document.querySelector('i[id="icon-'+n+'"]')}}))}}])&&t(e.prototype,s),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),i}();ready((function(){new i(document.body.id)}))}();
//# sourceMappingURL=logout.js.map