var _=Object.defineProperty;var u=(n,i,t)=>i in n?_(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var a=(n,i,t)=>(u(n,typeof i!="symbol"?i+"":i,t),t);(function(){"use strict";class n{constructor(t,e,o){a(this,"windowHeight","400");a(this,"windowWidth","600");a(this,"title",wp_dark_mode_social_share.title);a(this,"description",wp_dark_mode_social_share.description);this.channel=t,this.permalink=e,this.button=o}async counter(){const t=wp_dark_mode_social_share.ajax_url+"?action=wpdm_social_share_counter";var e={channel:this.channel,url:this.permalink,post_id:wp_dark_mode_social_share.post_id||0,nonce:wp_dark_mode_social_share.nonce||0,user_id:wp_dark_mode_social_share.user_id||0,user_agent:navigator.userAgent||""};const s=await(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json();if(Log(s),e=s.data||{},s.success){this.saveToLocalStorage();const h=s.data.shares,l=this.button.closest("._social-share-container"),d=l.querySelectorAll("[data-channel]");d.length>0&&d.forEach(w=>{const m=w.getAttribute("data-channel"),p=h.find(r=>r.channel===m);if(p){const r=w.querySelector("._channel-count span");r&&(r.innerText=p.total||0)}});const c=l.querySelector("._total-share-count");c&&(c.querySelector("span:first-child").innerText=e.total||0)}}saveToLocalStorage(){const t={url:this.permalink,channel:this.channel};let e=localStorage.getItem("wpdm_social_share_shares");if(e)try{e=JSON.parse(e)}catch{e=[]}else e=[];e.push(t),localStorage.setItem("wpdm_social_share_shares",JSON.stringify(e))}share(){if(!(typeof this["before_"+this.channel]=="function"&&!this["before_"+this.channel]())){if(!["copy","more"].includes(this.channel))try{const t=wp_dark_mode_social_share.options.maximum_click_count||0;if(t===0||t=="")this.counter();else{let e=localStorage.getItem("wpdm_social_share_shares");if(e)try{e=JSON.parse(e)}catch{e=[]}else e=[];e.filter(s=>s.url===this.permalink&&s.channel===this.channel).length<t&&this.counter()}}catch(t){Log(t)}this.channel==="copy"&&this.counter(),typeof this[this.channel]=="function"&&this[this.channel](),typeof this["after_"+this.channel]=="function"&&this["after_"+this.channel]()}}more(){jQuery("._wpdm-social-share-modal").fadeIn(150),jQuery("._wpdm-social-share-modal-overlay").fadeIn(100)}copy(){const t=document.createElement("textarea");t.value=this.permalink,document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}after_copy(){if(this.button.querySelector("span._channel-name")){const e=this.button.querySelector("._channel-tooltip")||document.createElement("span");e.classList.add("_channel-tooltip"),e.classList.add("wp-dark-mode-ignore"),e.classList.add("not-slanted"),e.innerText=wp_dark_mode_social_share.labels.copied||"Copied",e.style.display="none",this.button.appendChild(e),jQuery(e).fadeIn(120),setTimeout(()=>{jQuery(e).fadeOut(120)},2e3)}}facebook(){window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}twitter(){window.open("https://twitter.com/share?url="+encodeURI(this.permalink)+"&text="+encodeURI(this.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}linkedin(){window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURI(this.permalink)+"&title="+encodeURI(this.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}google(){window.open("https://plus.google.com/share?url="+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}pinterest(){window.open("https://pinterest.com/pin/create/button/?url="+encodeURI(this.permalink)+"&media="+encodeURI(wp_dark_mode_social_share.image)+"&description="+encodeURI(this.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}tumblr(){window.open("https://www.tumblr.com/share/link?url="+encodeURI(this.permalink)+"&name="+encodeURI(wp_dark_mode_social_share.title)+"&description="+encodeURI(wp_dark_mode_social_share.description),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}reddit(){window.open("https://reddit.com/submit?url="+encodeURI(this.permalink)+"&title="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}stumbleupon(){window.open("https://www.stumbleupon.com/submit?url="+encodeURI(this.permalink)+"&title="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}delicious(){window.open("https://delicious.com/save?url="+encodeURI(this.permalink)+"&title="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}evernote(){window.open("https://www.evernote.com/clip.action?url="+encodeURI(this.permalink)+"&title="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}wordpress(){window.open("https://wordpress.com/press-this.php?u="+encodeURI(this.permalink)+"&t="+encodeURI(wp_dark_mode_social_share.title)+"&s="+encodeURI(wp_dark_mode_social_share.description),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}pocket(){window.open("https://getpocket.com/save?url="+encodeURI(this.permalink)+"&title="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}email(){window.open("mailto:?subject="+encodeURI(wp_dark_mode_social_share.title)+"&body="+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}print(){window.print()}whatsapp(){window.open("https://api.whatsapp.com/send?text="+encodeURI(wp_dark_mode_social_share.title)+" "+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}sms(){window.open("sms:?body="+encodeURI(wp_dark_mode_social_share.title)+" "+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}messenger(){window.open("https://www.facebook.com/dialog/send?app_id=6292016320814619&link="+encodeURI(this.permalink)+"&redirect_uri="+encodeURI(this.permalink),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}telegram(){window.open("https://telegram.me/share/url?url="+encodeURI(this.permalink)+"&text="+encodeURI(wp_dark_mode_social_share.title),"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height="+this.windowHeight+",width="+this.windowWidth)}instagram(){const t=`https://www.instagram.com/create/story/?url=${encodeURI(this.permalink)}`;window.open(t,"",`menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=${this.windowHeight},width=${this.windowWidth}`)}}(function(){class i{constructor(){a(this,"triggerShare",e=>{const o=e.target.closest(".wpdm-social-share-button"),s=o.dataset.channel,h=wp_dark_mode_social_share.permalink||window.location.href;new n(s,h,o).share()});this.bindEvents()}bindEvents(){const e=document.querySelectorAll(".wpdm-social-share-button[data-channel]");e&&e.length&&e.forEach(o=>{o.addEventListener("click",this.triggerShare.bind(this))}),jQuery(document).on("click","._wpdm-social-share-modal-close, ._wpdm-social-share-modal-overlay",function(o){o.preventDefault(),jQuery("._wpdm-social-share-modal").fadeOut(100),jQuery("._wpdm-social-share-modal-overlay").fadeOut(100)})}}document.addEventListener("DOMContentLoaded",function(){new i})})(jQuery)})();
//# sourceMappingURL=social-share.min.js.map
