splide.esm.js 95 KB

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