@burdenoff/fe-libs 2026.1027.2 → 2026.1027.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +8 -5
- package/dist/node_modules/@openuidev/devtools/dist/index.js +74 -0
- package/dist/node_modules/@openuidev/lang-core/dist/index.js +3779 -0
- package/dist/node_modules/@openuidev/lang-core/dist/shared-Dzgc28Wo.js +39 -0
- package/dist/node_modules/@openuidev/observability/dist/index.js +30 -0
- package/dist/node_modules/@openuidev/react-lang/dist/exports-CLfR509v.js +946 -0
- package/dist/node_modules/@openuidev/react-lang/dist/index.js +25 -0
- package/dist/node_modules/ci-info/index.js +34 -0
- package/dist/node_modules/ci-info/vendors.json.js +331 -0
- package/dist/node_modules/react-dom/cjs/react-dom-client.development.js +11168 -0
- package/dist/node_modules/react-dom/cjs/react-dom-client.production.js +7384 -0
- package/dist/node_modules/react-dom/client.js +19 -0
- package/dist/node_modules/scheduler/cjs/scheduler.development.js +203 -0
- package/dist/node_modules/scheduler/cjs/scheduler.production.js +203 -0
- package/dist/node_modules/scheduler/index.js +10 -0
- package/dist/node_modules/zod/v4/classic/errors.js +23 -0
- package/dist/node_modules/zod/v4/classic/iso.js +31 -0
- package/dist/node_modules/zod/v4/classic/parse.js +6 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +339 -0
- package/dist/node_modules/zod/v4/core/api.js +491 -0
- package/dist/node_modules/zod/v4/core/checks.js +283 -0
- package/dist/node_modules/zod/v4/core/core.js +44 -0
- package/dist/node_modules/zod/v4/core/doc.js +23 -0
- package/dist/node_modules/zod/v4/core/errors.js +41 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +306 -0
- package/dist/node_modules/zod/v4/core/parse.js +68 -0
- package/dist/node_modules/zod/v4/core/regexes.js +25 -0
- package/dist/node_modules/zod/v4/core/registries.js +40 -0
- package/dist/node_modules/zod/v4/core/schemas.js +796 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +222 -0
- package/dist/node_modules/zod/v4/core/util.js +266 -0
- package/dist/node_modules/zod/v4/core/versions.js +8 -0
- package/dist/shared/assistant/index.d.ts +4 -0
- package/dist/shared/assistant/openui/AssistantOpenUiBlock.d.ts +19 -0
- package/dist/shared/assistant/openui/AssistantOpenUiBlock.js +26 -0
- package/dist/shared/assistant/openui/AssistantRichContent.d.ts +13 -0
- package/dist/shared/assistant/openui/AssistantRichContent.js +37 -0
- package/dist/shared/assistant/openui/OpenUiBoundary.d.ts +26 -0
- package/dist/shared/assistant/openui/OpenUiBoundary.js +13 -0
- package/dist/shared/assistant/openui/generativeUi.d.ts +6 -0
- package/dist/shared/assistant/openui/generativeUi.js +12 -0
- package/dist/shared/assistant/openui/library.d.ts +2 -0
- package/dist/shared/assistant/openui/library.js +191 -0
- package/dist/shared/assistant/openui/limits.d.ts +12 -0
- package/dist/shared/assistant/openui/limits.js +7 -0
- package/dist/shared/assistant/openui/segments.d.ts +40 -0
- package/dist/shared/assistant/openui/segments.js +52 -0
- package/dist/shared/assistant/ui/AssistantMessageItem.js +115 -109
- package/dist/shared-assistant.js +108 -104
- package/package.json +2 -1
|
@@ -0,0 +1,946 @@
|
|
|
1
|
+
import { ACTION_STEPS as e, BuiltinActionType as t, ToolNotFoundError as n, createLibrary as r, createQueryManager as i, createStore as a, createStreamingParser as o, defineComponent as s, enrichErrors as c, evaluate as l, evaluateRoot as u, extractToolResult as d, markReactive as f, parseMessage as p, resolveStateField as m, validate as h } from "../../lang-core/dist/index.js";
|
|
2
|
+
import { observability as g } from "../../observability/dist/index.js";
|
|
3
|
+
import { Component as _, Fragment as v, createContext as y, useCallback as b, useContext as x, useEffect as S, useId as C, useInsertionEffect as w, useMemo as T, useRef as E, useState as D, useSyncExternalStore as ee } from "react";
|
|
4
|
+
import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
|
|
5
|
+
//#region node_modules/@openuidev/react-lang/dist/exports-CLfR509v.mjs
|
|
6
|
+
var j = Symbol.for("openui.devtools.libraries"), M = "react-lang:library";
|
|
7
|
+
function N(e) {
|
|
8
|
+
return e.id ?? e.root ?? Object.keys(e.components).sort().join(",");
|
|
9
|
+
}
|
|
10
|
+
function P() {
|
|
11
|
+
let e = globalThis;
|
|
12
|
+
return e[j] ??= {};
|
|
13
|
+
}
|
|
14
|
+
function te(e, t = N(e)) {
|
|
15
|
+
P()[t] = e, g.info({
|
|
16
|
+
kind: M,
|
|
17
|
+
__libraryId: e.__libraryId,
|
|
18
|
+
...e.id === void 0 ? {} : { id: e.id },
|
|
19
|
+
...e.root === void 0 ? {} : { root: e.root },
|
|
20
|
+
components: Object.keys(e.components),
|
|
21
|
+
message: e.id ? `Library "${e.id}" registered` : `Library registered (root: ${e.root ?? "none"})`
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function F(e) {
|
|
25
|
+
return s(e);
|
|
26
|
+
}
|
|
27
|
+
function I(e) {
|
|
28
|
+
return R(r(e));
|
|
29
|
+
}
|
|
30
|
+
var L = 0;
|
|
31
|
+
function R(e, t = N(e)) {
|
|
32
|
+
process.env.NODE_ENV !== "production" && te(e, t);
|
|
33
|
+
let n = e.extend;
|
|
34
|
+
return Object.assign(e, { extend: ((e) => R(n(e), `${t}:extend-${++L}`)) });
|
|
35
|
+
}
|
|
36
|
+
var z = y(null);
|
|
37
|
+
function B() {
|
|
38
|
+
let e = x(z);
|
|
39
|
+
if (!e) throw Error("useOpenUI must be used within a <Renderer /> component.");
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
function V() {
|
|
43
|
+
return B().renderNode;
|
|
44
|
+
}
|
|
45
|
+
function H() {
|
|
46
|
+
return B().triggerAction;
|
|
47
|
+
}
|
|
48
|
+
function U() {
|
|
49
|
+
return B().isStreaming;
|
|
50
|
+
}
|
|
51
|
+
function W() {
|
|
52
|
+
return B().isQueryLoading;
|
|
53
|
+
}
|
|
54
|
+
function G() {
|
|
55
|
+
return B().getFieldValue;
|
|
56
|
+
}
|
|
57
|
+
function K() {
|
|
58
|
+
return B().setFieldValue;
|
|
59
|
+
}
|
|
60
|
+
var q = y(void 0);
|
|
61
|
+
function J() {
|
|
62
|
+
return x(q);
|
|
63
|
+
}
|
|
64
|
+
function Y({ formName: e, componentType: t, name: n, existingValue: r, defaultValue: i, shouldTriggerSaveCallback: a = !1 }) {
|
|
65
|
+
let o = K(), s = U();
|
|
66
|
+
S(() => {
|
|
67
|
+
!s && r === void 0 && i !== void 0 && o(e, t, n, i, a);
|
|
68
|
+
}, [
|
|
69
|
+
i,
|
|
70
|
+
r,
|
|
71
|
+
e,
|
|
72
|
+
t,
|
|
73
|
+
n,
|
|
74
|
+
s,
|
|
75
|
+
o,
|
|
76
|
+
a
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
var ne = "]]>openui:scripts", X = /^\]\]>openui:content(?:\?.*)?\r?$(\n?)/m, Z = /^\]\]>openui:scripts(?=\?|\r?$)/gm;
|
|
80
|
+
function Q(e) {
|
|
81
|
+
let t = "", n = !1;
|
|
82
|
+
for (let r = 0; r < e.length; r++) {
|
|
83
|
+
let i = e[r];
|
|
84
|
+
if (t) n ? n = !1 : i === "\\" ? n = !0 : i === t && (t = "");
|
|
85
|
+
else if (i === "#" || i === "/" && e[r + 1] === "/") {
|
|
86
|
+
let t = e.indexOf("\n", r);
|
|
87
|
+
if (t < 0) return -1;
|
|
88
|
+
r = t;
|
|
89
|
+
} else if (i === "\"" || i === "'") t = i;
|
|
90
|
+
else if (e.startsWith("]]>", r)) return r;
|
|
91
|
+
}
|
|
92
|
+
return -1;
|
|
93
|
+
}
|
|
94
|
+
function re(e, t) {
|
|
95
|
+
try {
|
|
96
|
+
let { count: n } = JSON.parse(e), r = JSON.parse(t);
|
|
97
|
+
if (!Array.isArray(r) || !Number.isSafeInteger(n) || n !== r.length) return null;
|
|
98
|
+
let i = /* @__PURE__ */ new Set();
|
|
99
|
+
for (let e of r) {
|
|
100
|
+
if (!e || typeof e.name != "string" || !e.name || typeof e.code != "string" || i.has(e.name)) return null;
|
|
101
|
+
i.add(e.name);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
names: i,
|
|
105
|
+
revision: JSON.stringify(r.map((e) => ({
|
|
106
|
+
name: e.name,
|
|
107
|
+
code: e.code
|
|
108
|
+
})).sort((e, t) => e.name.localeCompare(t.name)))
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function ie(e, t) {
|
|
115
|
+
let n = e ?? "", r = X.exec(n), i = !!r && (!t || r[1] === "\n"), { content: a, attributes: o, end: s } = p(n.replace(Z, "$& "), { streaming: t }), c = a, l = !1, u = null, d = Q(c);
|
|
116
|
+
if (d >= 0 && c.startsWith(ne, d)) {
|
|
117
|
+
l = !0;
|
|
118
|
+
let e = c.indexOf("\n", d), t = c.length;
|
|
119
|
+
if (e >= 0) {
|
|
120
|
+
let n = Q(c.slice(e + 1));
|
|
121
|
+
n >= 0 && (t = e + 1 + n), u = re(c.slice(d + 17, e), c.slice(e + 1, t));
|
|
122
|
+
}
|
|
123
|
+
let n = d > 0 ? c.slice(0, d).replace(/\r?\n$/, "") : "", r = c.slice(t);
|
|
124
|
+
c = r ? `${n}\n${r}` : n;
|
|
125
|
+
}
|
|
126
|
+
let f = {};
|
|
127
|
+
if (!i && !l && !s) return {
|
|
128
|
+
program: c,
|
|
129
|
+
metadata: f,
|
|
130
|
+
scripts: /* @__PURE__ */ new Set(),
|
|
131
|
+
complete: !0,
|
|
132
|
+
isBundle: !1,
|
|
133
|
+
error: void 0
|
|
134
|
+
};
|
|
135
|
+
i && o.name !== void 0 && (f.name = o.name);
|
|
136
|
+
let m = l && !u ? "Invalid scripts bundle" : void 0;
|
|
137
|
+
return {
|
|
138
|
+
program: c,
|
|
139
|
+
metadata: f,
|
|
140
|
+
scripts: u?.names ?? /* @__PURE__ */ new Set(),
|
|
141
|
+
complete: !m && (s || !t || !i),
|
|
142
|
+
isBundle: !0,
|
|
143
|
+
error: t ? void 0 : m,
|
|
144
|
+
...u?.names.size ? { scriptRevision: u.revision } : {}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function ae({ response: e, isStreaming: t, result: n, evaluatedResult: r, library: i, querySnapshot: a, parseExceptionRef: o, runtimeErrorsRef: s, renderErrorsRef: l, onError: u }) {
|
|
148
|
+
let d = E([]), [f, p] = D(0), m = E(""), h = E(u);
|
|
149
|
+
return h.current = u, S(() => {
|
|
150
|
+
if (t) {
|
|
151
|
+
d.current = [], m.current !== "" && (m.current = "", h.current?.([]));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
let r = [];
|
|
155
|
+
o.current && r.push(o.current), e && !n?.meta.statementCount && !o.current && r.push({
|
|
156
|
+
source: "parser",
|
|
157
|
+
code: "parse-failed",
|
|
158
|
+
message: "Response could not be parsed as valid openui-lang",
|
|
159
|
+
hint: `The entire response must be valid openui-lang code starting with root = ${i.root ?? "Root"}(...)`
|
|
160
|
+
}), n?.meta.errors.length && r.push(...c(n.meta.errors, i.toJSONSchema(), Object.keys(i.components))), r.push(...s.current), r.push(...l.current), l.current = [], r.push(...a.__openui_errors ?? []), d.current = r;
|
|
161
|
+
let u = JSON.stringify(r);
|
|
162
|
+
if (u !== m.current) {
|
|
163
|
+
if (m.current = u, p((e) => e + 1), h.current) h.current(r);
|
|
164
|
+
else if (r.length > 0) for (let e of r) console.warn(`[openui] ${e.source}/${e.code}: ${e.message}`);
|
|
165
|
+
}
|
|
166
|
+
}, [
|
|
167
|
+
t,
|
|
168
|
+
e,
|
|
169
|
+
n,
|
|
170
|
+
r,
|
|
171
|
+
a,
|
|
172
|
+
i,
|
|
173
|
+
o,
|
|
174
|
+
s,
|
|
175
|
+
l
|
|
176
|
+
]), {
|
|
177
|
+
errorsRef: d,
|
|
178
|
+
errorRevision: f
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
var oe = "react-lang:stream", se = "streaming", ce = "settled", le = 0;
|
|
182
|
+
function ue() {
|
|
183
|
+
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : (le += 1, `openui-lang-${Date.now().toString(36)}-${le.toString(36)}`);
|
|
184
|
+
}
|
|
185
|
+
function de() {
|
|
186
|
+
return {
|
|
187
|
+
id: null,
|
|
188
|
+
updateIndex: 0,
|
|
189
|
+
lastResponse: null,
|
|
190
|
+
hasPublishedStreamingSnapshot: !1,
|
|
191
|
+
settled: !1,
|
|
192
|
+
lastSettledErrorKey: null,
|
|
193
|
+
startedAt: null,
|
|
194
|
+
durationMs: null
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function fe(e, t = Date.now()) {
|
|
198
|
+
e.startedAt ??= t, e.settled && (e.durationMs ??= Math.max(0, t - e.startedAt));
|
|
199
|
+
let n = e.durationMs ?? Math.max(0, t - e.startedAt);
|
|
200
|
+
return {
|
|
201
|
+
startedAt: e.startedAt,
|
|
202
|
+
elapsedMs: n,
|
|
203
|
+
...e.durationMs == null ? {} : { durationMs: e.durationMs }
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function pe(e, t, n, r = null, i = ue) {
|
|
207
|
+
return t ? (e.settled && Object.assign(e, de()), e.id ??= i(), e.hasPublishedStreamingSnapshot && e.lastResponse === n ? null : (e.hasPublishedStreamingSnapshot = !0, e.lastResponse = n, e.updateIndex += 1, {
|
|
208
|
+
id: e.id,
|
|
209
|
+
phase: se,
|
|
210
|
+
updateIndex: e.updateIndex
|
|
211
|
+
})) : !e.id || e.settled && (r === null || e.lastSettledErrorKey === r) ? null : (e.updateIndex += 1, e.settled = !0, e.lastSettledErrorKey = r, {
|
|
212
|
+
id: e.id,
|
|
213
|
+
phase: ce,
|
|
214
|
+
updateIndex: e.updateIndex
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function me(e) {
|
|
218
|
+
if (e) return {
|
|
219
|
+
incomplete: e.meta.incomplete,
|
|
220
|
+
unresolved: e.meta.unresolved,
|
|
221
|
+
orphaned: e.meta.orphaned,
|
|
222
|
+
statementCount: e.meta.statementCount
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function he({ response: e, isStreaming: t, result: n, errorsRef: r, errorRevision: i, publish: a = !0, __libraryId: o }) {
|
|
226
|
+
let s = E(de());
|
|
227
|
+
S(() => {
|
|
228
|
+
if (!a) return;
|
|
229
|
+
let i = r.current, c = t ? null : JSON.stringify(i), l = pe(s.current, t, e, c), u = o === void 0 ? {} : { __libraryId: o };
|
|
230
|
+
if (t) {
|
|
231
|
+
l && g.info({
|
|
232
|
+
id: l.id,
|
|
233
|
+
kind: oe,
|
|
234
|
+
phase: l.phase,
|
|
235
|
+
updateIndex: l.updateIndex,
|
|
236
|
+
response: e,
|
|
237
|
+
responseLength: e?.length ?? 0,
|
|
238
|
+
parser: me(n),
|
|
239
|
+
...fe(s.current),
|
|
240
|
+
...u,
|
|
241
|
+
message: "OpenUI Lang is streaming"
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
l?.phase === "settled" && g(i.length > 0 ? "error" : "info", {
|
|
246
|
+
id: l.id,
|
|
247
|
+
kind: oe,
|
|
248
|
+
phase: ce,
|
|
249
|
+
updateIndex: l.updateIndex,
|
|
250
|
+
response: e,
|
|
251
|
+
responseLength: e?.length ?? 0,
|
|
252
|
+
parser: me(n),
|
|
253
|
+
errors: i,
|
|
254
|
+
errorCount: i.length,
|
|
255
|
+
...fe(s.current),
|
|
256
|
+
...u,
|
|
257
|
+
message: i.length > 0 ? `OpenUI Lang settled with ${i.length} error${i.length === 1 ? "" : "s"}` : "OpenUI Lang settled"
|
|
258
|
+
});
|
|
259
|
+
}, [
|
|
260
|
+
a,
|
|
261
|
+
t,
|
|
262
|
+
e,
|
|
263
|
+
n,
|
|
264
|
+
r,
|
|
265
|
+
i,
|
|
266
|
+
o
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
function ge(e) {
|
|
270
|
+
return e && typeof e == "object" && !Array.isArray(e) && "value" in e ? e.value : e;
|
|
271
|
+
}
|
|
272
|
+
function _e({ response: n, library: r, isStreaming: s, onAction: c, onStateUpdate: d, initialState: f, toolProvider: p, onError: m, publishObservability: h }, g) {
|
|
273
|
+
let _ = T(() => ie(n, s), [n, s]), v = s || !_.complete || !!_.error, y = _.isBundle && v, x = E({
|
|
274
|
+
revision: null,
|
|
275
|
+
names: /* @__PURE__ */ new Set()
|
|
276
|
+
});
|
|
277
|
+
v || (x.current = {
|
|
278
|
+
revision: "scriptRevision" in _ ? _.scriptRevision ?? null : null,
|
|
279
|
+
names: _.scripts
|
|
280
|
+
});
|
|
281
|
+
let C = x.current.revision, w = x.current.names, D = T(() => r.toJSONSchema(), [r]), O = T(() => o(D, r.root), [D, r.root]), k = T(() => Object.fromEntries(Object.entries(D.functions ?? {}).flatMap(([e, t]) => {
|
|
282
|
+
let n = r.functions?.[e]?.fn;
|
|
283
|
+
return n ? [[e, {
|
|
284
|
+
...t,
|
|
285
|
+
fn: n
|
|
286
|
+
}]] : [];
|
|
287
|
+
})), [D, r.functions]), A = E(null), j = T(() => {
|
|
288
|
+
if (A.current = _.error ? {
|
|
289
|
+
source: "parser",
|
|
290
|
+
code: "parse-failed",
|
|
291
|
+
message: _.error
|
|
292
|
+
} : null, !_.program) return null;
|
|
293
|
+
try {
|
|
294
|
+
return O.set(_.program, !s);
|
|
295
|
+
} catch (e) {
|
|
296
|
+
return A.current = {
|
|
297
|
+
source: "parser",
|
|
298
|
+
code: "parse-exception",
|
|
299
|
+
message: `Parser crashed: ${e instanceof Error ? e.message : String(e)}`,
|
|
300
|
+
hint: "The response may contain syntax the parser cannot handle"
|
|
301
|
+
}, null;
|
|
302
|
+
}
|
|
303
|
+
}, [
|
|
304
|
+
O,
|
|
305
|
+
_.program,
|
|
306
|
+
_.error,
|
|
307
|
+
s
|
|
308
|
+
]), M = T(() => a(), []), N = T(() => i(p ?? null), [p]);
|
|
309
|
+
S(() => (N.activate(), () => N.dispose()), [N]);
|
|
310
|
+
let P = E(!1), te = E(Symbol());
|
|
311
|
+
S(() => {
|
|
312
|
+
if (!j?.stateDeclarations && !f) return;
|
|
313
|
+
let e = `${JSON.stringify(j?.stateDeclarations)}::${JSON.stringify(f)}`;
|
|
314
|
+
if (te.current === e) return;
|
|
315
|
+
te.current = e;
|
|
316
|
+
let t = {};
|
|
317
|
+
if (f) for (let [e, n] of Object.entries(f)) e.startsWith("$") ? t[e] = n : M.set(e, n);
|
|
318
|
+
P.current = !0, M.initialize(j?.stateDeclarations ?? {}, t), P.current = !1;
|
|
319
|
+
}, [
|
|
320
|
+
j?.stateDeclarations,
|
|
321
|
+
M,
|
|
322
|
+
f
|
|
323
|
+
]);
|
|
324
|
+
let F = ee(M.subscribe, M.getSnapshot, M.getSnapshot), I = ee(N.subscribe, N.getSnapshot, N.getSnapshot), L = T(() => ({
|
|
325
|
+
getState: (e) => ge(M.get(e)),
|
|
326
|
+
resolveRef: (e) => N.getMutationResult(e) || N.getResult(e),
|
|
327
|
+
functions: k,
|
|
328
|
+
actions: D.actions
|
|
329
|
+
}), [
|
|
330
|
+
M,
|
|
331
|
+
N,
|
|
332
|
+
k,
|
|
333
|
+
D.actions
|
|
334
|
+
]);
|
|
335
|
+
S(() => {
|
|
336
|
+
if (v) return;
|
|
337
|
+
let e = (j?.queryStatements ?? []).map((e) => {
|
|
338
|
+
let t = {}, n = e.toolAST ? l(e.toolAST, L) : "";
|
|
339
|
+
if (e.deps) for (let n of e.deps) t[n] = F[n];
|
|
340
|
+
return w.has(n) && (t.__openuiScriptRevision = C), {
|
|
341
|
+
statementId: e.statementId,
|
|
342
|
+
toolName: n,
|
|
343
|
+
args: e.argsAST ? l(e.argsAST, L) : null,
|
|
344
|
+
defaults: e.defaultsAST ? l(e.defaultsAST, L) : null,
|
|
345
|
+
refreshInterval: e.refreshAST ? l(e.refreshAST, L) : void 0,
|
|
346
|
+
deps: Object.keys(t).length > 0 ? t : void 0,
|
|
347
|
+
complete: e.complete
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
N.evaluateQueries(e);
|
|
351
|
+
}, [
|
|
352
|
+
v,
|
|
353
|
+
j?.queryStatements,
|
|
354
|
+
L,
|
|
355
|
+
N,
|
|
356
|
+
F,
|
|
357
|
+
C,
|
|
358
|
+
w
|
|
359
|
+
]), S(() => {
|
|
360
|
+
if (v) return;
|
|
361
|
+
let e = (j?.mutationStatements ?? []).map((e) => ({
|
|
362
|
+
statementId: e.statementId,
|
|
363
|
+
toolName: e.toolAST ? l(e.toolAST, L) : ""
|
|
364
|
+
}));
|
|
365
|
+
N.registerMutations(e);
|
|
366
|
+
}, [
|
|
367
|
+
v,
|
|
368
|
+
j?.mutationStatements,
|
|
369
|
+
L,
|
|
370
|
+
N
|
|
371
|
+
]);
|
|
372
|
+
let R = E({
|
|
373
|
+
onAction: c,
|
|
374
|
+
onStateUpdate: d
|
|
375
|
+
});
|
|
376
|
+
R.current = {
|
|
377
|
+
onAction: c,
|
|
378
|
+
onStateUpdate: d
|
|
379
|
+
};
|
|
380
|
+
let z = E(j);
|
|
381
|
+
z.current = j;
|
|
382
|
+
let B = E(null);
|
|
383
|
+
S(() => (B.current = M.getSnapshot(), M.subscribe(() => {
|
|
384
|
+
let e = M.getSnapshot();
|
|
385
|
+
P.current || e === B.current || (B.current = null, R.current.onStateUpdate?.(e));
|
|
386
|
+
})), [M]);
|
|
387
|
+
let V = b((e, t) => {
|
|
388
|
+
if (!e) return ge(M.get(t));
|
|
389
|
+
let n = M.get(e);
|
|
390
|
+
if (!(!n || typeof n != "object" || Array.isArray(n))) return ge(n[t]);
|
|
391
|
+
}, [M]), H = b((e, t, n, r, i = !0) => {
|
|
392
|
+
let a = {
|
|
393
|
+
value: r,
|
|
394
|
+
componentType: t
|
|
395
|
+
};
|
|
396
|
+
if (!e) M.set(n, a);
|
|
397
|
+
else {
|
|
398
|
+
let t = M.get(e), r = t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
399
|
+
M.set(e, {
|
|
400
|
+
...r,
|
|
401
|
+
[n]: a
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
i && R.current.onStateUpdate?.(M.getSnapshot());
|
|
405
|
+
}, [M]), U = b((e) => {
|
|
406
|
+
if (e) {
|
|
407
|
+
let t = M.get(e);
|
|
408
|
+
if (t && typeof t == "object" && !Array.isArray(t)) return { [e]: t };
|
|
409
|
+
}
|
|
410
|
+
return M.getSnapshot();
|
|
411
|
+
}, [M]), W = b(async (n, r, i) => {
|
|
412
|
+
if (y) return;
|
|
413
|
+
let { onAction: a } = R.current;
|
|
414
|
+
if (i && !("steps" in i)) {
|
|
415
|
+
let e = U(r), o = i.type || t.ContinueConversation;
|
|
416
|
+
if (D.actions && Object.prototype.hasOwnProperty.call(D.actions, o)) return;
|
|
417
|
+
let s = { ...i.params || {} };
|
|
418
|
+
i.url && (s.url = i.url), i.context && (s.context = i.context), a?.({
|
|
419
|
+
type: o,
|
|
420
|
+
params: s,
|
|
421
|
+
humanFriendlyMessage: n,
|
|
422
|
+
formState: e,
|
|
423
|
+
formName: r
|
|
424
|
+
});
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
let o = i;
|
|
428
|
+
if (o?.steps) {
|
|
429
|
+
for (let n of o.steps) switch (n.type) {
|
|
430
|
+
case e.Run:
|
|
431
|
+
if (n.refType === "mutation") {
|
|
432
|
+
let e = z.current?.mutationStatements?.find((e) => e.statementId === n.statementId), t = e?.argsAST ? l(e.argsAST, L) : {};
|
|
433
|
+
if (!await N.fireMutation(n.statementId, t)) return;
|
|
434
|
+
} else N.invalidate([n.statementId]);
|
|
435
|
+
break;
|
|
436
|
+
case e.ToAssistant:
|
|
437
|
+
a?.({
|
|
438
|
+
type: t.ContinueConversation,
|
|
439
|
+
params: n.context === void 0 ? {} : { context: n.context },
|
|
440
|
+
humanFriendlyMessage: n.message,
|
|
441
|
+
formState: U(r),
|
|
442
|
+
formName: r
|
|
443
|
+
});
|
|
444
|
+
break;
|
|
445
|
+
case e.OpenUrl:
|
|
446
|
+
a?.({
|
|
447
|
+
type: t.OpenUrl,
|
|
448
|
+
params: { url: n.url },
|
|
449
|
+
humanFriendlyMessage: "",
|
|
450
|
+
formState: U(r),
|
|
451
|
+
formName: r
|
|
452
|
+
});
|
|
453
|
+
break;
|
|
454
|
+
case "custom_action":
|
|
455
|
+
a?.({
|
|
456
|
+
type: n.name,
|
|
457
|
+
params: n.params,
|
|
458
|
+
humanFriendlyMessage: "",
|
|
459
|
+
formState: U(r),
|
|
460
|
+
formName: r
|
|
461
|
+
});
|
|
462
|
+
break;
|
|
463
|
+
case e.Set: {
|
|
464
|
+
if (!n.valueAST) {
|
|
465
|
+
console.warn(`[openui] Set action for ${n.target} has no valueAST — skipping`);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
let e = l(n.valueAST, L);
|
|
469
|
+
M.set(n.target, e);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
case e.Reset: {
|
|
473
|
+
let e = z.current?.stateDeclarations ?? {};
|
|
474
|
+
for (let t of n.targets) M.set(t, e[t] ?? null, { pristine: !0 });
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
a?.({
|
|
481
|
+
type: t.ContinueConversation,
|
|
482
|
+
params: {},
|
|
483
|
+
humanFriendlyMessage: n,
|
|
484
|
+
formState: U(r),
|
|
485
|
+
formName: r
|
|
486
|
+
});
|
|
487
|
+
}, [
|
|
488
|
+
y,
|
|
489
|
+
N,
|
|
490
|
+
L,
|
|
491
|
+
U,
|
|
492
|
+
M,
|
|
493
|
+
D.actions
|
|
494
|
+
]), G = E([]), K = E(s);
|
|
495
|
+
K.current = s;
|
|
496
|
+
let q = b((e) => {
|
|
497
|
+
K.current || G.current.push(e);
|
|
498
|
+
}, []), J = I.__openui_loading.length > 0 || s && y && (j?.queryStatements.length ?? 0) > 0, Y = T(() => I.__openui_errors.filter((e) => e.source === "query"), [I]), ne = b(() => {
|
|
499
|
+
y || N.invalidate(Y.map((e) => e.statementId));
|
|
500
|
+
}, [
|
|
501
|
+
y,
|
|
502
|
+
N,
|
|
503
|
+
Y
|
|
504
|
+
]), X = E([]), Z = T(() => {
|
|
505
|
+
if (!j?.root && !j?.rootExpression) return j;
|
|
506
|
+
let e = [], t = {
|
|
507
|
+
ctx: L,
|
|
508
|
+
library: r,
|
|
509
|
+
store: M,
|
|
510
|
+
errors: e
|
|
511
|
+
};
|
|
512
|
+
try {
|
|
513
|
+
let n = u(j, t);
|
|
514
|
+
return X.current = e, {
|
|
515
|
+
...j,
|
|
516
|
+
root: n
|
|
517
|
+
};
|
|
518
|
+
} catch (t) {
|
|
519
|
+
let n = t instanceof Error ? t.message : String(t);
|
|
520
|
+
return e.push({
|
|
521
|
+
source: "runtime",
|
|
522
|
+
code: "runtime-error",
|
|
523
|
+
message: `Prop evaluation failed: ${n}`
|
|
524
|
+
}), X.current = e, j;
|
|
525
|
+
}
|
|
526
|
+
}, [
|
|
527
|
+
j,
|
|
528
|
+
L,
|
|
529
|
+
r,
|
|
530
|
+
M,
|
|
531
|
+
F,
|
|
532
|
+
I
|
|
533
|
+
]), Q = T(() => ({
|
|
534
|
+
library: r,
|
|
535
|
+
renderNode: g,
|
|
536
|
+
triggerAction: W,
|
|
537
|
+
isStreaming: v,
|
|
538
|
+
getFieldValue: V,
|
|
539
|
+
setFieldValue: H,
|
|
540
|
+
store: M,
|
|
541
|
+
evaluationContext: L,
|
|
542
|
+
reportError: q,
|
|
543
|
+
isQueryLoading: J
|
|
544
|
+
}), [
|
|
545
|
+
r,
|
|
546
|
+
g,
|
|
547
|
+
v,
|
|
548
|
+
J,
|
|
549
|
+
W,
|
|
550
|
+
V,
|
|
551
|
+
H,
|
|
552
|
+
M,
|
|
553
|
+
L,
|
|
554
|
+
q
|
|
555
|
+
]), { errorsRef: re, errorRevision: oe } = ae({
|
|
556
|
+
response: _.program,
|
|
557
|
+
isStreaming: s,
|
|
558
|
+
result: j,
|
|
559
|
+
evaluatedResult: Z,
|
|
560
|
+
library: r,
|
|
561
|
+
querySnapshot: I,
|
|
562
|
+
parseExceptionRef: A,
|
|
563
|
+
runtimeErrorsRef: X,
|
|
564
|
+
renderErrorsRef: G,
|
|
565
|
+
onError: m
|
|
566
|
+
});
|
|
567
|
+
return he({
|
|
568
|
+
response: _.program,
|
|
569
|
+
isStreaming: s,
|
|
570
|
+
result: j,
|
|
571
|
+
errorsRef: re,
|
|
572
|
+
errorRevision: oe,
|
|
573
|
+
publish: h,
|
|
574
|
+
__libraryId: r.__libraryId
|
|
575
|
+
}), {
|
|
576
|
+
result: Z,
|
|
577
|
+
parseResult: j,
|
|
578
|
+
contextValue: Q,
|
|
579
|
+
isQueryLoading: J,
|
|
580
|
+
queryErrors: Y,
|
|
581
|
+
retryQueries: ne
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
var ve = class extends _ {
|
|
585
|
+
lastValidChildren = null;
|
|
586
|
+
constructor(e) {
|
|
587
|
+
super(e), this.state = { hasError: !1 };
|
|
588
|
+
}
|
|
589
|
+
static getDerivedStateFromError() {
|
|
590
|
+
return { hasError: !0 };
|
|
591
|
+
}
|
|
592
|
+
componentDidMount() {
|
|
593
|
+
this.state.hasError || (this.lastValidChildren = this.props.children);
|
|
594
|
+
}
|
|
595
|
+
componentDidUpdate(e) {
|
|
596
|
+
this.state.hasError || (this.lastValidChildren = this.props.children), this.state.hasError && e.children !== this.props.children && this.setState({ hasError: !1 });
|
|
597
|
+
}
|
|
598
|
+
componentDidCatch(e) {
|
|
599
|
+
let t = this.props.componentName ?? "Unknown";
|
|
600
|
+
this.props.onError?.({
|
|
601
|
+
source: "runtime",
|
|
602
|
+
code: "render-error",
|
|
603
|
+
component: t,
|
|
604
|
+
message: `Component ${t} render failed: ${e.message}`
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
render() {
|
|
608
|
+
return this.state.hasError ? this.lastValidChildren : this.props.children;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
function ye(e) {
|
|
612
|
+
if (e == null) return null;
|
|
613
|
+
if (typeof e == "string") return e;
|
|
614
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
615
|
+
if (Array.isArray(e)) return e.map((e, t) => /* @__PURE__ */ k(v, { children: ye(e) }, t));
|
|
616
|
+
if (typeof e == "object" && e) {
|
|
617
|
+
let t = e;
|
|
618
|
+
if (t.type === "element") return /* @__PURE__ */ k(be, { node: t });
|
|
619
|
+
}
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
function be({ node: e }) {
|
|
623
|
+
let { library: t, reportError: n } = B(), r = t.components[e.typeName]?.component;
|
|
624
|
+
return r ? /* @__PURE__ */ k(ve, {
|
|
625
|
+
componentName: e.typeName,
|
|
626
|
+
onError: n,
|
|
627
|
+
children: /* @__PURE__ */ k(xe, {
|
|
628
|
+
el: e,
|
|
629
|
+
Comp: r
|
|
630
|
+
})
|
|
631
|
+
}) : null;
|
|
632
|
+
}
|
|
633
|
+
function xe({ el: e, Comp: t }) {
|
|
634
|
+
let n = V();
|
|
635
|
+
return /* @__PURE__ */ k(t, {
|
|
636
|
+
props: e.props,
|
|
637
|
+
renderNode: n,
|
|
638
|
+
statementId: e.statementId
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
var Se = !1;
|
|
642
|
+
function Ce() {
|
|
643
|
+
if (Se || typeof document > "u") return;
|
|
644
|
+
Se = !0;
|
|
645
|
+
let e = document.createElement("style");
|
|
646
|
+
e.textContent = "@keyframes openui-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }", document.head.appendChild(e);
|
|
647
|
+
}
|
|
648
|
+
var we = () => /* @__PURE__ */ k("div", {
|
|
649
|
+
role: "status",
|
|
650
|
+
"aria-label": "Loading data",
|
|
651
|
+
style: {
|
|
652
|
+
position: "absolute",
|
|
653
|
+
top: 8,
|
|
654
|
+
right: 8,
|
|
655
|
+
width: 16,
|
|
656
|
+
height: 16,
|
|
657
|
+
border: "2px solid #e5e7eb",
|
|
658
|
+
borderTopColor: "#3b82f6",
|
|
659
|
+
borderRadius: "50%",
|
|
660
|
+
animation: "openui-spin 0.6s linear infinite",
|
|
661
|
+
zIndex: 10
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
function Te({ response: e, library: t, isStreaming: r = !1, onAction: i, onStateUpdate: a, initialState: o, onParseResult: s, toolProvider: c, queryLoader: l, children: u, onError: f, publishObservability: p }) {
|
|
665
|
+
w(() => {
|
|
666
|
+
Ce();
|
|
667
|
+
}, []);
|
|
668
|
+
let m = E(s);
|
|
669
|
+
m.current = s;
|
|
670
|
+
let h = E(c);
|
|
671
|
+
h.current = c;
|
|
672
|
+
let g = E({ async callTool(e, t) {
|
|
673
|
+
let r = h.current ?? null;
|
|
674
|
+
if (r == null) throw Error("[openui] toolProvider is null");
|
|
675
|
+
if (typeof r.callTool == "function") return d(await r.callTool({
|
|
676
|
+
name: e,
|
|
677
|
+
arguments: t
|
|
678
|
+
}));
|
|
679
|
+
let i = r, a = i[e];
|
|
680
|
+
if (!a) throw new n(e, Object.keys(i));
|
|
681
|
+
return a(t);
|
|
682
|
+
} }), { result: _, parseResult: v, contextValue: y, isQueryLoading: b, queryErrors: x, retryQueries: C } = _e({
|
|
683
|
+
response: e,
|
|
684
|
+
library: t,
|
|
685
|
+
isStreaming: r,
|
|
686
|
+
onAction: i,
|
|
687
|
+
onStateUpdate: a,
|
|
688
|
+
initialState: o,
|
|
689
|
+
toolProvider: c == null ? null : g.current,
|
|
690
|
+
onError: f,
|
|
691
|
+
publishObservability: p
|
|
692
|
+
}, ye);
|
|
693
|
+
S(() => {
|
|
694
|
+
m.current?.(v);
|
|
695
|
+
}, [v]);
|
|
696
|
+
let D = T(() => ({
|
|
697
|
+
isLoading: b,
|
|
698
|
+
errors: x,
|
|
699
|
+
retry: C,
|
|
700
|
+
isRetrying: x.length > 0 && b
|
|
701
|
+
}), [
|
|
702
|
+
b,
|
|
703
|
+
x,
|
|
704
|
+
C
|
|
705
|
+
]), ee = {
|
|
706
|
+
root: _?.root ?? null,
|
|
707
|
+
query: D,
|
|
708
|
+
queryLoader: l
|
|
709
|
+
};
|
|
710
|
+
return /* @__PURE__ */ k(z.Provider, {
|
|
711
|
+
value: y,
|
|
712
|
+
children: /* @__PURE__ */ k(Ee.Provider, {
|
|
713
|
+
value: ee,
|
|
714
|
+
children: u
|
|
715
|
+
})
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
var Ee = y(null);
|
|
719
|
+
function $() {
|
|
720
|
+
let e = x(Ee);
|
|
721
|
+
if (!e) throw Error("Renderer slots must be used within Renderer.Root or Renderer.");
|
|
722
|
+
return e;
|
|
723
|
+
}
|
|
724
|
+
function De() {
|
|
725
|
+
return $().query;
|
|
726
|
+
}
|
|
727
|
+
function Oe({ style: e, hidden: t, ...n }) {
|
|
728
|
+
let { root: r, query: i } = $();
|
|
729
|
+
return r ? /* @__PURE__ */ k("div", {
|
|
730
|
+
...n,
|
|
731
|
+
"aria-busy": i.isLoading,
|
|
732
|
+
hidden: t || i.errors.length > 0,
|
|
733
|
+
style: {
|
|
734
|
+
opacity: i.isLoading ? .7 : 1,
|
|
735
|
+
transition: "opacity 0.2s ease",
|
|
736
|
+
...e
|
|
737
|
+
},
|
|
738
|
+
children: /* @__PURE__ */ k(be, { node: r })
|
|
739
|
+
}) : null;
|
|
740
|
+
}
|
|
741
|
+
function ke({ children: e }) {
|
|
742
|
+
let { query: { isLoading: t, errors: n }, queryLoader: r } = $();
|
|
743
|
+
return !t || n.length > 0 ? null : /* @__PURE__ */ k(O, { children: e === void 0 ? r ?? /* @__PURE__ */ k(we, {}) : e });
|
|
744
|
+
}
|
|
745
|
+
function Ae({ children: e }) {
|
|
746
|
+
let { errors: t } = De();
|
|
747
|
+
return t.length === 0 ? null : /* @__PURE__ */ k(O, { children: e });
|
|
748
|
+
}
|
|
749
|
+
function je({ children: e, onClick: t, disabled: n, ...r }) {
|
|
750
|
+
let { retry: i, isLoading: a, errors: o } = De(), s = n || a || o.length === 0;
|
|
751
|
+
return /* @__PURE__ */ k("button", {
|
|
752
|
+
type: "button",
|
|
753
|
+
...r,
|
|
754
|
+
disabled: s,
|
|
755
|
+
onClick: (e) => {
|
|
756
|
+
s || e.defaultPrevented || (t?.(e), e.defaultPrevented || i());
|
|
757
|
+
},
|
|
758
|
+
children: e
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
function Me() {
|
|
762
|
+
let { root: e, query: t, queryLoader: n } = $();
|
|
763
|
+
return e ? /* @__PURE__ */ A("div", {
|
|
764
|
+
"aria-busy": t.isLoading,
|
|
765
|
+
style: { position: "relative" },
|
|
766
|
+
children: [t.isLoading && (n ?? /* @__PURE__ */ k(we, {})), /* @__PURE__ */ k("div", {
|
|
767
|
+
style: {
|
|
768
|
+
opacity: t.isLoading ? .7 : 1,
|
|
769
|
+
transition: "opacity 0.2s ease"
|
|
770
|
+
},
|
|
771
|
+
children: /* @__PURE__ */ k(be, { node: e })
|
|
772
|
+
})]
|
|
773
|
+
}) : null;
|
|
774
|
+
}
|
|
775
|
+
function Ne({ children: e, ...t }) {
|
|
776
|
+
return /* @__PURE__ */ k(Te, {
|
|
777
|
+
...t,
|
|
778
|
+
children: e === void 0 ? /* @__PURE__ */ k(Me, {}) : e
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
var Pe = Object.assign(Ne, {
|
|
782
|
+
Root: Te,
|
|
783
|
+
Content: Oe,
|
|
784
|
+
QueryLoading: ke,
|
|
785
|
+
QueryError: Ae,
|
|
786
|
+
Retry: je
|
|
787
|
+
});
|
|
788
|
+
function Fe(e) {
|
|
789
|
+
return f(e), e;
|
|
790
|
+
}
|
|
791
|
+
function Ie(e, t) {
|
|
792
|
+
let n = B(), r = J();
|
|
793
|
+
return m(e, t, n.store ?? null, n.evaluationContext ?? null, (e) => n.getFieldValue(r, e), (e, t) => n.setFieldValue(r, void 0, e, t));
|
|
794
|
+
}
|
|
795
|
+
var Le = y(null);
|
|
796
|
+
function Re() {
|
|
797
|
+
return x(Le);
|
|
798
|
+
}
|
|
799
|
+
function ze() {
|
|
800
|
+
let [e, t] = D({}), n = E(e);
|
|
801
|
+
n.current = e;
|
|
802
|
+
let r = E({}), i = b((e) => n.current[e], []), a = b((e, n, r) => {
|
|
803
|
+
let i = h(n, r);
|
|
804
|
+
return t((t) => t[e] === i ? t : {
|
|
805
|
+
...t,
|
|
806
|
+
[e]: i
|
|
807
|
+
}), !i;
|
|
808
|
+
}, []), o = b((e, t, n) => {
|
|
809
|
+
r.current[e] = {
|
|
810
|
+
rules: t,
|
|
811
|
+
getValue: n
|
|
812
|
+
};
|
|
813
|
+
}, []), s = b((e) => {
|
|
814
|
+
delete r.current[e];
|
|
815
|
+
}, []), c = b(() => {
|
|
816
|
+
let e = !0, n = {};
|
|
817
|
+
for (let [t, i] of Object.entries(r.current)) {
|
|
818
|
+
let r = i.getValue();
|
|
819
|
+
typeof r == "object" && r && "value" in r && "componentType" in r && (r = r.value);
|
|
820
|
+
let a = h(r, i.rules);
|
|
821
|
+
n[t] = a, a && (e = !1);
|
|
822
|
+
}
|
|
823
|
+
return t(n), e;
|
|
824
|
+
}, []), l = b((e) => {
|
|
825
|
+
t((t) => t[e] === void 0 ? t : {
|
|
826
|
+
...t,
|
|
827
|
+
[e]: void 0
|
|
828
|
+
});
|
|
829
|
+
}, []);
|
|
830
|
+
return T(() => ({
|
|
831
|
+
errors: e,
|
|
832
|
+
getFieldError: i,
|
|
833
|
+
validateField: a,
|
|
834
|
+
registerField: o,
|
|
835
|
+
unregisterField: s,
|
|
836
|
+
validateForm: c,
|
|
837
|
+
clearFieldError: l
|
|
838
|
+
}), [
|
|
839
|
+
e,
|
|
840
|
+
i,
|
|
841
|
+
a,
|
|
842
|
+
o,
|
|
843
|
+
s,
|
|
844
|
+
c,
|
|
845
|
+
l
|
|
846
|
+
]);
|
|
847
|
+
}
|
|
848
|
+
var Be = y(null);
|
|
849
|
+
function Ve() {
|
|
850
|
+
let e = x(Be);
|
|
851
|
+
if (!e) throw Error("Preview slots must be used within WithPreviewRenderer.Root or WithPreviewRenderer.");
|
|
852
|
+
return e;
|
|
853
|
+
}
|
|
854
|
+
function He() {
|
|
855
|
+
return Ve().state;
|
|
856
|
+
}
|
|
857
|
+
function Ue({ open: e, defaultOpen: t = !1, onOpenChange: n, onMetadata: r, children: i, ...a }) {
|
|
858
|
+
let [o, s] = D(t), c = e ?? o, l = a.isStreaming === !0, u = C(), d = T(() => ie(a.response, l), [a.response, l]).metadata.name, f = T(() => d === void 0 ? {} : { name: d }, [d]), p = E(r);
|
|
859
|
+
p.current = r, S(() => {
|
|
860
|
+
p.current?.(f);
|
|
861
|
+
}, [f]);
|
|
862
|
+
let m = b((t) => {
|
|
863
|
+
t !== c && (e === void 0 && s(t), n?.(t));
|
|
864
|
+
}, [
|
|
865
|
+
e,
|
|
866
|
+
c,
|
|
867
|
+
n
|
|
868
|
+
]), h = b(() => m(!0), [m]), g = b(() => m(!1), [m]), _ = T(() => ({
|
|
869
|
+
metadata: f,
|
|
870
|
+
isOpen: c,
|
|
871
|
+
isStreaming: l,
|
|
872
|
+
contentId: u,
|
|
873
|
+
open: h,
|
|
874
|
+
close: g
|
|
875
|
+
}), [
|
|
876
|
+
f,
|
|
877
|
+
c,
|
|
878
|
+
l,
|
|
879
|
+
u,
|
|
880
|
+
h,
|
|
881
|
+
g
|
|
882
|
+
]);
|
|
883
|
+
return /* @__PURE__ */ k(Be.Provider, {
|
|
884
|
+
value: {
|
|
885
|
+
state: _,
|
|
886
|
+
rendererProps: a
|
|
887
|
+
},
|
|
888
|
+
children: i
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
function We({ children: e, onClick: t, disabled: n, ...r }) {
|
|
892
|
+
let { metadata: i, isOpen: a, isStreaming: o, contentId: s, open: c, close: l } = He();
|
|
893
|
+
return /* @__PURE__ */ k("button", {
|
|
894
|
+
type: "button",
|
|
895
|
+
...r,
|
|
896
|
+
disabled: n,
|
|
897
|
+
"aria-expanded": a,
|
|
898
|
+
"aria-controls": a ? s : void 0,
|
|
899
|
+
onClick: (e) => {
|
|
900
|
+
n || e.defaultPrevented || (t?.(e), e.defaultPrevented || (a ? l : c)());
|
|
901
|
+
},
|
|
902
|
+
children: e === void 0 ? `${i.name || "Untitled artifact"}${o ? " (generating…)" : ""}` : e
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
function Ge({ children: e, onClick: t, disabled: n, ...r }) {
|
|
906
|
+
let { metadata: i, close: a } = He();
|
|
907
|
+
return /* @__PURE__ */ k("button", {
|
|
908
|
+
type: "button",
|
|
909
|
+
...r,
|
|
910
|
+
disabled: n,
|
|
911
|
+
onClick: (e) => {
|
|
912
|
+
n || e.defaultPrevented || (t?.(e), e.defaultPrevented || a());
|
|
913
|
+
},
|
|
914
|
+
children: e === void 0 ? `Close ${i.name || "Untitled artifact"}` : e
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
function Ke({ children: e, style: t, ...n }) {
|
|
918
|
+
let { state: r, rendererProps: i } = Ve();
|
|
919
|
+
return r.isOpen ? /* @__PURE__ */ k("section", {
|
|
920
|
+
"aria-label": r.metadata.name || "Untitled artifact",
|
|
921
|
+
...n,
|
|
922
|
+
id: r.contentId,
|
|
923
|
+
style: {
|
|
924
|
+
position: "relative",
|
|
925
|
+
...t
|
|
926
|
+
},
|
|
927
|
+
children: e === void 0 ? /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(Ge, {}), /* @__PURE__ */ k(Pe, { ...i })] }) : /* @__PURE__ */ k(Pe, {
|
|
928
|
+
...i,
|
|
929
|
+
children: e
|
|
930
|
+
})
|
|
931
|
+
}) : null;
|
|
932
|
+
}
|
|
933
|
+
function qe({ children: e, ...t }) {
|
|
934
|
+
return /* @__PURE__ */ k(Ue, {
|
|
935
|
+
...t,
|
|
936
|
+
children: e === void 0 ? /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(We, {}), /* @__PURE__ */ k(Ke, {})] }) : e
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
var Je = Object.assign(qe, {
|
|
940
|
+
Root: Ue,
|
|
941
|
+
Trigger: We,
|
|
942
|
+
Content: Ke,
|
|
943
|
+
Close: Ge
|
|
944
|
+
});
|
|
945
|
+
//#endregion
|
|
946
|
+
export { q as FormNameContext, Le as FormValidationContext, Pe as Renderer, Je as WithPreviewRenderer, I as createLibrary$1, F as defineComponent$1, Fe as reactive, ze as useCreateFormValidation, J as useFormName, Re as useFormValidation, G as useGetFieldValue, W as useIsQueryLoading, U as useIsStreaming, V as useRenderNode, He as useRendererPreview, De as useRendererQuery, Y as useSetDefaultValue, K as useSetFieldValue, Ie as useStateField, H as useTriggerAction };
|