splide.esm.js 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647
  1. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3. /*!
  4. * Splide.js
  5. * Version : 4.0.4
  6. * License : MIT
  7. * Copyright: 2022 Naotoshi Fujita
  8. */
  9. var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
  10. var CREATED = 1;
  11. var MOUNTED = 2;
  12. var IDLE = 3;
  13. var MOVING = 4;
  14. var SCROLLING = 5;
  15. var DRAGGING = 6;
  16. var DESTROYED = 7;
  17. var STATES = {
  18. CREATED: CREATED,
  19. MOUNTED: MOUNTED,
  20. IDLE: IDLE,
  21. MOVING: MOVING,
  22. SCROLLING: SCROLLING,
  23. DRAGGING: DRAGGING,
  24. DESTROYED: DESTROYED
  25. };
  26. function empty(array) {
  27. array.length = 0;
  28. }
  29. function slice(arrayLike, start, end) {
  30. return Array.prototype.slice.call(arrayLike, start, end);
  31. }
  32. function apply(func) {
  33. return func.bind.apply(func, [null].concat(slice(arguments, 1)));
  34. }
  35. var nextTick = setTimeout;
  36. var noop = function noop() {};
  37. function raf(func) {
  38. return requestAnimationFrame(func);
  39. }
  40. function typeOf(type, subject) {
  41. return typeof subject === type;
  42. }
  43. function isObject(subject) {
  44. return !isNull(subject) && typeOf("object", subject);
  45. }
  46. var isArray = Array.isArray;
  47. var isFunction = apply(typeOf, "function");
  48. var isString = apply(typeOf, "string");
  49. var isUndefined = apply(typeOf, "undefined");
  50. function isNull(subject) {
  51. return subject === null;
  52. }
  53. function isHTMLElement(subject) {
  54. return subject instanceof HTMLElement;
  55. }
  56. function toArray(value) {
  57. return isArray(value) ? value : [value];
  58. }
  59. function forEach(values, iteratee) {
  60. toArray(values).forEach(iteratee);
  61. }
  62. function includes(array, value) {
  63. return array.indexOf(value) > -1;
  64. }
  65. function push(array, items) {
  66. array.push.apply(array, toArray(items));
  67. return array;
  68. }
  69. function toggleClass(elm, classes, add) {
  70. if (elm) {
  71. forEach(classes, function (name) {
  72. if (name) {
  73. elm.classList[add ? "add" : "remove"](name);
  74. }
  75. });
  76. }
  77. }
  78. function addClass(elm, classes) {
  79. toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true);
  80. }
  81. function append(parent, children) {
  82. forEach(children, parent.appendChild.bind(parent));
  83. }
  84. function before(nodes, ref) {
  85. forEach(nodes, function (node) {
  86. var parent = (ref || node).parentNode;
  87. if (parent) {
  88. parent.insertBefore(node, ref);
  89. }
  90. });
  91. }
  92. function matches(elm, selector) {
  93. return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector);
  94. }
  95. function children(parent, selector) {
  96. var children2 = parent ? slice(parent.children) : [];
  97. return selector ? children2.filter(function (child) {
  98. return matches(child, selector);
  99. }) : children2;
  100. }
  101. function child(parent, selector) {
  102. return selector ? children(parent, selector)[0] : parent.firstElementChild;
  103. }
  104. var ownKeys = Object.keys;
  105. function forOwn(object, iteratee, right) {
  106. if (object) {
  107. var keys = ownKeys(object);
  108. keys = right ? keys.reverse() : keys;
  109. for (var i = 0; i < keys.length; i++) {
  110. var key = keys[i];
  111. if (key !== "__proto__") {
  112. if (iteratee(object[key], key) === false) {
  113. break;
  114. }
  115. }
  116. }
  117. }
  118. return object;
  119. }
  120. function assign(object) {
  121. slice(arguments, 1).forEach(function (source) {
  122. forOwn(source, function (value, key) {
  123. object[key] = source[key];
  124. });
  125. });
  126. return object;
  127. }
  128. function merge(object) {
  129. slice(arguments, 1).forEach(function (source) {
  130. forOwn(source, function (value, key) {
  131. if (isArray(value)) {
  132. object[key] = value.slice();
  133. } else if (isObject(value)) {
  134. object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value);
  135. } else {
  136. object[key] = value;
  137. }
  138. });
  139. });
  140. return object;
  141. }
  142. function omit(object, keys) {
  143. toArray(keys || ownKeys(object)).forEach(function (key) {
  144. delete object[key];
  145. });
  146. }
  147. function removeAttribute(elms, attrs) {
  148. forEach(elms, function (elm) {
  149. forEach(attrs, function (attr) {
  150. elm && elm.removeAttribute(attr);
  151. });
  152. });
  153. }
  154. function setAttribute(elms, attrs, value) {
  155. if (isObject(attrs)) {
  156. forOwn(attrs, function (value2, name) {
  157. setAttribute(elms, name, value2);
  158. });
  159. } else {
  160. forEach(elms, function (elm) {
  161. isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value));
  162. });
  163. }
  164. }
  165. function create(tag, attrs, parent) {
  166. var elm = document.createElement(tag);
  167. if (attrs) {
  168. isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs);
  169. }
  170. parent && append(parent, elm);
  171. return elm;
  172. }
  173. function style(elm, prop, value) {
  174. if (isUndefined(value)) {
  175. return getComputedStyle(elm)[prop];
  176. }
  177. if (!isNull(value)) {
  178. elm.style[prop] = "" + value;
  179. }
  180. }
  181. function display(elm, display2) {
  182. style(elm, "display", display2);
  183. }
  184. function focus(elm) {
  185. elm["setActive"] && elm["setActive"]() || elm.focus({
  186. preventScroll: true
  187. });
  188. }
  189. function getAttribute(elm, attr) {
  190. return elm.getAttribute(attr);
  191. }
  192. function hasClass(elm, className) {
  193. return elm && elm.classList.contains(className);
  194. }
  195. function rect(target) {
  196. return target.getBoundingClientRect();
  197. }
  198. function remove(nodes) {
  199. forEach(nodes, function (node) {
  200. if (node && node.parentNode) {
  201. node.parentNode.removeChild(node);
  202. }
  203. });
  204. }
  205. function parseHtml(html) {
  206. return child(new DOMParser().parseFromString(html, "text/html").body);
  207. }
  208. function prevent(e, stopPropagation) {
  209. e.preventDefault();
  210. if (stopPropagation) {
  211. e.stopPropagation();
  212. e.stopImmediatePropagation();
  213. }
  214. }
  215. function query(parent, selector) {
  216. return parent && parent.querySelector(selector);
  217. }
  218. function queryAll(parent, selector) {
  219. return selector ? slice(parent.querySelectorAll(selector)) : [];
  220. }
  221. function removeClass(elm, classes) {
  222. toggleClass(elm, classes, false);
  223. }
  224. function timeOf(e) {
  225. return e.timeStamp;
  226. }
  227. function unit(value) {
  228. return isString(value) ? value : value ? value + "px" : "";
  229. }
  230. var PROJECT_CODE = "splide";
  231. var DATA_ATTRIBUTE = "data-" + PROJECT_CODE;
  232. function assert(condition, message) {
  233. if (!condition) {
  234. throw new Error("[" + PROJECT_CODE + "] " + (message || ""));
  235. }
  236. }
  237. var min = Math.min,
  238. max = Math.max,
  239. floor = Math.floor,
  240. ceil = Math.ceil,
  241. abs = Math.abs;
  242. function approximatelyEqual(x, y, epsilon) {
  243. return abs(x - y) < epsilon;
  244. }
  245. function between(number, minOrMax, maxOrMin, exclusive) {
  246. var minimum = min(minOrMax, maxOrMin);
  247. var maximum = max(minOrMax, maxOrMin);
  248. return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum;
  249. }
  250. function clamp(number, x, y) {
  251. var minimum = min(x, y);
  252. var maximum = max(x, y);
  253. return min(max(minimum, number), maximum);
  254. }
  255. function sign(x) {
  256. return +(x > 0) - +(x < 0);
  257. }
  258. function camelToKebab(string) {
  259. return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
  260. }
  261. function format(string, replacements) {
  262. forEach(replacements, function (replacement) {
  263. string = string.replace("%s", "" + replacement);
  264. });
  265. return string;
  266. }
  267. function pad(number) {
  268. return number < 10 ? "0" + number : "" + number;
  269. }
  270. var ids = {};
  271. function uniqueId(prefix) {
  272. return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1);
  273. }
  274. function EventBinder() {
  275. var listeners = [];
  276. function bind(targets, events, callback, options) {
  277. forEachEvent(targets, events, function (target, event, namespace) {
  278. var isEventTarget = ("addEventListener" in target);
  279. var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback);
  280. isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback);
  281. listeners.push([target, event, namespace, callback, remover]);
  282. });
  283. }
  284. function unbind(targets, events, callback) {
  285. forEachEvent(targets, events, function (target, event, namespace) {
  286. listeners = listeners.filter(function (listener) {
  287. if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) {
  288. listener[4]();
  289. return false;
  290. }
  291. return true;
  292. });
  293. });
  294. }
  295. function dispatch(target, type, detail) {
  296. var e;
  297. var bubbles = true;
  298. if (typeof CustomEvent === "function") {
  299. e = new CustomEvent(type, {
  300. bubbles: bubbles,
  301. detail: detail
  302. });
  303. } else {
  304. e = document.createEvent("CustomEvent");
  305. e.initCustomEvent(type, bubbles, false, detail);
  306. }
  307. target.dispatchEvent(e);
  308. return e;
  309. }
  310. function forEachEvent(targets, events, iteratee) {
  311. forEach(targets, function (target) {
  312. target && forEach(events, function (events2) {
  313. events2.split(" ").forEach(function (eventNS) {
  314. var fragment = eventNS.split(".");
  315. iteratee(target, fragment[0], fragment[1]);
  316. });
  317. });
  318. });
  319. }
  320. function destroy() {
  321. listeners.forEach(function (data) {
  322. data[4]();
  323. });
  324. empty(listeners);
  325. }
  326. return {
  327. bind: bind,
  328. unbind: unbind,
  329. dispatch: dispatch,
  330. destroy: destroy
  331. };
  332. }
  333. var EVENT_MOUNTED = "mounted";
  334. var EVENT_READY = "ready";
  335. var EVENT_MOVE = "move";
  336. var EVENT_MOVED = "moved";
  337. var EVENT_SHIFTED = "shifted";
  338. var EVENT_CLICK = "click";
  339. var EVENT_ACTIVE = "active";
  340. var EVENT_INACTIVE = "inactive";
  341. var EVENT_VISIBLE = "visible";
  342. var EVENT_HIDDEN = "hidden";
  343. var EVENT_SLIDE_KEYDOWN = "slide:keydown";
  344. var EVENT_REFRESH = "refresh";
  345. var EVENT_UPDATED = "updated";
  346. var EVENT_RESIZE = "resize";
  347. var EVENT_RESIZED = "resized";
  348. var EVENT_DRAG = "drag";
  349. var EVENT_DRAGGING = "dragging";
  350. var EVENT_DRAGGED = "dragged";
  351. var EVENT_SCROLL = "scroll";
  352. var EVENT_SCROLLED = "scrolled";
  353. var EVENT_DESTROY = "destroy";
  354. var EVENT_ARROWS_MOUNTED = "arrows:mounted";
  355. var EVENT_ARROWS_UPDATED = "arrows:updated";
  356. var EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  357. var EVENT_PAGINATION_UPDATED = "pagination:updated";
  358. var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  359. var EVENT_AUTOPLAY_PLAY = "autoplay:play";
  360. var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  361. var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  362. var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  363. function EventInterface(Splide2) {
  364. var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment();
  365. var binder = EventBinder();
  366. function on(events, callback) {
  367. binder.bind(bus, toArray(events).join(" "), function (e) {
  368. callback.apply(callback, isArray(e.detail) ? e.detail : []);
  369. });
  370. }
  371. function emit(event) {
  372. binder.dispatch(bus, event, slice(arguments, 1));
  373. }
  374. if (Splide2) {
  375. Splide2.event.on(EVENT_DESTROY, binder.destroy);
  376. }
  377. return assign(binder, {
  378. bus: bus,
  379. on: on,
  380. off: apply(binder.unbind, bus),
  381. emit: emit
  382. });
  383. }
  384. function RequestInterval(interval, onInterval, onUpdate, limit) {
  385. var now = Date.now;
  386. var startTime;
  387. var rate = 0;
  388. var id;
  389. var paused = true;
  390. var count = 0;
  391. function update() {
  392. if (!paused) {
  393. rate = interval ? min((now() - startTime) / interval, 1) : 1;
  394. onUpdate && onUpdate(rate);
  395. if (rate >= 1) {
  396. onInterval();
  397. startTime = now();
  398. if (limit && ++count >= limit) {
  399. return pause();
  400. }
  401. }
  402. raf(update);
  403. }
  404. }
  405. function start(resume) {
  406. !resume && cancel();
  407. startTime = now() - (resume ? rate * interval : 0);
  408. paused = false;
  409. raf(update);
  410. }
  411. function pause() {
  412. paused = true;
  413. }
  414. function rewind() {
  415. startTime = now();
  416. rate = 0;
  417. if (onUpdate) {
  418. onUpdate(rate);
  419. }
  420. }
  421. function cancel() {
  422. id && cancelAnimationFrame(id);
  423. rate = 0;
  424. id = 0;
  425. paused = true;
  426. }
  427. function set(time) {
  428. interval = time;
  429. }
  430. function isPaused() {
  431. return paused;
  432. }
  433. return {
  434. start: start,
  435. rewind: rewind,
  436. pause: pause,
  437. cancel: cancel,
  438. set: set,
  439. isPaused: isPaused
  440. };
  441. }
  442. function State(initialState) {
  443. var state = initialState;
  444. function set(value) {
  445. state = value;
  446. }
  447. function is(states) {
  448. return includes(toArray(states), state);
  449. }
  450. return {
  451. set: set,
  452. is: is
  453. };
  454. }
  455. function Throttle(func, duration) {
  456. var interval;
  457. function throttled() {
  458. if (!interval) {
  459. interval = RequestInterval(duration || 0, function () {
  460. func();
  461. interval = null;
  462. }, null, 1);
  463. interval.start();
  464. }
  465. }
  466. return throttled;
  467. }
  468. function Media(Splide2, Components2, options) {
  469. var state = Splide2.state;
  470. var breakpoints = options.breakpoints || {};
  471. var reducedMotion = options.reducedMotion || {};
  472. var binder = EventBinder();
  473. var queries = [];
  474. function setup() {
  475. var isMin = options.mediaQuery === "min";
  476. ownKeys(breakpoints).sort(function (n, m) {
  477. return isMin ? +n - +m : +m - +n;
  478. }).forEach(function (key) {
  479. register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)");
  480. });
  481. register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION);
  482. update();
  483. }
  484. function destroy(completely) {
  485. if (completely) {
  486. binder.destroy();
  487. }
  488. }
  489. function register(options2, query) {
  490. var queryList = matchMedia(query);
  491. binder.bind(queryList, "change", update);
  492. queries.push([options2, queryList]);
  493. }
  494. function update() {
  495. var destroyed = state.is(DESTROYED);
  496. var direction = options.direction;
  497. var merged = queries.reduce(function (merged2, entry) {
  498. return merge(merged2, entry[1].matches ? entry[0] : {});
  499. }, {});
  500. omit(options);
  501. set(merged);
  502. if (options.destroy) {
  503. Splide2.destroy(options.destroy === "completely");
  504. } else if (destroyed) {
  505. destroy(true);
  506. Splide2.mount();
  507. } else {
  508. direction !== options.direction && Splide2.refresh();
  509. }
  510. }
  511. function reduce(enable) {
  512. if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) {
  513. enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion));
  514. }
  515. }
  516. function set(opts, user) {
  517. merge(options, opts);
  518. user && merge(Object.getPrototypeOf(options), opts);
  519. if (!state.is(CREATED)) {
  520. Splide2.emit(EVENT_UPDATED, options);
  521. }
  522. }
  523. return {
  524. setup: setup,
  525. destroy: destroy,
  526. reduce: reduce,
  527. set: set
  528. };
  529. }
  530. var ARROW = "Arrow";
  531. var ARROW_LEFT = ARROW + "Left";
  532. var ARROW_RIGHT = ARROW + "Right";
  533. var ARROW_UP = ARROW + "Up";
  534. var ARROW_DOWN = ARROW + "Down";
  535. var LTR = "ltr";
  536. var RTL = "rtl";
  537. var TTB = "ttb";
  538. var ORIENTATION_MAP = {
  539. width: ["height"],
  540. left: ["top", "right"],
  541. right: ["bottom", "left"],
  542. x: ["y"],
  543. X: ["Y"],
  544. Y: ["X"],
  545. ArrowLeft: [ARROW_UP, ARROW_RIGHT],
  546. ArrowRight: [ARROW_DOWN, ARROW_LEFT]
  547. };
  548. function Direction(Splide2, Components2, options) {
  549. function resolve(prop, axisOnly, direction) {
  550. direction = direction || options.direction;
  551. var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  552. return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) {
  553. var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
  554. return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement;
  555. });
  556. }
  557. function orient(value) {
  558. return value * (options.direction === RTL ? 1 : -1);
  559. }
  560. return {
  561. resolve: resolve,
  562. orient: orient
  563. };
  564. }
  565. var ROLE = "role";
  566. var TAB_INDEX = "tabindex";
  567. var DISABLED = "disabled";
  568. var ARIA_PREFIX = "aria-";
  569. var ARIA_CONTROLS = ARIA_PREFIX + "controls";
  570. var ARIA_CURRENT = ARIA_PREFIX + "current";
  571. var ARIA_SELECTED = ARIA_PREFIX + "selected";
  572. var ARIA_LABEL = ARIA_PREFIX + "label";
  573. var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby";
  574. var ARIA_HIDDEN = ARIA_PREFIX + "hidden";
  575. var ARIA_ORIENTATION = ARIA_PREFIX + "orientation";
  576. var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription";
  577. var ARIA_LIVE = ARIA_PREFIX + "live";
  578. var ARIA_BUSY = ARIA_PREFIX + "busy";
  579. var ARIA_ATOMIC = ARIA_PREFIX + "atomic";
  580. var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION];
  581. var CLASS_ROOT = PROJECT_CODE;
  582. var CLASS_TRACK = PROJECT_CODE + "__track";
  583. var CLASS_LIST = PROJECT_CODE + "__list";
  584. var CLASS_SLIDE = PROJECT_CODE + "__slide";
  585. var CLASS_CLONE = CLASS_SLIDE + "--clone";
  586. var CLASS_CONTAINER = CLASS_SLIDE + "__container";
  587. var CLASS_ARROWS = PROJECT_CODE + "__arrows";
  588. var CLASS_ARROW = PROJECT_CODE + "__arrow";
  589. var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
  590. var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
  591. var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
  592. var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
  593. var CLASS_PROGRESS = PROJECT_CODE + "__progress";
  594. var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
  595. var CLASS_TOGGLE = PROJECT_CODE + "__toggle";
  596. var CLASS_TOGGLE_PLAY = CLASS_TOGGLE + "__play";
  597. var CLASS_TOGGLE_PAUSE = CLASS_TOGGLE + "__pause";
  598. var CLASS_SPINNER = PROJECT_CODE + "__spinner";
  599. var CLASS_SR = PROJECT_CODE + "__sr";
  600. var CLASS_INITIALIZED = "is-initialized";
  601. var CLASS_ACTIVE = "is-active";
  602. var CLASS_PREV = "is-prev";
  603. var CLASS_NEXT = "is-next";
  604. var CLASS_VISIBLE = "is-visible";
  605. var CLASS_LOADING = "is-loading";
  606. var CLASS_FOCUS_IN = "is-focus-in";
  607. var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN];
  608. var CLASSES = {
  609. slide: CLASS_SLIDE,
  610. clone: CLASS_CLONE,
  611. arrows: CLASS_ARROWS,
  612. arrow: CLASS_ARROW,
  613. prev: CLASS_ARROW_PREV,
  614. next: CLASS_ARROW_NEXT,
  615. pagination: CLASS_PAGINATION,
  616. page: CLASS_PAGINATION_PAGE,
  617. spinner: CLASS_SPINNER
  618. };
  619. function closest(from, selector) {
  620. if (isFunction(from.closest)) {
  621. return from.closest(selector);
  622. }
  623. var elm = from;
  624. while (elm && elm.nodeType === 1) {
  625. if (matches(elm, selector)) {
  626. break;
  627. }
  628. elm = elm.parentElement;
  629. }
  630. return elm;
  631. }
  632. var FRICTION = 5;
  633. var LOG_INTERVAL = 200;
  634. var POINTER_DOWN_EVENTS = "touchstart mousedown";
  635. var POINTER_MOVE_EVENTS = "touchmove mousemove";
  636. var POINTER_UP_EVENTS = "touchend touchcancel mouseup click";
  637. function Elements(Splide2, Components2, options) {
  638. var _EventInterface = EventInterface(Splide2),
  639. on = _EventInterface.on,
  640. bind = _EventInterface.bind;
  641. var root = Splide2.root;
  642. var i18n = options.i18n;
  643. var elements = {};
  644. var slides = [];
  645. var rootClasses = [];
  646. var trackClasses = [];
  647. var track;
  648. var list;
  649. var isUsingKey;
  650. function setup() {
  651. collect();
  652. init();
  653. update();
  654. }
  655. function mount() {
  656. on(EVENT_REFRESH, destroy);
  657. on(EVENT_REFRESH, setup);
  658. on(EVENT_UPDATED, update);
  659. bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) {
  660. isUsingKey = e.type === "keydown";
  661. }, {
  662. capture: true
  663. });
  664. bind(root, "focusin", function () {
  665. toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey);
  666. });
  667. }
  668. function destroy(completely) {
  669. var attrs = ALL_ATTRIBUTES.concat("style");
  670. empty(slides);
  671. removeClass(root, rootClasses);
  672. removeClass(track, trackClasses);
  673. removeAttribute([track, list], attrs);
  674. removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]);
  675. }
  676. function update() {
  677. removeClass(root, rootClasses);
  678. removeClass(track, trackClasses);
  679. rootClasses = getClasses(CLASS_ROOT);
  680. trackClasses = getClasses(CLASS_TRACK);
  681. addClass(root, rootClasses);
  682. addClass(track, trackClasses);
  683. setAttribute(root, ARIA_LABEL, options.label);
  684. setAttribute(root, ARIA_LABELLEDBY, options.labelledby);
  685. }
  686. function collect() {
  687. track = find("." + CLASS_TRACK);
  688. list = child(track, "." + CLASS_LIST);
  689. assert(track && list, "A track/list element is missing.");
  690. push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
  691. forOwn({
  692. arrows: CLASS_ARROWS,
  693. pagination: CLASS_PAGINATION,
  694. prev: CLASS_ARROW_PREV,
  695. next: CLASS_ARROW_NEXT,
  696. bar: CLASS_PROGRESS_BAR,
  697. toggle: CLASS_TOGGLE
  698. }, function (className, key) {
  699. elements[key] = find("." + className);
  700. });
  701. assign(elements, {
  702. root: root,
  703. track: track,
  704. list: list,
  705. slides: slides
  706. });
  707. }
  708. function init() {
  709. var id = root.id || uniqueId(PROJECT_CODE);
  710. var role = options.role;
  711. root.id = id;
  712. track.id = track.id || id + "-track";
  713. list.id = list.id || id + "-list";
  714. if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) {
  715. setAttribute(root, ROLE, role);
  716. }
  717. setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel);
  718. setAttribute(list, ROLE, "presentation");
  719. }
  720. function find(selector) {
  721. var elm = query(root, selector);
  722. return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0;
  723. }
  724. function getClasses(base) {
  725. return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE];
  726. }
  727. return assign(elements, {
  728. setup: setup,
  729. mount: mount,
  730. destroy: destroy
  731. });
  732. }
  733. var SLIDE = "slide";
  734. var LOOP = "loop";
  735. var FADE = "fade";
  736. function Slide$1(Splide2, index, slideIndex, slide) {
  737. var event = EventInterface(Splide2);
  738. var on = event.on,
  739. emit = event.emit,
  740. bind = event.bind;
  741. var Components = Splide2.Components,
  742. root = Splide2.root,
  743. options = Splide2.options;
  744. var isNavigation = options.isNavigation,
  745. updateOnMove = options.updateOnMove,
  746. i18n = options.i18n,
  747. pagination = options.pagination,
  748. slideFocus = options.slideFocus;
  749. var resolve = Components.Direction.resolve;
  750. var styles = getAttribute(slide, "style");
  751. var label = getAttribute(slide, ARIA_LABEL);
  752. var isClone = slideIndex > -1;
  753. var container = child(slide, "." + CLASS_CONTAINER);
  754. var focusableNodes = queryAll(slide, options.focusableNodes || "");
  755. var destroyed;
  756. function mount() {
  757. if (!isClone) {
  758. slide.id = root.id + "-slide" + pad(index + 1);
  759. setAttribute(slide, ROLE, pagination ? "tabpanel" : "group");
  760. setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide);
  761. setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length]));
  762. }
  763. listen();
  764. }
  765. function listen() {
  766. bind(slide, "click", apply(emit, EVENT_CLICK, self));
  767. bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self));
  768. on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update);
  769. on(EVENT_NAVIGATION_MOUNTED, initNavigation);
  770. if (updateOnMove) {
  771. on(EVENT_MOVE, onMove);
  772. }
  773. }
  774. function destroy() {
  775. destroyed = true;
  776. event.destroy();
  777. removeClass(slide, STATUS_CLASSES);
  778. removeAttribute(slide, ALL_ATTRIBUTES);
  779. setAttribute(slide, "style", styles);
  780. setAttribute(slide, ARIA_LABEL, label || "");
  781. }
  782. function initNavigation() {
  783. var controls = Splide2.splides.map(function (target) {
  784. var Slide2 = target.splide.Components.Slides.getAt(index);
  785. return Slide2 ? Slide2.slide.id : "";
  786. }).join(" ");
  787. setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1));
  788. setAttribute(slide, ARIA_CONTROLS, controls);
  789. setAttribute(slide, ROLE, slideFocus ? "button" : "");
  790. slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION);
  791. }
  792. function onMove() {
  793. if (!destroyed) {
  794. update();
  795. }
  796. }
  797. function update() {
  798. if (!destroyed) {
  799. var curr = Splide2.index;
  800. updateActivity();
  801. updateVisibility();
  802. toggleClass(slide, CLASS_PREV, index === curr - 1);
  803. toggleClass(slide, CLASS_NEXT, index === curr + 1);
  804. }
  805. }
  806. function updateActivity() {
  807. var active = isActive();
  808. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  809. toggleClass(slide, CLASS_ACTIVE, active);
  810. setAttribute(slide, ARIA_CURRENT, isNavigation && active || "");
  811. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self);
  812. }
  813. }
  814. function updateVisibility() {
  815. var visible = isVisible();
  816. var hidden = !visible && (!isActive() || isClone);
  817. if (!Splide2.state.is([MOVING, SCROLLING])) {
  818. setAttribute(slide, ARIA_HIDDEN, hidden || "");
  819. }
  820. setAttribute(focusableNodes, TAB_INDEX, hidden ? -1 : "");
  821. if (slideFocus) {
  822. setAttribute(slide, TAB_INDEX, hidden ? -1 : 0);
  823. }
  824. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  825. toggleClass(slide, CLASS_VISIBLE, visible);
  826. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self);
  827. }
  828. if (!visible && document.activeElement === slide) {
  829. var Slide2 = Components.Slides.getAt(Splide2.index);
  830. Slide2 && focus(Slide2.slide);
  831. }
  832. }
  833. function style$1(prop, value, useContainer) {
  834. style(useContainer && container || slide, prop, value);
  835. }
  836. function isActive() {
  837. var curr = Splide2.index;
  838. return curr === index || options.cloneStatus && curr === slideIndex;
  839. }
  840. function isVisible() {
  841. if (Splide2.is(FADE)) {
  842. return isActive();
  843. }
  844. var trackRect = rect(Components.Elements.track);
  845. var slideRect = rect(slide);
  846. var left = resolve("left");
  847. var right = resolve("right");
  848. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  849. }
  850. function isWithin(from, distance) {
  851. var diff = abs(from - index);
  852. if (!isClone && (options.rewind || Splide2.is(LOOP))) {
  853. diff = min(diff, Splide2.length - diff);
  854. }
  855. return diff <= distance;
  856. }
  857. var self = {
  858. index: index,
  859. slideIndex: slideIndex,
  860. slide: slide,
  861. container: container,
  862. isClone: isClone,
  863. mount: mount,
  864. destroy: destroy,
  865. update: update,
  866. style: style$1,
  867. isWithin: isWithin
  868. };
  869. return self;
  870. }
  871. function Slides(Splide2, Components2, options) {
  872. var _EventInterface2 = EventInterface(Splide2),
  873. on = _EventInterface2.on,
  874. emit = _EventInterface2.emit,
  875. bind = _EventInterface2.bind;
  876. var _Components2$Elements = Components2.Elements,
  877. slides = _Components2$Elements.slides,
  878. list = _Components2$Elements.list;
  879. var Slides2 = [];
  880. function mount() {
  881. init();
  882. on(EVENT_REFRESH, destroy);
  883. on(EVENT_REFRESH, init);
  884. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  885. Slides2.sort(function (Slide1, Slide2) {
  886. return Slide1.index - Slide2.index;
  887. });
  888. });
  889. }
  890. function init() {
  891. slides.forEach(function (slide, index) {
  892. register(slide, index, -1);
  893. });
  894. }
  895. function destroy() {
  896. forEach$1(function (Slide2) {
  897. Slide2.destroy();
  898. });
  899. empty(Slides2);
  900. }
  901. function update() {
  902. forEach$1(function (Slide2) {
  903. Slide2.update();
  904. });
  905. }
  906. function register(slide, index, slideIndex) {
  907. var object = Slide$1(Splide2, index, slideIndex, slide);
  908. object.mount();
  909. Slides2.push(object);
  910. }
  911. function get(excludeClones) {
  912. return excludeClones ? filter(function (Slide2) {
  913. return !Slide2.isClone;
  914. }) : Slides2;
  915. }
  916. function getIn(page) {
  917. var Controller = Components2.Controller;
  918. var index = Controller.toIndex(page);
  919. var max = Controller.hasFocus() ? 1 : options.perPage;
  920. return filter(function (Slide2) {
  921. return between(Slide2.index, index, index + max - 1);
  922. });
  923. }
  924. function getAt(index) {
  925. return filter(index)[0];
  926. }
  927. function add(items, index) {
  928. forEach(items, function (slide) {
  929. if (isString(slide)) {
  930. slide = parseHtml(slide);
  931. }
  932. if (isHTMLElement(slide)) {
  933. var ref = slides[index];
  934. ref ? before(slide, ref) : append(list, slide);
  935. addClass(slide, options.classes.slide);
  936. observeImages(slide, apply(emit, EVENT_RESIZE));
  937. }
  938. });
  939. emit(EVENT_REFRESH);
  940. }
  941. function remove$1(matcher) {
  942. remove(filter(matcher).map(function (Slide2) {
  943. return Slide2.slide;
  944. }));
  945. emit(EVENT_REFRESH);
  946. }
  947. function forEach$1(iteratee, excludeClones) {
  948. get(excludeClones).forEach(iteratee);
  949. }
  950. function filter(matcher) {
  951. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  952. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  953. });
  954. }
  955. function style(prop, value, useContainer) {
  956. forEach$1(function (Slide2) {
  957. Slide2.style(prop, value, useContainer);
  958. });
  959. }
  960. function observeImages(elm, callback) {
  961. var images = queryAll(elm, "img");
  962. var length = images.length;
  963. if (length) {
  964. images.forEach(function (img) {
  965. bind(img, "load error", function () {
  966. if (! --length) {
  967. callback();
  968. }
  969. });
  970. });
  971. } else {
  972. callback();
  973. }
  974. }
  975. function getLength(excludeClones) {
  976. return excludeClones ? slides.length : Slides2.length;
  977. }
  978. function isEnough() {
  979. return Slides2.length > options.perPage;
  980. }
  981. return {
  982. mount: mount,
  983. destroy: destroy,
  984. update: update,
  985. register: register,
  986. get: get,
  987. getIn: getIn,
  988. getAt: getAt,
  989. add: add,
  990. remove: remove$1,
  991. forEach: forEach$1,
  992. filter: filter,
  993. style: style,
  994. getLength: getLength,
  995. isEnough: isEnough
  996. };
  997. }
  998. function Layout(Splide2, Components2, options) {
  999. var _EventInterface3 = EventInterface(Splide2),
  1000. on = _EventInterface3.on,
  1001. bind = _EventInterface3.bind,
  1002. emit = _EventInterface3.emit;
  1003. var Slides = Components2.Slides;
  1004. var resolve = Components2.Direction.resolve;
  1005. var _Components2$Elements2 = Components2.Elements,
  1006. root = _Components2$Elements2.root,
  1007. track = _Components2$Elements2.track,
  1008. list = _Components2$Elements2.list;
  1009. var getAt = Slides.getAt,
  1010. styleSlides = Slides.style;
  1011. var vertical;
  1012. var rootRect;
  1013. function mount() {
  1014. init();
  1015. bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE)));
  1016. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1017. on(EVENT_RESIZE, resize);
  1018. }
  1019. function init() {
  1020. rootRect = null;
  1021. vertical = options.direction === TTB;
  1022. style(root, "maxWidth", unit(options.width));
  1023. style(track, resolve("paddingLeft"), cssPadding(false));
  1024. style(track, resolve("paddingRight"), cssPadding(true));
  1025. resize();
  1026. }
  1027. function resize() {
  1028. var newRect = rect(root);
  1029. if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
  1030. style(track, "height", cssTrackHeight());
  1031. styleSlides(resolve("marginRight"), unit(options.gap));
  1032. styleSlides("width", cssSlideWidth());
  1033. styleSlides("height", cssSlideHeight(), true);
  1034. rootRect = newRect;
  1035. emit(EVENT_RESIZED);
  1036. }
  1037. }
  1038. function cssPadding(right) {
  1039. var padding = options.padding;
  1040. var prop = resolve(right ? "right" : "left");
  1041. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  1042. }
  1043. function cssTrackHeight() {
  1044. var height = "";
  1045. if (vertical) {
  1046. height = cssHeight();
  1047. assert(height, "height or heightRatio is missing.");
  1048. height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")";
  1049. }
  1050. return height;
  1051. }
  1052. function cssHeight() {
  1053. return unit(options.height || rect(list).width * options.heightRatio);
  1054. }
  1055. function cssSlideWidth() {
  1056. return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1057. }
  1058. function cssSlideHeight() {
  1059. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight());
  1060. }
  1061. function cssSlideSize() {
  1062. var gap = unit(options.gap);
  1063. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1064. }
  1065. function listSize() {
  1066. return rect(list)[resolve("width")];
  1067. }
  1068. function slideSize(index, withoutGap) {
  1069. var Slide = getAt(index || 0);
  1070. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1071. }
  1072. function totalSize(index, withoutGap) {
  1073. var Slide = getAt(index);
  1074. if (Slide) {
  1075. var right = rect(Slide.slide)[resolve("right")];
  1076. var left = rect(list)[resolve("left")];
  1077. return abs(right - left) + (withoutGap ? 0 : getGap());
  1078. }
  1079. return 0;
  1080. }
  1081. function sliderSize() {
  1082. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1083. }
  1084. function getGap() {
  1085. var Slide = getAt(0);
  1086. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1087. }
  1088. function getPadding(right) {
  1089. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0;
  1090. }
  1091. return {
  1092. mount: mount,
  1093. listSize: listSize,
  1094. slideSize: slideSize,
  1095. sliderSize: sliderSize,
  1096. totalSize: totalSize,
  1097. getPadding: getPadding
  1098. };
  1099. }
  1100. var MULTIPLIER = 2;
  1101. function Clones(Splide2, Components2, options) {
  1102. var _EventInterface4 = EventInterface(Splide2),
  1103. on = _EventInterface4.on,
  1104. emit = _EventInterface4.emit;
  1105. var Elements = Components2.Elements,
  1106. Slides = Components2.Slides;
  1107. var resolve = Components2.Direction.resolve;
  1108. var clones = [];
  1109. var cloneCount;
  1110. function mount() {
  1111. init();
  1112. on(EVENT_REFRESH, destroy);
  1113. on(EVENT_REFRESH, init);
  1114. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1115. }
  1116. function init() {
  1117. if (cloneCount = computeCloneCount()) {
  1118. generate(cloneCount);
  1119. emit(EVENT_RESIZE);
  1120. }
  1121. }
  1122. function destroy() {
  1123. remove(clones);
  1124. empty(clones);
  1125. }
  1126. function observe() {
  1127. if (cloneCount < computeCloneCount()) {
  1128. emit(EVENT_REFRESH);
  1129. }
  1130. }
  1131. function generate(count) {
  1132. var slides = Slides.get().slice();
  1133. var length = slides.length;
  1134. if (length) {
  1135. while (slides.length < count) {
  1136. push(slides, slides);
  1137. }
  1138. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1139. var isHead = index < count;
  1140. var clone = cloneDeep(Slide.slide, index);
  1141. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1142. push(clones, clone);
  1143. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1144. });
  1145. }
  1146. }
  1147. function cloneDeep(elm, index) {
  1148. var clone = elm.cloneNode(true);
  1149. addClass(clone, options.classes.clone);
  1150. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1151. return clone;
  1152. }
  1153. function computeCloneCount() {
  1154. var clones2 = options.clones;
  1155. if (!Splide2.is(LOOP)) {
  1156. clones2 = 0;
  1157. } else if (!clones2) {
  1158. var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0);
  1159. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1160. clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER;
  1161. }
  1162. return clones2;
  1163. }
  1164. return {
  1165. mount: mount,
  1166. destroy: destroy
  1167. };
  1168. }
  1169. function Move(Splide2, Components2, options) {
  1170. var _EventInterface5 = EventInterface(Splide2),
  1171. on = _EventInterface5.on,
  1172. emit = _EventInterface5.emit;
  1173. var set = Splide2.state.set;
  1174. var _Components2$Layout = Components2.Layout,
  1175. slideSize = _Components2$Layout.slideSize,
  1176. getPadding = _Components2$Layout.getPadding,
  1177. totalSize = _Components2$Layout.totalSize,
  1178. listSize = _Components2$Layout.listSize,
  1179. sliderSize = _Components2$Layout.sliderSize;
  1180. var _Components2$Directio = Components2.Direction,
  1181. resolve = _Components2$Directio.resolve,
  1182. orient = _Components2$Directio.orient;
  1183. var _Components2$Elements3 = Components2.Elements,
  1184. list = _Components2$Elements3.list,
  1185. track = _Components2$Elements3.track;
  1186. var Transition;
  1187. function mount() {
  1188. Transition = Components2.Transition;
  1189. on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
  1190. }
  1191. function reposition() {
  1192. if (!Components2.Controller.isBusy()) {
  1193. Components2.Scroll.cancel();
  1194. jump(Splide2.index);
  1195. Components2.Slides.update();
  1196. }
  1197. }
  1198. function move(dest, index, prev, callback) {
  1199. var position = getPosition();
  1200. var crossing = sign(dest - prev) * orient(toPosition(dest) - position) < 0;
  1201. if ((dest !== index || crossing) && canShift(dest > prev)) {
  1202. cancel();
  1203. translate(shift(position, dest > prev), true);
  1204. }
  1205. set(MOVING);
  1206. emit(EVENT_MOVE, index, prev, dest);
  1207. Transition.start(index, function () {
  1208. set(IDLE);
  1209. emit(EVENT_MOVED, index, prev, dest);
  1210. callback && callback();
  1211. });
  1212. }
  1213. function jump(index) {
  1214. translate(toPosition(index, true));
  1215. }
  1216. function translate(position, preventLoop) {
  1217. if (!Splide2.is(FADE)) {
  1218. var destination = preventLoop ? position : loop(position);
  1219. style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)");
  1220. position !== destination && emit(EVENT_SHIFTED);
  1221. }
  1222. }
  1223. function loop(position) {
  1224. if (Splide2.is(LOOP)) {
  1225. var diff = orient(position - getPosition());
  1226. var exceededMin = exceededLimit(false, position) && diff < 0;
  1227. var exceededMax = exceededLimit(true, position) && diff > 0;
  1228. if (exceededMin || exceededMax) {
  1229. position = shift(position, exceededMax);
  1230. }
  1231. }
  1232. return position;
  1233. }
  1234. function shift(position, backwards) {
  1235. var excess = position - getLimit(backwards);
  1236. var size = sliderSize();
  1237. position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1);
  1238. return position;
  1239. }
  1240. function cancel() {
  1241. translate(getPosition());
  1242. Transition.cancel();
  1243. }
  1244. function toIndex(position) {
  1245. var Slides = Components2.Slides.get();
  1246. var index = 0;
  1247. var minDistance = Infinity;
  1248. for (var i = 0; i < Slides.length; i++) {
  1249. var slideIndex = Slides[i].index;
  1250. var distance = abs(toPosition(slideIndex, true) - position);
  1251. if (distance <= minDistance) {
  1252. minDistance = distance;
  1253. index = slideIndex;
  1254. } else {
  1255. break;
  1256. }
  1257. }
  1258. return index;
  1259. }
  1260. function toPosition(index, trimming) {
  1261. var position = orient(totalSize(index - 1) - offset(index));
  1262. return trimming ? trim(position) : position;
  1263. }
  1264. function getPosition() {
  1265. var left = resolve("left");
  1266. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1267. }
  1268. function trim(position) {
  1269. if (options.trimSpace && Splide2.is(SLIDE)) {
  1270. position = clamp(position, 0, orient(sliderSize() - listSize()));
  1271. }
  1272. return position;
  1273. }
  1274. function offset(index) {
  1275. var focus = options.focus;
  1276. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1277. }
  1278. function getLimit(max) {
  1279. return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
  1280. }
  1281. function canShift(backwards) {
  1282. var shifted = orient(shift(getPosition(), backwards));
  1283. return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")];
  1284. }
  1285. function exceededLimit(max, position) {
  1286. position = isUndefined(position) ? getPosition() : position;
  1287. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1288. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1289. return exceededMin || exceededMax;
  1290. }
  1291. return {
  1292. mount: mount,
  1293. move: move,
  1294. jump: jump,
  1295. translate: translate,
  1296. shift: shift,
  1297. cancel: cancel,
  1298. toIndex: toIndex,
  1299. toPosition: toPosition,
  1300. getPosition: getPosition,
  1301. getLimit: getLimit,
  1302. exceededLimit: exceededLimit,
  1303. reposition: reposition
  1304. };
  1305. }
  1306. function Controller(Splide2, Components2, options) {
  1307. var _EventInterface6 = EventInterface(Splide2),
  1308. on = _EventInterface6.on;
  1309. var Move = Components2.Move;
  1310. var getPosition = Move.getPosition,
  1311. getLimit = Move.getLimit,
  1312. toPosition = Move.toPosition;
  1313. var _Components2$Slides = Components2.Slides,
  1314. isEnough = _Components2$Slides.isEnough,
  1315. getLength = _Components2$Slides.getLength;
  1316. var isLoop = Splide2.is(LOOP);
  1317. var isSlide = Splide2.is(SLIDE);
  1318. var getNext = apply(getAdjacent, false);
  1319. var getPrev = apply(getAdjacent, true);
  1320. var currIndex = options.start || 0;
  1321. var prevIndex = currIndex;
  1322. var slideCount;
  1323. var perMove;
  1324. var perPage;
  1325. function mount() {
  1326. init();
  1327. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1328. }
  1329. function init() {
  1330. slideCount = getLength(true);
  1331. perMove = options.perMove;
  1332. perPage = options.perPage;
  1333. var index = clamp(currIndex, 0, slideCount - 1);
  1334. if (index !== currIndex) {
  1335. currIndex = index;
  1336. Move.reposition();
  1337. }
  1338. }
  1339. function go(control, allowSameIndex, callback) {
  1340. if (!isBusy()) {
  1341. var dest = parse(control);
  1342. var index = loop(dest);
  1343. if (index > -1 && (allowSameIndex || index !== currIndex)) {
  1344. setIndex(index);
  1345. Move.move(dest, index, prevIndex, callback);
  1346. }
  1347. }
  1348. }
  1349. function scroll(destination, duration, snap, callback) {
  1350. Components2.Scroll.scroll(destination, duration, snap, function () {
  1351. setIndex(loop(Move.toIndex(Move.getPosition())));
  1352. callback && callback();
  1353. });
  1354. }
  1355. function parse(control) {
  1356. var index = currIndex;
  1357. if (isString(control)) {
  1358. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1359. indicator = _ref[1],
  1360. number = _ref[2];
  1361. if (indicator === "+" || indicator === "-") {
  1362. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex);
  1363. } else if (indicator === ">") {
  1364. index = number ? toIndex(+number) : getNext(true);
  1365. } else if (indicator === "<") {
  1366. index = getPrev(true);
  1367. }
  1368. } else {
  1369. index = isLoop ? control : clamp(control, 0, getEnd());
  1370. }
  1371. return index;
  1372. }
  1373. function getAdjacent(prev, destination) {
  1374. var number = perMove || (hasFocus() ? 1 : perPage);
  1375. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus()));
  1376. if (dest === -1 && isSlide) {
  1377. if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
  1378. return prev ? 0 : getEnd();
  1379. }
  1380. }
  1381. return destination ? dest : loop(dest);
  1382. }
  1383. function computeDestIndex(dest, from, snapPage) {
  1384. if (isEnough()) {
  1385. var end = getEnd();
  1386. var index = computeMovableDestIndex(dest);
  1387. if (index !== dest) {
  1388. from = dest;
  1389. dest = index;
  1390. snapPage = false;
  1391. }
  1392. if (dest < 0 || dest > end) {
  1393. if (between(0, dest, from, true) || between(end, from, dest, true)) {
  1394. dest = toIndex(toPage(dest));
  1395. } else {
  1396. if (isLoop) {
  1397. dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest;
  1398. } else if (options.rewind) {
  1399. dest = dest < 0 ? end : 0;
  1400. } else {
  1401. dest = -1;
  1402. }
  1403. }
  1404. } else {
  1405. if (snapPage && dest !== from) {
  1406. dest = toIndex(toPage(from) + (dest < from ? -1 : 1));
  1407. }
  1408. }
  1409. } else {
  1410. dest = -1;
  1411. }
  1412. return dest;
  1413. }
  1414. function computeMovableDestIndex(dest) {
  1415. if (isSlide && options.trimSpace === "move" && dest !== currIndex) {
  1416. var position = getPosition();
  1417. while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) {
  1418. dest < currIndex ? --dest : ++dest;
  1419. }
  1420. }
  1421. return dest;
  1422. }
  1423. function loop(index) {
  1424. return isLoop ? (index + slideCount) % slideCount || 0 : index;
  1425. }
  1426. function getEnd() {
  1427. return max(slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage), 0);
  1428. }
  1429. function toIndex(page) {
  1430. return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
  1431. }
  1432. function toPage(index) {
  1433. return hasFocus() ? index : floor((index >= getEnd() ? slideCount - 1 : index) / perPage);
  1434. }
  1435. function toDest(destination) {
  1436. var closest = Move.toIndex(destination);
  1437. return isSlide ? clamp(closest, 0, getEnd()) : closest;
  1438. }
  1439. function setIndex(index) {
  1440. if (index !== currIndex) {
  1441. prevIndex = currIndex;
  1442. currIndex = index;
  1443. }
  1444. }
  1445. function getIndex(prev) {
  1446. return prev ? prevIndex : currIndex;
  1447. }
  1448. function hasFocus() {
  1449. return !isUndefined(options.focus) || options.isNavigation;
  1450. }
  1451. function isBusy() {
  1452. return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition;
  1453. }
  1454. return {
  1455. mount: mount,
  1456. go: go,
  1457. scroll: scroll,
  1458. getNext: getNext,
  1459. getPrev: getPrev,
  1460. getAdjacent: getAdjacent,
  1461. getEnd: getEnd,
  1462. setIndex: setIndex,
  1463. getIndex: getIndex,
  1464. toIndex: toIndex,
  1465. toPage: toPage,
  1466. toDest: toDest,
  1467. hasFocus: hasFocus,
  1468. isBusy: isBusy
  1469. };
  1470. }
  1471. var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1472. var 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";
  1473. var SIZE = 40;
  1474. function Arrows(Splide2, Components2, options) {
  1475. var event = EventInterface(Splide2);
  1476. var on = event.on,
  1477. bind = event.bind,
  1478. emit = event.emit;
  1479. var classes = options.classes,
  1480. i18n = options.i18n;
  1481. var Elements = Components2.Elements,
  1482. Controller = Components2.Controller;
  1483. var userArrows = Elements.arrows,
  1484. track = Elements.track;
  1485. var wrapper = userArrows;
  1486. var prev = Elements.prev;
  1487. var next = Elements.next;
  1488. var created;
  1489. var wrapperClasses;
  1490. var arrows = {};
  1491. function mount() {
  1492. init();
  1493. on(EVENT_UPDATED, remount);
  1494. }
  1495. function remount() {
  1496. destroy();
  1497. mount();
  1498. }
  1499. function init() {
  1500. var enabled = options.arrows;
  1501. if (enabled && !(prev && next)) {
  1502. createArrows();
  1503. }
  1504. if (prev && next) {
  1505. assign(arrows, {
  1506. prev: prev,
  1507. next: next
  1508. });
  1509. display(wrapper, enabled ? "" : "none");
  1510. addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction);
  1511. if (enabled) {
  1512. listen();
  1513. update();
  1514. setAttribute([prev, next], ARIA_CONTROLS, track.id);
  1515. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1516. }
  1517. }
  1518. }
  1519. function destroy() {
  1520. event.destroy();
  1521. removeClass(wrapper, wrapperClasses);
  1522. if (created) {
  1523. remove(userArrows ? [prev, next] : wrapper);
  1524. prev = next = null;
  1525. } else {
  1526. removeAttribute([prev, next], ALL_ATTRIBUTES);
  1527. }
  1528. }
  1529. function listen() {
  1530. on([EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1531. bind(next, "click", apply(go, ">"));
  1532. bind(prev, "click", apply(go, "<"));
  1533. }
  1534. function go(control) {
  1535. Controller.go(control, true);
  1536. }
  1537. function createArrows() {
  1538. wrapper = userArrows || create("div", classes.arrows);
  1539. prev = createArrow(true);
  1540. next = createArrow(false);
  1541. created = true;
  1542. append(wrapper, [prev, next]);
  1543. !userArrows && before(wrapper, track);
  1544. }
  1545. function createArrow(prev2) {
  1546. var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\" focusable=\"false\"><path d=\"" + (options.arrowPath || PATH) + "\" />";
  1547. return parseHtml(arrow);
  1548. }
  1549. function update() {
  1550. var index = Splide2.index;
  1551. var prevIndex = Controller.getPrev();
  1552. var nextIndex = Controller.getNext();
  1553. var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1554. var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1555. prev.disabled = prevIndex < 0;
  1556. next.disabled = nextIndex < 0;
  1557. setAttribute(prev, ARIA_LABEL, prevLabel);
  1558. setAttribute(next, ARIA_LABEL, nextLabel);
  1559. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1560. }
  1561. return {
  1562. arrows: arrows,
  1563. mount: mount,
  1564. destroy: destroy
  1565. };
  1566. }
  1567. var INTERVAL_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-interval";
  1568. function Autoplay(Splide2, Components2, options) {
  1569. var _EventInterface7 = EventInterface(Splide2),
  1570. on = _EventInterface7.on,
  1571. bind = _EventInterface7.bind,
  1572. emit = _EventInterface7.emit;
  1573. var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
  1574. var isPaused = interval.isPaused;
  1575. var Elements = Components2.Elements,
  1576. _Components2$Elements4 = Components2.Elements,
  1577. root = _Components2$Elements4.root,
  1578. toggle = _Components2$Elements4.toggle;
  1579. var autoplay = options.autoplay;
  1580. var hovered;
  1581. var focused;
  1582. var stopped = autoplay === "pause";
  1583. function mount() {
  1584. if (autoplay) {
  1585. listen();
  1586. toggle && setAttribute(toggle, ARIA_CONTROLS, Elements.track.id);
  1587. stopped || play();
  1588. update();
  1589. }
  1590. }
  1591. function listen() {
  1592. if (options.pauseOnHover) {
  1593. bind(root, "mouseenter mouseleave", function (e) {
  1594. hovered = e.type === "mouseenter";
  1595. autoToggle();
  1596. });
  1597. }
  1598. if (options.pauseOnFocus) {
  1599. bind(root, "focusin focusout", function (e) {
  1600. focused = e.type === "focusin";
  1601. autoToggle();
  1602. });
  1603. }
  1604. if (toggle) {
  1605. bind(toggle, "click", function () {
  1606. stopped ? play() : pause(true);
  1607. });
  1608. }
  1609. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1610. on(EVENT_MOVE, onMove);
  1611. }
  1612. function play() {
  1613. if (isPaused() && Components2.Slides.isEnough()) {
  1614. interval.start(!options.resetProgress);
  1615. focused = hovered = stopped = false;
  1616. update();
  1617. emit(EVENT_AUTOPLAY_PLAY);
  1618. }
  1619. }
  1620. function pause(stop) {
  1621. if (stop === void 0) {
  1622. stop = true;
  1623. }
  1624. stopped = !!stop;
  1625. update();
  1626. if (!isPaused()) {
  1627. interval.pause();
  1628. emit(EVENT_AUTOPLAY_PAUSE);
  1629. }
  1630. }
  1631. function autoToggle() {
  1632. if (!stopped) {
  1633. hovered || focused ? pause(false) : play();
  1634. }
  1635. }
  1636. function update() {
  1637. if (toggle) {
  1638. toggleClass(toggle, CLASS_ACTIVE, !stopped);
  1639. setAttribute(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]);
  1640. }
  1641. }
  1642. function onAnimationFrame(rate) {
  1643. var bar = Elements.bar;
  1644. bar && style(bar, "width", rate * 100 + "%");
  1645. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1646. }
  1647. function onMove(index) {
  1648. var Slide = Components2.Slides.getAt(index);
  1649. interval.set(Slide && +getAttribute(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval);
  1650. }
  1651. return {
  1652. mount: mount,
  1653. destroy: interval.cancel,
  1654. play: play,
  1655. pause: pause,
  1656. isPaused: isPaused
  1657. };
  1658. }
  1659. function Cover(Splide2, Components2, options) {
  1660. var _EventInterface8 = EventInterface(Splide2),
  1661. on = _EventInterface8.on;
  1662. function mount() {
  1663. if (options.cover) {
  1664. on(EVENT_LAZYLOAD_LOADED, apply(toggle, true));
  1665. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply(cover, true));
  1666. }
  1667. }
  1668. function cover(cover2) {
  1669. Components2.Slides.forEach(function (Slide) {
  1670. var img = child(Slide.container || Slide.slide, "img");
  1671. if (img && img.src) {
  1672. toggle(cover2, img, Slide);
  1673. }
  1674. });
  1675. }
  1676. function toggle(cover2, img, Slide) {
  1677. Slide.style("background", cover2 ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
  1678. display(img, cover2 ? "none" : "");
  1679. }
  1680. return {
  1681. mount: mount,
  1682. destroy: apply(cover, false)
  1683. };
  1684. }
  1685. var BOUNCE_DIFF_THRESHOLD = 10;
  1686. var BOUNCE_DURATION = 600;
  1687. var FRICTION_FACTOR = 0.6;
  1688. var BASE_VELOCITY = 1.5;
  1689. var MIN_DURATION = 800;
  1690. function Scroll(Splide2, Components2, options) {
  1691. var _EventInterface9 = EventInterface(Splide2),
  1692. on = _EventInterface9.on,
  1693. emit = _EventInterface9.emit;
  1694. var set = Splide2.state.set;
  1695. var Move = Components2.Move;
  1696. var getPosition = Move.getPosition,
  1697. getLimit = Move.getLimit,
  1698. exceededLimit = Move.exceededLimit,
  1699. translate = Move.translate;
  1700. var interval;
  1701. var callback;
  1702. var friction = 1;
  1703. function mount() {
  1704. on(EVENT_MOVE, clear);
  1705. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1706. }
  1707. function scroll(destination, duration, snap, onScrolled, noConstrain) {
  1708. var from = getPosition();
  1709. clear();
  1710. if (snap) {
  1711. var size = Components2.Layout.sliderSize();
  1712. var offset = sign(destination) * size * floor(abs(destination) / size) || 0;
  1713. destination = Move.toPosition(Components2.Controller.toDest(destination % size)) + offset;
  1714. }
  1715. var noDistance = approximatelyEqual(from, destination, 1);
  1716. friction = 1;
  1717. duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
  1718. callback = onScrolled;
  1719. interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
  1720. set(SCROLLING);
  1721. emit(EVENT_SCROLL);
  1722. interval.start();
  1723. }
  1724. function onEnd() {
  1725. set(IDLE);
  1726. callback && callback();
  1727. emit(EVENT_SCROLLED);
  1728. }
  1729. function update(from, to, noConstrain, rate) {
  1730. var position = getPosition();
  1731. var target = from + (to - from) * easing(rate);
  1732. var diff = (target - position) * friction;
  1733. translate(position + diff);
  1734. if (Splide2.is(SLIDE) && !noConstrain && exceededLimit()) {
  1735. friction *= FRICTION_FACTOR;
  1736. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1737. scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true);
  1738. }
  1739. }
  1740. }
  1741. function clear() {
  1742. if (interval) {
  1743. interval.cancel();
  1744. }
  1745. }
  1746. function cancel() {
  1747. if (interval && !interval.isPaused()) {
  1748. clear();
  1749. onEnd();
  1750. }
  1751. }
  1752. function easing(t) {
  1753. var easingFunc = options.easingFunc;
  1754. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1755. }
  1756. return {
  1757. mount: mount,
  1758. destroy: clear,
  1759. scroll: scroll,
  1760. cancel: cancel
  1761. };
  1762. }
  1763. var SCROLL_LISTENER_OPTIONS = {
  1764. passive: false,
  1765. capture: true
  1766. };
  1767. function Drag(Splide2, Components2, options) {
  1768. var _EventInterface10 = EventInterface(Splide2),
  1769. on = _EventInterface10.on,
  1770. emit = _EventInterface10.emit,
  1771. bind = _EventInterface10.bind,
  1772. unbind = _EventInterface10.unbind;
  1773. var state = Splide2.state;
  1774. var Move = Components2.Move,
  1775. Scroll = Components2.Scroll,
  1776. Controller = Components2.Controller,
  1777. track = Components2.Elements.track,
  1778. reduce = Components2.Media.reduce;
  1779. var _Components2$Directio2 = Components2.Direction,
  1780. resolve = _Components2$Directio2.resolve,
  1781. orient = _Components2$Directio2.orient;
  1782. var getPosition = Move.getPosition,
  1783. exceededLimit = Move.exceededLimit;
  1784. var basePosition;
  1785. var baseEvent;
  1786. var prevBaseEvent;
  1787. var isFree;
  1788. var dragging;
  1789. var exceeded = false;
  1790. var clickPrevented;
  1791. var disabled;
  1792. var target;
  1793. function mount() {
  1794. bind(track, POINTER_MOVE_EVENTS, noop, SCROLL_LISTENER_OPTIONS);
  1795. bind(track, POINTER_UP_EVENTS, noop, SCROLL_LISTENER_OPTIONS);
  1796. bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS);
  1797. bind(track, "click", onClick, {
  1798. capture: true
  1799. });
  1800. bind(track, "dragstart", prevent);
  1801. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1802. }
  1803. function init() {
  1804. var drag = options.drag;
  1805. disable(!drag);
  1806. isFree = drag === "free";
  1807. }
  1808. function onPointerDown(e) {
  1809. clickPrevented = false;
  1810. if (!disabled) {
  1811. var isTouch = isTouchEvent(e);
  1812. if (isDraggable(e.target) && (isTouch || !e.button)) {
  1813. if (!Controller.isBusy()) {
  1814. target = isTouch ? track : window;
  1815. dragging = state.is([MOVING, SCROLLING]);
  1816. prevBaseEvent = null;
  1817. bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS);
  1818. bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS);
  1819. Move.cancel();
  1820. Scroll.cancel();
  1821. save(e);
  1822. } else {
  1823. prevent(e, true);
  1824. }
  1825. }
  1826. }
  1827. }
  1828. function onPointerMove(e) {
  1829. if (!state.is(DRAGGING)) {
  1830. state.set(DRAGGING);
  1831. emit(EVENT_DRAG);
  1832. }
  1833. if (e.cancelable) {
  1834. if (dragging) {
  1835. Move.translate(basePosition + constrain(diffCoord(e)));
  1836. var expired = diffTime(e) > LOG_INTERVAL;
  1837. var hasExceeded = exceeded !== (exceeded = exceededLimit());
  1838. if (expired || hasExceeded) {
  1839. save(e);
  1840. }
  1841. clickPrevented = true;
  1842. emit(EVENT_DRAGGING);
  1843. prevent(e);
  1844. } else if (isSliderDirection(e)) {
  1845. dragging = shouldStart(e);
  1846. prevent(e);
  1847. }
  1848. }
  1849. }
  1850. function onPointerUp(e) {
  1851. if (state.is(DRAGGING)) {
  1852. state.set(IDLE);
  1853. emit(EVENT_DRAGGED);
  1854. }
  1855. if (dragging) {
  1856. move(e);
  1857. prevent(e);
  1858. }
  1859. unbind(target, POINTER_MOVE_EVENTS, onPointerMove);
  1860. unbind(target, POINTER_UP_EVENTS, onPointerUp);
  1861. dragging = false;
  1862. }
  1863. function onClick(e) {
  1864. if (!disabled && clickPrevented) {
  1865. prevent(e, true);
  1866. }
  1867. }
  1868. function save(e) {
  1869. prevBaseEvent = baseEvent;
  1870. baseEvent = e;
  1871. basePosition = getPosition();
  1872. }
  1873. function move(e) {
  1874. var velocity = computeVelocity(e);
  1875. var destination = computeDestination(velocity);
  1876. var rewind = options.rewind && options.rewindByDrag;
  1877. reduce(false);
  1878. if (isFree) {
  1879. Controller.scroll(destination, 0, options.snap);
  1880. } else if (Splide2.is(FADE)) {
  1881. Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
  1882. } else if (Splide2.is(SLIDE) && exceeded && rewind) {
  1883. Controller.go(exceededLimit(true) ? ">" : "<");
  1884. } else {
  1885. Controller.go(Controller.toDest(destination), true);
  1886. }
  1887. reduce(true);
  1888. }
  1889. function shouldStart(e) {
  1890. var thresholds = options.dragMinThreshold;
  1891. var isObj = isObject(thresholds);
  1892. var mouse = isObj && thresholds.mouse || 0;
  1893. var touch = (isObj ? thresholds.touch : +thresholds) || 10;
  1894. return abs(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse);
  1895. }
  1896. function isSliderDirection(e) {
  1897. return abs(diffCoord(e)) > abs(diffCoord(e, true));
  1898. }
  1899. function computeVelocity(e) {
  1900. if (Splide2.is(LOOP) || !exceeded) {
  1901. var time = diffTime(e);
  1902. if (time && time < LOG_INTERVAL) {
  1903. return diffCoord(e) / time;
  1904. }
  1905. }
  1906. return 0;
  1907. }
  1908. function computeDestination(velocity) {
  1909. return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
  1910. }
  1911. function diffCoord(e, orthogonal) {
  1912. return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal);
  1913. }
  1914. function diffTime(e) {
  1915. return timeOf(e) - timeOf(getBaseEvent(e));
  1916. }
  1917. function getBaseEvent(e) {
  1918. return baseEvent === e && prevBaseEvent || baseEvent;
  1919. }
  1920. function coordOf(e, orthogonal) {
  1921. return (isTouchEvent(e) ? e.changedTouches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")];
  1922. }
  1923. function constrain(diff) {
  1924. return diff / (exceeded && Splide2.is(SLIDE) ? FRICTION : 1);
  1925. }
  1926. function isDraggable(target2) {
  1927. var noDrag = options.noDrag;
  1928. return !matches(target2, "." + CLASS_PAGINATION_PAGE + ", ." + CLASS_ARROW) && (!noDrag || !matches(target2, noDrag));
  1929. }
  1930. function isTouchEvent(e) {
  1931. return typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
  1932. }
  1933. function isDragging() {
  1934. return dragging;
  1935. }
  1936. function disable(value) {
  1937. disabled = value;
  1938. }
  1939. return {
  1940. mount: mount,
  1941. disable: disable,
  1942. isDragging: isDragging
  1943. };
  1944. }
  1945. var NORMALIZATION_MAP = {
  1946. Spacebar: " ",
  1947. Right: ARROW_RIGHT,
  1948. Left: ARROW_LEFT,
  1949. Up: ARROW_UP,
  1950. Down: ARROW_DOWN
  1951. };
  1952. function normalizeKey(key) {
  1953. key = isString(key) ? key : key.key;
  1954. return NORMALIZATION_MAP[key] || key;
  1955. }
  1956. var KEYBOARD_EVENT = "keydown";
  1957. function Keyboard(Splide2, Components2, options) {
  1958. var _EventInterface11 = EventInterface(Splide2),
  1959. on = _EventInterface11.on,
  1960. bind = _EventInterface11.bind,
  1961. unbind = _EventInterface11.unbind;
  1962. var root = Splide2.root;
  1963. var resolve = Components2.Direction.resolve;
  1964. var target;
  1965. var disabled;
  1966. function mount() {
  1967. init();
  1968. on(EVENT_UPDATED, destroy);
  1969. on(EVENT_UPDATED, init);
  1970. on(EVENT_MOVE, onMove);
  1971. }
  1972. function init() {
  1973. var keyboard = options.keyboard;
  1974. if (keyboard) {
  1975. target = keyboard === "global" ? window : root;
  1976. bind(target, KEYBOARD_EVENT, onKeydown);
  1977. }
  1978. }
  1979. function destroy() {
  1980. unbind(target, KEYBOARD_EVENT);
  1981. }
  1982. function disable(value) {
  1983. disabled = value;
  1984. }
  1985. function onMove() {
  1986. var _disabled = disabled;
  1987. disabled = true;
  1988. nextTick(function () {
  1989. disabled = _disabled;
  1990. });
  1991. }
  1992. function onKeydown(e) {
  1993. if (!disabled) {
  1994. var key = normalizeKey(e);
  1995. if (key === resolve(ARROW_LEFT)) {
  1996. Splide2.go("<");
  1997. } else if (key === resolve(ARROW_RIGHT)) {
  1998. Splide2.go(">");
  1999. }
  2000. }
  2001. }
  2002. return {
  2003. mount: mount,
  2004. destroy: destroy,
  2005. disable: disable
  2006. };
  2007. }
  2008. var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
  2009. var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
  2010. var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
  2011. function LazyLoad(Splide2, Components2, options) {
  2012. var _EventInterface12 = EventInterface(Splide2),
  2013. on = _EventInterface12.on,
  2014. off = _EventInterface12.off,
  2015. bind = _EventInterface12.bind,
  2016. emit = _EventInterface12.emit;
  2017. var isSequential = options.lazyLoad === "sequential";
  2018. var events = [EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED, EVENT_SCROLLED];
  2019. var entries = [];
  2020. function mount() {
  2021. if (options.lazyLoad) {
  2022. init();
  2023. on(EVENT_REFRESH, init);
  2024. isSequential || on(events, observe);
  2025. }
  2026. }
  2027. function init() {
  2028. empty(entries);
  2029. Components2.Slides.forEach(function (Slide) {
  2030. queryAll(Slide.slide, IMAGE_SELECTOR).forEach(function (img) {
  2031. var src = getAttribute(img, SRC_DATA_ATTRIBUTE);
  2032. var srcset = getAttribute(img, SRCSET_DATA_ATTRIBUTE);
  2033. if (src !== img.src || srcset !== img.srcset) {
  2034. var className = options.classes.spinner;
  2035. var parent = img.parentElement;
  2036. var spinner = child(parent, "." + className) || create("span", className, parent);
  2037. entries.push([img, Slide, spinner]);
  2038. img.src || display(img, "none");
  2039. }
  2040. });
  2041. });
  2042. isSequential && loadNext();
  2043. }
  2044. function observe() {
  2045. entries = entries.filter(function (data) {
  2046. var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
  2047. return data[1].isWithin(Splide2.index, distance) ? load(data) : true;
  2048. });
  2049. entries.length || off(events);
  2050. }
  2051. function load(data) {
  2052. var img = data[0];
  2053. addClass(data[1].slide, CLASS_LOADING);
  2054. bind(img, "load error", apply(onLoad, data));
  2055. setAttribute(img, "src", getAttribute(img, SRC_DATA_ATTRIBUTE));
  2056. setAttribute(img, "srcset", getAttribute(img, SRCSET_DATA_ATTRIBUTE));
  2057. removeAttribute(img, SRC_DATA_ATTRIBUTE);
  2058. removeAttribute(img, SRCSET_DATA_ATTRIBUTE);
  2059. }
  2060. function onLoad(data, e) {
  2061. var img = data[0],
  2062. Slide = data[1];
  2063. removeClass(Slide.slide, CLASS_LOADING);
  2064. if (e.type !== "error") {
  2065. remove(data[2]);
  2066. display(img, "");
  2067. emit(EVENT_LAZYLOAD_LOADED, img, Slide);
  2068. emit(EVENT_RESIZE);
  2069. }
  2070. isSequential && loadNext();
  2071. }
  2072. function loadNext() {
  2073. entries.length && load(entries.shift());
  2074. }
  2075. return {
  2076. mount: mount,
  2077. destroy: apply(empty, entries)
  2078. };
  2079. }
  2080. function Pagination(Splide2, Components2, options) {
  2081. var event = EventInterface(Splide2);
  2082. var on = event.on,
  2083. emit = event.emit,
  2084. bind = event.bind;
  2085. var Slides = Components2.Slides,
  2086. Elements = Components2.Elements,
  2087. Controller = Components2.Controller;
  2088. var hasFocus = Controller.hasFocus,
  2089. getIndex = Controller.getIndex,
  2090. go = Controller.go;
  2091. var resolve = Components2.Direction.resolve;
  2092. var items = [];
  2093. var list;
  2094. var paginationClasses;
  2095. function mount() {
  2096. destroy();
  2097. on([EVENT_UPDATED, EVENT_REFRESH], mount);
  2098. if (options.pagination && Slides.isEnough()) {
  2099. on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update);
  2100. createPagination();
  2101. update();
  2102. emit(EVENT_PAGINATION_MOUNTED, {
  2103. list: list,
  2104. items: items
  2105. }, getAt(Splide2.index));
  2106. }
  2107. }
  2108. function destroy() {
  2109. if (list) {
  2110. remove(Elements.pagination ? slice(list.children) : list);
  2111. removeClass(list, paginationClasses);
  2112. empty(items);
  2113. list = null;
  2114. }
  2115. event.destroy();
  2116. }
  2117. function createPagination() {
  2118. var length = Splide2.length;
  2119. var classes = options.classes,
  2120. i18n = options.i18n,
  2121. perPage = options.perPage;
  2122. var max = hasFocus() ? length : ceil(length / perPage);
  2123. list = Elements.pagination || create("ul", classes.pagination, Elements.track.parentElement);
  2124. addClass(list, paginationClasses = CLASS_PAGINATION + "--" + getDirection());
  2125. setAttribute(list, ROLE, "tablist");
  2126. setAttribute(list, ARIA_LABEL, i18n.select);
  2127. setAttribute(list, ARIA_ORIENTATION, getDirection() === TTB ? "vertical" : "");
  2128. for (var i = 0; i < max; i++) {
  2129. var li = create("li", null, list);
  2130. var button = create("button", {
  2131. class: classes.page,
  2132. type: "button"
  2133. }, li);
  2134. var controls = Slides.getIn(i).map(function (Slide) {
  2135. return Slide.slide.id;
  2136. });
  2137. var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2138. bind(button, "click", apply(onClick, i));
  2139. if (options.paginationKeyboard) {
  2140. bind(button, "keydown", apply(onKeydown, i));
  2141. }
  2142. setAttribute(li, ROLE, "presentation");
  2143. setAttribute(button, ROLE, "tab");
  2144. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2145. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2146. setAttribute(button, TAB_INDEX, -1);
  2147. items.push({
  2148. li: li,
  2149. button: button,
  2150. page: i
  2151. });
  2152. }
  2153. }
  2154. function onClick(page) {
  2155. go(">" + page, true);
  2156. }
  2157. function onKeydown(page, e) {
  2158. var length = items.length;
  2159. var key = normalizeKey(e);
  2160. var dir = getDirection();
  2161. var nextPage = -1;
  2162. if (key === resolve(ARROW_RIGHT, false, dir)) {
  2163. nextPage = ++page % length;
  2164. } else if (key === resolve(ARROW_LEFT, false, dir)) {
  2165. nextPage = (--page + length) % length;
  2166. } else if (key === "Home") {
  2167. nextPage = 0;
  2168. } else if (key === "End") {
  2169. nextPage = length - 1;
  2170. }
  2171. var item = items[nextPage];
  2172. if (item) {
  2173. focus(item.button);
  2174. go(">" + nextPage);
  2175. prevent(e, true);
  2176. }
  2177. }
  2178. function getDirection() {
  2179. return options.paginationDirection || options.direction;
  2180. }
  2181. function getAt(index) {
  2182. return items[Controller.toPage(index)];
  2183. }
  2184. function update() {
  2185. var prev = getAt(getIndex(true));
  2186. var curr = getAt(getIndex());
  2187. if (prev) {
  2188. var button = prev.button;
  2189. removeClass(button, CLASS_ACTIVE);
  2190. removeAttribute(button, ARIA_SELECTED);
  2191. setAttribute(button, TAB_INDEX, -1);
  2192. }
  2193. if (curr) {
  2194. var _button = curr.button;
  2195. addClass(_button, CLASS_ACTIVE);
  2196. setAttribute(_button, ARIA_SELECTED, true);
  2197. setAttribute(_button, TAB_INDEX, "");
  2198. }
  2199. emit(EVENT_PAGINATION_UPDATED, {
  2200. list: list,
  2201. items: items
  2202. }, prev, curr);
  2203. }
  2204. return {
  2205. items: items,
  2206. mount: mount,
  2207. destroy: destroy,
  2208. getAt: getAt,
  2209. update: update
  2210. };
  2211. }
  2212. var TRIGGER_KEYS = [" ", "Enter"];
  2213. function Sync(Splide2, Components2, options) {
  2214. var isNavigation = options.isNavigation,
  2215. slideFocus = options.slideFocus;
  2216. var events = [];
  2217. function setup() {
  2218. Splide2.options = {
  2219. slideFocus: isUndefined(slideFocus) ? isNavigation : slideFocus
  2220. };
  2221. }
  2222. function mount() {
  2223. Splide2.splides.forEach(function (target) {
  2224. if (!target.isParent) {
  2225. sync(Splide2, target.splide);
  2226. sync(target.splide, Splide2);
  2227. }
  2228. });
  2229. if (isNavigation) {
  2230. navigate();
  2231. }
  2232. }
  2233. function destroy() {
  2234. events.forEach(function (event) {
  2235. event.destroy();
  2236. });
  2237. empty(events);
  2238. }
  2239. function remount() {
  2240. destroy();
  2241. mount();
  2242. }
  2243. function sync(splide, target) {
  2244. var event = EventInterface(splide);
  2245. event.on(EVENT_MOVE, function (index, prev, dest) {
  2246. target.go(target.is(LOOP) ? dest : index);
  2247. });
  2248. events.push(event);
  2249. }
  2250. function navigate() {
  2251. var event = EventInterface(Splide2);
  2252. var on = event.on;
  2253. on(EVENT_CLICK, onClick);
  2254. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2255. on([EVENT_MOUNTED, EVENT_UPDATED], update);
  2256. events.push(event);
  2257. event.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2258. }
  2259. function update() {
  2260. setAttribute(Components2.Elements.list, ARIA_ORIENTATION, options.direction === TTB ? "vertical" : "");
  2261. }
  2262. function onClick(Slide) {
  2263. Splide2.go(Slide.index);
  2264. }
  2265. function onKeydown(Slide, e) {
  2266. if (includes(TRIGGER_KEYS, normalizeKey(e))) {
  2267. onClick(Slide);
  2268. prevent(e);
  2269. }
  2270. }
  2271. return {
  2272. setup: setup,
  2273. mount: mount,
  2274. destroy: destroy,
  2275. remount: remount
  2276. };
  2277. }
  2278. function Wheel(Splide2, Components2, options) {
  2279. var _EventInterface13 = EventInterface(Splide2),
  2280. bind = _EventInterface13.bind;
  2281. var lastTime = 0;
  2282. function mount() {
  2283. if (options.wheel) {
  2284. bind(Components2.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS);
  2285. }
  2286. }
  2287. function onWheel(e) {
  2288. if (e.cancelable) {
  2289. var deltaY = e.deltaY;
  2290. var backwards = deltaY < 0;
  2291. var timeStamp = timeOf(e);
  2292. var _min = options.wheelMinThreshold || 0;
  2293. var sleep = options.wheelSleep || 0;
  2294. if (abs(deltaY) > _min && timeStamp - lastTime > sleep) {
  2295. Splide2.go(backwards ? "<" : ">");
  2296. lastTime = timeStamp;
  2297. }
  2298. shouldPrevent(backwards) && prevent(e);
  2299. }
  2300. }
  2301. function shouldPrevent(backwards) {
  2302. return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1;
  2303. }
  2304. return {
  2305. mount: mount
  2306. };
  2307. }
  2308. var SR_REMOVAL_DELAY = 90;
  2309. function Live(Splide2, Components2, options) {
  2310. var _EventInterface14 = EventInterface(Splide2),
  2311. on = _EventInterface14.on;
  2312. var track = Components2.Elements.track;
  2313. var enabled = options.live && !options.isNavigation;
  2314. var sr = create("span", CLASS_SR);
  2315. var interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
  2316. function mount() {
  2317. if (enabled) {
  2318. disable(!Components2.Autoplay.isPaused());
  2319. setAttribute(track, ARIA_ATOMIC, true);
  2320. sr.textContent = "\u2026";
  2321. on(EVENT_AUTOPLAY_PLAY, apply(disable, true));
  2322. on(EVENT_AUTOPLAY_PAUSE, apply(disable, false));
  2323. on([EVENT_MOVED, EVENT_SCROLLED], apply(toggle, true));
  2324. }
  2325. }
  2326. function toggle(active) {
  2327. setAttribute(track, ARIA_BUSY, active);
  2328. if (active) {
  2329. append(track, sr);
  2330. interval.start();
  2331. } else {
  2332. remove(sr);
  2333. }
  2334. }
  2335. function destroy() {
  2336. removeAttribute(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]);
  2337. remove(sr);
  2338. }
  2339. function disable(disabled) {
  2340. if (enabled) {
  2341. setAttribute(track, ARIA_LIVE, disabled ? "off" : "polite");
  2342. }
  2343. }
  2344. return {
  2345. mount: mount,
  2346. disable: disable,
  2347. destroy: destroy
  2348. };
  2349. }
  2350. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2351. __proto__: null,
  2352. Media: Media,
  2353. Direction: Direction,
  2354. Elements: Elements,
  2355. Slides: Slides,
  2356. Layout: Layout,
  2357. Clones: Clones,
  2358. Move: Move,
  2359. Controller: Controller,
  2360. Arrows: Arrows,
  2361. Autoplay: Autoplay,
  2362. Cover: Cover,
  2363. Scroll: Scroll,
  2364. Drag: Drag,
  2365. Keyboard: Keyboard,
  2366. LazyLoad: LazyLoad,
  2367. Pagination: Pagination,
  2368. Sync: Sync,
  2369. Wheel: Wheel,
  2370. Live: Live
  2371. });
  2372. var I18N = {
  2373. prev: "Previous slide",
  2374. next: "Next slide",
  2375. first: "Go to first slide",
  2376. last: "Go to last slide",
  2377. slideX: "Go to slide %s",
  2378. pageX: "Go to page %s",
  2379. play: "Start autoplay",
  2380. pause: "Pause autoplay",
  2381. carousel: "carousel",
  2382. slide: "slide",
  2383. select: "Select a slide to show",
  2384. slideLabel: "%s of %s"
  2385. };
  2386. var DEFAULTS = {
  2387. type: "slide",
  2388. role: "region",
  2389. speed: 400,
  2390. perPage: 1,
  2391. cloneStatus: true,
  2392. arrows: true,
  2393. pagination: true,
  2394. paginationKeyboard: true,
  2395. interval: 5e3,
  2396. pauseOnHover: true,
  2397. pauseOnFocus: true,
  2398. resetProgress: true,
  2399. easing: "cubic-bezier(0.25, 1, 0.5, 1)",
  2400. drag: true,
  2401. direction: "ltr",
  2402. trimSpace: true,
  2403. focusableNodes: "a, button, textarea, input, select, iframe",
  2404. live: true,
  2405. classes: CLASSES,
  2406. i18n: I18N,
  2407. reducedMotion: {
  2408. speed: 0,
  2409. rewindSpeed: 0,
  2410. autoplay: "pause"
  2411. }
  2412. };
  2413. function Fade(Splide2, Components2, options) {
  2414. var _EventInterface15 = EventInterface(Splide2),
  2415. on = _EventInterface15.on;
  2416. function mount() {
  2417. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2418. nextTick(function () {
  2419. Components2.Slides.style("transition", "opacity " + options.speed + "ms " + options.easing);
  2420. });
  2421. });
  2422. }
  2423. function start(index, done) {
  2424. var track = Components2.Elements.track;
  2425. style(track, "height", unit(rect(track).height));
  2426. nextTick(function () {
  2427. done();
  2428. style(track, "height", "");
  2429. });
  2430. }
  2431. return {
  2432. mount: mount,
  2433. start: start,
  2434. cancel: noop
  2435. };
  2436. }
  2437. function Slide(Splide2, Components2, options) {
  2438. var _EventInterface16 = EventInterface(Splide2),
  2439. bind = _EventInterface16.bind;
  2440. var Move = Components2.Move,
  2441. Controller = Components2.Controller,
  2442. Scroll = Components2.Scroll;
  2443. var list = Components2.Elements.list;
  2444. var transition = apply(style, list, "transition");
  2445. var endCallback;
  2446. function mount() {
  2447. bind(list, "transitionend", function (e) {
  2448. if (e.target === list && endCallback) {
  2449. cancel();
  2450. endCallback();
  2451. }
  2452. });
  2453. }
  2454. function start(index, done) {
  2455. var destination = Move.toPosition(index, true);
  2456. var position = Move.getPosition();
  2457. var speed = getSpeed(index);
  2458. if (abs(destination - position) >= 1 && speed >= 1) {
  2459. if (options.useScroll) {
  2460. Scroll.scroll(destination, speed, false, done);
  2461. } else {
  2462. transition("transform " + speed + "ms " + options.easing);
  2463. Move.translate(destination, true);
  2464. endCallback = done;
  2465. }
  2466. } else {
  2467. Move.jump(index);
  2468. done();
  2469. }
  2470. }
  2471. function cancel() {
  2472. transition("");
  2473. Scroll.cancel();
  2474. }
  2475. function getSpeed(index) {
  2476. var rewindSpeed = options.rewindSpeed;
  2477. if (Splide2.is(SLIDE) && rewindSpeed) {
  2478. var prev = Controller.getIndex(true);
  2479. var end = Controller.getEnd();
  2480. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2481. return rewindSpeed;
  2482. }
  2483. }
  2484. return options.speed;
  2485. }
  2486. return {
  2487. mount: mount,
  2488. start: start,
  2489. cancel: cancel
  2490. };
  2491. }
  2492. var _Splide = /*#__PURE__*/function () {
  2493. function _Splide(target, options) {
  2494. this.event = EventInterface();
  2495. this.Components = {};
  2496. this.state = State(CREATED);
  2497. this.splides = [];
  2498. this._o = {};
  2499. this._E = {};
  2500. var root = isString(target) ? query(document, target) : target;
  2501. assert(root, root + " is invalid.");
  2502. this.root = root;
  2503. options = merge({
  2504. label: getAttribute(root, ARIA_LABEL) || "",
  2505. labelledby: getAttribute(root, ARIA_LABELLEDBY) || ""
  2506. }, DEFAULTS, _Splide.defaults, options || {});
  2507. try {
  2508. merge(options, JSON.parse(getAttribute(root, DATA_ATTRIBUTE)));
  2509. } catch (e) {
  2510. assert(false, "Invalid JSON");
  2511. }
  2512. this._o = Object.create(merge({}, options));
  2513. }
  2514. var _proto = _Splide.prototype;
  2515. _proto.mount = function mount(Extensions, Transition) {
  2516. var _this = this;
  2517. var state = this.state,
  2518. Components2 = this.Components;
  2519. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2520. state.set(CREATED);
  2521. this._C = Components2;
  2522. this._T = Transition || this._T || (this.is(FADE) ? Fade : Slide);
  2523. this._E = Extensions || this._E;
  2524. var Constructors = assign({}, ComponentConstructors, this._E, {
  2525. Transition: this._T
  2526. });
  2527. forOwn(Constructors, function (Component, key) {
  2528. var component = Component(_this, Components2, _this._o);
  2529. Components2[key] = component;
  2530. component.setup && component.setup();
  2531. });
  2532. forOwn(Components2, function (component) {
  2533. component.mount && component.mount();
  2534. });
  2535. this.emit(EVENT_MOUNTED);
  2536. addClass(this.root, CLASS_INITIALIZED);
  2537. state.set(IDLE);
  2538. this.emit(EVENT_READY);
  2539. return this;
  2540. };
  2541. _proto.sync = function sync(splide) {
  2542. this.splides.push({
  2543. splide: splide
  2544. });
  2545. splide.splides.push({
  2546. splide: this,
  2547. isParent: true
  2548. });
  2549. if (this.state.is(IDLE)) {
  2550. this._C.Sync.remount();
  2551. splide.Components.Sync.remount();
  2552. }
  2553. return this;
  2554. };
  2555. _proto.go = function go(control) {
  2556. this._C.Controller.go(control);
  2557. return this;
  2558. };
  2559. _proto.on = function on(events, callback) {
  2560. this.event.on(events, callback);
  2561. return this;
  2562. };
  2563. _proto.off = function off(events) {
  2564. this.event.off(events);
  2565. return this;
  2566. };
  2567. _proto.emit = function emit(event) {
  2568. var _this$event;
  2569. (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1)));
  2570. return this;
  2571. };
  2572. _proto.add = function add(slides, index) {
  2573. this._C.Slides.add(slides, index);
  2574. return this;
  2575. };
  2576. _proto.remove = function remove(matcher) {
  2577. this._C.Slides.remove(matcher);
  2578. return this;
  2579. };
  2580. _proto.is = function is(type) {
  2581. return this._o.type === type;
  2582. };
  2583. _proto.refresh = function refresh() {
  2584. this.emit(EVENT_REFRESH);
  2585. return this;
  2586. };
  2587. _proto.destroy = function destroy(completely) {
  2588. if (completely === void 0) {
  2589. completely = true;
  2590. }
  2591. var event = this.event,
  2592. state = this.state;
  2593. if (state.is(CREATED)) {
  2594. EventInterface(this).on(EVENT_READY, this.destroy.bind(this, completely));
  2595. } else {
  2596. forOwn(this._C, function (component) {
  2597. component.destroy && component.destroy(completely);
  2598. }, true);
  2599. event.emit(EVENT_DESTROY);
  2600. event.destroy();
  2601. completely && empty(this.splides);
  2602. state.set(DESTROYED);
  2603. }
  2604. return this;
  2605. };
  2606. _createClass(_Splide, [{
  2607. key: "options",
  2608. get: function get() {
  2609. return this._o;
  2610. },
  2611. set: function set(options) {
  2612. this._C.Media.set(options, true);
  2613. }
  2614. }, {
  2615. key: "length",
  2616. get: function get() {
  2617. return this._C.Slides.getLength(true);
  2618. }
  2619. }, {
  2620. key: "index",
  2621. get: function get() {
  2622. return this._C.Controller.getIndex();
  2623. }
  2624. }]);
  2625. return _Splide;
  2626. }();
  2627. var Splide = _Splide;
  2628. Splide.defaults = {};
  2629. Splide.STATES = STATES;
  2630. var CLASS_RENDERED = "is-rendered";
  2631. var RENDERER_DEFAULT_CONFIG = {
  2632. listTag: "ul",
  2633. slideTag: "li"
  2634. };
  2635. var Style = /*#__PURE__*/function () {
  2636. function Style(id, options) {
  2637. this.styles = {};
  2638. this.id = id;
  2639. this.options = options;
  2640. }
  2641. var _proto2 = Style.prototype;
  2642. _proto2.rule = function rule(selector, prop, value, breakpoint) {
  2643. breakpoint = breakpoint || "default";
  2644. var selectors = this.styles[breakpoint] = this.styles[breakpoint] || {};
  2645. var styles = selectors[selector] = selectors[selector] || {};
  2646. styles[prop] = value;
  2647. };
  2648. _proto2.build = function build() {
  2649. var _this2 = this;
  2650. var css = "";
  2651. if (this.styles.default) {
  2652. css += this.buildSelectors(this.styles.default);
  2653. }
  2654. Object.keys(this.styles).sort(function (n, m) {
  2655. return _this2.options.mediaQuery === "min" ? +n - +m : +m - +n;
  2656. }).forEach(function (breakpoint) {
  2657. if (breakpoint !== "default") {
  2658. css += "@media screen and (max-width: " + breakpoint + "px) {";
  2659. css += _this2.buildSelectors(_this2.styles[breakpoint]);
  2660. css += "}";
  2661. }
  2662. });
  2663. return css;
  2664. };
  2665. _proto2.buildSelectors = function buildSelectors(selectors) {
  2666. var _this3 = this;
  2667. var css = "";
  2668. forOwn(selectors, function (styles, selector) {
  2669. selector = ("#" + _this3.id + " " + selector).trim();
  2670. css += selector + " {";
  2671. forOwn(styles, function (value, prop) {
  2672. if (value || value === 0) {
  2673. css += prop + ": " + value + ";";
  2674. }
  2675. });
  2676. css += "}";
  2677. });
  2678. return css;
  2679. };
  2680. return Style;
  2681. }();
  2682. var SplideRenderer = /*#__PURE__*/function () {
  2683. function SplideRenderer(contents, options, config, defaults) {
  2684. this.slides = [];
  2685. this.options = {};
  2686. this.breakpoints = [];
  2687. merge(DEFAULTS, defaults || {});
  2688. merge(merge(this.options, DEFAULTS), options || {});
  2689. this.contents = contents;
  2690. this.config = assign({}, RENDERER_DEFAULT_CONFIG, config || {});
  2691. this.id = this.config.id || uniqueId("splide");
  2692. this.Style = new Style(this.id, this.options);
  2693. this.Direction = Direction(null, null, this.options);
  2694. assert(this.contents.length, "Provide at least 1 content.");
  2695. this.init();
  2696. }
  2697. SplideRenderer.clean = function clean(splide) {
  2698. var _EventInterface17 = EventInterface(splide),
  2699. on = _EventInterface17.on;
  2700. var root = splide.root;
  2701. var clones = queryAll(root, "." + CLASS_CLONE);
  2702. on(EVENT_MOUNTED, function () {
  2703. remove(child(root, "style"));
  2704. });
  2705. remove(clones);
  2706. };
  2707. var _proto3 = SplideRenderer.prototype;
  2708. _proto3.init = function init() {
  2709. this.parseBreakpoints();
  2710. this.initSlides();
  2711. this.registerRootStyles();
  2712. this.registerTrackStyles();
  2713. this.registerSlideStyles();
  2714. this.registerListStyles();
  2715. };
  2716. _proto3.initSlides = function initSlides() {
  2717. var _this4 = this;
  2718. push(this.slides, this.contents.map(function (content, index) {
  2719. content = isString(content) ? {
  2720. html: content
  2721. } : content;
  2722. content.styles = content.styles || {};
  2723. content.attrs = content.attrs || {};
  2724. _this4.cover(content);
  2725. var classes = _this4.options.classes.slide + " " + (index === 0 ? CLASS_ACTIVE : "");
  2726. assign(content.attrs, {
  2727. class: (classes + " " + (content.attrs.class || "")).trim(),
  2728. style: _this4.buildStyles(content.styles)
  2729. });
  2730. return content;
  2731. }));
  2732. if (this.isLoop()) {
  2733. this.generateClones(this.slides);
  2734. }
  2735. };
  2736. _proto3.registerRootStyles = function registerRootStyles() {
  2737. var _this5 = this;
  2738. this.breakpoints.forEach(function (_ref2) {
  2739. var width = _ref2[0],
  2740. options = _ref2[1];
  2741. _this5.Style.rule(" ", "max-width", unit(options.width), width);
  2742. });
  2743. };
  2744. _proto3.registerTrackStyles = function registerTrackStyles() {
  2745. var _this6 = this;
  2746. var Style2 = this.Style;
  2747. var selector = "." + CLASS_TRACK;
  2748. this.breakpoints.forEach(function (_ref3) {
  2749. var width = _ref3[0],
  2750. options = _ref3[1];
  2751. Style2.rule(selector, _this6.resolve("paddingLeft"), _this6.cssPadding(options, false), width);
  2752. Style2.rule(selector, _this6.resolve("paddingRight"), _this6.cssPadding(options, true), width);
  2753. Style2.rule(selector, "height", _this6.cssTrackHeight(options), width);
  2754. });
  2755. };
  2756. _proto3.registerListStyles = function registerListStyles() {
  2757. var _this7 = this;
  2758. var Style2 = this.Style;
  2759. var selector = "." + CLASS_LIST;
  2760. this.breakpoints.forEach(function (_ref4) {
  2761. var width = _ref4[0],
  2762. options = _ref4[1];
  2763. Style2.rule(selector, "transform", _this7.buildTranslate(options), width);
  2764. if (!_this7.cssSlideHeight(options)) {
  2765. Style2.rule(selector, "aspect-ratio", _this7.cssAspectRatio(options), width);
  2766. }
  2767. });
  2768. };
  2769. _proto3.registerSlideStyles = function registerSlideStyles() {
  2770. var _this8 = this;
  2771. var Style2 = this.Style;
  2772. var selector = "." + CLASS_SLIDE;
  2773. this.breakpoints.forEach(function (_ref5) {
  2774. var width = _ref5[0],
  2775. options = _ref5[1];
  2776. Style2.rule(selector, "width", _this8.cssSlideWidth(options), width);
  2777. Style2.rule(selector, "height", _this8.cssSlideHeight(options) || "100%", width);
  2778. Style2.rule(selector, _this8.resolve("marginRight"), unit(options.gap) || "0px", width);
  2779. Style2.rule(selector + " > img", "display", options.cover ? "none" : "inline", width);
  2780. });
  2781. };
  2782. _proto3.buildTranslate = function buildTranslate(options) {
  2783. var _this$Direction = this.Direction,
  2784. resolve = _this$Direction.resolve,
  2785. orient = _this$Direction.orient;
  2786. var values = [];
  2787. values.push(this.cssOffsetClones(options));
  2788. values.push(this.cssOffsetGaps(options));
  2789. if (this.isCenter(options)) {
  2790. values.push(this.buildCssValue(orient(-50), "%"));
  2791. values.push.apply(values, this.cssOffsetCenter(options));
  2792. }
  2793. return values.filter(Boolean).map(function (value) {
  2794. return "translate" + resolve("X") + "(" + value + ")";
  2795. }).join(" ");
  2796. };
  2797. _proto3.cssOffsetClones = function cssOffsetClones(options) {
  2798. var _this$Direction2 = this.Direction,
  2799. resolve = _this$Direction2.resolve,
  2800. orient = _this$Direction2.orient;
  2801. var cloneCount = this.getCloneCount();
  2802. if (this.isFixedWidth(options)) {
  2803. var _this$parseCssValue = this.parseCssValue(options[resolve("fixedWidth")]),
  2804. value = _this$parseCssValue.value,
  2805. unit2 = _this$parseCssValue.unit;
  2806. return this.buildCssValue(orient(value) * cloneCount, unit2);
  2807. }
  2808. var percent = 100 * cloneCount / options.perPage;
  2809. return orient(percent) + "%";
  2810. };
  2811. _proto3.cssOffsetCenter = function cssOffsetCenter(options) {
  2812. var _this$Direction3 = this.Direction,
  2813. resolve = _this$Direction3.resolve,
  2814. orient = _this$Direction3.orient;
  2815. if (this.isFixedWidth(options)) {
  2816. var _this$parseCssValue2 = this.parseCssValue(options[resolve("fixedWidth")]),
  2817. value = _this$parseCssValue2.value,
  2818. unit2 = _this$parseCssValue2.unit;
  2819. return [this.buildCssValue(orient(value / 2), unit2)];
  2820. }
  2821. var values = [];
  2822. var perPage = options.perPage,
  2823. gap = options.gap;
  2824. values.push(orient(50 / perPage) + "%");
  2825. if (gap) {
  2826. var _this$parseCssValue3 = this.parseCssValue(gap),
  2827. _value = _this$parseCssValue3.value,
  2828. _unit = _this$parseCssValue3.unit;
  2829. var gapOffset = (_value / perPage - _value) / 2;
  2830. values.push(this.buildCssValue(orient(gapOffset), _unit));
  2831. }
  2832. return values;
  2833. };
  2834. _proto3.cssOffsetGaps = function cssOffsetGaps(options) {
  2835. var cloneCount = this.getCloneCount();
  2836. if (cloneCount && options.gap) {
  2837. var orient = this.Direction.orient;
  2838. var _this$parseCssValue4 = this.parseCssValue(options.gap),
  2839. value = _this$parseCssValue4.value,
  2840. unit2 = _this$parseCssValue4.unit;
  2841. if (this.isFixedWidth(options)) {
  2842. return this.buildCssValue(orient(value * cloneCount), unit2);
  2843. }
  2844. var perPage = options.perPage;
  2845. var gaps = cloneCount / perPage;
  2846. return this.buildCssValue(orient(gaps * value), unit2);
  2847. }
  2848. return "";
  2849. };
  2850. _proto3.resolve = function resolve(prop) {
  2851. return camelToKebab(this.Direction.resolve(prop));
  2852. };
  2853. _proto3.cssPadding = function cssPadding(options, right) {
  2854. var padding = options.padding;
  2855. var prop = this.Direction.resolve(right ? "right" : "left", true);
  2856. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  2857. };
  2858. _proto3.cssTrackHeight = function cssTrackHeight(options) {
  2859. var height = "";
  2860. if (this.isVertical()) {
  2861. height = this.cssHeight(options);
  2862. assert(height, '"height" is missing.');
  2863. height = "calc(" + height + " - " + this.cssPadding(options, false) + " - " + this.cssPadding(options, true) + ")";
  2864. }
  2865. return height;
  2866. };
  2867. _proto3.cssHeight = function cssHeight(options) {
  2868. return unit(options.height);
  2869. };
  2870. _proto3.cssSlideWidth = function cssSlideWidth(options) {
  2871. return options.autoWidth ? "" : unit(options.fixedWidth) || (this.isVertical() ? "" : this.cssSlideSize(options));
  2872. };
  2873. _proto3.cssSlideHeight = function cssSlideHeight(options) {
  2874. return unit(options.fixedHeight) || (this.isVertical() ? options.autoHeight ? "" : this.cssSlideSize(options) : this.cssHeight(options));
  2875. };
  2876. _proto3.cssSlideSize = function cssSlideSize(options) {
  2877. var gap = unit(options.gap);
  2878. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  2879. };
  2880. _proto3.cssAspectRatio = function cssAspectRatio(options) {
  2881. var heightRatio = options.heightRatio;
  2882. return heightRatio ? "" + 1 / heightRatio : "";
  2883. };
  2884. _proto3.buildCssValue = function buildCssValue(value, unit2) {
  2885. return "" + value + unit2;
  2886. };
  2887. _proto3.parseCssValue = function parseCssValue(value) {
  2888. if (isString(value)) {
  2889. var number = parseFloat(value) || 0;
  2890. var unit2 = value.replace(/\d*(\.\d*)?/, "") || "px";
  2891. return {
  2892. value: number,
  2893. unit: unit2
  2894. };
  2895. }
  2896. return {
  2897. value: value,
  2898. unit: "px"
  2899. };
  2900. };
  2901. _proto3.parseBreakpoints = function parseBreakpoints() {
  2902. var _this9 = this;
  2903. var breakpoints = this.options.breakpoints;
  2904. this.breakpoints.push(["default", this.options]);
  2905. if (breakpoints) {
  2906. forOwn(breakpoints, function (options, width) {
  2907. _this9.breakpoints.push([width, merge(merge({}, _this9.options), options)]);
  2908. });
  2909. }
  2910. };
  2911. _proto3.isFixedWidth = function isFixedWidth(options) {
  2912. return !!options[this.Direction.resolve("fixedWidth")];
  2913. };
  2914. _proto3.isLoop = function isLoop() {
  2915. return this.options.type === LOOP;
  2916. };
  2917. _proto3.isCenter = function isCenter(options) {
  2918. if (options.focus === "center") {
  2919. if (this.isLoop()) {
  2920. return true;
  2921. }
  2922. if (this.options.type === SLIDE) {
  2923. return !this.options.trimSpace;
  2924. }
  2925. }
  2926. return false;
  2927. };
  2928. _proto3.isVertical = function isVertical() {
  2929. return this.options.direction === TTB;
  2930. };
  2931. _proto3.buildClasses = function buildClasses() {
  2932. var options = this.options;
  2933. return [CLASS_ROOT, CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE, !this.config.hidden && CLASS_RENDERED].filter(Boolean).join(" ");
  2934. };
  2935. _proto3.buildAttrs = function buildAttrs(attrs) {
  2936. var attr = "";
  2937. forOwn(attrs, function (value, key) {
  2938. attr += value ? " " + camelToKebab(key) + "=\"" + value + "\"" : "";
  2939. });
  2940. return attr.trim();
  2941. };
  2942. _proto3.buildStyles = function buildStyles(styles) {
  2943. var style = "";
  2944. forOwn(styles, function (value, key) {
  2945. style += " " + camelToKebab(key) + ":" + value + ";";
  2946. });
  2947. return style.trim();
  2948. };
  2949. _proto3.renderSlides = function renderSlides() {
  2950. var _this10 = this;
  2951. var tag = this.config.slideTag;
  2952. return this.slides.map(function (content) {
  2953. return "<" + tag + " " + _this10.buildAttrs(content.attrs) + ">" + (content.html || "") + "</" + tag + ">";
  2954. }).join("");
  2955. };
  2956. _proto3.cover = function cover(content) {
  2957. var styles = content.styles,
  2958. _content$html = content.html,
  2959. html = _content$html === void 0 ? "" : _content$html;
  2960. if (this.options.cover && !this.options.lazyLoad) {
  2961. var src = html.match(/<img.*?src\s*=\s*(['"])(.+?)\1.*?>/);
  2962. if (src && src[2]) {
  2963. styles.background = "center/cover no-repeat url('" + src[2] + "')";
  2964. }
  2965. }
  2966. };
  2967. _proto3.generateClones = function generateClones(contents) {
  2968. var classes = this.options.classes;
  2969. var count = this.getCloneCount();
  2970. var slides = contents.slice();
  2971. while (slides.length < count) {
  2972. push(slides, slides);
  2973. }
  2974. push(slides.slice(-count).reverse(), slides.slice(0, count)).forEach(function (content, index) {
  2975. var attrs = assign({}, content.attrs, {
  2976. class: content.attrs.class + " " + classes.clone
  2977. });
  2978. var clone = assign({}, content, {
  2979. attrs: attrs
  2980. });
  2981. index < count ? contents.unshift(clone) : contents.push(clone);
  2982. });
  2983. };
  2984. _proto3.getCloneCount = function getCloneCount() {
  2985. if (this.isLoop()) {
  2986. var options = this.options;
  2987. if (options.clones) {
  2988. return options.clones;
  2989. }
  2990. var perPage = max.apply(void 0, this.breakpoints.map(function (_ref6) {
  2991. var options2 = _ref6[1];
  2992. return options2.perPage;
  2993. }));
  2994. return perPage * ((options.flickMaxPages || 1) + 1);
  2995. }
  2996. return 0;
  2997. };
  2998. _proto3.renderArrows = function renderArrows() {
  2999. var html = "";
  3000. html += "<div class=\"" + this.options.classes.arrows + "\">";
  3001. html += this.renderArrow(true);
  3002. html += this.renderArrow(false);
  3003. html += "</div>";
  3004. return html;
  3005. };
  3006. _proto3.renderArrow = function renderArrow(prev) {
  3007. var _this$options = this.options,
  3008. classes = _this$options.classes,
  3009. i18n = _this$options.i18n;
  3010. var attrs = {
  3011. class: classes.arrow + " " + (prev ? classes.prev : classes.next),
  3012. type: "button",
  3013. ariaLabel: prev ? i18n.prev : i18n.next
  3014. };
  3015. return "<button " + this.buildAttrs(attrs) + "><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\"><path d=\"" + (this.options.arrowPath || PATH) + "\" /></svg></button>";
  3016. };
  3017. _proto3.html = function html() {
  3018. var _this$config = this.config,
  3019. rootClass = _this$config.rootClass,
  3020. listTag = _this$config.listTag,
  3021. arrows = _this$config.arrows,
  3022. beforeTrack = _this$config.beforeTrack,
  3023. afterTrack = _this$config.afterTrack,
  3024. slider = _this$config.slider,
  3025. beforeSlider = _this$config.beforeSlider,
  3026. afterSlider = _this$config.afterSlider;
  3027. var html = "";
  3028. html += "<div id=\"" + this.id + "\" class=\"" + this.buildClasses() + " " + (rootClass || "") + "\">";
  3029. html += "<style>" + this.Style.build() + "</style>";
  3030. if (slider) {
  3031. html += beforeSlider || "";
  3032. html += "<div class=\"splide__slider\">";
  3033. }
  3034. html += beforeTrack || "";
  3035. if (arrows) {
  3036. html += this.renderArrows();
  3037. }
  3038. html += "<div class=\"splide__track\">";
  3039. html += "<" + listTag + " class=\"splide__list\">";
  3040. html += this.renderSlides();
  3041. html += "</" + listTag + ">";
  3042. html += "</div>";
  3043. html += afterTrack || "";
  3044. if (slider) {
  3045. html += "</div>";
  3046. html += afterSlider || "";
  3047. }
  3048. html += "</div>";
  3049. return html;
  3050. };
  3051. return SplideRenderer;
  3052. }();
  3053. export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, DEFAULTS, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, EventBinder, EventInterface, FADE, LOOP, LTR, RTL, RequestInterval, SLIDE, STATUS_CLASSES, Splide, SplideRenderer, State, TTB, Throttle, Splide as default };