class Article{constructor(){this.currentSize=16}Init(){$("#slider").attr({min:16,max:32});const t=Number($("#slider").attr("min"));let i=new CookieHelper,n=i.ReadCookie("CALCALIST_ARTICLE_FONTSIZE")?Number(i.ReadCookie("CALCALIST_ARTICLE_FONTSIZE")):this.currentSize;this.currentSize=n;n>t?Article.SliderInitialzation($("#slider"),n,this):t;this.ArticleComments();this.ArticleResize(this);this.ArticleGallery();this.ArticleShares();this.Initalizebase();this.Analytics();this.ArticleProgressBar();this.ArticlePiano();this.gptIntervals(150)}gptIntervals(n){dfpactive==="true"&&(console.log(`Interval set to ${n*1e3} milliseconds.`),setInterval(()=>{console.log(`gptInterval Invoked.`),window.gptCalcalist.refreshAds()},n*1e3))}ArticlePiano(){const r=n=>{var t=document.createElement("textarea");return t.innerHTML=n.replace("&amp;","&"),t.value},u=n=>n.split("-").reduce((n,t)=>[...n,n.length?`${n[n.length-1]}-${t}`:t],[]);let f=u(dcPath.dcPath),e=Analytics.articleTags.split(" | ").map(n=>r(n)),i=f.concat(e);dcPath.Restriction!=null?i.push(dcPath.Restriction):null;let n=Analytics.datePublished.split(" ")[0],t=Analytics.datePublished.split(" ")[1],o=new Date(n.split("/")[2],n.split("/")[1]-1,n.split("/")[0],t.split(":")[0],t.split(":")[1],t.split(":")[2],0);tp.push(["setContentCreated",o.toISOString()]);tp.push(["setContentAuthor",Analytics.authorName]);tp.push(["setTags",i]);tp.push(["init",function(){tp.experience.init()}])}ArticlePianoScript(){const i=n=>n.split("-").reduce((n,t)=>[...n,n.length?`${n[n.length-1]}-${t}`:t],[]);let r=i(dcPath.dcPath),u=Analytics.articleTags.split(" | "),f=r.concat(u),n=Analytics.datePublished.split(" ")[0],t=Analytics.datePublished.split(" ")[1],e=new Date(n.split("/")[2],n.split("/")[1]-1,n.split("/")[0],t.split(":")[0],t.split(":")[1],t.split(":")[2],0);tp.push(["setContentCreated",e.toISOString()]);tp.push(["setContentAuthor",Analytics.authorName]);tp.push(["setTags",f])}ArticleProgressBar(){document.addEventListener("scroll",()=>{const{scrollTop:t,scrollHeight:i}=document.documentElement,n=`${t/(i-window.innerHeight-(document.querySelector(".s-thirdparties-content")?document.querySelector(".s-thirdparties-content").offsetHeight:0))*100}%`;Number(n.replace("%",""))>=100?document.querySelector("#c-progress-bar").style.setProperty("--progress","100%"):document.querySelector("#c-progress-bar").style.setProperty("--progress",n)})}Analytics(){for(var n in articleAnalytics)articleAnalytics.hasOwnProperty(n)&&(window.Analytics[n]=articleAnalytics[n]);window.Analytics.status="success"}ApesterWidget(){let n=Number(dcPath.DesktopChannelId)||0;if(n===7||n===13){let n=$(".c-article-device__bullets");n.after('<div class="apester-strip" is-mobile-only="false" data-channel-tokens="5de3823d9d4005fe7cc9390c"item-shape="roundSquare" item-has-shadow="true" item-size="medium" item-text-color="black" strip-background="rgba(NaN,NaN,undefined,1)" data-fast-strip="true"header-font-size="17" header-font-family="Arimo" header-font-weight="700" header-text="הסטוריז של מוסף כלכליסט"header-font-color="rgba(208,30,37, 0.8)" header-ltr="false"thumbnails-stroke-color="rgba(208,30,37,0.8)"><\/div>')}else if(n===14){let n=$(".c-article-device__bullets");n.after('<div class="apester-strip" is-mobile-only="false" data-channel-tokens="5de3823d9d4005fe7cc9390c" item-shape="roundSquare" item-has-shadow="true" item-size="medium" item-text-color="black" strip-background="rgba(NaN,NaN,undefined,1)" data-fast-strip="true" header-font-size="17" header-font-family="Arimo" header-font-weight="700" header-text="הסטוריז של מוסף כלכליסט" header-font-color="rgba(208,30,37, 0.8)" header-ltr="false" thumbnails-stroke-color="rgba(208,30,37,0.8)"><\/div>')}}Initalizebase(){let i=new URL(window.location.href),u=i.searchParams.get("guid"),f=i.searchParams.get("ref")||"",t=[3847,5494,31023,5631,3717].find(n=>dcPath.dcPath.includes(n))!=null&&i.href.toLowerCase().indexOf("article.aspx")>-1;t||(t=dcPath.ArticleId==="Article.Id.b1kwx1hxq");console.log("3rd except taboola Isdisabled",t);let n=Array.prototype.slice.call(document.querySelectorAll(".c-article-device__paragraph p")).filter(n=>n.textContent.length>0);if(dcPath.ArticleType!=="photo"&&n.length>1){let i=n[1];if(i!==null){let n=document.createElement("div");n.id="taboola-taboola-mid-article";i.after(n)}if(n.length>3){let i=n.slice(2)[n.length>5?2:n.length-4];if(i!==null&&!t){let n=document.createElement("div");n.id="taboola-mid-article-with-video";i.after(n)}}else if(n.length<=3){let n=document.getElementById("taboola-taboola-mid-article");if(n){let t=document.createElement("div");t.id="taboola-mid-article-with-video";n.after(t)}}}else{let u=n.length==0?document.querySelector(".c-article-device__share"):n.slice(-1)[0],t=document.createElement("div"),i=document.createElement("div");i.id="taboola-taboola-mid-article";let r=document.createElement("div");r.id="taboola-mid-article-with-video";t.appendChild(i);t.appendChild(r);u.after(t)}window._taboola=window._taboola||[];_taboola.push({mode:"alternating-thumbnails-b",container:"taboola-taboola-mid-article",placement:t?"Taboola Mid Article Remove Readmore":"Taboola Mid Article",target_type:"mix"});window._taboola=window._taboola||[];_taboola.push({mode:"exchange-thumbnails-2x1",container:"taboola-mid-article-with-video",placement:"Mid Article with Video",target_type:"mix"});window._taboola=window._taboola||[];_taboola.push({flush:!0});let e=$("*[data-base]").each(function(){$(this).data("base",window.location.origin+window.location.pathname.replace("Article.aspx",""))}),o=$(".c-talkback__header a").each(function(){let n=$(this).attr("href").replace("https://BASEURL/",window.location.origin+window.location.pathname.replace("Article.aspx",""));$(this).attr("href",n)}),r=$(".c-article-device__image-widget");r.each(function(){let n=$(this),t=n.first("img"),i=n.first("span");n.html(t.html(),i.html());n.find("a").attr("href",n.find("img").attr("src")).attr("target","_blank")});window.location.href.indexOf("r146d4vkn")>0&&(document.querySelector(".t-article-device-time").nextElementSibling.nextElementSibling.remove(),document.querySelector(".t-article-device-time").nextElementSibling.remove())}urlParse(n,t){for(let i in t)n=n.replace(new RegExp("\\$\\{"+i+"\\}","g"),encodeURIComponent(t[i]));return n}openShare(n,t,i,r){const e={url:t,title:i,text:r};let u,f=this.urlParse(n,e);if(n.startsWith("http")){let n=screen.availWidth||1024,t=screen.availHeight||700,i=Math.min(600,n-40),r=Math.min(600,t-40),e=Math.floor((n-i)/2),o=Math.floor((t-r)/2);u=window.open(f,"social",`width=${i},height=${r},left=${e},top=${o},          location=0,menubar=0,toolbar=0,personalbar=0,status=0,scrollbars=1,resizable=1`)}u?u.focus():location.href=f}ArticleShares(){var n=this;let i=document.querySelector(".c-article-device__share").dataset.sharelocaiton="Article Head",t=$(".c-article-device_upshare, .c-article-device_uptwitter, .c-article-device_upwhatsapp, .c-article-device_upfacebook, .c-article-device__footer-share > a");t.on("click",function(t){function v(n){var t=document.createElement("div");return t.innerHTML=n,t.childNodes.length===0?"":t.childNodes[0].nodeValue}let a=t.currentTarget.parentElement.dataset.sharelocaiton;t.preventDefault();let h=$(".c-article-device__share"),c=v(h.data("title")),p=h.data("image").replace("http://","https://"),l=h.data("articleid"),y=$(this).data("sharetype"),r,s=c,u="https://m.calcalist.co.il/",f=`Article.aspx?guid=${l}`,i=`&utm_source=${u.split("/")[2]}&utm_medium=Share&utm_term=${l}&utm_campaign=#campaign#`,e,o;switch(y){case"mail":i=i.replace("#campaign#","email");r=`mailto:?subject=${s}&body=${u}${f}${i}`;e="Email";o="mailto:?subject=${title}&body=${url}";break;case"facebook":i=i.replace("#campaign#","facebook");r=`https://m.facebook.com/sharer.php?u=${u}${f}${i}`;e="Facebook";o="https://www.facebook.com/sharer/sharer.php?u=${url}";break;case"whatsapp":i=i.replace("#campaign#","whatsapp");r=`https://api.whatsapp.com/send?text=${s}${String.fromCharCode(58,32)}${u}${f}${i}`;e="WhatsApp";o="https://api.whatsapp.com/send?text=${title} ${url}";break;case"twitter":i=i.replace("#campaign#","twitter");r=`https://twitter.com/share?url=${u}${f}${i}&text=${s}`;e="Twitter";o="https://twitter.com/intent/tweet?url=${url}&amp;text=${title}";break;case"linkedin":i=i.replace("#campaign#","linkedin");r=`https://www.linkedin.com/shareArticle?mini=true&url=${u}${f}${i}&title=${s}&summary=${s}`;e="Linkedin";o="https://www.linkedin.com/shareArticle?mini=true&url=${url}&amp;title=${title}"}dataLayer.push({event:"share_events",Category:"Share",Action:a,Label:`${e}`});r=`${u}${f}${i}`;n.openShare(o,r,c,"")})}ArticleGallery(){let n=$(".c-article-device__gallery");n.each(function(){let n=$(this);n.on("click",function(){n.prepend('<div class="uil-ring-css" style="position: absolute !important;top: 19%;left: 42%;z-index: 10;"><div><\/div><\/div>');let r=n.find("a[data-galleryid]").data("galleryid"),i=$("#gallery__"+r);if(i.length>0)i.hasClass("hidden_elem")?i.show():"";else{var u="./Scripts/vendors/owlcarousel/owl.carousel.min.css",t=document.createElement("link");t.href=u.substr(0,u.lastIndexOf("."))+".css";t.type="text/css";t.rel="stylesheet";document.getElementsByTagName("head")[0].appendChild(t);let i=function(n,t){jQuery.ajax({url:n,dataType:"script",success:t,async:!0})};const n=document.createElement("script");n.src=`${baseUrl}Scripts/vendors/owlcarousel/owl.carousel.min.js`;n.onload=function(){Article.InitializeGallerybyId(r)};document.head.appendChild(n)}})})}static InitializeGallerybyId(n){$.ajax({type:"get",url:"./Article/GetImageArray/Jsondata.aspx",contentType:"application/json; charset=utf-8",datatype:"json",data:{gId:n}}).done(function(t){let u=$("body").append(t);var r=function(n){var o=$("body").css("position"),t=$("#gallery__"+n),s=document.body.getBoundingClientRect(),h=document.getElementById("gallery__"+n).getBoundingClientRect(),c=h.top-s.top,r=t.find(".article-gallery-items"),f,e;r.owlCarousel({rtl:!0,loop:!1,items:1,margin:10,dots:!1,onChanged:function(){setTimeout(function(){i(t)},250)}});f=t.find(".article-gallery-close");f.on("click",function(){$(".uil-ring-css").remove();$("body").css({position:o});$("body").scrollTop(c);t.addClass("hidden_elem").hide()});$("body").css({position:"fixed"});var l=$(".share-btn.ws-share"),a=$(".share-btn.fb-share"),v=$(".mail-share"),y=window.location.search.toString().toLowerCase().replace("?guid=",""),u="{'artid': '"+y+"','title': '"+document.title+"','picture': '', 'type': 'article'}";l.attr("onclick","shareWhatsapp("+u+")");a.attr("onclick","shareFacebook("+u+")");v.attr("onclick","shareMail("+u+")");e=$(".article-gallery-arrow");e.on("click",function(){$(this).hasClass("article-gallery-arrow-right")?r.trigger("next.owl.carousel"):r.trigger("prev.owl.carousel")})},i=function(n){n.find(".article-gallery-item-info .article-gallery-item-title").text(n.find(".owl-item.active > li").data("title"));n.find(".article-gallery-item-credit").text(n.find(".owl-item.active > li").data("credit"));n.find(".article-gallery-item-info .article-gallery-item-max").text(n.find(".owl-item").length);n.find(".article-gallery-item-info .article-gallery-item-idx").text(" / "+n.find(".owl-item.active > li").data("idx"))};r(n);i($("gallery__"+n))}).fail(function(n,t){console.log(t)})}ArticleComments(){let n=$(".c-article-device_upcomment");n.on("click",function(){let n=$("div[name='anchor-section-talkbacks']");$("html,body").animate({scrollTop:n.offset().top},900)})}ArticleResize(n){let t=$(".c-article-device_font");t.on("click",function(){var n=$(".c-article-device_slider-container");return n.hasClass("is-open")?n.hide().removeClass("is-open"):n.show().addClass("is-open"),!1});let i=$("#slider");i.change(function(t){t.stopPropagation();let i=$(this),u=Number(i.val()),r=(i.val()-i.attr("min"))/(i.attr("max")-i.attr("min"));i.css("background-image","-webkit-gradient(linear, left top, right top,color-stop("+r+", #d01e25), color-stop("+r+", #a7a8a7))");Article.SetFontSize(u,n)})}static SliderInitialzation(n,t,i){let r=(t-n.attr("min"))/(n.attr("max")-n.attr("min"));n.css("background-image","-webkit-gradient(linear, left top, right top,color-stop("+r+", #d01e25), color-stop("+r+", #a7a8a7))");n.val(t);Article.SetFontSize(t,i)}static SetFontSize(n,t){$(".c-article-device").find(".c-article-device__paragraph, .photoCalcalist span").each(function(){let t=Number($(this).css("line-height").replace("px","")),i=Number($(this).css("font-size").replace("px",""));$(this).css("font-size",n+"px");$(this).css("line-height",n*1.4375+"px")});let i=new CookieHelper;n!==t.currentSize&&(i.CreateCookie("CALCALIST_ARTICLE_FONTSIZE",null,-1),i.CreateCookie("CALCALIST_ARTICLE_FONTSIZE",n,30));t.currentSize=n}}$(function(){let n=new Article;n.Init();let t=new Comment;t.StickyComments()});class Comment{constructor(){}Init(){this.PaperComment();this.StickyComments()}PaperComment(){let n=$(".c-talkback__paper"),t=new URL(window.location.href),i=t.searchParams.get("f");i?n.show():n.hide();let r=$(".c-talkback__add, .c-talkback__closebtn");r.on("click",function(){n.toggle()});let u=$(".c-talkback__sendbtn");u.on("click",function(){Comment.PublishComment()})}StickyComments(){let n=$(".c-talkback__container");n.on("click",function(){let n=$(this);n.addClass("opened").css({height:"auto"});n.find(".c-talkback__title").removeClass("t-ellipsis");n.find(".c-talkback__description").removeClass("is-hidden");let t=n.find(".c-talkback__description");t.hasClass("--state--opened")?t.slideUp(200,function(){$(this).removeClass("--state--opened")}):t.slideDown(200,function(){$(this).addClass("--state--opened")})})}static PublishComment(){function t(){var n=!0;return $('[data-required="true"]').each(function(){var t=$(this);$.trim(t.val())===""?(t.parent().attr("data-attr-msg",t.data("msg")).addClass("t-validity"),n=!1):t.parent().removeAttr("data-attr-msg").removeClass("t-validity")}),n}var n=!1;if(t()&&!n){n=!0;let t=new URL(window.location.href),i=JSON.stringify({Name:encodeURIComponent($("#id-name").val()),Title:encodeURIComponent($("#id-title").val()),Content:encodeURIComponent($("#id-content").val()),Guid:t.searchParams.get("guid"),Type:t.searchParams.get("tbType"),Category:t.searchParams.get("catGuid")});$.ajax({type:"post",contentType:"application/json; charset=utf-8",datatype:"json",data:i,url:"./TalkBacks/AddTalkback",beforeSend:function(){let n=$(".c-talkback__paper").hide(),t=$("#id-name").val(""),i=$("#id-title").val(""),r=$("#id-content").val("")},success:function(n){var t;if(n.Answer==="Sent")t=document.getElementById("c-snackbar"),t.className="show",setTimeout(function(){t.className=t.className.replace("show","")},3e3),dataLayer.push({event:"GA_Event",Category:"Article",Action:"Send Comment",Label:"Success"});else if(n.Answer==="Error"){let n=$("#c-snackbar").html("חלה שגיאה, אנא נסה במועד מאוחר יותר");t=document.getElementById("c-snackbar");t.className="show";setTimeout(function(){t.className=t.className.replace("show","")},3e3);dataLayer.push({event:"GA_Event",Category:"Article",Action:"Send Comment",Label:"Fail"})}},complete:function(){n=!1},error:function(){let t=$("#c-snackbar").html("חלה שגיאה, אנא נסה במועד מאוחר יותר");var n=document.getElementById("c-snackbar");n.className="show";setTimeout(function(){n.className=n.className.replace("show","")},3e3)}})}}}$(function(){let n=new Comment;n.Init()})