(self.webpackChunkextract_css=self.webpackChunkextract_css||[]).push([[77751],{860631:(l,u,n)=>{"use strict";var o=n(296678)},296678:(l,u,n)=>{"use strict";n.r(u);var o=n(615155),v=n.n(o),m=n(747497),g=n(644700),f=n.n(g),d=n(416582),h=n.n(d),L=n(683748);YUI.add("squarespace-simple-liking",function(t){var k=t.config.win.Static;t.Squarespace.SimpleLike={TEXT_LIKE_VERB_NONE:(0,o.t)("No Likes",null,{project:"scripts-v6-root"}),TEXT_LIKE_VERB_SINGULAR:(0,o.t)("Like",null,{project:"scripts-v6-root"}),TEXT_LIKE_VERB_PLURAL:(0,o.t)("Likes",null,{project:"scripts-v6-root"}),TEXT_LIKE_ACTIVATED:(0,o.t)("You like this",null,{project:"scripts-v6-root"}),TEXT_LIKE_SUGGEST:(0,o.t)("Click to like",null,{project:"scripts-v6-root"}),attached:!1,attach:function(){if(!this.attached){this.attached=!0;var e;try{localStorage&&(e=t.JSON.parse(localStorage.getItem("squarespace-likes")),e||(e={}),localStorage.setItem("squarespace-likes",t.JSON.stringify(e)))}catch(a){e={}}this.eventHandlers=[];var i=t.delegate("click",function(r){var s=r.currentTarget,c=s.getAttribute("data-item-id");if(c){for(var p=0;p<5;++p)t.Squarespace.SimpleLike.burst(s);s.hasClass("clicked")||s.hasClass("float")||m.default.like(c).then(function(_){if(_.commited===!0){if(s&&s.getDOMNode()){var E=parseInt(s.getAttribute("data-like-count"),10);s.setAttribute("data-like-count",E+1),t.Squarespace.SimpleLike.renderLikeCount(s),s.addClass("clicked")}try{localStorage&&(e[c]=!0,localStorage.setItem("squarespace-likes",t.JSON.stringify(e)))}catch(S){console.warn("Unable to save like to local storage: ",S)}}_.error&&((0,L.areCookiesEnabled)()||t.config.win.alert((0,o.t)("You need to enable cookies to be able to like something.",null,{project:"scripts-v6-root"})))}).catch(function(_){})}},"body",".sqs-simple-like");this.eventHandlers.push(i),t.all(".sqs-simple-like").each(function(a){var r=a.getAttribute("data-item-id");r&&(k.SQUARESPACE_CONTEXT.websiteSettings.simpleLikingEnabled||a.remove(),e[r]&&a.addClass("clicked"),m.default.getLikeCount(r).then(function(c){a.setAttribute("data-like-count",c),t.Squarespace.SimpleLike.renderLikeCount(a)}).catch(function(){t.Squarespace.SimpleLike.renderLikeCount(a)}))})}},detach:function(){this.attached=!1,this.eventHandlers.forEach(function(e){e.detach()})},renderLikeCount:function(i){var a=i&&i.getDOMNode?i.getDOMNode():i;if(!(!a||!a.ownerDocument||!a.ownerDocument.defaultView)){var r=i.getAttribute("data-item-id"),s=i.getAttribute("data-like-count"),c=i.one(".like-count");!r||!c||c.setContent(this.formatLikeText(s))}},formatLikeText:function(e){return e===0?t.Squarespace.SimpleLike.TEXT_LIKE_VERB_NONE:e===1?"1 "+t.Squarespace.SimpleLike.TEXT_LIKE_VERB_SINGULAR:e+" "+t.Squarespace.SimpleLike.TEXT_LIKE_VERB_PLURAL},burst:function(e){var i=e.cloneNode(!0);i.one(".like-count")&&i.one(".like-count").remove();var a=e.one(".like-icon");(!a||a.getStyle("display")==="none")&&(a=e),i.setStyles({position:"absolute",left:a.getX()+"px",top:a.getY()+"px"}),t.one(t.config.doc.body).append(i);var r=new t.Anim({node:i,duration:2,easing:t.Easing.easeOut});r.set("to",{curve:t.Squarespace.SimpleLike.randomCurve(i)}),r.on("end",function(){this.get("node").remove()}),r.run(),i.removeClass("clicked"),i.addClass("float")},randomCurve:function(e){for(var i=[],a=3,r=30,s=Math.floor(Math.random()*2)?1:-1,c=Math.floor(Math.random()*2)?1:-1,p=e.getX(),_=e.getY(),E=0;E<a;++E)p+=Math.floor(Math.random()*r)*s,_+=Math.floor(Math.random()*r)*c,i.push([p,_]);return i}},t.config.win.Squarespace.onInitialize(t,function(){k.SQUARESPACE_CONTEXT.websiteSettings.simpleLikingEnabled&&t.Squarespace.SimpleLike.attach()}),t.config.win.Squarespace.onDestroy(t,function(){t.Squarespace.SimpleLike.attached===!0&&t.Squarespace.SimpleLike.detach()})},"1.0",{requires:["anim","json","node","squarespace-util"]})},416582:l=>{l.exports={}},644700:l=>{l.exports={}},747497:(l,u,n)=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0}),Object.defineProperty(u,"default",{enumerable:!0,get:function(){return k}});var o=v(n(456903));function v(e){return e&&e.__esModule?e:{default:e}}var m=",",g=e=>o.default.post("/api/content-items/"+e+"/sentiment/like").then(i=>{var a=i.data;return a}),f=[],d=null,h=()=>{var e=f.map(i=>i.itemId).join(m);o.default.get("/api/blog-like-count/".concat(e)).then(i=>{var a=i.data;f.forEach(r=>{if(a.hasOwnProperty(r.itemId)){r.resolve(a[r.itemId]);return}r.reject()}),f=[],d=null})},L=e=>new Promise((i,a)=>{f.push({itemId:e,resolve:i,reject:a}),d!==null&&clearTimeout(d),d=setTimeout(h,100)}),t=e=>L(e),k={like:g,getLikeCount:t}},683748:(l,u)=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0}),Object.defineProperty(u,"areCookiesEnabled",{enumerable:!0,get:function(){return n}});function n(){try{if(!("cookie"in document))return!1;var o="_testCookieName";return document.cookie=o,document.cookie.includes(o)}catch(v){return!1}}},392338:l=>{"use strict";l.exports=void 0}},l=>{var u=o=>l(l.s=o);l.O(0,[80276,46001],()=>u(860631));var n=l.O()}]);

//# sourceMappingURL=https://sourcemaps.squarespace.net/universal/scripts-compressed/sourcemaps/e11e916f9368495319fb3bd52ed33a93/simple-liking-b240c4039cac2761e6d0-min.en-US.js.map