@rific/auto-paper 0.5.1 → 0.6.1

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/dist/index.js CHANGED
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
19
 
22
20
  // src/index.ts
23
21
  var index_exports = {};
@@ -123,11 +121,17 @@ var APPEARANCES = [
123
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 })) });
124
122
 
125
123
  // src/components/BlurView.tsx
126
- var import_expo_blur = require("expo-blur");
127
124
  var import_react4 = require("react");
128
125
  var import_react_native2 = require("react-native");
129
126
  var import_react_native_paper3 = require("react-native-paper");
130
127
  var import_jsx_runtime3 = require("react/jsx-runtime");
128
+ var ExpoBlurView = (() => {
129
+ try {
130
+ return require("expo-blur").BlurView;
131
+ } catch {
132
+ return null;
133
+ }
134
+ })();
131
135
  var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
132
136
  var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
133
137
  var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
@@ -138,8 +142,8 @@ var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacit
138
142
  const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
139
143
  const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
140
144
  const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
141
- if (blur)
142
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_expo_blur.BlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
145
+ if (blur && ExpoBlurView)
146
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
143
147
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
144
148
  tint,
145
149
  children
@@ -155,6 +159,19 @@ var import_react7 = require("react");
155
159
  var import_react_native5 = require("react-native");
156
160
  var import_react_native_paper6 = require("react-native-paper");
157
161
 
162
+ // src/navigation-bar.ts
163
+ var navigationBar = (() => {
164
+ try {
165
+ return require("expo-navigation-bar");
166
+ } catch {
167
+ return null;
168
+ }
169
+ })();
170
+ var setNavigationBarStyle = (dark) => {
171
+ if (!navigationBar) return;
172
+ navigationBar.NavigationBar.setStyle(dark ? "light" : "dark");
173
+ };
174
+
158
175
  // src/ThemeProvider.tsx
159
176
  var import_react6 = require("react");
160
177
  var import_react_native4 = require("react-native");
@@ -597,7 +614,7 @@ var NavBarContext = (0, import_react6.createContext)({});
597
614
  var useNavBarContext = () => (0, import_react6.useContext)(NavBarContext);
598
615
  function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
599
616
  const [settings, setSettings] = (0, import_react6.useState)(() => ({ ...defaultThemeSettings, ...initialValue }));
600
- const set2 = (0, import_react6.useCallback)((patch) => {
617
+ const set = (0, import_react6.useCallback)((patch) => {
601
618
  setSettings((prev) => ({ ...prev, ...patch }));
602
619
  }, []);
603
620
  const onChangeRef = (0, import_react6.useRef)(onChange);
@@ -618,7 +635,7 @@ function Provider({ initialValue, onChange, children, defaults, onNavBarChange,
618
635
  }
619
636
  }, [theme, onReady]);
620
637
  if (!theme) return null;
621
- 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: [
638
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ThemeSettingsContext.Provider, { value: { settings, set }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native_paper5.Provider, { theme, children: [
622
639
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
623
640
  /* @__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 }) }) })
624
641
  ] }) });
@@ -633,8 +650,9 @@ function useNavigationBarSync() {
633
650
  const theme = (0, import_react_native_paper6.useTheme)();
634
651
  const { onNavBarChange } = useNavBarContext();
635
652
  (0, import_react7.useEffect)(() => {
636
- if (import_react_native5.Platform.OS !== "android" || !onNavBarChange) return;
637
- onNavBarChange(theme.colors.surface, theme.dark);
653
+ if (import_react_native5.Platform.OS !== "android") return;
654
+ if (onNavBarChange) onNavBarChange(theme.colors.surface, theme.dark);
655
+ else if (navigationBar) setNavigationBarStyle(theme.dark);
638
656
  }, [theme, onNavBarChange]);
639
657
  }
640
658
  function BottomNavigationComponent(props) {
@@ -843,1544 +861,6 @@ var TextInput = (0, import_react11.forwardRef)(function TextInput2(props, ref) {
843
861
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native_paper15.TextInput, { ref, ...defaults.TextInput, ...props });
844
862
  });
845
863
 
846
- // node_modules/redux/dist/redux.mjs
847
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
848
- var ActionTypes = {
849
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
850
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
851
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
852
- };
853
- function isPlainObject(obj) {
854
- if (typeof obj !== "object" || obj === null)
855
- return false;
856
- let proto = obj;
857
- while (Object.getPrototypeOf(proto) !== null) {
858
- proto = Object.getPrototypeOf(proto);
859
- }
860
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
861
- }
862
- function compose(...funcs) {
863
- if (funcs.length === 0) {
864
- return (arg) => arg;
865
- }
866
- if (funcs.length === 1) {
867
- return funcs[0];
868
- }
869
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
870
- }
871
- function isAction(action) {
872
- return isPlainObject(action) && "type" in action && typeof action.type === "string";
873
- }
874
-
875
- // node_modules/immer/dist/immer.mjs
876
- var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
877
- var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
878
- var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
879
- var errors = process.env.NODE_ENV !== "production" ? [
880
- // All error codes, starting by 0:
881
- function(plugin) {
882
- return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
883
- },
884
- function(thing) {
885
- 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}'`;
886
- },
887
- "This object has been frozen and should not be mutated",
888
- function(data) {
889
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
890
- },
891
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
892
- "Immer forbids circular references",
893
- "The first or second argument to `produce` must be a function",
894
- "The third argument to `produce` must be a function or undefined",
895
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
896
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
897
- function(thing) {
898
- return `'current' expects a draft, got: ${thing}`;
899
- },
900
- "Object.defineProperty() cannot be used on an Immer draft",
901
- "Object.setPrototypeOf() cannot be used on an Immer draft",
902
- "Immer only supports deleting array indices",
903
- "Immer only supports setting array indices and the 'length' property",
904
- function(thing) {
905
- return `'original' expects a draft, got: ${thing}`;
906
- }
907
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
908
- // See Patches.ts for additional errors
909
- ] : [];
910
- function die(error, ...args) {
911
- if (process.env.NODE_ENV !== "production") {
912
- const e = errors[error];
913
- const msg = isFunction(e) ? e.apply(null, args) : e;
914
- throw new Error(`[Immer] ${msg}`);
915
- }
916
- throw new Error(
917
- `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
918
- );
919
- }
920
- var O = Object;
921
- var getPrototypeOf = O.getPrototypeOf;
922
- var CONSTRUCTOR = "constructor";
923
- var PROTOTYPE = "prototype";
924
- var CONFIGURABLE = "configurable";
925
- var ENUMERABLE = "enumerable";
926
- var WRITABLE = "writable";
927
- var VALUE = "value";
928
- var isDraft = (value) => !!value && !!value[DRAFT_STATE];
929
- function isDraftable(value) {
930
- if (!value)
931
- return false;
932
- return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
933
- }
934
- var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
935
- var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
936
- function isPlainObject2(value) {
937
- if (!value || !isObjectish(value))
938
- return false;
939
- const proto = getPrototypeOf(value);
940
- if (proto === null || proto === O[PROTOTYPE])
941
- return true;
942
- const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
943
- if (Ctor === Object)
944
- return true;
945
- if (!isFunction(Ctor))
946
- return false;
947
- let ctorString = cachedCtorStrings.get(Ctor);
948
- if (ctorString === void 0) {
949
- ctorString = Function.toString.call(Ctor);
950
- cachedCtorStrings.set(Ctor, ctorString);
951
- }
952
- return ctorString === objectCtorString;
953
- }
954
- function each(obj, iter, strict = true) {
955
- if (getArchtype(obj) === 0) {
956
- const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
957
- keys.forEach((key) => {
958
- iter(key, obj[key], obj);
959
- });
960
- } else {
961
- obj.forEach((entry, index) => iter(index, entry, obj));
962
- }
963
- }
964
- function getArchtype(thing) {
965
- const state = thing[DRAFT_STATE];
966
- return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
967
- }
968
- var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
969
- var get = (thing, prop, type = getArchtype(thing)) => (
970
- // @ts-ignore
971
- type === 2 ? thing.get(prop) : thing[prop]
972
- );
973
- var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
974
- if (type === 2)
975
- thing.set(propOrOldValue, value);
976
- else if (type === 3) {
977
- thing.add(value);
978
- } else
979
- thing[propOrOldValue] = value;
980
- };
981
- function is(x, y) {
982
- if (x === y) {
983
- return x !== 0 || 1 / x === 1 / y;
984
- } else {
985
- return x !== x && y !== y;
986
- }
987
- }
988
- var isArray = Array.isArray;
989
- var isMap = (target) => target instanceof Map;
990
- var isSet = (target) => target instanceof Set;
991
- var isObjectish = (target) => typeof target === "object";
992
- var isFunction = (target) => typeof target === "function";
993
- var isBoolean = (target) => typeof target === "boolean";
994
- function isArrayIndex(value) {
995
- const n = +value;
996
- return Number.isInteger(n) && String(n) === value;
997
- }
998
- var latest = (state) => state.copy_ || state.base_;
999
- var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
1000
- function shallowCopy(base, strict) {
1001
- if (isMap(base)) {
1002
- return new Map(base);
1003
- }
1004
- if (isSet(base)) {
1005
- return new Set(base);
1006
- }
1007
- if (isArray(base))
1008
- return Array[PROTOTYPE].slice.call(base);
1009
- const isPlain = isPlainObject2(base);
1010
- if (strict === true || strict === "class_only" && !isPlain) {
1011
- const descriptors = O.getOwnPropertyDescriptors(base);
1012
- delete descriptors[DRAFT_STATE];
1013
- let keys = Reflect.ownKeys(descriptors);
1014
- for (let i = 0; i < keys.length; i++) {
1015
- const key = keys[i];
1016
- const desc = descriptors[key];
1017
- if (desc[WRITABLE] === false) {
1018
- desc[WRITABLE] = true;
1019
- desc[CONFIGURABLE] = true;
1020
- }
1021
- if (desc.get || desc.set)
1022
- descriptors[key] = {
1023
- [CONFIGURABLE]: true,
1024
- [WRITABLE]: true,
1025
- // could live with !!desc.set as well here...
1026
- [ENUMERABLE]: desc[ENUMERABLE],
1027
- [VALUE]: base[key]
1028
- };
1029
- }
1030
- return O.create(getPrototypeOf(base), descriptors);
1031
- } else {
1032
- const proto = getPrototypeOf(base);
1033
- if (proto !== null && isPlain) {
1034
- return { ...base };
1035
- }
1036
- const obj = O.create(proto);
1037
- return O.assign(obj, base);
1038
- }
1039
- }
1040
- function freeze(obj, deep = false) {
1041
- if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
1042
- return obj;
1043
- if (getArchtype(obj) > 1) {
1044
- O.defineProperties(obj, {
1045
- set: dontMutateMethodOverride,
1046
- add: dontMutateMethodOverride,
1047
- clear: dontMutateMethodOverride,
1048
- delete: dontMutateMethodOverride
1049
- });
1050
- }
1051
- O.freeze(obj);
1052
- if (deep)
1053
- each(
1054
- obj,
1055
- (_key, value) => {
1056
- freeze(value, true);
1057
- },
1058
- false
1059
- );
1060
- return obj;
1061
- }
1062
- function dontMutateFrozenCollections() {
1063
- die(2);
1064
- }
1065
- var dontMutateMethodOverride = {
1066
- [VALUE]: dontMutateFrozenCollections
1067
- };
1068
- function isFrozen(obj) {
1069
- if (obj === null || !isObjectish(obj))
1070
- return true;
1071
- return O.isFrozen(obj);
1072
- }
1073
- var PluginMapSet = "MapSet";
1074
- var PluginPatches = "Patches";
1075
- var PluginArrayMethods = "ArrayMethods";
1076
- var plugins = {};
1077
- function getPlugin(pluginKey) {
1078
- const plugin = plugins[pluginKey];
1079
- if (!plugin) {
1080
- die(0, pluginKey);
1081
- }
1082
- return plugin;
1083
- }
1084
- var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
1085
- var currentScope;
1086
- var getCurrentScope = () => currentScope;
1087
- var createScope = (parent_, immer_) => ({
1088
- drafts_: [],
1089
- parent_,
1090
- immer_,
1091
- // Whenever the modified draft contains a draft from another scope, we
1092
- // need to prevent auto-freezing so the unowned draft can be finalized.
1093
- canAutoFreeze_: true,
1094
- unfinalizedDrafts_: 0,
1095
- handledSet_: /* @__PURE__ */ new Set(),
1096
- processedForPatches_: /* @__PURE__ */ new Set(),
1097
- mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
1098
- arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
1099
- });
1100
- function usePatchesInScope(scope, patchListener) {
1101
- if (patchListener) {
1102
- scope.patchPlugin_ = getPlugin(PluginPatches);
1103
- scope.patches_ = [];
1104
- scope.inversePatches_ = [];
1105
- scope.patchListener_ = patchListener;
1106
- }
1107
- }
1108
- function revokeScope(scope) {
1109
- leaveScope(scope);
1110
- scope.drafts_.forEach(revokeDraft);
1111
- scope.drafts_ = null;
1112
- }
1113
- function leaveScope(scope) {
1114
- if (scope === currentScope) {
1115
- currentScope = scope.parent_;
1116
- }
1117
- }
1118
- var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
1119
- function revokeDraft(draft) {
1120
- const state = draft[DRAFT_STATE];
1121
- if (state.type_ === 0 || state.type_ === 1)
1122
- state.revoke_();
1123
- else
1124
- state.revoked_ = true;
1125
- }
1126
- function processResult(result, scope) {
1127
- scope.unfinalizedDrafts_ = scope.drafts_.length;
1128
- const baseDraft = scope.drafts_[0];
1129
- const isReplaced = result !== void 0 && result !== baseDraft;
1130
- if (isReplaced) {
1131
- if (baseDraft[DRAFT_STATE].modified_) {
1132
- revokeScope(scope);
1133
- die(4);
1134
- }
1135
- if (isDraftable(result)) {
1136
- result = finalize(scope, result);
1137
- }
1138
- const { patchPlugin_ } = scope;
1139
- if (patchPlugin_) {
1140
- patchPlugin_.generateReplacementPatches_(
1141
- baseDraft[DRAFT_STATE].base_,
1142
- result,
1143
- scope
1144
- );
1145
- }
1146
- } else {
1147
- result = finalize(scope, baseDraft);
1148
- }
1149
- maybeFreeze(scope, result, true);
1150
- revokeScope(scope);
1151
- if (scope.patches_) {
1152
- scope.patchListener_(scope.patches_, scope.inversePatches_);
1153
- }
1154
- return result !== NOTHING ? result : void 0;
1155
- }
1156
- function finalize(rootScope, value) {
1157
- if (isFrozen(value))
1158
- return value;
1159
- const state = value[DRAFT_STATE];
1160
- if (!state) {
1161
- const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
1162
- return finalValue;
1163
- }
1164
- if (!isSameScope(state, rootScope)) {
1165
- return value;
1166
- }
1167
- if (!state.modified_) {
1168
- return state.base_;
1169
- }
1170
- if (!state.finalized_) {
1171
- const { callbacks_ } = state;
1172
- if (callbacks_) {
1173
- while (callbacks_.length > 0) {
1174
- const callback = callbacks_.pop();
1175
- callback(rootScope);
1176
- }
1177
- }
1178
- generatePatchesAndFinalize(state, rootScope);
1179
- }
1180
- return state.copy_;
1181
- }
1182
- function maybeFreeze(scope, value, deep = false) {
1183
- if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
1184
- freeze(value, deep);
1185
- }
1186
- }
1187
- function markStateFinalized(state) {
1188
- state.finalized_ = true;
1189
- state.scope_.unfinalizedDrafts_--;
1190
- }
1191
- var isSameScope = (state, rootScope) => state.scope_ === rootScope;
1192
- var EMPTY_LOCATIONS_RESULT = [];
1193
- function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
1194
- const parentCopy = latest(parent);
1195
- const parentType = parent.type_;
1196
- if (originalKey !== void 0) {
1197
- const currentValue = get(parentCopy, originalKey, parentType);
1198
- if (currentValue === draftValue) {
1199
- set(parentCopy, originalKey, finalizedValue, parentType);
1200
- return;
1201
- }
1202
- }
1203
- if (!parent.draftLocations_) {
1204
- const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
1205
- each(parentCopy, (key, value) => {
1206
- if (isDraft(value)) {
1207
- const keys = draftLocations.get(value) || [];
1208
- keys.push(key);
1209
- draftLocations.set(value, keys);
1210
- }
1211
- });
1212
- }
1213
- const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
1214
- for (const location of locations) {
1215
- set(parentCopy, location, finalizedValue, parentType);
1216
- }
1217
- }
1218
- function registerChildFinalizationCallback(parent, child, key) {
1219
- parent.callbacks_.push(function childCleanup(rootScope) {
1220
- const state = child;
1221
- if (!state || !isSameScope(state, rootScope)) {
1222
- return;
1223
- }
1224
- rootScope.mapSetPlugin_?.fixSetContents(state);
1225
- const finalizedValue = getFinalValue(state);
1226
- updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
1227
- generatePatchesAndFinalize(state, rootScope);
1228
- });
1229
- }
1230
- function generatePatchesAndFinalize(state, rootScope) {
1231
- const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
1232
- if (shouldFinalize) {
1233
- const { patchPlugin_ } = rootScope;
1234
- if (patchPlugin_) {
1235
- const basePath = patchPlugin_.getPath(state);
1236
- if (basePath) {
1237
- patchPlugin_.generatePatches_(state, basePath, rootScope);
1238
- }
1239
- }
1240
- markStateFinalized(state);
1241
- }
1242
- }
1243
- function handleCrossReference(target, key, value) {
1244
- const { scope_ } = target;
1245
- if (isDraft(value)) {
1246
- const state = value[DRAFT_STATE];
1247
- if (isSameScope(state, scope_)) {
1248
- state.callbacks_.push(function crossReferenceCleanup() {
1249
- prepareCopy(target);
1250
- const finalizedValue = getFinalValue(state);
1251
- updateDraftInParent(target, value, finalizedValue, key);
1252
- });
1253
- }
1254
- } else if (isDraftable(value)) {
1255
- target.callbacks_.push(function nestedDraftCleanup() {
1256
- const targetCopy = latest(target);
1257
- if (target.type_ === 3) {
1258
- if (targetCopy.has(value)) {
1259
- handleValue(value, scope_.handledSet_, scope_);
1260
- }
1261
- } else {
1262
- if (get(targetCopy, key, target.type_) === value) {
1263
- if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
1264
- handleValue(
1265
- get(target.copy_, key, target.type_),
1266
- scope_.handledSet_,
1267
- scope_
1268
- );
1269
- }
1270
- }
1271
- }
1272
- });
1273
- }
1274
- }
1275
- function handleValue(target, handledSet, rootScope) {
1276
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1277
- return target;
1278
- }
1279
- if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1280
- return target;
1281
- }
1282
- handledSet.add(target);
1283
- each(target, (key, value) => {
1284
- if (isDraft(value)) {
1285
- const state = value[DRAFT_STATE];
1286
- if (isSameScope(state, rootScope)) {
1287
- const updatedValue = getFinalValue(state);
1288
- set(target, key, updatedValue, target.type_);
1289
- markStateFinalized(state);
1290
- }
1291
- } else if (isDraftable(value)) {
1292
- handleValue(value, handledSet, rootScope);
1293
- }
1294
- });
1295
- return target;
1296
- }
1297
- function createProxyProxy(base, parent) {
1298
- const baseIsArray = isArray(base);
1299
- const state = {
1300
- type_: baseIsArray ? 1 : 0,
1301
- // Track which produce call this is associated with.
1302
- scope_: parent ? parent.scope_ : getCurrentScope(),
1303
- // True for both shallow and deep changes.
1304
- modified_: false,
1305
- // Used during finalization.
1306
- finalized_: false,
1307
- // Track which properties have been assigned (true) or deleted (false).
1308
- // actually instantiated in `prepareCopy()`
1309
- assigned_: void 0,
1310
- // The parent draft state.
1311
- parent_: parent,
1312
- // The base state.
1313
- base_: base,
1314
- // The base proxy.
1315
- draft_: null,
1316
- // set below
1317
- // The base copy with any updated values.
1318
- copy_: null,
1319
- // Called by the `produce` function.
1320
- revoke_: null,
1321
- isManual_: false,
1322
- // `callbacks` actually gets assigned in `createProxy`
1323
- callbacks_: void 0
1324
- };
1325
- let target = state;
1326
- let traps = objectTraps;
1327
- if (baseIsArray) {
1328
- target = [state];
1329
- traps = arrayTraps;
1330
- }
1331
- const { revoke, proxy } = Proxy.revocable(target, traps);
1332
- state.draft_ = proxy;
1333
- state.revoke_ = revoke;
1334
- return [proxy, state];
1335
- }
1336
- var objectTraps = {
1337
- get(state, prop) {
1338
- if (prop === DRAFT_STATE)
1339
- return state;
1340
- let arrayPlugin = state.scope_.arrayMethodsPlugin_;
1341
- const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
1342
- if (isArrayWithStringProp) {
1343
- if (arrayPlugin?.isArrayOperationMethod(prop)) {
1344
- return arrayPlugin.createMethodInterceptor(state, prop);
1345
- }
1346
- }
1347
- const source = latest(state);
1348
- if (!has(source, prop, state.type_)) {
1349
- return readPropFromProto(state, source, prop);
1350
- }
1351
- const value = source[prop];
1352
- if (state.finalized_ || !isDraftable(value)) {
1353
- return value;
1354
- }
1355
- if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
1356
- state.operationMethod
1357
- ) && isArrayIndex(prop)) {
1358
- return value;
1359
- }
1360
- if (value === peek(state.base_, prop)) {
1361
- prepareCopy(state);
1362
- const childKey = state.type_ === 1 ? +prop : prop;
1363
- const childDraft = createProxy(state.scope_, value, state, childKey);
1364
- return state.copy_[childKey] = childDraft;
1365
- }
1366
- return value;
1367
- },
1368
- has(state, prop) {
1369
- return prop in latest(state);
1370
- },
1371
- ownKeys(state) {
1372
- return Reflect.ownKeys(latest(state));
1373
- },
1374
- set(state, prop, value) {
1375
- const desc = getDescriptorFromProto(latest(state), prop);
1376
- if (desc?.set) {
1377
- desc.set.call(state.draft_, value);
1378
- return true;
1379
- }
1380
- if (!state.modified_) {
1381
- const current2 = peek(latest(state), prop);
1382
- const currentState = current2?.[DRAFT_STATE];
1383
- if (currentState && currentState.base_ === value) {
1384
- state.copy_[prop] = value;
1385
- state.assigned_.set(prop, false);
1386
- return true;
1387
- }
1388
- if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
1389
- return true;
1390
- prepareCopy(state);
1391
- markChanged(state);
1392
- }
1393
- if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
1394
- (value !== void 0 || prop in state.copy_) || // special case: NaN
1395
- Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
1396
- return true;
1397
- state.copy_[prop] = value;
1398
- state.assigned_.set(prop, true);
1399
- handleCrossReference(state, prop, value);
1400
- return true;
1401
- },
1402
- deleteProperty(state, prop) {
1403
- prepareCopy(state);
1404
- if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
1405
- state.assigned_.set(prop, false);
1406
- markChanged(state);
1407
- } else {
1408
- state.assigned_.delete(prop);
1409
- }
1410
- if (state.copy_) {
1411
- delete state.copy_[prop];
1412
- }
1413
- return true;
1414
- },
1415
- // Note: We never coerce `desc.value` into an Immer draft, because we can't make
1416
- // the same guarantee in ES5 mode.
1417
- getOwnPropertyDescriptor(state, prop) {
1418
- const owner = latest(state);
1419
- const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
1420
- if (!desc)
1421
- return desc;
1422
- return {
1423
- [WRITABLE]: true,
1424
- [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
1425
- [ENUMERABLE]: desc[ENUMERABLE],
1426
- [VALUE]: owner[prop]
1427
- };
1428
- },
1429
- defineProperty() {
1430
- die(11);
1431
- },
1432
- getPrototypeOf(state) {
1433
- return getPrototypeOf(state.base_);
1434
- },
1435
- setPrototypeOf() {
1436
- die(12);
1437
- }
1438
- };
1439
- var arrayTraps = {};
1440
- for (let key in objectTraps) {
1441
- let fn = objectTraps[key];
1442
- arrayTraps[key] = function() {
1443
- const args = arguments;
1444
- args[0] = args[0][0];
1445
- return fn.apply(this, args);
1446
- };
1447
- }
1448
- arrayTraps.deleteProperty = function(state, prop) {
1449
- if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
1450
- die(13);
1451
- return arrayTraps.set.call(this, state, prop, void 0);
1452
- };
1453
- arrayTraps.set = function(state, prop, value) {
1454
- if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
1455
- die(14);
1456
- return objectTraps.set.call(this, state[0], prop, value, state[0]);
1457
- };
1458
- function peek(draft, prop) {
1459
- const state = draft[DRAFT_STATE];
1460
- const source = state ? latest(state) : draft;
1461
- return source[prop];
1462
- }
1463
- function readPropFromProto(state, source, prop) {
1464
- const desc = getDescriptorFromProto(source, prop);
1465
- return desc ? VALUE in desc ? desc[VALUE] : (
1466
- // This is a very special case, if the prop is a getter defined by the
1467
- // prototype, we should invoke it with the draft as context!
1468
- desc.get?.call(state.draft_)
1469
- ) : void 0;
1470
- }
1471
- function getDescriptorFromProto(source, prop) {
1472
- if (!(prop in source))
1473
- return void 0;
1474
- let proto = getPrototypeOf(source);
1475
- while (proto) {
1476
- const desc = Object.getOwnPropertyDescriptor(proto, prop);
1477
- if (desc)
1478
- return desc;
1479
- proto = getPrototypeOf(proto);
1480
- }
1481
- return void 0;
1482
- }
1483
- function markChanged(state) {
1484
- if (!state.modified_) {
1485
- state.modified_ = true;
1486
- if (state.parent_) {
1487
- markChanged(state.parent_);
1488
- }
1489
- }
1490
- }
1491
- function prepareCopy(state) {
1492
- if (!state.copy_) {
1493
- state.assigned_ = /* @__PURE__ */ new Map();
1494
- state.copy_ = shallowCopy(
1495
- state.base_,
1496
- state.scope_.immer_.useStrictShallowCopy_
1497
- );
1498
- }
1499
- }
1500
- var Immer2 = class {
1501
- constructor(config) {
1502
- this.autoFreeze_ = true;
1503
- this.useStrictShallowCopy_ = false;
1504
- this.useStrictIteration_ = false;
1505
- this.produce = (base, recipe, patchListener) => {
1506
- if (isFunction(base) && !isFunction(recipe)) {
1507
- const defaultBase = recipe;
1508
- recipe = base;
1509
- const self = this;
1510
- return function curriedProduce(base2 = defaultBase, ...args) {
1511
- return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
1512
- };
1513
- }
1514
- if (!isFunction(recipe))
1515
- die(6);
1516
- if (patchListener !== void 0 && !isFunction(patchListener))
1517
- die(7);
1518
- let result;
1519
- if (isDraftable(base)) {
1520
- const scope = enterScope(this);
1521
- const proxy = createProxy(scope, base, void 0);
1522
- let hasError = true;
1523
- try {
1524
- result = recipe(proxy);
1525
- hasError = false;
1526
- } finally {
1527
- if (hasError)
1528
- revokeScope(scope);
1529
- else
1530
- leaveScope(scope);
1531
- }
1532
- usePatchesInScope(scope, patchListener);
1533
- return processResult(result, scope);
1534
- } else if (!base || !isObjectish(base)) {
1535
- result = recipe(base);
1536
- if (result === void 0)
1537
- result = base;
1538
- if (result === NOTHING)
1539
- result = void 0;
1540
- if (this.autoFreeze_)
1541
- freeze(result, true);
1542
- if (patchListener) {
1543
- const p = [];
1544
- const ip = [];
1545
- getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
1546
- patches_: p,
1547
- inversePatches_: ip
1548
- });
1549
- patchListener(p, ip);
1550
- }
1551
- return result;
1552
- } else
1553
- die(1, base);
1554
- };
1555
- this.produceWithPatches = (base, recipe) => {
1556
- if (isFunction(base)) {
1557
- return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
1558
- }
1559
- let patches, inversePatches;
1560
- const result = this.produce(base, recipe, (p, ip) => {
1561
- patches = p;
1562
- inversePatches = ip;
1563
- });
1564
- return [result, patches, inversePatches];
1565
- };
1566
- if (isBoolean(config?.autoFreeze))
1567
- this.setAutoFreeze(config.autoFreeze);
1568
- if (isBoolean(config?.useStrictShallowCopy))
1569
- this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1570
- if (isBoolean(config?.useStrictIteration))
1571
- this.setUseStrictIteration(config.useStrictIteration);
1572
- }
1573
- createDraft(base) {
1574
- if (!isDraftable(base))
1575
- die(8);
1576
- if (isDraft(base))
1577
- base = current(base);
1578
- const scope = enterScope(this);
1579
- const proxy = createProxy(scope, base, void 0);
1580
- proxy[DRAFT_STATE].isManual_ = true;
1581
- leaveScope(scope);
1582
- return proxy;
1583
- }
1584
- finishDraft(draft, patchListener) {
1585
- const state = draft && draft[DRAFT_STATE];
1586
- if (!state || !state.isManual_)
1587
- die(9);
1588
- const { scope_: scope } = state;
1589
- usePatchesInScope(scope, patchListener);
1590
- return processResult(void 0, scope);
1591
- }
1592
- /**
1593
- * Pass true to automatically freeze all copies created by Immer.
1594
- *
1595
- * By default, auto-freezing is enabled.
1596
- */
1597
- setAutoFreeze(value) {
1598
- this.autoFreeze_ = value;
1599
- }
1600
- /**
1601
- * Pass true to enable strict shallow copy.
1602
- *
1603
- * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1604
- */
1605
- setUseStrictShallowCopy(value) {
1606
- this.useStrictShallowCopy_ = value;
1607
- }
1608
- /**
1609
- * Pass false to use faster iteration that skips non-enumerable properties
1610
- * but still handles symbols for compatibility.
1611
- *
1612
- * By default, strict iteration is enabled (includes all own properties).
1613
- */
1614
- setUseStrictIteration(value) {
1615
- this.useStrictIteration_ = value;
1616
- }
1617
- shouldUseStrictIteration() {
1618
- return this.useStrictIteration_;
1619
- }
1620
- applyPatches(base, patches) {
1621
- let i;
1622
- for (i = patches.length - 1; i >= 0; i--) {
1623
- const patch = patches[i];
1624
- if (patch.path.length === 0 && patch.op === "replace") {
1625
- base = patch.value;
1626
- break;
1627
- }
1628
- }
1629
- if (i > -1) {
1630
- patches = patches.slice(i + 1);
1631
- }
1632
- const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
1633
- if (isDraft(base)) {
1634
- return applyPatchesImpl(base, patches);
1635
- }
1636
- return this.produce(
1637
- base,
1638
- (draft) => applyPatchesImpl(draft, patches)
1639
- );
1640
- }
1641
- };
1642
- function createProxy(rootScope, value, parent, key) {
1643
- const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
1644
- const scope = parent?.scope_ ?? getCurrentScope();
1645
- scope.drafts_.push(draft);
1646
- state.callbacks_ = parent?.callbacks_ ?? [];
1647
- state.key_ = key;
1648
- if (parent && key !== void 0) {
1649
- registerChildFinalizationCallback(parent, state, key);
1650
- } else {
1651
- state.callbacks_.push(function rootDraftCleanup(rootScope2) {
1652
- rootScope2.mapSetPlugin_?.fixSetContents(state);
1653
- const { patchPlugin_ } = rootScope2;
1654
- if (state.modified_ && patchPlugin_) {
1655
- patchPlugin_.generatePatches_(state, [], rootScope2);
1656
- }
1657
- });
1658
- }
1659
- return draft;
1660
- }
1661
- function current(value) {
1662
- if (!isDraft(value))
1663
- die(10, value);
1664
- return currentImpl(value);
1665
- }
1666
- function currentImpl(value) {
1667
- if (!isDraftable(value) || isFrozen(value))
1668
- return value;
1669
- const state = value[DRAFT_STATE];
1670
- let copy;
1671
- let strict = true;
1672
- if (state) {
1673
- if (!state.modified_)
1674
- return state.base_;
1675
- state.finalized_ = true;
1676
- copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
1677
- strict = state.scope_.immer_.shouldUseStrictIteration();
1678
- } else {
1679
- copy = shallowCopy(value, true);
1680
- }
1681
- each(
1682
- copy,
1683
- (key, childValue) => {
1684
- set(copy, key, currentImpl(childValue));
1685
- },
1686
- strict
1687
- );
1688
- if (state) {
1689
- state.finalized_ = false;
1690
- }
1691
- return copy;
1692
- }
1693
- var immer = new Immer2();
1694
- var produce = immer.produce;
1695
-
1696
- // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
1697
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
1698
- if (arguments.length === 0) return void 0;
1699
- if (typeof arguments[0] === "object") return compose;
1700
- return compose.apply(null, arguments);
1701
- };
1702
- var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
1703
- return function(noop3) {
1704
- return noop3;
1705
- };
1706
- };
1707
- var hasMatchFunction = (v) => {
1708
- return v && typeof v.match === "function";
1709
- };
1710
- function createAction(type, prepareAction) {
1711
- function actionCreator(...args) {
1712
- if (prepareAction) {
1713
- let prepared = prepareAction(...args);
1714
- if (!prepared) {
1715
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1716
- }
1717
- return {
1718
- type,
1719
- payload: prepared.payload,
1720
- ..."meta" in prepared && {
1721
- meta: prepared.meta
1722
- },
1723
- ..."error" in prepared && {
1724
- error: prepared.error
1725
- }
1726
- };
1727
- }
1728
- return {
1729
- type,
1730
- payload: args[0]
1731
- };
1732
- }
1733
- actionCreator.toString = () => `${type}`;
1734
- actionCreator.type = type;
1735
- actionCreator.match = (action) => isAction(action) && action.type === type;
1736
- return actionCreator;
1737
- }
1738
- function freezeDraftable(val) {
1739
- return isDraftable(val) ? produce(val, () => {
1740
- }) : val;
1741
- }
1742
- function getOrInsertComputed(map, key, compute) {
1743
- if (map.has(key)) return map.get(key);
1744
- return map.set(key, compute(key)).get(key);
1745
- }
1746
- function executeReducerBuilderCallback(builderCallback) {
1747
- const actionsMap = {};
1748
- const actionMatchers = [];
1749
- let defaultCaseReducer;
1750
- const builder = {
1751
- addCase(typeOrActionCreator, reducer) {
1752
- if (process.env.NODE_ENV !== "production") {
1753
- if (actionMatchers.length > 0) {
1754
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
1755
- }
1756
- if (defaultCaseReducer) {
1757
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1758
- }
1759
- }
1760
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1761
- if (!type) {
1762
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
1763
- }
1764
- if (type in actionsMap) {
1765
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
1766
- }
1767
- actionsMap[type] = reducer;
1768
- return builder;
1769
- },
1770
- addAsyncThunk(asyncThunk, reducers2) {
1771
- if (process.env.NODE_ENV !== "production") {
1772
- if (defaultCaseReducer) {
1773
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
1774
- }
1775
- }
1776
- if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
1777
- if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
1778
- if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
1779
- if (reducers2.settled) actionMatchers.push({
1780
- matcher: asyncThunk.settled,
1781
- reducer: reducers2.settled
1782
- });
1783
- return builder;
1784
- },
1785
- addMatcher(matcher, reducer) {
1786
- if (process.env.NODE_ENV !== "production") {
1787
- if (defaultCaseReducer) {
1788
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1789
- }
1790
- }
1791
- actionMatchers.push({
1792
- matcher,
1793
- reducer
1794
- });
1795
- return builder;
1796
- },
1797
- addDefaultCase(reducer) {
1798
- if (process.env.NODE_ENV !== "production") {
1799
- if (defaultCaseReducer) {
1800
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1801
- }
1802
- }
1803
- defaultCaseReducer = reducer;
1804
- return builder;
1805
- }
1806
- };
1807
- builderCallback(builder);
1808
- return [actionsMap, actionMatchers, defaultCaseReducer];
1809
- }
1810
- function isStateFunction(x) {
1811
- return typeof x === "function";
1812
- }
1813
- function createReducer(initialState, mapOrBuilderCallback) {
1814
- if (process.env.NODE_ENV !== "production") {
1815
- if (typeof mapOrBuilderCallback === "object") {
1816
- 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");
1817
- }
1818
- }
1819
- let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1820
- let getInitialState;
1821
- if (isStateFunction(initialState)) {
1822
- getInitialState = () => freezeDraftable(initialState());
1823
- } else {
1824
- const frozenInitialState = freezeDraftable(initialState);
1825
- getInitialState = () => frozenInitialState;
1826
- }
1827
- function reducer(state = getInitialState(), action) {
1828
- let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1829
- matcher
1830
- }) => matcher(action)).map(({
1831
- reducer: reducer2
1832
- }) => reducer2)];
1833
- if (caseReducers.filter((cr) => !!cr).length === 0) {
1834
- caseReducers = [finalDefaultCaseReducer];
1835
- }
1836
- return caseReducers.reduce((previousState, caseReducer) => {
1837
- if (caseReducer) {
1838
- if (isDraft(previousState)) {
1839
- const draft = previousState;
1840
- const result = caseReducer(draft, action);
1841
- if (result === void 0) {
1842
- return previousState;
1843
- }
1844
- return result;
1845
- } else if (!isDraftable(previousState)) {
1846
- const result = caseReducer(previousState, action);
1847
- if (result === void 0) {
1848
- if (previousState === null) {
1849
- return previousState;
1850
- }
1851
- throw Error("A case reducer on a non-draftable value must not return undefined");
1852
- }
1853
- return result;
1854
- } else {
1855
- return produce(previousState, (draft) => {
1856
- return caseReducer(draft, action);
1857
- });
1858
- }
1859
- }
1860
- return previousState;
1861
- }, state);
1862
- }
1863
- reducer.getInitialState = getInitialState;
1864
- return reducer;
1865
- }
1866
- var matches = (matcher, action) => {
1867
- if (hasMatchFunction(matcher)) {
1868
- return matcher.match(action);
1869
- } else {
1870
- return matcher(action);
1871
- }
1872
- };
1873
- function isAnyOf(...matchers) {
1874
- return (action) => {
1875
- return matchers.some((matcher) => matches(matcher, action));
1876
- };
1877
- }
1878
- var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1879
- var nanoid = (size = 21) => {
1880
- let id = "";
1881
- let i = size;
1882
- while (i--) {
1883
- id += urlAlphabet[Math.random() * 64 | 0];
1884
- }
1885
- return id;
1886
- };
1887
- var commonProperties = ["name", "message", "stack", "code"];
1888
- var RejectWithValue = class {
1889
- constructor(payload, meta) {
1890
- __publicField(this, "payload");
1891
- __publicField(this, "meta");
1892
- /*
1893
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1894
- does not exist at runtime
1895
- */
1896
- __publicField(this, "_type");
1897
- this.payload = payload;
1898
- this.meta = meta;
1899
- }
1900
- };
1901
- var FulfillWithMeta = class {
1902
- constructor(payload, meta) {
1903
- __publicField(this, "payload");
1904
- __publicField(this, "meta");
1905
- /*
1906
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1907
- does not exist at runtime
1908
- */
1909
- __publicField(this, "_type");
1910
- this.payload = payload;
1911
- this.meta = meta;
1912
- }
1913
- };
1914
- var miniSerializeError = (value) => {
1915
- if (typeof value === "object" && value !== null) {
1916
- const simpleError = {};
1917
- for (const property of commonProperties) {
1918
- if (typeof value[property] === "string") {
1919
- simpleError[property] = value[property];
1920
- }
1921
- }
1922
- return simpleError;
1923
- }
1924
- return {
1925
- message: String(value)
1926
- };
1927
- };
1928
- var externalAbortMessage = "External signal was aborted";
1929
- var createAsyncThunk = /* @__PURE__ */ (() => {
1930
- function createAsyncThunk2(typePrefix, payloadCreator, options) {
1931
- const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1932
- payload,
1933
- meta: {
1934
- ...meta || {},
1935
- arg,
1936
- requestId,
1937
- requestStatus: "fulfilled"
1938
- }
1939
- }));
1940
- const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1941
- payload: void 0,
1942
- meta: {
1943
- ...meta || {},
1944
- arg,
1945
- requestId,
1946
- requestStatus: "pending"
1947
- }
1948
- }));
1949
- const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1950
- payload,
1951
- error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1952
- meta: {
1953
- ...meta || {},
1954
- arg,
1955
- requestId,
1956
- rejectedWithValue: !!payload,
1957
- requestStatus: "rejected",
1958
- aborted: error?.name === "AbortError",
1959
- condition: error?.name === "ConditionError"
1960
- }
1961
- }));
1962
- function actionCreator(arg, {
1963
- signal
1964
- } = {}) {
1965
- return (dispatch, getState, extra) => {
1966
- const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1967
- const abortController = new AbortController();
1968
- let abortHandler;
1969
- let abortReason;
1970
- function abort(reason) {
1971
- abortReason = reason;
1972
- abortController.abort();
1973
- }
1974
- if (signal) {
1975
- if (signal.aborted) {
1976
- abort(externalAbortMessage);
1977
- } else {
1978
- signal.addEventListener("abort", () => abort(externalAbortMessage), {
1979
- once: true
1980
- });
1981
- }
1982
- }
1983
- const promise = (async function() {
1984
- let finalAction;
1985
- try {
1986
- let conditionResult = options?.condition?.(arg, {
1987
- getState,
1988
- extra
1989
- });
1990
- if (isThenable(conditionResult)) {
1991
- conditionResult = await conditionResult;
1992
- }
1993
- if (conditionResult === false || abortController.signal.aborted) {
1994
- throw {
1995
- name: "ConditionError",
1996
- message: "Aborted due to condition callback returning false."
1997
- };
1998
- }
1999
- const abortedPromise = new Promise((_, reject) => {
2000
- abortHandler = () => {
2001
- reject({
2002
- name: "AbortError",
2003
- message: abortReason || "Aborted"
2004
- });
2005
- };
2006
- abortController.signal.addEventListener("abort", abortHandler, {
2007
- once: true
2008
- });
2009
- });
2010
- dispatch(pending(requestId, arg, options?.getPendingMeta?.({
2011
- requestId,
2012
- arg
2013
- }, {
2014
- getState,
2015
- extra
2016
- })));
2017
- finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
2018
- dispatch,
2019
- getState,
2020
- extra,
2021
- requestId,
2022
- signal: abortController.signal,
2023
- abort,
2024
- rejectWithValue: ((value, meta) => {
2025
- return new RejectWithValue(value, meta);
2026
- }),
2027
- fulfillWithValue: ((value, meta) => {
2028
- return new FulfillWithMeta(value, meta);
2029
- })
2030
- })).then((result) => {
2031
- if (result instanceof RejectWithValue) {
2032
- throw result;
2033
- }
2034
- if (result instanceof FulfillWithMeta) {
2035
- return fulfilled(result.payload, requestId, arg, result.meta);
2036
- }
2037
- return fulfilled(result, requestId, arg);
2038
- })]);
2039
- } catch (err) {
2040
- finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
2041
- } finally {
2042
- if (abortHandler) {
2043
- abortController.signal.removeEventListener("abort", abortHandler);
2044
- }
2045
- }
2046
- const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
2047
- if (!skipDispatch) {
2048
- dispatch(finalAction);
2049
- }
2050
- return finalAction;
2051
- })();
2052
- return Object.assign(promise, {
2053
- abort,
2054
- requestId,
2055
- arg,
2056
- unwrap() {
2057
- return promise.then(unwrapResult);
2058
- }
2059
- });
2060
- };
2061
- }
2062
- return Object.assign(actionCreator, {
2063
- pending,
2064
- rejected,
2065
- fulfilled,
2066
- settled: isAnyOf(rejected, fulfilled),
2067
- typePrefix
2068
- });
2069
- }
2070
- createAsyncThunk2.withTypes = () => createAsyncThunk2;
2071
- return createAsyncThunk2;
2072
- })();
2073
- function unwrapResult(action) {
2074
- if (action.meta && action.meta.rejectedWithValue) {
2075
- throw action.payload;
2076
- }
2077
- if (action.error) {
2078
- throw action.error;
2079
- }
2080
- return action.payload;
2081
- }
2082
- function isThenable(value) {
2083
- return value !== null && typeof value === "object" && typeof value.then === "function";
2084
- }
2085
- var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
2086
- var asyncThunkCreator = {
2087
- [asyncThunkSymbol]: createAsyncThunk
2088
- };
2089
- function getType(slice, actionKey) {
2090
- return `${slice}/${actionKey}`;
2091
- }
2092
- function buildCreateSlice({
2093
- creators
2094
- } = {}) {
2095
- const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
2096
- return function createSlice2(options) {
2097
- const {
2098
- name,
2099
- reducerPath = name
2100
- } = options;
2101
- if (!name) {
2102
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
2103
- }
2104
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
2105
- if (options.initialState === void 0) {
2106
- console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
2107
- }
2108
- }
2109
- const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
2110
- const reducerNames = Object.keys(reducers2);
2111
- const context = {
2112
- sliceCaseReducersByName: {},
2113
- sliceCaseReducersByType: {},
2114
- actionCreators: {},
2115
- sliceMatchers: []
2116
- };
2117
- const contextMethods = {
2118
- addCase(typeOrActionCreator, reducer2) {
2119
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
2120
- if (!type) {
2121
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
2122
- }
2123
- if (type in context.sliceCaseReducersByType) {
2124
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
2125
- }
2126
- context.sliceCaseReducersByType[type] = reducer2;
2127
- return contextMethods;
2128
- },
2129
- addMatcher(matcher, reducer2) {
2130
- context.sliceMatchers.push({
2131
- matcher,
2132
- reducer: reducer2
2133
- });
2134
- return contextMethods;
2135
- },
2136
- exposeAction(name2, actionCreator) {
2137
- context.actionCreators[name2] = actionCreator;
2138
- return contextMethods;
2139
- },
2140
- exposeCaseReducer(name2, reducer2) {
2141
- context.sliceCaseReducersByName[name2] = reducer2;
2142
- return contextMethods;
2143
- }
2144
- };
2145
- reducerNames.forEach((reducerName) => {
2146
- const reducerDefinition = reducers2[reducerName];
2147
- const reducerDetails = {
2148
- reducerName,
2149
- type: getType(name, reducerName),
2150
- createNotation: typeof options.reducers === "function"
2151
- };
2152
- if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
2153
- handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
2154
- } else {
2155
- handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
2156
- }
2157
- });
2158
- function buildReducer() {
2159
- if (process.env.NODE_ENV !== "production") {
2160
- if (typeof options.extraReducers === "object") {
2161
- 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");
2162
- }
2163
- }
2164
- const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
2165
- const finalCaseReducers = {
2166
- ...extraReducers,
2167
- ...context.sliceCaseReducersByType
2168
- };
2169
- return createReducer(options.initialState, (builder) => {
2170
- for (let key in finalCaseReducers) {
2171
- builder.addCase(key, finalCaseReducers[key]);
2172
- }
2173
- for (let sM of context.sliceMatchers) {
2174
- builder.addMatcher(sM.matcher, sM.reducer);
2175
- }
2176
- for (let m of actionMatchers) {
2177
- builder.addMatcher(m.matcher, m.reducer);
2178
- }
2179
- if (defaultCaseReducer) {
2180
- builder.addDefaultCase(defaultCaseReducer);
2181
- }
2182
- });
2183
- }
2184
- const selectSelf = (state) => state;
2185
- const injectedSelectorCache = /* @__PURE__ */ new Map();
2186
- const injectedStateCache = /* @__PURE__ */ new WeakMap();
2187
- let _reducer;
2188
- function reducer(state, action) {
2189
- if (!_reducer) _reducer = buildReducer();
2190
- return _reducer(state, action);
2191
- }
2192
- function getInitialState() {
2193
- if (!_reducer) _reducer = buildReducer();
2194
- return _reducer.getInitialState();
2195
- }
2196
- function makeSelectorProps(reducerPath2, injected = false) {
2197
- function selectSlice(state) {
2198
- let sliceState = state[reducerPath2];
2199
- if (typeof sliceState === "undefined") {
2200
- if (injected) {
2201
- sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
2202
- } else if (process.env.NODE_ENV !== "production") {
2203
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
2204
- }
2205
- }
2206
- return sliceState;
2207
- }
2208
- function getSelectors(selectState = selectSelf) {
2209
- const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
2210
- return getOrInsertComputed(selectorCache, selectState, () => {
2211
- const map = {};
2212
- for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
2213
- map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
2214
- }
2215
- return map;
2216
- });
2217
- }
2218
- return {
2219
- reducerPath: reducerPath2,
2220
- getSelectors,
2221
- get selectors() {
2222
- return getSelectors(selectSlice);
2223
- },
2224
- selectSlice
2225
- };
2226
- }
2227
- const slice = {
2228
- name,
2229
- reducer,
2230
- actions: context.actionCreators,
2231
- caseReducers: context.sliceCaseReducersByName,
2232
- getInitialState,
2233
- ...makeSelectorProps(reducerPath),
2234
- injectInto(injectable, {
2235
- reducerPath: pathOpt,
2236
- ...config
2237
- } = {}) {
2238
- const newReducerPath = pathOpt ?? reducerPath;
2239
- injectable.inject({
2240
- reducerPath: newReducerPath,
2241
- reducer
2242
- }, config);
2243
- return {
2244
- ...slice,
2245
- ...makeSelectorProps(newReducerPath, true)
2246
- };
2247
- }
2248
- };
2249
- return slice;
2250
- };
2251
- }
2252
- function wrapSelector(selector, selectState, getInitialState, injected) {
2253
- function wrapper(rootState, ...args) {
2254
- let sliceState = selectState(rootState);
2255
- if (typeof sliceState === "undefined") {
2256
- if (injected) {
2257
- sliceState = getInitialState();
2258
- } else if (process.env.NODE_ENV !== "production") {
2259
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
2260
- }
2261
- }
2262
- return selector(sliceState, ...args);
2263
- }
2264
- wrapper.unwrapped = selector;
2265
- return wrapper;
2266
- }
2267
- var createSlice = /* @__PURE__ */ buildCreateSlice();
2268
- function buildReducerCreators() {
2269
- function asyncThunk(payloadCreator, config) {
2270
- return {
2271
- _reducerDefinitionType: "asyncThunk",
2272
- payloadCreator,
2273
- ...config
2274
- };
2275
- }
2276
- asyncThunk.withTypes = () => asyncThunk;
2277
- return {
2278
- reducer(caseReducer) {
2279
- return Object.assign({
2280
- // hack so the wrapping function has the same name as the original
2281
- // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
2282
- [caseReducer.name](...args) {
2283
- return caseReducer(...args);
2284
- }
2285
- }[caseReducer.name], {
2286
- _reducerDefinitionType: "reducer"
2287
- /* reducer */
2288
- });
2289
- },
2290
- preparedReducer(prepare, reducer) {
2291
- return {
2292
- _reducerDefinitionType: "reducerWithPrepare",
2293
- prepare,
2294
- reducer
2295
- };
2296
- },
2297
- asyncThunk
2298
- };
2299
- }
2300
- function handleNormalReducerDefinition({
2301
- type,
2302
- reducerName,
2303
- createNotation
2304
- }, maybeReducerWithPrepare, context) {
2305
- let caseReducer;
2306
- let prepareCallback;
2307
- if ("reducer" in maybeReducerWithPrepare) {
2308
- if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
2309
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
2310
- }
2311
- caseReducer = maybeReducerWithPrepare.reducer;
2312
- prepareCallback = maybeReducerWithPrepare.prepare;
2313
- } else {
2314
- caseReducer = maybeReducerWithPrepare;
2315
- }
2316
- context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
2317
- }
2318
- function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
2319
- return reducerDefinition._reducerDefinitionType === "asyncThunk";
2320
- }
2321
- function isCaseReducerWithPrepareDefinition(reducerDefinition) {
2322
- return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
2323
- }
2324
- function handleThunkCaseReducerDefinition({
2325
- type,
2326
- reducerName
2327
- }, reducerDefinition, context, cAT) {
2328
- if (!cAT) {
2329
- 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`.");
2330
- }
2331
- const {
2332
- payloadCreator,
2333
- fulfilled,
2334
- pending,
2335
- rejected,
2336
- settled,
2337
- options
2338
- } = reducerDefinition;
2339
- const thunk = cAT(type, payloadCreator, options);
2340
- context.exposeAction(reducerName, thunk);
2341
- if (fulfilled) {
2342
- context.addCase(thunk.fulfilled, fulfilled);
2343
- }
2344
- if (pending) {
2345
- context.addCase(thunk.pending, pending);
2346
- }
2347
- if (rejected) {
2348
- context.addCase(thunk.rejected, rejected);
2349
- }
2350
- if (settled) {
2351
- context.addMatcher(thunk.settled, settled);
2352
- }
2353
- context.exposeCaseReducer(reducerName, {
2354
- fulfilled: fulfilled || noop,
2355
- pending: pending || noop,
2356
- rejected: rejected || noop,
2357
- settled: settled || noop
2358
- });
2359
- }
2360
- function noop() {
2361
- }
2362
- var listener = "listener";
2363
- var completed = "completed";
2364
- var cancelled = "cancelled";
2365
- var taskCancelled = `task-${cancelled}`;
2366
- var taskCompleted = `task-${completed}`;
2367
- var listenerCancelled = `${listener}-${cancelled}`;
2368
- var listenerCompleted = `${listener}-${completed}`;
2369
- var {
2370
- assign
2371
- } = Object;
2372
- var alm = "listenerMiddleware";
2373
- var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
2374
- withTypes: () => addListener
2375
- });
2376
- var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
2377
- var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
2378
- withTypes: () => removeListener
2379
- });
2380
- function formatProdErrorMessage(code) {
2381
- 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. `;
2382
- }
2383
-
2384
864
  // src/redux/themeSlice.ts
2385
865
  var defaultInitialState = {
2386
866
  appearance: "system",
@@ -2388,27 +868,31 @@ var defaultInitialState = {
2388
868
  color: "#6750a4",
2389
869
  harmony: "split-complementary"
2390
870
  };
2391
- var reducers = {
2392
- initialize: (state, action) => ({ ...state, ...action.payload }),
2393
- setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
2394
- setBlur: (state, action) => ({ ...state, blur: action.payload }),
2395
- setColor: (state, action) => ({ ...state, color: action.payload }),
2396
- setHarmony: (state, action) => ({ ...state, harmony: action.payload })
871
+ var createAction = (type) => {
872
+ const actionCreator = (payload) => ({ payload, type });
873
+ actionCreator.type = type;
874
+ actionCreator.match = (action) => action.type === type;
875
+ return actionCreator;
876
+ };
877
+ var initialize = createAction("theme/initialize");
878
+ var setAppearance = createAction("theme/setAppearance");
879
+ var setBlur = createAction("theme/setBlur");
880
+ var setColor = createAction("theme/setColor");
881
+ var setHarmony = createAction("theme/setHarmony");
882
+ var themeActions = { initialize, setAppearance, setBlur, setColor, setHarmony };
883
+ var reduce = (state, action) => {
884
+ if (initialize.match(action)) return { ...state, ...action.payload };
885
+ if (setAppearance.match(action)) return { ...state, appearance: action.payload };
886
+ if (setBlur.match(action)) return { ...state, blur: action.payload };
887
+ if (setColor.match(action)) return { ...state, color: action.payload };
888
+ if (setHarmony.match(action)) return { ...state, harmony: action.payload };
889
+ return state;
2397
890
  };
2398
891
  function createThemeReducer(initialState) {
2399
- return createSlice({
2400
- name: "theme",
2401
- initialState: { ...defaultInitialState, ...initialState },
2402
- reducers
2403
- }).reducer;
892
+ const initial = { ...defaultInitialState, ...initialState };
893
+ return (state = initial, action) => reduce(state, action);
2404
894
  }
2405
- var defaultSlice = createSlice({
2406
- name: "theme",
2407
- initialState: defaultInitialState,
2408
- reducers
2409
- });
2410
- var themeActions = defaultSlice.actions;
2411
- var themeReducer = defaultSlice.reducer;
895
+ var themeReducer = (state = defaultInitialState, action) => reduce(state, action);
2412
896
  var selectThemeAppearance = (state) => state.appearance;
2413
897
  var selectThemeBlur = (state) => state.blur;
2414
898
  var selectThemeColor = (state) => state.color;