@awesome-flow/noise 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/abstract/index.cjs +8 -3469
  2. package/dist/abstract/index.d.cts +2 -2
  3. package/dist/abstract/index.d.ts +2 -2
  4. package/dist/abstract/index.js +15 -3508
  5. package/dist/chunk-2Y22M2Y4.js +0 -0
  6. package/dist/chunk-4PQ4USYV.cjs +1 -0
  7. package/dist/chunk-5ELMFIRV.js +0 -0
  8. package/dist/chunk-ACWBUUZ7.cjs +1376 -0
  9. package/dist/chunk-BG6U3TYO.js +1376 -0
  10. package/dist/chunk-D5JM4EYQ.cjs +305 -0
  11. package/dist/chunk-DWSACR65.js +305 -0
  12. package/dist/chunk-FFQRP23R.cjs +1 -0
  13. package/dist/chunk-JACBT4MS.cjs +1 -0
  14. package/dist/chunk-KHIIB5TH.js +93 -0
  15. package/dist/chunk-M67JHEU2.cjs +93 -0
  16. package/dist/chunk-N6YNJKLS.cjs +1 -0
  17. package/dist/chunk-PS5VUND5.js +348 -0
  18. package/dist/chunk-Q5FVGKKM.cjs +1 -0
  19. package/dist/chunk-RDQ4BOOV.js +522 -0
  20. package/dist/chunk-RKTZQUWR.cjs +348 -0
  21. package/dist/chunk-RVWCBH7K.js +0 -0
  22. package/dist/chunk-SD3T3LFY.js +0 -0
  23. package/dist/chunk-SGHEOOLW.js +19 -0
  24. package/dist/chunk-TOYKGWYO.js +0 -0
  25. package/dist/chunk-TZCT2GZV.cjs +522 -0
  26. package/dist/chunk-UNMRBZ5X.cjs +19 -0
  27. package/dist/chunk-WOJTKQKO.cjs +1 -0
  28. package/dist/chunk-XZQQ6N3L.js +0 -0
  29. package/dist/modules/index.cjs +4 -42
  30. package/dist/modules/index.js +3 -15
  31. package/dist/nodes/generators/index.cjs +13 -335
  32. package/dist/nodes/generators/index.d.cts +7 -7
  33. package/dist/nodes/generators/index.d.ts +7 -7
  34. package/dist/nodes/generators/index.js +12 -299
  35. package/dist/nodes/groups/index.cjs +4 -111
  36. package/dist/nodes/groups/index.d.cts +2 -2
  37. package/dist/nodes/groups/index.d.ts +2 -2
  38. package/dist/nodes/groups/index.js +2 -88
  39. package/dist/nodes/index.cjs +75 -3425
  40. package/dist/nodes/index.js +37 -3397
  41. package/dist/nodes/modifiers/index.cjs +4 -1459
  42. package/dist/nodes/modifiers/index.d.cts +6 -6
  43. package/dist/nodes/modifiers/index.d.ts +6 -6
  44. package/dist/nodes/modifiers/index.js +11 -1479
  45. package/dist/nodes/output/index.cjs +8 -1335
  46. package/dist/nodes/output/index.d.cts +3 -3
  47. package/dist/nodes/output/index.d.ts +3 -3
  48. package/dist/nodes/output/index.js +10 -1361
  49. package/dist/nodes/selectors/index.cjs +8 -1317
  50. package/dist/nodes/selectors/index.d.cts +1 -1
  51. package/dist/nodes/selectors/index.d.ts +1 -1
  52. package/dist/nodes/selectors/index.js +8 -1343
  53. package/dist/nodes/transformers/index.cjs +8 -331
  54. package/dist/nodes/transformers/index.d.cts +5 -5
  55. package/dist/nodes/transformers/index.d.ts +5 -5
  56. package/dist/nodes/transformers/index.js +6 -311
  57. package/dist/templates/generators/index.cjs +8 -1199
  58. package/dist/templates/generators/index.d.cts +5 -5
  59. package/dist/templates/generators/index.d.ts +5 -5
  60. package/dist/templates/generators/index.js +17 -1226
  61. package/dist/templates/groups/index.cjs +8 -1199
  62. package/dist/templates/groups/index.js +8 -1226
  63. package/dist/templates/index.cjs +77 -1263
  64. package/dist/templates/index.js +43 -1226
  65. package/dist/templates/modifiers/index.cjs +8 -1199
  66. package/dist/templates/modifiers/index.d.cts +9 -9
  67. package/dist/templates/modifiers/index.d.ts +9 -9
  68. package/dist/templates/modifiers/index.js +16 -1226
  69. package/dist/templates/output/index.cjs +8 -1199
  70. package/dist/templates/output/index.d.cts +3 -3
  71. package/dist/templates/output/index.d.ts +3 -3
  72. package/dist/templates/output/index.js +11 -1226
  73. package/dist/templates/selectors/index.cjs +8 -1199
  74. package/dist/templates/selectors/index.js +9 -1226
  75. package/dist/templates/transformers/index.cjs +8 -1199
  76. package/dist/templates/transformers/index.js +12 -1226
  77. package/package.json +30 -20
@@ -1,1483 +1,15 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
28
- var require_fast_deep_equal = __commonJS({
29
- "../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
30
- "use strict";
31
- module.exports = function equal(a, b) {
32
- if (a === b) return true;
33
- if (a && b && typeof a == "object" && typeof b == "object") {
34
- if (a.constructor !== b.constructor) return false;
35
- var length, i, keys;
36
- if (Array.isArray(a)) {
37
- length = a.length;
38
- if (length != b.length) return false;
39
- for (i = length; i-- !== 0; )
40
- if (!equal(a[i], b[i])) return false;
41
- return true;
42
- }
43
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
44
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
45
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
46
- keys = Object.keys(a);
47
- length = keys.length;
48
- if (length !== Object.keys(b).length) return false;
49
- for (i = length; i-- !== 0; )
50
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
51
- for (i = length; i-- !== 0; ) {
52
- var key = keys[i];
53
- if (!equal(a[key], b[key])) return false;
54
- }
55
- return true;
56
- }
57
- return a !== a && b !== b;
58
- };
59
- }
60
- });
61
-
62
- // src/nodes/modifiers/noise-abs-node.tsx
63
- import { NodeContainer, NodeTrackConnections } from "@awesome-flow/core/layout";
64
- import { useEffect } from "react";
65
- import { useIncomingComputedData, useUpdateNodeComputedData } from "@awesome-flow/core/hooks";
66
- import { Abs } from "libnoise-simplex-ts";
67
- import { jsx } from "react/jsx-runtime";
68
- function NoiseAbsNode({ id, selected, data, type }) {
69
- const incoming = useIncomingComputedData(id);
70
- const updateComputedData = useUpdateNodeComputedData();
71
- useEffect(() => {
72
- if (incoming?.length > 0) {
73
- const module = new Abs(incoming[0].module);
74
- updateComputedData(id, { module });
75
- }
76
- }, [incoming]);
77
- return /* @__PURE__ */ jsx(NodeContainer, { id, selected, data, type, children: /* @__PURE__ */ jsx(NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" }) });
78
- }
79
- var noise_abs_node_default = NoiseAbsNode;
80
-
81
- // src/nodes/modifiers/noise-clamp-node.tsx
82
- import { NodeContainer as NodeContainer2, NodeTrackConnections as NodeTrackConnections2 } from "@awesome-flow/core/layout";
83
- import { useEffect as useEffect2, useState } from "react";
84
- import { Group, NumberInput, Stack } from "@mantine/core";
85
- import {
86
- useIncomingComputedData as useIncomingComputedData2,
87
- useUpdateNodeComputedData as useUpdateNodeComputedData2,
88
- useUpdateNodeData
89
- } from "@awesome-flow/core/hooks";
90
- import { Clamp } from "libnoise-simplex-ts";
91
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
92
- function NoiseClampNode({ id, selected, data, type }) {
93
- const [lowerBound, setLowerBound] = useState(data.lowerBound);
94
- const [upperBound, setUpperBound] = useState(data.upperBound);
95
- const incoming = useIncomingComputedData2(id);
96
- const updateNodeData = useUpdateNodeData();
97
- const updateComputedData = useUpdateNodeComputedData2();
98
- useEffect2(() => {
99
- if (incoming?.length) {
100
- const module = new Clamp(incoming[0].module, lowerBound, upperBound);
101
- updateComputedData(id, { module });
102
- }
103
- updateNodeData(id, { lowerBound, upperBound });
104
- }, [incoming, lowerBound, upperBound]);
105
- return /* @__PURE__ */ jsxs(NodeContainer2, { id, selected, data, type, children: [
106
- /* @__PURE__ */ jsx2(Stack, { children: /* @__PURE__ */ jsxs(Group, { children: [
107
- /* @__PURE__ */ jsx2(
108
- NumberInput,
109
- {
110
- size: "xs",
111
- w: 100,
112
- value: lowerBound,
113
- onChange: (e) => setLowerBound(Number(e)),
114
- step: 0.1
115
- }
116
- ),
117
- /* @__PURE__ */ jsx2(
118
- NumberInput,
119
- {
120
- size: "xs",
121
- w: 100,
122
- value: upperBound,
123
- onChange: (e) => setUpperBound(Number(e)),
124
- step: 0.1
125
- }
126
- )
127
- ] }) }),
128
- /* @__PURE__ */ jsx2(NodeTrackConnections2, { handles: data.handles, nodeId: id, type: "target" })
129
- ] });
130
- }
131
- var noise_clamp_node_default = NoiseClampNode;
132
-
133
- // src/nodes/modifiers/noise-combine-node.tsx
134
- import { NodeCombobox, NodeContainer as NodeContainer3, NodeTrackConnections as NodeTrackConnections3 } from "@awesome-flow/core/layout";
135
- import { useCallback, useEffect as useEffect3 } from "react";
136
- import {
137
- useIncomingComputedData as useIncomingComputedData3,
138
- useUpdateNodeComputedData as useUpdateNodeComputedData3,
139
- useUpdateNodeData as useUpdateNodeData2
140
- } from "@awesome-flow/core/hooks";
141
- import {
142
- IconAsterisk,
143
- IconChevronLeft,
144
- IconChevronRight,
145
- IconChevronUp,
146
- IconPlus
147
- } from "@tabler/icons-react";
148
-
149
- // src/abstract/operations.ts
150
- import { Add, Max, Min, Multiply, Power } from "libnoise-simplex-ts";
151
- var noiseCombineModuleMap = {
152
- ["add" /* add */]: Add,
153
- ["max" /* max */]: Max,
154
- ["min" /* min */]: Min,
155
- ["multiply" /* multiply */]: Multiply,
156
- ["power" /* power */]: Power
157
- };
158
-
159
- // src/nodes/modifiers/noise-combine-node.tsx
160
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
161
- var options = {
162
- add: /* @__PURE__ */ jsx3(IconPlus, {}),
163
- min: /* @__PURE__ */ jsx3(IconChevronLeft, {}),
164
- max: /* @__PURE__ */ jsx3(IconChevronRight, {}),
165
- multiply: /* @__PURE__ */ jsx3(IconAsterisk, {}),
166
- power: /* @__PURE__ */ jsx3(IconChevronUp, {})
167
- };
168
- function NoiseCombineNode({ id, selected, data, type }) {
169
- const updateNodeData = useUpdateNodeData2();
170
- const updateComputedData = useUpdateNodeComputedData3();
171
- const incoming = useIncomingComputedData3(id);
172
- useEffect3(() => {
173
- const ModuleFactory = noiseCombineModuleMap[data.operation];
174
- if (incoming?.length > 1) {
175
- const module = new ModuleFactory(incoming[0].module, incoming[1].module);
176
- updateComputedData(id, { module });
177
- }
178
- }, [data.operation, incoming]);
179
- const onChange = useCallback((operation) => {
180
- updateNodeData(id, { operation });
181
- }, []);
182
- return /* @__PURE__ */ jsxs2(NodeContainer3, { id, selected, data, type, children: [
183
- /* @__PURE__ */ jsx3(NodeCombobox, { options, selected: data.operation, onChange, width: 150 }),
184
- /* @__PURE__ */ jsx3(NodeTrackConnections3, { handles: data.handles, nodeId: id, type: "target" })
185
- ] });
186
- }
187
- var noise_combine_node_default = NoiseCombineNode;
188
-
189
- // src/nodes/modifiers/noise-curve-node.tsx
190
- import { NodeContainer as NodeContainer4, NodeTrackConnections as NodeTrackConnections4 } from "@awesome-flow/core/layout";
191
- import { ActionIcon, Button, Group as Group2, NumberInput as NumberInput2, Space } from "@mantine/core";
192
- import {
193
- useIncomingComputedData as useIncomingComputedData4,
194
- useUpdateNodeComputedData as useUpdateNodeComputedData4,
195
- useUpdateNodeData as useUpdateNodeData3
196
- } from "@awesome-flow/core/hooks";
197
-
198
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/use-form.mjs
199
- import { useState as useState5, useCallback as useCallback7 } from "react";
200
-
201
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/actions/actions.mjs
202
- import { useLayoutEffect, useEffect as useEffect4 } from "react";
203
- function validateFormName(name) {
204
- if (!/^[0-9a-zA-Z-]+$/.test(name)) {
205
- throw new Error(
206
- `[@mantine/use-form] Form name "${name}" is invalid, it should contain only letters, numbers and dashes`
207
- );
208
- }
209
- }
210
- var useIsomorphicEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect4;
211
- function useFormEvent(eventKey, handler) {
212
- useIsomorphicEffect(() => {
213
- if (eventKey) {
214
- window.addEventListener(eventKey, handler);
215
- return () => window.removeEventListener(eventKey, handler);
216
- }
217
- return void 0;
218
- }, [eventKey]);
219
- }
220
- function useFormActions(name, form) {
221
- if (name) {
222
- validateFormName(name);
223
- }
224
- useFormEvent(
225
- `mantine-form:${name}:set-field-value`,
226
- (event) => form.setFieldValue(event.detail.path, event.detail.value)
227
- );
228
- useFormEvent(
229
- `mantine-form:${name}:set-values`,
230
- (event) => form.setValues(event.detail)
231
- );
232
- useFormEvent(
233
- `mantine-form:${name}:set-initial-values`,
234
- (event) => form.setInitialValues(event.detail)
235
- );
236
- useFormEvent(
237
- `mantine-form:${name}:set-errors`,
238
- (event) => form.setErrors(event.detail)
239
- );
240
- useFormEvent(
241
- `mantine-form:${name}:set-field-error`,
242
- (event) => form.setFieldError(event.detail.path, event.detail.error)
243
- );
244
- useFormEvent(
245
- `mantine-form:${name}:clear-field-error`,
246
- (event) => form.clearFieldError(event.detail)
247
- );
248
- useFormEvent(`mantine-form:${name}:clear-errors`, form.clearErrors);
249
- useFormEvent(`mantine-form:${name}:reset`, form.reset);
250
- useFormEvent(`mantine-form:${name}:validate`, form.validate);
251
- useFormEvent(
252
- `mantine-form:${name}:validate-field`,
253
- (event) => form.validateField(event.detail)
254
- );
255
- useFormEvent(
256
- `mantine-form:${name}:reorder-list-item`,
257
- (event) => form.reorderListItem(event.detail.path, event.detail.payload)
258
- );
259
- useFormEvent(
260
- `mantine-form:${name}:remove-list-item`,
261
- (event) => form.removeListItem(event.detail.path, event.detail.index)
262
- );
263
- useFormEvent(
264
- `mantine-form:${name}:insert-list-item`,
265
- (event) => form.insertListItem(event.detail.path, event.detail.item, event.detail.index)
266
- );
267
- useFormEvent(
268
- `mantine-form:${name}:set-dirty`,
269
- (event) => form.setDirty(event.detail)
270
- );
271
- useFormEvent(
272
- `mantine-form:${name}:set-touched`,
273
- (event) => form.setTouched(event.detail)
274
- );
275
- useFormEvent(
276
- `mantine-form:${name}:reset-dirty`,
277
- (event) => form.resetDirty(event.detail)
278
- );
279
- useFormEvent(`mantine-form:${name}:reset-touched`, form.resetTouched);
280
- }
281
-
282
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/get-input-on-change/get-input-on-change.mjs
283
- function getInputOnChange(setValue) {
284
- return (val) => {
285
- if (!val) {
286
- setValue(val);
287
- } else if (typeof val === "function") {
288
- setValue(val);
289
- } else if (typeof val === "object" && "nativeEvent" in val) {
290
- const { currentTarget } = val;
291
- if (currentTarget instanceof HTMLInputElement) {
292
- if (currentTarget.type === "checkbox") {
293
- setValue(currentTarget.checked);
294
- } else {
295
- setValue(currentTarget.value);
296
- }
297
- } else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
298
- setValue(currentTarget.value);
299
- }
300
- } else {
301
- setValue(val);
302
- }
303
- };
304
- }
305
-
306
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
307
- import { useState as useState2, useRef, useCallback as useCallback2 } from "react";
308
-
309
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs
310
- function filterErrors(errors) {
311
- if (errors === null || typeof errors !== "object") {
312
- return {};
313
- }
314
- return Object.keys(errors).reduce((acc, key) => {
315
- const errorValue = errors[key];
316
- if (errorValue !== void 0 && errorValue !== null && errorValue !== false) {
317
- acc[key] = errorValue;
318
- }
319
- return acc;
320
- }, {});
321
- }
322
-
323
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
324
- function useFormErrors(initialErrors) {
325
- const [errorsState, setErrorsState] = useState2(filterErrors(initialErrors));
326
- const errorsRef = useRef(errorsState);
327
- const setErrors = useCallback2((errors) => {
328
- setErrorsState((current) => {
329
- const newErrors = filterErrors(typeof errors === "function" ? errors(current) : errors);
330
- errorsRef.current = newErrors;
331
- return newErrors;
332
- });
333
- }, []);
334
- const clearErrors = useCallback2(() => setErrors({}), []);
335
- const clearFieldError = useCallback2(
336
- (path) => {
337
- if (errorsRef.current[path] === void 0) {
338
- return;
339
- }
340
- setErrors((current) => {
341
- const errors = { ...current };
342
- delete errors[path];
343
- return errors;
344
- });
345
- },
346
- [errorsState]
347
- );
348
- const setFieldError = useCallback2(
349
- (path, error) => {
350
- if (error == null || error === false) {
351
- clearFieldError(path);
352
- } else if (errorsRef.current[path] !== error) {
353
- setErrors((current) => ({ ...current, [path]: error }));
354
- }
355
- },
356
- [errorsState]
357
- );
358
- return {
359
- errorsState,
360
- setErrors,
361
- clearErrors,
362
- setFieldError,
363
- clearFieldError
364
- };
365
- }
366
-
367
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
368
- import { useCallback as useCallback3 } from "react";
369
-
370
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/clear-list-state.mjs
371
- function clearListState(field, state) {
372
- if (state === null || typeof state !== "object") {
373
- return {};
374
- }
375
- const clone = { ...state };
376
- Object.keys(state).forEach((errorKey) => {
377
- if (errorKey.includes(`${String(field)}.`)) {
378
- delete clone[errorKey];
379
- }
380
- });
381
- return clone;
382
- }
383
-
384
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/change-error-indices.mjs
385
- function getIndexFromKeyAfterPath(key, path) {
386
- const split = key.substring(path.length + 1).split(".")[0];
387
- return parseInt(split, 10);
388
- }
389
- function changeErrorIndices(path, index, errors, change) {
390
- if (index === void 0) {
391
- return errors;
392
- }
393
- const pathString = `${String(path)}`;
394
- let clearedErrors = errors;
395
- if (change === -1) {
396
- clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);
397
- }
398
- const cloned = { ...clearedErrors };
399
- const changedKeys = /* @__PURE__ */ new Set();
400
- Object.entries(clearedErrors).filter(([key]) => {
401
- if (!key.startsWith(`${pathString}.`)) {
402
- return false;
403
- }
404
- const currIndex = getIndexFromKeyAfterPath(key, pathString);
405
- if (Number.isNaN(currIndex)) {
406
- return false;
407
- }
408
- return currIndex >= index;
409
- }).forEach(([key, value]) => {
410
- const currIndex = getIndexFromKeyAfterPath(key, pathString);
411
- const newKey = key.replace(
412
- `${pathString}.${currIndex}`,
413
- `${pathString}.${currIndex + change}`
414
- );
415
- cloned[newKey] = value;
416
- changedKeys.add(newKey);
417
- if (!changedKeys.has(key)) {
418
- delete cloned[key];
419
- }
420
- });
421
- return cloned;
422
- }
423
-
424
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/reorder-errors.mjs
425
- function reorderErrors(path, { from, to }, errors) {
426
- const oldKeyStart = `${path}.${from}`;
427
- const newKeyStart = `${path}.${to}`;
428
- const clone = { ...errors };
429
- Object.keys(errors).every((key) => {
430
- let oldKey;
431
- let newKey;
432
- if (key.startsWith(oldKeyStart)) {
433
- oldKey = key;
434
- newKey = key.replace(oldKeyStart, newKeyStart);
435
- }
436
- if (key.startsWith(newKeyStart)) {
437
- oldKey = key.replace(newKeyStart, oldKeyStart);
438
- newKey = key;
439
- }
440
- if (oldKey && newKey) {
441
- const value1 = clone[oldKey];
442
- const value2 = clone[newKey];
443
- value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
444
- value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
445
- return false;
446
- }
447
- return true;
448
- });
449
- return clone;
450
- }
451
-
452
- // ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/full/index.mjs
453
- function set(obj, key, val) {
454
- if (typeof val.value === "object") val.value = klona(val.value);
455
- if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
456
- Object.defineProperty(obj, key, val);
457
- } else obj[key] = val.value;
458
- }
459
- function klona(x) {
460
- if (typeof x !== "object") return x;
461
- var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
462
- if (str === "[object Object]") {
463
- tmp = Object.create(x.__proto__ || null);
464
- } else if (str === "[object Array]") {
465
- tmp = Array(x.length);
466
- } else if (str === "[object Set]") {
467
- tmp = /* @__PURE__ */ new Set();
468
- x.forEach(function(val) {
469
- tmp.add(klona(val));
470
- });
471
- } else if (str === "[object Map]") {
472
- tmp = /* @__PURE__ */ new Map();
473
- x.forEach(function(val, key) {
474
- tmp.set(klona(key), klona(val));
475
- });
476
- } else if (str === "[object Date]") {
477
- tmp = /* @__PURE__ */ new Date(+x);
478
- } else if (str === "[object RegExp]") {
479
- tmp = new RegExp(x.source, x.flags);
480
- } else if (str === "[object DataView]") {
481
- tmp = new x.constructor(klona(x.buffer));
482
- } else if (str === "[object ArrayBuffer]") {
483
- tmp = x.slice(0);
484
- } else if (str.slice(-6) === "Array]") {
485
- tmp = new x.constructor(x);
486
- }
487
- if (tmp) {
488
- for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
489
- set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
490
- }
491
- for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
492
- if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
493
- set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
494
- }
495
- }
496
- return tmp || x;
497
- }
498
-
499
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-splitted-path.mjs
500
- function getSplittedPath(path) {
501
- if (typeof path !== "string") {
502
- return [];
503
- }
504
- return path.split(".");
505
- }
506
-
507
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-path.mjs
508
- function getPath(path, values) {
509
- const splittedPath = getSplittedPath(path);
510
- if (splittedPath.length === 0 || typeof values !== "object" || values === null) {
511
- return void 0;
512
- }
513
- let value = values[splittedPath[0]];
514
- for (let i = 1; i < splittedPath.length; i += 1) {
515
- if (value === void 0) {
516
- break;
517
- }
518
- value = value[splittedPath[i]];
519
- }
520
- return value;
521
- }
522
-
523
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/set-path.mjs
524
- function setPath(path, value, values) {
525
- const splittedPath = getSplittedPath(path);
526
- if (splittedPath.length === 0) {
527
- return values;
528
- }
529
- const cloned = klona(values);
530
- if (splittedPath.length === 1) {
531
- cloned[splittedPath[0]] = value;
532
- return cloned;
533
- }
534
- let val = cloned[splittedPath[0]];
535
- for (let i = 1; i < splittedPath.length - 1; i += 1) {
536
- if (val === void 0) {
537
- return cloned;
538
- }
539
- val = val[splittedPath[i]];
540
- }
541
- val[splittedPath[splittedPath.length - 1]] = value;
542
- return cloned;
543
- }
544
-
545
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/reorder-path.mjs
546
- function reorderPath(path, { from, to }, values) {
547
- const currentValue = getPath(path, values);
548
- if (!Array.isArray(currentValue)) {
549
- return values;
550
- }
551
- const cloned = [...currentValue];
552
- const item = currentValue[from];
553
- cloned.splice(from, 1);
554
- cloned.splice(to, 0, item);
555
- return setPath(path, cloned, values);
556
- }
557
-
558
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/insert-path.mjs
559
- function insertPath(path, value, index, values) {
560
- const currentValue = getPath(path, values);
561
- if (!Array.isArray(currentValue)) {
562
- return values;
563
- }
564
- const cloned = [...currentValue];
565
- cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
566
- return setPath(path, cloned, values);
567
- }
568
-
569
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/remove-path.mjs
570
- function removePath(path, index, values) {
571
- const currentValue = getPath(path, values);
572
- if (!Array.isArray(currentValue)) {
573
- return values;
574
- }
575
- return setPath(
576
- path,
577
- currentValue.filter((_, itemIndex) => itemIndex !== index),
578
- values
579
- );
580
- }
581
-
582
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
583
- function useFormList({
584
- $values,
585
- $errors,
586
- $status
587
- }) {
588
- const reorderListItem = useCallback3((path, payload) => {
589
- $status.clearFieldDirty(path);
590
- $errors.setErrors((errs) => reorderErrors(path, payload, errs));
591
- $values.setValues({
592
- values: reorderPath(path, payload, $values.refValues.current),
593
- updateState: true
594
- });
595
- }, []);
596
- const removeListItem = useCallback3((path, index) => {
597
- $status.clearFieldDirty(path);
598
- $errors.setErrors((errs) => changeErrorIndices(path, index, errs, -1));
599
- $values.setValues({
600
- values: removePath(path, index, $values.refValues.current),
601
- updateState: true
602
- });
603
- }, []);
604
- const insertListItem = useCallback3((path, item, index) => {
605
- $status.clearFieldDirty(path);
606
- $errors.setErrors((errs) => changeErrorIndices(path, index, errs, 1));
607
- $values.setValues({
608
- values: insertPath(path, item, index, $values.refValues.current),
609
- updateState: true
610
- });
611
- }, []);
612
- return { reorderListItem, removeListItem, insertListItem };
613
- }
614
-
615
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
616
- var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
617
- import { useState as useState3, useRef as useRef2, useCallback as useCallback4 } from "react";
618
-
619
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/get-status/get-status.mjs
620
- function getStatus(status, path) {
621
- const paths = Object.keys(status);
622
- if (typeof path === "string") {
623
- const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
624
- return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
625
- }
626
- return paths.some((statusPath) => status[statusPath]);
627
- }
628
-
629
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
630
- function useFormStatus({
631
- initialDirty,
632
- initialTouched,
633
- mode,
634
- $values
635
- }) {
636
- const [touchedState, setTouchedState] = useState3(initialTouched);
637
- const [dirtyState, setDirtyState] = useState3(initialDirty);
638
- const touchedRef = useRef2(initialTouched);
639
- const dirtyRef = useRef2(initialDirty);
640
- const setTouched = useCallback4((values) => {
641
- const resolvedValues = typeof values === "function" ? values(touchedRef.current) : values;
642
- touchedRef.current = resolvedValues;
643
- if (mode === "controlled") {
644
- setTouchedState(resolvedValues);
645
- }
646
- }, []);
647
- const setDirty = useCallback4((values) => {
648
- const resolvedValues = typeof values === "function" ? values(dirtyRef.current) : values;
649
- dirtyRef.current = resolvedValues;
650
- if (mode === "controlled") {
651
- setDirtyState(resolvedValues);
652
- }
653
- }, []);
654
- const resetTouched = useCallback4(() => setTouched({}), []);
655
- const resetDirty = (values) => {
656
- const newSnapshot = values ? { ...values, ...$values.refValues.current } : $values.refValues.current;
657
- $values.setValuesSnapshot(newSnapshot);
658
- setDirty({});
659
- };
660
- const setFieldTouched = useCallback4((path, touched) => {
661
- setTouched((currentTouched) => {
662
- if (getStatus(currentTouched, path) === touched) {
663
- return currentTouched;
664
- }
665
- return { ...currentTouched, [path]: touched };
666
- });
667
- }, []);
668
- const setFieldDirty = useCallback4((path, dirty) => {
669
- setDirty((currentDirty) => {
670
- if (getStatus(currentDirty, path) === dirty) {
671
- return currentDirty;
672
- }
673
- return { ...currentDirty, [path]: dirty };
674
- });
675
- }, []);
676
- const isTouched = useCallback4(
677
- (path) => getStatus(touchedRef.current, path),
678
- []
679
- );
680
- const clearFieldDirty = useCallback4(
681
- (path) => setDirty((current) => {
682
- if (typeof path !== "string") {
683
- return current;
684
- }
685
- const result = clearListState(path, current);
686
- delete result[path];
687
- if ((0, import_fast_deep_equal.default)(result, current)) {
688
- return current;
689
- }
690
- return result;
691
- }),
692
- []
693
- );
694
- const isDirty = useCallback4((path) => {
695
- if (path) {
696
- const overriddenValue = getPath(path, dirtyRef.current);
697
- if (typeof overriddenValue === "boolean") {
698
- return overriddenValue;
699
- }
700
- const sliceOfValues = getPath(path, $values.refValues.current);
701
- const sliceOfInitialValues = getPath(path, $values.valuesSnapshot.current);
702
- return !(0, import_fast_deep_equal.default)(sliceOfValues, sliceOfInitialValues);
703
- }
704
- const isOverridden = Object.keys(dirtyRef.current).length > 0;
705
- if (isOverridden) {
706
- return getStatus(dirtyRef.current);
707
- }
708
- return !(0, import_fast_deep_equal.default)($values.refValues.current, $values.valuesSnapshot.current);
709
- }, []);
710
- const getDirty = useCallback4(() => dirtyRef.current, []);
711
- const getTouched = useCallback4(() => touchedRef.current, []);
712
- return {
713
- touchedState,
714
- dirtyState,
715
- touchedRef,
716
- dirtyRef,
717
- setTouched,
718
- setDirty,
719
- resetDirty,
720
- resetTouched,
721
- isTouched,
722
- setFieldTouched,
723
- setFieldDirty,
724
- setTouchedState,
725
- setDirtyState,
726
- clearFieldDirty,
727
- isDirty,
728
- getDirty,
729
- getTouched
730
- };
731
- }
732
-
733
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
734
- import { useRef as useRef3, useState as useState4, useCallback as useCallback5 } from "react";
735
- function useFormValues({
736
- initialValues,
737
- onValuesChange,
738
- mode
739
- }) {
740
- const initialized = useRef3(false);
741
- const [stateValues, setStateValues] = useState4(initialValues || {});
742
- const refValues = useRef3(stateValues);
743
- const valuesSnapshot = useRef3(stateValues);
744
- const setValues = useCallback5(
745
- ({
746
- values,
747
- subscribers,
748
- updateState = true,
749
- mergeWithPreviousValues = true
750
- }) => {
751
- const previousValues = refValues.current;
752
- const resolvedValues = values instanceof Function ? values(refValues.current) : values;
753
- const updatedValues = mergeWithPreviousValues ? { ...previousValues, ...resolvedValues } : resolvedValues;
754
- refValues.current = updatedValues;
755
- updateState && setStateValues(updatedValues);
756
- onValuesChange?.(updatedValues, previousValues);
757
- subscribers?.filter(Boolean).forEach((subscriber) => subscriber({ updatedValues, previousValues }));
758
- },
759
- [onValuesChange]
760
- );
761
- const setFieldValue = useCallback5((payload) => {
762
- const currentValue = getPath(payload.path, refValues.current);
763
- const updatedValue = payload.value instanceof Function ? payload.value(currentValue) : payload.value;
764
- if (currentValue !== updatedValue) {
765
- const previousValues = refValues.current;
766
- const updatedValues = setPath(payload.path, updatedValue, refValues.current);
767
- setValues({ values: updatedValues, updateState: payload.updateState });
768
- payload.subscribers?.filter(Boolean).forEach(
769
- (subscriber) => subscriber({ path: payload.path, updatedValues, previousValues })
770
- );
771
- }
772
- }, []);
773
- const setValuesSnapshot = useCallback5((payload) => {
774
- valuesSnapshot.current = payload;
775
- }, []);
776
- const initialize = useCallback5((values, onInitialize) => {
777
- if (!initialized.current) {
778
- initialized.current = true;
779
- setValues({ values, updateState: mode === "controlled" });
780
- setValuesSnapshot(values);
781
- onInitialize();
782
- }
783
- }, []);
784
- const resetValues = useCallback5(() => {
785
- setValues({
786
- values: valuesSnapshot.current,
787
- updateState: true,
788
- mergeWithPreviousValues: false
789
- });
790
- }, []);
791
- const getValues = useCallback5(() => refValues.current, []);
792
- return {
793
- initialized,
794
- stateValues,
795
- refValues,
796
- valuesSnapshot,
797
- setValues,
798
- setFieldValue,
799
- resetValues,
800
- setValuesSnapshot,
801
- initialize,
802
- getValues
803
- };
804
- }
805
-
806
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
807
- import { useRef as useRef4, useCallback as useCallback6, useEffect as useEffect5 } from "react";
808
- function useFormWatch({
809
- $status
810
- }) {
811
- const subscribers = useRef4(
812
- {}
813
- );
814
- const watch = useCallback6((path, callback) => {
815
- useEffect5(() => {
816
- subscribers.current[path] = subscribers.current[path] || [];
817
- subscribers.current[path].push(callback);
818
- return () => {
819
- subscribers.current[path] = subscribers.current[path].filter((cb) => cb !== callback);
820
- };
821
- }, [callback]);
822
- }, []);
823
- const getFieldSubscribers = useCallback6((path) => {
824
- if (!subscribers.current[path]) {
825
- return [];
826
- }
827
- return subscribers.current[path].map(
828
- (callback) => (input) => callback({
829
- previousValue: getPath(path, input.previousValues),
830
- value: getPath(path, input.updatedValues),
831
- touched: $status.isTouched(path),
832
- dirty: $status.isDirty(path)
833
- })
834
- );
835
- }, []);
836
- return {
837
- subscribers,
838
- watch,
839
- getFieldSubscribers
840
- };
841
- }
842
-
843
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-data-path.mjs
844
- function getDataPath(formName, fieldPath) {
845
- return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();
846
- }
847
-
848
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/validate-values.mjs
849
- function getValidationResults(errors) {
850
- const filteredErrors = filterErrors(errors);
851
- return { hasErrors: Object.keys(filteredErrors).length > 0, errors: filteredErrors };
852
- }
853
- function validateRulesRecord(rules, values, path = "", errors = {}) {
854
- if (typeof rules !== "object" || rules === null) {
855
- return errors;
856
- }
857
- return Object.keys(rules).reduce((acc, ruleKey) => {
858
- const rule = rules[ruleKey];
859
- const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
860
- const value = getPath(rulePath, values);
861
- let arrayValidation = false;
862
- if (typeof rule === "function") {
863
- acc[rulePath] = rule(value, values, rulePath);
864
- }
865
- if (typeof rule === "object" && Array.isArray(value)) {
866
- arrayValidation = true;
867
- value.forEach(
868
- (_item, index) => validateRulesRecord(rule, values, `${rulePath}.${index}`, acc)
869
- );
870
- }
871
- if (typeof rule === "object" && typeof value === "object" && value !== null) {
872
- if (!arrayValidation) {
873
- validateRulesRecord(rule, values, rulePath, acc);
874
- }
875
- }
876
- return acc;
877
- }, errors);
878
- }
879
- function validateValues(validate, values) {
880
- if (typeof validate === "function") {
881
- return getValidationResults(validate(values));
882
- }
883
- return getValidationResults(validateRulesRecord(validate, values));
884
- }
885
-
886
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/validate-field-value.mjs
887
- function validateFieldValue(path, rules, values) {
888
- if (typeof path !== "string") {
889
- return { hasError: false, error: null };
890
- }
891
- const results = validateValues(rules, values);
892
- const pathInError = Object.keys(results.errors).find(
893
- (errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i])
894
- );
895
- return { hasError: !!pathInError, error: pathInError ? results.errors[pathInError] : null };
896
- }
897
-
898
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/form-index.mjs
899
- var FORM_INDEX = "__MANTINE_FORM_INDEX__";
900
-
901
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
902
- function shouldValidateOnChange(path, validateInputOnChange) {
903
- if (!validateInputOnChange) {
904
- return false;
905
- }
906
- if (typeof validateInputOnChange === "boolean") {
907
- return validateInputOnChange;
908
- }
909
- if (Array.isArray(validateInputOnChange)) {
910
- return validateInputOnChange.includes(path.replace(/[.][0-9]/g, `.${FORM_INDEX}`));
911
- }
912
- return false;
913
- }
914
-
915
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/use-form.mjs
916
- function useForm({
917
- name,
918
- mode = "controlled",
919
- initialValues,
920
- initialErrors = {},
921
- initialDirty = {},
922
- initialTouched = {},
923
- clearInputErrorOnChange = true,
924
- validateInputOnChange = false,
925
- validateInputOnBlur = false,
926
- onValuesChange,
927
- transformValues = (values) => values,
928
- enhanceGetInputProps,
929
- validate: rules
930
- } = {}) {
931
- const $errors = useFormErrors(initialErrors);
932
- const $values = useFormValues({ initialValues, onValuesChange, mode });
933
- const $status = useFormStatus({ initialDirty, initialTouched, $values, mode });
934
- const $list = useFormList({ $values, $errors, $status });
935
- const $watch = useFormWatch({ $status });
936
- const [formKey, setFormKey] = useState5(0);
937
- const [fieldKeys, setFieldKeys] = useState5({});
938
- const reset = useCallback7(() => {
939
- $values.resetValues();
940
- $errors.clearErrors();
941
- $status.resetDirty();
942
- $status.resetTouched();
943
- mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
944
- }, []);
945
- const initialize = useCallback7((values) => {
946
- $values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
947
- }, []);
948
- const setFieldValue = useCallback7(
949
- (path, value, options2) => {
950
- const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
951
- $status.clearFieldDirty(path);
952
- $status.setFieldTouched(path, true);
953
- !shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
954
- $values.setFieldValue({
955
- path,
956
- value,
957
- updateState: mode === "controlled",
958
- subscribers: [
959
- ...$watch.getFieldSubscribers(path),
960
- shouldValidate ? (payload) => {
961
- const validationResults = validateFieldValue(path, rules, payload.updatedValues);
962
- validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
963
- } : null,
964
- options2?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
965
- ...keys,
966
- [path]: (keys[path] || 0) + 1
967
- })) : null
968
- ]
969
- });
970
- },
971
- [onValuesChange, rules]
972
- );
973
- const setValues = useCallback7(
974
- (values) => {
975
- const previousValues = $values.refValues.current;
976
- $values.setValues({ values, updateState: mode === "controlled" });
977
- clearInputErrorOnChange && $errors.clearErrors();
978
- mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
979
- Object.keys($watch.subscribers.current).forEach((path) => {
980
- const value = getPath(path, $values.refValues.current);
981
- const previousValue = getPath(path, previousValues);
982
- if (value !== previousValue) {
983
- $watch.getFieldSubscribers(path).forEach((cb) => cb({ previousValues, updatedValues: $values.refValues.current }));
984
- }
985
- });
986
- },
987
- [onValuesChange, clearInputErrorOnChange]
988
- );
989
- const validate = useCallback7(() => {
990
- const results = validateValues(rules, $values.refValues.current);
991
- $errors.setErrors(results.errors);
992
- return results;
993
- }, [rules]);
994
- const validateField = useCallback7(
995
- (path) => {
996
- const results = validateFieldValue(path, rules, $values.refValues.current);
997
- results.hasError ? $errors.setFieldError(path, results.error) : $errors.clearFieldError(path);
998
- return results;
999
- },
1000
- [rules]
1001
- );
1002
- const getInputProps = (path, { type = "input", withError = true, withFocus = true, ...otherOptions } = {}) => {
1003
- const onChange = getInputOnChange(
1004
- (value) => setFieldValue(path, value, { forceUpdate: false })
1005
- );
1006
- const payload = { onChange, "data-path": getDataPath(name, path) };
1007
- if (withError) {
1008
- payload.error = $errors.errorsState[path];
1009
- }
1010
- if (type === "checkbox") {
1011
- payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(
1012
- path,
1013
- $values.refValues.current
1014
- );
1015
- } else {
1016
- payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(
1017
- path,
1018
- $values.refValues.current
1019
- );
1020
- }
1021
- if (withFocus) {
1022
- payload.onFocus = () => $status.setFieldTouched(path, true);
1023
- payload.onBlur = () => {
1024
- if (shouldValidateOnChange(path, validateInputOnBlur)) {
1025
- const validationResults = validateFieldValue(path, rules, $values.refValues.current);
1026
- validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
1027
- }
1028
- };
1029
- }
1030
- return Object.assign(
1031
- payload,
1032
- enhanceGetInputProps?.({
1033
- inputProps: payload,
1034
- field: path,
1035
- options: { type, withError, withFocus, ...otherOptions },
1036
- form
1037
- })
1038
- );
1039
- };
1040
- const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
1041
- event?.preventDefault();
1042
- const results = validate();
1043
- if (results.hasErrors) {
1044
- handleValidationFailure?.(results.errors, $values.refValues.current, event);
1045
- } else {
1046
- handleSubmit?.(transformValues($values.refValues.current), event);
1047
- }
1048
- };
1049
- const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
1050
- const onReset = useCallback7((event) => {
1051
- event.preventDefault();
1052
- reset();
1053
- }, []);
1054
- const isValid = useCallback7(
1055
- (path) => path ? !validateFieldValue(path, rules, $values.refValues.current).hasError : !validateValues(rules, $values.refValues.current).hasErrors,
1056
- [rules]
1057
- );
1058
- const key = (path) => `${formKey}-${path}-${fieldKeys[path] || 0}`;
1059
- const getInputNode = useCallback7(
1060
- (path) => document.querySelector(`[data-path="${getDataPath(name, path)}"]`),
1061
- []
1062
- );
1063
- const form = {
1064
- watch: $watch.watch,
1065
- initialized: $values.initialized.current,
1066
- values: $values.stateValues,
1067
- getValues: $values.getValues,
1068
- setInitialValues: $values.setValuesSnapshot,
1069
- initialize,
1070
- setValues,
1071
- setFieldValue,
1072
- errors: $errors.errorsState,
1073
- setErrors: $errors.setErrors,
1074
- setFieldError: $errors.setFieldError,
1075
- clearFieldError: $errors.clearFieldError,
1076
- clearErrors: $errors.clearErrors,
1077
- resetDirty: $status.resetDirty,
1078
- setTouched: $status.setTouched,
1079
- setDirty: $status.setDirty,
1080
- isTouched: $status.isTouched,
1081
- resetTouched: $status.resetTouched,
1082
- isDirty: $status.isDirty,
1083
- getTouched: $status.getTouched,
1084
- getDirty: $status.getDirty,
1085
- reorderListItem: $list.reorderListItem,
1086
- insertListItem: $list.insertListItem,
1087
- removeListItem: $list.removeListItem,
1088
- reset,
1089
- validate,
1090
- validateField,
1091
- getInputProps,
1092
- onSubmit,
1093
- onReset,
1094
- isValid,
1095
- getTransformedValues,
1096
- key,
1097
- getInputNode
1098
- };
1099
- useFormActions(name, form);
1100
- return form;
1101
- }
1102
-
1103
- // src/nodes/modifiers/noise-curve-node.tsx
1104
- import { useCallback as useCallback8, useEffect as useEffect6, useState as useState6 } from "react";
1105
- import { Curve, Tuple } from "libnoise-simplex-ts";
1106
- import { IconX } from "@tabler/icons-react";
1107
- import { randomId } from "@mantine/hooks";
1108
- import { NodeState } from "@awesome-flow/core/abstract";
1109
- import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1110
- function NoiseCurveNode({ id, selected, data, type }) {
1111
- const incoming = useIncomingComputedData4(id);
1112
- const updateNodeData = useUpdateNodeData3();
1113
- const updateComputedData = useUpdateNodeComputedData4();
1114
- const [values, setValues] = useState6([]);
1115
- const form = useForm({
1116
- mode: "uncontrolled",
1117
- initialValues: {
1118
- points: []
1119
- },
1120
- validateInputOnChange: [`points.${FORM_INDEX}.input`],
1121
- clearInputErrorOnChange: true,
1122
- validate: {
1123
- points: {
1124
- input: (value, values2) => {
1125
- const counts = {};
1126
- values2.points.forEach((x) => {
1127
- counts[x.input] = (counts[x.input] || 0) + 1;
1128
- });
1129
- return counts[value] > 1;
1130
- }
1131
- }
1132
- },
1133
- onValuesChange: useCallback8((values2) => {
1134
- if (form.isValid()) {
1135
- const points = values2.points.map((v) => ({ input: v.input, output: v.output }));
1136
- setValues(points);
1137
- updateNodeData(id, { points });
1138
- }
1139
- form.validate();
1140
- }, [])
1141
- });
1142
- useEffect6(() => {
1143
- const points = data.points?.length ? data.points.map((v) => ({ input: v.input, output: v.output, key: randomId() })) : [1, 2, 3, 4].map(() => ({ input: 0, output: 0, key: randomId() }));
1144
- form.initialize({ points });
1145
- }, []);
1146
- useEffect6(() => {
1147
- if (incoming?.length && values?.length >= 4) {
1148
- const module = new Curve(
1149
- incoming[0].module,
1150
- values.map((p) => new Tuple(p.input, p.output))
1151
- );
1152
- updateComputedData(id, { module });
1153
- }
1154
- }, [values, incoming]);
1155
- const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs3(Group2, { mt: "xs", children: [
1156
- /* @__PURE__ */ jsx4(
1157
- NumberInput2,
1158
- {
1159
- size: "xs",
1160
- w: 100,
1161
- placeholder: "Input Value",
1162
- ...form.getInputProps(`points.${index}.input`),
1163
- step: 0.1
1164
- },
1165
- form.key(`points.${index}.input`)
1166
- ),
1167
- /* @__PURE__ */ jsx4(
1168
- NumberInput2,
1169
- {
1170
- size: "xs",
1171
- w: 100,
1172
- placeholder: "Output Value",
1173
- ...form.getInputProps(`points.${index}.output`),
1174
- step: 0.1
1175
- },
1176
- form.key(`points.${index}.output`)
1177
- ),
1178
- data.state === NodeState.edit && values.length > 4 && /* @__PURE__ */ jsx4(
1179
- ActionIcon,
1180
- {
1181
- color: "red",
1182
- variant: "outline",
1183
- size: "sm",
1184
- onClick: () => form.removeListItem("points", index),
1185
- children: /* @__PURE__ */ jsx4(IconX, { size: "1rem" })
1186
- }
1187
- )
1188
- ] }, item.key));
1189
- return /* @__PURE__ */ jsxs3(NodeContainer4, { id, selected, type, data, children: [
1190
- fields,
1191
- data.state === NodeState.edit && /* @__PURE__ */ jsxs3(Fragment, { children: [
1192
- /* @__PURE__ */ jsx4(Space, { h: 10 }),
1193
- /* @__PURE__ */ jsx4(
1194
- Button,
1195
- {
1196
- variant: "outline",
1197
- size: "xs",
1198
- fullWidth: true,
1199
- onClick: () => form.insertListItem("points", { input: 0, output: 0, key: randomId() }),
1200
- children: "Add control point"
1201
- }
1202
- )
1203
- ] }),
1204
- /* @__PURE__ */ jsx4(NodeTrackConnections4, { handles: data.handles, nodeId: id, type: "target" })
1205
- ] });
1206
- }
1207
- var noise_curve_node_default = NoiseCurveNode;
1208
-
1209
- // src/nodes/modifiers/noise-exponent-node.tsx
1210
- import { NodeContainer as NodeContainer5, NodeTrackConnections as NodeTrackConnections5 } from "@awesome-flow/core/layout";
1211
- import { useEffect as useEffect7, useState as useState7 } from "react";
1212
- import { Group as Group3, NumberInput as NumberInput3, Stack as Stack2 } from "@mantine/core";
1213
- import {
1214
- useIncomingComputedData as useIncomingComputedData5,
1215
- useUpdateNodeComputedData as useUpdateNodeComputedData5,
1216
- useUpdateNodeData as useUpdateNodeData4
1217
- } from "@awesome-flow/core/hooks";
1218
- import { Exponent } from "libnoise-simplex-ts";
1219
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1220
- function NoiseExponentNode({ id, selected, data, type }) {
1221
- const [exponent, setExponent] = useState7(data.exponent);
1222
- const incoming = useIncomingComputedData5(id);
1223
- const updateNodeData = useUpdateNodeData4();
1224
- const updateComputedData = useUpdateNodeComputedData5();
1225
- useEffect7(() => {
1226
- if (incoming?.length > 0) {
1227
- const module = new Exponent(incoming[0].module, exponent);
1228
- updateComputedData(id, { module });
1229
- }
1230
- updateNodeData(id, { exponent });
1231
- }, [incoming, exponent]);
1232
- return /* @__PURE__ */ jsxs4(NodeContainer5, { id, selected, data, type, children: [
1233
- /* @__PURE__ */ jsx5(Stack2, { children: /* @__PURE__ */ jsxs4(Group3, { children: [
1234
- "Exponent:",
1235
- /* @__PURE__ */ jsx5(
1236
- NumberInput3,
1237
- {
1238
- size: "xs",
1239
- value: exponent,
1240
- onChange: (e) => setExponent(Number(e)),
1241
- step: 0.1
1242
- }
1243
- )
1244
- ] }) }),
1245
- /* @__PURE__ */ jsx5(NodeTrackConnections5, { handles: data.handles, nodeId: id, type: "target" })
1246
- ] });
1247
- }
1248
- var noise_exponent_node_default = NoiseExponentNode;
1249
-
1250
- // src/nodes/modifiers/noise-invert-node.tsx
1251
- import { NodeContainer as NodeContainer6, NodeTrackConnections as NodeTrackConnections6 } from "@awesome-flow/core/layout";
1252
- import { useEffect as useEffect8 } from "react";
1253
- import { useIncomingComputedData as useIncomingComputedData6, useUpdateNodeComputedData as useUpdateNodeComputedData6 } from "@awesome-flow/core/hooks";
1254
- import { Invert } from "libnoise-simplex-ts";
1255
- import { jsx as jsx6 } from "react/jsx-runtime";
1256
- function NoiseInvertNode({ id, selected, data, type }) {
1257
- const incoming = useIncomingComputedData6(id);
1258
- const updateComputedData = useUpdateNodeComputedData6();
1259
- useEffect8(() => {
1260
- if (incoming?.length > 0) {
1261
- const module = new Invert(incoming[0].module);
1262
- updateComputedData(id, { module });
1263
- }
1264
- }, [incoming]);
1265
- return /* @__PURE__ */ jsx6(NodeContainer6, { id, selected, data, type, children: /* @__PURE__ */ jsx6(NodeTrackConnections6, { handles: data.handles, nodeId: id, type: "target" }) });
1266
- }
1267
- var noise_invert_node_default = NoiseInvertNode;
1268
-
1269
- // src/nodes/modifiers/noise-normalize-node.tsx
1270
- import { NodeContainer as NodeContainer7, NodeTrackConnections as NodeTrackConnections7 } from "@awesome-flow/core/layout";
1271
- import { useEffect as useEffect9, useState as useState8 } from "react";
1272
- import { Group as Group4, NumberInput as NumberInput4, Stack as Stack3 } from "@mantine/core";
1273
- import {
1274
- useIncomingComputedData as useIncomingComputedData7,
1275
- useUpdateNodeComputedData as useUpdateNodeComputedData7,
1276
- useUpdateNodeData as useUpdateNodeData5
1277
- } from "@awesome-flow/core/hooks";
1278
-
1279
- // src/modules/normalize-noise-module.ts
1280
- import { ModifierModule } from "libnoise-simplex-ts";
1281
- var NormalizeNoiseModule = class extends ModifierModule {
1282
- constructor(source, lowerBound, upperBound) {
1283
- super(source);
1284
- this.lowerBound = lowerBound;
1285
- this.upperBound = upperBound;
1286
- }
1287
- getValue(x, y, z) {
1288
- return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
1289
- }
1290
- };
1291
- function normalize(value, min, max) {
1292
- return (value - min) / (max - min);
1293
- }
1294
-
1295
- // src/nodes/modifiers/noise-normalize-node.tsx
1296
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1297
- function NoiseNormalizeNode({ id, selected, data, type }) {
1298
- const [intervalStart, setIntervalStart] = useState8(data.intervalStart);
1299
- const [intervalEnd, setIntervalEnd] = useState8(data.intervalEnd);
1300
- const incoming = useIncomingComputedData7(id);
1301
- const updateNodeData = useUpdateNodeData5();
1302
- const updateComputedData = useUpdateNodeComputedData7();
1303
- useEffect9(() => {
1304
- if (incoming?.length) {
1305
- const source = incoming[0].module;
1306
- const module = new NormalizeNoiseModule(source, intervalStart, intervalEnd);
1307
- updateComputedData(id, { module });
1308
- }
1309
- updateNodeData(id, { intervalStart, intervalEnd });
1310
- }, [incoming, intervalStart, intervalEnd]);
1311
- return /* @__PURE__ */ jsxs5(NodeContainer7, { id, selected, data, type, children: [
1312
- /* @__PURE__ */ jsx7(Stack3, { children: /* @__PURE__ */ jsxs5(Group4, { children: [
1313
- /* @__PURE__ */ jsx7(
1314
- NumberInput4,
1315
- {
1316
- size: "xs",
1317
- w: 100,
1318
- value: intervalStart,
1319
- onChange: (e) => setIntervalStart(Number(e))
1320
- }
1321
- ),
1322
- /* @__PURE__ */ jsx7(
1323
- NumberInput4,
1324
- {
1325
- size: "xs",
1326
- w: 100,
1327
- value: intervalEnd,
1328
- onChange: (e) => setIntervalEnd(Number(e))
1329
- }
1330
- )
1331
- ] }) }),
1332
- /* @__PURE__ */ jsx7(NodeTrackConnections7, { handles: data.handles, nodeId: id, type: "target" })
1333
- ] });
1334
- }
1335
- var noise_normalize_node_default = NoiseNormalizeNode;
1336
-
1337
- // src/nodes/modifiers/noise-scale-bias-node.tsx
1338
- import { NodeContainer as NodeContainer8, NodeTrackConnections as NodeTrackConnections8 } from "@awesome-flow/core/layout";
1339
- import { useEffect as useEffect10, useState as useState9 } from "react";
1340
- import { Group as Group5, NumberInput as NumberInput5, Stack as Stack4 } from "@mantine/core";
1341
- import {
1342
- useIncomingComputedData as useIncomingComputedData8,
1343
- useUpdateNodeComputedData as useUpdateNodeComputedData8,
1344
- useUpdateNodeData as useUpdateNodeData6
1345
- } from "@awesome-flow/core/hooks";
1346
- import { ScaleBias } from "libnoise-simplex-ts";
1347
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1348
- function NoiseScaleBiasNode({ id, selected, data, type }) {
1349
- const [scale, setScale] = useState9(data.scale);
1350
- const [bias, setBias] = useState9(data.bias);
1351
- const incoming = useIncomingComputedData8(id);
1352
- const updateNodeData = useUpdateNodeData6();
1353
- const updateComputedData = useUpdateNodeComputedData8();
1354
- useEffect10(() => {
1355
- if (incoming?.length > 0) {
1356
- const module = new ScaleBias(incoming[0].module, scale, bias);
1357
- updateComputedData(id, { module });
1358
- }
1359
- updateNodeData(id, { scale, bias });
1360
- }, [incoming, scale, bias]);
1361
- return /* @__PURE__ */ jsxs6(NodeContainer8, { id, selected, data, type, children: [
1362
- /* @__PURE__ */ jsxs6(Stack4, { children: [
1363
- /* @__PURE__ */ jsxs6(Group5, { children: [
1364
- "Scale:",
1365
- /* @__PURE__ */ jsx8(
1366
- NumberInput5,
1367
- {
1368
- size: "xs",
1369
- w: 100,
1370
- value: scale,
1371
- onChange: (e) => setScale(Number(e)),
1372
- step: 0.1
1373
- }
1374
- )
1375
- ] }),
1376
- /* @__PURE__ */ jsxs6(Group5, { children: [
1377
- "Bias:",
1378
- /* @__PURE__ */ jsx8(
1379
- NumberInput5,
1380
- {
1381
- size: "xs",
1382
- w: 100,
1383
- value: bias,
1384
- onChange: (e) => setBias(Number(e)),
1385
- step: 0.1
1386
- }
1387
- )
1388
- ] })
1389
- ] }),
1390
- /* @__PURE__ */ jsx8(NodeTrackConnections8, { handles: data.handles, nodeId: id, type: "target" })
1391
- ] });
1392
- }
1393
- var noise_scale_bias_node_default = NoiseScaleBiasNode;
1394
-
1395
- // src/nodes/modifiers/noise-terrace-node.tsx
1396
- import { NodeContainer as NodeContainer9, NodeTrackConnections as NodeTrackConnections9 } from "@awesome-flow/core/layout";
1397
- import { ActionIcon as ActionIcon2, Button as Button2, Group as Group6, NumberInput as NumberInput6, Space as Space2 } from "@mantine/core";
1398
1
  import {
1399
- useIncomingComputedData as useIncomingComputedData9,
1400
- useUpdateNodeComputedData as useUpdateNodeComputedData9,
1401
- useUpdateNodeData as useUpdateNodeData7
1402
- } from "@awesome-flow/core/hooks";
1403
- import { useCallback as useCallback9, useEffect as useEffect11, useState as useState10 } from "react";
1404
- import { Terrace } from "libnoise-simplex-ts";
1405
- import { IconX as IconX2 } from "@tabler/icons-react";
1406
- import { randomId as randomId2 } from "@mantine/hooks";
1407
- import { NodeState as NodeState2 } from "@awesome-flow/core/abstract";
1408
- import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1409
- function NoiseTerraceNode({ id, selected, data, type }) {
1410
- const incoming = useIncomingComputedData9(id);
1411
- const updateNodeData = useUpdateNodeData7();
1412
- const updateComputedData = useUpdateNodeComputedData9();
1413
- const [values, setValues] = useState10([]);
1414
- const form = useForm({
1415
- mode: "uncontrolled",
1416
- initialValues: {
1417
- points: []
1418
- },
1419
- validateInputOnChange: [`points.${FORM_INDEX}.input`],
1420
- clearInputErrorOnChange: true,
1421
- onValuesChange: useCallback9((values2) => {
1422
- if (form.isValid()) {
1423
- const points = values2.points.map((v) => v.value);
1424
- setValues(points);
1425
- updateNodeData(id, { points });
1426
- }
1427
- form.validate();
1428
- }, [])
1429
- });
1430
- useEffect11(() => {
1431
- const points = data.points?.length ? data.points.map((v) => ({ value: v, key: randomId2() })) : [1, 2].map(() => ({ value: 0, key: randomId2() }));
1432
- form.initialize({ points });
1433
- }, []);
1434
- useEffect11(() => {
1435
- if (incoming?.length && values?.length >= 2) {
1436
- const module = new Terrace(incoming[0].module, values);
1437
- updateComputedData(id, { module });
1438
- }
1439
- }, [values, incoming]);
1440
- const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs7(Group6, { mt: "xs", children: [
1441
- /* @__PURE__ */ jsx9(
1442
- NumberInput6,
1443
- {
1444
- size: "xs",
1445
- placeholder: "Input Value",
1446
- ...form.getInputProps(`points.${index}.value`),
1447
- step: 0.1
1448
- },
1449
- form.key(`points.${index}.value`)
1450
- ),
1451
- data.state === NodeState2.edit && values.length > 2 && /* @__PURE__ */ jsx9(
1452
- ActionIcon2,
1453
- {
1454
- color: "red",
1455
- variant: "outline",
1456
- size: "sm",
1457
- onClick: () => form.removeListItem("points", index),
1458
- children: /* @__PURE__ */ jsx9(IconX2, { size: "1rem" })
1459
- }
1460
- )
1461
- ] }, item.key));
1462
- return /* @__PURE__ */ jsxs7(NodeContainer9, { id, selected, type, data, children: [
1463
- fields,
1464
- data.state === NodeState2.edit && /* @__PURE__ */ jsxs7(Fragment2, { children: [
1465
- /* @__PURE__ */ jsx9(Space2, { h: 10 }),
1466
- /* @__PURE__ */ jsx9(
1467
- Button2,
1468
- {
1469
- variant: "outline",
1470
- size: "xs",
1471
- fullWidth: true,
1472
- onClick: () => form.insertListItem("points", { value: 0, key: randomId2() }),
1473
- children: "Add control point"
1474
- }
1475
- )
1476
- ] }),
1477
- /* @__PURE__ */ jsx9(NodeTrackConnections9, { handles: data.handles, nodeId: id, type: "target" })
1478
- ] });
1479
- }
1480
- var noise_terrace_node_default = NoiseTerraceNode;
2
+ noise_abs_node_default,
3
+ noise_clamp_node_default,
4
+ noise_combine_node_default,
5
+ noise_curve_node_default,
6
+ noise_exponent_node_default,
7
+ noise_invert_node_default,
8
+ noise_normalize_node_default,
9
+ noise_scale_bias_node_default,
10
+ noise_terrace_node_default
11
+ } from "../../chunk-RDQ4BOOV.js";
12
+ import "../../chunk-SGHEOOLW.js";
1481
13
  export {
1482
14
  noise_abs_node_default as NoiseAbsNode,
1483
15
  noise_clamp_node_default as NoiseClampNode,