(()=>{"use strict";var e=jQuery,t=e("body"),i=function(t){var i;if(void 0!==e.fn.block){var r="#fff center center no-repeat";"undefined"!=typeof yith_wcan_shortcodes&&null!==(i=yith_wcan_shortcodes)&&void 0!==i&&i.loader&&(r="url('".concat(yith_wcan_shortcodes.loader,"') ").concat(r)),t.block({message:null,overlayCSS:{background:r,opacity:.7}})}},r=function(t){void 0!==e.fn.unblock&&t.unblock()};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function a(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function o(e,t,i){return(t=l(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var s=function(){return l=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"xhr",null),o(this,"doingAjax",!1),o(this,"originalSearch",location.search),o(this,"initialized",!1),o(this,"filtered",!1),this.initPopState(),this.initialized=!0},s=[{key:"initPopState",value:function(){yith_wcan_shortcodes.reload_on_back&&(this.pushUrlToHistory(window.location,document.title,null,!0),e(window).on("popstate",(function(){var e;null!==(e=window.history.state)&&void 0!==e&&e._yithWcan&&window.location.reload(!0)})))}},{key:"doFilter",value:function(t,i,r){var n,a,o=this,l=e(i||"body");return(a=e(document).triggerHandler("yith_wcan_filters_parameters",[t]))&&(t=a),l&&this.block(l),n=this.buildUrl(t),yith_wcan_shortcodes.ajax_filters?(this.doingAjax=!0,this._doAjax(n).done((function(e){n=o.searchAlternativeUrl(e,n),o._beforeFilter(e,t),o.refreshFragments(i,r,e),o.pushUrlToHistory(n,e.pageTitle,t),o.originalSearch=location.search,l&&o.unblock(l),o._afterFilter(e,t),o.doingAjax=!1}))):(this.pushUrlToHistory(n,document.title,t),void(window.location=n))}},{key:"_beforeFilter",value:function(t,i){e(document).trigger("yith-wcan-ajax-loading",[t,i]),yith_wcan_shortcodes.query_vars=i}},{key:"_afterFilter",value:function(i,r){e(".woocommerce-ordering").on("change","select.orderby",(function(){e(this).closest("form").submit()})),this.filtered=r&&!!Object.keys(r).length,this.filtered?t.addClass("filtered"):t.removeClass("filtered"),e(window).trigger("scroll"),e(document).trigger("yith-wcan-ajax-filtered",[i,r]).trigger("yith_wcwl_reload_after_ajax")}},{key:"buildUrl",value:function(t){var i,r=this,a=yith_wcan_shortcodes.query_param,o={},l=window.location,s=yith_wcan_shortcodes.base_url?yith_wcan_shortcodes.base_url:(null==l?void 0:l.origin)+(null==l?void 0:l.pathname),c=this,u="object"===n(t)&&Object.keys(t).length;if(yith_wcan_shortcodes.session_param&&(s=s.replace(new RegExp("/"+yith_wcan_shortcodes.session_param+"/[^/]*/"),"")),u&&(o[a]=1),this.originalSearch){var h=this.originalSearch.replace("?","").split("&").reduce((function(e,t){var i=t.split("=");if(2===i.length){if(r.isFilterParam(i[0]))return e;e[i[0]]=i[1]}return e}),{});o=e.extend(o,h)}return u&&(o=e.extend(o,t)),(i=Object.keys(o).reduce((function(e,t){var i=o[t];return i&&t?e+=c._cleanParam(t)+"="+c._cleanParam(i)+"&":e}),"?").replace(/&$/g,"").replace(/%2B/g,"+").replace(/%2C/g,",")).length>1&&(s+=i),s}},{key:"searchAlternativeUrl",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return-1===e.indexOf("yith_wcan:sharing_url")?i:i=(t=e.match(/<meta name="yith_wcan:sharing_url" content="([^"]*)">/))&&1 in t?t[1]:i}},{key:"pushUrlToHistory",value:function(e,t,i,r){if(yith_wcan_shortcodes.change_browser_url&&!navigator.userAgent.match(/msie/i)){var n="pushState";r&&(n="replaceState"),window.history[n]({_yithWcan:!0,pageTitle:t,filters:i},"",e)}}},{key:"refreshFragments",value:function(t,i,r){var n=document.createElement("html"),a=e(n);if(n.innerHTML=r,t){var o,l=e(i),s=e(t);l.length&&(o=a.find(i)).length&&l.replaceWith(o.first()),s.length&&(o=a.find(t)).length&&s.replaceWith(o.first())}else{var c=e(yith_wcan_shortcodes.content);c.length?c.replaceWith(a.find(yith_wcan_shortcodes.content)):e("body").replaceWith(a.find("body"))}e(document).trigger("yith_wcan_init_shortcodes")}},{key:"_cleanParam",value:function(e){var t,i;return null===(t=yith_wcan_shortcodes)||void 0===t||!t.process_sanitize||null!==(i=yith_wcan_shortcodes)&&void 0!==i&&i.skip_sanitize?e:encodeURIComponent(e)}},{key:"_doAjax",value:function(t,i){return this.xhr&&this.xhr.abort(),i=e.extend({url:t,headers:{"X-YITH-WCAN":1}},i),this.xhr=e.ajax(i),this.xhr}},{key:"block",value:function(e){return i(e)}},{key:"unblock",value:function(e){return r(e)}},{key:"isFilterParam",value:function(t){var i,r=["rating_filter","min_price","max_price","price_ranges","onsale_filter","instock_filter","featured_filter","orderby","product-page",yith_wcan_shortcodes.query_param];return(i=e(document).triggerHandler("yith_wcan_supported_filters_parameters",[r]))&&(r=i),-1!==(r=r.concat(yith_wcan_shortcodes.supported_taxonomies.map((function(e){return e.replace("pa_","filter_")})))).indexOf(t)||-1!==t.indexOf("filter_")||-1!==t.indexOf("query_type_")}}],s&&a(l.prototype,s),c&&a(l,c),Object.defineProperty(l,"prototype",{writable:!1}),l;var l,s,c}();function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function h(e,t,i){return t&&u(e.prototype,t),i&&u(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){var t=function(e,t){if("object"!=c(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==c(t)?t:t+""}var d=h((function t(i){var r,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,a=null,(n=f(n="$reset"))in r?Object.defineProperty(r,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[n]=a,this.$reset=i,this.$reset.on("click",(function(t){t.preventDefault(),e(".yith-wcan-filters").each((function(){var t=e(this).data("preset");t.deactivateAllFilters(!0),t.closeModal()}))})),this.$reset.data("reset",this).addClass("enhanced")}));function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function v(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return y(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?y(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function m(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */m=function(){return t};var e,t={},i=Object.prototype,r=i.hasOwnProperty,n=Object.defineProperty||function(e,t,i){e[t]=i.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function c(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,i){return e[t]=i}}function u(e,t,i,r){var a=t&&t.prototype instanceof _?t:_,o=Object.create(a.prototype),l=new A(r||[]);return n(o,"_invoke",{value:j(e,i,l)}),o}function h(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function _(){}function b(){}function w(){}var k={};c(k,o,(function(){return this}));var F=Object.getPrototypeOf,x=F&&F(F(L([])));x&&x!==i&&r.call(x,o)&&(k=x);var C=w.prototype=_.prototype=Object.create(k);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function $(e,t){function i(n,a,o,l){var s=h(e[n],e,a);if("throw"!==s.type){var c=s.arg,u=c.value;return u&&"object"==p(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){i("next",e,o,l)}),(function(e){i("throw",e,o,l)})):t.resolve(u).then((function(e){c.value=e,o(c)}),(function(e){return i("throw",e,o,l)}))}l(s.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function j(t,i,r){var n=f;return function(a,o){if(n===v)throw Error("Generator is already running");if(n===y){if("throw"===a)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var l=r.delegate;if(l){var s=O(l,r);if(s){if(s===g)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var c=h(t,i,r);if("normal"===c.type){if(n=r.done?y:d,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=y,r.method="throw",r.arg=c.arg)}}}function O(t,i){var r=i.method,n=t.iterator[r];if(n===e)return i.delegate=null,"throw"===r&&t.iterator.return&&(i.method="return",i.arg=e,O(t,i),"throw"===i.method)||"return"!==r&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var a=h(n,t.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,g;var o=a.arg;return o?o.done?(i[t.resultName]=o.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,g):o:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,g)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function L(t){if(t||""===t){var i=t[o];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function i(){for(;++n<t.length;)if(r.call(t,n))return i.value=t[n],i.done=!1,i;return i.value=e,i.done=!0,i};return a.next=a}}throw new TypeError(p(t)+" is not iterable")}return b.prototype=w,n(C,"constructor",{value:w,configurable:!0}),n(w,"constructor",{value:b,configurable:!0}),b.displayName=c(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,c(e,s,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},S($.prototype),c($.prototype,l,(function(){return this})),t.AsyncIterator=$,t.async=function(e,i,r,n,a){void 0===a&&(a=Promise);var o=new $(u(e,i,r,n),a);return t.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(C),c(C,s,"Generator"),c(C,o,(function(){return this})),c(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),i=[];for(var r in t)i.push(r);return i.reverse(),function e(){for(;i.length;){var r=i.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=L,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var i in this)"t"===i.charAt(0)&&r.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function n(r,n){return l.type="throw",l.arg=t,i.next=r,n&&(i.method="next",i.arg=e),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],l=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),E(i),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;E(i)}return n}}throw Error("illegal catch attempt")},delegateYield:function(t,i,r){return this.delegate={iterator:L(t),resultName:i,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function g(e,t,i,r,n,a,o){try{var l=e[a](o),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(r,n)}function _(e){return function(){var t=this,i=arguments;return new Promise((function(r,n){var a=e.apply(t,i);function o(e){g(a,r,n,o,l,"next",e)}function l(e){g(a,r,n,o,l,"throw",e)}o(void 0)}))}}function b(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,k(r.key),r)}}function w(e,t,i){return(t=k(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function k(e){var t=function(e,t){if("object"!=p(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==p(t)?t:t+""}var F=function(){return t=function t(i,r){var n,a,o,l;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),w(this,"$originalSelect",null),w(this,"_items",[]),w(this,"$_main",null),w(this,"$_label",null),w(this,"$_dropdown",null),w(this,"$_search",null),w(this,"$_showMore",null),w(this,"$_items",null),w(this,"paginate",!1),w(this,"hasMore",!1),w(this,"needsRefresh",!0),w(this,"multiple",!1),w(this,"currentPage",1),w(this,"options",{}),this.$originalSelect=i,this.$originalSelect.is("select")){var s=this.$originalSelect.data("per_page"),c=this.$originalSelect.data("order"),u=this.$originalSelect.data("all-label"),h={showSearch:this.$originalSelect.data("show_search"),paginate:this.$originalSelect.data("paginate"),perPage:s||10,hasMore:!1,order:c||"ASC",getElements:null,labels:{emptyLabel:u||(null===(n=yith_wcan_shortcodes.labels)||void 0===n?void 0:n.empty_option),searchPlaceholder:null===(a=yith_wcan_shortcodes.labels)||void 0===a?void 0:a.search_placeholder,noItemsFound:null===(o=yith_wcan_shortcodes.labels)||void 0===o?void 0:o.no_items,showMore:null===(l=yith_wcan_shortcodes.labels)||void 0===l?void 0:l.show_more}};this.multiple=this.$originalSelect.prop("multiple"),this.options=e.extend(h,r),this.paginate=this.options.paginate||!1,this.hasMore=this.options.hasMore||!1,this._hideSelect(),this._initTemplate(),this._initActions(),this.$originalSelect.data("dropdown",this).addClass("enhanced")}},i=[{key:"_hideSelect",value:function(){this.$originalSelect.hide()}},{key:"_initTemplate",value:function(){var t=e("<div/>",{class:"yith-wcan-dropdown closed"}),i=e("<div/>",{class:"dropdown-label",html:this.getLabel()}),r=e("<div>",{class:"dropdown-wrapper"}),n=e("<ul/>",{class:"matching-items filter-items"});r.append(n),t.append(i).append(r),this.options.showSearch&&this._initSearchTemplate(r),this.options.paginate&&this._initShowMoreTemplate(r),this.$originalSelect.after(t),this.$_main=t,this.$_label=i,this.$_dropdown=r,this.$_items=n}},{key:"_initSearchTemplate",value:function(t){var i=e("<div/>",{class:"search-field-container"}),r=e("<input/>",{name:"s",class:"search-field",type:"search",placeholder:this.options.labels.searchPlaceholder}).attr("autocomplete","off");i.append(r).prependTo(t),this.$_search=r}},{key:"_initShowMoreTemplate",value:function(t){var i,r=e("<a/>",{class:"show-more",text:null===(i=this.options.labels.showMore)||void 0===i?void 0:i.replace("%d",this.options.perPage)});r.on("click",this.loadNextPage.bind(this)).hide(),t.append(r),this.$_showMore=r}},{key:"_initActions",value:function(){var t,i,r=this,n=this;null===(t=this.$_main)||void 0===t||t.on("click",(function(e){e.stopPropagation(),n.toggleDropdown()})),this.$_dropdown.on("click",(function(e){e.stopPropagation()})),null===(i=this.$_search)||void 0===i||i.on("keyup search change",(function(){return r.paginate=!1,r._populateItems().then((function(){r.needsRefresh=!0})),!1})),this.$_items.on("change",":input",(function(){var t,i=e(this).closest("li"),r=i.data("value");if(i.hasClass("disabled")&&!n.isValueSelected(r))return!1;i.toggleClass("active"),t=i.hasClass("active"),n._changeItemStatus(r,t)})),this.$_items.on("click","li:not(.checkbox) a",(function(t){var i,r=e(this).closest("li"),a=r.data("value");if(t.preventDefault(),r.hasClass("disabled")&&!n.isValueSelected(a))return!1;r.toggleClass("active"),(i=r.hasClass("active"))&&r.siblings().removeClass("active"),n._changeItemStatus(a,i)})),this.$_items.on("click","label > a",(function(t){var i=e(this).parent().find(":input");t.preventDefault(),(i.is('[type="radio"]')||i.is('[type="checkbox"]'))&&i.prop("checked",!i.prop("checked")),i.change()})),this.$originalSelect.on("change",(function(e,t){t||n.updateLabel()})),null!==globalThis&&void 0!==globalThis&&globalThis.yith_wcan_dropdown_init||(e(document).on("click",this._closeAllDropdowns),globalThis.yith_wcan_dropdown_init=!0)}},{key:"openDropdown",value:function(){var e;null===(e=this.$_main)||void 0===e||e.addClass("open").removeClass("closed"),this._afterDropdownOpen()}},{key:"closeDropdown",value:function(){var e;null===(e=this.$_main)||void 0===e||e.removeClass("open").addClass("closed")}},{key:"_closeAllDropdowns",value:function(){e(document).find("select.enhanced").filter((function(t,i){return!!e(i).data("dropdown")})).each((function(){e(this).data("dropdown").closeDropdown()}))}},{key:"_closeOtherDropdowns",value:function(){var t=this;e(document).find("select.enhanced").filter((function(i,r){var n=e(r);return!!n.data("dropdown")&&!n.is(t.$originalSelect)})).each((function(){e(this).data("dropdown").closeDropdown()}))}},{key:"toggleDropdown",value:function(){var e,t;null===(e=this.$_main)||void 0===e||e.toggleClass("open").toggleClass("closed"),null!==(t=this.$_main)&&void 0!==t&&t.hasClass("open")&&this._afterDropdownOpen()}},{key:"_afterDropdownOpen",value:function(){var e;this._closeOtherDropdowns(),null!==(e=this.$_search)&&void 0!==e&&e.length&&this.$_search.val(""),this._maybePopulateItems()}},{key:"getItems",value:(a=_(m().mark((function t(i){var r,n,a=this;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._items.length||this.getOptions().each((function(t,i){var r=e(i),n=r.val(),o=r.html();a._items.push({value:n,label:o})})),t.next=3,this.getMatchingElements(i);case 3:return r=t.sent,(n=this.paginate?this.options.perPage:0)&&r.length>n&&(this.hasMore=!0,r=r.slice(0,n)),t.abrupt("return",r);case 7:case"end":return t.stop()}}),t,this)}))),function(e){return a.apply(this,arguments)})},{key:"getMatchingElements",value:function(e){var t=this,i=this._items;return new Promise((function(r){i=e?i.filter((function(t){var i=t.label,r=t.value,n=new RegExp(".*"+e+".*","i");return n.test(r)||n.test(i)})):i,t.options.getElements?t.options.getElements.call(t,e).then((function(e){e&&(e=Object.keys(e).reduce((function(t,i){return e[i].label?(t.push(e[i]),t):(t.push({label:e[i],value:i}),t)}),[]),i=[].concat(v(i),v(e))),r(t._formatItems(i))})):r(t._formatItems(i))}))}},{key:"_formatItems",value:function(e){var t=this,i=[];return e.filter((function(e){var r=e.value,n=e.label;return-1===i.indexOf(r)&&(i.push(r),t.getOptionByValue(r).length||t.$originalSelect.append('<option class="filter-item" value="'.concat(r,'">').concat(n,"</option>")),!0)}))}},{key:"_generateItem",value:function(t,i){var r,n=this.isValueSelected(t),a=this.getOptionByValue(t),o=e("<li/>",{"data-value":t,class:a.length?a.attr("class"):""});if(a.length){var l=a.data("template"),s=a.data("count");i=l||i,s&&(i+=s)}if(r=e("<a/>",{href:a.length?a.data("filter_url"):"#",html:i,rel:"nofollow","data-title":a.length?a.data("title"):""}),this.multiple){var c=e("<input/>",{type:"checkbox",value:t}),u=e("<label>");c.prop("checked",n),u.prepend(c).append(r),o.append(u).addClass("checkbox")}else o.append(r);return n?o.addClass("active"):o.removeClass("active"),o}},{key:"_maybePopulateItems",value:function(){this.needsRefresh&&this._populateItems()}},{key:"_populateItems",value:function(){var e,t=this,i=!(null===(e=this.$_search)||void 0===e||!e.length)&&this.$_search.val();return this.getItems(i).then((function(e){t._emptyItems(),t._hideLoadMore(),t.$_items.append(e.map((function(e){var i=e.label,r=e.value;return t._generateItem(r,i)}))),t.$originalSelect.trigger("yith_wcan_dropdown_updated"),t.needsRefresh=!1,t.paginate&&t.hasMore&&t._showLoadMore()}))}},{key:"loadNextPage",value:(n=_(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.paginate=!1,this._populateItems().then((function(){t.hasMore=!1}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_selectItem",value:function(e){return this._changeItemStatus(e,!0)}},{key:"_deselectItem",value:function(e){return this._changeItemStatus(e,!1)}},{key:"_changeItemStatus",value:function(e,t){var i=this.$originalSelect.find('option[value="'.concat(e,'"]'));return!!i.length&&(i.prop("selected",t),!yith_wcan_shortcodes.instant_filters&&this.multiple||this.closeDropdown(),this.updateLabel(),this.$originalSelect.trigger("change",[!0]),!0)}},{key:"_emptyItems",value:function(){this.$_items.html("")}},{key:"_showLoadMore",value:function(){this.$_showMore.show()}},{key:"_hideLoadMore",value:function(){this.$_showMore.hide()}},{key:"getLabel",value:function(){return this.hasSelectedValues()?this.getSelectedLabels().join(", "):this.options.labels.emptyLabel}},{key:"updateLabel",value:function(){var e,t=this.getLabel();null===(e=this.$_label)||void 0===e||e.html(t)}},{key:"getOptions",value:function(){return this.$originalSelect.find("option")}},{key:"hasSelectedValues",value:function(){return this.getSelectedOptions().length}},{key:"isValueSelected",value:function(e){return-1!==this.getSelectedValues().indexOf(e.toString())}},{key:"getSelectedOptions",value:function(){return this.$originalSelect.find("option").filter(":selected")}},{key:"getOptionByValue",value:function(e){return this.$originalSelect.find('option[value="'.concat(e,'"]'))}},{key:"getSelectedLabels",value:function(){var t=[];return this.getSelectedOptions().each((function(){var i=e(this),r=i.data("template");r=r||i.html().replace(/\([0-9]*\)/,""),t.push(r)})),t}},{key:"getSelectedValues",value:function(){var t=[];return this.getSelectedOptions().each((function(){t.push(e(this).val())})),t}},{key:"destroy",value:function(){}}],i&&b(t.prototype,i),r&&b(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,r,n,a}();function x(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(e){if("string"==typeof e)return C(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?C(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){l=!0,a=e},f:function(){try{o||null==i.return||i.return()}finally{if(l)throw a}}}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function $(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */$=function(){return t};var e,t={},i=Object.prototype,r=i.hasOwnProperty,n=Object.defineProperty||function(e,t,i){e[t]=i.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function c(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,i){return e[t]=i}}function u(e,t,i,r){var a=t&&t.prototype instanceof m?t:m,o=Object.create(a.prototype),l=new A(r||[]);return n(o,"_invoke",{value:j(e,i,l)}),o}function h(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",d="suspendedYield",p="executing",v="completed",y={};function m(){}function g(){}function _(){}var b={};c(b,o,(function(){return this}));var w=Object.getPrototypeOf,k=w&&w(w(L([])));k&&k!==i&&r.call(k,o)&&(b=k);var F=_.prototype=m.prototype=Object.create(b);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function i(n,a,o,l){var s=h(e[n],e,a);if("throw"!==s.type){var c=s.arg,u=c.value;return u&&"object"==S(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){i("next",e,o,l)}),(function(e){i("throw",e,o,l)})):t.resolve(u).then((function(e){c.value=e,o(c)}),(function(e){return i("throw",e,o,l)}))}l(s.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function j(t,i,r){var n=f;return function(a,o){if(n===p)throw Error("Generator is already running");if(n===v){if("throw"===a)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var l=r.delegate;if(l){var s=O(l,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=h(t,i,r);if("normal"===c.type){if(n=r.done?v:d,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=v,r.method="throw",r.arg=c.arg)}}}function O(t,i){var r=i.method,n=t.iterator[r];if(n===e)return i.delegate=null,"throw"===r&&t.iterator.return&&(i.method="return",i.arg=e,O(t,i),"throw"===i.method)||"return"!==r&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var a=h(n,t.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,y;var o=a.arg;return o?o.done?(i[t.resultName]=o.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,y):o:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,y)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function L(t){if(t||""===t){var i=t[o];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function i(){for(;++n<t.length;)if(r.call(t,n))return i.value=t[n],i.done=!1,i;return i.value=e,i.done=!0,i};return a.next=a}}throw new TypeError(S(t)+" is not iterable")}return g.prototype=_,n(F,"constructor",{value:_,configurable:!0}),n(_,"constructor",{value:g,configurable:!0}),g.displayName=c(_,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,c(e,s,"GeneratorFunction")),e.prototype=Object.create(F),e},t.awrap=function(e){return{__await:e}},x(C.prototype),c(C.prototype,l,(function(){return this})),t.AsyncIterator=C,t.async=function(e,i,r,n,a){void 0===a&&(a=Promise);var o=new C(u(e,i,r,n),a);return t.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},x(F),c(F,s,"Generator"),c(F,o,(function(){return this})),c(F,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),i=[];for(var r in t)i.push(r);return i.reverse(),function e(){for(;i.length;){var r=i.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=L,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var i in this)"t"===i.charAt(0)&&r.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function n(r,n){return l.type="throw",l.arg=t,i.next=r,n&&(i.method="next",i.arg=e),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],l=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),E(i),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;E(i)}return n}}throw Error("illegal catch attempt")},delegateYield:function(t,i,r){return this.delegate={iterator:L(t),resultName:i,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function j(e,t,i,r,n,a,o){try{var l=e[a](o),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(r,n)}function O(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function P(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){A(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function E(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,L(r.key),r)}}function A(e,t,i){return(t=L(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function L(e){var t=function(e,t){if("object"!=S(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=S(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==S(t)?t:t+""}var T=function(){return t=function t(i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),A(this,"preset",!1),A(this,"$preset",!1),A(this,"target",!1),A(this,"$target",!1),A(this,"$filters",!1),A(this,"$filterButtons",!1),A(this,"modalElements",{}),A(this,"activeFilters",!1),A(this,"isMobile",!1),A(this,"sliderTimeout",!1),A(this,"originalFilters",null),A(this,"dirty",!1),A(this,"loaded",void 0),A(this,"inhibitFilters",!1),this.preset="#"+i.attr("id"),this.$preset=i,this.target=this.$preset.data("target"),this.$target=!!this.target&&e(this.target),this._regiterStatus(),this._initFilterButton(),this._initFilters(),this._initResponsive(),this._initActions(),this.$preset.data("preset",this).addClass("enhanced").trigger("yith_wcan_preset_initialized",[this])},n=[{key:"_initFilters",value:function(){var t=this,i=this.getFilters().get().map((function(i){return t._initFilter(e(i))}));this.loaded=Promise.all(i),this.maybeShowClearAllFilters()}},{key:"_initFilterButton",value:function(){var e=this;this.$filterButtons=this.$preset.find(".apply-filters"),this.$filterButtons.length&&this.$filterButtons.on("click",(function(t){t.preventDefault(),e.filter()})).hide()}},{key:"_initActions",value:function(){this.$preset.find("form").on("submit",(function(e){e.preventDefault()}))}},{key:"_initResponsive",value:function(){var t=this;if(yith_wcan_shortcodes.modal_on_mobile){var i=window.matchMedia("(max-width: ".concat(yith_wcan_shortcodes.mobile_media_query,"px)"));e(window).on("resize",(function(){var e=!!i.matches;e!==t.isMobile&&(t.isMobile=e,t._afterLayoutChange())})).resize()}}},{key:"_initFilter",value:function(t){var i=this,r=this,n=function(i){var n=e(this),a=n.closest(".yith-wcan-filter"),o=!!a.length&&"yes"===a.data("multiple"),l=n.closest(".filter-item"),s=l.length?a.find(".filter-item").not(l):[];return!a.is(".filter-price-slider")&&!(l.is(".disabled")&&!l.is(".active"))&&(i.preventDefault(),s.length&&!o&&s.removeClass("active").children("label").find(":input").prop("checked",!1).parent(".checked").removeClass("checked"),l.length&&l.toggleClass("active"),r.activeFilters=!1,r.maybeFilter(t),r.maybeToggleClearAllFilters(),void r.maybeToggleClearFilter(a))};return this._maybeLoadFilter(t).then((function(t){return t.on("click","a",(function(t){var i=e(this).closest(".filter-item");!i.length||i.is(".checkbox")||i.is(".radio")||n.call(this,t)})),t.on("change",":input",(function(t){var i=e(this),r=i.closest(".filter-item");if(r.is(".disabled")&&!r.is(".active"))return i.prop("checked",!1),!1;n.call(this,t)})),t.on("click","label > a",(function(t){var i=e(this),r=i.closest(".filter-item");if(t.preventDefault(),r.is(".disabled")&&!r.is(".active"))return!1;var n=i.parent().find(":input");(n.is('[type="radio"]')||n.is('[type="checkbox"]'))&&n.prop("checked",!n.prop("checked")),n.change()})),i._initFilterChildren(t),i.maybeShowClearFilter(t),t}))}},{key:"_initFilterChildren",value:function(t){var i,r=this;this._initTooltip(t),this._initPriceSlider(t),this._initDropdown(t),this._initCollapsable(t),this._initShowMore(t),null!==(i=this.$preset)&&void 0!==i&&i.hasClass("custom-style")&&(this._initCustomInput(t),t.on("yith_wcan_dropdown_updated",(function(t){var i=e(t.target).closest(".yith-wcan-filter");r._initCustomInput(i)})))}},{key:"_maybeLoadFilter",value:function(t){var i=this;return t.hasClass("filter-placeholder")?new Promise((function(r){var n;e.ajax({method:"GET",url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_render_filter",_preset_id:i.getId(),_filter_id:t.data("filter-id"),security:null===(n=yith_wcan_shortcodes.nonces)||void 0===n?void 0:n.render_filter},i.originalFilters)}).then((function(e){var n;return r(i._loadFilter(t,e.success?null==e||null===(n=e.data)||void 0===n?void 0:n.html:""))}))})):Promise.resolve(t)}},{key:"_loadFilter",value:function(t,i){if(!i)return t.remove();var r=e(i);return t.replaceWith(r),this.$filters=!1,r}},{key:"_initTooltip",value:function(t,i){t.find("[data-title]").each((function(){var t=e(this);!t.hasClass("tooltip-added")&&t.data("title")&&(t.on("mouseenter",(function(){var t,r=e(this),n=null,a=r.outerWidth(),o=0;if(!i||"top"!==i&&"right"!==i){var l=r.closest(".filter-item");i=l.hasClass("color")||l.hasClass("label")?"top":"right"}n=e("<span>",{class:"yith-wcan-tooltip",html:r.data("title")}),r.append(n),t=n.outerWidth()+6,n.outerWidth(t),o="top"===i?(a-t)/2:a+15,n.css({left:o.toFixed(0)+"px"}).fadeIn(200),r.addClass("with-tooltip")})).on("mouseleave",(function(){var t=e(this);t.find(".yith-wcan-tooltip").fadeOut(200,(function(){t.removeClass("with-tooltip").find(".yith-wcan-tooltip").remove()}))})),t.addClass("tooltip-added"))}))}},{key:"_initDropdown",value:function(t){var i=t.find("select.filter-dropdown");if(i.length&&!i.hasClass("enhanced")){i.hasClass("select2-hidden-accessible")&&void 0!==e.fn.selectWoo&&i.selectWoo("destroy");var r=this,n=i.data("has-more");this._initDropdownObject(i,P({paginate:!0,hasMore:n,perPage:parseInt(yith_wcan_shortcodes.terms_per_page)},n?{getElements:function(e){var i,n=this;return(i=$().mark((function i(){return $().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n.paginate&&n.hasMore||e){i.next=2;break}return i.abrupt("return",n._items);case 2:return i.abrupt("return",r._getTerms(t,e));case 3:case"end":return i.stop()}}),i)})),function(){var e=this,t=arguments;return new Promise((function(r,n){var a=i.apply(e,t);function o(e){j(a,r,n,o,l,"next",e)}function l(e){j(a,r,n,o,l,"throw",e)}o(void 0)}))})()}}:{}))}}},{key:"_initDropdownObject",value:function(e,t){return new F(e,t)}},{key:"_initPriceSlider",value:function(e){var t=this;if(e.hasClass("filter-price-slider")){var i=this,r=e.find(".price-slider"),n=r.find(".price-slider-min"),a=r.find(".price-slider-max"),o=parseFloat(r.data("min")),l=parseFloat(r.data("max")),s=parseFloat(n.val()),c=parseFloat(a.val()),u=parseFloat(r.data("step")),h=function(){i.sliderTimeout&&clearTimeout(i.sliderTimeout),i.sliderTimeout=setTimeout((function(){i.maybeFilter(e)}),300)};e.find(".price-slider-ui").off("change").ionRangeSlider({skin:"round",type:"double",min:o,max:l,step:u,from:s,to:c,min_interval:u,values_separator:" - ",prettify:function(e){return t.formatPrice(e)},onChange:function(e){n.val(e.from),a.val(e.to)},onFinish:h}),n.add(a).off("change").on("change",h).on("keyup",(function(e){if(!e.key.match(/[0-9,.]/))return e.preventDefault(),!1;n.val()&&a.val()&&h()}))}}},{key:"_initCollapsable",value:function(e){this._initTitleCollapsable(e),this._initHierarchyCollapsable(e)}},{key:"_initShowMore",value:function(e){var t=this,i=e.find(".filter-content").children(".show-more");i.length&&!i.hasClass("initialized")&&i.addClass("initialized").on("click",(function(){return t._loadItems(e).then((function(){return i.remove()}))}))}},{key:"_getTerms",value:function(t,n){var a=this;return new Promise((function(o){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return r(t)},url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_get_filter_terms",_preset_id:a.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.get_filter_terms,search:n},a.originalFilters)}).then((function(e){var t,i=e.success?null==e||null===(t=e.data)||void 0===t?void 0:t.items:{};o(i)}))}))}},{key:"_loadItems",value:function(t){var n=this;return new Promise((function(a){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return r(t)},url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_render_remaining_terms",_preset_id:n.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.render_remaining_terms},n.originalFilters)}).then((function(e){var i,r=t.find(".filter-content").children(".filter-items");r.append(e.success?null==e||null===(i=e.data)||void 0===i?void 0:i.html:""),n._initFilterChildren(t),a(r)}))}))}},{key:"_initTitleCollapsable",value:function(e){var t=e.find(".collapsable");t.length&&!t.hasClass("toggle-initialized")&&this._initToggle(t,t,e.find(".filter-content"))}},{key:"_initHierarchyCollapsable",value:function(t){var i=t.find(".hierarchy-collapsable");if(i.length){var r=this,n=t.find(".active");n.length&&(n.parents(".hierarchy-collapsable").removeClass("closed").addClass("opened"),n.hasClass("hierarchy-collapsable")&&yith_wcan_shortcodes.show_current_children&&n.removeClass("closed").addClass("opened")),i.each((function(){var t=e(this);if(!t.hasClass("toggle-initialized")){var i=e("<span/>",{class:"toggle-handle"});i.appendTo(t),r._initToggle(i,t,t.children("ul.filter-items"))}}))}}},{key:"_initToggle",value:function(e,t,i){var r=this;t.hasClass("toggle-initialized")||(t.hasClass("closed")&&i.hide(),e.off("click").on("click",(function(e){e.stopPropagation(),e.preventDefault(),r.toggle(i,t),i.trigger("yith_wcan_after_toggle_element",[t])})),t.addClass("toggle-initialized"))}},{key:"_initCustomInput",value:function(t){t.find(":input").each((function(){var t,i=e(this),r=i.attr("type"),n="".concat(r,"button");"checkbox"!==r&&"radio"!==r||i.closest(".".concat(n)).length||(i.is(":checked")&&(n+=" checked"),t=e("<span/>",{class:n}),i.wrap(t).on("change",(function(){var t=e(this);t.prop("checked")?t.parent().addClass("checked"):t.parent().removeClass("checked")})))}))}},{key:"_regiterStatus",value:function(){this.originalFilters=this.mergeProperties(yith_wcan_shortcodes.query_vars,this.getFiltersProperties())}},{key:"_afterLayoutChange",value:function(){var t,i,r=this;this.isMobile?(this.$preset.addClass("filters-modal").attr("role","dialog").attr("tabindex","-1").hide(),this._addCloseModalButton(),this._addApplyFiltersModalButton(),this.loaded.then((function(){return r._switchToCollapsables()})),null===(t=this.$filterButtons)||void 0===t||t.hide()):(this.$preset.removeClass("filters-modal").removeClass("open").removeAttr("role").removeAttr("tabindex").show(),e("body").css("overflow","auto").removeClass("yith-wcan-preset-modal-open"),this._removeCloseModalButton(),this._removeApplyFiltersModalButton(),this.loaded.then((function(){return r._switchBackCollapsables()})),null===(i=this.$filterButtons)||void 0===i||i.show())}},{key:"_addCloseModalButton",value:function(){var t=e("<a/>",{class:"close-button",html:"&times;","data-dismiss":"modal","aria-label":yith_wcan_shortcodes.labels.close});t.prependTo(this.$preset).on("click",this.closeModal.bind(this)),this.modalElements.closeButton=t}},{key:"_removeCloseModalButton",value:function(){var e;null===(e=this.modalElements)||void 0===e||null===(e=e.closeButton)||void 0===e||e.remove()}},{key:"_addApplyFiltersModalButton",value:function(){var t=this,i=e("<button/>",{class:"apply-filters main-modal-button",html:yith_wcan_shortcodes.labels.show_results,"data-dismiss":"modal"});i.appendTo(this.$preset).on("click",(function(){t.filter(),t.closeModal()})),this.modalElements.applyFiltersButton=i}},{key:"_removeApplyFiltersModalButton",value:function(){var e;null===(e=this.modalElements)||void 0===e||null===(e=e.applyFiltersButton)||void 0===e||e.remove()}},{key:"_switchToCollapsables",value:function(){var t=this;this.getFilters().each((function(){var i=e(this),r=i.find(".filter-title");r.length&&!r.hasClass("collapsable")&&(r.addClass("collapsable").data("disable-collapse",!0),t._initTitleCollapsable(i))}))}},{key:"_switchBackCollapsables",value:function(){this.getFilters().each((function(){var t=e(this),i=t.find(".filter-title");i.length&&i.hasClass("collapsable")&&i.data("disable-collapse")&&(i.removeClass("collapsable").removeData("disable-collapse",!0).off("click"),t.find(".filter-content").show())}))}},{key:"_openAllCollapsables",value:function(){var t=this;this.getFilters().not(".no-title").not((function(i,r){return t.isFilterActive(e(r))})).find(".filter-content").show().end().find(".filter-title").removeClass("closed").addClass("opened")}},{key:"_closeAllCollapsables",value:function(){var t=this;this.getFilters().not(".no-title").not((function(i,r){return t.isFilterActive(e(r))})).find(".filter-content").hide().end().find(".filter-title").addClass("closed").removeClass("opened")}},{key:"maybeRegisterStatusChange",value:function(){var e=this.getFiltersProperties(),t=JSON.stringify(e),i=JSON.stringify(this.originalFilters);this.dirty=t!==i}},{key:"maybeFilter",value:function(e){if(this.maybeRegisterStatusChange(),!this.inhibitFilters)if(yith_wcan_shortcodes.instant_filters&&!this.isMobile)this.filter();else if(yith_wcan_shortcodes.instant_filters||this.isMobile){if(this.isMobile&&this.dirty){var t;this.$preset.addClass("with-filter-button"),null===(t=this.modalElements.applyFiltersButton)||void 0===t||t.show()}}else{var i,r;this.dirty?null===(i=this.$filterButtons)||void 0===i||i.show():null===(r=this.$filterButtons)||void 0===r||r.hide()}}},{key:"filter",value:function(){var t,i,r,n=this,a=null===(t=window)||void 0===t?void 0:t.product_filter;null==a||null===(i=a.doFilter(this.getFiltersProperties(),this.target,this.preset))||void 0===i||i.done((function(){var t=e(n.preset);if(t.length&&yith_wcan_shortcodes.scroll_top){var i=t.offset().top;if(yith_wcan_shortcodes.scroll_target){var r=e(yith_wcan_shortcodes.scroll_target);i=r.length?r.offset().top:i}else n.isMobile&&(i=100);e("body, html").animate({scrollTop:i-100})}n._regiterStatus(),n.dirty=!1})),this.isMobile&&(this.$preset.removeClass("with-filter-button"),null===(r=this.modalElements.applyFiltersButton)||void 0===r||r.hide(),this.closeModal())}},{key:"getId",value:function(){return this.$preset.data("preset-id")}},{key:"getFilters",value:function(){return!1===this.$filters&&(this.$filters=this.$preset.find(".yith-wcan-filter")),this.$filters}},{key:"getActiveFilters",value:function(){return!1===this.activeFilters&&(this.activeFilters=this.getFiltersProperties()),this.activeFilters}},{key:"isAnyFilterActive",value:function(){return!!Object.keys(this.getActiveFilters()).length}},{key:"isFilterActive",value:function(e){var t,i;switch(e.data("filter-type")){case"tax":case"review":case"price_range":var r=e.find(".filter-dropdown");if(r.length){var n=r.val();t="object"===S(n)?!(null==n||!n.length):!!n;break}case"stock_sale":t=e.find(".filter-item").filter(".active").length;break;case"price_slider":var a=parseFloat(e.find(".price-slider").data("step")),o=parseFloat(e.find(".price-slider").data("min")),l=parseFloat(e.find(".price-slider").data("max")),s=parseFloat(e.find(".price-slider-min").val()),c=parseFloat(e.find(".price-slider-max").val());t=Math.abs(s-o)>=a||Math.abs(c-l)>=a;break;case"orderby":t="menu_order"!==e.find(".filter-order-by").val();break;default:t=!1}return t=void 0!==(i=e.triggerHandler("yith_wcan_is_filter_active",[t,this]))?i:t}},{key:"countActiveItems",value:function(e){var t;switch(e.data("filter-type")){case"tax":case"review":case"price_range":var i=e.find(".filter-dropdown");if(i.length){var r=i.val();t="object"===S(r)?null==r?void 0:r.length:+!!r;break}case"stock_sale":t=e.find(".filter-items").find(".active").length;break;case"orderby":this.isFilterActive(e)&&(t=1);break;default:t=0}return t}},{key:"getFilterProperties",value:function(t){var i,r,n=t.data("filter-type"),a="yes"===t.data("multiple"),o=t.find(".filter-dropdown"),l={};switch(n){case"tax":var s=[],c=t.data("taxonomy"),u=0===c.indexOf("filter"),h=t.data("relation");if(o.length?a?s=o.val():s.push(o.val()):s=(r=t.find(".filter-item").filter(".active").children("a, label")).get().reduce((function(t,i){var r;return(r=(i=e(i)).is("label")?i.find(":input").val():i.data("term-slug"))?(t.push(r),t):t}),s),a){var f=u||"and"!==h?",":"+";l[c]=s.join(f)}else l[c]=s.pop();u&&(l[c.replace("filter_","query_type_")]=h);break;case"review":o.length?l.rating_filter=o.val():(r=t.find(".filter-item").filter(".active").children("a, label"),a?l.rating_filter=r.get().reduce((function(t,i){var r;return(r=(i=e(i)).is("label")?i.find(":input").val():i.data("rating"))?(t.push(r),t):t}),[]).join(","):(r=r.first(),l.rating_filter=r.is("label")?r.find(":input").val():r.data("rating")));break;case"price_range":o.length?a?l.price_ranges=o.val().join(","):(l.min_price=o.val().split("-")[0],l.max_price=o.val().split("-")[1]):(r=t.find(".filter-item").filter(".active").children("a, label"),a?l.price_ranges=r.get().reduce((function(t,i){var r=e(i).data("range-min"),n=e(i).data("range-max");return t+=(n?"".concat(r,"-").concat(n):r)+","}),"").replace(/^(.*),$/,"$1"):(l.min_price=parseFloat(r.first().data("range-min")),l.max_price=parseFloat(r.first().data("range-max"))));break;case"price_slider":l.min_price=parseFloat(t.find(".price-slider-min").val()),l.max_price=parseFloat(t.find(".price-slider-max").val());break;case"stock_sale":t.find(".filter-on-sale").is(".active")&&(l.onsale_filter=1),t.find(".filter-in-stock").is(".active")&&(l.instock_filter=1),t.find(".filter-featured").is(".active")&&(l.featured_filter=1);break;case"orderby":l.orderby=t.find(".filter-order-by").val()}return l=void 0!==(i=t.triggerHandler("yith_wcan_filter_properties",[l,self]))?i:l}},{key:"getFiltersProperties",value:function(){var t={},i=this;return this.getFilters().each((function(){var r=e(this);if(i.isFilterActive(r)){var n=i.getFilterProperties(r);t=i.mergeProperties(t,n,r)}})),t}},{key:"getFiltersByProperties",value:function(t){var i=this;return this.getFilters().filter((function(){var r=e(this);if(i.isFilterActive(r)){var n,a=i.getFilterProperties(r),o=!1,l=x(t);try{for(l.s();!(n=l.n()).done;){var s=n.value;if(["min_price","max_price","price_ranges"].includes(s)&&(a.min_price||a.price_ranges)){o=!0;break}if(a[s]){o=!0;break}}}catch(e){l.e(e)}finally{l.f()}return o}return!1}))}},{key:"maybeToggleClearFilter",value:function(e){this.isFilterActive(e)?this.maybeShowClearFilter(e):this.maybeHideClearFilter(e)}},{key:"maybeToggleClearAllFilters",value:function(){this.isAnyFilterActive()?this.maybeShowClearAllFilters():this.maybeHideClearAllFilters()}},{key:"maybeShowClearFilter",value:function(t){var i=this;this.isFilterActive(t)&&yith_wcan_shortcodes.show_clear_filter&&(t.find(".clear-selection").remove(),e("<a/>",{class:"clear-selection",text:yith_wcan_shortcodes.labels.clear_selection,role:"button"}).prependTo(t.find(".filter-content")).on("click",(function(e){e.preventDefault(),i.deactivateFilter(t,!1,yith_wcan_shortcodes.instant_filters),i.maybeHideClearFilter(t),yith_wcan_shortcodes.instant_filters&&i.closeModal()})))}},{key:"maybeShowClearAllFilters",value:function(){var t=this;this.isAnyFilterActive()&&this.isMobile&&(this.$preset.find(".clear-selection").remove(),e("<a/>",{class:"clear-selection",text:yith_wcan_shortcodes.labels.clear_all_selections,role:"button"}).prependTo(this.$preset.find(".filters-container")).on("click",(function(e){e.preventDefault(),t.deactivateAllFilters(yith_wcan_shortcodes.instant_filters),t.maybeHideClearAllFilters(),yith_wcan_shortcodes.instant_filters&&t.closeModal()})))}},{key:"maybeHideClearFilter",value:function(e){!this.isFilterActive(e)&&yith_wcan_shortcodes.show_clear_filter&&e.find(".clear-selection").remove()}},{key:"maybeHideClearAllFilters",value:function(){this.isAnyFilterActive()||this.$preset.find(".filters-container").children(".clear-selection").remove()}},{key:"deactivateFilter",value:function(t,i,r){var n=t.data("filter-type"),a=t.find(".filter-item"),o=a.filter(".active"),l=t.find(".filter-dropdown");switch(this.inhibitFilters=!0,n){case"tax":var s=t.data("taxonomy");l.length?(i?l.find("option").each((function(){var t=e(this);t.val().toString()===i[s].toString()&&t.prop("selected",!1)})):l.find("option").prop("selected",!1),l.change()):i?o.each((function(){var t=e(this),r=t.children("label"),n=t.children("a");(r.length?r.find(":input").val():n.data("term-slug")).toString()===i[s].toString()&&(t.children("label").children("a").click(),t.removeClass("active"))})):(o.children("label").children("a").click(),o.removeClass("active"));break;case"review":l.length?(i?l.find("option").each((function(){var t=e(this);t.val()===i.rating_filter&&t.prop("selected",!1)})):l.find("option").prop("selected",!1),l.change()):i?o.each((function(){var t=e(this),r=t.children("label"),n=t.children("a");(r.length?r.find(":input").val():n.data("rating"))===i.rating_filter&&(t.children("label").children("a").click(),t.removeClass("active"))})):(o.children("label").children("a").click(),o.removeClass("active"));break;case"price_range":l.length?(i?l.find("option").each((function(){var t=e(this),r=i.min_price+(i.max_price?"-".concat(i.max_price):"");t.val()===r&&t.prop("selected",!1)})):l.find("option").prop("selected",!1),l.change()):i?o.each((function(){var t,r,n=e(this),a=n.children("label"),o=n.children("a");r=a.length?a.find(":input").val():o.data("min_price")+(o.data("max_price")?"-"+o.data("max_price"):""),i.min_price?t=i.min_price+(i.max_price?"-"+i.max_price:""):i.price_ranges&&(t=i.price_ranges),r===t&&(n.children("label").children("a").click(),n.removeClass("active"))})):(o.children("label").children("a").click(),o.removeClass("active"));break;case"price_slider":var c=t.find(".price-slider");t.find(".price-slider-min").val(c.data("min")),t.find(".price-slider-max").val(c.data("max")).change();break;case"orderby":t.find("select").val("menu_order");break;case"stock_sale":i?(null!=i&&i.instock_filter&&t.find(".filter-in-stock").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active"),null!=i&&i.onsale_filter&&t.find(".filter-on-sale").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active"),null!=i&&i.featured_filter&&t.find(".filter-featured").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active")):(t.find(".filter-in-stock").find(":input").prop("checked",!1).change(),t.find(".filter-on-sale").find(":input").prop("checked",!1).change(),t.find(".filter-featured").find(":input").prop("checked",!1).change(),a.removeClass("active"));break;default:a.removeClass("active")}this.inhibitFilters=!1,this.activeFilters=!1,r&&this.filter()}},{key:"deactivateAllFilters",value:function(t){var i=this;return this.getFilters().each((function(){var t=e(this);i.deactivateFilter(t)})),this.activeFilters=!1,t&&this.filter(),!0}},{key:"deactivateFilterByProperties",value:function(t,i){var r=this,n=this.getFiltersByProperties(Object.keys(t));return!!n.length&&(n.each((function(){var n=e(this);r.deactivateFilter(n,t,i)})),!0)}},{key:"toggle",value:function(e,t,i){void 0===i&&(i=t.hasClass("closed"));var r=i?"opened":"closed",n=i?"closed":"opened";e[i?"slideDown":"slideUp"](400,(function(){t.addClass(r).removeClass(n),e.trigger("yith_wcan_toggle_element",[t,i])}))}},{key:"openFilter",value:function(e){var t=e.find(".collapsable");t.length&&this.toggle(e.find(".filter-content"),t,!0)}},{key:"openAllFilters",value:function(t){var i=this;this.getFilters().each((function(){i.openFilter(e(this))}))}},{key:"closeFilter",value:function(e){var t=e.find(".collapsable");t.length&&this.toggle(e.find(".filter-content"),t,!1)}},{key:"closeAllFilters",value:function(t){var i=this;this.getFilters().each((function(){i.closeFilter(e(this))})),void 0!==t&&this.openFilter(t)}},{key:"openModal",value:function(){var t=this;this.isMobile&&(yith_wcan_shortcodes.toggles_open_on_modal?this._openAllCollapsables():this._closeAllCollapsables(),e("body").css("overflow","hidden").addClass("yith-wcan-preset-modal-open"),this.$preset.show(),setTimeout((function(){t.$preset.addClass("open")}),100))}},{key:"closeModal",value:function(){var t=this;this.isMobile&&(this.$preset.removeClass("open"),setTimeout((function(){t.$preset.hide(),e("body").css("overflow","auto").removeClass("yith-wcan-preset-modal-open")}),300))}},{key:"formatPrice",value:function(e){var t,i,r,n;return"undefined"!=typeof accounting&&(e=accounting.formatMoney(e,{symbol:null===(t=yith_wcan_shortcodes.currency_format)||void 0===t?void 0:t.symbol,decimal:null===(i=yith_wcan_shortcodes.currency_format)||void 0===i?void 0:i.decimal,thousand:null===(r=yith_wcan_shortcodes.currency_format)||void 0===r?void 0:r.thousand,precision:0,format:null===(n=yith_wcan_shortcodes.currency_format)||void 0===n?void 0:n.format})),e}},{key:"mergeProperties",value:function(t,i,r){for(var n in i)if(i.hasOwnProperty(n)&&t[n]){switch(n){case"rating_filter":case"min_price":case"max_price":case"onsale_filter":case"instock_filter":case"orderby":t[n]=i[n];break;default:if(0===n.indexOf("query_type_"))t[n]=i[n];else{var a=(null==r?void 0:r.data("relation"))||"and",o=0===n.indexOf("filter_"),l=o||"and"!==a?",":"+",s=t[n].replace(",",l)+l+i[n].replace(",",l);if(s=s.split(l).filter((function(e,t,i){return i.indexOf(e)===t})).join(l),t[n]=s,o){var c=n.replace("filter_","query_type_");t[c]="and",i[c]="and"}}}delete i[n]}return e.extend(t,i),t}}],n&&E(t.prototype,n),a&&E(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,a}();jQuery((function(e){e(document).on("yith_wcan_init_shortcodes yith_plugin_fw_gutenberg_success_do_shortcode",(function(){e(".yith-wcan-filters").not(".enhanced").each((function(){new T(e(this))})),e(".yith-wcan-reset-filters").not(".enhanced").each((function(){new d(e(this))}))})).trigger("yith_wcan_init_shortcodes"),globalThis.product_filter=new s}))})();