var CISION_FEED_URL,LANGUAGE,LANG_PATH="/content/corporate/",PAGE_NAME="/system/cision-shell.html",ID_URL_PARAM="?encryptedId\x3d",DATE_DIVIDER=" - ",recentNewsTemplate,detailedReleases=[];dayjs.extend(window.dayjs_plugin_localizedFormat);dayjs.extend(window.dayjs_plugin_localeData);dayjs.extend(window.dayjs_plugin_utc);dayjs.extend(window.dayjs_plugin_timezone);dayjs.extend(window.dayjs_plugin_advancedFormat);
$(window).on("load",function(){localizeDates();localizeDay();localizeTimezoneIndependentDay();CISION_FEED_URL=$(".cision-feed").val();LANGUAGE=$(".cision-language").val();var b=$("#recent-news-template").html();b&&(recentNewsTemplate=Handlebars.compile(b),pollCision(),setInterval(pollCision,1E4))});function pollCision(){CISION_FEED_URL&&$.getJSON(CISION_FEED_URL).done(function(b){cisionSuccess(b)}).fail(function(b,a,c){cisionFail(b,a,c)})}
function cisionSuccess(b){if(b){var a=$(".recent-news-cision-poller article"),c=extractIds(a),d=extractTimestamps(a);extractReferences(a);var k=[];b=b.Releases;detailedReleases=[];if(0<b.length){detailedReleases.push(b[0]);var v=getDetailDeferred(b[0].EncryptedId,0);if(1<b.length){detailedReleases.push(b[1]);var w=getDetailDeferred(b[1].EncryptedId,1);if(2<b.length){detailedReleases.push(b[2]);var x=getDetailDeferred(b[2].EncryptedId,2)}}}$.when(v,w,x).done(function(){$.each(detailedReleases,function(){if("INB"!=
this.InformationType){var e={};e.id=this.Id;var f=Date.parse(this.PublishDate);e.timestamp=f;e.date=dayjs(f).format("LL");e.title=this.Title;e.text=this.Intro;e.reference=this.CustomerReference;e.link=LANG_PATH+LANGUAGE+PAGE_NAME+ID_URL_PARAM+this.EncryptedId;f=convertTags(this.Categories);e.tags="";if(f)for(var h=0;h<f.length;h++){var r=$(".rn-read-all").attr("href");e.tags="se"==LANGUAGE?e.tags+('\x3ca href\x3d"'+r+"?filter\x3d"+encodeURIComponent(f[h].tagId)+'" class\x3d"c-tag js-no-link"\x3e'+
f[h].labelse+"\x3c/a\x3e"):e.tags+('\x3ca href\x3d"'+r+"?filter\x3d"+encodeURIComponent(f[h].tagId)+'" class\x3d"c-tag js-no-link"\x3e'+f[h].label+"\x3c/a\x3e")}k.push(e)}});k.reverse();var y=$(".recent-news-cision-poller .article-start"),z=$(".recent-news-cision-poller .article-end"),t=!1,u=0;for(g in d)u++;$.each(k,function(){if(recentNewsTemplate&&!c[this.id]){var e=!1,f;for(f in d){var h=parseInt(f);if(this.timestamp>h||3>u)e=!0}e&&(t=!0,$(y).after(recentNewsTemplate(this)))}});if(t){a.hide();
var g=$(".recent-news-cision-poller article");var q=[],m={};$.each(g,function(){-1==$.inArray($(this).attr("data-timestamp"),q)&&q.push($(this).attr("data-timestamp"));var e=$(this).attr("data-reference");e&&""!=e&&(m.hasOwnProperty(e)?m[e]+=1:m[e]=1)});for(var l in m)if(1<m[l]){g=$(".recent-news-cision-poller article[data-reference\x3d'"+l+"']");var n;$.each(g,function(){var e=$(this).attr("data-timestamp");n||(n=parseInt(e));parseInt(e)>n&&(n=parseInt(e))});n&&$.each(g,function(){parseInt($(this).attr("data-timestamp"))<
n&&$(this).remove()})}q.sort().reverse();for(g=l=0;g<q.length&&3>g;g++){var p=$('.recent-news-cision-poller article[data-timestamp\x3d"'+q[g]+'"]');p.length>3-l&&(p=p.slice(0,3-l));l+=p.length;p.insertBefore(z);3>=l&&p.addClass("js-to-show")}$(".js-to-show").show().removeClass("js-to-show");$(".recent-news-cision-poller .js-match:visible").matchHeight()}chopstickBlocklink()})}}function cisionFail(b,a,c){console.log("Cision Request Failed: "+(a+", "+c))}
function extractIds(b){var a={};b&&$.each(b,function(){var c=$(this).attr("data-page-name"),d=$(this).attr("data-cision-id");d&&""!=d&&(a[d]={},c&&""!=c?a[d].pageName=c:a[d].cisionId=d)});return a}function extractReferences(b){var a={};b&&$.each(b,function(){var c=$(this).attr("data-page-name"),d=$(this).attr("data-reference");d&&""!=d&&(a[d]={},c&&""!=c?a[d].pageName=c:a[d].cisionId=d)});return a}
function extractTimestamps(b){var a={};b&&$.each(b,function(){var c=$(this).attr("data-page-name"),d=$(this).attr("data-timestamp"),k=$(this).attr("data-cision-id");d&&""!=d&&(a[d]={},c&&""!=c?a[d].pageName=c:a[d].cisionId=k)});return a}
function localizeDates(){var b=$("[data-moment-date]");$.each(b,function(){var a=$(this).attr("data-moment-date"),c=$(this).attr("data-moment-lang");"undefined"!==typeof c&&(dayjs.locale(c),0<=a.indexOf(DATE_DIVIDER)?(a=a.split(DATE_DIVIDER),$(this).text(dayjs(parseInt(a[0])).format("LL")+DATE_DIVIDER+dayjs(parseInt(a[1])).format("LL"))):a&&""!=a&&$(this).text(dayjs(parseInt(a)).format("LL")))})}
function localizeDay(){var b=$("[data-moment-day]");$.each(b,function(){var a=$(this).attr("data-moment-day"),c=$(this).attr("data-moment-lang");dayjs.locale(c);a&&""!=a&&$(this).text(dayjs.tz(parseInt(a),"UTC").local().format("Do"))})}
function localizeTimezoneIndependentDay(){var b=$("[data-moment-timestamp-year]");$.each(b,function(){var a=$(this).attr("data-moment-timestamp-year"),c=$(this).attr("data-moment-timestamp-month"),d=$(this).attr("data-moment-timestamp-day"),k=$(this).attr("data-moment-lang");dayjs.locale(k);a&&c&&d&&$(this).text(dayjs.tz(a+"-"+c+"-"+d,"UTC").format("Do"))})}
function getDetailDeferred(b,a){var c=$.Deferred();$.ajax({url:window.location.protocol+"//publish.ne.cision.com/papi/Release/"+b+"?format\x3djson",success:function(d){detailedReleases[a].CustomerReference=d.Release.CustomerReference;detailedReleases[a].Categories=d.Release.Categories;c.resolve()}});return c.promise()}
this.CisionTag={SUBJECT:{aemTag:"subject",cisionTag:"TYPEOFINFORMATION"},ACQUISITIONS_AND_JOINT_VENTURES:{aemTag:"acquisitions-and-joint-ventures",cisionTag:"ACQUISITIONS",parentTag:"subject",label:"Acquisitions and joint ventures story",labelse:"F\u00f6rv\u00e4rv \x26 Joint Ventures"},ANNUAL_GENERAL_MEETING:{aemTag:"annual-general-meeting",cisionTag:"ANNUALGENERALMEETING",parentTag:"subject",label:"Annual general meeting",labelse:"\u00c5rsm\u00f6te"},ANNUAL_REPORTS:{aemTag:"annual-reports",cisionTag:"ANNUALREPORTS",
parentTag:"subject",label:"Annual reports",labelse:"\u00c5rsredovisningar "},APPOINTMENTS:{aemTag:"appointments",cisionTag:"APPOINTMENTS",parentTag:"subject",label:"Appointments",labelse:"Ledningsf\u00f6r\u00e4ndringar"},DIVESTMENTS:{aemTag:"divestments",cisionTag:"DIVESTMENTS",parentTag:"subject",label:"Divestments",labelse:"Avyttringar "},FINANCIAL_REPORTS:{aemTag:"financial-reports",cisionTag:"FINANCIALREPORTS",parentTag:"subject",label:"Financial reports",labelse:"Finansiella rapporter"},MISCELLANEOUS:{aemTag:"miscellaneous",
cisionTag:"MISCELLANEOUS",parentTag:"subject",label:"Miscellaneous",labelse:"Diverse"},PRODUCT_INFO:{aemTag:"product-info",cisionTag:"PRODUCTINFO",parentTag:"subject",label:"Product info",labelse:"Produktinformation"},STRUCTURAL_CHANGES:{aemTag:"structural-info",cisionTag:"STRUCTURALCHANGES",parentTag:"subject",label:"Structural changes",labelse:"Strukturf\u00f6r\u00e4ndringar"},REGULATORY_RELEASES:{aemTag:"regulatory-releases",cisionTag:"REGULATORY_RELEASES",parentTag:"subject",label:"Regulatory releases",
labelse:"Regelstryrda pressmeddelanden"},PRODUCT_CATEGORY:{aemTag:"product-category",cisionTag:"PRODUCT_CATEGORY"}};this.convertTags=function(b){if(b){for(var a=[],c=0;c<b.length;c++){var d=b[c].Code;for(tag in this.CisionTag)d===this.CisionTag[tag].cisionTag&&a.push({label:this.CisionTag[tag].label,tagId:"news:"+this.CisionTag[tag].parentTag+"/"+this.CisionTag[tag].cisionTag})}return a}};