@pluno/product-agent-web 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/product-agent-sdk.js +118 -113
- package/dist/product-agent-widget.js +283 -257
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PlunoProductAgent as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const e =
|
|
1
|
+
import { PlunoProductAgent as ye } from "./product-agent-sdk.js";
|
|
2
|
+
const ve = "#7c3aed";
|
|
3
|
+
function ke(t) {
|
|
4
|
+
const e = Te(t);
|
|
5
5
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
6
6
|
<defs>
|
|
7
7
|
<linearGradient id="boltFill" x1="420" y1="180" x2="790" y2="1040" gradientUnits="userSpaceOnUse">
|
|
@@ -75,27 +75,27 @@ function ve(t) {
|
|
|
75
75
|
</g>
|
|
76
76
|
</svg>`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
78
|
+
function Ce(t) {
|
|
79
|
+
return `data:image/svg+xml,${encodeURIComponent(ke(t))}`;
|
|
80
80
|
}
|
|
81
81
|
const N = "#2c2a1e", J = [253, 250, 241], Q = 3.5;
|
|
82
82
|
function he(t) {
|
|
83
|
-
const e =
|
|
83
|
+
const e = fe(t);
|
|
84
84
|
if (ee(M(e), J) >= Q)
|
|
85
85
|
return e;
|
|
86
|
-
let
|
|
86
|
+
let o = M(e);
|
|
87
87
|
const a = M(N);
|
|
88
88
|
for (let r = 0; r < 6; r += 1)
|
|
89
|
-
if (
|
|
90
|
-
return
|
|
91
|
-
return
|
|
89
|
+
if (o = Ne(o, a, 0.22), ee(o, J) >= Q)
|
|
90
|
+
return H(o);
|
|
91
|
+
return H(o);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const e = he(t),
|
|
93
|
+
function Se(t) {
|
|
94
|
+
const e = he(t), n = "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";
|
|
95
95
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
96
96
|
<defs>
|
|
97
97
|
<clipPath id="scribbleBoltClip">
|
|
98
|
-
<path d="${
|
|
98
|
+
<path d="${n}"/>
|
|
99
99
|
</clipPath>
|
|
100
100
|
<filter id="scribbleBoltWobble" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB">
|
|
101
101
|
<feTurbulence type="fractalNoise" baseFrequency="0.011" numOctaves="3" seed="7" result="noise"/>
|
|
@@ -104,9 +104,9 @@ function Ce(t) {
|
|
|
104
104
|
</defs>
|
|
105
105
|
<g filter="url(#scribbleBoltWobble)">
|
|
106
106
|
<g clip-path="url(#scribbleBoltClip)">
|
|
107
|
-
<path d="${
|
|
107
|
+
<path d="${Le()}" fill="none" stroke="${e}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
|
|
108
108
|
</g>
|
|
109
|
-
<path d="${
|
|
109
|
+
<path d="${n}" fill="none" stroke="${N}" stroke-width="18" stroke-linejoin="round"/>
|
|
110
110
|
<g transform="rotate(-2 528 463)">
|
|
111
111
|
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${N}" stroke-width="13"/>
|
|
112
112
|
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${N}"/>
|
|
@@ -120,20 +120,20 @@ function Ce(t) {
|
|
|
120
120
|
</g>
|
|
121
121
|
</svg>`;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
123
|
+
function Ee(t) {
|
|
124
|
+
return `data:image/svg+xml,${encodeURIComponent(Se(t))}`;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
let
|
|
126
|
+
function Le() {
|
|
127
|
+
let n = "M 280 120", o = !1, a = 0;
|
|
128
128
|
for (let r = 150; r <= 1170; r += 62) {
|
|
129
|
-
const i = (a % 3 - 1) * 18, d =
|
|
130
|
-
|
|
129
|
+
const i = (a % 3 - 1) * 18, d = o ? 280 - i : 1020 + i;
|
|
130
|
+
n += ` L ${d} ${r}`, o = !o, a += 1;
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return n;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const e =
|
|
136
|
-
return
|
|
134
|
+
function Te(t) {
|
|
135
|
+
const e = fe(t), n = W(M(e));
|
|
136
|
+
return n > 0.86 ? {
|
|
137
137
|
top: "#ffffff",
|
|
138
138
|
middle: "#f6f6f6",
|
|
139
139
|
bottom: "#e7e7e7",
|
|
@@ -144,7 +144,7 @@ function Le(t) {
|
|
|
144
144
|
highlight: "#ffffff",
|
|
145
145
|
inner: "#f4f4f4",
|
|
146
146
|
shadow: "#9d9d9d"
|
|
147
|
-
} :
|
|
147
|
+
} : n < 0.05 ? {
|
|
148
148
|
top: "#3d3d3d",
|
|
149
149
|
middle: "#171717",
|
|
150
150
|
bottom: "#030303",
|
|
@@ -168,9 +168,9 @@ function Le(t) {
|
|
|
168
168
|
shadow: v(e, -0.25, -0.08)
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function fe(t) {
|
|
172
172
|
const e = t.trim();
|
|
173
|
-
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((
|
|
173
|
+
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : ve;
|
|
174
174
|
}
|
|
175
175
|
function M(t) {
|
|
176
176
|
return [
|
|
@@ -179,69 +179,69 @@ function M(t) {
|
|
|
179
179
|
Number.parseInt(t.slice(5, 7), 16)
|
|
180
180
|
];
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
const
|
|
184
|
-
return `#${
|
|
182
|
+
function H([t, e, n]) {
|
|
183
|
+
const o = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
|
|
184
|
+
return `#${o(t)}${o(e)}${o(n)}`;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
const
|
|
186
|
+
function W([t, e, n]) {
|
|
187
|
+
const o = (a) => {
|
|
188
188
|
const r = a / 255;
|
|
189
189
|
return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
190
190
|
};
|
|
191
|
-
return 0.2126 *
|
|
191
|
+
return 0.2126 * o(t) + 0.7152 * o(e) + 0.0722 * o(n);
|
|
192
192
|
}
|
|
193
193
|
function ee(t, e) {
|
|
194
|
-
const
|
|
194
|
+
const n = W(t), o = W(e), [a, r] = n > o ? [n, o] : [o, n];
|
|
195
195
|
return (a + 0.05) / (r + 0.05);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const
|
|
197
|
+
function Ne(t, e, n) {
|
|
198
|
+
const o = V(n);
|
|
199
199
|
return [
|
|
200
|
-
t[0] + (e[0] - t[0]) *
|
|
201
|
-
t[1] + (e[1] - t[1]) *
|
|
202
|
-
t[2] + (e[2] - t[2]) *
|
|
200
|
+
t[0] + (e[0] - t[0]) * o,
|
|
201
|
+
t[1] + (e[1] - t[1]) * o,
|
|
202
|
+
t[2] + (e[2] - t[2]) * o
|
|
203
203
|
];
|
|
204
204
|
}
|
|
205
|
-
function v(t, e,
|
|
206
|
-
const [
|
|
207
|
-
return
|
|
205
|
+
function v(t, e, n) {
|
|
206
|
+
const [o, a, r] = Pe(M(t));
|
|
207
|
+
return H(Ie(o, V(a + n), V(r + e)));
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const
|
|
209
|
+
function Pe([t, e, n]) {
|
|
210
|
+
const o = t / 255, a = e / 255, r = n / 255, i = Math.max(o, a, r), d = Math.min(o, a, r), u = (i + d) / 2;
|
|
211
211
|
if (i === d)
|
|
212
212
|
return [0, 0, u];
|
|
213
213
|
const p = i - d, g = u > 0.5 ? p / (2 - i - d) : p / (i + d);
|
|
214
|
-
return [(i ===
|
|
214
|
+
return [(i === o ? (a - r) / p + (a < r ? 6 : 0) : i === a ? (r - o) / p + 2 : (o - a) / p + 4) / 6, g, u];
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function Ie(t, e, n) {
|
|
217
217
|
if (e === 0)
|
|
218
|
-
return [
|
|
219
|
-
const
|
|
218
|
+
return [n * 255, n * 255, n * 255];
|
|
219
|
+
const o = n < 0.5 ? n * (1 + e) : n + e - n * e, a = 2 * n - o;
|
|
220
220
|
return [
|
|
221
|
-
B(a,
|
|
222
|
-
B(a,
|
|
223
|
-
B(a,
|
|
221
|
+
B(a, o, t + 1 / 3) * 255,
|
|
222
|
+
B(a, o, t) * 255,
|
|
223
|
+
B(a, o, t - 1 / 3) * 255
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
|
-
function B(t, e,
|
|
227
|
-
let
|
|
228
|
-
return
|
|
226
|
+
function B(t, e, n) {
|
|
227
|
+
let o = n;
|
|
228
|
+
return o < 0 && (o += 1), o > 1 && (o -= 1), o < 1 / 6 ? t + (e - t) * 6 * o : o < 1 / 2 ? e : o < 2 / 3 ? t + (e - t) * (2 / 3 - o) * 6 : t;
|
|
229
229
|
}
|
|
230
230
|
function V(t) {
|
|
231
231
|
return Math.max(0, Math.min(1, t));
|
|
232
232
|
}
|
|
233
|
-
const Ae = "product-agent:sdk-preview-socket-connect",
|
|
233
|
+
const Ae = "product-agent:sdk-preview-socket-connect", Me = "product-agent:sdk-preview-socket-send", Oe = "product-agent:sdk-preview-socket-close", $e = "product-agent:sdk-preview-socket-open", De = "product-agent:sdk-preview-socket-message", Fe = "product-agent:sdk-preview-socket-error", Re = "product-agent:sdk-preview-socket-closed", te = "product-agent:sdk-preview-socket-id", Ge = "product-agent:preview-diagnostic", T = {
|
|
234
234
|
launcherLabel: "Ask for anything...",
|
|
235
235
|
accentColor: "#7c3aed",
|
|
236
236
|
colorScheme: "light",
|
|
237
237
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif',
|
|
238
238
|
scribbleStyle: !1,
|
|
239
239
|
position: "bottom-right"
|
|
240
|
-
}, ne = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 104 36"><g><ellipse cx="17.5" cy="24.5" rx="2.4" ry="3" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.5 27 C20.5 12, 7.5 2.5, 6 18.5" fill="none" stroke="%232c2a1e" stroke-width="2.5" stroke-linecap="round"/></g><g transform="translate(26 0)"><ellipse cx="17.9" cy="24.1" rx="2.5" ry="2.8" fill="none" stroke="%232c2a1e" stroke-width="1.5" opacity="0.8"/><path d="M18.9 26.4 C21.2 13, 8.6 3.6, 6.9 17.4" fill="none" stroke="%232c2a1e" stroke-width="2.35" stroke-linecap="round"/></g><g transform="translate(52 0)"><ellipse cx="17.1" cy="24.9" rx="2.2" ry="3.1" fill="none" stroke="%232c2a1e" stroke-width="1.7" opacity="0.8"/><path d="M18.1 27.5 C19.9 10.4, 6.4 2, 5.6 19.2" fill="none" stroke="%232c2a1e" stroke-width="2.6" stroke-linecap="round"/></g><g transform="translate(78 0)"><ellipse cx="17.6" cy="24.4" rx="2.4" ry="2.9" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.7 26.8 C21 11.2, 7.1 1.6, 6.3 18.1" fill="none" stroke="%232c2a1e" stroke-width="2.45" stroke-linecap="round"/></g></svg>',
|
|
241
|
-
function
|
|
240
|
+
}, ne = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 104 36"><g><ellipse cx="17.5" cy="24.5" rx="2.4" ry="3" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.5 27 C20.5 12, 7.5 2.5, 6 18.5" fill="none" stroke="%232c2a1e" stroke-width="2.5" stroke-linecap="round"/></g><g transform="translate(26 0)"><ellipse cx="17.9" cy="24.1" rx="2.5" ry="2.8" fill="none" stroke="%232c2a1e" stroke-width="1.5" opacity="0.8"/><path d="M18.9 26.4 C21.2 13, 8.6 3.6, 6.9 17.4" fill="none" stroke="%232c2a1e" stroke-width="2.35" stroke-linecap="round"/></g><g transform="translate(52 0)"><ellipse cx="17.1" cy="24.9" rx="2.2" ry="3.1" fill="none" stroke="%232c2a1e" stroke-width="1.7" opacity="0.8"/><path d="M18.1 27.5 C19.9 10.4, 6.4 2, 5.6 19.2" fill="none" stroke="%232c2a1e" stroke-width="2.6" stroke-linecap="round"/></g><g transform="translate(78 0)"><ellipse cx="17.6" cy="24.4" rx="2.4" ry="2.9" fill="none" stroke="%232c2a1e" stroke-width="1.6" opacity="0.8"/><path d="M18.7 26.8 C21 11.2, 7.1 1.6, 6.3 18.1" fill="none" stroke="%232c2a1e" stroke-width="2.45" stroke-linecap="round"/></g></svg>', ze = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', oe = "pluno-pa-scribble-font";
|
|
241
|
+
function Be(t) {
|
|
242
242
|
return (e) => new C(e, t);
|
|
243
243
|
}
|
|
244
|
-
async function
|
|
244
|
+
async function Ue(t = {}) {
|
|
245
245
|
const e = {
|
|
246
246
|
launcherLabel: t.launcherLabel ?? T.launcherLabel,
|
|
247
247
|
accentColor: t.accentColor ?? T.accentColor,
|
|
@@ -253,10 +253,11 @@ async function Be(t = {}) {
|
|
|
253
253
|
tokenProvider: t.tokenProvider,
|
|
254
254
|
tokenEndpoint: t.tokenEndpoint,
|
|
255
255
|
backendUrl: t.backendUrl,
|
|
256
|
+
metadata: t.metadata,
|
|
256
257
|
initialStarterPrompts: t.initialStarterPrompts,
|
|
257
258
|
webSocketFactory: t.webSocketFactory
|
|
258
259
|
};
|
|
259
|
-
|
|
260
|
+
I("web-sdk.widget", "Mounting widget with merged options", {
|
|
260
261
|
accentColor: e.accentColor,
|
|
261
262
|
colorScheme: e.colorScheme,
|
|
262
263
|
fontFamily: e.fontFamily,
|
|
@@ -267,9 +268,9 @@ async function Be(t = {}) {
|
|
|
267
268
|
hasWebSocketFactory: !!e.webSocketFactory,
|
|
268
269
|
initialStarterPromptCount: e.initialStarterPrompts?.length ?? 0
|
|
269
270
|
});
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
const
|
|
271
|
+
const n = document.createElement("div");
|
|
272
|
+
n.className = "pluno-pa-widget-host";
|
|
273
|
+
const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
273
274
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
274
275
|
let r = ae(e.accentColor, e.scribbleStyle);
|
|
275
276
|
a.innerHTML = `
|
|
@@ -332,22 +333,23 @@ async function Be(t = {}) {
|
|
|
332
333
|
<a class="pluno-pa-widget__powered-by" href="https://pluno.ai" target="_blank" rel="noopener noreferrer">Powered by Pluno.ai</a>
|
|
333
334
|
</form>
|
|
334
335
|
</section>
|
|
335
|
-
`,
|
|
336
|
-
const i = await
|
|
337
|
-
i.appendChild(
|
|
336
|
+
`, o.appendChild(a);
|
|
337
|
+
const i = await Ye(), d = i.ownerDocument;
|
|
338
|
+
i.appendChild(n), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ue(o, e.accentColor), re(a, r, {
|
|
338
339
|
accentColor: e.accentColor,
|
|
339
340
|
colorScheme: e.colorScheme,
|
|
340
341
|
fontFamily: e.fontFamily,
|
|
341
342
|
scribbleStyle: e.scribbleStyle
|
|
342
|
-
}),
|
|
343
|
+
}), I("web-sdk.widget", "Applied initial widget appearance", {
|
|
343
344
|
accentColor: e.accentColor,
|
|
344
345
|
colorScheme: e.colorScheme,
|
|
345
346
|
fontFamily: e.fontFamily,
|
|
346
347
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
347
348
|
});
|
|
348
|
-
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"),
|
|
349
|
-
if (!u || !p || !g || !
|
|
349
|
+
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), f = a.querySelector(".pluno-pa-widget__close"), x = a.querySelector(".pluno-pa-widget__composer"), s = a.querySelector(".pluno-pa-widget__input"), _ = a.querySelector(".pluno-pa-widget__send"), c = a.querySelector(".pluno-pa-widget__new-chat"), b = a.querySelector(".pluno-pa-widget__timeline");
|
|
350
|
+
if (!u || !p || !g || !f || !x || !s || !_ || !c || !b)
|
|
350
351
|
throw new Error("Failed to mount Product Agent widget");
|
|
352
|
+
ie(p), ie(s);
|
|
351
353
|
const y = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
352
354
|
if (!e.tokenEndpoint)
|
|
353
355
|
throw new Error("Product Agent widget requires token or tokenEndpoint");
|
|
@@ -363,37 +365,44 @@ async function Be(t = {}) {
|
|
|
363
365
|
if (!k.token)
|
|
364
366
|
throw new Error("Product Agent token endpoint did not return a token");
|
|
365
367
|
return k.token;
|
|
366
|
-
})
|
|
368
|
+
});
|
|
369
|
+
let h;
|
|
370
|
+
h = await ye.init({
|
|
367
371
|
token: e.token,
|
|
368
372
|
tokenProvider: y,
|
|
369
373
|
backendUrl: e.backendUrl,
|
|
374
|
+
metadata: () => ({
|
|
375
|
+
...e.metadata ?? {},
|
|
376
|
+
...!h.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
|
|
377
|
+
}),
|
|
370
378
|
initialStarterPrompts: e.initialStarterPrompts,
|
|
371
379
|
webSocketFactory: e.webSocketFactory
|
|
372
|
-
})
|
|
380
|
+
});
|
|
381
|
+
const w = Ze(e), m = new Set(w.openToolGroupKeys);
|
|
373
382
|
let S = null, j = !1;
|
|
374
|
-
const
|
|
375
|
-
j || typeof document > "u" || (
|
|
376
|
-
}, q = new MutationObserver(
|
|
383
|
+
const _e = () => {
|
|
384
|
+
j || typeof document > "u" || (ue(o, e.accentColor), n.isConnected || d.body?.appendChild(n));
|
|
385
|
+
}, q = new MutationObserver(_e);
|
|
377
386
|
q.observe(d.documentElement, { childList: !0, subtree: !0 });
|
|
378
387
|
const E = () => {
|
|
379
|
-
|
|
388
|
+
Xe(e, {
|
|
380
389
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
381
390
|
composerValue: s.value,
|
|
382
391
|
openToolGroupKeys: [...m]
|
|
383
392
|
});
|
|
384
393
|
}, P = (l = "", k = !0) => {
|
|
385
|
-
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1,
|
|
386
|
-
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l,
|
|
394
|
+
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, f.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
|
|
395
|
+
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E();
|
|
387
396
|
return;
|
|
388
397
|
}
|
|
389
398
|
window.requestAnimationFrame(() => {
|
|
390
|
-
a.classList.add("pluno-pa-widget--open"), l && (s.value = l,
|
|
391
|
-
u.hidden = !0,
|
|
399
|
+
a.classList.add("pluno-pa-widget--open"), l && (s.value = l, A(s)), b.scrollTop = b.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E(), S = window.setTimeout(() => {
|
|
400
|
+
u.hidden = !0, b.scrollTop = b.scrollHeight;
|
|
392
401
|
}, 220);
|
|
393
402
|
});
|
|
394
|
-
},
|
|
403
|
+
}, xe = () => {
|
|
395
404
|
S !== null && (window.clearTimeout(S), S = null), u.hidden = !1, a.classList.add("pluno-pa-widget--closing"), a.classList.remove("pluno-pa-widget--open"), E(), S = window.setTimeout(() => {
|
|
396
|
-
g.hidden = !0,
|
|
405
|
+
g.hidden = !0, f.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
397
406
|
}, 220);
|
|
398
407
|
};
|
|
399
408
|
u.addEventListener("submit", (l) => {
|
|
@@ -407,48 +416,48 @@ async function Be(t = {}) {
|
|
|
407
416
|
return;
|
|
408
417
|
const l = p.value;
|
|
409
418
|
P(l), p.value = "";
|
|
410
|
-
}),
|
|
419
|
+
}), f.addEventListener("click", xe);
|
|
411
420
|
const L = () => {
|
|
412
|
-
_.disabled = !
|
|
421
|
+
_.disabled = !h.getState().isThinking && s.value.trim().length === 0;
|
|
413
422
|
};
|
|
414
423
|
x.addEventListener("submit", (l) => {
|
|
415
|
-
l.preventDefault(), U(
|
|
424
|
+
l.preventDefault(), U(h, s), L();
|
|
416
425
|
}), _.addEventListener("click", () => {
|
|
417
|
-
if (
|
|
418
|
-
|
|
426
|
+
if (h.getState().isThinking) {
|
|
427
|
+
h.stop();
|
|
419
428
|
return;
|
|
420
429
|
}
|
|
421
|
-
U(
|
|
430
|
+
U(h, s), L();
|
|
422
431
|
}), c.addEventListener("click", () => {
|
|
423
|
-
|
|
432
|
+
h.startNewSession(), m.clear(), s.value = "", A(s), E(), L(), s.focus();
|
|
424
433
|
}), s.addEventListener("input", () => {
|
|
425
|
-
|
|
434
|
+
A(s), E(), L();
|
|
426
435
|
}), s.addEventListener("keydown", (l) => {
|
|
427
|
-
l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(
|
|
436
|
+
l.key !== "Enter" || l.shiftKey || (l.preventDefault(), U(h, s), L());
|
|
428
437
|
}), a.addEventListener("click", (l) => {
|
|
429
438
|
(l.target instanceof Element ? l.target : null)?.closest("a[href]") && E();
|
|
430
|
-
}), w.composerValue && (s.value = w.composerValue,
|
|
439
|
+
}), w.composerValue && (s.value = w.composerValue, A(s)), w.isOpen && P(s.value, !1);
|
|
431
440
|
const Y = () => r;
|
|
432
|
-
let R =
|
|
433
|
-
return
|
|
434
|
-
l.appearance ? (R = !0,
|
|
441
|
+
let R = h.getState().appearance !== null;
|
|
442
|
+
return h.on("state", (l) => {
|
|
443
|
+
l.appearance ? (R = !0, I("web-sdk.widget", "Agent state supplied appearance", {
|
|
435
444
|
appearance: l.appearance
|
|
436
|
-
}), G(l.appearance, "agent.state.appearance")) : R && (R = !1,
|
|
445
|
+
}), G(l.appearance, "agent.state.appearance")) : R && (R = !1, I("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
437
446
|
fallbackAccentColor: e.accentColor,
|
|
438
447
|
fallbackColorScheme: e.colorScheme,
|
|
439
448
|
fallbackFontFamily: e.fontFamily
|
|
440
|
-
}), G({}, "agent.state.appearance-cleared")),
|
|
441
|
-
|
|
449
|
+
}), G({}, "agent.state.appearance-cleared")), le(b, _, c, l, m, E, Y, (k) => {
|
|
450
|
+
h.sendMessage(k);
|
|
442
451
|
}), L();
|
|
443
|
-
}),
|
|
444
|
-
|
|
452
|
+
}), le(b, _, c, h.getState(), m, E, Y, (l) => {
|
|
453
|
+
h.sendMessage(l);
|
|
445
454
|
}), L(), {
|
|
446
|
-
agent:
|
|
455
|
+
agent: h,
|
|
447
456
|
updateAppearance: (l) => {
|
|
448
457
|
l.scribbleStyle !== void 0 && (e.scribbleStyle = l.scribbleStyle), G(l, "widgetHandle.updateAppearance");
|
|
449
458
|
},
|
|
450
459
|
destroy: () => {
|
|
451
|
-
j = !0, q.disconnect(),
|
|
460
|
+
j = !0, q.disconnect(), h.destroy(), n.remove();
|
|
452
461
|
}
|
|
453
462
|
};
|
|
454
463
|
function G(l, k) {
|
|
@@ -458,7 +467,7 @@ async function Be(t = {}) {
|
|
|
458
467
|
colorScheme: Z,
|
|
459
468
|
fontFamily: X,
|
|
460
469
|
scribbleStyle: z
|
|
461
|
-
}),
|
|
470
|
+
}), I("web-sdk.widget", "Updated widget appearance", {
|
|
462
471
|
source: k,
|
|
463
472
|
inputAppearance: l,
|
|
464
473
|
appliedAccentColor: O,
|
|
@@ -470,17 +479,17 @@ async function Be(t = {}) {
|
|
|
470
479
|
}
|
|
471
480
|
}
|
|
472
481
|
function ae(t, e) {
|
|
473
|
-
return e ?
|
|
482
|
+
return e ? Ee(t) : Ce(t);
|
|
474
483
|
}
|
|
475
|
-
function re(t, e,
|
|
476
|
-
t.classList.toggle("pluno-pa-widget--dark",
|
|
477
|
-
const
|
|
478
|
-
t.style.setProperty("--pluno-pa-accent",
|
|
484
|
+
function re(t, e, n) {
|
|
485
|
+
t.classList.toggle("pluno-pa-widget--dark", n.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", n.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
|
|
486
|
+
const o = n.scribbleStyle ? he(n.accentColor) : n.accentColor;
|
|
487
|
+
t.style.setProperty("--pluno-pa-accent", o), t.style.fontFamily = n.scribbleStyle ? ze : n.fontFamily, n.scribbleStyle && He(t.ownerDocument);
|
|
479
488
|
const a = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
480
489
|
for (const r of a)
|
|
481
490
|
r.src = e;
|
|
482
491
|
}
|
|
483
|
-
function
|
|
492
|
+
function He(t) {
|
|
484
493
|
if (t.getElementById(oe))
|
|
485
494
|
return;
|
|
486
495
|
const e = t.createElement("style");
|
|
@@ -492,204 +501,210 @@ function Ue(t) {
|
|
|
492
501
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
493
502
|
}`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
|
|
494
503
|
}
|
|
495
|
-
function
|
|
504
|
+
function I(t, e, n) {
|
|
496
505
|
if (typeof window > "u")
|
|
497
506
|
return;
|
|
498
|
-
const
|
|
507
|
+
const o = window, a = {
|
|
499
508
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
500
509
|
source: t,
|
|
501
510
|
message: e,
|
|
502
|
-
details:
|
|
503
|
-
}, r =
|
|
504
|
-
r.push(a), r.length > 120 && r.splice(0, r.length - 120),
|
|
511
|
+
details: n
|
|
512
|
+
}, r = o.__plunoProductAgentDiagnostics__ ?? [];
|
|
513
|
+
r.push(a), r.length > 120 && r.splice(0, r.length - 120), o.__plunoProductAgentDiagnostics__ = r, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent(Ge, { detail: a }));
|
|
505
514
|
}
|
|
506
515
|
function U(t, e) {
|
|
507
|
-
const
|
|
508
|
-
|
|
516
|
+
const n = e.value.trim();
|
|
517
|
+
n && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(n), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
509
518
|
}
|
|
510
|
-
function
|
|
519
|
+
function A(t) {
|
|
511
520
|
t.style.height = "0px";
|
|
512
521
|
const e = Math.max(22, Math.min(t.scrollHeight, 140));
|
|
513
522
|
t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
|
|
514
523
|
}
|
|
515
|
-
function ie(t
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
524
|
+
function ie(t) {
|
|
525
|
+
for (const e of ["keydown", "keypress", "keyup"])
|
|
526
|
+
t.addEventListener(e, (n) => {
|
|
527
|
+
n.stopPropagation();
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function le(t, e, n, o, a, r, i, d) {
|
|
531
|
+
const u = [...o.messages];
|
|
532
|
+
t.innerHTML = "", je(e, o.isThinking);
|
|
533
|
+
const p = u.length > 0 || !!o.assistantDraft || o.isThinking;
|
|
534
|
+
if (n.hidden = !p, u.length === 0 && !o.assistantDraft && !o.lastError && !o.isThinking) {
|
|
520
535
|
const c = document.createElement("div");
|
|
521
536
|
c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
522
|
-
const
|
|
523
|
-
|
|
537
|
+
const b = document.createElement("img");
|
|
538
|
+
b.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", b.src = i(), b.alt = "", b.setAttribute("aria-hidden", "true"), c.appendChild(b);
|
|
524
539
|
const y = document.createElement("div");
|
|
525
540
|
y.className = "pluno-pa-widget__empty", y.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(y);
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
for (const w of
|
|
541
|
+
const h = document.createElement("div");
|
|
542
|
+
h.className = o.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", o.starterPrompts.length === 0 && h.setAttribute("aria-hidden", "true");
|
|
543
|
+
for (const w of o.starterPrompts) {
|
|
529
544
|
const m = document.createElement("button");
|
|
530
545
|
m.type = "button", m.className = "pluno-pa-widget__starter-prompt", m.textContent = `"${w}"`, m.addEventListener("click", () => {
|
|
531
546
|
d(w);
|
|
532
|
-
}),
|
|
547
|
+
}), h.appendChild(m);
|
|
533
548
|
}
|
|
534
|
-
c.appendChild(
|
|
549
|
+
c.appendChild(h), t.appendChild(c);
|
|
535
550
|
return;
|
|
536
551
|
}
|
|
537
|
-
let g = null,
|
|
552
|
+
let g = null, f = null, x = [];
|
|
538
553
|
const s = () => {
|
|
539
554
|
if (x.length === 0)
|
|
540
555
|
return !1;
|
|
541
556
|
const c = We(x, a, r, i());
|
|
542
|
-
return t.appendChild(c), g = null,
|
|
557
|
+
return t.appendChild(c), g = null, f = c, x = [], !0;
|
|
543
558
|
};
|
|
544
559
|
for (let c = 0; c < u.length; c += 1) {
|
|
545
|
-
const
|
|
546
|
-
if (
|
|
547
|
-
x.push(
|
|
560
|
+
const b = u[c];
|
|
561
|
+
if (b.role === "tool") {
|
|
562
|
+
x.push(b);
|
|
548
563
|
continue;
|
|
549
564
|
}
|
|
550
|
-
if (
|
|
565
|
+
if (b.role === "system")
|
|
551
566
|
continue;
|
|
552
|
-
const y = s(),
|
|
553
|
-
if (
|
|
567
|
+
const y = s(), h = se(b.content);
|
|
568
|
+
if (b.role === "assistant" && !y) {
|
|
554
569
|
const m = K(i());
|
|
555
|
-
t.appendChild(m), g = null,
|
|
570
|
+
t.appendChild(m), g = null, f = m;
|
|
556
571
|
}
|
|
557
572
|
const w = document.createElement("div");
|
|
558
|
-
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${
|
|
573
|
+
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${b.role}`, b.role === "assistant" ? ce(w, h) : w.textContent = h, w.appendChild(pe(h)), t.appendChild(w), g = w, f = null;
|
|
559
574
|
}
|
|
560
575
|
const _ = s();
|
|
561
|
-
if (
|
|
576
|
+
if (o.assistantDraft) {
|
|
562
577
|
if (!_) {
|
|
563
578
|
const y = K(i());
|
|
564
|
-
t.appendChild(y), g = null,
|
|
579
|
+
t.appendChild(y), g = null, f = y;
|
|
565
580
|
}
|
|
566
|
-
const c =
|
|
567
|
-
|
|
581
|
+
const c = se(o.assistantDraft), b = document.createElement("div");
|
|
582
|
+
b.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", ce(b, c), b.appendChild(pe(c)), t.appendChild(b), g = b, f = null;
|
|
568
583
|
}
|
|
569
|
-
if (
|
|
584
|
+
if (o.isThinking && !o.assistantDraft)
|
|
570
585
|
if (_) {
|
|
571
|
-
const c =
|
|
572
|
-
t.appendChild(c), g = null,
|
|
586
|
+
const c = we();
|
|
587
|
+
t.appendChild(c), g = null, f = c;
|
|
573
588
|
} else {
|
|
574
|
-
const c =
|
|
575
|
-
t.appendChild(c), g = null,
|
|
589
|
+
const c = Ve(i());
|
|
590
|
+
t.appendChild(c), g = null, f = c;
|
|
576
591
|
}
|
|
577
|
-
if (
|
|
592
|
+
if (o.lastError) {
|
|
578
593
|
const c = document.createElement("div");
|
|
579
|
-
c.className = "pluno-pa-widget__error", c.textContent =
|
|
594
|
+
c.className = "pluno-pa-widget__error", c.textContent = o.lastError, t.appendChild(c), g = c, f = null;
|
|
580
595
|
}
|
|
581
|
-
g?.classList.add("pluno-pa-widget__message--bottom-reserve"),
|
|
596
|
+
g?.classList.add("pluno-pa-widget__message--bottom-reserve"), f?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
582
597
|
}
|
|
583
|
-
function
|
|
598
|
+
function pe(t) {
|
|
584
599
|
const e = document.createElement("button");
|
|
585
|
-
return e.type = "button", e.className = "pluno-pa-widget__message-copy", e.setAttribute("aria-label", "Copy message"), e.title = "Copy message", e.innerHTML = '<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>', e.addEventListener("click", (
|
|
586
|
-
|
|
600
|
+
return e.type = "button", e.className = "pluno-pa-widget__message-copy", e.setAttribute("aria-label", "Copy message"), e.title = "Copy message", e.innerHTML = '<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>', e.addEventListener("click", (n) => {
|
|
601
|
+
n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(t);
|
|
587
602
|
}), e;
|
|
588
603
|
}
|
|
589
|
-
function
|
|
604
|
+
function se(t) {
|
|
590
605
|
return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
591
606
|
}
|
|
592
|
-
function We(t, e,
|
|
607
|
+
function We(t, e, n, o) {
|
|
593
608
|
const a = document.createElement("article");
|
|
594
609
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
595
610
|
const r = document.createElement("img");
|
|
596
|
-
r.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", r.src =
|
|
597
|
-
const i = document.createElement("details"), d =
|
|
611
|
+
r.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", r.src = o, r.alt = "", r.setAttribute("aria-hidden", "true"), a.appendChild(r);
|
|
612
|
+
const i = document.createElement("details"), d = Ke(t);
|
|
598
613
|
i.open = e.has(d), i.addEventListener("toggle", () => {
|
|
599
|
-
i.open ? e.add(d) : e.delete(d),
|
|
614
|
+
i.open ? e.add(d) : e.delete(d), n();
|
|
600
615
|
});
|
|
601
616
|
const u = document.createElement("summary");
|
|
602
|
-
u.className = "pluno-pa-widget__tool-summary", t.some((
|
|
617
|
+
u.className = "pluno-pa-widget__tool-summary", t.some((f) => f.loading) && u.appendChild(de());
|
|
603
618
|
const g = document.createElement("span");
|
|
604
619
|
if (g.className = "pluno-pa-widget__tool-summary-title", g.textContent = t[t.length - 1].content || "Run tool", u.appendChild(g), i.appendChild(u), t.length > 0) {
|
|
605
|
-
const
|
|
606
|
-
|
|
620
|
+
const f = document.createElement("div");
|
|
621
|
+
f.className = "pluno-pa-widget__tool-lines";
|
|
607
622
|
for (const x of t) {
|
|
608
623
|
const s = document.createElement("div");
|
|
609
|
-
s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(
|
|
624
|
+
s.className = "pluno-pa-widget__tool-line", x.loading && s.appendChild(de());
|
|
610
625
|
const _ = document.createElement("span");
|
|
611
|
-
_.textContent = x.content || "Run tool", s.appendChild(_),
|
|
626
|
+
_.textContent = x.content || "Run tool", s.appendChild(_), f.appendChild(s);
|
|
612
627
|
}
|
|
613
|
-
i.appendChild(
|
|
628
|
+
i.appendChild(f);
|
|
614
629
|
}
|
|
615
630
|
return a.appendChild(i), a;
|
|
616
631
|
}
|
|
617
632
|
function K(t) {
|
|
618
633
|
const e = document.createElement("article");
|
|
619
634
|
e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
620
|
-
const
|
|
621
|
-
return
|
|
635
|
+
const n = document.createElement("img");
|
|
636
|
+
return n.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", n.src = t, n.alt = "", n.setAttribute("aria-hidden", "true"), e.appendChild(n), e;
|
|
622
637
|
}
|
|
623
|
-
function
|
|
638
|
+
function Ve(t) {
|
|
624
639
|
const e = K(t);
|
|
625
|
-
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(
|
|
640
|
+
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(we()), e;
|
|
626
641
|
}
|
|
627
|
-
function
|
|
642
|
+
function we() {
|
|
628
643
|
const t = document.createElement("div");
|
|
629
644
|
t.className = "pluno-pa-widget__status";
|
|
630
645
|
const e = document.createElement("span");
|
|
631
646
|
e.className = "pluno-pa-widget__thinking-dot", e.setAttribute("aria-hidden", "true"), t.appendChild(e);
|
|
632
|
-
const
|
|
633
|
-
return
|
|
647
|
+
const n = document.createElement("span");
|
|
648
|
+
return n.textContent = "Thinking...", t.appendChild(n), t;
|
|
634
649
|
}
|
|
635
|
-
function
|
|
650
|
+
function Ke(t) {
|
|
636
651
|
return `tools:${t.map((e) => e.id).join("|")}`;
|
|
637
652
|
}
|
|
638
|
-
function
|
|
653
|
+
function de() {
|
|
639
654
|
const t = document.createElement("span");
|
|
640
655
|
return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
|
|
641
656
|
}
|
|
642
|
-
function
|
|
657
|
+
function je(t, e) {
|
|
643
658
|
t.setAttribute("aria-label", e ? "Stop" : "Send"), t.classList.toggle("pluno-pa-widget__send--stop", e), t.innerHTML = e ? '<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2" /></svg>' : '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" /></svg>';
|
|
644
659
|
}
|
|
645
|
-
function
|
|
646
|
-
const
|
|
660
|
+
function ce(t, e) {
|
|
661
|
+
const n = e.replace(/\r\n/g, `
|
|
647
662
|
`).split(`
|
|
648
663
|
`);
|
|
649
|
-
let
|
|
650
|
-
for (;
|
|
651
|
-
const a = o
|
|
664
|
+
let o = 0;
|
|
665
|
+
for (; o < n.length; ) {
|
|
666
|
+
const a = n[o];
|
|
652
667
|
if (!a.trim()) {
|
|
653
|
-
|
|
668
|
+
o += 1;
|
|
654
669
|
continue;
|
|
655
670
|
}
|
|
656
671
|
if (a.match(/^```(\w+)?\s*$/)) {
|
|
657
672
|
const p = [];
|
|
658
|
-
for (
|
|
659
|
-
p.push(o
|
|
660
|
-
|
|
661
|
-
const g = document.createElement("pre"),
|
|
662
|
-
|
|
663
|
-
`), g.appendChild(
|
|
673
|
+
for (o += 1; o < n.length && !/^```\s*$/.test(n[o]); )
|
|
674
|
+
p.push(n[o]), o += 1;
|
|
675
|
+
o += o < n.length ? 1 : 0;
|
|
676
|
+
const g = document.createElement("pre"), f = document.createElement("code");
|
|
677
|
+
f.textContent = p.join(`
|
|
678
|
+
`), g.appendChild(f), t.appendChild(g);
|
|
664
679
|
continue;
|
|
665
680
|
}
|
|
666
681
|
const i = a.match(/^(#{1,3})\s+(.+)$/);
|
|
667
682
|
if (i) {
|
|
668
683
|
const p = document.createElement(`h${i[1].length + 2}`);
|
|
669
|
-
$(p, i[2]), t.appendChild(p),
|
|
684
|
+
$(p, i[2]), t.appendChild(p), o += 1;
|
|
670
685
|
continue;
|
|
671
686
|
}
|
|
672
687
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
673
688
|
const p = document.createElement("ul");
|
|
674
|
-
for (;
|
|
689
|
+
for (; o < n.length && /^\s*[-*+]\s+/.test(n[o]); ) {
|
|
675
690
|
const g = document.createElement("li");
|
|
676
|
-
$(g, o
|
|
691
|
+
$(g, n[o].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), o += 1;
|
|
677
692
|
}
|
|
678
693
|
t.appendChild(p);
|
|
679
694
|
continue;
|
|
680
695
|
}
|
|
681
696
|
if (/^\s*\d+\.\s+/.test(a)) {
|
|
682
697
|
const p = document.createElement("ol");
|
|
683
|
-
for (;
|
|
698
|
+
for (; o < n.length && /^\s*\d+\.\s+/.test(n[o]); ) {
|
|
684
699
|
const g = document.createElement("li");
|
|
685
|
-
$(g, o
|
|
700
|
+
$(g, n[o].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), o += 1;
|
|
686
701
|
}
|
|
687
702
|
t.appendChild(p);
|
|
688
703
|
continue;
|
|
689
704
|
}
|
|
690
705
|
const d = [a];
|
|
691
|
-
for (
|
|
692
|
-
d.push(o
|
|
706
|
+
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]); )
|
|
707
|
+
d.push(n[o]), o += 1;
|
|
693
708
|
const u = document.createElement("p");
|
|
694
709
|
d.forEach((p, g) => {
|
|
695
710
|
g > 0 && u.appendChild(document.createElement("br")), $(u, p);
|
|
@@ -697,11 +712,11 @@ function de(t, e) {
|
|
|
697
712
|
}
|
|
698
713
|
}
|
|
699
714
|
function $(t, e) {
|
|
700
|
-
const
|
|
701
|
-
let
|
|
702
|
-
for (const a of e.matchAll(
|
|
715
|
+
const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
716
|
+
let o = 0;
|
|
717
|
+
for (const a of e.matchAll(n)) {
|
|
703
718
|
const r = a.index ?? 0;
|
|
704
|
-
r >
|
|
719
|
+
r > o && t.appendChild(document.createTextNode(e.slice(o, r)));
|
|
705
720
|
const i = a[0];
|
|
706
721
|
if (i.startsWith("`")) {
|
|
707
722
|
const d = document.createElement("code");
|
|
@@ -714,17 +729,17 @@ function $(t, e) {
|
|
|
714
729
|
d.textContent = i.slice(1, -1), t.appendChild(d);
|
|
715
730
|
} else {
|
|
716
731
|
const d = i.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
717
|
-
if (d &&
|
|
732
|
+
if (d && qe(d[2])) {
|
|
718
733
|
const u = document.createElement("a");
|
|
719
734
|
u.href = d[2], u.target = "_top", u.rel = "noreferrer", u.textContent = d[1], t.appendChild(u);
|
|
720
735
|
} else
|
|
721
736
|
t.appendChild(document.createTextNode(i));
|
|
722
737
|
}
|
|
723
|
-
|
|
738
|
+
o = r + i.length;
|
|
724
739
|
}
|
|
725
|
-
|
|
740
|
+
o < e.length && t.appendChild(document.createTextNode(e.slice(o)));
|
|
726
741
|
}
|
|
727
|
-
function
|
|
742
|
+
function qe(t) {
|
|
728
743
|
if (t.startsWith("/") || t.startsWith("#"))
|
|
729
744
|
return !0;
|
|
730
745
|
try {
|
|
@@ -734,11 +749,11 @@ function je(t) {
|
|
|
734
749
|
return !1;
|
|
735
750
|
}
|
|
736
751
|
}
|
|
737
|
-
function
|
|
752
|
+
function ue(t, e) {
|
|
738
753
|
if (t.getElementById("pluno-pa-widget-styles"))
|
|
739
754
|
return;
|
|
740
|
-
const
|
|
741
|
-
|
|
755
|
+
const n = t.ownerDocument.createElement("style");
|
|
756
|
+
n.id = "pluno-pa-widget-styles", n.textContent = `
|
|
742
757
|
:host {
|
|
743
758
|
all: initial;
|
|
744
759
|
color-scheme: light;
|
|
@@ -1579,7 +1594,18 @@ function ce(t, e) {
|
|
|
1579
1594
|
margin-top: -11px;
|
|
1580
1595
|
}
|
|
1581
1596
|
.pluno-pa-widget--scribble .pluno-pa-widget__tool-group {
|
|
1582
|
-
|
|
1597
|
+
align-items: center;
|
|
1598
|
+
margin-bottom: -8px;
|
|
1599
|
+
}
|
|
1600
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__tool-group details {
|
|
1601
|
+
transform: translateY(-3px);
|
|
1602
|
+
}
|
|
1603
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker .pluno-pa-widget__status,
|
|
1604
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__status.pluno-pa-widget__bottom-reserve-compact {
|
|
1605
|
+
transform: translateY(-2px);
|
|
1606
|
+
}
|
|
1607
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__thinking-marker.pluno-pa-widget__bottom-reserve-compact {
|
|
1608
|
+
margin-bottom: 28px;
|
|
1583
1609
|
}
|
|
1584
1610
|
/* Wobbly outlines: the filter runs on a ::before layer that draws each
|
|
1585
1611
|
box's fill and border, so text glyphs stay crisp */
|
|
@@ -1730,9 +1756,9 @@ function ce(t, e) {
|
|
|
1730
1756
|
.pluno-pa-widget--scribble .pluno-pa-widget__close svg {
|
|
1731
1757
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1732
1758
|
}
|
|
1733
|
-
`, t.appendChild(
|
|
1759
|
+
`, t.appendChild(n);
|
|
1734
1760
|
}
|
|
1735
|
-
async function
|
|
1761
|
+
async function Ye() {
|
|
1736
1762
|
return document.body ? document.body : await new Promise((t) => {
|
|
1737
1763
|
const e = new MutationObserver(() => {
|
|
1738
1764
|
document.body && (e.disconnect(), t(document.body));
|
|
@@ -1744,54 +1770,54 @@ function D(t) {
|
|
|
1744
1770
|
const e = document.createElement("span");
|
|
1745
1771
|
return e.textContent = t, e.innerHTML;
|
|
1746
1772
|
}
|
|
1747
|
-
function
|
|
1773
|
+
function me(t) {
|
|
1748
1774
|
return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
|
|
1749
1775
|
}
|
|
1750
|
-
function
|
|
1776
|
+
function Ze(t) {
|
|
1751
1777
|
try {
|
|
1752
|
-
const e = window.localStorage.getItem(
|
|
1778
|
+
const e = window.localStorage.getItem(me(t));
|
|
1753
1779
|
if (!e)
|
|
1754
1780
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1755
|
-
const
|
|
1781
|
+
const n = JSON.parse(e);
|
|
1756
1782
|
return {
|
|
1757
|
-
isOpen:
|
|
1758
|
-
composerValue: typeof
|
|
1759
|
-
openToolGroupKeys: Array.isArray(
|
|
1783
|
+
isOpen: n.isOpen === !0,
|
|
1784
|
+
composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
|
|
1785
|
+
openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : []
|
|
1760
1786
|
};
|
|
1761
1787
|
} catch {
|
|
1762
1788
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1763
1789
|
}
|
|
1764
1790
|
}
|
|
1765
|
-
function
|
|
1791
|
+
function Xe(t, e) {
|
|
1766
1792
|
try {
|
|
1767
|
-
window.localStorage.setItem(
|
|
1793
|
+
window.localStorage.setItem(me(t), JSON.stringify(e));
|
|
1768
1794
|
} catch {
|
|
1769
1795
|
return;
|
|
1770
1796
|
}
|
|
1771
1797
|
}
|
|
1772
|
-
const
|
|
1773
|
-
function
|
|
1798
|
+
const ge = /* @__PURE__ */ new WeakSet();
|
|
1799
|
+
function Je(t) {
|
|
1774
1800
|
return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
|
|
1775
1801
|
}
|
|
1776
|
-
function
|
|
1802
|
+
function be(t) {
|
|
1777
1803
|
const e = t.pathname.split("/");
|
|
1778
1804
|
return e[e.length - 1] ?? "";
|
|
1779
1805
|
}
|
|
1780
|
-
function
|
|
1781
|
-
const
|
|
1782
|
-
return
|
|
1806
|
+
function Qe(t, e) {
|
|
1807
|
+
const n = new URL(t.src, document.baseURI);
|
|
1808
|
+
return n.href === e.href || n.pathname === e.pathname ? !0 : be(n) === be(e);
|
|
1783
1809
|
}
|
|
1784
1810
|
class C extends EventTarget {
|
|
1785
|
-
constructor(e,
|
|
1786
|
-
super(), this.channelId =
|
|
1811
|
+
constructor(e, n) {
|
|
1812
|
+
super(), this.channelId = n, this.url = e, this.addPreviewListener($e, () => {
|
|
1787
1813
|
this.readyState = C.OPEN, this.dispatchEvent(new Event("open"));
|
|
1788
|
-
}), this.addPreviewListener(
|
|
1789
|
-
const a =
|
|
1814
|
+
}), this.addPreviewListener(De, (o) => {
|
|
1815
|
+
const a = o;
|
|
1790
1816
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
1791
|
-
}), this.addPreviewListener(
|
|
1817
|
+
}), this.addPreviewListener(Fe, () => {
|
|
1792
1818
|
this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
1793
|
-
}), this.addPreviewListener(
|
|
1794
|
-
const a =
|
|
1819
|
+
}), this.addPreviewListener(Re, (o) => {
|
|
1820
|
+
const a = o;
|
|
1795
1821
|
this.readyState = C.CLOSED, this.dispatchEvent(
|
|
1796
1822
|
new CloseEvent("close", {
|
|
1797
1823
|
code: a.detail?.code ?? 1e3,
|
|
@@ -1816,37 +1842,37 @@ class C extends EventTarget {
|
|
|
1816
1842
|
binaryType = "blob";
|
|
1817
1843
|
bufferedAmount = 0;
|
|
1818
1844
|
readyState = C.CONNECTING;
|
|
1819
|
-
socketId =
|
|
1845
|
+
socketId = et();
|
|
1820
1846
|
listeners = /* @__PURE__ */ new Map();
|
|
1821
1847
|
send(e) {
|
|
1822
1848
|
if (this.readyState !== C.OPEN)
|
|
1823
1849
|
throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
|
|
1824
1850
|
window.dispatchEvent(
|
|
1825
|
-
new CustomEvent(F(
|
|
1851
|
+
new CustomEvent(F(Me, this.channelId), {
|
|
1826
1852
|
detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
|
|
1827
1853
|
})
|
|
1828
1854
|
);
|
|
1829
1855
|
}
|
|
1830
|
-
close(e,
|
|
1856
|
+
close(e, n) {
|
|
1831
1857
|
this.readyState !== C.CLOSED && (this.readyState = C.CLOSING, window.dispatchEvent(
|
|
1832
|
-
new CustomEvent(F(
|
|
1833
|
-
detail: { socketId: this.socketId, code: e, reason:
|
|
1858
|
+
new CustomEvent(F(Oe, this.channelId), {
|
|
1859
|
+
detail: { socketId: this.socketId, code: e, reason: n }
|
|
1834
1860
|
})
|
|
1835
1861
|
), this.cleanup());
|
|
1836
1862
|
}
|
|
1837
|
-
addPreviewListener(e,
|
|
1838
|
-
const
|
|
1839
|
-
r.detail?.socketId === this.socketId &&
|
|
1863
|
+
addPreviewListener(e, n) {
|
|
1864
|
+
const o = F(e, this.channelId), a = (r) => {
|
|
1865
|
+
r.detail?.socketId === this.socketId && n(r);
|
|
1840
1866
|
};
|
|
1841
|
-
this.listeners.set(
|
|
1867
|
+
this.listeners.set(o, a), window.addEventListener(o, a);
|
|
1842
1868
|
}
|
|
1843
1869
|
cleanup() {
|
|
1844
|
-
for (const [e,
|
|
1845
|
-
window.removeEventListener(e,
|
|
1870
|
+
for (const [e, n] of this.listeners.entries())
|
|
1871
|
+
window.removeEventListener(e, n);
|
|
1846
1872
|
this.listeners.clear();
|
|
1847
1873
|
}
|
|
1848
1874
|
}
|
|
1849
|
-
function
|
|
1875
|
+
function et() {
|
|
1850
1876
|
const t = window.sessionStorage.getItem(te);
|
|
1851
1877
|
if (t)
|
|
1852
1878
|
return t;
|
|
@@ -1856,39 +1882,39 @@ function Qe() {
|
|
|
1856
1882
|
function F(t, e) {
|
|
1857
1883
|
return `${t}:${e}`;
|
|
1858
1884
|
}
|
|
1859
|
-
function
|
|
1885
|
+
function tt(t) {
|
|
1860
1886
|
const e = document.currentScript;
|
|
1861
1887
|
if (e instanceof HTMLScriptElement)
|
|
1862
1888
|
return [e];
|
|
1863
|
-
const
|
|
1889
|
+
const n = new URL(t, document.baseURI).href, o = new URL(n);
|
|
1864
1890
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
1865
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
1891
|
+
(a) => a instanceof HTMLScriptElement && Je(a) && Qe(a, o)
|
|
1866
1892
|
);
|
|
1867
1893
|
}
|
|
1868
|
-
function
|
|
1869
|
-
for (const e of
|
|
1870
|
-
if (
|
|
1894
|
+
function nt(t) {
|
|
1895
|
+
for (const e of tt(t)) {
|
|
1896
|
+
if (ge.has(e) || e.dataset.plunoAutoMount === "false")
|
|
1871
1897
|
continue;
|
|
1872
|
-
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1898
|
+
ge.add(e);
|
|
1899
|
+
const n = e.dataset.plunoPreviewChannel;
|
|
1900
|
+
Ue({
|
|
1875
1901
|
token: e.dataset.plunoToken,
|
|
1876
1902
|
tokenEndpoint: e.dataset.plunoTokenEndpoint,
|
|
1877
1903
|
backendUrl: e.dataset.plunoBackendUrl,
|
|
1878
|
-
webSocketFactory:
|
|
1904
|
+
webSocketFactory: n ? Be(n) : void 0,
|
|
1879
1905
|
launcherLabel: e.dataset.plunoLauncherLabel,
|
|
1880
1906
|
accentColor: e.dataset.plunoAccentColor,
|
|
1881
1907
|
colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
1882
1908
|
fontFamily: e.dataset.plunoFontFamily,
|
|
1883
1909
|
scribbleStyle: e.dataset.plunoScribbleStyle === "true",
|
|
1884
1910
|
position: e.dataset.plunoPosition === "bottom-left" ? "bottom-left" : "bottom-right"
|
|
1885
|
-
}).catch((
|
|
1886
|
-
console.error("Failed to mount Pluno Product Agent widget",
|
|
1911
|
+
}).catch((o) => {
|
|
1912
|
+
console.error("Failed to mount Pluno Product Agent widget", o);
|
|
1887
1913
|
});
|
|
1888
1914
|
}
|
|
1889
1915
|
}
|
|
1890
|
-
|
|
1916
|
+
nt(import.meta.url);
|
|
1891
1917
|
export {
|
|
1892
|
-
|
|
1893
|
-
|
|
1918
|
+
Be as createProductAgentPreviewBridgeWebSocketFactory,
|
|
1919
|
+
Ue as mountPlunoProductAgentWidget
|
|
1894
1920
|
};
|