vendor: 4,485 bytes, lines 1-7
1/** 2 * @license ev-em.js v3.4.4 eugenDev 21/11/25 google fedcm migration no warning 3 * (c) 2015-2025 Evolok, Inc. https://www.evolok.com/ 4 * 5 * License: MIT 6 */ 7var 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.forEac
7h(_),!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)} 8"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 r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}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 r=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(n);return _possibleConstructorReturn(this,r?(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");
8if(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 r=[null];r.push.apply(r,t);r=new(Function.bind.apply(e,r));return n&&_setPrototypeOf(r,n.prototype),r}).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=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function asyncGeneratorStep(e,t,n,r,o,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(r,o)}function _asyncToGenerator(s){return function(){var e=this,a=arguments;return new Promise(function(t,n){var r=s.apply(e,a);function o(e){asyncGeneratorStep(r,t,n,o,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,o,i,"throw",e)}o(void 0)})}}function _createForOfIteratorHelper(e,t){var n,r;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 o=0,t=function(){};return{s:t,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:(r=function(e){throw e},i.toString=function(){return r.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 r.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,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}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)).forEac
8h(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 u,$,ee,d,m,i,p=new O,a=new O,n=!1,r=0,o=0,h={},s=0,c=0,l=!1,f=Promise.resolve(),g=!1;window.addEventListener("ev.widgets.dwelltime.enabled",function(e){e.detail.dwellTimeTrackingEnabled&&(n=!0,o=e.detail.maxDwellTimeRequests||3,setTimeout(function(){Z.Em.initDwellTimeRequests(h.authorizeData)},1e3))});var v,t,y=(v="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 "+v+"="+e+" evolok.api.secureSessionId="+t:(t=ne("ev_ss"),"Evolok "+v+"="+e+" evolok.api.sessionId="+t)});function E(){d&&(ee.disableCookies||te("ev_sid")==d||(w("ev_sid",d),C("ev_sid",d,0,"localStorage"))),m&&(ee.disableCookies||te("ev_did")==m||(w("ev_did",m),C("ev_did",m,0,"localStorage")))}function te(e){for(var t=(t=document.cookie).split("; "),n={},r=0;r<t.length;r++){var o=t[r].split("=");n[o[0]]=o[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",SWG_REQUIRE_LINKING:"swg.require.linking",REGISTRATION_FAILED:"registration.failed",REGISTRATION_SUCCESS:"registration.success",REGISTRATION_CANCEL:"registration.cancel",LOGIN_SUCCESS:"login.success",LOGIN_FAILED:"login.failed",SCROLL_DEPTH_REACHED:"ev.em.scroll.depth.reached"},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!";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("autoLinkIdentifierEncode")&&!1===e.autoLinkIdentifierEncode?this.autoLinkIdentifierEncode=!1:this.autoLinkIdentifierEncode=!0,e.hasOwnProperty("GTMDataLayerEnabled")&&(this.GTMDataLayerEnabled=e.GTMDataLayerEnabled),e.hasOwnProperty("enableDwellTime")&&(this.enableDwellTime=e.enableDwellTime,!0===this.enableDwellTime&&Z.Em.publish("generateDwellCheckListener")),e.hasOwnProperty("cookieExpireTime")&&(this.cookieExpireTime=e.cookieExpireTime),e.hasOwnProperty("getUserData")&&(this.getUserData=e.getUserData),(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();var t=te("ev_ss"),e=JSON.parse(localStorage.getItem("evolok:ev_session"));localStorage.getItem("evolok:ev_profile");t?e?e.mainSession.sessionId!==t&&(localStorage.removeItem("evolok:ev_session"),sessionStorage.removeItem("evolok:ev_profile"),Z.Em.getEVSessionNetworkCall()):t&&!e&&Z.Em.getEVSessionNetworkCall():(localStorage.removeItem("evolok:ev_session"),sessionStorage.removeItem("evolok:ev_profile"),A("ex_ss"))},getEVSessionNetworkCall:function(){var e=te("ev_ss");if(ee.icDomain)var t=ee.icDomain,t=(t.startsWith("https")?"".concat(t,"/session/"):"https://".concat(ee.icDomain,"/session/")).concat(e);else{if(!ee.domainName)return void console.log("missing icDomain or domainName properties");t="https://".concat(ee.domainName,"/ic/api/session/").concat(e)}ee.serviceName?(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){console.log(e),localStorage.setItem("evolok:ev_session",JSON.stringify(e)),sessionStorage.getItem("evolok:ev_profile")||Z.Em.getUserProfileData(!1)}).catch(function(e){console.error("There was a problem with getting session details:",e)})):console.log("missing service name")},entitlementsFlow:function(n,e,t){var r,a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;function o(){var e="https://".concat(ee.domainName,"/ic/api/social/").concat(r.guid),t={Accept:"application/json",Authorization:"Evolok evolok.api.service=".concat(ee.serviceName," evolok.api.sessionId=").concat(r.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,r):Z.Em.publish(Z.Em.Event.SWG_REQUIRE_LINKING,"user needs google account linking to perform the deffered swg subscription")}
8).catch(function(e){console.error("There was a problem with checking the account linking:",e)})}function i(t,e){0!==a.entitlements.length?function(n,e){purchaseData=JSON.parse(e.entitlements[0].subscriptionToken),skus=purchaseData.productId;var i=purchaseData.purchaseToken;return new Promise(function(o,e){if(!ee.pmUrl)return console.log("no pmUrl specified"),void o(!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)o(!1);else if(0!==e.length){var t,n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;if("SUBSCRIBE_WITH_GOOGLE"===r.paymentType&&"ACTIVE"===r.status||r.externalId===i)return void o(!0)}}catch(e){n.e(e)}finally{n.f()}console.log("Swg purchase not found for logged in user on Evolok side"),o(!1)}else o(!1);else o(!1)}).catch(function(e){console.log(e,"error getting purchases"),o(!0)})})}(e.mainSession.sessionId,a).then(function(e){console.log("Purchases checked:",e),e||t.completeDeferredAccountCreation({entitlements:a,consent:!0}).then(function(e){$?Z.Em.swgSubscribe(a,!1,e):function(n){var e,t=te("ev_sid")||ne("ev_sid","localStorage"),r=ee.productName,o=ee.productGroupName;if(ee.pmUrl){var i=ee.pmUrl+"/widget";if(r)e=i+"/product/".concat(r,"?ev_sid=").concat(t);else{if(!o)return console.log("no product name/group specified");e=i+"/productgroup/".concat(o,"?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(a,!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")}h.authorizeData.segments.includes("SWG_Subscriber")?console.log("User is swg subscriber by segment definition"):(r=e,ee.serviceName&&ee.enableGoogleOneTap&&ee.realmName?(e=te("ev_ss"),Z.Em.getEVSession()?t?o():i(n,r):(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){r=e,o()}).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,r;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(t){this.entitlements=t,r=t,console.log(this.entitlements),u?te("ev_ss")&&u&&(h.authorizeData=u.detail,Z.Em.entitlementsFlow(n,Z.Em.getEVSession(),!0,t)):Z.Em.on(Z.Em.Event.AD_AUTHORIZE,function(e){h.authorizeData=e.detail,te("ev_ss")&&Z.Em.entitlementsFlow(n,Z.Em.getEVSession(),!0,t)})}),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},this.getSwgEntitlements=function(){return r}},initGoogleApis:function(){var n,s,c,e,g=!1;function r(e){console.log("Google One Tap Response",e),e.network="google",l(e)}function l(e){var n,r,o,i,a,t=Z.Em.socialServiceName||Z.Em.serviceName,s=Z.Em.autoRegister||!0,c=Z.Em.autoPopulate||!1;n=Z.Em.realmName,r=t,o=s,i=c,a=e,new Promise(function(e,t){!function(t,u,e,n,r,o,d,m){var p=t.network||"google";if(t.hasOwnProperty("error")||t.hasOwnProperty("code")){var i=E(t,u,p);m(i)}else{var r={autoRegister:r||!0,autoPopulate:o||!0},h={};if(t.hasOwnProperty("credential")&&!g)Object.assign(t,{jwt:t.credential}),(h=t).client_id=ee.googleClientId,h.clientId=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(o&&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})}if(g){if(Z.Em.socialAttributeMapping)for(var c in Z.Em.socialAttributeMapping){c={name:c,value:Z.Em.socialAttributeMapping[c]};a.push(c)}else a.push({name:"email_address",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,r="https://".concat(Z.Em.icDomain,"/social/").concat(p,"/session?autoRegister=").concat(r.autoRegister,"&autoPopulate=").concat(r.autoPopulate),n={Accept:"application/json;charset=UTF-8","Content-Type":"application/json;charset=UTF-8",Authorization:y(n)};fetch(r,{method:"POST",headers:n,body:JSON.stringify(h)}).then(function(e){return f=t.headers,e.json()}).then(function(e){var t,n,r,o,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,r,o,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)):(o="true"===e.args[3],i=i.map(function(e){return e.toLowerCase()}),o?(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)}C("ev_auth_scheme",Z.Em.authSchemeName,0,"sessionStorage"),C("google_one_tap_attempted",JSON.stringify(a),0,"localStorage"),C("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),r=encodeURIComponent(a.googleOneTap.credential),o=encodeURIComponent(a.identifiers[0].name),i=encodeURIComponent(a.identifiers[0].value),s=encodeURIComponent(JSON.stringify(a.hideSocial)),c=encodeURIComponent(JSON.stringify(a.hideIcLogin)),i&&"string"==typeof i&&Z.Em.autoLinkIdentifierEncode&&(i=btoa(encodeURIComponent(i).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))),Z.Em.autoLinkLoginRedirectUrl="".concat(Z.Em.autoLinkLoginRedirectUrl).concat(Z.Em.autoLinkLoginRedirectUrl.includes("?")?"&":"?","network=").concat(t,"&google_client_id=").concat(n,"&credential=").concat(r,"&identifierName=").concat(o,"&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=E(e,u,p),m(a)):(t=e).hasOwnProperty("guid")&&(n=!1,t.hasOwnProperty("mainSession")&&(n=t.mainSession.hasOwnProperty("sessionCookie")?t.mainSession.sessionCookie:n,r=t.mainSession.hasOwnProperty("expiry")?t.mainSession.expiry:new Date),o=!1,!Z.Em.enableSeamlessMode||(a=f?f.get("X-EV-SSO"):void 0)&&(s=t,c=a,l=o=!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://",r=0;function o(){r===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(){r++,o()},e.onerror=function(){r++,o()}})}).then(function(){i=v(t,n,r,e,p,u),d(i)}
8)),o||(i=v(t,n,r,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,r,o,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 v(e,t,n,r,o,i){return function(e,t,n,r){Z.Em.assert(e,"Evolok session should not be empty!");var o,i,a="evolok:ev_session",s=Z.Em.ssoCookieDomain||window.location.hostname;r||(!Z.Em.disableCookies&&e&&e.hasOwnProperty("mainSession")&&u("ev_ss",e.mainSession.sessionId,{expireMillis:e.mainSession.expiry||n,domain:s}),!Z.Em.disableCookies&&Z.Em.secureModeEnabled&&e.hasOwnProperty("secureSession")&&u("ex_ss",e.secureSession.sessionId,{expireMillis:e.secureSession.expiry||n,domain:s}));(t?sessionStorage:localStorage).setItem(a,JSON.stringify(e));Z.Em.publish(Z.Em.Event.SESSION_SAVED,e),g&&Z.Em.generateOrder();ee.useSwg&&"function"==typeof Z.Em.getSwgSubscriptions&&"function"==typeof Z.Em.getSwgEntitlements&&(o=Z.Em.getSwgSubscriptions(),i=Z.Em.getSwgEntitlements());o&&!g&&Z.Em.entitlementsFlow(o,e,!1,i)}(e,t,n),Z.Em.publish(Z.Em.Event.SESSION_REFRESH,e),{network:o,statusCode:i,response:r}}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&&((r=new Date).setTime(n.expireMillis),t+="; time="+new Date+"; expires="+r.toGMTString()),n.domain&&n.domain!==document.domain){var r=n.domain.replace(/^\./,"");if(-1===document.domain.indexOf(r)||r.split(".").length<=1)throw Error("invalid domain");t+="; domain="+n.domain}n=T();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(";"),r=0;r<n.length;r++){for(var o=n[r];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""}function E(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 r=[],o=[],t={};if(n.forEach(function(e,t){e.products.forEach(function(e,t){r.push(e)})}),$.forEach(function(e,t){var n;e.externalIds&&e.externalIds.GOOGLE&&r.includes(e.externalIds.GOOGLE)&&(n=$[t]).paymentPlans.find(function(e){e.externalIds&&e.externalIds.GOOGLE&&e.externalIds.GOOGLE===skus&&(n.paymentPlan=e,o.push(n))})}),0===o.length||!o[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:o[0].paymentPlan.id,productId:o[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 o=d("ev_ss"),e="https://".concat(ee.domainName,"/pm/api/v2/widget/order?ev_ss=").concat(o);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,r;console.log("order created:",e),t=e,n=o,e="https://".concat(ee.domainName,"/pm/api/v2/widget/payment/").concat(t.id,"/subscription?ev_ss=").concat(n),r={swgOrderId:s.orderId,swgPurchaseToken:s.purchaseToken,swgPurchaseState:s.purchaseState},fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).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,r,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:r,use_fedcm_for_prompt:!0};if(null!==ee.googleGenericConf)for(var t in ee.googleGenericConf)e[t]=ee.googleGenericConf[t];google.accounts.id.initialize(e),google.accounts.id.prompt()}()},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,r,o=Z.Em.getEVSession();
8A("ev_ss"),A("ex_ss"),o&&(n=Z.Em.socialServiceName||Z.Em.serviceName,r=window.location.protocol+"//"+window.location.host,r={Accept:"application/json;charset=UTF-8","Content-Type":"application/json;charset=UTF-8",Authorization:y(n),Origin:r},Z.Em.deleteSession(o.mainSession.sessionId,r,null,e,t))})},deleteSession:function(e,t,n,r,o){Z.Em.assert(e,"Session ID should not be empty!");var i=ee.icDomain;function a(e){Z.Em.publish(Z.Em.Event.LOGOUT_SUCCESS,e),r(e)}e=(i.startsWith("https")?"".concat(i,"/session/"):"https://".concat(ee.icDomain,"/session/")).concat(e),Z.Em.delete(e,t,n).then(function(e){if(e.hasOwnProperty("statusCode")&&200==e.statusCode)if(Z.Em.clearAllSessions(),Z.Em.removeUserProfile(),localStorage.removeItem("evolok:ev_session"),sessionStorage.removeItem("evolok:ev_profile"),Z.Em.enableSeamlessMode){var t=e.headers?e.headers.get("X-EV-SSO"):void 0;if(!t)throw a(),new Error("Couldn't find the participating seamless sign-in domains");Z.Em.deleteSeamlessSession(t,!0).then(function(){a(e)})}else a(e);else a(e)},function(e){"SESSION_NOT_FOUND"==e.error.code?(Z.Em.clearAllSessions(),Z.Em.removeUserProfile(),a(e)):o(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://",r=0;function o(){r===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(){r++,o()},e.onerror=function(){r++,o()}})})},delete:function(t,n,e,r){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=r||{};r&&r.hasOwnProperty("serviceName")?e.serviceName=r.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,r=e.message||e.error&&e.error.message||e,o=[];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")?o=e.args:e.hasOwnProperty("error")&&(o=e.error.args),void a({code:n,message:r,statusCode:t,args:o})}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),A("ev_ss"),A("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 p.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=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=!1,n=document.getElementsByTagName("ev-em-profile-when"),r=localStorage.getItem("evolok:ev_session"),o=JSON.parse(JSON.parse(sessionStorage.getItem("evolok:ev_profile")))||{};if(r){var i,a=_createForOfIteratorHelper(n);try{for(a.s();!(i=a.n()).done;)"true"===i.value.getAttribute("getProfileEnable")&&(t=!0)}catch(e){a.e(e)}finally{a.f()}t||e?ee.serviceName in o||(e=(r=JSON.parse(r)).guid,o=r.secureSession.sessionId,r="Evolok evolok.api.service=".concat(ee.serviceName," evolok.api.secureSessionId=").concat(o),o=((o=ee.icDomain).startsWith("https")?"".concat(o,"/userProfile/"):"https://".concat(ee.icDomain,"/userProfile/")).concat(e,"?serviceName=").concat(ee.serviceName),fetch(o,{method:"GET",headers:{"Content-Type":"application/xml",Accept:"application/json",Authorization:r}}).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)}
8).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(a){var t,s,n,c,l,r,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=function(){var e={attributes:[]};if(ee.icDomain){var t=ee.icDomain;c=(t.startsWith("https")?"".concat(t,"/userProfile/"):"https://".concat(ee.icDomain,"/userProfile/")).concat(s,"/").concat(ee.profileServiceName)}else{if(!ee.domainName)return void console.log("missing icDomain or domainName properties");c="https://".concat(ee.domainName,"/ic/api/userProfile/").concat(s,"/").concat(ee.profileServiceName)}for(var n=0,r=Object.entries(a);n<r.length;n++){var o=_slicedToArray(r[n],2),i=o[0],o=o[1];e.attributes.push({name:i,value:o})}fetch(c,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:l},body:JSON.stringify(e)}).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)})},!document.cookie.match(new RegExp("(^| )ev_ss=([^;]+)"))){e.next=5;break}t=document.cookie.match(new RegExp("(^| )ev_ss=([^;]+)"))[2],e.next=7;break;case 5:return console.warn("Evolok Session not found, impossible to update user attributes"),e.abrupt("return");case 7:if(l="Evolok evolok.api.service=".concat(ee.profileServiceName," evolok.api.sessionId=").concat(t),!localStorage.getItem("evolok:ev_session")){e.next=13;break}s=JSON.parse(localStorage.getItem("evolok:ev_session")).guid,o(),e.next=31;break;case 13:if(!ee.icDomain){e.next=18;break}r=ee.icDomain,n=(r.startsWith("https")?"".concat(r,"/session/"):"https://".concat(ee.icDomain,"/session/")).concat(t),e.next=24;break;case 18:if(!ee.domainName){e.next=22;break}n="https://".concat(ee.domainName,"/ic/api/session/").concat(ev_ss),e.next=24;break;case 22:return console.log("missing icDomain or domainName properties"),e.abrupt("return");case 24:return e.next=26,fetch(n,{method:"GET",headers:{"Content-Type":"application/json",Authorization:l}});case 26:return r=e.sent,e.next=29,r.text().then(function(e){return(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("guid")[0].innerHTML});case 29:s=e.sent,o();case 31:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)}),trackScrollDepth:function(n){var r=!1;window.addEventListener("scroll",function(){var e,t;r||(e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight-window.innerHeight,n<=e/t*100&&(g=r=!0,console.log("Scroll depth ".concat(n,"% reached")),Z.Em.publish(Z.Em.Event.SCROLL_DEPTH_REACHED,n),h.authorizePayload.depthReached=n,Z.Em.authorize(JSON.stringify(h.authorizePayload),function(e){console.log("authorize res on depth:",e)},function(e){console.log("authorize err on depth:",e)})))})},authorize:function(e,r,o){Z.Em.assert(e,"Parameters should not be empty!"),Z.Em.assert(r,"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 n=new URLSearchParams(window.location.search);if(n.has(this.qrCodeQueryParam||Z.Em.qrCodeQueryParam)&&(e=(e=n.get(this.qrCodeQueryParam||Z.Em.qrCodeQueryParam)).split(" ").join("+"),t[this.qrCodeQueryParam||Z.Em.qrCodeQueryParam]=e),n.has(this.shareArticleTokenQueryParam)&&(c=(c=n.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;n.has(s)&&(t[s]=n.get(s))}}catch(e){a.e(e)}finally{a.f()}}t.ev_sid="",t.ev_did="",t.ev_ss="",!ee.disableCookies&&S("ev_sid")?(t.ev_sid=te("ev_sid"),C("ev_sid",te("ev_sid"),0,"localStorage")):!ee.disableCookies&&_("ev_sid")&&(ee.meterHD?!0===ee.meterHD&&(w("ev_sid",ne("ev_sid","localStorage")),t.ev_sid=ne("ev_sid","localStorage"),ee.meterHD):w("ev_sid",ne("ev_sid","localStorage"))),!ee.disableCookies&&S("ev_did")?(t.ev_did=te("ev_did"),C("ev_did",te("ev_did"),0,"localStorage")):!ee.disableCookies&&_("ev_did")&&(ee.meterHD?!0===ee.meterHD&&(w("ev_did",ne("ev_did","localStorage")),t.ev_did=ne("ev_did","localStorage")):w("ev_did",ne("ev_did","localStorage"))),""!==te("ev_ss")&&(t.ev_ss=te("ev_ss"));var c=N("/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,n;200<=l.status&&l.status<400?(n={},200!==l.status||l.responseText?n=JSON.parse(l.responseText):n.result="ALLOW_ACCESS",p.resolve(n),h.authorizeData=n,console.log(n),n.sessionKeys?(n.sessionKeys.ev_sid&&(d=n.sessionKeys.ev_sid,E()),n.sessionKeys.ev_did&&(m=n.sessionKeys.ev_did,n.deviceId=n.sessionKeys.ev_did,E())):n.deviceId=te("ev_did"),Z.Em.articleSharingHandler(n),Z.Em.paywallAndNotifierEvents(n),"REQUIRE_LOGIN"===n.result&&Z.Event&&(""!==te("ev_ss")&&Z.Event.publish("session.cleanup","Session has expired"),Z.Event.publish("login.required","Login is required")),"ALLOW_ACCESS"!=n.result&&Z.Em.hideMeteredContent(),Z.Em.GTMDataLayerEnabled&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({evAuthResponse:n})),!n.loggedOut&&void 0!==n.loggedOut||Z.Em.publish(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,"LoggedOut"),n.loggedOut||void 0===n.loggedOut||Z.Em.publish(Z.Em.Event.PROFILE_ACCESS_RENDER_STATUS,"LoggedIn"),!0!==ee.useSwg||u||te("ev_ss")&&(e=Z.Em.getSwgSubscriptions(),t=Z.Em.getSwgEntitlements(),Z.Em.entitlementsFlow(e,Z.Em.getEVSession(),!0,t)),r(n),n.ruleProperties&&n.ruleProperties.SDEPTH&&!g&&h.authorizePayload.articleId&&(n=Number(n.ruleProperties.SDEPTH),isNaN(n)||Z.Em.trackScrollDepth(n))):(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")},h.authorizePayload=t,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==o&&clearInterval(n)},3e4)},articleSharingHandler:function(e){var t,n=null!=e.articleSharingEnabled&&!0===e.articleSharingEnabled,r=_createForOfIteratorHelper(document.querySelectorAll("ev-share-article-btn"));try{for(r.s();!(t=r.n()).done;)t.value.style.display=n?"block":"none"}catch(e){r.e(e)}finally{r.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,"&").replace(/\\"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/gm,Z.Em.replacer)+"</pre>"},replacer:function(e,t,n,r,o){t=t||"";return n&&(t=t+"<span class=json-key>"+n.replace(/[": ]/g,"")+"</span>: "),(t=r?t+('"'==r[0]?"<span class=json-string>":"<span class=json-value>")+r+"</span>":t)+(o||"")},segment:function(t,n,r){Z.Em.assert(t,"Parameters should not be empty!"),Z.Em.assert(n,"Success callback should not be empty!"),Z.Em.assert(r,"Error callback should not be empty!");var t=N("/segment",function(e){var t,n="";for(t in e=JSON.parse(e))""!==n&&(n+="&"),n+=t+"="+encodeURIComponent(e[t]);return n}(t)),o=new XMLHttpRequest;o.open("GET",t,!0),o.withCredentials=!0,o.onload=function(){var e;200<=o.status&&o.status<400?(e=JSON.parse(o.responseText),a.resolve(e),n(e)):r&&r(o.status,o.responseText)},o.onerror=function(){e?r(e):r(0,"unknown connection error")},o.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"})},loginUser:function(e,t,n,r){var o;ee.icDomain&&ee.brand?(o=((o=ee.icDomain).startsWith("https")?"".concat(o,"/session/"):"https://".concat(ee.icDomain,"/session/")).concat(t),t={"Content-Type":"application/json",Accept:"application/json",Authorization:"Evolok evolok.api.service=".concat(t," evolok.api.sessionId=")},n={identifiers:[e.identifier],validators:[e.validator],rememberMe:!1,realmName:r,brand:ee.brand,channel:ee.channel||"WEB",authenticationSchemeName:n},fetch(o,{method:"POST",headers:t,body:JSON.stringify(n)}).then(function(e){return e.json()}).then(function(e){console.log("Response:",e),Z.Em.publish(Z.Em.Event.LOGIN_SUCCESS,e),w("ev_ss",(e=e).mainSession.sessionId),localStorage.setItem("evolok:ev_session",JSON.stringify(e)),Z.Em.publish(Z.Em.Event.SESSION_SAVED,e)}).catch(function(e){Z.Em.publish(Z.Em.Event.LOGIN_FAILED,e)})):console.log("icDomain or brand is not defined in EV.Em.init")}},setTimeout(function(){E()},4e3);var b=";SameSite=None; Secure";function w(e,t,n){if(!ee.sidCookieDomain)throw new Error("Please specify sidCookieDomain in the config!",!0);var r=new Date;n=1460,r.setDate(r.getDate()+n),(i=T())&&i<13?(document.cookie=e+"="+escape(t)+";time="+new Date+";expires="+r.toUTCString()+";path=/; domain="+ee.sidCookieDomain+"; Secure",console.log(e+"="+escape(t)+";time="+new Date+";expires="+r.toUTCString()+";path=/; domain="+ee.sidCookieDomain+"; Secure")):(document.cookie=e+"="+escape(t)+";time="+new Date+";expires="+r.toUTCString()+";path=/; domain="+ee.sidCookieDomain+b,console.log(e+"="+escape(t)+";time="+new Date+";expires="+r.toUTCString()+";path=/; domain="+ee.sidCookieDomain+b))}function S(e){return""!==te(e)&&"undefined"!==te(e)&&te(e)}function _(e){return""!==ne(e,"localStorage")&&"undefined"!==ne(e,"localStorage")&&ne(e,"localStorage")}function T(){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 C(e,t,n,r){var o=new Date;if("localStorage"==r)if(o.setDate(o.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=T(),document.cookie=i&&i<13?e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+o.toUTCString())+"; Secure":e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+o.toUTCString())+b;if("sessionStorage"==r)if(o.setDate(o.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=T(),document.cookie=i&&i<13?e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+o.toUTCString())+"; Secure":e+"="+escape(t)+(null===n?"":";time="+new Date+";expires="+o.toUTCString())+b}function A(t){var e;document.cookie.split(";").some(function(e){return e.trim().startsWith(t+"=")}
8)&&(document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",e=window.location.hostname.split(".").slice(-2).join("."),document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=."+e+"; path=/;")}function N(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 O(){var n=this;this.promise=new Promise(function(e,t){n.reject=t,n.resolve=e})}window.customElements.define("ev-engagement",function(){_inherits(r,_wrapNativeSuper(HTMLElement));var t,e,n=_createSuper(r);function r(){return _classCallCheck(this,r),n.apply(this,arguments)}return _createClass(r,[{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(){this.publishRenderedEvents();for(var e=document.querySelectorAll("script[data-ev-engagement]"),t=0;t<e.length;t++){var n=e[t],r=document.createElement("script");r.innerHTML=n.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:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getAttribute("article-sharing"),this.isArticleSharingEngagement=null!=t&&"true"===t,n=this,u)return 0===s&&(s=document.querySelectorAll("ev-engagement").length,console.log("Total ev-engagement tags:",s)),e.next=7,this.queueRequest(u);e.next=9;break;case 7:e.next=10;break;case 9:Z.Em.on(Z.Em.Event.AD_AUTHORIZE,function(e){0===s&&(s=document.querySelectorAll("ev-engagement").length,console.log("Total ev-engagement tags:",s)),r.queueRequest(e)});case 10:this.isArticleSharingEngagement?Z.Em.on(Z.Em.Event.CLOSE_ARTICLE_SHARING_MODAL,this.closeModal.bind(this)):Z.Em.on("generateDwellCheckListener",function(){Z.Em.on(Z.Em.Event.DWELLTIME_CHECK,n.dwellTimeCheckEvents.bind(n))});case 11:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})},{key:"queueRequest",value:function(r){var o=this;return new Promise(function(t,n){f=f.then(_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o.internalWidgetDisplay(r);case 3:c+=1,console.log("Completed engagement get call:",c),c!==s||l||(c=s=0,console.log("All API requests completed."),o.initiateWidgets()),t(),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),n(e.t0);case 12:case"end":return e.stop()}},e,null,[[0,9]])})))})}},{key:"initiateWidgets",value:function(){null!=Z.Widgets&&"function"==typeof Z.Widgets.asyncInit&&(console.log("Calling EV.Widgets.asyncInit..."),Z.Widgets.asyncInit().then(function(){console.log("EV widgets initialized from ev-em library"),l=!0}
8).catch(function(e){console.error("Error in EV.Widgets.asyncInit:",e)}))}},{key:"internalWidgetDisplay",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,r,o,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,r=n.deviceId||te("ev_did")||ne("ev_did","localStorage"),o=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||[],r,l,o,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||[],r,o,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,r,o,i,a){var s=this,r="".concat(ee.url,"/widgets/templates/paywall?ev_sid=").concat(this.ev_sid,"&ev_did=").concat(r),a={count:e.count,total:e.max,displayOn:t,segments:n,groupName:this.getGroupName(),loggedIn:o,brand:Z.Em.brand,abGroupName:i,abGroupValue:a};return this.post(r,a).then(function(e){return e&&(s.widgetType="paywall",s.handleManualRenderEvents(e,"paywall")),e})}},{key:"getNotifierWidget",value:function(e,t,n,r,o,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:r,groupName:this.getGroupName(),loggedIn:o,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,r=_createForOfIteratorHelper(document.querySelector(".ev-engagement").querySelectorAll("a[href]"));try{for(r.s();!(t=r.n()).done;){var o=t.value;o.dataset.widgetuid=n.template.uid,o.dataset.sessionid=n.ev_sid,o.addEventListener("click",this.trackLink.bind(this))}}catch(e){r.e(e)}finally{r.f()}}},{key:"trackLink",value:function(e){e.preventDefault();var t=e.target,n=(t="a"!==t.tagName.toLowerCase()?t.closest("a"):t).innerText,r=t.href,e=t.dataset.widgetuid,t=t.dataset.sessionid;this.storeLinkTracking(t,e,n,r).then(function(e){window.location=r}).catch(function(e){console.log(e),window.location=r})}},{key:"storeLinkTracking",value:function(e,t,n,r){e="".concat(ee.url,"/widgets/templates/linkTracking?ev_sid=").concat(e);return this.post(e,{templateUid:t,linkName:n,linkValue:r})}},{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})}}]),r}()),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)}
8return _createClass(n,[{key:"connectedCallback",value:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n,r,o;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"),r=te("ev_sid")||ne("ev_sid","localStorage"),r="".concat(ee.url,"/content/recommendations?ev_sid=").concat(r),!t&&Z.Em.brand&&(r+="&brand=".concat(Z.Em.brand)),ee.recency&&(r+="&recency=".concat(ee.recency)),ee.section&&(r+="§ion=".concat(ee.section)),e.next=9,fetch(r).then(function(e){return 200===e.status?e.json():null});case 9:r=e.sent,o="",r.recommendations.forEach(function(e){n&&(e.contentUrl=(e.contentUrl.includes("?")?"".concat(e.contentUrl,"&"):"".concat(e.contentUrl,"?")).concat(n)),o+='\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(o,"\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)}
8return _createClass(t,[{key:"connectedCallback",value:function(){this.displayStyle=this.getAttribute("display-style")||"block";var e=this;for(this.rendered=!1,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,r=Object.entries(this.userProfileData);t<r.length;t++)var o=_slicedToArray(r[t],2),o=(o[0],o[1]),e=[].concat(_toConsumableArray(e),_toConsumableArray(o.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.rendered||(this.rendered=!0,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-login",function(){_inherits(o,_wrapNativeSuper(HTMLElement));var n,e,t,r=_createSuper(o);function o(){return _classCallCheck(this,o),r.apply(this,arguments)}return _createClass(o,[{key:"connectedCallback",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:Z.Em.on(Z.Em.Event.AD_AUTHORIZE,this.fetchTemplateAndCreateForm.bind(this)),h.authorizeData&&this.fetchTemplateAndCreateForm();case 2:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"fetchTemplateAndCreateForm",value:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.showLabels="true"===this.getAttribute("show-labels"),this.serviceName=this.getAttribute("service-name")||ee.serviceName,this.authSchemeName=this.getAttribute("auth-scheme-name")||ee.authSchemeName,this.realmName=this.getAttribute("realm-name")||ee.realmName,this.icDomain=this.getAttribute("ic-domain")||ee.icDomain,this.showCancelBtn="true"===this.getAttribute("show-cancel-btn"),this.showErrorMsgs="true"===this.getAttribute("show-error-msgs"),this.showHeader="false"!==this.getAttribute("show-header"),this.title=this.getAttribute("title")||"Login",this.submitBtnText=this.getAttribute("submitbtn-caption")||"Login",this.cancelBtnText=this.getAttribute("cancelbtn-caption")||"Cancel",this.invalidPropertyErrorText=this.getAttribute("invalid-property-error")||"Invalid Input",void 0!==ee&&ee.icDomain&&ee.realmName&&this.serviceName&&this.authSchemeName){e.next=15;break}return console.error("Missing configuration: _config, _config.icDomain, _config.realmName, or _config.serviceName"),e.abrupt("return");case 15:return n="https://".concat(this.icDomain,"/ui/template/login/").concat(this.authSchemeName,"?serviceName=").concat(this.serviceName,"&realmName=").concat(this.realmName),e.prev=16,e.next=19,fetch(n);case 19:if((t=e.sent).ok){e.next=22;break}throw new Error("Error fetching template: ".concat(t.statusText));case 22:return e.next=24,t.json();case 24:n=e.sent,this.loginTemplate=n,this.generateLoginForm(n),e.next=32;break;case 29:e.prev=29,e.t0=e.catch(16),console.error("Failed to fetch template:",e.t0);case 32:case"end":return e.stop()}},e,this,[[16,29]])}
8)),function(){return e.apply(this,arguments)})},{key:"generateLoginForm",value:function(e){var t,r=this,n=document.createElement("form");n.className="ev-em-login-form",this.showHeader&&((t=document.createElement("div")).className="form-header",t.innerText=this.title,n.appendChild(t)),this.showErrorMsgs&&((a=document.createElement("div")).className="form-error-message",a.style.display="none",a.style.color="red",n.formErrorMessage=a,n.appendChild(a));var o=document.createElement("div");function i(e){var t=e.target,n=t.pattern?new RegExp(t.pattern):null,e=t.nextElementSibling;n?n.test(t.value)?(t.style.backgroundColor="",e.style.display="none"):(t.style.backgroundColor="#ffe7e7",e.style.display="block"):t.style.backgroundColor=""}o.className="input-fields-section",e.identifiers&&e.identifiers.forEach(function(e){var t=document.createElement("div");t.className="em-attribute-container",t.setAttribute("name",e.name),r.showLabels&&((n=document.createElement("label")).textContent=e.label,t.appendChild(n));var n=document.createElement("input");n.type="email",n.name=e.name,n.placeholder=e.description,e.mandatory&&(n.required=!0),e.validationList&&0<e.validationList.length&&(n.pattern=e.validationList[0]["evolok-regex-pattern"]);e=document.createElement("span");e.style.display="none",e.style.color="red",e.textContent=r.invalidPropertyErrorText,n.addEventListener("input",i),t.appendChild(n),t.appendChild(e),o.appendChild(t)}),e.validators&&e.validators.forEach(function(e){var t=document.createElement("div");t.className="em-attribute-container",t.setAttribute("name",e.name),r.showLabels&&((n=document.createElement("label")).textContent=e.label,t.appendChild(n));var n=document.createElement("input");n.type="password",n.name=e.name,n.placeholder=e.description,e.mandatory&&(n.required=!0),e.validationList&&0<e.validationList.length&&(n.pattern=e.validationList[0]["evolok-regex-pattern"]);e=document.createElement("span");e.style.display="none",e.style.color="red",e.textContent=r.invalidPropertyErrorText,n.addEventListener("input",i),t.appendChild(n),t.appendChild(e),o.appendChild(t)});var a=document.createElement("div");a.className="em-button-panel";e=document.createElement("button");e.type="submit",e.textContent=this.submitBtnText,a.appendChild(e),this.showCancelBtn&&((e=document.createElement("button")).type="button",e.textContent=this.cancelBtnText,e.addEventListener("click",function(){n.reset(),Z.Em.publish(Z.Em.Event.LOGIN_CANCEL,"Login Canceled")}),a.appendChild(e)),n.appendChild(o),n.appendChild(a),this.appendChild(n),n.addEventListener("submit",function(){var t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),n.checkValidity()){e.next=6;break}return r.showErrorMsgs&&(n.formErrorMessage.textContent="Please fill all required fields correctly.",n.formErrorMessage.style.display="block"),e.abrupt("return");case 6:r.showErrorMsgs&&(n.formErrorMessage.style.display="none");case 7:return e.next=9,r.handleLoginSubmission(new FormData(n),n);case 9:case"end":return e.stop()}},e)}));return function(e){return t.apply(this,arguments)}}())}},{key:"handleLoginSubmission",value:(n=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){var r,o,i,a,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,s=Object.fromEntries(t.entries()),(r=Object.entries(s)).length<2)throw new Error("Missing form fields");e.next=5;break;case 5:return a=_slicedToArray(r[0],2),o=a[0],i=a[1],s=_slicedToArray(r[1],2),a=s[0],s=s[1],e.next=9,Z.Em.loginUser({identifier:{name:o,value:i},validator:{name:a,value:s}},this.serviceName,this.authSchemeName,this.realmName);case 9:n.reset(),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(0),this.showErrorMsgs&&(n.formErrorMessage.textContent="Login failed: ".concat(e.t0.message),n.formErrorMessage.style.display="block"),n.reset(),console.error("Login failed:",e.t0);case 17:case"end":return e.stop()}},e,this,[[0,12]])})),function(e,t){return n.apply(this,arguments)})}]),o}()),window.customElements.define("ev-em-registration",function(){_inherits(o,_wrapNativeSuper(HTMLElement));var n,e,t,r=_createSuper(o);function o(){return _classCallCheck(this,o),r.apply(this,arguments)}
8return _createClass(o,[{key:"connectedCallback",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:Z.Em.on(Z.Em.Event.AD_AUTHORIZE,this.fetchTemplateAndCreateForm.bind(this)),Z.Em.on(Z.Em.Event.OPEN_PRODUCT_SELECTION,this.fetchTemplateAndCreateForm.bind(this));case 2:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"fetchTemplateAndCreateForm",value:(e=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.showLabels="true"===this.getAttribute("show-labels"),this.serviceName=this.getAttribute("service-name")||ee.serviceName,this.authSchemeName=this.getAttribute("auth-scheme-name")||ee.authSchemeName,this.realmName=this.getAttribute("realm-name")||ee.realmName,this.icDomain=this.getAttribute("ic-domain")||ee.icDomain,this.idv="false"===this.getAttribute("idv"),this.showCancelBtn="true"===this.getAttribute("show-cancel-btn"),this.showErrorMsgs="true"===this.getAttribute("show-error-msgs"),this.confirmValidators="false"!==this.getAttribute("confirm-validators"),this.showHeader="false"!==this.getAttribute("show-header"),this.title=this.getAttribute("title")||"Registration",this.hiddenAttributes=this.getAttribute("hidden-attributes"),this.autoGeneratePassword="true"===this.getAttribute("auto-generate-password"),this.autoLogin="true"===this.getAttribute("auto-login"),this.submitBtnText=this.getAttribute("submitbtn-caption"),this.cancelBtnText=this.getAttribute("cancelbtn-caption"),this.invalidPropertyErrorText=this.getAttribute("invalid-property-error"),this.notMatchErrorText=this.getAttribute("not-match-error"),this.validatorConfirmationValid=!this.confirmValidators,this.hiddenAttributes){this.hiddenAttributes=this.hiddenAttributes.replace(/'/g,'"');try{this.hiddenAttributes=JSON.parse(this.hiddenAttributes)}catch(e){console.error("Invalid JSON for hidden-attributes:",e),this.hiddenAttributes={}}}else this.hiddenAttributes={};if(this.matchedHiddenAttributes={},void 0!==ee&&ee.icDomain&&ee.realmName&&this.serviceName){e.next=24;break}return console.error("Missing configuration: _config, _config.icDomain, _config.realmName, or _config.serviceName"),e.abrupt("return");case 24:return n=(this.idv?"https://".concat(this.icDomain,"/ui/template/registration/null/").concat(this.serviceName,"?bypassAuthScheme=true&serviceName="):"https://".concat(this.icDomain,"/ui/template/registration/").concat(this.authSchemeName,"/").concat(this.serviceName,"?serviceName=")).concat(this.serviceName,"&realmName=").concat(this.realmName),e.prev=25,e.next=28,fetch(n);case 28:if((t=e.sent).ok){e.next=31;break}throw new Error("Error fetching template: ".concat(t.statusText));case 31:return e.next=33,t.json();case 33:n=e.sent,this.registrationTemplate=n,this.generateForm(n),e.next=41;break;case 38:e.prev=38,e.t0=e.catch(25),console.error("Failed to fetch template:",e.t0);case 41:case"end":return e.stop()}},e,this,[[25,38]])})),function(){return e.apply(this,arguments)})},{key:"generatePassword",value:function(e){for(var e=e.validationList[0]["evolok-regex-pattern"],t=new RegExp(e),n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+",r="";""===r||!t.test(r);)for(var r="",o=0;o<8;o++)r+=n.charAt(Math.floor(Math.random()*n.length));return r}},{key:"generateForm",value:function(r){var i=this,t=Object.keys(this.hiddenAttributes);r.identifiers&&(r.identifiers=r.identifiers.filter(function(e){return!t.includes(e.name)||(i.matchedHiddenAttributes[e.name]=i.hiddenAttributes[e.name],!1)})),r.validators&&(r.validators=r.validators.filter(function(e){return!t.includes(e.name)||(i.matchedHiddenAttributes[e.name]=i.hiddenAttributes[e.name],!1)})),r.attributes&&(r.attributes=r.attributes.filter(function(e){return!t.includes(e.name)||(i.matchedHiddenAttributes[e.name]=i.hiddenAttributes[e.name],!1)}));var e,o=document.createElement("form");o.className="ev-em-registration-form",this.showHeader&&((e=document.createElement("div")).className="form-header",e.innerText=this.title,o.appendChild(e)),this.showErrorMsgs&&((n=document.createElement("div")).className="form-error-message",n.style.display="none",n.style.color="red",o.formErrorMessage=n,o.appendChild(n));var a=document.createElement("div");a.className="identifiers-section";var s=document.createElement("div");s.className="validators-section";var c=document.createElement("div");function l(e){var t=e.target,n=t.pattern?new RegExp(t.pattern):null,e=t.nextElementSibling;n?n.test(t.value)?(t.style.backgroundColor="",e.style.display="none"):(t.style.backgroundColor="#ffe7e7",e.style.display="block"):t.style.backgroundColor="",r.validators&&r.validators[0]&&t.n
8ame===r.validators[0].name&&u()}function u(){var e=o.querySelector("input[name=".concat(r.validators[0].name,"]")),t=o.querySelector("input[name=confirm_".concat(r.validators[0].name,"]")),n=t.nextElementSibling;t.value===e.value?(t.style.backgroundColor="",n.style.display="none",this.validatorConfirmationValid=!0):(t.style.backgroundColor="#ffe7e7",n.style.display="block",this.validatorConfirmationValid=!1)}c.className="attributes-section",u=u.bind(this),null!==r.identifiers&&r.identifiers.forEach(function(e){var t=document.createElement("div");t.className="em-attribute-container",t.setAttribute("name",e.name),i.showLabels&&((n=document.createElement("label")).textContent=e.label,t.appendChild(n));var n=document.createElement("input");n.type=e.name.toLowerCase().includes("email")?"email":"text",n.name=e.name,n.placeholder=e.description,e.mandatory&&(n.required=!0),e.validationList&&0<e.validationList.length&&(n.pattern=e.validationList[0]["evolok-regex-pattern"]);e=document.createElement("span");e.style.display="none",e.style.color="red",e.textContent=i.invalidPropertyErrorText||"Invalid property",i.showLabels&&(e.style.marginLeft="35%"),n.addEventListener("input",l),t.appendChild(n),t.appendChild(e),a.appendChild(t)}),null!==r.validators&&(this.autoGeneratePassword?(d=r.validators[0],this.passAttributeName=r.validators[0].name,this.generatedPassword=this.generatePassword(d)):r.validators.forEach(function(e){var t=document.createElement("div");t.className="em-attribute-container",t.setAttribute("name",e.name),i.showLabels&&((o=document.createElement("label")).textContent=e.label,t.appendChild(o));var n=document.createElement("input");n.type="password",n.name=e.name,n.placeholder=e.description,e.mandatory&&(n.required=!0),e.validationList&&0<e.validationList.length&&(n.pattern=e.validationList[0]["evolok-regex-pattern"]);var r,o=document.createElement("span");o.style.display="none",o.style.color="red",o.textContent=i.invalidPropertyErrorText||"Invalid property",i.showLabels&&(o.style.marginLeft="35%"),n.addEventListener("input",l),t.appendChild(n),t.appendChild(o),s.appendChild(t),i.confirmValidators&&((t=document.createElement("div")).className="em-attribute-container",t.setAttribute("name","confirm_".concat(e.name)),i.showLabels&&((r=document.createElement("label")).textContent="Confirm ".concat(e.label),t.appendChild(r)),(r=document.createElement("input")).type="password",r.name="confirm_".concat(e.name),r.placeholder="Confirm ".concat(e.description),r.required=!0,(e=document.createElement("span")).style.display="none",e.style.color="red",e.textContent=i.notMatchErrorText||"Passwords do not match",i.showLabels&&(e.style.marginLeft="35%"),r.addEventListener("input",u),t.appendChild(r),t.appendChild(e),s.appendChild(t))})),r.attributes.forEach(function(e){var t=document.createElement("div");t.className="em-attribute-container",t.setAttribute("name",e.name),i.showLabels&&((n=document.createElement("label")).textContent=e.label,t.appendChild(n));var n=document.createElement("input");n.type="text",n.name=e.name,n.placeholder=e.description,e.mandatory&&(n.required=!0),e.validationList&&0<e.validationList.length&&(n.pattern=e.validationList[0]["evolok-regex-pattern"]);e=document.createElement("span");e.style.display="none",e.style.color="red",e.textContent=i.invalidPropertyErrorText||"Invalid property",n.addEventListener("input",l),t.appendChild(n),t.appendChild(e),c.appendChild(t)});var n=document.createElement("div");n.className="em-button-panel";var d=document.createElement("button");d.type="submit",d.textContent=this.submitBtnText||"Register",n.appendChild(d),this.showCancelBtn&&((d=document.createElement("button")).type="button",d.textContent=this.cancelBtnText||"Cancel",d.addEventListener("click",function(){o.reset(),Z.Em.publish(Z.Em.Event.REGISTRATION_CANCEL,"Cancel Registration")}),n.appendChild(d)),o.appendChild(a),o.appendChild(s),o.appendChild(c),o.appendChild(n),this.appendChild(o),o.addEventListener("submit",function(){var t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),i.validatorConfirmationValid||!r.validators||i.autoGeneratePassword){e.next=4;break}return i.showErrorMsgs&&(o.formErrorMessage.textContent=r.validators[0].name+" does not match",o.formErrorMessage.style.display="block"),e.abrupt("return");case 4:if(o.checkValidity()){e.next=9;break}return i.showErrorMsgs&&(o.formErrorMessage.textContent="Please fill all required attributes.",o.formErrorMessage.style.display="block"),e.abrupt("return");case 9:i.showErrorMsgs&&(o.formErrorMessage.style.display="none");case 10:return e.next=12,i.handleFormSubmission(new FormData(o),o);case 12:case"end":return e.stop()}},e)}));return function(e){return t.apply(this,arguments)}}())}},{key:"handleFormSubmission",value:(n=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){var r,o,i,a,s,c,l,u,d,m,p,h,f=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(l=Object.fromEntries(t.entries()),r=Object.entries(l).filter(function(e){return!_slicedToArray(e,1)[0].startsWith("confirm_")}).map(function(e){e=_slicedToArray(e,2);return{name:e[0],value:e[1]}}),this.autoGeneratePassword&&r.push({name:this.passAttributeName,value:this.generatedPassword}),o=0,i=Object.entries(this.matchedHiddenAttributes);o<i.length;o++)s=_slicedToArray(i[o],2),a=s[0],s=s[1],r.push({name:a,value:s});return d={attributes:r,brand:ee.brand,channel:ee.channel,realm:ee.realmName,services:[this.serviceName]},console.log("Payload for API:",d),e.prev=6,e.next=9,fetch("https://".concat(this.icDomain,"/userProfile"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Evolok evolok.api.service=".concat(this.serviceName)},body:JSON.stringify(d)});case 9:return c=e.sent,e.next=12,c.text();case 12:u=e.sent,l=function(e){var e=(new DOMParser).parseFromString(e,"application/xml"),t={};
8return e.documentElement.childNodes.forEach(function(e){1===e.nodeType&&(t[e.nodeName]=e.textContent)}),t},c.ok?(d=l(u),console.log("User created successfully:",d),this.showErrorMsgs&&(n.formErrorMessage.style.display="none"),n.reset(),Z.Em.publish(Z.Em.Event.REGISTRATION_SUCCESS,d),this.autoLogin&&!this.idv&&(0<(null===(d=this.registrationTemplate.identifiers)||void 0===d?void 0:d.length)?p=r.find(function(e){return e.name===f.registrationTemplate.identifiers[0].name}):0<(null===(m=this.registrationTemplate.attributes)||void 0===m?void 0:m.length)&&(p=this.registrationTemplate.attributes[0]),0<(null===(m=this.registrationTemplate.validators)||void 0===m?void 0:m.length)&&(h=r.find(function(e){return e.name===f.registrationTemplate.validators[0].name})),p&&h?Z.Em.loginUser({identifier:{name:p.name,value:p.value},validator:{name:h.name,value:h.value}},this.serviceName,this.authSchemeName,this.realmName):console.error("Auto-login failed: Missing identifier or password."))):(u=l(u),this.showErrorMsgs&&(n.formErrorMessage.textContent="Error creating user: ".concat(u.code||"Unknown error"),n.formErrorMessage.style.display="block"),Z.Em.publish(Z.Em.Event.REGISTRATION_FAILED,u)),e.next=22;break;case 17:e.prev=17,e.t0=e.catch(6),this.showErrorMsgs&&(n.formErrorMessage.textContent="Error creating user: ".concat(e.t0.message),n.formErrorMessage.style.display="block"),console.error("Error creating user:",e.t0),Z.Em.publish(Z.Em.Event.REGISTRATION_FAILED,e.t0);case 22:case"end":return e.stop()}},e,this,[[6,17]])})),function(e,t){return n.apply(this,arguments)})}]),o}()),window.customElements.define("ev-em-product-selection",function(){_inherits(r,_wrapNativeSuper(HTMLElement));var t,e,n=_createSuper(r);function r(){return _classCallCheck(this,r),n.apply(this,arguments)}return _createClass(r,[{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,r,o,i,a,s,c,S,_,l,T,u,C,A,d,N,O,k,I,m,L,R,D,P,x,U,M,G,H,F,j,p,h,f,g,v,E,q,y,W,V,b,w,J,B,z,K,Q,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)},Q=function(){return Y.apply(this,arguments)},K=function(){return(K=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=p+"/region/",r+=t?"?countryId="+t:"?countryName="+n,e.next=4,fetch(r).then(function(e){return 200===e.status?e.json():null}).then(function(e){return console.log("getRegion:",e),v=e});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)},z=function(e,t){return K.apply(this,arguments)},B=function(){if(m)return Q().then(function(e){e.find(function(e){return f&&f.country?e.id===f.country?e.name:void 0:e.name===g})&&z()})},J=function(e,t,n,r){e=r?Number(Number(e)+Number(r)).toFixed(2):e;var o=0,i=0;if(t&&0!==t.value)switch(t.type){case"PERCENTAGE":o=Number(Number(e)*Number(t.value)/100).toFixed(2);break;case"AMOUNT":o=Number(t.value).toFixed(2);break;default:throw"Discount type '"+t.type+"' is unknown!"}var a=Number(e)-Number(o);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!"}r=Number(a)+Number(i);return r<0?0:r},w=function(e,t){return J(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:J(e.price,e.discount,e.tax,t)},V=function(e){return e.trialPrice},W=function(t){var e,n;return t.regions&&0<t.regions.length&&v?(n=v.deliveryItems.find(function(e){return e.currency.id===t.currency.id}))&&(e=(t.trialPrice?b:w)(t,n.deliveryCost)):e=t.trialPrice||t.finalPrice,e=A&&t.promoDiscounts&&0<t.promoDiscounts.length?t.finalPrice
8:e},y=function(e){var t=e.querySelector(".product-footer"),n=document.createElement("div");n.className="row product-footer-spacer";var r=window.getComputedStyle(t),r=parseInt(r.getPropertyValue("padding-bottom").replace("px",""));n.style.minHeight=t.offsetHeight+r+"px",e.insertBefore(n,t)},q=function(e){var t=0,n=document.querySelectorAll(e);if(e.includes("product-wrapper"))for(var r=0;r<n.length;r++)y(n[r]);Array.prototype.map.call(n,function(e){e.clientHeight>t&&(t=e.clientHeight)});for(var o=0;o<n.length;o++)n[o].style.minHeight=t+"px"},(n=document.createElement("div")).innerHTML=window.widgetResponse.content,r=n.querySelectorAll("ev-em-product-selection"),o=[],r){i=_createForOfIteratorHelper(r);try{for(i.s();!(a=i.n()).done;)s=a.value,o.push(s.id)}catch(e){i.e(e)}finally{i.f()}}if(setTimeout(function(){window.widgetResponse=null,n.innerHTML=null},0),o.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"),S=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"),C=this.getAttribute("bundle-plans"),A=this.getAttribute("promo-code"),d="true"===this.getAttribute("display-vertical-products"),N="true"===this.getAttribute("display-horizontal-plans"),O="true"===this.getAttribute("show-plan-name"),k="true"===this.getAttribute("hide-plan-description"),I=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"),L="true"===this.getAttribute("show-boosted-text"),R=this.getAttribute("basic-text")||"Basic Plan",D=this.getAttribute("recommended-text")||"Recommended",P="true"===this.getAttribute("auto-select"),U=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"),F="true"===this.getAttribute("discount-offer-description"),j="true"===this.getAttribute("discount-offer-text"),p=h+"/widget",h&&(S||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"),B(),l?E=p+"/lite/product/".concat(l,"?ev_sid=").concat(c):u&&(E=p+"/productgroup/".concat(u,"?ev_sid=").concat(c)),e.next=56,fetch(E).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 w,n=X;function t(){"All"!==G&&G&&b.splice(G),(w=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,v,E,e=function(){var s=h.value;"BUNDLE"===s.type&&C?(n=s.bundlePlans.findIndex(function(e){return e.name===C}),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");
8e.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,r=document.createElement("div");r.className="row product-header",L&&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=D,r.appendChild(n)):L&&((o=document.createElement("div")).className="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-basic",o.innerText=R,r.appendChild(o));var o=document.createElement("div");o.className="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-title",o.innerText=s.displayName,r.appendChild(o),t.appendChild(r);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=N?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",P&&s.id===y.recommended?n.id===s.autoSelectPlan&&(x={planName:n.name,productName:s.name,promoDiscounts:n.promoDiscounts},t.classList.add("payment-plan-selected")):P&&!y.recommended&&(x||n.id!==s.autoSelectPlan&&1!==s.paymentPlans.length||(x={planName:n.name,productName:s.name,promoDiscounts:n.promoDiscounts},t.classList.add("payment-plan-selected")));var r=document.createElement("div");r.className="payment-plan-price";e=document.createElement("span");e.className="payment-currency-symbol",e.innerText=n.currency.symbol,r.innerHTML=e.outerHTML+W(n),t.appendChild(r);var o,i,a,r=document.createElement("div");r.className="payment-plan-frequency",r.innerText=I[n.frequency.id],t.appendChild(r),A&&n.promoDiscounts&&0<n.promoDiscounts.length&&((o=document.createElement("div")).className="discount-plan-price",(r=document.createElement("span")).className="payment-currency-symbol-discount",r.innerText=n.currency.symbol,o.innerHTML=r.outerHTML+V(n),t.appendChild(o)),A&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].displayName&&H&&((o=document.createElement("div")).className="promo-code-display-name",o.innerText=n.promoDiscounts[0].displayName,t.appendChild(o)),A&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].offerDescription&&F&&((i=document.createElement("div")).className="promo-code-offer-description",i.innerText=n.promoDiscounts[0].offerDescription,t.appendChild(i)),A&&n.promoDiscounts&&0<n.promoDiscounts.length&&n.promoDiscounts[0].offerText&&j&&((i=document.createElement("div")).className="promo-code-offer-text",i.innerText=n.promoDiscounts[0].offerText,t.appendChild(i)),O&&((a=document.createElement("div")).className="payment-plan-name",a.innerText=n.displayName,t.appendChild(a)),!k&&n.description&&((a=document.createElement("div")).className="payment-plan-description",a.innerText=n.description,t.appendChild(a)),n.externalIds&&n.externalIds.GOOGLE&&ee.useSwg&&"function"==typeof Z.Em.getSwgSubscriptions&&((v=document.createElement("div")).className="swg-container",(E=document.createElement("button")).id="button-swg-"+n.name,v.appendChild(E),t.appendChild(v),(g=Z.Em.getSwgSubscriptions()).attachButton(E,{theme:"light"},function(){g.subscribe(n.externalIds.GOOGLE)})),t.addEventListener("click",function(e){x={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()}r=document.createElement("div");r.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=(S.includes("?")?"&":"?").concat(U,"=").concat(M).concat(d);u.addEventListener("click",function(){var e;console.log("The select button ".concat(_," with index ").concat(d," was clicked!")),x&&x.productName===s.name?(e=S+m+"&productName="+s.name+"&paymentPlans="+x.planName,x.promoDiscounts&&0<x.promoDiscounts.length&&A&&(e+="&promoCode="+A),window.location=e):window.location=S+m+"&productName="+s.name}),a.appendChild(u),r.appendChild(a),t.appendChild(c),t.appendChild(r),e.a
8ppendChild(t),p.appendChild(e),w.appendChild(p)};for(t.s();!(h=t.n()).done;)e()}catch(e){t.e(e)}finally{t.f()}n.appendChild(w),q(".payment-plan-container"),q(".product-wrapper")}A&&1===b.length?(e=p+"/product/promocode/"+b[0].name+"?promoCode="+A,fetch(e).then(function(e){if(!e.ok)throw new Error("Response not OK");return e.json()}).then(function(r){if(r[0].appErrorCode)throw new Error("Application Error Code found");b[0].paymentPlans.forEach(function(t,e){var n=r.find(function(e){return e.id===t.id});n&&(b[0].paymentPlans[e]=n)}),Z.Em.publish(Z.Em.Event.PM_PROMO_ACTION,b[0])}).catch(function(e){console.log(e),A=null}).finally(function(){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)})}]),r}()),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:"c
8onnectedCallback",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)}
8return _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){u=e,h.authorizeData=e.detail})}(window.EV);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.