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