@rific/scroll-view 0.1.0

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 (46) hide show
  1. package/README.md +319 -0
  2. package/dist/index.d.mts +210 -0
  3. package/dist/index.d.ts +210 -0
  4. package/dist/index.js +2760 -0
  5. package/dist/index.mjs +2709 -0
  6. package/package.json +105 -0
  7. package/src/CustomList.tsx +127 -0
  8. package/src/FlatList.tsx +139 -0
  9. package/src/PullSearch.tsx +99 -0
  10. package/src/ScrollView.tsx +89 -0
  11. package/src/ScrollViewContext.ts +50 -0
  12. package/src/ScrollViewFooter.tsx +48 -0
  13. package/src/ScrollViewHeader.tsx +159 -0
  14. package/src/ScrollViewProvider.tsx +62 -0
  15. package/src/ScrollViewSettingsContext.ts +27 -0
  16. package/src/ScrollViewSettingsProvider.tsx +31 -0
  17. package/src/SectionList.tsx +195 -0
  18. package/src/__mocks__/auto-paper.ts +8 -0
  19. package/src/__mocks__/flash-list.ts +20 -0
  20. package/src/__mocks__/react-native-gesture-handler.ts +13 -0
  21. package/src/__mocks__/react-native-keyboard-controller.ts +11 -0
  22. package/src/__mocks__/react-native-paper.ts +22 -0
  23. package/src/__mocks__/react-native-reanimated.ts +30 -0
  24. package/src/__mocks__/react-native-safe-area-context.ts +2 -0
  25. package/src/__mocks__/react-native.ts +30 -0
  26. package/src/__tests__/CustomList.test.tsx +61 -0
  27. package/src/__tests__/FlatList.test.tsx +52 -0
  28. package/src/__tests__/PullSearch.test.tsx +38 -0
  29. package/src/__tests__/ScrollView.test.tsx +23 -0
  30. package/src/__tests__/ScrollViewHeader.test.tsx +28 -0
  31. package/src/__tests__/ScrollViewProvider.test.tsx +65 -0
  32. package/src/__tests__/SectionList.test.tsx +88 -0
  33. package/src/index.ts +26 -0
  34. package/src/internal/FAB.tsx +6 -0
  35. package/src/internal/HorizontalDots.tsx +99 -0
  36. package/src/internal/RefreshControl.tsx +5 -0
  37. package/src/internal/ScrollViewChip.tsx +22 -0
  38. package/src/internal/useScrollHandler.ts +101 -0
  39. package/src/internal/useScrollList.ts +64 -0
  40. package/src/internal/useStickyHeaders.ts +149 -0
  41. package/src/out.txt +61 -0
  42. package/src/redux/scrollViewSlice.ts +14 -0
  43. package/src/useKeyboardInset.ts +21 -0
  44. package/src/useScrollInit.ts +112 -0
  45. package/src/useScrollView.ts +8 -0
  46. package/src/useScrollViewSettings.ts +5 -0
package/dist/index.js ADDED
@@ -0,0 +1,2760 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+
32
+ // src/index.ts
33
+ var index_exports = {};
34
+ __export(index_exports, {
35
+ CustomList: () => CustomList,
36
+ FlatList: () => FlatList,
37
+ PullSearch: () => PullSearch,
38
+ ScrollView: () => ScrollView,
39
+ ScrollViewContext: () => ScrollViewContext,
40
+ ScrollViewFooter: () => ScrollViewFooter,
41
+ ScrollViewHeader: () => ScrollViewHeader,
42
+ ScrollViewProvider: () => ScrollViewProvider,
43
+ ScrollViewSettingsContext: () => ScrollViewSettingsContext,
44
+ ScrollViewSettingsProvider: () => ScrollViewSettingsProvider,
45
+ SectionList: () => SectionList,
46
+ defaultScrollViewSettings: () => defaultScrollViewSettings,
47
+ scrollViewActions: () => scrollViewActions,
48
+ scrollViewReducer: () => scrollViewReducer,
49
+ useKeyboardInset: () => useKeyboardInset,
50
+ useScrollView: () => useScrollView,
51
+ useScrollViewSettings: () => useScrollViewSettings
52
+ });
53
+ module.exports = __toCommonJS(index_exports);
54
+
55
+ // src/CustomList.tsx
56
+ var import_react6 = require("react");
57
+ var import_react_native4 = require("react-native");
58
+ var import_react_native_gesture_handler = require("react-native-gesture-handler");
59
+
60
+ // src/internal/RefreshControl.tsx
61
+ var import_react_native = require("react-native");
62
+ var import_jsx_runtime = require("react/jsx-runtime");
63
+ var RefreshControl = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.RefreshControl, { refreshing: false, ...props });
64
+
65
+ // src/internal/ScrollViewChip.tsx
66
+ var import_react_native2 = require("react-native");
67
+ var import_react_native_paper = require("react-native-paper");
68
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"));
69
+ var import_jsx_runtime2 = require("react/jsx-runtime");
70
+ var ScrollViewChip = ({ isHorizontal, onPress, style }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { style: [styles.chip, style], children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper.Chip, { compact: true, icon: isHorizontal ? "chevron-left" : "chevron-up", onPress, style: styles.chipInner, children: isHorizontal ? "Start" : "Top" }) });
71
+ var styles = import_react_native2.StyleSheet.create({
72
+ chip: { alignItems: "center", left: 0, position: "absolute", right: 0, zIndex: 3 },
73
+ chipInner: { elevation: 2, shadowColor: "#000", shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.15, shadowRadius: 2 }
74
+ });
75
+
76
+ // src/internal/useScrollHandler.ts
77
+ var import_react2 = require("react");
78
+ var import_react_native_reanimated2 = require("react-native-reanimated");
79
+
80
+ // src/ScrollViewContext.ts
81
+ var import_react = require("react");
82
+ var ScrollViewContext = (0, import_react.createContext)({
83
+ blur: true,
84
+ footerHeight: 0,
85
+ footerHeightShared: null,
86
+ footerFixed: false,
87
+ footerOffset: null,
88
+ headerHeight: 0,
89
+ headerHeightShared: null,
90
+ headerFixed: false,
91
+ headerOffset: null,
92
+ progress: null,
93
+ progressing: false,
94
+ pullSearchHeightShared: null,
95
+ scrollHeight: 0,
96
+ scrollPosition: null,
97
+ setFooterHeight: () => {
98
+ },
99
+ setHeaderHeight: () => {
100
+ },
101
+ setProgress: () => {
102
+ },
103
+ setProgressing: () => {
104
+ },
105
+ snapBackFooterShared: null,
106
+ snapBackHeaderShared: null,
107
+ tabBarHeight: 60
108
+ });
109
+
110
+ // src/internal/useScrollHandler.ts
111
+ function useScrollHandler({ chipHidden, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter }) {
112
+ const { footerHeightShared, footerOffset, headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackFooterShared, snapBackHeaderShared } = (0, import_react2.useContext)(ScrollViewContext);
113
+ const snapUpAccum = (0, import_react_native_reanimated2.useSharedValue)(0);
114
+ const fromBottomBounce = (0, import_react_native_reanimated2.useSharedValue)(false);
115
+ const isMomentum = (0, import_react_native_reanimated2.useSharedValue)(false);
116
+ const momentumPullSearchFired = (0, import_react_native_reanimated2.useSharedValue)(false);
117
+ return (0, import_react_native_reanimated2.useAnimatedScrollHandler)(
118
+ {
119
+ onScroll: ({ contentOffset: { x, y }, contentSize: { height: contentHeight }, layoutMeasurement: { height: layoutHeight } }) => {
120
+ "worklet";
121
+ if (isHorizontal) {
122
+ scrollPosition.value = x;
123
+ chipHidden.value = x < 100 ? 1 : 0;
124
+ return;
125
+ }
126
+ const delta = y - scrollPosition.value;
127
+ scrollPosition.value = y;
128
+ chipHidden.value = y < 100 ? 1 : 0;
129
+ const maxScroll = contentHeight - layoutHeight;
130
+ if (maxScroll > 0 && y >= maxScroll) {
131
+ fromBottomBounce.value = true;
132
+ snapUpAccum.value = 0;
133
+ } else if (fromBottomBounce.value) {
134
+ fromBottomBounce.value = false;
135
+ }
136
+ if (isMomentum.value && pullSearchHeightShared.value > 0 && !momentumPullSearchFired.value) {
137
+ const hideY = -headerHeightShared.value + pullSearchHeightShared.value;
138
+ if (y < hideY) {
139
+ momentumPullSearchFired.value = true;
140
+ if (onPullSearchZoneEnter) (0, import_react_native_reanimated2.runOnJS)(onPullSearchZoneEnter)();
141
+ }
142
+ }
143
+ const snapHeader = snapBackHeaderShared.value && !headerFixed;
144
+ const snapFooter = snapBackFooterShared.value && !footerFixed;
145
+ if (snapHeader || snapFooter) {
146
+ if (y <= -headerHeightShared.value) {
147
+ snapUpAccum.value = 0;
148
+ if (snapHeader) headerOffset.value = 0;
149
+ if (snapFooter) footerOffset.value = 0;
150
+ } else if (delta > 0) {
151
+ snapUpAccum.value = 0;
152
+ if (y >= -headerHeightShared.value + pullSearchHeightShared.value) {
153
+ if (snapHeader) headerOffset.value = Math.max(-headerHeightShared.value, Math.min(0, headerOffset.value - delta));
154
+ if (snapFooter) footerOffset.value = Math.max(0, Math.min(footerHeightShared.value, footerOffset.value + delta));
155
+ }
156
+ } else if (delta < 0 && !fromBottomBounce.value) {
157
+ if (y >= -headerHeightShared.value + pullSearchHeightShared.value) snapUpAccum.value -= delta;
158
+ if (snapUpAccum.value >= 10) {
159
+ snapUpAccum.value = 999;
160
+ if (snapHeader) headerOffset.value = (0, import_react_native_reanimated2.withTiming)(0, { duration: 200 });
161
+ if (snapFooter) footerOffset.value = (0, import_react_native_reanimated2.withTiming)(0, { duration: 200 });
162
+ }
163
+ }
164
+ }
165
+ },
166
+ onBeginDrag: () => {
167
+ "worklet";
168
+ isMomentum.value = false;
169
+ momentumPullSearchFired.value = false;
170
+ fromBottomBounce.value = false;
171
+ snapUpAccum.value = 0;
172
+ },
173
+ onMomentumBegin: () => {
174
+ "worklet";
175
+ isMomentum.value = true;
176
+ momentumPullSearchFired.value = false;
177
+ },
178
+ onEndDrag: ({ contentOffset: { y }, contentSize: { height: contentHeight }, layoutMeasurement: { height: layoutHeight } }) => {
179
+ "worklet";
180
+ if (isHorizontal) return;
181
+ if (y >= contentHeight - layoutHeight - 10) {
182
+ fromBottomBounce.value = true;
183
+ snapUpAccum.value = 0;
184
+ }
185
+ },
186
+ onMomentumEnd: () => {
187
+ "worklet";
188
+ isMomentum.value = false;
189
+ momentumPullSearchFired.value = false;
190
+ fromBottomBounce.value = false;
191
+ snapUpAccum.value = 0;
192
+ }
193
+ },
194
+ [headerFixed, footerFixed, isHorizontal, onPullSearchZoneEnter]
195
+ );
196
+ }
197
+
198
+ // src/internal/useScrollList.ts
199
+ var import_react4 = require("react");
200
+ var import_react_native3 = require("react-native");
201
+ var import_react_native_reanimated4 = require("react-native-reanimated");
202
+ var import_react_native_safe_area_context = require("react-native-safe-area-context");
203
+
204
+ // src/useKeyboardInset.ts
205
+ var import_react3 = require("react");
206
+ var import_react_native_keyboard_controller = require("react-native-keyboard-controller");
207
+ var import_react_native_reanimated3 = require("react-native-reanimated");
208
+ var useKeyboardInset = () => {
209
+ const [keyboardHeight, setKeyboardHeight] = (0, import_react3.useState)(0);
210
+ (0, import_react_native_keyboard_controller.useKeyboardHandler)(
211
+ {
212
+ onMove: (e) => {
213
+ "worklet";
214
+ (0, import_react_native_reanimated3.runOnJS)(setKeyboardHeight)(e.height);
215
+ },
216
+ onEnd: (e) => {
217
+ "worklet";
218
+ (0, import_react_native_reanimated3.runOnJS)(setKeyboardHeight)(e.height);
219
+ }
220
+ },
221
+ []
222
+ );
223
+ return keyboardHeight;
224
+ };
225
+
226
+ // src/internal/useScrollList.ts
227
+ var CHIP_SLIDE = 48;
228
+ function useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style } = {}) {
229
+ const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
230
+ const keyboardHeight = useKeyboardInset();
231
+ const { footerHeight, footerFixed: contextFooterFixed, headerHeight, headerFixed: contextHeaderFixed, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react4.useContext)(ScrollViewContext);
232
+ const headerFixed = isHorizontal ? true : headerFixedProp ?? contextHeaderFixed;
233
+ const footerFixed = isHorizontal ? true : footerFixedProp ?? contextFooterFixed;
234
+ (0, import_react4.useEffect)(() => {
235
+ pullSearchHeightShared.value = pullSearchHeight ?? 0;
236
+ }, [pullSearchHeight, pullSearchHeightShared]);
237
+ const containerStyle = (0, import_react4.useMemo)(() => headerHeight === 0 ? [{ flex: 1 }, style] : [import_react_native3.StyleSheet.absoluteFill, style], [headerHeight, style]);
238
+ const contentInset = (0, import_react4.useMemo)(() => ({ bottom: (footerFixed ? footerHeight || insets.bottom : insets.bottom) + (keyboardAware ? keyboardHeight : 0), top: headerHeight }), [footerFixed, footerHeight, insets.bottom, headerHeight, keyboardAware, keyboardHeight]);
239
+ const contentOffset = (0, import_react4.useMemo)(() => ({ x: 0, y: -contentInset.top }), [contentInset.top]);
240
+ const chipHidden = (0, import_react_native_reanimated4.useSharedValue)(1);
241
+ const chipStyle = (0, import_react_native_reanimated4.useAnimatedStyle)(() => {
242
+ const pointerEvents = chipHidden.value ? "none" : "box-none";
243
+ if (isHorizontal) {
244
+ return {
245
+ opacity: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(0) : (0, import_react_native_reanimated4.withTiming)(1),
246
+ pointerEvents,
247
+ top: Math.max(headerHeight, insets.top) + 4,
248
+ transform: [{ translateX: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated4.withTiming)(0) }]
249
+ };
250
+ }
251
+ const slide = headerFixed ? 0 : snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
252
+ const top = Math.max(headerHeight - slide, insets.top) + 4;
253
+ return {
254
+ opacity: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(0) : (0, import_react_native_reanimated4.withTiming)(1),
255
+ pointerEvents,
256
+ top,
257
+ transform: [{ translateY: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated4.withTiming)(0) }]
258
+ };
259
+ }, [isHorizontal, headerFixed, headerHeight, insets.top]);
260
+ return { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed, headerHeight, insets, isHorizontal: isHorizontal ?? false };
261
+ }
262
+
263
+ // src/useScrollInit.ts
264
+ var import_react5 = require("react");
265
+ function useScrollInit({ listHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollTo }) {
266
+ const { headerHeight, scrollPosition, setProgressing } = (0, import_react5.useContext)(ScrollViewContext);
267
+ const hasPullSearch = pullSearchHeight !== void 0;
268
+ const [phase, setPhase] = (0, import_react5.useState)(hasPullSearch ? "measuring" : "ready");
269
+ const [refreshing, setRefreshing] = (0, import_react5.useState)(false);
270
+ const dragStartY = (0, import_react5.useRef)(null);
271
+ const deliberatelyOpened = (0, import_react5.useRef)(false);
272
+ (0, import_react5.useEffect)(() => {
273
+ if (phase === "ready" || !headerHeight || !pullSearchHeight) return;
274
+ scrollPosition.value = -headerHeight + pullSearchHeight;
275
+ setPhase("ready");
276
+ }, [phase, headerHeight, pullSearchHeight, scrollPosition]);
277
+ const headerInitialized = (0, import_react5.useRef)(false);
278
+ (0, import_react5.useLayoutEffect)(() => {
279
+ if (!headerHeight || headerInitialized.current) return;
280
+ headerInitialized.current = true;
281
+ scrollPosition.value = -headerHeight;
282
+ scrollTo(-headerHeight, false);
283
+ }, [headerHeight, scrollPosition, scrollTo]);
284
+ const pullSearchInitialized = (0, import_react5.useRef)(false);
285
+ (0, import_react5.useLayoutEffect)(() => {
286
+ if (!hasPullSearch || phase !== "ready" || pullSearchInitialized.current || !headerHeight || !pullSearchHeight) return;
287
+ pullSearchInitialized.current = true;
288
+ scrollPosition.value = -headerHeight + pullSearchHeight;
289
+ scrollTo(-headerHeight + pullSearchHeight, false);
290
+ }, [hasPullSearch, phase, headerHeight, pullSearchHeight, scrollPosition, scrollTo]);
291
+ (0, import_react5.useEffect)(() => {
292
+ if (pullSearchHeight) setProgressing(refreshing);
293
+ }, [pullSearchHeight, refreshing, setProgressing]);
294
+ const handleScrollBeginDrag = (0, import_react5.useCallback)(
295
+ (e) => {
296
+ deliberatelyOpened.current = false;
297
+ if (pullSearchHeight) dragStartY.current = e.nativeEvent.contentOffset.y;
298
+ externalScrollBeginDrag?.(e);
299
+ },
300
+ [externalScrollBeginDrag, pullSearchHeight]
301
+ );
302
+ const handleScrollEndDrag = (0, import_react5.useCallback)(
303
+ (e) => {
304
+ if (pullSearchHeight && headerHeight) {
305
+ const y = e.nativeEvent.contentOffset.y;
306
+ const showY = -headerHeight;
307
+ const hideY = -headerHeight + pullSearchHeight;
308
+ const pulledDown = (dragStartY.current ?? hideY) <= hideY;
309
+ dragStartY.current = null;
310
+ if (pulledDown && y <= showY + pullSearchHeight * 0.5) {
311
+ deliberatelyOpened.current = true;
312
+ if (y <= showY && !refreshing && onRefresh) {
313
+ setRefreshing(true);
314
+ Promise.resolve(onRefresh()).finally(() => setRefreshing(false));
315
+ }
316
+ scrollTo(showY, true);
317
+ } else if (y < hideY) {
318
+ scrollTo(hideY, true);
319
+ }
320
+ }
321
+ externalScrollEndDrag?.(e);
322
+ },
323
+ [externalScrollEndDrag, headerHeight, onRefresh, pullSearchHeight, refreshing, scrollTo]
324
+ );
325
+ const handleMomentumScrollEnd = (0, import_react5.useCallback)(
326
+ (e) => {
327
+ if (pullSearchHeight && headerHeight && !deliberatelyOpened.current && !refreshing) {
328
+ const y = e.nativeEvent.contentOffset.y;
329
+ const hideY = -headerHeight + pullSearchHeight;
330
+ if (y < hideY - 1) scrollTo(hideY, true);
331
+ }
332
+ deliberatelyOpened.current = false;
333
+ externalMomentumScrollEnd?.(e);
334
+ },
335
+ [externalMomentumScrollEnd, headerHeight, pullSearchHeight, refreshing, scrollTo]
336
+ );
337
+ const activeListHeader = hasPullSearch && phase === "measuring" ? null : listHeaderComponent;
338
+ const hiddenHeader = phase === "measuring" && listHeaderComponent != null ? typeof listHeaderComponent === "function" ? (0, import_react5.createElement)(listHeaderComponent) : listHeaderComponent : null;
339
+ return { activeListHeader, handleMomentumScrollEnd, handleScrollBeginDrag, handleScrollEndDrag, hiddenHeader, pullSearchMinHeight: pullSearchHeight ?? 0 };
340
+ }
341
+
342
+ // src/CustomList.tsx
343
+ var import_jsx_runtime3 = require("react/jsx-runtime");
344
+ var CustomListInner = ({ component: List, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollRef, style, ...props }) => {
345
+ const { ListHeaderComponent: listHeaderComponent, contentContainerStyle: externalContentContainerStyle, ...restProps } = props;
346
+ const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, keyboardAware, pullSearchHeight, style });
347
+ const scrollViewInternal = (0, import_react6.useRef)(null);
348
+ const handleRef = (0, import_react6.useCallback)(
349
+ (el) => {
350
+ scrollViewInternal.current = el;
351
+ if (scrollRef) scrollRef.current = el;
352
+ },
353
+ [scrollRef]
354
+ );
355
+ const scrollTo = (0, import_react6.useCallback)((offset, animated) => {
356
+ scrollViewInternal.current?.scrollToOffset({ offset, animated });
357
+ }, []);
358
+ const {
359
+ activeListHeader: pullSearchHeader,
360
+ handleMomentumScrollEnd,
361
+ handleScrollBeginDrag,
362
+ handleScrollEndDrag,
363
+ hiddenHeader,
364
+ pullSearchMinHeight
365
+ } = useScrollInit({
366
+ listHeaderComponent,
367
+ onMomentumScrollEnd: externalMomentumScrollEnd,
368
+ onRefresh: pullSearchHeight ? onRefresh : void 0,
369
+ onScrollBeginDrag: externalScrollBeginDrag,
370
+ onScrollEndDrag: externalScrollEndDrag,
371
+ pullSearchHeight,
372
+ scrollTo
373
+ });
374
+ const activeListHeader = (0, import_react6.useMemo)(() => {
375
+ if (!renderFilters) return pullSearchHeader;
376
+ const Inner = pullSearchHeader;
377
+ return () => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
378
+ Inner ? typeof Inner === "function" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Inner, {}) : Inner : null,
379
+ renderFilters
380
+ ] });
381
+ }, [pullSearchHeader, renderFilters]);
382
+ const contentContainerStyle = (0, import_react6.useMemo)(() => [{ minHeight: import_react_native4.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
383
+ const onPullSearchZoneEnter = (0, import_react6.useCallback)(() => {
384
+ if (!pullSearchHeight) return;
385
+ scrollViewInternal.current?.scrollToOffset({ offset: -contentInset.top + pullSearchHeight, animated: true });
386
+ }, [contentInset.top, pullSearchHeight]);
387
+ const onScroll = useScrollHandler({ chipHidden, footerFixed, headerFixed, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
388
+ const handleScrollToTop = (0, import_react6.useCallback)(() => {
389
+ const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
390
+ scrollViewInternal.current?.scrollToOffset({ offset, animated: true });
391
+ }, [contentInset.top, pullSearchHeight]);
392
+ const refreshControl = (0, import_react6.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RefreshControl, {}), []);
393
+ const nativeGesture = (0, import_react6.useMemo)(() => import_react_native_gesture_handler.Gesture.Native(), []);
394
+ const combinedGesture = (0, import_react6.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
395
+ const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
396
+ const TypedList = List;
397
+ const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native4.View, { style: containerStyle, children: [
398
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TypedList, { ...restProps, contentContainerStyle, contentInset, contentOffset, ListHeaderComponent: activeListHeader, onMomentumScrollEnd: handleMomentumScrollEnd, onScroll, onScrollBeginDrag: handleScrollBeginDrag, onScrollEndDrag: handleScrollEndDrag, ref: handleRef, refreshControl, scrollEventThrottle: 16 }),
399
+ hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native4.View, { pointerEvents: "none", style: styles2.measureContainer, children: hiddenHeader }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ScrollViewChip, { onPress: handleScrollToTop, style: chipStyle })
401
+ ] });
402
+ return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: detectorGesture, children: content }) : content;
403
+ };
404
+ var styles2 = { measureContainer: { left: 0, opacity: 0, position: "absolute", right: 0, top: -9999 } };
405
+ var CustomList = (0, import_react6.memo)(CustomListInner);
406
+
407
+ // src/FlatList.tsx
408
+ var import_react8 = require("react");
409
+ var import_react_native6 = require("react-native");
410
+ var import_react_native_gesture_handler2 = require("react-native-gesture-handler");
411
+ var import_react_native_reanimated6 = __toESM(require("react-native-reanimated"));
412
+
413
+ // src/internal/HorizontalDots.tsx
414
+ var import_auto_paper = require("@rific/auto-paper");
415
+ var import_react7 = require("react");
416
+ var import_react_native5 = require("react-native");
417
+ var import_react_native_paper2 = require("react-native-paper");
418
+ var import_react_native_reanimated5 = __toESM(require("react-native-reanimated"));
419
+ var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
420
+ var import_jsx_runtime4 = require("react/jsx-runtime");
421
+ var DOT_FULL = 8;
422
+ var DOT_SMALL = 3;
423
+ var DOT_GAP = 6;
424
+ var DOT_STEP = DOT_FULL + DOT_GAP;
425
+ var CLIP_COUNT = 5;
426
+ var CLIP_WIDTH = CLIP_COUNT * DOT_STEP - DOT_GAP;
427
+ var PILL_PAD_H = 10;
428
+ var PILL_PAD_V = 6;
429
+ var PILL_HEIGHT = DOT_FULL + PILL_PAD_V * 2;
430
+ var PILL_RADIUS = PILL_HEIGHT / 2;
431
+ var PILL_WIDTH = CLIP_WIDTH + PILL_PAD_H * 2;
432
+ var Dot = ({ activeColor, index, inactiveColor, pageWidth, scrollPosition }) => {
433
+ const circleStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => {
434
+ const page = scrollPosition.value / pageWidth;
435
+ const distance = Math.abs(index - page);
436
+ const t = Math.max(0, Math.min((distance - 0.5) / 2, 1));
437
+ const size = DOT_FULL + (DOT_SMALL - DOT_FULL) * t;
438
+ const backgroundColor = (0, import_react_native_reanimated5.interpolateColor)(t, [0, 1], [activeColor, inactiveColor]);
439
+ return { backgroundColor, borderRadius: size / 2, height: size, width: size };
440
+ });
441
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotContainer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { style: circleStyle }) });
442
+ };
443
+ var HorizontalDots = ({ total }) => {
444
+ const { blur, footerHeightShared, scrollPosition } = (0, import_react7.useContext)(ScrollViewContext);
445
+ const { width } = (0, import_react_native5.useWindowDimensions)();
446
+ const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
447
+ const theme = (0, import_react_native_paper2.useTheme)();
448
+ const insetsBottom = insets.bottom;
449
+ const activeColor = theme.colors.primary;
450
+ const inactiveColor = theme.colors.outlineVariant;
451
+ const pillContainerStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => ({
452
+ bottom: Math.max(footerHeightShared.value, insetsBottom) + 8
453
+ }));
454
+ const rowStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => {
455
+ const page = scrollPosition.value / width;
456
+ const maxOffset = Math.max(0, (total - CLIP_COUNT) * DOT_STEP);
457
+ const offset = Math.max(0, Math.min((page - (CLIP_COUNT - 1) / 2) * DOT_STEP, maxOffset));
458
+ return { transform: [{ translateX: -offset }] };
459
+ });
460
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { pointerEvents: "none", style: [styles3.pillContainer, pillContainerStyle], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native5.View, { style: styles3.pill, children: [
461
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_auto_paper.BlurView, { blur, style: import_react_native5.StyleSheet.absoluteFill }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotsClip, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { style: [styles3.dotsRow, rowStyle], children: Array.from({ length: total }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Dot, { activeColor, index: i, inactiveColor, pageWidth: width, scrollPosition }, i)) }) })
463
+ ] }) });
464
+ };
465
+ var styles3 = import_react_native5.StyleSheet.create({
466
+ dotContainer: { alignItems: "center", height: DOT_FULL, justifyContent: "center", width: DOT_FULL },
467
+ dotsClip: { overflow: "hidden", width: CLIP_WIDTH },
468
+ dotsRow: { flexDirection: "row", gap: DOT_GAP },
469
+ pill: {
470
+ alignItems: "center",
471
+ borderRadius: PILL_RADIUS,
472
+ height: PILL_HEIGHT,
473
+ justifyContent: "center",
474
+ overflow: "hidden",
475
+ width: PILL_WIDTH
476
+ },
477
+ pillContainer: { alignItems: "center", left: 0, position: "absolute", right: 0, zIndex: 3 }
478
+ });
479
+
480
+ // src/FlatList.tsx
481
+ var import_jsx_runtime5 = require("react/jsx-runtime");
482
+ var FlatListInner = ({ contentContainerStyle: externalContentContainerStyle, data, initialNumToRender = 20, maxToRenderPerBatch = 50, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pagingEnabled, pullSearchHeight, removeClippedSubviews = false, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, onContentSizeChange, ref: externalRef, windowSize = 100, ...props }) => {
483
+ const scrollView = (0, import_react8.useRef)(null);
484
+ const isHorizontal = horizontal === true;
485
+ const showDots = isHorizontal && pagingEnabled === true && (data?.length ?? 0) > 1;
486
+ const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style });
487
+ const scrollTo = (0, import_react8.useCallback)((offset, animated) => {
488
+ scrollView.current?.scrollToOffset({ offset, animated });
489
+ }, []);
490
+ const {
491
+ activeListHeader: pullSearchHeader,
492
+ handleMomentumScrollEnd,
493
+ handleScrollBeginDrag,
494
+ handleScrollEndDrag,
495
+ hiddenHeader,
496
+ pullSearchMinHeight
497
+ } = useScrollInit({
498
+ listHeaderComponent: externalListHeaderComponent,
499
+ onMomentumScrollEnd: externalMomentumScrollEnd,
500
+ onRefresh: pullSearchHeight ? onRefresh : void 0,
501
+ onScrollBeginDrag: externalScrollBeginDrag,
502
+ onScrollEndDrag: externalScrollEndDrag,
503
+ pullSearchHeight,
504
+ scrollTo
505
+ });
506
+ const activeListHeader = (0, import_react8.useMemo)(() => {
507
+ if (!renderFilters) return pullSearchHeader;
508
+ const Inner = pullSearchHeader;
509
+ return () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
510
+ Inner ? typeof Inner === "function" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Inner, {}) : Inner : null,
511
+ renderFilters
512
+ ] });
513
+ }, [pullSearchHeader, renderFilters]);
514
+ const contentContainerStyle = (0, import_react8.useMemo)(() => isHorizontal ? externalContentContainerStyle : [{ minHeight: import_react_native6.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [isHorizontal, contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
515
+ const onPullSearchZoneEnter = (0, import_react8.useCallback)(() => {
516
+ if (!pullSearchHeight) return;
517
+ scrollView.current?.scrollToOffset({ offset: -contentInset.top + pullSearchHeight, animated: true });
518
+ }, [contentInset.top, pullSearchHeight]);
519
+ const handleScroll = useScrollHandler({ chipHidden, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
520
+ const handleScrollToTop = (0, import_react8.useCallback)(() => {
521
+ if (isHorizontal) {
522
+ scrollView.current?.scrollToOffset({ offset: 0, animated: true });
523
+ return;
524
+ }
525
+ const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
526
+ scrollView.current?.scrollToOffset({ offset, animated: true });
527
+ }, [isHorizontal, contentInset.top, pullSearchHeight]);
528
+ const handleContentSizeChange = (0, import_react8.useCallback)(
529
+ (w, h) => {
530
+ if (onContentSizeChange) onContentSizeChange(w, h);
531
+ },
532
+ [onContentSizeChange]
533
+ );
534
+ const refreshControl = (0, import_react8.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RefreshControl, {}), []);
535
+ const nativeGesture = (0, import_react8.useMemo)(() => import_react_native_gesture_handler2.Gesture.Native(), []);
536
+ const combinedGesture = (0, import_react8.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler2.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
537
+ const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
538
+ const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native6.View, { style: containerStyle, children: [
539
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
540
+ import_react_native_reanimated6.default.FlatList,
541
+ {
542
+ ...props,
543
+ contentContainerStyle,
544
+ contentInset,
545
+ contentOffset,
546
+ data,
547
+ horizontal: isHorizontal,
548
+ initialNumToRender,
549
+ ListHeaderComponent: activeListHeader,
550
+ maxToRenderPerBatch,
551
+ onContentSizeChange: handleContentSizeChange,
552
+ onMomentumScrollEnd: handleMomentumScrollEnd,
553
+ onScroll: handleScroll,
554
+ onScrollBeginDrag: handleScrollBeginDrag,
555
+ onScrollEndDrag: handleScrollEndDrag,
556
+ pagingEnabled,
557
+ ref: (el) => {
558
+ if (externalRef) externalRef.current = el;
559
+ scrollView.current = el;
560
+ },
561
+ refreshControl,
562
+ removeClippedSubviews,
563
+ scrollEventThrottle: 16,
564
+ showsHorizontalScrollIndicator: showsHorizontalScrollIndicator ?? isHorizontal,
565
+ showsVerticalScrollIndicator: showsVerticalScrollIndicator ?? !isHorizontal,
566
+ windowSize
567
+ }
568
+ ),
569
+ hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native6.View, { pointerEvents: "none", style: styles4.measureContainer, children: hiddenHeader }),
570
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ScrollViewChip, { isHorizontal, onPress: handleScrollToTop, style: chipStyle }),
571
+ showDots && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HorizontalDots, { total: data?.length ?? 0 })
572
+ ] });
573
+ return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture: detectorGesture, children: content }) : content;
574
+ };
575
+ var styles4 = { measureContainer: { left: 0, opacity: 0, position: "absolute", right: 0, top: -9999 } };
576
+ var FlatList = (0, import_react8.memo)(FlatListInner);
577
+
578
+ // src/PullSearch.tsx
579
+ var import_react9 = require("react");
580
+ var import_react_native7 = require("react-native");
581
+ var import_react_native_paper3 = require("react-native-paper");
582
+ var import_react_native_reanimated7 = __toESM(require("react-native-reanimated"));
583
+ var import_jsx_runtime6 = require("react/jsx-runtime");
584
+ var PullSearch = (0, import_react9.forwardRef)(function PullSearch2({ debounce, onChangeText, onHeightChange, placeholder, value: propValue }, ref) {
585
+ const { headerHeight, scrollPosition } = (0, import_react9.useContext)(ScrollViewContext);
586
+ const theme = (0, import_react_native_paper3.useTheme)();
587
+ const inputRef = (0, import_react9.useRef)(null);
588
+ const [barHeight, setBarHeight] = (0, import_react9.useState)(0);
589
+ const [value, setValue] = (0, import_react9.useState)(propValue ?? "");
590
+ const prevPropValueRef = (0, import_react9.useRef)(propValue);
591
+ (0, import_react9.useEffect)(() => {
592
+ if (prevPropValueRef.current === propValue) return;
593
+ prevPropValueRef.current = propValue;
594
+ setValue(propValue ?? "");
595
+ }, [propValue]);
596
+ (0, import_react9.useImperativeHandle)(ref, () => ({
597
+ blur: () => inputRef.current?.blur(),
598
+ focus: () => inputRef.current?.focus()
599
+ }));
600
+ const blurInput = (0, import_react9.useCallback)(() => inputRef.current?.blur(), []);
601
+ (0, import_react_native_reanimated7.useAnimatedReaction)(
602
+ () => {
603
+ if (barHeight === 0) return false;
604
+ return scrollPosition.value >= -headerHeight + barHeight;
605
+ },
606
+ (isHidden, wasHidden) => {
607
+ if (isHidden && !wasHidden) (0, import_react_native_reanimated7.runOnJS)(blurInput)();
608
+ },
609
+ [barHeight, headerHeight, blurInput]
610
+ );
611
+ const handleClear = (0, import_react9.useCallback)(() => {
612
+ setValue("");
613
+ onChangeText("");
614
+ }, [onChangeText]);
615
+ const handleLayout = (0, import_react9.useCallback)(
616
+ ({
617
+ nativeEvent: {
618
+ layout: { height }
619
+ }
620
+ }) => {
621
+ setBarHeight(height);
622
+ onHeightChange(height);
623
+ },
624
+ [onHeightChange]
625
+ );
626
+ (0, import_react9.useEffect)(() => {
627
+ const normalizedValue = value.trim();
628
+ if (debounce) {
629
+ const timeout = setTimeout(() => onChangeText(normalizedValue), 500);
630
+ return () => clearTimeout(timeout);
631
+ }
632
+ onChangeText(normalizedValue);
633
+ }, [debounce, onChangeText, value]);
634
+ const animatedStyle = (0, import_react_native_reanimated7.useAnimatedStyle)(() => {
635
+ if (barHeight === 0) return { opacity: 0 };
636
+ const showY = -headerHeight;
637
+ const hideY = -headerHeight + barHeight;
638
+ return { opacity: (0, import_react_native_reanimated7.interpolate)(scrollPosition.value, [showY, hideY], [1, 0], import_react_native_reanimated7.Extrapolation.CLAMP) };
639
+ }, [barHeight, headerHeight]);
640
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_reanimated7.default.View, { onLayout: handleLayout, style: [styles5.container, animatedStyle], children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper3.Searchbar, { autoCorrect: false, onChangeText: (text) => setValue((text || "").trimStart()), onClearIconPress: handleClear, placeholder, placeholderTextColor: theme.colors.onSurfaceVariant, ref: inputRef, spellCheck: false, style: styles5.input, value }) });
641
+ });
642
+ var styles5 = import_react_native7.StyleSheet.create({
643
+ container: { paddingVertical: 8 },
644
+ input: { margin: 0 }
645
+ });
646
+
647
+ // node_modules/redux/dist/redux.mjs
648
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
649
+ var ActionTypes = {
650
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
651
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
652
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
653
+ };
654
+ function isPlainObject(obj) {
655
+ if (typeof obj !== "object" || obj === null)
656
+ return false;
657
+ let proto = obj;
658
+ while (Object.getPrototypeOf(proto) !== null) {
659
+ proto = Object.getPrototypeOf(proto);
660
+ }
661
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
662
+ }
663
+ function compose(...funcs) {
664
+ if (funcs.length === 0) {
665
+ return (arg) => arg;
666
+ }
667
+ if (funcs.length === 1) {
668
+ return funcs[0];
669
+ }
670
+ return funcs.reduce((a, b) => (...args) => a(b(...args)));
671
+ }
672
+ function isAction(action) {
673
+ return isPlainObject(action) && "type" in action && typeof action.type === "string";
674
+ }
675
+
676
+ // node_modules/immer/dist/immer.mjs
677
+ var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
678
+ var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
679
+ var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
680
+ var errors = process.env.NODE_ENV !== "production" ? [
681
+ // All error codes, starting by 0:
682
+ function(plugin) {
683
+ return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
684
+ },
685
+ function(thing) {
686
+ return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
687
+ },
688
+ "This object has been frozen and should not be mutated",
689
+ function(data) {
690
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
691
+ },
692
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
693
+ "Immer forbids circular references",
694
+ "The first or second argument to `produce` must be a function",
695
+ "The third argument to `produce` must be a function or undefined",
696
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
697
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
698
+ function(thing) {
699
+ return `'current' expects a draft, got: ${thing}`;
700
+ },
701
+ "Object.defineProperty() cannot be used on an Immer draft",
702
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
703
+ "Immer only supports deleting array indices",
704
+ "Immer only supports setting array indices and the 'length' property",
705
+ function(thing) {
706
+ return `'original' expects a draft, got: ${thing}`;
707
+ }
708
+ // Note: if more errors are added, the errorOffset in Patches.ts should be increased
709
+ // See Patches.ts for additional errors
710
+ ] : [];
711
+ function die(error, ...args) {
712
+ if (process.env.NODE_ENV !== "production") {
713
+ const e = errors[error];
714
+ const msg = isFunction(e) ? e.apply(null, args) : e;
715
+ throw new Error(`[Immer] ${msg}`);
716
+ }
717
+ throw new Error(
718
+ `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
719
+ );
720
+ }
721
+ var O = Object;
722
+ var getPrototypeOf = O.getPrototypeOf;
723
+ var CONSTRUCTOR = "constructor";
724
+ var PROTOTYPE = "prototype";
725
+ var CONFIGURABLE = "configurable";
726
+ var ENUMERABLE = "enumerable";
727
+ var WRITABLE = "writable";
728
+ var VALUE = "value";
729
+ var isDraft = (value) => !!value && !!value[DRAFT_STATE];
730
+ function isDraftable(value) {
731
+ if (!value)
732
+ return false;
733
+ return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
734
+ }
735
+ var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
736
+ var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
737
+ function isPlainObject2(value) {
738
+ if (!value || !isObjectish(value))
739
+ return false;
740
+ const proto = getPrototypeOf(value);
741
+ if (proto === null || proto === O[PROTOTYPE])
742
+ return true;
743
+ const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
744
+ if (Ctor === Object)
745
+ return true;
746
+ if (!isFunction(Ctor))
747
+ return false;
748
+ let ctorString = cachedCtorStrings.get(Ctor);
749
+ if (ctorString === void 0) {
750
+ ctorString = Function.toString.call(Ctor);
751
+ cachedCtorStrings.set(Ctor, ctorString);
752
+ }
753
+ return ctorString === objectCtorString;
754
+ }
755
+ function each(obj, iter, strict = true) {
756
+ if (getArchtype(obj) === 0) {
757
+ const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
758
+ keys.forEach((key) => {
759
+ iter(key, obj[key], obj);
760
+ });
761
+ } else {
762
+ obj.forEach((entry, index) => iter(index, entry, obj));
763
+ }
764
+ }
765
+ function getArchtype(thing) {
766
+ const state = thing[DRAFT_STATE];
767
+ return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
768
+ }
769
+ var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
770
+ var get = (thing, prop, type = getArchtype(thing)) => (
771
+ // @ts-ignore
772
+ type === 2 ? thing.get(prop) : thing[prop]
773
+ );
774
+ var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
775
+ if (type === 2)
776
+ thing.set(propOrOldValue, value);
777
+ else if (type === 3) {
778
+ thing.add(value);
779
+ } else
780
+ thing[propOrOldValue] = value;
781
+ };
782
+ function is(x, y) {
783
+ if (x === y) {
784
+ return x !== 0 || 1 / x === 1 / y;
785
+ } else {
786
+ return x !== x && y !== y;
787
+ }
788
+ }
789
+ var isArray = Array.isArray;
790
+ var isMap = (target) => target instanceof Map;
791
+ var isSet = (target) => target instanceof Set;
792
+ var isObjectish = (target) => typeof target === "object";
793
+ var isFunction = (target) => typeof target === "function";
794
+ var isBoolean = (target) => typeof target === "boolean";
795
+ function isArrayIndex(value) {
796
+ const n = +value;
797
+ return Number.isInteger(n) && String(n) === value;
798
+ }
799
+ var latest = (state) => state.copy_ || state.base_;
800
+ var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
801
+ function shallowCopy(base, strict) {
802
+ if (isMap(base)) {
803
+ return new Map(base);
804
+ }
805
+ if (isSet(base)) {
806
+ return new Set(base);
807
+ }
808
+ if (isArray(base))
809
+ return Array[PROTOTYPE].slice.call(base);
810
+ const isPlain = isPlainObject2(base);
811
+ if (strict === true || strict === "class_only" && !isPlain) {
812
+ const descriptors = O.getOwnPropertyDescriptors(base);
813
+ delete descriptors[DRAFT_STATE];
814
+ let keys = Reflect.ownKeys(descriptors);
815
+ for (let i = 0; i < keys.length; i++) {
816
+ const key = keys[i];
817
+ const desc = descriptors[key];
818
+ if (desc[WRITABLE] === false) {
819
+ desc[WRITABLE] = true;
820
+ desc[CONFIGURABLE] = true;
821
+ }
822
+ if (desc.get || desc.set)
823
+ descriptors[key] = {
824
+ [CONFIGURABLE]: true,
825
+ [WRITABLE]: true,
826
+ // could live with !!desc.set as well here...
827
+ [ENUMERABLE]: desc[ENUMERABLE],
828
+ [VALUE]: base[key]
829
+ };
830
+ }
831
+ return O.create(getPrototypeOf(base), descriptors);
832
+ } else {
833
+ const proto = getPrototypeOf(base);
834
+ if (proto !== null && isPlain) {
835
+ return { ...base };
836
+ }
837
+ const obj = O.create(proto);
838
+ return O.assign(obj, base);
839
+ }
840
+ }
841
+ function freeze(obj, deep = false) {
842
+ if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
843
+ return obj;
844
+ if (getArchtype(obj) > 1) {
845
+ O.defineProperties(obj, {
846
+ set: dontMutateMethodOverride,
847
+ add: dontMutateMethodOverride,
848
+ clear: dontMutateMethodOverride,
849
+ delete: dontMutateMethodOverride
850
+ });
851
+ }
852
+ O.freeze(obj);
853
+ if (deep)
854
+ each(
855
+ obj,
856
+ (_key, value) => {
857
+ freeze(value, true);
858
+ },
859
+ false
860
+ );
861
+ return obj;
862
+ }
863
+ function dontMutateFrozenCollections() {
864
+ die(2);
865
+ }
866
+ var dontMutateMethodOverride = {
867
+ [VALUE]: dontMutateFrozenCollections
868
+ };
869
+ function isFrozen(obj) {
870
+ if (obj === null || !isObjectish(obj))
871
+ return true;
872
+ return O.isFrozen(obj);
873
+ }
874
+ var PluginMapSet = "MapSet";
875
+ var PluginPatches = "Patches";
876
+ var PluginArrayMethods = "ArrayMethods";
877
+ var plugins = {};
878
+ function getPlugin(pluginKey) {
879
+ const plugin = plugins[pluginKey];
880
+ if (!plugin) {
881
+ die(0, pluginKey);
882
+ }
883
+ return plugin;
884
+ }
885
+ var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
886
+ var currentScope;
887
+ var getCurrentScope = () => currentScope;
888
+ var createScope = (parent_, immer_) => ({
889
+ drafts_: [],
890
+ parent_,
891
+ immer_,
892
+ // Whenever the modified draft contains a draft from another scope, we
893
+ // need to prevent auto-freezing so the unowned draft can be finalized.
894
+ canAutoFreeze_: true,
895
+ unfinalizedDrafts_: 0,
896
+ handledSet_: /* @__PURE__ */ new Set(),
897
+ processedForPatches_: /* @__PURE__ */ new Set(),
898
+ mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
899
+ arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
900
+ });
901
+ function usePatchesInScope(scope, patchListener) {
902
+ if (patchListener) {
903
+ scope.patchPlugin_ = getPlugin(PluginPatches);
904
+ scope.patches_ = [];
905
+ scope.inversePatches_ = [];
906
+ scope.patchListener_ = patchListener;
907
+ }
908
+ }
909
+ function revokeScope(scope) {
910
+ leaveScope(scope);
911
+ scope.drafts_.forEach(revokeDraft);
912
+ scope.drafts_ = null;
913
+ }
914
+ function leaveScope(scope) {
915
+ if (scope === currentScope) {
916
+ currentScope = scope.parent_;
917
+ }
918
+ }
919
+ var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
920
+ function revokeDraft(draft) {
921
+ const state = draft[DRAFT_STATE];
922
+ if (state.type_ === 0 || state.type_ === 1)
923
+ state.revoke_();
924
+ else
925
+ state.revoked_ = true;
926
+ }
927
+ function processResult(result, scope) {
928
+ scope.unfinalizedDrafts_ = scope.drafts_.length;
929
+ const baseDraft = scope.drafts_[0];
930
+ const isReplaced = result !== void 0 && result !== baseDraft;
931
+ if (isReplaced) {
932
+ if (baseDraft[DRAFT_STATE].modified_) {
933
+ revokeScope(scope);
934
+ die(4);
935
+ }
936
+ if (isDraftable(result)) {
937
+ result = finalize(scope, result);
938
+ }
939
+ const { patchPlugin_ } = scope;
940
+ if (patchPlugin_) {
941
+ patchPlugin_.generateReplacementPatches_(
942
+ baseDraft[DRAFT_STATE].base_,
943
+ result,
944
+ scope
945
+ );
946
+ }
947
+ } else {
948
+ result = finalize(scope, baseDraft);
949
+ }
950
+ maybeFreeze(scope, result, true);
951
+ revokeScope(scope);
952
+ if (scope.patches_) {
953
+ scope.patchListener_(scope.patches_, scope.inversePatches_);
954
+ }
955
+ return result !== NOTHING ? result : void 0;
956
+ }
957
+ function finalize(rootScope, value) {
958
+ if (isFrozen(value))
959
+ return value;
960
+ const state = value[DRAFT_STATE];
961
+ if (!state) {
962
+ const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
963
+ return finalValue;
964
+ }
965
+ if (!isSameScope(state, rootScope)) {
966
+ return value;
967
+ }
968
+ if (!state.modified_) {
969
+ return state.base_;
970
+ }
971
+ if (!state.finalized_) {
972
+ const { callbacks_ } = state;
973
+ if (callbacks_) {
974
+ while (callbacks_.length > 0) {
975
+ const callback = callbacks_.pop();
976
+ callback(rootScope);
977
+ }
978
+ }
979
+ generatePatchesAndFinalize(state, rootScope);
980
+ }
981
+ return state.copy_;
982
+ }
983
+ function maybeFreeze(scope, value, deep = false) {
984
+ if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
985
+ freeze(value, deep);
986
+ }
987
+ }
988
+ function markStateFinalized(state) {
989
+ state.finalized_ = true;
990
+ state.scope_.unfinalizedDrafts_--;
991
+ }
992
+ var isSameScope = (state, rootScope) => state.scope_ === rootScope;
993
+ var EMPTY_LOCATIONS_RESULT = [];
994
+ function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
995
+ const parentCopy = latest(parent);
996
+ const parentType = parent.type_;
997
+ if (originalKey !== void 0) {
998
+ const currentValue = get(parentCopy, originalKey, parentType);
999
+ if (currentValue === draftValue) {
1000
+ set(parentCopy, originalKey, finalizedValue, parentType);
1001
+ return;
1002
+ }
1003
+ }
1004
+ if (!parent.draftLocations_) {
1005
+ const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
1006
+ each(parentCopy, (key, value) => {
1007
+ if (isDraft(value)) {
1008
+ const keys = draftLocations.get(value) || [];
1009
+ keys.push(key);
1010
+ draftLocations.set(value, keys);
1011
+ }
1012
+ });
1013
+ }
1014
+ const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
1015
+ for (const location of locations) {
1016
+ set(parentCopy, location, finalizedValue, parentType);
1017
+ }
1018
+ }
1019
+ function registerChildFinalizationCallback(parent, child, key) {
1020
+ parent.callbacks_.push(function childCleanup(rootScope) {
1021
+ const state = child;
1022
+ if (!state || !isSameScope(state, rootScope)) {
1023
+ return;
1024
+ }
1025
+ rootScope.mapSetPlugin_?.fixSetContents(state);
1026
+ const finalizedValue = getFinalValue(state);
1027
+ updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
1028
+ generatePatchesAndFinalize(state, rootScope);
1029
+ });
1030
+ }
1031
+ function generatePatchesAndFinalize(state, rootScope) {
1032
+ const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
1033
+ if (shouldFinalize) {
1034
+ const { patchPlugin_ } = rootScope;
1035
+ if (patchPlugin_) {
1036
+ const basePath = patchPlugin_.getPath(state);
1037
+ if (basePath) {
1038
+ patchPlugin_.generatePatches_(state, basePath, rootScope);
1039
+ }
1040
+ }
1041
+ markStateFinalized(state);
1042
+ }
1043
+ }
1044
+ function handleCrossReference(target, key, value) {
1045
+ const { scope_ } = target;
1046
+ if (isDraft(value)) {
1047
+ const state = value[DRAFT_STATE];
1048
+ if (isSameScope(state, scope_)) {
1049
+ state.callbacks_.push(function crossReferenceCleanup() {
1050
+ prepareCopy(target);
1051
+ const finalizedValue = getFinalValue(state);
1052
+ updateDraftInParent(target, value, finalizedValue, key);
1053
+ });
1054
+ }
1055
+ } else if (isDraftable(value)) {
1056
+ target.callbacks_.push(function nestedDraftCleanup() {
1057
+ const targetCopy = latest(target);
1058
+ if (target.type_ === 3) {
1059
+ if (targetCopy.has(value)) {
1060
+ handleValue(value, scope_.handledSet_, scope_);
1061
+ }
1062
+ } else {
1063
+ if (get(targetCopy, key, target.type_) === value) {
1064
+ if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
1065
+ handleValue(
1066
+ get(target.copy_, key, target.type_),
1067
+ scope_.handledSet_,
1068
+ scope_
1069
+ );
1070
+ }
1071
+ }
1072
+ }
1073
+ });
1074
+ }
1075
+ }
1076
+ function handleValue(target, handledSet, rootScope) {
1077
+ if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1078
+ return target;
1079
+ }
1080
+ if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1081
+ return target;
1082
+ }
1083
+ handledSet.add(target);
1084
+ each(target, (key, value) => {
1085
+ if (isDraft(value)) {
1086
+ const state = value[DRAFT_STATE];
1087
+ if (isSameScope(state, rootScope)) {
1088
+ const updatedValue = getFinalValue(state);
1089
+ set(target, key, updatedValue, target.type_);
1090
+ markStateFinalized(state);
1091
+ }
1092
+ } else if (isDraftable(value)) {
1093
+ handleValue(value, handledSet, rootScope);
1094
+ }
1095
+ });
1096
+ return target;
1097
+ }
1098
+ function createProxyProxy(base, parent) {
1099
+ const baseIsArray = isArray(base);
1100
+ const state = {
1101
+ type_: baseIsArray ? 1 : 0,
1102
+ // Track which produce call this is associated with.
1103
+ scope_: parent ? parent.scope_ : getCurrentScope(),
1104
+ // True for both shallow and deep changes.
1105
+ modified_: false,
1106
+ // Used during finalization.
1107
+ finalized_: false,
1108
+ // Track which properties have been assigned (true) or deleted (false).
1109
+ // actually instantiated in `prepareCopy()`
1110
+ assigned_: void 0,
1111
+ // The parent draft state.
1112
+ parent_: parent,
1113
+ // The base state.
1114
+ base_: base,
1115
+ // The base proxy.
1116
+ draft_: null,
1117
+ // set below
1118
+ // The base copy with any updated values.
1119
+ copy_: null,
1120
+ // Called by the `produce` function.
1121
+ revoke_: null,
1122
+ isManual_: false,
1123
+ // `callbacks` actually gets assigned in `createProxy`
1124
+ callbacks_: void 0
1125
+ };
1126
+ let target = state;
1127
+ let traps = objectTraps;
1128
+ if (baseIsArray) {
1129
+ target = [state];
1130
+ traps = arrayTraps;
1131
+ }
1132
+ const { revoke, proxy } = Proxy.revocable(target, traps);
1133
+ state.draft_ = proxy;
1134
+ state.revoke_ = revoke;
1135
+ return [proxy, state];
1136
+ }
1137
+ var objectTraps = {
1138
+ get(state, prop) {
1139
+ if (prop === DRAFT_STATE)
1140
+ return state;
1141
+ let arrayPlugin = state.scope_.arrayMethodsPlugin_;
1142
+ const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
1143
+ if (isArrayWithStringProp) {
1144
+ if (arrayPlugin?.isArrayOperationMethod(prop)) {
1145
+ return arrayPlugin.createMethodInterceptor(state, prop);
1146
+ }
1147
+ }
1148
+ const source = latest(state);
1149
+ if (!has(source, prop, state.type_)) {
1150
+ return readPropFromProto(state, source, prop);
1151
+ }
1152
+ const value = source[prop];
1153
+ if (state.finalized_ || !isDraftable(value)) {
1154
+ return value;
1155
+ }
1156
+ if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
1157
+ state.operationMethod
1158
+ ) && isArrayIndex(prop)) {
1159
+ return value;
1160
+ }
1161
+ if (value === peek(state.base_, prop)) {
1162
+ prepareCopy(state);
1163
+ const childKey = state.type_ === 1 ? +prop : prop;
1164
+ const childDraft = createProxy(state.scope_, value, state, childKey);
1165
+ return state.copy_[childKey] = childDraft;
1166
+ }
1167
+ return value;
1168
+ },
1169
+ has(state, prop) {
1170
+ return prop in latest(state);
1171
+ },
1172
+ ownKeys(state) {
1173
+ return Reflect.ownKeys(latest(state));
1174
+ },
1175
+ set(state, prop, value) {
1176
+ const desc = getDescriptorFromProto(latest(state), prop);
1177
+ if (desc?.set) {
1178
+ desc.set.call(state.draft_, value);
1179
+ return true;
1180
+ }
1181
+ if (!state.modified_) {
1182
+ const current2 = peek(latest(state), prop);
1183
+ const currentState = current2?.[DRAFT_STATE];
1184
+ if (currentState && currentState.base_ === value) {
1185
+ state.copy_[prop] = value;
1186
+ state.assigned_.set(prop, false);
1187
+ return true;
1188
+ }
1189
+ if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
1190
+ return true;
1191
+ prepareCopy(state);
1192
+ markChanged(state);
1193
+ }
1194
+ if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
1195
+ (value !== void 0 || prop in state.copy_) || // special case: NaN
1196
+ Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
1197
+ return true;
1198
+ state.copy_[prop] = value;
1199
+ state.assigned_.set(prop, true);
1200
+ handleCrossReference(state, prop, value);
1201
+ return true;
1202
+ },
1203
+ deleteProperty(state, prop) {
1204
+ prepareCopy(state);
1205
+ if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
1206
+ state.assigned_.set(prop, false);
1207
+ markChanged(state);
1208
+ } else {
1209
+ state.assigned_.delete(prop);
1210
+ }
1211
+ if (state.copy_) {
1212
+ delete state.copy_[prop];
1213
+ }
1214
+ return true;
1215
+ },
1216
+ // Note: We never coerce `desc.value` into an Immer draft, because we can't make
1217
+ // the same guarantee in ES5 mode.
1218
+ getOwnPropertyDescriptor(state, prop) {
1219
+ const owner = latest(state);
1220
+ const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
1221
+ if (!desc)
1222
+ return desc;
1223
+ return {
1224
+ [WRITABLE]: true,
1225
+ [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
1226
+ [ENUMERABLE]: desc[ENUMERABLE],
1227
+ [VALUE]: owner[prop]
1228
+ };
1229
+ },
1230
+ defineProperty() {
1231
+ die(11);
1232
+ },
1233
+ getPrototypeOf(state) {
1234
+ return getPrototypeOf(state.base_);
1235
+ },
1236
+ setPrototypeOf() {
1237
+ die(12);
1238
+ }
1239
+ };
1240
+ var arrayTraps = {};
1241
+ for (let key in objectTraps) {
1242
+ let fn = objectTraps[key];
1243
+ arrayTraps[key] = function() {
1244
+ const args = arguments;
1245
+ args[0] = args[0][0];
1246
+ return fn.apply(this, args);
1247
+ };
1248
+ }
1249
+ arrayTraps.deleteProperty = function(state, prop) {
1250
+ if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
1251
+ die(13);
1252
+ return arrayTraps.set.call(this, state, prop, void 0);
1253
+ };
1254
+ arrayTraps.set = function(state, prop, value) {
1255
+ if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
1256
+ die(14);
1257
+ return objectTraps.set.call(this, state[0], prop, value, state[0]);
1258
+ };
1259
+ function peek(draft, prop) {
1260
+ const state = draft[DRAFT_STATE];
1261
+ const source = state ? latest(state) : draft;
1262
+ return source[prop];
1263
+ }
1264
+ function readPropFromProto(state, source, prop) {
1265
+ const desc = getDescriptorFromProto(source, prop);
1266
+ return desc ? VALUE in desc ? desc[VALUE] : (
1267
+ // This is a very special case, if the prop is a getter defined by the
1268
+ // prototype, we should invoke it with the draft as context!
1269
+ desc.get?.call(state.draft_)
1270
+ ) : void 0;
1271
+ }
1272
+ function getDescriptorFromProto(source, prop) {
1273
+ if (!(prop in source))
1274
+ return void 0;
1275
+ let proto = getPrototypeOf(source);
1276
+ while (proto) {
1277
+ const desc = Object.getOwnPropertyDescriptor(proto, prop);
1278
+ if (desc)
1279
+ return desc;
1280
+ proto = getPrototypeOf(proto);
1281
+ }
1282
+ return void 0;
1283
+ }
1284
+ function markChanged(state) {
1285
+ if (!state.modified_) {
1286
+ state.modified_ = true;
1287
+ if (state.parent_) {
1288
+ markChanged(state.parent_);
1289
+ }
1290
+ }
1291
+ }
1292
+ function prepareCopy(state) {
1293
+ if (!state.copy_) {
1294
+ state.assigned_ = /* @__PURE__ */ new Map();
1295
+ state.copy_ = shallowCopy(
1296
+ state.base_,
1297
+ state.scope_.immer_.useStrictShallowCopy_
1298
+ );
1299
+ }
1300
+ }
1301
+ var Immer2 = class {
1302
+ constructor(config) {
1303
+ this.autoFreeze_ = true;
1304
+ this.useStrictShallowCopy_ = false;
1305
+ this.useStrictIteration_ = false;
1306
+ this.produce = (base, recipe, patchListener) => {
1307
+ if (isFunction(base) && !isFunction(recipe)) {
1308
+ const defaultBase = recipe;
1309
+ recipe = base;
1310
+ const self = this;
1311
+ return function curriedProduce(base2 = defaultBase, ...args) {
1312
+ return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
1313
+ };
1314
+ }
1315
+ if (!isFunction(recipe))
1316
+ die(6);
1317
+ if (patchListener !== void 0 && !isFunction(patchListener))
1318
+ die(7);
1319
+ let result;
1320
+ if (isDraftable(base)) {
1321
+ const scope = enterScope(this);
1322
+ const proxy = createProxy(scope, base, void 0);
1323
+ let hasError = true;
1324
+ try {
1325
+ result = recipe(proxy);
1326
+ hasError = false;
1327
+ } finally {
1328
+ if (hasError)
1329
+ revokeScope(scope);
1330
+ else
1331
+ leaveScope(scope);
1332
+ }
1333
+ usePatchesInScope(scope, patchListener);
1334
+ return processResult(result, scope);
1335
+ } else if (!base || !isObjectish(base)) {
1336
+ result = recipe(base);
1337
+ if (result === void 0)
1338
+ result = base;
1339
+ if (result === NOTHING)
1340
+ result = void 0;
1341
+ if (this.autoFreeze_)
1342
+ freeze(result, true);
1343
+ if (patchListener) {
1344
+ const p = [];
1345
+ const ip = [];
1346
+ getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
1347
+ patches_: p,
1348
+ inversePatches_: ip
1349
+ });
1350
+ patchListener(p, ip);
1351
+ }
1352
+ return result;
1353
+ } else
1354
+ die(1, base);
1355
+ };
1356
+ this.produceWithPatches = (base, recipe) => {
1357
+ if (isFunction(base)) {
1358
+ return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
1359
+ }
1360
+ let patches, inversePatches;
1361
+ const result = this.produce(base, recipe, (p, ip) => {
1362
+ patches = p;
1363
+ inversePatches = ip;
1364
+ });
1365
+ return [result, patches, inversePatches];
1366
+ };
1367
+ if (isBoolean(config?.autoFreeze))
1368
+ this.setAutoFreeze(config.autoFreeze);
1369
+ if (isBoolean(config?.useStrictShallowCopy))
1370
+ this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1371
+ if (isBoolean(config?.useStrictIteration))
1372
+ this.setUseStrictIteration(config.useStrictIteration);
1373
+ }
1374
+ createDraft(base) {
1375
+ if (!isDraftable(base))
1376
+ die(8);
1377
+ if (isDraft(base))
1378
+ base = current(base);
1379
+ const scope = enterScope(this);
1380
+ const proxy = createProxy(scope, base, void 0);
1381
+ proxy[DRAFT_STATE].isManual_ = true;
1382
+ leaveScope(scope);
1383
+ return proxy;
1384
+ }
1385
+ finishDraft(draft, patchListener) {
1386
+ const state = draft && draft[DRAFT_STATE];
1387
+ if (!state || !state.isManual_)
1388
+ die(9);
1389
+ const { scope_: scope } = state;
1390
+ usePatchesInScope(scope, patchListener);
1391
+ return processResult(void 0, scope);
1392
+ }
1393
+ /**
1394
+ * Pass true to automatically freeze all copies created by Immer.
1395
+ *
1396
+ * By default, auto-freezing is enabled.
1397
+ */
1398
+ setAutoFreeze(value) {
1399
+ this.autoFreeze_ = value;
1400
+ }
1401
+ /**
1402
+ * Pass true to enable strict shallow copy.
1403
+ *
1404
+ * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1405
+ */
1406
+ setUseStrictShallowCopy(value) {
1407
+ this.useStrictShallowCopy_ = value;
1408
+ }
1409
+ /**
1410
+ * Pass false to use faster iteration that skips non-enumerable properties
1411
+ * but still handles symbols for compatibility.
1412
+ *
1413
+ * By default, strict iteration is enabled (includes all own properties).
1414
+ */
1415
+ setUseStrictIteration(value) {
1416
+ this.useStrictIteration_ = value;
1417
+ }
1418
+ shouldUseStrictIteration() {
1419
+ return this.useStrictIteration_;
1420
+ }
1421
+ applyPatches(base, patches) {
1422
+ let i;
1423
+ for (i = patches.length - 1; i >= 0; i--) {
1424
+ const patch = patches[i];
1425
+ if (patch.path.length === 0 && patch.op === "replace") {
1426
+ base = patch.value;
1427
+ break;
1428
+ }
1429
+ }
1430
+ if (i > -1) {
1431
+ patches = patches.slice(i + 1);
1432
+ }
1433
+ const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
1434
+ if (isDraft(base)) {
1435
+ return applyPatchesImpl(base, patches);
1436
+ }
1437
+ return this.produce(
1438
+ base,
1439
+ (draft) => applyPatchesImpl(draft, patches)
1440
+ );
1441
+ }
1442
+ };
1443
+ function createProxy(rootScope, value, parent, key) {
1444
+ const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
1445
+ const scope = parent?.scope_ ?? getCurrentScope();
1446
+ scope.drafts_.push(draft);
1447
+ state.callbacks_ = parent?.callbacks_ ?? [];
1448
+ state.key_ = key;
1449
+ if (parent && key !== void 0) {
1450
+ registerChildFinalizationCallback(parent, state, key);
1451
+ } else {
1452
+ state.callbacks_.push(function rootDraftCleanup(rootScope2) {
1453
+ rootScope2.mapSetPlugin_?.fixSetContents(state);
1454
+ const { patchPlugin_ } = rootScope2;
1455
+ if (state.modified_ && patchPlugin_) {
1456
+ patchPlugin_.generatePatches_(state, [], rootScope2);
1457
+ }
1458
+ });
1459
+ }
1460
+ return draft;
1461
+ }
1462
+ function current(value) {
1463
+ if (!isDraft(value))
1464
+ die(10, value);
1465
+ return currentImpl(value);
1466
+ }
1467
+ function currentImpl(value) {
1468
+ if (!isDraftable(value) || isFrozen(value))
1469
+ return value;
1470
+ const state = value[DRAFT_STATE];
1471
+ let copy;
1472
+ let strict = true;
1473
+ if (state) {
1474
+ if (!state.modified_)
1475
+ return state.base_;
1476
+ state.finalized_ = true;
1477
+ copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
1478
+ strict = state.scope_.immer_.shouldUseStrictIteration();
1479
+ } else {
1480
+ copy = shallowCopy(value, true);
1481
+ }
1482
+ each(
1483
+ copy,
1484
+ (key, childValue) => {
1485
+ set(copy, key, currentImpl(childValue));
1486
+ },
1487
+ strict
1488
+ );
1489
+ if (state) {
1490
+ state.finalized_ = false;
1491
+ }
1492
+ return copy;
1493
+ }
1494
+ var immer = new Immer2();
1495
+ var produce = immer.produce;
1496
+
1497
+ // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
1498
+ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
1499
+ if (arguments.length === 0) return void 0;
1500
+ if (typeof arguments[0] === "object") return compose;
1501
+ return compose.apply(null, arguments);
1502
+ };
1503
+ var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
1504
+ return function(noop3) {
1505
+ return noop3;
1506
+ };
1507
+ };
1508
+ var hasMatchFunction = (v) => {
1509
+ return v && typeof v.match === "function";
1510
+ };
1511
+ function createAction(type, prepareAction) {
1512
+ function actionCreator(...args) {
1513
+ if (prepareAction) {
1514
+ let prepared = prepareAction(...args);
1515
+ if (!prepared) {
1516
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1517
+ }
1518
+ return {
1519
+ type,
1520
+ payload: prepared.payload,
1521
+ ..."meta" in prepared && {
1522
+ meta: prepared.meta
1523
+ },
1524
+ ..."error" in prepared && {
1525
+ error: prepared.error
1526
+ }
1527
+ };
1528
+ }
1529
+ return {
1530
+ type,
1531
+ payload: args[0]
1532
+ };
1533
+ }
1534
+ actionCreator.toString = () => `${type}`;
1535
+ actionCreator.type = type;
1536
+ actionCreator.match = (action) => isAction(action) && action.type === type;
1537
+ return actionCreator;
1538
+ }
1539
+ function freezeDraftable(val) {
1540
+ return isDraftable(val) ? produce(val, () => {
1541
+ }) : val;
1542
+ }
1543
+ function getOrInsertComputed(map, key, compute) {
1544
+ if (map.has(key)) return map.get(key);
1545
+ return map.set(key, compute(key)).get(key);
1546
+ }
1547
+ function executeReducerBuilderCallback(builderCallback) {
1548
+ const actionsMap = {};
1549
+ const actionMatchers = [];
1550
+ let defaultCaseReducer;
1551
+ const builder = {
1552
+ addCase(typeOrActionCreator, reducer) {
1553
+ if (process.env.NODE_ENV !== "production") {
1554
+ if (actionMatchers.length > 0) {
1555
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
1556
+ }
1557
+ if (defaultCaseReducer) {
1558
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1559
+ }
1560
+ }
1561
+ const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1562
+ if (!type) {
1563
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
1564
+ }
1565
+ if (type in actionsMap) {
1566
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
1567
+ }
1568
+ actionsMap[type] = reducer;
1569
+ return builder;
1570
+ },
1571
+ addAsyncThunk(asyncThunk, reducers) {
1572
+ if (process.env.NODE_ENV !== "production") {
1573
+ if (defaultCaseReducer) {
1574
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
1575
+ }
1576
+ }
1577
+ if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
1578
+ if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
1579
+ if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
1580
+ if (reducers.settled) actionMatchers.push({
1581
+ matcher: asyncThunk.settled,
1582
+ reducer: reducers.settled
1583
+ });
1584
+ return builder;
1585
+ },
1586
+ addMatcher(matcher, reducer) {
1587
+ if (process.env.NODE_ENV !== "production") {
1588
+ if (defaultCaseReducer) {
1589
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1590
+ }
1591
+ }
1592
+ actionMatchers.push({
1593
+ matcher,
1594
+ reducer
1595
+ });
1596
+ return builder;
1597
+ },
1598
+ addDefaultCase(reducer) {
1599
+ if (process.env.NODE_ENV !== "production") {
1600
+ if (defaultCaseReducer) {
1601
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1602
+ }
1603
+ }
1604
+ defaultCaseReducer = reducer;
1605
+ return builder;
1606
+ }
1607
+ };
1608
+ builderCallback(builder);
1609
+ return [actionsMap, actionMatchers, defaultCaseReducer];
1610
+ }
1611
+ function isStateFunction(x) {
1612
+ return typeof x === "function";
1613
+ }
1614
+ function createReducer(initialState, mapOrBuilderCallback) {
1615
+ if (process.env.NODE_ENV !== "production") {
1616
+ if (typeof mapOrBuilderCallback === "object") {
1617
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
1618
+ }
1619
+ }
1620
+ let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1621
+ let getInitialState;
1622
+ if (isStateFunction(initialState)) {
1623
+ getInitialState = () => freezeDraftable(initialState());
1624
+ } else {
1625
+ const frozenInitialState = freezeDraftable(initialState);
1626
+ getInitialState = () => frozenInitialState;
1627
+ }
1628
+ function reducer(state = getInitialState(), action) {
1629
+ let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1630
+ matcher
1631
+ }) => matcher(action)).map(({
1632
+ reducer: reducer2
1633
+ }) => reducer2)];
1634
+ if (caseReducers.filter((cr) => !!cr).length === 0) {
1635
+ caseReducers = [finalDefaultCaseReducer];
1636
+ }
1637
+ return caseReducers.reduce((previousState, caseReducer) => {
1638
+ if (caseReducer) {
1639
+ if (isDraft(previousState)) {
1640
+ const draft = previousState;
1641
+ const result = caseReducer(draft, action);
1642
+ if (result === void 0) {
1643
+ return previousState;
1644
+ }
1645
+ return result;
1646
+ } else if (!isDraftable(previousState)) {
1647
+ const result = caseReducer(previousState, action);
1648
+ if (result === void 0) {
1649
+ if (previousState === null) {
1650
+ return previousState;
1651
+ }
1652
+ throw Error("A case reducer on a non-draftable value must not return undefined");
1653
+ }
1654
+ return result;
1655
+ } else {
1656
+ return produce(previousState, (draft) => {
1657
+ return caseReducer(draft, action);
1658
+ });
1659
+ }
1660
+ }
1661
+ return previousState;
1662
+ }, state);
1663
+ }
1664
+ reducer.getInitialState = getInitialState;
1665
+ return reducer;
1666
+ }
1667
+ var matches = (matcher, action) => {
1668
+ if (hasMatchFunction(matcher)) {
1669
+ return matcher.match(action);
1670
+ } else {
1671
+ return matcher(action);
1672
+ }
1673
+ };
1674
+ function isAnyOf(...matchers) {
1675
+ return (action) => {
1676
+ return matchers.some((matcher) => matches(matcher, action));
1677
+ };
1678
+ }
1679
+ var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1680
+ var nanoid = (size = 21) => {
1681
+ let id = "";
1682
+ let i = size;
1683
+ while (i--) {
1684
+ id += urlAlphabet[Math.random() * 64 | 0];
1685
+ }
1686
+ return id;
1687
+ };
1688
+ var commonProperties = ["name", "message", "stack", "code"];
1689
+ var RejectWithValue = class {
1690
+ constructor(payload, meta) {
1691
+ __publicField(this, "payload");
1692
+ __publicField(this, "meta");
1693
+ /*
1694
+ type-only property to distinguish between RejectWithValue and FulfillWithMeta
1695
+ does not exist at runtime
1696
+ */
1697
+ __publicField(this, "_type");
1698
+ this.payload = payload;
1699
+ this.meta = meta;
1700
+ }
1701
+ };
1702
+ var FulfillWithMeta = class {
1703
+ constructor(payload, meta) {
1704
+ __publicField(this, "payload");
1705
+ __publicField(this, "meta");
1706
+ /*
1707
+ type-only property to distinguish between RejectWithValue and FulfillWithMeta
1708
+ does not exist at runtime
1709
+ */
1710
+ __publicField(this, "_type");
1711
+ this.payload = payload;
1712
+ this.meta = meta;
1713
+ }
1714
+ };
1715
+ var miniSerializeError = (value) => {
1716
+ if (typeof value === "object" && value !== null) {
1717
+ const simpleError = {};
1718
+ for (const property of commonProperties) {
1719
+ if (typeof value[property] === "string") {
1720
+ simpleError[property] = value[property];
1721
+ }
1722
+ }
1723
+ return simpleError;
1724
+ }
1725
+ return {
1726
+ message: String(value)
1727
+ };
1728
+ };
1729
+ var externalAbortMessage = "External signal was aborted";
1730
+ var createAsyncThunk = /* @__PURE__ */ (() => {
1731
+ function createAsyncThunk2(typePrefix, payloadCreator, options) {
1732
+ const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1733
+ payload,
1734
+ meta: {
1735
+ ...meta || {},
1736
+ arg,
1737
+ requestId,
1738
+ requestStatus: "fulfilled"
1739
+ }
1740
+ }));
1741
+ const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1742
+ payload: void 0,
1743
+ meta: {
1744
+ ...meta || {},
1745
+ arg,
1746
+ requestId,
1747
+ requestStatus: "pending"
1748
+ }
1749
+ }));
1750
+ const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1751
+ payload,
1752
+ error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1753
+ meta: {
1754
+ ...meta || {},
1755
+ arg,
1756
+ requestId,
1757
+ rejectedWithValue: !!payload,
1758
+ requestStatus: "rejected",
1759
+ aborted: error?.name === "AbortError",
1760
+ condition: error?.name === "ConditionError"
1761
+ }
1762
+ }));
1763
+ function actionCreator(arg, {
1764
+ signal
1765
+ } = {}) {
1766
+ return (dispatch, getState, extra) => {
1767
+ const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1768
+ const abortController = new AbortController();
1769
+ let abortHandler;
1770
+ let abortReason;
1771
+ function abort(reason) {
1772
+ abortReason = reason;
1773
+ abortController.abort();
1774
+ }
1775
+ if (signal) {
1776
+ if (signal.aborted) {
1777
+ abort(externalAbortMessage);
1778
+ } else {
1779
+ signal.addEventListener("abort", () => abort(externalAbortMessage), {
1780
+ once: true
1781
+ });
1782
+ }
1783
+ }
1784
+ const promise = (async function() {
1785
+ let finalAction;
1786
+ try {
1787
+ let conditionResult = options?.condition?.(arg, {
1788
+ getState,
1789
+ extra
1790
+ });
1791
+ if (isThenable(conditionResult)) {
1792
+ conditionResult = await conditionResult;
1793
+ }
1794
+ if (conditionResult === false || abortController.signal.aborted) {
1795
+ throw {
1796
+ name: "ConditionError",
1797
+ message: "Aborted due to condition callback returning false."
1798
+ };
1799
+ }
1800
+ const abortedPromise = new Promise((_, reject) => {
1801
+ abortHandler = () => {
1802
+ reject({
1803
+ name: "AbortError",
1804
+ message: abortReason || "Aborted"
1805
+ });
1806
+ };
1807
+ abortController.signal.addEventListener("abort", abortHandler, {
1808
+ once: true
1809
+ });
1810
+ });
1811
+ dispatch(pending(requestId, arg, options?.getPendingMeta?.({
1812
+ requestId,
1813
+ arg
1814
+ }, {
1815
+ getState,
1816
+ extra
1817
+ })));
1818
+ finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
1819
+ dispatch,
1820
+ getState,
1821
+ extra,
1822
+ requestId,
1823
+ signal: abortController.signal,
1824
+ abort,
1825
+ rejectWithValue: ((value, meta) => {
1826
+ return new RejectWithValue(value, meta);
1827
+ }),
1828
+ fulfillWithValue: ((value, meta) => {
1829
+ return new FulfillWithMeta(value, meta);
1830
+ })
1831
+ })).then((result) => {
1832
+ if (result instanceof RejectWithValue) {
1833
+ throw result;
1834
+ }
1835
+ if (result instanceof FulfillWithMeta) {
1836
+ return fulfilled(result.payload, requestId, arg, result.meta);
1837
+ }
1838
+ return fulfilled(result, requestId, arg);
1839
+ })]);
1840
+ } catch (err) {
1841
+ finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
1842
+ } finally {
1843
+ if (abortHandler) {
1844
+ abortController.signal.removeEventListener("abort", abortHandler);
1845
+ }
1846
+ }
1847
+ const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1848
+ if (!skipDispatch) {
1849
+ dispatch(finalAction);
1850
+ }
1851
+ return finalAction;
1852
+ })();
1853
+ return Object.assign(promise, {
1854
+ abort,
1855
+ requestId,
1856
+ arg,
1857
+ unwrap() {
1858
+ return promise.then(unwrapResult);
1859
+ }
1860
+ });
1861
+ };
1862
+ }
1863
+ return Object.assign(actionCreator, {
1864
+ pending,
1865
+ rejected,
1866
+ fulfilled,
1867
+ settled: isAnyOf(rejected, fulfilled),
1868
+ typePrefix
1869
+ });
1870
+ }
1871
+ createAsyncThunk2.withTypes = () => createAsyncThunk2;
1872
+ return createAsyncThunk2;
1873
+ })();
1874
+ function unwrapResult(action) {
1875
+ if (action.meta && action.meta.rejectedWithValue) {
1876
+ throw action.payload;
1877
+ }
1878
+ if (action.error) {
1879
+ throw action.error;
1880
+ }
1881
+ return action.payload;
1882
+ }
1883
+ function isThenable(value) {
1884
+ return value !== null && typeof value === "object" && typeof value.then === "function";
1885
+ }
1886
+ var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
1887
+ var asyncThunkCreator = {
1888
+ [asyncThunkSymbol]: createAsyncThunk
1889
+ };
1890
+ function getType(slice2, actionKey) {
1891
+ return `${slice2}/${actionKey}`;
1892
+ }
1893
+ function buildCreateSlice({
1894
+ creators
1895
+ } = {}) {
1896
+ const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
1897
+ return function createSlice2(options) {
1898
+ const {
1899
+ name,
1900
+ reducerPath = name
1901
+ } = options;
1902
+ if (!name) {
1903
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
1904
+ }
1905
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
1906
+ if (options.initialState === void 0) {
1907
+ console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
1908
+ }
1909
+ }
1910
+ const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1911
+ const reducerNames = Object.keys(reducers);
1912
+ const context = {
1913
+ sliceCaseReducersByName: {},
1914
+ sliceCaseReducersByType: {},
1915
+ actionCreators: {},
1916
+ sliceMatchers: []
1917
+ };
1918
+ const contextMethods = {
1919
+ addCase(typeOrActionCreator, reducer2) {
1920
+ const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1921
+ if (!type) {
1922
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
1923
+ }
1924
+ if (type in context.sliceCaseReducersByType) {
1925
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
1926
+ }
1927
+ context.sliceCaseReducersByType[type] = reducer2;
1928
+ return contextMethods;
1929
+ },
1930
+ addMatcher(matcher, reducer2) {
1931
+ context.sliceMatchers.push({
1932
+ matcher,
1933
+ reducer: reducer2
1934
+ });
1935
+ return contextMethods;
1936
+ },
1937
+ exposeAction(name2, actionCreator) {
1938
+ context.actionCreators[name2] = actionCreator;
1939
+ return contextMethods;
1940
+ },
1941
+ exposeCaseReducer(name2, reducer2) {
1942
+ context.sliceCaseReducersByName[name2] = reducer2;
1943
+ return contextMethods;
1944
+ }
1945
+ };
1946
+ reducerNames.forEach((reducerName) => {
1947
+ const reducerDefinition = reducers[reducerName];
1948
+ const reducerDetails = {
1949
+ reducerName,
1950
+ type: getType(name, reducerName),
1951
+ createNotation: typeof options.reducers === "function"
1952
+ };
1953
+ if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
1954
+ handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
1955
+ } else {
1956
+ handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
1957
+ }
1958
+ });
1959
+ function buildReducer() {
1960
+ if (process.env.NODE_ENV !== "production") {
1961
+ if (typeof options.extraReducers === "object") {
1962
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
1963
+ }
1964
+ }
1965
+ const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
1966
+ const finalCaseReducers = {
1967
+ ...extraReducers,
1968
+ ...context.sliceCaseReducersByType
1969
+ };
1970
+ return createReducer(options.initialState, (builder) => {
1971
+ for (let key in finalCaseReducers) {
1972
+ builder.addCase(key, finalCaseReducers[key]);
1973
+ }
1974
+ for (let sM of context.sliceMatchers) {
1975
+ builder.addMatcher(sM.matcher, sM.reducer);
1976
+ }
1977
+ for (let m of actionMatchers) {
1978
+ builder.addMatcher(m.matcher, m.reducer);
1979
+ }
1980
+ if (defaultCaseReducer) {
1981
+ builder.addDefaultCase(defaultCaseReducer);
1982
+ }
1983
+ });
1984
+ }
1985
+ const selectSelf = (state) => state;
1986
+ const injectedSelectorCache = /* @__PURE__ */ new Map();
1987
+ const injectedStateCache = /* @__PURE__ */ new WeakMap();
1988
+ let _reducer;
1989
+ function reducer(state, action) {
1990
+ if (!_reducer) _reducer = buildReducer();
1991
+ return _reducer(state, action);
1992
+ }
1993
+ function getInitialState() {
1994
+ if (!_reducer) _reducer = buildReducer();
1995
+ return _reducer.getInitialState();
1996
+ }
1997
+ function makeSelectorProps(reducerPath2, injected = false) {
1998
+ function selectSlice(state) {
1999
+ let sliceState = state[reducerPath2];
2000
+ if (typeof sliceState === "undefined") {
2001
+ if (injected) {
2002
+ sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
2003
+ } else if (process.env.NODE_ENV !== "production") {
2004
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
2005
+ }
2006
+ }
2007
+ return sliceState;
2008
+ }
2009
+ function getSelectors(selectState = selectSelf) {
2010
+ const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
2011
+ return getOrInsertComputed(selectorCache, selectState, () => {
2012
+ const map = {};
2013
+ for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
2014
+ map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
2015
+ }
2016
+ return map;
2017
+ });
2018
+ }
2019
+ return {
2020
+ reducerPath: reducerPath2,
2021
+ getSelectors,
2022
+ get selectors() {
2023
+ return getSelectors(selectSlice);
2024
+ },
2025
+ selectSlice
2026
+ };
2027
+ }
2028
+ const slice2 = {
2029
+ name,
2030
+ reducer,
2031
+ actions: context.actionCreators,
2032
+ caseReducers: context.sliceCaseReducersByName,
2033
+ getInitialState,
2034
+ ...makeSelectorProps(reducerPath),
2035
+ injectInto(injectable, {
2036
+ reducerPath: pathOpt,
2037
+ ...config
2038
+ } = {}) {
2039
+ const newReducerPath = pathOpt ?? reducerPath;
2040
+ injectable.inject({
2041
+ reducerPath: newReducerPath,
2042
+ reducer
2043
+ }, config);
2044
+ return {
2045
+ ...slice2,
2046
+ ...makeSelectorProps(newReducerPath, true)
2047
+ };
2048
+ }
2049
+ };
2050
+ return slice2;
2051
+ };
2052
+ }
2053
+ function wrapSelector(selector, selectState, getInitialState, injected) {
2054
+ function wrapper(rootState, ...args) {
2055
+ let sliceState = selectState(rootState);
2056
+ if (typeof sliceState === "undefined") {
2057
+ if (injected) {
2058
+ sliceState = getInitialState();
2059
+ } else if (process.env.NODE_ENV !== "production") {
2060
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
2061
+ }
2062
+ }
2063
+ return selector(sliceState, ...args);
2064
+ }
2065
+ wrapper.unwrapped = selector;
2066
+ return wrapper;
2067
+ }
2068
+ var createSlice = /* @__PURE__ */ buildCreateSlice();
2069
+ function buildReducerCreators() {
2070
+ function asyncThunk(payloadCreator, config) {
2071
+ return {
2072
+ _reducerDefinitionType: "asyncThunk",
2073
+ payloadCreator,
2074
+ ...config
2075
+ };
2076
+ }
2077
+ asyncThunk.withTypes = () => asyncThunk;
2078
+ return {
2079
+ reducer(caseReducer) {
2080
+ return Object.assign({
2081
+ // hack so the wrapping function has the same name as the original
2082
+ // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
2083
+ [caseReducer.name](...args) {
2084
+ return caseReducer(...args);
2085
+ }
2086
+ }[caseReducer.name], {
2087
+ _reducerDefinitionType: "reducer"
2088
+ /* reducer */
2089
+ });
2090
+ },
2091
+ preparedReducer(prepare, reducer) {
2092
+ return {
2093
+ _reducerDefinitionType: "reducerWithPrepare",
2094
+ prepare,
2095
+ reducer
2096
+ };
2097
+ },
2098
+ asyncThunk
2099
+ };
2100
+ }
2101
+ function handleNormalReducerDefinition({
2102
+ type,
2103
+ reducerName,
2104
+ createNotation
2105
+ }, maybeReducerWithPrepare, context) {
2106
+ let caseReducer;
2107
+ let prepareCallback;
2108
+ if ("reducer" in maybeReducerWithPrepare) {
2109
+ if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
2110
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
2111
+ }
2112
+ caseReducer = maybeReducerWithPrepare.reducer;
2113
+ prepareCallback = maybeReducerWithPrepare.prepare;
2114
+ } else {
2115
+ caseReducer = maybeReducerWithPrepare;
2116
+ }
2117
+ context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
2118
+ }
2119
+ function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
2120
+ return reducerDefinition._reducerDefinitionType === "asyncThunk";
2121
+ }
2122
+ function isCaseReducerWithPrepareDefinition(reducerDefinition) {
2123
+ return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
2124
+ }
2125
+ function handleThunkCaseReducerDefinition({
2126
+ type,
2127
+ reducerName
2128
+ }, reducerDefinition, context, cAT) {
2129
+ if (!cAT) {
2130
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
2131
+ }
2132
+ const {
2133
+ payloadCreator,
2134
+ fulfilled,
2135
+ pending,
2136
+ rejected,
2137
+ settled,
2138
+ options
2139
+ } = reducerDefinition;
2140
+ const thunk = cAT(type, payloadCreator, options);
2141
+ context.exposeAction(reducerName, thunk);
2142
+ if (fulfilled) {
2143
+ context.addCase(thunk.fulfilled, fulfilled);
2144
+ }
2145
+ if (pending) {
2146
+ context.addCase(thunk.pending, pending);
2147
+ }
2148
+ if (rejected) {
2149
+ context.addCase(thunk.rejected, rejected);
2150
+ }
2151
+ if (settled) {
2152
+ context.addMatcher(thunk.settled, settled);
2153
+ }
2154
+ context.exposeCaseReducer(reducerName, {
2155
+ fulfilled: fulfilled || noop,
2156
+ pending: pending || noop,
2157
+ rejected: rejected || noop,
2158
+ settled: settled || noop
2159
+ });
2160
+ }
2161
+ function noop() {
2162
+ }
2163
+ var listener = "listener";
2164
+ var completed = "completed";
2165
+ var cancelled = "cancelled";
2166
+ var taskCancelled = `task-${cancelled}`;
2167
+ var taskCompleted = `task-${completed}`;
2168
+ var listenerCancelled = `${listener}-${cancelled}`;
2169
+ var listenerCompleted = `${listener}-${completed}`;
2170
+ var {
2171
+ assign
2172
+ } = Object;
2173
+ var alm = "listenerMiddleware";
2174
+ var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
2175
+ withTypes: () => addListener
2176
+ });
2177
+ var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
2178
+ var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
2179
+ withTypes: () => removeListener
2180
+ });
2181
+ function formatProdErrorMessage(code) {
2182
+ return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2183
+ }
2184
+
2185
+ // src/ScrollViewSettingsContext.ts
2186
+ var import_react10 = require("react");
2187
+ var defaultScrollViewSettings = {
2188
+ backActionFixed: true,
2189
+ footerFixed: false,
2190
+ headerFixed: false,
2191
+ snapBack: false
2192
+ };
2193
+ var ScrollViewSettingsContext = (0, import_react10.createContext)({
2194
+ settings: defaultScrollViewSettings,
2195
+ set: () => {
2196
+ }
2197
+ });
2198
+
2199
+ // src/redux/scrollViewSlice.ts
2200
+ var slice = createSlice({
2201
+ name: "scrollView",
2202
+ initialState: defaultScrollViewSettings,
2203
+ reducers: {
2204
+ initialize: (_state, action) => action.payload
2205
+ }
2206
+ });
2207
+ var scrollViewActions = slice.actions;
2208
+ var scrollViewReducer = slice.reducer;
2209
+
2210
+ // src/ScrollView.tsx
2211
+ var import_react11 = require("react");
2212
+ var import_react_native8 = require("react-native");
2213
+ var import_react_native_gesture_handler3 = require("react-native-gesture-handler");
2214
+ var import_react_native_reanimated8 = __toESM(require("react-native-reanimated"));
2215
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2216
+ var ScrollViewInner = ({ children, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, style, ...props }) => {
2217
+ const scrollView = (0, import_react11.useRef)(null);
2218
+ const isHorizontal = horizontal === true;
2219
+ const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style });
2220
+ const scrollTo = (0, import_react11.useCallback)((offset, animated) => {
2221
+ scrollView.current?.scrollTo({ y: offset, animated });
2222
+ }, []);
2223
+ const { handleMomentumScrollEnd, handleScrollBeginDrag, handleScrollEndDrag } = useScrollInit({
2224
+ onMomentumScrollEnd: externalMomentumScrollEnd,
2225
+ onScrollBeginDrag: externalScrollBeginDrag,
2226
+ onScrollEndDrag: externalScrollEndDrag,
2227
+ pullSearchHeight,
2228
+ scrollTo
2229
+ });
2230
+ const onPullSearchZoneEnter = (0, import_react11.useCallback)(() => {
2231
+ if (!pullSearchHeight) return;
2232
+ scrollTo(-contentInset.top + pullSearchHeight, true);
2233
+ }, [contentInset.top, pullSearchHeight, scrollTo]);
2234
+ const handleScroll = useScrollHandler({ chipHidden, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
2235
+ const handleScrollToTop = (0, import_react11.useCallback)(() => {
2236
+ if (isHorizontal) {
2237
+ scrollView.current?.scrollTo({ x: 0, animated: true });
2238
+ return;
2239
+ }
2240
+ const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
2241
+ scrollView.current?.scrollTo({ y: offset, animated: true });
2242
+ }, [isHorizontal, contentInset.top, pullSearchHeight]);
2243
+ const refreshControl = (0, import_react11.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
2244
+ const nativeGesture = (0, import_react11.useMemo)(() => import_react_native_gesture_handler3.Gesture.Native(), []);
2245
+ const combinedGesture = (0, import_react11.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler3.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
2246
+ const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
2247
+ const content = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: containerStyle, children: [
2248
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2249
+ import_react_native_reanimated8.default.ScrollView,
2250
+ {
2251
+ ...props,
2252
+ contentInset,
2253
+ contentOffset,
2254
+ onMomentumScrollEnd: handleMomentumScrollEnd,
2255
+ onScroll: handleScroll,
2256
+ onScrollBeginDrag: handleScrollBeginDrag,
2257
+ onScrollEndDrag: handleScrollEndDrag,
2258
+ ref: (el) => {
2259
+ if (props.ref) props.ref.current = el;
2260
+ scrollView.current = el;
2261
+ },
2262
+ refreshControl,
2263
+ scrollEventThrottle: 16,
2264
+ children
2265
+ }
2266
+ ),
2267
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollViewChip, { isHorizontal, onPress: handleScrollToTop, style: chipStyle })
2268
+ ] });
2269
+ return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_gesture_handler3.GestureDetector, { gesture: detectorGesture, children: content }) : content;
2270
+ };
2271
+ var ScrollView = (0, import_react11.memo)(ScrollViewInner);
2272
+
2273
+ // src/ScrollViewFooter.tsx
2274
+ var import_auto_paper2 = require("@rific/auto-paper");
2275
+ var import_react12 = require("react");
2276
+ var import_react_native9 = require("react-native");
2277
+ var import_react_native_reanimated9 = __toESM(require("react-native-reanimated"));
2278
+ var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
2279
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2280
+ var ScrollViewFooter = ({ children, style }) => {
2281
+ const { blur, footerHeight, footerFixed, footerOffset, headerHeightShared, pullSearchHeightShared, scrollPosition, setFooterHeight, snapBackFooterShared } = (0, import_react12.useContext)(ScrollViewContext);
2282
+ const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
2283
+ (0, import_react12.useEffect)(
2284
+ () => () => {
2285
+ setFooterHeight(0);
2286
+ },
2287
+ [setFooterHeight]
2288
+ );
2289
+ const handleLayout = ({
2290
+ nativeEvent: {
2291
+ layout: { height }
2292
+ }
2293
+ }) => {
2294
+ if (footerHeight !== height) setFooterHeight(height);
2295
+ };
2296
+ const footerStyle = (0, import_react_native_reanimated9.useAnimatedStyle)(() => {
2297
+ if (footerFixed) return { transform: [{ translateY: 0 }] };
2298
+ if (snapBackFooterShared.value) return { transform: [{ translateY: footerOffset.value }] };
2299
+ const effective = scrollPosition.value + headerHeightShared.value - pullSearchHeightShared.value;
2300
+ if (effective <= 0) return { transform: [{ translateY: 0 }] };
2301
+ return { transform: [{ translateY: Math.min(effective, footerHeight) }] };
2302
+ }, [footerHeight, footerFixed]);
2303
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native_reanimated9.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [styles6.footer, footerStyle], children: [
2304
+ footerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_auto_paper2.BlurView, { blur, style: import_react_native9.StyleSheet.absoluteFill }),
2305
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native9.View, { style: [styles6.row, { paddingBottom: insets.bottom }, style], children })
2306
+ ] });
2307
+ };
2308
+ var styles6 = import_react_native9.StyleSheet.create({
2309
+ footer: { bottom: 0, left: 0, position: "absolute", right: 0, zIndex: 2 },
2310
+ row: { alignItems: "center", flexDirection: "row", zIndex: 1 }
2311
+ });
2312
+
2313
+ // src/ScrollViewHeader.tsx
2314
+ var import_auto_paper3 = require("@rific/auto-paper");
2315
+ var import_react13 = require("react");
2316
+ var import_react_native10 = require("react-native");
2317
+ var import_react_native_paper4 = require("react-native-paper");
2318
+ var import_react_native_reanimated10 = __toESM(require("react-native-reanimated"));
2319
+ var import_react_native_safe_area_context4 = require("react-native-safe-area-context");
2320
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2321
+ var ActionBg = ({ blur, style }) => blur ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.actionBg, style], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_auto_paper3.BlurView, { blur: true, style: import_react_native10.StyleSheet.absoluteFill }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.actionBg, style], pointerEvents: "none", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper4.Surface, { style: import_react_native10.StyleSheet.absoluteFill, elevation: 1, children: null }) });
2322
+ var ScrollViewHeader = ({ actionSize = 48, actionStyle, backAction, backActionFixed, caption, centerContent, children, iconSize, style, title, topInset = true, trailingAction, trailingActionFixed = true }) => {
2323
+ const { blur, headerHeight, headerFixed, headerOffset, progress, progressing, pullSearchHeightShared, scrollPosition, setHeaderHeight, snapBackHeaderShared } = (0, import_react13.useContext)(ScrollViewContext);
2324
+ const { settings } = (0, import_react13.useContext)(ScrollViewSettingsContext);
2325
+ const effectiveBackActionFixed = backActionFixed ?? settings.backActionFixed;
2326
+ const insets = (0, import_react_native_safe_area_context4.useSafeAreaInsets)();
2327
+ const theme = (0, import_react_native_paper4.useTheme)();
2328
+ const top = topInset ? insets.top : 0;
2329
+ const handleLayout = ({
2330
+ nativeEvent: {
2331
+ layout: { height }
2332
+ }
2333
+ }) => {
2334
+ if (headerHeight !== height) setHeaderHeight(height);
2335
+ };
2336
+ const translateStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
2337
+ if (headerFixed) return { transform: [{ translateY: 0 }] };
2338
+ if (snapBackHeaderShared.value) return { transform: [{ translateY: headerOffset.value }] };
2339
+ const effective = scrollPosition.value + headerHeight - pullSearchHeightShared.value;
2340
+ if (effective <= 0) return { transform: [{ translateY: 0 }] };
2341
+ return { transform: [{ translateY: -effective }] };
2342
+ }, [headerFixed, headerHeight]);
2343
+ const blurStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
2344
+ if (!headerHeight) return { height: 0 };
2345
+ if (headerFixed) return { height: headerHeight };
2346
+ const translateY = snapBackHeaderShared.value ? headerOffset.value : -Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
2347
+ return { height: Math.max(headerHeight + translateY, top) };
2348
+ }, [headerFixed, headerHeight, top]);
2349
+ const progressStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
2350
+ if (headerFixed) return { top: headerHeight };
2351
+ const slide = snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
2352
+ return { top: Math.max(headerHeight - slide, top) };
2353
+ }, [headerFixed, headerHeight, top]);
2354
+ const actionMargin = 4;
2355
+ const contentMinHeight = actionSize + 2 * actionMargin;
2356
+ const actionTop = top + actionMargin;
2357
+ const buttonStyle = { borderRadius: actionSize, height: actionSize, margin: 0, width: actionSize };
2358
+ const actionShadow = { borderRadius: actionSize / 2, elevation: 2, shadowColor: "#000", shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.15, shadowRadius: 2 };
2359
+ const leadingStyle = { alignItems: "center", height: actionSize, justifyContent: "center", left: actionMargin, position: "absolute", top: actionTop, width: actionSize, zIndex: 3, ...actionShadow };
2360
+ const trailingStyle = { alignItems: "center", height: actionSize, justifyContent: "center", position: "absolute", right: actionMargin, top: actionTop, width: actionSize, zIndex: 3, ...actionShadow };
2361
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2362
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated10.default.View, { pointerEvents: "none", style: [styles7.blur, blurStyle], children: headerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_auto_paper3.BlurView, { blur, style: [styles7.blurInner, { height: headerHeight }] }) }),
2363
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [headerHeight === 0 ? styles7.headerInit : styles7.header, translateStyle], children: [
2364
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [{ paddingTop: top }, style], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native10.View, { style: [styles7.content, { minHeight: contentMinHeight }], children: [
2365
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.side }),
2366
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.spacer }),
2367
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.side, children }),
2368
+ (centerContent || title || caption) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.titleContainer], pointerEvents: centerContent ? "box-none" : "none", children: centerContent ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2369
+ title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.Text, { numberOfLines: 1, style: [styles7.title, { color: theme.colors.onSurface }], children: title }),
2370
+ caption && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.Text, { numberOfLines: 1, style: [styles7.caption, { color: theme.colors.onSurfaceVariant }], children: caption })
2371
+ ] }) })
2372
+ ] }) }),
2373
+ !blur && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [styles7.divider, { backgroundColor: theme.colors.outlineVariant }] })
2374
+ ] }),
2375
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated10.default.View, { pointerEvents: "none", style: [styles7.progress, progressStyle], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper4.ProgressBar, { indeterminate: progress === null, visible: progressing, progress: progress ?? void 0 }) }),
2376
+ backAction && (effectiveBackActionFixed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: leadingStyle, children: [
2377
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2378
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper4.Appbar.BackAction, { onPress: backAction, size: iconSize ?? actionSize / 2, style: buttonStyle })
2379
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: [leadingStyle, translateStyle], children: [
2380
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2381
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper4.Appbar.BackAction, { onPress: backAction, size: iconSize ?? actionSize / 2, style: buttonStyle })
2382
+ ] })),
2383
+ trailingAction && (trailingActionFixed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native10.View, { style: trailingStyle, children: [
2384
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2385
+ trailingAction
2386
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: [trailingStyle, translateStyle], children: [
2387
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2388
+ trailingAction
2389
+ ] }))
2390
+ ] });
2391
+ };
2392
+ var styles7 = import_react_native10.StyleSheet.create({
2393
+ actionBg: { borderRadius: 100, overflow: "hidden" },
2394
+ divider: { bottom: 0, height: import_react_native10.StyleSheet.hairlineWidth, left: 0, position: "absolute", right: 0 },
2395
+ caption: { fontSize: 12, fontWeight: "400", textAlign: "center" },
2396
+ content: { alignItems: "center", flexDirection: "row", width: "100%" },
2397
+ blur: { left: 0, overflow: "hidden", position: "absolute", right: 0, top: 0, zIndex: 2 },
2398
+ blurInner: { left: 0, position: "absolute", right: 0, top: 0 },
2399
+ header: { left: 0, overflow: "hidden", position: "absolute", right: 0, top: 0, zIndex: 2 },
2400
+ headerInit: { left: 0, overflow: "hidden", right: 0, zIndex: 2 },
2401
+ progress: { left: 0, position: "absolute", right: 0, zIndex: 3 },
2402
+ side: { alignItems: "center", flexDirection: "row" },
2403
+ spacer: { flex: 1 },
2404
+ title: { fontSize: 20, fontWeight: "400", textAlign: "center" },
2405
+ titleContainer: { alignItems: "center", justifyContent: "center" }
2406
+ });
2407
+
2408
+ // src/ScrollViewProvider.tsx
2409
+ var import_auto_paper4 = require("@rific/auto-paper");
2410
+ var import_react14 = require("react");
2411
+ var import_react_native11 = require("react-native");
2412
+ var import_react_native_reanimated11 = require("react-native-reanimated");
2413
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2414
+ var ScrollViewProvider = ({ blur, children, fixed = false, footerFixed, headerFixed, snapBack, snapBackFooter, snapBackHeader, tabBarHeight = 60 }) => {
2415
+ const { settings } = (0, import_react14.useContext)(ScrollViewSettingsContext);
2416
+ const effectiveBlur = (0, import_auto_paper4.useBlur)(blur);
2417
+ const effectiveSnapBack = snapBack ?? settings.snapBack;
2418
+ const effectiveSnapBackHeader = snapBackHeader ?? settings.snapBackHeader;
2419
+ const effectiveSnapBackFooter = snapBackFooter ?? settings.snapBackFooter;
2420
+ const [headerHeight, setHeaderHeightState] = (0, import_react14.useState)(0);
2421
+ const [footerHeight, setFooterHeightState] = (0, import_react14.useState)(0);
2422
+ const [progress, setProgress] = (0, import_react14.useState)(null);
2423
+ const [progressing, setProgressing] = (0, import_react14.useState)(false);
2424
+ const scrollPosition = (0, import_react_native_reanimated11.useSharedValue)(0);
2425
+ const headerHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2426
+ const footerHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2427
+ const headerOffset = (0, import_react_native_reanimated11.useSharedValue)(0);
2428
+ const footerOffset = (0, import_react_native_reanimated11.useSharedValue)(0);
2429
+ const pullSearchHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2430
+ const snapBackHeaderShared = (0, import_react_native_reanimated11.useSharedValue)(false);
2431
+ const snapBackFooterShared = (0, import_react_native_reanimated11.useSharedValue)(false);
2432
+ (0, import_react14.useEffect)(() => {
2433
+ snapBackHeaderShared.value = effectiveSnapBackHeader ?? effectiveSnapBack;
2434
+ snapBackFooterShared.value = effectiveSnapBackFooter ?? effectiveSnapBack;
2435
+ }, [effectiveSnapBack, effectiveSnapBackFooter, effectiveSnapBackHeader, snapBackFooterShared, snapBackHeaderShared]);
2436
+ const setHeaderHeight = (0, import_react14.useCallback)(
2437
+ (h) => {
2438
+ setHeaderHeightState(h);
2439
+ headerHeightShared.value = h;
2440
+ },
2441
+ [headerHeightShared]
2442
+ );
2443
+ const setFooterHeight = (0, import_react14.useCallback)(
2444
+ (h) => {
2445
+ setFooterHeightState(h);
2446
+ footerHeightShared.value = h;
2447
+ },
2448
+ [footerHeightShared]
2449
+ );
2450
+ const scrollHeight = (0, import_react14.useMemo)(() => import_react_native11.Dimensions.get("window").height - headerHeight - footerHeight, [headerHeight, footerHeight]);
2451
+ const effectiveHeaderFixed = fixed || (headerFixed ?? settings.headerFixed);
2452
+ const effectiveFooterFixed = fixed || (footerFixed ?? settings.footerFixed);
2453
+ const value = (0, import_react14.useMemo)(() => ({ blur: effectiveBlur, footerHeight, footerHeightShared, footerFixed: effectiveFooterFixed, footerOffset, headerHeight, headerHeightShared, headerFixed: effectiveHeaderFixed, headerOffset, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, setProgress, setProgressing, snapBackFooterShared, snapBackHeaderShared, tabBarHeight }), [effectiveBlur, effectiveFooterFixed, effectiveHeaderFixed, footerHeight, footerHeightShared, footerOffset, headerHeight, headerHeightShared, headerOffset, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, snapBackFooterShared, snapBackHeaderShared, tabBarHeight]);
2454
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScrollViewContext.Provider, { value, children });
2455
+ };
2456
+
2457
+ // src/ScrollViewSettingsProvider.tsx
2458
+ var import_react15 = require("react");
2459
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2460
+ var ScrollViewSettingsProvider = ({ children, onChange, value }) => {
2461
+ const [settings, setSettings] = (0, import_react15.useState)(() => ({
2462
+ ...defaultScrollViewSettings,
2463
+ ...value
2464
+ }));
2465
+ const set2 = (0, import_react15.useCallback)(
2466
+ (patch) => {
2467
+ setSettings((prev) => {
2468
+ const next = { ...prev, ...patch };
2469
+ onChange?.(next);
2470
+ return next;
2471
+ });
2472
+ },
2473
+ [onChange]
2474
+ );
2475
+ const ctx = (0, import_react15.useMemo)(() => ({ settings, set: set2 }), [settings, set2]);
2476
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScrollViewSettingsContext.Provider, { value: ctx, children });
2477
+ };
2478
+
2479
+ // src/SectionList.tsx
2480
+ var import_react17 = require("react");
2481
+ var import_react_native12 = require("react-native");
2482
+ var import_react_native_gesture_handler4 = require("react-native-gesture-handler");
2483
+ var import_react_native_reanimated13 = __toESM(require("react-native-reanimated"));
2484
+
2485
+ // src/internal/useStickyHeaders.ts
2486
+ var import_react16 = require("react");
2487
+ var import_react_native_reanimated12 = require("react-native-reanimated");
2488
+ var import_react_native_safe_area_context5 = require("react-native-safe-area-context");
2489
+ function useStickyHeaders(headerFixed, enabled) {
2490
+ const { headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react16.useContext)(ScrollViewContext);
2491
+ const insetsTop = (0, import_react_native_safe_area_context5.useSafeAreaInsets)().top;
2492
+ const sectionYPositions = (0, import_react_native_reanimated12.useSharedValue)([]);
2493
+ const sectionHeights = (0, import_react_native_reanimated12.useSharedValue)([]);
2494
+ const [activeIndex, setActiveIndex] = (0, import_react16.useState)(-1);
2495
+ const contentIndexShared = (0, import_react_native_reanimated12.useSharedValue)(-1);
2496
+ (0, import_react16.useLayoutEffect)(() => {
2497
+ contentIndexShared.value = activeIndex;
2498
+ }, [activeIndex, contentIndexShared]);
2499
+ const positionsCache = (0, import_react16.useRef)([]);
2500
+ const heightsCache = (0, import_react16.useRef)([]);
2501
+ (0, import_react_native_reanimated12.useAnimatedReaction)(
2502
+ () => {
2503
+ if (!enabled) return -1;
2504
+ const positions = sectionYPositions.value;
2505
+ if (positions.length === 0) return -1;
2506
+ const hHeight = headerHeightShared.value;
2507
+ const scrollPos = scrollPosition.value;
2508
+ let stickyTop;
2509
+ if (headerFixed) {
2510
+ stickyTop = hHeight;
2511
+ } else if (snapBackHeaderShared.value) {
2512
+ stickyTop = Math.max(insetsTop, hHeight + headerOffset.value);
2513
+ } else {
2514
+ const effective = scrollPos + hHeight - pullSearchHeightShared.value;
2515
+ stickyTop = effective <= 0 ? hHeight : Math.max(insetsTop, hHeight - effective);
2516
+ }
2517
+ const threshold = scrollPos + stickyTop;
2518
+ let active = -1;
2519
+ for (let i = 0; i < positions.length; i++) {
2520
+ if (positions[i] >= 0 && positions[i] < threshold) active = i;
2521
+ else if (positions[i] >= 0) break;
2522
+ }
2523
+ return active;
2524
+ },
2525
+ (curr, prev) => {
2526
+ if (curr !== prev) (0, import_react_native_reanimated12.runOnJS)(setActiveIndex)(curr);
2527
+ },
2528
+ [enabled, headerFixed, insetsTop]
2529
+ );
2530
+ const clipStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
2531
+ const hHeight = headerHeightShared.value;
2532
+ const scrollPos = scrollPosition.value;
2533
+ let stickyTop;
2534
+ if (!enabled || headerFixed) {
2535
+ stickyTop = hHeight;
2536
+ } else if (snapBackHeaderShared.value) {
2537
+ stickyTop = Math.max(insetsTop, hHeight + headerOffset.value);
2538
+ } else {
2539
+ const effective = scrollPos + hHeight - pullSearchHeightShared.value;
2540
+ stickyTop = effective <= 0 ? hHeight : Math.max(insetsTop, hHeight - effective);
2541
+ }
2542
+ return { top: stickyTop };
2543
+ }, [enabled, headerFixed, insetsTop]);
2544
+ const overlayStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
2545
+ const hidden = { opacity: 0, top: 0, transform: [{ translateY: 0 }] };
2546
+ if (!enabled) return hidden;
2547
+ const index = contentIndexShared.value;
2548
+ const positions = sectionYPositions.value;
2549
+ if (index < 0 || index >= positions.length) return hidden;
2550
+ const hHeight = headerHeightShared.value;
2551
+ const scrollPos = scrollPosition.value;
2552
+ let stickyTop;
2553
+ if (headerFixed) {
2554
+ stickyTop = hHeight;
2555
+ } else if (snapBackHeaderShared.value) {
2556
+ stickyTop = Math.max(insetsTop, hHeight + headerOffset.value);
2557
+ } else {
2558
+ const effective = scrollPos + hHeight - pullSearchHeightShared.value;
2559
+ stickyTop = effective <= 0 ? hHeight : Math.max(insetsTop, hHeight - effective);
2560
+ }
2561
+ if (positions[index] - scrollPos >= stickyTop) return hidden;
2562
+ const currentHeight = Math.max(0, sectionHeights.value[index] ?? 0);
2563
+ const nextIndex = index + 1;
2564
+ let translateY = 0;
2565
+ if (currentHeight > 0 && nextIndex < positions.length && positions[nextIndex] >= 0) {
2566
+ const nextScreenY = positions[nextIndex] - scrollPos;
2567
+ const pushThreshold = stickyTop + currentHeight;
2568
+ if (nextScreenY < pushThreshold) translateY = nextScreenY - pushThreshold;
2569
+ }
2570
+ return { opacity: 1, top: 0, transform: [{ translateY }] };
2571
+ }, [enabled, headerFixed, insetsTop]);
2572
+ const measureHeader = (0, import_react16.useCallback)(
2573
+ (index, pageY, height) => {
2574
+ const contentY = pageY + scrollPosition.value;
2575
+ positionsCache.current[index] = contentY;
2576
+ sectionYPositions.value = positionsCache.current.slice();
2577
+ heightsCache.current[index] = height;
2578
+ sectionHeights.value = heightsCache.current.slice();
2579
+ },
2580
+ [scrollPosition, sectionHeights, sectionYPositions]
2581
+ );
2582
+ const resetPositions = (0, import_react16.useCallback)(
2583
+ (count) => {
2584
+ positionsCache.current = Array.from({ length: count }, () => -1);
2585
+ sectionYPositions.value = positionsCache.current.slice();
2586
+ heightsCache.current = Array.from({ length: count }, () => -1);
2587
+ sectionHeights.value = heightsCache.current.slice();
2588
+ },
2589
+ [sectionHeights, sectionYPositions]
2590
+ );
2591
+ return { activeIndex, clipStyle, measureHeader, overlayStyle, resetPositions };
2592
+ }
2593
+
2594
+ // src/SectionList.tsx
2595
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2596
+ var AnimatedSectionList = (0, import_react_native_reanimated13.createAnimatedComponent)(import_react_native12.SectionList);
2597
+ var SectionListInner = ({ contentContainerStyle: externalContentContainerStyle, initialNumToRender = 20, maxToRenderPerBatch = 50, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onContentSizeChange, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, removeClippedSubviews = false, sections, showsVerticalScrollIndicator, style, ref: externalRef, windowSize = 100, ...props }) => {
2598
+ const scrollView = (0, import_react17.useRef)(null);
2599
+ const { stickySectionHeadersEnabled = true, renderSectionHeader, ...passThroughProps } = props;
2600
+ const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed, headerHeight } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, keyboardAware, pullSearchHeight, style });
2601
+ const usesCustomSticky = stickySectionHeadersEnabled && renderSectionHeader != null;
2602
+ const { activeIndex, clipStyle, measureHeader, overlayStyle, resetPositions } = useStickyHeaders(headerFixed, usesCustomSticky);
2603
+ (0, import_react17.useLayoutEffect)(() => {
2604
+ if (usesCustomSticky) resetPositions(sections.length);
2605
+ }, [sections, usesCustomSticky, resetPositions, headerHeight]);
2606
+ const sectionViewRefs = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2607
+ const wrappedRenderSectionHeader = (0, import_react17.useMemo)(() => {
2608
+ if (!usesCustomSticky) return renderSectionHeader ?? void 0;
2609
+ return (info) => {
2610
+ const idx = sections.findIndex((s) => s === info.section);
2611
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2612
+ import_react_native12.View,
2613
+ {
2614
+ ref: (el) => {
2615
+ sectionViewRefs.current.set(idx, el);
2616
+ },
2617
+ onLayout: () => {
2618
+ const el = sectionViewRefs.current.get(idx);
2619
+ el?.measure((_x, _y, _w, h, _px, pageY) => {
2620
+ if (idx >= 0 && sectionViewRefs.current.get(idx) === el) measureHeader(idx, pageY, h);
2621
+ });
2622
+ },
2623
+ children: renderSectionHeader(info)
2624
+ }
2625
+ );
2626
+ };
2627
+ }, [usesCustomSticky, renderSectionHeader, sections, measureHeader]);
2628
+ const scrollTo = (0, import_react17.useCallback)((offset, animated) => {
2629
+ scrollView.current?.getScrollResponder()?.scrollTo({ y: offset, animated });
2630
+ }, []);
2631
+ const {
2632
+ activeListHeader: pullSearchHeader,
2633
+ handleMomentumScrollEnd,
2634
+ handleScrollBeginDrag,
2635
+ handleScrollEndDrag,
2636
+ hiddenHeader,
2637
+ pullSearchMinHeight
2638
+ } = useScrollInit({
2639
+ listHeaderComponent: externalListHeaderComponent,
2640
+ onMomentumScrollEnd: externalMomentumScrollEnd,
2641
+ onScrollBeginDrag: externalScrollBeginDrag,
2642
+ onScrollEndDrag: externalScrollEndDrag,
2643
+ pullSearchHeight,
2644
+ scrollTo
2645
+ });
2646
+ const activeListHeader = (0, import_react17.useMemo)(() => {
2647
+ if (!renderFilters) return pullSearchHeader;
2648
+ const Inner = pullSearchHeader;
2649
+ return () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2650
+ Inner ? typeof Inner === "function" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Inner, {}) : Inner : null,
2651
+ renderFilters
2652
+ ] });
2653
+ }, [pullSearchHeader, renderFilters]);
2654
+ const pullSearchSettled = (0, import_react17.useRef)(false);
2655
+ (0, import_react17.useEffect)(() => {
2656
+ if (!usesCustomSticky || activeListHeader == null || pullSearchSettled.current) return;
2657
+ pullSearchSettled.current = true;
2658
+ const handle = requestAnimationFrame(() => {
2659
+ sectionViewRefs.current.forEach((el, idx) => {
2660
+ el?.measure((_x, _y, _w, h, _px, pageY) => {
2661
+ if (sectionViewRefs.current.get(idx) === el) measureHeader(idx, pageY, h);
2662
+ });
2663
+ });
2664
+ });
2665
+ return () => cancelAnimationFrame(handle);
2666
+ }, [activeListHeader, usesCustomSticky, measureHeader]);
2667
+ const contentContainerStyle = (0, import_react17.useMemo)(() => [{ minHeight: import_react_native12.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
2668
+ const onPullSearchZoneEnter = (0, import_react17.useCallback)(() => {
2669
+ if (!pullSearchHeight) return;
2670
+ scrollTo(-contentInset.top + pullSearchHeight, true);
2671
+ }, [contentInset.top, pullSearchHeight, scrollTo]);
2672
+ const handleScroll = useScrollHandler({ chipHidden, footerFixed, headerFixed, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
2673
+ const handleScrollToTop = (0, import_react17.useCallback)(() => {
2674
+ const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
2675
+ scrollView.current?.getScrollResponder()?.scrollTo({ y: offset, animated: true });
2676
+ }, [contentInset.top, pullSearchHeight]);
2677
+ const handleContentSizeChange = (0, import_react17.useCallback)(
2678
+ (w, h) => {
2679
+ if (onContentSizeChange) onContentSizeChange(w, h);
2680
+ },
2681
+ [onContentSizeChange]
2682
+ );
2683
+ const refreshControl = (0, import_react17.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
2684
+ const nativeGesture = (0, import_react17.useMemo)(() => import_react_native_gesture_handler4.Gesture.Native(), []);
2685
+ const combinedGesture = (0, import_react17.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler4.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
2686
+ const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
2687
+ const content = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native12.View, { style: containerStyle, children: [
2688
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2689
+ AnimatedSectionList,
2690
+ {
2691
+ ...passThroughProps,
2692
+ contentContainerStyle,
2693
+ contentInset,
2694
+ contentOffset,
2695
+ initialNumToRender,
2696
+ ListHeaderComponent: activeListHeader,
2697
+ maxToRenderPerBatch,
2698
+ onContentSizeChange: handleContentSizeChange,
2699
+ onMomentumScrollEnd: handleMomentumScrollEnd,
2700
+ onScroll: handleScroll,
2701
+ onScrollBeginDrag: handleScrollBeginDrag,
2702
+ onScrollEndDrag: handleScrollEndDrag,
2703
+ ref: (el) => {
2704
+ if (externalRef) externalRef.current = el;
2705
+ scrollView.current = el;
2706
+ },
2707
+ refreshControl,
2708
+ removeClippedSubviews,
2709
+ renderSectionHeader: wrappedRenderSectionHeader,
2710
+ scrollEventThrottle: 16,
2711
+ sections,
2712
+ showsVerticalScrollIndicator: showsVerticalScrollIndicator ?? true,
2713
+ stickySectionHeadersEnabled: false,
2714
+ windowSize
2715
+ },
2716
+ headerHeight > 0 ? 1 : 0
2717
+ ),
2718
+ hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native12.View, { pointerEvents: "none", style: styles8.measureContainer, children: hiddenHeader }),
2719
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ScrollViewChip, { onPress: handleScrollToTop, style: chipStyle }),
2720
+ usesCustomSticky && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated13.default.View, { pointerEvents: "none", style: [styles8.stickyClip, clipStyle], children: activeIndex >= 0 && activeIndex < sections.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated13.default.View, { style: [styles8.stickyOverlay, overlayStyle], children: renderSectionHeader({ section: sections[activeIndex] }) }) })
2721
+ ] });
2722
+ return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_gesture_handler4.GestureDetector, { gesture: detectorGesture, children: content }) : content;
2723
+ };
2724
+ var styles8 = {
2725
+ measureContainer: { left: 0, opacity: 0, position: "absolute", right: 0, top: -9999 },
2726
+ stickyClip: { bottom: 0, left: 0, overflow: "hidden", position: "absolute", right: 0, zIndex: 2 },
2727
+ stickyOverlay: { left: 0, position: "absolute", right: 0 }
2728
+ };
2729
+ var SectionList = (0, import_react17.memo)(SectionListInner);
2730
+
2731
+ // src/useScrollView.ts
2732
+ var import_react18 = require("react");
2733
+ var useScrollView = () => {
2734
+ const { progress, progressing, scrollHeight, scrollPosition, setProgress, setProgressing } = (0, import_react18.useContext)(ScrollViewContext);
2735
+ return { progress, progressing, scrollHeight, scrollPosition, setProgress, setProgressing };
2736
+ };
2737
+
2738
+ // src/useScrollViewSettings.ts
2739
+ var import_react19 = require("react");
2740
+ var useScrollViewSettings = () => (0, import_react19.useContext)(ScrollViewSettingsContext);
2741
+ // Annotate the CommonJS export names for ESM import in node:
2742
+ 0 && (module.exports = {
2743
+ CustomList,
2744
+ FlatList,
2745
+ PullSearch,
2746
+ ScrollView,
2747
+ ScrollViewContext,
2748
+ ScrollViewFooter,
2749
+ ScrollViewHeader,
2750
+ ScrollViewProvider,
2751
+ ScrollViewSettingsContext,
2752
+ ScrollViewSettingsProvider,
2753
+ SectionList,
2754
+ defaultScrollViewSettings,
2755
+ scrollViewActions,
2756
+ scrollViewReducer,
2757
+ useKeyboardInset,
2758
+ useScrollView,
2759
+ useScrollViewSettings
2760
+ });