// source --> https://abatec.com.mx/wp-content/plugins/woo-product-filter/modules/woofilters/js/frontend.woofilters.js?ver=3.1.7 
/**
 * Product Filter by WBW - Frontend Woofilters JS
 *
 * @version 3.1.7
 *
 * @author  woobewoo
 */

/**
 * Main function.
 *
 * @version 3.1.7
 */
(function ($, app) {
	"use strict";

	/**
	 * wpfIsAjaxPaginationEnabled.
	 *
	 * @version 3.1.7
	 */
	function wpfIsAjaxPaginationEnabled() {
		var wrapper = jQuery('.wpfMainWrapper').first();
		if (!wrapper.length) return false;

		var raw = wrapper.attr('data-filter-settings');
		try {
			var settings = JSON.parse(raw);
		} catch (e) {
			return false;
		}

		return !!(settings.settings &&
			(parseInt(settings.settings.ajax_pagination, 10) === 1 ||
			parseInt(settings.settings.slug_format, 10) === 1));
	}
	function WpfFrontendPage() {
		this.$obj = this;
		this.noWoo = this.$obj.checkNoWooPage();
		var slugFormatEnable;
		if (!window.wpfAdminPage){
			var $fgeneralSettings = this.getFilterMainSettings(jQuery('.wpfMainWrapper'));
			if (typeof $fgeneralSettings.settings.slug_format !== 'undefined') {
				slugFormatEnable = $fgeneralSettings.settings.slug_format;
			} else {
				// Set default value if not found
				slugFormatEnable = '';  // Set your default value here
			}
		}
		this.slugFormat = slugFormatEnable;
		this.readyFuncs = ['.berocket_load_more_preload', 'woocommerce-product-bundle-hide', 'show_variation', 'woo_variation_swatches_pro_init', '.variations_form', 'yith_infs_start', 'flatsome_infinite_scroll','.dipl_woo_products_pagination_wrapper', 'divi_filter_loadmore_ajax_handler'];
		this.isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && ((navigator.userAgent && navigator.userAgent.indexOf('CriOS') == -1 && navigator.userAgent.indexOf('FxiOS') == -1) || (navigator.platform && /iPhone|iPad|iPod/.test(navigator.platform)));
		this.disableScrollJs = true;
		this.lastFids = [];
		return this.$obj;
	}

	WpfFrontendPage.prototype.init = (function () {
		var _thisObj = this.$obj;
		app.wpfNewUrl = '';
		window.wpfDoNotLoadMore = false;
		_thisObj.filterClick = true;
		_thisObj.filteringId = 0;

		_thisObj.setCurrentLocation();
		_thisObj.filterLoadTypes = [];
		_thisObj.defaultProductSelector = 'ul.products';
		_thisObj.isAdminPreview = jQuery('#wpfFiltersEditForm').length > 0 || (typeof isElementorPreview != 'undefined' && isElementorPreview == 1);
		_thisObj.moveFloatingElements();
		_thisObj.checkForceFilters();
		_thisObj.eventsPriceFilter();
		_thisObj.disableLeerOptions();
		_thisObj.eventsFrontend();
		_thisObj.changeSlugByUrl();
		_thisObj.runCustomJs();
		_thisObj.addCustomCss();
		_thisObj.chageRangeFieldWidth();
		_thisObj.addSpecificPluginActions();
		_thisObj.resizeWindow();
		_thisObj.changeOrderBy();
		_thisObj.copySelectsForSafari();

		jQuery('.wpfMainWrapper').each(function() {
			_thisObj.markCheckboxSelected(jQuery(this), true);
		});

		if (_thisObj.isAdminPreview) {
			_thisObj.hideFiltersLoader();
		} else {
			setTimeout(function () {
				_thisObj.hideFiltersLoader();
			}, 100);
		}
		var slugFormat=_thisObj.slugFormat;
		if(slugFormat !== "" && slugFormat !== 0 && slugFormat && slugFormat !== "0") {
			if($('.wpfFilterButton').length >0 && !window.wpfAdminPage){
				applyFilter(_thisObj,$('.wpfFilterButton'));
			}
		}
	});
	WpfFrontendPage.prototype.moveFloatingElements = (function () {
		var _thisObj = this.$obj;
		if (!_thisObj.isAdminPreview && jQuery('.wpfFloatingBlock').length == 0 && jQuery('.wpfFloatingWrapper').length == 1) {
			jQuery('body').append('<div class="wpfFloatingBlock"></div>');
			if (jQuery('.wpfFloatingSwitcher').length == 1) {
				var button = $('.wpfFloatingSwitcher');
				if (button.hasClass('wpfSwitcherRealFloat')) {
					button.detach();
					$('.wpfFloatingBlock').append(button);
				}
			}
			if (jQuery('.wpfFloatingOverlay').length == 1) {
				var overlay = $('.wpfFloatingOverlay').detach();
				$('.wpfFloatingBlock').append(overlay);
			}
			if ($('.wpfFloatingWrapper').closest('.wpfFilterForWtbp').length) $('.wpfFloatingBlock').addClass('wpfFilterForWtbpFloating');
			var block = $('.wpfFloatingWrapper').detach();
			$('.wpfFloatingBlock').append(block);

		}
	});

	WpfFrontendPage.prototype.changeOrderBy = (function () {
		jQuery('.woocommerce-ordering select').on('change', function (e) {
			e.preventDefault();
			var orderBy = jQuery(this).val(),
				curUrl = window.location.href;

			if ((curUrl.indexOf('?') === -1)) {
				curUrl += '?orderby=' + orderBy;
				jQuery('.wpfMainWrapper').each(function () {
					var filter = $(this).data('filter-settings');
					if (typeof filter.settings.filters.defaults !== 'undefined') {
						curUrl += '&' + filter.settings.filters.defaults.replace(';', '&').replace('|', '%7C');
					}
				});
			} else {
				if (curUrl.indexOf('orderby') === -1) {
					curUrl += ((curUrl.indexOf('?') === -1) ? '?' : '&') + 'orderby=' + orderBy;
				} else {
					curUrl = curUrl.replace(/(orderby=)[^&]*/, '$1' + orderBy);
				}
			}
			jQuery(location).attr('href', curUrl);
			return false;
		});
	});

	WpfFrontendPage.prototype.resizeWindow = (function() {
		var _thisObj = this.$obj;
		_thisObj.filterOptionsForDevices();
		jQuery( window ).on('resize', function() {
			_thisObj.filterOptionsForDevices();
		});
	});

	WpfFrontendPage.prototype.copySelectsForSafari = (function() {
		var _thisObj = this.$obj;
		if (!_thisObj.isSafari) return;

		jQuery('.wpfMainWrapper').each(function () {
			var $wrapper = jQuery(this),
				$selectsWrapper = $wrapper.find('.wpfSelectCopies');
			if ($selectsWrapper.length == 0) {
				jQuery('<div/>').addClass('wpfSelectCopies').appendTo($wrapper);
				$selectsWrapper = $wrapper.find('.wpfSelectCopies');
			}
			if ($selectsWrapper.length == 0) return;

			$wrapper.find('.wpfFilterWrapper[data-display-type="dropdown"] select').each(function() {
				var $select = jQuery(this),
					$filter = $select.closest('.wpfFilterWrapper'),
					blockId = $filter.attr('id');
				if ($selectsWrapper.find('select[data-block="' + blockId + '"]').length == 0) {
					$select.clone().attr('data-block', blockId).appendTo($selectsWrapper);
				}
			});
			_thisObj.removeHiddenOptionsForSafari($wrapper);
		});
	});

	WpfFrontendPage.prototype.restoreSelectsForSafari = (function() {
		var _thisObj = this.$obj;
		if (!_thisObj.isSafari) return;

		jQuery('.wpfMainWrapper').each(function () {
			var $wrapper = jQuery(this),
			$selectsWrapper = $wrapper.find('.wpfSelectCopies');
			if ($selectsWrapper.length == 1) {

				$selectsWrapper.find('select').each(function() {
					var $select = jQuery(this),
						blockId = $select.attr('data-block'),
						$filterSelect = $wrapper.find('#' + blockId + ' select');
					if ($filterSelect.length == 1) {
						var value = $filterSelect.val();
						$filterSelect.html($select.html());
						$filterSelect.val(value);
					}
				});
			}
		});
	});

	/**
	 * removeHiddenOptionsForSafari.
	 *
	 * @version 2.8.6
	 */
	WpfFrontendPage.prototype.removeHiddenOptionsForSafari = (function() {
		var _thisObj = this.$obj;
		if (!_thisObj.isSafari) return;

		var $found = jQuery('.wpfFilterWrapper[data-display-type="dropdown"] select:visible option[style*="none"]');
		if ($found.length) $found.remove();
		else {
			jQuery('.wpfFilterWrapper[data-display-type="dropdown"] select:visible option').each(function() {
				if (jQuery(this).css('display') == 'none') jQuery(this).remove();
			});
		}
	});

	WpfFrontendPage.prototype.checkForceFilters = (function() {
		var forceShowFilter = jQuery('.wpfMainWrapper[data-force="1"]');
		if (!forceShowFilter.length) return;

		jQuery('.wpfMainWrapper').each(function () {
			var wrapper = jQuery(this),
				forceShowCurrent = wrapper.attr('data-force');
			if (!forceShowCurrent){
				wrapper.remove();
				if (wrapper.closest('.WpfWoofiltersWidget').length) {
					wrapper.closest('.WpfWoofiltersWidget').remove();
				}
			}
		});
	});

	WpfFrontendPage.prototype.showFiltersLoader = (function() {
		jQuery('.wpfMainWrapper').each(function () {
			var wrapper = jQuery(this);
			wrapper.css('position','relative');
			if (!wrapper.find('.wpfLoaderLayout').length){
				jQuery('<div/>').addClass('wpfLoaderLayout').appendTo(wrapper);
				wrapper.find('.wpfLoaderLayout').append('<i class="fa fa-spinner fa-pulse fa-3x fa-fw"/>');
			}

			wrapper.find('.wpfLoaderLayout').show();
		});
	});

	WpfFrontendPage.prototype.hideFiltersLoader = (function() {
		jQuery('.wpfMainWrapper').each(function () {
			var wrapper = jQuery(this);

			hideFilterLoader(wrapper);
		});
	});

	WpfFrontendPage.prototype.runCustomJs = (function () {
		var _thisObj = this.$obj;
		jQuery('.wpfMainWrapper').each(function () {
			var wrapper = jQuery(this),
				jsCodeStr = '',
				settings = _thisObj.getFilterMainSettings(wrapper);
			if(settings){
				settings = settings.settings;
				jsCodeStr = settings.js_editor;
			}
			if(jsCodeStr.length > 0){
				try {
					eval(jsCodeStr);
				}catch(e) {
					console.log(e);
				}

			}
		});
	});

	WpfFrontendPage.prototype.addCustomCss = (function () {
		if (jQuery('style#wpfCustomCss').length === 0) {
			var cssCodeStr = '';

			jQuery('.wpfMainWrapper').each(function () {
				var wrapper = jQuery(this),
					customCss = jQuery('style#wpfCustomCss-' + wrapper.attr('data-viewid'));
				if (customCss.length) {
					cssCodeStr += customCss.html();
					customCss.remove();
				}
			});
			if (cssCodeStr.length > 0) {
				jQuery('<style type="text/css" id="wpfCustomCss">' + cssCodeStr + '</style>').appendTo('head');
			}
		}
	});

	WpfFrontendPage.prototype.chageRangeFieldWidth = (function () {
		var _thisObj = this.$obj;
		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
			var filter = jQuery(this),
				input1 = filter.find('#wpfMinPrice'),
				input2 = filter.find('#wpfMaxPrice'),
				fontSize1 = input1.css('font-size'),
				fontSize2 = input2.css('font-size'),
				visbleBuffer1 = filter.find('.wpfVisibleBufferMin'),
				visbleBuffer2 = filter.find('.wpfVisibleBufferMax');
			if(fontSize1) visbleBuffer1.css('font-size', fontSize1);
			if(fontSize2) visbleBuffer2.css('font-size', fontSize2);

			jQuery(visbleBuffer1).text(input1.val());
			jQuery(visbleBuffer2).text(input2.val());

			if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
				jQuery(input1).width(visbleBuffer1.width()+20);
				jQuery(input2).width(visbleBuffer2.width()+20);
			} else {
				jQuery(input1).width(visbleBuffer1.width()+10);
				jQuery(input2).width(visbleBuffer2.width()+10);
			}
		});
	});

	WpfFrontendPage.prototype.eventsPriceFilter = (function () {
		var _thisObj = this.$obj;

		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
			_thisObj.initDefaultSlider(jQuery(this));
		});

		//change price filters
		jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').on('wpfPriceChange', function(event){
			var filter = jQuery(this),
				mainWrapper = filter.closest('.wpfMainWrapper');

			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input').prop('checked', false);
			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select')
				.val(mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select option:first').val());

			filter.removeClass('wpfNotActive');
			mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"]').addClass('wpfNotActive');
		});

		//change price range
		jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input, .wpfFilterWrapper[data-filter-type="wpfPriceRange"] select').on('change', function(e){
			e.preventDefault();

			jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').addClass('wpfNotActive');
		});

	});

	WpfFrontendPage.prototype.initDefaultSlider = (function (filter, type) {
		var _thisObj = this.$obj,
			wrapper = filter.closest('.wpfMainWrapper'),
			filterType = typeof type !== 'undefined' ? type : 'price',
			getAttr = filter.data('get-attribute'),
			minInputId = '#wpfMinPrice',
			maxInputId = '#wpfMaxPrice',
			triggerName = 'wpfPriceChange';

		if (filterType === 'attr') {
			minInputId = '#wpfMinAttrNum';
			maxInputId = '#wpfMaxAttrNum';
			triggerName = 'wpfAttrSliderChange';
		}

		var minSelector = wrapper.find(minInputId),
			maxSelector = wrapper.find(maxInputId),
			wpfDataStep = wrapper.find('#wpfDataStep').val()
		if (wpfDataStep == '0.001') {
			wpfDataStep = '0.00000001';
		}
		wpfDataStep = Number(wpfDataStep);

		var valMin = parseFloat(minSelector.attr('min')),
			valMax = parseFloat(maxSelector.attr('max')),
			curUrl = window.location.href,
			urlParams = _thisObj.findGetParameter(curUrl),
			rate = filter.data('rate');

		urlParams = _thisObj.getConvertedPrices(urlParams, rate);

		var	minPriceGetParams = urlParams.wpf_min_price ? parseFloat(urlParams.wpf_min_price) : valMin,
			maxPriceGetParams = urlParams.wpf_max_price ? parseFloat(urlParams.wpf_max_price) : valMax;

		if (filterType === 'attr') {
			if (urlParams[getAttr]) {
				var idsAnd = urlParams[getAttr].split(','),
					idsOr = urlParams[getAttr].split('|'),
					isAnd = idsAnd.length > idsOr.length;
				var filterTypeValues = isAnd ? idsAnd : idsOr;
			}
			minPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues[0]) : valMin;
			maxPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues.pop()) : valMax;
		}

		var sliderWrapper = filter.find("#wpfSliderRange"),
			autoFilteringEnable = (wrapper.find('.wpfFilterButton').length == 0),
			skin = filter.attr('data-price-skin');
		if(skin === 'default'){
			sliderWrapper.slider({
				range: true,
				orientation: "horizontal",
				min: valMin,
				max: valMax,
				step: wpfDataStep,
				values: [minPriceGetParams, maxPriceGetParams],
				slide: function (event, ui) {
					minSelector.val(ui.values[0]);
					maxSelector.val(ui.values[1]);
					filter.trigger(triggerName);
				},
				start: function () {
					filter.trigger(triggerName);
				},
				stop: function () {
					if(autoFilteringEnable){
						_thisObj.setCurrentLocation();
						_thisObj.filtering(wrapper);
					}
				},
			});
			minSelector.val(sliderWrapper.slider("values", 0));
			maxSelector.val(sliderWrapper.slider("values", 1));
		}
	});

	// add/remove get query param
	WpfFrontendPage.prototype.QStringWork = (function ($attr, $value, $noWooPage, $filterWrapper, $type) {

		$noWooPage = false;
		if (window.wpfAdminPage) {
			$noWooPage = true;
		}
		if($type === 'change'){
			var curUrl = changeUrl($attr, $value, $noWooPage, $filterWrapper );
			$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
		}else if($type === 'remove'){
			var curUrl = removeQString($attr, $noWooPage, $filterWrapper);
			$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
		}
	});
	// slug generation
	// New: Convert original param string to slug segments (use slugs for values)
	WpfFrontendPage.prototype.convertParamsToSegments = function(paramString) {
		var segments = [];
		var exclude = ['wpf_count', 'wpf_fbv'];

		if (!paramString) return segments;

		// helper to safely use values in CSS attribute selectors
		function escAttr(v) {
			v = String(v);
			if (window.CSS && CSS.escape) return CSS.escape(v);
			// fallback escape (good enough for attr selectors)
			return v.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
		}

		paramString = paramString.replace(/^[?&]/, '');
		var pairs = paramString.split('&');

		pairs.forEach(function(pair) {
			var parts = pair.split('=');
			var key = parts[0];
			var val = parts.slice(1).join('='); // keep '=' inside values safe

			if (!key || !val || exclude.indexOf(key) !== -1) return;

			var decodedKey = decodeURIComponent(key);
			var delim = getDelimiterForFilter(decodedKey);
			var pathDelim = ('|' === delim) ? '~' : delim;
			// decode full value first (important!)
			var decodedVal = decodeURIComponent(val.replace(/\+/g, ' '));

			var slugs = decodedVal.split(delim)
				.map(s => s.trim())
				.filter(Boolean)
				.map(function(idRaw) {
					var id = idRaw; // already decoded
					var $wrap = jQuery('.wpfFilterWrapper[data-get-attribute="' + escAttr(decodedKey) + '"]');

					// Try LI mapping (checkbox/radio)
					var $li = $wrap.find('li[data-term-id="' + escAttr(id) + '"]');
					if ($li.length) return ($li.attr('data-term-slug') || id);

					// Fallback: try option mapping (dropdown)
					var $opt = $wrap.find('option[value="' + escAttr(id) + '"]');
					if ($opt.length) return ($opt.attr('data-term-slug') || $opt.data('term-slug') || id);

					return id;
				});

			if (slugs.length) {
				segments.push(decodedKey);
				segments.push(slugs.join(pathDelim));
			}
		});

		return segments;
	};
	// New: Convert slug segments back to param string (slugs → IDs)
	function getDelimiterForFilter(key) {
		var $filter = jQuery('.wpfFilterWrapper[data-get-attribute="' + key + '"]');
		if (!$filter.length) return ','; // safe fallback

		var logic = $filter.attr('data-query-logic') || 'or'; // default most filters to OR
		return (logic === 'and') ? ',' : '|';
	}
	WpfFrontendPage.prototype.eventChangeFilter = (function (e) {
		var _thisObj = this.$obj,
			_this = jQuery(e.target),
			mainWrapper = _this.closest('.wpfMainWrapper'),
			settings = _thisObj.getFilterMainSettings(mainWrapper);
		_thisObj.setCurrentLocation();

		_this.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
		if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
			_thisObj.eventChangeFilterPro(_this, settings);
		}

		var redirectOnlyClick = Number(settings.settings.redirect_only_click),
			autoUpdateFilter  = Number(settings.settings.auto_update_filter),
			loaderEnable  = Number(settings.settings.filter_loader_icon_onload_enable),
			isButton = ( mainWrapper.find('.wpfFilterButton').length > 0 ),
			isCheckbox = _this.attr('type') == 'checkbox',
			redirectLink = isCheckbox ? _this.closest('li' ).attr('data-link') : _this.find('option:selected').attr('data-link');

		if (typeof redirectLink !== 'undefined' && isCheckbox) {
			var filter = _this.closest('.wpfFilterWrapper');
			if (filter.attr('data-display-type') != 'list' && _this.is(':checked')){
				filter.find('input').prop('checked', false);
				_this.prop('checked', true);
			}
		}

		if (isButton) {
			// if there is a button and autoUpdateFilter is selected, then we only change the filter.
			// If redirectOnlyClick is selected, then we change the filter and products, but do not redirect until the button is clicked

			if (autoUpdateFilter || redirectOnlyClick) {
				if (loaderEnable) {
					mainWrapper.find('.wpfLoaderLayout').show();
				}
				_thisObj.filterClick = false;
				_thisObj.filtering(mainWrapper, false, redirectLink);
			}

		} else {
			_thisObj.filterClick = true;
			_thisObj.filtering(mainWrapper, false, redirectLink);
		}
	});


	WpfFrontendPage.prototype.eventsFrontend = (function () {
		var _thisObj = this.$obj,
			searchParams = jQuery.toQueryParams(window.location.search);

		//for Impreza LoadMore Pagination
		if (searchParams['all_products_filtering'] && searchParams['all_products_filtering'] == '1') {
			jQuery( document ).ajaxSend(function( event, jqxhr, settings ) {
				if (settings.data) {
					var response = _thisObj.unserializeStr(settings.data);
					if (response['action'] && response['action'] == 'us_ajax_grid') {
						if (response['template_vars'] && response['template_vars'].length) {
							try {
								var query = JSON.parse(response['template_vars']);
							}catch(e){
								var query = false;
							}
							if (query && query['query_args']) {
								var args = query['query_args'];
								if (args['product_cat']) delete args.product_cat;
								if (args['product_tag']) delete args.product_tag;
								response['template_vars'] = JSON.stringify(query);
								var result = [];
								jQuery.each(response, function(key, val) {
									result.push(encodeURIComponent(key) + "=" + encodeURIComponent(val));
								});
								settings.data = result.join("&").replace(/%20/g, "+");
							}
						}
					}
				}
			});
		}
		//for Divi Filter LoadMore / eael-pagination / premium-woo-products
		if (jQuery('.divi-filter-archive-loop, .eael-woo-pagination, .premium-woo-products-pagination, .uael-woocommerce-pagination').length) {
			var actions = ['divi_filter_loadmore_ajax_handler', 'woo_product_pagination_product', 'get_woo_products', 'uael_get_products'];
			jQuery( document ).ajaxSend(function( event, jqxhr, settings ) {
				if (settings.data) {
					var response = _thisObj.unserializeStr(settings.data);
					if (response['action'] && actions.indexOf(response['action']) != -1) {
						var s = window.location.search;
						if (s && s.length > 1) {
							response['with_wpf_filter'] = s.replace('?','');
							var result = [];
							jQuery.each(response, function(key, val) {
								result.push(encodeURIComponent(key) + "=" + encodeURIComponent(val));
							});
							settings.data = result.join("&").replace(/%20/g, "+");
						}
					}
				}
			});
		}
		//for woocommerce-blocks (All products and others)
		if (typeof window.wpfFetchHookCreated == 'undefined' || window.wpfFetchHookCreated != 1) {
			window.fetch = new Proxy(window.fetch, {
				apply(fetch, that, args) {
					var url = args.length ? args[0] : '';
					if (typeof url === 'string' && url.length) {
						if (url.indexOf('wp-json/wc/store/') != -1 && url.indexOf('/products?') != -1 && url.indexOf('per_page=') != -1) {
							var s = window.location.search;
							if (s.length) args[0] += s.replace('?','&');
							else {
								var urlPreselects = '';
								jQuery('.wpfMainWrapper').each(function() {
									var settings = _thisObj.getFilterMainSettings(jQuery(this)),
										preselects = typeof settings.settings.filters.preselect !== 'undefined' ? settings.settings.filters.preselect : '';
									if (preselects.length) {
										urlPreselects += '&'+preselects.replace(/;/g,'&');
										if (settings.settings.filtering_by_variations=='1') urlPreselects += '&wpf_fbv=1';
										if (settings.settings.exclude_backorder_variations=='1') urlPreselects += '&wpf_ebv=1';
										if (settings.settings.display_product_variations=='1') urlPreselects += '&wpf_dpv=1';
									}
								});
								if (urlPreselects.length) {
									args[0] += urlPreselects + '&wpf_preselects=1';

								}
							}
						} else {
							//Elementor Loop Load More
							if ((jQuery('.e-load-more-anchor').length == 1) && jQuery('.e-load-more-spinner').length && url.indexOf('?') == -1) {
								var $elementorLoadMoreAnchor = jQuery('.e-load-more-anchor'),
									s = window.location.search;
								if (s.length) {
									var nextPage = $elementorLoadMoreAnchor.attr('data-next-page');
									if (nextPage == url) args[0]+= s;
								}

							}
						}
					}
					const result = fetch.apply(that, args);
					return result;
				}
			});
			window.wpfFetchHookCreated = 1;
		}

		//for themes with ajax-paginations, ajax-ordering
		jQuery(document).ajaxComplete(function(event, xhr, options) {
			setTimeout(function() {
				if (jQuery('.wpfLoaderLayout:visible').length) {
					window.wpfFrontendPage.init();
					if (typeof(window.wpfFrontendPage.eventsFrontendPro) == 'function') {
						window.wpfFrontendPage.eventsFrontendPro();
					}
				}
			}, 500);
			//if (jQuery('.wpfLoaderLayout:visible').length) window.wpfFrontendPage.init();
		});

		jQuery('.wpfMainWrapper').find('select[multiple]').each(function(){
			var select = jQuery(this),
				selectAll = select.attr('data-placeholder'),
				search = JSON.parse(select.attr('data-search')),
				singleSelect = select.data('single-select'),
				showCheckbox = (typeof select.data('hide-checkboxes') === 'undefined');

			setTimeout(function () {
				select.multiselect({
					search: search.show,
					columns: 1,
					placeholder: selectAll ? selectAll : 'Select options',
					optionAttributes: ['style', 'data-term-id'],
					searchOptions: {'default': search.placeholder},
					showCheckbox: showCheckbox,
					onOptionClick: function (element, option) {
						if (typeof singleSelect !== 'undefined') {
							var value = jQuery(option).val();
							jQuery(option).closest('ul').find('input[type="checkbox"][value!=' + value + ']').prop('checked', false);
							jQuery(element).val(value);
							jQuery(element).siblings('.ms-options-wrap').find('.ms-options:visible').hide();
						}
					},
				});
			}, 100);

			if (search.show) {
				jQuery('.ms-options-wrap').on('click', 'button', function () {
					$(this).next('.ms-options').find('.ms-search input').focus();
				});
			}

		});

		if(jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
			jQuery('.woocommerce-ordering').css('display', 'block');
		}

		jQuery('.wpfFilterWrapper[data-hide-single="1"]').each(function(){
			var filter = jQuery(this),
				selector = filter.find('.wpfColorsFilter').length ? 'li[data-term-slug]' : '[data-term-id]',
				visible = 0;
			if (filter.attr('data-display-type') == 'slider') {
				var idsDef = filter.attr('data-ids-without-filtering').replaceAll(', ',',').split(',');
				if (idsDef.length <= 1) filter.hide();
			} else {
				filter.find(selector).each(function(){
					if (jQuery(this).css('display') != 'none') visible++;
				});
				if (visible <= 1) {
					filter.hide();
				}
			}
		});

		//if no enabled filters hide all html
		if(jQuery('.wpfFilterWrapper').length < 1){
			jQuery('.wpfMainWrapper').addClass('wpfHidden');
		}

		//Start filtering
		jQuery('body').on('mousedown', '.wpfFilterButton, .js-wpfFilterButtonSearch', function (e) {
			e.preventDefault();
			var $this = jQuery(this),
				mainWrapper = $this.closest('.wpfMainWrapper'),
				inputSearch = mainWrapper.find('.js-passiveFilterSearch');
			if (inputSearch.length) {
				inputSearch.each(function() {
					var $sElem = jQuery(this);
					if ($sElem.val() !== '') {
						$sElem.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
					}
					$sElem.trigger('blur');
				});

			}
			applyFilter(_thisObj, $this);
		});

		jQuery('input.js-passiveFilterSearch').on('keydown', function (e) {
			var char_code = e.which;
			if (parseInt(char_code) == 13) {
				e.preventDefault();
				var $this = jQuery(this);
				$this.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
				$this.trigger('blur');
				applyFilter(_thisObj, $this);
			}
		});


		//Clear filters
		jQuery('body').on('click', '.wpfClearButton', function (e) {
			e.preventDefault();
			var $filterWrapper = jQuery(this).closest('.wpfMainWrapper'),
				settings = _thisObj.getFilterMainSettings($filterWrapper),
				resetAllFilters = typeof settings.settings.reset_all_filters !== 'undefined' ? settings.settings.reset_all_filters : 0;
			_thisObj.setCurrentLocation();

			if (resetAllFilters !== '0') {
				jQuery('.wpfMainWrapper').each(function(){
					_thisObj.clearFilters(jQuery(this).find('.wpfFilterWrapper'), true);
				});
			} else {
				_thisObj.clearFilters($filterWrapper.find('.wpfFilterWrapper'), true);
			}
			if (Number(settings.settings.redirect_after_select) || Number(settings.settings.redirect_only_click)) {
				_thisObj.filterClick = false;
			}
			_thisObj.filtering($filterWrapper, true);

			if (typeof (_thisObj.initOneByOne) == 'function') {
				_thisObj.initOneByOne($filterWrapper);
			}

		});

		//price range choose only one checkbox
		jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] .wpfFilterContent input').on('change', function (e) {
			e.preventDefault();
			var input = jQuery(this),
				inputs = input.closest('.wpfFilterWrapper').find('input');
			if(input.is(":checked")){
				inputs.prop('checked', false);
				input.prop('checked', true);
			}
		});

		//category/brand list choose only one checkbox
		jQuery('.wpfFilterWrapper[data-filter-type="wpfCategory"], .wpfFilterWrapper[data-filter-type="wpfPerfectBrand"], .wpfFilterWrapper[data-filter-type="wpfAttribute"]').each(function() {
			var categoryFilter = jQuery(this),
				displayType = categoryFilter.data('display-type'),
				categoryMulti = displayType == 'multi';
			if (categoryFilter.data('filter-type') == 'wpfAttribute') {
				if (displayType == 'list' || displayType == 'switch') categoryMulti = true;
			}

			categoryFilter.find('.wpfFilterContent input').on('change', function (e) {
				e.preventDefault();
				var input = jQuery(this);
				if(categoryMulti) {
					var mainWrapper = input.closest('.wpfMainWrapper'),
						filterWrapper = input.closest('.wpfFilterWrapper'),
						expandSelectedToChild = _thisObj.getFilterParam('f_multi_extend_parent_select', mainWrapper, filterWrapper);

					if(expandSelectedToChild && input.is(':checked')) {
						input.closest('li').find('ul input').prop('checked', true);
					}

					if (expandSelectedToChild && ! input.is(':checked') ) {
						input.closest('li').find('ul input').prop('checked', false);
					}
				}
			});
		});

		//rating choose only one checkbox
		jQuery('.wpfFilterWrapper[data-filter-type="wpfRating"] .wpfFilterContent input').on('change', function (e) {
			e.preventDefault();
			var input = jQuery(this),
				inputs = input.closest('.wpfFilterWrapper').find('input');
			if(input.is(":checked")){
				inputs.prop('checked', false);
				input.prop('checked', true);
			}
		});

		//after change input or dropdown make this filter active
		//check if ajax mode enable and filtering on filter elements change
		jQuery('body').off('change', '.wpfFilterWrapper select, .wpfFilterWrapper input:not(.passiveFilter)').on('change', '.wpfFilterWrapper select, .wpfFilterWrapper input:not(.passiveFilter)', function (e) {
			e.preventDefault();
			var isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(this);
			// exeption checkbox in multidropdown
			if (!isExeptionCase) {
				var $this = jQuery(this);
				if ($this.is('input') && $this.closest('.wpfFilterWrapper').data('display-type') == 'mul_dropdown') {
					isExeptionCase = true;
				}
			}

			if (!isExeptionCase) {
				setTimeout(function() {
					_thisObj.eventChangeFilter(e);
				}, 100);
			}
		});

		//after change input or dropdown make this filter active
		jQuery('.wpfFilterWrapper input:not(.passiveFilter)').on('change', function (e) {
			e.preventDefault();
			// check if input change move to top
			_thisObj.moveCheckedToTop(jQuery(this));
			// check multy or single input (radio or checkbox)
			_thisObj.detectSingleCheckbox(jQuery(this))
			// Mark selected
			_thisObj.markCheckboxSelected(jQuery(this).closest('.wpfFilterWrapper'));
		});

		jQuery('.wpfMainWrapper').each(function() {
			var mainWrapper = jQuery(this),
				settings = _thisObj.getFilterMainSettings(mainWrapper);
			if (settings && settings.settings && settings.settings.checked_items_top === '1') {
				mainWrapper.find('.wpfFilterWrapper input').attr('autocomplete', 'off');
				mainWrapper.find('.wpfFilterWrapper input:checked').each(function() {
					_thisObj.moveCheckedToTop(jQuery(this), false);
				});
			}
		});

		/*jQuery('.wpfFilterWrapper input:checked').each(function() {
			_thisObj.moveCheckedToTop(jQuery(this), false);
		});*/

		//search field work
		jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('keyup', function (e) {
			var _this = jQuery(this),
				wrapper = _this.closest('.wpfFilterWrapper'),
				searchVal = _this.val().toLowerCase(),
				isIconFunc = typeof (_thisObj.getIcons) == 'function',
				unfolding = (searchVal.length && _this.attr('data-unfolding') == '1' && isIconFunc),
				collapse = (searchVal.length == 0 && _this.attr('data-collapse-search') == '1' && isIconFunc);
			wrapper.find('.wpfFilterContent li:not(.wpfShowFewerWrapper)').filter(function() {
				var $li = jQuery(this);
				if ($li.find('.wpfValue').text().toLowerCase().indexOf(searchVal) > -1) {
					$li.removeClass('wpfSearchHidden');
					if (unfolding || collapse) {
						var $parentLi = $li.closest('li');
						while ($parentLi.length && $parentLi.closest('.wpfFilterWrapper')) {
							var $label = $parentLi.children('label'),
								$icon = $label.length ? $label.find('i.fa, svg') : '';
							if ($icon.length) {
								var $icons = _thisObj.getIcons($icon.eq(0));
								if ($icons.collapsed && unfolding || !$icons.collapsed && collapse) {
									_thisObj.collapsibleToggle($icon.eq(0), $icons, $parentLi);
								}
							}
							$parentLi = $parentLi.closest('ul').closest('li');
						}
					}
				} else {
					$li.addClass('wpfSearchHidden');
				}
			});
			if(typeof(_thisObj.initShowMore) == 'function') {
				_thisObj.initShowMore(wrapper.find('.wpfFilterVerScroll'));
			}
		});
		/*jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('change', function (e) {
			jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent li.wpfSearchHidden .wpfCheckbox input').prop('checked', false);
		});*/

		//uncheck one slug
		jQuery('body').off('click', '.wpfSlugDelete').on('click', '.wpfSlugDelete', function(){
			var _this = jQuery(this),
				wrapper = _this.closest('.wpfSlug'),
				filterType = wrapper.attr('data-filter-type'),
				filterAttr = wrapper.attr('data-get-attribute'),
				filterWrapper = false;
			_thisObj.setCurrentLocation();

			jQuery('.wpfFilterWrapper[data-filter-type="'+filterType+'"][data-get-attribute="'+filterAttr+'"]').each(function(){
				var $this = jQuery(this),
					filterType = $this.attr("data-filter-type");
				if (filterType == 'wpfPrice' || filterType == 'wpfPriceRange') {
					_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
					_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
				} else {
					_thisObj.clearFilters($this);
				}
				if(filterWrapper == false) {
					filterWrapper = $this.closest('.wpfMainWrapper');
				}
			});
			if(filterWrapper != false) {
				_thisObj.filtering(filterWrapper);
			}
		});

		jQuery('body').off('click', '.wpfFilterWrapper .wpfFilterTitle').on('click', '.wpfFilterWrapper .wpfFilterTitle', function (e) {
			e.preventDefault();
			var _this = jQuery(this),
				wrapper = _this.closest('.wpfMainWrapper'),
				settings = _thisObj.getFilterMainSettings(wrapper),
				content = _this.closest('.wpfFilterWrapper').find('.wpfFilterContent');

			setTimeout(function () {
				var toggle = _this.find('i.wpfTitleToggle, svg'),
					icons  = {};
				if (toggle.length) {
					if (typeof (_thisObj.getIcons) == 'function') {
						icons = _thisObj.getIcons(toggle);
					} else {
						icons = {collapsed: toggle.hasClass('fa-plus'), plusIcon: 'fa-plus', minusIcon: 'fa-minus'};
					}

					if (settings.settings.hide_filter_icon !== '0') {
						if (icons.collapsed) {
							_thisObj.openFilterToggle(toggle, content, true, icons);
						} else {
							_thisObj.closeFilterToggle(toggle, content, true, icons);
						}
					}
				}
			}, 100);
		});

		jQuery('body').off('click', '.wpfFilterWrapper .wpfBlockClear').on('click', '.wpfFilterWrapper .wpfBlockClear',  function(){
			var parent = jQuery(this).closest(".wpfFilterWrapper"),
				parentAttr = parent.attr("data-filter-type");
			_thisObj.setCurrentLocation();
			if (parentAttr == 'wpfPrice' || parentAttr == 'wpfPriceRange') {
				_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
				_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
			} else {
				_thisObj.clearFilters(parent);
			}
			_thisObj.filtering(parent.closest('.wpfMainWrapper'));
			return false;
		});
		//ajax pagination
		jQuery('body').off('click', '.woocommerce-pagination a.page-numbers').on('click', '.woocommerce-pagination a.page-numbers', function (e) {
			var wrapper = jQuery('.wpfMainWrapper').first();
			// 1️⃣ If NoWooPage exists → let its handler handle it
			if (wrapper.hasClass('wpfNoWooPage')) {
				return;
			}
			// 2️⃣ If ajax pagination disabled → allow normal Woo pagination
			if (!wpfIsAjaxPaginationEnabled()) {
				return;
			}
			// 3️⃣ Otherwise → AJAX pagination
			e.preventDefault();
			var _this = jQuery(this),
				paginationWrapper = _this.closest('.woocommerce-pagination'),
				currentNumber = paginationWrapper.find('.current').text();
			if(!_this.hasClass('next') && !_this.hasClass('prev') ){
				var number = parseInt(_this.text(), 10) || 1;
			}else if(_this.hasClass('next')){
				var current = parseInt(currentNumber, 10) || 1;
				var number = current + 1;
			}else if(_this.hasClass('prev')){
				var current = parseInt(currentNumber, 10) || 1;
				var number = Math.max(current - 1, 1);
			}
			var wrapper = jQuery('.wpfMainWrapper').first(),
				$queryVars = wrapper.attr('data-settings');
			try{
				var settings = JSON.parse($queryVars);
			}catch(e){
				var settings = false;
			}
			if(settings){
				settings.paged = number;
				settings.pagination = 1;
				wrapper.attr('data-settings', JSON.stringify(settings) );
			}
			_thisObj.setCurrentLocation();

			// todo: testing for two+ filters on page
			_thisObj.filtering( jQuery('.wpfMainWrapper') );
			_thisObj.setPagination(0);
		});

		//ajax pagination
		jQuery('body').off('wpffiltering').on('wpffiltering', function () {
			_thisObj.setPagination(1);
			_thisObj.setCurrentLocation();
			_thisObj.filtering();
			_thisObj.setPagination(0);
		});

		//click on new pagination link with page number
		jQuery('body').off('click', '.wpfNoWooPage .woocommerce-pagination a.page-numbers').on('click', '.wpfNoWooPage .woocommerce-pagination a.page-numbers', function (e) {
			e.preventDefault();
			var _this = jQuery(this),
				paginationWrapper = _this.closest('.woocommerce-pagination'),
				currentNumber = paginationWrapper.find('.current').text();
			if(!_this.hasClass('next') && !_this.hasClass('prev') ){
				var number = parseInt(_this.text(), 10) || 1;
			}else if(_this.hasClass('next')){
				var current = parseInt(currentNumber, 10) || 1;
				var number = current + 1;
			}else if(_this.hasClass('prev')){
				var current = parseInt(currentNumber, 10) || 1;
				var number = Math.max(current - 1, 1);
			}
			var wrapper = jQuery('.wpfMainWrapper').first(),
				$queryVars = wrapper.attr('data-settings');
			try{
				var settings = JSON.parse($queryVars);
			}catch(e){
				var settings = false;
			}
			if(settings){
				settings.paged = number;
				settings.pagination = 1;
				wrapper.attr('data-settings', JSON.stringify(settings) );
			}
			_thisObj.setCurrentLocation();

			// todo: testing for two+ filters on page
			_thisObj.filtering( jQuery('.wpfMainWrapper') );
			_thisObj.setPagination(0);
		});

		var prevLocation = location.href.split('#').shift();
		jQuery(window).on('popstate', function (e) {

			var currentLocation = location.href.split('#').shift();
			if (location.href.split('#').length > 1 && prevLocation === currentLocation) {
				return;
			}

			if (typeof window.wpfAdminPage === 'undefined' && !_thisObj.isSafari) {
				location.reload();
			}
		});
		jQuery('.wpfPreselected:not([data-filter-type="wpfPriceRange"]) .wpfCheckbox input').prop('checked', true);

		jQuery('#wpfOverlay:not([data-filter]').each(function() {
			var $overlay = jQuery(this),
				$wrapper = $overlay.closest('.wpfMainWrapper');
			$overlay.attr('data-filter-for', $wrapper.attr('id')).attr('data-filter',$wrapper.attr('data-filter'));
			$overlay.appendTo('body');
		});

	});

	function applyFilter(_thisObj, $this) {
		var mainWrapper = $this.closest('.wpfMainWrapper');
		_thisObj.setCurrentLocation();

		_thisObj.filterClick = true;
		_thisObj.filtering(mainWrapper);
	}

	WpfFrontendPage.prototype.filterOptionsForDevices = (function () {
		var _thisObj = this.$obj;
		jQuery('.wpfMainWrapper .wpfFilterWrapper').each(function () {
			var _this = jQuery(this),
				wrapper = _this.closest('.wpfMainWrapper'),
				settings = _thisObj.getFilterMainSettings(wrapper),
				isMobile = false,
				screenSize = jQuery(window).width();

			if (settings.settings !== undefined) {
				var isMobileBreakpoint = settings.settings.desctop_mobile_breakpoint_switcher,
					mobileBreakpoinWidth = isMobileBreakpoint && isMobileBreakpoint == '1' ? settings.settings.desctop_mobile_breakpoint_width : '0',

					displayFor = settings.settings.display_for,

					filterWidthDesktop          = settings.settings.filter_width,
					filterWidthDesktopUnit      = settings.settings.filter_width_in,
					filterWidthMobile           = settings.settings.filter_width_mobile,
					filterWidthMobileUnit       = settings.settings.filter_width_in_mobile,
					filterBlockWidthDesktop     = settings.settings.filter_block_width,
					filterBlockWidthDesktopUnit = settings.settings.filter_block_width_in,
					filterBlockWidthMobile      = settings.settings.filter_block_width_mobile,
					filterBlockWidthMobileUnit  = settings.settings.filter_block_width_in_mobile;

				if (mobileBreakpoinWidth && '0' !== mobileBreakpoinWidth) {
					if (screenSize <= mobileBreakpoinWidth) {
						isMobile = true;
					}

					// "Filter Width" and "Filter Block Width" options
					if (isMobile && filterBlockWidthMobile != '0') {
						wrapper.css('width', filterWidthMobile+filterWidthMobileUnit);
						_this.css('width', filterBlockWidthMobile+filterBlockWidthMobileUnit);
						if (filterBlockWidthMobile+filterBlockWidthMobileUnit != '100%') {
							_this.css('float', 'left');
						}
					} else if (!isMobile && filterBlockWidthDesktop != '0') {
						wrapper.css('width', filterWidthDesktop+filterWidthDesktopUnit);
						_this.css('width', filterBlockWidthDesktop+filterBlockWidthDesktopUnit);
						if (filterBlockWidthDesktop+filterBlockWidthDesktopUnit != '100%') {
							_this.css('float', 'left');
						}
					}

					// "Display filter on"  option
					if (isMobile && displayFor == 'desktop') {
						wrapper.hide();
					} else if (!isMobile && displayFor == 'mobile') {
						wrapper.hide();
					}

					// filters title
					_this.find('.wpfFilterTitle[data-show-on-mobile]').each(function() {
						jQuery(this).closest('.wpfFilterMainWrapper').find('wpfLoaderLayout').show();
							var showDesctop = jQuery(this).data('show-on-desctop'),
								showMobile = jQuery(this).data('show-on-mobile'),
								content = jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent'),
								title = jQuery(this).find('.wfpTitle'),
								icons = {};
						title.show();

						var toggle = jQuery(this).closest('.wpfFilterWrapper').find('i.wpfTitleToggle, svg');
						setTimeout(function () {
							if (toggle.length) {
								toggle.show();
								if (typeof (_thisObj.getIcons) == 'function') {
									icons = _thisObj.getIcons(toggle);
								} else {
									icons = {collapsed: toggle.hasClass('fa-plus'), plusIcon: 'fa-plus', minusIcon: 'fa-minus'};
								}

								if (isMobile) {
									if (showMobile == 'yes_open') {
										_thisObj.openFilterToggle(toggle, content, false, icons);
									} else if (showMobile == 'yes_close') {
										_thisObj.closeFilterToggle(toggle, content, false, icons);
									} else if (showMobile == 'no') {
										_thisObj.openFilterToggle(toggle, content, false, icons);
										toggle.hide();
										title.hide();
									}
								} else {
									if (showDesctop == 'yes_open') {
										_thisObj.openFilterToggle(toggle, content, false, icons);
									} else if (showDesctop == 'yes_close') {
										_thisObj.closeFilterToggle(toggle, content, false, icons);
									} else if (showDesctop == 'no') {
										_thisObj.openFilterToggle(toggle, content, false, icons);
										toggle.hide();
										title.hide();
									}
								}
							}
						}, 100);
					});
				}
			}
		});
	});

	WpfFrontendPage.prototype.checkExeptionCasesBeforeFiltering = (function (filterInput) {
		var isExeption = false;
		// exeption when custom price do not set but input activated
		if ( jQuery(filterInput).parent().hasClass('wpfPriceCheckboxCustom')) {
			var customPriceWrapper = jQuery(filterInput).closest('li'),
				customMin = customPriceWrapper.find('input[name=wpf_custom_min]').val(),
				customMax = customPriceWrapper.find('input[name=wpf_custom_max]').val();

			if (!customMin && !customMax) {
				isExeption = true;
			}
		}
		return isExeption;
	});

	WpfFrontendPage.prototype.detectSingleCheckbox = (function (checkedInput) {
		var filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
			displayType = filterWrapper.data('display-type'),
			filterType = filterWrapper.data('filter-type');

		if (filterType == 'wpfCategory' || filterType == 'wpfPerfectBrand'|| filterType == 'wpfBrand') {
			var isOne = displayType == 'list';
		} else {
			var isOne = displayType == 'radio';
		}

		if (isOne) {
			var inputs = filterWrapper.find('input');

			if (checkedInput.is(':checked')) {
				inputs.prop('checked', false);
				checkedInput.prop('checked', true);
			}
		}
	});

	WpfFrontendPage.prototype.moveCheckedToTop = (function (checkedInput, setPause) {
		var _thisObj = this.$obj,
			sPause = setPause === false ? 0 : 200;
		setTimeout(function() {
			var checkboxWrapper = checkedInput.closest('li'),
				mainWrapper = checkedInput.closest('.wpfMainWrapper'),
				filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
				isHierarchical = filterWrapper.data('show-hierarchical'),
				settings = _thisObj.getFilterMainSettings(mainWrapper),
				checkboxesWrapper = checkedInput.closest(isHierarchical ? 'ul' : '.wpfFilterVerScroll');
			//if(settings && !isHierarchical) {
			if(settings && checkboxesWrapper.length) {
				settings = settings.settings;
				var checkedItemsTop = settings.checked_items_top === '1',
					isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(checkedInput);
				if(checkedItemsTop && !isExeptionCase){
					if (checkedInput.is(":checked")) {
						checkboxesWrapper.prepend(checkboxWrapper);
					} else {
						checkboxesWrapper.append(checkboxWrapper);
						checkboxesWrapper.append(checkboxesWrapper.find('.wpfShowFewerWrapper,.wpfShowMoreWrapper'));
					}
					checkboxesWrapper.scrollTop(0);
				}
			}
		}, sPause);
	});

	WpfFrontendPage.prototype.closeFilterToggle = (function (toggle, content, isTimeout, icons) {
		if (toggle.hasClass(icons.minusIcon)) {
			toggle.removeClass(icons.minusIcon);
			toggle.addClass(icons.plusIcon);
			content.addClass('wpfBlockAnimated');
			if (typeof isTimeout !== 'undefined' && isTimeout) {
				setTimeout(function () {
					if (content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
				}, 10);
			} else {
				if (content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
			}
		}
	});

	WpfFrontendPage.prototype.openFilterToggle = (function (toggle, content, isTimeout, icons) {
		if (toggle.hasClass(icons.plusIcon)) {
			toggle.removeClass(icons.plusIcon);
			toggle.addClass(icons.minusIcon);
			content.removeClass('wpfHide');
			if (typeof isTimeout !== 'undefined' && isTimeout) {
				setTimeout(function () {
					if (!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
				}, 400);
			} else {
				if (!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
			}
		}
	});

	WpfFrontendPage.prototype.setPagination = (function (pagination) {
		var wrapper = jQuery('.wpfMainWrapper').first(),
			$queryVars = wrapper.attr('data-settings');
		try{
			var settings = JSON.parse($queryVars);
		}catch(e){
			var settings = false;
		}
		if(settings){
			settings.pagination = pagination;
			wrapper.attr('data-settings', JSON.stringify(settings) );
		}
	});
	WpfFrontendPage.prototype.setCurrentLocation = (function() {
		app.wpfOldUrl = window.location.href;
		app.wpfNewUrl = app.wpfOldUrl;
	});
	//prepare url param
	WpfFrontendPage.prototype.prepareUrlParams = function(currentUrl) {
		// Step 1: Create a URL object to easily parse the current URL
		var finalUrl = new URL(currentUrl);
		// Step 2: Extract the path segments (e.g., /wbw/wpf_filter_cat_0/hoodies)
		var pathSegments = finalUrl.pathname.split('/').filter(Boolean); // Remove empty segments
		// Step 3: Initialize URLSearchParams to handle query parameters
		var urlParams = new URLSearchParams(finalUrl.search);
		// Step 4: Process the path segments and convert them into query parameters
		for (var i = 0; i < pathSegments.length; i++) {
			var segment = pathSegments[i];

			// Check if the segment is a filter key (e.g., wpf_filter_cat_0, pr_stock, etc.)
			if (segment.indexOf('wpf_filter_') === 0) {
				var filterKey = segment; // e.g., 'wpf_filter_cat_0'
				var filterValue = pathSegments[i + 1]; // e.g., 'hoodies'
				// You may need to resolve the term ID here based on the slug (e.g., 'hoodies' -> 34)
				// For now, we'll use the value directly, but you can integrate a lookup if needed

				// Add the filter to the query parameters
				urlParams.set(filterKey, filterValue); // Map the filterKey to filterValue
			}
		}

		// Step 5: Rebuild the URL with the updated parameters
		finalUrl.search = urlParams.toString();  // Set the new query string
		// Step 6: Return the final URL with updated query parameters
		return finalUrl.toString();  // Return the full URL with updated parameters
	};

	//prepare url param
	/**
	 * filtering.
	 *
	 * @version 3.1.3
	 */
	WpfFrontendPage.prototype.filtering = (function ($filterWrapper, clearAll, redirectLink, onlyRecalcFilter) {
		var _thisObj = this.$obj;
		_thisObj.chageRangeFieldWidth();
		if(_thisObj.isAdminPreview) return;

		if(typeof $filterWrapper == 'undefined' || $filterWrapper.length == 0) {
			$filterWrapper = jQuery('.wpfMainWrapper').first();
		}
		if (_thisObj.filterClick && $filterWrapper.length) {
			_thisObj.createOverlay($filterWrapper.attr('id'));
		}
		if (typeof (_thisObj.beforeFilteringPro) === 'function') {
			_thisObj.beforeFilteringPro($filterWrapper);
		}

		_thisObj.isSynchro = false;
		_thisObj.isStatistics = false;

		if ($filterWrapper.length !== 0) {
			_thisObj.filteringId++;
			_thisObj.lastFids[$filterWrapper.data('viewid')] = _thisObj.filteringId;

			var $filtersDataBackend = [],
				$filtersDataFrontend = [],
				noWooPage = _thisObj.noWoo,
				$generalSettings = _thisObj.getFilterMainSettings($filterWrapper);
			_thisObj.isSynchro = $generalSettings['settings']['use_filter_synchro'] && ($generalSettings['settings']['use_filter_synchro'] == '1') ? true : false;
			_thisObj.isStatistics = $filterWrapper.attr('data-is-stats') == 1;

			if(_thisObj.isSynchro) {
				_thisObj.syncronizeFilters($filterWrapper);
			}

			(_thisObj.isSynchro ? jQuery('.wpfMainWrapper') : $filterWrapper).find('.wpfFilterWrapper:not(.wpfNotActive), .wpfFilterWrapper.wpfPreselected').each(function () {
				var $filter = jQuery(this),
					filterType = $filter.attr('data-filter-type'),
					filterName = $filter.attr('data-get-attribute'),
					wrapper = $filter.closest('.wpfMainWrapper'),
					idFilter = wrapper.data('filter'),
					uniqId = $filter.attr('data-uniq-id'),
					allSettings = _thisObj.getFilterOptionsByType($filter, filterType),
					valueToPushBackend = {},
					valueToPushFrontend = {},
					logic = $filter.attr('data-query-logic'),
					isGroup = false,
					cgIndex = null;
				if(_thisObj.isStatistics && typeof (_thisObj.prepareStatisticsData) == 'function') {
					_thisObj.prepareStatisticsData($filter, allSettings);
				}

				try {
					var order = JSON.parse(_thisObj.getFilterMainSettings(wrapper).settings.filters.order);
					jQuery.each(order, function (i, v) {
						if (v.uniqId === uniqId) {
							jQuery.each(v.settings, function (i, v) {
								cgIndex = i.match(/^f_cglist\[(\d+)\]/);
								if (cgIndex !== null && typeof cgIndex[1] !== 'undefined' && v !== '') {
									isGroup = true;
								}
							});
						}
					});
				} catch (e) {
				}

				if (typeof logic === 'undefined') {
					logic = 'or';
				} else if (logic == 'not') {
					var notIds = $filter.attr('data-not-ids');
					if (notIds && notIds.length > 0) {
						allSettings = {backend: notIds.split(',')};
					}
				}
				var withChildren = $filter.attr('data-query-children');
				if (typeof withChildren === 'undefined') {
					withChildren = '1';
				}

				if (allSettings['backend'].length && typeof allSettings['backend'] !== 'undefined' || filterType === 'wpfSearchText'  || filterType === 'wpfSearchNumber') {
					valueToPushBackend['id'] = filterType;
					valueToPushBackend['uniqId'] = uniqId;
					valueToPushBackend['logic'] = logic;
					valueToPushBackend['children'] = withChildren;
					valueToPushBackend['settings'] = allSettings['backend'];
					valueToPushBackend['name'] = filterName;
					$filtersDataBackend.push(valueToPushBackend);
				}
				if ('frontend' in allSettings) {

					valueToPushFrontend['id'] = filterType;

					var logicDelimetrList = {
						or: '|',
						and: ',',
						not_in: ';'
					}

					valueToPushFrontend['delim'] = logicDelimetrList[logic];
					valueToPushFrontend['children'] = withChildren;
					valueToPushFrontend['settings'] = allSettings['frontend'];
					valueToPushFrontend['name'] = filterName;
					if (isGroup) {
						valueToPushFrontend['idFilter'] = idFilter;
						valueToPushFrontend['idBlock'] = uniqId.replace(/^wpf/, '');
					}
					$filtersDataFrontend.push(valueToPushFrontend);
				}
			});

			var redirectTerm = typeof redirectLink !== 'undefined';
			if (redirectTerm || (typeof $filterWrapper.data('redirect-page-url') !== 'undefined' && _thisObj.filterClick)) {
				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', location.protocol + '//' + location.host + location.pathname);
			}

			var filterId = $filterWrapper.data('filter');
			if (typeof filterId !== 'undefined') {
				jQuery('span.wpfHidden').each(function () {
					var $span = jQuery(this),
						attribute = $span.data('shortcode-attribute'),
						fclass = 'wpf-filter-' + filterId;
					if ((attribute.class !== '' && fclass === attribute.class) || $span.closest('.'+fclass).length) {
						_thisObj.QStringWork('wpf_id', filterId, noWooPage, $filterWrapper, 'change');
					}
				});
			}

			_thisObj.changeUrlByFilterParams($filtersDataFrontend);
			_thisObj.QStringWork('wpf_reload', '', noWooPage, $filterWrapper, 'remove');

			//get paged params from html
			var $queryVars = $filterWrapper.attr('data-settings'),
				$defQuery = $filterWrapper.attr('data-default-query'),
				$queryVarsSettings = JSON.parse($queryVars);

			var $filterSettings = $generalSettings === false ? {} : {
				'wpf_fid': _thisObj.filteringId,
				'filter_recount': $generalSettings['settings']['filter_recount'] && ($generalSettings['settings']['filter_recount'] == '1') ? true : false,
				'filter_recount_price': $generalSettings['settings']['filter_recount_price'] && ($generalSettings['settings']['filter_recount_price'] == '1') ? true : false,
				'text_no_products': $generalSettings['settings']['text_no_products'] ? $generalSettings['settings']['text_no_products'] : '',
				'count_product_shop': $generalSettings['settings']['count_product_shop'] ? parseInt($generalSettings['settings']['count_product_shop']) : 0,
				'f_multi_logic': $generalSettings['settings']['f_multi_logic'] ? $generalSettings['settings']['f_multi_logic'] : 'and',
				'remove_actions': $generalSettings['settings']['remove_actions'] && ($generalSettings['settings']['remove_actions'] == '1') ? true : false,
				'filtering_by_variations': $generalSettings['settings']['filtering_by_variations'] && ($generalSettings['settings']['filtering_by_variations'] == '1') ? true : false,
				'form_filter_by_variations': $generalSettings['settings']['form_filter_by_variations'] && ($generalSettings['settings']['form_filter_by_variations'] == '1') ? true : false,
				'exclude_backorder_variations': $generalSettings['settings']['exclude_backorder_variations'] && ($generalSettings['settings']['exclude_backorder_variations'] == '1') ? true : false,
				'display_product_variations': $generalSettings['settings']['display_product_variations'] && ($generalSettings['settings']['display_product_variations'] == '1') ? true : false,
				'all_products_filtering': $generalSettings['settings']['all_products_filtering'] && ($generalSettings['settings']['all_products_filtering'] == '1') ? true : false,
				'do_not_use_shortcut': $generalSettings['settings']['do_not_use_shortcut'] && ($generalSettings['settings']['do_not_use_shortcut'] == '1') ? true : false,
				'use_category_filtration': $generalSettings['settings']['use_category_filtration'] ? $generalSettings['settings']['use_category_filtration'] : 1,
				'product_list_selector': $generalSettings['settings']['product_list_selector'] ? $generalSettings['settings']['product_list_selector'] : '',
				'product_container_selector': $generalSettings['settings']['product_container_selector'] ? $generalSettings['settings']['product_container_selector'] : '',
				'auto_update_filter' : Number($generalSettings['settings']['auto_update_filter']),
				'redirect_only_click' : Number($generalSettings['settings']['redirect_only_click']),
				'display_status_private' : $generalSettings['settings']['display_status_private'] && ($generalSettings['settings']['display_status_private'] == '1') ? true : false,
				'open_one_by_one': $generalSettings['settings']['open_one_by_one'] ? $generalSettings['settings']['open_one_by_one'] : '',
				'obo_only_children': $generalSettings['settings']['obo_only_children'] ? $generalSettings['settings']['obo_only_children'] : '',
				'display_only_children_category': $generalSettings['settings']['display_only_children_category'] ? $generalSettings['settings']['display_only_children_category'] : '',
			};
			var $withPerPage = $filterWrapper.find('select.wpfPerPageDD'),
				perPageCount = $withPerPage.length ? $withPerPage.find('option:selected') : '';
			if (perPageCount.length) {
				$filterSettings['count_product_shop'] = perPageCount.val();
			}

			$filterSettings['sort_by_title'] = ($generalSettings['settings']['sort_by_title'] != undefined && $generalSettings['settings']['sort_by_title'] == '1' ? true : false);
			if (typeof $defQuery !== 'undefined' && $defQuery.length) $filterSettings['default_query'] = JSON.parse($defQuery);

			// find woocommerce product loop type ( shorcode, loop )
			var productContainerSelector = _thisObj.fixSelector($filterSettings['product_container_selector'], ''),
				productContainerElem = (productContainerSelector !== '')
					? jQuery(productContainerSelector)
					: jQuery(document);

			$queryVars = JSON.parse($queryVars);
			var shortcode = jQuery('span[data-shortcode-attribute]', productContainerElem),
				$shortcodeAttr = {};

			if (shortcode.length) {
				$shortcodeAttr = shortcode.data('shortcode-attribute');

				if ($shortcodeAttr['limit'] > 0) {
					$queryVars['posts_per_page'] = $shortcodeAttr['limit'];
				}

				$queryVars['wc_loop_type'] = 'shortcode';
				$queryVars['paginate_type'] = 'shortcode';
				$queryVars['paginate_base'] = 'product-page';
			} else {
				$queryVars['wc_loop_type'] = 'loop';
			}

			// for plugin WooCommerce Products Per Page
			var $wppp = jQuery('.wppp-select').first();
			if ($wppp.length) {
				$queryVars['posts_per_page'] = $wppp.val();
			}

			$queryVars = JSON.stringify($queryVars);
			$shortcodeAttr = JSON.stringify($shortcodeAttr);

			if (clearAll) {
				var newUrl = getCurrentUrlPartsWpf();
				if (newUrl.search.length && newUrl.search.indexOf('wpf_')) clearAll = false;
			}

			if ($filterSettings['count_product_shop'] > 0 && !clearAll) {
				_thisObj.QStringWork('wpf_count', $filterSettings['count_product_shop'], noWooPage, $filterWrapper, 'change');
			}
			if ($filterSettings['sort_by_title']) {
				_thisObj.QStringWork('wpf_order', 'title', noWooPage, $filterWrapper, 'change');
			}
			if ($filterSettings['filtering_by_variations'] && !clearAll) {
				_thisObj.QStringWork('wpf_fbv', 1, noWooPage, $filterWrapper, 'change');
			}
			if ($filterSettings['exclude_backorder_variations'] && !clearAll) {
				_thisObj.QStringWork('wpf_ebv', 1, noWooPage, $filterWrapper, 'change');
			}
			if ($filterSettings['display_product_variations'] && !clearAll) {
				_thisObj.QStringWork('wpf_dpv', 1, noWooPage, $filterWrapper, 'change');
			}
			if ($filterSettings['all_products_filtering'] && !clearAll) {
				_thisObj.QStringWork('all_products_filtering', '1', noWooPage, $filterWrapper, 'change');
			}
			if ($filtersDataBackend.length === 0) {
				_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
			}
			if ($filterSettings['f_multi_logic'] !== 'and' && !clearAll) {
				_thisObj.QStringWork('wpf_filter_tax_block_logic', $filterSettings['f_multi_logic'], noWooPage, $filterWrapper, 'change');
			}
			if ($filtersDataBackend.length === 0) {
				_thisObj.QStringWork('wpf_filter_tax_block_logic', '', noWooPage, $filterWrapper, 'remove');
			}
			// we always start from first page after filtering
			//if ($queryVarsSettings['paginate_type'] == 'query' || $queryVarsSettings['paginate_type'] == 'shortcode') {
			_thisObj.QStringWork($queryVarsSettings['paginate_base'], '', noWooPage, $filterWrapper, 'remove');
			_thisObj.QStringWork('product-page', '', noWooPage, $filterWrapper, 'remove');
			_thisObj.QStringWork('shopPage', '', noWooPage, $filterWrapper, 'remove');
			_thisObj.QStringWork('avia-element-paging', '', noWooPage, $filterWrapper, 'remove');

			var curUrl = getCurrentUrlPartsWpf();
			if (curUrl.search.length) {
				// Remove any URL parameters that start with 'e-page-'
				var ePageMatch = curUrl.search.match(/[?&](e-page-[^=&]+)=/);
				if (ePageMatch && ePageMatch[1]) {
					_thisObj.QStringWork(ePageMatch[1], '', noWooPage, $filterWrapper, 'remove');
				}

				var $pages = curUrl.search.match(/query-\d+-page/i);
				if ($pages != null && $pages.length) _thisObj.QStringWork($pages[0], '', noWooPage, $filterWrapper, 'remove');
			}

			var $woocommerceSettings = {};
			if (jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
				var $wooCommerceSort = jQuery('.woocommerce-ordering select');
				if ($wooCommerceSort.length > 0) {
					$woocommerceSettings['woocommercefSortBy'] = $wooCommerceSort.eq(0).val();
				}
			}
			if (onlyRecalcFilter) {
				// this block for forced filter refresh without product filtering
				// you can call this with custom js: window.wpfFrontendPage.filtering(jQuery('.wpfMainWrapper[data-filter="1"]'),false,false,true);
				var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
				_thisObj.ajaxOnlyRecount(requestData, $filterWrapper.attr('id'));
				return;
			}
			var redirect = (typeof $filterWrapper.data('redirect-page-url') !== 'undefined'),
				$needUrl = $filterSettings['open_one_by_one'] == '1' && $filterSettings['obo_only_children'] == '1';
			//slug generation
			if (history.pushState && app.wpfNewUrl != window.wpfOldUrl && ((!redirect && !redirectTerm) || $needUrl)) {
				var slugFormat=_thisObj.slugFormat;
				var newUrl = app.wpfNewUrl.indexOf('pr_search_') > 0 ? app.wpfNewUrl.replace('+', '%2b') : app.wpfNewUrl;
				var finalUrl = newUrl;
				if (slugFormat !== "" && slugFormat !== 0 && slugFormat && slugFormat !== "0") {
					var search = newUrl ? new URL(newUrl).search : window.location.search;
					var segments = _thisObj.convertParamsToSegments(search);
					finalUrl = $generalSettings.settings.shop_base_url + 'wbw/' + segments.join('/');
					if (segments.length === 0) finalUrl = $generalSettings.settings.shop_base_url;
				}
				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', finalUrl);
				app.wpfOldUrl = app.wpfNewUrl;
				_thisObj.changeSlugByUrl();
			}
			//slug generation
			if (redirectTerm || (redirect && _thisObj.filterClick)) {
				let queryString = app.wpfNewUrl.split('?')[1] || '';
				if (queryString !== '') {
					if (_thisObj.isStatistics) {
						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
						wpfDoActionsAfterLoad(_thisObj.filteringId, -1, requestData);
					}
					var redLink = (redirectTerm ? redirectLink : $filterWrapper.data('redirect-page-url'));
					jQuery(location).attr('href', redLink + (redLink.indexOf('?') == -1 ? '?' : '&') + queryString + '&redirect');
				}
			} else {
				if ($generalSettings && $generalSettings.settings.enable_ajax !== '1') {
					if (_thisObj.isStatistics) {
						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);
						wpfDoActionsAfterLoad(_thisObj.filteringId, -1, requestData);
					}
					if (_thisObj.isSafari || navigator.userAgent.match(/firefox|fxios/i)) location.reload(true);
					else location.reload();
					return;
				}

				_thisObj.currentFilterBackend = $filtersDataBackend;
				// event for custom javascript hook
				var customEvent = document.createEvent('Event');
				customEvent.initEvent('wpfAjaxStart', false, true);
				document.dispatchEvent(customEvent);
				//ajax call to server
				_thisObj.currentLoadId = $filterWrapper.attr('id');

				var $wtbpFilterWrapper = $filterWrapper.closest('.wpfFilterForWtbp');
				if ($wtbpFilterWrapper.length == 0) {
					if ($filterWrapper.closest('.wpfFilterForWtbpFloating').length) {
						$wtbpFilterWrapper = $('.wpfFilterForWtbp[data-wpf-id="'+$filterWrapper.attr('data-filter')+'"]');
					}
				}
				if ($wtbpFilterWrapper.length == 1) {
					var wtbpTableId = $wtbpFilterWrapper.closest('.wtbpTableWrapper').attr('data-table-id'),
						wtbpTable = wtbpTableId ? window.woobewoo.WooTablepress.getTableInstanceById(wtbpTableId) : false;
					if (wtbpTable && wtbpTable.isSSP) {
						wtbpTable.ajax.reload();
						return;
					}
				}
				_thisObj.sendFiltersOptionsByAjax(_thisObj.currentFilterBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr);
				if (_thisObj.isSynchro) {
					jQuery('.wpfMainWrapper:not(#'+_thisObj.currentLoadId+')').each(function(){
						var $synchroWrapper = jQuery(this);

						$generalSettings = _thisObj.getFilterMainSettings($synchroWrapper);
						var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);

						_thisObj.ajaxOnlyRecount(requestData, $synchroWrapper.attr('id'));

					});
				}
			}
		}
	});

	WpfFrontendPage.prototype.getAjaxRequestData = (function ($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings) {
		$generalSettings = $generalSettings ? $generalSettings['settings']['filters']['order'] : [];
		var typeSettings = typeof $generalSettings;
		if (typeSettings == 'undefined') $generalSettings = '[]';
		else if (typeSettings != 'string') $generalSettings = JSON.stringify($generalSettings);

		return {
			mod: 'woofilters',
			action: 'filtersFrontend',
			filtersDataBackend: JSON.stringify($filtersDataBackend),
			queryvars: $queryVars,
			filterSettings: JSON.stringify($filterSettings),
			generalSettings: $generalSettings,
			shortcodeAttr: $shortcodeAttr,
			woocommerceSettings: JSON.stringify($woocommerceSettings),
			currenturl: window.location.href,
		};
	});

	WpfFrontendPage.prototype.createOverlay = (function (filterId) {
		var selector = '#wpfOverlay';
		if (typeof filterId != 'undefined') selector += '[data-filter-for="'+filterId+'"]';
		jQuery(selector).css({'display':'block'});
	});

	WpfFrontendPage.prototype.removeOverlay = (function () {
		jQuery('#wpfOverlay').css({'display':'none'});
		jQuery('#wpfOverlay[data-filter-for]').css({'display':'none'});
	});

	WpfFrontendPage.prototype.syncronizeFilters = (function ($filterWrapper) {
		var _thisObj = this.$obj,
			filterId = $filterWrapper.attr('id');

		$filterWrapper.find('.wpfFilterWrapper').each(function () {
			var $filter = jQuery(this),
				filterType = $filter.attr('data-filter-type'),
				filterDisplay = $filter.attr('data-display-type'),
				filterSlug = $filter.attr('data-slug'),
				filterTaxonomy = $filter.attr('data-taxonomy'),
				selector = '.wpfMainWrapper:not(#'+filterId+') .wpfFilterWrapper[data-filter-type="'+filterType+'"]';
			if (filterDisplay) selector += '[data-display-type="'+filterDisplay+'"]';
			if (filterSlug) selector += '[data-slug="'+filterSlug+'"]';
			if (filterTaxonomy) selector += '[data-taxonomy="'+filterTaxonomy+'"]';
			var $synchroFilters = jQuery(selector);
			if ($synchroFilters.length) {
				$synchroFilters.find('input').prop('checked', false).trigger('wpf-synchro');
				$filter.find('input:checked').each(function(){
					var $li = jQuery(this).closest('[data-term-id]');
					if ($li) {
						var $synchroInput = $synchroFilters.find('[data-term-id="'+$li.attr('data-term-id')+'"] input');
						if ($synchroInput.length == 0 && filterDisplay == 'colors') $synchroInput = $synchroFilters.find('input[data-term-id="'+$li.attr('data-term-id')+'"]');
						if ($synchroInput.length) $synchroInput.prop('checked', true).trigger('wpf-synchro');
					}
				});
				if (filterType === 'wpfPrice'){
					var min = $filter.find('#wpfMinPrice').val(),
						max = $filter.find('#wpfMaxPrice').val();
					$synchroFilters.each(function() {
						var $slider = jQuery(this);
						$slider.find('#wpfMinPrice').val(min);
						$slider.find('#wpfMaxPrice').val(max);
						//$slider.find('#wpfSliderRange').slider("option", "values", [ min, max ]);
					});
				} else if (filterDisplay == 'mul_dropdown') {
					$synchroFilters.find('select').val($filter.find('select').val());
					$synchroFilters.find('select.jqmsLoaded').multiselect('reload');
				} else if(filterDisplay == 'text') {
					$synchroFilters.find('input').val($filter.find('input').val());
				} else {
					var value = $filter.find('select').val();
					$synchroFilters.find('select').each(function() {
						if (jQuery(this).find('option[value="'+value+'"]').length) jQuery(this).val(value);
					});
				}

				if(typeof(_thisObj.syncronizeFiltersPro) == 'function') {
					_thisObj.syncronizeFiltersPro($filter, $synchroFilters);
				}

				if ($filter.hasClass('wpfNotActive')) $synchroFilters.addClass('wpfNotActive');
				else $synchroFilters.removeClass('wpfNotActive');
			}



		});

		//_thisObj.markCheckboxSelected(filter);
	});

	WpfFrontendPage.prototype.clearFilters = (function (filter, clearAll) {
		var _thisObj = this.$obj,
			noWooPage = _thisObj.noWoo,
			clearAll = typeof clearAll == 'undefined' ? false : true;

		(filter ? filter : jQuery('.wpfFilterWrapper')).each(function () {
			var $filter = jQuery(this),
				$filterWrapper = $filter.closest('.wpfMainWrapper'),
				filterAttribute = $filter.attr('data-get-attribute'),
				filterType = $filter.attr('data-display-type'),
				defValue = $filter.attr('data-filter-default');
			if (typeof defValue === 'undefined') {
				defValue = '';
			}

			filterAttribute = filterAttribute.split(",");
			var count = filterAttribute.length;
			for(var i = 0; i < count; i++){
				_thisObj.QStringWork(filterAttribute[i], '', noWooPage, $filterWrapper, 'remove');
			}

			if($filter.hasClass('wpfHidden')){
				$filter.removeClass('wpfNotActive');
			} else {
				$filter.find('input').prop('checked', false);

				if(filterType == 'mul_dropdown') {
					$filter.find('select').val('');
					$filter.find('select.jqmsLoaded').multiselect('reload');
				} else if(filterType == 'text') {
					$filter.find('input').val('');
				} else {
					$filter.find("select").val($filter.find("select option:first").val());
				}
				if (defValue.length && clearAll) {
					if(filterType == 'dropdown') {
						$filter.find('select').val($filter.find('select option[data-term-slug="'+defValue+'"]').val());
					} else {
						$filter.find('li[data-term-slug="'+defValue+'"] input').prop('checked', true);
					}
					$filter.removeClass('wpfNotActive');
				} else {
					$filter.addClass('wpfNotActive');
				}
			}

			if($filter.attr('data-filter-type') === 'wpfPrice'){
				var min = $filter.find('#wpfMinPrice').attr('min'),
					max = $filter.find('#wpfMaxPrice').attr('max');
				$filter.find('#wpfMinPrice').val(min);
				$filter.find('#wpfMaxPrice').val(max);

				jQuery( "#wpfSliderRange" ).slider( "option", "values", [ min, max ] );
			}

			if(typeof(_thisObj.clearFiltersPro) == 'function') {
				_thisObj.clearFiltersPro($filter);
			}
			if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
				_thisObj.eventChangeFilterPro($filter);
			}
			if(clearAll) {
				_thisObj.QStringWork('wpf_order', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('wpf_count', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('wpf_oistock', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('wpf_fbv', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('wpf_dpv', '', noWooPage, $filterWrapper, 'remove');
				_thisObj.QStringWork('wpf_ebv', '', noWooPage, $filterWrapper, 'remove');
			}
		});

		_thisObj.markCheckboxSelected(filter);
	});

	WpfFrontendPage.prototype.getFilterMainSettings = (function ($selector) {
		var settingsStr = $selector.attr('data-filter-settings');
		try{
			var settings = JSON.parse(settingsStr);
		}catch(e){
			var settings = false;
		}
		if (settings === false) {
			settingsStr = settingsStr.replace('}]"', '}]').replace('"[{', '[{');
			try{
				settings = JSON.parse(settingsStr);
			}catch(e){
				settings = false;
			}
		}
		return settings;
	});

	WpfFrontendPage.prototype.getFilterParam = (function (paramSlug, mainWrapper, filterWrapper) {
		var paramValue = null,
			_thisObj = this.$obj,
			mainSettings = _thisObj.getFilterMainSettings(mainWrapper),
			orderKey = filterWrapper.attr('data-order-key');
		if (mainSettings.settings.filters.order && typeof orderKey !== undefined) {
			var filtersOderList = JSON.parse(mainSettings.settings.filters.order);
			if ( typeof filtersOderList[orderKey] !== undefined ) {
				var filterParamList = filtersOderList[orderKey].settings;
				if ( typeof filterParamList[paramSlug] !== undefined ) {
					paramValue = filterParamList[paramSlug];
				}
			}
		}
		return paramValue;
	});

	WpfFrontendPage.prototype.checkNoWooPage = (function () {
		var noWooPage = false;
		if(jQuery('.wpfMainWrapper').first().attr('data-nowoo')){
			noWooPage = true;
		}
		return noWooPage;
	});

	WpfFrontendPage.prototype.changeLmpButton = (function () {
		var lmpBtn = jQuery('.br_lmp_button_settings .lmp_button');
		if (lmpBtn.length) {
			var parentStyle = lmpBtn.parent().attr('style').replace(' ', '');
			if (parentStyle.indexOf('display:none') > -1) {
				return;
			}
			var url = lmpBtn.attr('href').split('?')[0];
			url += window.location.search;
			url = url.indexOf('/page/2') > -1 ? url : url.replace(/\/page\/[0-9]{1,}/ig, '/page/2');
			lmpBtn.attr('href', url);
			setTimeout(function(){
				jQuery('.woocommerce-pagination').addClass('wpfHidden');
			}, 1000);
		}
	});


	WpfFrontendPage.prototype.changeUrlByFilterParams = (function ($filtersDataFrontend) {
		var _thisObj = this.$obj,
			noWooPage = _thisObj.noWoo;
		if (typeof $filtersDataFrontend !== 'undefined' && $filtersDataFrontend.length > 0) {
			// the array is defined and has at least one element
			var count = $filtersDataFrontend.length,
				filterWrapper = jQuery('.wpfMainWrapper'),
				priceFlag = true;
			for(var i = 0; i < count; i++){
				switch ($filtersDataFrontend[i]['id']){
					case 'wpfPrice':
					case 'wpfPriceRange':
						if (priceFlag) {
							var minPrice = $filtersDataFrontend[i]['settings']['wpf_min_price'],
								maxPrice = $filtersDataFrontend[i]['settings']['wpf_max_price'],
								tax = $filtersDataFrontend[i]['settings']['tax'];

							if (typeof minPrice !== 'undefined' && minPrice.length > 0) {
								_thisObj.QStringWork('wpf_min_price', minPrice, noWooPage, filterWrapper, 'change');
							} else {
								_thisObj.QStringWork('wpf_min_price', '', noWooPage, filterWrapper, 'remove');
							}
							if (typeof maxPrice !== 'undefined' && maxPrice.length > 0) {
								_thisObj.QStringWork('wpf_max_price', maxPrice, noWooPage, filterWrapper, 'change');
							} else {
								_thisObj.QStringWork('wpf_max_price', '', noWooPage, filterWrapper, 'remove');
							}
							if (typeof tax !== 'undefined') {
								_thisObj.QStringWork('tax', tax, noWooPage, filterWrapper, 'change');
							} else {
								_thisObj.QStringWork('tax', '', noWooPage, filterWrapper, 'remove');
							}
							priceFlag = false;
						}
						break;
					case 'wpfSortBy':
						var orderby = $filtersDataFrontend[i]['settings']['orderby'],
							oistock = $filtersDataFrontend[i]['settings']['oistock'];
						if (typeof orderby !== 'undefined' && orderby.length > 0 ) {
							_thisObj.QStringWork('orderby', orderby, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('orderby', '', noWooPage, filterWrapper, 'remove');
						}
						if (typeof oistock !== 'undefined' && oistock == 1 ) {
							_thisObj.QStringWork('wpf_oistock', 1, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('wpf_oistock', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfCategory':
					case 'wpfPerfectBrand':
						var product_cat = $filtersDataFrontend[i]['settings']['settings'],
							name = $filtersDataFrontend[i]['name'],
							delim = $filtersDataFrontend[i]['delim'];
						product_cat = product_cat.join(delim ? delim : '|');
						if (typeof product_cat !== 'undefined' && product_cat.length > 0) {
							_thisObj.QStringWork(name, product_cat, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfTags':
						var product_tag = $filtersDataFrontend[i]['settings']['settings'],
							name = $filtersDataFrontend[i]['name'],
							delim = $filtersDataFrontend[i]['delim'];
						product_tag = product_tag.join(delim ? delim : '|');
						if (typeof product_tag !== 'undefined' && product_tag.length > 0) {
							_thisObj.QStringWork(name, product_tag, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfCustomField':
						var name  = $filtersDataFrontend[i]['name'];
						var delim = $filtersDataFrontend[i]['delim'] || '|';
						// Your custom field stores frontend settings as: settings[name] = "A|B"
						// (not as settings.settings = ["A","B"])
						var settingsObj = $filtersDataFrontend[i]['settings'] || {};
						var cfValues = (typeof settingsObj.settings !== 'undefined')
							? settingsObj.settings
							: settingsObj[name];

						if (Array.isArray(cfValues)) {
							cfValues = cfValues.join(delim);
						}

						if (typeof cfValues === 'string' && cfValues.length > 0) {
							_thisObj.QStringWork(name, cfValues, noWooPage, filterWrapper, 'change');
						} else {
							_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfAttribute':
						var product_taxonomy = $filtersDataFrontend[i]['settings']['taxonomy'],
							product_attr = $filtersDataFrontend[i]['settings']['settings'],
							delim = $filtersDataFrontend[i]['delim'];
						product_attr = product_attr.join(delim ? delim : '|');
						if (typeof product_attr !== 'undefined' && product_attr.length > 0) {
							_thisObj.QStringWork(product_taxonomy, product_attr, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork(product_taxonomy, '', noWooPage, filterWrapper, 'remove');
						}

						if (typeof $filtersDataFrontend[i]['idBlock']!== 'undefined' && typeof $filtersDataFrontend[i]['idFilter']!== 'undefined' ) {
							_thisObj.QStringWork('group' + product_taxonomy.replace('filter', '') + $filtersDataFrontend[i]['idBlock'], $filtersDataFrontend[i]['idFilter'], noWooPage, filterWrapper, 'change');
						}
						break;
					case 'wpfAuthor':
						var authorVal = $filtersDataFrontend[i]['settings']['settings'],
							name = $filtersDataFrontend[i]['name'],
							delim = $filtersDataFrontend[i]['delim'];
							authorVal = authorVal.join(delim ? delim : '|');
						if (typeof authorVal !== 'undefined' && authorVal.length > 0) {
							_thisObj.QStringWork('pr_author', authorVal, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('pr_author', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfFeatured':
						var featureVal = $filtersDataFrontend[i]['settings']['settings'];
						if (typeof featureVal !== 'undefined' && featureVal.length > 0) {
							_thisObj.QStringWork('pr_featured', featureVal, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('pr_featured', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfOnSale':
						var onSaleVal = $filtersDataFrontend[i]['settings']['settings'];
						if (typeof onSaleVal !== 'undefined' && onSaleVal.length > 0) {
							_thisObj.QStringWork('pr_onsale', onSaleVal, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('pr_onsale', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfInStock':
						var pr_stock = $filtersDataFrontend[i]['settings']['settings'];
						pr_stock = pr_stock.join(delim ? delim : '|');
						if (typeof pr_stock !== 'undefined' && pr_stock.length > 0 ) {
							_thisObj.QStringWork('pr_stock', pr_stock, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('pr_stock', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					case 'wpfRating':
						var ratingVal = $filtersDataFrontend[i]['settings']['settings'];
						if (typeof ratingVal !== 'undefined' && checkArray(ratingVal) && ratingVal.length > 0 ) {
							_thisObj.QStringWork('pr_rating', ratingVal, noWooPage, filterWrapper, 'change');
						}else{
							_thisObj.QStringWork('pr_rating', '', noWooPage, filterWrapper, 'remove');
						}
						break;
					default:
						if(typeof(_thisObj.changeUrlByFilterParamsPro) == 'function') {
							_thisObj.changeUrlByFilterParamsPro($filtersDataFrontend[i], noWooPage, filterWrapper);
						}
						break;
				}
			}
		}else{
			return false;
		}

	});

	/**
	 * changeSlugByUrl.
	 *
	 * @version 2.8.6
	 */
	WpfFrontendPage.prototype.changeSlugByUrl = (function () {
		jQuery('.wpfSlugWrapper .wpfSlug').remove();
		var _thisObj = this.$obj,
			noWooPage = _thisObj.noWoo,
			searchParams = jQuery.toQueryParams(window.location.search);
		if (noWooPage) {
			if( jQuery('.wpfMainWrapper').first().attr('data-hide-url')) {
				searchParams =  jQuery.toQueryParams(jQuery('.wpfMainWrapper').first().attr('data-hide-url'));
			}
		}

		var isRedirect = 'redirect' in searchParams && searchParams['redirect'] == 1;

		for (var key in searchParams) {
			if(key === 'wpf_min_price'){
				key = 'wpf_min_price,wpf_max_price,tax';
			}
			var $elem = jQuery('.wpfFilterWrapper[data-get-attribute="'+key+'"]');
			if (!$elem.length && isRedirect) {
				var parts = key.split('_'),
					cnt = parts.length;
				if (cnt > 2 && isNumber(parts[cnt-1])) {
					parts.pop();
					$elem = jQuery('.wpfFilterWrapper[data-get-attribute^="'+parts.join('_')+'"]');
					_thisObj.QStringWork(key, '', false, $elem.closest('.wpfMainWrapper'), 'remove');

				}
			}
			if($elem.length > 0) {
				var elem = $elem.first(),
					$slug = elem.attr('data-slug'),
					$label = elem.attr('data-label'),
					$title = elem.attr('data-title'),
					$getAttr = elem.attr('data-get-attribute'),
					$filterType = elem.attr('data-filter-type');
				if(typeof $title != 'undefined') $label = $title;
				else if(typeof $label == 'undefined') $label = $slug;

				var html = '';
				if(jQuery('.wpfSlugWrapper').length > 0){
					if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
						html += '<div class="wpfSlug" data-slug="'+$slug+'" data-get-attribute="'+$getAttr+'" data-filter-type="'+$filterType+'"><div class="wpfSlugTitle">'+$label+'</div><div class="wpfSlugDelete">x</div></div>';
						jQuery('.wpfSlugWrapper').append(html);
					}
				}else{
					if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
						html += '<div class="wpfSlugWrapper">';
						html += '<div class="wpfSlug" data-slug="'+$slug+'" data-get-attribute="'+$getAttr+'" data-filter-type="'+$filterType+'"><div class="wpfSlugTitle">'+$label+'</div><div class="wpfSlugDelete">x</div></div>';
						html += '</div>';
						jQuery('.storefront-sorting').append(html);
					}
				}
			}
			if (isRedirect && history.pushState && app.wpfNewUrl != window.wpfOldUrl)  {
				history.pushState({state: 1, rand: Math.random(), wpf: true}, '', app.wpfNewUrl);
				app.wpfOldUrl = app.wpfNewUrl;
			}
		}

	});

	WpfFrontendPage.prototype.sendFiltersOptionsByAjax = (function ($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr) {
		var _thisObj = this.$obj,
			$wrapperSettings = [];
		if ( window.wpfAdminPage ) {
			return false;
		}
		_thisObj.currentAjaxJSLoaded = false;
		_thisObj.currentProductBlock = false;

		if (_thisObj.filterLoadTypes[_thisObj.currentLoadId] && _thisObj.filterLoadTypes[_thisObj.currentLoadId] == 'reload') {
			location.reload();
			return;
		}
		var ajax_leave_products = $generalSettings && $generalSettings['settings'] && $generalSettings['settings']['ajax_leave_products'] == '1'

		if (typeof $generalSettings !== 'undefined') {
			$wrapperSettings = $generalSettings['settings'];
		}

		var customListSelector = $filterSettings['product_list_selector'],
			productListSelector = _thisObj.fixSelector(customListSelector, _thisObj.defaultProductSelector),
			productContainerSelector = _thisObj.fixSelector($filterSettings['product_container_selector'], ''),
			forceThemeTemplates = ($wrapperSettings['force_theme_templates'] == 1);

		var productContainerElem = (productContainerSelector !== '')
			? jQuery(productContainerSelector)
			: jQuery(document);

		if (productContainerElem.length === 0) {
			location.reload();
			return;
		}

		var productListElem = jQuery(productListSelector, productContainerElem);
		if (productListElem.hasClass('wpfNoWooPage') || productListElem.closest('.wpfNoWooPage').length) {
			forceThemeTemplates = false;
		}

		if (productListElem.length && (_thisObj.filterClick)) {
			if (_thisObj.enableFiltersLoaderPro && ajax_leave_products) {
				_thisObj.enableFiltersLoaderPro(_thisObj.currentLoadId, productListElem);
			} else {
				_thisObj.enableFiltersLoader(_thisObj.currentLoadId, productListElem);
			}
		}

		var onlyRecount = false;
		if ($filterSettings === undefined) {
			$filterSettings = [];
		} else {
			if (!_thisObj.filterClick && $filterSettings.auto_update_filter && !$filterSettings.redirect_only_click) {
				onlyRecount = true;
			}
		}

		var requestData =_thisObj.getAjaxRequestData($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $shortcodeAttr, $woocommerceSettings);

		if (onlyRecount) {
			_thisObj.ajaxOnlyRecount(requestData, _thisObj.currentLoadId, $wrapperSettings);
			return;
		} else if (forceThemeTemplates || _thisObj.filterLoadTypes[_thisObj.currentLoadId] == 'force') {
			_thisObj.ajaxForceThemeTemplates(productContainerSelector, productListSelector, requestData, $wrapperSettings);
			return;
		}

		/**
		 * There are some cases when we do not provide ajax functionlity
		 */
		if ( window.InfiniteScroll && window.InfiniteScroll.prototype ) {
			/**
			 * Flatsome theme compability
			 * We do not privide ajax functionlity with infinite scroll
			 *
			 * @link https://themeforest.net/item/flatsome-multipurpose-responsive-woocommerce-theme/5484319
			 */
			if (_thisObj.filterClick && jQuery('body').hasClass('theme-flatsome')) {
				location.reload();
				return;
			}
		}
		_thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'ajax';

		jQuery.sendFormWpf({
			data: requestData,
			onSuccess: function(res) {
				if (!res.error) {
					if ('fid' in res.data && toeInArray(res.data['fid'], _thisObj.lastFids) == -1) {
						return false;
					}
					if ('optionsHtml' in res.data) {
						var optionsHtml = res.data['optionsHtml'];

						jQuery('.wpfMainWrapper .wpfFilterWrapper[data-order-key]').each(function() {
							var $filter = jQuery(this),
								orderKey = $filter.attr('data-order-key'),
								$select = $filter.find('select');

							if (typeof optionsHtml[orderKey] !== 'undefined' && $select.length){
								var selectedValues = [];
								$select.find('option:selected').each(function() {
									selectedValues.push(jQuery(this).val());
								});

								$select.html(optionsHtml[orderKey]);

								if (selectedValues.length) {
									$select.val(selectedValues);
								}

							}
						});
					}
					if ('jscript' in res.data) {
						_thisObj.setAjaxJScript(res.data['jscript']);
					}
					if (_thisObj.filterClick) {
						if (customListSelector !== '' && productListElem.length) {
							var loopContainer = productListElem;
							loopContainer.html(res.data['productHtml']);
						} else {
							var catSelector = wpfGetSelector(res.data['categoryHtml'], true, _thisObj.defaultProductSelector, 1, false, productContainerElem),
								loopSelector = wpfGetSelector(res.data['loopStartHtml'], true, _thisObj.defaultProductSelector, 3, false, productContainerElem),
								loopContainer = jQuery(loopSelector, productContainerElem);

							if (!loopContainer.length) {
								// trying to obtain loop container without dynamically change classes with numbers in it names
								loopSelector = wpfGetSelector(res.data['loopStartHtml'], true, _thisObj.defaultProductSelector, 3, true, productContainerElem);
								loopContainer = jQuery(loopSelector, productContainerElem);
							}

							loopContainer.prev('.brand-description').remove();
							if (typeof res.data['beforeProductHtml'] !== 'undefined') {
								loopContainer.before('<div class="brand-description">' + res.data['beforeProductHtml'] + '</div>');
							}
							if (typeof jQuery('.product-categories-wrapper', productContainerElem) !== 'undefined' && jQuery('.product-categories-wrapper > ul.products', productContainerElem).length > 0) {
								//replace cats html
								if (res.data['categoryHtml'].length) {
									jQuery('.product-categories-wrapper > ul.products', productContainerElem).html(res.data['categoryHtml']);
								}
								//replace products html
								jQuery(_thisObj.defaultProductSelector, productContainerElem).eq(1).html(res.data['productHtml']);
							} else if (jQuery('.elementor-widget-container ul.products', productContainerElem).length > 0) {
								jQuery('.elementor-widget-container ul.products', productContainerElem).each(function () {
									if (!jQuery(this).find('.product-category').length) {
										jQuery(this).html(res.data['categoryHtml'] + res.data['productHtml']);
									}
								});
							} else if (jQuery('.woocommerce > .products[data-filterargs][data-innerargs]', productContainerElem).length > 0) {
								jQuery('.woocommerce > .products[data-filterargs][data-innerargs]', productContainerElem).html(res.data['categoryHtml'] + res.data['productHtml']);
							} else {
								if (!loopContainer.length) {
									if (!jQuery('.wpfMainWrapper', productContainerElem).attr('data-nowoo') !== typeof undefined
										&& !jQuery('.wpfMainWrapper', productContainerElem).attr('data-nowoo') !== false)
										_thisObj.ajaxForceThemeTemplates(productContainerSelector, productListSelector, requestData, $wrapperSettings);
									else {
										location.reload(true);
									}
									_thisObj.afterAjaxFiltering($wrapperSettings);
									return false;
								}

								loopContainer.each(function () {
									//replace cats html
									jQuery(this).html(res.data['categoryHtml']);
									//replace products html
									jQuery(this).append(res.data['productHtml']);
								});
							}
						}

						var countSelector = wpfGetSelector(res.data['resultCountHtml'], true, '.woocommerce-result-count', 1, false, productContainerElem),
							wooCount = jQuery(countSelector, productContainerElem);
						if (wooCount.length > 0) {
							wooCount.replaceWith(res.data['resultCountHtml']);
						}

						var isLeerPagination = res.data['paginationHtml'] == '',
							paginationSelector = wpfGetSelector(res.data[isLeerPagination ? 'paginationLeerHtml' : 'paginationHtml'], false, '.woocommerce-pagination', 1, false, productContainerElem),
							wooPagination = jQuery(paginationSelector, productContainerElem),
							newPagination = res.data['paginationHtml'];

						if (wooPagination.length > 0) {
							if (typeof _thisObj.paginationClasses == 'undefined') {
								_thisObj.paginationClasses = wooPagination.attr('class');
							}
							if (isLeerPagination) {
								wooPagination.css({'display': 'none'});
								wooPagination.empty();
							} else {
								wooPagination.replaceWith(newPagination);
							}
						} else if (!isLeerPagination) {
							var afterLoop = jQuery('.after-shop-loop', productContainerElem);
							if (afterLoop.length > 0) {
								afterLoop.prepend(newPagination);
							} else {
								wooCount = jQuery('.storefront-sorting ' + countSelector, productContainerElem);
								if (wooCount.length > 0) {
									wooCount.after(newPagination);
								} else {
									let shortcodeData = productContainerElem.find('span[data-shortcode-attribute]'),
										isPaginate = shortcodeData.length ? shortcodeData.data('shortcode-attribute').paginate : true;
									if (typeof isPaginate === 'undefined' || isPaginate) {
										loopContainer.eq(0).after(newPagination);
									}
								}
							}
						}
						if (typeof _thisObj.paginationClasses != 'undefined') {
							jQuery(paginationSelector, productContainerElem).attr('class', _thisObj.paginationClasses);
						}
						_thisObj.currentProductBlock = loopContainer.selector;
						if (!_thisObj.currentProductBlock) {
							loopContainer.addClass('wpfCurrentProductBlock');
							_thisObj.currentProductBlock = '.wpfCurrentProductBlock';
						}
					}

					_thisObj.afterAjaxFiltering($wrapperSettings);
					jQuery('.wpfLoaderLayout').hide();
				}
			}
		});
	});

	WpfFrontendPage.prototype.ajaxForceThemeTemplates = (function (productContainerSelector, productListSelector, requestData, $wrapperSettings) {
		var _thisObj = this.$obj,
			curUrl = window.location.href,
			isContainer = (productContainerSelector != '');

		_thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'force';

		jQuery.ajax({
			type: "GET",
			url: curUrl + (curUrl.indexOf('?') == -1 ? '?' : '&') + 'wpf_skip=1&wpf_fid=' + _thisObj.filteringId,
			cache: false,
			dataType: 'html',
			success: function(data){
				var block = '',
					foundContainer = false,
					noProducts = false,
					$loadedData = jQuery(data),
					$loadedJS = $loadedData.find('.wpfExistsTermsJS');
				if ($loadedJS.length) {
					if (toeInArray($loadedJS.eq(0).attr('data-fid'), _thisObj.lastFids) == -1) {
						return false;
					}
				}

				if (isContainer) {
					block = jQuery(data).find(productContainerSelector);
				}
				if (block.length) {
					foundContainer = true;
				} else {
					block = jQuery(data).find(productListSelector);
				}
				var pageBlock = jQuery(isContainer && (foundContainer || block.length == 0) ? productContainerSelector : productListSelector);
				if (block.length == 0 || pageBlock.length == 0) {
					if ($wrapperSettings.recalculate_filters === '1') {
						var existsTermsJS = jQuery(data).find('.wpfExistsTermsJS').html();
						_thisObj.setAjaxJScript(existsTermsJS);
					}
					if ($wrapperSettings.no_redirect_by_no_products === '1' && pageBlock.length > 0) {
						block = jQuery('<div><div class="wpfNoProducts">' + $wrapperSettings.text_no_products + '</div></div>');
						noProducts = true;
					} else {
						_thisObj.filterLoadTypes[_thisObj.currentLoadId] = 'reload';
						location.reload();
						return;
					}
				}
				if ($wrapperSettings.recalculate_filters !== '1') {
					_thisObj.ajaxOnlyRecount(requestData);
				}

				_thisObj.currentProductBlock = (typeof pageBlock.selector !== 'undefined') ? pageBlock.selector : productListSelector ;

				block.each(function (index, value) {
					var blockWhere = pageBlock.eq(index),
						blockWhat = jQuery(value);

					if (!foundContainer && !noProducts) {
						blockWhere = blockWhere.parent();
						blockWhat = blockWhat.parent();
					}
					// some plugins save url parameters in input fields
					blockWhat.find('input[name="wpf_skip"]').remove();

					blockWhere.html(blockWhat.html().replace(/wpf_skip=1/g, '').replace(/wpf_fid=[0-9]*/g, '').replace(/&amp;&amp;/g, '&amp;'));

					// if pagination is not in the block to be replaced, we will try to find and replace it
					var paginationPageBlock = jQuery(blockWhere).find('.woocommerce-pagination');
					if (!paginationPageBlock.length) {
						var paginationPage = jQuery('.woocommerce-pagination');
						var paginationResponse = jQuery(data).find('.woocommerce-pagination');
						if (paginationResponse.length) {
							paginationResponse = paginationResponse.eq(0).html().replace(/wpf_skip=1/g, '').replace(/wpf_fid=[0-9]*/g, '').replace(/&amp;&amp;/g, '&amp;');
							if (paginationPage.length) {
								paginationPage.html(paginationResponse);
							} else {
								jQuery(blockWhere).parent().after('<nav class="woocommerce-pagination">' + paginationResponse + '</nav>');
							}
						} else if (paginationPage.length) {
							paginationPage.remove();
						}
					}

					// if result count is not in the block to be replaced, we will try to find and replace it
					var resultCountBlock = jQuery(blockWhere).find('.woocommerce-result-count');
					var resultCountResponse = jQuery(data).find('.woocommerce-result-count');
					if (!resultCountBlock.length && resultCountResponse.length) {
						var resultCount = jQuery('.woocommerce-result-count');
						if (resultCount.length) {
							resultCount.replaceWith(resultCountResponse);
						}
					}
				});
				// for Divi archive loop
				var $styleObj = jQuery('style[id^="et-builder-module-design-"]');
				if ($styleObj.length == 1) {
					var $styleObjLoaded = $loadedData.find('style[id^="et-builder-module-design-"]');
					if ($styleObjLoaded.length == 0) $styleObjLoaded = $loadedData.filter('style[id^="et-builder-module-design-"]');
					if ($styleObjLoaded.length == 1) $styleObj.html($styleObjLoaded.html());
				}

				_thisObj.afterAjaxFiltering($wrapperSettings);
				_thisObj.runReadyList();
				if ($wrapperSettings.recalculate_filters === '1') {
					var existsTermsJS = jQuery(data).find('.wpfExistsTermsJS').html();
					_thisObj.setAjaxJScript(existsTermsJS);
				}

			}
		});

		return false;
	});

	WpfFrontendPage.prototype.ajaxOnlyRecount = (function (requestData, filterId, $wrapperSettings) {
		var _thisObj = this.$obj;

		if (!_thisObj.currentAjaxJSLoaded && requestData) {
			requestData['only_recound'] = 1;

			if (typeof filterId !==  'undefined') {
				requestData['synchro_filter_id'] = filterId;
			}

			jQuery.sendFormWpf({
				data: requestData,
				onSuccess: function (res) {

					if (typeof $wrapperSettings !== 'undefined'
						&& typeof $wrapperSettings.filter_loader_icon_onload_enable !== 'undefined'
						&& Number($wrapperSettings.filter_loader_icon_onload_enable)) {
						hideFilterLoader(jQuery('#' + filterId));
					}

					if (!res.error) {

						if ('jscript' in res.data) {
							_thisObj.setAjaxJScript(res.data['jscript'], filterId);
						}

					}
					_thisObj.removeOverlay();
				}
			});
		}

	});

	WpfFrontendPage.prototype.setAjaxJScript = (function(jscript, filterId){
		var _thisObj = this.$obj,
			filter = jQuery('#' + (typeof(filterId) == 'undefined' ? _thisObj.currentLoadId : filterId));
		if (filter.length && jscript != '') {
			var jsBlock = filter.find('.wpfAjaxJSBlock');
			if (jsBlock.length == 0) {
				jQuery('<div class="wpfAjaxJSBlock wpfHidden"></div>').appendTo(filter);
			}
			filter.find('.wpfAjaxJSBlock').html(jscript);
		}
		_thisObj.currentAjaxJSLoaded = true;
	});
	WpfFrontendPage.prototype.afterAjaxFiltering = (function($wrapperSettings){
		var _thisObj = this.$obj;

		//if changed min/max price and we have wpfPrice filter
		//we need change slider
		_thisObj.getUrlParamsChangeFiltersValues();

		_thisObj.disableFiltersLoader();
		_thisObj.removeOverlay();
		toggleClear();

		// fix for OceanWP theme
		if ( jQuery('body').find('.products').hasClass('oceanwp-row') ) {
			var products = jQuery('body').find('.products'),
				aligns = ['center', 'left', 'right'];
			products.find('li:first').addClass('col');
			for (var i = 1; i <= 7; i++) {
				if (products.find('li').hasClass('span_1_of_' + i)) {
					products.find('li:first').addClass('span_1_of_' + i);
					break;
				}
			}
			for (var j = 0; j < aligns.length; j++) {
				if (products.find('li').hasClass('owp-content-' + aligns[j])) {
					products.find('li:first').addClass('owp-content-' + aligns[j]);
					break;
				}
			}
		}

		_thisObj.changeLmpButton();

		// for yith quick view
		jQuery(document).trigger('yith_wcqv_wcajaxnav_update');

		if (typeof (_thisObj.scrollToProductsPro) == 'function') {
			_thisObj.scrollToProductsPro($wrapperSettings);
		}

		if (jQuery(_thisObj.defaultProductSelector).closest('.et_pb_shop').length && jQuery(_thisObj.defaultProductSelector).find('[loading="lazy"]').length == 0) {
			heightIdenticalInRow('.et_pb_shop li.product');
		}

		// Improve compatibility with 'Woocommerce Products Per Page'
		jQuery('.form-wppp-select').each( function () {
			var $form = jQuery(this);
			$form.attr('action', jQuery('#'+_thisObj.currentLoadId).attr('data-hide-url'));
			$form.find('input[type="hidden"]').remove();
		});
		// Improve compatibility with Theme Bricks + Bricks Builder
		if (typeof(bricksLazyLoad) == 'function') {
			bricksLazyLoad();
		}

		// event for custom javascript hook, example: document.addEventListener('wpfAjaxSuccess', function(event) {console.log('Custom js');});
		//document.dispatchEvent(new Event('wpfAjaxSuccess')); - not work in IE11
		var customEvent = document.createEvent('Event');
		customEvent.initEvent('wpfAjaxSuccess', false, true);
		document.dispatchEvent(customEvent);
	});

	WpfFrontendPage.prototype.runReadyList = (function(){
		if (window.readyList && readyList.length) {
			var _thisObj = this.$obj;
			if (_thisObj.disableScrollJs) {
				jQuery(window).off("yith_infs_start").off("scroll touchstart");
				if (typeof(jQuery.fn) == 'object' && typeof(jQuery.fn.init_infinitescroll) == 'function') {
					jQuery.fn.init_infinitescroll();
				}
			}
			jQuery(window.readyList).each(function(i, el) {
				var strFunc = el['a'][0].toString();
				if (strFunc.indexOf('WpfFrontendPage') == -1) {
					for(var i = 0; i < _thisObj.readyFuncs.length; i++) {
						if (strFunc.indexOf(_thisObj.readyFuncs[i]) != -1 && (strFunc.indexOf('.ajaxComplete(') == -1 || i == 3 || i == 4)) {
							try {
								window.originalReadyMethod.apply(el['c'], el['a']);
							} catch(e) {
								console.log(e);
							}
							break;
						}
					}
				}
			});
		}
		jQuery(window).trigger("fusion-element-render-fusion_woo_product_grid");
		var fusionPrInfinite = jQuery(".fusion-products-container-infinite");
		if (fusionPrInfinite.length && typeof(fusionPrInfinite.infinitescroll) == 'function') {
			fusionPrInfinite.infinitescroll('unbind');
			fusionPrInfinite.infinitescroll('bind');
		}

		if (typeof elementorFrontend !== 'undefined') {
			jQuery(window).trigger('resize');

			var $eaPagination = jQuery('.elementor-widget-eicon-woocommerce');
			if ($eaPagination.length && window.elementorFrontend && window.elementorFrontend.hooks) {
				window.elementorFrontend.hooks.doAction('frontend/element_ready/eicon-woocommerce.default', $eaPagination, jQuery);
			}
		}

		// AVADA infinitescroll
		if (jQuery('.fusion-grid-container-infinite').length == 1) {
			jQuery(document).trigger('fusion-element-render-fusion_post_cards');
			jQuery('.fusion-grid-container-infinite').infinitescroll('unbind');
			jQuery('.fusion-grid-container-infinite').infinitescroll('bind');
		}
	});

	WpfFrontendPage.prototype.enableFiltersLoader = (function(idWrapper, productListElem){
		var preview = jQuery('#' + idWrapper + ' .wpfPreviewLoader').first().clone().removeClass('wpfHidden');
		productListElem.html(preview);
	});

	WpfFrontendPage.prototype.disableFiltersLoader =(function(){
		jQuery('.wpfPreviewLoader').first().clone().addClass('wpfHidden');
	});

	//after load change price and price range filters params if find get params
	WpfFrontendPage.prototype.getUrlParamsChangeFiltersValues = (function(){
		var _thisObj = this.$obj,
			noWooPage = _thisObj.noWoo;
		var $generalSettings = _thisObj.getFilterMainSettings(jQuery('.wpfMainWrapper'));
		var slugFormat=_thisObj.slugFormat;
		// Check if 'slug_format' exists and is valid
		if(noWooPage || slugFormat !== "" && slugFormat !== 0 && slugFormat && slugFormat !== "0"){
			var curUrl = jQuery('.wpfMainWrapper').first().attr('data-hide-url');
		}else{
			var curUrl = window.location.href;
		}
		if(!curUrl){
			return;
		}
		//get all get params
		var urlParams = _thisObj.findGetParameter(curUrl);
		jQuery('.wpfFilterWrapper').each(function () {
			var $filter = jQuery(this),
				filterType = $filter.attr('data-filter-type'),
				settings = _thisObj.getFilterMainSettings($filter.closest('.wpfMainWrapper'));

			switch(filterType){
				case 'wpfAttribute':
					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
						_thisObj.eventChangeFilterPro($filter, settings);
					}
					break;
				case 'wpfPrice':
					var rate = $filter.data('rate');
					urlParams = _thisObj.getConvertedPrices(urlParams, rate);
					var minPrice = urlParams.wpf_min_price ? urlParams.wpf_min_price : $filter.attr('data-minvalue'),
						maxPrice = urlParams.wpf_max_price ? urlParams.wpf_max_price : $filter.attr('data-maxvalue'),
						skin = 'default';

					if(minPrice){
						$filter.find('#wpfMinPrice').val(minPrice);
					}
					if(maxPrice){
						$filter.find('#wpfMaxPrice').val(maxPrice);
					}
					if(settings){
						skin = $filter.attr('data-price-skin');
					}
					if(skin === 'default'){
						var sliderWrapper = $filter.find("#wpfSliderRange");
					}else{
						var sliderCurBefore = ($filter.attr('data-slider-currency-before') != undefined) ? $filter.attr('data-slider-currency-before') : '';
						var sliderCurAfter = ($filter.attr('data-slider-currency-after') != undefined) ? $filter.attr('data-slider-currency-after') : '';
						var sliderWrapper = $filter.find('.ion-range-slider').data('ionRangeSlider');
						$filter.addClass('wpfNotActiveSlider');

						if (sliderCurBefore || sliderCurAfter) {
							setTimeout(function()
							{
								$filter.find('span.irs-min:first').html(sliderCurBefore + sliderWrapper['result'].min_pretty + sliderCurAfter);
								$filter.find('span.irs-max:first').html(sliderCurBefore + sliderWrapper['result'].max_pretty + sliderCurAfter);
								$filter.find('span.irs-from:first').html(sliderCurBefore + sliderWrapper['result'].from_pretty + sliderCurAfter);
								$filter.find('span.irs-to:first').html(sliderCurBefore + sliderWrapper['result'].to_pretty + sliderCurAfter);
							}, 500);
						}
					}
					if(minPrice && maxPrice){
						if(skin === 'default'){
							sliderWrapper.slider({
								values: [minPrice, maxPrice]
							});
						}else if(typeof(sliderWrapper) != 'undefined') {
							sliderWrapper.update({from: minPrice, to: maxPrice});
							$filter.removeClass('wpfNotActiveSlider');
						}
					}
					_thisObj.chageRangeFieldWidth();
					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
						_thisObj.eventChangeFilterPro($filter, settings);
					}
					break;
				case 'wpfPriceRange':
					var rate = $filter.data('rate');
					urlParams = _thisObj.getConvertedPrices(urlParams, rate);
					var minPrice = urlParams.wpf_min_price ? parseFloat(urlParams.wpf_min_price) : false,
						maxPrice = urlParams.wpf_max_price ? parseFloat(urlParams.wpf_max_price) : false,
						$options = $filter.find('li');
					$options.find('input[type="checkbox"]').prop('checked', false);
					$options.each(function () {
						var _this = jQuery(this),
							range = _this.attr('data-range');
						if(typeof range != 'undefined') {
							range = range.split(',');
							var minRange = range[0] == '' ? false : parseFloat(range[0]),
								maxRange = range[1] == '' ? false : parseFloat(range[1]),
								minPrices = [minPrice - 1, minPrice, minPrice + 1], // rounding error correction
								maxPrices = [maxPrice - 1, maxPrice, maxPrice + 1]; // rounding error correction

							if(minPrices.includes(minRange) && maxPrices.includes(maxRange)){
								_this.find('input[type="checkbox"]').prop('checked', true);
								return false;
							}
						}
					});
					if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
						_thisObj.eventChangeFilterPro($filter, settings);
					}
					break;
			}
		});

	});

	WpfFrontendPage.prototype.findGetParameter =(function(url){
		// This function is anonymous, is executed immediately and
		// the return value is assigned to QueryString!
		var query_string = {},
			usefulParam = url.split("?")[1] || "",
			query = usefulParam || "",
			vars = query.split("&");

		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split("=");

			// If first entry with this name
			if (typeof query_string[pair[0]] === "undefined") {
				query_string[pair[0]] = decodeURIComponent(pair[1]);
				// If second entry with this name
			} else if (typeof query_string[pair[0]] === "string") {
				var arr = [query_string[pair[0]], decodeURIComponent(pair[1])];
				query_string[pair[0]] = arr;
				// If third or later entry with this name
			} else {
				query_string[pair[0]].push(decodeURIComponent(pair[1]));
			}
		}
		return query_string;
	});

	WpfFrontendPage.prototype.getClearLabel = (function (label, withCount) {
		if(withCount) {
			var cnt = label.lastIndexOf('(');
			if(cnt == -1) cnt = label.lastIndexOf('<span');
			if(cnt != -1) label = label.substring(0, cnt).trim();
		}

		label = label.replace(/&nbsp;/g,'');

		return label;
	});

	WpfFrontendPage.prototype.getFilterOptionsByType = (function($filter, filterType){
		var _thisObj = this.$obj;
		return _thisObj['get' + filterType.replace('wpf', '') + 'FilterOptions']($filter);
	});

	WpfFrontendPage.prototype.getPriceFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			options = [],
			minPrice = $filter.find('#wpfMinPrice').val(),
			maxPrice = $filter.find('#wpfMaxPrice').val(),
			tax = $filter.data('tax'),
			rate = $filter.data('rate'),
			str = '';

		[minPrice, maxPrice, tax] = _thisObj.getConvertedPrices([minPrice, maxPrice, tax], rate);
		str = minPrice + ',' + maxPrice;
		options.push(str);

		//options for frontend(change url)
		var frontendOptions = [],
			getParams = $filter.attr('data-get-attribute');
		frontendOptions['rate'] = rate;

		getParams = getParams.split(",");
		for (var i = 0; i < getParams.length; i++) {
			if (i === 0) {
				frontendOptions[getParams[i]] = minPrice;
			}
			if (i === 1) {
				frontendOptions[getParams[i]] = maxPrice;
			}
			if (i === 2 && tax !== '') {
				frontendOptions[getParams[i]] = tax;
			}
		}
		var symbol = $filter.find('.wpfCurrencySymbol'),
			symbolB = symbol.length && !symbol.is(':last-child') ? symbol.html() : '',
			symbolA = symbol.length && symbol.is(':last-child') ? symbol.html() : '',
			selectedOptions = {'is_one': true, 'list': [symbolB + minPrice + symbolA + ' - ' + symbolB + maxPrice + symbolA]};

		optionsArray['backend'] = options;
		optionsArray['frontend'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = [[minPrice, maxPrice]];

		return optionsArray;
	});

	WpfFrontendPage.prototype.getPriceRangeFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			options = [],
			frontendOptions = [],
			selectedOptions = {'is_one': true, 'list': []},
			statistics = [],
			i = 0,
			rate = $filter.data('rate');

		if ($filter.attr('data-display-type') === 'list') {
			if ($filter.find("input:checked").length) {
				var li = $filter.find('input:checked').closest('li');
				options[i] = li.attr('data-range');
				selectedOptions['list'][i] = li.find('.wpfValue').html();
			}
		}else if($filter.attr('data-display-type') === 'dropdown'){
			if($filter.find(":selected").attr('data-range')){
				var option = $filter.find(":selected");
				options[i] = option.attr('data-range');
				selectedOptions['list'][i] = option.html();
			}

		}

		//options for frontend(change url)
		if (typeof options !== 'undefined' && options.length > 0) {
			var getParams = $filter.attr('data-get-attribute'),
				tax = $filter.data('tax');
			frontendOptions['rate'] = rate;
			getParams = getParams.split(",");
			if (typeof options[0] !== 'undefined' && options[0].length > 0) {
				var prices = options[0].split(',');
				[prices[0], prices[1], tax] = _thisObj.getConvertedPrices([prices[0], prices[1], tax], rate);
				frontendOptions[getParams[0]] = prices[0];
				frontendOptions[getParams[1]] = prices[1];
				if (typeof tax !== 'undefined') {
					frontendOptions[getParams[2]] = tax;
				}
			}
		}
		if (options.length == 0) {
			var defRange = $filter.attr('data-default');
			if (typeof defRange != 'undefined' && defRange.length) {
				options[i] = defRange;
			}
		}

		if (typeof rate !== 'undefined') {
			var minPrice = '',
				maxPrice = '';
			options = options.map(function (elem) {
				[minPrice, maxPrice] = _thisObj.getConvertedPrices(elem.split(","), rate);
				return minPrice + ',' + maxPrice;
			});
		}

		if (options.length) {
			statistics = options.map(function (elem) {
				return elem.split(",");
			});
		}
		optionsArray['backend'] = options;
		optionsArray['frontend'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getSortByFilterOptions = (function ($filter) {
		var optionsArray = [],
			options = [],
			frontendOptions = [],
			selectedOptions = {'is_one': true, 'list': []},
			value = '';
		if ($filter.data('display-type') === 'radio') {
			var elem = $filter.find('input:checked').closest('li'),
				name = elem.find('.wpfFilterTaxNameWrapper').html();
		} else {
			var elem = $filter.find('select:not(.wpfPerPageDD)').find('option:selected'),
				name = elem.html();
		}
		if (elem.length) {
			value = elem.data('term-slug');
			//options for backend (filtering)
			options.push(value);

			//options for frontend(change url)
			var getParams = $filter.attr('data-get-attribute');
			frontendOptions[getParams] = value;
			selectedOptions['list'][0] = name;
			optionsArray['stats'] = [name];
		}
		if ($filter.data('first-instock') == '1') {
			frontendOptions['oistock'] = 1;
			options.push('oistock');
		}

		optionsArray['backend'] = options;
		optionsArray['frontend'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		return optionsArray;
	});

	WpfFrontendPage.prototype.getInStockFilterOptions = (function ($filter) {
		var optionsArray = [],
			frontendOptions = [],
			options = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType === 'dropdown'), 'list': []},
			statistics = [],
			i = 0;

		//options for backend (filtering)
		if(filterType === 'dropdown'){
			var option = $filter.find(":selected"),
				value = option.attr('data-slug');
			if(value != '') {
				options[i] = value;
				frontendOptions[i] = value;
				var name = option.html();
				selectedOptions['list'][i] = name;
				statistics.push(name);
			}
		} else {
			$filter.find('input:checked').each(function () {
				var li = jQuery(this).closest('li'),
					slug = li.attr('data-term-slug'),
					name = li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : li.find('.wpfValue').html();
				options[i] = slug;
				frontendOptions[i] = slug;
				selectedOptions['list'][li.attr('data-term-id')] = name;
				statistics.push(name);
				i++;
			});
		}
		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});
	//custom field
	WpfFrontendPage.prototype.getCustomFieldFilterOptions = (function ($filter) {
		var optionsArray = [],
			frontendOptions = {},
			options = [],
			statistics = [],
			filterType = $filter.attr('data-display-type') || $filter.data('display-type'),
			getParams = $filter.attr('data-get-attribute'),
			selectedOptions = {'is_one': (filterType === 'radio'), 'list': []},
			i = 0;
		if (!getParams) {
			optionsArray['backend']  = [];
			optionsArray['frontend'] = {};
			optionsArray['selected'] = selectedOptions;
			optionsArray['stats']    = [];
			return optionsArray;
		}
		if (filterType === 'radio') {
			var $sel = $filter.find('input[type="radio"]:checked');
			if ($sel.length) {
				var value = $sel.val();
				var label = $sel.closest('label').text().trim();
				options.push(value);
				var logic = $filter.attr('data-query-logic') || 'or';
				var joinDelim = (logic === 'and') ? ',' : '|';
				frontendOptions[getParams] = options.join(joinDelim);
				selectedOptions['list'] = [label];
				statistics = [label];
			}
		} else { // checkbox
			$filter.find('input[type="checkbox"]:checked').each(function () {
				var value = jQuery(this).val();
				var label = jQuery(this).closest('label').text().trim();

				options.push(value);
				selectedOptions['list'].push(label);
				statistics.push(label);
			});

			if (options.length) {
				frontendOptions[getParams] = options.join('|'); // ✅ key=Red|Green (correct)
			}
		}
		optionsArray['backend']  = options;
		optionsArray['frontend'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats']    = statistics;
		return optionsArray;
	});
	//customfield
	WpfFrontendPage.prototype.getCategoryFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			frontendOptions = [],
			options = [],
			filterType = $filter.attr('data-display-type'),
			useSlugs = $filter.attr('data-use-slugs') == '1',
			selectedOptions = {'is_one': (filterType == 'list' || filterType == 'dropdown'), 'list': []},
			statistics = [],
			i = 0;

		//options for backend (filtering)
		if(filterType === 'dropdown'){
			var option = $filter.find(":selected"),
				id = option.attr('data-term-id'),
				value = option.val();
			if(value != '') {
				options[i] = value;
				var name = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
				selectedOptions['list'][id] = name;
				statistics.push(name);
			}
			frontendOptions[i] = (useSlugs ? option.attr('data-term-slug') : id);
		} else if(filterType === 'mul_dropdown'){
			$filter.find(':selected').each(function () {
				var option = jQuery(this),
					id = option.attr('data-term-id');
				options[i] = option.val();
				frontendOptions[i] = (useSlugs ? option.attr('data-term-slug') : id);
				var name = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
				selectedOptions['list'][id] = name;
				statistics.push(name);
				i++;
			});
		} else {
			var removeSelectedList = [];
			$filter.find('input').each(function () {
				var inputCurent = jQuery(this),
					liCurent = inputCurent.closest('li'),
					id = liCurent.data('term-id'),
					isParent = liCurent.children('ul').length > 0,
					isChecked = inputCurent.is(':checked'),
					hierarchicalLogic = $filter.attr('data-logic-hierarchical'),
					type = $filter.attr('data-display-type'),
					isHierarchical = $filter.attr('data-show-hierarchical'),
					isHierarchicalLogic = isHierarchical === 'true' && type === 'multi' || type === 'text';

				if ( isParent ) {
					var isAllChildChecked = true,
						childList = [];

					liCurent.find('ul li').each(function() {
						var childId = jQuery(this).data('term-id'),
							childLi = jQuery(this),
							childInput = childLi.find('input'),
							isChildChecked = childInput.prop('checked');

						childList.push(childId);

						if (!isChildChecked) {
							isAllChildChecked = false;
							return false;
						}
					});

					if (isChecked && isAllChildChecked) {
						removeSelectedList = removeSelectedList.concat(childList);

						var onlyUnique = function(value, index, self) {
							return self.indexOf(value) === index;
						}

						removeSelectedList = removeSelectedList.filter( onlyUnique );
						selectedOptions.removeSelected = removeSelectedList;
					}
				}

				if (jQuery(this).is(':checked')) {
					if ( isHierarchicalLogic && hierarchicalLogic == 'child' ) {
						var liElements = liCurent.find('li'),
							isChildChicked = false;

						for (var j = 0; j < liElements.length; ++j) {
							 var li = liElements[j];
							if (jQuery(li).find('input').prop('checked')) {
								isChildChicked = true;
							}
						}
						if (!isChildChicked) {
							options[i] = id;
							frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
						}
					} else if(isHierarchicalLogic && hierarchicalLogic == 'parent') {
						var parents = liCurent.parents('li'),
							isChildChicked = false;

						for (var j = 0; j < parents.length; ++j) {
							 var li = parents[j];
							if (jQuery(li).find('input').prop('checked')) {
								isChildChicked = true;
							}
						}
						if (!isChildChicked) {
							options[i] = id;
							frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
						}
					} else {
						options[i] = id;
						frontendOptions[i] = (useSlugs ? liCurent.attr('data-term-slug') : id);
					}
					var name = liCurent.find('.wpfValue').html();
					selectedOptions['list'][id] = name;
					statistics.push(liCurent.find('.wpfFilterTaxNameWrapper:first').length ? liCurent.find('.wpfFilterTaxNameWrapper:first').html() : name);
					i++;
				}
			});
		}

		var options = options.filter(function (el) {
			return el != null;
		});
		var frontendOptions = frontendOptions.filter(function (el) {
			return el != null;
		});


		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getPerfectBrandFilterOptions = (function ($filter) {
		return this.$obj.getCategoryFilterOptions($filter);
	});

	WpfFrontendPage.prototype.getTagsFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			options = [],
			frontendOptions = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
			statistics = [],
			withCount = $filter.hasClass('wpfShowCount'),
			i = 0,
			proFilterType = [
				'colors'
			];

		//options for backend (filtering)
		if(filterType === 'dropdown'){
			var option = $filter.find(":selected"),
				value = option.val();
			if(value != '') {
				options[i] = value;
				frontendOptions[i] = option.attr('data-slug');
				var name = _thisObj.getClearLabel(option.html(), withCount);
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
			}
		} else if (filterType === 'mul_dropdown'){
			$filter.find(':selected').each(function () {
				var option = jQuery(this);
				options[i] = option.val();
				frontendOptions[i] = option.attr('data-slug');
				var name = _thisObj.getClearLabel(option.html(), withCount);
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
				i++;
			});
		} else if (jQuery.inArray(filterType, proFilterType) == -1 ) {
			$filter.find('input:checked').each(function () {
				var li = jQuery(this).closest('li'),
					id = li.attr('data-term-id');
				options[i] = id;
				frontendOptions[i] = li.attr('data-term-slug');
				var name = li.find('.wpfValue').html();
				selectedOptions['list'][id] = name;
				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
				i++;
			});
		}

		var data = {
			options : options,
			frontendOptions : frontendOptions,
			selectedOptions : selectedOptions,
			statistics : statistics,
			i : i,
		}

		if (typeof window.wpfFrontendPage.getTagsFilterOptionsPro == 'function') {
			data = window.wpfFrontendPage.getTagsFilterOptionsPro($filter, data);
		}

		optionsArray['backend'] = data.options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = data.frontendOptions;
		optionsArray['selected'] = data.selectedOptions;
		optionsArray['stats'] = data.statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getAttributeFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			options = [],
			frontendOptions = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
			statistics = [],
			withCount = $filter.hasClass('wpfShowCount'),
			i = 0,
			proFilterType = [
				'slider',
				'colors'
			];

		//options for backend (filtering)
		if (filterType === 'dropdown'){
			var option = $filter.find(":selected"),
				value = option.val();
			if (value != '') {
				options[i] = value;
				frontendOptions[i] = option.attr('data-slug');
				var name = _thisObj.getClearLabel(option.html(), withCount);
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
			}
		} else if (filterType === 'mul_dropdown'){
			$filter.find(':selected').each(function () {
				var option = jQuery(this);
				options[i] = option.val();
				frontendOptions[i] = option.attr('data-slug');
				var name = _thisObj.getClearLabel(option.html(), withCount);
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
				i++;
			});
		} else if (jQuery.inArray(filterType, proFilterType) == -1 ) {
			$filter.find('input:checked').each(function () {
				var li = jQuery(this).closest('li'),
					id = li.attr('data-term-id');
				options[i] = id;
				frontendOptions[i] = li.attr('data-term-slug');
				var name = li.find('.wpfValue').html();
				selectedOptions['list'][id] = name;
				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
				i++;
			});
		}

		var data = {
			options : options,
			frontendOptions : frontendOptions,
			selectedOptions : selectedOptions,
			statistics : statistics,
			i : i,
		}

		if (typeof window.wpfFrontendPage.getAttributeFilterOptionsPro == 'function') {
			data = window.wpfFrontendPage.getAttributeFilterOptionsPro($filter, data);
		}

		optionsArray['backend'] = data.options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = data.frontendOptions;
		optionsArray['selected'] = data.selectedOptions;
		optionsArray['stats'] = data.statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getAuthorFilterOptions = (function ($filter) {
		var _thisObj = this.$obj,
			optionsArray = [],
			options = [],
			frontendOptions = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
			statistics = [],
			i = 0;

		//options for backend (filtering)
		if(filterType === 'list'){
			$filter.find('input:checked').each(function () {
				var li = jQuery(this).closest('li'),
					id = li.attr('data-term-id');
				options[i] = id;
				frontendOptions[i] = li.attr('data-term-slug');
				var name = li.find('.wpfValue').html();
				selectedOptions['list'][id] = name;
				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
				i++;
			});
		} else if (filterType === 'mul_dropdown'){
			$filter.find(':selected').each(function () {
				var option = jQuery(this);
				options[i] = option.val();
				frontendOptions[i] = option.attr('data-slug');
				var name = _thisObj.getClearLabel(option.html());
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
				i++;
			});
		} else if (filterType === 'dropdown'){
			var option = $filter.find(":selected"),
				value = option.val();
			options[i] = value;
			if(value != '') {
				frontendOptions[i] = option.attr('data-slug');
				var name = option.html();
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
			}
		}
		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getFeaturedFilterOptions = (function ($filter) {
		var optionsArray = [],
			options = [],
			frontendOptions = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
			statistics = [],
			i = 0;

		$filter.find('input:checked').each(function () {
			var li = jQuery(this).closest('li'),
				id = li.attr('data-term-id');
			options[i] = id;
			frontendOptions[i] = li.attr('data-term-slug');
			var name = li.find('.wpfValue').html();
			selectedOptions['list'][id] = name;
			statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
			i++;
		});
		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getOnSaleFilterOptions = (function ($filter) {
		var optionsArray = [],
			options = [],
			frontendOptions = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
			statistics = [],
			i = 0;

		$filter.find('input:checked').each(function () {
			var li = jQuery(this).closest('li'),
				id = li.attr('data-term-id');
			options[i] = id;
			frontendOptions[i] = li.attr('data-term-slug');
			var name = li.find('.wpfValue').html();
			selectedOptions['list'][id] = name;
			statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
			i++;
		});
		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.getRatingFilterOptions = (function ($filter) {
		var optionsArray = [],
			frontendOptions = [],
			options = [],
			filterType = $filter.attr('data-display-type'),
			selectedOptions = {'is_one': true, 'list': []},
			statistics = [],
			i = 0;

		//options for backend (filtering)
		if(filterType == 'linestars' || filterType == 'liststars'){
			var input = $filter.find('input.wpfStarInput:checked'),
				rating = input.val();
			options[i] = rating;
			frontendOptions[i] = rating;
			var name = input.attr('data-label');
			selectedOptions['list'][i] = name;
			statistics.push(name);
		}else if(filterType == 'list'){
			$filter.find('input:checked').each(function () {
				var li = jQuery(this).closest('li'),
					id = li.attr('data-term-id');
				options[i] = id;
				frontendOptions[i] = li.attr('data-term-slug');
				var name = li.find('.wpfValue').html();
				selectedOptions['list'][id] = name;
				statistics.push(li.find('.wpfFilterTaxNameWrapper').length ? li.find('.wpfFilterTaxNameWrapper').html() : name);
				i++;
			});
		}else if(filterType == 'dropdown'){
			var option = $filter.find(":selected"),
				value = option.val();
			options[i] = value;
			if(value != '') {
				frontendOptions[i] = option.attr('data-slug');
				var name = option.html();
				selectedOptions['list'][option.attr('data-term-id')] = name;
				statistics.push(name);
			}
		}
		optionsArray['backend'] = options;

		//options for frontend(change url)
		var getParams = $filter.attr('data-get-attribute');

		optionsArray['frontend'] = [];
		optionsArray['frontend']['taxonomy'] = getParams;
		optionsArray['frontend']['settings'] = frontendOptions;
		optionsArray['selected'] = selectedOptions;
		optionsArray['stats'] = statistics;

		return optionsArray;
	});

	WpfFrontendPage.prototype.disableLeerOptions = (function () {
		var _thisObj = this.$obj;
		jQuery('.wpfMainWrapper').each(function () {
			var mainWrapper = jQuery(this),
				settings = _thisObj.getFilterMainSettings(mainWrapper);
			if(settings && settings.settings.filter_null_disabled === '1') {
				var filters = mainWrapper.find('.wpfFilterWrapper.wpfShowCount');
				if(filters.length) {
					filters.find('option[data-term-id]').prop('disabled', false);
					filters.find('option[data-term-id][data-count="0"]').prop('disabled', true);
					filters.find('.wpfCount').each(function(){
						var cntObj = jQuery(this),
							leer = cntObj.html() == '(0)',
							el = cntObj.closest('[data-term-id]'),
							input = false;
						if(el.length == 0) {
							el = cntObj.closest('[data-term-slug]');
						}
						if(el.length) {
							if(el.is('input')) {
								input = el;
								el = input.parent();
							} else {
								input = el.find('input');
							}
							input.prop('disabled', leer);
							if(leer) el.addClass('wpfOptionDisabled');
							else el.removeClass('wpfOptionDisabled');
						}
					});
				}
			}
		});
	});

	WpfFrontendPage.prototype.addSpecificPluginActions = (function() {
		// elementor plugin, action when widgets in admin panek are ready
		jQuery(window).on('load', function() {
			if ( window.elementorFrontend ) {
				if ( window.elementorFrontend.hooks ) {
					elementorFrontend.hooks.addAction( 'frontend/element_ready/widget', function( $scope ) {
						var wrapper = $scope.find('.wpfMainWrapper');

						hideFilterLoader(wrapper);
					});
				}
			} else if ( jQuery('.elementor .wpfMainWrapper').length ) {
				setTimeout(function() {
					jQuery('.elementor .wpfMainWrapper').each(function() {
						var wrapper = jQuery(this);
						hideFilterLoader(wrapper);
					});
				}, 2000);
			}
		});
	});

	WpfFrontendPage.prototype.fixSelector = (function(selector, defaultSelector) {
		if (typeof selector == 'undefined' || selector === '') {
			return typeof defaultSelector == 'undefined' ? '' : defaultSelector;
		}
		return (selector.search(/\.|#/) === -1) ? '.' + selector.replace(/(\s+)(\w+)/g, ' .$2')	: selector ;
	});

	WpfFrontendPage.prototype.markCheckboxSelected = (function ($filter, first) {
		if ($filter.length) {
			var settings = this.getFilterMainSettings($filter.closest('.wpfMainWrapper'));
			if(settings) {
				if (settings.settings.checked_items_bold == '1') {
					var wpfMainWrapper = $filter.closest('.wpfMainWrapper');
					wpfMainWrapper.find('.wpfDisplay').css('font-weight', '');
					wpfMainWrapper.find('.wpfAttrLabel').css('font-weight', '');
					// console.log(wpfMainWrapper.find('input:checked'))
					wpfMainWrapper.find('input:checked').each(function () {
						var wpfDisplay = jQuery(this).closest('.wpfLiLabel').find('.wpfDisplay'),
							wpfAttrLabel = jQuery(this).closest('.wpfColorsColBlock').find('.wpfAttrLabel');

						wpfDisplay.css('font-weight', 'bold');
						wpfAttrLabel.css('font-weight', 'bold');
					});
				}
			}
			if (first) {
				//need to delete automatic checked inputs by goback in browser Chrome/FF
				setTimeout(function () {
					$filter.find('input').each(function() {
						var input = this;
						if (input.type == "checkbox") {
							if (input.defaultChecked == true) {
								if (input.checked != true) input.checked = true;
							} else {
								if (input.checked == true) {
									input.checked = false;
									jQuery(input).closest('.wpfLiLabel').find('.wpfDisplay').removeClass('selected').css('font-weight', '');
								}
							}

						}
					});
				}, 100);
			}
		}
	});

	window.wpIinitialiseImmediately = typeof wpIinitialiseImmediately !== 'undefined' ? wpIinitialiseImmediately : 0;
	jQuery(document).ready(function () {
		if (!window.wpfFrontendPage) window.wpfFrontendPage = new WpfFrontendPage();
		if (typeof isElementorEditMode == 'undefined') {
			window.wpfFrontendPage.init();
		}
	});
	WpfFrontendPage.prototype.unserializeStr = function(serializedString){
		var str = decodeURI(serializedString);
		var pairs = str.split('&');
		var obj = {}, p, idx;
		for (var i=0, n=pairs.length; i < n; i++) {
			p = pairs[i].split('=');
			idx = p[0];
			if (obj[idx] === undefined) {
				obj[idx] = unescape(p[1]).replace ( /\+/g, ' ' );
			}else{
				if (typeof obj[idx] == "string") {
					obj[idx]=[obj[idx]];
				}
				obj[idx].push(unescape(p[1]).replace ( /\+/g, ' ' ));
			}
		}
		return obj;
	};

	WpfFrontendPage.prototype.getConvertedPrices = function (data, rate) {
		if (typeof rate !== 'undefined' && rate !== 1 ) {
			if (typeof data[0] !== 'undefined') {
				data[0] = String(Math.round(data[0] / rate));
				if (typeof data[1] !== 'undefined') {
					data[1] = String(Math.round(data[1] / rate));
				}
				if (typeof data[2] !== 'undefined') {
					data[2] = String(Math.round(data[2] / rate));
				}
			} else {
				if (data.wpf_min_price) {
					data.wpf_min_price = String(Math.round(data.wpf_min_price * rate));
				}
				if (data.wpf_max_price) {
					data.wpf_max_price = String(Math.round(data.wpf_max_price * rate));
				}
				if (data.tax) {
					data.tax = String(Math.round(data.tax * rate));
				}
			}
		}
		return data;
	};

	if (jQuery('.variations_form').length > 0 && typeof $(this).wc_variation_form == 'function') {
		document.addEventListener('wpfAjaxSuccess', function (event) {
			$('.variations_form').each(function () {
				$(this).wc_variation_form();
			});
		});
	}

	if (jQuery('.jetpack-lazy-image').length > 0) {
		document.addEventListener('wpfAjaxSuccess', function (event) {
			jQuery('.jetpack-lazy-image').each(function () {
				jQuery(this).removeAttr('srcset');
			});
		});
	}
	if (jQuery('.jetpack-lazy-image').length > 0) {
		document.addEventListener('wpfAjaxSuccess', function (event) {
			jQuery('.jetpack-lazy-image').each(function () {
				jQuery(this).removeAttr('srcset');
			});
		});
	}

	// added for ElementorPro Loop Load More
	if (jQuery('div.elementor-widget[data-widget_type="loop-grid.product"]').length > 0) {
		document.addEventListener('wpfAjaxSuccess', function (event) {
			if (window.elementorFrontend && window.elementorFrontend.elementsHandler) {
				var $products = jQuery('div.elementor-widget[data-widget_type="loop-grid.product"]');
				if ($products.length == 1 && $products.find('.e-load-more-anchor').length == 1) {
					$products.removeClass('e-load-more-pagination-end');
					window.elementorFrontend.elementsHandler.runReadyTrigger($products);
				}
			}
		});
	}

	// added for plugin: WooCommerce Load More Products
	jQuery(document).ready(function () {
		if (jQuery('a.lmp_button').length > 0) {
			document.addEventListener('wpfAjaxSuccess', function (event) {
				if (!window.wpfDoNotLoadMore && typeof load_next_page == 'function') {
					load_next_page(true, decodeURIComponent(location.href));
				}
			});
		}
	});

	// plugin event woocommerce-product-search
	// https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-extensions/woocommerce-product-search/
	jQuery(document).on('ixProductFilterRequestProcessed', function (event) {
		window.wpfFrontendPage.filtering();
	});
	if (window.wpIinitialiseImmediately) {
		window.wpfFrontendPage = new WpfFrontendPage();
	}
}(window.jQuery, window));

var objQueryString={};

toggleClear();

// try to get jquery selector from random html string
function wpfGetSelector(html, controlExist, defSelector, countChilds, removeDynamicClasses, context) {
	if(html.length == 0) return defSelector;

	var elem     = (typeof context !== 'undefined') ? jQuery(html, context) : jQuery(html),
		selector = '',
		i = 0;

	if (typeof countChilds == 'undefined') {
		countChilds = 1;
	}

	while (i < countChilds && elem && elem.length) {
		if (i > 0) {
			selector += ' ';
		}

		i++;

		if (elem.length > 1) {
			elem = elem.last();
		}

		var elemId = elem.attr('id');
		if (typeof elemId != 'undefined') {
			selector += '#' + elemId;
		} else {
			var elemClass = elem.attr('class');

			// try to remove some dinamically changed classes that contains a number in it name
			if (removeDynamicClasses) {
				classList = elemClass.split(' ');
				classList.forEach( function( className, key ) {
					var hasNumber = /\d/.test(className);
					if ( hasNumber ) {
						classList.splice(key, 1);
					}
				});
				elemClass = classList.join(' ');
			}

			if ( typeof elemClass != 'undefined' && elemClass != '' ) {
				if (elemClass == 'container' && countChilds == 1) countChilds = 2;
				selector += elem.get(0).tagName + '.' + elemClass.trim().replace(/ +/g, '.');
			}
		}

		if (controlExist && selector != '' && jQuery(selector).length == 0) {
			selector = '';
			break;
		}

		var elem = elem.children();
	}

	return selector.length == 0 ? defSelector : selector;
}


function getUrlParams () {
	var params={};
	window.location.search
	  .replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) {
		params[key] = value;
	  }
	);
	return params;
}

function toggleClear() {
	var params = getUrlParams();
	jQuery(".wpfBlockClear").hide();
	jQuery(".wpfFilterWrapper").each(function(){
		var attr = jQuery(this).attr('data-get-attribute');
		if (attr in params) {
			jQuery(this).find(".wpfBlockClear").show();
		}
	});
	if ('wpf_min_price' in params || 'wpf_max_price' in params) {
		jQuery("[data-filter-type='wpfPrice']").find(".wpfBlockClear").show();
		jQuery("[data-filter-type='wpfPriceRange']").find(".wpfBlockClear").show();
	}
}

//Get querystring value
function getParameterByName(name, searchUrl) {
	name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
	var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
		results = regex.exec(searchUrl);
	return results === null ? "" : decodeURIComponent(results[1]);//decodeURIComponent(results[1].replace(/\+/g, " "));
}
function getCurrentUrlPartsWpf() {
	var parts = window.wpfNewUrl.split('?'),
		s = (parts[1] || '');
	return {href: window.wpfNewUrl, path: parts[0].replace(/#.*$/, ''), search: (s.length ? '?' + s : '')};
}

//Add or modify querystring
function changeUrl(filterSlug, filterValue, $wooPage, $filterWrapper) {
	removePageQString();
	//Get query string filterValue
	$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);

	var curUrl = getCurrentUrlPartsWpf();
	if(!$wooPage){
		var searchUrl = decodeURIComponent(curUrl.search);
	}else{
		if($filterWrapper.attr('data-hide-url')){
			var searchUrl=$filterWrapper.attr('data-hide-url');
		} else {
			var searchUrl = '';
		}
	}

	// New: Check if slug format enabled
	var wrapper = $filterWrapper.closest('.wpfMainWrapper');

	var urlValue;
	if (searchUrl.indexOf("redirect")!==-1) {
		searchUrl = '';
	}

	if(searchUrl.indexOf("?")== "-1") {
		var urlValue = curUrl.path + '?'+filterSlug+'='+filterValue;
	} else {
		//Check for filterSlug in query string, if not present
		if(searchUrl.indexOf('&'+filterSlug+'=')== "-1" && searchUrl.indexOf('?'+filterSlug+'=')== "-1") {
			var urlValue=searchUrl+'&'+filterSlug+'='+filterValue;
		//If filterSlug present in query string
		} else {
			var oldValue = getParameterByName(filterSlug, searchUrl);
			if(searchUrl.indexOf("?"+filterSlug+"=")!= "-1") {
				var urlValue = searchUrl.replace('?'+filterSlug+'='+oldValue,'?'+filterSlug+'='+filterValue);
			// add existing in url filter with another option
			} else {
				var urlValue = searchUrl.replace('&'+filterSlug+'='+oldValue,'&'+filterSlug+'='+filterValue);
			}
		}
		urlValue = curUrl.path + urlValue;

		//history.pushState function is used to add history state.
		//It takes three parameters: a state object, a title (which is currently ignored), and (optionally) a URL.
	}

	if(!$wooPage){
		window.wpfNewUrl = encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue;
	}
	objQueryString.key=filterValue;
	return urlValue;
}


function removePageQString() {
	var curUrl = getCurrentUrlPartsWpf(),
		path = curUrl.path,
		page = path.indexOf('/page/');
	if(page != -1 && history.pushState) {
		window.wpfNewUrl = path.substr(0, page + 1) + curUrl.search;
	} else {
		window.wpfNewUrl = curUrl.path + removePagenum(curUrl.search);
	}
}

function removePagenum(url) {
	return url.replace(/([&?])pagenum=\d+(&|$)/g, function(match, prefix, suffix) {
		return prefix === '?' && suffix === '&' ? '?' :
			   prefix === '&' && suffix === '' ? '' :
			   prefix;
	});
}

/**
 * Removes querystring.
 *
 * @version 3.1.2
 */
function removeQString(key, $wooPage, $filterWrapper) {
	removePageQString();
	//Get query string value
	var curUrl = getCurrentUrlPartsWpf(),
		urlValue=decodeURI(curUrl.href);
	$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);
	if(!$wooPage){
		var searchUrl=decodeURIComponent(curUrl.search);
	}else{
		if($filterWrapper.attr('data-hide-url')){
			var searchUrl=decodeURI($filterWrapper.attr('data-hide-url'));
		}else {
			var searchUrl = '';
		}
		var urlValue=curUrl.href + searchUrl;
	}
	if(key!="") {
		const oldValue = getParameterByName(key, searchUrl);
		const newUrlValue = new URL(urlValue);
		newUrlValue.searchParams.delete(key, oldValue);
		urlValue = newUrlValue.toString().replace(/\+/g, '%20');
		if($wooPage){
			urlValue = urlValue.replace(curUrl.href,'');
		}
	} else {
		if(!$wooPage){
			var searchUrl=decodeURIComponent(curUrl.search);
			urlValue=urlValue.replace(searchUrl,'');
		}else{
			var searchUrl=$filterWrapper.attr('data-hide-url');
			urlValue=urlValue.replace(searchUrl,'');
			urlValue = urlValue.replace(curUrl.href,'');
		}
	}
	if(!$wooPage){
		window.wpfNewUrl = encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue;
	}
	return urlValue.indexOf('%25') !== -1 ? decodeURI(urlValue) : urlValue;
}
function checkArray(my_arr){
	for(var i=0;i<my_arr.length;i++){
		if(my_arr[i] === "")
			return false;
	}
	return true;
}
jQuery.toQueryParams = function(str, separator) {
	separator = separator || '&';
	var obj = {};
	if (str.length == 0)
		return obj
	var c = str.substr(0,1),
		s = c=='?' || c=='#'  ? str.substr(1) : str,
		a = s.split(separator);
	for (var i=0; i<a.length; i++) {
		var p = a[i].indexOf('=');
		if (p < 0) {
			obj[a[i]] = '';
			continue
		}
		var k = decodeURIComponent(a[i].substr(0,p)),
			v = decodeURIComponent(a[i].substr(p+1)),
			bps = k.indexOf('[');
		if (bps < 0) {
			obj[k] = v
			continue;
		}

		var bpe = k.substr(bps+1).indexOf(']');
		if (bpe < 0) {
			obj[k] = v
			continue;
		}

		var bpv = k.substr(bps+1, bps+bpe-1),
			k = k.substr(0,bps);
		if (bpv.length <= 0) {
			if (typeof(obj[k]) != 'object') obj[k] = [];
			obj[k].push(v);
		} else {
			if (typeof(obj[k]) != 'object') obj[k] = {};
			obj[k][bpv] = v;
		}
	}
	return obj;
}
function wpfChangeFiltersCount (wpfExistTerms, synchroFilterId) {

	var wpfPage = window.wpfFrontendPage,
		curFilter = wpfPage.isSynchro ? (typeof(synchroFilterId) != 'undefined' && synchroFilterId.length ? '#'+synchroFilterId : '#'+wpfPage.currentLoadId) : 'body';

	jQuery(curFilter).find(".wpfShowCount").find(".wpfCount").html("(0)");
	jQuery(curFilter).find(".wpfShowCount select:not([multiple]) option[data-count]").each(function(){
		var attr = jQuery(this).attr("data-term-name");
		jQuery(this).attr('data-count', 0).html(attr+" (0)");
	});
	jQuery(curFilter).find(".wpfShowCount select[multiple]").find("option").each(function(){
		attr = jQuery(this).attr("data-term-name");
		jQuery(this).attr('data-count', 0).html(attr+" (0)");
	});

	jQuery(curFilter).find(".wpfShowCount").each(function(filterCounter){

		var filter = jQuery(this);
		if (filter.attr("data-filter-type").length > 0) {
			var taxonomy = filter.data('taxonomy');
			if(typeof taxonomy == 'undefined' || taxonomy.length == 0) taxonomy = filter.data('slug');

			if (taxonomy in wpfExistTerms) {

				if (typeof (wpfExistTerms[taxonomy].relation) !== 'undefined') {
					var htmlArray = {};
					jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] li').each(function () {
						htmlArray[jQuery(this).data('term-id')] = jQuery('.wpfFilterTaxNameWrapper', this).html();
					});

					jQuery.each(wpfExistTerms[taxonomy].relation, function (index, value) {
						jQuery.each(htmlArray, function (i, v) {
							if (v === value && i !== index) {
								wpfExistTerms[taxonomy][i] = wpfExistTerms[taxonomy][index];
								delete wpfExistTerms[taxonomy][index];
							}
						});
					});
				}

				jQuery.each(wpfExistTerms[taxonomy], function (index, value) {
					changeCount(taxonomy, index, value, curFilter);
				});

				delete wpfExistTerms[taxonomy];
			}

		}
	});

	window.wpfFrontendPage.disableLeerOptions();
	var multi = jQuery('.wpfShowCount').find('select[multiple]');
	if (multi.length) multi.multiselect('reload');
};

function changeCount(taxonomy, index, value, curFilter) {

	var oIndex = index;
	index = index.toLowerCase();
	var els = jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] [data-term-id="' + oIndex + '"]');
	if (els.length === 0) {
		els = jQuery(curFilter).find('div.wpfShowCount[data-slug="' + taxonomy + '"] [data-term-id="' + oIndex + '"]');
	}
	if (els.length === 0) {
		els = jQuery(curFilter).find('div.wpfShowCount[data-taxonomy="' + taxonomy + '"] [data-term-id="' + index + '"]');
	}
	if (els.length === 0) {
		els = jQuery(curFilter).find('div.wpfShowCount[data-slug="' + taxonomy + '"] [data-term-id="' + index + '"]');
	}
	if (els.length > 0) {
		els.each(function () {
			var el = jQuery(this);
			if (el.find('.wpfCount').length > 0) {
				el.find('.wpfCount:first').html('(' + value + ')');
			} else if (el.parent().attr('class') == 'wpfColorsColBlock') {
				el.parent().find('.wpfCount').html('(' + value + ')');
			} else {
				var attrname = el.attr('data-term-name');
				var tooltipstered = el.siblings('.tooltipstered');
				if (tooltipstered.length) {
					attrname = tooltipstered.attr('data-term-name');
					tooltipstered.tooltipster('content', '' + attrname + ' (' + value + ')');
					if (tooltipstered.attr('data-show-count')) tooltipstered.text(value);
				} else if (attrname !== undefined) {
					el.html('' + attrname + ' (' + value + ')');
				} else {
					el.html('' + index + ' (' + value + ')');
				}
			}
			if (el.is('option')) {
				el.attr('data-count', value);
			}
		});
	}
}

// show/hide individual filter items
function wpfShowHideFiltersAtts(wpfExistTerms, wpfExistUsers, synchroFilterId) {

	var wpfPage = window.wpfFrontendPage,
		curFilter = typeof(synchroFilterId) != 'undefined' && synchroFilterId.length ? synchroFilterId : wpfPage.currentLoadId;

	wpfPage.restoreSelectsForSafari();

	jQuery((curFilter ? '#' + curFilter + ' ' : '') + '.wpfFilterWrapper').each(function(){
		var filter = jQuery(this),
			filterType = filter.data('filter-type'),
			isTextFilter = filter.attr('data-display-type') == 'text',
			filterContentType = isTextFilter && filter.attr('data-control-products') == '1' ? 'taxonomy' : filter.data('content-type'),
			taxonomy = filter.data('taxonomy'),
			getAttr = filter.data('get-attribute'),
			isFilterCurentlyActivated = getParameterByName(getAttr, location.search),
			isHideActive = filter.data('hide-active'),
			isShowAll = Boolean(filter.data('show-all')),
			isNotInLogic = getAttr.indexOf('pr_filter') == -1 ? false : true,
			userExistIds = [];

		switch (filterContentType) {
			case 'user':
				jQuery.each(wpfExistUsers, function (index, value) {
					userExistIds.push(parseInt(value.ID));
				});
				if (!isFilterCurentlyActivated && userExistIds.length > 0) {
					filter.find('[data-term-id]').each(function () {
						var el = jQuery(this),
							userId = el.data('term-id');
						if (userExistIds.indexOf(userId) >= 0) {
							el.show();
						} else {
							el.hide();
						}
					});
				}
				break;
			case 'taxonomy':
				if (typeof taxonomy == 'undefined' || taxonomy.length == 0) {
					taxonomy = filter.data('slug');
				}

				if ((!isFilterCurentlyActivated || isHideActive) && !isNotInLogic && !isShowAll ) {
					if (taxonomy in wpfExistTerms || isFilterCurentlyActivated) {
						var termIds = wpfExistTerms[taxonomy] || {};
						filter.find('[data-term-id]').each(function () {
							var elem = jQuery(this),
								id = elem.data('term-id'),
								selected = isFilterCurentlyActivated && (elem.is('input:checked') || elem.find('input:checked').length || elem.is('option:selected'));
							if (id in termIds || selected) {
								if(elem.closest('.wpfButtonsFilter').length) elem.css('display', 'inline-block');
								else elem.show();
								if (elem.parent().hasClass('wpfColorsColBlock')) {
									elem.parent().parent().show();
								}
								if (elem.closest('.wpfColorsRow').length) {
									elem.parent().css('display', 'inline-block');
								}
							} else {
								elem.hide();
								elem.find('input').prop('checked', false);
								if (elem.parent().hasClass('wpfColorsColBlock')) {
									elem.parent().parent().hide();
								}
								if (elem.closest('.wpfColorsRow').length) {
									elem.parent().hide();
								}
							}
						});

						if (filter.attr('data-display-type') == 'slider' ) {
							if (typeof(wpfPage.updateAttrSlider) == 'function') {
								wpfPage.updateAttrSlider(filter, termIds);
							}
						} else {
							// all terms display block already has css display none
							var hideSingle = filter.attr('data-hide-single') == '1',
								preSelector = hideSingle && filter.find('select[multiple]').length ? 'option' : '',
								selector = hideSingle && filter.find('.wpfColorsFilter').length ? 'li[data-term-slug]' : '[data-term-id]',
								cntAll = isTextFilter ? 1 : filter.find(preSelector+selector).length,
								cntHidden = filter.find(preSelector+selector+'[style*="none"]').length,
								limit = hideSingle ? 1 : 0;
							if (cntAll-cntHidden <= limit) {
								filter.hide();
							} else {
								filter.show();
							}
						}
					} else {
						filter.find('input').prop('checked', false);
						filter.find('select').val('');
						filter.hide();
					}
				}
				var multi = filter.find('select[multiple]');
				if (multi.length) multi.multiselect('reload');

				if(typeof(window.wpfFrontendPage.wpfShowHideFiltersAttsPro) == 'function') {
					window.wpfFrontendPage.wpfShowHideFiltersAttsPro(filter);
				}
				break;
			default:
				// console.log(`Sorry, we are out of ${expr}.`);
		}
	});
	wpfPage.removeHiddenOptionsForSafari();
}

function wpfChangePriceFiltersCount(prices) {
	var _thisObj = window.wpfFrontendPage,
		noWooPage = _thisObj.noWoo,
		filterWrapper = jQuery('.wpfMainWrapper'),
		priceFilters = jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"].wpfNotActive');

	jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
		var wpfPrice = jQuery(this);
		wpfPrice.attr('data-minvalue', prices.wpf_min_price).attr('data-maxvalue', prices.wpf_max_price);

		wpfPrice.find('#wpfMinPrice').attr('min', prices.wpf_min_price).val(prices.wpf_min_price);
		wpfPrice.find('#wpfMaxPrice').attr('max', prices.wpf_max_price).val(prices.wpf_max_price);

		if (wpfPrice.find(".ion-range-slider").length) {
			wpfPrice.find(".ion-range-slider").each(function () {
				jQuery(this).attr('data-min', prices.wpf_min_price).attr('data-max', prices.wpf_max_price);
				var ionSlider = jQuery(this).data("ionRangeSlider");
				ionSlider.update({
					min: prices.wpf_min_price,
					max: prices.wpf_max_price,
				});
			});
		}
	});
	window.wpfFrontendPage.eventsPriceFilter();
	_thisObj.getUrlParamsChangeFiltersValues();
	/*if (typeof(window.wpfFrontendPage.eventsFrontendPro) == 'function') {
		window.wpfFrontendPage.eventsFrontendPro();
	}*/
}

function hideFilterLoader( wrapper ) {
	wrapper.find('.wpfLoaderLayout').hide();
	wrapper.css({
		position: ''
	});
	wrapper.find('.wpfFilterWrapper').css({
		visibility: 'inherit'
	});
}

function heightIdenticalInRow(selector) {
	var setMaxHeight = function (elements) {
		if (elements.length > 1) {
			var elementHeightMax = elements[0].height;
			for (var j = 1; j < elements.length; j++) {
				if (elements[j].height > elementHeightMax) {
					elementHeightMax = elements[j].height;
				}
			}
			for (var j = 0; j < elements.length; j++) {
				jQuery(elements[j].selector).height(elementHeightMax);
			}
		}
	};
	var elementsHeight = [];
	var rowIndex = 0;
	var elementIndex = 0;

	jQuery(selector).each(function (index, element) {
		if (!elementsHeight[rowIndex]) {
			elementsHeight[rowIndex] = [];
		}
		if (
			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1]
			&&
			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top
			&&
			elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top !== jQuery(element).offset().top
		) {

			setMaxHeight(elementsHeight[rowIndex]);
			rowIndex++;
		}
		if (!elementsHeight[rowIndex]) {
			elementsHeight[rowIndex] = [];
		}
		elementsHeight[rowIndex].push({
			selector: selector + ':eq(' + elementIndex + ')',
			height: jQuery(element).height(),
			top: jQuery(element).offset().top
		});
		elementIndex++;
	});
	if (elementsHeight[rowIndex]) {
		setMaxHeight(elementsHeight[rowIndex]);
	}
}
function wpfDoActionsAfterLoad (fid, isFound, requestData) {
	if (typeof (window.wpfFrontendPage.saveStatistics) == 'function') {
		window.wpfFrontendPage.saveStatistics(fid, isFound, requestData);
	}
}
if (window.wpIinitialiseImmediately && window.wpfFrontendPage) {
	if (typeof isElementorEditMode == 'undefined') window.wpfFrontendPage.init();
};
// source --> https://abatec.com.mx/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js?ver=2.7.0-wc.10.7.0 
/*!
 * jQuery blockUI plugin
 * Version 2.70.0-2014.11.23
 * Requires jQuery v1.7 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2013 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */
!function(){"use strict";function e(e){e.fn._fadeIn=e.fn.fadeIn;var t=e.noop||function(){},o=/MSIE/.test(navigator.userAgent),n=/MSIE 6.0/.test(navigator.userAgent)&&!/MSIE 8.0/.test(navigator.userAgent),i=(document.documentMode,"function"==typeof document.createElement("div").style.setExpression&&document.createElement("div").style.setExpression);e.blockUI=function(e){d(window,e)},e.unblockUI=function(e){a(window,e)},e.growlUI=function(t,o,n,i){var s=e('<div class="growlUI"></div>');t&&s.append("<h1>"+t+"</h1>"),o&&s.append("<h2>"+o+"</h2>"),n===undefined&&(n=3e3);var l=function(t){t=t||{},e.blockUI({message:s,fadeIn:"undefined"!=typeof t.fadeIn?t.fadeIn:700,fadeOut:"undefined"!=typeof t.fadeOut?t.fadeOut:1e3,timeout:"undefined"!=typeof t.timeout?t.timeout:n,centerY:!1,showOverlay:!1,onUnblock:i,css:e.blockUI.defaults.growlCSS})};l();s.css("opacity");s.on("mouseover",function(){l({fadeIn:0,timeout:3e4});var t=e(".blockMsg");t.stop(),t.fadeTo(300,1)}).on("mouseout",function(){e(".blockMsg").fadeOut(1e3)})},e.fn.block=function(t){if(this[0]===window)return e.blockUI(t),this;var o=e.extend({},e.blockUI.defaults,t||{});return this.each(function(){var t=e(this);o.ignoreIfBlocked&&t.data("blockUI.isBlocked")||t.unblock({fadeOut:0})}),this.each(function(){"static"==e.css(this,"position")&&(this.style.position="relative",e(this).data("blockUI.static",!0)),this.style.zoom=1,d(this,t)})},e.fn.unblock=function(t){return this[0]===window?(e.unblockUI(t),this):this.each(function(){a(this,t)})},e.blockUI.version=2.7,e.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:!0,theme:!1,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:.6,cursor:"wait"},cursorReset:"default",growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:!1,baseZ:1e3,centerX:!0,centerY:!0,allowBodyStretch:!0,bindEvents:!0,constrainTabKey:!0,fadeIn:200,fadeOut:400,timeout:0,showOverlay:!0,focusInput:!0,focusableElements:":input:enabled:visible",onBlock:null,onUnblock:null,onOverlayClick:null,quirksmodeOffsetHack:4,blockMsgClass:"blockMsg",ignoreIfBlocked:!1};var s=null,l=[];function d(d,c){var u,b,h=d==window,k=c&&c.message!==undefined?c.message:undefined;if(!(c=e.extend({},e.blockUI.defaults,c||{})).ignoreIfBlocked||!e(d).data("blockUI.isBlocked")){if(c.overlayCSS=e.extend({},e.blockUI.defaults.overlayCSS,c.overlayCSS||{}),u=e.extend({},e.blockUI.defaults.css,c.css||{}),c.onOverlayClick&&(c.overlayCSS.cursor="pointer"),b=e.extend({},e.blockUI.defaults.themedCSS,c.themedCSS||{}),k=k===undefined?c.message:k,h&&s&&a(window,{fadeOut:0}),k&&"string"!=typeof k&&(k.parentNode||k.jquery)){var y=k.jquery?k[0]:k,m={};e(d).data("blockUI.history",m),m.el=y,m.parent=y.parentNode,m.display=y.style.display,m.position=y.style.position,m.parent&&m.parent.removeChild(y)}e(d).data("blockUI.onUnblock",c.onUnblock);var g,v,I,w,U=c.baseZ;g=o||c.forceIframe?e('<iframe class="blockUI" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+c.iframeSrc+'"></iframe>'):e('<div class="blockUI" style="display:none"></div>'),v=c.theme?e('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+U+++';display:none"></div>'):e('<div class="blockUI blockOverlay" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'),c.theme&&h?(w='<div class="blockUI '+c.blockMsgClass+' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:fixed">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):c.theme?(w='<div class="blockUI '+c.blockMsgClass+' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:absolute">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):w=h?'<div class="blockUI '+c.blockMsgClass+' blockPage" style="z-index:'+(U+10)+';display:none;position:fixed"></div>':'<div class="blockUI '+c.blockMsgClass+' blockElement" style="z-index:'+(U+10)+';display:none;position:absolute"></div>',I=e(w),k&&(c.theme?(I.css(b),I.addClass("ui-widget-content")):I.css(u)),c.theme||v.css(c.overlayCSS),v.css("position",h?"fixed":"absolute"),(o||c.forceIframe)&&g.css("opacity",0);var x=[g,v,I],C=e(h?"body":d);e.each(x,function(){this.appendTo(C)}),c.theme&&c.draggable&&e.fn.draggable&&I.draggable({handle:".ui-dialog-titlebar",cancel:"li"});var S=i&&(!e.support.boxModel||e("object,embed",h?null:d).length>0);if(n||S){if(h&&c.allowBodyStretch&&e.support.boxModel&&e("html,body").css("height","100%"),(n||!e.support.boxModel)&&!h)var E=p(d,"borderTopWidth"),O=p(d,"borderLeftWidth"),T=E?"(0 - "+E+")":0,M=O?"(0 - "+O+")":0;e.each(x,function(e,t){var o=t[0].style;if(o.position="absolute",e<2)h?o.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:"+c.quirksmodeOffsetHack+') + "px"'):o.setExpression("height",'this.parentNode.offsetHeight + "px"'),h?o.setExpression("width",'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):o.setExpression("width",'this.parentNode.offsetWidth + "px"'),M&&o.setExpression("left",M),T&&o.setExpression("top",T);else if(c.centerY)h&&o.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'),o.marginTop=0;else if(!c.centerY&&h){var n="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+(c.css&&c.css.top?parseInt(c.css.top,10):0)+') + "px"';o.setExpression("top",n)}})}if(k&&(c.theme?I.find(".ui-widget-content").append(k):I.append(k),(k.jquery||k.nodeType)&&e(k).show()),(o||c.forceIframe)&&c.showOverlay&&g.show(),c.fadeIn){var B=c.onBlock?c.onBlock:t,j=c.showOverlay&&!k?B:t,H=k?B:t;c.showOverlay&&v._fadeIn(c.fadeIn,j),k&&I._fadeIn(c.fadeIn,H)}else c.showOverlay&&v.show(),k&&I.show(),c.onBlock&&c.onBlock.bind(I)();if(r(1,d,c),h?(s=I[0],l=e(c.focusableElements,s),c.focusInput&&setTimeout(f,20)):function(e,t,o){var n=e.parentNode,i=e.style,s=(n.offsetWidth-e.offsetWidth)/2-p(n,"borderLeftWidth"),l=(n.offsetHeight-e.offsetHeight)/2-p(n,"borderTopWidth");t&&(i.left=s>0?s+"px":"0");o&&(i.top=l>0?l+"px":"0")}(I[0],c.centerX,c.centerY),c.timeout){var z=setTimeout(function(){h?e.unblockUI(c):e(d).unblock(c)},c.timeout);e(d).data("blockUI.timeout",z)}}}function a(t,o){var n,i,d=t==window,a=e(t),u=a.data("blockUI.history"),f=a.data("blockUI.timeout");f&&(clearTimeout(f),a.removeData("blockUI.timeout")),o=e.extend({},e.blockUI.defaults,o||{}),r(0,t,o),null===o.onUnblock&&(o.onUnblock=a.data("blockUI.onUnblock"),a.removeData("blockUI.onUnblock")),i=d?e(document.body).children().filter(".blockUI").add("body > .blockUI"):a.find(">.blockUI"),o.cursorReset&&(i.length>1&&(i[1].style.cursor=o.cursorReset),i.length>2&&(i[2].style.cursor=o.cursorReset)),d&&(s=l=null),o.fadeOut?(n=i.length,i.stop().fadeOut(o.fadeOut,function(){0==--n&&c(i,u,o,t)})):c(i,u,o,t)}function c(t,o,n,i){var s=e(i);if(!s.data("blockUI.isBlocked")){t.each(function(e,t){this.parentNode&&this.parentNode.removeChild(this)}),o&&o.el&&(o.el.style.display=o.display,o.el.style.position=o.position,o.el.style.cursor="default",o.parent&&o.parent.appendChild(o.el),s.removeData("blockUI.history")),s.data("blockUI.static")&&s.css("position","static"),"function"==typeof n.onUnblock&&n.onUnblock(i,n);var l=e(document.body),d=l.width(),a=l[0].style.width;l.width(d-1).width(d),l[0].style.width=a}}function r(t,o,n){var i=o==window,l=e(o);if((t||(!i||s)&&(i||l.data("blockUI.isBlocked")))&&(l.data("blockUI.isBlocked",t),i&&n.bindEvents&&(!t||n.showOverlay))){var d="mousedown mouseup keydown keypress keyup touchstart touchend touchmove";t?e(document).on(d,n,u):e(document).off(d,u)}}function u(t){if("keydown"===t.type&&t.keyCode&&9==t.keyCode&&s&&t.data.constrainTabKey){var o=l,n=!t.shiftKey&&t.target===o[o.length-1],i=t.shiftKey&&t.target===o[0];if(n||i)return setTimeout(function(){f(i)},10),!1}var d=t.data,a=e(t.target);return a.hasClass("blockOverlay")&&d.onOverlayClick&&d.onOverlayClick(t),a.parents("div."+d.blockMsgClass).length>0||0===a.parents().children().filter("div.blockUI").length}function f(e){if(l){var t=l[!0===e?l.length-1:0];t&&t.trigger("focus")}}function p(t,o){return parseInt(e.css(t,o),10)||0}}"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],e):e(jQuery)}();
// source --> https://abatec.com.mx/wp-content/plugins/woocommerce/assets/js/js-cookie/js.cookie.min.js?ver=2.1.4-wc.10.7.0 
/*! js-cookie v3.0.5 | MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(f){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})});
// source --> https://abatec.com.mx/wp-content/plugins/wp-fancybox/dist/fancybox/fancybox.js?ver=1.0.4 
! function(t, e) {
    "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = "undefined" != typeof globalThis ? globalThis : t || self).window = t.window || {})
}(this, (function(t) {
    "use strict";
    const e = (t, e = 1e4) => (t = parseFloat(t + "") || 0, Math.round((t + Number.EPSILON) * e) / e),
        i = function(t) {
            if (!(t && t instanceof Element && t.offsetParent)) return !1;
            const e = t.scrollHeight > t.clientHeight,
                i = window.getComputedStyle(t).overflowY,
                n = -1 !== i.indexOf("hidden"),
                s = -1 !== i.indexOf("visible");
            return e && !n && !s
        },
        n = function(t, e = void 0) {
            return !(!t || t === document.body || e && t === e) && (i(t) ? t : n(t.parentElement, e))
        },
        s = function(t) {
            var e = (new DOMParser).parseFromString(t, "text/html").body;
            if (e.childElementCount > 1) {
                for (var i = document.createElement("div"); e.firstChild;) i.appendChild(e.firstChild);
                return i
            }
            return e.firstChild
        },
        o = t => `${t||""}`.split(" ").filter((t => !!t)),
        a = (t, e, i) => {
            t && o(e).forEach((e => {
                t.classList.toggle(e, i || !1)
            }))
        };
    class r {
        constructor(t) {
            Object.defineProperty(this, "pageX", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "pageY", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "clientX", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "clientY", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "id", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "time", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "nativePointer", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), this.nativePointer = t, this.pageX = t.pageX, this.pageY = t.pageY, this.clientX = t.clientX, this.clientY = t.clientY, this.id = self.Touch && t instanceof Touch ? t.identifier : -1, this.time = Date.now()
        }
    }
    const l = {
        passive: !1
    };
    class c {
        constructor(t, {
            start: e = (() => !0),
            move: i = (() => {}),
            end: n = (() => {})
        }) {
            Object.defineProperty(this, "element", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "startCallback", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "moveCallback", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "endCallback", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "currentPointers", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: []
            }), Object.defineProperty(this, "startPointers", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: []
            }), this.element = t, this.startCallback = e, this.moveCallback = i, this.endCallback = n;
            for (const t of ["onPointerStart", "onTouchStart", "onMove", "onTouchEnd", "onPointerEnd", "onWindowBlur"]) this[t] = this[t].bind(this);
            this.element.addEventListener("mousedown", this.onPointerStart, l), this.element.addEventListener("touchstart", this.onTouchStart, l), this.element.addEventListener("touchmove", this.onMove, l), this.element.addEventListener("touchend", this.onTouchEnd), this.element.addEventListener("touchcancel", this.onTouchEnd)
        }
        onPointerStart(t) {
            if (!t.buttons || 0 !== t.button) return;
            const e = new r(t);
            this.currentPointers.some((t => t.id === e.id)) || this.triggerPointerStart(e, t) && (window.addEventListener("mousemove", this.onMove), window.addEventListener("mouseup", this.onPointerEnd), window.addEventListener("blur", this.onWindowBlur))
        }
        onTouchStart(t) {
            for (const e of Array.from(t.changedTouches || [])) this.triggerPointerStart(new r(e), t);
            window.addEventListener("blur", this.onWindowBlur)
        }
        onMove(t) {
            const e = this.currentPointers.slice(),
                i = "changedTouches" in t ? Array.from(t.changedTouches || []).map((t => new r(t))) : [new r(t)],
                n = [];
            for (const t of i) {
                const e = this.currentPointers.findIndex((e => e.id === t.id));
                e < 0 || (n.push(t), this.currentPointers[e] = t)
            }
            n.length && this.moveCallback(t, this.currentPointers.slice(), e)
        }
        onPointerEnd(t) {
            t.buttons > 0 && 0 !== t.button || (this.triggerPointerEnd(t, new r(t)), window.removeEventListener("mousemove", this.onMove), window.removeEventListener("mouseup", this.onPointerEnd), window.removeEventListener("blur", this.onWindowBlur))
        }
        onTouchEnd(t) {
            for (const e of Array.from(t.changedTouches || [])) this.triggerPointerEnd(t, new r(e))
        }
        triggerPointerStart(t, e) {
            return !!this.startCallback(e, t, this.currentPointers.slice()) && (this.currentPointers.push(t), this.startPointers.push(t), !0)
        }
        triggerPointerEnd(t, e) {
            const i = this.currentPointers.findIndex((t => t.id === e.id));
            i < 0 || (this.currentPointers.splice(i, 1), this.startPointers.splice(i, 1), this.endCallback(t, e, this.currentPointers.slice()))
        }
        onWindowBlur() {
            this.clear()
        }
        clear() {
            for (; this.currentPointers.length;) {
                const t = this.currentPointers[this.currentPointers.length - 1];
                this.currentPointers.splice(this.currentPointers.length - 1, 1), this.startPointers.splice(this.currentPointers.length - 1, 1), this.endCallback(new Event("touchend", {
                    bubbles: !0,
                    cancelable: !0,
                    clientX: t.clientX,
                    clientY: t.clientY
                }), t, this.currentPointers.slice())
            }
        }
        stop() {
            this.element.removeEventListener("mousedown", this.onPointerStart, l), this.element.removeEventListener("touchstart", this.onTouchStart, l), this.element.removeEventListener("touchmove", this.onMove, l), this.element.removeEventListener("touchend", this.onTouchEnd), this.element.removeEventListener("touchcancel", this.onTouchEnd), window.removeEventListener("mousemove", this.onMove), window.removeEventListener("mouseup", this.onPointerEnd), window.removeEventListener("blur", this.onWindowBlur)
        }
    }

    function h(t, e) {
        return e ? Math.sqrt(Math.pow(e.clientX - t.clientX, 2) + Math.pow(e.clientY - t.clientY, 2)) : 0
    }

    function d(t, e) {
        return e ? {
            clientX: (t.clientX + e.clientX) / 2,
            clientY: (t.clientY + e.clientY) / 2
        } : t
    }
    const u = t => "object" == typeof t && null !== t && t.constructor === Object && "[object Object]" === Object.prototype.toString.call(t),
        p = (t, ...e) => {
            const i = e.length;
            for (let n = 0; n < i; n++) {
                const i = e[n] || {};
                Object.entries(i).forEach((([e, i]) => {
                    const n = Array.isArray(i) ? [] : {};
                    t[e] || Object.assign(t, {
                        [e]: n
                    }), u(i) ? Object.assign(t[e], p(n, i)) : Array.isArray(i) ? Object.assign(t, {
                        [e]: [...i]
                    }) : Object.assign(t, {
                        [e]: i
                    })
                }))
            }
            return t
        },
        f = function(t, e) {
            return t.split(".").reduce(((t, e) => "object" == typeof t ? t[e] : void 0), e)
        };
    class g {
        constructor(t = {}) {
            Object.defineProperty(this, "options", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: t
            }), Object.defineProperty(this, "events", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: new Map
            }), this.setOptions(t);
            for (const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) t.startsWith("on") && "function" == typeof this[t] && (this[t] = this[t].bind(this))
        }
        setOptions(t) {
            this.options = t ? p({}, this.constructor.defaults, t) : {};
            for (const [t, e] of Object.entries(this.option("on") || {})) this.on(t, e)
        }
        option(t, ...e) {
            let i = f(t, this.options);
            return i && "function" == typeof i && (i = i.call(this, this, ...e)), i
        }
        optionFor(t, e, i, ...n) {
            let s = f(e, t);
            var o;
            "string" != typeof(o = s) || isNaN(o) || isNaN(parseFloat(o)) || (s = parseFloat(s)), "true" === s && (s = !0), "false" === s && (s = !1), s && "function" == typeof s && (s = s.call(this, this, t, ...n));
            let a = f(e, this.options);
            return a && "function" == typeof a ? s = a.call(this, this, t, ...n, s) : void 0 === s && (s = a), void 0 === s ? i : s
        }
        cn(t) {
            const e = this.options.classes;
            return e && e[t] || ""
        }
        localize(t, e = []) {
            t = String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g, ((t, e, i) => {
                let n = "";
                return i ? n = this.option(`${e[0]+e.toLowerCase().substring(1)}.l10n.${i}`) : e && (n = this.option(`l10n.${e}`)), n || (n = t), n
            }));
            for (let i = 0; i < e.length; i++) t = t.split(e[i][0]).join(e[i][1]);
            return t = t.replace(/\{\{(.*?)\}\}/g, ((t, e) => e))
        }
        on(t, e) {
            let i = [];
            "string" == typeof t ? i = t.split(" ") : Array.isArray(t) && (i = t), this.events || (this.events = new Map), i.forEach((t => {
                let i = this.events.get(t);
                i || (this.events.set(t, []), i = []), i.includes(e) || i.push(e), this.events.set(t, i)
            }))
        }
        off(t, e) {
            let i = [];
            "string" == typeof t ? i = t.split(" ") : Array.isArray(t) && (i = t), i.forEach((t => {
                const i = this.events.get(t);
                if (Array.isArray(i)) {
                    const t = i.indexOf(e);
                    t > -1 && i.splice(t, 1)
                }
            }))
        }
        emit(t, ...e) {
            [...this.events.get(t) || []].forEach((t => t(this, ...e))), "*" !== t && this.emit("*", t, ...e)
        }
    }
    Object.defineProperty(g, "version", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: "5.0.36"
    }), Object.defineProperty(g, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {}
    });
    class m extends g {
        constructor(t = {}) {
            super(t), Object.defineProperty(this, "plugins", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: {}
            })
        }
        attachPlugins(t = {}) {
            const e = new Map;
            for (const [i, n] of Object.entries(t)) {
                const t = this.option(i),
                    s = this.plugins[i];
                s || !1 === t ? s && !1 === t && (s.detach(), delete this.plugins[i]) : e.set(i, new n(this, t || {}))
            }
            for (const [t, i] of e) this.plugins[t] = i, i.attach()
        }
        detachPlugins(t) {
            t = t || Object.keys(this.plugins);
            for (const e of t) {
                const t = this.plugins[e];
                t && t.detach(), delete this.plugins[e]
            }
            return this.emit("detachPlugins"), this
        }
    }
    var v;
    ! function(t) {
        t[t.Init = 0] = "Init", t[t.Error = 1] = "Error", t[t.Ready = 2] = "Ready", t[t.Panning = 3] = "Panning", t[t.Mousemove = 4] = "Mousemove", t[t.Destroy = 5] = "Destroy"
    }(v || (v = {}));
    const b = ["a", "b", "c", "d", "e", "f"],
        y = {
            PANUP: "Move up",
            PANDOWN: "Move down",
            PANLEFT: "Move left",
            PANRIGHT: "Move right",
            ZOOMIN: "Zoom in",
            ZOOMOUT: "Zoom out",
            TOGGLEZOOM: "Toggle zoom level",
            TOGGLE1TO1: "Toggle zoom level",
            ITERATEZOOM: "Toggle zoom level",
            ROTATECCW: "Rotate counterclockwise",
            ROTATECW: "Rotate clockwise",
            FLIPX: "Flip horizontally",
            FLIPY: "Flip vertically",
            FITX: "Fit horizontally",
            FITY: "Fit vertically",
            RESET: "Reset",
            TOGGLEFS: "Toggle fullscreen"
        },
        w = {
            content: null,
            width: "auto",
            height: "auto",
            panMode: "drag",
            touch: !0,
            dragMinThreshold: 3,
            lockAxis: !1,
            mouseMoveFactor: 1,
            mouseMoveFriction: .12,
            zoom: !0,
            pinchToZoom: !0,
            panOnlyZoomed: "auto",
            minScale: 1,
            maxScale: 2,
            friction: .25,
            dragFriction: .35,
            decelFriction: .05,
            click: "toggleZoom",
            dblClick: !1,
            wheel: "zoom",
            wheelLimit: 7,
            spinner: !0,
            bounds: "auto",
            infinite: !1,
            rubberband: !0,
            bounce: !0,
            maxVelocity: 75,
            transformParent: !1,
            classes: {
                content: "f-panzoom__content",
                isLoading: "is-loading",
                canZoomIn: "can-zoom_in",
                canZoomOut: "can-zoom_out",
                isDraggable: "is-draggable",
                isDragging: "is-dragging",
                inFullscreen: "in-fullscreen",
                htmlHasFullscreen: "with-panzoom-in-fullscreen"
            },
            l10n: y
        },
        x = '<circle cx="25" cy="25" r="20"></circle>',
        E = '<div class="f-spinner"><svg viewBox="0 0 50 50">' + x + x + "</svg></div>",
        S = t => t && null !== t && t instanceof Element && "nodeType" in t,
        P = (t, e) => {
            t && o(e).forEach((e => {
                t.classList.remove(e)
            }))
        },
        C = (t, e) => {
            t && o(e).forEach((e => {
                t.classList.add(e)
            }))
        },
        T = {
            a: 1,
            b: 0,
            c: 0,
            d: 1,
            e: 0,
            f: 0
        },
        M = 1e5,
        O = 1e4,
        A = "mousemove",
        L = "drag",
        z = "content",
        R = "auto";
    let k = null,
        I = null;
    class D extends m {
        get fits() {
            return this.contentRect.width - this.contentRect.fitWidth < 1 && this.contentRect.height - this.contentRect.fitHeight < 1
        }
        get isTouchDevice() {
            return null === I && (I = window.matchMedia("(hover: none)").matches), I
        }
        get isMobile() {
            return null === k && (k = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)), k
        }
        get panMode() {
            return this.options.panMode !== A || this.isTouchDevice ? L : A
        }
        get panOnlyZoomed() {
            const t = this.options.panOnlyZoomed;
            return t === R ? this.isTouchDevice : t
        }
        get isInfinite() {
            return this.option("infinite")
        }
        get angle() {
            return 180 * Math.atan2(this.current.b, this.current.a) / Math.PI || 0
        }
        get targetAngle() {
            return 180 * Math.atan2(this.target.b, this.target.a) / Math.PI || 0
        }
        get scale() {
            const {
                a: t,
                b: e
            } = this.current;
            return Math.sqrt(t * t + e * e) || 1
        }
        get targetScale() {
            const {
                a: t,
                b: e
            } = this.target;
            return Math.sqrt(t * t + e * e) || 1
        }
        get minScale() {
            return this.option("minScale") || 1
        }
        get fullScale() {
            const {
                contentRect: t
            } = this;
            return t.fullWidth / t.fitWidth || 1
        }
        get maxScale() {
            return this.fullScale * (this.option("maxScale") || 1) || 1
        }
        get coverScale() {
            const {
                containerRect: t,
                contentRect: e
            } = this, i = Math.max(t.height / e.fitHeight, t.width / e.fitWidth) || 1;
            return Math.min(this.fullScale, i)
        }
        get isScaling() {
            return Math.abs(this.targetScale - this.scale) > 1e-5 && !this.isResting
        }
        get isContentLoading() {
            const t = this.content;
            return !!(t && t instanceof HTMLImageElement) && !t.complete
        }
        get isResting() {
            if (this.isBouncingX || this.isBouncingY) return !1;
            for (const t of b) {
                const e = "e" == t || "f" === t ? 1e-4 : 1e-5;
                if (Math.abs(this.target[t] - this.current[t]) > e) return !1
            }
            return !(!this.ignoreBounds && !this.checkBounds().inBounds)
        }
        constructor(t, e = {}, i = {}) {
            var n;
            if (super(e), Object.defineProperty(this, "pointerTracker", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "resizeObserver", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "updateTimer", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "clickTimer", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "rAF", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "isTicking", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), Object.defineProperty(this, "ignoreBounds", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), Object.defineProperty(this, "isBouncingX", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), Object.defineProperty(this, "isBouncingY", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), Object.defineProperty(this, "clicks", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "trackingPoints", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: []
                }), Object.defineProperty(this, "pwt", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "cwd", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "pmme", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: void 0
                }), Object.defineProperty(this, "friction", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "state", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: v.Init
                }), Object.defineProperty(this, "isDragging", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), Object.defineProperty(this, "container", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: void 0
                }), Object.defineProperty(this, "content", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: void 0
                }), Object.defineProperty(this, "spinner", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "containerRect", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {
                        width: 0,
                        height: 0,
                        innerWidth: 0,
                        innerHeight: 0
                    }
                }), Object.defineProperty(this, "contentRect", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {
                        top: 0,
                        right: 0,
                        bottom: 0,
                        left: 0,
                        fullWidth: 0,
                        fullHeight: 0,
                        fitWidth: 0,
                        fitHeight: 0,
                        width: 0,
                        height: 0
                    }
                }), Object.defineProperty(this, "dragStart", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {
                        x: 0,
                        y: 0,
                        top: 0,
                        left: 0,
                        time: 0
                    }
                }), Object.defineProperty(this, "dragOffset", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {
                        x: 0,
                        y: 0,
                        time: 0
                    }
                }), Object.defineProperty(this, "current", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: Object.assign({}, T)
                }), Object.defineProperty(this, "target", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: Object.assign({}, T)
                }), Object.defineProperty(this, "velocity", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {
                        a: 0,
                        b: 0,
                        c: 0,
                        d: 0,
                        e: 0,
                        f: 0
                    }
                }), Object.defineProperty(this, "lockedAxis", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: !1
                }), !t) throw new Error("Container Element Not Found");
            this.container = t, this.initContent(), this.attachPlugins(Object.assign(Object.assign({}, D.Plugins), i)), this.emit("attachPlugins"), this.emit("init");
            const o = this.content;
            if (o.addEventListener("load", this.onLoad), o.addEventListener("error", this.onError), this.isContentLoading) {
                if (this.option("spinner")) {
                    t.classList.add(this.cn("isLoading"));
                    const e = s(E);
                    !t.contains(o) || o.parentElement instanceof HTMLPictureElement ? this.spinner = t.appendChild(e) : this.spinner = (null === (n = o.parentElement) || void 0 === n ? void 0 : n.insertBefore(e, o)) || null
                }
                this.emit("beforeLoad")
            } else queueMicrotask((() => {
                this.enable()
            }))
        }
        initContent() {
            const {
                container: t
            } = this, e = this.cn(z);
            let i = this.option(z) || t.querySelector(`.${e}`);
            if (i || (i = t.querySelector("img,picture") || t.firstElementChild, i && C(i, e)), i instanceof HTMLPictureElement && (i = i.querySelector("img")), !i) throw new Error("No content found");
            this.content = i
        }
        onLoad() {
            const {
                spinner: t,
                container: e,
                state: i
            } = this;
            t && (t.remove(), this.spinner = null), this.option("spinner") && e.classList.remove(this.cn("isLoading")), this.emit("afterLoad"), i === v.Init ? this.enable() : this.updateMetrics()
        }
        onError() {
            this.state !== v.Destroy && (this.spinner && (this.spinner.remove(), this.spinner = null), this.stop(), this.detachEvents(), this.state = v.Error, this.emit("error"))
        }
        getNextScale(t) {
            const {
                fullScale: e,
                targetScale: i,
                coverScale: n,
                maxScale: s,
                minScale: o
            } = this;
            let a = o;
            switch (t) {
                case "toggleMax":
                    a = i - o < .5 * (s - o) ? s : o;
                    break;
                case "toggleCover":
                    a = i - o < .5 * (n - o) ? n : o;
                    break;
                case "toggleZoom":
                    a = i - o < .5 * (e - o) ? e : o;
                    break;
                case "iterateZoom":
                    let t = [1, e, s].sort(((t, e) => t - e)),
                        r = t.findIndex((t => t > i + 1e-5));
                    a = t[r] || 1
            }
            return a
        }
        attachObserver() {
            var t;
            const e = () => {
                const {
                    container: t,
                    containerRect: e
                } = this;
                return Math.abs(e.width - t.getBoundingClientRect().width) > .1 || Math.abs(e.height - t.getBoundingClientRect().height) > .1
            };
            this.resizeObserver || void 0 === window.ResizeObserver || (this.resizeObserver = new ResizeObserver((() => {
                this.updateTimer || (e() ? (this.onResize(), this.isMobile && (this.updateTimer = setTimeout((() => {
                    e() && this.onResize(), this.updateTimer = null
                }), 500))) : this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null))
            }))), null === (t = this.resizeObserver) || void 0 === t || t.observe(this.container)
        }
        detachObserver() {
            var t;
            null === (t = this.resizeObserver) || void 0 === t || t.disconnect()
        }
        attachEvents() {
            const {
                container: t
            } = this;
            t.addEventListener("click", this.onClick, {
                passive: !1,
                capture: !1
            }), t.addEventListener("wheel", this.onWheel, {
                passive: !1
            }), this.pointerTracker = new c(t, {
                start: this.onPointerDown,
                move: this.onPointerMove,
                end: this.onPointerUp
            }), document.addEventListener(A, this.onMouseMove)
        }
        detachEvents() {
            var t;
            const {
                container: e
            } = this;
            e.removeEventListener("click", this.onClick, {
                passive: !1,
                capture: !1
            }), e.removeEventListener("wheel", this.onWheel, {
                passive: !1
            }), null === (t = this.pointerTracker) || void 0 === t || t.stop(), this.pointerTracker = null, document.removeEventListener(A, this.onMouseMove), document.removeEventListener("keydown", this.onKeydown, !0), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null)
        }
        animate() {
            this.setTargetForce();
            const t = this.friction,
                e = this.option("maxVelocity");
            for (const i of b) t ? (this.velocity[i] *= 1 - t, e && !this.isScaling && (this.velocity[i] = Math.max(Math.min(this.velocity[i], e), -1 * e)), this.current[i] += this.velocity[i]) : this.current[i] = this.target[i];
            this.setTransform(), this.setEdgeForce(), !this.isResting || this.isDragging ? this.rAF = requestAnimationFrame((() => this.animate())) : this.stop("current")
        }
        setTargetForce() {
            for (const t of b) "e" === t && this.isBouncingX || "f" === t && this.isBouncingY || (this.velocity[t] = (1 / (1 - this.friction) - 1) * (this.target[t] - this.current[t]))
        }
        checkBounds(t = 0, e = 0) {
            const {
                current: i
            } = this, n = i.e + t, s = i.f + e, o = this.getBounds(), {
                x: a,
                y: r
            } = o, l = a.min, c = a.max, h = r.min, d = r.max;
            let u = 0,
                p = 0;
            return l !== 1 / 0 && n < l ? u = l - n : c !== 1 / 0 && n > c && (u = c - n), h !== 1 / 0 && s < h ? p = h - s : d !== 1 / 0 && s > d && (p = d - s), Math.abs(u) < 1e-4 && (u = 0), Math.abs(p) < 1e-4 && (p = 0), Object.assign(Object.assign({}, o), {
                xDiff: u,
                yDiff: p,
                inBounds: !u && !p
            })
        }
        clampTargetBounds() {
            const {
                target: t
            } = this, {
                x: e,
                y: i
            } = this.getBounds();
            e.min !== 1 / 0 && (t.e = Math.max(t.e, e.min)), e.max !== 1 / 0 && (t.e = Math.min(t.e, e.max)), i.min !== 1 / 0 && (t.f = Math.max(t.f, i.min)), i.max !== 1 / 0 && (t.f = Math.min(t.f, i.max))
        }
        calculateContentDim(t = this.current) {
            const {
                content: e,
                contentRect: i
            } = this, {
                fitWidth: n,
                fitHeight: s,
                fullWidth: o,
                fullHeight: a
            } = i;
            let r = o,
                l = a;
            if (this.option("zoom") || 0 !== this.angle) {
                const i = !(e instanceof HTMLImageElement) && ("none" === window.getComputedStyle(e).maxWidth || "none" === window.getComputedStyle(e).maxHeight),
                    c = i ? o : n,
                    h = i ? a : s,
                    d = this.getMatrix(t),
                    u = new DOMPoint(0, 0).matrixTransform(d),
                    p = new DOMPoint(0 + c, 0).matrixTransform(d),
                    f = new DOMPoint(0 + c, 0 + h).matrixTransform(d),
                    g = new DOMPoint(0, 0 + h).matrixTransform(d),
                    m = Math.abs(f.x - u.x),
                    v = Math.abs(f.y - u.y),
                    b = Math.abs(g.x - p.x),
                    y = Math.abs(g.y - p.y);
                r = Math.max(m, b), l = Math.max(v, y)
            }
            return {
                contentWidth: r,
                contentHeight: l
            }
        }
        setEdgeForce() {
            if (this.ignoreBounds || this.isDragging || this.panMode === A || this.targetScale < this.scale) return this.isBouncingX = !1, void(this.isBouncingY = !1);
            const {
                target: t
            } = this, {
                x: e,
                y: i,
                xDiff: n,
                yDiff: s
            } = this.checkBounds();
            const o = this.option("maxVelocity");
            let a = this.velocity.e,
                r = this.velocity.f;
            0 !== n ? (this.isBouncingX = !0, n * a <= 0 ? a += .14 * n : (a = .14 * n, e.min !== 1 / 0 && (this.target.e = Math.max(t.e, e.min)), e.max !== 1 / 0 && (this.target.e = Math.min(t.e, e.max))), o && (a = Math.max(Math.min(a, o), -1 * o))) : this.isBouncingX = !1, 0 !== s ? (this.isBouncingY = !0, s * r <= 0 ? r += .14 * s : (r = .14 * s, i.min !== 1 / 0 && (this.target.f = Math.max(t.f, i.min)), i.max !== 1 / 0 && (this.target.f = Math.min(t.f, i.max))), o && (r = Math.max(Math.min(r, o), -1 * o))) : this.isBouncingY = !1, this.isBouncingX && (this.velocity.e = a), this.isBouncingY && (this.velocity.f = r)
        }
        enable() {
            const {
                content: t
            } = this, e = new DOMMatrixReadOnly(window.getComputedStyle(t).transform);
            for (const t of b) this.current[t] = this.target[t] = e[t];
            this.updateMetrics(), this.attachObserver(), this.attachEvents(), this.state = v.Ready, this.emit("ready")
        }
        onClick(t) {
            var e;
            "click" === t.type && 0 === t.detail && (this.dragOffset.x = 0, this.dragOffset.y = 0), this.isDragging && (null === (e = this.pointerTracker) || void 0 === e || e.clear(), this.trackingPoints = [], this.startDecelAnim());
            const i = t.target;
            if (!i || t.defaultPrevented) return;
            if (i.hasAttribute("disabled")) return t.preventDefault(), void t.stopPropagation();
            if ((() => {
                    const t = window.getSelection();
                    return t && "Range" === t.type
                })() && !i.closest("button")) return;
            const n = i.closest("[data-panzoom-action]"),
                s = i.closest("[data-panzoom-change]"),
                o = n || s,
                a = o && S(o) ? o.dataset : null;
            if (a) {
                const e = a.panzoomChange,
                    i = a.panzoomAction;
                if ((e || i) && t.preventDefault(), e) {
                    let t = {};
                    try {
                        t = JSON.parse(e)
                    } catch (t) {
                        console && console.warn("The given data was not valid JSON")
                    }
                    return void this.applyChange(t)
                }
                if (i) return void(this[i] && this[i]())
            }
            if (Math.abs(this.dragOffset.x) > 3 || Math.abs(this.dragOffset.y) > 3) return t.preventDefault(), void t.stopPropagation();
            if (i.closest("[data-fancybox]")) return;
            const r = this.content.getBoundingClientRect(),
                l = this.dragStart;
            if (l.time && !this.canZoomOut() && (Math.abs(r.x - l.x) > 2 || Math.abs(r.y - l.y) > 2)) return;
            this.dragStart.time = 0;
            const c = e => {
                    this.option("zoom", t) && e && "string" == typeof e && /(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(e) && "function" == typeof this[e] && (t.preventDefault(), this[e]({
                        event: t
                    }))
                },
                h = this.option("click", t),
                d = this.option("dblClick", t);
            d ? (this.clicks++, 1 == this.clicks && (this.clickTimer = setTimeout((() => {
                1 === this.clicks ? (this.emit("click", t), !t.defaultPrevented && h && c(h)) : (this.emit("dblClick", t), t.defaultPrevented || c(d)), this.clicks = 0, this.clickTimer = null
            }), 350))) : (this.emit("click", t), !t.defaultPrevented && h && c(h))
        }
        addTrackingPoint(t) {
            const e = this.trackingPoints.filter((t => t.time > Date.now() - 100));
            e.push(t), this.trackingPoints = e
        }
        onPointerDown(t, e, i) {
            var n;
            if (!1 === this.option("touch", t)) return !1;
            this.pwt = 0, this.dragOffset = {
                x: 0,
                y: 0,
                time: 0
            }, this.trackingPoints = [];
            const s = this.content.getBoundingClientRect();
            if (this.dragStart = {
                    x: s.x,
                    y: s.y,
                    top: s.top,
                    left: s.left,
                    time: Date.now()
                }, this.clickTimer) return !1;
            if (this.panMode === A && this.targetScale > 1) return t.preventDefault(), t.stopPropagation(), !1;
            const o = t.composedPath()[0];
            if (!i.length) {
                if (["TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO", "IFRAME"].includes(o.nodeName) || o.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]")) return !1;
                null === (n = window.getSelection()) || void 0 === n || n.removeAllRanges()
            }
            if ("mousedown" === t.type)["A", "BUTTON"].includes(o.nodeName) || t.preventDefault();
            else if (Math.abs(this.velocity.a) > .3) return !1;
            return this.target.e = this.current.e, this.target.f = this.current.f, this.stop(), this.isDragging || (this.isDragging = !0, this.addTrackingPoint(e), this.emit("touchStart", t)), !0
        }
        onPointerMove(t, i, s) {
            if (!1 === this.option("touch", t)) return;
            if (!this.isDragging) return;
            if (i.length < 2 && this.panOnlyZoomed && e(this.targetScale) <= e(this.minScale)) return;
            if (this.emit("touchMove", t), t.defaultPrevented) return;
            this.addTrackingPoint(i[0]);
            const {
                content: o
            } = this, a = d(s[0], s[1]), r = d(i[0], i[1]);
            let l = 0,
                c = 0;
            if (i.length > 1) {
                const t = o.getBoundingClientRect();
                l = a.clientX - t.left - .5 * t.width, c = a.clientY - t.top - .5 * t.height
            }
            const u = h(s[0], s[1]),
                p = h(i[0], i[1]);
            let f = u ? p / u : 1,
                g = r.clientX - a.clientX,
                m = r.clientY - a.clientY;
            this.dragOffset.x += g, this.dragOffset.y += m, this.dragOffset.time = Date.now() - this.dragStart.time;
            let v = e(this.targetScale) === e(this.minScale) && this.option("lockAxis");
            if (v && !this.lockedAxis)
                if ("xy" === v || "y" === v || "touchmove" === t.type) {
                    if (Math.abs(this.dragOffset.x) < 6 && Math.abs(this.dragOffset.y) < 6) return void t.preventDefault();
                    const e = Math.abs(180 * Math.atan2(this.dragOffset.y, this.dragOffset.x) / Math.PI);
                    this.lockedAxis = e > 45 && e < 135 ? "y" : "x", this.dragOffset.x = 0, this.dragOffset.y = 0, g = 0, m = 0
                } else this.lockedAxis = v;
            if (n(t.target, this.content) && (v = "x", this.dragOffset.y = 0), v && "xy" !== v && this.lockedAxis !== v && e(this.targetScale) === e(this.minScale)) return;
            t.cancelable && t.preventDefault(), this.container.classList.add(this.cn("isDragging"));
            const b = this.checkBounds(g, m);
            this.option("rubberband") ? ("x" !== this.isInfinite && (b.xDiff > 0 && g < 0 || b.xDiff < 0 && g > 0) && (g *= Math.max(0, .5 - Math.abs(.75 / this.contentRect.fitWidth * b.xDiff))), "y" !== this.isInfinite && (b.yDiff > 0 && m < 0 || b.yDiff < 0 && m > 0) && (m *= Math.max(0, .5 - Math.abs(.75 / this.contentRect.fitHeight * b.yDiff)))) : (b.xDiff && (g = 0), b.yDiff && (m = 0));
            const y = this.targetScale,
                w = this.minScale,
                x = this.maxScale;
            y < .5 * w && (f = Math.max(f, w)), y > 1.5 * x && (f = Math.min(f, x)), "y" === this.lockedAxis && e(y) === e(w) && (g = 0), "x" === this.lockedAxis && e(y) === e(w) && (m = 0), this.applyChange({
                originX: l,
                originY: c,
                panX: g,
                panY: m,
                scale: f,
                friction: this.option("dragFriction"),
                ignoreBounds: !0
            })
        }
        onPointerUp(t, e, i) {
            if (i.length) return this.dragOffset.x = 0, this.dragOffset.y = 0, void(this.trackingPoints = []);
            this.container.classList.remove(this.cn("isDragging")), this.isDragging && (this.addTrackingPoint(e), this.panOnlyZoomed && this.contentRect.width - this.contentRect.fitWidth < 1 && this.contentRect.height - this.contentRect.fitHeight < 1 && (this.trackingPoints = []), n(t.target, this.content) && "y" === this.lockedAxis && (this.trackingPoints = []), this.emit("touchEnd", t), this.isDragging = !1, this.lockedAxis = !1, this.state !== v.Destroy && (t.defaultPrevented || this.startDecelAnim()))
        }
        startDecelAnim() {
            var t;
            const i = this.isScaling;
            this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.isBouncingX = !1, this.isBouncingY = !1;
            for (const t of b) this.velocity[t] = 0;
            this.target.e = this.current.e, this.target.f = this.current.f, P(this.container, "is-scaling"), P(this.container, "is-animating"), this.isTicking = !1;
            const {
                trackingPoints: n
            } = this, s = n[0], o = n[n.length - 1];
            let a = 0,
                r = 0,
                l = 0;
            o && s && (a = o.clientX - s.clientX, r = o.clientY - s.clientY, l = o.time - s.time);
            const c = (null === (t = window.visualViewport) || void 0 === t ? void 0 : t.scale) || 1;
            1 !== c && (a *= c, r *= c);
            let h = 0,
                d = 0,
                u = 0,
                p = 0,
                f = this.option("decelFriction");
            const g = this.targetScale;
            if (l > 0) {
                u = Math.abs(a) > 3 ? a / (l / 30) : 0, p = Math.abs(r) > 3 ? r / (l / 30) : 0;
                const t = this.option("maxVelocity");
                t && (u = Math.max(Math.min(u, t), -1 * t), p = Math.max(Math.min(p, t), -1 * t))
            }
            u && (h = u / (1 / (1 - f) - 1)), p && (d = p / (1 / (1 - f) - 1)), ("y" === this.option("lockAxis") || "xy" === this.option("lockAxis") && "y" === this.lockedAxis && e(g) === this.minScale) && (h = u = 0), ("x" === this.option("lockAxis") || "xy" === this.option("lockAxis") && "x" === this.lockedAxis && e(g) === this.minScale) && (d = p = 0);
            const m = this.dragOffset.x,
                v = this.dragOffset.y,
                y = this.option("dragMinThreshold") || 0;
            Math.abs(m) < y && Math.abs(v) < y && (h = d = 0, u = p = 0), (this.option("zoom") && (g < this.minScale - 1e-5 || g > this.maxScale + 1e-5) || i && !h && !d) && (f = .35), this.applyChange({
                panX: h,
                panY: d,
                friction: f
            }), this.emit("decel", u, p, m, v)
        }
        onWheel(t) {
            var e = [-t.deltaX || 0, -t.deltaY || 0, -t.detail || 0].reduce((function(t, e) {
                return Math.abs(e) > Math.abs(t) ? e : t
            }));
            const i = Math.max(-1, Math.min(1, e));
            if (this.emit("wheel", t, i), this.panMode === A) return;
            if (t.defaultPrevented) return;
            const n = this.option("wheel");
            "pan" === n ? (t.preventDefault(), this.panOnlyZoomed && !this.canZoomOut() || this.applyChange({
                panX: 2 * -t.deltaX,
                panY: 2 * -t.deltaY,
                bounce: !1
            })) : "zoom" === n && !1 !== this.option("zoom") && this.zoomWithWheel(t)
        }
        onMouseMove(t) {
            this.panWithMouse(t)
        }
        onKeydown(t) {
            "Escape" === t.key && this.toggleFS()
        }
        onResize() {
            this.updateMetrics(), this.checkBounds().inBounds || this.requestTick()
        }
        setTransform() {
            this.emit("beforeTransform");
            const {
                current: t,
                target: i,
                content: n,
                contentRect: s
            } = this, o = Object.assign({}, T);
            for (const n of b) {
                const s = "e" == n || "f" === n ? O : M;
                o[n] = e(t[n], s), Math.abs(i[n] - t[n]) < ("e" == n || "f" === n ? .51 : .001) && (t[n] = i[n])
            }
            let {
                a: a,
                b: r,
                c: l,
                d: c,
                e: h,
                f: d
            } = o, u = `matrix(${a}, ${r}, ${l}, ${c}, ${h}, ${d})`, p = n.parentElement instanceof HTMLPictureElement ? n.parentElement : n;
            if (this.option("transformParent") && (p = p.parentElement || p), p.style.transform === u) return;
            p.style.transform = u;
            const {
                contentWidth: f,
                contentHeight: g
            } = this.calculateContentDim();
            s.width = f, s.height = g, this.emit("afterTransform")
        }
        updateMetrics(t = !1) {
            var i;
            if (!this || this.state === v.Destroy) return;
            if (this.isContentLoading) return;
            const n = Math.max(1, (null === (i = window.visualViewport) || void 0 === i ? void 0 : i.scale) || 1),
                {
                    container: s,
                    content: o
                } = this,
                a = o instanceof HTMLImageElement,
                r = s.getBoundingClientRect(),
                l = getComputedStyle(this.container);
            let c = r.width * n,
                h = r.height * n;
            const d = parseFloat(l.paddingTop) + parseFloat(l.paddingBottom),
                u = c - (parseFloat(l.paddingLeft) + parseFloat(l.paddingRight)),
                p = h - d;
            this.containerRect = {
                width: c,
                height: h,
                innerWidth: u,
                innerHeight: p
            };
            const f = parseFloat(o.dataset.width || "") || (t => {
                    let e = 0;
                    return e = t instanceof HTMLImageElement ? t.naturalWidth : t instanceof SVGElement ? t.width.baseVal.value : Math.max(t.offsetWidth, t.scrollWidth), e || 0
                })(o),
                g = parseFloat(o.dataset.height || "") || (t => {
                    let e = 0;
                    return e = t instanceof HTMLImageElement ? t.naturalHeight : t instanceof SVGElement ? t.height.baseVal.value : Math.max(t.offsetHeight, t.scrollHeight), e || 0
                })(o);
            let m = this.option("width", f) || R,
                b = this.option("height", g) || R;
            const y = m === R,
                w = b === R;
            "number" != typeof m && (m = f), "number" != typeof b && (b = g), y && (m = f * (b / g)), w && (b = g / (f / m));
            let x = o.parentElement instanceof HTMLPictureElement ? o.parentElement : o;
            this.option("transformParent") && (x = x.parentElement || x);
            const E = x.getAttribute("style") || "";
            x.style.setProperty("transform", "none", "important"), a && (x.style.width = "", x.style.height = ""), x.offsetHeight;
            const S = o.getBoundingClientRect();
            let P = S.width * n,
                C = S.height * n,
                T = P,
                M = C;
            P = Math.min(P, m), C = Math.min(C, b), a ? ({
                width: P,
                height: C
            } = ((t, e, i, n) => {
                const s = i / t,
                    o = n / e,
                    a = Math.min(s, o);
                return {
                    width: t *= a,
                    height: e *= a
                }
            })(m, b, P, C)) : (P = Math.min(P, m), C = Math.min(C, b));
            let O = .5 * (M - C),
                A = .5 * (T - P);
            this.contentRect = Object.assign(Object.assign({}, this.contentRect), {
                top: S.top - r.top + O,
                bottom: r.bottom - S.bottom + O,
                left: S.left - r.left + A,
                right: r.right - S.right + A,
                fitWidth: P,
                fitHeight: C,
                width: P,
                height: C,
                fullWidth: m,
                fullHeight: b
            }), x.style.cssText = E, a && (x.style.width = `${P}px`, x.style.height = `${C}px`), this.setTransform(), !0 !== t && this.emit("refresh"), this.ignoreBounds || (e(this.targetScale) < e(this.minScale) ? this.zoomTo(this.minScale, {
                friction: 0
            }) : this.targetScale > this.maxScale ? this.zoomTo(this.maxScale, {
                friction: 0
            }) : this.state === v.Init || this.checkBounds().inBounds || this.requestTick()), this.updateControls()
        }
        calculateBounds() {
            const {
                contentWidth: t,
                contentHeight: i
            } = this.calculateContentDim(this.target), {
                targetScale: n,
                lockedAxis: s
            } = this, {
                fitWidth: o,
                fitHeight: a
            } = this.contentRect;
            let r = 0,
                l = 0,
                c = 0,
                h = 0;
            const d = this.option("infinite");
            if (!0 === d || s && d === s) r = -1 / 0, c = 1 / 0, l = -1 / 0, h = 1 / 0;
            else {
                let {
                    containerRect: s,
                    contentRect: d
                } = this, u = e(o * n, O), p = e(a * n, O), {
                    innerWidth: f,
                    innerHeight: g
                } = s;
                if (s.width === u && (f = s.width), s.width === p && (g = s.height), t > f) {
                    c = .5 * (t - f), r = -1 * c;
                    let e = .5 * (d.right - d.left);
                    r += e, c += e
                }
                if (o > f && t < f && (r -= .5 * (o - f), c -= .5 * (o - f)), i > g) {
                    h = .5 * (i - g), l = -1 * h;
                    let t = .5 * (d.bottom - d.top);
                    l += t, h += t
                }
                a > g && i < g && (r -= .5 * (a - g), c -= .5 * (a - g))
            }
            return {
                x: {
                    min: r,
                    max: c
                },
                y: {
                    min: l,
                    max: h
                }
            }
        }
        getBounds() {
            const t = this.option("bounds");
            return t !== R ? t : this.calculateBounds()
        }
        updateControls() {
            const t = this,
                i = t.container,
                {
                    panMode: n,
                    contentRect: s,
                    targetScale: o,
                    minScale: r
                } = t;
            let l = r,
                c = t.option("click") || !1;
            c && (l = t.getNextScale(c));
            let h = t.canZoomIn(),
                d = t.canZoomOut(),
                u = n === L && !!this.option("touch"),
                p = d && u;
            if (u && (e(o) < e(r) && !this.panOnlyZoomed && (p = !0), (e(s.width, 1) > e(s.fitWidth, 1) || e(s.height, 1) > e(s.fitHeight, 1)) && (p = !0)), e(s.width * o, 1) < e(s.fitWidth, 1) && (p = !1), n === A && (p = !1), a(i, this.cn("isDraggable"), p), !this.option("zoom")) return;
            let f = h && e(l) > e(o),
                g = !f && !p && d && e(l) < e(o);
            a(i, this.cn("canZoomIn"), f), a(i, this.cn("canZoomOut"), g);
            for (const t of i.querySelectorAll("[data-panzoom-action]")) {
                let e = !1,
                    i = !1;
                switch (t.dataset.panzoomAction) {
                    case "zoomIn":
                        h ? e = !0 : i = !0;
                        break;
                    case "zoomOut":
                        d ? e = !0 : i = !0;
                        break;
                    case "toggleZoom":
                    case "iterateZoom":
                        h || d ? e = !0 : i = !0;
                        const n = t.querySelector("g");
                        n && (n.style.display = h ? "" : "none")
                }
                e ? (t.removeAttribute("disabled"), t.removeAttribute("tabindex")) : i && (t.setAttribute("disabled", ""), t.setAttribute("tabindex", "-1"))
            }
        }
        panTo({
            x: t = this.target.e,
            y: e = this.target.f,
            scale: i = this.targetScale,
            friction: n = this.option("friction"),
            angle: s = 0,
            originX: o = 0,
            originY: a = 0,
            flipX: r = !1,
            flipY: l = !1,
            ignoreBounds: c = !1
        }) {
            this.state !== v.Destroy && this.applyChange({
                panX: t - this.target.e,
                panY: e - this.target.f,
                scale: i / this.targetScale,
                angle: s,
                originX: o,
                originY: a,
                friction: n,
                flipX: r,
                flipY: l,
                ignoreBounds: c
            })
        }
        applyChange({
            panX: t = 0,
            panY: i = 0,
            scale: n = 1,
            angle: s = 0,
            originX: o = -this.current.e,
            originY: a = -this.current.f,
            friction: r = this.option("friction"),
            flipX: l = !1,
            flipY: c = !1,
            ignoreBounds: h = !1,
            bounce: d = this.option("bounce")
        }) {
            const u = this.state;
            if (u === v.Destroy) return;
            this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.friction = r || 0, this.ignoreBounds = h;
            const {
                current: p
            } = this, f = p.e, g = p.f, m = this.getMatrix(this.target);
            let y = (new DOMMatrix).translate(f, g).translate(o, a).translate(t, i);
            if (this.option("zoom")) {
                if (!h) {
                    const t = this.targetScale,
                        e = this.minScale,
                        i = this.maxScale;
                    t * n < e && (n = e / t), t * n > i && (n = i / t)
                }
                y = y.scale(n)
            }
            y = y.translate(-o, -a).translate(-f, -g).multiply(m), s && (y = y.rotate(s)), l && (y = y.scale(-1, 1)), c && (y = y.scale(1, -1));
            for (const t of b) "e" !== t && "f" !== t && (y[t] > this.minScale + 1e-5 || y[t] < this.minScale - 1e-5) ? this.target[t] = y[t] : this.target[t] = e(y[t], O);
            (this.targetScale < this.scale || Math.abs(n - 1) > .1 || this.panMode === A || !1 === d) && !h && this.clampTargetBounds(), u === v.Init ? this.animate() : this.isResting || (this.state = v.Panning, this.requestTick())
        }
        stop(t = !1) {
            if (this.state === v.Init || this.state === v.Destroy) return;
            const e = this.isTicking;
            this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.isBouncingX = !1, this.isBouncingY = !1;
            for (const e of b) this.velocity[e] = 0, "current" === t ? this.current[e] = this.target[e] : "target" === t && (this.target[e] = this.current[e]);
            this.setTransform(), P(this.container, "is-scaling"), P(this.container, "is-animating"), this.isTicking = !1, this.state = v.Ready, e && (this.emit("endAnimation"), this.updateControls())
        }
        requestTick() {
            this.isTicking || (this.emit("startAnimation"), this.updateControls(), C(this.container, "is-animating"), this.isScaling && C(this.container, "is-scaling")), this.isTicking = !0, this.rAF || (this.rAF = requestAnimationFrame((() => this.animate())))
        }
        panWithMouse(t, i = this.option("mouseMoveFriction")) {
            if (this.pmme = t, this.panMode !== A || !t) return;
            if (e(this.targetScale) <= e(this.minScale)) return;
            this.emit("mouseMove", t);
            const {
                container: n,
                containerRect: s,
                contentRect: o
            } = this, a = s.width, r = s.height, l = n.getBoundingClientRect(), c = (t.clientX || 0) - l.left, h = (t.clientY || 0) - l.top;
            let {
                contentWidth: d,
                contentHeight: u
            } = this.calculateContentDim(this.target);
            const p = this.option("mouseMoveFactor");
            p > 1 && (d !== a && (d *= p), u !== r && (u *= p));
            let f = .5 * (d - a) - c / a * 100 / 100 * (d - a);
            f += .5 * (o.right - o.left);
            let g = .5 * (u - r) - h / r * 100 / 100 * (u - r);
            g += .5 * (o.bottom - o.top), this.applyChange({
                panX: f - this.target.e,
                panY: g - this.target.f,
                friction: i
            })
        }
        zoomWithWheel(t) {
            if (this.state === v.Destroy || this.state === v.Init) return;
            const i = Date.now();
            if (i - this.pwt < 45) return void t.preventDefault();
            this.pwt = i;
            var n = [-t.deltaX || 0, -t.deltaY || 0, -t.detail || 0].reduce((function(t, e) {
                return Math.abs(e) > Math.abs(t) ? e : t
            }));
            const s = Math.max(-1, Math.min(1, n)),
                {
                    targetScale: o,
                    maxScale: a,
                    minScale: r
                } = this;
            let l = o * (100 + 45 * s) / 100;
            e(l) < e(r) && e(o) <= e(r) ? (this.cwd += Math.abs(s), l = r) : e(l) > e(a) && e(o) >= e(a) ? (this.cwd += Math.abs(s), l = a) : (this.cwd = 0, l = Math.max(Math.min(l, a), r)), this.cwd > this.option("wheelLimit") || (t.preventDefault(), e(l) !== e(o) && this.zoomTo(l, {
                event: t
            }))
        }
        canZoomIn() {
            return this.option("zoom") && (e(this.contentRect.width, 1) < e(this.contentRect.fitWidth, 1) || e(this.targetScale) < e(this.maxScale))
        }
        canZoomOut() {
            return this.option("zoom") && e(this.targetScale) > e(this.minScale)
        }
        zoomIn(t = 1.25, e) {
            this.zoomTo(this.targetScale * t, e)
        }
        zoomOut(t = .8, e) {
            this.zoomTo(this.targetScale * t, e)
        }
        zoomToFit(t) {
            this.zoomTo("fit", t)
        }
        zoomToCover(t) {
            this.zoomTo("cover", t)
        }
        zoomToFull(t) {
            this.zoomTo("full", t)
        }
        zoomToMax(t) {
            this.zoomTo("max", t)
        }
        toggleZoom(t) {
            this.zoomTo(this.getNextScale("toggleZoom"), t)
        }
        toggleMax(t) {
            this.zoomTo(this.getNextScale("toggleMax"), t)
        }
        toggleCover(t) {
            this.zoomTo(this.getNextScale("toggleCover"), t)
        }
        iterateZoom(t) {
            this.zoomTo("next", t)
        }
        zoomTo(t = 1, {
            friction: e = R,
            originX: i = R,
            originY: n = R,
            event: s
        } = {}) {
            if (this.isContentLoading || this.state === v.Destroy) return;
            const {
                targetScale: o,
                fullScale: a,
                maxScale: r,
                coverScale: l
            } = this;
            if (this.stop(), this.panMode === A && (s = this.pmme || s), s || i === R || n === R) {
                const t = this.content.getBoundingClientRect(),
                    e = this.container.getBoundingClientRect(),
                    o = s ? s.clientX : e.left + .5 * e.width,
                    a = s ? s.clientY : e.top + .5 * e.height;
                i = o - t.left - .5 * t.width, n = a - t.top - .5 * t.height
            }
            let c = 1;
            "number" == typeof t ? c = t : "full" === t ? c = a : "cover" === t ? c = l : "max" === t ? c = r : "fit" === t ? c = 1 : "next" === t && (c = this.getNextScale("iterateZoom")), c = c / o || 1, e = e === R ? c > 1 ? .15 : .25 : e, this.applyChange({
                scale: c,
                originX: i,
                originY: n,
                friction: e
            }), s && this.panMode === A && this.panWithMouse(s, e)
        }
        rotateCCW() {
            this.applyChange({
                angle: -90
            })
        }
        rotateCW() {
            this.applyChange({
                angle: 90
            })
        }
        flipX() {
            this.applyChange({
                flipX: !0
            })
        }
        flipY() {
            this.applyChange({
                flipY: !0
            })
        }
        fitX() {
            this.stop("target");
            const {
                containerRect: t,
                contentRect: e,
                target: i
            } = this;
            this.applyChange({
                panX: .5 * t.width - (e.left + .5 * e.fitWidth) - i.e,
                panY: .5 * t.height - (e.top + .5 * e.fitHeight) - i.f,
                scale: t.width / e.fitWidth / this.targetScale,
                originX: 0,
                originY: 0,
                ignoreBounds: !0
            })
        }
        fitY() {
            this.stop("target");
            const {
                containerRect: t,
                contentRect: e,
                target: i
            } = this;
            this.applyChange({
                panX: .5 * t.width - (e.left + .5 * e.fitWidth) - i.e,
                panY: .5 * t.innerHeight - (e.top + .5 * e.fitHeight) - i.f,
                scale: t.height / e.fitHeight / this.targetScale,
                originX: 0,
                originY: 0,
                ignoreBounds: !0
            })
        }
        toggleFS() {
            const {
                container: t
            } = this, e = this.cn("inFullscreen"), i = this.cn("htmlHasFullscreen");
            t.classList.toggle(e);
            const n = t.classList.contains(e);
            n ? (document.documentElement.classList.add(i), document.addEventListener("keydown", this.onKeydown, !0)) : (document.documentElement.classList.remove(i), document.removeEventListener("keydown", this.onKeydown, !0)), this.updateMetrics(), this.emit(n ? "enterFS" : "exitFS")
        }
        getMatrix(t = this.current) {
            const {
                a: e,
                b: i,
                c: n,
                d: s,
                e: o,
                f: a
            } = t;
            return new DOMMatrix([e, i, n, s, o, a])
        }
        reset(t) {
            if (this.state !== v.Init && this.state !== v.Destroy) {
                this.stop("current");
                for (const t of b) this.target[t] = T[t];
                this.target.a = this.minScale, this.target.d = this.minScale, this.clampTargetBounds(), this.isResting || (this.friction = void 0 === t ? this.option("friction") : t, this.state = v.Panning, this.requestTick())
            }
        }
        destroy() {
            this.stop(), this.state = v.Destroy, this.detachEvents(), this.detachObserver();
            const {
                container: t,
                content: e
            } = this, i = this.option("classes") || {};
            for (const e of Object.values(i)) t.classList.remove(e + "");
            e && (e.removeEventListener("load", this.onLoad), e.removeEventListener("error", this.onError)), this.detachPlugins()
        }
    }
    Object.defineProperty(D, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: w
    }), Object.defineProperty(D, "Plugins", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {}
    });
    const F = function(t, e) {
            let i = !0;
            return (...n) => {
                i && (i = !1, t(...n), setTimeout((() => {
                    i = !0
                }), e))
            }
        },
        j = (t, e) => {
            let i = [];
            return t.childNodes.forEach((t => {
                t.nodeType !== Node.ELEMENT_NODE || e && !t.matches(e) || i.push(t)
            })), i
        },
        B = {
            viewport: null,
            track: null,
            enabled: !0,
            slides: [],
            axis: "x",
            transition: "fade",
            preload: 1,
            slidesPerPage: "auto",
            initialPage: 0,
            friction: .12,
            Panzoom: {
                decelFriction: .12
            },
            center: !0,
            infinite: !0,
            fill: !0,
            dragFree: !1,
            adaptiveHeight: !1,
            direction: "ltr",
            classes: {
                container: "f-carousel",
                viewport: "f-carousel__viewport",
                track: "f-carousel__track",
                slide: "f-carousel__slide",
                isLTR: "is-ltr",
                isRTL: "is-rtl",
                isHorizontal: "is-horizontal",
                isVertical: "is-vertical",
                inTransition: "in-transition",
                isSelected: "is-selected"
            },
            l10n: {
                NEXT: "Next slide",
                PREV: "Previous slide",
                GOTO: "Go to slide #%d"
            }
        };
    var H;
    ! function(t) {
        t[t.Init = 0] = "Init", t[t.Ready = 1] = "Ready", t[t.Destroy = 2] = "Destroy"
    }(H || (H = {}));
    const N = t => {
            if ("string" == typeof t || t instanceof HTMLElement) t = {
                html: t
            };
            else {
                const e = t.thumb;
                void 0 !== e && ("string" == typeof e && (t.thumbSrc = e), e instanceof HTMLImageElement && (t.thumbEl = e, t.thumbElSrc = e.src, t.thumbSrc = e.src), delete t.thumb)
            }
            return Object.assign({
                html: "",
                el: null,
                isDom: !1,
                class: "",
                customClass: "",
                index: -1,
                dim: 0,
                gap: 0,
                pos: 0,
                transition: !1
            }, t)
        },
        _ = (t = {}) => Object.assign({
            index: -1,
            slides: [],
            dim: 0,
            pos: -1
        }, t);
    class $ extends g {
        constructor(t, e) {
            super(e), Object.defineProperty(this, "instance", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: t
            })
        }
        attach() {}
        detach() {}
    }
    const W = {
        classes: {
            list: "f-carousel__dots",
            isDynamic: "is-dynamic",
            hasDots: "has-dots",
            dot: "f-carousel__dot",
            isBeforePrev: "is-before-prev",
            isPrev: "is-prev",
            isCurrent: "is-current",
            isNext: "is-next",
            isAfterNext: "is-after-next"
        },
        dotTpl: '<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>',
        dynamicFrom: 11,
        maxCount: 1 / 0,
        minCount: 2
    };
    class X extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "isDynamic", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            }), Object.defineProperty(this, "list", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            })
        }
        onRefresh() {
            this.refresh()
        }
        build() {
            let t = this.list;
            if (!t) {
                t = document.createElement("ul"), C(t, this.cn("list")), t.setAttribute("role", "tablist");
                const e = this.instance.container;
                e.appendChild(t), C(e, this.cn("hasDots")), this.list = t
            }
            return t
        }
        refresh() {
            var t;
            const e = this.instance.pages.length,
                i = Math.min(2, this.option("minCount")),
                n = Math.max(2e3, this.option("maxCount")),
                s = this.option("dynamicFrom");
            if (e < i || e > n) return void this.cleanup();
            const o = "number" == typeof s && e > 5 && e >= s,
                r = !this.list || this.isDynamic !== o || this.list.children.length !== e;
            r && this.cleanup();
            const l = this.build();
            if (a(l, this.cn("isDynamic"), !!o), r)
                for (let t = 0; t < e; t++) l.append(this.createItem(t));
            let c, h = 0;
            for (const e of [...l.children]) {
                const i = h === this.instance.page;
                i && (c = e), a(e, this.cn("isCurrent"), i), null === (t = e.children[0]) || void 0 === t || t.setAttribute("aria-selected", i ? "true" : "false");
                for (const t of ["isBeforePrev", "isPrev", "isNext", "isAfterNext"]) P(e, this.cn(t));
                h++
            }
            if (c = c || l.firstChild, o && c) {
                const t = c.previousElementSibling,
                    e = t && t.previousElementSibling;
                C(t, this.cn("isPrev")), C(e, this.cn("isBeforePrev"));
                const i = c.nextElementSibling,
                    n = i && i.nextElementSibling;
                C(i, this.cn("isNext")), C(n, this.cn("isAfterNext"))
            }
            this.isDynamic = o
        }
        createItem(t = 0) {
            var e;
            const i = document.createElement("li");
            i.setAttribute("role", "presentation");
            const n = s(this.instance.localize(this.option("dotTpl"), [
                ["%d", t + 1]
            ]).replace(/\%i/g, t + ""));
            return i.appendChild(n), null === (e = i.children[0]) || void 0 === e || e.setAttribute("role", "tab"), i
        }
        cleanup() {
            this.list && (this.list.remove(), this.list = null), this.isDynamic = !1, P(this.instance.container, this.cn("hasDots"))
        }
        attach() {
            this.instance.on(["refresh", "change"], this.onRefresh)
        }
        detach() {
            this.instance.off(["refresh", "change"], this.onRefresh), this.cleanup()
        }
    }
    Object.defineProperty(X, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: W
    });
    const q = "disabled",
        Y = "next",
        V = "prev";
    class Z extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "container", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "prev", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "next", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "isDom", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            })
        }
        onRefresh() {
            const t = this.instance,
                e = t.pages.length,
                i = t.page;
            if (e < 2) return void this.cleanup();
            this.build();
            let n = this.prev,
                s = this.next;
            n && s && (n.removeAttribute(q), s.removeAttribute(q), t.isInfinite || (i <= 0 && n.setAttribute(q, ""), i >= e - 1 && s.setAttribute(q, "")))
        }
        addBtn(t) {
            var e;
            const i = this.instance,
                n = document.createElement("button");
            n.setAttribute("tabindex", "0"), n.setAttribute("title", i.localize(`{{${t.toUpperCase()}}}`)), C(n, this.cn("button") + " " + this.cn(t === Y ? "isNext" : "isPrev"));
            const s = i.isRTL ? t === Y ? V : Y : t;
            var o;
            return n.innerHTML = i.localize(this.option(`${s}Tpl`)), n.dataset[`carousel${o=t,o?o.match("^[a-z]")?o.charAt(0).toUpperCase()+o.substring(1):o:""}`] = "true", null === (e = this.container) || void 0 === e || e.appendChild(n), n
        }
        build() {
            const t = this.instance.container,
                e = this.cn("container");
            let {
                container: i,
                prev: n,
                next: s
            } = this;
            i || (i = t.querySelector("." + e), this.isDom = !!i), i || (i = document.createElement("div"), C(i, e), t.appendChild(i)), this.container = i, s || (s = i.querySelector("[data-carousel-next]")), s || (s = this.addBtn(Y)), this.next = s, n || (n = i.querySelector("[data-carousel-prev]")), n || (n = this.addBtn(V)), this.prev = n
        }
        cleanup() {
            this.isDom || (this.prev && this.prev.remove(), this.next && this.next.remove(), this.container && this.container.remove()), this.prev = null, this.next = null, this.container = null, this.isDom = !1
        }
        attach() {
            this.instance.on(["refresh", "change"], this.onRefresh)
        }
        detach() {
            this.instance.off(["refresh", "change"], this.onRefresh), this.cleanup()
        }
    }
    Object.defineProperty(Z, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {
            classes: {
                container: "f-carousel__nav",
                button: "f-button",
                isNext: "is-next",
                isPrev: "is-prev"
            },
            nextTpl: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',
            prevTpl: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>'
        }
    });
    class U extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "selectedIndex", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "target", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "nav", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            })
        }
        addAsTargetFor(t) {
            this.target = this.instance, this.nav = t, this.attachEvents()
        }
        addAsNavFor(t) {
            this.nav = this.instance, this.target = t, this.attachEvents()
        }
        attachEvents() {
            const {
                nav: t,
                target: e
            } = this;
            t && e && (t.options.initialSlide = e.options.initialPage, t.state === H.Ready ? this.onNavReady(t) : t.on("ready", this.onNavReady), e.state === H.Ready ? this.onTargetReady(e) : e.on("ready", this.onTargetReady))
        }
        onNavReady(t) {
            t.on("createSlide", this.onNavCreateSlide), t.on("Panzoom.click", this.onNavClick), t.on("Panzoom.touchEnd", this.onNavTouch), this.onTargetChange()
        }
        onTargetReady(t) {
            t.on("change", this.onTargetChange), t.on("Panzoom.refresh", this.onTargetChange), this.onTargetChange()
        }
        onNavClick(t, e, i) {
            this.onNavTouch(t, t.panzoom, i)
        }
        onNavTouch(t, e, i) {
            var n, s;
            if (Math.abs(e.dragOffset.x) > 3 || Math.abs(e.dragOffset.y) > 3) return;
            const o = i.target,
                {
                    nav: a,
                    target: r
                } = this;
            if (!a || !r || !o) return;
            const l = o.closest("[data-index]");
            if (i.stopPropagation(), i.preventDefault(), !l) return;
            const c = parseInt(l.dataset.index || "", 10) || 0,
                h = r.getPageForSlide(c),
                d = a.getPageForSlide(c);
            a.slideTo(d), r.slideTo(h, {
                friction: (null === (s = null === (n = this.nav) || void 0 === n ? void 0 : n.plugins) || void 0 === s ? void 0 : s.Sync.option("friction")) || 0
            }), this.markSelectedSlide(c)
        }
        onNavCreateSlide(t, e) {
            e.index === this.selectedIndex && this.markSelectedSlide(e.index)
        }
        onTargetChange() {
            var t, e;
            const {
                target: i,
                nav: n
            } = this;
            if (!i || !n) return;
            if (n.state !== H.Ready || i.state !== H.Ready) return;
            const s = null === (e = null === (t = i.pages[i.page]) || void 0 === t ? void 0 : t.slides[0]) || void 0 === e ? void 0 : e.index,
                o = n.getPageForSlide(s);
            this.markSelectedSlide(s), n.slideTo(o, null === n.prevPage && null === i.prevPage ? {
                friction: 0
            } : void 0)
        }
        markSelectedSlide(t) {
            const e = this.nav;
            e && e.state === H.Ready && (this.selectedIndex = t, [...e.slides].map((e => {
                e.el && e.el.classList[e.index === t ? "add" : "remove"]("is-nav-selected")
            })))
        }
        attach() {
            const t = this;
            let e = t.options.target,
                i = t.options.nav;
            e ? t.addAsNavFor(e) : i && t.addAsTargetFor(i)
        }
        detach() {
            const t = this,
                e = t.nav,
                i = t.target;
            e && (e.off("ready", t.onNavReady), e.off("createSlide", t.onNavCreateSlide), e.off("Panzoom.click", t.onNavClick), e.off("Panzoom.touchEnd", t.onNavTouch)), t.nav = null, i && (i.off("ready", t.onTargetReady), i.off("refresh", t.onTargetChange), i.off("change", t.onTargetChange)), t.target = null
        }
    }
    Object.defineProperty(U, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {
            friction: .35
        }
    });
    const G = {
            Navigation: Z,
            Dots: X,
            Sync: U
        },
        K = "animationend",
        J = "isSelected",
        Q = "slide";
    class tt extends m {
        get axis() {
            return this.isHorizontal ? "e" : "f"
        }
        get isEnabled() {
            return this.state === H.Ready
        }
        get isInfinite() {
            let t = !1;
            const {
                contentDim: e,
                viewportDim: i,
                pages: n,
                slides: s
            } = this, o = s[0];
            return n.length >= 2 && o && e + o.dim >= i && (t = this.option("infinite")), t
        }
        get isRTL() {
            return "rtl" === this.option("direction")
        }
        get isHorizontal() {
            return "x" === this.option("axis")
        }
        constructor(t, e = {}, i = {}) {
            if (super(), Object.defineProperty(this, "bp", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: ""
                }), Object.defineProperty(this, "lp", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "userOptions", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {}
                }), Object.defineProperty(this, "userPlugins", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: {}
                }), Object.defineProperty(this, "state", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: H.Init
                }), Object.defineProperty(this, "page", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "prevPage", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "container", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: void 0
                }), Object.defineProperty(this, "viewport", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "track", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "slides", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: []
                }), Object.defineProperty(this, "pages", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: []
                }), Object.defineProperty(this, "panzoom", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: null
                }), Object.defineProperty(this, "inTransition", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: new Set
                }), Object.defineProperty(this, "contentDim", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), Object.defineProperty(this, "viewportDim", {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: 0
                }), "string" == typeof t && (t = document.querySelector(t)), !t || !S(t)) throw new Error("No Element found");
            this.container = t, this.slideNext = F(this.slideNext.bind(this), 150), this.slidePrev = F(this.slidePrev.bind(this), 150), this.userOptions = e, this.userPlugins = i, queueMicrotask((() => {
                this.processOptions()
            }))
        }
        processOptions() {
            var t, e;
            const i = p({}, tt.defaults, this.userOptions);
            let n = "";
            const s = i.breakpoints;
            if (s && u(s))
                for (const [t, e] of Object.entries(s)) window.matchMedia(t).matches && u(e) && (n += t, p(i, e));
            n === this.bp && this.state !== H.Init || (this.bp = n, this.state === H.Ready && (i.initialSlide = (null === (e = null === (t = this.pages[this.page]) || void 0 === t ? void 0 : t.slides[0]) || void 0 === e ? void 0 : e.index) || 0), this.state !== H.Init && this.destroy(), super.setOptions(i), !1 === this.option("enabled") ? this.attachEvents() : setTimeout((() => {
                this.init()
            }), 0))
        }
        init() {
            this.state = H.Init, this.emit("init"), this.attachPlugins(Object.assign(Object.assign({}, tt.Plugins), this.userPlugins)), this.emit("attachPlugins"), this.initLayout(), this.initSlides(), this.updateMetrics(), this.setInitialPosition(), this.initPanzoom(), this.attachEvents(), this.state = H.Ready, this.emit("ready")
        }
        initLayout() {
            const {
                container: t
            } = this, e = this.option("classes");
            C(t, this.cn("container")), a(t, e.isLTR, !this.isRTL), a(t, e.isRTL, this.isRTL), a(t, e.isVertical, !this.isHorizontal), a(t, e.isHorizontal, this.isHorizontal);
            let i = this.option("viewport") || t.querySelector(`.${e.viewport}`);
            i || (i = document.createElement("div"), C(i, e.viewport), i.append(...j(t, `.${e.slide}`)), t.prepend(i)), i.addEventListener("scroll", this.onScroll);
            let n = this.option("track") || t.querySelector(`.${e.track}`);
            n || (n = document.createElement("div"), C(n, e.track), n.append(...Array.from(i.childNodes))), n.setAttribute("aria-live", "polite"), i.contains(n) || i.prepend(n), this.viewport = i, this.track = n, this.emit("initLayout")
        }
        initSlides() {
            const {
                track: t
            } = this;
            if (!t) return;
            const e = [...this.slides],
                i = [];
            [...j(t, `.${this.cn(Q)}`)].forEach((t => {
                if (S(t)) {
                    const e = N({
                        el: t,
                        isDom: !0,
                        index: this.slides.length
                    });
                    i.push(e)
                }
            }));
            for (let t of [...this.option("slides", []) || [], ...e]) i.push(N(t));
            this.slides = i;
            for (let t = 0; t < this.slides.length; t++) this.slides[t].index = t;
            for (const t of i) this.emit("beforeInitSlide", t, t.index), this.emit("initSlide", t, t.index);
            this.emit("initSlides")
        }
        setInitialPage() {
            const t = this.option("initialSlide");
            this.page = "number" == typeof t ? this.getPageForSlide(t) : parseInt(this.option("initialPage", 0) + "", 10) || 0
        }
        setInitialPosition() {
            const {
                track: t,
                pages: e,
                isHorizontal: i
            } = this;
            if (!t || !e.length) return;
            let n = this.page;
            e[n] || (this.page = n = 0);
            const s = (e[n].pos || 0) * (this.isRTL && i ? 1 : -1),
                o = i ? `${s}px` : "0",
                a = i ? "0" : `${s}px`;
            t.style.transform = `translate3d(${o}, ${a}, 0) scale(1)`, this.option("adaptiveHeight") && this.setViewportHeight()
        }
        initPanzoom() {
            this.panzoom && (this.panzoom.destroy(), this.panzoom = null);
            const t = this.option("Panzoom") || {};
            this.panzoom = new D(this.viewport, p({}, {
                content: this.track,
                zoom: !1,
                panOnlyZoomed: !1,
                lockAxis: this.isHorizontal ? "x" : "y",
                infinite: this.isInfinite,
                click: !1,
                dblClick: !1,
                touch: t => !(this.pages.length < 2 && !t.options.infinite),
                bounds: () => this.getBounds(),
                maxVelocity: t => Math.abs(t.target[this.axis] - t.current[this.axis]) < 2 * this.viewportDim ? 100 : 0
            }, t)), this.panzoom.on("*", ((t, e, ...i) => {
                this.emit(`Panzoom.${e}`, t, ...i)
            })), this.panzoom.on("decel", this.onDecel), this.panzoom.on("refresh", this.onRefresh), this.panzoom.on("beforeTransform", this.onBeforeTransform), this.panzoom.on("endAnimation", this.onEndAnimation)
        }
        attachEvents() {
            const t = this.container;
            t && (t.addEventListener("click", this.onClick, {
                passive: !1,
                capture: !1
            }), t.addEventListener("slideTo", this.onSlideTo)), window.addEventListener("resize", this.onResize)
        }
        createPages() {
            let t = [];
            const {
                contentDim: e,
                viewportDim: i
            } = this;
            let n = this.option("slidesPerPage");
            n = ("auto" === n || e <= i) && !1 !== this.option("fill") ? 1 / 0 : parseFloat(n + "");
            let s = 0,
                o = 0,
                a = 0;
            for (const e of this.slides)(!t.length || o + e.dim - i > .05 || a >= n) && (t.push(_()), s = t.length - 1, o = 0, a = 0), t[s].slides.push(e), o += e.dim + e.gap, a++;
            return t
        }
        processPages() {
            const t = this.pages,
                {
                    contentDim: i,
                    viewportDim: n,
                    isInfinite: s
                } = this,
                o = this.option("center"),
                a = this.option("fill"),
                r = a && o && i > n && !s;
            if (t.forEach(((t, e) => {
                    var s;
                    t.index = e, t.pos = (null === (s = t.slides[0]) || void 0 === s ? void 0 : s.pos) || 0, t.dim = 0;
                    for (const [e, i] of t.slides.entries()) t.dim += i.dim, e < t.slides.length - 1 && (t.dim += i.gap);
                    r && t.pos + .5 * t.dim < .5 * n ? t.pos = 0 : r && t.pos + .5 * t.dim >= i - .5 * n ? t.pos = i - n : o && (t.pos += -.5 * (n - t.dim))
                })), t.forEach((t => {
                    a && !s && i > n && (t.pos = Math.max(t.pos, 0), t.pos = Math.min(t.pos, i - n)), t.pos = e(t.pos, 1e3), t.dim = e(t.dim, 1e3), Math.abs(t.pos) <= .1 && (t.pos = 0)
                })), s) return t;
            const l = [];
            let c;
            return t.forEach((t => {
                const e = Object.assign({}, t);
                c && e.pos === c.pos ? (c.dim += e.dim, c.slides = [...c.slides, ...e.slides]) : (e.index = l.length, c = e, l.push(e))
            })), l
        }
        getPageFromIndex(t = 0) {
            const e = this.pages.length;
            let i;
            return t = parseInt((t || 0).toString()) || 0, i = this.isInfinite ? (t % e + e) % e : Math.max(Math.min(t, e - 1), 0), i
        }
        getSlideMetrics(t) {
            var i, n;
            const s = this.isHorizontal ? "width" : "height";
            let o = 0,
                a = 0,
                r = t.el;
            const l = !(!r || r.parentNode);
            if (r ? o = parseFloat(r.dataset[s] || "") || 0 : (r = document.createElement("div"), r.style.visibility = "hidden", (this.track || document.body).prepend(r)), C(r, this.cn(Q) + " " + t.class + " " + t.customClass), o) r.style[s] = `${o}px`, r.style["width" === s ? "height" : "width"] = "";
            else {
                l && (this.track || document.body).prepend(r), o = r.getBoundingClientRect()[s] * Math.max(1, (null === (i = window.visualViewport) || void 0 === i ? void 0 : i.scale) || 1);
                let t = r[this.isHorizontal ? "offsetWidth" : "offsetHeight"];
                t - 1 > o && (o = t)
            }
            const c = getComputedStyle(r);
            return "content-box" === c.boxSizing && (this.isHorizontal ? (o += parseFloat(c.paddingLeft) || 0, o += parseFloat(c.paddingRight) || 0) : (o += parseFloat(c.paddingTop) || 0, o += parseFloat(c.paddingBottom) || 0)), a = parseFloat(c[this.isHorizontal ? "marginRight" : "marginBottom"]) || 0, l ? null === (n = r.parentElement) || void 0 === n || n.removeChild(r) : t.el || r.remove(), {
                dim: e(o, 1e3),
                gap: e(a, 1e3)
            }
        }
        getBounds() {
            const {
                isInfinite: t,
                isRTL: e,
                isHorizontal: i,
                pages: n
            } = this;
            let s = {
                min: 0,
                max: 0
            };
            if (t) s = {
                min: -1 / 0,
                max: 1 / 0
            };
            else if (n.length) {
                const t = n[0].pos,
                    o = n[n.length - 1].pos;
                s = e && i ? {
                    min: t,
                    max: o
                } : {
                    min: -1 * o,
                    max: -1 * t
                }
            }
            return {
                x: i ? s : {
                    min: 0,
                    max: 0
                },
                y: i ? {
                    min: 0,
                    max: 0
                } : s
            }
        }
        repositionSlides() {
            let t, {
                    isHorizontal: i,
                    isRTL: n,
                    isInfinite: s,
                    viewport: o,
                    viewportDim: a,
                    contentDim: r,
                    page: l,
                    pages: c,
                    slides: h,
                    panzoom: d
                } = this,
                u = 0,
                p = 0,
                f = 0,
                g = 0;
            d ? g = -1 * d.current[this.axis] : c[l] && (g = c[l].pos || 0), t = i ? n ? "right" : "left" : "top", n && i && (g *= -1);
            for (const i of h) {
                const n = i.el;
                n ? ("top" === t ? (n.style.right = "", n.style.left = "") : n.style.top = "", i.index !== u ? n.style[t] = 0 === p ? "" : `${e(p,1e3)}px` : n.style[t] = "", f += i.dim + i.gap, u++) : p += i.dim + i.gap
            }
            if (s && f && o) {
                let n = getComputedStyle(o),
                    s = "padding",
                    l = i ? "Right" : "Bottom",
                    c = parseFloat(n[s + (i ? "Left" : "Top")]);
                g -= c, a += c, a += parseFloat(n[s + l]);
                for (const i of h) i.el && (e(i.pos) < e(a) && e(i.pos + i.dim + i.gap) < e(g) && e(g) > e(r - a) && (i.el.style[t] = `${e(p+f,1e3)}px`), e(i.pos + i.gap) >= e(r - a) && e(i.pos) > e(g + a) && e(g) < e(a) && (i.el.style[t] = `-${e(f,1e3)}px`))
            }
            let m, v, b = [...this.inTransition];
            if (b.length > 1 && (m = c[b[0]], v = c[b[1]]), m && v) {
                let i = 0;
                for (const n of h) n.el ? this.inTransition.has(n.index) && m.slides.indexOf(n) < 0 && (n.el.style[t] = `${e(i+(m.pos-v.pos),1e3)}px`) : i += n.dim + n.gap
            }
        }
        createSlideEl(t) {
            const {
                track: e,
                slides: i
            } = this;
            if (!e || !t) return;
            if (t.el && t.el.parentNode) return;
            const n = t.el || document.createElement("div");
            C(n, this.cn(Q)), C(n, t.class), C(n, t.customClass);
            const s = t.html;
            s && (s instanceof HTMLElement ? n.appendChild(s) : n.innerHTML = t.html + "");
            const o = [];
            i.forEach(((t, e) => {
                t.el && o.push(e)
            }));
            const a = t.index;
            let r = null;
            if (o.length) {
                r = i[o.reduce(((t, e) => Math.abs(e - a) < Math.abs(t - a) ? e : t))]
            }
            const l = r && r.el && r.el.parentNode ? r.index < t.index ? r.el.nextSibling : r.el : null;
            e.insertBefore(n, e.contains(l) ? l : null), t.el = n, this.emit("createSlide", t)
        }
        removeSlideEl(t, e = !1) {
            const i = null == t ? void 0 : t.el;
            if (!i || !i.parentNode) return;
            const n = this.cn(J);
            if (i.classList.contains(n) && (P(i, n), this.emit("unselectSlide", t)), t.isDom && !e) return i.removeAttribute("aria-hidden"), i.removeAttribute("data-index"), void(i.style.left = "");
            this.emit("removeSlide", t);
            const s = new CustomEvent(K);
            i.dispatchEvent(s), t.el && (t.el.remove(), t.el = null)
        }
        transitionTo(t = 0, e = this.option("transition")) {
            var i, n, s, o;
            if (!e) return !1;
            const a = this.page,
                {
                    pages: r,
                    panzoom: l
                } = this;
            t = parseInt((t || 0).toString()) || 0;
            const c = this.getPageFromIndex(t);
            if (!l || !r[c] || r.length < 2 || Math.abs(((null === (n = null === (i = r[a]) || void 0 === i ? void 0 : i.slides[0]) || void 0 === n ? void 0 : n.dim) || 0) - this.viewportDim) > 1) return !1;
            let h = t > a ? 1 : -1;
            this.isInfinite && (0 === a && t === r.length - 1 && (h = -1), a === r.length - 1 && 0 === t && (h = 1));
            const d = r[c].pos * (this.isRTL ? 1 : -1);
            if (a === c && Math.abs(d - l.target[this.axis]) < 1) return !1;
            this.clearTransitions();
            const u = l.isResting;
            C(this.container, this.cn("inTransition"));
            const p = (null === (s = r[a]) || void 0 === s ? void 0 : s.slides[0]) || null,
                f = (null === (o = r[c]) || void 0 === o ? void 0 : o.slides[0]) || null;
            this.inTransition.add(f.index), this.createSlideEl(f);
            let g = p.el,
                m = f.el;
            u || e === Q || (e = "fadeFast", g = null);
            const v = this.isRTL ? "next" : "prev",
                b = this.isRTL ? "prev" : "next";
            return g && (this.inTransition.add(p.index), p.transition = e, g.addEventListener(K, this.onAnimationEnd), g.classList.add(`f-${e}Out`, `to-${h>0?b:v}`)), m && (f.transition = e, m.addEventListener(K, this.onAnimationEnd), m.classList.add(`f-${e}In`, `from-${h>0?v:b}`)), l.current[this.axis] = d, l.target[this.axis] = d, l.requestTick(), this.onChange(c), !0
        }
        manageSlideVisiblity() {
            const t = new Set,
                e = new Set,
                i = this.getVisibleSlides(parseFloat(this.option("preload", 0) + "") || 0);
            for (const n of this.slides) i.has(n) ? t.add(n) : e.add(n);
            for (const e of this.inTransition) t.add(this.slides[e]);
            for (const e of t) this.createSlideEl(e), this.lazyLoadSlide(e);
            for (const i of e) t.has(i) || this.removeSlideEl(i);
            this.markSelectedSlides(), this.repositionSlides()
        }
        markSelectedSlides() {
            if (!this.pages[this.page] || !this.pages[this.page].slides) return;
            const t = "aria-hidden";
            let e = this.cn(J);
            if (e)
                for (const i of this.slides) {
                    const n = i.el;
                    n && (n.dataset.index = `${i.index}`, n.classList.contains("f-thumbs__slide") ? this.getVisibleSlides(0).has(i) ? n.removeAttribute(t) : n.setAttribute(t, "true") : this.pages[this.page].slides.includes(i) ? (n.classList.contains(e) || (C(n, e), this.emit("selectSlide", i)), n.removeAttribute(t)) : (n.classList.contains(e) && (P(n, e), this.emit("unselectSlide", i)), n.setAttribute(t, "true")))
                }
        }
        flipInfiniteTrack() {
            const {
                axis: t,
                isHorizontal: e,
                isInfinite: i,
                isRTL: n,
                viewportDim: s,
                contentDim: o
            } = this, a = this.panzoom;
            if (!a || !i) return;
            let r = a.current[t],
                l = a.target[t] - r,
                c = 0,
                h = .5 * s;
            n && e ? (r < -h && (c = -1, r += o), r > o - h && (c = 1, r -= o)) : (r > h && (c = 1, r -= o), r < -o + h && (c = -1, r += o)), c && (a.current[t] = r, a.target[t] = r + l)
        }
        lazyLoadImg(t, e) {
            const i = this,
                n = "f-fadeIn",
                o = "is-preloading";
            let a = !1,
                r = null;
            const l = () => {
                a || (a = !0, r && (r.remove(), r = null), P(e, o), e.complete && (C(e, n), setTimeout((() => {
                    P(e, n)
                }), 350)), this.option("adaptiveHeight") && t.el && this.pages[this.page].slides.indexOf(t) > -1 && (i.updateMetrics(), i.setViewportHeight()), this.emit("load", t))
            };
            C(e, o), e.src = e.dataset.lazySrcset || e.dataset.lazySrc || "", delete e.dataset.lazySrc, delete e.dataset.lazySrcset, e.addEventListener("error", (() => {
                l()
            })), e.addEventListener("load", (() => {
                l()
            })), setTimeout((() => {
                const i = e.parentNode;
                i && t.el && (e.complete ? l() : a || (r = s(E), i.insertBefore(r, e)))
            }), 300)
        }
        lazyLoadSlide(t) {
            const e = t && t.el;
            if (!e) return;
            const i = new Set;
            let n = Array.from(e.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));
            e.dataset.lazySrc && n.push(e), n.map((t => {
                t instanceof HTMLImageElement ? i.add(t) : t instanceof HTMLElement && t.dataset.lazySrc && (t.style.backgroundImage = `url('${t.dataset.lazySrc}')`, delete t.dataset.lazySrc)
            }));
            for (const e of i) this.lazyLoadImg(t, e)
        }
        onAnimationEnd(t) {
            var e;
            const i = t.target,
                n = i ? parseInt(i.dataset.index || "", 10) || 0 : -1,
                s = this.slides[n],
                o = t.animationName;
            if (!i || !s || !o) return;
            const a = !!this.inTransition.has(n) && s.transition;
            a && o.substring(0, a.length + 2) === `f-${a}` && this.inTransition.delete(n), this.inTransition.size || this.clearTransitions(), n === this.page && (null === (e = this.panzoom) || void 0 === e ? void 0 : e.isResting) && this.emit("settle")
        }
        onDecel(t, e = 0, i = 0, n = 0, s = 0) {
            if (this.option("dragFree")) return void this.setPageFromPosition();
            const {
                isRTL: o,
                isHorizontal: a,
                axis: r,
                pages: l
            } = this, c = l.length, h = Math.abs(Math.atan2(i, e) / (Math.PI / 180));
            let d = 0;
            if (d = h > 45 && h < 135 ? a ? 0 : i : a ? e : 0, !c) return;
            let u = this.page,
                p = o && a ? 1 : -1;
            const f = t.current[r] * p;
            let {
                pageIndex: g
            } = this.getPageFromPosition(f);
            Math.abs(d) > 5 ? (l[u].dim < document.documentElement["client" + (this.isHorizontal ? "Width" : "Height")] - 1 && (u = g), u = o && a ? d < 0 ? u - 1 : u + 1 : d < 0 ? u + 1 : u - 1) : u = 0 === n && 0 === s ? u : g, this.slideTo(u, {
                transition: !1,
                friction: t.option("decelFriction")
            })
        }
        onClick(t) {
            const e = t.target,
                i = e && S(e) ? e.dataset : null;
            let n, s;
            i && (void 0 !== i.carouselPage ? (s = "slideTo", n = i.carouselPage) : void 0 !== i.carouselNext ? s = "slideNext" : void 0 !== i.carouselPrev && (s = "slidePrev")), s ? (t.preventDefault(), t.stopPropagation(), e && !e.hasAttribute("disabled") && this[s](n)) : this.emit("click", t)
        }
        onSlideTo(t) {
            const e = t.detail || 0;
            this.slideTo(this.getPageForSlide(e), {
                friction: 0
            })
        }
        onChange(t, e = 0) {
            const i = this.page;
            this.prevPage = i, this.page = t, this.option("adaptiveHeight") && this.setViewportHeight(), t !== i && (this.markSelectedSlides(), this.emit("change", t, i, e))
        }
        onRefresh() {
            let t = this.contentDim,
                e = this.viewportDim;
            this.updateMetrics(), this.contentDim === t && this.viewportDim === e || this.slideTo(this.page, {
                friction: 0,
                transition: !1
            })
        }
        onScroll() {
            var t;
            null === (t = this.viewport) || void 0 === t || t.scroll(0, 0)
        }
        onResize() {
            this.option("breakpoints") && this.processOptions()
        }
        onBeforeTransform(t) {
            this.lp !== t.current[this.axis] && (this.flipInfiniteTrack(), this.manageSlideVisiblity()), this.lp = t.current.e
        }
        onEndAnimation() {
            this.inTransition.size || this.emit("settle")
        }
        reInit(t = null, e = null) {
            this.destroy(), this.state = H.Init, this.prevPage = null, this.userOptions = t || this.userOptions, this.userPlugins = e || this.userPlugins, this.processOptions()
        }
        slideTo(t = 0, {
            friction: e = this.option("friction"),
            transition: i = this.option("transition")
        } = {}) {
            if (this.state === H.Destroy) return;
            t = parseInt((t || 0).toString()) || 0;
            const n = this.getPageFromIndex(t),
                {
                    axis: s,
                    isHorizontal: o,
                    isRTL: a,
                    pages: r,
                    panzoom: l
                } = this,
                c = r.length,
                h = a && o ? 1 : -1;
            if (!l || !c) return;
            if (this.page !== n) {
                const e = new Event("beforeChange", {
                    bubbles: !0,
                    cancelable: !0
                });
                if (this.emit("beforeChange", e, t), e.defaultPrevented) return
            }
            if (this.transitionTo(t, i)) return;
            let d = r[n].pos;
            if (this.isInfinite) {
                const e = this.contentDim,
                    i = l.target[s] * h;
                if (2 === c) d += e * Math.floor(parseFloat(t + "") / 2);
                else {
                    d = [d, d - e, d + e].reduce((function(t, e) {
                        return Math.abs(e - i) < Math.abs(t - i) ? e : t
                    }))
                }
            }
            d *= h, Math.abs(l.target[s] - d) < 1 || (l.panTo({
                x: o ? d : 0,
                y: o ? 0 : d,
                friction: e
            }), this.onChange(n))
        }
        slideToClosest(t) {
            if (this.panzoom) {
                const {
                    pageIndex: e
                } = this.getPageFromPosition();
                this.slideTo(e, t)
            }
        }
        slideNext() {
            this.slideTo(this.page + 1)
        }
        slidePrev() {
            this.slideTo(this.page - 1)
        }
        clearTransitions() {
            this.inTransition.clear(), P(this.container, this.cn("inTransition"));
            const t = ["to-prev", "to-next", "from-prev", "from-next"];
            for (const e of this.slides) {
                const i = e.el;
                if (i) {
                    i.removeEventListener(K, this.onAnimationEnd), i.classList.remove(...t);
                    const n = e.transition;
                    n && i.classList.remove(`f-${n}Out`, `f-${n}In`)
                }
            }
            this.manageSlideVisiblity()
        }
        addSlide(t, e) {
            var i, n, s, o;
            const a = this.panzoom,
                r = (null === (i = this.pages[this.page]) || void 0 === i ? void 0 : i.pos) || 0,
                l = (null === (n = this.pages[this.page]) || void 0 === n ? void 0 : n.dim) || 0,
                c = this.contentDim < this.viewportDim;
            let h = Array.isArray(e) ? e : [e];
            const d = [];
            for (const t of h) d.push(N(t));
            this.slides.splice(t, 0, ...d);
            for (let t = 0; t < this.slides.length; t++) this.slides[t].index = t;
            for (const t of d) this.emit("beforeInitSlide", t, t.index);
            if (this.page >= t && (this.page += d.length), this.updateMetrics(), a) {
                const e = (null === (s = this.pages[this.page]) || void 0 === s ? void 0 : s.pos) || 0,
                    i = (null === (o = this.pages[this.page]) || void 0 === o ? void 0 : o.dim) || 0,
                    n = this.pages.length || 1,
                    h = this.isRTL ? l - i : i - l,
                    d = this.isRTL ? r - e : e - r;
                c && 1 === n ? (t <= this.page && (a.current[this.axis] -= h, a.target[this.axis] -= h), a.panTo({
                    [this.isHorizontal ? "x" : "y"]: -1 * e
                })) : d && t <= this.page && (a.target[this.axis] -= d, a.current[this.axis] -= d, a.requestTick())
            }
            for (const t of d) this.emit("initSlide", t, t.index)
        }
        prependSlide(t) {
            this.addSlide(0, t)
        }
        appendSlide(t) {
            this.addSlide(this.slides.length, t)
        }
        removeSlide(t) {
            const e = this.slides.length;
            t = (t % e + e) % e;
            const i = this.slides[t];
            if (i) {
                this.removeSlideEl(i, !0), this.slides.splice(t, 1);
                for (let t = 0; t < this.slides.length; t++) this.slides[t].index = t;
                this.updateMetrics(), this.slideTo(this.page, {
                    friction: 0,
                    transition: !1
                }), this.emit("destroySlide", i)
            }
        }
        updateMetrics() {
            const {
                panzoom: t,
                viewport: i,
                track: n,
                slides: s,
                isHorizontal: o,
                isInfinite: a
            } = this;
            if (!n) return;
            const r = o ? "width" : "height",
                l = o ? "offsetWidth" : "offsetHeight";
            if (i) {
                let t = Math.max(i[l], e(i.getBoundingClientRect()[r], 1e3)),
                    n = getComputedStyle(i),
                    s = "padding",
                    a = o ? "Right" : "Bottom";
                t -= parseFloat(n[s + (o ? "Left" : "Top")]) + parseFloat(n[s + a]), this.viewportDim = t
            }
            let c, h = 0;
            for (const [t, i] of s.entries()) {
                let n = 0,
                    o = 0;
                !i.el && c ? (n = c.dim, o = c.gap) : (({
                    dim: n,
                    gap: o
                } = this.getSlideMetrics(i)), c = i), n = e(n, 1e3), o = e(o, 1e3), i.dim = n, i.gap = o, i.pos = h, h += n, (a || t < s.length - 1) && (h += o)
            }
            h = e(h, 1e3), this.contentDim = h, t && (t.contentRect[r] = h, t.contentRect[o ? "fullWidth" : "fullHeight"] = h), this.pages = this.createPages(), this.pages = this.processPages(), this.state === H.Init && this.setInitialPage(), this.page = Math.max(0, Math.min(this.page, this.pages.length - 1)), this.manageSlideVisiblity(), this.emit("refresh")
        }
        getProgress(t, i = !1, n = !1) {
            void 0 === t && (t = this.page);
            const s = this,
                o = s.panzoom,
                a = s.contentDim,
                r = s.pages[t] || 0;
            if (!r || !o) return t > this.page ? -1 : 1;
            let l = -1 * o.current.e,
                c = e((l - r.pos) / (1 * r.dim), 1e3),
                h = c,
                d = c;
            this.isInfinite && !0 !== n && (h = e((l - r.pos + a) / (1 * r.dim), 1e3), d = e((l - r.pos - a) / (1 * r.dim), 1e3));
            let u = [c, h, d].reduce((function(t, e) {
                return Math.abs(e) < Math.abs(t) ? e : t
            }));
            return i ? u : u > 1 ? 1 : u < -1 ? -1 : u
        }
        setViewportHeight() {
            const {
                page: t,
                pages: e,
                viewport: i,
                isHorizontal: n
            } = this;
            if (!i || !e[t]) return;
            let s = 0;
            n && this.track && (this.track.style.height = "auto", e[t].slides.forEach((t => {
                t.el && (s = Math.max(s, t.el.offsetHeight))
            }))), i.style.height = s ? `${s}px` : ""
        }
        getPageForSlide(t) {
            for (const e of this.pages)
                for (const i of e.slides)
                    if (i.index === t) return e.index;
            return -1
        }
        getVisibleSlides(t = 0) {
            var e;
            const i = new Set;
            let {
                panzoom: n,
                contentDim: s,
                viewportDim: o,
                pages: a,
                page: r
            } = this;
            if (o) {
                s = s + (null === (e = this.slides[this.slides.length - 1]) || void 0 === e ? void 0 : e.gap) || 0;
                let l = 0;
                l = n && n.state !== v.Init && n.state !== v.Destroy ? -1 * n.current[this.axis] : a[r] && a[r].pos || 0, this.isInfinite && (l -= Math.floor(l / s) * s), this.isRTL && this.isHorizontal && (l *= -1);
                const c = l - o * t,
                    h = l + o * (t + 1),
                    d = this.isInfinite ? [-1, 0, 1] : [0];
                for (const t of this.slides)
                    for (const e of d) {
                        const n = t.pos + e * s,
                            o = n + t.dim + t.gap;
                        n < h && o > c && i.add(t)
                    }
            }
            return i
        }
        getPageFromPosition(t) {
            const {
                viewportDim: e,
                contentDim: i,
                slides: n,
                pages: s,
                panzoom: o
            } = this, a = s.length, r = n.length, l = n[0], c = n[r - 1], h = this.option("center");
            let d = 0,
                u = 0,
                p = 0,
                f = void 0 === t ? -1 * ((null == o ? void 0 : o.target[this.axis]) || 0) : t;
            h && (f += .5 * e), this.isInfinite ? (f < l.pos - .5 * c.gap && (f -= i, p = -1), f > c.pos + c.dim + .5 * c.gap && (f -= i, p = 1)) : f = Math.max(l.pos || 0, Math.min(f, c.pos));
            let g = c,
                m = n.find((t => {
                    const e = t.pos - .5 * g.gap,
                        i = t.pos + t.dim + .5 * t.gap;
                    return g = t, f >= e && f < i
                }));
            return m || (m = c), u = this.getPageForSlide(m.index), d = u + p * a, {
                page: d,
                pageIndex: u
            }
        }
        setPageFromPosition() {
            const {
                pageIndex: t
            } = this.getPageFromPosition();
            this.onChange(t)
        }
        destroy() {
            if ([H.Destroy].includes(this.state)) return;
            this.state = H.Destroy;
            const {
                container: t,
                viewport: e,
                track: i,
                slides: n,
                panzoom: s
            } = this, o = this.option("classes");
            t.removeEventListener("click", this.onClick, {
                passive: !1,
                capture: !1
            }), t.removeEventListener("slideTo", this.onSlideTo), window.removeEventListener("resize", this.onResize), s && (s.destroy(), this.panzoom = null), n && n.forEach((t => {
                this.removeSlideEl(t)
            })), this.detachPlugins(), e && (e.removeEventListener("scroll", this.onScroll), e.offsetParent && i && i.offsetParent && e.replaceWith(...i.childNodes));
            for (const [e, i] of Object.entries(o)) "container" !== e && i && t.classList.remove(i);
            this.track = null, this.viewport = null, this.page = 0, this.slides = [];
            const a = this.events.get("ready");
            this.events = new Map, a && this.events.set("ready", a)
        }
    }
    Object.defineProperty(tt, "Panzoom", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: D
    }), Object.defineProperty(tt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: B
    }), Object.defineProperty(tt, "Plugins", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: G
    });
    const et = function(t) {
            if (!S(t)) return 0;
            const e = window.scrollY,
                i = window.innerHeight,
                n = e + i,
                s = t.getBoundingClientRect(),
                o = s.y + e,
                a = s.height,
                r = o + a;
            if (e > r || n < o) return 0;
            if (e < o && n > r) return 100;
            if (o < e && r > n) return 100;
            let l = a;
            o < e && (l -= e - o), r > n && (l -= r - n);
            const c = l / i * 100;
            return Math.round(c)
        },
        it = !("undefined" == typeof window || !window.document || !window.document.createElement);
    let nt;
    const st = ["a[href]", "area[href]", 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', "select:not([disabled]):not([aria-hidden])", "textarea:not([disabled]):not([aria-hidden])", "button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)", "iframe", "object", "embed", "video", "audio", "[contenteditable]", '[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","),
        ot = t => {
            if (t && it) {
                void 0 === nt && document.createElement("div").focus({
                    get preventScroll() {
                        return nt = !0, !1
                    }
                });
                try {
                    if (nt) t.focus({
                        preventScroll: !0
                    });
                    else {
                        const e = window.scrollY || document.body.scrollTop,
                            i = window.scrollX || document.body.scrollLeft;
                        t.focus(), document.body.scrollTo({
                            top: e,
                            left: i,
                            behavior: "auto"
                        })
                    }
                } catch (t) {}
            }
        },
        at = () => {
            const t = document;
            let e, i = "",
                n = "",
                s = "";
            return t.fullscreenEnabled ? (i = "requestFullscreen", n = "exitFullscreen", s = "fullscreenElement") : t.webkitFullscreenEnabled && (i = "webkitRequestFullscreen", n = "webkitExitFullscreen", s = "webkitFullscreenElement"), i && (e = {
                request: function(e = t.documentElement) {
                    return "webkitRequestFullscreen" === i ? e[i](Element.ALLOW_KEYBOARD_INPUT) : e[i]()
                },
                exit: function() {
                    return t[s] && t[n]()
                },
                isFullscreen: function() {
                    return t[s]
                }
            }), e
        },
        rt = {
            animated: !0,
            autoFocus: !0,
            backdropClick: "close",
            Carousel: {
                classes: {
                    container: "fancybox__carousel",
                    viewport: "fancybox__viewport",
                    track: "fancybox__track",
                    slide: "fancybox__slide"
                }
            },
            closeButton: "auto",
            closeExisting: !1,
            commonCaption: !1,
            compact: () => window.matchMedia("(max-width: 578px), (max-height: 578px)").matches,
            contentClick: "toggleZoom",
            contentDblClick: !1,
            defaultType: "image",
            defaultDisplay: "flex",
            dragToClose: !0,
            Fullscreen: {
                autoStart: !1
            },
            groupAll: !1,
            groupAttr: "data-fancybox",
            hideClass: "f-fadeOut",
            hideScrollbar: !0,
            idle: 3500,
            keyboard: {
                Escape: "close",
                Delete: "close",
                Backspace: "close",
                PageUp: "next",
                PageDown: "prev",
                ArrowUp: "prev",
                ArrowDown: "next",
                ArrowRight: "next",
                ArrowLeft: "prev"
            },
            l10n: Object.assign(Object.assign({}, y), {
                CLOSE: "Close",
                NEXT: "Next",
                PREV: "Previous",
                MODAL: "You can close this modal content with the ESC key",
                ERROR: "Something Went Wrong, Please Try Again Later",
                IMAGE_ERROR: "Image Not Found",
                ELEMENT_NOT_FOUND: "HTML Element Not Found",
                AJAX_NOT_FOUND: "Error Loading AJAX : Not Found",
                AJAX_FORBIDDEN: "Error Loading AJAX : Forbidden",
                IFRAME_ERROR: "Error Loading Page",
                TOGGLE_ZOOM: "Toggle zoom level",
                TOGGLE_THUMBS: "Toggle thumbnails",
                TOGGLE_SLIDESHOW: "Toggle slideshow",
                TOGGLE_FULLSCREEN: "Toggle full-screen mode",
                DOWNLOAD: "Download"
            }),
            parentEl: null,
            placeFocusBack: !0,
            showClass: "f-zoomInUp",
            startIndex: 0,
            tpl: {
                closeButton: '<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>',
                main: '<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">\n    <div class="fancybox__backdrop"></div>\n    <div class="fancybox__carousel"></div>\n    <div class="fancybox__footer"></div>\n  </div>'
            },
            trapFocus: !0,
            wheel: "zoom"
        };
    var lt, ct;
    ! function(t) {
        t[t.Init = 0] = "Init", t[t.Ready = 1] = "Ready", t[t.Closing = 2] = "Closing", t[t.CustomClosing = 3] = "CustomClosing", t[t.Destroy = 4] = "Destroy"
    }(lt || (lt = {})),
    function(t) {
        t[t.Loading = 0] = "Loading", t[t.Opening = 1] = "Opening", t[t.Ready = 2] = "Ready", t[t.Closing = 3] = "Closing"
    }(ct || (ct = {}));
    let ht = "",
        dt = !1,
        ut = !1,
        pt = null;
    const ft = () => {
            let t = "",
                e = "";
            const i = Ae.getInstance();
            if (i) {
                const n = i.carousel,
                    s = i.getSlide();
                if (n && s) {
                    let o = s.slug || void 0,
                        a = s.triggerEl || void 0;
                    e = o || (i.option("slug") || ""), !e && a && a.dataset && (e = a.dataset.fancybox || ""), e && "true" !== e && (t = "#" + e + (!o && n.slides.length > 1 ? "-" + (s.index + 1) : ""))
                }
            }
            return {
                hash: t,
                slug: e,
                index: 1
            }
        },
        gt = () => {
            const t = new URL(document.URL).hash,
                e = t.slice(1).split("-"),
                i = e[e.length - 1],
                n = i && /^\+?\d+$/.test(i) && parseInt(e.pop() || "1", 10) || 1;
            return {
                hash: t,
                slug: e.join("-"),
                index: n
            }
        },
        mt = () => {
            const {
                slug: t,
                index: e
            } = gt();
            if (!t) return;
            let i = document.querySelector(`[data-slug="${t}"]`);
            if (i && i.dispatchEvent(new CustomEvent("click", {
                    bubbles: !0,
                    cancelable: !0
                })), Ae.getInstance()) return;
            const n = document.querySelectorAll(`[data-fancybox="${t}"]`);
            n.length && (i = n[e - 1], i && i.dispatchEvent(new CustomEvent("click", {
                bubbles: !0,
                cancelable: !0
            })))
        },
        vt = () => {
            if (!1 === Ae.defaults.Hash) return;
            const t = Ae.getInstance();
            if (!1 === (null == t ? void 0 : t.options.Hash)) return;
            const {
                slug: e,
                index: i
            } = gt(), {
                slug: n
            } = ft();
            t && (e === n ? t.jumpTo(i - 1) : (dt = !0, t.close())), mt()
        },
        bt = () => {
            pt && clearTimeout(pt), queueMicrotask((() => {
                vt()
            }))
        },
        yt = () => {
            window.addEventListener("hashchange", bt, !1), setTimeout((() => {
                vt()
            }), 500)
        };
    it && (/complete|interactive|loaded/.test(document.readyState) ? yt() : document.addEventListener("DOMContentLoaded", yt));
    const wt = "is-zooming-in";
    class xt extends $ {
        onCreateSlide(t, e, i) {
            const n = this.instance.optionFor(i, "src") || "";
            i.el && "image" === i.type && "string" == typeof n && this.setImage(i, n)
        }
        onRemoveSlide(t, e, i) {
            i.panzoom && i.panzoom.destroy(), i.panzoom = void 0, i.imageEl = void 0
        }
        onChange(t, e, i, n) {
            P(this.instance.container, wt);
            for (const t of e.slides) {
                const e = t.panzoom;
                e && t.index !== i && e.reset(.35)
            }
        }
        onClose() {
            var t;
            const e = this.instance,
                i = e.container,
                n = e.getSlide();
            if (!i || !i.parentElement || !n) return;
            const {
                el: s,
                contentEl: o,
                panzoom: a,
                thumbElSrc: r
            } = n;
            if (!s || !r || !o || !a || a.isContentLoading || a.state === v.Init || a.state === v.Destroy) return;
            a.updateMetrics();
            let l = this.getZoomInfo(n);
            if (!l) return;
            this.instance.state = lt.CustomClosing, i.classList.remove(wt), i.classList.add("is-zooming-out"), o.style.backgroundImage = `url('${r}')`;
            const c = i.getBoundingClientRect();
            1 === ((null === (t = window.visualViewport) || void 0 === t ? void 0 : t.scale) || 1) && Object.assign(i.style, {
                position: "absolute",
                top: `${i.offsetTop+window.scrollY}px`,
                left: `${i.offsetLeft+window.scrollX}px`,
                bottom: "auto",
                right: "auto",
                width: `${c.width}px`,
                height: `${c.height}px`,
                overflow: "hidden"
            });
            const {
                x: h,
                y: d,
                scale: u,
                opacity: p
            } = l;
            if (p) {
                const t = ((t, e, i, n) => {
                    const s = e - t,
                        o = n - i;
                    return e => i + ((e - t) / s * o || 0)
                })(a.scale, u, 1, 0);
                a.on("afterTransform", (() => {
                    o.style.opacity = t(a.scale) + ""
                }))
            }
            a.on("endAnimation", (() => {
                e.destroy()
            })), a.target.a = u, a.target.b = 0, a.target.c = 0, a.target.d = u, a.panTo({
                x: h,
                y: d,
                scale: u,
                friction: p ? .2 : .33,
                ignoreBounds: !0
            }), a.isResting && e.destroy()
        }
        setImage(t, e) {
            const i = this.instance;
            t.src = e, this.process(t, e).then((e => {
                const {
                    contentEl: n,
                    imageEl: s,
                    thumbElSrc: o,
                    el: a
                } = t;
                if (i.isClosing() || !n || !s) return;
                n.offsetHeight;
                const r = !!i.isOpeningSlide(t) && this.getZoomInfo(t);
                if (this.option("protected") && a) {
                    a.addEventListener("contextmenu", (t => {
                        t.preventDefault()
                    }));
                    const t = document.createElement("div");
                    C(t, "fancybox-protected"), n.appendChild(t)
                }
                if (o && r) {
                    const s = e.contentRect,
                        a = Math.max(s.fullWidth, s.fullHeight);
                    let c = null;
                    !r.opacity && a > 1200 && (c = document.createElement("img"), C(c, "fancybox-ghost"), c.src = o, n.appendChild(c));
                    const h = () => {
                        c && (C(c, "f-fadeFastOut"), setTimeout((() => {
                            c && (c.remove(), c = null)
                        }), 200))
                    };
                    (l = o, new Promise(((t, e) => {
                        const i = new Image;
                        i.onload = t, i.onerror = e, i.src = l
                    }))).then((() => {
                        i.hideLoading(t), t.state = ct.Opening, this.instance.emit("reveal", t), this.zoomIn(t).then((() => {
                            h(), this.instance.done(t)
                        }), (() => {})), c && setTimeout((() => {
                            h()
                        }), a > 2500 ? 800 : 200)
                    }), (() => {
                        i.hideLoading(t), i.revealContent(t)
                    }))
                } else {
                    const n = this.optionFor(t, "initialSize"),
                        s = this.optionFor(t, "zoom"),
                        o = {
                            event: i.prevMouseMoveEvent || i.options.event,
                            friction: s ? .12 : 0
                        };
                    let a = i.optionFor(t, "showClass") || void 0,
                        r = !0;
                    i.isOpeningSlide(t) && ("full" === n ? e.zoomToFull(o) : "cover" === n ? e.zoomToCover(o) : "max" === n ? e.zoomToMax(o) : r = !1, e.stop("current")), r && a && (a = e.isDragging ? "f-fadeIn" : ""), i.hideLoading(t), i.revealContent(t, a)
                }
                var l
            }), (() => {
                i.setError(t, "{{IMAGE_ERROR}}")
            }))
        }
        process(t, e) {
            return new Promise(((i, n) => {
                var o;
                const a = this.instance,
                    r = t.el;
                a.clearContent(t), a.showLoading(t);
                let l = this.optionFor(t, "content");
                if ("string" == typeof l && (l = s(l)), !l || !S(l)) {
                    if (l = document.createElement("img"), l instanceof HTMLImageElement) {
                        let i = "",
                            n = t.caption;
                        i = "string" == typeof n && n ? n.replace(/<[^>]+>/gi, "").substring(0, 1e3) : `Image ${t.index+1} of ${(null===(o=a.carousel)||void 0===o?void 0:o.pages.length)||1}`, l.src = e || "", l.alt = i, l.draggable = !1, t.srcset && l.setAttribute("srcset", t.srcset), this.instance.isOpeningSlide(t) && (l.fetchPriority = "high")
                    }
                    t.sizes && l.setAttribute("sizes", t.sizes)
                }
                C(l, "fancybox-image"), t.imageEl = l, a.setContent(t, l, !1);
                t.panzoom = new D(r, p({
                    transformParent: !0
                }, this.option("Panzoom") || {}, {
                    content: l,
                    width: (e, i) => a.optionFor(t, "width", "auto", i) || "auto",
                    height: (e, i) => a.optionFor(t, "height", "auto", i) || "auto",
                    wheel: () => {
                        const t = a.option("wheel");
                        return ("zoom" === t || "pan" == t) && t
                    },
                    click: (e, i) => {
                        var n, s;
                        if (a.isCompact || a.isClosing()) return !1;
                        if (t.index !== (null === (n = a.getSlide()) || void 0 === n ? void 0 : n.index)) return !1;
                        if (i) {
                            const t = i.composedPath()[0];
                            if (["A", "BUTTON", "TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO"].includes(t.nodeName)) return !1
                        }
                        let o = !i || i.target && (null === (s = t.contentEl) || void 0 === s ? void 0 : s.contains(i.target));
                        return a.option(o ? "contentClick" : "backdropClick") || !1
                    },
                    dblClick: () => a.isCompact ? "toggleZoom" : a.option("contentDblClick") || !1,
                    spinner: !1,
                    panOnlyZoomed: !0,
                    wheelLimit: 1 / 0,
                    on: {
                        ready: t => {
                            i(t)
                        },
                        error: () => {
                            n()
                        },
                        destroy: () => {
                            n()
                        }
                    }
                }))
            }))
        }
        zoomIn(t) {
            return new Promise(((e, i) => {
                const n = this.instance,
                    s = n.container,
                    {
                        panzoom: o,
                        contentEl: a,
                        el: r
                    } = t;
                o && o.updateMetrics();
                const l = this.getZoomInfo(t);
                if (!(l && r && a && o && s)) return void i();
                const {
                    x: c,
                    y: h,
                    scale: d,
                    opacity: u
                } = l, p = () => {
                    t.state !== ct.Closing && (u && (a.style.opacity = Math.max(Math.min(1, 1 - (1 - o.scale) / (1 - d)), 0) + ""), o.scale >= 1 && o.scale > o.targetScale - .1 && e(o))
                }, f = t => {
                    (t.scale < .99 || t.scale > 1.01) && !t.isDragging || (P(s, wt), a.style.opacity = "", t.off("endAnimation", f), t.off("touchStart", f), t.off("afterTransform", p), e(t))
                };
                o.on("endAnimation", f), o.on("touchStart", f), o.on("afterTransform", p), o.on(["error", "destroy"], (() => {
                    i()
                })), o.panTo({
                    x: c,
                    y: h,
                    scale: d,
                    friction: 0,
                    ignoreBounds: !0
                }), o.stop("current");
                const g = {
                        event: "mousemove" === o.panMode ? n.prevMouseMoveEvent || n.options.event : void 0
                    },
                    m = this.optionFor(t, "initialSize");
                C(s, wt), n.hideLoading(t), "full" === m ? o.zoomToFull(g) : "cover" === m ? o.zoomToCover(g) : "max" === m ? o.zoomToMax(g) : o.reset(.172)
            }))
        }
        getZoomInfo(t) {
            const {
                el: e,
                imageEl: i,
                thumbEl: n,
                panzoom: s
            } = t, o = this.instance, a = o.container;
            if (!e || !i || !n || !s || et(n) < 3 || !this.optionFor(t, "zoom") || !a || o.state === lt.Destroy) return !1;
            if ("0" === getComputedStyle(a).getPropertyValue("--f-images-zoom")) return !1;
            const r = window.visualViewport || null;
            if (1 !== (r ? r.scale : 1)) return !1;
            let {
                top: l,
                left: c,
                width: h,
                height: d
            } = n.getBoundingClientRect(), {
                top: u,
                left: p,
                fitWidth: f,
                fitHeight: g
            } = s.contentRect;
            if (!(h && d && f && g)) return !1;
            const m = s.container.getBoundingClientRect();
            p += m.left, u += m.top;
            const v = -1 * (p + .5 * f - (c + .5 * h)),
                b = -1 * (u + .5 * g - (l + .5 * d)),
                y = h / f;
            let w = this.option("zoomOpacity") || !1;
            return "auto" === w && (w = Math.abs(h / d - f / g) > .1), {
                x: v,
                y: b,
                scale: y,
                opacity: w
            }
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("Carousel.change", t.onChange), e.on("Carousel.createSlide", t.onCreateSlide), e.on("Carousel.removeSlide", t.onRemoveSlide), e.on("close", t.onClose)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("Carousel.change", t.onChange), e.off("Carousel.createSlide", t.onCreateSlide), e.off("Carousel.removeSlide", t.onRemoveSlide), e.off("close", t.onClose)
        }
    }
    Object.defineProperty(xt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {
            initialSize: "fit",
            Panzoom: {
                maxScale: 1
            },
            protected: !1,
            zoom: !0,
            zoomOpacity: "auto"
        }
    }), "function" == typeof SuppressedError && SuppressedError;
    const Et = "html",
        St = "image",
        Pt = "map",
        Ct = "youtube",
        Tt = "vimeo",
        Mt = "html5video",
        Ot = (t, e = {}) => {
            const i = new URL(t),
                n = new URLSearchParams(i.search),
                s = new URLSearchParams;
            for (const [t, i] of [...n, ...Object.entries(e)]) {
                let e = i + "";
                if ("t" === t) {
                    let t = e.match(/((\d*)m)?(\d*)s?/);
                    t && s.set("start", 60 * parseInt(t[2] || "0") + parseInt(t[3] || "0") + "")
                } else s.set(t, e)
            }
            let o = s + "",
                a = t.match(/#t=((.*)?\d+s)/);
            return a && (o += `#t=${a[1]}`), o
        },
        At = {
            ajax: null,
            autoSize: !0,
            iframeAttr: {
                allow: "autoplay; fullscreen",
                scrolling: "auto"
            },
            preload: !0,
            videoAutoplay: !0,
            videoRatio: 16 / 9,
            videoTpl: '<video class="fancybox__html5video" playsinline controls controlsList="nodownload" poster="{{poster}}">\n  <source src="{{src}}" type="{{format}}" />Sorry, your browser doesn\'t support embedded videos.</video>',
            videoFormat: "",
            vimeo: {
                byline: 1,
                color: "00adef",
                controls: 1,
                dnt: 1,
                muted: 0
            },
            youtube: {
                controls: 1,
                enablejsapi: 1,
                nocookie: 1,
                rel: 0,
                fs: 1
            }
        },
        Lt = ["image", "html", "ajax", "inline", "clone", "iframe", "map", "pdf", "html5video", "youtube", "vimeo"];
    class zt extends $ {
        onBeforeInitSlide(t, e, i) {
            this.processType(i)
        }
        onCreateSlide(t, e, i) {
            this.setContent(i)
        }
        onClearContent(t, e) {
            e.xhr && (e.xhr.abort(), e.xhr = null);
            const i = e.iframeEl;
            i && (i.onload = i.onerror = null, i.src = "//about:blank", e.iframeEl = null);
            const n = e.contentEl,
                s = e.placeholderEl;
            if ("inline" === e.type && n && s) n.classList.remove("fancybox__content"), "none" !== getComputedStyle(n).getPropertyValue("display") && (n.style.display = "none"), setTimeout((() => {
                s && (n && s.parentNode && s.parentNode.insertBefore(n, s), s.remove())
            }), 0), e.contentEl = void 0, e.placeholderEl = void 0;
            else
                for (; e.el && e.el.firstChild;) e.el.removeChild(e.el.firstChild)
        }
        onSelectSlide(t, e, i) {
            i.state === ct.Ready && this.playVideo()
        }
        onUnselectSlide(t, e, i) {
            var n, s;
            if (i.type === Mt) {
                try {
                    null === (s = null === (n = i.el) || void 0 === n ? void 0 : n.querySelector("video")) || void 0 === s || s.pause()
                } catch (t) {}
                return
            }
            let o;
            i.type === Tt ? o = {
                method: "pause",
                value: "true"
            } : i.type === Ct && (o = {
                event: "command",
                func: "pauseVideo"
            }), o && i.iframeEl && i.iframeEl.contentWindow && i.iframeEl.contentWindow.postMessage(JSON.stringify(o), "*"), i.poller && clearTimeout(i.poller)
        }
        onDone(t, e) {
            t.isCurrentSlide(e) && !t.isClosing() && this.playVideo()
        }
        onRefresh(t, e) {
            e.slides.forEach((t => {
                t.el && (this.resizeIframe(t), this.setAspectRatio(t))
            }))
        }
        onMessage(t) {
            try {
                let e = JSON.parse(t.data);
                if ("https://player.vimeo.com" === t.origin) {
                    if ("ready" === e.event)
                        for (let e of Array.from(document.getElementsByClassName("fancybox__iframe"))) e instanceof HTMLIFrameElement && e.contentWindow === t.source && (e.dataset.ready = "true")
                } else if (t.origin.match(/^https:\/\/(www.)?youtube(-nocookie)?.com$/) && "onReady" === e.event) {
                    const t = document.getElementById(e.id);
                    t && (t.dataset.ready = "true")
                }
            } catch (t) {}
        }
        loadAjaxContent(t) {
            const e = this.instance.optionFor(t, "src") || "";
            this.instance.showLoading(t);
            const i = this.instance,
                n = new XMLHttpRequest;
            i.showLoading(t), n.onreadystatechange = function() {
                n.readyState === XMLHttpRequest.DONE && i.state === lt.Ready && (i.hideLoading(t), 200 === n.status ? i.setContent(t, n.responseText) : i.setError(t, 404 === n.status ? "{{AJAX_NOT_FOUND}}" : "{{AJAX_FORBIDDEN}}"))
            };
            const s = t.ajax || null;
            n.open(s ? "POST" : "GET", e + ""), n.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), n.setRequestHeader("X-Requested-With", "XMLHttpRequest"), n.send(s), t.xhr = n
        }
        setInlineContent(t) {
            let e = null;
            if (S(t.src)) e = t.src;
            else if ("string" == typeof t.src) {
                const i = t.src.split("#", 2).pop();
                e = i ? document.getElementById(i) : null
            }
            if (e) {
                if ("clone" === t.type || e.closest(".fancybox__slide")) {
                    e = e.cloneNode(!0);
                    const i = e.dataset.animationName;
                    i && (e.classList.remove(i), delete e.dataset.animationName);
                    let n = e.getAttribute("id");
                    n = n ? `${n}--clone` : `clone-${this.instance.id}-${t.index}`, e.setAttribute("id", n)
                } else if (e.parentNode) {
                    const i = document.createElement("div");
                    i.classList.add("fancybox-placeholder"), e.parentNode.insertBefore(i, e), t.placeholderEl = i
                }
                this.instance.setContent(t, e)
            } else this.instance.setError(t, "{{ELEMENT_NOT_FOUND}}")
        }
        setIframeContent(t) {
            const {
                src: e,
                el: i
            } = t;
            if (!e || "string" != typeof e || !i) return;
            i.classList.add("is-loading");
            const n = this.instance,
                s = document.createElement("iframe");
            s.className = "fancybox__iframe", s.setAttribute("id", `fancybox__iframe_${n.id}_${t.index}`);
            for (const [e, i] of Object.entries(this.optionFor(t, "iframeAttr") || {})) s.setAttribute(e, i);
            s.onerror = () => {
                n.setError(t, "{{IFRAME_ERROR}}")
            }, t.iframeEl = s;
            const o = this.optionFor(t, "preload");
            if ("iframe" !== t.type || !1 === o) return s.setAttribute("src", t.src + ""), n.setContent(t, s, !1), this.resizeIframe(t), void n.revealContent(t);
            n.showLoading(t), s.onload = () => {
                if (!s.src.length) return;
                const e = "true" !== s.dataset.ready;
                s.dataset.ready = "true", this.resizeIframe(t), e ? n.revealContent(t) : n.hideLoading(t)
            }, s.setAttribute("src", e), n.setContent(t, s, !1)
        }
        resizeIframe(t) {
            const {
                type: e,
                iframeEl: i
            } = t;
            if (e === Ct || e === Tt) return;
            const n = null == i ? void 0 : i.parentElement;
            if (!i || !n) return;
            let s = t.autoSize;
            void 0 === s && (s = this.optionFor(t, "autoSize"));
            let o = t.width || 0,
                a = t.height || 0;
            o && a && (s = !1);
            const r = n && n.style;
            if (!1 !== t.preload && !1 !== s && r) try {
                const t = window.getComputedStyle(n),
                    e = parseFloat(t.paddingLeft) + parseFloat(t.paddingRight),
                    s = parseFloat(t.paddingTop) + parseFloat(t.paddingBottom),
                    l = i.contentWindow;
                if (l) {
                    const t = l.document,
                        i = t.getElementsByTagName(Et)[0],
                        n = t.body;
                    r.width = "", n.style.overflow = "hidden", o = o || i.scrollWidth + e, r.width = `${o}px`, n.style.overflow = "", r.flex = "0 0 auto", r.height = `${n.scrollHeight}px`, a = i.scrollHeight + s
                }
            } catch (t) {}
            if (o || a) {
                const t = {
                    flex: "0 1 auto",
                    width: "",
                    height: ""
                };
                o && "auto" !== o && (t.width = `${o}px`), a && "auto" !== a && (t.height = `${a}px`), Object.assign(r, t)
            }
        }
        playVideo() {
            const t = this.instance.getSlide();
            if (!t) return;
            const {
                el: e
            } = t;
            if (!e || !e.offsetParent) return;
            if (!this.optionFor(t, "videoAutoplay")) return;
            if (t.type === Mt) try {
                const t = e.querySelector("video");
                if (t) {
                    const e = t.play();
                    void 0 !== e && e.then((() => {})).catch((e => {
                        t.muted = !0, t.play()
                    }))
                }
            } catch (t) {}
            if (t.type !== Ct && t.type !== Tt) return;
            const i = () => {
                if (t.iframeEl && t.iframeEl.contentWindow) {
                    let e;
                    if ("true" === t.iframeEl.dataset.ready) return e = t.type === Ct ? {
                        event: "command",
                        func: "playVideo"
                    } : {
                        method: "play",
                        value: "true"
                    }, e && t.iframeEl.contentWindow.postMessage(JSON.stringify(e), "*"), void(t.poller = void 0);
                    t.type === Ct && (e = {
                        event: "listening",
                        id: t.iframeEl.getAttribute("id")
                    }, t.iframeEl.contentWindow.postMessage(JSON.stringify(e), "*"))
                }
                t.poller = setTimeout(i, 250)
            };
            i()
        }
        processType(t) {
            if (t.html) return t.type = Et, t.src = t.html, void(t.html = "");
            const e = this.instance.optionFor(t, "src", "");
            if (!e || "string" != typeof e) return;
            let i = t.type,
                n = null;
            if (n = e.match(/(youtube\.com|youtu\.be|youtube\-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/|shorts\/|embed\/?)?(videoseries\?list=(?:.*)|[\w-]{11}|\?listType=(?:.*)&list=(?:.*))(?:.*)/i)) {
                const s = this.optionFor(t, Ct),
                    {
                        nocookie: o
                    } = s,
                    a = function(t, e) {
                        var i = {};
                        for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
                        if (null != t && "function" == typeof Object.getOwnPropertySymbols) {
                            var s = 0;
                            for (n = Object.getOwnPropertySymbols(t); s < n.length; s++) e.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[s]) && (i[n[s]] = t[n[s]])
                        }
                        return i
                    }(s, ["nocookie"]),
                    r = `www.youtube${o?"-nocookie":""}.com`,
                    l = Ot(e, a),
                    c = encodeURIComponent(n[2]);
                t.videoId = c, t.src = `https://${r}/embed/${c}?${l}`, t.thumbSrc = t.thumbSrc || `https://i.ytimg.com/vi/${c}/mqdefault.jpg`, i = Ct
            } else if (n = e.match(/^.+vimeo.com\/(?:\/)?([\d]+)((\/|\?h=)([a-z0-9]+))?(.*)?/)) {
                const s = Ot(e, this.optionFor(t, Tt)),
                    o = encodeURIComponent(n[1]),
                    a = n[4] || "";
                t.videoId = o, t.src = `https://player.vimeo.com/video/${o}?${a?`h=${a}${s?"&":""}`:""}${s}`, i = Tt
            }
            if (!i && t.triggerEl) {
                const e = t.triggerEl.dataset.type;
                Lt.includes(e) && (i = e)
            }
            i || "string" == typeof e && ("#" === e.charAt(0) ? i = "inline" : (n = e.match(/\.(mp4|mov|ogv|webm)((\?|#).*)?$/i)) ? (i = Mt, t.videoFormat = t.videoFormat || "video/" + ("ogv" === n[1] ? "ogg" : n[1])) : e.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i) ? i = St : e.match(/\.(pdf)((\?|#).*)?$/i) && (i = "pdf")), (n = e.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:(?:(?:maps\/(?:place\/(?:.*)\/)?\@(.*),(\d+.?\d+?)z))|(?:\?ll=))(.*)?/i)) ? (t.src = `https://maps.google.${n[1]}/?ll=${(n[2]?n[2]+"&z="+Math.floor(parseFloat(n[3]))+(n[4]?n[4].replace(/^\//,"&"):""):n[4]+"").replace(/\?/,"&")}&output=${n[4]&&n[4].indexOf("layer=c")>0?"svembed":"embed"}`, i = Pt) : (n = e.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/search\/)(.*)/i)) && (t.src = `https://maps.google.${n[1]}/maps?q=${n[2].replace("query=","q=").replace("api=1","")}&output=embed`, i = Pt), i = i || this.instance.option("defaultType"), t.type = i, i === St && (t.thumbSrc = t.thumbSrc || t.src)
        }
        setContent(t) {
            const e = this.instance.optionFor(t, "src") || "";
            if (t && t.type && e) {
                switch (t.type) {
                    case Et:
                        this.instance.setContent(t, e);
                        break;
                    case Mt:
                        const i = this.option("videoTpl");
                        i && this.instance.setContent(t, i.replace(/\{\{src\}\}/gi, e + "").replace(/\{\{format\}\}/gi, this.optionFor(t, "videoFormat") || "").replace(/\{\{poster\}\}/gi, t.poster || t.thumbSrc || ""));
                        break;
                    case "inline":
                    case "clone":
                        this.setInlineContent(t);
                        break;
                    case "ajax":
                        this.loadAjaxContent(t);
                        break;
                    case "pdf":
                    case Pt:
                    case Ct:
                    case Tt:
                        t.preload = !1;
                    case "iframe":
                        this.setIframeContent(t)
                }
                this.setAspectRatio(t)
            }
        }
        setAspectRatio(t) {
            const e = t.contentEl;
            if (!(t.el && e && t.type && [Ct, Tt, Mt].includes(t.type))) return;
            let i, n = t.width || "auto",
                s = t.height || "auto";
            if ("auto" === n || "auto" === s) {
                i = this.optionFor(t, "videoRatio");
                const e = (i + "").match(/(\d+)\s*\/\s?(\d+)/);
                i = e && e.length > 2 ? parseFloat(e[1]) / parseFloat(e[2]) : parseFloat(i + "")
            } else n && s && (i = n / s);
            if (!i) return;
            e.style.aspectRatio = "", e.style.width = "", e.style.height = "", e.offsetHeight;
            const o = e.getBoundingClientRect(),
                a = o.width || 1,
                r = o.height || 1;
            e.style.aspectRatio = i + "", i < a / r ? (s = "auto" === s ? r : Math.min(r, s), e.style.width = "auto", e.style.height = `${s}px`) : (n = "auto" === n ? a : Math.min(a, n), e.style.width = `${n}px`, e.style.height = "auto")
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("Carousel.beforeInitSlide", t.onBeforeInitSlide), e.on("Carousel.createSlide", t.onCreateSlide), e.on("Carousel.selectSlide", t.onSelectSlide), e.on("Carousel.unselectSlide", t.onUnselectSlide), e.on("Carousel.Panzoom.refresh", t.onRefresh), e.on("done", t.onDone), e.on("clearContent", t.onClearContent), window.addEventListener("message", t.onMessage)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("Carousel.beforeInitSlide", t.onBeforeInitSlide), e.off("Carousel.createSlide", t.onCreateSlide), e.off("Carousel.selectSlide", t.onSelectSlide), e.off("Carousel.unselectSlide", t.onUnselectSlide), e.off("Carousel.Panzoom.refresh", t.onRefresh), e.off("done", t.onDone), e.off("clearContent", t.onClearContent), window.removeEventListener("message", t.onMessage)
        }
    }
    Object.defineProperty(zt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: At
    });
    const Rt = "play",
        kt = "pause",
        It = "ready";
    class Dt extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "state", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: It
            }), Object.defineProperty(this, "inHover", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            }), Object.defineProperty(this, "timer", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "progressBar", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            })
        }
        get isActive() {
            return this.state !== It
        }
        onReady(t) {
            this.option("autoStart") && (t.isInfinite || t.page < t.pages.length - 1) && this.start()
        }
        onChange() {
            this.removeProgressBar(), this.pause()
        }
        onSettle() {
            this.resume()
        }
        onVisibilityChange() {
            "visible" === document.visibilityState ? this.resume() : this.pause()
        }
        onMouseEnter() {
            this.inHover = !0, this.pause()
        }
        onMouseLeave() {
            var t;
            this.inHover = !1, (null === (t = this.instance.panzoom) || void 0 === t ? void 0 : t.isResting) && this.resume()
        }
        onTimerEnd() {
            const t = this.instance;
            "play" === this.state && (t.isInfinite || t.page !== t.pages.length - 1 ? t.slideNext() : t.slideTo(0))
        }
        removeProgressBar() {
            this.progressBar && (this.progressBar.remove(), this.progressBar = null)
        }
        createProgressBar() {
            var t;
            if (!this.option("showProgress")) return null;
            this.removeProgressBar();
            const e = this.instance,
                i = (null === (t = e.pages[e.page]) || void 0 === t ? void 0 : t.slides) || [];
            let n = this.option("progressParentEl");
            if (n || (n = (1 === i.length ? i[0].el : null) || e.viewport), !n) return null;
            const s = document.createElement("div");
            return C(s, "f-progress"), n.prepend(s), this.progressBar = s, s.offsetHeight, s
        }
        set() {
            const t = this,
                e = t.instance;
            if (e.pages.length < 2) return;
            if (t.timer) return;
            const i = t.option("timeout");
            t.state = Rt, C(e.container, "has-autoplay");
            let n = t.createProgressBar();
            n && (n.style.transitionDuration = `${i}ms`, n.style.transform = "scaleX(1)"), t.timer = setTimeout((() => {
                t.timer = null, t.inHover || t.onTimerEnd()
            }), i), t.emit("set")
        }
        clear() {
            const t = this;
            t.timer && (clearTimeout(t.timer), t.timer = null), t.removeProgressBar()
        }
        start() {
            const t = this;
            if (t.set(), t.state !== It) {
                if (t.option("pauseOnHover")) {
                    const e = t.instance.container;
                    e.addEventListener("mouseenter", t.onMouseEnter, !1), e.addEventListener("mouseleave", t.onMouseLeave, !1)
                }
                document.addEventListener("visibilitychange", t.onVisibilityChange, !1), t.emit("start")
            }
        }
        stop() {
            const t = this,
                e = t.state,
                i = t.instance.container;
            t.clear(), t.state = It, i.removeEventListener("mouseenter", t.onMouseEnter, !1), i.removeEventListener("mouseleave", t.onMouseLeave, !1), document.removeEventListener("visibilitychange", t.onVisibilityChange, !1), P(i, "has-autoplay"), e !== It && t.emit("stop")
        }
        pause() {
            const t = this;
            t.state === Rt && (t.state = kt, t.clear(), t.emit(kt))
        }
        resume() {
            const t = this,
                e = t.instance;
            if (e.isInfinite || e.page !== e.pages.length - 1)
                if (t.state !== Rt) {
                    if (t.state === kt && !t.inHover) {
                        const e = new Event("resume", {
                            bubbles: !0,
                            cancelable: !0
                        });
                        t.emit("resume", e), e.defaultPrevented || t.set()
                    }
                } else t.set();
            else t.stop()
        }
        toggle() {
            this.state === Rt || this.state === kt ? this.stop() : this.start()
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("ready", t.onReady), e.on("Panzoom.startAnimation", t.onChange), e.on("Panzoom.endAnimation", t.onSettle), e.on("Panzoom.touchMove", t.onChange)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("ready", t.onReady), e.off("Panzoom.startAnimation", t.onChange), e.off("Panzoom.endAnimation", t.onSettle), e.off("Panzoom.touchMove", t.onChange), t.stop()
        }
    }
    Object.defineProperty(Dt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {
            autoStart: !0,
            pauseOnHover: !0,
            progressParentEl: null,
            showProgress: !0,
            timeout: 3e3
        }
    });
    class Ft extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "ref", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            })
        }
        onPrepare(t) {
            const e = t.carousel;
            if (!e) return;
            const i = t.container;
            i && (e.options.Autoplay = p({
                autoStart: !1
            }, this.option("Autoplay") || {}, {
                pauseOnHover: !1,
                timeout: this.option("timeout"),
                progressParentEl: () => this.option("progressParentEl") || null,
                on: {
                    start: () => {
                        t.emit("startSlideshow")
                    },
                    set: e => {
                        var n;
                        i.classList.add("has-slideshow"), (null === (n = t.getSlide()) || void 0 === n ? void 0 : n.state) !== ct.Ready && e.pause()
                    },
                    stop: () => {
                        i.classList.remove("has-slideshow"), t.isCompact || t.endIdle(), t.emit("endSlideshow")
                    },
                    resume: (e, i) => {
                        var n, s, o;
                        !i || !i.cancelable || (null === (n = t.getSlide()) || void 0 === n ? void 0 : n.state) === ct.Ready && (null === (o = null === (s = t.carousel) || void 0 === s ? void 0 : s.panzoom) || void 0 === o ? void 0 : o.isResting) || i.preventDefault()
                    }
                }
            }), e.attachPlugins({
                Autoplay: Dt
            }), this.ref = e.plugins.Autoplay)
        }
        onReady(t) {
            const e = t.carousel,
                i = this.ref;
            i && e && this.option("playOnStart") && (e.isInfinite || e.page < e.pages.length - 1) && i.start()
        }
        onDone(t, e) {
            const i = this.ref,
                n = t.carousel;
            if (!i || !n) return;
            const s = e.panzoom;
            s && s.on("startAnimation", (() => {
                t.isCurrentSlide(e) && i.stop()
            })), t.isCurrentSlide(e) && i.resume()
        }
        onKeydown(t, e) {
            var i;
            const n = this.ref;
            n && e === this.option("key") && "BUTTON" !== (null === (i = document.activeElement) || void 0 === i ? void 0 : i.nodeName) && n.toggle()
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("Carousel.init", t.onPrepare), e.on("Carousel.ready", t.onReady), e.on("done", t.onDone), e.on("keydown", t.onKeydown)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("Carousel.init", t.onPrepare), e.off("Carousel.ready", t.onReady), e.off("done", t.onDone), e.off("keydown", t.onKeydown)
        }
    }
    Object.defineProperty(Ft, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: {
            key: " ",
            playOnStart: !1,
            progressParentEl: t => {
                var e;
                return (null === (e = t.instance.container) || void 0 === e ? void 0 : e.querySelector(".fancybox__toolbar [data-fancybox-toggle-slideshow]")) || t.instance.container
            },
            timeout: 3e3
        }
    });
    const jt = {
        classes: {
            container: "f-thumbs f-carousel__thumbs",
            viewport: "f-thumbs__viewport",
            track: "f-thumbs__track",
            slide: "f-thumbs__slide",
            isResting: "is-resting",
            isSelected: "is-selected",
            isLoading: "is-loading",
            hasThumbs: "has-thumbs"
        },
        minCount: 2,
        parentEl: null,
        thumbTpl: '<button class="f-thumbs__slide__button" tabindex="0" type="button" aria-label="{{GOTO}}" data-carousel-index="%i"><img class="f-thumbs__slide__img" data-lazy-src="{{%s}}" alt="" /></button>',
        type: "modern"
    };
    var Bt;
    ! function(t) {
        t[t.Init = 0] = "Init", t[t.Ready = 1] = "Ready", t[t.Hidden = 2] = "Hidden"
    }(Bt || (Bt = {}));
    const Ht = "isResting",
        Nt = "thumbWidth",
        _t = "thumbHeight",
        $t = "thumbClipWidth";
    let Wt = class extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "type", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "modern"
            }), Object.defineProperty(this, "container", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "track", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "carousel", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "thumbWidth", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "thumbClipWidth", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "thumbHeight", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "thumbGap", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "thumbExtraGap", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "state", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: Bt.Init
            })
        }
        get isModern() {
            return "modern" === this.type
        }
        onInitSlide(t, e) {
            const i = e.el ? e.el.dataset : void 0;
            i && (e.thumbSrc = i.thumbSrc || e.thumbSrc || "", e[$t] = parseFloat(i[$t] || "") || e[$t] || 0, e[_t] = parseFloat(i.thumbHeight || "") || e[_t] || 0), this.addSlide(e)
        }
        onInitSlides() {
            this.build()
        }
        onChange() {
            var t;
            if (!this.isModern) return;
            const e = this.container,
                i = this.instance,
                n = i.panzoom,
                s = this.carousel,
                o = s ? s.panzoom : null,
                r = i.page;
            if (n && s && o) {
                if (n.isDragging) {
                    P(e, this.cn(Ht));
                    let n = (null === (t = s.pages[r]) || void 0 === t ? void 0 : t.pos) || 0;
                    n += i.getProgress(r) * (this[$t] + this.thumbGap);
                    let a = o.getBounds(); - 1 * n > a.x.min && -1 * n < a.x.max && o.panTo({
                        x: -1 * n,
                        friction: .12
                    })
                } else a(e, this.cn(Ht), n.isResting);
                this.shiftModern()
            }
        }
        onRefresh() {
            this.updateProps();
            for (const t of this.instance.slides || []) this.resizeModernSlide(t);
            this.shiftModern()
        }
        isDisabled() {
            const t = this.option("minCount") || 0;
            if (t) {
                const e = this.instance;
                let i = 0;
                for (const t of e.slides || []) t.thumbSrc && i++;
                if (i < t) return !0
            }
            const e = this.option("type");
            return ["modern", "classic"].indexOf(e) < 0
        }
        getThumb(t) {
            const e = this.option("thumbTpl") || "";
            return {
                html: this.instance.localize(e, [
                    ["%i", t.index],
                    ["%d", t.index + 1],
                    ["%s", t.thumbSrc || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]
                ])
            }
        }
        addSlide(t) {
            const e = this.carousel;
            e && e.addSlide(t.index, this.getThumb(t))
        }
        getSlides() {
            const t = [];
            for (const e of this.instance.slides || []) t.push(this.getThumb(e));
            return t
        }
        resizeModernSlide(t) {
            this.isModern && (t[Nt] = t[$t] && t[_t] ? Math.round(this[_t] * (t[$t] / t[_t])) : this[Nt])
        }
        updateProps() {
            const t = this.container;
            if (!t) return;
            const e = e => parseFloat(getComputedStyle(t).getPropertyValue("--f-thumb-" + e)) || 0;
            this.thumbGap = e("gap"), this.thumbExtraGap = e("extra-gap"), this[Nt] = e("width") || 40, this[$t] = e("clip-width") || 40, this[_t] = e("height") || 40
        }
        build() {
            const t = this;
            if (t.state !== Bt.Init) return;
            if (t.isDisabled()) return void t.emit("disabled");
            const e = t.instance,
                i = e.container,
                n = t.getSlides(),
                s = t.option("type");
            t.type = s;
            const o = t.option("parentEl"),
                a = t.cn("container"),
                r = t.cn("track");
            let l = null == o ? void 0 : o.querySelector("." + a);
            l || (l = document.createElement("div"), C(l, a), o ? o.appendChild(l) : i.after(l)), C(l, `is-${s}`), C(i, t.cn("hasThumbs")), t.container = l, t.updateProps();
            let c = l.querySelector("." + r);
            c || (c = document.createElement("div"), C(c, t.cn("track")), l.appendChild(c)), t.track = c;
            const h = p({}, {
                    track: c,
                    infinite: !1,
                    center: !0,
                    fill: "classic" === s,
                    dragFree: !0,
                    slidesPerPage: 1,
                    transition: !1,
                    preload: .25,
                    friction: .12,
                    Panzoom: {
                        maxVelocity: 0
                    },
                    Dots: !1,
                    Navigation: !1,
                    classes: {
                        container: "f-thumbs",
                        viewport: "f-thumbs__viewport",
                        track: "f-thumbs__track",
                        slide: "f-thumbs__slide"
                    }
                }, t.option("Carousel") || {}, {
                    Sync: {
                        target: e
                    },
                    slides: n
                }),
                d = new e.constructor(l, h);
            d.on("createSlide", ((e, i) => {
                t.setProps(i.index), t.emit("createSlide", i, i.el)
            })), d.on("ready", (() => {
                t.shiftModern(), t.emit("ready")
            })), d.on("refresh", (() => {
                t.shiftModern()
            })), d.on("Panzoom.click", ((e, i, n) => {
                t.onClick(n)
            })), t.carousel = d, t.state = Bt.Ready
        }
        onClick(t) {
            t.preventDefault(), t.stopPropagation();
            const e = this.instance,
                {
                    pages: i,
                    page: n
                } = e,
                s = t => {
                    if (t) {
                        const e = t.closest("[data-carousel-index]");
                        if (e) return [parseInt(e.dataset.carouselIndex || "", 10) || 0, e]
                    }
                    return [-1, void 0]
                },
                o = (t, e) => {
                    const i = document.elementFromPoint(t, e);
                    return i ? s(i) : [-1, void 0]
                };
            let [a, r] = s(t.target);
            if (a > -1) return;
            const l = this[$t],
                c = t.clientX,
                h = t.clientY;
            let [d, u] = o(c - l, h), [p, f] = o(c + l, h);
            u && f ? (a = Math.abs(c - u.getBoundingClientRect().right) < Math.abs(c - f.getBoundingClientRect().left) ? d : p, a === n && (a = a === d ? p : d)) : u ? a = d : f && (a = p), a > -1 && i[a] && e.slideTo(a)
        }
        getShift(t) {
            var e;
            const i = this,
                {
                    instance: n
                } = i,
                s = i.carousel;
            if (!n || !s) return 0;
            const o = i[Nt],
                a = i[$t],
                r = i.thumbGap,
                l = i.thumbExtraGap;
            if (!(null === (e = s.slides[t]) || void 0 === e ? void 0 : e.el)) return 0;
            const c = .5 * (o - a),
                h = n.pages.length - 1;
            let d = n.getProgress(0),
                u = n.getProgress(h),
                p = n.getProgress(t, !1, !0),
                f = 0,
                g = c + l + r;
            const m = d < 0 && d > -1,
                v = u > 0 && u < 1;
            return 0 === t ? (f = g * Math.abs(d), v && 1 === d && (f -= g * Math.abs(u))) : t === h ? (f = g * Math.abs(u) * -1, m && -1 === u && (f += g * Math.abs(d))) : m || v ? (f = -1 * g, f += g * Math.abs(d), f += g * (1 - Math.abs(u))) : f = g * p, f
        }
        setProps(t) {
            var i;
            const n = this;
            if (!n.isModern) return;
            const {
                instance: s
            } = n, o = n.carousel;
            if (s && o) {
                const a = null === (i = o.slides[t]) || void 0 === i ? void 0 : i.el;
                if (a && a.childNodes.length) {
                    let i = e(1 - Math.abs(s.getProgress(t))),
                        o = e(n.getShift(t));
                    a.style.setProperty("--progress", i ? i + "" : ""), a.style.setProperty("--shift", o + "")
                }
            }
        }
        shiftModern() {
            const t = this;
            if (!t.isModern) return;
            const {
                instance: e,
                track: i
            } = t, n = e.panzoom, s = t.carousel;
            if (!(e && i && n && s)) return;
            if (n.state === v.Init || n.state === v.Destroy) return;
            for (const i of e.slides) t.setProps(i.index);
            let o = (t[$t] + t.thumbGap) * (s.slides.length || 0);
            i.style.setProperty("--width", o + "")
        }
        cleanup() {
            const t = this;
            t.carousel && t.carousel.destroy(), t.carousel = null, t.container && t.container.remove(), t.container = null, t.track && t.track.remove(), t.track = null, t.state = Bt.Init, P(t.instance.container, t.cn("hasThumbs"))
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("initSlide", t.onInitSlide), e.state === H.Init ? e.on("initSlides", t.onInitSlides) : t.onInitSlides(), e.on(["change", "Panzoom.afterTransform"], t.onChange), e.on("Panzoom.refresh", t.onRefresh)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("initSlide", t.onInitSlide), e.off("initSlides", t.onInitSlides), e.off(["change", "Panzoom.afterTransform"], t.onChange), e.off("Panzoom.refresh", t.onRefresh), t.cleanup()
        }
    };
    Object.defineProperty(Wt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: jt
    });
    const Xt = Object.assign(Object.assign({}, jt), {
            key: "t",
            showOnStart: !0,
            parentEl: null
        }),
        qt = "is-masked",
        Yt = "aria-hidden";
    class Vt extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "ref", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "hidden", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            })
        }
        get isEnabled() {
            const t = this.ref;
            return t && !t.isDisabled()
        }
        get isHidden() {
            return this.hidden
        }
        onClick(t, e) {
            e.stopPropagation()
        }
        onCreateSlide(t, e) {
            var i, n, s;
            const o = (null === (s = null === (n = null === (i = this.instance) || void 0 === i ? void 0 : i.carousel) || void 0 === n ? void 0 : n.slides[e.index]) || void 0 === s ? void 0 : s.type) || "",
                a = e.el;
            if (a && o) {
                let t = `for-${o}`;
                ["video", "youtube", "vimeo", "html5video"].includes(o) && (t += " for-video"), C(a, t)
            }
        }
        onInit() {
            var t;
            const e = this,
                i = e.instance,
                n = i.carousel;
            if (e.ref || !n) return;
            const s = e.option("parentEl") || i.footer || i.container;
            if (!s) return;
            const o = p({}, e.options, {
                parentEl: s,
                classes: {
                    container: "f-thumbs fancybox__thumbs"
                },
                Carousel: {
                    Sync: {
                        friction: i.option("Carousel.friction") || 0
                    }
                },
                on: {
                    ready: t => {
                        const i = t.container;
                        i && this.hidden && (e.refresh(), i.style.transition = "none", e.hide(), i.offsetHeight, queueMicrotask((() => {
                            i.style.transition = "", e.show()
                        })))
                    }
                }
            });
            o.Carousel = o.Carousel || {}, o.Carousel.on = p((null === (t = e.options.Carousel) || void 0 === t ? void 0 : t.on) || {}, {
                click: this.onClick,
                createSlide: this.onCreateSlide
            }), n.options.Thumbs = o, n.attachPlugins({
                Thumbs: Wt
            }), e.ref = n.plugins.Thumbs, e.option("showOnStart") || (e.ref.state = Bt.Hidden, e.hidden = !0)
        }
        onResize() {
            var t;
            const e = null === (t = this.ref) || void 0 === t ? void 0 : t.container;
            e && (e.style.maxHeight = "")
        }
        onKeydown(t, e) {
            const i = this.option("key");
            i && i === e && this.toggle()
        }
        toggle() {
            const t = this.ref;
            if (t && !t.isDisabled()) return t.state === Bt.Hidden ? (t.state = Bt.Init, void t.build()) : void(this.hidden ? this.show() : this.hide())
        }
        show() {
            const t = this.ref;
            if (!t || t.isDisabled()) return;
            const e = t.container;
            e && (this.refresh(), e.offsetHeight, e.removeAttribute(Yt), e.classList.remove(qt), this.hidden = !1)
        }
        hide() {
            const t = this.ref,
                e = t && t.container;
            e && (this.refresh(), e.offsetHeight, e.classList.add(qt), e.setAttribute(Yt, "true")), this.hidden = !0
        }
        refresh() {
            const t = this.ref;
            if (!t || !t.state) return;
            const e = t.container,
                i = (null == e ? void 0 : e.firstChild) || null;
            e && i && i.childNodes.length && (e.style.maxHeight = `${i.getBoundingClientRect().height}px`)
        }
        attach() {
            const t = this,
                e = t.instance;
            e.state === lt.Init ? e.on("Carousel.init", t.onInit) : t.onInit(), e.on("resize", t.onResize), e.on("keydown", t.onKeydown)
        }
        detach() {
            var t;
            const e = this,
                i = e.instance;
            i.off("Carousel.init", e.onInit), i.off("resize", e.onResize), i.off("keydown", e.onKeydown), null === (t = i.carousel) || void 0 === t || t.detachPlugins(["Thumbs"]), e.ref = null
        }
    }
    Object.defineProperty(Vt, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: Xt
    });
    const Zt = {
        panLeft: {
            icon: '<svg><path d="M5 12h14M5 12l6 6M5 12l6-6"/></svg>',
            change: {
                panX: -100
            }
        },
        panRight: {
            icon: '<svg><path d="M5 12h14M13 18l6-6M13 6l6 6"/></svg>',
            change: {
                panX: 100
            }
        },
        panUp: {
            icon: '<svg><path d="M12 5v14M18 11l-6-6M6 11l6-6"/></svg>',
            change: {
                panY: -100
            }
        },
        panDown: {
            icon: '<svg><path d="M12 5v14M18 13l-6 6M6 13l6 6"/></svg>',
            change: {
                panY: 100
            }
        },
        zoomIn: {
            icon: '<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M11 8v6M8 11h6"/></svg>',
            action: "zoomIn"
        },
        zoomOut: {
            icon: '<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',
            action: "zoomOut"
        },
        toggle1to1: {
            icon: '<svg><path d="M3.51 3.07c5.74.02 11.48-.02 17.22.02 1.37.1 2.34 1.64 2.18 3.13 0 4.08.02 8.16 0 12.23-.1 1.54-1.47 2.64-2.79 2.46-5.61-.01-11.24.02-16.86-.01-1.36-.12-2.33-1.65-2.17-3.14 0-4.07-.02-8.16 0-12.23.1-1.36 1.22-2.48 2.42-2.46Z"/><path d="M5.65 8.54h1.49v6.92m8.94-6.92h1.49v6.92M11.5 9.4v.02m0 5.18v0"/></svg>',
            action: "toggleZoom"
        },
        toggleZoom: {
            icon: '<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',
            action: "toggleZoom"
        },
        iterateZoom: {
            icon: '<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',
            action: "iterateZoom"
        },
        rotateCCW: {
            icon: '<svg><path d="M15 4.55a8 8 0 0 0-6 14.9M9 15v5H4M18.37 7.16v.01M13 19.94v.01M16.84 18.37v.01M19.37 15.1v.01M19.94 11v.01"/></svg>',
            action: "rotateCCW"
        },
        rotateCW: {
            icon: '<svg><path d="M9 4.55a8 8 0 0 1 6 14.9M15 15v5h5M5.63 7.16v.01M4.06 11v.01M4.63 15.1v.01M7.16 18.37v.01M11 19.94v.01"/></svg>',
            action: "rotateCW"
        },
        flipX: {
            icon: '<svg style="stroke-width: 1.3"><path d="M12 3v18M16 7v10h5L16 7M8 7v10H3L8 7"/></svg>',
            action: "flipX"
        },
        flipY: {
            icon: '<svg style="stroke-width: 1.3"><path d="M3 12h18M7 16h10L7 21v-5M7 8h10L7 3v5"/></svg>',
            action: "flipY"
        },
        fitX: {
            icon: '<svg><path d="M4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v6M10 18H3M21 18h-7M6 15l-3 3 3 3M18 15l3 3-3 3"/></svg>',
            action: "fitX"
        },
        fitY: {
            icon: '<svg><path d="M12 20H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h6M18 14v7M18 3v7M15 18l3 3 3-3M15 6l3-3 3 3"/></svg>',
            action: "fitY"
        },
        reset: {
            icon: '<svg><path d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg>',
            action: "reset"
        },
        toggleFS: {
            icon: '<svg><g><path d="M14.5 9.5 21 3m0 0h-6m6 0v6M3 21l6.5-6.5M3 21v-6m0 6h6"/></g><g><path d="m14 10 7-7m-7 7h6m-6 0V4M3 21l7-7m0 0v6m0-6H4"/></g></svg>',
            action: "toggleFS"
        }
    };
    var Ut;
    ! function(t) {
        t[t.Init = 0] = "Init", t[t.Ready = 1] = "Ready", t[t.Disabled = 2] = "Disabled"
    }(Ut || (Ut = {}));
    const Gt = {
            absolute: "auto",
            display: {
                left: ["infobar"],
                middle: [],
                right: ["iterateZoom", "slideshow", "fullscreen", "thumbs", "close"]
            },
            enabled: "auto",
            items: {
                infobar: {
                    tpl: '<div class="fancybox__infobar" tabindex="-1"><span data-fancybox-current-index></span>/<span data-fancybox-count></span></div>'
                },
                download: {
                    tpl: '<a class="f-button" title="{{DOWNLOAD}}" data-fancybox-download href="javasript:;"><svg><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2M7 11l5 5 5-5M12 4v12"/></svg></a>'
                },
                prev: {
                    tpl: '<button class="f-button" title="{{PREV}}" data-fancybox-prev><svg><path d="m15 6-6 6 6 6"/></svg></button>'
                },
                next: {
                    tpl: '<button class="f-button" title="{{NEXT}}" data-fancybox-next><svg><path d="m9 6 6 6-6 6"/></svg></button>'
                },
                slideshow: {
                    tpl: '<button class="f-button" title="{{TOGGLE_SLIDESHOW}}" data-fancybox-toggle-slideshow><svg><g><path d="M8 4v16l13 -8z"></path></g><g><path d="M8 4v15M17 4v15"/></g></svg></button>'
                },
                fullscreen: {
                    tpl: '<button class="f-button" title="{{TOGGLE_FULLSCREEN}}" data-fancybox-toggle-fullscreen><svg><g><path d="M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2M16 4h2a2 2 0 0 1 2 2v2M16 20h2a2 2 0 0 0 2-2v-2"/></g><g><path d="M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5"/></g></svg></button>'
                },
                thumbs: {
                    tpl: '<button class="f-button" title="{{TOGGLE_THUMBS}}" data-fancybox-toggle-thumbs><svg><circle cx="5.5" cy="5.5" r="1"/><circle cx="12" cy="5.5" r="1"/><circle cx="18.5" cy="5.5" r="1"/><circle cx="5.5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18.5" cy="12" r="1"/><circle cx="5.5" cy="18.5" r="1"/><circle cx="12" cy="18.5" r="1"/><circle cx="18.5" cy="18.5" r="1"/></svg></button>'
                },
                close: {
                    tpl: '<button class="f-button" title="{{CLOSE}}" data-fancybox-close><svg><path d="m19.5 4.5-15 15M4.5 4.5l15 15"/></svg></button>'
                }
            },
            parentEl: null
        },
        Kt = {
            tabindex: "-1",
            width: "24",
            height: "24",
            viewBox: "0 0 24 24",
            xmlns: "http://www.w3.org/2000/svg"
        },
        Jt = "has-toolbar",
        Qt = "fancybox__toolbar";
    class te extends $ {
        constructor() {
            super(...arguments), Object.defineProperty(this, "state", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: Ut.Init
            }), Object.defineProperty(this, "container", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            })
        }
        onReady(t) {
            var e;
            if (!t.carousel) return;
            let i = this.option("display"),
                n = this.option("absolute"),
                s = this.option("enabled");
            if ("auto" === s) {
                const t = this.instance.carousel;
                let e = 0;
                if (t)
                    for (const i of t.slides)(i.panzoom || "image" === i.type) && e++;
                e || (s = !1)
            }
            s || (i = void 0);
            let o = 0;
            const a = {
                left: [],
                middle: [],
                right: []
            };
            if (i)
                for (const t of ["left", "middle", "right"])
                    for (const n of i[t]) {
                        const i = this.createEl(n);
                        i && (null === (e = a[t]) || void 0 === e || e.push(i), o++)
                    }
            let r = null;
            if (o && (r = this.createContainer()), r) {
                for (const [t, e] of Object.entries(a)) {
                    const i = document.createElement("div");
                    C(i, Qt + "__column is-" + t);
                    for (const t of e) i.appendChild(t);
                    "auto" !== n || "middle" !== t || e.length || (n = !0), r.appendChild(i)
                }!0 === n && C(r, "is-absolute"), this.state = Ut.Ready, this.onRefresh()
            } else this.state = Ut.Disabled
        }
        onClick(t) {
            var e, i;
            const n = this.instance,
                s = n.getSlide(),
                o = null == s ? void 0 : s.panzoom,
                a = t.target,
                r = a && S(a) ? a.dataset : null;
            if (!r) return;
            if (void 0 !== r.fancyboxToggleThumbs) return t.preventDefault(), t.stopPropagation(), void(null === (e = n.plugins.Thumbs) || void 0 === e || e.toggle());
            if (void 0 !== r.fancyboxToggleFullscreen) return t.preventDefault(), t.stopPropagation(), void this.instance.toggleFullscreen();
            if (void 0 !== r.fancyboxToggleSlideshow) {
                t.preventDefault(), t.stopPropagation();
                const e = null === (i = n.carousel) || void 0 === i ? void 0 : i.plugins.Autoplay;
                let s = e.isActive;
                return o && "mousemove" === o.panMode && !s && o.reset(), void(s ? e.stop() : e.start())
            }
            const l = r.panzoomAction,
                c = r.panzoomChange;
            if ((c || l) && (t.preventDefault(), t.stopPropagation()), c) {
                let t = {};
                try {
                    t = JSON.parse(c)
                } catch (t) {}
                o && o.applyChange(t)
            } else l && o && o[l] && o[l]()
        }
        onChange() {
            this.onRefresh()
        }
        onRefresh() {
            if (this.instance.isClosing()) return;
            const t = this.container;
            if (!t) return;
            const e = this.instance.getSlide();
            if (!e || e.state !== ct.Ready) return;
            const i = e && !e.error && e.panzoom;
            for (const e of t.querySelectorAll("[data-panzoom-action]")) i ? (e.removeAttribute("disabled"), e.removeAttribute("tabindex")) : (e.setAttribute("disabled", ""), e.setAttribute("tabindex", "-1"));
            let n = i && i.canZoomIn(),
                s = i && i.canZoomOut();
            for (const e of t.querySelectorAll('[data-panzoom-action="zoomIn"]')) n ? (e.removeAttribute("disabled"), e.removeAttribute("tabindex")) : (e.setAttribute("disabled", ""), e.setAttribute("tabindex", "-1"));
            for (const e of t.querySelectorAll('[data-panzoom-action="zoomOut"]')) s ? (e.removeAttribute("disabled"), e.removeAttribute("tabindex")) : (e.setAttribute("disabled", ""), e.setAttribute("tabindex", "-1"));
            for (const e of t.querySelectorAll('[data-panzoom-action="toggleZoom"],[data-panzoom-action="iterateZoom"]')) {
                s || n ? (e.removeAttribute("disabled"), e.removeAttribute("tabindex")) : (e.setAttribute("disabled", ""), e.setAttribute("tabindex", "-1"));
                const t = e.querySelector("g");
                t && (t.style.display = n ? "" : "none")
            }
        }
        onDone(t, e) {
            var i;
            null === (i = e.panzoom) || void 0 === i || i.on("afterTransform", (() => {
                this.instance.isCurrentSlide(e) && this.onRefresh()
            })), this.instance.isCurrentSlide(e) && this.onRefresh()
        }
        createContainer() {
            const t = this.instance.container;
            if (!t) return null;
            const e = this.option("parentEl") || t;
            let i = e.querySelector("." + Qt);
            return i || (i = document.createElement("div"), C(i, Qt), e.prepend(i)), i.addEventListener("click", this.onClick, {
                passive: !1,
                capture: !0
            }), t && C(t, Jt), this.container = i, i
        }
        createEl(t) {
            const e = this.instance,
                i = e.carousel;
            if (!i) return null;
            if ("toggleFS" === t) return null;
            if ("fullscreen" === t && !at()) return null;
            let n = null;
            const o = i.slides.length || 0;
            let a = 0,
                r = 0;
            for (const t of i.slides)(t.panzoom || "image" === t.type) && a++, ("image" === t.type || t.downloadSrc) && r++;
            if (o < 2 && ["infobar", "prev", "next"].includes(t)) return n;
            if (void 0 !== Zt[t] && !a) return null;
            if ("download" === t && !r) return null;
            if ("thumbs" === t) {
                const t = e.plugins.Thumbs;
                if (!t || !t.isEnabled) return null
            }
            if ("slideshow" === t) {
                if (!i.plugins.Autoplay || o < 2) return null
            }
            if (void 0 !== Zt[t]) {
                const e = Zt[t];
                n = document.createElement("button"), n.setAttribute("title", this.instance.localize(`{{${t.toUpperCase()}}}`)), C(n, "f-button"), e.action && (n.dataset.panzoomAction = e.action), e.change && (n.dataset.panzoomChange = JSON.stringify(e.change)), n.appendChild(s(this.instance.localize(e.icon)))
            } else {
                const e = (this.option("items") || [])[t];
                e && (n = s(this.instance.localize(e.tpl)), "function" == typeof e.click && n.addEventListener("click", (t => {
                    t.preventDefault(), t.stopPropagation(), "function" == typeof e.click && e.click.call(this, this, t)
                })))
            }
            const l = null == n ? void 0 : n.querySelector("svg");
            if (l)
                for (const [t, e] of Object.entries(Kt)) l.getAttribute(t) || l.setAttribute(t, String(e));
            return n
        }
        removeContainer() {
            const t = this.container;
            t && t.remove(), this.container = null, this.state = Ut.Disabled;
            const e = this.instance.container;
            e && P(e, Jt)
        }
        attach() {
            const t = this,
                e = t.instance;
            e.on("Carousel.initSlides", t.onReady), e.on("done", t.onDone), e.on(["reveal", "Carousel.change"], t.onChange), t.onReady(t.instance)
        }
        detach() {
            const t = this,
                e = t.instance;
            e.off("Carousel.initSlides", t.onReady), e.off("done", t.onDone), e.off(["reveal", "Carousel.change"], t.onChange), t.removeContainer()
        }
    }
    Object.defineProperty(te, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: Gt
    });
    const ee = {
            Hash: class extends $ {
                onReady() {
                    dt = !1
                }
                onChange(t) {
                    pt && clearTimeout(pt);
                    const {
                        hash: e
                    } = ft(), {
                        hash: i
                    } = gt(), n = t.isOpeningSlide(t.getSlide());
                    n && (ht = i === e ? "" : i), e && e !== i && (pt = setTimeout((() => {
                        try {
                            if (t.state === lt.Ready) {
                                let t = "replaceState";
                                n && !ut && (t = "pushState", ut = !0), window.history[t]({}, document.title, window.location.pathname + window.location.search + e)
                            }
                        } catch (t) {}
                    }), 300))
                }
                onClose(t) {
                    if (pt && clearTimeout(pt), !dt && ut) return ut = !1, dt = !1, void window.history.back();
                    if (!dt) try {
                        window.history.replaceState({}, document.title, window.location.pathname + window.location.search + (ht || ""))
                    } catch (t) {}
                }
                attach() {
                    const t = this.instance;
                    t.on("ready", this.onReady), t.on(["Carousel.ready", "Carousel.change"], this.onChange), t.on("close", this.onClose)
                }
                detach() {
                    const t = this.instance;
                    t.off("ready", this.onReady), t.off(["Carousel.ready", "Carousel.change"], this.onChange), t.off("close", this.onClose)
                }
                static parseURL() {
                    return gt()
                }
                static startFromUrl() {
                    mt()
                }
                static destroy() {
                    window.removeEventListener("hashchange", bt, !1)
                }
            },
            Html: zt,
            Images: xt,
            Slideshow: Ft,
            Thumbs: Vt,
            Toolbar: te
        },
        ie = "with-fancybox",
        ne = "hide-scrollbar",
        se = "--fancybox-scrollbar-compensate",
        oe = "--fancybox-body-margin",
        ae = "aria-hidden",
        re = "is-using-tab",
        le = "is-animated",
        ce = "is-compact",
        he = "is-loading",
        de = "is-opening",
        ue = "has-caption",
        pe = "disabled",
        fe = "tabindex",
        ge = "download",
        me = "href",
        ve = "src",
        be = t => "string" == typeof t,
        ye = function() {
            var t = window.getSelection();
            return !!t && "Range" === t.type
        };
    let we, xe = null,
        Ee = null,
        Se = 0,
        Pe = 0,
        Ce = 0,
        Te = 0;
    const Me = new Map;
    let Oe = 0;
    class Ae extends m {
        get isIdle() {
            return this.idle
        }
        get isCompact() {
            return this.option("compact")
        }
        constructor(t = [], e = {}, i = {}) {
            super(e), Object.defineProperty(this, "userSlides", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: []
            }), Object.defineProperty(this, "userPlugins", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: {}
            }), Object.defineProperty(this, "idle", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            }), Object.defineProperty(this, "idleTimer", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "clickTimer", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "pwt", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "ignoreFocusChange", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            }), Object.defineProperty(this, "startedFs", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: !1
            }), Object.defineProperty(this, "state", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: lt.Init
            }), Object.defineProperty(this, "id", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: 0
            }), Object.defineProperty(this, "container", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "caption", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "footer", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "carousel", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "lastFocus", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: null
            }), Object.defineProperty(this, "prevMouseMoveEvent", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), we || (we = at()), this.id = e.id || ++Oe, Me.set(this.id, this), this.userSlides = t, this.userPlugins = i, queueMicrotask((() => {
                this.init()
            }))
        }
        init() {
            if (this.state === lt.Destroy) return;
            this.state = lt.Init, this.attachPlugins(Object.assign(Object.assign({}, Ae.Plugins), this.userPlugins)), this.emit("init"), this.emit("attachPlugins"), !0 === this.option("hideScrollbar") && (() => {
                if (!it) return;
                const t = document,
                    e = t.body,
                    i = t.documentElement;
                if (e.classList.contains(ne)) return;
                let n = window.innerWidth - i.getBoundingClientRect().width;
                const s = parseFloat(window.getComputedStyle(e).marginRight);
                n < 0 && (n = 0), i.style.setProperty(se, `${n}px`), s && e.style.setProperty(oe, `${s}px`), e.classList.add(ne)
            })(), this.initLayout(), this.scale();
            const t = () => {
                this.initCarousel(this.userSlides), this.state = lt.Ready, this.attachEvents(), this.emit("ready"), setTimeout((() => {
                    this.container && this.container.setAttribute(ae, "false")
                }), 16)
            };
            this.option("Fullscreen.autoStart") && we && !we.isFullscreen() ? we.request().then((() => {
                this.startedFs = !0, t()
            })).catch((() => t())) : t()
        }
        initLayout() {
            var t, e;
            const i = this.option("parentEl") || document.body,
                n = s(this.localize(this.option("tpl.main") || ""));
            if (n) {
                if (n.setAttribute("id", `fancybox-${this.id}`), n.setAttribute("aria-label", this.localize("{{MODAL}}")), n.classList.toggle(ce, this.isCompact), C(n, this.option("mainClass") || ""), C(n, de), this.container = n, this.footer = n.querySelector(".fancybox__footer"), i.appendChild(n), C(document.documentElement, ie), xe && Ee || (xe = document.createElement("span"), C(xe, "fancybox-focus-guard"), xe.setAttribute(fe, "0"), xe.setAttribute(ae, "true"), xe.setAttribute("aria-label", "Focus guard"), Ee = xe.cloneNode(), null === (t = n.parentElement) || void 0 === t || t.insertBefore(xe, n), null === (e = n.parentElement) || void 0 === e || e.append(Ee)), n.addEventListener("mousedown", (t => {
                        Se = t.pageX, Pe = t.pageY, P(n, re)
                    })), this.option("closeExisting"))
                    for (const t of Me.values()) t.id !== this.id && t.close();
                else this.option("animated") && (C(n, le), setTimeout((() => {
                    this.isClosing() || P(n, le)
                }), 350));
                this.emit("initLayout")
            }
        }
        initCarousel(t) {
            const e = this.container;
            if (!e) return;
            const n = e.querySelector(".fancybox__carousel");
            if (!n) return;
            const s = this.carousel = new tt(n, p({}, {
                slides: t,
                transition: "fade",
                Panzoom: {
                    lockAxis: this.option("dragToClose") ? "xy" : "x",
                    infinite: !!this.option("dragToClose") && "y"
                },
                Dots: !1,
                Navigation: {
                    classes: {
                        container: "fancybox__nav",
                        button: "f-button",
                        isNext: "is-next",
                        isPrev: "is-prev"
                    }
                },
                initialPage: this.option("startIndex"),
                l10n: this.option("l10n")
            }, this.option("Carousel") || {}));
            s.on("*", ((t, e, ...i) => {
                this.emit(`Carousel.${e}`, t, ...i)
            })), s.on(["ready", "change"], (() => {
                this.manageCaption()
            })), this.on("Carousel.removeSlide", ((t, e, i) => {
                this.clearContent(i), i.state = void 0
            })), s.on("Panzoom.touchStart", (() => {
                var t, e;
                this.isCompact || this.endIdle(), (null === (t = document.activeElement) || void 0 === t ? void 0 : t.closest(".f-thumbs")) && (null === (e = this.container) || void 0 === e || e.focus())
            })), s.on("settle", (() => {
                this.idleTimer || this.isCompact || !this.option("idle") || this.setIdle(), this.option("autoFocus") && !this.isClosing && this.checkFocus()
            })), this.option("dragToClose") && (s.on("Panzoom.afterTransform", ((t, e) => {
                const n = this.getSlide();
                if (n && i(n.el)) return;
                const s = this.container;
                if (s) {
                    const t = Math.abs(e.current.f),
                        i = t < 1 ? "" : Math.max(.5, Math.min(1, 1 - t / e.contentRect.fitHeight * 1.5));
                    s.style.setProperty("--fancybox-ts", i ? "0s" : ""), s.style.setProperty("--fancybox-opacity", i + "")
                }
            })), s.on("Panzoom.touchEnd", ((t, e, n) => {
                var s;
                const o = this.getSlide();
                if (o && i(o.el)) return;
                if (e.isMobile && document.activeElement && -1 !== ["TEXTAREA", "INPUT"].indexOf(null === (s = document.activeElement) || void 0 === s ? void 0 : s.nodeName)) return;
                const a = Math.abs(e.dragOffset.y);
                "y" === e.lockedAxis && (a >= 200 || a >= 50 && e.dragOffset.time < 300) && (n && n.cancelable && n.preventDefault(), this.close(n, "f-throwOut" + (e.current.f < 0 ? "Up" : "Down")))
            }))), s.on("change", (t => {
                var e;
                let i = null === (e = this.getSlide()) || void 0 === e ? void 0 : e.triggerEl;
                if (i) {
                    const e = new CustomEvent("slideTo", {
                        bubbles: !0,
                        cancelable: !0,
                        detail: t.page
                    });
                    i.dispatchEvent(e)
                }
            })), s.on(["refresh", "change"], (t => {
                const e = this.container;
                if (!e) return;
                for (const i of e.querySelectorAll("[data-fancybox-current-index]")) i.innerHTML = t.page + 1;
                for (const i of e.querySelectorAll("[data-fancybox-count]")) i.innerHTML = t.pages.length;
                if (!t.isInfinite) {
                    for (const i of e.querySelectorAll("[data-fancybox-next]")) t.page < t.pages.length - 1 ? (i.removeAttribute(pe), i.removeAttribute(fe)) : (i.setAttribute(pe, ""), i.setAttribute(fe, "-1"));
                    for (const i of e.querySelectorAll("[data-fancybox-prev]")) t.page > 0 ? (i.removeAttribute(pe), i.removeAttribute(fe)) : (i.setAttribute(pe, ""), i.setAttribute(fe, "-1"))
                }
                const i = this.getSlide();
                if (!i) return;
                let n = i.downloadSrc || "";
                n || "image" !== i.type || i.error || !be(i[ve]) || (n = i[ve]);
                for (const t of e.querySelectorAll("[data-fancybox-download]")) {
                    const e = i.downloadFilename;
                    n ? (t.removeAttribute(pe), t.removeAttribute(fe), t.setAttribute(me, n), t.setAttribute(ge, e || n), t.setAttribute("target", "_blank")) : (t.setAttribute(pe, ""), t.setAttribute(fe, "-1"), t.removeAttribute(me), t.removeAttribute(ge))
                }
            })), this.emit("initCarousel")
        }
        attachEvents() {
            const t = this,
                e = t.container;
            if (!e) return;
            e.addEventListener("click", t.onClick, {
                passive: !1,
                capture: !1
            }), e.addEventListener("wheel", t.onWheel, {
                passive: !1,
                capture: !1
            }), document.addEventListener("keydown", t.onKeydown, {
                passive: !1,
                capture: !0
            }), document.addEventListener("visibilitychange", t.onVisibilityChange, !1), document.addEventListener("mousemove", t.onMousemove), t.option("trapFocus") && document.addEventListener("focus", t.onFocus, !0), window.addEventListener("resize", t.onResize);
            const i = window.visualViewport;
            i && (i.addEventListener("scroll", t.onResize), i.addEventListener("resize", t.onResize))
        }
        detachEvents() {
            const t = this,
                e = t.container;
            if (!e) return;
            document.removeEventListener("keydown", t.onKeydown, {
                passive: !1,
                capture: !0
            }), e.removeEventListener("wheel", t.onWheel, {
                passive: !1,
                capture: !1
            }), e.removeEventListener("click", t.onClick, {
                passive: !1,
                capture: !1
            }), document.removeEventListener("mousemove", t.onMousemove), window.removeEventListener("resize", t.onResize);
            const i = window.visualViewport;
            i && (i.removeEventListener("resize", t.onResize), i.removeEventListener("scroll", t.onResize)), document.removeEventListener("visibilitychange", t.onVisibilityChange, !1), document.removeEventListener("focus", t.onFocus, !0)
        }
        scale() {
            const t = this.container;
            if (!t) return;
            const e = window.visualViewport,
                i = Math.max(1, (null == e ? void 0 : e.scale) || 1);
            let n = "",
                s = "",
                o = "";
            if (e && i > 1) {
                let t = `${e.offsetLeft}px`,
                    a = `${e.offsetTop}px`;
                n = e.width * i + "px", s = e.height * i + "px", o = `translate3d(${t}, ${a}, 0) scale(${1/i})`
            }
            t.style.transform = o, t.style.width = n, t.style.height = s
        }
        onClick(t) {
            var e;
            const {
                container: i,
                isCompact: n
            } = this;
            if (!i || this.isClosing()) return;
            !n && this.option("idle") && this.resetIdle();
            const s = t.composedPath()[0];
            if (s.closest(".fancybox-spinner") || s.closest("[data-fancybox-close]")) return t.preventDefault(), void this.close(t);
            if (s.closest("[data-fancybox-prev]")) return t.preventDefault(), void this.prev();
            if (s.closest("[data-fancybox-next]")) return t.preventDefault(), void this.next();
            if ("click" === t.type && 0 === t.detail) return;
            if (Math.abs(t.pageX - Se) > 30 || Math.abs(t.pageY - Pe) > 30) return;
            const o = document.activeElement;
            if (ye() && o && i.contains(o)) return;
            if (n && "image" === (null === (e = this.getSlide()) || void 0 === e ? void 0 : e.type)) return void(this.clickTimer ? (clearTimeout(this.clickTimer), this.clickTimer = null) : this.clickTimer = setTimeout((() => {
                this.toggleIdle(), this.clickTimer = null
            }), 350));
            if (this.emit("click", t), t.defaultPrevented) return;
            let a = !1;
            if (s.closest(".fancybox__content")) {
                if (o) {
                    if (o.closest("[contenteditable]")) return;
                    s.matches(st) || o.blur()
                }
                if (ye()) return;
                a = this.option("contentClick")
            } else s.closest(".fancybox__carousel") && !s.matches(st) && (a = this.option("backdropClick"));
            "close" === a ? (t.preventDefault(), this.close(t)) : "next" === a ? (t.preventDefault(), this.next()) : "prev" === a && (t.preventDefault(), this.prev())
        }
        onWheel(t) {
            const e = t.target;
            let i = this.option("wheel", t);
            e.closest(".fancybox__thumbs") && (i = "slide");
            const s = "slide" === i,
                o = [-t.deltaX || 0, -t.deltaY || 0, -t.detail || 0].reduce((function(t, e) {
                    return Math.abs(e) > Math.abs(t) ? e : t
                })),
                a = Math.max(-1, Math.min(1, o)),
                r = Date.now();
            this.pwt && r - this.pwt < 300 ? s && t.preventDefault() : (this.pwt = r, this.emit("wheel", t, a), t.defaultPrevented || ("close" === i ? (t.preventDefault(), this.close(t)) : "slide" === i && (n(e) || (t.preventDefault(), this[a > 0 ? "prev" : "next"]()))))
        }
        onScroll() {
            window.scrollTo(Ce, Te)
        }
        onKeydown(t) {
            if (!this.isTopmost()) return;
            this.isCompact || !this.option("idle") || this.isClosing() || this.resetIdle();
            const e = t.key,
                i = this.option("keyboard");
            if (!i) return;
            const n = t.composedPath()[0],
                s = document.activeElement && document.activeElement.classList,
                o = s && s.contains("f-button") || n.dataset.carouselPage || n.dataset.carouselIndex;
            if ("Escape" !== e && !o && S(n)) {
                if (n.isContentEditable || -1 !== ["TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO"].indexOf(n.nodeName)) return
            }
            if ("Tab" === t.key ? C(this.container, re) : P(this.container, re), t.ctrlKey || t.altKey || t.shiftKey) return;
            this.emit("keydown", e, t);
            const a = i[e];
            a && "function" == typeof this[a] && (t.preventDefault(), this[a]())
        }
        onResize() {
            const t = this.container;
            if (!t) return;
            const e = this.isCompact;
            t.classList.toggle(ce, e), this.manageCaption(this.getSlide()), this.isCompact ? this.clearIdle() : this.endIdle(), this.scale(), this.emit("resize")
        }
        onFocus(t) {
            this.isTopmost() && this.checkFocus(t)
        }
        onMousemove(t) {
            this.prevMouseMoveEvent = t, !this.isCompact && this.option("idle") && this.resetIdle()
        }
        onVisibilityChange() {
            "visible" === document.visibilityState ? this.checkFocus() : this.endIdle()
        }
        manageCloseBtn(t) {
            const e = this.optionFor(t, "closeButton") || !1;
            if ("auto" === e) {
                const t = this.plugins.Toolbar;
                if (t && t.state === Ut.Ready) return
            }
            if (!e) return;
            if (!t.contentEl || t.closeBtnEl) return;
            const i = this.option("tpl.closeButton");
            if (i) {
                const e = s(this.localize(i));
                t.closeBtnEl = t.contentEl.appendChild(e), t.el && C(t.el, "has-close-btn")
            }
        }
        manageCaption(t = void 0) {
            return;
            var e, i;
            const n = "fancybox__caption",
                s = this.container;
            if (!s) return;
            P(s, ue);
            const o = this.isCompact || this.option("commonCaption"),
                a = !o;
            if (this.caption && this.stop(this.caption), a && this.caption && (this.caption.remove(), this.caption = null), o && !this.caption)
                for (const t of (null === (e = this.carousel) || void 0 === e ? void 0 : e.slides) || []) t.captionEl && (t.captionEl.remove(), t.captionEl = void 0, P(t.el, ue), null === (i = t.el) || void 0 === i || i.removeAttribute("aria-labelledby"));
            if (t || (t = this.getSlide()), !t || o && !this.isCurrentSlide(t)) return;
            const r = t.el;
            let l = this.optionFor(t, "caption", "");
            if (!l) return void(o && this.caption && this.animate(this.caption, "f-fadeOut", (() => {
                this.caption && (this.caption.innerHTML = "")
            })));
            let c = null;
            if (a) {
                if (c = t.captionEl || null, r && !c) {
                    const e = n + `_${this.id}_${t.index}`;
                    c = document.createElement("div"), C(c, n), c.setAttribute("id", e), t.captionEl = r.appendChild(c), C(r, ue), r.setAttribute("aria-labelledby", e)
                }
            } else {
                if (c = this.caption, c || (c = s.querySelector("." + n)), !c) {
                    c = document.createElement("div"), c.dataset.fancyboxCaption = "", C(c, n);
                    (this.footer || s).prepend(c)
                }
                C(s, ue), this.caption = c
            }
            c && (c.innerHTML = "", be(l) || "number" == typeof l ? c.innerHTML = l + "" : l instanceof HTMLElement && c.appendChild(l))
        }
        checkFocus(t) {
            this.focus(t)
        }
        focus(t) {
            var e;
            if (this.ignoreFocusChange) return;
            const i = document.activeElement || null,
                n = (null == t ? void 0 : t.target) || null,
                s = this.container,
                o = null === (e = this.carousel) || void 0 === e ? void 0 : e.viewport;
            if (!s || !o) return;
            if (!t && i && s.contains(i)) return;
            const a = this.getSlide(),
                r = a && a.state === ct.Ready ? a.el : null;
            if (!r || r.contains(i) || s === i) return;
            t && t.cancelable && t.preventDefault(), this.ignoreFocusChange = !0;
            const l = Array.from(s.querySelectorAll(st));
            let c = [],
                h = null;
            for (let t of l) {
                const e = !t.offsetParent || !!t.closest('[aria-hidden="true"]'),
                    i = r && r.contains(t),
                    n = !o.contains(t);
                if (t === s || (i || n) && !e) {
                    c.push(t);
                    const e = t.dataset.origTabindex;
                    void 0 !== e && e && (t.tabIndex = parseFloat(e)), t.removeAttribute("data-orig-tabindex"), !t.hasAttribute("autoFocus") && h || (h = t)
                } else {
                    const e = void 0 === t.dataset.origTabindex ? t.getAttribute("tabindex") || "" : t.dataset.origTabindex;
                    e && (t.dataset.origTabindex = e), t.tabIndex = -1
                }
            }
            let d = null;
            t ? (!n || c.indexOf(n) < 0) && (d = h || s, c.length && (i === Ee ? d = c[0] : this.lastFocus !== s && i !== xe || (d = c[c.length - 1]))) : d = a && "image" === a.type ? s : h || s, d && ot(d), this.lastFocus = document.activeElement, this.ignoreFocusChange = !1
        }
        next() {
            const t = this.carousel;
            t && t.pages.length > 1 && t.slideNext()
        }
        prev() {
            const t = this.carousel;
            t && t.pages.length > 1 && t.slidePrev()
        }
        jumpTo(...t) {
            this.carousel && this.carousel.slideTo(...t)
        }
        isTopmost() {
            var t;
            return (null === (t = Ae.getInstance()) || void 0 === t ? void 0 : t.id) == this.id
        }
        animate(t = null, e = "", i) {
            if (!t || !e) return void(i && i());
            this.stop(t);
            const n = s => {
                s.target === t && t.dataset.animationName && (t.removeEventListener("animationend", n), delete t.dataset.animationName, i && i(), P(t, e))
            };
            t.dataset.animationName = e, t.addEventListener("animationend", n), C(t, e)
        }
        stop(t) {
            t && t.dispatchEvent(new CustomEvent("animationend", {
                bubbles: !1,
                cancelable: !0,
                currentTarget: t
            }))
        }
        setContent(t, e = "", i = !0) {
            if (this.isClosing()) return;
            const n = t.el;
            if (!n) return;
            let o = null;
            if (S(e) ? o = e : (o = s(e + ""), S(o) || (o = document.createElement("div"), o.innerHTML = e + "")), ["img", "picture", "iframe", "video", "audio"].includes(o.nodeName.toLowerCase())) {
                const t = document.createElement("div");
                t.appendChild(o), o = t
            }
            S(o) && t.filter && !t.error && (o = o.querySelector(t.filter)), o && S(o) ? (C(o, "fancybox__content"), t.id && o.setAttribute("id", t.id), n.classList.add(`has-${t.error?"error":t.type||"unknown"}`), n.prepend(o), "none" === o.style.display && (o.style.display = ""), "none" === getComputedStyle(o).getPropertyValue("display") && (o.style.display = t.display || this.option("defaultDisplay") || "flex"), t.contentEl = o, i && this.revealContent(t), this.manageCloseBtn(t), this.manageCaption(t)) : this.setError(t, "{{ELEMENT_NOT_FOUND}}")
        }
        revealContent(t, e) {
            const i = t.el,
                n = t.contentEl;
            i && n && (this.emit("reveal", t), this.hideLoading(t), t.state = ct.Opening, (e = this.isOpeningSlide(t) ? void 0 === e ? this.optionFor(t, "showClass") : e : "f-fadeIn") ? this.animate(n, e, (() => {
                this.done(t)
            })) : this.done(t))
        }
        done(t) {
            this.isClosing() || (t.state = ct.Ready, this.emit("done", t), C(t.el, "is-done"), this.isCurrentSlide(t) && this.option("autoFocus") && queueMicrotask((() => {
                var e;
                null === (e = t.panzoom) || void 0 === e || e.updateControls(), this.option("autoFocus") && this.focus()
            })), this.isOpeningSlide(t) && (P(this.container, de), !this.isCompact && this.option("idle") && this.setIdle()))
        }
        isCurrentSlide(t) {
            const e = this.getSlide();
            return !(!t || !e) && e.index === t.index
        }
        isOpeningSlide(t) {
            var e, i;
            return null === (null === (e = this.carousel) || void 0 === e ? void 0 : e.prevPage) && t && t.index === (null === (i = this.getSlide()) || void 0 === i ? void 0 : i.index)
        }
        showLoading(t) {
            t.state = ct.Loading;
            const e = t.el;
            if (!e) return;
            C(e, he), this.emit("loading", t), t.spinnerEl || setTimeout((() => {
                if (!this.isClosing() && !t.spinnerEl && t.state === ct.Loading) {
                    let i = s(E);
                    C(i, "fancybox-spinner"), t.spinnerEl = i, e.prepend(i), this.animate(i, "f-fadeIn")
                }
            }), 250)
        }
        hideLoading(t) {
            const e = t.el;
            if (!e) return;
            const i = t.spinnerEl;
            this.isClosing() ? null == i || i.remove() : (P(e, he), i && this.animate(i, "f-fadeOut", (() => {
                i.remove()
            })), t.state === ct.Loading && (this.emit("loaded", t), t.state = ct.Ready))
        }
        setError(t, e) {
            if (this.isClosing()) return;
            const i = new Event("error", {
                bubbles: !0,
                cancelable: !0
            });
            if (this.emit("error", i, t), i.defaultPrevented) return;
            t.error = e, this.hideLoading(t), this.clearContent(t);
            const n = document.createElement("div");
            n.classList.add("fancybox-error"), n.innerHTML = this.localize(e || "<p>{{ERROR}}</p>"), this.setContent(t, n)
        }
        clearContent(t) {
            if (void 0 === t.state) return;
            this.emit("clearContent", t), t.contentEl && (t.contentEl.remove(), t.contentEl = void 0);
            const e = t.el;
            e && (P(e, "has-error"), P(e, "has-unknown"), P(e, `has-${t.type||"unknown"}`)), t.closeBtnEl && t.closeBtnEl.remove(), t.closeBtnEl = void 0, t.captionEl && t.captionEl.remove(), t.captionEl = void 0, t.spinnerEl && t.spinnerEl.remove(), t.spinnerEl = void 0
        }
        getSlide() {
            var t;
            const e = this.carousel;
            return (null === (t = null == e ? void 0 : e.pages[null == e ? void 0 : e.page]) || void 0 === t ? void 0 : t.slides[0]) || void 0
        }
        close(t, e) {
            if (this.isClosing()) return;
            const i = new Event("shouldClose", {
                bubbles: !0,
                cancelable: !0
            });
            if (this.emit("shouldClose", i, t), i.defaultPrevented) return;
            t && t.cancelable && (t.preventDefault(), t.stopPropagation());
            const n = () => {
                this.proceedClose(t, e)
            };
            this.startedFs && we && we.isFullscreen() ? Promise.resolve(we.exit()).then((() => n())) : n()
        }
        clearIdle() {
            this.idleTimer && clearTimeout(this.idleTimer), this.idleTimer = null
        }
        setIdle(t = !1) {
            const e = () => {
                this.clearIdle(), this.idle = !0, C(this.container, "is-idle"), this.emit("setIdle")
            };
            if (this.clearIdle(), !this.isClosing())
                if (t) e();
                else {
                    const t = this.option("idle");
                    t && (this.idleTimer = setTimeout(e, t))
                }
        }
        endIdle() {
            this.clearIdle(), this.idle && !this.isClosing() && (this.idle = !1, P(this.container, "is-idle"), this.emit("endIdle"))
        }
        resetIdle() {
            this.endIdle(), this.setIdle()
        }
        toggleIdle() {
            this.idle ? this.endIdle() : this.setIdle(!0)
        }
        toggleFullscreen() {
            we && (we.isFullscreen() ? we.exit() : we.request().then((() => {
                this.startedFs = !0
            })))
        }
        isClosing() {
            return [lt.Closing, lt.CustomClosing, lt.Destroy].includes(this.state)
        }
        proceedClose(t, e) {
            var i, n;
            this.state = lt.Closing, this.clearIdle(), this.detachEvents();
            const s = this.container,
                o = this.carousel,
                a = this.getSlide(),
                r = a && this.option("placeFocusBack") ? a.triggerEl || this.option("triggerEl") : null;
            if (r && (et(r) ? ot(r) : r.focus()), s && (P(s, de), C(s, "is-closing"), s.setAttribute(ae, "true"), this.option("animated") && C(s, le), s.style.pointerEvents = "none"), o) {
                o.clearTransitions(), null === (i = o.panzoom) || void 0 === i || i.destroy(), null === (n = o.plugins.Navigation) || void 0 === n || n.detach();
                for (const t of o.slides) {
                    t.state = ct.Closing, this.hideLoading(t);
                    const e = t.contentEl;
                    e && this.stop(e);
                    const i = null == t ? void 0 : t.panzoom;
                    i && (i.stop(), i.detachEvents(), i.detachObserver()), this.isCurrentSlide(t) || o.emit("removeSlide", t)
                }
            }
            Ce = window.scrollX, Te = window.scrollY, window.addEventListener("scroll", this.onScroll), this.emit("close", t), this.state !== lt.CustomClosing ? (void 0 === e && a && (e = this.optionFor(a, "hideClass")), e && a ? (this.animate(a.contentEl, e, (() => {
                o && o.emit("removeSlide", a)
            })), setTimeout((() => {
                this.destroy()
            }), 500)) : this.destroy()) : setTimeout((() => {
                this.destroy()
            }), 500)
        }
        destroy() {
            var t;
            if (this.state === lt.Destroy) return;
            window.removeEventListener("scroll", this.onScroll), this.state = lt.Destroy, null === (t = this.carousel) || void 0 === t || t.destroy();
            const e = this.container;
            e && e.remove(), Me.delete(this.id);
            const i = Ae.getInstance();
            i ? i.focus() : (xe && (xe.remove(), xe = null), Ee && (Ee.remove(), Ee = null), P(document.documentElement, ie), (() => {
                if (!it) return;
                const t = document,
                    e = t.body;
                e.classList.remove(ne), e.style.setProperty(oe, ""), t.documentElement.style.setProperty(se, "")
            })(), this.emit("destroy"))
        }
        static bind(t, e, i) {
            if (!it) return;
            let n, s = "",
                o = {};
            if (void 0 === t ? n = document.body : be(t) ? (n = document.body, s = t, "object" == typeof e && (o = e || {})) : (n = t, be(e) && (s = e), "object" == typeof i && (o = i || {})), !n || !S(n)) return;
            s = s || "[data-fancybox]";
            const a = Ae.openers.get(n) || new Map;
            a.set(s, o), Ae.openers.set(n, a), 1 === a.size && n.addEventListener("click", Ae.fromEvent)
        }
        static unbind(t, e) {
            let i, n = "";
            if (be(t) ? (i = document.body, n = t) : (i = t, be(e) && (n = e)), !i) return;
            const s = Ae.openers.get(i);
            s && n && s.delete(n), n && s || (Ae.openers.delete(i), i.removeEventListener("click", Ae.fromEvent))
        }
        static destroy() {
            let t;
            for (; t = Ae.getInstance();) t.destroy();
            for (const t of Ae.openers.keys()) t.removeEventListener("click", Ae.fromEvent);
            Ae.openers = new Map
        }
        static fromEvent(t) {
            if (t.defaultPrevented) return;
            if (t.button && 0 !== t.button) return;
            if (t.ctrlKey || t.metaKey || t.shiftKey) return;
            let e = t.composedPath()[0];
            const i = e.closest("[data-fancybox-trigger]");
            if (i) {
                const t = i.dataset.fancyboxTrigger || "",
                    n = document.querySelectorAll(`[data-fancybox="${t}"]`),
                    s = parseInt(i.dataset.fancyboxIndex || "", 10) || 0;
                e = n[s] || e
            }
            if (!(e && e instanceof Element)) return;
            let n, s, o, a;
            if ([...Ae.openers].reverse().find((([t, i]) => !(!t.contains(e) || ![...i].reverse().find((([i, r]) => {
                    let l = e.closest(i);
                    return !!l && (n = t, s = i, o = l, a = r, !0)
                }))))), !n || !s || !o) return;
            a = a || {}, t.preventDefault(), e = o;
            let r = [],
                l = p({}, rt, a);
            l.event = t, l.triggerEl = e, l.delegate = i;
            const c = l.groupAll,
                h = l.groupAttr,
                d = h && e ? e.getAttribute(`${h}`) : "";
            if ((!e || d || c) && (r = [].slice.call(n.querySelectorAll(s))), e && !c && (r = d ? r.filter((t => t.getAttribute(`${h}`) === d)) : [e]), !r.length) return;
            const u = Ae.getInstance();
            return u && u.options.triggerEl && r.indexOf(u.options.triggerEl) > -1 ? void 0 : (e && (l.startIndex = r.indexOf(e)), Ae.fromNodes(r, l))
        }
        static fromSelector(t, e, i) {
            let n = null,
                s = "",
                o = {};
            if (be(t) ? (n = document.body, s = t, "object" == typeof e && (o = e || {})) : t instanceof HTMLElement && be(e) && (n = t, s = e, "object" == typeof i && (o = i || {})), !n || !s) return !1;
            const a = Ae.openers.get(n);
            return !!a && (o = p({}, a.get(s) || {}, o), !!o && Ae.fromNodes(Array.from(n.querySelectorAll(s)), o))
        }
        static fromNodes(t, e) {
            e = p({}, rt, e || {});
            const i = [];
            for (const n of t) {
                const t = n.dataset || {},
                    s = t[ve] || n.getAttribute(me) || n.getAttribute("currentSrc") || n.getAttribute(ve) || void 0;
                let o;
                const a = e.delegate;
                let r;
                a && i.length === e.startIndex && (o = a instanceof HTMLImageElement ? a : a.querySelector("img:not([aria-hidden])")), o || (o = n instanceof HTMLImageElement ? n : n.querySelector("img:not([aria-hidden])")), o && (r = o.currentSrc || o[ve] || void 0, !r && o.dataset && (r = o.dataset.lazySrc || o.dataset[ve] || void 0));
                const l = {
                    src: s,
                    triggerEl: n,
                    thumbEl: o,
                    thumbElSrc: r,
                    thumbSrc: r
                };
                for (const e in t) {
                    let i = t[e] + "";
                    i = "false" !== i && ("true" === i || i), l[e] = i
                }
                i.push(l)
            }
            return new Ae(i, e)
        }
        static getInstance(t) {
            if (t) return Me.get(t);
            return Array.from(Me.values()).reverse().find((t => !t.isClosing() && t)) || null
        }
        static getSlide() {
            var t;
            return (null === (t = Ae.getInstance()) || void 0 === t ? void 0 : t.getSlide()) || null
        }
        static show(t = [], e = {}) {
            return new Ae(t, e)
        }
        static next() {
            const t = Ae.getInstance();
            t && t.next()
        }
        static prev() {
            const t = Ae.getInstance();
            t && t.prev()
        }
        static close(t = !0, ...e) {
            if (t)
                for (const t of Me.values()) t.close(...e);
            else {
                const t = Ae.getInstance();
                t && t.close(...e)
            }
        }
    }
    Object.defineProperty(Ae, "version", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: "5.0.36"
    }), Object.defineProperty(Ae, "defaults", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: rt
    }), Object.defineProperty(Ae, "Plugins", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: ee
    }), Object.defineProperty(Ae, "openers", {
        enumerable: !0,
        configurable: !0,
        writable: !0,
        value: new Map
    }), t.Carousel = tt, t.Fancybox = Ae, t.Panzoom = D
}));