splide.cjs.js 94 KB

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