@bitflow/core 0.6.0 → 0.7.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/index.cjs.js DELETED
@@ -1,725 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __export = (target, all) => {
25
- for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
-
39
- // src/index.ts
40
- var src_exports = {};
41
- __export(src_exports, {
42
- AndConditionSchema: () => AndConditionSchema,
43
- ConditionSchema: () => ConditionSchema,
44
- ControlFlowNodeSchema: () => ControlFlowNodeSchema,
45
- EndSchema: () => EndSchema,
46
- EqualConditionSchema: () => EqualConditionSchema,
47
- FeedbackMessageSchema: () => FeedbackMessageSchema,
48
- FlowCheckpointNodeSchema: () => FlowCheckpointNodeSchema,
49
- FlowEdgeSchema: () => FlowEdgeSchema,
50
- FlowPortalInputNodeSchema: () => FlowPortalInputNodeSchema,
51
- FlowPortalOutputNodeSchema: () => FlowPortalOutputNodeSchema,
52
- FlowSplitAnswerNodeSchema: () => FlowSplitAnswerNodeSchema,
53
- FlowSplitPointsNodeSchema: () => FlowSplitPointsNodeSchema,
54
- FlowSplitRandomNodeSchema: () => FlowSplitRandomNodeSchema,
55
- FlowSplitResultNodeSchema: () => FlowSplitResultNodeSchema,
56
- FlowSynchronizeNodeSchema: () => FlowSynchronizeNodeSchema,
57
- GreaterConditionSchema: () => GreaterConditionSchema,
58
- InConditionSchema: () => InConditionSchema,
59
- InputSchema: () => InputSchema,
60
- LessConditionSchema: () => LessConditionSchema,
61
- OrConditionSchema: () => OrConditionSchema,
62
- PortalInputSchema: () => PortalInputSchema,
63
- PortalOutputSchema: () => PortalOutputSchema,
64
- PrimitiveConditionSchema: () => PrimitiveConditionSchema,
65
- SplitAnswerSchema: () => SplitAnswerSchema,
66
- SplitPointsSchema: () => SplitPointsSchema,
67
- SplitResultSchema: () => SplitResultSchema,
68
- StartSchema: () => StartSchema,
69
- TaskAnswerSchema: () => TaskAnswerSchema,
70
- TaskResultSchema: () => TaskResultSchema,
71
- TaskSchema: () => TaskSchema,
72
- TaskStatisticSchema: () => TaskStatisticSchema,
73
- TitleSchema: () => TitleSchema,
74
- TrueConditionSchema: () => TrueConditionSchema,
75
- extractInteractiveFlowPublicNode: () => extractInteractiveFlowPublicNode,
76
- findLast: () => findLast,
77
- finishDoTry: () => finishDoTry,
78
- groupBy: () => groupBy,
79
- isControlFlowNode: () => isControlFlowNode,
80
- isDoFinishedTry: () => isDoFinishedTry,
81
- isDoSkippedTry: () => isDoSkippedTry,
82
- isDoStartedTry: () => isDoStartedTry,
83
- isFlowEndNode: () => isFlowEndNode,
84
- isFlowInputNode: () => isFlowInputNode,
85
- isFlowPortalInputNode: () => isFlowPortalInputNode,
86
- isFlowPortalOutputNode: () => isFlowPortalOutputNode,
87
- isFlowSplitAnswerNode: () => isFlowSplitAnswerNode,
88
- isFlowSplitPointsNode: () => isFlowSplitPointsNode,
89
- isFlowSplitRandomNode: () => isFlowSplitRandomNode,
90
- isFlowSplitResultNode: () => isFlowSplitResultNode,
91
- isFlowStartNode: () => isFlowStartNode,
92
- isFlowTaskNode: () => isFlowTaskNode,
93
- isFlowTitleNode: () => isFlowTitleNode,
94
- isInteractiveFlowNode: () => isInteractiveFlowNode,
95
- lerpColor: () => lerpColor,
96
- levenshtein: () => levenshtein,
97
- makeDoBaseTrySchema: () => makeDoBaseTrySchema,
98
- makeDoFinishedTry: () => makeDoFinishedTry,
99
- makeDoSkippedTry: () => makeDoSkippedTry,
100
- makeDoStartedTry: () => makeDoStartedTry,
101
- makeEvaluate: () => makeEvaluate,
102
- makeFlowEndNodeSchema: () => makeFlowEndNodeSchema,
103
- makeFlowInputNodeSchema: () => makeFlowInputNodeSchema,
104
- makeFlowNodeSchema: () => makeFlowNodeSchema,
105
- makeFlowSchema: () => makeFlowSchema,
106
- makeFlowStartNodeSchema: () => makeFlowStartNodeSchema,
107
- makeFlowTaskNodeSchema: () => makeFlowTaskNodeSchema,
108
- makeFlowTitleNodeSchema: () => makeFlowTitleNodeSchema,
109
- makeInteractiveFlowNodeSchema: () => makeInteractiveFlowNodeSchema,
110
- retryDoTry: () => retryDoTry,
111
- skipDoTry: () => skipDoTry,
112
- uuidv4: () => uuidv4
113
- });
114
- module.exports = __toCommonJS(src_exports);
115
-
116
- // ../../scripts/emotion-shim.js
117
- var import_react = require("@emotion/react");
118
-
119
- // src/bits.ts
120
- var makeEvaluate = (evaluateMap) => ({ task, answer }) => {
121
- const subtype = task.subtype;
122
- const evaluate = evaluateMap[subtype];
123
- if (!evaluate) {
124
- throw new Error("subtype not supported");
125
- }
126
- return evaluate({ answer, task });
127
- };
128
-
129
- // src/bitsSchema.ts
130
- var z = __toESM(require("zod"));
131
- var FeedbackMessageSchema = z.object({
132
- message: z.string(),
133
- severity: z.enum(["error", "warning", "info", "success"])
134
- });
135
- var TaskSchema = z.object({
136
- name: z.string(),
137
- description: z.string().optional(),
138
- subtype: z.string(),
139
- view: z.record(z.any()),
140
- evaluation: z.object({
141
- mode: z.enum(["auto", "skip", "manual"]),
142
- enableRetry: z.boolean(),
143
- showFeedback: z.boolean()
144
- }),
145
- feedback: z.record(z.any()).optional()
146
- });
147
- var TaskStatisticSchema = z.object({
148
- subtype: z.string(),
149
- count: z.number()
150
- });
151
- var TaskAnswerSchema = z.object({
152
- subtype: z.string()
153
- });
154
- var TaskResultSchema = z.object({
155
- subtype: z.string(),
156
- state: z.enum(["unknown", "manual", "correct", "wrong"]),
157
- allowRetry: z.boolean().optional(),
158
- feedback: z.any()
159
- });
160
- var InputSchema = z.object({
161
- name: z.string(),
162
- description: z.string(),
163
- subtype: z.string(),
164
- view: z.object({})
165
- });
166
- var TitleSchema = z.object({
167
- name: z.string(),
168
- description: z.string(),
169
- subtype: z.string(),
170
- view: z.object({})
171
- });
172
- var StartSchema = z.object({
173
- name: z.string(),
174
- description: z.string(),
175
- subtype: z.string(),
176
- view: z.object({})
177
- });
178
- var EndSchema = z.object({
179
- name: z.string(),
180
- description: z.string(),
181
- subtype: z.string(),
182
- view: z.object({})
183
- });
184
-
185
- // src/do.ts
186
- var isDoStartedTry = (d) => {
187
- return d.status === "started";
188
- };
189
- var isDoFinishedTry = (d) => {
190
- return d.status === "finished";
191
- };
192
- var isDoSkippedTry = (d) => {
193
- return d.status === "skipped";
194
- };
195
- var skipDoTry = (doResult, evaluation = { mode: "skip" }) => {
196
- const { tries } = doResult;
197
- let { maxPoints } = doResult;
198
- const currentTry = tries[tries.length - 1];
199
- const hasTry = tries.find((doTry) => doTry.node.id === currentTry.node.id && doTry.status !== "started");
200
- if (!hasTry && (evaluation == null ? void 0 : evaluation.mode) !== "skip") {
201
- maxPoints += 1;
202
- }
203
- tries[tries.length - 1] = __spreadProps(__spreadValues({}, currentTry), {
204
- evaluation,
205
- status: "skipped",
206
- endDate: new Date()
207
- });
208
- return __spreadProps(__spreadValues({}, doResult), {
209
- maxPoints,
210
- tries
211
- });
212
- };
213
- var finishDoTry = (doResult, answer, result) => {
214
- var _a, _b;
215
- const { tries } = doResult;
216
- let { points, maxPoints } = doResult;
217
- const currentTry = tries[tries.length - 1];
218
- const hasTry = tries.find((doTry) => doTry.node.id === currentTry.node.id && doTry.status !== "started");
219
- if (!hasTry && (result == null ? void 0 : result.state) !== "unknown") {
220
- maxPoints += 1;
221
- }
222
- tries[tries.length - 1] = __spreadProps(__spreadValues({}, currentTry), {
223
- status: "finished",
224
- endDate: new Date(),
225
- answer,
226
- result
227
- });
228
- const lastTry = tries.filter(isDoFinishedTry).find((doTry) => doTry.node.id === currentTry.node.id && currentTry.try - 1 === doTry.try);
229
- if (!lastTry && (result == null ? void 0 : result.state) === "correct") {
230
- points += 1;
231
- } else if (((_a = lastTry == null ? void 0 : lastTry.result) == null ? void 0 : _a.state) === "correct" && (result == null ? void 0 : result.state) !== "correct") {
232
- points -= 1;
233
- } else if (((_b = lastTry == null ? void 0 : lastTry.result) == null ? void 0 : _b.state) !== "correct" && (result == null ? void 0 : result.state) === "correct") {
234
- points += 1;
235
- }
236
- return __spreadProps(__spreadValues({}, doResult), {
237
- maxPoints,
238
- points,
239
- tries
240
- });
241
- };
242
- var retryDoTry = (doResult) => {
243
- const { tries } = doResult;
244
- const lastTry = tries[tries.length - 1];
245
- tries.push({
246
- status: "started",
247
- try: lastTry.try + 1,
248
- startDate: new Date(),
249
- node: __spreadValues({}, lastTry.node)
250
- });
251
- return __spreadProps(__spreadValues({}, doResult), { tries });
252
- };
253
-
254
- // src/doSchema.ts
255
- var import_zod2 = require("zod");
256
-
257
- // src/flowSchema.ts
258
- var import_zod = require("zod");
259
- var NodeBaseSchema = import_zod.z.object({
260
- id: import_zod.z.string(),
261
- position: import_zod.z.object({
262
- x: import_zod.z.number(),
263
- y: import_zod.z.number()
264
- })
265
- });
266
- var FlowCheckpointNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
267
- type: import_zod.z.literal("checkpoint")
268
- }));
269
- var FlowSynchronizeNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
270
- type: import_zod.z.literal("synchronize"),
271
- data: import_zod.z.object({
272
- unlocked: import_zod.z.boolean()
273
- })
274
- }));
275
- var makeFlowTaskNodeSchema = (task) => NodeBaseSchema.merge(import_zod.z.object({
276
- type: import_zod.z.literal("task"),
277
- data: task
278
- }));
279
- var makeFlowStartNodeSchema = (start) => NodeBaseSchema.merge(import_zod.z.object({
280
- type: import_zod.z.literal("start"),
281
- data: start
282
- }));
283
- var makeFlowEndNodeSchema = (end) => NodeBaseSchema.merge(import_zod.z.object({
284
- type: import_zod.z.literal("end"),
285
- data: end
286
- }));
287
- var makeFlowInputNodeSchema = (input) => NodeBaseSchema.merge(import_zod.z.object({
288
- type: import_zod.z.literal("input"),
289
- data: input
290
- }));
291
- var makeFlowTitleNodeSchema = (title) => NodeBaseSchema.merge(import_zod.z.object({
292
- type: import_zod.z.literal("title"),
293
- data: title
294
- }));
295
- var EqualConditionSchema = import_zod.z.object({
296
- type: import_zod.z.literal("equal"),
297
- not: import_zod.z.boolean(),
298
- nodeId: import_zod.z.string(),
299
- key: import_zod.z.string(),
300
- value: import_zod.z.union([import_zod.z.string(), import_zod.z.number()])
301
- });
302
- var TrueConditionSchema = import_zod.z.object({
303
- type: import_zod.z.literal("true"),
304
- not: import_zod.z.boolean(),
305
- nodeId: import_zod.z.string(),
306
- key: import_zod.z.string()
307
- });
308
- var GreaterConditionSchema = import_zod.z.object({
309
- type: import_zod.z.literal("greater"),
310
- include: import_zod.z.boolean(),
311
- not: import_zod.z.boolean(),
312
- nodeId: import_zod.z.string(),
313
- key: import_zod.z.string(),
314
- value: import_zod.z.number()
315
- });
316
- var LessConditionSchema = import_zod.z.object({
317
- type: import_zod.z.literal("less"),
318
- include: import_zod.z.boolean(),
319
- not: import_zod.z.boolean(),
320
- nodeId: import_zod.z.string(),
321
- key: import_zod.z.string(),
322
- value: import_zod.z.number()
323
- });
324
- var InConditionSchema = import_zod.z.object({
325
- type: import_zod.z.literal("in"),
326
- not: import_zod.z.boolean(),
327
- nodeId: import_zod.z.string(),
328
- key: import_zod.z.string(),
329
- value: import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number()]))
330
- });
331
- var PrimitiveConditionSchema = import_zod.z.union([
332
- EqualConditionSchema,
333
- TrueConditionSchema,
334
- GreaterConditionSchema,
335
- LessConditionSchema,
336
- InConditionSchema
337
- ]);
338
- var AndConditionSchema = import_zod.z.object({
339
- type: import_zod.z.literal("and"),
340
- conditions: import_zod.z.array(PrimitiveConditionSchema)
341
- });
342
- var OrConditionSchema = import_zod.z.object({
343
- type: import_zod.z.literal("or"),
344
- conditions: import_zod.z.array(PrimitiveConditionSchema)
345
- });
346
- var ConditionSchema = import_zod.z.union([
347
- PrimitiveConditionSchema,
348
- AndConditionSchema,
349
- OrConditionSchema
350
- ]);
351
- var SplitAnswerSchema = import_zod.z.object({
352
- condition: ConditionSchema
353
- });
354
- var FlowSplitAnswerNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
355
- type: import_zod.z.literal("split-answer"),
356
- data: SplitAnswerSchema
357
- }));
358
- var SplitResultSchema = import_zod.z.object({
359
- condition: ConditionSchema
360
- });
361
- var FlowSplitResultNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
362
- type: import_zod.z.literal("split-result"),
363
- data: SplitResultSchema
364
- }));
365
- var SplitPointsSchema = import_zod.z.object({
366
- points: import_zod.z.number()
367
- });
368
- var FlowSplitPointsNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
369
- type: import_zod.z.literal("split-points"),
370
- data: SplitPointsSchema
371
- }));
372
- var PortalInputSchema = import_zod.z.object({
373
- portal: import_zod.z.string(),
374
- description: import_zod.z.string()
375
- });
376
- var PortalOutputSchema = import_zod.z.object({
377
- portal: import_zod.z.string(),
378
- description: import_zod.z.string()
379
- });
380
- var FlowPortalInputNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
381
- type: import_zod.z.literal("portal-input"),
382
- data: PortalInputSchema
383
- }));
384
- var FlowPortalOutputNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
385
- type: import_zod.z.literal("portal-output"),
386
- data: PortalOutputSchema
387
- }));
388
- var FlowSplitRandomNodeSchema = NodeBaseSchema.merge(import_zod.z.object({
389
- type: import_zod.z.literal("split-random")
390
- }));
391
- var ControlFlowNodeSchema = import_zod.z.union([
392
- FlowSplitAnswerNodeSchema,
393
- FlowSplitResultNodeSchema,
394
- FlowSplitPointsNodeSchema,
395
- FlowSplitRandomNodeSchema,
396
- FlowPortalInputNodeSchema,
397
- FlowPortalOutputNodeSchema
398
- ]);
399
- var makeInteractiveFlowNodeSchema = ({
400
- start,
401
- end,
402
- input,
403
- title,
404
- task
405
- }) => import_zod.z.union([
406
- makeFlowStartNodeSchema(start),
407
- makeFlowEndNodeSchema(end),
408
- makeFlowInputNodeSchema(input),
409
- makeFlowTaskNodeSchema(task),
410
- makeFlowTitleNodeSchema(title),
411
- FlowSynchronizeNodeSchema,
412
- FlowCheckpointNodeSchema
413
- ]);
414
- var FlowEdgeSchema = import_zod.z.object({
415
- id: import_zod.z.string(),
416
- source: import_zod.z.string(),
417
- sourceHandle: import_zod.z.union([
418
- import_zod.z.literal("a"),
419
- import_zod.z.literal("b"),
420
- import_zod.z.literal("c"),
421
- import_zod.z.literal("d"),
422
- import_zod.z.literal("e"),
423
- import_zod.z.literal("f")
424
- ]).optional(),
425
- target: import_zod.z.string()
426
- });
427
- var makeFlowNodeSchema = ({
428
- end,
429
- input,
430
- start,
431
- task,
432
- title
433
- }) => import_zod.z.union([
434
- FlowSplitAnswerNodeSchema,
435
- FlowSplitResultNodeSchema,
436
- FlowSplitPointsNodeSchema,
437
- FlowSplitRandomNodeSchema,
438
- FlowPortalInputNodeSchema,
439
- FlowPortalOutputNodeSchema,
440
- FlowSynchronizeNodeSchema,
441
- FlowCheckpointNodeSchema,
442
- makeFlowEndNodeSchema(end),
443
- makeFlowInputNodeSchema(input),
444
- makeFlowStartNodeSchema(start),
445
- makeFlowTaskNodeSchema(task),
446
- makeFlowTitleNodeSchema(title)
447
- ]);
448
- var makeFlowSchema = ({
449
- end,
450
- input,
451
- start,
452
- task,
453
- title
454
- }) => import_zod.z.object({
455
- name: import_zod.z.string(),
456
- description: import_zod.z.string(),
457
- language: import_zod.z.enum(["en", "de", "fr", "es", "nl", "pt", "tr", "it"]),
458
- visibility: import_zod.z.enum(["public", "private", "unlisted"]),
459
- draft: import_zod.z.boolean(),
460
- nodes: import_zod.z.array(makeFlowNodeSchema({ start, end, input, title, task })),
461
- edges: import_zod.z.array(FlowEdgeSchema),
462
- zoom: import_zod.z.number().positive().default(1),
463
- position: import_zod.z.tuple([import_zod.z.number(), import_zod.z.number()]).default([0, 0])
464
- }).refine((data) => {
465
- const ids = data.nodes.map((n) => n.id);
466
- for (let edge of data.edges) {
467
- if (!ids.includes(edge.source) || !ids.includes(edge.target)) {
468
- return false;
469
- }
470
- }
471
- return true;
472
- }, { message: "Target and source of an edge need to be valid node ids." });
473
-
474
- // src/doSchema.ts
475
- var makeDoBaseTrySchema = (flowNodeSchemas) => import_zod2.z.object({
476
- node: makeInteractiveFlowNodeSchema(flowNodeSchemas),
477
- startDate: import_zod2.z.date(),
478
- try: import_zod2.z.number(),
479
- status: import_zod2.z.string()
480
- });
481
- var makeDoStartedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(import_zod2.z.object({
482
- status: import_zod2.z.literal("started")
483
- }));
484
- var makeDoFinishedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(import_zod2.z.object({
485
- status: import_zod2.z.literal("finished"),
486
- endDate: import_zod2.z.date(),
487
- answer: TaskAnswerSchema.optional(),
488
- result: TaskResultSchema.optional()
489
- }));
490
- var makeDoSkippedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(import_zod2.z.object({
491
- status: import_zod2.z.literal("skipped"),
492
- endDate: import_zod2.z.date()
493
- }));
494
-
495
- // src/findLast.ts
496
- function findLast(array, predicate) {
497
- let l = array.length;
498
- while (l--) {
499
- if (predicate(array[l], l, array))
500
- return array[l];
501
- }
502
- return null;
503
- }
504
-
505
- // src/flow.ts
506
- var isFlowTaskNode = (n) => {
507
- if (n.type === "task") {
508
- return true;
509
- }
510
- return false;
511
- };
512
- var isFlowStartNode = (n) => {
513
- if (n.type === "start") {
514
- return true;
515
- }
516
- return false;
517
- };
518
- var isFlowEndNode = (n) => {
519
- if (n.type === "end") {
520
- return true;
521
- }
522
- return false;
523
- };
524
- var isFlowInputNode = (n) => {
525
- if (n.type === "input") {
526
- return true;
527
- }
528
- return false;
529
- };
530
- var isFlowTitleNode = (n) => {
531
- if (n.type === "title") {
532
- return true;
533
- }
534
- return false;
535
- };
536
- var isFlowSplitAnswerNode = (n) => {
537
- return n.type === "split-answer";
538
- };
539
- var isFlowSplitResultNode = (n) => {
540
- return n.type === "split-result";
541
- };
542
- var isFlowSplitPointsNode = (n) => {
543
- return n.type === "split-points";
544
- };
545
- var isFlowPortalInputNode = (n) => {
546
- return n.type === "portal-input";
547
- };
548
- var isFlowPortalOutputNode = (n) => {
549
- return n.type === "portal-output";
550
- };
551
- var isFlowSplitRandomNode = (n) => {
552
- return n.type === "split-random";
553
- };
554
- var isControlFlowNode = (n) => {
555
- return n.type === "portal-input" || n.type === "portal-output" || n.type === "split-answer" || n.type === "split-points" || n.type === "split-random" || n.type === "split-result";
556
- };
557
- var isInteractiveFlowNode = (n) => {
558
- if (n.type === "checkpoint" || n.type === "end" || n.type === "input" || n.type === "start" || n.type === "synchronize" || n.type === "task" || n.type === "title") {
559
- return true;
560
- }
561
- return false;
562
- };
563
- var extractInteractiveFlowPublicNode = (n) => {
564
- if (n.type === "task") {
565
- return {
566
- id: n.id,
567
- type: n.type,
568
- data: {
569
- name: n.data.name,
570
- subtype: n.data.subtype,
571
- view: n.data.view
572
- }
573
- };
574
- } else if (n.type === "synchronize" || n.type === "checkpoint") {
575
- return {
576
- id: n.id,
577
- type: n.type
578
- };
579
- } else if (n.type === "input") {
580
- return {
581
- id: n.id,
582
- type: n.type,
583
- data: n.data
584
- };
585
- } else if (n.type === "end") {
586
- return {
587
- id: n.id,
588
- type: n.type,
589
- data: n.data
590
- };
591
- } else if (n.type === "start") {
592
- return {
593
- id: n.id,
594
- type: n.type,
595
- data: n.data
596
- };
597
- }
598
- return {
599
- id: n.id,
600
- type: n.type,
601
- data: n.data
602
- };
603
- };
604
-
605
- // src/groupBy.ts
606
- function groupBy(array, by) {
607
- const grouped = [];
608
- let index = 0;
609
- const indexes = {};
610
- let l = 0;
611
- while (l < array.length) {
612
- const value = array[l];
613
- const key = by(value);
614
- if (indexes[key] === void 0) {
615
- indexes[key] = index;
616
- index++;
617
- }
618
- if (!grouped[indexes[key]]) {
619
- grouped[indexes[key]] = [value];
620
- } else {
621
- grouped[indexes[key]].push(value);
622
- }
623
- l++;
624
- }
625
- return grouped;
626
- }
627
-
628
- // src/lerpColor.ts
629
- function lerpColor(a, b, amount) {
630
- let ah = +a.replace("#", "0x"), ar = ah >> 16, ag = ah >> 8 & 255, ab = ah & 255, bh = +b.replace("#", "0x"), br = bh >> 16, bg = bh >> 8 & 255, bb = bh & 255, rr = ar + amount * (br - ar), rg = ag + amount * (bg - ag), rb = ab + amount * (bb - ab);
631
- return "#" + ((1 << 24) + (rr << 16) + (rg << 8) + rb | 0).toString(16).slice(1);
632
- }
633
-
634
- // src/levenshtein.ts
635
- function _min(d0, d1, d2, bx, ay) {
636
- return d0 < d1 || d2 < d1 ? d0 > d2 ? d2 + 1 : d0 + 1 : bx === ay ? d1 : d1 + 1;
637
- }
638
- var levenshtein = (a, b) => {
639
- if (a === b) {
640
- return 0;
641
- }
642
- if (a.length > b.length) {
643
- var tmp = a;
644
- a = b;
645
- b = tmp;
646
- }
647
- var la = a.length;
648
- var lb = b.length;
649
- while (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) {
650
- la--;
651
- lb--;
652
- }
653
- var offset = 0;
654
- while (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) {
655
- offset++;
656
- }
657
- la -= offset;
658
- lb -= offset;
659
- if (la === 0 || lb < 3) {
660
- return lb;
661
- }
662
- let x = 0;
663
- let y;
664
- let d0;
665
- let d1;
666
- let d2;
667
- let d3;
668
- let dd = 0;
669
- let dy;
670
- let ay;
671
- let bx0;
672
- let bx1;
673
- let bx2;
674
- let bx3;
675
- let vector = [];
676
- for (y = 0; y < la; y++) {
677
- vector.push(y + 1);
678
- vector.push(a.charCodeAt(offset + y));
679
- }
680
- let len = vector.length - 1;
681
- for (; x < lb - 3; ) {
682
- bx0 = b.charCodeAt(offset + (d0 = x));
683
- bx1 = b.charCodeAt(offset + (d1 = x + 1));
684
- bx2 = b.charCodeAt(offset + (d2 = x + 2));
685
- bx3 = b.charCodeAt(offset + (d3 = x + 3));
686
- dd = x += 4;
687
- for (y = 0; y < len; y += 2) {
688
- dy = vector[y];
689
- ay = vector[y + 1];
690
- d0 = _min(dy, d0, d1, bx0, ay);
691
- d1 = _min(d0, d1, d2, bx1, ay);
692
- d2 = _min(d1, d2, d3, bx2, ay);
693
- dd = _min(d2, d3, dd, bx3, ay);
694
- vector[y] = dd;
695
- d3 = d2;
696
- d2 = d1;
697
- d1 = d0;
698
- d0 = dy;
699
- }
700
- }
701
- for (; x < lb; ) {
702
- bx0 = b.charCodeAt(offset + (d0 = x));
703
- dd = ++x;
704
- for (y = 0; y < len; y += 2) {
705
- dy = vector[y];
706
- vector[y] = dd = _min(dy, d0, dd, bx0, vector[y + 1]);
707
- d0 = dy;
708
- }
709
- }
710
- return dd;
711
- };
712
-
713
- // src/uuid.ts
714
- function uuidv4() {
715
- var uuid = "", i, random;
716
- for (i = 0; i < 32; i++) {
717
- random = Math.random() * 16 | 0;
718
- if (i == 8 || i == 12 || i == 16 || i == 20) {
719
- uuid += "-";
720
- }
721
- uuid += (i == 12 ? 4 : i == 16 ? random & 3 | 8 : random).toString(16);
722
- }
723
- return uuid;
724
- }
725
- //# sourceMappingURL=index.cjs.js.map