splide.esm.js 94 KB

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