@flowgram.ai/form-materials 0.2.30 → 0.2.31

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.js ADDED
@@ -0,0 +1,3695 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ ArrayIcons: () => ArrayIcons,
34
+ BatchOutputs: () => BatchOutputs,
35
+ BatchVariableSelector: () => BatchVariableSelector,
36
+ CodeEditor: () => CodeEditor,
37
+ ConditionRow: () => ConditionRow,
38
+ ConstantInput: () => ConstantInput,
39
+ DynamicValueInput: () => DynamicValueInput,
40
+ InputsValues: () => InputsValues,
41
+ JsonEditorWithVariables: () => JsonEditorWithVariables,
42
+ JsonSchemaEditor: () => JsonSchemaEditor,
43
+ JsonSchemaUtils: () => JsonSchemaUtils,
44
+ PromptEditor: () => PromptEditor,
45
+ PromptEditorWithInputs: () => PromptEditorWithInputs,
46
+ PromptEditorWithVariables: () => PromptEditorWithVariables,
47
+ TypeSelector: () => TypeSelector,
48
+ VariableSelector: () => VariableSelector,
49
+ VariableTypeIcons: () => VariableTypeIcons,
50
+ autoRenameRefEffect: () => autoRenameRefEffect,
51
+ createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
52
+ createInferInputsPlugin: () => createInferInputsPlugin,
53
+ formatLegacyRefOnInit: () => formatLegacyRefOnInit,
54
+ formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
55
+ formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
56
+ formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
57
+ getSchemaIcon: () => getSchemaIcon,
58
+ getTypeSelectValue: () => getTypeSelectValue,
59
+ isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
60
+ isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
61
+ parseTypeSelectValue: () => parseTypeSelectValue,
62
+ provideBatchInputEffect: () => provideBatchInputEffect,
63
+ provideBatchOutputsEffect: () => provideBatchOutputsEffect,
64
+ provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
65
+ syncVariableTitle: () => syncVariableTitle,
66
+ useVariableTree: () => useVariableTree
67
+ });
68
+ module.exports = __toCommonJS(src_exports);
69
+
70
+ // ../../../common/temp/node_modules/.pnpm/tsup@8.3.5_typescript@5.8.3/node_modules/tsup/assets/cjs_shims.js
71
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
72
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
73
+
74
+ // src/components/variable-selector/index.tsx
75
+ var import_react3 = __toESM(require("react"));
76
+ var import_semi_ui3 = require("@douyinfe/semi-ui");
77
+ var import_semi_icons2 = require("@douyinfe/semi-icons");
78
+
79
+ // src/components/variable-selector/use-variable-tree.tsx
80
+ var import_react2 = __toESM(require("react"));
81
+ var import_editor2 = require("@flowgram.ai/editor");
82
+ var import_semi_ui = require("@douyinfe/semi-ui");
83
+
84
+ // src/components/type-selector/constants.tsx
85
+ var import_react = __toESM(require("react"));
86
+ var import_semi_icons = __toESM(require("@douyinfe/semi-icons"));
87
+ var VariableTypeIcons = {
88
+ custom: /* @__PURE__ */ import_react.default.createElement(
89
+ "svg",
90
+ {
91
+ viewBox: "0 0 24 24",
92
+ fill: "none",
93
+ xmlns: "http://www.w3.org/2000/svg",
94
+ width: "1em",
95
+ height: "1em",
96
+ focusable: "false",
97
+ "aria-hidden": "true"
98
+ },
99
+ /* @__PURE__ */ import_react.default.createElement(
100
+ "path",
101
+ {
102
+ fillRule: "evenodd",
103
+ clipRule: "evenodd",
104
+ d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
105
+ fill: "currentColor"
106
+ }
107
+ )
108
+ ),
109
+ object: /* @__PURE__ */ import_react.default.createElement(
110
+ "svg",
111
+ {
112
+ width: "1em",
113
+ height: "1em",
114
+ viewBox: "0 0 16 16",
115
+ fill: "none",
116
+ xmlns: "http://www.w3.org/2000/svg"
117
+ },
118
+ /* @__PURE__ */ import_react.default.createElement(
119
+ "path",
120
+ {
121
+ d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
122
+ fill: "currentColor"
123
+ }
124
+ ),
125
+ /* @__PURE__ */ import_react.default.createElement(
126
+ "path",
127
+ {
128
+ d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
129
+ fill: "currentColor"
130
+ }
131
+ )
132
+ ),
133
+ boolean: /* @__PURE__ */ import_react.default.createElement(
134
+ "svg",
135
+ {
136
+ width: "1em",
137
+ height: "1em",
138
+ viewBox: "0 0 16 16",
139
+ fill: "none",
140
+ xmlns: "http://www.w3.org/2000/svg"
141
+ },
142
+ /* @__PURE__ */ import_react.default.createElement(
143
+ "path",
144
+ {
145
+ fillRule: "evenodd",
146
+ clipRule: "evenodd",
147
+ d: "M10.668 4.66683H5.33463C3.49369 4.66683 2.0013 6.15921 2.0013 8.00016C2.0013 9.84111 3.49369 11.3335 5.33463 11.3335H10.668C12.5089 11.3335 14.0013 9.84111 14.0013 8.00016C14.0013 6.15921 12.5089 4.66683 10.668 4.66683ZM5.33463 3.3335C2.75731 3.3335 0.667969 5.42283 0.667969 8.00016C0.667969 10.5775 2.75731 12.6668 5.33463 12.6668H10.668C13.2453 12.6668 15.3346 10.5775 15.3346 8.00016C15.3346 5.42283 13.2453 3.3335 10.668 3.3335H5.33463Z",
148
+ fill: "currentColor"
149
+ }
150
+ ),
151
+ /* @__PURE__ */ import_react.default.createElement(
152
+ "path",
153
+ {
154
+ fillRule: "evenodd",
155
+ clipRule: "evenodd",
156
+ d: "M8.66797 8.00016C8.66797 6.89559 9.5634 6.00016 10.668 6.00016C11.7725 6.00016 12.668 6.89559 12.668 8.00016C12.668 9.10473 11.7725 10.0002 10.668 10.0002C9.5634 10.0002 8.66797 9.10473 8.66797 8.00016ZM10.668 7.3335C10.2998 7.3335 10.0013 7.63197 10.0013 8.00016C10.0013 8.36835 10.2998 8.66683 10.668 8.66683C11.0362 8.66683 11.3346 8.36835 11.3346 8.00016C11.3346 7.63197 11.0362 7.3335 10.668 7.3335Z",
157
+ fill: "currentColor"
158
+ }
159
+ )
160
+ ),
161
+ string: /* @__PURE__ */ import_react.default.createElement(
162
+ "svg",
163
+ {
164
+ width: "1em",
165
+ height: "1em",
166
+ viewBox: "0 0 16 16",
167
+ fill: "none",
168
+ xmlns: "http://www.w3.org/2000/svg"
169
+ },
170
+ /* @__PURE__ */ import_react.default.createElement(
171
+ "path",
172
+ {
173
+ d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
174
+ fill: "currentColor"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ import_react.default.createElement(
178
+ "path",
179
+ {
180
+ d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
181
+ fill: "currentColor"
182
+ }
183
+ ),
184
+ /* @__PURE__ */ import_react.default.createElement(
185
+ "path",
186
+ {
187
+ d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
188
+ fill: "currentColor"
189
+ }
190
+ ),
191
+ /* @__PURE__ */ import_react.default.createElement(
192
+ "path",
193
+ {
194
+ d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
195
+ fill: "currentColor"
196
+ }
197
+ )
198
+ ),
199
+ integer: /* @__PURE__ */ import_react.default.createElement(
200
+ "svg",
201
+ {
202
+ width: "1em",
203
+ height: "1em",
204
+ viewBox: "0 0 16 16",
205
+ fill: "none",
206
+ xmlns: "http://www.w3.org/2000/svg"
207
+ },
208
+ /* @__PURE__ */ import_react.default.createElement(
209
+ "path",
210
+ {
211
+ d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
212
+ fill: "currentColor"
213
+ }
214
+ ),
215
+ /* @__PURE__ */ import_react.default.createElement(
216
+ "path",
217
+ {
218
+ d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
219
+ fill: "currentColor"
220
+ }
221
+ ),
222
+ /* @__PURE__ */ import_react.default.createElement(
223
+ "path",
224
+ {
225
+ d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
226
+ fill: "currentColor"
227
+ }
228
+ )
229
+ ),
230
+ number: /* @__PURE__ */ import_react.default.createElement(
231
+ "svg",
232
+ {
233
+ width: "1em",
234
+ height: "1em",
235
+ viewBox: "0 0 16 16",
236
+ fill: "none",
237
+ xmlns: "http://www.w3.org/2000/svg"
238
+ },
239
+ /* @__PURE__ */ import_react.default.createElement(
240
+ "path",
241
+ {
242
+ d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
243
+ fill: "currentColor"
244
+ }
245
+ ),
246
+ /* @__PURE__ */ import_react.default.createElement(
247
+ "path",
248
+ {
249
+ d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
250
+ fill: "currentColor"
251
+ }
252
+ ),
253
+ /* @__PURE__ */ import_react.default.createElement(
254
+ "path",
255
+ {
256
+ d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
257
+ fill: "currentColor"
258
+ }
259
+ )
260
+ ),
261
+ array: /* @__PURE__ */ import_react.default.createElement(
262
+ "svg",
263
+ {
264
+ width: "1em",
265
+ height: "1em",
266
+ viewBox: "0 0 16 16",
267
+ fill: "none",
268
+ xmlns: "http://www.w3.org/2000/svg"
269
+ },
270
+ /* @__PURE__ */ import_react.default.createElement(
271
+ "path",
272
+ {
273
+ d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
274
+ fill: "currentColor"
275
+ }
276
+ ),
277
+ /* @__PURE__ */ import_react.default.createElement(
278
+ "path",
279
+ {
280
+ d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
281
+ fill: "currentColor"
282
+ }
283
+ )
284
+ ),
285
+ stream: /* @__PURE__ */ import_react.default.createElement(
286
+ "svg",
287
+ {
288
+ viewBox: "0 0 1024 1024",
289
+ version: "1.1",
290
+ xmlns: "http://www.w3.org/2000/svg",
291
+ width: "1em",
292
+ height: "1em"
293
+ },
294
+ /* @__PURE__ */ import_react.default.createElement(
295
+ "path",
296
+ {
297
+ d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
298
+ fill: "currentColor"
299
+ }
300
+ )
301
+ ),
302
+ map: /* @__PURE__ */ import_react.default.createElement(
303
+ "svg",
304
+ {
305
+ viewBox: "0 0 1024 1024",
306
+ version: "1.1",
307
+ xmlns: "http://www.w3.org/2000/svg",
308
+ width: "1em",
309
+ height: "1em"
310
+ },
311
+ /* @__PURE__ */ import_react.default.createElement(
312
+ "path",
313
+ {
314
+ d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
315
+ fill: "currentColor"
316
+ }
317
+ ),
318
+ /* @__PURE__ */ import_react.default.createElement(
319
+ "path",
320
+ {
321
+ d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
322
+ fill: "currentColor"
323
+ }
324
+ )
325
+ )
326
+ };
327
+ var ArrayIcons = {
328
+ object: /* @__PURE__ */ import_react.default.createElement(
329
+ "svg",
330
+ {
331
+ width: "1em",
332
+ height: "1em",
333
+ viewBox: "0 0 16 16",
334
+ fill: "none",
335
+ xmlns: "http://www.w3.org/2000/svg"
336
+ },
337
+ /* @__PURE__ */ import_react.default.createElement(
338
+ "path",
339
+ {
340
+ fillRule: "evenodd",
341
+ clipRule: "evenodd",
342
+ d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
343
+ fill: "currentColor"
344
+ }
345
+ )
346
+ ),
347
+ boolean: /* @__PURE__ */ import_react.default.createElement(
348
+ "svg",
349
+ {
350
+ width: "1em",
351
+ height: "1em",
352
+ viewBox: "0 0 16 16",
353
+ fill: "none",
354
+ xmlns: "http://www.w3.org/2000/svg"
355
+ },
356
+ /* @__PURE__ */ import_react.default.createElement(
357
+ "path",
358
+ {
359
+ fillRule: "evenodd",
360
+ clipRule: "evenodd",
361
+ d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
362
+ fill: "currentColor"
363
+ }
364
+ )
365
+ ),
366
+ string: /* @__PURE__ */ import_react.default.createElement(
367
+ "svg",
368
+ {
369
+ width: "1em",
370
+ height: "1em",
371
+ viewBox: "0 0 16 16",
372
+ fill: "none",
373
+ xmlns: "http://www.w3.org/2000/svg"
374
+ },
375
+ /* @__PURE__ */ import_react.default.createElement(
376
+ "path",
377
+ {
378
+ fillRule: "evenodd",
379
+ clipRule: "evenodd",
380
+ d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
381
+ fill: "currentColor"
382
+ }
383
+ )
384
+ ),
385
+ integer: /* @__PURE__ */ import_react.default.createElement(
386
+ "svg",
387
+ {
388
+ width: "1em",
389
+ height: "1em",
390
+ viewBox: "0 0 16 16",
391
+ fill: "none",
392
+ xmlns: "http://www.w3.org/2000/svg"
393
+ },
394
+ /* @__PURE__ */ import_react.default.createElement(
395
+ "path",
396
+ {
397
+ fillRule: "evenodd",
398
+ clipRule: "evenodd",
399
+ d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
400
+ fill: "currentColor"
401
+ }
402
+ )
403
+ ),
404
+ number: /* @__PURE__ */ import_react.default.createElement(
405
+ "svg",
406
+ {
407
+ width: "1em",
408
+ height: "1em",
409
+ viewBox: "0 0 16 16",
410
+ fill: "none",
411
+ xmlns: "http://www.w3.org/2000/svg"
412
+ },
413
+ /* @__PURE__ */ import_react.default.createElement(
414
+ "path",
415
+ {
416
+ fillRule: "evenodd",
417
+ clipRule: "evenodd",
418
+ d: "M3.6139 1.58154H0V14.4191H3.6139V13.1269H1.36702V2.87375H3.6139V1.58154ZM3.41656 13.3271V13.3269H1.17155V13.3271H3.41656ZM0.199219 14.2191H0.197344V1.78154H3.41656V1.78174H0.199219V14.2191ZM16 1.58154H12.3861V2.87375H14.633V13.1269H12.3861V14.4191H16V1.58154ZM12.5834 1.78154V2.67375H12.5853V1.78174H15.8027V1.78154H12.5834ZM12.5853 14.2191V13.3271H14.8322V2.67394H14.8303V13.3269H12.5834V14.2191H12.5853ZM6.86771 4.5C5.87019 4.5 5.00104 5.30767 5.00104 6.31667V9.63333C5.00104 10.6423 5.87019 11.45 6.86771 11.45C7.86523 11.45 8.73438 10.6423 8.73438 9.63333V6.31667C8.73438 5.30767 7.86523 4.5 6.86771 4.5ZM11.1177 4.5C10.1202 4.5 9.25104 5.30767 9.25104 6.31667V9.63333C9.25104 10.6423 10.1202 11.45 11.1177 11.45C12.1152 11.45 12.9844 10.6423 12.9844 9.63333V6.31667C12.9844 5.30767 12.1152 4.5 11.1177 4.5ZM6.13438 6.31667C6.13438 5.9503 6.47884 5.63333 6.86771 5.63333C7.25657 5.63333 7.60104 5.9503 7.60104 6.31667V9.63333C7.60104 9.9997 7.25657 10.3167 6.86771 10.3167C6.47884 10.3167 6.13438 9.9997 6.13438 9.63333V6.31667ZM10.3844 6.31667C10.3844 5.9503 10.7288 5.63333 11.1177 5.63333C11.5066 5.63333 11.851 5.9503 11.851 6.31667V9.63333C11.851 9.9997 11.5066 10.3167 11.1177 10.3167C10.7288 10.3167 10.3844 9.9997 10.3844 9.63333V6.31667ZM3.75938 9.85C3.33135 9.85 2.98438 10.197 2.98438 10.625C2.98438 11.053 3.33135 11.4 3.75938 11.4C4.1874 11.4 4.53438 11.053 4.53438 10.625C4.53438 10.197 4.1874 9.85 3.75938 9.85Z",
419
+ fill: "currentColor"
420
+ }
421
+ )
422
+ )
423
+ };
424
+ var getSchemaIcon = (value) => {
425
+ if (value?.type === "array") {
426
+ return ArrayIcons[value.items?.type || "object"];
427
+ }
428
+ return VariableTypeIcons[value?.type || "object"];
429
+ };
430
+ var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
431
+ var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
432
+ var baseOptions = [
433
+ {
434
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
435
+ value: "string"
436
+ },
437
+ {
438
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
439
+ value: "integer"
440
+ },
441
+ {
442
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
443
+ value: "number"
444
+ },
445
+ {
446
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
447
+ value: "boolean"
448
+ },
449
+ {
450
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
451
+ value: "object"
452
+ }
453
+ ];
454
+ var options = [
455
+ ...baseOptions,
456
+ {
457
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
458
+ value: "array",
459
+ children: baseOptions.map((_opt) => ({
460
+ ..._opt,
461
+ value: `${_opt.value}`,
462
+ label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(
463
+ import_semi_icons.default,
464
+ {
465
+ size: "small",
466
+ svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
467
+ }
468
+ ), firstUppercase(_opt.value))
469
+ }))
470
+ }
471
+ ];
472
+
473
+ // src/utils/json-schema/index.ts
474
+ var import_lodash = require("lodash");
475
+ var import_editor = require("@flowgram.ai/editor");
476
+ var JsonSchemaUtils;
477
+ ((JsonSchemaUtils2) => {
478
+ function schemaToAST(jsonSchema) {
479
+ const { type, extra } = jsonSchema || {};
480
+ const { weak = false } = extra || {};
481
+ if (!type) {
482
+ return void 0;
483
+ }
484
+ switch (type) {
485
+ case "object":
486
+ if (weak) {
487
+ return { kind: import_editor.ASTKind.Object, weak: true };
488
+ }
489
+ return import_editor.ASTFactory.createObject({
490
+ properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
491
+ key,
492
+ type: schemaToAST(_property),
493
+ meta: {
494
+ title: _property.title,
495
+ description: _property.description
496
+ }
497
+ }))
498
+ });
499
+ case "array":
500
+ if (weak) {
501
+ return { kind: import_editor.ASTKind.Array, weak: true };
502
+ }
503
+ return import_editor.ASTFactory.createArray({
504
+ items: schemaToAST(jsonSchema.items)
505
+ });
506
+ case "map":
507
+ if (weak) {
508
+ return { kind: import_editor.ASTKind.Map, weak: true };
509
+ }
510
+ return import_editor.ASTFactory.createMap({
511
+ valueType: schemaToAST(jsonSchema.additionalProperties)
512
+ });
513
+ case "string":
514
+ return import_editor.ASTFactory.createString();
515
+ case "number":
516
+ return import_editor.ASTFactory.createNumber();
517
+ case "boolean":
518
+ return import_editor.ASTFactory.createBoolean();
519
+ case "integer":
520
+ return import_editor.ASTFactory.createInteger();
521
+ default:
522
+ return import_editor.ASTFactory.createCustomType({ typeName: type });
523
+ }
524
+ }
525
+ JsonSchemaUtils2.schemaToAST = schemaToAST;
526
+ function astToSchema(typeAST, options2) {
527
+ const { drilldown = true } = options2 || {};
528
+ if (import_editor.ASTMatch.isString(typeAST)) {
529
+ return {
530
+ type: "string"
531
+ };
532
+ }
533
+ if (import_editor.ASTMatch.isBoolean(typeAST)) {
534
+ return {
535
+ type: "boolean"
536
+ };
537
+ }
538
+ if (import_editor.ASTMatch.isNumber(typeAST)) {
539
+ return {
540
+ type: "number"
541
+ };
542
+ }
543
+ if (import_editor.ASTMatch.isInteger(typeAST)) {
544
+ return {
545
+ type: "integer"
546
+ };
547
+ }
548
+ if (import_editor.ASTMatch.isObject(typeAST)) {
549
+ return {
550
+ type: "object",
551
+ properties: drilldown ? Object.fromEntries(
552
+ typeAST.properties.map((property) => {
553
+ const schema = astToSchema(property.type);
554
+ if (property.meta?.title && schema) {
555
+ schema.title = property.meta.title;
556
+ }
557
+ if (property.meta?.description && schema) {
558
+ schema.description = property.meta.description;
559
+ }
560
+ return [property.key, schema];
561
+ })
562
+ ) : {}
563
+ };
564
+ }
565
+ if (import_editor.ASTMatch.isArray(typeAST)) {
566
+ return {
567
+ type: "array",
568
+ items: drilldown ? astToSchema(typeAST.items) : void 0
569
+ };
570
+ }
571
+ if (import_editor.ASTMatch.isMap(typeAST)) {
572
+ return {
573
+ type: "map",
574
+ items: drilldown ? astToSchema(typeAST.valueType) : void 0
575
+ };
576
+ }
577
+ if (import_editor.ASTMatch.isCustomType(typeAST)) {
578
+ return {
579
+ type: typeAST.typeName
580
+ };
581
+ }
582
+ return void 0;
583
+ }
584
+ JsonSchemaUtils2.astToSchema = astToSchema;
585
+ function isASTMatchSchema(typeAST, schema) {
586
+ if (Array.isArray(schema)) {
587
+ return typeAST.isTypeEqual(
588
+ import_editor.ASTFactory.createUnion({
589
+ types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
590
+ })
591
+ );
592
+ }
593
+ return typeAST.isTypeEqual(schemaToAST(schema));
594
+ }
595
+ JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
596
+ })(JsonSchemaUtils || (JsonSchemaUtils = {}));
597
+
598
+ // src/components/variable-selector/use-variable-tree.tsx
599
+ function useVariableTree(params) {
600
+ const { includeSchema, excludeSchema, customSkip } = params;
601
+ const variables = (0, import_editor2.useAvailableVariables)();
602
+ const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
603
+ if (variable.meta?.icon) {
604
+ if (typeof variable.meta.icon === "string") {
605
+ return /* @__PURE__ */ import_react2.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
606
+ }
607
+ return variable.meta.icon;
608
+ }
609
+ const _type = variable.type;
610
+ if (import_editor2.ASTMatch.isArray(_type)) {
611
+ return /* @__PURE__ */ import_react2.default.createElement(
612
+ import_semi_ui.Icon,
613
+ {
614
+ size: "small",
615
+ svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
616
+ }
617
+ );
618
+ }
619
+ if (import_editor2.ASTMatch.isCustomType(_type)) {
620
+ return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
621
+ }
622
+ return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
623
+ }, []);
624
+ const renderVariable = (variable, parentFields = []) => {
625
+ let type = variable?.type;
626
+ if (!type) {
627
+ return null;
628
+ }
629
+ let children;
630
+ if (import_editor2.ASTMatch.isObject(type)) {
631
+ children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
632
+ }
633
+ const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
634
+ const key = keyPath.join(".");
635
+ const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
636
+ const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
637
+ const isCustomSkip = customSkip ? customSkip(variable) : false;
638
+ const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip;
639
+ if (!isSchemaMatch && !children?.length) {
640
+ return null;
641
+ }
642
+ return {
643
+ key,
644
+ label: variable.meta?.title || variable.key,
645
+ value: key,
646
+ keyPath,
647
+ icon: getVariableTypeIcon(variable),
648
+ children,
649
+ disabled: !isSchemaMatch,
650
+ rootMeta: parentFields[0]?.meta || variable.meta,
651
+ isRoot: !parentFields?.length
652
+ };
653
+ };
654
+ return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
655
+ }
656
+
657
+ // src/components/variable-selector/styles.tsx
658
+ var import_styled_components = __toESM(require("styled-components"));
659
+ var import_semi_ui2 = require("@douyinfe/semi-ui");
660
+ var UIRootTitle = import_styled_components.default.div`
661
+ margin-right: 4px;
662
+ min-width: 20px;
663
+ overflow: hidden;
664
+ text-overflow: ellipsis;
665
+ white-space: nowrap;
666
+ color: var(--semi-color-text-2);
667
+ `;
668
+ var UIVarName = import_styled_components.default.div`
669
+ overflow: hidden;
670
+ text-overflow: ellipsis;
671
+ white-space: nowrap;
672
+
673
+ ${({ $inSelector }) => $inSelector && import_styled_components.css`
674
+ min-width: 50%;
675
+ `}
676
+ `;
677
+ var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
678
+ width: 100%;
679
+ display: flex;
680
+ align-items: center;
681
+ justify-content: flex-start;
682
+
683
+ & .semi-tag-content-center {
684
+ justify-content: flex-start;
685
+ }
686
+
687
+ &.semi-tag {
688
+ margin: 0;
689
+ height: 22px;
690
+ }
691
+ `;
692
+ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSelect)`
693
+ outline: ${({ $error }) => $error ? "1px solid red" : "none"};
694
+
695
+ & .semi-tree-select-selection {
696
+ padding: 0px;
697
+ height: 22px;
698
+ }
699
+
700
+ & .semi-tree-select-selection-content {
701
+ width: 100%;
702
+ }
703
+
704
+ & .semi-tree-select-selection-placeholder {
705
+ padding-left: 10px;
706
+ }
707
+ `;
708
+ var UIPopoverContent = import_styled_components.default.div`
709
+ padding: 10px;
710
+ display: inline-flex;
711
+ align-items: center;
712
+ justify-content: flex-start;
713
+ white-space: nowrap;
714
+ `;
715
+
716
+ // src/components/variable-selector/index.tsx
717
+ var VariableSelector = ({
718
+ value,
719
+ config = {},
720
+ onChange,
721
+ style,
722
+ readonly = false,
723
+ includeSchema,
724
+ excludeSchema,
725
+ hasError,
726
+ triggerRender
727
+ }) => {
728
+ const treeData = useVariableTree({ includeSchema, excludeSchema });
729
+ const treeValue = (0, import_react3.useMemo)(() => {
730
+ if (typeof value === "string") {
731
+ console.warn(
732
+ "The Value of VariableSelector is a string, it should be an ARRAY. \n",
733
+ "Please check the value of VariableSelector \n"
734
+ );
735
+ return value;
736
+ }
737
+ return value?.join(".");
738
+ }, [value]);
739
+ const renderIcon = (icon) => {
740
+ if (typeof icon === "string") {
741
+ return /* @__PURE__ */ import_react3.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
742
+ }
743
+ return icon;
744
+ };
745
+ return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
746
+ UITreeSelect,
747
+ {
748
+ dropdownMatchSelectWidth: false,
749
+ disabled: readonly,
750
+ treeData,
751
+ size: "small",
752
+ value: treeValue,
753
+ clearIcon: null,
754
+ $error: hasError,
755
+ style,
756
+ validateStatus: hasError ? "error" : void 0,
757
+ onChange: (_, _config) => {
758
+ onChange(_config.keyPath);
759
+ },
760
+ renderSelectedItem: (_option) => {
761
+ if (!_option?.keyPath) {
762
+ return /* @__PURE__ */ import_react3.default.createElement(
763
+ UITag,
764
+ {
765
+ prefixIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconIssueStroked, null),
766
+ color: "amber",
767
+ closable: !readonly,
768
+ onClose: () => onChange(void 0)
769
+ },
770
+ config?.notFoundContent ?? "Undefined"
771
+ );
772
+ }
773
+ const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
774
+ const rootTitle = /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
775
+ return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement(
776
+ import_semi_ui3.Popover,
777
+ {
778
+ content: /* @__PURE__ */ import_react3.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react3.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
779
+ },
780
+ /* @__PURE__ */ import_react3.default.createElement(
781
+ UITag,
782
+ {
783
+ prefixIcon: rootIcon,
784
+ closable: !readonly,
785
+ onClose: () => onChange(void 0)
786
+ },
787
+ rootTitle,
788
+ !_option.isRoot && /* @__PURE__ */ import_react3.default.createElement(UIVarName, { $inSelector: true }, _option.label)
789
+ )
790
+ ));
791
+ },
792
+ showClear: false,
793
+ arrowIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
794
+ triggerRender,
795
+ placeholder: config?.placeholder ?? "Select Variable..."
796
+ }
797
+ ));
798
+ };
799
+
800
+ // src/components/type-selector/index.tsx
801
+ var import_react4 = __toESM(require("react"));
802
+ var import_semi_ui4 = require("@douyinfe/semi-ui");
803
+ var getTypeSelectValue = (value) => {
804
+ if (value?.type === "array" && value?.items) {
805
+ return [value.type, ...getTypeSelectValue(value.items) || []];
806
+ }
807
+ return value?.type ? [value.type] : void 0;
808
+ };
809
+ var parseTypeSelectValue = (value) => {
810
+ const [type, ...subTypes] = value || [];
811
+ if (type === "array") {
812
+ return { type: "array", items: parseTypeSelectValue(subTypes) };
813
+ }
814
+ return { type };
815
+ };
816
+ function TypeSelector(props) {
817
+ const { value, onChange, readonly, disabled, style } = props;
818
+ const selectValue = (0, import_react4.useMemo)(() => getTypeSelectValue(value), [value]);
819
+ return /* @__PURE__ */ import_react4.default.createElement(
820
+ import_semi_ui4.Cascader,
821
+ {
822
+ disabled: readonly || disabled,
823
+ size: "small",
824
+ triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(
825
+ import_semi_ui4.IconButton,
826
+ {
827
+ size: "small",
828
+ style,
829
+ disabled: readonly || disabled,
830
+ icon: getSchemaIcon(value)
831
+ }
832
+ ),
833
+ treeData: options,
834
+ value: selectValue,
835
+ leafOnly: true,
836
+ onChange: (value2) => {
837
+ onChange?.(parseTypeSelectValue(value2));
838
+ }
839
+ }
840
+ );
841
+ }
842
+
843
+ // src/components/json-schema-editor/index.tsx
844
+ var import_react10 = __toESM(require("react"));
845
+ var import_semi_ui7 = require("@douyinfe/semi-ui");
846
+ var import_semi_icons5 = require("@douyinfe/semi-icons");
847
+
848
+ // src/components/json-schema-editor/styles.tsx
849
+ var import_react5 = __toESM(require("react"));
850
+ var import_styled_components2 = __toESM(require("styled-components"));
851
+ var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"));
852
+ var UIContainer = import_styled_components2.default.div`
853
+ /* & .semi-input {
854
+ background-color: #fff;
855
+ border-radius: 6px;
856
+ height: 24px;
857
+ } */
858
+ `;
859
+ var UIRow = import_styled_components2.default.div`
860
+ display: flex;
861
+ align-items: center;
862
+ gap: 6px;
863
+ `;
864
+ var UICollapseTrigger = import_styled_components2.default.div`
865
+ cursor: pointer;
866
+ margin-right: 5px;
867
+ `;
868
+ var UIExpandDetail = import_styled_components2.default.div`
869
+ display: flex;
870
+ flex-direction: column;
871
+ `;
872
+ var UILabel = import_styled_components2.default.div`
873
+ font-size: 12px;
874
+ color: #999;
875
+ font-weight: 400;
876
+ margin-bottom: 2px;
877
+ `;
878
+ var UIProperties = import_styled_components2.default.div`
879
+ display: grid;
880
+ grid-template-columns: auto 1fr;
881
+
882
+ ${({ $shrink }) => $shrink && import_styled_components2.css`
883
+ padding-left: 10px;
884
+ margin-top: 10px;
885
+ `}
886
+ `;
887
+ var UIPropertyLeft = import_styled_components2.default.div`
888
+ grid-column: 1;
889
+ position: relative;
890
+ width: 16px;
891
+
892
+ ${({ $showLine, $isLast, $parentType }) => {
893
+ let height = "100%";
894
+ if ($parentType && $isLast) {
895
+ height = "24px";
896
+ }
897
+ return $showLine && import_styled_components2.css`
898
+ &::before {
899
+ /* 竖线 */
900
+ content: '';
901
+ height: ${height};
902
+ position: absolute;
903
+ left: -22px;
904
+ top: -16px;
905
+ width: 1px;
906
+ background: #d9d9d9;
907
+ display: block;
908
+ }
909
+
910
+ &::after {
911
+ /* 横线 */
912
+ content: '';
913
+ position: absolute;
914
+ left: -22px; // 横线起点和竖线对齐
915
+ top: 8px; // 跟随你的行高调整
916
+ width: 18px; // 横线长度
917
+ height: 1px;
918
+ background: #d9d9d9;
919
+ display: block;
920
+ }
921
+ `;
922
+ }}
923
+ `;
924
+ var UIPropertyRight = import_styled_components2.default.div`
925
+ grid-column: 2;
926
+ margin-bottom: 10px;
927
+
928
+ &:last-child {
929
+ margin-bottom: 0px;
930
+ }
931
+ `;
932
+ var UIPropertyMain = import_styled_components2.default.div`
933
+ display: flex;
934
+ flex-direction: column;
935
+ gap: 10px;
936
+ position: relative;
937
+
938
+ ${({ $expand, type, $collapse, $showCollapse }) => {
939
+ const beforeElement = `
940
+ &::before {
941
+ /* \u7AD6\u7EBF */
942
+ content: '';
943
+ height: 100%;
944
+ position: absolute;
945
+ left: -12px;
946
+ top: 18px;
947
+ width: 1px;
948
+ background: #d9d9d9;
949
+ display: block;
950
+ }`;
951
+ return $expand && import_styled_components2.css`
952
+ background-color: #f5f5f5;
953
+ padding: 10px;
954
+ border-radius: 4px;
955
+
956
+ ${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components2.css`
957
+ ${beforeElement}
958
+ `}
959
+ `;
960
+ }}
961
+ `;
962
+ var UICollapsible = import_styled_components2.default.div`
963
+ display: none;
964
+
965
+ ${({ $collapse }) => $collapse && import_styled_components2.css`
966
+ display: block;
967
+ `}
968
+ `;
969
+ var UIName = import_styled_components2.default.div`
970
+ flex-grow: 1;
971
+ `;
972
+ var UIType = import_styled_components2.default.div``;
973
+ var UIRequired = import_styled_components2.default.div``;
974
+ var UIActions = import_styled_components2.default.div`
975
+ white-space: nowrap;
976
+ `;
977
+ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
978
+ "svg",
979
+ {
980
+ className: "icon-icon icon-icon-coz_add_node ",
981
+ width: "1em",
982
+ height: "1em",
983
+ viewBox: "0 0 24 24",
984
+ fill: "currentColor",
985
+ xmlns: "http://www.w3.org/2000/svg"
986
+ },
987
+ /* @__PURE__ */ import_react5.default.createElement(
988
+ "path",
989
+ {
990
+ fillRule: "evenodd",
991
+ clipRule: "evenodd",
992
+ d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
993
+ }
994
+ ),
995
+ /* @__PURE__ */ import_react5.default.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
996
+ );
997
+ var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons3.default, { size: "small", svg: iconAddChildrenSvg });
998
+ var DefaultValueWrapper = import_styled_components2.default.div`
999
+ margin: 0;
1000
+ `;
1001
+ var JSONViewerWrapper = import_styled_components2.default.div`
1002
+ padding: 0 0 24px;
1003
+ &:first-child {
1004
+ margin-top: 0px;
1005
+ }
1006
+ `;
1007
+ var JSONHeader = import_styled_components2.default.div`
1008
+ display: flex;
1009
+ justify-content: space-between;
1010
+ align-items: center;
1011
+ background-color: var(--semi-color-fill-0);
1012
+ border-radius: 6px 6px 0 0;
1013
+ height: 36px;
1014
+ padding: 0 8px 0 12px;
1015
+ `;
1016
+ var JSONHeaderLeft = import_styled_components2.default.div`
1017
+ display: flex;
1018
+ align-items: center;
1019
+ gap: 10px;
1020
+ `;
1021
+ var JSONHeaderRight = import_styled_components2.default.div`
1022
+ display: flex;
1023
+ align-items: center;
1024
+ gap: 10px;
1025
+ `;
1026
+ var ConstantInputWrapper = import_styled_components2.default.div`
1027
+ flex-grow: 1;
1028
+
1029
+ & .semi-tree-select,
1030
+ & .semi-input-number,
1031
+ & .semi-select {
1032
+ width: 100%;
1033
+ }
1034
+ `;
1035
+
1036
+ // src/components/json-schema-editor/hooks.tsx
1037
+ var import_react6 = require("react");
1038
+ var import_lodash2 = require("lodash");
1039
+ var _id = 0;
1040
+ function genId() {
1041
+ return _id++;
1042
+ }
1043
+ function getDrilldownSchema(value, path) {
1044
+ if (!value) {
1045
+ return {};
1046
+ }
1047
+ if (value.type === "array" && value.items) {
1048
+ return getDrilldownSchema(value.items, [...path || [], "items"]);
1049
+ }
1050
+ return { schema: value, path };
1051
+ }
1052
+ function usePropertiesEdit(value, onChange) {
1053
+ const drilldown = (0, import_react6.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
1054
+ const isDrilldownObject = drilldown.schema?.type === "object";
1055
+ const initPropertyList = (0, import_react6.useMemo)(
1056
+ () => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
1057
+ ([name, _value], index) => ({
1058
+ key: genId(),
1059
+ name,
1060
+ isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1061
+ ..._value,
1062
+ extra: {
1063
+ ..._value.extra || {},
1064
+ index
1065
+ }
1066
+ })
1067
+ ) : [],
1068
+ [isDrilldownObject]
1069
+ );
1070
+ const [propertyList, setPropertyList] = (0, import_react6.useState)(initPropertyList);
1071
+ const mountRef = (0, import_react6.useRef)(false);
1072
+ (0, import_react6.useEffect)(() => {
1073
+ if (mountRef.current) {
1074
+ setPropertyList((_list) => {
1075
+ const nameMap = /* @__PURE__ */ new Map();
1076
+ for (const _property of _list) {
1077
+ if (_property.name) {
1078
+ nameMap.set(_property.name, _property);
1079
+ }
1080
+ }
1081
+ return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
1082
+ const _property = nameMap.get(name);
1083
+ if (_property) {
1084
+ return {
1085
+ key: _property.key,
1086
+ name,
1087
+ isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1088
+ ..._value
1089
+ };
1090
+ }
1091
+ return {
1092
+ key: genId(),
1093
+ name,
1094
+ isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1095
+ ..._value
1096
+ };
1097
+ });
1098
+ });
1099
+ }
1100
+ mountRef.current = true;
1101
+ }, [drilldown.schema]);
1102
+ const updatePropertyList = (updater) => {
1103
+ setPropertyList((_list) => {
1104
+ const next = updater(_list);
1105
+ const nextProperties = {};
1106
+ const nextRequired = [];
1107
+ for (const _property of next) {
1108
+ if (!_property.name) {
1109
+ continue;
1110
+ }
1111
+ nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
1112
+ if (_property.isPropertyRequired) {
1113
+ nextRequired.push(_property.name);
1114
+ }
1115
+ }
1116
+ let drilldownSchema = value || {};
1117
+ if (drilldown.path) {
1118
+ drilldownSchema = drilldown.path.reduce((acc, key) => acc[key], value || {});
1119
+ }
1120
+ drilldownSchema.properties = nextProperties;
1121
+ drilldownSchema.required = nextRequired;
1122
+ onChange?.(value || {});
1123
+ return next;
1124
+ });
1125
+ };
1126
+ const onAddProperty = () => {
1127
+ updatePropertyList((_list) => [
1128
+ ..._list,
1129
+ { key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
1130
+ ]);
1131
+ };
1132
+ const onRemoveProperty = (key) => {
1133
+ updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
1134
+ };
1135
+ const onEditProperty = (key, nextValue) => {
1136
+ updatePropertyList(
1137
+ (_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
1138
+ );
1139
+ };
1140
+ (0, import_react6.useEffect)(() => {
1141
+ if (!isDrilldownObject) {
1142
+ setPropertyList([]);
1143
+ }
1144
+ }, [isDrilldownObject]);
1145
+ return {
1146
+ propertyList,
1147
+ isDrilldownObject,
1148
+ onAddProperty,
1149
+ onRemoveProperty,
1150
+ onEditProperty
1151
+ };
1152
+ }
1153
+
1154
+ // src/components/json-schema-editor/default-value.tsx
1155
+ var import_react8 = __toESM(require("react"));
1156
+ var import_semi_ui6 = require("@douyinfe/semi-ui");
1157
+ var import_semi_icons4 = require("@douyinfe/semi-icons");
1158
+
1159
+ // src/components/json-schema-editor/utils.ts
1160
+ function getValueType(value) {
1161
+ const type = typeof value;
1162
+ if (type === "string") {
1163
+ return "string";
1164
+ } else if (type === "number") {
1165
+ return Number.isInteger(value) ? "integer" : "number";
1166
+ } else if (type === "boolean") {
1167
+ return "boolean";
1168
+ } else if (type === "object") {
1169
+ if (value === null) {
1170
+ return "other";
1171
+ }
1172
+ return Array.isArray(value) ? "array" : "object";
1173
+ } else {
1174
+ return "other";
1175
+ }
1176
+ }
1177
+
1178
+ // src/components/constant-input/index.tsx
1179
+ var import_react7 = __toESM(require("react"));
1180
+ var import_semi_ui5 = require("@douyinfe/semi-ui");
1181
+ var defaultStrategies = [
1182
+ {
1183
+ hit: (schema) => schema?.type === "string",
1184
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1185
+ },
1186
+ {
1187
+ hit: (schema) => schema?.type === "number",
1188
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
1189
+ import_semi_ui5.InputNumber,
1190
+ {
1191
+ placeholder: "Please Input Number",
1192
+ size: "small",
1193
+ disabled: props.readonly,
1194
+ hideButtons: true,
1195
+ ...props
1196
+ }
1197
+ )
1198
+ },
1199
+ {
1200
+ hit: (schema) => schema?.type === "integer",
1201
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
1202
+ import_semi_ui5.InputNumber,
1203
+ {
1204
+ placeholder: "Please Input Integer",
1205
+ size: "small",
1206
+ disabled: props.readonly,
1207
+ hideButtons: true,
1208
+ precision: 0,
1209
+ ...props
1210
+ }
1211
+ )
1212
+ },
1213
+ {
1214
+ hit: (schema) => schema?.type === "boolean",
1215
+ Renderer: (props) => {
1216
+ const { value, onChange, ...rest } = props;
1217
+ return /* @__PURE__ */ import_react7.default.createElement(
1218
+ import_semi_ui5.Select,
1219
+ {
1220
+ placeholder: "Please Select Boolean",
1221
+ size: "small",
1222
+ disabled: props.readonly,
1223
+ optionList: [
1224
+ { label: "True", value: 1 },
1225
+ { label: "False", value: 0 }
1226
+ ],
1227
+ value: value ? 1 : 0,
1228
+ onChange: (value2) => onChange?.(!!value2),
1229
+ ...rest
1230
+ }
1231
+ );
1232
+ }
1233
+ }
1234
+ ];
1235
+ function ConstantInput(props) {
1236
+ const {
1237
+ value,
1238
+ onChange,
1239
+ schema,
1240
+ strategies: extraStrategies,
1241
+ fallbackRenderer,
1242
+ readonly,
1243
+ ...rest
1244
+ } = props;
1245
+ const strategies = (0, import_react7.useMemo)(
1246
+ // user's extraStrategies first
1247
+ () => [...extraStrategies || [], ...defaultStrategies],
1248
+ [extraStrategies]
1249
+ );
1250
+ const Renderer2 = (0, import_react7.useMemo)(() => {
1251
+ const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1252
+ return strategy?.Renderer;
1253
+ }, [strategies, schema]);
1254
+ if (!Renderer2) {
1255
+ if (fallbackRenderer) {
1256
+ return import_react7.default.createElement(fallbackRenderer, {
1257
+ value,
1258
+ onChange,
1259
+ readonly,
1260
+ ...rest
1261
+ });
1262
+ }
1263
+ return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1264
+ }
1265
+ return /* @__PURE__ */ import_react7.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
1266
+ }
1267
+
1268
+ // src/components/json-schema-editor/default-value.tsx
1269
+ function DefaultValue(props) {
1270
+ const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
1271
+ const wrapperRef = (0, import_react8.useRef)(null);
1272
+ const JsonViewerRef = (0, import_react8.useRef)(null);
1273
+ const [internalJsonValue, setInternalJsonValue] = (0, import_react8.useState)(
1274
+ getValueType(value) === "string" ? value : ""
1275
+ );
1276
+ const handleJsonChange = (0, import_react8.useCallback)((val) => {
1277
+ if (val !== internalJsonValue) {
1278
+ setInternalJsonValue(val);
1279
+ }
1280
+ }, []);
1281
+ const handleEditComplete = (0, import_react8.useCallback)(() => {
1282
+ onChange(internalJsonValue);
1283
+ requestAnimationFrame(() => {
1284
+ wrapperRef.current?.blur();
1285
+ });
1286
+ setJsonReadOnly(true);
1287
+ }, [internalJsonValue, onChange]);
1288
+ const [jsonReadOnly, setJsonReadOnly] = (0, import_react8.useState)(true);
1289
+ const handleFormatJson = (0, import_react8.useCallback)(() => {
1290
+ try {
1291
+ const parsed = JSON.parse(internalJsonValue);
1292
+ const formatted = JSON.stringify(parsed, null, 4);
1293
+ setInternalJsonValue(formatted);
1294
+ onChange(formatted);
1295
+ } catch (error) {
1296
+ console.error("Invalid JSON:", error);
1297
+ }
1298
+ }, [internalJsonValue, onChange]);
1299
+ return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(import_semi_ui6.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react8.default.createElement(
1300
+ import_semi_ui6.IconButton,
1301
+ {
1302
+ icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1303
+ size: "small",
1304
+ type: "tertiary",
1305
+ theme: "borderless",
1306
+ onClick: handleFormatJson
1307
+ }
1308
+ )))), /* @__PURE__ */ import_react8.default.createElement(
1309
+ JSONViewerWrapper,
1310
+ {
1311
+ ref: wrapperRef,
1312
+ tabIndex: -1,
1313
+ onBlur: (e) => {
1314
+ if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
1315
+ handleEditComplete();
1316
+ }
1317
+ },
1318
+ onClick: (e) => {
1319
+ setJsonReadOnly(false);
1320
+ }
1321
+ },
1322
+ /* @__PURE__ */ import_react8.default.createElement(
1323
+ import_semi_ui6.JsonViewer,
1324
+ {
1325
+ ref: JsonViewerRef,
1326
+ value: getValueType(value) === "string" ? value : "",
1327
+ height: 120,
1328
+ width: "100%",
1329
+ showSearch: false,
1330
+ options: {
1331
+ readOnly: jsonReadOnly,
1332
+ formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
1333
+ },
1334
+ style: {
1335
+ padding: 0
1336
+ },
1337
+ onChange: handleJsonChange
1338
+ }
1339
+ )
1340
+ )) : /* @__PURE__ */ import_react8.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react8.default.createElement(
1341
+ ConstantInput,
1342
+ {
1343
+ value,
1344
+ onChange: (_v) => onChange(_v),
1345
+ schema: schema || { type: "string" },
1346
+ placeholder: placeholder ?? "Default value if parameter is not provided"
1347
+ }
1348
+ ));
1349
+ }
1350
+
1351
+ // src/components/json-schema-editor/components/blur-input.tsx
1352
+ var import_react9 = __toESM(require("react"));
1353
+ var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
1354
+ function BlurInput(props) {
1355
+ const [value, setValue] = (0, import_react9.useState)("");
1356
+ (0, import_react9.useEffect)(() => {
1357
+ setValue(props.value);
1358
+ }, [props.value]);
1359
+ return /* @__PURE__ */ import_react9.default.createElement(
1360
+ import_input.default,
1361
+ {
1362
+ ...props,
1363
+ value,
1364
+ onChange: (value2) => {
1365
+ setValue(value2);
1366
+ },
1367
+ onBlur: (e) => props.onChange?.(value, e)
1368
+ }
1369
+ );
1370
+ }
1371
+
1372
+ // src/components/json-schema-editor/index.tsx
1373
+ function JsonSchemaEditor(props) {
1374
+ const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
1375
+ const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1376
+ value,
1377
+ onChangeProps
1378
+ );
1379
+ return /* @__PURE__ */ import_react10.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
1380
+ PropertyEdit,
1381
+ {
1382
+ readonly,
1383
+ key: _property.key,
1384
+ value: _property,
1385
+ config,
1386
+ $index: index,
1387
+ onChange: (_v) => {
1388
+ onEditProperty(_property.key, _v);
1389
+ },
1390
+ onRemove: () => {
1391
+ onRemoveProperty(_property.key);
1392
+ }
1393
+ }
1394
+ ))), /* @__PURE__ */ import_react10.default.createElement(
1395
+ import_semi_ui7.Button,
1396
+ {
1397
+ disabled: readonly,
1398
+ size: "small",
1399
+ style: { marginTop: 10, marginLeft: 16 },
1400
+ icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconPlus, null),
1401
+ onClick: onAddProperty
1402
+ },
1403
+ config?.addButtonText ?? "Add"
1404
+ ));
1405
+ }
1406
+ function PropertyEdit(props) {
1407
+ const {
1408
+ value,
1409
+ config,
1410
+ readonly,
1411
+ $level = 0,
1412
+ onChange: onChangeProps,
1413
+ onRemove,
1414
+ $index,
1415
+ $isFirst,
1416
+ $isLast,
1417
+ $parentExpand = false,
1418
+ $parentType = "",
1419
+ $showLine
1420
+ } = props;
1421
+ const [expand, setExpand] = (0, import_react10.useState)(false);
1422
+ const [collapse, setCollapse] = (0, import_react10.useState)(false);
1423
+ const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
1424
+ const typeSelectorValue = (0, import_react10.useMemo)(() => ({ type, items }), [type, items]);
1425
+ const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1426
+ const onChange = (key, _value) => {
1427
+ onChangeProps?.({
1428
+ ...value || {},
1429
+ [key]: _value
1430
+ });
1431
+ };
1432
+ const showCollapse = isDrilldownObject && propertyList.length > 0;
1433
+ return /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
1434
+ UIPropertyLeft,
1435
+ {
1436
+ type,
1437
+ $index,
1438
+ $isFirst,
1439
+ $isLast,
1440
+ $showLine,
1441
+ $isExpand: expand,
1442
+ $parentExpand,
1443
+ $parentType
1444
+ },
1445
+ showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronRight, { size: "small" }))
1446
+ ), /* @__PURE__ */ import_react10.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react10.default.createElement(
1447
+ UIPropertyMain,
1448
+ {
1449
+ $showCollapse: showCollapse,
1450
+ $collapse: collapse,
1451
+ $expand: expand,
1452
+ type
1453
+ },
1454
+ /* @__PURE__ */ import_react10.default.createElement(UIRow, null, /* @__PURE__ */ import_react10.default.createElement(UIName, null, /* @__PURE__ */ import_react10.default.createElement(
1455
+ BlurInput,
1456
+ {
1457
+ disabled: readonly,
1458
+ placeholder: config?.placeholder ?? "Input Variable Name",
1459
+ size: "small",
1460
+ value: name,
1461
+ onChange: (value2) => onChange("name", value2)
1462
+ }
1463
+ )), /* @__PURE__ */ import_react10.default.createElement(UIType, null, /* @__PURE__ */ import_react10.default.createElement(
1464
+ TypeSelector,
1465
+ {
1466
+ value: typeSelectorValue,
1467
+ readonly,
1468
+ onChange: (_value) => {
1469
+ onChangeProps?.({
1470
+ ...value || {},
1471
+ ..._value
1472
+ });
1473
+ }
1474
+ }
1475
+ )), /* @__PURE__ */ import_react10.default.createElement(UIRequired, null, /* @__PURE__ */ import_react10.default.createElement(
1476
+ import_semi_ui7.Checkbox,
1477
+ {
1478
+ disabled: readonly,
1479
+ checked: isPropertyRequired,
1480
+ onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1481
+ }
1482
+ )), /* @__PURE__ */ import_react10.default.createElement(UIActions, null, /* @__PURE__ */ import_react10.default.createElement(
1483
+ import_semi_ui7.IconButton,
1484
+ {
1485
+ disabled: readonly,
1486
+ size: "small",
1487
+ theme: "borderless",
1488
+ icon: expand ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconExpand, { size: "small" }),
1489
+ onClick: () => {
1490
+ setExpand((_expand) => !_expand);
1491
+ }
1492
+ }
1493
+ ), isDrilldownObject && /* @__PURE__ */ import_react10.default.createElement(
1494
+ import_semi_ui7.IconButton,
1495
+ {
1496
+ disabled: readonly,
1497
+ size: "small",
1498
+ theme: "borderless",
1499
+ icon: /* @__PURE__ */ import_react10.default.createElement(IconAddChildren, null),
1500
+ onClick: () => {
1501
+ onAddProperty();
1502
+ setCollapse(true);
1503
+ }
1504
+ }
1505
+ ), /* @__PURE__ */ import_react10.default.createElement(
1506
+ import_semi_ui7.IconButton,
1507
+ {
1508
+ disabled: readonly,
1509
+ size: "small",
1510
+ theme: "borderless",
1511
+ icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconMinus, { size: "small" }),
1512
+ onClick: onRemove
1513
+ }
1514
+ ))),
1515
+ expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react10.default.createElement(
1516
+ BlurInput,
1517
+ {
1518
+ disabled: readonly,
1519
+ size: "small",
1520
+ value: description,
1521
+ onChange: (value2) => onChange("description", value2),
1522
+ placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
1523
+ }
1524
+ ), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ import_react10.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react10.default.createElement(
1525
+ DefaultValue,
1526
+ {
1527
+ value: defaultValue,
1528
+ schema: value,
1529
+ type,
1530
+ placeholder: config?.defaultValuePlaceholder,
1531
+ jsonFormatText: config?.jsonFormatText,
1532
+ onChange: (value2) => onChange("default", value2)
1533
+ }
1534
+ ))))
1535
+ ), showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
1536
+ PropertyEdit,
1537
+ {
1538
+ readonly,
1539
+ key: _property.key,
1540
+ value: _property,
1541
+ config,
1542
+ $level: $level + 1,
1543
+ $parentExpand: expand,
1544
+ $parentType: type,
1545
+ onChange: (_v) => {
1546
+ onEditProperty(_property.key, _v);
1547
+ },
1548
+ onRemove: () => {
1549
+ onRemoveProperty(_property.key);
1550
+ },
1551
+ $isLast: index === propertyList.length - 1,
1552
+ $isFirst: index === 0,
1553
+ $index: index,
1554
+ $showLine: true
1555
+ }
1556
+ ))))));
1557
+ }
1558
+
1559
+ // src/components/batch-variable-selector/index.tsx
1560
+ var import_react11 = __toESM(require("react"));
1561
+ var import_editor3 = require("@flowgram.ai/editor");
1562
+ var batchVariableSchema = {
1563
+ type: "array",
1564
+ extra: { weak: true }
1565
+ };
1566
+ function BatchVariableSelector(props) {
1567
+ return /* @__PURE__ */ import_react11.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react11.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1568
+ }
1569
+
1570
+ // src/components/dynamic-value-input/index.tsx
1571
+ var import_react12 = __toESM(require("react"));
1572
+ var import_editor4 = require("@flowgram.ai/editor");
1573
+ var import_semi_ui8 = require("@douyinfe/semi-ui");
1574
+ var import_semi_icons6 = require("@douyinfe/semi-icons");
1575
+
1576
+ // src/utils/format-legacy-refs/index.ts
1577
+ var import_lodash3 = require("lodash");
1578
+ function formatLegacyRefOnSubmit(value) {
1579
+ if ((0, import_lodash3.isObject)(value)) {
1580
+ if (isLegacyFlowRefValueSchema(value)) {
1581
+ return formatLegacyRefToNewRef(value);
1582
+ }
1583
+ return Object.fromEntries(
1584
+ Object.entries(value).map(([key, value2]) => [
1585
+ key,
1586
+ formatLegacyRefOnSubmit(value2)
1587
+ ])
1588
+ );
1589
+ }
1590
+ if (Array.isArray(value)) {
1591
+ return value.map(formatLegacyRefOnSubmit);
1592
+ }
1593
+ return value;
1594
+ }
1595
+ function formatLegacyRefOnInit(value) {
1596
+ if ((0, import_lodash3.isObject)(value)) {
1597
+ if (isNewFlowRefValueSchema(value)) {
1598
+ return formatNewRefToLegacyRef(value);
1599
+ }
1600
+ return Object.fromEntries(
1601
+ Object.entries(value).map(([key, value2]) => [
1602
+ key,
1603
+ formatLegacyRefOnInit(value2)
1604
+ ])
1605
+ );
1606
+ }
1607
+ if (Array.isArray(value)) {
1608
+ return value.map(formatLegacyRefOnInit);
1609
+ }
1610
+ return value;
1611
+ }
1612
+ function isLegacyFlowRefValueSchema(value) {
1613
+ return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1614
+ }
1615
+ function isNewFlowRefValueSchema(value) {
1616
+ return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1617
+ }
1618
+ function formatLegacyRefToNewRef(value) {
1619
+ const keyPath = value.content.split(".");
1620
+ if (keyPath[1] === "outputs") {
1621
+ return {
1622
+ type: "ref",
1623
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1624
+ };
1625
+ }
1626
+ return {
1627
+ type: "ref",
1628
+ content: keyPath
1629
+ };
1630
+ }
1631
+ function formatNewRefToLegacyRef(value) {
1632
+ return {
1633
+ type: "ref",
1634
+ content: value.content.join(".")
1635
+ };
1636
+ }
1637
+
1638
+ // src/components/dynamic-value-input/styles.tsx
1639
+ var import_styled_components3 = __toESM(require("styled-components"));
1640
+ var UIContainer2 = import_styled_components3.default.div`
1641
+ display: flex;
1642
+ align-items: center;
1643
+ border-radius: 4px;
1644
+ border: 1px solid var(--semi-color-border);
1645
+
1646
+ overflow: hidden;
1647
+
1648
+ background-color: var(--semi-color-fill-0);
1649
+ `;
1650
+ var UIMain = import_styled_components3.default.div`
1651
+ flex-grow: 1;
1652
+ overflow: hidden;
1653
+ min-width: 0;
1654
+
1655
+ & .semi-tree-select,
1656
+ & .semi-input-number,
1657
+ & .semi-select {
1658
+ width: 100%;
1659
+ border: none;
1660
+ border-radius: 0;
1661
+ }
1662
+
1663
+ & .semi-input-wrapper {
1664
+ border: none;
1665
+ border-radius: 0;
1666
+ }
1667
+ `;
1668
+ var UIType2 = import_styled_components3.default.div`
1669
+ border-right: 1px solid #e5e5e5;
1670
+
1671
+ & .semi-button {
1672
+ border-radius: 0;
1673
+ }
1674
+ `;
1675
+ var UITrigger = import_styled_components3.default.div`
1676
+ border-left: 1px solid #e5e5e5;
1677
+
1678
+ & .semi-button {
1679
+ border-radius: 0;
1680
+ }
1681
+ `;
1682
+
1683
+ // src/components/dynamic-value-input/index.tsx
1684
+ function DynamicValueInput({
1685
+ value,
1686
+ onChange,
1687
+ readonly,
1688
+ style,
1689
+ schema: schemaFromProps,
1690
+ constantProps
1691
+ }) {
1692
+ const available = (0, import_editor4.useScopeAvailable)();
1693
+ const refVariable = (0, import_react12.useMemo)(() => {
1694
+ if (value?.type === "ref") {
1695
+ return available.getByKeyPath(value.content);
1696
+ }
1697
+ }, [value, available]);
1698
+ const [selectSchema, setSelectSchema] = (0, import_react12.useState)(
1699
+ schemaFromProps || constantProps?.schema || { type: "string" }
1700
+ );
1701
+ const renderTypeSelector = () => {
1702
+ if (schemaFromProps) {
1703
+ return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1704
+ }
1705
+ if (value?.type === "ref") {
1706
+ const schema = refVariable?.type ? JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
1707
+ return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schema, readonly: true });
1708
+ }
1709
+ return /* @__PURE__ */ import_react12.default.createElement(
1710
+ TypeSelector,
1711
+ {
1712
+ value: selectSchema,
1713
+ onChange: (_v) => setSelectSchema(_v || { type: "string" }),
1714
+ readonly
1715
+ }
1716
+ );
1717
+ };
1718
+ const includeSchema = (0, import_react12.useMemo)(() => {
1719
+ if (!schemaFromProps) {
1720
+ return;
1721
+ }
1722
+ if (schemaFromProps?.type === "number") {
1723
+ return [schemaFromProps, { type: "integer" }];
1724
+ }
1725
+ return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
1726
+ }, [schemaFromProps]);
1727
+ const renderMain = () => {
1728
+ if (value?.type === "ref") {
1729
+ return /* @__PURE__ */ import_react12.default.createElement(
1730
+ VariableSelector,
1731
+ {
1732
+ style: { width: "100%" },
1733
+ value: value?.content,
1734
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1735
+ includeSchema,
1736
+ readonly
1737
+ }
1738
+ );
1739
+ }
1740
+ const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1741
+ return /* @__PURE__ */ import_react12.default.createElement(
1742
+ ConstantInput,
1743
+ {
1744
+ value: value?.content,
1745
+ onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1746
+ schema: constantSchema || { type: "string" },
1747
+ readonly,
1748
+ strategies: [...constantProps?.strategies || []],
1749
+ fallbackRenderer: () => /* @__PURE__ */ import_react12.default.createElement(
1750
+ VariableSelector,
1751
+ {
1752
+ style: { width: "100%" },
1753
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1754
+ includeSchema,
1755
+ readonly
1756
+ }
1757
+ ),
1758
+ ...constantProps
1759
+ }
1760
+ );
1761
+ };
1762
+ const renderTrigger = () => /* @__PURE__ */ import_react12.default.createElement(
1763
+ VariableSelector,
1764
+ {
1765
+ style: { width: "100%" },
1766
+ value: value?.type === "ref" ? value?.content : void 0,
1767
+ onChange: (_v) => onChange({ type: "ref", content: _v }),
1768
+ includeSchema,
1769
+ readonly,
1770
+ triggerRender: () => /* @__PURE__ */ import_react12.default.createElement(import_semi_ui8.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons6.IconSetting, { size: "small" }) })
1771
+ }
1772
+ );
1773
+ return /* @__PURE__ */ import_react12.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react12.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react12.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react12.default.createElement(UITrigger, null, renderTrigger()));
1774
+ }
1775
+
1776
+ // src/components/condition-row/index.tsx
1777
+ var import_react15 = __toESM(require("react"));
1778
+ var import_semi_ui10 = require("@douyinfe/semi-ui");
1779
+
1780
+ // src/components/condition-row/styles.tsx
1781
+ var import_styled_components4 = __toESM(require("styled-components"));
1782
+ var UIContainer3 = import_styled_components4.default.div`
1783
+ display: flex;
1784
+ align-items: center;
1785
+ gap: 4px;
1786
+ `;
1787
+ var UIOperator = import_styled_components4.default.div``;
1788
+ var UILeft = import_styled_components4.default.div`
1789
+ width: 100%;
1790
+ `;
1791
+ var UIRight = import_styled_components4.default.div`
1792
+ width: 100%;
1793
+ `;
1794
+ var UIValues = import_styled_components4.default.div`
1795
+ flex-grow: 1;
1796
+ display: flex;
1797
+ flex-direction: column;
1798
+ align-items: center;
1799
+ gap: 4px;
1800
+ `;
1801
+
1802
+ // src/components/condition-row/hooks/useRule.ts
1803
+ var import_react13 = require("react");
1804
+ var import_editor5 = require("@flowgram.ai/editor");
1805
+
1806
+ // src/components/condition-row/constants.ts
1807
+ var rules = {
1808
+ string: {
1809
+ ["eq" /* EQ */]: "string",
1810
+ ["neq" /* NEQ */]: "string",
1811
+ ["contains" /* CONTAINS */]: "string",
1812
+ ["not_contains" /* NOT_CONTAINS */]: "string",
1813
+ ["in" /* IN */]: "array",
1814
+ ["nin" /* NIN */]: "array",
1815
+ ["is_empty" /* IS_EMPTY */]: null,
1816
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1817
+ },
1818
+ number: {
1819
+ ["eq" /* EQ */]: "number",
1820
+ ["neq" /* NEQ */]: "number",
1821
+ ["gt" /* GT */]: "number",
1822
+ ["gte" /* GTE */]: "number",
1823
+ ["lt" /* LT */]: "number",
1824
+ ["lte" /* LTE */]: "number",
1825
+ ["in" /* IN */]: "array",
1826
+ ["nin" /* NIN */]: "array"
1827
+ },
1828
+ integer: {
1829
+ ["eq" /* EQ */]: "number",
1830
+ ["neq" /* NEQ */]: "number",
1831
+ ["gt" /* GT */]: "number",
1832
+ ["gte" /* GTE */]: "number",
1833
+ ["lt" /* LT */]: "number",
1834
+ ["lte" /* LTE */]: "number",
1835
+ ["in" /* IN */]: "array",
1836
+ ["nin" /* NIN */]: "array"
1837
+ },
1838
+ boolean: {
1839
+ ["eq" /* EQ */]: "boolean",
1840
+ ["neq" /* NEQ */]: "boolean",
1841
+ ["is_true" /* IS_TRUE */]: null,
1842
+ ["is_false" /* IS_FALSE */]: null,
1843
+ ["in" /* IN */]: "array",
1844
+ ["nin" /* NIN */]: "array"
1845
+ },
1846
+ object: {
1847
+ ["is_empty" /* IS_EMPTY */]: null,
1848
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1849
+ },
1850
+ array: {
1851
+ ["is_empty" /* IS_EMPTY */]: null,
1852
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1853
+ },
1854
+ map: {
1855
+ ["is_empty" /* IS_EMPTY */]: null,
1856
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1857
+ }
1858
+ };
1859
+ var opConfigs = {
1860
+ ["eq" /* EQ */]: {
1861
+ label: "Equal",
1862
+ abbreviation: "="
1863
+ },
1864
+ ["neq" /* NEQ */]: {
1865
+ label: "Not Equal",
1866
+ abbreviation: "\u2260"
1867
+ },
1868
+ ["gt" /* GT */]: {
1869
+ label: "Greater Than",
1870
+ abbreviation: ">"
1871
+ },
1872
+ ["gte" /* GTE */]: {
1873
+ label: "Greater Than or Equal",
1874
+ abbreviation: ">="
1875
+ },
1876
+ ["lt" /* LT */]: {
1877
+ label: "Less Than",
1878
+ abbreviation: "<"
1879
+ },
1880
+ ["lte" /* LTE */]: {
1881
+ label: "Less Than or Equal",
1882
+ abbreviation: "<="
1883
+ },
1884
+ ["in" /* IN */]: {
1885
+ label: "In",
1886
+ abbreviation: "\u2208"
1887
+ },
1888
+ ["nin" /* NIN */]: {
1889
+ label: "Not In",
1890
+ abbreviation: "\u2209"
1891
+ },
1892
+ ["contains" /* CONTAINS */]: {
1893
+ label: "Contains",
1894
+ abbreviation: "\u2287"
1895
+ },
1896
+ ["not_contains" /* NOT_CONTAINS */]: {
1897
+ label: "Not Contains",
1898
+ abbreviation: "\u2289"
1899
+ },
1900
+ ["is_empty" /* IS_EMPTY */]: {
1901
+ label: "Is Empty",
1902
+ abbreviation: "=",
1903
+ rightDisplay: "Empty"
1904
+ },
1905
+ ["is_not_empty" /* IS_NOT_EMPTY */]: {
1906
+ label: "Is Not Empty",
1907
+ abbreviation: "\u2260",
1908
+ rightDisplay: "Empty"
1909
+ },
1910
+ ["is_true" /* IS_TRUE */]: {
1911
+ label: "Is True",
1912
+ abbreviation: "=",
1913
+ rightDisplay: "True"
1914
+ },
1915
+ ["is_false" /* IS_FALSE */]: {
1916
+ label: "Is False",
1917
+ abbreviation: "=",
1918
+ rightDisplay: "False"
1919
+ }
1920
+ };
1921
+
1922
+ // src/components/condition-row/hooks/useRule.ts
1923
+ function useRule(left) {
1924
+ const available = (0, import_editor5.useScopeAvailable)();
1925
+ const variable = (0, import_react13.useMemo)(() => {
1926
+ if (!left) return void 0;
1927
+ return available.getByKeyPath(left.content);
1928
+ }, [available, left]);
1929
+ const rule = (0, import_react13.useMemo)(() => {
1930
+ if (!variable) return void 0;
1931
+ const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
1932
+ return rules[schema?.type];
1933
+ }, [variable?.type]);
1934
+ return { rule };
1935
+ }
1936
+
1937
+ // src/components/condition-row/hooks/useOp.tsx
1938
+ var import_react14 = __toESM(require("react"));
1939
+ var import_semi_ui9 = require("@douyinfe/semi-ui");
1940
+ var import_semi_icons7 = require("@douyinfe/semi-icons");
1941
+ function useOp({ rule, op, onChange }) {
1942
+ const options2 = (0, import_react14.useMemo)(
1943
+ () => Object.keys(rule || {}).map((_op) => ({
1944
+ ...opConfigs[_op] || {},
1945
+ value: _op
1946
+ })),
1947
+ [rule]
1948
+ );
1949
+ const opConfig = (0, import_react14.useMemo)(() => opConfigs[op], [op]);
1950
+ const renderOpSelect = () => /* @__PURE__ */ import_react14.default.createElement(
1951
+ import_semi_ui9.Select,
1952
+ {
1953
+ style: { height: 22 },
1954
+ size: "small",
1955
+ value: op,
1956
+ optionList: options2,
1957
+ onChange: (v) => {
1958
+ onChange(v);
1959
+ },
1960
+ triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui9.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react14.default.createElement(import_semi_icons7.IconChevronDownStroked, { size: "small" }))
1961
+ }
1962
+ );
1963
+ return { renderOpSelect, opConfig };
1964
+ }
1965
+
1966
+ // src/components/condition-row/index.tsx
1967
+ function ConditionRow({ style, value, onChange, readonly }) {
1968
+ const { left, operator, right } = value || {};
1969
+ const { rule } = useRule(left);
1970
+ const { renderOpSelect, opConfig } = useOp({
1971
+ rule,
1972
+ op: operator,
1973
+ onChange: (v) => onChange({ ...value, operator: v })
1974
+ });
1975
+ const targetSchema = (0, import_react15.useMemo)(() => {
1976
+ const targetType = rule?.[operator] || null;
1977
+ return targetType ? { type: targetType, extra: { weak: true } } : null;
1978
+ }, [rule, opConfig]);
1979
+ return /* @__PURE__ */ import_react15.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react15.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react15.default.createElement(UIValues, null, /* @__PURE__ */ import_react15.default.createElement(UILeft, null, /* @__PURE__ */ import_react15.default.createElement(
1980
+ VariableSelector,
1981
+ {
1982
+ readonly,
1983
+ style: { width: "100%" },
1984
+ value: left?.content,
1985
+ onChange: (v) => onChange({
1986
+ ...value,
1987
+ left: {
1988
+ type: "ref",
1989
+ content: v
1990
+ }
1991
+ })
1992
+ }
1993
+ )), /* @__PURE__ */ import_react15.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react15.default.createElement(
1994
+ DynamicValueInput,
1995
+ {
1996
+ readonly: readonly || !rule,
1997
+ value: right,
1998
+ schema: targetSchema,
1999
+ onChange: (v) => onChange({ ...value, right: v })
2000
+ }
2001
+ ) : /* @__PURE__ */ import_react15.default.createElement(
2002
+ import_semi_ui10.Input,
2003
+ {
2004
+ size: "small",
2005
+ disabled: true,
2006
+ style: { pointerEvents: "none" },
2007
+ value: opConfig?.rightDisplay || "Empty"
2008
+ }
2009
+ ))));
2010
+ }
2011
+
2012
+ // src/components/batch-outputs/index.tsx
2013
+ var import_react17 = __toESM(require("react"));
2014
+ var import_semi_ui11 = require("@douyinfe/semi-ui");
2015
+ var import_semi_icons8 = require("@douyinfe/semi-icons");
2016
+
2017
+ // src/hooks/use-object-list/index.tsx
2018
+ var import_react16 = require("react");
2019
+ var import_nanoid = require("nanoid");
2020
+ var import_lodash4 = require("lodash");
2021
+ function genId2() {
2022
+ return (0, import_nanoid.nanoid)();
2023
+ }
2024
+ function useObjectList({
2025
+ value,
2026
+ onChange,
2027
+ sortIndexKey
2028
+ }) {
2029
+ const [list, setList] = (0, import_react16.useState)([]);
2030
+ (0, import_react16.useEffect)(() => {
2031
+ setList((_prevList) => {
2032
+ const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash4.get)(a[1], sortIndexKey || 0) - (0, import_lodash4.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
2033
+ const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
2034
+ const addKeys = (0, import_lodash4.difference)(newKeys, oldKeys);
2035
+ return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
2036
+ id: item.id,
2037
+ key: item.key,
2038
+ value: item.key ? value?.[item.key] : item.value
2039
+ })).concat(
2040
+ addKeys.map((_key) => ({
2041
+ id: genId2(),
2042
+ key: _key,
2043
+ value: value?.[_key]
2044
+ }))
2045
+ );
2046
+ });
2047
+ }, [value]);
2048
+ const add = () => {
2049
+ setList((prevList) => [
2050
+ ...prevList,
2051
+ {
2052
+ id: genId2()
2053
+ }
2054
+ ]);
2055
+ };
2056
+ const updateValue = (itemId, value2) => {
2057
+ setList((prevList) => {
2058
+ const nextList = prevList.map((_item) => {
2059
+ if (_item.id === itemId) {
2060
+ return {
2061
+ ..._item,
2062
+ value: value2
2063
+ };
2064
+ }
2065
+ return _item;
2066
+ });
2067
+ onChange(
2068
+ Object.fromEntries(
2069
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
2070
+ if ((0, import_lodash4.isObject)(_res[1]) && sortIndexKey) {
2071
+ (0, import_lodash4.set)(_res[1], sortIndexKey, idx);
2072
+ }
2073
+ return _res;
2074
+ })
2075
+ )
2076
+ );
2077
+ return nextList;
2078
+ });
2079
+ };
2080
+ const updateKey = (itemId, key) => {
2081
+ setList((prevList) => {
2082
+ const nextList = prevList.map((_item) => {
2083
+ if (_item.id === itemId) {
2084
+ return {
2085
+ ..._item,
2086
+ key
2087
+ };
2088
+ }
2089
+ return _item;
2090
+ });
2091
+ onChange(
2092
+ Object.fromEntries(
2093
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
2094
+ )
2095
+ );
2096
+ return nextList;
2097
+ });
2098
+ };
2099
+ const remove = (itemId) => {
2100
+ setList((prevList) => {
2101
+ const nextList = prevList.filter((_item) => _item.id !== itemId);
2102
+ onChange(
2103
+ Object.fromEntries(
2104
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
2105
+ )
2106
+ );
2107
+ return nextList;
2108
+ });
2109
+ };
2110
+ return { list, add, updateKey, updateValue, remove };
2111
+ }
2112
+
2113
+ // src/components/batch-outputs/styles.tsx
2114
+ var import_styled_components5 = __toESM(require("styled-components"));
2115
+ var UIRows = import_styled_components5.default.div`
2116
+ display: flex;
2117
+ flex-direction: column;
2118
+ gap: 10px;
2119
+ margin-bottom: 10px;
2120
+ `;
2121
+ var UIRow2 = import_styled_components5.default.div`
2122
+ display: flex;
2123
+ align-items: center;
2124
+ gap: 5px;
2125
+ `;
2126
+
2127
+ // src/components/batch-outputs/index.tsx
2128
+ function BatchOutputs(props) {
2129
+ const { readonly, style } = props;
2130
+ const { list, add, updateKey, updateValue, remove } = useObjectList(props);
2131
+ return /* @__PURE__ */ import_react17.default.createElement("div", null, /* @__PURE__ */ import_react17.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react17.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react17.default.createElement(
2132
+ import_semi_ui11.Input,
2133
+ {
2134
+ style: { width: 100 },
2135
+ disabled: readonly,
2136
+ size: "small",
2137
+ value: item.key,
2138
+ onChange: (v) => updateKey(item.id, v)
2139
+ }
2140
+ ), /* @__PURE__ */ import_react17.default.createElement(
2141
+ VariableSelector,
2142
+ {
2143
+ style: { flexGrow: 1 },
2144
+ readonly,
2145
+ value: item.value?.content,
2146
+ onChange: (v) => updateValue(item.id, { type: "ref", content: v })
2147
+ }
2148
+ ), /* @__PURE__ */ import_react17.default.createElement(
2149
+ import_semi_ui11.Button,
2150
+ {
2151
+ disabled: readonly,
2152
+ icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconDelete, null),
2153
+ size: "small",
2154
+ onClick: () => remove(item.id)
2155
+ }
2156
+ )))), /* @__PURE__ */ import_react17.default.createElement(import_semi_ui11.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconPlus, null), size: "small", onClick: add }, "Add"));
2157
+ }
2158
+
2159
+ // src/components/prompt-editor/index.tsx
2160
+ var import_react24 = __toESM(require("react"));
2161
+ var import_react25 = require("@coze-editor/editor/react");
2162
+ var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
2163
+
2164
+ // src/components/prompt-editor/styles.tsx
2165
+ var import_styled_components6 = __toESM(require("styled-components"));
2166
+ var UIContainer4 = import_styled_components6.default.div`
2167
+ background-color: var(--semi-color-fill-0);
2168
+ padding-left: 10px;
2169
+ padding-right: 6px;
2170
+
2171
+ ${({ $hasError }) => $hasError && import_styled_components6.css`
2172
+ border: 1px solid var(--semi-color-danger-6);
2173
+ `}
2174
+ `;
2175
+
2176
+ // src/components/prompt-editor/extensions/markdown.tsx
2177
+ var import_react18 = require("react");
2178
+ var import_react19 = require("@coze-editor/editor/react");
2179
+ var import_editor6 = require("@coze-editor/editor");
2180
+ var import_view = require("@codemirror/view");
2181
+ function MarkdownHighlight() {
2182
+ const injector = (0, import_react19.useInjector)();
2183
+ (0, import_react18.useLayoutEffect)(
2184
+ () => injector.inject([
2185
+ import_editor6.astDecorator.whole.of((cursor) => {
2186
+ if (cursor.name.startsWith("ATXHeading")) {
2187
+ return {
2188
+ type: "className",
2189
+ className: "heading"
2190
+ };
2191
+ }
2192
+ if (cursor.name === "Emphasis") {
2193
+ return {
2194
+ type: "className",
2195
+ className: "emphasis"
2196
+ };
2197
+ }
2198
+ if (cursor.name === "StrongEmphasis") {
2199
+ return {
2200
+ type: "className",
2201
+ className: "strong-emphasis"
2202
+ };
2203
+ }
2204
+ if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
2205
+ return {
2206
+ type: "className",
2207
+ className: "mark"
2208
+ };
2209
+ }
2210
+ }),
2211
+ import_view.EditorView.theme({
2212
+ ".heading": {
2213
+ color: "#00818C",
2214
+ fontWeight: "bold"
2215
+ },
2216
+ ".emphasis": {
2217
+ fontStyle: "italic"
2218
+ },
2219
+ ".strong-emphasis": {
2220
+ fontWeight: "bold"
2221
+ },
2222
+ ".mark": {
2223
+ color: "#4E40E5"
2224
+ }
2225
+ })
2226
+ ]),
2227
+ [injector]
2228
+ );
2229
+ return null;
2230
+ }
2231
+ var markdown_default = MarkdownHighlight;
2232
+
2233
+ // src/components/prompt-editor/extensions/language-support.tsx
2234
+ var import_react20 = require("react");
2235
+ var import_react21 = require("@coze-editor/editor/react");
2236
+ var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
2237
+ function LanguageSupport() {
2238
+ const injector = (0, import_react21.useInjector)();
2239
+ (0, import_react20.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
2240
+ return null;
2241
+ }
2242
+ var language_support_default = LanguageSupport;
2243
+
2244
+ // src/components/prompt-editor/extensions/jinja.tsx
2245
+ var import_react22 = require("react");
2246
+ var import_react23 = require("@coze-editor/editor/react");
2247
+ var import_editor7 = require("@coze-editor/editor");
2248
+ var import_view2 = require("@codemirror/view");
2249
+ function JinjaHighlight() {
2250
+ const injector = (0, import_react23.useInjector)();
2251
+ (0, import_react22.useLayoutEffect)(
2252
+ () => injector.inject([
2253
+ import_editor7.astDecorator.whole.of((cursor) => {
2254
+ if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
2255
+ return {
2256
+ type: "className",
2257
+ className: "jinja-statement-bracket"
2258
+ };
2259
+ }
2260
+ if (cursor.name === "JinjaComment") {
2261
+ return {
2262
+ type: "className",
2263
+ className: "jinja-comment"
2264
+ };
2265
+ }
2266
+ if (cursor.name === "JinjaExpression") {
2267
+ return {
2268
+ type: "className",
2269
+ className: "jinja-expression"
2270
+ };
2271
+ }
2272
+ }),
2273
+ import_view2.EditorView.theme({
2274
+ ".jinja-statement-bracket": {
2275
+ color: "#D1009D"
2276
+ },
2277
+ ".jinja-comment": {
2278
+ color: "#0607094D"
2279
+ },
2280
+ ".jinja-expression": {
2281
+ color: "#4E40E5"
2282
+ }
2283
+ })
2284
+ ]),
2285
+ [injector]
2286
+ );
2287
+ return null;
2288
+ }
2289
+ var jinja_default = JinjaHighlight;
2290
+
2291
+ // src/components/prompt-editor/index.tsx
2292
+ function PromptEditor(props) {
2293
+ const {
2294
+ value,
2295
+ onChange,
2296
+ readonly,
2297
+ placeholder,
2298
+ activeLinePlaceholder,
2299
+ style,
2300
+ hasError,
2301
+ children,
2302
+ disableMarkdownHighlight
2303
+ } = props || {};
2304
+ const editorRef = (0, import_react24.useRef)(null);
2305
+ (0, import_react24.useEffect)(() => {
2306
+ if (editorRef.current?.getValue() !== value?.content) {
2307
+ editorRef.current?.setValue(String(value?.content || ""));
2308
+ }
2309
+ }, [value]);
2310
+ return /* @__PURE__ */ import_react24.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react24.default.createElement(import_react25.EditorProvider, null, /* @__PURE__ */ import_react24.default.createElement(
2311
+ import_react25.Renderer,
2312
+ {
2313
+ didMount: (editor) => {
2314
+ editorRef.current = editor;
2315
+ },
2316
+ plugins: import_preset_prompt2.default,
2317
+ defaultValue: String(value?.content),
2318
+ options: {
2319
+ readOnly: readonly,
2320
+ editable: !readonly,
2321
+ placeholder
2322
+ },
2323
+ onChange: (e) => {
2324
+ onChange({ type: "template", content: e.value });
2325
+ }
2326
+ }
2327
+ ), activeLinePlaceholder && /* @__PURE__ */ import_react24.default.createElement(import_react25.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react24.default.createElement(markdown_default, null), /* @__PURE__ */ import_react24.default.createElement(language_support_default, null), /* @__PURE__ */ import_react24.default.createElement(jinja_default, null), children));
2328
+ }
2329
+
2330
+ // src/components/prompt-editor-with-variables/index.tsx
2331
+ var import_react30 = __toESM(require("react"));
2332
+
2333
+ // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2334
+ var import_react26 = __toESM(require("react"));
2335
+ var import_semi_ui12 = require("@douyinfe/semi-ui");
2336
+ var import_react27 = require("@coze-editor/editor/react");
2337
+ function VariableTree() {
2338
+ const [posKey, setPosKey] = (0, import_react26.useState)("");
2339
+ const [visible, setVisible] = (0, import_react26.useState)(false);
2340
+ const [position, setPosition] = (0, import_react26.useState)(-1);
2341
+ const editor = (0, import_react27.useEditor)();
2342
+ function insert(variablePath) {
2343
+ const range = (0, import_react27.getCurrentMentionReplaceRange)(editor.$view.state);
2344
+ if (!range) {
2345
+ return;
2346
+ }
2347
+ editor.replaceText({
2348
+ ...range,
2349
+ text: "{{" + variablePath + "}}"
2350
+ });
2351
+ setVisible(false);
2352
+ }
2353
+ function handleOpenChange(e) {
2354
+ setPosition(e.state.selection.main.head);
2355
+ setVisible(e.value);
2356
+ }
2357
+ (0, import_react26.useEffect)(() => {
2358
+ if (!editor) {
2359
+ return;
2360
+ }
2361
+ }, [editor, visible]);
2362
+ const treeData = useVariableTree({});
2363
+ return /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(import_react27.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react26.default.createElement(
2364
+ import_semi_ui12.Popover,
2365
+ {
2366
+ visible,
2367
+ trigger: "custom",
2368
+ position: "topLeft",
2369
+ rePosKey: posKey,
2370
+ content: /* @__PURE__ */ import_react26.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react26.default.createElement(
2371
+ import_semi_ui12.Tree,
2372
+ {
2373
+ treeData,
2374
+ onSelect: (v) => {
2375
+ insert(v);
2376
+ }
2377
+ }
2378
+ ))
2379
+ },
2380
+ /* @__PURE__ */ import_react26.default.createElement(
2381
+ import_react27.PositionMirror,
2382
+ {
2383
+ position,
2384
+ onChange: () => setPosKey(String(Math.random()))
2385
+ }
2386
+ )
2387
+ ));
2388
+ }
2389
+
2390
+ // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2391
+ var import_react_dom = __toESM(require("react-dom"));
2392
+ var import_react28 = __toESM(require("react"));
2393
+ var import_lodash5 = require("lodash");
2394
+ var import_editor8 = require("@flowgram.ai/editor");
2395
+ var import_semi_ui14 = require("@douyinfe/semi-ui");
2396
+ var import_semi_icons9 = require("@douyinfe/semi-icons");
2397
+ var import_react29 = require("@coze-editor/editor/react");
2398
+ var import_view3 = require("@codemirror/view");
2399
+
2400
+ // src/components/prompt-editor-with-variables/styles.tsx
2401
+ var import_styled_components7 = __toESM(require("styled-components"));
2402
+ var import_semi_ui13 = require("@douyinfe/semi-ui");
2403
+ var UIRootTitle2 = import_styled_components7.default.div`
2404
+ margin-right: 4px;
2405
+ min-width: 20px;
2406
+ overflow: hidden;
2407
+ text-overflow: ellipsis;
2408
+ white-space: nowrap;
2409
+ color: var(--semi-color-text-2);
2410
+ `;
2411
+ var UIVarName2 = import_styled_components7.default.div`
2412
+ overflow: hidden;
2413
+ text-overflow: ellipsis;
2414
+ white-space: nowrap;
2415
+ `;
2416
+ var UITag2 = (0, import_styled_components7.default)(import_semi_ui13.Tag)`
2417
+ display: inline-flex;
2418
+ align-items: center;
2419
+ justify-content: flex-start;
2420
+ max-width: 300px;
2421
+
2422
+ & .semi-tag-content-center {
2423
+ justify-content: flex-start;
2424
+ }
2425
+
2426
+ &.semi-tag {
2427
+ margin: 0 5px;
2428
+ }
2429
+ `;
2430
+ var UIPopoverContent2 = import_styled_components7.default.div`
2431
+ padding: 10px;
2432
+ display: inline-flex;
2433
+ align-items: center;
2434
+ justify-content: flex-start;
2435
+ `;
2436
+
2437
+ // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2438
+ var VariableTagWidget = class extends import_view3.WidgetType {
2439
+ constructor({ keyPath, scope }) {
2440
+ super();
2441
+ this.toDispose = new import_editor8.DisposableCollection();
2442
+ this.renderIcon = (icon) => {
2443
+ if (typeof icon === "string") {
2444
+ return /* @__PURE__ */ import_react28.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2445
+ }
2446
+ return icon;
2447
+ };
2448
+ this.keyPath = keyPath;
2449
+ this.scope = scope;
2450
+ }
2451
+ renderReact(jsx) {
2452
+ import_react_dom.default.render(jsx, this.rootDOM);
2453
+ }
2454
+ renderVariable(v) {
2455
+ if (!v) {
2456
+ this.renderReact(
2457
+ /* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons9.IconIssueStroked, null), color: "amber" }, "Unknown")
2458
+ );
2459
+ return;
2460
+ }
2461
+ const rootField = (0, import_lodash5.last)(v.parentFields) || v;
2462
+ const isRoot = v.parentFields.length === 0;
2463
+ const rootTitle = /* @__PURE__ */ import_react28.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2464
+ const rootIcon = this.renderIcon(rootField?.meta.icon);
2465
+ this.renderReact(
2466
+ /* @__PURE__ */ import_react28.default.createElement(
2467
+ import_semi_ui14.Popover,
2468
+ {
2469
+ content: /* @__PURE__ */ import_react28.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2470
+ },
2471
+ /* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.key))
2472
+ )
2473
+ );
2474
+ }
2475
+ toDOM(view) {
2476
+ const dom = document.createElement("span");
2477
+ this.rootDOM = dom;
2478
+ this.toDispose.push(
2479
+ import_editor8.Disposable.create(() => {
2480
+ import_react_dom.default.unmountComponentAtNode(this.rootDOM);
2481
+ })
2482
+ );
2483
+ this.toDispose.push(
2484
+ this.scope.available.trackByKeyPath(
2485
+ this.keyPath,
2486
+ (v) => {
2487
+ this.renderVariable(v);
2488
+ },
2489
+ { triggerOnInit: false }
2490
+ )
2491
+ );
2492
+ this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
2493
+ return dom;
2494
+ }
2495
+ eq(other) {
2496
+ return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
2497
+ }
2498
+ ignoreEvent() {
2499
+ return false;
2500
+ }
2501
+ destroy(dom) {
2502
+ this.toDispose.dispose();
2503
+ }
2504
+ };
2505
+ function VariableTagInject() {
2506
+ const injector = (0, import_react29.useInjector)();
2507
+ const scope = (0, import_editor8.useCurrentScope)();
2508
+ (0, import_react28.useLayoutEffect)(() => {
2509
+ const atMatcher = new import_view3.MatchDecorator({
2510
+ regexp: /\{\{([^\}]+)\}\}/g,
2511
+ decoration: (match) => import_view3.Decoration.replace({
2512
+ widget: new VariableTagWidget({
2513
+ keyPath: match[1]?.split(".") ?? [],
2514
+ scope
2515
+ })
2516
+ })
2517
+ });
2518
+ return injector.inject([
2519
+ import_view3.ViewPlugin.fromClass(
2520
+ class {
2521
+ constructor(view) {
2522
+ this.view = view;
2523
+ this.decorations = atMatcher.createDeco(view);
2524
+ }
2525
+ update() {
2526
+ this.decorations = atMatcher.createDeco(this.view);
2527
+ }
2528
+ },
2529
+ {
2530
+ decorations: (p) => p.decorations,
2531
+ provide(p) {
2532
+ return import_view3.EditorView.atomicRanges.of(
2533
+ (view) => view.plugin(p)?.decorations ?? import_view3.Decoration.none
2534
+ );
2535
+ }
2536
+ }
2537
+ )
2538
+ ]);
2539
+ }, [injector]);
2540
+ return null;
2541
+ }
2542
+
2543
+ // src/components/prompt-editor-with-variables/index.tsx
2544
+ function PromptEditorWithVariables(props) {
2545
+ return /* @__PURE__ */ import_react30.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react30.default.createElement(VariableTree, null), /* @__PURE__ */ import_react30.default.createElement(VariableTagInject, null));
2546
+ }
2547
+
2548
+ // src/components/prompt-editor-with-inputs/index.tsx
2549
+ var import_react34 = __toESM(require("react"));
2550
+
2551
+ // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2552
+ var import_react32 = __toESM(require("react"));
2553
+ var import_semi_ui16 = require("@douyinfe/semi-ui");
2554
+ var import_react33 = require("@coze-editor/editor/react");
2555
+
2556
+ // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2557
+ var import_react31 = __toESM(require("react"));
2558
+ var import_lodash6 = require("lodash");
2559
+ var import_editor9 = require("@flowgram.ai/editor");
2560
+ var import_semi_ui15 = require("@douyinfe/semi-ui");
2561
+ function InputsPicker({
2562
+ inputsValues,
2563
+ onSelect
2564
+ }) {
2565
+ const available = (0, import_editor9.useScopeAvailable)();
2566
+ const getArrayDrilldown = (type, depth = 1) => {
2567
+ if (import_editor9.ASTMatch.isArray(type.items)) {
2568
+ return getArrayDrilldown(type.items, depth + 1);
2569
+ }
2570
+ return { type: type.items, depth };
2571
+ };
2572
+ const renderVariable = (variable, keyPath) => {
2573
+ let type = variable?.type;
2574
+ let children;
2575
+ if (import_editor9.ASTMatch.isObject(type)) {
2576
+ children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
2577
+ }
2578
+ if (import_editor9.ASTMatch.isArray(type)) {
2579
+ const drilldown = getArrayDrilldown(type);
2580
+ if (import_editor9.ASTMatch.isObject(drilldown.type)) {
2581
+ children = (drilldown.type.properties || []).map(
2582
+ (_property) => renderVariable(_property, [
2583
+ ...keyPath,
2584
+ ...new Array(drilldown.depth).fill("[0]"),
2585
+ _property.key
2586
+ ])
2587
+ ).filter(Boolean);
2588
+ }
2589
+ }
2590
+ const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
2591
+ return {
2592
+ key,
2593
+ label: (0, import_lodash6.last)(keyPath),
2594
+ value: key,
2595
+ children
2596
+ };
2597
+ };
2598
+ const treeData = (0, import_react31.useMemo)(
2599
+ () => Object.entries(inputsValues).map(([key, value]) => {
2600
+ if (value?.type === "ref") {
2601
+ const variable = available.getByKeyPath(value.content || []);
2602
+ if (variable) {
2603
+ return renderVariable(variable, [key]);
2604
+ }
2605
+ }
2606
+ return {
2607
+ key,
2608
+ value: key,
2609
+ label: key
2610
+ };
2611
+ }),
2612
+ []
2613
+ );
2614
+ return /* @__PURE__ */ import_react31.default.createElement(import_semi_ui15.Tree, { treeData, onSelect: (v) => onSelect(v) });
2615
+ }
2616
+
2617
+ // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2618
+ function InputsTree({ inputsValues }) {
2619
+ const [posKey, setPosKey] = (0, import_react32.useState)("");
2620
+ const [visible, setVisible] = (0, import_react32.useState)(false);
2621
+ const [position, setPosition] = (0, import_react32.useState)(-1);
2622
+ const editor = (0, import_react33.useEditor)();
2623
+ function insert(variablePath) {
2624
+ const range = (0, import_react33.getCurrentMentionReplaceRange)(editor.$view.state);
2625
+ if (!range) {
2626
+ return;
2627
+ }
2628
+ editor.replaceText({
2629
+ ...range,
2630
+ text: "{{" + variablePath + "}}"
2631
+ });
2632
+ setVisible(false);
2633
+ }
2634
+ function handleOpenChange(e) {
2635
+ setPosition(e.state.selection.main.head);
2636
+ setVisible(e.value);
2637
+ }
2638
+ (0, import_react32.useEffect)(() => {
2639
+ if (!editor) {
2640
+ return;
2641
+ }
2642
+ }, [editor, visible]);
2643
+ return /* @__PURE__ */ import_react32.default.createElement(import_react32.default.Fragment, null, /* @__PURE__ */ import_react32.default.createElement(import_react33.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react32.default.createElement(
2644
+ import_semi_ui16.Popover,
2645
+ {
2646
+ visible,
2647
+ trigger: "custom",
2648
+ position: "topLeft",
2649
+ rePosKey: posKey,
2650
+ content: /* @__PURE__ */ import_react32.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react32.default.createElement(
2651
+ InputsPicker,
2652
+ {
2653
+ inputsValues,
2654
+ onSelect: (v) => {
2655
+ insert(v);
2656
+ }
2657
+ }
2658
+ ))
2659
+ },
2660
+ /* @__PURE__ */ import_react32.default.createElement(
2661
+ import_react33.PositionMirror,
2662
+ {
2663
+ position,
2664
+ onChange: () => setPosKey(String(Math.random()))
2665
+ }
2666
+ )
2667
+ ));
2668
+ }
2669
+
2670
+ // src/components/prompt-editor-with-inputs/index.tsx
2671
+ function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2672
+ return /* @__PURE__ */ import_react34.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react34.default.createElement(InputsTree, { inputsValues }));
2673
+ }
2674
+
2675
+ // src/components/code-editor/index.tsx
2676
+ var import_react35 = __toESM(require("react"));
2677
+ var import_react36 = require("@coze-editor/editor/react");
2678
+ var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
2679
+ var import_view4 = require("@codemirror/view");
2680
+
2681
+ // src/components/code-editor/utils.ts
2682
+ function getSuffixByLanguageId(languageId) {
2683
+ if (languageId === "python") {
2684
+ return ".py";
2685
+ }
2686
+ if (languageId === "typescript") {
2687
+ return ".ts";
2688
+ }
2689
+ if (languageId === "shell") {
2690
+ return ".sh";
2691
+ }
2692
+ if (languageId === "json") {
2693
+ return ".json";
2694
+ }
2695
+ return "";
2696
+ }
2697
+
2698
+ // src/components/code-editor/language-features.ts
2699
+ var import_preset_code = require("@coze-editor/editor/preset-code");
2700
+ var import_language_typescript = require("@coze-editor/editor/language-typescript");
2701
+ var import_language_shell = require("@coze-editor/editor/language-shell");
2702
+ var import_language_python = require("@coze-editor/editor/language-python");
2703
+ var import_language_json = require("@coze-editor/editor/language-json");
2704
+ var import_editor10 = require("@coze-editor/editor");
2705
+ import_preset_code.languages.register("python", import_language_python.python);
2706
+ import_preset_code.languages.register("shell", import_language_shell.shell);
2707
+ import_preset_code.languages.register("typescript", import_language_typescript.typescript);
2708
+ import_preset_code.languages.register("json", {
2709
+ // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
2710
+ language: (0, import_editor10.mixLanguages)({
2711
+ outerLanguage: import_language_json.json.language
2712
+ }),
2713
+ languageService: import_language_json.json.languageService
2714
+ });
2715
+ var tsWorkerInit = false;
2716
+ var initTsWorker = () => {
2717
+ if (tsWorkerInit) {
2718
+ return;
2719
+ }
2720
+ tsWorkerInit = true;
2721
+ const tsWorker = new Worker(
2722
+ new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
2723
+ { type: "module" }
2724
+ );
2725
+ import_language_typescript.typescript.languageService.initialize(tsWorker, {
2726
+ compilerOptions: {
2727
+ // eliminate Promise error
2728
+ lib: ["es2015", "dom"],
2729
+ noImplicitAny: false
2730
+ }
2731
+ });
2732
+ };
2733
+
2734
+ // src/components/code-editor/theme/index.ts
2735
+ var import_preset_code4 = require("@coze-editor/editor/preset-code");
2736
+
2737
+ // src/components/code-editor/theme/light.ts
2738
+ var import_preset_code2 = require("@coze-editor/editor/preset-code");
2739
+ var colors = {
2740
+ background: "#F7F7FC",
2741
+ // syntax
2742
+ comment: "#000A298A",
2743
+ key: "#00818C",
2744
+ string: "#D1009D",
2745
+ number: "#C74200",
2746
+ boolean: "#2B57D9",
2747
+ null: "#2B57D9",
2748
+ separator: "#0F1529D1"
2749
+ };
2750
+ var lightTheme = (0, import_preset_code2.createTheme)({
2751
+ variant: "light",
2752
+ settings: {
2753
+ background: "#fff",
2754
+ foreground: "#000",
2755
+ caret: "#000",
2756
+ selection: "#d9d9d9",
2757
+ gutterBackground: "#f0f0f0",
2758
+ gutterForeground: "#666",
2759
+ gutterBorderColor: "transparent",
2760
+ gutterBorderWidth: 0,
2761
+ lineHighlight: "#f0f0f0",
2762
+ bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
2763
+ tooltip: {
2764
+ backgroundColor: "#f0f0f0",
2765
+ color: "#000",
2766
+ border: "1px solid #ccc"
2767
+ },
2768
+ link: {
2769
+ color: "#007bff"
2770
+ },
2771
+ completionItemHover: {
2772
+ backgroundColor: "#f0f0f0"
2773
+ },
2774
+ completionItemSelected: {
2775
+ backgroundColor: "#e0e0e0"
2776
+ },
2777
+ completionItemIcon: {
2778
+ color: "#333"
2779
+ },
2780
+ completionItemLabel: {
2781
+ color: "#333"
2782
+ },
2783
+ completionItemInfo: {
2784
+ color: "#333"
2785
+ },
2786
+ completionItemDetail: {
2787
+ color: "#666"
2788
+ }
2789
+ },
2790
+ styles: [
2791
+ // JSON
2792
+ {
2793
+ tag: import_preset_code2.tags.comment,
2794
+ color: colors.comment
2795
+ },
2796
+ {
2797
+ tag: [import_preset_code2.tags.propertyName],
2798
+ color: colors.key
2799
+ },
2800
+ {
2801
+ tag: [import_preset_code2.tags.string],
2802
+ color: colors.string
2803
+ },
2804
+ {
2805
+ tag: [import_preset_code2.tags.number],
2806
+ color: colors.number
2807
+ },
2808
+ {
2809
+ tag: [import_preset_code2.tags.bool],
2810
+ color: colors.boolean
2811
+ },
2812
+ {
2813
+ tag: [import_preset_code2.tags.null],
2814
+ color: colors.null
2815
+ },
2816
+ {
2817
+ tag: [import_preset_code2.tags.separator],
2818
+ color: colors.separator
2819
+ },
2820
+ // markdown
2821
+ {
2822
+ tag: [import_preset_code2.tags.heading],
2823
+ color: "#3e76ef"
2824
+ },
2825
+ {
2826
+ tag: [import_preset_code2.tags.processingInstruction],
2827
+ color: "#3e76ef"
2828
+ },
2829
+ // shell
2830
+ // curl
2831
+ {
2832
+ tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
2833
+ color: "#00804A"
2834
+ },
2835
+ // -X
2836
+ {
2837
+ tag: [import_preset_code2.tags.attributeName],
2838
+ color: "#C74200"
2839
+ },
2840
+ // url in string (includes quotes), e.g. "https://..."
2841
+ {
2842
+ tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
2843
+ color: "#2B57D9"
2844
+ }
2845
+ ]
2846
+ });
2847
+
2848
+ // src/components/code-editor/theme/dark.ts
2849
+ var import_preset_code3 = require("@coze-editor/editor/preset-code");
2850
+ var colors2 = {
2851
+ background: "#151B27",
2852
+ // syntax
2853
+ comment: "#FFFFFF63",
2854
+ key: "#39E5D7",
2855
+ string: "#FF94D2",
2856
+ number: "#FF9933",
2857
+ boolean: "#78B0FF",
2858
+ null: "#78B0FF",
2859
+ separator: "#FFFFFFC9"
2860
+ };
2861
+ var darkTheme = (0, import_preset_code3.createTheme)({
2862
+ variant: "dark",
2863
+ settings: {
2864
+ background: colors2.background,
2865
+ foreground: "#fff",
2866
+ caret: "#AEAFAD",
2867
+ selection: "#d9d9d942",
2868
+ gutterBackground: colors2.background,
2869
+ gutterForeground: "#FFFFFF63",
2870
+ gutterBorderColor: "transparent",
2871
+ gutterBorderWidth: 0,
2872
+ lineHighlight: "#272e3d36",
2873
+ bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
2874
+ tooltip: {
2875
+ backgroundColor: "#363D4D",
2876
+ color: "#fff",
2877
+ border: "none"
2878
+ },
2879
+ link: {
2880
+ color: "#4daafc"
2881
+ },
2882
+ completionItemHover: {
2883
+ backgroundColor: "#FFFFFF0F"
2884
+ },
2885
+ completionItemSelected: {
2886
+ backgroundColor: "#FFFFFF17"
2887
+ },
2888
+ completionItemIcon: {
2889
+ color: "#FFFFFFC9"
2890
+ },
2891
+ completionItemLabel: {
2892
+ color: "#FFFFFFC9"
2893
+ },
2894
+ completionItemInfo: {
2895
+ color: "#FFFFFFC9"
2896
+ },
2897
+ completionItemDetail: {
2898
+ color: "#FFFFFF63"
2899
+ }
2900
+ },
2901
+ styles: [
2902
+ // json
2903
+ {
2904
+ tag: import_preset_code3.tags.comment,
2905
+ color: colors2.comment
2906
+ },
2907
+ {
2908
+ tag: [import_preset_code3.tags.propertyName],
2909
+ color: colors2.key
2910
+ },
2911
+ {
2912
+ tag: [import_preset_code3.tags.string],
2913
+ color: colors2.string
2914
+ },
2915
+ {
2916
+ tag: [import_preset_code3.tags.number],
2917
+ color: colors2.number
2918
+ },
2919
+ {
2920
+ tag: [import_preset_code3.tags.bool],
2921
+ color: colors2.boolean
2922
+ },
2923
+ {
2924
+ tag: [import_preset_code3.tags.null],
2925
+ color: colors2.null
2926
+ },
2927
+ {
2928
+ tag: [import_preset_code3.tags.separator],
2929
+ color: colors2.separator
2930
+ },
2931
+ // markdown
2932
+ {
2933
+ tag: [import_preset_code3.tags.heading],
2934
+ color: "#6b6bff"
2935
+ },
2936
+ {
2937
+ tag: [import_preset_code3.tags.processingInstruction],
2938
+ color: "#6b6bff"
2939
+ },
2940
+ // shell
2941
+ // curl
2942
+ {
2943
+ tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
2944
+ color: "#3BEB84"
2945
+ },
2946
+ // -X
2947
+ {
2948
+ tag: [import_preset_code3.tags.attributeName],
2949
+ color: "#FF9933"
2950
+ },
2951
+ // url in string (includes quotes), e.g. "https://..."
2952
+ {
2953
+ tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
2954
+ color: "#78B0FF"
2955
+ }
2956
+ ]
2957
+ });
2958
+
2959
+ // src/components/code-editor/theme/index.ts
2960
+ import_preset_code4.themes.register("dark", darkTheme);
2961
+ import_preset_code4.themes.register("light", lightTheme);
2962
+
2963
+ // src/components/code-editor/index.tsx
2964
+ var OriginCodeEditor = (0, import_react36.createRenderer)(import_preset_code5.default, [
2965
+ import_view4.EditorView.theme({
2966
+ "&.cm-focused": {
2967
+ outline: "none"
2968
+ }
2969
+ })
2970
+ ]);
2971
+ function CodeEditor({
2972
+ value,
2973
+ onChange,
2974
+ languageId = "python",
2975
+ theme = "light",
2976
+ children,
2977
+ placeholder,
2978
+ activeLinePlaceholder,
2979
+ options: options2,
2980
+ readonly
2981
+ }) {
2982
+ const editorRef = (0, import_react35.useRef)(null);
2983
+ (0, import_react35.useEffect)(() => {
2984
+ if (languageId === "typescript") {
2985
+ initTsWorker();
2986
+ }
2987
+ }, [languageId]);
2988
+ (0, import_react35.useEffect)(() => {
2989
+ if (editorRef.current?.getValue() !== value) {
2990
+ editorRef.current?.setValue(String(value || ""));
2991
+ }
2992
+ }, [value]);
2993
+ return /* @__PURE__ */ import_react35.default.createElement(import_react36.EditorProvider, null, /* @__PURE__ */ import_react35.default.createElement(
2994
+ OriginCodeEditor,
2995
+ {
2996
+ defaultValue: value,
2997
+ options: {
2998
+ uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
2999
+ languageId,
3000
+ theme,
3001
+ placeholder,
3002
+ readOnly: readonly,
3003
+ editable: !readonly,
3004
+ ...options2 || {}
3005
+ },
3006
+ didMount: (editor) => {
3007
+ editorRef.current = editor;
3008
+ },
3009
+ onChange: (e) => onChange?.(e.value)
3010
+ },
3011
+ activeLinePlaceholder && /* @__PURE__ */ import_react35.default.createElement(import_react36.ActiveLinePlaceholder, null, activeLinePlaceholder),
3012
+ children
3013
+ ));
3014
+ }
3015
+
3016
+ // src/components/json-editor-with-variables/index.tsx
3017
+ var import_react41 = __toESM(require("react"));
3018
+ var import_preset_code6 = require("@coze-editor/editor/preset-code");
3019
+
3020
+ // src/components/json-editor-with-variables/extensions/variable-tree.tsx
3021
+ var import_react37 = __toESM(require("react"));
3022
+ var import_semi_ui17 = require("@douyinfe/semi-ui");
3023
+ var import_react38 = require("@coze-editor/editor/react");
3024
+ function VariableTree2() {
3025
+ const [posKey, setPosKey] = (0, import_react37.useState)("");
3026
+ const [visible, setVisible] = (0, import_react37.useState)(false);
3027
+ const [position, setPosition] = (0, import_react37.useState)(-1);
3028
+ const editor = (0, import_react38.useEditor)();
3029
+ function insert(variablePath) {
3030
+ const range = (0, import_react38.getCurrentMentionReplaceRange)(editor.$view.state);
3031
+ if (!range) {
3032
+ return;
3033
+ }
3034
+ editor.replaceText({
3035
+ ...range,
3036
+ text: "{{" + variablePath + "}}"
3037
+ });
3038
+ setVisible(false);
3039
+ }
3040
+ function handleOpenChange(e) {
3041
+ setPosition(e.state.selection.main.head);
3042
+ setVisible(e.value);
3043
+ }
3044
+ (0, import_react37.useEffect)(() => {
3045
+ if (!editor) {
3046
+ return;
3047
+ }
3048
+ }, [editor, visible]);
3049
+ const treeData = useVariableTree({});
3050
+ return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(import_react38.Mention, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react37.default.createElement(
3051
+ import_semi_ui17.Popover,
3052
+ {
3053
+ visible,
3054
+ trigger: "custom",
3055
+ position: "topLeft",
3056
+ rePosKey: posKey,
3057
+ content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
3058
+ import_semi_ui17.Tree,
3059
+ {
3060
+ treeData,
3061
+ onSelect: (v) => {
3062
+ insert(v);
3063
+ }
3064
+ }
3065
+ ))
3066
+ },
3067
+ /* @__PURE__ */ import_react37.default.createElement(
3068
+ import_react38.PositionMirror,
3069
+ {
3070
+ position,
3071
+ onChange: () => setPosKey(String(Math.random()))
3072
+ }
3073
+ )
3074
+ ));
3075
+ }
3076
+
3077
+ // src/components/json-editor-with-variables/extensions/variable-tag.tsx
3078
+ var import_react39 = __toESM(require("react"));
3079
+ var import_client = require("react-dom/client");
3080
+ var import_lodash7 = require("lodash");
3081
+ var import_editor11 = require("@flowgram.ai/editor");
3082
+ var import_semi_ui19 = require("@douyinfe/semi-ui");
3083
+ var import_semi_icons10 = require("@douyinfe/semi-icons");
3084
+ var import_react40 = require("@coze-editor/editor/react");
3085
+ var import_view5 = require("@codemirror/view");
3086
+
3087
+ // src/components/json-editor-with-variables/styles.tsx
3088
+ var import_styled_components8 = __toESM(require("styled-components"));
3089
+ var import_semi_ui18 = require("@douyinfe/semi-ui");
3090
+ var UIRootTitle3 = import_styled_components8.default.div`
3091
+ margin-right: 4px;
3092
+ min-width: 20px;
3093
+ overflow: hidden;
3094
+ text-overflow: ellipsis;
3095
+ white-space: nowrap;
3096
+ color: var(--semi-color-text-2);
3097
+ `;
3098
+ var UIVarName3 = import_styled_components8.default.div`
3099
+ overflow: hidden;
3100
+ text-overflow: ellipsis;
3101
+ white-space: nowrap;
3102
+ `;
3103
+ var UITag3 = (0, import_styled_components8.default)(import_semi_ui18.Tag)`
3104
+ display: inline-flex;
3105
+ align-items: center;
3106
+ justify-content: flex-start;
3107
+ max-width: 300px;
3108
+
3109
+ & .semi-tag-content-center {
3110
+ justify-content: flex-start;
3111
+ }
3112
+
3113
+ &.semi-tag {
3114
+ margin: 0 5px;
3115
+ }
3116
+ `;
3117
+ var UIPopoverContent3 = import_styled_components8.default.div`
3118
+ padding: 10px;
3119
+ display: inline-flex;
3120
+ align-items: center;
3121
+ justify-content: flex-start;
3122
+ `;
3123
+
3124
+ // src/components/json-editor-with-variables/extensions/variable-tag.tsx
3125
+ var VariableTagWidget2 = class extends import_view5.WidgetType {
3126
+ constructor({ keyPath, scope }) {
3127
+ super();
3128
+ this.toDispose = new import_editor11.DisposableCollection();
3129
+ this.renderIcon = (icon) => {
3130
+ if (typeof icon === "string") {
3131
+ return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
3132
+ }
3133
+ return icon;
3134
+ };
3135
+ this.keyPath = keyPath;
3136
+ this.scope = scope;
3137
+ }
3138
+ renderVariable(v) {
3139
+ if (!v) {
3140
+ this.root.render(
3141
+ /* @__PURE__ */ import_react39.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons10.IconIssueStroked, null), color: "amber" }, "Unknown")
3142
+ );
3143
+ return;
3144
+ }
3145
+ const rootField = (0, import_lodash7.last)(v.parentFields);
3146
+ const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
3147
+ const rootIcon = this.renderIcon(rootField?.meta.icon);
3148
+ this.root.render(
3149
+ /* @__PURE__ */ import_react39.default.createElement(
3150
+ import_semi_ui19.Popover,
3151
+ {
3152
+ content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
3153
+ },
3154
+ /* @__PURE__ */ import_react39.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.key))
3155
+ )
3156
+ );
3157
+ }
3158
+ toDOM(view) {
3159
+ const dom = document.createElement("span");
3160
+ this.root = (0, import_client.createRoot)(dom);
3161
+ this.toDispose.push(
3162
+ import_editor11.Disposable.create(() => {
3163
+ this.root.unmount();
3164
+ })
3165
+ );
3166
+ this.toDispose.push(
3167
+ this.scope.available.trackByKeyPath(
3168
+ this.keyPath,
3169
+ (v) => {
3170
+ this.renderVariable(v);
3171
+ },
3172
+ { triggerOnInit: false }
3173
+ )
3174
+ );
3175
+ this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
3176
+ return dom;
3177
+ }
3178
+ eq(other) {
3179
+ return (0, import_lodash7.isEqual)(this.keyPath, other.keyPath);
3180
+ }
3181
+ ignoreEvent() {
3182
+ return false;
3183
+ }
3184
+ destroy(dom) {
3185
+ this.toDispose.dispose();
3186
+ }
3187
+ };
3188
+ function VariableTagInject2() {
3189
+ const injector = (0, import_react40.useInjector)();
3190
+ const scope = (0, import_editor11.useCurrentScope)();
3191
+ (0, import_react39.useLayoutEffect)(() => {
3192
+ const atMatcher = new import_view5.MatchDecorator({
3193
+ regexp: /\{\{([^\}]+)\}\}/g,
3194
+ decoration: (match) => import_view5.Decoration.replace({
3195
+ widget: new VariableTagWidget2({
3196
+ keyPath: match[1]?.split(".") ?? [],
3197
+ scope
3198
+ })
3199
+ })
3200
+ });
3201
+ return injector.inject([
3202
+ import_view5.ViewPlugin.fromClass(
3203
+ class {
3204
+ constructor(view) {
3205
+ this.view = view;
3206
+ this.decorations = atMatcher.createDeco(view);
3207
+ }
3208
+ update() {
3209
+ this.decorations = atMatcher.createDeco(this.view);
3210
+ }
3211
+ },
3212
+ {
3213
+ decorations: (p) => p.decorations,
3214
+ provide(p) {
3215
+ return import_view5.EditorView.atomicRanges.of(
3216
+ (view) => view.plugin(p)?.decorations ?? import_view5.Decoration.none
3217
+ );
3218
+ }
3219
+ }
3220
+ )
3221
+ ]);
3222
+ }, [injector]);
3223
+ return null;
3224
+ }
3225
+
3226
+ // src/components/json-editor-with-variables/index.tsx
3227
+ function findAllMatches(inputString, regex) {
3228
+ const globalRegex = new RegExp(
3229
+ regex,
3230
+ regex.flags.includes("g") ? regex.flags : regex.flags + "g"
3231
+ );
3232
+ let match;
3233
+ const matches = [];
3234
+ while ((match = globalRegex.exec(inputString)) !== null) {
3235
+ if (match.index === globalRegex.lastIndex) {
3236
+ globalRegex.lastIndex++;
3237
+ }
3238
+ matches.push({
3239
+ match: match[0],
3240
+ range: [match.index, match.index + match[0].length]
3241
+ });
3242
+ }
3243
+ return matches;
3244
+ }
3245
+ var transformer = (0, import_preset_code6.transformerCreator)((text) => {
3246
+ const originalSource = text.toString();
3247
+ const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
3248
+ if (matches.length > 0) {
3249
+ matches.forEach(({ range }) => {
3250
+ text.replaceRange(range[0], range[1], "null");
3251
+ });
3252
+ }
3253
+ return text;
3254
+ });
3255
+ function JsonEditorWithVariables(props) {
3256
+ return /* @__PURE__ */ import_react41.default.createElement(
3257
+ CodeEditor,
3258
+ {
3259
+ languageId: "json",
3260
+ activeLinePlaceholder: "Press '@' to Select variable",
3261
+ ...props,
3262
+ options: {
3263
+ transformer,
3264
+ ...props.options || {}
3265
+ }
3266
+ },
3267
+ /* @__PURE__ */ import_react41.default.createElement(VariableTree2, null),
3268
+ /* @__PURE__ */ import_react41.default.createElement(VariableTagInject2, null)
3269
+ );
3270
+ }
3271
+
3272
+ // src/components/inputs-values/index.tsx
3273
+ var import_react43 = __toESM(require("react"));
3274
+ var import_semi_ui20 = require("@douyinfe/semi-ui");
3275
+ var import_semi_icons11 = require("@douyinfe/semi-icons");
3276
+
3277
+ // src/components/inputs-values/styles.tsx
3278
+ var import_styled_components9 = __toESM(require("styled-components"));
3279
+ var UIRows2 = import_styled_components9.default.div`
3280
+ display: flex;
3281
+ flex-direction: column;
3282
+ gap: 10px;
3283
+ margin-bottom: 10px;
3284
+ `;
3285
+ var UIRow3 = import_styled_components9.default.div`
3286
+ display: flex;
3287
+ align-items: center;
3288
+ gap: 5px;
3289
+ `;
3290
+
3291
+ // src/components/inputs-values/components/blur-input.tsx
3292
+ var import_react42 = __toESM(require("react"));
3293
+ var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
3294
+ function BlurInput2(props) {
3295
+ const [value, setValue] = (0, import_react42.useState)("");
3296
+ (0, import_react42.useEffect)(() => {
3297
+ setValue(props.value);
3298
+ }, [props.value]);
3299
+ return /* @__PURE__ */ import_react42.default.createElement(
3300
+ import_input2.default,
3301
+ {
3302
+ ...props,
3303
+ value,
3304
+ onChange: (value2) => {
3305
+ setValue(value2);
3306
+ },
3307
+ onBlur: (e) => props.onChange?.(value, e)
3308
+ }
3309
+ );
3310
+ }
3311
+
3312
+ // src/components/inputs-values/index.tsx
3313
+ function InputsValues({
3314
+ value,
3315
+ onChange,
3316
+ style,
3317
+ readonly,
3318
+ constantProps,
3319
+ schema,
3320
+ hasError
3321
+ }) {
3322
+ const { list, updateKey, updateValue, remove, add } = useObjectList({
3323
+ value,
3324
+ onChange,
3325
+ sortIndexKey: "extra.index"
3326
+ });
3327
+ return /* @__PURE__ */ import_react43.default.createElement("div", null, /* @__PURE__ */ import_react43.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react43.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react43.default.createElement(
3328
+ BlurInput2,
3329
+ {
3330
+ style: { width: 100, minWidth: 100, maxWidth: 100 },
3331
+ disabled: readonly,
3332
+ size: "small",
3333
+ value: item.key,
3334
+ onChange: (v) => updateKey(item.id, v),
3335
+ placeholder: "Input Key"
3336
+ }
3337
+ ), /* @__PURE__ */ import_react43.default.createElement(
3338
+ DynamicValueInput,
3339
+ {
3340
+ style: { flexGrow: 1 },
3341
+ readonly,
3342
+ value: item.value,
3343
+ onChange: (v) => updateValue(item.id, v),
3344
+ schema,
3345
+ hasError,
3346
+ constantProps: {
3347
+ ...constantProps,
3348
+ strategies: [...constantProps?.strategies || []]
3349
+ }
3350
+ }
3351
+ ), /* @__PURE__ */ import_react43.default.createElement(
3352
+ import_semi_ui20.IconButton,
3353
+ {
3354
+ disabled: readonly,
3355
+ theme: "borderless",
3356
+ icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconDelete, { size: "small" }),
3357
+ size: "small",
3358
+ onClick: () => remove(item.id)
3359
+ }
3360
+ )))), /* @__PURE__ */ import_react43.default.createElement(import_semi_ui20.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconPlus, null), size: "small", onClick: add }, "Add"));
3361
+ }
3362
+
3363
+ // src/effects/provide-batch-input/index.ts
3364
+ var import_editor12 = require("@flowgram.ai/editor");
3365
+ var provideBatchInputEffect = (0, import_editor12.createEffectFromVariableProvider)({
3366
+ private: true,
3367
+ parse: (value, ctx) => [
3368
+ import_editor12.ASTFactory.createVariableDeclaration({
3369
+ key: `${ctx.node.id}_locals`,
3370
+ meta: {
3371
+ title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
3372
+ icon: ctx.node.getNodeRegistry().info?.icon
3373
+ },
3374
+ type: import_editor12.ASTFactory.createObject({
3375
+ properties: [
3376
+ import_editor12.ASTFactory.createProperty({
3377
+ key: "item",
3378
+ initializer: import_editor12.ASTFactory.createEnumerateExpression({
3379
+ enumerateFor: import_editor12.ASTFactory.createKeyPathExpression({
3380
+ keyPath: value.content || []
3381
+ })
3382
+ })
3383
+ }),
3384
+ import_editor12.ASTFactory.createProperty({
3385
+ key: "index",
3386
+ type: import_editor12.ASTFactory.createNumber()
3387
+ })
3388
+ ]
3389
+ })
3390
+ })
3391
+ ]
3392
+ });
3393
+
3394
+ // src/effects/auto-rename-ref/index.ts
3395
+ var import_lodash8 = require("lodash");
3396
+ var import_editor13 = require("@flowgram.ai/editor");
3397
+ var autoRenameRefEffect = [
3398
+ {
3399
+ event: import_editor13.DataEvent.onValueInit,
3400
+ effect: (params) => {
3401
+ const { context, form, name } = params;
3402
+ const renameService = context.node.getService(import_editor13.VariableFieldKeyRenameService);
3403
+ const disposable = renameService.onRename(({ before, after }) => {
3404
+ const beforeKeyPath = [
3405
+ ...before.parentFields.map((_field) => _field.key).reverse(),
3406
+ before.key
3407
+ ];
3408
+ const afterKeyPath = [
3409
+ ...after.parentFields.map((_field) => _field.key).reverse(),
3410
+ after.key
3411
+ ];
3412
+ traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
3413
+ if (_v.type === "ref") {
3414
+ if (isKeyPathMatch(_v.content, beforeKeyPath)) {
3415
+ _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3416
+ form.setValueIn(_drilldownName, _v);
3417
+ }
3418
+ } else if (_v.type === "template") {
3419
+ const templateKeyPaths = getTemplateKeyPaths(_v);
3420
+ let hasMatch = false;
3421
+ templateKeyPaths.forEach((_keyPath) => {
3422
+ if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
3423
+ hasMatch = true;
3424
+ const nextKeyPath = [
3425
+ ...afterKeyPath,
3426
+ ...(_keyPath || [])?.slice(beforeKeyPath.length)
3427
+ ];
3428
+ _v.content = _v.content?.replace(
3429
+ `{{${_keyPath.join(".")}}`,
3430
+ `{{${nextKeyPath.join(".")}}`
3431
+ );
3432
+ }
3433
+ });
3434
+ if (hasMatch) {
3435
+ form.setValueIn(_drilldownName, { ..._v });
3436
+ }
3437
+ }
3438
+ });
3439
+ });
3440
+ return () => {
3441
+ disposable.dispose();
3442
+ };
3443
+ }
3444
+ }
3445
+ ];
3446
+ function isKeyPathMatch(keyPath = [], targetKeyPath) {
3447
+ return targetKeyPath.every((_key, index) => _key === keyPath[index]);
3448
+ }
3449
+ function getTemplateKeyPaths(value) {
3450
+ const keyPathReg = /{{(.*?)}}/g;
3451
+ return (0, import_lodash8.uniq)(value.content?.match(keyPathReg) || []).map(
3452
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
3453
+ );
3454
+ }
3455
+ function isRef(value) {
3456
+ return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3457
+ }
3458
+ function isTemplate(value) {
3459
+ return value?.type === "template" && typeof value?.content === "string";
3460
+ }
3461
+ function traverseRef(name, value, cb) {
3462
+ if ((0, import_lodash8.isObject)(value)) {
3463
+ if (isRef(value)) {
3464
+ cb(name, value);
3465
+ return;
3466
+ }
3467
+ if (isTemplate(value)) {
3468
+ cb(name, value);
3469
+ return;
3470
+ }
3471
+ Object.entries(value).forEach(([_key, _value]) => {
3472
+ traverseRef(`${name}.${_key}`, _value, cb);
3473
+ });
3474
+ return;
3475
+ }
3476
+ if ((0, import_lodash8.isArray)(value)) {
3477
+ value.forEach((_value, idx) => {
3478
+ traverseRef(`${name}[${idx}]`, _value, cb);
3479
+ });
3480
+ return;
3481
+ }
3482
+ return;
3483
+ }
3484
+
3485
+ // src/effects/provide-json-schema-outputs/index.ts
3486
+ var import_editor14 = require("@flowgram.ai/editor");
3487
+ var provideJsonSchemaOutputs = (0, import_editor14.createEffectFromVariableProvider)({
3488
+ parse: (value, ctx) => [
3489
+ import_editor14.ASTFactory.createVariableDeclaration({
3490
+ key: `${ctx.node.id}`,
3491
+ meta: {
3492
+ title: (0, import_editor14.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3493
+ icon: ctx.node.getNodeRegistry().info?.icon
3494
+ },
3495
+ type: JsonSchemaUtils.schemaToAST(value)
3496
+ })
3497
+ ]
3498
+ });
3499
+
3500
+ // src/effects/sync-variable-title/index.ts
3501
+ var import_editor15 = require("@flowgram.ai/editor");
3502
+ var syncVariableTitle = [
3503
+ {
3504
+ event: import_editor15.DataEvent.onValueChange,
3505
+ effect: ({ value, context }) => {
3506
+ context.node.getData(import_editor15.FlowNodeVariableData).allScopes.forEach((_scope) => {
3507
+ _scope.output.variables.forEach((_var) => {
3508
+ _var.updateMeta({
3509
+ title: value || context.node.id,
3510
+ icon: context.node.getNodeRegistry().info?.icon
3511
+ });
3512
+ });
3513
+ });
3514
+ }
3515
+ }
3516
+ ];
3517
+
3518
+ // src/form-plugins/batch-outputs-plugin/index.ts
3519
+ var import_editor16 = require("@flowgram.ai/editor");
3520
+ var provideBatchOutputsEffect = (0, import_editor16.createEffectFromVariableProvider)({
3521
+ parse: (value, ctx) => [
3522
+ import_editor16.ASTFactory.createVariableDeclaration({
3523
+ key: `${ctx.node.id}`,
3524
+ meta: {
3525
+ title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title"),
3526
+ icon: ctx.node.getNodeRegistry().info?.icon
3527
+ },
3528
+ type: import_editor16.ASTFactory.createObject({
3529
+ properties: Object.entries(value).map(
3530
+ ([_key, value2]) => import_editor16.ASTFactory.createProperty({
3531
+ key: _key,
3532
+ initializer: import_editor16.ASTFactory.createWrapArrayExpression({
3533
+ wrapFor: import_editor16.ASTFactory.createKeyPathExpression({
3534
+ keyPath: value2?.content || []
3535
+ })
3536
+ })
3537
+ })
3538
+ )
3539
+ })
3540
+ })
3541
+ ]
3542
+ });
3543
+ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)({
3544
+ name: "batch-outputs-plugin",
3545
+ onSetupFormMeta({ mergeEffect }, { outputKey }) {
3546
+ mergeEffect({
3547
+ [outputKey]: provideBatchOutputsEffect
3548
+ });
3549
+ },
3550
+ onInit(ctx, { outputKey }) {
3551
+ const chainTransformService = ctx.node.getService(import_editor16.ScopeChainTransformService);
3552
+ const batchNodeType = ctx.node.flowNodeType;
3553
+ const transformerId = `${batchNodeType}-outputs`;
3554
+ if (chainTransformService.hasTransformer(transformerId)) {
3555
+ return;
3556
+ }
3557
+ chainTransformService.registerTransformer(transformerId, {
3558
+ transformCovers: (covers, ctx2) => {
3559
+ const node = ctx2.scope.meta?.node;
3560
+ if (node?.parent?.flowNodeType === batchNodeType) {
3561
+ return [...covers, (0, import_editor16.getNodeScope)(node.parent)];
3562
+ }
3563
+ return covers;
3564
+ },
3565
+ transformDeps(scopes, ctx2) {
3566
+ const scopeMeta = ctx2.scope.meta;
3567
+ if (scopeMeta?.type === import_editor16.FlowNodeScopeType.private) {
3568
+ return scopes;
3569
+ }
3570
+ const node = scopeMeta?.node;
3571
+ if (node?.flowNodeType === batchNodeType) {
3572
+ const childBlocks = node.blocks;
3573
+ return [
3574
+ (0, import_editor16.getNodePrivateScope)(node),
3575
+ ...childBlocks.map((_childBlock) => (0, import_editor16.getNodeScope)(_childBlock))
3576
+ ];
3577
+ }
3578
+ return scopes;
3579
+ }
3580
+ });
3581
+ }
3582
+ });
3583
+
3584
+ // src/form-plugins/infer-inputs-plugin/index.ts
3585
+ var import_lodash9 = require("lodash");
3586
+ var import_editor17 = require("@flowgram.ai/editor");
3587
+ var createInferInputsPlugin = (0, import_editor17.defineFormPluginCreator)({
3588
+ onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3589
+ if (!sourceKey || !targetKey) {
3590
+ return;
3591
+ }
3592
+ addFormatOnSubmit((formData, ctx) => {
3593
+ (0, import_lodash9.set)(
3594
+ formData,
3595
+ targetKey,
3596
+ infer(
3597
+ (0, import_lodash9.get)(formData, sourceKey),
3598
+ scope === "private" ? (0, import_editor17.getNodePrivateScope)(ctx.node) : (0, import_editor17.getNodeScope)(ctx.node)
3599
+ )
3600
+ );
3601
+ return formData;
3602
+ });
3603
+ }
3604
+ });
3605
+ function isRef2(value) {
3606
+ return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3607
+ }
3608
+ function isTemplate2(value) {
3609
+ return value?.type === "template" && typeof value?.content === "string";
3610
+ }
3611
+ function isConstant(value) {
3612
+ return value?.type === "constant" && typeof value?.content !== "undefined";
3613
+ }
3614
+ var infer = (values, scope) => {
3615
+ if (typeof values === "object") {
3616
+ if (isConstant(values)) {
3617
+ if (values?.schema) {
3618
+ return values.schema;
3619
+ }
3620
+ if (typeof values.content === "string") {
3621
+ return {
3622
+ type: "string"
3623
+ };
3624
+ }
3625
+ if (typeof values.content === "number") {
3626
+ return {
3627
+ type: "number"
3628
+ };
3629
+ }
3630
+ if (typeof values.content === "boolean") {
3631
+ return {
3632
+ type: "boolean"
3633
+ };
3634
+ }
3635
+ }
3636
+ if (isRef2(values)) {
3637
+ const variable = scope.available.getByKeyPath(values?.content);
3638
+ const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
3639
+ return schema;
3640
+ }
3641
+ if (isTemplate2(values)) {
3642
+ return {
3643
+ type: "string"
3644
+ };
3645
+ }
3646
+ return {
3647
+ type: "object",
3648
+ properties: Object.keys(values).reduce((acc, key) => {
3649
+ const schema = infer(values[key], scope);
3650
+ if (schema) {
3651
+ acc[key] = schema;
3652
+ }
3653
+ return acc;
3654
+ }, {})
3655
+ };
3656
+ }
3657
+ };
3658
+ // Annotate the CommonJS export names for ESM import in node:
3659
+ 0 && (module.exports = {
3660
+ ArrayIcons,
3661
+ BatchOutputs,
3662
+ BatchVariableSelector,
3663
+ CodeEditor,
3664
+ ConditionRow,
3665
+ ConstantInput,
3666
+ DynamicValueInput,
3667
+ InputsValues,
3668
+ JsonEditorWithVariables,
3669
+ JsonSchemaEditor,
3670
+ JsonSchemaUtils,
3671
+ PromptEditor,
3672
+ PromptEditorWithInputs,
3673
+ PromptEditorWithVariables,
3674
+ TypeSelector,
3675
+ VariableSelector,
3676
+ VariableTypeIcons,
3677
+ autoRenameRefEffect,
3678
+ createBatchOutputsFormPlugin,
3679
+ createInferInputsPlugin,
3680
+ formatLegacyRefOnInit,
3681
+ formatLegacyRefOnSubmit,
3682
+ formatLegacyRefToNewRef,
3683
+ formatNewRefToLegacyRef,
3684
+ getSchemaIcon,
3685
+ getTypeSelectValue,
3686
+ isLegacyFlowRefValueSchema,
3687
+ isNewFlowRefValueSchema,
3688
+ parseTypeSelectValue,
3689
+ provideBatchInputEffect,
3690
+ provideBatchOutputsEffect,
3691
+ provideJsonSchemaOutputs,
3692
+ syncVariableTitle,
3693
+ useVariableTree
3694
+ });
3695
+ //# sourceMappingURL=index.js.map