@automattic/agenttic-ui 0.1.75 → 0.1.77

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.
@@ -0,0 +1,1325 @@
1
+ import { jsx as e, jsxs as p, Fragment as Y } from "react/jsx-runtime";
2
+ import { __ as w } from "@wordpress/i18n";
3
+ import * as it from "react";
4
+ import k, { createContext as pt, useContext as ht, useState as ft, useEffect as tt, useId as gt, useCallback as et, useRef as bt, useMemo as st } from "react";
5
+ import { AnimatePresence as lt, motion as W } from "framer-motion";
6
+ import { Slot as Ct } from "@radix-ui/react-slot";
7
+ import * as O from "@radix-ui/react-popover";
8
+ import vt from "react-markdown";
9
+ import './DiffCard.css';function v(...t) {
10
+ return t.flat().filter(Boolean).map((n) => typeof n == "string" ? n : typeof n == "object" && !Array.isArray(n) && n !== null ? Object.entries(n).filter(([o, a]) => a).map(([o]) => o).join(" ") : "").join(" ").trim();
11
+ }
12
+ const J = {
13
+ type: "spring",
14
+ stiffness: 300,
15
+ damping: 30
16
+ }, U = {
17
+ type: "spring",
18
+ damping: 40,
19
+ stiffness: 500,
20
+ mass: 0.8
21
+ }, Q = {
22
+ ...U,
23
+ stiffness: 1e3,
24
+ damping: 90
25
+ }, wt = {
26
+ type: "spring",
27
+ damping: 40,
28
+ stiffness: 500,
29
+ mass: 0.8
30
+ }, yt = {
31
+ hidden: {
32
+ opacity: 0
33
+ },
34
+ visible: {
35
+ opacity: 1,
36
+ transition: J
37
+ },
38
+ exit: {
39
+ opacity: 0,
40
+ transition: { ...J, duration: 0.1 }
41
+ }
42
+ }, _t = () => {
43
+ if (typeof window > "u")
44
+ return { left: 0, right: 0, top: 0, bottom: 0 };
45
+ const t = 20;
46
+ return {
47
+ left: t,
48
+ right: window.innerWidth - 400 - t,
49
+ // Assuming max width of 400px
50
+ top: t,
51
+ bottom: window.innerHeight - 60 - t
52
+ // Assuming collapsed height of 60px
53
+ };
54
+ }, Nt = {
55
+ "0%": { backgroundPosition: "-200% 0" },
56
+ "100%": { backgroundPosition: "200% 0" }
57
+ }, wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
58
+ __proto__: null,
59
+ fadeVariants: yt,
60
+ fastSpring: U,
61
+ fastSpringWithDelay: Q,
62
+ getDragConstraints: _t,
63
+ morphSpring: wt,
64
+ springConfig: J,
65
+ thinkingGradientKeyframes: Nt
66
+ }, Symbol.toStringTag, { value: "Module" })), rt = pt(null);
67
+ function Z() {
68
+ const t = ht(rt);
69
+ if (!t)
70
+ throw new Error(
71
+ "useAgentUIContext must be used within an AgentUIContainer"
72
+ );
73
+ return t;
74
+ }
75
+ function yn({ children: t, value: n }) {
76
+ return /* @__PURE__ */ e(rt.Provider, { value: n, children: t });
77
+ }
78
+ const xt = "button-module_button", It = "button-module_pressed", St = "button-module_primary", $t = "button-module_ghost", Lt = "button-module_outline", kt = "button-module_transparent", Dt = "button-module_link", At = "button-module_icon", Rt = "button-module_sm", Bt = "button-module_lg", Wt = "button-module_withTextAndIcon", T = {
79
+ button: xt,
80
+ pressed: It,
81
+ primary: St,
82
+ ghost: $t,
83
+ outline: Lt,
84
+ transparent: kt,
85
+ link: Dt,
86
+ icon: At,
87
+ sm: Rt,
88
+ lg: Bt,
89
+ withTextAndIcon: Wt
90
+ }, D = it.forwardRef(
91
+ function({
92
+ className: n,
93
+ variant: o = "primary",
94
+ size: a,
95
+ icon: i,
96
+ children: s,
97
+ asChild: r = !1,
98
+ pressed: f,
99
+ ...g
100
+ }, d) {
101
+ const u = r ? Ct : "button", c = !!i, b = a || (c && !s ? "icon" : void 0);
102
+ return /* @__PURE__ */ p(
103
+ u,
104
+ {
105
+ ref: d,
106
+ "data-slot": "button",
107
+ className: v(
108
+ T.button,
109
+ T[o],
110
+ b && T[b],
111
+ c && s ? T.withTextAndIcon : void 0,
112
+ f ? T.pressed : void 0,
113
+ n
114
+ ),
115
+ "aria-pressed": f,
116
+ ...g,
117
+ children: [
118
+ i,
119
+ s
120
+ ]
121
+ }
122
+ );
123
+ }
124
+ );
125
+ D.displayName = "Button";
126
+ const Mt = "Textarea-module_textarea", jt = {
127
+ textarea: Mt
128
+ }, ct = it.forwardRef(
129
+ ({ className: t, ...n }, o) => /* @__PURE__ */ e(
130
+ "textarea",
131
+ {
132
+ "data-slot": "textarea",
133
+ className: jt.textarea,
134
+ ref: o,
135
+ ...n
136
+ }
137
+ )
138
+ );
139
+ ct.displayName = "Textarea";
140
+ function Et({ className: t, size: n = 24 }) {
141
+ return /* @__PURE__ */ e(
142
+ "svg",
143
+ {
144
+ width: n,
145
+ height: n,
146
+ viewBox: "0 0 24 24",
147
+ fill: "none",
148
+ xmlns: "http://www.w3.org/2000/svg",
149
+ className: t,
150
+ children: /* @__PURE__ */ e(
151
+ "path",
152
+ {
153
+ d: "M12.2197 5C12.4186 5 12.6094 5.07902 12.75 5.21967L17 9.46967C17.2929 9.76256 17.2929 10.2374 17 10.5303C16.7071 10.8232 16.2322 10.8232 15.9393 10.5303L12.9697 7.56067V18.25C12.9697 18.6642 12.6339 19 12.2197 19C11.8055 19 11.4697 18.6642 11.4697 18.25V7.56065L8.5 10.5303C8.2071 10.8232 7.73223 10.8232 7.43934 10.5303C7.14644 10.2374 7.14645 9.76256 7.43934 9.46967L11.6894 5.21967C11.83 5.07902 12.0208 5 12.2197 5Z",
154
+ fill: "currentColor"
155
+ }
156
+ )
157
+ }
158
+ );
159
+ }
160
+ function Pt({ className: t, size: n = 24 }) {
161
+ return /* @__PURE__ */ e(
162
+ "svg",
163
+ {
164
+ width: n,
165
+ height: n,
166
+ viewBox: "0 0 24 24",
167
+ fill: "none",
168
+ xmlns: "http://www.w3.org/2000/svg",
169
+ className: t,
170
+ children: /* @__PURE__ */ e(
171
+ "rect",
172
+ {
173
+ x: "7",
174
+ y: "7",
175
+ width: "10",
176
+ height: "10",
177
+ rx: "2",
178
+ fill: "currentColor"
179
+ }
180
+ )
181
+ }
182
+ );
183
+ }
184
+ const Vt = "ChatInput-module_container", Ht = "ChatInput-module_textareaContainer", Tt = "ChatInput-module_actions", Ut = "ChatInput-module_containerStacked", Zt = "ChatInput-module_button", Ot = "ChatInput-module_actionWrapper", Qt = "ChatInput-module_actionWrapperDisabled", I = {
185
+ container: Vt,
186
+ textareaContainer: Ht,
187
+ actions: Tt,
188
+ containerStacked: Ut,
189
+ button: Zt,
190
+ actionWrapper: Ot,
191
+ actionWrapperDisabled: Qt
192
+ };
193
+ function Ft({ className: t, size: n = 24 }) {
194
+ return /* @__PURE__ */ e(
195
+ "svg",
196
+ {
197
+ className: t,
198
+ width: n,
199
+ height: n,
200
+ viewBox: "0 0 24 24",
201
+ fill: "none",
202
+ xmlns: "http://www.w3.org/2000/svg",
203
+ children: /* @__PURE__ */ e(
204
+ "path",
205
+ {
206
+ fillRule: "evenodd",
207
+ clipRule: "evenodd",
208
+ d: "M18.0045 13.4451L12 7.9864L5.9955 13.4451L7.00451 14.5549L12 10.0136L16.9955 14.5549L18.0045 13.4451Z",
209
+ fill: "currentColor"
210
+ }
211
+ )
212
+ }
213
+ );
214
+ }
215
+ const Gt = "AnimatedPlaceholder-module_container", qt = {
216
+ container: Gt
217
+ };
218
+ function Kt({
219
+ texts: t,
220
+ interval: n = 3e3,
221
+ className: o = ""
222
+ }) {
223
+ const [a, i] = ft(0);
224
+ return tt(() => {
225
+ const s = setInterval(() => {
226
+ i(
227
+ (r) => (r + 1) % t.length
228
+ );
229
+ }, n);
230
+ return () => clearInterval(s);
231
+ }, [t.length, n]), /* @__PURE__ */ e(lt, { mode: "wait", children: /* @__PURE__ */ e(
232
+ W.span,
233
+ {
234
+ "data-slot": "animated-placeholder",
235
+ className: v(qt.container, o),
236
+ initial: { opacity: 0, y: 8 },
237
+ animate: { opacity: 1, y: 0 },
238
+ exit: { opacity: 0, y: -8 },
239
+ transition: {
240
+ duration: 0.3,
241
+ ease: [0.4, 0, 0.2, 1]
242
+ // Matches --transition-colors cubic-bezier
243
+ },
244
+ children: t[a]
245
+ },
246
+ a
247
+ ) });
248
+ }
249
+ function Xt({
250
+ value: t,
251
+ onChange: n,
252
+ onSubmit: o,
253
+ onKeyDown: a,
254
+ textareaRef: i,
255
+ placeholder: s = w("Ask anything", "a8c-agenttic"),
256
+ isProcessing: r,
257
+ onBlur: f,
258
+ onFocus: g,
259
+ onClick: d,
260
+ fromCompact: u = !1,
261
+ onExpand: c,
262
+ showExpandButton: b = !0,
263
+ focusOnMount: m = !1,
264
+ customActions: N = [],
265
+ actionOrder: y = "before-submit",
266
+ onStop: x,
267
+ disabled: A,
268
+ readOnly: h,
269
+ onMouseEnter: R,
270
+ onMouseLeave: $,
271
+ expandOnClick: P = !1,
272
+ layout: F = "inline"
273
+ }) {
274
+ const G = gt(), { variant: q, floatingChatState: nt, isInputOverLimit: M } = Z(), j = (
275
+ // If the consumer actively sets `disabled` to `false` (vs undefined), that takes precedence.
276
+ A !== void 0 ? !A : (t.trim() || r) && !M
277
+ ), dt = et(
278
+ (l) => {
279
+ const H = l.key.toLowerCase();
280
+ if (H === "enter" && !l.shiftKey && (l.nativeEvent.isComposing || l.keyCode === 229)) {
281
+ l.preventDefault();
282
+ return;
283
+ }
284
+ if (H === "enter" && !l.shiftKey && !j) {
285
+ l.preventDefault();
286
+ return;
287
+ }
288
+ if (h && H === "enter" && !l.shiftKey) {
289
+ l.preventDefault();
290
+ return;
291
+ }
292
+ ((l.metaKey || l.ctrlKey) && H === "z" || l.ctrlKey && H === "y") && l.stopPropagation(), a(l);
293
+ },
294
+ [j, a, h]
295
+ ), ot = (l) => l.endsWith("…") ? l : `${l}…`, K = Array.isArray(s);
296
+ let V;
297
+ K ? V = s.map(ot) : s ? V = ot(s) : V = "";
298
+ const X = bt(m);
299
+ tt(() => {
300
+ X.current && i.current && i.current.focus(), X.current = !1;
301
+ }, [X, i]);
302
+ const at = () => N.map((l) => /* @__PURE__ */ e(
303
+ "span",
304
+ {
305
+ className: v(I.actionWrapper, {
306
+ [I.actionWrapperDisabled]: l.disabled
307
+ }),
308
+ children: /* @__PURE__ */ e(
309
+ D,
310
+ {
311
+ className: l.className || I.button,
312
+ onClick: l.onClick,
313
+ disabled: l.disabled,
314
+ variant: l.variant || "ghost",
315
+ icon: l.icon,
316
+ "aria-label": l["aria-label"]
317
+ }
318
+ )
319
+ },
320
+ l.id
321
+ )), ut = () => q === "embedded" || nt === "expanded" || P ? null : b && c ? /* @__PURE__ */ e(
322
+ D,
323
+ {
324
+ className: I.button,
325
+ onClick: c,
326
+ variant: "ghost",
327
+ icon: /* @__PURE__ */ e(Ft, {}),
328
+ "aria-label": w("Expand conversation", "a8c-agenttic")
329
+ }
330
+ ) : null, mt = () => {
331
+ if (r && !x)
332
+ return null;
333
+ const l = () => {
334
+ r && x ? x() : o();
335
+ };
336
+ return /* @__PURE__ */ e(
337
+ D,
338
+ {
339
+ className: I.button,
340
+ onClick: l,
341
+ disabled: !j,
342
+ variant: "primary",
343
+ icon: r ? /* @__PURE__ */ e(Pt, {}) : /* @__PURE__ */ e(Et, {}),
344
+ "aria-label": r ? w("Stop processing", "a8c-agenttic") : w("Send message", "a8c-agenttic")
345
+ }
346
+ );
347
+ };
348
+ return /* @__PURE__ */ p(
349
+ "div",
350
+ {
351
+ "data-slot": "chat-input",
352
+ className: `${I.container}${F === "stacked" ? ` ${I.containerStacked}` : ""}`,
353
+ onMouseEnter: R,
354
+ onMouseLeave: $,
355
+ children: [
356
+ /* @__PURE__ */ p(
357
+ W.div,
358
+ {
359
+ className: I.textareaContainer,
360
+ initial: {
361
+ opacity: 0
362
+ },
363
+ animate: {
364
+ opacity: 1,
365
+ scale: 1,
366
+ transition: t.trim() ? { duration: 0 } : Q
367
+ },
368
+ children: [
369
+ !t && K && /* @__PURE__ */ e(
370
+ Kt,
371
+ {
372
+ texts: V
373
+ }
374
+ ),
375
+ /* @__PURE__ */ e(
376
+ ct,
377
+ {
378
+ id: G,
379
+ ref: i,
380
+ value: t,
381
+ readOnly: h,
382
+ onChange: (l) => n(l.target.value),
383
+ onKeyDown: dt,
384
+ onBlur: f,
385
+ onFocus: g,
386
+ onClick: d,
387
+ placeholder: K ? "" : V,
388
+ rows: 1,
389
+ "aria-label": w("Chat input", "a8c-agenttic")
390
+ }
391
+ )
392
+ ]
393
+ }
394
+ ),
395
+ /* @__PURE__ */ p(
396
+ W.div,
397
+ {
398
+ className: I.actions,
399
+ initial: {
400
+ opacity: u ? 1 : 0,
401
+ scale: u ? 1 : 0.5
402
+ },
403
+ animate: {
404
+ opacity: 1,
405
+ scale: 1,
406
+ transition: t.trim() ? { duration: 0 } : U
407
+ },
408
+ children: [
409
+ ut(),
410
+ y === "before-submit" && at(),
411
+ mt(),
412
+ y === "after-submit" && at()
413
+ ]
414
+ }
415
+ )
416
+ ]
417
+ }
418
+ );
419
+ }
420
+ function Yt({ className: t, size: n = 24 }) {
421
+ return /* @__PURE__ */ e(
422
+ "svg",
423
+ {
424
+ className: t,
425
+ width: n,
426
+ height: n,
427
+ viewBox: "0 0 24 24",
428
+ fill: "none",
429
+ xmlns: "http://www.w3.org/2000/svg",
430
+ children: /* @__PURE__ */ e(
431
+ "path",
432
+ {
433
+ fillRule: "evenodd",
434
+ clipRule: "evenodd",
435
+ d: "M18.0045 10.5549L12 16.0136L5.9955 10.5549L7.00451 9.44504L12 13.9864L16.9955 9.44504L18.0045 10.5549Z",
436
+ fill: "currentColor"
437
+ }
438
+ )
439
+ }
440
+ );
441
+ }
442
+ const Jt = "SuggestionDropdown-module_container", zt = "SuggestionDropdown-module_labelRow", te = "SuggestionDropdown-module_chevron", ee = "SuggestionDropdown-module_chevronOpen", ne = "SuggestionDropdown-module_dropdown", oe = "SuggestionDropdown-module_option", E = {
443
+ container: Jt,
444
+ labelRow: zt,
445
+ chevron: te,
446
+ chevronOpen: ee,
447
+ dropdown: ne,
448
+ option: oe
449
+ }, ae = "Suggestions-module_container", ie = "Suggestions-module_vertical", se = "Suggestions-module_button", le = "Suggestions-module_label", re = "Suggestions-module_description", ce = "Suggestions-module_floating", _ = {
450
+ container: ae,
451
+ vertical: ie,
452
+ button: se,
453
+ "suggestion-content--with-description": "Suggestions-module_suggestion-content--with-description",
454
+ label: le,
455
+ description: re,
456
+ floating: ce
457
+ }, de = (t, n) => !t || !n ? `${t}${n}` : /\s$/.test(t) || /^\s/.test(n) ? `${t}${n}` : `${t} ${n}`, ue = ({
458
+ suggestion: t,
459
+ onSelect: n,
460
+ availableSuggestions: o,
461
+ onOpenChange: a,
462
+ showDescription: i
463
+ }) => {
464
+ var A;
465
+ const [s, r] = k.useState(!1), f = k.useRef(null), [g, d] = k.useState(null), [u, c] = k.useState(null), [b, m] = k.useState(void 0), N = k.useCallback(
466
+ (h) => {
467
+ if (f.current = h, !h) {
468
+ d(null), c(null);
469
+ return;
470
+ }
471
+ d(
472
+ h.closest(".agenttic") ?? h
473
+ ), c(
474
+ h.closest(
475
+ '[data-slot="conversation-view"]'
476
+ ) ?? null
477
+ );
478
+ },
479
+ []
480
+ ), y = k.useCallback(
481
+ (h) => {
482
+ var R;
483
+ if (h) {
484
+ const $ = (R = f.current) == null ? void 0 : R.closest(
485
+ '[data-slot="suggestions"]'
486
+ );
487
+ $ && m($.clientWidth * 0.9);
488
+ }
489
+ r(h), a == null || a(h);
490
+ },
491
+ [a]
492
+ ), x = (h) => {
493
+ const { options: R, ...$ } = t, P = {
494
+ ...$,
495
+ prompt: de(
496
+ t.prompt ?? t.label,
497
+ h.value
498
+ ),
499
+ label: `${t.label} ${h.label}`
500
+ };
501
+ n == null || n(P, o), y(!1);
502
+ };
503
+ return /* @__PURE__ */ e("div", { ref: N, className: E.container, children: /* @__PURE__ */ p(O.Root, { open: s, onOpenChange: y, children: [
504
+ /* @__PURE__ */ e(O.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
505
+ D,
506
+ {
507
+ variant: "outline",
508
+ className: _.button,
509
+ children: /* @__PURE__ */ p(
510
+ "div",
511
+ {
512
+ className: v(
513
+ _["suggestion-content"],
514
+ i ? _["suggestion-content--with-description"] : ""
515
+ ),
516
+ children: [
517
+ /* @__PURE__ */ p("span", { className: E.labelRow, children: [
518
+ /* @__PURE__ */ e("span", { className: _.label, children: t.label }),
519
+ /* @__PURE__ */ e(
520
+ Yt,
521
+ {
522
+ size: 14,
523
+ className: `${E.chevron} ${s ? E.chevronOpen : ""}`
524
+ }
525
+ )
526
+ ] }),
527
+ i && t.description && /* @__PURE__ */ e(
528
+ "span",
529
+ {
530
+ className: _.description,
531
+ children: t.description
532
+ }
533
+ )
534
+ ]
535
+ }
536
+ )
537
+ }
538
+ ) }),
539
+ g && /* @__PURE__ */ e(O.Portal, { container: g, children: /* @__PURE__ */ e(
540
+ O.Content,
541
+ {
542
+ className: E.dropdown,
543
+ side: "top",
544
+ align: "start",
545
+ sideOffset: 4,
546
+ collisionBoundary: u,
547
+ "aria-label": t.label,
548
+ style: b ? { width: b } : void 0,
549
+ children: (A = t.options) == null ? void 0 : A.map((h) => /* @__PURE__ */ e(
550
+ "button",
551
+ {
552
+ type: "button",
553
+ "data-slot": "suggestion-option",
554
+ className: E.option,
555
+ onClick: () => x(h),
556
+ children: h.label
557
+ },
558
+ h.id
559
+ ))
560
+ }
561
+ ) })
562
+ ] }) });
563
+ }, me = ({
564
+ className: t,
565
+ suggestions: n,
566
+ onSubmit: o,
567
+ layout: a = "horizontal",
568
+ visible: i = !0,
569
+ onMouseEnter: s,
570
+ onMouseLeave: r,
571
+ onDropdownOpenChange: f,
572
+ translateY: g = "-100%"
573
+ }) => {
574
+ const { variant: d, reportSuggestionsRendered: u } = Z(), c = st(
575
+ () => d === "floating" ? n == null ? void 0 : n.slice(0, 3) : n,
576
+ [n, d]
577
+ );
578
+ tt(() => {
579
+ i && (c != null && c.length) && (u == null || u(c));
580
+ }, [i, c, u]);
581
+ const b = async (m, N) => {
582
+ let y = !0;
583
+ m.action && (y = await m.action()), y && o && m.prompt && o(m, N);
584
+ };
585
+ return !c || c.length === 0 ? null : /* @__PURE__ */ e(lt, { children: i && /* @__PURE__ */ e(
586
+ W.div,
587
+ {
588
+ "data-slot": "suggestions",
589
+ className: v(
590
+ _.container,
591
+ a === "vertical" ? _.vertical : a === "floating" ? _.floating : "",
592
+ t
593
+ ),
594
+ initial: { opacity: 0, y: "-80%" },
595
+ animate: { opacity: 1, y: g },
596
+ exit: { opacity: 0, y: "-80%" },
597
+ transition: Q,
598
+ onMouseEnter: s,
599
+ onMouseLeave: r,
600
+ children: c.map(
601
+ (m, N) => {
602
+ const y = !!m.description && a !== "horizontal";
603
+ return /* @__PURE__ */ e(
604
+ W.div,
605
+ {
606
+ initial: { opacity: 0, y: 10 },
607
+ animate: { opacity: 1, y: 0 },
608
+ exit: { opacity: 0, y: 10 },
609
+ transition: {
610
+ ...Q,
611
+ delay: N * 0.05
612
+ },
613
+ children: m.options && m.options.length > 0 ? /* @__PURE__ */ e(
614
+ ue,
615
+ {
616
+ suggestion: m,
617
+ onSelect: b,
618
+ availableSuggestions: c,
619
+ onOpenChange: f,
620
+ showDescription: y
621
+ }
622
+ ) : /* @__PURE__ */ e(
623
+ D,
624
+ {
625
+ onClick: (x) => {
626
+ x.stopPropagation(), b(
627
+ m,
628
+ c
629
+ );
630
+ },
631
+ variant: "outline",
632
+ className: _.button,
633
+ children: /* @__PURE__ */ p(
634
+ "div",
635
+ {
636
+ className: v(
637
+ _["suggestion-content"],
638
+ y ? _["suggestion-content--with-description"] : ""
639
+ ),
640
+ children: [
641
+ /* @__PURE__ */ e(
642
+ "span",
643
+ {
644
+ className: _.label,
645
+ children: m.label
646
+ }
647
+ ),
648
+ y && /* @__PURE__ */ e(
649
+ "span",
650
+ {
651
+ className: _.description,
652
+ children: m.description
653
+ }
654
+ )
655
+ ]
656
+ }
657
+ )
658
+ }
659
+ )
660
+ },
661
+ m.id
662
+ );
663
+ }
664
+ )
665
+ }
666
+ ) });
667
+ };
668
+ function pe({ className: t, size: n = 24 }) {
669
+ return /* @__PURE__ */ e(
670
+ "svg",
671
+ {
672
+ className: t,
673
+ width: n,
674
+ height: n,
675
+ viewBox: "0 0 24 24",
676
+ fill: "none",
677
+ xmlns: "http://www.w3.org/2000/svg",
678
+ children: /* @__PURE__ */ e(
679
+ "path",
680
+ {
681
+ d: "M12.0001 13.0607L16.4697 17.5304L17.5304 16.4697L13.0607 12.0001L17.5304 7.53039L16.4697 6.46973L12.0001 10.9394L7.5304 6.46973L6.46973 7.53039L10.9394 12.0001L6.46974 16.4697L7.5304 17.5304L12.0001 13.0607Z",
682
+ fill: "currentColor"
683
+ }
684
+ )
685
+ }
686
+ );
687
+ }
688
+ const he = "SourcesCard-module_card", fe = "SourcesCard-module_heading", ge = "SourcesCard-module_list", be = "SourcesCard-module_item", Ce = "SourcesCard-module_title", ve = "SourcesCard-module_label", B = {
689
+ card: he,
690
+ heading: fe,
691
+ list: ge,
692
+ item: be,
693
+ title: Ce,
694
+ label: ve
695
+ };
696
+ function _n({ sources: t, className: n }) {
697
+ return t != null && t.length ? /* @__PURE__ */ p(
698
+ "section",
699
+ {
700
+ className: v(B.card, n),
701
+ "data-agenttic-sources-card": !0,
702
+ "data-slot": "sources",
703
+ children: [
704
+ /* @__PURE__ */ e("p", { className: B.heading, "data-slot": "heading", children: w("Sources", "a8c-agenttic") }),
705
+ /* @__PURE__ */ e("ul", { className: B.list, "data-slot": "list", children: t.map((o, a) => {
706
+ const i = o.title || o.url || o.label || w("Untitled source", "a8c-agenttic"), s = o.id || o.url || `${i}-${a}`;
707
+ return /* @__PURE__ */ p(
708
+ "li",
709
+ {
710
+ className: B.item,
711
+ "data-slot": "source",
712
+ children: [
713
+ o.url ? /* @__PURE__ */ e(
714
+ "a",
715
+ {
716
+ className: B.title,
717
+ "data-slot": "title",
718
+ href: o.url,
719
+ target: "_blank",
720
+ rel: "noopener noreferrer",
721
+ children: i
722
+ }
723
+ ) : /* @__PURE__ */ e(
724
+ "span",
725
+ {
726
+ className: B.title,
727
+ "data-slot": "title",
728
+ children: i
729
+ }
730
+ ),
731
+ o.label ? /* @__PURE__ */ e(
732
+ "span",
733
+ {
734
+ className: B.label,
735
+ "data-slot": "label",
736
+ children: o.label
737
+ }
738
+ ) : null
739
+ ]
740
+ },
741
+ s
742
+ );
743
+ }) })
744
+ ]
745
+ }
746
+ ) : null;
747
+ }
748
+ function we({ className: t, size: n = 24 }) {
749
+ return /* @__PURE__ */ e(
750
+ "svg",
751
+ {
752
+ width: n,
753
+ height: n,
754
+ viewBox: "0 0 24 24",
755
+ fill: "none",
756
+ xmlns: "http://www.w3.org/2000/svg",
757
+ className: t,
758
+ children: /* @__PURE__ */ e(
759
+ "path",
760
+ {
761
+ d: "M12 5C12.4142 5 12.75 5.33579 12.75 5.75V11.25H18.25C18.6642 11.25 19 11.5858 19 12C19 12.4142 18.6642 12.75 18.25 12.75H12.75V18.25C12.75 18.6642 12.4142 19 12 19C11.5858 19 11.25 18.6642 11.25 18.25V12.75H5.75C5.33579 12.75 5 12.4142 5 12C5 11.5858 5.33579 11.25 5.75 11.25H11.25V5.75C11.25 5.33579 11.5858 5 12 5Z",
762
+ fill: "currentColor"
763
+ }
764
+ )
765
+ }
766
+ );
767
+ }
768
+ function ye({
769
+ className: t,
770
+ disabled: n,
771
+ readOnly: o,
772
+ customActions: a,
773
+ actionOrder: i,
774
+ onKeyDown: s,
775
+ layout: r,
776
+ imageUploaderRef: f,
777
+ imageUploadDisabled: g
778
+ } = {}) {
779
+ const {
780
+ inputValue: d,
781
+ setInputValue: u,
782
+ handleSubmit: c,
783
+ handleKeyDown: b,
784
+ textareaRef: m,
785
+ placeholder: N,
786
+ isProcessing: y,
787
+ onStop: x,
788
+ fromCompact: A,
789
+ onExpand: h,
790
+ showExpandButton: R,
791
+ focusOnMount: $,
792
+ onInputFocus: P,
793
+ onInputBlur: F
794
+ } = Z(), G = (M) => {
795
+ s == null || s(M), !M.defaultPrevented && b(M);
796
+ }, q = st(() => f ? [{
797
+ id: "image-upload",
798
+ icon: /* @__PURE__ */ e(we, {}),
799
+ onClick: () => {
800
+ var j;
801
+ return (j = f.current) == null ? void 0 : j.openFileDialog();
802
+ },
803
+ variant: "ghost",
804
+ disabled: g,
805
+ "aria-label": w("Upload image", "a8c-agenttic")
806
+ }, ...a || []] : a, [f, a, g]);
807
+ return /* @__PURE__ */ e(
808
+ Xt,
809
+ {
810
+ value: d,
811
+ onChange: u,
812
+ onSubmit: c,
813
+ onKeyDown: G,
814
+ onFocus: P,
815
+ onBlur: F,
816
+ textareaRef: m,
817
+ placeholder: N,
818
+ isProcessing: y,
819
+ onStop: x,
820
+ fromCompact: A,
821
+ onExpand: h,
822
+ showExpandButton: R,
823
+ focusOnMount: $,
824
+ disabled: n,
825
+ readOnly: o,
826
+ customActions: q,
827
+ actionOrder: i,
828
+ className: t,
829
+ layout: r ?? (f ? "stacked" : "inline")
830
+ }
831
+ );
832
+ }
833
+ function _e({
834
+ className: t,
835
+ showSuggestions: n,
836
+ onSelect: o
837
+ } = {}) {
838
+ const {
839
+ suggestions: a,
840
+ handleSuggestionSubmit: i,
841
+ inputValue: s,
842
+ messages: r,
843
+ variant: f,
844
+ emptyView: g
845
+ } = Z(), d = et(
846
+ (u, c) => {
847
+ try {
848
+ const b = u.prompt ?? u.label;
849
+ o == null || o(b);
850
+ } catch (b) {
851
+ console.warn("Suggestions onSelect callback failed:", b);
852
+ }
853
+ i(u, c);
854
+ },
855
+ [o, i]
856
+ );
857
+ return s && !n || g && ["floating", "embedded"].includes(f) && r.length === 0 && !s ? null : /* @__PURE__ */ e(
858
+ me,
859
+ {
860
+ suggestions: a,
861
+ onSubmit: d,
862
+ className: t
863
+ }
864
+ );
865
+ }
866
+ function Ne({ className: t, size: n = 18 }) {
867
+ return /* @__PURE__ */ p(
868
+ "svg",
869
+ {
870
+ width: n,
871
+ height: n,
872
+ viewBox: "0 0 18 18",
873
+ fill: "none",
874
+ xmlns: "http://www.w3.org/2000/svg",
875
+ className: t,
876
+ role: "img",
877
+ "aria-label": "Alert",
878
+ children: [
879
+ /* @__PURE__ */ e("path", { d: "M8.4375 12V10.875H9.5625V12H8.4375Z", fill: "currentColor" }),
880
+ /* @__PURE__ */ e(
881
+ "path",
882
+ {
883
+ d: "M8.4375 6L8.4375 9.75H9.5625V6L8.4375 6Z",
884
+ fill: "currentColor"
885
+ }
886
+ ),
887
+ /* @__PURE__ */ e(
888
+ "path",
889
+ {
890
+ fillRule: "evenodd",
891
+ clipRule: "evenodd",
892
+ d: "M9 3C5.68629 3 3 5.68629 3 9C3 12.3137 5.68629 15 9 15C12.3137 15 15 12.3137 15 9C15 5.68629 12.3137 3 9 3ZM4.125 9C4.125 11.6924 6.30761 13.875 9 13.875C11.6924 13.875 13.875 11.6924 13.875 9C13.875 6.30761 11.6924 4.125 9 4.125C6.30761 4.125 4.125 6.30761 4.125 9Z",
893
+ fill: "currentColor"
894
+ }
895
+ )
896
+ ]
897
+ }
898
+ );
899
+ }
900
+ function xe({ className: t, size: n = 18 }) {
901
+ return /* @__PURE__ */ p(
902
+ "svg",
903
+ {
904
+ width: n,
905
+ height: n,
906
+ viewBox: "0 0 18 18",
907
+ fill: "none",
908
+ xmlns: "http://www.w3.org/2000/svg",
909
+ className: t,
910
+ role: "img",
911
+ "aria-label": "Alert",
912
+ children: [
913
+ /* @__PURE__ */ e(
914
+ "path",
915
+ {
916
+ d: "M9.56279 13.0952H8.43779V11.9702H9.56279V13.0952Z",
917
+ fill: "currentColor"
918
+ }
919
+ ),
920
+ /* @__PURE__ */ e(
921
+ "path",
922
+ {
923
+ d: "M8.43779 10.8452H9.56279V7.0952L8.43779 7.0952V10.8452Z",
924
+ fill: "currentColor"
925
+ }
926
+ ),
927
+ /* @__PURE__ */ e(
928
+ "path",
929
+ {
930
+ fillRule: "evenodd",
931
+ clipRule: "evenodd",
932
+ d: "M7.85634 3.48153C8.35812 2.58949 9.64245 2.58949 10.1442 3.48153L15.6118 13.2017C16.104 14.0767 15.4717 15.1577 14.4679 15.1577H3.53267C2.52884 15.1577 1.89659 14.0767 2.38873 13.2017L7.85634 3.48153ZM9.16371 4.03308C9.09203 3.90564 8.90855 3.90564 8.83686 4.03308L3.36925 13.7533C3.29895 13.8783 3.38927 14.0327 3.53267 14.0327H14.4679C14.6113 14.0327 14.7016 13.8783 14.6313 13.7533L9.16371 4.03308Z",
933
+ fill: "currentColor"
934
+ }
935
+ )
936
+ ]
937
+ }
938
+ );
939
+ }
940
+ const Ie = "Notice-module_container", Se = "Notice-module_isSuccess", $e = "Notice-module_icon", Le = "Notice-module_isWarning", ke = "Notice-module_isError", De = "Notice-module_content", Ae = "Notice-module_actions", Re = "Notice-module_action", Be = "Notice-module_dismissible", S = {
941
+ container: Ie,
942
+ isSuccess: Se,
943
+ icon: $e,
944
+ isWarning: Le,
945
+ isError: ke,
946
+ content: De,
947
+ actions: Ae,
948
+ action: Re,
949
+ dismissible: Be
950
+ };
951
+ function We({
952
+ icon: t,
953
+ message: n,
954
+ action: o,
955
+ dismissible: a = !0,
956
+ onDismiss: i,
957
+ className: s,
958
+ status: r
959
+ }) {
960
+ const g = et(() => {
961
+ if (k.isValidElement(t))
962
+ return t;
963
+ if (t === !1 || t === null)
964
+ return null;
965
+ switch (r) {
966
+ case "warning":
967
+ return /* @__PURE__ */ e(Ne, {});
968
+ case "error":
969
+ return /* @__PURE__ */ e(xe, {});
970
+ default:
971
+ return null;
972
+ }
973
+ }, [t, r])();
974
+ return /* @__PURE__ */ p(
975
+ "div",
976
+ {
977
+ "data-slot": "notice",
978
+ className: v(
979
+ S.container,
980
+ {
981
+ [S.isSuccess]: r === "success",
982
+ [S.isWarning]: r === "warning",
983
+ [S.isError]: r === "error"
984
+ },
985
+ s
986
+ ),
987
+ children: [
988
+ /* @__PURE__ */ p("div", { className: S.content, children: [
989
+ g && /* @__PURE__ */ e("div", { className: S.icon, children: g }),
990
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
991
+ vt,
992
+ {
993
+ allowedElements: ["p", "strong", "em", "a", "br"],
994
+ unwrapDisallowed: !0,
995
+ components: {
996
+ a: ({ node: d, ...u }) => /* @__PURE__ */ e(
997
+ "a",
998
+ {
999
+ ...u,
1000
+ target: "_blank",
1001
+ rel: "noopener noreferrer",
1002
+ children: u.children
1003
+ }
1004
+ )
1005
+ },
1006
+ children: n
1007
+ }
1008
+ ) })
1009
+ ] }),
1010
+ /* @__PURE__ */ p("div", { className: S.actions, children: [
1011
+ o && /* @__PURE__ */ e(
1012
+ D,
1013
+ {
1014
+ className: S.action,
1015
+ onClick: o.onClick,
1016
+ variant: "link",
1017
+ children: o.label
1018
+ }
1019
+ ),
1020
+ a && i && /* @__PURE__ */ e(
1021
+ D,
1022
+ {
1023
+ className: S.dismissible,
1024
+ onClick: i,
1025
+ variant: "ghost",
1026
+ size: "sm",
1027
+ icon: /* @__PURE__ */ e(pe, {})
1028
+ }
1029
+ )
1030
+ ] })
1031
+ ]
1032
+ }
1033
+ );
1034
+ }
1035
+ function Me({ className: t } = {}) {
1036
+ const { notice: n } = Z();
1037
+ return n ? /* @__PURE__ */ e(
1038
+ We,
1039
+ {
1040
+ icon: n.icon,
1041
+ message: n.message,
1042
+ action: n.action,
1043
+ dismissible: n.dismissible,
1044
+ onDismiss: n.onDismiss,
1045
+ className: t,
1046
+ status: n.status
1047
+ }
1048
+ ) : null;
1049
+ }
1050
+ const je = "ChatFooter-module_container", Ee = "ChatFooter-module_disclosure", z = {
1051
+ container: je,
1052
+ disclosure: Ee
1053
+ }, Pe = "https://automattic.com/ai-guidelines/";
1054
+ function Ve() {
1055
+ const t = (
1056
+ /* translators: %s: the linked label "Guidelines" (links to Automattic's AI guidelines). */
1057
+ w("You’re chatting with AI. %s.", "a8c-agenttic")
1058
+ ), [n, o] = t.split("%s");
1059
+ return /* @__PURE__ */ p(Y, { children: [
1060
+ n,
1061
+ /* @__PURE__ */ e(
1062
+ "a",
1063
+ {
1064
+ href: Pe,
1065
+ target: "_blank",
1066
+ rel: "noopener noreferrer",
1067
+ "aria-label": w(
1068
+ "Guidelines (opens in a new tab)",
1069
+ "a8c-agenttic"
1070
+ ),
1071
+ children: w("Guidelines", "a8c-agenttic")
1072
+ }
1073
+ ),
1074
+ o
1075
+ ] });
1076
+ }
1077
+ function He({
1078
+ children: t
1079
+ }) {
1080
+ return t === !1 || t === null || t === void 0 ? null : /* @__PURE__ */ e(
1081
+ "div",
1082
+ {
1083
+ "data-slot": "chat-compliance-disclosure",
1084
+ className: z.disclosure,
1085
+ children: t
1086
+ }
1087
+ );
1088
+ }
1089
+ function Nn({
1090
+ children: t,
1091
+ className: n,
1092
+ complianceDisclosure: o = /* @__PURE__ */ e(Ve, {})
1093
+ } = {}) {
1094
+ const a = /* @__PURE__ */ e(He, { children: o });
1095
+ return t ? /* @__PURE__ */ p(Y, { children: [
1096
+ /* @__PURE__ */ e(
1097
+ W.div,
1098
+ {
1099
+ "data-slot": "chat-footer",
1100
+ className: v(z.container, n),
1101
+ initial: { opacity: 0, scale: 1 },
1102
+ animate: { opacity: 1, scale: 1 },
1103
+ transition: { ...U },
1104
+ children: t
1105
+ }
1106
+ ),
1107
+ a
1108
+ ] }) : /* @__PURE__ */ p(Y, { children: [
1109
+ /* @__PURE__ */ p(
1110
+ W.div,
1111
+ {
1112
+ "data-slot": "chat-footer",
1113
+ className: v(z.container, n),
1114
+ initial: { opacity: 0, scale: 1 },
1115
+ animate: { opacity: 1, scale: 1 },
1116
+ transition: { ...U },
1117
+ children: [
1118
+ /* @__PURE__ */ e(_e, {}),
1119
+ /* @__PURE__ */ e(Me, {}),
1120
+ /* @__PURE__ */ e(ye, {})
1121
+ ]
1122
+ }
1123
+ ),
1124
+ a
1125
+ ] });
1126
+ }
1127
+ const Te = "QuestionCard-module_card", Ue = "QuestionCard-module_question", Ze = "QuestionCard-module_choices", Oe = "QuestionCard-module_choicesGrid", Qe = "QuestionCard-module_choice", Fe = "QuestionCard-module_answered", Ge = "QuestionCard-module_label", qe = "QuestionCard-module_description", L = {
1128
+ card: Te,
1129
+ question: Ue,
1130
+ choices: Ze,
1131
+ choicesGrid: Oe,
1132
+ choice: Qe,
1133
+ answered: Fe,
1134
+ label: Ge,
1135
+ description: qe
1136
+ };
1137
+ function xn({
1138
+ prompt: t,
1139
+ onAnswer: n,
1140
+ disabled: o = !1,
1141
+ answered: a = !1,
1142
+ answeredChoice: i,
1143
+ className: s,
1144
+ renderChoiceContent: r
1145
+ }) {
1146
+ const f = o || a, g = t.choices.slice(0, 4);
1147
+ return /* @__PURE__ */ p(
1148
+ "section",
1149
+ {
1150
+ className: v(L.card, s),
1151
+ "data-agenttic-question-card": !0,
1152
+ "data-slot": "card",
1153
+ children: [
1154
+ /* @__PURE__ */ e("p", { className: L.question, "data-slot": "question", children: t.question }),
1155
+ /* @__PURE__ */ e(
1156
+ "div",
1157
+ {
1158
+ className: v(
1159
+ L.choices,
1160
+ g.length === 4 ? L.choicesGrid : void 0
1161
+ ),
1162
+ "data-slot": "choices",
1163
+ children: g.map((d, u) => {
1164
+ const c = d.message ?? d.label, b = i === c;
1165
+ return /* @__PURE__ */ p(
1166
+ "button",
1167
+ {
1168
+ type: "button",
1169
+ "data-slot": "choice",
1170
+ className: v(
1171
+ L.choice,
1172
+ b ? L.answered : void 0
1173
+ ),
1174
+ disabled: f,
1175
+ "aria-pressed": b || void 0,
1176
+ onClick: () => n(c, d),
1177
+ children: [
1178
+ /* @__PURE__ */ e("span", { className: L.label, "data-slot": "label", children: d.label }),
1179
+ d.description ? /* @__PURE__ */ e(
1180
+ "span",
1181
+ {
1182
+ className: L.description,
1183
+ "data-slot": "description",
1184
+ children: d.description
1185
+ }
1186
+ ) : null,
1187
+ r == null ? void 0 : r(d)
1188
+ ]
1189
+ },
1190
+ `${d.label}-${u}`
1191
+ );
1192
+ })
1193
+ }
1194
+ )
1195
+ ]
1196
+ }
1197
+ );
1198
+ }
1199
+ const Ke = "DiffCard-module_card", Xe = "DiffCard-module_isResolved", Ye = "DiffCard-module_title", Je = "DiffCard-module_summary", ze = "DiffCard-module_body", tn = "DiffCard-module_change", en = "DiffCard-module_changeLabel", nn = "DiffCard-module_diff", on = "DiffCard-module_removed", an = "DiffCard-module_added", sn = "DiffCard-module_resolution", ln = "DiffCard-module_actions", rn = "DiffCard-module_action", cn = "DiffCard-module_accept", dn = "DiffCard-module_reject", C = {
1200
+ card: Ke,
1201
+ isResolved: Xe,
1202
+ title: Ye,
1203
+ summary: Je,
1204
+ body: ze,
1205
+ change: tn,
1206
+ changeLabel: en,
1207
+ diff: nn,
1208
+ removed: on,
1209
+ added: an,
1210
+ resolution: sn,
1211
+ actions: ln,
1212
+ action: rn,
1213
+ accept: cn,
1214
+ reject: dn
1215
+ };
1216
+ function un(t) {
1217
+ return typeof t == "string" ? [] : Array.isArray(t) ? t : [t];
1218
+ }
1219
+ function mn(t, n) {
1220
+ const o = typeof t.original == "string" && t.original.length > 0, a = typeof t.replacement == "string" && t.replacement.length > 0;
1221
+ return /* @__PURE__ */ p("div", { className: C.change, "data-slot": "change", children: [
1222
+ t.label ? /* @__PURE__ */ e("span", { className: C.changeLabel, "data-slot": "change-label", children: t.label }) : null,
1223
+ o ? /* @__PURE__ */ e(
1224
+ "pre",
1225
+ {
1226
+ className: v(C.diff, C.removed),
1227
+ "data-slot": "original",
1228
+ children: t.original
1229
+ }
1230
+ ) : null,
1231
+ a ? /* @__PURE__ */ e(
1232
+ "pre",
1233
+ {
1234
+ className: v(C.diff, C.added),
1235
+ "data-slot": "replacement",
1236
+ children: t.replacement
1237
+ }
1238
+ ) : null
1239
+ ] }, n);
1240
+ }
1241
+ function In({
1242
+ diff: t,
1243
+ title: n,
1244
+ summary: o,
1245
+ onResolve: a,
1246
+ disabled: i = !1,
1247
+ resolved: s,
1248
+ acceptLabel: r,
1249
+ rejectLabel: f,
1250
+ className: g,
1251
+ renderDiff: d
1252
+ }) {
1253
+ const u = !!s, c = i || u, b = un(t);
1254
+ let m;
1255
+ return d ? m = d(t) : typeof t == "string" ? m = /* @__PURE__ */ e("pre", { className: C.diff, "data-slot": "diff", children: t }) : m = b.map(mn), /* @__PURE__ */ p(
1256
+ "section",
1257
+ {
1258
+ className: v(
1259
+ C.card,
1260
+ u ? C.isResolved : void 0,
1261
+ g
1262
+ ),
1263
+ "data-agenttic-diff-card": !0,
1264
+ "data-slot": "card",
1265
+ children: [
1266
+ n ? /* @__PURE__ */ e("p", { className: C.title, "data-slot": "title", children: n }) : null,
1267
+ o ? /* @__PURE__ */ e("p", { className: C.summary, "data-slot": "summary", children: o }) : null,
1268
+ /* @__PURE__ */ e("div", { className: C.body, "data-slot": "body", children: m }),
1269
+ u ? /* @__PURE__ */ e("p", { className: C.resolution, "data-slot": "resolution", children: s === "accepted" ? w("Accepted", "a8c-agenttic") : w("Rejected", "a8c-agenttic") }) : /* @__PURE__ */ p("div", { className: C.actions, "data-slot": "actions", children: [
1270
+ /* @__PURE__ */ e(
1271
+ "button",
1272
+ {
1273
+ type: "button",
1274
+ "data-slot": "accept",
1275
+ className: v(C.action, C.accept),
1276
+ disabled: c,
1277
+ onClick: () => a("accepted"),
1278
+ children: r ?? w("Accept", "a8c-agenttic")
1279
+ }
1280
+ ),
1281
+ /* @__PURE__ */ e(
1282
+ "button",
1283
+ {
1284
+ type: "button",
1285
+ "data-slot": "reject",
1286
+ className: v(C.action, C.reject),
1287
+ disabled: c,
1288
+ onClick: () => a("rejected"),
1289
+ children: f ?? w("Reject", "a8c-agenttic")
1290
+ }
1291
+ )
1292
+ ] })
1293
+ ]
1294
+ }
1295
+ );
1296
+ }
1297
+ export {
1298
+ yn as A,
1299
+ D as B,
1300
+ Xt as C,
1301
+ Ve as D,
1302
+ We as N,
1303
+ we as P,
1304
+ xn as Q,
1305
+ me as S,
1306
+ pe as X,
1307
+ Ft as a,
1308
+ yt as b,
1309
+ v as c,
1310
+ _n as d,
1311
+ Nn as e,
1312
+ U as f,
1313
+ Me as g,
1314
+ _e as h,
1315
+ ye as i,
1316
+ He as j,
1317
+ Kt as k,
1318
+ In as l,
1319
+ wt as m,
1320
+ wn as n,
1321
+ Pt as o,
1322
+ Et as p,
1323
+ z as s,
1324
+ Z as u
1325
+ };