@pluno/product-agent-web 0.1.12 → 0.1.13
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/boltIcon.d.ts +2 -0
- package/dist/product-agent-widget.js +614 -274
- package/dist/widget.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PlunoProductAgent as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const e =
|
|
1
|
+
import { PlunoProductAgent as be } from "./product-agent-sdk.js";
|
|
2
|
+
const fe = "#7c3aed";
|
|
3
|
+
function we(t) {
|
|
4
|
+
const e = ve(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,11 +75,53 @@ function ce(t) {
|
|
|
75
75
|
</g>
|
|
76
76
|
</svg>`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
78
|
+
function me(t) {
|
|
79
|
+
return `data:image/svg+xml,${encodeURIComponent(we(t))}`;
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const P = "#2c2a1e";
|
|
82
|
+
function _e(t) {
|
|
83
|
+
const e = se(t), o = de(W(e)) > 0.8 ? x(e, -0.3, 0.05) : e, 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";
|
|
84
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" role="img" aria-label="Pluno">
|
|
85
|
+
<defs>
|
|
86
|
+
<clipPath id="scribbleBoltClip">
|
|
87
|
+
<path d="${n}"/>
|
|
88
|
+
</clipPath>
|
|
89
|
+
<filter id="scribbleBoltWobble" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB">
|
|
90
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.011" numOctaves="3" seed="7" result="noise"/>
|
|
91
|
+
<feDisplacementMap in="SourceGraphic" in2="noise" scale="16" xChannelSelector="R" yChannelSelector="G"/>
|
|
92
|
+
</filter>
|
|
93
|
+
</defs>
|
|
94
|
+
<g filter="url(#scribbleBoltWobble)">
|
|
95
|
+
<g clip-path="url(#scribbleBoltClip)">
|
|
96
|
+
<path d="${ye()}" fill="none" stroke="${o}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
|
|
97
|
+
</g>
|
|
98
|
+
<path d="${n}" fill="none" stroke="${P}" stroke-width="18" stroke-linejoin="round"/>
|
|
99
|
+
<g transform="rotate(-2 528 463)">
|
|
100
|
+
<ellipse cx="528" cy="463" rx="73" ry="80" fill="#ffffff" stroke="${P}" stroke-width="13"/>
|
|
101
|
+
<ellipse cx="533" cy="473" rx="45" ry="53" fill="${P}"/>
|
|
102
|
+
<circle cx="557" cy="447" r="16" fill="#ffffff"/>
|
|
103
|
+
</g>
|
|
104
|
+
<g transform="rotate(2 717 462)">
|
|
105
|
+
<ellipse cx="717" cy="462" rx="73" ry="80" fill="#ffffff" stroke="${P}" stroke-width="13"/>
|
|
106
|
+
<ellipse cx="712" cy="473" rx="45" ry="53" fill="${P}"/>
|
|
107
|
+
<circle cx="728" cy="447" r="16" fill="#ffffff"/>
|
|
108
|
+
</g>
|
|
109
|
+
</g>
|
|
110
|
+
</svg>`;
|
|
111
|
+
}
|
|
112
|
+
function xe(t) {
|
|
113
|
+
return `data:image/svg+xml,${encodeURIComponent(_e(t))}`;
|
|
114
|
+
}
|
|
115
|
+
function ye() {
|
|
116
|
+
let o = "M 280 120", n = !1, a = 0;
|
|
117
|
+
for (let r = 150; r <= 1170; r += 62) {
|
|
118
|
+
const i = (a % 3 - 1) * 18, d = n ? 280 - i : 1020 + i;
|
|
119
|
+
o += ` L ${d} ${r}`, n = !n, a += 1;
|
|
120
|
+
}
|
|
121
|
+
return o;
|
|
122
|
+
}
|
|
123
|
+
function ve(t) {
|
|
124
|
+
const e = se(t), o = de(W(e));
|
|
83
125
|
return o > 0.86 ? {
|
|
84
126
|
top: "#ffffff",
|
|
85
127
|
middle: "#f6f6f6",
|
|
@@ -103,84 +145,86 @@ function ue(t) {
|
|
|
103
145
|
inner: "#4b4b4b",
|
|
104
146
|
shadow: "#000000"
|
|
105
147
|
} : {
|
|
106
|
-
top:
|
|
107
|
-
middle:
|
|
108
|
-
bottom:
|
|
109
|
-
edgeStart:
|
|
110
|
-
edgeMiddle:
|
|
111
|
-
edgeEnd:
|
|
112
|
-
glow:
|
|
113
|
-
highlight:
|
|
114
|
-
inner:
|
|
115
|
-
shadow:
|
|
148
|
+
top: x(e, 0.28, -0.03),
|
|
149
|
+
middle: x(e, 0.08, 0.04),
|
|
150
|
+
bottom: x(e, -0.1, 0.02),
|
|
151
|
+
edgeStart: x(e, 0.08, 0.08),
|
|
152
|
+
edgeMiddle: x(e, -0.08, 0.08),
|
|
153
|
+
edgeEnd: x(e, -0.18, 0.05),
|
|
154
|
+
glow: x(e, 0.32, -0.12),
|
|
155
|
+
highlight: x(e, 0.38, -0.18),
|
|
156
|
+
inner: x(e, 0.24, -0.1),
|
|
157
|
+
shadow: x(e, -0.25, -0.08)
|
|
116
158
|
};
|
|
117
159
|
}
|
|
118
|
-
function
|
|
160
|
+
function se(t) {
|
|
119
161
|
const e = t.trim();
|
|
120
|
-
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((o) => o + o).join("").toLowerCase()}` :
|
|
162
|
+
return /^#[0-9a-f]{6}$/i.test(e) ? e.toLowerCase() : /^#[0-9a-f]{3}$/i.test(e) ? `#${e.slice(1).split("").map((o) => o + o).join("").toLowerCase()}` : fe;
|
|
121
163
|
}
|
|
122
|
-
function
|
|
164
|
+
function W(t) {
|
|
123
165
|
return [
|
|
124
166
|
Number.parseInt(t.slice(1, 3), 16),
|
|
125
167
|
Number.parseInt(t.slice(3, 5), 16),
|
|
126
168
|
Number.parseInt(t.slice(5, 7), 16)
|
|
127
169
|
];
|
|
128
170
|
}
|
|
129
|
-
function
|
|
171
|
+
function ke([t, e, o]) {
|
|
130
172
|
const n = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
|
|
131
173
|
return `#${n(t)}${n(e)}${n(o)}`;
|
|
132
174
|
}
|
|
133
|
-
function
|
|
175
|
+
function de([t, e, o]) {
|
|
134
176
|
const n = (a) => {
|
|
135
|
-
const
|
|
136
|
-
return
|
|
177
|
+
const r = a / 255;
|
|
178
|
+
return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
137
179
|
};
|
|
138
180
|
return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
|
|
139
181
|
}
|
|
140
|
-
function
|
|
141
|
-
const [n, a,
|
|
142
|
-
return
|
|
182
|
+
function x(t, e, o) {
|
|
183
|
+
const [n, a, r] = Ce(W(t));
|
|
184
|
+
return ke(Se(n, Y(a + o), Y(r + e)));
|
|
143
185
|
}
|
|
144
|
-
function
|
|
145
|
-
const n = t / 255, a = e / 255,
|
|
146
|
-
if (
|
|
147
|
-
return [0, 0,
|
|
148
|
-
const p =
|
|
149
|
-
return [(
|
|
186
|
+
function Ce([t, e, o]) {
|
|
187
|
+
const n = t / 255, a = e / 255, r = o / 255, i = Math.max(n, a, r), d = Math.min(n, a, r), u = (i + d) / 2;
|
|
188
|
+
if (i === d)
|
|
189
|
+
return [0, 0, u];
|
|
190
|
+
const p = i - d, g = u > 0.5 ? p / (2 - i - d) : p / (i + d);
|
|
191
|
+
return [(i === n ? (a - r) / p + (a < r ? 6 : 0) : i === a ? (r - n) / p + 2 : (n - a) / p + 4) / 6, g, u];
|
|
150
192
|
}
|
|
151
|
-
function
|
|
193
|
+
function Se(t, e, o) {
|
|
152
194
|
if (e === 0)
|
|
153
195
|
return [o * 255, o * 255, o * 255];
|
|
154
196
|
const n = o < 0.5 ? o * (1 + e) : o + e - o * e, a = 2 * o - n;
|
|
155
197
|
return [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
198
|
+
R(a, n, t + 1 / 3) * 255,
|
|
199
|
+
R(a, n, t) * 255,
|
|
200
|
+
R(a, n, t - 1 / 3) * 255
|
|
159
201
|
];
|
|
160
202
|
}
|
|
161
|
-
function
|
|
203
|
+
function R(t, e, o) {
|
|
162
204
|
let n = o;
|
|
163
205
|
return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (e - t) * 6 * n : n < 1 / 2 ? e : n < 2 / 3 ? t + (e - t) * (2 / 3 - n) * 6 : t;
|
|
164
206
|
}
|
|
165
|
-
function
|
|
207
|
+
function Y(t) {
|
|
166
208
|
return Math.max(0, Math.min(1, t));
|
|
167
209
|
}
|
|
168
|
-
const
|
|
210
|
+
const Ee = "product-agent:sdk-preview-socket-connect", Le = "product-agent:sdk-preview-socket-send", Te = "product-agent:sdk-preview-socket-close", Ne = "product-agent:sdk-preview-socket-open", Pe = "product-agent:sdk-preview-socket-message", Me = "product-agent:sdk-preview-socket-error", Ie = "product-agent:sdk-preview-socket-closed", Z = "product-agent:sdk-preview-socket-id", Ae = "product-agent:preview-diagnostic", T = {
|
|
169
211
|
launcherLabel: "Ask for anything...",
|
|
170
212
|
accentColor: "#7c3aed",
|
|
171
213
|
colorScheme: "light",
|
|
172
214
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif',
|
|
215
|
+
scribbleStyle: !1,
|
|
173
216
|
position: "bottom-right"
|
|
174
|
-
};
|
|
175
|
-
function
|
|
217
|
+
}, X = '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>', Oe = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', J = "pluno-pa-scribble-font";
|
|
218
|
+
function $e(t) {
|
|
176
219
|
return (e) => new C(e, t);
|
|
177
220
|
}
|
|
178
|
-
async function
|
|
221
|
+
async function De(t = {}) {
|
|
179
222
|
const e = {
|
|
180
223
|
launcherLabel: t.launcherLabel ?? T.launcherLabel,
|
|
181
224
|
accentColor: t.accentColor ?? T.accentColor,
|
|
182
225
|
colorScheme: t.colorScheme ?? T.colorScheme,
|
|
183
226
|
fontFamily: t.fontFamily ?? T.fontFamily,
|
|
227
|
+
scribbleStyle: t.scribbleStyle ?? T.scribbleStyle,
|
|
184
228
|
position: t.position ?? T.position,
|
|
185
229
|
token: t.token,
|
|
186
230
|
tokenProvider: t.tokenProvider,
|
|
@@ -189,7 +233,7 @@ async function Le(t = {}) {
|
|
|
189
233
|
initialStarterPrompts: t.initialStarterPrompts,
|
|
190
234
|
webSocketFactory: t.webSocketFactory
|
|
191
235
|
};
|
|
192
|
-
|
|
236
|
+
M("web-sdk.widget", "Mounting widget with merged options", {
|
|
193
237
|
accentColor: e.accentColor,
|
|
194
238
|
colorScheme: e.colorScheme,
|
|
195
239
|
fontFamily: e.fontFamily,
|
|
@@ -204,11 +248,33 @@ async function Le(t = {}) {
|
|
|
204
248
|
o.className = "pluno-pa-widget-host";
|
|
205
249
|
const n = o.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
206
250
|
a.className = `pluno-pa-widget pluno-pa-widget--${e.position}`;
|
|
207
|
-
let
|
|
251
|
+
let r = Q(e.accentColor, e.scribbleStyle);
|
|
208
252
|
a.innerHTML = `
|
|
253
|
+
<svg class="pluno-pa-widget__scribble-defs" aria-hidden="true" focusable="false" width="0" height="0">
|
|
254
|
+
<defs>
|
|
255
|
+
<filter id="pluno-pa-scribble-wobble" x="-8%" y="-8%" width="116%" height="116%">
|
|
256
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.012 0.028" numOctaves="3" seed="2" result="stroke-noise" />
|
|
257
|
+
<feDisplacementMap in="SourceGraphic" in2="stroke-noise" scale="3.5" xChannelSelector="R" yChannelSelector="G" result="warped" />
|
|
258
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="1" seed="12" result="ink-noise" />
|
|
259
|
+
<feDisplacementMap in="warped" in2="ink-noise" scale="0.9" xChannelSelector="R" yChannelSelector="G" />
|
|
260
|
+
</filter>
|
|
261
|
+
<filter id="pluno-pa-scribble-wobble-2" x="-8%" y="-8%" width="116%" height="116%">
|
|
262
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.012 0.028" numOctaves="3" seed="5" result="stroke-noise" />
|
|
263
|
+
<feDisplacementMap in="SourceGraphic" in2="stroke-noise" scale="3.5" xChannelSelector="R" yChannelSelector="G" result="warped" />
|
|
264
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="1" seed="15" result="ink-noise" />
|
|
265
|
+
<feDisplacementMap in="warped" in2="ink-noise" scale="0.9" xChannelSelector="R" yChannelSelector="G" />
|
|
266
|
+
</filter>
|
|
267
|
+
<filter id="pluno-pa-scribble-wobble-3" x="-8%" y="-8%" width="116%" height="116%">
|
|
268
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.012 0.028" numOctaves="3" seed="9" result="stroke-noise" />
|
|
269
|
+
<feDisplacementMap in="SourceGraphic" in2="stroke-noise" scale="3.5" xChannelSelector="R" yChannelSelector="G" result="warped" />
|
|
270
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="1" seed="19" result="ink-noise" />
|
|
271
|
+
<feDisplacementMap in="warped" in2="ink-noise" scale="0.9" xChannelSelector="R" yChannelSelector="G" />
|
|
272
|
+
</filter>
|
|
273
|
+
</defs>
|
|
274
|
+
</svg>
|
|
209
275
|
<form class="pluno-pa-widget__launcher">
|
|
210
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${
|
|
211
|
-
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${
|
|
276
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--launcher" src="${$(r)}" alt="" aria-hidden="true" />
|
|
277
|
+
<input class="pluno-pa-widget__launcher-input" type="text" placeholder="${$(e.launcherLabel)}" aria-label="${$(e.launcherLabel)}" />
|
|
212
278
|
</form>
|
|
213
279
|
<button type="button" class="pluno-pa-widget__close" aria-label="Close" hidden>
|
|
214
280
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
@@ -219,7 +285,7 @@ async function Le(t = {}) {
|
|
|
219
285
|
<div class="pluno-pa-widget__timeline-wrap">
|
|
220
286
|
<main class="pluno-pa-widget__timeline">
|
|
221
287
|
<div class="pluno-pa-widget__empty-state">
|
|
222
|
-
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${
|
|
288
|
+
<img class="pluno-pa-widget__character pluno-pa-widget__character--empty" src="${$(r)}" alt="" aria-hidden="true" />
|
|
223
289
|
<div class="pluno-pa-widget__empty">Hey there, I'm Pluno 👋<br />What do you want to do today?</div>
|
|
224
290
|
</div>
|
|
225
291
|
</main>
|
|
@@ -244,150 +310,164 @@ async function Le(t = {}) {
|
|
|
244
310
|
</form>
|
|
245
311
|
</section>
|
|
246
312
|
`, n.appendChild(a);
|
|
247
|
-
const
|
|
248
|
-
|
|
313
|
+
const i = await We(), d = i.ownerDocument;
|
|
314
|
+
i.appendChild(o), a.classList.add(`pluno-pa-widget--${e.colorScheme}`), ie(n, e.accentColor), ee(a, r, {
|
|
249
315
|
accentColor: e.accentColor,
|
|
250
316
|
colorScheme: e.colorScheme,
|
|
251
|
-
fontFamily: e.fontFamily
|
|
252
|
-
|
|
317
|
+
fontFamily: e.fontFamily,
|
|
318
|
+
scribbleStyle: e.scribbleStyle
|
|
319
|
+
}), M("web-sdk.widget", "Applied initial widget appearance", {
|
|
253
320
|
accentColor: e.accentColor,
|
|
254
321
|
colorScheme: e.colorScheme,
|
|
255
322
|
fontFamily: e.fontFamily,
|
|
256
323
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
257
324
|
});
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
325
|
+
const u = a.querySelector(".pluno-pa-widget__launcher"), p = a.querySelector(".pluno-pa-widget__launcher-input"), g = a.querySelector(".pluno-pa-widget__panel"), b = a.querySelector(".pluno-pa-widget__close"), y = 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"), h = a.querySelector(".pluno-pa-widget__timeline");
|
|
326
|
+
if (!u || !p || !g || !b || !y || !s || !_ || !c || !h)
|
|
260
327
|
throw new Error("Failed to mount Product Agent widget");
|
|
261
328
|
const v = e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (async () => {
|
|
262
329
|
if (!e.tokenEndpoint)
|
|
263
330
|
throw new Error("Product Agent widget requires token or tokenEndpoint");
|
|
264
|
-
const
|
|
331
|
+
const l = await fetch(e.tokenEndpoint, {
|
|
265
332
|
method: "POST",
|
|
266
333
|
credentials: "include",
|
|
267
334
|
headers: { "content-type": "application/json" },
|
|
268
335
|
body: JSON.stringify({ origin: location.origin, url: location.href })
|
|
269
336
|
});
|
|
270
|
-
if (!
|
|
337
|
+
if (!l.ok)
|
|
271
338
|
throw new Error("Failed to load Product Agent token");
|
|
272
|
-
const k = await
|
|
339
|
+
const k = await l.json();
|
|
273
340
|
if (!k.token)
|
|
274
341
|
throw new Error("Product Agent token endpoint did not return a token");
|
|
275
342
|
return k.token;
|
|
276
|
-
}), f = await
|
|
343
|
+
}), f = await be.init({
|
|
277
344
|
token: e.token,
|
|
278
345
|
tokenProvider: v,
|
|
279
346
|
backendUrl: e.backendUrl,
|
|
280
347
|
initialStarterPrompts: e.initialStarterPrompts,
|
|
281
348
|
webSocketFactory: e.webSocketFactory
|
|
282
|
-
}), w =
|
|
283
|
-
let
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
|
|
349
|
+
}), w = He(e), m = new Set(w.openToolGroupKeys);
|
|
350
|
+
let S = null, H = !1;
|
|
351
|
+
const ge = () => {
|
|
352
|
+
H || typeof document > "u" || (ie(n, e.accentColor), o.isConnected || d.body?.appendChild(o));
|
|
353
|
+
}, V = new MutationObserver(ge);
|
|
354
|
+
V.observe(d.documentElement, { childList: !0, subtree: !0 });
|
|
355
|
+
const E = () => {
|
|
356
|
+
Ve(e, {
|
|
290
357
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
291
358
|
composerValue: s.value,
|
|
292
|
-
openToolGroupKeys: [...
|
|
359
|
+
openToolGroupKeys: [...m]
|
|
293
360
|
});
|
|
294
|
-
},
|
|
295
|
-
if (
|
|
296
|
-
a.classList.add("pluno-pa-widget--open"),
|
|
361
|
+
}, N = (l = "", k = !0) => {
|
|
362
|
+
if (S !== null && (window.clearTimeout(S), S = null), g.hidden = !1, b.hidden = !1, a.classList.remove("pluno-pa-widget--closing"), !k) {
|
|
363
|
+
a.classList.add("pluno-pa-widget--open"), u.hidden = !0, l && (s.value = l, I(s)), h.scrollTop = h.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E();
|
|
297
364
|
return;
|
|
298
365
|
}
|
|
299
366
|
window.requestAnimationFrame(() => {
|
|
300
|
-
a.classList.add("pluno-pa-widget--open"),
|
|
301
|
-
|
|
367
|
+
a.classList.add("pluno-pa-widget--open"), l && (s.value = l, I(s)), h.scrollTop = h.scrollHeight, s.focus(), s.setSelectionRange(s.value.length, s.value.length), E(), S = window.setTimeout(() => {
|
|
368
|
+
u.hidden = !0, h.scrollTop = h.scrollHeight;
|
|
302
369
|
}, 220);
|
|
303
370
|
});
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
|
|
371
|
+
}, he = () => {
|
|
372
|
+
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(() => {
|
|
373
|
+
g.hidden = !0, b.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
307
374
|
}, 220);
|
|
308
375
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}),
|
|
312
|
-
|
|
376
|
+
u.addEventListener("submit", (l) => {
|
|
377
|
+
l.preventDefault(), N(p.value), p.value = "";
|
|
378
|
+
}), u.addEventListener("click", (l) => {
|
|
379
|
+
l.target !== p && (N(p.value), p.value = "");
|
|
313
380
|
}), p.addEventListener("focus", () => {
|
|
314
|
-
|
|
381
|
+
N(p.value), p.value = "";
|
|
315
382
|
}), p.addEventListener("input", () => {
|
|
316
383
|
if (!p.value)
|
|
317
384
|
return;
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
}),
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
if (r.preventDefault(), c.hidden || !a.classList.contains("pluno-pa-widget--open")) {
|
|
324
|
-
L();
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
V();
|
|
328
|
-
}
|
|
385
|
+
const l = p.value;
|
|
386
|
+
N(l), p.value = "";
|
|
387
|
+
}), b.addEventListener("click", he);
|
|
388
|
+
const L = () => {
|
|
389
|
+
_.disabled = !f.getState().isThinking && s.value.trim().length === 0;
|
|
329
390
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}),
|
|
391
|
+
y.addEventListener("submit", (l) => {
|
|
392
|
+
l.preventDefault(), B(f, s), L();
|
|
393
|
+
}), _.addEventListener("click", () => {
|
|
333
394
|
if (f.getState().isThinking) {
|
|
334
395
|
f.stop();
|
|
335
396
|
return;
|
|
336
397
|
}
|
|
337
|
-
|
|
338
|
-
}),
|
|
339
|
-
f.startNewSession(),
|
|
398
|
+
B(f, s), L();
|
|
399
|
+
}), c.addEventListener("click", () => {
|
|
400
|
+
f.startNewSession(), m.clear(), s.value = "", I(s), E(), L(), s.focus();
|
|
340
401
|
}), s.addEventListener("input", () => {
|
|
341
|
-
|
|
342
|
-
}), s.addEventListener("keydown", (
|
|
343
|
-
|
|
344
|
-
}), a.addEventListener("click", (
|
|
345
|
-
(
|
|
346
|
-
}), w.composerValue && (s.value = w.composerValue,
|
|
347
|
-
const
|
|
348
|
-
let
|
|
349
|
-
return f.on("state", (
|
|
350
|
-
|
|
351
|
-
appearance:
|
|
352
|
-
}),
|
|
402
|
+
I(s), E(), L();
|
|
403
|
+
}), s.addEventListener("keydown", (l) => {
|
|
404
|
+
l.key !== "Enter" || l.shiftKey || (l.preventDefault(), B(f, s), L());
|
|
405
|
+
}), a.addEventListener("click", (l) => {
|
|
406
|
+
(l.target instanceof Element ? l.target : null)?.closest("a[href]") && E();
|
|
407
|
+
}), w.composerValue && (s.value = w.composerValue, I(s)), w.isOpen && N(s.value, !1);
|
|
408
|
+
const K = () => r;
|
|
409
|
+
let F = f.getState().appearance !== null;
|
|
410
|
+
return f.on("state", (l) => {
|
|
411
|
+
l.appearance ? (F = !0, M("web-sdk.widget", "Agent state supplied appearance", {
|
|
412
|
+
appearance: l.appearance
|
|
413
|
+
}), G(l.appearance, "agent.state.appearance")) : F && (F = !1, M("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
353
414
|
fallbackAccentColor: e.accentColor,
|
|
354
415
|
fallbackColorScheme: e.colorScheme,
|
|
355
416
|
fallbackFontFamily: e.fontFamily
|
|
356
|
-
}),
|
|
417
|
+
}), G({}, "agent.state.appearance-cleared")), te(h, _, c, l, m, E, K, (k) => {
|
|
357
418
|
f.sendMessage(k);
|
|
358
|
-
});
|
|
359
|
-
}),
|
|
360
|
-
f.sendMessage(
|
|
361
|
-
}), {
|
|
419
|
+
}), L();
|
|
420
|
+
}), te(h, _, c, f.getState(), m, E, K, (l) => {
|
|
421
|
+
f.sendMessage(l);
|
|
422
|
+
}), L(), {
|
|
362
423
|
agent: f,
|
|
363
|
-
updateAppearance: (
|
|
424
|
+
updateAppearance: (l) => {
|
|
425
|
+
l.scribbleStyle !== void 0 && (e.scribbleStyle = l.scribbleStyle), G(l, "widgetHandle.updateAppearance");
|
|
426
|
+
},
|
|
364
427
|
destroy: () => {
|
|
365
|
-
|
|
428
|
+
H = !0, V.disconnect(), f.destroy(), o.remove();
|
|
366
429
|
}
|
|
367
430
|
};
|
|
368
|
-
function
|
|
369
|
-
const A =
|
|
370
|
-
|
|
431
|
+
function G(l, k) {
|
|
432
|
+
const A = l.accentColor ?? e.accentColor, j = l.colorScheme ?? e.colorScheme, q = l.fontFamily ?? e.fontFamily, z = l.scribbleStyle ?? e.scribbleStyle;
|
|
433
|
+
r = Q(A, z), ee(a, r, {
|
|
371
434
|
accentColor: A,
|
|
372
|
-
colorScheme:
|
|
373
|
-
fontFamily:
|
|
374
|
-
|
|
435
|
+
colorScheme: j,
|
|
436
|
+
fontFamily: q,
|
|
437
|
+
scribbleStyle: z
|
|
438
|
+
}), M("web-sdk.widget", "Updated widget appearance", {
|
|
375
439
|
source: k,
|
|
376
|
-
inputAppearance:
|
|
440
|
+
inputAppearance: l,
|
|
377
441
|
appliedAccentColor: A,
|
|
378
|
-
appliedColorScheme:
|
|
379
|
-
appliedFontFamily:
|
|
442
|
+
appliedColorScheme: j,
|
|
443
|
+
appliedFontFamily: q,
|
|
444
|
+
appliedScribbleStyle: z,
|
|
380
445
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
381
446
|
});
|
|
382
447
|
}
|
|
383
448
|
}
|
|
384
|
-
function
|
|
385
|
-
|
|
449
|
+
function Q(t, e) {
|
|
450
|
+
return e ? xe(t) : me(t);
|
|
451
|
+
}
|
|
452
|
+
function ee(t, e, o) {
|
|
453
|
+
t.classList.toggle("pluno-pa-widget--dark", o.colorScheme === "dark"), t.classList.toggle("pluno-pa-widget--light", o.colorScheme !== "dark"), t.classList.toggle("pluno-pa-widget--scribble", o.scribbleStyle), t.style.setProperty("--pluno-pa-accent", o.accentColor), t.style.fontFamily = o.scribbleStyle ? Oe : o.fontFamily, o.scribbleStyle && Fe(t.ownerDocument);
|
|
386
454
|
const n = Array.from(t.querySelectorAll(".pluno-pa-widget__character"));
|
|
387
455
|
for (const a of n)
|
|
388
456
|
a.src = e;
|
|
389
457
|
}
|
|
390
|
-
function
|
|
458
|
+
function Fe(t) {
|
|
459
|
+
if (t.getElementById(J))
|
|
460
|
+
return;
|
|
461
|
+
const e = t.createElement("style");
|
|
462
|
+
e.id = J, e.textContent = `@font-face {
|
|
463
|
+
font-family: "Architects Daughter";
|
|
464
|
+
font-style: normal;
|
|
465
|
+
font-weight: 400;
|
|
466
|
+
font-display: swap;
|
|
467
|
+
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
468
|
+
}`, t.head.appendChild(e), t.fonts?.load('16px "Architects Daughter"');
|
|
469
|
+
}
|
|
470
|
+
function M(t, e, o) {
|
|
391
471
|
if (typeof window > "u")
|
|
392
472
|
return;
|
|
393
473
|
const n = window, a = {
|
|
@@ -395,131 +475,131 @@ function N(t, e, o) {
|
|
|
395
475
|
source: t,
|
|
396
476
|
message: e,
|
|
397
477
|
details: o
|
|
398
|
-
},
|
|
399
|
-
|
|
478
|
+
}, r = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
479
|
+
r.push(a), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent(Ae, { detail: a }));
|
|
400
480
|
}
|
|
401
|
-
function
|
|
481
|
+
function B(t, e) {
|
|
402
482
|
const o = e.value.trim();
|
|
403
483
|
o && (e.value = "", e.style.height = "22px", e.style.overflowY = "hidden", t.sendMessage(o), e.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
404
484
|
}
|
|
405
|
-
function
|
|
485
|
+
function I(t) {
|
|
406
486
|
t.style.height = "0px";
|
|
407
487
|
const e = Math.max(22, Math.min(t.scrollHeight, 140));
|
|
408
488
|
t.style.height = `${e}px`, t.style.overflowY = t.scrollHeight > 140 ? "auto" : "hidden";
|
|
409
489
|
}
|
|
410
|
-
function
|
|
411
|
-
const
|
|
412
|
-
t.innerHTML = "",
|
|
413
|
-
const p =
|
|
414
|
-
if (o.hidden = !p,
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
490
|
+
function te(t, e, o, n, a, r, i, d) {
|
|
491
|
+
const u = [...n.messages];
|
|
492
|
+
t.innerHTML = "", Be(e, n.isThinking);
|
|
493
|
+
const p = u.length > 0 || !!n.assistantDraft || n.isThinking;
|
|
494
|
+
if (o.hidden = !p, u.length === 0 && !n.assistantDraft && !n.lastError && !n.isThinking) {
|
|
495
|
+
const c = document.createElement("div");
|
|
496
|
+
c.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
497
|
+
const h = document.createElement("img");
|
|
498
|
+
h.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", h.src = i(), h.alt = "", h.setAttribute("aria-hidden", "true"), c.appendChild(h);
|
|
419
499
|
const v = document.createElement("div");
|
|
420
|
-
v.className = "pluno-pa-widget__empty", v.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?",
|
|
500
|
+
v.className = "pluno-pa-widget__empty", v.innerHTML = "Hey there, I'm Pluno 👋<br />What do you want to do today?", c.appendChild(v);
|
|
421
501
|
const f = document.createElement("div");
|
|
422
502
|
f.className = n.starterPrompts.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", n.starterPrompts.length === 0 && f.setAttribute("aria-hidden", "true");
|
|
423
503
|
for (const w of n.starterPrompts) {
|
|
424
|
-
const
|
|
425
|
-
|
|
504
|
+
const m = document.createElement("button");
|
|
505
|
+
m.type = "button", m.className = "pluno-pa-widget__starter-prompt", m.textContent = `"${w}"`, m.addEventListener("click", () => {
|
|
426
506
|
d(w);
|
|
427
|
-
}), f.appendChild(
|
|
507
|
+
}), f.appendChild(m);
|
|
428
508
|
}
|
|
429
|
-
|
|
509
|
+
c.appendChild(f), t.appendChild(c);
|
|
430
510
|
return;
|
|
431
511
|
}
|
|
432
|
-
let
|
|
512
|
+
let g = null, b = null, y = [];
|
|
433
513
|
const s = () => {
|
|
434
|
-
if (
|
|
514
|
+
if (y.length === 0)
|
|
435
515
|
return !1;
|
|
436
|
-
const
|
|
437
|
-
return t.appendChild(
|
|
516
|
+
const c = Ge(y, a, r, i());
|
|
517
|
+
return t.appendChild(c), g = null, b = c, y = [], !0;
|
|
438
518
|
};
|
|
439
|
-
for (let
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
|
|
519
|
+
for (let c = 0; c < u.length; c += 1) {
|
|
520
|
+
const h = u[c];
|
|
521
|
+
if (h.role === "tool") {
|
|
522
|
+
y.push(h);
|
|
443
523
|
continue;
|
|
444
524
|
}
|
|
445
|
-
if (
|
|
525
|
+
if (h.role === "system")
|
|
446
526
|
continue;
|
|
447
|
-
const v = s(), f =
|
|
448
|
-
if (
|
|
449
|
-
const
|
|
450
|
-
t.appendChild(
|
|
527
|
+
const v = s(), f = ne(h.content);
|
|
528
|
+
if (h.role === "assistant" && !v) {
|
|
529
|
+
const m = U(i());
|
|
530
|
+
t.appendChild(m), g = null, b = m;
|
|
451
531
|
}
|
|
452
532
|
const w = document.createElement("div");
|
|
453
|
-
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${
|
|
533
|
+
w.className = `pluno-pa-widget__message pluno-pa-widget__message--${h.role}`, h.role === "assistant" ? re(w, f) : w.textContent = f, w.appendChild(oe(f)), t.appendChild(w), g = w, b = null;
|
|
454
534
|
}
|
|
455
|
-
const
|
|
535
|
+
const _ = s();
|
|
456
536
|
if (n.assistantDraft) {
|
|
457
|
-
if (!
|
|
458
|
-
const v =
|
|
459
|
-
t.appendChild(v),
|
|
537
|
+
if (!_) {
|
|
538
|
+
const v = U(i());
|
|
539
|
+
t.appendChild(v), g = null, b = v;
|
|
460
540
|
}
|
|
461
|
-
const
|
|
462
|
-
|
|
541
|
+
const c = ne(n.assistantDraft), h = document.createElement("div");
|
|
542
|
+
h.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", re(h, c), h.appendChild(oe(c)), t.appendChild(h), g = h, b = null;
|
|
463
543
|
}
|
|
464
544
|
if (n.isThinking && !n.assistantDraft)
|
|
465
|
-
if (
|
|
466
|
-
const
|
|
467
|
-
t.appendChild(
|
|
545
|
+
if (_) {
|
|
546
|
+
const c = ce();
|
|
547
|
+
t.appendChild(c), g = null, b = c;
|
|
468
548
|
} else {
|
|
469
|
-
const
|
|
470
|
-
t.appendChild(
|
|
549
|
+
const c = ze(i());
|
|
550
|
+
t.appendChild(c), g = null, b = c;
|
|
471
551
|
}
|
|
472
552
|
if (n.lastError) {
|
|
473
|
-
const
|
|
474
|
-
|
|
553
|
+
const c = document.createElement("div");
|
|
554
|
+
c.className = "pluno-pa-widget__error", c.textContent = n.lastError, t.appendChild(c), g = c, b = null;
|
|
475
555
|
}
|
|
476
|
-
|
|
556
|
+
g?.classList.add("pluno-pa-widget__message--bottom-reserve"), b?.classList.add("pluno-pa-widget__bottom-reserve-compact"), t.scrollTop = t.scrollHeight;
|
|
477
557
|
}
|
|
478
|
-
function
|
|
558
|
+
function oe(t) {
|
|
479
559
|
const e = document.createElement("button");
|
|
480
560
|
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", (o) => {
|
|
481
561
|
o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(t);
|
|
482
562
|
}), e;
|
|
483
563
|
}
|
|
484
|
-
function
|
|
564
|
+
function ne(t) {
|
|
485
565
|
return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
486
566
|
}
|
|
487
|
-
function
|
|
567
|
+
function Ge(t, e, o, n) {
|
|
488
568
|
const a = document.createElement("article");
|
|
489
569
|
a.className = "pluno-pa-widget__tool-group", a.title = new Date(t[t.length - 1].createdAt).toLocaleString();
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
570
|
+
const r = document.createElement("img");
|
|
571
|
+
r.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", r.src = n, r.alt = "", r.setAttribute("aria-hidden", "true"), a.appendChild(r);
|
|
572
|
+
const i = document.createElement("details"), d = Re(t);
|
|
573
|
+
i.open = e.has(d), i.addEventListener("toggle", () => {
|
|
574
|
+
i.open ? e.add(d) : e.delete(d), o();
|
|
495
575
|
});
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
for (const
|
|
576
|
+
const u = document.createElement("summary");
|
|
577
|
+
u.className = "pluno-pa-widget__tool-summary", t.some((b) => b.loading) && u.appendChild(ae());
|
|
578
|
+
const g = document.createElement("span");
|
|
579
|
+
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) {
|
|
580
|
+
const b = document.createElement("div");
|
|
581
|
+
b.className = "pluno-pa-widget__tool-lines";
|
|
582
|
+
for (const y of t) {
|
|
503
583
|
const s = document.createElement("div");
|
|
504
|
-
s.className = "pluno-pa-widget__tool-line",
|
|
505
|
-
const
|
|
506
|
-
|
|
584
|
+
s.className = "pluno-pa-widget__tool-line", y.loading && s.appendChild(ae());
|
|
585
|
+
const _ = document.createElement("span");
|
|
586
|
+
_.textContent = y.content || "Run tool", s.appendChild(_), b.appendChild(s);
|
|
507
587
|
}
|
|
508
|
-
|
|
588
|
+
i.appendChild(b);
|
|
509
589
|
}
|
|
510
|
-
return a.appendChild(
|
|
590
|
+
return a.appendChild(i), a;
|
|
511
591
|
}
|
|
512
|
-
function
|
|
592
|
+
function U(t) {
|
|
513
593
|
const e = document.createElement("article");
|
|
514
594
|
e.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
515
595
|
const o = document.createElement("img");
|
|
516
596
|
return o.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", o.src = t, o.alt = "", o.setAttribute("aria-hidden", "true"), e.appendChild(o), e;
|
|
517
597
|
}
|
|
518
|
-
function
|
|
519
|
-
const e =
|
|
520
|
-
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(
|
|
598
|
+
function ze(t) {
|
|
599
|
+
const e = U(t);
|
|
600
|
+
return e.classList.add("pluno-pa-widget__thinking-marker"), e.appendChild(ce()), e;
|
|
521
601
|
}
|
|
522
|
-
function
|
|
602
|
+
function ce() {
|
|
523
603
|
const t = document.createElement("div");
|
|
524
604
|
t.className = "pluno-pa-widget__status";
|
|
525
605
|
const e = document.createElement("span");
|
|
@@ -527,17 +607,17 @@ function re() {
|
|
|
527
607
|
const o = document.createElement("span");
|
|
528
608
|
return o.textContent = "Thinking...", t.appendChild(o), t;
|
|
529
609
|
}
|
|
530
|
-
function
|
|
610
|
+
function Re(t) {
|
|
531
611
|
return `tools:${t.map((e) => e.id).join("|")}`;
|
|
532
612
|
}
|
|
533
|
-
function
|
|
613
|
+
function ae() {
|
|
534
614
|
const t = document.createElement("span");
|
|
535
615
|
return t.className = "pluno-pa-widget__spinner", t.setAttribute("aria-hidden", "true"), t;
|
|
536
616
|
}
|
|
537
|
-
function
|
|
617
|
+
function Be(t, e) {
|
|
538
618
|
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>';
|
|
539
619
|
}
|
|
540
|
-
function
|
|
620
|
+
function re(t, e) {
|
|
541
621
|
const o = e.replace(/\r\n/g, `
|
|
542
622
|
`).split(`
|
|
543
623
|
`);
|
|
@@ -553,22 +633,22 @@ function te(t, e) {
|
|
|
553
633
|
for (n += 1; n < o.length && !/^```\s*$/.test(o[n]); )
|
|
554
634
|
p.push(o[n]), n += 1;
|
|
555
635
|
n += n < o.length ? 1 : 0;
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
`),
|
|
636
|
+
const g = document.createElement("pre"), b = document.createElement("code");
|
|
637
|
+
b.textContent = p.join(`
|
|
638
|
+
`), g.appendChild(b), t.appendChild(g);
|
|
559
639
|
continue;
|
|
560
640
|
}
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
563
|
-
const p = document.createElement(`h${
|
|
564
|
-
|
|
641
|
+
const i = a.match(/^(#{1,3})\s+(.+)$/);
|
|
642
|
+
if (i) {
|
|
643
|
+
const p = document.createElement(`h${i[1].length + 2}`);
|
|
644
|
+
O(p, i[2]), t.appendChild(p), n += 1;
|
|
565
645
|
continue;
|
|
566
646
|
}
|
|
567
647
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
568
648
|
const p = document.createElement("ul");
|
|
569
649
|
for (; n < o.length && /^\s*[-*+]\s+/.test(o[n]); ) {
|
|
570
|
-
const
|
|
571
|
-
|
|
650
|
+
const g = document.createElement("li");
|
|
651
|
+
O(g, o[n].replace(/^\s*[-*+]\s+/, "")), p.appendChild(g), n += 1;
|
|
572
652
|
}
|
|
573
653
|
t.appendChild(p);
|
|
574
654
|
continue;
|
|
@@ -576,8 +656,8 @@ function te(t, e) {
|
|
|
576
656
|
if (/^\s*\d+\.\s+/.test(a)) {
|
|
577
657
|
const p = document.createElement("ol");
|
|
578
658
|
for (; n < o.length && /^\s*\d+\.\s+/.test(o[n]); ) {
|
|
579
|
-
const
|
|
580
|
-
|
|
659
|
+
const g = document.createElement("li");
|
|
660
|
+
O(g, o[n].replace(/^\s*\d+\.\s+/, "")), p.appendChild(g), n += 1;
|
|
581
661
|
}
|
|
582
662
|
t.appendChild(p);
|
|
583
663
|
continue;
|
|
@@ -585,41 +665,41 @@ function te(t, e) {
|
|
|
585
665
|
const d = [a];
|
|
586
666
|
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]); )
|
|
587
667
|
d.push(o[n]), n += 1;
|
|
588
|
-
const
|
|
589
|
-
d.forEach((p,
|
|
590
|
-
|
|
591
|
-
}), t.appendChild(
|
|
668
|
+
const u = document.createElement("p");
|
|
669
|
+
d.forEach((p, g) => {
|
|
670
|
+
g > 0 && u.appendChild(document.createElement("br")), O(u, p);
|
|
671
|
+
}), t.appendChild(u);
|
|
592
672
|
}
|
|
593
673
|
}
|
|
594
|
-
function
|
|
674
|
+
function O(t, e) {
|
|
595
675
|
const o = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
596
676
|
let n = 0;
|
|
597
677
|
for (const a of e.matchAll(o)) {
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
678
|
+
const r = a.index ?? 0;
|
|
679
|
+
r > n && t.appendChild(document.createTextNode(e.slice(n, r)));
|
|
680
|
+
const i = a[0];
|
|
681
|
+
if (i.startsWith("`")) {
|
|
602
682
|
const d = document.createElement("code");
|
|
603
|
-
d.textContent =
|
|
604
|
-
} else if (
|
|
683
|
+
d.textContent = i.slice(1, -1), t.appendChild(d);
|
|
684
|
+
} else if (i.startsWith("**")) {
|
|
605
685
|
const d = document.createElement("strong");
|
|
606
|
-
d.textContent =
|
|
607
|
-
} else if (
|
|
686
|
+
d.textContent = i.slice(2, -2), t.appendChild(d);
|
|
687
|
+
} else if (i.startsWith("*")) {
|
|
608
688
|
const d = document.createElement("em");
|
|
609
|
-
d.textContent =
|
|
689
|
+
d.textContent = i.slice(1, -1), t.appendChild(d);
|
|
610
690
|
} else {
|
|
611
|
-
const d =
|
|
612
|
-
if (d &&
|
|
613
|
-
const
|
|
614
|
-
|
|
691
|
+
const d = i.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
692
|
+
if (d && Ue(d[2])) {
|
|
693
|
+
const u = document.createElement("a");
|
|
694
|
+
u.href = d[2], u.target = "_top", u.rel = "noreferrer", u.textContent = d[1], t.appendChild(u);
|
|
615
695
|
} else
|
|
616
|
-
t.appendChild(document.createTextNode(
|
|
696
|
+
t.appendChild(document.createTextNode(i));
|
|
617
697
|
}
|
|
618
|
-
n =
|
|
698
|
+
n = r + i.length;
|
|
619
699
|
}
|
|
620
700
|
n < e.length && t.appendChild(document.createTextNode(e.slice(n)));
|
|
621
701
|
}
|
|
622
|
-
function
|
|
702
|
+
function Ue(t) {
|
|
623
703
|
if (t.startsWith("/") || t.startsWith("#"))
|
|
624
704
|
return !0;
|
|
625
705
|
try {
|
|
@@ -629,7 +709,7 @@ function Ie(t) {
|
|
|
629
709
|
return !1;
|
|
630
710
|
}
|
|
631
711
|
}
|
|
632
|
-
function
|
|
712
|
+
function ie(t, e) {
|
|
633
713
|
if (t.getElementById("pluno-pa-widget-styles"))
|
|
634
714
|
return;
|
|
635
715
|
const o = t.ownerDocument.createElement("style");
|
|
@@ -714,6 +794,7 @@ function ne(t, e) {
|
|
|
714
794
|
position: absolute;
|
|
715
795
|
display: flex;
|
|
716
796
|
align-items: center;
|
|
797
|
+
cursor: text;
|
|
717
798
|
right: 0;
|
|
718
799
|
bottom: 0;
|
|
719
800
|
width: var(--pluno-pa-launcher-width);
|
|
@@ -1366,9 +1447,267 @@ function ne(t, e) {
|
|
|
1366
1447
|
.pluno-pa-widget__error.pluno-pa-widget__message--bottom-reserve {
|
|
1367
1448
|
margin-bottom: 46px;
|
|
1368
1449
|
}
|
|
1450
|
+
|
|
1451
|
+
/* ── Scribble style (hand-drawn diary look, opt-in) ─────────── */
|
|
1452
|
+
.pluno-pa-widget__scribble-defs {
|
|
1453
|
+
position: absolute;
|
|
1454
|
+
width: 0;
|
|
1455
|
+
height: 0;
|
|
1456
|
+
overflow: hidden;
|
|
1457
|
+
}
|
|
1458
|
+
.pluno-pa-widget--scribble {
|
|
1459
|
+
/* Paper is always light; scribble ignores the configured color scheme */
|
|
1460
|
+
--pluno-pa-bg: #fdfaf1;
|
|
1461
|
+
--pluno-pa-surface: #f7f2e3;
|
|
1462
|
+
--pluno-pa-bubble: #f3ecd8;
|
|
1463
|
+
--pluno-pa-text: #18181b;
|
|
1464
|
+
--pluno-pa-muted: #5c5c63;
|
|
1465
|
+
--pluno-pa-faint: #8e8e95;
|
|
1466
|
+
--pluno-pa-divider: rgba(40, 36, 20, 0.45);
|
|
1467
|
+
--pluno-pa-launcher-hairline: rgba(40, 36, 20, 0.45);
|
|
1468
|
+
--pluno-pa-accent-soft: rgba(44, 42, 30, 0.14);
|
|
1469
|
+
--pluno-pa-scribble-grid-line: rgba(96, 138, 188, 0.22);
|
|
1470
|
+
--pluno-pa-scribble-wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
|
1471
|
+
--pluno-pa-scribble-wobble-alt: 15px 225px 15px 255px / 255px 15px 225px 15px;
|
|
1472
|
+
font-size: 17px;
|
|
1473
|
+
}
|
|
1474
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__panel {
|
|
1475
|
+
/* The paper sheet and border live on ::before so the wobble filter can
|
|
1476
|
+
bend them; overflow must stay visible for the spiral binding on top */
|
|
1477
|
+
overflow: visible;
|
|
1478
|
+
isolation: isolate;
|
|
1479
|
+
background: transparent;
|
|
1480
|
+
border: 2px solid transparent;
|
|
1481
|
+
border-radius: 18px 15px 20px 14px / 15px 19px 14px 20px;
|
|
1482
|
+
box-shadow: none;
|
|
1483
|
+
}
|
|
1484
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__panel::before {
|
|
1485
|
+
content: "";
|
|
1486
|
+
position: absolute;
|
|
1487
|
+
inset: -2px;
|
|
1488
|
+
z-index: -1;
|
|
1489
|
+
border: 2px solid var(--pluno-pa-divider);
|
|
1490
|
+
border-radius: inherit;
|
|
1491
|
+
background-color: var(--pluno-pa-bg);
|
|
1492
|
+
background-image:
|
|
1493
|
+
linear-gradient(var(--pluno-pa-scribble-grid-line) 1px, transparent 1px),
|
|
1494
|
+
linear-gradient(90deg, var(--pluno-pa-scribble-grid-line) 1px, transparent 1px);
|
|
1495
|
+
background-size: 22px 22px;
|
|
1496
|
+
filter: url(#pluno-pa-scribble-wobble);
|
|
1497
|
+
pointer-events: none;
|
|
1498
|
+
}
|
|
1499
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__panel::after {
|
|
1500
|
+
content: "";
|
|
1501
|
+
position: absolute;
|
|
1502
|
+
top: -16px;
|
|
1503
|
+
left: 16px;
|
|
1504
|
+
right: 16px;
|
|
1505
|
+
height: 36px;
|
|
1506
|
+
z-index: 3;
|
|
1507
|
+
background-image: url('${X}');
|
|
1508
|
+
background-repeat: repeat-x;
|
|
1509
|
+
background-size: 104px 36px;
|
|
1510
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1511
|
+
pointer-events: none;
|
|
1512
|
+
}
|
|
1513
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__timeline {
|
|
1514
|
+
padding-top: 34px;
|
|
1515
|
+
}
|
|
1516
|
+
/* The top text fade paints a square-cornered bg gradient; with the panel
|
|
1517
|
+
overflow visible for the spiral it would poke past the rounded border */
|
|
1518
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__timeline-wrap::before {
|
|
1519
|
+
display: none;
|
|
1520
|
+
}
|
|
1521
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer {
|
|
1522
|
+
background: transparent;
|
|
1523
|
+
border-top: 2px dashed var(--pluno-pa-divider);
|
|
1524
|
+
}
|
|
1525
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--assistant code,
|
|
1526
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--assistant pre {
|
|
1527
|
+
font-family: inherit;
|
|
1528
|
+
}
|
|
1529
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message {
|
|
1530
|
+
font-size: 17px;
|
|
1531
|
+
}
|
|
1532
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__input {
|
|
1533
|
+
font-size: 17px;
|
|
1534
|
+
line-height: 26px;
|
|
1535
|
+
height: 26px;
|
|
1536
|
+
min-height: 26px;
|
|
1537
|
+
}
|
|
1538
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__starter-prompt {
|
|
1539
|
+
font-size: 17px;
|
|
1540
|
+
}
|
|
1541
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__empty-state--starter .pluno-pa-widget__empty {
|
|
1542
|
+
font-size: 28px;
|
|
1543
|
+
}
|
|
1544
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__character--empty {
|
|
1545
|
+
width: 132px;
|
|
1546
|
+
height: 132px;
|
|
1547
|
+
}
|
|
1548
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__empty-state--starter .pluno-pa-widget__character--empty {
|
|
1549
|
+
margin-bottom: -36px;
|
|
1550
|
+
}
|
|
1551
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__character--tool-group {
|
|
1552
|
+
width: 50px;
|
|
1553
|
+
height: 50px;
|
|
1554
|
+
margin-top: -11px;
|
|
1555
|
+
}
|
|
1556
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__tool-group {
|
|
1557
|
+
margin-bottom: -16px;
|
|
1558
|
+
}
|
|
1559
|
+
/* Wobbly outlines: the filter runs on a ::before layer that draws each
|
|
1560
|
+
box's fill and border, so text glyphs stay crisp */
|
|
1561
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--user {
|
|
1562
|
+
border-radius: var(--pluno-pa-scribble-wobble-alt);
|
|
1563
|
+
transform: rotate(-0.6deg);
|
|
1564
|
+
}
|
|
1565
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer-inner {
|
|
1566
|
+
border-radius: var(--pluno-pa-scribble-wobble);
|
|
1567
|
+
}
|
|
1568
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--user,
|
|
1569
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer-inner,
|
|
1570
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher,
|
|
1571
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send,
|
|
1572
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat,
|
|
1573
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy,
|
|
1574
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close {
|
|
1575
|
+
isolation: isolate;
|
|
1576
|
+
border: 2px solid transparent;
|
|
1577
|
+
background: transparent;
|
|
1578
|
+
box-shadow: none;
|
|
1579
|
+
}
|
|
1580
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--user::before,
|
|
1581
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer-inner::before,
|
|
1582
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher::before,
|
|
1583
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send::before,
|
|
1584
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat::before,
|
|
1585
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy::before,
|
|
1586
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close::before {
|
|
1587
|
+
content: "";
|
|
1588
|
+
position: absolute;
|
|
1589
|
+
inset: -2px;
|
|
1590
|
+
z-index: -1;
|
|
1591
|
+
border: 2px solid var(--pluno-pa-divider);
|
|
1592
|
+
border-radius: inherit;
|
|
1593
|
+
background: var(--pluno-pa-surface);
|
|
1594
|
+
filter: url(#pluno-pa-scribble-wobble-3);
|
|
1595
|
+
pointer-events: none;
|
|
1596
|
+
}
|
|
1597
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message--user::before {
|
|
1598
|
+
background: var(--pluno-pa-bubble);
|
|
1599
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1600
|
+
}
|
|
1601
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send::before {
|
|
1602
|
+
background: var(--pluno-pa-accent);
|
|
1603
|
+
}
|
|
1604
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send:disabled::before {
|
|
1605
|
+
background: var(--pluno-pa-surface);
|
|
1606
|
+
}
|
|
1607
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat::before,
|
|
1608
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy::before,
|
|
1609
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close::before {
|
|
1610
|
+
background: var(--pluno-pa-bg);
|
|
1611
|
+
}
|
|
1612
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer-inner:focus-within {
|
|
1613
|
+
border-color: transparent;
|
|
1614
|
+
}
|
|
1615
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__composer-inner:focus-within::before {
|
|
1616
|
+
border-color: var(--pluno-pa-accent);
|
|
1617
|
+
}
|
|
1618
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send,
|
|
1619
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat,
|
|
1620
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy,
|
|
1621
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close {
|
|
1622
|
+
border-radius: 43% 57% 39% 61% / 59% 41% 58% 42%;
|
|
1623
|
+
}
|
|
1624
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send::after,
|
|
1625
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat::after,
|
|
1626
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy::after,
|
|
1627
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close::after {
|
|
1628
|
+
content: "";
|
|
1629
|
+
position: absolute;
|
|
1630
|
+
inset: -3px;
|
|
1631
|
+
z-index: -1;
|
|
1632
|
+
border: 2px solid var(--pluno-pa-divider);
|
|
1633
|
+
border-radius: 58% 42% 56% 44% / 43% 57% 45% 55%;
|
|
1634
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1635
|
+
pointer-events: none;
|
|
1636
|
+
opacity: 0.6;
|
|
1637
|
+
transform: rotate(12deg);
|
|
1638
|
+
}
|
|
1639
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat::after {
|
|
1640
|
+
transform: rotate(-10deg);
|
|
1641
|
+
filter: url(#pluno-pa-scribble-wobble);
|
|
1642
|
+
}
|
|
1643
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy::after {
|
|
1644
|
+
transform: rotate(14deg);
|
|
1645
|
+
filter: url(#pluno-pa-scribble-wobble-3);
|
|
1646
|
+
}
|
|
1647
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close::after {
|
|
1648
|
+
transform: rotate(-13deg);
|
|
1649
|
+
filter: url(#pluno-pa-scribble-wobble-3);
|
|
1650
|
+
}
|
|
1651
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send::before {
|
|
1652
|
+
transform: rotate(-7deg);
|
|
1653
|
+
filter: url(#pluno-pa-scribble-wobble);
|
|
1654
|
+
}
|
|
1655
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat::before {
|
|
1656
|
+
transform: rotate(6deg);
|
|
1657
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1658
|
+
}
|
|
1659
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy::before {
|
|
1660
|
+
transform: rotate(-9deg);
|
|
1661
|
+
}
|
|
1662
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close::before {
|
|
1663
|
+
transform: rotate(8deg);
|
|
1664
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1665
|
+
}
|
|
1666
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher {
|
|
1667
|
+
/* A paper strip, not a chat capsule */
|
|
1668
|
+
border-radius: 14px 11px 15px 10px / 12px 15px 10px 14px;
|
|
1669
|
+
/* Taller strip so the bolt clears the spiral ring stubs */
|
|
1670
|
+
height: 48px;
|
|
1671
|
+
}
|
|
1672
|
+
.pluno-pa-widget--scribble:not(.pluno-pa-widget--open):not(.pluno-pa-widget--closing) {
|
|
1673
|
+
height: 48px;
|
|
1674
|
+
}
|
|
1675
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__character--launcher {
|
|
1676
|
+
margin-top: 3px;
|
|
1677
|
+
}
|
|
1678
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher-input {
|
|
1679
|
+
margin-top: 2px;
|
|
1680
|
+
}
|
|
1681
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher::before {
|
|
1682
|
+
background-color: var(--pluno-pa-bg);
|
|
1683
|
+
background-image:
|
|
1684
|
+
linear-gradient(var(--pluno-pa-scribble-grid-line) 1px, transparent 1px),
|
|
1685
|
+
linear-gradient(90deg, var(--pluno-pa-scribble-grid-line) 1px, transparent 1px);
|
|
1686
|
+
background-size: 22px 22px;
|
|
1687
|
+
}
|
|
1688
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__launcher::after {
|
|
1689
|
+
content: "";
|
|
1690
|
+
position: absolute;
|
|
1691
|
+
top: -11px;
|
|
1692
|
+
left: 12px;
|
|
1693
|
+
right: 12px;
|
|
1694
|
+
height: 22px;
|
|
1695
|
+
z-index: 1;
|
|
1696
|
+
background-image: url('${X}');
|
|
1697
|
+
background-repeat: repeat-x;
|
|
1698
|
+
background-size: 62px 21.5px;
|
|
1699
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1700
|
+
pointer-events: none;
|
|
1701
|
+
}
|
|
1702
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__send svg,
|
|
1703
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__new-chat svg,
|
|
1704
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__message-copy svg,
|
|
1705
|
+
.pluno-pa-widget--scribble .pluno-pa-widget__close svg {
|
|
1706
|
+
filter: url(#pluno-pa-scribble-wobble-2);
|
|
1707
|
+
}
|
|
1369
1708
|
`, t.appendChild(o);
|
|
1370
1709
|
}
|
|
1371
|
-
async function
|
|
1710
|
+
async function We() {
|
|
1372
1711
|
return document.body ? document.body : await new Promise((t) => {
|
|
1373
1712
|
const e = new MutationObserver(() => {
|
|
1374
1713
|
document.body && (e.disconnect(), t(document.body));
|
|
@@ -1376,16 +1715,16 @@ async function Me() {
|
|
|
1376
1715
|
e.observe(document.documentElement, { childList: !0 });
|
|
1377
1716
|
});
|
|
1378
1717
|
}
|
|
1379
|
-
function
|
|
1718
|
+
function $(t) {
|
|
1380
1719
|
const e = document.createElement("span");
|
|
1381
1720
|
return e.textContent = t, e.innerHTML;
|
|
1382
1721
|
}
|
|
1383
|
-
function
|
|
1722
|
+
function ue(t) {
|
|
1384
1723
|
return `pluno.productAgent.widgetState.${location.origin}.${t.backendUrl ?? ""}.${t.tokenEndpoint ?? ""}.${t.position ?? ""}`;
|
|
1385
1724
|
}
|
|
1386
|
-
function
|
|
1725
|
+
function He(t) {
|
|
1387
1726
|
try {
|
|
1388
|
-
const e = window.localStorage.getItem(
|
|
1727
|
+
const e = window.localStorage.getItem(ue(t));
|
|
1389
1728
|
if (!e)
|
|
1390
1729
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1391
1730
|
const o = JSON.parse(e);
|
|
@@ -1398,35 +1737,35 @@ function Oe(t) {
|
|
|
1398
1737
|
return { isOpen: !1, composerValue: "", openToolGroupKeys: [] };
|
|
1399
1738
|
}
|
|
1400
1739
|
}
|
|
1401
|
-
function
|
|
1740
|
+
function Ve(t, e) {
|
|
1402
1741
|
try {
|
|
1403
|
-
window.localStorage.setItem(
|
|
1742
|
+
window.localStorage.setItem(ue(t), JSON.stringify(e));
|
|
1404
1743
|
} catch {
|
|
1405
1744
|
return;
|
|
1406
1745
|
}
|
|
1407
1746
|
}
|
|
1408
|
-
const
|
|
1409
|
-
function
|
|
1747
|
+
const le = /* @__PURE__ */ new WeakSet();
|
|
1748
|
+
function Ke(t) {
|
|
1410
1749
|
return Object.keys(t.dataset).some((e) => e.startsWith("pluno"));
|
|
1411
1750
|
}
|
|
1412
|
-
function
|
|
1751
|
+
function pe(t) {
|
|
1413
1752
|
const e = t.pathname.split("/");
|
|
1414
1753
|
return e[e.length - 1] ?? "";
|
|
1415
1754
|
}
|
|
1416
|
-
function
|
|
1755
|
+
function je(t, e) {
|
|
1417
1756
|
const o = new URL(t.src, document.baseURI);
|
|
1418
|
-
return o.href === e.href || o.pathname === e.pathname ? !0 :
|
|
1757
|
+
return o.href === e.href || o.pathname === e.pathname ? !0 : pe(o) === pe(e);
|
|
1419
1758
|
}
|
|
1420
1759
|
class C extends EventTarget {
|
|
1421
1760
|
constructor(e, o) {
|
|
1422
|
-
super(), this.channelId = o, this.url = e, this.addPreviewListener(
|
|
1761
|
+
super(), this.channelId = o, this.url = e, this.addPreviewListener(Ne, () => {
|
|
1423
1762
|
this.readyState = C.OPEN, this.dispatchEvent(new Event("open"));
|
|
1424
|
-
}), this.addPreviewListener(
|
|
1763
|
+
}), this.addPreviewListener(Pe, (n) => {
|
|
1425
1764
|
const a = n;
|
|
1426
1765
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
1427
|
-
}), this.addPreviewListener(
|
|
1766
|
+
}), this.addPreviewListener(Me, () => {
|
|
1428
1767
|
this.readyState = C.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
1429
|
-
}), this.addPreviewListener(
|
|
1768
|
+
}), this.addPreviewListener(Ie, (n) => {
|
|
1430
1769
|
const a = n;
|
|
1431
1770
|
this.readyState = C.CLOSED, this.dispatchEvent(
|
|
1432
1771
|
new CloseEvent("close", {
|
|
@@ -1436,7 +1775,7 @@ class C extends EventTarget {
|
|
|
1436
1775
|
})
|
|
1437
1776
|
), this.cleanup();
|
|
1438
1777
|
}), window.dispatchEvent(
|
|
1439
|
-
new CustomEvent(
|
|
1778
|
+
new CustomEvent(D(Ee, this.channelId), {
|
|
1440
1779
|
detail: { socketId: this.socketId, url: e }
|
|
1441
1780
|
})
|
|
1442
1781
|
);
|
|
@@ -1452,27 +1791,27 @@ class C extends EventTarget {
|
|
|
1452
1791
|
binaryType = "blob";
|
|
1453
1792
|
bufferedAmount = 0;
|
|
1454
1793
|
readyState = C.CONNECTING;
|
|
1455
|
-
socketId =
|
|
1794
|
+
socketId = qe();
|
|
1456
1795
|
listeners = /* @__PURE__ */ new Map();
|
|
1457
1796
|
send(e) {
|
|
1458
1797
|
if (this.readyState !== C.OPEN)
|
|
1459
1798
|
throw new DOMException("Product Agent preview websocket is not open", "InvalidStateError");
|
|
1460
1799
|
window.dispatchEvent(
|
|
1461
|
-
new CustomEvent(
|
|
1800
|
+
new CustomEvent(D(Le, this.channelId), {
|
|
1462
1801
|
detail: { socketId: this.socketId, data: typeof e == "string" ? e : String(e) }
|
|
1463
1802
|
})
|
|
1464
1803
|
);
|
|
1465
1804
|
}
|
|
1466
1805
|
close(e, o) {
|
|
1467
1806
|
this.readyState !== C.CLOSED && (this.readyState = C.CLOSING, window.dispatchEvent(
|
|
1468
|
-
new CustomEvent(
|
|
1807
|
+
new CustomEvent(D(Te, this.channelId), {
|
|
1469
1808
|
detail: { socketId: this.socketId, code: e, reason: o }
|
|
1470
1809
|
})
|
|
1471
1810
|
), this.cleanup());
|
|
1472
1811
|
}
|
|
1473
1812
|
addPreviewListener(e, o) {
|
|
1474
|
-
const n =
|
|
1475
|
-
|
|
1813
|
+
const n = D(e, this.channelId), a = (r) => {
|
|
1814
|
+
r.detail?.socketId === this.socketId && o(r);
|
|
1476
1815
|
};
|
|
1477
1816
|
this.listeners.set(n, a), window.addEventListener(n, a);
|
|
1478
1817
|
}
|
|
@@ -1482,48 +1821,49 @@ class C extends EventTarget {
|
|
|
1482
1821
|
this.listeners.clear();
|
|
1483
1822
|
}
|
|
1484
1823
|
}
|
|
1485
|
-
function
|
|
1486
|
-
const t = window.sessionStorage.getItem(
|
|
1824
|
+
function qe() {
|
|
1825
|
+
const t = window.sessionStorage.getItem(Z);
|
|
1487
1826
|
if (t)
|
|
1488
1827
|
return t;
|
|
1489
1828
|
const e = crypto.randomUUID();
|
|
1490
|
-
return window.sessionStorage.setItem(
|
|
1829
|
+
return window.sessionStorage.setItem(Z, e), e;
|
|
1491
1830
|
}
|
|
1492
|
-
function
|
|
1831
|
+
function D(t, e) {
|
|
1493
1832
|
return `${t}:${e}`;
|
|
1494
1833
|
}
|
|
1495
|
-
function
|
|
1834
|
+
function Ye(t) {
|
|
1496
1835
|
const e = document.currentScript;
|
|
1497
1836
|
if (e instanceof HTMLScriptElement)
|
|
1498
1837
|
return [e];
|
|
1499
1838
|
const o = new URL(t, document.baseURI).href, n = new URL(o);
|
|
1500
1839
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
1501
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
1840
|
+
(a) => a instanceof HTMLScriptElement && Ke(a) && je(a, n)
|
|
1502
1841
|
);
|
|
1503
1842
|
}
|
|
1504
|
-
function
|
|
1505
|
-
for (const e of
|
|
1506
|
-
if (
|
|
1843
|
+
function Ze(t) {
|
|
1844
|
+
for (const e of Ye(t)) {
|
|
1845
|
+
if (le.has(e) || e.dataset.plunoAutoMount === "false")
|
|
1507
1846
|
continue;
|
|
1508
|
-
|
|
1847
|
+
le.add(e);
|
|
1509
1848
|
const o = e.dataset.plunoPreviewChannel;
|
|
1510
|
-
|
|
1849
|
+
De({
|
|
1511
1850
|
token: e.dataset.plunoToken,
|
|
1512
1851
|
tokenEndpoint: e.dataset.plunoTokenEndpoint,
|
|
1513
1852
|
backendUrl: e.dataset.plunoBackendUrl,
|
|
1514
|
-
webSocketFactory: o ?
|
|
1853
|
+
webSocketFactory: o ? $e(o) : void 0,
|
|
1515
1854
|
launcherLabel: e.dataset.plunoLauncherLabel,
|
|
1516
1855
|
accentColor: e.dataset.plunoAccentColor,
|
|
1517
1856
|
colorScheme: e.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
1518
1857
|
fontFamily: e.dataset.plunoFontFamily,
|
|
1858
|
+
scribbleStyle: e.dataset.plunoScribbleStyle === "true",
|
|
1519
1859
|
position: e.dataset.plunoPosition === "bottom-left" ? "bottom-left" : "bottom-right"
|
|
1520
1860
|
}).catch((n) => {
|
|
1521
1861
|
console.error("Failed to mount Pluno Product Agent widget", n);
|
|
1522
1862
|
});
|
|
1523
1863
|
}
|
|
1524
1864
|
}
|
|
1525
|
-
|
|
1865
|
+
Ze(import.meta.url);
|
|
1526
1866
|
export {
|
|
1527
|
-
|
|
1528
|
-
|
|
1867
|
+
$e as createProductAgentPreviewBridgeWebSocketFactory,
|
|
1868
|
+
De as mountPlunoProductAgentWidget
|
|
1529
1869
|
};
|