splide.esm.js 93 KB

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