ivt 0.4.5 → 0.4.6

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 (224) hide show
  1. package/dist/accordion/index.mjs +15 -14
  2. package/dist/accordion/index.mjs.map +1 -1
  3. package/dist/alert/index.mjs +2 -2
  4. package/dist/alert-dialog/index.mjs +17 -16
  5. package/dist/alert-dialog/index.mjs.map +1 -1
  6. package/dist/aspect-ratio/index.d.ts +7 -0
  7. package/dist/aspect-ratio/index.mjs +46 -0
  8. package/dist/aspect-ratio/index.mjs.map +1 -0
  9. package/dist/avatar/index.mjs +7 -7
  10. package/dist/badge/index.mjs +3 -3
  11. package/dist/base/index.mjs +37 -35
  12. package/dist/base/index.mjs.map +1 -1
  13. package/dist/breadcrumb/index.d.ts +14 -0
  14. package/dist/breadcrumb/index.mjs +71 -0
  15. package/dist/breadcrumb/index.mjs.map +1 -0
  16. package/dist/button/index.mjs +3 -3
  17. package/dist/calendar/index.mjs +8 -8
  18. package/dist/card/index.mjs +2 -2
  19. package/dist/carousel/index.d.ts +25 -0
  20. package/dist/carousel/index.mjs +1793 -0
  21. package/dist/carousel/index.mjs.map +1 -0
  22. package/dist/chart/index.mjs +4 -4
  23. package/dist/checkbox/index.mjs +13 -13
  24. package/dist/chunks/{Container-DVypwIQb.mjs → Container-sBmoUJ1A.mjs} +2 -2
  25. package/dist/chunks/{Container-DVypwIQb.mjs.map → Container-sBmoUJ1A.mjs.map} +1 -1
  26. package/dist/chunks/{_commonjsHelpers-DxUjvHAf.mjs → _commonjsHelpers-DMx7h_rP.mjs} +1 -1
  27. package/dist/chunks/_commonjsHelpers-DMx7h_rP.mjs.map +1 -0
  28. package/dist/chunks/{accordion-C-7WU65v.mjs → accordion-BEzCfjyX.mjs} +11 -133
  29. package/dist/chunks/accordion-BEzCfjyX.mjs.map +1 -0
  30. package/dist/chunks/{badge-FyqsRWpb.mjs → badge-poifvE-U.mjs} +2 -2
  31. package/dist/chunks/{badge-FyqsRWpb.mjs.map → badge-poifvE-U.mjs.map} +1 -1
  32. package/dist/chunks/{bundle-mjs--Uc0zBMR.mjs → bundle-mjs-8KEENQOJ.mjs} +1 -1
  33. package/dist/chunks/{bundle-mjs--Uc0zBMR.mjs.map → bundle-mjs-8KEENQOJ.mjs.map} +1 -1
  34. package/dist/chunks/{button-CkvbfoBC.mjs → button-TULRIYFO.mjs} +2 -2
  35. package/dist/chunks/{button-CkvbfoBC.mjs.map → button-TULRIYFO.mjs.map} +1 -1
  36. package/dist/chunks/{calendar-DthuUOQB.mjs → calendar-nJ5T1YgK.mjs} +6 -6
  37. package/dist/chunks/{calendar-DthuUOQB.mjs.map → calendar-nJ5T1YgK.mjs.map} +1 -1
  38. package/dist/chunks/{check-CEEnU7uo.mjs → check-DcPt24aD.mjs} +2 -2
  39. package/dist/chunks/{check-CEEnU7uo.mjs.map → check-DcPt24aD.mjs.map} +1 -1
  40. package/dist/chunks/{chevron-down-CdtWWCvB.mjs → chevron-down-BNw46No-.mjs} +2 -2
  41. package/dist/chunks/{chevron-down-CdtWWCvB.mjs.map → chevron-down-BNw46No-.mjs.map} +1 -1
  42. package/dist/chunks/{chevron-left-dKr4sXaL.mjs → chevron-left-B-ZN622G.mjs} +2 -2
  43. package/dist/chunks/{chevron-left-dKr4sXaL.mjs.map → chevron-left-B-ZN622G.mjs.map} +1 -1
  44. package/dist/chunks/{chevron-right-BJERqiST.mjs → chevron-right-Ddz8dCda.mjs} +2 -2
  45. package/dist/chunks/{chevron-right-BJERqiST.mjs.map → chevron-right-Ddz8dCda.mjs.map} +1 -1
  46. package/dist/chunks/{chevrons-up-down-CvLRAoM4.mjs → chevrons-up-down-ChXPuZd6.mjs} +2 -2
  47. package/dist/chunks/{chevrons-up-down-CvLRAoM4.mjs.map → chevrons-up-down-ChXPuZd6.mjs.map} +1 -1
  48. package/dist/chunks/{command-BT07aIMk.mjs → command-D6QS1LFL.mjs} +8 -8
  49. package/dist/chunks/{command-BT07aIMk.mjs.map → command-D6QS1LFL.mjs.map} +1 -1
  50. package/dist/chunks/{createLucideIcon-C-36jtLf.mjs → createLucideIcon-DOOu6ntc.mjs} +1 -1
  51. package/dist/chunks/{createLucideIcon-C-36jtLf.mjs.map → createLucideIcon-DOOu6ntc.mjs.map} +1 -1
  52. package/dist/chunks/{dialog-E_tuNVVP.mjs → dialog-BefJPh8X.mjs} +4 -4
  53. package/dist/chunks/{dialog-E_tuNVVP.mjs.map → dialog-BefJPh8X.mjs.map} +1 -1
  54. package/dist/chunks/ellipsis-Cwr1X9R2.mjs +35 -0
  55. package/dist/chunks/ellipsis-Cwr1X9R2.mjs.map +1 -0
  56. package/dist/chunks/{hover-card-BnkDAKKp.mjs → hover-card-CcNjcMZa.mjs} +11 -10
  57. package/dist/chunks/{hover-card-BnkDAKKp.mjs.map → hover-card-CcNjcMZa.mjs.map} +1 -1
  58. package/dist/chunks/{index-ypP8ZSEh.mjs → index-0fdTSdHQ.mjs} +6 -21
  59. package/dist/chunks/index-0fdTSdHQ.mjs.map +1 -0
  60. package/dist/chunks/{index-Cn5ihFPu.mjs → index-1tph_k2t.mjs} +1 -1
  61. package/dist/chunks/{index-Cn5ihFPu.mjs.map → index-1tph_k2t.mjs.map} +1 -1
  62. package/dist/chunks/{index-B63fbqEU.mjs → index-BCsiqIRL.mjs} +1 -1
  63. package/dist/chunks/{index-B63fbqEU.mjs.map → index-BCsiqIRL.mjs.map} +1 -1
  64. package/dist/chunks/index-Bb31UsVK.mjs +7 -0
  65. package/dist/chunks/index-Bb31UsVK.mjs.map +1 -0
  66. package/dist/chunks/index-BnNdF3Y6.mjs +133 -0
  67. package/dist/chunks/index-BnNdF3Y6.mjs.map +1 -0
  68. package/dist/chunks/{index-hd6oiDyZ.mjs → index-BwVg1Kb5.mjs} +1 -1
  69. package/dist/chunks/{index-hd6oiDyZ.mjs.map → index-BwVg1Kb5.mjs.map} +1 -1
  70. package/dist/chunks/{index-Cf5nP8Sx.mjs → index-CK9CWim6.mjs} +2 -2
  71. package/dist/chunks/{index-Cf5nP8Sx.mjs.map → index-CK9CWim6.mjs.map} +1 -1
  72. package/dist/chunks/{index-Bv_h_hMx.mjs → index-CQc8iXpK.mjs} +11 -10
  73. package/dist/chunks/{index-Bv_h_hMx.mjs.map → index-CQc8iXpK.mjs.map} +1 -1
  74. package/dist/chunks/{index-DfGdJ6wp.mjs → index-CSiM72Dy.mjs} +1 -1
  75. package/dist/chunks/{index-DfGdJ6wp.mjs.map → index-CSiM72Dy.mjs.map} +1 -1
  76. package/dist/chunks/{index-BIfMxNBh.mjs → index-CWMDV9qs.mjs} +2 -2
  77. package/dist/chunks/{index-BIfMxNBh.mjs.map → index-CWMDV9qs.mjs.map} +1 -1
  78. package/dist/chunks/{index-oRHhKb2z.mjs → index-CjtaP9C4.mjs} +1 -1
  79. package/dist/chunks/{index-oRHhKb2z.mjs.map → index-CjtaP9C4.mjs.map} +1 -1
  80. package/dist/chunks/index-Cl4mLFZO.mjs +21 -0
  81. package/dist/chunks/index-Cl4mLFZO.mjs.map +1 -0
  82. package/dist/chunks/{index-VGFs-gvq.mjs → index-D1qT_gBX.mjs} +1 -1
  83. package/dist/chunks/{index-VGFs-gvq.mjs.map → index-D1qT_gBX.mjs.map} +1 -1
  84. package/dist/chunks/{index-OeC6d8TA.mjs → index-D7B2_9g4.mjs} +2 -2
  85. package/dist/chunks/{index-OeC6d8TA.mjs.map → index-D7B2_9g4.mjs.map} +1 -1
  86. package/dist/chunks/{index-DujcHJqa.mjs → index-DDe3wbsL.mjs} +1 -1
  87. package/dist/chunks/{index-DujcHJqa.mjs.map → index-DDe3wbsL.mjs.map} +1 -1
  88. package/dist/chunks/{index-n6Vlh2qs.mjs → index-DSL6rasA.mjs} +9 -9
  89. package/dist/chunks/{index-n6Vlh2qs.mjs.map → index-DSL6rasA.mjs.map} +1 -1
  90. package/dist/chunks/{index-D7MXDvLR.mjs → index-DejfSFbY.mjs} +7 -7
  91. package/dist/chunks/{index-D7MXDvLR.mjs.map → index-DejfSFbY.mjs.map} +1 -1
  92. package/dist/chunks/{index-CiQJ7wod.mjs → index-DoRi3lh9.mjs} +2 -2
  93. package/dist/chunks/{index-CiQJ7wod.mjs.map → index-DoRi3lh9.mjs.map} +1 -1
  94. package/dist/chunks/{index-ZiahhVWN.mjs → index-DvLErdHO.mjs} +1 -1
  95. package/dist/chunks/{index-ZiahhVWN.mjs.map → index-DvLErdHO.mjs.map} +1 -1
  96. package/dist/chunks/{index-Bzi8Hpka.mjs → index-EfpXtubk.mjs} +5 -5
  97. package/dist/chunks/{index-Bzi8Hpka.mjs.map → index-EfpXtubk.mjs.map} +1 -1
  98. package/dist/chunks/{index-mnhyF3Xs.mjs → index-JyHiZGQv.mjs} +16 -15
  99. package/dist/chunks/{index-mnhyF3Xs.mjs.map → index-JyHiZGQv.mjs.map} +1 -1
  100. package/dist/chunks/{index-0tMmOuv1.mjs → index-P1gmXtXB.mjs} +3 -3
  101. package/dist/chunks/{index-0tMmOuv1.mjs.map → index-P1gmXtXB.mjs.map} +1 -1
  102. package/dist/chunks/{index-D1toVD_V.mjs → index-e34k5BX3.mjs} +1 -1
  103. package/dist/chunks/{index-D1toVD_V.mjs.map → index-e34k5BX3.mjs.map} +1 -1
  104. package/dist/chunks/{input-f9f7o4dl.mjs → input-CDsq1Xde.mjs} +2 -2
  105. package/dist/chunks/{input-f9f7o4dl.mjs.map → input-CDsq1Xde.mjs.map} +1 -1
  106. package/dist/chunks/{label-ClnI7CPw.mjs → label-BzGy6SRg.mjs} +3 -3
  107. package/dist/chunks/{label-ClnI7CPw.mjs.map → label-BzGy6SRg.mjs.map} +1 -1
  108. package/dist/chunks/{pagination-ByGWAyDY.mjs → pagination-CfFGN_ib.mjs} +6 -37
  109. package/dist/chunks/pagination-CfFGN_ib.mjs.map +1 -0
  110. package/dist/chunks/{popover-BP0h5od9.mjs → popover-BlSoIp_B.mjs} +13 -12
  111. package/dist/chunks/{popover-BP0h5od9.mjs.map → popover-BlSoIp_B.mjs.map} +1 -1
  112. package/dist/chunks/{progress-C36nV_EJ.mjs → progress-CIapbA26.mjs} +4 -4
  113. package/dist/chunks/{progress-C36nV_EJ.mjs.map → progress-CIapbA26.mjs.map} +1 -1
  114. package/dist/chunks/{pt-BR-B365hYCq.mjs → pt-BR-BCfQl1oP.mjs} +3 -3
  115. package/dist/chunks/{pt-BR-B365hYCq.mjs.map → pt-BR-BCfQl1oP.mjs.map} +1 -1
  116. package/dist/chunks/{scroll-area-BCPovfc9.mjs → scroll-area-BE1y6Igy.mjs} +11 -15
  117. package/dist/chunks/scroll-area-BE1y6Igy.mjs.map +1 -0
  118. package/dist/chunks/{select-DsHm4Ncw.mjs → select-BBb0ke76.mjs} +5 -5
  119. package/dist/chunks/{select-DsHm4Ncw.mjs.map → select-BBb0ke76.mjs.map} +1 -1
  120. package/dist/chunks/{separator-D5jBoFYi.mjs → separator-B1yL1lh8.mjs} +3 -3
  121. package/dist/chunks/{separator-D5jBoFYi.mjs.map → separator-B1yL1lh8.mjs.map} +1 -1
  122. package/dist/chunks/sheet-FhW-R397.mjs +80 -0
  123. package/dist/chunks/sheet-FhW-R397.mjs.map +1 -0
  124. package/dist/chunks/{skeleton-BW9vlu4U.mjs → skeleton-Cy2Kyc1R.mjs} +2 -2
  125. package/dist/chunks/{skeleton-BW9vlu4U.mjs.map → skeleton-Cy2Kyc1R.mjs.map} +1 -1
  126. package/dist/chunks/{sortable-DbjP8Kx8.mjs → sortable-qR5yOJD2.mjs} +3 -3
  127. package/dist/chunks/{sortable-DbjP8Kx8.mjs.map → sortable-qR5yOJD2.mjs.map} +1 -1
  128. package/dist/chunks/{table-BrJ_iN3j.mjs → table-QPbxZz58.mjs} +2 -2
  129. package/dist/chunks/{table-BrJ_iN3j.mjs.map → table-QPbxZz58.mjs.map} +1 -1
  130. package/dist/chunks/{toggle-BYDRoIw7.mjs → toggle-CoBW3Uqo.mjs} +5 -5
  131. package/dist/chunks/{toggle-BYDRoIw7.mjs.map → toggle-CoBW3Uqo.mjs.map} +1 -1
  132. package/dist/chunks/{tooltip-DnGcpocO.mjs → tooltip-DNfLTD30.mjs} +13 -12
  133. package/dist/chunks/{tooltip-DnGcpocO.mjs.map → tooltip-DNfLTD30.mjs.map} +1 -1
  134. package/dist/chunks/{trash-2-Ccqlx7cY.mjs → trash-2-D3X2krCW.mjs} +2 -2
  135. package/dist/chunks/{trash-2-Ccqlx7cY.mjs.map → trash-2-D3X2krCW.mjs.map} +1 -1
  136. package/dist/chunks/{tslib.es6-CZ32kgxs.mjs → tslib.es6-UJQ1U8uE.mjs} +1 -1
  137. package/dist/chunks/{tslib.es6-CZ32kgxs.mjs.map → tslib.es6-UJQ1U8uE.mjs.map} +1 -1
  138. package/dist/chunks/{utils-SWF3jXjy.mjs → utils-AmLv58nm.mjs} +2 -2
  139. package/dist/chunks/{utils-SWF3jXjy.mjs.map → utils-AmLv58nm.mjs.map} +1 -1
  140. package/dist/chunks/{x-B9_z9ee1.mjs → x-CENvqJg-.mjs} +2 -2
  141. package/dist/chunks/{x-B9_z9ee1.mjs.map → x-CENvqJg-.mjs.map} +1 -1
  142. package/dist/collapsible/index.d.ts +9 -0
  143. package/dist/collapsible/index.mjs +35 -0
  144. package/dist/collapsible/index.mjs.map +1 -0
  145. package/dist/combobox/index.mjs +26 -25
  146. package/dist/combobox/index.mjs.map +1 -1
  147. package/dist/command/index.mjs +20 -19
  148. package/dist/command/index.mjs.map +1 -1
  149. package/dist/context-menu/index.d.ts +28 -0
  150. package/dist/context-menu/index.mjs +460 -0
  151. package/dist/context-menu/index.mjs.map +1 -0
  152. package/dist/data-table/index.mjs +35 -33
  153. package/dist/data-table/index.mjs.map +1 -1
  154. package/dist/date-picker/index.mjs +25 -24
  155. package/dist/date-picker/index.mjs.map +1 -1
  156. package/dist/dialog/index.mjs +19 -18
  157. package/dist/dialog/index.mjs.map +1 -1
  158. package/dist/drawer/index.d.ts +16 -0
  159. package/dist/drawer/index.mjs +1704 -0
  160. package/dist/drawer/index.mjs.map +1 -0
  161. package/dist/dropdown-menu/index.mjs +23 -22
  162. package/dist/dropdown-menu/index.mjs.map +1 -1
  163. package/dist/dropzone/index.mjs +18 -17
  164. package/dist/dropzone/index.mjs.map +1 -1
  165. package/dist/form/index.mjs +4 -4
  166. package/dist/hover-card/index.mjs +15 -14
  167. package/dist/hover-card/index.mjs.map +1 -1
  168. package/dist/icon/index.mjs +1 -1
  169. package/dist/index.css +1 -1
  170. package/dist/input/index.mjs +3 -3
  171. package/dist/input-otp/index.d.ts +14 -0
  172. package/dist/input-otp/index.mjs +456 -0
  173. package/dist/input-otp/index.mjs.map +1 -0
  174. package/dist/ivt.css +1 -1
  175. package/dist/label/index.mjs +4 -4
  176. package/dist/layout/index.mjs +5 -5
  177. package/dist/menubar/index.mjs +23 -22
  178. package/dist/menubar/index.mjs.map +1 -1
  179. package/dist/multi-select/index.mjs +30 -29
  180. package/dist/multi-select/index.mjs.map +1 -1
  181. package/dist/navigation-menu/index.d.ts +18 -0
  182. package/dist/navigation-menu/index.mjs +868 -0
  183. package/dist/navigation-menu/index.mjs.map +1 -0
  184. package/dist/pagination/index.mjs +8 -7
  185. package/dist/pagination/index.mjs.map +1 -1
  186. package/dist/popover/index.mjs +18 -17
  187. package/dist/popover/index.mjs.map +1 -1
  188. package/dist/progress/index.mjs +5 -5
  189. package/dist/radio-group/index.mjs +17 -17
  190. package/dist/resizable/index.d.ts +11 -0
  191. package/dist/resizable/index.mjs +2166 -0
  192. package/dist/resizable/index.mjs.map +1 -0
  193. package/dist/scroll-area/index.mjs +12 -11
  194. package/dist/scroll-area/index.mjs.map +1 -1
  195. package/dist/select/index.mjs +6 -6
  196. package/dist/separator/index.mjs +4 -4
  197. package/dist/shared/index.mjs +5 -5
  198. package/dist/sheet/index.mjs +20 -93
  199. package/dist/sheet/index.mjs.map +1 -1
  200. package/dist/sidebar/index.d.ts +75 -0
  201. package/dist/sidebar/index.mjs +457 -0
  202. package/dist/sidebar/index.mjs.map +1 -0
  203. package/dist/skeleton/index.mjs +3 -3
  204. package/dist/skeleton-component/index.mjs +4 -4
  205. package/dist/slider/index.d.ts +7 -0
  206. package/dist/slider/index.mjs +594 -0
  207. package/dist/slider/index.mjs.map +1 -0
  208. package/dist/sortable/index.mjs +4 -4
  209. package/dist/switch/index.mjs +10 -10
  210. package/dist/table/index.mjs +3 -3
  211. package/dist/tabs/index.mjs +13 -13
  212. package/dist/textarea/index.mjs +2 -2
  213. package/dist/toast/index.mjs +15 -14
  214. package/dist/toast/index.mjs.map +1 -1
  215. package/dist/toggle/index.mjs +7 -7
  216. package/dist/toggle-group/index.mjs +13 -13
  217. package/dist/tooltip/index.mjs +17 -16
  218. package/dist/tooltip/index.mjs.map +1 -1
  219. package/package.json +59 -6
  220. package/dist/chunks/_commonjsHelpers-DxUjvHAf.mjs.map +0 -1
  221. package/dist/chunks/accordion-C-7WU65v.mjs.map +0 -1
  222. package/dist/chunks/index-ypP8ZSEh.mjs.map +0 -1
  223. package/dist/chunks/pagination-ByGWAyDY.mjs.map +0 -1
  224. package/dist/chunks/scroll-area-BCPovfc9.mjs.map +0 -1
@@ -0,0 +1,1793 @@
1
+ import * as React from 'react';
2
+ import { useRef, useState, useCallback, useEffect } from 'react';
3
+ import { c as cn } from '../chunks/utils-AmLv58nm.mjs';
4
+ import { c as createLucideIcon } from '../chunks/createLucideIcon-DOOu6ntc.mjs';
5
+ import { B as Button } from '../chunks/button-TULRIYFO.mjs';
6
+ import '../chunks/bundle-mjs-8KEENQOJ.mjs';
7
+ import '@radix-ui/react-slot';
8
+ import 'class-variance-authority';
9
+
10
+ const __iconNode$1 = [
11
+ [
12
+ "path",
13
+ {
14
+ d: "m12 19-7-7 7-7",
15
+ key: "1l729n"
16
+ }
17
+ ],
18
+ [
19
+ "path",
20
+ {
21
+ d: "M19 12H5",
22
+ key: "x3x0zl"
23
+ }
24
+ ]
25
+ ];
26
+ const ArrowLeft = createLucideIcon("ArrowLeft", __iconNode$1);
27
+
28
+ const __iconNode = [
29
+ [
30
+ "path",
31
+ {
32
+ d: "M5 12h14",
33
+ key: "1ays0h"
34
+ }
35
+ ],
36
+ [
37
+ "path",
38
+ {
39
+ d: "m12 5 7 7-7 7",
40
+ key: "xquz4c"
41
+ }
42
+ ]
43
+ ];
44
+ const ArrowRight = createLucideIcon("ArrowRight", __iconNode);
45
+
46
+ function isObject$1(subject) {
47
+ return Object.prototype.toString.call(subject) === '[object Object]';
48
+ }
49
+ function isRecord(subject) {
50
+ return isObject$1(subject) || Array.isArray(subject);
51
+ }
52
+ function canUseDOM() {
53
+ return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
54
+ }
55
+ function areOptionsEqual(optionsA, optionsB) {
56
+ const optionsAKeys = Object.keys(optionsA);
57
+ const optionsBKeys = Object.keys(optionsB);
58
+ if (optionsAKeys.length !== optionsBKeys.length) return false;
59
+ const breakpointsA = JSON.stringify(Object.keys(optionsA.breakpoints || {}));
60
+ const breakpointsB = JSON.stringify(Object.keys(optionsB.breakpoints || {}));
61
+ if (breakpointsA !== breakpointsB) return false;
62
+ return optionsAKeys.every((key)=>{
63
+ const valueA = optionsA[key];
64
+ const valueB = optionsB[key];
65
+ if (typeof valueA === 'function') return `${valueA}` === `${valueB}`;
66
+ if (!isRecord(valueA) || !isRecord(valueB)) return valueA === valueB;
67
+ return areOptionsEqual(valueA, valueB);
68
+ });
69
+ }
70
+ function sortAndMapPluginToOptions(plugins) {
71
+ return plugins.concat().sort((a, b)=>a.name > b.name ? 1 : -1).map((plugin)=>plugin.options);
72
+ }
73
+ function arePluginsEqual(pluginsA, pluginsB) {
74
+ if (pluginsA.length !== pluginsB.length) return false;
75
+ const optionsA = sortAndMapPluginToOptions(pluginsA);
76
+ const optionsB = sortAndMapPluginToOptions(pluginsB);
77
+ return optionsA.every((optionA, index)=>{
78
+ const optionB = optionsB[index];
79
+ return areOptionsEqual(optionA, optionB);
80
+ });
81
+ }
82
+
83
+ function isNumber(subject) {
84
+ return typeof subject === 'number';
85
+ }
86
+ function isString(subject) {
87
+ return typeof subject === 'string';
88
+ }
89
+ function isBoolean(subject) {
90
+ return typeof subject === 'boolean';
91
+ }
92
+ function isObject(subject) {
93
+ return Object.prototype.toString.call(subject) === '[object Object]';
94
+ }
95
+ function mathAbs(n) {
96
+ return Math.abs(n);
97
+ }
98
+ function mathSign(n) {
99
+ return Math.sign(n);
100
+ }
101
+ function deltaAbs(valueB, valueA) {
102
+ return mathAbs(valueB - valueA);
103
+ }
104
+ function factorAbs(valueB, valueA) {
105
+ if (valueB === 0 || valueA === 0) return 0;
106
+ if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
107
+ const diff = deltaAbs(mathAbs(valueB), mathAbs(valueA));
108
+ return mathAbs(diff / valueB);
109
+ }
110
+ function roundToTwoDecimals(num) {
111
+ return Math.round(num * 100) / 100;
112
+ }
113
+ function arrayKeys(array) {
114
+ return objectKeys(array).map(Number);
115
+ }
116
+ function arrayLast(array) {
117
+ return array[arrayLastIndex(array)];
118
+ }
119
+ function arrayLastIndex(array) {
120
+ return Math.max(0, array.length - 1);
121
+ }
122
+ function arrayIsLastIndex(array, index) {
123
+ return index === arrayLastIndex(array);
124
+ }
125
+ function arrayFromNumber(n, startAt = 0) {
126
+ return Array.from(Array(n), (_, i)=>startAt + i);
127
+ }
128
+ function objectKeys(object) {
129
+ return Object.keys(object);
130
+ }
131
+ function objectsMergeDeep(objectA, objectB) {
132
+ return [
133
+ objectA,
134
+ objectB
135
+ ].reduce((mergedObjects, currentObject)=>{
136
+ objectKeys(currentObject).forEach((key)=>{
137
+ const valueA = mergedObjects[key];
138
+ const valueB = currentObject[key];
139
+ const areObjects = isObject(valueA) && isObject(valueB);
140
+ mergedObjects[key] = areObjects ? objectsMergeDeep(valueA, valueB) : valueB;
141
+ });
142
+ return mergedObjects;
143
+ }, {});
144
+ }
145
+ function isMouseEvent(evt, ownerWindow) {
146
+ return typeof ownerWindow.MouseEvent !== 'undefined' && evt instanceof ownerWindow.MouseEvent;
147
+ }
148
+ function Alignment(align, viewSize) {
149
+ const predefined = {
150
+ start,
151
+ center,
152
+ end
153
+ };
154
+ function start() {
155
+ return 0;
156
+ }
157
+ function center(n) {
158
+ return end(n) / 2;
159
+ }
160
+ function end(n) {
161
+ return viewSize - n;
162
+ }
163
+ function measure(n, index) {
164
+ if (isString(align)) return predefined[align](n);
165
+ return align(viewSize, n, index);
166
+ }
167
+ const self = {
168
+ measure
169
+ };
170
+ return self;
171
+ }
172
+ function EventStore() {
173
+ let listeners = [];
174
+ function add(node, type, handler, options = {
175
+ passive: true
176
+ }) {
177
+ let removeListener;
178
+ if ('addEventListener' in node) {
179
+ node.addEventListener(type, handler, options);
180
+ removeListener = ()=>node.removeEventListener(type, handler, options);
181
+ } else {
182
+ const legacyMediaQueryList = node;
183
+ legacyMediaQueryList.addListener(handler);
184
+ removeListener = ()=>legacyMediaQueryList.removeListener(handler);
185
+ }
186
+ listeners.push(removeListener);
187
+ return self;
188
+ }
189
+ function clear() {
190
+ listeners = listeners.filter((remove)=>remove());
191
+ }
192
+ const self = {
193
+ add,
194
+ clear
195
+ };
196
+ return self;
197
+ }
198
+ function Animations(ownerDocument, ownerWindow, update, render) {
199
+ const documentVisibleHandler = EventStore();
200
+ const fixedTimeStep = 1000 / 60;
201
+ let lastTimeStamp = null;
202
+ let accumulatedTime = 0;
203
+ let animationId = 0;
204
+ function init() {
205
+ documentVisibleHandler.add(ownerDocument, 'visibilitychange', ()=>{
206
+ if (ownerDocument.hidden) reset();
207
+ });
208
+ }
209
+ function destroy() {
210
+ stop();
211
+ documentVisibleHandler.clear();
212
+ }
213
+ function animate(timeStamp) {
214
+ if (!animationId) return;
215
+ if (!lastTimeStamp) {
216
+ lastTimeStamp = timeStamp;
217
+ update();
218
+ update();
219
+ }
220
+ const timeElapsed = timeStamp - lastTimeStamp;
221
+ lastTimeStamp = timeStamp;
222
+ accumulatedTime += timeElapsed;
223
+ while(accumulatedTime >= fixedTimeStep){
224
+ update();
225
+ accumulatedTime -= fixedTimeStep;
226
+ }
227
+ const alpha = accumulatedTime / fixedTimeStep;
228
+ render(alpha);
229
+ if (animationId) {
230
+ animationId = ownerWindow.requestAnimationFrame(animate);
231
+ }
232
+ }
233
+ function start() {
234
+ if (animationId) return;
235
+ animationId = ownerWindow.requestAnimationFrame(animate);
236
+ }
237
+ function stop() {
238
+ ownerWindow.cancelAnimationFrame(animationId);
239
+ lastTimeStamp = null;
240
+ accumulatedTime = 0;
241
+ animationId = 0;
242
+ }
243
+ function reset() {
244
+ lastTimeStamp = null;
245
+ accumulatedTime = 0;
246
+ }
247
+ const self = {
248
+ init,
249
+ destroy,
250
+ start,
251
+ stop,
252
+ update,
253
+ render
254
+ };
255
+ return self;
256
+ }
257
+ function Axis(axis, contentDirection) {
258
+ const isRightToLeft = contentDirection === 'rtl';
259
+ const isVertical = axis === 'y';
260
+ const scroll = isVertical ? 'y' : 'x';
261
+ const cross = isVertical ? 'x' : 'y';
262
+ const sign = !isVertical && isRightToLeft ? -1 : 1;
263
+ const startEdge = getStartEdge();
264
+ const endEdge = getEndEdge();
265
+ function measureSize(nodeRect) {
266
+ const { height, width } = nodeRect;
267
+ return isVertical ? height : width;
268
+ }
269
+ function getStartEdge() {
270
+ if (isVertical) return 'top';
271
+ return isRightToLeft ? 'right' : 'left';
272
+ }
273
+ function getEndEdge() {
274
+ if (isVertical) return 'bottom';
275
+ return isRightToLeft ? 'left' : 'right';
276
+ }
277
+ function direction(n) {
278
+ return n * sign;
279
+ }
280
+ const self = {
281
+ scroll,
282
+ cross,
283
+ startEdge,
284
+ endEdge,
285
+ measureSize,
286
+ direction
287
+ };
288
+ return self;
289
+ }
290
+ function Limit(min = 0, max = 0) {
291
+ const length = mathAbs(min - max);
292
+ function reachedMin(n) {
293
+ return n < min;
294
+ }
295
+ function reachedMax(n) {
296
+ return n > max;
297
+ }
298
+ function reachedAny(n) {
299
+ return reachedMin(n) || reachedMax(n);
300
+ }
301
+ function constrain(n) {
302
+ if (!reachedAny(n)) return n;
303
+ return reachedMin(n) ? min : max;
304
+ }
305
+ function removeOffset(n) {
306
+ if (!length) return n;
307
+ return n - length * Math.ceil((n - max) / length);
308
+ }
309
+ const self = {
310
+ length,
311
+ max,
312
+ min,
313
+ constrain,
314
+ reachedAny,
315
+ reachedMax,
316
+ reachedMin,
317
+ removeOffset
318
+ };
319
+ return self;
320
+ }
321
+ function Counter(max, start, loop) {
322
+ const { constrain } = Limit(0, max);
323
+ const loopEnd = max + 1;
324
+ let counter = withinLimit(start);
325
+ function withinLimit(n) {
326
+ return !loop ? constrain(n) : mathAbs((loopEnd + n) % loopEnd);
327
+ }
328
+ function get() {
329
+ return counter;
330
+ }
331
+ function set(n) {
332
+ counter = withinLimit(n);
333
+ return self;
334
+ }
335
+ function add(n) {
336
+ return clone().set(get() + n);
337
+ }
338
+ function clone() {
339
+ return Counter(max, get(), loop);
340
+ }
341
+ const self = {
342
+ get,
343
+ set,
344
+ add,
345
+ clone
346
+ };
347
+ return self;
348
+ }
349
+ function DragHandler(axis, rootNode, ownerDocument, ownerWindow, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction, watchDrag) {
350
+ const { cross: crossAxis, direction } = axis;
351
+ const focusNodes = [
352
+ 'INPUT',
353
+ 'SELECT',
354
+ 'TEXTAREA'
355
+ ];
356
+ const nonPassiveEvent = {
357
+ passive: false
358
+ };
359
+ const initEvents = EventStore();
360
+ const dragEvents = EventStore();
361
+ const goToNextThreshold = Limit(50, 225).constrain(percentOfView.measure(20));
362
+ const snapForceBoost = {
363
+ mouse: 300,
364
+ touch: 400
365
+ };
366
+ const freeForceBoost = {
367
+ mouse: 500,
368
+ touch: 600
369
+ };
370
+ const baseSpeed = dragFree ? 43 : 25;
371
+ let isMoving = false;
372
+ let startScroll = 0;
373
+ let startCross = 0;
374
+ let pointerIsDown = false;
375
+ let preventScroll = false;
376
+ let preventClick = false;
377
+ let isMouse = false;
378
+ function init(emblaApi) {
379
+ if (!watchDrag) return;
380
+ function downIfAllowed(evt) {
381
+ if (isBoolean(watchDrag) || watchDrag(emblaApi, evt)) down(evt);
382
+ }
383
+ const node = rootNode;
384
+ initEvents.add(node, 'dragstart', (evt)=>evt.preventDefault(), nonPassiveEvent).add(node, 'touchmove', ()=>undefined, nonPassiveEvent).add(node, 'touchend', ()=>undefined).add(node, 'touchstart', downIfAllowed).add(node, 'mousedown', downIfAllowed).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click, true);
385
+ }
386
+ function destroy() {
387
+ initEvents.clear();
388
+ dragEvents.clear();
389
+ }
390
+ function addDragEvents() {
391
+ const node = isMouse ? ownerDocument : rootNode;
392
+ dragEvents.add(node, 'touchmove', move, nonPassiveEvent).add(node, 'touchend', up).add(node, 'mousemove', move, nonPassiveEvent).add(node, 'mouseup', up);
393
+ }
394
+ function isFocusNode(node) {
395
+ const nodeName = node.nodeName || '';
396
+ return focusNodes.includes(nodeName);
397
+ }
398
+ function forceBoost() {
399
+ const boost = dragFree ? freeForceBoost : snapForceBoost;
400
+ const type = isMouse ? 'mouse' : 'touch';
401
+ return boost[type];
402
+ }
403
+ function allowedForce(force, targetChanged) {
404
+ const next = index.add(mathSign(force) * -1);
405
+ const baseForce = scrollTarget.byDistance(force, !dragFree).distance;
406
+ if (dragFree || mathAbs(force) < goToNextThreshold) return baseForce;
407
+ if (skipSnaps && targetChanged) return baseForce * 0.5;
408
+ return scrollTarget.byIndex(next.get(), 0).distance;
409
+ }
410
+ function down(evt) {
411
+ const isMouseEvt = isMouseEvent(evt, ownerWindow);
412
+ isMouse = isMouseEvt;
413
+ preventClick = dragFree && isMouseEvt && !evt.buttons && isMoving;
414
+ isMoving = deltaAbs(target.get(), location.get()) >= 2;
415
+ if (isMouseEvt && evt.button !== 0) return;
416
+ if (isFocusNode(evt.target)) return;
417
+ pointerIsDown = true;
418
+ dragTracker.pointerDown(evt);
419
+ scrollBody.useFriction(0).useDuration(0);
420
+ target.set(location);
421
+ addDragEvents();
422
+ startScroll = dragTracker.readPoint(evt);
423
+ startCross = dragTracker.readPoint(evt, crossAxis);
424
+ eventHandler.emit('pointerDown');
425
+ }
426
+ function move(evt) {
427
+ const isTouchEvt = !isMouseEvent(evt, ownerWindow);
428
+ if (isTouchEvt && evt.touches.length >= 2) return up(evt);
429
+ const lastScroll = dragTracker.readPoint(evt);
430
+ const lastCross = dragTracker.readPoint(evt, crossAxis);
431
+ const diffScroll = deltaAbs(lastScroll, startScroll);
432
+ const diffCross = deltaAbs(lastCross, startCross);
433
+ if (!preventScroll && !isMouse) {
434
+ if (!evt.cancelable) return up(evt);
435
+ preventScroll = diffScroll > diffCross;
436
+ if (!preventScroll) return up(evt);
437
+ }
438
+ const diff = dragTracker.pointerMove(evt);
439
+ if (diffScroll > dragThreshold) preventClick = true;
440
+ scrollBody.useFriction(0.3).useDuration(0.75);
441
+ animation.start();
442
+ target.add(direction(diff));
443
+ evt.preventDefault();
444
+ }
445
+ function up(evt) {
446
+ const currentLocation = scrollTarget.byDistance(0, false);
447
+ const targetChanged = currentLocation.index !== index.get();
448
+ const rawForce = dragTracker.pointerUp(evt) * forceBoost();
449
+ const force = allowedForce(direction(rawForce), targetChanged);
450
+ const forceFactor = factorAbs(rawForce, force);
451
+ const speed = baseSpeed - 10 * forceFactor;
452
+ const friction = baseFriction + forceFactor / 50;
453
+ preventScroll = false;
454
+ pointerIsDown = false;
455
+ dragEvents.clear();
456
+ scrollBody.useDuration(speed).useFriction(friction);
457
+ scrollTo.distance(force, !dragFree);
458
+ isMouse = false;
459
+ eventHandler.emit('pointerUp');
460
+ }
461
+ function click(evt) {
462
+ if (preventClick) {
463
+ evt.stopPropagation();
464
+ evt.preventDefault();
465
+ preventClick = false;
466
+ }
467
+ }
468
+ function pointerDown() {
469
+ return pointerIsDown;
470
+ }
471
+ const self = {
472
+ init,
473
+ destroy,
474
+ pointerDown
475
+ };
476
+ return self;
477
+ }
478
+ function DragTracker(axis, ownerWindow) {
479
+ const logInterval = 170;
480
+ let startEvent;
481
+ let lastEvent;
482
+ function readTime(evt) {
483
+ return evt.timeStamp;
484
+ }
485
+ function readPoint(evt, evtAxis) {
486
+ const property = evtAxis || axis.scroll;
487
+ const coord = `client${property === 'x' ? 'X' : 'Y'}`;
488
+ return (isMouseEvent(evt, ownerWindow) ? evt : evt.touches[0])[coord];
489
+ }
490
+ function pointerDown(evt) {
491
+ startEvent = evt;
492
+ lastEvent = evt;
493
+ return readPoint(evt);
494
+ }
495
+ function pointerMove(evt) {
496
+ const diff = readPoint(evt) - readPoint(lastEvent);
497
+ const expired = readTime(evt) - readTime(startEvent) > logInterval;
498
+ lastEvent = evt;
499
+ if (expired) startEvent = evt;
500
+ return diff;
501
+ }
502
+ function pointerUp(evt) {
503
+ if (!startEvent || !lastEvent) return 0;
504
+ const diffDrag = readPoint(lastEvent) - readPoint(startEvent);
505
+ const diffTime = readTime(evt) - readTime(startEvent);
506
+ const expired = readTime(evt) - readTime(lastEvent) > logInterval;
507
+ const force = diffDrag / diffTime;
508
+ const isFlick = diffTime && !expired && mathAbs(force) > 0.1;
509
+ return isFlick ? force : 0;
510
+ }
511
+ const self = {
512
+ pointerDown,
513
+ pointerMove,
514
+ pointerUp,
515
+ readPoint
516
+ };
517
+ return self;
518
+ }
519
+ function NodeRects() {
520
+ function measure(node) {
521
+ const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = node;
522
+ const offset = {
523
+ top: offsetTop,
524
+ right: offsetLeft + offsetWidth,
525
+ bottom: offsetTop + offsetHeight,
526
+ left: offsetLeft,
527
+ width: offsetWidth,
528
+ height: offsetHeight
529
+ };
530
+ return offset;
531
+ }
532
+ const self = {
533
+ measure
534
+ };
535
+ return self;
536
+ }
537
+ function PercentOfView(viewSize) {
538
+ function measure(n) {
539
+ return viewSize * (n / 100);
540
+ }
541
+ const self = {
542
+ measure
543
+ };
544
+ return self;
545
+ }
546
+ function ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects) {
547
+ const observeNodes = [
548
+ container
549
+ ].concat(slides);
550
+ let resizeObserver;
551
+ let containerSize;
552
+ let slideSizes = [];
553
+ let destroyed = false;
554
+ function readSize(node) {
555
+ return axis.measureSize(nodeRects.measure(node));
556
+ }
557
+ function init(emblaApi) {
558
+ if (!watchResize) return;
559
+ containerSize = readSize(container);
560
+ slideSizes = slides.map(readSize);
561
+ function defaultCallback(entries) {
562
+ for (const entry of entries){
563
+ if (destroyed) return;
564
+ const isContainer = entry.target === container;
565
+ const slideIndex = slides.indexOf(entry.target);
566
+ const lastSize = isContainer ? containerSize : slideSizes[slideIndex];
567
+ const newSize = readSize(isContainer ? container : slides[slideIndex]);
568
+ const diffSize = mathAbs(newSize - lastSize);
569
+ if (diffSize >= 0.5) {
570
+ emblaApi.reInit();
571
+ eventHandler.emit('resize');
572
+ break;
573
+ }
574
+ }
575
+ }
576
+ resizeObserver = new ResizeObserver((entries)=>{
577
+ if (isBoolean(watchResize) || watchResize(emblaApi, entries)) {
578
+ defaultCallback(entries);
579
+ }
580
+ });
581
+ ownerWindow.requestAnimationFrame(()=>{
582
+ observeNodes.forEach((node)=>resizeObserver.observe(node));
583
+ });
584
+ }
585
+ function destroy() {
586
+ destroyed = true;
587
+ if (resizeObserver) resizeObserver.disconnect();
588
+ }
589
+ const self = {
590
+ init,
591
+ destroy
592
+ };
593
+ return self;
594
+ }
595
+ function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
596
+ let scrollVelocity = 0;
597
+ let scrollDirection = 0;
598
+ let scrollDuration = baseDuration;
599
+ let scrollFriction = baseFriction;
600
+ let rawLocation = location.get();
601
+ let rawLocationPrevious = 0;
602
+ function seek() {
603
+ const displacement = target.get() - location.get();
604
+ const isInstant = !scrollDuration;
605
+ let scrollDistance = 0;
606
+ if (isInstant) {
607
+ scrollVelocity = 0;
608
+ previousLocation.set(target);
609
+ location.set(target);
610
+ scrollDistance = displacement;
611
+ } else {
612
+ previousLocation.set(location);
613
+ scrollVelocity += displacement / scrollDuration;
614
+ scrollVelocity *= scrollFriction;
615
+ rawLocation += scrollVelocity;
616
+ location.add(scrollVelocity);
617
+ scrollDistance = rawLocation - rawLocationPrevious;
618
+ }
619
+ scrollDirection = mathSign(scrollDistance);
620
+ rawLocationPrevious = rawLocation;
621
+ return self;
622
+ }
623
+ function settled() {
624
+ const diff = target.get() - offsetLocation.get();
625
+ return mathAbs(diff) < 0.001;
626
+ }
627
+ function duration() {
628
+ return scrollDuration;
629
+ }
630
+ function direction() {
631
+ return scrollDirection;
632
+ }
633
+ function velocity() {
634
+ return scrollVelocity;
635
+ }
636
+ function useBaseDuration() {
637
+ return useDuration(baseDuration);
638
+ }
639
+ function useBaseFriction() {
640
+ return useFriction(baseFriction);
641
+ }
642
+ function useDuration(n) {
643
+ scrollDuration = n;
644
+ return self;
645
+ }
646
+ function useFriction(n) {
647
+ scrollFriction = n;
648
+ return self;
649
+ }
650
+ const self = {
651
+ direction,
652
+ duration,
653
+ velocity,
654
+ seek,
655
+ settled,
656
+ useBaseFriction,
657
+ useBaseDuration,
658
+ useFriction,
659
+ useDuration
660
+ };
661
+ return self;
662
+ }
663
+ function ScrollBounds(limit, location, target, scrollBody, percentOfView) {
664
+ const pullBackThreshold = percentOfView.measure(10);
665
+ const edgeOffsetTolerance = percentOfView.measure(50);
666
+ const frictionLimit = Limit(0.1, 0.99);
667
+ let disabled = false;
668
+ function shouldConstrain() {
669
+ if (disabled) return false;
670
+ if (!limit.reachedAny(target.get())) return false;
671
+ if (!limit.reachedAny(location.get())) return false;
672
+ return true;
673
+ }
674
+ function constrain(pointerDown) {
675
+ if (!shouldConstrain()) return;
676
+ const edge = limit.reachedMin(location.get()) ? 'min' : 'max';
677
+ const diffToEdge = mathAbs(limit[edge] - location.get());
678
+ const diffToTarget = target.get() - location.get();
679
+ const friction = frictionLimit.constrain(diffToEdge / edgeOffsetTolerance);
680
+ target.subtract(diffToTarget * friction);
681
+ if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
682
+ target.set(limit.constrain(target.get()));
683
+ scrollBody.useDuration(25).useBaseFriction();
684
+ }
685
+ }
686
+ function toggleActive(active) {
687
+ disabled = !active;
688
+ }
689
+ const self = {
690
+ shouldConstrain,
691
+ constrain,
692
+ toggleActive
693
+ };
694
+ return self;
695
+ }
696
+ function ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance) {
697
+ const scrollBounds = Limit(-contentSize + viewSize, 0);
698
+ const snapsBounded = measureBounded();
699
+ const scrollContainLimit = findScrollContainLimit();
700
+ const snapsContained = measureContained();
701
+ function usePixelTolerance(bound, snap) {
702
+ return deltaAbs(bound, snap) <= 1;
703
+ }
704
+ function findScrollContainLimit() {
705
+ const startSnap = snapsBounded[0];
706
+ const endSnap = arrayLast(snapsBounded);
707
+ const min = snapsBounded.lastIndexOf(startSnap);
708
+ const max = snapsBounded.indexOf(endSnap) + 1;
709
+ return Limit(min, max);
710
+ }
711
+ function measureBounded() {
712
+ return snapsAligned.map((snapAligned, index)=>{
713
+ const { min, max } = scrollBounds;
714
+ const snap = scrollBounds.constrain(snapAligned);
715
+ const isFirst = !index;
716
+ const isLast = arrayIsLastIndex(snapsAligned, index);
717
+ if (isFirst) return max;
718
+ if (isLast) return min;
719
+ if (usePixelTolerance(min, snap)) return min;
720
+ if (usePixelTolerance(max, snap)) return max;
721
+ return snap;
722
+ }).map((scrollBound)=>parseFloat(scrollBound.toFixed(3)));
723
+ }
724
+ function measureContained() {
725
+ if (contentSize <= viewSize + pixelTolerance) return [
726
+ scrollBounds.max
727
+ ];
728
+ if (containScroll === 'keepSnaps') return snapsBounded;
729
+ const { min, max } = scrollContainLimit;
730
+ return snapsBounded.slice(min, max);
731
+ }
732
+ const self = {
733
+ snapsContained,
734
+ scrollContainLimit
735
+ };
736
+ return self;
737
+ }
738
+ function ScrollLimit(contentSize, scrollSnaps, loop) {
739
+ const max = scrollSnaps[0];
740
+ const min = loop ? max - contentSize : arrayLast(scrollSnaps);
741
+ const limit = Limit(min, max);
742
+ const self = {
743
+ limit
744
+ };
745
+ return self;
746
+ }
747
+ function ScrollLooper(contentSize, limit, location, vectors) {
748
+ const jointSafety = 0.1;
749
+ const min = limit.min + jointSafety;
750
+ const max = limit.max + jointSafety;
751
+ const { reachedMin, reachedMax } = Limit(min, max);
752
+ function shouldLoop(direction) {
753
+ if (direction === 1) return reachedMax(location.get());
754
+ if (direction === -1) return reachedMin(location.get());
755
+ return false;
756
+ }
757
+ function loop(direction) {
758
+ if (!shouldLoop(direction)) return;
759
+ const loopDistance = contentSize * (direction * -1);
760
+ vectors.forEach((v)=>v.add(loopDistance));
761
+ }
762
+ const self = {
763
+ loop
764
+ };
765
+ return self;
766
+ }
767
+ function ScrollProgress(limit) {
768
+ const { max, length } = limit;
769
+ function get(n) {
770
+ const currentLocation = n - max;
771
+ return length ? currentLocation / -length : 0;
772
+ }
773
+ const self = {
774
+ get
775
+ };
776
+ return self;
777
+ }
778
+ function ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll) {
779
+ const { startEdge, endEdge } = axis;
780
+ const { groupSlides } = slidesToScroll;
781
+ const alignments = measureSizes().map(alignment.measure);
782
+ const snaps = measureUnaligned();
783
+ const snapsAligned = measureAligned();
784
+ function measureSizes() {
785
+ return groupSlides(slideRects).map((rects)=>arrayLast(rects)[endEdge] - rects[0][startEdge]).map(mathAbs);
786
+ }
787
+ function measureUnaligned() {
788
+ return slideRects.map((rect)=>containerRect[startEdge] - rect[startEdge]).map((snap)=>-mathAbs(snap));
789
+ }
790
+ function measureAligned() {
791
+ return groupSlides(snaps).map((g)=>g[0]).map((snap, index)=>snap + alignments[index]);
792
+ }
793
+ const self = {
794
+ snaps,
795
+ snapsAligned
796
+ };
797
+ return self;
798
+ }
799
+ function SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes) {
800
+ const { groupSlides } = slidesToScroll;
801
+ const { min, max } = scrollContainLimit;
802
+ const slideRegistry = createSlideRegistry();
803
+ function createSlideRegistry() {
804
+ const groupedSlideIndexes = groupSlides(slideIndexes);
805
+ const doNotContain = !containSnaps || containScroll === 'keepSnaps';
806
+ if (scrollSnaps.length === 1) return [
807
+ slideIndexes
808
+ ];
809
+ if (doNotContain) return groupedSlideIndexes;
810
+ return groupedSlideIndexes.slice(min, max).map((group, index, groups)=>{
811
+ const isFirst = !index;
812
+ const isLast = arrayIsLastIndex(groups, index);
813
+ if (isFirst) {
814
+ const range = arrayLast(groups[0]) + 1;
815
+ return arrayFromNumber(range);
816
+ }
817
+ if (isLast) {
818
+ const range = arrayLastIndex(slideIndexes) - arrayLast(groups)[0] + 1;
819
+ return arrayFromNumber(range, arrayLast(groups)[0]);
820
+ }
821
+ return group;
822
+ });
823
+ }
824
+ const self = {
825
+ slideRegistry
826
+ };
827
+ return self;
828
+ }
829
+ function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
830
+ const { reachedAny, removeOffset, constrain } = limit;
831
+ function minDistance(distances) {
832
+ return distances.concat().sort((a, b)=>mathAbs(a) - mathAbs(b))[0];
833
+ }
834
+ function findTargetSnap(target) {
835
+ const distance = loop ? removeOffset(target) : constrain(target);
836
+ const ascDiffsToSnaps = scrollSnaps.map((snap, index)=>({
837
+ diff: shortcut(snap - distance, 0),
838
+ index
839
+ })).sort((d1, d2)=>mathAbs(d1.diff) - mathAbs(d2.diff));
840
+ const { index } = ascDiffsToSnaps[0];
841
+ return {
842
+ index,
843
+ distance
844
+ };
845
+ }
846
+ function shortcut(target, direction) {
847
+ const targets = [
848
+ target,
849
+ target + contentSize,
850
+ target - contentSize
851
+ ];
852
+ if (!loop) return target;
853
+ if (!direction) return minDistance(targets);
854
+ const matchingTargets = targets.filter((t)=>mathSign(t) === direction);
855
+ if (matchingTargets.length) return minDistance(matchingTargets);
856
+ return arrayLast(targets) - contentSize;
857
+ }
858
+ function byIndex(index, direction) {
859
+ const diffToSnap = scrollSnaps[index] - targetVector.get();
860
+ const distance = shortcut(diffToSnap, direction);
861
+ return {
862
+ index,
863
+ distance
864
+ };
865
+ }
866
+ function byDistance(distance, snap) {
867
+ const target = targetVector.get() + distance;
868
+ const { index, distance: targetSnapDistance } = findTargetSnap(target);
869
+ const reachedBound = !loop && reachedAny(target);
870
+ if (!snap || reachedBound) return {
871
+ index,
872
+ distance
873
+ };
874
+ const diffToSnap = scrollSnaps[index] - targetSnapDistance;
875
+ const snapDistance = distance + shortcut(diffToSnap, 0);
876
+ return {
877
+ index,
878
+ distance: snapDistance
879
+ };
880
+ }
881
+ const self = {
882
+ byDistance,
883
+ byIndex,
884
+ shortcut
885
+ };
886
+ return self;
887
+ }
888
+ function ScrollTo(animation, indexCurrent, indexPrevious, scrollBody, scrollTarget, targetVector, eventHandler) {
889
+ function scrollTo(target) {
890
+ const distanceDiff = target.distance;
891
+ const indexDiff = target.index !== indexCurrent.get();
892
+ targetVector.add(distanceDiff);
893
+ if (distanceDiff) {
894
+ if (scrollBody.duration()) {
895
+ animation.start();
896
+ } else {
897
+ animation.update();
898
+ animation.render(1);
899
+ animation.update();
900
+ }
901
+ }
902
+ if (indexDiff) {
903
+ indexPrevious.set(indexCurrent.get());
904
+ indexCurrent.set(target.index);
905
+ eventHandler.emit('select');
906
+ }
907
+ }
908
+ function distance(n, snap) {
909
+ const target = scrollTarget.byDistance(n, snap);
910
+ scrollTo(target);
911
+ }
912
+ function index(n, direction) {
913
+ const targetIndex = indexCurrent.clone().set(n);
914
+ const target = scrollTarget.byIndex(targetIndex.get(), direction);
915
+ scrollTo(target);
916
+ }
917
+ const self = {
918
+ distance,
919
+ index
920
+ };
921
+ return self;
922
+ }
923
+ function SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus) {
924
+ const focusListenerOptions = {
925
+ passive: true,
926
+ capture: true
927
+ };
928
+ let lastTabPressTime = 0;
929
+ function init(emblaApi) {
930
+ if (!watchFocus) return;
931
+ function defaultCallback(index) {
932
+ const nowTime = new Date().getTime();
933
+ const diffTime = nowTime - lastTabPressTime;
934
+ if (diffTime > 10) return;
935
+ eventHandler.emit('slideFocusStart');
936
+ root.scrollLeft = 0;
937
+ const group = slideRegistry.findIndex((group)=>group.includes(index));
938
+ if (!isNumber(group)) return;
939
+ scrollBody.useDuration(0);
940
+ scrollTo.index(group, 0);
941
+ eventHandler.emit('slideFocus');
942
+ }
943
+ eventStore.add(document, 'keydown', registerTabPress, false);
944
+ slides.forEach((slide, slideIndex)=>{
945
+ eventStore.add(slide, 'focus', (evt)=>{
946
+ if (isBoolean(watchFocus) || watchFocus(emblaApi, evt)) {
947
+ defaultCallback(slideIndex);
948
+ }
949
+ }, focusListenerOptions);
950
+ });
951
+ }
952
+ function registerTabPress(event) {
953
+ if (event.code === 'Tab') lastTabPressTime = new Date().getTime();
954
+ }
955
+ const self = {
956
+ init
957
+ };
958
+ return self;
959
+ }
960
+ function Vector1D(initialValue) {
961
+ let value = initialValue;
962
+ function get() {
963
+ return value;
964
+ }
965
+ function set(n) {
966
+ value = normalizeInput(n);
967
+ }
968
+ function add(n) {
969
+ value += normalizeInput(n);
970
+ }
971
+ function subtract(n) {
972
+ value -= normalizeInput(n);
973
+ }
974
+ function normalizeInput(n) {
975
+ return isNumber(n) ? n : n.get();
976
+ }
977
+ const self = {
978
+ get,
979
+ set,
980
+ add,
981
+ subtract
982
+ };
983
+ return self;
984
+ }
985
+ function Translate(axis, container) {
986
+ const translate = axis.scroll === 'x' ? x : y;
987
+ const containerStyle = container.style;
988
+ let previousTarget = null;
989
+ let disabled = false;
990
+ function x(n) {
991
+ return `translate3d(${n}px,0px,0px)`;
992
+ }
993
+ function y(n) {
994
+ return `translate3d(0px,${n}px,0px)`;
995
+ }
996
+ function to(target) {
997
+ if (disabled) return;
998
+ const newTarget = roundToTwoDecimals(axis.direction(target));
999
+ if (newTarget === previousTarget) return;
1000
+ containerStyle.transform = translate(newTarget);
1001
+ previousTarget = newTarget;
1002
+ }
1003
+ function toggleActive(active) {
1004
+ disabled = !active;
1005
+ }
1006
+ function clear() {
1007
+ if (disabled) return;
1008
+ containerStyle.transform = '';
1009
+ if (!container.getAttribute('style')) container.removeAttribute('style');
1010
+ }
1011
+ const self = {
1012
+ clear,
1013
+ to,
1014
+ toggleActive
1015
+ };
1016
+ return self;
1017
+ }
1018
+ function SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, location, slides) {
1019
+ const roundingSafety = 0.5;
1020
+ const ascItems = arrayKeys(slideSizesWithGaps);
1021
+ const descItems = arrayKeys(slideSizesWithGaps).reverse();
1022
+ const loopPoints = startPoints().concat(endPoints());
1023
+ function removeSlideSizes(indexes, from) {
1024
+ return indexes.reduce((a, i)=>{
1025
+ return a - slideSizesWithGaps[i];
1026
+ }, from);
1027
+ }
1028
+ function slidesInGap(indexes, gap) {
1029
+ return indexes.reduce((a, i)=>{
1030
+ const remainingGap = removeSlideSizes(a, gap);
1031
+ return remainingGap > 0 ? a.concat([
1032
+ i
1033
+ ]) : a;
1034
+ }, []);
1035
+ }
1036
+ function findSlideBounds(offset) {
1037
+ return snaps.map((snap, index)=>({
1038
+ start: snap - slideSizes[index] + roundingSafety + offset,
1039
+ end: snap + viewSize - roundingSafety + offset
1040
+ }));
1041
+ }
1042
+ function findLoopPoints(indexes, offset, isEndEdge) {
1043
+ const slideBounds = findSlideBounds(offset);
1044
+ return indexes.map((index)=>{
1045
+ const initial = isEndEdge ? 0 : -contentSize;
1046
+ const altered = isEndEdge ? contentSize : 0;
1047
+ const boundEdge = isEndEdge ? 'end' : 'start';
1048
+ const loopPoint = slideBounds[index][boundEdge];
1049
+ return {
1050
+ index,
1051
+ loopPoint,
1052
+ slideLocation: Vector1D(-1),
1053
+ translate: Translate(axis, slides[index]),
1054
+ target: ()=>location.get() > loopPoint ? initial : altered
1055
+ };
1056
+ });
1057
+ }
1058
+ function startPoints() {
1059
+ const gap = scrollSnaps[0];
1060
+ const indexes = slidesInGap(descItems, gap);
1061
+ return findLoopPoints(indexes, contentSize, false);
1062
+ }
1063
+ function endPoints() {
1064
+ const gap = viewSize - scrollSnaps[0] - 1;
1065
+ const indexes = slidesInGap(ascItems, gap);
1066
+ return findLoopPoints(indexes, -contentSize, true);
1067
+ }
1068
+ function canLoop() {
1069
+ return loopPoints.every(({ index })=>{
1070
+ const otherIndexes = ascItems.filter((i)=>i !== index);
1071
+ return removeSlideSizes(otherIndexes, viewSize) <= 0.1;
1072
+ });
1073
+ }
1074
+ function loop() {
1075
+ loopPoints.forEach((loopPoint)=>{
1076
+ const { target, translate, slideLocation } = loopPoint;
1077
+ const shiftLocation = target();
1078
+ if (shiftLocation === slideLocation.get()) return;
1079
+ translate.to(shiftLocation);
1080
+ slideLocation.set(shiftLocation);
1081
+ });
1082
+ }
1083
+ function clear() {
1084
+ loopPoints.forEach((loopPoint)=>loopPoint.translate.clear());
1085
+ }
1086
+ const self = {
1087
+ canLoop,
1088
+ clear,
1089
+ loop,
1090
+ loopPoints
1091
+ };
1092
+ return self;
1093
+ }
1094
+ function SlidesHandler(container, eventHandler, watchSlides) {
1095
+ let mutationObserver;
1096
+ let destroyed = false;
1097
+ function init(emblaApi) {
1098
+ if (!watchSlides) return;
1099
+ function defaultCallback(mutations) {
1100
+ for (const mutation of mutations){
1101
+ if (mutation.type === 'childList') {
1102
+ emblaApi.reInit();
1103
+ eventHandler.emit('slidesChanged');
1104
+ break;
1105
+ }
1106
+ }
1107
+ }
1108
+ mutationObserver = new MutationObserver((mutations)=>{
1109
+ if (destroyed) return;
1110
+ if (isBoolean(watchSlides) || watchSlides(emblaApi, mutations)) {
1111
+ defaultCallback(mutations);
1112
+ }
1113
+ });
1114
+ mutationObserver.observe(container, {
1115
+ childList: true
1116
+ });
1117
+ }
1118
+ function destroy() {
1119
+ if (mutationObserver) mutationObserver.disconnect();
1120
+ destroyed = true;
1121
+ }
1122
+ const self = {
1123
+ init,
1124
+ destroy
1125
+ };
1126
+ return self;
1127
+ }
1128
+ function SlidesInView(container, slides, eventHandler, threshold) {
1129
+ const intersectionEntryMap = {};
1130
+ let inViewCache = null;
1131
+ let notInViewCache = null;
1132
+ let intersectionObserver;
1133
+ let destroyed = false;
1134
+ function init() {
1135
+ intersectionObserver = new IntersectionObserver((entries)=>{
1136
+ if (destroyed) return;
1137
+ entries.forEach((entry)=>{
1138
+ const index = slides.indexOf(entry.target);
1139
+ intersectionEntryMap[index] = entry;
1140
+ });
1141
+ inViewCache = null;
1142
+ notInViewCache = null;
1143
+ eventHandler.emit('slidesInView');
1144
+ }, {
1145
+ root: container.parentElement,
1146
+ threshold
1147
+ });
1148
+ slides.forEach((slide)=>intersectionObserver.observe(slide));
1149
+ }
1150
+ function destroy() {
1151
+ if (intersectionObserver) intersectionObserver.disconnect();
1152
+ destroyed = true;
1153
+ }
1154
+ function createInViewList(inView) {
1155
+ return objectKeys(intersectionEntryMap).reduce((list, slideIndex)=>{
1156
+ const index = parseInt(slideIndex);
1157
+ const { isIntersecting } = intersectionEntryMap[index];
1158
+ const inViewMatch = inView && isIntersecting;
1159
+ const notInViewMatch = !inView && !isIntersecting;
1160
+ if (inViewMatch || notInViewMatch) list.push(index);
1161
+ return list;
1162
+ }, []);
1163
+ }
1164
+ function get(inView = true) {
1165
+ if (inView && inViewCache) return inViewCache;
1166
+ if (!inView && notInViewCache) return notInViewCache;
1167
+ const slideIndexes = createInViewList(inView);
1168
+ if (inView) inViewCache = slideIndexes;
1169
+ if (!inView) notInViewCache = slideIndexes;
1170
+ return slideIndexes;
1171
+ }
1172
+ const self = {
1173
+ init,
1174
+ destroy,
1175
+ get
1176
+ };
1177
+ return self;
1178
+ }
1179
+ function SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow) {
1180
+ const { measureSize, startEdge, endEdge } = axis;
1181
+ const withEdgeGap = slideRects[0] && readEdgeGap;
1182
+ const startGap = measureStartGap();
1183
+ const endGap = measureEndGap();
1184
+ const slideSizes = slideRects.map(measureSize);
1185
+ const slideSizesWithGaps = measureWithGaps();
1186
+ function measureStartGap() {
1187
+ if (!withEdgeGap) return 0;
1188
+ const slideRect = slideRects[0];
1189
+ return mathAbs(containerRect[startEdge] - slideRect[startEdge]);
1190
+ }
1191
+ function measureEndGap() {
1192
+ if (!withEdgeGap) return 0;
1193
+ const style = ownerWindow.getComputedStyle(arrayLast(slides));
1194
+ return parseFloat(style.getPropertyValue(`margin-${endEdge}`));
1195
+ }
1196
+ function measureWithGaps() {
1197
+ return slideRects.map((rect, index, rects)=>{
1198
+ const isFirst = !index;
1199
+ const isLast = arrayIsLastIndex(rects, index);
1200
+ if (isFirst) return slideSizes[index] + startGap;
1201
+ if (isLast) return slideSizes[index] + endGap;
1202
+ return rects[index + 1][startEdge] - rect[startEdge];
1203
+ }).map(mathAbs);
1204
+ }
1205
+ const self = {
1206
+ slideSizes,
1207
+ slideSizesWithGaps,
1208
+ startGap,
1209
+ endGap
1210
+ };
1211
+ return self;
1212
+ }
1213
+ function SlidesToScroll(axis, viewSize, slidesToScroll, loop, containerRect, slideRects, startGap, endGap, pixelTolerance) {
1214
+ const { startEdge, endEdge, direction } = axis;
1215
+ const groupByNumber = isNumber(slidesToScroll);
1216
+ function byNumber(array, groupSize) {
1217
+ return arrayKeys(array).filter((i)=>i % groupSize === 0).map((i)=>array.slice(i, i + groupSize));
1218
+ }
1219
+ function bySize(array) {
1220
+ if (!array.length) return [];
1221
+ return arrayKeys(array).reduce((groups, rectB, index)=>{
1222
+ const rectA = arrayLast(groups) || 0;
1223
+ const isFirst = rectA === 0;
1224
+ const isLast = rectB === arrayLastIndex(array);
1225
+ const edgeA = containerRect[startEdge] - slideRects[rectA][startEdge];
1226
+ const edgeB = containerRect[startEdge] - slideRects[rectB][endEdge];
1227
+ const gapA = !loop && isFirst ? direction(startGap) : 0;
1228
+ const gapB = !loop && isLast ? direction(endGap) : 0;
1229
+ const chunkSize = mathAbs(edgeB - gapB - (edgeA + gapA));
1230
+ if (index && chunkSize > viewSize + pixelTolerance) groups.push(rectB);
1231
+ if (isLast) groups.push(array.length);
1232
+ return groups;
1233
+ }, []).map((currentSize, index, groups)=>{
1234
+ const previousSize = Math.max(groups[index - 1] || 0);
1235
+ return array.slice(previousSize, currentSize);
1236
+ });
1237
+ }
1238
+ function groupSlides(array) {
1239
+ return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array);
1240
+ }
1241
+ const self = {
1242
+ groupSlides
1243
+ };
1244
+ return self;
1245
+ }
1246
+ function Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler) {
1247
+ // Options
1248
+ const { align, axis: scrollAxis, direction, startIndex, loop, duration, dragFree, dragThreshold, inViewThreshold, slidesToScroll: groupSlides, skipSnaps, containScroll, watchResize, watchSlides, watchDrag, watchFocus } = options;
1249
+ // Measurements
1250
+ const pixelTolerance = 2;
1251
+ const nodeRects = NodeRects();
1252
+ const containerRect = nodeRects.measure(container);
1253
+ const slideRects = slides.map(nodeRects.measure);
1254
+ const axis = Axis(scrollAxis, direction);
1255
+ const viewSize = axis.measureSize(containerRect);
1256
+ const percentOfView = PercentOfView(viewSize);
1257
+ const alignment = Alignment(align, viewSize);
1258
+ const containSnaps = !loop && !!containScroll;
1259
+ const readEdgeGap = loop || !!containScroll;
1260
+ const { slideSizes, slideSizesWithGaps, startGap, endGap } = SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow);
1261
+ const slidesToScroll = SlidesToScroll(axis, viewSize, groupSlides, loop, containerRect, slideRects, startGap, endGap, pixelTolerance);
1262
+ const { snaps, snapsAligned } = ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll);
1263
+ const contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
1264
+ const { snapsContained, scrollContainLimit } = ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance);
1265
+ const scrollSnaps = containSnaps ? snapsContained : snapsAligned;
1266
+ const { limit } = ScrollLimit(contentSize, scrollSnaps, loop);
1267
+ // Indexes
1268
+ const index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
1269
+ const indexPrevious = index.clone();
1270
+ const slideIndexes = arrayKeys(slides);
1271
+ // Animation
1272
+ const update = ({ dragHandler, scrollBody, scrollBounds, options: { loop } })=>{
1273
+ if (!loop) scrollBounds.constrain(dragHandler.pointerDown());
1274
+ scrollBody.seek();
1275
+ };
1276
+ const render = ({ scrollBody, translate, location, offsetLocation, previousLocation, scrollLooper, slideLooper, dragHandler, animation, eventHandler, scrollBounds, options: { loop } }, alpha)=>{
1277
+ const shouldSettle = scrollBody.settled();
1278
+ const withinBounds = !scrollBounds.shouldConstrain();
1279
+ const hasSettled = loop ? shouldSettle : shouldSettle && withinBounds;
1280
+ const hasSettledAndIdle = hasSettled && !dragHandler.pointerDown();
1281
+ if (hasSettledAndIdle) animation.stop();
1282
+ const interpolatedLocation = location.get() * alpha + previousLocation.get() * (1 - alpha);
1283
+ offsetLocation.set(interpolatedLocation);
1284
+ if (loop) {
1285
+ scrollLooper.loop(scrollBody.direction());
1286
+ slideLooper.loop();
1287
+ }
1288
+ translate.to(offsetLocation.get());
1289
+ if (hasSettledAndIdle) eventHandler.emit('settle');
1290
+ if (!hasSettled) eventHandler.emit('scroll');
1291
+ };
1292
+ const animation = Animations(ownerDocument, ownerWindow, ()=>update(engine), (alpha)=>render(engine, alpha));
1293
+ // Shared
1294
+ const friction = 0.68;
1295
+ const startLocation = scrollSnaps[index.get()];
1296
+ const location = Vector1D(startLocation);
1297
+ const previousLocation = Vector1D(startLocation);
1298
+ const offsetLocation = Vector1D(startLocation);
1299
+ const target = Vector1D(startLocation);
1300
+ const scrollBody = ScrollBody(location, offsetLocation, previousLocation, target, duration, friction);
1301
+ const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
1302
+ const scrollTo = ScrollTo(animation, index, indexPrevious, scrollBody, scrollTarget, target, eventHandler);
1303
+ const scrollProgress = ScrollProgress(limit);
1304
+ const eventStore = EventStore();
1305
+ const slidesInView = SlidesInView(container, slides, eventHandler, inViewThreshold);
1306
+ const { slideRegistry } = SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes);
1307
+ const slideFocus = SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus);
1308
+ // Engine
1309
+ const engine = {
1310
+ ownerDocument,
1311
+ ownerWindow,
1312
+ eventHandler,
1313
+ containerRect,
1314
+ slideRects,
1315
+ animation,
1316
+ axis,
1317
+ dragHandler: DragHandler(axis, root, ownerDocument, ownerWindow, target, DragTracker(axis, ownerWindow), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction, watchDrag),
1318
+ eventStore,
1319
+ percentOfView,
1320
+ index,
1321
+ indexPrevious,
1322
+ limit,
1323
+ location,
1324
+ offsetLocation,
1325
+ previousLocation,
1326
+ options,
1327
+ resizeHandler: ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects),
1328
+ scrollBody,
1329
+ scrollBounds: ScrollBounds(limit, offsetLocation, target, scrollBody, percentOfView),
1330
+ scrollLooper: ScrollLooper(contentSize, limit, offsetLocation, [
1331
+ location,
1332
+ offsetLocation,
1333
+ previousLocation,
1334
+ target
1335
+ ]),
1336
+ scrollProgress,
1337
+ scrollSnapList: scrollSnaps.map(scrollProgress.get),
1338
+ scrollSnaps,
1339
+ scrollTarget,
1340
+ scrollTo,
1341
+ slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, offsetLocation, slides),
1342
+ slideFocus,
1343
+ slidesHandler: SlidesHandler(container, eventHandler, watchSlides),
1344
+ slidesInView,
1345
+ slideIndexes,
1346
+ slideRegistry,
1347
+ slidesToScroll,
1348
+ target,
1349
+ translate: Translate(axis, container)
1350
+ };
1351
+ return engine;
1352
+ }
1353
+ function EventHandler() {
1354
+ let listeners = {};
1355
+ let api;
1356
+ function init(emblaApi) {
1357
+ api = emblaApi;
1358
+ }
1359
+ function getListeners(evt) {
1360
+ return listeners[evt] || [];
1361
+ }
1362
+ function emit(evt) {
1363
+ getListeners(evt).forEach((e)=>e(api, evt));
1364
+ return self;
1365
+ }
1366
+ function on(evt, cb) {
1367
+ listeners[evt] = getListeners(evt).concat([
1368
+ cb
1369
+ ]);
1370
+ return self;
1371
+ }
1372
+ function off(evt, cb) {
1373
+ listeners[evt] = getListeners(evt).filter((e)=>e !== cb);
1374
+ return self;
1375
+ }
1376
+ function clear() {
1377
+ listeners = {};
1378
+ }
1379
+ const self = {
1380
+ init,
1381
+ emit,
1382
+ off,
1383
+ on,
1384
+ clear
1385
+ };
1386
+ return self;
1387
+ }
1388
+ const defaultOptions = {
1389
+ align: 'center',
1390
+ axis: 'x',
1391
+ container: null,
1392
+ slides: null,
1393
+ containScroll: 'trimSnaps',
1394
+ direction: 'ltr',
1395
+ slidesToScroll: 1,
1396
+ inViewThreshold: 0,
1397
+ breakpoints: {},
1398
+ dragFree: false,
1399
+ dragThreshold: 10,
1400
+ loop: false,
1401
+ skipSnaps: false,
1402
+ duration: 25,
1403
+ startIndex: 0,
1404
+ active: true,
1405
+ watchDrag: true,
1406
+ watchResize: true,
1407
+ watchSlides: true,
1408
+ watchFocus: true
1409
+ };
1410
+ function OptionsHandler(ownerWindow) {
1411
+ function mergeOptions(optionsA, optionsB) {
1412
+ return objectsMergeDeep(optionsA, optionsB || {});
1413
+ }
1414
+ function optionsAtMedia(options) {
1415
+ const optionsAtMedia = options.breakpoints || {};
1416
+ const matchedMediaOptions = objectKeys(optionsAtMedia).filter((media)=>ownerWindow.matchMedia(media).matches).map((media)=>optionsAtMedia[media]).reduce((a, mediaOption)=>mergeOptions(a, mediaOption), {});
1417
+ return mergeOptions(options, matchedMediaOptions);
1418
+ }
1419
+ function optionsMediaQueries(optionsList) {
1420
+ return optionsList.map((options)=>objectKeys(options.breakpoints || {})).reduce((acc, mediaQueries)=>acc.concat(mediaQueries), []).map(ownerWindow.matchMedia);
1421
+ }
1422
+ const self = {
1423
+ mergeOptions,
1424
+ optionsAtMedia,
1425
+ optionsMediaQueries
1426
+ };
1427
+ return self;
1428
+ }
1429
+ function PluginsHandler(optionsHandler) {
1430
+ let activePlugins = [];
1431
+ function init(emblaApi, plugins) {
1432
+ activePlugins = plugins.filter(({ options })=>optionsHandler.optionsAtMedia(options).active !== false);
1433
+ activePlugins.forEach((plugin)=>plugin.init(emblaApi, optionsHandler));
1434
+ return plugins.reduce((map, plugin)=>Object.assign(map, {
1435
+ [plugin.name]: plugin
1436
+ }), {});
1437
+ }
1438
+ function destroy() {
1439
+ activePlugins = activePlugins.filter((plugin)=>plugin.destroy());
1440
+ }
1441
+ const self = {
1442
+ init,
1443
+ destroy
1444
+ };
1445
+ return self;
1446
+ }
1447
+ function EmblaCarousel(root, userOptions, userPlugins) {
1448
+ const ownerDocument = root.ownerDocument;
1449
+ const ownerWindow = ownerDocument.defaultView;
1450
+ const optionsHandler = OptionsHandler(ownerWindow);
1451
+ const pluginsHandler = PluginsHandler(optionsHandler);
1452
+ const mediaHandlers = EventStore();
1453
+ const eventHandler = EventHandler();
1454
+ const { mergeOptions, optionsAtMedia, optionsMediaQueries } = optionsHandler;
1455
+ const { on, off, emit } = eventHandler;
1456
+ const reInit = reActivate;
1457
+ let destroyed = false;
1458
+ let engine;
1459
+ let optionsBase = mergeOptions(defaultOptions, EmblaCarousel.globalOptions);
1460
+ let options = mergeOptions(optionsBase);
1461
+ let pluginList = [];
1462
+ let pluginApis;
1463
+ let container;
1464
+ let slides;
1465
+ function storeElements() {
1466
+ const { container: userContainer, slides: userSlides } = options;
1467
+ const customContainer = isString(userContainer) ? root.querySelector(userContainer) : userContainer;
1468
+ container = customContainer || root.children[0];
1469
+ const customSlides = isString(userSlides) ? container.querySelectorAll(userSlides) : userSlides;
1470
+ slides = [].slice.call(customSlides || container.children);
1471
+ }
1472
+ function createEngine(options) {
1473
+ const engine = Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler);
1474
+ if (options.loop && !engine.slideLooper.canLoop()) {
1475
+ const optionsWithoutLoop = Object.assign({}, options, {
1476
+ loop: false
1477
+ });
1478
+ return createEngine(optionsWithoutLoop);
1479
+ }
1480
+ return engine;
1481
+ }
1482
+ function activate(withOptions, withPlugins) {
1483
+ if (destroyed) return;
1484
+ optionsBase = mergeOptions(optionsBase, withOptions);
1485
+ options = optionsAtMedia(optionsBase);
1486
+ pluginList = withPlugins || pluginList;
1487
+ storeElements();
1488
+ engine = createEngine(options);
1489
+ optionsMediaQueries([
1490
+ optionsBase,
1491
+ ...pluginList.map(({ options })=>options)
1492
+ ]).forEach((query)=>mediaHandlers.add(query, 'change', reActivate));
1493
+ if (!options.active) return;
1494
+ engine.translate.to(engine.location.get());
1495
+ engine.animation.init();
1496
+ engine.slidesInView.init();
1497
+ engine.slideFocus.init(self);
1498
+ engine.eventHandler.init(self);
1499
+ engine.resizeHandler.init(self);
1500
+ engine.slidesHandler.init(self);
1501
+ if (engine.options.loop) engine.slideLooper.loop();
1502
+ if (container.offsetParent && slides.length) engine.dragHandler.init(self);
1503
+ pluginApis = pluginsHandler.init(self, pluginList);
1504
+ }
1505
+ function reActivate(withOptions, withPlugins) {
1506
+ const startIndex = selectedScrollSnap();
1507
+ deActivate();
1508
+ activate(mergeOptions({
1509
+ startIndex
1510
+ }, withOptions), withPlugins);
1511
+ eventHandler.emit('reInit');
1512
+ }
1513
+ function deActivate() {
1514
+ engine.dragHandler.destroy();
1515
+ engine.eventStore.clear();
1516
+ engine.translate.clear();
1517
+ engine.slideLooper.clear();
1518
+ engine.resizeHandler.destroy();
1519
+ engine.slidesHandler.destroy();
1520
+ engine.slidesInView.destroy();
1521
+ engine.animation.destroy();
1522
+ pluginsHandler.destroy();
1523
+ mediaHandlers.clear();
1524
+ }
1525
+ function destroy() {
1526
+ if (destroyed) return;
1527
+ destroyed = true;
1528
+ mediaHandlers.clear();
1529
+ deActivate();
1530
+ eventHandler.emit('destroy');
1531
+ eventHandler.clear();
1532
+ }
1533
+ function scrollTo(index, jump, direction) {
1534
+ if (!options.active || destroyed) return;
1535
+ engine.scrollBody.useBaseFriction().useDuration(jump === true ? 0 : options.duration);
1536
+ engine.scrollTo.index(index, direction || 0);
1537
+ }
1538
+ function scrollNext(jump) {
1539
+ const next = engine.index.add(1).get();
1540
+ scrollTo(next, jump, -1);
1541
+ }
1542
+ function scrollPrev(jump) {
1543
+ const prev = engine.index.add(-1).get();
1544
+ scrollTo(prev, jump, 1);
1545
+ }
1546
+ function canScrollNext() {
1547
+ const next = engine.index.add(1).get();
1548
+ return next !== selectedScrollSnap();
1549
+ }
1550
+ function canScrollPrev() {
1551
+ const prev = engine.index.add(-1).get();
1552
+ return prev !== selectedScrollSnap();
1553
+ }
1554
+ function scrollSnapList() {
1555
+ return engine.scrollSnapList;
1556
+ }
1557
+ function scrollProgress() {
1558
+ return engine.scrollProgress.get(engine.offsetLocation.get());
1559
+ }
1560
+ function selectedScrollSnap() {
1561
+ return engine.index.get();
1562
+ }
1563
+ function previousScrollSnap() {
1564
+ return engine.indexPrevious.get();
1565
+ }
1566
+ function slidesInView() {
1567
+ return engine.slidesInView.get();
1568
+ }
1569
+ function slidesNotInView() {
1570
+ return engine.slidesInView.get(false);
1571
+ }
1572
+ function plugins() {
1573
+ return pluginApis;
1574
+ }
1575
+ function internalEngine() {
1576
+ return engine;
1577
+ }
1578
+ function rootNode() {
1579
+ return root;
1580
+ }
1581
+ function containerNode() {
1582
+ return container;
1583
+ }
1584
+ function slideNodes() {
1585
+ return slides;
1586
+ }
1587
+ const self = {
1588
+ canScrollNext,
1589
+ canScrollPrev,
1590
+ containerNode,
1591
+ internalEngine,
1592
+ destroy,
1593
+ off,
1594
+ on,
1595
+ emit,
1596
+ plugins,
1597
+ previousScrollSnap,
1598
+ reInit,
1599
+ rootNode,
1600
+ scrollNext,
1601
+ scrollPrev,
1602
+ scrollProgress,
1603
+ scrollSnapList,
1604
+ scrollTo,
1605
+ selectedScrollSnap,
1606
+ slideNodes,
1607
+ slidesInView,
1608
+ slidesNotInView
1609
+ };
1610
+ activate(userOptions, userPlugins);
1611
+ setTimeout(()=>eventHandler.emit('init'), 0);
1612
+ return self;
1613
+ }
1614
+ EmblaCarousel.globalOptions = undefined;
1615
+
1616
+ function useEmblaCarousel(options = {}, plugins = []) {
1617
+ const storedOptions = useRef(options);
1618
+ const storedPlugins = useRef(plugins);
1619
+ const [emblaApi, setEmblaApi] = useState();
1620
+ const [viewport, setViewport] = useState();
1621
+ const reInit = useCallback(()=>{
1622
+ if (emblaApi) emblaApi.reInit(storedOptions.current, storedPlugins.current);
1623
+ }, [
1624
+ emblaApi
1625
+ ]);
1626
+ useEffect(()=>{
1627
+ if (areOptionsEqual(storedOptions.current, options)) return;
1628
+ storedOptions.current = options;
1629
+ reInit();
1630
+ }, [
1631
+ options,
1632
+ reInit
1633
+ ]);
1634
+ useEffect(()=>{
1635
+ if (arePluginsEqual(storedPlugins.current, plugins)) return;
1636
+ storedPlugins.current = plugins;
1637
+ reInit();
1638
+ }, [
1639
+ plugins,
1640
+ reInit
1641
+ ]);
1642
+ useEffect(()=>{
1643
+ if (canUseDOM() && viewport) {
1644
+ EmblaCarousel.globalOptions = useEmblaCarousel.globalOptions;
1645
+ const newEmblaApi = EmblaCarousel(viewport, storedOptions.current, storedPlugins.current);
1646
+ setEmblaApi(newEmblaApi);
1647
+ return ()=>newEmblaApi.destroy();
1648
+ } else {
1649
+ setEmblaApi(undefined);
1650
+ }
1651
+ }, [
1652
+ viewport,
1653
+ setEmblaApi
1654
+ ]);
1655
+ return [
1656
+ setViewport,
1657
+ emblaApi
1658
+ ];
1659
+ }
1660
+ useEmblaCarousel.globalOptions = undefined;
1661
+
1662
+ const CarouselContext = /*#__PURE__*/ React.createContext(null);
1663
+ function useCarousel() {
1664
+ const context = React.useContext(CarouselContext);
1665
+ if (!context) {
1666
+ throw new Error("useCarousel must be used within a <Carousel />");
1667
+ }
1668
+ return context;
1669
+ }
1670
+ function Carousel({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }) {
1671
+ const [carouselRef, api] = useEmblaCarousel({
1672
+ ...opts,
1673
+ axis: orientation === "horizontal" ? "x" : "y"
1674
+ }, plugins);
1675
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false);
1676
+ const [canScrollNext, setCanScrollNext] = React.useState(false);
1677
+ const onSelect = React.useCallback((api)=>{
1678
+ if (!api) return;
1679
+ setCanScrollPrev(api.canScrollPrev());
1680
+ setCanScrollNext(api.canScrollNext());
1681
+ }, []);
1682
+ const scrollPrev = React.useCallback(()=>{
1683
+ api?.scrollPrev();
1684
+ }, [
1685
+ api
1686
+ ]);
1687
+ const scrollNext = React.useCallback(()=>{
1688
+ api?.scrollNext();
1689
+ }, [
1690
+ api
1691
+ ]);
1692
+ const handleKeyDown = React.useCallback((event)=>{
1693
+ if (event.key === "ArrowLeft") {
1694
+ event.preventDefault();
1695
+ scrollPrev();
1696
+ } else if (event.key === "ArrowRight") {
1697
+ event.preventDefault();
1698
+ scrollNext();
1699
+ }
1700
+ }, [
1701
+ scrollPrev,
1702
+ scrollNext
1703
+ ]);
1704
+ React.useEffect(()=>{
1705
+ if (!api || !setApi) return;
1706
+ setApi(api);
1707
+ }, [
1708
+ api,
1709
+ setApi
1710
+ ]);
1711
+ React.useEffect(()=>{
1712
+ if (!api) return;
1713
+ onSelect(api);
1714
+ api.on("reInit", onSelect);
1715
+ api.on("select", onSelect);
1716
+ return ()=>{
1717
+ api?.off("select", onSelect);
1718
+ };
1719
+ }, [
1720
+ api,
1721
+ onSelect
1722
+ ]);
1723
+ return /*#__PURE__*/ React.createElement(CarouselContext.Provider, {
1724
+ value: {
1725
+ carouselRef,
1726
+ api: api,
1727
+ opts,
1728
+ orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
1729
+ scrollPrev,
1730
+ scrollNext,
1731
+ canScrollPrev,
1732
+ canScrollNext
1733
+ }
1734
+ }, /*#__PURE__*/ React.createElement("div", {
1735
+ onKeyDownCapture: handleKeyDown,
1736
+ className: cn("relative", className),
1737
+ "aria-roledescription": "carousel",
1738
+ "data-slot": "carousel",
1739
+ ...props
1740
+ }, children));
1741
+ }
1742
+ function CarouselContent({ className, ...props }) {
1743
+ const { carouselRef, orientation } = useCarousel();
1744
+ return /*#__PURE__*/ React.createElement("div", {
1745
+ ref: carouselRef,
1746
+ className: "overflow-hidden",
1747
+ "data-slot": "carousel-content"
1748
+ }, /*#__PURE__*/ React.createElement("div", {
1749
+ className: cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className),
1750
+ ...props
1751
+ }));
1752
+ }
1753
+ function CarouselItem({ className, ...props }) {
1754
+ const { orientation } = useCarousel();
1755
+ return /*#__PURE__*/ React.createElement("div", {
1756
+ role: "group",
1757
+ "aria-roledescription": "slide",
1758
+ "data-slot": "carousel-item",
1759
+ className: cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className),
1760
+ ...props
1761
+ });
1762
+ }
1763
+ function CarouselPrevious({ className, variant = "outline", size = "icon", ...props }) {
1764
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
1765
+ return /*#__PURE__*/ React.createElement(Button, {
1766
+ "data-slot": "carousel-previous",
1767
+ variant: variant,
1768
+ size: size,
1769
+ className: cn("absolute size-8 rounded-full", orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
1770
+ disabled: !canScrollPrev,
1771
+ onClick: scrollPrev,
1772
+ ...props
1773
+ }, /*#__PURE__*/ React.createElement(ArrowLeft, null), /*#__PURE__*/ React.createElement("span", {
1774
+ className: "sr-only"
1775
+ }, "Previous slide"));
1776
+ }
1777
+ function CarouselNext({ className, variant = "outline", size = "icon", ...props }) {
1778
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
1779
+ return /*#__PURE__*/ React.createElement(Button, {
1780
+ "data-slot": "carousel-next",
1781
+ variant: variant,
1782
+ size: size,
1783
+ className: cn("absolute size-8 rounded-full", orientation === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
1784
+ disabled: !canScrollNext,
1785
+ onClick: scrollNext,
1786
+ ...props
1787
+ }, /*#__PURE__*/ React.createElement(ArrowRight, null), /*#__PURE__*/ React.createElement("span", {
1788
+ className: "sr-only"
1789
+ }, "Next slide"));
1790
+ }
1791
+
1792
+ export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious };
1793
+ //# sourceMappingURL=index.mjs.map