(t=>{function e(t,c){var i=(t=t.find(".minimog-shoppable-image")).data("tag_type"),s=c(".mabel-siwc-img-wrapper",t),t=s.data("sw-icon"),e=s.data("sw-tags"),n=s.data("sw-text"),o=s.data("sw-size"),r='<i class="'+t+'"></i>';c(document.body).on("click",function(t){c(t.target).is(".mb-siwc-tag")||c(t.target).parents(".mb-siwc-tag").length||c(t.target).is(".mb-siwc-popup-inner")||c(t.target).parents(".mb-siwc-popup-inner").length||c(".mb-siwc-tag",this).removeClass("active").next().addClass("mabel-invisible")}),c.each(e,function(t,e){"numeric"===i&&(r=(t+1).toFixed(0));var t=e.thumb?'<img src="'+e.thumb+'" alt="'+e.title+'"/>':"",t='<div class="mb-siwc-popup-inner"><div class="siwc-thumb-wrapper"><a target="_blank" href="'+e.link+'">'+t+'</a></div><div class="siwc-content-wrapper"><h3 class="product-title"><a target="_blank" href="'+e.link+'">'+e.title+'</a></h3><p class="price">'+e.price+'</p><a target="_blank" class="product-link" href="'+e.link+'">'+n+"</a></div></div>",t=(c('<span class="mb-siwc-tag">'+r+"</span>").css({top:e.posY+"%",left:e.posX+"%"}).on("click",function(t){t.preventDefault();var t=c(t.currentTarget),e=s.find(".mb-siwc-tag");t.toggleClass("active"),e.not(t).removeClass("active"),e.not(t).next().addClass("mabel-invisible"),t.next().toggleClass("mabel-invisible")}).appendTo(s),c(t)),a=c('<div class="mb-siwc-popup mabel-invisible">');e.thumb||a.addClass("siwc-no-thumb"),a.append(t).appendTo(s).css({top:e.posY+"%",left:e.posX+"%",marginLeft:-a.width()/2,marginTop:o/2+7}),c(window).on("resize",function(){var t=((t,e,a,i)=>{null==(i=void 0===i?null:i)&&(i=c(document.body));var s=a.height(),a=a.width(),n=i.height(),i=i.width(),o=a/i*100,r=i*t/100,e=100<e+s/n*100?"top":"bottom";return 100<t+o&&a<r?e+=" left":t-o<0&&a<i-r&&(e+=" right"),e})(e.posX,e.posY,a,s);if("bottom"!=t)switch(t){case"top":a.css({marginTop:-1*(a.height()+o/2+7)});break;case"top left":a.css({marginTop:-1*(a.height()+o/2),marginLeft:-1*(a.width()+o/2)});break;case"top right":a.css({marginTop:-1*(a.height()+o/2),marginLeft:o/2});break;case"bottom left":a.css({marginTop:o/2,marginLeft:-1*(a.width()+o/2)});break;case"bottom right":a.css({marginTop:o/2,marginLeft:o/2})}a.addClass("mb-siwc-"+t.replace(" ","-"))}).trigger("resize")})}t(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/tm-shoppable-image.default",e)})})(jQuery);