splide.esm.js 93 KB

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