/**
 * @license ev-em.js v3.4.4 eugenDev 18/04 deffered fix
 * (c) 2015-2024 Evolok, Inc. https://www.evolok.com/
 *
 * License: MIT
 */
var runtime=function(a){"use strict";var u,t=Object.prototype,h=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",e=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function i(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{i({},"")}catch(t){i=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o,i,a,c,r=r&&r.prototype instanceof d?r:d,r=Object.create(r.prototype),n=new j(n||[]);return r._invoke=(o=t,i=e,a=n,c=l,function(t,r){if(c===p)throw new Error("Generator is already running");if(c===y){if("throw"===t)throw r;return k()}for(a.method=t,a.arg=r;;){var e=a.delegate;if(e){var n=function t(r,e){var n=r.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(r.iterator.return&&(e.method="return",e.arg=u,t(r,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var n=f(n,r.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,v;n=n.arg;if(!n)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v;{if(!n.done)return n;e[r.resultName]=n.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u)}e.delegate=null;return v}(e,a);if(n){if(n===v)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===l)throw c=y,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=p;n=f(o,i,a);if("normal"===n.type){if(c=a.done?y:s,n.arg!==v)return{value:n.arg,done:a.done}}else"throw"===n.type&&(c=y,a.method="throw",a.arg=n.arg)}}),r}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var l="suspendedStart",s="suspendedYield",p="executing",y="completed",v={};function d(){}function g(){}function m(){}var w={};w[n]=function(){return this};r=Object.getPrototypeOf,r=r&&r(r(O([])));r&&r!==t&&h.call(r,n)&&(w=r);var L=m.prototype=d.prototype=Object.create(w);function x(t){["next","throw","return"].forEach(function(r){i(t,r,function(t){return this._invoke(r,t)})})}function b(a,c){var r;this._invoke=function(e,n){function t(){return new c(function(t,r){!function r(t,e,n,o){t=f(a[t],a,e);if("throw"!==t.type){var i=t.arg;return(e=i.value)&&"object"==typeof e&&h.call(e,"__await")?c.resolve(e.__await).then(function(t){r("next",t,n,o)},function(t){r("throw",t,n,o)}):c.resolve(e).then(function(t){i.value=t,n(i)},function(t){return r("throw",t,n,o)})}o(t.arg)}(e,n,t,r)})}return r=r?r.then(t,t):t()}}function E(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function _(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function O(r){if(r){var t=r[n];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var e=-1,t=function t(){for(;++e<r.length;)if(h.call(r,e))return t.value=r[e],t.done=!1,t;return t.value=u,t.done=!0,t};return t.next=t}}return{next:k}}function k(){return{value:u,done:!0}}return((g.prototype=L.constructor=m).constructor=g).displayName=i(m,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,i(t,o,"GeneratorFunction")),t.prototype=Object.create(L),t},a.awrap=function(t){return{__await:t}},x(b.prototype),b.prototype[e]=function(){return this},a.AsyncIterator=b,a.async=function(t,r,e,n,o){void 0===o&&(o=Promise);var i=new b(c(t,r,e,n),o);return a.isGeneratorFunction(r)?i:i.next().then(function(t){return t.done?t.value:i.next()})},x(L),i(L,o,"Generator"),L[n]=function(){return this},L.toString=function(){return"[object Generator]"},a.keys=function(e){var t,n=[];for(t in e)n.push(t);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},a.values=O,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(_),!t)for(var r in this)"t"===r.charAt(0)&&h.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function t(t,r){return i.type="throw",i.arg=e,n.next=t,r&&(n.method="next",n.arg=u),!!r}for(var r=this.tryEntries.length-1;0<=r;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=h.call(o,"catchLoc"),c=h.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&h.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),v},finish:function(t){for(var r=this.tryEntries.length-1;0<=r;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),_(e),v}},catch:function(t){for(var r=this.tryEntries.length-1;0<=r;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n,o=e.completion;return"throw"===o.type&&(n=o.arg,_(e)),n}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:O(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=u),v}},a}("object"==typeof module?module.exports:{});try{regeneratorRuntime=runtime}catch(t){Function("r","regeneratorRuntime = r")(runtime)}
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _createSuper(n){var o=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(n);return _possibleConstructorReturn(this,o?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _wrapNativeSuper(e){var n="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _construct(e,t,n){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);o=new(Function.bind.apply(e,o));return n&&_setPrototypeOf(o,n.prototype),o}).apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],o=!0,r=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(r)throw i}}return n}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function asyncGeneratorStep(e,t,n,o,r,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(o,r)}function _asyncToGenerator(s){return function(){var e=this,a=arguments;return new Promise(function(t,n){var o=s.apply(e,a);function r(e){asyncGeneratorStep(o,t,n,r,i,"next",e)}function i(e){asyncGeneratorStep(o,t,n,r,i,"throw",e)}r(void 0)})}}function _createForOfIteratorHelper(e,t){var n,o;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,t=function(){};return{s:t,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:(o=function(e){throw e},i.toString=function(){return o.toString()},i),f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e){return o.apply(this,arguments)}var a,s,c=!0,l=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:(s=function(e){l=!0,a=e},u.toString=function(){return s.toString()},u),f:function(){try{c||null==n.return||n.return()}finally{if(l)throw a}}};function u(e){return s.apply(this,arguments)}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}window.EV=window.EV||{},function(Z){var o,$,ee,u,d,i,m=new _,a=new _,n=!1,r=0,s=0,p={};window.addEventListener("ev.widgets.dwelltime.enabled",function(e){e.detail.dwellTimeTrackingEnabled&&(n=!0,s=e.detail.maxDwellTimeRequests||3,setTimeout(function(){Z.Em.initDwellTimeRequests(p.authorizeData)},1e3))});var c,t,y=(c="evolok.api.service",function(e){var t;if(!e||0===e.trim().length)throw new Error("Could not find the service name or key!");return Z.Em.secureModeEnabled&&(t=ne("ex_ss"))?"Evolok "+c+"="+e+" evolok.api.secureSessionId="+t:(t=ne("ev_ss"),"Evolok "+c+"="+e+" evolok.api.sessionId="+t)});function h(){u&&(ee.disableCookies||te("ev_sid")==u||(f("ev_sid",u),S("ev_sid",u,0,"localStorage"))),d&&(ee.disableCookies||te("ev_did")==d||(f("ev_did",d),S("ev_did",d,0,"localStorage")))}function te(e){for(var t=(t=document.cookie).split("; "),n={},o=0;o<t.length;o++){var r=t[o].split("=");n[r[0]]=r[1]}return n[e]||""}Z.Em={Event:{AD_AUTHORIZE:"ev.ad.authorize",PROFILE_ACCESS_RENDER_STATUS:"ev.ad.profile.access.render.status",GET_USER_PROFILE_SUCCESS:"ev.ad.get.user.profile.success",GET_USER_PROFILE_FAIL:"ev.ad.get.user.profile.fail",UPDATE_PROFILE_SUCCESS:"ev.em.profile.update.success",UPDATE_PROFILE_FAIL:"ev.em.profile.update.fail",GET_PROFILE_TEMPLATE_SUCCESS:"ev.em.profile.template.get.success",GET_PROFILE_TEMPLATE_FAIL:"ev.em.profile.template.get.fail",GET_PROFILE_DATA_SUCCESS:"ev.em.profile.data.get.success",GET_PROFILE_DATA_FAIL:"ev.em.profile.data.get.fail",DWELLTIME_CHECK:"ev.ad.dwelltime.check",DWELLTIME_WIDGETS_ENABLED:"ev.widgets.dwelltime.enabled",PAYWALL_MODAL_RENDERED:"ev.em.paywall.modal.rendered",NOTIFIER_MODAL_RENDERED:"ev.em.notifier.modal.rendered",PAYWALL_OPENED:"ev.em.paywall.opened",NOTIFIER_OPENED:"ev.em.notifier.opened",PAYWALL_SHOW_CTA:"ev.em.paywall.showCTA",NOTIFIER_SHOW_CTA:"ev.em.notifier.showCTA",PAYWALL_RENDER_READY:"ev.em.paywall.render.ready",NOTIFIER_RENDER_READY:"ev.em.notifier.render.ready",NOTIFIER_CLOSE:"ev.em.notifier.close",ARTICLE_DATA:"ev.em.article.data",ARTICLE_URL:"ev.em.article.url",CLOSE_ARTICLE_SHARING_MODAL:"ev.em.close.article.sharing.modal",SHARE_ARTICLE_SUCCESS:"ev.em.share.article.success",SHARE_ARTICLE_ERROR:"ev.em.share.article.error",OPEN_PRODUCT_SELECTION:"ev.em.open.product.selection",PRODUCT_SELECTION_LOADED:"ev.em.product.selection.loaded",SOCIAL_LOGIN_SUCCESS:"ev.em.social.login.success",SOCIAL_LOGIN_FAILED:"ev.em.social.login.failed",SESSION_REFRESH:"ev.em.session.refresh",SESSION_SAVED:"ev.em.user.session.saved",IDENTITY_LINK_AUTHENTICATION:"ev.em.identity.link.authentication",SOCIALS_LINK_AUTHENTICATION:"ev.em.socials.link.authentication",SOCIAL_LOGIN_ATTEMPTED_EXISTING_EMAIL:"social.login.existing.email.attempted",SOCIAL_LOGIN_ATTEMPTED_REQUIRES_AUTHENTICATION:"social.login.existing.email.authentication.required",USER_IDENTIFIED:"ev.em.user.identified",LOGOUT_SUCCESS:"ev.em.logout.success",LOGOUT_FAILED:"ev.em.logout.failed",SESSION_EXPIRED:"ev.em.session.expired",PM_PROMO_ACTION:"pm.promo.action"},on:function(e,t){window.addEventListener(e,t)},publish:function(e,t){var n;"function"==typeof CustomEvent?n=new CustomEvent(e,{detail:t}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!1,!1,{detail:t}),window.dispatchEvent(n)},shareArticle:function(t){var e=te("ev_ss")||te("ev_ss"),n="".concat(ee.pmUrl,"/widget/account/sharearticle?ev_ss=").concat(e),e={articleUrl:t.articleUrl,articleId:t.articleId,recipientEmail:t.email};fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(function(e){200===e.status?e.json().then(function(e){Z.Em.publish(Z.Em.Event.CLOSE_ARTICLE_SHARING_MODAL,{}),Z.Em.publish(Z.Em.Event.SHARE_ARTICLE_SUCCESS,_objectSpread(_objectSpread({},e),{},{metadata:t.metadata}))}):e.json().then(function(e){return Z.Em.publish(Z.Em.Event.SHARE_ARTICLE_ERROR,e)})}).catch(function(e){Z.Em.publish(Z.Em.Event.SHARE_ARTICLE_ERROR,e),console.log(e)})},init:function(e){if(!e.url)throw"Configuration must specify the url property!";var t;e.hasOwnProperty("brand")&&(this.brand=e.brand),e.hasOwnProperty("channel")&&(this.channel=e.channel),e.hasOwnProperty("realmName")&&(this.realmName=e.realmName),e.hasOwnProperty("serviceName")&&(this.serviceName=e.serviceName),e.hasOwnProperty("socialServiceName")&&(this.socialServiceName=e.socialServiceName),e.hasOwnProperty("secureModeEnabled")&&(this.secureModeEnabled=e.secureModeEnabled),e.hasOwnProperty("autoRegister")&&(this.autoRegister=e.autoRegister),e.hasOwnProperty("autoPopulate")&&(this.autoPopulate=e.autoPopulate),e.hasOwnProperty("socialAttributeMapping")&&(this.socialAttributeMapping=e.socialAttributeMapping),e.hasOwnProperty("ssoCookieDomain")&&(this.ssoCookieDomain=e.ssoCookieDomain),e.hasOwnProperty("enableSeamlessMode")&&(this.enableSeamlessMode=e.enableSeamlessMode),e.hasOwnProperty("disableCookies")&&(this.disableCookies=e.disableCookies),e.hasOwnProperty("useSwg")&&(this.useSwg=e.useSwg),e.hasOwnProperty("productName")&&(this.productName=e.productName),e.hasOwnProperty("productGroupName")&&(this.productGroupName=e.productGroupName),e.hasOwnProperty("qrCodeQueryParam")?this.qrCodeQueryParam=e.qrCodeQueryParam:this.qrCodeQueryParam="evAccessToken",e.hasOwnProperty("shareArticleTokenQueryParam")?this.shareArticleTokenQueryParam=e.shareArticleTokenQueryParam:this.shareArticleTokenQueryParam="shareArticleToken",e.hasOwnProperty("articleUrlKey")?this.articleUrlKey=e.articleUrlKey:this.articleUrlKey="article_url",e.hasOwnProperty("articleIdKey")?this.articleIdKey=e.articleIdKey:this.articleIdKey="articleId",e.hasOwnProperty("authSchemeName")&&(this.authSchemeName=e.authSchemeName),e.hasOwnProperty("autoLinkLoginRedirectUrl")&&(this.autoLinkLoginRedirectUrl=e.autoLinkLoginRedirectUrl,(t=this.autoLinkLoginRedirectUrl.match(/^(https?:\/\/)?([^\/]+)/))&&t[2]&&(this.autoLinkLoginRedirectUrlDomain=t[2])),e.hasOwnProperty("autoLinkLoginRedirectAutomatic")?this.autoLinkLoginRedirectAutomatic=e.autoLinkLoginRedirectAutomatic:this.autoLinkLoginRedirectAutomatic=!0,e.hasOwnProperty("icDomain")&&(this.icDomain=e.icDomain),e.hasOwnProperty("GTMDataLayerEnabled")&&(this.GTMDataLayerEnabled=e.GTMDataLayerEnabled),e.hasOwnProperty("enableDwellTime")&&(this.enableDwellTime=e.enableDwellTime),e.hasOwnProperty("cookieExpireTime")&&(this.cookieExpireTime=e.cookieExpireTime),(ee=e).icDomain&&ee.serviceName&&Z.Em.getUserProfileData(),Z.Event&&Z.Event.on(Z.Event.USER_SESSION_SAVED,function(){Z.Em.getUserProfileData()}),(e.hasOwnProperty("enableGoogleOneTap")&&!0===e.enableGoogleOneTap||ee.useSwg)&&(e.hasOwnProperty("realmName")||e.hasOwnProperty("socialServiceName")&&e.hasOwnProperty("serviceName")?e.hasOwnProperty("googleClientId")||ee.useSwg?(this.googleClientId=e.googleClientId,this.enableGoogleOneTap=e.enableGoogleOneTap,this.googleGenericConf=e.googleGenericConf,Z.Em.initGoogleApis()):(console.warn("Impossible to initialize Google One Tap. Check that you have setup correctly the `googleClientId`"),delete e.enableGoogleOneTap):(console.warn("Impossible to initialize Google One Tap. Check that you have setup correctly: `realmName`, `socialServiceName` / `serviceName`"),delete e.enableGoogleOneTap)),!0===ee.useSwg&&Z.Em.loadSwgLibrary()},entitlementsFlow:function(n,e,t){var o;function r(){var e="https://".concat(ee.domainName,"ic/api/social/").concat(o.guid),t={Accept:"application/json",Authorization:"Evolok evolok.api.service=".concat(ee.serviceName," evolok.api.sessionId=").concat(o.mainSession.sessionId)};fetch(e,{method:"GET",headers:t}).then(function(e){if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(function(e){e.hasOwnProperty("GOOGLE")?i(n,o):console.log("auto linking?")}).catch(function(e){console.error("There was a problem with checking the account linking:",e)})}function i(t,n){t.getEntitlements().then(function(e){swgEntitlements=e,0!==swgEntitlements.entitlements.length?function(n,e){purchaseData=JSON.parse(e.entitlements[0].subscriptionToken),skus=purchaseData.productId;var i=purchaseData.purchaseToken;return new Promise(function(r,e){if(!ee.pmUrl)return console.log("no pmUrl specified"),void r(!0);var t=ee.pmUrl+"/widget/account/purchases/"+"?ev_ss=".concat(n);fetch(t).then(function(e){return e.json()}).then(function(e){if(console.log(e),null!==e.appErrorCode)if(e[0]&&e[0].appErrorCode&&"BEX0004"===e[0].appErrorCode)r(!1);else if(0!==e.length){var t,n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if("SUBSCRIBE_WITH_GOOGLE"===o.paymentType&&"ACTIVE"===o.status||o.externalId===i)return void r(!0)}}catch(e){n.e(e)}finally{n.f()}console.log("Swg purchase not found for logged in user on Evolok side"),r(!1)}else r(!1);else r(!1)}).catch(function(e){console.log(e,"error getting purchases"),r(!0)})})}(n.mainSession.sessionId,swgEntitlements).then(function(e){console.log("Purchases checked:",e),e||t.completeDeferredAccountCreation({entitlements:swgEntitlements,consent:!0}).then(function(e){$?Z.Em.swgSubscribe(swgEntitlements,!1,e):function(n){var e,t=te("ev_sid")||ne("ev_sid","localStorage"),o=ee.productName,r=ee.productGroupName;if(ee.pmUrl){var i=ee.pmUrl+"/widget";if(o)e=i+"/product/".concat(o,"?ev_sid=").concat(t);else{if(!r)return console.log("no product name/group specified");e=i+"/productgroup/".concat(r,"?ev_sid=").concat(t)}fetch(e).then(function(e){return 200===e.status?e.json():null}).then(function(e){if(!e)throw"Metering Library Error: Product/s info is empty";var t=[];e.products?t=e.products:t.push(e),$=t,Z.Em.swgSubscribe(swgEntitlements,!1,n)}).catch(function(e){console.log(e,"error getting products")})}else console.log("no pmUrl specified")}(e)},function(e){console.log(e)})}).catch(function(e){console.error("Error while checking purchases:",e)}):console.log("No entitelments")})}p.authorizeData.segments.includes("SWG_Subscriber")?console.log("User is swg subscriber by segment definition"):(o=e,ee.serviceName&&ee.enableGoogleOneTap&&ee.realmName?(e=te("ev_ss"),Z.Em.getEVSession()?t?r():i(n,o):(t="https://".concat(ee.domainName,"ic/api/session/").concat(e),e={Accept:"application/json",Authorization:"Evolok evolok.api.service=".concat(ee.serviceName," evolok.api.sessionId=").concat(e)},fetch(t,{method:"GET",headers:e}).then(function(e){if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(function(e){o=e,r()}).catch(function(e){console.error("There was a problem with getting session details:",e)}))):console.log("Google one tap not enabled, deffered flow stopped"))},loadSwgLibrary:function(){var n;if(console.log("Loading SWG Library"),!document.getElementById("evo-swg-markup"))return console.log("Script with id evo-swg-markup not found. SWG functionality will be skipped"),void(ee.useSwg=!1);var e=document.createElement("script");e.src="https://news.google.com/swg/js/v1/swg.js",e.setAttribute("subscriptions-control","manual"),e.onload=function(){(self.SWG=self.SWG||[]).push(function(e){var t=JSON.parse(document.getElementById("evo-swg-markup").innerText).isPartOf.productID;(n=e).init(t),e.start(),e.getEntitlements().then(function(e){this.entitlements=e,console.log(this.entitlements)}),Z.Em.publish("ev.swg.emLibraryLoaded",e),n.setOnPaymentResponse(function(e){console.log("OnPaymentResponse"),e.then(function(e){console.log("OnPaymentResponse.response",e),Z.Em.swgSubscribe(e,!1)})})})},document.body.appendChild(e),this.getSwgSubscriptions=function(){return n}},initGoogleApis:function(){var n,s,c,e,g=!1;function o(e){console.log("Google One Tap Response",e),e.network="google",l(e)}function l(e){var n,o,r,i,a,t=Z.Em.socialServiceName||Z.Em.serviceName,s=Z.Em.autoRegister||!0,c=Z.Em.autoPopulate||!1;n=Z.Em.realmName,o=t,r=s,i=c,a=e,new Promise(function(e,t){!function(t,u,e,n,o,r,d,m){var p=t.network||"google";if(t.hasOwnProperty("error")||t.hasOwnProperty("code")){var i=v(t,u,p);m(i)}else{var o={autoRegister:o||!0,autoPopulate:r||!0},h={};if(t.hasOwnProperty("credential")&&!g)Object.assign(t,{jwt:t.credential}),(h=t).client_id=ee.googleClientId;else{if(!g)return m("Credentials from Google One Tap response weren't found. Impossible to create User Session.");Object.assign(t,{client_id:t.userData.data.aud}),h.client_id=t.userData.data.aud,h.network="google",h.jwt="ND",h.credential="ND"}Object.assign(h,{realmName:e}),Object.assign(h,{serviceName:n});var a=[];if(r&&Z.Em.socialAttributeMapping&&!g){for(var s in Z.Em.socialAttributeMapping){s={name:s,value:Z.Em.socialAttributeMapping[s]};a.push(s)}Object.assign(h,{attributesMapping:a})}g&&(a.push({name:"Email",value:"email"}),a.push({name:"google_sub",value:t.userData.data.sub}),a.push({name:"google_email",value:t.userData.data.email}),a.push({name:"google_name",value:t.userData.data.name}),a.push({name:"google_given_name",value:t.userData.data.given_name||""}),a.push({name:"google_family_name",value:t.userData.data.family_name||""}),Object.assign(h,{attributesMapping:a})),Z.Em.brand&&(h.brand=Z.Em.brand),Z.Em.channel&&!g&&(h.channel=Z.Em.channel);var f,o="https://".concat(Z.Em.icDomain,"/social/").concat(p,"/session?autoRegister=").concat(o.autoRegister,"&autoPopulate=").concat(o.autoPopulate),n={Accept:"application/json;charset=UTF-8","Content-Type":"application/json;charset=UTF-8",Authorization:y(n)};fetch(o,{method:"POST",headers:n,body:JSON.stringify(h)}).then(function(e){return f=t.headers,e.json()}).then(function(e){var t,n,o,r,i,a,s,c,l;e.hasOwnProperty("error")||e.hasOwnProperty("code")||400<=u?(e.googleOneTap=h,function(e){if(e&&e.code&&"SOCIAL_EMAIL_ADDRESS_IN_USE"===e.code&&!g){var t,n,o,r,i,a={};if(a.googleOneTap=e.googleOneTap,a.identifiers=[{name:e.args[0],value:e.args[1]}],e.args&&(1===(i=e.args[2].split(",")).length&&""===i[0]?(i=[],Z.Em.publish("hide.social",{networks:i}),a.hideSocial={networks:i},Z.Em.publish(Z.Em.Event.IDENTITY_LINK_AUTHENTICATION),Z.Em.publish(Z.Em.Event.USER_IDENTIFIED,a.identifiers)):(r="true"===e.args[3],i=i.map(function(e){return e.toLowerCase()}),r?(Z.Em.publish(Z.Em.Event.IDENTITY_LINK_AUTHENTICATION),Z.Em.publish("user.identified.with.socials",{networks:i}),Z.Em.publish("hide.social",{networks:i,hideAllSocial:"false"}),a.hideSocial={networks:i,hideAllSocial:"false"},Z.Em.publish(Z.Em.Event.USER_IDENTIFIED,a.identifiers)):(1<i.length?(Z.Em.publish(Z.Em.Event.SOCIALS_LINK_AUTHENTICATION,i),a.socialLinkAuthentication=i):Z.Em.publish(i[0]+".link.authentication"),Z.Em.publish("hide.ic.login",{networks:i}),Z.Em.publish("hide.social",{networks:i,hideAllSocial:"false"}),a.hideIcLogin={networks:i},a.hideSocial={networks:i,hideAllSocial:"false"}))),e.network="google",a.socialNetwork=e.network,a.socialLoginAttempted=!0,!Z.Em.authSchemeName){var s="EV.Em.init() is not provided with an authSchemeName attribute, impossible to proceed with Social Linking to existing account.";return console.error(s),Z.Em.publish(Z.Em.Event.SOCIAL_LOGIN_FAILED,s)}S("ev_auth_scheme",Z.Em.authSchemeName,0,"sessionStorage"),S("google_one_tap_attempted",JSON.stringify(a),0,"sessionStorage"),Z.Em.autoLinkLoginRedirectUrlDomain!==document.domain&&(t=encodeURIComponent(a.googleOneTap.network),n=encodeURIComponent(a.googleOneTap.client_id),o=encodeURIComponent(a.googleOneTap.credential),r=encodeURIComponent(a.identifiers[0].name),i=encodeURIComponent(a.identifiers[0].value),s=encodeURIComponent(JSON.stringify(a.hideSocial)),c=encodeURIComponent(JSON.stringify(a.hideIcLogin)),Z.Em.autoLinkLoginRedirectUrl="".concat(Z.Em.autoLinkLoginRedirectUrl,"&network=").concat(t,"&google_client_id=").concat(n,"&credential=").concat(o,"&identifierName=").concat(r,"&identifierValue=").concat(i,"&hideSocial=").concat(s,"&hideIcLogin=").concat(c)),Z.Em.autoLinkLoginRedirectAutomatic&&Z.Em.autoLinkLoginRedirectUrl?(console.info("Redirecting user to authenticate with Evolok before doing Social Linking"),window.location.href=Z.Em.autoLinkLoginRedirectUrl):Z.Em.publish(Z.Em.Event.SOCIAL_LOGIN_ATTEMPTED_REQUIRES_AUTHENTICATION,{socialNetwork:e.network})}else{var c;e&&e.code&&"SOCIAL_EMAIL_ADDRESS_IN_USE"===e.code&&g&&(c=JSON.parse(localStorage.getItem("evolok:swg-purchase")),c=Z.Em.autoLinkLoginRedirectUrl+(Z.Em.autoLinkLoginRedirectUrl.includes("?")?"&":"?")+"google_sub="+c.userData.data.sub+"&google_aud="+c.userData.data.aud+"&google_email="+c.userData.data.email+"&google_name="+c.userData.data.name+"&google_given_name="+c.userData.data.given_name+"&google_family_name="+c.userData.data.family_name+"&evAutoLiking=true",window.location.href=c)}Z.Em.publish(Z.Em.Event.SOCIAL_LOGIN_FAILED,e)}(e),a=v(e,u,p),m(a)):(t=e).hasOwnProperty("guid")&&(n=!1,t.hasOwnProperty("mainSession")&&(n=t.mainSession.hasOwnProperty("sessionCookie")?t.mainSession.sessionCookie:n,o=t.mainSession.hasOwnProperty("expiry")?t.mainSession.expiry:new Date),r=!1,!Z.Em.enableSeamlessMode||(a=f?f.get("X-EV-SSO"):void 0)&&(s=t,c=a,l=r=!0,new Promise(function(e,t){Z.Em.assert(c,"Seamless domains should not be empty!"),Z.Em.assert(s,"Session should not be empty!"),c=c.split(",");var n=l?"https://":"http://",o=0;function r(){o===c.length&&e()}c.forEach(function(e){var t=n+e+"/ic/api/session/"+s.mainSession.sessionId+"/sso.gif",e=new XMLHttpRequest;e.open("GET",t),e.withCredentials=!0,e.send(),e.onload=function(){o++,r()},e.onerror=function(){o++,r()}})}).then(function(){i=E(t,n,o,e,p,u),d(i)})),r||(i=E(t,n,o,e,p,u),d(i)))}).catch(function(e){console.error("Social login failed",e),Z.Em.publish(Z.Em.Event.SOCIAL_LOGIN_FAILED,e.message)})}}(a,null,n,o,r,i,e,t)}).then(function(e){Z.Em.publish(Z.Em.Event.SOCIAL_LOGIN_SUCCESS,e)},function(e){console.error("Social login error",e)}).catch(function(e){console.log("Error during social login",e)})}function E(e,t,n,o,r,i){return function(e,t,n,o){Z.Em.assert(e,"Evolok session should not be empty!");var r,i="ev_session",a=Z.Em.ssoCookieDomain||window.location.hostname;o||(!Z.Em.disableCookies&&e&&e.hasOwnProperty("mainSession")&&u("ev_ss",e.mainSession.sessionId,{expireMillis:e.mainSession.expiry||n,domain:a}),!Z.Em.disableCookies&&Z.Em.secureModeEnabled&&e.hasOwnProperty("secureSession")&&u("ex_ss",e.secureSession.sessionId,{expireMillis:e.secureSession.expiry||n,domain:a}));(t?sessionStorage:localStorage).setItem(i,JSON.stringify(e));Z.Em.publish(Z.Em.Event.SESSION_SAVED,"session saved"),g&&Z.Em.generateOrder();ee.useSwg&&"function"==typeof Z.Em.getSwgSubscriptions&&(r=Z.Em.getSwgSubscriptions());r&&!g&&Z.Em.entitlementsFlow(r,e,!1)}(e,t,n),Z.Em.publish(Z.Em.Event.SESSION_REFRESH,e),{network:r,statusCode:i,response:o}}function u(e,t,n){if(!navigator.cookieEnabled)throw Error("cookies are disabled");if(n=n||{},!e)throw Error("invalid key");t=e+"="+t;if(n.expireMillis&&((o=new Date).setTime(n.expireMillis),t+="; time="+new Date+"; expires="+o.toGMTString()),n.domain&&n.domain!==document.domain){var o=n.domain.replace(/^\./,"");if(-1===document.domain.indexOf(o)||o.split(".").length<=1)throw Error("invalid domain");t+="; domain="+n.domain}n=b();document.cookie=n&&n<13?t+"; path=/; Secure":t+"; path=/;SameSite=None; Secure"}function d(e){for(var t=e+"=",n=decodeURIComponent(document.cookie).split(";"),o=0;o<n.length;o++){for(var r=n[o];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return""}function v(e,t,n){if(!e)return e;t={network:n,statusCode:t,error:{}};return e.hasOwnProperty("code")?(t.error.code=e.code,t.error.message=e.message):e.hasOwnProperty("error")?t.error=e.error:t.error=e,e.hasOwnProperty("args")&&(t.error.args=e.args),t}ee.useSwg&&(this.swgSubscribe=function(i){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a=2<arguments.length?arguments[2]:void 0;if(e||localStorage.setItem("evolok:swg-purchase",JSON.stringify(i)),g=!0,e&&(i=JSON.parse(localStorage.getItem("evolok:swg-purchase"))),(i=!a?JSON.parse(localStorage.getItem("evolok:swg-purchase")):i).entitlements.entitlements)n=i.entitlements.entitlements,s=JSON.parse(i.purchaseData.data),skus=s.productId,c=!1,sessionStorage.removeItem("subscribe.google.com:toast");else{if(!i.entitlements)return void console.log("no swg purchase to parse");n=i.entitlements,s=JSON.parse(i.entitlements[0].subscriptionToken),skus=s.productId,c=!0}var o=[],r=[],t={};if(n.forEach(function(e,t){e.products.forEach(function(e,t){o.push(e)})}),$.forEach(function(e,t){var n;e.externalIds&&e.externalIds.GOOGLE&&o.includes(e.externalIds.GOOGLE)&&((n=$[t]).paymentPlans.find(function(e){e.externalIds&&e.externalIds.GOOGLE&&e.externalIds.GOOGLE===skus&&(n.paymentPlan=e)}),r.push(n))}),0===r.length||!r[0].paymentPlan)return console.log("No match between SWG products/productId and Evolok Products/Plans, impossible to create an Order on Evolok side"),void console.log(skus);t.orderItems=[{paymentPlanId:r[0].paymentPlan.id,productId:r[0].id,region:null,beneficiaryLimit:null,startDate:null}],t.orderType="STANDARD",t.brand=Z.Em.brand,t.channel=Z.Em.channel||"WEB",t.paymentType="SUBSCRIBE_WITH_GOOGLE",console.log(t),console.log($),console.log(i),e||c||l(i),this.generateOrder=function(){var r=d("ev_ss"),e="https://".concat(ee.domainName,"pm/api/v2/widget/order?ev_ss=").concat(r);fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){var t,n,o;console.log("order created:",e),t=e,n=r,e="https://".concat(ee.domainName,"pm/api/v2/widget/payment/").concat(t.id,"/subscription?ev_ss=").concat(n),o={swgOrderId:s.orderId,swgPurchaseToken:s.purchaseToken,swgPurchaseState:s.purchaseState},fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(e){console.log("subscription created:",e),function(e,t,n){n="https://".concat(ee.domainName,"pm/api/v2/widget/payment/").concat(e.id,"/subscription/complete?ev_ss=").concat(n);fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){console.log("subscription completed:",e),i&&"function"==typeof i.complete&&i.complete().then(function(){console.log("subscription completed")}),g=!1,localStorage.removeItem("evolok:swg-purchase"),a&&"function"==typeof a.complete&&a.complete().then(function(){})}).catch(function(e){g=!1,console.error("Error during subscription creation request:",e),a&&"function"==typeof a.complete&&a.complete().then(function(){})})}(t,o,n)}).catch(function(e){g=!1,console.error("Error during subscription creation request:",e),a&&"function"==typeof a.complete&&a.complete().then(function(){})})}).catch(function(e){g=!1,console.error("Error during order creation request:",e),a&&"function"==typeof a.complete&&a.complete().then(function(){})})},(e&&d("ev_ss")||c&&d("ev_ss"))&&this.generateOrder()}),ee.enableGoogleOneTap&&((e=d("ev_ss"))&&""!==e?console.info("User is logged in, Google One Tap will be skipped",e):((e=document.createElement("script")).src="https://accounts.google.com/gsi/client",e.onload=function(){!function(){var e={client_id:ee.googleClientId,callback:o};if(null!==ee.googleGenericConf)for(var t in ee.googleGenericConf)e[t]=ee.googleGenericConf[t];google.accounts.id.initialize(e),google.accounts.id.prompt(function(e){console.log("Goole One Tap Notification",e),e.isNotDisplayed()?console.info("Google One Tap is not being displayed",e):e.isSkippedMoment()&&console.info("Google One Tap was skipped",e)})}()},e.defer=!0,document.body.appendChild(e)))},getEVSession:function(){var e="evolok:ev_session",t=localStorage.getItem(e);return(t=null==(t=null==t||0===t.length?sessionStorage.getItem(e)?sessionStorage.getItem(e):te(e):t)||0===t.length?localStorage.getItem("ev_session"):t)&&0<t.length?JSON.parse(t):null},logout:function(){return new Promise(function(e,t){var n,o,r=Z.Em.getEVSession();v("ev_ss"),v("ex_ss"),r&&(n=Z.Em.socialServiceName||Z.Em.serviceName,o=window.location.protocol+"//"+window.location.host,o={Accept:"application/json;charset=UTF-8","Content-Type":"application/json;charset=UTF-8",Authorization:y(n),Origin:o},Z.Em.deleteSession(r.mainSession.sessionId,o,null,e,t))})},deleteSession:function(e,t,n,o,r){Z.Em.assert(e,"Session ID should not be empty!");e="https://".concat(ee.icDomain,"/session/").concat(e);function i(e){Z.Em.publish(Z.Em.Event.LOGOUT_SUCCESS,e),o(e)}Z.Em.delete(e,t,n).then(function(e){if(e.hasOwnProperty("statusCode")&&200==e.statusCode)if(Z.Em.clearAllSessions(),Z.Em.removeUserProfile(),Z.Em.enableSeamlessMode){var t=e.headers?e.headers.get("X-EV-SSO"):void 0;if(!t)throw i(),new Error("Couldn't find the participating seamless sign-in domains");Z.Em.deleteSeamlessSession(t,!0).then(function(){i(e)})}else i(e);else i(e)},function(e){"SESSION_NOT_FOUND"==e.error.code?(Z.Em.clearAllSessions(),Z.Em.removeUserProfile(),i(e)):r(e)})},deleteSeamlessSession:function(i,a){return new Promise(function(e,t){Z.Em.assert(i,"Seamless domains should not be empty!"),i=i.split(",");var n=a?"https://":"http://",o=0;function r(){o===i.length&&e()}i.forEach(function(e){var t=n+e+"/ic/api/session/sso_logout.gif",e=new XMLHttpRequest;e.open("GET",t),e.withCredentials=!0,e.send(),e.onload=function(){o++,r()},e.onerror=function(){o++,r()}})})},delete:function(t,n,e,o){return new Promise(function(i,a){Z.Em.assert(t,"Http request resource uri path should not be empty!"),Z.Em.isValid();var s,c,e=o||{};o&&o.hasOwnProperty("serviceName")?e.serviceName=o.serviceName:(e.serviceName=Z.Em.socialServiceName||Z.Em.serviceName,e.realmName=Z.Em.realmName),n=n||{},fetch(t,{method:"DELETE",headers:n}).then(function(e){return c=e.headers,s=e.status,200===e.status?e.text():void Z.Em.publish(Z.Em.Event.LOGOUT_FAILED,{status:e.status})}).then(function(e){if(e.error||e.code){var t=s,n=e.code,o=e.message||e.error&&e.error.message||e,r=[];return"SESSION_HAS_EXPIRED"===e.code&&(Z.Em.clearAllSessions(),Z.Em.removeUserProfile(),Z.Event.publish(Z.Em.SESSION_EXPIRED,"Session has expired.")),e.hasOwnProperty("args")?r=e.args:e.hasOwnProperty("error")&&(r=e.error.args),void a({code:n,message:o,statusCode:t,args:r})}i({response:e,statusCode:s,headers:c})}).catch(function(e){console.error("Logout failed",e),Z.Em.publish(Z.Em.Event.LOGOUT_FAILED,e)})})},clearAllSessions:function(){Z.Em.removeEVSession()},removeUserProfile:function(){sessionStorage.removeItem("ev_profile")},removeEVSession:function(){var e="ev_session";sessionStorage.removeItem(e),localStorage.removeItem(e),v("ev_ss"),v("ex_ss");localStorage.removeItem("hello")},isValid:function(){if(!ee.icDomain)throw new Error("Config must specify the icDomain property");if(!Z.Em.detectBrowserSupport())throw console.error("Not Compatible with current browser!"),new Error("Not Compatible with current browser!")},detectBrowserSupport:function(){var e="withCredentials"in new XMLHttpRequest;return e||console.error("Error running EV: your browser does not support CORS."),e},getAuthResponse:function(){return m.promise},getSegmentResponse:function(){return a.promise},getUserProfileTemplate:function(){fetch("https://".concat(ee.domainName,"/ic/api/ui/template/profile/").concat(ee.profileServiceName),{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return 200===e.status?e.json():void Z.Em.publish(Z.Em.Event.GET_PROFILE_TEMPLATE_FAIL,e.status)}).then(function(e){Z.Em.publish(Z.Em.Event.GET_PROFILE_TEMPLATE_SUCCESS,e)}).catch(function(e){return Z.Em.publish(Z.Em.Event.GET_PROFILE_TEMPLATE_FAIL,e.message)})},getUserProfileData:function(){var e=!1,t=document.getElementsByTagName("ev-em-profile-when"),n=localStorage.getItem("evolok:ev_session"),o=JSON.parse(JSON.parse(sessionStorage.getItem("evolok:ev_profile")))||{};if(n){var r,i=_createForOfIteratorHelper(t);try{for(i.s();!(r=i.n()).done;)"true"===r.value.getAttribute("getProfileEnable")&&(e=!0)}catch(e){i.e(e)}finally{i.f()}e?ee.serviceName in o||(o=(n=JSON.parse(n)).guid,n=n.secureSession.sessionId,n="Evolok evolok.api.service=".concat(ee.serviceName," evolok.api.secureSessionId=").concat(n),fetch("https://".concat(ee.icDomain,"/userProfile/").concat(o,"?serviceName=").concat(ee.serviceName),{method:"GET",headers:{"Content-Type":"application/xml",Accept:"application/json",Authorization:n}}).then(function(e){return 200===e.status?e.json():void Z.Em.publish(Z.Em.Event.GET_PROFILE_DATA_FAIL,e.status)}).then(function(e){!function(e,t){console.log(e),console.log(t);var n={};n[t]=e,console.log(n),sessionStorage.setItem("evolok:ev_profile",JSON.stringify(JSON.stringify(n)))}(e.userProfile,ee.serviceName),Z.Em.publish(Z.Em.Event.GET_PROFILE_DATA_SUCCESS,e)}).catch(function(e){return Z.Em.publish(Z.Em.Event.GET_PROFILE_DATA_FAIL,e.message)})):Z.Em.publish(Z.Em.Event.GET_PROFILE_DATA_SUCCESS,"re-render")}},updateAttributes:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,o,r,i,a,s,c,l;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!document.cookie.match(new RegExp("(^| )ev_ss=([^;]+)"))){e.next=4;break}n=document.cookie.match(new RegExp("(^| )ev_ss=([^;]+)"))[2],e.next=6;break;case 4:return console.warn("Evolok Session not found, impossible to update user attributes"),e.abrupt("return");case 6:return o="Evolok evolok.api.service=".concat(ee.profileServiceName," evolok.api.sessionId=").concat(n),e.next=9,fetch("https://".concat(ee.domainName,"/ic/api/session/").concat(n),{method:"GET",headers:{"Content-Type":"application/json",Authorization:o}});case 9:return r=e.sent,e.next=12,r.text().then(function(e){return(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("guid")[0].innerHTML});case 12:for(r=e.sent,i={attributes:[]},a=0,s=Object.entries(t);a<s.length;a++)l=_slicedToArray(s[a],2),c=l[0],l=l[1],l={name:c,value:l},i.attributes.push(l);fetch("https://".concat(ee.domainName,"/ic/api/userProfile/").concat(r,"/").concat(ee.profileServiceName),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:o},body:JSON.stringify(i)}).then(function(e){200===e.status?Z.Em.publish(Z.Em.Event.UPDATE_PROFILE_SUCCESS,e.status):Z.Em.publish(Z.Em.Event.UPDATE_PROFILE_FAIL,e.status)}).catch(function(e){return Z.Em.publish(Z.Em.Event.UPDATE_PROFILE_FAIL,e.message)});case 16:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)}),authorize:function(e,n,o){Z.Em.assert(e,"Parameters should not be empty!"),Z.Em.assert(n,"Success callback should not be empty!"),Z.Em.assert(o,"Error callback should not be empty!");var t=e?JSON.parse(e):{};Object.keys(t).forEach(function(e){t[e]=""+t[e]}),!t.hasOwnProperty("referer")&&document.referrer&&(t.referer=document.referrer),!t.hasOwnProperty("title")&&document.title&&(t.title=document.title),!t.hasOwnProperty("article_url")&&window.location.href&&(t.article_url=window.location.href),Z.Em.publish(Z.Em.Event.ARTICLE_DATA,{articleUrl:t[this.articleUrlKey],articleId:t[this.articleIdKey]}),ee.brand?t.brand=ee.brand:e.site&&(t.brand=e.site);var r=new URLSearchParams(window.location.search);if(r.has(this.qrCodeQueryParam||Z.Em.qrCodeQueryParam)&&(e=(e=r.get(this.qrCodeQueryParam||Z.Em.qrCodeQueryParam)).split(" ").join("+"),t[this.qrCodeQueryParam||Z.Em.qrCodeQueryParam]=e),r.has(this.shareArticleTokenQueryParam)&&(c=(c=r.get(this.shareArticleTokenQueryParam)).split(" ").join("+"),t[this.shareArticleTokenQueryParam]=c),ee.authorizeParams){var i,a=_createForOfIteratorHelper(ee.authorizeParams);try{for(a.s();!(i=a.n()).done;){var s=i.value;r.has(s)&&(t[s]=r.get(s))}}catch(e){a.e(e)}finally{a.f()}}t.ev_sid="",t.ev_did="",t.ev_ss="",!ee.disableCookies&&g("ev_sid")?(t.ev_sid=te("ev_sid"),S("ev_sid",te("ev_sid"),0,"localStorage")):!ee.disableCookies&&E("ev_sid")&&(ee.meterHD?!0===ee.meterHD&&(f("ev_sid",ne("ev_sid","localStorage")),t.ev_sid=ne("ev_sid","localStorage"),ee.meterHD):f("ev_sid",ne("ev_sid","localStorage"))),!ee.disableCookies&&g("ev_did")?(t.ev_did=te("ev_did"),S("ev_did",te("ev_did"),0,"localStorage")):!ee.disableCookies&&E("ev_did")&&(ee.meterHD?!0===ee.meterHD&&(f("ev_did",ne("ev_did","localStorage")),t.ev_did=ne("ev_did","localStorage")):f("ev_did",ne("ev_did","localStorage"))),""!==te("ev_ss")&&(t.ev_ss=te("ev_ss"));var c=w("/authorize/json",null),l=new XMLHttpRequest;l.open("POST",c,!0),l.setRequestHeader("Content-Type","application/json;charset=UTF-8"),l.withCredentials=!0,l.onload=function(){var e,t;200<=l.status&&l.status<400?(e={},200!==l.status||l.responseText?e=JSON.parse(l.responseText):e.result="ALLOW_ACCESS",m.resolve(e),p.authorizeData=e,console.log(e),e.sessionKeys?(e.sessionKeys.ev_sid&&(u=e.sessionKeys.ev_sid,h()),e.sessionKeys.ev_did&&(d=e.sessionKeys.ev_did,e.deviceId=e.sessionKeys.ev_did,h())):e.deviceId=te("ev_did"),Z.Em.articleSharingHandler(e),Z.Em.paywallAndNotifierEvents(e),"REQUIRE_LOGIN"===e.result&&Z.Event&&(""!==te("ev_ss")&&Z.Event.publish("session.cleanup","Session has expired"),Z.Event.publish("login.required","Login is required")),"ALLOW_ACCESS"!=e.result&&Z.Em.hideMeteredContent(),Z.Em.GTMDataLayerEnabled&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({evAuthResponse:e})),!e.loggedOut&&void 0!==e.loggedOut||Z.Em.publish(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,"LoggedOut"),e.loggedOut||void 0===e.loggedOut||Z.Em.publish(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,"LoggedIn"),!0===ee.useSwg&&te("ev_ss")&&(t=Z.Em.getSwgSubscriptions(),Z.Em.entitlementsFlow(t,Z.Em.getEVSession(),!0)),n(e)):(o&&o(l.status,l.responseText),Z.Em.publish(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,"LoggedOut"))},l.onerror=function(e){e?o(e):o(0,"unknown connection error")},l.send(JSON.stringify(t))},initDwellTimeRequests:function(t){var n=window.setInterval(function(){var e;document.hidden||(e=30*r+30,t.dwellTimeInterval=e,Z.Em.paywallAndNotifierEvents(t),r++),r==s&&clearInterval(n)},3e4)},articleSharingHandler:function(e){var t,n=null!=e.articleSharingEnabled&&!0===e.articleSharingEnabled,o=_createForOfIteratorHelper(document.querySelectorAll("ev-share-article-btn"));try{for(o.s();!(t=o.n()).done;)t.value.style.display=n?"block":"none"}catch(e){o.e(e)}finally{o.f()}},paywallAndNotifierEvents:function(e){function t(e){Z.Em.publish(Z.Em.Event.AD_AUTHORIZE,e)}"ALLOW_ACCESS"!==e.result||e.articleSharingEvent||n||Z.Em.publish(Z.Em.Event.DWELLTIME_CHECK,{}),t(e),window.addEventListener("ev.widgets.paywall.load",function(){t(e)}),window.addEventListener("ev.widgets.notifier.load",function(){t(e)})},pretty_print:function(e){return"<pre>"+JSON.stringify(e,null,3).replace(/&/g,"&amp;").replace(/\\"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/gm,Z.Em.replacer)+"</pre>"},replacer:function(e,t,n,o,r){t=t||"";return n&&(t=t+"<span class=json-key>"+n.replace(/[": ]/g,"")+"</span>: "),(t=o?t+('"'==o[0]?"<span class=json-string>":"<span class=json-value>")+o+"</span>":t)+(r||"")},segment:function(t,n,o){Z.Em.assert(t,"Parameters should not be empty!"),Z.Em.assert(n,"Success callback should not be empty!"),Z.Em.assert(o,"Error callback should not be empty!");var t=w("/segment",function(e){var t,n="";for(t in e=JSON.parse(e))""!==n&&(n+="&"),n+=t+"="+encodeURIComponent(e[t]);return n}(t)),r=new XMLHttpRequest;r.open("GET",t,!0),r.withCredentials=!0,r.onload=function(){var e;200<=r.status&&r.status<400?(e=JSON.parse(r.responseText),a.resolve(e),n(e)):o&&o(r.status,r.responseText)},r.onerror=function(){e?o(e):o(0,"unknown connection error")},r.send()},assert:function(e,t){if(!e){if(t=t||"Assertion failed","undefined"!=typeof Error)throw new Error(t);throw t}},getUrl:function(){return ee.url},showMeteredContent:function(){var e=document.getElementsByClassName("ev-meter-content");[].forEach.call(e,function(e){e.style.display="block"})},hideMeteredContent:function(){var e=document.getElementsByClassName("ev-meter-content");[].forEach.call(e,function(e){e.style.display="none"})}},setTimeout(function(){h()},4e3);var l=";SameSite=None; Secure";function f(e,t,n){if(!ee.sidCookieDomain)throw new Error("Please specify sidCookieDomain in the config!",!0);var o=new Date;n=1460,o.setDate(o.getDate()+n),(i=b())&&i<13?(document.cookie=e+"="+escape(t)+";time="+new Date+";expires="+o.toUTCString()+";path=/; domain="+ee.sidCookieDomain+"; Secure",console.log(e+"="+escape(t)+";time="+new Date+";expires="+o.toUTCString()+";path=/; domain="+ee.sidCookieDomain+"; Secure")):(document.cookie=e+"="+escape(t)+";time="+new Date+";expires="+o.toUTCString()+";path=/; domain="+ee.sidCookieDomain+l,console.log(e+"="+escape(t)+";time="+new Date+";expires="+o.toUTCString()+";path=/; domain="+ee.sidCookieDomain+l))}function g(e){return""!==te(e)&&"undefined"!==te(e)&&te(e)}function E(e){return""!==ne(e,"localStorage")&&"undefined"!==ne(e,"localStorage")&&ne(e,"localStorage")}function b(){var e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return null!=e&&(e=[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||0,10)],parseFloat(e.join(".")))}function ne(e,t){var n=document.cookie.indexOf(e+"=");if("localStorage"==t){if("undefined"==typeof localStorage)return 0<document.cookie.length&&-1!==n?getCookieSubstring(n,e):"";try{return localStorage.getItem(e)}catch(e){return console.warn("Could not retrieve the cookie in local storage - maybe the browser's running on an environment with restricted access to localStorage?"),"undefined"}}if("sessionStorage"==t){if("undefined"==typeof sessionStorage)return n=document.cookie.indexOf(e+"="),0<document.cookie.length&&-1!==n?getCookieSubstring(n,e):"";console.log(sessionStorage.getItem(e));try{return sessionStorage.getItem(e)}catch(e){return console.warn("Could not retrieve the cookie in session storage - maybe the browser's running on an environment with restricted access to sessionStorage?"),"undefined"}}}function S(e,t,n,o){var r=new Date;if("localStorage"==o)if(r.setDate(r.getDate()+n),"undefined"!=typeof localStorage)try{localStorage.setItem(e,t)}catch(e){console.warn("Could not store the cookie in local storage - maybe the browser's running on an environment with restricted access to localStorage?")}else i=b(),document.cookie=i&&i<13?e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+r.toUTCString())+"; Secure":e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+r.toUTCString())+l;if("sessionStorage"==o)if(r.setDate(r.getDate()+n),"undefined"!=typeof sessionStorage)try{sessionStorage.setItem(e,t)}catch(e){console.warn("Could not store the cookie in session storage - maybe the browser's running on an environment with restricted access to sessionStorage?")}else i=b(),document.cookie=i&&i<13?e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+r.toUTCString())+"; Secure":e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+r.toUTCString())+l}function v(e){document.cookie=e+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function w(e,t){!function(){if(!ee)throw"Evolok Metering library is not initialised!"}();var n=ee.url;if(!n)throw new Error("Evolok Metering host url is not configured!");return"/"===n.charAt(n.length-1)&&"/"===e.charAt(0)?n+=e.substring(1,e.length):n+=e,n=t?n+"?"+t:n}function _(){var n=this;this.promise=new Promise(function(e,t){n.reject=t,n.resolve=e})}window.customElements.define("ev-engagement",function(){_inherits(n,_wrapNativeSuper(HTMLElement));var t,e=_createSuper(n);function n(){return _classCallCheck(this,n),e.apply(this,arguments)}return _createClass(n,[{key:"registerCloseModal",value:function(){var t=this;"notifier"===this.widgetType?(this.allowBackgroundClickClosing()&&(window.onclick=function(e){"ev-em-modal-backdrop"===e.target.id&&t.closeModal()}),Z.Em.on(Z.Em.Event.NOTIFIER_CLOSE,this.closeModal.bind(this))):Z.Em.on("ev.em.paywall.close",this.closeModal.bind(this))}},{key:"allowBackgroundClickClosing",value:function(){return null==this.getAttribute("modal-backdrop")||"false"!==this.getAttribute("modal-backdrop")}},{key:"getGroupName",value:function(){return this.getAttribute("group-name")}},{key:"closeModal",value:function(){null!=document.querySelector("#engagement-top")&&document.querySelector("#engagement-top").parentElement.remove(),document.body.style.overflow=null}},{key:"setModalContent",value:function(){window.closeModal=this.closeModal;var e=document.createElement("div");document.body.prepend(e),document.body.style.overflow="hidden",e.innerHTML='\n                <div id="engagement-top" class="ev-em-modals ev-em-modal">\n                    <div class="ev-em-modal-dialog ev-em-modal-'.concat(this.widgetResponse.modalSize,'">\n                        <div class="ev-em-modal-content">\n                            <div class="ev widget-container ev-engagement">\n                                <div class="ev-').concat(this.widgetType,'-template">\n                                    ').concat(this.widgetResponse.content,'\n                                </div>\n                            </div>\n                        </div>\n                    </div>\n                    <div id="ev-em-modal-backdrop" class="ev-em-modal-backdrop"></div>\n                </div>'),this.renderContent()}},{key:"setInlineContent",value:function(){this.innerHTML='\n                        <div class="ev widget-container ev-engagement">\n                            <div class="ev-'.concat(this.widgetType,'-template">\n                                ').concat(this.widgetResponse.content,"\n                            </div>\n                        </div>"),this.renderContent()}},{key:"renderContent",value:function(){var e;null==Z.Widgets||"function"!=typeof Z.Widgets.asyncInit||this.isArticleSharingEngagement?this.publishRenderedEvents():(e=this,Z.Widgets.asyncInit().then(function(){console.log("EV widgets initialized from ev-em library"),e.publishRenderedEvents()}));for(var t=document.querySelectorAll("script[data-ev-engagement]"),n=0;n<t.length;n++){var o=t[n],r=document.createElement("script");r.innerHTML=o.text,document.body.appendChild(r)}}},{key:"publishRenderedEvents",value:function(){var e={ev_sid:this.ev_sid,template:this.widgetResponse},t="notifier"===this.widgetType?Z.Em.Event.NOTIFIER_MODAL_RENDERED:Z.Em.Event.PAYWALL_MODAL_RENDERED;Z.Em.publish(t,e)}},{key:"connectedCallback",value:function(){var e=this.getAttribute("article-sharing");this.isArticleSharingEngagement=null!=e&&"true"===e;o?this.internalWidgetDisplay(o):Z.Em.on(Z.Em.Event.AD_AUTHORIZE,this.internalWidgetDisplay.bind(this)),this.isArticleSharingEngagement?Z.Em.on(Z.Em.Event.CLOSE_ARTICLE_SHARING_MODAL,this.closeModal.bind(this)):Z.Em.enableDwellTime&&Z.Em.on(Z.Em.Event.DWELLTIME_CHECK,this.dwellTimeCheckEvents.bind(this))}},{key:"internalWidgetDisplay",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,o,r,i,a,s,c,l,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(Z.Em.enableDwellTime&&this.blockDwellTimeRequests)return e.abrupt("return");e.next=2;break;case 2:if(n=t.detail,this.isArticleSharingEngagement&&!n.articleSharingEvent||!this.isArticleSharingEngagement&&n.articleSharingEvent)return e.abrupt("return");e.next=5;break;case 5:if(n.articleUrl&&(this.articleUrl=n.articleUrl,this.articleId=n.articleId),this.ev_sid=n.sessionId||n.restoredSessionId,o=n.deviceId||te("ev_did")||ne("ev_did","localStorage"),r=n.hasOwnProperty("loggedOut")&&!1===n.loggedOut,i=n.hasOwnProperty("abGroup")?n.abGroup.name:null,a=n.hasOwnProperty("abGroup")?n.abGroup.value:null,s=(s=this.getMeter(n))||{count:null,max:null},!this.isArticleSharingEngagement||null==this.widgetResponse){e.next=17;break}c=this.widgetResponse,e.next=29;break;case 17:if("ALLOW_ACCESS"===n.result)return l=n.dwellTimeInterval,e.next=21,this.getNotifierWidget(s,n.segments||[],o,l,r,i,a);e.next=24;break;case 21:c=e.sent,e.next=29;break;case 24:return this.blockDwellTimeRequests=!0,u=n.requireEntitlement?"REQUIRE_LOGIN_WITH_ENTITLEMENT":"REQUIRE_LOGIN"===n.result?"REQUIRE_LOGIN":"REQUIRE_ENTITLEMENT",e.next=28,this.getPaywallWidget(s,u,n.segments||[],o,r,i,a);case 28:c=e.sent;case 29:c&&(this.widgetResponse=c,window.widgetResponse=c,u="notifier"===this.widgetType?Z.Em.Event.NOTIFIER_MODAL_RENDERED:Z.Em.Event.PAYWALL_MODAL_RENDERED,Z.Em.on(u,this.initLinkTracking.bind(this)),c.autoRender&&this.displayEngagement());case 30:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"getMeter",value:function(e){return e.activeMeter||e.exceededMeter||e.offeredMeter}},{key:"displayEngagement",value:function(){var e;this.notifierDisplayed&&!this.isArticleSharingEngagement||(this.trackDwellTime||(this.notifierDisplayed=!0),null!=this.widgetResponse.dwellTime&&0<this.widgetResponse.dwellTime&&this.closeModal(),e="notifier"===this.widgetType?Z.Em.Event.NOTIFIER_OPENED:Z.Em.Event.PAYWALL_OPENED,Z.Em.publish(e,this.widgetResponse),Z.Em.publish("ev.em.open.modal.".concat(this.widgetType,".").concat(this.widgetResponse.displayOn)),this.widgetResponse.modal?(this.setModalContent(),this.registerCloseModal()):this.setInlineContent(),Z.Em.publish(Z.Em.Event.ARTICLE_URL,{articleUrl:this.articleUrl,articleId:this.articleId}),Z.Em.publish(Z.Em.Event.OPEN_PRODUCT_SELECTION,this))}},{key:"getPaywallWidget",value:function(e,t,n,o,r,i,a){var s=this,o="".concat(ee.url,"/widgets/templates/paywall?ev_sid=").concat(this.ev_sid,"&ev_did=").concat(o),a={count:e.count,total:e.max,displayOn:t,segments:n,groupName:this.getGroupName(),loggedIn:r,brand:Z.Em.brand,abGroupName:i,abGroupValue:a};return this.post(o,a).then(function(e){return e&&(s.widgetType="paywall",s.handleManualRenderEvents(e,"paywall")),e})}},{key:"getNotifierWidget",value:function(e,t,n,o,r,i,a){var s=this,n="".concat(ee.url,"/widgets/templates/notifier?ev_sid=").concat(this.ev_sid,"&ev_did=").concat(n),a={count:e.count,total:e.max,segments:t,dwellTime:o,groupName:this.getGroupName(),loggedIn:r,brand:Z.Em.brand,abGroupName:i,abGroupValue:a};return e.hasOwnProperty("viewed")&&(a.viewed=e.viewed),this.post(n,a).then(function(e){return e&&(s.widgetType="notifier",s.handleManualRenderEvents(e,"notifier")),e})}},{key:"post",value:function(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return 200===e.status?e.json():null})}},{key:"handleManualRenderEvents",value:function(e,t){var n;e.hasOwnProperty("autoRender")&&!1===e.autoRender&&(n="notifier"===t?Z.Em.Event.NOTIFIER_SHOW_CTA:Z.Em.Event.PAYWALL_SHOW_CTA,Z.Em.on(n,this.displayEngagement.bind(this)));t="notifier"===t?Z.Em.Event.NOTIFIER_RENDER_READY:Z.Em.Event.PAYWALL_RENDER_READY;Z.Em.publish(t,e)}},{key:"initLinkTracking",value:function(e){var t,n=e.detail,o=_createForOfIteratorHelper(document.querySelector(".ev-engagement").querySelectorAll("a[href]"));try{for(o.s();!(t=o.n()).done;){var r=t.value;r.dataset.widgetuid=n.template.uid,r.dataset.sessionid=n.ev_sid,r.addEventListener("click",this.trackLink.bind(this))}}catch(e){o.e(e)}finally{o.f()}}},{key:"trackLink",value:function(e){e.preventDefault();var t=e.target,n=(t="a"!==t.tagName.toLowerCase()?t.closest("a"):t).innerText,o=t.href,e=t.dataset.widgetuid,t=t.dataset.sessionid;this.storeLinkTracking(t,e,n,o).then(function(e){window.location=o}).catch(function(e){console.log(e),window.location=o})}},{key:"storeLinkTracking",value:function(e,t,n,o){e="".concat(ee.url,"/widgets/templates/linkTracking?ev_sid=").concat(e);return this.post(e,{templateUid:t,linkName:n,linkValue:o})}},{key:"dwellTimeCheckEvents",value:function(){var t=this,n={dwellTimeTrackingEnabled:!1};this.checkDwellTimeWidgetsActive().then(function(e){e?(t.trackDwellTime=!0,n.dwellTimeTrackingEnabled=!0,n.maxDwellTimeRequests=e.maxDwellTimeRequests||3):console.warn("No dwell time widgets found"),Z.Em.publish(Z.Em.Event.DWELLTIME_WIDGETS_ENABLED,n)}).catch(function(e){console.error("Error checking dwell time widgets:",e)})}},{key:"checkDwellTimeWidgetsActive",value:function(){var e="".concat(ee.url,"/widgets/templates/dwellTime?groupName=").concat(this.getGroupName());return fetch(e,{headers:{"Content-Type":"application/json"}}).then(function(e){return 200===e.status?e.json():null})}}]),n}()),window.customElements.define("ev-content-recommendations",function(){_inherits(n,_wrapNativeSuper(HTMLElement));var e,t=_createSuper(n);function n(){return _classCallCheck(this,n),t.apply(this,arguments)}return _createClass(n,[{key:"connectedCallback",value:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n,o,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=null!=this.getAttribute("all-brands")&&"true"===this.getAttribute("all-brands"),n=this.getAttribute("query-params"),o=te("ev_sid")||ne("ev_sid","localStorage"),o="".concat(ee.url,"/content/recommendations?ev_sid=").concat(o),!t&&Z.Em.brand&&(o+="&brand=".concat(Z.Em.brand)),ee.recency&&(o+="&recency=".concat(ee.recency)),ee.section&&(o+="&section=".concat(ee.section)),e.next=9,fetch(o).then(function(e){return 200===e.status?e.json():null});case 9:o=e.sent,r="",o.recommendations.forEach(function(e){n&&(e.contentUrl=(e.contentUrl.includes("?")?"".concat(e.contentUrl,"&"):"".concat(e.contentUrl,"?")).concat(n)),r+='\n                <article class="ev-content-item">\n                    <div class="ev-content-item-thumbnail">\n                        '.concat(e.thumbnailUrl?'\n                            <img src="'.concat(e.thumbnailUrl,'" width="120" height="67">\n                        '):"",'\n                    </div>\n                    <div class="ev-content-item-title">\n                        <a href="').concat(e.contentUrl,'">').concat(e.title,'</a>\n                    </div>\n\x3c!--                    <div class="ev-em-product-selection">This is aa sen</div>--\x3e\n\n                </article>\n            ')}),this.innerHTML='\n                <div class="ev-content-recommendations">\n                    '.concat(r,"\n                </div>");case 13:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})}]),n}()),window.customElements.define("ev-em-profile-when",function(){_inherits(t,_wrapNativeSuper(HTMLElement));var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"connectedCallback",value:function(){this.displayStyle=this.getAttribute("display-style")||"block";var e=this;for(this.customHtml=this.innerHTML;this.firstChild;)this.removeChild(this.firstChild);Z.Em.on(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,this.initRenderElement.bind(this)),Z.Em.on(Z.Em.Event.GET_PROFILE_DATA_SUCCESS,function(){e.resetHtml("LoggedIn")}),Z.Event&&Z.Event.on(Z.Event.LOGOUT_ACTION,function(){e.resetHtml("LoggedOut")})}},{key:"resetHtml",value:function(e){this.responseState=e,this.responseState===this.state&&(this.style.display=this.displayStyle),this.responseState!==this.state&&(this.style.display="none");e=this.customHtml;for(this.tempFullHtmlStr=this.innerHTML;this.firstChild;)this.removeChild(this.firstChild);this.setCustomHtmlVar(),this.tempFullHtmlStr=this.tempFullHtmlStr.replace(e,this.customHtml),this.insertAdjacentHTML("beforeend",this.tempFullHtmlStr)}},{key:"setCustomHtmlVar",value:function(){if(this.userProfileData=sessionStorage.getItem("evolok:ev_profile"),this.userProfileData=JSON.parse(JSON.parse(this.userProfileData)),this.userProfileData){if(!this.customHtml&&this.innerHTML&&this.firstChild)for(this.customHtml=this.innerHTML;this.firstChild;)this.removeChild(this.firstChild);for(var n=this.customHtml,e=[],t=0,o=Object.entries(this.userProfileData);t<o.length;t++)var r=_slicedToArray(o[t],2),r=(r[0],r[1]),e=[].concat(_toConsumableArray(e),_toConsumableArray(r.attributes));(e=e.filter(function(t,e,n){return n.findIndex(function(e){return e.name===t.name})===e})).forEach(function(e){var t="user."+e.name;n.includes(t)&&(t=new RegExp(t,"g"),n=n.replace(t,e.value))}),this.customHtml=n}}},{key:"initRenderElement",value:function(e){this.responseState=e.detail,this.state=this.getAttribute("state"),this.state&&(this.setCustomHtmlVar(),this.mainParent=document.createElement("div"),this.responseState!==this.state&&(this.style.display="none"),this.responseState===this.state&&(this.style.display=this.displayStyle),this.mainParent.className="container-fluid ev-em-profile-when",(e=document.createElement("div")).className="row",e.insertAdjacentHTML("beforeend",this.customHtml),this.mainParent.appendChild(e),this.appendChild(this.mainParent))}}]),t}()),window.customElements.define("ev-em-product-selection",function(){_inherits(o,_wrapNativeSuper(HTMLElement));var t,e,n=_createSuper(o);function o(){return _classCallCheck(this,o),n.apply(this,arguments)}return _createClass(o,[{key:"connectedCallback",value:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:window.addEventListener("ev.ad.authorize",this.initRendering.bind(this)),Z.Em.on(Z.Em.Event.OPEN_PRODUCT_SELECTION,this.initRendering.bind(this));case 2:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})},{key:"initRendering",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,o,r,i,a,s,c,w,_,l,T,u,O,I,d,A,C,N,L,m,k,P,R,D,U,x,M,G,H,j,F,p,h,f,g,E,v,W,y,q,J,b,S,B,V,K,Q,z,Y,X=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(Y=function(){return(Y=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=p+"/countries",e.next=3,fetch(t).then(function(e){return 200===e.status?e.json():null}).then(function(e){return console.log("getCountries:",e),e});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}},e)}))).apply(this,arguments)},z=function(){return Y.apply(this,arguments)},Q=function(){return(Q=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){var o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=p+"/region/",o+=t?"?countryId="+t:"?countryName="+n,e.next=4,fetch(o).then(function(e){return 200===e.status?e.json():null}).then(function(e){return console.log("getRegion:",e),E=e});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)},K=function(e,t){return Q.apply(this,arguments)},V=function(){if(m)return z().then(function(e){e.find(function(e){return f&&f.country?e.id===f.country?e.name:void 0:e.name===g})&&K()})},B=function(e,t,n,o){e=o?Number(Number(e)+Number(o)).toFixed(2):e;var r=0,i=0;if(t&&0!==t.value)switch(t.type){case"PERCENTAGE":r=Number(Number(e)*Number(t.value)/100).toFixed(2);break;case"AMOUNT":r=Number(t.value).toFixed(2);break;default:throw"Discount type '"+t.type+"' is unknown!"}var a=Number(e)-Number(r);if(n&&0!==n.value)switch(n.type){case"PERCENTAGE":i=Number(Number(a)*Number(n.value)/100).toFixed(2);break;case"AMOUNT":i=Number(n.value).toFixed(2);break;default:throw"Tax type '"+n.type+"' is unknown!"}o=Number(a)+Number(i);return o<0?0:o},S=function(e,t){return B(e.price,e.discount&&0<e.discount.value&&0===e.discount.period.numberOfDays?e.discount:null,e.tax,t)},b=function(e,t){return!e.discount||e.discount&&0===e.discount.period.numberOfDays?0:B(e.price,e.discount,e.tax,t)},J=function(e){return e.trialPrice},q=function(t){var e,n;return t.regions&&0<t.regions.length&&E?(n=E.deliveryItems.find(function(e){return e.currency.id===t.currency.id}))&&(e=(t.trialPrice?b:S)(t,n.deliveryCost)):e=t.trialPrice||t.finalPrice,e=I&&t.promoDiscounts&&0<t.promoDiscounts.length?t.finalPrice:e},y=function(e){var t=e.querySelector(".product-footer"),n=document.createElement("div");n.className="row product-footer-spacer";var o=window.getComputedStyle(t),o=parseInt(o.getPropertyValue("padding-bottom").replace("px",""));n.style.minHeight=t.offsetHeight+o+"px",e.insertBefore(n,t)},W=function(e){var t=0,n=document.querySelectorAll(e);if(e.includes("product-wrapper"))for(var o=0;o<n.length;o++)y(n[o]);Array.prototype.map.call(n,function(e){e.clientHeight>t&&(t=e.clientHeight)});for(var r=0;r<n.length;r++)n[r].style.minHeight=t+"px"},(n=document.createElement("div")).innerHTML=window.widgetResponse.content,o=n.querySelectorAll("ev-em-product-selection"),r=[],o){i=_createForOfIteratorHelper(o);try{for(i.s();!(a=i.n()).done;)s=a.value,r.push(s.id)}catch(e){i.e(e)}finally{i.f()}}if(setTimeout(function(){window.widgetResponse=null,n.innerHTML=null},0),r.includes(this.id)){e.next=20;break}return e.abrupt("return");case 20:if(u=t.detail,c=u.sessionId||u.restoredSessionId||te("ev_sid")||ne("ev_sid","localStorage"),h=ee.pmUrl||this.getAttribute("pm-domain"),w=this.getAttribute("subscribe-url-prefix"),_=this.getAttribute("subscribe-btn-text")||"Select",l=this.getAttribute("product-name"),T=this.getAttribute("payment-plans"),u=this.getAttribute("product-group"),O=this.getAttribute("bundle-plans"),I=this.getAttribute("promo-code"),d="true"===this.getAttribute("display-vertical-products"),A="true"===this.getAttribute("display-horizontal-plans"),C="true"===this.getAttribute("show-plan-name"),N="true"===this.getAttribute("hide-plan-description"),L=this.getAttribute("translation-plan-frequency")?JSON.parse(this.getAttribute("translation-plan-frequency").replace(/'/g,'"')):{NONE:"One-off",DAY1:"Daily",WEEK1:"Weekly",MONTH1:"Monthly",MONTH3:"Quarterly",MONTH6:"Biannual",MONTH12:"Yearly",MONTH18:"Sesquiennial"},m="true"===this.getAttribute("show-delivery-country"),k="true"===this.getAttribute("show-boosted-text"),P=this.getAttribute("basic-text")||"Basic Plan",R=this.getAttribute("recommended-text")||"Recommended",D="true"===this.getAttribute("auto-select"),x=this.getAttribute("button-url-prefix")||_,M=this.getAttribute("button-url-value")||"btn-selected",G=parseInt(this.getAttribute("product-limit"))||"All",H="true"===this.getAttribute("discount-display-name"),j="true"===this.getAttribute("discount-offer-description"),F="true"===this.getAttribute("discount-offer-text"),p=h+"/widget",h||w||l||u){e.next=49;break}throw"Metering Library Error: Trying to use product selection but check that all required attributes are specified: [pm-domain, subscribe-url-prefix, product-name, product-group]";case 49:return h=new URLSearchParams(window.location.search),f=Object.fromEntries(h.entries()),g=f&&f.defaultCountry||this.getAttribute("default-country"),V(),l?v=p+"/product/".concat(l,"?ev_sid=").concat(c):u&&(v=p+"/productgroup/".concat(u,"?ev_sid=").concat(c)),e.next=56,fetch(v).then(function(e){return 200===e.status?e.json():null}).then(function(y){if(!y)throw"Metering Library Error: Product/s info is empty";var b=[];y.products?b=y.products:b.push(y),$=b;var e=new URLSearchParams(window.location.search).has("isSWGDiffLogPage");e&&Z.Em.swgSubscribe("",e),"All"!==G&&G&&b.splice(G);var S,n=X;function t(){"All"!==G&&G&&b.splice(G),(S=document.createElement("div")).className="container-fluid ev-em-product-selection";var p=document.createElement("div");p.className="row";var h,f=d?12:Math.round(12/b.length),t=_createForOfIteratorHelper(b);try{var g,E,v,e=function(){var s=h.value;"BUNDLE"===s.type&&O?(n=s.bundlePlans.findIndex(function(e){return e.name===O}),s.paymentPlans.push(s.bundlePlans[n]),s.paymentPlans.forEach(function(e){return e.isBundle=!0})):"BUNDLE"===s.type&&(s.paymentPlans=s.bundlePlans,s.paymentPlans.forEach(function(e){return e.isBundle=!0}));var e=document.createElement("div");e.id="product-"+s.name,e.className="col-lg-"+f+" col-md-"+f+" col-sm-12 col-xs-12 product-item-container";var t=document.createElement("div");t.className="container-fluid product-wrapper";var n,o=document.createElement("div");o.className="row product-header",k&&s.id===y.recommended?(y.recommended,e.classList.add("recommended-product"),(n=document.createElement("div")).className="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-boosted",n.innerText=R,o.appendChild(n)):k&&((r=document.createElement("div")).className="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-basic",r.innerText=P,o.appendChild(r));var r=document.createElement("div");r.className="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-title",r.innerText=s.displayName,o.appendChild(r),t.appendChild(o);var c=document.createElement("div");c.className="row product-body",T&&(u=0<(a=s.paymentPlans.filter(function(e){return Object.values(e).some(function(e){return"string"==typeof e&&e.toLowerCase()===T.toLowerCase()})})).length?a:s.paymentPlans,s.paymentPlans=u);var l,i=_createForOfIteratorHelper(s.paymentPlans);try{for(i.s();!(l=i.n()).done;)!function(){var n=l.value,e=A?Math.round(12/s.paymentPlans.length):12,t=document.createElement("div");t.id="payment-plan-"+s.name+"-"+n.name,t.className="col-lg-"+e+" col-md-"+e+" col-sm-12 col-xs-12 payment-plan-container",D&&s.id===y.recommended?n.id===s.autoSelectPlan&&(U={planName:n.name,productName:s.name,promoDiscounts:n.promoDiscounts},t.classList.add("payment-plan-selected")):D&&!y.recommended&&(U||n.id!==s.autoSelectPlan&&1!==s.paymentPlans.length||(U={planName:n.name,productName:s.name,promoDiscounts:n.promoDiscounts},t.classList.add("payment-plan-selected")));var o=document.createElement("div");o.className="payment-plan-price";e=document.createElement("span");e.className="payment-currency-symbol",e.innerText=n.currency.symbol,o.innerHTML=e.outerHTML+q(n),t.appendChild(o);var r,i,a,o=document.createElement("div");o.className="payment-plan-frequency",o.innerText=L[n.frequency.id],t.appendChild(o),I&&n.promoDiscounts&&0<n.promoDiscounts.length&&((r=document.createElement("div")).className="discount-plan-price",(o=document.createElement("span")).className="payment-currency-symbol-discount",o.innerText=n.currency.symbol,r.innerHTML=o.outerHTML+J(n),t.appendChild(r)),I&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].displayName&&H&&((r=document.createElement("div")).className="promo-code-display-name",r.innerText=n.promoDiscounts[0].displayName,t.appendChild(r)),I&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].offerDescription&&j&&((i=document.createElement("div")).className="promo-code-offer-description",i.innerText=n.promoDiscounts[0].offerDescription,t.appendChild(i)),I&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].offerText&&F&&((i=document.createElement("div")).className="promo-code-offer-text",i.innerText=n.promoDiscounts[0].offerText,t.appendChild(i)),C&&((a=document.createElement("div")).className="payment-plan-name",a.innerText=n.displayName,t.appendChild(a)),N||((a=document.createElement("div")).className="payment-plan-description",a.innerText=n.description,t.appendChild(a)),n.externalIds.GOOGLE&&((E=document.createElement("div")).className="swg-container",(v=document.createElement("button")).id="button-swg-"+n.name,E.appendChild(v),t.appendChild(E),(g=Z.Em.getSwgSubscriptions()).attachButton(v,{theme:"light"},function(){g.subscribe(n.externalIds.GOOGLE)})),t.addEventListener("click",function(e){U={planName:n.name,productName:s.name,promoDiscounts:n.promoDiscounts};var t=document.querySelector(".payment-plan-selected");t&&t.classList.remove("payment-plan-selected"),e.currentTarget.classList.add("payment-plan-selected")}),c.appendChild(t)}()}catch(e){i.e(e)}finally{i.f()}o=document.createElement("div");o.className="row product-footer";var a=document.createElement("div");a.className="col-lg-12 col-md-12 col-sm-12 col-xs-12";var u=document.createElement("button"),d=b.indexOf(s)+1;u.className="btn btn-default product-select-btn",u.innerText=_;var m=(w.includes("?")?"&":"?").concat(x,"=").concat(M).concat(d);u.addEventListener("click",function(){var e;console.log("The select button ".concat(_," with index ").concat(d," was clicked!")),U&&U.productName===s.name?(e=w+m+"&productName="+s.name+"&paymentPlans="+U.planName,U.promoDiscounts&&0<U.promoDiscounts.length&&I&&(e+="&promoCode="+I),window.location=e):window.location=w+m+"&productName="+s.name}),a.appendChild(u),o.appendChild(a),t.appendChild(c),t.appendChild(o),e.appendChild(t),p.appendChild(e),S.appendChild(p)};for(t.s();!(h=t.n()).done;)e()}catch(e){t.e(e)}finally{t.f()}n.appendChild(S),W(".payment-plan-container"),W(".product-wrapper")}I&&1===b.length?(e=p+"/product/promocode/"+b[0].name+"?promoCode="+I,fetch(e).then(function(e){return e.ok||(I=null,t()),e.json()}).then(function(o){console.log(o),b[0].paymentPlans.forEach(function(t,e){var n=o.find(function(e){return e.id===t.id});n&&(b[0].paymentPlans[e]=n)}),t(),Z.Em.publish(Z.Em.Event.PM_PROMO_ACTION,b[0])}).catch(function(e){console.log(e),I=null,t()})):t(),Z.Em.publish(Z.Em.Event.PRODUCT_SELECTION_LOADED,b)});case 56:e.sent;case 57:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})}]),o}()),window.customElements.define("ev-share-article-btn",function(){_inherits(t,_wrapNativeSuper(HTMLElement));var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"connectedCallback",value:function(){Z.Em.on(Z.Em.Event.ARTICLE_DATA,this.storeArticleData.bind(this));var e=this.getAttribute("widget-count");this.widgetCount=null!=e?parseInt(e):1;e=this.getAttribute("share-article-group");this.articleShareGroup=e||"ShareArticle";e=this.getAttribute("share-button-text");this.shareBtnText=e||"Share Article",this.innerHTML='\n                <div>\n                    <button class="share-article-btn">'.concat(this.shareBtnText,'</button>\n                </div>\n                <ev-engagement group-name="').concat(this.articleShareGroup,'" article-sharing="true"></ev-engagement>\n            '),this.style.display="none",this.querySelector(".share-article-btn").addEventListener("click",this.openShareArticleModal.bind(this))}},{key:"storeArticleData",value:function(e){console.log(e.detail),this.articleUrl=e.detail.articleUrl,this.articleId=e.detail.articleId}},{key:"openShareArticleModal",value:function(){console.log("share article button clicked");var e={result:"ALLOW_ACCESS",sessionId:te("ev_sid")||ne("ev_sid","localStorage"),activeMeter:{count:this.widgetCount,max:100},articleSharingEvent:!0,articleUrl:this.articleUrl,articleId:this.articleId};Z.Em.paywallAndNotifierEvents(e)}}]),t}()),window.customElements.define("ev-share-article",function(){_inherits(t,_wrapNativeSuper(HTMLElement));var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"connectedCallback",value:function(){Z.Em.on(Z.Em.Event.ARTICLE_URL,this.storeArticleUrl.bind(this));var e=this.getAttribute("hide-email-input");this.hideEmailInput=null!=e&&"true"===e;e=this.getAttribute("email-label-text");this.emailLabelText=e||"Recipient Email";e=this.getAttribute("share-button-text");this.shareButtonText=e||"Share",this.innerHTML='\n                <div class="ev-share-article-template">\n                    <div style="display: '.concat(this.hideEmailInput?"none":"block",'">\n                        <label for="articleShareEmail">').concat(this.emailLabelText,'</label>\n                        <input id="ev-article-share-email" type="text">\n                    </div>\n\n                    <button class="share-submit-btn">').concat(this.shareButtonText,"</button>\n\n                </div>"),this.querySelector(".share-submit-btn").addEventListener("click",this.shareArticle.bind(this))}},{key:"storeArticleUrl",value:function(e){this.articleUrl=e.detail.articleUrl,this.articleId=e.detail.articleId}},{key:"shareArticle",value:function(){var e=document.querySelector("#ev-article-share-email").value;Z.Em.shareArticle({articleUrl:this.articleUrl,articleId:this.articleId,email:e})}}]),t}()),Z.Em.on(Z.Em.Event.AD_AUTHORIZE,function(e){o=e})}(window.EV);