@rific/auto-paper 0.4.0 → 0.6.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/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 = {};
@@ -43,6 +41,8 @@ __export(index_exports, {
43
41
  getBlendedColor: () => getBlendedColor,
44
42
  getHex: () => getHex,
45
43
  getRgb: () => getRgb,
44
+ getTintTextColor: () => getTintTextColor,
45
+ getTonalColor: () => getTonalColor,
46
46
  getTriadicPalette: () => getTriadicPalette,
47
47
  isDarkColor: () => isDarkColor,
48
48
  selectThemeAppearance: () => selectThemeAppearance,
@@ -121,24 +121,34 @@ var APPEARANCES = [
121
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 })) });
122
122
 
123
123
  // src/components/BlurView.tsx
124
- var import_expo_blur = require("expo-blur");
125
124
  var import_react4 = require("react");
126
125
  var import_react_native2 = require("react-native");
127
126
  var import_react_native_paper3 = require("react-native-paper");
128
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
+ })();
129
135
  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 }) => {
136
+ var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
137
+ var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
131
138
  const { dark, colors } = (0, import_react_native_paper3.useTheme)();
132
139
  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 }] }),
140
+ const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
141
+ const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
142
+ const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
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);
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;
145
+ if (blur && ExpoBlurView)
146
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
138
148
  tint,
139
149
  children
140
150
  ] });
141
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor: colors.surface }, style], children: [
151
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor: surfaceColor }, style], children: [
142
152
  tint,
143
153
  children
144
154
  ] });
@@ -149,6 +159,19 @@ var import_react7 = require("react");
149
159
  var import_react_native5 = require("react-native");
150
160
  var import_react_native_paper6 = require("react-native-paper");
151
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
+
152
175
  // src/ThemeProvider.tsx
153
176
  var import_react6 = require("react");
154
177
  var import_react_native4 = require("react-native");
@@ -591,16 +614,18 @@ var NavBarContext = (0, import_react6.createContext)({});
591
614
  var useNavBarContext = () => (0, import_react6.useContext)(NavBarContext);
592
615
  function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
593
616
  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
- );
617
+ const set = (0, import_react6.useCallback)((patch) => {
618
+ setSettings((prev) => ({ ...prev, ...patch }));
619
+ }, []);
620
+ const onChangeRef = (0, import_react6.useRef)(onChange);
621
+ onChangeRef.current = onChange;
622
+ const prevSettings = (0, import_react6.useRef)(settings);
623
+ (0, import_react6.useEffect)(() => {
624
+ if (prevSettings.current !== settings) {
625
+ prevSettings.current = settings;
626
+ onChangeRef.current?.(settings);
627
+ }
628
+ }, [settings]);
604
629
  const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
605
630
  const called = (0, import_react6.useRef)(false);
606
631
  (0, import_react6.useEffect)(() => {
@@ -610,7 +635,7 @@ function Provider({ initialValue, onChange, children, defaults, onNavBarChange,
610
635
  }
611
636
  }, [theme, onReady]);
612
637
  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: [
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: [
614
639
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
615
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 }) }) })
616
641
  ] }) });
@@ -625,8 +650,9 @@ function useNavigationBarSync() {
625
650
  const theme = (0, import_react_native_paper6.useTheme)();
626
651
  const { onNavBarChange } = useNavBarContext();
627
652
  (0, import_react7.useEffect)(() => {
628
- if (import_react_native5.Platform.OS !== "android" || !onNavBarChange) return;
629
- 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);
630
656
  }, [theme, onNavBarChange]);
631
657
  }
632
658
  function BottomNavigationComponent(props) {
@@ -639,7 +665,7 @@ function Bar(props) {
639
665
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper6.BottomNavigation.Bar, { ...props });
640
666
  }
641
667
  BottomNavigationComponent.Bar = Bar;
642
- BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation.SceneMap;
668
+ BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation?.SceneMap;
643
669
  var BottomNavigation = BottomNavigationComponent;
644
670
 
645
671
  // src/components/Button.tsx
@@ -835,1544 +861,6 @@ var TextInput = (0, import_react11.forwardRef)(function TextInput2(props, ref) {
835
861
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native_paper15.TextInput, { ref, ...defaults.TextInput, ...props });
836
862
  });
837
863
 
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);
851
- }
852
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
853
- }
854
- function compose(...funcs) {
855
- if (funcs.length === 0) {
856
- return (arg) => arg;
857
- }
858
- if (funcs.length === 1) {
859
- return funcs[0];
860
- }
861
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
862
- }
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}`);
907
- }
908
- throw new Error(
909
- `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
910
- );
911
- }
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);
925
- }
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);
943
- }
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);
951
- });
952
- } else {
953
- obj.forEach((entry, index) => iter(index, entry, obj));
954
- }
955
- }
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;
959
- }
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;
978
- }
979
- }
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;
989
- }
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);
995
- }
996
- if (isSet(base)) {
997
- return new Set(base);
998
- }
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;
1012
- }
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
- };
1021
- }
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);
1030
- }
1031
- }
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
- });
1042
- }
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;
1053
- }
1054
- function dontMutateFrozenCollections() {
1055
- die(2);
1056
- }
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);
1064
- }
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);
1073
- }
1074
- return plugin;
1075
- }
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;
1098
- }
1099
- }
1100
- function revokeScope(scope) {
1101
- leaveScope(scope);
1102
- scope.drafts_.forEach(revokeDraft);
1103
- scope.drafts_ = null;
1104
- }
1105
- function leaveScope(scope) {
1106
- if (scope === currentScope) {
1107
- currentScope = scope.parent_;
1108
- }
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);
1140
- }
1141
- maybeFreeze(scope, result, true);
1142
- revokeScope(scope);
1143
- if (scope.patches_) {
1144
- scope.patchListener_(scope.patches_, scope.inversePatches_);
1145
- }
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;
1155
- }
1156
- if (!isSameScope(state, rootScope)) {
1157
- return value;
1158
- }
1159
- if (!state.modified_) {
1160
- return state.base_;
1161
- }
1162
- if (!state.finalized_) {
1163
- const { callbacks_ } = state;
1164
- if (callbacks_) {
1165
- while (callbacks_.length > 0) {
1166
- const callback = callbacks_.pop();
1167
- callback(rootScope);
1168
- }
1169
- }
1170
- generatePatchesAndFinalize(state, rootScope);
1171
- }
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);
1177
- }
1178
- }
1179
- function markStateFinalized(state) {
1180
- state.finalized_ = true;
1181
- state.scope_.unfinalizedDrafts_--;
1182
- }
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
- }
1194
- }
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);
1208
- }
1209
- }
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);
1230
- }
1231
- }
1232
- markStateFinalized(state);
1233
- }
1234
- }
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);
1244
- });
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_);
1252
- }
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
- }
1262
- }
1263
- }
1264
- });
1265
- }
1266
- }
1267
- function handleValue(target, handledSet, rootScope) {
1268
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1269
- return target;
1270
- }
1271
- if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1272
- return target;
1273
- }
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);
1285
- }
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;
1322
- }
1323
- const { revoke, proxy } = Proxy.revocable(target, traps);
1324
- state.draft_ = proxy;
1325
- state.revoke_ = revoke;
1326
- return [proxy, state];
1327
- }
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);
1429
- }
1430
- };
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);
1438
- };
1439
- }
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);
1444
- };
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]);
1449
- };
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);
1472
- }
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_);
1480
- }
1481
- }
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
- };
1505
- }
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);
1523
- }
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);
1542
- }
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);
1564
- }
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;
1575
- }
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);
1583
- }
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
- }
1620
- }
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");
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
- };
1719
- }
1720
- return {
1721
- type,
1722
- payload: args[0]
1723
- };
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`");
1747
- }
1748
- if (defaultCaseReducer) {
1749
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1750
- }
1751
- }
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");
1755
- }
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}'`);
1758
- }
1759
- actionsMap[type] = reducer;
1760
- return builder;
1761
- },
1762
- addAsyncThunk(asyncThunk, reducers2) {
1763
- if (process.env.NODE_ENV !== "production") {
1764
- if (defaultCaseReducer) {
1765
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
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
1774
- });
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`");
1781
- }
1782
- }
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
- }
1794
- }
1795
- defaultCaseReducer = reducer;
1796
- return builder;
1797
- }
1798
- };
1799
- builderCallback(builder);
1800
- return [actionsMap, actionMatchers, defaultCaseReducer];
1801
- }
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");
1809
- }
1810
- }
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;
1818
- }
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
- });
1850
- }
1851
- }
1852
- return previousState;
1853
- }, state);
1854
- }
1855
- reducer.getInitialState = getInitialState;
1856
- return reducer;
1857
- }
1858
- var matches = (matcher, action) => {
1859
- if (hasMatchFunction(matcher)) {
1860
- return matcher.match(action);
1861
- } else {
1862
- return matcher(action);
1863
- }
1864
- };
1865
- function isAnyOf(...matchers) {
1866
- return (action) => {
1867
- return matchers.some((matcher) => matches(matcher, action));
1868
- };
1869
- }
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];
1876
- }
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;
1891
- }
1892
- };
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
- }
1905
- };
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
- };
1919
- };
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
- });
2052
- };
2053
- }
2054
- return Object.assign(actionCreator, {
2055
- pending,
2056
- rejected,
2057
- fulfilled,
2058
- settled: isAnyOf(rejected, fulfilled),
2059
- typePrefix
2060
- });
2061
- }
2062
- createAsyncThunk2.withTypes = () => createAsyncThunk2;
2063
- return createAsyncThunk2;
2064
- })();
2065
- function unwrapResult(action) {
2066
- if (action.meta && action.meta.rejectedWithValue) {
2067
- throw action.payload;
2068
- }
2069
- if (action.error) {
2070
- throw action.error;
2071
- }
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
2080
- };
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
- }
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
- };
2267
- }
2268
- asyncThunk.withTypes = () => asyncThunk;
2269
- return {
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
2290
- };
2291
- }
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;
2305
- } else {
2306
- caseReducer = maybeReducerWithPrepare;
2307
- }
2308
- context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
2309
- }
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. `;
2374
- }
2375
-
2376
864
  // src/redux/themeSlice.ts
2377
865
  var defaultInitialState = {
2378
866
  appearance: "system",
@@ -2380,27 +868,31 @@ var defaultInitialState = {
2380
868
  color: "#6750a4",
2381
869
  harmony: "split-complementary"
2382
870
  };
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 })
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;
2389
890
  };
2390
891
  function createThemeReducer(initialState) {
2391
- return createSlice({
2392
- name: "theme",
2393
- initialState: { ...defaultInitialState, ...initialState },
2394
- reducers
2395
- }).reducer;
892
+ const initial = { ...defaultInitialState, ...initialState };
893
+ return (state = initial, action) => reduce(state, action);
2396
894
  }
2397
- var defaultSlice = createSlice({
2398
- name: "theme",
2399
- initialState: defaultInitialState,
2400
- reducers
2401
- });
2402
- var themeActions = defaultSlice.actions;
2403
- var themeReducer = defaultSlice.reducer;
895
+ var themeReducer = (state = defaultInitialState, action) => reduce(state, action);
2404
896
  var selectThemeAppearance = (state) => state.appearance;
2405
897
  var selectThemeBlur = (state) => state.blur;
2406
898
  var selectThemeColor = (state) => state.color;
@@ -2409,6 +901,12 @@ var selectThemeHarmony = (state) => state.harmony;
2409
901
  // src/useThemeSettings.ts
2410
902
  var import_react12 = require("react");
2411
903
  var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext);
904
+
905
+ // src/utils/getTintTextColor.ts
906
+ var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
907
+ const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
908
+ return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
909
+ };
2412
910
  // Annotate the CommonJS export names for ESM import in node:
2413
911
  0 && (module.exports = {
2414
912
  Appbar,
@@ -2432,6 +930,8 @@ var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext
2432
930
  getBlendedColor,
2433
931
  getHex,
2434
932
  getRgb,
933
+ getTintTextColor,
934
+ getTonalColor,
2435
935
  getTriadicPalette,
2436
936
  isDarkColor,
2437
937
  selectThemeAppearance,