import*as e from"@wordpress/interactivity";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const o=(n={getContext:()=>e.getContext,store:()=>e.store},i={},t.d(i,n),i),{state:r}=(0,o.store)("buntywp/explicit-media",{isOpen:!1,isMediaShared:!1,imageSrc:"",Copied:!1,state:{get isMediaLiked(){return(0,o.getContext)().liked},get likeCount(){return(e=(0,o.getContext)().likeCount)<1e3?e.toString():e<1e6?(e/1e3).toFixed(1)+"K":(e/1e6).toFixed(1)+"M";var e},get expImageSrc(){return r.imageSrc},get expIsPopupOpen(){return r.isOpen},get expTwitterShareURL(){const e=(0,o.getContext)();return"https://x.com/intent/post?url="+encodeURIComponent(e.expShareUrl)},get expFBShareURL(){const e=(0,o.getContext)();return"https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(e.expShareUrl)}},actions:{expToggleLike:()=>{if(!r.userLoggedIn)return r.showLoginMessage=!0,void setTimeout((()=>{r.showLoginMessage=!1}),2e3);const e=(0,o.getContext)();e.liked=!e.liked,e.likeCount=e.liked?Number(e.likeCount+1):Number(e.likeCount-1),function(e){fetch(r.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"save_media_likes",nonce:r.nonce,context:JSON.stringify(e)})}).then((e=>e.json())).then((()=>{})).catch((e=>{console.error("Error saving Like:",e)}))}(e)},expShowLightbox:()=>{const e=(0,o.getContext)();r.isOpen=!0,r.imageSrc=e.mediaUrl},expHideLightbox:()=>{r.isOpen=!1,r.imageSrc=""},expToggleShare:()=>{const e=(0,o.getContext)();e.isShareOpen=!e.isShareOpen},expCopyLink:()=>{const e=(0,o.getContext)().expShareUrl;navigator.clipboard.writeText(e),r.Copied=!0,setTimeout((()=>{r.Copied=!1}),2e3)}},callbacks:{expSetupLightbox:()=>{window.addEventListener("keydown",(e=>{"Escape"===e.key&&(0,o.store)("buntywp/explicit-media").actions.expHideLightbox()})),window.addEventListener("click",(function(e){!e.target.closest(".exp-media-share-button")&&!e.target.closest(".exp-share-popup")&&document.querySelectorAll(".exp-share-popup").forEach((e=>{e.classList.add("hide")}))}))},expDisplayPiP:e=>{const t=e.currentTarget?.closest(".image-container")?.querySelector("video");t&&document.pictureInPictureEnabled&&(document.pictureInPictureElement?document.exitPictureInPicture().catch(console.error):t.requestPictureInPicture().catch(console.error))}}});var n,i;