@rific/auto-paper 0.2.0 → 0.4.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.
- package/README.md +117 -16
- package/dist/index.d.mts +130 -27
- package/dist/index.d.ts +130 -27
- package/dist/index.js +2197 -1886
- package/dist/index.mjs +1417 -1109
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
7
|
var __export = (target, all) => {
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
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
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
21
|
|
|
@@ -33,37 +23,74 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
33
23
|
var index_exports = {};
|
|
34
24
|
__export(index_exports, {
|
|
35
25
|
Appbar: () => Appbar,
|
|
26
|
+
AppearancePicker: () => AppearancePicker,
|
|
27
|
+
BlurView: () => BlurView,
|
|
36
28
|
BottomNavigation: () => BottomNavigation,
|
|
37
29
|
Button: () => Button,
|
|
38
30
|
Chip: () => Chip,
|
|
31
|
+
ColorPicker: () => ColorPicker,
|
|
32
|
+
Dialog: () => Dialog,
|
|
39
33
|
FAB: () => FAB,
|
|
34
|
+
HarmonyPicker: () => HarmonyPicker,
|
|
40
35
|
IconButton: () => IconButton,
|
|
36
|
+
Menu: () => Menu,
|
|
41
37
|
Provider: () => Provider,
|
|
42
38
|
TextInput: () => TextInput,
|
|
39
|
+
ThemeSettingsContext: () => ThemeSettingsContext,
|
|
43
40
|
createThemeReducer: () => createThemeReducer,
|
|
41
|
+
defaultColors: () => defaultColors,
|
|
42
|
+
defaultThemeSettings: () => defaultThemeSettings,
|
|
44
43
|
getBlendedColor: () => getBlendedColor,
|
|
45
44
|
getHex: () => getHex,
|
|
46
45
|
getRgb: () => getRgb,
|
|
47
46
|
getTriadicPalette: () => getTriadicPalette,
|
|
48
47
|
isDarkColor: () => isDarkColor,
|
|
49
48
|
selectThemeAppearance: () => selectThemeAppearance,
|
|
49
|
+
selectThemeBlur: () => selectThemeBlur,
|
|
50
50
|
selectThemeColor: () => selectThemeColor,
|
|
51
|
+
selectThemeHarmony: () => selectThemeHarmony,
|
|
51
52
|
themeActions: () => themeActions,
|
|
52
53
|
themeReducer: () => themeReducer,
|
|
54
|
+
useBlur: () => useBlur,
|
|
53
55
|
useComputedTheme: () => useComputedTheme,
|
|
54
|
-
usePaperDefaults: () => usePaperDefaults
|
|
56
|
+
usePaperDefaults: () => usePaperDefaults,
|
|
57
|
+
useThemeSettings: () => useThemeSettings
|
|
55
58
|
});
|
|
56
59
|
module.exports = __toCommonJS(index_exports);
|
|
57
60
|
|
|
61
|
+
// src/BlurContext.tsx
|
|
62
|
+
var import_react2 = require("react");
|
|
63
|
+
|
|
64
|
+
// src/ThemeSettingsContext.ts
|
|
65
|
+
var import_react = require("react");
|
|
66
|
+
var defaultThemeSettings = {
|
|
67
|
+
appearance: "system",
|
|
68
|
+
blur: true,
|
|
69
|
+
blurTint: 0.2,
|
|
70
|
+
color: "#6750a4",
|
|
71
|
+
harmony: "split-complementary"
|
|
72
|
+
};
|
|
73
|
+
var ThemeSettingsContext = (0, import_react.createContext)({
|
|
74
|
+
settings: defaultThemeSettings,
|
|
75
|
+
set: () => {
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/BlurContext.tsx
|
|
80
|
+
function useBlur(override) {
|
|
81
|
+
const { settings } = (0, import_react2.useContext)(ThemeSettingsContext);
|
|
82
|
+
return override ?? settings.blur;
|
|
83
|
+
}
|
|
84
|
+
|
|
58
85
|
// src/components/Appbar.tsx
|
|
59
86
|
var import_react_native = require("react-native");
|
|
60
87
|
var import_react_native_paper = require("react-native-paper");
|
|
61
88
|
|
|
62
89
|
// src/PaperDefaultsContext.tsx
|
|
63
|
-
var
|
|
64
|
-
var PaperDefaultsContext = (0,
|
|
90
|
+
var import_react3 = require("react");
|
|
91
|
+
var PaperDefaultsContext = (0, import_react3.createContext)({});
|
|
65
92
|
function usePaperDefaults() {
|
|
66
|
-
return (0,
|
|
93
|
+
return (0, import_react3.useContext)(PaperDefaultsContext);
|
|
67
94
|
}
|
|
68
95
|
|
|
69
96
|
// src/components/Appbar.tsx
|
|
@@ -83,2054 +110,2338 @@ var Appbar = {
|
|
|
83
110
|
BackAction: import_react_native_paper.Appbar.BackAction
|
|
84
111
|
};
|
|
85
112
|
|
|
86
|
-
// src/components/
|
|
87
|
-
var import_react2 = require("react");
|
|
88
|
-
var import_react_native2 = require("react-native");
|
|
113
|
+
// src/components/AppearancePicker.tsx
|
|
89
114
|
var import_react_native_paper2 = require("react-native-paper");
|
|
90
115
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setButtonStyleAsync(theme.dark ? "light" : "dark");
|
|
98
|
-
}).catch(() => {
|
|
99
|
-
});
|
|
100
|
-
}, [theme]);
|
|
101
|
-
}
|
|
102
|
-
function BottomNavigationComponent(props) {
|
|
103
|
-
const defaults = usePaperDefaults();
|
|
104
|
-
useNavigationBarSync();
|
|
105
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.BottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
106
|
-
}
|
|
107
|
-
function Bar(props) {
|
|
108
|
-
useNavigationBarSync();
|
|
109
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.BottomNavigation.Bar, { ...props });
|
|
110
|
-
}
|
|
111
|
-
BottomNavigationComponent.Bar = Bar;
|
|
112
|
-
BottomNavigationComponent.SceneMap = import_react_native_paper2.BottomNavigation.SceneMap;
|
|
113
|
-
var BottomNavigation = BottomNavigationComponent;
|
|
116
|
+
var APPEARANCES = [
|
|
117
|
+
{ label: "System", value: "system", icon: "brightness-auto" },
|
|
118
|
+
{ label: "Light", value: "light", icon: "white-balance-sunny" },
|
|
119
|
+
{ label: "Dark", value: "dark", icon: "weather-night" }
|
|
120
|
+
];
|
|
121
|
+
var AppearancePicker = ({ value, onChange }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.SegmentedButtons, { value, onValueChange: (v) => onChange(v), buttons: APPEARANCES.map((a) => ({ value: a.value, label: a.label, icon: a.icon })) });
|
|
114
122
|
|
|
115
|
-
// src/components/
|
|
123
|
+
// src/components/BlurView.tsx
|
|
124
|
+
var import_expo_blur = require("expo-blur");
|
|
125
|
+
var import_react4 = require("react");
|
|
126
|
+
var import_react_native2 = require("react-native");
|
|
116
127
|
var import_react_native_paper3 = require("react-native-paper");
|
|
117
128
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
129
|
+
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
130
|
+
var BlurView = ({ blur = true, children, elevation, style, ...props }) => {
|
|
131
|
+
const { dark, colors } = (0, import_react_native_paper3.useTheme)();
|
|
132
|
+
const { settings } = (0, import_react4.useContext)(ThemeSettingsContext);
|
|
133
|
+
const tintOpacity = elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0;
|
|
134
|
+
const tint = tintOpacity > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: colors.primary, opacity: tintOpacity }] }) : null;
|
|
135
|
+
if (blur)
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_expo_blur.BlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: colors.surface, opacity: settings.blurTint }] }),
|
|
138
|
+
tint,
|
|
139
|
+
children
|
|
140
|
+
] });
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor: colors.surface }, style], children: [
|
|
142
|
+
tint,
|
|
143
|
+
children
|
|
144
|
+
] });
|
|
145
|
+
};
|
|
122
146
|
|
|
123
|
-
// src/components/
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
const defaults = usePaperDefaults();
|
|
128
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper4.Chip, { ...defaults.Chip, ...props });
|
|
129
|
-
}
|
|
147
|
+
// src/components/BottomNavigation.tsx
|
|
148
|
+
var import_react7 = require("react");
|
|
149
|
+
var import_react_native5 = require("react-native");
|
|
150
|
+
var import_react_native_paper6 = require("react-native-paper");
|
|
130
151
|
|
|
131
|
-
// src/
|
|
152
|
+
// src/ThemeProvider.tsx
|
|
153
|
+
var import_react6 = require("react");
|
|
154
|
+
var import_react_native4 = require("react-native");
|
|
132
155
|
var import_react_native_paper5 = require("react-native-paper");
|
|
133
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
134
|
-
function FAB(props) {
|
|
135
|
-
const defaults = usePaperDefaults();
|
|
136
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper5.FAB, { ...defaults.FAB, ...props });
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/components/IconButton.tsx
|
|
140
|
-
var import_react_native_paper6 = require("react-native-paper");
|
|
141
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
142
|
-
function IconButton(props) {
|
|
143
|
-
const defaults = usePaperDefaults();
|
|
144
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper6.IconButton, { ...defaults.IconButton, ...props });
|
|
145
|
-
}
|
|
146
156
|
|
|
147
|
-
// src/
|
|
148
|
-
var
|
|
149
|
-
var
|
|
150
|
-
var
|
|
151
|
-
var TextInput = (0, import_react3.forwardRef)(function TextInput2(props, ref) {
|
|
152
|
-
const defaults = usePaperDefaults();
|
|
153
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper7.TextInput, { ref, ...defaults.TextInput, ...props });
|
|
154
|
-
});
|
|
157
|
+
// src/useComputedTheme.ts
|
|
158
|
+
var import_react5 = require("react");
|
|
159
|
+
var import_react_native3 = require("react-native");
|
|
160
|
+
var import_react_native_paper4 = require("react-native-paper");
|
|
155
161
|
|
|
156
|
-
//
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
// src/utils/colorNames.ts
|
|
163
|
+
var colorNames = {
|
|
164
|
+
aliceblue: "#f0f8ff",
|
|
165
|
+
antiquewhite: "#faebd7",
|
|
166
|
+
aqua: "#00ffff",
|
|
167
|
+
aquamarine: "#7fffd4",
|
|
168
|
+
azure: "#f0ffff",
|
|
169
|
+
beige: "#f5f5dc",
|
|
170
|
+
bisque: "#ffe4c4",
|
|
171
|
+
black: "#000000",
|
|
172
|
+
blanchedalmond: "#ffebcd",
|
|
173
|
+
blue: "#0000ff",
|
|
174
|
+
blueviolet: "#8a2be2",
|
|
175
|
+
brown: "#a52a2a",
|
|
176
|
+
burlywood: "#deb887",
|
|
177
|
+
cadetblue: "#5f9ea0",
|
|
178
|
+
chartreuse: "#7fff00",
|
|
179
|
+
chocolate: "#d2691e",
|
|
180
|
+
coral: "#ff7f50",
|
|
181
|
+
cornflowerblue: "#6495ed",
|
|
182
|
+
cornsilk: "#fff8dc",
|
|
183
|
+
crimson: "#dc143c",
|
|
184
|
+
cyan: "#00ffff",
|
|
185
|
+
darkblue: "#00008b",
|
|
186
|
+
darkcyan: "#008b8b",
|
|
187
|
+
darkgoldenrod: "#b8860b",
|
|
188
|
+
darkgray: "#a9a9a9",
|
|
189
|
+
darkgrey: "#a9a9a9",
|
|
190
|
+
darkgreen: "#006400",
|
|
191
|
+
darkkhaki: "#bdb76b",
|
|
192
|
+
darkmagenta: "#8b008b",
|
|
193
|
+
darkolivegreen: "#556b2f",
|
|
194
|
+
darkorange: "#ff8c00",
|
|
195
|
+
darkorchid: "#9932cc",
|
|
196
|
+
darkred: "#8b0000",
|
|
197
|
+
darksalmon: "#e9967a",
|
|
198
|
+
darkseagreen: "#8fbc8f",
|
|
199
|
+
darkslateblue: "#483d8b",
|
|
200
|
+
darkslategray: "#2f4f4f",
|
|
201
|
+
darkslategrey: "#2f4f4f",
|
|
202
|
+
darkturquoise: "#00ced1",
|
|
203
|
+
darkviolet: "#9400d3",
|
|
204
|
+
deeppink: "#ff1493",
|
|
205
|
+
deepskyblue: "#00bfff",
|
|
206
|
+
dimgray: "#696969",
|
|
207
|
+
dimgrey: "#696969",
|
|
208
|
+
dodgerblue: "#1e90ff",
|
|
209
|
+
firebrick: "#b22222",
|
|
210
|
+
floralwhite: "#fffaf0",
|
|
211
|
+
forestgreen: "#228b22",
|
|
212
|
+
fuchsia: "#ff00ff",
|
|
213
|
+
gainsboro: "#dcdcdc",
|
|
214
|
+
ghostwhite: "#f8f8ff",
|
|
215
|
+
gold: "#ffd700",
|
|
216
|
+
goldenrod: "#daa520",
|
|
217
|
+
gray: "#808080",
|
|
218
|
+
grey: "#808080",
|
|
219
|
+
green: "#008000",
|
|
220
|
+
greenyellow: "#adff2f",
|
|
221
|
+
honeydew: "#f0fff0",
|
|
222
|
+
hotpink: "#ff69b4",
|
|
223
|
+
indianred: "#cd5c5c",
|
|
224
|
+
indigo: "#4b0082",
|
|
225
|
+
ivory: "#fffff0",
|
|
226
|
+
khaki: "#f0e68c",
|
|
227
|
+
lavender: "#e6e6fa",
|
|
228
|
+
lavenderblush: "#fff0f5",
|
|
229
|
+
lawngreen: "#7cfc00",
|
|
230
|
+
lemonchiffon: "#fffacd",
|
|
231
|
+
lightblue: "#add8e6",
|
|
232
|
+
lightcoral: "#f08080",
|
|
233
|
+
lightcyan: "#e0ffff",
|
|
234
|
+
lightgoldenrodyellow: "#fafad2",
|
|
235
|
+
lightgray: "#d3d3d3",
|
|
236
|
+
lightgrey: "#d3d3d3",
|
|
237
|
+
lightgreen: "#90ee90",
|
|
238
|
+
lightpink: "#ffb6c1",
|
|
239
|
+
lightsalmon: "#ffa07a",
|
|
240
|
+
lightseagreen: "#20b2aa",
|
|
241
|
+
lightskyblue: "#87cefa",
|
|
242
|
+
lightslategray: "#778899",
|
|
243
|
+
lightslategrey: "#778899",
|
|
244
|
+
lightsteelblue: "#b0c4de",
|
|
245
|
+
lightyellow: "#ffffe0",
|
|
246
|
+
lime: "#00ff00",
|
|
247
|
+
limegreen: "#32cd32",
|
|
248
|
+
linen: "#faf0e6",
|
|
249
|
+
magenta: "#ff00ff",
|
|
250
|
+
maroon: "#800000",
|
|
251
|
+
mediumaquamarine: "#66cdaa",
|
|
252
|
+
mediumblue: "#0000cd",
|
|
253
|
+
mediumorchid: "#ba55d3",
|
|
254
|
+
mediumpurple: "#9370db",
|
|
255
|
+
mediumseagreen: "#3cb371",
|
|
256
|
+
mediumslateblue: "#7b68ee",
|
|
257
|
+
mediumspringgreen: "#00fa9a",
|
|
258
|
+
mediumturquoise: "#48d1cc",
|
|
259
|
+
mediumvioletred: "#c71585",
|
|
260
|
+
midnightblue: "#191970",
|
|
261
|
+
mintcream: "#f5fffa",
|
|
262
|
+
mistyrose: "#ffe4e1",
|
|
263
|
+
moccasin: "#ffe4b5",
|
|
264
|
+
navajowhite: "#ffdead",
|
|
265
|
+
navy: "#000080",
|
|
266
|
+
oldlace: "#fdf5e6",
|
|
267
|
+
olive: "#808000",
|
|
268
|
+
olivedrab: "#6b8e23",
|
|
269
|
+
orange: "#ffa500",
|
|
270
|
+
orangered: "#ff4500",
|
|
271
|
+
orchid: "#da70d6",
|
|
272
|
+
palegoldenrod: "#eee8aa",
|
|
273
|
+
palegreen: "#98fb98",
|
|
274
|
+
paleturquoise: "#afeeee",
|
|
275
|
+
palevioletred: "#db7093",
|
|
276
|
+
papayawhip: "#ffefd5",
|
|
277
|
+
peachpuff: "#ffdab9",
|
|
278
|
+
peru: "#cd853f",
|
|
279
|
+
pink: "#ffc0cb",
|
|
280
|
+
plum: "#dda0dd",
|
|
281
|
+
powderblue: "#b0e0e6",
|
|
282
|
+
purple: "#800080",
|
|
283
|
+
rebeccapurple: "#663399",
|
|
284
|
+
red: "#ff0000",
|
|
285
|
+
rosybrown: "#bc8f8f",
|
|
286
|
+
royalblue: "#4169e1",
|
|
287
|
+
saddlebrown: "#8b4513",
|
|
288
|
+
salmon: "#fa8072",
|
|
289
|
+
sandybrown: "#f4a460",
|
|
290
|
+
seagreen: "#2e8b57",
|
|
291
|
+
seashell: "#fff5ee",
|
|
292
|
+
sienna: "#a0522d",
|
|
293
|
+
silver: "#c0c0c0",
|
|
294
|
+
skyblue: "#87ceeb",
|
|
295
|
+
slateblue: "#6a5acd",
|
|
296
|
+
slategray: "#708090",
|
|
297
|
+
slategrey: "#708090",
|
|
298
|
+
snow: "#fffafa",
|
|
299
|
+
springgreen: "#00ff7f",
|
|
300
|
+
steelblue: "#4682b4",
|
|
301
|
+
tan: "#d2b48c",
|
|
302
|
+
teal: "#008080",
|
|
303
|
+
thistle: "#d8bfd8",
|
|
304
|
+
tomato: "#ff6347",
|
|
305
|
+
transparent: "transparent",
|
|
306
|
+
turquoise: "#40e0d0",
|
|
307
|
+
violet: "#ee82ee",
|
|
308
|
+
wheat: "#f5deb3",
|
|
309
|
+
white: "#ffffff",
|
|
310
|
+
whitesmoke: "#f5f5f5",
|
|
311
|
+
yellow: "#ffff00",
|
|
312
|
+
yellowgreen: "#9acd32"
|
|
162
313
|
};
|
|
163
|
-
function isPlainObject(obj) {
|
|
164
|
-
if (typeof obj !== "object" || obj === null)
|
|
165
|
-
return false;
|
|
166
|
-
let proto = obj;
|
|
167
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
168
|
-
proto = Object.getPrototypeOf(proto);
|
|
169
|
-
}
|
|
170
|
-
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
171
|
-
}
|
|
172
|
-
function compose(...funcs) {
|
|
173
|
-
if (funcs.length === 0) {
|
|
174
|
-
return (arg) => arg;
|
|
175
|
-
}
|
|
176
|
-
if (funcs.length === 1) {
|
|
177
|
-
return funcs[0];
|
|
178
|
-
}
|
|
179
|
-
return funcs.reduce((a, b) => (...args) => a(b(...args)));
|
|
180
|
-
}
|
|
181
|
-
function isAction(action) {
|
|
182
|
-
return isPlainObject(action) && "type" in action && typeof action.type === "string";
|
|
183
|
-
}
|
|
184
314
|
|
|
185
|
-
//
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
function(thing) {
|
|
215
|
-
return `'original' expects a draft, got: ${thing}`;
|
|
216
|
-
}
|
|
217
|
-
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
218
|
-
// See Patches.ts for additional errors
|
|
219
|
-
] : [];
|
|
220
|
-
function die(error, ...args) {
|
|
221
|
-
if (process.env.NODE_ENV !== "production") {
|
|
222
|
-
const e = errors[error];
|
|
223
|
-
const msg = isFunction(e) ? e.apply(null, args) : e;
|
|
224
|
-
throw new Error(`[Immer] ${msg}`);
|
|
225
|
-
}
|
|
226
|
-
throw new Error(
|
|
227
|
-
`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
var O = Object;
|
|
231
|
-
var getPrototypeOf = O.getPrototypeOf;
|
|
232
|
-
var CONSTRUCTOR = "constructor";
|
|
233
|
-
var PROTOTYPE = "prototype";
|
|
234
|
-
var CONFIGURABLE = "configurable";
|
|
235
|
-
var ENUMERABLE = "enumerable";
|
|
236
|
-
var WRITABLE = "writable";
|
|
237
|
-
var VALUE = "value";
|
|
238
|
-
var isDraft = (value) => !!value && !!value[DRAFT_STATE];
|
|
239
|
-
function isDraftable(value) {
|
|
240
|
-
if (!value)
|
|
241
|
-
return false;
|
|
242
|
-
return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
243
|
-
}
|
|
244
|
-
var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
|
|
245
|
-
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
246
|
-
function isPlainObject2(value) {
|
|
247
|
-
if (!value || !isObjectish(value))
|
|
248
|
-
return false;
|
|
249
|
-
const proto = getPrototypeOf(value);
|
|
250
|
-
if (proto === null || proto === O[PROTOTYPE])
|
|
251
|
-
return true;
|
|
252
|
-
const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
|
|
253
|
-
if (Ctor === Object)
|
|
254
|
-
return true;
|
|
255
|
-
if (!isFunction(Ctor))
|
|
256
|
-
return false;
|
|
257
|
-
let ctorString = cachedCtorStrings.get(Ctor);
|
|
258
|
-
if (ctorString === void 0) {
|
|
259
|
-
ctorString = Function.toString.call(Ctor);
|
|
260
|
-
cachedCtorStrings.set(Ctor, ctorString);
|
|
315
|
+
// src/utils/getRgb.ts
|
|
316
|
+
var getRgb = (value) => {
|
|
317
|
+
if (!value) return null;
|
|
318
|
+
let trimmed = value.trim().toLowerCase();
|
|
319
|
+
const namedColor = colorNames[trimmed];
|
|
320
|
+
if (namedColor) trimmed = namedColor;
|
|
321
|
+
const hexMatch = trimmed.match(/^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i);
|
|
322
|
+
if (hexMatch) {
|
|
323
|
+
const hex = hexMatch[1];
|
|
324
|
+
let normalized = hex;
|
|
325
|
+
if (hex.length === 3) {
|
|
326
|
+
normalized = hex.split("").map((c) => c + c).join("");
|
|
327
|
+
} else if (hex.length === 8) {
|
|
328
|
+
const alpha = parseInt(hex.substring(6, 8), 16);
|
|
329
|
+
normalized = hex.substring(0, 6);
|
|
330
|
+
const intVal2 = parseInt(normalized, 16);
|
|
331
|
+
return {
|
|
332
|
+
r: intVal2 >> 16 & 255,
|
|
333
|
+
g: intVal2 >> 8 & 255,
|
|
334
|
+
b: intVal2 & 255,
|
|
335
|
+
a: alpha / 255
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
const intVal = parseInt(normalized, 16);
|
|
339
|
+
return {
|
|
340
|
+
r: intVal >> 16 & 255,
|
|
341
|
+
g: intVal >> 8 & 255,
|
|
342
|
+
b: intVal & 255
|
|
343
|
+
};
|
|
261
344
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
345
|
+
const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([0-9.]+))?\s*\)$/i);
|
|
346
|
+
if (rgbMatch) {
|
|
347
|
+
const result = {
|
|
348
|
+
r: Number(rgbMatch[1]),
|
|
349
|
+
g: Number(rgbMatch[2]),
|
|
350
|
+
b: Number(rgbMatch[3])
|
|
351
|
+
};
|
|
352
|
+
if (rgbMatch[4] !== void 0) {
|
|
353
|
+
result.a = Number(rgbMatch[4]);
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
272
356
|
}
|
|
273
|
-
|
|
274
|
-
function getArchtype(thing) {
|
|
275
|
-
const state = thing[DRAFT_STATE];
|
|
276
|
-
return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
|
|
277
|
-
}
|
|
278
|
-
var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
|
|
279
|
-
var get = (thing, prop, type = getArchtype(thing)) => (
|
|
280
|
-
// @ts-ignore
|
|
281
|
-
type === 2 ? thing.get(prop) : thing[prop]
|
|
282
|
-
);
|
|
283
|
-
var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
|
|
284
|
-
if (type === 2)
|
|
285
|
-
thing.set(propOrOldValue, value);
|
|
286
|
-
else if (type === 3) {
|
|
287
|
-
thing.add(value);
|
|
288
|
-
} else
|
|
289
|
-
thing[propOrOldValue] = value;
|
|
357
|
+
return null;
|
|
290
358
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
var isBoolean = (target) => typeof target === "boolean";
|
|
304
|
-
function isArrayIndex(value) {
|
|
305
|
-
const n = +value;
|
|
306
|
-
return Number.isInteger(n) && String(n) === value;
|
|
307
|
-
}
|
|
308
|
-
var latest = (state) => state.copy_ || state.base_;
|
|
309
|
-
var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
|
|
310
|
-
function shallowCopy(base, strict) {
|
|
311
|
-
if (isMap(base)) {
|
|
312
|
-
return new Map(base);
|
|
359
|
+
|
|
360
|
+
// src/utils/getHex.ts
|
|
361
|
+
var getHex = (value) => {
|
|
362
|
+
const rgb = getRgb(value);
|
|
363
|
+
if (!rgb) return null;
|
|
364
|
+
const toHex = (n) => {
|
|
365
|
+
const hex = Math.round(n).toString(16);
|
|
366
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
367
|
+
};
|
|
368
|
+
const hexString = `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`;
|
|
369
|
+
if (rgb.a !== void 0) {
|
|
370
|
+
return `${hexString}${toHex(rgb.a * 255)}`;
|
|
313
371
|
}
|
|
314
|
-
|
|
315
|
-
|
|
372
|
+
return hexString;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// src/utils/getBlendedColor.ts
|
|
376
|
+
var getBlendedColor = (foreground, background, alpha) => {
|
|
377
|
+
const fg = getRgb(foreground);
|
|
378
|
+
const bg = getRgb(background);
|
|
379
|
+
if (!fg || !bg) return background;
|
|
380
|
+
const safeAlpha = Math.min(1, Math.max(0, alpha));
|
|
381
|
+
const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
|
|
382
|
+
const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
|
|
383
|
+
const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
|
|
384
|
+
return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// src/utils/getTonalColor.ts
|
|
388
|
+
var getTonalColor = (color, lightness) => {
|
|
389
|
+
const rgb = getRgb(color);
|
|
390
|
+
if (!rgb) return color;
|
|
391
|
+
const r = rgb.r / 255;
|
|
392
|
+
const g = rgb.g / 255;
|
|
393
|
+
const b = rgb.b / 255;
|
|
394
|
+
const max = Math.max(r, g, b);
|
|
395
|
+
const min = Math.min(r, g, b);
|
|
396
|
+
const delta = max - min;
|
|
397
|
+
let h = 0;
|
|
398
|
+
if (delta !== 0) {
|
|
399
|
+
if (max === r) h = (g - b) / delta % 6;
|
|
400
|
+
else if (max === g) h = (b - r) / delta + 2;
|
|
401
|
+
else h = (r - g) / delta + 4;
|
|
402
|
+
h = (h * 60 + 360) % 360;
|
|
316
403
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
404
|
+
const l = (max + min) / 2;
|
|
405
|
+
const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
406
|
+
const targetL = Math.min(1, Math.max(0, lightness));
|
|
407
|
+
const c = (1 - Math.abs(2 * targetL - 1)) * s;
|
|
408
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
409
|
+
const m = targetL - c / 2;
|
|
410
|
+
let r2 = 0, g2 = 0, b2 = 0;
|
|
411
|
+
if (h < 60) {
|
|
412
|
+
r2 = c;
|
|
413
|
+
g2 = x;
|
|
414
|
+
b2 = 0;
|
|
415
|
+
} else if (h < 120) {
|
|
416
|
+
r2 = x;
|
|
417
|
+
g2 = c;
|
|
418
|
+
b2 = 0;
|
|
419
|
+
} else if (h < 180) {
|
|
420
|
+
r2 = 0;
|
|
421
|
+
g2 = c;
|
|
422
|
+
b2 = x;
|
|
423
|
+
} else if (h < 240) {
|
|
424
|
+
r2 = 0;
|
|
425
|
+
g2 = x;
|
|
426
|
+
b2 = c;
|
|
427
|
+
} else if (h < 300) {
|
|
428
|
+
r2 = x;
|
|
429
|
+
g2 = 0;
|
|
430
|
+
b2 = c;
|
|
341
431
|
} else {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
432
|
+
r2 = c;
|
|
433
|
+
g2 = 0;
|
|
434
|
+
b2 = x;
|
|
435
|
+
}
|
|
436
|
+
const toInt = (n) => Math.round((n + m) * 255);
|
|
437
|
+
return getHex(`rgb(${toInt(r2)}, ${toInt(g2)}, ${toInt(b2)})`) ?? color;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// src/utils/getTriadicPalette.ts
|
|
441
|
+
var HARMONY_OFFSETS = {
|
|
442
|
+
analogous: [1 / 12, 2 / 12],
|
|
443
|
+
complementary: [1 / 4, 1 / 2],
|
|
444
|
+
"double-split": [1 / 12, 11 / 12],
|
|
445
|
+
"split-complementary": [5 / 12, 7 / 12],
|
|
446
|
+
square: [1 / 4, 3 / 4],
|
|
447
|
+
triadic: [1 / 3, 2 / 3]
|
|
448
|
+
};
|
|
449
|
+
function getTriadicPalette(primaryColor, harmony = "split-complementary") {
|
|
450
|
+
const rgb = getRgb(primaryColor);
|
|
451
|
+
if (!rgb) throw new Error(`Invalid color format: ${primaryColor}`);
|
|
452
|
+
const r = rgb.r / 255;
|
|
453
|
+
const g = rgb.g / 255;
|
|
454
|
+
const b = rgb.b / 255;
|
|
455
|
+
const max = Math.max(r, g, b);
|
|
456
|
+
const min = Math.min(r, g, b);
|
|
457
|
+
const l = (max + min) / 2;
|
|
458
|
+
let h = 0;
|
|
459
|
+
let s = 0;
|
|
460
|
+
if (max !== min) {
|
|
461
|
+
const d = max - min;
|
|
462
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
463
|
+
switch (max) {
|
|
464
|
+
case r:
|
|
465
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
466
|
+
break;
|
|
467
|
+
case g:
|
|
468
|
+
h = ((b - r) / d + 2) / 6;
|
|
469
|
+
break;
|
|
470
|
+
case b:
|
|
471
|
+
h = ((r - g) / d + 4) / 6;
|
|
472
|
+
break;
|
|
345
473
|
}
|
|
346
|
-
const obj = O.create(proto);
|
|
347
|
-
return O.assign(obj, base);
|
|
348
474
|
}
|
|
475
|
+
const [o1, o2] = HARMONY_OFFSETS[harmony];
|
|
476
|
+
return {
|
|
477
|
+
primary: getHex(primaryColor) ?? primaryColor,
|
|
478
|
+
secondary: hslToHex((h + o1) % 1, s, l),
|
|
479
|
+
tertiary: hslToHex((h + o2) % 1, s, l)
|
|
480
|
+
};
|
|
349
481
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
482
|
+
function hslToHex(h, s, l) {
|
|
483
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
484
|
+
const x = c * (1 - Math.abs(h * 6 % 2 - 1));
|
|
485
|
+
const m = l - c / 2;
|
|
486
|
+
let r = 0;
|
|
487
|
+
let g = 0;
|
|
488
|
+
let b = 0;
|
|
489
|
+
if (h < 1 / 6) {
|
|
490
|
+
r = c;
|
|
491
|
+
g = x;
|
|
492
|
+
b = 0;
|
|
493
|
+
} else if (h < 2 / 6) {
|
|
494
|
+
r = x;
|
|
495
|
+
g = c;
|
|
496
|
+
b = 0;
|
|
497
|
+
} else if (h < 3 / 6) {
|
|
498
|
+
r = 0;
|
|
499
|
+
g = c;
|
|
500
|
+
b = x;
|
|
501
|
+
} else if (h < 4 / 6) {
|
|
502
|
+
r = 0;
|
|
503
|
+
g = x;
|
|
504
|
+
b = c;
|
|
505
|
+
} else if (h < 5 / 6) {
|
|
506
|
+
r = x;
|
|
507
|
+
g = 0;
|
|
508
|
+
b = c;
|
|
509
|
+
} else {
|
|
510
|
+
r = c;
|
|
511
|
+
g = 0;
|
|
512
|
+
b = x;
|
|
360
513
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
freeze(value, true);
|
|
367
|
-
},
|
|
368
|
-
false
|
|
369
|
-
);
|
|
370
|
-
return obj;
|
|
371
|
-
}
|
|
372
|
-
function dontMutateFrozenCollections() {
|
|
373
|
-
die(2);
|
|
514
|
+
const toHex = (value) => {
|
|
515
|
+
const hex = Math.round((value + m) * 255).toString(16);
|
|
516
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
517
|
+
};
|
|
518
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
374
519
|
}
|
|
375
|
-
|
|
376
|
-
|
|
520
|
+
|
|
521
|
+
// src/utils/isDarkColor.ts
|
|
522
|
+
var isDarkColor = (value) => {
|
|
523
|
+
const rgb = getRgb(value);
|
|
524
|
+
if (!rgb) return false;
|
|
525
|
+
const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255];
|
|
526
|
+
const [rs, gs, bs] = [r, g, b].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
|
|
527
|
+
const luminance = 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
528
|
+
return luminance < 0.5;
|
|
377
529
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
530
|
+
|
|
531
|
+
// src/useComputedTheme.ts
|
|
532
|
+
function useComputedTheme(appearance, color, harmony = "split-complementary") {
|
|
533
|
+
const [theme, setTheme] = (0, import_react5.useState)(null);
|
|
534
|
+
const computeTheme = (0, import_react5.useCallback)(() => {
|
|
535
|
+
let resolved = appearance;
|
|
536
|
+
if (resolved === "system") resolved = import_react_native3.Appearance.getColorScheme();
|
|
537
|
+
if (resolved === "no-preference" || !resolved) resolved = "light";
|
|
538
|
+
const base = resolved === "dark" ? import_react_native_paper4.MD3DarkTheme : import_react_native_paper4.MD3LightTheme;
|
|
539
|
+
const _theme = {
|
|
540
|
+
...base,
|
|
541
|
+
colors: {
|
|
542
|
+
...base.colors,
|
|
543
|
+
elevation: { ...base.colors.elevation }
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
const palette = getTriadicPalette(color, harmony);
|
|
547
|
+
const surface = base.colors.surface;
|
|
548
|
+
_theme.colors.primary = palette.primary;
|
|
549
|
+
_theme.colors.onPrimary = getTonalColor(palette.primary, isDarkColor(palette.primary) ? 0.95 : 0.08);
|
|
550
|
+
_theme.colors.primaryContainer = getBlendedColor(palette.primary, surface, 0.15);
|
|
551
|
+
_theme.colors.onPrimaryContainer = getTonalColor(palette.primary, isDarkColor(_theme.colors.primaryContainer) ? 0.92 : 0.12);
|
|
552
|
+
_theme.colors.secondary = palette.secondary;
|
|
553
|
+
_theme.colors.onSecondary = getTonalColor(palette.secondary, isDarkColor(palette.secondary) ? 0.95 : 0.08);
|
|
554
|
+
_theme.colors.secondaryContainer = getBlendedColor(palette.secondary, surface, 0.15);
|
|
555
|
+
_theme.colors.onSecondaryContainer = getTonalColor(palette.secondary, isDarkColor(_theme.colors.secondaryContainer) ? 0.92 : 0.12);
|
|
556
|
+
_theme.colors.tertiary = palette.tertiary;
|
|
557
|
+
_theme.colors.onTertiary = getTonalColor(palette.tertiary, isDarkColor(palette.tertiary) ? 0.95 : 0.08);
|
|
558
|
+
_theme.colors.tertiaryContainer = getBlendedColor(palette.tertiary, surface, 0.15);
|
|
559
|
+
_theme.colors.onTertiaryContainer = getTonalColor(palette.tertiary, isDarkColor(_theme.colors.tertiaryContainer) ? 0.92 : 0.12);
|
|
560
|
+
const blended = getBlendedColor(color, palette.secondary, 0.5);
|
|
561
|
+
const tintSurface = (alpha) => getBlendedColor(blended, surface, alpha);
|
|
562
|
+
_theme.colors.background = base.dark ? "#0F0F0F" : "#F0F0F0";
|
|
563
|
+
_theme.colors.surface = surface;
|
|
564
|
+
_theme.colors.surfaceVariant = tintSurface(0.2);
|
|
565
|
+
_theme.colors.outline = getBlendedColor(color, base.colors.outline, 0.45);
|
|
566
|
+
const grey = base.dark ? "#424242" : "#c2c2c2";
|
|
567
|
+
const blendedGrey = getBlendedColor(blended, grey, 0.05);
|
|
568
|
+
_theme.colors.elevation = {
|
|
569
|
+
..._theme.colors.elevation,
|
|
570
|
+
level1: _theme.colors.surface,
|
|
571
|
+
level2: getBlendedColor(blendedGrey, _theme.colors.surface, 0.25),
|
|
572
|
+
level3: getBlendedColor(blendedGrey, _theme.colors.surface, 0.4),
|
|
573
|
+
level4: getBlendedColor(blendedGrey, _theme.colors.surface, 0.55),
|
|
574
|
+
level5: getBlendedColor(blendedGrey, _theme.colors.surface, 0.7)
|
|
575
|
+
};
|
|
576
|
+
setTheme(_theme);
|
|
577
|
+
}, [appearance, color, harmony]);
|
|
578
|
+
(0, import_react5.useEffect)(() => {
|
|
579
|
+
computeTheme();
|
|
580
|
+
}, [computeTheme]);
|
|
581
|
+
(0, import_react5.useEffect)(() => {
|
|
582
|
+
const subscription = import_react_native3.Appearance.addChangeListener(computeTheme);
|
|
583
|
+
return subscription.remove;
|
|
584
|
+
}, [computeTheme]);
|
|
585
|
+
return theme;
|
|
382
586
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
var
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
587
|
+
|
|
588
|
+
// src/ThemeProvider.tsx
|
|
589
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
590
|
+
var NavBarContext = (0, import_react6.createContext)({});
|
|
591
|
+
var useNavBarContext = () => (0, import_react6.useContext)(NavBarContext);
|
|
592
|
+
function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
|
|
593
|
+
const [settings, setSettings] = (0, import_react6.useState)(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
594
|
+
const set2 = (0, import_react6.useCallback)(
|
|
595
|
+
(patch) => {
|
|
596
|
+
setSettings((prev) => {
|
|
597
|
+
const next = { ...prev, ...patch };
|
|
598
|
+
onChange?.(next);
|
|
599
|
+
return next;
|
|
600
|
+
});
|
|
601
|
+
},
|
|
602
|
+
[onChange]
|
|
603
|
+
);
|
|
604
|
+
const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
|
|
605
|
+
const called = (0, import_react6.useRef)(false);
|
|
606
|
+
(0, import_react6.useEffect)(() => {
|
|
607
|
+
if (theme && !called.current) {
|
|
608
|
+
called.current = true;
|
|
609
|
+
onReady?.();
|
|
610
|
+
}
|
|
611
|
+
}, [theme, onReady]);
|
|
612
|
+
if (!theme) return null;
|
|
613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ThemeSettingsContext.Provider, { value: { settings, set: set2 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native_paper5.Provider, { theme, children: [
|
|
614
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NavBarContext.Provider, { value: { onNavBarChange }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) }) })
|
|
616
|
+
] }) });
|
|
393
617
|
}
|
|
394
|
-
var
|
|
395
|
-
|
|
396
|
-
var getCurrentScope = () => currentScope;
|
|
397
|
-
var createScope = (parent_, immer_) => ({
|
|
398
|
-
drafts_: [],
|
|
399
|
-
parent_,
|
|
400
|
-
immer_,
|
|
401
|
-
// Whenever the modified draft contains a draft from another scope, we
|
|
402
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
403
|
-
canAutoFreeze_: true,
|
|
404
|
-
unfinalizedDrafts_: 0,
|
|
405
|
-
handledSet_: /* @__PURE__ */ new Set(),
|
|
406
|
-
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
407
|
-
mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
|
|
408
|
-
arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
|
|
618
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
619
|
+
flex: { flex: 1 }
|
|
409
620
|
});
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
621
|
+
|
|
622
|
+
// src/components/BottomNavigation.tsx
|
|
623
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
624
|
+
function useNavigationBarSync() {
|
|
625
|
+
const theme = (0, import_react_native_paper6.useTheme)();
|
|
626
|
+
const { onNavBarChange } = useNavBarContext();
|
|
627
|
+
(0, import_react7.useEffect)(() => {
|
|
628
|
+
if (import_react_native5.Platform.OS !== "android" || !onNavBarChange) return;
|
|
629
|
+
onNavBarChange(theme.colors.surface, theme.dark);
|
|
630
|
+
}, [theme, onNavBarChange]);
|
|
417
631
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
632
|
+
function BottomNavigationComponent(props) {
|
|
633
|
+
const defaults = usePaperDefaults();
|
|
634
|
+
useNavigationBarSync();
|
|
635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper6.BottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
422
636
|
}
|
|
423
|
-
function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
637
|
+
function Bar(props) {
|
|
638
|
+
useNavigationBarSync();
|
|
639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper6.BottomNavigation.Bar, { ...props });
|
|
427
640
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
641
|
+
BottomNavigationComponent.Bar = Bar;
|
|
642
|
+
BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation.SceneMap;
|
|
643
|
+
var BottomNavigation = BottomNavigationComponent;
|
|
644
|
+
|
|
645
|
+
// src/components/Button.tsx
|
|
646
|
+
var import_react_native_paper7 = require("react-native-paper");
|
|
647
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
648
|
+
function Button(props) {
|
|
649
|
+
const defaults = usePaperDefaults();
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper7.Button, { ...defaults.Button, ...props });
|
|
435
651
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
652
|
+
|
|
653
|
+
// src/components/Chip.tsx
|
|
654
|
+
var import_react_native_paper8 = require("react-native-paper");
|
|
655
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
656
|
+
function Chip({ variant, style, selectedColor, ...props }) {
|
|
657
|
+
const defaults = usePaperDefaults();
|
|
658
|
+
const { colors } = (0, import_react_native_paper8.useTheme)();
|
|
659
|
+
const variantStyle = variant === "primary" ? { backgroundColor: colors.primaryContainer } : variant === "secondary" ? { backgroundColor: colors.secondaryContainer } : variant === "tertiary" ? { backgroundColor: colors.tertiaryContainer } : variant === "surface" ? { backgroundColor: colors.surface } : void 0;
|
|
660
|
+
const variantSelectedColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper8.Chip, { ...defaults.Chip, selectedColor: selectedColor ?? variantSelectedColor, ...props, style: [variantStyle, style] });
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/components/ColorPicker.tsx
|
|
665
|
+
var import_react9 = require("react");
|
|
666
|
+
var import_react_native7 = require("react-native");
|
|
667
|
+
var import_react_native_paper10 = require("react-native-paper");
|
|
668
|
+
|
|
669
|
+
// src/components/Dialog.tsx
|
|
670
|
+
var import_react8 = require("react");
|
|
671
|
+
var import_react_native6 = require("react-native");
|
|
672
|
+
var import_react_native_paper9 = require("react-native-paper");
|
|
673
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
674
|
+
function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }) {
|
|
675
|
+
const blur = useBlur(blurProp);
|
|
676
|
+
const { roundness, colors } = (0, import_react_native_paper9.useTheme)();
|
|
677
|
+
const opacity = (0, import_react8.useRef)(new import_react_native6.Animated.Value(0)).current;
|
|
678
|
+
const [mounted, setMounted] = (0, import_react8.useState)(visible);
|
|
679
|
+
(0, import_react8.useEffect)(() => {
|
|
680
|
+
if (visible) {
|
|
681
|
+
setMounted(true);
|
|
682
|
+
import_react_native6.Animated.timing(opacity, { toValue: 1, duration: 200, useNativeDriver: true }).start();
|
|
683
|
+
} else {
|
|
684
|
+
import_react_native6.Animated.timing(opacity, { toValue: 0, duration: 150, useNativeDriver: true }).start(() => setMounted(false));
|
|
447
685
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
686
|
+
}, [visible]);
|
|
687
|
+
if (!blur) {
|
|
688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_paper9.Dialog, { visible, onDismiss, style, ...rest, children });
|
|
689
|
+
}
|
|
690
|
+
if (!mounted) return null;
|
|
691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_paper9.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native6.Animated.View, { style: [import_react_native6.StyleSheet.absoluteFill, { opacity }], pointerEvents: visible ? "box-none" : "none", children: [
|
|
692
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native6.TouchableWithoutFeedback, { onPress: onDismiss, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native6.View, { style: [import_react_native6.StyleSheet.absoluteFill, { backgroundColor: colors.backdrop }] }) }),
|
|
693
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native6.View, { style: styles2.wrapper, pointerEvents: "box-none", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BlurView, { style: [styles2.card, { borderRadius: roundness * 7 }], children }) })
|
|
694
|
+
] }) });
|
|
695
|
+
}
|
|
696
|
+
DialogComponent.Title = import_react_native_paper9.Dialog.Title;
|
|
697
|
+
DialogComponent.Content = import_react_native_paper9.Dialog.Content;
|
|
698
|
+
DialogComponent.Actions = import_react_native_paper9.Dialog.Actions;
|
|
699
|
+
DialogComponent.ScrollArea = import_react_native_paper9.Dialog.ScrollArea;
|
|
700
|
+
var Dialog = DialogComponent;
|
|
701
|
+
var styles2 = import_react_native6.StyleSheet.create({
|
|
702
|
+
card: { overflow: "hidden" },
|
|
703
|
+
wrapper: { flex: 1, justifyContent: "center", paddingHorizontal: 26 }
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
// src/components/ColorPicker.tsx
|
|
707
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
708
|
+
var defaultColors = [
|
|
709
|
+
{ label: "Red", value: "#f44336" },
|
|
710
|
+
{ label: "Coral", value: "#ff5722" },
|
|
711
|
+
{ label: "Orange", value: "#ff6d00" },
|
|
712
|
+
{ label: "Amber", value: "#ff9800" },
|
|
713
|
+
{ label: "Yellow", value: "#fdd835" },
|
|
714
|
+
{ label: "Lime", value: "#8bc34a" },
|
|
715
|
+
{ label: "Emerald", value: "#4caf50" },
|
|
716
|
+
{ label: "Teal", value: "#009688" },
|
|
717
|
+
{ label: "Cyan", value: "#00bcd4" },
|
|
718
|
+
{ label: "Blue", value: "#2196f3" },
|
|
719
|
+
{ label: "Indigo", value: "#3f51b5" },
|
|
720
|
+
{ label: "Deep Purple", value: "#673ab7" },
|
|
721
|
+
{ label: "Violet", value: "#9c27b0" },
|
|
722
|
+
{ label: "Magenta", value: "#d500f9" },
|
|
723
|
+
{ label: "Pink", value: "#ec407a" },
|
|
724
|
+
{ label: "Rose", value: "#e91e63" },
|
|
725
|
+
{ label: "Brown", value: "#795548" },
|
|
726
|
+
{ label: "Blue Grey", value: "#607d8b" }
|
|
727
|
+
];
|
|
728
|
+
var ColorPicker = ({ value, onChange, colors = defaultColors, blur: blurProp }) => {
|
|
729
|
+
const blur = useBlur(blurProp);
|
|
730
|
+
const [open, setOpen] = (0, import_react9.useState)(false);
|
|
731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper10.TouchableRipple, { onPress: () => setOpen(true), style: [styles3.trigger, { backgroundColor: value }], borderless: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper10.Icon, { source: "palette", size: 20, color: "white" }) }),
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Dialog, { blur, visible: open, onDismiss: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Dialog.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native7.View, { style: styles3.swatches, children: colors.map(({ value: hex }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
734
|
+
import_react_native7.TouchableOpacity,
|
|
735
|
+
{
|
|
736
|
+
onPress: () => {
|
|
737
|
+
onChange(hex);
|
|
738
|
+
setOpen(false);
|
|
739
|
+
},
|
|
740
|
+
style: [styles3.swatch, { backgroundColor: hex }, value === hex && styles3.selected],
|
|
741
|
+
children: value === hex && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper10.Icon, { source: "check", size: 20, color: "white" })
|
|
742
|
+
},
|
|
743
|
+
hex
|
|
744
|
+
)) }) }) })
|
|
745
|
+
] });
|
|
746
|
+
};
|
|
747
|
+
var styles3 = import_react_native7.StyleSheet.create({
|
|
748
|
+
selected: { borderColor: "white", borderWidth: 3 },
|
|
749
|
+
swatch: { alignItems: "center", borderRadius: 24, height: 48, justifyContent: "center", width: 48 },
|
|
750
|
+
swatches: { flexDirection: "row", flexWrap: "wrap", gap: 12, paddingTop: 12 },
|
|
751
|
+
trigger: { alignItems: "center", alignSelf: "flex-start", borderRadius: 24, height: 48, justifyContent: "center", width: 48 }
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// src/components/FAB.tsx
|
|
755
|
+
var import_react_native_paper11 = require("react-native-paper");
|
|
756
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
757
|
+
function FAB(props) {
|
|
758
|
+
const defaults = usePaperDefaults();
|
|
759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native_paper11.FAB, { ...defaults.FAB, ...props });
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// src/components/HarmonyPicker.tsx
|
|
763
|
+
var import_react10 = require("react");
|
|
764
|
+
var import_react_native_paper13 = require("react-native-paper");
|
|
765
|
+
|
|
766
|
+
// src/components/Menu.tsx
|
|
767
|
+
var import_react_native8 = require("react-native");
|
|
768
|
+
var import_react_native_paper12 = require("react-native-paper");
|
|
769
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
770
|
+
var MenuComponent = ({ blur: blurProp, children, ...props }) => {
|
|
771
|
+
const blur = useBlur(blurProp);
|
|
772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native_paper12.Menu, { ...props, contentStyle: [styles4.content, props.contentStyle], children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BlurView, { blur, children }) });
|
|
773
|
+
};
|
|
774
|
+
var Menu = Object.assign(MenuComponent, {
|
|
775
|
+
Item: import_react_native_paper12.Menu.Item
|
|
776
|
+
});
|
|
777
|
+
var styles4 = import_react_native8.StyleSheet.create({
|
|
778
|
+
content: { backgroundColor: "transparent", paddingVertical: 0 }
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
// src/components/HarmonyPicker.tsx
|
|
782
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
783
|
+
var HARMONIES = [
|
|
784
|
+
{ label: "Triadic", value: "triadic", icon: "triangle-outline" },
|
|
785
|
+
{ label: "Split", value: "split-complementary", icon: "arrow-split-vertical" },
|
|
786
|
+
{ label: "Analogous", value: "analogous", icon: "ray-end-arrow" },
|
|
787
|
+
{ label: "Square", value: "square", icon: "square-outline" },
|
|
788
|
+
{ label: "Complement", value: "complementary", icon: "circle-half-full" },
|
|
789
|
+
{ label: "Dbl Split", value: "double-split", icon: "arrow-expand-horizontal" }
|
|
790
|
+
];
|
|
791
|
+
var HarmonyPicker = ({ value, onChange, blur: blurProp }) => {
|
|
792
|
+
const blur = useBlur(blurProp);
|
|
793
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
794
|
+
const selected = HARMONIES.find((h) => h.value === value);
|
|
795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
796
|
+
Menu,
|
|
797
|
+
{
|
|
798
|
+
blur,
|
|
799
|
+
visible: open,
|
|
800
|
+
onDismiss: () => setOpen(false),
|
|
801
|
+
anchor: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_paper13.Button, { mode: "outlined", icon: selected.icon, onPress: () => setOpen(true), children: selected.label }),
|
|
802
|
+
children: HARMONIES.map((h) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
803
|
+
Menu.Item,
|
|
804
|
+
{
|
|
805
|
+
leadingIcon: h.value === value ? "check" : h.icon,
|
|
806
|
+
title: h.label,
|
|
807
|
+
onPress: () => {
|
|
808
|
+
onChange(h.value);
|
|
809
|
+
setOpen(false);
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
h.value
|
|
813
|
+
))
|
|
455
814
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
// src/components/IconButton.tsx
|
|
819
|
+
var import_react_native_paper14 = require("react-native-paper");
|
|
820
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
821
|
+
function IconButton({ variant, iconColor, containerColor, ...props }) {
|
|
822
|
+
const defaults = usePaperDefaults();
|
|
823
|
+
const { colors } = (0, import_react_native_paper14.useTheme)();
|
|
824
|
+
const variantContainerColor = variant === "primary" ? colors.primaryContainer : variant === "secondary" ? colors.secondaryContainer : variant === "tertiary" ? colors.tertiaryContainer : variant === "surface" ? colors.surface : void 0;
|
|
825
|
+
const variantIconColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_paper14.IconButton, { ...defaults.IconButton, containerColor: containerColor ?? variantContainerColor, iconColor: iconColor ?? variantIconColor, ...props });
|
|
465
827
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
828
|
+
|
|
829
|
+
// src/components/TextInput.tsx
|
|
830
|
+
var import_react11 = require("react");
|
|
831
|
+
var import_react_native_paper15 = require("react-native-paper");
|
|
832
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
833
|
+
var TextInput = (0, import_react11.forwardRef)(function TextInput2(props, ref) {
|
|
834
|
+
const defaults = usePaperDefaults();
|
|
835
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native_paper15.TextInput, { ref, ...defaults.TextInput, ...props });
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// node_modules/redux/dist/redux.mjs
|
|
839
|
+
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
840
|
+
var ActionTypes = {
|
|
841
|
+
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
842
|
+
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
843
|
+
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
844
|
+
};
|
|
845
|
+
function isPlainObject(obj) {
|
|
846
|
+
if (typeof obj !== "object" || obj === null)
|
|
847
|
+
return false;
|
|
848
|
+
let proto = obj;
|
|
849
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
850
|
+
proto = Object.getPrototypeOf(proto);
|
|
476
851
|
}
|
|
477
|
-
|
|
478
|
-
|
|
852
|
+
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
853
|
+
}
|
|
854
|
+
function compose(...funcs) {
|
|
855
|
+
if (funcs.length === 0) {
|
|
856
|
+
return (arg) => arg;
|
|
479
857
|
}
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
if (callbacks_) {
|
|
483
|
-
while (callbacks_.length > 0) {
|
|
484
|
-
const callback = callbacks_.pop();
|
|
485
|
-
callback(rootScope);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
generatePatchesAndFinalize(state, rootScope);
|
|
858
|
+
if (funcs.length === 1) {
|
|
859
|
+
return funcs[0];
|
|
489
860
|
}
|
|
490
|
-
return
|
|
861
|
+
return funcs.reduce((a, b) => (...args) => a(b(...args)));
|
|
491
862
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
|
|
863
|
+
function isAction(action) {
|
|
864
|
+
return isPlainObject(action) && "type" in action && typeof action.type === "string";
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// node_modules/immer/dist/immer.mjs
|
|
868
|
+
var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
|
|
869
|
+
var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
|
|
870
|
+
var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
|
|
871
|
+
var errors = process.env.NODE_ENV !== "production" ? [
|
|
872
|
+
// All error codes, starting by 0:
|
|
873
|
+
function(plugin) {
|
|
874
|
+
return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
|
|
875
|
+
},
|
|
876
|
+
function(thing) {
|
|
877
|
+
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}'`;
|
|
878
|
+
},
|
|
879
|
+
"This object has been frozen and should not be mutated",
|
|
880
|
+
function(data) {
|
|
881
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
|
|
882
|
+
},
|
|
883
|
+
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
884
|
+
"Immer forbids circular references",
|
|
885
|
+
"The first or second argument to `produce` must be a function",
|
|
886
|
+
"The third argument to `produce` must be a function or undefined",
|
|
887
|
+
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
888
|
+
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
889
|
+
function(thing) {
|
|
890
|
+
return `'current' expects a draft, got: ${thing}`;
|
|
891
|
+
},
|
|
892
|
+
"Object.defineProperty() cannot be used on an Immer draft",
|
|
893
|
+
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
894
|
+
"Immer only supports deleting array indices",
|
|
895
|
+
"Immer only supports setting array indices and the 'length' property",
|
|
896
|
+
function(thing) {
|
|
897
|
+
return `'original' expects a draft, got: ${thing}`;
|
|
898
|
+
}
|
|
899
|
+
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
900
|
+
// See Patches.ts for additional errors
|
|
901
|
+
] : [];
|
|
902
|
+
function die(error, ...args) {
|
|
903
|
+
if (process.env.NODE_ENV !== "production") {
|
|
904
|
+
const e = errors[error];
|
|
905
|
+
const msg = isFunction(e) ? e.apply(null, args) : e;
|
|
906
|
+
throw new Error(`[Immer] ${msg}`);
|
|
495
907
|
}
|
|
908
|
+
throw new Error(
|
|
909
|
+
`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
|
|
910
|
+
);
|
|
496
911
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
912
|
+
var O = Object;
|
|
913
|
+
var getPrototypeOf = O.getPrototypeOf;
|
|
914
|
+
var CONSTRUCTOR = "constructor";
|
|
915
|
+
var PROTOTYPE = "prototype";
|
|
916
|
+
var CONFIGURABLE = "configurable";
|
|
917
|
+
var ENUMERABLE = "enumerable";
|
|
918
|
+
var WRITABLE = "writable";
|
|
919
|
+
var VALUE = "value";
|
|
920
|
+
var isDraft = (value) => !!value && !!value[DRAFT_STATE];
|
|
921
|
+
function isDraftable(value) {
|
|
922
|
+
if (!value)
|
|
923
|
+
return false;
|
|
924
|
+
return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
500
925
|
}
|
|
501
|
-
var
|
|
502
|
-
var
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
926
|
+
var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
|
|
927
|
+
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
928
|
+
function isPlainObject2(value) {
|
|
929
|
+
if (!value || !isObjectish(value))
|
|
930
|
+
return false;
|
|
931
|
+
const proto = getPrototypeOf(value);
|
|
932
|
+
if (proto === null || proto === O[PROTOTYPE])
|
|
933
|
+
return true;
|
|
934
|
+
const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
|
|
935
|
+
if (Ctor === Object)
|
|
936
|
+
return true;
|
|
937
|
+
if (!isFunction(Ctor))
|
|
938
|
+
return false;
|
|
939
|
+
let ctorString = cachedCtorStrings.get(Ctor);
|
|
940
|
+
if (ctorString === void 0) {
|
|
941
|
+
ctorString = Function.toString.call(Ctor);
|
|
942
|
+
cachedCtorStrings.set(Ctor, ctorString);
|
|
512
943
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
944
|
+
return ctorString === objectCtorString;
|
|
945
|
+
}
|
|
946
|
+
function each(obj, iter, strict = true) {
|
|
947
|
+
if (getArchtype(obj) === 0) {
|
|
948
|
+
const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
|
|
949
|
+
keys.forEach((key) => {
|
|
950
|
+
iter(key, obj[key], obj);
|
|
521
951
|
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
for (const location of locations) {
|
|
525
|
-
set(parentCopy, location, finalizedValue, parentType);
|
|
952
|
+
} else {
|
|
953
|
+
obj.forEach((entry, index) => iter(index, entry, obj));
|
|
526
954
|
}
|
|
527
955
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
if (!state || !isSameScope(state, rootScope)) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
rootScope.mapSetPlugin_?.fixSetContents(state);
|
|
535
|
-
const finalizedValue = getFinalValue(state);
|
|
536
|
-
updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
|
|
537
|
-
generatePatchesAndFinalize(state, rootScope);
|
|
538
|
-
});
|
|
956
|
+
function getArchtype(thing) {
|
|
957
|
+
const state = thing[DRAFT_STATE];
|
|
958
|
+
return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
|
|
539
959
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
960
|
+
var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
|
|
961
|
+
var get = (thing, prop, type = getArchtype(thing)) => (
|
|
962
|
+
// @ts-ignore
|
|
963
|
+
type === 2 ? thing.get(prop) : thing[prop]
|
|
964
|
+
);
|
|
965
|
+
var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
|
|
966
|
+
if (type === 2)
|
|
967
|
+
thing.set(propOrOldValue, value);
|
|
968
|
+
else if (type === 3) {
|
|
969
|
+
thing.add(value);
|
|
970
|
+
} else
|
|
971
|
+
thing[propOrOldValue] = value;
|
|
972
|
+
};
|
|
973
|
+
function is(x, y) {
|
|
974
|
+
if (x === y) {
|
|
975
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
976
|
+
} else {
|
|
977
|
+
return x !== x && y !== y;
|
|
551
978
|
}
|
|
552
979
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
} else if (isDraftable(value)) {
|
|
565
|
-
target.callbacks_.push(function nestedDraftCleanup() {
|
|
566
|
-
const targetCopy = latest(target);
|
|
567
|
-
if (target.type_ === 3) {
|
|
568
|
-
if (targetCopy.has(value)) {
|
|
569
|
-
handleValue(value, scope_.handledSet_, scope_);
|
|
570
|
-
}
|
|
571
|
-
} else {
|
|
572
|
-
if (get(targetCopy, key, target.type_) === value) {
|
|
573
|
-
if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
|
|
574
|
-
handleValue(
|
|
575
|
-
get(target.copy_, key, target.type_),
|
|
576
|
-
scope_.handledSet_,
|
|
577
|
-
scope_
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
}
|
|
980
|
+
var isArray = Array.isArray;
|
|
981
|
+
var isMap = (target) => target instanceof Map;
|
|
982
|
+
var isSet = (target) => target instanceof Set;
|
|
983
|
+
var isObjectish = (target) => typeof target === "object";
|
|
984
|
+
var isFunction = (target) => typeof target === "function";
|
|
985
|
+
var isBoolean = (target) => typeof target === "boolean";
|
|
986
|
+
function isArrayIndex(value) {
|
|
987
|
+
const n = +value;
|
|
988
|
+
return Number.isInteger(n) && String(n) === value;
|
|
584
989
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
990
|
+
var latest = (state) => state.copy_ || state.base_;
|
|
991
|
+
var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
|
|
992
|
+
function shallowCopy(base, strict) {
|
|
993
|
+
if (isMap(base)) {
|
|
994
|
+
return new Map(base);
|
|
588
995
|
}
|
|
589
|
-
if (
|
|
590
|
-
return
|
|
996
|
+
if (isSet(base)) {
|
|
997
|
+
return new Set(base);
|
|
591
998
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
999
|
+
if (isArray(base))
|
|
1000
|
+
return Array[PROTOTYPE].slice.call(base);
|
|
1001
|
+
const isPlain = isPlainObject2(base);
|
|
1002
|
+
if (strict === true || strict === "class_only" && !isPlain) {
|
|
1003
|
+
const descriptors = O.getOwnPropertyDescriptors(base);
|
|
1004
|
+
delete descriptors[DRAFT_STATE];
|
|
1005
|
+
let keys = Reflect.ownKeys(descriptors);
|
|
1006
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1007
|
+
const key = keys[i];
|
|
1008
|
+
const desc = descriptors[key];
|
|
1009
|
+
if (desc[WRITABLE] === false) {
|
|
1010
|
+
desc[WRITABLE] = true;
|
|
1011
|
+
desc[CONFIGURABLE] = true;
|
|
600
1012
|
}
|
|
601
|
-
|
|
602
|
-
|
|
1013
|
+
if (desc.get || desc.set)
|
|
1014
|
+
descriptors[key] = {
|
|
1015
|
+
[CONFIGURABLE]: true,
|
|
1016
|
+
[WRITABLE]: true,
|
|
1017
|
+
// could live with !!desc.set as well here...
|
|
1018
|
+
[ENUMERABLE]: desc[ENUMERABLE],
|
|
1019
|
+
[VALUE]: base[key]
|
|
1020
|
+
};
|
|
603
1021
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
613
|
-
// True for both shallow and deep changes.
|
|
614
|
-
modified_: false,
|
|
615
|
-
// Used during finalization.
|
|
616
|
-
finalized_: false,
|
|
617
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
618
|
-
// actually instantiated in `prepareCopy()`
|
|
619
|
-
assigned_: void 0,
|
|
620
|
-
// The parent draft state.
|
|
621
|
-
parent_: parent,
|
|
622
|
-
// The base state.
|
|
623
|
-
base_: base,
|
|
624
|
-
// The base proxy.
|
|
625
|
-
draft_: null,
|
|
626
|
-
// set below
|
|
627
|
-
// The base copy with any updated values.
|
|
628
|
-
copy_: null,
|
|
629
|
-
// Called by the `produce` function.
|
|
630
|
-
revoke_: null,
|
|
631
|
-
isManual_: false,
|
|
632
|
-
// `callbacks` actually gets assigned in `createProxy`
|
|
633
|
-
callbacks_: void 0
|
|
634
|
-
};
|
|
635
|
-
let target = state;
|
|
636
|
-
let traps = objectTraps;
|
|
637
|
-
if (baseIsArray) {
|
|
638
|
-
target = [state];
|
|
639
|
-
traps = arrayTraps;
|
|
1022
|
+
return O.create(getPrototypeOf(base), descriptors);
|
|
1023
|
+
} else {
|
|
1024
|
+
const proto = getPrototypeOf(base);
|
|
1025
|
+
if (proto !== null && isPlain) {
|
|
1026
|
+
return { ...base };
|
|
1027
|
+
}
|
|
1028
|
+
const obj = O.create(proto);
|
|
1029
|
+
return O.assign(obj, base);
|
|
640
1030
|
}
|
|
641
|
-
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
642
|
-
state.draft_ = proxy;
|
|
643
|
-
state.revoke_ = revoke;
|
|
644
|
-
return [proxy, state];
|
|
645
1031
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
const source = latest(state);
|
|
658
|
-
if (!has(source, prop, state.type_)) {
|
|
659
|
-
return readPropFromProto(state, source, prop);
|
|
660
|
-
}
|
|
661
|
-
const value = source[prop];
|
|
662
|
-
if (state.finalized_ || !isDraftable(value)) {
|
|
663
|
-
return value;
|
|
664
|
-
}
|
|
665
|
-
if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
|
|
666
|
-
state.operationMethod
|
|
667
|
-
) && isArrayIndex(prop)) {
|
|
668
|
-
return value;
|
|
669
|
-
}
|
|
670
|
-
if (value === peek(state.base_, prop)) {
|
|
671
|
-
prepareCopy(state);
|
|
672
|
-
const childKey = state.type_ === 1 ? +prop : prop;
|
|
673
|
-
const childDraft = createProxy(state.scope_, value, state, childKey);
|
|
674
|
-
return state.copy_[childKey] = childDraft;
|
|
675
|
-
}
|
|
676
|
-
return value;
|
|
677
|
-
},
|
|
678
|
-
has(state, prop) {
|
|
679
|
-
return prop in latest(state);
|
|
680
|
-
},
|
|
681
|
-
ownKeys(state) {
|
|
682
|
-
return Reflect.ownKeys(latest(state));
|
|
683
|
-
},
|
|
684
|
-
set(state, prop, value) {
|
|
685
|
-
const desc = getDescriptorFromProto(latest(state), prop);
|
|
686
|
-
if (desc?.set) {
|
|
687
|
-
desc.set.call(state.draft_, value);
|
|
688
|
-
return true;
|
|
689
|
-
}
|
|
690
|
-
if (!state.modified_) {
|
|
691
|
-
const current2 = peek(latest(state), prop);
|
|
692
|
-
const currentState = current2?.[DRAFT_STATE];
|
|
693
|
-
if (currentState && currentState.base_ === value) {
|
|
694
|
-
state.copy_[prop] = value;
|
|
695
|
-
state.assigned_.set(prop, false);
|
|
696
|
-
return true;
|
|
697
|
-
}
|
|
698
|
-
if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
|
|
699
|
-
return true;
|
|
700
|
-
prepareCopy(state);
|
|
701
|
-
markChanged(state);
|
|
702
|
-
}
|
|
703
|
-
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
704
|
-
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
705
|
-
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
706
|
-
return true;
|
|
707
|
-
state.copy_[prop] = value;
|
|
708
|
-
state.assigned_.set(prop, true);
|
|
709
|
-
handleCrossReference(state, prop, value);
|
|
710
|
-
return true;
|
|
711
|
-
},
|
|
712
|
-
deleteProperty(state, prop) {
|
|
713
|
-
prepareCopy(state);
|
|
714
|
-
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
715
|
-
state.assigned_.set(prop, false);
|
|
716
|
-
markChanged(state);
|
|
717
|
-
} else {
|
|
718
|
-
state.assigned_.delete(prop);
|
|
719
|
-
}
|
|
720
|
-
if (state.copy_) {
|
|
721
|
-
delete state.copy_[prop];
|
|
722
|
-
}
|
|
723
|
-
return true;
|
|
724
|
-
},
|
|
725
|
-
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
726
|
-
// the same guarantee in ES5 mode.
|
|
727
|
-
getOwnPropertyDescriptor(state, prop) {
|
|
728
|
-
const owner = latest(state);
|
|
729
|
-
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
730
|
-
if (!desc)
|
|
731
|
-
return desc;
|
|
732
|
-
return {
|
|
733
|
-
[WRITABLE]: true,
|
|
734
|
-
[CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
|
|
735
|
-
[ENUMERABLE]: desc[ENUMERABLE],
|
|
736
|
-
[VALUE]: owner[prop]
|
|
737
|
-
};
|
|
738
|
-
},
|
|
739
|
-
defineProperty() {
|
|
740
|
-
die(11);
|
|
741
|
-
},
|
|
742
|
-
getPrototypeOf(state) {
|
|
743
|
-
return getPrototypeOf(state.base_);
|
|
744
|
-
},
|
|
745
|
-
setPrototypeOf() {
|
|
746
|
-
die(12);
|
|
1032
|
+
function freeze(obj, deep = false) {
|
|
1033
|
+
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
|
|
1034
|
+
return obj;
|
|
1035
|
+
if (getArchtype(obj) > 1) {
|
|
1036
|
+
O.defineProperties(obj, {
|
|
1037
|
+
set: dontMutateMethodOverride,
|
|
1038
|
+
add: dontMutateMethodOverride,
|
|
1039
|
+
clear: dontMutateMethodOverride,
|
|
1040
|
+
delete: dontMutateMethodOverride
|
|
1041
|
+
});
|
|
747
1042
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1043
|
+
O.freeze(obj);
|
|
1044
|
+
if (deep)
|
|
1045
|
+
each(
|
|
1046
|
+
obj,
|
|
1047
|
+
(_key, value) => {
|
|
1048
|
+
freeze(value, true);
|
|
1049
|
+
},
|
|
1050
|
+
false
|
|
1051
|
+
);
|
|
1052
|
+
return obj;
|
|
757
1053
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
die(13);
|
|
761
|
-
return arrayTraps.set.call(this, state, prop, void 0);
|
|
762
|
-
};
|
|
763
|
-
arrayTraps.set = function(state, prop, value) {
|
|
764
|
-
if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
|
|
765
|
-
die(14);
|
|
766
|
-
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
767
|
-
};
|
|
768
|
-
function peek(draft, prop) {
|
|
769
|
-
const state = draft[DRAFT_STATE];
|
|
770
|
-
const source = state ? latest(state) : draft;
|
|
771
|
-
return source[prop];
|
|
1054
|
+
function dontMutateFrozenCollections() {
|
|
1055
|
+
die(2);
|
|
772
1056
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
)
|
|
1057
|
+
var dontMutateMethodOverride = {
|
|
1058
|
+
[VALUE]: dontMutateFrozenCollections
|
|
1059
|
+
};
|
|
1060
|
+
function isFrozen(obj) {
|
|
1061
|
+
if (obj === null || !isObjectish(obj))
|
|
1062
|
+
return true;
|
|
1063
|
+
return O.isFrozen(obj);
|
|
780
1064
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
proto = getPrototypeOf(proto);
|
|
1065
|
+
var PluginMapSet = "MapSet";
|
|
1066
|
+
var PluginPatches = "Patches";
|
|
1067
|
+
var PluginArrayMethods = "ArrayMethods";
|
|
1068
|
+
var plugins = {};
|
|
1069
|
+
function getPlugin(pluginKey) {
|
|
1070
|
+
const plugin = plugins[pluginKey];
|
|
1071
|
+
if (!plugin) {
|
|
1072
|
+
die(0, pluginKey);
|
|
790
1073
|
}
|
|
791
|
-
return
|
|
1074
|
+
return plugin;
|
|
792
1075
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1076
|
+
var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
|
|
1077
|
+
var currentScope;
|
|
1078
|
+
var getCurrentScope = () => currentScope;
|
|
1079
|
+
var createScope = (parent_, immer_) => ({
|
|
1080
|
+
drafts_: [],
|
|
1081
|
+
parent_,
|
|
1082
|
+
immer_,
|
|
1083
|
+
// Whenever the modified draft contains a draft from another scope, we
|
|
1084
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
1085
|
+
canAutoFreeze_: true,
|
|
1086
|
+
unfinalizedDrafts_: 0,
|
|
1087
|
+
handledSet_: /* @__PURE__ */ new Set(),
|
|
1088
|
+
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
1089
|
+
mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
|
|
1090
|
+
arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
|
|
1091
|
+
});
|
|
1092
|
+
function usePatchesInScope(scope, patchListener) {
|
|
1093
|
+
if (patchListener) {
|
|
1094
|
+
scope.patchPlugin_ = getPlugin(PluginPatches);
|
|
1095
|
+
scope.patches_ = [];
|
|
1096
|
+
scope.inversePatches_ = [];
|
|
1097
|
+
scope.patchListener_ = patchListener;
|
|
799
1098
|
}
|
|
800
1099
|
}
|
|
801
|
-
function
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
state.base_,
|
|
806
|
-
state.scope_.immer_.useStrictShallowCopy_
|
|
807
|
-
);
|
|
808
|
-
}
|
|
1100
|
+
function revokeScope(scope) {
|
|
1101
|
+
leaveScope(scope);
|
|
1102
|
+
scope.drafts_.forEach(revokeDraft);
|
|
1103
|
+
scope.drafts_ = null;
|
|
809
1104
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
this.useStrictShallowCopy_ = false;
|
|
814
|
-
this.useStrictIteration_ = false;
|
|
815
|
-
this.produce = (base, recipe, patchListener) => {
|
|
816
|
-
if (isFunction(base) && !isFunction(recipe)) {
|
|
817
|
-
const defaultBase = recipe;
|
|
818
|
-
recipe = base;
|
|
819
|
-
const self = this;
|
|
820
|
-
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
821
|
-
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
if (!isFunction(recipe))
|
|
825
|
-
die(6);
|
|
826
|
-
if (patchListener !== void 0 && !isFunction(patchListener))
|
|
827
|
-
die(7);
|
|
828
|
-
let result;
|
|
829
|
-
if (isDraftable(base)) {
|
|
830
|
-
const scope = enterScope(this);
|
|
831
|
-
const proxy = createProxy(scope, base, void 0);
|
|
832
|
-
let hasError = true;
|
|
833
|
-
try {
|
|
834
|
-
result = recipe(proxy);
|
|
835
|
-
hasError = false;
|
|
836
|
-
} finally {
|
|
837
|
-
if (hasError)
|
|
838
|
-
revokeScope(scope);
|
|
839
|
-
else
|
|
840
|
-
leaveScope(scope);
|
|
841
|
-
}
|
|
842
|
-
usePatchesInScope(scope, patchListener);
|
|
843
|
-
return processResult(result, scope);
|
|
844
|
-
} else if (!base || !isObjectish(base)) {
|
|
845
|
-
result = recipe(base);
|
|
846
|
-
if (result === void 0)
|
|
847
|
-
result = base;
|
|
848
|
-
if (result === NOTHING)
|
|
849
|
-
result = void 0;
|
|
850
|
-
if (this.autoFreeze_)
|
|
851
|
-
freeze(result, true);
|
|
852
|
-
if (patchListener) {
|
|
853
|
-
const p = [];
|
|
854
|
-
const ip = [];
|
|
855
|
-
getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
|
|
856
|
-
patches_: p,
|
|
857
|
-
inversePatches_: ip
|
|
858
|
-
});
|
|
859
|
-
patchListener(p, ip);
|
|
860
|
-
}
|
|
861
|
-
return result;
|
|
862
|
-
} else
|
|
863
|
-
die(1, base);
|
|
864
|
-
};
|
|
865
|
-
this.produceWithPatches = (base, recipe) => {
|
|
866
|
-
if (isFunction(base)) {
|
|
867
|
-
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
868
|
-
}
|
|
869
|
-
let patches, inversePatches;
|
|
870
|
-
const result = this.produce(base, recipe, (p, ip) => {
|
|
871
|
-
patches = p;
|
|
872
|
-
inversePatches = ip;
|
|
873
|
-
});
|
|
874
|
-
return [result, patches, inversePatches];
|
|
875
|
-
};
|
|
876
|
-
if (isBoolean(config?.autoFreeze))
|
|
877
|
-
this.setAutoFreeze(config.autoFreeze);
|
|
878
|
-
if (isBoolean(config?.useStrictShallowCopy))
|
|
879
|
-
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
880
|
-
if (isBoolean(config?.useStrictIteration))
|
|
881
|
-
this.setUseStrictIteration(config.useStrictIteration);
|
|
882
|
-
}
|
|
883
|
-
createDraft(base) {
|
|
884
|
-
if (!isDraftable(base))
|
|
885
|
-
die(8);
|
|
886
|
-
if (isDraft(base))
|
|
887
|
-
base = current(base);
|
|
888
|
-
const scope = enterScope(this);
|
|
889
|
-
const proxy = createProxy(scope, base, void 0);
|
|
890
|
-
proxy[DRAFT_STATE].isManual_ = true;
|
|
891
|
-
leaveScope(scope);
|
|
892
|
-
return proxy;
|
|
1105
|
+
function leaveScope(scope) {
|
|
1106
|
+
if (scope === currentScope) {
|
|
1107
|
+
currentScope = scope.parent_;
|
|
893
1108
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1109
|
+
}
|
|
1110
|
+
var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
|
|
1111
|
+
function revokeDraft(draft) {
|
|
1112
|
+
const state = draft[DRAFT_STATE];
|
|
1113
|
+
if (state.type_ === 0 || state.type_ === 1)
|
|
1114
|
+
state.revoke_();
|
|
1115
|
+
else
|
|
1116
|
+
state.revoked_ = true;
|
|
1117
|
+
}
|
|
1118
|
+
function processResult(result, scope) {
|
|
1119
|
+
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
1120
|
+
const baseDraft = scope.drafts_[0];
|
|
1121
|
+
const isReplaced = result !== void 0 && result !== baseDraft;
|
|
1122
|
+
if (isReplaced) {
|
|
1123
|
+
if (baseDraft[DRAFT_STATE].modified_) {
|
|
1124
|
+
revokeScope(scope);
|
|
1125
|
+
die(4);
|
|
1126
|
+
}
|
|
1127
|
+
if (isDraftable(result)) {
|
|
1128
|
+
result = finalize(scope, result);
|
|
1129
|
+
}
|
|
1130
|
+
const { patchPlugin_ } = scope;
|
|
1131
|
+
if (patchPlugin_) {
|
|
1132
|
+
patchPlugin_.generateReplacementPatches_(
|
|
1133
|
+
baseDraft[DRAFT_STATE].base_,
|
|
1134
|
+
result,
|
|
1135
|
+
scope
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
} else {
|
|
1139
|
+
result = finalize(scope, baseDraft);
|
|
901
1140
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
*/
|
|
907
|
-
setAutoFreeze(value) {
|
|
908
|
-
this.autoFreeze_ = value;
|
|
1141
|
+
maybeFreeze(scope, result, true);
|
|
1142
|
+
revokeScope(scope);
|
|
1143
|
+
if (scope.patches_) {
|
|
1144
|
+
scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
909
1145
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1146
|
+
return result !== NOTHING ? result : void 0;
|
|
1147
|
+
}
|
|
1148
|
+
function finalize(rootScope, value) {
|
|
1149
|
+
if (isFrozen(value))
|
|
1150
|
+
return value;
|
|
1151
|
+
const state = value[DRAFT_STATE];
|
|
1152
|
+
if (!state) {
|
|
1153
|
+
const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
|
|
1154
|
+
return finalValue;
|
|
917
1155
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
* but still handles symbols for compatibility.
|
|
921
|
-
*
|
|
922
|
-
* By default, strict iteration is enabled (includes all own properties).
|
|
923
|
-
*/
|
|
924
|
-
setUseStrictIteration(value) {
|
|
925
|
-
this.useStrictIteration_ = value;
|
|
1156
|
+
if (!isSameScope(state, rootScope)) {
|
|
1157
|
+
return value;
|
|
926
1158
|
}
|
|
927
|
-
|
|
928
|
-
return
|
|
1159
|
+
if (!state.modified_) {
|
|
1160
|
+
return state.base_;
|
|
929
1161
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
break;
|
|
1162
|
+
if (!state.finalized_) {
|
|
1163
|
+
const { callbacks_ } = state;
|
|
1164
|
+
if (callbacks_) {
|
|
1165
|
+
while (callbacks_.length > 0) {
|
|
1166
|
+
const callback = callbacks_.pop();
|
|
1167
|
+
callback(rootScope);
|
|
937
1168
|
}
|
|
938
1169
|
}
|
|
939
|
-
|
|
940
|
-
patches = patches.slice(i + 1);
|
|
941
|
-
}
|
|
942
|
-
const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
|
|
943
|
-
if (isDraft(base)) {
|
|
944
|
-
return applyPatchesImpl(base, patches);
|
|
945
|
-
}
|
|
946
|
-
return this.produce(
|
|
947
|
-
base,
|
|
948
|
-
(draft) => applyPatchesImpl(draft, patches)
|
|
949
|
-
);
|
|
1170
|
+
generatePatchesAndFinalize(state, rootScope);
|
|
950
1171
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
state.callbacks_ = parent?.callbacks_ ?? [];
|
|
957
|
-
state.key_ = key;
|
|
958
|
-
if (parent && key !== void 0) {
|
|
959
|
-
registerChildFinalizationCallback(parent, state, key);
|
|
960
|
-
} else {
|
|
961
|
-
state.callbacks_.push(function rootDraftCleanup(rootScope2) {
|
|
962
|
-
rootScope2.mapSetPlugin_?.fixSetContents(state);
|
|
963
|
-
const { patchPlugin_ } = rootScope2;
|
|
964
|
-
if (state.modified_ && patchPlugin_) {
|
|
965
|
-
patchPlugin_.generatePatches_(state, [], rootScope2);
|
|
966
|
-
}
|
|
967
|
-
});
|
|
1172
|
+
return state.copy_;
|
|
1173
|
+
}
|
|
1174
|
+
function maybeFreeze(scope, value, deep = false) {
|
|
1175
|
+
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
|
|
1176
|
+
freeze(value, deep);
|
|
968
1177
|
}
|
|
969
|
-
return draft;
|
|
970
1178
|
}
|
|
971
|
-
function
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
return currentImpl(value);
|
|
1179
|
+
function markStateFinalized(state) {
|
|
1180
|
+
state.finalized_ = true;
|
|
1181
|
+
state.scope_.unfinalizedDrafts_--;
|
|
975
1182
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
if (
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
988
|
-
} else {
|
|
989
|
-
copy = shallowCopy(value, true);
|
|
1183
|
+
var isSameScope = (state, rootScope) => state.scope_ === rootScope;
|
|
1184
|
+
var EMPTY_LOCATIONS_RESULT = [];
|
|
1185
|
+
function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
|
|
1186
|
+
const parentCopy = latest(parent);
|
|
1187
|
+
const parentType = parent.type_;
|
|
1188
|
+
if (originalKey !== void 0) {
|
|
1189
|
+
const currentValue = get(parentCopy, originalKey, parentType);
|
|
1190
|
+
if (currentValue === draftValue) {
|
|
1191
|
+
set(parentCopy, originalKey, finalizedValue, parentType);
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
990
1194
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
(key,
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1195
|
+
if (!parent.draftLocations_) {
|
|
1196
|
+
const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
|
|
1197
|
+
each(parentCopy, (key, value) => {
|
|
1198
|
+
if (isDraft(value)) {
|
|
1199
|
+
const keys = draftLocations.get(value) || [];
|
|
1200
|
+
keys.push(key);
|
|
1201
|
+
draftLocations.set(value, keys);
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
|
|
1206
|
+
for (const location of locations) {
|
|
1207
|
+
set(parentCopy, location, finalizedValue, parentType);
|
|
1000
1208
|
}
|
|
1001
|
-
return copy;
|
|
1002
1209
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
let prepared = prepareAction(...args);
|
|
1024
|
-
if (!prepared) {
|
|
1025
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
|
|
1210
|
+
function registerChildFinalizationCallback(parent, child, key) {
|
|
1211
|
+
parent.callbacks_.push(function childCleanup(rootScope) {
|
|
1212
|
+
const state = child;
|
|
1213
|
+
if (!state || !isSameScope(state, rootScope)) {
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
rootScope.mapSetPlugin_?.fixSetContents(state);
|
|
1217
|
+
const finalizedValue = getFinalValue(state);
|
|
1218
|
+
updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
|
|
1219
|
+
generatePatchesAndFinalize(state, rootScope);
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
function generatePatchesAndFinalize(state, rootScope) {
|
|
1223
|
+
const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
|
|
1224
|
+
if (shouldFinalize) {
|
|
1225
|
+
const { patchPlugin_ } = rootScope;
|
|
1226
|
+
if (patchPlugin_) {
|
|
1227
|
+
const basePath = patchPlugin_.getPath(state);
|
|
1228
|
+
if (basePath) {
|
|
1229
|
+
patchPlugin_.generatePatches_(state, basePath, rootScope);
|
|
1026
1230
|
}
|
|
1027
|
-
return {
|
|
1028
|
-
type,
|
|
1029
|
-
payload: prepared.payload,
|
|
1030
|
-
..."meta" in prepared && {
|
|
1031
|
-
meta: prepared.meta
|
|
1032
|
-
},
|
|
1033
|
-
..."error" in prepared && {
|
|
1034
|
-
error: prepared.error
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
1231
|
}
|
|
1038
|
-
|
|
1039
|
-
type,
|
|
1040
|
-
payload: args[0]
|
|
1041
|
-
};
|
|
1232
|
+
markStateFinalized(state);
|
|
1042
1233
|
}
|
|
1043
|
-
actionCreator.toString = () => `${type}`;
|
|
1044
|
-
actionCreator.type = type;
|
|
1045
|
-
actionCreator.match = (action) => isAction(action) && action.type === type;
|
|
1046
|
-
return actionCreator;
|
|
1047
|
-
}
|
|
1048
|
-
function freezeDraftable(val) {
|
|
1049
|
-
return isDraftable(val) ? produce(val, () => {
|
|
1050
|
-
}) : val;
|
|
1051
|
-
}
|
|
1052
|
-
function getOrInsertComputed(map, key, compute) {
|
|
1053
|
-
if (map.has(key)) return map.get(key);
|
|
1054
|
-
return map.set(key, compute(key)).get(key);
|
|
1055
1234
|
}
|
|
1056
|
-
function
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
if (defaultCaseReducer) {
|
|
1067
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
1071
|
-
if (!type) {
|
|
1072
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
|
|
1073
|
-
}
|
|
1074
|
-
if (type in actionsMap) {
|
|
1075
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
1076
|
-
}
|
|
1077
|
-
actionsMap[type] = reducer;
|
|
1078
|
-
return builder;
|
|
1079
|
-
},
|
|
1080
|
-
addAsyncThunk(asyncThunk, reducers2) {
|
|
1081
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1082
|
-
if (defaultCaseReducer) {
|
|
1083
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
|
|
1087
|
-
if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
|
|
1088
|
-
if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
|
|
1089
|
-
if (reducers2.settled) actionMatchers.push({
|
|
1090
|
-
matcher: asyncThunk.settled,
|
|
1091
|
-
reducer: reducers2.settled
|
|
1235
|
+
function handleCrossReference(target, key, value) {
|
|
1236
|
+
const { scope_ } = target;
|
|
1237
|
+
if (isDraft(value)) {
|
|
1238
|
+
const state = value[DRAFT_STATE];
|
|
1239
|
+
if (isSameScope(state, scope_)) {
|
|
1240
|
+
state.callbacks_.push(function crossReferenceCleanup() {
|
|
1241
|
+
prepareCopy(target);
|
|
1242
|
+
const finalizedValue = getFinalValue(state);
|
|
1243
|
+
updateDraftInParent(target, value, finalizedValue, key);
|
|
1092
1244
|
});
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1245
|
+
}
|
|
1246
|
+
} else if (isDraftable(value)) {
|
|
1247
|
+
target.callbacks_.push(function nestedDraftCleanup() {
|
|
1248
|
+
const targetCopy = latest(target);
|
|
1249
|
+
if (target.type_ === 3) {
|
|
1250
|
+
if (targetCopy.has(value)) {
|
|
1251
|
+
handleValue(value, scope_.handledSet_, scope_);
|
|
1099
1252
|
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
if (defaultCaseReducer) {
|
|
1110
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
|
|
1253
|
+
} else {
|
|
1254
|
+
if (get(targetCopy, key, target.type_) === value) {
|
|
1255
|
+
if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
|
|
1256
|
+
handleValue(
|
|
1257
|
+
get(target.copy_, key, target.type_),
|
|
1258
|
+
scope_.handledSet_,
|
|
1259
|
+
scope_
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1111
1262
|
}
|
|
1112
1263
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
};
|
|
1117
|
-
builderCallback(builder);
|
|
1118
|
-
return [actionsMap, actionMatchers, defaultCaseReducer];
|
|
1119
|
-
}
|
|
1120
|
-
function isStateFunction(x) {
|
|
1121
|
-
return typeof x === "function";
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1122
1266
|
}
|
|
1123
|
-
function
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1126
|
-
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");
|
|
1127
|
-
}
|
|
1267
|
+
function handleValue(target, handledSet, rootScope) {
|
|
1268
|
+
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
1269
|
+
return target;
|
|
1128
1270
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
if (isStateFunction(initialState)) {
|
|
1132
|
-
getInitialState = () => freezeDraftable(initialState());
|
|
1133
|
-
} else {
|
|
1134
|
-
const frozenInitialState = freezeDraftable(initialState);
|
|
1135
|
-
getInitialState = () => frozenInitialState;
|
|
1271
|
+
if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
|
|
1272
|
+
return target;
|
|
1136
1273
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1274
|
+
handledSet.add(target);
|
|
1275
|
+
each(target, (key, value) => {
|
|
1276
|
+
if (isDraft(value)) {
|
|
1277
|
+
const state = value[DRAFT_STATE];
|
|
1278
|
+
if (isSameScope(state, rootScope)) {
|
|
1279
|
+
const updatedValue = getFinalValue(state);
|
|
1280
|
+
set(target, key, updatedValue, target.type_);
|
|
1281
|
+
markStateFinalized(state);
|
|
1282
|
+
}
|
|
1283
|
+
} else if (isDraftable(value)) {
|
|
1284
|
+
handleValue(value, handledSet, rootScope);
|
|
1145
1285
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1286
|
+
});
|
|
1287
|
+
return target;
|
|
1288
|
+
}
|
|
1289
|
+
function createProxyProxy(base, parent) {
|
|
1290
|
+
const baseIsArray = isArray(base);
|
|
1291
|
+
const state = {
|
|
1292
|
+
type_: baseIsArray ? 1 : 0,
|
|
1293
|
+
// Track which produce call this is associated with.
|
|
1294
|
+
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
1295
|
+
// True for both shallow and deep changes.
|
|
1296
|
+
modified_: false,
|
|
1297
|
+
// Used during finalization.
|
|
1298
|
+
finalized_: false,
|
|
1299
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
1300
|
+
// actually instantiated in `prepareCopy()`
|
|
1301
|
+
assigned_: void 0,
|
|
1302
|
+
// The parent draft state.
|
|
1303
|
+
parent_: parent,
|
|
1304
|
+
// The base state.
|
|
1305
|
+
base_: base,
|
|
1306
|
+
// The base proxy.
|
|
1307
|
+
draft_: null,
|
|
1308
|
+
// set below
|
|
1309
|
+
// The base copy with any updated values.
|
|
1310
|
+
copy_: null,
|
|
1311
|
+
// Called by the `produce` function.
|
|
1312
|
+
revoke_: null,
|
|
1313
|
+
isManual_: false,
|
|
1314
|
+
// `callbacks` actually gets assigned in `createProxy`
|
|
1315
|
+
callbacks_: void 0
|
|
1316
|
+
};
|
|
1317
|
+
let target = state;
|
|
1318
|
+
let traps = objectTraps;
|
|
1319
|
+
if (baseIsArray) {
|
|
1320
|
+
target = [state];
|
|
1321
|
+
traps = arrayTraps;
|
|
1172
1322
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1323
|
+
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
1324
|
+
state.draft_ = proxy;
|
|
1325
|
+
state.revoke_ = revoke;
|
|
1326
|
+
return [proxy, state];
|
|
1175
1327
|
}
|
|
1176
|
-
var
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1328
|
+
var objectTraps = {
|
|
1329
|
+
get(state, prop) {
|
|
1330
|
+
if (prop === DRAFT_STATE)
|
|
1331
|
+
return state;
|
|
1332
|
+
let arrayPlugin = state.scope_.arrayMethodsPlugin_;
|
|
1333
|
+
const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
|
|
1334
|
+
if (isArrayWithStringProp) {
|
|
1335
|
+
if (arrayPlugin?.isArrayOperationMethod(prop)) {
|
|
1336
|
+
return arrayPlugin.createMethodInterceptor(state, prop);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
const source = latest(state);
|
|
1340
|
+
if (!has(source, prop, state.type_)) {
|
|
1341
|
+
return readPropFromProto(state, source, prop);
|
|
1342
|
+
}
|
|
1343
|
+
const value = source[prop];
|
|
1344
|
+
if (state.finalized_ || !isDraftable(value)) {
|
|
1345
|
+
return value;
|
|
1346
|
+
}
|
|
1347
|
+
if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
|
|
1348
|
+
state.operationMethod
|
|
1349
|
+
) && isArrayIndex(prop)) {
|
|
1350
|
+
return value;
|
|
1351
|
+
}
|
|
1352
|
+
if (value === peek(state.base_, prop)) {
|
|
1353
|
+
prepareCopy(state);
|
|
1354
|
+
const childKey = state.type_ === 1 ? +prop : prop;
|
|
1355
|
+
const childDraft = createProxy(state.scope_, value, state, childKey);
|
|
1356
|
+
return state.copy_[childKey] = childDraft;
|
|
1357
|
+
}
|
|
1358
|
+
return value;
|
|
1359
|
+
},
|
|
1360
|
+
has(state, prop) {
|
|
1361
|
+
return prop in latest(state);
|
|
1362
|
+
},
|
|
1363
|
+
ownKeys(state) {
|
|
1364
|
+
return Reflect.ownKeys(latest(state));
|
|
1365
|
+
},
|
|
1366
|
+
set(state, prop, value) {
|
|
1367
|
+
const desc = getDescriptorFromProto(latest(state), prop);
|
|
1368
|
+
if (desc?.set) {
|
|
1369
|
+
desc.set.call(state.draft_, value);
|
|
1370
|
+
return true;
|
|
1371
|
+
}
|
|
1372
|
+
if (!state.modified_) {
|
|
1373
|
+
const current2 = peek(latest(state), prop);
|
|
1374
|
+
const currentState = current2?.[DRAFT_STATE];
|
|
1375
|
+
if (currentState && currentState.base_ === value) {
|
|
1376
|
+
state.copy_[prop] = value;
|
|
1377
|
+
state.assigned_.set(prop, false);
|
|
1378
|
+
return true;
|
|
1379
|
+
}
|
|
1380
|
+
if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
|
|
1381
|
+
return true;
|
|
1382
|
+
prepareCopy(state);
|
|
1383
|
+
markChanged(state);
|
|
1384
|
+
}
|
|
1385
|
+
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
1386
|
+
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
1387
|
+
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
1388
|
+
return true;
|
|
1389
|
+
state.copy_[prop] = value;
|
|
1390
|
+
state.assigned_.set(prop, true);
|
|
1391
|
+
handleCrossReference(state, prop, value);
|
|
1392
|
+
return true;
|
|
1393
|
+
},
|
|
1394
|
+
deleteProperty(state, prop) {
|
|
1395
|
+
prepareCopy(state);
|
|
1396
|
+
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
1397
|
+
state.assigned_.set(prop, false);
|
|
1398
|
+
markChanged(state);
|
|
1399
|
+
} else {
|
|
1400
|
+
state.assigned_.delete(prop);
|
|
1401
|
+
}
|
|
1402
|
+
if (state.copy_) {
|
|
1403
|
+
delete state.copy_[prop];
|
|
1404
|
+
}
|
|
1405
|
+
return true;
|
|
1406
|
+
},
|
|
1407
|
+
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
1408
|
+
// the same guarantee in ES5 mode.
|
|
1409
|
+
getOwnPropertyDescriptor(state, prop) {
|
|
1410
|
+
const owner = latest(state);
|
|
1411
|
+
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
1412
|
+
if (!desc)
|
|
1413
|
+
return desc;
|
|
1414
|
+
return {
|
|
1415
|
+
[WRITABLE]: true,
|
|
1416
|
+
[CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
|
|
1417
|
+
[ENUMERABLE]: desc[ENUMERABLE],
|
|
1418
|
+
[VALUE]: owner[prop]
|
|
1419
|
+
};
|
|
1420
|
+
},
|
|
1421
|
+
defineProperty() {
|
|
1422
|
+
die(11);
|
|
1423
|
+
},
|
|
1424
|
+
getPrototypeOf(state) {
|
|
1425
|
+
return getPrototypeOf(state.base_);
|
|
1426
|
+
},
|
|
1427
|
+
setPrototypeOf() {
|
|
1428
|
+
die(12);
|
|
1181
1429
|
}
|
|
1182
1430
|
};
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1431
|
+
var arrayTraps = {};
|
|
1432
|
+
for (let key in objectTraps) {
|
|
1433
|
+
let fn = objectTraps[key];
|
|
1434
|
+
arrayTraps[key] = function() {
|
|
1435
|
+
const args = arguments;
|
|
1436
|
+
args[0] = args[0][0];
|
|
1437
|
+
return fn.apply(this, args);
|
|
1186
1438
|
};
|
|
1187
1439
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
while (i--) {
|
|
1193
|
-
id += urlAlphabet[Math.random() * 64 | 0];
|
|
1194
|
-
}
|
|
1195
|
-
return id;
|
|
1440
|
+
arrayTraps.deleteProperty = function(state, prop) {
|
|
1441
|
+
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
|
|
1442
|
+
die(13);
|
|
1443
|
+
return arrayTraps.set.call(this, state, prop, void 0);
|
|
1196
1444
|
};
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
__publicField(this, "meta");
|
|
1202
|
-
/*
|
|
1203
|
-
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
1204
|
-
does not exist at runtime
|
|
1205
|
-
*/
|
|
1206
|
-
__publicField(this, "_type");
|
|
1207
|
-
this.payload = payload;
|
|
1208
|
-
this.meta = meta;
|
|
1209
|
-
}
|
|
1445
|
+
arrayTraps.set = function(state, prop, value) {
|
|
1446
|
+
if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
|
|
1447
|
+
die(14);
|
|
1448
|
+
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
1210
1449
|
};
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1450
|
+
function peek(draft, prop) {
|
|
1451
|
+
const state = draft[DRAFT_STATE];
|
|
1452
|
+
const source = state ? latest(state) : draft;
|
|
1453
|
+
return source[prop];
|
|
1454
|
+
}
|
|
1455
|
+
function readPropFromProto(state, source, prop) {
|
|
1456
|
+
const desc = getDescriptorFromProto(source, prop);
|
|
1457
|
+
return desc ? VALUE in desc ? desc[VALUE] : (
|
|
1458
|
+
// This is a very special case, if the prop is a getter defined by the
|
|
1459
|
+
// prototype, we should invoke it with the draft as context!
|
|
1460
|
+
desc.get?.call(state.draft_)
|
|
1461
|
+
) : void 0;
|
|
1462
|
+
}
|
|
1463
|
+
function getDescriptorFromProto(source, prop) {
|
|
1464
|
+
if (!(prop in source))
|
|
1465
|
+
return void 0;
|
|
1466
|
+
let proto = getPrototypeOf(source);
|
|
1467
|
+
while (proto) {
|
|
1468
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
1469
|
+
if (desc)
|
|
1470
|
+
return desc;
|
|
1471
|
+
proto = getPrototypeOf(proto);
|
|
1222
1472
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}
|
|
1473
|
+
return void 0;
|
|
1474
|
+
}
|
|
1475
|
+
function markChanged(state) {
|
|
1476
|
+
if (!state.modified_) {
|
|
1477
|
+
state.modified_ = true;
|
|
1478
|
+
if (state.parent_) {
|
|
1479
|
+
markChanged(state.parent_);
|
|
1231
1480
|
}
|
|
1232
|
-
return simpleError;
|
|
1233
1481
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
}
|
|
1258
|
-
}));
|
|
1259
|
-
const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
|
|
1260
|
-
payload,
|
|
1261
|
-
error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
|
|
1262
|
-
meta: {
|
|
1263
|
-
...meta || {},
|
|
1264
|
-
arg,
|
|
1265
|
-
requestId,
|
|
1266
|
-
rejectedWithValue: !!payload,
|
|
1267
|
-
requestStatus: "rejected",
|
|
1268
|
-
aborted: error?.name === "AbortError",
|
|
1269
|
-
condition: error?.name === "ConditionError"
|
|
1482
|
+
}
|
|
1483
|
+
function prepareCopy(state) {
|
|
1484
|
+
if (!state.copy_) {
|
|
1485
|
+
state.assigned_ = /* @__PURE__ */ new Map();
|
|
1486
|
+
state.copy_ = shallowCopy(
|
|
1487
|
+
state.base_,
|
|
1488
|
+
state.scope_.immer_.useStrictShallowCopy_
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
var Immer2 = class {
|
|
1493
|
+
constructor(config) {
|
|
1494
|
+
this.autoFreeze_ = true;
|
|
1495
|
+
this.useStrictShallowCopy_ = false;
|
|
1496
|
+
this.useStrictIteration_ = false;
|
|
1497
|
+
this.produce = (base, recipe, patchListener) => {
|
|
1498
|
+
if (isFunction(base) && !isFunction(recipe)) {
|
|
1499
|
+
const defaultBase = recipe;
|
|
1500
|
+
recipe = base;
|
|
1501
|
+
const self = this;
|
|
1502
|
+
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
1503
|
+
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
1504
|
+
};
|
|
1270
1505
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
let
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1506
|
+
if (!isFunction(recipe))
|
|
1507
|
+
die(6);
|
|
1508
|
+
if (patchListener !== void 0 && !isFunction(patchListener))
|
|
1509
|
+
die(7);
|
|
1510
|
+
let result;
|
|
1511
|
+
if (isDraftable(base)) {
|
|
1512
|
+
const scope = enterScope(this);
|
|
1513
|
+
const proxy = createProxy(scope, base, void 0);
|
|
1514
|
+
let hasError = true;
|
|
1515
|
+
try {
|
|
1516
|
+
result = recipe(proxy);
|
|
1517
|
+
hasError = false;
|
|
1518
|
+
} finally {
|
|
1519
|
+
if (hasError)
|
|
1520
|
+
revokeScope(scope);
|
|
1521
|
+
else
|
|
1522
|
+
leaveScope(scope);
|
|
1283
1523
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1524
|
+
usePatchesInScope(scope, patchListener);
|
|
1525
|
+
return processResult(result, scope);
|
|
1526
|
+
} else if (!base || !isObjectish(base)) {
|
|
1527
|
+
result = recipe(base);
|
|
1528
|
+
if (result === void 0)
|
|
1529
|
+
result = base;
|
|
1530
|
+
if (result === NOTHING)
|
|
1531
|
+
result = void 0;
|
|
1532
|
+
if (this.autoFreeze_)
|
|
1533
|
+
freeze(result, true);
|
|
1534
|
+
if (patchListener) {
|
|
1535
|
+
const p = [];
|
|
1536
|
+
const ip = [];
|
|
1537
|
+
getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
|
|
1538
|
+
patches_: p,
|
|
1539
|
+
inversePatches_: ip
|
|
1540
|
+
});
|
|
1541
|
+
patchListener(p, ip);
|
|
1292
1542
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
});
|
|
1315
|
-
};
|
|
1316
|
-
abortController.signal.addEventListener("abort", abortHandler, {
|
|
1317
|
-
once: true
|
|
1318
|
-
});
|
|
1319
|
-
});
|
|
1320
|
-
dispatch(pending(requestId, arg, options?.getPendingMeta?.({
|
|
1321
|
-
requestId,
|
|
1322
|
-
arg
|
|
1323
|
-
}, {
|
|
1324
|
-
getState,
|
|
1325
|
-
extra
|
|
1326
|
-
})));
|
|
1327
|
-
finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
|
|
1328
|
-
dispatch,
|
|
1329
|
-
getState,
|
|
1330
|
-
extra,
|
|
1331
|
-
requestId,
|
|
1332
|
-
signal: abortController.signal,
|
|
1333
|
-
abort,
|
|
1334
|
-
rejectWithValue: ((value, meta) => {
|
|
1335
|
-
return new RejectWithValue(value, meta);
|
|
1336
|
-
}),
|
|
1337
|
-
fulfillWithValue: ((value, meta) => {
|
|
1338
|
-
return new FulfillWithMeta(value, meta);
|
|
1339
|
-
})
|
|
1340
|
-
})).then((result) => {
|
|
1341
|
-
if (result instanceof RejectWithValue) {
|
|
1342
|
-
throw result;
|
|
1343
|
-
}
|
|
1344
|
-
if (result instanceof FulfillWithMeta) {
|
|
1345
|
-
return fulfilled(result.payload, requestId, arg, result.meta);
|
|
1346
|
-
}
|
|
1347
|
-
return fulfilled(result, requestId, arg);
|
|
1348
|
-
})]);
|
|
1349
|
-
} catch (err) {
|
|
1350
|
-
finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
|
|
1351
|
-
} finally {
|
|
1352
|
-
if (abortHandler) {
|
|
1353
|
-
abortController.signal.removeEventListener("abort", abortHandler);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
|
|
1357
|
-
if (!skipDispatch) {
|
|
1358
|
-
dispatch(finalAction);
|
|
1359
|
-
}
|
|
1360
|
-
return finalAction;
|
|
1361
|
-
})();
|
|
1362
|
-
return Object.assign(promise, {
|
|
1363
|
-
abort,
|
|
1364
|
-
requestId,
|
|
1365
|
-
arg,
|
|
1366
|
-
unwrap() {
|
|
1367
|
-
return promise.then(unwrapResult);
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
return Object.assign(actionCreator, {
|
|
1373
|
-
pending,
|
|
1374
|
-
rejected,
|
|
1375
|
-
fulfilled,
|
|
1376
|
-
settled: isAnyOf(rejected, fulfilled),
|
|
1377
|
-
typePrefix
|
|
1378
|
-
});
|
|
1543
|
+
return result;
|
|
1544
|
+
} else
|
|
1545
|
+
die(1, base);
|
|
1546
|
+
};
|
|
1547
|
+
this.produceWithPatches = (base, recipe) => {
|
|
1548
|
+
if (isFunction(base)) {
|
|
1549
|
+
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
1550
|
+
}
|
|
1551
|
+
let patches, inversePatches;
|
|
1552
|
+
const result = this.produce(base, recipe, (p, ip) => {
|
|
1553
|
+
patches = p;
|
|
1554
|
+
inversePatches = ip;
|
|
1555
|
+
});
|
|
1556
|
+
return [result, patches, inversePatches];
|
|
1557
|
+
};
|
|
1558
|
+
if (isBoolean(config?.autoFreeze))
|
|
1559
|
+
this.setAutoFreeze(config.autoFreeze);
|
|
1560
|
+
if (isBoolean(config?.useStrictShallowCopy))
|
|
1561
|
+
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
1562
|
+
if (isBoolean(config?.useStrictIteration))
|
|
1563
|
+
this.setUseStrictIteration(config.useStrictIteration);
|
|
1379
1564
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1565
|
+
createDraft(base) {
|
|
1566
|
+
if (!isDraftable(base))
|
|
1567
|
+
die(8);
|
|
1568
|
+
if (isDraft(base))
|
|
1569
|
+
base = current(base);
|
|
1570
|
+
const scope = enterScope(this);
|
|
1571
|
+
const proxy = createProxy(scope, base, void 0);
|
|
1572
|
+
proxy[DRAFT_STATE].isManual_ = true;
|
|
1573
|
+
leaveScope(scope);
|
|
1574
|
+
return proxy;
|
|
1386
1575
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1576
|
+
finishDraft(draft, patchListener) {
|
|
1577
|
+
const state = draft && draft[DRAFT_STATE];
|
|
1578
|
+
if (!state || !state.isManual_)
|
|
1579
|
+
die(9);
|
|
1580
|
+
const { scope_: scope } = state;
|
|
1581
|
+
usePatchesInScope(scope, patchListener);
|
|
1582
|
+
return processResult(void 0, scope);
|
|
1389
1583
|
}
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1584
|
+
/**
|
|
1585
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
1586
|
+
*
|
|
1587
|
+
* By default, auto-freezing is enabled.
|
|
1588
|
+
*/
|
|
1589
|
+
setAutoFreeze(value) {
|
|
1590
|
+
this.autoFreeze_ = value;
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Pass true to enable strict shallow copy.
|
|
1594
|
+
*
|
|
1595
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
1596
|
+
*/
|
|
1597
|
+
setUseStrictShallowCopy(value) {
|
|
1598
|
+
this.useStrictShallowCopy_ = value;
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
1602
|
+
* but still handles symbols for compatibility.
|
|
1603
|
+
*
|
|
1604
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
1605
|
+
*/
|
|
1606
|
+
setUseStrictIteration(value) {
|
|
1607
|
+
this.useStrictIteration_ = value;
|
|
1608
|
+
}
|
|
1609
|
+
shouldUseStrictIteration() {
|
|
1610
|
+
return this.useStrictIteration_;
|
|
1611
|
+
}
|
|
1612
|
+
applyPatches(base, patches) {
|
|
1613
|
+
let i;
|
|
1614
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
1615
|
+
const patch = patches[i];
|
|
1616
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
1617
|
+
base = patch.value;
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1413
1620
|
}
|
|
1414
|
-
if (
|
|
1415
|
-
|
|
1416
|
-
|
|
1621
|
+
if (i > -1) {
|
|
1622
|
+
patches = patches.slice(i + 1);
|
|
1623
|
+
}
|
|
1624
|
+
const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
|
|
1625
|
+
if (isDraft(base)) {
|
|
1626
|
+
return applyPatchesImpl(base, patches);
|
|
1627
|
+
}
|
|
1628
|
+
return this.produce(
|
|
1629
|
+
base,
|
|
1630
|
+
(draft) => applyPatchesImpl(draft, patches)
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
function createProxy(rootScope, value, parent, key) {
|
|
1635
|
+
const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
1636
|
+
const scope = parent?.scope_ ?? getCurrentScope();
|
|
1637
|
+
scope.drafts_.push(draft);
|
|
1638
|
+
state.callbacks_ = parent?.callbacks_ ?? [];
|
|
1639
|
+
state.key_ = key;
|
|
1640
|
+
if (parent && key !== void 0) {
|
|
1641
|
+
registerChildFinalizationCallback(parent, state, key);
|
|
1642
|
+
} else {
|
|
1643
|
+
state.callbacks_.push(function rootDraftCleanup(rootScope2) {
|
|
1644
|
+
rootScope2.mapSetPlugin_?.fixSetContents(state);
|
|
1645
|
+
const { patchPlugin_ } = rootScope2;
|
|
1646
|
+
if (state.modified_ && patchPlugin_) {
|
|
1647
|
+
patchPlugin_.generatePatches_(state, [], rootScope2);
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
return draft;
|
|
1652
|
+
}
|
|
1653
|
+
function current(value) {
|
|
1654
|
+
if (!isDraft(value))
|
|
1655
|
+
die(10, value);
|
|
1656
|
+
return currentImpl(value);
|
|
1657
|
+
}
|
|
1658
|
+
function currentImpl(value) {
|
|
1659
|
+
if (!isDraftable(value) || isFrozen(value))
|
|
1660
|
+
return value;
|
|
1661
|
+
const state = value[DRAFT_STATE];
|
|
1662
|
+
let copy;
|
|
1663
|
+
let strict = true;
|
|
1664
|
+
if (state) {
|
|
1665
|
+
if (!state.modified_)
|
|
1666
|
+
return state.base_;
|
|
1667
|
+
state.finalized_ = true;
|
|
1668
|
+
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
1669
|
+
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
1670
|
+
} else {
|
|
1671
|
+
copy = shallowCopy(value, true);
|
|
1672
|
+
}
|
|
1673
|
+
each(
|
|
1674
|
+
copy,
|
|
1675
|
+
(key, childValue) => {
|
|
1676
|
+
set(copy, key, currentImpl(childValue));
|
|
1677
|
+
},
|
|
1678
|
+
strict
|
|
1679
|
+
);
|
|
1680
|
+
if (state) {
|
|
1681
|
+
state.finalized_ = false;
|
|
1682
|
+
}
|
|
1683
|
+
return copy;
|
|
1684
|
+
}
|
|
1685
|
+
var immer = new Immer2();
|
|
1686
|
+
var produce = immer.produce;
|
|
1687
|
+
|
|
1688
|
+
// node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
|
|
1689
|
+
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
1690
|
+
if (arguments.length === 0) return void 0;
|
|
1691
|
+
if (typeof arguments[0] === "object") return compose;
|
|
1692
|
+
return compose.apply(null, arguments);
|
|
1693
|
+
};
|
|
1694
|
+
var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
|
|
1695
|
+
return function(noop3) {
|
|
1696
|
+
return noop3;
|
|
1697
|
+
};
|
|
1698
|
+
};
|
|
1699
|
+
var hasMatchFunction = (v) => {
|
|
1700
|
+
return v && typeof v.match === "function";
|
|
1701
|
+
};
|
|
1702
|
+
function createAction(type, prepareAction) {
|
|
1703
|
+
function actionCreator(...args) {
|
|
1704
|
+
if (prepareAction) {
|
|
1705
|
+
let prepared = prepareAction(...args);
|
|
1706
|
+
if (!prepared) {
|
|
1707
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
|
|
1417
1708
|
}
|
|
1709
|
+
return {
|
|
1710
|
+
type,
|
|
1711
|
+
payload: prepared.payload,
|
|
1712
|
+
..."meta" in prepared && {
|
|
1713
|
+
meta: prepared.meta
|
|
1714
|
+
},
|
|
1715
|
+
..."error" in prepared && {
|
|
1716
|
+
error: prepared.error
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1418
1719
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
sliceCaseReducersByName: {},
|
|
1423
|
-
sliceCaseReducersByType: {},
|
|
1424
|
-
actionCreators: {},
|
|
1425
|
-
sliceMatchers: []
|
|
1720
|
+
return {
|
|
1721
|
+
type,
|
|
1722
|
+
payload: args[0]
|
|
1426
1723
|
};
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1724
|
+
}
|
|
1725
|
+
actionCreator.toString = () => `${type}`;
|
|
1726
|
+
actionCreator.type = type;
|
|
1727
|
+
actionCreator.match = (action) => isAction(action) && action.type === type;
|
|
1728
|
+
return actionCreator;
|
|
1729
|
+
}
|
|
1730
|
+
function freezeDraftable(val) {
|
|
1731
|
+
return isDraftable(val) ? produce(val, () => {
|
|
1732
|
+
}) : val;
|
|
1733
|
+
}
|
|
1734
|
+
function getOrInsertComputed(map, key, compute) {
|
|
1735
|
+
if (map.has(key)) return map.get(key);
|
|
1736
|
+
return map.set(key, compute(key)).get(key);
|
|
1737
|
+
}
|
|
1738
|
+
function executeReducerBuilderCallback(builderCallback) {
|
|
1739
|
+
const actionsMap = {};
|
|
1740
|
+
const actionMatchers = [];
|
|
1741
|
+
let defaultCaseReducer;
|
|
1742
|
+
const builder = {
|
|
1743
|
+
addCase(typeOrActionCreator, reducer) {
|
|
1744
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1745
|
+
if (actionMatchers.length > 0) {
|
|
1746
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
|
|
1432
1747
|
}
|
|
1433
|
-
if (
|
|
1434
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(
|
|
1748
|
+
if (defaultCaseReducer) {
|
|
1749
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
1435
1750
|
}
|
|
1436
|
-
context.sliceCaseReducersByType[type] = reducer2;
|
|
1437
|
-
return contextMethods;
|
|
1438
|
-
},
|
|
1439
|
-
addMatcher(matcher, reducer2) {
|
|
1440
|
-
context.sliceMatchers.push({
|
|
1441
|
-
matcher,
|
|
1442
|
-
reducer: reducer2
|
|
1443
|
-
});
|
|
1444
|
-
return contextMethods;
|
|
1445
|
-
},
|
|
1446
|
-
exposeAction(name2, actionCreator) {
|
|
1447
|
-
context.actionCreators[name2] = actionCreator;
|
|
1448
|
-
return contextMethods;
|
|
1449
|
-
},
|
|
1450
|
-
exposeCaseReducer(name2, reducer2) {
|
|
1451
|
-
context.sliceCaseReducersByName[name2] = reducer2;
|
|
1452
|
-
return contextMethods;
|
|
1453
1751
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
const reducerDetails = {
|
|
1458
|
-
reducerName,
|
|
1459
|
-
type: getType(name, reducerName),
|
|
1460
|
-
createNotation: typeof options.reducers === "function"
|
|
1461
|
-
};
|
|
1462
|
-
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
|
|
1463
|
-
handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
|
1464
|
-
} else {
|
|
1465
|
-
handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
1752
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
1753
|
+
if (!type) {
|
|
1754
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
|
|
1466
1755
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1470
|
-
if (typeof options.extraReducers === "object") {
|
|
1471
|
-
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");
|
|
1472
|
-
}
|
|
1756
|
+
if (type in actionsMap) {
|
|
1757
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
1473
1758
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
return createReducer(options.initialState, (builder) => {
|
|
1480
|
-
for (let key in finalCaseReducers) {
|
|
1481
|
-
builder.addCase(key, finalCaseReducers[key]);
|
|
1482
|
-
}
|
|
1483
|
-
for (let sM of context.sliceMatchers) {
|
|
1484
|
-
builder.addMatcher(sM.matcher, sM.reducer);
|
|
1485
|
-
}
|
|
1486
|
-
for (let m of actionMatchers) {
|
|
1487
|
-
builder.addMatcher(m.matcher, m.reducer);
|
|
1488
|
-
}
|
|
1759
|
+
actionsMap[type] = reducer;
|
|
1760
|
+
return builder;
|
|
1761
|
+
},
|
|
1762
|
+
addAsyncThunk(asyncThunk, reducers2) {
|
|
1763
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1489
1764
|
if (defaultCaseReducer) {
|
|
1490
|
-
builder.addDefaultCase
|
|
1765
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
1491
1766
|
}
|
|
1767
|
+
}
|
|
1768
|
+
if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
|
|
1769
|
+
if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
|
|
1770
|
+
if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
|
|
1771
|
+
if (reducers2.settled) actionMatchers.push({
|
|
1772
|
+
matcher: asyncThunk.settled,
|
|
1773
|
+
reducer: reducers2.settled
|
|
1492
1774
|
});
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
if (!_reducer) _reducer = buildReducer();
|
|
1500
|
-
return _reducer(state, action);
|
|
1501
|
-
}
|
|
1502
|
-
function getInitialState() {
|
|
1503
|
-
if (!_reducer) _reducer = buildReducer();
|
|
1504
|
-
return _reducer.getInitialState();
|
|
1505
|
-
}
|
|
1506
|
-
function makeSelectorProps(reducerPath2, injected = false) {
|
|
1507
|
-
function selectSlice(state) {
|
|
1508
|
-
let sliceState = state[reducerPath2];
|
|
1509
|
-
if (typeof sliceState === "undefined") {
|
|
1510
|
-
if (injected) {
|
|
1511
|
-
sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
|
1512
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
1513
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
|
1514
|
-
}
|
|
1775
|
+
return builder;
|
|
1776
|
+
},
|
|
1777
|
+
addMatcher(matcher, reducer) {
|
|
1778
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1779
|
+
if (defaultCaseReducer) {
|
|
1780
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
1515
1781
|
}
|
|
1516
|
-
return sliceState;
|
|
1517
1782
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1783
|
+
actionMatchers.push({
|
|
1784
|
+
matcher,
|
|
1785
|
+
reducer
|
|
1786
|
+
});
|
|
1787
|
+
return builder;
|
|
1788
|
+
},
|
|
1789
|
+
addDefaultCase(reducer) {
|
|
1790
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1791
|
+
if (defaultCaseReducer) {
|
|
1792
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
|
|
1793
|
+
}
|
|
1527
1794
|
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
getSelectors,
|
|
1531
|
-
get selectors() {
|
|
1532
|
-
return getSelectors(selectSlice);
|
|
1533
|
-
},
|
|
1534
|
-
selectSlice
|
|
1535
|
-
};
|
|
1795
|
+
defaultCaseReducer = reducer;
|
|
1796
|
+
return builder;
|
|
1536
1797
|
}
|
|
1537
|
-
const slice = {
|
|
1538
|
-
name,
|
|
1539
|
-
reducer,
|
|
1540
|
-
actions: context.actionCreators,
|
|
1541
|
-
caseReducers: context.sliceCaseReducersByName,
|
|
1542
|
-
getInitialState,
|
|
1543
|
-
...makeSelectorProps(reducerPath),
|
|
1544
|
-
injectInto(injectable, {
|
|
1545
|
-
reducerPath: pathOpt,
|
|
1546
|
-
...config
|
|
1547
|
-
} = {}) {
|
|
1548
|
-
const newReducerPath = pathOpt ?? reducerPath;
|
|
1549
|
-
injectable.inject({
|
|
1550
|
-
reducerPath: newReducerPath,
|
|
1551
|
-
reducer
|
|
1552
|
-
}, config);
|
|
1553
|
-
return {
|
|
1554
|
-
...slice,
|
|
1555
|
-
...makeSelectorProps(newReducerPath, true)
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
};
|
|
1559
|
-
return slice;
|
|
1560
1798
|
};
|
|
1799
|
+
builderCallback(builder);
|
|
1800
|
+
return [actionsMap, actionMatchers, defaultCaseReducer];
|
|
1561
1801
|
}
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
|
|
1570
|
-
}
|
|
1802
|
+
function isStateFunction(x) {
|
|
1803
|
+
return typeof x === "function";
|
|
1804
|
+
}
|
|
1805
|
+
function createReducer(initialState, mapOrBuilderCallback) {
|
|
1806
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1807
|
+
if (typeof mapOrBuilderCallback === "object") {
|
|
1808
|
+
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");
|
|
1571
1809
|
}
|
|
1572
|
-
return selector(sliceState, ...args);
|
|
1573
1810
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
_reducerDefinitionType: "asyncThunk",
|
|
1582
|
-
payloadCreator,
|
|
1583
|
-
...config
|
|
1584
|
-
};
|
|
1811
|
+
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
|
|
1812
|
+
let getInitialState;
|
|
1813
|
+
if (isStateFunction(initialState)) {
|
|
1814
|
+
getInitialState = () => freezeDraftable(initialState());
|
|
1815
|
+
} else {
|
|
1816
|
+
const frozenInitialState = freezeDraftable(initialState);
|
|
1817
|
+
getInitialState = () => frozenInitialState;
|
|
1585
1818
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1819
|
+
function reducer(state = getInitialState(), action) {
|
|
1820
|
+
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
|
|
1821
|
+
matcher
|
|
1822
|
+
}) => matcher(action)).map(({
|
|
1823
|
+
reducer: reducer2
|
|
1824
|
+
}) => reducer2)];
|
|
1825
|
+
if (caseReducers.filter((cr) => !!cr).length === 0) {
|
|
1826
|
+
caseReducers = [finalDefaultCaseReducer];
|
|
1827
|
+
}
|
|
1828
|
+
return caseReducers.reduce((previousState, caseReducer) => {
|
|
1829
|
+
if (caseReducer) {
|
|
1830
|
+
if (isDraft(previousState)) {
|
|
1831
|
+
const draft = previousState;
|
|
1832
|
+
const result = caseReducer(draft, action);
|
|
1833
|
+
if (result === void 0) {
|
|
1834
|
+
return previousState;
|
|
1835
|
+
}
|
|
1836
|
+
return result;
|
|
1837
|
+
} else if (!isDraftable(previousState)) {
|
|
1838
|
+
const result = caseReducer(previousState, action);
|
|
1839
|
+
if (result === void 0) {
|
|
1840
|
+
if (previousState === null) {
|
|
1841
|
+
return previousState;
|
|
1842
|
+
}
|
|
1843
|
+
throw Error("A case reducer on a non-draftable value must not return undefined");
|
|
1844
|
+
}
|
|
1845
|
+
return result;
|
|
1846
|
+
} else {
|
|
1847
|
+
return produce(previousState, (draft) => {
|
|
1848
|
+
return caseReducer(draft, action);
|
|
1849
|
+
});
|
|
1594
1850
|
}
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
return {
|
|
1602
|
-
_reducerDefinitionType: "reducerWithPrepare",
|
|
1603
|
-
prepare,
|
|
1604
|
-
reducer
|
|
1605
|
-
};
|
|
1606
|
-
},
|
|
1607
|
-
asyncThunk
|
|
1608
|
-
};
|
|
1851
|
+
}
|
|
1852
|
+
return previousState;
|
|
1853
|
+
}, state);
|
|
1854
|
+
}
|
|
1855
|
+
reducer.getInitialState = getInitialState;
|
|
1856
|
+
return reducer;
|
|
1609
1857
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
createNotation
|
|
1614
|
-
}, maybeReducerWithPrepare, context) {
|
|
1615
|
-
let caseReducer;
|
|
1616
|
-
let prepareCallback;
|
|
1617
|
-
if ("reducer" in maybeReducerWithPrepare) {
|
|
1618
|
-
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
|
|
1619
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
1620
|
-
}
|
|
1621
|
-
caseReducer = maybeReducerWithPrepare.reducer;
|
|
1622
|
-
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
1858
|
+
var matches = (matcher, action) => {
|
|
1859
|
+
if (hasMatchFunction(matcher)) {
|
|
1860
|
+
return matcher.match(action);
|
|
1623
1861
|
} else {
|
|
1624
|
-
|
|
1862
|
+
return matcher(action);
|
|
1625
1863
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
}
|
|
1631
|
-
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
|
1632
|
-
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
|
|
1864
|
+
};
|
|
1865
|
+
function isAnyOf(...matchers) {
|
|
1866
|
+
return (action) => {
|
|
1867
|
+
return matchers.some((matcher) => matches(matcher, action));
|
|
1868
|
+
};
|
|
1633
1869
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
const {
|
|
1642
|
-
payloadCreator,
|
|
1643
|
-
fulfilled,
|
|
1644
|
-
pending,
|
|
1645
|
-
rejected,
|
|
1646
|
-
settled,
|
|
1647
|
-
options
|
|
1648
|
-
} = reducerDefinition;
|
|
1649
|
-
const thunk = cAT(type, payloadCreator, options);
|
|
1650
|
-
context.exposeAction(reducerName, thunk);
|
|
1651
|
-
if (fulfilled) {
|
|
1652
|
-
context.addCase(thunk.fulfilled, fulfilled);
|
|
1653
|
-
}
|
|
1654
|
-
if (pending) {
|
|
1655
|
-
context.addCase(thunk.pending, pending);
|
|
1656
|
-
}
|
|
1657
|
-
if (rejected) {
|
|
1658
|
-
context.addCase(thunk.rejected, rejected);
|
|
1870
|
+
var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
|
|
1871
|
+
var nanoid = (size = 21) => {
|
|
1872
|
+
let id = "";
|
|
1873
|
+
let i = size;
|
|
1874
|
+
while (i--) {
|
|
1875
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
1659
1876
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1877
|
+
return id;
|
|
1878
|
+
};
|
|
1879
|
+
var commonProperties = ["name", "message", "stack", "code"];
|
|
1880
|
+
var RejectWithValue = class {
|
|
1881
|
+
constructor(payload, meta) {
|
|
1882
|
+
__publicField(this, "payload");
|
|
1883
|
+
__publicField(this, "meta");
|
|
1884
|
+
/*
|
|
1885
|
+
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
1886
|
+
does not exist at runtime
|
|
1887
|
+
*/
|
|
1888
|
+
__publicField(this, "_type");
|
|
1889
|
+
this.payload = payload;
|
|
1890
|
+
this.meta = meta;
|
|
1662
1891
|
}
|
|
1663
|
-
context.exposeCaseReducer(reducerName, {
|
|
1664
|
-
fulfilled: fulfilled || noop,
|
|
1665
|
-
pending: pending || noop,
|
|
1666
|
-
rejected: rejected || noop,
|
|
1667
|
-
settled: settled || noop
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
function noop() {
|
|
1671
|
-
}
|
|
1672
|
-
var listener = "listener";
|
|
1673
|
-
var completed = "completed";
|
|
1674
|
-
var cancelled = "cancelled";
|
|
1675
|
-
var taskCancelled = `task-${cancelled}`;
|
|
1676
|
-
var taskCompleted = `task-${completed}`;
|
|
1677
|
-
var listenerCancelled = `${listener}-${cancelled}`;
|
|
1678
|
-
var listenerCompleted = `${listener}-${completed}`;
|
|
1679
|
-
var {
|
|
1680
|
-
assign
|
|
1681
|
-
} = Object;
|
|
1682
|
-
var alm = "listenerMiddleware";
|
|
1683
|
-
var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
|
|
1684
|
-
withTypes: () => addListener
|
|
1685
|
-
});
|
|
1686
|
-
var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
|
|
1687
|
-
var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
|
|
1688
|
-
withTypes: () => removeListener
|
|
1689
|
-
});
|
|
1690
|
-
function formatProdErrorMessage(code) {
|
|
1691
|
-
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. `;
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
// src/redux/themeSlice.ts
|
|
1695
|
-
var defaultInitialState = {
|
|
1696
|
-
appearance: "system",
|
|
1697
|
-
color: "#6750a4"
|
|
1698
1892
|
};
|
|
1699
|
-
var
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1893
|
+
var FulfillWithMeta = class {
|
|
1894
|
+
constructor(payload, meta) {
|
|
1895
|
+
__publicField(this, "payload");
|
|
1896
|
+
__publicField(this, "meta");
|
|
1897
|
+
/*
|
|
1898
|
+
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
1899
|
+
does not exist at runtime
|
|
1900
|
+
*/
|
|
1901
|
+
__publicField(this, "_type");
|
|
1902
|
+
this.payload = payload;
|
|
1903
|
+
this.meta = meta;
|
|
1904
|
+
}
|
|
1703
1905
|
};
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
var themeReducer = defaultSlice.reducer;
|
|
1718
|
-
var selectThemeAppearance = (state) => state.appearance;
|
|
1719
|
-
var selectThemeColor = (state) => state.color;
|
|
1720
|
-
|
|
1721
|
-
// src/ThemeProvider.tsx
|
|
1722
|
-
var import_react5 = require("react");
|
|
1723
|
-
var import_react_native4 = require("react-native");
|
|
1724
|
-
var import_react_native_paper9 = require("react-native-paper");
|
|
1725
|
-
|
|
1726
|
-
// src/useComputedTheme.ts
|
|
1727
|
-
var import_react4 = require("react");
|
|
1728
|
-
var import_react_native3 = require("react-native");
|
|
1729
|
-
var import_react_native_paper8 = require("react-native-paper");
|
|
1730
|
-
|
|
1731
|
-
// src/utils/colorNames.ts
|
|
1732
|
-
var colorNames = {
|
|
1733
|
-
aliceblue: "#f0f8ff",
|
|
1734
|
-
antiquewhite: "#faebd7",
|
|
1735
|
-
aqua: "#00ffff",
|
|
1736
|
-
aquamarine: "#7fffd4",
|
|
1737
|
-
azure: "#f0ffff",
|
|
1738
|
-
beige: "#f5f5dc",
|
|
1739
|
-
bisque: "#ffe4c4",
|
|
1740
|
-
black: "#000000",
|
|
1741
|
-
blanchedalmond: "#ffebcd",
|
|
1742
|
-
blue: "#0000ff",
|
|
1743
|
-
blueviolet: "#8a2be2",
|
|
1744
|
-
brown: "#a52a2a",
|
|
1745
|
-
burlywood: "#deb887",
|
|
1746
|
-
cadetblue: "#5f9ea0",
|
|
1747
|
-
chartreuse: "#7fff00",
|
|
1748
|
-
chocolate: "#d2691e",
|
|
1749
|
-
coral: "#ff7f50",
|
|
1750
|
-
cornflowerblue: "#6495ed",
|
|
1751
|
-
cornsilk: "#fff8dc",
|
|
1752
|
-
crimson: "#dc143c",
|
|
1753
|
-
cyan: "#00ffff",
|
|
1754
|
-
darkblue: "#00008b",
|
|
1755
|
-
darkcyan: "#008b8b",
|
|
1756
|
-
darkgoldenrod: "#b8860b",
|
|
1757
|
-
darkgray: "#a9a9a9",
|
|
1758
|
-
darkgrey: "#a9a9a9",
|
|
1759
|
-
darkgreen: "#006400",
|
|
1760
|
-
darkkhaki: "#bdb76b",
|
|
1761
|
-
darkmagenta: "#8b008b",
|
|
1762
|
-
darkolivegreen: "#556b2f",
|
|
1763
|
-
darkorange: "#ff8c00",
|
|
1764
|
-
darkorchid: "#9932cc",
|
|
1765
|
-
darkred: "#8b0000",
|
|
1766
|
-
darksalmon: "#e9967a",
|
|
1767
|
-
darkseagreen: "#8fbc8f",
|
|
1768
|
-
darkslateblue: "#483d8b",
|
|
1769
|
-
darkslategray: "#2f4f4f",
|
|
1770
|
-
darkslategrey: "#2f4f4f",
|
|
1771
|
-
darkturquoise: "#00ced1",
|
|
1772
|
-
darkviolet: "#9400d3",
|
|
1773
|
-
deeppink: "#ff1493",
|
|
1774
|
-
deepskyblue: "#00bfff",
|
|
1775
|
-
dimgray: "#696969",
|
|
1776
|
-
dimgrey: "#696969",
|
|
1777
|
-
dodgerblue: "#1e90ff",
|
|
1778
|
-
firebrick: "#b22222",
|
|
1779
|
-
floralwhite: "#fffaf0",
|
|
1780
|
-
forestgreen: "#228b22",
|
|
1781
|
-
fuchsia: "#ff00ff",
|
|
1782
|
-
gainsboro: "#dcdcdc",
|
|
1783
|
-
ghostwhite: "#f8f8ff",
|
|
1784
|
-
gold: "#ffd700",
|
|
1785
|
-
goldenrod: "#daa520",
|
|
1786
|
-
gray: "#808080",
|
|
1787
|
-
grey: "#808080",
|
|
1788
|
-
green: "#008000",
|
|
1789
|
-
greenyellow: "#adff2f",
|
|
1790
|
-
honeydew: "#f0fff0",
|
|
1791
|
-
hotpink: "#ff69b4",
|
|
1792
|
-
indianred: "#cd5c5c",
|
|
1793
|
-
indigo: "#4b0082",
|
|
1794
|
-
ivory: "#fffff0",
|
|
1795
|
-
khaki: "#f0e68c",
|
|
1796
|
-
lavender: "#e6e6fa",
|
|
1797
|
-
lavenderblush: "#fff0f5",
|
|
1798
|
-
lawngreen: "#7cfc00",
|
|
1799
|
-
lemonchiffon: "#fffacd",
|
|
1800
|
-
lightblue: "#add8e6",
|
|
1801
|
-
lightcoral: "#f08080",
|
|
1802
|
-
lightcyan: "#e0ffff",
|
|
1803
|
-
lightgoldenrodyellow: "#fafad2",
|
|
1804
|
-
lightgray: "#d3d3d3",
|
|
1805
|
-
lightgrey: "#d3d3d3",
|
|
1806
|
-
lightgreen: "#90ee90",
|
|
1807
|
-
lightpink: "#ffb6c1",
|
|
1808
|
-
lightsalmon: "#ffa07a",
|
|
1809
|
-
lightseagreen: "#20b2aa",
|
|
1810
|
-
lightskyblue: "#87cefa",
|
|
1811
|
-
lightslategray: "#778899",
|
|
1812
|
-
lightslategrey: "#778899",
|
|
1813
|
-
lightsteelblue: "#b0c4de",
|
|
1814
|
-
lightyellow: "#ffffe0",
|
|
1815
|
-
lime: "#00ff00",
|
|
1816
|
-
limegreen: "#32cd32",
|
|
1817
|
-
linen: "#faf0e6",
|
|
1818
|
-
magenta: "#ff00ff",
|
|
1819
|
-
maroon: "#800000",
|
|
1820
|
-
mediumaquamarine: "#66cdaa",
|
|
1821
|
-
mediumblue: "#0000cd",
|
|
1822
|
-
mediumorchid: "#ba55d3",
|
|
1823
|
-
mediumpurple: "#9370db",
|
|
1824
|
-
mediumseagreen: "#3cb371",
|
|
1825
|
-
mediumslateblue: "#7b68ee",
|
|
1826
|
-
mediumspringgreen: "#00fa9a",
|
|
1827
|
-
mediumturquoise: "#48d1cc",
|
|
1828
|
-
mediumvioletred: "#c71585",
|
|
1829
|
-
midnightblue: "#191970",
|
|
1830
|
-
mintcream: "#f5fffa",
|
|
1831
|
-
mistyrose: "#ffe4e1",
|
|
1832
|
-
moccasin: "#ffe4b5",
|
|
1833
|
-
navajowhite: "#ffdead",
|
|
1834
|
-
navy: "#000080",
|
|
1835
|
-
oldlace: "#fdf5e6",
|
|
1836
|
-
olive: "#808000",
|
|
1837
|
-
olivedrab: "#6b8e23",
|
|
1838
|
-
orange: "#ffa500",
|
|
1839
|
-
orangered: "#ff4500",
|
|
1840
|
-
orchid: "#da70d6",
|
|
1841
|
-
palegoldenrod: "#eee8aa",
|
|
1842
|
-
palegreen: "#98fb98",
|
|
1843
|
-
paleturquoise: "#afeeee",
|
|
1844
|
-
palevioletred: "#db7093",
|
|
1845
|
-
papayawhip: "#ffefd5",
|
|
1846
|
-
peachpuff: "#ffdab9",
|
|
1847
|
-
peru: "#cd853f",
|
|
1848
|
-
pink: "#ffc0cb",
|
|
1849
|
-
plum: "#dda0dd",
|
|
1850
|
-
powderblue: "#b0e0e6",
|
|
1851
|
-
purple: "#800080",
|
|
1852
|
-
rebeccapurple: "#663399",
|
|
1853
|
-
red: "#ff0000",
|
|
1854
|
-
rosybrown: "#bc8f8f",
|
|
1855
|
-
royalblue: "#4169e1",
|
|
1856
|
-
saddlebrown: "#8b4513",
|
|
1857
|
-
salmon: "#fa8072",
|
|
1858
|
-
sandybrown: "#f4a460",
|
|
1859
|
-
seagreen: "#2e8b57",
|
|
1860
|
-
seashell: "#fff5ee",
|
|
1861
|
-
sienna: "#a0522d",
|
|
1862
|
-
silver: "#c0c0c0",
|
|
1863
|
-
skyblue: "#87ceeb",
|
|
1864
|
-
slateblue: "#6a5acd",
|
|
1865
|
-
slategray: "#708090",
|
|
1866
|
-
slategrey: "#708090",
|
|
1867
|
-
snow: "#fffafa",
|
|
1868
|
-
springgreen: "#00ff7f",
|
|
1869
|
-
steelblue: "#4682b4",
|
|
1870
|
-
tan: "#d2b48c",
|
|
1871
|
-
teal: "#008080",
|
|
1872
|
-
thistle: "#d8bfd8",
|
|
1873
|
-
tomato: "#ff6347",
|
|
1874
|
-
transparent: "transparent",
|
|
1875
|
-
turquoise: "#40e0d0",
|
|
1876
|
-
violet: "#ee82ee",
|
|
1877
|
-
wheat: "#f5deb3",
|
|
1878
|
-
white: "#ffffff",
|
|
1879
|
-
whitesmoke: "#f5f5f5",
|
|
1880
|
-
yellow: "#ffff00",
|
|
1881
|
-
yellowgreen: "#9acd32"
|
|
1906
|
+
var miniSerializeError = (value) => {
|
|
1907
|
+
if (typeof value === "object" && value !== null) {
|
|
1908
|
+
const simpleError = {};
|
|
1909
|
+
for (const property of commonProperties) {
|
|
1910
|
+
if (typeof value[property] === "string") {
|
|
1911
|
+
simpleError[property] = value[property];
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
return simpleError;
|
|
1915
|
+
}
|
|
1916
|
+
return {
|
|
1917
|
+
message: String(value)
|
|
1918
|
+
};
|
|
1882
1919
|
};
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1920
|
+
var externalAbortMessage = "External signal was aborted";
|
|
1921
|
+
var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
1922
|
+
function createAsyncThunk2(typePrefix, payloadCreator, options) {
|
|
1923
|
+
const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
|
|
1924
|
+
payload,
|
|
1925
|
+
meta: {
|
|
1926
|
+
...meta || {},
|
|
1927
|
+
arg,
|
|
1928
|
+
requestId,
|
|
1929
|
+
requestStatus: "fulfilled"
|
|
1930
|
+
}
|
|
1931
|
+
}));
|
|
1932
|
+
const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
|
|
1933
|
+
payload: void 0,
|
|
1934
|
+
meta: {
|
|
1935
|
+
...meta || {},
|
|
1936
|
+
arg,
|
|
1937
|
+
requestId,
|
|
1938
|
+
requestStatus: "pending"
|
|
1939
|
+
}
|
|
1940
|
+
}));
|
|
1941
|
+
const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
|
|
1942
|
+
payload,
|
|
1943
|
+
error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
|
|
1944
|
+
meta: {
|
|
1945
|
+
...meta || {},
|
|
1946
|
+
arg,
|
|
1947
|
+
requestId,
|
|
1948
|
+
rejectedWithValue: !!payload,
|
|
1949
|
+
requestStatus: "rejected",
|
|
1950
|
+
aborted: error?.name === "AbortError",
|
|
1951
|
+
condition: error?.name === "ConditionError"
|
|
1952
|
+
}
|
|
1953
|
+
}));
|
|
1954
|
+
function actionCreator(arg, {
|
|
1955
|
+
signal
|
|
1956
|
+
} = {}) {
|
|
1957
|
+
return (dispatch, getState, extra) => {
|
|
1958
|
+
const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
|
|
1959
|
+
const abortController = new AbortController();
|
|
1960
|
+
let abortHandler;
|
|
1961
|
+
let abortReason;
|
|
1962
|
+
function abort(reason) {
|
|
1963
|
+
abortReason = reason;
|
|
1964
|
+
abortController.abort();
|
|
1965
|
+
}
|
|
1966
|
+
if (signal) {
|
|
1967
|
+
if (signal.aborted) {
|
|
1968
|
+
abort(externalAbortMessage);
|
|
1969
|
+
} else {
|
|
1970
|
+
signal.addEventListener("abort", () => abort(externalAbortMessage), {
|
|
1971
|
+
once: true
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
const promise = (async function() {
|
|
1976
|
+
let finalAction;
|
|
1977
|
+
try {
|
|
1978
|
+
let conditionResult = options?.condition?.(arg, {
|
|
1979
|
+
getState,
|
|
1980
|
+
extra
|
|
1981
|
+
});
|
|
1982
|
+
if (isThenable(conditionResult)) {
|
|
1983
|
+
conditionResult = await conditionResult;
|
|
1984
|
+
}
|
|
1985
|
+
if (conditionResult === false || abortController.signal.aborted) {
|
|
1986
|
+
throw {
|
|
1987
|
+
name: "ConditionError",
|
|
1988
|
+
message: "Aborted due to condition callback returning false."
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
const abortedPromise = new Promise((_, reject) => {
|
|
1992
|
+
abortHandler = () => {
|
|
1993
|
+
reject({
|
|
1994
|
+
name: "AbortError",
|
|
1995
|
+
message: abortReason || "Aborted"
|
|
1996
|
+
});
|
|
1997
|
+
};
|
|
1998
|
+
abortController.signal.addEventListener("abort", abortHandler, {
|
|
1999
|
+
once: true
|
|
2000
|
+
});
|
|
2001
|
+
});
|
|
2002
|
+
dispatch(pending(requestId, arg, options?.getPendingMeta?.({
|
|
2003
|
+
requestId,
|
|
2004
|
+
arg
|
|
2005
|
+
}, {
|
|
2006
|
+
getState,
|
|
2007
|
+
extra
|
|
2008
|
+
})));
|
|
2009
|
+
finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
|
|
2010
|
+
dispatch,
|
|
2011
|
+
getState,
|
|
2012
|
+
extra,
|
|
2013
|
+
requestId,
|
|
2014
|
+
signal: abortController.signal,
|
|
2015
|
+
abort,
|
|
2016
|
+
rejectWithValue: ((value, meta) => {
|
|
2017
|
+
return new RejectWithValue(value, meta);
|
|
2018
|
+
}),
|
|
2019
|
+
fulfillWithValue: ((value, meta) => {
|
|
2020
|
+
return new FulfillWithMeta(value, meta);
|
|
2021
|
+
})
|
|
2022
|
+
})).then((result) => {
|
|
2023
|
+
if (result instanceof RejectWithValue) {
|
|
2024
|
+
throw result;
|
|
2025
|
+
}
|
|
2026
|
+
if (result instanceof FulfillWithMeta) {
|
|
2027
|
+
return fulfilled(result.payload, requestId, arg, result.meta);
|
|
2028
|
+
}
|
|
2029
|
+
return fulfilled(result, requestId, arg);
|
|
2030
|
+
})]);
|
|
2031
|
+
} catch (err) {
|
|
2032
|
+
finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
|
|
2033
|
+
} finally {
|
|
2034
|
+
if (abortHandler) {
|
|
2035
|
+
abortController.signal.removeEventListener("abort", abortHandler);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
|
|
2039
|
+
if (!skipDispatch) {
|
|
2040
|
+
dispatch(finalAction);
|
|
2041
|
+
}
|
|
2042
|
+
return finalAction;
|
|
2043
|
+
})();
|
|
2044
|
+
return Object.assign(promise, {
|
|
2045
|
+
abort,
|
|
2046
|
+
requestId,
|
|
2047
|
+
arg,
|
|
2048
|
+
unwrap() {
|
|
2049
|
+
return promise.then(unwrapResult);
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
1905
2052
|
};
|
|
1906
2053
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
2054
|
+
return Object.assign(actionCreator, {
|
|
2055
|
+
pending,
|
|
2056
|
+
rejected,
|
|
2057
|
+
fulfilled,
|
|
2058
|
+
settled: isAnyOf(rejected, fulfilled),
|
|
2059
|
+
typePrefix
|
|
2060
|
+
});
|
|
1913
2061
|
}
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
};
|
|
1921
|
-
if (rgbMatch[4] !== void 0) {
|
|
1922
|
-
result.a = Number(rgbMatch[4]);
|
|
1923
|
-
}
|
|
1924
|
-
return result;
|
|
2062
|
+
createAsyncThunk2.withTypes = () => createAsyncThunk2;
|
|
2063
|
+
return createAsyncThunk2;
|
|
2064
|
+
})();
|
|
2065
|
+
function unwrapResult(action) {
|
|
2066
|
+
if (action.meta && action.meta.rejectedWithValue) {
|
|
2067
|
+
throw action.payload;
|
|
1925
2068
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
// src/utils/getHex.ts
|
|
1930
|
-
var getHex = (value) => {
|
|
1931
|
-
const rgb = getRgb(value);
|
|
1932
|
-
if (!rgb) return null;
|
|
1933
|
-
const toHex = (n) => {
|
|
1934
|
-
const hex = Math.round(n).toString(16);
|
|
1935
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
1936
|
-
};
|
|
1937
|
-
const hexString = `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`;
|
|
1938
|
-
if (rgb.a !== void 0) {
|
|
1939
|
-
return `${hexString}${toHex(rgb.a * 255)}`;
|
|
2069
|
+
if (action.error) {
|
|
2070
|
+
throw action.error;
|
|
1940
2071
|
}
|
|
1941
|
-
return
|
|
1942
|
-
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
const safeAlpha = Math.min(1, Math.max(0, alpha));
|
|
1950
|
-
const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
|
|
1951
|
-
const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
|
|
1952
|
-
const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
|
|
1953
|
-
return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
|
|
2072
|
+
return action.payload;
|
|
2073
|
+
}
|
|
2074
|
+
function isThenable(value) {
|
|
2075
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2076
|
+
}
|
|
2077
|
+
var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
|
|
2078
|
+
var asyncThunkCreator = {
|
|
2079
|
+
[asyncThunkSymbol]: createAsyncThunk
|
|
1954
2080
|
};
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2081
|
+
function getType(slice, actionKey) {
|
|
2082
|
+
return `${slice}/${actionKey}`;
|
|
2083
|
+
}
|
|
2084
|
+
function buildCreateSlice({
|
|
2085
|
+
creators
|
|
2086
|
+
} = {}) {
|
|
2087
|
+
const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
|
|
2088
|
+
return function createSlice2(options) {
|
|
2089
|
+
const {
|
|
2090
|
+
name,
|
|
2091
|
+
reducerPath = name
|
|
2092
|
+
} = options;
|
|
2093
|
+
if (!name) {
|
|
2094
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
|
|
2095
|
+
}
|
|
2096
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
2097
|
+
if (options.initialState === void 0) {
|
|
2098
|
+
console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
|
|
2102
|
+
const reducerNames = Object.keys(reducers2);
|
|
2103
|
+
const context = {
|
|
2104
|
+
sliceCaseReducersByName: {},
|
|
2105
|
+
sliceCaseReducersByType: {},
|
|
2106
|
+
actionCreators: {},
|
|
2107
|
+
sliceMatchers: []
|
|
2108
|
+
};
|
|
2109
|
+
const contextMethods = {
|
|
2110
|
+
addCase(typeOrActionCreator, reducer2) {
|
|
2111
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
2112
|
+
if (!type) {
|
|
2113
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
|
|
2114
|
+
}
|
|
2115
|
+
if (type in context.sliceCaseReducersByType) {
|
|
2116
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
|
2117
|
+
}
|
|
2118
|
+
context.sliceCaseReducersByType[type] = reducer2;
|
|
2119
|
+
return contextMethods;
|
|
2120
|
+
},
|
|
2121
|
+
addMatcher(matcher, reducer2) {
|
|
2122
|
+
context.sliceMatchers.push({
|
|
2123
|
+
matcher,
|
|
2124
|
+
reducer: reducer2
|
|
2125
|
+
});
|
|
2126
|
+
return contextMethods;
|
|
2127
|
+
},
|
|
2128
|
+
exposeAction(name2, actionCreator) {
|
|
2129
|
+
context.actionCreators[name2] = actionCreator;
|
|
2130
|
+
return contextMethods;
|
|
2131
|
+
},
|
|
2132
|
+
exposeCaseReducer(name2, reducer2) {
|
|
2133
|
+
context.sliceCaseReducersByName[name2] = reducer2;
|
|
2134
|
+
return contextMethods;
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
reducerNames.forEach((reducerName) => {
|
|
2138
|
+
const reducerDefinition = reducers2[reducerName];
|
|
2139
|
+
const reducerDetails = {
|
|
2140
|
+
reducerName,
|
|
2141
|
+
type: getType(name, reducerName),
|
|
2142
|
+
createNotation: typeof options.reducers === "function"
|
|
2143
|
+
};
|
|
2144
|
+
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
|
|
2145
|
+
handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
|
2146
|
+
} else {
|
|
2147
|
+
handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
function buildReducer() {
|
|
2151
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2152
|
+
if (typeof options.extraReducers === "object") {
|
|
2153
|
+
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");
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
|
|
2157
|
+
const finalCaseReducers = {
|
|
2158
|
+
...extraReducers,
|
|
2159
|
+
...context.sliceCaseReducersByType
|
|
2160
|
+
};
|
|
2161
|
+
return createReducer(options.initialState, (builder) => {
|
|
2162
|
+
for (let key in finalCaseReducers) {
|
|
2163
|
+
builder.addCase(key, finalCaseReducers[key]);
|
|
2164
|
+
}
|
|
2165
|
+
for (let sM of context.sliceMatchers) {
|
|
2166
|
+
builder.addMatcher(sM.matcher, sM.reducer);
|
|
2167
|
+
}
|
|
2168
|
+
for (let m of actionMatchers) {
|
|
2169
|
+
builder.addMatcher(m.matcher, m.reducer);
|
|
2170
|
+
}
|
|
2171
|
+
if (defaultCaseReducer) {
|
|
2172
|
+
builder.addDefaultCase(defaultCaseReducer);
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
const selectSelf = (state) => state;
|
|
2177
|
+
const injectedSelectorCache = /* @__PURE__ */ new Map();
|
|
2178
|
+
const injectedStateCache = /* @__PURE__ */ new WeakMap();
|
|
2179
|
+
let _reducer;
|
|
2180
|
+
function reducer(state, action) {
|
|
2181
|
+
if (!_reducer) _reducer = buildReducer();
|
|
2182
|
+
return _reducer(state, action);
|
|
2183
|
+
}
|
|
2184
|
+
function getInitialState() {
|
|
2185
|
+
if (!_reducer) _reducer = buildReducer();
|
|
2186
|
+
return _reducer.getInitialState();
|
|
2187
|
+
}
|
|
2188
|
+
function makeSelectorProps(reducerPath2, injected = false) {
|
|
2189
|
+
function selectSlice(state) {
|
|
2190
|
+
let sliceState = state[reducerPath2];
|
|
2191
|
+
if (typeof sliceState === "undefined") {
|
|
2192
|
+
if (injected) {
|
|
2193
|
+
sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
|
2194
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
2195
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
return sliceState;
|
|
2199
|
+
}
|
|
2200
|
+
function getSelectors(selectState = selectSelf) {
|
|
2201
|
+
const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
|
|
2202
|
+
return getOrInsertComputed(selectorCache, selectState, () => {
|
|
2203
|
+
const map = {};
|
|
2204
|
+
for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
|
|
2205
|
+
map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
|
2206
|
+
}
|
|
2207
|
+
return map;
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
return {
|
|
2211
|
+
reducerPath: reducerPath2,
|
|
2212
|
+
getSelectors,
|
|
2213
|
+
get selectors() {
|
|
2214
|
+
return getSelectors(selectSlice);
|
|
2215
|
+
},
|
|
2216
|
+
selectSlice
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
const slice = {
|
|
2220
|
+
name,
|
|
2221
|
+
reducer,
|
|
2222
|
+
actions: context.actionCreators,
|
|
2223
|
+
caseReducers: context.sliceCaseReducersByName,
|
|
2224
|
+
getInitialState,
|
|
2225
|
+
...makeSelectorProps(reducerPath),
|
|
2226
|
+
injectInto(injectable, {
|
|
2227
|
+
reducerPath: pathOpt,
|
|
2228
|
+
...config
|
|
2229
|
+
} = {}) {
|
|
2230
|
+
const newReducerPath = pathOpt ?? reducerPath;
|
|
2231
|
+
injectable.inject({
|
|
2232
|
+
reducerPath: newReducerPath,
|
|
2233
|
+
reducer
|
|
2234
|
+
}, config);
|
|
2235
|
+
return {
|
|
2236
|
+
...slice,
|
|
2237
|
+
...makeSelectorProps(newReducerPath, true)
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
return slice;
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
function wrapSelector(selector, selectState, getInitialState, injected) {
|
|
2245
|
+
function wrapper(rootState, ...args) {
|
|
2246
|
+
let sliceState = selectState(rootState);
|
|
2247
|
+
if (typeof sliceState === "undefined") {
|
|
2248
|
+
if (injected) {
|
|
2249
|
+
sliceState = getInitialState();
|
|
2250
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
2251
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
|
|
2252
|
+
}
|
|
1981
2253
|
}
|
|
2254
|
+
return selector(sliceState, ...args);
|
|
2255
|
+
}
|
|
2256
|
+
wrapper.unwrapped = selector;
|
|
2257
|
+
return wrapper;
|
|
2258
|
+
}
|
|
2259
|
+
var createSlice = /* @__PURE__ */ buildCreateSlice();
|
|
2260
|
+
function buildReducerCreators() {
|
|
2261
|
+
function asyncThunk(payloadCreator, config) {
|
|
2262
|
+
return {
|
|
2263
|
+
_reducerDefinitionType: "asyncThunk",
|
|
2264
|
+
payloadCreator,
|
|
2265
|
+
...config
|
|
2266
|
+
};
|
|
1982
2267
|
}
|
|
2268
|
+
asyncThunk.withTypes = () => asyncThunk;
|
|
1983
2269
|
return {
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2270
|
+
reducer(caseReducer) {
|
|
2271
|
+
return Object.assign({
|
|
2272
|
+
// hack so the wrapping function has the same name as the original
|
|
2273
|
+
// we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
|
|
2274
|
+
[caseReducer.name](...args) {
|
|
2275
|
+
return caseReducer(...args);
|
|
2276
|
+
}
|
|
2277
|
+
}[caseReducer.name], {
|
|
2278
|
+
_reducerDefinitionType: "reducer"
|
|
2279
|
+
/* reducer */
|
|
2280
|
+
});
|
|
2281
|
+
},
|
|
2282
|
+
preparedReducer(prepare, reducer) {
|
|
2283
|
+
return {
|
|
2284
|
+
_reducerDefinitionType: "reducerWithPrepare",
|
|
2285
|
+
prepare,
|
|
2286
|
+
reducer
|
|
2287
|
+
};
|
|
2288
|
+
},
|
|
2289
|
+
asyncThunk
|
|
1987
2290
|
};
|
|
1988
2291
|
}
|
|
1989
|
-
function
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
let
|
|
1995
|
-
let
|
|
1996
|
-
if (
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
g = c;
|
|
2003
|
-
b = 0;
|
|
2004
|
-
} else if (h < 3 / 6) {
|
|
2005
|
-
r = 0;
|
|
2006
|
-
g = c;
|
|
2007
|
-
b = x;
|
|
2008
|
-
} else if (h < 4 / 6) {
|
|
2009
|
-
r = 0;
|
|
2010
|
-
g = x;
|
|
2011
|
-
b = c;
|
|
2012
|
-
} else if (h < 5 / 6) {
|
|
2013
|
-
r = x;
|
|
2014
|
-
g = 0;
|
|
2015
|
-
b = c;
|
|
2292
|
+
function handleNormalReducerDefinition({
|
|
2293
|
+
type,
|
|
2294
|
+
reducerName,
|
|
2295
|
+
createNotation
|
|
2296
|
+
}, maybeReducerWithPrepare, context) {
|
|
2297
|
+
let caseReducer;
|
|
2298
|
+
let prepareCallback;
|
|
2299
|
+
if ("reducer" in maybeReducerWithPrepare) {
|
|
2300
|
+
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
|
|
2301
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
2302
|
+
}
|
|
2303
|
+
caseReducer = maybeReducerWithPrepare.reducer;
|
|
2304
|
+
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
2016
2305
|
} else {
|
|
2017
|
-
|
|
2018
|
-
g = 0;
|
|
2019
|
-
b = x;
|
|
2306
|
+
caseReducer = maybeReducerWithPrepare;
|
|
2020
2307
|
}
|
|
2021
|
-
|
|
2022
|
-
const hex = Math.round((value + m) * 255).toString(16);
|
|
2023
|
-
return hex.length === 1 ? `0${hex}` : hex;
|
|
2024
|
-
};
|
|
2025
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
2308
|
+
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
|
2026
2309
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
}
|
|
2091
|
-
return theme;
|
|
2310
|
+
function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
|
2311
|
+
return reducerDefinition._reducerDefinitionType === "asyncThunk";
|
|
2312
|
+
}
|
|
2313
|
+
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
|
2314
|
+
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
|
|
2315
|
+
}
|
|
2316
|
+
function handleThunkCaseReducerDefinition({
|
|
2317
|
+
type,
|
|
2318
|
+
reducerName
|
|
2319
|
+
}, reducerDefinition, context, cAT) {
|
|
2320
|
+
if (!cAT) {
|
|
2321
|
+
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`.");
|
|
2322
|
+
}
|
|
2323
|
+
const {
|
|
2324
|
+
payloadCreator,
|
|
2325
|
+
fulfilled,
|
|
2326
|
+
pending,
|
|
2327
|
+
rejected,
|
|
2328
|
+
settled,
|
|
2329
|
+
options
|
|
2330
|
+
} = reducerDefinition;
|
|
2331
|
+
const thunk = cAT(type, payloadCreator, options);
|
|
2332
|
+
context.exposeAction(reducerName, thunk);
|
|
2333
|
+
if (fulfilled) {
|
|
2334
|
+
context.addCase(thunk.fulfilled, fulfilled);
|
|
2335
|
+
}
|
|
2336
|
+
if (pending) {
|
|
2337
|
+
context.addCase(thunk.pending, pending);
|
|
2338
|
+
}
|
|
2339
|
+
if (rejected) {
|
|
2340
|
+
context.addCase(thunk.rejected, rejected);
|
|
2341
|
+
}
|
|
2342
|
+
if (settled) {
|
|
2343
|
+
context.addMatcher(thunk.settled, settled);
|
|
2344
|
+
}
|
|
2345
|
+
context.exposeCaseReducer(reducerName, {
|
|
2346
|
+
fulfilled: fulfilled || noop,
|
|
2347
|
+
pending: pending || noop,
|
|
2348
|
+
rejected: rejected || noop,
|
|
2349
|
+
settled: settled || noop
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
function noop() {
|
|
2353
|
+
}
|
|
2354
|
+
var listener = "listener";
|
|
2355
|
+
var completed = "completed";
|
|
2356
|
+
var cancelled = "cancelled";
|
|
2357
|
+
var taskCancelled = `task-${cancelled}`;
|
|
2358
|
+
var taskCompleted = `task-${completed}`;
|
|
2359
|
+
var listenerCancelled = `${listener}-${cancelled}`;
|
|
2360
|
+
var listenerCompleted = `${listener}-${completed}`;
|
|
2361
|
+
var {
|
|
2362
|
+
assign
|
|
2363
|
+
} = Object;
|
|
2364
|
+
var alm = "listenerMiddleware";
|
|
2365
|
+
var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
|
|
2366
|
+
withTypes: () => addListener
|
|
2367
|
+
});
|
|
2368
|
+
var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
|
|
2369
|
+
var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
|
|
2370
|
+
withTypes: () => removeListener
|
|
2371
|
+
});
|
|
2372
|
+
function formatProdErrorMessage(code) {
|
|
2373
|
+
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. `;
|
|
2092
2374
|
}
|
|
2093
2375
|
|
|
2094
|
-
// src/
|
|
2095
|
-
var
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2376
|
+
// src/redux/themeSlice.ts
|
|
2377
|
+
var defaultInitialState = {
|
|
2378
|
+
appearance: "system",
|
|
2379
|
+
blur: true,
|
|
2380
|
+
color: "#6750a4",
|
|
2381
|
+
harmony: "split-complementary"
|
|
2382
|
+
};
|
|
2383
|
+
var reducers = {
|
|
2384
|
+
initialize: (state, action) => ({ ...state, ...action.payload }),
|
|
2385
|
+
setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
|
|
2386
|
+
setBlur: (state, action) => ({ ...state, blur: action.payload }),
|
|
2387
|
+
setColor: (state, action) => ({ ...state, color: action.payload }),
|
|
2388
|
+
setHarmony: (state, action) => ({ ...state, harmony: action.payload })
|
|
2389
|
+
};
|
|
2390
|
+
function createThemeReducer(initialState) {
|
|
2391
|
+
return createSlice({
|
|
2392
|
+
name: "theme",
|
|
2393
|
+
initialState: { ...defaultInitialState, ...initialState },
|
|
2394
|
+
reducers
|
|
2395
|
+
}).reducer;
|
|
2110
2396
|
}
|
|
2111
|
-
var
|
|
2112
|
-
|
|
2397
|
+
var defaultSlice = createSlice({
|
|
2398
|
+
name: "theme",
|
|
2399
|
+
initialState: defaultInitialState,
|
|
2400
|
+
reducers
|
|
2113
2401
|
});
|
|
2402
|
+
var themeActions = defaultSlice.actions;
|
|
2403
|
+
var themeReducer = defaultSlice.reducer;
|
|
2404
|
+
var selectThemeAppearance = (state) => state.appearance;
|
|
2405
|
+
var selectThemeBlur = (state) => state.blur;
|
|
2406
|
+
var selectThemeColor = (state) => state.color;
|
|
2407
|
+
var selectThemeHarmony = (state) => state.harmony;
|
|
2408
|
+
|
|
2409
|
+
// src/useThemeSettings.ts
|
|
2410
|
+
var import_react12 = require("react");
|
|
2411
|
+
var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext);
|
|
2114
2412
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2115
2413
|
0 && (module.exports = {
|
|
2116
2414
|
Appbar,
|
|
2415
|
+
AppearancePicker,
|
|
2416
|
+
BlurView,
|
|
2117
2417
|
BottomNavigation,
|
|
2118
2418
|
Button,
|
|
2119
2419
|
Chip,
|
|
2420
|
+
ColorPicker,
|
|
2421
|
+
Dialog,
|
|
2120
2422
|
FAB,
|
|
2423
|
+
HarmonyPicker,
|
|
2121
2424
|
IconButton,
|
|
2425
|
+
Menu,
|
|
2122
2426
|
Provider,
|
|
2123
2427
|
TextInput,
|
|
2428
|
+
ThemeSettingsContext,
|
|
2124
2429
|
createThemeReducer,
|
|
2430
|
+
defaultColors,
|
|
2431
|
+
defaultThemeSettings,
|
|
2125
2432
|
getBlendedColor,
|
|
2126
2433
|
getHex,
|
|
2127
2434
|
getRgb,
|
|
2128
2435
|
getTriadicPalette,
|
|
2129
2436
|
isDarkColor,
|
|
2130
2437
|
selectThemeAppearance,
|
|
2438
|
+
selectThemeBlur,
|
|
2131
2439
|
selectThemeColor,
|
|
2440
|
+
selectThemeHarmony,
|
|
2132
2441
|
themeActions,
|
|
2133
2442
|
themeReducer,
|
|
2443
|
+
useBlur,
|
|
2134
2444
|
useComputedTheme,
|
|
2135
|
-
usePaperDefaults
|
|
2445
|
+
usePaperDefaults,
|
|
2446
|
+
useThemeSettings
|
|
2136
2447
|
});
|