@flowgram.ai/form-materials 0.1.0-alpha.11 → 0.1.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/bin/index.ts +14 -22
  2. package/bin/materials.ts +41 -90
  3. package/bin/project.ts +4 -0
  4. package/bin/utils/import.ts +127 -0
  5. package/bin/utils/traverse-file.ts +60 -0
  6. package/dist/esm/index.js +2073 -1601
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/index.d.mts +392 -131
  9. package/dist/index.d.ts +392 -131
  10. package/dist/index.js +2175 -1710
  11. package/dist/index.js.map +1 -1
  12. package/package.json +5 -4
  13. package/src/components/assign-row/components/blur-input.tsx +27 -0
  14. package/src/components/assign-row/index.tsx +84 -0
  15. package/src/components/assign-row/types.ts +25 -0
  16. package/src/components/assign-rows/index.tsx +59 -0
  17. package/src/components/batch-outputs/index.tsx +7 -14
  18. package/src/components/batch-outputs/types.ts +1 -1
  19. package/src/components/batch-variable-selector/index.tsx +2 -2
  20. package/src/components/code-editor/index.tsx +7 -0
  21. package/src/components/code-editor/language-features.ts +22 -1
  22. package/src/components/code-editor/theme/light.ts +1 -1
  23. package/src/components/code-editor-mini/index.tsx +31 -0
  24. package/src/components/condition-row/constants.ts +8 -10
  25. package/src/components/condition-row/hooks/useOp.tsx +15 -9
  26. package/src/components/condition-row/hooks/useRule.ts +9 -5
  27. package/src/components/condition-row/index.tsx +28 -10
  28. package/src/components/condition-row/types.ts +5 -5
  29. package/src/components/constant-input/index.tsx +20 -61
  30. package/src/components/constant-input/types.ts +6 -9
  31. package/src/components/display-flow-value/index.tsx +59 -0
  32. package/src/components/display-inputs-values/index.tsx +28 -0
  33. package/src/components/display-inputs-values/styles.ts +12 -0
  34. package/src/components/display-outputs/index.tsx +65 -0
  35. package/src/components/display-outputs/styles.ts +12 -0
  36. package/src/components/display-schema-tag/index.tsx +45 -0
  37. package/src/components/display-schema-tag/styles.ts +28 -0
  38. package/src/components/display-schema-tree/index.tsx +75 -0
  39. package/src/components/display-schema-tree/styles.tsx +90 -0
  40. package/src/components/dynamic-value-input/hooks.ts +53 -0
  41. package/src/components/dynamic-value-input/index.tsx +74 -19
  42. package/src/components/dynamic-value-input/styles.tsx +28 -2
  43. package/src/components/index.ts +9 -0
  44. package/src/components/inputs-values/components/blur-input.tsx +27 -0
  45. package/src/components/inputs-values/index.tsx +75 -0
  46. package/src/components/inputs-values/styles.tsx +19 -0
  47. package/src/components/inputs-values/types.ts +22 -0
  48. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
  49. package/src/components/json-editor-with-variables/index.tsx +2 -1
  50. package/src/components/json-schema-editor/default-value.tsx +12 -106
  51. package/src/components/json-schema-editor/hooks.tsx +53 -94
  52. package/src/components/json-schema-editor/index.tsx +32 -13
  53. package/src/components/json-schema-editor/styles.tsx +0 -29
  54. package/src/components/json-schema-editor/types.ts +1 -1
  55. package/src/components/prompt-editor/types.tsx +1 -1
  56. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
  57. package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
  58. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +2 -2
  59. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
  60. package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
  61. package/src/components/prompt-editor-with-variables/index.tsx +2 -1
  62. package/src/components/type-selector/index.tsx +58 -13
  63. package/src/components/variable-selector/index.tsx +42 -17
  64. package/src/components/variable-selector/styles.tsx +18 -8
  65. package/src/components/variable-selector/use-variable-tree.tsx +19 -22
  66. package/src/effects/auto-rename-ref/index.ts +1 -1
  67. package/src/effects/index.ts +3 -1
  68. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  69. package/src/effects/listen-ref-value-change/index.ts +53 -0
  70. package/src/effects/provide-batch-input/index.ts +1 -1
  71. package/src/effects/provide-json-schema-outputs/index.ts +1 -3
  72. package/src/effects/sync-variable-title/index.ts +1 -0
  73. package/src/effects/validate-when-variable-sync/index.ts +35 -0
  74. package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
  75. package/src/form-plugins/index.ts +3 -1
  76. package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
  77. package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
  78. package/src/hooks/index.tsx +6 -0
  79. package/src/hooks/use-object-list/index.tsx +136 -0
  80. package/src/index.ts +3 -1
  81. package/src/{utils/format-legacy-refs → plugins/disable-declaration-plugin}/config.json +1 -1
  82. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  83. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  84. package/src/plugins/index.ts +7 -0
  85. package/src/plugins/json-schema-preset/config.json +9 -0
  86. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
  87. package/src/plugins/json-schema-preset/index.tsx +41 -0
  88. package/src/plugins/json-schema-preset/manager.ts +18 -0
  89. package/src/plugins/json-schema-preset/type-definition/array.tsx +26 -0
  90. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +33 -0
  91. package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
  92. package/src/plugins/json-schema-preset/type-definition/integer.tsx +25 -0
  93. package/src/plugins/json-schema-preset/type-definition/number.tsx +25 -0
  94. package/src/plugins/json-schema-preset/type-definition/object.tsx +26 -0
  95. package/src/plugins/json-schema-preset/type-definition/string.tsx +24 -0
  96. package/src/{utils → shared}/index.ts +1 -1
  97. package/src/shared/inject-material/README.md +170 -0
  98. package/src/shared/inject-material/README.zh.md +174 -0
  99. package/src/shared/inject-material/index.tsx +87 -0
  100. package/src/typings/flow-value/index.ts +11 -0
  101. package/src/typings/index.ts +0 -1
  102. package/src/validate/index.tsx +6 -0
  103. package/src/validate/validate-flow-value/index.tsx +73 -0
  104. package/src/components/batch-outputs/config.json +0 -12
  105. package/src/components/batch-outputs/use-list.ts +0 -86
  106. package/src/components/batch-variable-selector/config.json +0 -5
  107. package/src/components/code-editor/config.json +0 -10
  108. package/src/components/condition-row/config.json +0 -5
  109. package/src/components/constant-input/config.json +0 -6
  110. package/src/components/dynamic-value-input/config.json +0 -5
  111. package/src/components/json-editor-with-variables/config.json +0 -13
  112. package/src/components/json-schema-editor/config.json +0 -13
  113. package/src/components/json-schema-editor/utils.ts +0 -29
  114. package/src/components/prompt-editor/config.json +0 -9
  115. package/src/components/prompt-editor-with-inputs/config.json +0 -13
  116. package/src/components/prompt-editor-with-variables/config.json +0 -13
  117. package/src/components/type-selector/config.json +0 -5
  118. package/src/components/type-selector/constants.tsx +0 -364
  119. package/src/components/variable-selector/config.json +0 -5
  120. package/src/effects/auto-rename-ref/config.json +0 -5
  121. package/src/effects/provide-batch-input/config.json +0 -5
  122. package/src/effects/provide-batch-outputs/config.json +0 -5
  123. package/src/effects/provide-batch-outputs/index.ts +0 -38
  124. package/src/effects/provide-json-schema-outputs/config.json +0 -8
  125. package/src/effects/sync-variable-title/config.json +0 -5
  126. package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
  127. package/src/typings/flow-value/config.json +0 -5
  128. package/src/typings/json-schema/config.json +0 -5
  129. package/src/typings/json-schema/index.ts +0 -36
  130. package/src/utils/json-schema/config.json +0 -5
  131. package/src/utils/json-schema/index.ts +0 -180
  132. /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
  133. /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/dist/esm/index.js CHANGED
@@ -1,551 +1,670 @@
1
1
  // src/components/variable-selector/index.tsx
2
- import React3, { useMemo } from "react";
2
+ import React12, { useMemo } from "react";
3
+ import { I18n as I18n7 } from "@flowgram.ai/editor";
4
+ import { Popover } from "@douyinfe/semi-ui";
3
5
  import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
4
6
 
7
+ // src/shared/format-legacy-refs/index.ts
8
+ import { isObject } from "lodash";
9
+ function formatLegacyRefOnSubmit(value) {
10
+ if (isObject(value)) {
11
+ if (isLegacyFlowRefValueSchema(value)) {
12
+ return formatLegacyRefToNewRef(value);
13
+ }
14
+ return Object.fromEntries(
15
+ Object.entries(value).map(([key, value2]) => [
16
+ key,
17
+ formatLegacyRefOnSubmit(value2)
18
+ ])
19
+ );
20
+ }
21
+ if (Array.isArray(value)) {
22
+ return value.map(formatLegacyRefOnSubmit);
23
+ }
24
+ return value;
25
+ }
26
+ function formatLegacyRefOnInit(value) {
27
+ if (isObject(value)) {
28
+ if (isNewFlowRefValueSchema(value)) {
29
+ return formatNewRefToLegacyRef(value);
30
+ }
31
+ return Object.fromEntries(
32
+ Object.entries(value).map(([key, value2]) => [
33
+ key,
34
+ formatLegacyRefOnInit(value2)
35
+ ])
36
+ );
37
+ }
38
+ if (Array.isArray(value)) {
39
+ return value.map(formatLegacyRefOnInit);
40
+ }
41
+ return value;
42
+ }
43
+ function isLegacyFlowRefValueSchema(value) {
44
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
45
+ }
46
+ function isNewFlowRefValueSchema(value) {
47
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
48
+ }
49
+ function formatLegacyRefToNewRef(value) {
50
+ const keyPath = value.content.split(".");
51
+ if (keyPath[1] === "outputs") {
52
+ return {
53
+ type: "ref",
54
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
55
+ };
56
+ }
57
+ return {
58
+ type: "ref",
59
+ content: keyPath
60
+ };
61
+ }
62
+ function formatNewRefToLegacyRef(value) {
63
+ return {
64
+ type: "ref",
65
+ content: value.content.join(".")
66
+ };
67
+ }
68
+
69
+ // src/shared/inject-material/index.tsx
70
+ import React from "react";
71
+ import {
72
+ FlowRendererComponentType,
73
+ FlowRendererRegistry,
74
+ usePlaygroundContainer
75
+ } from "@flowgram.ai/editor";
76
+ function createInjectMaterial(Component, params) {
77
+ const InjectComponent = (props) => {
78
+ const container = usePlaygroundContainer();
79
+ if (!container?.isBound(FlowRendererRegistry)) {
80
+ return React.createElement(Component, { ...props });
81
+ }
82
+ const rendererRegistry = container.get(FlowRendererRegistry);
83
+ const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
84
+ const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
85
+ if (renderer?.type !== FlowRendererComponentType.REACT) {
86
+ return React.createElement(Component, { ...props });
87
+ }
88
+ return React.createElement(renderer.renderer, {
89
+ ...props
90
+ });
91
+ };
92
+ return InjectComponent;
93
+ }
94
+
5
95
  // src/components/variable-selector/use-variable-tree.tsx
6
- import React2, { useCallback } from "react";
96
+ import React11, { useCallback } from "react";
97
+ import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
7
98
  import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
8
- import { Icon as Icon2 } from "@douyinfe/semi-ui";
99
+ import { Icon } from "@douyinfe/semi-ui";
9
100
 
10
- // src/components/type-selector/constants.tsx
11
- import React from "react";
12
- import Icon from "@douyinfe/semi-icons";
13
- var VariableTypeIcons = {
14
- custom: /* @__PURE__ */ React.createElement(
15
- "svg",
16
- {
17
- viewBox: "0 0 24 24",
18
- fill: "none",
19
- xmlns: "http://www.w3.org/2000/svg",
20
- width: "1em",
21
- height: "1em",
22
- focusable: "false",
23
- "aria-hidden": "true"
101
+ // src/plugins/json-schema-preset/index.tsx
102
+ import React10 from "react";
103
+ import {
104
+ JsonSchemaUtils,
105
+ useTypeManager as useOriginTypeManager,
106
+ TypePresetProvider as OriginTypePresetProvider
107
+ } from "@flowgram.ai/json-schema";
108
+
109
+ // src/plugins/json-schema-preset/type-definition/index.tsx
110
+ import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
111
+
112
+ // src/plugins/json-schema-preset/type-definition/string.tsx
113
+ import React2 from "react";
114
+ import { I18n } from "@flowgram.ai/editor";
115
+ import { Input } from "@douyinfe/semi-ui";
116
+ var stringRegistry = {
117
+ type: "string",
118
+ ConstantRenderer: (props) => /* @__PURE__ */ React2.createElement(
119
+ Input,
120
+ {
121
+ placeholder: I18n.t("Please Input String"),
122
+ size: "small",
123
+ disabled: props.readonly,
124
+ ...props
125
+ }
126
+ )
127
+ };
128
+
129
+ // src/plugins/json-schema-preset/type-definition/object.tsx
130
+ import React5 from "react";
131
+ import { I18n as I18n2 } from "@flowgram.ai/editor";
132
+
133
+ // src/components/code-editor-mini/index.tsx
134
+ import React4 from "react";
135
+ import styled from "styled-components";
136
+
137
+ // src/components/code-editor/index.tsx
138
+ import React3, { useEffect, useRef } from "react";
139
+ import {
140
+ ActiveLinePlaceholder,
141
+ createRenderer,
142
+ EditorProvider
143
+ } from "@coze-editor/editor/react";
144
+ import preset from "@coze-editor/editor/preset-code";
145
+ import { EditorView } from "@codemirror/view";
146
+
147
+ // src/components/code-editor/utils.ts
148
+ function getSuffixByLanguageId(languageId) {
149
+ if (languageId === "python") {
150
+ return ".py";
151
+ }
152
+ if (languageId === "typescript") {
153
+ return ".ts";
154
+ }
155
+ if (languageId === "shell") {
156
+ return ".sh";
157
+ }
158
+ if (languageId === "json") {
159
+ return ".json";
160
+ }
161
+ return "";
162
+ }
163
+
164
+ // src/components/code-editor/language-features.ts
165
+ import { languages } from "@coze-editor/editor/preset-code";
166
+ import { typescript } from "@coze-editor/editor/language-typescript";
167
+ import { shell } from "@coze-editor/editor/language-shell";
168
+ import { python } from "@coze-editor/editor/language-python";
169
+ import { json } from "@coze-editor/editor/language-json";
170
+ import { mixLanguages } from "@coze-editor/editor";
171
+ languages.register("python", python);
172
+ languages.register("shell", shell);
173
+ languages.register("typescript", typescript);
174
+ languages.register("json", {
175
+ // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
176
+ language: mixLanguages({
177
+ outerLanguage: json.language
178
+ }),
179
+ languageService: json.languageService
180
+ });
181
+ var tsWorkerInit = false;
182
+ var initTsWorker = () => {
183
+ if (tsWorkerInit) {
184
+ return;
185
+ }
186
+ tsWorkerInit = true;
187
+ const tsWorker = new Worker(
188
+ new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
189
+ { type: "module" }
190
+ );
191
+ typescript.languageService.initialize(tsWorker, {
192
+ compilerOptions: {
193
+ // eliminate Promise error
194
+ lib: ["es2015", "dom"],
195
+ noImplicitAny: false
196
+ }
197
+ });
198
+ };
199
+
200
+ // src/components/code-editor/theme/index.ts
201
+ import { themes } from "@coze-editor/editor/preset-code";
202
+
203
+ // src/components/code-editor/theme/light.ts
204
+ import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
205
+ var colors = {
206
+ background: "#F7F7FC",
207
+ // syntax
208
+ comment: "#000A298A",
209
+ key: "#00818C",
210
+ string: "#D1009D",
211
+ number: "#C74200",
212
+ boolean: "#2B57D9",
213
+ null: "#2B57D9",
214
+ separator: "#0F1529D1"
215
+ };
216
+ var lightTheme = createTheme({
217
+ variant: "light",
218
+ settings: {
219
+ background: "#fff",
220
+ foreground: "#000",
221
+ caret: "#000",
222
+ selection: "#d9d9d9",
223
+ gutterBackground: "#f0f0f0",
224
+ gutterForeground: "#666",
225
+ gutterBorderColor: "transparent",
226
+ gutterBorderWidth: 0,
227
+ lineHighlight: "#e1e1e180",
228
+ bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
229
+ tooltip: {
230
+ backgroundColor: "#f0f0f0",
231
+ color: "#000",
232
+ border: "1px solid #ccc"
24
233
  },
25
- /* @__PURE__ */ React.createElement(
26
- "path",
27
- {
28
- fillRule: "evenodd",
29
- clipRule: "evenodd",
30
- 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",
31
- fill: "currentColor"
32
- }
33
- )
34
- ),
35
- object: /* @__PURE__ */ React.createElement(
36
- "svg",
37
- {
38
- width: "1em",
39
- height: "1em",
40
- viewBox: "0 0 16 16",
41
- fill: "none",
42
- xmlns: "http://www.w3.org/2000/svg"
234
+ link: {
235
+ color: "#007bff"
43
236
  },
44
- /* @__PURE__ */ React.createElement(
45
- "path",
46
- {
47
- 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",
48
- fill: "currentColor"
49
- }
50
- ),
51
- /* @__PURE__ */ React.createElement(
52
- "path",
53
- {
54
- 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",
55
- fill: "currentColor"
56
- }
57
- )
58
- ),
59
- boolean: /* @__PURE__ */ React.createElement(
60
- "svg",
61
- {
62
- width: "1em",
63
- height: "1em",
64
- viewBox: "0 0 16 16",
65
- fill: "none",
66
- xmlns: "http://www.w3.org/2000/svg"
237
+ completionItemHover: {
238
+ backgroundColor: "#f0f0f0"
67
239
  },
68
- /* @__PURE__ */ React.createElement(
69
- "path",
70
- {
71
- fillRule: "evenodd",
72
- clipRule: "evenodd",
73
- 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",
74
- fill: "currentColor"
75
- }
76
- ),
77
- /* @__PURE__ */ React.createElement(
78
- "path",
79
- {
80
- fillRule: "evenodd",
81
- clipRule: "evenodd",
82
- 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",
83
- fill: "currentColor"
84
- }
85
- )
86
- ),
87
- string: /* @__PURE__ */ React.createElement(
88
- "svg",
89
- {
90
- width: "1em",
91
- height: "1em",
92
- viewBox: "0 0 16 16",
93
- fill: "none",
94
- xmlns: "http://www.w3.org/2000/svg"
240
+ completionItemSelected: {
241
+ backgroundColor: "#e0e0e0"
95
242
  },
96
- /* @__PURE__ */ React.createElement(
97
- "path",
98
- {
99
- 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",
100
- fill: "currentColor"
101
- }
102
- ),
103
- /* @__PURE__ */ React.createElement(
104
- "path",
105
- {
106
- 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",
107
- fill: "currentColor"
108
- }
109
- ),
110
- /* @__PURE__ */ React.createElement(
111
- "path",
112
- {
113
- 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",
114
- fill: "currentColor"
115
- }
116
- ),
117
- /* @__PURE__ */ React.createElement(
118
- "path",
119
- {
120
- 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",
121
- fill: "currentColor"
122
- }
123
- )
124
- ),
125
- integer: /* @__PURE__ */ React.createElement(
126
- "svg",
127
- {
128
- width: "1em",
129
- height: "1em",
130
- viewBox: "0 0 16 16",
131
- fill: "none",
132
- xmlns: "http://www.w3.org/2000/svg"
243
+ completionItemIcon: {
244
+ color: "#333"
133
245
  },
134
- /* @__PURE__ */ React.createElement(
135
- "path",
136
- {
137
- 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",
138
- fill: "currentColor"
139
- }
140
- ),
141
- /* @__PURE__ */ React.createElement(
142
- "path",
143
- {
144
- 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",
145
- fill: "currentColor"
146
- }
147
- ),
148
- /* @__PURE__ */ React.createElement(
149
- "path",
150
- {
151
- d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
152
- fill: "currentColor"
153
- }
154
- )
155
- ),
156
- number: /* @__PURE__ */ React.createElement(
157
- "svg",
158
- {
159
- width: "1em",
160
- height: "1em",
161
- viewBox: "0 0 16 16",
162
- fill: "none",
163
- xmlns: "http://www.w3.org/2000/svg"
246
+ completionItemLabel: {
247
+ color: "#333"
164
248
  },
165
- /* @__PURE__ */ React.createElement(
166
- "path",
167
- {
168
- 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",
169
- fill: "currentColor"
170
- }
171
- ),
172
- /* @__PURE__ */ React.createElement(
173
- "path",
174
- {
175
- 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",
176
- fill: "currentColor"
177
- }
178
- ),
179
- /* @__PURE__ */ React.createElement(
180
- "path",
181
- {
182
- 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",
183
- fill: "currentColor"
184
- }
185
- )
186
- ),
187
- array: /* @__PURE__ */ React.createElement(
188
- "svg",
189
- {
190
- width: "1em",
191
- height: "1em",
192
- viewBox: "0 0 16 16",
193
- fill: "none",
194
- xmlns: "http://www.w3.org/2000/svg"
249
+ completionItemInfo: {
250
+ color: "#333"
195
251
  },
196
- /* @__PURE__ */ React.createElement(
197
- "path",
198
- {
199
- d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
200
- fill: "currentColor"
201
- }
202
- ),
203
- /* @__PURE__ */ React.createElement(
204
- "path",
205
- {
206
- d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
207
- fill: "currentColor"
208
- }
209
- )
210
- ),
211
- stream: /* @__PURE__ */ React.createElement(
212
- "svg",
213
- {
214
- viewBox: "0 0 1024 1024",
215
- version: "1.1",
216
- xmlns: "http://www.w3.org/2000/svg",
217
- width: "1em",
218
- height: "1em"
252
+ completionItemDetail: {
253
+ color: "#666"
254
+ }
255
+ },
256
+ styles: [
257
+ // JSON
258
+ {
259
+ tag: t.comment,
260
+ color: colors.comment
219
261
  },
220
- /* @__PURE__ */ React.createElement(
221
- "path",
222
- {
223
- 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",
224
- fill: "currentColor"
225
- }
226
- )
227
- ),
228
- map: /* @__PURE__ */ React.createElement(
229
- "svg",
230
- {
231
- viewBox: "0 0 1024 1024",
232
- version: "1.1",
233
- xmlns: "http://www.w3.org/2000/svg",
234
- width: "1em",
235
- height: "1em"
262
+ {
263
+ tag: [t.propertyName],
264
+ color: colors.key
236
265
  },
237
- /* @__PURE__ */ React.createElement(
238
- "path",
239
- {
240
- 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",
241
- fill: "currentColor"
242
- }
243
- ),
244
- /* @__PURE__ */ React.createElement(
245
- "path",
246
- {
247
- 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",
248
- fill: "currentColor"
249
- }
250
- )
251
- )
252
- };
253
- var ArrayIcons = {
254
- object: /* @__PURE__ */ React.createElement(
255
- "svg",
256
- {
257
- width: "1em",
258
- height: "1em",
259
- viewBox: "0 0 16 16",
260
- fill: "none",
261
- xmlns: "http://www.w3.org/2000/svg"
266
+ {
267
+ tag: [t.string],
268
+ color: colors.string
262
269
  },
263
- /* @__PURE__ */ React.createElement(
264
- "path",
265
- {
266
- fillRule: "evenodd",
267
- clipRule: "evenodd",
268
- 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",
269
- fill: "currentColor"
270
- }
271
- )
272
- ),
273
- boolean: /* @__PURE__ */ React.createElement(
274
- "svg",
275
- {
276
- width: "1em",
277
- height: "1em",
278
- viewBox: "0 0 16 16",
279
- fill: "none",
280
- xmlns: "http://www.w3.org/2000/svg"
270
+ {
271
+ tag: [t.number],
272
+ color: colors.number
281
273
  },
282
- /* @__PURE__ */ React.createElement(
283
- "path",
284
- {
285
- fillRule: "evenodd",
286
- clipRule: "evenodd",
287
- 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",
288
- fill: "currentColor"
289
- }
290
- )
291
- ),
292
- string: /* @__PURE__ */ React.createElement(
293
- "svg",
294
- {
295
- width: "1em",
296
- height: "1em",
297
- viewBox: "0 0 16 16",
298
- fill: "none",
299
- xmlns: "http://www.w3.org/2000/svg"
274
+ {
275
+ tag: [t.bool],
276
+ color: colors.boolean
300
277
  },
301
- /* @__PURE__ */ React.createElement(
302
- "path",
303
- {
304
- fillRule: "evenodd",
305
- clipRule: "evenodd",
306
- 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",
307
- fill: "currentColor"
308
- }
309
- )
310
- ),
311
- integer: /* @__PURE__ */ React.createElement(
312
- "svg",
313
- {
314
- width: "1em",
315
- height: "1em",
316
- viewBox: "0 0 16 16",
317
- fill: "none",
318
- xmlns: "http://www.w3.org/2000/svg"
278
+ {
279
+ tag: [t.null],
280
+ color: colors.null
319
281
  },
320
- /* @__PURE__ */ React.createElement(
321
- "path",
322
- {
323
- fillRule: "evenodd",
324
- clipRule: "evenodd",
325
- 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",
326
- fill: "currentColor"
327
- }
328
- )
329
- ),
330
- number: /* @__PURE__ */ React.createElement(
331
- "svg",
332
- {
333
- width: "1em",
334
- height: "1em",
335
- viewBox: "0 0 16 16",
336
- fill: "none",
337
- xmlns: "http://www.w3.org/2000/svg"
282
+ {
283
+ tag: [t.separator],
284
+ color: colors.separator
338
285
  },
339
- /* @__PURE__ */ React.createElement(
340
- "path",
341
- {
342
- fillRule: "evenodd",
343
- clipRule: "evenodd",
344
- 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",
345
- fill: "currentColor"
346
- }
347
- )
348
- )
349
- };
350
- var getSchemaIcon = (value) => {
351
- if (value?.type === "array") {
352
- return ArrayIcons[value.items?.type || "object"];
353
- }
354
- return VariableTypeIcons[value?.type || "object"];
286
+ // markdown
287
+ {
288
+ tag: [t.heading],
289
+ color: "#3e76ef"
290
+ },
291
+ {
292
+ tag: [t.processingInstruction],
293
+ color: "#3e76ef"
294
+ },
295
+ // shell
296
+ // curl
297
+ {
298
+ tag: [t.standard(t.variableName)],
299
+ color: "#00804A"
300
+ },
301
+ // -X
302
+ {
303
+ tag: [t.attributeName],
304
+ color: "#C74200"
305
+ },
306
+ // url in string (includes quotes), e.g. "https://..."
307
+ {
308
+ tag: [t.special(t.string)],
309
+ color: "#2B57D9"
310
+ }
311
+ ]
312
+ });
313
+
314
+ // src/components/code-editor/theme/dark.ts
315
+ import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
316
+ var colors2 = {
317
+ background: "#151B27",
318
+ // syntax
319
+ comment: "#FFFFFF63",
320
+ key: "#39E5D7",
321
+ string: "#FF94D2",
322
+ number: "#FF9933",
323
+ boolean: "#78B0FF",
324
+ null: "#78B0FF",
325
+ separator: "#FFFFFFC9"
355
326
  };
356
- var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
357
- var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
358
- var baseOptions = [
359
- {
360
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
361
- value: "string"
362
- },
363
- {
364
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
365
- value: "integer"
366
- },
367
- {
368
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
369
- value: "number"
370
- },
371
- {
372
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
373
- value: "boolean"
327
+ var darkTheme = createTheme2({
328
+ variant: "dark",
329
+ settings: {
330
+ background: colors2.background,
331
+ foreground: "#fff",
332
+ caret: "#AEAFAD",
333
+ selection: "#d9d9d942",
334
+ gutterBackground: colors2.background,
335
+ gutterForeground: "#FFFFFF63",
336
+ gutterBorderColor: "transparent",
337
+ gutterBorderWidth: 0,
338
+ lineHighlight: "#272e3d36",
339
+ bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
340
+ tooltip: {
341
+ backgroundColor: "#363D4D",
342
+ color: "#fff",
343
+ border: "none"
344
+ },
345
+ link: {
346
+ color: "#4daafc"
347
+ },
348
+ completionItemHover: {
349
+ backgroundColor: "#FFFFFF0F"
350
+ },
351
+ completionItemSelected: {
352
+ backgroundColor: "#FFFFFF17"
353
+ },
354
+ completionItemIcon: {
355
+ color: "#FFFFFFC9"
356
+ },
357
+ completionItemLabel: {
358
+ color: "#FFFFFFC9"
359
+ },
360
+ completionItemInfo: {
361
+ color: "#FFFFFFC9"
362
+ },
363
+ completionItemDetail: {
364
+ color: "#FFFFFF63"
365
+ }
374
366
  },
375
- {
376
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
377
- value: "object"
378
- }
379
- ];
380
- var options = [
381
- ...baseOptions,
382
- {
383
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
384
- value: "array",
385
- children: baseOptions.map((_opt) => ({
386
- ..._opt,
387
- value: `${_opt.value}`,
388
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
389
- Icon,
390
- {
391
- size: "small",
392
- svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
393
- }
394
- ), firstUppercase(_opt.value))
395
- }))
396
- }
397
- ];
398
-
399
- // src/utils/json-schema/index.ts
400
- import { get } from "lodash";
401
- import { ASTFactory, ASTKind, ASTMatch } from "@flowgram.ai/editor";
402
- var JsonSchemaUtils;
403
- ((JsonSchemaUtils2) => {
404
- function schemaToAST(jsonSchema) {
405
- const { type, extra } = jsonSchema || {};
406
- const { weak = false } = extra || {};
407
- if (!type) {
408
- return void 0;
367
+ styles: [
368
+ // json
369
+ {
370
+ tag: t2.comment,
371
+ color: colors2.comment
372
+ },
373
+ {
374
+ tag: [t2.propertyName],
375
+ color: colors2.key
376
+ },
377
+ {
378
+ tag: [t2.string],
379
+ color: colors2.string
380
+ },
381
+ {
382
+ tag: [t2.number],
383
+ color: colors2.number
384
+ },
385
+ {
386
+ tag: [t2.bool],
387
+ color: colors2.boolean
388
+ },
389
+ {
390
+ tag: [t2.null],
391
+ color: colors2.null
392
+ },
393
+ {
394
+ tag: [t2.separator],
395
+ color: colors2.separator
396
+ },
397
+ // markdown
398
+ {
399
+ tag: [t2.heading],
400
+ color: "#6b6bff"
401
+ },
402
+ {
403
+ tag: [t2.processingInstruction],
404
+ color: "#6b6bff"
405
+ },
406
+ // shell
407
+ // curl
408
+ {
409
+ tag: [t2.standard(t2.variableName)],
410
+ color: "#3BEB84"
411
+ },
412
+ // -X
413
+ {
414
+ tag: [t2.attributeName],
415
+ color: "#FF9933"
416
+ },
417
+ // url in string (includes quotes), e.g. "https://..."
418
+ {
419
+ tag: [t2.special(t2.string)],
420
+ color: "#78B0FF"
409
421
  }
410
- switch (type) {
411
- case "object":
412
- if (weak) {
413
- return { kind: ASTKind.Object, weak: true };
414
- }
415
- return ASTFactory.createObject({
416
- properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
417
- key,
418
- type: schemaToAST(_property),
419
- meta: {
420
- title: _property.title,
421
- description: _property.description
422
- }
423
- }))
424
- });
425
- case "array":
426
- if (weak) {
427
- return { kind: ASTKind.Array, weak: true };
428
- }
429
- return ASTFactory.createArray({
430
- items: schemaToAST(jsonSchema.items)
431
- });
432
- case "map":
433
- if (weak) {
434
- return { kind: ASTKind.Map, weak: true };
435
- }
436
- return ASTFactory.createMap({
437
- valueType: schemaToAST(jsonSchema.additionalProperties)
438
- });
439
- case "string":
440
- return ASTFactory.createString();
441
- case "number":
442
- return ASTFactory.createNumber();
443
- case "boolean":
444
- return ASTFactory.createBoolean();
445
- case "integer":
446
- return ASTFactory.createInteger();
447
- default:
448
- return ASTFactory.createCustomType({ typeName: type });
449
- }
450
- }
451
- JsonSchemaUtils2.schemaToAST = schemaToAST;
452
- function astToSchema(typeAST, options2) {
453
- const { drilldown = true } = options2 || {};
454
- if (ASTMatch.isString(typeAST)) {
455
- return {
456
- type: "string"
457
- };
422
+ ]
423
+ });
424
+
425
+ // src/components/code-editor/theme/index.ts
426
+ themes.register("dark", darkTheme);
427
+ themes.register("light", lightTheme);
428
+
429
+ // src/components/code-editor/index.tsx
430
+ var OriginCodeEditor = createRenderer(preset, [
431
+ EditorView.theme({
432
+ "&.cm-focused": {
433
+ outline: "none"
458
434
  }
459
- if (ASTMatch.isBoolean(typeAST)) {
460
- return {
461
- type: "boolean"
462
- };
435
+ })
436
+ ]);
437
+ function CodeEditor({
438
+ value,
439
+ onChange,
440
+ languageId = "python",
441
+ theme = "light",
442
+ children,
443
+ placeholder,
444
+ activeLinePlaceholder,
445
+ options,
446
+ readonly
447
+ }) {
448
+ const editorRef = useRef(null);
449
+ useEffect(() => {
450
+ if (languageId === "typescript") {
451
+ initTsWorker();
463
452
  }
464
- if (ASTMatch.isNumber(typeAST)) {
465
- return {
466
- type: "number"
467
- };
453
+ }, [languageId]);
454
+ useEffect(() => {
455
+ if (editorRef.current?.getValue() !== value) {
456
+ editorRef.current?.setValue(String(value || ""));
468
457
  }
469
- if (ASTMatch.isInteger(typeAST)) {
470
- return {
471
- type: "integer"
472
- };
458
+ }, [value]);
459
+ return /* @__PURE__ */ React3.createElement(EditorProvider, null, /* @__PURE__ */ React3.createElement(
460
+ OriginCodeEditor,
461
+ {
462
+ defaultValue: value,
463
+ options: {
464
+ uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
465
+ languageId,
466
+ theme,
467
+ placeholder,
468
+ readOnly: readonly,
469
+ editable: !readonly,
470
+ ...options || {}
471
+ },
472
+ didMount: (editor) => {
473
+ editorRef.current = editor;
474
+ },
475
+ onChange: (e) => onChange?.(e.value)
476
+ },
477
+ activeLinePlaceholder && /* @__PURE__ */ React3.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
478
+ children
479
+ ));
480
+ }
481
+
482
+ // src/components/code-editor-mini/index.tsx
483
+ var UIMini = styled.div`
484
+ .ͼ1 .cm-content {
485
+ padding: 0;
486
+ }
487
+ `;
488
+ function CodeEditorMini(props) {
489
+ return /* @__PURE__ */ React4.createElement(UIMini, null, /* @__PURE__ */ React4.createElement(
490
+ CodeEditor,
491
+ {
492
+ ...props,
493
+ options: {
494
+ lineNumbersGutter: false,
495
+ foldGutter: false,
496
+ ...props.options || {}
497
+ }
473
498
  }
474
- if (ASTMatch.isObject(typeAST)) {
475
- return {
476
- type: "object",
477
- properties: drilldown ? Object.fromEntries(
478
- typeAST.properties.map((property) => {
479
- const schema = astToSchema(property.type);
480
- if (property.meta?.title && schema) {
481
- schema.title = property.meta.title;
482
- }
483
- if (property.meta?.description && schema) {
484
- schema.description = property.meta.description;
485
- }
486
- return [property.key, schema];
487
- })
488
- ) : {}
489
- };
499
+ ));
500
+ }
501
+
502
+ // src/plugins/json-schema-preset/type-definition/object.tsx
503
+ var objectRegistry = {
504
+ type: "object",
505
+ ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
506
+ CodeEditorMini,
507
+ {
508
+ value: props.value,
509
+ onChange: (v) => props.onChange?.(v),
510
+ languageId: "json",
511
+ placeholder: I18n2.t("Please Input Object"),
512
+ readonly: props.readonly
490
513
  }
491
- if (ASTMatch.isArray(typeAST)) {
492
- return {
493
- type: "array",
494
- items: drilldown ? astToSchema(typeAST.items) : void 0
495
- };
496
- }
497
- if (ASTMatch.isMap(typeAST)) {
498
- return {
499
- type: "map",
500
- items: drilldown ? astToSchema(typeAST.valueType) : void 0
501
- };
514
+ )
515
+ };
516
+
517
+ // src/plugins/json-schema-preset/type-definition/number.tsx
518
+ import React6 from "react";
519
+ import { I18n as I18n3 } from "@flowgram.ai/editor";
520
+ import { InputNumber } from "@douyinfe/semi-ui";
521
+ var numberRegistry = {
522
+ type: "number",
523
+ ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
524
+ InputNumber,
525
+ {
526
+ placeholder: I18n3.t("Please Input Number"),
527
+ size: "small",
528
+ disabled: props.readonly,
529
+ hideButtons: true,
530
+ ...props
502
531
  }
503
- if (ASTMatch.isCustomType(typeAST)) {
504
- return {
505
- type: typeAST.typeName
506
- };
532
+ )
533
+ };
534
+
535
+ // src/plugins/json-schema-preset/type-definition/integer.tsx
536
+ import React7 from "react";
537
+ import { I18n as I18n4 } from "@flowgram.ai/editor";
538
+ import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
539
+ var integerRegistry = {
540
+ type: "integer",
541
+ ConstantRenderer: (props) => /* @__PURE__ */ React7.createElement(
542
+ InputNumber2,
543
+ {
544
+ placeholder: I18n4.t("Please Input Integer"),
545
+ size: "small",
546
+ disabled: props.readonly,
547
+ precision: 0,
548
+ ...props
507
549
  }
508
- return void 0;
550
+ )
551
+ };
552
+
553
+ // src/plugins/json-schema-preset/type-definition/boolean.tsx
554
+ import React8 from "react";
555
+ import { I18n as I18n5 } from "@flowgram.ai/editor";
556
+ import { Select } from "@douyinfe/semi-ui";
557
+ var booleanRegistry = {
558
+ type: "boolean",
559
+ ConstantRenderer: (props) => {
560
+ const { value, onChange, ...rest } = props;
561
+ return /* @__PURE__ */ React8.createElement(
562
+ Select,
563
+ {
564
+ placeholder: I18n5.t("Please Select Boolean"),
565
+ size: "small",
566
+ disabled: props.readonly,
567
+ optionList: [
568
+ { label: I18n5.t("True"), value: 1 },
569
+ { label: I18n5.t("False"), value: 0 }
570
+ ],
571
+ value: value ? 1 : 0,
572
+ onChange: (value2) => onChange?.(!!value2),
573
+ ...rest
574
+ }
575
+ );
509
576
  }
510
- JsonSchemaUtils2.astToSchema = astToSchema;
511
- function isASTMatchSchema(typeAST, schema) {
512
- if (Array.isArray(schema)) {
513
- return typeAST.isTypeEqual(
514
- ASTFactory.createUnion({
515
- types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
516
- })
517
- );
577
+ };
578
+
579
+ // src/plugins/json-schema-preset/type-definition/array.tsx
580
+ import React9 from "react";
581
+ import { I18n as I18n6 } from "@flowgram.ai/editor";
582
+ var arrayRegistry = {
583
+ type: "array",
584
+ ConstantRenderer: (props) => /* @__PURE__ */ React9.createElement(
585
+ CodeEditorMini,
586
+ {
587
+ value: props.value,
588
+ languageId: "json",
589
+ onChange: (v) => props.onChange?.(v),
590
+ placeholder: I18n6.t("Please Input Array"),
591
+ readonly: props.readonly
518
592
  }
519
- return typeAST.isTypeEqual(schemaToAST(schema));
593
+ )
594
+ };
595
+
596
+ // src/plugins/json-schema-preset/type-definition/index.tsx
597
+ var jsonSchemaTypePreset = [
598
+ stringRegistry,
599
+ objectRegistry,
600
+ numberRegistry,
601
+ integerRegistry,
602
+ booleanRegistry,
603
+ arrayRegistry
604
+ ];
605
+ jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
606
+
607
+ // src/plugins/json-schema-preset/create-type-preset-plugin.tsx
608
+ import {
609
+ BaseTypeManager,
610
+ jsonSchemaContainerModule
611
+ } from "@flowgram.ai/json-schema";
612
+ import { definePluginCreator } from "@flowgram.ai/editor";
613
+ var createTypePresetPlugin = definePluginCreator({
614
+ onInit(ctx, opts) {
615
+ const typeManager = ctx.get(BaseTypeManager);
616
+ jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
617
+ opts.types?.forEach((_type) => typeManager.register(_type));
618
+ opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
619
+ },
620
+ containerModules: [jsonSchemaContainerModule]
621
+ });
622
+
623
+ // src/plugins/json-schema-preset/index.tsx
624
+ var useTypeManager = () => useOriginTypeManager();
625
+ var JsonSchemaTypePresetProvider = ({
626
+ types = [],
627
+ children
628
+ }) => /* @__PURE__ */ React10.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
629
+
630
+ // src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
631
+ import {
632
+ ASTMatch,
633
+ definePluginCreator as definePluginCreator2,
634
+ VariableEngine
635
+ } from "@flowgram.ai/editor";
636
+ var createDisableDeclarationPlugin = definePluginCreator2({
637
+ onInit(ctx) {
638
+ const variableEngine = ctx.get(VariableEngine);
639
+ const handleEvent = (action) => {
640
+ if (ASTMatch.isVariableDeclaration(action.ast)) {
641
+ if (!action.ast.meta?.disabled) {
642
+ action.ast.updateMeta({
643
+ ...action.ast.meta || {},
644
+ disabled: true
645
+ });
646
+ }
647
+ }
648
+ };
649
+ variableEngine.onGlobalEvent("NewAST", handleEvent);
650
+ variableEngine.onGlobalEvent("UpdateAST", handleEvent);
520
651
  }
521
- JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
522
- })(JsonSchemaUtils || (JsonSchemaUtils = {}));
652
+ });
523
653
 
524
654
  // src/components/variable-selector/use-variable-tree.tsx
525
655
  function useVariableTree(params) {
526
- const { includeSchema, excludeSchema } = params;
656
+ const { includeSchema, excludeSchema, customSkip } = params;
657
+ const typeManager = useTypeManager();
527
658
  const variables = useAvailableVariables();
528
659
  const getVariableTypeIcon = useCallback((variable) => {
529
660
  if (variable.meta?.icon) {
530
661
  if (typeof variable.meta.icon === "string") {
531
- return /* @__PURE__ */ React2.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
662
+ return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
532
663
  }
533
664
  return variable.meta.icon;
534
665
  }
535
- const _type = variable.type;
536
- if (ASTMatch2.isArray(_type)) {
537
- return /* @__PURE__ */ React2.createElement(
538
- Icon2,
539
- {
540
- size: "small",
541
- svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
542
- }
543
- );
544
- }
545
- if (ASTMatch2.isCustomType(_type)) {
546
- return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
547
- }
548
- return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
666
+ const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
667
+ return /* @__PURE__ */ React11.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
549
668
  }, []);
550
669
  const renderVariable = (variable, parentFields = []) => {
551
670
  let type = variable?.type;
@@ -558,9 +677,11 @@ function useVariableTree(params) {
558
677
  }
559
678
  const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
560
679
  const key = keyPath.join(".");
561
- const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
562
- const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
563
- const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
680
+ const isSchemaInclude = includeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, includeSchema) : true;
681
+ const isSchemaExclude = excludeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, excludeSchema) : false;
682
+ const isCustomSkip = customSkip ? customSkip(variable) : false;
683
+ const isMetaDisabled = variable.meta?.disabled;
684
+ const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
564
685
  if (!isSchemaMatch && !children?.length) {
565
686
  return null;
566
687
  }
@@ -572,16 +693,17 @@ function useVariableTree(params) {
572
693
  icon: getVariableTypeIcon(variable),
573
694
  children,
574
695
  disabled: !isSchemaMatch,
575
- rootMeta: parentFields[0]?.meta
696
+ rootMeta: parentFields[0]?.meta || variable.meta,
697
+ isRoot: !parentFields?.length
576
698
  };
577
699
  };
578
700
  return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
579
701
  }
580
702
 
581
703
  // src/components/variable-selector/styles.tsx
582
- import styled from "styled-components";
704
+ import styled2, { css } from "styled-components";
583
705
  import { Tag, TreeSelect } from "@douyinfe/semi-ui";
584
- var UIRootTitle = styled.div`
706
+ var UIRootTitle = styled2.div`
585
707
  margin-right: 4px;
586
708
  min-width: 20px;
587
709
  overflow: hidden;
@@ -589,13 +711,16 @@ var UIRootTitle = styled.div`
589
711
  white-space: nowrap;
590
712
  color: var(--semi-color-text-2);
591
713
  `;
592
- var UIVarName = styled.div`
714
+ var UIVarName = styled2.div`
593
715
  overflow: hidden;
594
716
  text-overflow: ellipsis;
595
717
  white-space: nowrap;
596
- min-width: 50%;
718
+
719
+ ${({ $inSelector }) => $inSelector && css`
720
+ min-width: 50%;
721
+ `}
597
722
  `;
598
- var UITag = styled(Tag)`
723
+ var UITag = styled2(Tag)`
599
724
  width: 100%;
600
725
  display: flex;
601
726
  align-items: center;
@@ -607,17 +732,14 @@ var UITag = styled(Tag)`
607
732
 
608
733
  &.semi-tag {
609
734
  margin: 0;
735
+ height: 22px;
610
736
  }
611
737
  `;
612
- var UITreeSelect = styled(TreeSelect)`
738
+ var UITreeSelect = styled2(TreeSelect)`
613
739
  outline: ${({ $error }) => $error ? "1px solid red" : "none"};
614
740
 
615
- height: 22px;
616
- min-height: 22px;
617
- line-height: 22px;
618
-
619
741
  & .semi-tree-select-selection {
620
- padding: 0 2px;
742
+ padding: 0px;
621
743
  height: 22px;
622
744
  }
623
745
 
@@ -629,6 +751,13 @@ var UITreeSelect = styled(TreeSelect)`
629
751
  padding-left: 10px;
630
752
  }
631
753
  `;
754
+ var UIPopoverContent = styled2.div`
755
+ padding: 10px;
756
+ display: inline-flex;
757
+ align-items: center;
758
+ justify-content: flex-start;
759
+ white-space: nowrap;
760
+ `;
632
761
 
633
762
  // src/components/variable-selector/index.tsx
634
763
  var VariableSelector = ({
@@ -655,11 +784,11 @@ var VariableSelector = ({
655
784
  }, [value]);
656
785
  const renderIcon = (icon) => {
657
786
  if (typeof icon === "string") {
658
- return /* @__PURE__ */ React3.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
787
+ return /* @__PURE__ */ React12.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
659
788
  }
660
789
  return icon;
661
790
  };
662
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
791
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
663
792
  UITreeSelect,
664
793
  {
665
794
  dropdownMatchSelectWidth: false,
@@ -676,10 +805,10 @@ var VariableSelector = ({
676
805
  },
677
806
  renderSelectedItem: (_option) => {
678
807
  if (!_option?.keyPath) {
679
- return /* @__PURE__ */ React3.createElement(
808
+ return /* @__PURE__ */ React12.createElement(
680
809
  UITag,
681
810
  {
682
- prefixIcon: /* @__PURE__ */ React3.createElement(IconIssueStroked, null),
811
+ prefixIcon: /* @__PURE__ */ React12.createElement(IconIssueStroked, null),
683
812
  color: "amber",
684
813
  closable: !readonly,
685
814
  onClose: () => onChange(void 0)
@@ -687,28 +816,39 @@ var VariableSelector = ({
687
816
  config?.notFoundContent ?? "Undefined"
688
817
  );
689
818
  }
690
- return /* @__PURE__ */ React3.createElement(
691
- UITag,
819
+ const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
820
+ const rootTitle = /* @__PURE__ */ React12.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
821
+ return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(
822
+ Popover,
692
823
  {
693
- prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
694
- closable: !readonly,
695
- onClose: () => onChange(void 0)
824
+ content: /* @__PURE__ */ React12.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React12.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
696
825
  },
697
- /* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
698
- /* @__PURE__ */ React3.createElement(UIVarName, null, _option.label)
699
- );
826
+ /* @__PURE__ */ React12.createElement(
827
+ UITag,
828
+ {
829
+ prefixIcon: rootIcon,
830
+ closable: !readonly,
831
+ onClose: () => onChange(void 0)
832
+ },
833
+ rootTitle,
834
+ !_option.isRoot && /* @__PURE__ */ React12.createElement(UIVarName, { $inSelector: true }, _option.label)
835
+ )
836
+ ));
700
837
  },
701
838
  showClear: false,
702
- arrowIcon: /* @__PURE__ */ React3.createElement(IconChevronDownStroked, { size: "small" }),
839
+ arrowIcon: /* @__PURE__ */ React12.createElement(IconChevronDownStroked, { size: "small" }),
703
840
  triggerRender,
704
- placeholder: config?.placeholder ?? "Select Variable..."
841
+ placeholder: config?.placeholder ?? I18n7.t("Select Variable")
705
842
  }
706
843
  ));
707
844
  };
845
+ VariableSelector.renderKey = "variable-selector-render-key";
846
+ var InjectVariableSelector = createInjectMaterial(VariableSelector);
708
847
 
709
848
  // src/components/type-selector/index.tsx
710
- import React4, { useMemo as useMemo2 } from "react";
711
- import { Button, Cascader } from "@douyinfe/semi-ui";
849
+ import React13, { useMemo as useMemo2 } from "react";
850
+ import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
851
+ var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
712
852
  var getTypeSelectValue = (value) => {
713
853
  if (value?.type === "array" && value?.items) {
714
854
  return [value.type, ...getTypeSelectValue(value.items) || []];
@@ -723,27 +863,55 @@ var parseTypeSelectValue = (value) => {
723
863
  return { type };
724
864
  };
725
865
  function TypeSelector(props) {
726
- const { value, onChange, disabled, style } = props;
866
+ const { value, onChange, readonly, disabled, style } = props;
727
867
  const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
728
- return /* @__PURE__ */ React4.createElement(
868
+ const typeManager = useTypeManager();
869
+ const icon = typeManager.getDisplayIcon(value || {});
870
+ const options = useMemo2(
871
+ () => typeManager.getTypeRegistriesWithParentType().map((_type) => {
872
+ const isArray2 = _type.type === "array";
873
+ return {
874
+ label: /* @__PURE__ */ React13.createElement("div", { style: labelStyle }, /* @__PURE__ */ React13.createElement(Icon2, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
875
+ value: _type.type,
876
+ children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
877
+ label: /* @__PURE__ */ React13.createElement("div", { style: labelStyle }, /* @__PURE__ */ React13.createElement(
878
+ Icon2,
879
+ {
880
+ size: "small",
881
+ svg: typeManager.getDisplayIcon({
882
+ type: "array",
883
+ items: { type: _type2.type }
884
+ })
885
+ }
886
+ ), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
887
+ value: _type2.type
888
+ })) : []
889
+ };
890
+ }),
891
+ []
892
+ );
893
+ return /* @__PURE__ */ React13.createElement(
729
894
  Cascader,
730
895
  {
731
- disabled,
896
+ disabled: readonly || disabled,
732
897
  size: "small",
733
- triggerRender: () => /* @__PURE__ */ React4.createElement(Button, { size: "small", style }, getSchemaIcon(value)),
898
+ triggerRender: () => /* @__PURE__ */ React13.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
734
899
  treeData: options,
735
900
  value: selectValue,
736
901
  leafOnly: true,
737
902
  onChange: (value2) => {
738
- onChange(parseTypeSelectValue(value2));
903
+ onChange?.(parseTypeSelectValue(value2));
739
904
  }
740
905
  }
741
906
  );
742
907
  }
908
+ TypeSelector.renderKey = "type-selector-render-key";
909
+ var InjectTypeSelector = createInjectMaterial(TypeSelector);
743
910
 
744
911
  // src/components/json-schema-editor/index.tsx
745
- import React9, { useMemo as useMemo5, useState as useState4 } from "react";
746
- import { Button as Button2, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
912
+ import React18, { useMemo as useMemo4, useState as useState3 } from "react";
913
+ import { I18n as I18n9 } from "@flowgram.ai/editor";
914
+ import { Button, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
747
915
  import {
748
916
  IconExpand,
749
917
  IconShrink,
@@ -754,45 +922,45 @@ import {
754
922
  } from "@douyinfe/semi-icons";
755
923
 
756
924
  // src/components/json-schema-editor/styles.tsx
757
- import React5 from "react";
758
- import styled2, { css } from "styled-components";
925
+ import React14 from "react";
926
+ import styled3, { css as css2 } from "styled-components";
759
927
  import Icon3 from "@douyinfe/semi-icons";
760
- var UIContainer = styled2.div`
928
+ var UIContainer = styled3.div`
761
929
  /* & .semi-input {
762
930
  background-color: #fff;
763
931
  border-radius: 6px;
764
932
  height: 24px;
765
933
  } */
766
934
  `;
767
- var UIRow = styled2.div`
935
+ var UIRow = styled3.div`
768
936
  display: flex;
769
937
  align-items: center;
770
938
  gap: 6px;
771
939
  `;
772
- var UICollapseTrigger = styled2.div`
940
+ var UICollapseTrigger = styled3.div`
773
941
  cursor: pointer;
774
942
  margin-right: 5px;
775
943
  `;
776
- var UIExpandDetail = styled2.div`
944
+ var UIExpandDetail = styled3.div`
777
945
  display: flex;
778
946
  flex-direction: column;
779
947
  `;
780
- var UILabel = styled2.div`
948
+ var UILabel = styled3.div`
781
949
  font-size: 12px;
782
950
  color: #999;
783
951
  font-weight: 400;
784
952
  margin-bottom: 2px;
785
953
  `;
786
- var UIProperties = styled2.div`
954
+ var UIProperties = styled3.div`
787
955
  display: grid;
788
956
  grid-template-columns: auto 1fr;
789
957
 
790
- ${({ $shrink }) => $shrink && css`
958
+ ${({ $shrink }) => $shrink && css2`
791
959
  padding-left: 10px;
792
960
  margin-top: 10px;
793
961
  `}
794
962
  `;
795
- var UIPropertyLeft = styled2.div`
963
+ var UIPropertyLeft = styled3.div`
796
964
  grid-column: 1;
797
965
  position: relative;
798
966
  width: 16px;
@@ -802,7 +970,7 @@ var UIPropertyLeft = styled2.div`
802
970
  if ($parentType && $isLast) {
803
971
  height = "24px";
804
972
  }
805
- return $showLine && css`
973
+ return $showLine && css2`
806
974
  &::before {
807
975
  /* 竖线 */
808
976
  content: '';
@@ -829,7 +997,7 @@ var UIPropertyLeft = styled2.div`
829
997
  `;
830
998
  }}
831
999
  `;
832
- var UIPropertyRight = styled2.div`
1000
+ var UIPropertyRight = styled3.div`
833
1001
  grid-column: 2;
834
1002
  margin-bottom: 10px;
835
1003
 
@@ -837,7 +1005,7 @@ var UIPropertyRight = styled2.div`
837
1005
  margin-bottom: 0px;
838
1006
  }
839
1007
  `;
840
- var UIPropertyMain = styled2.div`
1008
+ var UIPropertyMain = styled3.div`
841
1009
  display: flex;
842
1010
  flex-direction: column;
843
1011
  gap: 10px;
@@ -856,33 +1024,33 @@ var UIPropertyMain = styled2.div`
856
1024
  background: #d9d9d9;
857
1025
  display: block;
858
1026
  }`;
859
- return $expand && css`
1027
+ return $expand && css2`
860
1028
  background-color: #f5f5f5;
861
1029
  padding: 10px;
862
1030
  border-radius: 4px;
863
1031
 
864
- ${$showCollapse && $collapse && (type === "array" || type === "object") && css`
1032
+ ${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
865
1033
  ${beforeElement}
866
1034
  `}
867
1035
  `;
868
1036
  }}
869
1037
  `;
870
- var UICollapsible = styled2.div`
1038
+ var UICollapsible = styled3.div`
871
1039
  display: none;
872
1040
 
873
- ${({ $collapse }) => $collapse && css`
1041
+ ${({ $collapse }) => $collapse && css2`
874
1042
  display: block;
875
1043
  `}
876
1044
  `;
877
- var UIName = styled2.div`
1045
+ var UIName = styled3.div`
878
1046
  flex-grow: 1;
879
1047
  `;
880
- var UIType = styled2.div``;
881
- var UIRequired = styled2.div``;
882
- var UIActions = styled2.div`
1048
+ var UIType = styled3.div``;
1049
+ var UIRequired = styled3.div``;
1050
+ var UIActions = styled3.div`
883
1051
  white-space: nowrap;
884
1052
  `;
885
- var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
1053
+ var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
886
1054
  "svg",
887
1055
  {
888
1056
  className: "icon-icon icon-icon-coz_add_node ",
@@ -892,7 +1060,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
892
1060
  fill: "currentColor",
893
1061
  xmlns: "http://www.w3.org/2000/svg"
894
1062
  },
895
- /* @__PURE__ */ React5.createElement(
1063
+ /* @__PURE__ */ React14.createElement(
896
1064
  "path",
897
1065
  {
898
1066
  fillRule: "evenodd",
@@ -900,38 +1068,13 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
900
1068
  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"
901
1069
  }
902
1070
  ),
903
- /* @__PURE__ */ React5.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" })
1071
+ /* @__PURE__ */ React14.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" })
904
1072
  );
905
- var IconAddChildren = () => /* @__PURE__ */ React5.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
906
- var DefaultValueWrapper = styled2.div`
1073
+ var IconAddChildren = () => /* @__PURE__ */ React14.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
1074
+ var DefaultValueWrapper = styled3.div`
907
1075
  margin: 0;
908
1076
  `;
909
- var JSONViewerWrapper = styled2.div`
910
- padding: 0 0 24px;
911
- &:first-child {
912
- margin-top: 0px;
913
- }
914
- `;
915
- var JSONHeader = styled2.div`
916
- display: flex;
917
- justify-content: space-between;
918
- align-items: center;
919
- background-color: var(--semi-color-fill-0);
920
- border-radius: 6px 6px 0 0;
921
- height: 36px;
922
- padding: 0 8px 0 12px;
923
- `;
924
- var JSONHeaderLeft = styled2.div`
925
- display: flex;
926
- align-items: center;
927
- gap: 10px;
928
- `;
929
- var JSONHeaderRight = styled2.div`
930
- display: flex;
931
- align-items: center;
932
- gap: 10px;
933
- `;
934
- var ConstantInputWrapper = styled2.div`
1077
+ var ConstantInputWrapper = styled3.div`
935
1078
  flex-grow: 1;
936
1079
 
937
1080
  & .semi-tree-select,
@@ -942,71 +1085,39 @@ var ConstantInputWrapper = styled2.div`
942
1085
  `;
943
1086
 
944
1087
  // src/components/json-schema-editor/hooks.tsx
945
- import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
946
- import { omit } from "lodash";
1088
+ import { useEffect as useEffect2, useState } from "react";
1089
+ import { difference, omit } from "lodash";
1090
+ import { produce } from "immer";
1091
+ import { useTypeManager as useTypeManager2 } from "@flowgram.ai/json-schema";
947
1092
  var _id = 0;
948
1093
  function genId() {
949
1094
  return _id++;
950
1095
  }
951
- function getDrilldownSchema(value, path) {
952
- if (!value) {
953
- return {};
954
- }
955
- if (value.type === "array" && value.items) {
956
- return getDrilldownSchema(value.items, [...path || [], "items"]);
957
- }
958
- return { schema: value, path };
959
- }
960
1096
  function usePropertiesEdit(value, onChange) {
961
- const drilldown = useMemo3(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
962
- const isDrilldownObject = drilldown.schema?.type === "object";
963
- const initPropertyList = useMemo3(
964
- () => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
965
- ([name, _value], index) => ({
966
- key: genId(),
967
- name,
968
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
969
- ..._value,
970
- extra: {
971
- ..._value.extra || {},
972
- index
973
- }
974
- })
975
- ) : [],
976
- [isDrilldownObject]
977
- );
978
- const [propertyList, setPropertyList] = useState(initPropertyList);
979
- const mountRef = useRef(false);
980
- useEffect(() => {
981
- if (mountRef.current) {
982
- setPropertyList((_list) => {
983
- const nameMap = /* @__PURE__ */ new Map();
984
- for (const _property of _list) {
985
- if (_property.name) {
986
- nameMap.set(_property.name, _property);
987
- }
988
- }
989
- return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
990
- const _property = nameMap.get(name);
991
- if (_property) {
992
- return {
993
- key: _property.key,
994
- name,
995
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
996
- ..._value
997
- };
998
- }
999
- return {
1000
- key: genId(),
1001
- name,
1002
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1003
- ..._value
1004
- };
1005
- });
1006
- });
1007
- }
1008
- mountRef.current = true;
1009
- }, [drilldown.schema]);
1097
+ const typeManager = useTypeManager2();
1098
+ const drilldownSchema = typeManager.getPropertiesParent(value || {});
1099
+ const canAddField = typeManager.canAddField(value || {});
1100
+ const [propertyList, setPropertyList] = useState([]);
1101
+ useEffect2(() => {
1102
+ setPropertyList((_list) => {
1103
+ const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
1104
+ const oldNames = _list.map((item) => item.name).filter(Boolean);
1105
+ const addNames = difference(newNames, oldNames);
1106
+ return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
1107
+ key: item.key,
1108
+ name: item.name,
1109
+ isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
1110
+ ...item
1111
+ })).concat(
1112
+ addNames.map((_name) => ({
1113
+ key: genId(),
1114
+ name: _name,
1115
+ isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
1116
+ ...drilldownSchema?.properties?.[_name] || {}
1117
+ }))
1118
+ );
1119
+ });
1120
+ }, [drilldownSchema]);
1010
1121
  const updatePropertyList = (updater) => {
1011
1122
  setPropertyList((_list) => {
1012
1123
  const next = updater(_list);
@@ -1021,18 +1132,21 @@ function usePropertiesEdit(value, onChange) {
1021
1132
  nextRequired.push(_property.name);
1022
1133
  }
1023
1134
  }
1024
- let drilldownSchema = value || {};
1025
- if (drilldown.path) {
1026
- drilldownSchema = drilldown.path.reduce((acc, key) => acc[key], value || {});
1027
- }
1028
- drilldownSchema.properties = nextProperties;
1029
- drilldownSchema.required = nextRequired;
1030
- onChange?.(value || {});
1135
+ onChange?.(
1136
+ produce(value || {}, (draft) => {
1137
+ const propertiesParent = typeManager.getPropertiesParent(draft);
1138
+ if (propertiesParent) {
1139
+ propertiesParent.properties = nextProperties;
1140
+ propertiesParent.required = nextRequired;
1141
+ return;
1142
+ }
1143
+ })
1144
+ );
1031
1145
  return next;
1032
1146
  });
1033
1147
  };
1034
1148
  const onAddProperty = () => {
1035
- updatePropertyList((_list) => [
1149
+ setPropertyList((_list) => [
1036
1150
  ..._list,
1037
1151
  { key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
1038
1152
  ]);
@@ -1045,14 +1159,14 @@ function usePropertiesEdit(value, onChange) {
1045
1159
  (_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
1046
1160
  );
1047
1161
  };
1048
- useEffect(() => {
1049
- if (!isDrilldownObject) {
1162
+ useEffect2(() => {
1163
+ if (!canAddField) {
1050
1164
  setPropertyList([]);
1051
1165
  }
1052
- }, [isDrilldownObject]);
1166
+ }, [canAddField]);
1053
1167
  return {
1054
1168
  propertyList,
1055
- isDrilldownObject,
1169
+ canAddField,
1056
1170
  onAddProperty,
1057
1171
  onRemoveProperty,
1058
1172
  onEditProperty
@@ -1060,195 +1174,60 @@ function usePropertiesEdit(value, onChange) {
1060
1174
  }
1061
1175
 
1062
1176
  // src/components/json-schema-editor/default-value.tsx
1063
- import React7, { useRef as useRef2, useState as useState2, useCallback as useCallback2 } from "react";
1064
- import { IconButton, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
1065
- import { IconBrackets } from "@douyinfe/semi-icons";
1066
-
1067
- // src/components/json-schema-editor/utils.ts
1068
- function getValueType(value) {
1069
- const type = typeof value;
1070
- if (type === "string") {
1071
- return "string";
1072
- } else if (type === "number") {
1073
- return Number.isInteger(value) ? "integer" : "number";
1074
- } else if (type === "boolean") {
1075
- return "boolean";
1076
- } else if (type === "object") {
1077
- if (value === null) {
1078
- return "other";
1079
- }
1080
- return Array.isArray(value) ? "array" : "object";
1081
- } else {
1082
- return "other";
1083
- }
1084
- }
1177
+ import React16 from "react";
1178
+ import { I18n as I18n8 } from "@flowgram.ai/editor";
1085
1179
 
1086
1180
  // src/components/constant-input/index.tsx
1087
- import React6, { useMemo as useMemo4 } from "react";
1088
- import { Input, InputNumber, Select } from "@douyinfe/semi-ui";
1089
- var defaultStrategies = [
1090
- {
1091
- hit: (schema) => schema?.type === "string",
1092
- Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1093
- },
1094
- {
1095
- hit: (schema) => schema?.type === "number",
1096
- Renderer: (props) => /* @__PURE__ */ React6.createElement(
1097
- InputNumber,
1098
- {
1099
- placeholder: "Please Input Number",
1100
- size: "small",
1101
- disabled: props.readonly,
1102
- hideButtons: true,
1103
- ...props
1104
- }
1105
- )
1106
- },
1107
- {
1108
- hit: (schema) => schema?.type === "integer",
1109
- Renderer: (props) => /* @__PURE__ */ React6.createElement(
1110
- InputNumber,
1111
- {
1112
- placeholder: "Please Input Integer",
1113
- size: "small",
1114
- disabled: props.readonly,
1115
- hideButtons: true,
1116
- precision: 0,
1117
- ...props
1118
- }
1119
- )
1120
- },
1121
- {
1122
- hit: (schema) => schema?.type === "boolean",
1123
- Renderer: (props) => {
1124
- const { value, onChange, ...rest } = props;
1125
- return /* @__PURE__ */ React6.createElement(
1126
- Select,
1127
- {
1128
- placeholder: "Please Select Boolean",
1129
- size: "small",
1130
- disabled: props.readonly,
1131
- optionList: [
1132
- { label: "True", value: 1 },
1133
- { label: "False", value: 0 }
1134
- ],
1135
- value: value ? 1 : 0,
1136
- onChange: (value2) => onChange?.(!!value2),
1137
- ...rest
1138
- }
1139
- );
1140
- }
1141
- }
1142
- ];
1181
+ import React15, { useMemo as useMemo3 } from "react";
1182
+ import { Input as Input2 } from "@douyinfe/semi-ui";
1143
1183
  function ConstantInput(props) {
1144
- const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1145
- const strategies = useMemo4(
1146
- () => [...defaultStrategies, ...extraStrategies || []],
1147
- [extraStrategies]
1148
- );
1149
- const Renderer2 = useMemo4(() => {
1150
- const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1184
+ const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
1185
+ const typeManager = useTypeManager();
1186
+ const Renderer2 = useMemo3(() => {
1187
+ const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
1188
+ if (!strategy) {
1189
+ return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
1190
+ }
1151
1191
  return strategy?.Renderer;
1152
1192
  }, [strategies, schema]);
1153
1193
  if (!Renderer2) {
1154
- return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1194
+ if (fallbackRenderer) {
1195
+ return React15.createElement(fallbackRenderer, {
1196
+ value,
1197
+ onChange,
1198
+ readonly,
1199
+ ...rest
1200
+ });
1201
+ }
1202
+ return /* @__PURE__ */ React15.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
1155
1203
  }
1156
- return /* @__PURE__ */ React6.createElement(Renderer2, { value, onChange, readonly, ...rest });
1204
+ return /* @__PURE__ */ React15.createElement(Renderer2, { value, onChange, readonly, ...rest });
1157
1205
  }
1158
1206
 
1159
1207
  // src/components/json-schema-editor/default-value.tsx
1160
1208
  function DefaultValue(props) {
1161
- const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
1162
- const wrapperRef = useRef2(null);
1163
- const JsonViewerRef = useRef2(null);
1164
- const [internalJsonValue, setInternalJsonValue] = useState2(
1165
- getValueType(value) === "string" ? value : ""
1166
- );
1167
- const handleJsonChange = useCallback2((val) => {
1168
- if (val !== internalJsonValue) {
1169
- setInternalJsonValue(val);
1170
- }
1171
- }, []);
1172
- const handleEditComplete = useCallback2(() => {
1173
- onChange(internalJsonValue);
1174
- requestAnimationFrame(() => {
1175
- wrapperRef.current?.blur();
1176
- });
1177
- setJsonReadOnly(true);
1178
- }, [internalJsonValue, onChange]);
1179
- const [jsonReadOnly, setJsonReadOnly] = useState2(true);
1180
- const handleFormatJson = useCallback2(() => {
1181
- try {
1182
- const parsed = JSON.parse(internalJsonValue);
1183
- const formatted = JSON.stringify(parsed, null, 4);
1184
- setInternalJsonValue(formatted);
1185
- onChange(formatted);
1186
- } catch (error) {
1187
- console.error("Invalid JSON:", error);
1188
- }
1189
- }, [internalJsonValue, onChange]);
1190
- return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React7.createElement(
1191
- IconButton,
1192
- {
1193
- icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1194
- size: "small",
1195
- type: "tertiary",
1196
- theme: "borderless",
1197
- onClick: handleFormatJson
1198
- }
1199
- )))), /* @__PURE__ */ React7.createElement(
1200
- JSONViewerWrapper,
1201
- {
1202
- ref: wrapperRef,
1203
- tabIndex: -1,
1204
- onBlur: (e) => {
1205
- if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
1206
- handleEditComplete();
1207
- }
1208
- },
1209
- onClick: (e) => {
1210
- setJsonReadOnly(false);
1211
- }
1212
- },
1213
- /* @__PURE__ */ React7.createElement(
1214
- JsonViewer,
1215
- {
1216
- ref: JsonViewerRef,
1217
- value: getValueType(value) === "string" ? value : "",
1218
- height: 120,
1219
- width: "100%",
1220
- showSearch: false,
1221
- options: {
1222
- readOnly: jsonReadOnly,
1223
- formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
1224
- },
1225
- style: {
1226
- padding: 0
1227
- },
1228
- onChange: handleJsonChange
1229
- }
1230
- )
1231
- )) : /* @__PURE__ */ React7.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React7.createElement(
1209
+ const { value, schema, onChange, placeholder } = props;
1210
+ return /* @__PURE__ */ React16.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React16.createElement(
1232
1211
  ConstantInput,
1233
1212
  {
1234
1213
  value,
1235
1214
  onChange: (_v) => onChange(_v),
1236
1215
  schema: schema || { type: "string" },
1237
- placeholder: placeholder ?? "Default value if parameter is not provided"
1216
+ placeholder: placeholder ?? I18n8.t("Default value if parameter is not provided")
1238
1217
  }
1239
1218
  ));
1240
1219
  }
1241
1220
 
1242
1221
  // src/components/json-schema-editor/components/blur-input.tsx
1243
- import React8, { useEffect as useEffect2, useState as useState3 } from "react";
1244
- import Input2 from "@douyinfe/semi-ui/lib/es/input";
1222
+ import React17, { useEffect as useEffect3, useState as useState2 } from "react";
1223
+ import Input3 from "@douyinfe/semi-ui/lib/es/input";
1245
1224
  function BlurInput(props) {
1246
- const [value, setValue] = useState3("");
1247
- useEffect2(() => {
1225
+ const [value, setValue] = useState2("");
1226
+ useEffect3(() => {
1248
1227
  setValue(props.value);
1249
1228
  }, [props.value]);
1250
- return /* @__PURE__ */ React8.createElement(
1251
- Input2,
1229
+ return /* @__PURE__ */ React17.createElement(
1230
+ Input3,
1252
1231
  {
1253
1232
  ...props,
1254
1233
  value,
@@ -1261,15 +1240,17 @@ function BlurInput(props) {
1261
1240
  }
1262
1241
 
1263
1242
  // src/components/json-schema-editor/index.tsx
1243
+ var DEFAULT = { type: "object" };
1264
1244
  function JsonSchemaEditor(props) {
1265
- const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
1245
+ const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
1266
1246
  const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1267
1247
  value,
1268
1248
  onChangeProps
1269
1249
  );
1270
- return /* @__PURE__ */ React9.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React9.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1250
+ return /* @__PURE__ */ React18.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React18.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
1271
1251
  PropertyEdit,
1272
1252
  {
1253
+ readonly,
1273
1254
  key: _property.key,
1274
1255
  value: _property,
1275
1256
  config,
@@ -1281,21 +1262,23 @@ function JsonSchemaEditor(props) {
1281
1262
  onRemoveProperty(_property.key);
1282
1263
  }
1283
1264
  }
1284
- ))), /* @__PURE__ */ React9.createElement(
1285
- Button2,
1265
+ ))), /* @__PURE__ */ React18.createElement(
1266
+ Button,
1286
1267
  {
1268
+ disabled: readonly,
1287
1269
  size: "small",
1288
1270
  style: { marginTop: 10, marginLeft: 16 },
1289
- icon: /* @__PURE__ */ React9.createElement(IconPlus, null),
1271
+ icon: /* @__PURE__ */ React18.createElement(IconPlus, null),
1290
1272
  onClick: onAddProperty
1291
1273
  },
1292
- config?.addButtonText ?? "Add"
1274
+ config?.addButtonText ?? I18n9.t("Add")
1293
1275
  ));
1294
1276
  }
1295
1277
  function PropertyEdit(props) {
1296
1278
  const {
1297
1279
  value,
1298
1280
  config,
1281
+ readonly,
1299
1282
  $level = 0,
1300
1283
  onChange: onChangeProps,
1301
1284
  onRemove,
@@ -1306,19 +1289,19 @@ function PropertyEdit(props) {
1306
1289
  $parentType = "",
1307
1290
  $showLine
1308
1291
  } = props;
1309
- const [expand, setExpand] = useState4(false);
1310
- const [collapse, setCollapse] = useState4(false);
1292
+ const [expand, setExpand] = useState3(false);
1293
+ const [collapse, setCollapse] = useState3(false);
1311
1294
  const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
1312
- const typeSelectorValue = useMemo5(() => ({ type, items }), [type, items]);
1313
- const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1295
+ const typeSelectorValue = useMemo4(() => ({ type, items }), [type, items]);
1296
+ const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1314
1297
  const onChange = (key, _value) => {
1315
1298
  onChangeProps?.({
1316
1299
  ...value || {},
1317
1300
  [key]: _value
1318
1301
  });
1319
1302
  };
1320
- const showCollapse = isDrilldownObject && propertyList.length > 0;
1321
- return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
1303
+ const showCollapse = canAddField && propertyList.length > 0;
1304
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
1322
1305
  UIPropertyLeft,
1323
1306
  {
1324
1307
  type,
@@ -1330,8 +1313,8 @@ function PropertyEdit(props) {
1330
1313
  $parentExpand,
1331
1314
  $parentType
1332
1315
  },
1333
- showCollapse && /* @__PURE__ */ React9.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React9.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconChevronRight, { size: "small" }))
1334
- ), /* @__PURE__ */ React9.createElement(UIPropertyRight, null, /* @__PURE__ */ React9.createElement(
1316
+ showCollapse && /* @__PURE__ */ React18.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React18.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconChevronRight, { size: "small" }))
1317
+ ), /* @__PURE__ */ React18.createElement(UIPropertyRight, null, /* @__PURE__ */ React18.createElement(
1335
1318
  UIPropertyMain,
1336
1319
  {
1337
1320
  $showCollapse: showCollapse,
@@ -1339,18 +1322,20 @@ function PropertyEdit(props) {
1339
1322
  $expand: expand,
1340
1323
  type
1341
1324
  },
1342
- /* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
1325
+ /* @__PURE__ */ React18.createElement(UIRow, null, /* @__PURE__ */ React18.createElement(UIName, null, /* @__PURE__ */ React18.createElement(
1343
1326
  BlurInput,
1344
1327
  {
1328
+ disabled: readonly,
1345
1329
  placeholder: config?.placeholder ?? "Input Variable Name",
1346
1330
  size: "small",
1347
1331
  value: name,
1348
1332
  onChange: (value2) => onChange("name", value2)
1349
1333
  }
1350
- )), /* @__PURE__ */ React9.createElement(UIType, null, /* @__PURE__ */ React9.createElement(
1351
- TypeSelector,
1334
+ )), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
1335
+ InjectTypeSelector,
1352
1336
  {
1353
1337
  value: typeSelectorValue,
1338
+ readonly,
1354
1339
  onChange: (_value) => {
1355
1340
  onChangeProps?.({
1356
1341
  ...value || {},
@@ -1358,64 +1343,70 @@ function PropertyEdit(props) {
1358
1343
  });
1359
1344
  }
1360
1345
  }
1361
- )), /* @__PURE__ */ React9.createElement(UIRequired, null, /* @__PURE__ */ React9.createElement(
1346
+ )), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
1362
1347
  Checkbox,
1363
1348
  {
1349
+ disabled: readonly,
1364
1350
  checked: isPropertyRequired,
1365
1351
  onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1366
1352
  }
1367
- )), /* @__PURE__ */ React9.createElement(UIActions, null, /* @__PURE__ */ React9.createElement(
1353
+ )), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
1368
1354
  IconButton2,
1369
1355
  {
1356
+ disabled: readonly,
1370
1357
  size: "small",
1371
1358
  theme: "borderless",
1372
- icon: expand ? /* @__PURE__ */ React9.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconExpand, { size: "small" }),
1359
+ icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
1373
1360
  onClick: () => {
1374
1361
  setExpand((_expand) => !_expand);
1375
1362
  }
1376
1363
  }
1377
- ), isDrilldownObject && /* @__PURE__ */ React9.createElement(
1364
+ ), canAddField && /* @__PURE__ */ React18.createElement(
1378
1365
  IconButton2,
1379
1366
  {
1367
+ disabled: readonly,
1380
1368
  size: "small",
1381
1369
  theme: "borderless",
1382
- icon: /* @__PURE__ */ React9.createElement(IconAddChildren, null),
1370
+ icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
1383
1371
  onClick: () => {
1384
1372
  onAddProperty();
1385
1373
  setCollapse(true);
1386
1374
  }
1387
1375
  }
1388
- ), /* @__PURE__ */ React9.createElement(
1376
+ ), /* @__PURE__ */ React18.createElement(
1389
1377
  IconButton2,
1390
1378
  {
1379
+ disabled: readonly,
1391
1380
  size: "small",
1392
1381
  theme: "borderless",
1393
- icon: /* @__PURE__ */ React9.createElement(IconMinus, { size: "small" }),
1382
+ icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
1394
1383
  onClick: onRemove
1395
1384
  }
1396
1385
  ))),
1397
- expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
1386
+ expand && /* @__PURE__ */ React18.createElement(UIExpandDetail, null, /* @__PURE__ */ React18.createElement(UILabel, null, config?.descTitle ?? I18n9.t("Description")), /* @__PURE__ */ React18.createElement(
1398
1387
  BlurInput,
1399
1388
  {
1389
+ disabled: readonly,
1400
1390
  size: "small",
1401
1391
  value: description,
1402
1392
  onChange: (value2) => onChange("description", value2),
1403
- placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
1393
+ placeholder: config?.descPlaceholder ?? I18n9.t("Help LLM to understand the property")
1404
1394
  }
1405
- ), $level === 0 && type && type !== "array" && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React9.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React9.createElement(
1395
+ ), $level === 0 && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n9.t("Default Value")), /* @__PURE__ */ React18.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React18.createElement(
1406
1396
  DefaultValue,
1407
1397
  {
1408
1398
  value: defaultValue,
1409
1399
  schema: value,
1410
1400
  type,
1411
- placeholder: config?.defaultValuePlaceholder,
1401
+ placeholder: config?.defaultValuePlaceholder ?? I18n9.t("Default Value"),
1412
1402
  jsonFormatText: config?.jsonFormatText,
1413
1403
  onChange: (value2) => onChange("default", value2)
1414
1404
  }
1415
1405
  ))))
1416
- ), showCollapse && /* @__PURE__ */ React9.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React9.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1406
+ ), showCollapse && /* @__PURE__ */ React18.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React18.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
1417
1407
  PropertyEdit,
1418
1408
  {
1409
+ readonly,
1419
1410
  key: _property.key,
1420
1411
  value: _property,
1421
1412
  config,
@@ -1437,29 +1428,35 @@ function PropertyEdit(props) {
1437
1428
  }
1438
1429
 
1439
1430
  // src/components/batch-variable-selector/index.tsx
1440
- import React10 from "react";
1431
+ import React19 from "react";
1441
1432
  import { PrivateScopeProvider } from "@flowgram.ai/editor";
1442
1433
  var batchVariableSchema = {
1443
1434
  type: "array",
1444
1435
  extra: { weak: true }
1445
1436
  };
1446
1437
  function BatchVariableSelector(props) {
1447
- return /* @__PURE__ */ React10.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React10.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1438
+ return /* @__PURE__ */ React19.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React19.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1448
1439
  }
1449
1440
 
1450
1441
  // src/components/dynamic-value-input/index.tsx
1451
- import React11, { useMemo as useMemo6 } from "react";
1442
+ import React20 from "react";
1443
+ import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
1452
1444
  import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
1453
1445
  import { IconSetting } from "@douyinfe/semi-icons";
1454
1446
 
1455
1447
  // src/components/dynamic-value-input/styles.tsx
1456
- import styled3 from "styled-components";
1457
- var UIContainer2 = styled3.div`
1448
+ import styled4 from "styled-components";
1449
+ var UIContainer2 = styled4.div`
1458
1450
  display: flex;
1459
1451
  align-items: center;
1460
- gap: 5px;
1452
+ border-radius: 4px;
1453
+ border: 1px solid var(--semi-color-border);
1454
+
1455
+ overflow: hidden;
1456
+
1457
+ background-color: var(--semi-color-fill-0);
1461
1458
  `;
1462
- var UIMain = styled3.div`
1459
+ var UIMain = styled4.div`
1463
1460
  flex-grow: 1;
1464
1461
  overflow: hidden;
1465
1462
  min-width: 0;
@@ -1468,9 +1465,62 @@ var UIMain = styled3.div`
1468
1465
  & .semi-input-number,
1469
1466
  & .semi-select {
1470
1467
  width: 100%;
1468
+ border: none;
1469
+ border-radius: 0;
1470
+ }
1471
+
1472
+ & .semi-input-wrapper {
1473
+ border: none;
1474
+ border-radius: 0;
1475
+ }
1476
+ `;
1477
+ var UIType2 = styled4.div`
1478
+ border-right: 1px solid #e5e5e5;
1479
+
1480
+ & .semi-button {
1481
+ border-radius: 0;
1471
1482
  }
1472
1483
  `;
1473
- var UITrigger = styled3.div``;
1484
+ var UITrigger = styled4.div`
1485
+ border-left: 1px solid #e5e5e5;
1486
+
1487
+ & .semi-button {
1488
+ border-radius: 0;
1489
+ }
1490
+ `;
1491
+
1492
+ // src/components/dynamic-value-input/hooks.ts
1493
+ import { useMemo as useMemo5, useState as useState4 } from "react";
1494
+ import { useScopeAvailable } from "@flowgram.ai/editor";
1495
+ function useRefVariable(value) {
1496
+ const available = useScopeAvailable();
1497
+ const refVariable = useMemo5(() => {
1498
+ if (value?.type === "ref") {
1499
+ return available.getByKeyPath(value.content);
1500
+ }
1501
+ }, [value, available]);
1502
+ return refVariable;
1503
+ }
1504
+ function useSelectSchema(schemaFromProps, constantProps, value) {
1505
+ let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
1506
+ if (value?.type === "constant") {
1507
+ defaultSelectSchema = value?.schema || defaultSelectSchema;
1508
+ }
1509
+ const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
1510
+ return [selectSchema, setSelectSchema];
1511
+ }
1512
+ function useIncludeSchema(schemaFromProps) {
1513
+ const includeSchema = useMemo5(() => {
1514
+ if (!schemaFromProps) {
1515
+ return;
1516
+ }
1517
+ if (schemaFromProps?.type === "number") {
1518
+ return [schemaFromProps, { type: "integer" }];
1519
+ }
1520
+ return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
1521
+ }, [schemaFromProps]);
1522
+ return includeSchema;
1523
+ }
1474
1524
 
1475
1525
  // src/components/dynamic-value-input/index.tsx
1476
1526
  function DynamicValueInput({
@@ -1478,19 +1528,50 @@ function DynamicValueInput({
1478
1528
  onChange,
1479
1529
  readonly,
1480
1530
  style,
1481
- schema,
1531
+ schema: schemaFromProps,
1482
1532
  constantProps
1483
1533
  }) {
1484
- const includeSchema = useMemo6(() => {
1485
- if (schema?.type === "number") {
1486
- return [schema, { type: "integer" }];
1534
+ const refVariable = useRefVariable(value);
1535
+ const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
1536
+ const includeSchema = useIncludeSchema(schemaFromProps);
1537
+ const renderTypeSelector = () => {
1538
+ if (schemaFromProps) {
1539
+ return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1487
1540
  }
1488
- return schema;
1489
- }, [schema]);
1541
+ if (value?.type === "ref") {
1542
+ const schema = refVariable?.type ? JsonSchemaUtils3.astToSchema(refVariable?.type) : void 0;
1543
+ return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schema, readonly: true });
1544
+ }
1545
+ return /* @__PURE__ */ React20.createElement(
1546
+ TypeSelector,
1547
+ {
1548
+ value: selectSchema,
1549
+ onChange: (_v) => {
1550
+ setSelectSchema(_v || { type: "string" });
1551
+ let content;
1552
+ if (_v?.type === "object") {
1553
+ content = "{}";
1554
+ }
1555
+ if (_v?.type === "array") {
1556
+ content = "[]";
1557
+ }
1558
+ if (_v?.type === "boolean") {
1559
+ content = false;
1560
+ }
1561
+ onChange({
1562
+ type: "constant",
1563
+ content,
1564
+ schema: _v || { type: "string" }
1565
+ });
1566
+ },
1567
+ readonly
1568
+ }
1569
+ );
1570
+ };
1490
1571
  const renderMain = () => {
1491
1572
  if (value?.type === "ref") {
1492
- return /* @__PURE__ */ React11.createElement(
1493
- VariableSelector,
1573
+ return /* @__PURE__ */ React20.createElement(
1574
+ InjectVariableSelector,
1494
1575
  {
1495
1576
  style: { width: "100%" },
1496
1577
  value: value?.content,
@@ -1500,50 +1581,64 @@ function DynamicValueInput({
1500
1581
  }
1501
1582
  );
1502
1583
  }
1503
- return /* @__PURE__ */ React11.createElement(
1584
+ const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1585
+ return /* @__PURE__ */ React20.createElement(
1504
1586
  ConstantInput,
1505
1587
  {
1506
1588
  value: value?.content,
1507
- onChange: (_v) => onChange({ type: "constant", content: _v }),
1508
- schema: schema || { type: "string" },
1589
+ onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1590
+ schema: constantSchema || { type: "string" },
1509
1591
  readonly,
1592
+ strategies: [...constantProps?.strategies || []],
1593
+ fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
1594
+ InjectVariableSelector,
1595
+ {
1596
+ style: { width: "100%" },
1597
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1598
+ includeSchema,
1599
+ readonly
1600
+ }
1601
+ ),
1510
1602
  ...constantProps
1511
1603
  }
1512
1604
  );
1513
1605
  };
1514
- const renderTrigger = () => /* @__PURE__ */ React11.createElement(
1515
- VariableSelector,
1606
+ const renderTrigger = () => /* @__PURE__ */ React20.createElement(
1607
+ InjectVariableSelector,
1516
1608
  {
1517
1609
  style: { width: "100%" },
1518
1610
  value: value?.type === "ref" ? value?.content : void 0,
1519
1611
  onChange: (_v) => onChange({ type: "ref", content: _v }),
1520
1612
  includeSchema,
1521
1613
  readonly,
1522
- triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
1614
+ triggerRender: () => /* @__PURE__ */ React20.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React20.createElement(IconSetting, { size: "small" }) })
1523
1615
  }
1524
1616
  );
1525
- return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
1617
+ return /* @__PURE__ */ React20.createElement(UIContainer2, { style }, /* @__PURE__ */ React20.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React20.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React20.createElement(UITrigger, null, renderTrigger()));
1526
1618
  }
1619
+ DynamicValueInput.renderKey = "dynamic-value-input-render-key";
1620
+ var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
1527
1621
 
1528
1622
  // src/components/condition-row/index.tsx
1529
- import React13, { useMemo as useMemo9 } from "react";
1530
- import { Input as Input3 } from "@douyinfe/semi-ui";
1623
+ import React22, { useMemo as useMemo8 } from "react";
1624
+ import { I18n as I18n11 } from "@flowgram.ai/editor";
1625
+ import { Input as Input4 } from "@douyinfe/semi-ui";
1531
1626
 
1532
1627
  // src/components/condition-row/styles.tsx
1533
- import styled4 from "styled-components";
1534
- var UIContainer3 = styled4.div`
1628
+ import styled5 from "styled-components";
1629
+ var UIContainer3 = styled5.div`
1535
1630
  display: flex;
1536
1631
  align-items: center;
1537
1632
  gap: 4px;
1538
1633
  `;
1539
- var UIOperator = styled4.div``;
1540
- var UILeft = styled4.div`
1634
+ var UIOperator = styled5.div``;
1635
+ var UILeft = styled5.div`
1541
1636
  width: 100%;
1542
1637
  `;
1543
- var UIRight = styled4.div`
1638
+ var UIRight = styled5.div`
1544
1639
  width: 100%;
1545
1640
  `;
1546
- var UIValues = styled4.div`
1641
+ var UIValues = styled5.div`
1547
1642
  flex-grow: 1;
1548
1643
  display: flex;
1549
1644
  flex-direction: column;
@@ -1552,11 +1647,12 @@ var UIValues = styled4.div`
1552
1647
  `;
1553
1648
 
1554
1649
  // src/components/condition-row/hooks/useRule.ts
1555
- import { useMemo as useMemo7 } from "react";
1556
- import { useScopeAvailable } from "@flowgram.ai/editor";
1650
+ import { useMemo as useMemo6 } from "react";
1651
+ import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
1652
+ import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
1557
1653
 
1558
1654
  // src/components/condition-row/constants.ts
1559
- var rules = {
1655
+ var defaultRules = {
1560
1656
  string: {
1561
1657
  ["eq" /* EQ */]: "string",
1562
1658
  ["neq" /* NEQ */]: "string",
@@ -1564,8 +1660,8 @@ var rules = {
1564
1660
  ["not_contains" /* NOT_CONTAINS */]: "string",
1565
1661
  ["in" /* IN */]: "array",
1566
1662
  ["nin" /* NIN */]: "array",
1567
- ["is_empty" /* IS_EMPTY */]: "string",
1568
- ["is_not_empty" /* IS_NOT_EMPTY */]: "string"
1663
+ ["is_empty" /* IS_EMPTY */]: null,
1664
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1569
1665
  },
1570
1666
  number: {
1571
1667
  ["eq" /* EQ */]: "number",
@@ -1575,9 +1671,7 @@ var rules = {
1575
1671
  ["lt" /* LT */]: "number",
1576
1672
  ["lte" /* LTE */]: "number",
1577
1673
  ["in" /* IN */]: "array",
1578
- ["nin" /* NIN */]: "array",
1579
- ["is_empty" /* IS_EMPTY */]: null,
1580
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1674
+ ["nin" /* NIN */]: "array"
1581
1675
  },
1582
1676
  integer: {
1583
1677
  ["eq" /* EQ */]: "number",
@@ -1587,9 +1681,7 @@ var rules = {
1587
1681
  ["lt" /* LT */]: "number",
1588
1682
  ["lte" /* LTE */]: "number",
1589
1683
  ["in" /* IN */]: "array",
1590
- ["nin" /* NIN */]: "array",
1591
- ["is_empty" /* IS_EMPTY */]: null,
1592
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1684
+ ["nin" /* NIN */]: "array"
1593
1685
  },
1594
1686
  boolean: {
1595
1687
  ["eq" /* EQ */]: "boolean",
@@ -1597,9 +1689,7 @@ var rules = {
1597
1689
  ["is_true" /* IS_TRUE */]: null,
1598
1690
  ["is_false" /* IS_FALSE */]: null,
1599
1691
  ["in" /* IN */]: "array",
1600
- ["nin" /* NIN */]: "array",
1601
- ["is_empty" /* IS_EMPTY */]: null,
1602
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1692
+ ["nin" /* NIN */]: "array"
1603
1693
  },
1604
1694
  object: {
1605
1695
  ["is_empty" /* IS_EMPTY */]: null,
@@ -1607,14 +1697,18 @@ var rules = {
1607
1697
  },
1608
1698
  array: {
1609
1699
  ["is_empty" /* IS_EMPTY */]: null,
1610
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1700
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null,
1701
+ ["contains" /* CONTAINS */]: "array",
1702
+ ["not_contains" /* NOT_CONTAINS */]: "array",
1703
+ ["eq" /* EQ */]: "array",
1704
+ ["neq" /* NEQ */]: "array"
1611
1705
  },
1612
1706
  map: {
1613
1707
  ["is_empty" /* IS_EMPTY */]: null,
1614
1708
  ["is_not_empty" /* IS_NOT_EMPTY */]: null
1615
1709
  }
1616
1710
  };
1617
- var opConfigs = {
1711
+ var defaultOpConfigs = {
1618
1712
  ["eq" /* EQ */]: {
1619
1713
  label: "Equal",
1620
1714
  abbreviation: "="
@@ -1677,127 +1771,82 @@ var opConfigs = {
1677
1771
  }
1678
1772
  };
1679
1773
 
1680
- // src/utils/format-legacy-refs/index.ts
1681
- import { isObject } from "lodash";
1682
- function formatLegacyRefOnSubmit(value) {
1683
- if (isObject(value)) {
1684
- if (isLegacyFlowRefValueSchema(value)) {
1685
- return formatLegacyRefToNewRef(value);
1686
- }
1687
- return Object.fromEntries(
1688
- Object.entries(value).map(([key, value2]) => [
1689
- key,
1690
- formatLegacyRefOnSubmit(value2)
1691
- ])
1692
- );
1693
- }
1694
- if (Array.isArray(value)) {
1695
- return value.map(formatLegacyRefOnSubmit);
1696
- }
1697
- return value;
1698
- }
1699
- function formatLegacyRefOnInit(value) {
1700
- if (isObject(value)) {
1701
- if (isNewFlowRefValueSchema(value)) {
1702
- return formatNewRefToLegacyRef(value);
1703
- }
1704
- return Object.fromEntries(
1705
- Object.entries(value).map(([key, value2]) => [
1706
- key,
1707
- formatLegacyRefOnInit(value2)
1708
- ])
1709
- );
1710
- }
1711
- if (Array.isArray(value)) {
1712
- return value.map(formatLegacyRefOnInit);
1713
- }
1714
- return value;
1715
- }
1716
- function isLegacyFlowRefValueSchema(value) {
1717
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1718
- }
1719
- function isNewFlowRefValueSchema(value) {
1720
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1721
- }
1722
- function formatLegacyRefToNewRef(value) {
1723
- const keyPath = value.content.split(".");
1724
- if (keyPath[1] === "outputs") {
1725
- return {
1726
- type: "ref",
1727
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1728
- };
1729
- }
1730
- return {
1731
- type: "ref",
1732
- content: keyPath
1733
- };
1734
- }
1735
- function formatNewRefToLegacyRef(value) {
1736
- return {
1737
- type: "ref",
1738
- content: value.content.join(".")
1739
- };
1740
- }
1741
-
1742
1774
  // src/components/condition-row/hooks/useRule.ts
1743
- function useRule(left) {
1744
- const available = useScopeAvailable();
1745
- const variable = useMemo7(() => {
1775
+ function useRule(left, userRules) {
1776
+ const available = useScopeAvailable2();
1777
+ const rules = useMemo6(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
1778
+ const variable = useMemo6(() => {
1746
1779
  if (!left) return void 0;
1747
1780
  return available.getByKeyPath(left.content);
1748
1781
  }, [available, left]);
1749
- const rule = useMemo7(() => {
1782
+ const rule = useMemo6(() => {
1750
1783
  if (!variable) return void 0;
1751
- const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
1784
+ const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
1752
1785
  return rules[schema?.type];
1753
- }, [variable?.type]);
1786
+ }, [variable?.type, rules]);
1754
1787
  return { rule };
1755
1788
  }
1756
1789
 
1757
1790
  // src/components/condition-row/hooks/useOp.tsx
1758
- import React12, { useMemo as useMemo8 } from "react";
1759
- import { Button as Button3, Select as Select2 } from "@douyinfe/semi-ui";
1791
+ import React21, { useMemo as useMemo7 } from "react";
1792
+ import { I18n as I18n10 } from "@flowgram.ai/editor";
1793
+ import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
1760
1794
  import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
1761
- function useOp({ rule, op, onChange }) {
1762
- const options2 = useMemo8(
1795
+ function useOp({ rule, op, onChange, readonly, userOps }) {
1796
+ const options = useMemo7(
1763
1797
  () => Object.keys(rule || {}).map((_op) => ({
1764
- ...opConfigs[_op] || {},
1765
- value: _op
1798
+ ...defaultOpConfigs[_op] || {},
1799
+ ...userOps?.[_op] || {},
1800
+ value: _op,
1801
+ label: I18n10.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
1766
1802
  })),
1767
- [rule]
1803
+ [rule, userOps]
1768
1804
  );
1769
- const opConfig = useMemo8(() => opConfigs[op], [op]);
1770
- const renderOpSelect = () => /* @__PURE__ */ React12.createElement(
1805
+ const opConfig = useMemo7(() => defaultOpConfigs[op], [op]);
1806
+ const renderOpSelect = () => /* @__PURE__ */ React21.createElement(
1771
1807
  Select2,
1772
1808
  {
1773
1809
  style: { height: 22 },
1810
+ disabled: readonly,
1774
1811
  size: "small",
1775
1812
  value: op,
1776
- optionList: options2,
1813
+ optionList: options,
1777
1814
  onChange: (v) => {
1778
1815
  onChange(v);
1779
1816
  },
1780
- triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
1817
+ triggerRender: ({ value }) => /* @__PURE__ */ React21.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React21.createElement(IconChevronDownStroked2, { size: "small" }))
1781
1818
  }
1782
1819
  );
1783
1820
  return { renderOpSelect, opConfig };
1784
1821
  }
1785
1822
 
1786
1823
  // src/components/condition-row/index.tsx
1787
- function ConditionRow({ style, value, onChange, readonly }) {
1824
+ var defaultRuleConfig = {
1825
+ ops: {},
1826
+ rules: {}
1827
+ };
1828
+ function ConditionRow({
1829
+ style,
1830
+ value,
1831
+ onChange,
1832
+ readonly,
1833
+ ruleConfig = defaultRuleConfig
1834
+ }) {
1788
1835
  const { left, operator, right } = value || {};
1789
- const { rule } = useRule(left);
1836
+ const { rule } = useRule(left, ruleConfig.rules);
1790
1837
  const { renderOpSelect, opConfig } = useOp({
1791
1838
  rule,
1792
1839
  op: operator,
1793
- onChange: (v) => onChange({ ...value, operator: v })
1840
+ onChange: (v) => onChange({ ...value, operator: v }),
1841
+ readonly,
1842
+ userOps: ruleConfig.ops
1794
1843
  });
1795
- const targetSchema = useMemo9(() => {
1796
- const targetType = rule?.[operator] || null;
1844
+ const targetSchema = useMemo8(() => {
1845
+ const targetType = rule?.[operator || ""] || null;
1797
1846
  return targetType ? { type: targetType, extra: { weak: true } } : null;
1798
1847
  }, [rule, opConfig]);
1799
- return /* @__PURE__ */ React13.createElement(UIContainer3, { style }, /* @__PURE__ */ React13.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues, null, /* @__PURE__ */ React13.createElement(UILeft, null, /* @__PURE__ */ React13.createElement(
1800
- VariableSelector,
1848
+ return /* @__PURE__ */ React22.createElement(UIContainer3, { style }, /* @__PURE__ */ React22.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React22.createElement(UIValues, null, /* @__PURE__ */ React22.createElement(UILeft, null, /* @__PURE__ */ React22.createElement(
1849
+ InjectVariableSelector,
1801
1850
  {
1802
1851
  readonly,
1803
1852
  style: { width: "100%" },
@@ -1810,48 +1859,52 @@ function ConditionRow({ style, value, onChange, readonly }) {
1810
1859
  }
1811
1860
  })
1812
1861
  }
1813
- )), /* @__PURE__ */ React13.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React13.createElement(
1814
- DynamicValueInput,
1862
+ )), /* @__PURE__ */ React22.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React22.createElement(
1863
+ InjectDynamicValueInput,
1815
1864
  {
1816
1865
  readonly: readonly || !rule,
1817
1866
  value: right,
1818
1867
  schema: targetSchema,
1819
1868
  onChange: (v) => onChange({ ...value, right: v })
1820
1869
  }
1821
- ) : /* @__PURE__ */ React13.createElement(
1822
- Input3,
1870
+ ) : /* @__PURE__ */ React22.createElement(
1871
+ Input4,
1823
1872
  {
1824
1873
  size: "small",
1825
1874
  disabled: true,
1826
1875
  style: { pointerEvents: "none" },
1827
- value: opConfig?.rightDisplay || "Empty"
1876
+ value: opConfig?.rightDisplay || I18n11.t("Empty")
1828
1877
  }
1829
1878
  ))));
1830
1879
  }
1831
1880
 
1832
1881
  // src/components/batch-outputs/index.tsx
1833
- import React14 from "react";
1834
- import { Button as Button4, Input as Input4 } from "@douyinfe/semi-ui";
1882
+ import React23 from "react";
1883
+ import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
1835
1884
  import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
1836
1885
 
1837
- // src/components/batch-outputs/use-list.ts
1838
- import { useEffect as useEffect3, useState as useState5 } from "react";
1839
- import { difference } from "lodash";
1840
- var _id2 = 0;
1886
+ // src/hooks/use-object-list/index.tsx
1887
+ import { useEffect as useEffect4, useState as useState5 } from "react";
1888
+ import { nanoid } from "nanoid";
1889
+ import { difference as difference2, get, isObject as isObject2, set } from "lodash";
1841
1890
  function genId2() {
1842
- return _id2++;
1891
+ return nanoid();
1843
1892
  }
1844
- function useList({ value, onChange }) {
1893
+ function useObjectList({
1894
+ value,
1895
+ onChange,
1896
+ sortIndexKey
1897
+ }) {
1845
1898
  const [list, setList] = useState5([]);
1846
- useEffect3(() => {
1899
+ useEffect4(() => {
1847
1900
  setList((_prevList) => {
1848
- const newKeys = Object.keys(value || {});
1901
+ const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
1849
1902
  const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
1850
- const addKeys = difference(newKeys, oldKeys);
1903
+ const addKeys = difference2(newKeys, oldKeys);
1851
1904
  return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1852
1905
  id: item.id,
1853
1906
  key: item.key,
1854
- value: item.key ? value?.[item.key] : void 0
1907
+ value: item.key ? value?.[item.key] : item.value
1855
1908
  })).concat(
1856
1909
  addKeys.map((_key) => ({
1857
1910
  id: genId2(),
@@ -1869,17 +1922,44 @@ function useList({ value, onChange }) {
1869
1922
  }
1870
1923
  ]);
1871
1924
  };
1872
- const update = (item) => {
1925
+ const updateValue = (itemId, value2) => {
1926
+ setList((prevList) => {
1927
+ const nextList = prevList.map((_item) => {
1928
+ if (_item.id === itemId) {
1929
+ return {
1930
+ ..._item,
1931
+ value: value2
1932
+ };
1933
+ }
1934
+ return _item;
1935
+ });
1936
+ onChange(
1937
+ Object.fromEntries(
1938
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
1939
+ if (isObject2(_res[1]) && sortIndexKey) {
1940
+ set(_res[1], sortIndexKey, idx);
1941
+ }
1942
+ return _res;
1943
+ })
1944
+ )
1945
+ );
1946
+ return nextList;
1947
+ });
1948
+ };
1949
+ const updateKey = (itemId, key) => {
1873
1950
  setList((prevList) => {
1874
1951
  const nextList = prevList.map((_item) => {
1875
- if (_item.id === item.id) {
1876
- return item;
1952
+ if (_item.id === itemId) {
1953
+ return {
1954
+ ..._item,
1955
+ key
1956
+ };
1877
1957
  }
1878
1958
  return _item;
1879
1959
  });
1880
1960
  onChange(
1881
1961
  Object.fromEntries(
1882
- nextList.filter((item2) => item2.key).map((item2) => [item2.key, item2.value])
1962
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1883
1963
  )
1884
1964
  );
1885
1965
  return nextList;
@@ -1896,18 +1976,18 @@ function useList({ value, onChange }) {
1896
1976
  return nextList;
1897
1977
  });
1898
1978
  };
1899
- return { list, add, update, remove };
1979
+ return { list, add, updateKey, updateValue, remove };
1900
1980
  }
1901
1981
 
1902
1982
  // src/components/batch-outputs/styles.tsx
1903
- import styled5 from "styled-components";
1904
- var UIRows = styled5.div`
1983
+ import styled6 from "styled-components";
1984
+ var UIRows = styled6.div`
1905
1985
  display: flex;
1906
1986
  flex-direction: column;
1907
1987
  gap: 10px;
1908
1988
  margin-bottom: 10px;
1909
1989
  `;
1910
- var UIRow2 = styled5.div`
1990
+ var UIRow2 = styled6.div`
1911
1991
  display: flex;
1912
1992
  align-items: center;
1913
1993
  gap: 5px;
@@ -1916,54 +1996,48 @@ var UIRow2 = styled5.div`
1916
1996
  // src/components/batch-outputs/index.tsx
1917
1997
  function BatchOutputs(props) {
1918
1998
  const { readonly, style } = props;
1919
- const { list, add, update, remove } = useList(props);
1920
- return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
1921
- Input4,
1999
+ const { list, add, updateKey, updateValue, remove } = useObjectList(props);
2000
+ return /* @__PURE__ */ React23.createElement("div", null, /* @__PURE__ */ React23.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React23.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React23.createElement(
2001
+ Input5,
1922
2002
  {
1923
2003
  style: { width: 100 },
1924
2004
  disabled: readonly,
1925
2005
  size: "small",
1926
2006
  value: item.key,
1927
- onChange: (v) => update({ ...item, key: v })
2007
+ onChange: (v) => updateKey(item.id, v)
1928
2008
  }
1929
- ), /* @__PURE__ */ React14.createElement(
1930
- VariableSelector,
2009
+ ), /* @__PURE__ */ React23.createElement(
2010
+ InjectVariableSelector,
1931
2011
  {
1932
2012
  style: { flexGrow: 1 },
1933
2013
  readonly,
1934
2014
  value: item.value?.content,
1935
- onChange: (v) => update({
1936
- ...item,
1937
- value: {
1938
- type: "ref",
1939
- content: v
1940
- }
1941
- })
2015
+ onChange: (v) => updateValue(item.id, { type: "ref", content: v })
1942
2016
  }
1943
- ), /* @__PURE__ */ React14.createElement(
1944
- Button4,
2017
+ ), /* @__PURE__ */ React23.createElement(
2018
+ Button3,
1945
2019
  {
1946
2020
  disabled: readonly,
1947
- icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
2021
+ icon: /* @__PURE__ */ React23.createElement(IconDelete, null),
1948
2022
  size: "small",
1949
2023
  onClick: () => remove(item.id)
1950
2024
  }
1951
- )))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
2025
+ )))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
1952
2026
  }
1953
2027
 
1954
2028
  // src/components/prompt-editor/index.tsx
1955
- import React15, { useEffect as useEffect4, useRef as useRef3 } from "react";
1956
- import { Renderer, EditorProvider, ActiveLinePlaceholder } from "@coze-editor/editor/react";
1957
- import preset from "@coze-editor/editor/preset-prompt";
2029
+ import React24, { useEffect as useEffect5, useRef as useRef2 } from "react";
2030
+ import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
2031
+ import preset2 from "@coze-editor/editor/preset-prompt";
1958
2032
 
1959
2033
  // src/components/prompt-editor/styles.tsx
1960
- import styled6, { css as css2 } from "styled-components";
1961
- var UIContainer4 = styled6.div`
2034
+ import styled7, { css as css3 } from "styled-components";
2035
+ var UIContainer4 = styled7.div`
1962
2036
  background-color: var(--semi-color-fill-0);
1963
2037
  padding-left: 10px;
1964
2038
  padding-right: 6px;
1965
2039
 
1966
- ${({ $hasError }) => $hasError && css2`
2040
+ ${({ $hasError }) => $hasError && css3`
1967
2041
  border: 1px solid var(--semi-color-danger-6);
1968
2042
  `}
1969
2043
  `;
@@ -1972,7 +2046,7 @@ var UIContainer4 = styled6.div`
1972
2046
  import { useLayoutEffect } from "react";
1973
2047
  import { useInjector } from "@coze-editor/editor/react";
1974
2048
  import { astDecorator } from "@coze-editor/editor";
1975
- import { EditorView } from "@codemirror/view";
2049
+ import { EditorView as EditorView2 } from "@codemirror/view";
1976
2050
  function MarkdownHighlight() {
1977
2051
  const injector = useInjector();
1978
2052
  useLayoutEffect(
@@ -2003,7 +2077,7 @@ function MarkdownHighlight() {
2003
2077
  };
2004
2078
  }
2005
2079
  }),
2006
- EditorView.theme({
2080
+ EditorView2.theme({
2007
2081
  ".heading": {
2008
2082
  color: "#00818C",
2009
2083
  fontWeight: "bold"
@@ -2040,7 +2114,7 @@ var language_support_default = LanguageSupport;
2040
2114
  import { useLayoutEffect as useLayoutEffect3 } from "react";
2041
2115
  import { useInjector as useInjector3 } from "@coze-editor/editor/react";
2042
2116
  import { astDecorator as astDecorator2 } from "@coze-editor/editor";
2043
- import { EditorView as EditorView2 } from "@codemirror/view";
2117
+ import { EditorView as EditorView3 } from "@codemirror/view";
2044
2118
  function JinjaHighlight() {
2045
2119
  const injector = useInjector3();
2046
2120
  useLayoutEffect3(
@@ -2065,7 +2139,7 @@ function JinjaHighlight() {
2065
2139
  };
2066
2140
  }
2067
2141
  }),
2068
- EditorView2.theme({
2142
+ EditorView3.theme({
2069
2143
  ".jinja-statement-bracket": {
2070
2144
  color: "#D1009D"
2071
2145
  },
@@ -2096,19 +2170,19 @@ function PromptEditor(props) {
2096
2170
  children,
2097
2171
  disableMarkdownHighlight
2098
2172
  } = props || {};
2099
- const editorRef = useRef3(null);
2100
- useEffect4(() => {
2173
+ const editorRef = useRef2(null);
2174
+ useEffect5(() => {
2101
2175
  if (editorRef.current?.getValue() !== value?.content) {
2102
2176
  editorRef.current?.setValue(String(value?.content || ""));
2103
2177
  }
2104
2178
  }, [value]);
2105
- return /* @__PURE__ */ React15.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React15.createElement(EditorProvider, null, /* @__PURE__ */ React15.createElement(
2179
+ return /* @__PURE__ */ React24.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React24.createElement(EditorProvider2, null, /* @__PURE__ */ React24.createElement(
2106
2180
  Renderer,
2107
2181
  {
2108
2182
  didMount: (editor) => {
2109
2183
  editorRef.current = editor;
2110
2184
  },
2111
- plugins: preset,
2185
+ plugins: preset2,
2112
2186
  defaultValue: String(value?.content),
2113
2187
  options: {
2114
2188
  readOnly: readonly,
@@ -2119,15 +2193,15 @@ function PromptEditor(props) {
2119
2193
  onChange({ type: "template", content: e.value });
2120
2194
  }
2121
2195
  }
2122
- ), activeLinePlaceholder && /* @__PURE__ */ React15.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React15.createElement(markdown_default, null), /* @__PURE__ */ React15.createElement(language_support_default, null), /* @__PURE__ */ React15.createElement(jinja_default, null), children));
2196
+ ), activeLinePlaceholder && /* @__PURE__ */ React24.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React24.createElement(markdown_default, null), /* @__PURE__ */ React24.createElement(language_support_default, null), /* @__PURE__ */ React24.createElement(jinja_default, null), children));
2123
2197
  }
2124
2198
 
2125
2199
  // src/components/prompt-editor-with-variables/index.tsx
2126
- import React18 from "react";
2200
+ import React27 from "react";
2127
2201
 
2128
2202
  // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2129
- import React16, { useEffect as useEffect5, useState as useState6 } from "react";
2130
- import { Popover, Tree } from "@douyinfe/semi-ui";
2203
+ import React25, { useEffect as useEffect6, useState as useState6 } from "react";
2204
+ import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
2131
2205
  import {
2132
2206
  Mention,
2133
2207
  getCurrentMentionReplaceRange,
@@ -2154,20 +2228,20 @@ function VariableTree() {
2154
2228
  setPosition(e.state.selection.main.head);
2155
2229
  setVisible(e.value);
2156
2230
  }
2157
- useEffect5(() => {
2231
+ useEffect6(() => {
2158
2232
  if (!editor) {
2159
2233
  return;
2160
2234
  }
2161
2235
  }, [editor, visible]);
2162
2236
  const treeData = useVariableTree({});
2163
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React16.createElement(
2164
- Popover,
2237
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React25.createElement(
2238
+ Popover2,
2165
2239
  {
2166
2240
  visible,
2167
2241
  trigger: "custom",
2168
2242
  position: "topLeft",
2169
2243
  rePosKey: posKey,
2170
- content: /* @__PURE__ */ React16.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React16.createElement(
2244
+ content: /* @__PURE__ */ React25.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React25.createElement(
2171
2245
  Tree,
2172
2246
  {
2173
2247
  treeData,
@@ -2177,7 +2251,7 @@ function VariableTree() {
2177
2251
  }
2178
2252
  ))
2179
2253
  },
2180
- /* @__PURE__ */ React16.createElement(
2254
+ /* @__PURE__ */ React25.createElement(
2181
2255
  PositionMirror,
2182
2256
  {
2183
2257
  position,
@@ -2189,28 +2263,28 @@ function VariableTree() {
2189
2263
 
2190
2264
  // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2191
2265
  import ReactDOM from "react-dom";
2192
- import React17, { useLayoutEffect as useLayoutEffect4 } from "react";
2266
+ import React26, { useLayoutEffect as useLayoutEffect4 } from "react";
2193
2267
  import { isEqual, last } from "lodash";
2194
2268
  import {
2195
2269
  Disposable,
2196
2270
  DisposableCollection,
2197
2271
  useCurrentScope
2198
2272
  } from "@flowgram.ai/editor";
2199
- import { Popover as Popover2 } from "@douyinfe/semi-ui";
2273
+ import { Popover as Popover3 } from "@douyinfe/semi-ui";
2200
2274
  import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
2201
2275
  import { useInjector as useInjector4 } from "@coze-editor/editor/react";
2202
2276
  import {
2203
2277
  Decoration,
2204
- EditorView as EditorView3,
2278
+ EditorView as EditorView4,
2205
2279
  MatchDecorator,
2206
2280
  ViewPlugin,
2207
2281
  WidgetType
2208
2282
  } from "@codemirror/view";
2209
2283
 
2210
2284
  // src/components/prompt-editor-with-variables/styles.tsx
2211
- import styled7 from "styled-components";
2285
+ import styled8 from "styled-components";
2212
2286
  import { Tag as Tag2 } from "@douyinfe/semi-ui";
2213
- var UIRootTitle2 = styled7.div`
2287
+ var UIRootTitle2 = styled8.div`
2214
2288
  margin-right: 4px;
2215
2289
  min-width: 20px;
2216
2290
  overflow: hidden;
@@ -2218,12 +2292,12 @@ var UIRootTitle2 = styled7.div`
2218
2292
  white-space: nowrap;
2219
2293
  color: var(--semi-color-text-2);
2220
2294
  `;
2221
- var UIVarName2 = styled7.div`
2295
+ var UIVarName2 = styled8.div`
2222
2296
  overflow: hidden;
2223
2297
  text-overflow: ellipsis;
2224
2298
  white-space: nowrap;
2225
2299
  `;
2226
- var UITag2 = styled7(Tag2)`
2300
+ var UITag2 = styled8(Tag2)`
2227
2301
  display: inline-flex;
2228
2302
  align-items: center;
2229
2303
  justify-content: flex-start;
@@ -2237,7 +2311,7 @@ var UITag2 = styled7(Tag2)`
2237
2311
  margin: 0 5px;
2238
2312
  }
2239
2313
  `;
2240
- var UIPopoverContent = styled7.div`
2314
+ var UIPopoverContent2 = styled8.div`
2241
2315
  padding: 10px;
2242
2316
  display: inline-flex;
2243
2317
  align-items: center;
@@ -2251,7 +2325,7 @@ var VariableTagWidget = class extends WidgetType {
2251
2325
  this.toDispose = new DisposableCollection();
2252
2326
  this.renderIcon = (icon) => {
2253
2327
  if (typeof icon === "string") {
2254
- return /* @__PURE__ */ React17.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2328
+ return /* @__PURE__ */ React26.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2255
2329
  }
2256
2330
  return icon;
2257
2331
  };
@@ -2264,20 +2338,21 @@ var VariableTagWidget = class extends WidgetType {
2264
2338
  renderVariable(v) {
2265
2339
  if (!v) {
2266
2340
  this.renderReact(
2267
- /* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React17.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2341
+ /* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React26.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2268
2342
  );
2269
2343
  return;
2270
2344
  }
2271
- const rootField = last(v.parentFields);
2272
- const rootTitle = /* @__PURE__ */ React17.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2345
+ const rootField = last(v.parentFields) || v;
2346
+ const isRoot = v.parentFields.length === 0;
2347
+ const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2273
2348
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2274
2349
  this.renderReact(
2275
- /* @__PURE__ */ React17.createElement(
2276
- Popover2,
2350
+ /* @__PURE__ */ React26.createElement(
2351
+ Popover3,
2277
2352
  {
2278
- content: /* @__PURE__ */ React17.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2353
+ content: /* @__PURE__ */ React26.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2279
2354
  },
2280
- /* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.key))
2355
+ /* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
2281
2356
  )
2282
2357
  );
2283
2358
  }
@@ -2338,7 +2413,7 @@ function VariableTagInject() {
2338
2413
  {
2339
2414
  decorations: (p) => p.decorations,
2340
2415
  provide(p) {
2341
- return EditorView3.atomicRanges.of(
2416
+ return EditorView4.atomicRanges.of(
2342
2417
  (view) => view.plugin(p)?.decorations ?? Decoration.none
2343
2418
  );
2344
2419
  }
@@ -2351,15 +2426,15 @@ function VariableTagInject() {
2351
2426
 
2352
2427
  // src/components/prompt-editor-with-variables/index.tsx
2353
2428
  function PromptEditorWithVariables(props) {
2354
- return /* @__PURE__ */ React18.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React18.createElement(VariableTree, null), /* @__PURE__ */ React18.createElement(VariableTagInject, null));
2429
+ return /* @__PURE__ */ React27.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React27.createElement(VariableTree, null), /* @__PURE__ */ React27.createElement(VariableTagInject, null));
2355
2430
  }
2356
2431
 
2357
2432
  // src/components/prompt-editor-with-inputs/index.tsx
2358
- import React21 from "react";
2433
+ import React30 from "react";
2359
2434
 
2360
2435
  // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2361
- import React20, { useEffect as useEffect6, useState as useState7 } from "react";
2362
- import { Popover as Popover3 } from "@douyinfe/semi-ui";
2436
+ import React29, { useEffect as useEffect7, useState as useState7 } from "react";
2437
+ import { Popover as Popover4 } from "@douyinfe/semi-ui";
2363
2438
  import {
2364
2439
  Mention as Mention2,
2365
2440
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
@@ -2368,18 +2443,18 @@ import {
2368
2443
  } from "@coze-editor/editor/react";
2369
2444
 
2370
2445
  // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2371
- import React19, { useMemo as useMemo10 } from "react";
2446
+ import React28, { useMemo as useMemo9 } from "react";
2372
2447
  import { last as last2 } from "lodash";
2373
2448
  import {
2374
2449
  ASTMatch as ASTMatch3,
2375
- useScopeAvailable as useScopeAvailable2
2450
+ useScopeAvailable as useScopeAvailable3
2376
2451
  } from "@flowgram.ai/editor";
2377
2452
  import { Tree as Tree2 } from "@douyinfe/semi-ui";
2378
2453
  function InputsPicker({
2379
2454
  inputsValues,
2380
2455
  onSelect
2381
2456
  }) {
2382
- const available = useScopeAvailable2();
2457
+ const available = useScopeAvailable3();
2383
2458
  const getArrayDrilldown = (type, depth = 1) => {
2384
2459
  if (ASTMatch3.isArray(type.items)) {
2385
2460
  return getArrayDrilldown(type.items, depth + 1);
@@ -2411,413 +2486,91 @@ function InputsPicker({
2411
2486
  value: key,
2412
2487
  children
2413
2488
  };
2414
- };
2415
- const treeData = useMemo10(
2416
- () => Object.entries(inputsValues).map(([key, value]) => {
2417
- if (value.type === "ref") {
2418
- const variable = available.getByKeyPath(value.content || []);
2419
- if (variable) {
2420
- return renderVariable(variable, [key]);
2421
- }
2422
- }
2423
- return {
2424
- key,
2425
- value: key,
2426
- label: key
2427
- };
2428
- }),
2429
- []
2430
- );
2431
- return /* @__PURE__ */ React19.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
2432
- }
2433
-
2434
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2435
- function InputsTree({ inputsValues }) {
2436
- const [posKey, setPosKey] = useState7("");
2437
- const [visible, setVisible] = useState7(false);
2438
- const [position, setPosition] = useState7(-1);
2439
- const editor = useEditor2();
2440
- function insert(variablePath) {
2441
- const range = getCurrentMentionReplaceRange2(editor.$view.state);
2442
- if (!range) {
2443
- return;
2444
- }
2445
- editor.replaceText({
2446
- ...range,
2447
- text: "{{" + variablePath + "}}"
2448
- });
2449
- setVisible(false);
2450
- }
2451
- function handleOpenChange(e) {
2452
- setPosition(e.state.selection.main.head);
2453
- setVisible(e.value);
2454
- }
2455
- useEffect6(() => {
2456
- if (!editor) {
2457
- return;
2458
- }
2459
- }, [editor, visible]);
2460
- return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React20.createElement(
2461
- Popover3,
2462
- {
2463
- visible,
2464
- trigger: "custom",
2465
- position: "topLeft",
2466
- rePosKey: posKey,
2467
- content: /* @__PURE__ */ React20.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React20.createElement(
2468
- InputsPicker,
2469
- {
2470
- inputsValues,
2471
- onSelect: (v) => {
2472
- insert(v);
2473
- }
2474
- }
2475
- ))
2476
- },
2477
- /* @__PURE__ */ React20.createElement(
2478
- PositionMirror2,
2479
- {
2480
- position,
2481
- onChange: () => setPosKey(String(Math.random()))
2482
- }
2483
- )
2484
- ));
2485
- }
2486
-
2487
- // src/components/prompt-editor-with-inputs/index.tsx
2488
- function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2489
- return /* @__PURE__ */ React21.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React21.createElement(InputsTree, { inputsValues }));
2490
- }
2491
-
2492
- // src/components/code-editor/index.tsx
2493
- import React22, { useEffect as useEffect7, useRef as useRef4 } from "react";
2494
- import {
2495
- ActiveLinePlaceholder as ActiveLinePlaceholder2,
2496
- createRenderer,
2497
- EditorProvider as EditorProvider2
2498
- } from "@coze-editor/editor/react";
2499
- import preset2 from "@coze-editor/editor/preset-code";
2500
- import { EditorView as EditorView4 } from "@codemirror/view";
2501
-
2502
- // src/components/code-editor/utils.ts
2503
- function getSuffixByLanguageId(languageId) {
2504
- if (languageId === "python") {
2505
- return ".py";
2506
- }
2507
- if (languageId === "typescript") {
2508
- return ".ts";
2509
- }
2510
- if (languageId === "shell") {
2511
- return ".sh";
2512
- }
2513
- if (languageId === "json") {
2514
- return ".json";
2515
- }
2516
- return "";
2517
- }
2518
-
2519
- // src/components/code-editor/theme/index.ts
2520
- import { themes } from "@coze-editor/editor/preset-code";
2521
-
2522
- // src/components/code-editor/theme/light.ts
2523
- import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
2524
- var colors = {
2525
- background: "#F7F7FC",
2526
- // syntax
2527
- comment: "#000A298A",
2528
- key: "#00818C",
2529
- string: "#D1009D",
2530
- number: "#C74200",
2531
- boolean: "#2B57D9",
2532
- null: "#2B57D9",
2533
- separator: "#0F1529D1"
2534
- };
2535
- var lightTheme = createTheme({
2536
- variant: "light",
2537
- settings: {
2538
- background: "#fff",
2539
- foreground: "#000",
2540
- caret: "#000",
2541
- selection: "#d9d9d9",
2542
- gutterBackground: "#f0f0f0",
2543
- gutterForeground: "#666",
2544
- gutterBorderColor: "transparent",
2545
- gutterBorderWidth: 0,
2546
- lineHighlight: "#f0f0f0",
2547
- bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
2548
- tooltip: {
2549
- backgroundColor: "#f0f0f0",
2550
- color: "#000",
2551
- border: "1px solid #ccc"
2552
- },
2553
- link: {
2554
- color: "#007bff"
2555
- },
2556
- completionItemHover: {
2557
- backgroundColor: "#f0f0f0"
2558
- },
2559
- completionItemSelected: {
2560
- backgroundColor: "#e0e0e0"
2561
- },
2562
- completionItemIcon: {
2563
- color: "#333"
2564
- },
2565
- completionItemLabel: {
2566
- color: "#333"
2567
- },
2568
- completionItemInfo: {
2569
- color: "#333"
2570
- },
2571
- completionItemDetail: {
2572
- color: "#666"
2573
- }
2574
- },
2575
- styles: [
2576
- // JSON
2577
- {
2578
- tag: t.comment,
2579
- color: colors.comment
2580
- },
2581
- {
2582
- tag: [t.propertyName],
2583
- color: colors.key
2584
- },
2585
- {
2586
- tag: [t.string],
2587
- color: colors.string
2588
- },
2589
- {
2590
- tag: [t.number],
2591
- color: colors.number
2592
- },
2593
- {
2594
- tag: [t.bool],
2595
- color: colors.boolean
2596
- },
2597
- {
2598
- tag: [t.null],
2599
- color: colors.null
2600
- },
2601
- {
2602
- tag: [t.separator],
2603
- color: colors.separator
2604
- },
2605
- // markdown
2606
- {
2607
- tag: [t.heading],
2608
- color: "#3e76ef"
2609
- },
2610
- {
2611
- tag: [t.processingInstruction],
2612
- color: "#3e76ef"
2613
- },
2614
- // shell
2615
- // curl
2616
- {
2617
- tag: [t.standard(t.variableName)],
2618
- color: "#00804A"
2619
- },
2620
- // -X
2621
- {
2622
- tag: [t.attributeName],
2623
- color: "#C74200"
2624
- },
2625
- // url in string (includes quotes), e.g. "https://..."
2626
- {
2627
- tag: [t.special(t.string)],
2628
- color: "#2B57D9"
2629
- }
2630
- ]
2631
- });
2632
-
2633
- // src/components/code-editor/theme/dark.ts
2634
- import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
2635
- var colors2 = {
2636
- background: "#151B27",
2637
- // syntax
2638
- comment: "#FFFFFF63",
2639
- key: "#39E5D7",
2640
- string: "#FF94D2",
2641
- number: "#FF9933",
2642
- boolean: "#78B0FF",
2643
- null: "#78B0FF",
2644
- separator: "#FFFFFFC9"
2645
- };
2646
- var darkTheme = createTheme2({
2647
- variant: "dark",
2648
- settings: {
2649
- background: colors2.background,
2650
- foreground: "#fff",
2651
- caret: "#AEAFAD",
2652
- selection: "#d9d9d942",
2653
- gutterBackground: colors2.background,
2654
- gutterForeground: "#FFFFFF63",
2655
- gutterBorderColor: "transparent",
2656
- gutterBorderWidth: 0,
2657
- lineHighlight: "#272e3d36",
2658
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
2659
- tooltip: {
2660
- backgroundColor: "#363D4D",
2661
- color: "#fff",
2662
- border: "none"
2663
- },
2664
- link: {
2665
- color: "#4daafc"
2666
- },
2667
- completionItemHover: {
2668
- backgroundColor: "#FFFFFF0F"
2669
- },
2670
- completionItemSelected: {
2671
- backgroundColor: "#FFFFFF17"
2672
- },
2673
- completionItemIcon: {
2674
- color: "#FFFFFFC9"
2675
- },
2676
- completionItemLabel: {
2677
- color: "#FFFFFFC9"
2678
- },
2679
- completionItemInfo: {
2680
- color: "#FFFFFFC9"
2681
- },
2682
- completionItemDetail: {
2683
- color: "#FFFFFF63"
2684
- }
2685
- },
2686
- styles: [
2687
- // json
2688
- {
2689
- tag: t2.comment,
2690
- color: colors2.comment
2691
- },
2692
- {
2693
- tag: [t2.propertyName],
2694
- color: colors2.key
2695
- },
2696
- {
2697
- tag: [t2.string],
2698
- color: colors2.string
2699
- },
2700
- {
2701
- tag: [t2.number],
2702
- color: colors2.number
2703
- },
2704
- {
2705
- tag: [t2.bool],
2706
- color: colors2.boolean
2707
- },
2708
- {
2709
- tag: [t2.null],
2710
- color: colors2.null
2711
- },
2712
- {
2713
- tag: [t2.separator],
2714
- color: colors2.separator
2715
- },
2716
- // markdown
2717
- {
2718
- tag: [t2.heading],
2719
- color: "#6b6bff"
2720
- },
2721
- {
2722
- tag: [t2.processingInstruction],
2723
- color: "#6b6bff"
2724
- },
2725
- // shell
2726
- // curl
2727
- {
2728
- tag: [t2.standard(t2.variableName)],
2729
- color: "#3BEB84"
2730
- },
2731
- // -X
2732
- {
2733
- tag: [t2.attributeName],
2734
- color: "#FF9933"
2735
- },
2736
- // url in string (includes quotes), e.g. "https://..."
2737
- {
2738
- tag: [t2.special(t2.string)],
2739
- color: "#78B0FF"
2740
- }
2741
- ]
2742
- });
2743
-
2744
- // src/components/code-editor/theme/index.ts
2745
- themes.register("dark", darkTheme);
2746
- themes.register("light", lightTheme);
2747
-
2748
- // src/components/code-editor/language-features.ts
2749
- import { languages } from "@coze-editor/editor/preset-code";
2750
- import { typescript } from "@coze-editor/editor/language-typescript";
2751
- import { shell } from "@coze-editor/editor/language-shell";
2752
- import { python } from "@coze-editor/editor/language-python";
2753
- import { json } from "@coze-editor/editor/language-json";
2754
- import { mixLanguages } from "@coze-editor/editor";
2755
- languages.register("python", python);
2756
- languages.register("typescript", typescript);
2757
- languages.register("shell", shell);
2758
- languages.register("json", {
2759
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
2760
- language: mixLanguages({
2761
- outerLanguage: json.language
2762
- }),
2763
- languageService: json.languageService
2764
- });
2489
+ };
2490
+ const treeData = useMemo9(
2491
+ () => Object.entries(inputsValues).map(([key, value]) => {
2492
+ if (value?.type === "ref") {
2493
+ const variable = available.getByKeyPath(value.content || []);
2494
+ if (variable) {
2495
+ return renderVariable(variable, [key]);
2496
+ }
2497
+ }
2498
+ return {
2499
+ key,
2500
+ value: key,
2501
+ label: key
2502
+ };
2503
+ }),
2504
+ []
2505
+ );
2506
+ return /* @__PURE__ */ React28.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
2507
+ }
2765
2508
 
2766
- // src/components/code-editor/index.tsx
2767
- var OriginCodeEditor = createRenderer(preset2, [
2768
- EditorView4.theme({
2769
- "&.cm-focused": {
2770
- outline: "none"
2509
+ // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2510
+ function InputsTree({ inputsValues }) {
2511
+ const [posKey, setPosKey] = useState7("");
2512
+ const [visible, setVisible] = useState7(false);
2513
+ const [position, setPosition] = useState7(-1);
2514
+ const editor = useEditor2();
2515
+ function insert(variablePath) {
2516
+ const range = getCurrentMentionReplaceRange2(editor.$view.state);
2517
+ if (!range) {
2518
+ return;
2771
2519
  }
2772
- })
2773
- ]);
2774
- function CodeEditor({
2775
- value,
2776
- onChange,
2777
- languageId = "python",
2778
- theme = "light",
2779
- children,
2780
- placeholder,
2781
- activeLinePlaceholder,
2782
- options: options2,
2783
- readonly
2784
- }) {
2785
- const editorRef = useRef4(null);
2520
+ editor.replaceText({
2521
+ ...range,
2522
+ text: "{{" + variablePath + "}}"
2523
+ });
2524
+ setVisible(false);
2525
+ }
2526
+ function handleOpenChange(e) {
2527
+ setPosition(e.state.selection.main.head);
2528
+ setVisible(e.value);
2529
+ }
2786
2530
  useEffect7(() => {
2787
- if (editorRef.current?.getValue() !== value) {
2788
- editorRef.current?.setValue(String(value || ""));
2531
+ if (!editor) {
2532
+ return;
2789
2533
  }
2790
- }, [value]);
2791
- return /* @__PURE__ */ React22.createElement(EditorProvider2, null, /* @__PURE__ */ React22.createElement(
2792
- OriginCodeEditor,
2534
+ }, [editor, visible]);
2535
+ return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React29.createElement(
2536
+ Popover4,
2793
2537
  {
2794
- defaultValue: value,
2795
- options: {
2796
- uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
2797
- languageId,
2798
- theme,
2799
- placeholder,
2800
- readOnly: readonly,
2801
- editable: !readonly,
2802
- ...options2 || {}
2803
- },
2804
- didMount: (editor) => {
2805
- editorRef.current = editor;
2806
- },
2807
- onChange: (e) => onChange?.(e.value)
2538
+ visible,
2539
+ trigger: "custom",
2540
+ position: "topLeft",
2541
+ rePosKey: posKey,
2542
+ content: /* @__PURE__ */ React29.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React29.createElement(
2543
+ InputsPicker,
2544
+ {
2545
+ inputsValues,
2546
+ onSelect: (v) => {
2547
+ insert(v);
2548
+ }
2549
+ }
2550
+ ))
2808
2551
  },
2809
- activeLinePlaceholder && /* @__PURE__ */ React22.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder),
2810
- children
2552
+ /* @__PURE__ */ React29.createElement(
2553
+ PositionMirror2,
2554
+ {
2555
+ position,
2556
+ onChange: () => setPosKey(String(Math.random()))
2557
+ }
2558
+ )
2811
2559
  ));
2812
2560
  }
2813
2561
 
2562
+ // src/components/prompt-editor-with-inputs/index.tsx
2563
+ function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2564
+ return /* @__PURE__ */ React30.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React30.createElement(InputsTree, { inputsValues }));
2565
+ }
2566
+
2814
2567
  // src/components/json-editor-with-variables/index.tsx
2815
- import React25 from "react";
2568
+ import React33 from "react";
2816
2569
  import { transformerCreator } from "@coze-editor/editor/preset-code";
2817
2570
 
2818
2571
  // src/components/json-editor-with-variables/extensions/variable-tree.tsx
2819
- import React23, { useEffect as useEffect8, useState as useState8 } from "react";
2820
- import { Popover as Popover4, Tree as Tree3 } from "@douyinfe/semi-ui";
2572
+ import React31, { useEffect as useEffect8, useState as useState8 } from "react";
2573
+ import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
2821
2574
  import {
2822
2575
  Mention as Mention3,
2823
2576
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange3,
@@ -2850,14 +2603,14 @@ function VariableTree2() {
2850
2603
  }
2851
2604
  }, [editor, visible]);
2852
2605
  const treeData = useVariableTree({});
2853
- return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React23.createElement(
2854
- Popover4,
2606
+ return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React31.createElement(
2607
+ Popover5,
2855
2608
  {
2856
2609
  visible,
2857
2610
  trigger: "custom",
2858
2611
  position: "topLeft",
2859
2612
  rePosKey: posKey,
2860
- content: /* @__PURE__ */ React23.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React23.createElement(
2613
+ content: /* @__PURE__ */ React31.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React31.createElement(
2861
2614
  Tree3,
2862
2615
  {
2863
2616
  treeData,
@@ -2867,7 +2620,7 @@ function VariableTree2() {
2867
2620
  }
2868
2621
  ))
2869
2622
  },
2870
- /* @__PURE__ */ React23.createElement(
2623
+ /* @__PURE__ */ React31.createElement(
2871
2624
  PositionMirror3,
2872
2625
  {
2873
2626
  position,
@@ -2878,7 +2631,7 @@ function VariableTree2() {
2878
2631
  }
2879
2632
 
2880
2633
  // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2881
- import React24, { useLayoutEffect as useLayoutEffect5 } from "react";
2634
+ import React32, { useLayoutEffect as useLayoutEffect5 } from "react";
2882
2635
  import { createRoot } from "react-dom/client";
2883
2636
  import { isEqual as isEqual2, last as last3 } from "lodash";
2884
2637
  import {
@@ -2886,7 +2639,7 @@ import {
2886
2639
  DisposableCollection as DisposableCollection2,
2887
2640
  useCurrentScope as useCurrentScope2
2888
2641
  } from "@flowgram.ai/editor";
2889
- import { Popover as Popover5 } from "@douyinfe/semi-ui";
2642
+ import { Popover as Popover6 } from "@douyinfe/semi-ui";
2890
2643
  import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
2891
2644
  import { useInjector as useInjector5 } from "@coze-editor/editor/react";
2892
2645
  import {
@@ -2898,9 +2651,9 @@ import {
2898
2651
  } from "@codemirror/view";
2899
2652
 
2900
2653
  // src/components/json-editor-with-variables/styles.tsx
2901
- import styled8 from "styled-components";
2654
+ import styled9 from "styled-components";
2902
2655
  import { Tag as Tag3 } from "@douyinfe/semi-ui";
2903
- var UIRootTitle3 = styled8.div`
2656
+ var UIRootTitle3 = styled9.div`
2904
2657
  margin-right: 4px;
2905
2658
  min-width: 20px;
2906
2659
  overflow: hidden;
@@ -2908,12 +2661,12 @@ var UIRootTitle3 = styled8.div`
2908
2661
  white-space: nowrap;
2909
2662
  color: var(--semi-color-text-2);
2910
2663
  `;
2911
- var UIVarName3 = styled8.div`
2664
+ var UIVarName3 = styled9.div`
2912
2665
  overflow: hidden;
2913
2666
  text-overflow: ellipsis;
2914
2667
  white-space: nowrap;
2915
2668
  `;
2916
- var UITag3 = styled8(Tag3)`
2669
+ var UITag3 = styled9(Tag3)`
2917
2670
  display: inline-flex;
2918
2671
  align-items: center;
2919
2672
  justify-content: flex-start;
@@ -2927,7 +2680,7 @@ var UITag3 = styled8(Tag3)`
2927
2680
  margin: 0 5px;
2928
2681
  }
2929
2682
  `;
2930
- var UIPopoverContent2 = styled8.div`
2683
+ var UIPopoverContent3 = styled9.div`
2931
2684
  padding: 10px;
2932
2685
  display: inline-flex;
2933
2686
  align-items: center;
@@ -2941,7 +2694,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
2941
2694
  this.toDispose = new DisposableCollection2();
2942
2695
  this.renderIcon = (icon) => {
2943
2696
  if (typeof icon === "string") {
2944
- return /* @__PURE__ */ React24.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2697
+ return /* @__PURE__ */ React32.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2945
2698
  }
2946
2699
  return icon;
2947
2700
  };
@@ -2951,20 +2704,20 @@ var VariableTagWidget2 = class extends WidgetType2 {
2951
2704
  renderVariable(v) {
2952
2705
  if (!v) {
2953
2706
  this.root.render(
2954
- /* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React24.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
2707
+ /* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React32.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
2955
2708
  );
2956
2709
  return;
2957
2710
  }
2958
2711
  const rootField = last3(v.parentFields);
2959
- const rootTitle = /* @__PURE__ */ React24.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2712
+ const rootTitle = /* @__PURE__ */ React32.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2960
2713
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2961
2714
  this.root.render(
2962
- /* @__PURE__ */ React24.createElement(
2963
- Popover5,
2715
+ /* @__PURE__ */ React32.createElement(
2716
+ Popover6,
2964
2717
  {
2965
- content: /* @__PURE__ */ React24.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2718
+ content: /* @__PURE__ */ React32.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2966
2719
  },
2967
- /* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.key))
2720
+ /* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.key))
2968
2721
  )
2969
2722
  );
2970
2723
  }
@@ -3036,80 +2789,546 @@ function VariableTagInject2() {
3036
2789
  return null;
3037
2790
  }
3038
2791
 
3039
- // src/components/json-editor-with-variables/index.tsx
3040
- function findAllMatches(inputString, regex) {
3041
- const globalRegex = new RegExp(
3042
- regex,
3043
- regex.flags.includes("g") ? regex.flags : regex.flags + "g"
3044
- );
3045
- let match;
3046
- const matches = [];
3047
- while ((match = globalRegex.exec(inputString)) !== null) {
3048
- if (match.index === globalRegex.lastIndex) {
3049
- globalRegex.lastIndex++;
2792
+ // src/components/json-editor-with-variables/index.tsx
2793
+ function findAllMatches(inputString, regex) {
2794
+ const globalRegex = new RegExp(
2795
+ regex,
2796
+ regex.flags.includes("g") ? regex.flags : regex.flags + "g"
2797
+ );
2798
+ let match;
2799
+ const matches = [];
2800
+ while ((match = globalRegex.exec(inputString)) !== null) {
2801
+ if (match.index === globalRegex.lastIndex) {
2802
+ globalRegex.lastIndex++;
2803
+ }
2804
+ matches.push({
2805
+ match: match[0],
2806
+ range: [match.index, match.index + match[0].length]
2807
+ });
2808
+ }
2809
+ return matches;
2810
+ }
2811
+ var transformer = transformerCreator((text) => {
2812
+ const originalSource = text.toString();
2813
+ const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
2814
+ if (matches.length > 0) {
2815
+ matches.forEach(({ range }) => {
2816
+ text.replaceRange(range[0], range[1], "null");
2817
+ });
2818
+ }
2819
+ return text;
2820
+ });
2821
+ function JsonEditorWithVariables(props) {
2822
+ return /* @__PURE__ */ React33.createElement(
2823
+ CodeEditor,
2824
+ {
2825
+ languageId: "json",
2826
+ activeLinePlaceholder: "Press '@' to Select variable",
2827
+ ...props,
2828
+ options: {
2829
+ transformer,
2830
+ ...props.options || {}
2831
+ }
2832
+ },
2833
+ /* @__PURE__ */ React33.createElement(VariableTree2, null),
2834
+ /* @__PURE__ */ React33.createElement(VariableTagInject2, null)
2835
+ );
2836
+ }
2837
+
2838
+ // src/components/inputs-values/index.tsx
2839
+ import React35 from "react";
2840
+ import { I18n as I18n12 } from "@flowgram.ai/editor";
2841
+ import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
2842
+ import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
2843
+
2844
+ // src/components/inputs-values/styles.tsx
2845
+ import styled10 from "styled-components";
2846
+ var UIRows2 = styled10.div`
2847
+ display: flex;
2848
+ flex-direction: column;
2849
+ gap: 10px;
2850
+ margin-bottom: 10px;
2851
+ `;
2852
+ var UIRow3 = styled10.div`
2853
+ display: flex;
2854
+ align-items: center;
2855
+ gap: 5px;
2856
+ `;
2857
+
2858
+ // src/components/inputs-values/components/blur-input.tsx
2859
+ import React34, { useEffect as useEffect9, useState as useState9 } from "react";
2860
+ import Input6 from "@douyinfe/semi-ui/lib/es/input";
2861
+ function BlurInput2(props) {
2862
+ const [value, setValue] = useState9("");
2863
+ useEffect9(() => {
2864
+ setValue(props.value);
2865
+ }, [props.value]);
2866
+ return /* @__PURE__ */ React34.createElement(
2867
+ Input6,
2868
+ {
2869
+ ...props,
2870
+ value,
2871
+ onChange: (value2) => {
2872
+ setValue(value2);
2873
+ },
2874
+ onBlur: (e) => props.onChange?.(value, e)
2875
+ }
2876
+ );
2877
+ }
2878
+
2879
+ // src/components/inputs-values/index.tsx
2880
+ function InputsValues({
2881
+ value,
2882
+ onChange,
2883
+ style,
2884
+ readonly,
2885
+ constantProps,
2886
+ schema,
2887
+ hasError
2888
+ }) {
2889
+ const { list, updateKey, updateValue, remove, add } = useObjectList({
2890
+ value,
2891
+ onChange,
2892
+ sortIndexKey: "extra.index"
2893
+ });
2894
+ return /* @__PURE__ */ React35.createElement("div", null, /* @__PURE__ */ React35.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React35.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React35.createElement(
2895
+ BlurInput2,
2896
+ {
2897
+ style: { width: 100, minWidth: 100, maxWidth: 100 },
2898
+ disabled: readonly,
2899
+ size: "small",
2900
+ value: item.key,
2901
+ onChange: (v) => updateKey(item.id, v),
2902
+ placeholder: I18n12.t("Input Key")
2903
+ }
2904
+ ), /* @__PURE__ */ React35.createElement(
2905
+ InjectDynamicValueInput,
2906
+ {
2907
+ style: { flexGrow: 1 },
2908
+ readonly,
2909
+ value: item.value,
2910
+ onChange: (v) => updateValue(item.id, v),
2911
+ schema,
2912
+ hasError,
2913
+ constantProps: {
2914
+ ...constantProps,
2915
+ strategies: [...constantProps?.strategies || []]
2916
+ }
2917
+ }
2918
+ ), /* @__PURE__ */ React35.createElement(
2919
+ IconButton4,
2920
+ {
2921
+ disabled: readonly,
2922
+ theme: "borderless",
2923
+ icon: /* @__PURE__ */ React35.createElement(IconDelete2, { size: "small" }),
2924
+ size: "small",
2925
+ onClick: () => remove(item.id)
2926
+ }
2927
+ )))), /* @__PURE__ */ React35.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React35.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
2928
+ }
2929
+
2930
+ // src/components/display-schema-tree/index.tsx
2931
+ import React36 from "react";
2932
+
2933
+ // src/components/display-schema-tree/styles.tsx
2934
+ import styled11, { css as css4 } from "styled-components";
2935
+ var TreeRow = styled11.div`
2936
+ display: flex;
2937
+ align-items: center;
2938
+
2939
+ .tree-icon {
2940
+ margin-right: 8px;
2941
+ width: 14px;
2942
+ height: 14px;
2943
+ }
2944
+
2945
+ height: 27px;
2946
+ white-space: nowrap;
2947
+ `;
2948
+ var HorizontalLine = styled11.div`
2949
+ position: relative;
2950
+
2951
+ &::before,
2952
+ &::after {
2953
+ content: '';
2954
+ position: absolute;
2955
+ background-color: var(--semi-color-text-3);
2956
+ }
2957
+
2958
+ &::after {
2959
+ top: 0px;
2960
+ right: 6px;
2961
+ width: 15px;
2962
+ height: 1px;
2963
+ }
2964
+ `;
2965
+ var TreeTitle = styled11.div`
2966
+ // overflow: hidden;
2967
+ // text-overflow: ellipsis;
2968
+ `;
2969
+ var TreeLevel = styled11.div`
2970
+ padding-left: 30px;
2971
+ position: relative;
2972
+
2973
+ /* &::before {
2974
+ content: '';
2975
+ position: absolute;
2976
+ background-color: var(--semi-color-text-3);
2977
+ top: 0px;
2978
+ bottom: 0px;
2979
+ left: -22px;
2980
+ width: 1px;
2981
+ } */
2982
+ `;
2983
+ var TreeItem = styled11.div`
2984
+ position: relative;
2985
+
2986
+ &::before {
2987
+ content: '';
2988
+ position: absolute;
2989
+ background-color: var(--semi-color-text-3);
2990
+ }
2991
+
2992
+ &:not(:last-child)::before {
2993
+ width: 1px;
2994
+ top: 0;
2995
+ bottom: 0;
2996
+ left: -22px;
2997
+ }
2998
+
2999
+ &:last-child::before {
3000
+ width: 1px;
3001
+ top: 0;
3002
+ height: 14px;
3003
+ left: -22px;
3004
+ }
3005
+
3006
+ ${(props) => props.depth === 0 && css4`
3007
+ &::before {
3008
+ width: 0px !important;
3009
+ }
3010
+ `}
3011
+ `;
3012
+
3013
+ // src/components/display-schema-tree/index.tsx
3014
+ function DisplaySchemaTree(props) {
3015
+ return /* @__PURE__ */ React36.createElement(SchemaTree, { ...props });
3016
+ }
3017
+ function SchemaTree(props) {
3018
+ const {
3019
+ value: schema = {},
3020
+ drilldown = true,
3021
+ depth = 0,
3022
+ showIcon = true,
3023
+ parentKey = ""
3024
+ } = props || {};
3025
+ const typeManager = useTypeManager();
3026
+ const config = typeManager.getTypeBySchema(schema);
3027
+ const title = typeManager.getComplexText(schema);
3028
+ const icon = typeManager?.getDisplayIcon(schema);
3029
+ let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
3030
+ const childEntries = Object.entries(properties || {});
3031
+ return /* @__PURE__ */ React36.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React36.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React36.createElement(HorizontalLine, null), showIcon && icon && React36.cloneElement(icon, {
3032
+ className: "tree-icon"
3033
+ }), /* @__PURE__ */ React36.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React36.createElement(React36.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React36.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React36.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
3034
+ }
3035
+
3036
+ // src/components/display-outputs/index.tsx
3037
+ import React38, { useEffect as useEffect10 } from "react";
3038
+ import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
3039
+ import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
3040
+
3041
+ // src/components/display-schema-tag/index.tsx
3042
+ import React37 from "react";
3043
+ import { Popover as Popover7 } from "@douyinfe/semi-ui";
3044
+
3045
+ // src/components/display-schema-tag/styles.ts
3046
+ import styled12 from "styled-components";
3047
+ import { Tag as Tag4 } from "@douyinfe/semi-ui";
3048
+ var PopoverContent = styled12.div`
3049
+ padding: 10px;
3050
+ `;
3051
+ var StyledTag = styled12(Tag4)`
3052
+ padding: 4px;
3053
+
3054
+ .tag-icon {
3055
+ width: 12px;
3056
+ height: 12px;
3057
+ }
3058
+ `;
3059
+ var TitleSpan = styled12.span`
3060
+ display: inline-block;
3061
+ margin-left: 4px;
3062
+ margin-top: -1px;
3063
+ overflow: hidden;
3064
+ text-overflow: ellipsis;
3065
+ `;
3066
+
3067
+ // src/components/display-schema-tag/index.tsx
3068
+ function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
3069
+ const typeManager = useTypeManager();
3070
+ const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
3071
+ return /* @__PURE__ */ React37.createElement(
3072
+ Popover7,
3073
+ {
3074
+ content: /* @__PURE__ */ React37.createElement(PopoverContent, null, /* @__PURE__ */ React37.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
3075
+ },
3076
+ /* @__PURE__ */ React37.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React37.cloneElement(icon, {
3077
+ className: "tag-icon"
3078
+ }), title && /* @__PURE__ */ React37.createElement(TitleSpan, null, title))
3079
+ );
3080
+ }
3081
+
3082
+ // src/components/display-outputs/styles.ts
3083
+ import styled13 from "styled-components";
3084
+ var DisplayOutputsWrapper = styled13.div`
3085
+ display: flex;
3086
+ gap: 5px;
3087
+ flex-wrap: wrap;
3088
+ `;
3089
+
3090
+ // src/components/display-outputs/index.tsx
3091
+ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3092
+ const scope = useCurrentScope3();
3093
+ const refresh = useRefresh();
3094
+ useEffect10(() => {
3095
+ if (!displayFromScope) {
3096
+ return () => null;
3097
+ }
3098
+ const disposable = scope.output.onListOrAnyVarChange(() => {
3099
+ refresh();
3100
+ });
3101
+ return () => {
3102
+ disposable.dispose();
3103
+ };
3104
+ }, [displayFromScope]);
3105
+ const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
3106
+ acm = {
3107
+ ...acm,
3108
+ ...JsonSchemaUtils5.astToSchema(curr.type)?.properties || {}
3109
+ };
3110
+ return acm;
3111
+ }, {}) : value?.properties || {};
3112
+ const childEntries = Object.entries(properties || {});
3113
+ return /* @__PURE__ */ React38.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React38.createElement(
3114
+ DisplaySchemaTag,
3115
+ {
3116
+ key,
3117
+ title: key,
3118
+ value: schema,
3119
+ showIconInTree,
3120
+ warning: !schema
3121
+ }
3122
+ )));
3123
+ }
3124
+
3125
+ // src/components/display-flow-value/index.tsx
3126
+ import React39, { useMemo as useMemo10 } from "react";
3127
+ import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
3128
+ import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
3129
+ function DisplayFlowValue({ value, title, showIconInTree }) {
3130
+ const available = useScopeAvailable4();
3131
+ const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3132
+ const schema = useMemo10(() => {
3133
+ if (value?.type === "ref") {
3134
+ return JsonSchemaUtils6.astToSchema(variable?.type);
3050
3135
  }
3051
- matches.push({
3052
- match: match[0],
3053
- range: [match.index, match.index + match[0].length]
3054
- });
3055
- }
3056
- return matches;
3136
+ if (value?.type === "template") {
3137
+ return { type: "string" };
3138
+ }
3139
+ if (value?.type === "constant") {
3140
+ if (value?.schema) {
3141
+ return value?.schema;
3142
+ }
3143
+ if (typeof value?.content === "string") {
3144
+ return { type: "string" };
3145
+ }
3146
+ if (typeof value?.content === "number") {
3147
+ return { type: "number" };
3148
+ }
3149
+ if (typeof value?.content === "boolean") {
3150
+ return { type: "boolean" };
3151
+ }
3152
+ }
3153
+ return { type: "unknown" };
3154
+ }, [value, variable?.hash]);
3155
+ return /* @__PURE__ */ React39.createElement(
3156
+ DisplaySchemaTag,
3157
+ {
3158
+ title,
3159
+ value: schema,
3160
+ showIconInTree,
3161
+ warning: value?.type === "ref" && !variable
3162
+ }
3163
+ );
3057
3164
  }
3058
- var transformer = transformerCreator((text) => {
3059
- const originalSource = text.toString();
3060
- const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
3061
- if (matches.length > 0) {
3062
- matches.forEach(({ range }) => {
3063
- text.replaceRange(range[0], range[1], "null");
3064
- });
3065
- }
3066
- return text;
3067
- });
3068
- function JsonEditorWithVariables(props) {
3069
- return /* @__PURE__ */ React25.createElement(
3070
- CodeEditor,
3165
+
3166
+ // src/components/display-inputs-values/index.tsx
3167
+ import React40 from "react";
3168
+
3169
+ // src/components/display-inputs-values/styles.ts
3170
+ import styled14 from "styled-components";
3171
+ var DisplayInputsWrapper = styled14.div`
3172
+ display: flex;
3173
+ gap: 5px;
3174
+ flex-wrap: wrap;
3175
+ `;
3176
+
3177
+ // src/components/display-inputs-values/index.tsx
3178
+ function DisplayInputsValues({ value, showIconInTree }) {
3179
+ const childEntries = Object.entries(value || {});
3180
+ return /* @__PURE__ */ React40.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React40.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
3181
+ }
3182
+
3183
+ // src/components/assign-rows/index.tsx
3184
+ import React43 from "react";
3185
+ import { FieldArray } from "@flowgram.ai/editor";
3186
+ import { Button as Button5 } from "@douyinfe/semi-ui";
3187
+ import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
3188
+
3189
+ // src/components/assign-row/index.tsx
3190
+ import React42 from "react";
3191
+ import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
3192
+ import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
3193
+
3194
+ // src/components/assign-row/components/blur-input.tsx
3195
+ import React41, { useEffect as useEffect11, useState as useState10 } from "react";
3196
+ import Input7 from "@douyinfe/semi-ui/lib/es/input";
3197
+ function BlurInput3(props) {
3198
+ const [value, setValue] = useState10("");
3199
+ useEffect11(() => {
3200
+ setValue(props.value);
3201
+ }, [props.value]);
3202
+ return /* @__PURE__ */ React41.createElement(
3203
+ Input7,
3071
3204
  {
3072
- languageId: "json",
3073
- activeLinePlaceholder: "Press '@' to Select variable",
3074
3205
  ...props,
3075
- options: {
3076
- transformer,
3077
- ...props.options || {}
3078
- }
3079
- },
3080
- /* @__PURE__ */ React25.createElement(VariableTree2, null),
3081
- /* @__PURE__ */ React25.createElement(VariableTagInject2, null)
3206
+ value,
3207
+ onChange: (value2) => {
3208
+ setValue(value2);
3209
+ },
3210
+ onBlur: (e) => props.onChange?.(value, e)
3211
+ }
3082
3212
  );
3083
3213
  }
3084
3214
 
3215
+ // src/components/assign-row/index.tsx
3216
+ function AssignRow(props) {
3217
+ const {
3218
+ value = {
3219
+ operator: "assign"
3220
+ },
3221
+ onChange,
3222
+ onDelete,
3223
+ readonly
3224
+ } = props;
3225
+ return /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React42.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React42.createElement(
3226
+ InjectVariableSelector,
3227
+ {
3228
+ style: { width: "100%", height: 26 },
3229
+ value: value?.left?.content,
3230
+ config: { placeholder: "Select Left" },
3231
+ onChange: (v) => onChange?.({
3232
+ ...value,
3233
+ left: { type: "ref", content: v }
3234
+ })
3235
+ }
3236
+ ) : /* @__PURE__ */ React42.createElement(
3237
+ BlurInput3,
3238
+ {
3239
+ style: { height: 26 },
3240
+ size: "small",
3241
+ placeholder: "Input Name",
3242
+ value: value?.left,
3243
+ onChange: (v) => onChange?.({
3244
+ ...value,
3245
+ left: v
3246
+ })
3247
+ }
3248
+ )), /* @__PURE__ */ React42.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React42.createElement(
3249
+ InjectDynamicValueInput,
3250
+ {
3251
+ readonly,
3252
+ value: value?.right,
3253
+ onChange: (v) => onChange?.({
3254
+ ...value,
3255
+ right: v
3256
+ })
3257
+ }
3258
+ )), onDelete && /* @__PURE__ */ React42.createElement("div", null, /* @__PURE__ */ React42.createElement(
3259
+ IconButton5,
3260
+ {
3261
+ size: "small",
3262
+ theme: "borderless",
3263
+ icon: /* @__PURE__ */ React42.createElement(IconMinus2, null),
3264
+ onClick: () => onDelete?.()
3265
+ }
3266
+ )));
3267
+ }
3268
+
3269
+ // src/components/assign-rows/index.tsx
3270
+ function AssignRows(props) {
3271
+ const { name, readonly } = props;
3272
+ return /* @__PURE__ */ React43.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React43.createElement(React43.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React43.createElement(
3273
+ AssignRow,
3274
+ {
3275
+ key: childField.key,
3276
+ readonly,
3277
+ value: childField.value,
3278
+ onChange: (value) => {
3279
+ childField.onChange(value);
3280
+ },
3281
+ onDelete: () => field.remove(index)
3282
+ }
3283
+ )), /* @__PURE__ */ React43.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React43.createElement(
3284
+ Button5,
3285
+ {
3286
+ size: "small",
3287
+ theme: "borderless",
3288
+ icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
3289
+ onClick: () => field.append({ operator: "assign" })
3290
+ },
3291
+ "Assign"
3292
+ ), /* @__PURE__ */ React43.createElement(
3293
+ Button5,
3294
+ {
3295
+ size: "small",
3296
+ theme: "borderless",
3297
+ icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
3298
+ onClick: () => field.append({ operator: "declare" })
3299
+ },
3300
+ "Declaration"
3301
+ ))));
3302
+ }
3303
+
3085
3304
  // src/effects/provide-batch-input/index.ts
3086
3305
  import {
3087
- ASTFactory as ASTFactory2,
3306
+ ASTFactory,
3088
3307
  createEffectFromVariableProvider,
3089
3308
  getNodeForm
3090
3309
  } from "@flowgram.ai/editor";
3091
3310
  var provideBatchInputEffect = createEffectFromVariableProvider({
3092
3311
  private: true,
3093
3312
  parse: (value, ctx) => [
3094
- ASTFactory2.createVariableDeclaration({
3313
+ ASTFactory.createVariableDeclaration({
3095
3314
  key: `${ctx.node.id}_locals`,
3096
3315
  meta: {
3097
3316
  title: getNodeForm(ctx.node)?.getValueIn("title"),
3098
3317
  icon: ctx.node.getNodeRegistry().info?.icon
3099
3318
  },
3100
- type: ASTFactory2.createObject({
3319
+ type: ASTFactory.createObject({
3101
3320
  properties: [
3102
- ASTFactory2.createProperty({
3321
+ ASTFactory.createProperty({
3103
3322
  key: "item",
3104
- initializer: ASTFactory2.createEnumerateExpression({
3105
- enumerateFor: ASTFactory2.createKeyPathExpression({
3323
+ initializer: ASTFactory.createEnumerateExpression({
3324
+ enumerateFor: ASTFactory.createKeyPathExpression({
3106
3325
  keyPath: value.content || []
3107
3326
  })
3108
3327
  })
3109
3328
  }),
3110
- ASTFactory2.createProperty({
3329
+ ASTFactory.createProperty({
3111
3330
  key: "index",
3112
- type: ASTFactory2.createNumber()
3331
+ type: ASTFactory.createNumber()
3113
3332
  })
3114
3333
  ]
3115
3334
  })
@@ -3117,38 +3336,8 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
3117
3336
  ]
3118
3337
  });
3119
3338
 
3120
- // src/effects/provide-batch-outputs/index.ts
3121
- import {
3122
- ASTFactory as ASTFactory3,
3123
- createEffectFromVariableProvider as createEffectFromVariableProvider2,
3124
- getNodeForm as getNodeForm2
3125
- } from "@flowgram.ai/editor";
3126
- var provideBatchOutputsEffect = createEffectFromVariableProvider2({
3127
- parse: (value, ctx) => [
3128
- ASTFactory3.createVariableDeclaration({
3129
- key: `${ctx.node.id}`,
3130
- meta: {
3131
- title: getNodeForm2(ctx.node)?.getValueIn("title"),
3132
- icon: ctx.node.getNodeRegistry().info?.icon
3133
- },
3134
- type: ASTFactory3.createObject({
3135
- properties: Object.entries(value).map(
3136
- ([_key, value2]) => ASTFactory3.createProperty({
3137
- key: _key,
3138
- initializer: ASTFactory3.createWrapArrayExpression({
3139
- wrapFor: ASTFactory3.createKeyPathExpression({
3140
- keyPath: value2.content || []
3141
- })
3142
- })
3143
- })
3144
- )
3145
- })
3146
- })
3147
- ]
3148
- });
3149
-
3150
3339
  // src/effects/auto-rename-ref/index.ts
3151
- import { isArray, isObject as isObject2, uniq } from "lodash";
3340
+ import { isArray, isObject as isObject3, uniq } from "lodash";
3152
3341
  import {
3153
3342
  DataEvent,
3154
3343
  VariableFieldKeyRenameService
@@ -3218,7 +3407,7 @@ function isTemplate(value) {
3218
3407
  return value?.type === "template" && typeof value?.content === "string";
3219
3408
  }
3220
3409
  function traverseRef(name, value, cb) {
3221
- if (isObject2(value)) {
3410
+ if (isObject3(value)) {
3222
3411
  if (isRef(value)) {
3223
3412
  cb(name, value);
3224
3413
  return;
@@ -3242,20 +3431,21 @@ function traverseRef(name, value, cb) {
3242
3431
  }
3243
3432
 
3244
3433
  // src/effects/provide-json-schema-outputs/index.ts
3434
+ import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
3245
3435
  import {
3246
- ASTFactory as ASTFactory4,
3247
- createEffectFromVariableProvider as createEffectFromVariableProvider3,
3248
- getNodeForm as getNodeForm3
3436
+ ASTFactory as ASTFactory2,
3437
+ createEffectFromVariableProvider as createEffectFromVariableProvider2,
3438
+ getNodeForm as getNodeForm2
3249
3439
  } from "@flowgram.ai/editor";
3250
- var provideJsonSchemaOutputs = createEffectFromVariableProvider3({
3440
+ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
3251
3441
  parse: (value, ctx) => [
3252
- ASTFactory4.createVariableDeclaration({
3442
+ ASTFactory2.createVariableDeclaration({
3253
3443
  key: `${ctx.node.id}`,
3254
3444
  meta: {
3255
- title: getNodeForm3(ctx.node)?.getValueIn("title") || ctx.node.id,
3445
+ title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
3256
3446
  icon: ctx.node.getNodeRegistry().info?.icon
3257
3447
  },
3258
- type: JsonSchemaUtils.schemaToAST(value)
3448
+ type: JsonSchemaUtils7.schemaToAST(value)
3259
3449
  })
3260
3450
  ]
3261
3451
  });
@@ -3272,6 +3462,7 @@ var syncVariableTitle = [
3272
3462
  context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
3273
3463
  _scope.output.variables.forEach((_var) => {
3274
3464
  _var.updateMeta({
3465
+ ..._var.meta || {},
3275
3466
  title: value || context.node.id,
3276
3467
  icon: context.node.getNodeRegistry().info?.icon
3277
3468
  });
@@ -3281,31 +3472,111 @@ var syncVariableTitle = [
3281
3472
  }
3282
3473
  ];
3283
3474
 
3475
+ // src/effects/validate-when-variable-sync/index.ts
3476
+ import { isEmpty } from "lodash";
3477
+ import {
3478
+ DataEvent as DataEvent3,
3479
+ getNodeScope,
3480
+ getNodePrivateScope
3481
+ } from "@flowgram.ai/editor";
3482
+ var validateWhenVariableSync = ({
3483
+ scope
3484
+ } = {}) => [
3485
+ {
3486
+ event: DataEvent3.onValueInit,
3487
+ effect: ({ context, form }) => {
3488
+ const nodeScope = scope === "private" ? getNodePrivateScope(context.node) : getNodeScope(context.node);
3489
+ const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3490
+ if (!isEmpty(form.state.errors)) {
3491
+ form.validate();
3492
+ }
3493
+ });
3494
+ return () => disposable.dispose();
3495
+ }
3496
+ }
3497
+ ];
3498
+
3499
+ // src/effects/listen-ref-value-change/index.ts
3500
+ import {
3501
+ DataEvent as DataEvent4,
3502
+ getNodeScope as getNodeScope2
3503
+ } from "@flowgram.ai/editor";
3504
+ var listenRefValueChange = (cb) => [
3505
+ {
3506
+ event: DataEvent4.onValueInitOrChange,
3507
+ effect: (params) => {
3508
+ const { context, value } = params;
3509
+ if (value?.type !== "ref") {
3510
+ return () => null;
3511
+ }
3512
+ const disposable = getNodeScope2(context.node).available.trackByKeyPath(
3513
+ value?.content || [],
3514
+ (v) => {
3515
+ cb({ ...params, variable: v });
3516
+ }
3517
+ );
3518
+ return () => {
3519
+ disposable.dispose();
3520
+ };
3521
+ }
3522
+ }
3523
+ ];
3524
+
3525
+ // src/effects/listen-ref-schema-change/index.ts
3526
+ import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
3527
+ import {
3528
+ DataEvent as DataEvent5,
3529
+ getNodeScope as getNodeScope3
3530
+ } from "@flowgram.ai/editor";
3531
+ var listenRefSchemaChange = (cb) => [
3532
+ {
3533
+ event: DataEvent5.onValueInitOrChange,
3534
+ effect: (params) => {
3535
+ const { context, value } = params;
3536
+ if (value?.type !== "ref") {
3537
+ return () => null;
3538
+ }
3539
+ const disposable = getNodeScope3(context.node).available.trackByKeyPath(
3540
+ value?.content || [],
3541
+ (_type) => {
3542
+ cb({ ...params, schema: JsonSchemaUtils8.astToSchema(_type) });
3543
+ },
3544
+ {
3545
+ selector: (_v) => _v?.type
3546
+ }
3547
+ );
3548
+ return () => {
3549
+ disposable.dispose();
3550
+ };
3551
+ }
3552
+ }
3553
+ ];
3554
+
3284
3555
  // src/form-plugins/batch-outputs-plugin/index.ts
3285
3556
  import {
3286
- ASTFactory as ASTFactory5,
3287
- createEffectFromVariableProvider as createEffectFromVariableProvider4,
3557
+ ASTFactory as ASTFactory3,
3558
+ createEffectFromVariableProvider as createEffectFromVariableProvider3,
3288
3559
  defineFormPluginCreator,
3289
- getNodeForm as getNodeForm4,
3290
- getNodePrivateScope,
3291
- getNodeScope,
3560
+ getNodeForm as getNodeForm3,
3561
+ getNodePrivateScope as getNodePrivateScope2,
3562
+ getNodeScope as getNodeScope4,
3292
3563
  ScopeChainTransformService,
3293
3564
  FlowNodeScopeType
3294
3565
  } from "@flowgram.ai/editor";
3295
- var provideBatchOutputsEffect2 = createEffectFromVariableProvider4({
3566
+ var provideBatchOutputsEffect = createEffectFromVariableProvider3({
3296
3567
  parse: (value, ctx) => [
3297
- ASTFactory5.createVariableDeclaration({
3568
+ ASTFactory3.createVariableDeclaration({
3298
3569
  key: `${ctx.node.id}`,
3299
3570
  meta: {
3300
- title: getNodeForm4(ctx.node)?.getValueIn("title"),
3571
+ title: getNodeForm3(ctx.node)?.getValueIn("title"),
3301
3572
  icon: ctx.node.getNodeRegistry().info?.icon
3302
3573
  },
3303
- type: ASTFactory5.createObject({
3574
+ type: ASTFactory3.createObject({
3304
3575
  properties: Object.entries(value).map(
3305
- ([_key, value2]) => ASTFactory5.createProperty({
3576
+ ([_key, value2]) => ASTFactory3.createProperty({
3306
3577
  key: _key,
3307
- initializer: ASTFactory5.createWrapArrayExpression({
3308
- wrapFor: ASTFactory5.createKeyPathExpression({
3578
+ initializer: ASTFactory3.createWrapArrayExpression({
3579
+ wrapFor: ASTFactory3.createKeyPathExpression({
3309
3580
  keyPath: value2?.content || []
3310
3581
  })
3311
3582
  })
@@ -3319,7 +3590,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3319
3590
  name: "batch-outputs-plugin",
3320
3591
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
3321
3592
  mergeEffect({
3322
- [outputKey]: provideBatchOutputsEffect2
3593
+ [outputKey]: provideBatchOutputsEffect
3323
3594
  });
3324
3595
  },
3325
3596
  onInit(ctx, { outputKey }) {
@@ -3333,7 +3604,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3333
3604
  transformCovers: (covers, ctx2) => {
3334
3605
  const node = ctx2.scope.meta?.node;
3335
3606
  if (node?.parent?.flowNodeType === batchNodeType) {
3336
- return [...covers, getNodeScope(node.parent)];
3607
+ return [...covers, getNodeScope4(node.parent)];
3337
3608
  }
3338
3609
  return covers;
3339
3610
  },
@@ -3346,8 +3617,8 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3346
3617
  if (node?.flowNodeType === batchNodeType) {
3347
3618
  const childBlocks = node.blocks;
3348
3619
  return [
3349
- getNodePrivateScope(node),
3350
- ...childBlocks.map((_childBlock) => getNodeScope(_childBlock))
3620
+ getNodePrivateScope2(node),
3621
+ ...childBlocks.map((_childBlock) => getNodeScope4(_childBlock))
3351
3622
  ];
3352
3623
  }
3353
3624
  return scopes;
@@ -3355,38 +3626,239 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3355
3626
  });
3356
3627
  }
3357
3628
  });
3629
+
3630
+ // src/form-plugins/infer-inputs-plugin/index.ts
3631
+ import { get as get2, set as set2 } from "lodash";
3632
+ import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
3633
+ import {
3634
+ defineFormPluginCreator as defineFormPluginCreator2,
3635
+ getNodePrivateScope as getNodePrivateScope3,
3636
+ getNodeScope as getNodeScope5
3637
+ } from "@flowgram.ai/editor";
3638
+ var createInferInputsPlugin = defineFormPluginCreator2({
3639
+ onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3640
+ if (!sourceKey || !targetKey) {
3641
+ return;
3642
+ }
3643
+ addFormatOnSubmit((formData, ctx) => {
3644
+ set2(
3645
+ formData,
3646
+ targetKey,
3647
+ infer(
3648
+ get2(formData, sourceKey),
3649
+ scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
3650
+ )
3651
+ );
3652
+ return formData;
3653
+ });
3654
+ }
3655
+ });
3656
+ function isRef2(value) {
3657
+ return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3658
+ }
3659
+ function isTemplate2(value) {
3660
+ return value?.type === "template" && typeof value?.content === "string";
3661
+ }
3662
+ function isConstant(value) {
3663
+ return value?.type === "constant" && typeof value?.content !== "undefined";
3664
+ }
3665
+ var infer = (values, scope) => {
3666
+ if (typeof values === "object") {
3667
+ if (isConstant(values)) {
3668
+ if (values?.schema) {
3669
+ return values.schema;
3670
+ }
3671
+ if (typeof values.content === "string") {
3672
+ return {
3673
+ type: "string"
3674
+ };
3675
+ }
3676
+ if (typeof values.content === "number") {
3677
+ return {
3678
+ type: "number"
3679
+ };
3680
+ }
3681
+ if (typeof values.content === "boolean") {
3682
+ return {
3683
+ type: "boolean"
3684
+ };
3685
+ }
3686
+ }
3687
+ if (isRef2(values)) {
3688
+ const variable = scope.available.getByKeyPath(values?.content);
3689
+ const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
3690
+ return schema;
3691
+ }
3692
+ if (isTemplate2(values)) {
3693
+ return {
3694
+ type: "string"
3695
+ };
3696
+ }
3697
+ return {
3698
+ type: "object",
3699
+ properties: Object.keys(values).reduce((acc, key) => {
3700
+ const schema = infer(values[key], scope);
3701
+ if (schema) {
3702
+ acc[key] = schema;
3703
+ }
3704
+ return acc;
3705
+ }, {})
3706
+ };
3707
+ }
3708
+ };
3709
+
3710
+ // src/form-plugins/infer-assign-plugin/index.ts
3711
+ import { set as set3, uniqBy } from "lodash";
3712
+ import { JsonSchemaUtils as JsonSchemaUtils10 } from "@flowgram.ai/json-schema";
3713
+ import {
3714
+ ASTFactory as ASTFactory4,
3715
+ createEffectFromVariableProvider as createEffectFromVariableProvider4,
3716
+ defineFormPluginCreator as defineFormPluginCreator3,
3717
+ getNodeForm as getNodeForm4,
3718
+ getNodeScope as getNodeScope6
3719
+ } from "@flowgram.ai/editor";
3720
+ var createInferAssignPlugin = defineFormPluginCreator3({
3721
+ onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
3722
+ if (!assignKey || !outputKey) {
3723
+ return;
3724
+ }
3725
+ mergeEffect({
3726
+ [assignKey]: createEffectFromVariableProvider4({
3727
+ parse: (value, ctx) => {
3728
+ const declareRows = uniqBy(
3729
+ value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
3730
+ "left"
3731
+ );
3732
+ return [
3733
+ ASTFactory4.createVariableDeclaration({
3734
+ key: `${ctx.node.id}`,
3735
+ meta: {
3736
+ title: getNodeForm4(ctx.node)?.getValueIn("title"),
3737
+ icon: ctx.node.getNodeRegistry().info?.icon
3738
+ },
3739
+ type: ASTFactory4.createObject({
3740
+ properties: declareRows.map(
3741
+ (_v) => ASTFactory4.createProperty({
3742
+ key: _v.left,
3743
+ type: _v.right?.type === "constant" ? JsonSchemaUtils10.schemaToAST(_v.right?.schema || {}) : void 0,
3744
+ initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
3745
+ keyPath: _v.right?.content || []
3746
+ }) : {}
3747
+ })
3748
+ )
3749
+ })
3750
+ })
3751
+ ];
3752
+ }
3753
+ })
3754
+ });
3755
+ addFormatOnSubmit((formData, ctx) => {
3756
+ set3(
3757
+ formData,
3758
+ outputKey,
3759
+ JsonSchemaUtils10.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
3760
+ );
3761
+ return formData;
3762
+ });
3763
+ }
3764
+ });
3765
+
3766
+ // src/validate/validate-flow-value/index.tsx
3767
+ import { isNil, uniq as uniq2 } from "lodash";
3768
+ import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
3769
+ function validateFlowValue(value, ctx) {
3770
+ const { node, required, errorMessages } = ctx;
3771
+ const {
3772
+ required: requiredMessage = "Field is required",
3773
+ unknownVariable: unknownVariableMessage = "Unknown Variable"
3774
+ } = errorMessages || {};
3775
+ if (required && (isNil(value) || isNil(value?.content) || value?.content === "")) {
3776
+ return {
3777
+ level: FeedbackLevel.Error,
3778
+ message: requiredMessage
3779
+ };
3780
+ }
3781
+ if (value?.type === "ref") {
3782
+ const variable = getNodeScope7(node).available.getByKeyPath(value?.content || []);
3783
+ if (!variable) {
3784
+ return {
3785
+ level: FeedbackLevel.Error,
3786
+ message: unknownVariableMessage
3787
+ };
3788
+ }
3789
+ }
3790
+ if (value?.type === "template") {
3791
+ const allRefs = getTemplateKeyPaths2(value);
3792
+ for (const ref of allRefs) {
3793
+ const variable = getNodeScope7(node).available.getByKeyPath(ref);
3794
+ if (!variable) {
3795
+ return {
3796
+ level: FeedbackLevel.Error,
3797
+ message: unknownVariableMessage
3798
+ };
3799
+ }
3800
+ }
3801
+ }
3802
+ return void 0;
3803
+ }
3804
+ function getTemplateKeyPaths2(value) {
3805
+ const keyPathReg = /{{(.*?)}}/g;
3806
+ return uniq2(value.content?.match(keyPathReg) || []).map(
3807
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
3808
+ );
3809
+ }
3358
3810
  export {
3359
- ArrayIcons,
3811
+ AssignRow,
3812
+ AssignRows,
3360
3813
  BatchOutputs,
3361
3814
  BatchVariableSelector,
3362
3815
  CodeEditor,
3816
+ CodeEditorMini,
3363
3817
  ConditionRow,
3364
3818
  ConstantInput,
3819
+ DisplayFlowValue,
3820
+ DisplayInputsValues,
3821
+ DisplayOutputs,
3822
+ DisplaySchemaTag,
3823
+ DisplaySchemaTree,
3365
3824
  DynamicValueInput,
3825
+ InjectDynamicValueInput,
3826
+ InjectTypeSelector,
3827
+ InjectVariableSelector,
3828
+ InputsValues,
3366
3829
  JsonEditorWithVariables,
3367
3830
  JsonSchemaEditor,
3831
+ JsonSchemaTypePresetProvider,
3368
3832
  JsonSchemaUtils,
3369
3833
  PromptEditor,
3370
3834
  PromptEditorWithInputs,
3371
3835
  PromptEditorWithVariables,
3372
3836
  TypeSelector,
3373
3837
  VariableSelector,
3374
- VariableTypeIcons,
3375
3838
  autoRenameRefEffect,
3376
3839
  createBatchOutputsFormPlugin,
3840
+ createDisableDeclarationPlugin,
3841
+ createInferAssignPlugin,
3842
+ createInferInputsPlugin,
3843
+ createInjectMaterial,
3844
+ createTypePresetPlugin,
3377
3845
  formatLegacyRefOnInit,
3378
3846
  formatLegacyRefOnSubmit,
3379
3847
  formatLegacyRefToNewRef,
3380
3848
  formatNewRefToLegacyRef,
3381
- getSchemaIcon,
3382
3849
  getTypeSelectValue,
3383
3850
  isLegacyFlowRefValueSchema,
3384
3851
  isNewFlowRefValueSchema,
3852
+ listenRefSchemaChange,
3853
+ listenRefValueChange,
3385
3854
  parseTypeSelectValue,
3386
3855
  provideBatchInputEffect,
3387
3856
  provideBatchOutputsEffect,
3388
3857
  provideJsonSchemaOutputs,
3389
3858
  syncVariableTitle,
3390
- useVariableTree
3859
+ useTypeManager,
3860
+ useVariableTree,
3861
+ validateFlowValue,
3862
+ validateWhenVariableSync
3391
3863
  };
3392
3864
  //# sourceMappingURL=index.js.map