(window.cbJsonP=window.cbJsonP||[]).push([[211],{453:function(t,e,n){"use strict";n.r(e);var i=n(3),a=n.n(i),o=n(10),s=n.n(o),r=n(24),u=n.n(r),c=n(13),l=n.n(c),h=n(2),p=n.n(h),f=n(5),v=n.n(f),d=(n(29),n(15)),g=[{name:"portal",actions:[{name:"logout",method:"post",endpoint:"/api/internal/ssp_users/logout",headers:{"X-Requested-With":"XMLHttpRequest"}}]},{name:"js_info",actions:[{name:"static",method:"get",headers:{"X-Requested-With":"XMLHttpRequest"},endpoint:function(){return"/api/internal/"+Object(d.d)()+"/retrieve_js_info"},static:!0},{name:"get",method:"get",headers:{"X-Requested-With":"XMLHttpRequest"},endpoint:function(){return"/api/internal/"+Object(d.d)()+"/retrieve_js_info"},static:!1}]},{name:"locale",actions:[{name:"retrieve",method:"get",headers:{"X-Requested-With":"XMLHttpRequest"},endpoint:function(t){return"/api/internal/cbjs/"+Object(d.d)()+"/translations?locale="+t.languageCode}}]}],_=n(19),m=n(46),C=n(26),j=function(){function t(e){p()(this,t),this.config={site:e.site,hostname:e.hostName,publishableKey:e.publishableKey},this.apiClient=e.apiClient,this.iframeClient=e.connectionClient,this.commMgr=e}return v()(t,[{key:"init",value:function(){return this.apiClient.addApis(g),this.hpData={},this.infoRetrievalCount=0,this.getInfo()}},{key:"getInfo",value:function(){var t=this;return this.info?l.a.resolve(this.info):this.infoRetrievalCount>=5?l.a.resolve({site:this.config.site}):(this.infoRetrievalCount>1?this.apiClient.js_info.get():this.apiClient.js_info.static()).then((function(e){t.infoRetrievalCount=-1,t.info=e;var n=e.captcha_site_key||e.recaptcha_site_key;return n&&t.commMgr.initializeCaptcha({siteKey:n,provider:e.captcha_provider,isGlobalRecaptcha:e.supported_global_recaptcha}),e})).catch((function(e){return m.a.kvl({action:"retrieve_js_info_failed",info_retrieval_count:t.infoRetrievalCount},e),l.a.resolve({site:t.config.site})})).finally((function(){return t.infoRetrievalCount++}))}},{key:"syncTranslations",value:function(t){Object(C.i)(t)}},{key:"getTranslations",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=Object(C.h)(e.locale),i=e.languageCode,a=Object(C.e)();return n?a[n]?l.a.resolve(a[n]):this.apiClient.locale.retrieve({languageCode:i}).then((function(e){return t.syncTranslations(e),e})).catch((function(t){var e=new _.a(t);throw m.a.error(e),e})):l.a.resolve(a)}},{key:"getHpData",value:function(t){return t&&u()(this.hpData[t])?s()({},t,this.hpData[t]):t?{}:this.hpData}},{key:"portalLogout",value:function(){var t=this;return this.hpData.jwt?this.apiClient.portal.logout({},{token:this.hpData.jwt}).then((function(){return t.hpData.jwt="",{success:!0}})):l.a.resolve({success:!1})}},{key:"setHpData",value:function(t){var e=this;return a()(t).map((function(n){u()(t[n])&&(e.hpData[n]=t[n])})),l.a.resolve({acknowledged:!0})}}]),t}();e.default=j}}]); //# sourceMappingURL=211-4998abc5f64da0d53c90.js.map