@powerduck/schema-designer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +217 -0
  2. package/dist/InlineSchemaEditor-BssSx3SI.d.ts +6 -0
  3. package/dist/InlineSchemaEditor-Bua-lDhE.d.cts +6 -0
  4. package/dist/chunk-2XUQB6BQ.js +1896 -0
  5. package/dist/chunk-4H3LXOL4.cjs +1900 -0
  6. package/dist/chunk-7LG4MVMD.cjs +2 -0
  7. package/dist/chunk-BXFABOMJ.js +1475 -0
  8. package/dist/chunk-FTALJIVZ.js +1 -0
  9. package/dist/chunk-GTZH37JS.cjs +1120 -0
  10. package/dist/chunk-GWHDTTQK.js +1437 -0
  11. package/dist/chunk-GXXD6ITE.cjs +1477 -0
  12. package/dist/chunk-HI5FBHCO.js +1057 -0
  13. package/dist/chunk-KX3LFFOV.js +88 -0
  14. package/dist/chunk-MADPN2PJ.js +185 -0
  15. package/dist/chunk-NOUORNCI.cjs +1452 -0
  16. package/dist/chunk-O6PTRJQ5.js +1195 -0
  17. package/dist/chunk-OBHJC3I2.cjs +2 -0
  18. package/dist/chunk-OOSNM45O.cjs +264 -0
  19. package/dist/chunk-P5B3HSPY.js +244 -0
  20. package/dist/chunk-PBE36BVA.js +1 -0
  21. package/dist/chunk-PVEYKCM6.js +1 -0
  22. package/dist/chunk-QZADGAP3.cjs +1218 -0
  23. package/dist/chunk-S7GNTGEE.js +1 -0
  24. package/dist/chunk-SMBDRWV2.cjs +2 -0
  25. package/dist/chunk-THYDOHOP.cjs +2 -0
  26. package/dist/chunk-WRHWOMZQ.cjs +190 -0
  27. package/dist/chunk-YNKP5JJA.cjs +32 -0
  28. package/dist/chunk-YWDKCX6N.cjs +91 -0
  29. package/dist/chunk-ZHNYNFGL.js +28 -0
  30. package/dist/compat/inline.cjs +137 -0
  31. package/dist/compat/inline.css +275 -0
  32. package/dist/compat/inline.d.cts +6 -0
  33. package/dist/compat/inline.d.ts +6 -0
  34. package/dist/compat/inline.js +4 -0
  35. package/dist/compat/parameters.cjs +90 -0
  36. package/dist/compat/parameters.css +997 -0
  37. package/dist/compat/parameters.d.cts +70 -0
  38. package/dist/compat/parameters.d.ts +70 -0
  39. package/dist/compat/parameters.js +9 -0
  40. package/dist/compat/tree.cjs +142 -0
  41. package/dist/compat/tree.css +1069 -0
  42. package/dist/compat/tree.d.cts +4 -0
  43. package/dist/compat/tree.d.ts +4 -0
  44. package/dist/compat/tree.js +5 -0
  45. package/dist/compat/variable-editor.cjs +82 -0
  46. package/dist/compat/variable-editor.d.cts +68 -0
  47. package/dist/compat/variable-editor.d.ts +68 -0
  48. package/dist/compat/variable-editor.js +1 -0
  49. package/dist/core/index.cjs +197 -0
  50. package/dist/core/index.d.cts +21 -0
  51. package/dist/core/index.d.ts +21 -0
  52. package/dist/core/index.js +4 -0
  53. package/dist/index.cjs +35 -0
  54. package/dist/index.css +1791 -0
  55. package/dist/index.d.cts +9 -0
  56. package/dist/index.d.ts +9 -0
  57. package/dist/index.js +10 -0
  58. package/dist/parameterValue-2pL9n-3q.d.ts +8 -0
  59. package/dist/parameterValue-Cky9Lnd3.d.cts +8 -0
  60. package/dist/react/index.cjs +35 -0
  61. package/dist/react/index.css +1791 -0
  62. package/dist/react/index.d.cts +9 -0
  63. package/dist/react/index.d.ts +9 -0
  64. package/dist/react/index.js +10 -0
  65. package/dist/react/inlineSchemaEditor/index.cjs +97 -0
  66. package/dist/react/inlineSchemaEditor/index.css +275 -0
  67. package/dist/react/inlineSchemaEditor/index.d.cts +6 -0
  68. package/dist/react/inlineSchemaEditor/index.d.ts +6 -0
  69. package/dist/react/inlineSchemaEditor/index.js +4 -0
  70. package/dist/react/parametersTable/index.cjs +22 -0
  71. package/dist/react/parametersTable/index.css +997 -0
  72. package/dist/react/parametersTable/index.d.cts +7 -0
  73. package/dist/react/parametersTable/index.d.ts +7 -0
  74. package/dist/react/parametersTable/index.js +9 -0
  75. package/dist/react/parametersTable/libs/generateValue.cjs +558 -0
  76. package/dist/react/parametersTable/libs/generateValue.d.cts +17 -0
  77. package/dist/react/parametersTable/libs/generateValue.d.ts +17 -0
  78. package/dist/react/parametersTable/libs/generateValue.js +551 -0
  79. package/dist/react/schemaTreeEditor/index.cjs +18 -0
  80. package/dist/react/schemaTreeEditor/index.css +1069 -0
  81. package/dist/react/schemaTreeEditor/index.d.cts +7 -0
  82. package/dist/react/schemaTreeEditor/index.d.ts +7 -0
  83. package/dist/react/schemaTreeEditor/index.js +5 -0
  84. package/dist/react/variableTextEditor/index.cjs +11 -0
  85. package/dist/react/variableTextEditor/index.css +306 -0
  86. package/dist/react/variableTextEditor/index.d.cts +6 -0
  87. package/dist/react/variableTextEditor/index.d.ts +6 -0
  88. package/dist/react/variableTextEditor/index.js +2 -0
  89. package/dist/schema-CKAPsYeW.d.cts +41 -0
  90. package/dist/schema-o7OJRaJ8.d.ts +41 -0
  91. package/dist/styles.css +1791 -0
  92. package/dist/tree-D06Xa6_N.d.ts +95 -0
  93. package/dist/tree-Dq1Rk-CF.d.cts +95 -0
  94. package/dist/types-B27Dw9do.d.cts +163 -0
  95. package/dist/types-B27Dw9do.d.ts +163 -0
  96. package/dist/types-Bk9rzr6l.d.cts +48 -0
  97. package/dist/types-D2jEaM9Z.d.cts +145 -0
  98. package/dist/types-D2jEaM9Z.d.ts +145 -0
  99. package/dist/types-xAihO_KW.d.ts +48 -0
  100. package/dist/variableTextEditor.types-ClzvARvK.d.cts +49 -0
  101. package/dist/variableTextEditor.types-ClzvARvK.d.ts +49 -0
  102. package/package.json +130 -0
@@ -0,0 +1,1900 @@
1
+ 'use strict';
2
+
3
+ var chunkGTZH37JS_cjs = require('./chunk-GTZH37JS.cjs');
4
+ var react = require('@chakra-ui/react');
5
+ var react$1 = require('react');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var vsc = require('react-icons/vsc');
8
+ var lu = require('react-icons/lu');
9
+
10
+ function useSchemaEditor(schema, externalType) {
11
+ return react$1.useMemo(
12
+ () => ({
13
+ schema: chunkGTZH37JS_cjs.toSchemaRecord(schema),
14
+ type: externalType ?? chunkGTZH37JS_cjs.getSchemaType(schema)
15
+ }),
16
+ [schema, externalType]
17
+ );
18
+ }
19
+ function useSchemaPatch(schema, update) {
20
+ const patch = react$1.useCallback(
21
+ (next) => update(next),
22
+ [update]
23
+ );
24
+ const replace = react$1.useCallback(
25
+ (next) => {
26
+ const current = schema ?? {};
27
+ const patchValue = { ...next };
28
+ Object.keys(current).forEach((key) => {
29
+ if (!Object.hasOwn(next, key))
30
+ Object.defineProperty(patchValue, key, {
31
+ value: void 0,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ });
36
+ });
37
+ update(patchValue);
38
+ },
39
+ [schema, update]
40
+ );
41
+ return { patch, replace };
42
+ }
43
+ var OPTIONS = react.createListCollection({
44
+ items: [
45
+ { value: "any", label: "Any" },
46
+ { value: "string", label: "String" },
47
+ { value: "number", label: "Number" },
48
+ { value: "integer", label: "Integer" },
49
+ { value: "boolean", label: "Boolean" },
50
+ { value: "array", label: "Array" },
51
+ { value: "object", label: "Object" },
52
+ { value: "null", label: "Null" }
53
+ ]
54
+ });
55
+ function SchemaTypeSelector(props) {
56
+ return /* @__PURE__ */ jsxRuntime.jsxs(
57
+ react.Select.Root,
58
+ {
59
+ collection: OPTIONS,
60
+ size: "sm",
61
+ width: "132px",
62
+ value: [props.value],
63
+ disabled: props.disabled,
64
+ onValueChange: (e) => props.onChange(e.value?.[0] ?? "any"),
65
+ children: [
66
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.HiddenSelect, {}),
67
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Control, { children: [
68
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.ValueText, { placeholder: "Select type" }) }),
69
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.IndicatorGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Indicator, {}) })
70
+ ] }),
71
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(
72
+ react.Select.Content,
73
+ {
74
+ className: "pdDesignerSelectMenu",
75
+ background: "var(--color-surface)",
76
+ color: "var(--color-text-primary)",
77
+ borderColor: "var(--color-border-default)",
78
+ fontSize: "12px",
79
+ children: OPTIONS.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Item, { item, children: [
80
+ item.label,
81
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.ItemIndicator, {})
82
+ ] }, item.value))
83
+ }
84
+ ) }) })
85
+ ]
86
+ }
87
+ );
88
+ }
89
+ var SchemaHeader = react$1.memo(function SchemaHeader2(props) {
90
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", className: "pdDesignerSchemaSection", children: [
91
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", gap: "2", align: "start", flexWrap: "wrap", children: [
92
+ !props.hideName && /* @__PURE__ */ jsxRuntime.jsx(react.VStack, { flex: "1", children: !props.hideName ? /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Field name" }),
94
+ /* @__PURE__ */ jsxRuntime.jsx(
95
+ react.Input,
96
+ {
97
+ size: "sm",
98
+ value: props.name ?? "",
99
+ disabled: props.disabled,
100
+ placeholder: "customerEmail",
101
+ onChange: (e) => props.onNameChange?.(e.target.value)
102
+ }
103
+ )
104
+ ] }) : null }),
105
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: "4", flexShrink: 0, align: "end", children: [
106
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
107
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Type" }),
108
+ /* @__PURE__ */ jsxRuntime.jsx(
109
+ SchemaTypeSelector,
110
+ {
111
+ value: props.type,
112
+ disabled: props.disabled,
113
+ onChange: props.onTypeChange
114
+ }
115
+ )
116
+ ] }),
117
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { gap: "2", align: "center", flexWrap: "wrap", children: props.onRequiredChange ? /* @__PURE__ */ jsxRuntime.jsxs(
118
+ react.Switch.Root,
119
+ {
120
+ checked: !!props.required,
121
+ disabled: props.disabled,
122
+ onCheckedChange: (e) => props.onRequiredChange?.(!!e.checked),
123
+ children: [
124
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
125
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
126
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Required" })
127
+ ]
128
+ }
129
+ ) : null })
130
+ ] })
131
+ ] }),
132
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
133
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Description" }),
134
+ /* @__PURE__ */ jsxRuntime.jsx(
135
+ react.Input,
136
+ {
137
+ size: "sm",
138
+ value: props.description ?? "",
139
+ disabled: props.disabled,
140
+ placeholder: "Helpful summary for API consumers",
141
+ onChange: (e) => props.onDescriptionChange?.(e.target.value)
142
+ }
143
+ )
144
+ ] })
145
+ ] });
146
+ });
147
+ function SchemaReferenceEditor(props) {
148
+ const record = chunkGTZH37JS_cjs.toSchemaRecord(props.schema);
149
+ const ref = typeof record.$ref === "string" ? record.$ref : "";
150
+ const options = chunkGTZH37JS_cjs.getReferenceOptions(props.fullSchema);
151
+ if (ref && !options.includes(ref)) options.unshift(ref);
152
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", className: "pdDesignerSchemaSection", children: [
153
+ /* @__PURE__ */ jsxRuntime.jsx(react.HStack, { justify: "space-between", align: "center", flexWrap: "wrap", children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: "2", children: [
154
+ ref ? /* @__PURE__ */ jsxRuntime.jsx(
155
+ react.Button,
156
+ {
157
+ size: "xs",
158
+ variant: "ghost",
159
+ onClick: props.onClearReference,
160
+ disabled: props.disabled,
161
+ children: "Use inline schema"
162
+ }
163
+ ) : null,
164
+ props.hasDraft && !ref ? /* @__PURE__ */ jsxRuntime.jsx(
165
+ react.Button,
166
+ {
167
+ size: "xs",
168
+ variant: "ghost",
169
+ onClick: props.onRestoreDraft,
170
+ disabled: props.disabled,
171
+ children: "Restore draft"
172
+ }
173
+ ) : null
174
+ ] }) }),
175
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
176
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "$ref" }),
177
+ /* @__PURE__ */ jsxRuntime.jsxs(react.NativeSelect.Root, { size: "sm", disabled: props.disabled, children: [
178
+ /* @__PURE__ */ jsxRuntime.jsxs(
179
+ react.NativeSelect.Field,
180
+ {
181
+ value: ref,
182
+ onChange: (event) => {
183
+ const value = event.target.value;
184
+ props.update({ $ref: value || void 0 });
185
+ },
186
+ children: [
187
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "No reference" }),
188
+ options.map((value) => /* @__PURE__ */ jsxRuntime.jsx("option", { value, children: value }, value))
189
+ ]
190
+ }
191
+ ),
192
+ /* @__PURE__ */ jsxRuntime.jsx(react.NativeSelect.Indicator, {})
193
+ ] })
194
+ ] })
195
+ ] });
196
+ }
197
+ function SchemaValueEditor(props) {
198
+ const externalText = chunkGTZH37JS_cjs.stringifySchemaValue(props.value);
199
+ const [draft, setDraft] = react$1.useState(externalText);
200
+ react$1.useEffect(() => {
201
+ setDraft(externalText);
202
+ }, [externalText, props.type]);
203
+ const booleanCollection = react$1.useMemo(
204
+ () => react.createListCollection({
205
+ items: [
206
+ { label: "Unset", value: "" },
207
+ { label: "True", value: "true" },
208
+ { label: "False", value: "false" }
209
+ ]
210
+ }),
211
+ []
212
+ );
213
+ const change = (text) => {
214
+ setDraft(text);
215
+ props.onTextChange?.(text);
216
+ if (chunkGTZH37JS_cjs.canParseSchemaValue(text, props.type)) {
217
+ props.onChange(chunkGTZH37JS_cjs.parseSchemaValue(text, props.type));
218
+ }
219
+ };
220
+ if (props.type === "boolean") {
221
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { invalid: !!props.error, children: [
222
+ /* @__PURE__ */ jsxRuntime.jsxs(
223
+ react.Select.Root,
224
+ {
225
+ collection: booleanCollection,
226
+ size: "sm",
227
+ disabled: props.disabled,
228
+ value: [String(props.value ?? "")],
229
+ onValueChange: (e) => change(e.value?.[0] ?? ""),
230
+ children: [
231
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.HiddenSelect, {}),
232
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Control, { children: [
233
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.ValueText, { placeholder: "Unset" }) }),
234
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.IndicatorGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Indicator, {}) })
235
+ ] }),
236
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Content, { className: "pdDesignerSelectMenu", children: booleanCollection.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Item, { item, children: [
237
+ item.label,
238
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.ItemIndicator, {})
239
+ ] }, item.value)) }) }) })
240
+ ]
241
+ }
242
+ ),
243
+ props.error && /* @__PURE__ */ jsxRuntime.jsx(react.Field.ErrorText, { children: props.error })
244
+ ] });
245
+ }
246
+ const multiline = ["array", "object", "any"].includes(props.type);
247
+ const value = draft;
248
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { invalid: !!props.error, children: [
249
+ multiline ? /* @__PURE__ */ jsxRuntime.jsx(
250
+ react.Textarea,
251
+ {
252
+ value,
253
+ disabled: props.disabled,
254
+ placeholder: props.placeholder,
255
+ minH: "96px",
256
+ fontFamily: "mono",
257
+ fontSize: "xs",
258
+ onChange: (e) => change(e.target.value)
259
+ }
260
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
261
+ react.Input,
262
+ {
263
+ size: "sm",
264
+ value,
265
+ disabled: props.disabled,
266
+ placeholder: props.placeholder,
267
+ onChange: (e) => change(e.target.value)
268
+ }
269
+ ),
270
+ props.error && /* @__PURE__ */ jsxRuntime.jsx(react.Field.ErrorText, { children: props.error })
271
+ ] });
272
+ }
273
+ function readRecord(value) {
274
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
275
+ }
276
+ function getValueError(type, text) {
277
+ if (!text.trim()) return "";
278
+ if (type === "boolean")
279
+ return text === "true" || text === "false" ? "" : "Pick true or false.";
280
+ if (type === "integer")
281
+ return Number.isInteger(Number(text)) ? "" : "Enter a valid integer.";
282
+ if (type === "number")
283
+ return Number.isFinite(Number(text)) ? "" : "Enter a valid number.";
284
+ if (type === "null") return text.trim() === "null" ? "" : 'Use "null".';
285
+ if (["array", "object"].includes(type))
286
+ return chunkGTZH37JS_cjs.canParseSchemaValue(text, type) ? "" : "Enter valid JSON.";
287
+ return "";
288
+ }
289
+ var SchemaAdvancedEditor = react$1.memo(function SchemaAdvancedEditor2(props) {
290
+ const s = props.schema;
291
+ const schemaType = chunkGTZH37JS_cjs.getSchemaType(s);
292
+ const examples = react$1.useMemo(
293
+ () => Array.isArray(s.examples) ? [...s.examples] : [],
294
+ [s.examples]
295
+ );
296
+ const [exampleDrafts, setExampleDrafts] = react$1.useState(
297
+ () => examples.map((item) => chunkGTZH37JS_cjs.stringifySchemaValue(item))
298
+ );
299
+ const [exampleDraft, setExampleDraft] = react$1.useState(
300
+ () => chunkGTZH37JS_cjs.stringifySchemaValue(s.example)
301
+ );
302
+ const [defaultDraft, setDefaultDraft] = react$1.useState(
303
+ () => chunkGTZH37JS_cjs.stringifySchemaValue(s.default)
304
+ );
305
+ const exampleError = getValueError(schemaType, exampleDraft);
306
+ const defaultError = getValueError(schemaType, defaultDraft);
307
+ react$1.useEffect(() => {
308
+ setExampleDrafts(examples.map((item) => chunkGTZH37JS_cjs.stringifySchemaValue(item)));
309
+ }, [examples]);
310
+ react$1.useEffect(() => {
311
+ setExampleDraft(chunkGTZH37JS_cjs.stringifySchemaValue(s.example));
312
+ }, [s.example]);
313
+ react$1.useEffect(() => {
314
+ setDefaultDraft(chunkGTZH37JS_cjs.stringifySchemaValue(s.default));
315
+ }, [s.default]);
316
+ const updateExamples = (next, drafts) => {
317
+ if (drafts) setExampleDrafts(drafts);
318
+ props.update({ examples: next.length ? next : void 0 });
319
+ };
320
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "4", className: "pdDesignerSchemaSection", children: [
321
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "600", children: "Advanced options" }),
322
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: [
323
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
324
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Title" }),
325
+ /* @__PURE__ */ jsxRuntime.jsx(
326
+ react.Input,
327
+ {
328
+ size: "sm",
329
+ value: typeof s.title === "string" ? s.title : "",
330
+ disabled: props.disabled,
331
+ onChange: (e) => props.update({ title: e.target.value || void 0 })
332
+ }
333
+ )
334
+ ] }),
335
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
336
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Const" }),
337
+ /* @__PURE__ */ jsxRuntime.jsx(
338
+ react.Input,
339
+ {
340
+ size: "sm",
341
+ value: typeof s.const === "string" ? s.const : s.const === void 0 ? "" : JSON.stringify(s.const),
342
+ disabled: props.disabled,
343
+ onChange: (e) => {
344
+ const raw = e.target.value;
345
+ if (!raw) props.update({ const: void 0 });
346
+ else {
347
+ try {
348
+ props.update({ const: JSON.parse(raw) });
349
+ } catch {
350
+ props.update({ const: raw });
351
+ }
352
+ }
353
+ }
354
+ }
355
+ )
356
+ ] })
357
+ ] }),
358
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
359
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Description" }),
360
+ /* @__PURE__ */ jsxRuntime.jsx(
361
+ react.Textarea,
362
+ {
363
+ size: "sm",
364
+ minH: "80px",
365
+ value: typeof s.description === "string" ? s.description : "",
366
+ disabled: props.disabled,
367
+ onChange: (e) => props.update({ description: e.target.value || void 0 })
368
+ }
369
+ )
370
+ ] }),
371
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: [
372
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
373
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Example" }),
374
+ /* @__PURE__ */ jsxRuntime.jsx(
375
+ SchemaValueEditor,
376
+ {
377
+ value: s.example,
378
+ type: schemaType,
379
+ disabled: props.disabled,
380
+ placeholder: schemaType === "object" || schemaType === "array" ? "Enter valid JSON" : void 0,
381
+ error: exampleError,
382
+ onTextChange: setExampleDraft,
383
+ onChange: (value) => props.update({ example: value })
384
+ }
385
+ )
386
+ ] }),
387
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
388
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Default" }),
389
+ /* @__PURE__ */ jsxRuntime.jsx(
390
+ SchemaValueEditor,
391
+ {
392
+ value: s.default,
393
+ type: schemaType,
394
+ disabled: props.disabled,
395
+ error: defaultError,
396
+ onTextChange: setDefaultDraft,
397
+ onChange: (value) => props.update({ default: value })
398
+ }
399
+ )
400
+ ] })
401
+ ] }),
402
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", children: [
403
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", children: [
404
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "600", children: "Examples" }),
405
+ /* @__PURE__ */ jsxRuntime.jsx(
406
+ react.Button,
407
+ {
408
+ size: "xs",
409
+ variant: "outline",
410
+ disabled: props.disabled,
411
+ onClick: () => {
412
+ const seed = schemaType === "boolean" ? true : schemaType === "integer" || schemaType === "number" ? 0 : schemaType === "null" ? null : schemaType === "array" ? [] : schemaType === "object" ? {} : "";
413
+ const next = [...examples, seed];
414
+ updateExamples(
415
+ next,
416
+ next.map((item) => chunkGTZH37JS_cjs.stringifySchemaValue(item))
417
+ );
418
+ },
419
+ children: "Add example"
420
+ }
421
+ )
422
+ ] }),
423
+ examples.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: "No examples." }) : null,
424
+ examples.map((value, index) => {
425
+ const text = exampleDrafts[index] ?? chunkGTZH37JS_cjs.stringifySchemaValue(value);
426
+ const error = getValueError(schemaType, text);
427
+ return /* @__PURE__ */ jsxRuntime.jsx(
428
+ react.Box,
429
+ {
430
+ p: "3",
431
+ border: "1px solid var(--color-border-subtle)",
432
+ borderRadius: "var(--radius-lg)",
433
+ bg: "var(--color-surface-subtle)",
434
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { align: "start", gap: "2", children: [
435
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { invalid: !!error, flex: "1", children: [
436
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Label, { children: [
437
+ "Example ",
438
+ index + 1
439
+ ] }),
440
+ /* @__PURE__ */ jsxRuntime.jsx(
441
+ react.Input,
442
+ {
443
+ size: "sm",
444
+ value: text,
445
+ disabled: props.disabled,
446
+ onChange: (e) => {
447
+ const nextDrafts = [...exampleDrafts];
448
+ nextDrafts[index] = e.target.value;
449
+ setExampleDrafts(nextDrafts);
450
+ if (chunkGTZH37JS_cjs.canParseSchemaValue(e.target.value, schemaType)) {
451
+ const next = [...examples];
452
+ next[index] = chunkGTZH37JS_cjs.parseSchemaValue(
453
+ e.target.value,
454
+ schemaType
455
+ );
456
+ updateExamples(next);
457
+ }
458
+ }
459
+ }
460
+ ),
461
+ error ? /* @__PURE__ */ jsxRuntime.jsx(react.Field.ErrorText, { children: error }) : null
462
+ ] }),
463
+ /* @__PURE__ */ jsxRuntime.jsx(
464
+ react.IconButton,
465
+ {
466
+ mt: "6",
467
+ size: "xs",
468
+ variant: "plain",
469
+ "aria-label": "Remove example",
470
+ disabled: props.disabled,
471
+ onClick: () => {
472
+ const next = [...examples];
473
+ next.splice(index, 1);
474
+ const nextDrafts = [...exampleDrafts];
475
+ nextDrafts.splice(index, 1);
476
+ updateExamples(next, nextDrafts);
477
+ },
478
+ children: "\xD7"
479
+ }
480
+ )
481
+ ] })
482
+ },
483
+ index
484
+ );
485
+ })
486
+ ] }),
487
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Collapsible.Root, { defaultOpen: false, children: [
488
+ /* @__PURE__ */ jsxRuntime.jsx(react.Collapsible.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Button, { size: "xs", variant: "ghost", alignSelf: "flex-start", children: "Show less common options" }) }),
489
+ /* @__PURE__ */ jsxRuntime.jsx(react.Collapsible.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "4", pt: "3", children: [
490
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: [
491
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
492
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Content encoding" }),
493
+ /* @__PURE__ */ jsxRuntime.jsx(
494
+ react.Input,
495
+ {
496
+ size: "sm",
497
+ value: typeof s.contentEncoding === "string" ? s.contentEncoding : "",
498
+ disabled: props.disabled,
499
+ onChange: (e) => props.update({
500
+ contentEncoding: e.target.value || void 0
501
+ })
502
+ }
503
+ )
504
+ ] }),
505
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
506
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Content media type" }),
507
+ /* @__PURE__ */ jsxRuntime.jsx(
508
+ react.Input,
509
+ {
510
+ size: "sm",
511
+ value: typeof s.contentMediaType === "string" ? s.contentMediaType : "",
512
+ disabled: props.disabled,
513
+ onChange: (e) => props.update({
514
+ contentMediaType: e.target.value || void 0
515
+ })
516
+ }
517
+ )
518
+ ] })
519
+ ] }),
520
+ /* @__PURE__ */ jsxRuntime.jsxs(
521
+ react.Switch.Root,
522
+ {
523
+ checked: s.deprecated === true,
524
+ disabled: props.disabled,
525
+ onCheckedChange: (e) => props.update({ deprecated: e.checked ? true : void 0 }),
526
+ children: [
527
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
528
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
529
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Deprecated" })
530
+ ]
531
+ }
532
+ ),
533
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
534
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Write only" }),
535
+ /* @__PURE__ */ jsxRuntime.jsxs(
536
+ react.Switch.Root,
537
+ {
538
+ checked: s.writeOnly === true,
539
+ disabled: props.disabled,
540
+ onCheckedChange: (e) => props.update({ writeOnly: e.checked ? true : void 0 }),
541
+ children: [
542
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
543
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
544
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Hidden from responses" })
545
+ ]
546
+ }
547
+ )
548
+ ] }),
549
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
550
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Read only" }),
551
+ /* @__PURE__ */ jsxRuntime.jsxs(
552
+ react.Switch.Root,
553
+ {
554
+ checked: s.readOnly === true,
555
+ disabled: props.disabled,
556
+ onCheckedChange: (e) => props.update({ readOnly: e.checked ? true : void 0 }),
557
+ children: [
558
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
559
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
560
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Hidden from requests" })
561
+ ]
562
+ }
563
+ )
564
+ ] }),
565
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
566
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "External docs URL" }),
567
+ /* @__PURE__ */ jsxRuntime.jsx(
568
+ react.Input,
569
+ {
570
+ size: "sm",
571
+ value: typeof readRecord(s.externalDocs).url === "string" ? String(readRecord(s.externalDocs).url) : "",
572
+ disabled: props.disabled,
573
+ onChange: (e) => props.update({
574
+ externalDocs: e.target.value ? { ...readRecord(s.externalDocs), url: e.target.value } : void 0
575
+ })
576
+ }
577
+ )
578
+ ] })
579
+ ] }) })
580
+ ] })
581
+ ] });
582
+ });
583
+ function validateEnumText(type, text) {
584
+ if (!text.trim())
585
+ return type === "string" ? "" : "Enter a value or remove this entry.";
586
+ if (type === "integer") {
587
+ return Number.isInteger(Number(text)) ? "" : "Enter a valid integer.";
588
+ }
589
+ if (type === "number") {
590
+ return Number.isFinite(Number(text)) ? "" : "Enter a valid number.";
591
+ }
592
+ if (type === "boolean") {
593
+ return text === "true" || text === "false" ? "" : "Use true or false.";
594
+ }
595
+ if (type === "null") {
596
+ return text.trim() === "null" ? "" : 'Use "null".';
597
+ }
598
+ if (["array", "object", "any"].includes(type)) {
599
+ return chunkGTZH37JS_cjs.canParseSchemaValue(text, type) ? "" : "Enter valid JSON.";
600
+ }
601
+ return "";
602
+ }
603
+ var SchemaEnumEditor = react$1.memo(function SchemaEnumEditor2(props) {
604
+ const values = react$1.useMemo(
605
+ () => chunkGTZH37JS_cjs.getEnumValues(props.schema),
606
+ [props.schema.enum]
607
+ );
608
+ const [drafts, setDrafts] = react$1.useState(
609
+ () => values.map((value) => chunkGTZH37JS_cjs.stringifySchemaValue(value))
610
+ );
611
+ react$1.useEffect(() => {
612
+ setDrafts(values.map((value) => chunkGTZH37JS_cjs.stringifySchemaValue(value)));
613
+ }, [values]);
614
+ const commit = (next) => {
615
+ props.update({ enum: next.length ? next : void 0 });
616
+ };
617
+ const createSeedValue = () => {
618
+ if (props.type === "integer" || props.type === "number") return 0;
619
+ if (props.type === "boolean") return true;
620
+ if (props.type === "null") return null;
621
+ if (props.type === "array") return [];
622
+ if (props.type === "object") return {};
623
+ return "";
624
+ };
625
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", children: [
626
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", children: [
627
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "600", children: "Enum" }),
628
+ /* @__PURE__ */ jsxRuntime.jsx(
629
+ react.Button,
630
+ {
631
+ size: "xs",
632
+ variant: "outline",
633
+ disabled: props.disabled,
634
+ onClick: () => {
635
+ const nextValues = [...values, createSeedValue()];
636
+ setDrafts(nextValues.map((value) => chunkGTZH37JS_cjs.stringifySchemaValue(value)));
637
+ commit(nextValues);
638
+ },
639
+ children: "Add enum"
640
+ }
641
+ )
642
+ ] }),
643
+ values.map((value, index) => {
644
+ const text = drafts[index] ?? chunkGTZH37JS_cjs.stringifySchemaValue(value);
645
+ const error = validateEnumText(props.type, text);
646
+ return /* @__PURE__ */ jsxRuntime.jsx(
647
+ react.Box,
648
+ {
649
+ p: "3",
650
+ border: "1px solid var(--color-border-subtle)",
651
+ borderRadius: "var(--radius-lg)",
652
+ bg: "var(--color-surface-subtle)",
653
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { align: "start", gap: "2", children: [
654
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { invalid: !!error, flex: "1", children: [
655
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Label, { children: [
656
+ "Value ",
657
+ index + 1
658
+ ] }),
659
+ /* @__PURE__ */ jsxRuntime.jsx(
660
+ react.Input,
661
+ {
662
+ size: "sm",
663
+ value: text,
664
+ disabled: props.disabled,
665
+ onChange: (e) => {
666
+ const nextDrafts = [...drafts];
667
+ nextDrafts[index] = e.target.value;
668
+ setDrafts(nextDrafts);
669
+ if (!validateEnumText(props.type, e.target.value)) {
670
+ const next = [...values];
671
+ next[index] = chunkGTZH37JS_cjs.parseSchemaValue(
672
+ e.target.value,
673
+ props.type
674
+ );
675
+ commit(next);
676
+ }
677
+ }
678
+ }
679
+ ),
680
+ error ? /* @__PURE__ */ jsxRuntime.jsx(react.Field.ErrorText, { children: error }) : null
681
+ ] }),
682
+ /* @__PURE__ */ jsxRuntime.jsx(
683
+ react.IconButton,
684
+ {
685
+ mt: "6",
686
+ size: "xs",
687
+ variant: "plain",
688
+ className: "pdDesignerSchemaIconButton",
689
+ "aria-label": "Remove enum value",
690
+ disabled: props.disabled,
691
+ onClick: () => {
692
+ const next = [...values];
693
+ next.splice(index, 1);
694
+ const nextDrafts = [...drafts];
695
+ nextDrafts.splice(index, 1);
696
+ setDrafts(nextDrafts);
697
+ commit(next);
698
+ },
699
+ children: "\xD7"
700
+ }
701
+ )
702
+ ] })
703
+ },
704
+ index
705
+ );
706
+ }),
707
+ values.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: "No enum values." }) : null
708
+ ] });
709
+ });
710
+
711
+ // src/react/shared/SettingsPanel.module.css
712
+ var SettingsPanel_default = {
713
+ panel: "SettingsPanel_panel",
714
+ header: "SettingsPanel_header",
715
+ title: "SettingsPanel_title",
716
+ close: "SettingsPanel_close",
717
+ body: "SettingsPanel_body"
718
+ };
719
+ function SettingsPanel({
720
+ title,
721
+ children
722
+ }) {
723
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Popover.Content, { className: SettingsPanel_default.panel, children: [
724
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Popover.Header, { className: SettingsPanel_default.header, children: [
725
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Title, { className: SettingsPanel_default.title, children: title }),
726
+ /* @__PURE__ */ jsxRuntime.jsx(
727
+ react.Popover.CloseTrigger,
728
+ {
729
+ className: SettingsPanel_default.close,
730
+ "aria-label": "Close settings",
731
+ children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuX, { size: 14 })
732
+ }
733
+ )
734
+ ] }),
735
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Body, { className: SettingsPanel_default.body, children })
736
+ ] });
737
+ }
738
+ var KEYS = ["allOf", "anyOf", "oneOf"];
739
+ var CompositionList = react$1.memo(function CompositionList2(props) {
740
+ const { schema, fullSchema, keyName, disabled, onChange } = props;
741
+ const values = chunkGTZH37JS_cjs.getComposition(schema, keyName);
742
+ const commit = (nextValues) => onChange(chunkGTZH37JS_cjs.setComposition(schema, keyName, nextValues));
743
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", className: "pdDesignerSchemaSection", children: [
744
+ /* @__PURE__ */ jsxRuntime.jsxs(
745
+ react.Button,
746
+ {
747
+ size: "xs",
748
+ alignSelf: "flex-start",
749
+ variant: "outline",
750
+ disabled,
751
+ onClick: () => commit([
752
+ ...values,
753
+ { type: "object", properties: {} }
754
+ ]),
755
+ children: [
756
+ "Add ",
757
+ keyName,
758
+ " item"
759
+ ]
760
+ }
761
+ ),
762
+ values.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: [
763
+ "No ",
764
+ keyName,
765
+ " rules."
766
+ ] }) : null,
767
+ values.map((item, index) => {
768
+ return /* @__PURE__ */ jsxRuntime.jsx(
769
+ react.Box,
770
+ {
771
+ className: "pdDesignerSchemaNestedCard",
772
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", gap: "3", children: [
773
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { flex: "1", minW: "0", children: [
774
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Text, { fontSize: "sm", fontWeight: "600", children: [
775
+ keyName,
776
+ "[",
777
+ index,
778
+ "]"
779
+ ] }),
780
+ /* @__PURE__ */ jsxRuntime.jsx(
781
+ react.Text,
782
+ {
783
+ fontSize: "xs",
784
+ color: "var(--color-text-secondary)",
785
+ lineClamp: 2,
786
+ children: chunkGTZH37JS_cjs.getSchemaSummary(item)
787
+ }
788
+ )
789
+ ] }),
790
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { gap: "1", flexShrink: 0, children: [
791
+ /* @__PURE__ */ jsxRuntime.jsxs(
792
+ react.Popover.Root,
793
+ {
794
+ lazyMount: true,
795
+ unmountOnExit: true,
796
+ positioning: { placement: "left-start", strategy: "fixed" },
797
+ children: [
798
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
799
+ react.IconButton,
800
+ {
801
+ size: "xs",
802
+ variant: "outline",
803
+ "aria-label": `Configure ${keyName} item ${index + 1}`,
804
+ className: "pdDesignerSchemaIconButton",
805
+ children: /* @__PURE__ */ jsxRuntime.jsx(vsc.VscSettingsCompact, { size: 16 })
806
+ }
807
+ ) }),
808
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, { title: `${keyName} \xB7 ${index + 1}`, children: /* @__PURE__ */ jsxRuntime.jsx(
809
+ InlineSchemaEditor,
810
+ {
811
+ schema: item,
812
+ fullSchema,
813
+ disabled,
814
+ nested: true,
815
+ path: [keyName, String(index)],
816
+ onChange: (value) => {
817
+ const next = [...values];
818
+ next[index] = value;
819
+ commit(next);
820
+ }
821
+ }
822
+ ) }) }) })
823
+ ]
824
+ }
825
+ ),
826
+ /* @__PURE__ */ jsxRuntime.jsx(
827
+ react.IconButton,
828
+ {
829
+ size: "xs",
830
+ variant: "plain",
831
+ "aria-label": `Remove ${keyName} item ${index + 1}`,
832
+ className: "pdDesignerSchemaIconButton",
833
+ disabled,
834
+ onClick: () => commit(values.filter((_, itemIndex) => itemIndex !== index)),
835
+ children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuX, { size: 14, strokeWidth: 1.5 })
836
+ }
837
+ )
838
+ ] })
839
+ ] })
840
+ },
841
+ `${keyName}-${index}`
842
+ );
843
+ })
844
+ ] });
845
+ });
846
+ var SchemaCompositionEditor = react$1.memo(
847
+ function SchemaCompositionEditor2(props) {
848
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Tabs.Root, { size: "sm", defaultValue: "allOf", variant: "plain", lazyMount: true, children: [
849
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.List, { className: "pdDesignerSchemaTabsList", children: KEYS.map((key) => /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Trigger, { value: key, children: key }, key)) }),
850
+ KEYS.map((key) => /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Content, { value: key, pt: "3", children: /* @__PURE__ */ jsxRuntime.jsx(
851
+ CompositionList,
852
+ {
853
+ schema: props.schema,
854
+ fullSchema: props.fullSchema,
855
+ keyName: key,
856
+ disabled: props.disabled,
857
+ onChange: props.onChange
858
+ }
859
+ ) }, key))
860
+ ] });
861
+ }
862
+ );
863
+ function previewText(schema) {
864
+ try {
865
+ return JSON.stringify(schema, null, 2);
866
+ } catch {
867
+ return "Schema preview unavailable: input contains a cyclic or non-JSON value.";
868
+ }
869
+ }
870
+ function SchemaPreview(props) {
871
+ const [copied, setCopied] = react$1.useState(false);
872
+ const [baselineText, setBaselineText] = react$1.useState(
873
+ () => previewText(props.schema)
874
+ );
875
+ const [lastStableText, setLastStableText] = react$1.useState(
876
+ () => previewText(props.schema)
877
+ );
878
+ const currentText = react$1.useMemo(() => previewText(props.schema), [props.schema]);
879
+ const copyTimerRef = react$1.useRef(
880
+ void 0
881
+ );
882
+ react$1.useEffect(() => () => clearTimeout(copyTimerRef.current), []);
883
+ const timerRef = react$1.useRef(null);
884
+ react$1.useEffect(() => {
885
+ if (currentText === lastStableText) return;
886
+ if (timerRef.current) window.clearTimeout(timerRef.current);
887
+ timerRef.current = window.setTimeout(() => {
888
+ setBaselineText(lastStableText);
889
+ setLastStableText(currentText);
890
+ timerRef.current = null;
891
+ }, 1400);
892
+ return () => {
893
+ if (timerRef.current) window.clearTimeout(timerRef.current);
894
+ };
895
+ }, [currentText, lastStableText]);
896
+ const lines = react$1.useMemo(
897
+ () => chunkGTZH37JS_cjs.diffSchemaLines(baselineText, currentText),
898
+ [baselineText, currentText]
899
+ );
900
+ const pathText = (props.path?.length ? props.path.join(" / ") : "root").replace(/\./g, " / ");
901
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", h: "100%", children: [
902
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "start", children: [
903
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { minW: "0", children: [
904
+ /* @__PURE__ */ jsxRuntime.jsx(
905
+ react.Text,
906
+ {
907
+ fontSize: "sm",
908
+ fontWeight: "700",
909
+ color: "var(--color-text-primary)",
910
+ children: "Generated schema"
911
+ }
912
+ ),
913
+ /* @__PURE__ */ jsxRuntime.jsx(
914
+ react.Text,
915
+ {
916
+ fontSize: "xs",
917
+ color: "var(--color-text-secondary)",
918
+ whiteSpace: "nowrap",
919
+ overflow: "hidden",
920
+ textOverflow: "ellipsis",
921
+ children: pathText
922
+ }
923
+ )
924
+ ] }),
925
+ /* @__PURE__ */ jsxRuntime.jsx(
926
+ react.Button,
927
+ {
928
+ size: "xs",
929
+ variant: "outline",
930
+ onClick: async () => {
931
+ try {
932
+ await navigator.clipboard.writeText(currentText);
933
+ setCopied(true);
934
+ clearTimeout(copyTimerRef.current);
935
+ copyTimerRef.current = setTimeout(() => setCopied(false), 1400);
936
+ } catch {
937
+ setCopied(false);
938
+ }
939
+ },
940
+ children: copied ? "Copied" : "Copy"
941
+ }
942
+ )
943
+ ] }),
944
+ /* @__PURE__ */ jsxRuntime.jsx(
945
+ react.Box,
946
+ {
947
+ flex: "1",
948
+ minH: "0",
949
+ overflow: "auto",
950
+ border: "1px solid var(--color-border-subtle)",
951
+ borderRadius: "var(--radius-xl)",
952
+ bg: "var(--color-surface-subtle)",
953
+ p: "3",
954
+ fontFamily: "mono",
955
+ fontSize: "12px",
956
+ children: lines.map((line, index) => /* @__PURE__ */ jsxRuntime.jsx(
957
+ react.Box,
958
+ {
959
+ px: "2",
960
+ py: "0.5",
961
+ borderRadius: "var(--radius-sm)",
962
+ bg: line.kind === "added" ? "var(--color-success-soft)" : line.kind === "removed" ? "var(--color-danger-soft)" : "transparent",
963
+ color: line.kind === "added" ? "var(--color-success)" : line.kind === "removed" ? "var(--color-danger)" : "var(--color-text-primary)",
964
+ textDecoration: line.kind === "removed" ? "line-through" : "none",
965
+ whiteSpace: "pre",
966
+ children: line.value || " "
967
+ },
968
+ `${index}-${line.kind}-${line.value}`
969
+ ))
970
+ }
971
+ ),
972
+ copied ? /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
973
+ react.Box,
974
+ {
975
+ position: "fixed",
976
+ top: "20px",
977
+ right: "20px",
978
+ zIndex: 2e3,
979
+ bg: "var(--color-surface)",
980
+ color: "var(--color-text-primary)",
981
+ border: "1px solid var(--color-border-default)",
982
+ borderRadius: "var(--radius-lg)",
983
+ boxShadow: "var(--shadow-md)",
984
+ px: "3",
985
+ py: "2",
986
+ children: "Copied schema JSON"
987
+ }
988
+ ) }) : null
989
+ ] });
990
+ }
991
+ function StringSchemaEditor(props) {
992
+ const formats = chunkGTZH37JS_cjs.normalizeFormatOptions(props.formatOptions);
993
+ const collection = react.createListCollection({
994
+ items: [
995
+ { value: "", label: "None" },
996
+ ...formats.map((value) => ({ value, label: value }))
997
+ ]
998
+ });
999
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { gap: "3", children: /* @__PURE__ */ jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: [
1000
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1001
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Format" }),
1002
+ /* @__PURE__ */ jsxRuntime.jsxs(
1003
+ react.Select.Root,
1004
+ {
1005
+ collection,
1006
+ size: "sm",
1007
+ disabled: props.disabled,
1008
+ value: [
1009
+ typeof props.schema.format === "string" ? props.schema.format : ""
1010
+ ],
1011
+ onValueChange: (e) => props.update({ format: e.value?.[0] || void 0 }),
1012
+ children: [
1013
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.HiddenSelect, {}),
1014
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Control, { children: [
1015
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.ValueText, { placeholder: "None" }) }),
1016
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.IndicatorGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Indicator, {}) })
1017
+ ] }),
1018
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Content, { className: "pdDesignerSelectMenu", children: collection.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Item, { item, children: [
1019
+ item.label,
1020
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.ItemIndicator, {})
1021
+ ] }, item.value)) }) }) })
1022
+ ]
1023
+ }
1024
+ )
1025
+ ] }),
1026
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1027
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Pattern" }),
1028
+ /* @__PURE__ */ jsxRuntime.jsx(
1029
+ react.Input,
1030
+ {
1031
+ size: "sm",
1032
+ disabled: props.disabled,
1033
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.pattern),
1034
+ onChange: (e) => props.update({ pattern: e.target.value || void 0 })
1035
+ }
1036
+ )
1037
+ ] }),
1038
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1039
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Min length" }),
1040
+ /* @__PURE__ */ jsxRuntime.jsx(
1041
+ react.Input,
1042
+ {
1043
+ size: "sm",
1044
+ type: "number",
1045
+ disabled: props.disabled,
1046
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.minLength),
1047
+ onChange: (e) => props.update({ minLength: chunkGTZH37JS_cjs.parseOptionalNumber(e.target.value) })
1048
+ }
1049
+ )
1050
+ ] }),
1051
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1052
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Max length" }),
1053
+ /* @__PURE__ */ jsxRuntime.jsx(
1054
+ react.Input,
1055
+ {
1056
+ size: "sm",
1057
+ type: "number",
1058
+ disabled: props.disabled,
1059
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.maxLength),
1060
+ onChange: (e) => props.update({ maxLength: chunkGTZH37JS_cjs.parseOptionalNumber(e.target.value) })
1061
+ }
1062
+ )
1063
+ ] })
1064
+ ] }) });
1065
+ }
1066
+ function NumberSchemaEditor(props) {
1067
+ const formats = chunkGTZH37JS_cjs.normalizeFormatOptions(props.formatOptions);
1068
+ const collection = react.createListCollection({
1069
+ items: [
1070
+ { value: "", label: "None" },
1071
+ ...formats.map((value) => ({ value, label: value }))
1072
+ ]
1073
+ });
1074
+ const numeric = (key, value) => props.update({
1075
+ [key]: chunkGTZH37JS_cjs.parseOptionalNumber(value)
1076
+ });
1077
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { gap: "3", children: /* @__PURE__ */ jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: [
1078
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1079
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Format" }),
1080
+ /* @__PURE__ */ jsxRuntime.jsxs(
1081
+ react.Select.Root,
1082
+ {
1083
+ collection,
1084
+ size: "sm",
1085
+ disabled: props.disabled,
1086
+ value: [
1087
+ typeof props.schema.format === "string" ? props.schema.format : ""
1088
+ ],
1089
+ onValueChange: (e) => props.update({ format: e.value?.[0] || void 0 }),
1090
+ children: [
1091
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.HiddenSelect, {}),
1092
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Control, { children: [
1093
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.ValueText, { placeholder: "None" }) }),
1094
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.IndicatorGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Indicator, {}) })
1095
+ ] }),
1096
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Select.Content, { className: "pdDesignerSelectMenu", children: collection.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Select.Item, { item, children: [
1097
+ item.label,
1098
+ /* @__PURE__ */ jsxRuntime.jsx(react.Select.ItemIndicator, {})
1099
+ ] }, item.value)) }) }) })
1100
+ ]
1101
+ }
1102
+ )
1103
+ ] }),
1104
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1105
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Multiple of" }),
1106
+ /* @__PURE__ */ jsxRuntime.jsx(
1107
+ react.Input,
1108
+ {
1109
+ size: "sm",
1110
+ type: "number",
1111
+ disabled: props.disabled,
1112
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.multipleOf),
1113
+ onChange: (e) => numeric("multipleOf", e.target.value)
1114
+ }
1115
+ )
1116
+ ] }),
1117
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1118
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Minimum" }),
1119
+ /* @__PURE__ */ jsxRuntime.jsx(
1120
+ react.Input,
1121
+ {
1122
+ size: "sm",
1123
+ type: "number",
1124
+ disabled: props.disabled,
1125
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.minimum),
1126
+ onChange: (e) => numeric("minimum", e.target.value)
1127
+ }
1128
+ )
1129
+ ] }),
1130
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1131
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Maximum" }),
1132
+ /* @__PURE__ */ jsxRuntime.jsx(
1133
+ react.Input,
1134
+ {
1135
+ size: "sm",
1136
+ type: "number",
1137
+ disabled: props.disabled,
1138
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.maximum),
1139
+ onChange: (e) => numeric("maximum", e.target.value)
1140
+ }
1141
+ )
1142
+ ] }),
1143
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1144
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Exclusive minimum" }),
1145
+ /* @__PURE__ */ jsxRuntime.jsx(
1146
+ react.Input,
1147
+ {
1148
+ size: "sm",
1149
+ type: "number",
1150
+ disabled: props.disabled,
1151
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.exclusiveMinimum),
1152
+ onChange: (e) => numeric("exclusiveMinimum", e.target.value)
1153
+ }
1154
+ )
1155
+ ] }),
1156
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1157
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Exclusive maximum" }),
1158
+ /* @__PURE__ */ jsxRuntime.jsx(
1159
+ react.Input,
1160
+ {
1161
+ size: "sm",
1162
+ type: "number",
1163
+ disabled: props.disabled,
1164
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema.exclusiveMaximum),
1165
+ onChange: (e) => numeric("exclusiveMaximum", e.target.value)
1166
+ }
1167
+ )
1168
+ ] })
1169
+ ] }) });
1170
+ }
1171
+ var NestedSchemaCard = react$1.memo(function NestedSchemaCard2(props) {
1172
+ const triggerRef = react$1.useRef(null);
1173
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: "pdDesignerSchemaNestedCard", children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", gap: "3", children: [
1174
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { flex: "1", minW: "0", children: [
1175
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontWeight: "600", fontSize: "sm", children: props.title }),
1176
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", mb: "1", children: props.description }),
1177
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", lineClamp: 2, children: chunkGTZH37JS_cjs.getSchemaSummary(props.schema) })
1178
+ ] }),
1179
+ props.onRemove && /* @__PURE__ */ jsxRuntime.jsx(
1180
+ react.Button,
1181
+ {
1182
+ size: "xs",
1183
+ variant: "ghost",
1184
+ disabled: props.disabled,
1185
+ onClick: props.onRemove,
1186
+ "aria-label": `Remove ${props.title.toLowerCase()}`,
1187
+ children: "Remove"
1188
+ }
1189
+ ),
1190
+ /* @__PURE__ */ jsxRuntime.jsxs(
1191
+ react.Popover.Root,
1192
+ {
1193
+ lazyMount: true,
1194
+ unmountOnExit: true,
1195
+ positioning: { placement: "left-start", strategy: "fixed" },
1196
+ onOpenChange: (details) => {
1197
+ if (!details.open && triggerRef.current) {
1198
+ window.requestAnimationFrame(() => triggerRef.current?.focus());
1199
+ }
1200
+ },
1201
+ children: [
1202
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1203
+ react.IconButton,
1204
+ {
1205
+ ref: triggerRef,
1206
+ size: "xs",
1207
+ variant: "outline",
1208
+ "aria-label": `Configure ${props.title.toLowerCase()}`,
1209
+ className: "pdDesignerSchemaIconButton",
1210
+ children: /* @__PURE__ */ jsxRuntime.jsx(vsc.VscSettingsCompact, { size: 16 })
1211
+ }
1212
+ ) }),
1213
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, { title: props.title, children: /* @__PURE__ */ jsxRuntime.jsx(
1214
+ InlineSchemaEditor,
1215
+ {
1216
+ schema: props.schema,
1217
+ onChange: props.onChange,
1218
+ fullSchema: props.fullSchema,
1219
+ disabled: props.disabled,
1220
+ nested: true,
1221
+ path: props.path
1222
+ }
1223
+ ) }) }) })
1224
+ ]
1225
+ }
1226
+ )
1227
+ ] }) });
1228
+ });
1229
+ var ArraySchemaEditor = react$1.memo(function ArraySchemaEditor2(props) {
1230
+ const items = chunkGTZH37JS_cjs.getArrayItems(props.schema) ?? { type: "string" };
1231
+ const prefixItems = chunkGTZH37JS_cjs.getPrefixItems(props.schema);
1232
+ const contains = typeof props.schema.contains === "boolean" || typeof props.schema.contains === "object" && props.schema.contains ? props.schema.contains : { type: "string" };
1233
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "4", children: [
1234
+ /* @__PURE__ */ jsxRuntime.jsx(
1235
+ NestedSchemaCard,
1236
+ {
1237
+ title: "Items schema",
1238
+ description: "Define the schema used by each array item.",
1239
+ schema: items,
1240
+ fullSchema: props.fullSchema,
1241
+ disabled: props.disabled,
1242
+ path: ["items"],
1243
+ onChange: (next) => props.onChange({
1244
+ ...props.schema,
1245
+ type: "array",
1246
+ items: next
1247
+ })
1248
+ }
1249
+ ),
1250
+ /* @__PURE__ */ jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: ["minItems", "maxItems", "minContains", "maxContains"].map((key) => /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1251
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: key }),
1252
+ /* @__PURE__ */ jsxRuntime.jsx(
1253
+ react.Input,
1254
+ {
1255
+ size: "sm",
1256
+ type: "number",
1257
+ disabled: props.disabled,
1258
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema[key]),
1259
+ onChange: (e) => props.onChange({
1260
+ ...props.schema,
1261
+ [key]: chunkGTZH37JS_cjs.parseOptionalNumber(e.target.value)
1262
+ })
1263
+ }
1264
+ )
1265
+ ] }, key)) }),
1266
+ /* @__PURE__ */ jsxRuntime.jsxs(
1267
+ react.Switch.Root,
1268
+ {
1269
+ checked: props.schema.uniqueItems === true,
1270
+ disabled: props.disabled,
1271
+ onCheckedChange: (e) => props.onChange({
1272
+ ...props.schema,
1273
+ uniqueItems: e.checked ? true : void 0
1274
+ }),
1275
+ children: [
1276
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
1277
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
1278
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Unique items" })
1279
+ ]
1280
+ }
1281
+ ),
1282
+ /* @__PURE__ */ jsxRuntime.jsx(
1283
+ NestedSchemaCard,
1284
+ {
1285
+ title: "Contains schema",
1286
+ description: "Require at least one array item to match this schema.",
1287
+ schema: contains,
1288
+ fullSchema: props.fullSchema,
1289
+ disabled: props.disabled,
1290
+ path: ["contains"],
1291
+ onChange: (next) => props.onChange({ ...props.schema, contains: next })
1292
+ }
1293
+ ),
1294
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", className: "pdDesignerSchemaSection", children: [
1295
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", children: [
1296
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "700", children: "Tuple prefix items" }),
1297
+ /* @__PURE__ */ jsxRuntime.jsx(
1298
+ react.Button,
1299
+ {
1300
+ size: "xs",
1301
+ variant: "outline",
1302
+ disabled: props.disabled,
1303
+ onClick: () => props.onChange({
1304
+ ...props.schema,
1305
+ prefixItems: [...prefixItems, { type: "string" }]
1306
+ }),
1307
+ children: "Add prefix item"
1308
+ }
1309
+ )
1310
+ ] }),
1311
+ prefixItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: "No tuple prefix items." }) : null,
1312
+ prefixItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
1313
+ NestedSchemaCard,
1314
+ {
1315
+ title: `Prefix item ${index + 1}`,
1316
+ description: "Schema for the positional tuple item.",
1317
+ schema: item,
1318
+ fullSchema: props.fullSchema,
1319
+ disabled: props.disabled,
1320
+ path: ["prefixItems", String(index)],
1321
+ onRemove: () => props.onChange({
1322
+ ...props.schema,
1323
+ prefixItems: prefixItems.filter(
1324
+ (_, position) => position !== index
1325
+ )
1326
+ }),
1327
+ onChange: (next) => {
1328
+ const values = [...prefixItems];
1329
+ values[index] = next;
1330
+ props.onChange({
1331
+ ...props.schema,
1332
+ prefixItems: values
1333
+ });
1334
+ }
1335
+ },
1336
+ `prefix-${index}`
1337
+ ))
1338
+ ] })
1339
+ ] });
1340
+ });
1341
+ var SchemaPropertyRow = react$1.memo(function SchemaPropertyRow2(props) {
1342
+ const [name, setName] = react$1.useState(props.name);
1343
+ const [error, setError] = react$1.useState("");
1344
+ const triggerRef = react$1.useRef(null);
1345
+ react$1.useEffect(() => {
1346
+ setName(props.name);
1347
+ setError("");
1348
+ }, [props.name]);
1349
+ const validate = (next) => {
1350
+ const trimmed = next.trim();
1351
+ if (!trimmed) return "Property name is required.";
1352
+ if (trimmed !== props.name && props.siblingNames.includes(trimmed)) {
1353
+ return "Property name already exists.";
1354
+ }
1355
+ return "";
1356
+ };
1357
+ const commitRename = () => {
1358
+ const nextError = validate(name);
1359
+ setError(nextError);
1360
+ if (!nextError && name.trim() !== props.name) {
1361
+ props.onRename(name.trim());
1362
+ }
1363
+ };
1364
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: "pdDesignerSchemaNestedCard", children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { align: "start", gap: "3", className: "schemaPropertyRow", children: [
1365
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { invalid: !!error, flex: "1", minW: "0", children: [
1366
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: "Property" }),
1367
+ /* @__PURE__ */ jsxRuntime.jsx(
1368
+ react.Input,
1369
+ {
1370
+ size: "sm",
1371
+ value: name,
1372
+ disabled: props.disabled,
1373
+ onChange: (e) => {
1374
+ setName(e.target.value);
1375
+ setError(validate(e.target.value));
1376
+ },
1377
+ onBlur: commitRename,
1378
+ onKeyDown: (e) => {
1379
+ if (e.key === "Enter") {
1380
+ e.preventDefault();
1381
+ commitRename();
1382
+ }
1383
+ if (e.key === "Escape") {
1384
+ setName(props.name);
1385
+ setError("");
1386
+ }
1387
+ if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "d") {
1388
+ e.preventDefault();
1389
+ props.onDuplicate();
1390
+ }
1391
+ if ((e.metaKey || e.ctrlKey) && e.key === "Backspace") {
1392
+ e.preventDefault();
1393
+ props.onRemove();
1394
+ }
1395
+ },
1396
+ placeholder: "Property name"
1397
+ }
1398
+ ),
1399
+ error ? /* @__PURE__ */ jsxRuntime.jsx(react.Field.ErrorText, { children: error }) : null,
1400
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", mt: "1", children: chunkGTZH37JS_cjs.getSchemaSummary(props.schema) })
1401
+ ] }),
1402
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", pt: "6", minW: "88px", flexShrink: 0, children: [
1403
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: chunkGTZH37JS_cjs.getSchemaType(props.schema) }),
1404
+ /* @__PURE__ */ jsxRuntime.jsxs(
1405
+ react.Switch.Root,
1406
+ {
1407
+ checked: props.required,
1408
+ disabled: props.disabled,
1409
+ onCheckedChange: (e) => props.onRequiredChange(!!e.checked),
1410
+ children: [
1411
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
1412
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
1413
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { fontSize: "xs", children: "Required" })
1414
+ ]
1415
+ }
1416
+ )
1417
+ ] }),
1418
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { pt: "6", gap: "1", flexShrink: 0, children: [
1419
+ /* @__PURE__ */ jsxRuntime.jsxs(
1420
+ react.Popover.Root,
1421
+ {
1422
+ lazyMount: true,
1423
+ unmountOnExit: true,
1424
+ positioning: { placement: "left-start", strategy: "fixed" },
1425
+ onOpenChange: (details) => {
1426
+ if (!details.open && triggerRef.current) {
1427
+ window.requestAnimationFrame(() => triggerRef.current?.focus());
1428
+ }
1429
+ },
1430
+ children: [
1431
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1432
+ react.IconButton,
1433
+ {
1434
+ ref: triggerRef,
1435
+ size: "xs",
1436
+ variant: "outline",
1437
+ "aria-label": "Configure property",
1438
+ className: "pdDesignerSchemaIconButton",
1439
+ children: /* @__PURE__ */ jsxRuntime.jsx(vsc.VscSettingsCompact, { size: 16 })
1440
+ }
1441
+ ) }),
1442
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, { title: props.name, children: /* @__PURE__ */ jsxRuntime.jsx(
1443
+ InlineSchemaEditor,
1444
+ {
1445
+ schema: props.schema,
1446
+ onChange: props.onChange,
1447
+ fullSchema: props.fullSchema,
1448
+ disabled: props.disabled,
1449
+ nested: true,
1450
+ path: [props.name]
1451
+ }
1452
+ ) }) }) })
1453
+ ]
1454
+ }
1455
+ ),
1456
+ /* @__PURE__ */ jsxRuntime.jsx(
1457
+ react.IconButton,
1458
+ {
1459
+ pt: "0",
1460
+ size: "xs",
1461
+ variant: "plain",
1462
+ "aria-label": "Duplicate property",
1463
+ className: "pdDesignerSchemaIconButton",
1464
+ disabled: props.disabled,
1465
+ onClick: props.onDuplicate,
1466
+ children: "\u29C9"
1467
+ }
1468
+ ),
1469
+ /* @__PURE__ */ jsxRuntime.jsx(
1470
+ react.IconButton,
1471
+ {
1472
+ pt: "0",
1473
+ size: "xs",
1474
+ variant: "plain",
1475
+ "aria-label": "Remove property",
1476
+ className: "pdDesignerSchemaIconButton",
1477
+ disabled: props.disabled,
1478
+ onClick: props.onRemove,
1479
+ children: "\xD7"
1480
+ }
1481
+ )
1482
+ ] })
1483
+ ] }) });
1484
+ });
1485
+ var SchemaPropertyList = react$1.memo(function SchemaPropertyList2(props) {
1486
+ const properties = react$1.useMemo(() => chunkGTZH37JS_cjs.getProperties(props.schema), [props.schema]);
1487
+ const required = react$1.useMemo(
1488
+ () => chunkGTZH37JS_cjs.getRequiredProperties(props.schema),
1489
+ [props.schema]
1490
+ );
1491
+ const names = react$1.useMemo(() => Object.keys(properties), [properties]);
1492
+ const add = react$1.useCallback(() => {
1493
+ let index = names.length + 1;
1494
+ let name = `property${index}`;
1495
+ while (name in properties) name = `property${++index}`;
1496
+ props.onChange(
1497
+ chunkGTZH37JS_cjs.updateProperty(props.schema, name, { type: "string" })
1498
+ );
1499
+ }, [names, properties, props]);
1500
+ const duplicate = react$1.useCallback(
1501
+ (name) => {
1502
+ let index = 2;
1503
+ let nextName = `${name}Copy`;
1504
+ while (nextName in properties) nextName = `${name}Copy${index++}`;
1505
+ props.onChange(
1506
+ chunkGTZH37JS_cjs.updateProperty(props.schema, nextName, chunkGTZH37JS_cjs.cloneSchema2(properties[name]))
1507
+ );
1508
+ },
1509
+ [properties, props]
1510
+ );
1511
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", className: "pdDesignerSchemaSection", children: [
1512
+ /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", children: [
1513
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontWeight: "700", fontSize: "sm", children: "Properties" }),
1514
+ /* @__PURE__ */ jsxRuntime.jsx(
1515
+ react.Button,
1516
+ {
1517
+ size: "xs",
1518
+ variant: "outline",
1519
+ disabled: props.disabled,
1520
+ onClick: add,
1521
+ children: "Add property"
1522
+ }
1523
+ )
1524
+ ] }),
1525
+ names.map((name) => /* @__PURE__ */ jsxRuntime.jsx(
1526
+ SchemaPropertyRow,
1527
+ {
1528
+ name,
1529
+ schema: properties[name],
1530
+ required: required.has(name),
1531
+ siblingNames: names,
1532
+ fullSchema: props.fullSchema,
1533
+ disabled: props.disabled,
1534
+ onRename: (next) => props.onChange(chunkGTZH37JS_cjs.renameProperty(props.schema, name, next)),
1535
+ onDuplicate: () => duplicate(name),
1536
+ onRequiredChange: (value) => props.onChange(chunkGTZH37JS_cjs.setPropertyRequired(props.schema, name, value)),
1537
+ onChange: (schema) => props.onChange(chunkGTZH37JS_cjs.updateProperty(props.schema, name, schema)),
1538
+ onRemove: () => props.onChange(chunkGTZH37JS_cjs.removeProperty(props.schema, name))
1539
+ },
1540
+ name
1541
+ )),
1542
+ !names.length ? /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "xs", color: "var(--color-text-secondary)", children: "No properties defined." }) : null
1543
+ ] });
1544
+ });
1545
+ var ObjectSchemaEditor = react$1.memo(function ObjectSchemaEditor2(props) {
1546
+ const triggerRef = react$1.useRef(null);
1547
+ const mode = props.schema.additionalProperties === false ? "deny" : typeof props.schema.additionalProperties === "object" ? "schema" : "allow";
1548
+ const additional = typeof props.schema.additionalProperties === "object" && props.schema.additionalProperties !== null ? props.schema.additionalProperties : { type: "string" };
1549
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "4", children: [
1550
+ /* @__PURE__ */ jsxRuntime.jsx(
1551
+ SchemaPropertyList,
1552
+ {
1553
+ schema: props.schema,
1554
+ fullSchema: props.fullSchema,
1555
+ disabled: props.disabled,
1556
+ onChange: props.onChange
1557
+ }
1558
+ ),
1559
+ /* @__PURE__ */ jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(2, minmax(0, 1fr))", gap: "3", children: ["minProperties", "maxProperties"].map((key) => /* @__PURE__ */ jsxRuntime.jsxs(react.Field.Root, { children: [
1560
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Label, { children: key }),
1561
+ /* @__PURE__ */ jsxRuntime.jsx(
1562
+ react.Input,
1563
+ {
1564
+ size: "sm",
1565
+ type: "number",
1566
+ disabled: props.disabled,
1567
+ value: chunkGTZH37JS_cjs.toInputValue(props.schema[key]),
1568
+ onChange: (e) => props.onChange({
1569
+ ...props.schema,
1570
+ [key]: chunkGTZH37JS_cjs.parseOptionalNumber(e.target.value)
1571
+ })
1572
+ }
1573
+ )
1574
+ ] }, key)) }),
1575
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", className: "pdDesignerSchemaSection", children: [
1576
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "700", children: "Additional properties" }),
1577
+ /* @__PURE__ */ jsxRuntime.jsx(react.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(react.NativeSelect.Root, { size: "sm", disabled: props.disabled, children: [
1578
+ /* @__PURE__ */ jsxRuntime.jsxs(
1579
+ react.NativeSelect.Field,
1580
+ {
1581
+ value: mode,
1582
+ onChange: (e) => {
1583
+ const value = e.target.value;
1584
+ props.onChange({
1585
+ ...props.schema,
1586
+ additionalProperties: value === "deny" ? false : value === "schema" ? additional : void 0
1587
+ });
1588
+ },
1589
+ children: [
1590
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "allow", children: "Allow any property" }),
1591
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "deny", children: "Disallow extra properties" }),
1592
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "schema", children: "Validate with schema" })
1593
+ ]
1594
+ }
1595
+ ),
1596
+ /* @__PURE__ */ jsxRuntime.jsx(react.NativeSelect.Indicator, {})
1597
+ ] }) }),
1598
+ mode === "schema" ? /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: "pdDesignerSchemaNestedCard", children: /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { justify: "space-between", align: "center", gap: "3", children: [
1599
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { flex: "1", minW: "0", children: [
1600
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", fontWeight: "600", children: "Additional property schema" }),
1601
+ /* @__PURE__ */ jsxRuntime.jsx(
1602
+ react.Text,
1603
+ {
1604
+ fontSize: "xs",
1605
+ color: "var(--color-text-secondary)",
1606
+ lineClamp: 2,
1607
+ children: chunkGTZH37JS_cjs.getSchemaSummary(additional)
1608
+ }
1609
+ )
1610
+ ] }),
1611
+ /* @__PURE__ */ jsxRuntime.jsxs(
1612
+ react.Popover.Root,
1613
+ {
1614
+ lazyMount: true,
1615
+ unmountOnExit: true,
1616
+ positioning: { placement: "left-start", strategy: "fixed" },
1617
+ onOpenChange: (details) => {
1618
+ if (!details.open && triggerRef.current) {
1619
+ window.requestAnimationFrame(
1620
+ () => triggerRef.current?.focus()
1621
+ );
1622
+ }
1623
+ },
1624
+ children: [
1625
+ /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1626
+ react.IconButton,
1627
+ {
1628
+ ref: triggerRef,
1629
+ size: "xs",
1630
+ variant: "outline",
1631
+ "aria-label": "Configure additional property schema",
1632
+ className: "pdDesignerSchemaIconButton",
1633
+ children: /* @__PURE__ */ jsxRuntime.jsx(vsc.VscSettingsCompact, { size: 16 })
1634
+ }
1635
+ ) }),
1636
+ /* @__PURE__ */ jsxRuntime.jsx(react.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Popover.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, { title: "Additional properties", children: /* @__PURE__ */ jsxRuntime.jsx(
1637
+ InlineSchemaEditor,
1638
+ {
1639
+ schema: additional,
1640
+ fullSchema: props.fullSchema,
1641
+ disabled: props.disabled,
1642
+ nested: true,
1643
+ path: ["additionalProperties"],
1644
+ onChange: (value) => props.onChange({
1645
+ ...props.schema,
1646
+ additionalProperties: value
1647
+ })
1648
+ }
1649
+ ) }) }) })
1650
+ ]
1651
+ }
1652
+ )
1653
+ ] }) }) : null
1654
+ ] })
1655
+ ] });
1656
+ });
1657
+ function BooleanSchemaEditor() {
1658
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", color: "var(--color-text-secondary)", children: "Boolean schemas do not expose type-specific constraints in this compact editor." });
1659
+ }
1660
+
1661
+ // src/react/inlineSchemaEditor/InlineSchemaEditor.module.css
1662
+ var InlineSchemaEditor_default = {
1663
+ root: "InlineSchemaEditor_root",
1664
+ shell: "InlineSchemaEditor_shell",
1665
+ editorPane: "InlineSchemaEditor_editorPane",
1666
+ previewPane: "InlineSchemaEditor_previewPane",
1667
+ reference: "InlineSchemaEditor_reference",
1668
+ tabsList: "InlineSchemaEditor_tabsList"
1669
+ };
1670
+ var STRING_FORMATS = [
1671
+ "date",
1672
+ "date-time",
1673
+ "time",
1674
+ "duration",
1675
+ "email",
1676
+ "idn-email",
1677
+ "hostname",
1678
+ "idn-hostname",
1679
+ "ipv4",
1680
+ "ipv6",
1681
+ "uri",
1682
+ "uri-reference",
1683
+ "iri",
1684
+ "iri-reference",
1685
+ "uuid",
1686
+ "regex",
1687
+ "json-pointer",
1688
+ "relative-json-pointer"
1689
+ ];
1690
+ var NUMBER_FORMATS = ["float", "double"];
1691
+ var INTEGER_FORMATS = ["int32", "int64"];
1692
+ function InlineSchemaEditor(props) {
1693
+ const current = props.value !== void 0 ? props.value : props.schema;
1694
+ const update = (patch) => {
1695
+ if (props.disabled) return;
1696
+ props.onChange?.(chunkGTZH37JS_cjs.mergeSchema(current, patch));
1697
+ props.update?.(patch);
1698
+ if (Object.hasOwn(patch, "example")) props.onExampleChange?.(patch.example);
1699
+ if (Object.hasOwn(patch, "default")) props.onDefaultChange?.(patch.default);
1700
+ };
1701
+ if (typeof current === "boolean")
1702
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: InlineSchemaEditor_default.root, children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "3", children: [
1703
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontWeight: "600", children: current ? "Any value is allowed" : "No values are allowed" }),
1704
+ /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "sm", children: "This is a boolean JSON Schema." }),
1705
+ props.onRequiredChange && /* @__PURE__ */ jsxRuntime.jsxs(
1706
+ react.Switch.Root,
1707
+ {
1708
+ checked: !!props.required,
1709
+ disabled: props.disabled,
1710
+ onCheckedChange: (event) => props.onRequiredChange?.(event.checked),
1711
+ children: [
1712
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.HiddenInput, {}),
1713
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Control, {}),
1714
+ /* @__PURE__ */ jsxRuntime.jsx(react.Switch.Label, { children: "Required" })
1715
+ ]
1716
+ }
1717
+ ),
1718
+ /* @__PURE__ */ jsxRuntime.jsx(
1719
+ react.Button,
1720
+ {
1721
+ size: "sm",
1722
+ disabled: props.disabled || !props.onChange,
1723
+ onClick: () => props.onChange?.(!current),
1724
+ children: current ? "Disallow all values" : "Allow all values"
1725
+ }
1726
+ ),
1727
+ /* @__PURE__ */ jsxRuntime.jsx(
1728
+ react.Button,
1729
+ {
1730
+ size: "sm",
1731
+ variant: "outline",
1732
+ disabled: props.disabled,
1733
+ onClick: () => update({}),
1734
+ children: "Configure constraints"
1735
+ }
1736
+ )
1737
+ ] }) });
1738
+ return /* @__PURE__ */ jsxRuntime.jsx(ObjectSchemaEditorView, { ...props, schema: current, update });
1739
+ }
1740
+ function ObjectSchemaEditorView(props) {
1741
+ const { schema, type } = useSchemaEditor(props.schema, props.schemaType);
1742
+ const { patch, replace } = useSchemaPatch(props.schema, props.update);
1743
+ const record = chunkGTZH37JS_cjs.toSchemaRecord(schema);
1744
+ const isRefMode = typeof record.$ref === "string" && record.$ref.length > 0;
1745
+ const onTypeChange = react$1.useCallback(
1746
+ (nextType) => {
1747
+ const next = chunkGTZH37JS_cjs.createSchemaForType(nextType, schema);
1748
+ replace(next);
1749
+ props.onTypeChange?.(nextType);
1750
+ },
1751
+ [props, replace, schema]
1752
+ );
1753
+ const formatOptions = react$1.useMemo(
1754
+ () => props.formatOptions ?? (type === "string" ? STRING_FORMATS : type === "number" ? NUMBER_FORMATS : type === "integer" ? INTEGER_FORMATS : []),
1755
+ [props.formatOptions, type]
1756
+ );
1757
+ const mergeSchema2 = react$1.useCallback(
1758
+ (next) => replace(next),
1759
+ [replace]
1760
+ );
1761
+ const previewVisible = props.showLiveJson !== false && !props.nested;
1762
+ const handleRefUpdate = react$1.useCallback(
1763
+ (nextPatch) => {
1764
+ patch(nextPatch);
1765
+ },
1766
+ [isRefMode, patch, replace, schema]
1767
+ );
1768
+ const showBasicEnum = !["object", "array", "null", "any"].includes(type);
1769
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", minW: "0", flex: "1", children: [
1770
+ /* @__PURE__ */ jsxRuntime.jsx(
1771
+ SchemaHeader,
1772
+ {
1773
+ name: props.schemaName,
1774
+ description: typeof schema.description === "string" ? schema.description : "",
1775
+ type,
1776
+ required: props.required,
1777
+ disabled: props.disabled,
1778
+ onTypeChange,
1779
+ onRequiredChange: props.onRequiredChange,
1780
+ onNameChange: props.onNameChange,
1781
+ hideName: !!props.nested,
1782
+ onDescriptionChange: (value) => patch({ description: value || void 0 })
1783
+ }
1784
+ ),
1785
+ /* @__PURE__ */ jsxRuntime.jsxs("details", { className: InlineSchemaEditor_default.reference, open: isRefMode || void 0, children: [
1786
+ /* @__PURE__ */ jsxRuntime.jsxs("summary", { children: [
1787
+ "Reference",
1788
+ isRefMode ? " linked" : " (optional)"
1789
+ ] }),
1790
+ /* @__PURE__ */ jsxRuntime.jsx(
1791
+ SchemaReferenceEditor,
1792
+ {
1793
+ schema,
1794
+ fullSchema: props.fullSchema,
1795
+ disabled: props.disabled,
1796
+ onClearReference: () => handleRefUpdate({ $ref: void 0 }),
1797
+ update: handleRefUpdate
1798
+ }
1799
+ )
1800
+ ] }),
1801
+ !isRefMode && /* @__PURE__ */ jsxRuntime.jsxs(
1802
+ react.Tabs.Root,
1803
+ {
1804
+ size: "sm",
1805
+ defaultValue: "core",
1806
+ variant: "plain",
1807
+ lazyMount: true,
1808
+ unmountOnExit: true,
1809
+ children: [
1810
+ /* @__PURE__ */ jsxRuntime.jsxs(react.Tabs.List, { className: InlineSchemaEditor_default.tabsList, children: [
1811
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Trigger, { value: "core", children: "Core" }),
1812
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Trigger, { value: "validation", children: "Validation" }),
1813
+ props.showAdvanced !== false && /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Trigger, { value: "advanced", children: "Advanced" })
1814
+ ] }),
1815
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Content, { value: "core", pt: "2", children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", children: [
1816
+ type === "string" && /* @__PURE__ */ jsxRuntime.jsx(
1817
+ StringSchemaEditor,
1818
+ {
1819
+ schema,
1820
+ disabled: props.disabled,
1821
+ formatOptions,
1822
+ update: patch
1823
+ }
1824
+ ),
1825
+ (type === "number" || type === "integer") && /* @__PURE__ */ jsxRuntime.jsx(
1826
+ NumberSchemaEditor,
1827
+ {
1828
+ schema,
1829
+ disabled: props.disabled,
1830
+ formatOptions,
1831
+ update: patch
1832
+ }
1833
+ ),
1834
+ type === "boolean" && /* @__PURE__ */ jsxRuntime.jsx(BooleanSchemaEditor, {}),
1835
+ type === "array" && /* @__PURE__ */ jsxRuntime.jsx(
1836
+ ArraySchemaEditor,
1837
+ {
1838
+ schema,
1839
+ fullSchema: props.fullSchema,
1840
+ disabled: props.disabled,
1841
+ onChange: mergeSchema2
1842
+ }
1843
+ ),
1844
+ type === "object" && /* @__PURE__ */ jsxRuntime.jsx(
1845
+ ObjectSchemaEditor,
1846
+ {
1847
+ schema,
1848
+ fullSchema: props.fullSchema,
1849
+ disabled: props.disabled,
1850
+ onChange: mergeSchema2
1851
+ }
1852
+ )
1853
+ ] }) }),
1854
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Content, { value: "validation", pt: "2", children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { gap: "2", children: [
1855
+ showBasicEnum ? /* @__PURE__ */ jsxRuntime.jsx(
1856
+ SchemaEnumEditor,
1857
+ {
1858
+ schema,
1859
+ type,
1860
+ disabled: props.disabled,
1861
+ update: patch
1862
+ }
1863
+ ) : null,
1864
+ props.showComposition !== false && /* @__PURE__ */ jsxRuntime.jsxs("details", { className: InlineSchemaEditor_default.reference, children: [
1865
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Composition rules (allOf / anyOf / oneOf)" }),
1866
+ /* @__PURE__ */ jsxRuntime.jsx(
1867
+ SchemaCompositionEditor,
1868
+ {
1869
+ schema,
1870
+ fullSchema: props.fullSchema,
1871
+ disabled: props.disabled,
1872
+ onChange: mergeSchema2
1873
+ }
1874
+ )
1875
+ ] })
1876
+ ] }) }),
1877
+ /* @__PURE__ */ jsxRuntime.jsx(react.Tabs.Content, { value: "advanced", pt: "2", children: /* @__PURE__ */ jsxRuntime.jsx(
1878
+ SchemaAdvancedEditor,
1879
+ {
1880
+ schema,
1881
+ disabled: props.disabled,
1882
+ update: patch
1883
+ }
1884
+ ) })
1885
+ ]
1886
+ }
1887
+ )
1888
+ ] });
1889
+ if (props.nested) {
1890
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: InlineSchemaEditor_default.root, children: content });
1891
+ }
1892
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: InlineSchemaEditor_default.root, children: /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { className: InlineSchemaEditor_default.shell, children: [
1893
+ /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: InlineSchemaEditor_default.editorPane, children: content }),
1894
+ previewVisible && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { className: InlineSchemaEditor_default.previewPane, children: /* @__PURE__ */ jsxRuntime.jsx(SchemaPreview, { schema, path: props.path }) })
1895
+ ] }) });
1896
+ }
1897
+
1898
+ exports.InlineSchemaEditor = InlineSchemaEditor;
1899
+ exports.InlineSchemaEditor_default = InlineSchemaEditor_default;
1900
+ exports.SettingsPanel = SettingsPanel;