splide.cjs.js 96 KB

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