!function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(e){var n=function(e,n){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==t(n)?n:n+""}function n(t,n,r){return(n=e(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}const o={},i=function(t={}){if(t=function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?r(Object(o),!0).forEach(function(e){n(t,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}({el:null,action:null},t),!t.el)return;if(!t.action)return;if(t.el.classList.contains("ct-loading"))return;let e=parseInt(t.el.dataset.page,10);if("prev"===t.action&&1===e)return;if(t.el.querySelectorAll(".ct-trending-block-item").length<4&&1===e)return;if(t.el.dataset.page.indexOf("last")>-1&&"next"===t.action)return;t.el.querySelectorAll(".ct-trending-block-item").forEach(function(t,e){t.style.opacity=0,t.style.transform="translateY(3px)",t.style.transitionDelay=(e?.15*e-.05:0)+"s"});let i="prev"===t.action?e-1:e+1;var c;Promise.all([new Promise(function(t){requestAnimationFrame(function(){setTimeout(function(){return t()},650)})}),(c=`${ct_localizations.ajax_url}?action=blocksy_get_trending_posts&page=${i}`,o[c]?new Promise(function(t){t(o[c]),window.ct_customizer_localizations||(o[c]=o[c].clone())}):new Promise(function(t){return fetch(c).then(function(e){t(e),window.ct_customizer_localizations||(o[c]=e.clone())})})).then(function(t){return t.json()})]).then(function([e,{success:n,data:r}]){if(!n)return;let{posts:{is_last_page:o,posts:c}}=r;t.el.dataset.page=`${i}${o?":last":""}`,[...t.el.querySelectorAll(".ct-trending-block-item")].map(function(t){return t.remove()}),c.map(function(e,n){return t.el.insertAdjacentHTML("beforeend",`<div class="ct-trending-block-item" style="opacity: 0; transform: translateY(3px); transition-delay: ${n?.15*n-.05:0}s;">\n\t\t\t\t\t${e.image}\n\n\t\t\t\t\t<div class="ct-trending-block-item-content">\n\t\t\t\t\t\t${e.taxonomy}\n\t\t\t\t\t\t<a href="${e.url}" class="ct-post-title">\n\t\t\t\t\t\t\t${e.title}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t${e.price}\n\t\t\t\t\t</div>\n\t\t\t\t</a>`)}),setTimeout(function(){t.el.querySelectorAll(".ct-trending-block-item").forEach(function(t,e){t.style.opacity=1,t.style.transform="translateY(0)",t.style.transitionDelay=(e?.15*e-.05:0)+"s"}),requestAnimationFrame(function(){setTimeout(function(){t.el.querySelectorAll(".ct-trending-block-item").forEach(function(t){t.removeAttribute("style")})},650)})},50)})};(0,window.ctFrontend.registerDynamicChunk)("blocksy_ext_trending",{mount:function(t,{event:e}){const n=t.closest("[data-page]");t.classList.contains("ct-arrow-prev")&&i({el:n,action:"prev"}),t.classList.contains("ct-arrow-next")&&i({el:n,action:"next"})}})}();