@ugurdemirel/landcraft 0.1.19 → 0.1.21

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,171 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as T, Fragment as oe } from "react/jsx-runtime";
3
+ import { forwardRef as ie, useState as f, useRef as k, useEffect as l } from "react";
4
+ import { Pause as ce, Play as le, RotateCcw as ae } from "../../icons.js";
5
+ import { ToolCard as ue } from "./ToolCard.js";
6
+ import { DemoWindow as H, EmptyState as de, FinishedStep as X, DemoFooter as Y, AssistantMessage as fe, ThinkingRow as me, StepProgress as he, ControlButton as K } from "./parts.js";
7
+ const ge = 24, pe = 350, ye = 1e3, Pe = 1100, Re = 2600;
8
+ function Te() {
9
+ const [q, r] = f(!1);
10
+ return l(() => {
11
+ if (typeof window > "u" || typeof window.matchMedia != "function") return;
12
+ const m = window.matchMedia("(prefers-reduced-motion: reduce)");
13
+ r(m.matches);
14
+ }, []), q;
15
+ }
16
+ const we = ie(function({
17
+ script: r,
18
+ title: m,
19
+ subtitle: I,
20
+ logo: S,
21
+ logoSrc: x,
22
+ logoAlt: C,
23
+ logoClassName: b,
24
+ height: A,
25
+ autoplay: a = !0,
26
+ paused: h = !1,
27
+ loop: U = !1,
28
+ speed: E = 1,
29
+ showControls: Z = !0,
30
+ showSteps: $ = !0,
31
+ onDone: O,
32
+ className: F,
33
+ "aria-label": L,
34
+ ...N
35
+ }, _) {
36
+ const ee = Te(), g = !a || ee, p = E && E > 0 ? E : 1, [W, te] = f(0), [j, u] = f(a && !h), [i, B] = f(0), [D, ne] = f(""), [z, y] = f(!1), w = k(null), J = k(""), d = k(0), M = k(O);
37
+ l(() => {
38
+ M.current = O;
39
+ }, [O]);
40
+ const c = r.length, s = c > 0 && i >= c, v = (e) => {
41
+ J.current = e, ne(e);
42
+ }, Q = () => {
43
+ d.current = 0, v(""), y(!1), B(0), u(!0), te((e) => e + 1);
44
+ };
45
+ if (l(() => {
46
+ d.current = 0, v(""), y(!1), B(0), u(a && !h);
47
+ }, [r, a, h]), l(() => {
48
+ h ? u(!1) : a && u(!0);
49
+ }, [h, a]), l(() => {
50
+ if (g || !j || i >= c) return;
51
+ const e = r[i], n = [];
52
+ let P;
53
+ d.current = J.current.length;
54
+ const G = () => {
55
+ n.push(
56
+ setTimeout(() => {
57
+ v(""), y(!1), d.current = 0, B((R) => R + 1);
58
+ }, pe / p)
59
+ );
60
+ };
61
+ if (e.type === "user" || e.type === "assistant") {
62
+ const R = e.text, se = Math.max(1, Math.ceil(R.length / 36));
63
+ P = setInterval(() => {
64
+ d.current += se;
65
+ const V = R.slice(0, d.current);
66
+ v(V), V.length >= R.length && (P && clearInterval(P), G());
67
+ }, ge / p);
68
+ } else e.type === "thinking" ? n.push(setTimeout(G, ye / p)) : (y(!0), n.push(
69
+ setTimeout(() => {
70
+ y(!1), G();
71
+ }, Pe / p)
72
+ ));
73
+ return () => {
74
+ P && clearInterval(P), n.forEach(clearTimeout);
75
+ };
76
+ }, [g, j, i, W, r, p, c]), l(() => {
77
+ var n;
78
+ if (g || !s || ((n = M.current) == null || n.call(M), !U)) return;
79
+ const e = setTimeout(Q, Re);
80
+ return () => clearTimeout(e);
81
+ }, [g, s, U, W]), l(() => {
82
+ const e = w.current;
83
+ e && (e.scrollTop = e.scrollHeight);
84
+ }, [i, D, z]), c === 0)
85
+ return /* @__PURE__ */ t("div", { ref: _, className: F, ...N, children: /* @__PURE__ */ t(
86
+ H,
87
+ {
88
+ title: m,
89
+ subtitle: I,
90
+ logo: S,
91
+ logoSrc: x,
92
+ logoAlt: C,
93
+ logoClassName: b,
94
+ logLabel: L ?? "Scripted agent demo",
95
+ height: A,
96
+ logRef: w,
97
+ children: /* @__PURE__ */ t(de, {})
98
+ }
99
+ ) });
100
+ if (g)
101
+ return /* @__PURE__ */ t("div", { ref: _, className: F, ...N, children: /* @__PURE__ */ t(
102
+ H,
103
+ {
104
+ title: m,
105
+ subtitle: I,
106
+ logo: S,
107
+ logoSrc: x,
108
+ logoAlt: C,
109
+ logoClassName: b,
110
+ logLabel: L ?? "Scripted agent demo",
111
+ height: A,
112
+ logRef: w,
113
+ footer: /* @__PURE__ */ t(Y, {}),
114
+ children: r.map((e, n) => /* @__PURE__ */ t(X, { step: e }, n))
115
+ }
116
+ ) });
117
+ const o = r[Math.min(i, c - 1)], re = !s && o.type === "user" ? D : void 0;
118
+ return /* @__PURE__ */ t("div", { ref: _, className: F, ...N, children: /* @__PURE__ */ T(
119
+ H,
120
+ {
121
+ title: m,
122
+ subtitle: I,
123
+ logo: S,
124
+ logoSrc: x,
125
+ logoAlt: C,
126
+ logoClassName: b,
127
+ logLabel: L ?? "Scripted agent demo",
128
+ height: A,
129
+ logRef: w,
130
+ footer: /* @__PURE__ */ t(
131
+ Y,
132
+ {
133
+ composing: re,
134
+ controls: Z ? /* @__PURE__ */ T(oe, { children: [
135
+ j && !s ? /* @__PURE__ */ T(K, { onClick: () => u(!1), "aria-label": "Pause demo", children: [
136
+ /* @__PURE__ */ t(ce, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
137
+ "Pause"
138
+ ] }) : s ? null : /* @__PURE__ */ T(K, { onClick: () => u(!0), "aria-label": "Play demo", children: [
139
+ /* @__PURE__ */ t(le, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
140
+ "Play"
141
+ ] }),
142
+ /* @__PURE__ */ T(K, { onClick: Q, "aria-label": "Replay demo", children: [
143
+ /* @__PURE__ */ t(ae, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
144
+ "Replay"
145
+ ] })
146
+ ] }) : void 0,
147
+ progress: $ ? /* @__PURE__ */ t("span", { className: "ml-auto", children: /* @__PURE__ */ t(he, { current: i + 1, total: c, done: s }) }) : void 0
148
+ }
149
+ ),
150
+ children: [
151
+ r.slice(0, i).map((e, n) => /* @__PURE__ */ t(X, { step: e }, n)),
152
+ !s && o.type === "assistant" ? /* @__PURE__ */ t(fe, { text: D, partial: !0 }) : null,
153
+ !s && o.type === "thinking" ? /* @__PURE__ */ t(me, { label: o.label ?? "Thinking…" }) : null,
154
+ !s && o.type === "tool" ? /* @__PURE__ */ t(
155
+ ue,
156
+ {
157
+ name: o.name,
158
+ args: o.args,
159
+ result: o.result,
160
+ status: z ? "running" : o.status === "error" ? "error" : "success"
161
+ }
162
+ ) : null
163
+ ]
164
+ }
165
+ ) });
166
+ });
167
+ we.displayName = "AgentDemoPlayer";
168
+ export {
169
+ we as AgentDemoPlayer
170
+ };
171
+ //# sourceMappingURL=Player.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Player.js","sources":["../../../../src/components/AgentDemo/Player.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { Pause, Play, RotateCcw } from \"../../icons\";\nimport type { AgentDemoProps } from \"./types\";\nimport { ToolCard } from \"./ToolCard\";\nimport {\n AssistantMessage,\n ControlButton,\n DemoFooter,\n DemoWindow,\n EmptyState,\n FinishedStep,\n StepProgress,\n ThinkingRow,\n} from \"./parts\";\n\nconst TICK = 24;\nconst GAP = 350;\nconst THINKING_MS = 1000;\nconst TOOL_MS = 1100;\nconst LOOP_PAUSE = 2600;\n\nfunction usePrefersReducedMotion() {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return;\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n setReduced(query.matches);\n }, []);\n return reduced;\n}\n\nexport const AgentDemoPlayer = forwardRef<HTMLDivElement, AgentDemoProps>(function AgentDemoPlayer(\n {\n script,\n title,\n subtitle,\n logo,\n logoSrc,\n logoAlt,\n logoClassName,\n height,\n autoplay = true,\n paused = false,\n loop = false,\n speed = 1,\n showControls = true,\n showSteps = true,\n onDone,\n className,\n \"aria-label\": ariaLabel,\n ...props\n },\n ref,\n) {\n const reduceMotion = usePrefersReducedMotion();\n const staticRender = !autoplay || reduceMotion;\n const rate = speed && speed > 0 ? speed : 1;\n\n const [runId, setRunId] = useState(0);\n const [playing, setPlaying] = useState(autoplay && !paused);\n const [completed, setCompleted] = useState(0);\n const [partial, setPartial] = useState(\"\");\n const [toolRunning, setToolRunning] = useState(false);\n\n const logRef = useRef<HTMLDivElement | null>(null);\n const partialRef = useRef(\"\");\n const progressRef = useRef(0);\n const onDoneRef = useRef(onDone);\n useEffect(() => {\n onDoneRef.current = onDone;\n }, [onDone]);\n\n const total = script.length;\n const done = total > 0 && completed >= total;\n\n const setPartialBoth = (value: string) => {\n partialRef.current = value;\n setPartial(value);\n };\n\n const replay = () => {\n progressRef.current = 0;\n setPartialBoth(\"\");\n setToolRunning(false);\n setCompleted(0);\n setPlaying(true);\n setRunId((id) => id + 1);\n };\n\n // Reset when the script changes.\n useEffect(() => {\n progressRef.current = 0;\n setPartialBoth(\"\");\n setToolRunning(false);\n setCompleted(0);\n setPlaying(autoplay && !paused);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [script, autoplay, paused]);\n\n // Follow the `paused` prop (explicit Play/Pause clicks always win locally).\n useEffect(() => {\n if (paused) {\n setPlaying(false);\n } else if (autoplay) {\n setPlaying(true);\n }\n }, [paused, autoplay]);\n\n // Core playback loop: one effect per in-progress step.\n useEffect(() => {\n if (staticRender || !playing || completed >= total) return;\n const step = script[completed];\n const timers: ReturnType<typeof setTimeout>[] = [];\n let interval: ReturnType<typeof setInterval> | undefined;\n // Resume typing where it paused instead of restarting the message.\n progressRef.current = partialRef.current.length;\n\n const finish = () => {\n timers.push(\n setTimeout(() => {\n setPartialBoth(\"\");\n setToolRunning(false);\n progressRef.current = 0;\n setCompleted((c) => c + 1);\n }, GAP / rate),\n );\n };\n\n if (step.type === \"user\" || step.type === \"assistant\") {\n const full = step.text;\n const chunk = Math.max(1, Math.ceil(full.length / 36));\n interval = setInterval(() => {\n progressRef.current += chunk;\n const next = full.slice(0, progressRef.current);\n setPartialBoth(next);\n if (next.length >= full.length) {\n if (interval) clearInterval(interval);\n finish();\n }\n }, TICK / rate);\n } else if (step.type === \"thinking\") {\n timers.push(setTimeout(finish, THINKING_MS / rate));\n } else {\n setToolRunning(true);\n timers.push(\n setTimeout(() => {\n setToolRunning(false);\n finish();\n }, TOOL_MS / rate),\n );\n }\n\n return () => {\n if (interval) clearInterval(interval);\n timers.forEach(clearTimeout);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [staticRender, playing, completed, runId, script, rate, total]);\n\n // Completion: notify once per run, then loop if asked.\n useEffect(() => {\n if (staticRender || !done) return;\n onDoneRef.current?.();\n if (!loop) return;\n const timer = setTimeout(replay, LOOP_PAUSE);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [staticRender, done, loop, runId]);\n\n // Keep the newest step in view while playing.\n useEffect(() => {\n const el = logRef.current;\n if (el) el.scrollTop = el.scrollHeight;\n }, [completed, partial, toolRunning]);\n\n if (total === 0) {\n return (\n <div ref={ref} className={className} {...props}>\n <DemoWindow\n title={title}\n subtitle={subtitle}\n logo={logo}\n logoSrc={logoSrc}\n logoAlt={logoAlt}\n logoClassName={logoClassName}\n logLabel={ariaLabel ?? \"Scripted agent demo\"}\n height={height}\n logRef={logRef}\n >\n <EmptyState />\n </DemoWindow>\n </div>\n );\n }\n\n if (staticRender) {\n return (\n <div ref={ref} className={className} {...props}>\n <DemoWindow\n title={title}\n subtitle={subtitle}\n logo={logo}\n logoSrc={logoSrc}\n logoAlt={logoAlt}\n logoClassName={logoClassName}\n logLabel={ariaLabel ?? \"Scripted agent demo\"}\n height={height}\n logRef={logRef}\n footer={<DemoFooter />}\n >\n {script.map((step, i) => (\n <FinishedStep key={i} step={step} />\n ))}\n </DemoWindow>\n </div>\n );\n }\n\n const current = script[Math.min(completed, total - 1)];\n // The user \"types\" in the input box; the bubble only mounts once sent.\n const composing = !done && current.type === \"user\" ? partial : undefined;\n\n return (\n <div ref={ref} className={className} {...props}>\n <DemoWindow\n title={title}\n subtitle={subtitle}\n logo={logo}\n logoSrc={logoSrc}\n logoAlt={logoAlt}\n logoClassName={logoClassName}\n logLabel={ariaLabel ?? \"Scripted agent demo\"}\n height={height}\n logRef={logRef}\n footer={\n <DemoFooter\n composing={composing}\n controls={\n showControls ? (\n <>\n {playing && !done ? (\n <ControlButton onClick={() => setPlaying(false)} aria-label=\"Pause demo\">\n <Pause className=\"h-3.5 w-3.5\" aria-hidden />\n Pause\n </ControlButton>\n ) : !done ? (\n <ControlButton onClick={() => setPlaying(true)} aria-label=\"Play demo\">\n <Play className=\"h-3.5 w-3.5\" aria-hidden />\n Play\n </ControlButton>\n ) : null}\n <ControlButton onClick={replay} aria-label=\"Replay demo\">\n <RotateCcw className=\"h-3.5 w-3.5\" aria-hidden />\n Replay\n </ControlButton>\n </>\n ) : undefined\n }\n progress={\n showSteps ? (\n <span className=\"ml-auto\">\n <StepProgress current={completed + 1} total={total} done={done} />\n </span>\n ) : undefined\n }\n />\n }\n >\n {script.slice(0, completed).map((step, i) => (\n <FinishedStep key={i} step={step} />\n ))}\n {!done && current.type === \"assistant\" ? (\n <AssistantMessage text={partial} partial />\n ) : null}\n {!done && current.type === \"thinking\" ? (\n <ThinkingRow label={current.label ?? \"Thinking…\"} />\n ) : null}\n {!done && current.type === \"tool\" ? (\n <ToolCard\n name={current.name}\n args={current.args}\n result={current.result}\n status={\n toolRunning ? \"running\" : current.status === \"error\" ? \"error\" : \"success\"\n }\n />\n ) : null}\n </DemoWindow>\n </div>\n );\n});\nAgentDemoPlayer.displayName = \"AgentDemoPlayer\";\n"],"names":["TICK","GAP","THINKING_MS","TOOL_MS","LOOP_PAUSE","usePrefersReducedMotion","reduced","setReduced","useState","useEffect","query","AgentDemoPlayer","forwardRef","script","title","subtitle","logo","logoSrc","logoAlt","logoClassName","height","autoplay","paused","loop","speed","showControls","showSteps","onDone","className","ariaLabel","props","ref","reduceMotion","staticRender","rate","runId","setRunId","playing","setPlaying","completed","setCompleted","partial","setPartial","toolRunning","setToolRunning","logRef","useRef","partialRef","progressRef","onDoneRef","total","done","setPartialBoth","value","replay","id","step","timers","interval","finish","c","full","chunk","next","_a","timer","el","jsx","DemoWindow","EmptyState","DemoFooter","i","FinishedStep","current","composing","jsxs","Fragment","ControlButton","Pause","Play","RotateCcw","StepProgress","AssistantMessage","ThinkingRow","ToolCard"],"mappings":";;;;;AAgBA,MAAMA,KAAO,IACPC,KAAM,KACNC,KAAc,KACdC,KAAU,MACVC,KAAa;AAEnB,SAASC,KAA0B;AACjC,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAC5C,SAAAC,EAAU,MAAM;AACd,QAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,WAAY;AAC9E,UAAMC,IAAQ,OAAO,WAAW,kCAAkC;AAClE,IAAAH,EAAWG,EAAM,OAAO;AAAA,EAC1B,GAAG,CAAA,CAAE,GACEJ;AACT;AAEO,MAAMK,KAAkBC,GAA2C,SACxE;AAAA,EACE,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,QAAAC,IAAS;AAAA,EACT,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,cAAAC,IAAe;AAAA,EACf,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAcC;AAAA,EACd,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,KAAe3B,GAAA,GACf4B,IAAe,CAACZ,KAAYW,IAC5BE,IAAOV,KAASA,IAAQ,IAAIA,IAAQ,GAEpC,CAACW,GAAOC,EAAQ,IAAI5B,EAAS,CAAC,GAC9B,CAAC6B,GAASC,CAAU,IAAI9B,EAASa,KAAY,CAACC,CAAM,GACpD,CAACiB,GAAWC,CAAY,IAAIhC,EAAS,CAAC,GACtC,CAACiC,GAASC,EAAU,IAAIlC,E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AiB,MAAMzC,GAAS,SAAO,GAAA,CAAC,IACvC;AAAA,QACH,CAACU,KAAQsB,EAAQ,SAAS,aACzB,gBAAAN,EAACgB,IAAA,EAAY,OAAOV,EAAQ,SAAS,YAAA,CAAa,IAChD;AAAA,QACH,CAACtB,KAAQsB,EAAQ,SAAS,SACzB,gBAAAN;AAAA,UAACiB;AAAA,UAAA;AAAA,YACC,MAAMX,EAAQ;AAAA,YACd,MAAMA,EAAQ;AAAA,YACd,QAAQA,EAAQ;AAAA,YAChB,QACE9B,IAAc,YAAY8B,EAAQ,WAAW,UAAU,UAAU;AAAA,UAAA;AAAA,QAAA,IAGnE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAER;AAEJ,CAAC;AACD9D,GAAgB,cAAc;"}
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
3
+ import { useState as m } from "react";
4
+ import { cn as o } from "../../utils/cn.js";
5
+ import { X as p, Check as x, Terminal as f, ChevronDown as g, Cpu as h } from "../../icons.js";
6
+ const s = {
7
+ running: "Running",
8
+ success: "Done",
9
+ error: "Failed"
10
+ };
11
+ function v({
12
+ name: d,
13
+ args: t,
14
+ result: a,
15
+ status: r = "success"
16
+ }) {
17
+ const [i, c] = m(!1), l = !!(t ?? a);
18
+ return /* @__PURE__ */ n(
19
+ "div",
20
+ {
21
+ className: o(
22
+ "rounded-xl border border-border bg-surface-strong/40",
23
+ r === "error" && "border-red-500/40"
24
+ ),
25
+ children: [
26
+ /* @__PURE__ */ n(
27
+ "button",
28
+ {
29
+ type: "button",
30
+ "aria-expanded": i,
31
+ "aria-label": `${d} details, ${s[r].toLowerCase()}`,
32
+ onClick: () => c((u) => !u),
33
+ className: "flex w-full cursor-pointer items-center gap-2.5 px-3.5 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
34
+ children: [
35
+ /* @__PURE__ */ e(
36
+ "span",
37
+ {
38
+ className: o(
39
+ "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md",
40
+ r === "error" ? "bg-red-500/15 text-red-500" : "bg-foreground/8 text-foreground"
41
+ ),
42
+ children: r === "running" ? /* @__PURE__ */ e(
43
+ "span",
44
+ {
45
+ "aria-hidden": !0,
46
+ className: "h-3 w-3 animate-spin rounded-full border-[1.5px] border-current border-t-transparent"
47
+ }
48
+ ) : r === "error" ? /* @__PURE__ */ e(p, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(x, { className: "h-3.5 w-3.5" })
49
+ }
50
+ ),
51
+ /* @__PURE__ */ e(f, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground", "aria-hidden": !0 }),
52
+ /* @__PURE__ */ e("span", { className: "truncate font-mono text-[13px] font-medium", children: d }),
53
+ /* @__PURE__ */ n(
54
+ "span",
55
+ {
56
+ className: o(
57
+ "ml-auto flex shrink-0 items-center gap-1.5 text-xs",
58
+ r === "running" ? "text-muted-foreground" : r === "error" ? "text-red-500" : "text-emerald-600 dark:text-emerald-400"
59
+ ),
60
+ children: [
61
+ r === "running" ? /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-current", "aria-hidden": !0 }) : null,
62
+ s[r]
63
+ ]
64
+ }
65
+ ),
66
+ l ? /* @__PURE__ */ e(
67
+ g,
68
+ {
69
+ "aria-hidden": !0,
70
+ className: o("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform", i && "rotate-180")
71
+ }
72
+ ) : null
73
+ ]
74
+ }
75
+ ),
76
+ i && l ? /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-border px-3.5 py-3", children: [
77
+ t ? /* @__PURE__ */ n("div", { children: [
78
+ /* @__PURE__ */ n("p", { className: "mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [
79
+ /* @__PURE__ */ e(h, { className: "h-3 w-3", "aria-hidden": !0 }),
80
+ " Arguments"
81
+ ] }),
82
+ /* @__PURE__ */ e("pre", { className: "overflow-x-auto rounded-lg bg-background/60 p-2.5 font-mono text-xs leading-5", children: t })
83
+ ] }) : null,
84
+ a ? /* @__PURE__ */ n("div", { children: [
85
+ /* @__PURE__ */ e("p", { className: "mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: "Result" }),
86
+ /* @__PURE__ */ e("p", { className: "rounded-lg bg-background/60 p-2.5 font-mono text-xs leading-5", children: a })
87
+ ] }) : null
88
+ ] }) : null
89
+ ]
90
+ }
91
+ );
92
+ }
93
+ export {
94
+ v as ToolCard
95
+ };
96
+ //# sourceMappingURL=ToolCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolCard.js","sources":["../../../../src/components/AgentDemo/ToolCard.tsx"],"sourcesContent":["\"use client\";\nimport { useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Check, ChevronDown, Cpu, Terminal, X } from \"../../icons\";\n\nexport type ToolStatus = \"running\" | \"success\" | \"error\";\n\nconst statusLabel: Record<ToolStatus, string> = {\n running: \"Running\",\n success: \"Done\",\n error: \"Failed\",\n};\n\nexport function ToolCard({\n name,\n args,\n result,\n status = \"success\",\n}: {\n name: string;\n args?: string;\n result?: string;\n status?: ToolStatus;\n}) {\n const [open, setOpen] = useState(false);\n const hasDetails = Boolean(args ?? result);\n\n return (\n <div\n className={cn(\n \"rounded-xl border border-border bg-surface-strong/40\",\n status === \"error\" && \"border-red-500/40\",\n )}\n >\n <button\n type=\"button\"\n aria-expanded={open}\n aria-label={`${name} details, ${statusLabel[status].toLowerCase()}`}\n onClick={() => setOpen((o) => !o)}\n className=\"flex w-full cursor-pointer items-center gap-2.5 px-3.5 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring\"\n >\n <span\n className={cn(\n \"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md\",\n status === \"error\" ? \"bg-red-500/15 text-red-500\" : \"bg-foreground/8 text-foreground\",\n )}\n >\n {status === \"running\" ? (\n <span\n aria-hidden\n className=\"h-3 w-3 animate-spin rounded-full border-[1.5px] border-current border-t-transparent\"\n />\n ) : status === \"error\" ? (\n <X className=\"h-3.5 w-3.5\" />\n ) : (\n <Check className=\"h-3.5 w-3.5\" />\n )}\n </span>\n <Terminal className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"truncate font-mono text-[13px] font-medium\">{name}</span>\n <span\n className={cn(\n \"ml-auto flex shrink-0 items-center gap-1.5 text-xs\",\n status === \"running\"\n ? \"text-muted-foreground\"\n : status === \"error\"\n ? \"text-red-500\"\n : \"text-emerald-600 dark:text-emerald-400\",\n )}\n >\n {status === \"running\" ? (\n <span className=\"h-1.5 w-1.5 animate-pulse rounded-full bg-current\" aria-hidden />\n ) : null}\n {statusLabel[status]}\n </span>\n {hasDetails ? (\n <ChevronDown\n aria-hidden\n className={cn(\"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform\", open && \"rotate-180\")}\n />\n ) : null}\n </button>\n {open && hasDetails ? (\n <div className=\"space-y-2 border-t border-border px-3.5 py-3\">\n {args ? (\n <div>\n <p className=\"mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\">\n <Cpu className=\"h-3 w-3\" aria-hidden /> Arguments\n </p>\n <pre className=\"overflow-x-auto rounded-lg bg-background/60 p-2.5 font-mono text-xs leading-5\">\n {args}\n </pre>\n </div>\n ) : null}\n {result ? (\n <div>\n <p className=\"mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\">\n Result\n </p>\n <p className=\"rounded-lg bg-background/60 p-2.5 font-mono text-xs leading-5\">{result}</p>\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n"],"names":["statusLabel","ToolCard","name","args","result","status","open","setOpen","useState","hasDetails","jsxs","cn","o","jsx","X","Check","Terminal","ChevronDown","Cpu"],"mappings":";;;;AAOA,MAAMA,IAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,SAA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,kBAAA;AAAA,kBAGP,UAAA;AAAA,oBAAAA,MAAW,YACV,gBAAAQ,EAAC,QAAA,EAAK,WAAU,qDAAoD,eAAW,IAAC,IAC9E;AAAA,oBACHb,EAAYK,CAAM;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEpBI,IACC,gBAAAI;AAAA,gBAACI;AAAA,gBAAA;AAAA,kBACC,eAAW;AAAA,kBACX,WAAWN,EAAG,mEAAmEL,KAAQ,YAAY;AAAA,gBAAA;AAAA,cAAA,IAErG;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAELA,KAAQG,IACP,gBAAAC,EAAC,OAAA,EAAI,WAAU,gDACZ,UAAA;AAAA,UAAAP,sBACE,OAAA,EACC,UAAA;AAAA,YAAA,gBAAAO,EAAC,KAAA,EAAE,WAAU,2GACX,UAAA;AAAA,cAAA,gBAAAG,EAACK,GAAA,EAAI,WAAU,WAAU,eAAW,IAAC;AAAA,cAAE;AAAA,YAAA,GACzC;AAAA,YACA,gBAAAL,EAAC,OAAA,EAAI,WAAU,iFACZ,UAAAV,EAAA,CACH;AAAA,UAAA,EAAA,CACF,IACE;AAAA,UACHC,sBACE,OAAA,EACC,UAAA;AAAA,YAAA,gBAAAS,EAAC,KAAA,EAAE,WAAU,iFAAgF,UAAA,UAE7F;AAAA,YACA,gBAAAA,EAAC,KAAA,EAAE,WAAU,iEAAiE,UAAAT,EAAA,CAAO;AAAA,UAAA,EAAA,CACvF,IACE;AAAA,QAAA,EAAA,CACN,IACE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
@@ -0,0 +1,163 @@
1
+ import { jsx as r, jsxs as a } from "react/jsx-runtime";
2
+ import { cn as l } from "../../utils/cn.js";
3
+ import { Send as p } from "../../icons.js";
4
+ import { ToolCard as g } from "./ToolCard.js";
5
+ function j({
6
+ title: e,
7
+ subtitle: n,
8
+ logo: t,
9
+ logoSrc: s,
10
+ logoAlt: o,
11
+ logoClassName: i,
12
+ footer: u,
13
+ logLabel: c,
14
+ logRef: m,
15
+ height: f = "70dvh",
16
+ children: x
17
+ }) {
18
+ const d = t ?? (s ? /* @__PURE__ */ r(
19
+ "img",
20
+ {
21
+ src: s,
22
+ alt: o ?? (typeof e == "string" ? e : "Logo"),
23
+ className: l("h-8 w-8 rounded-lg object-cover", i)
24
+ }
25
+ ) : void 0);
26
+ return /* @__PURE__ */ a(
27
+ "div",
28
+ {
29
+ style: { height: f },
30
+ className: "flex flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-overlay",
31
+ children: [
32
+ /* @__PURE__ */ a("div", { className: "flex shrink-0 items-center gap-3 border-b border-border px-4 py-3 sm:px-5", children: [
33
+ /* @__PURE__ */ a("div", { className: "flex gap-1.5", "aria-hidden": !0, children: [
34
+ /* @__PURE__ */ r("span", { className: "h-2.5 w-2.5 rounded-full bg-foreground/15" }),
35
+ /* @__PURE__ */ r("span", { className: "h-2.5 w-2.5 rounded-full bg-foreground/15" }),
36
+ /* @__PURE__ */ r("span", { className: "h-2.5 w-2.5 rounded-full bg-foreground/15" })
37
+ ] }),
38
+ d ? /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center", children: d }) : null,
39
+ e ?? n ? /* @__PURE__ */ a("div", { className: "min-w-0", children: [
40
+ e ? /* @__PURE__ */ r("p", { className: "truncate text-sm font-semibold tracking-tight", children: e }) : null,
41
+ n ? /* @__PURE__ */ r("p", { className: "truncate text-xs text-muted-foreground", children: n }) : null
42
+ ] }) : null
43
+ ] }),
44
+ /* @__PURE__ */ r(
45
+ "div",
46
+ {
47
+ role: "log",
48
+ ref: m,
49
+ "aria-live": "polite",
50
+ "aria-label": c,
51
+ className: "min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5",
52
+ children: /* @__PURE__ */ r("div", { className: "flex flex-col gap-4", children: x })
53
+ }
54
+ ),
55
+ u
56
+ ]
57
+ }
58
+ );
59
+ }
60
+ function M({
61
+ controls: e,
62
+ progress: n,
63
+ composing: t
64
+ }) {
65
+ return /* @__PURE__ */ a("div", { className: "shrink-0 border-t border-border px-4 py-3 sm:px-5", children: [
66
+ e ?? n ? /* @__PURE__ */ a("div", { className: "mb-3 flex items-center gap-2", children: [
67
+ e,
68
+ n
69
+ ] }) : null,
70
+ /* @__PURE__ */ a(
71
+ "div",
72
+ {
73
+ "aria-hidden": !0,
74
+ className: "flex cursor-not-allowed items-center gap-2 rounded-xl border border-border bg-surface-strong/40 px-3.5 py-2.5 text-sm text-muted-foreground select-none",
75
+ children: [
76
+ t !== void 0 ? /* @__PURE__ */ a("span", { className: "flex-1 truncate text-foreground", children: [
77
+ t,
78
+ /* @__PURE__ */ r("span", { className: "ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-foreground" })
79
+ ] }) : /* @__PURE__ */ r("span", { className: "flex-1 truncate", children: "Ask anything…" }),
80
+ /* @__PURE__ */ r(
81
+ p,
82
+ {
83
+ className: l("h-4 w-4 shrink-0", t ? "text-foreground" : void 0)
84
+ }
85
+ )
86
+ ]
87
+ }
88
+ )
89
+ ] });
90
+ }
91
+ function h({ text: e, partial: n = !1 }) {
92
+ return /* @__PURE__ */ r("div", { className: "flex justify-end", children: /* @__PURE__ */ a("p", { className: "max-w-[85%] rounded-2xl rounded-br-md bg-primary px-3.5 py-2.5 text-sm leading-6 text-on-primary", children: [
93
+ e,
94
+ n ? /* @__PURE__ */ r("span", { className: "ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-on-primary" }) : null
95
+ ] }) });
96
+ }
97
+ function b({ text: e, partial: n = !1 }) {
98
+ return /* @__PURE__ */ r("div", { className: "flex justify-start", children: /* @__PURE__ */ a("p", { className: "max-w-[90%] rounded-2xl rounded-bl-md bg-primary-soft px-3.5 py-2.5 text-sm leading-6 text-foreground", children: [
99
+ e,
100
+ n ? /* @__PURE__ */ r("span", { className: "ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-foreground" }) : null
101
+ ] }) });
102
+ }
103
+ function N({ label: e, active: n = !0 }) {
104
+ return /* @__PURE__ */ a("div", { className: "flex items-center gap-2 text-[13px] text-muted-foreground", children: [
105
+ /* @__PURE__ */ r("span", { className: "flex gap-1", "aria-hidden": !0, children: ["[animation-delay:-0.3s]", "[animation-delay:-0.15s]", ""].map((s, o) => /* @__PURE__ */ r(
106
+ "span",
107
+ {
108
+ className: l(
109
+ "h-1.5 w-1.5 rounded-full bg-current",
110
+ n && "animate-bounce",
111
+ n && s
112
+ )
113
+ },
114
+ o
115
+ )) }),
116
+ /* @__PURE__ */ r("span", { className: n ? "animate-pulse" : void 0, children: e })
117
+ ] });
118
+ }
119
+ function S() {
120
+ return /* @__PURE__ */ r("p", { className: "py-10 text-center text-sm text-muted-foreground", children: "This demo has no steps yet." });
121
+ }
122
+ function T({ current: e, total: n, done: t }) {
123
+ return /* @__PURE__ */ r("span", { className: "text-xs tabular-nums text-muted-foreground", children: t ? "Demo complete" : `Step ${Math.min(e, n)} of ${n}` });
124
+ }
125
+ function D({ step: e }) {
126
+ return e.type === "user" ? /* @__PURE__ */ r(h, { text: e.text }) : e.type === "assistant" ? /* @__PURE__ */ r(b, { text: e.text }) : e.type === "thinking" ? /* @__PURE__ */ r(N, { label: e.label ?? "Thinking…", active: !1 }) : /* @__PURE__ */ r(
127
+ g,
128
+ {
129
+ name: e.name,
130
+ args: e.args,
131
+ result: e.result,
132
+ status: e.status === "error" ? "error" : "success"
133
+ }
134
+ );
135
+ }
136
+ function A({
137
+ className: e,
138
+ ...n
139
+ }) {
140
+ return /* @__PURE__ */ r(
141
+ "button",
142
+ {
143
+ type: "button",
144
+ className: l(
145
+ "inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border px-3 text-xs font-semibold text-foreground transition-colors duration-150 hover:border-foreground/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
146
+ e
147
+ ),
148
+ ...n
149
+ }
150
+ );
151
+ }
152
+ export {
153
+ b as AssistantMessage,
154
+ A as ControlButton,
155
+ M as DemoFooter,
156
+ j as DemoWindow,
157
+ S as EmptyState,
158
+ D as FinishedStep,
159
+ T as StepProgress,
160
+ N as ThinkingRow,
161
+ h as UserMessage
162
+ };
163
+ //# sourceMappingURL=parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.js","sources":["../../../../src/components/AgentDemo/parts.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes, ReactNode, Ref } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Send } from \"../../icons\";\nimport type { AgentScriptStep } from \"./types\";\nimport { ToolCard } from \"./ToolCard\";\n\nexport function DemoWindow({\n title,\n subtitle,\n logo,\n logoSrc,\n logoAlt,\n logoClassName,\n footer,\n logLabel,\n logRef,\n height = \"70dvh\",\n children,\n}: {\n title?: ReactNode;\n subtitle?: ReactNode;\n logo?: ReactNode;\n logoSrc?: string;\n logoAlt?: string;\n logoClassName?: string;\n footer?: ReactNode;\n logLabel: string;\n logRef?: Ref<HTMLDivElement>;\n height?: string;\n children: ReactNode;\n}) {\n const logoNode =\n logo ??\n (logoSrc ? (\n <img\n src={logoSrc}\n alt={logoAlt ?? (typeof title === \"string\" ? title : \"Logo\")}\n className={cn(\"h-8 w-8 rounded-lg object-cover\", logoClassName)}\n />\n ) : undefined);\n return (\n <div\n style={{ height }}\n className=\"flex flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-overlay\"\n >\n <div className=\"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3 sm:px-5\">\n <div className=\"flex gap-1.5\" aria-hidden>\n <span className=\"h-2.5 w-2.5 rounded-full bg-foreground/15\" />\n <span className=\"h-2.5 w-2.5 rounded-full bg-foreground/15\" />\n <span className=\"h-2.5 w-2.5 rounded-full bg-foreground/15\" />\n </div>\n {logoNode ? <span className=\"flex shrink-0 items-center\">{logoNode}</span> : null}\n {title ?? subtitle ? (\n <div className=\"min-w-0\">\n {title ? (\n <p className=\"truncate text-sm font-semibold tracking-tight\">{title}</p>\n ) : null}\n {subtitle ? (\n <p className=\"truncate text-xs text-muted-foreground\">{subtitle}</p>\n ) : null}\n </div>\n ) : null}\n </div>\n\n <div\n role=\"log\"\n ref={logRef}\n aria-live=\"polite\"\n aria-label={logLabel}\n className=\"min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5\"\n >\n <div className=\"flex flex-col gap-4\">{children}</div>\n </div>\n\n {footer}\n </div>\n );\n}\n\nexport function DemoFooter({\n controls,\n progress,\n composing,\n}: {\n controls?: ReactNode;\n progress?: ReactNode;\n composing?: string;\n}) {\n const hasMeta = controls ?? progress;\n return (\n <div className=\"shrink-0 border-t border-border px-4 py-3 sm:px-5\">\n {hasMeta ? (\n <div className=\"mb-3 flex items-center gap-2\">\n {controls}\n {progress}\n </div>\n ) : null}\n <div\n aria-hidden\n className=\"flex cursor-not-allowed items-center gap-2 rounded-xl border border-border bg-surface-strong/40 px-3.5 py-2.5 text-sm text-muted-foreground select-none\"\n >\n {composing !== undefined ? (\n <span className=\"flex-1 truncate text-foreground\">\n {composing}\n <span className=\"ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-foreground\" />\n </span>\n ) : (\n <span className=\"flex-1 truncate\">Ask anything…</span>\n )}\n <Send\n className={cn(\"h-4 w-4 shrink-0\", composing ? \"text-foreground\" : undefined)}\n />\n </div>\n </div>\n );\n}\n\nexport function UserMessage({ text, partial = false }: { text: string; partial?: boolean }) {\n return (\n <div className=\"flex justify-end\">\n <p className=\"max-w-[85%] rounded-2xl rounded-br-md bg-primary px-3.5 py-2.5 text-sm leading-6 text-on-primary\">\n {text}\n {partial ? (\n <span className=\"ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-on-primary\" />\n ) : null}\n </p>\n </div>\n );\n}\n\nexport function AssistantMessage({ text, partial = false }: { text: string; partial?: boolean }) {\n return (\n <div className=\"flex justify-start\">\n <p className=\"max-w-[90%] rounded-2xl rounded-bl-md bg-primary-soft px-3.5 py-2.5 text-sm leading-6 text-foreground\">\n {text}\n {partial ? (\n <span className=\"ml-0.5 inline-block h-4 w-[2px] translate-y-[3px] animate-pulse bg-foreground\" />\n ) : null}\n </p>\n </div>\n );\n}\n\nexport function ThinkingRow({ label, active = true }: { label: string; active?: boolean }) {\n const dots = [\"[animation-delay:-0.3s]\", \"[animation-delay:-0.15s]\", \"\"];\n return (\n <div className=\"flex items-center gap-2 text-[13px] text-muted-foreground\">\n <span className=\"flex gap-1\" aria-hidden>\n {dots.map((delay, i) => (\n <span\n key={i}\n className={cn(\n \"h-1.5 w-1.5 rounded-full bg-current\",\n active && \"animate-bounce\",\n active && delay,\n )}\n />\n ))}\n </span>\n <span className={active ? \"animate-pulse\" : undefined}>{label}</span>\n </div>\n );\n}\n\nexport function EmptyState() {\n return (\n <p className=\"py-10 text-center text-sm text-muted-foreground\">\n This demo has no steps yet.\n </p>\n );\n}\n\nexport function StepProgress({ current, total, done }: { current: number; total: number; done: boolean }) {\n return (\n <span className=\"text-xs tabular-nums text-muted-foreground\">\n {done ? \"Demo complete\" : `Step ${Math.min(current, total)} of ${total}`}\n </span>\n );\n}\n\n/** Render one script step in its finished state (used by the transcript and completed player steps). */\nexport function FinishedStep({ step }: { step: AgentScriptStep }) {\n if (step.type === \"user\") return <UserMessage text={step.text} />;\n if (step.type === \"assistant\") return <AssistantMessage text={step.text} />;\n if (step.type === \"thinking\") return <ThinkingRow label={step.label ?? \"Thinking…\"} active={false} />;\n return (\n <ToolCard\n name={step.name}\n args={step.args}\n result={step.result}\n status={step.status === \"error\" ? \"error\" : \"success\"}\n />\n );\n}\n\nexport function ControlButton({\n className,\n ...props\n}: ButtonHTMLAttributes<HTMLButtonElement>) {\n return (\n <button\n type=\"button\"\n className={cn(\n \"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border px-3 text-xs font-semibold text-foreground transition-colors duration-150 hover:border-foreground/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n className,\n )}\n {...props}\n />\n );\n}\n"],"names":["DemoWindow","title","subtitle","logo","logoSrc","logoAlt","logoClassName","footer","logLabel","logRef","height","children","logoNode","jsx","cn","jsxs","DemoFooter","controls","progress","composing","Send","UserMessage","text","partial","AssistantMessage","ThinkingRow","label","active","delay","i","EmptyState","StepProgress","current","total","done","FinishedStep","step","ToolCard","ControlButton","className","props"],"mappings":";;;;AAMO,SAASA,EAAW;AAAA,EACzB,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,UAAAC;AACF,GAYG;AACD,QAAMC,IACJT,MACCC,IACC,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKT;AAAA,MACL,KAAKC,MAAY,OAAOJ,KAAU,WAAWA,IAAQ;AAAA,MACrD,WAAWa,EAAG,mCAAmCR,CAAa;AAAA,IAAA;AAAA,EAAA,IAE9D;AACN,SACE,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,QAAAL,EAAA;AAAA,MACT,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,gBAAAK,EAAC,OAAA,EAAI,WAAU,6EACb,UAAA;AAAA,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,gBAAe,eAAW,IACvC,UAAA;AAAA,YAAA,gBAAAF,EAAC,QAAA,EAAK,WAAU,4CAAA,CAA4C;AAAA,YAC5D,gBAAAA,EAAC,QAAA,EAAK,WAAU,4CAAA,CAA4C;AAAA,YAC5D,gBAAAA,EAAC,QAAA,EAAK,WAAU,4CAAA,CAA4C;AAAA,UAAA,GAC9D;AAAA,UACCD,IAAW,gBAAAC,EAAC,QAAA,EAAK,WAAU,8BAA8B,aAAS,IAAU;AAAA,UAC5EZ,KAASC,IACR,gBAAAa,EAAC,OAAA,EAAI,WAAU,WAC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