@awesome-flow/noise 0.1.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 (109) hide show
  1. package/dist/abstract/index.cjs +4234 -0
  2. package/dist/abstract/index.cjs.map +1 -0
  3. package/dist/abstract/index.d.cts +137 -0
  4. package/dist/abstract/index.d.ts +137 -0
  5. package/dist/abstract/index.js +4271 -0
  6. package/dist/abstract/index.js.map +1 -0
  7. package/dist/handle-types-D-v5S53h.d.cts +22 -0
  8. package/dist/handle-types-D-v5S53h.d.ts +22 -0
  9. package/dist/layout/index.cjs +164 -0
  10. package/dist/layout/index.cjs.map +1 -0
  11. package/dist/layout/index.d.cts +26 -0
  12. package/dist/layout/index.d.ts +26 -0
  13. package/dist/layout/index.js +136 -0
  14. package/dist/layout/index.js.map +1 -0
  15. package/dist/modules/index.cjs +71 -0
  16. package/dist/modules/index.cjs.map +1 -0
  17. package/dist/modules/index.d.cts +18 -0
  18. package/dist/modules/index.d.ts +18 -0
  19. package/dist/modules/index.js +34 -0
  20. package/dist/modules/index.js.map +1 -0
  21. package/dist/node-props-CeZ8Oshz.d.ts +161 -0
  22. package/dist/node-props-hKW-_KOU.d.cts +161 -0
  23. package/dist/nodes/generators/index.cjs +640 -0
  24. package/dist/nodes/generators/index.cjs.map +1 -0
  25. package/dist/nodes/generators/index.d.cts +38 -0
  26. package/dist/nodes/generators/index.d.ts +38 -0
  27. package/dist/nodes/generators/index.js +592 -0
  28. package/dist/nodes/generators/index.js.map +1 -0
  29. package/dist/nodes/groups/index.cjs +104 -0
  30. package/dist/nodes/groups/index.cjs.map +1 -0
  31. package/dist/nodes/groups/index.d.cts +7 -0
  32. package/dist/nodes/groups/index.d.ts +7 -0
  33. package/dist/nodes/groups/index.js +78 -0
  34. package/dist/nodes/groups/index.js.map +1 -0
  35. package/dist/nodes/index.cjs +2830 -0
  36. package/dist/nodes/index.cjs.map +1 -0
  37. package/dist/nodes/index.d.cts +16 -0
  38. package/dist/nodes/index.d.ts +16 -0
  39. package/dist/nodes/index.js +2840 -0
  40. package/dist/nodes/index.js.map +1 -0
  41. package/dist/nodes/modifiers/index.cjs +1593 -0
  42. package/dist/nodes/modifiers/index.cjs.map +1 -0
  43. package/dist/nodes/modifiers/index.d.cts +32 -0
  44. package/dist/nodes/modifiers/index.d.ts +32 -0
  45. package/dist/nodes/modifiers/index.js +1612 -0
  46. package/dist/nodes/modifiers/index.js.map +1 -0
  47. package/dist/nodes/output/index.cjs +210 -0
  48. package/dist/nodes/output/index.cjs.map +1 -0
  49. package/dist/nodes/output/index.d.cts +13 -0
  50. package/dist/nodes/output/index.d.ts +13 -0
  51. package/dist/nodes/output/index.js +181 -0
  52. package/dist/nodes/output/index.js.map +1 -0
  53. package/dist/nodes/selectors/index.cjs +136 -0
  54. package/dist/nodes/selectors/index.cjs.map +1 -0
  55. package/dist/nodes/selectors/index.d.cts +16 -0
  56. package/dist/nodes/selectors/index.d.ts +16 -0
  57. package/dist/nodes/selectors/index.js +113 -0
  58. package/dist/nodes/selectors/index.js.map +1 -0
  59. package/dist/nodes/transformers/index.cjs +477 -0
  60. package/dist/nodes/transformers/index.cjs.map +1 -0
  61. package/dist/nodes/transformers/index.d.cts +22 -0
  62. package/dist/nodes/transformers/index.d.ts +22 -0
  63. package/dist/nodes/transformers/index.js +459 -0
  64. package/dist/nodes/transformers/index.js.map +1 -0
  65. package/dist/properties-BxwtU6i9.d.cts +9 -0
  66. package/dist/properties-BxwtU6i9.d.ts +9 -0
  67. package/dist/templates/generators/index.cjs +1714 -0
  68. package/dist/templates/generators/index.cjs.map +1 -0
  69. package/dist/templates/generators/index.d.cts +89 -0
  70. package/dist/templates/generators/index.d.ts +89 -0
  71. package/dist/templates/generators/index.js +1723 -0
  72. package/dist/templates/generators/index.js.map +1 -0
  73. package/dist/templates/groups/index.cjs +1690 -0
  74. package/dist/templates/groups/index.cjs.map +1 -0
  75. package/dist/templates/groups/index.d.cts +11 -0
  76. package/dist/templates/groups/index.d.ts +11 -0
  77. package/dist/templates/groups/index.js +1711 -0
  78. package/dist/templates/groups/index.js.map +1 -0
  79. package/dist/templates/index.cjs +1758 -0
  80. package/dist/templates/index.cjs.map +1 -0
  81. package/dist/templates/index.d.cts +15 -0
  82. package/dist/templates/index.d.ts +15 -0
  83. package/dist/templates/index.js +1745 -0
  84. package/dist/templates/index.js.map +1 -0
  85. package/dist/templates/modifiers/index.cjs +1708 -0
  86. package/dist/templates/modifiers/index.cjs.map +1 -0
  87. package/dist/templates/modifiers/index.d.cts +71 -0
  88. package/dist/templates/modifiers/index.d.ts +71 -0
  89. package/dist/templates/modifiers/index.js +1720 -0
  90. package/dist/templates/modifiers/index.js.map +1 -0
  91. package/dist/templates/output/index.cjs +1696 -0
  92. package/dist/templates/output/index.cjs.map +1 -0
  93. package/dist/templates/output/index.d.cts +29 -0
  94. package/dist/templates/output/index.d.ts +29 -0
  95. package/dist/templates/output/index.js +1714 -0
  96. package/dist/templates/output/index.js.map +1 -0
  97. package/dist/templates/selectors/index.cjs +1692 -0
  98. package/dist/templates/selectors/index.cjs.map +1 -0
  99. package/dist/templates/selectors/index.d.cts +22 -0
  100. package/dist/templates/selectors/index.d.ts +22 -0
  101. package/dist/templates/selectors/index.js +1712 -0
  102. package/dist/templates/selectors/index.js.map +1 -0
  103. package/dist/templates/transformers/index.cjs +1698 -0
  104. package/dist/templates/transformers/index.cjs.map +1 -0
  105. package/dist/templates/transformers/index.d.cts +40 -0
  106. package/dist/templates/transformers/index.d.ts +40 -0
  107. package/dist/templates/transformers/index.js +1715 -0
  108. package/dist/templates/transformers/index.js.map +1 -0
  109. package/package.json +111 -0
@@ -0,0 +1,1593 @@
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 __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // ../../node_modules/fast-deep-equal/index.js
33
+ var require_fast_deep_equal = __commonJS({
34
+ "../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
35
+ "use strict";
36
+ module2.exports = function equal(a, b) {
37
+ if (a === b)
38
+ return true;
39
+ if (a && b && typeof a == "object" && typeof b == "object") {
40
+ if (a.constructor !== b.constructor)
41
+ return false;
42
+ var length, i, keys;
43
+ if (Array.isArray(a)) {
44
+ length = a.length;
45
+ if (length != b.length)
46
+ return false;
47
+ for (i = length; i-- !== 0; )
48
+ if (!equal(a[i], b[i]))
49
+ return false;
50
+ return true;
51
+ }
52
+ if (a.constructor === RegExp)
53
+ return a.source === b.source && a.flags === b.flags;
54
+ if (a.valueOf !== Object.prototype.valueOf)
55
+ return a.valueOf() === b.valueOf();
56
+ if (a.toString !== Object.prototype.toString)
57
+ return a.toString() === b.toString();
58
+ keys = Object.keys(a);
59
+ length = keys.length;
60
+ if (length !== Object.keys(b).length)
61
+ return false;
62
+ for (i = length; i-- !== 0; )
63
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
64
+ return false;
65
+ for (i = length; i-- !== 0; ) {
66
+ var key = keys[i];
67
+ if (!equal(a[key], b[key]))
68
+ return false;
69
+ }
70
+ return true;
71
+ }
72
+ return a !== a && b !== b;
73
+ };
74
+ }
75
+ });
76
+
77
+ // src/nodes/modifiers/index.ts
78
+ var modifiers_exports = {};
79
+ __export(modifiers_exports, {
80
+ NoiseAbsNode: () => noise_abs_node_default,
81
+ NoiseClampNode: () => noise_clamp_node_default,
82
+ NoiseCombineNode: () => noise_combine_node_default,
83
+ NoiseCurveNode: () => noise_curve_node_default,
84
+ NoiseExponentNode: () => noise_exponent_node_default,
85
+ NoiseInvertNode: () => noise_invert_node_default,
86
+ NoiseNormalizeNode: () => noise_normalize_node_default,
87
+ NoiseScaleBiasNode: () => noise_scale_bias_node_default,
88
+ NoiseTerraceNode: () => noise_terrace_node_default,
89
+ VariableCombineNode: () => variable_combine_node_default
90
+ });
91
+ module.exports = __toCommonJS(modifiers_exports);
92
+
93
+ // src/nodes/modifiers/noise-abs-node.tsx
94
+ var import_layout = require("@awesome-flow/core/layout");
95
+ var import_react = require("react");
96
+ var import_hooks = require("@awesome-flow/core/hooks");
97
+ var import_modifier = require("libnoise-ts/module/modifier");
98
+ var import_jsx_runtime = require("react/jsx-runtime");
99
+ function NoiseAbsNode({ id, selected, data, type }) {
100
+ const incoming = (0, import_hooks.useIncomingComputedData)(id);
101
+ const updateComputedData = (0, import_hooks.useUpdateNodeComputedData)();
102
+ (0, import_react.useEffect)(() => {
103
+ if (incoming?.length > 0) {
104
+ const module2 = new import_modifier.Abs(incoming[0].module);
105
+ updateComputedData(id, { module: module2 });
106
+ }
107
+ }, [incoming]);
108
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layout.NodeContainer, { id, selected, data, type, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" }) });
109
+ }
110
+ var noise_abs_node_default = NoiseAbsNode;
111
+
112
+ // src/nodes/modifiers/noise-clamp-node.tsx
113
+ var import_layout2 = require("@awesome-flow/core/layout");
114
+ var import_react2 = require("react");
115
+ var import_core = require("@mantine/core");
116
+ var import_hooks2 = require("@awesome-flow/core/hooks");
117
+ var import_modifier2 = require("libnoise-ts/module/modifier");
118
+ var import_jsx_runtime2 = require("react/jsx-runtime");
119
+ function NoiseClampNode({ id, selected, data, type }) {
120
+ const [lowerBound, setLowerBound] = (0, import_react2.useState)(data.lowerBound);
121
+ const [upperBound, setUpperBound] = (0, import_react2.useState)(data.upperBound);
122
+ const incoming = (0, import_hooks2.useIncomingComputedData)(id);
123
+ const updateNodeData = (0, import_hooks2.useUpdateNodeData)();
124
+ const updateComputedData = (0, import_hooks2.useUpdateNodeComputedData)();
125
+ (0, import_react2.useEffect)(() => {
126
+ if (incoming?.length) {
127
+ const module2 = new import_modifier2.Clamp(incoming[0].module, lowerBound, upperBound);
128
+ updateComputedData(id, { module: module2 });
129
+ }
130
+ updateNodeData(id, { lowerBound, upperBound });
131
+ }, [incoming, lowerBound, upperBound]);
132
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_layout2.NodeContainer, { id, selected, data, type, children: [
133
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core.Group, { children: [
134
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
135
+ import_core.NumberInput,
136
+ {
137
+ size: "xs",
138
+ w: 100,
139
+ value: lowerBound,
140
+ onChange: (e) => setLowerBound(Number(e)),
141
+ step: 0.1
142
+ }
143
+ ),
144
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
145
+ import_core.NumberInput,
146
+ {
147
+ size: "xs",
148
+ w: 100,
149
+ value: upperBound,
150
+ onChange: (e) => setUpperBound(Number(e)),
151
+ step: 0.1
152
+ }
153
+ )
154
+ ] }) }),
155
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_layout2.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
156
+ ] });
157
+ }
158
+ var noise_clamp_node_default = NoiseClampNode;
159
+
160
+ // src/nodes/modifiers/noise-combine-node.tsx
161
+ var import_layout3 = require("@awesome-flow/core/layout");
162
+ var import_react3 = require("react");
163
+ var import_hooks3 = require("@awesome-flow/core/hooks");
164
+ var import_icons_react = require("@tabler/icons-react");
165
+
166
+ // src/abstract/operations.ts
167
+ var import_combiner = require("libnoise-ts/module/combiner");
168
+ var noiseCombineModuleMap = {
169
+ ["add" /* add */]: import_combiner.Add,
170
+ ["max" /* max */]: import_combiner.Max,
171
+ ["min" /* min */]: import_combiner.Min,
172
+ ["multiply" /* multiply */]: import_combiner.Multiply,
173
+ ["power" /* power */]: import_combiner.Power
174
+ };
175
+
176
+ // src/nodes/modifiers/noise-combine-node.tsx
177
+ var import_jsx_runtime3 = require("react/jsx-runtime");
178
+ var options = {
179
+ add: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconPlus, {}),
180
+ min: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronLeft, {}),
181
+ max: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronRight, {}),
182
+ multiply: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconAsterisk, {}),
183
+ power: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronUp, {})
184
+ };
185
+ function NoiseCombineNode({ id, selected, data, type }) {
186
+ const updateNodeData = (0, import_hooks3.useUpdateNodeData)();
187
+ const updateComputedData = (0, import_hooks3.useUpdateNodeComputedData)();
188
+ const incoming = (0, import_hooks3.useIncomingComputedData)(id);
189
+ (0, import_react3.useEffect)(() => {
190
+ const ModuleFactory = noiseCombineModuleMap[data.operation];
191
+ if (incoming?.length > 1) {
192
+ const module2 = new ModuleFactory(incoming[0].module, incoming[1].module);
193
+ updateComputedData(id, { module: module2 });
194
+ }
195
+ }, [data.operation, incoming]);
196
+ const onChange = (0, import_react3.useCallback)((operation) => {
197
+ updateNodeData(id, { operation });
198
+ }, []);
199
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_layout3.NodeContainer, { id, selected, data, type, children: [
200
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_layout3.NodeCombobox, { options, selected: data.operation, onChange }),
201
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_layout3.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
202
+ ] });
203
+ }
204
+ var noise_combine_node_default = NoiseCombineNode;
205
+
206
+ // src/nodes/modifiers/noise-curve-node.tsx
207
+ var import_layout4 = require("@awesome-flow/core/layout");
208
+ var import_core2 = require("@mantine/core");
209
+ var import_hooks4 = require("@awesome-flow/core/hooks");
210
+
211
+ // ../../node_modules/@mantine/form/esm/use-form.mjs
212
+ var import_react10 = require("react");
213
+
214
+ // ../../node_modules/@mantine/form/esm/actions/actions.mjs
215
+ var import_react4 = require("react");
216
+ function validateFormName(name) {
217
+ if (!/^[0-9a-zA-Z-]+$/.test(name)) {
218
+ throw new Error(
219
+ `[@mantine/use-form] Form name "${name}" is invalid, it should contain only letters, numbers and dashes`
220
+ );
221
+ }
222
+ }
223
+ var useIsomorphicEffect = typeof window !== "undefined" ? import_react4.useLayoutEffect : import_react4.useEffect;
224
+ function useFormEvent(eventKey, handler) {
225
+ useIsomorphicEffect(() => {
226
+ if (eventKey) {
227
+ window.addEventListener(eventKey, handler);
228
+ return () => window.removeEventListener(eventKey, handler);
229
+ }
230
+ return void 0;
231
+ }, [eventKey]);
232
+ }
233
+ function useFormActions(name, form) {
234
+ if (name) {
235
+ validateFormName(name);
236
+ }
237
+ useFormEvent(
238
+ `mantine-form:${name}:set-field-value`,
239
+ (event) => form.setFieldValue(event.detail.path, event.detail.value)
240
+ );
241
+ useFormEvent(
242
+ `mantine-form:${name}:set-values`,
243
+ (event) => form.setValues(event.detail)
244
+ );
245
+ useFormEvent(
246
+ `mantine-form:${name}:set-initial-values`,
247
+ (event) => form.setInitialValues(event.detail)
248
+ );
249
+ useFormEvent(
250
+ `mantine-form:${name}:set-errors`,
251
+ (event) => form.setErrors(event.detail)
252
+ );
253
+ useFormEvent(
254
+ `mantine-form:${name}:set-field-error`,
255
+ (event) => form.setFieldError(event.detail.path, event.detail.error)
256
+ );
257
+ useFormEvent(
258
+ `mantine-form:${name}:clear-field-error`,
259
+ (event) => form.clearFieldError(event.detail)
260
+ );
261
+ useFormEvent(`mantine-form:${name}:clear-errors`, form.clearErrors);
262
+ useFormEvent(`mantine-form:${name}:reset`, form.reset);
263
+ useFormEvent(`mantine-form:${name}:validate`, form.validate);
264
+ useFormEvent(
265
+ `mantine-form:${name}:validate-field`,
266
+ (event) => form.validateField(event.detail)
267
+ );
268
+ useFormEvent(
269
+ `mantine-form:${name}:reorder-list-item`,
270
+ (event) => form.reorderListItem(event.detail.path, event.detail.payload)
271
+ );
272
+ useFormEvent(
273
+ `mantine-form:${name}:remove-list-item`,
274
+ (event) => form.removeListItem(event.detail.path, event.detail.index)
275
+ );
276
+ useFormEvent(
277
+ `mantine-form:${name}:insert-list-item`,
278
+ (event) => form.insertListItem(event.detail.path, event.detail.item, event.detail.index)
279
+ );
280
+ useFormEvent(
281
+ `mantine-form:${name}:set-dirty`,
282
+ (event) => form.setDirty(event.detail)
283
+ );
284
+ useFormEvent(
285
+ `mantine-form:${name}:set-touched`,
286
+ (event) => form.setTouched(event.detail)
287
+ );
288
+ useFormEvent(
289
+ `mantine-form:${name}:reset-dirty`,
290
+ (event) => form.resetDirty(event.detail)
291
+ );
292
+ useFormEvent(`mantine-form:${name}:reset-touched`, form.resetTouched);
293
+ }
294
+
295
+ // ../../node_modules/@mantine/form/esm/get-input-on-change/get-input-on-change.mjs
296
+ function getInputOnChange(setValue) {
297
+ return (val) => {
298
+ if (!val) {
299
+ setValue(val);
300
+ } else if (typeof val === "function") {
301
+ setValue(val);
302
+ } else if (typeof val === "object" && "nativeEvent" in val) {
303
+ const { currentTarget } = val;
304
+ if (currentTarget instanceof HTMLInputElement) {
305
+ if (currentTarget.type === "checkbox") {
306
+ setValue(currentTarget.checked);
307
+ } else {
308
+ setValue(currentTarget.value);
309
+ }
310
+ } else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
311
+ setValue(currentTarget.value);
312
+ }
313
+ } else {
314
+ setValue(val);
315
+ }
316
+ };
317
+ }
318
+
319
+ // ../../node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
320
+ var import_react5 = require("react");
321
+
322
+ // ../../node_modules/@mantine/form/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs
323
+ function filterErrors(errors) {
324
+ if (errors === null || typeof errors !== "object") {
325
+ return {};
326
+ }
327
+ return Object.keys(errors).reduce((acc, key) => {
328
+ const errorValue = errors[key];
329
+ if (errorValue !== void 0 && errorValue !== null && errorValue !== false) {
330
+ acc[key] = errorValue;
331
+ }
332
+ return acc;
333
+ }, {});
334
+ }
335
+
336
+ // ../../node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
337
+ function useFormErrors(initialErrors) {
338
+ const [errorsState, setErrorsState] = (0, import_react5.useState)(filterErrors(initialErrors));
339
+ const setErrors = (0, import_react5.useCallback)((errors) => {
340
+ setErrorsState(
341
+ (current) => filterErrors(typeof errors === "function" ? errors(current) : errors)
342
+ );
343
+ }, []);
344
+ const clearErrors = (0, import_react5.useCallback)(() => setErrorsState({}), []);
345
+ const clearFieldError = (0, import_react5.useCallback)(
346
+ (path) => {
347
+ if (errorsState[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 = (0, import_react5.useCallback)(
359
+ (path, error) => {
360
+ if (error == null || error === false) {
361
+ clearFieldError(path);
362
+ } else if (errorsState[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/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
378
+ var import_react6 = require("react");
379
+
380
+ // ../../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/@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/@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/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/@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/@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/@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/@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/@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/@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/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
597
+ function useFormList({
598
+ $values,
599
+ $errors,
600
+ $status
601
+ }) {
602
+ const reorderListItem = (0, import_react6.useCallback)((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 = (0, import_react6.useCallback)((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 = (0, import_react6.useCallback)((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/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
630
+ var import_react7 = require("react");
631
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
632
+
633
+ // ../../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/@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] = (0, import_react7.useState)(initialTouched);
651
+ const [dirtyState, setDirtyState] = (0, import_react7.useState)(initialDirty);
652
+ const touchedRef = (0, import_react7.useRef)(initialTouched);
653
+ const dirtyRef = (0, import_react7.useRef)(initialDirty);
654
+ const setTouched = (0, import_react7.useCallback)((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 = (0, import_react7.useCallback)((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 = (0, import_react7.useCallback)(() => 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 = (0, import_react7.useCallback)((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 = (0, import_react7.useCallback)((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 = (0, import_react7.useCallback)(
691
+ (path) => getStatus(touchedRef.current, path),
692
+ []
693
+ );
694
+ const clearFieldDirty = (0, import_react7.useCallback)(
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 = (0, import_react7.useCallback)((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 = (0, import_react7.useCallback)(() => dirtyRef.current, []);
725
+ const getTouched = (0, import_react7.useCallback)(() => 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/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
748
+ var import_react8 = require("react");
749
+ function useFormValues({
750
+ initialValues,
751
+ onValuesChange,
752
+ mode
753
+ }) {
754
+ const initialized = (0, import_react8.useRef)(false);
755
+ const [stateValues, setStateValues] = (0, import_react8.useState)(initialValues || {});
756
+ const refValues = (0, import_react8.useRef)(stateValues);
757
+ const valuesSnapshot = (0, import_react8.useRef)(stateValues);
758
+ const setValues = (0, import_react8.useCallback)(
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 = (0, import_react8.useCallback)((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 = (0, import_react8.useCallback)((payload) => {
788
+ valuesSnapshot.current = payload;
789
+ }, []);
790
+ const initialize = (0, import_react8.useCallback)((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 = (0, import_react8.useCallback)(() => {
799
+ setValues({
800
+ values: valuesSnapshot.current,
801
+ updateState: true,
802
+ mergeWithPreviousValues: false
803
+ });
804
+ }, []);
805
+ const getValues = (0, import_react8.useCallback)(() => 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/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
821
+ var import_react9 = require("react");
822
+ function useFormWatch({
823
+ $status
824
+ }) {
825
+ const subscribers = (0, import_react9.useRef)(
826
+ {}
827
+ );
828
+ const watch = (0, import_react9.useCallback)((path, callback) => {
829
+ (0, import_react9.useEffect)(() => {
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 = (0, import_react9.useCallback)((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/@mantine/form/esm/validate/validate-values.mjs
858
+ function getValidationResults(errors) {
859
+ const filteredErrors = filterErrors(errors);
860
+ return { hasErrors: Object.keys(filteredErrors).length > 0, errors: filteredErrors };
861
+ }
862
+ function validateRulesRecord(rules, values, path = "", errors = {}) {
863
+ if (typeof rules !== "object" || rules === null) {
864
+ return errors;
865
+ }
866
+ return Object.keys(rules).reduce((acc, ruleKey) => {
867
+ const rule = rules[ruleKey];
868
+ const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
869
+ const value = getPath(rulePath, values);
870
+ let arrayValidation = false;
871
+ if (typeof rule === "function") {
872
+ acc[rulePath] = rule(value, values, rulePath);
873
+ }
874
+ if (typeof rule === "object" && Array.isArray(value)) {
875
+ arrayValidation = true;
876
+ value.forEach(
877
+ (_item, index) => validateRulesRecord(rule, values, `${rulePath}.${index}`, acc)
878
+ );
879
+ }
880
+ if (typeof rule === "object" && typeof value === "object" && value !== null) {
881
+ if (!arrayValidation) {
882
+ validateRulesRecord(rule, values, rulePath, acc);
883
+ }
884
+ }
885
+ return acc;
886
+ }, errors);
887
+ }
888
+ function validateValues(validate, values) {
889
+ if (typeof validate === "function") {
890
+ return getValidationResults(validate(values));
891
+ }
892
+ return getValidationResults(validateRulesRecord(validate, values));
893
+ }
894
+
895
+ // ../../node_modules/@mantine/form/esm/validate/validate-field-value.mjs
896
+ function validateFieldValue(path, rules, values) {
897
+ if (typeof path !== "string") {
898
+ return { hasError: false, error: null };
899
+ }
900
+ const results = validateValues(rules, values);
901
+ const pathInError = Object.keys(results.errors).find(
902
+ (errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i])
903
+ );
904
+ return { hasError: !!pathInError, error: pathInError ? results.errors[pathInError] : null };
905
+ }
906
+
907
+ // ../../node_modules/@mantine/form/esm/form-index.mjs
908
+ var FORM_INDEX = "__MANTINE_FORM_INDEX__";
909
+
910
+ // ../../node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
911
+ function shouldValidateOnChange(path, validateInputOnChange) {
912
+ if (!validateInputOnChange) {
913
+ return false;
914
+ }
915
+ if (typeof validateInputOnChange === "boolean") {
916
+ return validateInputOnChange;
917
+ }
918
+ if (Array.isArray(validateInputOnChange)) {
919
+ return validateInputOnChange.includes(path.replace(/[.][0-9]/g, `.${FORM_INDEX}`));
920
+ }
921
+ return false;
922
+ }
923
+
924
+ // ../../node_modules/@mantine/form/esm/use-form.mjs
925
+ function useForm({
926
+ name,
927
+ mode = "controlled",
928
+ initialValues,
929
+ initialErrors = {},
930
+ initialDirty = {},
931
+ initialTouched = {},
932
+ clearInputErrorOnChange = true,
933
+ validateInputOnChange = false,
934
+ validateInputOnBlur = false,
935
+ onValuesChange,
936
+ transformValues = (values) => values,
937
+ enhanceGetInputProps,
938
+ validate: rules
939
+ } = {}) {
940
+ const $errors = useFormErrors(initialErrors);
941
+ const $values = useFormValues({ initialValues, onValuesChange, mode });
942
+ const $status = useFormStatus({ initialDirty, initialTouched, $values, mode });
943
+ const $list = useFormList({ $values, $errors, $status });
944
+ const $watch = useFormWatch({ $status });
945
+ const [formKey, setFormKey] = (0, import_react10.useState)(0);
946
+ const [fieldKeys, setFieldKeys] = (0, import_react10.useState)({});
947
+ const reset = (0, import_react10.useCallback)(() => {
948
+ $values.resetValues();
949
+ $errors.clearErrors();
950
+ $status.resetDirty();
951
+ $status.resetTouched();
952
+ mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
953
+ }, []);
954
+ const initialize = (0, import_react10.useCallback)((values) => {
955
+ $values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
956
+ }, []);
957
+ const setFieldValue = (0, import_react10.useCallback)(
958
+ (path, value, options3) => {
959
+ const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
960
+ $status.clearFieldDirty(path);
961
+ $status.setFieldTouched(path, true);
962
+ !shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
963
+ $values.setFieldValue({
964
+ path,
965
+ value,
966
+ updateState: mode === "controlled",
967
+ subscribers: [
968
+ ...$watch.getFieldSubscribers(path),
969
+ shouldValidate ? (payload) => {
970
+ const validationResults = validateFieldValue(path, rules, payload.updatedValues);
971
+ validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
972
+ } : null,
973
+ options3?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
974
+ ...keys,
975
+ [path]: (keys[path] || 0) + 1
976
+ })) : null
977
+ ]
978
+ });
979
+ },
980
+ [onValuesChange, rules]
981
+ );
982
+ const setValues = (0, import_react10.useCallback)(
983
+ (values) => {
984
+ const previousValues = $values.refValues.current;
985
+ $values.setValues({ values, updateState: mode === "controlled" });
986
+ clearInputErrorOnChange && $errors.clearErrors();
987
+ mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
988
+ Object.keys($watch.subscribers.current).forEach((path) => {
989
+ const value = getPath(path, $values.refValues.current);
990
+ const previousValue = getPath(path, previousValues);
991
+ if (value !== previousValue) {
992
+ $watch.getFieldSubscribers(path).forEach((cb) => cb({ previousValues, updatedValues: $values.refValues.current }));
993
+ }
994
+ });
995
+ },
996
+ [onValuesChange, clearInputErrorOnChange]
997
+ );
998
+ const validate = (0, import_react10.useCallback)(() => {
999
+ const results = validateValues(rules, $values.refValues.current);
1000
+ $errors.setErrors(results.errors);
1001
+ return results;
1002
+ }, [rules]);
1003
+ const validateField = (0, import_react10.useCallback)(
1004
+ (path) => {
1005
+ const results = validateFieldValue(path, rules, $values.refValues.current);
1006
+ results.hasError ? $errors.setFieldError(path, results.error) : $errors.clearFieldError(path);
1007
+ return results;
1008
+ },
1009
+ [rules]
1010
+ );
1011
+ const getInputProps = (path, { type = "input", withError = true, withFocus = true, ...otherOptions } = {}) => {
1012
+ const onChange = getInputOnChange(
1013
+ (value) => setFieldValue(path, value, { forceUpdate: false })
1014
+ );
1015
+ const payload = { onChange };
1016
+ if (withError) {
1017
+ payload.error = $errors.errorsState[path];
1018
+ }
1019
+ if (type === "checkbox") {
1020
+ payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(
1021
+ path,
1022
+ $values.refValues.current
1023
+ );
1024
+ } else {
1025
+ payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(
1026
+ path,
1027
+ $values.refValues.current
1028
+ );
1029
+ }
1030
+ if (withFocus) {
1031
+ payload.onFocus = () => $status.setFieldTouched(path, true);
1032
+ payload.onBlur = () => {
1033
+ if (shouldValidateOnChange(path, validateInputOnBlur)) {
1034
+ const validationResults = validateFieldValue(path, rules, $values.refValues.current);
1035
+ validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
1036
+ }
1037
+ };
1038
+ }
1039
+ return Object.assign(
1040
+ payload,
1041
+ enhanceGetInputProps?.({
1042
+ inputProps: payload,
1043
+ field: path,
1044
+ options: { type, withError, withFocus, ...otherOptions },
1045
+ form
1046
+ })
1047
+ );
1048
+ };
1049
+ const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
1050
+ event?.preventDefault();
1051
+ const results = validate();
1052
+ if (results.hasErrors) {
1053
+ handleValidationFailure?.(results.errors, $values.refValues.current, event);
1054
+ } else {
1055
+ handleSubmit?.(transformValues($values.refValues.current), event);
1056
+ }
1057
+ };
1058
+ const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
1059
+ const onReset = (0, import_react10.useCallback)((event) => {
1060
+ event.preventDefault();
1061
+ reset();
1062
+ }, []);
1063
+ const isValid = (0, import_react10.useCallback)(
1064
+ (path) => path ? !validateFieldValue(path, rules, $values.refValues.current).hasError : !validateValues(rules, $values.refValues.current).hasErrors,
1065
+ [rules]
1066
+ );
1067
+ const key = (path) => `${formKey}-${path}-${fieldKeys[path] || 0}`;
1068
+ const form = {
1069
+ watch: $watch.watch,
1070
+ initialized: $values.initialized.current,
1071
+ values: $values.stateValues,
1072
+ getValues: $values.getValues,
1073
+ setInitialValues: $values.setValuesSnapshot,
1074
+ initialize,
1075
+ setValues,
1076
+ setFieldValue,
1077
+ errors: $errors.errorsState,
1078
+ setErrors: $errors.setErrors,
1079
+ setFieldError: $errors.setFieldError,
1080
+ clearFieldError: $errors.clearFieldError,
1081
+ clearErrors: $errors.clearErrors,
1082
+ resetDirty: $status.resetDirty,
1083
+ setTouched: $status.setTouched,
1084
+ setDirty: $status.setDirty,
1085
+ isTouched: $status.isTouched,
1086
+ resetTouched: $status.resetTouched,
1087
+ isDirty: $status.isDirty,
1088
+ getTouched: $status.getTouched,
1089
+ getDirty: $status.getDirty,
1090
+ reorderListItem: $list.reorderListItem,
1091
+ insertListItem: $list.insertListItem,
1092
+ removeListItem: $list.removeListItem,
1093
+ reset,
1094
+ validate,
1095
+ validateField,
1096
+ getInputProps,
1097
+ onSubmit,
1098
+ onReset,
1099
+ isValid,
1100
+ getTransformedValues,
1101
+ key
1102
+ };
1103
+ useFormActions(name, form);
1104
+ return form;
1105
+ }
1106
+
1107
+ // src/nodes/modifiers/noise-curve-node.tsx
1108
+ var import_react11 = require("react");
1109
+ var import_modifier3 = require("libnoise-ts/module/modifier");
1110
+ var import_util = require("libnoise-ts/util");
1111
+ var import_icons_react2 = require("@tabler/icons-react");
1112
+ var import_hooks5 = require("@mantine/hooks");
1113
+ var import_abstract = require("@awesome-flow/core/abstract");
1114
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1115
+ function NoiseCurveNode({ id, selected, data, type }) {
1116
+ const incoming = (0, import_hooks4.useIncomingComputedData)(id);
1117
+ const updateNodeData = (0, import_hooks4.useUpdateNodeData)();
1118
+ const updateComputedData = (0, import_hooks4.useUpdateNodeComputedData)();
1119
+ const [values, setValues] = (0, import_react11.useState)([]);
1120
+ const form = useForm({
1121
+ mode: "uncontrolled",
1122
+ initialValues: {
1123
+ points: []
1124
+ },
1125
+ validateInputOnChange: [`points.${FORM_INDEX}.input`],
1126
+ clearInputErrorOnChange: true,
1127
+ validate: {
1128
+ points: {
1129
+ input: (value, values2) => {
1130
+ const counts = {};
1131
+ values2.points.forEach((x) => {
1132
+ counts[x.input] = (counts[x.input] || 0) + 1;
1133
+ });
1134
+ return counts[value] > 1;
1135
+ }
1136
+ }
1137
+ },
1138
+ onValuesChange: (0, import_react11.useCallback)((values2) => {
1139
+ if (form.isValid()) {
1140
+ const points = values2.points.map((v) => ({ input: v.input, output: v.output }));
1141
+ setValues(points);
1142
+ updateNodeData(id, { points });
1143
+ }
1144
+ form.validate();
1145
+ }, [])
1146
+ });
1147
+ (0, import_react11.useEffect)(() => {
1148
+ const points = data.points?.length ? data.points.map((v) => ({ input: v.input, output: v.output, key: (0, import_hooks5.randomId)() })) : [1, 2, 3, 4].map(() => ({ input: 0, output: 0, key: (0, import_hooks5.randomId)() }));
1149
+ form.initialize({ points });
1150
+ }, []);
1151
+ (0, import_react11.useEffect)(() => {
1152
+ if (incoming?.length && values?.length >= 4) {
1153
+ const module2 = new import_modifier3.Curve(
1154
+ incoming[0].module,
1155
+ values.map((p) => new import_util.Tuple(p.input, p.output))
1156
+ );
1157
+ updateComputedData(id, { module: module2 });
1158
+ }
1159
+ }, [values, incoming]);
1160
+ const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_core2.Group, { mt: "xs", children: [
1161
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1162
+ import_core2.NumberInput,
1163
+ {
1164
+ size: "xs",
1165
+ w: 100,
1166
+ placeholder: "Input Value",
1167
+ ...form.getInputProps(`points.${index}.input`),
1168
+ step: 0.1
1169
+ },
1170
+ form.key(`points.${index}.input`)
1171
+ ),
1172
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1173
+ import_core2.NumberInput,
1174
+ {
1175
+ size: "xs",
1176
+ w: 100,
1177
+ placeholder: "Output Value",
1178
+ ...form.getInputProps(`points.${index}.output`),
1179
+ step: 0.1
1180
+ },
1181
+ form.key(`points.${index}.output`)
1182
+ ),
1183
+ data.state === import_abstract.NodeState.edit && values.length > 4 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1184
+ import_core2.ActionIcon,
1185
+ {
1186
+ color: "red",
1187
+ variant: "outline",
1188
+ size: "sm",
1189
+ onClick: () => form.removeListItem("points", index),
1190
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons_react2.IconX, { size: "1rem" })
1191
+ }
1192
+ )
1193
+ ] }, item.key));
1194
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_layout4.NodeContainer, { id, selected, type, data, children: [
1195
+ fields,
1196
+ data.state === import_abstract.NodeState.edit && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1197
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core2.Space, { h: 10 }),
1198
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1199
+ import_core2.Button,
1200
+ {
1201
+ variant: "outline",
1202
+ size: "xs",
1203
+ fullWidth: true,
1204
+ onClick: () => form.insertListItem("points", { input: 0, output: 0, key: (0, import_hooks5.randomId)() }),
1205
+ children: "Add control point"
1206
+ }
1207
+ )
1208
+ ] }),
1209
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_layout4.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1210
+ ] });
1211
+ }
1212
+ var noise_curve_node_default = NoiseCurveNode;
1213
+
1214
+ // src/nodes/modifiers/noise-exponent-node.tsx
1215
+ var import_layout5 = require("@awesome-flow/core/layout");
1216
+ var import_react12 = require("react");
1217
+ var import_core3 = require("@mantine/core");
1218
+ var import_hooks6 = require("@awesome-flow/core/hooks");
1219
+ var import_modifier4 = require("libnoise-ts/module/modifier");
1220
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1221
+ function NoiseExponentNode({ id, selected, data, type }) {
1222
+ const [exponent, setExponent] = (0, import_react12.useState)(data.exponent);
1223
+ const incoming = (0, import_hooks6.useIncomingComputedData)(id);
1224
+ const updateNodeData = (0, import_hooks6.useUpdateNodeData)();
1225
+ const updateComputedData = (0, import_hooks6.useUpdateNodeComputedData)();
1226
+ (0, import_react12.useEffect)(() => {
1227
+ if (incoming?.length > 0) {
1228
+ const module2 = new import_modifier4.Exponent(incoming[0].module, exponent);
1229
+ updateComputedData(id, { module: module2 });
1230
+ }
1231
+ updateNodeData(id, { exponent });
1232
+ }, [incoming, exponent]);
1233
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_layout5.NodeContainer, { id, selected, data, type, children: [
1234
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core3.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_core3.Group, { children: [
1235
+ "Exponent:",
1236
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1237
+ import_core3.NumberInput,
1238
+ {
1239
+ size: "xs",
1240
+ value: exponent,
1241
+ onChange: (e) => setExponent(Number(e)),
1242
+ step: 0.1
1243
+ }
1244
+ )
1245
+ ] }) }),
1246
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_layout5.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1247
+ ] });
1248
+ }
1249
+ var noise_exponent_node_default = NoiseExponentNode;
1250
+
1251
+ // src/nodes/modifiers/noise-invert-node.tsx
1252
+ var import_layout6 = require("@awesome-flow/core/layout");
1253
+ var import_react13 = require("react");
1254
+ var import_hooks7 = require("@awesome-flow/core/hooks");
1255
+ var import_modifier5 = require("libnoise-ts/module/modifier");
1256
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1257
+ function NoiseInvertNode({ id, selected, data, type }) {
1258
+ const incoming = (0, import_hooks7.useIncomingComputedData)(id);
1259
+ const updateComputedData = (0, import_hooks7.useUpdateNodeComputedData)();
1260
+ (0, import_react13.useEffect)(() => {
1261
+ if (incoming?.length > 0) {
1262
+ const module2 = new import_modifier5.Invert(incoming[0].module);
1263
+ updateComputedData(id, { module: module2 });
1264
+ }
1265
+ }, [incoming]);
1266
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_layout6.NodeContainer, { id, selected, data, type, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_layout6.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" }) });
1267
+ }
1268
+ var noise_invert_node_default = NoiseInvertNode;
1269
+
1270
+ // src/nodes/modifiers/noise-normalize-node.tsx
1271
+ var import_layout7 = require("@awesome-flow/core/layout");
1272
+ var import_react14 = require("react");
1273
+ var import_core4 = require("@mantine/core");
1274
+ var import_hooks8 = require("@awesome-flow/core/hooks");
1275
+
1276
+ // src/modules/normalize-noise-module.ts
1277
+ var import_modifier6 = __toESM(require("libnoise-ts/module/modifier"), 1);
1278
+ var NormalizeNoiseModule = class extends import_modifier6.default {
1279
+ constructor(source, lowerBound, upperBound) {
1280
+ super(source);
1281
+ this.lowerBound = lowerBound;
1282
+ this.upperBound = upperBound;
1283
+ }
1284
+ getValue(x, y, z) {
1285
+ return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
1286
+ }
1287
+ };
1288
+ function normalize(value, min, max) {
1289
+ return (value - min) / (max - min);
1290
+ }
1291
+
1292
+ // src/nodes/modifiers/noise-normalize-node.tsx
1293
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1294
+ function NoiseNormalizeNode({ id, selected, data, type }) {
1295
+ const [intervalStart, setIntervalStart] = (0, import_react14.useState)(data.intervalStart);
1296
+ const [intervalEnd, setIntervalEnd] = (0, import_react14.useState)(data.intervalEnd);
1297
+ const incoming = (0, import_hooks8.useIncomingComputedData)(id);
1298
+ const updateNodeData = (0, import_hooks8.useUpdateNodeData)();
1299
+ const updateComputedData = (0, import_hooks8.useUpdateNodeComputedData)();
1300
+ (0, import_react14.useEffect)(() => {
1301
+ if (incoming?.length) {
1302
+ const source = incoming[0].module;
1303
+ const module2 = new NormalizeNoiseModule(source, intervalStart, intervalEnd);
1304
+ updateComputedData(id, { module: module2 });
1305
+ }
1306
+ updateNodeData(id, { intervalStart, intervalEnd });
1307
+ }, [incoming, intervalStart, intervalEnd]);
1308
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_layout7.NodeContainer, { id, selected, data, type, children: [
1309
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core4.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core4.Group, { children: [
1310
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1311
+ import_core4.NumberInput,
1312
+ {
1313
+ size: "xs",
1314
+ w: 100,
1315
+ value: intervalStart,
1316
+ onChange: (e) => setIntervalStart(Number(e))
1317
+ }
1318
+ ),
1319
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1320
+ import_core4.NumberInput,
1321
+ {
1322
+ size: "xs",
1323
+ w: 100,
1324
+ value: intervalEnd,
1325
+ onChange: (e) => setIntervalEnd(Number(e))
1326
+ }
1327
+ )
1328
+ ] }) }),
1329
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_layout7.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1330
+ ] });
1331
+ }
1332
+ var noise_normalize_node_default = NoiseNormalizeNode;
1333
+
1334
+ // src/nodes/modifiers/noise-scale-bias-node.tsx
1335
+ var import_layout8 = require("@awesome-flow/core/layout");
1336
+ var import_react15 = require("react");
1337
+ var import_core5 = require("@mantine/core");
1338
+ var import_hooks9 = require("@awesome-flow/core/hooks");
1339
+ var import_modifier7 = require("libnoise-ts/module/modifier");
1340
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1341
+ function NoiseScaleBiasNode({ id, selected, data, type }) {
1342
+ const [scale, setScale] = (0, import_react15.useState)(data.scale);
1343
+ const [bias, setBias] = (0, import_react15.useState)(data.bias);
1344
+ const incoming = (0, import_hooks9.useIncomingComputedData)(id);
1345
+ const updateNodeData = (0, import_hooks9.useUpdateNodeData)();
1346
+ const updateComputedData = (0, import_hooks9.useUpdateNodeComputedData)();
1347
+ (0, import_react15.useEffect)(() => {
1348
+ if (incoming?.length > 0) {
1349
+ const module2 = new import_modifier7.ScaleBias(incoming[0].module, scale, bias);
1350
+ updateComputedData(id, { module: module2 });
1351
+ }
1352
+ updateNodeData(id, { scale, bias });
1353
+ }, [incoming, scale, bias]);
1354
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_layout8.NodeContainer, { id, selected, data, type, children: [
1355
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Stack, { children: [
1356
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Group, { children: [
1357
+ "Scale:",
1358
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1359
+ import_core5.NumberInput,
1360
+ {
1361
+ size: "xs",
1362
+ w: 100,
1363
+ value: scale,
1364
+ onChange: (e) => setScale(Number(e)),
1365
+ step: 0.1
1366
+ }
1367
+ )
1368
+ ] }),
1369
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Group, { children: [
1370
+ "Bias:",
1371
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1372
+ import_core5.NumberInput,
1373
+ {
1374
+ size: "xs",
1375
+ w: 100,
1376
+ value: bias,
1377
+ onChange: (e) => setBias(Number(e)),
1378
+ step: 0.1
1379
+ }
1380
+ )
1381
+ ] })
1382
+ ] }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_layout8.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1384
+ ] });
1385
+ }
1386
+ var noise_scale_bias_node_default = NoiseScaleBiasNode;
1387
+
1388
+ // src/nodes/modifiers/noise-terrace-node.tsx
1389
+ var import_layout9 = require("@awesome-flow/core/layout");
1390
+ var import_core6 = require("@mantine/core");
1391
+ var import_hooks10 = require("@awesome-flow/core/hooks");
1392
+ var import_react16 = require("react");
1393
+ var import_modifier8 = require("libnoise-ts/module/modifier");
1394
+ var import_icons_react3 = require("@tabler/icons-react");
1395
+ var import_hooks11 = require("@mantine/hooks");
1396
+ var import_abstract2 = require("@awesome-flow/core/abstract");
1397
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1398
+ function NoiseTerraceNode({ id, selected, data, type }) {
1399
+ const incoming = (0, import_hooks10.useIncomingComputedData)(id);
1400
+ const updateNodeData = (0, import_hooks10.useUpdateNodeData)();
1401
+ const updateComputedData = (0, import_hooks10.useUpdateNodeComputedData)();
1402
+ const [values, setValues] = (0, import_react16.useState)([]);
1403
+ const form = useForm({
1404
+ mode: "uncontrolled",
1405
+ initialValues: {
1406
+ points: []
1407
+ },
1408
+ validateInputOnChange: [`points.${FORM_INDEX}.input`],
1409
+ clearInputErrorOnChange: true,
1410
+ onValuesChange: (0, import_react16.useCallback)((values2) => {
1411
+ if (form.isValid()) {
1412
+ const points = values2.points.map((v) => v.value);
1413
+ setValues(points);
1414
+ updateNodeData(id, { points });
1415
+ }
1416
+ form.validate();
1417
+ }, [])
1418
+ });
1419
+ (0, import_react16.useEffect)(() => {
1420
+ const points = data.points?.length ? data.points.map((v) => ({ value: v, key: (0, import_hooks11.randomId)() })) : [1, 2].map(() => ({ value: 0, key: (0, import_hooks11.randomId)() }));
1421
+ form.initialize({ points });
1422
+ }, []);
1423
+ (0, import_react16.useEffect)(() => {
1424
+ if (incoming?.length && values?.length >= 2) {
1425
+ const module2 = new import_modifier8.Terrace(incoming[0].module, values);
1426
+ updateComputedData(id, { module: module2 });
1427
+ }
1428
+ }, [values, incoming]);
1429
+ const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core6.Group, { mt: "xs", children: [
1430
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1431
+ import_core6.NumberInput,
1432
+ {
1433
+ size: "xs",
1434
+ placeholder: "Input Value",
1435
+ ...form.getInputProps(`points.${index}.value`),
1436
+ step: 0.1
1437
+ },
1438
+ form.key(`points.${index}.value`)
1439
+ ),
1440
+ data.state === import_abstract2.NodeState.edit && values.length > 2 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1441
+ import_core6.ActionIcon,
1442
+ {
1443
+ color: "red",
1444
+ variant: "outline",
1445
+ size: "sm",
1446
+ onClick: () => form.removeListItem("points", index),
1447
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons_react3.IconX, { size: "1rem" })
1448
+ }
1449
+ )
1450
+ ] }, item.key));
1451
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_layout9.NodeContainer, { id, selected, type, data, children: [
1452
+ fields,
1453
+ data.state === import_abstract2.NodeState.edit && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1454
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core6.Space, { h: 10 }),
1455
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1456
+ import_core6.Button,
1457
+ {
1458
+ variant: "outline",
1459
+ size: "xs",
1460
+ fullWidth: true,
1461
+ onClick: () => form.insertListItem("points", { value: 0, key: (0, import_hooks11.randomId)() }),
1462
+ children: "Add control point"
1463
+ }
1464
+ )
1465
+ ] }),
1466
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_layout9.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1467
+ ] });
1468
+ }
1469
+ var noise_terrace_node_default = NoiseTerraceNode;
1470
+
1471
+ // src/nodes/modifiers/variable-combine-node.tsx
1472
+ var import_layout10 = require("@awesome-flow/core/layout");
1473
+ var import_react18 = require("react");
1474
+ var import_hooks13 = require("@awesome-flow/core/hooks");
1475
+ var import_icons_react4 = require("@tabler/icons-react");
1476
+
1477
+ // src/layout/node-value-input.tsx
1478
+ var import_core7 = require("@mantine/core");
1479
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1480
+ function NodeValueInput({ value, disabled, step, onChange }) {
1481
+ if (value === void 0 || value === null) {
1482
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {});
1483
+ }
1484
+ switch (typeof value) {
1485
+ case "boolean": {
1486
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1487
+ import_core7.Switch,
1488
+ {
1489
+ checked: value,
1490
+ disabled,
1491
+ onChange: (e) => onChange(e.currentTarget.checked)
1492
+ }
1493
+ );
1494
+ }
1495
+ case "number": {
1496
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core7.NumberInput, { value, disabled, step, onChange: (e) => onChange(e) });
1497
+ }
1498
+ case "string": {
1499
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1500
+ import_core7.Input,
1501
+ {
1502
+ value,
1503
+ disabled,
1504
+ onChange: (e) => onChange(e.currentTarget.value)
1505
+ }
1506
+ );
1507
+ }
1508
+ default:
1509
+ throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);
1510
+ }
1511
+ }
1512
+ var node_value_input_default = NodeValueInput;
1513
+
1514
+ // src/layout/node-property-input.tsx
1515
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1516
+
1517
+ // src/layout/node-property-variables.tsx
1518
+ var import_hooks12 = require("@awesome-flow/core/hooks");
1519
+ var import_react17 = require("react");
1520
+ var import_core8 = require("@mantine/core");
1521
+ var import_utils = require("@awesome-flow/core/utils");
1522
+ var import_abstract3 = require("@awesome-flow/core/abstract");
1523
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1524
+
1525
+ // src/nodes/modifiers/variable-combine-node.tsx
1526
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1527
+ var options2 = {
1528
+ add: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconPlus, {}),
1529
+ divide: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconDivide, {}),
1530
+ min: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconChevronLeft, {}),
1531
+ max: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconChevronRight, {}),
1532
+ multiply: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconAsterisk, {}),
1533
+ power: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react4.IconChevronUp, {})
1534
+ };
1535
+ function VariableCombineNode({
1536
+ id,
1537
+ selected,
1538
+ data,
1539
+ type
1540
+ }) {
1541
+ const [operation, setOperation] = (0, import_react18.useState)(data.operation);
1542
+ const [value, setValue] = (0, import_react18.useState)(data.value);
1543
+ const updateNodeData = (0, import_hooks13.useUpdateNodeData)();
1544
+ const incoming = (0, import_hooks13.useIncomingNodeData)(id);
1545
+ (0, import_react18.useEffect)(() => {
1546
+ if (incoming?.length > 1) {
1547
+ const result = getOperationResult(operation, incoming[0].value, incoming[1].value);
1548
+ setValue(result);
1549
+ updateNodeData(id, { value: result });
1550
+ }
1551
+ }, [operation, incoming]);
1552
+ const onChange = (0, import_react18.useCallback)((op) => {
1553
+ updateNodeData(id, { operation: op });
1554
+ setOperation(op);
1555
+ }, []);
1556
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_layout10.NodeContainer, { id, selected, data, type, children: [
1557
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_layout10.NodeCombobox, { options: options2, selected: operation, onChange }),
1558
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(node_value_input_default, { value, onChange: () => {
1559
+ }, disabled: true }),
1560
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_layout10.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1561
+ ] });
1562
+ }
1563
+ function getOperationResult(operation, value1, value2) {
1564
+ switch (operation) {
1565
+ case "add" /* add */:
1566
+ return Number(value1) + Number(value2);
1567
+ case "divide" /* divide */:
1568
+ return Number(value1) / (Number(value2) || 1);
1569
+ case "max" /* max */:
1570
+ return Number(value1) > Number(value2) ? value1 : value2;
1571
+ case "min" /* min */:
1572
+ return Number(value1) < Number(value2) ? value1 : value2;
1573
+ case "multiply" /* multiply */:
1574
+ return Number(value1) * Number(value2);
1575
+ case "power" /* power */:
1576
+ return Number(value1) ** Number(value2);
1577
+ }
1578
+ }
1579
+ var variable_combine_node_default = VariableCombineNode;
1580
+ // Annotate the CommonJS export names for ESM import in node:
1581
+ 0 && (module.exports = {
1582
+ NoiseAbsNode,
1583
+ NoiseClampNode,
1584
+ NoiseCombineNode,
1585
+ NoiseCurveNode,
1586
+ NoiseExponentNode,
1587
+ NoiseInvertNode,
1588
+ NoiseNormalizeNode,
1589
+ NoiseScaleBiasNode,
1590
+ NoiseTerraceNode,
1591
+ VariableCombineNode
1592
+ });
1593
+ //# sourceMappingURL=index.cjs.map