@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.
- package/dist/abstract/index.cjs +4234 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +137 -0
- package/dist/abstract/index.d.ts +137 -0
- package/dist/abstract/index.js +4271 -0
- package/dist/abstract/index.js.map +1 -0
- package/dist/handle-types-D-v5S53h.d.cts +22 -0
- package/dist/handle-types-D-v5S53h.d.ts +22 -0
- package/dist/layout/index.cjs +164 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.d.cts +26 -0
- package/dist/layout/index.d.ts +26 -0
- package/dist/layout/index.js +136 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/modules/index.cjs +71 -0
- package/dist/modules/index.cjs.map +1 -0
- package/dist/modules/index.d.cts +18 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +34 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/node-props-CeZ8Oshz.d.ts +161 -0
- package/dist/node-props-hKW-_KOU.d.cts +161 -0
- package/dist/nodes/generators/index.cjs +640 -0
- package/dist/nodes/generators/index.cjs.map +1 -0
- package/dist/nodes/generators/index.d.cts +38 -0
- package/dist/nodes/generators/index.d.ts +38 -0
- package/dist/nodes/generators/index.js +592 -0
- package/dist/nodes/generators/index.js.map +1 -0
- package/dist/nodes/groups/index.cjs +104 -0
- package/dist/nodes/groups/index.cjs.map +1 -0
- package/dist/nodes/groups/index.d.cts +7 -0
- package/dist/nodes/groups/index.d.ts +7 -0
- package/dist/nodes/groups/index.js +78 -0
- package/dist/nodes/groups/index.js.map +1 -0
- package/dist/nodes/index.cjs +2830 -0
- package/dist/nodes/index.cjs.map +1 -0
- package/dist/nodes/index.d.cts +16 -0
- package/dist/nodes/index.d.ts +16 -0
- package/dist/nodes/index.js +2840 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/modifiers/index.cjs +1593 -0
- package/dist/nodes/modifiers/index.cjs.map +1 -0
- package/dist/nodes/modifiers/index.d.cts +32 -0
- package/dist/nodes/modifiers/index.d.ts +32 -0
- package/dist/nodes/modifiers/index.js +1612 -0
- package/dist/nodes/modifiers/index.js.map +1 -0
- package/dist/nodes/output/index.cjs +210 -0
- package/dist/nodes/output/index.cjs.map +1 -0
- package/dist/nodes/output/index.d.cts +13 -0
- package/dist/nodes/output/index.d.ts +13 -0
- package/dist/nodes/output/index.js +181 -0
- package/dist/nodes/output/index.js.map +1 -0
- package/dist/nodes/selectors/index.cjs +136 -0
- package/dist/nodes/selectors/index.cjs.map +1 -0
- package/dist/nodes/selectors/index.d.cts +16 -0
- package/dist/nodes/selectors/index.d.ts +16 -0
- package/dist/nodes/selectors/index.js +113 -0
- package/dist/nodes/selectors/index.js.map +1 -0
- package/dist/nodes/transformers/index.cjs +477 -0
- package/dist/nodes/transformers/index.cjs.map +1 -0
- package/dist/nodes/transformers/index.d.cts +22 -0
- package/dist/nodes/transformers/index.d.ts +22 -0
- package/dist/nodes/transformers/index.js +459 -0
- package/dist/nodes/transformers/index.js.map +1 -0
- package/dist/properties-BxwtU6i9.d.cts +9 -0
- package/dist/properties-BxwtU6i9.d.ts +9 -0
- package/dist/templates/generators/index.cjs +1714 -0
- package/dist/templates/generators/index.cjs.map +1 -0
- package/dist/templates/generators/index.d.cts +89 -0
- package/dist/templates/generators/index.d.ts +89 -0
- package/dist/templates/generators/index.js +1723 -0
- package/dist/templates/generators/index.js.map +1 -0
- package/dist/templates/groups/index.cjs +1690 -0
- package/dist/templates/groups/index.cjs.map +1 -0
- package/dist/templates/groups/index.d.cts +11 -0
- package/dist/templates/groups/index.d.ts +11 -0
- package/dist/templates/groups/index.js +1711 -0
- package/dist/templates/groups/index.js.map +1 -0
- package/dist/templates/index.cjs +1758 -0
- package/dist/templates/index.cjs.map +1 -0
- package/dist/templates/index.d.cts +15 -0
- package/dist/templates/index.d.ts +15 -0
- package/dist/templates/index.js +1745 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/modifiers/index.cjs +1708 -0
- package/dist/templates/modifiers/index.cjs.map +1 -0
- package/dist/templates/modifiers/index.d.cts +71 -0
- package/dist/templates/modifiers/index.d.ts +71 -0
- package/dist/templates/modifiers/index.js +1720 -0
- package/dist/templates/modifiers/index.js.map +1 -0
- package/dist/templates/output/index.cjs +1696 -0
- package/dist/templates/output/index.cjs.map +1 -0
- package/dist/templates/output/index.d.cts +29 -0
- package/dist/templates/output/index.d.ts +29 -0
- package/dist/templates/output/index.js +1714 -0
- package/dist/templates/output/index.js.map +1 -0
- package/dist/templates/selectors/index.cjs +1692 -0
- package/dist/templates/selectors/index.cjs.map +1 -0
- package/dist/templates/selectors/index.d.cts +22 -0
- package/dist/templates/selectors/index.d.ts +22 -0
- package/dist/templates/selectors/index.js +1712 -0
- package/dist/templates/selectors/index.js.map +1 -0
- package/dist/templates/transformers/index.cjs +1698 -0
- package/dist/templates/transformers/index.cjs.map +1 -0
- package/dist/templates/transformers/index.d.cts +40 -0
- package/dist/templates/transformers/index.d.ts +40 -0
- package/dist/templates/transformers/index.js +1715 -0
- package/dist/templates/transformers/index.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,1612 @@
|
|
|
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/fast-deep-equal/index.js
|
|
28
|
+
var require_fast_deep_equal = __commonJS({
|
|
29
|
+
"../../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 }),
|
|
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/@mantine/form/esm/use-form.mjs
|
|
209
|
+
import { useState as useState5, useCallback as useCallback7 } from "react";
|
|
210
|
+
|
|
211
|
+
// ../../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/@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/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
|
|
317
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
318
|
+
|
|
319
|
+
// ../../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/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
|
|
334
|
+
function useFormErrors(initialErrors) {
|
|
335
|
+
const [errorsState, setErrorsState] = useState2(filterErrors(initialErrors));
|
|
336
|
+
const setErrors = useCallback2((errors) => {
|
|
337
|
+
setErrorsState(
|
|
338
|
+
(current) => filterErrors(typeof errors === "function" ? errors(current) : errors)
|
|
339
|
+
);
|
|
340
|
+
}, []);
|
|
341
|
+
const clearErrors = useCallback2(() => setErrorsState({}), []);
|
|
342
|
+
const clearFieldError = useCallback2(
|
|
343
|
+
(path) => {
|
|
344
|
+
if (errorsState[path] === void 0) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
setErrors((current) => {
|
|
348
|
+
const errors = { ...current };
|
|
349
|
+
delete errors[path];
|
|
350
|
+
return errors;
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
[errorsState]
|
|
354
|
+
);
|
|
355
|
+
const setFieldError = useCallback2(
|
|
356
|
+
(path, error) => {
|
|
357
|
+
if (error == null || error === false) {
|
|
358
|
+
clearFieldError(path);
|
|
359
|
+
} else if (errorsState[path] !== error) {
|
|
360
|
+
setErrors((current) => ({ ...current, [path]: error }));
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
[errorsState]
|
|
364
|
+
);
|
|
365
|
+
return {
|
|
366
|
+
errorsState,
|
|
367
|
+
setErrors,
|
|
368
|
+
clearErrors,
|
|
369
|
+
setFieldError,
|
|
370
|
+
clearFieldError
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
|
|
375
|
+
import { useCallback as useCallback3 } from "react";
|
|
376
|
+
|
|
377
|
+
// ../../node_modules/@mantine/form/esm/lists/clear-list-state.mjs
|
|
378
|
+
function clearListState(field, state) {
|
|
379
|
+
if (state === null || typeof state !== "object") {
|
|
380
|
+
return {};
|
|
381
|
+
}
|
|
382
|
+
const clone = { ...state };
|
|
383
|
+
Object.keys(state).forEach((errorKey) => {
|
|
384
|
+
if (errorKey.includes(`${String(field)}.`)) {
|
|
385
|
+
delete clone[errorKey];
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return clone;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// ../../node_modules/@mantine/form/esm/lists/change-error-indices.mjs
|
|
392
|
+
function getIndexFromKeyAfterPath(key, path) {
|
|
393
|
+
const split = key.substring(path.length + 1).split(".")[0];
|
|
394
|
+
return parseInt(split, 10);
|
|
395
|
+
}
|
|
396
|
+
function changeErrorIndices(path, index, errors, change) {
|
|
397
|
+
if (index === void 0) {
|
|
398
|
+
return errors;
|
|
399
|
+
}
|
|
400
|
+
const pathString = `${String(path)}`;
|
|
401
|
+
let clearedErrors = errors;
|
|
402
|
+
if (change === -1) {
|
|
403
|
+
clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);
|
|
404
|
+
}
|
|
405
|
+
const cloned = { ...clearedErrors };
|
|
406
|
+
const changedKeys = /* @__PURE__ */ new Set();
|
|
407
|
+
Object.entries(clearedErrors).filter(([key]) => {
|
|
408
|
+
if (!key.startsWith(`${pathString}.`)) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
412
|
+
if (Number.isNaN(currIndex)) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
return currIndex >= index;
|
|
416
|
+
}).forEach(([key, value]) => {
|
|
417
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
418
|
+
const newKey = key.replace(
|
|
419
|
+
`${pathString}.${currIndex}`,
|
|
420
|
+
`${pathString}.${currIndex + change}`
|
|
421
|
+
);
|
|
422
|
+
cloned[newKey] = value;
|
|
423
|
+
changedKeys.add(newKey);
|
|
424
|
+
if (!changedKeys.has(key)) {
|
|
425
|
+
delete cloned[key];
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
return cloned;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ../../node_modules/@mantine/form/esm/lists/reorder-errors.mjs
|
|
432
|
+
function reorderErrors(path, { from, to }, errors) {
|
|
433
|
+
const oldKeyStart = `${path}.${from}`;
|
|
434
|
+
const newKeyStart = `${path}.${to}`;
|
|
435
|
+
const clone = { ...errors };
|
|
436
|
+
Object.keys(errors).every((key) => {
|
|
437
|
+
let oldKey;
|
|
438
|
+
let newKey;
|
|
439
|
+
if (key.startsWith(oldKeyStart)) {
|
|
440
|
+
oldKey = key;
|
|
441
|
+
newKey = key.replace(oldKeyStart, newKeyStart);
|
|
442
|
+
}
|
|
443
|
+
if (key.startsWith(newKeyStart)) {
|
|
444
|
+
oldKey = key.replace(newKeyStart, oldKeyStart);
|
|
445
|
+
newKey = key;
|
|
446
|
+
}
|
|
447
|
+
if (oldKey && newKey) {
|
|
448
|
+
const value1 = clone[oldKey];
|
|
449
|
+
const value2 = clone[newKey];
|
|
450
|
+
value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
|
|
451
|
+
value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
return true;
|
|
455
|
+
});
|
|
456
|
+
return clone;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ../../node_modules/klona/full/index.mjs
|
|
460
|
+
function set(obj, key, val) {
|
|
461
|
+
if (typeof val.value === "object")
|
|
462
|
+
val.value = klona(val.value);
|
|
463
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
|
|
464
|
+
Object.defineProperty(obj, key, val);
|
|
465
|
+
} else
|
|
466
|
+
obj[key] = val.value;
|
|
467
|
+
}
|
|
468
|
+
function klona(x) {
|
|
469
|
+
if (typeof x !== "object")
|
|
470
|
+
return x;
|
|
471
|
+
var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
472
|
+
if (str === "[object Object]") {
|
|
473
|
+
tmp = Object.create(x.__proto__ || null);
|
|
474
|
+
} else if (str === "[object Array]") {
|
|
475
|
+
tmp = Array(x.length);
|
|
476
|
+
} else if (str === "[object Set]") {
|
|
477
|
+
tmp = /* @__PURE__ */ new Set();
|
|
478
|
+
x.forEach(function(val) {
|
|
479
|
+
tmp.add(klona(val));
|
|
480
|
+
});
|
|
481
|
+
} else if (str === "[object Map]") {
|
|
482
|
+
tmp = /* @__PURE__ */ new Map();
|
|
483
|
+
x.forEach(function(val, key) {
|
|
484
|
+
tmp.set(klona(key), klona(val));
|
|
485
|
+
});
|
|
486
|
+
} else if (str === "[object Date]") {
|
|
487
|
+
tmp = /* @__PURE__ */ new Date(+x);
|
|
488
|
+
} else if (str === "[object RegExp]") {
|
|
489
|
+
tmp = new RegExp(x.source, x.flags);
|
|
490
|
+
} else if (str === "[object DataView]") {
|
|
491
|
+
tmp = new x.constructor(klona(x.buffer));
|
|
492
|
+
} else if (str === "[object ArrayBuffer]") {
|
|
493
|
+
tmp = x.slice(0);
|
|
494
|
+
} else if (str.slice(-6) === "Array]") {
|
|
495
|
+
tmp = new x.constructor(x);
|
|
496
|
+
}
|
|
497
|
+
if (tmp) {
|
|
498
|
+
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
499
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
500
|
+
}
|
|
501
|
+
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
502
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k])
|
|
503
|
+
continue;
|
|
504
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return tmp || x;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// ../../node_modules/@mantine/form/esm/paths/get-splitted-path.mjs
|
|
511
|
+
function getSplittedPath(path) {
|
|
512
|
+
if (typeof path !== "string") {
|
|
513
|
+
return [];
|
|
514
|
+
}
|
|
515
|
+
return path.split(".");
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// ../../node_modules/@mantine/form/esm/paths/get-path.mjs
|
|
519
|
+
function getPath(path, values) {
|
|
520
|
+
const splittedPath = getSplittedPath(path);
|
|
521
|
+
if (splittedPath.length === 0 || typeof values !== "object" || values === null) {
|
|
522
|
+
return void 0;
|
|
523
|
+
}
|
|
524
|
+
let value = values[splittedPath[0]];
|
|
525
|
+
for (let i = 1; i < splittedPath.length; i += 1) {
|
|
526
|
+
if (value === void 0) {
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
value = value[splittedPath[i]];
|
|
530
|
+
}
|
|
531
|
+
return value;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// ../../node_modules/@mantine/form/esm/paths/set-path.mjs
|
|
535
|
+
function setPath(path, value, values) {
|
|
536
|
+
const splittedPath = getSplittedPath(path);
|
|
537
|
+
if (splittedPath.length === 0) {
|
|
538
|
+
return values;
|
|
539
|
+
}
|
|
540
|
+
const cloned = klona(values);
|
|
541
|
+
if (splittedPath.length === 1) {
|
|
542
|
+
cloned[splittedPath[0]] = value;
|
|
543
|
+
return cloned;
|
|
544
|
+
}
|
|
545
|
+
let val = cloned[splittedPath[0]];
|
|
546
|
+
for (let i = 1; i < splittedPath.length - 1; i += 1) {
|
|
547
|
+
if (val === void 0) {
|
|
548
|
+
return cloned;
|
|
549
|
+
}
|
|
550
|
+
val = val[splittedPath[i]];
|
|
551
|
+
}
|
|
552
|
+
val[splittedPath[splittedPath.length - 1]] = value;
|
|
553
|
+
return cloned;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// ../../node_modules/@mantine/form/esm/paths/reorder-path.mjs
|
|
557
|
+
function reorderPath(path, { from, to }, values) {
|
|
558
|
+
const currentValue = getPath(path, values);
|
|
559
|
+
if (!Array.isArray(currentValue)) {
|
|
560
|
+
return values;
|
|
561
|
+
}
|
|
562
|
+
const cloned = [...currentValue];
|
|
563
|
+
const item = currentValue[from];
|
|
564
|
+
cloned.splice(from, 1);
|
|
565
|
+
cloned.splice(to, 0, item);
|
|
566
|
+
return setPath(path, cloned, values);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// ../../node_modules/@mantine/form/esm/paths/insert-path.mjs
|
|
570
|
+
function insertPath(path, value, index, values) {
|
|
571
|
+
const currentValue = getPath(path, values);
|
|
572
|
+
if (!Array.isArray(currentValue)) {
|
|
573
|
+
return values;
|
|
574
|
+
}
|
|
575
|
+
const cloned = [...currentValue];
|
|
576
|
+
cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
|
|
577
|
+
return setPath(path, cloned, values);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// ../../node_modules/@mantine/form/esm/paths/remove-path.mjs
|
|
581
|
+
function removePath(path, index, values) {
|
|
582
|
+
const currentValue = getPath(path, values);
|
|
583
|
+
if (!Array.isArray(currentValue)) {
|
|
584
|
+
return values;
|
|
585
|
+
}
|
|
586
|
+
return setPath(
|
|
587
|
+
path,
|
|
588
|
+
currentValue.filter((_, itemIndex) => itemIndex !== index),
|
|
589
|
+
values
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
|
|
594
|
+
function useFormList({
|
|
595
|
+
$values,
|
|
596
|
+
$errors,
|
|
597
|
+
$status
|
|
598
|
+
}) {
|
|
599
|
+
const reorderListItem = useCallback3((path, payload) => {
|
|
600
|
+
$status.clearFieldDirty(path);
|
|
601
|
+
$errors.setErrors((errs) => reorderErrors(path, payload, errs));
|
|
602
|
+
$values.setValues({
|
|
603
|
+
values: reorderPath(path, payload, $values.refValues.current),
|
|
604
|
+
updateState: true
|
|
605
|
+
});
|
|
606
|
+
}, []);
|
|
607
|
+
const removeListItem = useCallback3((path, index) => {
|
|
608
|
+
$status.clearFieldDirty(path);
|
|
609
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, -1));
|
|
610
|
+
$values.setValues({
|
|
611
|
+
values: removePath(path, index, $values.refValues.current),
|
|
612
|
+
updateState: true
|
|
613
|
+
});
|
|
614
|
+
}, []);
|
|
615
|
+
const insertListItem = useCallback3((path, item, index) => {
|
|
616
|
+
$status.clearFieldDirty(path);
|
|
617
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, 1));
|
|
618
|
+
$values.setValues({
|
|
619
|
+
values: insertPath(path, item, index, $values.refValues.current),
|
|
620
|
+
updateState: true
|
|
621
|
+
});
|
|
622
|
+
}, []);
|
|
623
|
+
return { reorderListItem, removeListItem, insertListItem };
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
|
|
627
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
|
|
628
|
+
import { useState as useState3, useRef, useCallback as useCallback4 } from "react";
|
|
629
|
+
|
|
630
|
+
// ../../node_modules/@mantine/form/esm/get-status/get-status.mjs
|
|
631
|
+
function getStatus(status, path) {
|
|
632
|
+
const paths = Object.keys(status);
|
|
633
|
+
if (typeof path === "string") {
|
|
634
|
+
const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
|
|
635
|
+
return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
|
|
636
|
+
}
|
|
637
|
+
return paths.some((statusPath) => status[statusPath]);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
|
|
641
|
+
function useFormStatus({
|
|
642
|
+
initialDirty,
|
|
643
|
+
initialTouched,
|
|
644
|
+
mode,
|
|
645
|
+
$values
|
|
646
|
+
}) {
|
|
647
|
+
const [touchedState, setTouchedState] = useState3(initialTouched);
|
|
648
|
+
const [dirtyState, setDirtyState] = useState3(initialDirty);
|
|
649
|
+
const touchedRef = useRef(initialTouched);
|
|
650
|
+
const dirtyRef = useRef(initialDirty);
|
|
651
|
+
const setTouched = useCallback4((values) => {
|
|
652
|
+
const resolvedValues = typeof values === "function" ? values(touchedRef.current) : values;
|
|
653
|
+
touchedRef.current = resolvedValues;
|
|
654
|
+
if (mode === "controlled") {
|
|
655
|
+
setTouchedState(resolvedValues);
|
|
656
|
+
}
|
|
657
|
+
}, []);
|
|
658
|
+
const setDirty = useCallback4((values) => {
|
|
659
|
+
const resolvedValues = typeof values === "function" ? values(dirtyRef.current) : values;
|
|
660
|
+
dirtyRef.current = resolvedValues;
|
|
661
|
+
if (mode === "controlled") {
|
|
662
|
+
setDirtyState(resolvedValues);
|
|
663
|
+
}
|
|
664
|
+
}, []);
|
|
665
|
+
const resetTouched = useCallback4(() => setTouched({}), []);
|
|
666
|
+
const resetDirty = (values) => {
|
|
667
|
+
const newSnapshot = values ? { ...values, ...$values.refValues.current } : $values.refValues.current;
|
|
668
|
+
$values.setValuesSnapshot(newSnapshot);
|
|
669
|
+
setDirty({});
|
|
670
|
+
};
|
|
671
|
+
const setFieldTouched = useCallback4((path, touched) => {
|
|
672
|
+
setTouched((currentTouched) => {
|
|
673
|
+
if (getStatus(currentTouched, path) === touched) {
|
|
674
|
+
return currentTouched;
|
|
675
|
+
}
|
|
676
|
+
return { ...currentTouched, [path]: touched };
|
|
677
|
+
});
|
|
678
|
+
}, []);
|
|
679
|
+
const setFieldDirty = useCallback4((path, dirty) => {
|
|
680
|
+
setDirty((currentDirty) => {
|
|
681
|
+
if (getStatus(currentDirty, path) === dirty) {
|
|
682
|
+
return currentDirty;
|
|
683
|
+
}
|
|
684
|
+
return { ...currentDirty, [path]: dirty };
|
|
685
|
+
});
|
|
686
|
+
}, []);
|
|
687
|
+
const isTouched = useCallback4(
|
|
688
|
+
(path) => getStatus(touchedRef.current, path),
|
|
689
|
+
[]
|
|
690
|
+
);
|
|
691
|
+
const clearFieldDirty = useCallback4(
|
|
692
|
+
(path) => setDirty((current) => {
|
|
693
|
+
if (typeof path !== "string") {
|
|
694
|
+
return current;
|
|
695
|
+
}
|
|
696
|
+
const result = clearListState(path, current);
|
|
697
|
+
delete result[path];
|
|
698
|
+
if ((0, import_fast_deep_equal.default)(result, current)) {
|
|
699
|
+
return current;
|
|
700
|
+
}
|
|
701
|
+
return result;
|
|
702
|
+
}),
|
|
703
|
+
[]
|
|
704
|
+
);
|
|
705
|
+
const isDirty = useCallback4((path) => {
|
|
706
|
+
if (path) {
|
|
707
|
+
const overriddenValue = getPath(path, dirtyRef.current);
|
|
708
|
+
if (typeof overriddenValue === "boolean") {
|
|
709
|
+
return overriddenValue;
|
|
710
|
+
}
|
|
711
|
+
const sliceOfValues = getPath(path, $values.refValues.current);
|
|
712
|
+
const sliceOfInitialValues = getPath(path, $values.valuesSnapshot.current);
|
|
713
|
+
return !(0, import_fast_deep_equal.default)(sliceOfValues, sliceOfInitialValues);
|
|
714
|
+
}
|
|
715
|
+
const isOverridden = Object.keys(dirtyRef.current).length > 0;
|
|
716
|
+
if (isOverridden) {
|
|
717
|
+
return getStatus(dirtyRef.current);
|
|
718
|
+
}
|
|
719
|
+
return !(0, import_fast_deep_equal.default)($values.refValues.current, $values.valuesSnapshot.current);
|
|
720
|
+
}, []);
|
|
721
|
+
const getDirty = useCallback4(() => dirtyRef.current, []);
|
|
722
|
+
const getTouched = useCallback4(() => touchedRef.current, []);
|
|
723
|
+
return {
|
|
724
|
+
touchedState,
|
|
725
|
+
dirtyState,
|
|
726
|
+
touchedRef,
|
|
727
|
+
dirtyRef,
|
|
728
|
+
setTouched,
|
|
729
|
+
setDirty,
|
|
730
|
+
resetDirty,
|
|
731
|
+
resetTouched,
|
|
732
|
+
isTouched,
|
|
733
|
+
setFieldTouched,
|
|
734
|
+
setFieldDirty,
|
|
735
|
+
setTouchedState,
|
|
736
|
+
setDirtyState,
|
|
737
|
+
clearFieldDirty,
|
|
738
|
+
isDirty,
|
|
739
|
+
getDirty,
|
|
740
|
+
getTouched
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
|
|
745
|
+
import { useRef as useRef2, useState as useState4, useCallback as useCallback5 } from "react";
|
|
746
|
+
function useFormValues({
|
|
747
|
+
initialValues,
|
|
748
|
+
onValuesChange,
|
|
749
|
+
mode
|
|
750
|
+
}) {
|
|
751
|
+
const initialized = useRef2(false);
|
|
752
|
+
const [stateValues, setStateValues] = useState4(initialValues || {});
|
|
753
|
+
const refValues = useRef2(stateValues);
|
|
754
|
+
const valuesSnapshot = useRef2(stateValues);
|
|
755
|
+
const setValues = useCallback5(
|
|
756
|
+
({
|
|
757
|
+
values,
|
|
758
|
+
subscribers,
|
|
759
|
+
updateState = true,
|
|
760
|
+
mergeWithPreviousValues = true
|
|
761
|
+
}) => {
|
|
762
|
+
const previousValues = refValues.current;
|
|
763
|
+
const resolvedValues = values instanceof Function ? values(refValues.current) : values;
|
|
764
|
+
const updatedValues = mergeWithPreviousValues ? { ...previousValues, ...resolvedValues } : resolvedValues;
|
|
765
|
+
refValues.current = updatedValues;
|
|
766
|
+
updateState && setStateValues(updatedValues);
|
|
767
|
+
onValuesChange?.(updatedValues, previousValues);
|
|
768
|
+
subscribers?.filter(Boolean).forEach((subscriber) => subscriber({ updatedValues, previousValues }));
|
|
769
|
+
},
|
|
770
|
+
[onValuesChange]
|
|
771
|
+
);
|
|
772
|
+
const setFieldValue = useCallback5((payload) => {
|
|
773
|
+
const currentValue = getPath(payload.path, refValues.current);
|
|
774
|
+
const updatedValue = payload.value instanceof Function ? payload.value(currentValue) : payload.value;
|
|
775
|
+
if (currentValue !== updatedValue) {
|
|
776
|
+
const previousValues = refValues.current;
|
|
777
|
+
const updatedValues = setPath(payload.path, updatedValue, refValues.current);
|
|
778
|
+
setValues({ values: updatedValues, updateState: payload.updateState });
|
|
779
|
+
payload.subscribers?.filter(Boolean).forEach(
|
|
780
|
+
(subscriber) => subscriber({ path: payload.path, updatedValues, previousValues })
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
}, []);
|
|
784
|
+
const setValuesSnapshot = useCallback5((payload) => {
|
|
785
|
+
valuesSnapshot.current = payload;
|
|
786
|
+
}, []);
|
|
787
|
+
const initialize = useCallback5((values, onInitialize) => {
|
|
788
|
+
if (!initialized.current) {
|
|
789
|
+
initialized.current = true;
|
|
790
|
+
setValues({ values, updateState: mode === "controlled" });
|
|
791
|
+
setValuesSnapshot(values);
|
|
792
|
+
onInitialize();
|
|
793
|
+
}
|
|
794
|
+
}, []);
|
|
795
|
+
const resetValues = useCallback5(() => {
|
|
796
|
+
setValues({
|
|
797
|
+
values: valuesSnapshot.current,
|
|
798
|
+
updateState: true,
|
|
799
|
+
mergeWithPreviousValues: false
|
|
800
|
+
});
|
|
801
|
+
}, []);
|
|
802
|
+
const getValues = useCallback5(() => refValues.current, []);
|
|
803
|
+
return {
|
|
804
|
+
initialized,
|
|
805
|
+
stateValues,
|
|
806
|
+
refValues,
|
|
807
|
+
valuesSnapshot,
|
|
808
|
+
setValues,
|
|
809
|
+
setFieldValue,
|
|
810
|
+
resetValues,
|
|
811
|
+
setValuesSnapshot,
|
|
812
|
+
initialize,
|
|
813
|
+
getValues
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
|
|
818
|
+
import { useRef as useRef3, useCallback as useCallback6, useEffect as useEffect5 } from "react";
|
|
819
|
+
function useFormWatch({
|
|
820
|
+
$status
|
|
821
|
+
}) {
|
|
822
|
+
const subscribers = useRef3(
|
|
823
|
+
{}
|
|
824
|
+
);
|
|
825
|
+
const watch = useCallback6((path, callback) => {
|
|
826
|
+
useEffect5(() => {
|
|
827
|
+
subscribers.current[path] = subscribers.current[path] || [];
|
|
828
|
+
subscribers.current[path].push(callback);
|
|
829
|
+
return () => {
|
|
830
|
+
subscribers.current[path] = subscribers.current[path].filter((cb) => cb !== callback);
|
|
831
|
+
};
|
|
832
|
+
}, [callback]);
|
|
833
|
+
}, []);
|
|
834
|
+
const getFieldSubscribers = useCallback6((path) => {
|
|
835
|
+
if (!subscribers.current[path]) {
|
|
836
|
+
return [];
|
|
837
|
+
}
|
|
838
|
+
return subscribers.current[path].map(
|
|
839
|
+
(callback) => (input) => callback({
|
|
840
|
+
previousValue: getPath(path, input.previousValues),
|
|
841
|
+
value: getPath(path, input.updatedValues),
|
|
842
|
+
touched: $status.isTouched(path),
|
|
843
|
+
dirty: $status.isDirty(path)
|
|
844
|
+
})
|
|
845
|
+
);
|
|
846
|
+
}, []);
|
|
847
|
+
return {
|
|
848
|
+
subscribers,
|
|
849
|
+
watch,
|
|
850
|
+
getFieldSubscribers
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// ../../node_modules/@mantine/form/esm/validate/validate-values.mjs
|
|
855
|
+
function getValidationResults(errors) {
|
|
856
|
+
const filteredErrors = filterErrors(errors);
|
|
857
|
+
return { hasErrors: Object.keys(filteredErrors).length > 0, errors: filteredErrors };
|
|
858
|
+
}
|
|
859
|
+
function validateRulesRecord(rules, values, path = "", errors = {}) {
|
|
860
|
+
if (typeof rules !== "object" || rules === null) {
|
|
861
|
+
return errors;
|
|
862
|
+
}
|
|
863
|
+
return Object.keys(rules).reduce((acc, ruleKey) => {
|
|
864
|
+
const rule = rules[ruleKey];
|
|
865
|
+
const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
|
|
866
|
+
const value = getPath(rulePath, values);
|
|
867
|
+
let arrayValidation = false;
|
|
868
|
+
if (typeof rule === "function") {
|
|
869
|
+
acc[rulePath] = rule(value, values, rulePath);
|
|
870
|
+
}
|
|
871
|
+
if (typeof rule === "object" && Array.isArray(value)) {
|
|
872
|
+
arrayValidation = true;
|
|
873
|
+
value.forEach(
|
|
874
|
+
(_item, index) => validateRulesRecord(rule, values, `${rulePath}.${index}`, acc)
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
if (typeof rule === "object" && typeof value === "object" && value !== null) {
|
|
878
|
+
if (!arrayValidation) {
|
|
879
|
+
validateRulesRecord(rule, values, rulePath, acc);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return acc;
|
|
883
|
+
}, errors);
|
|
884
|
+
}
|
|
885
|
+
function validateValues(validate, values) {
|
|
886
|
+
if (typeof validate === "function") {
|
|
887
|
+
return getValidationResults(validate(values));
|
|
888
|
+
}
|
|
889
|
+
return getValidationResults(validateRulesRecord(validate, values));
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// ../../node_modules/@mantine/form/esm/validate/validate-field-value.mjs
|
|
893
|
+
function validateFieldValue(path, rules, values) {
|
|
894
|
+
if (typeof path !== "string") {
|
|
895
|
+
return { hasError: false, error: null };
|
|
896
|
+
}
|
|
897
|
+
const results = validateValues(rules, values);
|
|
898
|
+
const pathInError = Object.keys(results.errors).find(
|
|
899
|
+
(errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i])
|
|
900
|
+
);
|
|
901
|
+
return { hasError: !!pathInError, error: pathInError ? results.errors[pathInError] : null };
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// ../../node_modules/@mantine/form/esm/form-index.mjs
|
|
905
|
+
var FORM_INDEX = "__MANTINE_FORM_INDEX__";
|
|
906
|
+
|
|
907
|
+
// ../../node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
|
|
908
|
+
function shouldValidateOnChange(path, validateInputOnChange) {
|
|
909
|
+
if (!validateInputOnChange) {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
if (typeof validateInputOnChange === "boolean") {
|
|
913
|
+
return validateInputOnChange;
|
|
914
|
+
}
|
|
915
|
+
if (Array.isArray(validateInputOnChange)) {
|
|
916
|
+
return validateInputOnChange.includes(path.replace(/[.][0-9]/g, `.${FORM_INDEX}`));
|
|
917
|
+
}
|
|
918
|
+
return false;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// ../../node_modules/@mantine/form/esm/use-form.mjs
|
|
922
|
+
function useForm({
|
|
923
|
+
name,
|
|
924
|
+
mode = "controlled",
|
|
925
|
+
initialValues,
|
|
926
|
+
initialErrors = {},
|
|
927
|
+
initialDirty = {},
|
|
928
|
+
initialTouched = {},
|
|
929
|
+
clearInputErrorOnChange = true,
|
|
930
|
+
validateInputOnChange = false,
|
|
931
|
+
validateInputOnBlur = false,
|
|
932
|
+
onValuesChange,
|
|
933
|
+
transformValues = (values) => values,
|
|
934
|
+
enhanceGetInputProps,
|
|
935
|
+
validate: rules
|
|
936
|
+
} = {}) {
|
|
937
|
+
const $errors = useFormErrors(initialErrors);
|
|
938
|
+
const $values = useFormValues({ initialValues, onValuesChange, mode });
|
|
939
|
+
const $status = useFormStatus({ initialDirty, initialTouched, $values, mode });
|
|
940
|
+
const $list = useFormList({ $values, $errors, $status });
|
|
941
|
+
const $watch = useFormWatch({ $status });
|
|
942
|
+
const [formKey, setFormKey] = useState5(0);
|
|
943
|
+
const [fieldKeys, setFieldKeys] = useState5({});
|
|
944
|
+
const reset = useCallback7(() => {
|
|
945
|
+
$values.resetValues();
|
|
946
|
+
$errors.clearErrors();
|
|
947
|
+
$status.resetDirty();
|
|
948
|
+
$status.resetTouched();
|
|
949
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
950
|
+
}, []);
|
|
951
|
+
const initialize = useCallback7((values) => {
|
|
952
|
+
$values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
|
|
953
|
+
}, []);
|
|
954
|
+
const setFieldValue = useCallback7(
|
|
955
|
+
(path, value, options3) => {
|
|
956
|
+
const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
|
|
957
|
+
$status.clearFieldDirty(path);
|
|
958
|
+
$status.setFieldTouched(path, true);
|
|
959
|
+
!shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
|
|
960
|
+
$values.setFieldValue({
|
|
961
|
+
path,
|
|
962
|
+
value,
|
|
963
|
+
updateState: mode === "controlled",
|
|
964
|
+
subscribers: [
|
|
965
|
+
...$watch.getFieldSubscribers(path),
|
|
966
|
+
shouldValidate ? (payload) => {
|
|
967
|
+
const validationResults = validateFieldValue(path, rules, payload.updatedValues);
|
|
968
|
+
validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
|
|
969
|
+
} : null,
|
|
970
|
+
options3?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
|
|
971
|
+
...keys,
|
|
972
|
+
[path]: (keys[path] || 0) + 1
|
|
973
|
+
})) : null
|
|
974
|
+
]
|
|
975
|
+
});
|
|
976
|
+
},
|
|
977
|
+
[onValuesChange, rules]
|
|
978
|
+
);
|
|
979
|
+
const setValues = useCallback7(
|
|
980
|
+
(values) => {
|
|
981
|
+
const previousValues = $values.refValues.current;
|
|
982
|
+
$values.setValues({ values, updateState: mode === "controlled" });
|
|
983
|
+
clearInputErrorOnChange && $errors.clearErrors();
|
|
984
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
985
|
+
Object.keys($watch.subscribers.current).forEach((path) => {
|
|
986
|
+
const value = getPath(path, $values.refValues.current);
|
|
987
|
+
const previousValue = getPath(path, previousValues);
|
|
988
|
+
if (value !== previousValue) {
|
|
989
|
+
$watch.getFieldSubscribers(path).forEach((cb) => cb({ previousValues, updatedValues: $values.refValues.current }));
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
},
|
|
993
|
+
[onValuesChange, clearInputErrorOnChange]
|
|
994
|
+
);
|
|
995
|
+
const validate = useCallback7(() => {
|
|
996
|
+
const results = validateValues(rules, $values.refValues.current);
|
|
997
|
+
$errors.setErrors(results.errors);
|
|
998
|
+
return results;
|
|
999
|
+
}, [rules]);
|
|
1000
|
+
const validateField = useCallback7(
|
|
1001
|
+
(path) => {
|
|
1002
|
+
const results = validateFieldValue(path, rules, $values.refValues.current);
|
|
1003
|
+
results.hasError ? $errors.setFieldError(path, results.error) : $errors.clearFieldError(path);
|
|
1004
|
+
return results;
|
|
1005
|
+
},
|
|
1006
|
+
[rules]
|
|
1007
|
+
);
|
|
1008
|
+
const getInputProps = (path, { type = "input", withError = true, withFocus = true, ...otherOptions } = {}) => {
|
|
1009
|
+
const onChange = getInputOnChange(
|
|
1010
|
+
(value) => setFieldValue(path, value, { forceUpdate: false })
|
|
1011
|
+
);
|
|
1012
|
+
const payload = { onChange };
|
|
1013
|
+
if (withError) {
|
|
1014
|
+
payload.error = $errors.errorsState[path];
|
|
1015
|
+
}
|
|
1016
|
+
if (type === "checkbox") {
|
|
1017
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(
|
|
1018
|
+
path,
|
|
1019
|
+
$values.refValues.current
|
|
1020
|
+
);
|
|
1021
|
+
} else {
|
|
1022
|
+
payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(
|
|
1023
|
+
path,
|
|
1024
|
+
$values.refValues.current
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
if (withFocus) {
|
|
1028
|
+
payload.onFocus = () => $status.setFieldTouched(path, true);
|
|
1029
|
+
payload.onBlur = () => {
|
|
1030
|
+
if (shouldValidateOnChange(path, validateInputOnBlur)) {
|
|
1031
|
+
const validationResults = validateFieldValue(path, rules, $values.refValues.current);
|
|
1032
|
+
validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
return Object.assign(
|
|
1037
|
+
payload,
|
|
1038
|
+
enhanceGetInputProps?.({
|
|
1039
|
+
inputProps: payload,
|
|
1040
|
+
field: path,
|
|
1041
|
+
options: { type, withError, withFocus, ...otherOptions },
|
|
1042
|
+
form
|
|
1043
|
+
})
|
|
1044
|
+
);
|
|
1045
|
+
};
|
|
1046
|
+
const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
|
|
1047
|
+
event?.preventDefault();
|
|
1048
|
+
const results = validate();
|
|
1049
|
+
if (results.hasErrors) {
|
|
1050
|
+
handleValidationFailure?.(results.errors, $values.refValues.current, event);
|
|
1051
|
+
} else {
|
|
1052
|
+
handleSubmit?.(transformValues($values.refValues.current), event);
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
|
|
1056
|
+
const onReset = useCallback7((event) => {
|
|
1057
|
+
event.preventDefault();
|
|
1058
|
+
reset();
|
|
1059
|
+
}, []);
|
|
1060
|
+
const isValid = useCallback7(
|
|
1061
|
+
(path) => path ? !validateFieldValue(path, rules, $values.refValues.current).hasError : !validateValues(rules, $values.refValues.current).hasErrors,
|
|
1062
|
+
[rules]
|
|
1063
|
+
);
|
|
1064
|
+
const key = (path) => `${formKey}-${path}-${fieldKeys[path] || 0}`;
|
|
1065
|
+
const form = {
|
|
1066
|
+
watch: $watch.watch,
|
|
1067
|
+
initialized: $values.initialized.current,
|
|
1068
|
+
values: $values.stateValues,
|
|
1069
|
+
getValues: $values.getValues,
|
|
1070
|
+
setInitialValues: $values.setValuesSnapshot,
|
|
1071
|
+
initialize,
|
|
1072
|
+
setValues,
|
|
1073
|
+
setFieldValue,
|
|
1074
|
+
errors: $errors.errorsState,
|
|
1075
|
+
setErrors: $errors.setErrors,
|
|
1076
|
+
setFieldError: $errors.setFieldError,
|
|
1077
|
+
clearFieldError: $errors.clearFieldError,
|
|
1078
|
+
clearErrors: $errors.clearErrors,
|
|
1079
|
+
resetDirty: $status.resetDirty,
|
|
1080
|
+
setTouched: $status.setTouched,
|
|
1081
|
+
setDirty: $status.setDirty,
|
|
1082
|
+
isTouched: $status.isTouched,
|
|
1083
|
+
resetTouched: $status.resetTouched,
|
|
1084
|
+
isDirty: $status.isDirty,
|
|
1085
|
+
getTouched: $status.getTouched,
|
|
1086
|
+
getDirty: $status.getDirty,
|
|
1087
|
+
reorderListItem: $list.reorderListItem,
|
|
1088
|
+
insertListItem: $list.insertListItem,
|
|
1089
|
+
removeListItem: $list.removeListItem,
|
|
1090
|
+
reset,
|
|
1091
|
+
validate,
|
|
1092
|
+
validateField,
|
|
1093
|
+
getInputProps,
|
|
1094
|
+
onSubmit,
|
|
1095
|
+
onReset,
|
|
1096
|
+
isValid,
|
|
1097
|
+
getTransformedValues,
|
|
1098
|
+
key
|
|
1099
|
+
};
|
|
1100
|
+
useFormActions(name, form);
|
|
1101
|
+
return form;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// src/nodes/modifiers/noise-curve-node.tsx
|
|
1105
|
+
import { useCallback as useCallback8, useEffect as useEffect6, useState as useState6 } from "react";
|
|
1106
|
+
import { Curve } from "libnoise-ts/module/modifier";
|
|
1107
|
+
import { Tuple } from "libnoise-ts/util";
|
|
1108
|
+
import { IconX } from "@tabler/icons-react";
|
|
1109
|
+
import { randomId } from "@mantine/hooks";
|
|
1110
|
+
import { NodeState } from "@awesome-flow/core/abstract";
|
|
1111
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1112
|
+
function NoiseCurveNode({ id, selected, data, type }) {
|
|
1113
|
+
const incoming = useIncomingComputedData4(id);
|
|
1114
|
+
const updateNodeData = useUpdateNodeData3();
|
|
1115
|
+
const updateComputedData = useUpdateNodeComputedData4();
|
|
1116
|
+
const [values, setValues] = useState6([]);
|
|
1117
|
+
const form = useForm({
|
|
1118
|
+
mode: "uncontrolled",
|
|
1119
|
+
initialValues: {
|
|
1120
|
+
points: []
|
|
1121
|
+
},
|
|
1122
|
+
validateInputOnChange: [`points.${FORM_INDEX}.input`],
|
|
1123
|
+
clearInputErrorOnChange: true,
|
|
1124
|
+
validate: {
|
|
1125
|
+
points: {
|
|
1126
|
+
input: (value, values2) => {
|
|
1127
|
+
const counts = {};
|
|
1128
|
+
values2.points.forEach((x) => {
|
|
1129
|
+
counts[x.input] = (counts[x.input] || 0) + 1;
|
|
1130
|
+
});
|
|
1131
|
+
return counts[value] > 1;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
onValuesChange: useCallback8((values2) => {
|
|
1136
|
+
if (form.isValid()) {
|
|
1137
|
+
const points = values2.points.map((v) => ({ input: v.input, output: v.output }));
|
|
1138
|
+
setValues(points);
|
|
1139
|
+
updateNodeData(id, { points });
|
|
1140
|
+
}
|
|
1141
|
+
form.validate();
|
|
1142
|
+
}, [])
|
|
1143
|
+
});
|
|
1144
|
+
useEffect6(() => {
|
|
1145
|
+
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() }));
|
|
1146
|
+
form.initialize({ points });
|
|
1147
|
+
}, []);
|
|
1148
|
+
useEffect6(() => {
|
|
1149
|
+
if (incoming?.length && values?.length >= 4) {
|
|
1150
|
+
const module = new Curve(
|
|
1151
|
+
incoming[0].module,
|
|
1152
|
+
values.map((p) => new Tuple(p.input, p.output))
|
|
1153
|
+
);
|
|
1154
|
+
updateComputedData(id, { module });
|
|
1155
|
+
}
|
|
1156
|
+
}, [values, incoming]);
|
|
1157
|
+
const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs3(Group2, { mt: "xs", children: [
|
|
1158
|
+
/* @__PURE__ */ jsx4(
|
|
1159
|
+
NumberInput2,
|
|
1160
|
+
{
|
|
1161
|
+
size: "xs",
|
|
1162
|
+
w: 100,
|
|
1163
|
+
placeholder: "Input Value",
|
|
1164
|
+
...form.getInputProps(`points.${index}.input`),
|
|
1165
|
+
step: 0.1
|
|
1166
|
+
},
|
|
1167
|
+
form.key(`points.${index}.input`)
|
|
1168
|
+
),
|
|
1169
|
+
/* @__PURE__ */ jsx4(
|
|
1170
|
+
NumberInput2,
|
|
1171
|
+
{
|
|
1172
|
+
size: "xs",
|
|
1173
|
+
w: 100,
|
|
1174
|
+
placeholder: "Output Value",
|
|
1175
|
+
...form.getInputProps(`points.${index}.output`),
|
|
1176
|
+
step: 0.1
|
|
1177
|
+
},
|
|
1178
|
+
form.key(`points.${index}.output`)
|
|
1179
|
+
),
|
|
1180
|
+
data.state === NodeState.edit && values.length > 4 && /* @__PURE__ */ jsx4(
|
|
1181
|
+
ActionIcon,
|
|
1182
|
+
{
|
|
1183
|
+
color: "red",
|
|
1184
|
+
variant: "outline",
|
|
1185
|
+
size: "sm",
|
|
1186
|
+
onClick: () => form.removeListItem("points", index),
|
|
1187
|
+
children: /* @__PURE__ */ jsx4(IconX, { size: "1rem" })
|
|
1188
|
+
}
|
|
1189
|
+
)
|
|
1190
|
+
] }, item.key));
|
|
1191
|
+
return /* @__PURE__ */ jsxs3(NodeContainer4, { id, selected, type, data, children: [
|
|
1192
|
+
fields,
|
|
1193
|
+
data.state === NodeState.edit && /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
1194
|
+
/* @__PURE__ */ jsx4(Space, { h: 10 }),
|
|
1195
|
+
/* @__PURE__ */ jsx4(
|
|
1196
|
+
Button,
|
|
1197
|
+
{
|
|
1198
|
+
variant: "outline",
|
|
1199
|
+
size: "xs",
|
|
1200
|
+
fullWidth: true,
|
|
1201
|
+
onClick: () => form.insertListItem("points", { input: 0, output: 0, key: randomId() }),
|
|
1202
|
+
children: "Add control point"
|
|
1203
|
+
}
|
|
1204
|
+
)
|
|
1205
|
+
] }),
|
|
1206
|
+
/* @__PURE__ */ jsx4(NodeTrackConnections4, { handles: data.handles, nodeId: id, type: "target" })
|
|
1207
|
+
] });
|
|
1208
|
+
}
|
|
1209
|
+
var noise_curve_node_default = NoiseCurveNode;
|
|
1210
|
+
|
|
1211
|
+
// src/nodes/modifiers/noise-exponent-node.tsx
|
|
1212
|
+
import { NodeContainer as NodeContainer5, NodeTrackConnections as NodeTrackConnections5 } from "@awesome-flow/core/layout";
|
|
1213
|
+
import { useEffect as useEffect7, useState as useState7 } from "react";
|
|
1214
|
+
import { Group as Group3, NumberInput as NumberInput3, Stack as Stack2 } from "@mantine/core";
|
|
1215
|
+
import {
|
|
1216
|
+
useIncomingComputedData as useIncomingComputedData5,
|
|
1217
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData5,
|
|
1218
|
+
useUpdateNodeData as useUpdateNodeData4
|
|
1219
|
+
} from "@awesome-flow/core/hooks";
|
|
1220
|
+
import { Exponent } from "libnoise-ts/module/modifier";
|
|
1221
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1222
|
+
function NoiseExponentNode({ id, selected, data, type }) {
|
|
1223
|
+
const [exponent, setExponent] = useState7(data.exponent);
|
|
1224
|
+
const incoming = useIncomingComputedData5(id);
|
|
1225
|
+
const updateNodeData = useUpdateNodeData4();
|
|
1226
|
+
const updateComputedData = useUpdateNodeComputedData5();
|
|
1227
|
+
useEffect7(() => {
|
|
1228
|
+
if (incoming?.length > 0) {
|
|
1229
|
+
const module = new Exponent(incoming[0].module, exponent);
|
|
1230
|
+
updateComputedData(id, { module });
|
|
1231
|
+
}
|
|
1232
|
+
updateNodeData(id, { exponent });
|
|
1233
|
+
}, [incoming, exponent]);
|
|
1234
|
+
return /* @__PURE__ */ jsxs4(NodeContainer5, { id, selected, data, type, children: [
|
|
1235
|
+
/* @__PURE__ */ jsx5(Stack2, { children: /* @__PURE__ */ jsxs4(Group3, { children: [
|
|
1236
|
+
"Exponent:",
|
|
1237
|
+
/* @__PURE__ */ jsx5(
|
|
1238
|
+
NumberInput3,
|
|
1239
|
+
{
|
|
1240
|
+
size: "xs",
|
|
1241
|
+
value: exponent,
|
|
1242
|
+
onChange: (e) => setExponent(Number(e)),
|
|
1243
|
+
step: 0.1
|
|
1244
|
+
}
|
|
1245
|
+
)
|
|
1246
|
+
] }) }),
|
|
1247
|
+
/* @__PURE__ */ jsx5(NodeTrackConnections5, { handles: data.handles, nodeId: id, type: "target" })
|
|
1248
|
+
] });
|
|
1249
|
+
}
|
|
1250
|
+
var noise_exponent_node_default = NoiseExponentNode;
|
|
1251
|
+
|
|
1252
|
+
// src/nodes/modifiers/noise-invert-node.tsx
|
|
1253
|
+
import { NodeContainer as NodeContainer6, NodeTrackConnections as NodeTrackConnections6 } from "@awesome-flow/core/layout";
|
|
1254
|
+
import { useEffect as useEffect8 } from "react";
|
|
1255
|
+
import { useIncomingComputedData as useIncomingComputedData6, useUpdateNodeComputedData as useUpdateNodeComputedData6 } from "@awesome-flow/core/hooks";
|
|
1256
|
+
import { Invert } from "libnoise-ts/module/modifier";
|
|
1257
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1258
|
+
function NoiseInvertNode({ id, selected, data, type }) {
|
|
1259
|
+
const incoming = useIncomingComputedData6(id);
|
|
1260
|
+
const updateComputedData = useUpdateNodeComputedData6();
|
|
1261
|
+
useEffect8(() => {
|
|
1262
|
+
if (incoming?.length > 0) {
|
|
1263
|
+
const module = new Invert(incoming[0].module);
|
|
1264
|
+
updateComputedData(id, { module });
|
|
1265
|
+
}
|
|
1266
|
+
}, [incoming]);
|
|
1267
|
+
return /* @__PURE__ */ jsx6(NodeContainer6, { id, selected, data, type, children: /* @__PURE__ */ jsx6(NodeTrackConnections6, { handles: data.handles, nodeId: id, type: "target" }) });
|
|
1268
|
+
}
|
|
1269
|
+
var noise_invert_node_default = NoiseInvertNode;
|
|
1270
|
+
|
|
1271
|
+
// src/nodes/modifiers/noise-normalize-node.tsx
|
|
1272
|
+
import { NodeContainer as NodeContainer7, NodeTrackConnections as NodeTrackConnections7 } from "@awesome-flow/core/layout";
|
|
1273
|
+
import { useEffect as useEffect9, useState as useState8 } from "react";
|
|
1274
|
+
import { Group as Group4, NumberInput as NumberInput4, Stack as Stack3 } from "@mantine/core";
|
|
1275
|
+
import {
|
|
1276
|
+
useIncomingComputedData as useIncomingComputedData7,
|
|
1277
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData7,
|
|
1278
|
+
useUpdateNodeData as useUpdateNodeData5
|
|
1279
|
+
} from "@awesome-flow/core/hooks";
|
|
1280
|
+
|
|
1281
|
+
// src/modules/normalize-noise-module.ts
|
|
1282
|
+
import ModifierModule from "libnoise-ts/module/modifier";
|
|
1283
|
+
var NormalizeNoiseModule = class extends ModifierModule {
|
|
1284
|
+
constructor(source, lowerBound, upperBound) {
|
|
1285
|
+
super(source);
|
|
1286
|
+
this.lowerBound = lowerBound;
|
|
1287
|
+
this.upperBound = upperBound;
|
|
1288
|
+
}
|
|
1289
|
+
getValue(x, y, z) {
|
|
1290
|
+
return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
function normalize(value, min, max) {
|
|
1294
|
+
return (value - min) / (max - min);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
// src/nodes/modifiers/noise-normalize-node.tsx
|
|
1298
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1299
|
+
function NoiseNormalizeNode({ id, selected, data, type }) {
|
|
1300
|
+
const [intervalStart, setIntervalStart] = useState8(data.intervalStart);
|
|
1301
|
+
const [intervalEnd, setIntervalEnd] = useState8(data.intervalEnd);
|
|
1302
|
+
const incoming = useIncomingComputedData7(id);
|
|
1303
|
+
const updateNodeData = useUpdateNodeData5();
|
|
1304
|
+
const updateComputedData = useUpdateNodeComputedData7();
|
|
1305
|
+
useEffect9(() => {
|
|
1306
|
+
if (incoming?.length) {
|
|
1307
|
+
const source = incoming[0].module;
|
|
1308
|
+
const module = new NormalizeNoiseModule(source, intervalStart, intervalEnd);
|
|
1309
|
+
updateComputedData(id, { module });
|
|
1310
|
+
}
|
|
1311
|
+
updateNodeData(id, { intervalStart, intervalEnd });
|
|
1312
|
+
}, [incoming, intervalStart, intervalEnd]);
|
|
1313
|
+
return /* @__PURE__ */ jsxs5(NodeContainer7, { id, selected, data, type, children: [
|
|
1314
|
+
/* @__PURE__ */ jsx7(Stack3, { children: /* @__PURE__ */ jsxs5(Group4, { children: [
|
|
1315
|
+
/* @__PURE__ */ jsx7(
|
|
1316
|
+
NumberInput4,
|
|
1317
|
+
{
|
|
1318
|
+
size: "xs",
|
|
1319
|
+
w: 100,
|
|
1320
|
+
value: intervalStart,
|
|
1321
|
+
onChange: (e) => setIntervalStart(Number(e))
|
|
1322
|
+
}
|
|
1323
|
+
),
|
|
1324
|
+
/* @__PURE__ */ jsx7(
|
|
1325
|
+
NumberInput4,
|
|
1326
|
+
{
|
|
1327
|
+
size: "xs",
|
|
1328
|
+
w: 100,
|
|
1329
|
+
value: intervalEnd,
|
|
1330
|
+
onChange: (e) => setIntervalEnd(Number(e))
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1333
|
+
] }) }),
|
|
1334
|
+
/* @__PURE__ */ jsx7(NodeTrackConnections7, { handles: data.handles, nodeId: id, type: "target" })
|
|
1335
|
+
] });
|
|
1336
|
+
}
|
|
1337
|
+
var noise_normalize_node_default = NoiseNormalizeNode;
|
|
1338
|
+
|
|
1339
|
+
// src/nodes/modifiers/noise-scale-bias-node.tsx
|
|
1340
|
+
import { NodeContainer as NodeContainer8, NodeTrackConnections as NodeTrackConnections8 } from "@awesome-flow/core/layout";
|
|
1341
|
+
import { useEffect as useEffect10, useState as useState9 } from "react";
|
|
1342
|
+
import { Group as Group5, NumberInput as NumberInput5, Stack as Stack4 } from "@mantine/core";
|
|
1343
|
+
import {
|
|
1344
|
+
useIncomingComputedData as useIncomingComputedData8,
|
|
1345
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData8,
|
|
1346
|
+
useUpdateNodeData as useUpdateNodeData6
|
|
1347
|
+
} from "@awesome-flow/core/hooks";
|
|
1348
|
+
import { ScaleBias } from "libnoise-ts/module/modifier";
|
|
1349
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1350
|
+
function NoiseScaleBiasNode({ id, selected, data, type }) {
|
|
1351
|
+
const [scale, setScale] = useState9(data.scale);
|
|
1352
|
+
const [bias, setBias] = useState9(data.bias);
|
|
1353
|
+
const incoming = useIncomingComputedData8(id);
|
|
1354
|
+
const updateNodeData = useUpdateNodeData6();
|
|
1355
|
+
const updateComputedData = useUpdateNodeComputedData8();
|
|
1356
|
+
useEffect10(() => {
|
|
1357
|
+
if (incoming?.length > 0) {
|
|
1358
|
+
const module = new ScaleBias(incoming[0].module, scale, bias);
|
|
1359
|
+
updateComputedData(id, { module });
|
|
1360
|
+
}
|
|
1361
|
+
updateNodeData(id, { scale, bias });
|
|
1362
|
+
}, [incoming, scale, bias]);
|
|
1363
|
+
return /* @__PURE__ */ jsxs6(NodeContainer8, { id, selected, data, type, children: [
|
|
1364
|
+
/* @__PURE__ */ jsxs6(Stack4, { children: [
|
|
1365
|
+
/* @__PURE__ */ jsxs6(Group5, { children: [
|
|
1366
|
+
"Scale:",
|
|
1367
|
+
/* @__PURE__ */ jsx8(
|
|
1368
|
+
NumberInput5,
|
|
1369
|
+
{
|
|
1370
|
+
size: "xs",
|
|
1371
|
+
w: 100,
|
|
1372
|
+
value: scale,
|
|
1373
|
+
onChange: (e) => setScale(Number(e)),
|
|
1374
|
+
step: 0.1
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] }),
|
|
1378
|
+
/* @__PURE__ */ jsxs6(Group5, { children: [
|
|
1379
|
+
"Bias:",
|
|
1380
|
+
/* @__PURE__ */ jsx8(
|
|
1381
|
+
NumberInput5,
|
|
1382
|
+
{
|
|
1383
|
+
size: "xs",
|
|
1384
|
+
w: 100,
|
|
1385
|
+
value: bias,
|
|
1386
|
+
onChange: (e) => setBias(Number(e)),
|
|
1387
|
+
step: 0.1
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1390
|
+
] })
|
|
1391
|
+
] }),
|
|
1392
|
+
/* @__PURE__ */ jsx8(NodeTrackConnections8, { handles: data.handles, nodeId: id, type: "target" })
|
|
1393
|
+
] });
|
|
1394
|
+
}
|
|
1395
|
+
var noise_scale_bias_node_default = NoiseScaleBiasNode;
|
|
1396
|
+
|
|
1397
|
+
// src/nodes/modifiers/noise-terrace-node.tsx
|
|
1398
|
+
import { NodeContainer as NodeContainer9, NodeTrackConnections as NodeTrackConnections9 } from "@awesome-flow/core/layout";
|
|
1399
|
+
import { ActionIcon as ActionIcon2, Button as Button2, Group as Group6, NumberInput as NumberInput6, Space as Space2 } from "@mantine/core";
|
|
1400
|
+
import {
|
|
1401
|
+
useIncomingComputedData as useIncomingComputedData9,
|
|
1402
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData9,
|
|
1403
|
+
useUpdateNodeData as useUpdateNodeData7
|
|
1404
|
+
} from "@awesome-flow/core/hooks";
|
|
1405
|
+
import { useCallback as useCallback9, useEffect as useEffect11, useState as useState10 } from "react";
|
|
1406
|
+
import { Terrace } from "libnoise-ts/module/modifier";
|
|
1407
|
+
import { IconX as IconX2 } from "@tabler/icons-react";
|
|
1408
|
+
import { randomId as randomId2 } from "@mantine/hooks";
|
|
1409
|
+
import { NodeState as NodeState2 } from "@awesome-flow/core/abstract";
|
|
1410
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1411
|
+
function NoiseTerraceNode({ id, selected, data, type }) {
|
|
1412
|
+
const incoming = useIncomingComputedData9(id);
|
|
1413
|
+
const updateNodeData = useUpdateNodeData7();
|
|
1414
|
+
const updateComputedData = useUpdateNodeComputedData9();
|
|
1415
|
+
const [values, setValues] = useState10([]);
|
|
1416
|
+
const form = useForm({
|
|
1417
|
+
mode: "uncontrolled",
|
|
1418
|
+
initialValues: {
|
|
1419
|
+
points: []
|
|
1420
|
+
},
|
|
1421
|
+
validateInputOnChange: [`points.${FORM_INDEX}.input`],
|
|
1422
|
+
clearInputErrorOnChange: true,
|
|
1423
|
+
onValuesChange: useCallback9((values2) => {
|
|
1424
|
+
if (form.isValid()) {
|
|
1425
|
+
const points = values2.points.map((v) => v.value);
|
|
1426
|
+
setValues(points);
|
|
1427
|
+
updateNodeData(id, { points });
|
|
1428
|
+
}
|
|
1429
|
+
form.validate();
|
|
1430
|
+
}, [])
|
|
1431
|
+
});
|
|
1432
|
+
useEffect11(() => {
|
|
1433
|
+
const points = data.points?.length ? data.points.map((v) => ({ value: v, key: randomId2() })) : [1, 2].map(() => ({ value: 0, key: randomId2() }));
|
|
1434
|
+
form.initialize({ points });
|
|
1435
|
+
}, []);
|
|
1436
|
+
useEffect11(() => {
|
|
1437
|
+
if (incoming?.length && values?.length >= 2) {
|
|
1438
|
+
const module = new Terrace(incoming[0].module, values);
|
|
1439
|
+
updateComputedData(id, { module });
|
|
1440
|
+
}
|
|
1441
|
+
}, [values, incoming]);
|
|
1442
|
+
const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs7(Group6, { mt: "xs", children: [
|
|
1443
|
+
/* @__PURE__ */ jsx9(
|
|
1444
|
+
NumberInput6,
|
|
1445
|
+
{
|
|
1446
|
+
size: "xs",
|
|
1447
|
+
placeholder: "Input Value",
|
|
1448
|
+
...form.getInputProps(`points.${index}.value`),
|
|
1449
|
+
step: 0.1
|
|
1450
|
+
},
|
|
1451
|
+
form.key(`points.${index}.value`)
|
|
1452
|
+
),
|
|
1453
|
+
data.state === NodeState2.edit && values.length > 2 && /* @__PURE__ */ jsx9(
|
|
1454
|
+
ActionIcon2,
|
|
1455
|
+
{
|
|
1456
|
+
color: "red",
|
|
1457
|
+
variant: "outline",
|
|
1458
|
+
size: "sm",
|
|
1459
|
+
onClick: () => form.removeListItem("points", index),
|
|
1460
|
+
children: /* @__PURE__ */ jsx9(IconX2, { size: "1rem" })
|
|
1461
|
+
}
|
|
1462
|
+
)
|
|
1463
|
+
] }, item.key));
|
|
1464
|
+
return /* @__PURE__ */ jsxs7(NodeContainer9, { id, selected, type, data, children: [
|
|
1465
|
+
fields,
|
|
1466
|
+
data.state === NodeState2.edit && /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1467
|
+
/* @__PURE__ */ jsx9(Space2, { h: 10 }),
|
|
1468
|
+
/* @__PURE__ */ jsx9(
|
|
1469
|
+
Button2,
|
|
1470
|
+
{
|
|
1471
|
+
variant: "outline",
|
|
1472
|
+
size: "xs",
|
|
1473
|
+
fullWidth: true,
|
|
1474
|
+
onClick: () => form.insertListItem("points", { value: 0, key: randomId2() }),
|
|
1475
|
+
children: "Add control point"
|
|
1476
|
+
}
|
|
1477
|
+
)
|
|
1478
|
+
] }),
|
|
1479
|
+
/* @__PURE__ */ jsx9(NodeTrackConnections9, { handles: data.handles, nodeId: id, type: "target" })
|
|
1480
|
+
] });
|
|
1481
|
+
}
|
|
1482
|
+
var noise_terrace_node_default = NoiseTerraceNode;
|
|
1483
|
+
|
|
1484
|
+
// src/nodes/modifiers/variable-combine-node.tsx
|
|
1485
|
+
import { NodeCombobox as NodeCombobox2, NodeContainer as NodeContainer10, NodeTrackConnections as NodeTrackConnections10 } from "@awesome-flow/core/layout";
|
|
1486
|
+
import { useCallback as useCallback11, useEffect as useEffect13, useState as useState12 } from "react";
|
|
1487
|
+
import { useIncomingNodeData as useIncomingNodeData2, useUpdateNodeData as useUpdateNodeData9 } from "@awesome-flow/core/hooks";
|
|
1488
|
+
import {
|
|
1489
|
+
IconAsterisk as IconAsterisk2,
|
|
1490
|
+
IconChevronLeft as IconChevronLeft2,
|
|
1491
|
+
IconChevronRight as IconChevronRight2,
|
|
1492
|
+
IconChevronUp as IconChevronUp2,
|
|
1493
|
+
IconDivide,
|
|
1494
|
+
IconPlus as IconPlus2
|
|
1495
|
+
} from "@tabler/icons-react";
|
|
1496
|
+
|
|
1497
|
+
// src/layout/node-value-input.tsx
|
|
1498
|
+
import { Input, NumberInput as NumberInput7, Switch } from "@mantine/core";
|
|
1499
|
+
import { Fragment as Fragment3, jsx as jsx10 } from "react/jsx-runtime";
|
|
1500
|
+
function NodeValueInput({ value, disabled, step, onChange }) {
|
|
1501
|
+
if (value === void 0 || value === null) {
|
|
1502
|
+
return /* @__PURE__ */ jsx10(Fragment3, {});
|
|
1503
|
+
}
|
|
1504
|
+
switch (typeof value) {
|
|
1505
|
+
case "boolean": {
|
|
1506
|
+
return /* @__PURE__ */ jsx10(
|
|
1507
|
+
Switch,
|
|
1508
|
+
{
|
|
1509
|
+
checked: value,
|
|
1510
|
+
disabled,
|
|
1511
|
+
onChange: (e) => onChange(e.currentTarget.checked)
|
|
1512
|
+
}
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
case "number": {
|
|
1516
|
+
return /* @__PURE__ */ jsx10(NumberInput7, { value, disabled, step, onChange: (e) => onChange(e) });
|
|
1517
|
+
}
|
|
1518
|
+
case "string": {
|
|
1519
|
+
return /* @__PURE__ */ jsx10(
|
|
1520
|
+
Input,
|
|
1521
|
+
{
|
|
1522
|
+
value,
|
|
1523
|
+
disabled,
|
|
1524
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
1525
|
+
}
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1528
|
+
default:
|
|
1529
|
+
throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
var node_value_input_default = NodeValueInput;
|
|
1533
|
+
|
|
1534
|
+
// src/layout/node-property-input.tsx
|
|
1535
|
+
import { Fragment as Fragment4, jsx as jsx11 } from "react/jsx-runtime";
|
|
1536
|
+
|
|
1537
|
+
// src/layout/node-property-variables.tsx
|
|
1538
|
+
import { useIncomingNodeData, useUpdateNodeData as useUpdateNodeData8 } from "@awesome-flow/core/hooks";
|
|
1539
|
+
import { useCallback as useCallback10, useEffect as useEffect12, useMemo, useState as useState11 } from "react";
|
|
1540
|
+
import { Group as Group7, Stack as Stack5 } from "@mantine/core";
|
|
1541
|
+
import { getObjectKeys } from "@awesome-flow/core/utils";
|
|
1542
|
+
import { nodeDataPropertyExcept } from "@awesome-flow/core/abstract";
|
|
1543
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1544
|
+
|
|
1545
|
+
// src/nodes/modifiers/variable-combine-node.tsx
|
|
1546
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1547
|
+
var options2 = {
|
|
1548
|
+
add: /* @__PURE__ */ jsx13(IconPlus2, {}),
|
|
1549
|
+
divide: /* @__PURE__ */ jsx13(IconDivide, {}),
|
|
1550
|
+
min: /* @__PURE__ */ jsx13(IconChevronLeft2, {}),
|
|
1551
|
+
max: /* @__PURE__ */ jsx13(IconChevronRight2, {}),
|
|
1552
|
+
multiply: /* @__PURE__ */ jsx13(IconAsterisk2, {}),
|
|
1553
|
+
power: /* @__PURE__ */ jsx13(IconChevronUp2, {})
|
|
1554
|
+
};
|
|
1555
|
+
function VariableCombineNode({
|
|
1556
|
+
id,
|
|
1557
|
+
selected,
|
|
1558
|
+
data,
|
|
1559
|
+
type
|
|
1560
|
+
}) {
|
|
1561
|
+
const [operation, setOperation] = useState12(data.operation);
|
|
1562
|
+
const [value, setValue] = useState12(data.value);
|
|
1563
|
+
const updateNodeData = useUpdateNodeData9();
|
|
1564
|
+
const incoming = useIncomingNodeData2(id);
|
|
1565
|
+
useEffect13(() => {
|
|
1566
|
+
if (incoming?.length > 1) {
|
|
1567
|
+
const result = getOperationResult(operation, incoming[0].value, incoming[1].value);
|
|
1568
|
+
setValue(result);
|
|
1569
|
+
updateNodeData(id, { value: result });
|
|
1570
|
+
}
|
|
1571
|
+
}, [operation, incoming]);
|
|
1572
|
+
const onChange = useCallback11((op) => {
|
|
1573
|
+
updateNodeData(id, { operation: op });
|
|
1574
|
+
setOperation(op);
|
|
1575
|
+
}, []);
|
|
1576
|
+
return /* @__PURE__ */ jsxs9(NodeContainer10, { id, selected, data, type, children: [
|
|
1577
|
+
/* @__PURE__ */ jsx13(NodeCombobox2, { options: options2, selected: operation, onChange }),
|
|
1578
|
+
/* @__PURE__ */ jsx13(node_value_input_default, { value, onChange: () => {
|
|
1579
|
+
}, disabled: true }),
|
|
1580
|
+
/* @__PURE__ */ jsx13(NodeTrackConnections10, { handles: data.handles, nodeId: id, type: "target" })
|
|
1581
|
+
] });
|
|
1582
|
+
}
|
|
1583
|
+
function getOperationResult(operation, value1, value2) {
|
|
1584
|
+
switch (operation) {
|
|
1585
|
+
case "add" /* add */:
|
|
1586
|
+
return Number(value1) + Number(value2);
|
|
1587
|
+
case "divide" /* divide */:
|
|
1588
|
+
return Number(value1) / (Number(value2) || 1);
|
|
1589
|
+
case "max" /* max */:
|
|
1590
|
+
return Number(value1) > Number(value2) ? value1 : value2;
|
|
1591
|
+
case "min" /* min */:
|
|
1592
|
+
return Number(value1) < Number(value2) ? value1 : value2;
|
|
1593
|
+
case "multiply" /* multiply */:
|
|
1594
|
+
return Number(value1) * Number(value2);
|
|
1595
|
+
case "power" /* power */:
|
|
1596
|
+
return Number(value1) ** Number(value2);
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
var variable_combine_node_default = VariableCombineNode;
|
|
1600
|
+
export {
|
|
1601
|
+
noise_abs_node_default as NoiseAbsNode,
|
|
1602
|
+
noise_clamp_node_default as NoiseClampNode,
|
|
1603
|
+
noise_combine_node_default as NoiseCombineNode,
|
|
1604
|
+
noise_curve_node_default as NoiseCurveNode,
|
|
1605
|
+
noise_exponent_node_default as NoiseExponentNode,
|
|
1606
|
+
noise_invert_node_default as NoiseInvertNode,
|
|
1607
|
+
noise_normalize_node_default as NoiseNormalizeNode,
|
|
1608
|
+
noise_scale_bias_node_default as NoiseScaleBiasNode,
|
|
1609
|
+
noise_terrace_node_default as NoiseTerraceNode,
|
|
1610
|
+
variable_combine_node_default as VariableCombineNode
|
|
1611
|
+
};
|
|
1612
|
+
//# sourceMappingURL=index.js.map
|