@amodalai/react 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,72 +1,72 @@
1
1
  import { jsx as e, jsxs as n, Fragment as ne } from "react/jsx-runtime";
2
- import { useState as w, useCallback as b, Component as re, useRef as A, useEffect as M } from "react";
3
- import { m as ie, u as le, b as de, a as oe } from "./theme-VAUsolBG.js";
4
- import { d as tt, c as st } from "./theme-VAUsolBG.js";
5
- import { W as at, a as nt, d as rt, g as it, l as lt } from "./event-bus-h26clqbZ.js";
2
+ import { useState as w, useCallback as b, Component as re, useRef as B, useEffect as M } from "react";
3
+ import { m as ie, u as le, b as oe, a as de } from "./theme-VAUsolBG.js";
4
+ import { d as ct, c as st } from "./theme-VAUsolBG.js";
5
+ import { W as nt, a as rt, d as it, g as lt, l as ot } from "./event-bus-h26clqbZ.js";
6
6
  /**
7
7
  * @license
8
8
  * Copyright 2025 Amodal Labs, Inc.
9
9
  * SPDX-License-Identifier: MIT
10
10
  */
11
- function O(s) {
12
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
11
+ function R(c) {
12
+ return c.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
13
13
  }
14
- function D(s) {
15
- let c = O(s);
16
- return c = c.replace(/`([^`]+)`/g, '<code class="pcw-md-code">$1</code>'), c = c.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), c = c.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), c = c.replace(/__(.+?)__/g, "<strong>$1</strong>"), c = c.replace(/\*(.+?)\*/g, "<em>$1</em>"), c = c.replace(new RegExp("(?<!\\w)_(.+?)_(?!\\w)", "g"), "<em>$1</em>"), c = c.replace(
14
+ function O(c) {
15
+ let s = R(c);
16
+ return s = s.replace(/`([^`]+)`/g, '<code class="pcw-md-code">$1</code>'), s = s.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), s = s.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), s = s.replace(/__(.+?)__/g, "<strong>$1</strong>"), s = s.replace(/\*(.+?)\*/g, "<em>$1</em>"), s = s.replace(new RegExp("(?<!\\w)_(.+?)_(?!\\w)", "g"), "<em>$1</em>"), s = s.replace(
17
17
  /\[([^\]]+)\]\(([^)]+)\)/g,
18
18
  '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
19
- ), c;
19
+ ), s;
20
20
  }
21
- function pe(s) {
22
- const c = s.split(`
21
+ function pe(c) {
22
+ const s = c.split(`
23
23
  `), t = [];
24
- let a = !1, i = [], l = !1;
25
- for (let d = 0; d < c.length; d++) {
26
- const r = c[d];
27
- if (r.startsWith("```")) {
28
- a ? (t.push(`<pre class="pcw-md-codeblock"><code>${O(i.join(`
29
- `))}</code></pre>`), i = [], a = !1) : (l && (t.push("</ul>"), l = !1), a = !0);
24
+ let a = !1, r = [], l = !1;
25
+ for (let d = 0; d < s.length; d++) {
26
+ const i = s[d];
27
+ if (i.startsWith("```")) {
28
+ a ? (t.push(`<pre class="pcw-md-codeblock"><code>${R(r.join(`
29
+ `))}</code></pre>`), r = [], a = !1) : (l && (t.push("</ul>"), l = !1), a = !0);
30
30
  continue;
31
31
  }
32
32
  if (a) {
33
- i.push(r);
33
+ r.push(i);
34
34
  continue;
35
35
  }
36
- if (r.trim() === "") {
36
+ if (i.trim() === "") {
37
37
  l && (t.push("</ul>"), l = !1);
38
38
  continue;
39
39
  }
40
- const p = /^(#{1,4})\s+(.+)$/.exec(r);
40
+ const p = /^(#{1,4}) (\S.*)$/.exec(i);
41
41
  if (p) {
42
42
  l && (t.push("</ul>"), l = !1);
43
- const u = p[1].length;
44
- t.push(`<h${String(u)} class="pcw-md-h${String(u)}">${D(p[2])}</h${String(u)}>`);
43
+ const o = p[1].length;
44
+ t.push(`<h${String(o)} class="pcw-md-h${String(o)}">${O(p[2])}</h${String(o)}>`);
45
45
  continue;
46
46
  }
47
- const o = /^(\s*)[-*]\s+(.+)$/.exec(r) ?? /^(\s*)\d+\.\s+(.+)$/.exec(r);
48
- if (o) {
49
- l || (t.push('<ul class="pcw-md-list">'), l = !0), t.push(`<li>${D(o[2])}</li>`);
47
+ const u = /^(\s*)[-*] (\S.*)$/.exec(i) ?? /^(\s*)\d+\. (\S.*)$/.exec(i);
48
+ if (u) {
49
+ l || (t.push('<ul class="pcw-md-list">'), l = !0), t.push(`<li>${O(u[2])}</li>`);
50
50
  continue;
51
51
  }
52
- l && (t.push("</ul>"), l = !1), t.push(`<p>${D(r)}</p>`);
52
+ l && (t.push("</ul>"), l = !1), t.push(`<p>${O(i)}</p>`);
53
53
  }
54
- return a && t.push(`<pre class="pcw-md-codeblock"><code>${O(i.join(`
54
+ return a && t.push(`<pre class="pcw-md-codeblock"><code>${R(r.join(`
55
55
  `))}</code></pre>`), l && t.push("</ul>"), t.join(`
56
56
  `);
57
57
  }
58
- function x({ text: s, className: c }) {
59
- const t = pe(s);
58
+ function C({ text: c, className: s }) {
59
+ const t = pe(c);
60
60
  return /* @__PURE__ */ e(
61
61
  "div",
62
62
  {
63
- className: `pcw-formatted-text${c ? ` ${c}` : ""}`,
63
+ className: `pcw-formatted-text${s ? ` ${s}` : ""}`,
64
64
  dangerouslySetInnerHTML: { __html: t }
65
65
  }
66
66
  );
67
67
  }
68
- function he({ event: s }) {
69
- const [c, t] = w(!1), a = !!(s.result || s.error || s.toolArgs);
68
+ function he({ event: c }) {
69
+ const [s, t] = w(!1), a = !!(c.result || c.error || c.toolArgs);
70
70
  return /* @__PURE__ */ n("div", { className: "pcw-subagent-row", children: [
71
71
  /* @__PURE__ */ n(
72
72
  "button",
@@ -74,28 +74,28 @@ function he({ event: s }) {
74
74
  type: "button",
75
75
  className: `pcw-subagent-row__header${a ? "" : " pcw-subagent-row__header--static"}`,
76
76
  onClick: () => {
77
- a && t(!c);
77
+ a && t(!s);
78
78
  },
79
79
  children: [
80
- a && /* @__PURE__ */ e("span", { className: "pcw-subagent-row__chevron", children: c ? "▼" : "▶" }),
81
- /* @__PURE__ */ e("span", { className: `pcw-subagent-row__icon${s.error ? " pcw-subagent-row__icon--error" : ""}`, children: s.error ? "✗" : "✓" }),
82
- /* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: s.toolName ?? "unknown" })
80
+ a && /* @__PURE__ */ e("span", { className: "pcw-subagent-row__chevron", children: s ? "▼" : "▶" }),
81
+ /* @__PURE__ */ e("span", { className: `pcw-subagent-row__icon${c.error ? " pcw-subagent-row__icon--error" : ""}`, children: c.error ? "✗" : "✓" }),
82
+ /* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: c.toolName ?? "unknown" })
83
83
  ]
84
84
  }
85
85
  ),
86
- c && /* @__PURE__ */ n("div", { className: "pcw-subagent-row__detail", children: [
87
- s.error && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__error", children: s.error }),
88
- s.result && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__result", children: s.result }),
89
- s.toolArgs && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__args", children: JSON.stringify(s.toolArgs, null, 2) })
86
+ s && /* @__PURE__ */ n("div", { className: "pcw-subagent-row__detail", children: [
87
+ c.error && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__error", children: c.error }),
88
+ c.result && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__result", children: c.result }),
89
+ c.toolArgs && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__args", children: JSON.stringify(c.toolArgs, null, 2) })
90
90
  ] })
91
91
  ] });
92
92
  }
93
- function ue({ params: s }) {
94
- const c = s.subagent, t = s.task, a = s.instruction, i = s.kb_tags, l = s.tools;
93
+ function ue({ params: c }) {
94
+ const s = c.subagent, t = c.task, a = c.instruction, r = c.kb_tags, l = c.tools;
95
95
  return /* @__PURE__ */ n("div", { className: "pcw-dispatch-args", children: [
96
- c && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
96
+ s && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
97
97
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "agent" }),
98
- /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__value--mono", children: c })
98
+ /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__value--mono", children: s })
99
99
  ] }),
100
100
  t && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
101
101
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "task" }),
@@ -105,9 +105,9 @@ function ue({ params: s }) {
105
105
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "instruction" }),
106
106
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value", children: a })
107
107
  ] }),
108
- i && i.length > 0 && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
108
+ r && r.length > 0 && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
109
109
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "kb" }),
110
- /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__tags", children: i.map((d) => /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__tag", children: d }, d)) })
110
+ /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__tags", children: r.map((d) => /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__tag", children: d }, d)) })
111
111
  ] }),
112
112
  l && l.length > 0 && /* @__PURE__ */ n("div", { className: "pcw-dispatch-args__row", children: [
113
113
  /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "tools" }),
@@ -115,44 +115,44 @@ function ue({ params: s }) {
115
115
  ] })
116
116
  ] });
117
117
  }
118
- function me(s) {
119
- if (!s || s.length === 0) return [];
120
- const c = [];
118
+ function me(c) {
119
+ if (!c || c.length === 0) return [];
120
+ const s = [];
121
121
  let t = "";
122
- for (const a of s)
123
- a.eventType === "thought" && a.text ? t += a.text : (a.eventType === "tool_call_start" || a.eventType === "tool_call_end") && (t && (c.push({ kind: "text", text: t }), t = ""), c.push({ kind: "tool", event: a }));
124
- return t && c.push({ kind: "text", text: t }), c;
122
+ for (const a of c)
123
+ a.eventType === "thought" && a.text ? t += a.text : (a.eventType === "tool_call_start" || a.eventType === "tool_call_end") && (t && (s.push({ kind: "text", text: t }), t = ""), s.push({ kind: "tool", event: a }));
124
+ return t && s.push({ kind: "text", text: t }), s;
125
125
  }
126
- function _e({ event: s }) {
127
- const c = s.eventType === "tool_call_end", t = s.error ? "✗" : c ? "✓" : "⦿", a = s.error ? "pcw-subagent-row__icon--error" : c ? "" : "pcw-subagent-row__icon--running";
126
+ function _e({ event: c }) {
127
+ const s = c.eventType === "tool_call_end", t = c.error ? "✗" : s ? "✓" : "⦿", a = c.error ? "pcw-subagent-row__icon--error" : s ? "" : "pcw-subagent-row__icon--running";
128
128
  return /* @__PURE__ */ n("div", { className: "pcw-subagent-inline-tool", children: [
129
129
  /* @__PURE__ */ e("span", { className: `pcw-subagent-row__icon ${a}`, children: t }),
130
- /* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: s.toolName ?? "unknown" })
130
+ /* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: c.toolName ?? "unknown" })
131
131
  ] });
132
132
  }
133
- function we({ toolCall: s }) {
134
- var u;
135
- const [c, t] = w(!1), a = `pcw-tool-call__status pcw-tool-call__status--${s.status}`, i = s.duration_ms ? `dispatch (${String(s.duration_ms)}ms)` : "dispatch", l = (u = s.subagentEvents) == null ? void 0 : u.find(
133
+ function we({ toolCall: c }) {
134
+ var o;
135
+ const [s, t] = w(!1), a = `pcw-tool-call__status pcw-tool-call__status--${c.status}`, r = c.duration_ms ? `dispatch (${String(c.duration_ms)}ms)` : "dispatch", l = (o = c.subagentEvents) == null ? void 0 : o.find(
136
136
  (h) => h.eventType === "complete"
137
- ), d = me(s.subagentEvents), r = d.length > 0, p = d.filter((h) => h.kind === "tool" && h.event.eventType === "tool_call_end").length, o = r || !!(l != null && l.text);
137
+ ), d = me(c.subagentEvents), i = d.length > 0, p = d.filter((h) => h.kind === "tool" && h.event.eventType === "tool_call_end").length, u = i || !!(l != null && l.text);
138
138
  return /* @__PURE__ */ n("div", { className: "pcw-tool-call", children: [
139
139
  /* @__PURE__ */ n("div", { className: "pcw-tool-call__header pcw-tool-call__header--static", children: [
140
- /* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: i }),
141
- /* @__PURE__ */ e("span", { className: a, children: s.status })
140
+ /* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: r }),
141
+ /* @__PURE__ */ e("span", { className: a, children: c.status })
142
142
  ] }),
143
- s.parameters && /* @__PURE__ */ e(ue, { params: s.parameters }),
144
- s.status === "running" && r && /* @__PURE__ */ e("div", { className: "pcw-dispatch-streaming", children: d.map(
145
- (h, _) => h.kind === "text" ? /* @__PURE__ */ e(x, { text: h.text }, _) : /* @__PURE__ */ e(_e, { event: h.event }, _)
143
+ c.parameters && /* @__PURE__ */ e(ue, { params: c.parameters }),
144
+ c.status === "running" && i && /* @__PURE__ */ e("div", { className: "pcw-dispatch-streaming", children: d.map(
145
+ (h, m) => h.kind === "text" ? /* @__PURE__ */ e(C, { text: h.text }, m) : /* @__PURE__ */ e(_e, { event: h.event }, m)
146
146
  ) }),
147
- s.status !== "running" && o && /* @__PURE__ */ n("div", { className: "pcw-dispatch-details", children: [
147
+ c.status !== "running" && u && /* @__PURE__ */ n("div", { className: "pcw-dispatch-details", children: [
148
148
  /* @__PURE__ */ n(
149
149
  "button",
150
150
  {
151
151
  type: "button",
152
152
  className: "pcw-dispatch-details__toggle",
153
- onClick: () => t(!c),
153
+ onClick: () => t(!s),
154
154
  children: [
155
- /* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: c ? "▼" : "▶" }),
155
+ /* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: s ? "▼" : "▶" }),
156
156
  /* @__PURE__ */ e("span", { children: "details" }),
157
157
  p > 0 && /* @__PURE__ */ n("span", { className: "pcw-dispatch-details__count", children: [
158
158
  String(p),
@@ -161,37 +161,37 @@ function we({ toolCall: s }) {
161
161
  ]
162
162
  }
163
163
  ),
164
- c && /* @__PURE__ */ n("div", { className: "pcw-dispatch-details__body", children: [
165
- (l == null ? void 0 : l.text) && /* @__PURE__ */ e(x, { text: l.text, className: "pcw-tool-call__subagent-summary" }),
164
+ s && /* @__PURE__ */ n("div", { className: "pcw-dispatch-details__body", children: [
165
+ (l == null ? void 0 : l.text) && /* @__PURE__ */ e(C, { text: l.text, className: "pcw-tool-call__subagent-summary" }),
166
166
  d.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-tool-call__subagent", children: d.map(
167
- (h, _) => h.kind === "text" ? /* @__PURE__ */ e(x, { text: h.text, className: "pcw-dispatch-inline-text" }, _) : /* @__PURE__ */ e(he, { event: h.event }, _)
167
+ (h, m) => h.kind === "text" ? /* @__PURE__ */ e(C, { text: h.text, className: "pcw-dispatch-inline-text" }, m) : /* @__PURE__ */ e(he, { event: h.event }, m)
168
168
  ) })
169
169
  ] })
170
170
  ] }),
171
- s.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: s.error })
171
+ c.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: c.error })
172
172
  ] });
173
173
  }
174
- function K({ toolCall: s }) {
175
- const [c, t] = w(!1);
176
- if (s.toolName === "dispatch")
177
- return /* @__PURE__ */ e(we, { toolCall: s });
178
- const a = `pcw-tool-call__status pcw-tool-call__status--${s.status}`, i = s.duration_ms ? `${s.toolName} (${String(s.duration_ms)}ms)` : s.toolName;
174
+ function Z({ toolCall: c }) {
175
+ const [s, t] = w(!1);
176
+ if (c.toolName === "dispatch")
177
+ return /* @__PURE__ */ e(we, { toolCall: c });
178
+ const a = `pcw-tool-call__status pcw-tool-call__status--${c.status}`, r = c.duration_ms ? `${c.toolName} (${String(c.duration_ms)}ms)` : c.toolName;
179
179
  return /* @__PURE__ */ n("div", { className: "pcw-tool-call", children: [
180
180
  /* @__PURE__ */ n(
181
181
  "button",
182
182
  {
183
183
  type: "button",
184
184
  className: "pcw-tool-call__header",
185
- onClick: () => t(!c),
185
+ onClick: () => t(!s),
186
186
  children: [
187
- /* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: c ? "▼" : "▶" }),
188
- /* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: i }),
189
- /* @__PURE__ */ e("span", { className: a, children: s.status })
187
+ /* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: s ? "▼" : "▶" }),
188
+ /* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: r }),
189
+ /* @__PURE__ */ e("span", { className: a, children: c.status })
190
190
  ]
191
191
  }
192
192
  ),
193
- c && s.parameters && /* @__PURE__ */ e("pre", { className: "pcw-tool-call__details", children: JSON.stringify(s.parameters, null, 2) }),
194
- s.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: s.error })
193
+ s && c.parameters && /* @__PURE__ */ e("pre", { className: "pcw-tool-call__details", children: JSON.stringify(c.parameters, null, 2) }),
194
+ c.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: c.error })
195
195
  ] });
196
196
  }
197
197
  /**
@@ -199,14 +199,14 @@ function K({ toolCall: s }) {
199
199
  * Copyright 2025 Amodal Labs, Inc.
200
200
  * SPDX-License-Identifier: MIT
201
201
  */
202
- function Z({ proposal: s }) {
202
+ function J({ proposal: c }) {
203
203
  return /* @__PURE__ */ n("div", { className: "pcw-kb-proposal", children: [
204
204
  /* @__PURE__ */ n("div", { className: "pcw-kb-proposal__header", children: [
205
205
  /* @__PURE__ */ e("span", { className: "pcw-kb-proposal__icon", children: "💡" }),
206
- /* @__PURE__ */ e("span", { className: "pcw-kb-proposal__title", children: s.title }),
207
- /* @__PURE__ */ e("span", { className: "pcw-kb-proposal__scope", children: s.scope })
206
+ /* @__PURE__ */ e("span", { className: "pcw-kb-proposal__title", children: c.title }),
207
+ /* @__PURE__ */ e("span", { className: "pcw-kb-proposal__scope", children: c.scope })
208
208
  ] }),
209
- /* @__PURE__ */ e("p", { className: "pcw-kb-proposal__reasoning", children: s.reasoning })
209
+ /* @__PURE__ */ e("p", { className: "pcw-kb-proposal__reasoning", children: c.reasoning })
210
210
  ] });
211
211
  }
212
212
  /**
@@ -214,10 +214,10 @@ function Z({ proposal: s }) {
214
214
  * Copyright 2025 Amodal Labs, Inc.
215
215
  * SPDX-License-Identifier: MIT
216
216
  */
217
- function J({ skill: s }) {
217
+ function Y({ skill: c }) {
218
218
  return /* @__PURE__ */ n("span", { className: "pcw-skill-pill", children: [
219
219
  "Using: ",
220
- s
220
+ c
221
221
  ] });
222
222
  }
223
223
  /**
@@ -233,19 +233,19 @@ function ge() {
233
233
  ] });
234
234
  }
235
235
  function be({
236
- question: s,
237
- index: c,
236
+ question: c,
237
+ index: s,
238
238
  value: t,
239
239
  onChange: a,
240
- disabled: i
240
+ disabled: r
241
241
  }) {
242
- const l = `ask-user-q-${String(c)}`;
243
- switch (s.type) {
242
+ const l = `ask-user-q-${String(s)}`;
243
+ switch (c.type) {
244
244
  case "text":
245
245
  return /* @__PURE__ */ n("div", { className: "pcw-ask-user__field", children: [
246
246
  /* @__PURE__ */ n("label", { htmlFor: l, className: "pcw-ask-user__label", children: [
247
- s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
248
- s.question
247
+ c.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: c.header }),
248
+ c.question
249
249
  ] }),
250
250
  /* @__PURE__ */ e(
251
251
  "textarea",
@@ -254,8 +254,8 @@ function be({
254
254
  className: "pcw-ask-user__textarea",
255
255
  value: t,
256
256
  onChange: (d) => a(d.target.value),
257
- placeholder: s.placeholder ?? "",
258
- disabled: i,
257
+ placeholder: c.placeholder ?? "",
258
+ disabled: r,
259
259
  rows: 3
260
260
  }
261
261
  )
@@ -263,8 +263,8 @@ function be({
263
263
  case "yesno":
264
264
  return /* @__PURE__ */ n("div", { className: "pcw-ask-user__field", children: [
265
265
  /* @__PURE__ */ n("span", { className: "pcw-ask-user__label", children: [
266
- s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
267
- s.question
266
+ c.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: c.header }),
267
+ c.question
268
268
  ] }),
269
269
  /* @__PURE__ */ n("div", { className: "pcw-ask-user__yesno", children: [
270
270
  /* @__PURE__ */ e(
@@ -273,7 +273,7 @@ function be({
273
273
  type: "button",
274
274
  className: `pcw-ask-user__yesno-btn ${t === "yes" ? "pcw-ask-user__yesno-btn--active" : ""}`,
275
275
  onClick: () => a("yes"),
276
- disabled: i,
276
+ disabled: r,
277
277
  children: "Yes"
278
278
  }
279
279
  ),
@@ -283,85 +283,85 @@ function be({
283
283
  type: "button",
284
284
  className: `pcw-ask-user__yesno-btn ${t === "no" ? "pcw-ask-user__yesno-btn--active" : ""}`,
285
285
  onClick: () => a("no"),
286
- disabled: i,
286
+ disabled: r,
287
287
  children: "No"
288
288
  }
289
289
  )
290
290
  ] })
291
291
  ] });
292
292
  case "choice": {
293
- const d = s.options ?? [];
294
- if (s.multiSelect) {
295
- const r = t ? t.split(",").filter(Boolean) : [], p = (o) => {
296
- const u = r.includes(o) ? r.filter((h) => h !== o) : [...r, o];
297
- a(u.join(","));
293
+ const d = c.options ?? [];
294
+ if (c.multiSelect) {
295
+ const i = t ? t.split(",").filter(Boolean) : [], p = (u) => {
296
+ const o = i.includes(u) ? i.filter((h) => h !== u) : [...i, u];
297
+ a(o.join(","));
298
298
  };
299
299
  return /* @__PURE__ */ n("div", { className: "pcw-ask-user__field", children: [
300
300
  /* @__PURE__ */ n("span", { className: "pcw-ask-user__label", children: [
301
- s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
302
- s.question
301
+ c.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: c.header }),
302
+ c.question
303
303
  ] }),
304
- /* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: d.map((o) => /* @__PURE__ */ n("label", { className: "pcw-ask-user__choice", children: [
304
+ /* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: d.map((u) => /* @__PURE__ */ n("label", { className: "pcw-ask-user__choice", children: [
305
305
  /* @__PURE__ */ e(
306
306
  "input",
307
307
  {
308
308
  type: "checkbox",
309
- checked: r.includes(o.label),
310
- onChange: () => p(o.label),
311
- disabled: i
309
+ checked: i.includes(u.label),
310
+ onChange: () => p(u.label),
311
+ disabled: r
312
312
  }
313
313
  ),
314
- /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: o.label }),
315
- o.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: o.description })
316
- ] }, o.label)) })
314
+ /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: u.label }),
315
+ u.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: u.description })
316
+ ] }, u.label)) })
317
317
  ] });
318
318
  }
319
319
  return /* @__PURE__ */ n("div", { className: "pcw-ask-user__field", children: [
320
320
  /* @__PURE__ */ n("span", { className: "pcw-ask-user__label", children: [
321
- s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
322
- s.question
321
+ c.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: c.header }),
322
+ c.question
323
323
  ] }),
324
- /* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: d.map((r) => /* @__PURE__ */ n("label", { className: "pcw-ask-user__choice", children: [
324
+ /* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: d.map((i) => /* @__PURE__ */ n("label", { className: "pcw-ask-user__choice", children: [
325
325
  /* @__PURE__ */ e(
326
326
  "input",
327
327
  {
328
328
  type: "radio",
329
329
  name: l,
330
- checked: t === r.label,
331
- onChange: () => a(r.label),
332
- disabled: i
330
+ checked: t === i.label,
331
+ onChange: () => a(i.label),
332
+ disabled: r
333
333
  }
334
334
  ),
335
- /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: r.label }),
336
- r.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: r.description })
337
- ] }, r.label)) })
335
+ /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: i.label }),
336
+ i.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: i.description })
337
+ ] }, i.label)) })
338
338
  ] });
339
339
  }
340
340
  default:
341
341
  return null;
342
342
  }
343
343
  }
344
- function ve({ block: s, onSubmit: c }) {
345
- const [t, a] = w({}), [i, l] = w(!1), d = s.status === "submitted", r = d || i, p = () => {
346
- l(!0), c(s.askId, t);
344
+ function ve({ block: c, onSubmit: s }) {
345
+ const [t, a] = w({}), [r, l] = w(!1), d = c.status === "submitted", i = d || r, p = () => {
346
+ l(!0), s(c.askId, t);
347
347
  };
348
- return d && s.answers ? /* @__PURE__ */ e("div", { className: "pcw-ask-user pcw-ask-user--submitted", children: s.questions.map((o, u) => {
348
+ return d && c.answers ? /* @__PURE__ */ e("div", { className: "pcw-ask-user pcw-ask-user--submitted", children: c.questions.map((u, o) => {
349
349
  var h;
350
350
  return /* @__PURE__ */ n("div", { className: "pcw-ask-user__summary", children: [
351
- /* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-q", children: o.question }),
352
- /* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-a", children: ((h = s.answers) == null ? void 0 : h[String(u)]) ?? "" })
353
- ] }, `${o.header}-${String(u)}`);
351
+ /* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-q", children: u.question }),
352
+ /* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-a", children: ((h = c.answers) == null ? void 0 : h[String(o)]) ?? "" })
353
+ ] }, `${u.header}-${String(o)}`);
354
354
  }) }) : /* @__PURE__ */ n("div", { className: "pcw-ask-user", children: [
355
- s.questions.map((o, u) => /* @__PURE__ */ e(
355
+ c.questions.map((u, o) => /* @__PURE__ */ e(
356
356
  be,
357
357
  {
358
- question: o,
359
- index: u,
360
- value: t[String(u)] ?? "",
361
- onChange: (h) => a((_) => ({ ..._, [String(u)]: h })),
362
- disabled: r
358
+ question: u,
359
+ index: o,
360
+ value: t[String(o)] ?? "",
361
+ onChange: (h) => a((m) => ({ ...m, [String(o)]: h })),
362
+ disabled: i
363
363
  },
364
- `${o.header}-${String(u)}`
364
+ `${u.header}-${String(o)}`
365
365
  )),
366
366
  /* @__PURE__ */ e(
367
367
  "button",
@@ -369,14 +369,14 @@ function ve({ block: s, onSubmit: c }) {
369
369
  type: "button",
370
370
  className: "pcw-ask-user__submit",
371
371
  onClick: p,
372
- disabled: r,
373
- children: i ? "Submitting..." : "Submit"
372
+ disabled: i,
373
+ children: r ? "Submitting..." : "Submit"
374
374
  }
375
375
  )
376
376
  ] });
377
377
  }
378
- function Ne({ data: s, sendMessage: c, onInteraction: t }) {
379
- const a = s, i = Math.min(100, Math.max(0, a.suspicion_score)), l = b(() => {
378
+ function Ne({ data: c, sendMessage: s, onInteraction: t }) {
379
+ const a = c, r = Math.min(100, Math.max(0, a.suspicion_score)), l = b(() => {
380
380
  const p = {
381
381
  type: "entity_hovered",
382
382
  entity: { entityType: "device", entityId: a.mac, source: "widget:entity-card" },
@@ -390,7 +390,7 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
390
390
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
391
391
  };
392
392
  t == null || t(p);
393
- }, [a.mac, t]), r = b(() => {
393
+ }, [a.mac, t]), i = b(() => {
394
394
  const p = {
395
395
  type: "entity_clicked",
396
396
  entity: { entityType: "device", entityId: a.mac, source: "widget:entity-card" },
@@ -404,7 +404,7 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
404
404
  className: "pcw-widget-card pcw-entity-card",
405
405
  onMouseEnter: l,
406
406
  onMouseLeave: d,
407
- onClick: r,
407
+ onClick: i,
408
408
  "data-testid": "entity-card",
409
409
  children: [
410
410
  /* @__PURE__ */ n("div", { className: "pcw-entity-card__header", children: [
@@ -426,15 +426,15 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
426
426
  "div",
427
427
  {
428
428
  className: "pcw-score-bar__fill",
429
- style: { width: `${String(i)}%` }
429
+ style: { width: `${String(r)}%` }
430
430
  }
431
431
  ) })
432
432
  ] }),
433
- a.score_factors && Object.keys(a.score_factors).length > 0 && /* @__PURE__ */ e("div", { className: "pcw-entity-card__factors", children: Object.entries(a.score_factors).map(([p, o]) => /* @__PURE__ */ n("div", { className: "pcw-entity-card__factor", children: [
433
+ a.score_factors && Object.keys(a.score_factors).length > 0 && /* @__PURE__ */ e("div", { className: "pcw-entity-card__factors", children: Object.entries(a.score_factors).map(([p, u]) => /* @__PURE__ */ n("div", { className: "pcw-entity-card__factor", children: [
434
434
  /* @__PURE__ */ e("span", { children: p.replace(/_/g, " ") }),
435
435
  /* @__PURE__ */ n("span", { children: [
436
436
  "+",
437
- o
437
+ u
438
438
  ] })
439
439
  ] }, p)) }),
440
440
  /* @__PURE__ */ n("div", { className: "pcw-entity-card__meta", children: [
@@ -454,7 +454,7 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
454
454
  {
455
455
  type: "button",
456
456
  className: "pcw-entity-card__btn",
457
- onClick: () => c(`Investigate device ${a.mac} in Zone ${a.zone}`),
457
+ onClick: () => s(`Investigate device ${a.mac} in Zone ${a.zone}`),
458
458
  children: "Investigate"
459
459
  }
460
460
  ),
@@ -463,7 +463,7 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
463
463
  {
464
464
  type: "button",
465
465
  className: "pcw-entity-card__btn pcw-entity-card__btn--secondary",
466
- onClick: () => c(`Tag device ${a.mac} as suspicious`),
466
+ onClick: () => s(`Tag device ${a.mac} as suspicious`),
467
467
  children: "Tag"
468
468
  }
469
469
  )
@@ -472,21 +472,21 @@ function Ne({ data: s, sendMessage: c, onInteraction: t }) {
472
472
  }
473
473
  );
474
474
  }
475
- function ye({ data: s, sendMessage: c }) {
476
- const t = s, [a, i] = w(null), [l, d] = w(t.sort ?? "suspicion_score"), r = [...t.devices].sort((u, h) => l === "suspicion_score" ? h.suspicion_score - u.suspicion_score : l === "mac" ? u.mac.localeCompare(h.mac) : l === "zone" ? u.zone.localeCompare(h.zone) : 0), p = t.max_display ?? r.length, o = r.slice(0, p);
475
+ function ye({ data: c, sendMessage: s }) {
476
+ const t = c, [a, r] = w(null), [l, d] = w(t.sort ?? "suspicion_score"), i = [...t.devices].sort((o, h) => l === "suspicion_score" ? h.suspicion_score - o.suspicion_score : l === "mac" ? o.mac.localeCompare(h.mac) : l === "zone" ? o.zone.localeCompare(h.zone) : 0), p = t.max_display ?? i.length, u = i.slice(0, p);
477
477
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-entity-list", children: [
478
478
  t.title && /* @__PURE__ */ e("div", { className: "pcw-entity-list__title", children: t.title }),
479
479
  /* @__PURE__ */ n("div", { className: "pcw-entity-list__sort", children: [
480
480
  "Sort:",
481
- ["suspicion_score", "mac", "zone"].map((u) => /* @__PURE__ */ e(
481
+ ["suspicion_score", "mac", "zone"].map((o) => /* @__PURE__ */ e(
482
482
  "button",
483
483
  {
484
484
  type: "button",
485
- className: `pcw-entity-list__sort-btn ${l === u ? "pcw-entity-list__sort-btn--active" : ""}`,
486
- onClick: () => d(u),
487
- children: u.replace(/_/g, " ")
485
+ className: `pcw-entity-list__sort-btn ${l === o ? "pcw-entity-list__sort-btn--active" : ""}`,
486
+ onClick: () => d(o),
487
+ children: o.replace(/_/g, " ")
488
488
  },
489
- u
489
+ o
490
490
  ))
491
491
  ] }),
492
492
  /* @__PURE__ */ n("table", { className: "pcw-data-table__table", children: [
@@ -497,20 +497,20 @@ function ye({ data: s, sendMessage: c }) {
497
497
  /* @__PURE__ */ e("th", { children: "Score" }),
498
498
  /* @__PURE__ */ e("th", { children: "Tag" })
499
499
  ] }) }),
500
- /* @__PURE__ */ e("tbody", { children: o.map((u) => /* @__PURE__ */ n(
500
+ /* @__PURE__ */ e("tbody", { children: u.map((o) => /* @__PURE__ */ n(
501
501
  "tr",
502
502
  {
503
- className: `pcw-entity-list__row ${a === u.mac ? "pcw-entity-list__row--expanded" : ""}`,
504
- onClick: () => i(a === u.mac ? null : u.mac),
503
+ className: `pcw-entity-list__row ${a === o.mac ? "pcw-entity-list__row--expanded" : ""}`,
504
+ onClick: () => r(a === o.mac ? null : o.mac),
505
505
  children: [
506
- /* @__PURE__ */ e("td", { className: "pcw-entity-list__mac", children: u.mac }),
507
- /* @__PURE__ */ e("td", { children: u.manufacturer }),
508
- /* @__PURE__ */ e("td", { children: u.zone }),
509
- /* @__PURE__ */ e("td", { children: u.suspicion_score }),
510
- /* @__PURE__ */ e("td", { children: u.tag_status })
506
+ /* @__PURE__ */ e("td", { className: "pcw-entity-list__mac", children: o.mac }),
507
+ /* @__PURE__ */ e("td", { children: o.manufacturer }),
508
+ /* @__PURE__ */ e("td", { children: o.zone }),
509
+ /* @__PURE__ */ e("td", { children: o.suspicion_score }),
510
+ /* @__PURE__ */ e("td", { children: o.tag_status })
511
511
  ]
512
512
  },
513
- u.mac
513
+ o.mac
514
514
  )) })
515
515
  ] }),
516
516
  a && /* @__PURE__ */ e("div", { className: "pcw-entity-list__detail", children: /* @__PURE__ */ n(
@@ -518,16 +518,16 @@ function ye({ data: s, sendMessage: c }) {
518
518
  {
519
519
  type: "button",
520
520
  className: "pcw-entity-card__btn",
521
- onClick: () => c(`Tell me more about device ${a}`),
521
+ onClick: () => s(`Tell me more about device ${a}`),
522
522
  children: [
523
523
  "Investigate ",
524
524
  a
525
525
  ]
526
526
  }
527
527
  ) }),
528
- r.length > p && /* @__PURE__ */ n("div", { className: "pcw-entity-list__more", children: [
528
+ i.length > p && /* @__PURE__ */ n("div", { className: "pcw-entity-list__more", children: [
529
529
  "+",
530
- r.length - p,
530
+ i.length - p,
531
531
  " more devices"
532
532
  ] })
533
533
  ] });
@@ -545,52 +545,52 @@ const fe = {
545
545
  D: "Warehouse",
546
546
  E: "Parking"
547
547
  };
548
- function Se({ data: s, onInteraction: c }) {
549
- const t = s, a = new Set(t.highlight_zones ?? []), i = b(
550
- (d, r) => {
548
+ function Se({ data: c, onInteraction: s }) {
549
+ const t = c, a = new Set(t.highlight_zones ?? []), r = b(
550
+ (d, i) => {
551
551
  const p = {
552
552
  type: d,
553
- entity: { entityType: "zone", entityId: r, source: "widget:scope-map" },
553
+ entity: { entityType: "zone", entityId: i, source: "widget:scope-map" },
554
554
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
555
555
  };
556
- c == null || c(p);
556
+ s == null || s(p);
557
557
  },
558
- [c]
558
+ [s]
559
559
  ), l = b(
560
- (d, r) => {
560
+ (d, i) => {
561
561
  const p = {
562
562
  type: d,
563
- entity: { entityType: "device", entityId: r, source: "widget:scope-map" },
563
+ entity: { entityType: "device", entityId: i, source: "widget:scope-map" },
564
564
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
565
565
  };
566
- c == null || c(p);
566
+ s == null || s(p);
567
567
  },
568
- [c]
568
+ [s]
569
569
  );
570
570
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-scope-map", children: [
571
571
  t.label && /* @__PURE__ */ e("div", { className: "pcw-scope-map__label", children: t.label }),
572
- /* @__PURE__ */ e("svg", { viewBox: "0 0 280 150", className: "pcw-scope-map__svg", children: Object.entries(fe).map(([d, r]) => /* @__PURE__ */ n("g", { children: [
572
+ /* @__PURE__ */ e("svg", { viewBox: "0 0 280 150", className: "pcw-scope-map__svg", children: Object.entries(fe).map(([d, i]) => /* @__PURE__ */ n("g", { children: [
573
573
  /* @__PURE__ */ e(
574
574
  "rect",
575
575
  {
576
- x: r.x,
577
- y: r.y,
578
- width: r.w,
579
- height: r.h,
576
+ x: i.x,
577
+ y: i.y,
578
+ width: i.w,
579
+ height: i.h,
580
580
  rx: 4,
581
581
  className: a.has(d) ? "pcw-scope-map__zone pcw-scope-map__zone--highlight" : "pcw-scope-map__zone",
582
582
  "data-testid": `zone-${d}`,
583
- onMouseEnter: () => i("entity_hovered", d),
584
- onMouseLeave: () => i("entity_unhovered", d),
585
- onClick: () => i("entity_clicked", d),
583
+ onMouseEnter: () => r("entity_hovered", d),
584
+ onMouseLeave: () => r("entity_unhovered", d),
585
+ onClick: () => r("entity_clicked", d),
586
586
  style: { cursor: "pointer" }
587
587
  }
588
588
  ),
589
589
  /* @__PURE__ */ n(
590
590
  "text",
591
591
  {
592
- x: r.x + r.w / 2,
593
- y: r.y + r.h / 2 - 6,
592
+ x: i.x + i.w / 2,
593
+ y: i.y + i.h / 2 - 6,
594
594
  textAnchor: "middle",
595
595
  className: "pcw-scope-map__zone-label",
596
596
  style: { pointerEvents: "none" },
@@ -603,8 +603,8 @@ function Se({ data: s, onInteraction: c }) {
603
603
  /* @__PURE__ */ e(
604
604
  "text",
605
605
  {
606
- x: r.x + r.w / 2,
607
- y: r.y + r.h / 2 + 8,
606
+ x: i.x + i.w / 2,
607
+ y: i.y + i.h / 2 + 8,
608
608
  textAnchor: "middle",
609
609
  className: "pcw-scope-map__zone-name",
610
610
  style: { pointerEvents: "none" },
@@ -638,8 +638,8 @@ const xe = {
638
638
  high: "pcw-alert-card__severity--high",
639
639
  critical: "pcw-alert-card__severity--critical"
640
640
  };
641
- function Ce({ data: s, sendMessage: c }) {
642
- const t = s;
641
+ function Ce({ data: c, sendMessage: s }) {
642
+ const t = c;
643
643
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-alert-card", children: [
644
644
  /* @__PURE__ */ n("div", { className: "pcw-alert-card__header", children: [
645
645
  /* @__PURE__ */ e("span", { className: `pcw-alert-card__severity ${xe[t.severity] ?? ""}`, children: t.severity.toUpperCase() }),
@@ -655,7 +655,7 @@ function Ce({ data: s, sendMessage: c }) {
655
655
  {
656
656
  type: "button",
657
657
  className: "pcw-alert-card__device-link",
658
- onClick: () => c(`Tell me about device ${a}`),
658
+ onClick: () => s(`Tell me about device ${a}`),
659
659
  children: a
660
660
  },
661
661
  a
@@ -669,19 +669,19 @@ function Ce({ data: s, sendMessage: c }) {
669
669
  * Copyright 2025 Amodal Labs, Inc.
670
670
  * SPDX-License-Identifier: MIT
671
671
  */
672
- const Y = {
672
+ const G = {
673
673
  device_seen: "#3b82f6",
674
674
  zone_change: "#8b5cf6",
675
675
  alert: "#ef4444",
676
676
  tag_change: "#10b981",
677
677
  custom: "#6b7280"
678
678
  };
679
- function $e({ data: s, sendMessage: c }) {
680
- const t = s;
679
+ function $e({ data: c, sendMessage: s }) {
680
+ const t = c;
681
681
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-timeline", children: [
682
682
  t.label && /* @__PURE__ */ e("div", { className: "pcw-timeline__label", children: t.label }),
683
- /* @__PURE__ */ e("div", { className: "pcw-timeline__events", children: t.events.map((a, i) => {
684
- const l = Y[a.type ?? "custom"] ?? Y.custom;
683
+ /* @__PURE__ */ e("div", { className: "pcw-timeline__events", children: t.events.map((a, r) => {
684
+ const l = G[a.type ?? "custom"] ?? G.custom;
685
685
  return /* @__PURE__ */ n("div", { className: "pcw-timeline__event", children: [
686
686
  /* @__PURE__ */ e("div", { className: "pcw-timeline__marker", style: { backgroundColor: l } }),
687
687
  /* @__PURE__ */ n("div", { className: "pcw-timeline__content", children: [
@@ -695,12 +695,12 @@ function $e({ data: s, sendMessage: c }) {
695
695
  {
696
696
  type: "button",
697
697
  className: "pcw-alert-card__device-link",
698
- onClick: () => c(`Tell me about device ${a.device}`),
698
+ onClick: () => s(`Tell me about device ${a.device}`),
699
699
  children: a.device
700
700
  }
701
701
  )
702
702
  ] })
703
- ] }, `${a.timestamp}-${String(i)}`);
703
+ ] }, `${a.timestamp}-${String(r)}`);
704
704
  }) })
705
705
  ] });
706
706
  }
@@ -709,8 +709,8 @@ function $e({ data: s, sendMessage: c }) {
709
709
  * Copyright 2025 Amodal Labs, Inc.
710
710
  * SPDX-License-Identifier: MIT
711
711
  */
712
- function Te({ data: s, sendMessage: c }) {
713
- const t = s;
712
+ function Te({ data: c, sendMessage: s }) {
713
+ const t = c;
714
714
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-comparison", children: [
715
715
  t.title && /* @__PURE__ */ e("div", { className: "pcw-comparison__title", children: t.title }),
716
716
  /* @__PURE__ */ e("div", { className: "pcw-comparison__grid", children: t.items.map((a) => /* @__PURE__ */ n("div", { className: "pcw-comparison__item", children: [
@@ -734,42 +734,42 @@ function Te({ data: s, sendMessage: c }) {
734
734
  {
735
735
  type: "button",
736
736
  className: "pcw-entity-card__btn",
737
- onClick: () => c(`Investigate device ${a.mac}`),
737
+ onClick: () => s(`Investigate device ${a.mac}`),
738
738
  children: "Investigate"
739
739
  }
740
740
  )
741
741
  ] }, a.mac)) })
742
742
  ] });
743
743
  }
744
- function Ee({ data: s }) {
745
- const c = s, t = c.columns ?? [], a = c.rows ?? [], [i, l] = w(null), [d, r] = w("asc"), p = b(
746
- (u) => {
747
- c.sortable && (i === u ? r((h) => h === "asc" ? "desc" : "asc") : (l(u), r("asc")));
744
+ function Ee({ data: c }) {
745
+ const s = c, t = s.columns ?? [], a = s.rows ?? [], [r, l] = w(null), [d, i] = w("asc"), p = b(
746
+ (o) => {
747
+ s.sortable && (r === o ? i((h) => h === "asc" ? "desc" : "asc") : (l(o), i("asc")));
748
748
  },
749
- [c.sortable, i]
750
- ), o = i ? [...a].sort((u, h) => {
751
- const _ = u[i], m = h[i];
752
- if (typeof _ == "number" && typeof m == "number")
753
- return d === "asc" ? _ - m : m - _;
754
- const g = String(_ ?? ""), v = String(m ?? "");
749
+ [s.sortable, r]
750
+ ), u = r ? [...a].sort((o, h) => {
751
+ const m = o[r], _ = h[r];
752
+ if (typeof m == "number" && typeof _ == "number")
753
+ return d === "asc" ? m - _ : _ - m;
754
+ const g = String(m ?? ""), v = String(_ ?? "");
755
755
  return d === "asc" ? g.localeCompare(v) : v.localeCompare(g);
756
756
  }) : a;
757
757
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-data-table", children: [
758
- c.title && /* @__PURE__ */ e("div", { className: "pcw-data-table__title", children: c.title }),
758
+ s.title && /* @__PURE__ */ e("div", { className: "pcw-data-table__title", children: s.title }),
759
759
  /* @__PURE__ */ e("div", { className: "pcw-data-table__scroll", children: /* @__PURE__ */ n("table", { className: "pcw-data-table__table", children: [
760
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: t.map((u) => /* @__PURE__ */ n(
760
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: t.map((o) => /* @__PURE__ */ n(
761
761
  "th",
762
762
  {
763
- onClick: () => p(u.key),
764
- className: c.sortable ? "pcw-data-table__sortable" : "",
763
+ onClick: () => p(o.key),
764
+ className: s.sortable ? "pcw-data-table__sortable" : "",
765
765
  children: [
766
- u.label,
767
- i === u.key && (d === "asc" ? " ▲" : " ▼")
766
+ o.label,
767
+ r === o.key && (d === "asc" ? " ▲" : " ▼")
768
768
  ]
769
769
  },
770
- u.key
770
+ o.key
771
771
  )) }) }),
772
- /* @__PURE__ */ e("tbody", { children: o.map((u, h) => /* @__PURE__ */ e("tr", { children: t.map((_) => /* @__PURE__ */ e("td", { children: String(u[_.key] ?? "") }, _.key)) }, String(h))) })
772
+ /* @__PURE__ */ e("tbody", { children: u.map((o, h) => /* @__PURE__ */ e("tr", { children: t.map((m) => /* @__PURE__ */ e("td", { children: String(o[m.key] ?? "") }, m.key)) }, String(h))) })
773
773
  ] }) })
774
774
  ] });
775
775
  }
@@ -778,14 +778,14 @@ function Ee({ data: s }) {
778
778
  * Copyright 2025 Amodal Labs, Inc.
779
779
  * SPDX-License-Identifier: MIT
780
780
  */
781
- function Ae({ data: s }) {
782
- const c = s, t = c.max_score ?? 100, a = Math.min(100, Math.max(0, c.total_score / t * 100));
781
+ function Ae({ data: c }) {
782
+ const s = c, t = s.max_score ?? 100, a = Math.min(100, Math.max(0, s.total_score / t * 100));
783
783
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-score-breakdown", children: [
784
- c.label && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__label", children: c.label }),
784
+ s.label && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__label", children: s.label }),
785
785
  /* @__PURE__ */ n("div", { className: "pcw-score-bar", children: [
786
786
  /* @__PURE__ */ n("div", { className: "pcw-score-bar__label", children: [
787
787
  "Score: ",
788
- c.total_score,
788
+ s.total_score,
789
789
  t !== 100 ? ` / ${t}` : ""
790
790
  ] }),
791
791
  /* @__PURE__ */ e("div", { className: "pcw-score-bar__track", children: /* @__PURE__ */ e(
@@ -796,14 +796,14 @@ function Ae({ data: s }) {
796
796
  }
797
797
  ) })
798
798
  ] }),
799
- /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factors", children: c.factors.map((i) => {
800
- const l = i.max ?? t, d = Math.min(100, Math.max(0, i.value / l * 100));
799
+ /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factors", children: s.factors.map((r) => {
800
+ const l = r.max ?? t, d = Math.min(100, Math.max(0, r.value / l * 100));
801
801
  return /* @__PURE__ */ n("div", { className: "pcw-score-breakdown__factor", children: [
802
802
  /* @__PURE__ */ n("div", { className: "pcw-score-breakdown__factor-header", children: [
803
- /* @__PURE__ */ e("span", { className: "pcw-score-breakdown__factor-name", children: i.name.replace(/_/g, " ") }),
803
+ /* @__PURE__ */ e("span", { className: "pcw-score-breakdown__factor-name", children: r.name.replace(/_/g, " ") }),
804
804
  /* @__PURE__ */ n("span", { className: "pcw-score-breakdown__factor-value", children: [
805
805
  "+",
806
- i.value
806
+ r.value
807
807
  ] })
808
808
  ] }),
809
809
  /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factor-bar", children: /* @__PURE__ */ e(
@@ -813,8 +813,8 @@ function Ae({ data: s }) {
813
813
  style: { width: `${String(d)}%` }
814
814
  }
815
815
  ) }),
816
- i.description && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factor-desc", children: i.description })
817
- ] }, i.name);
816
+ r.description && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factor-desc", children: r.description })
817
+ ] }, r.name);
818
818
  }) })
819
819
  ] });
820
820
  }
@@ -829,41 +829,41 @@ const Q = {
829
829
  medium: 2,
830
830
  low: 3
831
831
  };
832
- function Le({ data: s, sendMessage: c }) {
833
- const t = s, a = [...t.items].sort(
834
- (i, l) => (Q[i.severity] ?? 4) - (Q[l.severity] ?? 4)
832
+ function Be({ data: c, sendMessage: s }) {
833
+ const t = c, a = [...t.items].sort(
834
+ (r, l) => (Q[r.severity] ?? 4) - (Q[l.severity] ?? 4)
835
835
  );
836
836
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-status-board", children: [
837
837
  t.title && /* @__PURE__ */ e("div", { className: "pcw-status-board__title", children: t.title }),
838
- /* @__PURE__ */ e("div", { className: "pcw-status-board__items", children: a.map((i) => /* @__PURE__ */ n(
838
+ /* @__PURE__ */ e("div", { className: "pcw-status-board__items", children: a.map((r) => /* @__PURE__ */ n(
839
839
  "div",
840
840
  {
841
- className: `pcw-status-board__item pcw-status-board__item--${i.severity}`,
842
- onClick: () => c(`Tell me more about ${i.label}`),
841
+ className: `pcw-status-board__item pcw-status-board__item--${r.severity}`,
842
+ onClick: () => s(`Tell me more about ${r.label}`),
843
843
  style: { cursor: "pointer" },
844
844
  children: [
845
845
  /* @__PURE__ */ n("div", { className: "pcw-status-board__item-header", children: [
846
- /* @__PURE__ */ e("span", { className: `pcw-status-board__severity pcw-status-board__severity--${i.severity}`, children: i.severity.toUpperCase() }),
847
- /* @__PURE__ */ e("span", { className: "pcw-status-board__item-label", children: i.label }),
848
- /* @__PURE__ */ e("span", { className: "pcw-status-board__item-status", children: i.status })
846
+ /* @__PURE__ */ e("span", { className: `pcw-status-board__severity pcw-status-board__severity--${r.severity}`, children: r.severity.toUpperCase() }),
847
+ /* @__PURE__ */ e("span", { className: "pcw-status-board__item-label", children: r.label }),
848
+ /* @__PURE__ */ e("span", { className: "pcw-status-board__item-status", children: r.status })
849
849
  ] }),
850
- i.description && /* @__PURE__ */ e("div", { className: "pcw-status-board__item-desc", children: i.description })
850
+ r.description && /* @__PURE__ */ e("div", { className: "pcw-status-board__item-desc", children: r.description })
851
851
  ]
852
852
  },
853
- i.id
853
+ r.id
854
854
  )) })
855
855
  ] });
856
856
  }
857
- function Be({ data: s, sendMessage: c }) {
858
- const t = s, [a, i] = w({}), [l, d] = w("idle"), [r, p] = w(""), o = b((h, _) => {
859
- i((m) => ({ ...m, [h]: _ }));
860
- }, []), u = b(
857
+ function Le({ data: c, sendMessage: s }) {
858
+ const t = c, [a, r] = w({}), [l, d] = w("idle"), [i, p] = w(""), u = b((h, m) => {
859
+ r((_) => ({ ..._, [h]: m }));
860
+ }, []), o = b(
861
861
  async (h) => {
862
862
  h.preventDefault(), d("submitting"), p("");
863
863
  try {
864
- const m = `${window.location.origin}/api/apps/${t.app_id}/secrets`;
864
+ const _ = `${window.location.origin}/api/apps/${t.app_id}/secrets`;
865
865
  for (const g of t.fields) {
866
- const v = await fetch(m, {
866
+ const v = await fetch(_, {
867
867
  method: "POST",
868
868
  headers: { "Content-Type": "application/json" },
869
869
  body: JSON.stringify({
@@ -875,12 +875,12 @@ function Be({ data: s, sendMessage: c }) {
875
875
  if (!v.ok)
876
876
  throw new Error(`Failed to save ${g.label}: ${String(v.status)}`);
877
877
  }
878
- d("success"), i({}), c(`Credentials for ${t.connection_name} have been saved.`);
879
- } catch (_) {
880
- d("error"), p(_ instanceof Error ? _.message : "Failed to save credentials");
878
+ d("success"), r({}), s(`Credentials for ${t.connection_name} have been saved.`);
879
+ } catch (m) {
880
+ d("error"), p(m instanceof Error ? m.message : "Failed to save credentials");
881
881
  }
882
882
  },
883
- [t.app_id, t.connection_name, t.fields, a, c]
883
+ [t.app_id, t.connection_name, t.fields, a, s]
884
884
  );
885
885
  return l === "success" ? /* @__PURE__ */ e("div", { className: "pcw-widget-card pcw-widget-card--credential-input", children: /* @__PURE__ */ n("div", { className: "pcw-credential-input__status pcw-credential-input__status--success", children: [
886
886
  "Credentials for ",
@@ -895,7 +895,7 @@ function Be({ data: s, sendMessage: c }) {
895
895
  "form",
896
896
  {
897
897
  onSubmit: (h) => {
898
- u(h);
898
+ o(h);
899
899
  },
900
900
  children: [
901
901
  t.fields.map((h) => /* @__PURE__ */ n("div", { className: "pcw-credential-input__field", children: [
@@ -913,11 +913,11 @@ function Be({ data: s, sendMessage: c }) {
913
913
  autoComplete: h.type === "password" ? "new-password" : "off",
914
914
  value: a[h.name] ?? "",
915
915
  disabled: l === "submitting",
916
- onChange: (_) => o(h.name, _.target.value)
916
+ onChange: (m) => u(h.name, m.target.value)
917
917
  }
918
918
  )
919
919
  ] }, h.name)),
920
- l === "error" && /* @__PURE__ */ e("div", { className: "pcw-credential-input__status pcw-credential-input__status--error", children: r }),
920
+ l === "error" && /* @__PURE__ */ e("div", { className: "pcw-credential-input__status pcw-credential-input__status--error", children: i }),
921
921
  /* @__PURE__ */ e(
922
922
  "button",
923
923
  {
@@ -936,19 +936,19 @@ const De = {
936
936
  create: "New",
937
937
  update: "Update"
938
938
  };
939
- function Me({ data: s, sendMessage: c }) {
940
- const t = s, [a, i] = w(!1), [l, d] = w(t.body), [r, p] = w(!1), o = b(() => {
941
- p(!0), c(`I've approved the ${t.resource_type} '${t.preview_id}'.`);
942
- }, [t.resource_type, t.preview_id, c]), u = b(() => {
943
- i(!0);
939
+ function Oe({ data: c, sendMessage: s }) {
940
+ const t = c, [a, r] = w(!1), [l, d] = w(t.body), [i, p] = w(!1), u = b(() => {
941
+ p(!0), s(`I've approved the ${t.resource_type} '${t.preview_id}'.`);
942
+ }, [t.resource_type, t.preview_id, s]), o = b(() => {
943
+ r(!0);
944
944
  }, []), h = b(() => {
945
- p(!0), i(!1), c(
945
+ p(!0), r(!1), s(
946
946
  `I've approved the ${t.resource_type} '${t.preview_id}' with edits:
947
947
 
948
948
  ${l}`
949
949
  );
950
- }, [t.resource_type, t.preview_id, l, c]);
951
- return r ? /* @__PURE__ */ e("div", { className: "pcw-widget-card pcw-widget-card--document-preview", children: /* @__PURE__ */ n("div", { className: "pcw-document-preview__header", children: [
950
+ }, [t.resource_type, t.preview_id, l, s]);
951
+ return i ? /* @__PURE__ */ e("div", { className: "pcw-widget-card pcw-widget-card--document-preview", children: /* @__PURE__ */ n("div", { className: "pcw-document-preview__header", children: [
952
952
  /* @__PURE__ */ e("span", { className: "pcw-document-preview__title", children: t.title }),
953
953
  /* @__PURE__ */ e("span", { className: "pcw-document-preview__badge pcw-document-preview__badge--approved", children: "Approved" })
954
954
  ] }) }) : /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-widget-card--document-preview", children: [
@@ -963,7 +963,7 @@ ${l}`
963
963
  {
964
964
  className: "pcw-document-preview__editor",
965
965
  value: l,
966
- onChange: (_) => d(_.target.value),
966
+ onChange: (m) => d(m.target.value),
967
967
  rows: 12
968
968
  }
969
969
  ),
@@ -983,7 +983,7 @@ ${l}`
983
983
  type: "button",
984
984
  className: "pcw-document-preview__btn pcw-document-preview__btn--secondary",
985
985
  onClick: () => {
986
- i(!1), d(t.body);
986
+ r(!1), d(t.body);
987
987
  },
988
988
  children: "Cancel"
989
989
  }
@@ -997,7 +997,7 @@ ${l}`
997
997
  {
998
998
  type: "button",
999
999
  className: "pcw-document-preview__btn pcw-document-preview__btn--primary",
1000
- onClick: o,
1000
+ onClick: u,
1001
1001
  children: "Approve"
1002
1002
  }
1003
1003
  ),
@@ -1006,7 +1006,7 @@ ${l}`
1006
1006
  {
1007
1007
  type: "button",
1008
1008
  className: "pcw-document-preview__btn pcw-document-preview__btn--secondary",
1009
- onClick: u,
1009
+ onClick: o,
1010
1010
  children: "Edit First"
1011
1011
  }
1012
1012
  )
@@ -1019,8 +1019,8 @@ ${l}`
1019
1019
  * Copyright 2025 Amodal Labs, Inc.
1020
1020
  * SPDX-License-Identifier: MIT
1021
1021
  */
1022
- function Oe({ data: s, sendMessage: c }) {
1023
- const t = s, a = t.title ?? "Untitled", i = Array.isArray(t.fields) ? t.fields : [], l = Array.isArray(t.tags) ? t.tags : [], d = Array.isArray(t.actions) ? t.actions : [];
1022
+ function Me({ data: c, sendMessage: s }) {
1023
+ const t = c, a = t.title ?? "Untitled", r = Array.isArray(t.fields) ? t.fields : [], l = Array.isArray(t.tags) ? t.tags : [], d = Array.isArray(t.actions) ? t.actions : [];
1024
1024
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-info-card", "data-testid": "info-card", children: [
1025
1025
  /* @__PURE__ */ n("div", { className: "pcw-info-card__header", children: [
1026
1026
  /* @__PURE__ */ e("span", { className: "pcw-info-card__title", children: a }),
@@ -1028,20 +1028,20 @@ function Oe({ data: s, sendMessage: c }) {
1028
1028
  ] }),
1029
1029
  t.subtitle && /* @__PURE__ */ e("div", { className: "pcw-info-card__subtitle", children: t.subtitle }),
1030
1030
  t.description && /* @__PURE__ */ e("p", { className: "pcw-info-card__description", children: t.description }),
1031
- i.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__fields", children: i.map((r) => /* @__PURE__ */ n("div", { className: "pcw-info-card__field", children: [
1032
- /* @__PURE__ */ e("span", { className: "pcw-info-card__field-label", children: r.label }),
1033
- /* @__PURE__ */ e("span", { className: "pcw-info-card__field-value", children: String(r.value) })
1034
- ] }, r.label)) }),
1035
- l.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__tags", children: l.map((r) => /* @__PURE__ */ e("span", { className: "pcw-info-card__tag", children: r }, r)) }),
1036
- d.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__actions", children: d.map((r) => /* @__PURE__ */ e(
1031
+ r.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__fields", children: r.map((i) => /* @__PURE__ */ n("div", { className: "pcw-info-card__field", children: [
1032
+ /* @__PURE__ */ e("span", { className: "pcw-info-card__field-label", children: i.label }),
1033
+ /* @__PURE__ */ e("span", { className: "pcw-info-card__field-value", children: String(i.value) })
1034
+ ] }, i.label)) }),
1035
+ l.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__tags", children: l.map((i) => /* @__PURE__ */ e("span", { className: "pcw-info-card__tag", children: i }, i)) }),
1036
+ d.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__actions", children: d.map((i) => /* @__PURE__ */ e(
1037
1037
  "button",
1038
1038
  {
1039
1039
  type: "button",
1040
1040
  className: "pcw-info-card__btn",
1041
- onClick: () => c(r.message),
1042
- children: r.label
1041
+ onClick: () => s(i.message),
1042
+ children: i.label
1043
1043
  },
1044
- r.label
1044
+ i.label
1045
1045
  )) })
1046
1046
  ] });
1047
1047
  }
@@ -1055,24 +1055,24 @@ const Re = {
1055
1055
  down: "↓",
1056
1056
  flat: "→"
1057
1057
  };
1058
- function He({ data: s }) {
1059
- const c = s, t = c.label ?? "Metric", a = c.value ?? "—";
1058
+ function je({ data: c }) {
1059
+ const s = c, t = s.label ?? "Metric", a = s.value ?? "—";
1060
1060
  return /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-metric", "data-testid": "metric", children: [
1061
1061
  /* @__PURE__ */ e("div", { className: "pcw-metric__label", children: t }),
1062
1062
  /* @__PURE__ */ n("div", { className: "pcw-metric__value-row", children: [
1063
1063
  /* @__PURE__ */ e("span", { className: "pcw-metric__value", children: String(a) }),
1064
- c.unit && /* @__PURE__ */ e("span", { className: "pcw-metric__unit", children: c.unit }),
1065
- c.trend && /* @__PURE__ */ e("span", { className: `pcw-metric__trend pcw-metric__trend--${c.trend}`, children: Re[c.trend] ?? "" })
1064
+ s.unit && /* @__PURE__ */ e("span", { className: "pcw-metric__unit", children: s.unit }),
1065
+ s.trend && /* @__PURE__ */ e("span", { className: `pcw-metric__trend pcw-metric__trend--${s.trend}`, children: Re[s.trend] ?? "" })
1066
1066
  ] }),
1067
- c.description && /* @__PURE__ */ e("div", { className: "pcw-metric__description", children: c.description }),
1068
- c.previous_value != null && /* @__PURE__ */ n("div", { className: "pcw-metric__previous", children: [
1067
+ s.description && /* @__PURE__ */ e("div", { className: "pcw-metric__description", children: s.description }),
1068
+ s.previous_value != null && /* @__PURE__ */ n("div", { className: "pcw-metric__previous", children: [
1069
1069
  "Previous: ",
1070
- String(c.previous_value),
1071
- c.unit ? ` ${c.unit}` : ""
1070
+ String(s.previous_value),
1071
+ s.unit ? ` ${s.unit}` : ""
1072
1072
  ] })
1073
1073
  ] });
1074
1074
  }
1075
- const je = {
1075
+ const He = {
1076
1076
  "entity-card": Ne,
1077
1077
  "entity-list": ye,
1078
1078
  "scope-map": Se,
@@ -1081,18 +1081,18 @@ const je = {
1081
1081
  comparison: Te,
1082
1082
  "data-table": Ee,
1083
1083
  "score-breakdown": Ae,
1084
- "status-board": Le,
1085
- "credential-input": Be,
1086
- "document-preview": Me,
1087
- "info-card": Oe,
1088
- metric: He
1084
+ "status-board": Be,
1085
+ "credential-input": Le,
1086
+ "document-preview": Oe,
1087
+ "info-card": Me,
1088
+ metric: je
1089
1089
  };
1090
1090
  class ze extends re {
1091
- constructor(c) {
1092
- super(c), this.state = { error: null };
1091
+ constructor(s) {
1092
+ super(s), this.state = { error: null };
1093
1093
  }
1094
- static getDerivedStateFromError(c) {
1095
- return { error: c };
1094
+ static getDerivedStateFromError(s) {
1095
+ return { error: s };
1096
1096
  }
1097
1097
  render() {
1098
1098
  return this.state.error ? /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-widget-card--generic", children: [
@@ -1105,55 +1105,106 @@ class ze extends re {
1105
1105
  }
1106
1106
  }
1107
1107
  function Ie({
1108
- widgetType: s,
1109
- data: c,
1108
+ widgetType: c,
1109
+ data: s,
1110
1110
  sendMessage: t,
1111
1111
  customWidgets: a,
1112
- onInteraction: i
1112
+ onInteraction: r
1113
1113
  }) {
1114
- const l = (a == null ? void 0 : a[s]) ?? je[s];
1115
- return l ? /* @__PURE__ */ e(ze, { widgetType: s, data: c, children: /* @__PURE__ */ e(l, { data: c, sendMessage: t, onInteraction: i }) }) : /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-widget-card--generic", children: [
1116
- /* @__PURE__ */ e("div", { className: "pcw-widget-card__header", children: /* @__PURE__ */ e("span", { className: "pcw-widget-card__type", children: s }) }),
1117
- /* @__PURE__ */ e("pre", { className: "pcw-widget-card__json", children: JSON.stringify(c, null, 2) })
1114
+ const l = (a == null ? void 0 : a[c]) ?? He[c];
1115
+ return l ? /* @__PURE__ */ e(ze, { widgetType: c, data: s, children: /* @__PURE__ */ e(l, { data: s, sendMessage: t, onInteraction: r }) }) : /* @__PURE__ */ n("div", { className: "pcw-widget-card pcw-widget-card--generic", children: [
1116
+ /* @__PURE__ */ e("div", { className: "pcw-widget-card__header", children: /* @__PURE__ */ e("span", { className: "pcw-widget-card__type", children: c }) }),
1117
+ /* @__PURE__ */ e("pre", { className: "pcw-widget-card__json", children: JSON.stringify(s, null, 2) })
1118
+ ] });
1119
+ }
1120
+ function Pe({ messageId: c, sessionId: s, query: t, response: a }) {
1121
+ const [r, l] = w(null), [d, i] = w(!1), [p, u] = w(""), o = b((m, _) => {
1122
+ l(m), i(!1), fetch("/api/feedback", {
1123
+ method: "POST",
1124
+ headers: { "Content-Type": "application/json" },
1125
+ body: JSON.stringify({ sessionId: s ?? "", messageId: c, rating: m, comment: _, query: t, response: a })
1126
+ }).catch(() => {
1127
+ });
1128
+ }, [s, c, t, a]), h = b(() => {
1129
+ l(null), i(!1), u("");
1130
+ }, []);
1131
+ return /* @__PURE__ */ n("div", { className: "pcw-feedback", children: [
1132
+ /* @__PURE__ */ e(
1133
+ "button",
1134
+ {
1135
+ className: `pcw-feedback__btn ${r === "up" ? "pcw-feedback__btn--active" : ""}`,
1136
+ onClick: () => r === "up" ? h() : o("up"),
1137
+ title: r === "up" ? "Undo" : "Good response",
1138
+ children: "👍"
1139
+ }
1140
+ ),
1141
+ /* @__PURE__ */ e(
1142
+ "button",
1143
+ {
1144
+ className: `pcw-feedback__btn ${r === "down" ? "pcw-feedback__btn--active" : ""}`,
1145
+ onClick: () => {
1146
+ r === "down" ? h() : d ? o("down", p || void 0) : i(!0);
1147
+ },
1148
+ title: r === "down" ? "Undo" : "Bad response",
1149
+ children: "👎"
1150
+ }
1151
+ ),
1152
+ d && /* @__PURE__ */ n("div", { className: "pcw-feedback__comment", children: [
1153
+ /* @__PURE__ */ e(
1154
+ "input",
1155
+ {
1156
+ type: "text",
1157
+ value: p,
1158
+ onChange: (m) => u(m.target.value),
1159
+ onKeyDown: (m) => {
1160
+ m.key === "Enter" && o("down", p || void 0);
1161
+ },
1162
+ placeholder: "What went wrong? (optional)",
1163
+ className: "pcw-feedback__input",
1164
+ autoFocus: !0
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ e("button", { className: "pcw-feedback__submit", onClick: () => o("down", p || void 0), children: "Submit" })
1168
+ ] })
1118
1169
  ] });
1119
1170
  }
1120
- function Pe({
1121
- message: s,
1122
- sendMessage: c,
1171
+ function Fe({
1172
+ message: c,
1173
+ sendMessage: s,
1123
1174
  customWidgets: t,
1124
1175
  onInteraction: a,
1125
- onAskUserSubmit: i
1176
+ onAskUserSubmit: r
1126
1177
  }) {
1127
- const l = s.contentBlocks && s.contentBlocks.length > 0, d = s.toolCalls.length > 0 || s.skillActivations.length > 0 || s.kbProposals.length > 0;
1178
+ const l = c.contentBlocks && c.contentBlocks.length > 0, d = c.toolCalls.length > 0 || c.skillActivations.length > 0 || c.kbProposals.length > 0;
1128
1179
  if (l) {
1129
- const r = s.kbProposals.length > 0;
1180
+ const i = c.kbProposals.length > 0;
1130
1181
  return /* @__PURE__ */ n("div", { className: "pcw-bubble pcw-bubble--assistant", children: [
1131
- s.skillActivations.map((p) => /* @__PURE__ */ e(J, { skill: p }, p)),
1132
- s.contentBlocks.map((p, o) => {
1182
+ c.skillActivations.map((p) => /* @__PURE__ */ e(Y, { skill: p }, p)),
1183
+ c.contentBlocks.map((p, u) => {
1133
1184
  switch (p.type) {
1134
1185
  case "text":
1135
- return p.text.length > 0 ? /* @__PURE__ */ e(x, { text: p.text, className: "pcw-bubble__text" }, `text-${String(o)}`) : null;
1186
+ return p.text.length > 0 ? /* @__PURE__ */ e(C, { text: p.text, className: "pcw-bubble__text" }, `text-${String(u)}`) : null;
1136
1187
  case "widget":
1137
1188
  return /* @__PURE__ */ e(
1138
1189
  Ie,
1139
1190
  {
1140
1191
  widgetType: p.widgetType,
1141
1192
  data: p.data,
1142
- sendMessage: c ?? (() => {
1193
+ sendMessage: s ?? (() => {
1143
1194
  }),
1144
1195
  customWidgets: t,
1145
1196
  onInteraction: a
1146
1197
  },
1147
- `widget-${String(o)}`
1198
+ `widget-${String(u)}`
1148
1199
  );
1149
1200
  case "tool_calls":
1150
- return /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: p.calls.map((u) => /* @__PURE__ */ e(K, { toolCall: u }, u.toolId)) }, `tools-${String(o)}`);
1201
+ return /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: p.calls.map((o) => /* @__PURE__ */ e(Z, { toolCall: o }, o.toolId)) }, `tools-${String(u)}`);
1151
1202
  case "ask_user":
1152
1203
  return /* @__PURE__ */ e(
1153
1204
  ve,
1154
1205
  {
1155
1206
  block: p,
1156
- onSubmit: i ?? (() => {
1207
+ onSubmit: r ?? (() => {
1157
1208
  })
1158
1209
  },
1159
1210
  `ask-${p.askId}`
@@ -1162,53 +1213,58 @@ function Pe({
1162
1213
  return null;
1163
1214
  }
1164
1215
  }),
1165
- r && /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: s.kbProposals.map((p, o) => /* @__PURE__ */ e(Z, { proposal: p }, `${p.title}-${String(o)}`)) })
1216
+ i && /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: c.kbProposals.map((p, u) => /* @__PURE__ */ e(J, { proposal: p }, `${p.title}-${String(u)}`)) })
1166
1217
  ] });
1167
1218
  }
1168
1219
  return /* @__PURE__ */ n("div", { className: "pcw-bubble pcw-bubble--assistant", children: [
1169
- s.skillActivations.map((r) => /* @__PURE__ */ e(J, { skill: r }, r)),
1170
- s.text.length > 0 && /* @__PURE__ */ e(x, { className: "pcw-bubble__text", text: s.text }),
1220
+ c.skillActivations.map((i) => /* @__PURE__ */ e(Y, { skill: i }, i)),
1221
+ c.text.length > 0 && /* @__PURE__ */ e(C, { className: "pcw-bubble__text", text: c.text }),
1171
1222
  d && /* @__PURE__ */ n("div", { className: "pcw-bubble__extras", children: [
1172
- s.toolCalls.map((r) => /* @__PURE__ */ e(K, { toolCall: r }, r.toolId)),
1173
- s.kbProposals.map((r, p) => /* @__PURE__ */ e(Z, { proposal: r }, `${r.title}-${String(p)}`))
1223
+ c.toolCalls.map((i) => /* @__PURE__ */ e(Z, { toolCall: i }, i.toolId)),
1224
+ c.kbProposals.map((i, p) => /* @__PURE__ */ e(J, { proposal: i }, `${i.title}-${String(p)}`))
1174
1225
  ] })
1175
1226
  ] });
1176
1227
  }
1177
- function G({ messages: s, isStreaming: c, sendMessage: t, customWidgets: a, onInteraction: i, onAskUserSubmit: l, emptyStateText: d }) {
1178
- const r = A(null), p = A(!0);
1228
+ function X({ messages: c, isStreaming: s, sendMessage: t, customWidgets: a, onInteraction: r, onAskUserSubmit: l, emptyStateText: d, sessionId: i }) {
1229
+ const p = B(null), u = B(!0);
1179
1230
  return M(() => {
1180
- const o = r.current;
1231
+ const o = p.current;
1181
1232
  if (!o) return;
1182
- const u = () => {
1183
- p.current = o.scrollHeight - o.scrollTop - o.clientHeight < 100;
1233
+ const h = () => {
1234
+ u.current = o.scrollHeight - o.scrollTop - o.clientHeight < 100;
1184
1235
  };
1185
- return o.addEventListener("scroll", u), () => o.removeEventListener("scroll", u);
1236
+ return o.addEventListener("scroll", h), () => o.removeEventListener("scroll", h);
1186
1237
  }, []), M(() => {
1187
- p.current && r.current && (r.current.scrollTop = r.current.scrollHeight);
1188
- }, [s, c]), s.length === 0 ? /* @__PURE__ */ e("div", { className: "pcw-messages--empty", children: /* @__PURE__ */ e("p", { children: d ?? "Send a message to start a conversation." }) }) : /* @__PURE__ */ n("div", { ref: r, className: "pcw-messages", children: [
1189
- s.map((o) => {
1238
+ u.current && p.current && (p.current.scrollTop = p.current.scrollHeight);
1239
+ }, [c, s]), c.length === 0 ? /* @__PURE__ */ e("div", { className: "pcw-messages--empty", children: /* @__PURE__ */ e("p", { children: d ?? "Send a message to start a conversation." }) }) : /* @__PURE__ */ n("div", { ref: p, className: "pcw-messages", children: [
1240
+ c.map((o) => {
1241
+ var h;
1190
1242
  switch (o.type) {
1191
1243
  case "user":
1192
1244
  return /* @__PURE__ */ e("div", { className: "pcw-bubble pcw-bubble--user", children: /* @__PURE__ */ e("p", { className: "pcw-bubble__text", children: o.text }) }, o.id);
1193
- case "assistant_text":
1194
- return /* @__PURE__ */ e(
1195
- Pe,
1196
- {
1197
- message: o,
1198
- sendMessage: t,
1199
- customWidgets: a,
1200
- onInteraction: i,
1201
- onAskUserSubmit: l
1202
- },
1203
- o.id
1204
- );
1245
+ case "assistant_text": {
1246
+ const m = c.indexOf(o), _ = c.slice(0, m).reverse().find((f) => f.type === "user"), g = _ && "text" in _ ? String(_.text) : "", v = ((h = o.contentBlocks) == null ? void 0 : h.filter((f) => f.type === "text").map((f) => f.text).join("")) ?? o.text;
1247
+ return /* @__PURE__ */ n("div", { children: [
1248
+ /* @__PURE__ */ e(
1249
+ Fe,
1250
+ {
1251
+ message: o,
1252
+ sendMessage: t,
1253
+ customWidgets: a,
1254
+ onInteraction: r,
1255
+ onAskUserSubmit: l
1256
+ }
1257
+ ),
1258
+ !s && /* @__PURE__ */ e(Pe, { messageId: o.id, sessionId: i, query: g, response: v })
1259
+ ] }, o.id);
1260
+ }
1205
1261
  case "error":
1206
1262
  return /* @__PURE__ */ e("div", { className: "pcw-error", children: o.message }, o.id);
1207
1263
  default:
1208
1264
  return null;
1209
1265
  }
1210
1266
  }),
1211
- c && /* @__PURE__ */ e(ge, {})
1267
+ s && /* @__PURE__ */ e(ge, {})
1212
1268
  ] });
1213
1269
  }
1214
1270
  function We() {
@@ -1217,33 +1273,33 @@ function We() {
1217
1273
  /* @__PURE__ */ e("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
1218
1274
  ] });
1219
1275
  }
1220
- function Fe() {
1276
+ function Ue() {
1221
1277
  return /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }) });
1222
1278
  }
1223
- function X({ onSend: s, onStop: c, disabled: t, isStreaming: a, placeholder: i }) {
1224
- const [l, d] = w(""), r = A(null), p = b(() => {
1279
+ function q({ onSend: c, onStop: s, disabled: t, isStreaming: a, placeholder: r }) {
1280
+ const [l, d] = w(""), i = B(null), p = b(() => {
1225
1281
  const h = l.trim();
1226
- h.length !== 0 && (s(h), d(""), r.current && (r.current.style.height = "auto"));
1227
- }, [l, s]), o = b(
1282
+ h.length !== 0 && (c(h), d(""), i.current && (i.current.style.height = "auto"));
1283
+ }, [l, c]), u = b(
1228
1284
  (h) => {
1229
1285
  h.key === "Enter" && !h.shiftKey && (h.preventDefault(), p());
1230
1286
  },
1231
1287
  [p]
1232
- ), u = b(() => {
1233
- const h = r.current;
1288
+ ), o = b(() => {
1289
+ const h = i.current;
1234
1290
  h && (h.style.height = "auto", h.style.height = `${String(Math.min(h.scrollHeight, 120))}px`);
1235
1291
  }, []);
1236
1292
  return /* @__PURE__ */ n("div", { className: "pcw-input", children: [
1237
1293
  /* @__PURE__ */ e(
1238
1294
  "textarea",
1239
1295
  {
1240
- ref: r,
1296
+ ref: i,
1241
1297
  className: "pcw-input__textarea",
1242
1298
  value: l,
1243
1299
  onChange: (h) => d(h.target.value),
1244
- onKeyDown: o,
1245
- onInput: u,
1246
- placeholder: i,
1300
+ onKeyDown: u,
1301
+ onInput: o,
1302
+ placeholder: r,
1247
1303
  disabled: t && !a,
1248
1304
  rows: 1
1249
1305
  }
@@ -1253,9 +1309,9 @@ function X({ onSend: s, onStop: c, disabled: t, isStreaming: a, placeholder: i }
1253
1309
  {
1254
1310
  type: "button",
1255
1311
  className: "pcw-input__send pcw-input__stop",
1256
- onClick: c,
1312
+ onClick: s,
1257
1313
  "aria-label": "Stop generating",
1258
- children: /* @__PURE__ */ e(Fe, {})
1314
+ children: /* @__PURE__ */ e(Ue, {})
1259
1315
  }
1260
1316
  ) : /* @__PURE__ */ e(
1261
1317
  "button",
@@ -1270,44 +1326,44 @@ function X({ onSend: s, onStop: c, disabled: t, isStreaming: a, placeholder: i }
1270
1326
  )
1271
1327
  ] });
1272
1328
  }
1273
- function Ve({ tags: s, onSave: c }) {
1274
- const [t, a] = w(!1), [i, l] = w(""), d = b(
1275
- (o) => {
1276
- c(s.filter((u) => u !== o));
1329
+ function Ve({ tags: c, onSave: s }) {
1330
+ const [t, a] = w(!1), [r, l] = w(""), d = b(
1331
+ (u) => {
1332
+ s(c.filter((o) => o !== u));
1277
1333
  },
1278
- [s, c]
1279
- ), r = b(() => {
1280
- const o = i.trim();
1281
- o && !s.includes(o) && c([...s, o]), l(""), a(!1);
1282
- }, [i, s, c]), p = b(
1283
- (o) => {
1284
- o.key === "Enter" ? (o.preventDefault(), r()) : o.key === "Escape" && (l(""), a(!1));
1334
+ [c, s]
1335
+ ), i = b(() => {
1336
+ const u = r.trim();
1337
+ u && !c.includes(u) && s([...c, u]), l(""), a(!1);
1338
+ }, [r, c, s]), p = b(
1339
+ (u) => {
1340
+ u.key === "Enter" ? (u.preventDefault(), i()) : u.key === "Escape" && (l(""), a(!1));
1285
1341
  },
1286
- [r]
1342
+ [i]
1287
1343
  );
1288
1344
  return /* @__PURE__ */ n("div", { className: "pcw-tag-editor", children: [
1289
- s.map((o) => /* @__PURE__ */ n("span", { className: "pcw-tag-badge", children: [
1290
- o,
1345
+ c.map((u) => /* @__PURE__ */ n("span", { className: "pcw-tag-badge", children: [
1346
+ u,
1291
1347
  /* @__PURE__ */ e(
1292
1348
  "button",
1293
1349
  {
1294
1350
  type: "button",
1295
1351
  className: "pcw-tag-remove",
1296
- onClick: () => d(o),
1297
- "aria-label": `Remove tag ${o}`,
1352
+ onClick: () => d(u),
1353
+ "aria-label": `Remove tag ${u}`,
1298
1354
  children: "x"
1299
1355
  }
1300
1356
  )
1301
- ] }, o)),
1357
+ ] }, u)),
1302
1358
  t ? /* @__PURE__ */ e(
1303
1359
  "input",
1304
1360
  {
1305
1361
  className: "pcw-tag-input",
1306
1362
  type: "text",
1307
- value: i,
1308
- onChange: (o) => l(o.target.value),
1363
+ value: r,
1364
+ onChange: (u) => l(u.target.value),
1309
1365
  onKeyDown: p,
1310
- onBlur: r,
1366
+ onBlur: i,
1311
1367
  placeholder: "Add tag...",
1312
1368
  autoFocus: !0
1313
1369
  }
@@ -1323,29 +1379,29 @@ function Ve({ tags: s, onSave: c }) {
1323
1379
  )
1324
1380
  ] });
1325
1381
  }
1326
- function Ue(s) {
1327
- const c = Date.now(), t = new Date(s).getTime(), a = c - t, i = Math.floor(a / 6e4);
1328
- if (i < 1) return "just now";
1329
- if (i < 60) return `${String(i)}m ago`;
1330
- const l = Math.floor(i / 60);
1382
+ function Ke(c) {
1383
+ const s = Date.now(), t = new Date(c).getTime(), a = s - t, r = Math.floor(a / 6e4);
1384
+ if (r < 1) return "just now";
1385
+ if (r < 60) return `${String(r)}m ago`;
1386
+ const l = Math.floor(r / 60);
1331
1387
  if (l < 24) return `${String(l)}h ago`;
1332
1388
  const d = Math.floor(l / 24);
1333
1389
  return `${String(d)}d ago`;
1334
1390
  }
1335
- function q({
1336
- sessions: s,
1337
- isLoading: c,
1391
+ function ee({
1392
+ sessions: c,
1393
+ isLoading: s,
1338
1394
  allTags: t,
1339
1395
  onSelectSession: a,
1340
- onNewChat: i,
1396
+ onNewChat: r,
1341
1397
  onClose: l,
1342
1398
  onUpdateTags: d
1343
1399
  }) {
1344
- const [r, p] = w([]), [o, u] = w(null), h = b((m) => {
1400
+ const [i, p] = w([]), [u, o] = w(null), h = b((_) => {
1345
1401
  p(
1346
- (g) => g.includes(m) ? g.filter((v) => v !== m) : [...g, m]
1402
+ (g) => g.includes(_) ? g.filter((v) => v !== _) : [...g, _]
1347
1403
  );
1348
- }, []), _ = r.length > 0 ? s.filter((m) => r.some((g) => m.tags.includes(g))) : s;
1404
+ }, []), m = i.length > 0 ? c.filter((_) => i.some((g) => _.tags.includes(g))) : c;
1349
1405
  return /* @__PURE__ */ n("div", { className: "pcw-history-drawer", "data-testid": "session-history", children: [
1350
1406
  /* @__PURE__ */ n("div", { className: "pcw-history-header", children: [
1351
1407
  /* @__PURE__ */ e("h3", { className: "pcw-history-title", children: "Session History" }),
@@ -1368,24 +1424,24 @@ function q({
1368
1424
  {
1369
1425
  type: "button",
1370
1426
  className: "pcw-history-new-chat",
1371
- onClick: i,
1427
+ onClick: r,
1372
1428
  children: "+ New Chat"
1373
1429
  }
1374
1430
  ),
1375
- t.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-history-filters", children: t.map((m) => /* @__PURE__ */ e(
1431
+ t.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-history-filters", children: t.map((_) => /* @__PURE__ */ e(
1376
1432
  "button",
1377
1433
  {
1378
1434
  type: "button",
1379
- className: `pcw-filter-chip ${r.includes(m) ? "pcw-filter-chip--active" : ""}`,
1380
- onClick: () => h(m),
1381
- children: m
1435
+ className: `pcw-filter-chip ${i.includes(_) ? "pcw-filter-chip--active" : ""}`,
1436
+ onClick: () => h(_),
1437
+ children: _
1382
1438
  },
1383
- m
1439
+ _
1384
1440
  )) }),
1385
1441
  /* @__PURE__ */ n("div", { className: "pcw-history-list", children: [
1386
- c && /* @__PURE__ */ e("div", { className: "pcw-history-loading", children: "Loading sessions..." }),
1387
- !c && _.length === 0 && /* @__PURE__ */ e("div", { className: "pcw-history-empty", children: "No past sessions" }),
1388
- _.map((m) => /* @__PURE__ */ n(
1442
+ s && /* @__PURE__ */ e("div", { className: "pcw-history-loading", children: "Loading sessions..." }),
1443
+ !s && m.length === 0 && /* @__PURE__ */ e("div", { className: "pcw-history-empty", children: "No past sessions" }),
1444
+ m.map((_) => /* @__PURE__ */ n(
1389
1445
  "div",
1390
1446
  {
1391
1447
  className: "pcw-history-item",
@@ -1395,37 +1451,37 @@ function q({
1395
1451
  {
1396
1452
  type: "button",
1397
1453
  className: "pcw-history-item-content",
1398
- onClick: () => a(m.id),
1454
+ onClick: () => a(_.id),
1399
1455
  children: [
1400
- /* @__PURE__ */ e("div", { className: "pcw-history-item-title", children: m.title ?? `Session ${m.id.slice(0, 8)}` }),
1456
+ /* @__PURE__ */ e("div", { className: "pcw-history-item-title", children: _.title ?? `Session ${_.id.slice(0, 8)}` }),
1401
1457
  /* @__PURE__ */ n("div", { className: "pcw-history-item-meta", children: [
1402
- /* @__PURE__ */ e("span", { className: "pcw-history-item-time", children: Ue(m.created_at) }),
1458
+ /* @__PURE__ */ e("span", { className: "pcw-history-item-time", children: Ke(_.created_at) }),
1403
1459
  /* @__PURE__ */ n("span", { className: "pcw-history-item-count", children: [
1404
- String(m.message_count),
1460
+ String(_.message_count),
1405
1461
  " msg",
1406
- m.message_count !== 1 ? "s" : ""
1462
+ _.message_count !== 1 ? "s" : ""
1407
1463
  ] })
1408
1464
  ] })
1409
1465
  ]
1410
1466
  }
1411
1467
  ),
1412
- /* @__PURE__ */ e("div", { className: "pcw-history-item-tags", children: o === m.id ? /* @__PURE__ */ e(
1468
+ /* @__PURE__ */ e("div", { className: "pcw-history-item-tags", children: u === _.id ? /* @__PURE__ */ e(
1413
1469
  Ve,
1414
1470
  {
1415
- tags: m.tags,
1471
+ tags: _.tags,
1416
1472
  onSave: (g) => {
1417
- d(m.id, g), u(null);
1473
+ d(_.id, g), o(null);
1418
1474
  }
1419
1475
  }
1420
1476
  ) : /* @__PURE__ */ n("div", { className: "pcw-history-item-tag-list", children: [
1421
- m.tags.map((g) => /* @__PURE__ */ e("span", { className: "pcw-tag-badge pcw-tag-badge--small", children: g }, g)),
1477
+ _.tags.map((g) => /* @__PURE__ */ e("span", { className: "pcw-tag-badge pcw-tag-badge--small", children: g }, g)),
1422
1478
  /* @__PURE__ */ e(
1423
1479
  "button",
1424
1480
  {
1425
1481
  type: "button",
1426
1482
  className: "pcw-tag-edit-btn",
1427
1483
  onClick: (g) => {
1428
- g.stopPropagation(), u(m.id);
1484
+ g.stopPropagation(), o(_.id);
1429
1485
  },
1430
1486
  "aria-label": "Edit tags",
1431
1487
  children: /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, width: 12, height: 12, children: [
@@ -1437,169 +1493,169 @@ function q({
1437
1493
  ] }) })
1438
1494
  ]
1439
1495
  },
1440
- m.id
1496
+ _.id
1441
1497
  ))
1442
1498
  ] })
1443
1499
  ] });
1444
1500
  }
1445
- function Ke() {
1501
+ function Ze() {
1446
1502
  return /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
1447
1503
  }
1448
- function Ze() {
1504
+ function Je() {
1449
1505
  return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [
1450
1506
  /* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1451
1507
  /* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1452
1508
  ] });
1453
1509
  }
1454
- function Xe({
1455
- serverUrl: s,
1456
- user: c,
1510
+ function qe({
1511
+ serverUrl: c,
1512
+ user: s,
1457
1513
  getToken: t,
1458
1514
  theme: a,
1459
- position: i = "floating",
1515
+ position: r = "floating",
1460
1516
  defaultOpen: l = !1,
1461
1517
  onToolCall: d,
1462
- onKBProposal: r,
1518
+ onKBProposal: i,
1463
1519
  onEvent: p,
1464
- entityExtractors: o,
1465
- widgets: u,
1520
+ entityExtractors: u,
1521
+ widgets: o,
1466
1522
  historyEnabled: h = !1,
1467
- showInput: _ = !0,
1468
- sessionType: m,
1523
+ showInput: m = !0,
1524
+ sessionType: _,
1469
1525
  deployId: g,
1470
1526
  initialMessage: v,
1471
- resumeSessionId: te,
1472
- onStreamEnd: se,
1473
- onSessionCreated: ce
1527
+ resumeSessionId: f,
1528
+ onStreamEnd: ce,
1529
+ onSessionCreated: se
1474
1530
  }) {
1475
- const [ae, R] = w(l), [L, f] = w(!1), C = A(null), k = ie(a), { messages: H, send: B, stop: j, isStreaming: S, error: $, reset: T, eventBus: z, submitAskUserResponse: I, loadSession: P, isHistorical: E } = le({
1476
- serverUrl: s,
1477
- user: c,
1531
+ const [ae, j] = w(l), [L, k] = w(!1), $ = B(null), S = ie(a), { messages: H, send: D, stop: z, isStreaming: x, error: T, reset: E, eventBus: I, submitAskUserResponse: P, loadSession: F, isHistorical: A } = le({
1532
+ serverUrl: c,
1533
+ user: s,
1478
1534
  getToken: t,
1479
1535
  onToolCall: d,
1480
- onKBProposal: r,
1536
+ onKBProposal: i,
1481
1537
  onEvent: p,
1482
- entityExtractors: o,
1483
- sessionType: m,
1538
+ entityExtractors: u,
1539
+ sessionType: _,
1484
1540
  deployId: g,
1485
1541
  initialMessage: v,
1486
- resumeSessionId: te,
1487
- onStreamEnd: se,
1488
- onSessionCreated: ce
1489
- }), N = de({
1490
- serverUrl: s,
1542
+ resumeSessionId: f,
1543
+ onStreamEnd: ce,
1544
+ onSessionCreated: se
1545
+ }), N = oe({
1546
+ serverUrl: c,
1491
1547
  getToken: t,
1492
1548
  enabled: h && L
1493
1549
  }), W = b(
1494
1550
  (y) => {
1495
- z.emitInteraction(y), p == null || p(y);
1551
+ I.emitInteraction(y), p == null || p(y);
1496
1552
  },
1497
- [z, p]
1498
- ), F = b(
1553
+ [I, p]
1554
+ ), U = b(
1499
1555
  (y) => {
1500
- P(y), f(!1);
1556
+ F(y), k(!1);
1501
1557
  },
1502
- [P]
1558
+ [F]
1503
1559
  ), V = b(() => {
1504
- T(), f(!1);
1505
- }, [T]);
1560
+ E(), k(!1);
1561
+ }, [E]);
1506
1562
  M(() => {
1507
- C.current && a && oe(C.current, a);
1563
+ $.current && a && de($.current, a);
1508
1564
  }, [a]);
1509
- const U = `pcw-widget pcw-widget--${i}`;
1510
- return i === "inline" ? /* @__PURE__ */ n("div", { ref: C, className: U, "data-testid": "chat-widget", children: [
1565
+ const K = `pcw-widget pcw-widget--${r}`;
1566
+ return r === "inline" ? /* @__PURE__ */ n("div", { ref: $, className: K, "data-testid": "chat-widget", children: [
1511
1567
  /* @__PURE__ */ e(
1512
- ee,
1568
+ te,
1513
1569
  {
1514
- title: k.headerText,
1515
- onReset: T,
1570
+ title: S.headerText,
1571
+ onReset: E,
1516
1572
  historyEnabled: h,
1517
- onToggleHistory: () => f((y) => !y),
1518
- isHistorical: E
1573
+ onToggleHistory: () => k((y) => !y),
1574
+ isHistorical: A
1519
1575
  }
1520
1576
  ),
1521
1577
  L && /* @__PURE__ */ e(
1522
- q,
1578
+ ee,
1523
1579
  {
1524
1580
  sessions: N.sessions,
1525
1581
  isLoading: N.isLoading,
1526
1582
  allTags: N.allTags,
1527
- onSelectSession: F,
1583
+ onSelectSession: U,
1528
1584
  onNewChat: V,
1529
- onClose: () => f(!1),
1585
+ onClose: () => k(!1),
1530
1586
  onUpdateTags: N.updateTags
1531
1587
  }
1532
1588
  ),
1533
- /* @__PURE__ */ e(G, { messages: H, isStreaming: S, sendMessage: B, customWidgets: u, onInteraction: W, onAskUserSubmit: I, emptyStateText: k.emptyStateText }),
1534
- $ && /* @__PURE__ */ e("div", { className: "pcw-error", children: $ }),
1535
- _ && /* @__PURE__ */ e(
1536
- X,
1589
+ /* @__PURE__ */ e(X, { messages: H, isStreaming: x, sendMessage: D, customWidgets: o, onInteraction: W, onAskUserSubmit: P, emptyStateText: S.emptyStateText }),
1590
+ T && /* @__PURE__ */ e("div", { className: "pcw-error", children: T }),
1591
+ m && /* @__PURE__ */ e(
1592
+ q,
1537
1593
  {
1538
- onSend: B,
1539
- onStop: j,
1540
- disabled: S,
1541
- isStreaming: S,
1542
- placeholder: E ? "Send a message to start a new chat..." : k.placeholder
1594
+ onSend: D,
1595
+ onStop: z,
1596
+ disabled: x,
1597
+ isStreaming: x,
1598
+ placeholder: A ? "Send a message to start a new chat..." : S.placeholder
1543
1599
  }
1544
1600
  )
1545
- ] }) : ae ? /* @__PURE__ */ n("div", { ref: C, className: U, "data-testid": "chat-widget", children: [
1601
+ ] }) : ae ? /* @__PURE__ */ n("div", { ref: $, className: K, "data-testid": "chat-widget", children: [
1546
1602
  /* @__PURE__ */ e(
1547
- ee,
1603
+ te,
1548
1604
  {
1549
- title: k.headerText,
1550
- onClose: () => R(!1),
1551
- onReset: T,
1605
+ title: S.headerText,
1606
+ onClose: () => j(!1),
1607
+ onReset: E,
1552
1608
  showClose: !0,
1553
1609
  historyEnabled: h,
1554
- onToggleHistory: () => f((y) => !y),
1555
- isHistorical: E
1610
+ onToggleHistory: () => k((y) => !y),
1611
+ isHistorical: A
1556
1612
  }
1557
1613
  ),
1558
1614
  L && /* @__PURE__ */ e(
1559
- q,
1615
+ ee,
1560
1616
  {
1561
1617
  sessions: N.sessions,
1562
1618
  isLoading: N.isLoading,
1563
1619
  allTags: N.allTags,
1564
- onSelectSession: F,
1620
+ onSelectSession: U,
1565
1621
  onNewChat: V,
1566
- onClose: () => f(!1),
1622
+ onClose: () => k(!1),
1567
1623
  onUpdateTags: N.updateTags
1568
1624
  }
1569
1625
  ),
1570
- /* @__PURE__ */ e(G, { messages: H, isStreaming: S, onInteraction: W, onAskUserSubmit: I, emptyStateText: k.emptyStateText }),
1571
- $ && /* @__PURE__ */ e("div", { className: "pcw-error", children: $ }),
1572
- _ && /* @__PURE__ */ e(
1573
- X,
1626
+ /* @__PURE__ */ e(X, { messages: H, isStreaming: x, onInteraction: W, onAskUserSubmit: P, emptyStateText: S.emptyStateText }),
1627
+ T && /* @__PURE__ */ e("div", { className: "pcw-error", children: T }),
1628
+ m && /* @__PURE__ */ e(
1629
+ q,
1574
1630
  {
1575
- onSend: B,
1576
- onStop: j,
1577
- disabled: S,
1578
- isStreaming: S,
1579
- placeholder: E ? "Send a message to start a new chat..." : k.placeholder
1631
+ onSend: D,
1632
+ onStop: z,
1633
+ disabled: x,
1634
+ isStreaming: x,
1635
+ placeholder: A ? "Send a message to start a new chat..." : S.placeholder
1580
1636
  }
1581
1637
  )
1582
- ] }) : i === "floating" ? /* @__PURE__ */ e(
1638
+ ] }) : r === "floating" ? /* @__PURE__ */ e(
1583
1639
  "button",
1584
1640
  {
1585
1641
  type: "button",
1586
1642
  className: "pcw-toggle",
1587
- onClick: () => R(!0),
1643
+ onClick: () => j(!0),
1588
1644
  "aria-label": "Open chat",
1589
- children: /* @__PURE__ */ e(Ke, {})
1645
+ children: /* @__PURE__ */ e(Ze, {})
1590
1646
  }
1591
1647
  ) : null;
1592
1648
  }
1593
- function Je() {
1649
+ function Ye() {
1594
1650
  return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", width: 16, height: 16, children: [
1595
1651
  /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
1596
1652
  /* @__PURE__ */ e("polyline", { points: "12 6 12 12 16 14" })
1597
1653
  ] });
1598
1654
  }
1599
- function ee({ title: s, onClose: c, onReset: t, showClose: a = !1, historyEnabled: i, onToggleHistory: l, isHistorical: d }) {
1655
+ function te({ title: c, onClose: s, onReset: t, showClose: a = !1, historyEnabled: r, onToggleHistory: l, isHistorical: d }) {
1600
1656
  return /* @__PURE__ */ n("div", { className: "pcw-header", children: [
1601
1657
  /* @__PURE__ */ n("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
1602
- i && l && /* @__PURE__ */ e(
1658
+ r && l && /* @__PURE__ */ e(
1603
1659
  "button",
1604
1660
  {
1605
1661
  type: "button",
@@ -1607,11 +1663,11 @@ function ee({ title: s, onClose: c, onReset: t, showClose: a = !1, historyEnable
1607
1663
  onClick: l,
1608
1664
  "aria-label": "Session history",
1609
1665
  title: "Session history",
1610
- children: /* @__PURE__ */ e(Je, {})
1666
+ children: /* @__PURE__ */ e(Ye, {})
1611
1667
  }
1612
1668
  ),
1613
1669
  /* @__PURE__ */ n("h3", { className: "pcw-header__title", children: [
1614
- s,
1670
+ c,
1615
1671
  d && /* @__PURE__ */ e("span", { className: "pcw-header__badge", children: "History" })
1616
1672
  ] })
1617
1673
  ] }),
@@ -1627,14 +1683,14 @@ function ee({ title: s, onClose: c, onReset: t, showClose: a = !1, historyEnable
1627
1683
  children: "↻"
1628
1684
  }
1629
1685
  ),
1630
- a && c && /* @__PURE__ */ e(
1686
+ a && s && /* @__PURE__ */ e(
1631
1687
  "button",
1632
1688
  {
1633
1689
  type: "button",
1634
1690
  className: "pcw-header__close",
1635
- onClick: c,
1691
+ onClick: s,
1636
1692
  "aria-label": "Close chat",
1637
- children: /* @__PURE__ */ e(Ze, {})
1693
+ children: /* @__PURE__ */ e(Je, {})
1638
1694
  }
1639
1695
  )
1640
1696
  ] })
@@ -1642,27 +1698,27 @@ function ee({ title: s, onClose: c, onReset: t, showClose: a = !1, historyEnable
1642
1698
  }
1643
1699
  export {
1644
1700
  ve as AskUserCard,
1645
- Xe as ChatWidget,
1646
- x as FormattedText,
1647
- X as InputBar,
1648
- Z as KBProposalCard,
1649
- G as MessageList,
1650
- q as SessionHistory,
1651
- J as SkillPill,
1701
+ qe as ChatWidget,
1702
+ C as FormattedText,
1703
+ q as InputBar,
1704
+ J as KBProposalCard,
1705
+ X as MessageList,
1706
+ ee as SessionHistory,
1707
+ Y as SkillPill,
1652
1708
  ge as StreamingIndicator,
1653
1709
  Ve as TagEditor,
1654
- K as ToolCallCard,
1655
- at as WidgetEventBus,
1710
+ Z as ToolCallCard,
1711
+ nt as WidgetEventBus,
1656
1712
  Ie as WidgetRenderer,
1657
- oe as applyTheme,
1658
- nt as createSession,
1659
- rt as defaultEntityExtractor,
1660
- tt as defaultTheme,
1661
- it as getSessionHistory,
1662
- lt as listSessions,
1713
+ de as applyTheme,
1714
+ rt as createSession,
1715
+ it as defaultEntityExtractor,
1716
+ ct as defaultTheme,
1717
+ lt as getSessionHistory,
1718
+ ot as listSessions,
1663
1719
  ie as mergeTheme,
1664
1720
  le as useChat,
1665
- de as useSessionHistory,
1721
+ oe as useSessionHistory,
1666
1722
  st as useWidgetEvents
1667
1723
  };
1668
1724
  //# sourceMappingURL=widget.js.map