itmar-block-packages 2.1.2 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +18 -4
  2. package/build/cjs/AnimationBlock.js +61 -92
  3. package/build/cjs/AnimationBlock.js.map +1 -1
  4. package/build/cjs/BlockEditWrapper.js +3 -10
  5. package/build/cjs/BlockEditWrapper.js.map +1 -1
  6. package/build/cjs/BlockPlace.js +277 -482
  7. package/build/cjs/BlockPlace.js.map +1 -1
  8. package/build/cjs/BrockInserter.js +195 -191
  9. package/build/cjs/BrockInserter.js.map +1 -1
  10. package/build/cjs/DateElm.js +254 -281
  11. package/build/cjs/DateElm.js.map +1 -1
  12. package/build/cjs/DraggableBox.js +99 -129
  13. package/build/cjs/DraggableBox.js.map +1 -1
  14. package/build/cjs/GridControls.js +292 -392
  15. package/build/cjs/GridControls.js.map +1 -1
  16. package/build/cjs/IconSelectControl.js +65 -156
  17. package/build/cjs/IconSelectControl.js.map +1 -1
  18. package/build/cjs/JapaneseHolidays.js +67 -76
  19. package/build/cjs/JapaneseHolidays.js.map +1 -1
  20. package/build/cjs/MasonryControl.js +95 -100
  21. package/build/cjs/MasonryControl.js.map +1 -1
  22. package/build/cjs/PseudoElm.js +37 -50
  23. package/build/cjs/PseudoElm.js.map +1 -1
  24. package/build/cjs/ShadowStyle.js +216 -430
  25. package/build/cjs/ShadowStyle.js.map +1 -1
  26. package/build/cjs/SwiperControl.js +240 -241
  27. package/build/cjs/SwiperControl.js.map +1 -1
  28. package/build/cjs/ToggleElement.js +17 -9
  29. package/build/cjs/ToggleElement.js.map +1 -1
  30. package/build/cjs/TypographyControls.js +73 -139
  31. package/build/cjs/TypographyControls.js.map +1 -1
  32. package/build/cjs/UpdateAllPostsBlockAttributes.js +102 -119
  33. package/build/cjs/UpdateAllPostsBlockAttributes.js.map +1 -1
  34. package/build/cjs/ZipAddress.js +27 -23
  35. package/build/cjs/ZipAddress.js.map +1 -1
  36. package/build/cjs/blockStore.js +42 -47
  37. package/build/cjs/blockStore.js.map +1 -1
  38. package/build/cjs/cssPropertes.js +165 -117
  39. package/build/cjs/cssPropertes.js.map +1 -1
  40. package/build/cjs/customHooks.js +277 -0
  41. package/build/cjs/customHooks.js.map +1 -0
  42. package/build/cjs/formatCreate.js +115 -145
  43. package/build/cjs/formatCreate.js.map +1 -1
  44. package/build/cjs/hslToRgb.js +112 -116
  45. package/build/cjs/hslToRgb.js.map +1 -1
  46. package/build/cjs/index.js +15 -11
  47. package/build/cjs/index.js.map +1 -1
  48. package/build/cjs/mediaUpload.js +95 -158
  49. package/build/cjs/mediaUpload.js.map +1 -1
  50. package/build/cjs/node_modules/swiper/shared/ssr-window.esm.js +144 -0
  51. package/build/cjs/node_modules/swiper/shared/ssr-window.esm.js.map +1 -0
  52. package/build/cjs/node_modules/swiper/shared/swiper-core.js +3925 -0
  53. package/build/cjs/node_modules/swiper/shared/swiper-core.js.map +1 -0
  54. package/build/cjs/node_modules/swiper/shared/utils.js +294 -0
  55. package/build/cjs/node_modules/swiper/shared/utils.js.map +1 -0
  56. package/build/cjs/pickupStore.js +56 -54
  57. package/build/cjs/pickupStore.js.map +1 -1
  58. package/build/cjs/shopfiApi.js +127 -138
  59. package/build/cjs/shopfiApi.js.map +1 -1
  60. package/build/cjs/types/AnimationBlock.d.ts +22 -0
  61. package/build/cjs/types/BlockEditWrapper.d.ts +7 -0
  62. package/build/cjs/types/BlockPlace.d.ts +49 -0
  63. package/build/cjs/types/BrockInserter.d.ts +6 -0
  64. package/build/cjs/types/DateElm.d.ts +69 -0
  65. package/build/cjs/types/DraggableBox.d.ts +19 -0
  66. package/build/cjs/types/GridControls.d.ts +27 -0
  67. package/build/cjs/types/IconSelectControl.d.ts +17 -0
  68. package/build/cjs/types/JapaneseHolidays.d.ts +6 -0
  69. package/build/cjs/types/MasonryControl.d.ts +35 -0
  70. package/build/cjs/types/PseudoElm.d.ts +11 -0
  71. package/build/cjs/types/ShadowStyle.d.ts +33 -0
  72. package/build/cjs/types/SwiperControl.d.ts +12 -0
  73. package/build/cjs/types/ToggleElement.d.ts +13 -0
  74. package/build/cjs/types/TypographyControls.d.ts +17 -0
  75. package/build/cjs/types/UpdateAllPostsBlockAttributes.d.ts +10 -0
  76. package/build/cjs/types/ZipAddress.d.ts +18 -0
  77. package/build/cjs/types/blockStore.d.ts +15 -0
  78. package/build/cjs/types/cssPropertes.d.ts +53 -0
  79. package/build/cjs/types/customHooks.d.ts +11 -0
  80. package/build/cjs/types/formatCreate.d.ts +18 -0
  81. package/build/cjs/types/hslToRgb.d.ts +23 -0
  82. package/build/cjs/types/index.d.ts +31 -0
  83. package/build/cjs/types/mediaUpload.d.ts +29 -0
  84. package/build/cjs/types/pickupStore.d.ts +39 -0
  85. package/build/cjs/types/shopfiApi.d.ts +18 -0
  86. package/build/cjs/types/validationCheck.d.ts +5 -0
  87. package/build/cjs/types/wordpressApi.d.ts +99 -0
  88. package/build/cjs/validationCheck.js +15 -9
  89. package/build/cjs/validationCheck.js.map +1 -1
  90. package/build/cjs/wordpressApi.js +364 -576
  91. package/build/cjs/wordpressApi.js.map +1 -1
  92. package/build/esm/AnimationBlock.d.ts +22 -0
  93. package/build/esm/AnimationBlock.js +61 -92
  94. package/build/esm/AnimationBlock.js.map +1 -1
  95. package/build/esm/BlockEditWrapper.d.ts +7 -0
  96. package/build/esm/BlockEditWrapper.js +4 -11
  97. package/build/esm/BlockEditWrapper.js.map +1 -1
  98. package/build/esm/BlockPlace.d.ts +49 -0
  99. package/build/esm/BlockPlace.js +279 -484
  100. package/build/esm/BlockPlace.js.map +1 -1
  101. package/build/esm/BrockInserter.d.ts +6 -0
  102. package/build/esm/BrockInserter.js +195 -191
  103. package/build/esm/BrockInserter.js.map +1 -1
  104. package/build/esm/DateElm.d.ts +69 -0
  105. package/build/esm/DateElm.js +254 -281
  106. package/build/esm/DateElm.js.map +1 -1
  107. package/build/esm/DraggableBox.d.ts +19 -0
  108. package/build/esm/DraggableBox.js +99 -129
  109. package/build/esm/DraggableBox.js.map +1 -1
  110. package/build/esm/GridControls.d.ts +27 -0
  111. package/build/esm/GridControls.js +294 -394
  112. package/build/esm/GridControls.js.map +1 -1
  113. package/build/esm/IconSelectControl.d.ts +17 -0
  114. package/build/esm/IconSelectControl.js +65 -156
  115. package/build/esm/IconSelectControl.js.map +1 -1
  116. package/build/esm/JapaneseHolidays.d.ts +6 -0
  117. package/build/esm/JapaneseHolidays.js +67 -76
  118. package/build/esm/JapaneseHolidays.js.map +1 -1
  119. package/build/esm/MasonryControl.d.ts +35 -0
  120. package/build/esm/MasonryControl.js +95 -100
  121. package/build/esm/MasonryControl.js.map +1 -1
  122. package/build/esm/PseudoElm.d.ts +11 -0
  123. package/build/esm/PseudoElm.js +37 -50
  124. package/build/esm/PseudoElm.js.map +1 -1
  125. package/build/esm/ShadowStyle.d.ts +33 -0
  126. package/build/esm/ShadowStyle.js +217 -431
  127. package/build/esm/ShadowStyle.js.map +1 -1
  128. package/build/esm/SwiperControl.d.ts +12 -0
  129. package/build/esm/SwiperControl.js +240 -241
  130. package/build/esm/SwiperControl.js.map +1 -1
  131. package/build/esm/ToggleElement.d.ts +13 -0
  132. package/build/esm/ToggleElement.js +17 -9
  133. package/build/esm/ToggleElement.js.map +1 -1
  134. package/build/esm/TypographyControls.d.ts +17 -0
  135. package/build/esm/TypographyControls.js +73 -139
  136. package/build/esm/TypographyControls.js.map +1 -1
  137. package/build/esm/UpdateAllPostsBlockAttributes.d.ts +10 -0
  138. package/build/esm/UpdateAllPostsBlockAttributes.js +103 -120
  139. package/build/esm/UpdateAllPostsBlockAttributes.js.map +1 -1
  140. package/build/esm/ZipAddress.d.ts +18 -0
  141. package/build/esm/ZipAddress.js +27 -23
  142. package/build/esm/ZipAddress.js.map +1 -1
  143. package/build/esm/blockStore.d.ts +15 -0
  144. package/build/esm/blockStore.js +42 -47
  145. package/build/esm/blockStore.js.map +1 -1
  146. package/build/esm/cssPropertes.d.ts +53 -0
  147. package/build/esm/cssPropertes.js +165 -117
  148. package/build/esm/cssPropertes.js.map +1 -1
  149. package/build/esm/customHooks.d.ts +11 -0
  150. package/build/esm/customHooks.js +267 -0
  151. package/build/esm/customHooks.js.map +1 -0
  152. package/build/esm/formatCreate.d.ts +18 -0
  153. package/build/esm/formatCreate.js +115 -145
  154. package/build/esm/formatCreate.js.map +1 -1
  155. package/build/esm/hslToRgb.d.ts +23 -0
  156. package/build/esm/hslToRgb.js +112 -116
  157. package/build/esm/hslToRgb.js.map +1 -1
  158. package/build/esm/index.d.ts +27 -0
  159. package/build/esm/index.js +8 -1
  160. package/build/esm/index.js.map +1 -1
  161. package/build/esm/mediaUpload.d.ts +29 -0
  162. package/build/esm/mediaUpload.js +95 -158
  163. package/build/esm/mediaUpload.js.map +1 -1
  164. package/build/esm/node_modules/swiper/shared/ssr-window.esm.js +141 -0
  165. package/build/esm/node_modules/swiper/shared/ssr-window.esm.js.map +1 -0
  166. package/build/esm/node_modules/swiper/shared/swiper-core.js +3922 -0
  167. package/build/esm/node_modules/swiper/shared/swiper-core.js.map +1 -0
  168. package/build/esm/node_modules/swiper/shared/utils.js +274 -0
  169. package/build/esm/node_modules/swiper/shared/utils.js.map +1 -0
  170. package/build/esm/pickupStore.d.ts +39 -0
  171. package/build/esm/pickupStore.js +56 -54
  172. package/build/esm/pickupStore.js.map +1 -1
  173. package/build/esm/shopfiApi.d.ts +18 -0
  174. package/build/esm/shopfiApi.js +127 -138
  175. package/build/esm/shopfiApi.js.map +1 -1
  176. package/build/esm/types/AnimationBlock.d.ts +22 -0
  177. package/build/esm/types/BlockEditWrapper.d.ts +7 -0
  178. package/build/esm/types/BlockPlace.d.ts +49 -0
  179. package/build/esm/types/BrockInserter.d.ts +6 -0
  180. package/build/esm/types/DateElm.d.ts +69 -0
  181. package/build/esm/types/DraggableBox.d.ts +19 -0
  182. package/build/esm/types/GridControls.d.ts +27 -0
  183. package/build/esm/types/IconSelectControl.d.ts +17 -0
  184. package/build/esm/types/JapaneseHolidays.d.ts +6 -0
  185. package/build/esm/types/MasonryControl.d.ts +35 -0
  186. package/build/esm/types/PseudoElm.d.ts +11 -0
  187. package/build/esm/types/ShadowStyle.d.ts +33 -0
  188. package/build/esm/types/SwiperControl.d.ts +12 -0
  189. package/build/esm/types/ToggleElement.d.ts +13 -0
  190. package/build/esm/types/TypographyControls.d.ts +17 -0
  191. package/build/esm/types/UpdateAllPostsBlockAttributes.d.ts +10 -0
  192. package/build/esm/types/ZipAddress.d.ts +18 -0
  193. package/build/esm/types/blockStore.d.ts +15 -0
  194. package/build/esm/types/cssPropertes.d.ts +53 -0
  195. package/build/esm/types/customHooks.d.ts +11 -0
  196. package/build/esm/types/formatCreate.d.ts +18 -0
  197. package/build/esm/types/hslToRgb.d.ts +23 -0
  198. package/build/esm/types/index.d.ts +31 -0
  199. package/build/esm/types/mediaUpload.d.ts +29 -0
  200. package/build/esm/types/pickupStore.d.ts +39 -0
  201. package/build/esm/types/shopfiApi.d.ts +18 -0
  202. package/build/esm/types/validationCheck.d.ts +5 -0
  203. package/build/esm/types/wordpressApi.d.ts +99 -0
  204. package/build/esm/validationCheck.d.ts +5 -0
  205. package/build/esm/validationCheck.js +15 -9
  206. package/build/esm/validationCheck.js.map +1 -1
  207. package/build/esm/wordpressApi.d.ts +99 -0
  208. package/build/esm/wordpressApi.js +365 -577
  209. package/build/esm/wordpressApi.js.map +1 -1
  210. package/package.json +29 -7
  211. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -117
  212. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  213. package/build/cjs/customFooks.js +0 -300
  214. package/build/cjs/customFooks.js.map +0 -1
  215. package/build/esm/_virtual/_rollupPluginBabelHelpers.js +0 -107
  216. package/build/esm/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  217. package/build/esm/customFooks.js +0 -290
  218. package/build/esm/customFooks.js.map +0 -1
@@ -0,0 +1,3922 @@
1
+ import { a as getWindow, g as getDocument } from './ssr-window.esm.js';
2
+ import { x as extend, v as showWarning, e as elementChildren, n as nextTick, u as animateCSSModeScroll, l as getTranslate, r as elementNextAll, t as elementPrevAll, b as setCSSProperty, q as elementStyle, i as elementOuterSize, j as elementIndex, c as createElement, y as deleteProps, w as elementIsChildOf, h as now, d as elementParents } from './utils.js';
3
+
4
+ let support;
5
+ function calcSupport() {
6
+ const window = getWindow();
7
+ const document = getDocument();
8
+ return {
9
+ smoothScroll: document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style,
10
+ touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
11
+ };
12
+ }
13
+ function getSupport() {
14
+ if (!support) {
15
+ support = calcSupport();
16
+ }
17
+ return support;
18
+ }
19
+
20
+ let deviceCached;
21
+ function calcDevice({
22
+ userAgent
23
+ } = {}) {
24
+ const support = getSupport();
25
+ const window = getWindow();
26
+ const platform = window.navigator.platform;
27
+ const ua = userAgent || window.navigator.userAgent;
28
+ const device = {
29
+ ios: false,
30
+ android: false
31
+ };
32
+ const screenWidth = window.screen.width;
33
+ const screenHeight = window.screen.height;
34
+ const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
35
+ let ipad = ua.match(/(iPad)(?!\1).*OS\s([\d_]+)/);
36
+ const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
37
+ const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
38
+ const windows = platform === 'Win32';
39
+ let macos = platform === 'MacIntel';
40
+
41
+ // iPadOs 13 fix
42
+ const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
43
+ if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
44
+ ipad = ua.match(/(Version)\/([\d.]+)/);
45
+ if (!ipad) ipad = [0, 1, '13_0_0'];
46
+ macos = false;
47
+ }
48
+
49
+ // Android
50
+ if (android && !windows) {
51
+ device.os = 'android';
52
+ device.android = true;
53
+ }
54
+ if (ipad || iphone || ipod) {
55
+ device.os = 'ios';
56
+ device.ios = true;
57
+ }
58
+
59
+ // Export object
60
+ return device;
61
+ }
62
+ function getDevice(overrides = {}) {
63
+ if (!deviceCached) {
64
+ deviceCached = calcDevice(overrides);
65
+ }
66
+ return deviceCached;
67
+ }
68
+
69
+ let browser;
70
+ function calcBrowser() {
71
+ const window = getWindow();
72
+ const device = getDevice();
73
+ let needPerspectiveFix = false;
74
+ function isSafari() {
75
+ const ua = window.navigator.userAgent.toLowerCase();
76
+ return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
77
+ }
78
+ if (isSafari()) {
79
+ const ua = String(window.navigator.userAgent);
80
+ if (ua.includes('Version/')) {
81
+ const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
82
+ needPerspectiveFix = major < 16 || major === 16 && minor < 2;
83
+ }
84
+ }
85
+ const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent);
86
+ const isSafariBrowser = isSafari();
87
+ const need3dFix = isSafariBrowser || isWebView && device.ios;
88
+ return {
89
+ isSafari: needPerspectiveFix || isSafariBrowser,
90
+ needPerspectiveFix,
91
+ need3dFix,
92
+ isWebView
93
+ };
94
+ }
95
+ function getBrowser() {
96
+ if (!browser) {
97
+ browser = calcBrowser();
98
+ }
99
+ return browser;
100
+ }
101
+
102
+ function Resize({
103
+ swiper,
104
+ on,
105
+ emit
106
+ }) {
107
+ const window = getWindow();
108
+ let observer = null;
109
+ let animationFrame = null;
110
+ const resizeHandler = () => {
111
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
112
+ emit('beforeResize');
113
+ emit('resize');
114
+ };
115
+ const createObserver = () => {
116
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
117
+ observer = new ResizeObserver(entries => {
118
+ animationFrame = window.requestAnimationFrame(() => {
119
+ const {
120
+ width,
121
+ height
122
+ } = swiper;
123
+ let newWidth = width;
124
+ let newHeight = height;
125
+ entries.forEach(({
126
+ contentBoxSize,
127
+ contentRect,
128
+ target
129
+ }) => {
130
+ if (target && target !== swiper.el) return;
131
+ newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
132
+ newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
133
+ });
134
+ if (newWidth !== width || newHeight !== height) {
135
+ resizeHandler();
136
+ }
137
+ });
138
+ });
139
+ observer.observe(swiper.el);
140
+ };
141
+ const removeObserver = () => {
142
+ if (animationFrame) {
143
+ window.cancelAnimationFrame(animationFrame);
144
+ }
145
+ if (observer && observer.unobserve && swiper.el) {
146
+ observer.unobserve(swiper.el);
147
+ observer = null;
148
+ }
149
+ };
150
+ const orientationChangeHandler = () => {
151
+ if (!swiper || swiper.destroyed || !swiper.initialized) return;
152
+ emit('orientationchange');
153
+ };
154
+ on('init', () => {
155
+ if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
156
+ createObserver();
157
+ return;
158
+ }
159
+ window.addEventListener('resize', resizeHandler);
160
+ window.addEventListener('orientationchange', orientationChangeHandler);
161
+ });
162
+ on('destroy', () => {
163
+ removeObserver();
164
+ window.removeEventListener('resize', resizeHandler);
165
+ window.removeEventListener('orientationchange', orientationChangeHandler);
166
+ });
167
+ }
168
+
169
+ function Observer({
170
+ swiper,
171
+ extendParams,
172
+ on,
173
+ emit
174
+ }) {
175
+ const observers = [];
176
+ const window = getWindow();
177
+ const attach = (target, options = {}) => {
178
+ const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
179
+ const observer = new ObserverFunc(mutations => {
180
+ // The observerUpdate event should only be triggered
181
+ // once despite the number of mutations. Additional
182
+ // triggers are redundant and are very costly
183
+ if (swiper.__preventObserver__) return;
184
+ if (mutations.length === 1) {
185
+ emit('observerUpdate', mutations[0]);
186
+ return;
187
+ }
188
+ const observerUpdate = function observerUpdate() {
189
+ emit('observerUpdate', mutations[0]);
190
+ };
191
+ if (window.requestAnimationFrame) {
192
+ window.requestAnimationFrame(observerUpdate);
193
+ } else {
194
+ window.setTimeout(observerUpdate, 0);
195
+ }
196
+ });
197
+ observer.observe(target, {
198
+ attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
199
+ childList: swiper.isElement || (typeof options.childList === 'undefined' ? true : options).childList,
200
+ characterData: typeof options.characterData === 'undefined' ? true : options.characterData
201
+ });
202
+ observers.push(observer);
203
+ };
204
+ const init = () => {
205
+ if (!swiper.params.observer) return;
206
+ if (swiper.params.observeParents) {
207
+ const containerParents = elementParents(swiper.hostEl);
208
+ for (let i = 0; i < containerParents.length; i += 1) {
209
+ attach(containerParents[i]);
210
+ }
211
+ }
212
+ // Observe container
213
+ attach(swiper.hostEl, {
214
+ childList: swiper.params.observeSlideChildren
215
+ });
216
+
217
+ // Observe wrapper
218
+ attach(swiper.wrapperEl, {
219
+ attributes: false
220
+ });
221
+ };
222
+ const destroy = () => {
223
+ observers.forEach(observer => {
224
+ observer.disconnect();
225
+ });
226
+ observers.splice(0, observers.length);
227
+ };
228
+ extendParams({
229
+ observer: false,
230
+ observeParents: false,
231
+ observeSlideChildren: false
232
+ });
233
+ on('init', init);
234
+ on('destroy', destroy);
235
+ }
236
+
237
+ /* eslint-disable no-underscore-dangle */
238
+
239
+ var eventsEmitter = {
240
+ on(events, handler, priority) {
241
+ const self = this;
242
+ if (!self.eventsListeners || self.destroyed) return self;
243
+ if (typeof handler !== 'function') return self;
244
+ const method = priority ? 'unshift' : 'push';
245
+ events.split(' ').forEach(event => {
246
+ if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
247
+ self.eventsListeners[event][method](handler);
248
+ });
249
+ return self;
250
+ },
251
+ once(events, handler, priority) {
252
+ const self = this;
253
+ if (!self.eventsListeners || self.destroyed) return self;
254
+ if (typeof handler !== 'function') return self;
255
+ function onceHandler(...args) {
256
+ self.off(events, onceHandler);
257
+ if (onceHandler.__emitterProxy) {
258
+ delete onceHandler.__emitterProxy;
259
+ }
260
+ handler.apply(self, args);
261
+ }
262
+ onceHandler.__emitterProxy = handler;
263
+ return self.on(events, onceHandler, priority);
264
+ },
265
+ onAny(handler, priority) {
266
+ const self = this;
267
+ if (!self.eventsListeners || self.destroyed) return self;
268
+ if (typeof handler !== 'function') return self;
269
+ const method = priority ? 'unshift' : 'push';
270
+ if (self.eventsAnyListeners.indexOf(handler) < 0) {
271
+ self.eventsAnyListeners[method](handler);
272
+ }
273
+ return self;
274
+ },
275
+ offAny(handler) {
276
+ const self = this;
277
+ if (!self.eventsListeners || self.destroyed) return self;
278
+ if (!self.eventsAnyListeners) return self;
279
+ const index = self.eventsAnyListeners.indexOf(handler);
280
+ if (index >= 0) {
281
+ self.eventsAnyListeners.splice(index, 1);
282
+ }
283
+ return self;
284
+ },
285
+ off(events, handler) {
286
+ const self = this;
287
+ if (!self.eventsListeners || self.destroyed) return self;
288
+ if (!self.eventsListeners) return self;
289
+ events.split(' ').forEach(event => {
290
+ if (typeof handler === 'undefined') {
291
+ self.eventsListeners[event] = [];
292
+ } else if (self.eventsListeners[event]) {
293
+ self.eventsListeners[event].forEach((eventHandler, index) => {
294
+ if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
295
+ self.eventsListeners[event].splice(index, 1);
296
+ }
297
+ });
298
+ }
299
+ });
300
+ return self;
301
+ },
302
+ emit(...args) {
303
+ const self = this;
304
+ if (!self.eventsListeners || self.destroyed) return self;
305
+ if (!self.eventsListeners) return self;
306
+ let events;
307
+ let data;
308
+ let context;
309
+ if (typeof args[0] === 'string' || Array.isArray(args[0])) {
310
+ events = args[0];
311
+ data = args.slice(1, args.length);
312
+ context = self;
313
+ } else {
314
+ events = args[0].events;
315
+ data = args[0].data;
316
+ context = args[0].context || self;
317
+ }
318
+ data.unshift(context);
319
+ const eventsArray = Array.isArray(events) ? events : events.split(' ');
320
+ eventsArray.forEach(event => {
321
+ if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
322
+ self.eventsAnyListeners.forEach(eventHandler => {
323
+ eventHandler.apply(context, [event, ...data]);
324
+ });
325
+ }
326
+ if (self.eventsListeners && self.eventsListeners[event]) {
327
+ self.eventsListeners[event].forEach(eventHandler => {
328
+ eventHandler.apply(context, data);
329
+ });
330
+ }
331
+ });
332
+ return self;
333
+ }
334
+ };
335
+
336
+ function updateSize() {
337
+ const swiper = this;
338
+ let width;
339
+ let height;
340
+ const el = swiper.el;
341
+ if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
342
+ width = swiper.params.width;
343
+ } else {
344
+ width = el.clientWidth;
345
+ }
346
+ if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
347
+ height = swiper.params.height;
348
+ } else {
349
+ height = el.clientHeight;
350
+ }
351
+ if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
352
+ return;
353
+ }
354
+
355
+ // Subtract paddings
356
+ width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
357
+ height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
358
+ if (Number.isNaN(width)) width = 0;
359
+ if (Number.isNaN(height)) height = 0;
360
+ Object.assign(swiper, {
361
+ width,
362
+ height,
363
+ size: swiper.isHorizontal() ? width : height
364
+ });
365
+ }
366
+
367
+ function updateSlides() {
368
+ const swiper = this;
369
+ function getDirectionPropertyValue(node, label) {
370
+ return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
371
+ }
372
+ const params = swiper.params;
373
+ const {
374
+ wrapperEl,
375
+ slidesEl,
376
+ rtlTranslate: rtl,
377
+ wrongRTL
378
+ } = swiper;
379
+ const isVirtual = swiper.virtual && params.virtual.enabled;
380
+ const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
381
+ const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
382
+ const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
383
+ let snapGrid = [];
384
+ const slidesGrid = [];
385
+ const slidesSizesGrid = [];
386
+ let offsetBefore = params.slidesOffsetBefore;
387
+ if (typeof offsetBefore === 'function') {
388
+ offsetBefore = params.slidesOffsetBefore.call(swiper);
389
+ }
390
+ let offsetAfter = params.slidesOffsetAfter;
391
+ if (typeof offsetAfter === 'function') {
392
+ offsetAfter = params.slidesOffsetAfter.call(swiper);
393
+ }
394
+ const previousSnapGridLength = swiper.snapGrid.length;
395
+ const previousSlidesGridLength = swiper.slidesGrid.length;
396
+ const swiperSize = swiper.size - offsetBefore - offsetAfter;
397
+ let spaceBetween = params.spaceBetween;
398
+ let slidePosition = -offsetBefore;
399
+ let prevSlideSize = 0;
400
+ let index = 0;
401
+ if (typeof swiperSize === 'undefined') {
402
+ return;
403
+ }
404
+ if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
405
+ spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
406
+ } else if (typeof spaceBetween === 'string') {
407
+ spaceBetween = parseFloat(spaceBetween);
408
+ }
409
+ swiper.virtualSize = -spaceBetween - offsetBefore - offsetAfter;
410
+
411
+ // reset margins
412
+ slides.forEach(slideEl => {
413
+ if (rtl) {
414
+ slideEl.style.marginLeft = '';
415
+ } else {
416
+ slideEl.style.marginRight = '';
417
+ }
418
+ slideEl.style.marginBottom = '';
419
+ slideEl.style.marginTop = '';
420
+ });
421
+
422
+ // reset cssMode offsets
423
+ if (params.centeredSlides && params.cssMode) {
424
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
425
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
426
+ }
427
+
428
+ // set cssMode offsets
429
+ if (params.cssMode) {
430
+ setCSSProperty(wrapperEl, '--swiper-slides-offset-before', `${offsetBefore}px`);
431
+ setCSSProperty(wrapperEl, '--swiper-slides-offset-after', `${offsetAfter}px`);
432
+ }
433
+ const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
434
+ if (gridEnabled) {
435
+ swiper.grid.initSlides(slides);
436
+ } else if (swiper.grid) {
437
+ swiper.grid.unsetSlides();
438
+ }
439
+
440
+ // Calc slides
441
+ let slideSize;
442
+ const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
443
+ return typeof params.breakpoints[key].slidesPerView !== 'undefined';
444
+ }).length > 0;
445
+ for (let i = 0; i < slidesLength; i += 1) {
446
+ slideSize = 0;
447
+ const slide = slides[i];
448
+ if (slide) {
449
+ if (gridEnabled) {
450
+ swiper.grid.updateSlide(i, slide, slides);
451
+ }
452
+ if (elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
453
+ }
454
+
455
+ if (isVirtual && params.slidesPerView === 'auto') {
456
+ if (params.virtual.slidesPerViewAutoSlideSize) {
457
+ slideSize = params.virtual.slidesPerViewAutoSlideSize;
458
+ }
459
+ if (slideSize && slide) {
460
+ if (params.roundLengths) slideSize = Math.floor(slideSize);
461
+ slide.style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
462
+ }
463
+ } else if (params.slidesPerView === 'auto') {
464
+ if (shouldResetSlideSize) {
465
+ slide.style[swiper.getDirectionLabel('width')] = ``;
466
+ }
467
+ const slideStyles = getComputedStyle(slide);
468
+ const currentTransform = slide.style.transform;
469
+ const currentWebKitTransform = slide.style.webkitTransform;
470
+ if (currentTransform) {
471
+ slide.style.transform = 'none';
472
+ }
473
+ if (currentWebKitTransform) {
474
+ slide.style.webkitTransform = 'none';
475
+ }
476
+ if (params.roundLengths) {
477
+ slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width') : elementOuterSize(slide, 'height');
478
+ } else {
479
+ // eslint-disable-next-line
480
+ const width = getDirectionPropertyValue(slideStyles, 'width');
481
+ const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
482
+ const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
483
+ const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
484
+ const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
485
+ const boxSizing = slideStyles.getPropertyValue('box-sizing');
486
+ if (boxSizing && boxSizing === 'border-box') {
487
+ slideSize = width + marginLeft + marginRight;
488
+ } else {
489
+ const {
490
+ clientWidth,
491
+ offsetWidth
492
+ } = slide;
493
+ slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
494
+ }
495
+ }
496
+ if (currentTransform) {
497
+ slide.style.transform = currentTransform;
498
+ }
499
+ if (currentWebKitTransform) {
500
+ slide.style.webkitTransform = currentWebKitTransform;
501
+ }
502
+ if (params.roundLengths) slideSize = Math.floor(slideSize);
503
+ } else {
504
+ slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
505
+ if (params.roundLengths) slideSize = Math.floor(slideSize);
506
+ if (slide) {
507
+ slide.style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
508
+ }
509
+ }
510
+ if (slide) {
511
+ slide.swiperSlideSize = slideSize;
512
+ }
513
+ slidesSizesGrid.push(slideSize);
514
+ if (params.centeredSlides) {
515
+ slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
516
+ if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
517
+ if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
518
+ if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
519
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition);
520
+ if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
521
+ slidesGrid.push(slidePosition);
522
+ } else {
523
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition);
524
+ if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
525
+ slidesGrid.push(slidePosition);
526
+ slidePosition = slidePosition + slideSize + spaceBetween;
527
+ }
528
+ swiper.virtualSize += slideSize + spaceBetween;
529
+ prevSlideSize = slideSize;
530
+ index += 1;
531
+ }
532
+ swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
533
+ if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
534
+ wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
535
+ }
536
+ if (params.setWrapperSize) {
537
+ wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
538
+ }
539
+ if (gridEnabled) {
540
+ swiper.grid.updateWrapperSize(slideSize, snapGrid);
541
+ }
542
+
543
+ // Remove last grid elements depending on width
544
+ if (!params.centeredSlides) {
545
+ // Check if snapToSlideEdge should be applied
546
+ const isFractionalSlidesPerView = params.slidesPerView !== 'auto' && params.slidesPerView % 1 !== 0;
547
+ const shouldSnapToSlideEdge = params.snapToSlideEdge && !params.loop && (params.slidesPerView === 'auto' || isFractionalSlidesPerView);
548
+
549
+ // Calculate the last allowed snap index when snapToSlideEdge is enabled
550
+ // This ensures minimum slides are visible at the end
551
+ let lastAllowedSnapIndex = snapGrid.length;
552
+ if (shouldSnapToSlideEdge) {
553
+ let minVisibleSlides;
554
+ if (params.slidesPerView === 'auto') {
555
+ // For 'auto' mode, calculate how many slides fit based on actual sizes
556
+ minVisibleSlides = 1;
557
+ let accumulatedSize = 0;
558
+ for (let i = slidesSizesGrid.length - 1; i >= 0; i -= 1) {
559
+ accumulatedSize += slidesSizesGrid[i] + (i < slidesSizesGrid.length - 1 ? spaceBetween : 0);
560
+ if (accumulatedSize <= swiperSize) {
561
+ minVisibleSlides = slidesSizesGrid.length - i;
562
+ } else {
563
+ break;
564
+ }
565
+ }
566
+ } else {
567
+ minVisibleSlides = Math.floor(params.slidesPerView);
568
+ }
569
+ lastAllowedSnapIndex = Math.max(slidesLength - minVisibleSlides, 0);
570
+ }
571
+ const newSlidesGrid = [];
572
+ for (let i = 0; i < snapGrid.length; i += 1) {
573
+ let slidesGridItem = snapGrid[i];
574
+ if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
575
+ if (shouldSnapToSlideEdge) {
576
+ // When snapToSlideEdge is enabled, only keep snaps up to lastAllowedSnapIndex
577
+ if (i <= lastAllowedSnapIndex) {
578
+ newSlidesGrid.push(slidesGridItem);
579
+ }
580
+ } else if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
581
+ // When snapToSlideEdge is disabled, keep snaps that fit within scrollable area
582
+ newSlidesGrid.push(slidesGridItem);
583
+ }
584
+ }
585
+ snapGrid = newSlidesGrid;
586
+ if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
587
+ // Only add edge-aligned snap if snapToSlideEdge is not enabled
588
+ if (!shouldSnapToSlideEdge) {
589
+ snapGrid.push(swiper.virtualSize - swiperSize);
590
+ }
591
+ }
592
+ }
593
+ if (isVirtual && params.loop) {
594
+ const size = slidesSizesGrid[0] + spaceBetween;
595
+ if (params.slidesPerGroup > 1) {
596
+ const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
597
+ const groupSize = size * params.slidesPerGroup;
598
+ for (let i = 0; i < groups; i += 1) {
599
+ snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
600
+ }
601
+ }
602
+ for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
603
+ if (params.slidesPerGroup === 1) {
604
+ snapGrid.push(snapGrid[snapGrid.length - 1] + size);
605
+ }
606
+ slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
607
+ swiper.virtualSize += size;
608
+ }
609
+ }
610
+ if (snapGrid.length === 0) snapGrid = [0];
611
+ if (spaceBetween !== 0) {
612
+ const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
613
+ slides.filter((_, slideIndex) => {
614
+ if (!params.cssMode || params.loop) return true;
615
+ if (slideIndex === slides.length - 1) {
616
+ return false;
617
+ }
618
+ return true;
619
+ }).forEach(slideEl => {
620
+ slideEl.style[key] = `${spaceBetween}px`;
621
+ });
622
+ }
623
+ if (params.centeredSlides && params.centeredSlidesBounds) {
624
+ let allSlidesSize = 0;
625
+ slidesSizesGrid.forEach(slideSizeValue => {
626
+ allSlidesSize += slideSizeValue + (spaceBetween || 0);
627
+ });
628
+ allSlidesSize -= spaceBetween;
629
+ const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0;
630
+ snapGrid = snapGrid.map(snap => {
631
+ if (snap <= 0) return -offsetBefore;
632
+ if (snap > maxSnap) return maxSnap + offsetAfter;
633
+ return snap;
634
+ });
635
+ }
636
+ if (params.centerInsufficientSlides) {
637
+ let allSlidesSize = 0;
638
+ slidesSizesGrid.forEach(slideSizeValue => {
639
+ allSlidesSize += slideSizeValue + (spaceBetween || 0);
640
+ });
641
+ allSlidesSize -= spaceBetween;
642
+ if (allSlidesSize < swiperSize) {
643
+ const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
644
+ snapGrid.forEach((snap, snapIndex) => {
645
+ snapGrid[snapIndex] = snap - allSlidesOffset;
646
+ });
647
+ slidesGrid.forEach((snap, snapIndex) => {
648
+ slidesGrid[snapIndex] = snap + allSlidesOffset;
649
+ });
650
+ }
651
+ }
652
+ Object.assign(swiper, {
653
+ slides,
654
+ snapGrid,
655
+ slidesGrid,
656
+ slidesSizesGrid
657
+ });
658
+ if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
659
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
660
+ setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
661
+ const addToSnapGrid = -swiper.snapGrid[0];
662
+ const addToSlidesGrid = -swiper.slidesGrid[0];
663
+ swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
664
+ swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
665
+ }
666
+ if (slidesLength !== previousSlidesLength) {
667
+ swiper.emit('slidesLengthChange');
668
+ }
669
+ if (snapGrid.length !== previousSnapGridLength) {
670
+ if (swiper.params.watchOverflow) swiper.checkOverflow();
671
+ swiper.emit('snapGridLengthChange');
672
+ }
673
+ if (slidesGrid.length !== previousSlidesGridLength) {
674
+ swiper.emit('slidesGridLengthChange');
675
+ }
676
+ if (params.watchSlidesProgress) {
677
+ swiper.updateSlidesOffset();
678
+ }
679
+ swiper.emit('slidesUpdated');
680
+ if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
681
+ const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
682
+ const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
683
+ if (slidesLength <= params.maxBackfaceHiddenSlides) {
684
+ if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
685
+ } else if (hasClassBackfaceClassAdded) {
686
+ swiper.el.classList.remove(backFaceHiddenClass);
687
+ }
688
+ }
689
+ }
690
+
691
+ function updateAutoHeight(speed) {
692
+ const swiper = this;
693
+ const activeSlides = [];
694
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
695
+ let newHeight = 0;
696
+ let i;
697
+ if (typeof speed === 'number') {
698
+ swiper.setTransition(speed);
699
+ } else if (speed === true) {
700
+ swiper.setTransition(swiper.params.speed);
701
+ }
702
+ const getSlideByIndex = index => {
703
+ if (isVirtual) {
704
+ return swiper.slides[swiper.getSlideIndexByData(index)];
705
+ }
706
+ return swiper.slides[index];
707
+ };
708
+ // Find slides currently in view
709
+ if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
710
+ if (swiper.params.centeredSlides) {
711
+ (swiper.visibleSlides || []).forEach(slide => {
712
+ activeSlides.push(slide);
713
+ });
714
+ } else {
715
+ for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
716
+ const index = swiper.activeIndex + i;
717
+ if (index > swiper.slides.length && !isVirtual) break;
718
+ activeSlides.push(getSlideByIndex(index));
719
+ }
720
+ }
721
+ } else {
722
+ activeSlides.push(getSlideByIndex(swiper.activeIndex));
723
+ }
724
+
725
+ // Find new height from highest slide in view
726
+ for (i = 0; i < activeSlides.length; i += 1) {
727
+ if (typeof activeSlides[i] !== 'undefined') {
728
+ const height = activeSlides[i].offsetHeight;
729
+ newHeight = height > newHeight ? height : newHeight;
730
+ }
731
+ }
732
+
733
+ // Update Height
734
+ if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
735
+ }
736
+
737
+ function updateSlidesOffset() {
738
+ const swiper = this;
739
+ const slides = swiper.slides;
740
+ // eslint-disable-next-line
741
+ const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
742
+ for (let i = 0; i < slides.length; i += 1) {
743
+ slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
744
+ }
745
+ }
746
+
747
+ const toggleSlideClasses$1 = (slideEl, condition, className) => {
748
+ if (condition && !slideEl.classList.contains(className)) {
749
+ slideEl.classList.add(className);
750
+ } else if (!condition && slideEl.classList.contains(className)) {
751
+ slideEl.classList.remove(className);
752
+ }
753
+ };
754
+ function updateSlidesProgress(translate = this && this.translate || 0) {
755
+ const swiper = this;
756
+ const params = swiper.params;
757
+ const {
758
+ slides,
759
+ rtlTranslate: rtl,
760
+ snapGrid
761
+ } = swiper;
762
+ if (slides.length === 0) return;
763
+ if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
764
+ let offsetCenter = -translate;
765
+ if (rtl) offsetCenter = translate;
766
+ swiper.visibleSlidesIndexes = [];
767
+ swiper.visibleSlides = [];
768
+ let spaceBetween = params.spaceBetween;
769
+ if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
770
+ spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
771
+ } else if (typeof spaceBetween === 'string') {
772
+ spaceBetween = parseFloat(spaceBetween);
773
+ }
774
+ for (let i = 0; i < slides.length; i += 1) {
775
+ const slide = slides[i];
776
+ let slideOffset = slide.swiperSlideOffset;
777
+ if (params.cssMode && params.centeredSlides) {
778
+ slideOffset -= slides[0].swiperSlideOffset;
779
+ }
780
+ const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
781
+ const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
782
+ const slideBefore = -(offsetCenter - slideOffset);
783
+ const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
784
+ const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
785
+ const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
786
+ if (isVisible) {
787
+ swiper.visibleSlides.push(slide);
788
+ swiper.visibleSlidesIndexes.push(i);
789
+ }
790
+ toggleSlideClasses$1(slide, isVisible, params.slideVisibleClass);
791
+ toggleSlideClasses$1(slide, isFullyVisible, params.slideFullyVisibleClass);
792
+ slide.progress = rtl ? -slideProgress : slideProgress;
793
+ slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
794
+ }
795
+ }
796
+
797
+ function updateProgress(translate) {
798
+ const swiper = this;
799
+ if (typeof translate === 'undefined') {
800
+ const multiplier = swiper.rtlTranslate ? -1 : 1;
801
+ // eslint-disable-next-line
802
+ translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
803
+ }
804
+ const params = swiper.params;
805
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
806
+ let {
807
+ progress,
808
+ isBeginning,
809
+ isEnd,
810
+ progressLoop
811
+ } = swiper;
812
+ const wasBeginning = isBeginning;
813
+ const wasEnd = isEnd;
814
+ if (translatesDiff === 0) {
815
+ progress = 0;
816
+ isBeginning = true;
817
+ isEnd = true;
818
+ } else {
819
+ progress = (translate - swiper.minTranslate()) / translatesDiff;
820
+ const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
821
+ const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
822
+ isBeginning = isBeginningRounded || progress <= 0;
823
+ isEnd = isEndRounded || progress >= 1;
824
+ if (isBeginningRounded) progress = 0;
825
+ if (isEndRounded) progress = 1;
826
+ }
827
+ if (params.loop) {
828
+ const firstSlideIndex = swiper.getSlideIndexByData(0);
829
+ const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
830
+ const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
831
+ const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
832
+ const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
833
+ const translateAbs = Math.abs(translate);
834
+ if (translateAbs >= firstSlideTranslate) {
835
+ progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
836
+ } else {
837
+ progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
838
+ }
839
+ if (progressLoop > 1) progressLoop -= 1;
840
+ }
841
+ Object.assign(swiper, {
842
+ progress,
843
+ progressLoop,
844
+ isBeginning,
845
+ isEnd
846
+ });
847
+ if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
848
+ if (isBeginning && !wasBeginning) {
849
+ swiper.emit('reachBeginning toEdge');
850
+ }
851
+ if (isEnd && !wasEnd) {
852
+ swiper.emit('reachEnd toEdge');
853
+ }
854
+ if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
855
+ swiper.emit('fromEdge');
856
+ }
857
+ swiper.emit('progress', progress);
858
+ }
859
+
860
+ const toggleSlideClasses = (slideEl, condition, className) => {
861
+ if (condition && !slideEl.classList.contains(className)) {
862
+ slideEl.classList.add(className);
863
+ } else if (!condition && slideEl.classList.contains(className)) {
864
+ slideEl.classList.remove(className);
865
+ }
866
+ };
867
+ function updateSlidesClasses() {
868
+ const swiper = this;
869
+ const {
870
+ slides,
871
+ params,
872
+ slidesEl,
873
+ activeIndex
874
+ } = swiper;
875
+ const isVirtual = swiper.virtual && params.virtual.enabled;
876
+ const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
877
+ const getFilteredSlide = selector => {
878
+ return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
879
+ };
880
+ let activeSlide;
881
+ let prevSlide;
882
+ let nextSlide;
883
+ if (isVirtual) {
884
+ if (params.loop) {
885
+ let slideIndex = activeIndex - swiper.virtual.slidesBefore;
886
+ if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
887
+ if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
888
+ activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
889
+ } else {
890
+ activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
891
+ }
892
+ } else {
893
+ if (gridEnabled) {
894
+ activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
895
+ nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
896
+ prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
897
+ } else {
898
+ activeSlide = slides[activeIndex];
899
+ }
900
+ }
901
+ if (activeSlide) {
902
+ if (!gridEnabled) {
903
+ // Next Slide
904
+ nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
905
+ if (params.loop && !nextSlide) {
906
+ nextSlide = slides[0];
907
+ }
908
+
909
+ // Prev Slide
910
+ prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
911
+ if (params.loop && !prevSlide === 0) {
912
+ prevSlide = slides[slides.length - 1];
913
+ }
914
+ }
915
+ }
916
+ slides.forEach(slideEl => {
917
+ toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
918
+ toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
919
+ toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
920
+ });
921
+ swiper.emitSlidesClasses();
922
+ }
923
+
924
+ const processLazyPreloader = (swiper, imageEl) => {
925
+ if (!swiper || swiper.destroyed || !swiper.params) return;
926
+ const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
927
+ const slideEl = imageEl.closest(slideSelector());
928
+ if (slideEl) {
929
+ let lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
930
+ if (!lazyEl && swiper.isElement) {
931
+ if (slideEl.shadowRoot) {
932
+ lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
933
+ } else {
934
+ // init later
935
+ requestAnimationFrame(() => {
936
+ if (slideEl.shadowRoot) {
937
+ lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
938
+ if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
939
+ }
940
+ });
941
+ }
942
+ }
943
+ // Skip removal if managed by React/Vue component
944
+ if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
945
+ }
946
+ };
947
+ const unlazy = (swiper, index) => {
948
+ if (!swiper.slides[index]) return;
949
+ const imageEl = swiper.slides[index].querySelector('[loading="lazy"]');
950
+ if (imageEl) imageEl.removeAttribute('loading');
951
+ };
952
+ const preload = swiper => {
953
+ if (!swiper || swiper.destroyed || !swiper.params) return;
954
+ let amount = swiper.params.lazyPreloadPrevNext;
955
+ const len = swiper.slides.length;
956
+ if (!len || !amount || amount < 0) return;
957
+ amount = Math.min(amount, len);
958
+ const slidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView);
959
+ const activeIndex = swiper.activeIndex;
960
+ if (swiper.params.grid && swiper.params.grid.rows > 1) {
961
+ const activeColumn = activeIndex;
962
+ const preloadColumns = [activeColumn - amount];
963
+ preloadColumns.push(...Array.from({
964
+ length: amount
965
+ }).map((_, i) => {
966
+ return activeColumn + slidesPerView + i;
967
+ }));
968
+ swiper.slides.forEach((slideEl, i) => {
969
+ if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i);
970
+ });
971
+ return;
972
+ }
973
+ const slideIndexLastInView = activeIndex + slidesPerView - 1;
974
+ if (swiper.params.rewind || swiper.params.loop) {
975
+ for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
976
+ const realIndex = (i % len + len) % len;
977
+ if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex);
978
+ }
979
+ } else {
980
+ for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
981
+ if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
982
+ unlazy(swiper, i);
983
+ }
984
+ }
985
+ }
986
+ };
987
+
988
+ function getActiveIndexByTranslate(swiper) {
989
+ const {
990
+ slidesGrid,
991
+ params
992
+ } = swiper;
993
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
994
+ let activeIndex;
995
+ for (let i = 0; i < slidesGrid.length; i += 1) {
996
+ if (typeof slidesGrid[i + 1] !== 'undefined') {
997
+ if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
998
+ activeIndex = i;
999
+ } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
1000
+ activeIndex = i + 1;
1001
+ }
1002
+ } else if (translate >= slidesGrid[i]) {
1003
+ activeIndex = i;
1004
+ }
1005
+ }
1006
+ // Normalize slideIndex
1007
+ if (params.normalizeSlideIndex) {
1008
+ if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
1009
+ }
1010
+ return activeIndex;
1011
+ }
1012
+ function updateActiveIndex(newActiveIndex) {
1013
+ const swiper = this;
1014
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
1015
+ const {
1016
+ snapGrid,
1017
+ params,
1018
+ activeIndex: previousIndex,
1019
+ realIndex: previousRealIndex,
1020
+ snapIndex: previousSnapIndex
1021
+ } = swiper;
1022
+ let activeIndex = newActiveIndex;
1023
+ let snapIndex;
1024
+ const getVirtualRealIndex = aIndex => {
1025
+ let realIndex = aIndex - swiper.virtual.slidesBefore;
1026
+ if (realIndex < 0) {
1027
+ realIndex = swiper.virtual.slides.length + realIndex;
1028
+ }
1029
+ if (realIndex >= swiper.virtual.slides.length) {
1030
+ realIndex -= swiper.virtual.slides.length;
1031
+ }
1032
+ return realIndex;
1033
+ };
1034
+ if (typeof activeIndex === 'undefined') {
1035
+ activeIndex = getActiveIndexByTranslate(swiper);
1036
+ }
1037
+ if (snapGrid.indexOf(translate) >= 0) {
1038
+ snapIndex = snapGrid.indexOf(translate);
1039
+ } else {
1040
+ const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
1041
+ snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
1042
+ }
1043
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1044
+ if (activeIndex === previousIndex && !swiper.params.loop) {
1045
+ if (snapIndex !== previousSnapIndex) {
1046
+ swiper.snapIndex = snapIndex;
1047
+ swiper.emit('snapIndexChange');
1048
+ }
1049
+ return;
1050
+ }
1051
+ if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
1052
+ swiper.realIndex = getVirtualRealIndex(activeIndex);
1053
+ return;
1054
+ }
1055
+ const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
1056
+
1057
+ // Get real index
1058
+ let realIndex;
1059
+ if (swiper.virtual && params.virtual.enabled) {
1060
+ if (params.loop) {
1061
+ realIndex = getVirtualRealIndex(activeIndex);
1062
+ } else {
1063
+ realIndex = activeIndex;
1064
+ }
1065
+ } else if (gridEnabled) {
1066
+ const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
1067
+ let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
1068
+ if (Number.isNaN(activeSlideIndex)) {
1069
+ activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
1070
+ }
1071
+ realIndex = Math.floor(activeSlideIndex / params.grid.rows);
1072
+ } else if (swiper.slides[activeIndex]) {
1073
+ const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
1074
+ if (slideIndex) {
1075
+ realIndex = parseInt(slideIndex, 10);
1076
+ } else {
1077
+ realIndex = activeIndex;
1078
+ }
1079
+ } else {
1080
+ realIndex = activeIndex;
1081
+ }
1082
+ Object.assign(swiper, {
1083
+ previousSnapIndex,
1084
+ snapIndex,
1085
+ previousRealIndex,
1086
+ realIndex,
1087
+ previousIndex,
1088
+ activeIndex
1089
+ });
1090
+ if (swiper.initialized) {
1091
+ preload(swiper);
1092
+ }
1093
+ swiper.emit('activeIndexChange');
1094
+ swiper.emit('snapIndexChange');
1095
+ if (swiper.initialized || swiper.params.runCallbacksOnInit) {
1096
+ if (previousRealIndex !== realIndex) {
1097
+ swiper.emit('realIndexChange');
1098
+ }
1099
+ swiper.emit('slideChange');
1100
+ }
1101
+ }
1102
+
1103
+ function updateClickedSlide(el, path) {
1104
+ const swiper = this;
1105
+ const params = swiper.params;
1106
+ let slide = el.closest(`.${params.slideClass}, swiper-slide`);
1107
+ if (!slide && swiper.isElement && path && path.length > 1 && path.includes(el)) {
1108
+ [...path.slice(path.indexOf(el) + 1, path.length)].forEach(pathEl => {
1109
+ if (!slide && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
1110
+ slide = pathEl;
1111
+ }
1112
+ });
1113
+ }
1114
+ let slideFound = false;
1115
+ let slideIndex;
1116
+ if (slide) {
1117
+ for (let i = 0; i < swiper.slides.length; i += 1) {
1118
+ if (swiper.slides[i] === slide) {
1119
+ slideFound = true;
1120
+ slideIndex = i;
1121
+ break;
1122
+ }
1123
+ }
1124
+ }
1125
+ if (slide && slideFound) {
1126
+ swiper.clickedSlide = slide;
1127
+ if (swiper.virtual && swiper.params.virtual.enabled) {
1128
+ swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
1129
+ } else {
1130
+ swiper.clickedIndex = slideIndex;
1131
+ }
1132
+ } else {
1133
+ swiper.clickedSlide = undefined;
1134
+ swiper.clickedIndex = undefined;
1135
+ return;
1136
+ }
1137
+ if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
1138
+ swiper.slideToClickedSlide();
1139
+ }
1140
+ }
1141
+
1142
+ var update = {
1143
+ updateSize,
1144
+ updateSlides,
1145
+ updateAutoHeight,
1146
+ updateSlidesOffset,
1147
+ updateSlidesProgress,
1148
+ updateProgress,
1149
+ updateSlidesClasses,
1150
+ updateActiveIndex,
1151
+ updateClickedSlide
1152
+ };
1153
+
1154
+ function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
1155
+ const swiper = this;
1156
+ const {
1157
+ params,
1158
+ rtlTranslate: rtl,
1159
+ translate,
1160
+ wrapperEl
1161
+ } = swiper;
1162
+ if (params.virtualTranslate) {
1163
+ return rtl ? -translate : translate;
1164
+ }
1165
+ if (params.cssMode) {
1166
+ return translate;
1167
+ }
1168
+ let currentTranslate = getTranslate(wrapperEl, axis);
1169
+ currentTranslate += swiper.cssOverflowAdjustment();
1170
+ if (rtl) currentTranslate = -currentTranslate;
1171
+ return currentTranslate || 0;
1172
+ }
1173
+
1174
+ function setTranslate(translate, byController) {
1175
+ const swiper = this;
1176
+ const {
1177
+ rtlTranslate: rtl,
1178
+ params,
1179
+ wrapperEl,
1180
+ progress
1181
+ } = swiper;
1182
+ let x = 0;
1183
+ let y = 0;
1184
+ const z = 0;
1185
+ if (swiper.isHorizontal()) {
1186
+ x = rtl ? -translate : translate;
1187
+ } else {
1188
+ y = translate;
1189
+ }
1190
+ if (params.roundLengths) {
1191
+ x = Math.floor(x);
1192
+ y = Math.floor(y);
1193
+ }
1194
+ swiper.previousTranslate = swiper.translate;
1195
+ swiper.translate = swiper.isHorizontal() ? x : y;
1196
+ if (params.cssMode) {
1197
+ wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
1198
+ } else if (!params.virtualTranslate) {
1199
+ if (swiper.isHorizontal()) {
1200
+ x -= swiper.cssOverflowAdjustment();
1201
+ } else {
1202
+ y -= swiper.cssOverflowAdjustment();
1203
+ }
1204
+ wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
1205
+ }
1206
+
1207
+ // Check if we need to update progress
1208
+ let newProgress;
1209
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
1210
+ if (translatesDiff === 0) {
1211
+ newProgress = 0;
1212
+ } else {
1213
+ newProgress = (translate - swiper.minTranslate()) / translatesDiff;
1214
+ }
1215
+ if (newProgress !== progress) {
1216
+ swiper.updateProgress(translate);
1217
+ }
1218
+ swiper.emit('setTranslate', swiper.translate, byController);
1219
+ }
1220
+
1221
+ function minTranslate() {
1222
+ return -this.snapGrid[0];
1223
+ }
1224
+
1225
+ function maxTranslate() {
1226
+ return -this.snapGrid[this.snapGrid.length - 1];
1227
+ }
1228
+
1229
+ function translateTo(translate = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) {
1230
+ const swiper = this;
1231
+ const {
1232
+ params,
1233
+ wrapperEl
1234
+ } = swiper;
1235
+ if (swiper.animating && params.preventInteractionOnTransition) {
1236
+ return false;
1237
+ }
1238
+ const minTranslate = swiper.minTranslate();
1239
+ const maxTranslate = swiper.maxTranslate();
1240
+ let newTranslate;
1241
+ if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
1242
+
1243
+ // Update progress
1244
+ swiper.updateProgress(newTranslate);
1245
+ if (params.cssMode) {
1246
+ const isH = swiper.isHorizontal();
1247
+ if (speed === 0) {
1248
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
1249
+ } else {
1250
+ if (!swiper.support.smoothScroll) {
1251
+ animateCSSModeScroll({
1252
+ swiper,
1253
+ targetPosition: -newTranslate,
1254
+ side: isH ? 'left' : 'top'
1255
+ });
1256
+ return true;
1257
+ }
1258
+ wrapperEl.scrollTo({
1259
+ [isH ? 'left' : 'top']: -newTranslate,
1260
+ behavior: 'smooth'
1261
+ });
1262
+ }
1263
+ return true;
1264
+ }
1265
+ if (speed === 0) {
1266
+ swiper.setTransition(0);
1267
+ swiper.setTranslate(newTranslate);
1268
+ if (runCallbacks) {
1269
+ swiper.emit('beforeTransitionStart', speed, internal);
1270
+ swiper.emit('transitionEnd');
1271
+ }
1272
+ } else {
1273
+ swiper.setTransition(speed);
1274
+ swiper.setTranslate(newTranslate);
1275
+ if (runCallbacks) {
1276
+ swiper.emit('beforeTransitionStart', speed, internal);
1277
+ swiper.emit('transitionStart');
1278
+ }
1279
+ if (!swiper.animating) {
1280
+ swiper.animating = true;
1281
+ if (!swiper.onTranslateToWrapperTransitionEnd) {
1282
+ swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
1283
+ if (!swiper || swiper.destroyed) return;
1284
+ if (e.target !== this) return;
1285
+ swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
1286
+ swiper.onTranslateToWrapperTransitionEnd = null;
1287
+ delete swiper.onTranslateToWrapperTransitionEnd;
1288
+ swiper.animating = false;
1289
+ if (runCallbacks) {
1290
+ swiper.emit('transitionEnd');
1291
+ }
1292
+ };
1293
+ }
1294
+ swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
1295
+ }
1296
+ }
1297
+ return true;
1298
+ }
1299
+
1300
+ var translate = {
1301
+ getTranslate: getSwiperTranslate,
1302
+ setTranslate,
1303
+ minTranslate,
1304
+ maxTranslate,
1305
+ translateTo
1306
+ };
1307
+
1308
+ function setTransition(duration, byController) {
1309
+ const swiper = this;
1310
+ if (!swiper.params.cssMode) {
1311
+ swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
1312
+ swiper.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : '';
1313
+ }
1314
+ swiper.emit('setTransition', duration, byController);
1315
+ }
1316
+
1317
+ function transitionEmit({
1318
+ swiper,
1319
+ runCallbacks,
1320
+ direction,
1321
+ step
1322
+ }) {
1323
+ const {
1324
+ activeIndex,
1325
+ previousIndex
1326
+ } = swiper;
1327
+ let dir = direction;
1328
+ if (!dir) {
1329
+ if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
1330
+ }
1331
+ swiper.emit(`transition${step}`);
1332
+ if (runCallbacks && dir === 'reset') {
1333
+ swiper.emit(`slideResetTransition${step}`);
1334
+ } else if (runCallbacks && activeIndex !== previousIndex) {
1335
+ swiper.emit(`slideChangeTransition${step}`);
1336
+ if (dir === 'next') {
1337
+ swiper.emit(`slideNextTransition${step}`);
1338
+ } else {
1339
+ swiper.emit(`slidePrevTransition${step}`);
1340
+ }
1341
+ }
1342
+ }
1343
+
1344
+ function transitionStart(runCallbacks = true, direction) {
1345
+ const swiper = this;
1346
+ const {
1347
+ params
1348
+ } = swiper;
1349
+ if (params.cssMode) return;
1350
+ if (params.autoHeight) {
1351
+ swiper.updateAutoHeight();
1352
+ }
1353
+ transitionEmit({
1354
+ swiper,
1355
+ runCallbacks,
1356
+ direction,
1357
+ step: 'Start'
1358
+ });
1359
+ }
1360
+
1361
+ function transitionEnd(runCallbacks = true, direction) {
1362
+ const swiper = this;
1363
+ const {
1364
+ params
1365
+ } = swiper;
1366
+ swiper.animating = false;
1367
+ if (params.cssMode) return;
1368
+ swiper.setTransition(0);
1369
+ transitionEmit({
1370
+ swiper,
1371
+ runCallbacks,
1372
+ direction,
1373
+ step: 'End'
1374
+ });
1375
+ }
1376
+
1377
+ var transition = {
1378
+ setTransition,
1379
+ transitionStart,
1380
+ transitionEnd
1381
+ };
1382
+
1383
+ function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
1384
+ if (typeof index === 'string') {
1385
+ index = parseInt(index, 10);
1386
+ }
1387
+ const swiper = this;
1388
+ let slideIndex = index;
1389
+ if (slideIndex < 0) slideIndex = 0;
1390
+ const {
1391
+ params,
1392
+ snapGrid,
1393
+ slidesGrid,
1394
+ previousIndex,
1395
+ activeIndex,
1396
+ rtlTranslate: rtl,
1397
+ wrapperEl,
1398
+ enabled
1399
+ } = swiper;
1400
+ if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) {
1401
+ return false;
1402
+ }
1403
+ if (typeof speed === 'undefined') {
1404
+ speed = swiper.params.speed;
1405
+ }
1406
+ const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
1407
+ let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
1408
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
1409
+ const translate = -snapGrid[snapIndex];
1410
+ // Normalize slideIndex
1411
+ if (params.normalizeSlideIndex) {
1412
+ for (let i = 0; i < slidesGrid.length; i += 1) {
1413
+ const normalizedTranslate = -Math.floor(translate * 100);
1414
+ const normalizedGrid = Math.floor(slidesGrid[i] * 100);
1415
+ const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
1416
+ if (typeof slidesGrid[i + 1] !== 'undefined') {
1417
+ if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
1418
+ slideIndex = i;
1419
+ } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
1420
+ slideIndex = i + 1;
1421
+ }
1422
+ } else if (normalizedTranslate >= normalizedGrid) {
1423
+ slideIndex = i;
1424
+ }
1425
+ }
1426
+ }
1427
+ // Directions locks
1428
+ if (swiper.initialized && slideIndex !== activeIndex) {
1429
+ if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
1430
+ return false;
1431
+ }
1432
+ if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
1433
+ if ((activeIndex || 0) !== slideIndex) {
1434
+ return false;
1435
+ }
1436
+ }
1437
+ }
1438
+ if (slideIndex !== (previousIndex || 0) && runCallbacks) {
1439
+ swiper.emit('beforeSlideChangeStart');
1440
+ }
1441
+
1442
+ // Update progress
1443
+ swiper.updateProgress(translate);
1444
+ let direction;
1445
+ if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
1446
+
1447
+ // initial virtual
1448
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1449
+ const isInitialVirtual = isVirtual && initial;
1450
+ // Update Index
1451
+ if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
1452
+ swiper.updateActiveIndex(slideIndex);
1453
+ // Update Height
1454
+ if (params.autoHeight) {
1455
+ swiper.updateAutoHeight();
1456
+ }
1457
+ swiper.updateSlidesClasses();
1458
+ if (params.effect !== 'slide') {
1459
+ swiper.setTranslate(translate);
1460
+ }
1461
+ if (direction !== 'reset') {
1462
+ swiper.transitionStart(runCallbacks, direction);
1463
+ swiper.transitionEnd(runCallbacks, direction);
1464
+ }
1465
+ return false;
1466
+ }
1467
+ if (params.cssMode) {
1468
+ const isH = swiper.isHorizontal();
1469
+ const t = rtl ? translate : -translate;
1470
+ if (speed === 0) {
1471
+ if (isVirtual) {
1472
+ swiper.wrapperEl.style.scrollSnapType = 'none';
1473
+ swiper._immediateVirtual = true;
1474
+ }
1475
+ if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
1476
+ swiper._cssModeVirtualInitialSet = true;
1477
+ requestAnimationFrame(() => {
1478
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
1479
+ });
1480
+ } else {
1481
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
1482
+ }
1483
+ if (isVirtual) {
1484
+ requestAnimationFrame(() => {
1485
+ swiper.wrapperEl.style.scrollSnapType = '';
1486
+ swiper._immediateVirtual = false;
1487
+ });
1488
+ }
1489
+ } else {
1490
+ if (!swiper.support.smoothScroll) {
1491
+ animateCSSModeScroll({
1492
+ swiper,
1493
+ targetPosition: t,
1494
+ side: isH ? 'left' : 'top'
1495
+ });
1496
+ return true;
1497
+ }
1498
+ wrapperEl.scrollTo({
1499
+ [isH ? 'left' : 'top']: t,
1500
+ behavior: 'smooth'
1501
+ });
1502
+ }
1503
+ return true;
1504
+ }
1505
+ const browser = getBrowser();
1506
+ const isSafari = browser.isSafari;
1507
+ if (isVirtual && !initial && isSafari && swiper.isElement) {
1508
+ swiper.virtual.update(false, false, slideIndex);
1509
+ }
1510
+ swiper.setTransition(speed);
1511
+ swiper.setTranslate(translate);
1512
+ swiper.updateActiveIndex(slideIndex);
1513
+ swiper.updateSlidesClasses();
1514
+ swiper.emit('beforeTransitionStart', speed, internal);
1515
+ swiper.transitionStart(runCallbacks, direction);
1516
+ if (speed === 0) {
1517
+ swiper.transitionEnd(runCallbacks, direction);
1518
+ } else if (!swiper.animating) {
1519
+ swiper.animating = true;
1520
+ if (!swiper.onSlideToWrapperTransitionEnd) {
1521
+ swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
1522
+ if (!swiper || swiper.destroyed) return;
1523
+ if (e.target !== this) return;
1524
+ swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
1525
+ swiper.onSlideToWrapperTransitionEnd = null;
1526
+ delete swiper.onSlideToWrapperTransitionEnd;
1527
+ swiper.transitionEnd(runCallbacks, direction);
1528
+ };
1529
+ }
1530
+ swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
1531
+ }
1532
+ return true;
1533
+ }
1534
+
1535
+ function slideToLoop(index = 0, speed, runCallbacks = true, internal) {
1536
+ if (typeof index === 'string') {
1537
+ const indexAsNumber = parseInt(index, 10);
1538
+ index = indexAsNumber;
1539
+ }
1540
+ const swiper = this;
1541
+ if (swiper.destroyed) return;
1542
+ if (typeof speed === 'undefined') {
1543
+ speed = swiper.params.speed;
1544
+ }
1545
+ const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
1546
+ let newIndex = index;
1547
+ if (swiper.params.loop) {
1548
+ if (swiper.virtual && swiper.params.virtual.enabled) {
1549
+ // eslint-disable-next-line
1550
+ newIndex = newIndex + swiper.virtual.slidesBefore;
1551
+ } else {
1552
+ let targetSlideIndex;
1553
+ if (gridEnabled) {
1554
+ const slideIndex = newIndex * swiper.params.grid.rows;
1555
+ targetSlideIndex = swiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex).column;
1556
+ } else {
1557
+ targetSlideIndex = swiper.getSlideIndexByData(newIndex);
1558
+ }
1559
+ const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
1560
+ const {
1561
+ centeredSlides,
1562
+ slidesOffsetBefore,
1563
+ slidesOffsetAfter
1564
+ } = swiper.params;
1565
+ const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
1566
+ let slidesPerView = swiper.params.slidesPerView;
1567
+ if (slidesPerView === 'auto') {
1568
+ slidesPerView = swiper.slidesPerViewDynamic();
1569
+ } else {
1570
+ slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
1571
+ if (bothDirections && slidesPerView % 2 === 0) {
1572
+ slidesPerView = slidesPerView + 1;
1573
+ }
1574
+ }
1575
+ let needLoopFix = cols - targetSlideIndex < slidesPerView;
1576
+ if (bothDirections) {
1577
+ needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
1578
+ }
1579
+ if (internal && bothDirections && swiper.params.slidesPerView !== 'auto' && !gridEnabled) {
1580
+ needLoopFix = false;
1581
+ }
1582
+ if (needLoopFix) {
1583
+ const direction = bothDirections ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
1584
+ swiper.loopFix({
1585
+ direction,
1586
+ slideTo: true,
1587
+ activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
1588
+ slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
1589
+ });
1590
+ }
1591
+ if (gridEnabled) {
1592
+ const slideIndex = newIndex * swiper.params.grid.rows;
1593
+ newIndex = swiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex).column;
1594
+ } else {
1595
+ newIndex = swiper.getSlideIndexByData(newIndex);
1596
+ }
1597
+ }
1598
+ }
1599
+ requestAnimationFrame(() => {
1600
+ swiper.slideTo(newIndex, speed, runCallbacks, internal);
1601
+ });
1602
+ return swiper;
1603
+ }
1604
+
1605
+ /* eslint no-unused-vars: "off" */
1606
+ function slideNext(speed, runCallbacks = true, internal) {
1607
+ const swiper = this;
1608
+ const {
1609
+ enabled,
1610
+ params,
1611
+ animating
1612
+ } = swiper;
1613
+ if (!enabled || swiper.destroyed) return swiper;
1614
+ if (typeof speed === 'undefined') {
1615
+ speed = swiper.params.speed;
1616
+ }
1617
+ let perGroup = params.slidesPerGroup;
1618
+ if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1619
+ perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
1620
+ }
1621
+ const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
1622
+ const isVirtual = swiper.virtual && params.virtual.enabled;
1623
+ if (params.loop) {
1624
+ if (animating && !isVirtual && params.loopPreventsSliding) return false;
1625
+ swiper.loopFix({
1626
+ direction: 'next'
1627
+ });
1628
+ // eslint-disable-next-line
1629
+ swiper._clientLeft = swiper.wrapperEl.clientLeft;
1630
+ if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) {
1631
+ requestAnimationFrame(() => {
1632
+ swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
1633
+ });
1634
+ return true;
1635
+ }
1636
+ }
1637
+ if (params.rewind && swiper.isEnd) {
1638
+ return swiper.slideTo(0, speed, runCallbacks, internal);
1639
+ }
1640
+ return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
1641
+ }
1642
+
1643
+ /* eslint no-unused-vars: "off" */
1644
+ function slidePrev(speed, runCallbacks = true, internal) {
1645
+ const swiper = this;
1646
+ const {
1647
+ params,
1648
+ snapGrid,
1649
+ slidesGrid,
1650
+ rtlTranslate,
1651
+ enabled,
1652
+ animating
1653
+ } = swiper;
1654
+ if (!enabled || swiper.destroyed) return swiper;
1655
+ if (typeof speed === 'undefined') {
1656
+ speed = swiper.params.speed;
1657
+ }
1658
+ const isVirtual = swiper.virtual && params.virtual.enabled;
1659
+ if (params.loop) {
1660
+ if (animating && !isVirtual && params.loopPreventsSliding) return false;
1661
+ swiper.loopFix({
1662
+ direction: 'prev'
1663
+ });
1664
+ // eslint-disable-next-line
1665
+ swiper._clientLeft = swiper.wrapperEl.clientLeft;
1666
+ }
1667
+ const translate = rtlTranslate ? swiper.translate : -swiper.translate;
1668
+ function normalize(val) {
1669
+ if (val < 0) return -Math.floor(Math.abs(val));
1670
+ return Math.floor(val);
1671
+ }
1672
+ const normalizedTranslate = normalize(translate);
1673
+ const normalizedSnapGrid = snapGrid.map(val => normalize(val));
1674
+ const isFreeMode = params.freeMode && params.freeMode.enabled;
1675
+ let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
1676
+ if (typeof prevSnap === 'undefined' && (params.cssMode || isFreeMode)) {
1677
+ let prevSnapIndex;
1678
+ snapGrid.forEach((snap, snapIndex) => {
1679
+ if (normalizedTranslate >= snap) {
1680
+ // prevSnap = snap;
1681
+ prevSnapIndex = snapIndex;
1682
+ }
1683
+ });
1684
+ if (typeof prevSnapIndex !== 'undefined') {
1685
+ prevSnap = isFreeMode ? snapGrid[prevSnapIndex] : snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
1686
+ }
1687
+ }
1688
+ let prevIndex = 0;
1689
+ if (typeof prevSnap !== 'undefined') {
1690
+ prevIndex = slidesGrid.indexOf(prevSnap);
1691
+ if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
1692
+ if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
1693
+ prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
1694
+ prevIndex = Math.max(prevIndex, 0);
1695
+ }
1696
+ }
1697
+ if (params.rewind && swiper.isBeginning) {
1698
+ const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
1699
+ return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
1700
+ } else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
1701
+ requestAnimationFrame(() => {
1702
+ swiper.slideTo(prevIndex, speed, runCallbacks, internal);
1703
+ });
1704
+ return true;
1705
+ }
1706
+ return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
1707
+ }
1708
+
1709
+ /* eslint no-unused-vars: "off" */
1710
+ function slideReset(speed, runCallbacks = true, internal) {
1711
+ const swiper = this;
1712
+ if (swiper.destroyed) return;
1713
+ if (typeof speed === 'undefined') {
1714
+ speed = swiper.params.speed;
1715
+ }
1716
+ return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
1717
+ }
1718
+
1719
+ /* eslint no-unused-vars: "off" */
1720
+ function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) {
1721
+ const swiper = this;
1722
+ if (swiper.destroyed) return;
1723
+ if (typeof speed === 'undefined') {
1724
+ speed = swiper.params.speed;
1725
+ }
1726
+ let index = swiper.activeIndex;
1727
+ const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
1728
+ const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
1729
+ const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
1730
+ if (translate >= swiper.snapGrid[snapIndex]) {
1731
+ // The current translate is on or after the current snap index, so the choice
1732
+ // is between the current index and the one after it.
1733
+ const currentSnap = swiper.snapGrid[snapIndex];
1734
+ const nextSnap = swiper.snapGrid[snapIndex + 1];
1735
+ if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
1736
+ index += swiper.params.slidesPerGroup;
1737
+ }
1738
+ } else {
1739
+ // The current translate is before the current snap index, so the choice
1740
+ // is between the current index and the one before it.
1741
+ const prevSnap = swiper.snapGrid[snapIndex - 1];
1742
+ const currentSnap = swiper.snapGrid[snapIndex];
1743
+ if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
1744
+ index -= swiper.params.slidesPerGroup;
1745
+ }
1746
+ }
1747
+ index = Math.max(index, 0);
1748
+ index = Math.min(index, swiper.slidesGrid.length - 1);
1749
+ return swiper.slideTo(index, speed, runCallbacks, internal);
1750
+ }
1751
+
1752
+ function slideToClickedSlide() {
1753
+ const swiper = this;
1754
+ if (swiper.destroyed) return;
1755
+ const {
1756
+ params,
1757
+ slidesEl
1758
+ } = swiper;
1759
+ const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
1760
+ let slideToIndex = swiper.getSlideIndexWhenGrid(swiper.clickedIndex);
1761
+ let realIndex;
1762
+ const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
1763
+ const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
1764
+ if (params.loop) {
1765
+ if (swiper.animating) return;
1766
+ realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
1767
+ if (params.centeredSlides) {
1768
+ swiper.slideToLoop(realIndex);
1769
+ } else if (slideToIndex > (isGrid ? (swiper.slides.length - slidesPerView) / 2 - (swiper.params.grid.rows - 1) : swiper.slides.length - slidesPerView)) {
1770
+ swiper.loopFix();
1771
+ slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
1772
+ nextTick(() => {
1773
+ swiper.slideTo(slideToIndex);
1774
+ });
1775
+ } else {
1776
+ swiper.slideTo(slideToIndex);
1777
+ }
1778
+ } else {
1779
+ swiper.slideTo(slideToIndex);
1780
+ }
1781
+ }
1782
+
1783
+ var slide = {
1784
+ slideTo,
1785
+ slideToLoop,
1786
+ slideNext,
1787
+ slidePrev,
1788
+ slideReset,
1789
+ slideToClosest,
1790
+ slideToClickedSlide
1791
+ };
1792
+
1793
+ function loopCreate(slideRealIndex, initial) {
1794
+ const swiper = this;
1795
+ const {
1796
+ params,
1797
+ slidesEl
1798
+ } = swiper;
1799
+ if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
1800
+ const initSlides = () => {
1801
+ const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
1802
+ slides.forEach((el, index) => {
1803
+ el.setAttribute('data-swiper-slide-index', index);
1804
+ });
1805
+ };
1806
+ const clearBlankSlides = () => {
1807
+ const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
1808
+ slides.forEach(el => {
1809
+ el.remove();
1810
+ });
1811
+ if (slides.length > 0) {
1812
+ swiper.recalcSlides();
1813
+ swiper.updateSlides();
1814
+ }
1815
+ };
1816
+ const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
1817
+ if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
1818
+ clearBlankSlides();
1819
+ }
1820
+ const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
1821
+ const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
1822
+ const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
1823
+ const addBlankSlides = amountOfSlides => {
1824
+ for (let i = 0; i < amountOfSlides; i += 1) {
1825
+ const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
1826
+ swiper.slidesEl.append(slideEl);
1827
+ }
1828
+ };
1829
+ if (shouldFillGroup) {
1830
+ if (params.loopAddBlankSlides) {
1831
+ const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
1832
+ addBlankSlides(slidesToAdd);
1833
+ swiper.recalcSlides();
1834
+ swiper.updateSlides();
1835
+ } else {
1836
+ showWarning('Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
1837
+ }
1838
+ initSlides();
1839
+ } else if (shouldFillGrid) {
1840
+ if (params.loopAddBlankSlides) {
1841
+ const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
1842
+ addBlankSlides(slidesToAdd);
1843
+ swiper.recalcSlides();
1844
+ swiper.updateSlides();
1845
+ } else {
1846
+ showWarning('Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
1847
+ }
1848
+ initSlides();
1849
+ } else {
1850
+ initSlides();
1851
+ }
1852
+ const bothDirections = params.centeredSlides || !!params.slidesOffsetBefore || !!params.slidesOffsetAfter;
1853
+ swiper.loopFix({
1854
+ slideRealIndex,
1855
+ direction: bothDirections ? undefined : 'next',
1856
+ initial
1857
+ });
1858
+ }
1859
+
1860
+ function loopFix({
1861
+ slideRealIndex,
1862
+ slideTo = true,
1863
+ direction,
1864
+ setTranslate,
1865
+ activeSlideIndex,
1866
+ initial,
1867
+ byController,
1868
+ byMousewheel
1869
+ } = {}) {
1870
+ const swiper = this;
1871
+ if (!swiper.params.loop) return;
1872
+ swiper.emit('beforeLoopFix');
1873
+ const {
1874
+ slides,
1875
+ allowSlidePrev,
1876
+ allowSlideNext,
1877
+ slidesEl,
1878
+ params
1879
+ } = swiper;
1880
+ const {
1881
+ centeredSlides,
1882
+ slidesOffsetBefore,
1883
+ slidesOffsetAfter,
1884
+ initialSlide
1885
+ } = params;
1886
+ const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
1887
+ swiper.allowSlidePrev = true;
1888
+ swiper.allowSlideNext = true;
1889
+ if (swiper.virtual && params.virtual.enabled) {
1890
+ if (slideTo) {
1891
+ if (!bothDirections && swiper.snapIndex === 0) {
1892
+ swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
1893
+ } else if (bothDirections && swiper.snapIndex < params.slidesPerView) {
1894
+ swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
1895
+ } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
1896
+ swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
1897
+ }
1898
+ }
1899
+ swiper.allowSlidePrev = allowSlidePrev;
1900
+ swiper.allowSlideNext = allowSlideNext;
1901
+ swiper.emit('loopFix');
1902
+ return;
1903
+ }
1904
+ let slidesPerView = params.slidesPerView;
1905
+ if (slidesPerView === 'auto') {
1906
+ slidesPerView = swiper.slidesPerViewDynamic();
1907
+ } else {
1908
+ slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
1909
+ if (bothDirections && slidesPerView % 2 === 0) {
1910
+ slidesPerView = slidesPerView + 1;
1911
+ }
1912
+ }
1913
+ const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
1914
+ let loopedSlides = bothDirections ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
1915
+ if (loopedSlides % slidesPerGroup !== 0) {
1916
+ loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
1917
+ }
1918
+ loopedSlides += params.loopAdditionalSlides;
1919
+ swiper.loopedSlides = loopedSlides;
1920
+ const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
1921
+ if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
1922
+ showWarning('Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters');
1923
+ } else if (gridEnabled && params.grid.fill === 'row') {
1924
+ showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
1925
+ }
1926
+ const prependSlidesIndexes = [];
1927
+ const appendSlidesIndexes = [];
1928
+ const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
1929
+ const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !bothDirections;
1930
+ let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
1931
+ if (typeof activeSlideIndex === 'undefined') {
1932
+ activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
1933
+ } else {
1934
+ activeIndex = activeSlideIndex;
1935
+ }
1936
+ const isNext = direction === 'next' || !direction;
1937
+ const isPrev = direction === 'prev' || !direction;
1938
+ let slidesPrepended = 0;
1939
+ let slidesAppended = 0;
1940
+ const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
1941
+ const activeColIndexWithShift = activeColIndex + (bothDirections && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
1942
+ // prepend last slides before start
1943
+ if (activeColIndexWithShift < loopedSlides) {
1944
+ slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
1945
+ for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
1946
+ const index = i - Math.floor(i / cols) * cols;
1947
+ if (gridEnabled) {
1948
+ const colIndexToPrepend = cols - index - 1;
1949
+ for (let i = slides.length - 1; i >= 0; i -= 1) {
1950
+ if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
1951
+ }
1952
+ // slides.forEach((slide, slideIndex) => {
1953
+ // if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
1954
+ // });
1955
+ } else {
1956
+ prependSlidesIndexes.push(cols - index - 1);
1957
+ }
1958
+ }
1959
+ } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
1960
+ slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
1961
+ if (isInitialOverflow) {
1962
+ slidesAppended = Math.max(slidesAppended, slidesPerView - cols + initialSlide + 1);
1963
+ }
1964
+ for (let i = 0; i < slidesAppended; i += 1) {
1965
+ const index = i - Math.floor(i / cols) * cols;
1966
+ if (gridEnabled) {
1967
+ slides.forEach((slide, slideIndex) => {
1968
+ if (slide.column === index) appendSlidesIndexes.push(slideIndex);
1969
+ });
1970
+ } else {
1971
+ appendSlidesIndexes.push(index);
1972
+ }
1973
+ }
1974
+ }
1975
+ swiper.__preventObserver__ = true;
1976
+ requestAnimationFrame(() => {
1977
+ swiper.__preventObserver__ = false;
1978
+ });
1979
+ if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
1980
+ if (appendSlidesIndexes.includes(activeSlideIndex)) {
1981
+ appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
1982
+ }
1983
+ if (prependSlidesIndexes.includes(activeSlideIndex)) {
1984
+ prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
1985
+ }
1986
+ }
1987
+ if (isPrev) {
1988
+ prependSlidesIndexes.forEach(index => {
1989
+ slides[index].swiperLoopMoveDOM = true;
1990
+ slidesEl.prepend(slides[index]);
1991
+ slides[index].swiperLoopMoveDOM = false;
1992
+ });
1993
+ }
1994
+ if (isNext) {
1995
+ appendSlidesIndexes.forEach(index => {
1996
+ slides[index].swiperLoopMoveDOM = true;
1997
+ slidesEl.append(slides[index]);
1998
+ slides[index].swiperLoopMoveDOM = false;
1999
+ });
2000
+ }
2001
+ swiper.recalcSlides();
2002
+ if (params.slidesPerView === 'auto') {
2003
+ swiper.updateSlides();
2004
+ } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
2005
+ swiper.slides.forEach((slide, slideIndex) => {
2006
+ swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
2007
+ });
2008
+ }
2009
+ if (params.watchSlidesProgress) {
2010
+ swiper.updateSlidesOffset();
2011
+ }
2012
+ if (slideTo) {
2013
+ if (prependSlidesIndexes.length > 0 && isPrev) {
2014
+ if (typeof slideRealIndex === 'undefined') {
2015
+ const currentSlideTranslate = swiper.slidesGrid[activeIndex];
2016
+ const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
2017
+ const diff = newSlideTranslate - currentSlideTranslate;
2018
+ if (byMousewheel) {
2019
+ swiper.setTranslate(swiper.translate - diff);
2020
+ } else {
2021
+ swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
2022
+ if (setTranslate) {
2023
+ swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
2024
+ swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
2025
+ }
2026
+ }
2027
+ } else {
2028
+ if (setTranslate) {
2029
+ const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
2030
+ swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
2031
+ swiper.touchEventsData.currentTranslate = swiper.translate;
2032
+ }
2033
+ }
2034
+ } else if (appendSlidesIndexes.length > 0 && isNext) {
2035
+ if (typeof slideRealIndex === 'undefined') {
2036
+ const currentSlideTranslate = swiper.slidesGrid[activeIndex];
2037
+ const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
2038
+ const diff = newSlideTranslate - currentSlideTranslate;
2039
+ if (byMousewheel) {
2040
+ swiper.setTranslate(swiper.translate - diff);
2041
+ } else {
2042
+ swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
2043
+ if (setTranslate) {
2044
+ swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
2045
+ swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
2046
+ }
2047
+ }
2048
+ } else {
2049
+ const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
2050
+ swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
2051
+ }
2052
+ }
2053
+ }
2054
+ swiper.allowSlidePrev = allowSlidePrev;
2055
+ swiper.allowSlideNext = allowSlideNext;
2056
+ if (swiper.controller && swiper.controller.control && !byController) {
2057
+ const loopParams = {
2058
+ slideRealIndex,
2059
+ direction,
2060
+ setTranslate,
2061
+ activeSlideIndex,
2062
+ byController: true
2063
+ };
2064
+ if (Array.isArray(swiper.controller.control)) {
2065
+ swiper.controller.control.forEach(c => {
2066
+ if (!c.destroyed && c.params.loop) c.loopFix({
2067
+ ...loopParams,
2068
+ slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
2069
+ });
2070
+ });
2071
+ } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
2072
+ swiper.controller.control.loopFix({
2073
+ ...loopParams,
2074
+ slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
2075
+ });
2076
+ }
2077
+ }
2078
+ swiper.emit('loopFix');
2079
+ }
2080
+
2081
+ function loopDestroy() {
2082
+ const swiper = this;
2083
+ const {
2084
+ params,
2085
+ slidesEl
2086
+ } = swiper;
2087
+ if (!params.loop || !slidesEl || swiper.virtual && swiper.params.virtual.enabled) return;
2088
+ swiper.recalcSlides();
2089
+ const newSlidesOrder = [];
2090
+ swiper.slides.forEach(slideEl => {
2091
+ const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
2092
+ newSlidesOrder[index] = slideEl;
2093
+ });
2094
+ swiper.slides.forEach(slideEl => {
2095
+ slideEl.removeAttribute('data-swiper-slide-index');
2096
+ });
2097
+ newSlidesOrder.forEach(slideEl => {
2098
+ slidesEl.append(slideEl);
2099
+ });
2100
+ swiper.recalcSlides();
2101
+ swiper.slideTo(swiper.realIndex, 0);
2102
+ }
2103
+
2104
+ var loop = {
2105
+ loopCreate,
2106
+ loopFix,
2107
+ loopDestroy
2108
+ };
2109
+
2110
+ function setGrabCursor(moving) {
2111
+ const swiper = this;
2112
+ if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
2113
+ const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
2114
+ if (swiper.isElement) {
2115
+ swiper.__preventObserver__ = true;
2116
+ }
2117
+ el.style.cursor = 'move';
2118
+ el.style.cursor = moving ? 'grabbing' : 'grab';
2119
+ if (swiper.isElement) {
2120
+ requestAnimationFrame(() => {
2121
+ swiper.__preventObserver__ = false;
2122
+ });
2123
+ }
2124
+ }
2125
+
2126
+ function unsetGrabCursor() {
2127
+ const swiper = this;
2128
+ if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
2129
+ return;
2130
+ }
2131
+ if (swiper.isElement) {
2132
+ swiper.__preventObserver__ = true;
2133
+ }
2134
+ swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
2135
+ if (swiper.isElement) {
2136
+ requestAnimationFrame(() => {
2137
+ swiper.__preventObserver__ = false;
2138
+ });
2139
+ }
2140
+ }
2141
+
2142
+ var grabCursor = {
2143
+ setGrabCursor,
2144
+ unsetGrabCursor
2145
+ };
2146
+
2147
+ // Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
2148
+ function closestElement(selector, base = this) {
2149
+ function __closestFrom(el) {
2150
+ if (!el || el === getDocument() || el === getWindow()) return null;
2151
+ if (el.assignedSlot) el = el.assignedSlot;
2152
+ const found = el.closest(selector);
2153
+ if (!found && !el.getRootNode) {
2154
+ return null;
2155
+ }
2156
+ return found || __closestFrom(el.getRootNode().host);
2157
+ }
2158
+ return __closestFrom(base);
2159
+ }
2160
+ function preventEdgeSwipe(swiper, event, startX) {
2161
+ const window = getWindow();
2162
+ const {
2163
+ params
2164
+ } = swiper;
2165
+ const edgeSwipeDetection = params.edgeSwipeDetection;
2166
+ const edgeSwipeThreshold = params.edgeSwipeThreshold;
2167
+ if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
2168
+ if (edgeSwipeDetection === 'prevent') {
2169
+ event.preventDefault();
2170
+ return true;
2171
+ }
2172
+ return false;
2173
+ }
2174
+ return true;
2175
+ }
2176
+ function onTouchStart(event) {
2177
+ const swiper = this;
2178
+ const document = getDocument();
2179
+ let e = event;
2180
+ if (e.originalEvent) e = e.originalEvent;
2181
+ const data = swiper.touchEventsData;
2182
+ if (e.type === 'pointerdown') {
2183
+ if (data.pointerId !== null && data.pointerId !== e.pointerId) {
2184
+ return;
2185
+ }
2186
+ data.pointerId = e.pointerId;
2187
+ } else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
2188
+ data.touchId = e.targetTouches[0].identifier;
2189
+ }
2190
+ if (e.type === 'touchstart') {
2191
+ // don't proceed touch event
2192
+ preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
2193
+ return;
2194
+ }
2195
+ const {
2196
+ params,
2197
+ touches,
2198
+ enabled
2199
+ } = swiper;
2200
+ if (!enabled) return;
2201
+ if (!params.simulateTouch && e.pointerType === 'mouse') return;
2202
+ if (swiper.animating && params.preventInteractionOnTransition) {
2203
+ return;
2204
+ }
2205
+ if (!swiper.animating && params.cssMode && params.loop) {
2206
+ swiper.loopFix();
2207
+ }
2208
+ let targetEl = e.target;
2209
+ if (params.touchEventsTarget === 'wrapper') {
2210
+ if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
2211
+ }
2212
+ if ('which' in e && e.which === 3) return;
2213
+ if ('button' in e && e.button > 0) return;
2214
+ if (data.isTouched && data.isMoved) return;
2215
+
2216
+ // change target el for shadow root component
2217
+ const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
2218
+ // eslint-disable-next-line
2219
+ const eventPath = e.composedPath ? e.composedPath() : e.path;
2220
+ if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
2221
+ targetEl = eventPath[0];
2222
+ }
2223
+ const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
2224
+ const isTargetShadow = !!(e.target && e.target.shadowRoot);
2225
+
2226
+ // use closestElement for shadow root element to get the actual closest for nested shadow root element
2227
+ if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
2228
+ swiper.allowClick = true;
2229
+ return;
2230
+ }
2231
+ if (params.swipeHandler) {
2232
+ if (!targetEl.closest(params.swipeHandler)) return;
2233
+ }
2234
+ touches.currentX = e.pageX;
2235
+ touches.currentY = e.pageY;
2236
+ const startX = touches.currentX;
2237
+ const startY = touches.currentY;
2238
+
2239
+ // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
2240
+
2241
+ if (!preventEdgeSwipe(swiper, e, startX)) {
2242
+ return;
2243
+ }
2244
+ Object.assign(data, {
2245
+ isTouched: true,
2246
+ isMoved: false,
2247
+ allowTouchCallbacks: true,
2248
+ isScrolling: undefined,
2249
+ startMoving: undefined
2250
+ });
2251
+ touches.startX = startX;
2252
+ touches.startY = startY;
2253
+ data.touchStartTime = now();
2254
+ swiper.allowClick = true;
2255
+ swiper.updateSize();
2256
+ swiper.swipeDirection = undefined;
2257
+ if (params.threshold > 0) data.allowThresholdMove = false;
2258
+ let preventDefault = true;
2259
+ if (targetEl.matches(data.focusableElements)) {
2260
+ preventDefault = false;
2261
+ if (targetEl.nodeName === 'SELECT') {
2262
+ data.isTouched = false;
2263
+ }
2264
+ }
2265
+ if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl && (e.pointerType === 'mouse' || e.pointerType !== 'mouse' && !targetEl.matches(data.focusableElements))) {
2266
+ document.activeElement.blur();
2267
+ }
2268
+ const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
2269
+ if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
2270
+ e.preventDefault();
2271
+ }
2272
+ if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
2273
+ swiper.freeMode.onTouchStart();
2274
+ }
2275
+ swiper.emit('touchStart', e);
2276
+ }
2277
+
2278
+ function onTouchMove(event) {
2279
+ const document = getDocument();
2280
+ const swiper = this;
2281
+ const data = swiper.touchEventsData;
2282
+ const {
2283
+ params,
2284
+ touches,
2285
+ rtlTranslate: rtl,
2286
+ enabled
2287
+ } = swiper;
2288
+ if (!enabled) return;
2289
+ if (!params.simulateTouch && event.pointerType === 'mouse') return;
2290
+ let e = event;
2291
+ if (e.originalEvent) e = e.originalEvent;
2292
+ if (e.type === 'pointermove') {
2293
+ if (data.touchId !== null) return; // return from pointer if we use touch
2294
+ const id = e.pointerId;
2295
+ if (id !== data.pointerId) return;
2296
+ }
2297
+ let targetTouch;
2298
+ if (e.type === 'touchmove') {
2299
+ targetTouch = [...e.changedTouches].find(t => t.identifier === data.touchId);
2300
+ if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2301
+ } else {
2302
+ targetTouch = e;
2303
+ }
2304
+ if (!data.isTouched) {
2305
+ if (data.startMoving && data.isScrolling) {
2306
+ swiper.emit('touchMoveOpposite', e);
2307
+ }
2308
+ return;
2309
+ }
2310
+ const pageX = targetTouch.pageX;
2311
+ const pageY = targetTouch.pageY;
2312
+ if (e.preventedByNestedSwiper) {
2313
+ touches.startX = pageX;
2314
+ touches.startY = pageY;
2315
+ return;
2316
+ }
2317
+ if (!swiper.allowTouchMove) {
2318
+ if (!e.target.matches(data.focusableElements)) {
2319
+ swiper.allowClick = false;
2320
+ }
2321
+ if (data.isTouched) {
2322
+ Object.assign(touches, {
2323
+ startX: pageX,
2324
+ startY: pageY,
2325
+ currentX: pageX,
2326
+ currentY: pageY
2327
+ });
2328
+ data.touchStartTime = now();
2329
+ }
2330
+ return;
2331
+ }
2332
+ if (params.touchReleaseOnEdges && !params.loop) {
2333
+ if (swiper.isVertical()) {
2334
+ // Vertical
2335
+ if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
2336
+ data.isTouched = false;
2337
+ data.isMoved = false;
2338
+ return;
2339
+ }
2340
+ } else if (rtl && (pageX > touches.startX && -swiper.translate <= swiper.maxTranslate() || pageX < touches.startX && -swiper.translate >= swiper.minTranslate())) {
2341
+ return;
2342
+ } else if (!rtl && (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate())) {
2343
+ return;
2344
+ }
2345
+ }
2346
+ if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== e.target && e.pointerType !== 'mouse') {
2347
+ document.activeElement.blur();
2348
+ }
2349
+ if (document.activeElement) {
2350
+ if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
2351
+ data.isMoved = true;
2352
+ swiper.allowClick = false;
2353
+ return;
2354
+ }
2355
+ }
2356
+ if (data.allowTouchCallbacks) {
2357
+ swiper.emit('touchMove', e);
2358
+ }
2359
+ touches.previousX = touches.currentX;
2360
+ touches.previousY = touches.currentY;
2361
+ touches.currentX = pageX;
2362
+ touches.currentY = pageY;
2363
+ const diffX = touches.currentX - touches.startX;
2364
+ const diffY = touches.currentY - touches.startY;
2365
+ if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
2366
+ if (typeof data.isScrolling === 'undefined') {
2367
+ let touchAngle;
2368
+ if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
2369
+ data.isScrolling = false;
2370
+ } else {
2371
+ // eslint-disable-next-line
2372
+ if (diffX * diffX + diffY * diffY >= 25) {
2373
+ touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
2374
+ data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
2375
+ }
2376
+ }
2377
+ }
2378
+ if (data.isScrolling) {
2379
+ swiper.emit('touchMoveOpposite', e);
2380
+ }
2381
+ if (typeof data.startMoving === 'undefined') {
2382
+ if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
2383
+ data.startMoving = true;
2384
+ }
2385
+ }
2386
+ if (data.isScrolling || e.type === 'touchmove' && data.preventTouchMoveFromPointerMove) {
2387
+ data.isTouched = false;
2388
+ return;
2389
+ }
2390
+ if (!data.startMoving) {
2391
+ return;
2392
+ }
2393
+ swiper.allowClick = false;
2394
+ if (!params.cssMode && e.cancelable) {
2395
+ e.preventDefault();
2396
+ }
2397
+ if (params.touchMoveStopPropagation && !params.nested) {
2398
+ e.stopPropagation();
2399
+ }
2400
+ let diff = swiper.isHorizontal() ? diffX : diffY;
2401
+ let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
2402
+ if (params.oneWayMovement) {
2403
+ diff = Math.abs(diff) * (rtl ? 1 : -1);
2404
+ touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
2405
+ }
2406
+ touches.diff = diff;
2407
+ diff *= params.touchRatio;
2408
+ if (rtl) {
2409
+ diff = -diff;
2410
+ touchesDiff = -touchesDiff;
2411
+ }
2412
+ const prevTouchesDirection = swiper.touchesDirection;
2413
+ swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
2414
+ swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
2415
+ const isLoop = swiper.params.loop && !params.cssMode;
2416
+ const allowLoopFix = swiper.touchesDirection === 'next' && swiper.allowSlideNext || swiper.touchesDirection === 'prev' && swiper.allowSlidePrev;
2417
+ if (!data.isMoved) {
2418
+ if (isLoop && allowLoopFix) {
2419
+ swiper.loopFix({
2420
+ direction: swiper.swipeDirection
2421
+ });
2422
+ }
2423
+ data.startTranslate = swiper.getTranslate();
2424
+ swiper.setTransition(0);
2425
+ if (swiper.animating) {
2426
+ const evt = new window.CustomEvent('transitionend', {
2427
+ bubbles: true,
2428
+ cancelable: true,
2429
+ detail: {
2430
+ bySwiperTouchMove: true
2431
+ }
2432
+ });
2433
+ swiper.wrapperEl.dispatchEvent(evt);
2434
+ }
2435
+ data.allowMomentumBounce = false;
2436
+ // Grab Cursor
2437
+ if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
2438
+ swiper.setGrabCursor(true);
2439
+ }
2440
+ swiper.emit('sliderFirstMove', e);
2441
+ }
2442
+ new Date().getTime();
2443
+ if (params._loopSwapReset !== false && data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
2444
+ Object.assign(touches, {
2445
+ startX: pageX,
2446
+ startY: pageY,
2447
+ currentX: pageX,
2448
+ currentY: pageY,
2449
+ startTranslate: data.currentTranslate
2450
+ });
2451
+ data.loopSwapReset = true;
2452
+ data.startTranslate = data.currentTranslate;
2453
+ return;
2454
+ }
2455
+ swiper.emit('sliderMove', e);
2456
+ data.isMoved = true;
2457
+ data.currentTranslate = diff + data.startTranslate;
2458
+ let disableParentSwiper = true;
2459
+ let resistanceRatio = params.resistanceRatio;
2460
+ if (params.touchReleaseOnEdges) {
2461
+ resistanceRatio = 0;
2462
+ }
2463
+ if (diff > 0) {
2464
+ if (isLoop && allowLoopFix && true && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) {
2465
+ swiper.loopFix({
2466
+ direction: 'prev',
2467
+ setTranslate: true,
2468
+ activeSlideIndex: 0
2469
+ });
2470
+ }
2471
+ if (data.currentTranslate > swiper.minTranslate()) {
2472
+ disableParentSwiper = false;
2473
+ if (params.resistance) {
2474
+ data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
2475
+ }
2476
+ }
2477
+ } else if (diff < 0) {
2478
+ if (isLoop && allowLoopFix && true && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) {
2479
+ swiper.loopFix({
2480
+ direction: 'next',
2481
+ setTranslate: true,
2482
+ activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
2483
+ });
2484
+ }
2485
+ if (data.currentTranslate < swiper.maxTranslate()) {
2486
+ disableParentSwiper = false;
2487
+ if (params.resistance) {
2488
+ data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
2489
+ }
2490
+ }
2491
+ }
2492
+ if (disableParentSwiper) {
2493
+ e.preventedByNestedSwiper = true;
2494
+ }
2495
+
2496
+ // Directions locks
2497
+ if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
2498
+ data.currentTranslate = data.startTranslate;
2499
+ }
2500
+ if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
2501
+ data.currentTranslate = data.startTranslate;
2502
+ }
2503
+ if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
2504
+ data.currentTranslate = data.startTranslate;
2505
+ }
2506
+
2507
+ // Threshold
2508
+ if (params.threshold > 0) {
2509
+ if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
2510
+ if (!data.allowThresholdMove) {
2511
+ data.allowThresholdMove = true;
2512
+ touches.startX = touches.currentX;
2513
+ touches.startY = touches.currentY;
2514
+ data.currentTranslate = data.startTranslate;
2515
+ touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
2516
+ return;
2517
+ }
2518
+ } else {
2519
+ data.currentTranslate = data.startTranslate;
2520
+ return;
2521
+ }
2522
+ }
2523
+ if (!params.followFinger || params.cssMode) return;
2524
+
2525
+ // Update active index in free mode
2526
+ if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
2527
+ swiper.updateActiveIndex();
2528
+ swiper.updateSlidesClasses();
2529
+ }
2530
+ if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
2531
+ swiper.freeMode.onTouchMove();
2532
+ }
2533
+ // Update progress
2534
+ swiper.updateProgress(data.currentTranslate);
2535
+ // Update translate
2536
+ swiper.setTranslate(data.currentTranslate);
2537
+ }
2538
+
2539
+ function onTouchEnd(event) {
2540
+ const swiper = this;
2541
+ const data = swiper.touchEventsData;
2542
+ let e = event;
2543
+ if (e.originalEvent) e = e.originalEvent;
2544
+ let targetTouch;
2545
+ const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
2546
+ if (!isTouchEvent) {
2547
+ if (data.touchId !== null) return; // return from pointer if we use touch
2548
+ if (e.pointerId !== data.pointerId) return;
2549
+ targetTouch = e;
2550
+ } else {
2551
+ targetTouch = [...e.changedTouches].find(t => t.identifier === data.touchId);
2552
+ if (!targetTouch || targetTouch.identifier !== data.touchId) return;
2553
+ }
2554
+ if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
2555
+ const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
2556
+ if (!proceed) {
2557
+ return;
2558
+ }
2559
+ }
2560
+ data.pointerId = null;
2561
+ data.touchId = null;
2562
+ const {
2563
+ params,
2564
+ touches,
2565
+ rtlTranslate: rtl,
2566
+ slidesGrid,
2567
+ enabled
2568
+ } = swiper;
2569
+ if (!enabled) return;
2570
+ if (!params.simulateTouch && e.pointerType === 'mouse') return;
2571
+ if (data.allowTouchCallbacks) {
2572
+ swiper.emit('touchEnd', e);
2573
+ }
2574
+ data.allowTouchCallbacks = false;
2575
+ if (!data.isTouched) {
2576
+ if (data.isMoved && params.grabCursor) {
2577
+ swiper.setGrabCursor(false);
2578
+ }
2579
+ data.isMoved = false;
2580
+ data.startMoving = false;
2581
+ return;
2582
+ }
2583
+
2584
+ // Return Grab Cursor
2585
+ if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
2586
+ swiper.setGrabCursor(false);
2587
+ }
2588
+
2589
+ // Time diff
2590
+ const touchEndTime = now();
2591
+ const timeDiff = touchEndTime - data.touchStartTime;
2592
+
2593
+ // Tap, doubleTap, Click
2594
+ if (swiper.allowClick) {
2595
+ const pathTree = e.path || e.composedPath && e.composedPath();
2596
+ swiper.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree);
2597
+ swiper.emit('tap click', e);
2598
+ if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
2599
+ swiper.emit('doubleTap doubleClick', e);
2600
+ }
2601
+ }
2602
+ data.lastClickTime = now();
2603
+ nextTick(() => {
2604
+ if (!swiper.destroyed) swiper.allowClick = true;
2605
+ });
2606
+ if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
2607
+ data.isTouched = false;
2608
+ data.isMoved = false;
2609
+ data.startMoving = false;
2610
+ return;
2611
+ }
2612
+ data.isTouched = false;
2613
+ data.isMoved = false;
2614
+ data.startMoving = false;
2615
+ let currentPos;
2616
+ if (params.followFinger) {
2617
+ currentPos = rtl ? swiper.translate : -swiper.translate;
2618
+ } else {
2619
+ currentPos = -data.currentTranslate;
2620
+ }
2621
+ if (params.cssMode) {
2622
+ return;
2623
+ }
2624
+ if (params.freeMode && params.freeMode.enabled) {
2625
+ swiper.freeMode.onTouchEnd({
2626
+ currentPos
2627
+ });
2628
+ return;
2629
+ }
2630
+
2631
+ // Find current slide
2632
+ const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
2633
+ let stopIndex = 0;
2634
+ let groupSize = swiper.slidesSizesGrid[0];
2635
+ for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
2636
+ const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2637
+ if (typeof slidesGrid[i + increment] !== 'undefined') {
2638
+ if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
2639
+ stopIndex = i;
2640
+ groupSize = slidesGrid[i + increment] - slidesGrid[i];
2641
+ }
2642
+ } else if (swipeToLast || currentPos >= slidesGrid[i]) {
2643
+ stopIndex = i;
2644
+ groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
2645
+ }
2646
+ }
2647
+ let rewindFirstIndex = null;
2648
+ let rewindLastIndex = null;
2649
+ if (params.rewind) {
2650
+ if (swiper.isBeginning) {
2651
+ rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
2652
+ } else if (swiper.isEnd) {
2653
+ rewindFirstIndex = 0;
2654
+ }
2655
+ }
2656
+ // Find current slide size
2657
+ const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
2658
+ const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
2659
+ if (timeDiff > params.longSwipesMs) {
2660
+ // Long touches
2661
+ if (!params.longSwipes) {
2662
+ swiper.slideTo(swiper.activeIndex);
2663
+ return;
2664
+ }
2665
+ if (swiper.swipeDirection === 'next') {
2666
+ if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
2667
+ }
2668
+ if (swiper.swipeDirection === 'prev') {
2669
+ if (ratio > 1 - params.longSwipesRatio) {
2670
+ swiper.slideTo(stopIndex + increment);
2671
+ } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
2672
+ swiper.slideTo(rewindLastIndex);
2673
+ } else {
2674
+ swiper.slideTo(stopIndex);
2675
+ }
2676
+ }
2677
+ } else {
2678
+ // Short swipes
2679
+ if (!params.shortSwipes) {
2680
+ swiper.slideTo(swiper.activeIndex);
2681
+ return;
2682
+ }
2683
+ const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
2684
+ if (!isNavButtonTarget) {
2685
+ if (swiper.swipeDirection === 'next') {
2686
+ swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
2687
+ }
2688
+ if (swiper.swipeDirection === 'prev') {
2689
+ swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
2690
+ }
2691
+ } else if (e.target === swiper.navigation.nextEl) {
2692
+ swiper.slideTo(stopIndex + increment);
2693
+ } else {
2694
+ swiper.slideTo(stopIndex);
2695
+ }
2696
+ }
2697
+ }
2698
+
2699
+ function onResize() {
2700
+ const swiper = this;
2701
+ const {
2702
+ params,
2703
+ el
2704
+ } = swiper;
2705
+ if (el && el.offsetWidth === 0) return;
2706
+
2707
+ // Breakpoints
2708
+ if (params.breakpoints) {
2709
+ swiper.setBreakpoint();
2710
+ }
2711
+
2712
+ // Save locks
2713
+ const {
2714
+ allowSlideNext,
2715
+ allowSlidePrev,
2716
+ snapGrid
2717
+ } = swiper;
2718
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2719
+
2720
+ // Disable locks on resize
2721
+ swiper.allowSlideNext = true;
2722
+ swiper.allowSlidePrev = true;
2723
+ swiper.updateSize();
2724
+ swiper.updateSlides();
2725
+ swiper.updateSlidesClasses();
2726
+ const isVirtualLoop = isVirtual && params.loop;
2727
+ if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
2728
+ swiper.slideTo(swiper.slides.length - 1, 0, false, true);
2729
+ } else {
2730
+ if (swiper.params.loop && !isVirtual) {
2731
+ swiper.slideToLoop(swiper.realIndex, 0, false, true);
2732
+ } else {
2733
+ swiper.slideTo(swiper.activeIndex, 0, false, true);
2734
+ }
2735
+ }
2736
+ if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
2737
+ clearTimeout(swiper.autoplay.resizeTimeout);
2738
+ swiper.autoplay.resizeTimeout = setTimeout(() => {
2739
+ if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
2740
+ swiper.autoplay.resume();
2741
+ }
2742
+ }, 500);
2743
+ }
2744
+ // Return locks after resize
2745
+ swiper.allowSlidePrev = allowSlidePrev;
2746
+ swiper.allowSlideNext = allowSlideNext;
2747
+ if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
2748
+ swiper.checkOverflow();
2749
+ }
2750
+ }
2751
+
2752
+ function onClick(e) {
2753
+ const swiper = this;
2754
+ if (!swiper.enabled) return;
2755
+ if (!swiper.allowClick) {
2756
+ if (swiper.params.preventClicks) e.preventDefault();
2757
+ if (swiper.params.preventClicksPropagation && swiper.animating) {
2758
+ e.stopPropagation();
2759
+ e.stopImmediatePropagation();
2760
+ }
2761
+ }
2762
+ }
2763
+
2764
+ function onScroll() {
2765
+ const swiper = this;
2766
+ const {
2767
+ wrapperEl,
2768
+ rtlTranslate,
2769
+ enabled
2770
+ } = swiper;
2771
+ if (!enabled) return;
2772
+ swiper.previousTranslate = swiper.translate;
2773
+ if (swiper.isHorizontal()) {
2774
+ swiper.translate = -wrapperEl.scrollLeft;
2775
+ } else {
2776
+ swiper.translate = -wrapperEl.scrollTop;
2777
+ }
2778
+ // eslint-disable-next-line
2779
+ if (swiper.translate === 0) swiper.translate = 0;
2780
+ swiper.updateActiveIndex();
2781
+ swiper.updateSlidesClasses();
2782
+ let newProgress;
2783
+ const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2784
+ if (translatesDiff === 0) {
2785
+ newProgress = 0;
2786
+ } else {
2787
+ newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
2788
+ }
2789
+ if (newProgress !== swiper.progress) {
2790
+ swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
2791
+ }
2792
+ swiper.emit('setTranslate', swiper.translate, false);
2793
+ }
2794
+
2795
+ function onLoad(e) {
2796
+ const swiper = this;
2797
+ processLazyPreloader(swiper, e.target);
2798
+ if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
2799
+ return;
2800
+ }
2801
+ swiper.update();
2802
+ }
2803
+
2804
+ function onDocumentTouchStart() {
2805
+ const swiper = this;
2806
+ if (swiper.documentTouchHandlerProceeded) return;
2807
+ swiper.documentTouchHandlerProceeded = true;
2808
+ if (swiper.params.touchReleaseOnEdges) {
2809
+ swiper.el.style.touchAction = 'auto';
2810
+ }
2811
+ }
2812
+
2813
+ const events = (swiper, method) => {
2814
+ const document = getDocument();
2815
+ const {
2816
+ params,
2817
+ el,
2818
+ wrapperEl,
2819
+ device
2820
+ } = swiper;
2821
+ const capture = !!params.nested;
2822
+ const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
2823
+ const swiperMethod = method;
2824
+ if (!el || typeof el === 'string') return;
2825
+
2826
+ // Touch Events
2827
+ document[domMethod]('touchstart', swiper.onDocumentTouchStart, {
2828
+ passive: false,
2829
+ capture
2830
+ });
2831
+ el[domMethod]('touchstart', swiper.onTouchStart, {
2832
+ passive: false
2833
+ });
2834
+ el[domMethod]('pointerdown', swiper.onTouchStart, {
2835
+ passive: false
2836
+ });
2837
+ document[domMethod]('touchmove', swiper.onTouchMove, {
2838
+ passive: false,
2839
+ capture
2840
+ });
2841
+ document[domMethod]('pointermove', swiper.onTouchMove, {
2842
+ passive: false,
2843
+ capture
2844
+ });
2845
+ document[domMethod]('touchend', swiper.onTouchEnd, {
2846
+ passive: true
2847
+ });
2848
+ document[domMethod]('pointerup', swiper.onTouchEnd, {
2849
+ passive: true
2850
+ });
2851
+ document[domMethod]('pointercancel', swiper.onTouchEnd, {
2852
+ passive: true
2853
+ });
2854
+ document[domMethod]('touchcancel', swiper.onTouchEnd, {
2855
+ passive: true
2856
+ });
2857
+ document[domMethod]('pointerout', swiper.onTouchEnd, {
2858
+ passive: true
2859
+ });
2860
+ document[domMethod]('pointerleave', swiper.onTouchEnd, {
2861
+ passive: true
2862
+ });
2863
+ document[domMethod]('contextmenu', swiper.onTouchEnd, {
2864
+ passive: true
2865
+ });
2866
+
2867
+ // Prevent Links Clicks
2868
+ if (params.preventClicks || params.preventClicksPropagation) {
2869
+ el[domMethod]('click', swiper.onClick, true);
2870
+ }
2871
+ if (params.cssMode) {
2872
+ wrapperEl[domMethod]('scroll', swiper.onScroll);
2873
+ }
2874
+
2875
+ // Resize handler
2876
+ if (params.updateOnWindowResize) {
2877
+ swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
2878
+ } else {
2879
+ swiper[swiperMethod]('observerUpdate', onResize, true);
2880
+ }
2881
+
2882
+ // Images loader
2883
+ el[domMethod]('load', swiper.onLoad, {
2884
+ capture: true
2885
+ });
2886
+ };
2887
+ function attachEvents() {
2888
+ const swiper = this;
2889
+ const {
2890
+ params
2891
+ } = swiper;
2892
+ swiper.onTouchStart = onTouchStart.bind(swiper);
2893
+ swiper.onTouchMove = onTouchMove.bind(swiper);
2894
+ swiper.onTouchEnd = onTouchEnd.bind(swiper);
2895
+ swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
2896
+ if (params.cssMode) {
2897
+ swiper.onScroll = onScroll.bind(swiper);
2898
+ }
2899
+ swiper.onClick = onClick.bind(swiper);
2900
+ swiper.onLoad = onLoad.bind(swiper);
2901
+ events(swiper, 'on');
2902
+ }
2903
+ function detachEvents() {
2904
+ const swiper = this;
2905
+ events(swiper, 'off');
2906
+ }
2907
+ var events$1 = {
2908
+ attachEvents,
2909
+ detachEvents
2910
+ };
2911
+
2912
+ const isGridEnabled = (swiper, params) => {
2913
+ return swiper.grid && params.grid && params.grid.rows > 1;
2914
+ };
2915
+ function setBreakpoint() {
2916
+ const swiper = this;
2917
+ const {
2918
+ realIndex,
2919
+ initialized,
2920
+ params,
2921
+ el
2922
+ } = swiper;
2923
+ const breakpoints = params.breakpoints;
2924
+ if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
2925
+ const document = getDocument();
2926
+
2927
+ // Get breakpoint for window/container width and update parameters
2928
+ const breakpointsBase = params.breakpointsBase === 'window' || !params.breakpointsBase ? params.breakpointsBase : 'container';
2929
+ const breakpointContainer = ['window', 'container'].includes(params.breakpointsBase) || !params.breakpointsBase ? swiper.el : document.querySelector(params.breakpointsBase);
2930
+ const breakpoint = swiper.getBreakpoint(breakpoints, breakpointsBase, breakpointContainer);
2931
+ if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
2932
+ const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
2933
+ const breakpointParams = breakpointOnlyParams || swiper.originalParams;
2934
+ const wasMultiRow = isGridEnabled(swiper, params);
2935
+ const isMultiRow = isGridEnabled(swiper, breakpointParams);
2936
+ const wasGrabCursor = swiper.params.grabCursor;
2937
+ const isGrabCursor = breakpointParams.grabCursor;
2938
+ const wasEnabled = params.enabled;
2939
+ if (wasMultiRow && !isMultiRow) {
2940
+ el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
2941
+ swiper.emitContainerClasses();
2942
+ } else if (!wasMultiRow && isMultiRow) {
2943
+ el.classList.add(`${params.containerModifierClass}grid`);
2944
+ if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
2945
+ el.classList.add(`${params.containerModifierClass}grid-column`);
2946
+ }
2947
+ swiper.emitContainerClasses();
2948
+ }
2949
+ if (wasGrabCursor && !isGrabCursor) {
2950
+ swiper.unsetGrabCursor();
2951
+ } else if (!wasGrabCursor && isGrabCursor) {
2952
+ swiper.setGrabCursor();
2953
+ }
2954
+
2955
+ // Toggle navigation, pagination, scrollbar
2956
+ ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
2957
+ if (typeof breakpointParams[prop] === 'undefined') return;
2958
+ const wasModuleEnabled = params[prop] && params[prop].enabled;
2959
+ const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
2960
+ if (wasModuleEnabled && !isModuleEnabled) {
2961
+ swiper[prop].disable();
2962
+ }
2963
+ if (!wasModuleEnabled && isModuleEnabled) {
2964
+ swiper[prop].enable();
2965
+ }
2966
+ });
2967
+ const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
2968
+ const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
2969
+ const wasLoop = params.loop;
2970
+ if (directionChanged && initialized) {
2971
+ swiper.changeDirection();
2972
+ }
2973
+ extend(swiper.params, breakpointParams);
2974
+ const isEnabled = swiper.params.enabled;
2975
+ const hasLoop = swiper.params.loop;
2976
+ Object.assign(swiper, {
2977
+ allowTouchMove: swiper.params.allowTouchMove,
2978
+ allowSlideNext: swiper.params.allowSlideNext,
2979
+ allowSlidePrev: swiper.params.allowSlidePrev
2980
+ });
2981
+ if (wasEnabled && !isEnabled) {
2982
+ swiper.disable();
2983
+ } else if (!wasEnabled && isEnabled) {
2984
+ swiper.enable();
2985
+ }
2986
+ swiper.currentBreakpoint = breakpoint;
2987
+ swiper.emit('_beforeBreakpoint', breakpointParams);
2988
+ if (initialized) {
2989
+ if (needsReLoop) {
2990
+ swiper.loopDestroy();
2991
+ swiper.loopCreate(realIndex);
2992
+ swiper.updateSlides();
2993
+ } else if (!wasLoop && hasLoop) {
2994
+ swiper.loopCreate(realIndex);
2995
+ swiper.updateSlides();
2996
+ } else if (wasLoop && !hasLoop) {
2997
+ swiper.loopDestroy();
2998
+ }
2999
+ }
3000
+ swiper.emit('breakpoint', breakpointParams);
3001
+ }
3002
+
3003
+ function getBreakpoint(breakpoints, base = 'window', containerEl) {
3004
+ if (!breakpoints || base === 'container' && !containerEl) return undefined;
3005
+ let breakpoint = false;
3006
+ const window = getWindow();
3007
+ const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
3008
+ const points = Object.keys(breakpoints).map(point => {
3009
+ if (typeof point === 'string' && point.indexOf('@') === 0) {
3010
+ const minRatio = parseFloat(point.substr(1));
3011
+ const value = currentHeight * minRatio;
3012
+ return {
3013
+ value,
3014
+ point
3015
+ };
3016
+ }
3017
+ return {
3018
+ value: point,
3019
+ point
3020
+ };
3021
+ });
3022
+ points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
3023
+ for (let i = 0; i < points.length; i += 1) {
3024
+ const {
3025
+ point,
3026
+ value
3027
+ } = points[i];
3028
+ if (base === 'window') {
3029
+ if (window.matchMedia(`(min-width: ${value}px)`).matches) {
3030
+ breakpoint = point;
3031
+ }
3032
+ } else if (value <= containerEl.clientWidth) {
3033
+ breakpoint = point;
3034
+ }
3035
+ }
3036
+ return breakpoint || 'max';
3037
+ }
3038
+
3039
+ var breakpoints = {
3040
+ setBreakpoint,
3041
+ getBreakpoint
3042
+ };
3043
+
3044
+ function prepareClasses(entries, prefix) {
3045
+ const resultClasses = [];
3046
+ entries.forEach(item => {
3047
+ if (typeof item === 'object') {
3048
+ Object.keys(item).forEach(classNames => {
3049
+ if (item[classNames]) {
3050
+ resultClasses.push(prefix + classNames);
3051
+ }
3052
+ });
3053
+ } else if (typeof item === 'string') {
3054
+ resultClasses.push(prefix + item);
3055
+ }
3056
+ });
3057
+ return resultClasses;
3058
+ }
3059
+ function addClasses() {
3060
+ const swiper = this;
3061
+ const {
3062
+ classNames,
3063
+ params,
3064
+ rtl,
3065
+ el,
3066
+ device
3067
+ } = swiper;
3068
+ // prettier-ignore
3069
+ const suffixes = prepareClasses(['initialized', params.direction, {
3070
+ 'free-mode': swiper.params.freeMode && params.freeMode.enabled
3071
+ }, {
3072
+ 'autoheight': params.autoHeight
3073
+ }, {
3074
+ 'rtl': rtl
3075
+ }, {
3076
+ 'grid': params.grid && params.grid.rows > 1
3077
+ }, {
3078
+ 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
3079
+ }, {
3080
+ 'android': device.android
3081
+ }, {
3082
+ 'ios': device.ios
3083
+ }, {
3084
+ 'css-mode': params.cssMode
3085
+ }, {
3086
+ 'centered': params.cssMode && params.centeredSlides
3087
+ }, {
3088
+ 'watch-progress': params.watchSlidesProgress
3089
+ }], params.containerModifierClass);
3090
+ classNames.push(...suffixes);
3091
+ el.classList.add(...classNames);
3092
+ swiper.emitContainerClasses();
3093
+ }
3094
+
3095
+ function removeClasses() {
3096
+ const swiper = this;
3097
+ const {
3098
+ el,
3099
+ classNames
3100
+ } = swiper;
3101
+ if (!el || typeof el === 'string') return;
3102
+ el.classList.remove(...classNames);
3103
+ swiper.emitContainerClasses();
3104
+ }
3105
+
3106
+ var classes = {
3107
+ addClasses,
3108
+ removeClasses
3109
+ };
3110
+
3111
+ function checkOverflow() {
3112
+ const swiper = this;
3113
+ const {
3114
+ isLocked: wasLocked,
3115
+ params
3116
+ } = swiper;
3117
+ const {
3118
+ slidesOffsetBefore
3119
+ } = params;
3120
+ if (slidesOffsetBefore) {
3121
+ const lastSlideIndex = swiper.slides.length - 1;
3122
+ const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
3123
+ swiper.isLocked = swiper.size > lastSlideRightEdge;
3124
+ } else {
3125
+ swiper.isLocked = swiper.snapGrid.length === 1;
3126
+ }
3127
+ if (params.allowSlideNext === true) {
3128
+ swiper.allowSlideNext = !swiper.isLocked;
3129
+ }
3130
+ if (params.allowSlidePrev === true) {
3131
+ swiper.allowSlidePrev = !swiper.isLocked;
3132
+ }
3133
+ if (wasLocked && wasLocked !== swiper.isLocked) {
3134
+ swiper.isEnd = false;
3135
+ }
3136
+ if (wasLocked !== swiper.isLocked) {
3137
+ swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
3138
+ }
3139
+ }
3140
+ var checkOverflow$1 = {
3141
+ checkOverflow
3142
+ };
3143
+
3144
+ var defaults = {
3145
+ init: true,
3146
+ direction: 'horizontal',
3147
+ oneWayMovement: false,
3148
+ swiperElementNodeName: 'SWIPER-CONTAINER',
3149
+ touchEventsTarget: 'wrapper',
3150
+ initialSlide: 0,
3151
+ speed: 300,
3152
+ cssMode: false,
3153
+ updateOnWindowResize: true,
3154
+ resizeObserver: true,
3155
+ nested: false,
3156
+ createElements: false,
3157
+ eventsPrefix: 'swiper',
3158
+ enabled: true,
3159
+ focusableElements: 'input, select, option, textarea, button, video, label',
3160
+ // Overrides
3161
+ width: null,
3162
+ height: null,
3163
+ //
3164
+ preventInteractionOnTransition: false,
3165
+ // ssr
3166
+ userAgent: null,
3167
+ url: null,
3168
+ // To support iOS's swipe-to-go-back gesture (when being used in-app).
3169
+ edgeSwipeDetection: false,
3170
+ edgeSwipeThreshold: 20,
3171
+ // Autoheight
3172
+ autoHeight: false,
3173
+ // Set wrapper width
3174
+ setWrapperSize: false,
3175
+ // Virtual Translate
3176
+ virtualTranslate: false,
3177
+ // Effects
3178
+ effect: 'slide',
3179
+ // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
3180
+
3181
+ // Breakpoints
3182
+ breakpoints: undefined,
3183
+ breakpointsBase: 'window',
3184
+ // Slides grid
3185
+ spaceBetween: 0,
3186
+ slidesPerView: 1,
3187
+ slidesPerGroup: 1,
3188
+ slidesPerGroupSkip: 0,
3189
+ slidesPerGroupAuto: false,
3190
+ centeredSlides: false,
3191
+ centeredSlidesBounds: false,
3192
+ slidesOffsetBefore: 0,
3193
+ // in px
3194
+ slidesOffsetAfter: 0,
3195
+ // in px
3196
+ normalizeSlideIndex: true,
3197
+ centerInsufficientSlides: false,
3198
+ snapToSlideEdge: false,
3199
+ // Disable swiper and hide navigation when container not overflow
3200
+ watchOverflow: true,
3201
+ // Round length
3202
+ roundLengths: false,
3203
+ // Touches
3204
+ touchRatio: 1,
3205
+ touchAngle: 45,
3206
+ simulateTouch: true,
3207
+ shortSwipes: true,
3208
+ longSwipes: true,
3209
+ longSwipesRatio: 0.5,
3210
+ longSwipesMs: 300,
3211
+ followFinger: true,
3212
+ allowTouchMove: true,
3213
+ threshold: 5,
3214
+ touchMoveStopPropagation: false,
3215
+ touchStartPreventDefault: true,
3216
+ touchStartForcePreventDefault: false,
3217
+ touchReleaseOnEdges: false,
3218
+ // Unique Navigation Elements
3219
+ uniqueNavElements: true,
3220
+ // Resistance
3221
+ resistance: true,
3222
+ resistanceRatio: 0.85,
3223
+ // Progress
3224
+ watchSlidesProgress: false,
3225
+ // Cursor
3226
+ grabCursor: false,
3227
+ // Clicks
3228
+ preventClicks: true,
3229
+ preventClicksPropagation: true,
3230
+ slideToClickedSlide: false,
3231
+ // loop
3232
+ loop: false,
3233
+ loopAddBlankSlides: true,
3234
+ loopAdditionalSlides: 0,
3235
+ loopPreventsSliding: true,
3236
+ // rewind
3237
+ rewind: false,
3238
+ // Swiping/no swiping
3239
+ allowSlidePrev: true,
3240
+ allowSlideNext: true,
3241
+ swipeHandler: null,
3242
+ // '.swipe-handler',
3243
+ noSwiping: true,
3244
+ noSwipingClass: 'swiper-no-swiping',
3245
+ noSwipingSelector: null,
3246
+ // Passive Listeners
3247
+ passiveListeners: true,
3248
+ maxBackfaceHiddenSlides: 10,
3249
+ // NS
3250
+ containerModifierClass: 'swiper-',
3251
+ // NEW
3252
+ slideClass: 'swiper-slide',
3253
+ slideBlankClass: 'swiper-slide-blank',
3254
+ slideActiveClass: 'swiper-slide-active',
3255
+ slideVisibleClass: 'swiper-slide-visible',
3256
+ slideFullyVisibleClass: 'swiper-slide-fully-visible',
3257
+ slideNextClass: 'swiper-slide-next',
3258
+ slidePrevClass: 'swiper-slide-prev',
3259
+ wrapperClass: 'swiper-wrapper',
3260
+ lazyPreloaderClass: 'swiper-lazy-preloader',
3261
+ lazyPreloadPrevNext: 0,
3262
+ // Callbacks
3263
+ runCallbacksOnInit: true,
3264
+ // Internals
3265
+ _emitClasses: false
3266
+ };
3267
+
3268
+ function moduleExtendParams(params, allModulesParams) {
3269
+ return function extendParams(obj = {}) {
3270
+ const moduleParamName = Object.keys(obj)[0];
3271
+ const moduleParams = obj[moduleParamName];
3272
+ if (typeof moduleParams !== 'object' || moduleParams === null) {
3273
+ extend(allModulesParams, obj);
3274
+ return;
3275
+ }
3276
+ if (params[moduleParamName] === true) {
3277
+ params[moduleParamName] = {
3278
+ enabled: true
3279
+ };
3280
+ }
3281
+ if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
3282
+ params[moduleParamName].auto = true;
3283
+ }
3284
+ if (['pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
3285
+ params[moduleParamName].auto = true;
3286
+ }
3287
+ if (!(moduleParamName in params && 'enabled' in moduleParams)) {
3288
+ extend(allModulesParams, obj);
3289
+ return;
3290
+ }
3291
+ if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
3292
+ params[moduleParamName].enabled = true;
3293
+ }
3294
+ if (!params[moduleParamName]) params[moduleParamName] = {
3295
+ enabled: false
3296
+ };
3297
+ extend(allModulesParams, obj);
3298
+ };
3299
+ }
3300
+
3301
+ /* eslint no-param-reassign: "off" */
3302
+ const prototypes = {
3303
+ eventsEmitter,
3304
+ update,
3305
+ translate,
3306
+ transition,
3307
+ slide,
3308
+ loop,
3309
+ grabCursor,
3310
+ events: events$1,
3311
+ breakpoints,
3312
+ checkOverflow: checkOverflow$1,
3313
+ classes
3314
+ };
3315
+ const extendedDefaults = {};
3316
+ class Swiper {
3317
+ constructor(...args) {
3318
+ let el;
3319
+ let params;
3320
+ if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
3321
+ params = args[0];
3322
+ } else {
3323
+ [el, params] = args;
3324
+ }
3325
+ if (!params) params = {};
3326
+ params = extend({}, params);
3327
+ if (el && !params.el) params.el = el;
3328
+ const document = getDocument();
3329
+ if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
3330
+ const swipers = [];
3331
+ document.querySelectorAll(params.el).forEach(containerEl => {
3332
+ const newParams = extend({}, params, {
3333
+ el: containerEl
3334
+ });
3335
+ swipers.push(new Swiper(newParams));
3336
+ });
3337
+ // eslint-disable-next-line no-constructor-return
3338
+ return swipers;
3339
+ }
3340
+
3341
+ // Swiper Instance
3342
+ const swiper = this;
3343
+ swiper.__swiper__ = true;
3344
+ swiper.support = getSupport();
3345
+ swiper.device = getDevice({
3346
+ userAgent: params.userAgent
3347
+ });
3348
+ swiper.browser = getBrowser();
3349
+ swiper.eventsListeners = {};
3350
+ swiper.eventsAnyListeners = [];
3351
+ swiper.modules = [...swiper.__modules__];
3352
+ if (params.modules && Array.isArray(params.modules)) {
3353
+ params.modules.forEach(mod => {
3354
+ if (typeof mod === 'function' && swiper.modules.indexOf(mod) < 0) {
3355
+ swiper.modules.push(mod);
3356
+ }
3357
+ });
3358
+ }
3359
+ const allModulesParams = {};
3360
+ swiper.modules.forEach(mod => {
3361
+ mod({
3362
+ params,
3363
+ swiper,
3364
+ extendParams: moduleExtendParams(params, allModulesParams),
3365
+ on: swiper.on.bind(swiper),
3366
+ once: swiper.once.bind(swiper),
3367
+ off: swiper.off.bind(swiper),
3368
+ emit: swiper.emit.bind(swiper)
3369
+ });
3370
+ });
3371
+
3372
+ // Extend defaults with modules params
3373
+ const swiperParams = extend({}, defaults, allModulesParams);
3374
+
3375
+ // Extend defaults with passed params
3376
+ swiper.params = extend({}, swiperParams, extendedDefaults, params);
3377
+ swiper.originalParams = extend({}, swiper.params);
3378
+ swiper.passedParams = extend({}, params);
3379
+
3380
+ // add event listeners
3381
+ if (swiper.params && swiper.params.on) {
3382
+ Object.keys(swiper.params.on).forEach(eventName => {
3383
+ swiper.on(eventName, swiper.params.on[eventName]);
3384
+ });
3385
+ }
3386
+ if (swiper.params && swiper.params.onAny) {
3387
+ swiper.onAny(swiper.params.onAny);
3388
+ }
3389
+
3390
+ // Extend Swiper
3391
+ Object.assign(swiper, {
3392
+ enabled: swiper.params.enabled,
3393
+ el,
3394
+ // Classes
3395
+ classNames: [],
3396
+ // Slides
3397
+ slides: [],
3398
+ slidesGrid: [],
3399
+ snapGrid: [],
3400
+ slidesSizesGrid: [],
3401
+ // isDirection
3402
+ isHorizontal() {
3403
+ return swiper.params.direction === 'horizontal';
3404
+ },
3405
+ isVertical() {
3406
+ return swiper.params.direction === 'vertical';
3407
+ },
3408
+ // Indexes
3409
+ activeIndex: 0,
3410
+ realIndex: 0,
3411
+ //
3412
+ isBeginning: true,
3413
+ isEnd: false,
3414
+ // Props
3415
+ translate: 0,
3416
+ previousTranslate: 0,
3417
+ progress: 0,
3418
+ velocity: 0,
3419
+ animating: false,
3420
+ cssOverflowAdjustment() {
3421
+ // Returns 0 unless `translate` is > 2**23
3422
+ // Should be subtracted from css values to prevent overflow
3423
+ return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
3424
+ },
3425
+ // Locks
3426
+ allowSlideNext: swiper.params.allowSlideNext,
3427
+ allowSlidePrev: swiper.params.allowSlidePrev,
3428
+ // Touch Events
3429
+ touchEventsData: {
3430
+ isTouched: undefined,
3431
+ isMoved: undefined,
3432
+ allowTouchCallbacks: undefined,
3433
+ touchStartTime: undefined,
3434
+ isScrolling: undefined,
3435
+ currentTranslate: undefined,
3436
+ startTranslate: undefined,
3437
+ allowThresholdMove: undefined,
3438
+ // Form elements to match
3439
+ focusableElements: swiper.params.focusableElements,
3440
+ // Last click time
3441
+ lastClickTime: 0,
3442
+ clickTimeout: undefined,
3443
+ // Velocities
3444
+ velocities: [],
3445
+ allowMomentumBounce: undefined,
3446
+ startMoving: undefined,
3447
+ pointerId: null,
3448
+ touchId: null
3449
+ },
3450
+ // Clicks
3451
+ allowClick: true,
3452
+ // Touches
3453
+ allowTouchMove: swiper.params.allowTouchMove,
3454
+ touches: {
3455
+ startX: 0,
3456
+ startY: 0,
3457
+ currentX: 0,
3458
+ currentY: 0,
3459
+ diff: 0
3460
+ },
3461
+ // Images
3462
+ imagesToLoad: [],
3463
+ imagesLoaded: 0
3464
+ });
3465
+ swiper.emit('_swiper');
3466
+
3467
+ // Init
3468
+ if (swiper.params.init) {
3469
+ swiper.init();
3470
+ }
3471
+
3472
+ // Return app instance
3473
+ // eslint-disable-next-line no-constructor-return
3474
+ return swiper;
3475
+ }
3476
+ getDirectionLabel(property) {
3477
+ if (this.isHorizontal()) {
3478
+ return property;
3479
+ }
3480
+ // prettier-ignore
3481
+ return {
3482
+ 'width': 'height',
3483
+ 'margin-top': 'margin-left',
3484
+ 'margin-bottom ': 'margin-right',
3485
+ 'margin-left': 'margin-top',
3486
+ 'margin-right': 'margin-bottom',
3487
+ 'padding-left': 'padding-top',
3488
+ 'padding-right': 'padding-bottom',
3489
+ 'marginRight': 'marginBottom'
3490
+ }[property];
3491
+ }
3492
+ getSlideIndex(slideEl) {
3493
+ const {
3494
+ slidesEl,
3495
+ params
3496
+ } = this;
3497
+ const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3498
+ const firstSlideIndex = elementIndex(slides[0]);
3499
+ return elementIndex(slideEl) - firstSlideIndex;
3500
+ }
3501
+ getSlideIndexByData(index) {
3502
+ return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
3503
+ }
3504
+ getSlideIndexWhenGrid(index) {
3505
+ if (this.grid && this.params.grid && this.params.grid.rows > 1) {
3506
+ if (this.params.grid.fill === 'column') {
3507
+ index = Math.floor(index / this.params.grid.rows);
3508
+ } else if (this.params.grid.fill === 'row') {
3509
+ index = index % Math.ceil(this.slides.length / this.params.grid.rows);
3510
+ }
3511
+ }
3512
+ return index;
3513
+ }
3514
+ recalcSlides() {
3515
+ const swiper = this;
3516
+ const {
3517
+ slidesEl,
3518
+ params
3519
+ } = swiper;
3520
+ swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
3521
+ }
3522
+ enable() {
3523
+ const swiper = this;
3524
+ if (swiper.enabled) return;
3525
+ swiper.enabled = true;
3526
+ if (swiper.params.grabCursor) {
3527
+ swiper.setGrabCursor();
3528
+ }
3529
+ swiper.emit('enable');
3530
+ }
3531
+ disable() {
3532
+ const swiper = this;
3533
+ if (!swiper.enabled) return;
3534
+ swiper.enabled = false;
3535
+ if (swiper.params.grabCursor) {
3536
+ swiper.unsetGrabCursor();
3537
+ }
3538
+ swiper.emit('disable');
3539
+ }
3540
+ setProgress(progress, speed) {
3541
+ const swiper = this;
3542
+ progress = Math.min(Math.max(progress, 0), 1);
3543
+ const min = swiper.minTranslate();
3544
+ const max = swiper.maxTranslate();
3545
+ const current = (max - min) * progress + min;
3546
+ swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
3547
+ swiper.updateActiveIndex();
3548
+ swiper.updateSlidesClasses();
3549
+ }
3550
+ emitContainerClasses() {
3551
+ const swiper = this;
3552
+ if (!swiper.params._emitClasses || !swiper.el) return;
3553
+ const cls = swiper.el.className.split(' ').filter(className => {
3554
+ return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
3555
+ });
3556
+ swiper.emit('_containerClasses', cls.join(' '));
3557
+ }
3558
+ getSlideClasses(slideEl) {
3559
+ const swiper = this;
3560
+ if (swiper.destroyed) return '';
3561
+ return slideEl.className.split(' ').filter(className => {
3562
+ return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
3563
+ }).join(' ');
3564
+ }
3565
+ emitSlidesClasses() {
3566
+ const swiper = this;
3567
+ if (!swiper.params._emitClasses || !swiper.el) return;
3568
+ const updates = [];
3569
+ swiper.slides.forEach(slideEl => {
3570
+ const classNames = swiper.getSlideClasses(slideEl);
3571
+ updates.push({
3572
+ slideEl,
3573
+ classNames
3574
+ });
3575
+ swiper.emit('_slideClass', slideEl, classNames);
3576
+ });
3577
+ swiper.emit('_slideClasses', updates);
3578
+ }
3579
+ slidesPerViewDynamic(view = 'current', exact = false) {
3580
+ const swiper = this;
3581
+ const {
3582
+ params,
3583
+ slides,
3584
+ slidesGrid,
3585
+ slidesSizesGrid,
3586
+ size: swiperSize,
3587
+ activeIndex
3588
+ } = swiper;
3589
+ let spv = 1;
3590
+ if (typeof params.slidesPerView === 'number') return params.slidesPerView;
3591
+ if (params.centeredSlides) {
3592
+ let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0;
3593
+ let breakLoop;
3594
+ for (let i = activeIndex + 1; i < slides.length; i += 1) {
3595
+ if (slides[i] && !breakLoop) {
3596
+ slideSize += Math.ceil(slides[i].swiperSlideSize);
3597
+ spv += 1;
3598
+ if (slideSize > swiperSize) breakLoop = true;
3599
+ }
3600
+ }
3601
+ for (let i = activeIndex - 1; i >= 0; i -= 1) {
3602
+ if (slides[i] && !breakLoop) {
3603
+ slideSize += slides[i].swiperSlideSize;
3604
+ spv += 1;
3605
+ if (slideSize > swiperSize) breakLoop = true;
3606
+ }
3607
+ }
3608
+ } else {
3609
+ // eslint-disable-next-line
3610
+ if (view === 'current') {
3611
+ for (let i = activeIndex + 1; i < slides.length; i += 1) {
3612
+ const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
3613
+ if (slideInView) {
3614
+ spv += 1;
3615
+ }
3616
+ }
3617
+ } else {
3618
+ // previous
3619
+ for (let i = activeIndex - 1; i >= 0; i -= 1) {
3620
+ const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
3621
+ if (slideInView) {
3622
+ spv += 1;
3623
+ }
3624
+ }
3625
+ }
3626
+ }
3627
+ return spv;
3628
+ }
3629
+ update() {
3630
+ const swiper = this;
3631
+ if (!swiper || swiper.destroyed) return;
3632
+ const {
3633
+ snapGrid,
3634
+ params
3635
+ } = swiper;
3636
+ // Breakpoints
3637
+ if (params.breakpoints) {
3638
+ swiper.setBreakpoint();
3639
+ }
3640
+ [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
3641
+ if (imageEl.complete) {
3642
+ processLazyPreloader(swiper, imageEl);
3643
+ }
3644
+ });
3645
+ swiper.updateSize();
3646
+ swiper.updateSlides();
3647
+ swiper.updateProgress();
3648
+ swiper.updateSlidesClasses();
3649
+ function setTranslate() {
3650
+ const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
3651
+ const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
3652
+ swiper.setTranslate(newTranslate);
3653
+ swiper.updateActiveIndex();
3654
+ swiper.updateSlidesClasses();
3655
+ }
3656
+ let translated;
3657
+ if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
3658
+ setTranslate();
3659
+ if (params.autoHeight) {
3660
+ swiper.updateAutoHeight();
3661
+ }
3662
+ } else {
3663
+ if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
3664
+ const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
3665
+ translated = swiper.slideTo(slides.length - 1, 0, false, true);
3666
+ } else {
3667
+ translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
3668
+ }
3669
+ if (!translated) {
3670
+ setTranslate();
3671
+ }
3672
+ }
3673
+ if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
3674
+ swiper.checkOverflow();
3675
+ }
3676
+ swiper.emit('update');
3677
+ }
3678
+ changeDirection(newDirection, needUpdate = true) {
3679
+ const swiper = this;
3680
+ const currentDirection = swiper.params.direction;
3681
+ if (!newDirection) {
3682
+ // eslint-disable-next-line
3683
+ newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
3684
+ }
3685
+ if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
3686
+ return swiper;
3687
+ }
3688
+ swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
3689
+ swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
3690
+ swiper.emitContainerClasses();
3691
+ swiper.params.direction = newDirection;
3692
+ swiper.slides.forEach(slideEl => {
3693
+ if (newDirection === 'vertical') {
3694
+ slideEl.style.width = '';
3695
+ } else {
3696
+ slideEl.style.height = '';
3697
+ }
3698
+ });
3699
+ swiper.emit('changeDirection');
3700
+ if (needUpdate) swiper.update();
3701
+ return swiper;
3702
+ }
3703
+ changeLanguageDirection(direction) {
3704
+ const swiper = this;
3705
+ if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
3706
+ swiper.rtl = direction === 'rtl';
3707
+ swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
3708
+ if (swiper.rtl) {
3709
+ swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
3710
+ swiper.el.dir = 'rtl';
3711
+ } else {
3712
+ swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
3713
+ swiper.el.dir = 'ltr';
3714
+ }
3715
+ swiper.update();
3716
+ }
3717
+ mount(element) {
3718
+ const swiper = this;
3719
+ if (swiper.mounted) return true;
3720
+
3721
+ // Find el
3722
+ let el = element || swiper.params.el;
3723
+ if (typeof el === 'string') {
3724
+ el = document.querySelector(el);
3725
+ }
3726
+ if (!el) {
3727
+ return false;
3728
+ }
3729
+ el.swiper = swiper;
3730
+ if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
3731
+ swiper.isElement = true;
3732
+ }
3733
+ const getWrapperSelector = () => {
3734
+ return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
3735
+ };
3736
+ const getWrapper = () => {
3737
+ if (el && el.shadowRoot && el.shadowRoot.querySelector) {
3738
+ const res = el.shadowRoot.querySelector(getWrapperSelector());
3739
+ // Children needs to return slot items
3740
+ return res;
3741
+ }
3742
+ return elementChildren(el, getWrapperSelector())[0];
3743
+ };
3744
+ // Find Wrapper
3745
+ let wrapperEl = getWrapper();
3746
+ if (!wrapperEl && swiper.params.createElements) {
3747
+ wrapperEl = createElement('div', swiper.params.wrapperClass);
3748
+ el.append(wrapperEl);
3749
+ elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
3750
+ wrapperEl.append(slideEl);
3751
+ });
3752
+ }
3753
+ Object.assign(swiper, {
3754
+ el,
3755
+ wrapperEl,
3756
+ slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
3757
+ hostEl: swiper.isElement ? el.parentNode.host : el,
3758
+ mounted: true,
3759
+ // RTL
3760
+ rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
3761
+ rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
3762
+ wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
3763
+ });
3764
+ return true;
3765
+ }
3766
+ init(el) {
3767
+ const swiper = this;
3768
+ if (swiper.initialized) return swiper;
3769
+ const mounted = swiper.mount(el);
3770
+ if (mounted === false) return swiper;
3771
+ swiper.emit('beforeInit');
3772
+
3773
+ // Set breakpoint
3774
+ if (swiper.params.breakpoints) {
3775
+ swiper.setBreakpoint();
3776
+ }
3777
+
3778
+ // Add Classes
3779
+ swiper.addClasses();
3780
+
3781
+ // Update size
3782
+ swiper.updateSize();
3783
+
3784
+ // Update slides
3785
+ swiper.updateSlides();
3786
+ if (swiper.params.watchOverflow) {
3787
+ swiper.checkOverflow();
3788
+ }
3789
+
3790
+ // Set Grab Cursor
3791
+ if (swiper.params.grabCursor && swiper.enabled) {
3792
+ swiper.setGrabCursor();
3793
+ }
3794
+
3795
+ // Slide To Initial Slide
3796
+ if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
3797
+ swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
3798
+ } else {
3799
+ swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
3800
+ }
3801
+
3802
+ // Create loop
3803
+ if (swiper.params.loop) {
3804
+ swiper.loopCreate(undefined, true);
3805
+ }
3806
+
3807
+ // Attach events
3808
+ swiper.attachEvents();
3809
+ const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
3810
+ if (swiper.isElement) {
3811
+ lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
3812
+ }
3813
+ lazyElements.forEach(imageEl => {
3814
+ if (imageEl.complete) {
3815
+ processLazyPreloader(swiper, imageEl);
3816
+ } else {
3817
+ imageEl.addEventListener('load', e => {
3818
+ processLazyPreloader(swiper, e.target);
3819
+ });
3820
+ }
3821
+ });
3822
+ preload(swiper);
3823
+
3824
+ // Init Flag
3825
+ swiper.initialized = true;
3826
+ preload(swiper);
3827
+
3828
+ // Emit
3829
+ swiper.emit('init');
3830
+ swiper.emit('afterInit');
3831
+ return swiper;
3832
+ }
3833
+ destroy(deleteInstance = true, cleanStyles = true) {
3834
+ const swiper = this;
3835
+ const {
3836
+ params,
3837
+ el,
3838
+ wrapperEl,
3839
+ slides
3840
+ } = swiper;
3841
+ if (typeof swiper.params === 'undefined' || swiper.destroyed) {
3842
+ return null;
3843
+ }
3844
+ swiper.emit('beforeDestroy');
3845
+
3846
+ // Init Flag
3847
+ swiper.initialized = false;
3848
+
3849
+ // Detach events
3850
+ swiper.detachEvents();
3851
+
3852
+ // Destroy loop
3853
+ if (params.loop) {
3854
+ swiper.loopDestroy();
3855
+ }
3856
+
3857
+ // Cleanup styles
3858
+ if (cleanStyles) {
3859
+ swiper.removeClasses();
3860
+ if (el && typeof el !== 'string') {
3861
+ el.removeAttribute('style');
3862
+ }
3863
+ if (wrapperEl) {
3864
+ wrapperEl.removeAttribute('style');
3865
+ }
3866
+ if (slides && slides.length) {
3867
+ slides.forEach(slideEl => {
3868
+ slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
3869
+ slideEl.removeAttribute('style');
3870
+ slideEl.removeAttribute('data-swiper-slide-index');
3871
+ });
3872
+ }
3873
+ }
3874
+ swiper.emit('destroy');
3875
+
3876
+ // Detach emitter events
3877
+ Object.keys(swiper.eventsListeners).forEach(eventName => {
3878
+ swiper.off(eventName);
3879
+ });
3880
+ if (deleteInstance !== false) {
3881
+ if (swiper.el && typeof swiper.el !== 'string') {
3882
+ swiper.el.swiper = null;
3883
+ }
3884
+ deleteProps(swiper);
3885
+ }
3886
+ swiper.destroyed = true;
3887
+ return null;
3888
+ }
3889
+ static extendDefaults(newDefaults) {
3890
+ extend(extendedDefaults, newDefaults);
3891
+ }
3892
+ static get extendedDefaults() {
3893
+ return extendedDefaults;
3894
+ }
3895
+ static get defaults() {
3896
+ return defaults;
3897
+ }
3898
+ static installModule(mod) {
3899
+ if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
3900
+ const modules = Swiper.prototype.__modules__;
3901
+ if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
3902
+ modules.push(mod);
3903
+ }
3904
+ }
3905
+ static use(module) {
3906
+ if (Array.isArray(module)) {
3907
+ module.forEach(m => Swiper.installModule(m));
3908
+ return Swiper;
3909
+ }
3910
+ Swiper.installModule(module);
3911
+ return Swiper;
3912
+ }
3913
+ }
3914
+ Object.keys(prototypes).forEach(prototypeGroup => {
3915
+ Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
3916
+ Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
3917
+ });
3918
+ });
3919
+ Swiper.use([Resize, Observer]);
3920
+
3921
+ export { Swiper as S, defaults as d };
3922
+ //# sourceMappingURL=swiper-core.js.map