1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[56504],{504:(t,e,i)=>{i.r(e),i.d(e,{default:()=>s});class s extends window.PluginBaseClass{static #t=this.options={blogPostId:null,userVote:null,thankYouText:""};init(){this._voteUrl=this.el.getAttribute("data-url"),this._likeButton=this.el.querySelector('[data-vote-type="like"]'),this._dislikeButton=this.el.querySelector('[data-vote-type="dislike"]'),this._likeCount=this.el.querySelector("[data-vote-count-like]"),this._dislikeCount=this.el.querySelector("[data-vote-count-dislike]"),this._thankYou=this.el.querySelector("[data-vote-thank-you]"),this._currentVote=this._getStoredVote()||this.options.userVote,this._applyActiveState(),this._registerEvents()}_registerEvents(){this._likeButton&&this._likeButton.addEventListener("click",()=>this._onVote("like")),this._dislikeButton&&this._dislikeButton.addEventListener("click",()=>this._onVote("dislike"))}_onVote(t){if(this._isLoading||(this._isLoading=!0,!this._voteUrl))return;let e=new FormData;e.append("type",t),fetch(this._voteUrl,{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:e}).then(t=>t.ok&&204!==t.status?t.json():null).then(t=>{t&&(this._currentVote=t.userVote,this._storeVote(t.userVote),this._updateCounts(t.likeCount,t.dislikeCount),this._applyActiveState(),this._showThankYou())}).catch(()=>{}).finally(()=>{this._isLoading=!1})}_updateCounts(t,e){this._likeCount&&(this._likeCount.textContent=t),this._dislikeCount&&(this._dislikeCount.textContent=e)}_applyActiveState(){this._likeButton&&this._likeButton.classList.toggle("is--active","like"===this._currentVote),this._dislikeButton&&this._dislikeButton.classList.toggle("is--active","dislike"===this._currentVote)}_showThankYou(){this._thankYou&&(this._thankYou.hidden=!1)}_getStorageKey(){return`shopStudioBlogVote_${this.options.blogPostId}`}_getStoredVote(){try{return localStorage.getItem(this._getStorageKey())}catch{return null}}_storeVote(t){try{t?localStorage.setItem(this._getStorageKey(),t):localStorage.removeItem(this._getStorageKey())}catch{}}}}}]);
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.