// source --> https://tpc.ch/wp-content/plugins/ele-custom-skin/modules/container-layout/assets/js/ecs-slider.js?ver=4.3.6 
( function () {
	'use strict';

	var CHEVRON_PREV = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><path d="M15.5 5 8.5 12.5 15.5 20" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>';
	var CHEVRON_NEXT = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><path d="M9.5 5 16.5 12.5 9.5 20" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>';

	// ── Live mode (PHP generated Swiper HTML) ─────────────────────────────────

	function doInitLiveSlider( el ) {
		el.setAttribute( 'data-ecs-swiper-init', '1' );

		var settings = JSON.parse( el.getAttribute( 'data-ecs-slider-settings' ) || '{}' );

		if ( settings.navigation ) {
			settings.navigation = {
				prevEl: el.querySelector( '.elementor-swiper-button-prev' ),
				nextEl: el.querySelector( '.elementor-swiper-button-next' ),
			};
		}
		if ( settings.pagination ) {
			settings.pagination.el = el.querySelector( '.swiper-pagination' );
		}

		new Swiper( el, settings ); // eslint-disable-line no-undef
	}

	function initLiveSlider( el ) {
		if ( el.hasAttribute( 'data-ecs-swiper-init' ) ) {
			return;
		}

		// Defer init if hidden (e.g. inside display:none responsive-version on desktop).
		// ResizeObserver fires when CSS shows the element — media query triggered by viewport change.
		if ( el.offsetWidth === 0 && typeof ResizeObserver !== 'undefined' ) {
			el.setAttribute( 'data-ecs-swiper-init', 'pending' );
			var ro = new ResizeObserver( function ( entries ) {
				if ( entries[ 0 ].contentRect.width > 0 ) {
					ro.disconnect();
					el.removeAttribute( 'data-ecs-swiper-init' );
					doInitLiveSlider( el );
				}
			} );
			ro.observe( el );
			return;
		}

		doInitLiveSlider( el );
	}

	function initAllLiveSliders() {
		document.querySelectorAll( '.ecs-swiper:not([data-ecs-swiper-init])' ).forEach( initLiveSlider );
	}

	// ── Editor mode (JS builds Swiper from existing DOM) ──────────────────────

	/**
	 * Read slider control values from the parent editor's Backbone model.
	 * This is the same pattern used in ecs-editor-preview.js.
	 */
	function getEditorSettings( containerId ) {
		try {
			return window.parent.elementor.getContainer( containerId ).settings.toJSON();
		} catch ( e ) {
			return {};
		}
	}

	function buildSwiperConfig( s ) {
		var navigation = s.ecs_navigation || 'arrows';
		var showArrows = navigation === 'arrows' || navigation === 'both';
		var showDots   = navigation === 'dots'   || navigation === 'both';

		var colsDesktop = parseInt( s.ecs_slider_columns, 10 ) || 1;
		var colsTablet  = parseInt( s.ecs_slider_columns_tablet, 10 ) || colsDesktop;
		var colsMobile  = parseInt( s.ecs_slider_columns_mobile, 10 ) || colsTablet;
		var layoutTablet = s.ecs_container_type_tablet || '';
		var layoutMobile = s.ecs_container_type_mobile || '';

		var config = {
			slidesPerView: colsDesktop,
			loop:          s.ecs_loop === 'yes',
			speed:         parseInt( s.ecs_speed, 10 ) || 500,
			spaceBetween:  parseInt( s.ecs_space_between, 10 ) || 0,
			breakpoints: {
				0: {
					slidesPerView: colsMobile,
					enabled: layoutMobile !== 'flex' && layoutMobile !== 'grid',
				},
				768: {
					slidesPerView: colsTablet,
					enabled: layoutTablet !== 'flex' && layoutTablet !== 'grid',
				},
				1025: {
					slidesPerView: colsDesktop,
					enabled: true,
				},
			},
		};

		if ( s.ecs_autoplay === 'yes' ) {
			config.autoplay = {
				delay:                parseInt( s.ecs_autoplay_speed, 10 ) || 3000,
				pauseOnMouseEnter:    s.ecs_pause_on_hover === 'yes',
				disableOnInteraction: false,
			};
		}

		return { config: config, showArrows: showArrows, showDots: showDots };
	}

	/**
	 * Move real children back to their scope (e-con-inner or container) then remove swiper.
	 * Using real elements (not clones) keeps Backbone model-binding intact and allows editing.
	 */
	function destroyEditorSlider( containerEl ) {
		var existing = containerEl.querySelector( ':scope > .ecs-editor-swiper' );
		if ( existing ) {
			var inner = containerEl.querySelector( ':scope > .e-con-inner' );
			var scope = inner || containerEl;
			// Move real children back from slides to scope, preserving order
			existing.querySelectorAll( ':scope > .swiper-wrapper > .swiper-slide:not(.swiper-slide-duplicate)' ).forEach( function ( slide ) {
				var child = Array.from( slide.children ).find( function ( el ) {
					return el.dataset && el.dataset.id;
				} );
				if ( child ) {
					scope.appendChild( child );
				}
			} );
			if ( existing.swiper ) {
				existing.swiper.destroy( true, true );
			}
			existing.remove();
		}
		containerEl.classList.remove( 'ecs-editor-slider-active' );
		containerEl.removeAttribute( 'data-ecs-slider-key' );
		containerEl.removeAttribute( 'data-ecs-rebuild-key' );
	}

	/** Cache key based on child IDs only (structural changes). */
	function sliderKey( children ) {
		return children.map( function ( el ) { return el.getAttribute( 'data-id' ); } ).join( ',' );
	}

	/**
	 * Key for settings that require HTML rebuild (navigation type).
	 * Non-structural settings (columns, speed…) are updated in-place by
	 * updateEditorSliderParams() to avoid disturbing the live DOM.
	 */
	function rebuildKey( built ) {
		return ( built.showArrows ? 'a' : '' ) + ( built.showDots ? 'd' : '' );
	}

	/**
	 * Build editor swiper by MOVING real children into slides (not cloning).
	 * Real elements stay connected to their Backbone views so they remain editable.
	 * Loop is disabled in editor to prevent Swiper from creating duplicate [data-id] nodes.
	 */
	function buildEditorSlider( containerEl ) {
		var id       = containerEl.getAttribute( 'data-id' );
		var settings = getEditorSettings( id );

		var inner    = containerEl.querySelector( ':scope > .e-con-inner' );
		var scope    = inner || containerEl;
		var children = Array.from( scope.children ).filter( function ( el ) {
			return el.dataset && el.dataset.id;
		} );

		if ( ! children.length ) {
			return;
		}

		var built      = buildSwiperConfig( settings );
		built.config.loop = false; // disable loop in editor — avoids duplicate [data-id] nodes

		var swiperEl   = document.createElement( 'div' );
		swiperEl.className = 'swiper ecs-swiper ecs-editor-swiper';

		var wrapperEl  = document.createElement( 'div' );
		wrapperEl.className = 'swiper-wrapper';

		// Move real children into slides — preserves Backbone binding and allows editing
		children.forEach( function ( child ) {
			var slide = document.createElement( 'div' );
			slide.className = 'swiper-slide';
			slide.appendChild( child ); // MOVE, not clone
			wrapperEl.appendChild( slide );
		} );
		swiperEl.appendChild( wrapperEl );

		if ( built.showArrows ) {
			swiperEl.insertAdjacentHTML( 'beforeend',
				'<div class="elementor-swiper-button elementor-swiper-button-prev" role="button" tabindex="0">' + CHEVRON_PREV + '</div>' +
				'<div class="elementor-swiper-button elementor-swiper-button-next" role="button" tabindex="0">' + CHEVRON_NEXT + '</div>'
			);
			built.config.navigation = {
				prevEl: swiperEl.querySelector( '.elementor-swiper-button-prev' ),
				nextEl: swiperEl.querySelector( '.elementor-swiper-button-next' ),
			};
		}

		if ( built.showDots ) {
			swiperEl.insertAdjacentHTML( 'beforeend', '<div class="swiper-pagination"></div>' );
			built.config.pagination = {
				el:        swiperEl.querySelector( '.swiper-pagination' ),
				clickable: true,
			};
		}

		// CSS class hides empty .e-con-inner (children were moved out into swiper slides)
		containerEl.classList.add( 'ecs-editor-slider-active' );
		containerEl.appendChild( swiperEl );
		containerEl.setAttribute( 'data-ecs-slider-key', sliderKey( children ) );
		containerEl.setAttribute( 'data-ecs-rebuild-key', rebuildKey( built ) );

		if ( typeof Swiper !== 'undefined' ) { // eslint-disable-line no-undef
			new Swiper( swiperEl, built.config ); // eslint-disable-line no-undef
		}
	}

	function syncEditorSlider( containerEl ) {
		// Backbone re-render may have removed .ecs-editor-swiper while leaving
		// ecs-editor-slider-active class — reset so we fall through to rebuild.
		if (
			containerEl.classList.contains( 'ecs-editor-slider-active' ) &&
			! containerEl.querySelector( ':scope > .ecs-editor-swiper' )
		) {
			destroyEditorSlider( containerEl );
		}

		var swiperEl = containerEl.querySelector( ':scope > .ecs-editor-swiper' );
		var inner    = containerEl.querySelector( ':scope > .e-con-inner' );
		var scope    = inner || containerEl;

		var children;
		if ( swiperEl ) {
			// Slider active: real children live inside swiper slides
			var slideChildren = Array.from(
				swiperEl.querySelectorAll( ':scope > .swiper-wrapper > .swiper-slide:not(.swiper-slide-duplicate)' )
			).map( function ( slide ) {
				return Array.from( slide.children ).find( function ( el ) {
					return el.dataset && el.dataset.id;
				} );
			} ).filter( Boolean );

			// Plus any new direct scope children Backbone may have appended (new widget added)
			var newScopeChildren = Array.from( scope.children ).filter( function ( el ) {
				return el.dataset && el.dataset.id;
			} );
			children = slideChildren.concat( newScopeChildren );
		} else {
			children = Array.from( scope.children ).filter( function ( el ) {
				return el.dataset && el.dataset.id;
			} );
		}

		var cached = containerEl.getAttribute( 'data-ecs-slider-key' );
		if ( cached !== null && cached === sliderKey( children ) ) {
			return; // structure unchanged
		}

		destroyEditorSlider( containerEl ); // moves children back to scope
		if ( children.length ) {
			buildEditorSlider( containerEl );
		}
	}

	/**
	 * Return the resolved ecs_container_type for the current device mode.
	 * Inherits from larger breakpoints when device-specific value is empty.
	 * Mirrors the same logic in ecs-editor-preview.js (parent frame).
	 */
	function getResolvedType( containerEl ) {
		var id = containerEl.getAttribute( 'data-id' );
		if ( ! id ) { return 'flex'; }
		try {
			var device   = window.parent.elementor.channels.deviceMode.request( 'currentMode' ) || 'desktop';
			var settings = window.parent.elementor.getContainer( id ).settings;
			var suffixes = { desktop: '', tablet: '_tablet', mobile: '_mobile' };
			var order    = device === 'mobile'  ? [ 'mobile', 'tablet', 'desktop' ]
			             : device === 'tablet'  ? [ 'tablet', 'desktop' ]
			             : [ 'desktop' ];
			for ( var i = 0; i < order.length; i++ ) {
				var val = settings.get( 'ecs_container_type' + suffixes[ order[ i ] ] );
				if ( val ) { return val; }
			}
			return 'flex';
		} catch ( e ) { return 'flex'; }
	}

	function syncAllEditorSliders() {
		// Cleanup or rebuild stale active markers.
		document.querySelectorAll( '.ecs-editor-slider-active' ).forEach( function ( el ) {
			if ( getResolvedType( el ) !== 'slider' ) {
				destroyEditorSlider( el );
			} else if ( ! el.querySelector( ':scope > .ecs-editor-swiper' ) ) {
				// Elementor re-rendered and removed our swiper DOM — rebuild it.
				destroyEditorSlider( el ); // clears stale ecs-editor-slider-active class
				syncEditorSlider( el );
			}
		} );
		// Build: any container with an ECS slider class that resolves to 'slider' now.
		document.querySelectorAll( '.e-con[class*="-slider"]' ).forEach( function ( el ) {
			if ( ! el.classList.contains( 'ecs-editor-slider-active' ) && getResolvedType( el ) === 'slider' ) {
				syncEditorSlider( el );
			}
		} );
	}

	/**
	 * Update Swiper config in-place without destroy/clone.
	 * Called on settings panel changes (columns, speed, color, etc.).
	 * Falls back to full syncEditorSlider only when HTML structure must change
	 * (navigation type or loop — these require different DOM elements).
	 */
	function updateEditorSliderParams( containerEl ) {
		var swiperEl = containerEl.querySelector( ':scope > .ecs-editor-swiper' );
		if ( ! swiperEl || ! swiperEl.swiper ) {
			syncEditorSlider( containerEl ); // swiper missing — full rebuild
			return;
		}

		var id       = containerEl.getAttribute( 'data-id' );
		var settings = getEditorSettings( id );
		var built    = buildSwiperConfig( settings );
		var swiper   = swiperEl.swiper;

		// Navigation type or loop change requires HTML rebuild (different DOM structure)
		var currRebuildKey = rebuildKey( built );
		var prevRebuildKey = containerEl.getAttribute( 'data-ecs-rebuild-key' );
		if ( prevRebuildKey !== null && prevRebuildKey !== currRebuildKey ) {
			syncEditorSlider( containerEl );
			return;
		}

		// Safe in-place param update — no cloning, no race condition
		swiper.params.slidesPerView = built.config.slidesPerView;
		swiper.params.speed         = built.config.speed;
		swiper.params.spaceBetween  = built.config.spaceBetween;
		swiper.params.breakpoints   = built.config.breakpoints;

		if ( built.config.autoplay ) {
			swiper.params.autoplay = built.config.autoplay;
			if ( swiper.autoplay && ! swiper.autoplay.running ) {
				swiper.autoplay.start();
			}
		} else if ( swiper.autoplay && swiper.autoplay.running ) {
			swiper.autoplay.stop();
			swiper.params.autoplay = false;
		}

		swiper.update();
	}

	function updateAllEditorSliderParams() {
		// Clear the structural key so syncEditorSlider always rebuilds with
		// fresh settings (column count, speed, etc. may have changed).
		document.querySelectorAll( '.ecs-editor-slider-active' ).forEach( function ( el ) {
			el.removeAttribute( 'data-ecs-slider-key' );
			syncEditorSlider( el );
		} );
	}

	// ── Entry point ───────────────────────────────────────────────────────────

	var inEditMode = !! (
		window.elementorFrontend &&
		typeof elementorFrontend.isEditMode === 'function' &&
		elementorFrontend.isEditMode()
	);

	if ( inEditMode ) {
		var suppressObserver = false;

		var observer = new MutationObserver( function ( mutations ) {
			if ( suppressObserver ) { return; }

			var relevant = false;
			for ( var i = 0; i < mutations.length; i++ ) {
				var m = mutations[ i ];
				var t = m.target;
				// Skip mutations caused by our own swiper structure
				if ( t && t.classList && (
					t.classList.contains( 'ecs-editor-swiper' ) ||
					t.classList.contains( 'swiper-wrapper' ) ||
					t.classList.contains( 'swiper-slide' )
				) ) {
					continue;
				}
				relevant = true;
				break;
			}
			if ( relevant ) {
				suppressObserver = true;
				syncAllEditorSliders();
				Promise.resolve().then( function () { suppressObserver = false; } );
			}
		} );

		function setupEditor() {
			syncAllEditorSliders();
			observer.observe( document.body, {
				childList:       true,
				subtree:         true,
				attributes:      true,
				attributeFilter: [ 'class', 'data-id' ],
			} );

			// Safety rebuild at 800ms: catches cases where MutationObserver fires before
			// Backbone has finished populating widget content. syncEditorSlider will
			// also detect empty widgets on each MO-triggered call going forward.
			setTimeout( syncAllEditorSliders, 800 );

			// Settings panel changes (columns, colors, speed…) don't mutate the DOM so
			// MutationObserver never fires. Update Swiper params in-place — no cloning,
			// no race condition with Backbone re-renders.
			try {
				var settingsTimer = null;
				// editor:change fires for panel control edits in real usage.
				window.parent.elementor.channels.editor.on( 'change', function () {
					clearTimeout( settingsTimer );
					settingsTimer = setTimeout( updateAllEditorSliderParams, 150 );
				} );
				// command:after fires for every $e.run() including programmatic changes.
				window.parent.elementor.channels.data.on( 'command:after', function () {
					clearTimeout( settingsTimer );
					settingsTimer = setTimeout( updateAllEditorSliderParams, 150 );
				} );
				// Device mode switch changes which type is active — rebuild sliders.
				window.parent.elementor.channels.deviceMode.on( 'change', function () {
					clearTimeout( settingsTimer );
					settingsTimer = setTimeout( syncAllEditorSliders, 200 );
				} );
			} catch ( e ) { /* cross-origin or elementor unavailable */ }
		}

		// Expose a hook for ecs-editor-preview.js (parent frame) to call when
		// settings change. Cross-frame Backbone channels are unreliable for this.
		window.ecsSliderSettingsChanged = function () {
			// Re-sync existing active sliders with updated params.
			document.querySelectorAll( '.ecs-editor-slider-active' ).forEach( function ( el ) {
				el.removeAttribute( 'data-ecs-slider-key' );
				syncEditorSlider( el );
			} );
			// Build any new sliders that just became active (e.g. type just set to 'slider').
			syncAllEditorSliders();
		};

		// components:init already fired by the time a footer script loads.
		// Run directly — Backbone views are ready by DOMContentLoaded.
		if ( document.readyState === 'loading' ) {
			document.addEventListener( 'DOMContentLoaded', function () {
				setTimeout( setupEditor, 300 );
			} );
		} else {
			setTimeout( setupEditor, 300 );
		}

	} else {
		// Live frontend: PHP already generated Swiper HTML.
		if ( document.readyState === 'loading' ) {
			document.addEventListener( 'DOMContentLoaded', initAllLiveSliders );
		} else {
			initAllLiveSliders();
		}

		if ( typeof MutationObserver !== 'undefined' ) {
			var liveObserver = new MutationObserver( function ( mutations ) {
				var found = false;
				for ( var i = 0; i < mutations.length; i++ ) {
					var added = mutations[ i ].addedNodes;
					for ( var j = 0; j < added.length; j++ ) {
						var node = added[ j ];
						if ( node.nodeType !== 1 ) { continue; }
						if (
							( node.classList && node.classList.contains( 'ecs-swiper' ) ) ||
							( node.querySelector && node.querySelector( '.ecs-swiper:not([data-ecs-swiper-init])' ) )
						) {
							found = true;
							break;
						}
					}
					if ( found ) { break; }
				}
				if ( found ) { initAllLiveSliders(); }
			} );
			liveObserver.observe( document.body, { childList: true, subtree: true } );
		}
	}

} )();
// source --> https://tpc.ch/wp-content/plugins/elementor/assets/lib/e-gallery/js/e-gallery.min.js?ver=1.2.0 
/*! E-Gallery v1.2.0 by Elementor */
var EGallery=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=9)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}},function(t,e,i){var n=i(5),s=i(6);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?s(t):e}},function(t,e){function i(e){return t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},i(e)}t.exports=i},function(t,e,i){var n=i(7);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},function(t,e){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){return(n="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":i(t)})(t)}function s(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=s=function(t){return n(t)}:t.exports=s=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},s(e)}t.exports=s},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function i(e,n){return t.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(e,n)}t.exports=i},function(t,e,i){},function(t,e,i){"use strict";i.r(e);var n=i(0),s=i.n(n),r=i(1),a=i.n(r),o=i(2),l=i.n(o),u=i(3),c=i.n(u),h=i(4),y=i.n(h);var g=function(){function t(e){var i=this;s()(this,t),this.settings=jQuery.extend(!0,this.getDefaultSettings(),e),this.$container=jQuery(this.settings.container),this.timeouts=[],this.initElements(),this.prepareGallery();var n=this.runGallery.bind(this);this.runGallery=this.debounce(function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];i.settings.lazyLoad?n.apply(void 0,e):i.allImagesPromise.then(function(){return n.apply(void 0,e)})},300),this.settings.lazyLoad&&(this.handleScroll=this.debounce(function(){return i.lazyLoadImages()},16)),this.bindEvents(),this.runGallery()}return a()(t,[{key:"getDefaultSettings",value:function(){return{}}},{key:"getItemClass",value:function(t){return this.settings.classesPrefix+t}},{key:"initElements",value:function(){this.elements={$window:jQuery(window)};var t="-"+(this.settings.rtl?"rtl":"ltr"),e=this.getItemClass(this.settings.classes.container)+" "+this.getItemClass(this.settings.type)+" "+this.getItemClass(t);this.settings.lazyLoad&&(e+=" "+this.getItemClass(this.settings.classes.lazyLoad)),this.$container.addClass(e)}},{key:"bindEvents",value:function(){this.elements.$window.on("resize",this.runGallery),this.settings.lazyLoad&&this.elements.$window.on("scroll",this.handleScroll)}},{key:"getNestedObjectData",value:function(t,e){var i=e.split("."),n=i.splice(0,1);return i.length?this.getNestedObjectData(t[n],i.join(".")):{object:t,key:e}}},{key:"getTemplateArgs",value:function(t,e){var i=this.getNestedObjectData(t,e);return i.object[i.key]||""}},{key:"getCurrentBreakpoint",value:function(){var t=Object.keys(this.settings.breakpoints).map(Number).sort(function(t,e){return t-e}),e=0;return t.some(function(t){return innerWidth<t&&(e=t,!0)}),e}},{key:"getCurrentDeviceSetting",value:function(t){var e=this.getCurrentBreakpoint();return e?this.settings.breakpoints[e][t]:this.settings[t]}},{key:"getActiveItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.settings.tags,i=[];if(!e.length)return t?(this.$items.each(function(t){i.push(t)}),i):this.$items;var n=this.$items.filter(function(n,s){var r=s.dataset.eGalleryTags;return!!r&&(r=r.split(/[ ,]+/),!!e.some(function(t){return r.includes(t)})&&(t&&i.push(n),!0))});return t?i:n}},{key:"getImageData",value:function(t){return this.settings.tags.length&&(t=this.getActiveItems(!0)[t]),this.imagesData[t]}},{key:"compileTemplate",value:function(t,e){var i=this;return t.replace(/{{([^}]+)}}/g,function(t,n){return i.getTemplateArgs(e,n.trim())})}},{key:"createOverlay",value:function(t){var e=this.settings,i=e.classes,n=e.overlayTemplate,s=jQuery("<div>",{class:this.getItemClass(i.overlay)}),r=this.compileTemplate(n,jQuery.extend(!0,this.settings,t));return s.html(r),s}},{key:"createItem",value:function(t){var e,i=this.settings.classes,n=jQuery("<div>",{class:this.getItemClass(i.item),"data-e-gallery-tags":t.tags}),s=jQuery("<div>",{class:this.getItemClass(i.image)});this.settings.lazyLoad||s.css("background-image","url("+t.thumbnail+")"),this.settings.overlay&&(e=this.createOverlay(t));var r=n;return t.url&&(r=jQuery("<a>",{class:this.getItemClass(i.link),href:t.url}),n.html(r)),r.html(s),e&&r.append(e),n}},{key:"debounce",value:function(t,e){var i,n=this;return function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];clearTimeout(i),i=setTimeout(function(){return t.apply(void 0,r)},e),n.timeouts.push(i)}}},{key:"buildGallery",value:function(){var t=this,e=this.settings.items;this.$items=jQuery(),e.forEach(function(e){var i=t.createItem(e);t.$items=t.$items.add(i),t.$container.append(i)})}},{key:"loadImages",value:function(){var t=this,e=[];this.settings.items.forEach(function(i,n){var s=new Image,r=new Promise(function(t){s.onload=t});e.push(r),r.then(function(){return t.calculateImageSize(s,n)}),s.src=i.thumbnail}),this.allImagesPromise=Promise.all(e)}},{key:"lazyLoadImages",value:function(){var t=this;if(!this.lazyLoadComplete){var e=this.getActiveItems(),i=this.getActiveItems(!0);e.each(function(e,n){var s=t.settings.items[i[e]];if(s.loading||!function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",i=t.getBoundingClientRect().top,n=t.offsetHeight,s=i+n;return("middle"===e?i+n/2:"bottom"===e?s:i)<=innerHeight&&s>=0}(n))return!0;s.loading=!0;var r=jQuery(n),a=new Image;return new Promise(function(t){a.onload=t}).then(function(){r.find(t.settings.selectors.image).css("background-image",'url("'+s.thumbnail+'")').addClass(t.getItemClass(t.settings.classes.imageLoaded)),t.loadedItemsCount++,t.loadedItemsCount===t.settings.items.length&&(t.lazyLoadComplete=!0)}),a.src=s.thumbnail,!0})}}},{key:"calculateImageSize",value:function(t,e){this.imagesData[e]={width:t.width,height:t.height,ratio:t.width/t.height}}},{key:"createImagesData",value:function(){var t=this;this.settings.items.forEach(function(e,i){return t.calculateImageSize(e,i)})}},{key:"makeGalleryFromContent",value:function(){var t=this.settings.selectors,e=this.settings.lazyLoad,i=[];this.$items=this.$container.find(t.items),this.$items.each(function(n,s){var r=jQuery(s).find(t.image);i[n]={thumbnail:r.data("thumbnail")},e?(i[n].width=r.data("width"),i[n].height=r.data("height")):r.css("background-image",'url("'.concat(r.data("thumbnail"),'")'))}),this.settings.items=i}},{key:"prepareGallery",value:function(){this.settings.items?this.buildGallery():this.makeGalleryFromContent(),this.imagesData=[],this.settings.lazyLoad?(this.loadedItemsCount=0,this.lazyLoadComplete=!1,this.createImagesData()):this.loadImages()}},{key:"runGallery",value:function(t){var e=this,i=this.$container[0].style;i.setProperty("--hgap",this.getCurrentDeviceSetting("horizontalGap")+"px"),i.setProperty("--vgap",this.getCurrentDeviceSetting("verticalGap")+"px"),i.setProperty("--animation-duration",this.settings.animationDuration+"ms"),this.$items.addClass(this.getItemClass(this.settings.classes.hidden)),this.getActiveItems().removeClass(this.getItemClass(this.settings.classes.hidden)),this.settings.lazyLoad&&setTimeout(function(){return e.lazyLoadImages()},300),this.run(t)}},{key:"setSettings",value:function(t,e){var i=this.getNestedObjectData(this.settings,t);i.object&&(i.object[i.key]=e,this.runGallery(!0))}},{key:"unbindEvents",value:function(){this.elements.$window.off("resize",this.runGallery)}},{key:"destroy",value:function(){this.unbindEvents(),this.$container.empty(),this.timeouts.forEach(function(t){return clearTimeout(t)})}}]),t}(),f=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"getDefaultSettings",value:function(){return{aspectRatio:"16:9"}}},{key:"setItemsPosition",value:function(){var t=this.getCurrentDeviceSetting("columns");this.getActiveItems().each(function(e,i){i.style.setProperty("--column",e%t),i.style.setProperty("--row",Math.floor(e/t))})}},{key:"setContainerSize",value:function(){var t=this.getCurrentDeviceSetting("columns"),e=Math.ceil(this.getActiveItems().length/t),i=this.$container[0].style;i.setProperty("--columns",t),i.setProperty("--rows",e);var n=this.getActiveItems().width(),s=this.settings.aspectRatio.split(":"),r=s[1]/s[0],a=(r*n*e+this.getCurrentDeviceSetting("horizontalGap")*(e-1))/this.$container.width()*100;i.setProperty("--aspect-ratio",100*r+"%"),i.setProperty("--container-aspect-ratio",a+"%")}},{key:"run",value:function(){var t=this,e=this.getItemClass(this.settings.classes.animated);this.$container.addClass(e),setTimeout(function(){t.setItemsPosition(),t.setContainerSize(),setTimeout(function(){return t.$container.removeClass(e)},t.settings.animationDuration)},50)}}]),e}(g),m=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"getDefaultSettings",value:function(){return{idealRowHeight:200,lastRow:"auto",breakpoints:{1024:{idealRowHeight:150},768:{idealRowHeight:100}}}}},{key:"run",value:function(){this.rowsHeights=[],this.rowsCount=0,this.containerWidth=this.$container.width(),this.makeJustifiedRow(0)}},{key:"makeJustifiedRow",value:function(t){for(var e=0,i=t;;i++){var n=this.getImageData(i),s=Math.round(this.getCurrentDeviceSetting("idealRowHeight")*n.ratio);s>this.containerWidth&&(s=this.containerWidth);var r=e+s;if(r>this.containerWidth)if(this.containerWidth-e<r-this.containerWidth){this.fitImagesInContainer(t,i,e),this.rowsCount++,this.makeJustifiedRow(i);break}var a=i===this.getActiveItems().length-1;if(n.computedWidth=s,a){var o=this.getCurrentDeviceSetting("lastRow");if("hide"!==o){var l="fit"===o||.7<=r/this.containerWidth?r:this.containerWidth;this.fitImagesInContainer(t,i+1,l)}this.inflateGalleryHeight();break}e=r}}},{key:"fitImagesInContainer",value:function(t,e,i){for(var n=e-t-1,s=this.getActiveItems(),r=0,a=t;a<e;a++){var o=this.getImageData(a),l=o.computedWidth/i,u=s.get(a),c=this.getItemClass(this.settings.classes.firstRowItem);if(u.style.setProperty("--item-width",l),u.style.setProperty("--gap-count",n),u.style.setProperty("--item-height",o.height/o.width*100+"%"),u.style.setProperty("--item-start",r),u.style.setProperty("--item-row-index",a-t),r+=l,a===t){u.classList.add(c);var h=l*(this.containerWidth-n*this.getCurrentDeviceSetting("horizontalGap"));this.rowsHeights.push(h/o.ratio)}else u.classList.remove(c)}}},{key:"inflateGalleryHeight",value:function(){var t=this.rowsHeights.reduce(function(t,e){return t+e})+this.rowsCount*this.getCurrentDeviceSetting("verticalGap"),e=t/this.containerWidth,i=this.rowsHeights.map(function(e){return e/t*100}),n=-1,s=0;this.getActiveItems().each(function(t,e){"0"===e.style.getPropertyValue("--item-row-index")&&++n&&(s+=i[n-1]),e.style.setProperty("--item-top",s+"%"),e.style.setProperty("--item-height",i[n]+"%"),e.style.setProperty("--row",n)}),this.$container[0].style.setProperty("--container-aspect-ratio",e)}}]),e}(g),d=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"run",value:function(t){var e=this,i=this.getCurrentBreakpoint();if(t||i!==this.currentBreakpoint){this.currentBreakpoint=i;for(var n=[],s=[],r=[],a=this.getCurrentDeviceSetting("columns"),o=this.$container.width(),l=(o-this.getCurrentDeviceSetting("horizontalGap")*(a-1))/a,u=this.getActiveItems(),c=0,h=0;h<a;h++)s[h]=0,n[h]=0;u.each(function(t,i){var o=e.getImageData(t),u=l/o.ratio,h=t%a;c=n[h],jQuery.each(n,function(t,e){e&&c>e+5&&(c=e,h=t)}),r[t]=n[h],n[h]+=u,i.style.setProperty("--item-height",o.height/o.width*100+"%"),i.style.setProperty("--column",h),i.style.setProperty("--items-in-column",s[h]),s[h]++});var y=Math.max.apply(Math,n),g=n.indexOf(y),f=s[g]-1,m=y/o;this.$container[0].style.setProperty("--columns",a),this.$container[0].style.setProperty("--highest-column-gap-count",f),this.$container.css("padding-bottom",100*m+"%"),u.each(function(t,e){var i=r[t]?r[t]/y*100:0;e.style.setProperty("--percent-height",i+"%")})}}}]),e}(g);i(8);i.d(e,"default",function(){return p});var p=function(){function t(e){s()(this,t),this.userSettings=e,this.initGalleriesTypes(),this.createGallery()}return a()(t,[{key:"getDefaultSettings",value:function(){return{container:null,items:null,type:"grid",tags:[],overlay:!1,overlayTemplate:'<div class="{{ classesPrefix }}{{ classes.overlayTitle }}">{{ title }}</div><div class="{{ classesPrefix }}{{ classes.overlayDescription }}">{{ description }}</div>',columns:5,horizontalGap:10,verticalGap:10,rtl:!1,animationDuration:350,lazyLoad:!1,classesPrefix:"e-gallery-",classes:{container:"container",item:"item",image:"image",overlay:"overlay",overlayTitle:"overlay__title",overlayDescription:"overlay__description",link:"link",firstRowItem:"first-row-item",animated:"-animated",hidden:"item--hidden",lazyLoad:"-lazyload",imageLoaded:"image-loaded"},selectors:{items:".e-gallery-item",image:".e-gallery-image"},breakpoints:{1024:{horizontalGap:5,verticalGap:5,columns:4},768:{horizontalGap:1,verticalGap:1,columns:2}}}}},{key:"initGalleriesTypes",value:function(){this.galleriesTypes={grid:f,justified:m,masonry:d}}},{key:"createGallery",value:function(){var t=jQuery.extend(this.getDefaultSettings(),this.userSettings),e=this.galleriesTypes[t.type];this.galleryHandler=new e(t)}},{key:"setSettings",value:function(t,e){this.galleryHandler.setSettings(t,e)}},{key:"destroy",value:function(){this.galleryHandler.destroy()}}]),t}()}]).default;