splide.cjs.js 95 KB

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