splide.esm.js 93 KB

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