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