@anvia/react-ui 1.3.0 → 1.3.1

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 (131) hide show
  1. package/dist/attachment/index.d.ts +3 -21
  2. package/dist/attachment/index.js +3 -12
  3. package/dist/attachment-DsKTPumt.js +89 -0
  4. package/dist/attachment-DsKTPumt.js.map +1 -0
  5. package/dist/chat/index.d.ts +3 -152
  6. package/dist/chat/index.js +3 -25
  7. package/dist/chat-CAnvUEAv.js +1210 -0
  8. package/dist/chat-CAnvUEAv.js.map +1 -0
  9. package/dist/completion/index.d.ts +3 -29
  10. package/dist/completion/index.js +3 -16
  11. package/dist/completion-DDTKoZRJ.js +124 -0
  12. package/dist/completion-DDTKoZRJ.js.map +1 -0
  13. package/dist/connection-DeNq8wHS.js +203 -0
  14. package/dist/connection-DeNq8wHS.js.map +1 -0
  15. package/dist/contexts-B4ijG24z.js +212 -0
  16. package/dist/contexts-B4ijG24z.js.map +1 -0
  17. package/dist/elements-D4vmkkF8.js +19 -0
  18. package/dist/elements-D4vmkkF8.js.map +1 -0
  19. package/dist/graph-explorer/index.d.ts +54 -73
  20. package/dist/graph-explorer/index.d.ts.map +1 -0
  21. package/dist/graph-explorer/index.js +181 -248
  22. package/dist/graph-explorer/index.js.map +1 -1
  23. package/dist/human-input/index.d.ts +3 -78
  24. package/dist/human-input/index.js +3 -21
  25. package/dist/human-input-CsCbZomZ.js +314 -0
  26. package/dist/human-input-CsCbZomZ.js.map +1 -0
  27. package/dist/image/index.d.ts +3 -40
  28. package/dist/image/index.js +3 -12
  29. package/dist/image-D_7vaQCR.js +302 -0
  30. package/dist/image-D_7vaQCR.js.map +1 -0
  31. package/dist/index-B1Qs2Cjv.d.ts +145 -0
  32. package/dist/index-B1Qs2Cjv.d.ts.map +1 -0
  33. package/dist/index-BCBVcl0D.d.ts +277 -0
  34. package/dist/index-BCBVcl0D.d.ts.map +1 -0
  35. package/dist/index-CE22tsua.d.ts +20 -0
  36. package/dist/index-CE22tsua.d.ts.map +1 -0
  37. package/dist/index-CGqtpc6b.d.ts +25 -0
  38. package/dist/index-CGqtpc6b.d.ts.map +1 -0
  39. package/dist/index-DqdyM0Jm.d.ts +7 -0
  40. package/dist/index-DqdyM0Jm.d.ts.map +1 -0
  41. package/dist/index-Mw3ltwSG.d.ts +318 -0
  42. package/dist/index-Mw3ltwSG.d.ts.map +1 -0
  43. package/dist/index.d.ts +7 -40
  44. package/dist/index.js +34 -118
  45. package/dist/index.js.map +1 -1
  46. package/dist/message/index.d.ts +3 -105
  47. package/dist/message/index.js +3 -20
  48. package/dist/message-Dn3wW6yy.js +783 -0
  49. package/dist/message-Dn3wW6yy.js.map +1 -0
  50. package/dist/primitives-xfE7zfwJ.js +15 -0
  51. package/dist/primitives-xfE7zfwJ.js.map +1 -0
  52. package/dist/refs-Djj9rSvB.js +10 -0
  53. package/dist/refs-Djj9rSvB.js.map +1 -0
  54. package/dist/sandbox-desktop/index.d.ts +100 -104
  55. package/dist/sandbox-desktop/index.d.ts.map +1 -0
  56. package/dist/sandbox-desktop/index.js +344 -342
  57. package/dist/sandbox-desktop/index.js.map +1 -1
  58. package/dist/sandbox-terminal/index.d.ts +52 -56
  59. package/dist/sandbox-terminal/index.d.ts.map +1 -0
  60. package/dist/sandbox-terminal/index.js +217 -208
  61. package/dist/sandbox-terminal/index.js.map +1 -1
  62. package/dist/selection-toolbar/index.d.ts +3 -21
  63. package/dist/selection-toolbar/index.js +3 -13
  64. package/dist/selection-toolbar-CIkOoM-7.js +171 -0
  65. package/dist/selection-toolbar-CIkOoM-7.js.map +1 -0
  66. package/dist/shared-BSYElFU2.d.ts +2 -0
  67. package/dist/shared.d.ts +4 -14
  68. package/dist/shared.js +1 -43
  69. package/dist/stream/index.d.ts +2 -22
  70. package/dist/stream/index.js +1 -8
  71. package/dist/stream-CAO0x8_1.js +298 -0
  72. package/dist/stream-CAO0x8_1.js.map +1 -0
  73. package/dist/thread-list/index.d.ts +3 -47
  74. package/dist/thread-list/index.js +3 -18
  75. package/dist/thread-list-xJbGXFrE.js +228 -0
  76. package/dist/thread-list-xJbGXFrE.js.map +1 -0
  77. package/dist/ticket-CoJHBpdF.d.ts +32 -0
  78. package/dist/ticket-CoJHBpdF.d.ts.map +1 -0
  79. package/dist/value-BGGrx72L.js +13 -0
  80. package/dist/value-BGGrx72L.js.map +1 -0
  81. package/package.json +22 -22
  82. package/dist/attachment/index.js.map +0 -1
  83. package/dist/attachment-mbjsroli.d.ts +0 -9
  84. package/dist/chat/index.js.map +0 -1
  85. package/dist/chat-PSj1Fo4W.d.ts +0 -88
  86. package/dist/chunk-22EZJUPM.js +0 -120
  87. package/dist/chunk-22EZJUPM.js.map +0 -1
  88. package/dist/chunk-5FZKTDZR.js +0 -201
  89. package/dist/chunk-5FZKTDZR.js.map +0 -1
  90. package/dist/chunk-6XOJFLX4.js +0 -22
  91. package/dist/chunk-6XOJFLX4.js.map +0 -1
  92. package/dist/chunk-CKA4CE26.js +0 -25
  93. package/dist/chunk-CKA4CE26.js.map +0 -1
  94. package/dist/chunk-DLBNFBXQ.js +0 -425
  95. package/dist/chunk-DLBNFBXQ.js.map +0 -1
  96. package/dist/chunk-E73S3SOF.js +0 -404
  97. package/dist/chunk-E73S3SOF.js.map +0 -1
  98. package/dist/chunk-F6AKBUO3.js +0 -380
  99. package/dist/chunk-F6AKBUO3.js.map +0 -1
  100. package/dist/chunk-HGOPGZNQ.js +0 -195
  101. package/dist/chunk-HGOPGZNQ.js.map +0 -1
  102. package/dist/chunk-KHB5CHAU.js +0 -220
  103. package/dist/chunk-KHB5CHAU.js.map +0 -1
  104. package/dist/chunk-LHABOAOP.js +0 -316
  105. package/dist/chunk-LHABOAOP.js.map +0 -1
  106. package/dist/chunk-N5XQU36W.js +0 -410
  107. package/dist/chunk-N5XQU36W.js.map +0 -1
  108. package/dist/chunk-T3ZFZ3NP.js +0 -30
  109. package/dist/chunk-T3ZFZ3NP.js.map +0 -1
  110. package/dist/chunk-T4IYUEPH.js +0 -1612
  111. package/dist/chunk-T4IYUEPH.js.map +0 -1
  112. package/dist/chunk-W2AHKMRS.js +0 -1092
  113. package/dist/chunk-W2AHKMRS.js.map +0 -1
  114. package/dist/completion/index.js.map +0 -1
  115. package/dist/completion-input-DHlwrhxB.d.ts +0 -24
  116. package/dist/composer-6iCSIq6L.d.ts +0 -111
  117. package/dist/human-input/index.js.map +0 -1
  118. package/dist/human-input-CkLrZ8IC.d.ts +0 -27
  119. package/dist/image/index.js.map +0 -1
  120. package/dist/image-VZv6Ddsn.d.ts +0 -14
  121. package/dist/message/index.js.map +0 -1
  122. package/dist/message-CNRnZQwU.d.ts +0 -14
  123. package/dist/render-CRKWam2v.d.ts +0 -8
  124. package/dist/selection-toolbar/index.js.map +0 -1
  125. package/dist/selection-toolbar-Cwjbuv5S.d.ts +0 -14
  126. package/dist/shared.js.map +0 -1
  127. package/dist/stream/index.js.map +0 -1
  128. package/dist/thread-Bz6-1zaJ.d.ts +0 -12
  129. package/dist/thread-list/index.js.map +0 -1
  130. package/dist/thread-list-On8db4XL.d.ts +0 -34
  131. package/dist/ticket-pexI1zIa.d.ts +0 -33
@@ -1,410 +0,0 @@
1
- import {
2
- stringifyValue
3
- } from "./chunk-CKA4CE26.js";
4
- import {
5
- renderPrimitive
6
- } from "./chunk-T3ZFZ3NP.js";
7
- import {
8
- InternalApprovalProvider,
9
- InternalQuestionPromptProvider,
10
- InternalQuestionProvider,
11
- useApproval,
12
- useChatContext,
13
- useHumanInput,
14
- useQuestion,
15
- useQuestionPrompt
16
- } from "./chunk-E73S3SOF.js";
17
-
18
- // src/human-input/approvals.tsx
19
- import { forwardRef, useCallback } from "react";
20
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
- var HumanInputStatus = forwardRef(
22
- function HumanInputStatus2({ children, ...props }, ref) {
23
- const humanInput = useHumanInput();
24
- const renderedChildren = typeof children === "function" ? children(humanInput) : children;
25
- const pendingCount = humanInput.approvals.pending.length + humanInput.questions.pending.length;
26
- return renderPrimitive(
27
- "div",
28
- {
29
- ...props,
30
- children: renderedChildren ?? `${pendingCount} pending`
31
- },
32
- ref
33
- );
34
- }
35
- );
36
- var HumanInputApprovals = forwardRef(
37
- function HumanInputApprovals2({ children, filter = "pending", keepMounted = false, ...props }, ref) {
38
- const humanInput = useHumanInput();
39
- const approvals = filter === "all" ? humanInput.approvals.all : humanInput.approvals.pending;
40
- const empty = approvals.length === 0;
41
- if (empty && !keepMounted) {
42
- return null;
43
- }
44
- return renderPrimitive(
45
- "div",
46
- {
47
- ...props,
48
- children: approvals.map((approval) => /* @__PURE__ */ jsx(InternalApprovalProvider, { approval, children: typeof children === "function" ? children(approval) : children ?? /* @__PURE__ */ jsx(HumanInputApproval, {}) }, approval.request.id)),
49
- "data-state": empty ? "empty" : "populated"
50
- },
51
- ref
52
- );
53
- }
54
- );
55
- var HumanInputApproval = forwardRef(
56
- function HumanInputApproval2({ children, ...props }, ref) {
57
- const { approval } = useApproval();
58
- const renderedChildren = typeof children === "function" ? children(approval) : children ?? defaultApprovalContent(approval);
59
- return renderPrimitive(
60
- "div",
61
- {
62
- ...props,
63
- children: renderedChildren,
64
- "data-state": approval.status
65
- },
66
- ref
67
- );
68
- }
69
- );
70
- var HumanInputApprove = forwardRef(
71
- function HumanInputApprove2({ onClick, ...props }, ref) {
72
- const chat = useChatContext();
73
- const { approval, reason } = useApproval();
74
- const disabled = props.disabled ?? (approval.status !== "pending" || chat.respondingInteractions.has(approval.request.id));
75
- const handleClick = useCallback(
76
- (event) => {
77
- onClick?.(event);
78
- if (event.defaultPrevented || disabled) {
79
- return;
80
- }
81
- const decisionReason = reason.trim().length > 0 ? reason : void 0;
82
- const response = { type: "tool-approval", approved: true };
83
- if (decisionReason !== void 0) Object.assign(response, { reason: decisionReason });
84
- void chat.respondToInteraction({
85
- interactionId: approval.request.id,
86
- response
87
- });
88
- },
89
- [approval.request.id, chat, disabled, onClick, reason]
90
- );
91
- return renderPrimitive(
92
- "button",
93
- {
94
- ...props,
95
- children: props.children ?? "Approve",
96
- disabled,
97
- onClick: handleClick,
98
- type: props.type ?? "button",
99
- "data-state": disabled ? "disabled" : "enabled"
100
- },
101
- ref
102
- );
103
- }
104
- );
105
- var HumanInputReject = forwardRef(
106
- function HumanInputReject2({ onClick, ...props }, ref) {
107
- const chat = useChatContext();
108
- const { approval, reason } = useApproval();
109
- const disabled = props.disabled ?? (approval.status !== "pending" || chat.respondingInteractions.has(approval.request.id));
110
- const handleClick = useCallback(
111
- (event) => {
112
- onClick?.(event);
113
- if (event.defaultPrevented || disabled) {
114
- return;
115
- }
116
- const decisionReason = reason.trim().length > 0 ? reason : void 0;
117
- const response = { type: "tool-approval", approved: false };
118
- if (decisionReason !== void 0) Object.assign(response, { reason: decisionReason });
119
- void chat.respondToInteraction({
120
- interactionId: approval.request.id,
121
- response
122
- });
123
- },
124
- [approval.request.id, chat, disabled, onClick, reason]
125
- );
126
- return renderPrimitive(
127
- "button",
128
- {
129
- ...props,
130
- children: props.children ?? "Reject",
131
- disabled,
132
- onClick: handleClick,
133
- type: props.type ?? "button",
134
- "data-state": disabled ? "disabled" : "enabled"
135
- },
136
- ref
137
- );
138
- }
139
- );
140
- var HumanInputApprovalReason = forwardRef(
141
- function HumanInputApprovalReason2({ onChange, ...props }, ref) {
142
- const approval = useApproval();
143
- const handleChange = useCallback(
144
- (event) => {
145
- onChange?.(event);
146
- if (!event.defaultPrevented) {
147
- approval.setReason(event.currentTarget.value);
148
- }
149
- },
150
- [approval, onChange]
151
- );
152
- return renderPrimitive(
153
- "textarea",
154
- {
155
- ...props,
156
- "aria-label": props["aria-label"] ?? "Approval reason",
157
- onChange: handleChange,
158
- value: approval.reason
159
- },
160
- ref
161
- );
162
- }
163
- );
164
- function defaultApprovalContent(approval) {
165
- return /* @__PURE__ */ jsxs(Fragment, { children: [
166
- /* @__PURE__ */ jsx("div", { children: approval.request.toolName }),
167
- approval.request.input !== void 0 ? /* @__PURE__ */ jsx("pre", { children: stringifyValue(approval.request.input) }) : null,
168
- /* @__PURE__ */ jsx(HumanInputApprovalReason, {}),
169
- /* @__PURE__ */ jsx(HumanInputApprove, {}),
170
- /* @__PURE__ */ jsx(HumanInputReject, {})
171
- ] });
172
- }
173
-
174
- // src/human-input/panel.tsx
175
- import { forwardRef as forwardRef3 } from "react";
176
-
177
- // src/human-input/questions.tsx
178
- import {
179
- forwardRef as forwardRef2,
180
- useCallback as useCallback2,
181
- useMemo,
182
- useState
183
- } from "react";
184
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
185
- var HumanInputQuestions = forwardRef2(
186
- function HumanInputQuestions2({ children, filter = "pending", keepMounted = false, ...props }, ref) {
187
- const humanInput = useHumanInput();
188
- const questions = filter === "all" ? humanInput.questions.all : humanInput.questions.pending;
189
- const empty = questions.length === 0;
190
- if (empty && !keepMounted) {
191
- return null;
192
- }
193
- return renderPrimitive(
194
- "div",
195
- {
196
- ...props,
197
- children: questions.map((question) => /* @__PURE__ */ jsx2(QuestionProvider, { question, children: typeof children === "function" ? children(question) : children ?? /* @__PURE__ */ jsx2(HumanInputQuestion, {}) }, question.request.id)),
198
- "data-state": empty ? "empty" : "populated"
199
- },
200
- ref
201
- );
202
- }
203
- );
204
- var HumanInputQuestion = forwardRef2(
205
- function HumanInputQuestion2({ children, ...props }, ref) {
206
- const { question } = useQuestion();
207
- const renderedChildren = typeof children === "function" ? children(question) : children ?? defaultQuestionContent(question);
208
- return renderPrimitive(
209
- "div",
210
- {
211
- ...props,
212
- children: renderedChildren,
213
- "data-state": question.status
214
- },
215
- ref
216
- );
217
- }
218
- );
219
- var HumanInputQuestionPrompt = forwardRef2(
220
- function HumanInputQuestionPrompt2({ promptId, ...props }, ref) {
221
- const { question } = useQuestion();
222
- const prompt = question.request.questions.find((item) => item.id === promptId) ?? question.request.questions[0];
223
- if (prompt === void 0) {
224
- return null;
225
- }
226
- return /* @__PURE__ */ jsx2(InternalQuestionPromptProvider, { prompt, children: renderPrimitive(
227
- "div",
228
- {
229
- ...props,
230
- children: props.children ?? defaultQuestionPrompt(prompt)
231
- },
232
- ref
233
- ) });
234
- }
235
- );
236
- var HumanInputQuestionChoice = forwardRef2(
237
- function HumanInputQuestionChoice2({ answer, custom = false, onClick, value, ...props }, ref) {
238
- const { prompt } = useQuestionPrompt();
239
- const question = useQuestion();
240
- const choiceValue = value ?? prompt.choices?.[0]?.value ?? "";
241
- const choice = prompt.choices?.find((item) => item.value === choiceValue);
242
- const selected = question.answers[prompt.id]?.value === choiceValue;
243
- const handleClick = useCallback2(
244
- (event) => {
245
- onClick?.(event);
246
- if (event.defaultPrevented || choiceValue.length === 0) {
247
- return;
248
- }
249
- const nextAnswer = {
250
- questionId: prompt.id,
251
- value: custom ? answer ?? choice?.label ?? choiceValue : choiceValue
252
- };
253
- question.setAnswer(prompt, nextAnswer);
254
- },
255
- [answer, choice?.label, choiceValue, custom, onClick, prompt, question]
256
- );
257
- return renderPrimitive(
258
- "button",
259
- {
260
- ...props,
261
- children: props.children ?? choice?.label ?? choiceValue,
262
- onClick: handleClick,
263
- type: props.type ?? "button",
264
- "data-state": selected ? "selected" : "idle"
265
- },
266
- ref
267
- );
268
- }
269
- );
270
- var HumanInputQuestionTextAnswer = forwardRef2(
271
- function HumanInputQuestionTextAnswer2({ onChange, ...props }, ref) {
272
- const { prompt } = useQuestionPrompt();
273
- const question = useQuestion();
274
- const value = question.answers[prompt.id]?.value ?? "";
275
- const handleChange = useCallback2(
276
- (event) => {
277
- onChange?.(event);
278
- if (event.defaultPrevented) {
279
- return;
280
- }
281
- const answer = event.currentTarget.value;
282
- question.setAnswer(prompt, {
283
- questionId: prompt.id,
284
- value: answer
285
- });
286
- },
287
- [onChange, prompt, question]
288
- );
289
- return renderPrimitive(
290
- "textarea",
291
- {
292
- ...props,
293
- "aria-label": props["aria-label"] ?? prompt.text,
294
- onChange: handleChange,
295
- value
296
- },
297
- ref
298
- );
299
- }
300
- );
301
- var HumanInputQuestionSubmit = forwardRef2(
302
- function HumanInputQuestionSubmit2({ onClick, ...props }, ref) {
303
- const chat = useChatContext();
304
- const question = useQuestion();
305
- const answers = useMemo(
306
- () => question.question.request.questions.flatMap((prompt) => {
307
- const answer = question.answers[prompt.id];
308
- return answer === void 0 || answer.value.trim().length === 0 ? [] : [answer];
309
- }),
310
- [question]
311
- );
312
- const disabled = props.disabled ?? (question.question.status !== "pending" || chat.respondingInteractions.has(question.question.request.id) || answers.length !== question.question.request.questions.length);
313
- const handleClick = useCallback2(
314
- (event) => {
315
- onClick?.(event);
316
- if (event.defaultPrevented || disabled) {
317
- return;
318
- }
319
- void chat.respondToInteraction({
320
- interactionId: question.question.request.id,
321
- response: { type: "tool-question", answers }
322
- });
323
- },
324
- [answers, chat, disabled, onClick, question.question.request.id]
325
- );
326
- return renderPrimitive(
327
- "button",
328
- {
329
- ...props,
330
- children: props.children ?? "Submit",
331
- disabled,
332
- onClick: handleClick,
333
- type: props.type ?? "button",
334
- "data-state": disabled ? "disabled" : "enabled"
335
- },
336
- ref
337
- );
338
- }
339
- );
340
- function QuestionProvider({
341
- question,
342
- children
343
- }) {
344
- const [answers, setAnswers] = useState({});
345
- const setAnswer = useCallback2((prompt, answer) => {
346
- setAnswers((current) => ({ ...current, [prompt.id]: answer }));
347
- }, []);
348
- const value = useMemo(
349
- () => ({ question, answers, setAnswer }),
350
- [answers, question, setAnswer]
351
- );
352
- return /* @__PURE__ */ jsx2(InternalQuestionProvider, { value, children });
353
- }
354
- function defaultQuestionContent(question) {
355
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
356
- /* @__PURE__ */ jsx2("div", { children: question.request.toolName }),
357
- question.request.questions.map((prompt) => /* @__PURE__ */ jsx2(HumanInputQuestionPrompt, { promptId: prompt.id }, prompt.id)),
358
- /* @__PURE__ */ jsx2(HumanInputQuestionSubmit, {})
359
- ] });
360
- }
361
- function defaultQuestionPrompt(prompt) {
362
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
363
- /* @__PURE__ */ jsx2("div", { children: prompt.text }),
364
- (prompt.choices?.length ?? 0) > 0 ? /* @__PURE__ */ jsx2("div", { children: prompt.choices?.map((choice) => /* @__PURE__ */ jsx2(HumanInputQuestionChoice, { value: choice.value, children: choice.label }, choice.value)) }) : /* @__PURE__ */ jsx2(HumanInputQuestionTextAnswer, {})
365
- ] });
366
- }
367
-
368
- // src/human-input/panel.tsx
369
- import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
370
- var HumanInputPanel = forwardRef3(function HumanInputPanel2({ children, filter = "pending", ...props }, ref) {
371
- const humanInput = useHumanInput();
372
- const approvals = filter === "all" ? humanInput.approvals.all : humanInput.approvals.pending;
373
- const questions = filter === "all" ? humanInput.questions.all : humanInput.questions.pending;
374
- if (approvals.length === 0 && questions.length === 0) {
375
- return null;
376
- }
377
- return renderPrimitive(
378
- "div",
379
- {
380
- ...props,
381
- children: children ?? /* @__PURE__ */ jsxs3(Fragment3, { children: [
382
- /* @__PURE__ */ jsx3(HumanInputApprovals, { filter }),
383
- /* @__PURE__ */ jsx3(HumanInputQuestions, { filter })
384
- ] })
385
- },
386
- ref
387
- );
388
- });
389
-
390
- // src/human-input/index.ts
391
- var HumanInputPrimitive = {
392
- Panel: HumanInputPanel,
393
- Status: HumanInputStatus,
394
- Approvals: HumanInputApprovals,
395
- Approval: HumanInputApproval,
396
- ApprovalReason: HumanInputApprovalReason,
397
- Approve: HumanInputApprove,
398
- Reject: HumanInputReject,
399
- Questions: HumanInputQuestions,
400
- Question: HumanInputQuestion,
401
- QuestionPrompt: HumanInputQuestionPrompt,
402
- QuestionChoice: HumanInputQuestionChoice,
403
- QuestionTextAnswer: HumanInputQuestionTextAnswer,
404
- QuestionSubmit: HumanInputQuestionSubmit
405
- };
406
-
407
- export {
408
- HumanInputPrimitive
409
- };
410
- //# sourceMappingURL=chunk-N5XQU36W.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/human-input/approvals.tsx","../src/human-input/panel.tsx","../src/human-input/questions.tsx","../src/human-input/index.ts"],"sourcesContent":["import { type ChangeEvent, forwardRef, type MouseEvent, type ReactNode, useCallback } from \"react\";\n\nimport {\n type ApprovalInteraction,\n InternalApprovalProvider,\n useApproval,\n useChatContext,\n useHumanInput,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype ApprovalChildren = ReactNode | ((approval: ApprovalInteraction) => ReactNode);\ntype HumanInputFilter = \"pending\" | \"all\";\n\ntype HumanInputStatusProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: ReactNode | ((state: ReturnType<typeof useHumanInput>) => ReactNode);\n};\n\nconst HumanInputStatus = forwardRef<HTMLDivElement, HumanInputStatusProps>(\n function HumanInputStatus({ children, ...props }, ref) {\n const humanInput = useHumanInput();\n const renderedChildren = typeof children === \"function\" ? children(humanInput) : children;\n const pendingCount = humanInput.approvals.pending.length + humanInput.questions.pending.length;\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren ?? `${pendingCount} pending`,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype HumanInputApprovalsProps = PrimitiveProps<\"div\"> & {\n filter?: HumanInputFilter;\n keepMounted?: boolean;\n children?: ApprovalChildren;\n};\n\nconst HumanInputApprovals = forwardRef<HTMLDivElement, HumanInputApprovalsProps>(\n function HumanInputApprovals(\n { children, filter = \"pending\", keepMounted = false, ...props },\n ref,\n ) {\n const humanInput = useHumanInput();\n const approvals = filter === \"all\" ? humanInput.approvals.all : humanInput.approvals.pending;\n const empty = approvals.length === 0;\n if (empty && !keepMounted) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: approvals.map((approval) => (\n <InternalApprovalProvider key={approval.request.id} approval={approval}>\n {typeof children === \"function\"\n ? children(approval)\n : (children ?? <HumanInputApproval />)}\n </InternalApprovalProvider>\n )),\n \"data-state\": empty ? \"empty\" : \"populated\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype HumanInputApprovalProps = PrimitiveProps<\"div\"> & {\n children?: ApprovalChildren;\n};\n\nconst HumanInputApproval = forwardRef<HTMLDivElement, HumanInputApprovalProps>(\n function HumanInputApproval({ children, ...props }, ref) {\n const { approval } = useApproval();\n const renderedChildren =\n typeof children === \"function\"\n ? children(approval)\n : (children ?? defaultApprovalContent(approval));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-state\": approval.status,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nconst HumanInputApprove = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function HumanInputApprove({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { approval, reason } = useApproval();\n const disabled =\n props.disabled ??\n (approval.status !== \"pending\" || chat.respondingInteractions.has(approval.request.id));\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const decisionReason = reason.trim().length > 0 ? reason : undefined;\n const response = { type: \"tool-approval\" as const, approved: true };\n if (decisionReason !== undefined) Object.assign(response, { reason: decisionReason });\n void chat.respondToInteraction({\n interactionId: approval.request.id,\n response,\n });\n },\n [approval.request.id, chat, disabled, onClick, reason],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Approve\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst HumanInputReject = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function HumanInputReject({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { approval, reason } = useApproval();\n const disabled =\n props.disabled ??\n (approval.status !== \"pending\" || chat.respondingInteractions.has(approval.request.id));\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const decisionReason = reason.trim().length > 0 ? reason : undefined;\n const response = { type: \"tool-approval\" as const, approved: false };\n if (decisionReason !== undefined) Object.assign(response, { reason: decisionReason });\n void chat.respondToInteraction({\n interactionId: approval.request.id,\n response,\n });\n },\n [approval.request.id, chat, disabled, onClick, reason],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Reject\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst HumanInputApprovalReason = forwardRef<HTMLTextAreaElement, PrimitiveProps<\"textarea\">>(\n function HumanInputApprovalReason({ onChange, ...props }, ref) {\n const approval = useApproval();\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLTextAreaElement>) => {\n onChange?.(event);\n if (!event.defaultPrevented) {\n approval.setReason(event.currentTarget.value);\n }\n },\n [approval, onChange],\n );\n\n return renderPrimitive(\n \"textarea\",\n {\n ...props,\n \"aria-label\": props[\"aria-label\"] ?? \"Approval reason\",\n onChange: handleChange,\n value: approval.reason,\n } as PrimitiveProps<\"textarea\">,\n ref,\n );\n },\n);\n\nfunction defaultApprovalContent(approval: ApprovalInteraction): ReactNode {\n return (\n <>\n <div>{approval.request.toolName}</div>\n {approval.request.input !== undefined ? (\n <pre>{stringifyValue(approval.request.input)}</pre>\n ) : null}\n <HumanInputApprovalReason />\n <HumanInputApprove />\n <HumanInputReject />\n </>\n );\n}\n\nexport type { ApprovalChildren, HumanInputFilter };\nexport {\n HumanInputApproval,\n HumanInputApprovalReason,\n HumanInputApprovals,\n HumanInputApprove,\n HumanInputReject,\n HumanInputStatus,\n};\n","import { forwardRef } from \"react\";\n\nimport { useHumanInput } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\nimport { HumanInputApprovals, type HumanInputFilter } from \"./approvals\";\nimport { HumanInputQuestions } from \"./questions\";\n\ntype HumanInputPanelProps = PrimitiveProps<\"div\"> & {\n filter?: HumanInputFilter;\n};\n\nconst HumanInputPanel = forwardRef<HTMLDivElement, HumanInputPanelProps>(function HumanInputPanel(\n { children, filter = \"pending\", ...props },\n ref,\n) {\n const humanInput = useHumanInput();\n const approvals = filter === \"all\" ? humanInput.approvals.all : humanInput.approvals.pending;\n const questions = filter === \"all\" ? humanInput.questions.all : humanInput.questions.pending;\n if (approvals.length === 0 && questions.length === 0) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: children ?? (\n <>\n <HumanInputApprovals filter={filter} />\n <HumanInputQuestions filter={filter} />\n </>\n ),\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nexport { HumanInputPanel };\n","import type { AgentQuestionAnswer, AgentQuestionPrompt } from \"@anvia/core/agent/interactions\";\nimport {\n type ChangeEvent,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport {\n InternalQuestionPromptProvider,\n InternalQuestionProvider,\n type QuestionContextValue,\n type QuestionInteraction,\n useChatContext,\n useHumanInput,\n useQuestion,\n useQuestionPrompt,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\nimport type { HumanInputFilter } from \"./approvals\";\n\ntype QuestionChildren = ReactNode | ((question: QuestionInteraction) => ReactNode);\n\ntype HumanInputQuestionsProps = PrimitiveProps<\"div\"> & {\n filter?: HumanInputFilter;\n keepMounted?: boolean;\n children?: QuestionChildren;\n};\n\nconst HumanInputQuestions = forwardRef<HTMLDivElement, HumanInputQuestionsProps>(\n function HumanInputQuestions(\n { children, filter = \"pending\", keepMounted = false, ...props },\n ref,\n ) {\n const humanInput = useHumanInput();\n const questions = filter === \"all\" ? humanInput.questions.all : humanInput.questions.pending;\n const empty = questions.length === 0;\n if (empty && !keepMounted) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: questions.map((question) => (\n <QuestionProvider key={question.request.id} question={question}>\n {typeof children === \"function\"\n ? children(question)\n : (children ?? <HumanInputQuestion />)}\n </QuestionProvider>\n )),\n \"data-state\": empty ? \"empty\" : \"populated\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype HumanInputQuestionProps = PrimitiveProps<\"div\"> & {\n children?: QuestionChildren;\n};\n\nconst HumanInputQuestion = forwardRef<HTMLDivElement, HumanInputQuestionProps>(\n function HumanInputQuestion({ children, ...props }, ref) {\n const { question } = useQuestion();\n const renderedChildren =\n typeof children === \"function\"\n ? children(question)\n : (children ?? defaultQuestionContent(question));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-state\": question.status,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype HumanInputQuestionPromptProps = PrimitiveProps<\"div\"> & {\n promptId?: string;\n};\n\nconst HumanInputQuestionPrompt = forwardRef<HTMLDivElement, HumanInputQuestionPromptProps>(\n function HumanInputQuestionPrompt({ promptId, ...props }, ref) {\n const { question } = useQuestion();\n const prompt =\n question.request.questions.find((item) => item.id === promptId) ??\n question.request.questions[0];\n if (prompt === undefined) {\n return null;\n }\n\n return (\n <InternalQuestionPromptProvider prompt={prompt}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? defaultQuestionPrompt(prompt),\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalQuestionPromptProvider>\n );\n },\n);\n\ntype HumanInputQuestionChoiceProps = PrimitiveProps<\"button\"> & {\n value?: string;\n answer?: string;\n custom?: boolean;\n};\n\nconst HumanInputQuestionChoice = forwardRef<HTMLButtonElement, HumanInputQuestionChoiceProps>(\n function HumanInputQuestionChoice({ answer, custom = false, onClick, value, ...props }, ref) {\n const { prompt } = useQuestionPrompt();\n const question = useQuestion();\n const choiceValue = value ?? prompt.choices?.[0]?.value ?? \"\";\n const choice = prompt.choices?.find((item) => item.value === choiceValue);\n const selected = question.answers[prompt.id]?.value === choiceValue;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || choiceValue.length === 0) {\n return;\n }\n const nextAnswer: AgentQuestionAnswer = {\n questionId: prompt.id,\n value: custom ? (answer ?? choice?.label ?? choiceValue) : choiceValue,\n };\n question.setAnswer(prompt, nextAnswer);\n },\n [answer, choice?.label, choiceValue, custom, onClick, prompt, question],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? choice?.label ?? choiceValue,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": selected ? \"selected\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst HumanInputQuestionTextAnswer = forwardRef<HTMLTextAreaElement, PrimitiveProps<\"textarea\">>(\n function HumanInputQuestionTextAnswer({ onChange, ...props }, ref) {\n const { prompt } = useQuestionPrompt();\n const question = useQuestion();\n const value = question.answers[prompt.id]?.value ?? \"\";\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLTextAreaElement>) => {\n onChange?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const answer = event.currentTarget.value;\n question.setAnswer(prompt, {\n questionId: prompt.id,\n value: answer,\n });\n },\n [onChange, prompt, question],\n );\n\n return renderPrimitive(\n \"textarea\",\n {\n ...props,\n \"aria-label\": props[\"aria-label\"] ?? prompt.text,\n onChange: handleChange,\n value,\n } as PrimitiveProps<\"textarea\">,\n ref,\n );\n },\n);\n\nconst HumanInputQuestionSubmit = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function HumanInputQuestionSubmit({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const question = useQuestion();\n const answers = useMemo(\n () =>\n question.question.request.questions.flatMap((prompt) => {\n const answer = question.answers[prompt.id];\n return answer === undefined || answer.value.trim().length === 0 ? [] : [answer];\n }),\n [question],\n );\n const disabled =\n props.disabled ??\n (question.question.status !== \"pending\" ||\n chat.respondingInteractions.has(question.question.request.id) ||\n answers.length !== question.question.request.questions.length);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.respondToInteraction({\n interactionId: question.question.request.id,\n response: { type: \"tool-question\", answers },\n });\n },\n [answers, chat, disabled, onClick, question.question.request.id],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Submit\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nfunction QuestionProvider({\n question,\n children,\n}: {\n question: QuestionInteraction;\n children?: ReactNode;\n}) {\n const [answers, setAnswers] = useState<Record<string, AgentQuestionAnswer>>({});\n const setAnswer = useCallback((prompt: AgentQuestionPrompt, answer: AgentQuestionAnswer) => {\n setAnswers((current) => ({ ...current, [prompt.id]: answer }));\n }, []);\n const value = useMemo<QuestionContextValue>(\n () => ({ question, answers, setAnswer }),\n [answers, question, setAnswer],\n );\n\n return <InternalQuestionProvider value={value}>{children}</InternalQuestionProvider>;\n}\n\nfunction defaultQuestionContent(question: QuestionInteraction): ReactNode {\n return (\n <>\n <div>{question.request.toolName}</div>\n {question.request.questions.map((prompt) => (\n <HumanInputQuestionPrompt key={prompt.id} promptId={prompt.id} />\n ))}\n <HumanInputQuestionSubmit />\n </>\n );\n}\n\nfunction defaultQuestionPrompt(prompt: AgentQuestionPrompt): ReactNode {\n return (\n <>\n <div>{prompt.text}</div>\n {(prompt.choices?.length ?? 0) > 0 ? (\n <div>\n {prompt.choices?.map((choice) => (\n <HumanInputQuestionChoice key={choice.value} value={choice.value}>\n {choice.label}\n </HumanInputQuestionChoice>\n ))}\n </div>\n ) : (\n <HumanInputQuestionTextAnswer />\n )}\n </>\n );\n}\n\nexport type { QuestionChildren };\nexport {\n HumanInputQuestion,\n HumanInputQuestionChoice,\n HumanInputQuestionPrompt,\n HumanInputQuestionSubmit,\n HumanInputQuestions,\n HumanInputQuestionTextAnswer,\n};\n","import {\n HumanInputApproval,\n HumanInputApprovalReason,\n HumanInputApprovals,\n HumanInputApprove,\n HumanInputReject,\n HumanInputStatus,\n} from \"./approvals\";\nimport { HumanInputPanel } from \"./panel\";\nimport {\n HumanInputQuestion,\n HumanInputQuestionChoice,\n HumanInputQuestionPrompt,\n HumanInputQuestionSubmit,\n HumanInputQuestions,\n HumanInputQuestionTextAnswer,\n} from \"./questions\";\n\nexport const HumanInputPrimitive = {\n Panel: HumanInputPanel,\n Status: HumanInputStatus,\n Approvals: HumanInputApprovals,\n Approval: HumanInputApproval,\n ApprovalReason: HumanInputApprovalReason,\n Approve: HumanInputApprove,\n Reject: HumanInputReject,\n Questions: HumanInputQuestions,\n Question: HumanInputQuestion,\n QuestionPrompt: HumanInputQuestionPrompt,\n QuestionChoice: HumanInputQuestionChoice,\n QuestionTextAnswer: HumanInputQuestionTextAnswer,\n QuestionSubmit: HumanInputQuestionSubmit,\n} as const;\n\nexport type {\n ApprovalContextValue,\n QuestionContextValue,\n QuestionPromptContextValue,\n} from \"../contexts\";\nexport {\n useApproval,\n useChatContext,\n useHumanInput,\n useQuestion,\n useQuestionPrompt,\n} from \"../contexts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAA2B,YAA6C,mBAAmB;AA8D9D,SA+IzB,UA/IyB,KA+IzB,YA/IyB;AA3C7B,IAAM,mBAAmB;AAAA,EACvB,SAASA,kBAAiB,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK;AACrD,UAAM,aAAa,cAAc;AACjC,UAAM,mBAAmB,OAAO,aAAa,aAAa,SAAS,UAAU,IAAI;AACjF,UAAM,eAAe,WAAW,UAAU,QAAQ,SAAS,WAAW,UAAU,QAAQ;AAExF,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,oBAAoB,GAAG,YAAY;AAAA,MAC/C;AAAA,MACA;AAAA,IACF;AAAA,EACF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AAC,WACpB,gBAAAA,KAAC,4BAA4C,OAAO,OAAO,OACxD,iBAAO,SADqB,OAAO,KAEtC,CACD,GACH,IAEA,gBAAAA,KAAC,gCAA6B;AAAA,KAElC;AAEJ;;;ADpQQ,qBAAAU,WACE,OAAAC,MADF,QAAAC,aAAA;AAhBR,IAAM,kBAAkBC,YAAiD,SAASC,iBAChF,EAAE,UAAU,SAAS,WAAW,GAAG,MAAM,GACzC,KACA;AACA,QAAM,aAAa,cAAc;AACjC,QAAM,YAAY,WAAW,QAAQ,WAAW,UAAU,MAAM,WAAW,UAAU;AACrF,QAAM,YAAY,WAAW,QAAQ,WAAW,UAAU,MAAM,WAAW,UAAU;AACrF,MAAI,UAAU,WAAW,KAAK,UAAU,WAAW,GAAG;AACpD,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,UAAU,YACR,gBAAAF,MAAAF,WAAA,EACE;AAAA,wBAAAC,KAAC,uBAAoB,QAAgB;AAAA,QACrC,gBAAAA,KAAC,uBAAoB,QAAgB;AAAA,SACvC;AAAA,IAEJ;AAAA,IACA;AAAA,EACF;AACF,CAAC;;;AEjBM,IAAM,sBAAsB;AAAA,EACjC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,gBAAgB;AAClB;","names":["HumanInputStatus","HumanInputApprovals","HumanInputApproval","HumanInputApprove","HumanInputReject","HumanInputApprovalReason","forwardRef","forwardRef","useCallback","Fragment","jsx","jsxs","forwardRef","HumanInputQuestions","HumanInputQuestion","HumanInputQuestionPrompt","HumanInputQuestionChoice","useCallback","HumanInputQuestionTextAnswer","HumanInputQuestionSubmit","Fragment","jsx","jsxs","forwardRef","HumanInputPanel"]}
@@ -1,30 +0,0 @@
1
- // src/primitives/refs.ts
2
- function composeRefs(...refs) {
3
- return (node) => {
4
- for (const ref of refs) {
5
- if (typeof ref === "function") {
6
- ref(node);
7
- } else if (ref !== void 0 && ref !== null) {
8
- ref.current = node;
9
- }
10
- }
11
- };
12
- }
13
-
14
- // src/primitives/render.tsx
15
- import { Slot } from "@radix-ui/react-slot";
16
- import {
17
- createElement
18
- } from "react";
19
- function renderPrimitive(element, props, ref) {
20
- const { asChild, ...rest } = props;
21
- const Component = asChild ? Slot : element;
22
- const nextProps = ref === void 0 ? rest : { ...rest, ref };
23
- return createElement(Component, nextProps);
24
- }
25
-
26
- export {
27
- composeRefs,
28
- renderPrimitive
29
- };
30
- //# sourceMappingURL=chunk-T3ZFZ3NP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/primitives/refs.ts","../src/primitives/render.tsx"],"sourcesContent":["import type { Ref, RefCallback } from \"react\";\n\nexport function composeRefs<T>(...refs: Array<Ref<T> | undefined>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref !== undefined && ref !== null) {\n ref.current = node;\n }\n }\n };\n}\n","import { Slot } from \"@radix-ui/react-slot\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentPropsWithRef,\n createElement,\n type ElementType,\n type ReactElement,\n type Ref,\n} from \"react\";\n\nexport type PrimitiveProps<TElement extends ElementType = \"div\"> = Omit<\n ComponentPropsWithoutRef<TElement>,\n \"asChild\"\n> & {\n asChild?: boolean;\n};\n\nexport type PrimitiveRef<TElement extends ElementType> = ComponentPropsWithRef<TElement>[\"ref\"];\n\nexport function renderPrimitive<TElement extends ElementType>(\n element: TElement,\n props: PrimitiveProps<TElement>,\n ref?: Ref<unknown>,\n): ReactElement {\n const { asChild, ...rest } = props;\n const Component = asChild ? Slot : element;\n const nextProps = ref === undefined ? rest : { ...rest, ref };\n return createElement(Component, nextProps);\n}\n"],"mappings":";AAEO,SAAS,eAAkB,MAAiD;AACjF,SAAO,CAAC,SAAS;AACf,eAAW,OAAO,MAAM;AACtB,UAAI,OAAO,QAAQ,YAAY;AAC7B,YAAI,IAAI;AAAA,MACV,WAAW,QAAQ,UAAa,QAAQ,MAAM;AAC5C,YAAI,UAAU;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;;;ACZA,SAAS,YAAY;AACrB;AAAA,EAGE;AAAA,OAIK;AAWA,SAAS,gBACd,SACA,OACA,KACc;AACd,QAAM,EAAE,SAAS,GAAG,KAAK,IAAI;AAC7B,QAAM,YAAY,UAAU,OAAO;AACnC,QAAM,YAAY,QAAQ,SAAY,OAAO,EAAE,GAAG,MAAM,IAAI;AAC5D,SAAO,cAAc,WAAW,SAAS;AAC3C;","names":[]}