/*! * Splide.js * Version : 3.6.14 * License : MIT * Copyright: 2022 Naotoshi Fujita */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const EVENT_MOUNTED = "mounted"; const EVENT_READY = "ready"; const EVENT_MOVE = "move"; const EVENT_MOVED = "moved"; const EVENT_SHIFTED = "shifted"; const EVENT_CLICK = "click"; const EVENT_ACTIVE = "active"; const EVENT_INACTIVE = "inactive"; const EVENT_VISIBLE = "visible"; const EVENT_HIDDEN = "hidden"; const EVENT_SLIDE_KEYDOWN = "slide:keydown"; const EVENT_REFRESH = "refresh"; const EVENT_UPDATED = "updated"; const EVENT_MEDIA = "media"; const EVENT_RESIZE = "resize"; const EVENT_RESIZED = "resized"; const EVENT_REPOSITIONED = "repositioned"; const EVENT_DRAG = "drag"; const EVENT_DRAGGING = "dragging"; const EVENT_DRAGGED = "dragged"; const EVENT_SCROLL = "scroll"; const EVENT_SCROLLED = "scrolled"; const EVENT_DESTROY = "destroy"; const EVENT_ARROWS_MOUNTED = "arrows:mounted"; const EVENT_ARROWS_UPDATED = "arrows:updated"; const EVENT_PAGINATION_MOUNTED = "pagination:mounted"; const EVENT_PAGINATION_UPDATED = "pagination:updated"; const EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; const EVENT_AUTOPLAY_PLAY = "autoplay:play"; const EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; const EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; const EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; const CREATED = 1; const MOUNTED = 2; const IDLE = 3; const MOVING = 4; const DRAGGING = 5; const DESTROYED = 6; const STATES = { CREATED, MOUNTED, IDLE, MOVING, DRAGGING, DESTROYED }; const DEFAULT_EVENT_PRIORITY = 10; const DEFAULT_USER_EVENT_PRIORITY = 20; function empty(array) { array.length = 0; } function slice(arrayLike, start, end) { return Array.prototype.slice.call(arrayLike, start, end); } function find(arrayLike, predicate) { return slice(arrayLike).filter(predicate)[0]; } function apply(func) { return func.bind(null, ...slice(arguments, 1)); } const nextTick = setTimeout; const noop = () => { }; function raf(func) { return requestAnimationFrame(func); } function typeOf(type, subject) { return typeof subject === type; } function isObject(subject) { return !isNull(subject) && typeOf("object", subject); } const isArray = Array.isArray; const isFunction = apply(typeOf, "function"); const isString = apply(typeOf, "string"); const isUndefined = apply(typeOf, "undefined"); function isNull(subject) { return subject === null; } function isHTMLElement(subject) { return subject instanceof HTMLElement; } function toArray(value) { return isArray(value) ? value : [value]; } function forEach(values, iteratee) { toArray(values).forEach(iteratee); } function includes(array, value) { return array.indexOf(value) > -1; } function push(array, items) { array.push(...toArray(items)); return array; } function toggleClass(elm, classes, add) { if (elm) { forEach(classes, (name) => { if (name) { elm.classList[add ? "add" : "remove"](name); } }); } } function addClass(elm, classes) { toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); } function append(parent, children) { forEach(children, parent.appendChild.bind(parent)); } function before(nodes, ref) { forEach(nodes, (node) => { const parent = ref.parentNode; if (parent) { parent.insertBefore(node, ref); } }); } function matches(elm, selector) { return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); } function children(parent, selector) { return parent ? slice(parent.children).filter((child) => matches(child, selector)) : []; } function child(parent, selector) { return selector ? children(parent, selector)[0] : parent.firstElementChild; } function forOwn(object, iteratee, right) { if (object) { let keys = Object.keys(object); keys = right ? keys.reverse() : keys; for (let i = 0; i < keys.length; i++) { const key = keys[i]; if (key !== "__proto__") { if (iteratee(object[key], key) === false) { break; } } } } return object; } function assign(object) { slice(arguments, 1).forEach((source) => { forOwn(source, (value, key) => { object[key] = source[key]; }); }); return object; } function merge(object) { slice(arguments).forEach((source) => { forOwn(source, (value, key) => { if (isArray(value)) { object[key] = value.slice(); } else if (isObject(value)) { object[key] = merge(isObject(object[key]) ? object[key] : {}, value); } else { object[key] = value; } }); }); return object; } function removeAttribute(elms, attrs) { forEach(elms, (elm) => { forEach(attrs, (attr) => { elm && elm.removeAttribute(attr); }); }); } function setAttribute(elms, attrs, value) { if (isObject(attrs)) { forOwn(attrs, (value2, name) => { setAttribute(elms, name, value2); }); } else { forEach(elms, (elm) => { isNull(value) ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); }); } } function create(tag, attrs, parent) { const elm = document.createElement(tag); if (attrs) { isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); } parent && append(parent, elm); return elm; } function style(elm, prop, value) { if (isUndefined(value)) { return getComputedStyle(elm)[prop]; } if (!isNull(value)) { const { style: style2 } = elm; value = `${value}`; if (style2[prop] !== value) { style2[prop] = value; } } } function display(elm, display2) { style(elm, "display", display2); } function focus(elm) { elm["setActive"] && elm["setActive"]() || elm.focus({ preventScroll: true }); } function getAttribute(elm, attr) { return elm.getAttribute(attr); } function hasClass(elm, className) { return elm && elm.classList.contains(className); } function rect(target) { return target.getBoundingClientRect(); } function remove(nodes) { forEach(nodes, (node) => { if (node && node.parentNode) { node.parentNode.removeChild(node); } }); } function measure(parent, value) { if (isString(value)) { const div = create("div", { style: `width: ${value}; position: absolute;` }, parent); value = rect(div).width; remove(div); } return value; } function parseHtml(html) { return child(new DOMParser().parseFromString(html, "text/html").body); } function prevent(e, stopPropagation) { e.preventDefault(); if (stopPropagation) { e.stopPropagation(); e.stopImmediatePropagation(); } } function query(parent, selector) { return parent && parent.querySelector(selector); } function queryAll(parent, selector) { return slice(parent.querySelectorAll(selector)); } function removeClass(elm, classes) { toggleClass(elm, classes, false); } function timeOf(e) { return e.timeStamp; } function unit(value) { return isString(value) ? value : value ? `${value}px` : ""; } const PROJECT_CODE = "splide"; const DATA_ATTRIBUTE = `data-${PROJECT_CODE}`; function assert(condition, message) { if (!condition) { throw new Error(`[${PROJECT_CODE}] ${message || ""}`); } } const { min, max, floor, ceil, abs } = Math; function approximatelyEqual(x, y, epsilon) { return abs(x - y) < epsilon; } function between(number, minOrMax, maxOrMin, exclusive) { const minimum = min(minOrMax, maxOrMin); const maximum = max(minOrMax, maxOrMin); return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; } function clamp(number, x, y) { const minimum = min(x, y); const maximum = max(x, y); return min(max(minimum, number), maximum); } function sign(x) { return +(x > 0) - +(x < 0); } function camelToKebab(string) { return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); } function format(string, replacements) { forEach(replacements, (replacement) => { string = string.replace("%s", `${replacement}`); }); return string; } function pad(number) { return number < 10 ? `0${number}` : `${number}`; } const ids = {}; function uniqueId(prefix) { return `${prefix}${pad(ids[prefix] = (ids[prefix] || 0) + 1)}`; } function EventBus() { let handlers = {}; function on(events, callback, key, priority = DEFAULT_EVENT_PRIORITY) { forEachEvent(events, (event, namespace) => { const events2 = handlers[event] = handlers[event] || []; events2.push([callback, namespace, priority, key]); events2.sort((handler1, handler2) => handler1[2] - handler2[2]); }); } function off(events, key) { forEachEvent(events, (event, namespace) => { handlers[event] = (handlers[event] || []).filter((handler) => { return handler[3] ? handler[3] !== key : key || handler[1] !== namespace; }); }); } function offBy(key) { forOwn(handlers, (eventHandlers, event) => { off(event, key); }); } function emit(event) { (handlers[event] || []).forEach((handler) => { handler[0].apply(handler, slice(arguments, 1)); }); } function destroy() { handlers = {}; } function forEachEvent(events, iteratee) { toArray(events).join(" ").split(" ").forEach((eventNS) => { const fragments = eventNS.split("."); iteratee(fragments[0], fragments[1]); }); } return { on, off, offBy, emit, destroy }; } function EventInterface(Splide2, manual) { const { event } = Splide2; const key = {}; let listeners = []; function on(events, callback, priority) { event.on(events, callback, key, priority); } function off(events) { event.off(events, key); } function bind(targets, events, callback, options) { forEachEvent(targets, events, (target, event2) => { const isEventTarget = "addEventListener" in target; const remover = isEventTarget ? target.removeEventListener.bind(target, event2, callback, options) : target["removeListener"].bind(target, callback); isEventTarget ? target.addEventListener(event2, callback, options) : target["addListener"](callback); listeners.push([target, event2, callback, remover]); }); } function unbind(targets, events, callback) { forEachEvent(targets, events, (target, event2) => { listeners = listeners.filter((listener) => { if (listener[0] === target && listener[1] === event2 && (!callback || listener[2] === callback)) { listener[3](); return false; } return true; }); }); } function forEachEvent(targets, events, iteratee) { forEach(targets, (target) => { if (target) { events.split(" ").forEach(apply(iteratee, target)); } }); } function destroy() { listeners = listeners.filter((data) => { data[3](); }); event.offBy(key); } !manual && event.on(EVENT_DESTROY, destroy, key); return { on, off, emit: event.emit, bind, unbind, destroy }; } function RequestInterval(interval, onInterval, onUpdate, limit) { const { now } = Date; let startTime; let rate = 0; let id; let paused = true; let count = 0; function update() { if (!paused) { const elapsed = now() - startTime; if (elapsed >= interval) { rate = 1; startTime = now(); } else { rate = elapsed / interval; } if (onUpdate) { onUpdate(rate); } if (rate === 1) { onInterval(); if (limit && ++count >= limit) { return pause(); } } raf(update); } } function start(resume) { !resume && cancel(); startTime = now() - (resume ? rate * interval : 0); paused = false; raf(update); } function pause() { paused = true; } function rewind() { startTime = now(); rate = 0; if (onUpdate) { onUpdate(rate); } } function cancel() { cancelAnimationFrame(id); rate = 0; id = 0; paused = true; } function set(time) { interval = time; } function isPaused() { return paused; } return { start, rewind, pause, cancel, set, isPaused }; } function State(initialState) { let state = initialState; function set(value) { state = value; } function is(states) { return includes(toArray(states), state); } return { set, is }; } function Throttle(func, duration) { let interval; function throttled() { if (!interval) { const args = slice(arguments); interval = RequestInterval(duration || 0, () => { func.apply(this, args); interval = null; }, null, 1); interval.start(); } } return throttled; } function Media(Splide2, Components2, options) { const event = EventInterface(Splide2, true); const breakpoints = options.breakpoints || {}; const userOptions = merge({}, options); const queries = []; function setup() { const isMin = options.mediaQuery === "min"; register(Object.keys(breakpoints).sort((n, m) => isMin ? +m - +n : +n - +m).map((key) => [breakpoints[key], `(${isMin ? "min" : "max"}-width:${key}px)`]).concat([[userOptions]])); register([[{ speed: 0, autoplay: "pause" }, "(prefers-reduced-motion: reduce)"]]); update(); } function destroy(completely) { if (completely) { event.destroy(); } } function register(entries) { queries.push(entries.map((entry) => { const query = entry[1] && matchMedia(entry[1]); query && event.bind(query, "change", update); return [entry[0], query]; })); } function update() { const options2 = accumulate(); const { destroy: _destroy } = options2; if (_destroy) { Splide2.options = userOptions; Splide2.destroy(_destroy === "completely"); } else if (Splide2.state.is(DESTROYED)) { destroy(true); Splide2.mount(); } else { Splide2.options = options2; } } function accumulate() { return queries.reduce((merged, entries) => { const entry = find(entries, (entry2) => !entry2[1] || entry2[1].matches) || []; entry[1] && event.emit(EVENT_MEDIA, entry[1]); return merge(merged, entry[0] || {}); }, merge({}, userOptions)); } return { setup, mount: noop, destroy }; } const RTL = "rtl"; const TTB = "ttb"; const ORIENTATION_MAP = { marginRight: ["marginBottom", "marginLeft"], autoWidth: ["autoHeight"], fixedWidth: ["fixedHeight"], paddingLeft: ["paddingTop", "paddingRight"], paddingRight: ["paddingBottom", "paddingLeft"], width: ["height"], left: ["top", "right"], right: ["bottom", "left"], x: ["y"], X: ["Y"], Y: ["X"], ArrowLeft: ["ArrowUp", "ArrowRight"], ArrowRight: ["ArrowDown", "ArrowLeft"] }; function Direction(Splide2, Components2, options) { function resolve(prop, axisOnly) { const { direction } = options; const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; return ORIENTATION_MAP[prop][index] || prop; } function orient(value) { return value * (options.direction === RTL ? 1 : -1); } return { resolve, orient }; } const ROLE = "role"; const TAB_INDEX = "tabindex"; const DISABLED = "disabled"; const ARIA_PREFIX = "aria-"; const ARIA_CONTROLS = `${ARIA_PREFIX}controls`; const ARIA_CURRENT = `${ARIA_PREFIX}current`; const ARIA_LABEL = `${ARIA_PREFIX}label`; const ARIA_HIDDEN = `${ARIA_PREFIX}hidden`; const ARIA_ORIENTATION = `${ARIA_PREFIX}orientation`; const ARIA_ROLEDESCRIPTION = `${ARIA_PREFIX}roledescription`; const ARIA_ATOMIC = `${ARIA_PREFIX}atomic`; const ARIA_LIVE = `${ARIA_PREFIX}live`; const ALL_ATTRIBUTES = [ ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION, ARIA_ATOMIC, ARIA_LIVE ]; const CLASS_ROOT = PROJECT_CODE; const CLASS_SLIDER = `${PROJECT_CODE}__slider`; const CLASS_TRACK = `${PROJECT_CODE}__track`; const CLASS_LIST = `${PROJECT_CODE}__list`; const CLASS_SLIDE = `${PROJECT_CODE}__slide`; const CLASS_CLONE = `${CLASS_SLIDE}--clone`; const CLASS_CONTAINER = `${CLASS_SLIDE}__container`; const CLASS_ARROWS = `${PROJECT_CODE}__arrows`; const CLASS_ARROW = `${PROJECT_CODE}__arrow`; const CLASS_ARROW_PREV = `${CLASS_ARROW}--prev`; const CLASS_ARROW_NEXT = `${CLASS_ARROW}--next`; const CLASS_PAGINATION = `${PROJECT_CODE}__pagination`; const CLASS_PAGINATION_PAGE = `${CLASS_PAGINATION}__page`; const CLASS_PROGRESS = `${PROJECT_CODE}__progress`; const CLASS_PROGRESS_BAR = `${CLASS_PROGRESS}__bar`; const CLASS_AUTOPLAY = `${PROJECT_CODE}__autoplay`; const CLASS_PLAY = `${PROJECT_CODE}__play`; const CLASS_PAUSE = `${PROJECT_CODE}__pause`; const CLASS_SPINNER = `${PROJECT_CODE}__spinner`; const CLASS_SR = `${PROJECT_CODE}__sr`; const CLASS_INITIALIZED = "is-initialized"; const CLASS_ACTIVE = "is-active"; const CLASS_PREV = "is-prev"; const CLASS_NEXT = "is-next"; const CLASS_VISIBLE = "is-visible"; const CLASS_LOADING = "is-loading"; const STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING]; const CLASSES = { slide: CLASS_SLIDE, clone: CLASS_CLONE, arrows: CLASS_ARROWS, arrow: CLASS_ARROW, prev: CLASS_ARROW_PREV, next: CLASS_ARROW_NEXT, pagination: CLASS_PAGINATION, page: CLASS_PAGINATION_PAGE, spinner: CLASS_SPINNER }; function Elements(Splide2, Components2, options) { const { on } = EventInterface(Splide2); const { root } = Splide2; const { i18n } = options; const elements = {}; const slides = []; let classes; let slider; let track; let list; function setup() { collect(); init(); addClass(root, classes = getClasses()); } function mount() { on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, setup); on(EVENT_UPDATED, update); } function destroy() { empty(slides); removeClass(root, classes); removeAttribute([root, track, list], ALL_ATTRIBUTES.concat("style")); } function update() { removeClass(root, classes); addClass(root, classes = getClasses()); } function collect() { slider = child(root, `.${CLASS_SLIDER}`); track = query(root, `.${CLASS_TRACK}`); list = child(track, `.${CLASS_LIST}`); assert(track && list, "A track/list element is missing."); push(slides, children(list, `.${CLASS_SLIDE}:not(.${CLASS_CLONE})`)); const autoplay = find(`.${CLASS_AUTOPLAY}`); const arrows = find(`.${CLASS_ARROWS}`); assign(elements, { root, slider, track, list, slides, arrows, autoplay, prev: query(arrows, `.${CLASS_ARROW_PREV}`), next: query(arrows, `.${CLASS_ARROW_NEXT}`), bar: query(find(`.${CLASS_PROGRESS}`), `.${CLASS_PROGRESS_BAR}`), play: query(autoplay, `.${CLASS_PLAY}`), pause: query(autoplay, `.${CLASS_PAUSE}`) }); } function init() { const id = root.id || uniqueId(PROJECT_CODE); root.id = id; track.id = track.id || `${id}-track`; list.id = list.id || `${id}-list`; setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); setAttribute(root, ROLE, root.tagName !== "SECTION" && options.role || null); setAttribute(list, ROLE, "none"); } function find(selector) { return child(root, selector) || child(slider, selector); } function getClasses() { return [ `${CLASS_ROOT}--${options.type}`, `${CLASS_ROOT}--${options.direction}`, options.drag && `${CLASS_ROOT}--draggable`, options.isNavigation && `${CLASS_ROOT}--nav`, CLASS_ACTIVE ]; } return assign(elements, { setup, mount, destroy }); } const SLIDE = "slide"; const LOOP = "loop"; const FADE = "fade"; function Slide$1(Splide2, index, slideIndex, slide) { const { on, emit, bind, destroy: destroyEvents } = EventInterface(Splide2); const { Components, root, options } = Splide2; const { isNavigation, updateOnMove, i18n } = options; const { resolve } = Components.Direction; const styles = getAttribute(slide, "style"); const isClone = slideIndex > -1; const container = child(slide, `.${CLASS_CONTAINER}`); const focusableNodes = options.focusableNodes && queryAll(slide, options.focusableNodes); let destroyed; function mount() { if (!isClone) { slide.id = `${root.id}-slide${pad(index + 1)}`; setAttribute(slide, ROLE, "group"); setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); setAttribute(slide, ARIA_LABEL, format(i18n.slideLabel, [index + 1, Splide2.length])); } listen(); } function listen() { bind(slide, "click keydown", (e) => { emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, self, e); }); on([EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_SHIFTED, EVENT_MOVED, EVENT_SCROLLED], update); on(EVENT_NAVIGATION_MOUNTED, initNavigation); if (updateOnMove) { on(EVENT_MOVE, onMove); } } function destroy() { destroyed = true; destroyEvents(); removeClass(slide, STATUS_CLASSES); removeAttribute(slide, ALL_ATTRIBUTES); setAttribute(slide, "style", styles); } function initNavigation() { const idx = isClone ? slideIndex : index; const label = format(i18n.slideX, idx + 1); const controls = Splide2.splides.map((target) => target.splide.root.id).join(" "); setAttribute(slide, ARIA_LABEL, label); setAttribute(slide, ARIA_CONTROLS, controls); setAttribute(slide, ROLE, "menuitem"); updateActivity(isActive()); } function onMove() { if (!destroyed) { update(); } } function update() { if (!destroyed) { const { index: currIndex } = Splide2; updateActivity(isActive()); updateVisibility(isVisible()); toggleClass(slide, CLASS_PREV, index === currIndex - 1); toggleClass(slide, CLASS_NEXT, index === currIndex + 1); } } function updateActivity(active) { if (active !== hasClass(slide, CLASS_ACTIVE)) { toggleClass(slide, CLASS_ACTIVE, active); if (isNavigation) { setAttribute(slide, ARIA_CURRENT, active || null); } emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); } } function updateVisibility(visible) { const hidden = !visible && (!isActive() || isClone); setAttribute(slide, ARIA_HIDDEN, hidden || null); setAttribute(slide, TAB_INDEX, !hidden && options.slideFocus ? 0 : null); setAttribute(focusableNodes || [], TAB_INDEX, hidden ? -1 : null); if (visible !== hasClass(slide, CLASS_VISIBLE)) { toggleClass(slide, CLASS_VISIBLE, visible); emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); } } function style$1(prop, value, useContainer) { style(useContainer && container || slide, prop, value); } function isActive() { const { index: curr } = Splide2; return curr === index || options.cloneStatus && curr === slideIndex; } function isVisible() { if (Splide2.is(FADE)) { return isActive(); } const trackRect = rect(Components.Elements.track); const slideRect = rect(slide); const left = resolve("left"); const right = resolve("right"); return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); } function isWithin(from, distance) { let diff = abs(from - index); if (!isClone && (options.rewind || Splide2.is(LOOP))) { diff = min(diff, Splide2.length - diff); } return diff <= distance; } const self = { index, slideIndex, slide, container, isClone, mount, destroy, update, style: style$1, isWithin }; return self; } function Slides(Splide2, Components2, options) { const { on, emit, bind } = EventInterface(Splide2); const { slides, list } = Components2.Elements; const Slides2 = []; function mount() { init(); on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, init); on([EVENT_MOUNTED, EVENT_REFRESH], () => { Slides2.sort((Slide1, Slide2) => Slide1.index - Slide2.index); }); } function init() { slides.forEach((slide, index) => { register(slide, index, -1); }); } function destroy() { forEach$1((Slide2) => { Slide2.destroy(); }); empty(Slides2); } function update() { forEach$1((Slide2) => { Slide2.update(); }); } function register(slide, index, slideIndex) { const object = Slide$1(Splide2, index, slideIndex, slide); object.mount(); Slides2.push(object); } function get(excludeClones) { return excludeClones ? filter((Slide2) => !Slide2.isClone) : Slides2; } function getIn(page) { const { Controller } = Components2; const index = Controller.toIndex(page); const max = Controller.hasFocus() ? 1 : options.perPage; return filter((Slide2) => between(Slide2.index, index, index + max - 1)); } function getAt(index) { return filter(index)[0]; } function add(items, index) { forEach(items, (slide) => { if (isString(slide)) { slide = parseHtml(slide); } if (isHTMLElement(slide)) { const ref = slides[index]; ref ? before(slide, ref) : append(list, slide); addClass(slide, options.classes.slide); observeImages(slide, apply(emit, EVENT_RESIZE)); } }); emit(EVENT_REFRESH); } function remove$1(matcher) { remove(filter(matcher).map((Slide2) => Slide2.slide)); emit(EVENT_REFRESH); } function forEach$1(iteratee, excludeClones) { get(excludeClones).forEach(iteratee); } function filter(matcher) { return Slides2.filter(isFunction(matcher) ? matcher : (Slide2) => isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index)); } function style(prop, value, useContainer) { forEach$1((Slide2) => { Slide2.style(prop, value, useContainer); }); } function observeImages(elm, callback) { const images = queryAll(elm, "img"); let { length } = images; if (length) { images.forEach((img) => { bind(img, "load error", () => { if (!--length) { callback(); } }); }); } else { callback(); } } function getLength(excludeClones) { return excludeClones ? slides.length : Slides2.length; } function isEnough() { return Slides2.length > options.perPage; } return { mount, destroy, update, register, get, getIn, getAt, add, remove: remove$1, forEach: forEach$1, filter, style, getLength, isEnough }; } function Layout(Splide2, Components2, options) { const { on, bind, emit } = EventInterface(Splide2); const { Slides } = Components2; const { resolve } = Components2.Direction; const { root, track, list } = Components2.Elements; const { getAt, style: styleSlides } = Slides; let vertical; let rootRect; function mount() { init(); bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); on([EVENT_UPDATED, EVENT_REFRESH], init); on(EVENT_RESIZE, resize); } function init() { rootRect = null; vertical = options.direction === TTB; style(root, "maxWidth", unit(options.width)); style(track, resolve("paddingLeft"), cssPadding(false)); style(track, resolve("paddingRight"), cssPadding(true)); resize(); } function resize() { const newRect = rect(root); if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { style(track, "height", cssTrackHeight()); styleSlides(resolve("marginRight"), unit(options.gap)); styleSlides("width", cssSlideWidth() || null); styleSlides("height", cssSlideHeight() || null, true); rootRect = newRect; emit(EVENT_RESIZED); } } function cssPadding(right) { const { padding } = options; const prop = resolve(right ? "right" : "left"); return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; } function cssTrackHeight() { let height = ""; if (vertical) { height = cssHeight(); assert(height, "height or heightRatio is missing."); height = `calc(${height} - ${cssPadding(false)} - ${cssPadding(true)})`; } return height; } function cssHeight() { return unit(options.height || rect(list).width * options.heightRatio); } function cssSlideWidth() { return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); } function cssSlideHeight() { return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight()); } function cssSlideSize() { const gap = unit(options.gap); return `calc((100%${gap && ` + ${gap}`})/${options.perPage || 1}${gap && ` - ${gap}`})`; } function listSize() { return rect(list)[resolve("width")]; } function slideSize(index, withoutGap) { const Slide = getAt(index || 0); return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; } function totalSize(index, withoutGap) { const Slide = getAt(index); if (Slide) { const right = rect(Slide.slide)[resolve("right")]; const left = rect(list)[resolve("left")]; return abs(right - left) + (withoutGap ? 0 : getGap()); } return 0; } function sliderSize() { return totalSize(Splide2.length - 1, true) - totalSize(-1, true); } function getGap() { const Slide = getAt(0); return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; } function getPadding(right) { return parseFloat(style(track, resolve(`padding${right ? "Right" : "Left"}`))) || 0; } return { mount, listSize, slideSize, sliderSize, totalSize, getPadding }; } function Clones(Splide2, Components2, options) { const { on, emit } = EventInterface(Splide2); const { Elements, Slides } = Components2; const { resolve } = Components2.Direction; const clones = []; let cloneCount; function mount() { init(); on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, init); on([EVENT_UPDATED, EVENT_RESIZE], observe); } function init() { if (cloneCount = computeCloneCount()) { generate(cloneCount); emit(EVENT_RESIZE); } } function destroy() { remove(clones); empty(clones); } function observe() { if (cloneCount < computeCloneCount()) { emit(EVENT_REFRESH); } } function generate(count) { const slides = Slides.get().slice(); const { length } = slides; if (length) { while (slides.length < count) { push(slides, slides); } push(slides.slice(-count), slides.slice(0, count)).forEach((Slide, index) => { const isHead = index < count; const clone = cloneDeep(Slide.slide, index); isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); push(clones, clone); Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); }); } } function cloneDeep(elm, index) { const clone = elm.cloneNode(true); addClass(clone, options.classes.clone); clone.id = `${Splide2.root.id}-clone${pad(index + 1)}`; return clone; } function computeCloneCount() { let { clones: clones2 } = options; if (!Splide2.is(LOOP)) { clones2 = 0; } else if (!clones2) { const fixedSize = measure(Elements.list, options[resolve("fixedWidth")]); const fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); const baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage; clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2); } return clones2; } return { mount, destroy }; } function Move(Splide2, Components2, options) { const { on, emit } = EventInterface(Splide2); const { slideSize, getPadding, totalSize, listSize, sliderSize } = Components2.Layout; const { resolve, orient } = Components2.Direction; const { list, track } = Components2.Elements; let Transition; function mount() { Transition = Components2.Transition; on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); } function reposition() { if (!isBusy()) { Components2.Scroll.cancel(); jump(Splide2.index); emit(EVENT_REPOSITIONED); } } function move(dest, index, prev, callback) { if (!isBusy()) { const { set } = Splide2.state; const position = getPosition(); if (dest !== index) { Transition.cancel(); translate(shift(position, dest > index), true); } set(MOVING); emit(EVENT_MOVE, index, prev, dest); Transition.start(index, () => { set(IDLE); emit(EVENT_MOVED, index, prev, dest); if (options.trimSpace === "move" && dest !== prev && position === getPosition()) { Components2.Controller.go(dest > prev ? ">" : "<", false, callback); } else { callback && callback(); } }); } } function jump(index) { translate(toPosition(index, true)); } function translate(position, preventLoop) { if (!Splide2.is(FADE)) { const destination = preventLoop ? position : loop(position); list.style.transform = `translate${resolve("X")}(${destination}px)`; position !== destination && emit(EVENT_SHIFTED); } } function loop(position) { if (Splide2.is(LOOP)) { const diff = orient(position - getPosition()); const exceededMin = exceededLimit(false, position) && diff < 0; const exceededMax = exceededLimit(true, position) && diff > 0; if (exceededMin || exceededMax) { position = shift(position, exceededMax); } } return position; } function shift(position, backwards) { const excess = position - getLimit(backwards); const size = sliderSize(); position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); return position; } function cancel() { translate(getPosition()); Transition.cancel(); } function toIndex(position) { const Slides = Components2.Slides.get(); let index = 0; let minDistance = Infinity; for (let i = 0; i < Slides.length; i++) { const slideIndex = Slides[i].index; const distance = abs(toPosition(slideIndex, true) - position); if (distance <= minDistance) { minDistance = distance; index = slideIndex; } else { break; } } return index; } function toPosition(index, trimming) { const position = orient(totalSize(index - 1) - offset(index)); return trimming ? trim(position) : position; } function getPosition() { const left = resolve("left"); return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); } function trim(position) { if (options.trimSpace && Splide2.is(SLIDE)) { position = clamp(position, 0, orient(sliderSize() - listSize())); } return position; } function offset(index) { const { focus } = options; return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; } function getLimit(max) { return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); } function isBusy() { return Splide2.state.is(MOVING) && options.waitForTransition; } function exceededLimit(max, position) { position = isUndefined(position) ? getPosition() : position; const exceededMin = max !== true && orient(position) < orient(getLimit(false)); const exceededMax = max !== false && orient(position) > orient(getLimit(true)); return exceededMin || exceededMax; } return { mount, move, jump, translate, shift, cancel, toIndex, toPosition, getPosition, getLimit, isBusy, exceededLimit, reposition }; } function Controller(Splide2, Components2, options) { const { on } = EventInterface(Splide2); const { Move } = Components2; const { getPosition, getLimit } = Move; const { isEnough, getLength } = Components2.Slides; const isLoop = Splide2.is(LOOP); const isSlide = Splide2.is(SLIDE); const getNext = apply(getAdjacent, false); const getPrev = apply(getAdjacent, true); let currIndex = options.start || 0; let prevIndex = currIndex; let slideCount; let perMove; let perPage; function mount() { init(); on([EVENT_UPDATED, EVENT_REFRESH], init); } function init() { slideCount = getLength(true); perMove = options.perMove; perPage = options.perPage; const index = clamp(currIndex, 0, slideCount - 1); if (index !== currIndex) { currIndex = index; Move.reposition(); } } function go(control, allowSameIndex, callback) { const dest = parse(control); if (options.useScroll) { scroll(dest, true, true, options.speed, callback); } else { const index = loop(dest); if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) { setIndex(index); Move.move(dest, index, prevIndex, callback); } } } function scroll(destination, useIndex, snap, duration, callback) { const dest = useIndex ? destination : toDest(destination); Components2.Scroll.scroll(useIndex || snap ? Move.toPosition(dest, true) : destination, duration, () => { setIndex(Move.toIndex(Move.getPosition())); callback && callback(); }); } function parse(control) { let index = currIndex; if (isString(control)) { const [, indicator, number] = control.match(/([+\-<>])(\d+)?/) || []; if (indicator === "+" || indicator === "-") { index = computeDestIndex(currIndex + +`${indicator}${+number || 1}`, currIndex, true); } else if (indicator === ">") { index = number ? toIndex(+number) : getNext(true); } else if (indicator === "<") { index = getPrev(true); } } else { index = isLoop ? control : clamp(control, 0, getEnd()); } return index; } function getAdjacent(prev, destination) { const number = perMove || (hasFocus() ? 1 : perPage); const dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex); if (dest === -1 && isSlide) { if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { return prev ? 0 : getEnd(); } } return destination ? dest : loop(dest); } function computeDestIndex(dest, from, incremental) { if (isEnough()) { const end = getEnd(); if (dest < 0 || dest > end) { if (between(0, dest, from, true) || between(end, from, dest, true)) { dest = toIndex(toPage(dest)); } else { if (isLoop) { dest = perMove || hasFocus() ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount; } else if (options.rewind) { dest = dest < 0 ? end : 0; } else { dest = -1; } } } else { if (!incremental && dest !== from) { dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1)); } } } else { dest = -1; } return dest; } function getEnd() { let end = slideCount - perPage; if (hasFocus() || isLoop && perMove) { end = slideCount - 1; } return max(end, 0); } function loop(index) { if (isLoop) { return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1; } return index; } function toIndex(page) { return clamp(hasFocus() ? page : perPage * page, 0, getEnd()); } function toPage(index) { if (!hasFocus()) { index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index; index = floor(index / perPage); } return index; } function toDest(destination) { const closest = Move.toIndex(destination); return isSlide ? clamp(closest, 0, getEnd()) : closest; } function setIndex(index) { if (index !== currIndex) { prevIndex = currIndex; currIndex = index; } } function getIndex(prev) { return prev ? prevIndex : currIndex; } function hasFocus() { return !isUndefined(options.focus) || options.isNavigation; } return { mount, go, scroll, getNext, getPrev, getAdjacent, getEnd, setIndex, getIndex, toIndex, toPage, toDest, hasFocus }; } const XML_NAME_SPACE = "http://www.w3.org/2000/svg"; const PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; const SIZE = 40; function Arrows(Splide2, Components2, options) { const { on, bind, emit } = EventInterface(Splide2); const { classes, i18n } = options; const { Elements, Controller } = Components2; let wrapper = Elements.arrows; let prev = Elements.prev; let next = Elements.next; let created; const arrows = {}; function mount() { init(); on(EVENT_UPDATED, init); } function init() { if (options.arrows) { if (!prev || !next) { createArrows(); } } if (prev && next) { if (!arrows.prev) { setAttribute([prev, next], ARIA_CONTROLS, Elements.list.id); arrows.prev = prev; arrows.next = next; listen(); emit(EVENT_ARROWS_MOUNTED, prev, next); } display(wrapper, options.arrows === false ? "none" : ""); } } function destroy() { if (created) { remove(wrapper); } else { removeAttribute([prev, next], ALL_ATTRIBUTES); } } function listen() { const { go } = Controller; on([EVENT_MOUNTED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update); bind(next, "click", apply(go, ">", true, void 0)); bind(prev, "click", apply(go, "<", true, void 0)); } function createArrows() { wrapper = create("div", classes.arrows); prev = createArrow(true); next = createArrow(false); created = true; append(wrapper, [prev, next]); before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root)); } function createArrow(prev2) { const arrow = ``; } html() { const { rootClass, listTag, arrows, beforeTrack, afterTrack, slider, beforeSlider, afterSlider } = this.config; let html = ""; html += `
`; html += ``; if (slider) { html += beforeSlider || ""; html += `
`; } html += beforeTrack || ""; if (arrows) { html += this.renderArrows(); } html += `
`; html += `<${listTag} class="splide__list">`; html += this.renderSlides(); html += ``; html += `
`; html += afterTrack || ""; if (slider) { html += `
`; html += afterSlider || ""; } html += `
`; return html; } } exports.CLASSES = CLASSES; exports.CLASS_ACTIVE = CLASS_ACTIVE; exports.CLASS_ARROW = CLASS_ARROW; exports.CLASS_ARROWS = CLASS_ARROWS; exports.CLASS_ARROW_NEXT = CLASS_ARROW_NEXT; exports.CLASS_ARROW_PREV = CLASS_ARROW_PREV; exports.CLASS_AUTOPLAY = CLASS_AUTOPLAY; exports.CLASS_CLONE = CLASS_CLONE; exports.CLASS_CONTAINER = CLASS_CONTAINER; exports.CLASS_INITIALIZED = CLASS_INITIALIZED; exports.CLASS_LIST = CLASS_LIST; exports.CLASS_LOADING = CLASS_LOADING; exports.CLASS_NEXT = CLASS_NEXT; exports.CLASS_PAGINATION = CLASS_PAGINATION; exports.CLASS_PAGINATION_PAGE = CLASS_PAGINATION_PAGE; exports.CLASS_PAUSE = CLASS_PAUSE; exports.CLASS_PLAY = CLASS_PLAY; exports.CLASS_PREV = CLASS_PREV; exports.CLASS_PROGRESS = CLASS_PROGRESS; exports.CLASS_PROGRESS_BAR = CLASS_PROGRESS_BAR; exports.CLASS_ROOT = CLASS_ROOT; exports.CLASS_SLIDE = CLASS_SLIDE; exports.CLASS_SLIDER = CLASS_SLIDER; exports.CLASS_SPINNER = CLASS_SPINNER; exports.CLASS_SR = CLASS_SR; exports.CLASS_TRACK = CLASS_TRACK; exports.CLASS_VISIBLE = CLASS_VISIBLE; exports.EVENT_ACTIVE = EVENT_ACTIVE; exports.EVENT_ARROWS_MOUNTED = EVENT_ARROWS_MOUNTED; exports.EVENT_ARROWS_UPDATED = EVENT_ARROWS_UPDATED; exports.EVENT_AUTOPLAY_PAUSE = EVENT_AUTOPLAY_PAUSE; exports.EVENT_AUTOPLAY_PLAY = EVENT_AUTOPLAY_PLAY; exports.EVENT_AUTOPLAY_PLAYING = EVENT_AUTOPLAY_PLAYING; exports.EVENT_CLICK = EVENT_CLICK; exports.EVENT_DESTROY = EVENT_DESTROY; exports.EVENT_DRAG = EVENT_DRAG; exports.EVENT_DRAGGED = EVENT_DRAGGED; exports.EVENT_DRAGGING = EVENT_DRAGGING; exports.EVENT_HIDDEN = EVENT_HIDDEN; exports.EVENT_INACTIVE = EVENT_INACTIVE; exports.EVENT_LAZYLOAD_LOADED = EVENT_LAZYLOAD_LOADED; exports.EVENT_MEDIA = EVENT_MEDIA; exports.EVENT_MOUNTED = EVENT_MOUNTED; exports.EVENT_MOVE = EVENT_MOVE; exports.EVENT_MOVED = EVENT_MOVED; exports.EVENT_NAVIGATION_MOUNTED = EVENT_NAVIGATION_MOUNTED; exports.EVENT_PAGINATION_MOUNTED = EVENT_PAGINATION_MOUNTED; exports.EVENT_PAGINATION_UPDATED = EVENT_PAGINATION_UPDATED; exports.EVENT_READY = EVENT_READY; exports.EVENT_REFRESH = EVENT_REFRESH; exports.EVENT_REPOSITIONED = EVENT_REPOSITIONED; exports.EVENT_RESIZE = EVENT_RESIZE; exports.EVENT_RESIZED = EVENT_RESIZED; exports.EVENT_SCROLL = EVENT_SCROLL; exports.EVENT_SCROLLED = EVENT_SCROLLED; exports.EVENT_SHIFTED = EVENT_SHIFTED; exports.EVENT_SLIDE_KEYDOWN = EVENT_SLIDE_KEYDOWN; exports.EVENT_UPDATED = EVENT_UPDATED; exports.EVENT_VISIBLE = EVENT_VISIBLE; exports.EventBus = EventBus; exports.EventInterface = EventInterface; exports.RequestInterval = RequestInterval; exports.STATUS_CLASSES = STATUS_CLASSES; exports.Splide = Splide; exports.SplideRenderer = SplideRenderer; exports.State = State; exports.Throttle = Throttle; exports["default"] = Splide;