!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,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 r={},o=function(t={}){if(t=function(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){var r,i,c;r=t,i=n,c=o[n],(i=e(i))in r?Object.defineProperty(r,i,{value:c,enumerable:!0,configurable:!0,writable:!0}):r[i]=c})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(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 o=parseInt(t.el.dataset.page,10);if("prev"===t.action&&1===o)return;if(t.el.querySelectorAll(".ct-trending-block-item").length<4&&1===o)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?o-1:o+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}`,r[c]?new Promise((function(t){t(r[c]),window.ct_customizer_localizations||(r[c]=r[c].clone())})):new Promise((function(t){return fetch(c).then((function(e){t(e),window.ct_customizer_localizations||(r[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")&&o({el:n,action:"prev"}),t.classList.contains("ct-arrow-next")&&o({el:n,action:"next"})}})}();