splide.cjs.js 94 KB

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