@pluno/product-agent-web 0.1.52 → 0.1.54

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.
@@ -1,27 +1,27 @@
1
- import { PlunoProductAgent as Vn } from "./product-agent-sdk.js";
2
- const Yn = "#7c3aed", He = "M547 151 C516 151 493 169 485 199 L382 606 C373 641 396 666 431 666 L523 666 C552 666 568 684 563 713 L491 1028 C486 1054 510 1067 527 1044 L894 487 C915 455 894 432 856 432 L815 432 C784 432 773 411 789 382 L904 205 C922 171 901 145 859 145 Z", Ge = "#2c2a1e", Nt = [253, 250, 241], Dt = 3.5;
3
- function dn(e) {
4
- const t = cn(e);
5
- if (Rt(Te(t), Nt) >= Dt)
1
+ import { PlunoProductAgent as Jn } from "./product-agent-sdk.js";
2
+ const Qn = "#7c3aed", $e = "M547 151 C516 151 493 169 485 199 L382 606 C373 641 396 666 431 666 L523 666 C552 666 568 684 563 713 L491 1028 C486 1054 510 1067 527 1044 L894 487 C915 455 894 432 856 432 L815 432 C784 432 773 411 789 382 L904 205 C922 171 901 145 859 145 Z", qe = "#2c2a1e", zt = [253, 250, 241], Bt = 3.5;
3
+ function hn(e) {
4
+ const t = mn(e);
5
+ if (Ut(Re(t), zt) >= Bt)
6
6
  return t;
7
- let o = Te(t);
8
- const i = Te(Ge);
7
+ let n = Re(t);
8
+ const i = Re(qe);
9
9
  for (let a = 0; a < 6; a += 1)
10
- if (o = Zn(o, i, 0.22), Rt(o, Nt) >= Dt)
11
- return st(o);
12
- return st(o);
10
+ if (n = no(n, i, 0.22), Ut(n, zt) >= Bt)
11
+ return ut(n);
12
+ return ut(n);
13
13
  }
14
- function Kn() {
15
- let n = "M 280 120", o = !1, i = 0;
14
+ function eo() {
15
+ let o = "M 280 120", n = !1, i = 0;
16
16
  for (let a = 150; a <= 1170; a += 62) {
17
- const l = (i % 3 - 1) * 18, p = o ? 280 - l : 1020 + l;
18
- n += ` L ${p} ${a}`, o = !o, i += 1;
17
+ const l = (i % 3 - 1) * 18, p = n ? 280 - l : 1020 + l;
18
+ o += ` L ${p} ${a}`, n = !n, i += 1;
19
19
  }
20
- return n;
20
+ return o;
21
21
  }
22
- function Xn(e) {
23
- const t = cn(e), n = dt(Te(t));
24
- return n > 0.86 ? {
22
+ function to(e) {
23
+ const t = mn(e), o = gt(Re(t));
24
+ return o > 0.86 ? {
25
25
  top: "#ffffff",
26
26
  middle: "#f6f6f6",
27
27
  bottom: "#e7e7e7",
@@ -32,7 +32,7 @@ function Xn(e) {
32
32
  highlight: "#ffffff",
33
33
  inner: "#f4f4f4",
34
34
  shadow: "#9d9d9d"
35
- } : n < 0.05 ? {
35
+ } : o < 0.05 ? {
36
36
  top: "#3d3d3d",
37
37
  middle: "#171717",
38
38
  bottom: "#030303",
@@ -44,187 +44,179 @@ function Xn(e) {
44
44
  inner: "#4b4b4b",
45
45
  shadow: "#000000"
46
46
  } : {
47
- top: K(t, 0.28, -0.03),
48
- middle: K(t, 0.08, 0.04),
49
- bottom: K(t, -0.1, 0.02),
50
- edgeStart: K(t, 0.08, 0.08),
51
- edgeMiddle: K(t, -0.08, 0.08),
52
- edgeEnd: K(t, -0.18, 0.05),
53
- glow: K(t, 0.32, -0.12),
54
- highlight: K(t, 0.38, -0.18),
55
- inner: K(t, 0.24, -0.1),
56
- shadow: K(t, -0.25, -0.08)
47
+ top: Y(t, 0.28, -0.03),
48
+ middle: Y(t, 0.08, 0.04),
49
+ bottom: Y(t, -0.1, 0.02),
50
+ edgeStart: Y(t, 0.08, 0.08),
51
+ edgeMiddle: Y(t, -0.08, 0.08),
52
+ edgeEnd: Y(t, -0.18, 0.05),
53
+ glow: Y(t, 0.32, -0.12),
54
+ highlight: Y(t, 0.38, -0.18),
55
+ inner: Y(t, 0.24, -0.1),
56
+ shadow: Y(t, -0.25, -0.08)
57
57
  };
58
58
  }
59
- function cn(e) {
59
+ function mn(e) {
60
60
  const t = e.trim();
61
- return /^#[0-9a-f]{6}$/i.test(t) ? t.toLowerCase() : /^#[0-9a-f]{3}$/i.test(t) ? `#${t.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : Yn;
61
+ return /^#[0-9a-f]{6}$/i.test(t) ? t.toLowerCase() : /^#[0-9a-f]{3}$/i.test(t) ? `#${t.slice(1).split("").map((o) => o + o).join("").toLowerCase()}` : Qn;
62
62
  }
63
- function Te(e) {
63
+ function Re(e) {
64
64
  return [
65
65
  Number.parseInt(e.slice(1, 3), 16),
66
66
  Number.parseInt(e.slice(3, 5), 16),
67
67
  Number.parseInt(e.slice(5, 7), 16)
68
68
  ];
69
69
  }
70
- function st([e, t, n]) {
71
- const o = (i) => Math.max(0, Math.min(255, Math.round(i))).toString(16).padStart(2, "0");
72
- return `#${o(e)}${o(t)}${o(n)}`;
70
+ function ut([e, t, o]) {
71
+ const n = (i) => Math.max(0, Math.min(255, Math.round(i))).toString(16).padStart(2, "0");
72
+ return `#${n(e)}${n(t)}${n(o)}`;
73
73
  }
74
- function dt([e, t, n]) {
75
- const o = (i) => {
74
+ function gt([e, t, o]) {
75
+ const n = (i) => {
76
76
  const a = i / 255;
77
77
  return a <= 0.04045 ? a / 12.92 : ((a + 0.055) / 1.055) ** 2.4;
78
78
  };
79
- return 0.2126 * o(e) + 0.7152 * o(t) + 0.0722 * o(n);
79
+ return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
80
80
  }
81
- function Rt(e, t) {
82
- const n = dt(e), o = dt(t), [i, a] = n > o ? [n, o] : [o, n];
81
+ function Ut(e, t) {
82
+ const o = gt(e), n = gt(t), [i, a] = o > n ? [o, n] : [n, o];
83
83
  return (i + 0.05) / (a + 0.05);
84
84
  }
85
- function Zn(e, t, n) {
86
- const o = ct(n);
85
+ function no(e, t, o) {
86
+ const n = ht(o);
87
87
  return [
88
- e[0] + (t[0] - e[0]) * o,
89
- e[1] + (t[1] - e[1]) * o,
90
- e[2] + (t[2] - e[2]) * o
88
+ e[0] + (t[0] - e[0]) * n,
89
+ e[1] + (t[1] - e[1]) * n,
90
+ e[2] + (t[2] - e[2]) * n
91
91
  ];
92
92
  }
93
- function K(e, t, n) {
94
- const [o, i, a] = Jn(Te(e));
95
- return st(Qn(o, ct(i + n), ct(a + t)));
93
+ function Y(e, t, o) {
94
+ const [n, i, a] = oo(Re(e));
95
+ return ut(io(n, ht(i + o), ht(a + t)));
96
96
  }
97
- function Jn([e, t, n]) {
98
- const o = e / 255, i = t / 255, a = n / 255, l = Math.max(o, i, a), p = Math.min(o, i, a), c = (l + p) / 2;
97
+ function oo([e, t, o]) {
98
+ const n = e / 255, i = t / 255, a = o / 255, l = Math.max(n, i, a), p = Math.min(n, i, a), c = (l + p) / 2;
99
99
  if (l === p)
100
100
  return [0, 0, c];
101
101
  const u = l - p, d = c > 0.5 ? u / (2 - l - p) : u / (l + p);
102
- return [(l === o ? (i - a) / u + (i < a ? 6 : 0) : l === i ? (a - o) / u + 2 : (o - i) / u + 4) / 6, d, c];
102
+ return [(l === n ? (i - a) / u + (i < a ? 6 : 0) : l === i ? (a - n) / u + 2 : (n - i) / u + 4) / 6, d, c];
103
103
  }
104
- function Qn(e, t, n) {
104
+ function io(e, t, o) {
105
105
  if (t === 0)
106
- return [n * 255, n * 255, n * 255];
107
- const o = n < 0.5 ? n * (1 + t) : n + t - n * t, i = 2 * n - o;
106
+ return [o * 255, o * 255, o * 255];
107
+ const n = o < 0.5 ? o * (1 + t) : o + t - o * t, i = 2 * o - n;
108
108
  return [
109
- ot(i, o, e + 1 / 3) * 255,
110
- ot(i, o, e) * 255,
111
- ot(i, o, e - 1 / 3) * 255
109
+ at(i, n, e + 1 / 3) * 255,
110
+ at(i, n, e) * 255,
111
+ at(i, n, e - 1 / 3) * 255
112
112
  ];
113
113
  }
114
- function ot(e, t, n) {
115
- let o = n;
116
- return o < 0 && (o += 1), o > 1 && (o -= 1), o < 1 / 6 ? e + (t - e) * 6 * o : o < 1 / 2 ? t : o < 2 / 3 ? e + (t - e) * (2 / 3 - o) * 6 : e;
114
+ function at(e, t, o) {
115
+ let n = o;
116
+ return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e;
117
117
  }
118
- function ct(e) {
118
+ function ht(e) {
119
119
  return Math.max(0, Math.min(1, e));
120
120
  }
121
- const un = "suggest_share_on_socials";
122
- function eo(e) {
121
+ const bn = "suggest_share_on_socials";
122
+ function ao(e) {
123
123
  for (let t = e.length - 1; t >= 0; t -= 1) {
124
- const n = e[t];
125
- if (n.role !== "tool" || n.toolName !== un)
124
+ const o = e[t];
125
+ if (o.role !== "tool" || o.toolName !== bn)
126
126
  continue;
127
- const o = Mt(e, t, "assistant");
128
- if (!o)
127
+ const n = Ot(e, t, "assistant");
128
+ if (!n)
129
129
  return null;
130
- const i = Mt(e, o.index, "user");
130
+ const i = Ot(e, n.index, "user");
131
131
  return i ? {
132
- id: `share:${n.callId ?? n.id}`,
132
+ id: `share:${o.callId ?? o.id}`,
133
133
  userPrompt: i.content,
134
- assistantAnswer: o.content
134
+ assistantAnswer: n.content
135
135
  } : null;
136
136
  }
137
137
  return null;
138
138
  }
139
- async function to(e) {
140
- const t = await no(e);
139
+ async function ro(e) {
140
+ const t = await lo(e);
141
141
  if (!navigator.clipboard || typeof ClipboardItem > "u")
142
142
  throw new Error("Image copy is not supported in this browser. Download the screenshot instead.");
143
143
  await navigator.clipboard.write([new ClipboardItem({ [t.type || "image/png"]: t })]);
144
144
  }
145
- function Mt(e, t, n) {
146
- for (let o = t - 1; o >= 0; o -= 1) {
147
- const i = e[o];
148
- if (i.role === n && i.content.trim())
149
- return { index: o, content: i.content.trim() };
145
+ function Ot(e, t, o) {
146
+ for (let n = t - 1; n >= 0; n -= 1) {
147
+ const i = e[n];
148
+ if (i.role === o && i.content.trim())
149
+ return { index: n, content: i.content.trim() };
150
150
  }
151
151
  return null;
152
152
  }
153
- async function no(e) {
153
+ async function lo(e) {
154
154
  return await (await fetch(e)).blob();
155
155
  }
156
- const oo = "https://app.pluno.ai", io = "/api/product-agent/embed/active-users", ao = 1800, ro = 15e3, lo = 250, po = 1e3, so = 3e4;
157
- function co(e, t = {}) {
158
- let n = !1, o = null, i = null, a = null;
156
+ const po = "https://app.pluno.ai", so = "/api/product-agent/embed/active-users", co = 1800, uo = 15e3, go = 250, ho = 1e3, mo = 3e4;
157
+ function bo(e, t = {}) {
158
+ let o = !1, n = null, i = null, a = null;
159
159
  const l = () => {
160
160
  a !== null && (window.clearInterval(a), a = null);
161
161
  }, p = (d) => {
162
- n || (i !== null && window.clearTimeout(i), i = window.setTimeout(() => {
162
+ o || (i !== null && window.clearTimeout(i), i = window.setTimeout(() => {
163
163
  u();
164
- }, ho(d)));
164
+ }, _o(d)));
165
165
  }, c = (d) => {
166
- if (l(), o === null) {
167
- o = d, e(d);
166
+ if (l(), n === null) {
167
+ n = d, e(d);
168
168
  return;
169
169
  }
170
- const h = o, x = performance.now();
170
+ const g = n, S = performance.now();
171
171
  a = window.setInterval(() => {
172
- if (n) {
172
+ if (o) {
173
173
  l();
174
174
  return;
175
175
  }
176
- const y = Math.min(1, (performance.now() - x) / ao);
177
- o = Math.round(h + (d - h) * mo(y)), e(o), y >= 1 && (o = d, e(d), l());
178
- }, lo);
176
+ const f = Math.min(1, (performance.now() - S) / co);
177
+ n = Math.round(g + (d - g) * xo(f)), e(n), f >= 1 && (n = d, e(d), l());
178
+ }, go);
179
179
  }, u = async () => {
180
180
  try {
181
- const d = await uo(t);
182
- if (n)
181
+ const d = await fo(t);
182
+ if (o)
183
183
  return;
184
184
  c(d.count), p(d.refreshAfterMs);
185
185
  } catch {
186
- p(ro);
186
+ p(uo);
187
187
  }
188
188
  };
189
189
  return u(), () => {
190
- n = !0, i !== null && window.clearTimeout(i), l();
190
+ o = !0, i !== null && window.clearTimeout(i), l();
191
191
  };
192
192
  }
193
- async function uo(e) {
193
+ async function fo(e) {
194
194
  if (e.loader)
195
195
  return e.loader();
196
- const n = await (e.fetcher ?? fetch)(new URL(io, go(e.backendUrl ?? oo)).toString(), {
196
+ const o = await (e.fetcher ?? fetch)(new URL(so, wo(e.backendUrl ?? po)).toString(), {
197
197
  cache: "no-store",
198
198
  credentials: "omit"
199
199
  });
200
- if (!n.ok)
200
+ if (!o.ok)
201
201
  throw new Error("Failed to load active users");
202
- const o = await n.json(), i = zt(o.count), a = zt(o.refreshAfterMs ?? o.refresh_after_ms);
202
+ const n = await o.json(), i = Ft(n.count), a = Ft(n.refreshAfterMs ?? n.refresh_after_ms);
203
203
  if (i === null || a === null)
204
204
  throw new Error("Invalid active users response");
205
205
  return { count: i, refreshAfterMs: a };
206
206
  }
207
- function zt(e) {
207
+ function Ft(e) {
208
208
  return typeof e != "number" || !Number.isFinite(e) || e < 0 ? null : Math.round(e);
209
209
  }
210
- function go(e) {
210
+ function wo(e) {
211
211
  return e.endsWith("/") ? e : `${e}/`;
212
212
  }
213
- function ho(e) {
214
- return Math.min(so, Math.max(po, e));
213
+ function _o(e) {
214
+ return Math.min(mo, Math.max(ho, e));
215
215
  }
216
- function mo(e) {
216
+ function xo(e) {
217
217
  return e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2;
218
218
  }
219
- const gn = 100, bo = "product-agent:sdk-preview-socket-connect", fo = "product-agent:sdk-preview-socket-send", wo = "product-agent:sdk-preview-socket-close", _o = "product-agent:sdk-preview-socket-open", xo = "product-agent:sdk-preview-socket-message", yo = "product-agent:sdk-preview-socket-error", vo = "product-agent:sdk-preview-socket-closed", Bt = "product-agent:sdk-preview-socket-id", Co = "data-pluno-sdk-preview-channel", Eo = "product-agent:preview-diagnostic", hn = "pluno.productAgent.sharePromptsDisabled", We = 10, So = 10 * 1024 * 1024, mn = /* @__PURE__ */ new Set([
220
- "image/png",
221
- "image/jpeg",
222
- "image/webp",
223
- "image/gif",
224
- "application/pdf"
225
- ]), ko = Array.from(
226
- mn
227
- ).join(","), Lo = 3, Ao = "No recent chats for this page yet.", Z = {
219
+ const fn = 100, vo = "product-agent:sdk-preview-socket-connect", yo = "product-agent:sdk-preview-socket-send", Co = "product-agent:sdk-preview-socket-close", So = "product-agent:sdk-preview-socket-open", Eo = "product-agent:sdk-preview-socket-message", ko = "product-agent:sdk-preview-socket-error", Lo = "product-agent:sdk-preview-socket-closed", Ht = "product-agent:sdk-preview-socket-id", Po = "data-pluno-sdk-preview-channel", Io = "product-agent:preview-diagnostic", wn = "pluno.productAgent.sharePromptsDisabled", Ao = 3, No = "No recent chats for this page yet.", Z = {
228
220
  launcherLabel: "Ask for anything...",
229
221
  accentColor: "#7c3aed",
230
222
  colorScheme: "light",
@@ -232,7 +224,7 @@ const gn = 100, bo = "product-agent:sdk-preview-socket-connect", fo = "product-a
232
224
  scribbleStyle: !1,
233
225
  position: "bottom-right",
234
226
  movableLauncher: !1
235
- }, Po = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', Ot = "pluno-pa-scribble-font", bn = 190, fn = 41, Ut = 22, Io = 16, To = 24, No = 1, Do = 48, Ro = 420, Mo = 520, zo = 0.24, Bo = 680, Oo = 800, Uo = 0.76, W = 8, ut = 50, wn = "http://www.w3.org/2000/svg", Ft = 26, Ht = 8, Fo = 36, Gt = [
227
+ }, To = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', Wt = "pluno-pa-scribble-font", _n = 190, xn = 41, Gt = 22, Do = 16, Ro = 24, Mo = 1, zo = 48, Bo = 420, Uo = 520, Oo = 0.24, Fo = 680, Ho = 800, Wo = 0.76, W = 8, mt = 50, vn = "http://www.w3.org/2000/svg", $t = 26, qt = 8, Go = 36, jt = [
236
228
  {
237
229
  ellipseCx: "17.5",
238
230
  ellipseCy: "24.5",
@@ -269,12 +261,12 @@ const gn = 100, bo = "product-agent:sdk-preview-socket-connect", fo = "product-a
269
261
  path: "M18.7 26.8 C21 11.2, 7.1 1.6, 6.3 18.1",
270
262
  pathStrokeWidth: "2.45"
271
263
  }
272
- ], Ho = 11, Go = 13, Wt = 4, Wo = 10, $o = 40, qo = "movable-launcher-position-v2", _n = "pluno-pa-widget-styles", xn = "data-pluno-pa-widget-styles";
273
- let $t = 0;
274
- function jo(e) {
264
+ ], $o = 11, qo = 13, Vt = 4, jo = 10, Vo = 40, Ko = "movable-launcher-position-v2", yn = "pluno-pa-widget-styles", Cn = "data-pluno-pa-widget-styles";
265
+ let Kt = 0;
266
+ function Yo(e) {
275
267
  return (t) => new oe(t, e);
276
268
  }
277
- async function Vo(e = {}) {
269
+ async function Xo(e = {}) {
278
270
  const t = {
279
271
  launcherLabel: e.launcherLabel ?? Z.launcherLabel,
280
272
  accentColor: e.accentColor ?? Z.accentColor,
@@ -293,6 +285,7 @@ async function Vo(e = {}) {
293
285
  restorePersistedState: e.restorePersistedState,
294
286
  expectedPersistedSessionId: e.expectedPersistedSessionId,
295
287
  webSocketFactory: e.webSocketFactory,
288
+ prepareAttachmentUpload: e.prepareAttachmentUpload,
296
289
  loginRequired: e.loginRequired === !0,
297
290
  loginButtonLabel: e.loginButtonLabel ?? "Log in to Pluno",
298
291
  loginUrl: e.loginUrl,
@@ -311,6 +304,7 @@ async function Vo(e = {}) {
311
304
  sdkPreviewChannelId: e.sdkPreviewChannelId,
312
305
  initialDisplayState: e.initialDisplayState,
313
306
  onDisplayStateChange: e.onDisplayStateChange,
307
+ onPanelOpenChange: e.onPanelOpenChange,
314
308
  showLauncherMinimizeButton: e.showLauncherMinimizeButton === !0
315
309
  };
316
310
  X(
@@ -328,41 +322,41 @@ async function Vo(e = {}) {
328
322
  initialStarterPromptCount: t.initialStarterPrompts?.length ?? 0
329
323
  }
330
324
  );
331
- const n = document.createElement("div");
332
- n.className = "pluno-pa-widget-host", n.setAttribute("data-pluno-product-agent-ui", "widget"), t.sdkPreviewChannelId && n.setAttribute(
333
- Co,
325
+ const o = document.createElement("div");
326
+ o.className = "pluno-pa-widget-host", o.setAttribute("data-pluno-product-agent-ui", "widget"), t.sdkPreviewChannelId && o.setAttribute(
327
+ Po,
334
328
  t.sdkPreviewChannelId
335
329
  );
336
- const o = n.attachShadow({ mode: "open" }), i = document.createElement("div");
330
+ const n = o.attachShadow({ mode: "open" }), i = document.createElement("div");
337
331
  i.className = `pluno-pa-widget pluno-pa-widget--${t.position}`, i.setAttribute("data-pluno-product-agent-ui-root", "widget");
338
- let a = qt(
332
+ let a = Yt(
339
333
  t.accentColor,
340
334
  t.scribbleStyle
341
335
  );
342
- ui(
336
+ bi(
343
337
  i,
344
338
  t.launcherLabel,
345
339
  a,
346
340
  t.movableLauncher,
347
341
  t.showLauncherMinimizeButton
348
- ), o.appendChild(i);
342
+ ), n.appendChild(i);
349
343
  const l = ca(t);
350
344
  let p = t.movableLauncher ? l.launcherPosition : null, c = p !== null;
351
- i.classList.add(`pluno-pa-widget--${t.colorScheme}`), t.scribbleStyle && i.classList.add("pluno-pa-widget--scribble"), t.initialDisplayState === "minimized" && (i.classList.add("pluno-pa-widget--minimized"), me(
345
+ i.classList.add(`pluno-pa-widget--${t.colorScheme}`), t.scribbleStyle && i.classList.add("pluno-pa-widget--scribble"), t.initialDisplayState === "minimized" && (i.classList.add("pluno-pa-widget--minimized"), fe(
352
346
  i,
353
- it(
347
+ rt(
354
348
  i,
355
349
  p,
356
350
  t.position
357
351
  )
358
- )), rn(o, t.accentColor), jt(i, a, {
352
+ )), dn(n, t.accentColor), Xt(i, a, {
359
353
  accentColor: t.accentColor,
360
354
  colorScheme: t.colorScheme,
361
355
  fontFamily: t.fontFamily,
362
356
  scribbleStyle: t.scribbleStyle
363
357
  });
364
358
  const u = await da(), d = u.ownerDocument;
365
- u.appendChild(n), X(
359
+ u.appendChild(o), X(
366
360
  "web-sdk.widget",
367
361
  "Applied initial widget appearance",
368
362
  {
@@ -372,70 +366,70 @@ async function Vo(e = {}) {
372
366
  cssAccent: i.style.getPropertyValue("--pluno-pa-accent")
373
367
  }
374
368
  );
375
- const h = i.querySelector(
369
+ const g = i.querySelector(
376
370
  ".pluno-pa-widget__launcher"
377
- ), x = i.querySelector(
371
+ ), S = i.querySelector(
378
372
  ".pluno-pa-widget__launcher-drag-handle"
379
- ), y = i.querySelector(
373
+ ), f = i.querySelector(
380
374
  ".pluno-pa-widget__launcher-input"
381
- ), P = i.querySelector(
375
+ ), F = i.querySelector(
382
376
  ".pluno-pa-widget__launcher-minimize"
383
- ), T = i.querySelector(".pluno-pa-widget__panel"), f = i.querySelector(
377
+ ), k = i.querySelector(".pluno-pa-widget__panel"), x = i.querySelector(
384
378
  ".pluno-pa-widget__close"
385
- ), E = i.querySelector(
379
+ ), v = i.querySelector(
386
380
  ".pluno-pa-widget__composer"
387
- ), g = i.querySelector(
381
+ ), h = i.querySelector(
388
382
  ".pluno-pa-widget__attachment-error"
389
- ), S = i.querySelector(
383
+ ), I = i.querySelector(
390
384
  ".pluno-pa-widget__billing-status"
391
- ), k = i.querySelector(
385
+ ), T = i.querySelector(
392
386
  ".pluno-pa-widget__attachments"
393
- ), R = i.querySelector(
387
+ ), P = i.querySelector(
394
388
  ".pluno-pa-widget__attachment-input"
395
- ), Ce = i.querySelector(
389
+ ), ke = i.querySelector(
396
390
  ".pluno-pa-widget__attach"
397
391
  ), b = i.querySelector(
398
392
  ".pluno-pa-widget__input"
399
- ), ie = i.querySelector(
393
+ ), D = i.querySelector(
400
394
  ".pluno-pa-widget__send"
401
- ), ae = i.querySelector(
395
+ ), de = i.querySelector(
402
396
  ".pluno-pa-widget__top-actions"
403
- ), _ = i.querySelector(
397
+ ), ce = i.querySelector(
404
398
  ".pluno-pa-widget__history"
405
- ), N = i.querySelector(
399
+ ), we = i.querySelector(
406
400
  ".pluno-pa-widget__history-panel"
407
- ), F = i.querySelector(
401
+ ), G = i.querySelector(
408
402
  ".pluno-pa-widget__history-list"
409
- ), H = i.querySelector(
403
+ ), ie = i.querySelector(
410
404
  ".pluno-pa-widget__history-close"
411
- ), L = i.querySelector(
405
+ ), _ = i.querySelector(
412
406
  ".pluno-pa-widget__history-status"
413
- ), I = i.querySelector(
407
+ ), M = i.querySelector(
414
408
  ".pluno-pa-widget__timeline-jump"
415
- ), be = i.querySelector(
409
+ ), ae = i.querySelector(
416
410
  ".pluno-pa-widget__active-users-counter"
417
- ), A = i.querySelector(
411
+ ), L = i.querySelector(
418
412
  ".pluno-pa-widget__timeline"
419
- ), je = i.querySelector(
413
+ ), A = i.querySelector(
420
414
  ".pluno-pa-widget__timeline-bottom-sentinel"
421
415
  );
422
- if (!h || !y || !T || !f || !E || !g || !S || !k || !R || !Ce || !b || !ie || !ae || !_ || !N || !F || !H || !L || !I || !be || !A || !je)
416
+ if (!g || !f || !k || !x || !v || !h || !I || !T || !P || !ke || !b || !D || !de || !ce || !we || !G || !ie || !_ || !M || !ae || !L || !A)
423
417
  throw new Error("Failed to mount Pluno widget");
424
- if (t.movableLauncher && !x)
418
+ if (t.movableLauncher && !S)
425
419
  throw new Error("Failed to mount Pluno widget drag handle");
426
- Zt(y), Zt(b);
427
- let z = [], te = null;
428
- const fe = () => {
429
- Ti(
430
- k,
431
- z,
420
+ tn(f), tn(b);
421
+ let y = [], B = null;
422
+ const _e = () => {
423
+ Ri(
424
+ T,
425
+ y,
432
426
  (r) => {
433
- z = z.filter(
434
- (s, C) => C !== r
435
- ), fe(), O(w.getState()), $();
427
+ y = y.filter(
428
+ (s, E) => E !== r
429
+ ), _e(), O(w.getState()), $();
436
430
  }
437
431
  );
438
- }, Mn = t.loginRequired || t.signupRequired || t.token || t.webSocketFactory ? void 0 : t.tokenProvider ?? (async () => {
432
+ }, On = t.loginRequired || t.signupRequired || t.token || t.webSocketFactory ? void 0 : t.tokenProvider ?? (async () => {
439
433
  if (!t.tokenEndpoint)
440
434
  throw new Error("Pluno widget requires token or tokenEndpoint");
441
435
  const r = await fetch(t.tokenEndpoint, {
@@ -453,11 +447,11 @@ async function Vo(e = {}) {
453
447
  if (!s.token)
454
448
  throw new Error("Pluno token endpoint did not return a token");
455
449
  return s.token;
456
- }), zn = window.fetch.bind(window);
450
+ }), Fn = window.fetch.bind(window);
457
451
  let w;
458
- w = await Vn.init({
452
+ w = await Jn.init({
459
453
  token: t.token,
460
- tokenProvider: Mn,
454
+ tokenProvider: On,
461
455
  backendUrl: t.backendUrl,
462
456
  metadata: () => ({
463
457
  ...t.metadata ?? {},
@@ -468,56 +462,57 @@ async function Vo(e = {}) {
468
462
  restorePersistedState: t.restorePersistedState,
469
463
  expectedPersistedSessionId: t.expectedPersistedSessionId,
470
464
  webSocketFactory: t.webSocketFactory,
465
+ prepareAttachmentUpload: t.prepareAttachmentUpload,
471
466
  autoConnect: t.loginRequired || t.signupRequired ? !1 : void 0
472
467
  });
473
- const Ve = new Set(l.openToolGroupKeys), we = new Set(
468
+ const Ke = new Set(l.openToolGroupKeys), xe = new Set(
474
469
  l.seenShareCandidateIds
475
- ), Ne = new Set(we);
476
- let Ye = l.sharePromptsDisabled || await ua(t), j = null, De = !1, de = !1, ce = {
470
+ ), Me = new Set(xe);
471
+ let Ye = l.sharePromptsDisabled || await ua(t), j = null, ze = !1, ue = !1, ge = {
477
472
  enabled: !0
478
- }, ue = 0, _t = "", re = !1, ne = !1, le = [], Ke = null, Ee = null;
473
+ }, he = 0, Ct = "", re = !1, ne = !1, le = [], Xe = null, Le = null;
479
474
  const V = (r, s) => {
480
- ce = { enabled: r, reason: s };
481
- }, Y = () => {
482
- I.hidden = !0;
483
- }, Bn = () => {
484
- I.hidden = !1;
485
- }, On = (r = "jump") => {
486
- V(!0, r), Y(), Ie(A, () => ce.enabled), ue = A.scrollTop;
487
- }, ge = () => {
488
- if (_.hidden = t.loginRequired, N.hidden = !re, _.setAttribute("aria-expanded", String(re)), F.classList.toggle(
475
+ ge = { enabled: r, reason: s };
476
+ }, K = () => {
477
+ M.hidden = !0;
478
+ }, Hn = () => {
479
+ M.hidden = !1;
480
+ }, Wn = (r = "jump") => {
481
+ V(!0, r), K(), De(L, () => ge.enabled), he = L.scrollTop;
482
+ }, me = () => {
483
+ if (ce.hidden = t.loginRequired, we.hidden = !re, ce.setAttribute("aria-expanded", String(re)), G.classList.toggle(
489
484
  "pluno-pa-widget__history-list--center",
490
485
  ne && le.length === 0
491
- ), F.replaceChildren(), ne && le.length === 0) {
486
+ ), G.replaceChildren(), ne && le.length === 0) {
492
487
  const r = document.createElement("p");
493
- r.className = "pluno-pa-widget__history-loading", r.textContent = "Loading...", F.appendChild(r);
488
+ r.className = "pluno-pa-widget__history-loading", r.textContent = "Loading...", G.appendChild(r);
494
489
  }
495
490
  for (const r of le) {
496
491
  const s = document.createElement("button");
497
492
  s.type = "button", s.className = "pluno-pa-widget__history-item", s.disabled = ne;
498
- const C = document.createElement("span");
499
- C.className = "pluno-pa-widget__history-item-title", C.textContent = si(r);
500
- const B = document.createElement("time");
501
- B.className = "pluno-pa-widget__history-time", B.dateTime = r.lastActiveAt, B.textContent = ci(
493
+ const E = document.createElement("span");
494
+ E.className = "pluno-pa-widget__history-item-title", E.textContent = gi(r);
495
+ const z = document.createElement("time");
496
+ z.className = "pluno-pa-widget__history-time", z.dateTime = r.lastActiveAt, z.textContent = mi(
502
497
  r.lastActiveAt,
503
498
  Date.now()
504
499
  );
505
- const D = document.createElement("small");
506
- D.className = "pluno-pa-widget__history-path", D.textContent = di(r), s.append(C, B, D), s.addEventListener("click", () => {
507
- re = !1, Ee = null, ge(), V(!0, "newSession"), Y(), w.loadSession(r.id), O(w.getState());
508
- }), F.appendChild(s);
500
+ const N = document.createElement("small");
501
+ N.className = "pluno-pa-widget__history-path", N.textContent = hi(r), s.append(E, z, N), s.addEventListener("click", () => {
502
+ re = !1, Le = null, me(), V(!0, "newSession"), K(), w.loadSession(r.id), O(w.getState());
503
+ }), G.appendChild(s);
509
504
  }
510
505
  if (ne && le.length > 0) {
511
506
  const r = document.createElement("p");
512
- r.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", r.textContent = "Loading...", F.appendChild(r);
507
+ r.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", r.textContent = "Loading...", G.appendChild(r);
513
508
  }
514
- L.textContent = Ee ?? (!ne && le.length === 0 ? "No recent chats for this page yet." : ""), L.hidden = L.textContent.length === 0;
515
- }, xt = async (r) => {
509
+ _.textContent = Le ?? (!ne && le.length === 0 ? "No recent chats for this page yet." : ""), _.hidden = _.textContent.length === 0;
510
+ }, St = async (r) => {
516
511
  if (!ne) {
517
- ne = !0, Ee = null, ge();
512
+ ne = !0, Le = null, me();
518
513
  try {
519
514
  const s = await w.listSessions({ cursor: r, limit: 20 });
520
- le = r ? [...le, ...s.sessions] : s.sessions, Ke = s.nextCursor;
515
+ le = r ? [...le, ...s.sessions] : s.sessions, Xe = s.nextCursor;
521
516
  } catch (s) {
522
517
  X(
523
518
  "web-sdk.widget",
@@ -525,60 +520,60 @@ async function Vo(e = {}) {
525
520
  {
526
521
  message: s instanceof Error ? s.message : String(s)
527
522
  }
528
- ), Ee = Ao;
523
+ ), Le = No;
529
524
  } finally {
530
- ne = !1, ge();
525
+ ne = !1, me();
531
526
  }
532
527
  }
533
- }, Un = () => {
534
- !Ke || ne || F.scrollHeight - F.scrollTop - F.clientHeight <= 24 && xt(Ke);
535
- }, Fn = () => {
536
- De || typeof document > "u" || (rn(o, t.accentColor), n.isConnected || d.body?.appendChild(n));
537
- }, yt = new MutationObserver(Fn);
538
- yt.observe(d.documentElement, {
528
+ }, Gn = () => {
529
+ !Xe || ne || G.scrollHeight - G.scrollTop - G.clientHeight <= 24 && St(Xe);
530
+ }, $n = () => {
531
+ ze || typeof document > "u" || (dn(n, t.accentColor), o.isConnected || d.body?.appendChild(o));
532
+ }, Et = new MutationObserver($n);
533
+ Et.observe(d.documentElement, {
539
534
  childList: !0,
540
535
  subtree: !0
541
536
  });
542
- const Xe = (r = !0) => {
543
- const s = $e(i, r);
544
- return gt(
537
+ const Ze = (r = !0) => {
538
+ const s = je(i, r);
539
+ return bt(
545
540
  i,
546
- p ? vn(p, s) : Qo(
541
+ p ? En(p, s) : ni(
547
542
  i,
548
543
  t.position,
549
544
  s
550
545
  ),
551
546
  s
552
547
  );
553
- }, G = () => {
548
+ }, H = () => {
554
549
  ha(t, {
555
550
  isOpen: i.classList.contains("pluno-pa-widget--open"),
556
551
  composerValue: b.value,
557
- openToolGroupKeys: [...Ve],
552
+ openToolGroupKeys: [...Ke],
558
553
  launcherPosition: c ? p : null,
559
- seenShareCandidateIds: [...we].slice(
560
- -gn
554
+ seenShareCandidateIds: [...xe].slice(
555
+ -fn
561
556
  ),
562
557
  sharePromptsDisabled: Ye
563
558
  });
564
- }, Re = (r) => {
559
+ }, Be = (r) => {
565
560
  t.onDisplayStateChange?.(r);
566
- }, Se = (r, s = !0) => {
561
+ }, Pe = (r, s = !0) => {
567
562
  if (r === "shown") {
568
- i.classList.remove("pluno-pa-widget--minimized"), h.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") && ke(!1), s && Re("shown");
563
+ i.classList.remove("pluno-pa-widget--minimized"), g.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") && Ie(!1), s && Be("shown");
569
564
  return;
570
565
  }
571
- j !== null && (window.clearTimeout(j), j = null), i.classList.remove("pluno-pa-widget--open"), i.classList.remove("pluno-pa-widget--closing"), i.classList.add("pluno-pa-widget--minimized"), h.hidden = !1, T.hidden = !0, f.hidden = !0, h.tabIndex = 0, b.value = "", me(
566
+ j !== null && (window.clearTimeout(j), j = null), i.classList.remove("pluno-pa-widget--open"), i.classList.remove("pluno-pa-widget--closing"), i.classList.add("pluno-pa-widget--minimized"), g.hidden = !1, k.hidden = !0, x.hidden = !0, g.tabIndex = 0, b.value = "", fe(
572
567
  i,
573
- it(
568
+ rt(
574
569
  i,
575
570
  p,
576
571
  t.position
577
572
  )
578
- ), Yt(i), G(), s && Re("minimized");
579
- }, he = (r, s = {}) => {
580
- ri(r, {
581
- debugVersion: qo,
573
+ ), Jt(i), H(), s && Be("minimized");
574
+ }, be = (r, s = {}) => {
575
+ si(r, {
576
+ debugVersion: Ko,
582
577
  launcherPosition: p,
583
578
  rootClasses: i.className,
584
579
  rootStyle: {
@@ -587,35 +582,35 @@ async function Vo(e = {}) {
587
582
  right: i.style.right,
588
583
  bottom: i.style.bottom
589
584
  },
590
- rootRect: at(i),
591
- launcherRect: at(h),
592
- panelRect: at(T),
593
- viewport: Q(),
594
- panelHidden: T.hidden,
595
- closeHidden: f.hidden,
585
+ rootRect: lt(i),
586
+ launcherRect: lt(g),
587
+ panelRect: lt(k),
588
+ viewport: ee(),
589
+ panelHidden: k.hidden,
590
+ closeHidden: x.hidden,
596
591
  ...s
597
592
  });
598
- }, ke = (r = !0) => {
593
+ }, Ie = (r = !0) => {
599
594
  if (!p)
600
- return me(i, null), Xe(r);
601
- const s = Xe(r);
602
- return me(i, s), he("Applied stored closed launcher position", {
595
+ return fe(i, null), Ze(r);
596
+ const s = Ze(r);
597
+ return fe(i, s), be("Applied stored closed launcher position", {
603
598
  visibleLauncherPosition: s
604
599
  }), s;
605
- }, vt = (r, s) => {
600
+ }, kt = (r, s) => {
606
601
  if (!r || !s) {
607
- Yt(i);
602
+ Jt(i);
608
603
  return;
609
604
  }
610
- ai(i, {
605
+ pi(i, {
611
606
  x: r.x - s.x,
612
607
  y: r.y - s.y
613
608
  });
614
- }, Ct = () => {
609
+ }, Lt = () => {
615
610
  if (i.classList.contains("pluno-pa-widget--minimized")) {
616
- me(
611
+ fe(
617
612
  i,
618
- it(
613
+ rt(
619
614
  i,
620
615
  p,
621
616
  t.position
@@ -623,127 +618,127 @@ async function Vo(e = {}) {
623
618
  );
624
619
  return;
625
620
  }
626
- const r = ke();
621
+ const r = Ie();
627
622
  if (i.classList.contains("pluno-pa-widget--open") || i.classList.contains("pluno-pa-widget--closing")) {
628
- const s = Vt(
623
+ const s = Zt(
629
624
  i,
630
625
  r,
631
626
  t.position
632
627
  );
633
- vt(s, r), he(
628
+ kt(s, r), be(
634
629
  "Applied open panel position after viewport resize",
635
630
  { openPanelPosition: s }
636
631
  );
637
- } else p && he(
632
+ } else p && be(
638
633
  "Applied visible launcher position after viewport resize",
639
634
  { visibleLauncherPosition: r }
640
635
  );
641
636
  };
642
- let Et = () => {
637
+ let Pt = () => {
643
638
  };
644
- window.addEventListener("resize", Ct), t.movableLauncher && x ? (ke(), Et = Jo({
639
+ window.addEventListener("resize", Lt), t.movableLauncher && S ? (Ie(), Pt = ti({
645
640
  root: i,
646
- launcher: h,
647
- launcherDragHandle: x,
648
- getPosition: () => Xe(),
641
+ launcher: g,
642
+ launcherDragHandle: S,
643
+ getPosition: () => Ze(),
649
644
  setPosition: (r) => {
650
- const s = r, C = $e(i), B = gt(
645
+ const s = r, E = je(i), z = bt(
651
646
  i,
652
647
  r,
653
- C
648
+ E
654
649
  );
655
- p = ti(
656
- B,
657
- C
658
- ), me(i, B), he("Dragging closed launcher", {
650
+ p = ii(
651
+ z,
652
+ E
653
+ ), fe(i, z), be("Dragging closed launcher", {
659
654
  requestedPosition: s
660
655
  });
661
656
  },
662
657
  persist: () => {
663
- c = !0, G(), he("Persisted closed launcher drag position");
658
+ c = !0, H(), be("Persisted closed launcher drag position");
664
659
  }
665
- })) : me(i, null);
666
- let Ze = !1;
667
- const St = async () => {
668
- if (!(!t.billingStatusLoader || Ze)) {
669
- Ze = !0;
660
+ })) : fe(i, null);
661
+ let Je = !1;
662
+ const It = async () => {
663
+ if (!(!t.billingStatusLoader || Je)) {
664
+ Je = !0;
670
665
  try {
671
666
  const r = await t.billingStatusLoader();
672
- Qt(
667
+ on(
673
668
  t.billingStatus,
674
669
  r,
675
670
  w.getState().lastErrorCode
676
- ) && (t.billingStatus = r, pt(
677
- S,
671
+ ) && (t.billingStatus = r, dt(
672
+ I,
678
673
  t.billingStatus,
679
674
  w.getState().lastErrorCode
680
675
  ), $());
681
676
  } finally {
682
- Ze = !1;
677
+ Je = !1;
683
678
  }
684
679
  }
685
680
  }, pe = (r = "", s = !0) => {
686
- St(), j !== null && (window.clearTimeout(j), j = null), Se("shown", !1), T.hidden = !1, f.hidden = !1, i.classList.remove("pluno-pa-widget--closing");
687
- const C = ke(), B = Vt(
681
+ It(), j !== null && (window.clearTimeout(j), j = null), Pe("shown", !1), k.hidden = !1, x.hidden = !1, i.classList.remove("pluno-pa-widget--closing");
682
+ const E = Ie(), z = Zt(
688
683
  i,
689
- C,
684
+ E,
690
685
  t.position
691
686
  );
692
- if (vt(B, C), he("Opening launcher at clamped open panel position", {
693
- openPanelPosition: B,
694
- visibleLauncherPosition: C
695
- }), V(!0, "open"), Y(), !s) {
696
- i.classList.add("pluno-pa-widget--open"), h.hidden = !0, r && (b.value = r, Pe(b)), Ie(A, () => ce.enabled), ue = A.scrollTop, b.focus(), b.setSelectionRange(b.value.length, b.value.length), G(), Re("shown");
687
+ if (kt(z, E), be("Opening launcher at clamped open panel position", {
688
+ openPanelPosition: z,
689
+ visibleLauncherPosition: E
690
+ }), V(!0, "open"), K(), !s) {
691
+ i.classList.add("pluno-pa-widget--open"), g.hidden = !0, r && (b.value = r, Te(b)), De(L, () => ge.enabled), he = L.scrollTop, b.focus(), b.setSelectionRange(b.value.length, b.value.length), H(), Be("shown"), t.onPanelOpenChange?.(!0);
697
692
  return;
698
693
  }
699
694
  window.requestAnimationFrame(() => {
700
- i.classList.add("pluno-pa-widget--open"), r && (b.value = r, Pe(b)), Ie(A, () => ce.enabled), ue = A.scrollTop, b.focus(), b.setSelectionRange(b.value.length, b.value.length), G(), Re("shown"), j = window.setTimeout(() => {
701
- h.hidden = !0, Ie(A, () => ce.enabled), ue = A.scrollTop;
695
+ i.classList.add("pluno-pa-widget--open"), r && (b.value = r, Te(b)), De(L, () => ge.enabled), he = L.scrollTop, b.focus(), b.setSelectionRange(b.value.length, b.value.length), H(), Be("shown"), t.onPanelOpenChange?.(!0), j = window.setTimeout(() => {
696
+ g.hidden = !0, De(L, () => ge.enabled), he = L.scrollTop;
702
697
  }, 220);
703
698
  });
704
- }, Hn = () => {
705
- j !== null && (window.clearTimeout(j), j = null), h.hidden = !1, p && (ke(!1), he("Closing launcher at stored position")), i.classList.remove("pluno-pa-widget--open"), i.classList.add("pluno-pa-widget--closing"), G(), j = window.setTimeout(() => {
706
- T.hidden = !0, f.hidden = !0, i.classList.remove("pluno-pa-widget--closing");
699
+ }, qn = () => {
700
+ j !== null && (window.clearTimeout(j), j = null), g.hidden = !1, p && (Ie(!1), be("Closing launcher at stored position")), i.classList.remove("pluno-pa-widget--open"), i.classList.add("pluno-pa-widget--closing"), H(), t.onPanelOpenChange?.(!1), j = window.setTimeout(() => {
701
+ k.hidden = !0, x.hidden = !0, i.classList.remove("pluno-pa-widget--closing");
707
702
  }, 220);
708
703
  };
709
- h.addEventListener("submit", (r) => {
710
- r.preventDefault(), pe(y.value), y.value = "";
711
- }), x?.addEventListener("click", (r) => {
704
+ g.addEventListener("submit", (r) => {
705
+ r.preventDefault(), pe(f.value), f.value = "";
706
+ }), S?.addEventListener("click", (r) => {
712
707
  r.preventDefault(), r.stopPropagation();
713
- }), h.addEventListener("click", (r) => {
714
- r.target === y && !x || (pe(y.value), y.value = "");
715
- }), y.addEventListener("focus", () => {
716
- pe(y.value), y.value = "";
717
- }), y.addEventListener("input", () => {
718
- if (!y.value)
708
+ }), g.addEventListener("click", (r) => {
709
+ r.target === f && !S || (pe(f.value), f.value = "");
710
+ }), f.addEventListener("focus", () => {
711
+ pe(f.value), f.value = "";
712
+ }), f.addEventListener("input", () => {
713
+ if (!f.value)
719
714
  return;
720
- const r = y.value;
721
- pe(r), y.value = "";
722
- }), h.addEventListener("keydown", (r) => {
715
+ const r = f.value;
716
+ pe(r), f.value = "";
717
+ }), g.addEventListener("keydown", (r) => {
723
718
  !i.classList.contains("pluno-pa-widget--minimized") || r.key !== "Enter" && r.key !== " " || (r.preventDefault(), pe());
724
- }), P?.addEventListener("pointerdown", (r) => {
719
+ }), F?.addEventListener("pointerdown", (r) => {
725
720
  r.stopPropagation();
726
- }), P?.addEventListener("click", (r) => {
727
- r.preventDefault(), r.stopPropagation(), Se("minimized");
728
- }), f.addEventListener("click", Hn), A.addEventListener("scroll", () => {
729
- A.scrollTop < ue - 1 && V(!1, "userScroll"), ue = A.scrollTop;
730
- }), I.addEventListener("click", () => {
731
- On();
721
+ }), F?.addEventListener("click", (r) => {
722
+ r.preventDefault(), r.stopPropagation(), Pe("minimized");
723
+ }), x.addEventListener("click", qn), L.addEventListener("scroll", () => {
724
+ L.scrollTop < he - 1 && V(!1, "userScroll"), he = L.scrollTop;
725
+ }), M.addEventListener("click", () => {
726
+ Wn();
732
727
  });
733
- const kt = typeof IntersectionObserver > "u" ? null : new IntersectionObserver(
728
+ const At = typeof IntersectionObserver > "u" ? null : new IntersectionObserver(
734
729
  ([r]) => {
735
- r?.isIntersecting && (V(!0, "bottom"), Y());
730
+ r?.isIntersecting && (V(!0, "bottom"), K());
736
731
  },
737
- { root: A, threshold: 0 }
732
+ { root: L, threshold: 0 }
738
733
  );
739
- kt?.observe(je);
740
- const Me = () => t.loginRequired || t.signupRequired, Lt = () => {
741
- const r = Me();
742
- y.readOnly = r, y.placeholder = r ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : t.launcherLabel, b.placeholder = r ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : Z.launcherLabel, E.hidden = r;
734
+ At?.observe(A);
735
+ const Ue = () => t.loginRequired || t.signupRequired, Nt = () => {
736
+ const r = Ue();
737
+ f.readOnly = r, f.placeholder = r ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : t.launcherLabel, b.placeholder = r ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : Z.launcherLabel, v.hidden = r;
743
738
  }, $ = () => {
744
- ie.disabled = J(t.billingStatus) || !w.getState().isThinking && b.value.trim().length === 0 && z.length === 0, Ce.disabled = Me() || J(t.billingStatus);
739
+ D.disabled = Q(t.billingStatus) || !w.getState().isThinking && b.value.trim().length === 0 && y.length === 0, ke.disabled = Ue() || Q(t.billingStatus);
745
740
  };
746
- Lt(), E.addEventListener("submit", (r) => {
741
+ Nt(), v.addEventListener("submit", (r) => {
747
742
  if (r.preventDefault(), t.loginRequired) {
748
743
  t.onLoginClick?.();
749
744
  return;
@@ -752,59 +747,55 @@ async function Vo(e = {}) {
752
747
  t.onSignupClick?.();
753
748
  return;
754
749
  }
755
- J(t.billingStatus) || (de = !0, V(!0, "send"), Y(), z = rt(
750
+ Q(t.billingStatus) || (ue = !0, V(!0, "send"), K(), y = pt(
756
751
  w,
757
752
  b,
758
- z
759
- ), fe(), $());
753
+ y
754
+ ), _e(), $());
760
755
  });
761
- let Le = 0;
762
- const Gn = () => {
763
- Le = 0, i.classList.remove("pluno-pa-widget--drag-over");
764
- }, At = (r) => {
765
- te !== null && window.clearTimeout(te), g.textContent = r, g.hidden = !1, te = window.setTimeout(() => {
766
- g.textContent = "", g.hidden = !0, te = null;
756
+ let Ae = 0;
757
+ const jn = () => {
758
+ Ae = 0, i.classList.remove("pluno-pa-widget--drag-over");
759
+ }, Tt = (r) => {
760
+ B !== null && window.clearTimeout(B), h.textContent = r, h.hidden = !1, B = window.setTimeout(() => {
761
+ h.textContent = "", h.hidden = !0, B = null;
767
762
  }, 3e3);
768
- }, Wn = () => {
769
- te !== null && (window.clearTimeout(te), te = null), g.textContent = "", g.hidden = !0;
770
- }, Pt = async (r) => {
763
+ }, Vn = () => {
764
+ B !== null && (window.clearTimeout(B), B = null), h.textContent = "", h.hidden = !0;
765
+ }, Dt = async (r) => {
771
766
  if (r.length === 0)
772
767
  return;
773
- const s = await Mi(r);
774
- if (z.length + s.length > We)
775
- throw new Error(
776
- `Attach up to ${We} files per message.`
777
- );
778
- z = [...z, ...s], fe(), Wn(), $(), O(w.getState()), i.classList.contains("pluno-pa-widget--open") || pe();
768
+ const s = Bi(w, r);
769
+ y = [...y, ...s], _e(), Vn(), $(), O(w.getState()), i.classList.contains("pluno-pa-widget--open") || pe();
779
770
  };
780
- Ce.addEventListener("click", () => {
781
- t.loginRequired || J(t.billingStatus) || R.click();
782
- }), R.addEventListener("change", () => {
783
- const r = Array.from(R.files ?? []);
784
- R.value = "", Pt(r).catch((s) => {
785
- At(
771
+ ke.addEventListener("click", () => {
772
+ t.loginRequired || Q(t.billingStatus) || P.click();
773
+ }), P.addEventListener("change", () => {
774
+ const r = Array.from(P.files ?? []);
775
+ P.value = "", Dt(r).catch((s) => {
776
+ Tt(
786
777
  s instanceof Error ? s.message : "Failed to attach file"
787
778
  ), X("web-sdk.widget", "Attachment failed", {
788
779
  message: s instanceof Error ? s.message : String(s)
789
780
  });
790
781
  });
791
782
  }), i.addEventListener("dragenter", (r) => {
792
- !Oe(r.dataTransfer) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), Le += 1, i.classList.add("pluno-pa-widget--drag-over"));
783
+ !He(r.dataTransfer) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), Ae += 1, i.classList.add("pluno-pa-widget--drag-over"));
793
784
  }), i.addEventListener("dragover", (r) => {
794
785
  const s = r.dataTransfer;
795
- !Oe(s) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), s.dropEffect = "copy");
786
+ !He(s) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), s.dropEffect = "copy");
796
787
  }), i.addEventListener("dragleave", (r) => {
797
- Oe(r.dataTransfer) && (r.stopPropagation(), Le = Math.max(0, Le - 1), Le === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
788
+ He(r.dataTransfer) && (r.stopPropagation(), Ae = Math.max(0, Ae - 1), Ae === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
798
789
  }), i.addEventListener("drop", (r) => {
799
790
  const s = r.dataTransfer;
800
- !Oe(s) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), Gn(), Pt(s.files).catch((C) => {
801
- At(
802
- C instanceof Error ? C.message : "Failed to attach file"
791
+ !He(s) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), jn(), Dt(s.files).catch((E) => {
792
+ Tt(
793
+ E instanceof Error ? E.message : "Failed to attach file"
803
794
  ), X("web-sdk.widget", "Attachment failed", {
804
- message: C instanceof Error ? C.message : String(C)
795
+ message: E instanceof Error ? E.message : String(E)
805
796
  });
806
797
  }));
807
- }), ie.addEventListener("click", () => {
798
+ }), D.addEventListener("click", () => {
808
799
  if (t.loginRequired) {
809
800
  t.onLoginClick?.();
810
801
  return;
@@ -813,61 +804,64 @@ async function Vo(e = {}) {
813
804
  w.stop();
814
805
  return;
815
806
  }
816
- de = !0, V(!0, "send"), Y(), z = rt(
807
+ ue = !0, V(!0, "send"), K(), y = pt(
817
808
  w,
818
809
  b,
819
- z
820
- ), fe(), $(), O(w.getState());
821
- }), _.addEventListener("click", () => {
822
- re = !re, Ee = null, ge(), re && le.length === 0 && xt(null);
823
- }), H.addEventListener("click", () => {
824
- re = !1, ge();
825
- }), F.addEventListener("scroll", Un), b.addEventListener("input", () => {
826
- Pe(b), G(), $(), O(w.getState());
810
+ y
811
+ ), _e(), $(), O(w.getState());
812
+ }), ce.addEventListener("click", () => {
813
+ re = !re, Le = null, me(), re && le.length === 0 && St(null);
814
+ }), ie.addEventListener("click", () => {
815
+ re = !1, me();
816
+ }), G.addEventListener("scroll", Gn), b.addEventListener("input", () => {
817
+ Te(b), H(), $(), Yn();
827
818
  }), b.addEventListener("keydown", (r) => {
828
819
  if (!(r.key !== "Enter" || r.shiftKey)) {
829
820
  if (r.preventDefault(), t.loginRequired) {
830
821
  t.onLoginClick?.();
831
822
  return;
832
823
  }
833
- de = !0, V(!0, "send"), Y(), z = rt(
824
+ ue = !0, V(!0, "send"), K(), y = pt(
834
825
  w,
835
826
  b,
836
- z
837
- ), fe(), $(), O(w.getState());
827
+ y
828
+ ), _e(), $(), O(w.getState());
838
829
  }
839
830
  }), i.addEventListener("click", (r) => {
840
- (r.target instanceof Element ? r.target : null)?.closest("a[href]") && G();
841
- }), l.composerValue && (b.value = l.composerValue, Pe(b)), t.initialDisplayState === "minimized" ? Se("minimized", !1) : l.isOpen && pe(b.value, !1);
842
- const ze = () => a;
843
- let Je = w.getState().appearance !== null, Be = null, Ae = null, _e = null, It = w.getState().isThinking, xe = null, Qe = null, Tt = () => {
831
+ (r.target instanceof Element ? r.target : null)?.closest("a[href]") && H();
832
+ }), l.composerValue && (b.value = l.composerValue, Te(b)), t.initialDisplayState === "minimized" ? Pe("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && pe(b.value, !1);
833
+ const Oe = () => a;
834
+ let Qe = w.getState().appearance !== null, Fe = null, Ne = null, ve = null, Rt = w.getState().isThinking, ye = null, Ce = null, Mt = () => {
835
+ };
836
+ const Kn = !!t.socialPostDraftHandler, et = /* @__PURE__ */ new Map(), tt = () => b.value.trim().length > 0 || y.length > 0, Yn = () => {
837
+ const r = Ce !== null && ct(w.getState(), tt());
838
+ ae.hidden = !r, r && Ce !== null && Ln(ae, Ce);
844
839
  };
845
- const $n = !!t.socialPostDraftHandler;
846
- let ye = null;
847
- const qn = () => {
848
- de = !0, V(!0, "newSession"), Y(), re = !1, ge(), w.startNewSession(), Ve.clear(), b.value = "", z = [], fe(), Pe(b), G(), $(), b.focus(), O(w.getState());
849
- }, et = (r) => {
840
+ let Se = null;
841
+ const Xn = () => {
842
+ ue = !0, V(!0, "newSession"), K(), re = !1, me(), w.startNewSession(), Ke.clear(), b.value = "", y = [], _e(), Te(b), H(), $(), b.focus(), O(w.getState());
843
+ }, nt = (r) => {
850
844
  if (!r) {
851
- ye?.remove(), ye = null;
845
+ Se?.remove(), Se = null;
852
846
  return;
853
847
  }
854
- ye || (ye = qe(
848
+ Se || (Se = Ve(
855
849
  "pluno-pa-widget__new-chat",
856
850
  "New chat",
857
- Ci(),
851
+ ki(),
858
852
  !1
859
- ), ye.addEventListener("click", qn), ae.insertBefore(ye, _));
853
+ ), Se.addEventListener("click", Xn), de.insertBefore(Se, ce));
860
854
  }, O = (r) => {
861
- if (ge(), wt(r.lastErrorCode) ? xe = r.lastErrorCode : t.billingStatus?.creditsUsed !== null && !J(t.billingStatus) && (xe = null), pt(
862
- S,
855
+ if (me(), yt(r.lastErrorCode) ? ye = r.lastErrorCode : t.billingStatus?.creditsUsed !== null && !Q(t.billingStatus) && (ye = null), dt(
856
+ I,
863
857
  t.billingStatus,
864
- xe
858
+ ye
865
859
  ), t.loginRequired) {
866
- on(
867
- A,
868
- ie,
869
- et,
870
- ze,
860
+ et.clear(), pn(
861
+ L,
862
+ D,
863
+ nt,
864
+ Oe,
871
865
  "Log in to use Pluno on this page.",
872
866
  t.loginButtonLabel,
873
867
  t.loginUrl,
@@ -876,11 +870,11 @@ async function Vo(e = {}) {
876
870
  return;
877
871
  }
878
872
  if (t.signupRequired) {
879
- on(
880
- A,
881
- ie,
882
- et,
883
- ze,
873
+ et.clear(), pn(
874
+ L,
875
+ D,
876
+ nt,
877
+ Oe,
884
878
  "Complete signup to unlock your free trial credits.",
885
879
  t.signupButtonLabel,
886
880
  t.signupUrl,
@@ -888,70 +882,65 @@ async function Vo(e = {}) {
888
882
  );
889
883
  return;
890
884
  }
891
- const s = li(r), C = s !== _t;
892
- _t = s;
893
- const B = de || ce.enabled;
894
- de = !1, Vi(
885
+ const s = ci(r), E = s !== Ct;
886
+ Ct = s;
887
+ const z = ue || ge.enabled;
888
+ ue = !1, $i(
889
+ L,
895
890
  A,
896
- je,
897
- ie,
898
- et,
899
- be,
891
+ D,
892
+ nt,
893
+ ae,
900
894
  r,
901
- Qe,
902
- Qe !== null && tn(
903
- r,
904
- b.value.trim().length > 0 || z.length > 0
905
- ),
906
- B,
907
- () => ce.enabled,
908
- Ve,
909
- G,
910
- ze,
911
- (D) => {
912
- de = !0, V(!0, "send"), Y(), w.sendMessage(D);
895
+ Ce,
896
+ Ce !== null && ct(r, tt()),
897
+ z,
898
+ () => ge.enabled,
899
+ Ke,
900
+ et,
901
+ H,
902
+ Oe,
903
+ (N) => {
904
+ ue = !0, V(!0, "send"), K(), w.sendMessage(N);
913
905
  },
914
- $n && !Ye ? {
915
- dismissedCandidateIds: Ne,
916
- draftingCandidateId: Be,
917
- error: Ae,
918
- characterIconOptions: ze(),
919
- onSeen: (D) => {
920
- we.add(D.id), G();
906
+ Kn && !Ye ? {
907
+ dismissedCandidateIds: Me,
908
+ draftingCandidateId: Fe,
909
+ error: Ne,
910
+ characterIconOptions: Oe(),
911
+ onSeen: (N) => {
912
+ xe.add(N.id), H();
921
913
  },
922
- onDraft: (D) => {
923
- jn(D);
914
+ onDraft: (N) => {
915
+ Zn(N);
924
916
  },
925
- onDismiss: (D) => {
926
- we.add(D.id), Ne.add(D.id), G(), Ae = null, O(w.getState());
917
+ onDismiss: (N) => {
918
+ xe.add(N.id), Me.add(N.id), H(), Ne = null, O(w.getState());
927
919
  },
928
- onDisable: (D) => {
929
- Ye = !0, we.add(D.id), Ne.add(D.id), G(), ga(t, !0), Ae = null, O(w.getState());
920
+ onDisable: (N) => {
921
+ Ye = !0, xe.add(N.id), Me.add(N.id), H(), ga(t, !0), Ne = null, O(w.getState());
930
922
  }
931
923
  } : void 0
932
- ), B ? (ue = A.scrollTop, Y()) : C && pi(r) && Bn();
924
+ ), z ? (he = L.scrollTop, K()) : E && ui(r) && Hn();
933
925
  };
934
- return Tt = co(
926
+ return Mt = bo(
935
927
  (r) => {
936
- Qe = r, !De && tn(
937
- w.getState(),
938
- b.value.trim().length > 0 || z.length > 0
939
- ) && O(w.getState());
928
+ Ce = r, !ze && ct(w.getState(), tt()) && O(w.getState());
940
929
  },
941
930
  {
942
931
  backendUrl: t.backendUrl,
943
- fetcher: zn,
932
+ fetcher: Fn,
944
933
  loader: t.activeUsersLoader
945
934
  }
946
935
  ), w.on("state", (r) => {
947
- const s = It && !r.isThinking;
948
- It = r.isThinking, r.appearance ? (Je = !0, X(
936
+ const s = Rt && !r.isThinking;
937
+ Rt = r.isThinking, r.appearance ? (Qe = !0, X(
949
938
  "web-sdk.widget",
950
939
  "Agent state supplied appearance",
951
940
  {
952
941
  appearance: r.appearance
953
942
  }
954
- ), tt(r.appearance, "agent.state.appearance")) : Je && (Je = !1, X(
943
+ ), ot(r.appearance, "agent.state.appearance")) : Qe && (Qe = !1, X(
955
944
  "web-sdk.widget",
956
945
  "Agent state cleared appearance; reverting to configured widget options",
957
946
  {
@@ -959,32 +948,32 @@ async function Vo(e = {}) {
959
948
  fallbackColorScheme: t.colorScheme,
960
949
  fallbackFontFamily: t.fontFamily
961
950
  }
962
- ), tt({}, "agent.state.appearance-cleared")), O(r), $(), s && St();
951
+ ), ot({}, "agent.state.appearance-cleared")), O(r), $(), s && It();
963
952
  }), O(w.getState()), $(), {
964
953
  agent: w,
965
954
  updateAppearance: (r) => {
966
- r.scribbleStyle !== void 0 && (t.scribbleStyle = r.scribbleStyle), tt(r, "widgetHandle.updateAppearance");
955
+ r.scribbleStyle !== void 0 && (t.scribbleStyle = r.scribbleStyle), ot(r, "widgetHandle.updateAppearance");
967
956
  },
968
957
  updateBillingStatus: (r) => {
969
958
  const s = r ?? null;
970
- Qt(
959
+ on(
971
960
  t.billingStatus,
972
961
  s,
973
- xe
974
- ) && (t.billingStatus = s, t.billingStatus?.creditsUsed !== null && !J(t.billingStatus) && (xe = null), pt(
962
+ ye
963
+ ) && (t.billingStatus = s, t.billingStatus?.creditsUsed !== null && !Q(t.billingStatus) && (ye = null), dt(
975
964
  i.querySelector(".pluno-pa-widget__billing-status"),
976
965
  t.billingStatus,
977
- xe
966
+ ye
978
967
  ), $());
979
968
  },
980
969
  updateAuthGate: (r) => {
981
- const s = Me();
982
- t.loginRequired = r.loginRequired === !0, t.signupRequired = r.signupRequired === !0, r.loginButtonLabel !== void 0 && (t.loginButtonLabel = r.loginButtonLabel), r.loginUrl !== void 0 && (t.loginUrl = r.loginUrl), r.signupButtonLabel !== void 0 && (t.signupButtonLabel = r.signupButtonLabel), r.signupUrl !== void 0 && (t.signupUrl = r.signupUrl), Lt(), O(w.getState()), $(), s && !Me() && w.connect().catch((C) => {
970
+ const s = Ue();
971
+ t.loginRequired = r.loginRequired === !0, t.signupRequired = r.signupRequired === !0, r.loginButtonLabel !== void 0 && (t.loginButtonLabel = r.loginButtonLabel), r.loginUrl !== void 0 && (t.loginUrl = r.loginUrl), r.signupButtonLabel !== void 0 && (t.signupButtonLabel = r.signupButtonLabel), r.signupUrl !== void 0 && (t.signupUrl = r.signupUrl), Nt(), O(w.getState()), $(), s && !Ue() && w.connect().catch((E) => {
983
972
  X(
984
973
  "web-sdk.widget",
985
974
  "Failed to connect after auth gate cleared",
986
975
  {
987
- message: C instanceof Error ? C.message : String(C)
976
+ message: E instanceof Error ? E.message : String(E)
988
977
  }
989
978
  );
990
979
  });
@@ -994,66 +983,66 @@ async function Vo(e = {}) {
994
983
  },
995
984
  updateDisplayState: (r) => {
996
985
  if (r === "shown") {
997
- Se("shown", !1);
986
+ Pe("shown", !1);
998
987
  return;
999
988
  }
1000
- Se("minimized", !1);
989
+ Pe("minimized", !1);
1001
990
  },
1002
991
  destroy: () => {
1003
- De || (De = !0, yt.disconnect(), kt?.disconnect(), window.removeEventListener("resize", Ct), Et(), te !== null && window.clearTimeout(te), Tt(), _e?.remove(), w.destroy(), n.remove());
992
+ ze || (ze = !0, Et.disconnect(), At?.disconnect(), window.removeEventListener("resize", Lt), Pt(), B !== null && window.clearTimeout(B), Mt(), ve?.remove(), w.destroy(), o.remove());
1004
993
  }
1005
994
  };
1006
- async function jn(r) {
1007
- if (!Be) {
1008
- Be = r.id, Ae = null, O(w.getState());
995
+ async function Zn(r) {
996
+ if (!Fe) {
997
+ Fe = r.id, Ne = null, O(w.getState());
1009
998
  try {
1010
999
  if (!t.socialPostDraftHandler)
1011
1000
  throw new Error("Social post drafting is not available here.");
1012
1001
  const s = await t.socialPostDraftHandler(r);
1013
1002
  if (!s.linkedinPost || !s.xPost)
1014
1003
  throw new Error("Pluno did not return a complete social post draft.");
1015
- we.add(r.id), Ne.add(r.id), G(), _e?.remove(), _e = Ji(s, {
1004
+ xe.add(r.id), Me.add(r.id), H(), ve?.remove(), ve = Ji(s, {
1016
1005
  socialPostRewardsUrl: t.socialPostRewardsUrl,
1017
1006
  onClose: () => {
1018
- _e?.remove(), _e = null;
1007
+ ve?.remove(), ve = null;
1019
1008
  }
1020
- }), i.appendChild(_e);
1009
+ }), i.appendChild(ve);
1021
1010
  } catch (s) {
1022
- Ae = s instanceof Error ? s.message : "Could not draft social post.";
1011
+ Ne = s instanceof Error ? s.message : "Could not draft social post.";
1023
1012
  } finally {
1024
- Be = null, O(w.getState());
1013
+ Fe = null, O(w.getState());
1025
1014
  }
1026
1015
  }
1027
1016
  }
1028
- function tt(r, s) {
1029
- const C = r.accentColor ?? t.accentColor, B = r.colorScheme ?? t.colorScheme, D = r.fontFamily ?? t.fontFamily, nt = r.scribbleStyle ?? t.scribbleStyle;
1030
- a = qt(
1031
- C,
1032
- nt
1033
- ), jt(i, a, {
1034
- accentColor: C,
1035
- colorScheme: B,
1036
- fontFamily: D,
1037
- scribbleStyle: nt
1017
+ function ot(r, s) {
1018
+ const E = r.accentColor ?? t.accentColor, z = r.colorScheme ?? t.colorScheme, N = r.fontFamily ?? t.fontFamily, it = r.scribbleStyle ?? t.scribbleStyle;
1019
+ a = Yt(
1020
+ E,
1021
+ it
1022
+ ), Xt(i, a, {
1023
+ accentColor: E,
1024
+ colorScheme: z,
1025
+ fontFamily: N,
1026
+ scribbleStyle: it
1038
1027
  }), X("web-sdk.widget", "Updated widget appearance", {
1039
1028
  source: s,
1040
1029
  inputAppearance: r,
1041
- appliedAccentColor: C,
1042
- appliedColorScheme: B,
1043
- appliedFontFamily: D,
1044
- appliedScribbleStyle: nt,
1030
+ appliedAccentColor: E,
1031
+ appliedColorScheme: z,
1032
+ appliedFontFamily: N,
1033
+ appliedScribbleStyle: it,
1045
1034
  cssAccent: i.style.getPropertyValue("--pluno-pa-accent")
1046
1035
  });
1047
1036
  }
1048
1037
  }
1049
- function qt(e, t) {
1038
+ function Yt(e, t) {
1050
1039
  return { accentColor: e, scribbleStyle: t };
1051
1040
  }
1052
- function Yo(e) {
1053
- const t = Ko(e);
1054
- return t === null ? "#fafafa" : Xo(t) > 0.5 ? "#18181b" : "#fafaf9";
1041
+ function Zo(e) {
1042
+ const t = Jo(e);
1043
+ return t === null ? "#fafafa" : Qo(t) > 0.5 ? "#18181b" : "#fafaf9";
1055
1044
  }
1056
- function Ko(e) {
1045
+ function Jo(e) {
1057
1046
  const t = e.trim();
1058
1047
  return /^#[0-9a-f]{6}$/i.test(t) ? [
1059
1048
  Number.parseInt(t.slice(1, 3), 16),
@@ -1065,26 +1054,26 @@ function Ko(e) {
1065
1054
  Number.parseInt(t[3] + t[3], 16)
1066
1055
  ] : null;
1067
1056
  }
1068
- function Xo([e, t, n]) {
1069
- const o = (i) => {
1057
+ function Qo([e, t, o]) {
1058
+ const n = (i) => {
1070
1059
  const a = i / 255;
1071
1060
  return a <= 0.03928 ? a / 12.92 : ((a + 0.055) / 1.055) ** 2.4;
1072
1061
  };
1073
- return 0.2126 * o(e) + 0.7152 * o(t) + 0.0722 * o(n);
1062
+ return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
1074
1063
  }
1075
- function jt(e, t, n) {
1064
+ function Xt(e, t, o) {
1076
1065
  e.classList.toggle(
1077
1066
  "pluno-pa-widget--dark",
1078
- n.colorScheme === "dark"
1067
+ o.colorScheme === "dark"
1079
1068
  ), e.classList.toggle(
1080
1069
  "pluno-pa-widget--light",
1081
- n.colorScheme !== "dark"
1082
- ), e.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
1083
- const o = n.scribbleStyle ? dn(n.accentColor) : n.accentColor;
1084
- e.style.setProperty("--pluno-pa-accent", o), n.scribbleStyle ? e.style.setProperty(
1070
+ o.colorScheme !== "dark"
1071
+ ), e.classList.toggle("pluno-pa-widget--scribble", o.scribbleStyle);
1072
+ const n = o.scribbleStyle ? hn(o.accentColor) : o.accentColor;
1073
+ e.style.setProperty("--pluno-pa-accent", n), o.scribbleStyle ? e.style.setProperty(
1085
1074
  "--pluno-pa-accent-contrast",
1086
- Yo(o)
1087
- ) : e.style.removeProperty("--pluno-pa-accent-contrast"), e.style.fontFamily = n.scribbleStyle ? Po : n.fontFamily, n.scribbleStyle && Zo(e.ownerDocument);
1075
+ Zo(n)
1076
+ ) : e.style.removeProperty("--pluno-pa-accent-contrast"), e.style.fontFamily = o.scribbleStyle ? To : o.fontFamily, o.scribbleStyle && ei(e.ownerDocument);
1088
1077
  const i = Array.from(
1089
1078
  e.querySelectorAll(".pluno-pa-widget__character")
1090
1079
  );
@@ -1096,11 +1085,11 @@ function jt(e, t, n) {
1096
1085
  )
1097
1086
  );
1098
1087
  }
1099
- function Zo(e) {
1100
- if (e.getElementById(Ot))
1088
+ function ei(e) {
1089
+ if (e.getElementById(Wt))
1101
1090
  return;
1102
1091
  const t = e.createElement("style");
1103
- t.id = Ot, t.textContent = `@font-face {
1092
+ t.id = Wt, t.textContent = `@font-face {
1104
1093
  font-family: "Architects Daughter";
1105
1094
  font-style: normal;
1106
1095
  font-weight: 400;
@@ -1108,201 +1097,201 @@ function Zo(e) {
1108
1097
  src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
1109
1098
  }`, e.head.appendChild(t), e.fonts?.load('16px "Architects Daughter"');
1110
1099
  }
1111
- function Jo({
1100
+ function ti({
1112
1101
  root: e,
1113
1102
  launcher: t,
1114
- launcherDragHandle: n,
1115
- getPosition: o,
1103
+ launcherDragHandle: o,
1104
+ getPosition: n,
1116
1105
  setPosition: i,
1117
1106
  persist: a
1118
1107
  }) {
1119
1108
  let l = null, p = null, c = null, u = !1, d = null;
1120
- const h = () => {
1109
+ const g = () => {
1121
1110
  l = null, p = null, c = null, u = !1, e.classList.remove("pluno-pa-widget--dragging");
1122
- }, x = (g) => {
1123
- e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing") || (g.preventDefault(), g.stopPropagation(), l = g.pointerId, p = { x: g.clientX, y: g.clientY }, c = o(), u = !1, t.setPointerCapture?.(g.pointerId));
1124
- }, y = (g) => {
1125
- if (l !== g.pointerId || !p || !c)
1111
+ }, S = (h) => {
1112
+ e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing") || (h.preventDefault(), h.stopPropagation(), l = h.pointerId, p = { x: h.clientX, y: h.clientY }, c = n(), u = !1, t.setPointerCapture?.(h.pointerId));
1113
+ }, f = (h) => {
1114
+ if (l !== h.pointerId || !p || !c)
1126
1115
  return;
1127
- g.preventDefault();
1128
- const S = g.clientX - p.x, k = g.clientY - p.y;
1129
- !u && Math.hypot(S, k) < Wt || (u = !0, e.classList.add("pluno-pa-widget--dragging"), i({ x: c.x + S, y: c.y + k }));
1130
- }, P = (g) => {
1131
- l === g.pointerId && (g.preventDefault(), g.stopPropagation(), u && (d = { x: g.clientX, y: g.clientY }, a()), h());
1132
- }, T = (g) => {
1133
- l === g.pointerId && (g.preventDefault(), h());
1134
- }, f = (g) => {
1116
+ h.preventDefault();
1117
+ const I = h.clientX - p.x, T = h.clientY - p.y;
1118
+ !u && Math.hypot(I, T) < Vt || (u = !0, e.classList.add("pluno-pa-widget--dragging"), i({ x: c.x + I, y: c.y + T }));
1119
+ }, F = (h) => {
1120
+ l === h.pointerId && (h.preventDefault(), h.stopPropagation(), u && (d = { x: h.clientX, y: h.clientY }, a()), g());
1121
+ }, k = (h) => {
1122
+ l === h.pointerId && (h.preventDefault(), g());
1123
+ }, x = (h) => {
1135
1124
  if (!d)
1136
1125
  return;
1137
- const S = Math.hypot(
1138
- g.clientX - d.x,
1139
- g.clientY - d.y
1140
- ) <= Wt;
1141
- d = null, S && (g.preventDefault(), g.stopPropagation());
1142
- }, E = (g) => {
1126
+ const I = Math.hypot(
1127
+ h.clientX - d.x,
1128
+ h.clientY - d.y
1129
+ ) <= Vt;
1130
+ d = null, I && (h.preventDefault(), h.stopPropagation());
1131
+ }, v = (h) => {
1143
1132
  if (e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing"))
1144
1133
  return;
1145
- const S = g.shiftKey ? $o : Wo, k = o();
1146
- let R = null;
1147
- g.key === "ArrowUp" ? R = { x: k.x, y: k.y - S } : g.key === "ArrowDown" ? R = { x: k.x, y: k.y + S } : g.key === "ArrowLeft" ? R = { x: k.x - S, y: k.y } : g.key === "ArrowRight" && (R = { x: k.x + S, y: k.y }), R && (g.preventDefault(), g.stopPropagation(), i(R), a());
1134
+ const I = h.shiftKey ? Vo : jo, T = n();
1135
+ let P = null;
1136
+ h.key === "ArrowUp" ? P = { x: T.x, y: T.y - I } : h.key === "ArrowDown" ? P = { x: T.x, y: T.y + I } : h.key === "ArrowLeft" ? P = { x: T.x - I, y: T.y } : h.key === "ArrowRight" && (P = { x: T.x + I, y: T.y }), P && (h.preventDefault(), h.stopPropagation(), i(P), a());
1148
1137
  };
1149
- return t.addEventListener("pointerdown", x), t.addEventListener("pointermove", y), t.addEventListener("pointerup", P), t.addEventListener("pointercancel", T), t.addEventListener("click", f, !0), n.addEventListener("keydown", E), () => {
1150
- t.removeEventListener("pointerdown", x), t.removeEventListener("pointermove", y), t.removeEventListener("pointerup", P), t.removeEventListener("pointercancel", T), t.removeEventListener("click", f, !0), n.removeEventListener("keydown", E);
1138
+ return t.addEventListener("pointerdown", S), t.addEventListener("pointermove", f), t.addEventListener("pointerup", F), t.addEventListener("pointercancel", k), t.addEventListener("click", x, !0), o.addEventListener("keydown", v), () => {
1139
+ t.removeEventListener("pointerdown", S), t.removeEventListener("pointermove", f), t.removeEventListener("pointerup", F), t.removeEventListener("pointercancel", k), t.removeEventListener("click", x, !0), o.removeEventListener("keydown", v);
1151
1140
  };
1152
1141
  }
1153
- function $e(e, t = !0) {
1154
- const n = Q();
1142
+ function je(e, t = !0) {
1143
+ const o = ee();
1155
1144
  if (e.classList.contains("pluno-pa-widget--minimized"))
1156
1145
  return e.classList.contains("pluno-pa-widget--scribble") ? {
1157
- width: Io,
1158
- height: To
1159
- } : { width: Ut, height: Ut };
1160
- const o = e.getBoundingClientRect(), i = !e.classList.contains("pluno-pa-widget--open") && !e.classList.contains("pluno-pa-widget--closing");
1146
+ width: Do,
1147
+ height: Ro
1148
+ } : { width: Gt, height: Gt };
1149
+ const n = e.getBoundingClientRect(), i = !e.classList.contains("pluno-pa-widget--open") && !e.classList.contains("pluno-pa-widget--closing");
1161
1150
  return {
1162
- width: t && i && o.width > 0 ? o.width : Math.min(bn, n.width - 36),
1163
- height: t && i && o.height > 0 ? o.height : e.classList.contains("pluno-pa-widget--scribble") ? Do : fn
1151
+ width: t && i && n.width > 0 ? n.width : Math.min(_n, o.width - 36),
1152
+ height: t && i && n.height > 0 ? n.height : e.classList.contains("pluno-pa-widget--scribble") ? zo : xn
1164
1153
  };
1165
1154
  }
1166
- function yn() {
1167
- const e = Q();
1155
+ function Sn() {
1156
+ const e = ee();
1168
1157
  return {
1169
1158
  width: Math.min(
1170
- ve(
1171
- e.width * zo,
1172
- Ro,
1173
- Mo
1159
+ Ee(
1160
+ e.width * Oo,
1161
+ Bo,
1162
+ Uo
1174
1163
  ),
1175
1164
  e.width - W * 2
1176
1165
  ),
1177
1166
  height: Math.min(
1178
- ve(
1179
- e.height * Uo,
1180
- Bo,
1181
- Oo
1167
+ Ee(
1168
+ e.height * Wo,
1169
+ Fo,
1170
+ Ho
1182
1171
  ),
1183
- e.height - ut - W
1172
+ e.height - mt - W
1184
1173
  )
1185
1174
  };
1186
1175
  }
1187
- function Qo(e, t, n) {
1188
- const o = Number.parseFloat(e.style.left), i = Number.parseFloat(e.style.top);
1189
- if (Number.isFinite(o) && Number.isFinite(i))
1190
- return { x: o, y: i };
1176
+ function ni(e, t, o) {
1177
+ const n = Number.parseFloat(e.style.left), i = Number.parseFloat(e.style.top);
1178
+ if (Number.isFinite(n) && Number.isFinite(i))
1179
+ return { x: n, y: i };
1191
1180
  const a = e.getBoundingClientRect();
1192
1181
  if (a.width > 0 || a.height > 0)
1193
1182
  return { x: a.left, y: a.top };
1194
- const l = Q();
1183
+ const l = ee();
1195
1184
  return {
1196
- x: t === "bottom-left" ? 26 : l.width - 26 - n.width,
1197
- y: l.height - 24 - n.height
1185
+ x: t === "bottom-left" ? 26 : l.width - 26 - o.width,
1186
+ y: l.height - 24 - o.height
1198
1187
  };
1199
1188
  }
1200
- function it(e, t, n) {
1201
- const o = $e(e, !1);
1202
- return t ? gt(
1189
+ function rt(e, t, o) {
1190
+ const n = je(e, !1);
1191
+ return t ? bt(
1203
1192
  e,
1204
- vn(t, o),
1205
- o
1206
- ) : ei(n === "bottom-left" ? "bottom-left" : "bottom-right", o, No);
1193
+ En(t, n),
1194
+ n
1195
+ ) : oi(o === "bottom-left" ? "bottom-left" : "bottom-right", n, Mo);
1207
1196
  }
1208
- function ei(e, t, n) {
1209
- const o = Q();
1197
+ function oi(e, t, o) {
1198
+ const n = ee();
1210
1199
  return {
1211
- x: e.endsWith("right") ? Math.max(0, o.width - t.width - n) : n,
1212
- y: e.startsWith("bottom") ? Math.max(0, o.height - t.height - n) : n
1200
+ x: e.endsWith("right") ? Math.max(0, n.width - t.width - o) : o,
1201
+ y: e.startsWith("bottom") ? Math.max(0, n.height - t.height - o) : o
1213
1202
  };
1214
1203
  }
1215
- function gt(e, t, n) {
1216
- const o = Q(), i = W + oi(e);
1204
+ function bt(e, t, o) {
1205
+ const n = ee(), i = W + ri(e);
1217
1206
  return {
1218
- x: ve(
1207
+ x: Ee(
1219
1208
  t.x,
1220
1209
  W,
1221
1210
  Math.max(
1222
1211
  W,
1223
- o.width - n.width - W
1212
+ n.width - o.width - W
1224
1213
  )
1225
1214
  ),
1226
- y: ve(
1215
+ y: Ee(
1227
1216
  t.y,
1228
1217
  i,
1229
1218
  Math.max(
1230
1219
  i,
1231
- o.height - n.height - W
1220
+ n.height - o.height - W
1232
1221
  )
1233
1222
  )
1234
1223
  };
1235
1224
  }
1236
- function vn(e, t) {
1237
- const n = Q();
1225
+ function En(e, t) {
1226
+ const o = ee();
1238
1227
  return {
1239
- x: e.anchor.endsWith("right") ? n.width - t.width - e.x : e.x,
1240
- y: e.anchor.startsWith("bottom") ? n.height - t.height - e.y : e.y
1228
+ x: e.anchor.endsWith("right") ? o.width - t.width - e.x : e.x,
1229
+ y: e.anchor.startsWith("bottom") ? o.height - t.height - e.y : e.y
1241
1230
  };
1242
1231
  }
1243
- function ti(e, t) {
1244
- const n = ni(e, t), o = Q();
1232
+ function ii(e, t) {
1233
+ const o = ai(e, t), n = ee();
1245
1234
  return {
1246
- anchor: n,
1247
- x: n.endsWith("right") ? o.width - e.x - t.width : e.x,
1248
- y: n.startsWith("bottom") ? o.height - e.y - t.height : e.y
1235
+ anchor: o,
1236
+ x: o.endsWith("right") ? n.width - e.x - t.width : e.x,
1237
+ y: o.startsWith("bottom") ? n.height - e.y - t.height : e.y
1249
1238
  };
1250
1239
  }
1251
- function ni(e, t) {
1252
- const n = Q(), o = e.x + t.width / 2, a = e.y + t.height / 2 <= n.height / 2 ? "top" : "bottom", l = o <= n.width / 2 ? "left" : "right";
1240
+ function ai(e, t) {
1241
+ const o = ee(), n = e.x + t.width / 2, a = e.y + t.height / 2 <= o.height / 2 ? "top" : "bottom", l = n <= o.width / 2 ? "left" : "right";
1253
1242
  return `${a}-${l}`;
1254
1243
  }
1255
- function oi(e) {
1256
- return e.classList.contains("pluno-pa-widget--scribble") ? Go : Ho;
1244
+ function ri(e) {
1245
+ return e.classList.contains("pluno-pa-widget--scribble") ? qo : $o;
1257
1246
  }
1258
- function Vt(e, t, n) {
1259
- const o = $e(e), i = yn(), a = {
1260
- x: n === "bottom-left" ? t.x : t.x + o.width - i.width,
1261
- y: t.y + o.height - i.height
1247
+ function Zt(e, t, o) {
1248
+ const n = je(e), i = Sn(), a = {
1249
+ x: o === "bottom-left" ? t.x : t.x + n.width - i.width,
1250
+ y: t.y + n.height - i.height
1262
1251
  };
1263
- return ii(a);
1252
+ return li(a);
1264
1253
  }
1265
- function ii(e) {
1266
- const t = Q(), n = yn();
1254
+ function li(e) {
1255
+ const t = ee(), o = Sn();
1267
1256
  return {
1268
- x: ve(
1257
+ x: Ee(
1269
1258
  e.x,
1270
1259
  W,
1271
1260
  Math.max(
1272
1261
  W,
1273
- t.width - n.width - W
1262
+ t.width - o.width - W
1274
1263
  )
1275
1264
  ),
1276
- y: ve(
1265
+ y: Ee(
1277
1266
  e.y,
1278
- ut,
1267
+ mt,
1279
1268
  Math.max(
1280
- ut,
1281
- t.height - n.height - W
1269
+ mt,
1270
+ t.height - o.height - W
1282
1271
  )
1283
1272
  )
1284
1273
  };
1285
1274
  }
1286
- function me(e, t) {
1275
+ function fe(e, t) {
1287
1276
  if (e.classList.toggle("pluno-pa-widget--custom-position", t !== null), !t) {
1288
1277
  e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
1289
1278
  return;
1290
1279
  }
1291
1280
  e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.right = "auto", e.style.bottom = "auto";
1292
1281
  }
1293
- function ai(e, t) {
1282
+ function pi(e, t) {
1294
1283
  e.style.setProperty("--pluno-pa-panel-offset-x", `${t.x}px`), e.style.setProperty("--pluno-pa-panel-offset-y", `${t.y}px`);
1295
1284
  }
1296
- function Yt(e) {
1285
+ function Jt(e) {
1297
1286
  e.style.removeProperty("--pluno-pa-panel-offset-x"), e.style.removeProperty("--pluno-pa-panel-offset-y");
1298
1287
  }
1299
- function Q() {
1288
+ function ee() {
1300
1289
  return {
1301
- width: window.innerWidth || document.documentElement.clientWidth || bn + W * 2,
1302
- height: window.innerHeight || document.documentElement.clientHeight || fn + W * 2
1290
+ width: window.innerWidth || document.documentElement.clientWidth || _n + W * 2,
1291
+ height: window.innerHeight || document.documentElement.clientHeight || xn + W * 2
1303
1292
  };
1304
1293
  }
1305
- function at(e) {
1294
+ function lt(e) {
1306
1295
  const t = e.getBoundingClientRect();
1307
1296
  return {
1308
1297
  x: Math.round(t.x),
@@ -1311,42 +1300,45 @@ function at(e) {
1311
1300
  height: Math.round(t.height)
1312
1301
  };
1313
1302
  }
1314
- function ve(e, t, n) {
1315
- return Math.min(Math.max(e, t), n);
1303
+ function Ee(e, t, o) {
1304
+ return Math.min(Math.max(e, t), o);
1316
1305
  }
1317
- function X(e, t, n) {
1306
+ function X(e, t, o) {
1318
1307
  if (typeof window > "u")
1319
1308
  return;
1320
- const o = window, i = {
1309
+ const n = window, i = {
1321
1310
  at: (/* @__PURE__ */ new Date()).toISOString(),
1322
1311
  source: e,
1323
1312
  message: t,
1324
- details: n
1325
- }, a = o.__plunoProductAgentDiagnostics__ ?? [];
1326
- a.push(i), a.length > 120 && a.splice(0, a.length - 120), o.__plunoProductAgentDiagnostics__ = a, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...a], window.dispatchEvent(
1327
- new CustomEvent(Eo, { detail: i })
1313
+ details: o
1314
+ }, a = n.__plunoProductAgentDiagnostics__ ?? [];
1315
+ a.push(i), a.length > 120 && a.splice(0, a.length - 120), n.__plunoProductAgentDiagnostics__ = a, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...a], window.dispatchEvent(
1316
+ new CustomEvent(Io, { detail: i })
1328
1317
  );
1329
1318
  }
1330
- function ri(e, t) {
1319
+ function si(e, t) {
1331
1320
  X("web-sdk.widget.position", e, t);
1332
1321
  }
1333
- function rt(e, t, n) {
1334
- const o = t.value.trim();
1335
- return !o && n.length === 0 ? n : (t.value = "", t.style.height = "22px", t.style.overflowY = "hidden", e.sendMessage(o, {
1336
- attachments: n.length > 0 ? n : void 0
1322
+ function pt(e, t, o) {
1323
+ const n = t.value.trim();
1324
+ return !n && o.length === 0 ? o : (t.value = "", t.style.height = "22px", t.style.overflowY = "hidden", e.sendMessage(n, {
1325
+ attachments: o.length > 0 ? o.map(di) : void 0
1337
1326
  }), t.dispatchEvent(new Event("input", { bubbles: !0 })), []);
1338
1327
  }
1339
- function Pe(e) {
1328
+ function di(e) {
1329
+ return e;
1330
+ }
1331
+ function Te(e) {
1340
1332
  e.style.height = "0px";
1341
1333
  const t = Math.max(22, Math.min(e.scrollHeight, 140));
1342
1334
  e.style.height = `${t}px`, e.style.overflowY = e.scrollHeight > 140 ? "auto" : "hidden";
1343
1335
  }
1344
- function Ie(e, t = () => !0) {
1336
+ function De(e, t = () => !0) {
1345
1337
  e.scrollTop = e.scrollHeight, window.requestAnimationFrame(() => {
1346
1338
  t() && (e.scrollTop = e.scrollHeight);
1347
1339
  });
1348
1340
  }
1349
- function li(e) {
1341
+ function ci(e) {
1350
1342
  const t = e.messages[e.messages.length - 1];
1351
1343
  return [
1352
1344
  e.messages.length,
@@ -1357,64 +1349,64 @@ function li(e) {
1357
1349
  e.lastError ?? ""
1358
1350
  ].join(":");
1359
1351
  }
1360
- function pi(e) {
1352
+ function ui(e) {
1361
1353
  return e.messages.length > 0 || e.assistantDraft.length > 0 || e.isThinking || !!e.lastError;
1362
1354
  }
1363
- function si(e) {
1355
+ function gi(e) {
1364
1356
  return e.firstUserMessage?.trim() ? e.firstUserMessage : e.title?.trim() ? e.title : "Untitled chat";
1365
1357
  }
1366
- function di(e) {
1358
+ function hi(e) {
1367
1359
  const t = e.currentPage;
1368
1360
  if (typeof t?.url == "string" && t.url.trim())
1369
1361
  try {
1370
- const n = new URL(t.url);
1371
- return `${n.pathname || "/"}${n.search}`;
1362
+ const o = new URL(t.url);
1363
+ return `${o.pathname || "/"}${o.search}`;
1372
1364
  } catch {
1373
1365
  return t.url;
1374
1366
  }
1375
1367
  return typeof t?.origin == "string" && t.origin.trim() ? t.origin : "Current origin";
1376
1368
  }
1377
- function ci(e, t) {
1378
- const n = new Date(e).getTime();
1379
- if (!Number.isFinite(n))
1369
+ function mi(e, t) {
1370
+ const o = new Date(e).getTime();
1371
+ if (!Number.isFinite(o))
1380
1372
  return "now";
1381
- const o = Math.max(0, t - n), i = [
1373
+ const n = Math.max(0, t - o), i = [
1382
1374
  ["day", 864e5],
1383
1375
  ["hour", 36e5],
1384
1376
  ["min", 6e4]
1385
1377
  ];
1386
1378
  for (const [a, l] of i)
1387
- if (o >= l) {
1388
- const p = Math.max(1, Math.floor(o / l));
1379
+ if (n >= l) {
1380
+ const p = Math.max(1, Math.floor(n / l));
1389
1381
  return a === "min" ? `${p} min` : `${p} ${a}${p === 1 ? "" : "s"}`;
1390
1382
  }
1391
1383
  return "now";
1392
1384
  }
1393
- function ui(e, t, n, o, i) {
1394
- e.appendChild(yi()), e.appendChild(
1395
- gi(
1385
+ function bi(e, t, o, n, i) {
1386
+ e.appendChild(Si()), e.appendChild(
1387
+ fi(
1396
1388
  t,
1397
- n,
1398
1389
  o,
1390
+ n,
1399
1391
  i
1400
1392
  )
1401
1393
  ), e.appendChild(
1402
- qe(
1394
+ Ve(
1403
1395
  "pluno-pa-widget__close",
1404
1396
  "Close",
1405
- vi(16),
1397
+ Ei(16),
1406
1398
  !0
1407
1399
  )
1408
- ), e.appendChild(hi(n));
1400
+ ), e.appendChild(wi(o));
1409
1401
  }
1410
- function gi(e, t, n, o) {
1402
+ function fi(e, t, o, n) {
1411
1403
  const i = document.createElement("form");
1412
- if (i.className = "pluno-pa-widget__launcher", o && i.classList.add("pluno-pa-widget__launcher--minimizable"), n) {
1404
+ if (i.className = "pluno-pa-widget__launcher", n && i.classList.add("pluno-pa-widget__launcher--minimizable"), o) {
1413
1405
  const l = document.createElement("button");
1414
1406
  l.type = "button", l.className = "pluno-pa-widget__launcher-drag-handle", l.setAttribute("aria-label", "Move Pluno launcher"), l.title = "Move Pluno launcher", i.appendChild(l);
1415
1407
  }
1416
1408
  i.appendChild(
1417
- Sn(
1409
+ In(
1418
1410
  "pluno-pa-widget__scribble-spirals--launcher",
1419
1411
  10
1420
1412
  )
@@ -1425,118 +1417,118 @@ function gi(e, t, n, o) {
1425
1417
  )
1426
1418
  );
1427
1419
  const a = document.createElement("input");
1428
- if (a.className = "pluno-pa-widget__launcher-input", a.type = "text", a.placeholder = e, a.setAttribute("aria-label", e), i.appendChild(a), o) {
1420
+ if (a.className = "pluno-pa-widget__launcher-input", a.type = "text", a.placeholder = e, a.setAttribute("aria-label", e), i.appendChild(a), n) {
1429
1421
  const l = document.createElement("button");
1430
1422
  l.type = "button", l.className = "pluno-pa-widget__launcher-minimize", l.textContent = "-", l.setAttribute("aria-label", "Minimize Pluno on this site"), l.title = "Minimize Pluno on this site", i.appendChild(l);
1431
1423
  }
1432
1424
  return i;
1433
1425
  }
1434
- function hi(e) {
1426
+ function wi(e) {
1435
1427
  const t = document.createElement("section");
1436
1428
  t.className = "pluno-pa-widget__panel", t.hidden = !0, t.appendChild(
1437
- Sn("pluno-pa-widget__scribble-spirals--panel", 16)
1429
+ In("pluno-pa-widget__scribble-spirals--panel", 16)
1438
1430
  );
1439
- const n = document.createElement("div");
1440
- n.className = "pluno-pa-widget__timeline-wrap";
1441
- const o = document.createElement("main");
1442
- o.className = "pluno-pa-widget__timeline", o.appendChild(fi(e));
1431
+ const o = document.createElement("div");
1432
+ o.className = "pluno-pa-widget__timeline-wrap";
1433
+ const n = document.createElement("main");
1434
+ n.className = "pluno-pa-widget__timeline", n.appendChild(vi(e));
1443
1435
  const i = document.createElement("div");
1444
- i.className = "pluno-pa-widget__timeline-bottom-sentinel", i.setAttribute("aria-hidden", "true"), o.appendChild(i), n.appendChild(o);
1436
+ i.className = "pluno-pa-widget__timeline-bottom-sentinel", i.setAttribute("aria-hidden", "true"), n.appendChild(i), o.appendChild(n);
1445
1437
  const a = document.createElement("div");
1446
- a.className = "pluno-pa-widget__active-users-counter", a.hidden = !0, n.appendChild(a);
1438
+ a.className = "pluno-pa-widget__active-users-counter", a.hidden = !0, o.appendChild(a);
1447
1439
  const l = document.createElement("button");
1448
- l.type = "button", l.className = "pluno-pa-widget__timeline-jump", l.textContent = "New messages ↓", l.hidden = !0, n.appendChild(l);
1440
+ l.type = "button", l.className = "pluno-pa-widget__timeline-jump", l.textContent = "New messages ↓", l.hidden = !0, o.appendChild(l);
1449
1441
  const p = document.createElement("div");
1450
1442
  return p.className = "pluno-pa-widget__top-actions", p.appendChild(
1451
- qe(
1443
+ Ve(
1452
1444
  "pluno-pa-widget__history",
1453
1445
  "Recent chats",
1454
- Ei(),
1446
+ Li(),
1455
1447
  !0
1456
1448
  )
1457
- ), n.appendChild(p), n.appendChild(bi()), t.appendChild(n), t.appendChild(mi()), t;
1449
+ ), o.appendChild(p), o.appendChild(xi()), t.appendChild(o), t.appendChild(_i()), t;
1458
1450
  }
1459
- function mi() {
1451
+ function _i() {
1460
1452
  const e = document.createElement("form");
1461
1453
  e.className = "pluno-pa-widget__composer";
1462
1454
  const t = document.createElement("div");
1463
1455
  t.className = "pluno-pa-widget__billing-status", t.hidden = !0, e.appendChild(t);
1464
- const n = document.createElement("div");
1465
- n.className = "pluno-pa-widget__attachment-error", n.hidden = !0, e.appendChild(n);
1466
1456
  const o = document.createElement("div");
1467
- o.className = "pluno-pa-widget__attachments", o.hidden = !0, e.appendChild(o);
1457
+ o.className = "pluno-pa-widget__attachment-error", o.hidden = !0, e.appendChild(o);
1458
+ const n = document.createElement("div");
1459
+ n.className = "pluno-pa-widget__attachments", n.hidden = !0, e.appendChild(n);
1468
1460
  const i = document.createElement("div");
1469
1461
  i.className = "pluno-pa-widget__composer-inner";
1470
1462
  const a = document.createElement("input");
1471
- a.className = "pluno-pa-widget__attachment-input", a.type = "file", a.accept = ko, a.multiple = !0, a.tabIndex = -1, a.setAttribute("aria-hidden", "true"), i.appendChild(a);
1463
+ a.className = "pluno-pa-widget__attachment-input", a.type = "file", a.multiple = !0, a.tabIndex = -1, a.setAttribute("aria-hidden", "true"), i.appendChild(a);
1472
1464
  const l = document.createElement("button");
1473
- l.type = "button", l.className = "pluno-pa-widget__attach", l.setAttribute("aria-label", "Attach files"), l.title = "Attach files", l.appendChild(ki()), l.appendChild(Li()), i.appendChild(l);
1465
+ l.type = "button", l.className = "pluno-pa-widget__attach", l.setAttribute("aria-label", "Attach files"), l.title = "Attach files", l.appendChild(Ii()), l.appendChild(Ai()), i.appendChild(l);
1474
1466
  const p = document.createElement("textarea");
1475
1467
  p.className = "pluno-pa-widget__input", p.rows = 1, p.placeholder = "Ask for anything...", i.appendChild(p);
1476
1468
  const c = document.createElement("button");
1477
- c.type = "button", c.className = "pluno-pa-widget__send", c.setAttribute("aria-label", "Send"), c.appendChild(kn()), i.appendChild(c), e.appendChild(i);
1469
+ c.type = "button", c.className = "pluno-pa-widget__send", c.setAttribute("aria-label", "Send"), c.appendChild(An()), i.appendChild(c), e.appendChild(i);
1478
1470
  const u = document.createElement("div");
1479
1471
  u.className = "pluno-pa-widget__composer-meta";
1480
1472
  const d = document.createElement("a");
1481
1473
  d.className = "pluno-pa-widget__powered-by", d.href = "https://pluno.ai", d.target = "_blank", d.rel = "noopener noreferrer", d.textContent = "Powered by Pluno.ai.", u.appendChild(d);
1482
- const h = document.createElement("span");
1483
- return h.className = "pluno-pa-widget__ai-disclaimer", h.textContent = "AI can make mistakes. Verify outputs.", u.appendChild(h), e.appendChild(u), e;
1474
+ const g = document.createElement("span");
1475
+ return g.className = "pluno-pa-widget__ai-disclaimer", g.textContent = "AI can make mistakes. Verify outputs.", u.appendChild(g), e.appendChild(u), e;
1484
1476
  }
1485
- function bi() {
1477
+ function xi() {
1486
1478
  const e = document.createElement("section");
1487
1479
  e.className = "pluno-pa-widget__history-panel", e.hidden = !0, e.setAttribute("aria-label", "Recent chats");
1488
1480
  const t = document.createElement("div");
1489
1481
  t.className = "pluno-pa-widget__history-header";
1490
- const n = document.createElement("strong");
1491
- n.textContent = "Recent chats";
1492
- const o = qe(
1482
+ const o = document.createElement("strong");
1483
+ o.textContent = "Recent chats";
1484
+ const n = Ve(
1493
1485
  "pluno-pa-widget__history-close",
1494
1486
  "Close recent chats",
1495
- Si(),
1487
+ Pi(),
1496
1488
  !1
1497
1489
  );
1498
- t.append(n, o);
1490
+ t.append(o, n);
1499
1491
  const i = document.createElement("div");
1500
1492
  i.className = "pluno-pa-widget__history-list";
1501
1493
  const a = document.createElement("p");
1502
1494
  return a.className = "pluno-pa-widget__history-status", a.hidden = !0, e.append(t, i, a), e;
1503
1495
  }
1504
- function fi(e) {
1496
+ function vi(e) {
1505
1497
  const t = document.createElement("div");
1506
1498
  return t.className = "pluno-pa-widget__empty-state", t.appendChild(
1507
1499
  se(
1508
1500
  "pluno-pa-widget__character--empty",
1509
1501
  e
1510
1502
  )
1511
- ), t.appendChild(Cn()), t;
1503
+ ), t.appendChild(kn()), t;
1512
1504
  }
1513
- function Cn() {
1505
+ function kn() {
1514
1506
  const e = document.createElement("div");
1515
1507
  return e.className = "pluno-pa-widget__empty", e.appendChild(document.createTextNode("Hey there, I'm Pluno 👋")), e.appendChild(document.createElement("br")), e.appendChild(document.createTextNode("What do you want to do today?")), e;
1516
1508
  }
1517
- function wi(e, t) {
1509
+ function Ln(e, t) {
1518
1510
  e.replaceChildren(), e.setAttribute(
1519
1511
  "aria-label",
1520
1512
  `${t.toLocaleString("en-US")} users currently active`
1521
1513
  );
1522
- const n = document.createElement("span");
1523
- n.className = "pluno-pa-widget__active-users-counter-dot", n.setAttribute("aria-hidden", "true"), e.appendChild(n), e.appendChild(
1514
+ const o = document.createElement("span");
1515
+ o.className = "pluno-pa-widget__active-users-counter-dot", o.setAttribute("aria-hidden", "true"), e.appendChild(o), e.appendChild(
1524
1516
  document.createTextNode(
1525
1517
  `${t.toLocaleString("en-US")} users currently active`
1526
1518
  )
1527
1519
  );
1528
1520
  }
1529
1521
  function se(e, t) {
1530
- const n = `pluno-pa-character-${$t}`;
1531
- $t += 1;
1532
- const o = t.scribbleStyle ? xi(t.accentColor, n) : _i(t.accentColor, n), i = e.split(/\s+/).filter(Boolean);
1533
- return o.setAttribute(
1522
+ const o = `pluno-pa-character-${Kt}`;
1523
+ Kt += 1;
1524
+ const n = t.scribbleStyle ? Ci(t.accentColor, o) : yi(t.accentColor, o), i = e.split(/\s+/).filter(Boolean);
1525
+ return n.setAttribute(
1534
1526
  "class",
1535
1527
  i.includes("pluno-pa-widget__character") ? e : `pluno-pa-widget__character ${e}`
1536
- ), o.setAttribute("aria-hidden", "true"), o.setAttribute("focusable", "false"), o.removeAttribute("role"), o.removeAttribute("aria-label"), o;
1528
+ ), n.setAttribute("aria-hidden", "true"), n.setAttribute("focusable", "false"), n.removeAttribute("role"), n.removeAttribute("aria-label"), n;
1537
1529
  }
1538
- function _i(e, t) {
1539
- const n = Xn(e), o = {
1530
+ function yi(e, t) {
1531
+ const o = to(e), n = {
1540
1532
  boltFill: `${t}-boltFill`,
1541
1533
  boltEdge: `${t}-boltEdge`,
1542
1534
  boltGlow: `${t}-boltGlow`,
@@ -1547,171 +1539,171 @@ function _i(e, t) {
1547
1539
  eyeShadow: `${t}-eyeShadow`,
1548
1540
  pupilGloss: `${t}-pupilGloss`,
1549
1541
  boltClip: `${t}-boltClip`
1550
- }, i = En(), a = m(i, "defs"), l = m(a, "linearGradient", {
1551
- id: o.boltFill,
1542
+ }, i = Pn(), a = m(i, "defs"), l = m(a, "linearGradient", {
1543
+ id: n.boltFill,
1552
1544
  x1: "420",
1553
1545
  y1: "180",
1554
1546
  x2: "790",
1555
1547
  y2: "1040",
1556
1548
  gradientUnits: "userSpaceOnUse"
1557
1549
  });
1558
- M(l, "0", n.top), M(l, "0.36", n.middle), M(l, "0.72", n.bottom), M(l, "1", n.bottom);
1550
+ R(l, "0", o.top), R(l, "0.36", o.middle), R(l, "0.72", o.bottom), R(l, "1", o.bottom);
1559
1551
  const p = m(a, "linearGradient", {
1560
- id: o.boltEdge,
1552
+ id: n.boltEdge,
1561
1553
  x1: "470",
1562
1554
  y1: "145",
1563
1555
  x2: "900",
1564
1556
  y2: "980",
1565
1557
  gradientUnits: "userSpaceOnUse"
1566
1558
  });
1567
- M(p, "0", n.edgeStart), M(p, "0.32", n.edgeMiddle), M(p, "0.78", n.edgeEnd), M(p, "1", n.edgeEnd);
1559
+ R(p, "0", o.edgeStart), R(p, "0.32", o.edgeMiddle), R(p, "0.78", o.edgeEnd), R(p, "1", o.edgeEnd);
1568
1560
  const c = m(a, "radialGradient", {
1569
- id: o.boltGlow,
1561
+ id: n.boltGlow,
1570
1562
  cx: "50%",
1571
1563
  cy: "22%",
1572
1564
  r: "82%"
1573
1565
  });
1574
- M(c, "0", n.glow, "0.72"), M(c, "0.5", n.middle, "0.44"), M(c, "1", n.bottom, "0");
1566
+ R(c, "0", o.glow, "0.72"), R(c, "0.5", o.middle, "0.44"), R(c, "1", o.bottom, "0");
1575
1567
  const u = m(a, "radialGradient", {
1576
- id: o.eyeWhite,
1568
+ id: n.eyeWhite,
1577
1569
  cx: "35%",
1578
1570
  cy: "25%",
1579
1571
  r: "70%"
1580
1572
  });
1581
- M(u, "0", "#ffffff"), M(u, "0.72", "#ffffff"), M(u, "1", "#e5e5e5");
1573
+ R(u, "0", "#ffffff"), R(u, "0.72", "#ffffff"), R(u, "1", "#e5e5e5");
1582
1574
  const d = m(a, "radialGradient", {
1583
- id: o.pupil,
1575
+ id: n.pupil,
1584
1576
  cx: "42%",
1585
1577
  cy: "38%",
1586
1578
  r: "65%"
1587
1579
  });
1588
- M(d, "0", "#2a1f10"), M(d, "0.52", "#080604"), M(d, "1", "#000000");
1589
- const h = m(a, "filter", {
1590
- id: o.softDropShadow,
1580
+ R(d, "0", "#2a1f10"), R(d, "0.52", "#080604"), R(d, "1", "#000000");
1581
+ const g = m(a, "filter", {
1582
+ id: n.softDropShadow,
1591
1583
  x: "-18%",
1592
1584
  y: "-12%",
1593
1585
  width: "136%",
1594
1586
  height: "136%",
1595
1587
  "color-interpolation-filters": "sRGB"
1596
1588
  });
1597
- m(h, "feDropShadow", {
1589
+ m(g, "feDropShadow", {
1598
1590
  dx: "0",
1599
1591
  dy: "12",
1600
1592
  stdDeviation: "18",
1601
- "flood-color": n.shadow,
1593
+ "flood-color": o.shadow,
1602
1594
  "flood-opacity": "0.24"
1603
1595
  });
1604
- const x = m(a, "filter", {
1605
- id: o.innerDepth,
1596
+ const S = m(a, "filter", {
1597
+ id: n.innerDepth,
1606
1598
  x: "-8%",
1607
1599
  y: "-8%",
1608
1600
  width: "116%",
1609
1601
  height: "116%",
1610
1602
  "color-interpolation-filters": "sRGB"
1611
1603
  });
1612
- m(x, "feGaussianBlur", {
1604
+ m(S, "feGaussianBlur", {
1613
1605
  in: "SourceAlpha",
1614
1606
  stdDeviation: "8",
1615
1607
  result: "blur"
1616
- }), m(x, "feOffset", {
1608
+ }), m(S, "feOffset", {
1617
1609
  dx: "-7",
1618
1610
  dy: "-9",
1619
1611
  result: "topLeft"
1620
- }), m(x, "feComposite", {
1612
+ }), m(S, "feComposite", {
1621
1613
  in: "topLeft",
1622
1614
  in2: "SourceAlpha",
1623
1615
  operator: "arithmetic",
1624
1616
  k2: "-1",
1625
1617
  k3: "1",
1626
1618
  result: "innerShadow"
1627
- }), m(x, "feColorMatrix", {
1619
+ }), m(S, "feColorMatrix", {
1628
1620
  in: "innerShadow",
1629
1621
  type: "matrix",
1630
1622
  values: "1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0.42 0",
1631
1623
  result: "innerLight"
1632
- }), m(x, "feBlend", {
1624
+ }), m(S, "feBlend", {
1633
1625
  in: "SourceGraphic",
1634
1626
  in2: "innerLight",
1635
1627
  mode: "screen"
1636
1628
  });
1637
- const y = m(a, "filter", {
1638
- id: o.eyeShadow,
1629
+ const f = m(a, "filter", {
1630
+ id: n.eyeShadow,
1639
1631
  x: "-24%",
1640
1632
  y: "-20%",
1641
1633
  width: "148%",
1642
1634
  height: "148%",
1643
1635
  "color-interpolation-filters": "sRGB"
1644
1636
  });
1645
- m(y, "feDropShadow", {
1637
+ m(f, "feDropShadow", {
1646
1638
  dx: "0",
1647
1639
  dy: "8",
1648
1640
  stdDeviation: "5",
1649
- "flood-color": n.shadow,
1641
+ "flood-color": o.shadow,
1650
1642
  "flood-opacity": "0.3"
1651
1643
  });
1652
- const P = m(a, "filter", {
1653
- id: o.pupilGloss,
1644
+ const F = m(a, "filter", {
1645
+ id: n.pupilGloss,
1654
1646
  x: "-15%",
1655
1647
  y: "-15%",
1656
1648
  width: "130%",
1657
1649
  height: "130%",
1658
1650
  "color-interpolation-filters": "sRGB"
1659
1651
  });
1660
- m(P, "feDropShadow", {
1652
+ m(F, "feDropShadow", {
1661
1653
  dx: "0",
1662
1654
  dy: "3",
1663
1655
  stdDeviation: "3",
1664
1656
  "flood-color": "#000000",
1665
1657
  "flood-opacity": "0.22"
1666
1658
  });
1667
- const T = m(a, "clipPath", { id: o.boltClip });
1668
- m(T, "path", { d: He });
1669
- const f = m(i, "g", {
1670
- filter: q(o.softDropShadow)
1659
+ const k = m(a, "clipPath", { id: n.boltClip });
1660
+ m(k, "path", { d: $e });
1661
+ const x = m(i, "g", {
1662
+ filter: q(n.softDropShadow)
1671
1663
  });
1672
- m(f, "path", {
1673
- d: He,
1674
- fill: q(o.boltEdge)
1664
+ m(x, "path", {
1665
+ d: $e,
1666
+ fill: q(n.boltEdge)
1675
1667
  });
1676
- const E = "M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z";
1677
- m(f, "path", {
1678
- d: E,
1679
- fill: q(o.boltFill),
1680
- filter: q(o.innerDepth)
1681
- }), m(f, "path", {
1682
- d: E,
1683
- fill: q(o.boltGlow),
1668
+ const v = "M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z";
1669
+ m(x, "path", {
1670
+ d: v,
1671
+ fill: q(n.boltFill),
1672
+ filter: q(n.innerDepth)
1673
+ }), m(x, "path", {
1674
+ d: v,
1675
+ fill: q(n.boltGlow),
1684
1676
  opacity: "0.74"
1685
1677
  });
1686
- const g = m(f, "g", {
1687
- "clip-path": q(o.boltClip),
1678
+ const h = m(x, "g", {
1679
+ "clip-path": q(n.boltClip),
1688
1680
  opacity: "0.42"
1689
1681
  });
1690
- m(g, "path", {
1682
+ m(h, "path", {
1691
1683
  d: "M523 181 C505 189 496 206 489 232 L400 594 C397 606 400 619 411 626",
1692
1684
  fill: "none",
1693
- stroke: n.highlight,
1685
+ stroke: o.highlight,
1694
1686
  "stroke-width": "22",
1695
1687
  "stroke-linecap": "round",
1696
1688
  opacity: "0.65"
1697
- }), m(g, "path", {
1689
+ }), m(h, "path", {
1698
1690
  d: "M556 685 L501 994",
1699
1691
  fill: "none",
1700
- stroke: n.highlight,
1692
+ stroke: o.highlight,
1701
1693
  "stroke-width": "20",
1702
1694
  "stroke-linecap": "round",
1703
1695
  opacity: "0.55"
1704
- }), m(g, "path", {
1696
+ }), m(h, "path", {
1705
1697
  d: "M858 160 C882 166 893 181 883 204",
1706
1698
  fill: "none",
1707
- stroke: n.inner,
1699
+ stroke: o.inner,
1708
1700
  "stroke-width": "18",
1709
1701
  "stroke-linecap": "round",
1710
1702
  opacity: "0.48"
1711
1703
  });
1712
- const S = m(i, "g", { filter: q(o.eyeShadow) });
1713
- return Kt(
1714
- S,
1704
+ const I = m(i, "g", { filter: q(n.eyeShadow) });
1705
+ return Qt(
1706
+ I,
1715
1707
  "rotate(-2 528 463)",
1716
1708
  "528",
1717
1709
  "463",
@@ -1719,9 +1711,9 @@ function _i(e, t) {
1719
1711
  "473",
1720
1712
  "557",
1721
1713
  "447",
1722
- o
1723
- ), Kt(
1724
- S,
1714
+ n
1715
+ ), Qt(
1716
+ I,
1725
1717
  "rotate(2 717 462)",
1726
1718
  "717",
1727
1719
  "462",
@@ -1729,17 +1721,17 @@ function _i(e, t) {
1729
1721
  "473",
1730
1722
  "728",
1731
1723
  "447",
1732
- o
1724
+ n
1733
1725
  ), i;
1734
1726
  }
1735
- function xi(e, t) {
1736
- const n = dn(e), o = {
1727
+ function Ci(e, t) {
1728
+ const o = hn(e), n = {
1737
1729
  clip: `${t}-scribbleBoltClip`,
1738
1730
  wobble: `${t}-scribbleBoltWobble`
1739
- }, i = En(), a = m(i, "defs"), l = m(a, "clipPath", { id: o.clip });
1740
- m(l, "path", { d: He });
1731
+ }, i = Pn(), a = m(i, "defs"), l = m(a, "clipPath", { id: n.clip });
1732
+ m(l, "path", { d: $e });
1741
1733
  const p = m(a, "filter", {
1742
- id: o.wobble,
1734
+ id: n.wobble,
1743
1735
  x: "-10%",
1744
1736
  y: "-10%",
1745
1737
  width: "120%",
@@ -1759,25 +1751,25 @@ function xi(e, t) {
1759
1751
  xChannelSelector: "R",
1760
1752
  yChannelSelector: "G"
1761
1753
  });
1762
- const c = m(i, "g", { filter: q(o.wobble) }), u = m(c, "g", {
1763
- "clip-path": q(o.clip)
1754
+ const c = m(i, "g", { filter: q(n.wobble) }), u = m(c, "g", {
1755
+ "clip-path": q(n.clip)
1764
1756
  });
1765
1757
  return m(u, "path", {
1766
- d: Kn(),
1758
+ d: eo(),
1767
1759
  fill: "none",
1768
- stroke: n,
1760
+ stroke: o,
1769
1761
  "stroke-width": "56",
1770
1762
  "stroke-linecap": "round",
1771
1763
  "stroke-linejoin": "round",
1772
1764
  opacity: "0.9",
1773
1765
  transform: "rotate(-14 627 600)"
1774
1766
  }), m(c, "path", {
1775
- d: He,
1767
+ d: $e,
1776
1768
  fill: "none",
1777
- stroke: Ge,
1769
+ stroke: qe,
1778
1770
  "stroke-width": "18",
1779
1771
  "stroke-linejoin": "round"
1780
- }), Xt(
1772
+ }), en(
1781
1773
  c,
1782
1774
  "rotate(-2 528 463)",
1783
1775
  "528",
@@ -1786,7 +1778,7 @@ function xi(e, t) {
1786
1778
  "473",
1787
1779
  "557",
1788
1780
  "447"
1789
- ), Xt(
1781
+ ), en(
1790
1782
  c,
1791
1783
  "rotate(2 717 462)",
1792
1784
  "717",
@@ -1797,17 +1789,17 @@ function xi(e, t) {
1797
1789
  "447"
1798
1790
  ), i;
1799
1791
  }
1800
- function En() {
1801
- return v("svg", {
1802
- xmlns: wn,
1792
+ function Pn() {
1793
+ return C("svg", {
1794
+ xmlns: vn,
1803
1795
  viewBox: "0 0 1254 1254"
1804
1796
  });
1805
1797
  }
1806
- function Kt(e, t, n, o, i, a, l, p, c) {
1798
+ function Qt(e, t, o, n, i, a, l, p, c) {
1807
1799
  const u = m(e, "g", { transform: t });
1808
1800
  m(u, "ellipse", {
1809
- cx: n,
1810
- cy: o,
1801
+ cx: o,
1802
+ cy: n,
1811
1803
  rx: "73",
1812
1804
  ry: "80",
1813
1805
  fill: q(c.eyeWhite)
@@ -1825,22 +1817,22 @@ function Kt(e, t, n, o, i, a, l, p, c) {
1825
1817
  fill: "#ffffff"
1826
1818
  });
1827
1819
  }
1828
- function Xt(e, t, n, o, i, a, l, p) {
1820
+ function en(e, t, o, n, i, a, l, p) {
1829
1821
  const c = m(e, "g", { transform: t });
1830
1822
  m(c, "ellipse", {
1831
- cx: n,
1832
- cy: o,
1823
+ cx: o,
1824
+ cy: n,
1833
1825
  rx: "73",
1834
1826
  ry: "80",
1835
1827
  fill: "#ffffff",
1836
- stroke: Ge,
1828
+ stroke: qe,
1837
1829
  "stroke-width": "13"
1838
1830
  }), m(c, "ellipse", {
1839
1831
  cx: i,
1840
1832
  cy: a,
1841
1833
  rx: "45",
1842
1834
  ry: "53",
1843
- fill: Ge
1835
+ fill: qe
1844
1836
  }), m(c, "circle", {
1845
1837
  cx: l,
1846
1838
  cy: p,
@@ -1848,49 +1840,49 @@ function Xt(e, t, n, o, i, a, l, p) {
1848
1840
  fill: "#ffffff"
1849
1841
  });
1850
1842
  }
1851
- function m(e, t, n = {}) {
1852
- const o = v(t, n);
1853
- return e.appendChild(o), o;
1843
+ function m(e, t, o = {}) {
1844
+ const n = C(t, o);
1845
+ return e.appendChild(n), n;
1854
1846
  }
1855
- function M(e, t, n, o) {
1856
- const i = { offset: t, "stop-color": n };
1857
- o !== void 0 && (i["stop-opacity"] = o), m(e, "stop", i);
1847
+ function R(e, t, o, n) {
1848
+ const i = { offset: t, "stop-color": o };
1849
+ n !== void 0 && (i["stop-opacity"] = n), m(e, "stop", i);
1858
1850
  }
1859
1851
  function q(e) {
1860
1852
  return `url(#${e})`;
1861
1853
  }
1862
- function qe(e, t, n, o) {
1854
+ function Ve(e, t, o, n) {
1863
1855
  const i = document.createElement("button");
1864
- return i.type = "button", i.className = e, i.setAttribute("aria-label", t), i.title = t, i.hidden = o, i.appendChild(n), i;
1856
+ return i.type = "button", i.className = e, i.setAttribute("aria-label", t), i.title = t, i.hidden = n, i.appendChild(o), i;
1865
1857
  }
1866
- function yi() {
1867
- const e = v("svg", {
1858
+ function Si() {
1859
+ const e = C("svg", {
1868
1860
  class: "pluno-pa-widget__scribble-defs",
1869
1861
  "aria-hidden": "true",
1870
1862
  focusable: "false",
1871
1863
  width: "0",
1872
1864
  height: "0"
1873
- }), t = v("defs");
1874
- return t.appendChild(lt("pluno-pa-scribble-wobble", "2", "12")), t.appendChild(
1875
- lt("pluno-pa-scribble-wobble-2", "5", "15")
1865
+ }), t = C("defs");
1866
+ return t.appendChild(st("pluno-pa-scribble-wobble", "2", "12")), t.appendChild(
1867
+ st("pluno-pa-scribble-wobble-2", "5", "15")
1876
1868
  ), t.appendChild(
1877
- lt("pluno-pa-scribble-wobble-3", "9", "19")
1869
+ st("pluno-pa-scribble-wobble-3", "9", "19")
1878
1870
  ), e.appendChild(t), e;
1879
1871
  }
1880
- function Sn(e, t) {
1881
- const n = t * Ft + Ht * 2, o = v("svg", {
1872
+ function In(e, t) {
1873
+ const o = t * $t + qt * 2, n = C("svg", {
1882
1874
  class: `pluno-pa-widget__scribble-spirals ${e}`,
1883
- viewBox: `0 0 ${n} ${Fo}`,
1875
+ viewBox: `0 0 ${o} ${Go}`,
1884
1876
  preserveAspectRatio: "xMidYMid meet",
1885
1877
  "aria-hidden": "true",
1886
1878
  focusable: "false"
1887
1879
  });
1888
1880
  for (let i = 0; i < t; i += 1) {
1889
- const a = Gt[i % Gt.length], l = v("g", {
1890
- transform: `translate(${Ht + i * Ft} 0)`
1881
+ const a = jt[i % jt.length], l = C("g", {
1882
+ transform: `translate(${qt + i * $t} 0)`
1891
1883
  });
1892
1884
  l.appendChild(
1893
- v("ellipse", {
1885
+ C("ellipse", {
1894
1886
  cx: a.ellipseCx,
1895
1887
  cy: a.ellipseCy,
1896
1888
  rx: a.ellipseRx,
@@ -1901,35 +1893,35 @@ function Sn(e, t) {
1901
1893
  opacity: "0.8"
1902
1894
  })
1903
1895
  ), l.appendChild(
1904
- v("path", {
1896
+ C("path", {
1905
1897
  d: a.path,
1906
1898
  fill: "none",
1907
1899
  stroke: "#2c2a1e",
1908
1900
  "stroke-width": a.pathStrokeWidth,
1909
1901
  "stroke-linecap": "round"
1910
1902
  })
1911
- ), o.appendChild(l);
1903
+ ), n.appendChild(l);
1912
1904
  }
1913
- return o;
1905
+ return n;
1914
1906
  }
1915
- function lt(e, t, n) {
1916
- const o = v("filter", {
1907
+ function st(e, t, o) {
1908
+ const n = C("filter", {
1917
1909
  id: e,
1918
1910
  x: "-8%",
1919
1911
  y: "-8%",
1920
1912
  width: "116%",
1921
1913
  height: "116%"
1922
1914
  });
1923
- return o.appendChild(
1924
- v("feTurbulence", {
1915
+ return n.appendChild(
1916
+ C("feTurbulence", {
1925
1917
  type: "fractalNoise",
1926
1918
  baseFrequency: "0.012 0.028",
1927
1919
  numOctaves: "3",
1928
1920
  seed: t,
1929
1921
  result: "stroke-noise"
1930
1922
  })
1931
- ), o.appendChild(
1932
- v("feDisplacementMap", {
1923
+ ), n.appendChild(
1924
+ C("feDisplacementMap", {
1933
1925
  in: "SourceGraphic",
1934
1926
  in2: "stroke-noise",
1935
1927
  scale: "3.5",
@@ -1937,26 +1929,26 @@ function lt(e, t, n) {
1937
1929
  yChannelSelector: "G",
1938
1930
  result: "warped"
1939
1931
  })
1940
- ), o.appendChild(
1941
- v("feTurbulence", {
1932
+ ), n.appendChild(
1933
+ C("feTurbulence", {
1942
1934
  type: "fractalNoise",
1943
1935
  baseFrequency: "0.7",
1944
1936
  numOctaves: "1",
1945
- seed: n,
1937
+ seed: o,
1946
1938
  result: "ink-noise"
1947
1939
  })
1948
- ), o.appendChild(
1949
- v("feDisplacementMap", {
1940
+ ), n.appendChild(
1941
+ C("feDisplacementMap", {
1950
1942
  in: "warped",
1951
1943
  in2: "ink-noise",
1952
1944
  scale: "0.9",
1953
1945
  xChannelSelector: "R",
1954
1946
  yChannelSelector: "G"
1955
1947
  })
1956
- ), o;
1948
+ ), n;
1957
1949
  }
1958
- function vi(e) {
1959
- const t = ee(
1950
+ function Ei(e) {
1951
+ const t = te(
1960
1952
  "0 0 24 24",
1961
1953
  e,
1962
1954
  e,
@@ -1964,10 +1956,10 @@ function vi(e) {
1964
1956
  "currentColor",
1965
1957
  "2.25"
1966
1958
  );
1967
- return t.appendChild(v("path", { d: "m6 9 6 6 6-6" })), t;
1959
+ return t.appendChild(C("path", { d: "m6 9 6 6 6-6" })), t;
1968
1960
  }
1969
- function Ci() {
1970
- const e = ee(
1961
+ function ki() {
1962
+ const e = te(
1971
1963
  "0 0 24 24",
1972
1964
  17,
1973
1965
  17,
@@ -1976,17 +1968,17 @@ function Ci() {
1976
1968
  "2.25"
1977
1969
  );
1978
1970
  return e.appendChild(
1979
- v("path", {
1971
+ C("path", {
1980
1972
  d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
1981
1973
  })
1982
1974
  ), e.appendChild(
1983
- v("path", {
1975
+ C("path", {
1984
1976
  d: "M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4Z"
1985
1977
  })
1986
1978
  ), e;
1987
1979
  }
1988
- function Ei() {
1989
- const e = ee(
1980
+ function Li() {
1981
+ const e = te(
1990
1982
  "0 0 24 24",
1991
1983
  17,
1992
1984
  17,
@@ -1994,10 +1986,10 @@ function Ei() {
1994
1986
  "currentColor",
1995
1987
  "2.25"
1996
1988
  );
1997
- return e.appendChild(v("path", { d: "M3 12a9 9 0 1 0 3-6.7" })), e.appendChild(v("path", { d: "M3 4v5h5" })), e.appendChild(v("path", { d: "M12 7v5l3 2" })), e;
1989
+ return e.appendChild(C("path", { d: "M3 12a9 9 0 1 0 3-6.7" })), e.appendChild(C("path", { d: "M3 4v5h5" })), e.appendChild(C("path", { d: "M12 7v5l3 2" })), e;
1998
1990
  }
1999
- function Si() {
2000
- const e = ee(
1991
+ function Pi() {
1992
+ const e = te(
2001
1993
  "0 0 24 24",
2002
1994
  15,
2003
1995
  15,
@@ -2005,10 +1997,10 @@ function Si() {
2005
1997
  "currentColor",
2006
1998
  "2.4"
2007
1999
  );
2008
- return e.appendChild(v("path", { d: "M18 6 6 18" })), e.appendChild(v("path", { d: "m6 6 12 12" })), e;
2000
+ return e.appendChild(C("path", { d: "M18 6 6 18" })), e.appendChild(C("path", { d: "m6 6 12 12" })), e;
2009
2001
  }
2010
- function kn() {
2011
- const e = ee(
2002
+ function An() {
2003
+ const e = te(
2012
2004
  "0 0 24 24",
2013
2005
  14,
2014
2006
  14,
@@ -2017,11 +2009,11 @@ function kn() {
2017
2009
  "2.75"
2018
2010
  );
2019
2011
  return e.appendChild(
2020
- v("line", { x1: "12", y1: "19", x2: "12", y2: "5" })
2021
- ), e.appendChild(v("polyline", { points: "5 12 12 5 19 12" })), e;
2012
+ C("line", { x1: "12", y1: "19", x2: "12", y2: "5" })
2013
+ ), e.appendChild(C("polyline", { points: "5 12 12 5 19 12" })), e;
2022
2014
  }
2023
- function ki() {
2024
- const e = ee(
2015
+ function Ii() {
2016
+ const e = te(
2025
2017
  "0 0 24 24",
2026
2018
  16,
2027
2019
  16,
@@ -2033,18 +2025,18 @@ function ki() {
2033
2025
  "class",
2034
2026
  "pluno-pa-widget__paperclip-icon pluno-pa-widget__paperclip-icon--standard"
2035
2027
  ), e.appendChild(
2036
- v("path", {
2028
+ C("path", {
2037
2029
  d: "m21.4 11.6-8.5 8.5a6 6 0 0 1-8.5-8.5l9.2-9.2a4 4 0 0 1 5.7 5.7l-9.2 9.2a2 2 0 0 1-2.8-2.8l8.5-8.5"
2038
2030
  })
2039
2031
  ), e;
2040
2032
  }
2041
- function Li() {
2042
- const e = ee("0 0 24 24", 19, 19, "none", "currentColor");
2033
+ function Ai() {
2034
+ const e = te("0 0 24 24", 19, 19, "none", "currentColor");
2043
2035
  return e.setAttribute(
2044
2036
  "class",
2045
2037
  "pluno-pa-widget__paperclip-icon pluno-pa-widget__paperclip-icon--scribble"
2046
2038
  ), e.appendChild(
2047
- v("path", {
2039
+ C("path", {
2048
2040
  d: "M7.1 15.6 15.2 7.7c1.9-1.8 4.9.8 2.7 3.2l-8.8 8.3c-3.2 3-8-1.1-4.6-4.8l10.1-9.1",
2049
2041
  stroke: "currentColor",
2050
2042
  "stroke-width": "2",
@@ -2053,10 +2045,10 @@ function Li() {
2053
2045
  })
2054
2046
  ), e;
2055
2047
  }
2056
- function Ai() {
2057
- const e = ee("0 0 24 24", 18, 18, "currentColor");
2048
+ function Ni() {
2049
+ const e = te("0 0 24 24", 18, 18, "currentColor");
2058
2050
  return e.appendChild(
2059
- v("rect", {
2051
+ C("rect", {
2060
2052
  x: "6",
2061
2053
  y: "6",
2062
2054
  width: "12",
@@ -2065,8 +2057,8 @@ function Ai() {
2065
2057
  })
2066
2058
  ), e;
2067
2059
  }
2068
- function Pi() {
2069
- const e = ee(
2060
+ function Ti() {
2061
+ const e = te(
2070
2062
  "0 0 24 24",
2071
2063
  12,
2072
2064
  12,
@@ -2074,10 +2066,10 @@ function Pi() {
2074
2066
  "currentColor",
2075
2067
  "2.4"
2076
2068
  );
2077
- return e.appendChild(v("path", { d: "M18 6 6 18" })), e.appendChild(v("path", { d: "m6 6 12 12" })), e;
2069
+ return e.appendChild(C("path", { d: "M18 6 6 18" })), e.appendChild(C("path", { d: "m6 6 12 12" })), e;
2078
2070
  }
2079
- function Ii() {
2080
- const e = ee(
2071
+ function Di() {
2072
+ const e = te(
2081
2073
  "0 0 24 24",
2082
2074
  13,
2083
2075
  13,
@@ -2086,7 +2078,7 @@ function Ii() {
2086
2078
  "2.25"
2087
2079
  );
2088
2080
  return e.appendChild(
2089
- v("rect", {
2081
+ C("rect", {
2090
2082
  width: "14",
2091
2083
  height: "14",
2092
2084
  x: "8",
@@ -2095,379 +2087,341 @@ function Ii() {
2095
2087
  ry: "2"
2096
2088
  })
2097
2089
  ), e.appendChild(
2098
- v("path", {
2090
+ C("path", {
2099
2091
  d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
2100
2092
  })
2101
2093
  ), e;
2102
2094
  }
2103
- function ee(e, t, n, o, i, a) {
2095
+ function te(e, t, o, n, i, a) {
2104
2096
  const l = {
2105
2097
  viewBox: e,
2106
2098
  width: String(t),
2107
- height: String(n),
2108
- fill: o,
2099
+ height: String(o),
2100
+ fill: n,
2109
2101
  "aria-hidden": "true"
2110
2102
  };
2111
- return i && (l.stroke = i, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"), a && (l["stroke-width"] = a), v("svg", l);
2103
+ return i && (l.stroke = i, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"), a && (l["stroke-width"] = a), C("svg", l);
2112
2104
  }
2113
- function v(e, t = {}) {
2114
- const n = document.createElementNS(wn, e);
2115
- for (const [o, i] of Object.entries(t))
2116
- n.setAttribute(o, i);
2117
- return n;
2105
+ function C(e, t = {}) {
2106
+ const o = document.createElementNS(vn, e);
2107
+ for (const [n, i] of Object.entries(t))
2108
+ o.setAttribute(n, i);
2109
+ return o;
2118
2110
  }
2119
- function Zt(e) {
2111
+ function tn(e) {
2120
2112
  for (const t of ["keydown", "keypress", "keyup"])
2121
- e.addEventListener(t, (n) => {
2122
- n.stopPropagation();
2113
+ e.addEventListener(t, (o) => {
2114
+ o.stopPropagation();
2123
2115
  });
2124
2116
  }
2125
- function Ti(e, t, n) {
2117
+ function Ri(e, t, o) {
2126
2118
  e.replaceChildren(), e.hidden = t.length === 0;
2127
- for (const [o, i] of t.entries()) {
2119
+ for (const [n, i] of t.entries()) {
2128
2120
  const a = document.createElement("div");
2129
- a.className = "pluno-pa-widget__attachment", a.appendChild(Ni(i));
2121
+ a.className = "pluno-pa-widget__attachment", a.appendChild(Mi(i));
2130
2122
  const l = document.createElement("span");
2131
2123
  l.textContent = i.name, a.appendChild(l);
2132
2124
  const p = document.createElement("button");
2133
- p.type = "button", p.setAttribute("aria-label", `Remove ${i.name}`), p.appendChild(Pi()), p.addEventListener("click", () => n(o)), a.appendChild(p), e.appendChild(a);
2125
+ p.type = "button", p.setAttribute("aria-label", `Remove ${i.name}`), p.appendChild(Ti()), p.addEventListener("click", () => o(n)), a.appendChild(p), e.appendChild(a);
2134
2126
  }
2135
2127
  }
2136
- function Ni(e) {
2137
- if (Ln(e)) {
2128
+ function Mi(e) {
2129
+ const t = vt(e), o = Nn(e);
2130
+ if (t === "image" && o) {
2138
2131
  const n = document.createElement("img");
2139
- return n.src = e.dataUrl, n.alt = "", n.setAttribute("aria-hidden", "true"), n;
2132
+ return n.src = o, n.alt = "", n.setAttribute("aria-hidden", "true"), n.addEventListener("error", () => n.replaceWith(J(e))), n;
2140
2133
  }
2141
- const t = document.createElement("span");
2142
- return t.className = "pluno-pa-widget__attachment-file", t.textContent = "PDF", t;
2134
+ if (t === "video" && o) {
2135
+ const n = document.createElement("video");
2136
+ return n.src = o, n.muted = !0, n.preload = "metadata", n.setAttribute("aria-hidden", "true"), n.addEventListener("error", () => n.replaceWith(J(e))), n.addEventListener("stalled", () => n.replaceWith(J(e))), n;
2137
+ }
2138
+ return J(e);
2143
2139
  }
2144
- function Di(e) {
2145
- if (Ln(e)) {
2146
- const i = document.createElement("img");
2147
- return i.src = e.dataUrl, i.alt = e.name, i;
2140
+ function zi(e) {
2141
+ const t = vt(e), o = Nn(e);
2142
+ if (t === "image" && o) {
2143
+ const n = document.createElement("img");
2144
+ return n.className = "pluno-pa-widget__message-attachment-preview", n.src = o, n.alt = e.name, n.addEventListener("error", () => n.replaceWith(J(e, "message"))), n;
2148
2145
  }
2149
- const t = document.createElement("div");
2150
- t.className = "pluno-pa-widget__message-attachment-file";
2151
- const n = document.createElement("span");
2152
- n.textContent = "PDF";
2153
- const o = document.createElement("strong");
2154
- return o.textContent = e.name, t.append(n, o), t;
2146
+ if (t === "pdf" && o) {
2147
+ const n = document.createElement("object");
2148
+ return n.className = "pluno-pa-widget__message-attachment-preview pluno-pa-widget__message-attachment-preview--pdf", n.data = o, n.type = "application/pdf", n.setAttribute("aria-label", e.name), n.addEventListener("error", () => n.replaceWith(J(e, "message"))), n.appendChild(J(e, "message")), n;
2149
+ }
2150
+ if (t === "video" && o) {
2151
+ const n = document.createElement("video");
2152
+ return n.className = "pluno-pa-widget__message-attachment-preview", n.src = o, n.muted = !0, n.preload = "metadata", n.addEventListener("error", () => n.replaceWith(J(e, "message"))), n.addEventListener("stalled", () => n.replaceWith(J(e, "message"))), n;
2153
+ }
2154
+ return J(e, "message");
2155
2155
  }
2156
- function Ln(e) {
2157
- return e.mimeType.startsWith("image/");
2156
+ function J(e, t = "composer") {
2157
+ if (t === "composer") {
2158
+ const a = document.createElement("span");
2159
+ return a.className = "pluno-pa-widget__attachment-file", a.textContent = nn(e), a;
2160
+ }
2161
+ const o = document.createElement("div");
2162
+ o.className = "pluno-pa-widget__message-attachment-file";
2163
+ const n = document.createElement("span");
2164
+ n.textContent = nn(e);
2165
+ const i = document.createElement("strong");
2166
+ return i.textContent = e.name, o.append(n, i), o;
2158
2167
  }
2159
- function Ri(e) {
2160
- return e === "application/pdf" ? "document.pdf" : "image";
2168
+ function vt(e) {
2169
+ return e.mimeType.startsWith("image/") ? "image" : e.mimeType === "application/pdf" ? "pdf" : e.mimeType.startsWith("video/") ? "video" : "file";
2161
2170
  }
2162
- async function Mi(e) {
2163
- if (!e)
2164
- return [];
2165
- const t = Array.from(e);
2166
- if (t.length > We)
2167
- throw new Error(
2168
- `Attach up to ${We} files per message.`
2169
- );
2170
- return Promise.all(
2171
- t.map(async (n) => {
2172
- const o = zi(n);
2173
- if (!o)
2174
- throw new Error(
2175
- "Pluno supports PNG, JPEG, WebP, non-animated GIF, and PDF files."
2176
- );
2177
- if (n.size > So)
2178
- throw new Error("Each Pluno attachment can be up to 10 MB.");
2179
- if (o === "image/gif") {
2180
- const i = new Uint8Array(await qi(n));
2181
- if (Oi(i))
2182
- throw new Error("Pluno supports non-animated GIF images.");
2183
- }
2184
- return {
2185
- name: n.name || Ri(o),
2186
- mimeType: o,
2187
- sizeBytes: n.size,
2188
- dataUrl: Bi(
2189
- await ji(n),
2190
- o
2191
- )
2192
- };
2193
- })
2194
- );
2171
+ function Nn(e) {
2172
+ return "previewUrl" in e && e.previewUrl ? e.previewUrl : e.fileUrl ?? "";
2195
2173
  }
2196
- function zi(e) {
2197
- if (mn.has(e.type))
2198
- return e.type;
2199
- const t = e.name.toLowerCase();
2200
- return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
2174
+ function nn(e) {
2175
+ const t = vt(e);
2176
+ return t === "image" ? "IMG" : t === "pdf" ? "PDF" : t === "video" ? "VID" : "FILE";
2201
2177
  }
2202
2178
  function Bi(e, t) {
2203
- const n = `data:${t};base64,`;
2204
- return e.startsWith(n) ? e : e.replace(/^data:[^;]*;base64,/, n);
2205
- }
2206
- function Oi(e) {
2207
- if (e.length < 14 || !Ui(e))
2208
- return !1;
2209
- const t = e[10];
2210
- let n = 13;
2211
- t & 128 && (n += 3 * 2 ** ((t & 7) + 1));
2212
- let o = 0;
2213
- for (; n < e.length; ) {
2214
- const i = e[n];
2215
- if (n += 1, i === 59)
2216
- return !1;
2217
- if (i === 33) {
2218
- n += 1, n = Jt(e, n);
2219
- continue;
2220
- }
2221
- if (i !== 44)
2222
- return !1;
2223
- if (o += 1, o > 1)
2224
- return !0;
2225
- if (n + 9 >= e.length)
2226
- return !1;
2227
- const a = e[n + 8];
2228
- if (n += 9, a & 128 && (n += 3 * 2 ** ((a & 7) + 1)), n >= e.length)
2229
- return !1;
2230
- n += 1, n = Jt(e, n);
2231
- }
2232
- return !1;
2179
+ return t ? Array.from(t).map((n) => ({
2180
+ ...e.createLocalAttachment(n),
2181
+ previewUrl: Ui(n)
2182
+ })) : [];
2233
2183
  }
2234
2184
  function Ui(e) {
2235
- return e[0] === 71 && e[1] === 73 && e[2] === 70 && e[3] === 56 && (e[4] === 55 || e[4] === 57) && e[5] === 97;
2236
- }
2237
- function Jt(e, t) {
2238
- for (; t < e.length; ) {
2239
- const n = e[t];
2240
- if (t += 1, n === 0)
2241
- return t;
2242
- t += n;
2243
- }
2244
- return t;
2185
+ return typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : void 0;
2245
2186
  }
2246
- function Oe(e) {
2187
+ function He(e) {
2247
2188
  return !!(e && Array.from(e.types).includes("Files"));
2248
2189
  }
2249
- function pt(e, t, n = null) {
2250
- if (!e || !ht(t, n)) {
2190
+ function dt(e, t, o = null) {
2191
+ if (!e || !ft(t, o)) {
2251
2192
  e && (e.hidden = !0, e.replaceChildren());
2252
2193
  return;
2253
2194
  }
2254
- e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status", J(t) || wt(n) ? e.appendChild(
2255
- Fi(t, n)
2256
- ) : An(t) && e.appendChild(Hi(t));
2195
+ e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status", Q(t) || yt(o) ? e.appendChild(
2196
+ Oi(t, o)
2197
+ ) : Tn(t) && e.appendChild(Fi(t));
2257
2198
  }
2258
- function Fi(e, t) {
2259
- const n = document.createElement("div");
2260
- n.className = "pluno-pa-widget__billing-action-card";
2261
- const o = e.limitExceeded || t === "limit_exceeded", i = document.createElement("strong");
2262
- i.textContent = o ? "Credits used up" : "Billing needs attention", n.appendChild(i);
2199
+ function Oi(e, t) {
2200
+ const o = document.createElement("div");
2201
+ o.className = "pluno-pa-widget__billing-action-card";
2202
+ const n = e.limitExceeded || t === "limit_exceeded", i = document.createElement("strong");
2203
+ i.textContent = n ? "Credits used up" : "Billing needs attention", o.appendChild(i);
2263
2204
  const a = document.createElement("span");
2264
- return a.textContent = o ? "Earn bonus credits or upgrade to keep using Pluno on this product." : e.paymentIssue ?? "Open billing to keep using Pluno.", n.appendChild(a), n.appendChild(
2265
- Pn(
2205
+ return a.textContent = n ? "Earn bonus credits or upgrade to keep using Pluno on this product." : e.paymentIssue ?? "Open billing to keep using Pluno.", o.appendChild(a), o.appendChild(
2206
+ Dn(
2266
2207
  e,
2267
2208
  "Upgrade plan",
2268
2209
  "pluno-pa-widget__billing-action-card-actions"
2269
2210
  )
2270
- ), n;
2211
+ ), o;
2271
2212
  }
2272
- function Hi(e) {
2213
+ function Fi(e) {
2273
2214
  const t = document.createElement("div");
2274
2215
  t.className = "pluno-pa-widget__billing-action-card pluno-pa-widget__billing-action-card--low";
2275
- const n = document.createElement("strong");
2276
- n.textContent = "Credits running low", t.appendChild(n);
2277
- const o = document.createElement("span");
2278
- return o.textContent = Wi(e) ?? "Credits are running low for this period.", t.appendChild(o), t.appendChild(
2279
- Pn(
2216
+ const o = document.createElement("strong");
2217
+ o.textContent = "Credits running low", t.appendChild(o);
2218
+ const n = document.createElement("span");
2219
+ return n.textContent = Wi(e) ?? "Credits are running low for this period.", t.appendChild(n), t.appendChild(
2220
+ Dn(
2280
2221
  e,
2281
2222
  "Upgrade",
2282
2223
  "pluno-pa-widget__billing-action-card-actions"
2283
2224
  )
2284
2225
  ), t;
2285
2226
  }
2286
- function ht(e, t) {
2287
- return e !== null && (J(e) || An(e) || wt(t));
2227
+ function ft(e, t) {
2228
+ return e !== null && (Q(e) || Tn(e) || yt(t));
2288
2229
  }
2289
- function Qt(e, t, n) {
2290
- return ht(t, n) || Gi(t) ? !0 : !ht(e, n);
2230
+ function on(e, t, o) {
2231
+ return ft(t, o) || Hi(t) ? !0 : !ft(e, o);
2291
2232
  }
2292
- function Gi(e) {
2293
- return e != null && (e.creditsUsed !== null || e.creditLimit !== null || e.creditsRemaining !== null || J(e));
2233
+ function Hi(e) {
2234
+ return e != null && (e.creditsUsed !== null || e.creditLimit !== null || e.creditsRemaining !== null || Q(e));
2294
2235
  }
2295
- function J(e) {
2236
+ function Q(e) {
2296
2237
  return e?.limitExceeded === !0 || !!e?.paymentIssue;
2297
2238
  }
2298
- function wt(e) {
2239
+ function yt(e) {
2299
2240
  return e === "limit_exceeded" || e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required";
2300
2241
  }
2301
- function An(e) {
2302
- return !J(e) && e.creditLimit !== null && e.creditLimit > 0 && e.creditsRemaining !== null && e.creditsRemaining > 0 && e.creditsRemaining / e.creditLimit <= 0.2;
2242
+ function Tn(e) {
2243
+ return !Q(e) && e.creditLimit !== null && e.creditLimit > 0 && e.creditsRemaining !== null && e.creditsRemaining > 0 && e.creditsRemaining / e.creditLimit <= 0.2;
2303
2244
  }
2304
2245
  function Wi(e) {
2305
- return e.creditsRemaining === null ? null : `${$i(e.creditsRemaining)} credits left`;
2246
+ return e.creditsRemaining === null ? null : `${Gi(e.creditsRemaining)} credits left`;
2306
2247
  }
2307
- function $i(e) {
2248
+ function Gi(e) {
2308
2249
  return new Intl.NumberFormat("en-US", {
2309
2250
  maximumFractionDigits: 0
2310
2251
  }).format(Math.ceil(e));
2311
2252
  }
2312
- function Pn(e, t, n) {
2313
- const o = document.createElement("div");
2314
- return o.className = n, o.appendChild(
2315
- en(t, e.pricingUrl)
2316
- ), o.appendChild(
2317
- en("Earn credits", e.earnCreditsUrl)
2318
- ), o;
2253
+ function Dn(e, t, o) {
2254
+ const n = document.createElement("div");
2255
+ return n.className = o, n.appendChild(
2256
+ an(t, e.pricingUrl)
2257
+ ), n.appendChild(
2258
+ an("Earn credits", e.earnCreditsUrl)
2259
+ ), n;
2319
2260
  }
2320
- function en(e, t) {
2321
- const n = document.createElement("button");
2322
- if (n.type = "button", e === "Earn credits") {
2323
- const o = document.createElement("span");
2324
- o.className = "pluno-pa-widget__billing-action-card-earn-credits-label", o.textContent = e, n.appendChild(o);
2261
+ function an(e, t) {
2262
+ const o = document.createElement("button");
2263
+ if (o.type = "button", e === "Earn credits") {
2264
+ const n = document.createElement("span");
2265
+ n.className = "pluno-pa-widget__billing-action-card-earn-credits-label", n.textContent = e, o.appendChild(n);
2325
2266
  } else
2326
- n.textContent = e;
2327
- return n.disabled = t.trim().length === 0, n.addEventListener("click", () => {
2267
+ o.textContent = e;
2268
+ return o.disabled = t.trim().length === 0, o.addEventListener("click", () => {
2328
2269
  t.trim().length !== 0 && window.open(t, "_blank", "noopener,noreferrer");
2329
- }), n;
2330
- }
2331
- function qi(e) {
2332
- return new Promise((t, n) => {
2333
- const o = new FileReader();
2334
- o.addEventListener("load", () => {
2335
- if (o.result instanceof ArrayBuffer) {
2336
- t(o.result);
2337
- return;
2338
- }
2339
- n(new Error("Failed to read file"));
2340
- }), o.addEventListener("error", () => {
2341
- n(o.error ?? new Error("Failed to read file"));
2342
- }), o.readAsArrayBuffer(e);
2343
- });
2270
+ }), o;
2344
2271
  }
2345
- function ji(e) {
2346
- return new Promise((t, n) => {
2347
- const o = new FileReader();
2348
- o.addEventListener("load", () => {
2349
- if (typeof o.result == "string") {
2350
- t(o.result);
2351
- return;
2352
- }
2353
- n(new Error("Failed to read file"));
2354
- }), o.addEventListener("error", () => {
2355
- n(o.error ?? new Error("Failed to read file"));
2356
- }), o.readAsDataURL(e);
2357
- });
2358
- }
2359
- function tn(e, t) {
2272
+ function ct(e, t) {
2360
2273
  return e.messages.filter(
2361
- (o) => !In(o)
2274
+ (n) => !Rn(n)
2362
2275
  ).length === 0 && !e.assistantDraft && !e.lastError && !e.isThinking && !t;
2363
2276
  }
2364
- function Vi(e, t, n, o, i, a, l, p, c, u, d, h, x, y, P) {
2365
- const T = Yi(a), f = T.filter(
2366
- (_) => !In(_)
2367
- ), E = e.scrollTop;
2368
- e.replaceChildren(), Nn(n, a.isThinking), i.hidden = !p, p && l !== null && wi(i, l);
2369
- const g = f.length > 0 || !!a.assistantDraft || a.isThinking;
2370
- if (o(g), f.length === 0 && !a.assistantDraft && !a.lastError && !a.isThinking) {
2277
+ function $i(e, t, o, n, i, a, l, p, c, u, d, g, S, f, F, k) {
2278
+ const x = Ki(a), v = x.filter(
2279
+ (_) => !Rn(_)
2280
+ ), h = e.scrollTop, I = [], T = /* @__PURE__ */ new Set(), P = (_) => {
2281
+ I.push(_);
2282
+ };
2283
+ zn(o, a.isThinking), i.hidden = !p, p && l !== null && Ln(i, l);
2284
+ const ke = v.length > 0 || !!a.assistantDraft || a.isThinking;
2285
+ if (n(ke), v.length === 0 && !a.assistantDraft && !a.lastError && !a.isThinking) {
2371
2286
  const _ = document.createElement("div");
2372
2287
  _.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
2373
- const N = document.createElement("div");
2374
- N.className = "pluno-pa-widget__empty-hero";
2375
- const F = se(
2288
+ const M = document.createElement("div");
2289
+ M.className = "pluno-pa-widget__empty-hero";
2290
+ const ae = se(
2376
2291
  "pluno-pa-widget__character--empty",
2377
- x()
2292
+ f()
2378
2293
  );
2379
- N.appendChild(F), _.appendChild(N), _.appendChild(Cn());
2380
- const H = document.createElement("div");
2381
- if (H.className = a.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", a.starterPrompts.length === 0 && !a.starterPromptsLoading && H.setAttribute("aria-hidden", "true"), a.starterPrompts.length > 0)
2382
- for (const L of a.starterPrompts) {
2383
- const I = document.createElement("button");
2384
- I.type = "button", I.className = "pluno-pa-widget__starter-prompt", I.textContent = `"${L}"`, I.addEventListener("click", () => {
2385
- y(L);
2386
- }), H.appendChild(I);
2294
+ M.appendChild(ae), _.appendChild(M), _.appendChild(kn());
2295
+ const L = document.createElement("div");
2296
+ if (L.className = a.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", a.starterPrompts.length === 0 && !a.starterPromptsLoading && L.setAttribute("aria-hidden", "true"), a.starterPrompts.length > 0)
2297
+ for (const A of a.starterPrompts) {
2298
+ const y = document.createElement("button");
2299
+ y.type = "button", y.className = "pluno-pa-widget__starter-prompt", y.textContent = `"${A}"`, y.addEventListener("click", () => {
2300
+ F(A);
2301
+ }), L.appendChild(y);
2387
2302
  }
2388
2303
  else if (a.starterPromptsLoading) {
2389
- const L = document.createElement("button");
2390
- L.type = "button", L.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder pluno-pa-widget__starter-prompt--loading", L.disabled = !0, L.tabIndex = -1, L.textContent = "Generating example tasks...", H.appendChild(L);
2304
+ const A = document.createElement("button");
2305
+ A.type = "button", A.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder pluno-pa-widget__starter-prompt--loading", A.disabled = !0, A.tabIndex = -1, A.textContent = "Generating example tasks...", L.appendChild(A);
2391
2306
  } else
2392
- for (let L = 0; L < Lo; L += 1) {
2393
- const I = document.createElement("button");
2394
- I.type = "button", I.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder", I.disabled = !0, I.tabIndex = -1, I.textContent = "", H.appendChild(I);
2307
+ for (let A = 0; A < Ao; A += 1) {
2308
+ const y = document.createElement("button");
2309
+ y.type = "button", y.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder", y.disabled = !0, y.tabIndex = -1, y.textContent = "", L.appendChild(y);
2395
2310
  }
2396
- _.appendChild(H), e.appendChild(_), e.appendChild(t);
2311
+ _.appendChild(L), g.clear(), P(_), P(t), rn(e, I);
2397
2312
  return;
2398
2313
  }
2399
- let S = null, k = null, R = [];
2400
- const Ce = f.some(mt), b = () => {
2401
- if (R.length === 0)
2314
+ let b = null, D = null, de = [];
2315
+ const ce = v.some(wt), we = () => {
2316
+ if (de.length === 0)
2402
2317
  return !1;
2403
2318
  const _ = ia(
2404
- R,
2319
+ de,
2405
2320
  d,
2406
- h,
2407
- x()
2321
+ S,
2322
+ f()
2408
2323
  );
2409
- return e.appendChild(_), S = null, k = _, R = [], !0;
2324
+ return P(_), b = null, D = _, de = [], !0;
2410
2325
  };
2411
- for (let _ = 0; _ < f.length; _ += 1) {
2412
- const N = f[_];
2413
- if (N.role === "tool") {
2414
- R.push(N);
2326
+ for (let _ = 0; _ < v.length; _ += 1) {
2327
+ const M = v[_];
2328
+ if (M.role === "tool") {
2329
+ de.push(M);
2415
2330
  continue;
2416
2331
  }
2417
- if (mt(N)) {
2418
- if (b()) {
2419
- const A = bt();
2420
- e.appendChild(A), S = null, k = A;
2332
+ if (wt(M)) {
2333
+ if (we()) {
2334
+ const B = _t();
2335
+ P(B), b = null, D = B;
2421
2336
  } else {
2422
- const A = an(x());
2423
- e.appendChild(A), S = null, k = A;
2337
+ const B = sn(f());
2338
+ P(B), b = null, D = B;
2424
2339
  }
2425
2340
  continue;
2426
2341
  }
2427
- if (N.role === "system")
2342
+ if (M.role === "system")
2428
2343
  continue;
2429
- const F = b(), H = oa(N.content);
2430
- if (N.role === "assistant" && !F) {
2431
- const be = Tn(x());
2432
- e.appendChild(be), S = null, k = be;
2344
+ const ae = we(), L = oa(M.content);
2345
+ if (M.role === "assistant" && !ae) {
2346
+ const y = Mn(f());
2347
+ P(y), b = null, D = y;
2433
2348
  }
2434
- const L = document.createElement("div");
2435
- L.className = `pluno-pa-widget__message pluno-pa-widget__message--${N.role}`, N.role === "assistant" ? ra(L, H) : L.textContent = H, N.role === "user" && N.attachments?.length && L.appendChild(Ki(N.attachments));
2436
- const I = document.createElement("div");
2437
- I.className = "pluno-pa-widget__message-actions", I.appendChild(Xi(H)), L.appendChild(I), e.appendChild(L), S = L, k = null;
2349
+ const A = qi(M, L, g, T);
2350
+ P(A), b = A, D = null;
2438
2351
  }
2439
- const ie = b();
2440
- if (a.isThinking && !a.assistantDraft && !Ce)
2441
- if (ie) {
2442
- const _ = bt();
2443
- e.appendChild(_), S = null, k = _;
2352
+ const G = we();
2353
+ if (a.isThinking && !a.assistantDraft && !ce)
2354
+ if (G) {
2355
+ const _ = _t();
2356
+ P(_), b = null, D = _;
2444
2357
  } else {
2445
- const _ = an(x());
2446
- e.appendChild(_), S = null, k = _;
2358
+ const _ = sn(f());
2359
+ P(_), b = null, D = _;
2447
2360
  }
2448
2361
  if (a.lastError) {
2449
2362
  const _ = document.createElement("div");
2450
- _.className = "pluno-pa-widget__error", _.textContent = a.lastError, e.appendChild(_), S = _, k = null;
2363
+ _.className = "pluno-pa-widget__error", _.textContent = a.lastError, P(_), b = _, D = null;
2451
2364
  }
2452
- const ae = P && !a.isThinking ? eo(T) : null;
2453
- if (P && ae && !P.dismissedCandidateIds.has(ae.id)) {
2454
- const _ = Zi(ae, {
2455
- isDrafting: P.draftingCandidateId === ae.id,
2456
- error: P.error,
2457
- characterIconOptions: P.characterIconOptions,
2458
- onDraft: P.onDraft,
2459
- onDismiss: P.onDismiss,
2460
- onDisable: P.onDisable
2365
+ const ie = k && !a.isThinking ? ao(x) : null;
2366
+ if (k && ie && !k.dismissedCandidateIds.has(ie.id)) {
2367
+ const _ = Zi(ie, {
2368
+ isDrafting: k.draftingCandidateId === ie.id,
2369
+ error: k.error,
2370
+ characterIconOptions: k.characterIconOptions,
2371
+ onDraft: k.onDraft,
2372
+ onDismiss: k.onDismiss,
2373
+ onDisable: k.onDisable
2461
2374
  });
2462
- e.appendChild(_), P.onSeen(ae), S = null, k = _;
2375
+ P(_), k.onSeen(ie), b = null, D = _;
2463
2376
  }
2464
- S?.classList.add(
2465
- "pluno-pa-widget__message--bottom-reserve"
2466
- ), k?.classList.add(
2467
- "pluno-pa-widget__bottom-reserve-compact"
2468
- ), e.appendChild(t), c ? Ie(e, u) : e.scrollTop = E;
2377
+ b?.classList.add("pluno-pa-widget__message--bottom-reserve"), D?.classList.add("pluno-pa-widget__bottom-reserve-compact"), P(t), Vi(g, T), rn(e, I), c ? De(e, u) : e.scrollTop = h;
2378
+ }
2379
+ function qi(e, t, o, n) {
2380
+ const i = ji(e, t), a = i ? o.get(i) : void 0;
2381
+ if (i && a)
2382
+ return a.classList.remove("pluno-pa-widget__message--bottom-reserve"), n.add(i), a;
2383
+ const l = document.createElement("div");
2384
+ l.className = `pluno-pa-widget__message pluno-pa-widget__message--${e.role}`, e.role === "assistant" ? ra(l, t) : l.textContent = t, e.role === "user" && e.attachments?.length && l.appendChild(Yi(e.attachments));
2385
+ const p = document.createElement("div");
2386
+ return p.className = "pluno-pa-widget__message-actions", p.appendChild(Xi(t)), l.appendChild(p), i && (o.set(i, l), n.add(i)), l;
2387
+ }
2388
+ function ji(e, t) {
2389
+ return e.role !== "user" || !e.attachments?.length ? null : JSON.stringify({
2390
+ id: e.id,
2391
+ content: t,
2392
+ attachments: e.attachments.map((o) => {
2393
+ const { previewUrl: n } = o;
2394
+ return {
2395
+ id: o.id ?? null,
2396
+ name: o.name,
2397
+ mimeType: o.mimeType,
2398
+ sizeBytes: o.sizeBytes,
2399
+ previewUrl: n ?? null,
2400
+ fileUrl: o.fileUrl ?? null,
2401
+ gcsPath: o.gcsPath ?? null
2402
+ };
2403
+ })
2404
+ });
2469
2405
  }
2470
- function Yi(e) {
2406
+ function Vi(e, t) {
2407
+ for (const o of e.keys())
2408
+ t.has(o) || e.delete(o);
2409
+ }
2410
+ function rn(e, t) {
2411
+ let o = e.firstChild;
2412
+ for (const n of t) {
2413
+ if (n === o) {
2414
+ o = o.nextSibling;
2415
+ continue;
2416
+ }
2417
+ e.insertBefore(n, o);
2418
+ }
2419
+ for (; o; ) {
2420
+ const n = o;
2421
+ o = o.nextSibling, e.removeChild(n);
2422
+ }
2423
+ }
2424
+ function Ki(e) {
2471
2425
  if (!e.assistantDraft)
2472
2426
  return [...e.messages];
2473
2427
  const t = {
@@ -2481,22 +2435,22 @@ function Yi(e) {
2481
2435
  };
2482
2436
  if (!t.respondsToUserMessageId)
2483
2437
  return [...e.messages, t];
2484
- const n = e.messages.findIndex(
2438
+ const o = e.messages.findIndex(
2485
2439
  (a) => a.role === "user" && a.id === t.respondsToUserMessageId
2486
2440
  );
2487
- if (n === -1)
2441
+ if (o === -1)
2488
2442
  return [...e.messages, t];
2489
- const o = e.messages.findIndex(
2490
- (a, l) => l > n && a.role !== "user" && a.respondsToUserMessageId === t.respondsToUserMessageId && nn(a, t) && mt(a)
2443
+ const n = e.messages.findIndex(
2444
+ (a, l) => l > o && a.role !== "user" && a.respondsToUserMessageId === t.respondsToUserMessageId && ln(a, t) && wt(a)
2491
2445
  );
2492
- if (o !== -1)
2446
+ if (n !== -1)
2493
2447
  return [
2494
- ...e.messages.slice(0, o),
2448
+ ...e.messages.slice(0, n),
2495
2449
  t,
2496
- ...e.messages.slice(o + 1)
2450
+ ...e.messages.slice(n + 1)
2497
2451
  ];
2498
- let i = n + 1;
2499
- for (; i < e.messages.length && e.messages[i].role !== "user" && e.messages[i].respondsToUserMessageId === t.respondsToUserMessageId && nn(e.messages[i], t); )
2452
+ let i = o + 1;
2453
+ for (; i < e.messages.length && e.messages[i].role !== "user" && e.messages[i].respondsToUserMessageId === t.respondsToUserMessageId && ln(e.messages[i], t); )
2500
2454
  i += 1;
2501
2455
  return [
2502
2456
  ...e.messages.slice(0, i),
@@ -2504,49 +2458,49 @@ function Yi(e) {
2504
2458
  ...e.messages.slice(i)
2505
2459
  ];
2506
2460
  }
2507
- function mt(e) {
2461
+ function wt(e) {
2508
2462
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2509
2463
  }
2510
- function nn(e, t) {
2464
+ function ln(e, t) {
2511
2465
  return !e.runId || !t.runId ? !0 : e.runId === t.runId;
2512
2466
  }
2513
- function on(e, t, n, o, i, a, l, p) {
2514
- e.replaceChildren(), Nn(t, !1), t.disabled = !0, n(!1);
2467
+ function pn(e, t, o, n, i, a, l, p) {
2468
+ e.replaceChildren(), zn(t, !1), t.disabled = !0, o(!1);
2515
2469
  const c = document.createElement("div");
2516
2470
  c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
2517
2471
  const u = se(
2518
2472
  "pluno-pa-widget__character--empty",
2519
- o()
2473
+ n()
2520
2474
  );
2521
2475
  c.appendChild(u);
2522
2476
  const d = document.createElement("div");
2523
2477
  if (d.className = "pluno-pa-widget__empty", d.textContent = i, c.appendChild(d), l) {
2524
- const h = document.createElement("a");
2525
- h.className = "pluno-pa-widget__login", h.href = l, h.target = "_blank", h.rel = "noopener noreferrer", h.textContent = a, c.appendChild(h);
2478
+ const g = document.createElement("a");
2479
+ g.className = "pluno-pa-widget__login", g.href = l, g.target = "_blank", g.rel = "noopener noreferrer", g.textContent = a, c.appendChild(g);
2526
2480
  } else {
2527
- const h = document.createElement("button");
2528
- h.type = "button", h.className = "pluno-pa-widget__login", h.textContent = a, h.addEventListener("click", () => p?.()), c.appendChild(h);
2481
+ const g = document.createElement("button");
2482
+ g.type = "button", g.className = "pluno-pa-widget__login", g.textContent = a, g.addEventListener("click", () => p?.()), c.appendChild(g);
2529
2483
  }
2530
2484
  e.appendChild(c);
2531
2485
  }
2532
- function Ki(e) {
2486
+ function Yi(e) {
2533
2487
  const t = document.createElement("div");
2534
2488
  t.className = "pluno-pa-widget__message-attachments";
2535
- for (const n of e)
2536
- t.appendChild(Di(n));
2489
+ for (const o of e)
2490
+ t.appendChild(zi(o));
2537
2491
  return t;
2538
2492
  }
2539
2493
  function Xi(e) {
2540
2494
  const t = document.createElement("button");
2541
- return t.type = "button", t.className = "pluno-pa-widget__message-copy", t.setAttribute("aria-label", "Copy message"), t.title = "Copy message", t.appendChild(Ii()), t.addEventListener("click", (n) => {
2542
- n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(e);
2495
+ return t.type = "button", t.className = "pluno-pa-widget__message-copy", t.setAttribute("aria-label", "Copy message"), t.title = "Copy message", t.appendChild(Di()), t.addEventListener("click", (o) => {
2496
+ o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(e);
2543
2497
  }), t;
2544
2498
  }
2545
2499
  function Zi(e, t) {
2546
- const n = document.createElement("article");
2547
- n.className = "pluno-pa-widget__share-prompt";
2548
- const o = document.createElement("div");
2549
- o.className = "pluno-pa-widget__share-prompt-body", o.appendChild(
2500
+ const o = document.createElement("article");
2501
+ o.className = "pluno-pa-widget__share-prompt";
2502
+ const n = document.createElement("div");
2503
+ n.className = "pluno-pa-widget__share-prompt-body", n.appendChild(
2550
2504
  se(
2551
2505
  "pluno-pa-widget__share-prompt-icon",
2552
2506
  t.characterIconOptions
@@ -2561,7 +2515,7 @@ function Zi(e, t) {
2561
2515
  const d = document.createElement("span");
2562
2516
  d.className = "pluno-pa-widget__share-prompt-error", d.textContent = t.error, i.appendChild(d);
2563
2517
  }
2564
- o.appendChild(i);
2518
+ n.appendChild(i);
2565
2519
  const p = document.createElement("div");
2566
2520
  p.className = "pluno-pa-widget__share-prompt-actions";
2567
2521
  const c = document.createElement("div");
@@ -2569,31 +2523,31 @@ function Zi(e, t) {
2569
2523
  const u = document.createElement("button");
2570
2524
  if (u.type = "button", u.disabled = t.isDrafting, u.addEventListener("click", () => {
2571
2525
  t.onDraft(e);
2572
- }), t.isDrafting ? (u.appendChild(ft()), u.appendChild(document.createTextNode("Drafting..."))) : u.textContent = "Draft a social post", c.appendChild(u), t.isDrafting)
2526
+ }), t.isDrafting ? (u.appendChild(xt()), u.appendChild(document.createTextNode("Drafting..."))) : u.textContent = "Draft a social post", c.appendChild(u), t.isDrafting)
2573
2527
  p.appendChild(c);
2574
2528
  else {
2575
2529
  const d = document.createElement("button");
2576
2530
  d.type = "button", d.className = "pluno-pa-widget__share-prompt-dismiss", d.setAttribute("aria-label", "Dismiss share prompt"), d.title = "Dismiss", d.textContent = "Dismiss", d.addEventListener("click", () => {
2577
2531
  t.onDismiss(e);
2578
2532
  }), c.appendChild(d), p.appendChild(c);
2579
- const h = document.createElement("button");
2580
- h.type = "button", h.className = "pluno-pa-widget__share-prompt-disable", h.textContent = "Don't ask again", h.addEventListener("click", () => {
2533
+ const g = document.createElement("button");
2534
+ g.type = "button", g.className = "pluno-pa-widget__share-prompt-disable", g.textContent = "Don't ask again", g.addEventListener("click", () => {
2581
2535
  t.onDisable(e);
2582
- }), p.appendChild(h);
2536
+ }), p.appendChild(g);
2583
2537
  }
2584
- return o.appendChild(p), n.appendChild(o), n;
2538
+ return n.appendChild(p), o.appendChild(n), o;
2585
2539
  }
2586
2540
  function Ji(e, t) {
2587
- const n = document.createElement("div");
2588
- n.className = "pluno-pa-widget__share-dialog-backdrop", n.addEventListener("click", (f) => {
2589
- f.target === n && t.onClose();
2541
+ const o = document.createElement("div");
2542
+ o.className = "pluno-pa-widget__share-dialog-backdrop", o.addEventListener("click", (x) => {
2543
+ x.target === o && t.onClose();
2590
2544
  });
2591
- const o = document.createElement("section");
2592
- o.className = "pluno-pa-widget__share-dialog", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.setAttribute("aria-label", "Draft a social post");
2545
+ const n = document.createElement("section");
2546
+ n.className = "pluno-pa-widget__share-dialog", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-label", "Draft a social post");
2593
2547
  const i = document.createElement("header"), a = document.createElement("strong");
2594
2548
  a.textContent = "Share this win", i.appendChild(a);
2595
2549
  const l = document.createElement("button");
2596
- l.type = "button", l.setAttribute("aria-label", "Close"), l.textContent = "×", l.addEventListener("click", t.onClose), i.appendChild(l), o.appendChild(i);
2550
+ l.type = "button", l.setAttribute("aria-label", "Close"), l.textContent = "×", l.addEventListener("click", t.onClose), i.appendChild(l), n.appendChild(i);
2597
2551
  const p = document.createElement("p");
2598
2552
  p.className = "pluno-pa-widget__share-dialog-status", p.hidden = !0;
2599
2553
  const c = document.createElement("div");
@@ -2602,53 +2556,53 @@ function Ji(e, t) {
2602
2556
  u.className = "pluno-pa-widget__share-dialog-step-header";
2603
2557
  const d = document.createElement("strong");
2604
2558
  d.textContent = "1) Copy Screenshot", u.appendChild(d);
2605
- const h = Qi(
2559
+ const g = Qi(
2606
2560
  "Copy Screenshot",
2607
2561
  async () => {
2608
2562
  try {
2609
- return await to(e.screenshotDataUrl ?? ""), p.textContent = "", p.hidden = !0, !0;
2563
+ return await ro(e.screenshotDataUrl ?? ""), p.textContent = "", p.hidden = !0, !0;
2610
2564
  } catch {
2611
2565
  return p.textContent = "Could not copy screenshot.", p.hidden = !1, !1;
2612
2566
  }
2613
2567
  }
2614
2568
  );
2615
- if (u.appendChild(h), c.appendChild(u), e.screenshotDataUrl) {
2616
- const f = document.createElement("div");
2617
- f.className = "pluno-pa-widget__share-dialog-screenshot";
2618
- const E = document.createElement("img");
2619
- E.src = e.screenshotDataUrl, E.alt = "Product page with Pluno open", f.appendChild(E), c.appendChild(f);
2569
+ if (u.appendChild(g), c.appendChild(u), e.screenshotDataUrl) {
2570
+ const x = document.createElement("div");
2571
+ x.className = "pluno-pa-widget__share-dialog-screenshot";
2572
+ const v = document.createElement("img");
2573
+ v.src = e.screenshotDataUrl, v.alt = "Product page with Pluno open", x.appendChild(v), c.appendChild(x);
2620
2574
  }
2621
- o.appendChild(c), o.appendChild(p);
2622
- const x = document.createElement("div");
2623
- x.className = "pluno-pa-widget__share-dialog-step";
2624
- const y = document.createElement("strong");
2625
- y.className = "pluno-pa-widget__share-dialog-step-title", y.textContent = "2) Share on", x.appendChild(y);
2626
- const P = document.createElement("p");
2627
- P.className = "pluno-pa-widget__share-dialog-hint", P.textContent = "Post draft opens prefilled on supported platforms.", x.appendChild(P);
2628
- const T = document.createElement("footer");
2629
- T.className = "pluno-pa-widget__share-dialog-platforms";
2630
- for (const f of ea(e)) {
2631
- const E = document.createElement("a");
2632
- E.href = f.href, E.target = "_blank", E.rel = "noopener noreferrer", E.title = f.label, E.setAttribute("aria-label", `Open ${f.label}`), E.appendChild(ta(f.id)), T.appendChild(E);
2575
+ n.appendChild(c), n.appendChild(p);
2576
+ const S = document.createElement("div");
2577
+ S.className = "pluno-pa-widget__share-dialog-step";
2578
+ const f = document.createElement("strong");
2579
+ f.className = "pluno-pa-widget__share-dialog-step-title", f.textContent = "2) Share on", S.appendChild(f);
2580
+ const F = document.createElement("p");
2581
+ F.className = "pluno-pa-widget__share-dialog-hint", F.textContent = "Post draft opens prefilled on supported platforms.", S.appendChild(F);
2582
+ const k = document.createElement("footer");
2583
+ k.className = "pluno-pa-widget__share-dialog-platforms";
2584
+ for (const x of ea(e)) {
2585
+ const v = document.createElement("a");
2586
+ v.href = x.href, v.target = "_blank", v.rel = "noopener noreferrer", v.title = x.label, v.setAttribute("aria-label", `Open ${x.label}`), v.appendChild(ta(x.id)), k.appendChild(v);
2633
2587
  }
2634
- if (x.appendChild(T), o.appendChild(x), t.socialPostRewardsUrl) {
2635
- const f = document.createElement("div");
2636
- f.className = "pluno-pa-widget__share-dialog-step";
2637
- const E = document.createElement("strong");
2638
- E.className = "pluno-pa-widget__share-dialog-step-title", E.textContent = "3) Submit post to get 2000 free credits!", f.appendChild(E);
2639
- const g = document.createElement("a");
2640
- g.className = "pluno-pa-widget__share-dialog-reward-link", g.href = t.socialPostRewardsUrl, g.target = "_blank", g.rel = "noopener noreferrer", g.appendChild(document.createTextNode("Submit post URL")), g.appendChild(na()), f.appendChild(g), o.appendChild(f);
2588
+ if (S.appendChild(k), n.appendChild(S), t.socialPostRewardsUrl) {
2589
+ const x = document.createElement("div");
2590
+ x.className = "pluno-pa-widget__share-dialog-step";
2591
+ const v = document.createElement("strong");
2592
+ v.className = "pluno-pa-widget__share-dialog-step-title", v.textContent = "3) Submit post to get 2000 free credits!", x.appendChild(v);
2593
+ const h = document.createElement("a");
2594
+ h.className = "pluno-pa-widget__share-dialog-reward-link", h.href = t.socialPostRewardsUrl, h.target = "_blank", h.rel = "noopener noreferrer", h.appendChild(document.createTextNode("Submit post URL")), h.appendChild(na()), x.appendChild(h), n.appendChild(x);
2641
2595
  }
2642
- return n.appendChild(o), n;
2596
+ return o.appendChild(n), o;
2643
2597
  }
2644
2598
  function Qi(e, t) {
2645
- const n = document.createElement("button");
2646
- return n.type = "button", n.className = "pluno-pa-widget__share-dialog-copy", n.textContent = e, n.addEventListener("click", async (o) => {
2647
- o.preventDefault(), o.stopPropagation(), await t() && (n.textContent = "Copied ✓");
2648
- }), n;
2599
+ const o = document.createElement("button");
2600
+ return o.type = "button", o.className = "pluno-pa-widget__share-dialog-copy", o.textContent = e, o.addEventListener("click", async (n) => {
2601
+ n.preventDefault(), n.stopPropagation(), await t() && (o.textContent = "Copied ✓");
2602
+ }), o;
2649
2603
  }
2650
2604
  function ea(e) {
2651
- const t = e.linkedinPost.trim(), n = e.xPost.trim();
2605
+ const t = e.linkedinPost.trim(), o = e.xPost.trim();
2652
2606
  return [
2653
2607
  {
2654
2608
  id: "linkedin",
@@ -2658,7 +2612,7 @@ function ea(e) {
2658
2612
  {
2659
2613
  id: "x",
2660
2614
  label: "X",
2661
- href: `https://twitter.com/intent/tweet?text=${encodeURIComponent(n)}`
2615
+ href: `https://twitter.com/intent/tweet?text=${encodeURIComponent(o)}`
2662
2616
  },
2663
2617
  {
2664
2618
  id: "instagram",
@@ -2690,9 +2644,9 @@ function ta(e) {
2690
2644
  "M22 10.7c.3-.1.7 0 .9.3.2.4.1.8-.2 1-.4.2-.8.1-1-.2-.2-.4-.1-.8.3-1.1Z"
2691
2645
  ), t);
2692
2646
  }
2693
- function U(e, t, n) {
2694
- const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
2695
- o.setAttribute("d", t), n && o.setAttribute("opacity", n), e.appendChild(o);
2647
+ function U(e, t, o) {
2648
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
2649
+ n.setAttribute("d", t), o && n.setAttribute("opacity", o), e.appendChild(n);
2696
2650
  }
2697
2651
  function na() {
2698
2652
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -2701,43 +2655,43 @@ function na() {
2701
2655
  "M18 13v5a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5"
2702
2656
  ), e;
2703
2657
  }
2704
- function In(e) {
2705
- return e.role === "tool" && e.toolName === un;
2658
+ function Rn(e) {
2659
+ return e.role === "tool" && e.toolName === bn;
2706
2660
  }
2707
2661
  function oa(e) {
2708
2662
  return e.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
2709
2663
  }
2710
- function ia(e, t, n, o) {
2664
+ function ia(e, t, o, n) {
2711
2665
  const i = document.createElement("article");
2712
2666
  i.className = "pluno-pa-widget__tool-group", i.title = new Date(
2713
2667
  e[e.length - 1].createdAt
2714
2668
  ).toLocaleString(), i.appendChild(
2715
2669
  se(
2716
2670
  "pluno-pa-widget__character--tool-group",
2717
- o
2671
+ n
2718
2672
  )
2719
2673
  );
2720
2674
  const a = document.createElement("details"), l = aa(e);
2721
2675
  a.open = t.has(l), i.classList.toggle("pluno-pa-widget__tool-group--open", a.open), a.addEventListener("toggle", () => {
2722
- i.classList.toggle("pluno-pa-widget__tool-group--open", a.open), a.open ? t.add(l) : t.delete(l), n();
2676
+ i.classList.toggle("pluno-pa-widget__tool-group--open", a.open), a.open ? t.add(l) : t.delete(l), o();
2723
2677
  });
2724
2678
  const p = document.createElement("summary");
2725
- p.className = "pluno-pa-widget__tool-summary", e.some((d) => d.loading) && p.appendChild(ft());
2679
+ p.className = "pluno-pa-widget__tool-summary", e.some((d) => d.loading) && p.appendChild(xt());
2726
2680
  const u = document.createElement("span");
2727
2681
  if (u.className = "pluno-pa-widget__tool-summary-title", u.textContent = e[e.length - 1].content || "Run tool", p.appendChild(u), a.appendChild(p), e.length > 0) {
2728
2682
  const d = document.createElement("div");
2729
2683
  d.className = "pluno-pa-widget__tool-lines";
2730
- for (const h of e) {
2731
- const x = document.createElement("div");
2732
- x.className = "pluno-pa-widget__tool-line", h.loading && x.appendChild(ft());
2733
- const y = document.createElement("span");
2734
- y.textContent = h.content || "Run tool", x.appendChild(y), d.appendChild(x);
2684
+ for (const g of e) {
2685
+ const S = document.createElement("div");
2686
+ S.className = "pluno-pa-widget__tool-line", g.loading && S.appendChild(xt());
2687
+ const f = document.createElement("span");
2688
+ f.textContent = g.content || "Run tool", S.appendChild(f), d.appendChild(S);
2735
2689
  }
2736
2690
  a.appendChild(d);
2737
2691
  }
2738
2692
  return i.appendChild(a), i;
2739
2693
  }
2740
- function Tn(e) {
2694
+ function Mn(e) {
2741
2695
  const t = document.createElement("article");
2742
2696
  return t.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker", t.appendChild(
2743
2697
  se(
@@ -2746,89 +2700,89 @@ function Tn(e) {
2746
2700
  )
2747
2701
  ), t;
2748
2702
  }
2749
- function an(e) {
2750
- const t = Tn(e);
2751
- return t.classList.add("pluno-pa-widget__thinking-marker"), t.appendChild(bt()), t;
2703
+ function sn(e) {
2704
+ const t = Mn(e);
2705
+ return t.classList.add("pluno-pa-widget__thinking-marker"), t.appendChild(_t()), t;
2752
2706
  }
2753
- function bt() {
2707
+ function _t() {
2754
2708
  const e = document.createElement("div");
2755
2709
  e.className = "pluno-pa-widget__status";
2756
2710
  const t = document.createElement("span");
2757
2711
  t.className = "pluno-pa-widget__thinking-dot", t.setAttribute("aria-hidden", "true"), e.appendChild(t);
2758
- const n = document.createElement("span");
2759
- return n.textContent = "Thinking...", e.appendChild(n), e;
2712
+ const o = document.createElement("span");
2713
+ return o.textContent = "Thinking...", e.appendChild(o), e;
2760
2714
  }
2761
2715
  function aa(e) {
2762
2716
  return `tools:${e[0]?.id ?? ""}`;
2763
2717
  }
2764
- function ft() {
2718
+ function xt() {
2765
2719
  const e = document.createElement("span");
2766
2720
  return e.className = "pluno-pa-widget__spinner", e.setAttribute("aria-hidden", "true"), e;
2767
2721
  }
2768
- function Nn(e, t) {
2769
- e.setAttribute("aria-label", t ? "Stop" : "Send"), e.classList.toggle("pluno-pa-widget__send--stop", t), e.replaceChildren(t ? Ai() : kn());
2722
+ function zn(e, t) {
2723
+ e.setAttribute("aria-label", t ? "Stop" : "Send"), e.classList.toggle("pluno-pa-widget__send--stop", t), e.replaceChildren(t ? Ni() : An());
2770
2724
  }
2771
2725
  function ra(e, t) {
2772
- const n = t.replace(/\r\n/g, `
2726
+ const o = t.replace(/\r\n/g, `
2773
2727
  `).split(`
2774
2728
  `);
2775
- let o = 0;
2776
- for (; o < n.length; ) {
2777
- const i = n[o];
2729
+ let n = 0;
2730
+ for (; n < o.length; ) {
2731
+ const i = o[n];
2778
2732
  if (!i.trim()) {
2779
- o += 1;
2733
+ n += 1;
2780
2734
  continue;
2781
2735
  }
2782
2736
  if (i.match(/^```(\w+)?\s*$/)) {
2783
2737
  const u = [];
2784
- for (o += 1; o < n.length && !/^```\s*$/.test(n[o]); )
2785
- u.push(n[o]), o += 1;
2786
- o += o < n.length ? 1 : 0;
2787
- const d = document.createElement("pre"), h = document.createElement("code");
2788
- h.textContent = u.join(`
2789
- `), d.appendChild(h), e.appendChild(d);
2738
+ for (n += 1; n < o.length && !/^```\s*$/.test(o[n]); )
2739
+ u.push(o[n]), n += 1;
2740
+ n += n < o.length ? 1 : 0;
2741
+ const d = document.createElement("pre"), g = document.createElement("code");
2742
+ g.textContent = u.join(`
2743
+ `), d.appendChild(g), e.appendChild(d);
2790
2744
  continue;
2791
2745
  }
2792
2746
  const l = i.match(/^(#{1,3})\s+(.+)$/);
2793
2747
  if (l) {
2794
2748
  const u = document.createElement(`h${l[1].length + 2}`);
2795
- Ue(u, l[2]), e.appendChild(u), o += 1;
2749
+ We(u, l[2]), e.appendChild(u), n += 1;
2796
2750
  continue;
2797
2751
  }
2798
2752
  if (/^\s*[-*+]\s+/.test(i)) {
2799
2753
  const u = document.createElement("ul");
2800
- for (; o < n.length && /^\s*[-*+]\s+/.test(n[o]); ) {
2754
+ for (; n < o.length && /^\s*[-*+]\s+/.test(o[n]); ) {
2801
2755
  const d = document.createElement("li");
2802
- Ue(d, n[o].replace(/^\s*[-*+]\s+/, "")), u.appendChild(d), o += 1;
2756
+ We(d, o[n].replace(/^\s*[-*+]\s+/, "")), u.appendChild(d), n += 1;
2803
2757
  }
2804
2758
  e.appendChild(u);
2805
2759
  continue;
2806
2760
  }
2807
2761
  if (/^\s*\d+\.\s+/.test(i)) {
2808
2762
  const u = document.createElement("ol");
2809
- for (; o < n.length && /^\s*\d+\.\s+/.test(n[o]); ) {
2763
+ for (; n < o.length && /^\s*\d+\.\s+/.test(o[n]); ) {
2810
2764
  const d = document.createElement("li");
2811
- Ue(d, n[o].replace(/^\s*\d+\.\s+/, "")), u.appendChild(d), o += 1;
2765
+ We(d, o[n].replace(/^\s*\d+\.\s+/, "")), u.appendChild(d), n += 1;
2812
2766
  }
2813
2767
  e.appendChild(u);
2814
2768
  continue;
2815
2769
  }
2816
2770
  const p = [i];
2817
- for (o += 1; o < n.length && n[o].trim() && !/^```/.test(n[o]) && !/^(#{1,3})\s+/.test(n[o]) && !/^\s*[-*+]\s+/.test(n[o]) && !/^\s*\d+\.\s+/.test(n[o]); )
2818
- p.push(n[o]), o += 1;
2771
+ for (n += 1; n < o.length && o[n].trim() && !/^```/.test(o[n]) && !/^(#{1,3})\s+/.test(o[n]) && !/^\s*[-*+]\s+/.test(o[n]) && !/^\s*\d+\.\s+/.test(o[n]); )
2772
+ p.push(o[n]), n += 1;
2819
2773
  const c = document.createElement("p");
2820
2774
  p.forEach((u, d) => {
2821
- d > 0 && c.appendChild(document.createElement("br")), Ue(c, u);
2775
+ d > 0 && c.appendChild(document.createElement("br")), We(c, u);
2822
2776
  }), e.appendChild(c);
2823
2777
  }
2824
2778
  }
2825
- function Ue(e, t) {
2826
- const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
2827
- let o = 0;
2828
- for (const i of t.matchAll(n)) {
2779
+ function We(e, t) {
2780
+ const o = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
2781
+ let n = 0;
2782
+ for (const i of t.matchAll(o)) {
2829
2783
  const a = i.index ?? 0;
2830
- a > o && e.appendChild(
2831
- document.createTextNode(t.slice(o, a))
2784
+ a > n && e.appendChild(
2785
+ document.createTextNode(t.slice(n, a))
2832
2786
  );
2833
2787
  const l = i[0];
2834
2788
  if (l.startsWith("`")) {
@@ -2848,9 +2802,9 @@ function Ue(e, t) {
2848
2802
  } else
2849
2803
  e.appendChild(document.createTextNode(l));
2850
2804
  }
2851
- o = a + l.length;
2805
+ n = a + l.length;
2852
2806
  }
2853
- o < t.length && e.appendChild(document.createTextNode(t.slice(o)));
2807
+ n < t.length && e.appendChild(document.createTextNode(t.slice(n)));
2854
2808
  }
2855
2809
  function la(e) {
2856
2810
  if (e.startsWith("/") || e.startsWith("#"))
@@ -2862,10 +2816,10 @@ function la(e) {
2862
2816
  return !1;
2863
2817
  }
2864
2818
  }
2865
- function rn(e, t) {
2819
+ function dn(e, t) {
2866
2820
  if (pa(e))
2867
2821
  return;
2868
- const n = `
2822
+ const o = `
2869
2823
  :host {
2870
2824
  all: initial;
2871
2825
  color-scheme: light;
@@ -3508,12 +3462,14 @@ function rn(e, t) {
3508
3462
  margin-top: 8px;
3509
3463
  max-width: 220px;
3510
3464
  }
3511
- .pluno-pa-widget__message-attachments img {
3465
+ .pluno-pa-widget__message-attachment-preview {
3512
3466
  width: 100%;
3513
3467
  aspect-ratio: 1;
3514
3468
  border-radius: 8px;
3515
3469
  object-fit: cover;
3516
3470
  border: 1px solid var(--pluno-pa-divider);
3471
+ background: var(--pluno-pa-surface);
3472
+ overflow: hidden;
3517
3473
  }
3518
3474
  .pluno-pa-widget__message-attachment-file {
3519
3475
  min-width: 0;
@@ -4199,7 +4155,8 @@ function rn(e, t) {
4199
4155
  padding: 3px 5px 3px 3px;
4200
4156
  font-size: 12px;
4201
4157
  }
4202
- .pluno-pa-widget__attachment img {
4158
+ .pluno-pa-widget__attachment img,
4159
+ .pluno-pa-widget__attachment video {
4203
4160
  width: 22px;
4204
4161
  height: 22px;
4205
4162
  border-radius: 5px;
@@ -4968,23 +4925,23 @@ function rn(e, t) {
4968
4925
  filter: url(#pluno-pa-scribble-wobble-2);
4969
4926
  }
4970
4927
  `;
4971
- if (sa(e, n))
4928
+ if (sa(e, o))
4972
4929
  return;
4973
- const o = e.ownerDocument.createElement("style");
4974
- o.id = _n, o.textContent = n, e.appendChild(o), Dn(e);
4930
+ const n = e.ownerDocument.createElement("style");
4931
+ n.id = yn, n.textContent = o, e.appendChild(n), Bn(e);
4975
4932
  }
4976
4933
  function pa(e) {
4977
- return e.getElementById(_n) !== null || e.host instanceof HTMLElement && e.host.getAttribute(xn) === "true";
4934
+ return e.getElementById(yn) !== null || e.host instanceof HTMLElement && e.host.getAttribute(Cn) === "true";
4978
4935
  }
4979
- function Dn(e) {
4980
- e.host instanceof HTMLElement && e.host.setAttribute(xn, "true");
4936
+ function Bn(e) {
4937
+ e.host instanceof HTMLElement && e.host.setAttribute(Cn, "true");
4981
4938
  }
4982
4939
  function sa(e, t) {
4983
4940
  if (typeof CSSStyleSheet > "u" || typeof CSSStyleSheet.prototype.replaceSync != "function" || !("adoptedStyleSheets" in e))
4984
4941
  return !1;
4985
4942
  try {
4986
- const n = new CSSStyleSheet();
4987
- return n.replaceSync(t), e.adoptedStyleSheets = [...e.adoptedStyleSheets, n], Dn(e), !0;
4943
+ const o = new CSSStyleSheet();
4944
+ return o.replaceSync(t), e.adoptedStyleSheets = [...e.adoptedStyleSheets, o], Bn(e), !0;
4988
4945
  } catch {
4989
4946
  return !1;
4990
4947
  }
@@ -4997,34 +4954,34 @@ async function da() {
4997
4954
  t.observe(document.documentElement, { childList: !0 });
4998
4955
  });
4999
4956
  }
5000
- function Rn(e) {
4957
+ function Un(e) {
5001
4958
  return `pluno.productAgent.widgetState.${location.origin}.${e.backendUrl ?? ""}.${e.tokenEndpoint ?? ""}.${e.position ?? ""}`;
5002
4959
  }
5003
4960
  function ca(e) {
5004
4961
  try {
5005
- const t = window.localStorage.getItem(Rn(e));
4962
+ const t = window.localStorage.getItem(Un(e));
5006
4963
  if (!t)
5007
- return ln();
5008
- const n = JSON.parse(t);
4964
+ return cn();
4965
+ const o = JSON.parse(t);
5009
4966
  return {
5010
- isOpen: n.isOpen === !0,
5011
- composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
5012
- openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter(
5013
- (o) => typeof o == "string"
4967
+ isOpen: o.isOpen === !0,
4968
+ composerValue: typeof o.composerValue == "string" ? o.composerValue : "",
4969
+ openToolGroupKeys: Array.isArray(o.openToolGroupKeys) ? o.openToolGroupKeys.filter(
4970
+ (n) => typeof n == "string"
5014
4971
  ) : [],
5015
- launcherPosition: ma(n.launcherPosition) ? n.launcherPosition : null,
5016
- seenShareCandidateIds: Array.isArray(n.seenShareCandidateIds) ? n.seenShareCandidateIds.filter((o) => typeof o == "string").slice(-gn) : [],
5017
- sharePromptsDisabled: n.sharePromptsDisabled === !0
4972
+ launcherPosition: ma(o.launcherPosition) ? o.launcherPosition : null,
4973
+ seenShareCandidateIds: Array.isArray(o.seenShareCandidateIds) ? o.seenShareCandidateIds.filter((n) => typeof n == "string").slice(-fn) : [],
4974
+ sharePromptsDisabled: o.sharePromptsDisabled === !0
5018
4975
  };
5019
4976
  } catch {
5020
- return ln();
4977
+ return cn();
5021
4978
  }
5022
4979
  }
5023
4980
  async function ua(e) {
5024
4981
  if (e.loadSharePromptsDisabled)
5025
4982
  return e.loadSharePromptsDisabled();
5026
4983
  try {
5027
- return window.localStorage.getItem(hn) === "true";
4984
+ return window.localStorage.getItem(wn) === "true";
5028
4985
  } catch {
5029
4986
  return !1;
5030
4987
  }
@@ -5038,12 +4995,12 @@ function ga(e, t) {
5038
4995
  return;
5039
4996
  }
5040
4997
  try {
5041
- t && window.localStorage.setItem(hn, "true");
4998
+ t && window.localStorage.setItem(wn, "true");
5042
4999
  } catch {
5043
5000
  return;
5044
5001
  }
5045
5002
  }
5046
- function ln() {
5003
+ function cn() {
5047
5004
  return {
5048
5005
  isOpen: !1,
5049
5006
  composerValue: "",
@@ -5056,7 +5013,7 @@ function ln() {
5056
5013
  function ha(e, t) {
5057
5014
  try {
5058
5015
  window.localStorage.setItem(
5059
- Rn(e),
5016
+ Un(e),
5060
5017
  JSON.stringify(t)
5061
5018
  );
5062
5019
  } catch {
@@ -5069,31 +5026,31 @@ function ma(e) {
5069
5026
  const t = e;
5070
5027
  return Number.isFinite(t.x) && Number.isFinite(t.y) && (t.anchor === "top-left" || t.anchor === "top-right" || t.anchor === "bottom-left" || t.anchor === "bottom-right");
5071
5028
  }
5072
- const pn = /* @__PURE__ */ new WeakSet();
5029
+ const un = /* @__PURE__ */ new WeakSet();
5073
5030
  function ba(e) {
5074
5031
  return Object.keys(e.dataset).some((t) => t.startsWith("pluno"));
5075
5032
  }
5076
- function sn(e) {
5033
+ function gn(e) {
5077
5034
  const t = e.pathname.split("/");
5078
5035
  return t[t.length - 1] ?? "";
5079
5036
  }
5080
5037
  function fa(e, t) {
5081
- const n = new URL(e.src, document.baseURI);
5082
- return n.href === t.href || n.pathname === t.pathname ? !0 : sn(n) === sn(t);
5038
+ const o = new URL(e.src, document.baseURI);
5039
+ return o.href === t.href || o.pathname === t.pathname ? !0 : gn(o) === gn(t);
5083
5040
  }
5084
5041
  class oe extends EventTarget {
5085
- constructor(t, n) {
5086
- super(), this.channelId = n, this.url = t, this.addPreviewListener(_o, () => {
5042
+ constructor(t, o) {
5043
+ super(), this.channelId = o, this.url = t, this.addPreviewListener(So, () => {
5087
5044
  this.readyState = oe.OPEN, this.dispatchEvent(new Event("open"));
5088
- }), this.addPreviewListener(xo, (o) => {
5089
- const i = o;
5045
+ }), this.addPreviewListener(Eo, (n) => {
5046
+ const i = n;
5090
5047
  this.dispatchEvent(
5091
5048
  new MessageEvent("message", { data: i.detail?.data ?? "" })
5092
5049
  );
5093
- }), this.addPreviewListener(yo, () => {
5050
+ }), this.addPreviewListener(ko, () => {
5094
5051
  this.readyState = oe.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
5095
- }), this.addPreviewListener(vo, (o) => {
5096
- const i = o;
5052
+ }), this.addPreviewListener(Lo, (n) => {
5053
+ const i = n;
5097
5054
  this.readyState = oe.CLOSED, this.dispatchEvent(
5098
5055
  new CloseEvent("close", {
5099
5056
  code: i.detail?.code ?? 1e3,
@@ -5103,8 +5060,8 @@ class oe extends EventTarget {
5103
5060
  ), this.cleanup();
5104
5061
  }), window.dispatchEvent(
5105
5062
  new CustomEvent(
5106
- Fe(
5107
- bo,
5063
+ Ge(
5064
+ vo,
5108
5065
  this.channelId
5109
5066
  ),
5110
5067
  {
@@ -5134,7 +5091,7 @@ class oe extends EventTarget {
5134
5091
  );
5135
5092
  window.dispatchEvent(
5136
5093
  new CustomEvent(
5137
- Fe(fo, this.channelId),
5094
+ Ge(yo, this.channelId),
5138
5095
  {
5139
5096
  detail: {
5140
5097
  socketId: this.socketId,
@@ -5144,78 +5101,78 @@ class oe extends EventTarget {
5144
5101
  )
5145
5102
  );
5146
5103
  }
5147
- close(t, n) {
5104
+ close(t, o) {
5148
5105
  this.readyState !== oe.CLOSED && (this.readyState = oe.CLOSING, window.dispatchEvent(
5149
5106
  new CustomEvent(
5150
- Fe(wo, this.channelId),
5107
+ Ge(Co, this.channelId),
5151
5108
  {
5152
- detail: { socketId: this.socketId, code: t, reason: n }
5109
+ detail: { socketId: this.socketId, code: t, reason: o }
5153
5110
  }
5154
5111
  )
5155
5112
  ), this.cleanup());
5156
5113
  }
5157
- addPreviewListener(t, n) {
5158
- const o = Fe(
5114
+ addPreviewListener(t, o) {
5115
+ const n = Ge(
5159
5116
  t,
5160
5117
  this.channelId
5161
5118
  ), i = (a) => {
5162
- a.detail?.socketId === this.socketId && n(a);
5119
+ a.detail?.socketId === this.socketId && o(a);
5163
5120
  };
5164
- this.listeners.set(o, i), window.addEventListener(o, i);
5121
+ this.listeners.set(n, i), window.addEventListener(n, i);
5165
5122
  }
5166
5123
  cleanup() {
5167
- for (const [t, n] of this.listeners.entries())
5168
- window.removeEventListener(t, n);
5124
+ for (const [t, o] of this.listeners.entries())
5125
+ window.removeEventListener(t, o);
5169
5126
  this.listeners.clear();
5170
5127
  }
5171
5128
  }
5172
5129
  function wa() {
5173
5130
  const e = window.sessionStorage.getItem(
5174
- Bt
5131
+ Ht
5175
5132
  );
5176
5133
  if (e)
5177
5134
  return e;
5178
5135
  const t = crypto.randomUUID();
5179
- return window.sessionStorage.setItem(Bt, t), t;
5136
+ return window.sessionStorage.setItem(Ht, t), t;
5180
5137
  }
5181
- function Fe(e, t) {
5138
+ function Ge(e, t) {
5182
5139
  return `${e}:${t}`;
5183
5140
  }
5184
5141
  function _a(e) {
5185
5142
  const t = document.currentScript;
5186
5143
  if (t instanceof HTMLScriptElement)
5187
5144
  return [t];
5188
- const n = new URL(e, document.baseURI).href, o = new URL(n);
5145
+ const o = new URL(e, document.baseURI).href, n = new URL(o);
5189
5146
  return Array.from(
5190
5147
  document.querySelectorAll("script[type='module'][src]")
5191
5148
  ).filter(
5192
- (i) => i instanceof HTMLScriptElement && ba(i) && fa(i, o)
5149
+ (i) => i instanceof HTMLScriptElement && ba(i) && fa(i, n)
5193
5150
  );
5194
5151
  }
5195
5152
  function xa(e) {
5196
5153
  for (const t of _a(e)) {
5197
- if (pn.has(t) || t.dataset.plunoAutoMount === "false")
5154
+ if (un.has(t) || t.dataset.plunoAutoMount === "false")
5198
5155
  continue;
5199
- pn.add(t);
5200
- const n = t.dataset.plunoPreviewChannel;
5201
- Vo({
5156
+ un.add(t);
5157
+ const o = t.dataset.plunoPreviewChannel;
5158
+ Xo({
5202
5159
  token: t.dataset.plunoToken,
5203
5160
  tokenEndpoint: t.dataset.plunoTokenEndpoint,
5204
5161
  backendUrl: t.dataset.plunoBackendUrl,
5205
- webSocketFactory: n ? jo(n) : void 0,
5162
+ webSocketFactory: o ? Yo(o) : void 0,
5206
5163
  launcherLabel: t.dataset.plunoLauncherLabel,
5207
5164
  accentColor: t.dataset.plunoAccentColor,
5208
5165
  colorScheme: t.dataset.plunoColorScheme === "dark" ? "dark" : "light",
5209
5166
  fontFamily: t.dataset.plunoFontFamily,
5210
5167
  scribbleStyle: t.dataset.plunoScribbleStyle === "true",
5211
5168
  position: t.dataset.plunoPosition === "bottom-left" ? "bottom-left" : "bottom-right"
5212
- }).catch((o) => {
5213
- console.error("Failed to mount Pluno widget", o);
5169
+ }).catch((n) => {
5170
+ console.error("Failed to mount Pluno widget", n);
5214
5171
  });
5215
5172
  }
5216
5173
  }
5217
5174
  xa(import.meta.url);
5218
5175
  export {
5219
- jo as createProductAgentPreviewBridgeWebSocketFactory,
5220
- Vo as mountPlunoProductAgentWidget
5176
+ Yo as createProductAgentPreviewBridgeWebSocketFactory,
5177
+ Xo as mountPlunoProductAgentWidget
5221
5178
  };