sunpeak 0.16.29 → 0.17.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 (140) hide show
  1. package/bin/commands/dev.mjs +169 -342
  2. package/bin/commands/inspect.mjs +763 -0
  3. package/bin/commands/new.mjs +2 -2
  4. package/bin/lib/inspect/inspect-config.d.mts +20 -0
  5. package/bin/lib/inspect/inspect-config.mjs +76 -0
  6. package/bin/lib/live/global-setup.mjs +6 -1
  7. package/bin/sunpeak.js +11 -1
  8. package/dist/chatgpt/globals.css +8 -0
  9. package/dist/chatgpt/index.cjs +3 -11
  10. package/dist/chatgpt/index.cjs.map +1 -1
  11. package/dist/chatgpt/index.d.ts +2 -2
  12. package/dist/chatgpt/index.js +4 -8
  13. package/dist/chatgpt/index.js.map +1 -1
  14. package/dist/claude/index.cjs +1 -1
  15. package/dist/claude/index.js +1 -1
  16. package/dist/discovery-Cgoegt62.js +114 -0
  17. package/dist/discovery-Cgoegt62.js.map +1 -0
  18. package/dist/discovery-Clu4uHp1.cjs +161 -0
  19. package/dist/discovery-Clu4uHp1.cjs.map +1 -0
  20. package/dist/index.cjs +1 -4
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.js +2 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/discovery-cli.cjs +1 -1
  25. package/dist/lib/discovery-cli.js +1 -1
  26. package/dist/lib/discovery.d.ts +7 -67
  27. package/dist/lib/index.d.ts +0 -1
  28. package/dist/mcp/index.cjs +34 -23
  29. package/dist/mcp/index.cjs.map +1 -1
  30. package/dist/mcp/index.js +34 -23
  31. package/dist/mcp/index.js.map +1 -1
  32. package/dist/mcp/types.d.ts +5 -0
  33. package/dist/simulator/index.cjs +5 -11
  34. package/dist/simulator/index.cjs.map +1 -1
  35. package/dist/simulator/index.d.ts +4 -2
  36. package/dist/simulator/index.js +5 -8
  37. package/dist/simulator/index.js.map +1 -1
  38. package/dist/simulator/simple-sidebar.d.ts +7 -4
  39. package/dist/simulator/simulator-url.d.ts +8 -0
  40. package/dist/simulator/simulator.d.ts +15 -2
  41. package/dist/simulator/use-mcp-connection.d.ts +19 -0
  42. package/dist/{simulator-DIVvI69i.cjs → simulator-CH9hs0N6.cjs} +129 -21
  43. package/dist/simulator-CH9hs0N6.cjs.map +1 -0
  44. package/dist/{simulator-C7mkK7Sz.js → simulator-Dl8B-Ljb.js} +124 -22
  45. package/dist/simulator-Dl8B-Ljb.js.map +1 -0
  46. package/dist/{simulator-url-BDGD4vZD.cjs → simulator-url-CozKF1jf.cjs} +3 -1
  47. package/dist/simulator-url-CozKF1jf.cjs.map +1 -0
  48. package/dist/{simulator-url-Bkxj43yT.js → simulator-url-KoS_ToP6.js} +3 -1
  49. package/dist/simulator-url-KoS_ToP6.js.map +1 -0
  50. package/dist/style.css +8 -0
  51. package/package.json +11 -3
  52. package/template/dist/albums/albums.html +105 -0
  53. package/template/dist/albums/albums.json +16 -0
  54. package/template/dist/carousel/carousel.html +105 -0
  55. package/template/dist/carousel/carousel.json +16 -0
  56. package/template/dist/map/map.html +3060 -0
  57. package/template/dist/map/map.json +22 -0
  58. package/template/dist/review/review.html +105 -0
  59. package/template/dist/review/review.json +16 -0
  60. package/template/dist/server.js +15 -0
  61. package/template/dist/tools/review-diff.js +50 -0
  62. package/template/dist/tools/review-post.js +50 -0
  63. package/template/dist/tools/review-purchase.js +61 -0
  64. package/template/dist/tools/review.js +31 -0
  65. package/template/dist/tools/show-albums.js +56 -0
  66. package/template/dist/tools/show-carousel.js +41 -0
  67. package/template/dist/tools/show-map.js +47 -0
  68. package/template/node_modules/.vite/deps/_metadata.json +8 -0
  69. package/template/node_modules/.vite/deps/package.json +3 -0
  70. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +500 -0
  71. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -0
  72. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +563 -0
  73. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -0
  74. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +575 -0
  75. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -0
  76. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +11363 -0
  77. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -0
  78. package/template/node_modules/.vite-mcp/deps/_metadata.json +130 -0
  79. package/template/node_modules/.vite-mcp/deps/chunk-BoAXSpZd.js +33 -0
  80. package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js +14385 -0
  81. package/template/node_modules/.vite-mcp/deps/client-CU1wWud4.js.map +1 -0
  82. package/template/node_modules/.vite-mcp/deps/clsx.js +18 -0
  83. package/template/node_modules/.vite-mcp/deps/clsx.js.map +1 -0
  84. package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js +505 -0
  85. package/template/node_modules/.vite-mcp/deps/dist-uWX8WbjY.js.map +1 -0
  86. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js +1461 -0
  87. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js.map +1 -0
  88. package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js +536 -0
  89. package/template/node_modules/.vite-mcp/deps/embla-carousel-wheel-gestures.js.map +1 -0
  90. package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js +1013 -0
  91. package/template/node_modules/.vite-mcp/deps/magic-string.es-Cklsmr-5.js.map +1 -0
  92. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js +46311 -0
  93. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js.map +1 -0
  94. package/template/node_modules/.vite-mcp/deps/package.json +3 -0
  95. package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js +2090 -0
  96. package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js.map +1 -0
  97. package/template/node_modules/.vite-mcp/deps/react-dom.js +186 -0
  98. package/template/node_modules/.vite-mcp/deps/react-dom.js.map +1 -0
  99. package/template/node_modules/.vite-mcp/deps/react-dom_client.js +2 -0
  100. package/template/node_modules/.vite-mcp/deps/react.js +769 -0
  101. package/template/node_modules/.vite-mcp/deps/react.js.map +1 -0
  102. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js +205 -0
  103. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js.map +1 -0
  104. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js +209 -0
  105. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js.map +1 -0
  106. package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js +12157 -0
  107. package/template/node_modules/.vite-mcp/deps/schemas-NsgmY9QV.js.map +1 -0
  108. package/template/node_modules/.vite-mcp/deps/tailwind-merge.js +2025 -0
  109. package/template/node_modules/.vite-mcp/deps/tailwind-merge.js.map +1 -0
  110. package/template/node_modules/.vite-mcp/deps/vitest.js +14021 -0
  111. package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -0
  112. package/template/node_modules/.vite-mcp/deps/zod.js +624 -0
  113. package/template/node_modules/.vite-mcp/deps/zod.js.map +1 -0
  114. package/template/src/tools/review-diff.test.ts +5 -1
  115. package/template/src/tools/review-diff.ts +1 -1
  116. package/template/src/tools/review-post.test.ts +5 -1
  117. package/template/src/tools/review-post.ts +1 -1
  118. package/template/src/tools/review-purchase.test.ts +5 -1
  119. package/template/src/tools/review-purchase.ts +1 -1
  120. package/template/src/tools/review.test.ts +5 -1
  121. package/template/src/tools/review.ts +1 -1
  122. package/template/src/tools/show-albums.test.ts +5 -1
  123. package/template/src/tools/show-albums.ts +1 -1
  124. package/template/src/tools/show-carousel.test.ts +5 -1
  125. package/template/src/tools/show-carousel.ts +1 -1
  126. package/template/src/tools/show-map.test.ts +5 -1
  127. package/template/src/tools/show-map.ts +1 -1
  128. package/dist/discovery-BxKCIgG5.cjs +0 -332
  129. package/dist/discovery-BxKCIgG5.cjs.map +0 -1
  130. package/dist/discovery-Du4LHrih.js +0 -261
  131. package/dist/discovery-Du4LHrih.js.map +0 -1
  132. package/dist/simulator-C7mkK7Sz.js.map +0 -1
  133. package/dist/simulator-DIVvI69i.cjs.map +0 -1
  134. package/dist/simulator-url-BDGD4vZD.cjs.map +0 -1
  135. package/dist/simulator-url-Bkxj43yT.js.map +0 -1
  136. package/template/.sunpeak/dev.tsx +0 -79
  137. package/template/.sunpeak/resource-loader.html +0 -20
  138. package/template/.sunpeak/resource-loader.tsx +0 -57
  139. package/template/index.html +0 -14
  140. package/template/src/resources/index.ts +0 -17
@@ -0,0 +1,1461 @@
1
+ import { r as __toESM } from "./chunk-BoAXSpZd.js";
2
+ import { t as require_react } from "./react.js";
3
+ //#region ../../../node_modules/.pnpm/embla-carousel-reactive-utils@8.6.0_embla-carousel@8.6.0/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js
4
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
5
+ function isObject$1(subject) {
6
+ return Object.prototype.toString.call(subject) === "[object Object]";
7
+ }
8
+ function isRecord(subject) {
9
+ return isObject$1(subject) || Array.isArray(subject);
10
+ }
11
+ function canUseDOM() {
12
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
13
+ }
14
+ function areOptionsEqual(optionsA, optionsB) {
15
+ const optionsAKeys = Object.keys(optionsA);
16
+ const optionsBKeys = Object.keys(optionsB);
17
+ if (optionsAKeys.length !== optionsBKeys.length) return false;
18
+ if (JSON.stringify(Object.keys(optionsA.breakpoints || {})) !== JSON.stringify(Object.keys(optionsB.breakpoints || {}))) return false;
19
+ return optionsAKeys.every((key) => {
20
+ const valueA = optionsA[key];
21
+ const valueB = optionsB[key];
22
+ if (typeof valueA === "function") return `${valueA}` === `${valueB}`;
23
+ if (!isRecord(valueA) || !isRecord(valueB)) return valueA === valueB;
24
+ return areOptionsEqual(valueA, valueB);
25
+ });
26
+ }
27
+ function sortAndMapPluginToOptions(plugins) {
28
+ return plugins.concat().sort((a, b) => a.name > b.name ? 1 : -1).map((plugin) => plugin.options);
29
+ }
30
+ function arePluginsEqual(pluginsA, pluginsB) {
31
+ if (pluginsA.length !== pluginsB.length) return false;
32
+ const optionsA = sortAndMapPluginToOptions(pluginsA);
33
+ const optionsB = sortAndMapPluginToOptions(pluginsB);
34
+ return optionsA.every((optionA, index) => {
35
+ const optionB = optionsB[index];
36
+ return areOptionsEqual(optionA, optionB);
37
+ });
38
+ }
39
+ //#endregion
40
+ //#region ../../../node_modules/.pnpm/embla-carousel@8.6.0/node_modules/embla-carousel/esm/embla-carousel.esm.js
41
+ function isNumber(subject) {
42
+ return typeof subject === "number";
43
+ }
44
+ function isString(subject) {
45
+ return typeof subject === "string";
46
+ }
47
+ function isBoolean(subject) {
48
+ return typeof subject === "boolean";
49
+ }
50
+ function isObject(subject) {
51
+ return Object.prototype.toString.call(subject) === "[object Object]";
52
+ }
53
+ function mathAbs(n) {
54
+ return Math.abs(n);
55
+ }
56
+ function mathSign(n) {
57
+ return Math.sign(n);
58
+ }
59
+ function deltaAbs(valueB, valueA) {
60
+ return mathAbs(valueB - valueA);
61
+ }
62
+ function factorAbs(valueB, valueA) {
63
+ if (valueB === 0 || valueA === 0) return 0;
64
+ if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
65
+ return mathAbs(deltaAbs(mathAbs(valueB), mathAbs(valueA)) / valueB);
66
+ }
67
+ function roundToTwoDecimals(num) {
68
+ return Math.round(num * 100) / 100;
69
+ }
70
+ function arrayKeys(array) {
71
+ return objectKeys(array).map(Number);
72
+ }
73
+ function arrayLast(array) {
74
+ return array[arrayLastIndex(array)];
75
+ }
76
+ function arrayLastIndex(array) {
77
+ return Math.max(0, array.length - 1);
78
+ }
79
+ function arrayIsLastIndex(array, index) {
80
+ return index === arrayLastIndex(array);
81
+ }
82
+ function arrayFromNumber(n, startAt = 0) {
83
+ return Array.from(Array(n), (_, i) => startAt + i);
84
+ }
85
+ function objectKeys(object) {
86
+ return Object.keys(object);
87
+ }
88
+ function objectsMergeDeep(objectA, objectB) {
89
+ return [objectA, objectB].reduce((mergedObjects, currentObject) => {
90
+ objectKeys(currentObject).forEach((key) => {
91
+ const valueA = mergedObjects[key];
92
+ const valueB = currentObject[key];
93
+ mergedObjects[key] = isObject(valueA) && isObject(valueB) ? objectsMergeDeep(valueA, valueB) : valueB;
94
+ });
95
+ return mergedObjects;
96
+ }, {});
97
+ }
98
+ function isMouseEvent(evt, ownerWindow) {
99
+ return typeof ownerWindow.MouseEvent !== "undefined" && evt instanceof ownerWindow.MouseEvent;
100
+ }
101
+ function Alignment(align, viewSize) {
102
+ const predefined = {
103
+ start,
104
+ center,
105
+ end
106
+ };
107
+ function start() {
108
+ return 0;
109
+ }
110
+ function center(n) {
111
+ return end(n) / 2;
112
+ }
113
+ function end(n) {
114
+ return viewSize - n;
115
+ }
116
+ function measure(n, index) {
117
+ if (isString(align)) return predefined[align](n);
118
+ return align(viewSize, n, index);
119
+ }
120
+ return { measure };
121
+ }
122
+ function EventStore() {
123
+ let listeners = [];
124
+ function add(node, type, handler, options = { passive: true }) {
125
+ let removeListener;
126
+ if ("addEventListener" in node) {
127
+ node.addEventListener(type, handler, options);
128
+ removeListener = () => node.removeEventListener(type, handler, options);
129
+ } else {
130
+ const legacyMediaQueryList = node;
131
+ legacyMediaQueryList.addListener(handler);
132
+ removeListener = () => legacyMediaQueryList.removeListener(handler);
133
+ }
134
+ listeners.push(removeListener);
135
+ return self;
136
+ }
137
+ function clear() {
138
+ listeners = listeners.filter((remove) => remove());
139
+ }
140
+ const self = {
141
+ add,
142
+ clear
143
+ };
144
+ return self;
145
+ }
146
+ function Animations(ownerDocument, ownerWindow, update, render) {
147
+ const documentVisibleHandler = EventStore();
148
+ const fixedTimeStep = 1e3 / 60;
149
+ let lastTimeStamp = null;
150
+ let accumulatedTime = 0;
151
+ let animationId = 0;
152
+ function init() {
153
+ documentVisibleHandler.add(ownerDocument, "visibilitychange", () => {
154
+ if (ownerDocument.hidden) reset();
155
+ });
156
+ }
157
+ function destroy() {
158
+ stop();
159
+ documentVisibleHandler.clear();
160
+ }
161
+ function animate(timeStamp) {
162
+ if (!animationId) return;
163
+ if (!lastTimeStamp) {
164
+ lastTimeStamp = timeStamp;
165
+ update();
166
+ update();
167
+ }
168
+ const timeElapsed = timeStamp - lastTimeStamp;
169
+ lastTimeStamp = timeStamp;
170
+ accumulatedTime += timeElapsed;
171
+ while (accumulatedTime >= fixedTimeStep) {
172
+ update();
173
+ accumulatedTime -= fixedTimeStep;
174
+ }
175
+ render(accumulatedTime / fixedTimeStep);
176
+ if (animationId) animationId = ownerWindow.requestAnimationFrame(animate);
177
+ }
178
+ function start() {
179
+ if (animationId) return;
180
+ animationId = ownerWindow.requestAnimationFrame(animate);
181
+ }
182
+ function stop() {
183
+ ownerWindow.cancelAnimationFrame(animationId);
184
+ lastTimeStamp = null;
185
+ accumulatedTime = 0;
186
+ animationId = 0;
187
+ }
188
+ function reset() {
189
+ lastTimeStamp = null;
190
+ accumulatedTime = 0;
191
+ }
192
+ return {
193
+ init,
194
+ destroy,
195
+ start,
196
+ stop,
197
+ update,
198
+ render
199
+ };
200
+ }
201
+ function Axis(axis, contentDirection) {
202
+ const isRightToLeft = contentDirection === "rtl";
203
+ const isVertical = axis === "y";
204
+ const scroll = isVertical ? "y" : "x";
205
+ const cross = isVertical ? "x" : "y";
206
+ const sign = !isVertical && isRightToLeft ? -1 : 1;
207
+ const startEdge = getStartEdge();
208
+ const endEdge = getEndEdge();
209
+ function measureSize(nodeRect) {
210
+ const { height, width } = nodeRect;
211
+ return isVertical ? height : width;
212
+ }
213
+ function getStartEdge() {
214
+ if (isVertical) return "top";
215
+ return isRightToLeft ? "right" : "left";
216
+ }
217
+ function getEndEdge() {
218
+ if (isVertical) return "bottom";
219
+ return isRightToLeft ? "left" : "right";
220
+ }
221
+ function direction(n) {
222
+ return n * sign;
223
+ }
224
+ return {
225
+ scroll,
226
+ cross,
227
+ startEdge,
228
+ endEdge,
229
+ measureSize,
230
+ direction
231
+ };
232
+ }
233
+ function Limit(min = 0, max = 0) {
234
+ const length = mathAbs(min - max);
235
+ function reachedMin(n) {
236
+ return n < min;
237
+ }
238
+ function reachedMax(n) {
239
+ return n > max;
240
+ }
241
+ function reachedAny(n) {
242
+ return reachedMin(n) || reachedMax(n);
243
+ }
244
+ function constrain(n) {
245
+ if (!reachedAny(n)) return n;
246
+ return reachedMin(n) ? min : max;
247
+ }
248
+ function removeOffset(n) {
249
+ if (!length) return n;
250
+ return n - length * Math.ceil((n - max) / length);
251
+ }
252
+ return {
253
+ length,
254
+ max,
255
+ min,
256
+ constrain,
257
+ reachedAny,
258
+ reachedMax,
259
+ reachedMin,
260
+ removeOffset
261
+ };
262
+ }
263
+ function Counter(max, start, loop) {
264
+ const { constrain } = Limit(0, max);
265
+ const loopEnd = max + 1;
266
+ let counter = withinLimit(start);
267
+ function withinLimit(n) {
268
+ return !loop ? constrain(n) : mathAbs((loopEnd + n) % loopEnd);
269
+ }
270
+ function get() {
271
+ return counter;
272
+ }
273
+ function set(n) {
274
+ counter = withinLimit(n);
275
+ return self;
276
+ }
277
+ function add(n) {
278
+ return clone().set(get() + n);
279
+ }
280
+ function clone() {
281
+ return Counter(max, get(), loop);
282
+ }
283
+ const self = {
284
+ get,
285
+ set,
286
+ add,
287
+ clone
288
+ };
289
+ return self;
290
+ }
291
+ function DragHandler(axis, rootNode, ownerDocument, ownerWindow, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction, watchDrag) {
292
+ const { cross: crossAxis, direction } = axis;
293
+ const focusNodes = [
294
+ "INPUT",
295
+ "SELECT",
296
+ "TEXTAREA"
297
+ ];
298
+ const nonPassiveEvent = { passive: false };
299
+ const initEvents = EventStore();
300
+ const dragEvents = EventStore();
301
+ const goToNextThreshold = Limit(50, 225).constrain(percentOfView.measure(20));
302
+ const snapForceBoost = {
303
+ mouse: 300,
304
+ touch: 400
305
+ };
306
+ const freeForceBoost = {
307
+ mouse: 500,
308
+ touch: 600
309
+ };
310
+ const baseSpeed = dragFree ? 43 : 25;
311
+ let isMoving = false;
312
+ let startScroll = 0;
313
+ let startCross = 0;
314
+ let pointerIsDown = false;
315
+ let preventScroll = false;
316
+ let preventClick = false;
317
+ let isMouse = false;
318
+ function init(emblaApi) {
319
+ if (!watchDrag) return;
320
+ function downIfAllowed(evt) {
321
+ if (isBoolean(watchDrag) || watchDrag(emblaApi, evt)) down(evt);
322
+ }
323
+ const node = rootNode;
324
+ initEvents.add(node, "dragstart", (evt) => evt.preventDefault(), nonPassiveEvent).add(node, "touchmove", () => void 0, nonPassiveEvent).add(node, "touchend", () => void 0).add(node, "touchstart", downIfAllowed).add(node, "mousedown", downIfAllowed).add(node, "touchcancel", up).add(node, "contextmenu", up).add(node, "click", click, true);
325
+ }
326
+ function destroy() {
327
+ initEvents.clear();
328
+ dragEvents.clear();
329
+ }
330
+ function addDragEvents() {
331
+ const node = isMouse ? ownerDocument : rootNode;
332
+ dragEvents.add(node, "touchmove", move, nonPassiveEvent).add(node, "touchend", up).add(node, "mousemove", move, nonPassiveEvent).add(node, "mouseup", up);
333
+ }
334
+ function isFocusNode(node) {
335
+ const nodeName = node.nodeName || "";
336
+ return focusNodes.includes(nodeName);
337
+ }
338
+ function forceBoost() {
339
+ return (dragFree ? freeForceBoost : snapForceBoost)[isMouse ? "mouse" : "touch"];
340
+ }
341
+ function allowedForce(force, targetChanged) {
342
+ const next = index.add(mathSign(force) * -1);
343
+ const baseForce = scrollTarget.byDistance(force, !dragFree).distance;
344
+ if (dragFree || mathAbs(force) < goToNextThreshold) return baseForce;
345
+ if (skipSnaps && targetChanged) return baseForce * .5;
346
+ return scrollTarget.byIndex(next.get(), 0).distance;
347
+ }
348
+ function down(evt) {
349
+ const isMouseEvt = isMouseEvent(evt, ownerWindow);
350
+ isMouse = isMouseEvt;
351
+ preventClick = dragFree && isMouseEvt && !evt.buttons && isMoving;
352
+ isMoving = deltaAbs(target.get(), location.get()) >= 2;
353
+ if (isMouseEvt && evt.button !== 0) return;
354
+ if (isFocusNode(evt.target)) return;
355
+ pointerIsDown = true;
356
+ dragTracker.pointerDown(evt);
357
+ scrollBody.useFriction(0).useDuration(0);
358
+ target.set(location);
359
+ addDragEvents();
360
+ startScroll = dragTracker.readPoint(evt);
361
+ startCross = dragTracker.readPoint(evt, crossAxis);
362
+ eventHandler.emit("pointerDown");
363
+ }
364
+ function move(evt) {
365
+ if (!isMouseEvent(evt, ownerWindow) && evt.touches.length >= 2) return up(evt);
366
+ const lastScroll = dragTracker.readPoint(evt);
367
+ const lastCross = dragTracker.readPoint(evt, crossAxis);
368
+ const diffScroll = deltaAbs(lastScroll, startScroll);
369
+ const diffCross = deltaAbs(lastCross, startCross);
370
+ if (!preventScroll && !isMouse) {
371
+ if (!evt.cancelable) return up(evt);
372
+ preventScroll = diffScroll > diffCross;
373
+ if (!preventScroll) return up(evt);
374
+ }
375
+ const diff = dragTracker.pointerMove(evt);
376
+ if (diffScroll > dragThreshold) preventClick = true;
377
+ scrollBody.useFriction(.3).useDuration(.75);
378
+ animation.start();
379
+ target.add(direction(diff));
380
+ evt.preventDefault();
381
+ }
382
+ function up(evt) {
383
+ const targetChanged = scrollTarget.byDistance(0, false).index !== index.get();
384
+ const rawForce = dragTracker.pointerUp(evt) * forceBoost();
385
+ const force = allowedForce(direction(rawForce), targetChanged);
386
+ const forceFactor = factorAbs(rawForce, force);
387
+ const speed = baseSpeed - 10 * forceFactor;
388
+ const friction = baseFriction + forceFactor / 50;
389
+ preventScroll = false;
390
+ pointerIsDown = false;
391
+ dragEvents.clear();
392
+ scrollBody.useDuration(speed).useFriction(friction);
393
+ scrollTo.distance(force, !dragFree);
394
+ isMouse = false;
395
+ eventHandler.emit("pointerUp");
396
+ }
397
+ function click(evt) {
398
+ if (preventClick) {
399
+ evt.stopPropagation();
400
+ evt.preventDefault();
401
+ preventClick = false;
402
+ }
403
+ }
404
+ function pointerDown() {
405
+ return pointerIsDown;
406
+ }
407
+ return {
408
+ init,
409
+ destroy,
410
+ pointerDown
411
+ };
412
+ }
413
+ function DragTracker(axis, ownerWindow) {
414
+ const logInterval = 170;
415
+ let startEvent;
416
+ let lastEvent;
417
+ function readTime(evt) {
418
+ return evt.timeStamp;
419
+ }
420
+ function readPoint(evt, evtAxis) {
421
+ const coord = `client${(evtAxis || axis.scroll) === "x" ? "X" : "Y"}`;
422
+ return (isMouseEvent(evt, ownerWindow) ? evt : evt.touches[0])[coord];
423
+ }
424
+ function pointerDown(evt) {
425
+ startEvent = evt;
426
+ lastEvent = evt;
427
+ return readPoint(evt);
428
+ }
429
+ function pointerMove(evt) {
430
+ const diff = readPoint(evt) - readPoint(lastEvent);
431
+ const expired = readTime(evt) - readTime(startEvent) > logInterval;
432
+ lastEvent = evt;
433
+ if (expired) startEvent = evt;
434
+ return diff;
435
+ }
436
+ function pointerUp(evt) {
437
+ if (!startEvent || !lastEvent) return 0;
438
+ const diffDrag = readPoint(lastEvent) - readPoint(startEvent);
439
+ const diffTime = readTime(evt) - readTime(startEvent);
440
+ const expired = readTime(evt) - readTime(lastEvent) > logInterval;
441
+ const force = diffDrag / diffTime;
442
+ return diffTime && !expired && mathAbs(force) > .1 ? force : 0;
443
+ }
444
+ return {
445
+ pointerDown,
446
+ pointerMove,
447
+ pointerUp,
448
+ readPoint
449
+ };
450
+ }
451
+ function NodeRects() {
452
+ function measure(node) {
453
+ const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = node;
454
+ return {
455
+ top: offsetTop,
456
+ right: offsetLeft + offsetWidth,
457
+ bottom: offsetTop + offsetHeight,
458
+ left: offsetLeft,
459
+ width: offsetWidth,
460
+ height: offsetHeight
461
+ };
462
+ }
463
+ return { measure };
464
+ }
465
+ function PercentOfView(viewSize) {
466
+ function measure(n) {
467
+ return viewSize * (n / 100);
468
+ }
469
+ return { measure };
470
+ }
471
+ function ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects) {
472
+ const observeNodes = [container].concat(slides);
473
+ let resizeObserver;
474
+ let containerSize;
475
+ let slideSizes = [];
476
+ let destroyed = false;
477
+ function readSize(node) {
478
+ return axis.measureSize(nodeRects.measure(node));
479
+ }
480
+ function init(emblaApi) {
481
+ if (!watchResize) return;
482
+ containerSize = readSize(container);
483
+ slideSizes = slides.map(readSize);
484
+ function defaultCallback(entries) {
485
+ for (const entry of entries) {
486
+ if (destroyed) return;
487
+ const isContainer = entry.target === container;
488
+ const slideIndex = slides.indexOf(entry.target);
489
+ const lastSize = isContainer ? containerSize : slideSizes[slideIndex];
490
+ if (mathAbs(readSize(isContainer ? container : slides[slideIndex]) - lastSize) >= .5) {
491
+ emblaApi.reInit();
492
+ eventHandler.emit("resize");
493
+ break;
494
+ }
495
+ }
496
+ }
497
+ resizeObserver = new ResizeObserver((entries) => {
498
+ if (isBoolean(watchResize) || watchResize(emblaApi, entries)) defaultCallback(entries);
499
+ });
500
+ ownerWindow.requestAnimationFrame(() => {
501
+ observeNodes.forEach((node) => resizeObserver.observe(node));
502
+ });
503
+ }
504
+ function destroy() {
505
+ destroyed = true;
506
+ if (resizeObserver) resizeObserver.disconnect();
507
+ }
508
+ return {
509
+ init,
510
+ destroy
511
+ };
512
+ }
513
+ function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
514
+ let scrollVelocity = 0;
515
+ let scrollDirection = 0;
516
+ let scrollDuration = baseDuration;
517
+ let scrollFriction = baseFriction;
518
+ let rawLocation = location.get();
519
+ let rawLocationPrevious = 0;
520
+ function seek() {
521
+ const displacement = target.get() - location.get();
522
+ const isInstant = !scrollDuration;
523
+ let scrollDistance = 0;
524
+ if (isInstant) {
525
+ scrollVelocity = 0;
526
+ previousLocation.set(target);
527
+ location.set(target);
528
+ scrollDistance = displacement;
529
+ } else {
530
+ previousLocation.set(location);
531
+ scrollVelocity += displacement / scrollDuration;
532
+ scrollVelocity *= scrollFriction;
533
+ rawLocation += scrollVelocity;
534
+ location.add(scrollVelocity);
535
+ scrollDistance = rawLocation - rawLocationPrevious;
536
+ }
537
+ scrollDirection = mathSign(scrollDistance);
538
+ rawLocationPrevious = rawLocation;
539
+ return self;
540
+ }
541
+ function settled() {
542
+ return mathAbs(target.get() - offsetLocation.get()) < .001;
543
+ }
544
+ function duration() {
545
+ return scrollDuration;
546
+ }
547
+ function direction() {
548
+ return scrollDirection;
549
+ }
550
+ function velocity() {
551
+ return scrollVelocity;
552
+ }
553
+ function useBaseDuration() {
554
+ return useDuration(baseDuration);
555
+ }
556
+ function useBaseFriction() {
557
+ return useFriction(baseFriction);
558
+ }
559
+ function useDuration(n) {
560
+ scrollDuration = n;
561
+ return self;
562
+ }
563
+ function useFriction(n) {
564
+ scrollFriction = n;
565
+ return self;
566
+ }
567
+ const self = {
568
+ direction,
569
+ duration,
570
+ velocity,
571
+ seek,
572
+ settled,
573
+ useBaseFriction,
574
+ useBaseDuration,
575
+ useFriction,
576
+ useDuration
577
+ };
578
+ return self;
579
+ }
580
+ function ScrollBounds(limit, location, target, scrollBody, percentOfView) {
581
+ const pullBackThreshold = percentOfView.measure(10);
582
+ const edgeOffsetTolerance = percentOfView.measure(50);
583
+ const frictionLimit = Limit(.1, .99);
584
+ let disabled = false;
585
+ function shouldConstrain() {
586
+ if (disabled) return false;
587
+ if (!limit.reachedAny(target.get())) return false;
588
+ if (!limit.reachedAny(location.get())) return false;
589
+ return true;
590
+ }
591
+ function constrain(pointerDown) {
592
+ if (!shouldConstrain()) return;
593
+ const diffToEdge = mathAbs(limit[limit.reachedMin(location.get()) ? "min" : "max"] - location.get());
594
+ const diffToTarget = target.get() - location.get();
595
+ const friction = frictionLimit.constrain(diffToEdge / edgeOffsetTolerance);
596
+ target.subtract(diffToTarget * friction);
597
+ if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
598
+ target.set(limit.constrain(target.get()));
599
+ scrollBody.useDuration(25).useBaseFriction();
600
+ }
601
+ }
602
+ function toggleActive(active) {
603
+ disabled = !active;
604
+ }
605
+ return {
606
+ shouldConstrain,
607
+ constrain,
608
+ toggleActive
609
+ };
610
+ }
611
+ function ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance) {
612
+ const scrollBounds = Limit(-contentSize + viewSize, 0);
613
+ const snapsBounded = measureBounded();
614
+ const scrollContainLimit = findScrollContainLimit();
615
+ const snapsContained = measureContained();
616
+ function usePixelTolerance(bound, snap) {
617
+ return deltaAbs(bound, snap) <= 1;
618
+ }
619
+ function findScrollContainLimit() {
620
+ const startSnap = snapsBounded[0];
621
+ const endSnap = arrayLast(snapsBounded);
622
+ return Limit(snapsBounded.lastIndexOf(startSnap), snapsBounded.indexOf(endSnap) + 1);
623
+ }
624
+ function measureBounded() {
625
+ return snapsAligned.map((snapAligned, index) => {
626
+ const { min, max } = scrollBounds;
627
+ const snap = scrollBounds.constrain(snapAligned);
628
+ const isFirst = !index;
629
+ const isLast = arrayIsLastIndex(snapsAligned, index);
630
+ if (isFirst) return max;
631
+ if (isLast) return min;
632
+ if (usePixelTolerance(min, snap)) return min;
633
+ if (usePixelTolerance(max, snap)) return max;
634
+ return snap;
635
+ }).map((scrollBound) => parseFloat(scrollBound.toFixed(3)));
636
+ }
637
+ function measureContained() {
638
+ if (contentSize <= viewSize + pixelTolerance) return [scrollBounds.max];
639
+ if (containScroll === "keepSnaps") return snapsBounded;
640
+ const { min, max } = scrollContainLimit;
641
+ return snapsBounded.slice(min, max);
642
+ }
643
+ return {
644
+ snapsContained,
645
+ scrollContainLimit
646
+ };
647
+ }
648
+ function ScrollLimit(contentSize, scrollSnaps, loop) {
649
+ const max = scrollSnaps[0];
650
+ return { limit: Limit(loop ? max - contentSize : arrayLast(scrollSnaps), max) };
651
+ }
652
+ function ScrollLooper(contentSize, limit, location, vectors) {
653
+ const jointSafety = .1;
654
+ const { reachedMin, reachedMax } = Limit(limit.min + jointSafety, limit.max + jointSafety);
655
+ function shouldLoop(direction) {
656
+ if (direction === 1) return reachedMax(location.get());
657
+ if (direction === -1) return reachedMin(location.get());
658
+ return false;
659
+ }
660
+ function loop(direction) {
661
+ if (!shouldLoop(direction)) return;
662
+ const loopDistance = contentSize * (direction * -1);
663
+ vectors.forEach((v) => v.add(loopDistance));
664
+ }
665
+ return { loop };
666
+ }
667
+ function ScrollProgress(limit) {
668
+ const { max, length } = limit;
669
+ function get(n) {
670
+ const currentLocation = n - max;
671
+ return length ? currentLocation / -length : 0;
672
+ }
673
+ return { get };
674
+ }
675
+ function ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll) {
676
+ const { startEdge, endEdge } = axis;
677
+ const { groupSlides } = slidesToScroll;
678
+ const alignments = measureSizes().map(alignment.measure);
679
+ const snaps = measureUnaligned();
680
+ const snapsAligned = measureAligned();
681
+ function measureSizes() {
682
+ return groupSlides(slideRects).map((rects) => arrayLast(rects)[endEdge] - rects[0][startEdge]).map(mathAbs);
683
+ }
684
+ function measureUnaligned() {
685
+ return slideRects.map((rect) => containerRect[startEdge] - rect[startEdge]).map((snap) => -mathAbs(snap));
686
+ }
687
+ function measureAligned() {
688
+ return groupSlides(snaps).map((g) => g[0]).map((snap, index) => snap + alignments[index]);
689
+ }
690
+ return {
691
+ snaps,
692
+ snapsAligned
693
+ };
694
+ }
695
+ function SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes) {
696
+ const { groupSlides } = slidesToScroll;
697
+ const { min, max } = scrollContainLimit;
698
+ const slideRegistry = createSlideRegistry();
699
+ function createSlideRegistry() {
700
+ const groupedSlideIndexes = groupSlides(slideIndexes);
701
+ const doNotContain = !containSnaps || containScroll === "keepSnaps";
702
+ if (scrollSnaps.length === 1) return [slideIndexes];
703
+ if (doNotContain) return groupedSlideIndexes;
704
+ return groupedSlideIndexes.slice(min, max).map((group, index, groups) => {
705
+ const isFirst = !index;
706
+ const isLast = arrayIsLastIndex(groups, index);
707
+ if (isFirst) return arrayFromNumber(arrayLast(groups[0]) + 1);
708
+ if (isLast) return arrayFromNumber(arrayLastIndex(slideIndexes) - arrayLast(groups)[0] + 1, arrayLast(groups)[0]);
709
+ return group;
710
+ });
711
+ }
712
+ return { slideRegistry };
713
+ }
714
+ function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
715
+ const { reachedAny, removeOffset, constrain } = limit;
716
+ function minDistance(distances) {
717
+ return distances.concat().sort((a, b) => mathAbs(a) - mathAbs(b))[0];
718
+ }
719
+ function findTargetSnap(target) {
720
+ const distance = loop ? removeOffset(target) : constrain(target);
721
+ const { index } = scrollSnaps.map((snap, index) => ({
722
+ diff: shortcut(snap - distance, 0),
723
+ index
724
+ })).sort((d1, d2) => mathAbs(d1.diff) - mathAbs(d2.diff))[0];
725
+ return {
726
+ index,
727
+ distance
728
+ };
729
+ }
730
+ function shortcut(target, direction) {
731
+ const targets = [
732
+ target,
733
+ target + contentSize,
734
+ target - contentSize
735
+ ];
736
+ if (!loop) return target;
737
+ if (!direction) return minDistance(targets);
738
+ const matchingTargets = targets.filter((t) => mathSign(t) === direction);
739
+ if (matchingTargets.length) return minDistance(matchingTargets);
740
+ return arrayLast(targets) - contentSize;
741
+ }
742
+ function byIndex(index, direction) {
743
+ return {
744
+ index,
745
+ distance: shortcut(scrollSnaps[index] - targetVector.get(), direction)
746
+ };
747
+ }
748
+ function byDistance(distance, snap) {
749
+ const target = targetVector.get() + distance;
750
+ const { index, distance: targetSnapDistance } = findTargetSnap(target);
751
+ const reachedBound = !loop && reachedAny(target);
752
+ if (!snap || reachedBound) return {
753
+ index,
754
+ distance
755
+ };
756
+ return {
757
+ index,
758
+ distance: distance + shortcut(scrollSnaps[index] - targetSnapDistance, 0)
759
+ };
760
+ }
761
+ return {
762
+ byDistance,
763
+ byIndex,
764
+ shortcut
765
+ };
766
+ }
767
+ function ScrollTo(animation, indexCurrent, indexPrevious, scrollBody, scrollTarget, targetVector, eventHandler) {
768
+ function scrollTo(target) {
769
+ const distanceDiff = target.distance;
770
+ const indexDiff = target.index !== indexCurrent.get();
771
+ targetVector.add(distanceDiff);
772
+ if (distanceDiff) if (scrollBody.duration()) animation.start();
773
+ else {
774
+ animation.update();
775
+ animation.render(1);
776
+ animation.update();
777
+ }
778
+ if (indexDiff) {
779
+ indexPrevious.set(indexCurrent.get());
780
+ indexCurrent.set(target.index);
781
+ eventHandler.emit("select");
782
+ }
783
+ }
784
+ function distance(n, snap) {
785
+ scrollTo(scrollTarget.byDistance(n, snap));
786
+ }
787
+ function index(n, direction) {
788
+ const targetIndex = indexCurrent.clone().set(n);
789
+ scrollTo(scrollTarget.byIndex(targetIndex.get(), direction));
790
+ }
791
+ return {
792
+ distance,
793
+ index
794
+ };
795
+ }
796
+ function SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus) {
797
+ const focusListenerOptions = {
798
+ passive: true,
799
+ capture: true
800
+ };
801
+ let lastTabPressTime = 0;
802
+ function init(emblaApi) {
803
+ if (!watchFocus) return;
804
+ function defaultCallback(index) {
805
+ if ((/* @__PURE__ */ new Date()).getTime() - lastTabPressTime > 10) return;
806
+ eventHandler.emit("slideFocusStart");
807
+ root.scrollLeft = 0;
808
+ const group = slideRegistry.findIndex((group) => group.includes(index));
809
+ if (!isNumber(group)) return;
810
+ scrollBody.useDuration(0);
811
+ scrollTo.index(group, 0);
812
+ eventHandler.emit("slideFocus");
813
+ }
814
+ eventStore.add(document, "keydown", registerTabPress, false);
815
+ slides.forEach((slide, slideIndex) => {
816
+ eventStore.add(slide, "focus", (evt) => {
817
+ if (isBoolean(watchFocus) || watchFocus(emblaApi, evt)) defaultCallback(slideIndex);
818
+ }, focusListenerOptions);
819
+ });
820
+ }
821
+ function registerTabPress(event) {
822
+ if (event.code === "Tab") lastTabPressTime = (/* @__PURE__ */ new Date()).getTime();
823
+ }
824
+ return { init };
825
+ }
826
+ function Vector1D(initialValue) {
827
+ let value = initialValue;
828
+ function get() {
829
+ return value;
830
+ }
831
+ function set(n) {
832
+ value = normalizeInput(n);
833
+ }
834
+ function add(n) {
835
+ value += normalizeInput(n);
836
+ }
837
+ function subtract(n) {
838
+ value -= normalizeInput(n);
839
+ }
840
+ function normalizeInput(n) {
841
+ return isNumber(n) ? n : n.get();
842
+ }
843
+ return {
844
+ get,
845
+ set,
846
+ add,
847
+ subtract
848
+ };
849
+ }
850
+ function Translate(axis, container) {
851
+ const translate = axis.scroll === "x" ? x : y;
852
+ const containerStyle = container.style;
853
+ let previousTarget = null;
854
+ let disabled = false;
855
+ function x(n) {
856
+ return `translate3d(${n}px,0px,0px)`;
857
+ }
858
+ function y(n) {
859
+ return `translate3d(0px,${n}px,0px)`;
860
+ }
861
+ function to(target) {
862
+ if (disabled) return;
863
+ const newTarget = roundToTwoDecimals(axis.direction(target));
864
+ if (newTarget === previousTarget) return;
865
+ containerStyle.transform = translate(newTarget);
866
+ previousTarget = newTarget;
867
+ }
868
+ function toggleActive(active) {
869
+ disabled = !active;
870
+ }
871
+ function clear() {
872
+ if (disabled) return;
873
+ containerStyle.transform = "";
874
+ if (!container.getAttribute("style")) container.removeAttribute("style");
875
+ }
876
+ return {
877
+ clear,
878
+ to,
879
+ toggleActive
880
+ };
881
+ }
882
+ function SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, location, slides) {
883
+ const roundingSafety = .5;
884
+ const ascItems = arrayKeys(slideSizesWithGaps);
885
+ const descItems = arrayKeys(slideSizesWithGaps).reverse();
886
+ const loopPoints = startPoints().concat(endPoints());
887
+ function removeSlideSizes(indexes, from) {
888
+ return indexes.reduce((a, i) => {
889
+ return a - slideSizesWithGaps[i];
890
+ }, from);
891
+ }
892
+ function slidesInGap(indexes, gap) {
893
+ return indexes.reduce((a, i) => {
894
+ return removeSlideSizes(a, gap) > 0 ? a.concat([i]) : a;
895
+ }, []);
896
+ }
897
+ function findSlideBounds(offset) {
898
+ return snaps.map((snap, index) => ({
899
+ start: snap - slideSizes[index] + roundingSafety + offset,
900
+ end: snap + viewSize - roundingSafety + offset
901
+ }));
902
+ }
903
+ function findLoopPoints(indexes, offset, isEndEdge) {
904
+ const slideBounds = findSlideBounds(offset);
905
+ return indexes.map((index) => {
906
+ const initial = isEndEdge ? 0 : -contentSize;
907
+ const altered = isEndEdge ? contentSize : 0;
908
+ const boundEdge = isEndEdge ? "end" : "start";
909
+ const loopPoint = slideBounds[index][boundEdge];
910
+ return {
911
+ index,
912
+ loopPoint,
913
+ slideLocation: Vector1D(-1),
914
+ translate: Translate(axis, slides[index]),
915
+ target: () => location.get() > loopPoint ? initial : altered
916
+ };
917
+ });
918
+ }
919
+ function startPoints() {
920
+ const gap = scrollSnaps[0];
921
+ return findLoopPoints(slidesInGap(descItems, gap), contentSize, false);
922
+ }
923
+ function endPoints() {
924
+ return findLoopPoints(slidesInGap(ascItems, viewSize - scrollSnaps[0] - 1), -contentSize, true);
925
+ }
926
+ function canLoop() {
927
+ return loopPoints.every(({ index }) => {
928
+ return removeSlideSizes(ascItems.filter((i) => i !== index), viewSize) <= .1;
929
+ });
930
+ }
931
+ function loop() {
932
+ loopPoints.forEach((loopPoint) => {
933
+ const { target, translate, slideLocation } = loopPoint;
934
+ const shiftLocation = target();
935
+ if (shiftLocation === slideLocation.get()) return;
936
+ translate.to(shiftLocation);
937
+ slideLocation.set(shiftLocation);
938
+ });
939
+ }
940
+ function clear() {
941
+ loopPoints.forEach((loopPoint) => loopPoint.translate.clear());
942
+ }
943
+ return {
944
+ canLoop,
945
+ clear,
946
+ loop,
947
+ loopPoints
948
+ };
949
+ }
950
+ function SlidesHandler(container, eventHandler, watchSlides) {
951
+ let mutationObserver;
952
+ let destroyed = false;
953
+ function init(emblaApi) {
954
+ if (!watchSlides) return;
955
+ function defaultCallback(mutations) {
956
+ for (const mutation of mutations) if (mutation.type === "childList") {
957
+ emblaApi.reInit();
958
+ eventHandler.emit("slidesChanged");
959
+ break;
960
+ }
961
+ }
962
+ mutationObserver = new MutationObserver((mutations) => {
963
+ if (destroyed) return;
964
+ if (isBoolean(watchSlides) || watchSlides(emblaApi, mutations)) defaultCallback(mutations);
965
+ });
966
+ mutationObserver.observe(container, { childList: true });
967
+ }
968
+ function destroy() {
969
+ if (mutationObserver) mutationObserver.disconnect();
970
+ destroyed = true;
971
+ }
972
+ return {
973
+ init,
974
+ destroy
975
+ };
976
+ }
977
+ function SlidesInView(container, slides, eventHandler, threshold) {
978
+ const intersectionEntryMap = {};
979
+ let inViewCache = null;
980
+ let notInViewCache = null;
981
+ let intersectionObserver;
982
+ let destroyed = false;
983
+ function init() {
984
+ intersectionObserver = new IntersectionObserver((entries) => {
985
+ if (destroyed) return;
986
+ entries.forEach((entry) => {
987
+ const index = slides.indexOf(entry.target);
988
+ intersectionEntryMap[index] = entry;
989
+ });
990
+ inViewCache = null;
991
+ notInViewCache = null;
992
+ eventHandler.emit("slidesInView");
993
+ }, {
994
+ root: container.parentElement,
995
+ threshold
996
+ });
997
+ slides.forEach((slide) => intersectionObserver.observe(slide));
998
+ }
999
+ function destroy() {
1000
+ if (intersectionObserver) intersectionObserver.disconnect();
1001
+ destroyed = true;
1002
+ }
1003
+ function createInViewList(inView) {
1004
+ return objectKeys(intersectionEntryMap).reduce((list, slideIndex) => {
1005
+ const index = parseInt(slideIndex);
1006
+ const { isIntersecting } = intersectionEntryMap[index];
1007
+ if (inView && isIntersecting || !inView && !isIntersecting) list.push(index);
1008
+ return list;
1009
+ }, []);
1010
+ }
1011
+ function get(inView = true) {
1012
+ if (inView && inViewCache) return inViewCache;
1013
+ if (!inView && notInViewCache) return notInViewCache;
1014
+ const slideIndexes = createInViewList(inView);
1015
+ if (inView) inViewCache = slideIndexes;
1016
+ if (!inView) notInViewCache = slideIndexes;
1017
+ return slideIndexes;
1018
+ }
1019
+ return {
1020
+ init,
1021
+ destroy,
1022
+ get
1023
+ };
1024
+ }
1025
+ function SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow) {
1026
+ const { measureSize, startEdge, endEdge } = axis;
1027
+ const withEdgeGap = slideRects[0] && readEdgeGap;
1028
+ const startGap = measureStartGap();
1029
+ const endGap = measureEndGap();
1030
+ const slideSizes = slideRects.map(measureSize);
1031
+ const slideSizesWithGaps = measureWithGaps();
1032
+ function measureStartGap() {
1033
+ if (!withEdgeGap) return 0;
1034
+ const slideRect = slideRects[0];
1035
+ return mathAbs(containerRect[startEdge] - slideRect[startEdge]);
1036
+ }
1037
+ function measureEndGap() {
1038
+ if (!withEdgeGap) return 0;
1039
+ const style = ownerWindow.getComputedStyle(arrayLast(slides));
1040
+ return parseFloat(style.getPropertyValue(`margin-${endEdge}`));
1041
+ }
1042
+ function measureWithGaps() {
1043
+ return slideRects.map((rect, index, rects) => {
1044
+ const isFirst = !index;
1045
+ const isLast = arrayIsLastIndex(rects, index);
1046
+ if (isFirst) return slideSizes[index] + startGap;
1047
+ if (isLast) return slideSizes[index] + endGap;
1048
+ return rects[index + 1][startEdge] - rect[startEdge];
1049
+ }).map(mathAbs);
1050
+ }
1051
+ return {
1052
+ slideSizes,
1053
+ slideSizesWithGaps,
1054
+ startGap,
1055
+ endGap
1056
+ };
1057
+ }
1058
+ function SlidesToScroll(axis, viewSize, slidesToScroll, loop, containerRect, slideRects, startGap, endGap, pixelTolerance) {
1059
+ const { startEdge, endEdge, direction } = axis;
1060
+ const groupByNumber = isNumber(slidesToScroll);
1061
+ function byNumber(array, groupSize) {
1062
+ return arrayKeys(array).filter((i) => i % groupSize === 0).map((i) => array.slice(i, i + groupSize));
1063
+ }
1064
+ function bySize(array) {
1065
+ if (!array.length) return [];
1066
+ return arrayKeys(array).reduce((groups, rectB, index) => {
1067
+ const rectA = arrayLast(groups) || 0;
1068
+ const isFirst = rectA === 0;
1069
+ const isLast = rectB === arrayLastIndex(array);
1070
+ const edgeA = containerRect[startEdge] - slideRects[rectA][startEdge];
1071
+ const edgeB = containerRect[startEdge] - slideRects[rectB][endEdge];
1072
+ const gapA = !loop && isFirst ? direction(startGap) : 0;
1073
+ const chunkSize = mathAbs(edgeB - (!loop && isLast ? direction(endGap) : 0) - (edgeA + gapA));
1074
+ if (index && chunkSize > viewSize + pixelTolerance) groups.push(rectB);
1075
+ if (isLast) groups.push(array.length);
1076
+ return groups;
1077
+ }, []).map((currentSize, index, groups) => {
1078
+ const previousSize = Math.max(groups[index - 1] || 0);
1079
+ return array.slice(previousSize, currentSize);
1080
+ });
1081
+ }
1082
+ function groupSlides(array) {
1083
+ return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array);
1084
+ }
1085
+ return { groupSlides };
1086
+ }
1087
+ function Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler) {
1088
+ const { align, axis: scrollAxis, direction, startIndex, loop, duration, dragFree, dragThreshold, inViewThreshold, slidesToScroll: groupSlides, skipSnaps, containScroll, watchResize, watchSlides, watchDrag, watchFocus } = options;
1089
+ const pixelTolerance = 2;
1090
+ const nodeRects = NodeRects();
1091
+ const containerRect = nodeRects.measure(container);
1092
+ const slideRects = slides.map(nodeRects.measure);
1093
+ const axis = Axis(scrollAxis, direction);
1094
+ const viewSize = axis.measureSize(containerRect);
1095
+ const percentOfView = PercentOfView(viewSize);
1096
+ const alignment = Alignment(align, viewSize);
1097
+ const containSnaps = !loop && !!containScroll;
1098
+ const { slideSizes, slideSizesWithGaps, startGap, endGap } = SlideSizes(axis, containerRect, slideRects, slides, loop || !!containScroll, ownerWindow);
1099
+ const slidesToScroll = SlidesToScroll(axis, viewSize, groupSlides, loop, containerRect, slideRects, startGap, endGap, pixelTolerance);
1100
+ const { snaps, snapsAligned } = ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll);
1101
+ const contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
1102
+ const { snapsContained, scrollContainLimit } = ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance);
1103
+ const scrollSnaps = containSnaps ? snapsContained : snapsAligned;
1104
+ const { limit } = ScrollLimit(contentSize, scrollSnaps, loop);
1105
+ const index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
1106
+ const indexPrevious = index.clone();
1107
+ const slideIndexes = arrayKeys(slides);
1108
+ const update = ({ dragHandler, scrollBody, scrollBounds, options: { loop } }) => {
1109
+ if (!loop) scrollBounds.constrain(dragHandler.pointerDown());
1110
+ scrollBody.seek();
1111
+ };
1112
+ const render = ({ scrollBody, translate, location, offsetLocation, previousLocation, scrollLooper, slideLooper, dragHandler, animation, eventHandler, scrollBounds, options: { loop } }, alpha) => {
1113
+ const shouldSettle = scrollBody.settled();
1114
+ const withinBounds = !scrollBounds.shouldConstrain();
1115
+ const hasSettled = loop ? shouldSettle : shouldSettle && withinBounds;
1116
+ const hasSettledAndIdle = hasSettled && !dragHandler.pointerDown();
1117
+ if (hasSettledAndIdle) animation.stop();
1118
+ const interpolatedLocation = location.get() * alpha + previousLocation.get() * (1 - alpha);
1119
+ offsetLocation.set(interpolatedLocation);
1120
+ if (loop) {
1121
+ scrollLooper.loop(scrollBody.direction());
1122
+ slideLooper.loop();
1123
+ }
1124
+ translate.to(offsetLocation.get());
1125
+ if (hasSettledAndIdle) eventHandler.emit("settle");
1126
+ if (!hasSettled) eventHandler.emit("scroll");
1127
+ };
1128
+ const animation = Animations(ownerDocument, ownerWindow, () => update(engine), (alpha) => render(engine, alpha));
1129
+ const friction = .68;
1130
+ const startLocation = scrollSnaps[index.get()];
1131
+ const location = Vector1D(startLocation);
1132
+ const previousLocation = Vector1D(startLocation);
1133
+ const offsetLocation = Vector1D(startLocation);
1134
+ const target = Vector1D(startLocation);
1135
+ const scrollBody = ScrollBody(location, offsetLocation, previousLocation, target, duration, friction);
1136
+ const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
1137
+ const scrollTo = ScrollTo(animation, index, indexPrevious, scrollBody, scrollTarget, target, eventHandler);
1138
+ const scrollProgress = ScrollProgress(limit);
1139
+ const eventStore = EventStore();
1140
+ const slidesInView = SlidesInView(container, slides, eventHandler, inViewThreshold);
1141
+ const { slideRegistry } = SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes);
1142
+ const slideFocus = SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus);
1143
+ const engine = {
1144
+ ownerDocument,
1145
+ ownerWindow,
1146
+ eventHandler,
1147
+ containerRect,
1148
+ slideRects,
1149
+ animation,
1150
+ axis,
1151
+ dragHandler: DragHandler(axis, root, ownerDocument, ownerWindow, target, DragTracker(axis, ownerWindow), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction, watchDrag),
1152
+ eventStore,
1153
+ percentOfView,
1154
+ index,
1155
+ indexPrevious,
1156
+ limit,
1157
+ location,
1158
+ offsetLocation,
1159
+ previousLocation,
1160
+ options,
1161
+ resizeHandler: ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects),
1162
+ scrollBody,
1163
+ scrollBounds: ScrollBounds(limit, offsetLocation, target, scrollBody, percentOfView),
1164
+ scrollLooper: ScrollLooper(contentSize, limit, offsetLocation, [
1165
+ location,
1166
+ offsetLocation,
1167
+ previousLocation,
1168
+ target
1169
+ ]),
1170
+ scrollProgress,
1171
+ scrollSnapList: scrollSnaps.map(scrollProgress.get),
1172
+ scrollSnaps,
1173
+ scrollTarget,
1174
+ scrollTo,
1175
+ slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, offsetLocation, slides),
1176
+ slideFocus,
1177
+ slidesHandler: SlidesHandler(container, eventHandler, watchSlides),
1178
+ slidesInView,
1179
+ slideIndexes,
1180
+ slideRegistry,
1181
+ slidesToScroll,
1182
+ target,
1183
+ translate: Translate(axis, container)
1184
+ };
1185
+ return engine;
1186
+ }
1187
+ function EventHandler() {
1188
+ let listeners = {};
1189
+ let api;
1190
+ function init(emblaApi) {
1191
+ api = emblaApi;
1192
+ }
1193
+ function getListeners(evt) {
1194
+ return listeners[evt] || [];
1195
+ }
1196
+ function emit(evt) {
1197
+ getListeners(evt).forEach((e) => e(api, evt));
1198
+ return self;
1199
+ }
1200
+ function on(evt, cb) {
1201
+ listeners[evt] = getListeners(evt).concat([cb]);
1202
+ return self;
1203
+ }
1204
+ function off(evt, cb) {
1205
+ listeners[evt] = getListeners(evt).filter((e) => e !== cb);
1206
+ return self;
1207
+ }
1208
+ function clear() {
1209
+ listeners = {};
1210
+ }
1211
+ const self = {
1212
+ init,
1213
+ emit,
1214
+ off,
1215
+ on,
1216
+ clear
1217
+ };
1218
+ return self;
1219
+ }
1220
+ var defaultOptions = {
1221
+ align: "center",
1222
+ axis: "x",
1223
+ container: null,
1224
+ slides: null,
1225
+ containScroll: "trimSnaps",
1226
+ direction: "ltr",
1227
+ slidesToScroll: 1,
1228
+ inViewThreshold: 0,
1229
+ breakpoints: {},
1230
+ dragFree: false,
1231
+ dragThreshold: 10,
1232
+ loop: false,
1233
+ skipSnaps: false,
1234
+ duration: 25,
1235
+ startIndex: 0,
1236
+ active: true,
1237
+ watchDrag: true,
1238
+ watchResize: true,
1239
+ watchSlides: true,
1240
+ watchFocus: true
1241
+ };
1242
+ function OptionsHandler(ownerWindow) {
1243
+ function mergeOptions(optionsA, optionsB) {
1244
+ return objectsMergeDeep(optionsA, optionsB || {});
1245
+ }
1246
+ function optionsAtMedia(options) {
1247
+ const optionsAtMedia = options.breakpoints || {};
1248
+ return mergeOptions(options, objectKeys(optionsAtMedia).filter((media) => ownerWindow.matchMedia(media).matches).map((media) => optionsAtMedia[media]).reduce((a, mediaOption) => mergeOptions(a, mediaOption), {}));
1249
+ }
1250
+ function optionsMediaQueries(optionsList) {
1251
+ return optionsList.map((options) => objectKeys(options.breakpoints || {})).reduce((acc, mediaQueries) => acc.concat(mediaQueries), []).map(ownerWindow.matchMedia);
1252
+ }
1253
+ return {
1254
+ mergeOptions,
1255
+ optionsAtMedia,
1256
+ optionsMediaQueries
1257
+ };
1258
+ }
1259
+ function PluginsHandler(optionsHandler) {
1260
+ let activePlugins = [];
1261
+ function init(emblaApi, plugins) {
1262
+ activePlugins = plugins.filter(({ options }) => optionsHandler.optionsAtMedia(options).active !== false);
1263
+ activePlugins.forEach((plugin) => plugin.init(emblaApi, optionsHandler));
1264
+ return plugins.reduce((map, plugin) => Object.assign(map, { [plugin.name]: plugin }), {});
1265
+ }
1266
+ function destroy() {
1267
+ activePlugins = activePlugins.filter((plugin) => plugin.destroy());
1268
+ }
1269
+ return {
1270
+ init,
1271
+ destroy
1272
+ };
1273
+ }
1274
+ function EmblaCarousel(root, userOptions, userPlugins) {
1275
+ const ownerDocument = root.ownerDocument;
1276
+ const ownerWindow = ownerDocument.defaultView;
1277
+ const optionsHandler = OptionsHandler(ownerWindow);
1278
+ const pluginsHandler = PluginsHandler(optionsHandler);
1279
+ const mediaHandlers = EventStore();
1280
+ const eventHandler = EventHandler();
1281
+ const { mergeOptions, optionsAtMedia, optionsMediaQueries } = optionsHandler;
1282
+ const { on, off, emit } = eventHandler;
1283
+ const reInit = reActivate;
1284
+ let destroyed = false;
1285
+ let engine;
1286
+ let optionsBase = mergeOptions(defaultOptions, EmblaCarousel.globalOptions);
1287
+ let options = mergeOptions(optionsBase);
1288
+ let pluginList = [];
1289
+ let pluginApis;
1290
+ let container;
1291
+ let slides;
1292
+ function storeElements() {
1293
+ const { container: userContainer, slides: userSlides } = options;
1294
+ container = (isString(userContainer) ? root.querySelector(userContainer) : userContainer) || root.children[0];
1295
+ const customSlides = isString(userSlides) ? container.querySelectorAll(userSlides) : userSlides;
1296
+ slides = [].slice.call(customSlides || container.children);
1297
+ }
1298
+ function createEngine(options) {
1299
+ const engine = Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler);
1300
+ if (options.loop && !engine.slideLooper.canLoop()) return createEngine(Object.assign({}, options, { loop: false }));
1301
+ return engine;
1302
+ }
1303
+ function activate(withOptions, withPlugins) {
1304
+ if (destroyed) return;
1305
+ optionsBase = mergeOptions(optionsBase, withOptions);
1306
+ options = optionsAtMedia(optionsBase);
1307
+ pluginList = withPlugins || pluginList;
1308
+ storeElements();
1309
+ engine = createEngine(options);
1310
+ optionsMediaQueries([optionsBase, ...pluginList.map(({ options }) => options)]).forEach((query) => mediaHandlers.add(query, "change", reActivate));
1311
+ if (!options.active) return;
1312
+ engine.translate.to(engine.location.get());
1313
+ engine.animation.init();
1314
+ engine.slidesInView.init();
1315
+ engine.slideFocus.init(self);
1316
+ engine.eventHandler.init(self);
1317
+ engine.resizeHandler.init(self);
1318
+ engine.slidesHandler.init(self);
1319
+ if (engine.options.loop) engine.slideLooper.loop();
1320
+ if (container.offsetParent && slides.length) engine.dragHandler.init(self);
1321
+ pluginApis = pluginsHandler.init(self, pluginList);
1322
+ }
1323
+ function reActivate(withOptions, withPlugins) {
1324
+ const startIndex = selectedScrollSnap();
1325
+ deActivate();
1326
+ activate(mergeOptions({ startIndex }, withOptions), withPlugins);
1327
+ eventHandler.emit("reInit");
1328
+ }
1329
+ function deActivate() {
1330
+ engine.dragHandler.destroy();
1331
+ engine.eventStore.clear();
1332
+ engine.translate.clear();
1333
+ engine.slideLooper.clear();
1334
+ engine.resizeHandler.destroy();
1335
+ engine.slidesHandler.destroy();
1336
+ engine.slidesInView.destroy();
1337
+ engine.animation.destroy();
1338
+ pluginsHandler.destroy();
1339
+ mediaHandlers.clear();
1340
+ }
1341
+ function destroy() {
1342
+ if (destroyed) return;
1343
+ destroyed = true;
1344
+ mediaHandlers.clear();
1345
+ deActivate();
1346
+ eventHandler.emit("destroy");
1347
+ eventHandler.clear();
1348
+ }
1349
+ function scrollTo(index, jump, direction) {
1350
+ if (!options.active || destroyed) return;
1351
+ engine.scrollBody.useBaseFriction().useDuration(jump === true ? 0 : options.duration);
1352
+ engine.scrollTo.index(index, direction || 0);
1353
+ }
1354
+ function scrollNext(jump) {
1355
+ scrollTo(engine.index.add(1).get(), jump, -1);
1356
+ }
1357
+ function scrollPrev(jump) {
1358
+ scrollTo(engine.index.add(-1).get(), jump, 1);
1359
+ }
1360
+ function canScrollNext() {
1361
+ return engine.index.add(1).get() !== selectedScrollSnap();
1362
+ }
1363
+ function canScrollPrev() {
1364
+ return engine.index.add(-1).get() !== selectedScrollSnap();
1365
+ }
1366
+ function scrollSnapList() {
1367
+ return engine.scrollSnapList;
1368
+ }
1369
+ function scrollProgress() {
1370
+ return engine.scrollProgress.get(engine.offsetLocation.get());
1371
+ }
1372
+ function selectedScrollSnap() {
1373
+ return engine.index.get();
1374
+ }
1375
+ function previousScrollSnap() {
1376
+ return engine.indexPrevious.get();
1377
+ }
1378
+ function slidesInView() {
1379
+ return engine.slidesInView.get();
1380
+ }
1381
+ function slidesNotInView() {
1382
+ return engine.slidesInView.get(false);
1383
+ }
1384
+ function plugins() {
1385
+ return pluginApis;
1386
+ }
1387
+ function internalEngine() {
1388
+ return engine;
1389
+ }
1390
+ function rootNode() {
1391
+ return root;
1392
+ }
1393
+ function containerNode() {
1394
+ return container;
1395
+ }
1396
+ function slideNodes() {
1397
+ return slides;
1398
+ }
1399
+ const self = {
1400
+ canScrollNext,
1401
+ canScrollPrev,
1402
+ containerNode,
1403
+ internalEngine,
1404
+ destroy,
1405
+ off,
1406
+ on,
1407
+ emit,
1408
+ plugins,
1409
+ previousScrollSnap,
1410
+ reInit,
1411
+ rootNode,
1412
+ scrollNext,
1413
+ scrollPrev,
1414
+ scrollProgress,
1415
+ scrollSnapList,
1416
+ scrollTo,
1417
+ selectedScrollSnap,
1418
+ slideNodes,
1419
+ slidesInView,
1420
+ slidesNotInView
1421
+ };
1422
+ activate(userOptions, userPlugins);
1423
+ setTimeout(() => eventHandler.emit("init"), 0);
1424
+ return self;
1425
+ }
1426
+ EmblaCarousel.globalOptions = void 0;
1427
+ //#endregion
1428
+ //#region ../../../node_modules/.pnpm/embla-carousel-react@8.6.0_react@19.2.4/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js
1429
+ function useEmblaCarousel(options = {}, plugins = []) {
1430
+ const storedOptions = (0, import_react.useRef)(options);
1431
+ const storedPlugins = (0, import_react.useRef)(plugins);
1432
+ const [emblaApi, setEmblaApi] = (0, import_react.useState)();
1433
+ const [viewport, setViewport] = (0, import_react.useState)();
1434
+ const reInit = (0, import_react.useCallback)(() => {
1435
+ if (emblaApi) emblaApi.reInit(storedOptions.current, storedPlugins.current);
1436
+ }, [emblaApi]);
1437
+ (0, import_react.useEffect)(() => {
1438
+ if (areOptionsEqual(storedOptions.current, options)) return;
1439
+ storedOptions.current = options;
1440
+ reInit();
1441
+ }, [options, reInit]);
1442
+ (0, import_react.useEffect)(() => {
1443
+ if (arePluginsEqual(storedPlugins.current, plugins)) return;
1444
+ storedPlugins.current = plugins;
1445
+ reInit();
1446
+ }, [plugins, reInit]);
1447
+ (0, import_react.useEffect)(() => {
1448
+ if (canUseDOM() && viewport) {
1449
+ EmblaCarousel.globalOptions = useEmblaCarousel.globalOptions;
1450
+ const newEmblaApi = EmblaCarousel(viewport, storedOptions.current, storedPlugins.current);
1451
+ setEmblaApi(newEmblaApi);
1452
+ return () => newEmblaApi.destroy();
1453
+ } else setEmblaApi(void 0);
1454
+ }, [viewport, setEmblaApi]);
1455
+ return [setViewport, emblaApi];
1456
+ }
1457
+ useEmblaCarousel.globalOptions = void 0;
1458
+ //#endregion
1459
+ export { useEmblaCarousel as default };
1460
+
1461
+ //# sourceMappingURL=embla-carousel-react.js.map