splide.esm.js 95 KB

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