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